openStrategies.mjs.map 3.6 KB

1
  1. {"version":3,"file":"openStrategies.mjs","names":["singleOpenStrategy","open","_ref","id","value","opened","parents","newOpened","Set","add","parent","get","delete","select","multipleOpenStrategy","_ref2","listOpenStrategy","_ref3","path","push"],"sources":["../../../src/composables/nested/openStrategies.ts"],"sourcesContent":["export type OpenStrategyFn = (data: {\n id: unknown\n value: boolean\n opened: Set<unknown>\n children: Map<unknown, unknown[]>\n parents: Map<unknown, unknown>\n event?: Event\n}) => Set<unknown>\n\nexport type OpenSelectStrategyFn = (data: {\n id: unknown\n value: boolean\n opened: Set<unknown>\n selected: Map<unknown, 'on' | 'off' | 'indeterminate'>\n children: Map<unknown, unknown[]>\n parents: Map<unknown, unknown>\n event?: Event\n}) => Set<unknown> | null\n\nexport type OpenStrategy = {\n open: OpenStrategyFn\n select: OpenSelectStrategyFn\n}\n\nexport const singleOpenStrategy: OpenStrategy = {\n open: ({ id, value, opened, parents }) => {\n if (value) {\n const newOpened = new Set<unknown>()\n newOpened.add(id)\n\n let parent = parents.get(id)\n\n while (parent != null) {\n newOpened.add(parent)\n parent = parents.get(parent)\n }\n\n return newOpened\n } else {\n opened.delete(id)\n return opened\n }\n },\n select: () => null,\n}\n\nexport const multipleOpenStrategy: OpenStrategy = {\n open: ({ id, value, opened, parents }) => {\n if (value) {\n let parent = parents.get(id)\n opened.add(id)\n\n while (parent != null && parent !== id) {\n opened.add(parent)\n parent = parents.get(parent)\n }\n\n return opened\n } else {\n opened.delete(id)\n }\n return opened\n },\n select: () => null,\n}\n\nexport const listOpenStrategy: OpenStrategy = {\n open: multipleOpenStrategy.open,\n select: ({ id, value, opened, parents }) => {\n if (!value) return opened\n\n const path: unknown[] = []\n\n let parent = parents.get(id)\n\n while (parent != null) {\n path.push(parent)\n parent = parents.get(parent)\n }\n\n return new Set(path)\n },\n}\n"],"mappings":"AAwBA,OAAO,MAAMA,kBAAgC,GAAG;EAC9CC,IAAI,EAAEC,IAAA,IAAoC;IAAA,IAAnC;MAAE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