vft 0.0.73 → 0.0.76
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/attributes.json +1 -1
- package/dist/index.css +1 -1
- package/es/component.js +67 -48
- package/es/components/affix/affix.js +45 -0
- package/es/components/affix/affix.vue.js +4 -0
- package/es/components/affix/affix.vue2.js +83 -0
- package/es/components/affix/index.js +12 -0
- package/es/components/affix/style/css.js +2 -0
- package/es/components/affix/style/index.js +2 -0
- package/es/components/back-top/back-top.vue2.js +10 -2
- package/es/components/button/button.vue2.js +58 -59
- package/es/components/button/use-button.js +26 -20
- package/es/components/card/card.vue.js +4 -0
- package/es/components/card/card.vue2.js +44 -0
- package/es/components/card/index.js +12 -0
- package/es/components/card/instance.js +1 -0
- package/es/components/card/style/css.js +2 -0
- package/es/components/card/style/index.js +2 -0
- package/es/components/check-tag/check-tag.vue.js +4 -0
- package/es/components/check-tag/check-tag.vue2.js +35 -0
- package/es/components/check-tag/index.js +12 -0
- package/es/components/check-tag/style/css.js +2 -0
- package/es/components/check-tag/style/index.js +2 -0
- package/es/components/color-picker/color-picker.vue2.js +1 -1
- package/es/components/context-menu/context-menu.vue2.js +10 -2
- package/es/components/date-picker/composables/use-month-range-header.js +1 -1
- package/es/components/date-picker/constants.js +16 -2
- package/es/components/date-picker/date-picker-com/basic-month-table.vue2.js +37 -34
- package/es/components/date-picker/date-picker-com/basic-year-table.vue2.js +0 -1
- package/es/components/date-picker/date-picker-com/panel-date-pick.vue2.js +177 -178
- package/es/components/date-picker/date-picker-com/panel-date-range.vue2.js +328 -336
- package/es/components/date-picker/date-picker.js +18 -18
- package/es/components/date-picker/index.js +5 -4
- package/es/components/date-picker/props/shared.js +1 -1
- package/es/components/date-time-select/date-time-select.vue2.js +59 -59
- package/es/components/dialog/dialog.vue2.js +12 -12
- package/es/components/dialog/hooks/use-dialog.js +4 -4
- package/es/components/dropdown/dropdown-menu.vue2.js +4 -4
- package/es/components/footer-layout/footer-layout.vue2.js +10 -2
- package/es/components/header-layout/header-layout.vue2.js +10 -2
- package/es/components/horizontal-menu/constants.js +4 -0
- package/es/components/horizontal-menu/horizontal-menu.vue2.js +153 -86
- package/es/components/horizontal-menu/index.js +7 -5
- package/es/components/index.js +228 -194
- package/es/components/md-container/md-container.vue2.js +10 -2
- package/es/components/menu/menu-item.vue2.js +58 -58
- package/es/components/menu/menu.vue2.js +72 -68
- package/es/components/menu/sub-menu.vue2.js +139 -117
- package/es/components/multiple-tabs/multiple-tabs.vue2.js +35 -26
- package/es/components/option/style/css.js +2 -0
- package/es/components/option/style/index.js +2 -0
- package/es/components/option-group/style/css.js +2 -0
- package/es/components/option-group/style/index.js +2 -0
- package/es/components/popconfirm/index.js +12 -0
- package/es/components/popconfirm/popconfirm.vue.js +4 -0
- package/es/components/popconfirm/popconfirm.vue2.js +112 -0
- package/es/components/popconfirm/style/css.js +6 -0
- package/es/components/popconfirm/style/index.js +6 -0
- package/es/components/popover/style/index.js +1 -1
- package/es/components/result/result.vue2.js +10 -2
- package/es/components/roving-focus-group/roving-focus-item.vue2.js +1 -1
- package/es/components/search/style/css.js +2 -0
- package/es/components/search/style/index.js +2 -0
- package/es/components/select/index.js +22 -0
- package/es/components/select/option-group.vue.js +25 -0
- package/es/components/select/option-group.vue2.js +53 -0
- package/es/components/select/option.vue.js +27 -0
- package/es/components/select/option.vue2.js +58 -0
- package/es/components/select/options.js +34 -0
- package/es/components/select/select-dropdown.vue.js +15 -0
- package/es/components/select/select-dropdown.vue2.js +32 -0
- package/es/components/select/select.vue.js +327 -0
- package/es/components/select/select.vue2.js +348 -0
- package/es/components/select/style/css.js +8 -0
- package/es/components/select/style/index.js +8 -0
- package/es/components/select/token.js +5 -0
- package/es/components/select/useOption.js +71 -0
- package/es/components/select/useSelect.js +414 -0
- package/es/components/select-v2/select-dropdown.js +1 -1
- package/es/components/select-v2/useSelect.js +269 -269
- package/es/components/side-menu/side-menu.vue2.js +153 -142
- package/es/components/skeleton/index.js +16 -0
- package/es/components/skeleton/skeleton-item.vue.js +4 -0
- package/es/components/skeleton/skeleton-item.vue2.js +31 -0
- package/es/components/skeleton/skeleton.vue.js +4 -0
- package/es/components/skeleton/skeleton.vue2.js +55 -0
- package/es/components/skeleton/style/css.js +3 -0
- package/es/components/skeleton/style/index.js +3 -0
- package/es/components/skeleton-item/style/css.js +2 -0
- package/es/components/skeleton-item/style/index.js +2 -0
- package/es/components/space/index.js +17 -0
- package/es/components/space/item.js +24 -0
- package/es/components/space/space.js +182 -0
- package/es/components/space/style/css.js +2 -0
- package/es/components/space/style/index.js +2 -0
- package/es/components/space/use-space.js +44 -0
- package/es/components/switch/switch.vue2.js +1 -1
- package/es/components/tabs/tab-nav.vue2.js +30 -22
- package/es/components/tabs/tabs.vue2.js +37 -37
- package/es/components/time-picker/common/picker.vue2.js +241 -257
- package/es/components/time-picker/common/props.js +10 -6
- package/es/components/time-picker/time-picker-com/panel-time-range.vue2.js +1 -1
- package/es/components/time-picker/time-picker.js +10 -10
- package/es/components/time-select/time-select.vue2.js +38 -42
- package/es/components/tooltip/content.vue2.js +1 -1
- package/es/components/tree/index.js +14 -0
- package/es/components/tree/model/node.js +248 -0
- package/es/components/tree/model/tree-store.js +197 -0
- package/es/components/tree/model/useDragNode.js +71 -0
- package/es/components/tree/model/useKeydown.js +81 -0
- package/es/components/tree/model/useNodeExpandEventBroadcast.js +19 -0
- package/es/components/tree/model/util.js +21 -0
- package/es/components/tree/style/css.js +3 -0
- package/es/components/tree/style/index.js +3 -0
- package/es/components/tree/tree-node-content.vue.js +4 -0
- package/es/components/tree/tree-node-content.vue2.js +28 -0
- package/es/components/tree/tree-node.vue.js +98 -0
- package/es/components/tree/tree-node.vue2.js +152 -0
- package/es/components/tree/tree.type.js +1 -0
- package/es/components/tree/tree.vue.js +48 -0
- package/es/components/tree/tree.vue2.js +268 -0
- package/es/components/tree-select/cache-options.js +32 -0
- package/es/components/tree-select/index.js +9 -0
- package/es/components/tree-select/select.js +38 -0
- package/es/components/tree-select/style/css.js +11 -0
- package/es/components/tree-select/style/index.js +11 -0
- package/es/components/tree-select/tree-select-option.js +21 -0
- package/es/components/tree-select/tree-select.vue.js +4 -0
- package/es/components/tree-select/tree-select.vue2.js +81 -0
- package/es/components/tree-select/tree.js +137 -0
- package/es/components/tree-select/utils.js +45 -0
- package/es/hooks/index.js +25 -21
- package/es/hooks/use-focus/index.js +9 -0
- package/es/hooks/use-throttle-render/index.js +21 -0
- package/es/index.js +408 -368
- package/es/package.json.js +1 -1
- package/es/utils/helper.js +5 -2
- package/es/utils/index.js +48 -46
- package/lib/component.cjs +1 -1
- package/lib/components/affix/affix.cjs +1 -0
- package/lib/components/affix/affix.vue.cjs +1 -0
- package/lib/components/affix/affix.vue2.cjs +1 -0
- package/lib/components/affix/index.cjs +1 -0
- package/lib/components/affix/style/css.cjs +1 -0
- package/lib/components/affix/style/index.cjs +1 -0
- package/lib/components/back-top/back-top.vue2.cjs +1 -1
- package/lib/components/button/button.vue2.cjs +1 -1
- package/lib/components/button/use-button.cjs +1 -1
- package/lib/components/card/card.vue.cjs +1 -0
- package/lib/components/card/card.vue2.cjs +1 -0
- package/lib/components/card/index.cjs +1 -0
- package/lib/components/card/instance.cjs +1 -0
- package/lib/components/card/style/css.cjs +1 -0
- package/lib/components/card/style/index.cjs +1 -0
- package/lib/components/check-tag/check-tag.vue.cjs +1 -0
- package/lib/components/check-tag/check-tag.vue2.cjs +1 -0
- package/lib/components/check-tag/index.cjs +1 -0
- package/lib/components/check-tag/style/css.cjs +1 -0
- package/lib/components/check-tag/style/index.cjs +1 -0
- package/lib/components/color-picker/color-picker.vue2.cjs +1 -1
- package/lib/components/context-menu/context-menu.vue2.cjs +1 -1
- package/lib/components/date-picker/composables/use-month-range-header.cjs +1 -1
- package/lib/components/date-picker/constants.cjs +1 -1
- package/lib/components/date-picker/date-picker-com/basic-month-table.vue2.cjs +1 -1
- package/lib/components/date-picker/date-picker-com/basic-year-table.vue2.cjs +1 -1
- package/lib/components/date-picker/date-picker-com/panel-date-pick.vue2.cjs +1 -1
- package/lib/components/date-picker/date-picker-com/panel-date-range.vue2.cjs +1 -1
- package/lib/components/date-picker/date-picker.cjs +1 -1
- package/lib/components/date-picker/index.cjs +1 -1
- package/lib/components/date-picker/props/shared.cjs +1 -1
- package/lib/components/date-time-select/date-time-select.vue2.cjs +1 -1
- package/lib/components/dialog/dialog.vue2.cjs +1 -1
- package/lib/components/dialog/hooks/use-dialog.cjs +1 -1
- package/lib/components/dropdown/dropdown-menu.vue2.cjs +1 -1
- package/lib/components/footer-layout/footer-layout.vue2.cjs +1 -1
- package/lib/components/header-layout/header-layout.vue2.cjs +1 -1
- package/lib/components/horizontal-menu/constants.cjs +1 -0
- package/lib/components/horizontal-menu/horizontal-menu.vue2.cjs +1 -1
- package/lib/components/horizontal-menu/index.cjs +1 -1
- package/lib/components/index.cjs +1 -1
- package/lib/components/md-container/md-container.vue2.cjs +1 -1
- package/lib/components/menu/menu-item.vue2.cjs +1 -1
- package/lib/components/menu/menu.vue2.cjs +1 -1
- package/lib/components/menu/sub-menu.vue2.cjs +1 -1
- package/lib/components/multiple-tabs/multiple-tabs.vue2.cjs +1 -1
- package/lib/components/option/style/css.cjs +1 -0
- package/lib/components/option/style/index.cjs +1 -0
- package/lib/components/option-group/style/css.cjs +1 -0
- package/lib/components/option-group/style/index.cjs +1 -0
- package/lib/components/popconfirm/index.cjs +1 -0
- package/lib/components/popconfirm/popconfirm.vue.cjs +1 -0
- package/lib/components/popconfirm/popconfirm.vue2.cjs +1 -0
- package/lib/components/popconfirm/style/css.cjs +1 -0
- package/lib/components/popconfirm/style/index.cjs +1 -0
- package/lib/components/popover/style/index.cjs +1 -1
- package/lib/components/result/result.vue2.cjs +1 -1
- package/lib/components/roving-focus-group/roving-focus-item.vue2.cjs +1 -1
- package/lib/components/search/style/css.cjs +1 -1
- package/lib/components/search/style/index.cjs +1 -1
- package/lib/components/select/index.cjs +1 -0
- package/lib/components/select/option-group.vue.cjs +1 -0
- package/lib/components/select/option-group.vue2.cjs +1 -0
- package/lib/components/select/option.vue.cjs +1 -0
- package/lib/components/select/option.vue2.cjs +1 -0
- package/lib/components/select/options.cjs +1 -0
- package/lib/components/select/select-dropdown.vue.cjs +1 -0
- package/lib/components/select/select-dropdown.vue2.cjs +1 -0
- package/lib/components/select/select.vue.cjs +1 -0
- package/lib/components/select/select.vue2.cjs +1 -0
- package/lib/components/select/style/css.cjs +1 -0
- package/lib/components/select/style/index.cjs +1 -0
- package/lib/components/select/token.cjs +1 -0
- package/lib/components/select/useOption.cjs +1 -0
- package/lib/components/select/useSelect.cjs +1 -0
- package/lib/components/select-v2/select-dropdown.cjs +1 -1
- package/lib/components/select-v2/useSelect.cjs +1 -1
- package/lib/components/side-menu/side-menu.vue2.cjs +1 -1
- package/lib/components/skeleton/index.cjs +1 -0
- package/lib/components/skeleton/skeleton-item.vue.cjs +1 -0
- package/lib/components/skeleton/skeleton-item.vue2.cjs +1 -0
- package/lib/components/skeleton/skeleton.vue.cjs +1 -0
- package/lib/components/skeleton/skeleton.vue2.cjs +1 -0
- package/lib/components/skeleton/style/css.cjs +1 -0
- package/lib/components/skeleton/style/index.cjs +1 -0
- package/lib/components/skeleton-item/style/css.cjs +1 -0
- package/lib/components/skeleton-item/style/index.cjs +1 -0
- package/lib/components/space/index.cjs +1 -0
- package/lib/components/space/item.cjs +1 -0
- package/lib/components/space/space.cjs +1 -0
- package/lib/components/space/style/css.cjs +1 -0
- package/lib/components/space/style/index.cjs +1 -0
- package/lib/components/space/use-space.cjs +1 -0
- package/lib/components/switch/switch.vue2.cjs +1 -1
- package/lib/components/tabs/tab-nav.vue2.cjs +1 -1
- package/lib/components/tabs/tabs.vue2.cjs +1 -1
- package/lib/components/time-picker/common/picker.vue2.cjs +1 -1
- package/lib/components/time-picker/common/props.cjs +1 -1
- package/lib/components/time-picker/time-picker-com/panel-time-range.vue2.cjs +1 -1
- package/lib/components/time-picker/time-picker.cjs +1 -1
- package/lib/components/time-select/time-select.vue2.cjs +1 -1
- package/lib/components/tooltip/content.vue2.cjs +1 -1
- package/lib/components/tree/index.cjs +1 -0
- package/lib/components/tree/model/node.cjs +1 -0
- package/lib/components/tree/model/tree-store.cjs +1 -0
- package/lib/components/tree/model/useDragNode.cjs +1 -0
- package/lib/components/tree/model/useKeydown.cjs +1 -0
- package/lib/components/tree/model/useNodeExpandEventBroadcast.cjs +1 -0
- package/lib/components/tree/model/util.cjs +1 -0
- package/lib/components/tree/style/css.cjs +1 -0
- package/lib/components/tree/style/index.cjs +1 -0
- package/lib/components/tree/tree-node-content.vue.cjs +1 -0
- package/lib/components/tree/tree-node-content.vue2.cjs +1 -0
- package/lib/components/tree/tree-node.vue.cjs +1 -0
- package/lib/components/tree/tree-node.vue2.cjs +1 -0
- package/lib/components/tree/tree.type.cjs +1 -0
- package/lib/components/tree/tree.vue.cjs +1 -0
- package/lib/components/tree/tree.vue2.cjs +1 -0
- package/lib/components/tree-select/cache-options.cjs +1 -0
- package/lib/components/tree-select/index.cjs +1 -0
- package/lib/components/tree-select/select.cjs +1 -0
- package/lib/components/tree-select/style/css.cjs +1 -0
- package/lib/components/tree-select/style/index.cjs +1 -0
- package/lib/components/tree-select/tree-select-option.cjs +1 -0
- package/lib/components/tree-select/tree-select.vue.cjs +1 -0
- package/lib/components/tree-select/tree-select.vue2.cjs +1 -0
- package/lib/components/tree-select/tree.cjs +1 -0
- package/lib/components/tree-select/utils.cjs +1 -0
- package/lib/hooks/index.cjs +1 -1
- package/lib/hooks/use-focus/index.cjs +1 -0
- package/lib/hooks/use-throttle-render/index.cjs +1 -0
- package/lib/index.cjs +1 -1
- package/lib/package.json.cjs +1 -1
- package/lib/utils/helper.cjs +1 -1
- package/lib/utils/index.cjs +1 -1
- package/package.json +1 -1
- package/tags.json +1 -1
- package/theme-style/base.css +1 -1
- package/theme-style/index.css +1 -1
- package/theme-style/src/alert.scss +1 -1
- package/theme-style/src/autocomplete.scss +2 -2
- package/theme-style/src/breadcrumb.scss +4 -4
- package/theme-style/src/calendar.scss +2 -2
- package/theme-style/src/card.scss +1 -1
- package/theme-style/src/carousel.scss +1 -1
- package/theme-style/src/cascader.scss +3 -3
- package/theme-style/src/check-tag.scss +3 -3
- package/theme-style/src/checkbox.scss +1 -1
- package/theme-style/src/color-picker.scss +2 -2
- package/theme-style/src/common/var.scss +527 -521
- package/theme-style/src/date-picker/date-picker.scss +1 -1
- package/theme-style/src/date-picker/date-range-picker.scss +2 -2
- package/theme-style/src/date-picker/date-table.scss +1 -1
- package/theme-style/src/date-picker/month-table.scss +2 -2
- package/theme-style/src/date-picker/picker-panel.scss +4 -5
- package/theme-style/src/date-picker/picker.scss +7 -9
- package/theme-style/src/date-picker/time-picker.scss +2 -2
- package/theme-style/src/date-picker/time-spinner.scss +6 -8
- package/theme-style/src/date-picker/year-table.scss +3 -3
- package/theme-style/src/date-time-select.scss +3 -4
- package/theme-style/src/descriptions-item.scss +4 -4
- package/theme-style/src/descriptions.scss +2 -2
- package/theme-style/src/header-layout.scss +1 -1
- package/theme-style/src/horizontal-menu.scss +27 -39
- package/theme-style/src/image-viewer.scss +1 -1
- package/theme-style/src/index.scss +3 -0
- package/theme-style/src/input-number.scss +1 -1
- package/theme-style/src/menu.scss +76 -66
- package/theme-style/src/mixins/_var.scss +2 -2
- package/theme-style/src/mixins/mixins.scss +2 -2
- package/theme-style/src/popconfirm.scss +16 -0
- package/theme-style/src/popper.scss +4 -2
- package/theme-style/src/progress.scss +1 -1
- package/theme-style/src/reset.scss +3 -3
- package/theme-style/src/result.scss +2 -2
- package/theme-style/src/select-dropdown-v2.scss +1 -1
- package/theme-style/src/select-dropdown.scss +1 -1
- package/theme-style/src/select-v2.scss +2 -2
- package/theme-style/src/select.scss +4 -5
- package/theme-style/src/side-menu.scss +0 -1
- package/theme-style/src/skeleton-item.scss +83 -0
- package/theme-style/src/skeleton.scss +44 -0
- package/theme-style/src/step.scss +10 -10
- package/theme-style/src/tabs.scss +15 -155
- package/theme-style/src/timeline-item.scss +2 -2
- package/theme-style/src/transfer.scss +5 -5
- package/theme-style/src/tree.scss +2 -5
- package/theme-style/src/upload.scss +11 -11
- package/theme-style/src/var.scss +1 -1
- package/theme-style/vft-alert.css +1 -1
- package/theme-style/vft-autocomplete.css +1 -1
- package/theme-style/vft-breadcrumb.css +1 -1
- package/theme-style/vft-calendar.css +1 -1
- package/theme-style/vft-card.css +1 -1
- package/theme-style/vft-carousel.css +1 -1
- package/theme-style/vft-cascader.css +1 -1
- package/theme-style/vft-check-tag.css +1 -1
- package/theme-style/vft-checkbox.css +1 -1
- package/theme-style/vft-color-picker.css +1 -1
- package/theme-style/vft-date-picker.css +1 -1
- package/theme-style/vft-date-time-select.css +1 -1
- package/theme-style/vft-descriptions-item.css +1 -1
- package/theme-style/vft-descriptions.css +1 -1
- package/theme-style/vft-header-layout.css +1 -1
- package/theme-style/vft-horizontal-menu.css +1 -1
- package/theme-style/vft-image-viewer.css +1 -1
- package/theme-style/vft-input-number.css +1 -1
- package/theme-style/vft-menu.css +1 -1
- package/theme-style/vft-popconfirm.css +1 -0
- package/theme-style/vft-popper.css +1 -1
- package/theme-style/vft-progress.css +1 -1
- package/theme-style/vft-reset.css +1 -1
- package/theme-style/vft-result.css +1 -1
- package/theme-style/vft-select-dropdown-v2.css +1 -1
- package/theme-style/vft-select-dropdown.css +1 -1
- package/theme-style/vft-select-v2.css +1 -1
- package/theme-style/vft-select.css +1 -1
- package/theme-style/vft-side-menu.css +1 -1
- package/theme-style/vft-skeleton-item.css +1 -0
- package/theme-style/vft-skeleton.css +1 -0
- package/theme-style/vft-step.css +1 -1
- package/theme-style/vft-tabs.css +1 -1
- package/theme-style/vft-time-picker.css +1 -1
- package/theme-style/vft-time-select.css +1 -1
- package/theme-style/vft-timeline-item.css +1 -1
- package/theme-style/vft-transfer.css +1 -1
- package/theme-style/vft-tree.css +1 -1
- package/theme-style/vft-upload.css +1 -1
- package/theme-style/vft-var.css +1 -1
- package/web-types.json +1 -1
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { hasOwn as u, isObject as C } from "@vft/utils";
|
|
2
|
+
import N from "./node.js";
|
|
3
|
+
import { getNodeKey as y } from "./util.js";
|
|
4
|
+
class M {
|
|
5
|
+
constructor(e) {
|
|
6
|
+
this.currentNode = null, this.currentNodeKey = null;
|
|
7
|
+
for (const t in e)
|
|
8
|
+
u(e, t) && (this[t] = e[t]);
|
|
9
|
+
this.nodesMap = {};
|
|
10
|
+
}
|
|
11
|
+
initialize() {
|
|
12
|
+
if (this.root = new N({
|
|
13
|
+
data: this.data,
|
|
14
|
+
store: this
|
|
15
|
+
}), this.root.initialize(), this.lazy && this.load) {
|
|
16
|
+
const e = this.load;
|
|
17
|
+
e(this.root, (t) => {
|
|
18
|
+
this.root.doCreateChildren(t), this._initDefaultCheckedNodes();
|
|
19
|
+
});
|
|
20
|
+
} else
|
|
21
|
+
this._initDefaultCheckedNodes();
|
|
22
|
+
}
|
|
23
|
+
filter(e) {
|
|
24
|
+
const t = this.filterNodeMethod, s = this.lazy, o = function(i) {
|
|
25
|
+
const d = i.root ? i.root.childNodes : i.childNodes;
|
|
26
|
+
if (d.forEach((r) => {
|
|
27
|
+
r.visible = t.call(r, e, r.data, r), o(r);
|
|
28
|
+
}), !i.visible && d.length) {
|
|
29
|
+
let r = !0;
|
|
30
|
+
r = !d.some((h) => h.visible), i.root ? i.root.visible = r === !1 : i.visible = r === !1;
|
|
31
|
+
}
|
|
32
|
+
e && i.visible && !i.isLeaf && !s && i.expand();
|
|
33
|
+
};
|
|
34
|
+
o(this);
|
|
35
|
+
}
|
|
36
|
+
setData(e) {
|
|
37
|
+
e !== this.root.data ? (this.root.setData(e), this._initDefaultCheckedNodes()) : this.root.updateChildren();
|
|
38
|
+
}
|
|
39
|
+
getNode(e) {
|
|
40
|
+
if (e instanceof N)
|
|
41
|
+
return e;
|
|
42
|
+
const t = C(e) ? y(this.key, e) : e;
|
|
43
|
+
return this.nodesMap[t] || null;
|
|
44
|
+
}
|
|
45
|
+
insertBefore(e, t) {
|
|
46
|
+
const s = this.getNode(t);
|
|
47
|
+
s.parent.insertBefore({ data: e }, s);
|
|
48
|
+
}
|
|
49
|
+
insertAfter(e, t) {
|
|
50
|
+
const s = this.getNode(t);
|
|
51
|
+
s.parent.insertAfter({ data: e }, s);
|
|
52
|
+
}
|
|
53
|
+
remove(e) {
|
|
54
|
+
const t = this.getNode(e);
|
|
55
|
+
t && t.parent && (t === this.currentNode && (this.currentNode = null), t.parent.removeChild(t));
|
|
56
|
+
}
|
|
57
|
+
append(e, t) {
|
|
58
|
+
const s = t ? this.getNode(t) : this.root;
|
|
59
|
+
s && s.insertChild({ data: e });
|
|
60
|
+
}
|
|
61
|
+
_initDefaultCheckedNodes() {
|
|
62
|
+
const e = this.defaultCheckedKeys || [], t = this.nodesMap;
|
|
63
|
+
e.forEach((s) => {
|
|
64
|
+
const o = t[s];
|
|
65
|
+
o && o.setChecked(!0, !this.checkStrictly);
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
_initDefaultCheckedNode(e) {
|
|
69
|
+
(this.defaultCheckedKeys || []).includes(e.key) && e.setChecked(!0, !this.checkStrictly);
|
|
70
|
+
}
|
|
71
|
+
setDefaultCheckedKey(e) {
|
|
72
|
+
e !== this.defaultCheckedKeys && (this.defaultCheckedKeys = e, this._initDefaultCheckedNodes());
|
|
73
|
+
}
|
|
74
|
+
registerNode(e) {
|
|
75
|
+
const t = this.key;
|
|
76
|
+
!e || !e.data || (t ? e.key !== void 0 && (this.nodesMap[e.key] = e) : this.nodesMap[e.id] = e);
|
|
77
|
+
}
|
|
78
|
+
deregisterNode(e) {
|
|
79
|
+
!this.key || !e || !e.data || (e.childNodes.forEach((s) => {
|
|
80
|
+
this.deregisterNode(s);
|
|
81
|
+
}), delete this.nodesMap[e.key]);
|
|
82
|
+
}
|
|
83
|
+
getCheckedNodes(e = !1, t = !1) {
|
|
84
|
+
const s = [], o = function(i) {
|
|
85
|
+
(i.root ? i.root.childNodes : i.childNodes).forEach((r) => {
|
|
86
|
+
(r.checked || t && r.indeterminate) && (!e || e && r.isLeaf) && s.push(r.data), o(r);
|
|
87
|
+
});
|
|
88
|
+
};
|
|
89
|
+
return o(this), s;
|
|
90
|
+
}
|
|
91
|
+
getCheckedKeys(e = !1) {
|
|
92
|
+
return this.getCheckedNodes(e).map((t) => (t || {})[this.key]);
|
|
93
|
+
}
|
|
94
|
+
getHalfCheckedNodes() {
|
|
95
|
+
const e = [], t = function(s) {
|
|
96
|
+
(s.root ? s.root.childNodes : s.childNodes).forEach((i) => {
|
|
97
|
+
i.indeterminate && e.push(i.data), t(i);
|
|
98
|
+
});
|
|
99
|
+
};
|
|
100
|
+
return t(this), e;
|
|
101
|
+
}
|
|
102
|
+
getHalfCheckedKeys() {
|
|
103
|
+
return this.getHalfCheckedNodes().map((e) => (e || {})[this.key]);
|
|
104
|
+
}
|
|
105
|
+
_getAllNodes() {
|
|
106
|
+
const e = [], t = this.nodesMap;
|
|
107
|
+
for (const s in t)
|
|
108
|
+
u(t, s) && e.push(t[s]);
|
|
109
|
+
return e;
|
|
110
|
+
}
|
|
111
|
+
updateChildren(e, t) {
|
|
112
|
+
const s = this.nodesMap[e];
|
|
113
|
+
if (!s)
|
|
114
|
+
return;
|
|
115
|
+
const o = s.childNodes;
|
|
116
|
+
for (let i = o.length - 1; i >= 0; i--) {
|
|
117
|
+
const d = o[i];
|
|
118
|
+
this.remove(d.data);
|
|
119
|
+
}
|
|
120
|
+
for (let i = 0, d = t.length; i < d; i++) {
|
|
121
|
+
const r = t[i];
|
|
122
|
+
this.append(r, s.data);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
_setCheckedKeys(e, t = !1, s) {
|
|
126
|
+
const o = this._getAllNodes().sort((r, h) => h.level - r.level), i = /* @__PURE__ */ Object.create(null), d = Object.keys(s);
|
|
127
|
+
o.forEach((r) => r.setChecked(!1, !1));
|
|
128
|
+
for (let r = 0, h = o.length; r < h; r++) {
|
|
129
|
+
const n = o[r], l = n.data[e].toString();
|
|
130
|
+
if (!d.includes(l)) {
|
|
131
|
+
n.checked && !i[l] && n.setChecked(!1, !1);
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
let c = n.parent;
|
|
135
|
+
for (; c && c.level > 0; )
|
|
136
|
+
i[c.data[e]] = !0, c = c.parent;
|
|
137
|
+
if (n.isLeaf || this.checkStrictly) {
|
|
138
|
+
n.setChecked(!0, !1);
|
|
139
|
+
continue;
|
|
140
|
+
}
|
|
141
|
+
if (n.setChecked(!0, !0), t) {
|
|
142
|
+
n.setChecked(!1, !1);
|
|
143
|
+
const f = function(k) {
|
|
144
|
+
k.childNodes.forEach((a) => {
|
|
145
|
+
a.isLeaf || a.setChecked(!1, !1), f(a);
|
|
146
|
+
});
|
|
147
|
+
};
|
|
148
|
+
f(n);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
setCheckedNodes(e, t = !1) {
|
|
153
|
+
const s = this.key, o = {};
|
|
154
|
+
e.forEach((i) => {
|
|
155
|
+
o[(i || {})[s]] = !0;
|
|
156
|
+
}), this._setCheckedKeys(s, t, o);
|
|
157
|
+
}
|
|
158
|
+
setCheckedKeys(e, t = !1) {
|
|
159
|
+
this.defaultCheckedKeys = e;
|
|
160
|
+
const s = this.key, o = {};
|
|
161
|
+
e.forEach((i) => {
|
|
162
|
+
o[i] = !0;
|
|
163
|
+
}), this._setCheckedKeys(s, t, o);
|
|
164
|
+
}
|
|
165
|
+
setDefaultExpandedKeys(e) {
|
|
166
|
+
e = e || [], this.defaultExpandedKeys = e, e.forEach((t) => {
|
|
167
|
+
const s = this.getNode(t);
|
|
168
|
+
s && s.expand(null, this.autoExpandParent);
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
setChecked(e, t, s) {
|
|
172
|
+
const o = this.getNode(e);
|
|
173
|
+
o && o.setChecked(!!t, s);
|
|
174
|
+
}
|
|
175
|
+
getCurrentNode() {
|
|
176
|
+
return this.currentNode;
|
|
177
|
+
}
|
|
178
|
+
setCurrentNode(e) {
|
|
179
|
+
const t = this.currentNode;
|
|
180
|
+
t && (t.isCurrent = !1), this.currentNode = e, this.currentNode.isCurrent = !0;
|
|
181
|
+
}
|
|
182
|
+
setUserCurrentNode(e, t = !0) {
|
|
183
|
+
const s = e[this.key], o = this.nodesMap[s];
|
|
184
|
+
this.setCurrentNode(o), t && this.currentNode.level > 1 && this.currentNode.parent.expand(null, !0);
|
|
185
|
+
}
|
|
186
|
+
setCurrentNodeKey(e, t = !0) {
|
|
187
|
+
if (e == null) {
|
|
188
|
+
this.currentNode && (this.currentNode.isCurrent = !1), this.currentNode = null;
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
const s = this.getNode(e);
|
|
192
|
+
s && (this.setCurrentNode(s), t && this.currentNode.level > 1 && this.currentNode.parent.expand(null, !0));
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
export {
|
|
196
|
+
M as default
|
|
197
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { ref as I, provide as S } from "vue";
|
|
2
|
+
import { removeClass as v, addClass as E } from "@vft/utils";
|
|
3
|
+
import { useNamespace as P } from "../../../hooks/use-namespace/index.js";
|
|
4
|
+
import "@popperjs/core";
|
|
5
|
+
import "lodash";
|
|
6
|
+
import "../../../hooks/use-z-index/index.js";
|
|
7
|
+
import "@vueuse/core";
|
|
8
|
+
import "../../../utils/ns-cover.js";
|
|
9
|
+
const B = Symbol("dragEvents");
|
|
10
|
+
function F({ props: p, ctx: s, el$: h, dropIndicator$: b, store: T }) {
|
|
11
|
+
const g = P("tree"), d = I({
|
|
12
|
+
showDropIndicator: !1,
|
|
13
|
+
draggingNode: null,
|
|
14
|
+
dropNode: null,
|
|
15
|
+
allowDrop: !0,
|
|
16
|
+
dropType: null
|
|
17
|
+
});
|
|
18
|
+
return S(B, {
|
|
19
|
+
treeNodeDragStart: ({ event: r, treeNode: t }) => {
|
|
20
|
+
if (typeof p.allowDrag == "function" && !p.allowDrag(t.node))
|
|
21
|
+
return r.preventDefault(), !1;
|
|
22
|
+
r.dataTransfer.effectAllowed = "move";
|
|
23
|
+
try {
|
|
24
|
+
r.dataTransfer.setData("text/plain", "");
|
|
25
|
+
} catch {
|
|
26
|
+
}
|
|
27
|
+
d.value.draggingNode = t, s.emit("node-drag-start", t.node, r);
|
|
28
|
+
},
|
|
29
|
+
treeNodeDragOver: ({ event: r, treeNode: t }) => {
|
|
30
|
+
const e = t, o = d.value.dropNode;
|
|
31
|
+
o && o !== e && v(o.$el, g.is("drop-inner"));
|
|
32
|
+
const n = d.value.draggingNode;
|
|
33
|
+
if (!n || !e)
|
|
34
|
+
return;
|
|
35
|
+
let l = !0, i = !0, f = !0, N = !0;
|
|
36
|
+
typeof p.allowDrop == "function" && (l = p.allowDrop(n.node, e.node, "prev"), N = i = p.allowDrop(
|
|
37
|
+
n.node,
|
|
38
|
+
e.node,
|
|
39
|
+
"inner"
|
|
40
|
+
), f = p.allowDrop(n.node, e.node, "next")), r.dataTransfer.dropEffect = i || l || f ? "move" : "none", (l || i || f) && o !== e && (o && s.emit("node-drag-leave", n.node, o.node, r), s.emit("node-drag-enter", n.node, e.node, r)), (l || i || f) && (d.value.dropNode = e), e.node.nextSibling === n.node && (f = !1), e.node.previousSibling === n.node && (l = !1), e.node.contains(n.node, !1) && (i = !1), (n.node === e.node || n.node.contains(e.node)) && (l = !1, i = !1, f = !1);
|
|
41
|
+
const u = e.$el.getBoundingClientRect(), c = h.value.getBoundingClientRect();
|
|
42
|
+
let a;
|
|
43
|
+
const $ = l ? i ? 0.25 : f ? 0.45 : 1 : -1, C = f ? i ? 0.75 : l ? 0.55 : 0 : 1;
|
|
44
|
+
let m = -9999;
|
|
45
|
+
const w = r.clientY - u.top;
|
|
46
|
+
w < u.height * $ ? a = "before" : w > u.height * C ? a = "after" : i ? a = "inner" : a = "none";
|
|
47
|
+
const D = e.$el.querySelector(`.${g.be("node", "expand-icon")}`).getBoundingClientRect(), y = b.value;
|
|
48
|
+
a === "before" ? m = D.top - c.top : a === "after" && (m = D.bottom - c.top), y.style.top = `${m}px`, y.style.left = `${D.right - c.left}px`, a === "inner" ? E(e.$el, g.is("drop-inner")) : v(e.$el, g.is("drop-inner")), d.value.showDropIndicator = a === "before" || a === "after", d.value.allowDrop = d.value.showDropIndicator || N, d.value.dropType = a, s.emit("node-drag-over", n.node, e.node, r);
|
|
49
|
+
},
|
|
50
|
+
treeNodeDragEnd: (r) => {
|
|
51
|
+
const { draggingNode: t, dropType: e, dropNode: o } = d.value;
|
|
52
|
+
if (r.preventDefault(), r.dataTransfer.dropEffect = "move", t && o) {
|
|
53
|
+
const n = { data: t.node.data };
|
|
54
|
+
e !== "none" && t.node.remove(), e === "before" ? o.node.parent.insertBefore(n, o.node) : e === "after" ? o.node.parent.insertAfter(n, o.node) : e === "inner" && o.node.insertChild(n), e !== "none" && T.value.registerNode(n), v(o.$el, g.is("drop-inner")), s.emit(
|
|
55
|
+
"node-drag-end",
|
|
56
|
+
t.node,
|
|
57
|
+
o.node,
|
|
58
|
+
e,
|
|
59
|
+
r
|
|
60
|
+
), e !== "none" && s.emit("node-drop", t.node, o.node, e, r);
|
|
61
|
+
}
|
|
62
|
+
t && !o && s.emit("node-drag-end", t.node, null, e, r), d.value.showDropIndicator = !1, d.value.draggingNode = null, d.value.dropNode = null, d.value.allowDrop = !0;
|
|
63
|
+
}
|
|
64
|
+
}), {
|
|
65
|
+
dragState: d
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
export {
|
|
69
|
+
B as dragEventsKey,
|
|
70
|
+
F as useDragNodeHandler
|
|
71
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { shallowRef as m, onMounted as v, onUpdated as y, watch as h } from "vue";
|
|
2
|
+
import { useEventListener as b } from "@vueuse/core";
|
|
3
|
+
import { EVENT_CODE as a } from "../../../constants/aria.js";
|
|
4
|
+
import { useNamespace as k } from "../../../hooks/use-namespace/index.js";
|
|
5
|
+
import "@popperjs/core";
|
|
6
|
+
import "lodash";
|
|
7
|
+
import "../../../hooks/use-z-index/index.js";
|
|
8
|
+
import "@vft/utils";
|
|
9
|
+
import "../../../utils/ns-cover.js";
|
|
10
|
+
function K({ el$: l }, d) {
|
|
11
|
+
const u = k("tree"), t = m([]), i = m([]);
|
|
12
|
+
v(() => {
|
|
13
|
+
p();
|
|
14
|
+
}), y(() => {
|
|
15
|
+
t.value = Array.from(l.value.querySelectorAll("[role=treeitem]")), i.value = Array.from(
|
|
16
|
+
l.value.querySelectorAll("input[type=checkbox]")
|
|
17
|
+
);
|
|
18
|
+
}), h(i, (r) => {
|
|
19
|
+
r.forEach((o) => {
|
|
20
|
+
o.setAttribute("tabindex", "-1");
|
|
21
|
+
});
|
|
22
|
+
}), b(l, "keydown", (r) => {
|
|
23
|
+
const o = r.target;
|
|
24
|
+
if (!o.className.includes(u.b("node")))
|
|
25
|
+
return;
|
|
26
|
+
const c = r.code;
|
|
27
|
+
t.value = Array.from(
|
|
28
|
+
l.value.querySelectorAll(`.${u.is("focusable")}[role=treeitem]`)
|
|
29
|
+
);
|
|
30
|
+
const n = t.value.indexOf(o);
|
|
31
|
+
let e;
|
|
32
|
+
if ([a.up, a.down].includes(c)) {
|
|
33
|
+
if (r.preventDefault(), c === a.up) {
|
|
34
|
+
e = n === -1 ? 0 : n !== 0 ? n - 1 : t.value.length - 1;
|
|
35
|
+
const s = e;
|
|
36
|
+
for (; !d.value.getNode(t.value[e].dataset.key).canFocus; ) {
|
|
37
|
+
if (e--, e === s) {
|
|
38
|
+
e = -1;
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
41
|
+
e < 0 && (e = t.value.length - 1);
|
|
42
|
+
}
|
|
43
|
+
} else {
|
|
44
|
+
e = n === -1 ? 0 : n < t.value.length - 1 ? n + 1 : 0;
|
|
45
|
+
const s = e;
|
|
46
|
+
for (; !d.value.getNode(t.value[e].dataset.key).canFocus; ) {
|
|
47
|
+
if (e++, e === s) {
|
|
48
|
+
e = -1;
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
e >= t.value.length && (e = 0);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
e !== -1 && t.value[e].focus();
|
|
55
|
+
}
|
|
56
|
+
[a.left, a.right].includes(c) && (r.preventDefault(), o.click());
|
|
57
|
+
const f = o.querySelector(
|
|
58
|
+
'[type="checkbox"]'
|
|
59
|
+
);
|
|
60
|
+
[a.enter, a.space].includes(c) && f && (r.preventDefault(), f.click());
|
|
61
|
+
});
|
|
62
|
+
const p = () => {
|
|
63
|
+
var o;
|
|
64
|
+
t.value = Array.from(
|
|
65
|
+
l.value.querySelectorAll(`.${u.is("focusable")}[role=treeitem]`)
|
|
66
|
+
), i.value = Array.from(
|
|
67
|
+
l.value.querySelectorAll("input[type=checkbox]")
|
|
68
|
+
);
|
|
69
|
+
const r = l.value.querySelectorAll(
|
|
70
|
+
`.${u.is("checked")}[role=treeitem]`
|
|
71
|
+
);
|
|
72
|
+
if (r.length) {
|
|
73
|
+
r[0].setAttribute("tabindex", "0");
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
(o = t.value[0]) == null || o.setAttribute("tabindex", "0");
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
export {
|
|
80
|
+
K as useKeydown
|
|
81
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { inject as t, provide as a } from "vue";
|
|
2
|
+
function i(e) {
|
|
3
|
+
const n = t("TreeNodeMap", null), d = {
|
|
4
|
+
treeNodeExpand: (o) => {
|
|
5
|
+
e.node !== o && e.node.collapse();
|
|
6
|
+
},
|
|
7
|
+
children: []
|
|
8
|
+
};
|
|
9
|
+
return n && n.children.push(d), a("TreeNodeMap", d), {
|
|
10
|
+
broadcastExpanded: (o) => {
|
|
11
|
+
if (e.accordion)
|
|
12
|
+
for (const r of d.children)
|
|
13
|
+
r.treeNodeExpand(o);
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export {
|
|
18
|
+
i as useNodeExpandEventBroadcast
|
|
19
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const t = "$treeNodeId", c = function(r, e) {
|
|
2
|
+
!e || e[t] || Object.defineProperty(e, t, {
|
|
3
|
+
value: r.id,
|
|
4
|
+
enumerable: !1,
|
|
5
|
+
configurable: !1,
|
|
6
|
+
writable: !1
|
|
7
|
+
});
|
|
8
|
+
}, l = function(r, e) {
|
|
9
|
+
return r ? e[r] : e[t];
|
|
10
|
+
}, a = (r, e, u) => {
|
|
11
|
+
const o = r.value.currentNode;
|
|
12
|
+
u();
|
|
13
|
+
const n = r.value.currentNode;
|
|
14
|
+
o !== n && e("current-change", n ? n.data : null, n);
|
|
15
|
+
};
|
|
16
|
+
export {
|
|
17
|
+
t as NODE_KEY,
|
|
18
|
+
l as getNodeKey,
|
|
19
|
+
a as handleCurrentChange,
|
|
20
|
+
c as markNodeData
|
|
21
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { defineComponent as m, inject as r, h as s } from "vue";
|
|
2
|
+
import { useNamespace as i } from "../../hooks/use-namespace/index.js";
|
|
3
|
+
import "@popperjs/core";
|
|
4
|
+
import "lodash";
|
|
5
|
+
import "../../hooks/use-z-index/index.js";
|
|
6
|
+
import "@vueuse/core";
|
|
7
|
+
import "@vft/utils";
|
|
8
|
+
import "../../utils/ns-cover.js";
|
|
9
|
+
const _ = m({
|
|
10
|
+
name: "VftTreeNodeContent",
|
|
11
|
+
props: {
|
|
12
|
+
node: {
|
|
13
|
+
type: Object,
|
|
14
|
+
required: !0
|
|
15
|
+
},
|
|
16
|
+
renderContent: Function
|
|
17
|
+
},
|
|
18
|
+
setup(t) {
|
|
19
|
+
const a = i("tree"), c = r("NodeInstance"), n = r("RootTree");
|
|
20
|
+
return () => {
|
|
21
|
+
const e = t.node, { data: o, store: d } = e;
|
|
22
|
+
return t.renderContent ? t.renderContent(s, { _self: c, node: e, data: o, store: d }) : n.ctx.slots.default ? n.ctx.slots.default({ node: e, data: o }) : s("span", { class: a.be("node", "label") }, [e.label]);
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
export {
|
|
27
|
+
_ as default
|
|
28
|
+
};
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import C from "./tree-node.vue2.js";
|
|
2
|
+
import { resolveComponent as a, withDirectives as g, openBlock as r, createElementBlock as i, normalizeClass as s, withModifiers as d, createElementVNode as v, normalizeStyle as D, createVNode as l, createBlock as p, createCommentVNode as t, withCtx as N, Fragment as y, renderList as E, vShow as k } from "vue";
|
|
3
|
+
import w from "../../_virtual/_plugin-vue_export-helper.js";
|
|
4
|
+
const $ = ["aria-expanded", "aria-disabled", "aria-checked", "draggable", "data-key"], L = ["aria-expanded"];
|
|
5
|
+
function S(e, n, c, B, M, V) {
|
|
6
|
+
const h = a("vft-icon"), m = a("vft-checkbox"), u = a("node-content"), b = a("tree-node", !0), f = a("vft-collapse-transition");
|
|
7
|
+
return g((r(), i("div", {
|
|
8
|
+
ref: "node$",
|
|
9
|
+
class: s([
|
|
10
|
+
e.ns.b("node"),
|
|
11
|
+
e.ns.is("expanded", e.expanded),
|
|
12
|
+
e.ns.is("current", e.node.isCurrent),
|
|
13
|
+
e.ns.is("hidden", !e.node.visible),
|
|
14
|
+
e.ns.is("focusable", !e.node.disabled),
|
|
15
|
+
e.ns.is("checked", !e.node.disabled && e.node.checked),
|
|
16
|
+
e.getNodeClass(e.node)
|
|
17
|
+
]),
|
|
18
|
+
role: "treeitem",
|
|
19
|
+
tabindex: "-1",
|
|
20
|
+
"aria-expanded": e.expanded,
|
|
21
|
+
"aria-disabled": e.node.disabled,
|
|
22
|
+
"aria-checked": e.node.checked,
|
|
23
|
+
draggable: e.tree.props.draggable,
|
|
24
|
+
"data-key": e.getNodeKey(e.node),
|
|
25
|
+
onClick: n[1] || (n[1] = d((...o) => e.handleClick && e.handleClick(...o), ["stop"])),
|
|
26
|
+
onContextmenu: n[2] || (n[2] = (...o) => e.handleContextMenu && e.handleContextMenu(...o)),
|
|
27
|
+
onDragstart: n[3] || (n[3] = d((...o) => e.handleDragStart && e.handleDragStart(...o), ["stop"])),
|
|
28
|
+
onDragover: n[4] || (n[4] = d((...o) => e.handleDragOver && e.handleDragOver(...o), ["stop"])),
|
|
29
|
+
onDragend: n[5] || (n[5] = d((...o) => e.handleDragEnd && e.handleDragEnd(...o), ["stop"])),
|
|
30
|
+
onDrop: n[6] || (n[6] = d((...o) => e.handleDrop && e.handleDrop(...o), ["stop"]))
|
|
31
|
+
}, [
|
|
32
|
+
v("div", {
|
|
33
|
+
class: s(e.ns.be("node", "content")),
|
|
34
|
+
style: D({ paddingLeft: (e.node.level - 1) * e.tree.props.indent + "px" })
|
|
35
|
+
}, [
|
|
36
|
+
l(h, {
|
|
37
|
+
icon: e.tree.props.icon || "ico-ep:caret-right",
|
|
38
|
+
class: s([
|
|
39
|
+
e.ns.be("node", "expand-icon"),
|
|
40
|
+
e.ns.is("leaf", e.node.isLeaf),
|
|
41
|
+
{
|
|
42
|
+
expanded: !e.node.isLeaf && e.expanded
|
|
43
|
+
}
|
|
44
|
+
]),
|
|
45
|
+
onClick: d(e.handleExpandIconClick, ["stop"])
|
|
46
|
+
}, null, 8, ["icon", "class", "onClick"]),
|
|
47
|
+
e.showCheckbox ? (r(), p(m, {
|
|
48
|
+
key: 0,
|
|
49
|
+
"model-value": e.node.checked,
|
|
50
|
+
indeterminate: e.node.indeterminate,
|
|
51
|
+
disabled: !!e.node.disabled,
|
|
52
|
+
onClick: n[0] || (n[0] = d(() => {
|
|
53
|
+
}, ["stop"])),
|
|
54
|
+
onChange: e.handleCheckChange
|
|
55
|
+
}, null, 8, ["model-value", "indeterminate", "disabled", "onChange"])) : t("", !0),
|
|
56
|
+
e.node.loading ? (r(), p(h, {
|
|
57
|
+
key: 1,
|
|
58
|
+
icon: "ico-ep:loading",
|
|
59
|
+
rotate: "",
|
|
60
|
+
class: s([e.ns.be("node", "loading-icon"), e.ns.is("loading")])
|
|
61
|
+
}, null, 8, ["class"])) : t("", !0),
|
|
62
|
+
l(u, {
|
|
63
|
+
node: e.node,
|
|
64
|
+
"render-content": e.renderContent
|
|
65
|
+
}, null, 8, ["node", "render-content"])
|
|
66
|
+
], 6),
|
|
67
|
+
l(f, null, {
|
|
68
|
+
default: N(() => [
|
|
69
|
+
!e.renderAfterExpand || e.childNodeRendered ? g((r(), i("div", {
|
|
70
|
+
key: 0,
|
|
71
|
+
class: s(e.ns.be("node", "children")),
|
|
72
|
+
role: "group",
|
|
73
|
+
"aria-expanded": e.expanded
|
|
74
|
+
}, [
|
|
75
|
+
(r(!0), i(y, null, E(e.node.childNodes, (o) => (r(), p(b, {
|
|
76
|
+
key: e.getNodeKey(o),
|
|
77
|
+
"render-content": e.renderContent,
|
|
78
|
+
"render-after-expand": e.renderAfterExpand,
|
|
79
|
+
"show-checkbox": e.showCheckbox,
|
|
80
|
+
node: o,
|
|
81
|
+
accordion: e.accordion,
|
|
82
|
+
props: e.props,
|
|
83
|
+
onNodeExpand: e.handleChildNodeExpand
|
|
84
|
+
}, null, 8, ["render-content", "render-after-expand", "show-checkbox", "node", "accordion", "props", "onNodeExpand"]))), 128))
|
|
85
|
+
], 10, L)), [
|
|
86
|
+
[k, e.expanded]
|
|
87
|
+
]) : t("", !0)
|
|
88
|
+
]),
|
|
89
|
+
_: 1
|
|
90
|
+
})
|
|
91
|
+
], 42, $)), [
|
|
92
|
+
[k, e.node.visible]
|
|
93
|
+
]);
|
|
94
|
+
}
|
|
95
|
+
const O = /* @__PURE__ */ w(C, [["render", S]]);
|
|
96
|
+
export {
|
|
97
|
+
O as default
|
|
98
|
+
};
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { defineComponent as S, inject as x, ref as r, getCurrentInstance as T, provide as I, watch as l, nextTick as N } from "vue";
|
|
2
|
+
import { isFunction as _, isString as B } from "@vft/utils";
|
|
3
|
+
import $ from "../collapse-transition/index.js";
|
|
4
|
+
import { VftCheckbox as F } from "../checkbox/index.js";
|
|
5
|
+
import { VftIcon as V } from "../icon/index.js";
|
|
6
|
+
import { debugWarn as j } from "../../utils/error.js";
|
|
7
|
+
import "lodash";
|
|
8
|
+
import "@vueuse/core";
|
|
9
|
+
import "../../utils/ns-cover.js";
|
|
10
|
+
import { useNamespace as w } from "../../hooks/use-namespace/index.js";
|
|
11
|
+
import "@popperjs/core";
|
|
12
|
+
import "../../hooks/use-z-index/index.js";
|
|
13
|
+
import H from "./tree-node-content.vue2.js";
|
|
14
|
+
import { getNodeKey as R, handleCurrentChange as A } from "./model/util.js";
|
|
15
|
+
import { useNodeExpandEventBroadcast as L } from "./model/useNodeExpandEventBroadcast.js";
|
|
16
|
+
import { dragEventsKey as M } from "./model/useDragNode.js";
|
|
17
|
+
import P from "./model/node.js";
|
|
18
|
+
const he = S({
|
|
19
|
+
name: "TreeNode",
|
|
20
|
+
components: {
|
|
21
|
+
VftCollapseTransition: $,
|
|
22
|
+
VftCheckbox: F,
|
|
23
|
+
NodeContent: H,
|
|
24
|
+
VftIcon: V
|
|
25
|
+
},
|
|
26
|
+
props: {
|
|
27
|
+
node: {
|
|
28
|
+
type: P,
|
|
29
|
+
default: () => ({})
|
|
30
|
+
},
|
|
31
|
+
props: {
|
|
32
|
+
type: Object,
|
|
33
|
+
default: () => ({})
|
|
34
|
+
},
|
|
35
|
+
accordion: Boolean,
|
|
36
|
+
renderContent: Function,
|
|
37
|
+
renderAfterExpand: Boolean,
|
|
38
|
+
showCheckbox: {
|
|
39
|
+
type: Boolean,
|
|
40
|
+
default: !1
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
emits: ["node-expand"],
|
|
44
|
+
setup(n, k) {
|
|
45
|
+
const v = w("tree"), { broadcastExpanded: p } = L(n), t = x("RootTree"), c = r(!1), i = r(!1), s = r(null), u = r(null), m = r(null), h = x(M), a = T();
|
|
46
|
+
I("NodeInstance", a), t || j("Tree", "Can not find node's tree."), n.node.expanded && (c.value = !0, i.value = !0);
|
|
47
|
+
const y = t.props.children || "children";
|
|
48
|
+
l(
|
|
49
|
+
() => {
|
|
50
|
+
const e = n.node.data[y];
|
|
51
|
+
return e && [...e];
|
|
52
|
+
},
|
|
53
|
+
() => {
|
|
54
|
+
n.node.updateChildren();
|
|
55
|
+
}
|
|
56
|
+
), l(
|
|
57
|
+
() => n.node.indeterminate,
|
|
58
|
+
(e) => {
|
|
59
|
+
f(n.node.checked, e);
|
|
60
|
+
}
|
|
61
|
+
), l(
|
|
62
|
+
() => n.node.checked,
|
|
63
|
+
(e) => {
|
|
64
|
+
f(e, n.node.indeterminate);
|
|
65
|
+
}
|
|
66
|
+
), l(
|
|
67
|
+
() => n.node.expanded,
|
|
68
|
+
(e) => {
|
|
69
|
+
N(() => c.value = e), e && (i.value = !0);
|
|
70
|
+
}
|
|
71
|
+
);
|
|
72
|
+
const D = (e) => R(t.props.nodeKey, e.data), E = (e) => {
|
|
73
|
+
const d = n.props.class;
|
|
74
|
+
if (!d)
|
|
75
|
+
return {};
|
|
76
|
+
let o;
|
|
77
|
+
if (_(d)) {
|
|
78
|
+
const { data: O } = e;
|
|
79
|
+
o = d(O, e);
|
|
80
|
+
} else
|
|
81
|
+
o = d;
|
|
82
|
+
return B(o) ? { [o]: !0 } : o;
|
|
83
|
+
}, f = (e, d) => {
|
|
84
|
+
(s.value !== e || u.value !== d) && t.ctx.emit("check-change", n.node.data, e, d), s.value = e, u.value = d;
|
|
85
|
+
}, K = (e) => {
|
|
86
|
+
A(
|
|
87
|
+
t.store,
|
|
88
|
+
t.ctx.emit,
|
|
89
|
+
() => t.store.value.setCurrentNode(n.node)
|
|
90
|
+
), t.currentNode.value = n.node, t.props.expandOnClickNode && g(), t.props.checkOnClickNode && !n.node.disabled && C(null, {
|
|
91
|
+
target: { checked: !n.node.checked }
|
|
92
|
+
}), t.ctx.emit("node-click", n.node.data, n.node, a, e);
|
|
93
|
+
}, b = (e) => {
|
|
94
|
+
t.instance.vnode.props.onNodeContextmenu && (e.stopPropagation(), e.preventDefault()), t.ctx.emit(
|
|
95
|
+
"node-contextmenu",
|
|
96
|
+
e,
|
|
97
|
+
n.node.data,
|
|
98
|
+
n.node,
|
|
99
|
+
a
|
|
100
|
+
);
|
|
101
|
+
}, g = () => {
|
|
102
|
+
n.node.isLeaf || (c.value ? (t.ctx.emit("node-collapse", n.node.data, n.node, a), n.node.collapse()) : (n.node.expand(), k.emit("node-expand", n.node.data, n.node, a)));
|
|
103
|
+
}, C = (e, d) => {
|
|
104
|
+
n.node.setChecked(d.target.checked, !t.props.checkStrictly), N(() => {
|
|
105
|
+
const o = t.store.value;
|
|
106
|
+
t.ctx.emit("check", n.node.data, {
|
|
107
|
+
checkedNodes: o.getCheckedNodes(),
|
|
108
|
+
checkedKeys: o.getCheckedKeys(),
|
|
109
|
+
halfCheckedNodes: o.getHalfCheckedNodes(),
|
|
110
|
+
halfCheckedKeys: o.getHalfCheckedKeys()
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
};
|
|
114
|
+
return {
|
|
115
|
+
ns: v,
|
|
116
|
+
node$: m,
|
|
117
|
+
tree: t,
|
|
118
|
+
expanded: c,
|
|
119
|
+
childNodeRendered: i,
|
|
120
|
+
oldChecked: s,
|
|
121
|
+
oldIndeterminate: u,
|
|
122
|
+
getNodeKey: D,
|
|
123
|
+
getNodeClass: E,
|
|
124
|
+
handleSelectChange: f,
|
|
125
|
+
handleClick: K,
|
|
126
|
+
handleContextMenu: b,
|
|
127
|
+
handleExpandIconClick: g,
|
|
128
|
+
handleCheckChange: C,
|
|
129
|
+
handleChildNodeExpand: (e, d, o) => {
|
|
130
|
+
p(d), t.ctx.emit("node-expand", e, d, o);
|
|
131
|
+
},
|
|
132
|
+
handleDragStart: (e) => {
|
|
133
|
+
t.props.draggable && h.treeNodeDragStart({ event: e, treeNode: n });
|
|
134
|
+
},
|
|
135
|
+
handleDragOver: (e) => {
|
|
136
|
+
e.preventDefault(), t.props.draggable && h.treeNodeDragOver({
|
|
137
|
+
event: e,
|
|
138
|
+
treeNode: { $el: m.value, node: n.node }
|
|
139
|
+
});
|
|
140
|
+
},
|
|
141
|
+
handleDrop: (e) => {
|
|
142
|
+
e.preventDefault();
|
|
143
|
+
},
|
|
144
|
+
handleDragEnd: (e) => {
|
|
145
|
+
t.props.draggable && h.treeNodeDragEnd(e);
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
export {
|
|
151
|
+
he as default
|
|
152
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|