yuyeon 0.3.0-rc.4 → 0.3.0-rc.6
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 +2881 -2827
- package/dist/yuyeon.umd.cjs +3 -3
- package/lib/components/dialog/YDialog.mjs +5 -1
- package/lib/components/dialog/YDialog.mjs.map +1 -1
- package/lib/components/text-ellipsis/YTextEllipsis.mjs +3 -0
- package/lib/components/text-ellipsis/YTextEllipsis.mjs.map +1 -1
- package/lib/components/tree-view/YTreeView.mjs +26 -142
- package/lib/components/tree-view/YTreeView.mjs.map +1 -1
- package/lib/components/tree-view/YTreeViewNode.mjs +7 -5
- package/lib/components/tree-view/YTreeViewNode.mjs.map +1 -1
- package/lib/components/tree-view/tree-view.mjs +179 -0
- package/lib/components/tree-view/tree-view.mjs.map +1 -0
- package/package.json +1 -1
- package/types/components/text-ellipsis/YTextEllipsis.d.ts +3 -0
- package/types/components/tree-view/YTreeView.d.ts +7 -7
- package/types/components/tree-view/YTreeViewNode.d.ts +11 -1
- package/types/components/tree-view/tree-view.d.ts +50 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"YTreeViewNode.mjs","names":["computed","getCurrentInstance","inject","mergeProps","onBeforeMount","ref","resolveComponent","pressItemsPropsOptions","useRender","getObjectValueByPath","defineComponent","propsFactory","YButton","YIconCheckbox","YIconExpand","YPlate","YTextHighlighter","YExpandVTransition","pressYTreeViewNodeProps","search","String","disableTransition","Boolean","enableActive","activeClass","Array","activeSingleModifier","requiredActive","activeColor","type","default","enableSelect","onMouseenterContainer","Function","onMouseleaveContainer","onMousemoveContainer","itemKey","YTreeViewNode","name","components","props","item","Object","level","Number","slots","setup","_ref","expose","YTreeNode","vm","treeView","container$","expanded","active","selected","immediate","children","itemChildren","slice","imLeaf","value","length","classes","styles","contentText","itemText","slotProps","searchLoading","leaves","filter","leaf","isExcluded","onClick","e","to","updateActive","myKey","emitActive","onClickExpand","stopPropagation","updateExpanded","emitExpanded","onClickSelect","updateSelected","emitSelected","indentSpacer","i","push","_createVNode","leading","text","trailing","map","_mergeProps","_len","arguments","args","_key","_len2","_key2","_len3","_key3","_len4","_key4","register","exposed"],"sources":["../../../src/components/tree-view/YTreeViewNode.tsx"],"sourcesContent":["import {\r\n type PropType,\r\n type SlotsType,\r\n type VNodeArrayChildren,\r\n computed,\r\n getCurrentInstance,\r\n inject,\r\n mergeProps,\r\n onBeforeMount,\r\n ref,\r\n resolveComponent,\r\n} from 'vue';\r\n\r\nimport { pressItemsPropsOptions } from '@/abstract/items';\r\nimport { useRender } from '@/composables/component';\r\nimport { getObjectValueByPath } from '@/util/common';\r\nimport { defineComponent } from '@/util/component';\r\nimport { propsFactory } from '@/util/component';\r\n\r\nimport { YButton } from '../button';\r\nimport { YIconCheckbox, YIconExpand } from '../icons';\r\nimport { YPlate } from '../plate';\r\nimport { YTextHighlighter } from '../text-highlighter/YTextHighlighter';\r\nimport { YExpandVTransition } from '../transitions';\r\n\r\nexport const pressYTreeViewNodeProps = propsFactory(\r\n {\r\n search: String,\r\n disableTransition: Boolean,\r\n enableActive: Boolean,\r\n activeClass: [String, Array],\r\n activeSingleModifier: String,\r\n requiredActive: Boolean,\r\n activeColor: {\r\n type: String,\r\n default: 'primary',\r\n },\r\n enableSelect: Boolean,\r\n onMouseenterContainer: Function,\r\n onMouseleaveContainer: Function,\r\n onMousemoveContainer: Function,\r\n ...pressItemsPropsOptions({\r\n itemKey: 'id',\r\n }),\r\n },\r\n 'YTreeViewNode',\r\n);\r\n\r\nexport const YTreeViewNode = defineComponent({\r\n name: 'YTreeNode',\r\n components: {\r\n YButton,\r\n YIconExpand,\r\n YPlate,\r\n YIconCheckbox,\r\n },\r\n props: {\r\n item: {\r\n type: Object as PropType<any>,\r\n },\r\n level: {\r\n type: Number as PropType<number>,\r\n default: 0,\r\n },\r\n ...pressYTreeViewNodeProps(),\r\n },\r\n slots: Object as SlotsType<{\r\n default: any;\r\n 'expand-icon': any;\r\n leading: any;\r\n trailing: any;\r\n }>,\r\n setup(props, { slots, expose }) {\r\n const YTreeNode = resolveComponent('YTreeViewNode', true) as any;\r\n const vm = getCurrentInstance();\r\n const treeView = inject<any>('tree-view');\r\n const container$ = ref<HTMLElement>();\r\n\r\n const expanded = ref(false);\r\n const active = ref(false);\r\n const selected = ref(false);\r\n const immediate = ref(false);\r\n\r\n const children = computed(() => {\r\n return (\r\n getObjectValueByPath(props.item, props.itemChildren as string) ?? []\r\n ).slice();\r\n });\r\n\r\n const imLeaf = computed(() => children.value.length < 1);\r\n\r\n const classes = computed(() => {\r\n return {\r\n 'y-tree-view-node': true,\r\n 'y-tree-view-node--leaf': imLeaf.value,\r\n 'y-tree-view-node--expanded': expanded.value,\r\n 'y-tree-view-node--active': active.value,\r\n };\r\n });\r\n\r\n const styles = computed(() => {\r\n return {\r\n '--tree-view-node--level': props.level,\r\n };\r\n });\r\n\r\n const contentText = computed(() => {\r\n return getObjectValueByPath(props.item, props.itemText) ?? '';\r\n });\r\n\r\n const slotProps = computed(() => {\r\n return {\r\n level: props.level,\r\n imLeaf: imLeaf.value,\r\n };\r\n });\r\n\r\n const searchLoading = computed(() => {\r\n return treeView.searchLoading.value;\r\n });\r\n\r\n const leaves = computed(() => {\r\n return children.value.filter((leaf: any) => {\r\n return !treeView.isExcluded(getObjectValueByPath(leaf, props.itemKey));\r\n });\r\n });\r\n\r\n function onClick(e: MouseEvent) {\r\n const to = !active.value;\r\n active.value = to;\r\n treeView.updateActive(myKey.value, to, e);\r\n treeView.emitActive();\r\n }\r\n\r\n function onClickExpand(e: MouseEvent) {\r\n e.stopPropagation();\r\n const to = !expanded.value;\r\n expanded.value = to;\r\n treeView.updateExpanded(myKey.value, to);\r\n treeView.emitExpanded();\r\n }\r\n\r\n function onClickSelect(e: MouseEvent) {\r\n e.stopPropagation();\r\n const to = !selected.value;\r\n selected.value = to;\r\n treeView.updateSelected(myKey.value, to);\r\n treeView.emitSelected();\r\n }\r\n\r\n function onMouseenterContainer(e: MouseEvent) {\r\n props.onMouseenterContainer?.(e, {\r\n ...slotProps.value,\r\n item: props.item,\r\n });\r\n }\r\n\r\n function onMouseleaveContainer(e: MouseEvent) {\r\n props.onMouseleaveContainer?.(e, {\r\n ...slotProps.value,\r\n item: props.item,\r\n });\r\n }\r\n\r\n function onMousemoveContainer(e: MouseEvent) {\r\n props.onMousemoveContainer?.(e, { ...slotProps.value, item: props.item });\r\n }\r\n\r\n useRender(() => {\r\n const indentSpacer: VNodeArrayChildren = [];\r\n for (let i = 0; i < props.level; i += 1) {\r\n indentSpacer.push(\r\n <div class={'y-tree-view-node__indent-spacer'}></div>,\r\n );\r\n }\r\n\r\n return (\r\n <div\r\n class={classes.value}\r\n style={styles.value}\r\n role=\"treeitem\"\r\n data-level={props.level}\r\n >\r\n <div\r\n ref={container$}\r\n class={'y-tree-view-node__container'}\r\n onClick={(e: MouseEvent) =>\r\n props.enableActive ? onClick(e) : void 0\r\n }\r\n onMouseenter={props.onMouseenterContainer && onMouseenterContainer}\r\n onMouseleave={props.onMouseleaveContainer && onMouseleaveContainer}\r\n onMousemove={props.onMousemoveContainer && onMousemoveContainer}\r\n >\r\n <YPlate />\r\n <div class={'y-tree-view-node__indents'}>{indentSpacer}</div>\r\n {/* EXPAND */}\r\n {!imLeaf.value && leaves.value.length > 0 ? (\r\n <YButton\r\n class={'y-tree-view-node__expand-icon'}\r\n variation={'icon'}\r\n onClick={onClickExpand}\r\n >\r\n {slots['expand-icon'] ? (\r\n slots['expand-icon']()\r\n ) : (\r\n <YIconExpand></YIconExpand>\r\n )}\r\n </YButton>\r\n ) : (\r\n <i class={'y-tree-view-node__no-expand-icon'}></i>\r\n )}\r\n {/* SELECT */}\r\n {props.enableSelect && (\r\n <div class={'y-tree-view-node__select'} onClick={onClickSelect}>\r\n <YIconCheckbox checked={selected.value}></YIconCheckbox>\r\n </div>\r\n )}\r\n {/* CONTENT */}\r\n <div class={'y-tree-view-node__content'}>\r\n {slots.leading && (\r\n <div class={'y-tree-view-node__leading'}>\r\n {slots.leading(slotProps.value)}\r\n </div>\r\n )}\r\n <div class={'y-tree-view-node__text'}>\r\n {slots.default ? (\r\n slots.default?.({\r\n text: contentText.value,\r\n item: props.item,\r\n ...slotProps.value,\r\n })\r\n ) : props.search && !searchLoading.value ? (\r\n <YTextHighlighter\r\n text={contentText.value}\r\n keyword={props.search}\r\n ></YTextHighlighter>\r\n ) : (\r\n contentText.value\r\n )}\r\n </div>\r\n {slots.trailing && (\r\n <div class={'y-tree-view-node__trailing'}>\r\n {slots.trailing(slotProps.value)}\r\n </div>\r\n )}\r\n </div>\r\n </div>\r\n {/* CHILDREN */}\r\n {children.value.length > 0 && (\r\n <YExpandVTransition disabled={props.disableTransition}>\r\n {expanded.value && (\r\n <div class={['y-tree-view-node__leaves']} role=\"tree\">\r\n {leaves.value.map((item: any) => {\r\n return (\r\n <YTreeNode\r\n {...mergeProps(props)}\r\n key={getObjectValueByPath(item, props.itemKey)}\r\n level={(props.level ?? 0) + 1}\r\n item={item}\r\n >\r\n {{\r\n default:\r\n slots.default &&\r\n ((...args: any[]) => slots.default?.(...args)),\r\n 'expand-icon':\r\n slots['expand-icon'] &&\r\n ((...args: any[]) =>\r\n slots['expand-icon']?.(...args)),\r\n leading:\r\n slots.leading &&\r\n ((...args: any[]) => slots.leading?.(...args)),\r\n trailing:\r\n slots.trailing &&\r\n ((...args: any[]) => slots.trailing?.(...args)),\r\n }}\r\n </YTreeNode>\r\n );\r\n })}\r\n </div>\r\n )}\r\n </YExpandVTransition>\r\n )}\r\n </div>\r\n );\r\n });\r\n\r\n const myKey = computed(() => {\r\n return getObjectValueByPath(props.item, props.itemKey);\r\n });\r\n\r\n expose({\r\n myKey,\r\n expanded,\r\n active,\r\n selected,\r\n immediate,\r\n });\r\n\r\n onBeforeMount(() => {\r\n treeView?.register?.(myKey.value, vm!.exposed);\r\n });\r\n\r\n return {\r\n treeView,\r\n myKey,\r\n expanded,\r\n active,\r\n selected,\r\n immediate,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EAAEsD,QAAQ,GAAG5B,KAAK,CAAChB,KAAK,EAAEX,EAAE,CAAEwD,OAAO,CAAC;IAChD,CAAC,CAAC;IAEF,OAAO;MACLvD,QAAQ;MACR0B,KAAK;MACLxB,QAAQ;MACRC,MAAM;MACNC,QAAQ;MACRC;IACF,CAAC;EACH;AACF,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"YTreeViewNode.mjs","names":["computed","getCurrentInstance","mergeProps","onBeforeMount","ref","resolveComponent","pressItemsPropsOptions","useTreeView","useRender","getObjectValueByPath","defineComponent","propsFactory","YButton","YIconCheckbox","YIconExpand","YPlate","YTextHighlighter","YExpandVTransition","pressYTreeViewNodeProps","search","String","disableTransition","Boolean","enableActive","activeClass","Array","activeSingleModifier","requiredActive","activeColor","type","default","enableSelect","onMouseenterContainer","Function","onMouseleaveContainer","onMousemoveContainer","itemKey","YTreeViewNode","name","components","props","item","Object","level","Number","slots","setup","_ref","expose","YTreeNode","vm","treeView","container$","expanded","active","selected","immediate","children","itemChildren","slice","imLeaf","value","length","classes","styles","contentText","itemText","slotProps","searchLoading","leaves","filter","leaf","isExcluded","onClick","e","to","updateActive","myKey","emitActive","onClickExpand","stopPropagation","updateExpanded","emitExpanded","onClickSelect","updateSelected","emitSelected","indentSpacer","i","push","_createVNode","leading","text","trailing","map","_mergeProps","_len","arguments","args","_key","_len2","_key2","_len3","_key3","_len4","_key4","nodeState","register"],"sources":["../../../src/components/tree-view/YTreeViewNode.tsx"],"sourcesContent":["import {\n type PropType,\n type SlotsType,\n type VNodeArrayChildren,\n computed,\n getCurrentInstance,\n mergeProps,\n onBeforeMount,\n ref,\n resolveComponent,\n} from 'vue';\n\nimport { pressItemsPropsOptions } from '@/abstract/items';\nimport { useTreeView } from '@/components/tree-view/tree-view';\nimport { useRender } from '@/composables/component';\nimport { getObjectValueByPath } from '@/util/common';\nimport { defineComponent } from '@/util/component';\nimport { propsFactory } from '@/util/component';\n\nimport { YButton } from '../button';\nimport { YIconCheckbox, YIconExpand } from '../icons';\nimport { YPlate } from '../plate';\nimport { YTextHighlighter } from '../text-highlighter/YTextHighlighter';\nimport { YExpandVTransition } from '../transitions';\n\nexport const pressYTreeViewNodeProps = propsFactory(\n {\n search: String,\n disableTransition: Boolean,\n enableActive: Boolean,\n activeClass: [String, Array],\n activeSingleModifier: String,\n requiredActive: Boolean,\n activeColor: {\n type: String,\n default: 'primary',\n },\n enableSelect: Boolean,\n onMouseenterContainer: Function,\n onMouseleaveContainer: Function,\n onMousemoveContainer: Function,\n ...pressItemsPropsOptions({\n itemKey: 'id',\n }),\n },\n 'YTreeViewNode',\n);\n\nexport const YTreeViewNode = defineComponent({\n name: 'YTreeNode',\n components: {\n YButton,\n YIconExpand,\n YPlate,\n YIconCheckbox,\n },\n props: {\n item: {\n type: Object as PropType<any>,\n },\n level: {\n type: Number as PropType<number>,\n default: 0,\n },\n ...pressYTreeViewNodeProps(),\n },\n slots: Object as SlotsType<{\n default: any;\n 'expand-icon': any;\n leading: any;\n trailing: any;\n }>,\n setup(props, { slots, expose }) {\n const YTreeNode = resolveComponent('YTreeViewNode', true) as any;\n const vm = getCurrentInstance();\n const treeView = useTreeView();\n const container$ = ref<HTMLElement>();\n\n const expanded = ref(false);\n const active = ref(false);\n const selected = ref(false);\n const immediate = ref(false);\n\n const children = computed(() => {\n return (\n getObjectValueByPath(props.item, props.itemChildren as string) ?? []\n ).slice();\n });\n\n const imLeaf = computed(() => children.value.length < 1);\n\n const classes = computed(() => {\n return {\n 'y-tree-view-node': true,\n 'y-tree-view-node--leaf': imLeaf.value,\n 'y-tree-view-node--expanded': expanded.value,\n 'y-tree-view-node--active': active.value,\n };\n });\n\n const styles = computed(() => {\n return {\n '--tree-view-node--level': props.level,\n };\n });\n\n const contentText = computed(() => {\n return getObjectValueByPath(props.item, props.itemText) ?? '';\n });\n\n const slotProps = computed(() => {\n return {\n level: props.level,\n imLeaf: imLeaf.value,\n };\n });\n\n const searchLoading = computed(() => {\n return treeView.searchLoading.value;\n });\n\n const leaves = computed(() => {\n return children.value.filter((leaf: any) => {\n return !treeView.isExcluded(getObjectValueByPath(leaf, props.itemKey));\n });\n });\n\n function onClick(e: MouseEvent) {\n const to = !active.value;\n active.value = to;\n treeView.updateActive(myKey.value, to, e);\n treeView.emitActive();\n }\n\n function onClickExpand(e: MouseEvent) {\n e.stopPropagation();\n const to = !expanded.value;\n expanded.value = to;\n treeView.updateExpanded(myKey.value, to);\n treeView.emitExpanded();\n }\n\n function onClickSelect(e: MouseEvent) {\n e.stopPropagation();\n const to = !selected.value;\n selected.value = to;\n treeView.updateSelected(myKey.value, to);\n treeView.emitSelected();\n }\n\n function onMouseenterContainer(e: MouseEvent) {\n props.onMouseenterContainer?.(e, {\n ...slotProps.value,\n item: props.item,\n });\n }\n\n function onMouseleaveContainer(e: MouseEvent) {\n props.onMouseleaveContainer?.(e, {\n ...slotProps.value,\n item: props.item,\n });\n }\n\n function onMousemoveContainer(e: MouseEvent) {\n props.onMousemoveContainer?.(e, { ...slotProps.value, item: props.item });\n }\n\n useRender(() => {\n const indentSpacer: VNodeArrayChildren = [];\n for (let i = 0; i < props.level; i += 1) {\n indentSpacer.push(\n <div class={'y-tree-view-node__indent-spacer'}></div>,\n );\n }\n\n return (\n <div\n class={classes.value}\n style={styles.value}\n role=\"treeitem\"\n data-level={props.level}\n >\n <div\n ref={container$}\n class={'y-tree-view-node__container'}\n onClick={(e: MouseEvent) =>\n props.enableActive ? onClick(e) : void 0\n }\n onMouseenter={props.onMouseenterContainer && onMouseenterContainer}\n onMouseleave={props.onMouseleaveContainer && onMouseleaveContainer}\n onMousemove={props.onMousemoveContainer && onMousemoveContainer}\n >\n <YPlate />\n <div class={'y-tree-view-node__indents'}>{indentSpacer}</div>\n {/* EXPAND */}\n {!imLeaf.value && leaves.value.length > 0 ? (\n <YButton\n class={'y-tree-view-node__expand-icon'}\n variation={'icon'}\n onClick={onClickExpand}\n >\n {slots['expand-icon'] ? (\n slots['expand-icon']()\n ) : (\n <YIconExpand></YIconExpand>\n )}\n </YButton>\n ) : (\n <i class={'y-tree-view-node__no-expand-icon'}></i>\n )}\n {/* SELECT */}\n {props.enableSelect && (\n <div class={'y-tree-view-node__select'} onClick={onClickSelect}>\n <YIconCheckbox checked={selected.value}></YIconCheckbox>\n </div>\n )}\n {/* CONTENT */}\n <div class={'y-tree-view-node__content'}>\n {slots.leading && (\n <div class={'y-tree-view-node__leading'}>\n {slots.leading(slotProps.value)}\n </div>\n )}\n <div class={'y-tree-view-node__text'}>\n {slots.default ? (\n slots.default?.({\n text: contentText.value,\n item: props.item,\n ...slotProps.value,\n })\n ) : props.search && !searchLoading.value ? (\n <YTextHighlighter\n text={contentText.value}\n keyword={props.search}\n ></YTextHighlighter>\n ) : (\n contentText.value\n )}\n </div>\n {slots.trailing && (\n <div class={'y-tree-view-node__trailing'}>\n {slots.trailing(slotProps.value)}\n </div>\n )}\n </div>\n </div>\n {/* CHILDREN */}\n {children.value.length > 0 && (\n <YExpandVTransition disabled={props.disableTransition}>\n {expanded.value && (\n <div class={['y-tree-view-node__leaves']} role=\"tree\">\n {leaves.value.map((item: any) => {\n return (\n <YTreeNode\n {...mergeProps(props)}\n key={getObjectValueByPath(item, props.itemKey)}\n level={(props.level ?? 0) + 1}\n item={item}\n >\n {{\n default:\n slots.default &&\n ((...args: any[]) => slots.default?.(...args)),\n 'expand-icon':\n slots['expand-icon'] &&\n ((...args: any[]) =>\n slots['expand-icon']?.(...args)),\n leading:\n slots.leading &&\n ((...args: any[]) => slots.leading?.(...args)),\n trailing:\n slots.trailing &&\n ((...args: any[]) => slots.trailing?.(...args)),\n }}\n </YTreeNode>\n );\n })}\n </div>\n )}\n </YExpandVTransition>\n )}\n </div>\n );\n });\n\n const myKey = computed(() => {\n return getObjectValueByPath(props.item, props.itemKey);\n });\n\n const nodeState = {\n myKey,\n expanded,\n active,\n selected,\n immediate,\n };\n\n expose(nodeState);\n\n onBeforeMount(() => {\n treeView?.register?.(myKey.value, nodeState);\n });\n\n return {\n treeView,\n myKey,\n expanded,\n active,\n selected,\n immediate,\n };\n },\n});\n\nexport type YTreeNode = InstanceType<typeof YTreeViewNode>;\n"],"mappings":";AAAA,SAIEA,QAAQ,EACRC,kBAAkB,EAClBC,UAAU,EACVC,aAAa,EACbC,GAAG,EACHC,gBAAgB,QACX,KAAK;AAAC,SAEJC,sBAAsB;AAAA,SACtBC,WAAW;AAAA,SACXC,SAAS;AAAA,SACTC,oBAAoB;AAAA,SACpBC,eAAe;AAAA,SACfC,YAAY;AAAA,SAEZC,OAAO;AAAA,SACPC,aAAa,EAAEC,WAAW;AAAA,SAC1BC,MAAM;AAAA,SACNC,gBAAgB;AAAA,SAChBC,kBAAkB;AAE3B,OAAO,MAAMC,uBAAuB,GAAGP,YAAY,CACjD;EACEQ,MAAM,EAAEC,MAAM;EACdC,iBAAiB,EAAEC,OAAO;EAC1BC,YAAY,EAAED,OAAO;EACrBE,WAAW,EAAE,CAACJ,MAAM,EAAEK,KAAK,CAAC;EAC5BC,oBAAoB,EAAEN,MAAM;EAC5BO,cAAc,EAAEL,OAAO;EACvBM,WAAW,EAAE;IACXC,IAAI,EAAET,MAAM;IACZU,OAAO,EAAE;EACX,CAAC;EACDC,YAAY,EAAET,OAAO;EACrBU,qBAAqB,EAAEC,QAAQ;EAC/BC,qBAAqB,EAAED,QAAQ;EAC/BE,oBAAoB,EAAEF,QAAQ;EAC9B,GAAG3B,sBAAsB,CAAC;IACxB8B,OAAO,EAAE;EACX,CAAC;AACH,CAAC,EACD,eACF,CAAC;AAED,OAAO,MAAMC,aAAa,GAAG3B,eAAe,CAAC;EAC3C4B,IAAI,EAAE,WAAW;EACjBC,UAAU,EAAE;IACV3B,OAAO;IACPE,WAAW;IACXC,MAAM;IACNF;EACF,CAAC;EACD2B,KAAK,EAAE;IACLC,IAAI,EAAE;MACJZ,IAAI,EAAEa;IACR,CAAC;IACDC,KAAK,EAAE;MACLd,IAAI,EAAEe,MAA0B;MAChCd,OAAO,EAAE;IACX,CAAC;IACD,GA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SAAS,CAAC;IAEjBtG,aAAa,CAAC,MAAM;MAClBgD,QAAQ,EAAEuD,QAAQ,GAAG7B,KAAK,CAAChB,KAAK,EAAE4C,SAAS,CAAC;IAC9C,CAAC,CAAC;IAEF,OAAO;MACLtD,QAAQ;MACR0B,KAAK;MACLxB,QAAQ;MACRC,MAAM;MACNC,QAAQ;MACRC;IACF,CAAC;EACH;AACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { inject, provide, ref, shallowRef } from 'vue';
|
|
2
|
+
import { useModelDuplex } from "../../composables/index.mjs";
|
|
3
|
+
import { getObjectValueByPath } from "../../util/index.mjs";
|
|
4
|
+
export const Y_TREE_VIEW = Symbol.for('YTreeView');
|
|
5
|
+
|
|
6
|
+
// TODO: props type
|
|
7
|
+
export function provideTreeView(props) {
|
|
8
|
+
const nodes = ref({});
|
|
9
|
+
const expanded = useModelDuplex(props, 'expanded');
|
|
10
|
+
const active = useModelDuplex(props, 'active');
|
|
11
|
+
const selected = useModelDuplex(props, 'selected');
|
|
12
|
+
const expandedSet = ref(new Set());
|
|
13
|
+
const selectedSet = ref(new Set());
|
|
14
|
+
const activeSet = ref(new Set());
|
|
15
|
+
const searchLoading = shallowRef(false);
|
|
16
|
+
const excludedSet = ref(new Set());
|
|
17
|
+
|
|
18
|
+
// Utils
|
|
19
|
+
function getDescendants(key) {
|
|
20
|
+
const descendants = [];
|
|
21
|
+
const {
|
|
22
|
+
childKeys
|
|
23
|
+
} = nodes.value[key];
|
|
24
|
+
descendants.push(...childKeys);
|
|
25
|
+
const remains = childKeys.slice();
|
|
26
|
+
while (remains.length > 0) {
|
|
27
|
+
const childKey = remains.splice(0, 1)[0];
|
|
28
|
+
const item = nodes.value[childKey];
|
|
29
|
+
if (item) {
|
|
30
|
+
descendants.push(...item.childKeys);
|
|
31
|
+
remains.push(...item.childKeys);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return descendants;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Search
|
|
38
|
+
function isExcluded(key) {
|
|
39
|
+
return !!props.search && excludedSet.value.has(key);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
//
|
|
43
|
+
function issueVnodeState(key) {
|
|
44
|
+
const node = nodes.value[key];
|
|
45
|
+
if (node?.vnode) {
|
|
46
|
+
node.vnode.active = node.active;
|
|
47
|
+
node.vnode.selected = node.selected;
|
|
48
|
+
node.vnode.indeterminate = node.indeterminate;
|
|
49
|
+
node.vnode.expanded = node.expanded;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Update
|
|
54
|
+
function updateExpanded(key, to) {
|
|
55
|
+
if (!(key in nodes.value)) return;
|
|
56
|
+
const node = nodes.value[key];
|
|
57
|
+
const children = getObjectValueByPath(node.item, props.itemChildren);
|
|
58
|
+
if (Array.isArray(children) && children.length > 0) {
|
|
59
|
+
to ? expandedSet.value.add(key) : expandedSet.value.delete(key);
|
|
60
|
+
node.expanded = to;
|
|
61
|
+
issueVnodeState(key);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
function updateActive(key, to, event) {
|
|
65
|
+
if (!(key in nodes.value)) return;
|
|
66
|
+
const node = nodes.value[key];
|
|
67
|
+
let inactiveKey = !to ? key : '';
|
|
68
|
+
if (!props.multipleActive && to && !activeSet.value.has(key)) {
|
|
69
|
+
[inactiveKey] = [...activeSet.value];
|
|
70
|
+
}
|
|
71
|
+
if (to) {
|
|
72
|
+
activeSet.value.add(key);
|
|
73
|
+
node.active = true;
|
|
74
|
+
issueVnodeState(key);
|
|
75
|
+
} else {
|
|
76
|
+
if (props.requiredActive && activeSet.value.size === 1 && key === inactiveKey) {
|
|
77
|
+
issueVnodeState(key);
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
if (inactiveKey && inactiveKey in nodes.value) {
|
|
82
|
+
activeSet.value.delete(inactiveKey);
|
|
83
|
+
nodes.value[inactiveKey].active = false;
|
|
84
|
+
issueVnodeState(inactiveKey);
|
|
85
|
+
}
|
|
86
|
+
if (props.activeSingleModifier && event?.getModifierState(props.activeSingleModifier)) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
if (props.multipleActive && props.activeStrategy === 'cascade') {
|
|
90
|
+
for (const descendant of getDescendants(key)) {
|
|
91
|
+
if (descendant in nodes.value) {
|
|
92
|
+
to ? activeSet.value.add(descendant) : activeSet.value.delete(descendant);
|
|
93
|
+
nodes.value[descendant].active = to;
|
|
94
|
+
issueVnodeState(descendant);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
function updateSelected(key, to) {
|
|
100
|
+
if (!(key in nodes.value)) return;
|
|
101
|
+
const node = nodes.value[key];
|
|
102
|
+
if (to) {
|
|
103
|
+
selectedSet.value.add(key);
|
|
104
|
+
node.selected = true;
|
|
105
|
+
}
|
|
106
|
+
if (!to && key in nodes.value) {
|
|
107
|
+
selectedSet.value.delete(key);
|
|
108
|
+
nodes.value[key].selected = false;
|
|
109
|
+
issueVnodeState(key);
|
|
110
|
+
}
|
|
111
|
+
if (props.selectStrategy === 'cascade') {
|
|
112
|
+
for (const descendant of getDescendants(key)) {
|
|
113
|
+
if (descendant in nodes.value) {
|
|
114
|
+
to ? selectedSet.value.add(descendant) : selectedSet.value.delete(descendant);
|
|
115
|
+
nodes.value[descendant].selected = to;
|
|
116
|
+
issueVnodeState(descendant);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// Emit
|
|
123
|
+
function emitExpanded() {
|
|
124
|
+
const arr = [...expandedSet.value];
|
|
125
|
+
expanded.value = props.returnItem ? arr.map(key => nodes.value[key].item) : arr;
|
|
126
|
+
}
|
|
127
|
+
function emitActive() {
|
|
128
|
+
const arr = [...activeSet.value];
|
|
129
|
+
active.value = props.returnItem ? arr.map(key => nodes.value[key].item) : arr;
|
|
130
|
+
}
|
|
131
|
+
function emitSelected() {
|
|
132
|
+
const arr = [...selectedSet.value];
|
|
133
|
+
selected.value = props.returnItem ? arr.map(key => nodes.value[key].item) : arr;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// Inject
|
|
137
|
+
function register(key, vnode) {
|
|
138
|
+
if (nodes.value[key]) {
|
|
139
|
+
nodes.value[key].vnode = vnode;
|
|
140
|
+
}
|
|
141
|
+
issueVnodeState(key);
|
|
142
|
+
}
|
|
143
|
+
provide(Y_TREE_VIEW, {
|
|
144
|
+
register,
|
|
145
|
+
updateExpanded,
|
|
146
|
+
updateActive,
|
|
147
|
+
updateSelected,
|
|
148
|
+
searchLoading,
|
|
149
|
+
isExcluded,
|
|
150
|
+
emitExpanded,
|
|
151
|
+
emitActive,
|
|
152
|
+
emitSelected
|
|
153
|
+
});
|
|
154
|
+
return {
|
|
155
|
+
nodes,
|
|
156
|
+
expanded,
|
|
157
|
+
active,
|
|
158
|
+
selected,
|
|
159
|
+
issueVnodeState,
|
|
160
|
+
updateExpanded,
|
|
161
|
+
updateActive,
|
|
162
|
+
updateSelected,
|
|
163
|
+
emitExpanded,
|
|
164
|
+
emitActive,
|
|
165
|
+
emitSelected,
|
|
166
|
+
expandedSet,
|
|
167
|
+
selectedSet,
|
|
168
|
+
activeSet,
|
|
169
|
+
searchLoading,
|
|
170
|
+
excludedSet,
|
|
171
|
+
isExcluded
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
export function useTreeView() {
|
|
175
|
+
const instance = inject(Y_TREE_VIEW);
|
|
176
|
+
if (!instance) throw new Error('Not found provided YTreeView');
|
|
177
|
+
return instance;
|
|
178
|
+
}
|
|
179
|
+
//# sourceMappingURL=tree-view.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tree-view.mjs","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,CA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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"}
|
package/package.json
CHANGED
|
@@ -4,5 +4,8 @@ export declare const YTextEllipsis: import('vue').DefineComponent<{
|
|
|
4
4
|
type: StringConstructor;
|
|
5
5
|
default: string;
|
|
6
6
|
};
|
|
7
|
+
position: {
|
|
8
|
+
type: StringConstructor;
|
|
9
|
+
};
|
|
7
10
|
}, void, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string>;
|
|
8
11
|
export type YTextEllipsis = InstanceType<typeof YTextEllipsis>;
|
|
@@ -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<"
|
|
49
|
+
type: PropType<"cascade" | "independent">;
|
|
50
50
|
default: string;
|
|
51
51
|
};
|
|
52
52
|
selected: {
|
|
@@ -54,7 +54,7 @@ export declare const YTreeView: import('vue').DefineComponent<import('vue').Extr
|
|
|
54
54
|
default: () => never[];
|
|
55
55
|
};
|
|
56
56
|
selectStrategy: {
|
|
57
|
-
type: PropType<"
|
|
57
|
+
type: PropType<"cascade" | "independent">;
|
|
58
58
|
default: string;
|
|
59
59
|
};
|
|
60
60
|
returnItem: BooleanConstructor;
|
|
@@ -116,7 +116,7 @@ export declare const YTreeView: import('vue').DefineComponent<import('vue').Extr
|
|
|
116
116
|
};
|
|
117
117
|
multipleActive: BooleanConstructor;
|
|
118
118
|
activeStrategy: {
|
|
119
|
-
type: PropType<"
|
|
119
|
+
type: PropType<"cascade" | "independent">;
|
|
120
120
|
default: string;
|
|
121
121
|
};
|
|
122
122
|
selected: {
|
|
@@ -124,7 +124,7 @@ export declare const YTreeView: import('vue').DefineComponent<import('vue').Extr
|
|
|
124
124
|
default: () => never[];
|
|
125
125
|
};
|
|
126
126
|
selectStrategy: {
|
|
127
|
-
type: PropType<"
|
|
127
|
+
type: PropType<"cascade" | "independent">;
|
|
128
128
|
default: string;
|
|
129
129
|
};
|
|
130
130
|
returnItem: BooleanConstructor;
|
|
@@ -146,15 +146,15 @@ export declare const YTreeView: import('vue').DefineComponent<import('vue').Extr
|
|
|
146
146
|
itemKey: string;
|
|
147
147
|
itemText: string;
|
|
148
148
|
itemChildren: string | boolean;
|
|
149
|
+
selected: CandidateKey[];
|
|
149
150
|
disableTransition: boolean;
|
|
150
151
|
enableActive: boolean;
|
|
151
152
|
requiredActive: boolean;
|
|
152
153
|
activeColor: string;
|
|
153
154
|
enableSelect: boolean;
|
|
154
|
-
selected: CandidateKey[];
|
|
155
155
|
multipleActive: boolean;
|
|
156
|
-
activeStrategy: "
|
|
157
|
-
selectStrategy: "
|
|
156
|
+
activeStrategy: "cascade" | "independent";
|
|
157
|
+
selectStrategy: "cascade" | "independent";
|
|
158
158
|
searchDebounceWait: number;
|
|
159
159
|
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
160
160
|
export type YTreeView = InstanceType<typeof YTreeView>;
|
|
@@ -156,7 +156,17 @@ export declare const YTreeViewNode: import('vue').DefineComponent<{
|
|
|
156
156
|
default: number;
|
|
157
157
|
};
|
|
158
158
|
}, {
|
|
159
|
-
treeView:
|
|
159
|
+
treeView: {
|
|
160
|
+
register: (key: import('../../types').CandidateKey, vnode: any) => void;
|
|
161
|
+
updateExpanded: (key: import('../../types').CandidateKey, to: boolean) => void;
|
|
162
|
+
updateActive: (key: import('../../types').CandidateKey, to: boolean, event?: MouseEvent | undefined) => void;
|
|
163
|
+
updateSelected: (key: import('../../types').CandidateKey, to: boolean) => void;
|
|
164
|
+
searchLoading: import('vue').Ref<boolean, boolean>;
|
|
165
|
+
isExcluded: (key: import('../../types').CandidateKey) => boolean;
|
|
166
|
+
emitExpanded: () => void;
|
|
167
|
+
emitActive: () => void;
|
|
168
|
+
emitSelected: () => void;
|
|
169
|
+
};
|
|
160
170
|
myKey: import('vue').ComputedRef<any>;
|
|
161
171
|
expanded: import('vue').Ref<boolean, boolean>;
|
|
162
172
|
active: import('vue').Ref<boolean, boolean>;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { InjectionKey, Ref } from 'vue';
|
|
2
|
+
import { CandidateKey } from '../../types';
|
|
3
|
+
|
|
4
|
+
export declare const Y_TREE_VIEW: InjectionKey<{
|
|
5
|
+
register: (key: CandidateKey, vnode: any) => void;
|
|
6
|
+
updateExpanded: (key: CandidateKey, to: boolean) => void;
|
|
7
|
+
updateActive: (key: CandidateKey, to: boolean, event?: MouseEvent) => void;
|
|
8
|
+
updateSelected: (key: CandidateKey, to: boolean) => void;
|
|
9
|
+
searchLoading: Ref<boolean>;
|
|
10
|
+
isExcluded: (key: CandidateKey) => boolean;
|
|
11
|
+
emitExpanded: () => void;
|
|
12
|
+
emitActive: () => void;
|
|
13
|
+
emitSelected: () => void;
|
|
14
|
+
}>;
|
|
15
|
+
export declare function provideTreeView(props: any): {
|
|
16
|
+
nodes: Ref<Record<CandidateKey, any>, Record<CandidateKey, any>>;
|
|
17
|
+
expanded: Ref<any, any> & {
|
|
18
|
+
readonly rxValue: any;
|
|
19
|
+
};
|
|
20
|
+
active: Ref<any, any> & {
|
|
21
|
+
readonly rxValue: any;
|
|
22
|
+
};
|
|
23
|
+
selected: Ref<any, any> & {
|
|
24
|
+
readonly rxValue: any;
|
|
25
|
+
};
|
|
26
|
+
issueVnodeState: (key: CandidateKey) => void;
|
|
27
|
+
updateExpanded: (key: CandidateKey, to: boolean) => void;
|
|
28
|
+
updateActive: (key: CandidateKey, to: boolean, event?: MouseEvent) => void;
|
|
29
|
+
updateSelected: (key: CandidateKey, to: boolean) => void;
|
|
30
|
+
emitExpanded: () => void;
|
|
31
|
+
emitActive: () => void;
|
|
32
|
+
emitSelected: () => void;
|
|
33
|
+
expandedSet: Ref<Set<CandidateKey> & Omit<Set<CandidateKey>, keyof Set<any>>, Set<CandidateKey> | (Set<CandidateKey> & Omit<Set<CandidateKey>, keyof Set<any>>)>;
|
|
34
|
+
selectedSet: Ref<Set<CandidateKey> & Omit<Set<CandidateKey>, keyof Set<any>>, Set<CandidateKey> | (Set<CandidateKey> & Omit<Set<CandidateKey>, keyof Set<any>>)>;
|
|
35
|
+
activeSet: Ref<Set<CandidateKey> & Omit<Set<CandidateKey>, keyof Set<any>>, Set<CandidateKey> | (Set<CandidateKey> & Omit<Set<CandidateKey>, keyof Set<any>>)>;
|
|
36
|
+
searchLoading: import('vue').ShallowRef<boolean, boolean>;
|
|
37
|
+
excludedSet: Ref<Set<CandidateKey> & Omit<Set<CandidateKey>, keyof Set<any>>, Set<CandidateKey> | (Set<CandidateKey> & Omit<Set<CandidateKey>, keyof Set<any>>)>;
|
|
38
|
+
isExcluded: (key: CandidateKey) => boolean;
|
|
39
|
+
};
|
|
40
|
+
export declare function useTreeView(): {
|
|
41
|
+
register: (key: CandidateKey, vnode: any) => void;
|
|
42
|
+
updateExpanded: (key: CandidateKey, to: boolean) => void;
|
|
43
|
+
updateActive: (key: CandidateKey, to: boolean, event?: MouseEvent | undefined) => void;
|
|
44
|
+
updateSelected: (key: CandidateKey, to: boolean) => void;
|
|
45
|
+
searchLoading: Ref<boolean, boolean>;
|
|
46
|
+
isExcluded: (key: CandidateKey) => boolean;
|
|
47
|
+
emitExpanded: () => void;
|
|
48
|
+
emitActive: () => void;
|
|
49
|
+
emitSelected: () => void;
|
|
50
|
+
};
|