@silver-formily/element-plus 0.0.1-beta.0 → 1.0.1
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/esm/__builtins__/configs/index.d.ts +1 -0
- package/esm/__builtins__/configs/index.mjs +5 -0
- package/esm/__builtins__/configs/index.mjs.map +1 -0
- package/esm/__builtins__/index.d.ts +2 -0
- package/esm/__builtins__/index.mjs +27 -0
- package/esm/__builtins__/index.mjs.map +1 -0
- package/esm/__builtins__/shared/hooks.d.ts +7 -0
- package/esm/__builtins__/shared/hooks.mjs +59 -0
- package/esm/__builtins__/shared/hooks.mjs.map +1 -0
- package/esm/__builtins__/shared/index.d.ts +7 -0
- package/esm/__builtins__/shared/index.mjs +25 -0
- package/esm/__builtins__/shared/index.mjs.map +1 -0
- package/esm/__builtins__/shared/load-config-provider.d.ts +2 -0
- package/esm/__builtins__/shared/load-config-provider.mjs +12 -0
- package/esm/__builtins__/shared/load-config-provider.mjs.map +1 -0
- package/esm/__builtins__/shared/loading.d.ts +12 -0
- package/esm/__builtins__/shared/loading.mjs +49 -0
- package/esm/__builtins__/shared/loading.mjs.map +1 -0
- package/esm/__builtins__/shared/simple-version-compare.d.ts +2 -0
- package/esm/__builtins__/shared/simple-version-compare.mjs +18 -0
- package/esm/__builtins__/shared/simple-version-compare.mjs.map +1 -0
- package/esm/__builtins__/shared/transform-component.d.ts +8 -0
- package/esm/__builtins__/shared/transform-component.mjs +49 -0
- package/esm/__builtins__/shared/transform-component.mjs.map +1 -0
- package/esm/__builtins__/shared/types.d.ts +2 -0
- package/esm/__builtins__/shared/types.mjs +2 -0
- package/esm/__builtins__/shared/types.mjs.map +1 -0
- package/esm/__builtins__/shared/utils.d.ts +8 -0
- package/esm/__builtins__/shared/utils.mjs +34 -0
- package/esm/__builtins__/shared/utils.mjs.map +1 -0
- package/esm/array-base/array-base-addition.d.ts +5 -0
- package/esm/array-base/array-base-index.d.ts +19 -0
- package/esm/array-base/array-base-inner.d.ts +18 -0
- package/esm/array-base/array-base-item.d.ts +18 -0
- package/esm/array-base/array-base-move-down.d.ts +18 -0
- package/esm/array-base/array-base-move-up.d.ts +18 -0
- package/esm/array-base/array-base-remove.d.ts +18 -0
- package/esm/array-base/array-base-sort-handle.d.ts +2 -0
- package/esm/array-base/index.d.ts +114 -0
- package/esm/array-base/index.mjs +209 -0
- package/esm/array-base/index.mjs.map +1 -0
- package/esm/array-base/symbols.d.ts +4 -0
- package/esm/array-base/symbols.mjs +6 -0
- package/esm/array-base/symbols.mjs.map +1 -0
- package/esm/array-base/types.d.ts +28 -0
- package/esm/array-base/types.mjs +2 -0
- package/esm/array-base/types.mjs.map +1 -0
- package/esm/array-base/utils.d.ts +18 -0
- package/esm/array-base/utils.mjs +79 -0
- package/esm/array-base/utils.mjs.map +1 -0
- package/esm/array-cards/array-cards.d.ts +13 -0
- package/esm/array-cards/index.d.ts +122 -0
- package/esm/array-cards/index.mjs +119 -0
- package/esm/array-cards/index.mjs.map +1 -0
- package/esm/array-collapse/array-collapse-item.d.ts +18 -0
- package/esm/array-collapse/array-collapse.d.ts +16 -0
- package/esm/array-collapse/index.d.ts +134 -0
- package/esm/array-collapse/index.mjs +177 -0
- package/esm/array-collapse/index.mjs.map +1 -0
- package/esm/array-collapse/utils.d.ts +1 -0
- package/esm/array-collapse/utils.mjs +12 -0
- package/esm/array-collapse/utils.mjs.map +1 -0
- package/esm/array-items/array-items-item.d.ts +30 -0
- package/esm/array-items/array-items.d.ts +2 -0
- package/esm/array-items/index.d.ts +130 -0
- package/esm/array-items/index.mjs +105 -0
- package/esm/array-items/index.mjs.map +1 -0
- package/esm/array-list-tabs/array-list-tabs.d.ts +31 -0
- package/esm/array-list-tabs/index.d.ts +83 -0
- package/esm/array-list-tabs/index.mjs +183 -0
- package/esm/array-list-tabs/index.mjs.map +1 -0
- package/esm/array-list-tabs/utils.d.ts +3 -0
- package/esm/array-list-tabs/utils.mjs +16 -0
- package/esm/array-list-tabs/utils.mjs.map +1 -0
- package/esm/array-table/array-table.d.ts +1477 -0
- package/esm/array-table/index.d.ts +1573 -0
- package/esm/array-table/index.mjs +225 -0
- package/esm/array-table/index.mjs.map +1 -0
- package/esm/array-table/types.d.ts +6 -0
- package/esm/array-table/types.mjs +2 -0
- package/esm/array-table/types.mjs.map +1 -0
- package/esm/array-table/utils.d.ts +5 -0
- package/esm/array-table/utils.mjs +25 -0
- package/esm/array-table/utils.mjs.map +1 -0
- package/esm/array-tabs/array-tabs.d.ts +2 -0
- package/esm/array-tabs/index.d.ts +2 -0
- package/esm/array-tabs/index.mjs +87 -0
- package/esm/array-tabs/index.mjs.map +1 -0
- package/esm/cascader/cascader.d.ts +30 -0
- package/esm/cascader/index.d.ts +41 -0
- package/esm/cascader/index.mjs +54 -0
- package/esm/cascader/index.mjs.map +1 -0
- package/esm/checkbox/checkbox-group.d.ts +58 -0
- package/esm/checkbox/index.d.ts +779 -0
- package/esm/checkbox/index.mjs +83 -0
- package/esm/checkbox/index.mjs.map +1 -0
- package/esm/date-picker/index.d.ts +2 -0
- package/esm/date-picker/index.mjs +57 -0
- package/esm/date-picker/index.mjs.map +1 -0
- package/esm/editable/editable-popover.d.ts +25 -0
- package/esm/editable/editable.d.ts +187 -0
- package/esm/editable/index.d.ts +147 -0
- package/esm/editable/index.mjs +225 -0
- package/esm/editable/index.mjs.map +1 -0
- package/esm/form/form.d.ts +46 -0
- package/esm/form/form.mjs +71 -0
- package/esm/form/form.mjs.map +1 -0
- package/esm/form/index.d.ts +1 -0
- package/esm/form/index.mjs +6 -0
- package/esm/form/index.mjs.map +1 -0
- package/esm/form-button-group/form-button-group-sticky.d.ts +17 -0
- package/esm/form-button-group/form-button-group.d.ts +48 -0
- package/esm/form-button-group/index.d.ts +87 -0
- package/esm/form-button-group/index.mjs +87 -0
- package/esm/form-button-group/index.mjs.map +1 -0
- package/esm/form-button-group/utils.d.ts +1 -0
- package/esm/form-button-group/utils.mjs +12 -0
- package/esm/form-button-group/utils.mjs.map +1 -0
- package/esm/form-collapse/form-collapse.d.ts +18 -0
- package/esm/form-collapse/index.d.ts +45 -0
- package/esm/form-collapse/index.mjs +87 -0
- package/esm/form-collapse/index.mjs.map +1 -0
- package/esm/form-collapse/utils.d.ts +31 -0
- package/esm/form-collapse/utils.mjs +50 -0
- package/esm/form-collapse/utils.mjs.map +1 -0
- package/esm/form-dialog/dialog-content.d.ts +60 -0
- package/esm/form-dialog/index.d.ts +4 -0
- package/esm/form-dialog/index.mjs +208 -0
- package/esm/form-dialog/index.mjs.map +1 -0
- package/esm/form-dialog/types.d.ts +32 -0
- package/esm/form-dialog/types.mjs +2 -0
- package/esm/form-dialog/types.mjs.map +1 -0
- package/esm/form-drawer/drawer-content.d.ts +60 -0
- package/esm/form-drawer/index.d.ts +4 -0
- package/esm/form-drawer/index.mjs +202 -0
- package/esm/form-drawer/index.mjs.map +1 -0
- package/esm/form-drawer/types.d.ts +32 -0
- package/esm/form-drawer/types.mjs +2 -0
- package/esm/form-drawer/types.mjs.map +1 -0
- package/esm/form-grid/form-grid-column.d.ts +29 -0
- package/esm/form-grid/form-grid.d.ts +101 -0
- package/esm/form-grid/hooks.d.ts +5 -0
- package/esm/form-grid/hooks.mjs +14 -0
- package/esm/form-grid/hooks.mjs.map +1 -0
- package/esm/form-grid/index.d.ts +184 -0
- package/esm/form-grid/index.mjs +107 -0
- package/esm/form-grid/index.mjs.map +1 -0
- package/esm/form-item/form-item.d.ts +18 -0
- package/esm/form-item/index.d.ts +70 -0
- package/esm/form-item/index.mjs +331 -0
- package/esm/form-item/index.mjs.map +1 -0
- package/esm/form-item/types.d.ts +25 -0
- package/esm/form-item/types.mjs +2 -0
- package/esm/form-item/types.mjs.map +1 -0
- package/esm/form-item/utils.d.ts +3 -0
- package/esm/form-item/utils.mjs +17 -0
- package/esm/form-item/utils.mjs.map +1 -0
- package/esm/form-layout/form-layout.d.ts +32 -0
- package/esm/form-layout/form-layout.mjs +83 -0
- package/esm/form-layout/form-layout.mjs.map +1 -0
- package/esm/form-layout/index.d.ts +1 -0
- package/esm/form-layout/index.mjs +6 -0
- package/esm/form-layout/index.mjs.map +1 -0
- package/esm/form-layout/types.d.ts +43 -0
- package/esm/form-layout/types.mjs +2 -0
- package/esm/form-layout/types.mjs.map +1 -0
- package/esm/form-layout/utils.d.ts +57 -0
- package/esm/form-layout/utils.mjs +109 -0
- package/esm/form-layout/utils.mjs.map +1 -0
- package/esm/form-step/form-step-pane.d.ts +2 -0
- package/esm/form-step/form-step.d.ts +5 -0
- package/esm/form-step/index.d.ts +24 -0
- package/esm/form-step/index.mjs +92 -0
- package/esm/form-step/index.mjs.map +1 -0
- package/esm/form-step/types.d.ts +21 -0
- package/esm/form-step/types.mjs +2 -0
- package/esm/form-step/types.mjs.map +1 -0
- package/esm/form-step/utils.d.ts +11 -0
- package/esm/form-step/utils.mjs +64 -0
- package/esm/form-step/utils.mjs.map +1 -0
- package/esm/form-tab/form-tab.d.ts +7 -0
- package/esm/form-tab/hooks.d.ts +7 -0
- package/esm/form-tab/hooks.mjs +24 -0
- package/esm/form-tab/hooks.mjs.map +1 -0
- package/esm/form-tab/index.d.ts +28 -0
- package/esm/form-tab/index.mjs +77 -0
- package/esm/form-tab/index.mjs.map +1 -0
- package/esm/form-tab/types.d.ts +12 -0
- package/esm/form-tab/types.mjs +2 -0
- package/esm/form-tab/types.mjs.map +1 -0
- package/esm/form-tab/utils.d.ts +4 -0
- package/esm/form-tab/utils.mjs +14 -0
- package/esm/form-tab/utils.mjs.map +1 -0
- package/esm/index.d.ts +37 -0
- package/esm/index.mjs +81 -0
- package/esm/index.mjs.map +1 -0
- package/esm/input/index.d.ts +84 -0
- package/esm/input/index.mjs +77 -0
- package/esm/input/index.mjs.map +1 -0
- package/esm/input/input.d.ts +32 -0
- package/esm/input-number/index.d.ts +4 -0
- package/esm/input-number/index.mjs +30 -0
- package/esm/input-number/index.mjs.map +1 -0
- package/esm/pagination/components/jumper.d.ts +16 -0
- package/esm/pagination/components/jumper.mjs +12 -0
- package/esm/pagination/components/jumper.mjs.map +1 -0
- package/esm/pagination/components/next.d.ts +42 -0
- package/esm/pagination/components/next.mjs +23 -0
- package/esm/pagination/components/next.mjs.map +1 -0
- package/esm/pagination/components/pager.d.ts +42 -0
- package/esm/pagination/components/pager.mjs +23 -0
- package/esm/pagination/components/pager.mjs.map +1 -0
- package/esm/pagination/components/prev.d.ts +39 -0
- package/esm/pagination/components/prev.mjs +22 -0
- package/esm/pagination/components/prev.mjs.map +1 -0
- package/esm/pagination/components/sizes.d.ts +56 -0
- package/esm/pagination/components/sizes.mjs +7 -0
- package/esm/pagination/components/sizes.mjs.map +1 -0
- package/esm/pagination/components/total.d.ts +8 -0
- package/esm/pagination/components/total.mjs +11 -0
- package/esm/pagination/components/total.mjs.map +1 -0
- package/esm/pagination/pagination.d.ts +128 -0
- package/esm/pagination/pagination.mjs +629 -0
- package/esm/pagination/pagination.mjs.map +1 -0
- package/esm/password/index.d.ts +86 -0
- package/esm/password/index.mjs +14 -0
- package/esm/password/index.mjs.map +1 -0
- package/esm/preview-text/cascader.d.ts +5 -0
- package/esm/preview-text/date-picker.d.ts +5 -0
- package/esm/preview-text/index.d.ts +102 -0
- package/esm/preview-text/index.mjs +314 -0
- package/esm/preview-text/index.mjs.map +1 -0
- package/esm/preview-text/input.d.ts +28 -0
- package/esm/preview-text/preview.d.ts +18 -0
- package/esm/preview-text/select.d.ts +5 -0
- package/esm/preview-text/time-picker.d.ts +5 -0
- package/esm/preview-text/tree.d.ts +22 -0
- package/esm/preview-text/utils.d.ts +14 -0
- package/esm/preview-text/utils.mjs +16 -0
- package/esm/preview-text/utils.mjs.map +1 -0
- package/esm/radio/index.d.ts +370 -0
- package/esm/radio/index.mjs +80 -0
- package/esm/radio/index.mjs.map +1 -0
- package/esm/radio/radio-group.d.ts +44 -0
- package/esm/reset/index.d.ts +63 -0
- package/esm/reset/index.mjs +44 -0
- package/esm/reset/index.mjs.map +1 -0
- package/esm/reset/reset.d.ts +45 -0
- package/esm/select/index.d.ts +142 -0
- package/esm/select/index.mjs +132 -0
- package/esm/select/index.mjs.map +1 -0
- package/esm/select/select.d.ts +50 -0
- package/esm/select-table/index.d.ts +1530 -0
- package/esm/select-table/index.mjs +205 -0
- package/esm/select-table/index.mjs.map +1 -0
- package/esm/select-table/select-table.d.ts +2974 -0
- package/esm/select-table/types.d.ts +17 -0
- package/esm/select-table/types.mjs +2 -0
- package/esm/select-table/types.mjs.map +1 -0
- package/esm/space/index.d.ts +1 -0
- package/esm/space/index.mjs +6 -0
- package/esm/space/index.mjs.map +1 -0
- package/esm/styles/array-base/index.css +1 -0
- package/esm/styles/array-cards/index.css +1 -0
- package/esm/styles/array-collapse/index.css +1 -0
- package/esm/styles/array-items/index.css +1 -0
- package/esm/styles/array-list-tabs/index.css +1 -0
- package/esm/styles/array-table/index.css +1 -0
- package/esm/styles/array-tabs/index.css +1 -0
- package/esm/styles/editable/index.css +1 -0
- package/esm/styles/form-button-group/index.css +1 -0
- package/esm/styles/form-collapse/index.css +1 -0
- package/esm/styles/form-grid/index.css +1 -0
- package/esm/styles/form-item/index.css +1 -0
- package/esm/styles/form-tab/index.css +1 -0
- package/esm/styles/preview-text/index.css +1 -0
- package/esm/styles/radio/index.css +1 -0
- package/esm/styles/select-table/index.css +1 -0
- package/esm/submit/index.d.ts +48 -0
- package/esm/submit/index.mjs +40 -0
- package/esm/submit/index.mjs.map +1 -0
- package/esm/submit/submit.d.ts +36 -0
- package/esm/switch/index.d.ts +4 -0
- package/esm/switch/index.mjs +19 -0
- package/esm/switch/index.mjs.map +1 -0
- package/esm/time-picker/index.d.ts +4 -0
- package/esm/time-picker/index.mjs +21 -0
- package/esm/time-picker/index.mjs.map +1 -0
- package/esm/time-select/index.d.ts +2 -0
- package/esm/time-select/index.mjs +21 -0
- package/esm/time-select/index.mjs.map +1 -0
- package/esm/transfer/index.d.ts +186 -0
- package/esm/transfer/index.mjs +11 -0
- package/esm/transfer/index.mjs.map +1 -0
- package/esm/tree/index.d.ts +42 -0
- package/esm/tree/index.mjs +104 -0
- package/esm/tree/index.mjs.map +1 -0
- package/esm/tree/tree.d.ts +20 -0
- package/esm/tree/types.d.ts +13 -0
- package/esm/tree/types.mjs +2 -0
- package/esm/tree/types.mjs.map +1 -0
- package/esm/tree/utils.d.ts +45 -0
- package/esm/tree/utils.mjs +161 -0
- package/esm/tree/utils.mjs.map +1 -0
- package/esm/tree-select/index.d.ts +32 -0
- package/esm/tree-select/index.mjs +47 -0
- package/esm/tree-select/index.mjs.map +1 -0
- package/esm/tree-select/tree-select.d.ts +17 -0
- package/esm/upload/index.d.ts +707 -0
- package/esm/upload/index.mjs +175 -0
- package/esm/upload/index.mjs.map +1 -0
- package/esm/upload/upload.d.ts +1249 -0
- package/esm/vendor/icon.mjs +11 -0
- package/esm/vendor/icon.mjs.map +1 -0
- package/esm/vendor/lodash.mjs +1400 -0
- package/esm/vendor/lodash.mjs.map +1 -0
- package/esm/vendor/runtime.mjs +35 -0
- package/esm/vendor/runtime.mjs.map +1 -0
- package/esm/vendor/shared.esm-bundler.mjs +14 -0
- package/esm/vendor/shared.esm-bundler.mjs.map +1 -0
- package/esm/vendor/sizes.mjs +27 -0
- package/esm/vendor/sizes.mjs.map +1 -0
- package/esm/vendor/types.mjs +19 -0
- package/esm/vendor/types.mjs.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { useField as A, connect as D, mapProps as H } from "@formily/vue";
|
|
2
|
+
import { defineComponent as F, useSlots as P, ref as m, computed as y, watch as v, nextTick as k, createBlock as g, openBlock as C, unref as a, withCtx as T, withDirectives as R, mergeProps as w, createSlots as B, renderList as V, renderSlot as E, normalizeProps as L, guardReactiveProps as j } from "vue";
|
|
3
|
+
import { ElScrollbar as z, ElTree as I, vLoading as N } from "element-plus";
|
|
4
|
+
import "@formily/reactive";
|
|
5
|
+
import { mapReadPretty as O } from "../__builtins__/shared/transform-component.mjs";
|
|
6
|
+
import { PreviewText as $ } from "../preview-text/index.mjs";
|
|
7
|
+
import { isFn as q } from "@formily/shared";
|
|
8
|
+
import "@formily/core";
|
|
9
|
+
import "@formily/reactive-vue";
|
|
10
|
+
import { useCleanAttrs as G } from "../__builtins__/shared/utils.mjs";
|
|
11
|
+
import { addDisabledToNodes as J, flattenTree as M, getInputKeys as Q, getOutputData as U } from "./utils.mjs";
|
|
12
|
+
const W = /* @__PURE__ */ F({
|
|
13
|
+
name: "Tree",
|
|
14
|
+
inheritAttrs: !1,
|
|
15
|
+
__name: "tree",
|
|
16
|
+
props: {
|
|
17
|
+
nodeKey: null,
|
|
18
|
+
data: null,
|
|
19
|
+
value: null,
|
|
20
|
+
valueType: { default: "all" },
|
|
21
|
+
includeHalfChecked: { type: Boolean, default: !1 },
|
|
22
|
+
optionAsValue: { type: Boolean, default: !1 },
|
|
23
|
+
props: { default: {
|
|
24
|
+
children: "children",
|
|
25
|
+
label: "label",
|
|
26
|
+
disabled: "disabled"
|
|
27
|
+
} },
|
|
28
|
+
optionFormatter: { type: Function },
|
|
29
|
+
height: null,
|
|
30
|
+
maxHeight: null
|
|
31
|
+
},
|
|
32
|
+
emits: ["change"],
|
|
33
|
+
setup(K, { emit: b }) {
|
|
34
|
+
const e = K, i = b, x = P(), { props: l } = G(), o = m(), n = m([]), c = y(() => J(e.data ?? [], l.value.disabled, e.props)), d = y(() => M(c.value ?? [], [], e.props.children));
|
|
35
|
+
async function p() {
|
|
36
|
+
await k();
|
|
37
|
+
const t = o.value.getCheckedKeys(), f = o.value.getHalfCheckedKeys() || [];
|
|
38
|
+
n.value = t;
|
|
39
|
+
const { value: h, nodes: r } = U(t, f, {
|
|
40
|
+
flatData: d.value,
|
|
41
|
+
nodeKey: e.nodeKey,
|
|
42
|
+
propsConfig: e.props,
|
|
43
|
+
data: e.data ?? [],
|
|
44
|
+
valueType: e.valueType,
|
|
45
|
+
includeHalfChecked: e.includeHalfChecked,
|
|
46
|
+
checkStrictly: l.value.checkStrictly
|
|
47
|
+
});
|
|
48
|
+
e.optionAsValue ? q(e.optionFormatter) ? i("change", r.map((s, S, _) => e.optionFormatter(s, S, _))) : i("change", r) : i("change", h);
|
|
49
|
+
}
|
|
50
|
+
v(() => e.value, (t) => {
|
|
51
|
+
t !== void 0 && (n.value = Q(t, {
|
|
52
|
+
optionAsValue: e.optionAsValue,
|
|
53
|
+
nodeKey: e.nodeKey,
|
|
54
|
+
flatData: d.value,
|
|
55
|
+
propsConfig: e.props,
|
|
56
|
+
data: e.data ?? [],
|
|
57
|
+
valueType: e.valueType,
|
|
58
|
+
checkStrictly: l.value.checkStrictly
|
|
59
|
+
}), k(() => {
|
|
60
|
+
o.value && o.value.setCheckedKeys(n.value);
|
|
61
|
+
}));
|
|
62
|
+
}, { immediate: !0 }), v(() => [e.valueType, e.optionAsValue, e.includeHalfChecked], () => {
|
|
63
|
+
p();
|
|
64
|
+
}, { immediate: !1 });
|
|
65
|
+
const u = A();
|
|
66
|
+
return u.value?.inject({
|
|
67
|
+
getTreeRef: () => o
|
|
68
|
+
}), (t, f) => (C(), g(a(z), {
|
|
69
|
+
height: e.height,
|
|
70
|
+
"max-height": e.maxHeight
|
|
71
|
+
}, {
|
|
72
|
+
default: T(() => [
|
|
73
|
+
R((C(), g(a(I), w({
|
|
74
|
+
ref_key: "treeRef",
|
|
75
|
+
ref: o,
|
|
76
|
+
data: c.value,
|
|
77
|
+
props: e.props,
|
|
78
|
+
"node-key": e.nodeKey,
|
|
79
|
+
"default-checked-keys": n.value,
|
|
80
|
+
"show-checkbox": !0
|
|
81
|
+
}, a(l), { onCheck: p }), B({ _: 2 }, [
|
|
82
|
+
V(a(x), (h, r) => ({
|
|
83
|
+
name: r,
|
|
84
|
+
fn: T((s) => [
|
|
85
|
+
E(t.$slots, r, L(j({ field: a(u), ...s })))
|
|
86
|
+
])
|
|
87
|
+
}))
|
|
88
|
+
]), 1040, ["data", "props", "node-key", "default-checked-keys"])), [
|
|
89
|
+
[a(N), a(l).loading]
|
|
90
|
+
])
|
|
91
|
+
]),
|
|
92
|
+
_: 3
|
|
93
|
+
}, 8, ["height", "max-height"]));
|
|
94
|
+
}
|
|
95
|
+
}), se = D(
|
|
96
|
+
W,
|
|
97
|
+
H({ dataSource: "data", loading: "loading", disabled: !0 }),
|
|
98
|
+
O($.Tree)
|
|
99
|
+
);
|
|
100
|
+
export {
|
|
101
|
+
se as Tree,
|
|
102
|
+
se as default
|
|
103
|
+
};
|
|
104
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../src/tree/tree.vue","../../src/tree/index.ts"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { Field } from '@formily/core'\nimport type { TreeValueTypeProps } from './types'\nimport { isFn } from '@formily/shared'\nimport { useField } from '@formily/vue'\nimport { ElScrollbar, ElTree, vLoading } from 'element-plus'\nimport { computed, nextTick, ref, useSlots, watch } from 'vue'\nimport { useCleanAttrs } from '../__builtins__'\nimport { addDisabledToNodes, flattenTree, getInputKeys, getOutputData } from './utils'\n\ndefineOptions({\n name: 'Tree',\n inheritAttrs: false,\n})\n\nconst props = defineProps({\n nodeKey: null,\n data: null,\n value: null,\n valueType: { default: 'all' },\n includeHalfChecked: { type: Boolean, default: false },\n optionAsValue: { type: Boolean, default: false },\n props: { default: {\n children: 'children',\n label: 'label',\n disabled: 'disabled',\n } },\n optionFormatter: { type: Function },\n height: null,\n maxHeight: null\n})\n\nconst emit = defineEmits([\"change\"])\n\nconst slots = useSlots()\n\nconst { props: attrs } = useCleanAttrs()\nconst treeRef = ref<InstanceType<typeof ElTree>>()\nconst checkedKeys = ref<any[]>([])\n\nconst processedData = computed(() => {\n return addDisabledToNodes(props.data ?? [], attrs.value.disabled, props.props)\n})\n\nconst flatData = computed(() => flattenTree(processedData.value ?? [], [], props.props.children))\n\nasync function handleCheck() {\n await nextTick()\n const keys = treeRef.value.getCheckedKeys()\n const halfCheckedKeys = treeRef.value.getHalfCheckedKeys() || []\n checkedKeys.value = keys\n\n const { value, nodes } = getOutputData(keys, halfCheckedKeys, {\n flatData: flatData.value,\n nodeKey: props.nodeKey,\n propsConfig: props.props,\n data: props.data ?? [],\n valueType: props.valueType,\n includeHalfChecked: props.includeHalfChecked,\n checkStrictly: attrs.value.checkStrictly,\n })\n\n if (props.optionAsValue) {\n isFn(props.optionFormatter)\n ? emit('change', nodes.map((element, index, array) => {\n return props.optionFormatter(element, index, array)\n }))\n : emit('change', nodes)\n }\n else {\n emit('change', value)\n }\n}\n\nwatch(() => props.value, (newValue) => {\n if (newValue !== undefined) {\n checkedKeys.value = getInputKeys(newValue, {\n optionAsValue: props.optionAsValue,\n nodeKey: props.nodeKey,\n flatData: flatData.value,\n propsConfig: props.props,\n data: props.data ?? [],\n valueType: props.valueType,\n checkStrictly: attrs.value.checkStrictly,\n })\n nextTick(() => {\n if (treeRef.value) {\n treeRef.value.setCheckedKeys(checkedKeys.value)\n }\n })\n }\n}, { immediate: true })\n\nwatch(() => [props.valueType, props.optionAsValue, props.includeHalfChecked], () => {\n handleCheck()\n}, { immediate: false })\n\nconst fieldRef = useField<Field>()\nfieldRef.value?.inject({\n getTreeRef: () => {\n return treeRef\n },\n})\n</script>\n\n<template>\n <ElScrollbar :height=\"props.height\" :max-height=\"props.maxHeight\">\n <ElTree\n ref=\"treeRef\"\n v-loading=\"attrs.loading\"\n :data=\"processedData\"\n :props=\"props.props\"\n :node-key=\"props.nodeKey\"\n :default-checked-keys=\"checkedKeys\"\n :show-checkbox=\"true\"\n v-bind=\"attrs\"\n @check=\"handleCheck\"\n >\n <template v-for=\"(_, name) of slots\" #[name]=\"slotData\">\n <slot :name=\"name\" v-bind=\"{ field: fieldRef, ...slotData }\" />\n </template>\n </ElTree>\n </ElScrollbar>\n</template>\n","import { connect, mapProps } from '@formily/vue'\nimport { mapReadPretty } from '../__builtins__'\nimport { PreviewText } from '../preview-text'\nimport InnerTree from './tree.vue'\n\nconst Tree = connect(\n InnerTree,\n mapProps({ dataSource: 'data', loading: 'loading', disabled: true }),\n mapReadPretty(PreviewText.Tree),\n)\n\nexport { Tree }\n\nexport default Tree\n"],"names":["props","__props","emit","__emit","slots","useSlots","attrs","useCleanAttrs","treeRef","ref","checkedKeys","processedData","computed","addDisabledToNodes","flatData","flattenTree","handleCheck","nextTick","keys","halfCheckedKeys","value","nodes","getOutputData","isFn","element","index","array","watch","newValue","getInputKeys","fieldRef","useField","_createBlock","_unref","ElScrollbar","_withDirectives","_openBlock","_mergeProps","_createSlots","_","name","_withCtx","slotData","_renderSlot","_ctx","_normalizeProps","_guardReactiveProps","vLoading","Tree","connect","InnerTree","mapProps","mapReadPretty","PreviewText"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAeA,UAAMA,IAAQC,GAiBRC,IAAOC,GAEPC,IAAQC,EAAA,GAER,EAAE,OAAOC,EAAA,IAAUC,EAAA,GACnBC,IAAUC,EAAA,GACVC,IAAcD,EAAW,EAAE,GAE3BE,IAAgBC,EAAS,MACtBC,EAAmBb,EAAM,QAAQ,CAAA,GAAIM,EAAM,MAAM,UAAUN,EAAM,KAAK,CAC9E,GAEKc,IAAWF,EAAS,MAAMG,EAAYJ,EAAc,SAAS,CAAA,GAAI,IAAIX,EAAM,MAAM,QAAQ,CAAC;AAEhG,mBAAegB,IAAc;AAC3B,YAAMC,EAAA;AACN,YAAMC,IAAOV,EAAQ,MAAM,eAAA,GACrBW,IAAkBX,EAAQ,MAAM,mBAAA,KAAwB,CAAA;AAC9D,MAAAE,EAAY,QAAQQ;AAEpB,YAAM,EAAE,OAAAE,GAAO,OAAAC,EAAA,IAAUC,EAAcJ,GAAMC,GAAiB;AAAA,QAC5D,UAAUL,EAAS;AAAA,QACnB,SAASd,EAAM;AAAA,QACf,aAAaA,EAAM;AAAA,QACnB,MAAMA,EAAM,QAAQ,CAAA;AAAA,QACpB,WAAWA,EAAM;AAAA,QACjB,oBAAoBA,EAAM;AAAA,QAC1B,eAAeM,EAAM,MAAM;AAAA,MAAA,CAC5B;AAED,MAAIN,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A,QAAA,GACRuB,EAAA3B,CAAA,GAAK,EACZ,SAAOU,GAAW,GAAAsB,EAAA,EAAA,GAAA,KAAA;AAAA,YAEWL,EAAA7B,CAAA,GAAK,CAAjBmC,GAAGC;;YACnB,IAAAC,EAAA,CAD4CC,MAAQ;AAAA,cACpDC,EAA+DC,EAAA,QAAlDJ,GAAIK,EAAAC,EAAA,EAAA,OAAmBb,EAAAH,CAAA,MAAaY,EAAA,CAAQ,CAAA,CAAA;AAAA,YAAA;;;UAVhD,CAAAT,EAAAc,CAAA,GAAAd,EAAA3B,CAAA,EAAM,OAAO;AAAA,QAAA;;;;;ICxGxB0C,KAAOC;AAAA,EACXC;AAAAA,EACAC,EAAS,EAAE,YAAY,QAAQ,SAAS,WAAW,UAAU,IAAM;AAAA,EACnEC,EAAcC,EAAY,IAAI;AAChC;"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { TreeValueTypeProps } from './types';
|
|
2
|
+
declare function __VLS_template(): any;
|
|
3
|
+
type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
|
|
4
|
+
declare const __VLS_component: import('vue').DefineComponent<TreeValueTypeProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
5
|
+
change: (value: any) => any;
|
|
6
|
+
}, string, import('vue').PublicProps, Readonly<TreeValueTypeProps> & Readonly<{
|
|
7
|
+
onChange?: (value: any) => any;
|
|
8
|
+
}>, {
|
|
9
|
+
props: any;
|
|
10
|
+
valueType: "all" | "parent" | "child" | "path";
|
|
11
|
+
includeHalfChecked: boolean;
|
|
12
|
+
optionAsValue: boolean;
|
|
13
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, any, any>;
|
|
14
|
+
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
|
|
15
|
+
export default _default;
|
|
16
|
+
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
17
|
+
new (): {
|
|
18
|
+
$slots: S;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { TreeNodeData } from 'element-plus';
|
|
2
|
+
export interface TreeValueTypeProps {
|
|
3
|
+
nodeKey: string;
|
|
4
|
+
data?: TreeNodeData[];
|
|
5
|
+
value?: any;
|
|
6
|
+
valueType?: 'all' | 'parent' | 'child' | 'path';
|
|
7
|
+
includeHalfChecked?: boolean;
|
|
8
|
+
optionAsValue?: boolean;
|
|
9
|
+
props?: any;
|
|
10
|
+
optionFormatter?: (node: TreeNodeData, index: number, array: TreeNodeData[]) => TreeNodeData;
|
|
11
|
+
height?: number;
|
|
12
|
+
maxHeight?: number;
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { TreeNodeData } from 'element-plus';
|
|
2
|
+
export declare function flattenTree(nodes: TreeNodeData[], result?: TreeNodeData[], childrenKey?: string): TreeNodeData[];
|
|
3
|
+
export declare function addDisabledToNodes(nodes: TreeNodeData[], disabled: boolean, propsConfig: any): TreeNodeData[];
|
|
4
|
+
export declare function traverseTree(nodes: TreeNodeData[], callback: (node: TreeNodeData) => void, options?: {
|
|
5
|
+
leafOnly?: boolean;
|
|
6
|
+
childrenKey?: string;
|
|
7
|
+
}): void;
|
|
8
|
+
export declare function getChildrenKeys(node: TreeNodeData, nodeKey: string, propsConfig: any): any[];
|
|
9
|
+
export declare function extractKeysFromPath(pathNodes: TreeNodeData[], nodeKey: string, propsConfig: any): any[];
|
|
10
|
+
export declare function getSelectedPath(nodes: TreeNodeData[], selectedKeys: any[], nodeKey: string, propsConfig: any): TreeNodeData[];
|
|
11
|
+
/**
|
|
12
|
+
* 查找节点的所有父节点路径
|
|
13
|
+
*/
|
|
14
|
+
export declare function findParents(nodes: TreeNodeData[], targetKey: any, nodeKey: string, propsConfig: any, parents?: any[]): any[];
|
|
15
|
+
/**
|
|
16
|
+
* 过滤叶子节点
|
|
17
|
+
*/
|
|
18
|
+
export declare function filterLeafNodes(keys: any[], flatData: TreeNodeData[], nodeKey: string, propsConfig: any): any[];
|
|
19
|
+
/**
|
|
20
|
+
* 获取输出数据
|
|
21
|
+
*/
|
|
22
|
+
export declare function getOutputData(keys: any[], halfCheckedKeys: any[], options: {
|
|
23
|
+
flatData: TreeNodeData[];
|
|
24
|
+
nodeKey: string;
|
|
25
|
+
propsConfig: any;
|
|
26
|
+
data: TreeNodeData[];
|
|
27
|
+
valueType: string;
|
|
28
|
+
includeHalfChecked: boolean;
|
|
29
|
+
checkStrictly: boolean;
|
|
30
|
+
}): {
|
|
31
|
+
value: any[];
|
|
32
|
+
nodes: TreeNodeData[];
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* 根据valueType将输入值转换为checkedKeys
|
|
36
|
+
*/
|
|
37
|
+
export declare function getInputKeys(inputValue: any, options: {
|
|
38
|
+
optionAsValue: boolean;
|
|
39
|
+
nodeKey: string;
|
|
40
|
+
flatData: TreeNodeData[];
|
|
41
|
+
propsConfig: any;
|
|
42
|
+
data: TreeNodeData[];
|
|
43
|
+
valueType: string;
|
|
44
|
+
checkStrictly: boolean;
|
|
45
|
+
}): any[];
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
function k(c, r = [], t = "children") {
|
|
2
|
+
for (const e of c)
|
|
3
|
+
r.push(e), e[t] && e[t].length > 0 && k(e[t], r, t);
|
|
4
|
+
return r;
|
|
5
|
+
}
|
|
6
|
+
function m(c, r, t) {
|
|
7
|
+
return r ? c.map((e) => {
|
|
8
|
+
const n = { ...e };
|
|
9
|
+
return n[t.disabled] = !0, e[t.children] && e[t.children].length > 0 && (n[t.children] = m(e[t.children], r, t)), n;
|
|
10
|
+
}) : c;
|
|
11
|
+
}
|
|
12
|
+
function S(c, r, t = {}) {
|
|
13
|
+
const { leafOnly: e = !1, childrenKey: n = "children" } = t;
|
|
14
|
+
for (const l of c) {
|
|
15
|
+
const i = l[n] || [], o = i.length === 0;
|
|
16
|
+
(!e || o) && r(l), i.length > 0 && S(i, r, t);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
function N(c, r, t) {
|
|
20
|
+
const e = c[t.children] || [];
|
|
21
|
+
if (e.length === 0)
|
|
22
|
+
return [];
|
|
23
|
+
const n = [];
|
|
24
|
+
return S(e, (l) => {
|
|
25
|
+
n.push(l[r]);
|
|
26
|
+
}, { childrenKey: t.children }), n;
|
|
27
|
+
}
|
|
28
|
+
function w(c, r, t) {
|
|
29
|
+
const e = [];
|
|
30
|
+
return S(c, (n) => {
|
|
31
|
+
e.push(n[r]);
|
|
32
|
+
}, { leafOnly: !0, childrenKey: t.children }), e;
|
|
33
|
+
}
|
|
34
|
+
function P(c, r, t, e) {
|
|
35
|
+
const n = [];
|
|
36
|
+
for (const l of c) {
|
|
37
|
+
const i = l[e.children] || [], o = i.length > 0 ? P(i, r, t, e).length > 0 : !1;
|
|
38
|
+
if (r.includes(l[t]) || o) {
|
|
39
|
+
const u = { ...l };
|
|
40
|
+
o && i.length > 0 && (u[e.children] = P(i, r, t, e)), n.push(u);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return n;
|
|
44
|
+
}
|
|
45
|
+
function T(c, r, t, e, n = []) {
|
|
46
|
+
for (const l of c) {
|
|
47
|
+
const i = [...n, l[t]];
|
|
48
|
+
if (l[t] === r)
|
|
49
|
+
return i;
|
|
50
|
+
const o = l[e.children] || [];
|
|
51
|
+
if (o.length > 0) {
|
|
52
|
+
const u = T(o, r, t, e, i);
|
|
53
|
+
if (u.length > 0)
|
|
54
|
+
return u;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
/* istanbul ignore next -- @preserve */
|
|
58
|
+
return [];
|
|
59
|
+
}
|
|
60
|
+
function v(c, r, t, e) {
|
|
61
|
+
return c.filter((n) => {
|
|
62
|
+
const l = r.find((o) => o[t] === n);
|
|
63
|
+
return l ? (l[e.children] || []).length === 0 : !1;
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
function D(c, r = [], t) {
|
|
67
|
+
const { flatData: e, nodeKey: n, propsConfig: l, data: i, valueType: o, includeHalfChecked: u, checkStrictly: a } = t, d = e.filter(
|
|
68
|
+
(s) => c.includes(s[n])
|
|
69
|
+
);
|
|
70
|
+
let h = [...c], f = [...d];
|
|
71
|
+
if (a)
|
|
72
|
+
return {
|
|
73
|
+
value: h,
|
|
74
|
+
nodes: f
|
|
75
|
+
};
|
|
76
|
+
switch (o) {
|
|
77
|
+
case "parent": {
|
|
78
|
+
const s = [];
|
|
79
|
+
for (const y of d)
|
|
80
|
+
s.push(...N(y, n, l));
|
|
81
|
+
h = c.filter((y) => !s.includes(y)), f = d.filter(
|
|
82
|
+
(y) => h.includes(y[n])
|
|
83
|
+
);
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
case "child": {
|
|
87
|
+
for (const s of d)
|
|
88
|
+
N(s, n, l).some((g) => c.includes(g)) && (h = h.filter((g) => g !== s[n]), f = f.filter(
|
|
89
|
+
(g) => g[n] !== s[n]
|
|
90
|
+
));
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
case "path": {
|
|
94
|
+
const s = P(i, c, n, l);
|
|
95
|
+
return {
|
|
96
|
+
value: s,
|
|
97
|
+
nodes: s
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
default: {
|
|
101
|
+
if (u && r.length > 0) {
|
|
102
|
+
const s = e.filter(
|
|
103
|
+
(y) => r.includes(y[n])
|
|
104
|
+
);
|
|
105
|
+
h = [...h, ...r], f = [...f, ...s];
|
|
106
|
+
}
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return {
|
|
111
|
+
value: h,
|
|
112
|
+
nodes: f
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
function b(c, r) {
|
|
116
|
+
const { optionAsValue: t, nodeKey: e, flatData: n, propsConfig: l, data: i, valueType: o, checkStrictly: u } = r;
|
|
117
|
+
/* istanbul ignore if -- @preserve */
|
|
118
|
+
if (!c || !Array.isArray(c))
|
|
119
|
+
return [];
|
|
120
|
+
const a = t ? c.map((d) => d[e]) : c;
|
|
121
|
+
if (u)
|
|
122
|
+
return a;
|
|
123
|
+
switch (o) {
|
|
124
|
+
case "parent": {
|
|
125
|
+
const d = [...a];
|
|
126
|
+
for (const h of a) {
|
|
127
|
+
const f = n.find((s) => s[e] === h);
|
|
128
|
+
if (f) {
|
|
129
|
+
const s = N(f, e, l);
|
|
130
|
+
d.push(...s);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return v(d, n, e, l);
|
|
134
|
+
}
|
|
135
|
+
case "child": {
|
|
136
|
+
const d = [...a];
|
|
137
|
+
for (const h of a) {
|
|
138
|
+
const f = T(i, h, e, l);
|
|
139
|
+
d.push(...f);
|
|
140
|
+
}
|
|
141
|
+
return v(d, n, e, l);
|
|
142
|
+
}
|
|
143
|
+
case "path":
|
|
144
|
+
return w(a, e, l);
|
|
145
|
+
default:
|
|
146
|
+
return v(a, n, e, l);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
export {
|
|
150
|
+
m as addDisabledToNodes,
|
|
151
|
+
w as extractKeysFromPath,
|
|
152
|
+
v as filterLeafNodes,
|
|
153
|
+
T as findParents,
|
|
154
|
+
k as flattenTree,
|
|
155
|
+
N as getChildrenKeys,
|
|
156
|
+
b as getInputKeys,
|
|
157
|
+
D as getOutputData,
|
|
158
|
+
P as getSelectedPath,
|
|
159
|
+
S as traverseTree
|
|
160
|
+
};
|
|
161
|
+
//# sourceMappingURL=utils.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.mjs","sources":["../../src/tree/utils.ts"],"sourcesContent":["import type { TreeNodeData } from 'element-plus'\n\nexport function flattenTree(nodes: TreeNodeData[], result: TreeNodeData[] = [], childrenKey = 'children'): TreeNodeData[] {\n for (const node of nodes) {\n result.push(node)\n if (node[childrenKey] && node[childrenKey].length > 0) {\n flattenTree(node[childrenKey], result, childrenKey)\n }\n }\n return result\n}\n\nexport function addDisabledToNodes(nodes: TreeNodeData[], disabled: boolean, propsConfig: any): TreeNodeData[] {\n if (!disabled) {\n return nodes\n }\n\n return nodes.map((node) => {\n const newNode = { ...node }\n newNode[propsConfig.disabled!] = true\n\n if (node[propsConfig.children!] && node[propsConfig.children!].length > 0) {\n newNode[propsConfig.children!] = addDisabledToNodes(node[propsConfig.children!], disabled, propsConfig)\n }\n\n return newNode\n })\n}\n\nexport function traverseTree(\n nodes: TreeNodeData[],\n callback: (node: TreeNodeData) => void,\n options: {\n leafOnly?: boolean\n childrenKey?: string\n } = {},\n) {\n const { leafOnly = false, childrenKey = 'children' } = options\n\n for (const node of nodes) {\n const children = node[childrenKey] || []\n const isLeaf = children.length === 0\n\n if (!leafOnly || isLeaf) {\n callback(node)\n }\n if (children.length > 0) {\n traverseTree(children, callback, options)\n }\n }\n}\n\nexport function getChildrenKeys(node: TreeNodeData, nodeKey: string, propsConfig: any): any[] {\n const children = node[propsConfig.children!] || []\n if (children.length === 0)\n return []\n\n const keys: any[] = []\n traverseTree(children, (child) => {\n keys.push(child[nodeKey])\n }, { childrenKey: propsConfig.children })\n\n return keys\n}\n\nexport function extractKeysFromPath(pathNodes: TreeNodeData[], nodeKey: string, propsConfig: any): any[] {\n const keys: any[] = []\n traverseTree(pathNodes, (node) => {\n keys.push(node[nodeKey])\n }, { leafOnly: true, childrenKey: propsConfig.children })\n\n return keys\n}\n\nexport function getSelectedPath(nodes: TreeNodeData[], selectedKeys: any[], nodeKey: string, propsConfig: any): TreeNodeData[] {\n const result: TreeNodeData[] = []\n\n for (const node of nodes) {\n const children = node[propsConfig.children!] || []\n const hasSelectedChild = children.length > 0\n ? getSelectedPath(children, selectedKeys, nodeKey, propsConfig).length > 0\n : false\n\n if (selectedKeys.includes(node[nodeKey]) || hasSelectedChild) {\n const newNode = { ...node }\n if (hasSelectedChild && children.length > 0) {\n newNode[propsConfig.children!] = getSelectedPath(children, selectedKeys, nodeKey, propsConfig)\n }\n result.push(newNode)\n }\n }\n\n return result\n}\n\n/**\n * 查找节点的所有父节点路径\n */\nexport function findParents(nodes: TreeNodeData[], targetKey: any, nodeKey: string, propsConfig: any, parents: any[] = []): any[] {\n for (const node of nodes) {\n const currentPath = [...parents, node[nodeKey]]\n\n if (node[nodeKey] === targetKey) {\n return currentPath\n }\n\n const children = node[propsConfig.children!] || []\n if (children.length > 0) {\n const found = findParents(children, targetKey, nodeKey, propsConfig, currentPath)\n if (found.length > 0) {\n return found\n }\n }\n }\n /* istanbul ignore next -- @preserve */\n return []\n}\n\n/**\n * 过滤叶子节点\n */\nexport function filterLeafNodes(keys: any[], flatData: TreeNodeData[], nodeKey: string, propsConfig: any): any[] {\n return keys.filter((key) => {\n const node = flatData.find(n => n[nodeKey] === key)\n if (!node)\n return false\n const children = node[propsConfig.children!] || []\n return children.length === 0\n })\n}\n\n/**\n * 获取输出数据\n */\nexport function getOutputData(\n keys: any[],\n halfCheckedKeys: any[] = [],\n options: {\n flatData: TreeNodeData[]\n nodeKey: string\n propsConfig: any\n data: TreeNodeData[]\n valueType: string\n includeHalfChecked: boolean\n checkStrictly: boolean\n },\n) {\n const { flatData, nodeKey, propsConfig, data, valueType, includeHalfChecked, checkStrictly } = options\n\n const selectedNodes = flatData.filter(node =>\n keys.includes(node[nodeKey]),\n )\n\n let outputKeys = [...keys]\n let outputNodes = [...selectedNodes]\n\n if (checkStrictly) {\n return {\n value: outputKeys,\n nodes: outputNodes,\n }\n }\n\n switch (valueType) {\n case 'parent': {\n const allChildKeys: any[] = []\n for (const node of selectedNodes) {\n allChildKeys.push(...getChildrenKeys(node, nodeKey, propsConfig))\n }\n outputKeys = keys.filter(key => !allChildKeys.includes(key))\n outputNodes = selectedNodes.filter(node =>\n outputKeys.includes(node[nodeKey]),\n )\n break\n }\n\n case 'child': {\n for (const node of selectedNodes) {\n const childKeys = getChildrenKeys(node, nodeKey, propsConfig)\n const hasSelectedChild = childKeys.some(key => keys.includes(key))\n if (hasSelectedChild) {\n outputKeys = outputKeys.filter(key => key !== node[nodeKey])\n outputNodes = outputNodes.filter(n =>\n n[nodeKey] !== node[nodeKey],\n )\n }\n }\n break\n }\n\n case 'path': {\n const selectedPath = getSelectedPath(data, keys, nodeKey, propsConfig)\n return {\n value: selectedPath,\n nodes: selectedPath,\n }\n }\n\n default: { // 'all'\n if (includeHalfChecked && halfCheckedKeys.length > 0) {\n const halfCheckedNodes = flatData.filter(node =>\n halfCheckedKeys.includes(node[nodeKey]),\n )\n outputKeys = [...outputKeys, ...halfCheckedKeys]\n outputNodes = [...outputNodes, ...halfCheckedNodes]\n }\n break\n }\n }\n\n return {\n value: outputKeys,\n nodes: outputNodes,\n }\n}\n\n/**\n * 根据valueType将输入值转换为checkedKeys\n */\nexport function getInputKeys(\n inputValue: any,\n options: {\n optionAsValue: boolean\n nodeKey: string\n flatData: TreeNodeData[]\n propsConfig: any\n data: TreeNodeData[]\n valueType: string\n checkStrictly: boolean\n },\n): any[] {\n const { optionAsValue, nodeKey, flatData, propsConfig, data, valueType, checkStrictly } = options\n\n /* istanbul ignore if -- @preserve */\n if (!inputValue || !Array.isArray(inputValue))\n return []\n\n const valueArray = optionAsValue ? inputValue.map((item: any) => item[nodeKey]) : inputValue\n\n if (checkStrictly) {\n return valueArray\n }\n\n switch (valueType) {\n case 'parent': {\n const allKeys = [...valueArray]\n\n for (const key of valueArray) {\n const node = flatData.find(n => n[nodeKey] === key)\n if (node) {\n const childKeys = getChildrenKeys(node, nodeKey, propsConfig)\n allKeys.push(...childKeys)\n }\n }\n return filterLeafNodes(allKeys, flatData, nodeKey, propsConfig)\n }\n\n case 'child': {\n const allKeys = [...valueArray]\n for (const key of valueArray) {\n const parentPath = findParents(data, key, nodeKey, propsConfig)\n allKeys.push(...parentPath)\n }\n return filterLeafNodes(allKeys, flatData, nodeKey, propsConfig)\n }\n\n case 'path': {\n return extractKeysFromPath(valueArray, nodeKey, propsConfig)\n }\n\n default: { // 'all'\n return filterLeafNodes(valueArray, flatData, nodeKey, propsConfig)\n }\n }\n}\n"],"names":["flattenTree","nodes","result","childrenKey","node","addDisabledToNodes","disabled","propsConfig","newNode","traverseTree","callback","options","leafOnly","children","isLeaf","getChildrenKeys","nodeKey","keys","child","extractKeysFromPath","pathNodes","getSelectedPath","selectedKeys","hasSelectedChild","findParents","targetKey","parents","currentPath","found","filterLeafNodes","flatData","key","n","getOutputData","halfCheckedKeys","data","valueType","includeHalfChecked","checkStrictly","selectedNodes","outputKeys","outputNodes","allChildKeys","selectedPath","halfCheckedNodes","getInputKeys","inputValue","optionAsValue","valueArray","item","allKeys","childKeys","parentPath"],"mappings":"AAEO,SAASA,EAAYC,GAAuBC,IAAyB,CAAA,GAAIC,IAAc,YAA4B;AACxH,aAAWC,KAAQH;AACjB,IAAAC,EAAO,KAAKE,CAAI,GACZA,EAAKD,CAAW,KAAKC,EAAKD,CAAW,EAAE,SAAS,KAClDH,EAAYI,EAAKD,CAAW,GAAGD,GAAQC,CAAW;AAGtD,SAAOD;AACT;AAEO,SAASG,EAAmBJ,GAAuBK,GAAmBC,GAAkC;AAC7G,SAAKD,IAIEL,EAAM,IAAI,CAACG,MAAS;AACzB,UAAMI,IAAU,EAAE,GAAGJ,EAAA;AACrB,WAAAI,EAAQD,EAAY,QAAS,IAAI,IAE7BH,EAAKG,EAAY,QAAS,KAAKH,EAAKG,EAAY,QAAS,EAAE,SAAS,MACtEC,EAAQD,EAAY,QAAS,IAAIF,EAAmBD,EAAKG,EAAY,QAAS,GAAGD,GAAUC,CAAW,IAGjGC;AAAA,EACT,CAAC,IAZQP;AAaX;AAEO,SAASQ,EACdR,GACAS,GACAC,IAGI,CAAA,GACJ;AACA,QAAM,EAAE,UAAAC,IAAW,IAAO,aAAAT,IAAc,eAAeQ;AAEvD,aAAWP,KAAQH,GAAO;AACxB,UAAMY,IAAWT,EAAKD,CAAW,KA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AAG1F,MAAI,CAACmC,KAAc,CAAC,MAAM,QAAQA,CAAU;AAC1C,WAAO,CAAA;AAET,QAAME,IAAaD,IAAgBD,EAAW,IAAI,CAACG,MAAcA,EAAKjC,CAAO,CAAC,IAAI8B;AAElF,MAAIR;AACF,WAAOU;AAGT,UAAQZ,GAAA;AAAA,IACN,KAAK,UAAU;AACb,YAAMc,IAAU,CAAC,GAAGF,CAAU;AAE9B,iBAAWjB,KAAOiB,GAAY;AAC5B,cAAM5C,IAAO0B,EAAS,KAAK,OAAKE,EAAEhB,CAAO,MAAMe,CAAG;AAClD,YAAI3B,GAAM;AACR,gBAAM+C,IAAYpC,EAAgBX,GAAMY,GAAST,CAAW;AAC5D,UAAA2C,EAAQ,KAAK,GAAGC,CAAS;AAAA,QAC3B;AAAA,MACF;AACA,aAAOtB,EAAgBqB,GAASpB,GAAUd,GAAST,CAAW;AAAA,IAChE;AAAA,IAEA,KAAK,SAAS;AACZ,YAAM2C,IAAU,CAAC,GAAGF,CAAU;AAC9B,iBAAWjB,KAAOiB,GAAY;AAC5B,cAAMI,IAAa5B,EAAYW,GAAMJ,GAAKf,GAAST,CAAW;AAC9D,QAAA2C,EAAQ,KAAK,GAAGE,CAAU;AAAA,MAC5B;AACA,aAAOvB,EAAgBqB,GAASpB,GAAUd,GAAST,CAAW;AAAA,IAChE;AAAA,IAEA,KAAK;AACH,aAAOY,EAAoB6B,GAAYhC,GAAST,CAAW;AAAA,IAG7D;AACE,aAAOsB,EAAgBmB,GAAYlB,GAAUd,GAAST,CAAW;AAAA,EACnE;AAEJ;"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export declare const TreeSelect: {
|
|
2
|
+
new (...args: any[]): import('vue').CreateComponentPublicInstanceWithMixins<Readonly<{
|
|
3
|
+
value: any;
|
|
4
|
+
}> & Readonly<{
|
|
5
|
+
onChange?: (...args: any[]) => any;
|
|
6
|
+
}>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
7
|
+
change: (...args: any[]) => void;
|
|
8
|
+
}, import('vue').PublicProps, {}, false, {}, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, any, any, import('vue').ComponentProvideOptions, {
|
|
9
|
+
P: {};
|
|
10
|
+
B: {};
|
|
11
|
+
D: {};
|
|
12
|
+
C: {};
|
|
13
|
+
M: {};
|
|
14
|
+
Defaults: {};
|
|
15
|
+
}, Readonly<{
|
|
16
|
+
value: any;
|
|
17
|
+
}> & Readonly<{
|
|
18
|
+
onChange?: (...args: any[]) => any;
|
|
19
|
+
}>, {}, {}, {}, {}, {}>;
|
|
20
|
+
__isFragment?: never;
|
|
21
|
+
__isTeleport?: never;
|
|
22
|
+
__isSuspense?: never;
|
|
23
|
+
} & import('vue').ComponentOptionsBase<Readonly<{
|
|
24
|
+
value: any;
|
|
25
|
+
}> & Readonly<{
|
|
26
|
+
onChange?: (...args: any[]) => any;
|
|
27
|
+
}>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
28
|
+
change: (...args: any[]) => void;
|
|
29
|
+
}, string, {}, {}, string, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, import('vue').ComponentProvideOptions> & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps & (new () => {
|
|
30
|
+
$slots: any;
|
|
31
|
+
});
|
|
32
|
+
export default TreeSelect;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { useField as f, connect as S, mapProps as v } from "@formily/vue";
|
|
2
|
+
import { defineComponent as g, useSlots as P, ref as R, createBlock as _, openBlock as T, unref as e, mergeProps as y, createSlots as h, renderList as k, withCtx as x, renderSlot as C, normalizeProps as w, guardReactiveProps as A } from "vue";
|
|
3
|
+
import { ElTreeSelect as B } from "element-plus";
|
|
4
|
+
import "@formily/reactive";
|
|
5
|
+
import { mapReadPretty as F } from "../__builtins__/shared/transform-component.mjs";
|
|
6
|
+
import { PreviewText as V } from "../preview-text/index.mjs";
|
|
7
|
+
import "@formily/core";
|
|
8
|
+
import "@formily/reactive-vue";
|
|
9
|
+
import { useCleanAttrs as j } from "../__builtins__/shared/utils.mjs";
|
|
10
|
+
const z = /* @__PURE__ */ g({
|
|
11
|
+
name: "FSelectTree",
|
|
12
|
+
inheritAttrs: !1,
|
|
13
|
+
__name: "tree-select",
|
|
14
|
+
props: {
|
|
15
|
+
value: null
|
|
16
|
+
},
|
|
17
|
+
emits: ["change"],
|
|
18
|
+
setup(a, { emit: s }) {
|
|
19
|
+
const m = a, i = s, c = P(), { props: p } = j(), r = R(), t = f();
|
|
20
|
+
return t.value?.inject({
|
|
21
|
+
getTreeSelectRef: () => r
|
|
22
|
+
}), (u, o) => (T(), _(e(B), y({
|
|
23
|
+
ref_key: "treeSelectRef",
|
|
24
|
+
ref: r,
|
|
25
|
+
"model-value": m.value,
|
|
26
|
+
loading: e(t).value?.loading
|
|
27
|
+
}, e(p), {
|
|
28
|
+
"onUpdate:modelValue": o[0] || (o[0] = (l) => i("change", l))
|
|
29
|
+
}), h({ _: 2 }, [
|
|
30
|
+
k(e(c), (l, n) => ({
|
|
31
|
+
name: n,
|
|
32
|
+
fn: x((d) => [
|
|
33
|
+
C(u.$slots, n, w(A({ field: e(t), ...d })))
|
|
34
|
+
])
|
|
35
|
+
}))
|
|
36
|
+
]), 1040, ["model-value", "loading"]));
|
|
37
|
+
}
|
|
38
|
+
}), H = S(
|
|
39
|
+
z,
|
|
40
|
+
v({ value: "modelValue", readOnly: "readonly", dataSource: "data" }),
|
|
41
|
+
F(V.Select)
|
|
42
|
+
);
|
|
43
|
+
export {
|
|
44
|
+
H as TreeSelect,
|
|
45
|
+
H as default
|
|
46
|
+
};
|
|
47
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../src/tree-select/tree-select.vue","../../src/tree-select/index.ts"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { Field } from '@formily/core'\nimport { useField } from '@formily/vue'\nimport { ElTreeSelect } from 'element-plus'\nimport { ref, useSlots } from 'vue'\nimport { useCleanAttrs } from '../__builtins__'\n\ndefineOptions({\n name: 'FSelectTree',\n inheritAttrs: false,\n})\n\nconst props = defineProps({\n value: null\n})\n\nconst emit = defineEmits(['change'])\n\nconst slots = useSlots()\n\nconst { props: attrs } = useCleanAttrs()\n\nconst treeSelectRef = ref()\n\nconst fieldRef = useField<Field>()\n\nfieldRef.value?.inject({\n getTreeSelectRef: () => {\n return treeSelectRef\n },\n})\n</script>\n\n<template>\n <ElTreeSelect\n ref=\"treeSelectRef\"\n :model-value=\"props.value\"\n :loading=\"fieldRef.value?.loading\"\n v-bind=\"attrs\"\n @update:model-value=\"emit('change', $event)\"\n >\n <template v-for=\"(_, name) of slots\" #[name]=\"slotData\">\n <slot :name=\"name\" v-bind=\"{ field: fieldRef, ...slotData }\" />\n </template>\n </ElTreeSelect>\n</template>\n","import { connect, mapProps } from '@formily/vue'\r\nimport { mapReadPretty } from '../__builtins__'\r\nimport { PreviewText } from '../preview-text'\r\nimport FTreeSelect from './tree-select.vue'\r\n\r\nexport const TreeSelect = connect(\r\n FTreeSelect,\r\n mapProps({ value: 'modelValue', readOnly: 'readonly', dataSource: 'data' }),\r\n mapReadPretty(PreviewText.Select),\r\n)\r\n\r\nexport default TreeSelect\r\n"],"names":["props","__props","emit","__emit","slots","useSlots","attrs","useCleanAttrs","treeSelectRef","ref","fieldRef","useField","_openBlock","_createBlock","_unref","_mergeProps","_cache","$event","_","name","_withCtx","slotData","_renderSlot","_ctx","_normalizeProps","_guardReactiveProps","TreeSelect","connect","FTreeSelect","mapProps","mapReadPretty","PreviewText"],"mappings":";;;;;;;;;;;;;;;;;;AAYA,UAAMA,IAAQC,GAIRC,IAAOC,GAEPC,IAAQC,EAAA,GAER,EAAE,OAAOC,EAAA,IAAUC,EAAA,GAEnBC,IAAgBC,EAAA,GAEhBC,IAAWC,EAAA;AAEjB,WAAAD,EAAS,OAAO,OAAO;AAAA,MACrB,kBAAkB,MACTF;AAAA,IACT,CACD,cAICI,KAAAC,EAUeC,MAVfC,EAUe;AAAA,eATT;AAAA,MAAJ,KAAIP;AAAA,MACH,eAAaR,EAAM;AAAA,MACnB,SAASc,EAAAJ,CAAA,EAAS,OAAO;AAAA,IAAA,GAClBI,EAAAR,CAAA,GAAK;AAAA,MACZ,uBAAkBU,EAAA,CAAA,MAAAA,EAAA,CAAA,IAAA,CAAAC,MAAEf,EAAI,UAAWe,CAAM;AAAA,IAAA;QAEZH,EAAAV,CAAA,GAAK,CAAjBc,GAAGC;;QACnB,IAAAC,EAAA,CAD4CC,MAAQ;AAAA,UACpDC,EAA+DC,EAAA,QAAlDJ,GAAIK,EAAAC,EAAA,EAAA,OAAmBX,EAAAJ,CAAA,MAAaW,EAAA,CAAQ,CAAA,CAAA;AAAA,QAAA;;;;ICrClDK,IAAaC;AAAA,EACxBC;AAAAA,EACAC,EAAS,EAAE,OAAO,cAAc,UAAU,YAAY,YAAY,QAAQ;AAAA,EAC1EC,EAAcC,EAAY,MAAM;AAClC;"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
type __VLS_Props = {
|
|
2
|
+
value: any;
|
|
3
|
+
};
|
|
4
|
+
declare function __VLS_template(): any;
|
|
5
|
+
type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
|
|
6
|
+
declare const __VLS_component: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
7
|
+
change: (...args: any[]) => void;
|
|
8
|
+
}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
9
|
+
onChange?: (...args: any[]) => any;
|
|
10
|
+
}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, any, any>;
|
|
11
|
+
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
|
|
12
|
+
export default _default;
|
|
13
|
+
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
14
|
+
new (): {
|
|
15
|
+
$slots: S;
|
|
16
|
+
};
|
|
17
|
+
};
|