yuyeon 0.3.2-rc.1 → 0.3.2-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/yuyeon.js +1367 -1346
- package/dist/yuyeon.umd.cjs +3 -3
- package/lib/components/tree-view/YTreeView.js +1 -3
- package/lib/components/tree-view/YTreeView.js.map +1 -1
- package/lib/components/tree-view/tree-view.js +34 -4
- package/lib/components/tree-view/tree-view.js.map +1 -1
- package/lib/components/tree-view/types.js.map +1 -1
- package/package.json +1 -1
- package/types/components/tree-view/YTreeView.d.ts +5 -5
- package/types/components/tree-view/tree-view.d.ts +2 -1
- package/types/components/tree-view/types.d.ts +8 -6
|
@@ -26,7 +26,6 @@ export const YTreeView = defineComponent({
|
|
|
26
26
|
multipleActive: Boolean,
|
|
27
27
|
activeStrategy: {
|
|
28
28
|
type: String,
|
|
29
|
-
// TODO: 'leaf'
|
|
30
29
|
default: 'independent'
|
|
31
30
|
},
|
|
32
31
|
selected: {
|
|
@@ -35,7 +34,6 @@ export const YTreeView = defineComponent({
|
|
|
35
34
|
},
|
|
36
35
|
selectStrategy: {
|
|
37
36
|
type: String,
|
|
38
|
-
// TODO: 'leaf'
|
|
39
37
|
default: 'leaf'
|
|
40
38
|
},
|
|
41
39
|
returnItem: Boolean,
|
|
@@ -159,7 +157,7 @@ export const YTreeView = defineComponent({
|
|
|
159
157
|
let until = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
160
158
|
Object.entries(nodes.value).forEach(_ref2 => {
|
|
161
159
|
let [key, node] = _ref2;
|
|
162
|
-
if (until === true || until >= node.level) {
|
|
160
|
+
if (until === true || Number(until) >= node.level) {
|
|
163
161
|
updateExpanded(key, true);
|
|
164
162
|
}
|
|
165
163
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"YTreeView.js","names":["computed","defineComponent","onMounted","ref","shallowRef","watch","provideTreeView","useRender","differenceBetween","isColorValue","deepEqual","getObjectValueByPath","hasOwnProperty","chooseProps","debounce","YProgressBar","YTreeViewNode","pressYTreeViewNodeProps","filterTreeItem","filterTreeItems","getKeys","treeViewNodeProps","YTreeView","name","props","expanded","type","Array","default","active","multipleActive","Boolean","activeStrategy","String","selected","selectStrategy","returnItem","defaultExpand","Number","filter","Function","searchDebounceWait","emits","setup","_ref","slots","emit","expose","filterItemsFn","excludeItem","expandedCache","nodes","expandedSet","selectedSet","activeSet","searchLoading","excludedSet","issueVnodeState","updateExpanded","updateActive","updateSelected","emitExpanded","emitActive","emitSelected","isExcluded","items","search","arguments","length","undefined","excluded","Set","value","diff","forEach","key","item","itemKey","itemText","itemChildren","expand","getNodeKey","itemOrKey","updateNodes","parentKey","level","children","exist","existNode","vnode","includes","indeterminate","node","childKeys","map","child","add","neo","deep","until","Object","entries","_ref2","stateWatcher","stateSet","updater","emitter","valuesOfKey","v","old","oldKeys","keys","nodeKey","neoKeys","k","oldSelected","oldActive","clear","flush","renderLeaves","slice","leaf","classes","styles","color","activeColor","activeValue","selectedValue","_createVNode","_Fragment","_mergeProps","_createTextVNode"],"sources":["../../../src/components/tree-view/YTreeView.tsx"],"sourcesContent":["import {\n type PropType,\n type Ref,\n computed,\n defineComponent,\n onMounted,\n ref,\n shallowRef,\n watch,\n} from 'vue';\n\nimport { provideTreeView } from '@/components/tree-view/tree-view';\nimport { useRender } from '@/composables/component';\nimport { CandidateKey } from '@/types';\nimport { differenceBetween } from '@/util/array';\nimport { isColorValue } from '@/util/color';\nimport { deepEqual, getObjectValueByPath, hasOwnProperty } from '@/util/common';\nimport { chooseProps } from '@/util/component';\nimport { debounce } from '@/util/debounce';\n\nimport { YProgressBar } from '../progress-bar';\nimport { YTreeViewNode, pressYTreeViewNodeProps } from './YTreeViewNode';\nimport { NodeState, TreeviewFilterFn } from './types';\nimport { filterTreeItem, filterTreeItems, getKeys } from './util';\n\nimport './YTreeView.scss';\n\nconst treeViewNodeProps = pressYTreeViewNodeProps();\n\nexport const YTreeView = defineComponent({\n name: 'YTreeView',\n props: {\n expanded: {\n type: [Array] as PropType<CandidateKey[]>,\n default: () => [],\n },\n active: {\n type: [Array] as PropType<CandidateKey[]>,\n default: () => [],\n },\n multipleActive: Boolean,\n activeStrategy: {\n type: String as PropType<'independent' | 'cascade'>, // TODO: 'leaf'\n default: 'independent',\n },\n selected: {\n type: [Array] as PropType<CandidateKey[]>,\n default: () => [],\n },\n selectStrategy: {\n type: String as PropType<'independent' | 'cascade'>, // TODO: 'leaf'\n default: 'leaf',\n },\n returnItem: Boolean,\n defaultExpand: [Boolean, String, Number],\n filter: Function as PropType<TreeviewFilterFn>,\n searchDebounceWait: {\n type: Number as PropType<number>,\n default: 700,\n },\n ...treeViewNodeProps,\n },\n emits: ['update:expanded', 'update:active', 'update:selected'],\n setup(props, { slots, emit, expose }) {\n const filterItemsFn = shallowRef(\n debounce(excludeItem, props.searchDebounceWait),\n );\n const expandedCache = ref<CandidateKey[]>([]);\n\n const {\n nodes,\n expanded,\n active,\n selected,\n expandedSet,\n selectedSet,\n activeSet,\n searchLoading,\n excludedSet,\n issueVnodeState,\n updateExpanded,\n updateActive,\n updateSelected,\n emitExpanded,\n emitActive,\n emitSelected,\n isExcluded,\n } = provideTreeView(props);\n\n function excludeItem(items: any[], search = '', filter = filterTreeItem) {\n const excluded = new Set<CandidateKey>();\n if (!search) {\n searchLoading.value = false;\n excludedSet.value = excluded;\n const diff = differenceBetween(expandedCache.value, [\n ...expandedSet.value,\n ]);\n diff.forEach((key) => {\n updateExpanded(key, false);\n });\n expandedCache.value.forEach((key) => {\n updateExpanded(key, true);\n });\n return;\n }\n for (const item of items) {\n filterTreeItems(\n filter,\n item,\n search ?? '',\n props.itemKey,\n props.itemText,\n props.itemChildren as string,\n excluded,\n );\n }\n excludedSet.value = excluded;\n searchLoading.value = false;\n expand();\n }\n\n watch(\n () => props.search,\n () => {\n searchLoading.value = true;\n filterItemsFn.value(props.items, props.search, props.filter);\n },\n );\n\n // Util Methods\n function getNodeKey(itemOrKey: any) {\n return props.returnItem\n ? getObjectValueByPath(itemOrKey, props.itemKey)\n : itemOrKey;\n }\n\n // State Methods\n function updateNodes(\n items: any[],\n parentKey: CandidateKey | null = null,\n level = 0,\n ) {\n for (const item of items) {\n const key = getObjectValueByPath(item, props.itemKey);\n const children =\n getObjectValueByPath(item, props.itemChildren as string) ?? [];\n const exist = hasOwnProperty(nodes.value, key);\n const existNode = exist\n ? nodes.value[key]\n : {\n vnode: null,\n selected: selected.value?.includes(key) ?? false,\n indeterminate: false,\n active: active.value?.includes(key) ?? false,\n expanded: expanded.value?.includes(key) ?? false,\n };\n const node: NodeState = {\n vnode: existNode.vnode,\n item,\n level,\n parentKey,\n childKeys: children.map((child: any) =>\n getObjectValueByPath(child, props.itemKey),\n ),\n expanded: children.length > 0 && existNode.expanded,\n active: existNode.active,\n indeterminate: existNode.indeterminate,\n selected: existNode.selected,\n };\n\n updateNodes(children, key, level + 1);\n\n nodes.value[key] = node;\n if (nodes.value[key].expanded) {\n expandedSet.value.add(key);\n }\n if (nodes.value[key].selected) {\n selectedSet.value.add(key);\n }\n if (nodes.value[key].active) {\n activeSet.value.add(key);\n }\n issueVnodeState(key);\n }\n }\n\n watch(\n expandedSet,\n (neo) => {\n if (!props.search) {\n expandedCache.value = [...neo];\n }\n },\n { deep: true },\n );\n\n function expand(until: boolean | string | number = true) {\n Object.entries(nodes.value).forEach(([key, node]) => {\n if (until === true || until >= node.level) {\n updateExpanded(key, true);\n }\n });\n emitExpanded();\n return expandedSet.value;\n }\n\n function stateWatcher(\n value: any[],\n stateSet: Ref<Set<CandidateKey>>,\n updater: (key: CandidateKey, to: boolean) => void,\n emitter: () => void,\n ) {\n const valuesOfKey = props.returnItem\n ? value.map((v) => getObjectValueByPath(v, props.itemKey))\n : value;\n const old = [...stateSet.value];\n if (deepEqual(old, valuesOfKey)) {\n return;\n }\n old.forEach((key) => updater(key, false));\n valuesOfKey.forEach((key) => updater(key, true));\n emitter();\n }\n\n watch(expanded, (neo) => {\n stateWatcher(neo, expandedSet, updateExpanded, emitExpanded);\n });\n\n watch(active, (neo) => {\n stateWatcher(neo, activeSet, updateActive, emitActive);\n });\n\n watch(selected, (neo) => {\n stateWatcher(neo, selectedSet, updateSelected, emitSelected);\n });\n\n watch(\n () => props.items,\n (neo: any[]) => {\n const oldKeys = Object.keys(nodes.value).map((nodeKey) =>\n getObjectValueByPath(nodes.value[nodeKey].item, props.itemKey),\n );\n const neoKeys = getKeys(\n neo,\n props.itemKey,\n props.itemChildren as string,\n );\n const diff = differenceBetween(oldKeys, neoKeys);\n if (diff.length < 1 && neoKeys.length < oldKeys.length) {\n return;\n }\n diff.forEach((k) => delete nodes.value[k]);\n\n // init\n const oldSelected = [...selectedSet.value];\n const oldActive = [...activeSet.value];\n selectedSet.value.clear();\n expandedSet.value.clear();\n activeSet.value.clear();\n updateNodes(neo);\n if (!deepEqual(oldSelected, [...selectedSet.value])) {\n emitSelected();\n }\n if (!deepEqual(oldActive, [...activeSet.value])) {\n emitActive();\n }\n filterItemsFn.value(neo, props.search, props.filter);\n },\n { deep: true, flush: 'sync' },\n );\n\n // Provide & Issue\n\n updateNodes(props.items);\n\n const renderLeaves = computed(() => {\n return props.items.slice().filter((leaf) => {\n return !isExcluded(getObjectValueByPath(leaf, props.itemKey));\n });\n });\n\n const classes = computed(() => {\n return {\n 'y-tree-view': true,\n };\n });\n\n const styles = computed(() => {\n let color = props.activeColor;\n if (props.activeColor && !isColorValue(props.activeColor)) {\n color = `var(--y-theme-${props.activeColor})`;\n }\n return {\n [`--y-tree-view__active-color`]: color,\n };\n });\n\n onMounted(() => {\n if (props.search) {\n searchLoading.value = true;\n excludeItem(props.items, props.search, props.filter);\n }\n\n if (props.defaultExpand != null && props.defaultExpand !== false) {\n expandedCache.value = [...expand(props.defaultExpand)];\n } else {\n expanded.value.forEach((v: any) => updateExpanded(getNodeKey(v), true));\n emitExpanded();\n }\n\n for (const activeValue of props.active.map(getNodeKey)) {\n updateActive(activeValue, true);\n }\n\n for (const selectedValue of props.selected.map(getNodeKey)) {\n updateSelected(selectedValue, true);\n }\n });\n\n expose({\n expand,\n });\n\n useRender(() => {\n return (\n <>\n <div class={classes.value} style={styles.value} role=\"tree\">\n {searchLoading.value && <YProgressBar indeterminate />}\n {renderLeaves.value.length > 0 ? (\n renderLeaves.value.slice().map((leaf) => {\n return (\n <YTreeViewNode\n v-slots={slots}\n key={getObjectValueByPath(leaf, props.itemKey)}\n {...{\n ...chooseProps(props, treeViewNodeProps),\n item: leaf,\n level: 0,\n }}\n ></YTreeViewNode>\n );\n })\n ) : (\n <div class=\"y-tree-view__no-data\">\n {slots['no-data'] ? slots['no-data']() : <span>No Data</span>}\n </div>\n )}\n </div>\n </>\n );\n });\n\n return {\n nodes,\n expandedSet,\n selectedSet,\n activeSet,\n excludedSet,\n searchLoading,\n expandedCache,\n renderLeaves,\n };\n },\n});\n\nexport type YTreeView = InstanceType<typeof YTreeView>;\n"],"mappings":";AAAA,SAGEA,QAAQ,EACRC,eAAe,EACfC,SAAS,EACTC,GAAG,EACHC,UAAU,EACVC,KAAK,QACA,KAAK;AAAC,SAEJC,eAAe;AAAA,SACfC,SAAS;AAAA,SAETC,iBAAiB;AAAA,SACjBC,YAAY;AAAA,SACZC,SAAS,EAAEC,oBAAoB,EAAEC,cAAc;AAAA,SAC/CC,WAAW;AAAA,SACXC,QAAQ;AAAA,SAERC,YAAY;AAAA,SACZC,aAAa,EAAEC,uBAAuB;AAAA,SAEtCC,cAAc,EAAEC,eAAe,EAAEC,OAAO;AAEjD;AAEA,MAAMC,iBAAiB,GAAGJ,uBAAuB,CAAC,CAAC;AAEnD,OAAO,MAAMK,SAAS,GAAGrB,eAAe,CAAC;EACvCsB,IAAI,EAAE,WAAW;EACjBC,KAAK,EAAE;IACLC,QAAQ,EAAE;MACRC,IAAI,EAAE,CAACC,KAAK,CAA6B;MACzCC,OAAO,EAAEA,CAAA,KAAM;IACjB,CAAC;IACDC,MAAM,EAAE;MACNH,IAAI,EAAE,C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C1B,GAAG,CAAE2B,IAAI,IAAK;QACvC,OAAAO,YAAA,CAAAhH,aAAA,EAAAkH,WAAA;UAAA,OAGSvH,oBAAoB,CAAC8G,IAAI,EAAEjG,KAAK,CAACqD,OAAO;QAAC;UAE5C,GAAGhE,WAAW,CAACW,KAAK,EAAEH,iBAAiB,CAAC;UACxCuD,IAAI,EAAE6C,IAAI;UACVpC,KAAK,EAAE;QAAC,IALDxC,KAAK;MASpB,CAAC,CAAC,GAAAmF,YAAA;QAAA;MAAA,IAGCnF,KAAK,CAAC,SAAS,CAAC,GAAGA,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,GAAAmF,YAAA,gBAAAG,gBAAA,aAAuB,EAEhE;IAIT,CAAC,CAAC;IAEF,OAAO;MACLhF,KAAK;MACLC,WAAW;MACXC,WAAW;MACXC,SAAS;MACTE,WAAW;MACXD,aAAa;MACbL,aAAa;MACbqE;IACF,CAAC;EACH;AACF,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"YTreeView.js","names":["computed","defineComponent","onMounted","ref","shallowRef","watch","provideTreeView","useRender","differenceBetween","isColorValue","deepEqual","getObjectValueByPath","hasOwnProperty","chooseProps","debounce","YProgressBar","YTreeViewNode","pressYTreeViewNodeProps","filterTreeItem","filterTreeItems","getKeys","treeViewNodeProps","YTreeView","name","props","expanded","type","Array","default","active","multipleActive","Boolean","activeStrategy","String","selected","selectStrategy","returnItem","defaultExpand","Number","filter","Function","searchDebounceWait","emits","setup","_ref","slots","emit","expose","filterItemsFn","excludeItem","expandedCache","nodes","expandedSet","selectedSet","activeSet","searchLoading","excludedSet","issueVnodeState","updateExpanded","updateActive","updateSelected","emitExpanded","emitActive","emitSelected","isExcluded","items","search","arguments","length","undefined","excluded","Set","value","diff","forEach","key","item","itemKey","itemText","itemChildren","expand","getNodeKey","itemOrKey","updateNodes","parentKey","level","children","exist","existNode","vnode","includes","indeterminate","node","childKeys","map","child","add","neo","deep","until","Object","entries","_ref2","stateWatcher","stateSet","updater","emitter","valuesOfKey","v","old","oldKeys","keys","nodeKey","neoKeys","k","oldSelected","oldActive","clear","flush","renderLeaves","slice","leaf","classes","styles","color","activeColor","activeValue","selectedValue","_createVNode","_Fragment","_mergeProps","_createTextVNode"],"sources":["../../../src/components/tree-view/YTreeView.tsx"],"sourcesContent":["import {\n type PropType,\n type Ref,\n computed,\n defineComponent,\n onMounted,\n ref,\n shallowRef,\n watch,\n} from 'vue';\n\nimport { provideTreeView } from '@/components/tree-view/tree-view';\nimport { useRender } from '@/composables/component';\nimport { CandidateKey } from '@/types';\nimport { differenceBetween } from '@/util/array';\nimport { isColorValue } from '@/util/color';\nimport { deepEqual, getObjectValueByPath, hasOwnProperty } from '@/util/common';\nimport { chooseProps } from '@/util/component';\nimport { debounce } from '@/util/debounce';\n\nimport { YProgressBar } from '../progress-bar';\nimport { YTreeViewNode, pressYTreeViewNodeProps } from './YTreeViewNode';\nimport { NodeState, TreeviewFilterFn } from './types';\nimport { filterTreeItem, filterTreeItems, getKeys } from './util';\n\nimport './YTreeView.scss';\n\nconst treeViewNodeProps = pressYTreeViewNodeProps();\n\nexport const YTreeView = defineComponent({\n name: 'YTreeView',\n props: {\n expanded: {\n type: [Array] as PropType<CandidateKey[]>,\n default: () => [],\n },\n active: {\n type: [Array] as PropType<CandidateKey[]>,\n default: () => [],\n },\n multipleActive: Boolean,\n activeStrategy: {\n type: String as PropType<'independent' | 'cascade' | 'relative'>,\n default: 'independent',\n },\n selected: {\n type: [Array] as PropType<CandidateKey[]>,\n default: () => [],\n },\n selectStrategy: {\n type: String as PropType<'independent' | 'cascade'>,\n default: 'leaf',\n },\n returnItem: Boolean,\n defaultExpand: [Boolean, String, Number],\n filter: Function as PropType<TreeviewFilterFn>,\n searchDebounceWait: {\n type: Number as PropType<number>,\n default: 700,\n },\n ...treeViewNodeProps,\n },\n emits: ['update:expanded', 'update:active', 'update:selected'],\n setup(props, { slots, emit, expose }) {\n const filterItemsFn = shallowRef(\n debounce(excludeItem, props.searchDebounceWait),\n );\n const expandedCache = ref<CandidateKey[]>([]);\n\n const {\n nodes,\n expanded,\n active,\n selected,\n expandedSet,\n selectedSet,\n activeSet,\n searchLoading,\n excludedSet,\n issueVnodeState,\n updateExpanded,\n updateActive,\n updateSelected,\n emitExpanded,\n emitActive,\n emitSelected,\n isExcluded,\n } = provideTreeView(props);\n\n function excludeItem(items: any[], search = '', filter = filterTreeItem) {\n const excluded = new Set<CandidateKey>();\n if (!search) {\n searchLoading.value = false;\n excludedSet.value = excluded;\n const diff = differenceBetween(expandedCache.value, [\n ...expandedSet.value,\n ]);\n diff.forEach((key) => {\n updateExpanded(key, false);\n });\n expandedCache.value.forEach((key) => {\n updateExpanded(key, true);\n });\n return;\n }\n for (const item of items) {\n filterTreeItems(\n filter,\n item,\n search ?? '',\n props.itemKey,\n props.itemText,\n props.itemChildren as string,\n excluded,\n );\n }\n excludedSet.value = excluded;\n searchLoading.value = false;\n expand();\n }\n\n watch(\n () => props.search,\n () => {\n searchLoading.value = true;\n filterItemsFn.value(props.items, props.search, props.filter);\n },\n );\n\n // Util Methods\n function getNodeKey(itemOrKey: any) {\n return props.returnItem\n ? getObjectValueByPath(itemOrKey, props.itemKey)\n : itemOrKey;\n }\n\n // State Methods\n function updateNodes(\n items: any[],\n parentKey: CandidateKey | null = null,\n level = 0,\n ) {\n for (const item of items) {\n const key = getObjectValueByPath(item, props.itemKey);\n const children =\n getObjectValueByPath(item, props.itemChildren as string) ?? [];\n const exist = hasOwnProperty(nodes.value, key);\n const existNode = exist\n ? nodes.value[key]\n : {\n vnode: null,\n selected: selected.value?.includes(key) ?? false,\n indeterminate: false,\n active: active.value?.includes(key) ?? false,\n expanded: expanded.value?.includes(key) ?? false,\n };\n const node: NodeState = {\n vnode: existNode.vnode,\n item,\n level,\n parentKey,\n childKeys: children.map((child: any) =>\n getObjectValueByPath(child, props.itemKey),\n ),\n expanded: children.length > 0 && existNode.expanded,\n active: existNode.active,\n indeterminate: existNode.indeterminate,\n selected: existNode.selected,\n };\n\n updateNodes(children, key, level + 1);\n\n nodes.value[key] = node;\n if (nodes.value[key].expanded) {\n expandedSet.value.add(key);\n }\n if (nodes.value[key].selected) {\n selectedSet.value.add(key);\n }\n if (nodes.value[key].active) {\n activeSet.value.add(key);\n }\n issueVnodeState(key);\n }\n }\n\n watch(\n expandedSet,\n (neo) => {\n if (!props.search) {\n expandedCache.value = [...neo];\n }\n },\n { deep: true },\n );\n\n function expand(until: boolean | string | number = true) {\n Object.entries(nodes.value).forEach(([key, node]) => {\n if (until === true || Number(until) >= node.level) {\n updateExpanded(key, true);\n }\n });\n emitExpanded();\n return expandedSet.value;\n }\n\n function stateWatcher(\n value: any[],\n stateSet: Ref<Set<CandidateKey>>,\n updater: (key: CandidateKey, to: boolean) => void,\n emitter: () => void,\n ) {\n const valuesOfKey = props.returnItem\n ? value.map((v) => getObjectValueByPath(v, props.itemKey))\n : value;\n const old = [...stateSet.value];\n if (deepEqual(old, valuesOfKey)) {\n return;\n }\n old.forEach((key) => updater(key, false));\n valuesOfKey.forEach((key) => updater(key, true));\n emitter();\n }\n\n watch(expanded, (neo) => {\n stateWatcher(neo, expandedSet, updateExpanded, emitExpanded);\n });\n\n watch(active, (neo) => {\n stateWatcher(neo, activeSet, updateActive, emitActive);\n });\n\n watch(selected, (neo) => {\n stateWatcher(neo, selectedSet, updateSelected, emitSelected);\n });\n\n watch(\n () => props.items,\n (neo: any[]) => {\n const oldKeys = Object.keys(nodes.value).map((nodeKey) =>\n getObjectValueByPath(nodes.value[nodeKey].item, props.itemKey),\n );\n const neoKeys = getKeys(\n neo,\n props.itemKey,\n props.itemChildren as string,\n );\n const diff = differenceBetween(oldKeys, neoKeys);\n if (diff.length < 1 && neoKeys.length < oldKeys.length) {\n return;\n }\n diff.forEach((k) => delete nodes.value[k]);\n\n // init\n const oldSelected = [...selectedSet.value];\n const oldActive = [...activeSet.value];\n selectedSet.value.clear();\n expandedSet.value.clear();\n activeSet.value.clear();\n updateNodes(neo);\n if (!deepEqual(oldSelected, [...selectedSet.value])) {\n emitSelected();\n }\n if (!deepEqual(oldActive, [...activeSet.value])) {\n emitActive();\n }\n filterItemsFn.value(neo, props.search, props.filter);\n },\n { deep: true, flush: 'sync' },\n );\n\n // Provide & Issue\n\n updateNodes(props.items);\n\n const renderLeaves = computed(() => {\n return props.items.slice().filter((leaf) => {\n return !isExcluded(getObjectValueByPath(leaf, props.itemKey));\n });\n });\n\n const classes = computed(() => {\n return {\n 'y-tree-view': true,\n };\n });\n\n const styles = computed(() => {\n let color = props.activeColor;\n if (props.activeColor && !isColorValue(props.activeColor)) {\n color = `var(--y-theme-${props.activeColor})`;\n }\n return {\n [`--y-tree-view__active-color`]: color,\n };\n });\n\n onMounted(() => {\n if (props.search) {\n searchLoading.value = true;\n excludeItem(props.items, props.search, props.filter);\n }\n\n if (props.defaultExpand != null && props.defaultExpand !== false) {\n expandedCache.value = [...expand(props.defaultExpand)];\n } else {\n expanded.value.forEach((v: any) => updateExpanded(getNodeKey(v), true));\n emitExpanded();\n }\n\n for (const activeValue of props.active.map(getNodeKey)) {\n updateActive(activeValue, true);\n }\n\n for (const selectedValue of props.selected.map(getNodeKey)) {\n updateSelected(selectedValue, true);\n }\n });\n\n expose({\n expand,\n });\n\n useRender(() => {\n return (\n <>\n <div class={classes.value} style={styles.value} role=\"tree\">\n {searchLoading.value && <YProgressBar indeterminate />}\n {renderLeaves.value.length > 0 ? (\n renderLeaves.value.slice().map((leaf) => {\n return (\n <YTreeViewNode\n v-slots={slots}\n key={getObjectValueByPath(leaf, props.itemKey)}\n {...{\n ...chooseProps(props, treeViewNodeProps),\n item: leaf,\n level: 0,\n }}\n ></YTreeViewNode>\n );\n })\n ) : (\n <div class=\"y-tree-view__no-data\">\n {slots['no-data'] ? slots['no-data']() : <span>No Data</span>}\n </div>\n )}\n </div>\n </>\n );\n });\n\n return {\n nodes,\n expandedSet,\n selectedSet,\n activeSet,\n excludedSet,\n searchLoading,\n expandedCache,\n renderLeaves,\n };\n },\n});\n\n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Aa;MACbL,aAAa;MACbqE;IACF,CAAC;EACH;AACF,CAAC,CAAC"}
|
|
@@ -86,14 +86,29 @@ export function provideTreeView(props) {
|
|
|
86
86
|
if (props.activeSingleModifier && event?.getModifierState(props.activeSingleModifier)) {
|
|
87
87
|
return;
|
|
88
88
|
}
|
|
89
|
-
if (props.multipleActive && props.activeStrategy === 'cascade') {
|
|
89
|
+
if (props.multipleActive && (props.activeStrategy === 'cascade' || props.activeStrategy === 'relative')) {
|
|
90
90
|
for (const descendant of getDescendants(key)) {
|
|
91
91
|
if (descendant in nodes.value) {
|
|
92
|
-
|
|
93
|
-
nodes.value[descendant].active = to;
|
|
94
|
-
issueVnodeState(descendant);
|
|
92
|
+
setActive(descendant, to);
|
|
95
93
|
}
|
|
96
94
|
}
|
|
95
|
+
if (props.activeStrategy === 'relative') {
|
|
96
|
+
let grand = node.parentKey;
|
|
97
|
+
do {
|
|
98
|
+
const parentKey = grand;
|
|
99
|
+
grand = null;
|
|
100
|
+
if (!parentKey) continue;
|
|
101
|
+
const parent = nodes.value[parentKey];
|
|
102
|
+
if (!parent) continue;
|
|
103
|
+
const all = isChildrenAll(parentKey, 'active', to);
|
|
104
|
+
if (all || !to) {
|
|
105
|
+
setActive(parentKey, to);
|
|
106
|
+
if (parent.parentKey) {
|
|
107
|
+
grand = parent.parentKey;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
} while (grand != null);
|
|
111
|
+
}
|
|
97
112
|
}
|
|
98
113
|
}
|
|
99
114
|
function updateSelected(key, to) {
|
|
@@ -118,6 +133,21 @@ export function provideTreeView(props) {
|
|
|
118
133
|
}
|
|
119
134
|
}
|
|
120
135
|
}
|
|
136
|
+
function isChildrenAll(key, stateKey, to) {
|
|
137
|
+
const node = nodes.value[key];
|
|
138
|
+
if (!node) return false;
|
|
139
|
+
const {
|
|
140
|
+
childKeys
|
|
141
|
+
} = node;
|
|
142
|
+
return childKeys.every(childKey => {
|
|
143
|
+
return nodes.value[childKey]?.[stateKey] === to;
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
function setActive(key, to) {
|
|
147
|
+
to ? activeSet.value.add(key) : activeSet.value.delete(key);
|
|
148
|
+
nodes.value[key].active = to;
|
|
149
|
+
issueVnodeState(key);
|
|
150
|
+
}
|
|
121
151
|
|
|
122
152
|
// Emit
|
|
123
153
|
function emitExpanded() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tree-view.js","names":["inject","provide","ref","shallowRef","useModelDuplex","getObjectValueByPath","Y_TREE_VIEW","Symbol","for","provideTreeView","props","nodes","expanded","active","selected","expandedSet","Set","selectedSet","activeSet","searchLoading","excludedSet","getDescendants","key","descendants","childKeys","value","push","remains","slice","length","childKey","splice","item","isExcluded","search","has","issueVnodeState","node","vnode","indeterminate","updateExpanded","to","children","itemChildren","Array","isArray","add","delete","updateActive","event","inactiveKey","multipleActive","requiredActive","size","activeSingleModifier","getModifierState","activeStrategy","descendant","updateSelected","selectStrategy","emitExpanded","arr","returnItem","map","emitActive","emitSelected","register","useTreeView","instance","Error"],"sources":["../../../src/components/tree-view/tree-view.ts"],"sourcesContent":["import {\n InjectionKey,\n Ref,\n inject,\n provide,\n ref,\n shallowRef,\n} from 'vue';\n\nimport { useModelDuplex } from '@/composables';\nimport { CandidateKey } from '@/types';\nimport { getObjectValueByPath } from '@/util';\n\nexport const Y_TREE_VIEW: InjectionKey<{\n register: (key: CandidateKey, vnode: any) => void;\n updateExpanded: (key: CandidateKey, to: boolean) => void;\n updateActive: (key: CandidateKey, to: boolean, event?: MouseEvent) => void;\n updateSelected: (key: CandidateKey, to: boolean) => void;\n searchLoading: Ref<boolean>;\n isExcluded: (key: CandidateKey) => boolean;\n emitExpanded: () => void;\n emitActive: () => void;\n emitSelected: () => void;\n}> = Symbol.for('YTreeView');\n\n// TODO: props type\nexport function provideTreeView(props: any) {\n const nodes = ref<Record<CandidateKey, any>>({});\n const expanded = useModelDuplex(props, 'expanded');\n const active = useModelDuplex(props, 'active');\n const selected = useModelDuplex(props, 'selected');\n\n const expandedSet = ref(new Set<CandidateKey>());\n const selectedSet = ref(new Set<CandidateKey>());\n const activeSet = ref(new Set<CandidateKey>());\n const searchLoading = shallowRef(false);\n const excludedSet = ref(new Set<CandidateKey>());\n\n // Utils\n function getDescendants(key: CandidateKey) {\n const descendants: CandidateKey[] = [];\n const { childKeys } = nodes.value[key];\n descendants.push(...childKeys);\n const remains: CandidateKey[] = childKeys.slice();\n\n while (remains.length > 0) {\n const childKey: CandidateKey = remains.splice(0, 1)[0];\n const item = nodes.value[childKey];\n if (item) {\n descendants.push(...item.childKeys);\n remains.push(...item.childKeys);\n }\n }\n\n return descendants;\n }\n\n // Search\n function isExcluded(key: CandidateKey) {\n return !!props.search && excludedSet.value.has(key);\n }\n\n //\n function issueVnodeState(key: CandidateKey) {\n const node = nodes.value[key];\n if (node?.vnode) {\n node.vnode.active = node.active;\n node.vnode.selected = node.selected;\n node.vnode.indeterminate = node.indeterminate;\n node.vnode.expanded = node.expanded;\n }\n }\n\n // Update\n function updateExpanded(key: CandidateKey, to: boolean) {\n if (!(key in nodes.value)) return;\n const node = nodes.value[key];\n const children = getObjectValueByPath(\n node.item,\n props.itemChildren as string,\n );\n if (Array.isArray(children) && children.length > 0) {\n to ? expandedSet.value.add(key) : expandedSet.value.delete(key);\n node.expanded = to;\n issueVnodeState(key);\n }\n }\n\n function updateActive(key: CandidateKey, to: boolean, event?: MouseEvent) {\n if (!(key in nodes.value)) return;\n const node = nodes.value[key];\n let inactiveKey = !to ? key : '';\n if (!props.multipleActive && to && !activeSet.value.has(key)) {\n [inactiveKey] = [...activeSet.value];\n }\n if (to) {\n activeSet.value.add(key);\n node.active = true;\n issueVnodeState(key);\n } else {\n if (\n props.requiredActive &&\n activeSet.value.size === 1 &&\n key === inactiveKey\n ) {\n issueVnodeState(key);\n return;\n }\n }\n if (inactiveKey && inactiveKey in nodes.value) {\n activeSet.value.delete(inactiveKey);\n nodes.value[inactiveKey].active = false;\n issueVnodeState(inactiveKey);\n }\n\n if (\n props.activeSingleModifier &&\n event?.getModifierState(props.activeSingleModifier)\n ) {\n return;\n }\n\n if (props.multipleActive && props.activeStrategy === 'cascade') {\n for (const descendant of getDescendants(key)) {\n if (descendant in nodes.value) {\n to\n ? activeSet.value.add(descendant)\n : activeSet.value.delete(descendant);\n nodes.value[descendant].active = to;\n issueVnodeState(descendant);\n }\n }\n }\n }\n\n function updateSelected(key: CandidateKey, to: boolean) {\n if (!(key in nodes.value)) return;\n const node = nodes.value[key];\n\n if (to) {\n selectedSet.value.add(key);\n node.selected = true;\n }\n\n if (!to && key in nodes.value) {\n selectedSet.value.delete(key);\n nodes.value[key].selected = false;\n issueVnodeState(key);\n }\n\n if (props.selectStrategy === 'cascade') {\n for (const descendant of getDescendants(key)) {\n if (descendant in nodes.value) {\n to\n ? selectedSet.value.add(descendant)\n : selectedSet.value.delete(descendant);\n nodes.value[descendant].selected = to;\n issueVnodeState(descendant);\n }\n }\n }\n }\n\n // Emit\n function emitExpanded() {\n const arr = [...expandedSet.value];\n expanded.value = props.returnItem\n ? arr.map((key) => nodes.value[key].item)\n : arr;\n }\n\n function emitActive() {\n const arr = [...activeSet.value];\n active.value = props.returnItem\n ? arr.map((key) => nodes.value[key].item)\n : arr;\n }\n\n function emitSelected() {\n const arr = [...selectedSet.value];\n selected.value = props.returnItem\n ? arr.map((key) => nodes.value[key].item)\n : arr;\n }\n\n // Inject\n function register(key: CandidateKey, vnode: any) {\n if (nodes.value[key]) {\n nodes.value[key].vnode = vnode;\n }\n\n issueVnodeState(key);\n }\n\n provide(Y_TREE_VIEW, {\n register,\n updateExpanded,\n updateActive,\n updateSelected,\n searchLoading,\n isExcluded,\n emitExpanded,\n emitActive,\n emitSelected,\n });\n\n return {\n nodes,\n expanded,\n active,\n selected,\n issueVnodeState,\n updateExpanded,\n updateActive,\n updateSelected,\n emitExpanded,\n emitActive,\n emitSelected,\n expandedSet,\n selectedSet,\n activeSet,\n searchLoading,\n excludedSet,\n isExcluded,\n };\n}\n\nexport function useTreeView() {\n const instance = inject(Y_TREE_VIEW);\n if (!instance) throw new Error('Not found provided YTreeView');\n return instance;\n}\n"],"mappings":"AAAA,SAGEA,MAAM,EACNC,OAAO,EACPC,GAAG,EACHC,UAAU,QACL,KAAK;AAAC,SAEJC,cAAc;AAAA,SAEdC,oBAAoB;AAE7B,OAAO,MAAMC,WAUX,GAAGC,MAAM,CAACC,GAAG,CAAC,WAAW,CAAC;;AAE5B;AACA,OAAO,SAASC,eAAeA,CAACC,KAAU,EAAE;EAC1C,MAAMC,KAAK,GAAGT,GAAG,CAA4B,CAAC,CAAC,CAAC;EAChD,MAAMU,QAAQ,GAAGR,cAAc,CAACM,KAAK,EAAE,UAAU,CAAC;EAClD,MAAMG,MAAM,GAAGT,cAAc,CAACM,KAAK,EAAE,QAAQ,CAAC;EAC9C,MAAMI,QAAQ,GAAGV,cAAc,CAACM,KAAK,EAAE,UAAU,CAAC;EAElD,MAAMK,WAAW,GAAGb,GAAG,CAAC,IAAIc,GAAG,CAAe,CAAC,CAAC;EAChD,MAAMC,WAAW,GAAGf,GAAG,CAAC,IAAIc,GAAG,CAAe,CAAC,CAAC;EAChD,MAAME,SAAS,GAAGhB,GAAG,CAAC,IAAIc,GAAG,CAAe,CAAC,CAAC;EAC9C,MAAMG,aAAa,GAAGhB,UAAU,CAAC,KAAK,CAAC;EACvC,MAAMiB,WAAW,GAAGlB,GAAG,CAAC,IAAIc,GAAG,CAAe,CAAC,CAAC;;EAEhD;EACA,SAASK,cAAcA,CAACC,GAAiB,EAAE;IACzC,MAAMC,WAA2B,GAAG,EAAE;IACtC,MAAM;MAAEC;IAAU,CAAC,GAAGb,KAAK,CAACc,KAAK,CAACH,GAAG,CAAC;IACtCC,WAAW,CAACG,IAAI,CAAC,GAAGF,SAAS,CAAC;IAC9B,MAAMG,OAAuB,GAAGH,SAAS,CAACI,KAAK,CAAC,CAAC;IAEjD,OAAOD,OAAO,CAACE,MAAM,GAAG,CAAC,EA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,GAAG;EACT;;EAEA;EACA,SAASK,QAAQA,CAAC5C,GAAiB,EAAEgB,KAAU,EAAE;IAC/C,IAAI3B,KAAK,CAACc,KAAK,CAACH,GAAG,CAAC,EAAE;MACpBX,KAAK,CAACc,KAAK,CAACH,GAAG,CAAC,CAACgB,KAAK,GAAGA,KAAK;IAChC;IAEAF,eAAe,CAACd,GAAG,CAAC;EACtB;EAEArB,OAAO,CAACK,WAAW,EAAE;IACnB4D,QAAQ;IACR1B,cAAc;IACdQ,YAAY;IACZU,cAAc;IACdvC,aAAa;IACbc,UAAU;IACV2B,YAAY;IACZI,UAAU;IACVC;EACF,CAAC,CAAC;EAEF,OAAO;IACLtD,KAAK;IACLC,QAAQ;IACRC,MAAM;IACNC,QAAQ;IACRsB,eAAe;IACfI,cAAc;IACdQ,YAAY;IACZU,cAAc;IACdE,YAAY;IACZI,UAAU;IACVC,YAAY;IACZlD,WAAW;IACXE,WAAW;IACXC,SAAS;IACTC,aAAa;IACbC,WAAW;IACXa;EACF,CAAC;AACH;AAEA,OAAO,SAASkC,WAAWA,CAAA,EAAG;EAC5B,MAAMC,QAAQ,GAAGpE,MAAM,CAACM,WAAW,CAAC;EACpC,IAAI,CAAC8D,QAAQ,EAAE,MAAM,IAAIC,KAAK,CAAC,8BAA8B,CAAC;EAC9D,OAAOD,QAAQ;AACjB"}
|
|
1
|
+
{"version":3,"file":"tree-view.js","names":["inject","provide","ref","shallowRef","useModelDuplex","getObjectValueByPath","Y_TREE_VIEW","Symbol","for","provideTreeView","props","nodes","expanded","active","selected","expandedSet","Set","selectedSet","activeSet","searchLoading","excludedSet","getDescendants","key","descendants","childKeys","value","push","remains","slice","length","childKey","splice","item","isExcluded","search","has","issueVnodeState","node","vnode","indeterminate","updateExpanded","to","children","itemChildren","Array","isArray","add","delete","updateActive","event","inactiveKey","multipleActive","requiredActive","size","activeSingleModifier","getModifierState","activeStrategy","descendant","setActive","grand","parentKey","parent","all","isChildrenAll","updateSelected","selectStrategy","stateKey","every","emitExpanded","arr","returnItem","map","emitActive","emitSelected","register","useTreeView","instance","Error"],"sources":["../../../src/components/tree-view/tree-view.ts"],"sourcesContent":["import { InjectionKey, Ref, inject, provide, ref, shallowRef } from 'vue';\n\n\n\nimport { NodeState } from '@/components/tree-view/types';\nimport { useModelDuplex } from '@/composables';\nimport { CandidateKey } from '@/types';\nimport { getObjectValueByPath } from '@/util';\n\n\nexport const Y_TREE_VIEW: InjectionKey<{\n register: (key: CandidateKey, vnode: any) => void;\n updateExpanded: (key: CandidateKey, to: boolean) => void;\n updateActive: (key: CandidateKey, to: boolean, event?: MouseEvent) => void;\n updateSelected: (key: CandidateKey, to: boolean) => void;\n searchLoading: Ref<boolean>;\n isExcluded: (key: CandidateKey) => boolean;\n emitExpanded: () => void;\n emitActive: () => void;\n emitSelected: () => void;\n}> = Symbol.for('YTreeView');\n\n// TODO: props type\nexport function provideTreeView(props: any) {\n const nodes = ref<Record<CandidateKey, NodeState>>({});\n const expanded = useModelDuplex(props, 'expanded');\n const active = useModelDuplex(props, 'active');\n const selected = useModelDuplex(props, 'selected');\n\n const expandedSet = ref(new Set<CandidateKey>());\n const selectedSet = ref(new Set<CandidateKey>());\n const activeSet = ref(new Set<CandidateKey>());\n const searchLoading = shallowRef(false);\n const excludedSet = ref(new Set<CandidateKey>());\n\n // Utils\n function getDescendants(key: CandidateKey) {\n const descendants: CandidateKey[] = [];\n const { childKeys } = nodes.value[key];\n descendants.push(...childKeys);\n const remains: CandidateKey[] = childKeys.slice();\n\n while (remains.length > 0) {\n const childKey: CandidateKey = remains.splice(0, 1)[0];\n const item = nodes.value[childKey];\n if (item) {\n descendants.push(...item.childKeys);\n remains.push(...item.childKeys);\n }\n }\n\n return descendants;\n }\n\n // Search\n function isExcluded(key: CandidateKey) {\n return !!props.search && excludedSet.value.has(key);\n }\n\n //\n function issueVnodeState(key: CandidateKey) {\n const node = nodes.value[key];\n if (node?.vnode) {\n node.vnode.active = node.active;\n node.vnode.selected = node.selected;\n node.vnode.indeterminate = node.indeterminate;\n node.vnode.expanded = node.expanded;\n }\n }\n\n // Update\n function updateExpanded(key: CandidateKey, to: boolean) {\n if (!(key in nodes.value)) return;\n const node = nodes.value[key];\n const children = getObjectValueByPath(\n node.item,\n props.itemChildren as string,\n );\n if (Array.isArray(children) && children.length > 0) {\n to ? expandedSet.value.add(key) : expandedSet.value.delete(key);\n node.expanded = to;\n issueVnodeState(key);\n }\n }\n\n function updateActive(key: CandidateKey, to: boolean, event?: MouseEvent) {\n if (!(key in nodes.value)) return;\n const node = nodes.value[key];\n let inactiveKey = !to ? key : '';\n if (!props.multipleActive && to && !activeSet.value.has(key)) {\n [inactiveKey] = [...activeSet.value];\n }\n if (to) {\n activeSet.value.add(key);\n node.active = true;\n issueVnodeState(key);\n } else {\n if (\n props.requiredActive &&\n activeSet.value.size === 1 &&\n key === inactiveKey\n ) {\n issueVnodeState(key);\n return;\n }\n }\n if (inactiveKey && inactiveKey in nodes.value) {\n activeSet.value.delete(inactiveKey);\n nodes.value[inactiveKey].active = false;\n issueVnodeState(inactiveKey);\n }\n\n if (\n props.activeSingleModifier &&\n event?.getModifierState(props.activeSingleModifier)\n ) {\n return;\n }\n\n if (\n props.multipleActive &&\n (props.activeStrategy === 'cascade' ||\n props.activeStrategy === 'relative')\n ) {\n for (const descendant of getDescendants(key)) {\n if (descendant in nodes.value) {\n setActive(descendant, to);\n }\n }\n if (props.activeStrategy === 'relative') {\n let grand: CandidateKey | null = node.parentKey;\n do {\n const parentKey = grand;\n grand = null;\n if (!parentKey) continue;\n const parent = nodes.value[parentKey];\n if (!parent) continue;\n const all = isChildrenAll(parentKey, 'active', to);\n if (all || !to) {\n setActive(parentKey, to);\n if (parent.parentKey) {\n grand = (parent.parentKey);\n }\n }\n } while(grand != null)\n }\n }\n }\n\n function updateSelected(key: CandidateKey, to: boolean) {\n if (!(key in nodes.value)) return;\n const node = nodes.value[key];\n\n if (to) {\n selectedSet.value.add(key);\n node.selected = true;\n }\n\n if (!to && key in nodes.value) {\n selectedSet.value.delete(key);\n nodes.value[key].selected = false;\n issueVnodeState(key);\n }\n\n if (props.selectStrategy === 'cascade') {\n for (const descendant of getDescendants(key)) {\n if (descendant in nodes.value) {\n to\n ? selectedSet.value.add(descendant)\n : selectedSet.value.delete(descendant);\n nodes.value[descendant].selected = to;\n issueVnodeState(descendant);\n }\n }\n }\n }\n\n function isChildrenAll(key: CandidateKey, stateKey: string, to: boolean) {\n const node = nodes.value[key];\n if (!node) return false;\n const { childKeys } = node;\n return childKeys.every((childKey) => {\n return (nodes.value[childKey] as any)?.[stateKey] === to;\n });\n }\n\n function setActive(key: CandidateKey, to: boolean) {\n to\n ? activeSet.value.add(key)\n : activeSet.value.delete(key);\n nodes.value[key].active = to;\n issueVnodeState(key);\n }\n\n // Emit\n function emitExpanded() {\n const arr = [...expandedSet.value];\n expanded.value = props.returnItem\n ? arr.map((key) => nodes.value[key].item)\n : arr;\n }\n\n function emitActive() {\n const arr = [...activeSet.value];\n active.value = props.returnItem\n ? arr.map((key) => nodes.value[key].item)\n : arr;\n }\n\n function emitSelected() {\n const arr = [...selectedSet.value];\n selected.value = props.returnItem\n ? arr.map((key) => nodes.value[key].item)\n : arr;\n }\n\n // Inject\n function register(key: CandidateKey, vnode: any) {\n if (nodes.value[key]) {\n nodes.value[key].vnode = vnode;\n }\n\n issueVnodeState(key);\n }\n\n provide(Y_TREE_VIEW, {\n register,\n updateExpanded,\n updateActive,\n updateSelected,\n searchLoading,\n isExcluded,\n emitExpanded,\n emitActive,\n emitSelected,\n });\n\n return {\n nodes,\n expanded,\n active,\n selected,\n issueVnodeState,\n updateExpanded,\n updateActive,\n updateSelected,\n emitExpanded,\n emitActive,\n emitSelected,\n expandedSet,\n selectedSet,\n activeSet,\n searchLoading,\n excludedSet,\n isExcluded,\n };\n}\n\nexport function useTreeView() {\n const instance = inject(Y_TREE_VIEW);\n if (!instance) throw new Error('Not found provided YTreeView');\n return instance;\n}\n"],"mappings":"AAAA,SAA4BA,MAAM,EAAE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CAACd,GAAG,CAAC;EACtB;EAEArB,OAAO,CAACK,WAAW,EAAE;IACnBoE,QAAQ;IACRlC,cAAc;IACdQ,YAAY;IACZgB,cAAc;IACd7C,aAAa;IACbc,UAAU;IACVmC,YAAY;IACZI,UAAU;IACVC;EACF,CAAC,CAAC;EAEF,OAAO;IACL9D,KAAK;IACLC,QAAQ;IACRC,MAAM;IACNC,QAAQ;IACRsB,eAAe;IACfI,cAAc;IACdQ,YAAY;IACZgB,cAAc;IACdI,YAAY;IACZI,UAAU;IACVC,YAAY;IACZ1D,WAAW;IACXE,WAAW;IACXC,SAAS;IACTC,aAAa;IACbC,WAAW;IACXa;EACF,CAAC;AACH;AAEA,OAAO,SAAS0C,WAAWA,CAAA,EAAG;EAC5B,MAAMC,QAAQ,GAAG5E,MAAM,CAACM,WAAW,CAAC;EACpC,IAAI,CAACsE,QAAQ,EAAE,MAAM,IAAIC,KAAK,CAAC,8BAA8B,CAAC;EAC9D,OAAOD,QAAQ;AACjB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../../../src/components/tree-view/types.ts"],"sourcesContent":["import { type ComponentPublicInstance } from 'vue';\
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../../src/components/tree-view/types.ts"],"sourcesContent":["import { type ComponentPublicInstance } from 'vue';\n\nimport type { CandidateKey } from '@/types';\n\nexport interface ItemState {\n selected: boolean;\n indeterminate: boolean;\n active: boolean;\n expanded: boolean;\n}\n\nexport interface NodeState extends ItemState {\n childKeys: CandidateKey[];\n item: any;\n parentKey: null | CandidateKey;\n vnode:\n | null\n | (ComponentPublicInstance & ItemState);\n level: number;\n}\n\nexport type TreeviewFilterFn = (\n item: any,\n search: string,\n itemText: string,\n) => boolean;\n"],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PropType, Ref } from 'vue';
|
|
2
2
|
import { CandidateKey } from '../../types';
|
|
3
|
-
import { TreeviewFilterFn } from './types';
|
|
3
|
+
import { NodeState, TreeviewFilterFn } from './types';
|
|
4
4
|
|
|
5
5
|
export declare const YTreeView: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
|
|
6
6
|
items: {
|
|
@@ -46,7 +46,7 @@ export declare const YTreeView: import('vue').DefineComponent<import('vue').Extr
|
|
|
46
46
|
};
|
|
47
47
|
multipleActive: BooleanConstructor;
|
|
48
48
|
activeStrategy: {
|
|
49
|
-
type: PropType<"cascade" | "independent">;
|
|
49
|
+
type: PropType<"relative" | "cascade" | "independent">;
|
|
50
50
|
default: string;
|
|
51
51
|
};
|
|
52
52
|
selected: {
|
|
@@ -65,7 +65,7 @@ export declare const YTreeView: import('vue').DefineComponent<import('vue').Extr
|
|
|
65
65
|
default: number;
|
|
66
66
|
};
|
|
67
67
|
}>, {
|
|
68
|
-
nodes: Ref<Record<CandidateKey,
|
|
68
|
+
nodes: Ref<Record<CandidateKey, NodeState>, Record<CandidateKey, NodeState>>;
|
|
69
69
|
expandedSet: Ref<Set<CandidateKey> & Omit<Set<CandidateKey>, keyof Set<any>>, Set<CandidateKey> | (Set<CandidateKey> & Omit<Set<CandidateKey>, keyof Set<any>>)>;
|
|
70
70
|
selectedSet: Ref<Set<CandidateKey> & Omit<Set<CandidateKey>, keyof Set<any>>, Set<CandidateKey> | (Set<CandidateKey> & Omit<Set<CandidateKey>, keyof Set<any>>)>;
|
|
71
71
|
activeSet: Ref<Set<CandidateKey> & Omit<Set<CandidateKey>, keyof Set<any>>, Set<CandidateKey> | (Set<CandidateKey> & Omit<Set<CandidateKey>, keyof Set<any>>)>;
|
|
@@ -117,7 +117,7 @@ export declare const YTreeView: import('vue').DefineComponent<import('vue').Extr
|
|
|
117
117
|
};
|
|
118
118
|
multipleActive: BooleanConstructor;
|
|
119
119
|
activeStrategy: {
|
|
120
|
-
type: PropType<"cascade" | "independent">;
|
|
120
|
+
type: PropType<"relative" | "cascade" | "independent">;
|
|
121
121
|
default: string;
|
|
122
122
|
};
|
|
123
123
|
selected: {
|
|
@@ -154,7 +154,7 @@ export declare const YTreeView: import('vue').DefineComponent<import('vue').Extr
|
|
|
154
154
|
activeColor: string;
|
|
155
155
|
enableSelect: boolean;
|
|
156
156
|
multipleActive: boolean;
|
|
157
|
-
activeStrategy: "cascade" | "independent";
|
|
157
|
+
activeStrategy: "relative" | "cascade" | "independent";
|
|
158
158
|
selectStrategy: "cascade" | "independent";
|
|
159
159
|
searchDebounceWait: number;
|
|
160
160
|
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { InjectionKey, Ref } from 'vue';
|
|
2
|
+
import { NodeState } from './types';
|
|
2
3
|
import { CandidateKey } from '../../types';
|
|
3
4
|
|
|
4
5
|
export declare const Y_TREE_VIEW: InjectionKey<{
|
|
@@ -13,7 +14,7 @@ export declare const Y_TREE_VIEW: InjectionKey<{
|
|
|
13
14
|
emitSelected: () => void;
|
|
14
15
|
}>;
|
|
15
16
|
export declare function provideTreeView(props: any): {
|
|
16
|
-
nodes: Ref<Record<CandidateKey,
|
|
17
|
+
nodes: Ref<Record<CandidateKey, NodeState>, Record<CandidateKey, NodeState>>;
|
|
17
18
|
expanded: Ref<any, any> & {
|
|
18
19
|
readonly rxValue: any;
|
|
19
20
|
};
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import { ComponentPublicInstance } from 'vue';
|
|
2
2
|
import { CandidateKey } from '../../types';
|
|
3
3
|
|
|
4
|
-
export interface
|
|
4
|
+
export interface ItemState {
|
|
5
|
+
selected: boolean;
|
|
6
|
+
indeterminate: boolean;
|
|
7
|
+
active: boolean;
|
|
8
|
+
expanded: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface NodeState extends ItemState {
|
|
5
11
|
childKeys: CandidateKey[];
|
|
6
12
|
item: any;
|
|
7
13
|
parentKey: null | CandidateKey;
|
|
8
|
-
vnode: null | ComponentPublicInstance;
|
|
14
|
+
vnode: null | (ComponentPublicInstance & ItemState);
|
|
9
15
|
level: number;
|
|
10
|
-
selected: false;
|
|
11
|
-
indeterminate: false;
|
|
12
|
-
active: false;
|
|
13
|
-
expanded: false;
|
|
14
16
|
}
|
|
15
17
|
export type TreeviewFilterFn = (item: any, search: string, itemText: string) => boolean;
|