@wfrog/vc-ui 1.0.0
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/README.md +95 -0
- package/dist/es/chunk/-EkpfdcW.mjs +1100 -0
- package/dist/es/chunk/8rLUmOVR.mjs +29 -0
- package/dist/es/chunk/B-rxnVJv.mjs +3 -0
- package/dist/es/chunk/BAGoDD49.mjs +36 -0
- package/dist/es/chunk/BAtns-Mc.mjs +96 -0
- package/dist/es/chunk/BJS5Pdfp.mjs +55 -0
- package/dist/es/chunk/BMzd-IS6.mjs +900 -0
- package/dist/es/chunk/BWcCXRRK.mjs +229 -0
- package/dist/es/chunk/BX-Ogf7p.mjs +3743 -0
- package/dist/es/chunk/B_tU9Nax.mjs +49 -0
- package/dist/es/chunk/BdDihk0t.mjs +3420 -0
- package/dist/es/chunk/C2LgraHx.mjs +489 -0
- package/dist/es/chunk/C5hWsUfD.mjs +64 -0
- package/dist/es/chunk/C7iSSBUr.mjs +303 -0
- package/dist/es/chunk/CD98REcR.mjs +666 -0
- package/dist/es/chunk/CEClY-_T.mjs +445 -0
- package/dist/es/chunk/CEm0brzD.mjs +35 -0
- package/dist/es/chunk/CMABHk8B.mjs +1942 -0
- package/dist/es/chunk/CS4VKsqy.mjs +19 -0
- package/dist/es/chunk/CVlj9F0I.mjs +291 -0
- package/dist/es/chunk/CZ4ggqDE.mjs +140 -0
- package/dist/es/chunk/CaTfZePA.mjs +533 -0
- package/dist/es/chunk/Ce9ApjrT.mjs +201 -0
- package/dist/es/chunk/ClZGuAIb.mjs +10 -0
- package/dist/es/chunk/Coex0GxM.mjs +450 -0
- package/dist/es/chunk/Ct6q2FXg.mjs +5 -0
- package/dist/es/chunk/CyxEcbcy.mjs +29 -0
- package/dist/es/chunk/D389hx_T.mjs +35 -0
- package/dist/es/chunk/D3DXeVfC.mjs +1171 -0
- package/dist/es/chunk/D3uV7vm-.mjs +45 -0
- package/dist/es/chunk/D5259bwd.mjs +50 -0
- package/dist/es/chunk/DMHNh_tw.mjs +49 -0
- package/dist/es/chunk/DVNTpOBR.mjs +4 -0
- package/dist/es/chunk/DZACQ9LT.mjs +95 -0
- package/dist/es/chunk/De_EXLIy.mjs +22 -0
- package/dist/es/chunk/Dh4jaUSg.mjs +89 -0
- package/dist/es/chunk/DhhdKtyu.mjs +439 -0
- package/dist/es/chunk/DqUIKX7f.mjs +2039 -0
- package/dist/es/chunk/Dqz1zvKN.mjs +59 -0
- package/dist/es/chunk/Dvi7RsXg.mjs +727 -0
- package/dist/es/chunk/DyDMGLoF.mjs +123 -0
- package/dist/es/chunk/E_WRn0OP.mjs +449 -0
- package/dist/es/chunk/Fo0dZYnz.mjs +128 -0
- package/dist/es/chunk/HSv8BL8o.mjs +72 -0
- package/dist/es/chunk/JCIyOUEY.mjs +105 -0
- package/dist/es/chunk/O-uhUKF4.mjs +43 -0
- package/dist/es/chunk/Spa-JKB4.mjs +1046 -0
- package/dist/es/chunk/VAdRxe-1.mjs +16 -0
- package/dist/es/chunk/VCrtRnxt.mjs +1477 -0
- package/dist/es/chunk/ViP2SEY4.mjs +211 -0
- package/dist/es/chunk/aibQ9WSZ.mjs +249 -0
- package/dist/es/chunk/nWBcrYxV.mjs +690 -0
- package/dist/es/chunk/pcqpp-6-.mjs +9 -0
- package/dist/es/chunk/qY9OvNHY.mjs +283 -0
- package/dist/es/chunk/su2Zrql0.mjs +53 -0
- package/dist/es/chunk/zfg5SOj1.mjs +138 -0
- package/dist/es/components/awesome-icon/awesome-icon.d.ts +6 -0
- package/dist/es/components/awesome-icon/awesome-icon.mjs +41 -0
- package/dist/es/components/awesome-icon/awesome-icon.vue.d.ts +5 -0
- package/dist/es/components/awesome-icon/index.d.ts +4 -0
- package/dist/es/components/awesome-icon/index.mjs +6 -0
- package/dist/es/components/backbottom/backbottom.d.ts +7 -0
- package/dist/es/components/backbottom/backbottom.mjs +172 -0
- package/dist/es/components/backbottom/backbottom.vue.d.ts +7 -0
- package/dist/es/components/backbottom/components/child.vue.d.ts +30 -0
- package/dist/es/components/backbottom/index.d.ts +4 -0
- package/dist/es/components/backbottom/index.mjs +6 -0
- package/dist/es/components/button/button.d.ts +18 -0
- package/dist/es/components/button/button.mjs +313 -0
- package/dist/es/components/button/button.vue.d.ts +33 -0
- package/dist/es/components/button/index.css +9 -0
- package/dist/es/components/button/index.d.ts +4 -0
- package/dist/es/components/button/index.mjs +6 -0
- package/dist/es/components/cdn-tag.vue.d.ts +5 -0
- package/dist/es/components/chat-container/chat-container.d.ts +9 -0
- package/dist/es/components/chat-container/chat-container.mjs +77 -0
- package/dist/es/components/chat-container/chat-container.vue.d.ts +29 -0
- package/dist/es/components/chat-container/index.css +9 -0
- package/dist/es/components/chat-container/index.d.ts +4 -0
- package/dist/es/components/chat-container/index.mjs +6 -0
- package/dist/es/components/choice/choice.d.ts +6 -0
- package/dist/es/components/choice/choice.mjs +53 -0
- package/dist/es/components/choice/choice.vue.d.ts +5 -0
- package/dist/es/components/choice/index.css +7 -0
- package/dist/es/components/choice/index.d.ts +4 -0
- package/dist/es/components/choice/index.mjs +6 -0
- package/dist/es/components/choice-boolean/choice-boolean.d.ts +5 -0
- package/dist/es/components/choice-boolean/choice-boolean.mjs +32 -0
- package/dist/es/components/choice-boolean/choice-boolean.vue.d.ts +10 -0
- package/dist/es/components/choice-boolean/index.d.ts +4 -0
- package/dist/es/components/choice-boolean/index.mjs +6 -0
- package/dist/es/components/config-provider/config-provider.d.ts +16 -0
- package/dist/es/components/config-provider/config-provider.mjs +29 -0
- package/dist/es/components/config-provider/config-provider.vue.d.ts +18 -0
- package/dist/es/components/config-provider/config-provider2.mjs +6 -0
- package/dist/es/components/config-provider/index.d.ts +4 -0
- package/dist/es/components/config-provider/index.mjs +6 -0
- package/dist/es/components/cropper/cropper.d.ts +12 -0
- package/dist/es/components/cropper/cropper.mjs +333 -0
- package/dist/es/components/cropper/cropper.vue.d.ts +32 -0
- package/dist/es/components/cropper/index.css +4 -0
- package/dist/es/components/cropper/index.d.ts +4 -0
- package/dist/es/components/cropper/index.mjs +6 -0
- package/dist/es/components/currency/currency.d.ts +21 -0
- package/dist/es/components/currency/currency.mjs +185 -0
- package/dist/es/components/currency/currency.vue.d.ts +14 -0
- package/dist/es/components/currency/index.css +8 -0
- package/dist/es/components/currency/index.d.ts +4 -0
- package/dist/es/components/currency/index.mjs +6 -0
- package/dist/es/components/daterange-picker/daterange-picker.d.ts +6 -0
- package/dist/es/components/daterange-picker/daterange-picker.mjs +5550 -0
- package/dist/es/components/daterange-picker/daterange-picker.vue.d.ts +13 -0
- package/dist/es/components/daterange-picker/index.d.ts +4 -0
- package/dist/es/components/daterange-picker/index.mjs +6 -0
- package/dist/es/components/dialog/dialog.d.ts +13 -0
- package/dist/es/components/dialog/dialog.mjs +537 -0
- package/dist/es/components/dialog/dialog.vue.d.ts +38 -0
- package/dist/es/components/dialog/index.css +87 -0
- package/dist/es/components/dialog/index.d.ts +4 -0
- package/dist/es/components/dialog/index.mjs +6 -0
- package/dist/es/components/dialog-camera-upload/dialog-camera-upload.d.ts +33 -0
- package/dist/es/components/dialog-camera-upload/dialog-camera-upload.mjs +412 -0
- package/dist/es/components/dialog-camera-upload/dialog-camera-upload.vue.d.ts +23 -0
- package/dist/es/components/dialog-camera-upload/index.css +66 -0
- package/dist/es/components/dialog-camera-upload/index.d.ts +4 -0
- package/dist/es/components/dialog-camera-upload/index.mjs +6 -0
- package/dist/es/components/dialog-map-point/dialog-map-point.d.ts +9 -0
- package/dist/es/components/dialog-map-point/dialog-map-point.mjs +183 -0
- package/dist/es/components/dialog-map-point/dialog-map-point.vue.d.ts +22 -0
- package/dist/es/components/dialog-map-point/index.css +11 -0
- package/dist/es/components/dialog-map-point/index.d.ts +4 -0
- package/dist/es/components/dialog-map-point/index.mjs +6 -0
- package/dist/es/components/dialog-upload-images/dialog-upload-images.d.ts +16 -0
- package/dist/es/components/dialog-upload-images/dialog-upload-images.mjs +1391 -0
- package/dist/es/components/dialog-upload-images/dialog-upload-images.vue.d.ts +19 -0
- package/dist/es/components/dialog-upload-images/index.css +62 -0
- package/dist/es/components/dialog-upload-images/index.d.ts +4 -0
- package/dist/es/components/dialog-upload-images/index.mjs +6 -0
- package/dist/es/components/document.vue.d.ts +14 -0
- package/dist/es/components/drawer/drawer.d.ts +7 -0
- package/dist/es/components/drawer/drawer.mjs +412 -0
- package/dist/es/components/drawer/drawer.vue.d.ts +31 -0
- package/dist/es/components/drawer/index.css +56 -0
- package/dist/es/components/drawer/index.d.ts +4 -0
- package/dist/es/components/drawer/index.mjs +6 -0
- package/dist/es/components/easy-pagination/easy-pagination.d.ts +8 -0
- package/dist/es/components/easy-pagination/easy-pagination.mjs +74 -0
- package/dist/es/components/easy-pagination/easy-pagination.vue.d.ts +19 -0
- package/dist/es/components/easy-pagination/index.css +10 -0
- package/dist/es/components/easy-pagination/index.d.ts +4 -0
- package/dist/es/components/easy-pagination/index.mjs +6 -0
- package/dist/es/components/el-icon/el-icon.d.ts +6 -0
- package/dist/es/components/el-icon/el-icon.mjs +46 -0
- package/dist/es/components/el-icon/el-icon.vue.d.ts +6 -0
- package/dist/es/components/el-icon/index.css +7 -0
- package/dist/es/components/el-icon/index.d.ts +4 -0
- package/dist/es/components/el-icon/index.mjs +6 -0
- package/dist/es/components/example-wrapper.vue.d.ts +19 -0
- package/dist/es/components/flag/flag.mjs +44 -0
- package/dist/es/components/flag/flag.vue.d.ts +5 -0
- package/dist/es/components/flag/flags.d.ts +8 -0
- package/dist/es/components/flag/index.d.ts +4 -0
- package/dist/es/components/flag/index.mjs +6 -0
- package/dist/es/components/icon/icon.d.ts +6 -0
- package/dist/es/components/icon/icon.mjs +54 -0
- package/dist/es/components/icon/icon.vue.d.ts +3 -0
- package/dist/es/components/icon/icon2.mjs +27 -0
- package/dist/es/components/icon/index.css +9 -0
- package/dist/es/components/icon/index.d.ts +4 -0
- package/dist/es/components/icon/index.mjs +6 -0
- package/dist/es/components/image/image.d.ts +16 -0
- package/dist/es/components/image/image.mjs +167 -0
- package/dist/es/components/image/image.vue.d.ts +206 -0
- package/dist/es/components/image/index.css +20 -0
- package/dist/es/components/image/index.d.ts +4 -0
- package/dist/es/components/image/index.mjs +6 -0
- package/dist/es/components/input/index.css +9 -0
- package/dist/es/components/input/index.d.ts +4 -0
- package/dist/es/components/input/index.mjs +6 -0
- package/dist/es/components/input/input.d.ts +4 -0
- package/dist/es/components/input/input.mjs +85 -0
- package/dist/es/components/input/input.vue.d.ts +1232 -0
- package/dist/es/components/input-number/index.css +24 -0
- package/dist/es/components/input-number/index.d.ts +4 -0
- package/dist/es/components/input-number/index.mjs +6 -0
- package/dist/es/components/input-number/input-number.d.ts +8 -0
- package/dist/es/components/input-number/input-number.mjs +137 -0
- package/dist/es/components/input-number/input-number.vue.d.ts +35 -0
- package/dist/es/components/pca-picker/components/c.vue.d.ts +123 -0
- package/dist/es/components/pca-picker/components/elevator-item.vue.d.ts +7 -0
- package/dist/es/components/pca-picker/components/filter.vue.d.ts +2 -0
- package/dist/es/components/pca-picker/components/history.vue.d.ts +2 -0
- package/dist/es/components/pca-picker/components/hot.vue.d.ts +2 -0
- package/dist/es/components/pca-picker/components/p.vue.d.ts +2 -0
- package/dist/es/components/pca-picker/components/pca.vue.d.ts +9 -0
- package/dist/es/components/pca-picker/index.css +107 -0
- package/dist/es/components/pca-picker/index.d.ts +4 -0
- package/dist/es/components/pca-picker/index.mjs +6 -0
- package/dist/es/components/pca-picker/pca-picker.d.ts +78 -0
- package/dist/es/components/pca-picker/pca-picker.mjs +1667 -0
- package/dist/es/components/pca-picker/pca-picker.vue.d.ts +583 -0
- package/dist/es/components/qr-code/index.d.ts +4 -0
- package/dist/es/components/qr-code/index.mjs +6 -0
- package/dist/es/components/qr-code/qr-code.d.ts +9 -0
- package/dist/es/components/qr-code/qr-code.mjs +69 -0
- package/dist/es/components/qr-code/qr-code.vue.d.ts +13 -0
- package/dist/es/components/screenfull/index.css +14 -0
- package/dist/es/components/screenfull/index.d.ts +4 -0
- package/dist/es/components/screenfull/index.mjs +6 -0
- package/dist/es/components/screenfull/screenfull.d.ts +4 -0
- package/dist/es/components/screenfull/screenfull.mjs +91 -0
- package/dist/es/components/screenfull/screenfull.vue.d.ts +20 -0
- package/dist/es/components/select/index.css +9 -0
- package/dist/es/components/select/index.d.ts +4 -0
- package/dist/es/components/select/index.mjs +6 -0
- package/dist/es/components/select/select.d.ts +6 -0
- package/dist/es/components/select/select.mjs +63 -0
- package/dist/es/components/select/select.vue.d.ts +6 -0
- package/dist/es/components/single-player/index.css +45 -0
- package/dist/es/components/single-player/index.d.ts +4 -0
- package/dist/es/components/single-player/index.mjs +6 -0
- package/dist/es/components/single-player/single-player.d.ts +4 -0
- package/dist/es/components/single-player/single-player.mjs +1172 -0
- package/dist/es/components/single-player/single-player.vue.d.ts +13 -0
- package/dist/es/components/svg-icon/index.css +9 -0
- package/dist/es/components/svg-icon/index.d.ts +4 -0
- package/dist/es/components/svg-icon/index.mjs +6 -0
- package/dist/es/components/svg-icon/svg-icon.d.ts +5 -0
- package/dist/es/components/svg-icon/svg-icon.mjs +46 -0
- package/dist/es/components/svg-icon/svg-icon.vue.d.ts +18 -0
- package/dist/es/components/switch/index.css +15 -0
- package/dist/es/components/switch/index.d.ts +4 -0
- package/dist/es/components/switch/index.mjs +6 -0
- package/dist/es/components/switch/switch.d.ts +9 -0
- package/dist/es/components/switch/switch.mjs +82 -0
- package/dist/es/components/switch/switch.vue.d.ts +14 -0
- package/dist/es/components/sync-scroll-container/index.css +82 -0
- package/dist/es/components/sync-scroll-container/index.d.ts +4 -0
- package/dist/es/components/sync-scroll-container/index.mjs +6 -0
- package/dist/es/components/sync-scroll-container/sync-scroll-container.d.ts +6 -0
- package/dist/es/components/sync-scroll-container/sync-scroll-container.mjs +157 -0
- package/dist/es/components/sync-scroll-container/sync-scroll-container.vue.d.ts +36 -0
- package/dist/es/components/tags/index.css +17 -0
- package/dist/es/components/tags/index.d.ts +4 -0
- package/dist/es/components/tags/index.mjs +6 -0
- package/dist/es/components/tags/tags.d.ts +9 -0
- package/dist/es/components/tags/tags.mjs +296 -0
- package/dist/es/components/tags/tags.vue.d.ts +20 -0
- package/dist/es/components/text-ellipsis/index.css +15 -0
- package/dist/es/components/text-ellipsis/index.d.ts +4 -0
- package/dist/es/components/text-ellipsis/index.mjs +6 -0
- package/dist/es/components/text-ellipsis/text-ellipsis.d.ts +12 -0
- package/dist/es/components/text-ellipsis/text-ellipsis.mjs +137 -0
- package/dist/es/components/text-ellipsis/text-ellipsis.vue.d.ts +41 -0
- package/dist/es/components/thousand-input/index.css +4 -0
- package/dist/es/components/thousand-input/index.d.ts +4 -0
- package/dist/es/components/thousand-input/index.mjs +6 -0
- package/dist/es/components/thousand-input/thousand-input.d.ts +11 -0
- package/dist/es/components/thousand-input/thousand-input.mjs +159 -0
- package/dist/es/components/thousand-input/thousand-input.vue.d.ts +2558 -0
- package/dist/es/components/tinymce/config.d.ts +25 -0
- package/dist/es/components/tinymce/index.css +9 -0
- package/dist/es/components/tinymce/index.d.ts +4 -0
- package/dist/es/components/tinymce/index.mjs +6 -0
- package/dist/es/components/tinymce/tinymce.d.ts +9 -0
- package/dist/es/components/tinymce/tinymce.mjs +176 -0
- package/dist/es/components/tinymce/tinymce.vue.d.ts +20 -0
- package/dist/es/components/tree-picker/components/popover-cascader.d.ts +8 -0
- package/dist/es/components/tree-picker/components/popover-cascader.vue.d.ts +1361 -0
- package/dist/es/components/tree-picker/docs/data.d.ts +2 -0
- package/dist/es/components/tree-picker/index.css +41 -0
- package/dist/es/components/tree-picker/index.d.ts +4 -0
- package/dist/es/components/tree-picker/index.mjs +6 -0
- package/dist/es/components/tree-picker/popover-cascader.css +23 -0
- package/dist/es/components/tree-picker/tree-picker.d.ts +14 -0
- package/dist/es/components/tree-picker/tree-picker.mjs +173 -0
- package/dist/es/components/tree-picker/tree-picker.vue.d.ts +575 -0
- package/dist/es/components/upload-file/index.css +30 -0
- package/dist/es/components/upload-file/index.d.ts +4 -0
- package/dist/es/components/upload-file/index.mjs +6 -0
- package/dist/es/components/upload-file/upload-file.d.ts +39 -0
- package/dist/es/components/upload-file/upload-file.mjs +202 -0
- package/dist/es/components/upload-file/upload-file.vue.d.ts +30 -0
- package/dist/es/directives/cleave/index.d.ts +3 -0
- package/dist/es/directives/focus/index.d.ts +4 -0
- package/dist/es/directives/index.d.ts +3 -0
- package/dist/es/directives/thousand/index.d.ts +3 -0
- package/dist/es/index.d.ts +42 -0
- package/dist/es/index.mjs +122 -0
- package/dist/es/use/useSmallScreen/index.d.ts +4 -0
- package/dist/es/use/useSmallScreen/index.mjs +10 -0
- package/dist/es/use/useStore/index.d.ts +3 -0
- package/dist/es/use/useStore/index.mjs +22 -0
- package/dist/es/utils/index.d.ts +6 -0
- package/dist/es/utils/resolver.d.ts +3 -0
- package/dist/es/utils/resolver.mjs +24 -0
- package/dist/es/utils/typescript.d.ts +6 -0
- package/dist/global.d.ts +42 -0
- package/dist/index.css +869 -0
- package/package.json +58 -0
|
@@ -0,0 +1,3743 @@
|
|
|
1
|
+
import { defineComponent, inject, createVNode, Comment, computed, createElementBlock, openBlock, normalizeClass, unref, createCommentVNode, createBlock, withModifiers, withCtx, createElementVNode, Fragment, getCurrentInstance, ref, renderList, createTextVNode, toDisplayString, renderSlot, useSlots, provide, reactive, watch, onBeforeUpdate, onMounted, nextTick, useAttrs, withDirectives, isRef, vShow, normalizeStyle, createSlots, resolveDynamicComponent, withKeys, vModelText, Transition, mergeProps, toHandlers, onUpdated, h, resolveComponent, useTemplateRef, onBeforeUnmount } from 'vue';
|
|
2
|
+
import { j as isLeaf, k as focusNode, l as getSibling, e as useResizeObserver, m as useCssVar, c as useEventListener } from './CEClY-_T.mjs';
|
|
3
|
+
import { E as ElInput } from './Dvi7RsXg.mjs';
|
|
4
|
+
import { g as unique, c as castArray, u as useTooltipContentProps, E as Ee, a as ElTooltip } from './DqUIKX7f.mjs';
|
|
5
|
+
import { E as ElScrollbar } from './CaTfZePA.mjs';
|
|
6
|
+
import { t as tagProps, E as ElTag } from './CZ4ggqDE.mjs';
|
|
7
|
+
import { E as ElIcon } from './DMHNh_tw.mjs';
|
|
8
|
+
import { Check, Loading, ArrowRight, CircleClose, ArrowDown, CaretRight } from '@element-plus/icons-vue';
|
|
9
|
+
import { u as useNamespace, i as isArray, a as isEmpty, j as isFunction, g as isUndefined, C as isPropAbsent, c as buildProps, N as NOOP, d as definePropType, o as isClient, x as isBoolean, e as debugWarn, w as useDebounceFn, G as isPromise, H as hasOwn, k as isNil, h as isString, s as isObject } from './E_WRn0OP.mjs';
|
|
10
|
+
import { u as useSizeProp, c as componentSizes } from './CS4VKsqy.mjs';
|
|
11
|
+
import { i as iconPropType } from '../components/icon/icon2.mjs';
|
|
12
|
+
import { u as useEmptyValuesProps, a as useEmptyValues } from './C5hWsUfD.mjs';
|
|
13
|
+
import { C as CHANGE_EVENT, U as UPDATE_MODEL_EVENT } from './Ct6q2FXg.mjs';
|
|
14
|
+
import { _ as _export_sfc, w as withInstall } from './D389hx_T.mjs';
|
|
15
|
+
import { C as ClickOutside } from './HSv8BL8o.mjs';
|
|
16
|
+
import { u as useLocale } from './aibQ9WSZ.mjs';
|
|
17
|
+
import { u as useFormItem, b as useFormDisabled, c as useFormSize } from './DZACQ9LT.mjs';
|
|
18
|
+
import { a as useComposition, u as useFocusController } from './JCIyOUEY.mjs';
|
|
19
|
+
import { g as getEventCode, E as EVENT_CODE } from './BJS5Pdfp.mjs';
|
|
20
|
+
import { c as cloneDeep } from './CyxEcbcy.mjs';
|
|
21
|
+
import { b as ElCheckbox, c as ElRadio } from './D3DXeVfC.mjs';
|
|
22
|
+
import { u as useVModel } from './CD98REcR.mjs';
|
|
23
|
+
import { r as removeClass, b as addClass } from './D5259bwd.mjs';
|
|
24
|
+
import { u as useId, f as formItemContextKey } from './8rLUmOVR.mjs';
|
|
25
|
+
import { i as isEqual } from './-EkpfdcW.mjs';
|
|
26
|
+
import { s as scrollIntoView } from './DyDMGLoF.mjs';
|
|
27
|
+
import { b as baseFlatten } from './C2LgraHx.mjs';
|
|
28
|
+
import { _ as _export_sfc$1 } from './pcqpp-6-.mjs';
|
|
29
|
+
|
|
30
|
+
/** Used as references for various `Number` constants. */
|
|
31
|
+
var INFINITY = 1 / 0;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Recursively flattens `array`.
|
|
35
|
+
*
|
|
36
|
+
* @static
|
|
37
|
+
* @memberOf _
|
|
38
|
+
* @since 3.0.0
|
|
39
|
+
* @category Array
|
|
40
|
+
* @param {Array} array The array to flatten.
|
|
41
|
+
* @returns {Array} Returns the new flattened array.
|
|
42
|
+
* @example
|
|
43
|
+
*
|
|
44
|
+
* _.flattenDeep([1, [2, [3, [4]], 5]]);
|
|
45
|
+
* // => [1, 2, 3, 4, 5]
|
|
46
|
+
*/
|
|
47
|
+
function flattenDeep(array) {
|
|
48
|
+
var length = array == null ? 0 : array.length;
|
|
49
|
+
return length ? baseFlatten(array, INFINITY) : [];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const CASCADER_PANEL_INJECTION_KEY = Symbol();
|
|
53
|
+
|
|
54
|
+
function isVNodeEmpty(vnodes) {
|
|
55
|
+
return !!(isArray(vnodes) ? vnodes.every(({
|
|
56
|
+
type
|
|
57
|
+
}) => type === Comment) : (vnodes == null ? void 0 : vnodes.type) === Comment);
|
|
58
|
+
}
|
|
59
|
+
var NodeContent$1 = defineComponent({
|
|
60
|
+
name: "NodeContent",
|
|
61
|
+
props: {
|
|
62
|
+
node: {
|
|
63
|
+
type: Object,
|
|
64
|
+
required: true
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
setup(props) {
|
|
68
|
+
const ns = useNamespace("cascader-node");
|
|
69
|
+
const {
|
|
70
|
+
renderLabelFn
|
|
71
|
+
} = inject(CASCADER_PANEL_INJECTION_KEY);
|
|
72
|
+
const {
|
|
73
|
+
node
|
|
74
|
+
} = props;
|
|
75
|
+
const {
|
|
76
|
+
data,
|
|
77
|
+
label: nodeLabel
|
|
78
|
+
} = node;
|
|
79
|
+
const label = () => {
|
|
80
|
+
const renderLabel = renderLabelFn == null ? void 0 : renderLabelFn({
|
|
81
|
+
node,
|
|
82
|
+
data
|
|
83
|
+
});
|
|
84
|
+
return isVNodeEmpty(renderLabel) ? nodeLabel : renderLabel != null ? renderLabel : nodeLabel;
|
|
85
|
+
};
|
|
86
|
+
return () => createVNode("span", {
|
|
87
|
+
"class": ns.e("label")
|
|
88
|
+
}, [label()]);
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
const __default__$5 = defineComponent({
|
|
93
|
+
name: "ElCascaderNode"
|
|
94
|
+
});
|
|
95
|
+
const _sfc_main$9 = /* @__PURE__ */ defineComponent({
|
|
96
|
+
...__default__$5,
|
|
97
|
+
props: {
|
|
98
|
+
node: {
|
|
99
|
+
type: Object,
|
|
100
|
+
required: true
|
|
101
|
+
},
|
|
102
|
+
menuId: String
|
|
103
|
+
},
|
|
104
|
+
emits: ["expand"],
|
|
105
|
+
setup(__props, { emit }) {
|
|
106
|
+
const props = __props;
|
|
107
|
+
const panel = inject(CASCADER_PANEL_INJECTION_KEY);
|
|
108
|
+
const ns = useNamespace("cascader-node");
|
|
109
|
+
const isHoverMenu = computed(() => panel.isHoverMenu);
|
|
110
|
+
const multiple = computed(() => panel.config.multiple);
|
|
111
|
+
const checkStrictly = computed(() => panel.config.checkStrictly);
|
|
112
|
+
const showPrefix = computed(() => panel.config.showPrefix);
|
|
113
|
+
const checkedNodeId = computed(() => {
|
|
114
|
+
var _a;
|
|
115
|
+
return (_a = panel.checkedNodes[0]) == null ? void 0 : _a.uid;
|
|
116
|
+
});
|
|
117
|
+
const isDisabled = computed(() => props.node.isDisabled);
|
|
118
|
+
const isLeaf = computed(() => props.node.isLeaf);
|
|
119
|
+
const expandable = computed(() => checkStrictly.value && !isLeaf.value || !isDisabled.value);
|
|
120
|
+
const inExpandingPath = computed(() => isInPath(panel.expandingNode));
|
|
121
|
+
const inCheckedPath = computed(() => checkStrictly.value && panel.checkedNodes.some(isInPath));
|
|
122
|
+
const isInPath = (node) => {
|
|
123
|
+
var _a;
|
|
124
|
+
const { level, uid } = props.node;
|
|
125
|
+
return ((_a = node == null ? void 0 : node.pathNodes[level - 1]) == null ? void 0 : _a.uid) === uid;
|
|
126
|
+
};
|
|
127
|
+
const doExpand = () => {
|
|
128
|
+
if (inExpandingPath.value)
|
|
129
|
+
return;
|
|
130
|
+
panel.expandNode(props.node);
|
|
131
|
+
};
|
|
132
|
+
const doCheck = (checked) => {
|
|
133
|
+
const { node } = props;
|
|
134
|
+
if (checked === node.checked)
|
|
135
|
+
return;
|
|
136
|
+
panel.handleCheckChange(node, checked);
|
|
137
|
+
};
|
|
138
|
+
const doLoad = () => {
|
|
139
|
+
panel.lazyLoad(props.node, () => {
|
|
140
|
+
if (!isLeaf.value)
|
|
141
|
+
doExpand();
|
|
142
|
+
});
|
|
143
|
+
};
|
|
144
|
+
const handleHoverExpand = (e) => {
|
|
145
|
+
if (!isHoverMenu.value)
|
|
146
|
+
return;
|
|
147
|
+
handleExpand();
|
|
148
|
+
!isLeaf.value && emit("expand", e);
|
|
149
|
+
};
|
|
150
|
+
const handleExpand = () => {
|
|
151
|
+
const { node } = props;
|
|
152
|
+
if (!expandable.value || node.loading)
|
|
153
|
+
return;
|
|
154
|
+
node.loaded ? doExpand() : doLoad();
|
|
155
|
+
};
|
|
156
|
+
const handleClick = () => {
|
|
157
|
+
if (isLeaf.value && !isDisabled.value && !checkStrictly.value && !multiple.value) {
|
|
158
|
+
handleCheck(true);
|
|
159
|
+
} else if ((panel.config.checkOnClickNode && (multiple.value || checkStrictly.value) || isLeaf.value && panel.config.checkOnClickLeaf) && !isDisabled.value) {
|
|
160
|
+
handleSelectCheck(!props.node.checked);
|
|
161
|
+
} else if (!isHoverMenu.value) {
|
|
162
|
+
handleExpand();
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
const handleSelectCheck = (checked) => {
|
|
166
|
+
if (checkStrictly.value) {
|
|
167
|
+
doCheck(checked);
|
|
168
|
+
if (props.node.loaded) {
|
|
169
|
+
doExpand();
|
|
170
|
+
}
|
|
171
|
+
} else {
|
|
172
|
+
handleCheck(checked);
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
const handleCheck = (checked) => {
|
|
176
|
+
if (!props.node.loaded) {
|
|
177
|
+
doLoad();
|
|
178
|
+
} else {
|
|
179
|
+
doCheck(checked);
|
|
180
|
+
!checkStrictly.value && doExpand();
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
return (_ctx, _cache) => {
|
|
184
|
+
return openBlock(), createElementBlock("li", {
|
|
185
|
+
id: `${__props.menuId}-${__props.node.uid}`,
|
|
186
|
+
role: "menuitem",
|
|
187
|
+
"aria-haspopup": !unref(isLeaf),
|
|
188
|
+
"aria-owns": unref(isLeaf) ? void 0 : __props.menuId,
|
|
189
|
+
"aria-expanded": unref(inExpandingPath),
|
|
190
|
+
tabindex: unref(expandable) ? -1 : void 0,
|
|
191
|
+
class: normalizeClass([
|
|
192
|
+
unref(ns).b(),
|
|
193
|
+
unref(ns).is("selectable", unref(checkStrictly)),
|
|
194
|
+
unref(ns).is("active", __props.node.checked),
|
|
195
|
+
unref(ns).is("disabled", !unref(expandable)),
|
|
196
|
+
unref(inExpandingPath) && "in-active-path",
|
|
197
|
+
unref(inCheckedPath) && "in-checked-path"
|
|
198
|
+
]),
|
|
199
|
+
onMouseenter: handleHoverExpand,
|
|
200
|
+
onFocus: handleHoverExpand,
|
|
201
|
+
onClick: handleClick
|
|
202
|
+
}, [
|
|
203
|
+
createCommentVNode(" prefix "),
|
|
204
|
+
unref(multiple) && unref(showPrefix) ? (openBlock(), createBlock(unref(ElCheckbox), {
|
|
205
|
+
key: 0,
|
|
206
|
+
"model-value": __props.node.checked,
|
|
207
|
+
indeterminate: __props.node.indeterminate,
|
|
208
|
+
disabled: unref(isDisabled),
|
|
209
|
+
onClick: withModifiers(() => {
|
|
210
|
+
}, ["stop"]),
|
|
211
|
+
"onUpdate:modelValue": handleSelectCheck
|
|
212
|
+
}, null, 8, ["model-value", "indeterminate", "disabled", "onClick"])) : unref(checkStrictly) && unref(showPrefix) ? (openBlock(), createBlock(unref(ElRadio), {
|
|
213
|
+
key: 1,
|
|
214
|
+
"model-value": unref(checkedNodeId),
|
|
215
|
+
label: __props.node.uid,
|
|
216
|
+
disabled: unref(isDisabled),
|
|
217
|
+
"onUpdate:modelValue": handleSelectCheck,
|
|
218
|
+
onClick: withModifiers(() => {
|
|
219
|
+
}, ["stop"])
|
|
220
|
+
}, {
|
|
221
|
+
default: withCtx(() => [
|
|
222
|
+
createCommentVNode("\n Add an empty element to avoid render label,\n do not use empty fragment here for https://github.com/vuejs/vue-next/pull/2485\n "),
|
|
223
|
+
createElementVNode("span")
|
|
224
|
+
]),
|
|
225
|
+
_: 1
|
|
226
|
+
}, 8, ["model-value", "label", "disabled", "onClick"])) : unref(isLeaf) && __props.node.checked ? (openBlock(), createBlock(unref(ElIcon), {
|
|
227
|
+
key: 2,
|
|
228
|
+
class: normalizeClass(unref(ns).e("prefix"))
|
|
229
|
+
}, {
|
|
230
|
+
default: withCtx(() => [
|
|
231
|
+
createVNode(unref(Check))
|
|
232
|
+
]),
|
|
233
|
+
_: 1
|
|
234
|
+
}, 8, ["class"])) : createCommentVNode("v-if", true),
|
|
235
|
+
createCommentVNode(" content "),
|
|
236
|
+
createVNode(unref(NodeContent$1), { node: __props.node }, null, 8, ["node"]),
|
|
237
|
+
createCommentVNode(" postfix "),
|
|
238
|
+
!unref(isLeaf) ? (openBlock(), createElementBlock(Fragment, { key: 3 }, [
|
|
239
|
+
__props.node.loading ? (openBlock(), createBlock(unref(ElIcon), {
|
|
240
|
+
key: 0,
|
|
241
|
+
class: normalizeClass([unref(ns).is("loading"), unref(ns).e("postfix")])
|
|
242
|
+
}, {
|
|
243
|
+
default: withCtx(() => [
|
|
244
|
+
createVNode(unref(Loading))
|
|
245
|
+
]),
|
|
246
|
+
_: 1
|
|
247
|
+
}, 8, ["class"])) : (openBlock(), createBlock(unref(ElIcon), {
|
|
248
|
+
key: 1,
|
|
249
|
+
class: normalizeClass(["arrow-right", unref(ns).e("postfix")])
|
|
250
|
+
}, {
|
|
251
|
+
default: withCtx(() => [
|
|
252
|
+
createVNode(unref(ArrowRight))
|
|
253
|
+
]),
|
|
254
|
+
_: 1
|
|
255
|
+
}, 8, ["class"]))
|
|
256
|
+
], 64)) : createCommentVNode("v-if", true)
|
|
257
|
+
], 42, ["id", "aria-haspopup", "aria-owns", "aria-expanded", "tabindex"]);
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
var ElCascaderNode = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["__file", "node.vue"]]);
|
|
262
|
+
|
|
263
|
+
const __default__$4 = defineComponent({
|
|
264
|
+
name: "ElCascaderMenu"
|
|
265
|
+
});
|
|
266
|
+
const _sfc_main$8 = /* @__PURE__ */ defineComponent({
|
|
267
|
+
...__default__$4,
|
|
268
|
+
props: {
|
|
269
|
+
nodes: {
|
|
270
|
+
type: Array,
|
|
271
|
+
required: true
|
|
272
|
+
},
|
|
273
|
+
index: {
|
|
274
|
+
type: Number,
|
|
275
|
+
required: true
|
|
276
|
+
}
|
|
277
|
+
},
|
|
278
|
+
setup(__props) {
|
|
279
|
+
const props = __props;
|
|
280
|
+
const instance = getCurrentInstance();
|
|
281
|
+
const ns = useNamespace("cascader-menu");
|
|
282
|
+
const { t } = useLocale();
|
|
283
|
+
const id = useId();
|
|
284
|
+
let activeNode;
|
|
285
|
+
let hoverTimer;
|
|
286
|
+
const panel = inject(CASCADER_PANEL_INJECTION_KEY);
|
|
287
|
+
const hoverZone = ref();
|
|
288
|
+
const isEmpty = computed(() => !props.nodes.length);
|
|
289
|
+
const isLoading = computed(() => !panel.initialLoaded);
|
|
290
|
+
const menuId = computed(() => `${id.value}-${props.index}`);
|
|
291
|
+
const handleExpand = (e) => {
|
|
292
|
+
activeNode = e.target;
|
|
293
|
+
};
|
|
294
|
+
const handleMouseMove = (e) => {
|
|
295
|
+
var _a;
|
|
296
|
+
if (!panel.isHoverMenu || !activeNode || !hoverZone.value)
|
|
297
|
+
return;
|
|
298
|
+
if (activeNode.contains(e.target)) {
|
|
299
|
+
clearHoverTimer();
|
|
300
|
+
const el = instance.vnode.el;
|
|
301
|
+
const { left } = el.getBoundingClientRect();
|
|
302
|
+
const { offsetWidth, offsetHeight } = el;
|
|
303
|
+
const startX = e.clientX - left;
|
|
304
|
+
const top = activeNode.offsetTop;
|
|
305
|
+
const bottom = top + activeNode.offsetHeight;
|
|
306
|
+
const scrollTop = ((_a = el.querySelector(`.${ns.e("wrap")}`)) == null ? void 0 : _a.scrollTop) || 0;
|
|
307
|
+
hoverZone.value.innerHTML = `
|
|
308
|
+
<path style="pointer-events: auto;" fill="transparent" d="M${startX} ${top} L${offsetWidth} ${scrollTop} V${top} Z" />
|
|
309
|
+
<path style="pointer-events: auto;" fill="transparent" d="M${startX} ${bottom} L${offsetWidth} ${offsetHeight + scrollTop} V${bottom} Z" />
|
|
310
|
+
`;
|
|
311
|
+
} else if (!hoverTimer) {
|
|
312
|
+
hoverTimer = window.setTimeout(clearHoverZone, panel.config.hoverThreshold);
|
|
313
|
+
}
|
|
314
|
+
};
|
|
315
|
+
const clearHoverTimer = () => {
|
|
316
|
+
if (!hoverTimer)
|
|
317
|
+
return;
|
|
318
|
+
clearTimeout(hoverTimer);
|
|
319
|
+
hoverTimer = void 0;
|
|
320
|
+
};
|
|
321
|
+
const clearHoverZone = () => {
|
|
322
|
+
if (!hoverZone.value)
|
|
323
|
+
return;
|
|
324
|
+
hoverZone.value.innerHTML = "";
|
|
325
|
+
clearHoverTimer();
|
|
326
|
+
};
|
|
327
|
+
return (_ctx, _cache) => {
|
|
328
|
+
return openBlock(), createBlock(unref(ElScrollbar), {
|
|
329
|
+
key: unref(menuId),
|
|
330
|
+
tag: "ul",
|
|
331
|
+
role: "menu",
|
|
332
|
+
class: normalizeClass(unref(ns).b()),
|
|
333
|
+
"wrap-class": unref(ns).e("wrap"),
|
|
334
|
+
"view-class": [unref(ns).e("list"), unref(ns).is("empty", unref(isEmpty))],
|
|
335
|
+
onMousemove: handleMouseMove,
|
|
336
|
+
onMouseleave: clearHoverZone
|
|
337
|
+
}, {
|
|
338
|
+
default: withCtx(() => {
|
|
339
|
+
var _a;
|
|
340
|
+
return [
|
|
341
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(__props.nodes, (node) => {
|
|
342
|
+
return openBlock(), createBlock(ElCascaderNode, {
|
|
343
|
+
key: node.uid,
|
|
344
|
+
node,
|
|
345
|
+
"menu-id": unref(menuId),
|
|
346
|
+
onExpand: handleExpand
|
|
347
|
+
}, null, 8, ["node", "menu-id"]);
|
|
348
|
+
}), 128)),
|
|
349
|
+
unref(isLoading) ? (openBlock(), createElementBlock("div", {
|
|
350
|
+
key: 0,
|
|
351
|
+
class: normalizeClass(unref(ns).e("empty-text"))
|
|
352
|
+
}, [
|
|
353
|
+
createVNode(unref(ElIcon), {
|
|
354
|
+
size: "14",
|
|
355
|
+
class: normalizeClass(unref(ns).is("loading"))
|
|
356
|
+
}, {
|
|
357
|
+
default: withCtx(() => [
|
|
358
|
+
createVNode(unref(Loading))
|
|
359
|
+
]),
|
|
360
|
+
_: 1
|
|
361
|
+
}, 8, ["class"]),
|
|
362
|
+
createTextVNode(" " + toDisplayString(unref(t)("el.cascader.loading")), 1)
|
|
363
|
+
], 2)) : unref(isEmpty) ? (openBlock(), createElementBlock("div", {
|
|
364
|
+
key: 1,
|
|
365
|
+
class: normalizeClass(unref(ns).e("empty-text"))
|
|
366
|
+
}, [
|
|
367
|
+
renderSlot(_ctx.$slots, "empty", {}, () => [
|
|
368
|
+
createTextVNode(toDisplayString(unref(t)("el.cascader.noData")), 1)
|
|
369
|
+
])
|
|
370
|
+
], 2)) : ((_a = unref(panel)) == null ? void 0 : _a.isHoverMenu) ? (openBlock(), createElementBlock(Fragment, { key: 2 }, [
|
|
371
|
+
createCommentVNode(" eslint-disable-next-line vue/html-self-closing "),
|
|
372
|
+
(openBlock(), createElementBlock("svg", {
|
|
373
|
+
ref_key: "hoverZone",
|
|
374
|
+
ref: hoverZone,
|
|
375
|
+
class: normalizeClass(unref(ns).e("hover-zone"))
|
|
376
|
+
}, null, 2))
|
|
377
|
+
], 2112)) : createCommentVNode("v-if", true)
|
|
378
|
+
];
|
|
379
|
+
}),
|
|
380
|
+
_: 3
|
|
381
|
+
}, 8, ["class", "wrap-class", "view-class"]);
|
|
382
|
+
};
|
|
383
|
+
}
|
|
384
|
+
});
|
|
385
|
+
var ElCascaderMenu = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["__file", "menu.vue"]]);
|
|
386
|
+
|
|
387
|
+
let uid = 0;
|
|
388
|
+
const calculatePathNodes = (node) => {
|
|
389
|
+
const nodes = [node];
|
|
390
|
+
let { parent } = node;
|
|
391
|
+
while (parent) {
|
|
392
|
+
nodes.unshift(parent);
|
|
393
|
+
parent = parent.parent;
|
|
394
|
+
}
|
|
395
|
+
return nodes;
|
|
396
|
+
};
|
|
397
|
+
let Node$1 = class Node {
|
|
398
|
+
constructor(data, config, parent, root = false) {
|
|
399
|
+
this.data = data;
|
|
400
|
+
this.config = config;
|
|
401
|
+
this.parent = parent;
|
|
402
|
+
this.root = root;
|
|
403
|
+
this.uid = uid++;
|
|
404
|
+
this.checked = false;
|
|
405
|
+
this.indeterminate = false;
|
|
406
|
+
this.loading = false;
|
|
407
|
+
const { value: valueKey, label: labelKey, children: childrenKey } = config;
|
|
408
|
+
const childrenData = data[childrenKey];
|
|
409
|
+
const pathNodes = calculatePathNodes(this);
|
|
410
|
+
this.level = root ? 0 : parent ? parent.level + 1 : 1;
|
|
411
|
+
this.value = data[valueKey];
|
|
412
|
+
this.label = data[labelKey];
|
|
413
|
+
this.pathNodes = pathNodes;
|
|
414
|
+
this.pathValues = pathNodes.map((node) => node.value);
|
|
415
|
+
this.pathLabels = pathNodes.map((node) => node.label);
|
|
416
|
+
this.childrenData = childrenData;
|
|
417
|
+
this.children = (childrenData || []).map((child) => new Node(child, config, this));
|
|
418
|
+
this.loaded = !config.lazy || this.isLeaf || !isEmpty(childrenData);
|
|
419
|
+
this.text = "";
|
|
420
|
+
}
|
|
421
|
+
get isDisabled() {
|
|
422
|
+
const { data, parent, config } = this;
|
|
423
|
+
const { disabled, checkStrictly } = config;
|
|
424
|
+
const isDisabled = isFunction(disabled) ? disabled(data, this) : !!data[disabled];
|
|
425
|
+
return isDisabled || !checkStrictly && !!(parent == null ? void 0 : parent.isDisabled);
|
|
426
|
+
}
|
|
427
|
+
get isLeaf() {
|
|
428
|
+
const { data, config, childrenData, loaded } = this;
|
|
429
|
+
const { lazy, leaf } = config;
|
|
430
|
+
const isLeaf = isFunction(leaf) ? leaf(data, this) : data[leaf];
|
|
431
|
+
return isUndefined(isLeaf) ? lazy && !loaded ? false : !(isArray(childrenData) && childrenData.length) : !!isLeaf;
|
|
432
|
+
}
|
|
433
|
+
get valueByOption() {
|
|
434
|
+
return this.config.emitPath ? this.pathValues : this.value;
|
|
435
|
+
}
|
|
436
|
+
appendChild(childData) {
|
|
437
|
+
const { childrenData, children } = this;
|
|
438
|
+
const node = new Node(childData, this.config, this);
|
|
439
|
+
if (isArray(childrenData)) {
|
|
440
|
+
childrenData.push(childData);
|
|
441
|
+
} else {
|
|
442
|
+
this.childrenData = [childData];
|
|
443
|
+
}
|
|
444
|
+
children.push(node);
|
|
445
|
+
return node;
|
|
446
|
+
}
|
|
447
|
+
calcText(allLevels, separator) {
|
|
448
|
+
const text = allLevels ? this.pathLabels.join(separator) : this.label;
|
|
449
|
+
this.text = text;
|
|
450
|
+
return text;
|
|
451
|
+
}
|
|
452
|
+
broadcast(checked) {
|
|
453
|
+
this.children.forEach((child) => {
|
|
454
|
+
var _a;
|
|
455
|
+
if (child) {
|
|
456
|
+
child.broadcast(checked);
|
|
457
|
+
(_a = child.onParentCheck) == null ? void 0 : _a.call(child, checked);
|
|
458
|
+
}
|
|
459
|
+
});
|
|
460
|
+
}
|
|
461
|
+
emit() {
|
|
462
|
+
var _a;
|
|
463
|
+
const { parent } = this;
|
|
464
|
+
if (parent) {
|
|
465
|
+
(_a = parent.onChildCheck) == null ? void 0 : _a.call(parent);
|
|
466
|
+
parent.emit();
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
onParentCheck(checked) {
|
|
470
|
+
if (!this.isDisabled) {
|
|
471
|
+
this.setCheckState(checked);
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
onChildCheck() {
|
|
475
|
+
const { children } = this;
|
|
476
|
+
const validChildren = children.filter((child) => !child.isDisabled);
|
|
477
|
+
const checked = validChildren.length ? validChildren.every((child) => child.checked) : false;
|
|
478
|
+
this.setCheckState(checked);
|
|
479
|
+
}
|
|
480
|
+
setCheckState(checked) {
|
|
481
|
+
const totalNum = this.children.length;
|
|
482
|
+
const checkedNum = this.children.reduce((c, p) => {
|
|
483
|
+
const num = p.checked ? 1 : p.indeterminate ? 0.5 : 0;
|
|
484
|
+
return c + num;
|
|
485
|
+
}, 0);
|
|
486
|
+
this.checked = this.loaded && this.children.filter((child) => !child.isDisabled).every((child) => child.loaded && child.checked) && checked;
|
|
487
|
+
this.indeterminate = this.loaded && checkedNum !== totalNum && checkedNum > 0;
|
|
488
|
+
}
|
|
489
|
+
doCheck(checked) {
|
|
490
|
+
if (this.checked === checked)
|
|
491
|
+
return;
|
|
492
|
+
const { checkStrictly, multiple } = this.config;
|
|
493
|
+
if (checkStrictly || !multiple) {
|
|
494
|
+
this.checked = checked;
|
|
495
|
+
} else {
|
|
496
|
+
this.broadcast(checked);
|
|
497
|
+
this.setCheckState(checked);
|
|
498
|
+
this.emit();
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
};
|
|
502
|
+
|
|
503
|
+
const flatNodes = (nodes, leafOnly) => {
|
|
504
|
+
return nodes.reduce((res, node) => {
|
|
505
|
+
if (node.isLeaf) {
|
|
506
|
+
res.push(node);
|
|
507
|
+
} else {
|
|
508
|
+
!leafOnly && res.push(node);
|
|
509
|
+
res = res.concat(flatNodes(node.children, leafOnly));
|
|
510
|
+
}
|
|
511
|
+
return res;
|
|
512
|
+
}, []);
|
|
513
|
+
};
|
|
514
|
+
class Store {
|
|
515
|
+
constructor(data, config) {
|
|
516
|
+
this.config = config;
|
|
517
|
+
const nodes = (data || []).map((nodeData) => new Node$1(nodeData, this.config));
|
|
518
|
+
this.nodes = nodes;
|
|
519
|
+
this.allNodes = flatNodes(nodes, false);
|
|
520
|
+
this.leafNodes = flatNodes(nodes, true);
|
|
521
|
+
}
|
|
522
|
+
getNodes() {
|
|
523
|
+
return this.nodes;
|
|
524
|
+
}
|
|
525
|
+
getFlattedNodes(leafOnly) {
|
|
526
|
+
return leafOnly ? this.leafNodes : this.allNodes;
|
|
527
|
+
}
|
|
528
|
+
appendNode(nodeData, parentNode) {
|
|
529
|
+
const node = parentNode ? parentNode.appendChild(nodeData) : new Node$1(nodeData, this.config);
|
|
530
|
+
if (!parentNode)
|
|
531
|
+
this.nodes.push(node);
|
|
532
|
+
this.appendAllNodesAndLeafNodes(node);
|
|
533
|
+
}
|
|
534
|
+
appendNodes(nodeDataList, parentNode) {
|
|
535
|
+
if (nodeDataList.length > 0) {
|
|
536
|
+
nodeDataList.forEach((nodeData) => this.appendNode(nodeData, parentNode));
|
|
537
|
+
} else {
|
|
538
|
+
parentNode && parentNode.isLeaf && this.leafNodes.push(parentNode);
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
appendAllNodesAndLeafNodes(node) {
|
|
542
|
+
this.allNodes.push(node);
|
|
543
|
+
node.isLeaf && this.leafNodes.push(node);
|
|
544
|
+
if (node.children) {
|
|
545
|
+
node.children.forEach((subNode) => {
|
|
546
|
+
this.appendAllNodesAndLeafNodes(subNode);
|
|
547
|
+
});
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
getNodeByValue(value, leafOnly = false) {
|
|
551
|
+
if (isPropAbsent(value))
|
|
552
|
+
return null;
|
|
553
|
+
const node = this.getFlattedNodes(leafOnly).find((node2) => isEqual(node2.value, value) || isEqual(node2.pathValues, value));
|
|
554
|
+
return node || null;
|
|
555
|
+
}
|
|
556
|
+
getSameNode(node) {
|
|
557
|
+
if (!node)
|
|
558
|
+
return null;
|
|
559
|
+
const node_ = this.getFlattedNodes(false).find(({ value, level }) => isEqual(node.value, value) && node.level === level);
|
|
560
|
+
return node_ || null;
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
const CommonProps = buildProps({
|
|
565
|
+
modelValue: {
|
|
566
|
+
type: definePropType([Number, String, Array, Object])
|
|
567
|
+
},
|
|
568
|
+
options: {
|
|
569
|
+
type: definePropType(Array),
|
|
570
|
+
default: () => []
|
|
571
|
+
},
|
|
572
|
+
props: {
|
|
573
|
+
type: definePropType(Object),
|
|
574
|
+
default: () => ({})
|
|
575
|
+
}
|
|
576
|
+
});
|
|
577
|
+
const DefaultProps = {
|
|
578
|
+
expandTrigger: "click",
|
|
579
|
+
multiple: false,
|
|
580
|
+
checkStrictly: false,
|
|
581
|
+
emitPath: true,
|
|
582
|
+
lazy: false,
|
|
583
|
+
lazyLoad: NOOP,
|
|
584
|
+
value: "value",
|
|
585
|
+
label: "label",
|
|
586
|
+
children: "children",
|
|
587
|
+
leaf: "leaf",
|
|
588
|
+
disabled: "disabled",
|
|
589
|
+
hoverThreshold: 500,
|
|
590
|
+
checkOnClickNode: false,
|
|
591
|
+
checkOnClickLeaf: true,
|
|
592
|
+
showPrefix: true
|
|
593
|
+
};
|
|
594
|
+
const cascaderPanelProps = buildProps({
|
|
595
|
+
...CommonProps,
|
|
596
|
+
border: {
|
|
597
|
+
type: Boolean,
|
|
598
|
+
default: true
|
|
599
|
+
},
|
|
600
|
+
renderLabel: {
|
|
601
|
+
type: Function
|
|
602
|
+
}
|
|
603
|
+
});
|
|
604
|
+
const emitChangeFn$1 = (value) => true;
|
|
605
|
+
const cascaderPanelEmits = {
|
|
606
|
+
[UPDATE_MODEL_EVENT]: emitChangeFn$1,
|
|
607
|
+
[CHANGE_EVENT]: emitChangeFn$1,
|
|
608
|
+
close: () => true,
|
|
609
|
+
"expand-change": (value) => value
|
|
610
|
+
};
|
|
611
|
+
const useCascaderConfig = (props) => {
|
|
612
|
+
return computed(() => ({
|
|
613
|
+
...DefaultProps,
|
|
614
|
+
...props.props
|
|
615
|
+
}));
|
|
616
|
+
};
|
|
617
|
+
|
|
618
|
+
const getMenuIndex = (el) => {
|
|
619
|
+
if (!el)
|
|
620
|
+
return 0;
|
|
621
|
+
const pieces = el.id.split("-");
|
|
622
|
+
return Number(pieces[pieces.length - 2]);
|
|
623
|
+
};
|
|
624
|
+
const checkNode = (el) => {
|
|
625
|
+
if (!el)
|
|
626
|
+
return;
|
|
627
|
+
const input = el.querySelector("input");
|
|
628
|
+
if (input) {
|
|
629
|
+
input.click();
|
|
630
|
+
} else if (isLeaf(el)) {
|
|
631
|
+
el.click();
|
|
632
|
+
}
|
|
633
|
+
};
|
|
634
|
+
const sortByOriginalOrder = (oldNodes, newNodes) => {
|
|
635
|
+
const newNodesCopy = newNodes.slice(0);
|
|
636
|
+
const newIds = newNodesCopy.map((node) => node.uid);
|
|
637
|
+
const res = oldNodes.reduce((acc, item) => {
|
|
638
|
+
const index = newIds.indexOf(item.uid);
|
|
639
|
+
if (index > -1) {
|
|
640
|
+
acc.push(item);
|
|
641
|
+
newNodesCopy.splice(index, 1);
|
|
642
|
+
newIds.splice(index, 1);
|
|
643
|
+
}
|
|
644
|
+
return acc;
|
|
645
|
+
}, []);
|
|
646
|
+
res.push(...newNodesCopy);
|
|
647
|
+
return res;
|
|
648
|
+
};
|
|
649
|
+
|
|
650
|
+
const __default__$3 = defineComponent({
|
|
651
|
+
name: "ElCascaderPanel"
|
|
652
|
+
});
|
|
653
|
+
const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
654
|
+
...__default__$3,
|
|
655
|
+
props: cascaderPanelProps,
|
|
656
|
+
emits: cascaderPanelEmits,
|
|
657
|
+
setup(__props, { expose, emit }) {
|
|
658
|
+
const props = __props;
|
|
659
|
+
let manualChecked = false;
|
|
660
|
+
const ns = useNamespace("cascader");
|
|
661
|
+
const config = useCascaderConfig(props);
|
|
662
|
+
const slots = useSlots();
|
|
663
|
+
let store;
|
|
664
|
+
const initialLoaded = ref(true);
|
|
665
|
+
const initialLoadedOnce = ref(false);
|
|
666
|
+
const menuList = ref([]);
|
|
667
|
+
const checkedValue = ref();
|
|
668
|
+
const menus = ref([]);
|
|
669
|
+
const expandingNode = ref();
|
|
670
|
+
const checkedNodes = ref([]);
|
|
671
|
+
const isHoverMenu = computed(() => config.value.expandTrigger === "hover");
|
|
672
|
+
const renderLabelFn = computed(() => props.renderLabel || slots.default);
|
|
673
|
+
const initStore = () => {
|
|
674
|
+
const { options } = props;
|
|
675
|
+
const cfg = config.value;
|
|
676
|
+
manualChecked = false;
|
|
677
|
+
store = new Store(options, cfg);
|
|
678
|
+
menus.value = [store.getNodes()];
|
|
679
|
+
if (cfg.lazy && isEmpty(props.options)) {
|
|
680
|
+
initialLoaded.value = false;
|
|
681
|
+
lazyLoad(void 0, (list) => {
|
|
682
|
+
if (list) {
|
|
683
|
+
store = new Store(list, cfg);
|
|
684
|
+
menus.value = [store.getNodes()];
|
|
685
|
+
}
|
|
686
|
+
initialLoaded.value = true;
|
|
687
|
+
syncCheckedValue(false, true);
|
|
688
|
+
});
|
|
689
|
+
} else {
|
|
690
|
+
syncCheckedValue(false, true);
|
|
691
|
+
}
|
|
692
|
+
};
|
|
693
|
+
const lazyLoad = (node, cb) => {
|
|
694
|
+
const cfg = config.value;
|
|
695
|
+
node = node || new Node$1({}, cfg, void 0, true);
|
|
696
|
+
node.loading = true;
|
|
697
|
+
const resolve = (dataList) => {
|
|
698
|
+
const _node = node;
|
|
699
|
+
const parent = _node.root ? null : _node;
|
|
700
|
+
_node.loading = false;
|
|
701
|
+
_node.loaded = true;
|
|
702
|
+
_node.childrenData = _node.childrenData || [];
|
|
703
|
+
dataList && (store == null ? void 0 : store.appendNodes(dataList, parent));
|
|
704
|
+
dataList && (cb == null ? void 0 : cb(dataList));
|
|
705
|
+
if (node.level === 0) {
|
|
706
|
+
initialLoadedOnce.value = true;
|
|
707
|
+
}
|
|
708
|
+
};
|
|
709
|
+
const reject = () => {
|
|
710
|
+
node.loading = false;
|
|
711
|
+
node.loaded = false;
|
|
712
|
+
if (node.level === 0) {
|
|
713
|
+
initialLoaded.value = true;
|
|
714
|
+
}
|
|
715
|
+
};
|
|
716
|
+
cfg.lazyLoad(node, resolve, reject);
|
|
717
|
+
};
|
|
718
|
+
const expandNode = (node, silent) => {
|
|
719
|
+
var _a;
|
|
720
|
+
const { level } = node;
|
|
721
|
+
const newMenus = menus.value.slice(0, level);
|
|
722
|
+
let newExpandingNode;
|
|
723
|
+
if (node.isLeaf) {
|
|
724
|
+
newExpandingNode = node.pathNodes[level - 2];
|
|
725
|
+
} else {
|
|
726
|
+
newExpandingNode = node;
|
|
727
|
+
newMenus.push(node.children);
|
|
728
|
+
}
|
|
729
|
+
if (((_a = expandingNode.value) == null ? void 0 : _a.uid) !== (newExpandingNode == null ? void 0 : newExpandingNode.uid)) {
|
|
730
|
+
expandingNode.value = node;
|
|
731
|
+
menus.value = newMenus;
|
|
732
|
+
!silent && emit("expand-change", (node == null ? void 0 : node.pathValues) || []);
|
|
733
|
+
}
|
|
734
|
+
};
|
|
735
|
+
const handleCheckChange = (node, checked, emitClose = true) => {
|
|
736
|
+
const { checkStrictly, multiple } = config.value;
|
|
737
|
+
const oldNode = checkedNodes.value[0];
|
|
738
|
+
manualChecked = true;
|
|
739
|
+
!multiple && (oldNode == null ? void 0 : oldNode.doCheck(false));
|
|
740
|
+
node.doCheck(checked);
|
|
741
|
+
calculateCheckedValue();
|
|
742
|
+
emitClose && !multiple && !checkStrictly && emit("close");
|
|
743
|
+
!emitClose && !multiple && expandParentNode(node);
|
|
744
|
+
};
|
|
745
|
+
const expandParentNode = (node) => {
|
|
746
|
+
if (!node)
|
|
747
|
+
return;
|
|
748
|
+
node = node.parent;
|
|
749
|
+
expandParentNode(node);
|
|
750
|
+
node && expandNode(node);
|
|
751
|
+
};
|
|
752
|
+
const getFlattedNodes = (leafOnly) => store == null ? void 0 : store.getFlattedNodes(leafOnly);
|
|
753
|
+
const getCheckedNodes = (leafOnly) => {
|
|
754
|
+
var _a;
|
|
755
|
+
return (_a = getFlattedNodes(leafOnly)) == null ? void 0 : _a.filter(({ checked }) => checked !== false);
|
|
756
|
+
};
|
|
757
|
+
const clearCheckedNodes = () => {
|
|
758
|
+
checkedNodes.value.forEach((node) => node.doCheck(false));
|
|
759
|
+
calculateCheckedValue();
|
|
760
|
+
menus.value = menus.value.slice(0, 1);
|
|
761
|
+
expandingNode.value = void 0;
|
|
762
|
+
emit("expand-change", []);
|
|
763
|
+
};
|
|
764
|
+
const calculateCheckedValue = () => {
|
|
765
|
+
var _a;
|
|
766
|
+
const { checkStrictly, multiple } = config.value;
|
|
767
|
+
const oldNodes = checkedNodes.value;
|
|
768
|
+
const newNodes = getCheckedNodes(!checkStrictly);
|
|
769
|
+
const nodes = sortByOriginalOrder(oldNodes, newNodes);
|
|
770
|
+
const values = nodes.map((node) => node.valueByOption);
|
|
771
|
+
checkedNodes.value = nodes;
|
|
772
|
+
checkedValue.value = multiple ? values : (_a = values[0]) != null ? _a : null;
|
|
773
|
+
};
|
|
774
|
+
const syncCheckedValue = (loaded = false, forced = false) => {
|
|
775
|
+
const { modelValue } = props;
|
|
776
|
+
const { lazy, multiple, checkStrictly } = config.value;
|
|
777
|
+
const leafOnly = !checkStrictly;
|
|
778
|
+
if (!initialLoaded.value || manualChecked || !forced && isEqual(modelValue, checkedValue.value))
|
|
779
|
+
return;
|
|
780
|
+
if (lazy && !loaded) {
|
|
781
|
+
const values = unique(flattenDeep(castArray(modelValue)));
|
|
782
|
+
const nodes = values.map((val) => store == null ? void 0 : store.getNodeByValue(val)).filter((node) => !!node && !node.loaded && !node.loading);
|
|
783
|
+
if (nodes.length) {
|
|
784
|
+
nodes.forEach((node) => {
|
|
785
|
+
lazyLoad(node, () => syncCheckedValue(false, forced));
|
|
786
|
+
});
|
|
787
|
+
} else {
|
|
788
|
+
syncCheckedValue(true, forced);
|
|
789
|
+
}
|
|
790
|
+
} else {
|
|
791
|
+
const values = multiple ? castArray(modelValue) : [modelValue];
|
|
792
|
+
const nodes = unique(values.map((val) => store == null ? void 0 : store.getNodeByValue(val, leafOnly)));
|
|
793
|
+
syncMenuState(nodes, forced);
|
|
794
|
+
checkedValue.value = cloneDeep(modelValue != null ? modelValue : void 0);
|
|
795
|
+
}
|
|
796
|
+
};
|
|
797
|
+
const syncMenuState = (newCheckedNodes, reserveExpandingState = true) => {
|
|
798
|
+
const { checkStrictly } = config.value;
|
|
799
|
+
const oldNodes = checkedNodes.value;
|
|
800
|
+
const newNodes = newCheckedNodes.filter((node) => !!node && (checkStrictly || node.isLeaf));
|
|
801
|
+
const oldExpandingNode = store == null ? void 0 : store.getSameNode(expandingNode.value);
|
|
802
|
+
const newExpandingNode = reserveExpandingState && oldExpandingNode || newNodes[0];
|
|
803
|
+
if (newExpandingNode) {
|
|
804
|
+
newExpandingNode.pathNodes.forEach((node) => expandNode(node, true));
|
|
805
|
+
} else {
|
|
806
|
+
expandingNode.value = void 0;
|
|
807
|
+
}
|
|
808
|
+
oldNodes.forEach((node) => node.doCheck(false));
|
|
809
|
+
reactive(newNodes).forEach((node) => node.doCheck(true));
|
|
810
|
+
checkedNodes.value = newNodes;
|
|
811
|
+
nextTick(scrollToExpandingNode);
|
|
812
|
+
};
|
|
813
|
+
const scrollToExpandingNode = () => {
|
|
814
|
+
if (!isClient)
|
|
815
|
+
return;
|
|
816
|
+
menuList.value.forEach((menu) => {
|
|
817
|
+
const menuElement = menu == null ? void 0 : menu.$el;
|
|
818
|
+
if (menuElement) {
|
|
819
|
+
const container = menuElement.querySelector(`.${ns.namespace.value}-scrollbar__wrap`);
|
|
820
|
+
const activeNode = menuElement.querySelector(`.${ns.b("node")}.${ns.is("active")}:last-child`) || menuElement.querySelector(`.${ns.b("node")}.in-active-path`);
|
|
821
|
+
scrollIntoView(container, activeNode);
|
|
822
|
+
}
|
|
823
|
+
});
|
|
824
|
+
};
|
|
825
|
+
const handleKeyDown = (e) => {
|
|
826
|
+
const target = e.target;
|
|
827
|
+
const code = getEventCode(e);
|
|
828
|
+
switch (code) {
|
|
829
|
+
case EVENT_CODE.up:
|
|
830
|
+
case EVENT_CODE.down: {
|
|
831
|
+
e.preventDefault();
|
|
832
|
+
const distance = code === EVENT_CODE.up ? -1 : 1;
|
|
833
|
+
focusNode(getSibling(target, distance, `.${ns.b("node")}[tabindex="-1"]`));
|
|
834
|
+
break;
|
|
835
|
+
}
|
|
836
|
+
case EVENT_CODE.left: {
|
|
837
|
+
e.preventDefault();
|
|
838
|
+
const preMenu = menuList.value[getMenuIndex(target) - 1];
|
|
839
|
+
const expandedNode = preMenu == null ? void 0 : preMenu.$el.querySelector(`.${ns.b("node")}[aria-expanded="true"]`);
|
|
840
|
+
focusNode(expandedNode);
|
|
841
|
+
break;
|
|
842
|
+
}
|
|
843
|
+
case EVENT_CODE.right: {
|
|
844
|
+
e.preventDefault();
|
|
845
|
+
const nextMenu = menuList.value[getMenuIndex(target) + 1];
|
|
846
|
+
const firstNode = nextMenu == null ? void 0 : nextMenu.$el.querySelector(`.${ns.b("node")}[tabindex="-1"]`);
|
|
847
|
+
focusNode(firstNode);
|
|
848
|
+
break;
|
|
849
|
+
}
|
|
850
|
+
case EVENT_CODE.enter:
|
|
851
|
+
case EVENT_CODE.numpadEnter:
|
|
852
|
+
checkNode(target);
|
|
853
|
+
break;
|
|
854
|
+
}
|
|
855
|
+
};
|
|
856
|
+
provide(CASCADER_PANEL_INJECTION_KEY, reactive({
|
|
857
|
+
config,
|
|
858
|
+
expandingNode,
|
|
859
|
+
checkedNodes,
|
|
860
|
+
isHoverMenu,
|
|
861
|
+
initialLoaded,
|
|
862
|
+
renderLabelFn,
|
|
863
|
+
lazyLoad,
|
|
864
|
+
expandNode,
|
|
865
|
+
handleCheckChange
|
|
866
|
+
}));
|
|
867
|
+
watch(config, (newVal, oldVal) => {
|
|
868
|
+
if (isEqual(newVal, oldVal))
|
|
869
|
+
return;
|
|
870
|
+
initStore();
|
|
871
|
+
}, {
|
|
872
|
+
immediate: true
|
|
873
|
+
});
|
|
874
|
+
watch(() => props.options, initStore, {
|
|
875
|
+
deep: true
|
|
876
|
+
});
|
|
877
|
+
watch(() => props.modelValue, () => {
|
|
878
|
+
manualChecked = false;
|
|
879
|
+
syncCheckedValue();
|
|
880
|
+
}, {
|
|
881
|
+
deep: true
|
|
882
|
+
});
|
|
883
|
+
watch(() => checkedValue.value, (val) => {
|
|
884
|
+
if (!isEqual(val, props.modelValue)) {
|
|
885
|
+
emit(UPDATE_MODEL_EVENT, val);
|
|
886
|
+
emit(CHANGE_EVENT, val);
|
|
887
|
+
}
|
|
888
|
+
});
|
|
889
|
+
const loadLazyRootNodes = () => {
|
|
890
|
+
if (initialLoadedOnce.value)
|
|
891
|
+
return;
|
|
892
|
+
initStore();
|
|
893
|
+
};
|
|
894
|
+
onBeforeUpdate(() => menuList.value = []);
|
|
895
|
+
onMounted(() => !isEmpty(props.modelValue) && syncCheckedValue());
|
|
896
|
+
expose({
|
|
897
|
+
menuList,
|
|
898
|
+
menus,
|
|
899
|
+
checkedNodes,
|
|
900
|
+
handleKeyDown,
|
|
901
|
+
handleCheckChange,
|
|
902
|
+
getFlattedNodes,
|
|
903
|
+
getCheckedNodes,
|
|
904
|
+
clearCheckedNodes,
|
|
905
|
+
calculateCheckedValue,
|
|
906
|
+
scrollToExpandingNode,
|
|
907
|
+
loadLazyRootNodes
|
|
908
|
+
});
|
|
909
|
+
return (_ctx, _cache) => {
|
|
910
|
+
return openBlock(), createElementBlock("div", {
|
|
911
|
+
class: normalizeClass([unref(ns).b("panel"), unref(ns).is("bordered", _ctx.border)]),
|
|
912
|
+
onKeydown: handleKeyDown
|
|
913
|
+
}, [
|
|
914
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(menus.value, (menu, index) => {
|
|
915
|
+
return openBlock(), createBlock(ElCascaderMenu, {
|
|
916
|
+
key: index,
|
|
917
|
+
ref_for: true,
|
|
918
|
+
ref: (item) => menuList.value[index] = item,
|
|
919
|
+
index,
|
|
920
|
+
nodes: [...menu]
|
|
921
|
+
}, {
|
|
922
|
+
empty: withCtx(() => [
|
|
923
|
+
renderSlot(_ctx.$slots, "empty")
|
|
924
|
+
]),
|
|
925
|
+
_: 2
|
|
926
|
+
}, 1032, ["index", "nodes"]);
|
|
927
|
+
}), 128))
|
|
928
|
+
], 34);
|
|
929
|
+
};
|
|
930
|
+
}
|
|
931
|
+
});
|
|
932
|
+
var CascaderPanel = /* @__PURE__ */ _export_sfc(_sfc_main$7, [["__file", "index.vue"]]);
|
|
933
|
+
|
|
934
|
+
const ElCascaderPanel = withInstall(CascaderPanel);
|
|
935
|
+
|
|
936
|
+
const cascaderProps = buildProps({
|
|
937
|
+
...CommonProps,
|
|
938
|
+
size: useSizeProp,
|
|
939
|
+
placeholder: String,
|
|
940
|
+
disabled: {
|
|
941
|
+
type: Boolean,
|
|
942
|
+
default: void 0
|
|
943
|
+
},
|
|
944
|
+
clearable: Boolean,
|
|
945
|
+
clearIcon: {
|
|
946
|
+
type: iconPropType,
|
|
947
|
+
default: CircleClose
|
|
948
|
+
},
|
|
949
|
+
filterable: Boolean,
|
|
950
|
+
filterMethod: {
|
|
951
|
+
type: definePropType(Function),
|
|
952
|
+
default: (node, keyword) => node.text.includes(keyword)
|
|
953
|
+
},
|
|
954
|
+
separator: {
|
|
955
|
+
type: String,
|
|
956
|
+
default: " / "
|
|
957
|
+
},
|
|
958
|
+
showAllLevels: {
|
|
959
|
+
type: Boolean,
|
|
960
|
+
default: true
|
|
961
|
+
},
|
|
962
|
+
collapseTags: Boolean,
|
|
963
|
+
maxCollapseTags: {
|
|
964
|
+
type: Number,
|
|
965
|
+
default: 1
|
|
966
|
+
},
|
|
967
|
+
collapseTagsTooltip: Boolean,
|
|
968
|
+
maxCollapseTagsTooltipHeight: {
|
|
969
|
+
type: [String, Number]
|
|
970
|
+
},
|
|
971
|
+
debounce: {
|
|
972
|
+
type: Number,
|
|
973
|
+
default: 300
|
|
974
|
+
},
|
|
975
|
+
beforeFilter: {
|
|
976
|
+
type: definePropType(Function),
|
|
977
|
+
default: () => true
|
|
978
|
+
},
|
|
979
|
+
placement: {
|
|
980
|
+
type: definePropType(String),
|
|
981
|
+
values: Ee,
|
|
982
|
+
default: "bottom-start"
|
|
983
|
+
},
|
|
984
|
+
fallbackPlacements: {
|
|
985
|
+
type: definePropType(Array),
|
|
986
|
+
default: ["bottom-start", "bottom", "top-start", "top", "right", "left"]
|
|
987
|
+
},
|
|
988
|
+
popperClass: useTooltipContentProps.popperClass,
|
|
989
|
+
popperStyle: useTooltipContentProps.popperStyle,
|
|
990
|
+
teleported: useTooltipContentProps.teleported,
|
|
991
|
+
effect: {
|
|
992
|
+
type: definePropType(String),
|
|
993
|
+
default: "light"
|
|
994
|
+
},
|
|
995
|
+
tagType: { ...tagProps.type, default: "info" },
|
|
996
|
+
tagEffect: { ...tagProps.effect, default: "light" },
|
|
997
|
+
validateEvent: {
|
|
998
|
+
type: Boolean,
|
|
999
|
+
default: true
|
|
1000
|
+
},
|
|
1001
|
+
persistent: {
|
|
1002
|
+
type: Boolean,
|
|
1003
|
+
default: true
|
|
1004
|
+
},
|
|
1005
|
+
showCheckedStrategy: {
|
|
1006
|
+
type: String,
|
|
1007
|
+
values: ["parent", "child"],
|
|
1008
|
+
default: "child"
|
|
1009
|
+
},
|
|
1010
|
+
checkOnClickNode: Boolean,
|
|
1011
|
+
showPrefix: {
|
|
1012
|
+
type: Boolean,
|
|
1013
|
+
default: true
|
|
1014
|
+
},
|
|
1015
|
+
...useEmptyValuesProps
|
|
1016
|
+
});
|
|
1017
|
+
const emitChangeFn = (value) => true;
|
|
1018
|
+
const cascaderEmits = {
|
|
1019
|
+
[UPDATE_MODEL_EVENT]: emitChangeFn,
|
|
1020
|
+
[CHANGE_EVENT]: emitChangeFn,
|
|
1021
|
+
focus: (evt) => evt instanceof FocusEvent,
|
|
1022
|
+
blur: (evt) => evt instanceof FocusEvent,
|
|
1023
|
+
clear: () => true,
|
|
1024
|
+
visibleChange: (val) => isBoolean(val),
|
|
1025
|
+
expandChange: (val) => !!val,
|
|
1026
|
+
removeTag: (val) => !!val
|
|
1027
|
+
};
|
|
1028
|
+
|
|
1029
|
+
const __default__$2 = defineComponent({
|
|
1030
|
+
name: "ElCascader"
|
|
1031
|
+
});
|
|
1032
|
+
const _sfc_main$6 = /* @__PURE__ */ defineComponent({
|
|
1033
|
+
...__default__$2,
|
|
1034
|
+
props: cascaderProps,
|
|
1035
|
+
emits: cascaderEmits,
|
|
1036
|
+
setup(__props, { expose, emit }) {
|
|
1037
|
+
const props = __props;
|
|
1038
|
+
const popperOptions = {
|
|
1039
|
+
modifiers: [
|
|
1040
|
+
{
|
|
1041
|
+
name: "arrowPosition",
|
|
1042
|
+
enabled: true,
|
|
1043
|
+
phase: "main",
|
|
1044
|
+
fn: ({ state }) => {
|
|
1045
|
+
const { modifiersData, placement } = state;
|
|
1046
|
+
if (["right", "left", "bottom", "top"].includes(placement))
|
|
1047
|
+
return;
|
|
1048
|
+
if (modifiersData.arrow) {
|
|
1049
|
+
modifiersData.arrow.x = 35;
|
|
1050
|
+
}
|
|
1051
|
+
},
|
|
1052
|
+
requires: ["arrow"]
|
|
1053
|
+
}
|
|
1054
|
+
]
|
|
1055
|
+
};
|
|
1056
|
+
const attrs = useAttrs();
|
|
1057
|
+
let inputInitialHeight = 0;
|
|
1058
|
+
let pressDeleteCount = 0;
|
|
1059
|
+
const nsCascader = useNamespace("cascader");
|
|
1060
|
+
const nsInput = useNamespace("input");
|
|
1061
|
+
const { t } = useLocale();
|
|
1062
|
+
const { formItem } = useFormItem();
|
|
1063
|
+
const isDisabled = useFormDisabled();
|
|
1064
|
+
const { valueOnClear } = useEmptyValues(props);
|
|
1065
|
+
const { isComposing, handleComposition } = useComposition({
|
|
1066
|
+
afterComposition(event) {
|
|
1067
|
+
var _a;
|
|
1068
|
+
const text = (_a = event.target) == null ? void 0 : _a.value;
|
|
1069
|
+
handleInput(text);
|
|
1070
|
+
}
|
|
1071
|
+
});
|
|
1072
|
+
const tooltipRef = ref();
|
|
1073
|
+
const tagTooltipRef = ref();
|
|
1074
|
+
const inputRef = ref();
|
|
1075
|
+
const tagWrapper = ref();
|
|
1076
|
+
const cascaderPanelRef = ref();
|
|
1077
|
+
const suggestionPanel = ref();
|
|
1078
|
+
const popperVisible = ref(false);
|
|
1079
|
+
const inputHover = ref(false);
|
|
1080
|
+
const filtering = ref(false);
|
|
1081
|
+
const inputValue = ref("");
|
|
1082
|
+
const searchInputValue = ref("");
|
|
1083
|
+
const tags = ref([]);
|
|
1084
|
+
const suggestions = ref([]);
|
|
1085
|
+
const showTagList = computed(() => {
|
|
1086
|
+
if (!props.props.multiple) {
|
|
1087
|
+
return [];
|
|
1088
|
+
}
|
|
1089
|
+
return props.collapseTags ? tags.value.slice(0, props.maxCollapseTags) : tags.value;
|
|
1090
|
+
});
|
|
1091
|
+
const collapseTagList = computed(() => {
|
|
1092
|
+
if (!props.props.multiple) {
|
|
1093
|
+
return [];
|
|
1094
|
+
}
|
|
1095
|
+
return props.collapseTags ? tags.value.slice(props.maxCollapseTags) : [];
|
|
1096
|
+
});
|
|
1097
|
+
const cascaderStyle = computed(() => {
|
|
1098
|
+
return attrs.style;
|
|
1099
|
+
});
|
|
1100
|
+
const inputPlaceholder = computed(() => {
|
|
1101
|
+
var _a;
|
|
1102
|
+
return (_a = props.placeholder) != null ? _a : t("el.cascader.placeholder");
|
|
1103
|
+
});
|
|
1104
|
+
const currentPlaceholder = computed(() => searchInputValue.value || tags.value.length > 0 || isComposing.value ? "" : inputPlaceholder.value);
|
|
1105
|
+
const realSize = useFormSize();
|
|
1106
|
+
const tagSize = computed(() => realSize.value === "small" ? "small" : "default");
|
|
1107
|
+
const multiple = computed(() => !!props.props.multiple);
|
|
1108
|
+
const readonly = computed(() => !props.filterable || multiple.value);
|
|
1109
|
+
const searchKeyword = computed(() => multiple.value ? searchInputValue.value : inputValue.value);
|
|
1110
|
+
const checkedNodes = computed(() => {
|
|
1111
|
+
var _a;
|
|
1112
|
+
return ((_a = cascaderPanelRef.value) == null ? void 0 : _a.checkedNodes) || [];
|
|
1113
|
+
});
|
|
1114
|
+
const { wrapperRef, isFocused, handleBlur } = useFocusController(inputRef, {
|
|
1115
|
+
disabled: isDisabled,
|
|
1116
|
+
beforeBlur(event) {
|
|
1117
|
+
var _a, _b;
|
|
1118
|
+
return ((_a = tooltipRef.value) == null ? void 0 : _a.isFocusInsideContent(event)) || ((_b = tagTooltipRef.value) == null ? void 0 : _b.isFocusInsideContent(event));
|
|
1119
|
+
},
|
|
1120
|
+
afterBlur() {
|
|
1121
|
+
var _a;
|
|
1122
|
+
if (props.validateEvent) {
|
|
1123
|
+
(_a = formItem == null ? void 0 : formItem.validate) == null ? void 0 : _a.call(formItem, "blur").catch((err) => debugWarn(err));
|
|
1124
|
+
}
|
|
1125
|
+
}
|
|
1126
|
+
});
|
|
1127
|
+
const clearBtnVisible = computed(() => {
|
|
1128
|
+
if (!props.clearable || isDisabled.value || filtering.value || !inputHover.value && !isFocused.value)
|
|
1129
|
+
return false;
|
|
1130
|
+
return !!checkedNodes.value.length;
|
|
1131
|
+
});
|
|
1132
|
+
const presentText = computed(() => {
|
|
1133
|
+
const { showAllLevels, separator } = props;
|
|
1134
|
+
const nodes = checkedNodes.value;
|
|
1135
|
+
return nodes.length ? multiple.value ? "" : nodes[0].calcText(showAllLevels, separator) : "";
|
|
1136
|
+
});
|
|
1137
|
+
const validateState = computed(() => (formItem == null ? void 0 : formItem.validateState) || "");
|
|
1138
|
+
const checkedValue = computed({
|
|
1139
|
+
get() {
|
|
1140
|
+
return cloneDeep(props.modelValue);
|
|
1141
|
+
},
|
|
1142
|
+
set(val) {
|
|
1143
|
+
const value = val != null ? val : valueOnClear.value;
|
|
1144
|
+
emit(UPDATE_MODEL_EVENT, value);
|
|
1145
|
+
emit(CHANGE_EVENT, value);
|
|
1146
|
+
if (props.validateEvent) {
|
|
1147
|
+
formItem == null ? void 0 : formItem.validate("change").catch((err) => debugWarn(err));
|
|
1148
|
+
}
|
|
1149
|
+
}
|
|
1150
|
+
});
|
|
1151
|
+
const cascaderKls = computed(() => {
|
|
1152
|
+
return [
|
|
1153
|
+
nsCascader.b(),
|
|
1154
|
+
nsCascader.m(realSize.value),
|
|
1155
|
+
nsCascader.is("disabled", isDisabled.value),
|
|
1156
|
+
attrs.class
|
|
1157
|
+
];
|
|
1158
|
+
});
|
|
1159
|
+
const cascaderIconKls = computed(() => {
|
|
1160
|
+
return [
|
|
1161
|
+
nsInput.e("icon"),
|
|
1162
|
+
"icon-arrow-down",
|
|
1163
|
+
nsCascader.is("reverse", popperVisible.value)
|
|
1164
|
+
];
|
|
1165
|
+
});
|
|
1166
|
+
const inputClass = computed(() => nsCascader.is("focus", isFocused.value));
|
|
1167
|
+
const contentRef = computed(() => {
|
|
1168
|
+
var _a, _b;
|
|
1169
|
+
return (_b = (_a = tooltipRef.value) == null ? void 0 : _a.popperRef) == null ? void 0 : _b.contentRef;
|
|
1170
|
+
});
|
|
1171
|
+
const handleClickOutside = (event) => {
|
|
1172
|
+
if (isFocused.value) {
|
|
1173
|
+
const _event = new FocusEvent("blur", event);
|
|
1174
|
+
handleBlur(_event);
|
|
1175
|
+
}
|
|
1176
|
+
togglePopperVisible(false);
|
|
1177
|
+
};
|
|
1178
|
+
const togglePopperVisible = (visible) => {
|
|
1179
|
+
var _a, _b, _c;
|
|
1180
|
+
if (isDisabled.value)
|
|
1181
|
+
return;
|
|
1182
|
+
visible = visible != null ? visible : !popperVisible.value;
|
|
1183
|
+
if (visible !== popperVisible.value) {
|
|
1184
|
+
popperVisible.value = visible;
|
|
1185
|
+
(_b = (_a = inputRef.value) == null ? void 0 : _a.input) == null ? void 0 : _b.setAttribute("aria-expanded", `${visible}`);
|
|
1186
|
+
if (visible) {
|
|
1187
|
+
updatePopperPosition();
|
|
1188
|
+
nextTick((_c = cascaderPanelRef.value) == null ? void 0 : _c.scrollToExpandingNode);
|
|
1189
|
+
} else if (props.filterable) {
|
|
1190
|
+
syncPresentTextValue();
|
|
1191
|
+
}
|
|
1192
|
+
emit("visibleChange", visible);
|
|
1193
|
+
}
|
|
1194
|
+
};
|
|
1195
|
+
const updatePopperPosition = () => {
|
|
1196
|
+
nextTick(() => {
|
|
1197
|
+
var _a;
|
|
1198
|
+
(_a = tooltipRef.value) == null ? void 0 : _a.updatePopper();
|
|
1199
|
+
});
|
|
1200
|
+
};
|
|
1201
|
+
const hideSuggestionPanel = () => {
|
|
1202
|
+
filtering.value = false;
|
|
1203
|
+
};
|
|
1204
|
+
const genTag = (node) => {
|
|
1205
|
+
const { showAllLevels, separator } = props;
|
|
1206
|
+
return {
|
|
1207
|
+
node,
|
|
1208
|
+
key: node.uid,
|
|
1209
|
+
text: node.calcText(showAllLevels, separator),
|
|
1210
|
+
hitState: false,
|
|
1211
|
+
closable: !isDisabled.value && !node.isDisabled
|
|
1212
|
+
};
|
|
1213
|
+
};
|
|
1214
|
+
const deleteTag = (tag) => {
|
|
1215
|
+
var _a;
|
|
1216
|
+
const node = tag.node;
|
|
1217
|
+
node.doCheck(false);
|
|
1218
|
+
(_a = cascaderPanelRef.value) == null ? void 0 : _a.calculateCheckedValue();
|
|
1219
|
+
emit("removeTag", node.valueByOption);
|
|
1220
|
+
};
|
|
1221
|
+
const getStrategyCheckedNodes = () => {
|
|
1222
|
+
switch (props.showCheckedStrategy) {
|
|
1223
|
+
case "child":
|
|
1224
|
+
return checkedNodes.value;
|
|
1225
|
+
case "parent": {
|
|
1226
|
+
const clickedNodes = getCheckedNodes(false);
|
|
1227
|
+
const clickedNodesValue = clickedNodes.map((o) => o.value);
|
|
1228
|
+
const parentNodes = clickedNodes.filter((o) => !o.parent || !clickedNodesValue.includes(o.parent.value));
|
|
1229
|
+
return parentNodes;
|
|
1230
|
+
}
|
|
1231
|
+
default:
|
|
1232
|
+
return [];
|
|
1233
|
+
}
|
|
1234
|
+
};
|
|
1235
|
+
const calculatePresentTags = () => {
|
|
1236
|
+
if (!multiple.value)
|
|
1237
|
+
return;
|
|
1238
|
+
const nodes = getStrategyCheckedNodes();
|
|
1239
|
+
const allTags = [];
|
|
1240
|
+
nodes.forEach((node) => allTags.push(genTag(node)));
|
|
1241
|
+
tags.value = allTags;
|
|
1242
|
+
};
|
|
1243
|
+
const calculateSuggestions = () => {
|
|
1244
|
+
var _a, _b;
|
|
1245
|
+
const { filterMethod, showAllLevels, separator } = props;
|
|
1246
|
+
const res = (_b = (_a = cascaderPanelRef.value) == null ? void 0 : _a.getFlattedNodes(!props.props.checkStrictly)) == null ? void 0 : _b.filter((node) => {
|
|
1247
|
+
if (node.isDisabled)
|
|
1248
|
+
return false;
|
|
1249
|
+
node.calcText(showAllLevels, separator);
|
|
1250
|
+
return filterMethod(node, searchKeyword.value);
|
|
1251
|
+
});
|
|
1252
|
+
if (multiple.value) {
|
|
1253
|
+
tags.value.forEach((tag) => {
|
|
1254
|
+
tag.hitState = false;
|
|
1255
|
+
});
|
|
1256
|
+
}
|
|
1257
|
+
filtering.value = true;
|
|
1258
|
+
suggestions.value = res;
|
|
1259
|
+
updatePopperPosition();
|
|
1260
|
+
};
|
|
1261
|
+
const focusFirstNode = () => {
|
|
1262
|
+
var _a;
|
|
1263
|
+
let firstNode;
|
|
1264
|
+
if (filtering.value && suggestionPanel.value) {
|
|
1265
|
+
firstNode = suggestionPanel.value.$el.querySelector(`.${nsCascader.e("suggestion-item")}`);
|
|
1266
|
+
} else {
|
|
1267
|
+
firstNode = (_a = cascaderPanelRef.value) == null ? void 0 : _a.$el.querySelector(`.${nsCascader.b("node")}[tabindex="-1"]`);
|
|
1268
|
+
}
|
|
1269
|
+
if (firstNode) {
|
|
1270
|
+
firstNode.focus();
|
|
1271
|
+
!filtering.value && firstNode.click();
|
|
1272
|
+
}
|
|
1273
|
+
};
|
|
1274
|
+
const updateStyle = () => {
|
|
1275
|
+
var _a, _b;
|
|
1276
|
+
const inputInner = (_a = inputRef.value) == null ? void 0 : _a.input;
|
|
1277
|
+
const tagWrapperEl = tagWrapper.value;
|
|
1278
|
+
const suggestionPanelEl = (_b = suggestionPanel.value) == null ? void 0 : _b.$el;
|
|
1279
|
+
if (!isClient || !inputInner)
|
|
1280
|
+
return;
|
|
1281
|
+
if (suggestionPanelEl) {
|
|
1282
|
+
const suggestionList = suggestionPanelEl.querySelector(`.${nsCascader.e("suggestion-list")}`);
|
|
1283
|
+
suggestionList.style.minWidth = `${inputInner.offsetWidth}px`;
|
|
1284
|
+
}
|
|
1285
|
+
if (tagWrapperEl) {
|
|
1286
|
+
const { offsetHeight } = tagWrapperEl;
|
|
1287
|
+
const height = tags.value.length > 0 ? `${Math.max(offsetHeight, inputInitialHeight) - 2}px` : `${inputInitialHeight}px`;
|
|
1288
|
+
inputInner.style.height = height;
|
|
1289
|
+
updatePopperPosition();
|
|
1290
|
+
}
|
|
1291
|
+
};
|
|
1292
|
+
const getCheckedNodes = (leafOnly) => {
|
|
1293
|
+
var _a;
|
|
1294
|
+
return (_a = cascaderPanelRef.value) == null ? void 0 : _a.getCheckedNodes(leafOnly);
|
|
1295
|
+
};
|
|
1296
|
+
const handleExpandChange = (value) => {
|
|
1297
|
+
updatePopperPosition();
|
|
1298
|
+
emit("expandChange", value);
|
|
1299
|
+
};
|
|
1300
|
+
const handleKeyDown = (e) => {
|
|
1301
|
+
if (isComposing.value)
|
|
1302
|
+
return;
|
|
1303
|
+
const code = getEventCode(e);
|
|
1304
|
+
switch (code) {
|
|
1305
|
+
case EVENT_CODE.enter:
|
|
1306
|
+
case EVENT_CODE.numpadEnter:
|
|
1307
|
+
togglePopperVisible();
|
|
1308
|
+
break;
|
|
1309
|
+
case EVENT_CODE.down:
|
|
1310
|
+
togglePopperVisible(true);
|
|
1311
|
+
nextTick(focusFirstNode);
|
|
1312
|
+
e.preventDefault();
|
|
1313
|
+
break;
|
|
1314
|
+
case EVENT_CODE.esc:
|
|
1315
|
+
if (popperVisible.value === true) {
|
|
1316
|
+
e.preventDefault();
|
|
1317
|
+
e.stopPropagation();
|
|
1318
|
+
togglePopperVisible(false);
|
|
1319
|
+
}
|
|
1320
|
+
break;
|
|
1321
|
+
case EVENT_CODE.tab:
|
|
1322
|
+
togglePopperVisible(false);
|
|
1323
|
+
break;
|
|
1324
|
+
}
|
|
1325
|
+
};
|
|
1326
|
+
const handleClear = () => {
|
|
1327
|
+
var _a;
|
|
1328
|
+
(_a = cascaderPanelRef.value) == null ? void 0 : _a.clearCheckedNodes();
|
|
1329
|
+
if (!popperVisible.value && props.filterable) {
|
|
1330
|
+
syncPresentTextValue();
|
|
1331
|
+
}
|
|
1332
|
+
togglePopperVisible(false);
|
|
1333
|
+
emit("clear");
|
|
1334
|
+
};
|
|
1335
|
+
const syncPresentTextValue = () => {
|
|
1336
|
+
const { value } = presentText;
|
|
1337
|
+
inputValue.value = value;
|
|
1338
|
+
searchInputValue.value = value;
|
|
1339
|
+
};
|
|
1340
|
+
const handleSuggestionClick = (node) => {
|
|
1341
|
+
var _a, _b;
|
|
1342
|
+
const { checked } = node;
|
|
1343
|
+
if (multiple.value) {
|
|
1344
|
+
(_a = cascaderPanelRef.value) == null ? void 0 : _a.handleCheckChange(node, !checked, false);
|
|
1345
|
+
} else {
|
|
1346
|
+
!checked && ((_b = cascaderPanelRef.value) == null ? void 0 : _b.handleCheckChange(node, true, false));
|
|
1347
|
+
togglePopperVisible(false);
|
|
1348
|
+
}
|
|
1349
|
+
};
|
|
1350
|
+
const handleSuggestionKeyDown = (e) => {
|
|
1351
|
+
const target = e.target;
|
|
1352
|
+
const code = getEventCode(e);
|
|
1353
|
+
switch (code) {
|
|
1354
|
+
case EVENT_CODE.up:
|
|
1355
|
+
case EVENT_CODE.down: {
|
|
1356
|
+
e.preventDefault();
|
|
1357
|
+
const distance = code === EVENT_CODE.up ? -1 : 1;
|
|
1358
|
+
focusNode(getSibling(target, distance, `.${nsCascader.e("suggestion-item")}[tabindex="-1"]`));
|
|
1359
|
+
break;
|
|
1360
|
+
}
|
|
1361
|
+
case EVENT_CODE.enter:
|
|
1362
|
+
case EVENT_CODE.numpadEnter:
|
|
1363
|
+
target.click();
|
|
1364
|
+
break;
|
|
1365
|
+
}
|
|
1366
|
+
};
|
|
1367
|
+
const handleDelete = () => {
|
|
1368
|
+
const lastTag = tags.value[tags.value.length - 1];
|
|
1369
|
+
pressDeleteCount = searchInputValue.value ? 0 : pressDeleteCount + 1;
|
|
1370
|
+
if (!lastTag || !pressDeleteCount || props.collapseTags && tags.value.length > 1)
|
|
1371
|
+
return;
|
|
1372
|
+
if (lastTag.hitState) {
|
|
1373
|
+
deleteTag(lastTag);
|
|
1374
|
+
} else {
|
|
1375
|
+
lastTag.hitState = true;
|
|
1376
|
+
}
|
|
1377
|
+
};
|
|
1378
|
+
const debounce = computed(() => props.debounce);
|
|
1379
|
+
const handleFilter = useDebounceFn(() => {
|
|
1380
|
+
const { value } = searchKeyword;
|
|
1381
|
+
if (!value)
|
|
1382
|
+
return;
|
|
1383
|
+
const passed = props.beforeFilter(value);
|
|
1384
|
+
if (isPromise(passed)) {
|
|
1385
|
+
passed.then(calculateSuggestions).catch(() => {
|
|
1386
|
+
});
|
|
1387
|
+
} else if (passed !== false) {
|
|
1388
|
+
calculateSuggestions();
|
|
1389
|
+
} else {
|
|
1390
|
+
hideSuggestionPanel();
|
|
1391
|
+
}
|
|
1392
|
+
}, debounce);
|
|
1393
|
+
const handleInput = (val, e) => {
|
|
1394
|
+
!popperVisible.value && togglePopperVisible(true);
|
|
1395
|
+
if (e == null ? void 0 : e.isComposing)
|
|
1396
|
+
return;
|
|
1397
|
+
val ? handleFilter() : hideSuggestionPanel();
|
|
1398
|
+
};
|
|
1399
|
+
const getInputInnerHeight = (inputInner) => Number.parseFloat(useCssVar(nsInput.cssVarName("input-height"), inputInner).value) - 2;
|
|
1400
|
+
const focus = () => {
|
|
1401
|
+
var _a;
|
|
1402
|
+
(_a = inputRef.value) == null ? void 0 : _a.focus();
|
|
1403
|
+
};
|
|
1404
|
+
const blur = () => {
|
|
1405
|
+
var _a;
|
|
1406
|
+
(_a = inputRef.value) == null ? void 0 : _a.blur();
|
|
1407
|
+
};
|
|
1408
|
+
watch(filtering, updatePopperPosition);
|
|
1409
|
+
watch([
|
|
1410
|
+
checkedNodes,
|
|
1411
|
+
isDisabled,
|
|
1412
|
+
() => props.collapseTags,
|
|
1413
|
+
() => props.maxCollapseTags
|
|
1414
|
+
], calculatePresentTags);
|
|
1415
|
+
watch(tags, () => {
|
|
1416
|
+
nextTick(() => updateStyle());
|
|
1417
|
+
});
|
|
1418
|
+
watch(realSize, async () => {
|
|
1419
|
+
await nextTick();
|
|
1420
|
+
const inputInner = inputRef.value.input;
|
|
1421
|
+
inputInitialHeight = getInputInnerHeight(inputInner) || inputInitialHeight;
|
|
1422
|
+
updateStyle();
|
|
1423
|
+
});
|
|
1424
|
+
watch(presentText, syncPresentTextValue, { immediate: true });
|
|
1425
|
+
watch(() => popperVisible.value, (val) => {
|
|
1426
|
+
var _a;
|
|
1427
|
+
if (val && props.props.lazy && props.props.lazyLoad) {
|
|
1428
|
+
(_a = cascaderPanelRef.value) == null ? void 0 : _a.loadLazyRootNodes();
|
|
1429
|
+
}
|
|
1430
|
+
});
|
|
1431
|
+
onMounted(() => {
|
|
1432
|
+
const inputInner = inputRef.value.input;
|
|
1433
|
+
const inputInnerHeight = getInputInnerHeight(inputInner);
|
|
1434
|
+
inputInitialHeight = inputInner.offsetHeight || inputInnerHeight;
|
|
1435
|
+
useResizeObserver(inputInner, updateStyle);
|
|
1436
|
+
});
|
|
1437
|
+
expose({
|
|
1438
|
+
getCheckedNodes,
|
|
1439
|
+
cascaderPanelRef,
|
|
1440
|
+
togglePopperVisible,
|
|
1441
|
+
contentRef,
|
|
1442
|
+
presentText,
|
|
1443
|
+
focus,
|
|
1444
|
+
blur
|
|
1445
|
+
});
|
|
1446
|
+
return (_ctx, _cache) => {
|
|
1447
|
+
return openBlock(), createBlock(unref(ElTooltip), {
|
|
1448
|
+
ref_key: "tooltipRef",
|
|
1449
|
+
ref: tooltipRef,
|
|
1450
|
+
visible: popperVisible.value,
|
|
1451
|
+
teleported: _ctx.teleported,
|
|
1452
|
+
"popper-class": [unref(nsCascader).e("dropdown"), _ctx.popperClass],
|
|
1453
|
+
"popper-style": _ctx.popperStyle,
|
|
1454
|
+
"popper-options": popperOptions,
|
|
1455
|
+
"fallback-placements": _ctx.fallbackPlacements,
|
|
1456
|
+
"stop-popper-mouse-event": false,
|
|
1457
|
+
"gpu-acceleration": false,
|
|
1458
|
+
placement: _ctx.placement,
|
|
1459
|
+
transition: `${unref(nsCascader).namespace.value}-zoom-in-top`,
|
|
1460
|
+
effect: _ctx.effect,
|
|
1461
|
+
pure: "",
|
|
1462
|
+
persistent: _ctx.persistent,
|
|
1463
|
+
onHide: hideSuggestionPanel
|
|
1464
|
+
}, {
|
|
1465
|
+
default: withCtx(() => [
|
|
1466
|
+
withDirectives((openBlock(), createElementBlock("div", {
|
|
1467
|
+
ref_key: "wrapperRef",
|
|
1468
|
+
ref: wrapperRef,
|
|
1469
|
+
class: normalizeClass(unref(cascaderKls)),
|
|
1470
|
+
style: normalizeStyle(unref(cascaderStyle)),
|
|
1471
|
+
onClick: () => togglePopperVisible(unref(readonly) ? void 0 : true),
|
|
1472
|
+
onKeydown: handleKeyDown,
|
|
1473
|
+
onMouseenter: ($event) => inputHover.value = true,
|
|
1474
|
+
onMouseleave: ($event) => inputHover.value = false
|
|
1475
|
+
}, [
|
|
1476
|
+
createVNode(unref(ElInput), {
|
|
1477
|
+
ref_key: "inputRef",
|
|
1478
|
+
ref: inputRef,
|
|
1479
|
+
modelValue: inputValue.value,
|
|
1480
|
+
"onUpdate:modelValue": ($event) => inputValue.value = $event,
|
|
1481
|
+
placeholder: unref(currentPlaceholder),
|
|
1482
|
+
readonly: unref(readonly),
|
|
1483
|
+
disabled: unref(isDisabled),
|
|
1484
|
+
"validate-event": false,
|
|
1485
|
+
size: unref(realSize),
|
|
1486
|
+
class: normalizeClass(unref(inputClass)),
|
|
1487
|
+
tabindex: unref(multiple) && _ctx.filterable && !unref(isDisabled) ? -1 : void 0,
|
|
1488
|
+
onCompositionstart: unref(handleComposition),
|
|
1489
|
+
onCompositionupdate: unref(handleComposition),
|
|
1490
|
+
onCompositionend: unref(handleComposition),
|
|
1491
|
+
onInput: handleInput
|
|
1492
|
+
}, createSlots({
|
|
1493
|
+
suffix: withCtx(() => [
|
|
1494
|
+
unref(clearBtnVisible) ? (openBlock(), createBlock(unref(ElIcon), {
|
|
1495
|
+
key: "clear",
|
|
1496
|
+
class: normalizeClass([unref(nsInput).e("icon"), "icon-circle-close"]),
|
|
1497
|
+
onClick: withModifiers(handleClear, ["stop"])
|
|
1498
|
+
}, {
|
|
1499
|
+
default: withCtx(() => [
|
|
1500
|
+
(openBlock(), createBlock(resolveDynamicComponent(_ctx.clearIcon)))
|
|
1501
|
+
]),
|
|
1502
|
+
_: 1
|
|
1503
|
+
}, 8, ["class", "onClick"])) : (openBlock(), createBlock(unref(ElIcon), {
|
|
1504
|
+
key: "arrow-down",
|
|
1505
|
+
class: normalizeClass(unref(cascaderIconKls)),
|
|
1506
|
+
onClick: withModifiers(($event) => togglePopperVisible(), ["stop"])
|
|
1507
|
+
}, {
|
|
1508
|
+
default: withCtx(() => [
|
|
1509
|
+
createVNode(unref(ArrowDown))
|
|
1510
|
+
]),
|
|
1511
|
+
_: 1
|
|
1512
|
+
}, 8, ["class", "onClick"]))
|
|
1513
|
+
]),
|
|
1514
|
+
_: 2
|
|
1515
|
+
}, [
|
|
1516
|
+
_ctx.$slots.prefix ? {
|
|
1517
|
+
name: "prefix",
|
|
1518
|
+
fn: withCtx(() => [
|
|
1519
|
+
renderSlot(_ctx.$slots, "prefix")
|
|
1520
|
+
])
|
|
1521
|
+
} : void 0
|
|
1522
|
+
]), 1032, ["modelValue", "onUpdate:modelValue", "placeholder", "readonly", "disabled", "size", "class", "tabindex", "onCompositionstart", "onCompositionupdate", "onCompositionend"]),
|
|
1523
|
+
unref(multiple) ? (openBlock(), createElementBlock("div", {
|
|
1524
|
+
key: 0,
|
|
1525
|
+
ref_key: "tagWrapper",
|
|
1526
|
+
ref: tagWrapper,
|
|
1527
|
+
class: normalizeClass([
|
|
1528
|
+
unref(nsCascader).e("tags"),
|
|
1529
|
+
unref(nsCascader).is("validate", Boolean(unref(validateState)))
|
|
1530
|
+
])
|
|
1531
|
+
}, [
|
|
1532
|
+
renderSlot(_ctx.$slots, "tag", {
|
|
1533
|
+
data: tags.value,
|
|
1534
|
+
deleteTag
|
|
1535
|
+
}, () => [
|
|
1536
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(showTagList), (tag) => {
|
|
1537
|
+
return openBlock(), createBlock(unref(ElTag), {
|
|
1538
|
+
key: tag.key,
|
|
1539
|
+
type: _ctx.tagType,
|
|
1540
|
+
size: unref(tagSize),
|
|
1541
|
+
effect: _ctx.tagEffect,
|
|
1542
|
+
hit: tag.hitState,
|
|
1543
|
+
closable: tag.closable,
|
|
1544
|
+
"disable-transitions": "",
|
|
1545
|
+
onClose: ($event) => deleteTag(tag)
|
|
1546
|
+
}, {
|
|
1547
|
+
default: withCtx(() => [
|
|
1548
|
+
createElementVNode("span", null, toDisplayString(tag.text), 1)
|
|
1549
|
+
]),
|
|
1550
|
+
_: 2
|
|
1551
|
+
}, 1032, ["type", "size", "effect", "hit", "closable", "onClose"]);
|
|
1552
|
+
}), 128))
|
|
1553
|
+
]),
|
|
1554
|
+
_ctx.collapseTags && tags.value.length > _ctx.maxCollapseTags ? (openBlock(), createBlock(unref(ElTooltip), {
|
|
1555
|
+
key: 0,
|
|
1556
|
+
ref_key: "tagTooltipRef",
|
|
1557
|
+
ref: tagTooltipRef,
|
|
1558
|
+
disabled: popperVisible.value || !_ctx.collapseTagsTooltip,
|
|
1559
|
+
"fallback-placements": ["bottom", "top", "right", "left"],
|
|
1560
|
+
placement: "bottom",
|
|
1561
|
+
"popper-class": _ctx.popperClass,
|
|
1562
|
+
"popper-style": _ctx.popperStyle,
|
|
1563
|
+
effect: _ctx.effect,
|
|
1564
|
+
persistent: _ctx.persistent
|
|
1565
|
+
}, {
|
|
1566
|
+
default: withCtx(() => [
|
|
1567
|
+
createVNode(unref(ElTag), {
|
|
1568
|
+
closable: false,
|
|
1569
|
+
size: unref(tagSize),
|
|
1570
|
+
type: _ctx.tagType,
|
|
1571
|
+
effect: _ctx.tagEffect,
|
|
1572
|
+
"disable-transitions": ""
|
|
1573
|
+
}, {
|
|
1574
|
+
default: withCtx(() => [
|
|
1575
|
+
createElementVNode("span", {
|
|
1576
|
+
class: normalizeClass(unref(nsCascader).e("tags-text"))
|
|
1577
|
+
}, " + " + toDisplayString(tags.value.length - _ctx.maxCollapseTags), 3)
|
|
1578
|
+
]),
|
|
1579
|
+
_: 1
|
|
1580
|
+
}, 8, ["size", "type", "effect"])
|
|
1581
|
+
]),
|
|
1582
|
+
content: withCtx(() => [
|
|
1583
|
+
createVNode(unref(ElScrollbar), { "max-height": _ctx.maxCollapseTagsTooltipHeight }, {
|
|
1584
|
+
default: withCtx(() => [
|
|
1585
|
+
createElementVNode("div", {
|
|
1586
|
+
class: normalizeClass(unref(nsCascader).e("collapse-tags"))
|
|
1587
|
+
}, [
|
|
1588
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(collapseTagList), (tag, idx) => {
|
|
1589
|
+
return openBlock(), createElementBlock("div", {
|
|
1590
|
+
key: idx,
|
|
1591
|
+
class: normalizeClass(unref(nsCascader).e("collapse-tag"))
|
|
1592
|
+
}, [
|
|
1593
|
+
(openBlock(), createBlock(unref(ElTag), {
|
|
1594
|
+
key: tag.key,
|
|
1595
|
+
class: "in-tooltip",
|
|
1596
|
+
type: _ctx.tagType,
|
|
1597
|
+
size: unref(tagSize),
|
|
1598
|
+
effect: _ctx.tagEffect,
|
|
1599
|
+
hit: tag.hitState,
|
|
1600
|
+
closable: tag.closable,
|
|
1601
|
+
"disable-transitions": "",
|
|
1602
|
+
onClose: ($event) => deleteTag(tag)
|
|
1603
|
+
}, {
|
|
1604
|
+
default: withCtx(() => [
|
|
1605
|
+
createElementVNode("span", null, toDisplayString(tag.text), 1)
|
|
1606
|
+
]),
|
|
1607
|
+
_: 2
|
|
1608
|
+
}, 1032, ["type", "size", "effect", "hit", "closable", "onClose"]))
|
|
1609
|
+
], 2);
|
|
1610
|
+
}), 128))
|
|
1611
|
+
], 2)
|
|
1612
|
+
]),
|
|
1613
|
+
_: 1
|
|
1614
|
+
}, 8, ["max-height"])
|
|
1615
|
+
]),
|
|
1616
|
+
_: 1
|
|
1617
|
+
}, 8, ["disabled", "popper-class", "popper-style", "effect", "persistent"])) : createCommentVNode("v-if", true),
|
|
1618
|
+
_ctx.filterable && !unref(isDisabled) ? withDirectives((openBlock(), createElementBlock("input", {
|
|
1619
|
+
key: 1,
|
|
1620
|
+
"onUpdate:modelValue": ($event) => searchInputValue.value = $event,
|
|
1621
|
+
type: "text",
|
|
1622
|
+
class: normalizeClass(unref(nsCascader).e("search-input")),
|
|
1623
|
+
placeholder: unref(presentText) ? "" : unref(inputPlaceholder),
|
|
1624
|
+
onInput: (e) => handleInput(searchInputValue.value, e),
|
|
1625
|
+
onClick: withModifiers(($event) => togglePopperVisible(true), ["stop"]),
|
|
1626
|
+
onKeydown: withKeys(handleDelete, ["delete"]),
|
|
1627
|
+
onCompositionstart: unref(handleComposition),
|
|
1628
|
+
onCompositionupdate: unref(handleComposition),
|
|
1629
|
+
onCompositionend: unref(handleComposition)
|
|
1630
|
+
}, null, 42, ["onUpdate:modelValue", "placeholder", "onInput", "onClick", "onKeydown", "onCompositionstart", "onCompositionupdate", "onCompositionend"])), [
|
|
1631
|
+
[vModelText, searchInputValue.value]
|
|
1632
|
+
]) : createCommentVNode("v-if", true)
|
|
1633
|
+
], 2)) : createCommentVNode("v-if", true)
|
|
1634
|
+
], 46, ["onClick", "onMouseenter", "onMouseleave"])), [
|
|
1635
|
+
[unref(ClickOutside), handleClickOutside, unref(contentRef)]
|
|
1636
|
+
])
|
|
1637
|
+
]),
|
|
1638
|
+
content: withCtx(() => [
|
|
1639
|
+
_ctx.$slots.header ? (openBlock(), createElementBlock("div", {
|
|
1640
|
+
key: 0,
|
|
1641
|
+
class: normalizeClass(unref(nsCascader).e("header")),
|
|
1642
|
+
onClick: withModifiers(() => {
|
|
1643
|
+
}, ["stop"])
|
|
1644
|
+
}, [
|
|
1645
|
+
renderSlot(_ctx.$slots, "header")
|
|
1646
|
+
], 10, ["onClick"])) : createCommentVNode("v-if", true),
|
|
1647
|
+
withDirectives(createVNode(unref(ElCascaderPanel), {
|
|
1648
|
+
ref_key: "cascaderPanelRef",
|
|
1649
|
+
ref: cascaderPanelRef,
|
|
1650
|
+
modelValue: unref(checkedValue),
|
|
1651
|
+
"onUpdate:modelValue": ($event) => isRef(checkedValue) ? checkedValue.value = $event : null,
|
|
1652
|
+
options: _ctx.options,
|
|
1653
|
+
props: props.props,
|
|
1654
|
+
border: false,
|
|
1655
|
+
"render-label": _ctx.$slots.default,
|
|
1656
|
+
onExpandChange: handleExpandChange,
|
|
1657
|
+
onClose: ($event) => _ctx.$nextTick(() => togglePopperVisible(false))
|
|
1658
|
+
}, {
|
|
1659
|
+
empty: withCtx(() => [
|
|
1660
|
+
renderSlot(_ctx.$slots, "empty")
|
|
1661
|
+
]),
|
|
1662
|
+
_: 3
|
|
1663
|
+
}, 8, ["modelValue", "onUpdate:modelValue", "options", "props", "render-label", "onClose"]), [
|
|
1664
|
+
[vShow, !filtering.value]
|
|
1665
|
+
]),
|
|
1666
|
+
_ctx.filterable ? withDirectives((openBlock(), createBlock(unref(ElScrollbar), {
|
|
1667
|
+
key: 1,
|
|
1668
|
+
ref_key: "suggestionPanel",
|
|
1669
|
+
ref: suggestionPanel,
|
|
1670
|
+
tag: "ul",
|
|
1671
|
+
class: normalizeClass(unref(nsCascader).e("suggestion-panel")),
|
|
1672
|
+
"view-class": unref(nsCascader).e("suggestion-list"),
|
|
1673
|
+
onKeydown: handleSuggestionKeyDown
|
|
1674
|
+
}, {
|
|
1675
|
+
default: withCtx(() => [
|
|
1676
|
+
suggestions.value.length ? (openBlock(true), createElementBlock(Fragment, { key: 0 }, renderList(suggestions.value, (item) => {
|
|
1677
|
+
return openBlock(), createElementBlock("li", {
|
|
1678
|
+
key: item.uid,
|
|
1679
|
+
class: normalizeClass([
|
|
1680
|
+
unref(nsCascader).e("suggestion-item"),
|
|
1681
|
+
unref(nsCascader).is("checked", item.checked)
|
|
1682
|
+
]),
|
|
1683
|
+
tabindex: -1,
|
|
1684
|
+
onClick: ($event) => handleSuggestionClick(item)
|
|
1685
|
+
}, [
|
|
1686
|
+
renderSlot(_ctx.$slots, "suggestion-item", { item }, () => [
|
|
1687
|
+
createElementVNode("span", null, toDisplayString(item.text), 1),
|
|
1688
|
+
item.checked ? (openBlock(), createBlock(unref(ElIcon), { key: 0 }, {
|
|
1689
|
+
default: withCtx(() => [
|
|
1690
|
+
createVNode(unref(Check))
|
|
1691
|
+
]),
|
|
1692
|
+
_: 1
|
|
1693
|
+
})) : createCommentVNode("v-if", true)
|
|
1694
|
+
])
|
|
1695
|
+
], 10, ["onClick"]);
|
|
1696
|
+
}), 128)) : renderSlot(_ctx.$slots, "empty", { key: 1 }, () => [
|
|
1697
|
+
createElementVNode("li", {
|
|
1698
|
+
class: normalizeClass(unref(nsCascader).e("empty-text"))
|
|
1699
|
+
}, toDisplayString(unref(t)("el.cascader.noMatch")), 3)
|
|
1700
|
+
])
|
|
1701
|
+
]),
|
|
1702
|
+
_: 3
|
|
1703
|
+
}, 8, ["class", "view-class"])), [
|
|
1704
|
+
[vShow, filtering.value]
|
|
1705
|
+
]) : createCommentVNode("v-if", true),
|
|
1706
|
+
_ctx.$slots.footer ? (openBlock(), createElementBlock("div", {
|
|
1707
|
+
key: 2,
|
|
1708
|
+
class: normalizeClass(unref(nsCascader).e("footer")),
|
|
1709
|
+
onClick: withModifiers(() => {
|
|
1710
|
+
}, ["stop"])
|
|
1711
|
+
}, [
|
|
1712
|
+
renderSlot(_ctx.$slots, "footer")
|
|
1713
|
+
], 10, ["onClick"])) : createCommentVNode("v-if", true)
|
|
1714
|
+
]),
|
|
1715
|
+
_: 3
|
|
1716
|
+
}, 8, ["visible", "teleported", "popper-class", "popper-style", "fallback-placements", "placement", "transition", "effect", "persistent"]);
|
|
1717
|
+
};
|
|
1718
|
+
}
|
|
1719
|
+
});
|
|
1720
|
+
var Cascader = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["__file", "cascader.vue"]]);
|
|
1721
|
+
|
|
1722
|
+
const ElCascader = withInstall(Cascader);
|
|
1723
|
+
|
|
1724
|
+
const __default__$1 = defineComponent({
|
|
1725
|
+
name: "ElCollapseTransition"
|
|
1726
|
+
});
|
|
1727
|
+
const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
1728
|
+
...__default__$1,
|
|
1729
|
+
setup(__props) {
|
|
1730
|
+
const ns = useNamespace("collapse-transition");
|
|
1731
|
+
const reset = (el) => {
|
|
1732
|
+
el.style.maxHeight = "";
|
|
1733
|
+
el.style.overflow = el.dataset.oldOverflow;
|
|
1734
|
+
el.style.paddingTop = el.dataset.oldPaddingTop;
|
|
1735
|
+
el.style.paddingBottom = el.dataset.oldPaddingBottom;
|
|
1736
|
+
};
|
|
1737
|
+
const on = {
|
|
1738
|
+
beforeEnter(el) {
|
|
1739
|
+
if (!el.dataset)
|
|
1740
|
+
el.dataset = {};
|
|
1741
|
+
el.dataset.oldPaddingTop = el.style.paddingTop;
|
|
1742
|
+
el.dataset.oldPaddingBottom = el.style.paddingBottom;
|
|
1743
|
+
if (el.style.height)
|
|
1744
|
+
el.dataset.elExistsHeight = el.style.height;
|
|
1745
|
+
el.style.maxHeight = 0;
|
|
1746
|
+
el.style.paddingTop = 0;
|
|
1747
|
+
el.style.paddingBottom = 0;
|
|
1748
|
+
},
|
|
1749
|
+
enter(el) {
|
|
1750
|
+
requestAnimationFrame(() => {
|
|
1751
|
+
el.dataset.oldOverflow = el.style.overflow;
|
|
1752
|
+
if (el.dataset.elExistsHeight) {
|
|
1753
|
+
el.style.maxHeight = el.dataset.elExistsHeight;
|
|
1754
|
+
} else if (el.scrollHeight !== 0) {
|
|
1755
|
+
el.style.maxHeight = `${el.scrollHeight}px`;
|
|
1756
|
+
} else {
|
|
1757
|
+
el.style.maxHeight = 0;
|
|
1758
|
+
}
|
|
1759
|
+
el.style.paddingTop = el.dataset.oldPaddingTop;
|
|
1760
|
+
el.style.paddingBottom = el.dataset.oldPaddingBottom;
|
|
1761
|
+
el.style.overflow = "hidden";
|
|
1762
|
+
});
|
|
1763
|
+
},
|
|
1764
|
+
afterEnter(el) {
|
|
1765
|
+
el.style.maxHeight = "";
|
|
1766
|
+
el.style.overflow = el.dataset.oldOverflow;
|
|
1767
|
+
},
|
|
1768
|
+
enterCancelled(el) {
|
|
1769
|
+
reset(el);
|
|
1770
|
+
},
|
|
1771
|
+
beforeLeave(el) {
|
|
1772
|
+
if (!el.dataset)
|
|
1773
|
+
el.dataset = {};
|
|
1774
|
+
el.dataset.oldPaddingTop = el.style.paddingTop;
|
|
1775
|
+
el.dataset.oldPaddingBottom = el.style.paddingBottom;
|
|
1776
|
+
el.dataset.oldOverflow = el.style.overflow;
|
|
1777
|
+
el.style.maxHeight = `${el.scrollHeight}px`;
|
|
1778
|
+
el.style.overflow = "hidden";
|
|
1779
|
+
},
|
|
1780
|
+
leave(el) {
|
|
1781
|
+
if (el.scrollHeight !== 0) {
|
|
1782
|
+
el.style.maxHeight = 0;
|
|
1783
|
+
el.style.paddingTop = 0;
|
|
1784
|
+
el.style.paddingBottom = 0;
|
|
1785
|
+
}
|
|
1786
|
+
},
|
|
1787
|
+
afterLeave(el) {
|
|
1788
|
+
reset(el);
|
|
1789
|
+
},
|
|
1790
|
+
leaveCancelled(el) {
|
|
1791
|
+
reset(el);
|
|
1792
|
+
}
|
|
1793
|
+
};
|
|
1794
|
+
return (_ctx, _cache) => {
|
|
1795
|
+
return openBlock(), createBlock(Transition, mergeProps({
|
|
1796
|
+
name: unref(ns).b()
|
|
1797
|
+
}, toHandlers(on)), {
|
|
1798
|
+
default: withCtx(() => [
|
|
1799
|
+
renderSlot(_ctx.$slots, "default")
|
|
1800
|
+
]),
|
|
1801
|
+
_: 3
|
|
1802
|
+
}, 16, ["name"]);
|
|
1803
|
+
};
|
|
1804
|
+
}
|
|
1805
|
+
});
|
|
1806
|
+
var CollapseTransition = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["__file", "collapse-transition.vue"]]);
|
|
1807
|
+
|
|
1808
|
+
const ElCollapseTransition = withInstall(CollapseTransition);
|
|
1809
|
+
|
|
1810
|
+
const textProps = buildProps({
|
|
1811
|
+
type: {
|
|
1812
|
+
type: String,
|
|
1813
|
+
values: ["primary", "success", "info", "warning", "danger", ""],
|
|
1814
|
+
default: ""
|
|
1815
|
+
},
|
|
1816
|
+
size: {
|
|
1817
|
+
type: String,
|
|
1818
|
+
values: componentSizes,
|
|
1819
|
+
default: ""
|
|
1820
|
+
},
|
|
1821
|
+
truncated: Boolean,
|
|
1822
|
+
lineClamp: {
|
|
1823
|
+
type: [String, Number]
|
|
1824
|
+
},
|
|
1825
|
+
tag: {
|
|
1826
|
+
type: String,
|
|
1827
|
+
default: "span"
|
|
1828
|
+
}
|
|
1829
|
+
});
|
|
1830
|
+
|
|
1831
|
+
const __default__ = defineComponent({
|
|
1832
|
+
name: "ElText"
|
|
1833
|
+
});
|
|
1834
|
+
const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
|
1835
|
+
...__default__,
|
|
1836
|
+
props: textProps,
|
|
1837
|
+
setup(__props) {
|
|
1838
|
+
const props = __props;
|
|
1839
|
+
const textRef = ref();
|
|
1840
|
+
const textSize = useFormSize();
|
|
1841
|
+
const ns = useNamespace("text");
|
|
1842
|
+
const textKls = computed(() => [
|
|
1843
|
+
ns.b(),
|
|
1844
|
+
ns.m(props.type),
|
|
1845
|
+
ns.m(textSize.value),
|
|
1846
|
+
ns.is("truncated", props.truncated),
|
|
1847
|
+
ns.is("line-clamp", !isUndefined(props.lineClamp))
|
|
1848
|
+
]);
|
|
1849
|
+
const bindTitle = () => {
|
|
1850
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
1851
|
+
const inheritTitle = useAttrs().title;
|
|
1852
|
+
if (inheritTitle)
|
|
1853
|
+
return;
|
|
1854
|
+
let shouldAddTitle = false;
|
|
1855
|
+
const text = ((_a = textRef.value) == null ? void 0 : _a.textContent) || "";
|
|
1856
|
+
if (props.truncated) {
|
|
1857
|
+
const width = (_b = textRef.value) == null ? void 0 : _b.offsetWidth;
|
|
1858
|
+
const scrollWidth = (_c = textRef.value) == null ? void 0 : _c.scrollWidth;
|
|
1859
|
+
if (width && scrollWidth && scrollWidth > width) {
|
|
1860
|
+
shouldAddTitle = true;
|
|
1861
|
+
}
|
|
1862
|
+
} else if (!isUndefined(props.lineClamp)) {
|
|
1863
|
+
const height = (_d = textRef.value) == null ? void 0 : _d.offsetHeight;
|
|
1864
|
+
const scrollHeight = (_e = textRef.value) == null ? void 0 : _e.scrollHeight;
|
|
1865
|
+
if (height && scrollHeight && scrollHeight > height) {
|
|
1866
|
+
shouldAddTitle = true;
|
|
1867
|
+
}
|
|
1868
|
+
}
|
|
1869
|
+
if (shouldAddTitle) {
|
|
1870
|
+
(_f = textRef.value) == null ? void 0 : _f.setAttribute("title", text);
|
|
1871
|
+
} else {
|
|
1872
|
+
(_g = textRef.value) == null ? void 0 : _g.removeAttribute("title");
|
|
1873
|
+
}
|
|
1874
|
+
};
|
|
1875
|
+
onMounted(bindTitle);
|
|
1876
|
+
onUpdated(bindTitle);
|
|
1877
|
+
return (_ctx, _cache) => {
|
|
1878
|
+
return openBlock(), createBlock(resolveDynamicComponent(_ctx.tag), {
|
|
1879
|
+
ref_key: "textRef",
|
|
1880
|
+
ref: textRef,
|
|
1881
|
+
class: normalizeClass(unref(textKls)),
|
|
1882
|
+
style: normalizeStyle({ "-webkit-line-clamp": _ctx.lineClamp })
|
|
1883
|
+
}, {
|
|
1884
|
+
default: withCtx(() => [
|
|
1885
|
+
renderSlot(_ctx.$slots, "default")
|
|
1886
|
+
]),
|
|
1887
|
+
_: 3
|
|
1888
|
+
}, 8, ["class", "style"]);
|
|
1889
|
+
};
|
|
1890
|
+
}
|
|
1891
|
+
});
|
|
1892
|
+
var Text = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__file", "text.vue"]]);
|
|
1893
|
+
|
|
1894
|
+
const ElText = withInstall(Text);
|
|
1895
|
+
|
|
1896
|
+
const NODE_KEY = "$treeNodeId";
|
|
1897
|
+
const markNodeData = function(node, data) {
|
|
1898
|
+
if (!data || data[NODE_KEY])
|
|
1899
|
+
return;
|
|
1900
|
+
Object.defineProperty(data, NODE_KEY, {
|
|
1901
|
+
value: node.id,
|
|
1902
|
+
enumerable: false,
|
|
1903
|
+
configurable: false,
|
|
1904
|
+
writable: false
|
|
1905
|
+
});
|
|
1906
|
+
};
|
|
1907
|
+
const getNodeKey = (key, data) => data == null ? void 0 : data[key || NODE_KEY];
|
|
1908
|
+
const handleCurrentChange = (store, emit, setCurrent) => {
|
|
1909
|
+
const preCurrentNode = store.value.currentNode;
|
|
1910
|
+
setCurrent();
|
|
1911
|
+
const currentNode = store.value.currentNode;
|
|
1912
|
+
if (preCurrentNode === currentNode)
|
|
1913
|
+
return;
|
|
1914
|
+
emit("current-change", currentNode ? currentNode.data : null, currentNode);
|
|
1915
|
+
};
|
|
1916
|
+
|
|
1917
|
+
const getChildState = (node) => {
|
|
1918
|
+
let all = true;
|
|
1919
|
+
let none = true;
|
|
1920
|
+
let allWithoutDisable = true;
|
|
1921
|
+
let isEffectivelyChecked = true;
|
|
1922
|
+
for (let i = 0, j = node.length; i < j; i++) {
|
|
1923
|
+
const n = node[i];
|
|
1924
|
+
if (n.checked !== true || n.indeterminate) {
|
|
1925
|
+
all = false;
|
|
1926
|
+
if (!n.disabled) {
|
|
1927
|
+
allWithoutDisable = false;
|
|
1928
|
+
}
|
|
1929
|
+
}
|
|
1930
|
+
if (n.checked !== false || n.indeterminate) {
|
|
1931
|
+
none = false;
|
|
1932
|
+
}
|
|
1933
|
+
if (!n.isEffectivelyChecked) {
|
|
1934
|
+
isEffectivelyChecked = false;
|
|
1935
|
+
}
|
|
1936
|
+
}
|
|
1937
|
+
return {
|
|
1938
|
+
all,
|
|
1939
|
+
none,
|
|
1940
|
+
allWithoutDisable,
|
|
1941
|
+
half: !all && !none,
|
|
1942
|
+
isEffectivelyChecked
|
|
1943
|
+
};
|
|
1944
|
+
};
|
|
1945
|
+
const reInitChecked = function(node) {
|
|
1946
|
+
if (node.childNodes.length === 0 || node.loading) {
|
|
1947
|
+
node.isEffectivelyChecked = node.disabled || node.checked;
|
|
1948
|
+
return;
|
|
1949
|
+
}
|
|
1950
|
+
const { all, none, half, isEffectivelyChecked } = getChildState(node.childNodes);
|
|
1951
|
+
node.isEffectivelyChecked = isEffectivelyChecked;
|
|
1952
|
+
if (all) {
|
|
1953
|
+
node.checked = true;
|
|
1954
|
+
node.indeterminate = false;
|
|
1955
|
+
} else if (half) {
|
|
1956
|
+
node.checked = false;
|
|
1957
|
+
node.indeterminate = true;
|
|
1958
|
+
} else if (none) {
|
|
1959
|
+
node.checked = false;
|
|
1960
|
+
node.indeterminate = false;
|
|
1961
|
+
}
|
|
1962
|
+
const parent = node.parent;
|
|
1963
|
+
if (!parent || parent.level === 0)
|
|
1964
|
+
return;
|
|
1965
|
+
if (!node.store.checkStrictly) {
|
|
1966
|
+
reInitChecked(parent);
|
|
1967
|
+
}
|
|
1968
|
+
};
|
|
1969
|
+
const getPropertyFromData = function(node, prop) {
|
|
1970
|
+
const props = node.store.props;
|
|
1971
|
+
const data = node.data || {};
|
|
1972
|
+
const config = props[prop];
|
|
1973
|
+
if (isFunction(config)) {
|
|
1974
|
+
return config(data, node);
|
|
1975
|
+
} else if (isString(config)) {
|
|
1976
|
+
return data[config];
|
|
1977
|
+
} else if (isUndefined(config)) {
|
|
1978
|
+
const dataProp = data[prop];
|
|
1979
|
+
return isUndefined(dataProp) ? "" : dataProp;
|
|
1980
|
+
}
|
|
1981
|
+
};
|
|
1982
|
+
const setCanFocus = function(childNodes, focus) {
|
|
1983
|
+
childNodes.forEach((item) => {
|
|
1984
|
+
item.canFocus = focus;
|
|
1985
|
+
setCanFocus(item.childNodes, focus);
|
|
1986
|
+
});
|
|
1987
|
+
};
|
|
1988
|
+
let nodeIdSeed = 0;
|
|
1989
|
+
class Node {
|
|
1990
|
+
constructor(options) {
|
|
1991
|
+
this.isLeafByUser = void 0;
|
|
1992
|
+
this.isLeaf = void 0;
|
|
1993
|
+
this.isEffectivelyChecked = false;
|
|
1994
|
+
this.id = nodeIdSeed++;
|
|
1995
|
+
this.text = null;
|
|
1996
|
+
this.checked = false;
|
|
1997
|
+
this.indeterminate = false;
|
|
1998
|
+
this.data = null;
|
|
1999
|
+
this.expanded = false;
|
|
2000
|
+
this.parent = null;
|
|
2001
|
+
this.visible = true;
|
|
2002
|
+
this.isCurrent = false;
|
|
2003
|
+
this.canFocus = false;
|
|
2004
|
+
for (const name in options) {
|
|
2005
|
+
if (hasOwn(options, name)) {
|
|
2006
|
+
this[name] = options[name];
|
|
2007
|
+
}
|
|
2008
|
+
}
|
|
2009
|
+
this.level = 0;
|
|
2010
|
+
this.loaded = false;
|
|
2011
|
+
this.childNodes = [];
|
|
2012
|
+
this.loading = false;
|
|
2013
|
+
if (this.parent) {
|
|
2014
|
+
this.level = this.parent.level + 1;
|
|
2015
|
+
}
|
|
2016
|
+
}
|
|
2017
|
+
initialize() {
|
|
2018
|
+
var _a;
|
|
2019
|
+
const store = this.store;
|
|
2020
|
+
if (!store) {
|
|
2021
|
+
throw new Error("[Node]store is required!");
|
|
2022
|
+
}
|
|
2023
|
+
store.registerNode(this);
|
|
2024
|
+
const props = store.props;
|
|
2025
|
+
if (props && typeof props.isLeaf !== "undefined") {
|
|
2026
|
+
const isLeaf = getPropertyFromData(this, "isLeaf");
|
|
2027
|
+
if (isBoolean(isLeaf)) {
|
|
2028
|
+
this.isLeafByUser = isLeaf;
|
|
2029
|
+
}
|
|
2030
|
+
}
|
|
2031
|
+
if (store.lazy !== true && this.data) {
|
|
2032
|
+
this.setData(this.data);
|
|
2033
|
+
if (store.defaultExpandAll) {
|
|
2034
|
+
this.expanded = true;
|
|
2035
|
+
this.canFocus = true;
|
|
2036
|
+
}
|
|
2037
|
+
} else if (this.level > 0 && store.lazy && store.defaultExpandAll && !this.isLeafByUser) {
|
|
2038
|
+
this.expand();
|
|
2039
|
+
}
|
|
2040
|
+
if (!isArray(this.data)) {
|
|
2041
|
+
markNodeData(this, this.data);
|
|
2042
|
+
}
|
|
2043
|
+
if (!this.data)
|
|
2044
|
+
return;
|
|
2045
|
+
const defaultExpandedKeys = store.defaultExpandedKeys;
|
|
2046
|
+
const key = store.key;
|
|
2047
|
+
if (key && !isNil(this.key) && defaultExpandedKeys && defaultExpandedKeys.includes(this.key)) {
|
|
2048
|
+
this.expand(null, store.autoExpandParent);
|
|
2049
|
+
}
|
|
2050
|
+
if (key && store.currentNodeKey !== void 0 && this.key === store.currentNodeKey) {
|
|
2051
|
+
store.currentNode && (store.currentNode.isCurrent = false);
|
|
2052
|
+
store.currentNode = this;
|
|
2053
|
+
store.currentNode.isCurrent = true;
|
|
2054
|
+
}
|
|
2055
|
+
if (store.lazy) {
|
|
2056
|
+
store._initDefaultCheckedNode(this);
|
|
2057
|
+
}
|
|
2058
|
+
this.updateLeafState();
|
|
2059
|
+
if (this.level === 1 || ((_a = this.parent) == null ? void 0 : _a.expanded) === true)
|
|
2060
|
+
this.canFocus = true;
|
|
2061
|
+
}
|
|
2062
|
+
setData(data) {
|
|
2063
|
+
if (!isArray(data)) {
|
|
2064
|
+
markNodeData(this, data);
|
|
2065
|
+
}
|
|
2066
|
+
this.data = data;
|
|
2067
|
+
this.childNodes = [];
|
|
2068
|
+
let children;
|
|
2069
|
+
if (this.level === 0 && isArray(this.data)) {
|
|
2070
|
+
children = this.data;
|
|
2071
|
+
} else {
|
|
2072
|
+
children = getPropertyFromData(this, "children") || [];
|
|
2073
|
+
}
|
|
2074
|
+
for (let i = 0, j = children.length; i < j; i++) {
|
|
2075
|
+
this.insertChild({ data: children[i] });
|
|
2076
|
+
}
|
|
2077
|
+
}
|
|
2078
|
+
get label() {
|
|
2079
|
+
return getPropertyFromData(this, "label");
|
|
2080
|
+
}
|
|
2081
|
+
get key() {
|
|
2082
|
+
const nodeKey = this.store.key;
|
|
2083
|
+
if (this.data)
|
|
2084
|
+
return this.data[nodeKey];
|
|
2085
|
+
return null;
|
|
2086
|
+
}
|
|
2087
|
+
get disabled() {
|
|
2088
|
+
return getPropertyFromData(this, "disabled");
|
|
2089
|
+
}
|
|
2090
|
+
get nextSibling() {
|
|
2091
|
+
const parent = this.parent;
|
|
2092
|
+
if (parent) {
|
|
2093
|
+
const index = parent.childNodes.indexOf(this);
|
|
2094
|
+
if (index > -1) {
|
|
2095
|
+
return parent.childNodes[index + 1];
|
|
2096
|
+
}
|
|
2097
|
+
}
|
|
2098
|
+
return null;
|
|
2099
|
+
}
|
|
2100
|
+
get previousSibling() {
|
|
2101
|
+
const parent = this.parent;
|
|
2102
|
+
if (parent) {
|
|
2103
|
+
const index = parent.childNodes.indexOf(this);
|
|
2104
|
+
if (index > -1) {
|
|
2105
|
+
return index > 0 ? parent.childNodes[index - 1] : null;
|
|
2106
|
+
}
|
|
2107
|
+
}
|
|
2108
|
+
return null;
|
|
2109
|
+
}
|
|
2110
|
+
contains(target, deep = true) {
|
|
2111
|
+
return (this.childNodes || []).some((child) => child === target || deep && child.contains(target));
|
|
2112
|
+
}
|
|
2113
|
+
remove() {
|
|
2114
|
+
const parent = this.parent;
|
|
2115
|
+
if (parent) {
|
|
2116
|
+
parent.removeChild(this);
|
|
2117
|
+
}
|
|
2118
|
+
}
|
|
2119
|
+
insertChild(child, index, batch) {
|
|
2120
|
+
if (!child)
|
|
2121
|
+
throw new Error("InsertChild error: child is required.");
|
|
2122
|
+
if (!(child instanceof Node)) {
|
|
2123
|
+
if (!batch) {
|
|
2124
|
+
const children = this.getChildren(true);
|
|
2125
|
+
if (!(children == null ? void 0 : children.includes(child.data))) {
|
|
2126
|
+
if (isUndefined(index) || index < 0) {
|
|
2127
|
+
children == null ? void 0 : children.push(child.data);
|
|
2128
|
+
} else {
|
|
2129
|
+
children == null ? void 0 : children.splice(index, 0, child.data);
|
|
2130
|
+
}
|
|
2131
|
+
}
|
|
2132
|
+
}
|
|
2133
|
+
Object.assign(child, {
|
|
2134
|
+
parent: this,
|
|
2135
|
+
store: this.store
|
|
2136
|
+
});
|
|
2137
|
+
child = reactive(new Node(child));
|
|
2138
|
+
if (child instanceof Node) {
|
|
2139
|
+
child.initialize();
|
|
2140
|
+
}
|
|
2141
|
+
}
|
|
2142
|
+
child.level = this.level + 1;
|
|
2143
|
+
if (isUndefined(index) || index < 0) {
|
|
2144
|
+
this.childNodes.push(child);
|
|
2145
|
+
} else {
|
|
2146
|
+
this.childNodes.splice(index, 0, child);
|
|
2147
|
+
}
|
|
2148
|
+
this.updateLeafState();
|
|
2149
|
+
}
|
|
2150
|
+
insertBefore(child, ref) {
|
|
2151
|
+
let index;
|
|
2152
|
+
if (ref) {
|
|
2153
|
+
index = this.childNodes.indexOf(ref);
|
|
2154
|
+
}
|
|
2155
|
+
this.insertChild(child, index);
|
|
2156
|
+
}
|
|
2157
|
+
insertAfter(child, ref) {
|
|
2158
|
+
let index;
|
|
2159
|
+
if (ref) {
|
|
2160
|
+
index = this.childNodes.indexOf(ref);
|
|
2161
|
+
if (index !== -1)
|
|
2162
|
+
index += 1;
|
|
2163
|
+
}
|
|
2164
|
+
this.insertChild(child, index);
|
|
2165
|
+
}
|
|
2166
|
+
removeChild(child) {
|
|
2167
|
+
const children = this.getChildren() || [];
|
|
2168
|
+
const dataIndex = children.indexOf(child.data);
|
|
2169
|
+
if (dataIndex > -1) {
|
|
2170
|
+
children.splice(dataIndex, 1);
|
|
2171
|
+
}
|
|
2172
|
+
const index = this.childNodes.indexOf(child);
|
|
2173
|
+
if (index > -1) {
|
|
2174
|
+
this.store && this.store.deregisterNode(child);
|
|
2175
|
+
child.parent = null;
|
|
2176
|
+
this.childNodes.splice(index, 1);
|
|
2177
|
+
}
|
|
2178
|
+
this.updateLeafState();
|
|
2179
|
+
}
|
|
2180
|
+
removeChildByData(data) {
|
|
2181
|
+
const targetNode = this.childNodes.find((child) => child.data === data);
|
|
2182
|
+
if (targetNode) {
|
|
2183
|
+
this.removeChild(targetNode);
|
|
2184
|
+
}
|
|
2185
|
+
}
|
|
2186
|
+
expand(callback, expandParent) {
|
|
2187
|
+
const done = () => {
|
|
2188
|
+
if (expandParent) {
|
|
2189
|
+
let parent = this.parent;
|
|
2190
|
+
while (parent && parent.level > 0) {
|
|
2191
|
+
parent.expanded = true;
|
|
2192
|
+
parent = parent.parent;
|
|
2193
|
+
}
|
|
2194
|
+
}
|
|
2195
|
+
this.expanded = true;
|
|
2196
|
+
if (callback)
|
|
2197
|
+
callback();
|
|
2198
|
+
setCanFocus(this.childNodes, true);
|
|
2199
|
+
};
|
|
2200
|
+
if (this.shouldLoadData()) {
|
|
2201
|
+
this.loadData((data) => {
|
|
2202
|
+
if (isArray(data)) {
|
|
2203
|
+
if (this.checked) {
|
|
2204
|
+
this.setChecked(true, true);
|
|
2205
|
+
} else if (!this.store.checkStrictly) {
|
|
2206
|
+
reInitChecked(this);
|
|
2207
|
+
}
|
|
2208
|
+
done();
|
|
2209
|
+
}
|
|
2210
|
+
});
|
|
2211
|
+
} else {
|
|
2212
|
+
done();
|
|
2213
|
+
}
|
|
2214
|
+
}
|
|
2215
|
+
doCreateChildren(array, defaultProps = {}) {
|
|
2216
|
+
array.forEach((item) => {
|
|
2217
|
+
this.insertChild(Object.assign({ data: item }, defaultProps), void 0, true);
|
|
2218
|
+
});
|
|
2219
|
+
}
|
|
2220
|
+
collapse() {
|
|
2221
|
+
this.expanded = false;
|
|
2222
|
+
setCanFocus(this.childNodes, false);
|
|
2223
|
+
}
|
|
2224
|
+
shouldLoadData() {
|
|
2225
|
+
return Boolean(this.store.lazy === true && this.store.load && !this.loaded);
|
|
2226
|
+
}
|
|
2227
|
+
updateLeafState() {
|
|
2228
|
+
if (this.store.lazy === true && this.loaded !== true && typeof this.isLeafByUser !== "undefined") {
|
|
2229
|
+
this.isLeaf = this.isLeafByUser;
|
|
2230
|
+
this.isEffectivelyChecked = this.isLeaf && this.disabled;
|
|
2231
|
+
return;
|
|
2232
|
+
}
|
|
2233
|
+
const childNodes = this.childNodes;
|
|
2234
|
+
if (!this.store.lazy || this.store.lazy === true && this.loaded === true) {
|
|
2235
|
+
this.isLeaf = !childNodes || childNodes.length === 0;
|
|
2236
|
+
this.isEffectivelyChecked = this.isLeaf && this.disabled;
|
|
2237
|
+
return;
|
|
2238
|
+
}
|
|
2239
|
+
this.isLeaf = false;
|
|
2240
|
+
}
|
|
2241
|
+
setChecked(value, deep, recursion, passValue) {
|
|
2242
|
+
this.indeterminate = value === "half";
|
|
2243
|
+
this.checked = value === true;
|
|
2244
|
+
this.isEffectivelyChecked = !this.childNodes.length && (this.disabled || this.checked);
|
|
2245
|
+
if (this.store.checkStrictly)
|
|
2246
|
+
return;
|
|
2247
|
+
if (!(this.shouldLoadData() && !this.store.checkDescendants)) {
|
|
2248
|
+
const handleDescendants = () => {
|
|
2249
|
+
if (deep) {
|
|
2250
|
+
const childNodes = this.childNodes;
|
|
2251
|
+
for (let i = 0, j = childNodes.length; i < j; i++) {
|
|
2252
|
+
const child = childNodes[i];
|
|
2253
|
+
passValue = passValue || value !== false;
|
|
2254
|
+
const isCheck = child.disabled && child.isLeaf ? child.checked : passValue;
|
|
2255
|
+
child.setChecked(isCheck, deep, true, passValue);
|
|
2256
|
+
}
|
|
2257
|
+
const { half, all, isEffectivelyChecked } = getChildState(childNodes);
|
|
2258
|
+
if (!all) {
|
|
2259
|
+
this.checked = all;
|
|
2260
|
+
this.indeterminate = half;
|
|
2261
|
+
}
|
|
2262
|
+
this.isEffectivelyChecked = !this.childNodes.length ? this.disabled || this.checked : isEffectivelyChecked;
|
|
2263
|
+
}
|
|
2264
|
+
};
|
|
2265
|
+
if (this.shouldLoadData()) {
|
|
2266
|
+
this.loadData(() => {
|
|
2267
|
+
handleDescendants();
|
|
2268
|
+
reInitChecked(this);
|
|
2269
|
+
}, {
|
|
2270
|
+
checked: value !== false
|
|
2271
|
+
});
|
|
2272
|
+
return;
|
|
2273
|
+
} else {
|
|
2274
|
+
handleDescendants();
|
|
2275
|
+
}
|
|
2276
|
+
}
|
|
2277
|
+
const parent = this.parent;
|
|
2278
|
+
if (!parent || parent.level === 0)
|
|
2279
|
+
return;
|
|
2280
|
+
if (!recursion) {
|
|
2281
|
+
reInitChecked(parent);
|
|
2282
|
+
}
|
|
2283
|
+
}
|
|
2284
|
+
getChildren(forceInit = false) {
|
|
2285
|
+
if (this.level === 0)
|
|
2286
|
+
return this.data;
|
|
2287
|
+
const data = this.data;
|
|
2288
|
+
if (!data)
|
|
2289
|
+
return null;
|
|
2290
|
+
const props = this.store.props;
|
|
2291
|
+
let children = "children";
|
|
2292
|
+
if (props) {
|
|
2293
|
+
children = props.children || "children";
|
|
2294
|
+
}
|
|
2295
|
+
if (isUndefined(data[children])) {
|
|
2296
|
+
data[children] = null;
|
|
2297
|
+
}
|
|
2298
|
+
if (forceInit && !data[children]) {
|
|
2299
|
+
data[children] = [];
|
|
2300
|
+
}
|
|
2301
|
+
return data[children];
|
|
2302
|
+
}
|
|
2303
|
+
updateChildren() {
|
|
2304
|
+
const newData = this.getChildren() || [];
|
|
2305
|
+
const oldData = this.childNodes.map((node) => node.data);
|
|
2306
|
+
const newDataMap = {};
|
|
2307
|
+
const newNodes = [];
|
|
2308
|
+
newData.forEach((item, index) => {
|
|
2309
|
+
const key = item[NODE_KEY];
|
|
2310
|
+
const isNodeExists = !!key && oldData.some((data) => (data == null ? void 0 : data[NODE_KEY]) === key);
|
|
2311
|
+
if (isNodeExists) {
|
|
2312
|
+
newDataMap[key] = { index, data: item };
|
|
2313
|
+
} else {
|
|
2314
|
+
newNodes.push({ index, data: item });
|
|
2315
|
+
}
|
|
2316
|
+
});
|
|
2317
|
+
if (!this.store.lazy) {
|
|
2318
|
+
oldData.forEach((item) => {
|
|
2319
|
+
if (!newDataMap[item == null ? void 0 : item[NODE_KEY]])
|
|
2320
|
+
this.removeChildByData(item);
|
|
2321
|
+
});
|
|
2322
|
+
}
|
|
2323
|
+
newNodes.forEach(({ index, data }) => {
|
|
2324
|
+
this.insertChild({ data }, index);
|
|
2325
|
+
});
|
|
2326
|
+
this.updateLeafState();
|
|
2327
|
+
}
|
|
2328
|
+
loadData(callback, defaultProps = {}) {
|
|
2329
|
+
if (this.store.lazy === true && this.store.load && !this.loaded && (!this.loading || Object.keys(defaultProps).length)) {
|
|
2330
|
+
this.loading = true;
|
|
2331
|
+
const resolve = (children) => {
|
|
2332
|
+
this.childNodes = [];
|
|
2333
|
+
this.doCreateChildren(children, defaultProps);
|
|
2334
|
+
this.loaded = true;
|
|
2335
|
+
this.loading = false;
|
|
2336
|
+
this.updateLeafState();
|
|
2337
|
+
if (callback) {
|
|
2338
|
+
callback.call(this, children);
|
|
2339
|
+
}
|
|
2340
|
+
};
|
|
2341
|
+
const reject = () => {
|
|
2342
|
+
this.loading = false;
|
|
2343
|
+
};
|
|
2344
|
+
this.store.load(this, resolve, reject);
|
|
2345
|
+
} else {
|
|
2346
|
+
if (callback) {
|
|
2347
|
+
callback.call(this);
|
|
2348
|
+
}
|
|
2349
|
+
}
|
|
2350
|
+
}
|
|
2351
|
+
eachNode(callback) {
|
|
2352
|
+
const arr = [this];
|
|
2353
|
+
while (arr.length) {
|
|
2354
|
+
const node = arr.shift();
|
|
2355
|
+
arr.unshift(...node.childNodes);
|
|
2356
|
+
callback(node);
|
|
2357
|
+
}
|
|
2358
|
+
}
|
|
2359
|
+
reInitChecked() {
|
|
2360
|
+
if (this.store.checkStrictly)
|
|
2361
|
+
return;
|
|
2362
|
+
reInitChecked(this);
|
|
2363
|
+
}
|
|
2364
|
+
}
|
|
2365
|
+
|
|
2366
|
+
class TreeStore {
|
|
2367
|
+
constructor(options) {
|
|
2368
|
+
this.lazy = false;
|
|
2369
|
+
this.checkStrictly = false;
|
|
2370
|
+
this.autoExpandParent = false;
|
|
2371
|
+
this.defaultExpandAll = false;
|
|
2372
|
+
this.checkDescendants = false;
|
|
2373
|
+
this.currentNode = null;
|
|
2374
|
+
this.currentNodeKey = null;
|
|
2375
|
+
for (const option in options) {
|
|
2376
|
+
if (hasOwn(options, option)) {
|
|
2377
|
+
this[option] = options[option];
|
|
2378
|
+
}
|
|
2379
|
+
}
|
|
2380
|
+
this.nodesMap = {};
|
|
2381
|
+
}
|
|
2382
|
+
initialize() {
|
|
2383
|
+
this.root = new Node({
|
|
2384
|
+
data: this.data,
|
|
2385
|
+
store: this
|
|
2386
|
+
});
|
|
2387
|
+
this.root.initialize();
|
|
2388
|
+
if (this.lazy && this.load) {
|
|
2389
|
+
const loadFn = this.load;
|
|
2390
|
+
loadFn(this.root, (data) => {
|
|
2391
|
+
this.root.doCreateChildren(data);
|
|
2392
|
+
this._initDefaultCheckedNodes();
|
|
2393
|
+
}, NOOP);
|
|
2394
|
+
} else {
|
|
2395
|
+
this._initDefaultCheckedNodes();
|
|
2396
|
+
}
|
|
2397
|
+
}
|
|
2398
|
+
filter(value) {
|
|
2399
|
+
const filterNodeMethod = this.filterNodeMethod;
|
|
2400
|
+
const lazy = this.lazy;
|
|
2401
|
+
const traverse = async function(node) {
|
|
2402
|
+
const childNodes = node.root ? node.root.childNodes : node.childNodes;
|
|
2403
|
+
for (const [index, child] of childNodes.entries()) {
|
|
2404
|
+
child.visible = !!(filterNodeMethod == null ? void 0 : filterNodeMethod.call(child, value, child.data, child));
|
|
2405
|
+
if (index % 80 === 0 && index > 0) {
|
|
2406
|
+
await nextTick();
|
|
2407
|
+
}
|
|
2408
|
+
await traverse(child);
|
|
2409
|
+
}
|
|
2410
|
+
if (!node.visible && childNodes.length) {
|
|
2411
|
+
let allHidden = true;
|
|
2412
|
+
allHidden = !childNodes.some((child) => child.visible);
|
|
2413
|
+
if (node.root) {
|
|
2414
|
+
node.root.visible = allHidden === false;
|
|
2415
|
+
} else {
|
|
2416
|
+
node.visible = allHidden === false;
|
|
2417
|
+
}
|
|
2418
|
+
}
|
|
2419
|
+
if (!value)
|
|
2420
|
+
return;
|
|
2421
|
+
if (node.visible && !node.isLeaf) {
|
|
2422
|
+
if (!lazy || node.loaded) {
|
|
2423
|
+
node.expand();
|
|
2424
|
+
}
|
|
2425
|
+
}
|
|
2426
|
+
};
|
|
2427
|
+
traverse(this);
|
|
2428
|
+
}
|
|
2429
|
+
setData(newVal) {
|
|
2430
|
+
const instanceChanged = newVal !== this.root.data;
|
|
2431
|
+
if (instanceChanged) {
|
|
2432
|
+
this.nodesMap = {};
|
|
2433
|
+
this.root.setData(newVal);
|
|
2434
|
+
this._initDefaultCheckedNodes();
|
|
2435
|
+
this.setCurrentNodeKey(this.currentNodeKey);
|
|
2436
|
+
} else {
|
|
2437
|
+
this.root.updateChildren();
|
|
2438
|
+
}
|
|
2439
|
+
}
|
|
2440
|
+
getNode(data) {
|
|
2441
|
+
if (data instanceof Node)
|
|
2442
|
+
return data;
|
|
2443
|
+
const key = isObject(data) ? getNodeKey(this.key, data) : data;
|
|
2444
|
+
return this.nodesMap[key] || null;
|
|
2445
|
+
}
|
|
2446
|
+
insertBefore(data, refData) {
|
|
2447
|
+
var _a;
|
|
2448
|
+
const refNode = this.getNode(refData);
|
|
2449
|
+
(_a = refNode.parent) == null ? void 0 : _a.insertBefore({ data }, refNode);
|
|
2450
|
+
}
|
|
2451
|
+
insertAfter(data, refData) {
|
|
2452
|
+
var _a;
|
|
2453
|
+
const refNode = this.getNode(refData);
|
|
2454
|
+
(_a = refNode.parent) == null ? void 0 : _a.insertAfter({ data }, refNode);
|
|
2455
|
+
}
|
|
2456
|
+
remove(data) {
|
|
2457
|
+
const node = this.getNode(data);
|
|
2458
|
+
if (node && node.parent) {
|
|
2459
|
+
if (node === this.currentNode) {
|
|
2460
|
+
this.currentNode = null;
|
|
2461
|
+
}
|
|
2462
|
+
node.parent.removeChild(node);
|
|
2463
|
+
}
|
|
2464
|
+
}
|
|
2465
|
+
append(data, parentData) {
|
|
2466
|
+
const parentNode = !isPropAbsent(parentData) ? this.getNode(parentData) : this.root;
|
|
2467
|
+
if (parentNode) {
|
|
2468
|
+
parentNode.insertChild({ data });
|
|
2469
|
+
}
|
|
2470
|
+
}
|
|
2471
|
+
_initDefaultCheckedNodes() {
|
|
2472
|
+
const defaultCheckedKeys = this.defaultCheckedKeys || [];
|
|
2473
|
+
const nodesMap = this.nodesMap;
|
|
2474
|
+
defaultCheckedKeys.forEach((checkedKey) => {
|
|
2475
|
+
const node = nodesMap[checkedKey];
|
|
2476
|
+
if (node) {
|
|
2477
|
+
node.setChecked(true, !this.checkStrictly);
|
|
2478
|
+
}
|
|
2479
|
+
});
|
|
2480
|
+
}
|
|
2481
|
+
_initDefaultCheckedNode(node) {
|
|
2482
|
+
const defaultCheckedKeys = this.defaultCheckedKeys || [];
|
|
2483
|
+
if (!isNil(node.key) && defaultCheckedKeys.includes(node.key)) {
|
|
2484
|
+
node.setChecked(true, !this.checkStrictly);
|
|
2485
|
+
}
|
|
2486
|
+
}
|
|
2487
|
+
setDefaultCheckedKey(newVal) {
|
|
2488
|
+
if (newVal !== this.defaultCheckedKeys) {
|
|
2489
|
+
this.defaultCheckedKeys = newVal;
|
|
2490
|
+
this._initDefaultCheckedNodes();
|
|
2491
|
+
}
|
|
2492
|
+
}
|
|
2493
|
+
registerNode(node) {
|
|
2494
|
+
const key = this.key;
|
|
2495
|
+
if (!node || !node.data)
|
|
2496
|
+
return;
|
|
2497
|
+
if (!key) {
|
|
2498
|
+
this.nodesMap[node.id] = node;
|
|
2499
|
+
} else {
|
|
2500
|
+
const nodeKey = node.key;
|
|
2501
|
+
if (!isNil(nodeKey))
|
|
2502
|
+
this.nodesMap[nodeKey] = node;
|
|
2503
|
+
}
|
|
2504
|
+
}
|
|
2505
|
+
deregisterNode(node) {
|
|
2506
|
+
const key = this.key;
|
|
2507
|
+
if (!key || !node || !node.data)
|
|
2508
|
+
return;
|
|
2509
|
+
node.childNodes.forEach((child) => {
|
|
2510
|
+
this.deregisterNode(child);
|
|
2511
|
+
});
|
|
2512
|
+
delete this.nodesMap[node.key];
|
|
2513
|
+
}
|
|
2514
|
+
getCheckedNodes(leafOnly = false, includeHalfChecked = false) {
|
|
2515
|
+
const checkedNodes = [];
|
|
2516
|
+
const traverse = function(node) {
|
|
2517
|
+
const childNodes = node.root ? node.root.childNodes : node.childNodes;
|
|
2518
|
+
childNodes.forEach((child) => {
|
|
2519
|
+
if ((child.checked || includeHalfChecked && child.indeterminate) && (!leafOnly || leafOnly && child.isLeaf)) {
|
|
2520
|
+
checkedNodes.push(child.data);
|
|
2521
|
+
}
|
|
2522
|
+
traverse(child);
|
|
2523
|
+
});
|
|
2524
|
+
};
|
|
2525
|
+
traverse(this);
|
|
2526
|
+
return checkedNodes;
|
|
2527
|
+
}
|
|
2528
|
+
getCheckedKeys(leafOnly = false) {
|
|
2529
|
+
return this.getCheckedNodes(leafOnly).map((data) => (data || {})[this.key]);
|
|
2530
|
+
}
|
|
2531
|
+
getHalfCheckedNodes() {
|
|
2532
|
+
const nodes = [];
|
|
2533
|
+
const traverse = function(node) {
|
|
2534
|
+
const childNodes = node.root ? node.root.childNodes : node.childNodes;
|
|
2535
|
+
childNodes.forEach((child) => {
|
|
2536
|
+
if (child.indeterminate) {
|
|
2537
|
+
nodes.push(child.data);
|
|
2538
|
+
}
|
|
2539
|
+
traverse(child);
|
|
2540
|
+
});
|
|
2541
|
+
};
|
|
2542
|
+
traverse(this);
|
|
2543
|
+
return nodes;
|
|
2544
|
+
}
|
|
2545
|
+
getHalfCheckedKeys() {
|
|
2546
|
+
return this.getHalfCheckedNodes().map((data) => (data || {})[this.key]);
|
|
2547
|
+
}
|
|
2548
|
+
_getAllNodes() {
|
|
2549
|
+
const allNodes = [];
|
|
2550
|
+
const nodesMap = this.nodesMap;
|
|
2551
|
+
for (const nodeKey in nodesMap) {
|
|
2552
|
+
if (hasOwn(nodesMap, nodeKey)) {
|
|
2553
|
+
allNodes.push(nodesMap[nodeKey]);
|
|
2554
|
+
}
|
|
2555
|
+
}
|
|
2556
|
+
return allNodes;
|
|
2557
|
+
}
|
|
2558
|
+
updateChildren(key, data) {
|
|
2559
|
+
const node = this.nodesMap[key];
|
|
2560
|
+
if (!node)
|
|
2561
|
+
return;
|
|
2562
|
+
const childNodes = node.childNodes;
|
|
2563
|
+
for (let i = childNodes.length - 1; i >= 0; i--) {
|
|
2564
|
+
const child = childNodes[i];
|
|
2565
|
+
this.remove(child.data);
|
|
2566
|
+
}
|
|
2567
|
+
for (let i = 0, j = data.length; i < j; i++) {
|
|
2568
|
+
const child = data[i];
|
|
2569
|
+
this.append(child, node.data);
|
|
2570
|
+
}
|
|
2571
|
+
}
|
|
2572
|
+
_setCheckedKeys(key, leafOnly = false, checkedKeys) {
|
|
2573
|
+
const allNodes = this._getAllNodes().sort((a, b) => a.level - b.level);
|
|
2574
|
+
const cache = /* @__PURE__ */ Object.create(null);
|
|
2575
|
+
const keys = Object.keys(checkedKeys);
|
|
2576
|
+
allNodes.forEach((node) => node.setChecked(false, false));
|
|
2577
|
+
const cacheCheckedChild = (node) => {
|
|
2578
|
+
node.childNodes.forEach((child) => {
|
|
2579
|
+
var _a;
|
|
2580
|
+
cache[child.data[key]] = true;
|
|
2581
|
+
if ((_a = child.childNodes) == null ? void 0 : _a.length) {
|
|
2582
|
+
cacheCheckedChild(child);
|
|
2583
|
+
}
|
|
2584
|
+
});
|
|
2585
|
+
};
|
|
2586
|
+
for (let i = 0, j = allNodes.length; i < j; i++) {
|
|
2587
|
+
const node = allNodes[i];
|
|
2588
|
+
const nodeKey = node.data[key].toString();
|
|
2589
|
+
const checked = keys.includes(nodeKey);
|
|
2590
|
+
if (!checked) {
|
|
2591
|
+
if (node.checked && !cache[nodeKey]) {
|
|
2592
|
+
node.setChecked(false, false);
|
|
2593
|
+
}
|
|
2594
|
+
continue;
|
|
2595
|
+
}
|
|
2596
|
+
if (node.childNodes.length) {
|
|
2597
|
+
cacheCheckedChild(node);
|
|
2598
|
+
}
|
|
2599
|
+
if (node.isLeaf || this.checkStrictly) {
|
|
2600
|
+
node.setChecked(true, false);
|
|
2601
|
+
continue;
|
|
2602
|
+
}
|
|
2603
|
+
node.setChecked(true, true);
|
|
2604
|
+
if (leafOnly) {
|
|
2605
|
+
node.setChecked(false, false);
|
|
2606
|
+
const traverse = function(node2) {
|
|
2607
|
+
const childNodes = node2.childNodes;
|
|
2608
|
+
childNodes.forEach((child) => {
|
|
2609
|
+
if (!child.isLeaf) {
|
|
2610
|
+
child.setChecked(false, false);
|
|
2611
|
+
}
|
|
2612
|
+
traverse(child);
|
|
2613
|
+
});
|
|
2614
|
+
};
|
|
2615
|
+
traverse(node);
|
|
2616
|
+
}
|
|
2617
|
+
}
|
|
2618
|
+
}
|
|
2619
|
+
setCheckedNodes(array, leafOnly = false) {
|
|
2620
|
+
const key = this.key;
|
|
2621
|
+
const checkedKeys = {};
|
|
2622
|
+
array.forEach((item) => {
|
|
2623
|
+
checkedKeys[(item || {})[key]] = true;
|
|
2624
|
+
});
|
|
2625
|
+
this._setCheckedKeys(key, leafOnly, checkedKeys);
|
|
2626
|
+
}
|
|
2627
|
+
setCheckedKeys(keys, leafOnly = false) {
|
|
2628
|
+
this.defaultCheckedKeys = keys;
|
|
2629
|
+
const key = this.key;
|
|
2630
|
+
const checkedKeys = {};
|
|
2631
|
+
keys.forEach((key2) => {
|
|
2632
|
+
checkedKeys[key2] = true;
|
|
2633
|
+
});
|
|
2634
|
+
this._setCheckedKeys(key, leafOnly, checkedKeys);
|
|
2635
|
+
}
|
|
2636
|
+
setDefaultExpandedKeys(keys) {
|
|
2637
|
+
keys = keys || [];
|
|
2638
|
+
this.defaultExpandedKeys = keys;
|
|
2639
|
+
keys.forEach((key) => {
|
|
2640
|
+
const node = this.getNode(key);
|
|
2641
|
+
if (node)
|
|
2642
|
+
node.expand(null, this.autoExpandParent);
|
|
2643
|
+
});
|
|
2644
|
+
}
|
|
2645
|
+
setChecked(data, checked, deep) {
|
|
2646
|
+
const node = this.getNode(data);
|
|
2647
|
+
if (node) {
|
|
2648
|
+
node.setChecked(!!checked, deep);
|
|
2649
|
+
}
|
|
2650
|
+
}
|
|
2651
|
+
getCurrentNode() {
|
|
2652
|
+
return this.currentNode;
|
|
2653
|
+
}
|
|
2654
|
+
setCurrentNode(currentNode) {
|
|
2655
|
+
const prevCurrentNode = this.currentNode;
|
|
2656
|
+
if (prevCurrentNode) {
|
|
2657
|
+
prevCurrentNode.isCurrent = false;
|
|
2658
|
+
}
|
|
2659
|
+
this.currentNode = currentNode;
|
|
2660
|
+
this.currentNode.isCurrent = true;
|
|
2661
|
+
}
|
|
2662
|
+
setUserCurrentNode(node, shouldAutoExpandParent = true) {
|
|
2663
|
+
var _a;
|
|
2664
|
+
const key = node[this.key];
|
|
2665
|
+
const currNode = this.nodesMap[key];
|
|
2666
|
+
this.setCurrentNode(currNode);
|
|
2667
|
+
if (shouldAutoExpandParent && this.currentNode && this.currentNode.level > 1) {
|
|
2668
|
+
(_a = this.currentNode.parent) == null ? void 0 : _a.expand(null, true);
|
|
2669
|
+
}
|
|
2670
|
+
}
|
|
2671
|
+
setCurrentNodeKey(key, shouldAutoExpandParent = true) {
|
|
2672
|
+
var _a;
|
|
2673
|
+
this.currentNodeKey = key;
|
|
2674
|
+
if (isPropAbsent(key)) {
|
|
2675
|
+
this.currentNode && (this.currentNode.isCurrent = false);
|
|
2676
|
+
this.currentNode = null;
|
|
2677
|
+
return;
|
|
2678
|
+
}
|
|
2679
|
+
const node = this.getNode(key);
|
|
2680
|
+
if (node) {
|
|
2681
|
+
this.setCurrentNode(node);
|
|
2682
|
+
if (shouldAutoExpandParent && this.currentNode && this.currentNode.level > 1) {
|
|
2683
|
+
(_a = this.currentNode.parent) == null ? void 0 : _a.expand(null, true);
|
|
2684
|
+
}
|
|
2685
|
+
}
|
|
2686
|
+
}
|
|
2687
|
+
}
|
|
2688
|
+
|
|
2689
|
+
const ROOT_TREE_INJECTION_KEY = "RootTree";
|
|
2690
|
+
const NODE_INSTANCE_INJECTION_KEY = "NodeInstance";
|
|
2691
|
+
const TREE_NODE_MAP_INJECTION_KEY = "TreeNodeMap";
|
|
2692
|
+
|
|
2693
|
+
const _sfc_main$3 = defineComponent({
|
|
2694
|
+
name: "ElTreeNodeContent",
|
|
2695
|
+
props: {
|
|
2696
|
+
node: {
|
|
2697
|
+
type: Object,
|
|
2698
|
+
required: true
|
|
2699
|
+
},
|
|
2700
|
+
renderContent: Function
|
|
2701
|
+
},
|
|
2702
|
+
setup(props) {
|
|
2703
|
+
const ns = useNamespace("tree");
|
|
2704
|
+
const nodeInstance = inject(NODE_INSTANCE_INJECTION_KEY);
|
|
2705
|
+
const tree = inject(ROOT_TREE_INJECTION_KEY);
|
|
2706
|
+
return () => {
|
|
2707
|
+
const node = props.node;
|
|
2708
|
+
const { data, store } = node;
|
|
2709
|
+
return props.renderContent ? props.renderContent(h, { _self: nodeInstance, node, data, store }) : renderSlot(tree.ctx.slots, "default", { node, data }, () => [
|
|
2710
|
+
h(ElText, { tag: "span", truncated: true, class: ns.be("node", "label") }, () => [node.label])
|
|
2711
|
+
]);
|
|
2712
|
+
};
|
|
2713
|
+
}
|
|
2714
|
+
});
|
|
2715
|
+
var NodeContent = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__file", "tree-node-content.vue"]]);
|
|
2716
|
+
|
|
2717
|
+
function useNodeExpandEventBroadcast(props) {
|
|
2718
|
+
const parentNodeMap = inject(TREE_NODE_MAP_INJECTION_KEY, null);
|
|
2719
|
+
const currentNodeMap = {
|
|
2720
|
+
treeNodeExpand: (node) => {
|
|
2721
|
+
var _a;
|
|
2722
|
+
if (props.node !== node) {
|
|
2723
|
+
(_a = props.node) == null ? void 0 : _a.collapse();
|
|
2724
|
+
}
|
|
2725
|
+
},
|
|
2726
|
+
children: []
|
|
2727
|
+
};
|
|
2728
|
+
if (parentNodeMap) {
|
|
2729
|
+
parentNodeMap.children.push(currentNodeMap);
|
|
2730
|
+
}
|
|
2731
|
+
provide(TREE_NODE_MAP_INJECTION_KEY, currentNodeMap);
|
|
2732
|
+
return {
|
|
2733
|
+
broadcastExpanded: (node) => {
|
|
2734
|
+
if (!props.accordion)
|
|
2735
|
+
return;
|
|
2736
|
+
for (const childNode of currentNodeMap.children) {
|
|
2737
|
+
childNode.treeNodeExpand(node);
|
|
2738
|
+
}
|
|
2739
|
+
}
|
|
2740
|
+
};
|
|
2741
|
+
}
|
|
2742
|
+
|
|
2743
|
+
const dragEventsKey = Symbol("dragEvents");
|
|
2744
|
+
function useDragNodeHandler({
|
|
2745
|
+
props,
|
|
2746
|
+
ctx,
|
|
2747
|
+
el$,
|
|
2748
|
+
dropIndicator$,
|
|
2749
|
+
store
|
|
2750
|
+
}) {
|
|
2751
|
+
const ns = useNamespace("tree");
|
|
2752
|
+
const dragState = ref({
|
|
2753
|
+
showDropIndicator: false,
|
|
2754
|
+
draggingNode: null,
|
|
2755
|
+
dropNode: null,
|
|
2756
|
+
allowDrop: true,
|
|
2757
|
+
dropType: null
|
|
2758
|
+
});
|
|
2759
|
+
const treeNodeDragStart = ({ event, treeNode }) => {
|
|
2760
|
+
if (!event.dataTransfer)
|
|
2761
|
+
return;
|
|
2762
|
+
if (isFunction(props.allowDrag) && !props.allowDrag(treeNode.node)) {
|
|
2763
|
+
event.preventDefault();
|
|
2764
|
+
return false;
|
|
2765
|
+
}
|
|
2766
|
+
event.dataTransfer.effectAllowed = "move";
|
|
2767
|
+
try {
|
|
2768
|
+
event.dataTransfer.setData("text/plain", "");
|
|
2769
|
+
} catch (e) {
|
|
2770
|
+
}
|
|
2771
|
+
dragState.value.draggingNode = treeNode;
|
|
2772
|
+
ctx.emit("node-drag-start", treeNode.node, event);
|
|
2773
|
+
};
|
|
2774
|
+
const treeNodeDragOver = ({ event, treeNode }) => {
|
|
2775
|
+
if (!event.dataTransfer)
|
|
2776
|
+
return;
|
|
2777
|
+
const dropNode = treeNode;
|
|
2778
|
+
const oldDropNode = dragState.value.dropNode;
|
|
2779
|
+
if (oldDropNode && oldDropNode.node.id !== dropNode.node.id) {
|
|
2780
|
+
removeClass(oldDropNode.$el, ns.is("drop-inner"));
|
|
2781
|
+
}
|
|
2782
|
+
const draggingNode = dragState.value.draggingNode;
|
|
2783
|
+
if (!draggingNode || !dropNode)
|
|
2784
|
+
return;
|
|
2785
|
+
let dropPrev = true;
|
|
2786
|
+
let dropInner = true;
|
|
2787
|
+
let dropNext = true;
|
|
2788
|
+
let userAllowDropInner = true;
|
|
2789
|
+
if (isFunction(props.allowDrop)) {
|
|
2790
|
+
dropPrev = props.allowDrop(draggingNode.node, dropNode.node, "prev");
|
|
2791
|
+
userAllowDropInner = dropInner = props.allowDrop(draggingNode.node, dropNode.node, "inner");
|
|
2792
|
+
dropNext = props.allowDrop(draggingNode.node, dropNode.node, "next");
|
|
2793
|
+
}
|
|
2794
|
+
event.dataTransfer.dropEffect = dropInner || dropPrev || dropNext ? "move" : "none";
|
|
2795
|
+
if ((dropPrev || dropInner || dropNext) && (oldDropNode == null ? void 0 : oldDropNode.node.id) !== dropNode.node.id) {
|
|
2796
|
+
if (oldDropNode) {
|
|
2797
|
+
ctx.emit("node-drag-leave", draggingNode.node, oldDropNode.node, event);
|
|
2798
|
+
}
|
|
2799
|
+
ctx.emit("node-drag-enter", draggingNode.node, dropNode.node, event);
|
|
2800
|
+
}
|
|
2801
|
+
if (dropPrev || dropInner || dropNext) {
|
|
2802
|
+
dragState.value.dropNode = dropNode;
|
|
2803
|
+
} else {
|
|
2804
|
+
dragState.value.dropNode = null;
|
|
2805
|
+
}
|
|
2806
|
+
if (dropNode.node.nextSibling === draggingNode.node) {
|
|
2807
|
+
dropNext = false;
|
|
2808
|
+
}
|
|
2809
|
+
if (dropNode.node.previousSibling === draggingNode.node) {
|
|
2810
|
+
dropPrev = false;
|
|
2811
|
+
}
|
|
2812
|
+
if (dropNode.node.contains(draggingNode.node, false)) {
|
|
2813
|
+
dropInner = false;
|
|
2814
|
+
}
|
|
2815
|
+
if (draggingNode.node === dropNode.node || draggingNode.node.contains(dropNode.node)) {
|
|
2816
|
+
dropPrev = false;
|
|
2817
|
+
dropInner = false;
|
|
2818
|
+
dropNext = false;
|
|
2819
|
+
}
|
|
2820
|
+
const dropEl = dropNode.$el;
|
|
2821
|
+
const targetPosition = dropEl.querySelector(`.${ns.be("node", "content")}`).getBoundingClientRect();
|
|
2822
|
+
const treePosition = el$.value.getBoundingClientRect();
|
|
2823
|
+
const treeScrollTop = el$.value.scrollTop;
|
|
2824
|
+
let dropType;
|
|
2825
|
+
const prevPercent = dropPrev ? dropInner ? 0.25 : dropNext ? 0.45 : 1 : Number.NEGATIVE_INFINITY;
|
|
2826
|
+
const nextPercent = dropNext ? dropInner ? 0.75 : dropPrev ? 0.55 : 0 : Number.POSITIVE_INFINITY;
|
|
2827
|
+
let indicatorTop = -9999;
|
|
2828
|
+
const distance = event.clientY - targetPosition.top;
|
|
2829
|
+
if (distance < targetPosition.height * prevPercent) {
|
|
2830
|
+
dropType = "before";
|
|
2831
|
+
} else if (distance > targetPosition.height * nextPercent) {
|
|
2832
|
+
dropType = "after";
|
|
2833
|
+
} else if (dropInner) {
|
|
2834
|
+
dropType = "inner";
|
|
2835
|
+
} else {
|
|
2836
|
+
dropType = "none";
|
|
2837
|
+
}
|
|
2838
|
+
const iconPosition = dropEl.querySelector(`.${ns.be("node", "expand-icon")}`).getBoundingClientRect();
|
|
2839
|
+
const dropIndicator = dropIndicator$.value;
|
|
2840
|
+
if (dropType === "before") {
|
|
2841
|
+
indicatorTop = iconPosition.top - treePosition.top + treeScrollTop;
|
|
2842
|
+
} else if (dropType === "after") {
|
|
2843
|
+
indicatorTop = iconPosition.bottom - treePosition.top + treeScrollTop;
|
|
2844
|
+
}
|
|
2845
|
+
dropIndicator.style.top = `${indicatorTop}px`;
|
|
2846
|
+
dropIndicator.style.left = `${iconPosition.right - treePosition.left}px`;
|
|
2847
|
+
if (dropType === "inner") {
|
|
2848
|
+
addClass(dropEl, ns.is("drop-inner"));
|
|
2849
|
+
} else {
|
|
2850
|
+
removeClass(dropEl, ns.is("drop-inner"));
|
|
2851
|
+
}
|
|
2852
|
+
dragState.value.showDropIndicator = dropType === "before" || dropType === "after";
|
|
2853
|
+
dragState.value.allowDrop = dragState.value.showDropIndicator || userAllowDropInner;
|
|
2854
|
+
dragState.value.dropType = dropType;
|
|
2855
|
+
ctx.emit("node-drag-over", draggingNode.node, dropNode.node, event);
|
|
2856
|
+
};
|
|
2857
|
+
const treeNodeDragEnd = (event) => {
|
|
2858
|
+
var _a, _b;
|
|
2859
|
+
const { draggingNode, dropType, dropNode } = dragState.value;
|
|
2860
|
+
event.preventDefault();
|
|
2861
|
+
if (event.dataTransfer) {
|
|
2862
|
+
event.dataTransfer.dropEffect = "move";
|
|
2863
|
+
}
|
|
2864
|
+
if ((draggingNode == null ? void 0 : draggingNode.node.data) && dropNode) {
|
|
2865
|
+
const draggingNodeCopy = { data: draggingNode.node.data };
|
|
2866
|
+
if (dropType !== "none") {
|
|
2867
|
+
draggingNode.node.remove();
|
|
2868
|
+
}
|
|
2869
|
+
if (dropType === "before") {
|
|
2870
|
+
(_a = dropNode.node.parent) == null ? void 0 : _a.insertBefore(draggingNodeCopy, dropNode.node);
|
|
2871
|
+
} else if (dropType === "after") {
|
|
2872
|
+
(_b = dropNode.node.parent) == null ? void 0 : _b.insertAfter(draggingNodeCopy, dropNode.node);
|
|
2873
|
+
} else if (dropType === "inner") {
|
|
2874
|
+
dropNode.node.insertChild(draggingNodeCopy);
|
|
2875
|
+
}
|
|
2876
|
+
if (dropType !== "none") {
|
|
2877
|
+
store.value.registerNode(draggingNodeCopy);
|
|
2878
|
+
if (store.value.key) {
|
|
2879
|
+
draggingNode.node.eachNode((node) => {
|
|
2880
|
+
var _a2;
|
|
2881
|
+
(_a2 = store.value.nodesMap[node.data[store.value.key]]) == null ? void 0 : _a2.setChecked(node.checked, !store.value.checkStrictly);
|
|
2882
|
+
});
|
|
2883
|
+
}
|
|
2884
|
+
}
|
|
2885
|
+
removeClass(dropNode.$el, ns.is("drop-inner"));
|
|
2886
|
+
ctx.emit("node-drag-end", draggingNode.node, dropNode.node, dropType, event);
|
|
2887
|
+
if (dropType !== "none") {
|
|
2888
|
+
ctx.emit("node-drop", draggingNode.node, dropNode.node, dropType, event);
|
|
2889
|
+
}
|
|
2890
|
+
}
|
|
2891
|
+
if (draggingNode && !dropNode) {
|
|
2892
|
+
ctx.emit("node-drag-end", draggingNode.node, null, dropType, event);
|
|
2893
|
+
}
|
|
2894
|
+
dragState.value.showDropIndicator = false;
|
|
2895
|
+
dragState.value.draggingNode = null;
|
|
2896
|
+
dragState.value.dropNode = null;
|
|
2897
|
+
dragState.value.allowDrop = true;
|
|
2898
|
+
};
|
|
2899
|
+
provide(dragEventsKey, {
|
|
2900
|
+
treeNodeDragStart,
|
|
2901
|
+
treeNodeDragOver,
|
|
2902
|
+
treeNodeDragEnd
|
|
2903
|
+
});
|
|
2904
|
+
return {
|
|
2905
|
+
dragState
|
|
2906
|
+
};
|
|
2907
|
+
}
|
|
2908
|
+
|
|
2909
|
+
const _sfc_main$2 = defineComponent({
|
|
2910
|
+
name: "ElTreeNode",
|
|
2911
|
+
components: {
|
|
2912
|
+
ElCollapseTransition,
|
|
2913
|
+
ElCheckbox,
|
|
2914
|
+
NodeContent,
|
|
2915
|
+
ElIcon,
|
|
2916
|
+
Loading
|
|
2917
|
+
},
|
|
2918
|
+
props: {
|
|
2919
|
+
node: {
|
|
2920
|
+
type: Node,
|
|
2921
|
+
default: () => ({})
|
|
2922
|
+
},
|
|
2923
|
+
props: {
|
|
2924
|
+
type: Object,
|
|
2925
|
+
default: () => ({})
|
|
2926
|
+
},
|
|
2927
|
+
accordion: Boolean,
|
|
2928
|
+
renderContent: Function,
|
|
2929
|
+
renderAfterExpand: Boolean,
|
|
2930
|
+
showCheckbox: Boolean
|
|
2931
|
+
},
|
|
2932
|
+
emits: ["node-expand"],
|
|
2933
|
+
setup(props, ctx) {
|
|
2934
|
+
const ns = useNamespace("tree");
|
|
2935
|
+
const { broadcastExpanded } = useNodeExpandEventBroadcast(props);
|
|
2936
|
+
const tree = inject(ROOT_TREE_INJECTION_KEY);
|
|
2937
|
+
const expanded = ref(false);
|
|
2938
|
+
const childNodeRendered = ref(false);
|
|
2939
|
+
const oldChecked = ref();
|
|
2940
|
+
const oldIndeterminate = ref();
|
|
2941
|
+
const node$ = ref();
|
|
2942
|
+
const dragEvents = inject(dragEventsKey);
|
|
2943
|
+
const instance = getCurrentInstance();
|
|
2944
|
+
provide(NODE_INSTANCE_INJECTION_KEY, instance);
|
|
2945
|
+
if (!tree) {
|
|
2946
|
+
debugWarn("Tree", "Can not find node's tree.");
|
|
2947
|
+
}
|
|
2948
|
+
if (props.node.expanded) {
|
|
2949
|
+
expanded.value = true;
|
|
2950
|
+
childNodeRendered.value = true;
|
|
2951
|
+
}
|
|
2952
|
+
const childrenKey = tree.props.props["children"] || "children";
|
|
2953
|
+
watch(() => {
|
|
2954
|
+
var _a;
|
|
2955
|
+
const children = (_a = props.node.data) == null ? void 0 : _a[childrenKey];
|
|
2956
|
+
return children && [...children];
|
|
2957
|
+
}, () => {
|
|
2958
|
+
props.node.updateChildren();
|
|
2959
|
+
});
|
|
2960
|
+
watch(() => props.node.indeterminate, (val) => {
|
|
2961
|
+
handleSelectChange(props.node.checked, val);
|
|
2962
|
+
});
|
|
2963
|
+
watch(() => props.node.checked, (val) => {
|
|
2964
|
+
handleSelectChange(val, props.node.indeterminate);
|
|
2965
|
+
});
|
|
2966
|
+
watch(() => props.node.childNodes.length, () => props.node.reInitChecked());
|
|
2967
|
+
watch(() => props.node.expanded, (val) => {
|
|
2968
|
+
nextTick(() => expanded.value = val);
|
|
2969
|
+
if (val) {
|
|
2970
|
+
childNodeRendered.value = true;
|
|
2971
|
+
}
|
|
2972
|
+
});
|
|
2973
|
+
const getNodeKey$1 = (node) => {
|
|
2974
|
+
return getNodeKey(tree.props.nodeKey, node.data);
|
|
2975
|
+
};
|
|
2976
|
+
const getNodeClass = (node) => {
|
|
2977
|
+
const nodeClassFunc = props.props.class;
|
|
2978
|
+
if (!nodeClassFunc) {
|
|
2979
|
+
return {};
|
|
2980
|
+
}
|
|
2981
|
+
let className;
|
|
2982
|
+
if (isFunction(nodeClassFunc)) {
|
|
2983
|
+
const { data } = node;
|
|
2984
|
+
className = nodeClassFunc(data, node);
|
|
2985
|
+
} else {
|
|
2986
|
+
className = nodeClassFunc;
|
|
2987
|
+
}
|
|
2988
|
+
if (isString(className)) {
|
|
2989
|
+
return { [className]: true };
|
|
2990
|
+
} else {
|
|
2991
|
+
return className;
|
|
2992
|
+
}
|
|
2993
|
+
};
|
|
2994
|
+
const handleSelectChange = (checked, indeterminate) => {
|
|
2995
|
+
if (oldChecked.value !== checked || oldIndeterminate.value !== indeterminate) {
|
|
2996
|
+
tree.ctx.emit("check-change", props.node.data, checked, indeterminate);
|
|
2997
|
+
}
|
|
2998
|
+
oldChecked.value = checked;
|
|
2999
|
+
oldIndeterminate.value = indeterminate;
|
|
3000
|
+
};
|
|
3001
|
+
const handleClick = (e) => {
|
|
3002
|
+
handleCurrentChange(tree.store, tree.ctx.emit, () => {
|
|
3003
|
+
var _a;
|
|
3004
|
+
const nodeKeyProp = (_a = tree == null ? void 0 : tree.props) == null ? void 0 : _a.nodeKey;
|
|
3005
|
+
if (nodeKeyProp) {
|
|
3006
|
+
const curNodeKey = getNodeKey$1(props.node);
|
|
3007
|
+
tree.store.value.setCurrentNodeKey(curNodeKey);
|
|
3008
|
+
} else {
|
|
3009
|
+
tree.store.value.setCurrentNode(props.node);
|
|
3010
|
+
}
|
|
3011
|
+
});
|
|
3012
|
+
tree.currentNode.value = props.node;
|
|
3013
|
+
if (tree.props.expandOnClickNode) {
|
|
3014
|
+
handleExpandIconClick();
|
|
3015
|
+
}
|
|
3016
|
+
if ((tree.props.checkOnClickNode || props.node.isLeaf && tree.props.checkOnClickLeaf && props.showCheckbox) && !props.node.disabled) {
|
|
3017
|
+
handleCheckChange(!props.node.checked);
|
|
3018
|
+
}
|
|
3019
|
+
tree.ctx.emit("node-click", props.node.data, props.node, instance, e);
|
|
3020
|
+
};
|
|
3021
|
+
const handleContextMenu = (event) => {
|
|
3022
|
+
var _a;
|
|
3023
|
+
if ((_a = tree.instance.vnode.props) == null ? void 0 : _a["onNodeContextmenu"]) {
|
|
3024
|
+
event.stopPropagation();
|
|
3025
|
+
event.preventDefault();
|
|
3026
|
+
}
|
|
3027
|
+
tree.ctx.emit("node-contextmenu", event, props.node.data, props.node, instance);
|
|
3028
|
+
};
|
|
3029
|
+
const handleExpandIconClick = () => {
|
|
3030
|
+
if (props.node.isLeaf)
|
|
3031
|
+
return;
|
|
3032
|
+
if (expanded.value) {
|
|
3033
|
+
tree.ctx.emit("node-collapse", props.node.data, props.node, instance);
|
|
3034
|
+
props.node.collapse();
|
|
3035
|
+
} else {
|
|
3036
|
+
props.node.expand(() => {
|
|
3037
|
+
ctx.emit("node-expand", props.node.data, props.node, instance);
|
|
3038
|
+
});
|
|
3039
|
+
}
|
|
3040
|
+
};
|
|
3041
|
+
const handleCheckChange = (value) => {
|
|
3042
|
+
const checkStrictly = tree == null ? void 0 : tree.props.checkStrictly;
|
|
3043
|
+
const childNodes = props.node.childNodes;
|
|
3044
|
+
if (!checkStrictly && childNodes.length) {
|
|
3045
|
+
value = childNodes.some((node) => !node.isEffectivelyChecked);
|
|
3046
|
+
}
|
|
3047
|
+
props.node.setChecked(value, !checkStrictly);
|
|
3048
|
+
nextTick(() => {
|
|
3049
|
+
const store = tree.store.value;
|
|
3050
|
+
tree.ctx.emit("check", props.node.data, {
|
|
3051
|
+
checkedNodes: store.getCheckedNodes(),
|
|
3052
|
+
checkedKeys: store.getCheckedKeys(),
|
|
3053
|
+
halfCheckedNodes: store.getHalfCheckedNodes(),
|
|
3054
|
+
halfCheckedKeys: store.getHalfCheckedKeys()
|
|
3055
|
+
});
|
|
3056
|
+
});
|
|
3057
|
+
};
|
|
3058
|
+
const handleChildNodeExpand = (nodeData, node, instance2) => {
|
|
3059
|
+
broadcastExpanded(node);
|
|
3060
|
+
tree.ctx.emit("node-expand", nodeData, node, instance2);
|
|
3061
|
+
};
|
|
3062
|
+
const handleDragStart = (event) => {
|
|
3063
|
+
if (!tree.props.draggable)
|
|
3064
|
+
return;
|
|
3065
|
+
dragEvents.treeNodeDragStart({ event, treeNode: props });
|
|
3066
|
+
};
|
|
3067
|
+
const handleDragOver = (event) => {
|
|
3068
|
+
event.preventDefault();
|
|
3069
|
+
if (!tree.props.draggable)
|
|
3070
|
+
return;
|
|
3071
|
+
dragEvents.treeNodeDragOver({
|
|
3072
|
+
event,
|
|
3073
|
+
treeNode: { $el: node$.value, node: props.node }
|
|
3074
|
+
});
|
|
3075
|
+
};
|
|
3076
|
+
const handleDrop = (event) => {
|
|
3077
|
+
event.preventDefault();
|
|
3078
|
+
};
|
|
3079
|
+
const handleDragEnd = (event) => {
|
|
3080
|
+
if (!tree.props.draggable)
|
|
3081
|
+
return;
|
|
3082
|
+
dragEvents.treeNodeDragEnd(event);
|
|
3083
|
+
};
|
|
3084
|
+
return {
|
|
3085
|
+
ns,
|
|
3086
|
+
node$,
|
|
3087
|
+
tree,
|
|
3088
|
+
expanded,
|
|
3089
|
+
childNodeRendered,
|
|
3090
|
+
oldChecked,
|
|
3091
|
+
oldIndeterminate,
|
|
3092
|
+
getNodeKey: getNodeKey$1,
|
|
3093
|
+
getNodeClass,
|
|
3094
|
+
handleSelectChange,
|
|
3095
|
+
handleClick,
|
|
3096
|
+
handleContextMenu,
|
|
3097
|
+
handleExpandIconClick,
|
|
3098
|
+
handleCheckChange,
|
|
3099
|
+
handleChildNodeExpand,
|
|
3100
|
+
handleDragStart,
|
|
3101
|
+
handleDragOver,
|
|
3102
|
+
handleDrop,
|
|
3103
|
+
handleDragEnd,
|
|
3104
|
+
CaretRight
|
|
3105
|
+
};
|
|
3106
|
+
}
|
|
3107
|
+
});
|
|
3108
|
+
function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3109
|
+
const _component_el_icon = resolveComponent("el-icon");
|
|
3110
|
+
const _component_el_checkbox = resolveComponent("el-checkbox");
|
|
3111
|
+
const _component_loading = resolveComponent("loading");
|
|
3112
|
+
const _component_node_content = resolveComponent("node-content");
|
|
3113
|
+
const _component_el_tree_node = resolveComponent("el-tree-node");
|
|
3114
|
+
const _component_el_collapse_transition = resolveComponent("el-collapse-transition");
|
|
3115
|
+
return withDirectives((openBlock(), createElementBlock("div", {
|
|
3116
|
+
ref: "node$",
|
|
3117
|
+
class: normalizeClass([
|
|
3118
|
+
_ctx.ns.b("node"),
|
|
3119
|
+
_ctx.ns.is("expanded", _ctx.expanded),
|
|
3120
|
+
_ctx.ns.is("current", _ctx.node.isCurrent),
|
|
3121
|
+
_ctx.ns.is("hidden", !_ctx.node.visible),
|
|
3122
|
+
_ctx.ns.is("focusable", !_ctx.node.disabled),
|
|
3123
|
+
_ctx.ns.is("checked", !_ctx.node.disabled && _ctx.node.checked),
|
|
3124
|
+
_ctx.getNodeClass(_ctx.node)
|
|
3125
|
+
]),
|
|
3126
|
+
role: "treeitem",
|
|
3127
|
+
tabindex: "-1",
|
|
3128
|
+
"aria-expanded": _ctx.expanded,
|
|
3129
|
+
"aria-disabled": _ctx.node.disabled,
|
|
3130
|
+
"aria-checked": _ctx.node.checked,
|
|
3131
|
+
draggable: _ctx.tree.props.draggable,
|
|
3132
|
+
"data-key": _ctx.getNodeKey(_ctx.node),
|
|
3133
|
+
onClick: withModifiers(_ctx.handleClick, ["stop"]),
|
|
3134
|
+
onContextmenu: _ctx.handleContextMenu,
|
|
3135
|
+
onDragstart: withModifiers(_ctx.handleDragStart, ["stop"]),
|
|
3136
|
+
onDragover: withModifiers(_ctx.handleDragOver, ["stop"]),
|
|
3137
|
+
onDragend: withModifiers(_ctx.handleDragEnd, ["stop"]),
|
|
3138
|
+
onDrop: withModifiers(_ctx.handleDrop, ["stop"])
|
|
3139
|
+
}, [
|
|
3140
|
+
createElementVNode("div", {
|
|
3141
|
+
class: normalizeClass(_ctx.ns.be("node", "content")),
|
|
3142
|
+
style: normalizeStyle({ paddingLeft: (_ctx.node.level - 1) * _ctx.tree.props.indent + "px" })
|
|
3143
|
+
}, [
|
|
3144
|
+
_ctx.tree.props.icon || _ctx.CaretRight ? (openBlock(), createBlock(_component_el_icon, {
|
|
3145
|
+
key: 0,
|
|
3146
|
+
class: normalizeClass([
|
|
3147
|
+
_ctx.ns.be("node", "expand-icon"),
|
|
3148
|
+
_ctx.ns.is("leaf", _ctx.node.isLeaf),
|
|
3149
|
+
{
|
|
3150
|
+
expanded: !_ctx.node.isLeaf && _ctx.expanded
|
|
3151
|
+
}
|
|
3152
|
+
]),
|
|
3153
|
+
onClick: withModifiers(_ctx.handleExpandIconClick, ["stop"])
|
|
3154
|
+
}, {
|
|
3155
|
+
default: withCtx(() => [
|
|
3156
|
+
(openBlock(), createBlock(resolveDynamicComponent(_ctx.tree.props.icon || _ctx.CaretRight)))
|
|
3157
|
+
]),
|
|
3158
|
+
_: 1
|
|
3159
|
+
}, 8, ["class", "onClick"])) : createCommentVNode("v-if", true),
|
|
3160
|
+
_ctx.showCheckbox ? (openBlock(), createBlock(_component_el_checkbox, {
|
|
3161
|
+
key: 1,
|
|
3162
|
+
"model-value": _ctx.node.checked,
|
|
3163
|
+
indeterminate: _ctx.node.indeterminate,
|
|
3164
|
+
disabled: !!_ctx.node.disabled,
|
|
3165
|
+
onClick: withModifiers(() => {
|
|
3166
|
+
}, ["stop"]),
|
|
3167
|
+
onChange: _ctx.handleCheckChange
|
|
3168
|
+
}, null, 8, ["model-value", "indeterminate", "disabled", "onClick", "onChange"])) : createCommentVNode("v-if", true),
|
|
3169
|
+
_ctx.node.loading ? (openBlock(), createBlock(_component_el_icon, {
|
|
3170
|
+
key: 2,
|
|
3171
|
+
class: normalizeClass([_ctx.ns.be("node", "loading-icon"), _ctx.ns.is("loading")])
|
|
3172
|
+
}, {
|
|
3173
|
+
default: withCtx(() => [
|
|
3174
|
+
createVNode(_component_loading)
|
|
3175
|
+
]),
|
|
3176
|
+
_: 1
|
|
3177
|
+
}, 8, ["class"])) : createCommentVNode("v-if", true),
|
|
3178
|
+
createVNode(_component_node_content, {
|
|
3179
|
+
node: _ctx.node,
|
|
3180
|
+
"render-content": _ctx.renderContent
|
|
3181
|
+
}, null, 8, ["node", "render-content"])
|
|
3182
|
+
], 6),
|
|
3183
|
+
createVNode(_component_el_collapse_transition, null, {
|
|
3184
|
+
default: withCtx(() => [
|
|
3185
|
+
!_ctx.renderAfterExpand || _ctx.childNodeRendered ? withDirectives((openBlock(), createElementBlock("div", {
|
|
3186
|
+
key: 0,
|
|
3187
|
+
class: normalizeClass(_ctx.ns.be("node", "children")),
|
|
3188
|
+
role: "group",
|
|
3189
|
+
"aria-expanded": _ctx.expanded,
|
|
3190
|
+
onClick: withModifiers(() => {
|
|
3191
|
+
}, ["stop"])
|
|
3192
|
+
}, [
|
|
3193
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.node.childNodes, (child) => {
|
|
3194
|
+
return openBlock(), createBlock(_component_el_tree_node, {
|
|
3195
|
+
key: _ctx.getNodeKey(child),
|
|
3196
|
+
"render-content": _ctx.renderContent,
|
|
3197
|
+
"render-after-expand": _ctx.renderAfterExpand,
|
|
3198
|
+
"show-checkbox": _ctx.showCheckbox,
|
|
3199
|
+
node: child,
|
|
3200
|
+
accordion: _ctx.accordion,
|
|
3201
|
+
props: _ctx.props,
|
|
3202
|
+
onNodeExpand: _ctx.handleChildNodeExpand
|
|
3203
|
+
}, null, 8, ["render-content", "render-after-expand", "show-checkbox", "node", "accordion", "props", "onNodeExpand"]);
|
|
3204
|
+
}), 128))
|
|
3205
|
+
], 10, ["aria-expanded", "onClick"])), [
|
|
3206
|
+
[vShow, _ctx.expanded]
|
|
3207
|
+
]) : createCommentVNode("v-if", true)
|
|
3208
|
+
]),
|
|
3209
|
+
_: 1
|
|
3210
|
+
})
|
|
3211
|
+
], 42, ["aria-expanded", "aria-disabled", "aria-checked", "draggable", "data-key", "onClick", "onContextmenu", "onDragstart", "onDragover", "onDragend", "onDrop"])), [
|
|
3212
|
+
[vShow, _ctx.node.visible]
|
|
3213
|
+
]);
|
|
3214
|
+
}
|
|
3215
|
+
var ElTreeNode = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["render", _sfc_render$1], ["__file", "tree-node.vue"]]);
|
|
3216
|
+
|
|
3217
|
+
function useKeydown({ el$ }, store) {
|
|
3218
|
+
const ns = useNamespace("tree");
|
|
3219
|
+
onMounted(() => {
|
|
3220
|
+
initTabIndex();
|
|
3221
|
+
});
|
|
3222
|
+
onUpdated(() => {
|
|
3223
|
+
const checkboxItems = Array.from(el$.value.querySelectorAll("input[type=checkbox]"));
|
|
3224
|
+
checkboxItems.forEach((checkbox) => {
|
|
3225
|
+
checkbox.setAttribute("tabindex", "-1");
|
|
3226
|
+
});
|
|
3227
|
+
});
|
|
3228
|
+
function canNodeFocus(treeItems, nextIndex) {
|
|
3229
|
+
var _a, _b;
|
|
3230
|
+
const currentNode = store.value.getNode(treeItems[nextIndex].dataset.key);
|
|
3231
|
+
return currentNode.canFocus && currentNode.visible && (((_a = currentNode.parent) == null ? void 0 : _a.expanded) || ((_b = currentNode.parent) == null ? void 0 : _b.level) === 0);
|
|
3232
|
+
}
|
|
3233
|
+
const handleKeydown = (ev) => {
|
|
3234
|
+
const currentItem = ev.target;
|
|
3235
|
+
if (!currentItem.className.includes(ns.b("node")))
|
|
3236
|
+
return;
|
|
3237
|
+
const code = getEventCode(ev);
|
|
3238
|
+
const treeItems = Array.from(el$.value.querySelectorAll(`.${ns.is("focusable")}[role=treeitem]`));
|
|
3239
|
+
const currentIndex = treeItems.indexOf(currentItem);
|
|
3240
|
+
let nextIndex;
|
|
3241
|
+
if ([EVENT_CODE.up, EVENT_CODE.down].includes(code)) {
|
|
3242
|
+
ev.preventDefault();
|
|
3243
|
+
if (code === EVENT_CODE.up) {
|
|
3244
|
+
nextIndex = currentIndex === -1 ? 0 : currentIndex !== 0 ? currentIndex - 1 : treeItems.length - 1;
|
|
3245
|
+
const startIndex = nextIndex;
|
|
3246
|
+
while (true) {
|
|
3247
|
+
if (canNodeFocus(treeItems, nextIndex)) {
|
|
3248
|
+
break;
|
|
3249
|
+
}
|
|
3250
|
+
nextIndex--;
|
|
3251
|
+
if (nextIndex === startIndex) {
|
|
3252
|
+
nextIndex = -1;
|
|
3253
|
+
break;
|
|
3254
|
+
}
|
|
3255
|
+
if (nextIndex < 0) {
|
|
3256
|
+
nextIndex = treeItems.length - 1;
|
|
3257
|
+
}
|
|
3258
|
+
}
|
|
3259
|
+
} else {
|
|
3260
|
+
nextIndex = currentIndex === -1 ? 0 : currentIndex < treeItems.length - 1 ? currentIndex + 1 : 0;
|
|
3261
|
+
const startIndex = nextIndex;
|
|
3262
|
+
while (true) {
|
|
3263
|
+
if (canNodeFocus(treeItems, nextIndex)) {
|
|
3264
|
+
break;
|
|
3265
|
+
}
|
|
3266
|
+
nextIndex++;
|
|
3267
|
+
if (nextIndex === startIndex) {
|
|
3268
|
+
nextIndex = -1;
|
|
3269
|
+
break;
|
|
3270
|
+
}
|
|
3271
|
+
if (nextIndex >= treeItems.length) {
|
|
3272
|
+
nextIndex = 0;
|
|
3273
|
+
}
|
|
3274
|
+
}
|
|
3275
|
+
}
|
|
3276
|
+
nextIndex !== -1 && treeItems[nextIndex].focus();
|
|
3277
|
+
}
|
|
3278
|
+
if ([EVENT_CODE.left, EVENT_CODE.right].includes(code)) {
|
|
3279
|
+
ev.preventDefault();
|
|
3280
|
+
currentItem.click();
|
|
3281
|
+
}
|
|
3282
|
+
const hasInput = currentItem.querySelector('[type="checkbox"]');
|
|
3283
|
+
if ([EVENT_CODE.enter, EVENT_CODE.numpadEnter, EVENT_CODE.space].includes(code) && hasInput) {
|
|
3284
|
+
ev.preventDefault();
|
|
3285
|
+
hasInput.click();
|
|
3286
|
+
}
|
|
3287
|
+
};
|
|
3288
|
+
useEventListener(el$, "keydown", handleKeydown);
|
|
3289
|
+
const initTabIndex = () => {
|
|
3290
|
+
var _a;
|
|
3291
|
+
if (!el$.value)
|
|
3292
|
+
return;
|
|
3293
|
+
const treeItems = Array.from(el$.value.querySelectorAll(`.${ns.is("focusable")}[role=treeitem]`));
|
|
3294
|
+
const checkboxItems = Array.from(el$.value.querySelectorAll("input[type=checkbox]"));
|
|
3295
|
+
checkboxItems.forEach((checkbox) => {
|
|
3296
|
+
checkbox.setAttribute("tabindex", "-1");
|
|
3297
|
+
});
|
|
3298
|
+
const checkedItem = el$.value.querySelectorAll(`.${ns.is("checked")}[role=treeitem]`);
|
|
3299
|
+
if (checkedItem.length) {
|
|
3300
|
+
checkedItem[0].setAttribute("tabindex", "0");
|
|
3301
|
+
return;
|
|
3302
|
+
}
|
|
3303
|
+
(_a = treeItems[0]) == null ? void 0 : _a.setAttribute("tabindex", "0");
|
|
3304
|
+
};
|
|
3305
|
+
}
|
|
3306
|
+
|
|
3307
|
+
const treeEmits = {
|
|
3308
|
+
"check-change": (data, checked, indeterminate) => data && isBoolean(checked) && isBoolean(indeterminate),
|
|
3309
|
+
"current-change": (data, node) => true,
|
|
3310
|
+
"node-click": (data, node, nodeInstance, evt) => data && node && evt instanceof Event,
|
|
3311
|
+
"node-contextmenu": (evt, data, node, nodeInstance) => evt instanceof Event && data && node,
|
|
3312
|
+
"node-collapse": (data, node, nodeInstance) => data && node,
|
|
3313
|
+
"node-expand": (data, node, nodeInstance) => data && node,
|
|
3314
|
+
check: (data, checkedInfo) => data && checkedInfo,
|
|
3315
|
+
"node-drag-start": (node, evt) => node && evt,
|
|
3316
|
+
"node-drag-end": (draggingNode, dropNode, dropType, evt) => draggingNode && evt,
|
|
3317
|
+
"node-drop": (draggingNode, dropNode, dropType, evt) => draggingNode && dropNode && evt,
|
|
3318
|
+
"node-drag-leave": (draggingNode, oldDropNode, evt) => draggingNode && oldDropNode && evt,
|
|
3319
|
+
"node-drag-enter": (draggingNode, dropNode, evt) => draggingNode && dropNode && evt,
|
|
3320
|
+
"node-drag-over": (draggingNode, dropNode, evt) => draggingNode && dropNode && evt
|
|
3321
|
+
};
|
|
3322
|
+
|
|
3323
|
+
const _sfc_main$1 = defineComponent({
|
|
3324
|
+
name: "ElTree",
|
|
3325
|
+
components: { ElTreeNode },
|
|
3326
|
+
props: {
|
|
3327
|
+
data: {
|
|
3328
|
+
type: definePropType(Array),
|
|
3329
|
+
default: () => []
|
|
3330
|
+
},
|
|
3331
|
+
emptyText: {
|
|
3332
|
+
type: String
|
|
3333
|
+
},
|
|
3334
|
+
renderAfterExpand: {
|
|
3335
|
+
type: Boolean,
|
|
3336
|
+
default: true
|
|
3337
|
+
},
|
|
3338
|
+
nodeKey: String,
|
|
3339
|
+
checkStrictly: Boolean,
|
|
3340
|
+
defaultExpandAll: Boolean,
|
|
3341
|
+
expandOnClickNode: {
|
|
3342
|
+
type: Boolean,
|
|
3343
|
+
default: true
|
|
3344
|
+
},
|
|
3345
|
+
checkOnClickNode: Boolean,
|
|
3346
|
+
checkOnClickLeaf: {
|
|
3347
|
+
type: Boolean,
|
|
3348
|
+
default: true
|
|
3349
|
+
},
|
|
3350
|
+
checkDescendants: Boolean,
|
|
3351
|
+
autoExpandParent: {
|
|
3352
|
+
type: Boolean,
|
|
3353
|
+
default: true
|
|
3354
|
+
},
|
|
3355
|
+
defaultCheckedKeys: Array,
|
|
3356
|
+
defaultExpandedKeys: Array,
|
|
3357
|
+
currentNodeKey: [String, Number],
|
|
3358
|
+
renderContent: {
|
|
3359
|
+
type: definePropType(Function)
|
|
3360
|
+
},
|
|
3361
|
+
showCheckbox: Boolean,
|
|
3362
|
+
draggable: Boolean,
|
|
3363
|
+
allowDrag: {
|
|
3364
|
+
type: definePropType(Function)
|
|
3365
|
+
},
|
|
3366
|
+
allowDrop: {
|
|
3367
|
+
type: definePropType(Function)
|
|
3368
|
+
},
|
|
3369
|
+
props: {
|
|
3370
|
+
type: Object,
|
|
3371
|
+
default: () => ({
|
|
3372
|
+
children: "children",
|
|
3373
|
+
label: "label",
|
|
3374
|
+
disabled: "disabled"
|
|
3375
|
+
})
|
|
3376
|
+
},
|
|
3377
|
+
lazy: Boolean,
|
|
3378
|
+
highlightCurrent: Boolean,
|
|
3379
|
+
load: Function,
|
|
3380
|
+
filterNodeMethod: Function,
|
|
3381
|
+
accordion: Boolean,
|
|
3382
|
+
indent: {
|
|
3383
|
+
type: Number,
|
|
3384
|
+
default: 18
|
|
3385
|
+
},
|
|
3386
|
+
icon: {
|
|
3387
|
+
type: iconPropType
|
|
3388
|
+
}
|
|
3389
|
+
},
|
|
3390
|
+
emits: treeEmits,
|
|
3391
|
+
setup(props, ctx) {
|
|
3392
|
+
const { t } = useLocale();
|
|
3393
|
+
const ns = useNamespace("tree");
|
|
3394
|
+
const store = ref(new TreeStore({
|
|
3395
|
+
key: props.nodeKey,
|
|
3396
|
+
data: props.data,
|
|
3397
|
+
lazy: props.lazy,
|
|
3398
|
+
props: props.props,
|
|
3399
|
+
load: props.load,
|
|
3400
|
+
currentNodeKey: props.currentNodeKey,
|
|
3401
|
+
checkStrictly: props.checkStrictly,
|
|
3402
|
+
checkDescendants: props.checkDescendants,
|
|
3403
|
+
defaultCheckedKeys: props.defaultCheckedKeys,
|
|
3404
|
+
defaultExpandedKeys: props.defaultExpandedKeys,
|
|
3405
|
+
autoExpandParent: props.autoExpandParent,
|
|
3406
|
+
defaultExpandAll: props.defaultExpandAll,
|
|
3407
|
+
filterNodeMethod: props.filterNodeMethod
|
|
3408
|
+
}));
|
|
3409
|
+
store.value.initialize();
|
|
3410
|
+
const root = ref(store.value.root);
|
|
3411
|
+
const currentNode = ref(null);
|
|
3412
|
+
const el$ = ref(null);
|
|
3413
|
+
const dropIndicator$ = ref(null);
|
|
3414
|
+
const { broadcastExpanded } = useNodeExpandEventBroadcast(props);
|
|
3415
|
+
const { dragState } = useDragNodeHandler({
|
|
3416
|
+
props,
|
|
3417
|
+
ctx,
|
|
3418
|
+
el$,
|
|
3419
|
+
dropIndicator$,
|
|
3420
|
+
store
|
|
3421
|
+
});
|
|
3422
|
+
useKeydown({ el$ }, store);
|
|
3423
|
+
const instance = getCurrentInstance();
|
|
3424
|
+
const isSelectTree = computed(() => {
|
|
3425
|
+
let parent = instance == null ? void 0 : instance.parent;
|
|
3426
|
+
while (parent) {
|
|
3427
|
+
if (parent.type.name === "ElTreeSelect") {
|
|
3428
|
+
return true;
|
|
3429
|
+
}
|
|
3430
|
+
parent = parent.parent;
|
|
3431
|
+
}
|
|
3432
|
+
return false;
|
|
3433
|
+
});
|
|
3434
|
+
const isEmpty = computed(() => {
|
|
3435
|
+
const { childNodes } = root.value;
|
|
3436
|
+
return (!childNodes || childNodes.length === 0 || childNodes.every(({ visible }) => !visible)) && !isSelectTree.value;
|
|
3437
|
+
});
|
|
3438
|
+
watch(() => props.currentNodeKey, (newVal) => {
|
|
3439
|
+
store.value.setCurrentNodeKey(newVal != null ? newVal : null);
|
|
3440
|
+
});
|
|
3441
|
+
watch(() => props.defaultCheckedKeys, (newVal, oldVal) => {
|
|
3442
|
+
if (isEqual(newVal, oldVal))
|
|
3443
|
+
return;
|
|
3444
|
+
store.value.setDefaultCheckedKey(newVal != null ? newVal : []);
|
|
3445
|
+
});
|
|
3446
|
+
watch(() => props.defaultExpandedKeys, (newVal) => {
|
|
3447
|
+
store.value.setDefaultExpandedKeys(newVal != null ? newVal : []);
|
|
3448
|
+
});
|
|
3449
|
+
watch(() => props.data, (newVal) => {
|
|
3450
|
+
store.value.setData(newVal);
|
|
3451
|
+
}, { deep: true });
|
|
3452
|
+
watch(() => props.checkStrictly, (newVal) => {
|
|
3453
|
+
store.value.checkStrictly = newVal;
|
|
3454
|
+
});
|
|
3455
|
+
const filter = (value) => {
|
|
3456
|
+
if (!props.filterNodeMethod)
|
|
3457
|
+
throw new Error("[Tree] filterNodeMethod is required when filter");
|
|
3458
|
+
store.value.filter(value);
|
|
3459
|
+
};
|
|
3460
|
+
const getNodeKey$1 = (node) => {
|
|
3461
|
+
return getNodeKey(props.nodeKey, node.data);
|
|
3462
|
+
};
|
|
3463
|
+
const requireNodeKey = (methodName) => {
|
|
3464
|
+
if (!props.nodeKey) {
|
|
3465
|
+
throw new Error(`[Tree] nodeKey is required in ${methodName}`);
|
|
3466
|
+
}
|
|
3467
|
+
};
|
|
3468
|
+
const getNodePath = (data) => {
|
|
3469
|
+
requireNodeKey("getNodePath");
|
|
3470
|
+
const node = store.value.getNode(data);
|
|
3471
|
+
if (!node)
|
|
3472
|
+
return [];
|
|
3473
|
+
const path = [node.data];
|
|
3474
|
+
let parent = node.parent;
|
|
3475
|
+
while (parent && parent !== root.value) {
|
|
3476
|
+
path.push(parent.data);
|
|
3477
|
+
parent = parent.parent;
|
|
3478
|
+
}
|
|
3479
|
+
return path.reverse();
|
|
3480
|
+
};
|
|
3481
|
+
const getCheckedNodes = (leafOnly, includeHalfChecked) => {
|
|
3482
|
+
return store.value.getCheckedNodes(leafOnly, includeHalfChecked);
|
|
3483
|
+
};
|
|
3484
|
+
const getCheckedKeys = (leafOnly) => {
|
|
3485
|
+
return store.value.getCheckedKeys(leafOnly);
|
|
3486
|
+
};
|
|
3487
|
+
const getCurrentNode = () => {
|
|
3488
|
+
const currentNode2 = store.value.getCurrentNode();
|
|
3489
|
+
return currentNode2 ? currentNode2.data : null;
|
|
3490
|
+
};
|
|
3491
|
+
const getCurrentKey = () => {
|
|
3492
|
+
requireNodeKey("getCurrentKey");
|
|
3493
|
+
const currentNode2 = getCurrentNode();
|
|
3494
|
+
return currentNode2 ? currentNode2[props.nodeKey] : null;
|
|
3495
|
+
};
|
|
3496
|
+
const setCheckedNodes = (nodes, leafOnly) => {
|
|
3497
|
+
requireNodeKey("setCheckedNodes");
|
|
3498
|
+
store.value.setCheckedNodes(nodes, leafOnly);
|
|
3499
|
+
};
|
|
3500
|
+
const setCheckedKeys = (keys, leafOnly) => {
|
|
3501
|
+
requireNodeKey("setCheckedKeys");
|
|
3502
|
+
store.value.setCheckedKeys(keys, leafOnly);
|
|
3503
|
+
};
|
|
3504
|
+
const setChecked = (data, checked, deep) => {
|
|
3505
|
+
store.value.setChecked(data, checked, deep);
|
|
3506
|
+
};
|
|
3507
|
+
const getHalfCheckedNodes = () => {
|
|
3508
|
+
return store.value.getHalfCheckedNodes();
|
|
3509
|
+
};
|
|
3510
|
+
const getHalfCheckedKeys = () => {
|
|
3511
|
+
return store.value.getHalfCheckedKeys();
|
|
3512
|
+
};
|
|
3513
|
+
const setCurrentNode = (node, shouldAutoExpandParent = true) => {
|
|
3514
|
+
requireNodeKey("setCurrentNode");
|
|
3515
|
+
handleCurrentChange(store, ctx.emit, () => {
|
|
3516
|
+
broadcastExpanded(node);
|
|
3517
|
+
store.value.setUserCurrentNode(node, shouldAutoExpandParent);
|
|
3518
|
+
});
|
|
3519
|
+
};
|
|
3520
|
+
const setCurrentKey = (key = null, shouldAutoExpandParent = true) => {
|
|
3521
|
+
requireNodeKey("setCurrentKey");
|
|
3522
|
+
handleCurrentChange(store, ctx.emit, () => {
|
|
3523
|
+
broadcastExpanded();
|
|
3524
|
+
store.value.setCurrentNodeKey(key, shouldAutoExpandParent);
|
|
3525
|
+
});
|
|
3526
|
+
};
|
|
3527
|
+
const getNode = (data) => {
|
|
3528
|
+
return store.value.getNode(data);
|
|
3529
|
+
};
|
|
3530
|
+
const remove = (data) => {
|
|
3531
|
+
store.value.remove(data);
|
|
3532
|
+
};
|
|
3533
|
+
const append = (data, parentNode) => {
|
|
3534
|
+
store.value.append(data, parentNode);
|
|
3535
|
+
};
|
|
3536
|
+
const insertBefore = (data, refNode) => {
|
|
3537
|
+
store.value.insertBefore(data, refNode);
|
|
3538
|
+
};
|
|
3539
|
+
const insertAfter = (data, refNode) => {
|
|
3540
|
+
store.value.insertAfter(data, refNode);
|
|
3541
|
+
};
|
|
3542
|
+
const handleNodeExpand = (nodeData, node, instance2) => {
|
|
3543
|
+
broadcastExpanded(node);
|
|
3544
|
+
ctx.emit("node-expand", nodeData, node, instance2);
|
|
3545
|
+
};
|
|
3546
|
+
const updateKeyChildren = (key, data) => {
|
|
3547
|
+
requireNodeKey("updateKeyChild");
|
|
3548
|
+
store.value.updateChildren(key, data);
|
|
3549
|
+
};
|
|
3550
|
+
provide(ROOT_TREE_INJECTION_KEY, {
|
|
3551
|
+
ctx,
|
|
3552
|
+
props,
|
|
3553
|
+
store,
|
|
3554
|
+
root,
|
|
3555
|
+
currentNode,
|
|
3556
|
+
instance
|
|
3557
|
+
});
|
|
3558
|
+
provide(formItemContextKey, void 0);
|
|
3559
|
+
return {
|
|
3560
|
+
ns,
|
|
3561
|
+
store,
|
|
3562
|
+
root,
|
|
3563
|
+
currentNode,
|
|
3564
|
+
dragState,
|
|
3565
|
+
el$,
|
|
3566
|
+
dropIndicator$,
|
|
3567
|
+
isEmpty,
|
|
3568
|
+
filter,
|
|
3569
|
+
getNodeKey: getNodeKey$1,
|
|
3570
|
+
getNodePath,
|
|
3571
|
+
getCheckedNodes,
|
|
3572
|
+
getCheckedKeys,
|
|
3573
|
+
getCurrentNode,
|
|
3574
|
+
getCurrentKey,
|
|
3575
|
+
setCheckedNodes,
|
|
3576
|
+
setCheckedKeys,
|
|
3577
|
+
setChecked,
|
|
3578
|
+
getHalfCheckedNodes,
|
|
3579
|
+
getHalfCheckedKeys,
|
|
3580
|
+
setCurrentNode,
|
|
3581
|
+
setCurrentKey,
|
|
3582
|
+
t,
|
|
3583
|
+
getNode,
|
|
3584
|
+
remove,
|
|
3585
|
+
append,
|
|
3586
|
+
insertBefore,
|
|
3587
|
+
insertAfter,
|
|
3588
|
+
handleNodeExpand,
|
|
3589
|
+
updateKeyChildren
|
|
3590
|
+
};
|
|
3591
|
+
}
|
|
3592
|
+
});
|
|
3593
|
+
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3594
|
+
const _component_el_tree_node = resolveComponent("el-tree-node");
|
|
3595
|
+
return openBlock(), createElementBlock("div", {
|
|
3596
|
+
ref: "el$",
|
|
3597
|
+
class: normalizeClass([
|
|
3598
|
+
_ctx.ns.b(),
|
|
3599
|
+
_ctx.ns.is("dragging", !!_ctx.dragState.draggingNode),
|
|
3600
|
+
_ctx.ns.is("drop-not-allow", !_ctx.dragState.allowDrop),
|
|
3601
|
+
_ctx.ns.is("drop-inner", _ctx.dragState.dropType === "inner"),
|
|
3602
|
+
{ [_ctx.ns.m("highlight-current")]: _ctx.highlightCurrent }
|
|
3603
|
+
]),
|
|
3604
|
+
role: "tree"
|
|
3605
|
+
}, [
|
|
3606
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.root.childNodes, (child) => {
|
|
3607
|
+
return openBlock(), createBlock(_component_el_tree_node, {
|
|
3608
|
+
key: _ctx.getNodeKey(child),
|
|
3609
|
+
node: child,
|
|
3610
|
+
props: _ctx.props,
|
|
3611
|
+
accordion: _ctx.accordion,
|
|
3612
|
+
"render-after-expand": _ctx.renderAfterExpand,
|
|
3613
|
+
"show-checkbox": _ctx.showCheckbox,
|
|
3614
|
+
"render-content": _ctx.renderContent,
|
|
3615
|
+
onNodeExpand: _ctx.handleNodeExpand
|
|
3616
|
+
}, null, 8, ["node", "props", "accordion", "render-after-expand", "show-checkbox", "render-content", "onNodeExpand"]);
|
|
3617
|
+
}), 128)),
|
|
3618
|
+
_ctx.isEmpty ? (openBlock(), createElementBlock("div", {
|
|
3619
|
+
key: 0,
|
|
3620
|
+
class: normalizeClass(_ctx.ns.e("empty-block"))
|
|
3621
|
+
}, [
|
|
3622
|
+
renderSlot(_ctx.$slots, "empty", {}, () => {
|
|
3623
|
+
var _a;
|
|
3624
|
+
return [
|
|
3625
|
+
createElementVNode("span", {
|
|
3626
|
+
class: normalizeClass(_ctx.ns.e("empty-text"))
|
|
3627
|
+
}, toDisplayString((_a = _ctx.emptyText) != null ? _a : _ctx.t("el.tree.emptyText")), 3)
|
|
3628
|
+
];
|
|
3629
|
+
})
|
|
3630
|
+
], 2)) : createCommentVNode("v-if", true),
|
|
3631
|
+
withDirectives(createElementVNode("div", {
|
|
3632
|
+
ref: "dropIndicator$",
|
|
3633
|
+
class: normalizeClass(_ctx.ns.e("drop-indicator"))
|
|
3634
|
+
}, null, 2), [
|
|
3635
|
+
[vShow, _ctx.dragState.showDropIndicator]
|
|
3636
|
+
])
|
|
3637
|
+
], 2);
|
|
3638
|
+
}
|
|
3639
|
+
var Tree = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render], ["__file", "tree.vue"]]);
|
|
3640
|
+
|
|
3641
|
+
const ElTree = withInstall(Tree);
|
|
3642
|
+
|
|
3643
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
3644
|
+
__name: "popover-cascader",
|
|
3645
|
+
props: {
|
|
3646
|
+
modelValue: {},
|
|
3647
|
+
multiple: { type: Boolean },
|
|
3648
|
+
emptyText: { default: "尚未选择" },
|
|
3649
|
+
props: {},
|
|
3650
|
+
options: {}
|
|
3651
|
+
},
|
|
3652
|
+
emits: ["update:modelValue", "change", "expandChange", "choiced"],
|
|
3653
|
+
setup(__props, { emit: __emit }) {
|
|
3654
|
+
const props = __props;
|
|
3655
|
+
const emits = __emit;
|
|
3656
|
+
const myValue = useVModel(props, "modelValue", emits);
|
|
3657
|
+
const cascaderProps = computed(() => ({
|
|
3658
|
+
label: props.props.label || "label",
|
|
3659
|
+
value: props.props.value || "value",
|
|
3660
|
+
children: props.props.children || "children",
|
|
3661
|
+
multiple: props.multiple,
|
|
3662
|
+
emitPath: false,
|
|
3663
|
+
...props.props
|
|
3664
|
+
}));
|
|
3665
|
+
const treeProps = computed(() => ({
|
|
3666
|
+
label: props.props.label || "label",
|
|
3667
|
+
children: props.props.children || "children"
|
|
3668
|
+
}));
|
|
3669
|
+
function filterNode(value, data) {
|
|
3670
|
+
if (!value) {
|
|
3671
|
+
return false;
|
|
3672
|
+
}
|
|
3673
|
+
return value.includes(data[cascaderProps.value.value]);
|
|
3674
|
+
}
|
|
3675
|
+
const treeRef = useTemplateRef("treeRef");
|
|
3676
|
+
function filterTree(val) {
|
|
3677
|
+
nextTick(() => treeRef.value?.filter(val));
|
|
3678
|
+
emits("expandChange");
|
|
3679
|
+
}
|
|
3680
|
+
const cascaderPanelRef = useTemplateRef("cascaderPanelRef");
|
|
3681
|
+
function handleCascaderChange(val) {
|
|
3682
|
+
const node = cascaderPanelRef.value?.getCheckedNodes(true);
|
|
3683
|
+
emits("change", val, node);
|
|
3684
|
+
if (!props.multiple) {
|
|
3685
|
+
emits("choiced");
|
|
3686
|
+
} else {
|
|
3687
|
+
filterTree(val);
|
|
3688
|
+
}
|
|
3689
|
+
}
|
|
3690
|
+
const filterTreeWatch = watch(myValue, (val) => props.multiple && filterTree(val || ""), { immediate: true });
|
|
3691
|
+
onBeforeUnmount(() => filterTreeWatch.stop());
|
|
3692
|
+
return (_ctx, _cache) => {
|
|
3693
|
+
const _component_ElTree = ElTree;
|
|
3694
|
+
const _component_ElScrollbar = ElScrollbar;
|
|
3695
|
+
const _component_ElCascaderPanel = ElCascaderPanel;
|
|
3696
|
+
return openBlock(), createElementBlock(Fragment, null, [
|
|
3697
|
+
__props.multiple ? (openBlock(), createElementBlock("div", {
|
|
3698
|
+
key: 0,
|
|
3699
|
+
class: normalizeClass(_ctx.$style.selected)
|
|
3700
|
+
}, [
|
|
3701
|
+
createVNode(_component_ElScrollbar, null, {
|
|
3702
|
+
default: withCtx(() => [
|
|
3703
|
+
createVNode(_component_ElTree, {
|
|
3704
|
+
ref_key: "treeRef",
|
|
3705
|
+
ref: treeRef,
|
|
3706
|
+
"default-expand-all": "",
|
|
3707
|
+
"node-key": unref(cascaderProps).value,
|
|
3708
|
+
props: unref(treeProps),
|
|
3709
|
+
"empty-text": __props.emptyText,
|
|
3710
|
+
data: __props.options,
|
|
3711
|
+
"filter-node-method": filterNode
|
|
3712
|
+
}, null, 8, ["node-key", "props", "empty-text", "data"])
|
|
3713
|
+
]),
|
|
3714
|
+
_: 1
|
|
3715
|
+
})
|
|
3716
|
+
], 2)) : createCommentVNode("", true),
|
|
3717
|
+
createVNode(_component_ElCascaderPanel, mergeProps({
|
|
3718
|
+
ref_key: "cascaderPanelRef",
|
|
3719
|
+
ref: cascaderPanelRef,
|
|
3720
|
+
modelValue: unref(myValue),
|
|
3721
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => isRef(myValue) ? myValue.value = $event : null),
|
|
3722
|
+
props: unref(cascaderProps),
|
|
3723
|
+
options: __props.options
|
|
3724
|
+
}, _ctx.$attrs, {
|
|
3725
|
+
onExpandChange: _cache[1] || (_cache[1] = ($event) => emits("expandChange")),
|
|
3726
|
+
onChange: handleCascaderChange
|
|
3727
|
+
}), null, 16, ["modelValue", "props", "options"])
|
|
3728
|
+
], 64);
|
|
3729
|
+
};
|
|
3730
|
+
}
|
|
3731
|
+
});
|
|
3732
|
+
|
|
3733
|
+
/* unplugin-vue-components disabled */const selected = "_selected_1r65k_1";
|
|
3734
|
+
const style0 = {
|
|
3735
|
+
selected: selected
|
|
3736
|
+
};
|
|
3737
|
+
|
|
3738
|
+
const cssModules = {
|
|
3739
|
+
"$style": style0
|
|
3740
|
+
};
|
|
3741
|
+
const PopoverCascader = /* @__PURE__ */ _export_sfc$1(_sfc_main, [["__cssModules", cssModules]]);
|
|
3742
|
+
|
|
3743
|
+
export { ElText as E, PopoverCascader as P, ElCascader as a };
|