@wfrog/vc-ui 1.3.0 → 1.4.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/dist/es/chunk/{CCmEeM7D.mjs → B3GxuXVE.mjs} +6 -6
- package/dist/es/chunk/BL8WhaLp.mjs +427 -0
- package/dist/es/chunk/{BiHWk71g.mjs → BPqrpkTb.mjs} +4 -4
- package/dist/es/chunk/{C_7t9blX.mjs → BZ1uhZQF.mjs} +1 -1
- package/dist/es/chunk/{-ga82G_B.mjs → BdVq9mV6.mjs} +1 -1
- package/dist/es/chunk/{DGGhWn1A.mjs → BfjuZmry.mjs} +6 -5
- package/dist/es/chunk/{BLLKi_0v.mjs → Bu3XHP55.mjs} +1 -1
- package/dist/es/chunk/{DEiqPcuO.mjs → BvNFaD5d.mjs} +3 -3
- package/dist/es/chunk/BxibBO68.mjs +5741 -0
- package/dist/es/chunk/{DO-mBaf5.mjs → By7FMB3I.mjs} +1 -43
- package/dist/es/chunk/{DATKTbFj.mjs → CGhekNBa.mjs} +5 -5
- package/dist/es/chunk/{plK2vnjp.mjs → CJ0afvkJ.mjs} +1 -1
- package/dist/es/chunk/{CtYp4FB7.mjs → CK5Bluh4.mjs} +2 -2
- package/dist/es/chunk/{Vv8g5_A1.mjs → CKZGL4_3.mjs} +9 -8
- package/dist/es/chunk/CNEMJL35.mjs +69 -0
- package/dist/es/chunk/{C9ldJ8Hh.mjs → CPCieLBG.mjs} +1 -1
- package/dist/es/chunk/{C50_dziC.mjs → CQz3lhyS.mjs} +2 -1
- package/dist/es/chunk/{Cekqdlxf.mjs → CbYM6R_O.mjs} +12 -77
- package/dist/es/chunk/{CQbpo0im.mjs → CboHfRXN.mjs} +5 -6
- package/dist/es/chunk/{BambM7zX.mjs → Cdh3HNZa.mjs} +2 -2
- package/dist/es/chunk/{aX4SRHmD.mjs → Cg-Krnly.mjs} +2 -1
- package/dist/es/chunk/{9qQNa4bM.mjs → Cjp0Czyu.mjs} +1 -1
- package/dist/es/chunk/Cmb_E8Ip.mjs +184 -0
- package/dist/es/chunk/{BIK5Djc_.mjs → Co77DVCw.mjs} +2 -2
- package/dist/es/chunk/CqTa_Vd-.mjs +375 -0
- package/dist/es/{components/dual-pane/dual-pane.mjs → chunk/CsjEhAYY.mjs} +11 -91
- package/dist/es/chunk/{BQyZW57B.mjs → CwXV7M2F.mjs} +3 -3
- package/dist/es/chunk/{b9dx0jdT.mjs → D1MHFKtN.mjs} +3 -3
- package/dist/es/chunk/{DskGUrkJ.mjs → D6m3vWpc.mjs} +2 -1
- package/dist/es/chunk/{4F1xxyju.mjs → D6nWUATi.mjs} +48 -2117
- package/dist/es/chunk/{C6bIuBQg.mjs → D7CQDxqy.mjs} +3 -3
- package/dist/es/chunk/{Dqk3gyUk.mjs → D9Lr0Bzb.mjs} +1 -374
- package/dist/es/chunk/{Xk5kfdyT.mjs → DAIuzoFs.mjs} +2 -1
- package/dist/es/chunk/{OVbHCQoq.mjs → DCS0eqqM.mjs} +3 -101
- package/dist/es/chunk/{BJTCqgn1.mjs → DDR6UjaC.mjs} +1 -1
- package/dist/es/chunk/{BKmk2ptO.mjs → DNsAO9iB.mjs} +2 -2
- package/dist/es/chunk/{-_x5oKYF.mjs → DQK0ezHm.mjs} +5 -4
- package/dist/es/chunk/{BQHHM_Gw.mjs → DQi1QPak.mjs} +30 -70
- package/dist/es/chunk/{BaqDgAvL.mjs → DSt2uDNE.mjs} +22 -434
- package/dist/es/chunk/DSw4GnC6.mjs +44 -0
- package/dist/es/chunk/DTbnchOm.mjs +94 -0
- package/dist/es/chunk/DViraU6I.mjs +45 -0
- package/dist/es/chunk/{C540ZOUa.mjs → DX84QR5M.mjs} +10 -9
- package/dist/es/chunk/DYKOYbzT.mjs +2003 -0
- package/dist/es/chunk/{D1PKXAql.mjs → D_F7nIja.mjs} +3 -4
- package/dist/es/chunk/{DcTh6n4x.mjs → D_Mvdscy.mjs} +5 -4
- package/dist/es/chunk/DhGOsWxx.mjs +6 -0
- package/dist/es/chunk/{DFxeI_lP.mjs → DhGcJR5p.mjs} +6 -6
- package/dist/es/chunk/DxxbB5jY.mjs +34 -0
- package/dist/es/chunk/EMeQxUfH.mjs +49 -0
- package/dist/es/chunk/{eN6VJ63C.mjs → F2ph6lWu.mjs} +9 -8
- package/dist/es/chunk/{Dn-BFXcJ.mjs → dN0VcQc2.mjs} +1 -1
- package/dist/es/chunk/{DTpr71Gd.mjs → e5i7OJY-.mjs} +4 -4
- package/dist/es/chunk/fueZ9sVu.mjs +890 -0
- package/dist/es/chunk/{CV2NA_2e.mjs → ipA7n6-J.mjs} +1 -1
- package/dist/es/chunk/{Dw-yyl2m.mjs → q2jRgbir.mjs} +2 -2
- package/dist/es/chunk/{C72pWnuz.mjs → w7VqVeWU.mjs} +5 -4
- package/dist/es/chunk/{DWcIzeMM.mjs → ytiKcA3H.mjs} +108 -10
- package/dist/es/chunk/{DFHjl3eL.mjs → yuIXvUxc.mjs} +1 -1
- package/dist/es/components/backbottom/backbottom.mjs +2 -2
- package/dist/es/components/button/button.d.ts +2 -1
- package/dist/es/components/button/button.mjs +68 -17
- package/dist/es/components/button/button.vue.d.ts +4 -1
- package/dist/es/components/choice/choice.mjs +3 -2
- package/dist/es/components/color-switcher/color-switcher.d.ts +15 -0
- package/dist/es/components/color-switcher/color-switcher.mjs +1215 -0
- package/dist/es/components/color-switcher/color-switcher.vue.d.ts +122 -0
- package/dist/es/components/color-switcher/index.css +5 -0
- package/dist/es/components/color-switcher/index.d.ts +4 -0
- package/dist/es/components/color-switcher/index.mjs +6 -0
- package/dist/es/components/cropper/cropper.mjs +12 -11
- package/dist/es/components/cropper/cropper.vue.d.ts +2 -2
- package/dist/es/components/currency/currency.mjs +7 -7
- package/dist/es/components/dark-switcher/dark-switcher.d.ts +10 -0
- package/dist/es/components/dark-switcher/dark-switcher.mjs +87 -0
- package/dist/es/components/dark-switcher/dark-switcher.vue.d.ts +12 -0
- package/dist/es/components/dark-switcher/index.css +11 -0
- package/dist/es/components/dark-switcher/index.d.ts +4 -0
- package/dist/es/components/dark-switcher/index.mjs +6 -0
- package/dist/es/components/daterange-picker/daterange-picker.mjs +21 -20
- package/dist/es/components/dialog/dialog.d.ts +1 -1
- package/dist/es/components/dialog/dialog.mjs +46 -61
- package/dist/es/components/dialog/dialog.vue.d.ts +1 -3
- package/dist/es/components/dialog/index.css +31 -32
- package/dist/es/components/dialog-camera-upload/dialog-camera-upload.mjs +12 -12
- package/dist/es/components/dialog-map-point/dialog-map-point.mjs +5 -5
- package/dist/es/components/dialog-upload-images/dialog-upload-images.mjs +14 -13
- package/dist/es/components/document.vue.d.ts +14 -0
- package/dist/es/components/drag-verify/drag-verify.mjs +14 -14
- package/dist/es/components/drag-verify/index.css +11 -11
- package/dist/es/components/drawer/drawer.mjs +14 -14
- package/dist/es/components/drawer/index.css +16 -15
- package/dist/es/components/easy-pagination/easy-pagination.mjs +4 -4
- package/dist/es/components/el-icon/el-icon.mjs +2 -2
- package/dist/es/components/example-wrapper.vue.d.ts +19 -0
- package/dist/es/components/explorer/docs/data.d.ts +13 -0
- package/dist/es/components/explorer/explorer.d.ts +12 -0
- package/dist/es/components/explorer/explorer.mjs +64 -0
- package/dist/es/components/explorer/explorer.vue.d.ts +183 -0
- package/dist/es/components/explorer/explorer2.mjs +6 -0
- package/dist/es/components/explorer/index.css +14 -0
- package/dist/es/components/explorer/index.d.ts +4 -0
- package/dist/es/components/explorer/index.mjs +6 -0
- package/dist/es/components/explorer-column-table/explorer-column-table.d.ts +23 -0
- package/dist/es/components/explorer-column-table/explorer-column-table.mjs +2948 -0
- package/dist/es/components/explorer-column-table/explorer-column-table.vue.d.ts +1486 -0
- package/dist/es/components/explorer-column-table/index.css +49 -0
- package/dist/es/components/explorer-column-table/index.d.ts +4 -0
- package/dist/es/components/explorer-column-table/index.mjs +6 -0
- package/dist/es/components/explorer-filter/explorer-filter.d.ts +12 -0
- package/dist/es/components/explorer-filter/explorer-filter.mjs +81 -0
- package/dist/es/components/explorer-filter/explorer-filter.vue.d.ts +14 -0
- package/dist/es/components/explorer-filter/index.css +7 -0
- package/dist/es/components/explorer-filter/index.d.ts +4 -0
- package/dist/es/components/explorer-filter/index.mjs +6 -0
- package/dist/es/components/explorer-footer/explorer-footer.d.ts +5 -0
- package/dist/es/components/explorer-footer/explorer-footer.mjs +92 -0
- package/dist/es/components/explorer-footer/explorer-footer.vue.d.ts +21 -0
- package/dist/es/components/explorer-footer/index.css +7 -0
- package/dist/es/components/explorer-footer/index.d.ts +4 -0
- package/dist/es/components/explorer-footer/index.mjs +6 -0
- package/dist/es/components/explorer-list/explorer-list.d.ts +23 -0
- package/dist/es/components/explorer-list/explorer-list.mjs +157 -0
- package/dist/es/components/explorer-list/explorer-list.vue.d.ts +38 -0
- package/dist/es/components/explorer-list/index.css +47 -0
- package/dist/es/components/explorer-list/index.d.ts +4 -0
- package/dist/es/components/explorer-list/index.mjs +6 -0
- package/dist/es/components/explorer-panel/explorer-panel.d.ts +14 -0
- package/dist/es/components/explorer-panel/explorer-panel.mjs +77 -0
- package/dist/es/components/explorer-panel/explorer-panel.vue.d.ts +253 -0
- package/dist/es/components/explorer-panel/explorer-panel2.mjs +6 -0
- package/dist/es/components/explorer-panel/index.css +12 -0
- package/dist/es/components/explorer-panel/index.d.ts +4 -0
- package/dist/es/components/explorer-panel/index.mjs +6 -0
- package/dist/es/components/explorer-query/explorer-query.d.ts +11 -0
- package/dist/es/components/explorer-query/explorer-query.mjs +2376 -0
- package/dist/es/components/explorer-query/explorer-query.vue.d.ts +396 -0
- package/dist/es/components/explorer-query/index.css +36 -0
- package/dist/es/components/explorer-query/index.d.ts +4 -0
- package/dist/es/components/explorer-query/index.mjs +6 -0
- package/dist/es/components/explorer-table/explorer-table.d.ts +11 -0
- package/dist/es/components/explorer-table/explorer-table.mjs +116 -0
- package/dist/es/components/explorer-table/explorer-table.vue.d.ts +25 -0
- package/dist/es/components/explorer-table/index.css +18 -0
- package/dist/es/components/explorer-table/index.d.ts +4 -0
- package/dist/es/components/explorer-table/index.mjs +6 -0
- package/dist/es/components/explorer-tools/components/column-setter.vue.d.ts +3028 -0
- package/dist/es/components/explorer-tools/explorer-tools.d.ts +35 -0
- package/dist/es/components/explorer-tools/explorer-tools.mjs +585 -0
- package/dist/es/components/explorer-tools/explorer-tools.vue.d.ts +43 -0
- package/dist/es/components/explorer-tools/index.css +60 -0
- package/dist/es/components/explorer-tools/index.d.ts +4 -0
- package/dist/es/components/explorer-tools/index.mjs +6 -0
- package/dist/es/components/explorer-tree/explorer-tree.d.ts +22 -0
- package/dist/es/components/explorer-tree/explorer-tree.mjs +174 -0
- package/dist/es/components/explorer-tree/explorer-tree.vue.d.ts +2055 -0
- package/dist/es/components/explorer-tree/index.css +55 -0
- package/dist/es/components/explorer-tree/index.d.ts +4 -0
- package/dist/es/components/explorer-tree/index.mjs +6 -0
- package/dist/es/components/icon/icon2.mjs +2 -2
- package/dist/es/components/icon-picker/components/collections.vue.d.ts +242 -196
- package/dist/es/components/icon-picker/icon-picker.mjs +38 -921
- package/dist/es/components/icon-picker/index.css +31 -29
- package/dist/es/components/iconify-icon/iconify-icon.mjs +2 -2
- package/dist/es/components/image/image.mjs +5 -5
- package/dist/es/components/image/image.vue.d.ts +7 -7
- package/dist/es/components/input/index.css +4 -5
- package/dist/es/components/input/input.mjs +7 -7
- package/dist/es/components/input/input.vue.d.ts +3 -3
- package/dist/es/components/input-number/input-number.mjs +5 -5
- package/dist/es/components/pca-picker/components/c.vue.d.ts +3 -3
- package/dist/es/components/pca-picker/index.css +4 -4
- package/dist/es/components/pca-picker/pca-picker.mjs +21 -209
- package/dist/es/components/pca-picker/pca-picker.vue.d.ts +10 -10
- package/dist/es/components/screenfull/screenfull.mjs +4 -4
- package/dist/es/components/scrollbar/index.css +6 -5
- package/dist/es/components/scrollbar/scrollbar.d.ts +2 -0
- package/dist/es/components/scrollbar/scrollbar.mjs +17 -12
- package/dist/es/components/scrollbar/scrollbar.vue.d.ts +156 -134
- package/dist/es/components/select/select.mjs +7 -7
- package/dist/es/components/single-player/index.css +11 -11
- package/dist/es/components/single-player/single-player.mjs +20 -19
- package/dist/es/components/splitter/index.d.ts +4 -0
- package/dist/es/components/splitter/index.mjs +6 -0
- package/dist/es/components/splitter/splitter.d.ts +4 -0
- package/dist/es/components/splitter/splitter.mjs +28 -0
- package/dist/es/components/{dual-pane/dual-pane.vue.d.ts → splitter/splitter.vue.d.ts} +3 -5
- package/dist/es/components/splitter-panel/index.css +5 -0
- package/dist/es/components/splitter-panel/index.d.ts +4 -0
- package/dist/es/components/splitter-panel/index.mjs +6 -0
- package/dist/es/components/splitter-panel/splitter-panel.d.ts +3 -0
- package/dist/es/components/splitter-panel/splitter-panel.mjs +49 -0
- package/dist/es/components/splitter-panel/splitter-panel.vue.d.ts +20 -0
- package/dist/es/components/svg-icon/svg-icon.mjs +2 -2
- package/dist/es/components/switch/switch.mjs +2 -2
- package/dist/es/components/sync-scroll-container/sync-scroll-container.mjs +2 -2
- package/dist/es/components/tags/tags.mjs +12 -11
- package/dist/es/components/text-ellipsis/text-ellipsis.mjs +4 -4
- package/dist/es/components/text-ellipsis/text-ellipsis.vue.d.ts +1 -1
- package/dist/es/components/thousand-input/thousand-input.mjs +3 -3
- package/dist/es/components/thousand-input/thousand-input.vue.d.ts +8 -8
- package/dist/es/components/tinymce/index.css +1 -1
- package/dist/es/components/tinymce/tinymce.d.ts +1 -0
- package/dist/es/components/tinymce/tinymce.mjs +20 -11
- package/dist/es/components/tinymce/tinymce.vue.d.ts +1 -0
- package/dist/es/components/tree-picker/popover-cascader.css +1 -1
- package/dist/es/components/tree-picker/tree-picker.mjs +11 -10
- package/dist/es/components/tree-picker/tree-picker.vue.d.ts +10 -10
- package/dist/es/components/upload-file/upload-file.mjs +2 -2
- package/dist/es/index.d.ts +14 -1
- package/dist/es/index.mjs +69 -39
- package/dist/es/use/usePersistentModel/index.d.ts +4 -0
- package/dist/es/use/usePersistentModel/index.mjs +19 -0
- package/dist/global.d.ts +14 -1
- package/dist/index.css +450 -123
- package/package.json +4 -1
- package/dist/es/chunk/DVNTpOBR.mjs +0 -4
- package/dist/es/components/dual-pane/dual-pane.d.ts +0 -8
- package/dist/es/components/dual-pane/index.css +0 -8
- package/dist/es/components/dual-pane/index.d.ts +0 -4
- package/dist/es/components/dual-pane/index.mjs +0 -6
|
@@ -1,30 +1,33 @@
|
|
|
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, vShow, normalizeStyle, createSlots, resolveDynamicComponent, withKeys, vModelText,
|
|
2
|
-
import { isClient, useDebounceFn, useResizeObserver, useCssVar,
|
|
3
|
-
import { E as ElInput } from './
|
|
4
|
-
import { g as unique, c as castArray, u as useTooltipContentProps, E as Ee, a as ElTooltip } from './
|
|
5
|
-
import { E as ElScrollbar } from './
|
|
6
|
-
import { t as tagProps, E as ElTag } from './
|
|
7
|
-
import { E as ElIcon } from './
|
|
8
|
-
import { Check, Loading, ArrowRight, CircleClose, ArrowDown
|
|
9
|
-
import { u as useNamespace,
|
|
10
|
-
import { u as useSizeProp
|
|
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, vShow, normalizeStyle, createSlots, resolveDynamicComponent, withKeys, vModelText, useTemplateRef, onBeforeUnmount, mergeProps, isRef } from 'vue';
|
|
2
|
+
import { isClient, useDebounceFn, useResizeObserver, useCssVar, useVModel } from '@vueuse/core';
|
|
3
|
+
import { E as ElInput } from './CKZGL4_3.mjs';
|
|
4
|
+
import { g as unique, c as castArray, u as useTooltipContentProps, E as Ee, a as ElTooltip } from './BfjuZmry.mjs';
|
|
5
|
+
import { E as ElScrollbar } from './D_Mvdscy.mjs';
|
|
6
|
+
import { t as tagProps, E as ElTag } from './DhGcJR5p.mjs';
|
|
7
|
+
import { E as ElIcon } from './D1MHFKtN.mjs';
|
|
8
|
+
import { Check, Loading, ArrowRight, CircleClose, ArrowDown } from '@element-plus/icons-vue';
|
|
9
|
+
import { u as useNamespace, c as isArray, f as isFunction, b as buildProps, N as NOOP, d as definePropType, a as debugWarn, p as isPromise } from './By7FMB3I.mjs';
|
|
10
|
+
import { u as useSizeProp } from './CPCieLBG.mjs';
|
|
11
11
|
import { i as iconPropType } from '../components/icon/icon2.mjs';
|
|
12
|
-
import { u as useEmptyValuesProps, a as useEmptyValues } from './
|
|
12
|
+
import { u as useEmptyValuesProps, a as useEmptyValues } from './CK5Bluh4.mjs';
|
|
13
13
|
import { C as CHANGE_EVENT, U as UPDATE_MODEL_EVENT } from './Ct6q2FXg.mjs';
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import { u as
|
|
18
|
-
import { a as
|
|
14
|
+
import { a as isEmpty, c as isUndefined, e as isPropAbsent, d as isBoolean } from './DViraU6I.mjs';
|
|
15
|
+
import { _ as _export_sfc, w as withInstall } from './dN0VcQc2.mjs';
|
|
16
|
+
import { C as ClickOutside } from './Cg-Krnly.mjs';
|
|
17
|
+
import { u as useLocale } from './CJ0afvkJ.mjs';
|
|
18
|
+
import { u as useFormItem, a as useFormDisabled, c as useFormSize } from './BvNFaD5d.mjs';
|
|
19
|
+
import { a as useComposition, u as useFocusController } from './DAIuzoFs.mjs';
|
|
19
20
|
import { g as getEventCode, E as EVENT_CODE } from './BTpNRPQW.mjs';
|
|
20
21
|
import { b as isLeaf, c as focusNode, g as getSibling } from './CsLIbnzG.mjs';
|
|
21
|
-
import { c as cloneDeep } from './
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
22
|
+
import { c as cloneDeep } from './ipA7n6-J.mjs';
|
|
23
|
+
import { E as ElCheckbox } from './DSt2uDNE.mjs';
|
|
24
|
+
import { b as ElRadio } from './BL8WhaLp.mjs';
|
|
25
|
+
import { E as ElTree } from './DYKOYbzT.mjs';
|
|
26
|
+
import './DTbnchOm.mjs';
|
|
27
|
+
import { u as useId } from './Co77DVCw.mjs';
|
|
28
|
+
import { i as isEqual } from './q2jRgbir.mjs';
|
|
29
|
+
import { s as scrollIntoView } from './CboHfRXN.mjs';
|
|
30
|
+
import { b as baseFlatten } from './DCS0eqqM.mjs';
|
|
28
31
|
import { _ as _export_sfc$1 } from './pcqpp-6-.mjs';
|
|
29
32
|
|
|
30
33
|
/** Used as references for various `Number` constants. */
|
|
@@ -56,7 +59,7 @@ function isVNodeEmpty(vnodes) {
|
|
|
56
59
|
type
|
|
57
60
|
}) => type === Comment) : (vnodes == null ? void 0 : vnodes.type) === Comment);
|
|
58
61
|
}
|
|
59
|
-
var NodeContent
|
|
62
|
+
var NodeContent = defineComponent({
|
|
60
63
|
name: "NodeContent",
|
|
61
64
|
props: {
|
|
62
65
|
node: {
|
|
@@ -89,8 +92,8 @@ var NodeContent$1 = defineComponent({
|
|
|
89
92
|
}
|
|
90
93
|
});
|
|
91
94
|
|
|
92
|
-
const _hoisted_1$
|
|
93
|
-
const _sfc_main$
|
|
95
|
+
const _hoisted_1$1 = ["id", "aria-haspopup", "aria-owns", "aria-expanded", "tabindex"];
|
|
96
|
+
const _sfc_main$4 = defineComponent({
|
|
94
97
|
...{
|
|
95
98
|
name: "ElCascaderNode"
|
|
96
99
|
},
|
|
@@ -244,7 +247,7 @@ const _sfc_main$9 = defineComponent({
|
|
|
244
247
|
_: 1
|
|
245
248
|
}, 8, ["class"])) : createCommentVNode("v-if", true),
|
|
246
249
|
createCommentVNode(" content "),
|
|
247
|
-
createVNode(unref(NodeContent
|
|
250
|
+
createVNode(unref(NodeContent), { node: __props.node }, null, 8, ["node"]),
|
|
248
251
|
createCommentVNode(" postfix "),
|
|
249
252
|
!isLeaf.value ? (openBlock(), createElementBlock(
|
|
250
253
|
Fragment,
|
|
@@ -270,13 +273,13 @@ const _sfc_main$9 = defineComponent({
|
|
|
270
273
|
],
|
|
271
274
|
64
|
|
272
275
|
)) : createCommentVNode("v-if", true)
|
|
273
|
-
], 42, _hoisted_1$
|
|
276
|
+
], 42, _hoisted_1$1);
|
|
274
277
|
};
|
|
275
278
|
}
|
|
276
279
|
});
|
|
277
|
-
var ElCascaderNode = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
280
|
+
var ElCascaderNode = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/cascader-panel/src/node.vue"]]);
|
|
278
281
|
|
|
279
|
-
const _sfc_main$
|
|
282
|
+
const _sfc_main$3 = defineComponent({
|
|
280
283
|
...{
|
|
281
284
|
name: "ElCascaderMenu"
|
|
282
285
|
},
|
|
@@ -430,7 +433,7 @@ const _sfc_main$8 = defineComponent({
|
|
|
430
433
|
};
|
|
431
434
|
}
|
|
432
435
|
});
|
|
433
|
-
var ElCascaderMenu = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
436
|
+
var ElCascaderMenu = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/cascader-panel/src/menu.vue"]]);
|
|
434
437
|
|
|
435
438
|
let uid = 0;
|
|
436
439
|
const calculatePathNodes = (node) => {
|
|
@@ -442,7 +445,7 @@ const calculatePathNodes = (node) => {
|
|
|
442
445
|
}
|
|
443
446
|
return nodes;
|
|
444
447
|
};
|
|
445
|
-
|
|
448
|
+
class Node {
|
|
446
449
|
constructor(data, config, parent, root = false) {
|
|
447
450
|
this.data = data;
|
|
448
451
|
this.config = config;
|
|
@@ -548,7 +551,7 @@ let Node$1 = class Node {
|
|
|
548
551
|
this.emit();
|
|
549
552
|
}
|
|
550
553
|
}
|
|
551
|
-
}
|
|
554
|
+
}
|
|
552
555
|
|
|
553
556
|
const flatNodes = (nodes, leafOnly) => {
|
|
554
557
|
return nodes.reduce((res, node) => {
|
|
@@ -565,7 +568,7 @@ class Store {
|
|
|
565
568
|
constructor(data, config) {
|
|
566
569
|
this.config = config;
|
|
567
570
|
const nodes = (data || []).map(
|
|
568
|
-
(nodeData) => new Node
|
|
571
|
+
(nodeData) => new Node(nodeData, this.config)
|
|
569
572
|
);
|
|
570
573
|
this.nodes = nodes;
|
|
571
574
|
this.allNodes = flatNodes(nodes, false);
|
|
@@ -578,7 +581,7 @@ class Store {
|
|
|
578
581
|
return leafOnly ? this.leafNodes : this.allNodes;
|
|
579
582
|
}
|
|
580
583
|
appendNode(nodeData, parentNode) {
|
|
581
|
-
const node = parentNode ? parentNode.appendChild(nodeData) : new Node
|
|
584
|
+
const node = parentNode ? parentNode.appendChild(nodeData) : new Node(nodeData, this.config);
|
|
582
585
|
if (!parentNode)
|
|
583
586
|
this.nodes.push(node);
|
|
584
587
|
this.appendAllNodesAndLeafNodes(node);
|
|
@@ -703,7 +706,7 @@ const sortByOriginalOrder = (oldNodes, newNodes) => {
|
|
|
703
706
|
return res;
|
|
704
707
|
};
|
|
705
708
|
|
|
706
|
-
const _sfc_main$
|
|
709
|
+
const _sfc_main$2 = defineComponent({
|
|
707
710
|
...{
|
|
708
711
|
name: "ElCascaderPanel"
|
|
709
712
|
},
|
|
@@ -749,7 +752,7 @@ const _sfc_main$7 = defineComponent({
|
|
|
749
752
|
};
|
|
750
753
|
const lazyLoad = (node, cb) => {
|
|
751
754
|
const cfg = config.value;
|
|
752
|
-
node = node || new Node
|
|
755
|
+
node = node || new Node({}, cfg, void 0, true);
|
|
753
756
|
node.loading = true;
|
|
754
757
|
const resolve = (dataList) => {
|
|
755
758
|
const _node = node;
|
|
@@ -1038,7 +1041,7 @@ const _sfc_main$7 = defineComponent({
|
|
|
1038
1041
|
};
|
|
1039
1042
|
}
|
|
1040
1043
|
});
|
|
1041
|
-
var CascaderPanel = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
1044
|
+
var CascaderPanel = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/cascader-panel/src/index.vue"]]);
|
|
1042
1045
|
|
|
1043
1046
|
const ElCascaderPanel = withInstall(CascaderPanel);
|
|
1044
1047
|
|
|
@@ -1137,9 +1140,9 @@ const cascaderEmits = {
|
|
|
1137
1140
|
removeTag: (val) => !!val
|
|
1138
1141
|
};
|
|
1139
1142
|
|
|
1140
|
-
const _hoisted_1
|
|
1141
|
-
const _hoisted_2
|
|
1142
|
-
const _sfc_main$
|
|
1143
|
+
const _hoisted_1 = ["placeholder"];
|
|
1144
|
+
const _hoisted_2 = ["onClick"];
|
|
1145
|
+
const _sfc_main$1 = defineComponent({
|
|
1143
1146
|
...{
|
|
1144
1147
|
name: "ElCascader"
|
|
1145
1148
|
},
|
|
@@ -1836,7 +1839,7 @@ const _sfc_main$6 = defineComponent({
|
|
|
1836
1839
|
onCompositionstart: _cache[5] || (_cache[5] = (...args) => unref(handleComposition) && unref(handleComposition)(...args)),
|
|
1837
1840
|
onCompositionupdate: _cache[6] || (_cache[6] = (...args) => unref(handleComposition) && unref(handleComposition)(...args)),
|
|
1838
1841
|
onCompositionend: _cache[7] || (_cache[7] = (...args) => unref(handleComposition) && unref(handleComposition)(...args))
|
|
1839
|
-
}, null, 42, _hoisted_1
|
|
1842
|
+
}, null, 42, _hoisted_1)), [
|
|
1840
1843
|
[vModelText, searchInputValue.value]
|
|
1841
1844
|
]) : createCommentVNode("v-if", true)
|
|
1842
1845
|
],
|
|
@@ -1918,7 +1921,7 @@ const _sfc_main$6 = defineComponent({
|
|
|
1918
1921
|
_: 1
|
|
1919
1922
|
})) : createCommentVNode("v-if", true)
|
|
1920
1923
|
])
|
|
1921
|
-
], 10, _hoisted_2
|
|
1924
|
+
], 10, _hoisted_2);
|
|
1922
1925
|
}),
|
|
1923
1926
|
128
|
|
1924
1927
|
)) : renderSlot(_ctx.$slots, "empty", { key: 1 }, () => [
|
|
@@ -1955,2082 +1958,10 @@ const _sfc_main$6 = defineComponent({
|
|
|
1955
1958
|
};
|
|
1956
1959
|
}
|
|
1957
1960
|
});
|
|
1958
|
-
var Cascader = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
1961
|
+
var Cascader = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/cascader/src/cascader.vue"]]);
|
|
1959
1962
|
|
|
1960
1963
|
const ElCascader = withInstall(Cascader);
|
|
1961
1964
|
|
|
1962
|
-
const _sfc_main$5 = defineComponent({
|
|
1963
|
-
...{
|
|
1964
|
-
name: "ElCollapseTransition"
|
|
1965
|
-
},
|
|
1966
|
-
__name: "collapse-transition",
|
|
1967
|
-
setup(__props) {
|
|
1968
|
-
const ns = useNamespace("collapse-transition");
|
|
1969
|
-
const reset = (el) => {
|
|
1970
|
-
el.style.maxHeight = "";
|
|
1971
|
-
el.style.overflow = el.dataset.oldOverflow;
|
|
1972
|
-
el.style.paddingTop = el.dataset.oldPaddingTop;
|
|
1973
|
-
el.style.paddingBottom = el.dataset.oldPaddingBottom;
|
|
1974
|
-
};
|
|
1975
|
-
const on = {
|
|
1976
|
-
beforeEnter(el) {
|
|
1977
|
-
if (!el.dataset)
|
|
1978
|
-
el.dataset = {};
|
|
1979
|
-
el.dataset.oldPaddingTop = el.style.paddingTop;
|
|
1980
|
-
el.dataset.oldPaddingBottom = el.style.paddingBottom;
|
|
1981
|
-
if (el.style.height)
|
|
1982
|
-
el.dataset.elExistsHeight = el.style.height;
|
|
1983
|
-
el.style.maxHeight = 0;
|
|
1984
|
-
el.style.paddingTop = 0;
|
|
1985
|
-
el.style.paddingBottom = 0;
|
|
1986
|
-
},
|
|
1987
|
-
enter(el) {
|
|
1988
|
-
requestAnimationFrame(() => {
|
|
1989
|
-
el.dataset.oldOverflow = el.style.overflow;
|
|
1990
|
-
if (el.dataset.elExistsHeight) {
|
|
1991
|
-
el.style.maxHeight = el.dataset.elExistsHeight;
|
|
1992
|
-
} else if (el.scrollHeight !== 0) {
|
|
1993
|
-
el.style.maxHeight = `${el.scrollHeight}px`;
|
|
1994
|
-
} else {
|
|
1995
|
-
el.style.maxHeight = 0;
|
|
1996
|
-
}
|
|
1997
|
-
el.style.paddingTop = el.dataset.oldPaddingTop;
|
|
1998
|
-
el.style.paddingBottom = el.dataset.oldPaddingBottom;
|
|
1999
|
-
el.style.overflow = "hidden";
|
|
2000
|
-
});
|
|
2001
|
-
},
|
|
2002
|
-
afterEnter(el) {
|
|
2003
|
-
el.style.maxHeight = "";
|
|
2004
|
-
el.style.overflow = el.dataset.oldOverflow;
|
|
2005
|
-
},
|
|
2006
|
-
enterCancelled(el) {
|
|
2007
|
-
reset(el);
|
|
2008
|
-
},
|
|
2009
|
-
beforeLeave(el) {
|
|
2010
|
-
if (!el.dataset)
|
|
2011
|
-
el.dataset = {};
|
|
2012
|
-
el.dataset.oldPaddingTop = el.style.paddingTop;
|
|
2013
|
-
el.dataset.oldPaddingBottom = el.style.paddingBottom;
|
|
2014
|
-
el.dataset.oldOverflow = el.style.overflow;
|
|
2015
|
-
el.style.maxHeight = `${el.scrollHeight}px`;
|
|
2016
|
-
el.style.overflow = "hidden";
|
|
2017
|
-
},
|
|
2018
|
-
leave(el) {
|
|
2019
|
-
if (el.scrollHeight !== 0) {
|
|
2020
|
-
el.style.maxHeight = 0;
|
|
2021
|
-
el.style.paddingTop = 0;
|
|
2022
|
-
el.style.paddingBottom = 0;
|
|
2023
|
-
}
|
|
2024
|
-
},
|
|
2025
|
-
afterLeave(el) {
|
|
2026
|
-
reset(el);
|
|
2027
|
-
},
|
|
2028
|
-
leaveCancelled(el) {
|
|
2029
|
-
reset(el);
|
|
2030
|
-
}
|
|
2031
|
-
};
|
|
2032
|
-
return (_ctx, _cache) => {
|
|
2033
|
-
return openBlock(), createBlock(Transition, mergeProps({
|
|
2034
|
-
name: unref(ns).b()
|
|
2035
|
-
}, toHandlers(on)), {
|
|
2036
|
-
default: withCtx(() => [
|
|
2037
|
-
renderSlot(_ctx.$slots, "default")
|
|
2038
|
-
]),
|
|
2039
|
-
_: 3
|
|
2040
|
-
}, 16, ["name"]);
|
|
2041
|
-
};
|
|
2042
|
-
}
|
|
2043
|
-
});
|
|
2044
|
-
var CollapseTransition = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/collapse-transition/src/collapse-transition.vue"]]);
|
|
2045
|
-
|
|
2046
|
-
const ElCollapseTransition = withInstall(CollapseTransition);
|
|
2047
|
-
|
|
2048
|
-
const textProps = buildProps({
|
|
2049
|
-
type: {
|
|
2050
|
-
type: String,
|
|
2051
|
-
values: ["primary", "success", "info", "warning", "danger", ""],
|
|
2052
|
-
default: ""
|
|
2053
|
-
},
|
|
2054
|
-
size: {
|
|
2055
|
-
type: String,
|
|
2056
|
-
values: componentSizes,
|
|
2057
|
-
default: ""
|
|
2058
|
-
},
|
|
2059
|
-
truncated: Boolean,
|
|
2060
|
-
lineClamp: {
|
|
2061
|
-
type: [String, Number]
|
|
2062
|
-
},
|
|
2063
|
-
tag: {
|
|
2064
|
-
type: String,
|
|
2065
|
-
default: "span"
|
|
2066
|
-
}
|
|
2067
|
-
});
|
|
2068
|
-
|
|
2069
|
-
const _sfc_main$4 = defineComponent({
|
|
2070
|
-
...{
|
|
2071
|
-
name: "ElText"
|
|
2072
|
-
},
|
|
2073
|
-
__name: "text",
|
|
2074
|
-
props: textProps,
|
|
2075
|
-
setup(__props) {
|
|
2076
|
-
const props = __props;
|
|
2077
|
-
const textRef = ref();
|
|
2078
|
-
const textSize = useFormSize();
|
|
2079
|
-
const ns = useNamespace("text");
|
|
2080
|
-
const textKls = computed(() => [
|
|
2081
|
-
ns.b(),
|
|
2082
|
-
ns.m(props.type),
|
|
2083
|
-
ns.m(textSize.value),
|
|
2084
|
-
ns.is("truncated", props.truncated),
|
|
2085
|
-
ns.is("line-clamp", !isUndefined(props.lineClamp))
|
|
2086
|
-
]);
|
|
2087
|
-
const bindTitle = () => {
|
|
2088
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
2089
|
-
const inheritTitle = useAttrs().title;
|
|
2090
|
-
if (inheritTitle)
|
|
2091
|
-
return;
|
|
2092
|
-
let shouldAddTitle = false;
|
|
2093
|
-
const text = ((_a = textRef.value) == null ? void 0 : _a.textContent) || "";
|
|
2094
|
-
if (props.truncated) {
|
|
2095
|
-
const width = (_b = textRef.value) == null ? void 0 : _b.offsetWidth;
|
|
2096
|
-
const scrollWidth = (_c = textRef.value) == null ? void 0 : _c.scrollWidth;
|
|
2097
|
-
if (width && scrollWidth && scrollWidth > width) {
|
|
2098
|
-
shouldAddTitle = true;
|
|
2099
|
-
}
|
|
2100
|
-
} else if (!isUndefined(props.lineClamp)) {
|
|
2101
|
-
const height = (_d = textRef.value) == null ? void 0 : _d.offsetHeight;
|
|
2102
|
-
const scrollHeight = (_e = textRef.value) == null ? void 0 : _e.scrollHeight;
|
|
2103
|
-
if (height && scrollHeight && scrollHeight > height) {
|
|
2104
|
-
shouldAddTitle = true;
|
|
2105
|
-
}
|
|
2106
|
-
}
|
|
2107
|
-
if (shouldAddTitle) {
|
|
2108
|
-
(_f = textRef.value) == null ? void 0 : _f.setAttribute("title", text);
|
|
2109
|
-
} else {
|
|
2110
|
-
(_g = textRef.value) == null ? void 0 : _g.removeAttribute("title");
|
|
2111
|
-
}
|
|
2112
|
-
};
|
|
2113
|
-
onMounted(bindTitle);
|
|
2114
|
-
onUpdated(bindTitle);
|
|
2115
|
-
return (_ctx, _cache) => {
|
|
2116
|
-
return openBlock(), createBlock(resolveDynamicComponent(_ctx.tag), {
|
|
2117
|
-
ref_key: "textRef",
|
|
2118
|
-
ref: textRef,
|
|
2119
|
-
class: normalizeClass(textKls.value),
|
|
2120
|
-
style: normalizeStyle({ "-webkit-line-clamp": _ctx.lineClamp })
|
|
2121
|
-
}, {
|
|
2122
|
-
default: withCtx(() => [
|
|
2123
|
-
renderSlot(_ctx.$slots, "default")
|
|
2124
|
-
]),
|
|
2125
|
-
_: 3
|
|
2126
|
-
}, 8, ["class", "style"]);
|
|
2127
|
-
};
|
|
2128
|
-
}
|
|
2129
|
-
});
|
|
2130
|
-
var Text = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/text/src/text.vue"]]);
|
|
2131
|
-
|
|
2132
|
-
const ElText = withInstall(Text);
|
|
2133
|
-
|
|
2134
|
-
const NODE_KEY = "$treeNodeId";
|
|
2135
|
-
const markNodeData = function(node, data) {
|
|
2136
|
-
if (!data || data[NODE_KEY])
|
|
2137
|
-
return;
|
|
2138
|
-
Object.defineProperty(data, NODE_KEY, {
|
|
2139
|
-
value: node.id,
|
|
2140
|
-
enumerable: false,
|
|
2141
|
-
configurable: false,
|
|
2142
|
-
writable: false
|
|
2143
|
-
});
|
|
2144
|
-
};
|
|
2145
|
-
const getNodeKey = (key, data) => data == null ? void 0 : data[key || NODE_KEY];
|
|
2146
|
-
const handleCurrentChange = (store, emit, setCurrent) => {
|
|
2147
|
-
const preCurrentNode = store.value.currentNode;
|
|
2148
|
-
setCurrent();
|
|
2149
|
-
const currentNode = store.value.currentNode;
|
|
2150
|
-
if (preCurrentNode === currentNode)
|
|
2151
|
-
return;
|
|
2152
|
-
emit("current-change", currentNode ? currentNode.data : null, currentNode);
|
|
2153
|
-
};
|
|
2154
|
-
|
|
2155
|
-
const getChildState = (node) => {
|
|
2156
|
-
let all = true;
|
|
2157
|
-
let none = true;
|
|
2158
|
-
let allWithoutDisable = true;
|
|
2159
|
-
let isEffectivelyChecked = true;
|
|
2160
|
-
for (let i = 0, j = node.length; i < j; i++) {
|
|
2161
|
-
const n = node[i];
|
|
2162
|
-
if (n.checked !== true || n.indeterminate) {
|
|
2163
|
-
all = false;
|
|
2164
|
-
if (!n.disabled) {
|
|
2165
|
-
allWithoutDisable = false;
|
|
2166
|
-
}
|
|
2167
|
-
}
|
|
2168
|
-
if (n.checked !== false || n.indeterminate) {
|
|
2169
|
-
none = false;
|
|
2170
|
-
}
|
|
2171
|
-
if (!n.isEffectivelyChecked) {
|
|
2172
|
-
isEffectivelyChecked = false;
|
|
2173
|
-
}
|
|
2174
|
-
}
|
|
2175
|
-
return {
|
|
2176
|
-
all,
|
|
2177
|
-
none,
|
|
2178
|
-
allWithoutDisable,
|
|
2179
|
-
half: !all && !none,
|
|
2180
|
-
isEffectivelyChecked
|
|
2181
|
-
};
|
|
2182
|
-
};
|
|
2183
|
-
const reInitChecked = function(node) {
|
|
2184
|
-
if (node.childNodes.length === 0 || node.loading) {
|
|
2185
|
-
node.isEffectivelyChecked = node.disabled || node.checked;
|
|
2186
|
-
return;
|
|
2187
|
-
}
|
|
2188
|
-
const { all, none, half, isEffectivelyChecked } = getChildState(
|
|
2189
|
-
node.childNodes
|
|
2190
|
-
);
|
|
2191
|
-
node.isEffectivelyChecked = isEffectivelyChecked;
|
|
2192
|
-
if (all) {
|
|
2193
|
-
node.checked = true;
|
|
2194
|
-
node.indeterminate = false;
|
|
2195
|
-
} else if (half) {
|
|
2196
|
-
node.checked = false;
|
|
2197
|
-
node.indeterminate = true;
|
|
2198
|
-
} else if (none) {
|
|
2199
|
-
node.checked = false;
|
|
2200
|
-
node.indeterminate = false;
|
|
2201
|
-
}
|
|
2202
|
-
const parent = node.parent;
|
|
2203
|
-
if (!parent || parent.level === 0)
|
|
2204
|
-
return;
|
|
2205
|
-
if (!node.store.checkStrictly) {
|
|
2206
|
-
reInitChecked(parent);
|
|
2207
|
-
}
|
|
2208
|
-
};
|
|
2209
|
-
const getPropertyFromData = function(node, prop) {
|
|
2210
|
-
const props = node.store.props;
|
|
2211
|
-
const data = node.data || {};
|
|
2212
|
-
const config = props[prop];
|
|
2213
|
-
if (isFunction(config)) {
|
|
2214
|
-
return config(data, node);
|
|
2215
|
-
} else if (isString(config)) {
|
|
2216
|
-
return data[config];
|
|
2217
|
-
} else if (isUndefined(config)) {
|
|
2218
|
-
const dataProp = data[prop];
|
|
2219
|
-
return isUndefined(dataProp) ? "" : dataProp;
|
|
2220
|
-
}
|
|
2221
|
-
};
|
|
2222
|
-
const setCanFocus = function(childNodes, focus) {
|
|
2223
|
-
childNodes.forEach((item) => {
|
|
2224
|
-
item.canFocus = focus;
|
|
2225
|
-
setCanFocus(item.childNodes, focus);
|
|
2226
|
-
});
|
|
2227
|
-
};
|
|
2228
|
-
let nodeIdSeed = 0;
|
|
2229
|
-
class Node {
|
|
2230
|
-
constructor(options) {
|
|
2231
|
-
this.isLeafByUser = void 0;
|
|
2232
|
-
this.isLeaf = void 0;
|
|
2233
|
-
this.isEffectivelyChecked = false;
|
|
2234
|
-
this.id = nodeIdSeed++;
|
|
2235
|
-
this.text = null;
|
|
2236
|
-
this.checked = false;
|
|
2237
|
-
this.indeterminate = false;
|
|
2238
|
-
this.data = null;
|
|
2239
|
-
this.expanded = false;
|
|
2240
|
-
this.parent = null;
|
|
2241
|
-
this.visible = true;
|
|
2242
|
-
this.isCurrent = false;
|
|
2243
|
-
this.canFocus = false;
|
|
2244
|
-
for (const name in options) {
|
|
2245
|
-
if (hasOwn(options, name)) {
|
|
2246
|
-
this[name] = options[name];
|
|
2247
|
-
}
|
|
2248
|
-
}
|
|
2249
|
-
this.level = 0;
|
|
2250
|
-
this.loaded = false;
|
|
2251
|
-
this.childNodes = [];
|
|
2252
|
-
this.loading = false;
|
|
2253
|
-
if (this.parent) {
|
|
2254
|
-
this.level = this.parent.level + 1;
|
|
2255
|
-
}
|
|
2256
|
-
}
|
|
2257
|
-
initialize() {
|
|
2258
|
-
var _a;
|
|
2259
|
-
const store = this.store;
|
|
2260
|
-
if (!store) {
|
|
2261
|
-
throw new Error("[Node]store is required!");
|
|
2262
|
-
}
|
|
2263
|
-
store.registerNode(this);
|
|
2264
|
-
const props = store.props;
|
|
2265
|
-
if (props && typeof props.isLeaf !== "undefined") {
|
|
2266
|
-
const isLeaf = getPropertyFromData(this, "isLeaf");
|
|
2267
|
-
if (isBoolean(isLeaf)) {
|
|
2268
|
-
this.isLeafByUser = isLeaf;
|
|
2269
|
-
}
|
|
2270
|
-
}
|
|
2271
|
-
if (store.lazy !== true && this.data) {
|
|
2272
|
-
this.setData(this.data);
|
|
2273
|
-
if (store.defaultExpandAll) {
|
|
2274
|
-
this.expanded = true;
|
|
2275
|
-
this.canFocus = true;
|
|
2276
|
-
}
|
|
2277
|
-
} else if (this.level > 0 && store.lazy && store.defaultExpandAll && !this.isLeafByUser) {
|
|
2278
|
-
this.expand();
|
|
2279
|
-
}
|
|
2280
|
-
if (!isArray(this.data)) {
|
|
2281
|
-
markNodeData(this, this.data);
|
|
2282
|
-
}
|
|
2283
|
-
if (!this.data)
|
|
2284
|
-
return;
|
|
2285
|
-
const defaultExpandedKeys = store.defaultExpandedKeys;
|
|
2286
|
-
const key = store.key;
|
|
2287
|
-
if (key && !isNil(this.key) && defaultExpandedKeys && defaultExpandedKeys.includes(this.key)) {
|
|
2288
|
-
this.expand(null, store.autoExpandParent);
|
|
2289
|
-
}
|
|
2290
|
-
if (key && store.currentNodeKey !== void 0 && this.key === store.currentNodeKey) {
|
|
2291
|
-
store.currentNode && (store.currentNode.isCurrent = false);
|
|
2292
|
-
store.currentNode = this;
|
|
2293
|
-
store.currentNode.isCurrent = true;
|
|
2294
|
-
}
|
|
2295
|
-
if (store.lazy) {
|
|
2296
|
-
store._initDefaultCheckedNode(this);
|
|
2297
|
-
}
|
|
2298
|
-
this.updateLeafState();
|
|
2299
|
-
if (this.level === 1 || ((_a = this.parent) == null ? void 0 : _a.expanded) === true)
|
|
2300
|
-
this.canFocus = true;
|
|
2301
|
-
}
|
|
2302
|
-
setData(data) {
|
|
2303
|
-
if (!isArray(data)) {
|
|
2304
|
-
markNodeData(this, data);
|
|
2305
|
-
}
|
|
2306
|
-
this.data = data;
|
|
2307
|
-
this.childNodes = [];
|
|
2308
|
-
let children;
|
|
2309
|
-
if (this.level === 0 && isArray(this.data)) {
|
|
2310
|
-
children = this.data;
|
|
2311
|
-
} else {
|
|
2312
|
-
children = getPropertyFromData(this, "children") || [];
|
|
2313
|
-
}
|
|
2314
|
-
for (let i = 0, j = children.length; i < j; i++) {
|
|
2315
|
-
this.insertChild({ data: children[i] });
|
|
2316
|
-
}
|
|
2317
|
-
}
|
|
2318
|
-
get label() {
|
|
2319
|
-
return getPropertyFromData(this, "label");
|
|
2320
|
-
}
|
|
2321
|
-
get key() {
|
|
2322
|
-
const nodeKey = this.store.key;
|
|
2323
|
-
if (this.data)
|
|
2324
|
-
return this.data[nodeKey];
|
|
2325
|
-
return null;
|
|
2326
|
-
}
|
|
2327
|
-
get disabled() {
|
|
2328
|
-
return getPropertyFromData(this, "disabled");
|
|
2329
|
-
}
|
|
2330
|
-
get nextSibling() {
|
|
2331
|
-
const parent = this.parent;
|
|
2332
|
-
if (parent) {
|
|
2333
|
-
const index = parent.childNodes.indexOf(this);
|
|
2334
|
-
if (index > -1) {
|
|
2335
|
-
return parent.childNodes[index + 1];
|
|
2336
|
-
}
|
|
2337
|
-
}
|
|
2338
|
-
return null;
|
|
2339
|
-
}
|
|
2340
|
-
get previousSibling() {
|
|
2341
|
-
const parent = this.parent;
|
|
2342
|
-
if (parent) {
|
|
2343
|
-
const index = parent.childNodes.indexOf(this);
|
|
2344
|
-
if (index > -1) {
|
|
2345
|
-
return index > 0 ? parent.childNodes[index - 1] : null;
|
|
2346
|
-
}
|
|
2347
|
-
}
|
|
2348
|
-
return null;
|
|
2349
|
-
}
|
|
2350
|
-
contains(target, deep = true) {
|
|
2351
|
-
return (this.childNodes || []).some(
|
|
2352
|
-
(child) => child === target || deep && child.contains(target)
|
|
2353
|
-
);
|
|
2354
|
-
}
|
|
2355
|
-
remove() {
|
|
2356
|
-
const parent = this.parent;
|
|
2357
|
-
if (parent) {
|
|
2358
|
-
parent.removeChild(this);
|
|
2359
|
-
}
|
|
2360
|
-
}
|
|
2361
|
-
insertChild(child, index, batch) {
|
|
2362
|
-
if (!child)
|
|
2363
|
-
throw new Error("InsertChild error: child is required.");
|
|
2364
|
-
if (!(child instanceof Node)) {
|
|
2365
|
-
if (!batch) {
|
|
2366
|
-
const children = this.getChildren(true);
|
|
2367
|
-
if (!(children == null ? void 0 : children.includes(child.data))) {
|
|
2368
|
-
if (isUndefined(index) || index < 0) {
|
|
2369
|
-
children == null ? void 0 : children.push(child.data);
|
|
2370
|
-
} else {
|
|
2371
|
-
children == null ? void 0 : children.splice(index, 0, child.data);
|
|
2372
|
-
}
|
|
2373
|
-
}
|
|
2374
|
-
}
|
|
2375
|
-
Object.assign(child, {
|
|
2376
|
-
parent: this,
|
|
2377
|
-
store: this.store
|
|
2378
|
-
});
|
|
2379
|
-
child = reactive(new Node(child));
|
|
2380
|
-
if (child instanceof Node) {
|
|
2381
|
-
child.initialize();
|
|
2382
|
-
}
|
|
2383
|
-
}
|
|
2384
|
-
child.level = this.level + 1;
|
|
2385
|
-
if (isUndefined(index) || index < 0) {
|
|
2386
|
-
this.childNodes.push(child);
|
|
2387
|
-
} else {
|
|
2388
|
-
this.childNodes.splice(index, 0, child);
|
|
2389
|
-
}
|
|
2390
|
-
this.updateLeafState();
|
|
2391
|
-
}
|
|
2392
|
-
insertBefore(child, ref) {
|
|
2393
|
-
let index;
|
|
2394
|
-
if (ref) {
|
|
2395
|
-
index = this.childNodes.indexOf(ref);
|
|
2396
|
-
}
|
|
2397
|
-
this.insertChild(child, index);
|
|
2398
|
-
}
|
|
2399
|
-
insertAfter(child, ref) {
|
|
2400
|
-
let index;
|
|
2401
|
-
if (ref) {
|
|
2402
|
-
index = this.childNodes.indexOf(ref);
|
|
2403
|
-
if (index !== -1)
|
|
2404
|
-
index += 1;
|
|
2405
|
-
}
|
|
2406
|
-
this.insertChild(child, index);
|
|
2407
|
-
}
|
|
2408
|
-
removeChild(child) {
|
|
2409
|
-
const children = this.getChildren() || [];
|
|
2410
|
-
const dataIndex = children.indexOf(child.data);
|
|
2411
|
-
if (dataIndex > -1) {
|
|
2412
|
-
children.splice(dataIndex, 1);
|
|
2413
|
-
}
|
|
2414
|
-
const index = this.childNodes.indexOf(child);
|
|
2415
|
-
if (index > -1) {
|
|
2416
|
-
this.store && this.store.deregisterNode(child);
|
|
2417
|
-
child.parent = null;
|
|
2418
|
-
this.childNodes.splice(index, 1);
|
|
2419
|
-
}
|
|
2420
|
-
this.updateLeafState();
|
|
2421
|
-
}
|
|
2422
|
-
removeChildByData(data) {
|
|
2423
|
-
const targetNode = this.childNodes.find((child) => child.data === data);
|
|
2424
|
-
if (targetNode) {
|
|
2425
|
-
this.removeChild(targetNode);
|
|
2426
|
-
}
|
|
2427
|
-
}
|
|
2428
|
-
expand(callback, expandParent) {
|
|
2429
|
-
const done = () => {
|
|
2430
|
-
if (expandParent) {
|
|
2431
|
-
let parent = this.parent;
|
|
2432
|
-
while (parent && parent.level > 0) {
|
|
2433
|
-
parent.expanded = true;
|
|
2434
|
-
parent = parent.parent;
|
|
2435
|
-
}
|
|
2436
|
-
}
|
|
2437
|
-
this.expanded = true;
|
|
2438
|
-
if (callback)
|
|
2439
|
-
callback();
|
|
2440
|
-
setCanFocus(this.childNodes, true);
|
|
2441
|
-
};
|
|
2442
|
-
if (this.shouldLoadData()) {
|
|
2443
|
-
this.loadData((data) => {
|
|
2444
|
-
if (isArray(data)) {
|
|
2445
|
-
if (this.checked) {
|
|
2446
|
-
this.setChecked(true, true);
|
|
2447
|
-
} else if (!this.store.checkStrictly) {
|
|
2448
|
-
reInitChecked(this);
|
|
2449
|
-
}
|
|
2450
|
-
done();
|
|
2451
|
-
}
|
|
2452
|
-
});
|
|
2453
|
-
} else {
|
|
2454
|
-
done();
|
|
2455
|
-
}
|
|
2456
|
-
}
|
|
2457
|
-
doCreateChildren(array, defaultProps = {}) {
|
|
2458
|
-
array.forEach((item) => {
|
|
2459
|
-
this.insertChild(
|
|
2460
|
-
Object.assign({ data: item }, defaultProps),
|
|
2461
|
-
void 0,
|
|
2462
|
-
true
|
|
2463
|
-
);
|
|
2464
|
-
});
|
|
2465
|
-
}
|
|
2466
|
-
collapse() {
|
|
2467
|
-
this.expanded = false;
|
|
2468
|
-
setCanFocus(this.childNodes, false);
|
|
2469
|
-
}
|
|
2470
|
-
shouldLoadData() {
|
|
2471
|
-
return Boolean(this.store.lazy === true && this.store.load && !this.loaded);
|
|
2472
|
-
}
|
|
2473
|
-
updateLeafState() {
|
|
2474
|
-
if (this.store.lazy === true && this.loaded !== true && typeof this.isLeafByUser !== "undefined") {
|
|
2475
|
-
this.isLeaf = this.isLeafByUser;
|
|
2476
|
-
this.isEffectivelyChecked = this.isLeaf && this.disabled;
|
|
2477
|
-
return;
|
|
2478
|
-
}
|
|
2479
|
-
const childNodes = this.childNodes;
|
|
2480
|
-
if (!this.store.lazy || this.store.lazy === true && this.loaded === true) {
|
|
2481
|
-
this.isLeaf = !childNodes || childNodes.length === 0;
|
|
2482
|
-
this.isEffectivelyChecked = this.isLeaf && this.disabled;
|
|
2483
|
-
return;
|
|
2484
|
-
}
|
|
2485
|
-
this.isLeaf = false;
|
|
2486
|
-
}
|
|
2487
|
-
setChecked(value, deep, recursion, passValue) {
|
|
2488
|
-
this.indeterminate = value === "half";
|
|
2489
|
-
this.checked = value === true;
|
|
2490
|
-
this.isEffectivelyChecked = !this.childNodes.length && (this.disabled || this.checked);
|
|
2491
|
-
if (this.store.checkStrictly)
|
|
2492
|
-
return;
|
|
2493
|
-
if (!(this.shouldLoadData() && !this.store.checkDescendants)) {
|
|
2494
|
-
const handleDescendants = () => {
|
|
2495
|
-
if (deep) {
|
|
2496
|
-
const childNodes = this.childNodes;
|
|
2497
|
-
for (let i = 0, j = childNodes.length; i < j; i++) {
|
|
2498
|
-
const child = childNodes[i];
|
|
2499
|
-
passValue = passValue || value !== false;
|
|
2500
|
-
const isCheck = child.disabled && child.isLeaf ? child.checked : passValue;
|
|
2501
|
-
child.setChecked(isCheck, deep, true, passValue);
|
|
2502
|
-
}
|
|
2503
|
-
const { half, all, isEffectivelyChecked } = getChildState(childNodes);
|
|
2504
|
-
if (!all) {
|
|
2505
|
-
this.checked = all;
|
|
2506
|
-
this.indeterminate = half;
|
|
2507
|
-
}
|
|
2508
|
-
this.isEffectivelyChecked = !this.childNodes.length ? this.disabled || this.checked : isEffectivelyChecked;
|
|
2509
|
-
}
|
|
2510
|
-
};
|
|
2511
|
-
if (this.shouldLoadData()) {
|
|
2512
|
-
this.loadData(
|
|
2513
|
-
() => {
|
|
2514
|
-
handleDescendants();
|
|
2515
|
-
reInitChecked(this);
|
|
2516
|
-
},
|
|
2517
|
-
{
|
|
2518
|
-
checked: value !== false
|
|
2519
|
-
}
|
|
2520
|
-
);
|
|
2521
|
-
return;
|
|
2522
|
-
} else {
|
|
2523
|
-
handleDescendants();
|
|
2524
|
-
}
|
|
2525
|
-
}
|
|
2526
|
-
const parent = this.parent;
|
|
2527
|
-
if (!parent || parent.level === 0)
|
|
2528
|
-
return;
|
|
2529
|
-
if (!recursion) {
|
|
2530
|
-
reInitChecked(parent);
|
|
2531
|
-
}
|
|
2532
|
-
}
|
|
2533
|
-
getChildren(forceInit = false) {
|
|
2534
|
-
if (this.level === 0)
|
|
2535
|
-
return this.data;
|
|
2536
|
-
const data = this.data;
|
|
2537
|
-
if (!data)
|
|
2538
|
-
return null;
|
|
2539
|
-
const props = this.store.props;
|
|
2540
|
-
let children = "children";
|
|
2541
|
-
if (props) {
|
|
2542
|
-
children = props.children || "children";
|
|
2543
|
-
}
|
|
2544
|
-
if (isUndefined(data[children])) {
|
|
2545
|
-
data[children] = null;
|
|
2546
|
-
}
|
|
2547
|
-
if (forceInit && !data[children]) {
|
|
2548
|
-
data[children] = [];
|
|
2549
|
-
}
|
|
2550
|
-
return data[children];
|
|
2551
|
-
}
|
|
2552
|
-
updateChildren() {
|
|
2553
|
-
const newData = this.getChildren() || [];
|
|
2554
|
-
const oldData = this.childNodes.map((node) => node.data);
|
|
2555
|
-
const newDataMap = {};
|
|
2556
|
-
const newNodes = [];
|
|
2557
|
-
newData.forEach((item, index) => {
|
|
2558
|
-
const key = item[NODE_KEY];
|
|
2559
|
-
const isNodeExists = !!key && oldData.some((data) => (data == null ? void 0 : data[NODE_KEY]) === key);
|
|
2560
|
-
if (isNodeExists) {
|
|
2561
|
-
newDataMap[key] = { index, data: item };
|
|
2562
|
-
} else {
|
|
2563
|
-
newNodes.push({ index, data: item });
|
|
2564
|
-
}
|
|
2565
|
-
});
|
|
2566
|
-
if (!this.store.lazy) {
|
|
2567
|
-
oldData.forEach((item) => {
|
|
2568
|
-
if (!newDataMap[item == null ? void 0 : item[NODE_KEY]])
|
|
2569
|
-
this.removeChildByData(item);
|
|
2570
|
-
});
|
|
2571
|
-
}
|
|
2572
|
-
newNodes.forEach(({ index, data }) => {
|
|
2573
|
-
this.insertChild({ data }, index);
|
|
2574
|
-
});
|
|
2575
|
-
this.updateLeafState();
|
|
2576
|
-
}
|
|
2577
|
-
loadData(callback, defaultProps = {}) {
|
|
2578
|
-
if (this.store.lazy === true && this.store.load && !this.loaded && (!this.loading || Object.keys(defaultProps).length)) {
|
|
2579
|
-
this.loading = true;
|
|
2580
|
-
const resolve = (children) => {
|
|
2581
|
-
this.childNodes = [];
|
|
2582
|
-
this.doCreateChildren(children, defaultProps);
|
|
2583
|
-
this.loaded = true;
|
|
2584
|
-
this.loading = false;
|
|
2585
|
-
this.updateLeafState();
|
|
2586
|
-
if (callback) {
|
|
2587
|
-
callback.call(this, children);
|
|
2588
|
-
}
|
|
2589
|
-
};
|
|
2590
|
-
const reject = () => {
|
|
2591
|
-
this.loading = false;
|
|
2592
|
-
};
|
|
2593
|
-
this.store.load(this, resolve, reject);
|
|
2594
|
-
} else {
|
|
2595
|
-
if (callback) {
|
|
2596
|
-
callback.call(this);
|
|
2597
|
-
}
|
|
2598
|
-
}
|
|
2599
|
-
}
|
|
2600
|
-
eachNode(callback) {
|
|
2601
|
-
const arr = [this];
|
|
2602
|
-
while (arr.length) {
|
|
2603
|
-
const node = arr.shift();
|
|
2604
|
-
arr.unshift(...node.childNodes);
|
|
2605
|
-
callback(node);
|
|
2606
|
-
}
|
|
2607
|
-
}
|
|
2608
|
-
reInitChecked() {
|
|
2609
|
-
if (this.store.checkStrictly)
|
|
2610
|
-
return;
|
|
2611
|
-
reInitChecked(this);
|
|
2612
|
-
}
|
|
2613
|
-
}
|
|
2614
|
-
|
|
2615
|
-
class TreeStore {
|
|
2616
|
-
constructor(options) {
|
|
2617
|
-
this.lazy = false;
|
|
2618
|
-
this.checkStrictly = false;
|
|
2619
|
-
this.autoExpandParent = false;
|
|
2620
|
-
this.defaultExpandAll = false;
|
|
2621
|
-
this.checkDescendants = false;
|
|
2622
|
-
this.currentNode = null;
|
|
2623
|
-
this.currentNodeKey = null;
|
|
2624
|
-
for (const option in options) {
|
|
2625
|
-
if (hasOwn(options, option)) {
|
|
2626
|
-
this[option] = options[option];
|
|
2627
|
-
}
|
|
2628
|
-
}
|
|
2629
|
-
this.nodesMap = {};
|
|
2630
|
-
}
|
|
2631
|
-
initialize() {
|
|
2632
|
-
this.root = new Node({
|
|
2633
|
-
data: this.data,
|
|
2634
|
-
store: this
|
|
2635
|
-
});
|
|
2636
|
-
this.root.initialize();
|
|
2637
|
-
if (this.lazy && this.load) {
|
|
2638
|
-
const loadFn = this.load;
|
|
2639
|
-
loadFn(
|
|
2640
|
-
this.root,
|
|
2641
|
-
(data) => {
|
|
2642
|
-
this.root.doCreateChildren(data);
|
|
2643
|
-
this._initDefaultCheckedNodes();
|
|
2644
|
-
},
|
|
2645
|
-
NOOP
|
|
2646
|
-
);
|
|
2647
|
-
} else {
|
|
2648
|
-
this._initDefaultCheckedNodes();
|
|
2649
|
-
}
|
|
2650
|
-
}
|
|
2651
|
-
filter(value) {
|
|
2652
|
-
const filterNodeMethod = this.filterNodeMethod;
|
|
2653
|
-
const lazy = this.lazy;
|
|
2654
|
-
const traverse = async function(node) {
|
|
2655
|
-
const childNodes = node.root ? node.root.childNodes : node.childNodes;
|
|
2656
|
-
for (const [index, child] of childNodes.entries()) {
|
|
2657
|
-
child.visible = !!(filterNodeMethod == null ? void 0 : filterNodeMethod.call(
|
|
2658
|
-
child,
|
|
2659
|
-
value,
|
|
2660
|
-
child.data,
|
|
2661
|
-
child
|
|
2662
|
-
));
|
|
2663
|
-
if (index % 80 === 0 && index > 0) {
|
|
2664
|
-
await nextTick();
|
|
2665
|
-
}
|
|
2666
|
-
await traverse(child);
|
|
2667
|
-
}
|
|
2668
|
-
if (!node.visible && childNodes.length) {
|
|
2669
|
-
let allHidden = true;
|
|
2670
|
-
allHidden = !childNodes.some((child) => child.visible);
|
|
2671
|
-
if (node.root) {
|
|
2672
|
-
node.root.visible = allHidden === false;
|
|
2673
|
-
} else {
|
|
2674
|
-
node.visible = allHidden === false;
|
|
2675
|
-
}
|
|
2676
|
-
}
|
|
2677
|
-
if (!value)
|
|
2678
|
-
return;
|
|
2679
|
-
if (node.visible && !node.isLeaf) {
|
|
2680
|
-
if (!lazy || node.loaded) {
|
|
2681
|
-
node.expand();
|
|
2682
|
-
}
|
|
2683
|
-
}
|
|
2684
|
-
};
|
|
2685
|
-
traverse(this);
|
|
2686
|
-
}
|
|
2687
|
-
setData(newVal) {
|
|
2688
|
-
const instanceChanged = newVal !== this.root.data;
|
|
2689
|
-
if (instanceChanged) {
|
|
2690
|
-
this.nodesMap = {};
|
|
2691
|
-
this.root.setData(newVal);
|
|
2692
|
-
this._initDefaultCheckedNodes();
|
|
2693
|
-
this.setCurrentNodeKey(this.currentNodeKey);
|
|
2694
|
-
} else {
|
|
2695
|
-
this.root.updateChildren();
|
|
2696
|
-
}
|
|
2697
|
-
}
|
|
2698
|
-
getNode(data) {
|
|
2699
|
-
if (data instanceof Node)
|
|
2700
|
-
return data;
|
|
2701
|
-
const key = isObject(data) ? getNodeKey(this.key, data) : data;
|
|
2702
|
-
return this.nodesMap[key] || null;
|
|
2703
|
-
}
|
|
2704
|
-
insertBefore(data, refData) {
|
|
2705
|
-
var _a;
|
|
2706
|
-
const refNode = this.getNode(refData);
|
|
2707
|
-
(_a = refNode.parent) == null ? void 0 : _a.insertBefore({ data }, refNode);
|
|
2708
|
-
}
|
|
2709
|
-
insertAfter(data, refData) {
|
|
2710
|
-
var _a;
|
|
2711
|
-
const refNode = this.getNode(refData);
|
|
2712
|
-
(_a = refNode.parent) == null ? void 0 : _a.insertAfter({ data }, refNode);
|
|
2713
|
-
}
|
|
2714
|
-
remove(data) {
|
|
2715
|
-
const node = this.getNode(data);
|
|
2716
|
-
if (node && node.parent) {
|
|
2717
|
-
if (node === this.currentNode) {
|
|
2718
|
-
this.currentNode = null;
|
|
2719
|
-
}
|
|
2720
|
-
node.parent.removeChild(node);
|
|
2721
|
-
}
|
|
2722
|
-
}
|
|
2723
|
-
append(data, parentData) {
|
|
2724
|
-
const parentNode = !isPropAbsent(parentData) ? this.getNode(parentData) : this.root;
|
|
2725
|
-
if (parentNode) {
|
|
2726
|
-
parentNode.insertChild({ data });
|
|
2727
|
-
}
|
|
2728
|
-
}
|
|
2729
|
-
_initDefaultCheckedNodes() {
|
|
2730
|
-
const defaultCheckedKeys = this.defaultCheckedKeys || [];
|
|
2731
|
-
const nodesMap = this.nodesMap;
|
|
2732
|
-
defaultCheckedKeys.forEach((checkedKey) => {
|
|
2733
|
-
const node = nodesMap[checkedKey];
|
|
2734
|
-
if (node) {
|
|
2735
|
-
node.setChecked(true, !this.checkStrictly);
|
|
2736
|
-
}
|
|
2737
|
-
});
|
|
2738
|
-
}
|
|
2739
|
-
_initDefaultCheckedNode(node) {
|
|
2740
|
-
const defaultCheckedKeys = this.defaultCheckedKeys || [];
|
|
2741
|
-
if (!isNil(node.key) && defaultCheckedKeys.includes(node.key)) {
|
|
2742
|
-
node.setChecked(true, !this.checkStrictly);
|
|
2743
|
-
}
|
|
2744
|
-
}
|
|
2745
|
-
setDefaultCheckedKey(newVal) {
|
|
2746
|
-
if (newVal !== this.defaultCheckedKeys) {
|
|
2747
|
-
this.defaultCheckedKeys = newVal;
|
|
2748
|
-
this._initDefaultCheckedNodes();
|
|
2749
|
-
}
|
|
2750
|
-
}
|
|
2751
|
-
registerNode(node) {
|
|
2752
|
-
const key = this.key;
|
|
2753
|
-
if (!node || !node.data)
|
|
2754
|
-
return;
|
|
2755
|
-
if (!key) {
|
|
2756
|
-
this.nodesMap[node.id] = node;
|
|
2757
|
-
} else {
|
|
2758
|
-
const nodeKey = node.key;
|
|
2759
|
-
if (!isNil(nodeKey))
|
|
2760
|
-
this.nodesMap[nodeKey] = node;
|
|
2761
|
-
}
|
|
2762
|
-
}
|
|
2763
|
-
deregisterNode(node) {
|
|
2764
|
-
const key = this.key;
|
|
2765
|
-
if (!key || !node || !node.data)
|
|
2766
|
-
return;
|
|
2767
|
-
node.childNodes.forEach((child) => {
|
|
2768
|
-
this.deregisterNode(child);
|
|
2769
|
-
});
|
|
2770
|
-
delete this.nodesMap[node.key];
|
|
2771
|
-
}
|
|
2772
|
-
getCheckedNodes(leafOnly = false, includeHalfChecked = false) {
|
|
2773
|
-
const checkedNodes = [];
|
|
2774
|
-
const traverse = function(node) {
|
|
2775
|
-
const childNodes = node.root ? node.root.childNodes : node.childNodes;
|
|
2776
|
-
childNodes.forEach((child) => {
|
|
2777
|
-
if ((child.checked || includeHalfChecked && child.indeterminate) && (!leafOnly || leafOnly && child.isLeaf)) {
|
|
2778
|
-
checkedNodes.push(child.data);
|
|
2779
|
-
}
|
|
2780
|
-
traverse(child);
|
|
2781
|
-
});
|
|
2782
|
-
};
|
|
2783
|
-
traverse(this);
|
|
2784
|
-
return checkedNodes;
|
|
2785
|
-
}
|
|
2786
|
-
getCheckedKeys(leafOnly = false) {
|
|
2787
|
-
return this.getCheckedNodes(leafOnly).map((data) => (data || {})[this.key]);
|
|
2788
|
-
}
|
|
2789
|
-
getHalfCheckedNodes() {
|
|
2790
|
-
const nodes = [];
|
|
2791
|
-
const traverse = function(node) {
|
|
2792
|
-
const childNodes = node.root ? node.root.childNodes : node.childNodes;
|
|
2793
|
-
childNodes.forEach((child) => {
|
|
2794
|
-
if (child.indeterminate) {
|
|
2795
|
-
nodes.push(child.data);
|
|
2796
|
-
}
|
|
2797
|
-
traverse(child);
|
|
2798
|
-
});
|
|
2799
|
-
};
|
|
2800
|
-
traverse(this);
|
|
2801
|
-
return nodes;
|
|
2802
|
-
}
|
|
2803
|
-
getHalfCheckedKeys() {
|
|
2804
|
-
return this.getHalfCheckedNodes().map((data) => (data || {})[this.key]);
|
|
2805
|
-
}
|
|
2806
|
-
_getAllNodes() {
|
|
2807
|
-
const allNodes = [];
|
|
2808
|
-
const nodesMap = this.nodesMap;
|
|
2809
|
-
for (const nodeKey in nodesMap) {
|
|
2810
|
-
if (hasOwn(nodesMap, nodeKey)) {
|
|
2811
|
-
allNodes.push(nodesMap[nodeKey]);
|
|
2812
|
-
}
|
|
2813
|
-
}
|
|
2814
|
-
return allNodes;
|
|
2815
|
-
}
|
|
2816
|
-
updateChildren(key, data) {
|
|
2817
|
-
const node = this.nodesMap[key];
|
|
2818
|
-
if (!node)
|
|
2819
|
-
return;
|
|
2820
|
-
const childNodes = node.childNodes;
|
|
2821
|
-
for (let i = childNodes.length - 1; i >= 0; i--) {
|
|
2822
|
-
const child = childNodes[i];
|
|
2823
|
-
this.remove(child.data);
|
|
2824
|
-
}
|
|
2825
|
-
for (let i = 0, j = data.length; i < j; i++) {
|
|
2826
|
-
const child = data[i];
|
|
2827
|
-
this.append(child, node.data);
|
|
2828
|
-
}
|
|
2829
|
-
}
|
|
2830
|
-
_setCheckedKeys(key, leafOnly = false, checkedKeys) {
|
|
2831
|
-
const allNodes = this._getAllNodes().sort((a, b) => a.level - b.level);
|
|
2832
|
-
const cache = /* @__PURE__ */ Object.create(null);
|
|
2833
|
-
const keys = Object.keys(checkedKeys);
|
|
2834
|
-
allNodes.forEach((node) => node.setChecked(false, false));
|
|
2835
|
-
const cacheCheckedChild = (node) => {
|
|
2836
|
-
node.childNodes.forEach((child) => {
|
|
2837
|
-
var _a;
|
|
2838
|
-
cache[child.data[key]] = true;
|
|
2839
|
-
if ((_a = child.childNodes) == null ? void 0 : _a.length) {
|
|
2840
|
-
cacheCheckedChild(child);
|
|
2841
|
-
}
|
|
2842
|
-
});
|
|
2843
|
-
};
|
|
2844
|
-
for (let i = 0, j = allNodes.length; i < j; i++) {
|
|
2845
|
-
const node = allNodes[i];
|
|
2846
|
-
const nodeKey = node.data[key].toString();
|
|
2847
|
-
const checked = keys.includes(nodeKey);
|
|
2848
|
-
if (!checked) {
|
|
2849
|
-
if (node.checked && !cache[nodeKey]) {
|
|
2850
|
-
node.setChecked(false, false);
|
|
2851
|
-
}
|
|
2852
|
-
continue;
|
|
2853
|
-
}
|
|
2854
|
-
if (node.childNodes.length) {
|
|
2855
|
-
cacheCheckedChild(node);
|
|
2856
|
-
}
|
|
2857
|
-
if (node.isLeaf || this.checkStrictly) {
|
|
2858
|
-
node.setChecked(true, false);
|
|
2859
|
-
continue;
|
|
2860
|
-
}
|
|
2861
|
-
node.setChecked(true, true);
|
|
2862
|
-
if (leafOnly) {
|
|
2863
|
-
node.setChecked(false, false);
|
|
2864
|
-
const traverse = function(node2) {
|
|
2865
|
-
const childNodes = node2.childNodes;
|
|
2866
|
-
childNodes.forEach((child) => {
|
|
2867
|
-
if (!child.isLeaf) {
|
|
2868
|
-
child.setChecked(false, false);
|
|
2869
|
-
}
|
|
2870
|
-
traverse(child);
|
|
2871
|
-
});
|
|
2872
|
-
};
|
|
2873
|
-
traverse(node);
|
|
2874
|
-
}
|
|
2875
|
-
}
|
|
2876
|
-
}
|
|
2877
|
-
setCheckedNodes(array, leafOnly = false) {
|
|
2878
|
-
const key = this.key;
|
|
2879
|
-
const checkedKeys = {};
|
|
2880
|
-
array.forEach((item) => {
|
|
2881
|
-
checkedKeys[(item || {})[key]] = true;
|
|
2882
|
-
});
|
|
2883
|
-
this._setCheckedKeys(key, leafOnly, checkedKeys);
|
|
2884
|
-
}
|
|
2885
|
-
setCheckedKeys(keys, leafOnly = false) {
|
|
2886
|
-
this.defaultCheckedKeys = keys;
|
|
2887
|
-
const key = this.key;
|
|
2888
|
-
const checkedKeys = {};
|
|
2889
|
-
keys.forEach((key2) => {
|
|
2890
|
-
checkedKeys[key2] = true;
|
|
2891
|
-
});
|
|
2892
|
-
this._setCheckedKeys(key, leafOnly, checkedKeys);
|
|
2893
|
-
}
|
|
2894
|
-
setDefaultExpandedKeys(keys) {
|
|
2895
|
-
keys = keys || [];
|
|
2896
|
-
this.defaultExpandedKeys = keys;
|
|
2897
|
-
keys.forEach((key) => {
|
|
2898
|
-
const node = this.getNode(key);
|
|
2899
|
-
if (node)
|
|
2900
|
-
node.expand(null, this.autoExpandParent);
|
|
2901
|
-
});
|
|
2902
|
-
}
|
|
2903
|
-
setChecked(data, checked, deep) {
|
|
2904
|
-
const node = this.getNode(data);
|
|
2905
|
-
if (node) {
|
|
2906
|
-
node.setChecked(!!checked, deep);
|
|
2907
|
-
}
|
|
2908
|
-
}
|
|
2909
|
-
getCurrentNode() {
|
|
2910
|
-
return this.currentNode;
|
|
2911
|
-
}
|
|
2912
|
-
setCurrentNode(currentNode) {
|
|
2913
|
-
const prevCurrentNode = this.currentNode;
|
|
2914
|
-
if (prevCurrentNode) {
|
|
2915
|
-
prevCurrentNode.isCurrent = false;
|
|
2916
|
-
}
|
|
2917
|
-
this.currentNode = currentNode;
|
|
2918
|
-
this.currentNode.isCurrent = true;
|
|
2919
|
-
}
|
|
2920
|
-
setUserCurrentNode(node, shouldAutoExpandParent = true) {
|
|
2921
|
-
var _a;
|
|
2922
|
-
const key = node[this.key];
|
|
2923
|
-
const currNode = this.nodesMap[key];
|
|
2924
|
-
this.setCurrentNode(currNode);
|
|
2925
|
-
if (shouldAutoExpandParent && this.currentNode && this.currentNode.level > 1) {
|
|
2926
|
-
(_a = this.currentNode.parent) == null ? void 0 : _a.expand(null, true);
|
|
2927
|
-
}
|
|
2928
|
-
}
|
|
2929
|
-
setCurrentNodeKey(key, shouldAutoExpandParent = true) {
|
|
2930
|
-
var _a;
|
|
2931
|
-
this.currentNodeKey = key;
|
|
2932
|
-
if (isPropAbsent(key)) {
|
|
2933
|
-
this.currentNode && (this.currentNode.isCurrent = false);
|
|
2934
|
-
this.currentNode = null;
|
|
2935
|
-
return;
|
|
2936
|
-
}
|
|
2937
|
-
const node = this.getNode(key);
|
|
2938
|
-
if (node) {
|
|
2939
|
-
this.setCurrentNode(node);
|
|
2940
|
-
if (shouldAutoExpandParent && this.currentNode && this.currentNode.level > 1) {
|
|
2941
|
-
(_a = this.currentNode.parent) == null ? void 0 : _a.expand(null, true);
|
|
2942
|
-
}
|
|
2943
|
-
}
|
|
2944
|
-
}
|
|
2945
|
-
}
|
|
2946
|
-
|
|
2947
|
-
const ROOT_TREE_INJECTION_KEY = "RootTree";
|
|
2948
|
-
const NODE_INSTANCE_INJECTION_KEY = "NodeInstance";
|
|
2949
|
-
const TREE_NODE_MAP_INJECTION_KEY = "TreeNodeMap";
|
|
2950
|
-
|
|
2951
|
-
const _sfc_main$3 = defineComponent({
|
|
2952
|
-
name: "ElTreeNodeContent",
|
|
2953
|
-
props: {
|
|
2954
|
-
node: {
|
|
2955
|
-
type: Object,
|
|
2956
|
-
required: true
|
|
2957
|
-
},
|
|
2958
|
-
renderContent: Function
|
|
2959
|
-
},
|
|
2960
|
-
setup(props) {
|
|
2961
|
-
const ns = useNamespace("tree");
|
|
2962
|
-
const nodeInstance = inject(
|
|
2963
|
-
NODE_INSTANCE_INJECTION_KEY
|
|
2964
|
-
);
|
|
2965
|
-
const tree = inject(ROOT_TREE_INJECTION_KEY);
|
|
2966
|
-
return () => {
|
|
2967
|
-
const node = props.node;
|
|
2968
|
-
const { data, store } = node;
|
|
2969
|
-
return props.renderContent ? props.renderContent(h, { _self: nodeInstance, node, data, store }) : renderSlot(tree.ctx.slots, "default", { node, data }, () => [
|
|
2970
|
-
h(
|
|
2971
|
-
ElText,
|
|
2972
|
-
{ tag: "span", truncated: true, class: ns.be("node", "label") },
|
|
2973
|
-
() => [node.label]
|
|
2974
|
-
)
|
|
2975
|
-
]);
|
|
2976
|
-
};
|
|
2977
|
-
}
|
|
2978
|
-
});
|
|
2979
|
-
var NodeContent = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/tree/src/tree-node-content.vue"]]);
|
|
2980
|
-
|
|
2981
|
-
function useNodeExpandEventBroadcast(props) {
|
|
2982
|
-
const parentNodeMap = inject(
|
|
2983
|
-
TREE_NODE_MAP_INJECTION_KEY,
|
|
2984
|
-
null
|
|
2985
|
-
);
|
|
2986
|
-
let currentNodeMap = {
|
|
2987
|
-
treeNodeExpand: (node) => {
|
|
2988
|
-
var _a;
|
|
2989
|
-
if (props.node !== node) {
|
|
2990
|
-
(_a = props.node) == null ? void 0 : _a.collapse();
|
|
2991
|
-
}
|
|
2992
|
-
},
|
|
2993
|
-
children: /* @__PURE__ */ new Set()
|
|
2994
|
-
};
|
|
2995
|
-
if (parentNodeMap) {
|
|
2996
|
-
parentNodeMap.children.add(currentNodeMap);
|
|
2997
|
-
}
|
|
2998
|
-
onBeforeUnmount(() => {
|
|
2999
|
-
if (parentNodeMap) {
|
|
3000
|
-
parentNodeMap.children.delete(currentNodeMap);
|
|
3001
|
-
}
|
|
3002
|
-
currentNodeMap = null;
|
|
3003
|
-
});
|
|
3004
|
-
provide(TREE_NODE_MAP_INJECTION_KEY, currentNodeMap);
|
|
3005
|
-
return {
|
|
3006
|
-
broadcastExpanded: (node) => {
|
|
3007
|
-
if (!props.accordion)
|
|
3008
|
-
return;
|
|
3009
|
-
for (const childNode of currentNodeMap.children) {
|
|
3010
|
-
childNode.treeNodeExpand(node);
|
|
3011
|
-
}
|
|
3012
|
-
}
|
|
3013
|
-
};
|
|
3014
|
-
}
|
|
3015
|
-
|
|
3016
|
-
const dragEventsKey = Symbol("dragEvents");
|
|
3017
|
-
function useDragNodeHandler({
|
|
3018
|
-
props,
|
|
3019
|
-
ctx,
|
|
3020
|
-
el$,
|
|
3021
|
-
dropIndicator$,
|
|
3022
|
-
store
|
|
3023
|
-
}) {
|
|
3024
|
-
const ns = useNamespace("tree");
|
|
3025
|
-
const dragState = ref({
|
|
3026
|
-
showDropIndicator: false,
|
|
3027
|
-
draggingNode: null,
|
|
3028
|
-
dropNode: null,
|
|
3029
|
-
allowDrop: true,
|
|
3030
|
-
dropType: null
|
|
3031
|
-
});
|
|
3032
|
-
const treeNodeDragStart = ({ event, treeNode }) => {
|
|
3033
|
-
if (!event.dataTransfer)
|
|
3034
|
-
return;
|
|
3035
|
-
if (isFunction(props.allowDrag) && !props.allowDrag(treeNode.node)) {
|
|
3036
|
-
event.preventDefault();
|
|
3037
|
-
return false;
|
|
3038
|
-
}
|
|
3039
|
-
event.dataTransfer.effectAllowed = "move";
|
|
3040
|
-
try {
|
|
3041
|
-
event.dataTransfer.setData("text/plain", "");
|
|
3042
|
-
} catch (e) {
|
|
3043
|
-
}
|
|
3044
|
-
dragState.value.draggingNode = treeNode;
|
|
3045
|
-
ctx.emit("node-drag-start", treeNode.node, event);
|
|
3046
|
-
};
|
|
3047
|
-
const treeNodeDragOver = ({ event, treeNode }) => {
|
|
3048
|
-
if (!event.dataTransfer)
|
|
3049
|
-
return;
|
|
3050
|
-
const dropNode = treeNode;
|
|
3051
|
-
const oldDropNode = dragState.value.dropNode;
|
|
3052
|
-
if (oldDropNode && oldDropNode.node.id !== dropNode.node.id) {
|
|
3053
|
-
removeClass(oldDropNode.$el, ns.is("drop-inner"));
|
|
3054
|
-
}
|
|
3055
|
-
const draggingNode = dragState.value.draggingNode;
|
|
3056
|
-
if (!draggingNode || !dropNode)
|
|
3057
|
-
return;
|
|
3058
|
-
let dropPrev = true;
|
|
3059
|
-
let dropInner = true;
|
|
3060
|
-
let dropNext = true;
|
|
3061
|
-
let userAllowDropInner = true;
|
|
3062
|
-
if (isFunction(props.allowDrop)) {
|
|
3063
|
-
dropPrev = props.allowDrop(draggingNode.node, dropNode.node, "prev");
|
|
3064
|
-
userAllowDropInner = dropInner = props.allowDrop(
|
|
3065
|
-
draggingNode.node,
|
|
3066
|
-
dropNode.node,
|
|
3067
|
-
"inner"
|
|
3068
|
-
);
|
|
3069
|
-
dropNext = props.allowDrop(draggingNode.node, dropNode.node, "next");
|
|
3070
|
-
}
|
|
3071
|
-
event.dataTransfer.dropEffect = dropInner || dropPrev || dropNext ? "move" : "none";
|
|
3072
|
-
if ((dropPrev || dropInner || dropNext) && (oldDropNode == null ? void 0 : oldDropNode.node.id) !== dropNode.node.id) {
|
|
3073
|
-
if (oldDropNode) {
|
|
3074
|
-
ctx.emit("node-drag-leave", draggingNode.node, oldDropNode.node, event);
|
|
3075
|
-
}
|
|
3076
|
-
ctx.emit("node-drag-enter", draggingNode.node, dropNode.node, event);
|
|
3077
|
-
}
|
|
3078
|
-
if (dropPrev || dropInner || dropNext) {
|
|
3079
|
-
dragState.value.dropNode = dropNode;
|
|
3080
|
-
} else {
|
|
3081
|
-
dragState.value.dropNode = null;
|
|
3082
|
-
}
|
|
3083
|
-
if (dropNode.node.nextSibling === draggingNode.node) {
|
|
3084
|
-
dropNext = false;
|
|
3085
|
-
}
|
|
3086
|
-
if (dropNode.node.previousSibling === draggingNode.node) {
|
|
3087
|
-
dropPrev = false;
|
|
3088
|
-
}
|
|
3089
|
-
if (dropNode.node.contains(draggingNode.node, false)) {
|
|
3090
|
-
dropInner = false;
|
|
3091
|
-
}
|
|
3092
|
-
if (draggingNode.node === dropNode.node || draggingNode.node.contains(dropNode.node)) {
|
|
3093
|
-
dropPrev = false;
|
|
3094
|
-
dropInner = false;
|
|
3095
|
-
dropNext = false;
|
|
3096
|
-
}
|
|
3097
|
-
const dropEl = dropNode.$el;
|
|
3098
|
-
const targetPosition = dropEl.querySelector(`.${ns.be("node", "content")}`).getBoundingClientRect();
|
|
3099
|
-
const treePosition = el$.value.getBoundingClientRect();
|
|
3100
|
-
const treeScrollTop = el$.value.scrollTop;
|
|
3101
|
-
let dropType;
|
|
3102
|
-
const prevPercent = dropPrev ? dropInner ? 0.25 : dropNext ? 0.45 : 1 : Number.NEGATIVE_INFINITY;
|
|
3103
|
-
const nextPercent = dropNext ? dropInner ? 0.75 : dropPrev ? 0.55 : 0 : Number.POSITIVE_INFINITY;
|
|
3104
|
-
let indicatorTop = -9999;
|
|
3105
|
-
const distance = event.clientY - targetPosition.top;
|
|
3106
|
-
if (distance < targetPosition.height * prevPercent) {
|
|
3107
|
-
dropType = "before";
|
|
3108
|
-
} else if (distance > targetPosition.height * nextPercent) {
|
|
3109
|
-
dropType = "after";
|
|
3110
|
-
} else if (dropInner) {
|
|
3111
|
-
dropType = "inner";
|
|
3112
|
-
} else {
|
|
3113
|
-
dropType = "none";
|
|
3114
|
-
}
|
|
3115
|
-
const iconPosition = dropEl.querySelector(`.${ns.be("node", "expand-icon")}`).getBoundingClientRect();
|
|
3116
|
-
const dropIndicator = dropIndicator$.value;
|
|
3117
|
-
if (dropType === "before") {
|
|
3118
|
-
indicatorTop = iconPosition.top - treePosition.top + treeScrollTop;
|
|
3119
|
-
} else if (dropType === "after") {
|
|
3120
|
-
indicatorTop = iconPosition.bottom - treePosition.top + treeScrollTop;
|
|
3121
|
-
}
|
|
3122
|
-
dropIndicator.style.top = `${indicatorTop}px`;
|
|
3123
|
-
dropIndicator.style.left = `${iconPosition.right - treePosition.left}px`;
|
|
3124
|
-
if (dropType === "inner") {
|
|
3125
|
-
addClass(dropEl, ns.is("drop-inner"));
|
|
3126
|
-
} else {
|
|
3127
|
-
removeClass(dropEl, ns.is("drop-inner"));
|
|
3128
|
-
}
|
|
3129
|
-
dragState.value.showDropIndicator = dropType === "before" || dropType === "after";
|
|
3130
|
-
dragState.value.allowDrop = dragState.value.showDropIndicator || userAllowDropInner;
|
|
3131
|
-
dragState.value.dropType = dropType;
|
|
3132
|
-
ctx.emit("node-drag-over", draggingNode.node, dropNode.node, event);
|
|
3133
|
-
};
|
|
3134
|
-
const treeNodeDragEnd = (event) => {
|
|
3135
|
-
var _a, _b;
|
|
3136
|
-
const { draggingNode, dropType, dropNode } = dragState.value;
|
|
3137
|
-
event.preventDefault();
|
|
3138
|
-
if (event.dataTransfer) {
|
|
3139
|
-
event.dataTransfer.dropEffect = "move";
|
|
3140
|
-
}
|
|
3141
|
-
if ((draggingNode == null ? void 0 : draggingNode.node.data) && dropNode) {
|
|
3142
|
-
const draggingNodeCopy = { data: draggingNode.node.data };
|
|
3143
|
-
if (dropType !== "none") {
|
|
3144
|
-
draggingNode.node.remove();
|
|
3145
|
-
}
|
|
3146
|
-
if (dropType === "before") {
|
|
3147
|
-
(_a = dropNode.node.parent) == null ? void 0 : _a.insertBefore(draggingNodeCopy, dropNode.node);
|
|
3148
|
-
} else if (dropType === "after") {
|
|
3149
|
-
(_b = dropNode.node.parent) == null ? void 0 : _b.insertAfter(draggingNodeCopy, dropNode.node);
|
|
3150
|
-
} else if (dropType === "inner") {
|
|
3151
|
-
dropNode.node.insertChild(draggingNodeCopy);
|
|
3152
|
-
}
|
|
3153
|
-
if (dropType !== "none") {
|
|
3154
|
-
store.value.registerNode(draggingNodeCopy);
|
|
3155
|
-
if (store.value.key) {
|
|
3156
|
-
draggingNode.node.eachNode((node) => {
|
|
3157
|
-
var _a2;
|
|
3158
|
-
(_a2 = store.value.nodesMap[node.data[store.value.key]]) == null ? void 0 : _a2.setChecked(
|
|
3159
|
-
node.checked,
|
|
3160
|
-
!store.value.checkStrictly
|
|
3161
|
-
);
|
|
3162
|
-
});
|
|
3163
|
-
}
|
|
3164
|
-
}
|
|
3165
|
-
removeClass(dropNode.$el, ns.is("drop-inner"));
|
|
3166
|
-
ctx.emit(
|
|
3167
|
-
"node-drag-end",
|
|
3168
|
-
draggingNode.node,
|
|
3169
|
-
dropNode.node,
|
|
3170
|
-
dropType,
|
|
3171
|
-
event
|
|
3172
|
-
);
|
|
3173
|
-
if (dropType !== "none") {
|
|
3174
|
-
ctx.emit(
|
|
3175
|
-
"node-drop",
|
|
3176
|
-
draggingNode.node,
|
|
3177
|
-
dropNode.node,
|
|
3178
|
-
dropType,
|
|
3179
|
-
event
|
|
3180
|
-
);
|
|
3181
|
-
}
|
|
3182
|
-
}
|
|
3183
|
-
if (draggingNode && !dropNode) {
|
|
3184
|
-
ctx.emit("node-drag-end", draggingNode.node, null, dropType, event);
|
|
3185
|
-
}
|
|
3186
|
-
dragState.value.showDropIndicator = false;
|
|
3187
|
-
dragState.value.draggingNode = null;
|
|
3188
|
-
dragState.value.dropNode = null;
|
|
3189
|
-
dragState.value.allowDrop = true;
|
|
3190
|
-
};
|
|
3191
|
-
provide(dragEventsKey, {
|
|
3192
|
-
treeNodeDragStart,
|
|
3193
|
-
treeNodeDragOver,
|
|
3194
|
-
treeNodeDragEnd
|
|
3195
|
-
});
|
|
3196
|
-
return {
|
|
3197
|
-
dragState
|
|
3198
|
-
};
|
|
3199
|
-
}
|
|
3200
|
-
|
|
3201
|
-
const _sfc_main$2 = defineComponent({
|
|
3202
|
-
name: "ElTreeNode",
|
|
3203
|
-
components: {
|
|
3204
|
-
ElCollapseTransition,
|
|
3205
|
-
ElCheckbox,
|
|
3206
|
-
NodeContent,
|
|
3207
|
-
ElIcon,
|
|
3208
|
-
Loading
|
|
3209
|
-
},
|
|
3210
|
-
props: {
|
|
3211
|
-
node: {
|
|
3212
|
-
type: Node,
|
|
3213
|
-
default: () => ({})
|
|
3214
|
-
},
|
|
3215
|
-
props: {
|
|
3216
|
-
type: Object,
|
|
3217
|
-
default: () => ({})
|
|
3218
|
-
},
|
|
3219
|
-
accordion: Boolean,
|
|
3220
|
-
renderContent: Function,
|
|
3221
|
-
renderAfterExpand: Boolean,
|
|
3222
|
-
showCheckbox: Boolean
|
|
3223
|
-
},
|
|
3224
|
-
emits: ["node-expand"],
|
|
3225
|
-
setup(props, ctx) {
|
|
3226
|
-
const ns = useNamespace("tree");
|
|
3227
|
-
const { broadcastExpanded } = useNodeExpandEventBroadcast(props);
|
|
3228
|
-
const tree = inject(ROOT_TREE_INJECTION_KEY);
|
|
3229
|
-
const expanded = ref(false);
|
|
3230
|
-
const childNodeRendered = ref(false);
|
|
3231
|
-
const oldChecked = ref();
|
|
3232
|
-
const oldIndeterminate = ref();
|
|
3233
|
-
const node$ = ref();
|
|
3234
|
-
const dragEvents = inject(dragEventsKey);
|
|
3235
|
-
const instance = getCurrentInstance();
|
|
3236
|
-
provide(NODE_INSTANCE_INJECTION_KEY, instance);
|
|
3237
|
-
if (!tree) {
|
|
3238
|
-
debugWarn("Tree", "Can not find node's tree.");
|
|
3239
|
-
}
|
|
3240
|
-
if (props.node.expanded) {
|
|
3241
|
-
expanded.value = true;
|
|
3242
|
-
childNodeRendered.value = true;
|
|
3243
|
-
}
|
|
3244
|
-
const childrenKey = tree.props.props["children"] || "children";
|
|
3245
|
-
watch(
|
|
3246
|
-
() => {
|
|
3247
|
-
var _a;
|
|
3248
|
-
const children = (_a = props.node.data) == null ? void 0 : _a[childrenKey];
|
|
3249
|
-
return children && [...children];
|
|
3250
|
-
},
|
|
3251
|
-
() => {
|
|
3252
|
-
props.node.updateChildren();
|
|
3253
|
-
}
|
|
3254
|
-
);
|
|
3255
|
-
watch(
|
|
3256
|
-
() => props.node.indeterminate,
|
|
3257
|
-
(val) => {
|
|
3258
|
-
handleSelectChange(props.node.checked, val);
|
|
3259
|
-
}
|
|
3260
|
-
);
|
|
3261
|
-
watch(
|
|
3262
|
-
() => props.node.checked,
|
|
3263
|
-
(val) => {
|
|
3264
|
-
handleSelectChange(val, props.node.indeterminate);
|
|
3265
|
-
}
|
|
3266
|
-
);
|
|
3267
|
-
watch(
|
|
3268
|
-
() => props.node.childNodes.length,
|
|
3269
|
-
() => props.node.reInitChecked()
|
|
3270
|
-
);
|
|
3271
|
-
watch(
|
|
3272
|
-
() => props.node.expanded,
|
|
3273
|
-
(val) => {
|
|
3274
|
-
nextTick(() => expanded.value = val);
|
|
3275
|
-
if (val) {
|
|
3276
|
-
childNodeRendered.value = true;
|
|
3277
|
-
}
|
|
3278
|
-
}
|
|
3279
|
-
);
|
|
3280
|
-
const getNodeKey$1 = (node) => {
|
|
3281
|
-
return getNodeKey(tree.props.nodeKey, node.data);
|
|
3282
|
-
};
|
|
3283
|
-
const getNodeClass = (node) => {
|
|
3284
|
-
const nodeClassFunc = props.props.class;
|
|
3285
|
-
if (!nodeClassFunc) {
|
|
3286
|
-
return {};
|
|
3287
|
-
}
|
|
3288
|
-
let className;
|
|
3289
|
-
if (isFunction(nodeClassFunc)) {
|
|
3290
|
-
const { data } = node;
|
|
3291
|
-
className = nodeClassFunc(data, node);
|
|
3292
|
-
} else {
|
|
3293
|
-
className = nodeClassFunc;
|
|
3294
|
-
}
|
|
3295
|
-
if (isString(className)) {
|
|
3296
|
-
return { [className]: true };
|
|
3297
|
-
} else {
|
|
3298
|
-
return className;
|
|
3299
|
-
}
|
|
3300
|
-
};
|
|
3301
|
-
const handleSelectChange = (checked, indeterminate) => {
|
|
3302
|
-
if (oldChecked.value !== checked || oldIndeterminate.value !== indeterminate) {
|
|
3303
|
-
tree.ctx.emit("check-change", props.node.data, checked, indeterminate);
|
|
3304
|
-
}
|
|
3305
|
-
oldChecked.value = checked;
|
|
3306
|
-
oldIndeterminate.value = indeterminate;
|
|
3307
|
-
};
|
|
3308
|
-
const handleClick = (e) => {
|
|
3309
|
-
handleCurrentChange(tree.store, tree.ctx.emit, () => {
|
|
3310
|
-
var _a;
|
|
3311
|
-
const nodeKeyProp = (_a = tree == null ? void 0 : tree.props) == null ? void 0 : _a.nodeKey;
|
|
3312
|
-
if (nodeKeyProp) {
|
|
3313
|
-
const curNodeKey = getNodeKey$1(props.node);
|
|
3314
|
-
tree.store.value.setCurrentNodeKey(curNodeKey);
|
|
3315
|
-
} else {
|
|
3316
|
-
tree.store.value.setCurrentNode(props.node);
|
|
3317
|
-
}
|
|
3318
|
-
});
|
|
3319
|
-
tree.currentNode.value = props.node;
|
|
3320
|
-
if (tree.props.expandOnClickNode) {
|
|
3321
|
-
handleExpandIconClick();
|
|
3322
|
-
}
|
|
3323
|
-
if ((tree.props.checkOnClickNode || props.node.isLeaf && tree.props.checkOnClickLeaf && props.showCheckbox) && !props.node.disabled) {
|
|
3324
|
-
handleCheckChange(!props.node.checked);
|
|
3325
|
-
}
|
|
3326
|
-
tree.ctx.emit("node-click", props.node.data, props.node, instance, e);
|
|
3327
|
-
};
|
|
3328
|
-
const handleContextMenu = (event) => {
|
|
3329
|
-
var _a;
|
|
3330
|
-
if ((_a = tree.instance.vnode.props) == null ? void 0 : _a["onNodeContextmenu"]) {
|
|
3331
|
-
event.stopPropagation();
|
|
3332
|
-
event.preventDefault();
|
|
3333
|
-
}
|
|
3334
|
-
tree.ctx.emit(
|
|
3335
|
-
"node-contextmenu",
|
|
3336
|
-
event,
|
|
3337
|
-
props.node.data,
|
|
3338
|
-
props.node,
|
|
3339
|
-
instance
|
|
3340
|
-
);
|
|
3341
|
-
};
|
|
3342
|
-
const handleExpandIconClick = () => {
|
|
3343
|
-
if (props.node.isLeaf)
|
|
3344
|
-
return;
|
|
3345
|
-
if (expanded.value) {
|
|
3346
|
-
tree.ctx.emit("node-collapse", props.node.data, props.node, instance);
|
|
3347
|
-
props.node.collapse();
|
|
3348
|
-
} else {
|
|
3349
|
-
props.node.expand(() => {
|
|
3350
|
-
ctx.emit("node-expand", props.node.data, props.node, instance);
|
|
3351
|
-
});
|
|
3352
|
-
}
|
|
3353
|
-
};
|
|
3354
|
-
const handleCheckChange = (value) => {
|
|
3355
|
-
const checkStrictly = tree == null ? void 0 : tree.props.checkStrictly;
|
|
3356
|
-
const childNodes = props.node.childNodes;
|
|
3357
|
-
if (!checkStrictly && childNodes.length) {
|
|
3358
|
-
value = childNodes.some((node) => !node.isEffectivelyChecked);
|
|
3359
|
-
}
|
|
3360
|
-
props.node.setChecked(value, !checkStrictly);
|
|
3361
|
-
nextTick(() => {
|
|
3362
|
-
const store = tree.store.value;
|
|
3363
|
-
tree.ctx.emit("check", props.node.data, {
|
|
3364
|
-
checkedNodes: store.getCheckedNodes(),
|
|
3365
|
-
checkedKeys: store.getCheckedKeys(),
|
|
3366
|
-
halfCheckedNodes: store.getHalfCheckedNodes(),
|
|
3367
|
-
halfCheckedKeys: store.getHalfCheckedKeys()
|
|
3368
|
-
});
|
|
3369
|
-
});
|
|
3370
|
-
};
|
|
3371
|
-
const handleChildNodeExpand = (nodeData, node, instance2) => {
|
|
3372
|
-
broadcastExpanded(node);
|
|
3373
|
-
tree.ctx.emit("node-expand", nodeData, node, instance2);
|
|
3374
|
-
};
|
|
3375
|
-
const handleDragStart = (event) => {
|
|
3376
|
-
if (!tree.props.draggable)
|
|
3377
|
-
return;
|
|
3378
|
-
dragEvents.treeNodeDragStart({ event, treeNode: props });
|
|
3379
|
-
};
|
|
3380
|
-
const handleDragOver = (event) => {
|
|
3381
|
-
event.preventDefault();
|
|
3382
|
-
if (!tree.props.draggable)
|
|
3383
|
-
return;
|
|
3384
|
-
dragEvents.treeNodeDragOver({
|
|
3385
|
-
event,
|
|
3386
|
-
treeNode: { $el: node$.value, node: props.node }
|
|
3387
|
-
});
|
|
3388
|
-
};
|
|
3389
|
-
const handleDrop = (event) => {
|
|
3390
|
-
event.preventDefault();
|
|
3391
|
-
};
|
|
3392
|
-
const handleDragEnd = (event) => {
|
|
3393
|
-
if (!tree.props.draggable)
|
|
3394
|
-
return;
|
|
3395
|
-
dragEvents.treeNodeDragEnd(event);
|
|
3396
|
-
};
|
|
3397
|
-
return {
|
|
3398
|
-
ns,
|
|
3399
|
-
node$,
|
|
3400
|
-
tree,
|
|
3401
|
-
expanded,
|
|
3402
|
-
childNodeRendered,
|
|
3403
|
-
oldChecked,
|
|
3404
|
-
oldIndeterminate,
|
|
3405
|
-
getNodeKey: getNodeKey$1,
|
|
3406
|
-
getNodeClass,
|
|
3407
|
-
handleSelectChange,
|
|
3408
|
-
handleClick,
|
|
3409
|
-
handleContextMenu,
|
|
3410
|
-
handleExpandIconClick,
|
|
3411
|
-
handleCheckChange,
|
|
3412
|
-
handleChildNodeExpand,
|
|
3413
|
-
handleDragStart,
|
|
3414
|
-
handleDragOver,
|
|
3415
|
-
handleDrop,
|
|
3416
|
-
handleDragEnd,
|
|
3417
|
-
CaretRight
|
|
3418
|
-
};
|
|
3419
|
-
}
|
|
3420
|
-
});
|
|
3421
|
-
const _hoisted_1 = ["aria-expanded", "aria-disabled", "aria-checked", "draggable", "data-key"];
|
|
3422
|
-
const _hoisted_2 = ["aria-expanded"];
|
|
3423
|
-
function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3424
|
-
const _component_el_icon = resolveComponent("el-icon");
|
|
3425
|
-
const _component_el_checkbox = resolveComponent("el-checkbox");
|
|
3426
|
-
const _component_loading = resolveComponent("loading");
|
|
3427
|
-
const _component_node_content = resolveComponent("node-content");
|
|
3428
|
-
const _component_el_tree_node = resolveComponent("el-tree-node");
|
|
3429
|
-
const _component_el_collapse_transition = resolveComponent("el-collapse-transition");
|
|
3430
|
-
return withDirectives((openBlock(), createElementBlock("div", {
|
|
3431
|
-
ref: "node$",
|
|
3432
|
-
class: normalizeClass([
|
|
3433
|
-
_ctx.ns.b("node"),
|
|
3434
|
-
_ctx.ns.is("expanded", _ctx.expanded),
|
|
3435
|
-
_ctx.ns.is("current", _ctx.node.isCurrent),
|
|
3436
|
-
_ctx.ns.is("hidden", !_ctx.node.visible),
|
|
3437
|
-
_ctx.ns.is("focusable", !_ctx.node.disabled),
|
|
3438
|
-
_ctx.ns.is("checked", !_ctx.node.disabled && _ctx.node.checked),
|
|
3439
|
-
_ctx.getNodeClass(_ctx.node)
|
|
3440
|
-
]),
|
|
3441
|
-
role: "treeitem",
|
|
3442
|
-
tabindex: "-1",
|
|
3443
|
-
"aria-expanded": _ctx.expanded,
|
|
3444
|
-
"aria-disabled": _ctx.node.disabled,
|
|
3445
|
-
"aria-checked": _ctx.node.checked,
|
|
3446
|
-
draggable: _ctx.tree.props.draggable,
|
|
3447
|
-
"data-key": _ctx.getNodeKey(_ctx.node),
|
|
3448
|
-
onClick: _cache[2] || (_cache[2] = withModifiers((...args) => _ctx.handleClick && _ctx.handleClick(...args), ["stop"])),
|
|
3449
|
-
onContextmenu: _cache[3] || (_cache[3] = (...args) => _ctx.handleContextMenu && _ctx.handleContextMenu(...args)),
|
|
3450
|
-
onDragstart: _cache[4] || (_cache[4] = withModifiers((...args) => _ctx.handleDragStart && _ctx.handleDragStart(...args), ["stop"])),
|
|
3451
|
-
onDragover: _cache[5] || (_cache[5] = withModifiers((...args) => _ctx.handleDragOver && _ctx.handleDragOver(...args), ["stop"])),
|
|
3452
|
-
onDragend: _cache[6] || (_cache[6] = withModifiers((...args) => _ctx.handleDragEnd && _ctx.handleDragEnd(...args), ["stop"])),
|
|
3453
|
-
onDrop: _cache[7] || (_cache[7] = withModifiers((...args) => _ctx.handleDrop && _ctx.handleDrop(...args), ["stop"]))
|
|
3454
|
-
}, [
|
|
3455
|
-
createElementVNode(
|
|
3456
|
-
"div",
|
|
3457
|
-
{
|
|
3458
|
-
class: normalizeClass(_ctx.ns.be("node", "content")),
|
|
3459
|
-
style: normalizeStyle({ paddingLeft: (_ctx.node.level - 1) * _ctx.tree.props.indent + "px" })
|
|
3460
|
-
},
|
|
3461
|
-
[
|
|
3462
|
-
_ctx.tree.props.icon || _ctx.CaretRight ? (openBlock(), createBlock(_component_el_icon, {
|
|
3463
|
-
key: 0,
|
|
3464
|
-
class: normalizeClass([
|
|
3465
|
-
_ctx.ns.be("node", "expand-icon"),
|
|
3466
|
-
_ctx.ns.is("leaf", _ctx.node.isLeaf),
|
|
3467
|
-
{
|
|
3468
|
-
expanded: !_ctx.node.isLeaf && _ctx.expanded
|
|
3469
|
-
}
|
|
3470
|
-
]),
|
|
3471
|
-
onClick: withModifiers(_ctx.handleExpandIconClick, ["stop"])
|
|
3472
|
-
}, {
|
|
3473
|
-
default: withCtx(() => [
|
|
3474
|
-
(openBlock(), createBlock(resolveDynamicComponent(_ctx.tree.props.icon || _ctx.CaretRight)))
|
|
3475
|
-
]),
|
|
3476
|
-
_: 1
|
|
3477
|
-
}, 8, ["class", "onClick"])) : createCommentVNode("v-if", true),
|
|
3478
|
-
_ctx.showCheckbox ? (openBlock(), createBlock(_component_el_checkbox, {
|
|
3479
|
-
key: 1,
|
|
3480
|
-
"model-value": _ctx.node.checked,
|
|
3481
|
-
indeterminate: _ctx.node.indeterminate,
|
|
3482
|
-
disabled: !!_ctx.node.disabled,
|
|
3483
|
-
onClick: _cache[0] || (_cache[0] = withModifiers(() => {
|
|
3484
|
-
}, ["stop"])),
|
|
3485
|
-
onChange: _ctx.handleCheckChange
|
|
3486
|
-
}, null, 8, ["model-value", "indeterminate", "disabled", "onChange"])) : createCommentVNode("v-if", true),
|
|
3487
|
-
_ctx.node.loading ? (openBlock(), createBlock(_component_el_icon, {
|
|
3488
|
-
key: 2,
|
|
3489
|
-
class: normalizeClass([_ctx.ns.be("node", "loading-icon"), _ctx.ns.is("loading")])
|
|
3490
|
-
}, {
|
|
3491
|
-
default: withCtx(() => [
|
|
3492
|
-
createVNode(_component_loading)
|
|
3493
|
-
]),
|
|
3494
|
-
_: 1
|
|
3495
|
-
}, 8, ["class"])) : createCommentVNode("v-if", true),
|
|
3496
|
-
createVNode(_component_node_content, {
|
|
3497
|
-
node: _ctx.node,
|
|
3498
|
-
"render-content": _ctx.renderContent
|
|
3499
|
-
}, null, 8, ["node", "render-content"])
|
|
3500
|
-
],
|
|
3501
|
-
6
|
|
3502
|
-
),
|
|
3503
|
-
createVNode(_component_el_collapse_transition, null, {
|
|
3504
|
-
default: withCtx(() => [
|
|
3505
|
-
!_ctx.renderAfterExpand || _ctx.childNodeRendered ? withDirectives((openBlock(), createElementBlock("div", {
|
|
3506
|
-
key: 0,
|
|
3507
|
-
class: normalizeClass(_ctx.ns.be("node", "children")),
|
|
3508
|
-
role: "group",
|
|
3509
|
-
"aria-expanded": _ctx.expanded,
|
|
3510
|
-
onClick: _cache[1] || (_cache[1] = withModifiers(() => {
|
|
3511
|
-
}, ["stop"]))
|
|
3512
|
-
}, [
|
|
3513
|
-
(openBlock(true), createElementBlock(
|
|
3514
|
-
Fragment,
|
|
3515
|
-
null,
|
|
3516
|
-
renderList(_ctx.node.childNodes, (child) => {
|
|
3517
|
-
return openBlock(), createBlock(_component_el_tree_node, {
|
|
3518
|
-
key: _ctx.getNodeKey(child),
|
|
3519
|
-
"render-content": _ctx.renderContent,
|
|
3520
|
-
"render-after-expand": _ctx.renderAfterExpand,
|
|
3521
|
-
"show-checkbox": _ctx.showCheckbox,
|
|
3522
|
-
node: child,
|
|
3523
|
-
accordion: _ctx.accordion,
|
|
3524
|
-
props: _ctx.props,
|
|
3525
|
-
onNodeExpand: _ctx.handleChildNodeExpand
|
|
3526
|
-
}, null, 8, ["render-content", "render-after-expand", "show-checkbox", "node", "accordion", "props", "onNodeExpand"]);
|
|
3527
|
-
}),
|
|
3528
|
-
128
|
|
3529
|
-
))
|
|
3530
|
-
], 10, _hoisted_2)), [
|
|
3531
|
-
[vShow, _ctx.expanded]
|
|
3532
|
-
]) : createCommentVNode("v-if", true)
|
|
3533
|
-
]),
|
|
3534
|
-
_: 1
|
|
3535
|
-
})
|
|
3536
|
-
], 42, _hoisted_1)), [
|
|
3537
|
-
[vShow, _ctx.node.visible]
|
|
3538
|
-
]);
|
|
3539
|
-
}
|
|
3540
|
-
var ElTreeNode = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["render", _sfc_render$1], ["__file", "/home/runner/work/element-plus/element-plus/packages/components/tree/src/tree-node.vue"]]);
|
|
3541
|
-
|
|
3542
|
-
function useKeydown({ el$ }, store) {
|
|
3543
|
-
const ns = useNamespace("tree");
|
|
3544
|
-
onMounted(() => {
|
|
3545
|
-
initTabIndex();
|
|
3546
|
-
});
|
|
3547
|
-
onUpdated(() => {
|
|
3548
|
-
var _a;
|
|
3549
|
-
(_a = el$.value) == null ? void 0 : _a.querySelectorAll("input[type=checkbox]").forEach((checkbox) => {
|
|
3550
|
-
checkbox.setAttribute("tabindex", "-1");
|
|
3551
|
-
});
|
|
3552
|
-
});
|
|
3553
|
-
function canNodeFocus(treeItems, nextIndex) {
|
|
3554
|
-
var _a, _b;
|
|
3555
|
-
const currentNode = store.value.getNode(treeItems[nextIndex].dataset.key);
|
|
3556
|
-
return currentNode.canFocus && currentNode.visible && (((_a = currentNode.parent) == null ? void 0 : _a.expanded) || ((_b = currentNode.parent) == null ? void 0 : _b.level) === 0);
|
|
3557
|
-
}
|
|
3558
|
-
const handleKeydown = (ev) => {
|
|
3559
|
-
const currentItem = ev.target;
|
|
3560
|
-
if (!currentItem.className.includes(ns.b("node")))
|
|
3561
|
-
return;
|
|
3562
|
-
const code = getEventCode(ev);
|
|
3563
|
-
const treeItems = Array.from(
|
|
3564
|
-
el$.value.querySelectorAll(`.${ns.is("focusable")}[role=treeitem]`)
|
|
3565
|
-
);
|
|
3566
|
-
const currentIndex = treeItems.indexOf(currentItem);
|
|
3567
|
-
let nextIndex;
|
|
3568
|
-
if ([EVENT_CODE.up, EVENT_CODE.down].includes(code)) {
|
|
3569
|
-
ev.preventDefault();
|
|
3570
|
-
if (code === EVENT_CODE.up) {
|
|
3571
|
-
nextIndex = currentIndex === -1 ? 0 : currentIndex !== 0 ? currentIndex - 1 : treeItems.length - 1;
|
|
3572
|
-
const startIndex = nextIndex;
|
|
3573
|
-
while (true) {
|
|
3574
|
-
if (canNodeFocus(treeItems, nextIndex)) {
|
|
3575
|
-
break;
|
|
3576
|
-
}
|
|
3577
|
-
nextIndex--;
|
|
3578
|
-
if (nextIndex === startIndex) {
|
|
3579
|
-
nextIndex = -1;
|
|
3580
|
-
break;
|
|
3581
|
-
}
|
|
3582
|
-
if (nextIndex < 0) {
|
|
3583
|
-
nextIndex = treeItems.length - 1;
|
|
3584
|
-
}
|
|
3585
|
-
}
|
|
3586
|
-
} else {
|
|
3587
|
-
nextIndex = currentIndex === -1 ? 0 : currentIndex < treeItems.length - 1 ? currentIndex + 1 : 0;
|
|
3588
|
-
const startIndex = nextIndex;
|
|
3589
|
-
while (true) {
|
|
3590
|
-
if (canNodeFocus(treeItems, nextIndex)) {
|
|
3591
|
-
break;
|
|
3592
|
-
}
|
|
3593
|
-
nextIndex++;
|
|
3594
|
-
if (nextIndex === startIndex) {
|
|
3595
|
-
nextIndex = -1;
|
|
3596
|
-
break;
|
|
3597
|
-
}
|
|
3598
|
-
if (nextIndex >= treeItems.length) {
|
|
3599
|
-
nextIndex = 0;
|
|
3600
|
-
}
|
|
3601
|
-
}
|
|
3602
|
-
}
|
|
3603
|
-
nextIndex !== -1 && treeItems[nextIndex].focus();
|
|
3604
|
-
}
|
|
3605
|
-
if ([EVENT_CODE.left, EVENT_CODE.right].includes(code)) {
|
|
3606
|
-
ev.preventDefault();
|
|
3607
|
-
currentItem.click();
|
|
3608
|
-
}
|
|
3609
|
-
const hasInput = currentItem.querySelector(
|
|
3610
|
-
'[type="checkbox"]'
|
|
3611
|
-
);
|
|
3612
|
-
if ([EVENT_CODE.enter, EVENT_CODE.numpadEnter, EVENT_CODE.space].includes(
|
|
3613
|
-
code
|
|
3614
|
-
) && hasInput) {
|
|
3615
|
-
ev.preventDefault();
|
|
3616
|
-
hasInput.click();
|
|
3617
|
-
}
|
|
3618
|
-
};
|
|
3619
|
-
useEventListener(el$, "keydown", handleKeydown);
|
|
3620
|
-
const initTabIndex = () => {
|
|
3621
|
-
var _a;
|
|
3622
|
-
if (!el$.value)
|
|
3623
|
-
return;
|
|
3624
|
-
const treeItems = Array.from(
|
|
3625
|
-
el$.value.querySelectorAll(`.${ns.is("focusable")}[role=treeitem]`)
|
|
3626
|
-
);
|
|
3627
|
-
const checkboxItems = Array.from(
|
|
3628
|
-
el$.value.querySelectorAll("input[type=checkbox]")
|
|
3629
|
-
);
|
|
3630
|
-
checkboxItems.forEach((checkbox) => {
|
|
3631
|
-
checkbox.setAttribute("tabindex", "-1");
|
|
3632
|
-
});
|
|
3633
|
-
const checkedItem = el$.value.querySelectorAll(
|
|
3634
|
-
`.${ns.is("checked")}[role=treeitem]`
|
|
3635
|
-
);
|
|
3636
|
-
if (checkedItem.length) {
|
|
3637
|
-
checkedItem[0].setAttribute("tabindex", "0");
|
|
3638
|
-
return;
|
|
3639
|
-
}
|
|
3640
|
-
(_a = treeItems[0]) == null ? void 0 : _a.setAttribute("tabindex", "0");
|
|
3641
|
-
};
|
|
3642
|
-
}
|
|
3643
|
-
|
|
3644
|
-
const treeProps = buildProps({
|
|
3645
|
-
data: {
|
|
3646
|
-
type: definePropType(Array),
|
|
3647
|
-
default: () => []
|
|
3648
|
-
},
|
|
3649
|
-
emptyText: {
|
|
3650
|
-
type: String
|
|
3651
|
-
},
|
|
3652
|
-
renderAfterExpand: {
|
|
3653
|
-
type: Boolean,
|
|
3654
|
-
default: true
|
|
3655
|
-
},
|
|
3656
|
-
nodeKey: String,
|
|
3657
|
-
checkStrictly: Boolean,
|
|
3658
|
-
defaultExpandAll: Boolean,
|
|
3659
|
-
expandOnClickNode: {
|
|
3660
|
-
type: Boolean,
|
|
3661
|
-
default: true
|
|
3662
|
-
},
|
|
3663
|
-
checkOnClickNode: Boolean,
|
|
3664
|
-
checkOnClickLeaf: {
|
|
3665
|
-
type: Boolean,
|
|
3666
|
-
default: true
|
|
3667
|
-
},
|
|
3668
|
-
checkDescendants: Boolean,
|
|
3669
|
-
autoExpandParent: {
|
|
3670
|
-
type: Boolean,
|
|
3671
|
-
default: true
|
|
3672
|
-
},
|
|
3673
|
-
defaultCheckedKeys: {
|
|
3674
|
-
type: Array
|
|
3675
|
-
},
|
|
3676
|
-
defaultExpandedKeys: {
|
|
3677
|
-
type: Array
|
|
3678
|
-
},
|
|
3679
|
-
currentNodeKey: {
|
|
3680
|
-
type: [String, Number]
|
|
3681
|
-
},
|
|
3682
|
-
renderContent: {
|
|
3683
|
-
type: definePropType(Function)
|
|
3684
|
-
},
|
|
3685
|
-
showCheckbox: Boolean,
|
|
3686
|
-
draggable: Boolean,
|
|
3687
|
-
allowDrag: {
|
|
3688
|
-
type: definePropType(Function)
|
|
3689
|
-
},
|
|
3690
|
-
allowDrop: {
|
|
3691
|
-
type: definePropType(Function)
|
|
3692
|
-
},
|
|
3693
|
-
props: {
|
|
3694
|
-
type: Object,
|
|
3695
|
-
default: () => ({
|
|
3696
|
-
children: "children",
|
|
3697
|
-
label: "label",
|
|
3698
|
-
disabled: "disabled"
|
|
3699
|
-
})
|
|
3700
|
-
},
|
|
3701
|
-
lazy: Boolean,
|
|
3702
|
-
highlightCurrent: Boolean,
|
|
3703
|
-
load: {
|
|
3704
|
-
type: Function
|
|
3705
|
-
},
|
|
3706
|
-
filterNodeMethod: {
|
|
3707
|
-
type: Function
|
|
3708
|
-
},
|
|
3709
|
-
accordion: Boolean,
|
|
3710
|
-
indent: {
|
|
3711
|
-
type: Number,
|
|
3712
|
-
default: 18
|
|
3713
|
-
},
|
|
3714
|
-
icon: {
|
|
3715
|
-
type: iconPropType
|
|
3716
|
-
}
|
|
3717
|
-
});
|
|
3718
|
-
const treeEmits = {
|
|
3719
|
-
"check-change": (data, checked, indeterminate) => data && isBoolean(checked) && isBoolean(indeterminate),
|
|
3720
|
-
"current-change": (data, node) => true,
|
|
3721
|
-
"node-click": (data, node, nodeInstance, evt) => data && node && evt instanceof Event,
|
|
3722
|
-
"node-contextmenu": (evt, data, node, nodeInstance) => evt instanceof Event && data && node,
|
|
3723
|
-
"node-collapse": (data, node, nodeInstance) => data && node,
|
|
3724
|
-
"node-expand": (data, node, nodeInstance) => data && node,
|
|
3725
|
-
check: (data, checkedInfo) => data && checkedInfo,
|
|
3726
|
-
"node-drag-start": (node, evt) => node && evt,
|
|
3727
|
-
"node-drag-end": (draggingNode, dropNode, dropType, evt) => draggingNode && evt,
|
|
3728
|
-
"node-drop": (draggingNode, dropNode, dropType, evt) => draggingNode && dropNode && evt,
|
|
3729
|
-
"node-drag-leave": (draggingNode, oldDropNode, evt) => draggingNode && oldDropNode && evt,
|
|
3730
|
-
"node-drag-enter": (draggingNode, dropNode, evt) => draggingNode && dropNode && evt,
|
|
3731
|
-
"node-drag-over": (draggingNode, dropNode, evt) => draggingNode && dropNode && evt
|
|
3732
|
-
};
|
|
3733
|
-
|
|
3734
|
-
const _sfc_main$1 = defineComponent({
|
|
3735
|
-
name: "ElTree",
|
|
3736
|
-
components: { ElTreeNode },
|
|
3737
|
-
props: treeProps,
|
|
3738
|
-
emits: treeEmits,
|
|
3739
|
-
setup(props, ctx) {
|
|
3740
|
-
const { t } = useLocale();
|
|
3741
|
-
const ns = useNamespace("tree");
|
|
3742
|
-
const store = ref(
|
|
3743
|
-
new TreeStore({
|
|
3744
|
-
key: props.nodeKey,
|
|
3745
|
-
data: props.data,
|
|
3746
|
-
lazy: props.lazy,
|
|
3747
|
-
props: props.props,
|
|
3748
|
-
load: props.load,
|
|
3749
|
-
currentNodeKey: props.currentNodeKey,
|
|
3750
|
-
checkStrictly: props.checkStrictly,
|
|
3751
|
-
checkDescendants: props.checkDescendants,
|
|
3752
|
-
defaultCheckedKeys: props.defaultCheckedKeys,
|
|
3753
|
-
defaultExpandedKeys: props.defaultExpandedKeys,
|
|
3754
|
-
autoExpandParent: props.autoExpandParent,
|
|
3755
|
-
defaultExpandAll: props.defaultExpandAll,
|
|
3756
|
-
filterNodeMethod: props.filterNodeMethod
|
|
3757
|
-
})
|
|
3758
|
-
);
|
|
3759
|
-
store.value.initialize();
|
|
3760
|
-
const root = ref(store.value.root);
|
|
3761
|
-
const currentNode = ref(null);
|
|
3762
|
-
const el$ = ref(null);
|
|
3763
|
-
const dropIndicator$ = ref(null);
|
|
3764
|
-
const { broadcastExpanded } = useNodeExpandEventBroadcast(props);
|
|
3765
|
-
const { dragState } = useDragNodeHandler({
|
|
3766
|
-
props,
|
|
3767
|
-
ctx,
|
|
3768
|
-
el$,
|
|
3769
|
-
dropIndicator$,
|
|
3770
|
-
store
|
|
3771
|
-
});
|
|
3772
|
-
useKeydown({ el$ }, store);
|
|
3773
|
-
const instance = getCurrentInstance();
|
|
3774
|
-
const isSelectTree = computed(() => {
|
|
3775
|
-
let parent = instance == null ? void 0 : instance.parent;
|
|
3776
|
-
while (parent) {
|
|
3777
|
-
if (parent.type.name === "ElTreeSelect") {
|
|
3778
|
-
return true;
|
|
3779
|
-
}
|
|
3780
|
-
parent = parent.parent;
|
|
3781
|
-
}
|
|
3782
|
-
return false;
|
|
3783
|
-
});
|
|
3784
|
-
const isEmpty = computed(() => {
|
|
3785
|
-
const { childNodes } = root.value;
|
|
3786
|
-
return (!childNodes || childNodes.length === 0 || childNodes.every(({ visible }) => !visible)) && !isSelectTree.value;
|
|
3787
|
-
});
|
|
3788
|
-
watch(
|
|
3789
|
-
() => props.currentNodeKey,
|
|
3790
|
-
(newVal) => {
|
|
3791
|
-
store.value.setCurrentNodeKey(newVal != null ? newVal : null);
|
|
3792
|
-
}
|
|
3793
|
-
);
|
|
3794
|
-
watch(
|
|
3795
|
-
() => props.defaultCheckedKeys,
|
|
3796
|
-
(newVal, oldVal) => {
|
|
3797
|
-
if (isEqual(newVal, oldVal))
|
|
3798
|
-
return;
|
|
3799
|
-
store.value.setDefaultCheckedKey(newVal != null ? newVal : []);
|
|
3800
|
-
}
|
|
3801
|
-
);
|
|
3802
|
-
watch(
|
|
3803
|
-
() => props.defaultExpandedKeys,
|
|
3804
|
-
(newVal) => {
|
|
3805
|
-
store.value.setDefaultExpandedKeys(newVal != null ? newVal : []);
|
|
3806
|
-
}
|
|
3807
|
-
);
|
|
3808
|
-
watch(
|
|
3809
|
-
() => props.data,
|
|
3810
|
-
(newVal) => {
|
|
3811
|
-
store.value.setData(newVal);
|
|
3812
|
-
},
|
|
3813
|
-
{ deep: true }
|
|
3814
|
-
);
|
|
3815
|
-
watch(
|
|
3816
|
-
() => props.checkStrictly,
|
|
3817
|
-
(newVal) => {
|
|
3818
|
-
store.value.checkStrictly = newVal;
|
|
3819
|
-
}
|
|
3820
|
-
);
|
|
3821
|
-
const filter = (value) => {
|
|
3822
|
-
if (!props.filterNodeMethod)
|
|
3823
|
-
throw new Error("[Tree] filterNodeMethod is required when filter");
|
|
3824
|
-
store.value.filter(value);
|
|
3825
|
-
};
|
|
3826
|
-
const getNodeKey$1 = (node) => {
|
|
3827
|
-
return getNodeKey(props.nodeKey, node.data);
|
|
3828
|
-
};
|
|
3829
|
-
const requireNodeKey = (methodName) => {
|
|
3830
|
-
if (!props.nodeKey) {
|
|
3831
|
-
throw new Error(`[Tree] nodeKey is required in ${methodName}`);
|
|
3832
|
-
}
|
|
3833
|
-
};
|
|
3834
|
-
const getNodePath = (data) => {
|
|
3835
|
-
requireNodeKey("getNodePath");
|
|
3836
|
-
const node = store.value.getNode(data);
|
|
3837
|
-
if (!node)
|
|
3838
|
-
return [];
|
|
3839
|
-
const path = [node.data];
|
|
3840
|
-
let parent = node.parent;
|
|
3841
|
-
while (parent && parent !== root.value) {
|
|
3842
|
-
path.push(parent.data);
|
|
3843
|
-
parent = parent.parent;
|
|
3844
|
-
}
|
|
3845
|
-
return path.reverse();
|
|
3846
|
-
};
|
|
3847
|
-
const getCheckedNodes = (leafOnly, includeHalfChecked) => {
|
|
3848
|
-
return store.value.getCheckedNodes(leafOnly, includeHalfChecked);
|
|
3849
|
-
};
|
|
3850
|
-
const getCheckedKeys = (leafOnly) => {
|
|
3851
|
-
return store.value.getCheckedKeys(leafOnly);
|
|
3852
|
-
};
|
|
3853
|
-
const getCurrentNode = () => {
|
|
3854
|
-
const currentNode2 = store.value.getCurrentNode();
|
|
3855
|
-
return currentNode2 ? currentNode2.data : null;
|
|
3856
|
-
};
|
|
3857
|
-
const getCurrentKey = () => {
|
|
3858
|
-
requireNodeKey("getCurrentKey");
|
|
3859
|
-
const currentNode2 = getCurrentNode();
|
|
3860
|
-
return currentNode2 ? currentNode2[props.nodeKey] : null;
|
|
3861
|
-
};
|
|
3862
|
-
const setCheckedNodes = (nodes, leafOnly) => {
|
|
3863
|
-
requireNodeKey("setCheckedNodes");
|
|
3864
|
-
store.value.setCheckedNodes(nodes, leafOnly);
|
|
3865
|
-
};
|
|
3866
|
-
const setCheckedKeys = (keys, leafOnly) => {
|
|
3867
|
-
requireNodeKey("setCheckedKeys");
|
|
3868
|
-
store.value.setCheckedKeys(keys, leafOnly);
|
|
3869
|
-
};
|
|
3870
|
-
const setChecked = (data, checked, deep) => {
|
|
3871
|
-
store.value.setChecked(data, checked, deep);
|
|
3872
|
-
};
|
|
3873
|
-
const getHalfCheckedNodes = () => {
|
|
3874
|
-
return store.value.getHalfCheckedNodes();
|
|
3875
|
-
};
|
|
3876
|
-
const getHalfCheckedKeys = () => {
|
|
3877
|
-
return store.value.getHalfCheckedKeys();
|
|
3878
|
-
};
|
|
3879
|
-
const setCurrentNode = (node, shouldAutoExpandParent = true) => {
|
|
3880
|
-
requireNodeKey("setCurrentNode");
|
|
3881
|
-
handleCurrentChange(store, ctx.emit, () => {
|
|
3882
|
-
broadcastExpanded(node);
|
|
3883
|
-
store.value.setUserCurrentNode(node, shouldAutoExpandParent);
|
|
3884
|
-
});
|
|
3885
|
-
};
|
|
3886
|
-
const setCurrentKey = (key = null, shouldAutoExpandParent = true) => {
|
|
3887
|
-
requireNodeKey("setCurrentKey");
|
|
3888
|
-
handleCurrentChange(store, ctx.emit, () => {
|
|
3889
|
-
broadcastExpanded();
|
|
3890
|
-
store.value.setCurrentNodeKey(key, shouldAutoExpandParent);
|
|
3891
|
-
});
|
|
3892
|
-
};
|
|
3893
|
-
const getNode = (data) => {
|
|
3894
|
-
return store.value.getNode(data);
|
|
3895
|
-
};
|
|
3896
|
-
const remove = (data) => {
|
|
3897
|
-
store.value.remove(data);
|
|
3898
|
-
};
|
|
3899
|
-
const append = (data, parentNode) => {
|
|
3900
|
-
store.value.append(data, parentNode);
|
|
3901
|
-
};
|
|
3902
|
-
const insertBefore = (data, refNode) => {
|
|
3903
|
-
store.value.insertBefore(data, refNode);
|
|
3904
|
-
};
|
|
3905
|
-
const insertAfter = (data, refNode) => {
|
|
3906
|
-
store.value.insertAfter(data, refNode);
|
|
3907
|
-
};
|
|
3908
|
-
const handleNodeExpand = (nodeData, node, instance2) => {
|
|
3909
|
-
broadcastExpanded(node);
|
|
3910
|
-
ctx.emit("node-expand", nodeData, node, instance2);
|
|
3911
|
-
};
|
|
3912
|
-
const updateKeyChildren = (key, data) => {
|
|
3913
|
-
requireNodeKey("updateKeyChild");
|
|
3914
|
-
store.value.updateChildren(key, data);
|
|
3915
|
-
};
|
|
3916
|
-
provide(ROOT_TREE_INJECTION_KEY, {
|
|
3917
|
-
ctx,
|
|
3918
|
-
props,
|
|
3919
|
-
store,
|
|
3920
|
-
root,
|
|
3921
|
-
currentNode,
|
|
3922
|
-
instance
|
|
3923
|
-
});
|
|
3924
|
-
provide(formItemContextKey, void 0);
|
|
3925
|
-
return {
|
|
3926
|
-
ns,
|
|
3927
|
-
store,
|
|
3928
|
-
root,
|
|
3929
|
-
currentNode,
|
|
3930
|
-
dragState,
|
|
3931
|
-
el$,
|
|
3932
|
-
dropIndicator$,
|
|
3933
|
-
isEmpty,
|
|
3934
|
-
filter,
|
|
3935
|
-
getNodeKey: getNodeKey$1,
|
|
3936
|
-
getNodePath,
|
|
3937
|
-
getCheckedNodes,
|
|
3938
|
-
getCheckedKeys,
|
|
3939
|
-
getCurrentNode,
|
|
3940
|
-
getCurrentKey,
|
|
3941
|
-
setCheckedNodes,
|
|
3942
|
-
setCheckedKeys,
|
|
3943
|
-
setChecked,
|
|
3944
|
-
getHalfCheckedNodes,
|
|
3945
|
-
getHalfCheckedKeys,
|
|
3946
|
-
setCurrentNode,
|
|
3947
|
-
setCurrentKey,
|
|
3948
|
-
t,
|
|
3949
|
-
getNode,
|
|
3950
|
-
remove,
|
|
3951
|
-
append,
|
|
3952
|
-
insertBefore,
|
|
3953
|
-
insertAfter,
|
|
3954
|
-
handleNodeExpand,
|
|
3955
|
-
updateKeyChildren
|
|
3956
|
-
};
|
|
3957
|
-
}
|
|
3958
|
-
});
|
|
3959
|
-
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3960
|
-
const _component_el_tree_node = resolveComponent("el-tree-node");
|
|
3961
|
-
return openBlock(), createElementBlock(
|
|
3962
|
-
"div",
|
|
3963
|
-
{
|
|
3964
|
-
ref: "el$",
|
|
3965
|
-
class: normalizeClass([
|
|
3966
|
-
_ctx.ns.b(),
|
|
3967
|
-
_ctx.ns.is("dragging", !!_ctx.dragState.draggingNode),
|
|
3968
|
-
_ctx.ns.is("drop-not-allow", !_ctx.dragState.allowDrop),
|
|
3969
|
-
_ctx.ns.is("drop-inner", _ctx.dragState.dropType === "inner"),
|
|
3970
|
-
{ [_ctx.ns.m("highlight-current")]: _ctx.highlightCurrent }
|
|
3971
|
-
]),
|
|
3972
|
-
role: "tree"
|
|
3973
|
-
},
|
|
3974
|
-
[
|
|
3975
|
-
(openBlock(true), createElementBlock(
|
|
3976
|
-
Fragment,
|
|
3977
|
-
null,
|
|
3978
|
-
renderList(_ctx.root.childNodes, (child) => {
|
|
3979
|
-
return openBlock(), createBlock(_component_el_tree_node, {
|
|
3980
|
-
key: _ctx.getNodeKey(child),
|
|
3981
|
-
node: child,
|
|
3982
|
-
props: _ctx.props,
|
|
3983
|
-
accordion: _ctx.accordion,
|
|
3984
|
-
"render-after-expand": _ctx.renderAfterExpand,
|
|
3985
|
-
"show-checkbox": _ctx.showCheckbox,
|
|
3986
|
-
"render-content": _ctx.renderContent,
|
|
3987
|
-
onNodeExpand: _ctx.handleNodeExpand
|
|
3988
|
-
}, null, 8, ["node", "props", "accordion", "render-after-expand", "show-checkbox", "render-content", "onNodeExpand"]);
|
|
3989
|
-
}),
|
|
3990
|
-
128
|
|
3991
|
-
)),
|
|
3992
|
-
_ctx.isEmpty ? (openBlock(), createElementBlock(
|
|
3993
|
-
"div",
|
|
3994
|
-
{
|
|
3995
|
-
key: 0,
|
|
3996
|
-
class: normalizeClass(_ctx.ns.e("empty-block"))
|
|
3997
|
-
},
|
|
3998
|
-
[
|
|
3999
|
-
renderSlot(_ctx.$slots, "empty", {}, () => {
|
|
4000
|
-
var _a;
|
|
4001
|
-
return [
|
|
4002
|
-
createElementVNode(
|
|
4003
|
-
"span",
|
|
4004
|
-
{
|
|
4005
|
-
class: normalizeClass(_ctx.ns.e("empty-text"))
|
|
4006
|
-
},
|
|
4007
|
-
toDisplayString((_a = _ctx.emptyText) != null ? _a : _ctx.t("el.tree.emptyText")),
|
|
4008
|
-
3
|
|
4009
|
-
)
|
|
4010
|
-
];
|
|
4011
|
-
})
|
|
4012
|
-
],
|
|
4013
|
-
2
|
|
4014
|
-
)) : createCommentVNode("v-if", true),
|
|
4015
|
-
withDirectives(createElementVNode(
|
|
4016
|
-
"div",
|
|
4017
|
-
{
|
|
4018
|
-
ref: "dropIndicator$",
|
|
4019
|
-
class: normalizeClass(_ctx.ns.e("drop-indicator"))
|
|
4020
|
-
},
|
|
4021
|
-
null,
|
|
4022
|
-
2
|
|
4023
|
-
), [
|
|
4024
|
-
[vShow, _ctx.dragState.showDropIndicator]
|
|
4025
|
-
])
|
|
4026
|
-
],
|
|
4027
|
-
2
|
|
4028
|
-
);
|
|
4029
|
-
}
|
|
4030
|
-
var Tree = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render], ["__file", "/home/runner/work/element-plus/element-plus/packages/components/tree/src/tree.vue"]]);
|
|
4031
|
-
|
|
4032
|
-
const ElTree = withInstall(Tree);
|
|
4033
|
-
|
|
4034
1965
|
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
4035
1966
|
__name: "popover-cascader",
|
|
4036
1967
|
props: {
|
|
@@ -4131,4 +2062,4 @@ const cssModules = {
|
|
|
4131
2062
|
};
|
|
4132
2063
|
const PopoverCascader = /* @__PURE__ */ _export_sfc$1(_sfc_main, [["__cssModules", cssModules]]);
|
|
4133
2064
|
|
|
4134
|
-
export {
|
|
2065
|
+
export { ElCascader as E, PopoverCascader as P };
|