@silver-formily/element-plus 1.0.1 → 2.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.
Files changed (162) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +35 -35
  3. package/esm/__builtins__/configs/index.mjs.map +1 -1
  4. package/esm/__builtins__/shared/hooks.mjs.map +1 -1
  5. package/esm/__builtins__/shared/loading.mjs.map +1 -1
  6. package/esm/__builtins__/shared/simple-version-compare.mjs.map +1 -1
  7. package/esm/__builtins__/shared/transform-component.d.ts +1 -2
  8. package/esm/__builtins__/shared/transform-component.mjs +1 -1
  9. package/esm/__builtins__/shared/transform-component.mjs.map +1 -1
  10. package/esm/__builtins__/shared/utils.mjs +1 -1
  11. package/esm/__builtins__/shared/utils.mjs.map +1 -1
  12. package/esm/array-base/index.mjs +39 -42
  13. package/esm/array-base/index.mjs.map +1 -1
  14. package/esm/array-base/symbols.mjs.map +1 -1
  15. package/esm/array-base/utils.mjs +29 -33
  16. package/esm/array-base/utils.mjs.map +1 -1
  17. package/esm/array-cards/array-cards.d.ts +1 -1
  18. package/esm/array-cards/index.d.ts +3 -3
  19. package/esm/array-cards/index.mjs +23 -25
  20. package/esm/array-cards/index.mjs.map +1 -1
  21. package/esm/array-collapse/array-collapse.d.ts +2 -2
  22. package/esm/array-collapse/index.d.ts +3 -3
  23. package/esm/array-collapse/index.mjs +87 -88
  24. package/esm/array-collapse/index.mjs.map +1 -1
  25. package/esm/array-collapse/utils.mjs +2 -8
  26. package/esm/array-collapse/utils.mjs.map +1 -1
  27. package/esm/array-items/index.mjs +29 -32
  28. package/esm/array-items/index.mjs.map +1 -1
  29. package/esm/array-list-tabs/array-list-tabs.d.ts +3 -3
  30. package/esm/array-list-tabs/index.d.ts +6 -6
  31. package/esm/array-list-tabs/index.mjs +88 -86
  32. package/esm/array-list-tabs/index.mjs.map +1 -1
  33. package/esm/array-list-tabs/utils.mjs +5 -11
  34. package/esm/array-list-tabs/utils.mjs.map +1 -1
  35. package/esm/array-table/array-table.d.ts +1 -1
  36. package/esm/array-table/index.d.ts +3 -3
  37. package/esm/array-table/index.mjs +48 -50
  38. package/esm/array-table/index.mjs.map +1 -1
  39. package/esm/array-table/types.d.ts +1 -1
  40. package/esm/array-table/utils.mjs +12 -18
  41. package/esm/array-table/utils.mjs.map +1 -1
  42. package/esm/array-tabs/index.mjs +26 -28
  43. package/esm/array-tabs/index.mjs.map +1 -1
  44. package/esm/cascader/cascader.d.ts +1 -6
  45. package/esm/cascader/index.d.ts +3 -16
  46. package/esm/cascader/index.mjs +26 -32
  47. package/esm/cascader/index.mjs.map +1 -1
  48. package/esm/checkbox/checkbox-group.d.ts +2 -15
  49. package/esm/checkbox/index.d.ts +3 -28
  50. package/esm/checkbox/index.mjs +33 -45
  51. package/esm/checkbox/index.mjs.map +1 -1
  52. package/esm/date-picker/index.d.ts +442 -1
  53. package/esm/date-picker/index.mjs +9 -18
  54. package/esm/date-picker/index.mjs.map +1 -1
  55. package/esm/editable/index.mjs +34 -36
  56. package/esm/editable/index.mjs.map +1 -1
  57. package/esm/form/form.mjs +7 -7
  58. package/esm/form/form.mjs.map +1 -1
  59. package/esm/form-button-group/index.mjs +20 -23
  60. package/esm/form-button-group/index.mjs.map +1 -1
  61. package/esm/form-button-group/utils.mjs +2 -8
  62. package/esm/form-button-group/utils.mjs.map +1 -1
  63. package/esm/form-collapse/index.mjs +31 -32
  64. package/esm/form-collapse/index.mjs.map +1 -1
  65. package/esm/form-collapse/utils.mjs.map +1 -1
  66. package/esm/form-dialog/index.mjs +18 -18
  67. package/esm/form-dialog/index.mjs.map +1 -1
  68. package/esm/form-drawer/index.mjs +17 -17
  69. package/esm/form-drawer/index.mjs.map +1 -1
  70. package/esm/form-grid/hooks.mjs.map +1 -1
  71. package/esm/form-grid/index.mjs +20 -23
  72. package/esm/form-grid/index.mjs.map +1 -1
  73. package/esm/form-item/index.mjs +30 -32
  74. package/esm/form-item/index.mjs.map +1 -1
  75. package/esm/form-item/utils.mjs.map +1 -1
  76. package/esm/form-layout/form-layout.mjs +11 -14
  77. package/esm/form-layout/form-layout.mjs.map +1 -1
  78. package/esm/form-layout/utils.mjs +19 -24
  79. package/esm/form-layout/utils.mjs.map +1 -1
  80. package/esm/form-step/index.mjs +22 -24
  81. package/esm/form-step/index.mjs.map +1 -1
  82. package/esm/form-step/utils.mjs.map +1 -1
  83. package/esm/form-tab/form-tab.d.ts +2 -2
  84. package/esm/form-tab/hooks.mjs +1 -1
  85. package/esm/form-tab/hooks.mjs.map +1 -1
  86. package/esm/form-tab/index.d.ts +5 -5
  87. package/esm/form-tab/index.mjs +28 -29
  88. package/esm/form-tab/index.mjs.map +1 -1
  89. package/esm/form-tab/types.d.ts +1 -1
  90. package/esm/form-tab/utils.mjs.map +1 -1
  91. package/esm/index.mjs +58 -58
  92. package/esm/input/index.d.ts +6 -38
  93. package/esm/input/index.mjs +36 -48
  94. package/esm/input/index.mjs.map +1 -1
  95. package/esm/input/input.d.ts +1 -8
  96. package/esm/input-number/index.d.ts +215 -1
  97. package/esm/input-number/index.mjs +8 -17
  98. package/esm/input-number/index.mjs.map +1 -1
  99. package/esm/pagination/components/jumper.mjs.map +1 -1
  100. package/esm/pagination/components/next.mjs.map +1 -1
  101. package/esm/pagination/components/pager.mjs.map +1 -1
  102. package/esm/pagination/components/prev.mjs.map +1 -1
  103. package/esm/pagination/components/total.mjs.map +1 -1
  104. package/esm/pagination/pagination.mjs +1 -1
  105. package/esm/pagination/pagination.mjs.map +1 -1
  106. package/esm/password/index.d.ts +6 -38
  107. package/esm/password/index.mjs +1 -1
  108. package/esm/password/index.mjs.map +1 -1
  109. package/esm/preview-text/cascader.d.ts +1 -1
  110. package/esm/preview-text/date-picker.d.ts +1 -1
  111. package/esm/preview-text/index.d.ts +13 -13
  112. package/esm/preview-text/index.mjs +115 -118
  113. package/esm/preview-text/index.mjs.map +1 -1
  114. package/esm/preview-text/input.d.ts +1 -1
  115. package/esm/preview-text/select.d.ts +1 -1
  116. package/esm/preview-text/time-picker.d.ts +1 -1
  117. package/esm/preview-text/tree.d.ts +1 -1
  118. package/esm/preview-text/utils.mjs.map +1 -1
  119. package/esm/radio/index.d.ts +3 -25
  120. package/esm/radio/index.mjs +34 -44
  121. package/esm/radio/index.mjs.map +1 -1
  122. package/esm/radio/radio-group.d.ts +2 -13
  123. package/esm/reset/index.mjs +1 -1
  124. package/esm/reset/index.mjs.map +1 -1
  125. package/esm/select/index.d.ts +3 -16
  126. package/esm/select/index.mjs +62 -70
  127. package/esm/select/index.mjs.map +1 -1
  128. package/esm/select/select.d.ts +1 -6
  129. package/esm/select-table/index.d.ts +5 -5
  130. package/esm/select-table/index.mjs +78 -81
  131. package/esm/select-table/index.mjs.map +1 -1
  132. package/esm/select-table/select-table.d.ts +2 -2
  133. package/esm/select-table/types.d.ts +1 -1
  134. package/esm/submit/index.mjs +1 -1
  135. package/esm/submit/index.mjs.map +1 -1
  136. package/esm/switch/index.d.ts +260 -1
  137. package/esm/switch/index.mjs +5 -11
  138. package/esm/switch/index.mjs.map +1 -1
  139. package/esm/time-picker/index.d.ts +442 -1
  140. package/esm/time-picker/index.mjs +8 -15
  141. package/esm/time-picker/index.mjs.map +1 -1
  142. package/esm/time-select/index.d.ts +124 -1
  143. package/esm/time-select/index.mjs +10 -17
  144. package/esm/time-select/index.mjs.map +1 -1
  145. package/esm/transfer/index.mjs +5 -5
  146. package/esm/transfer/index.mjs.map +1 -1
  147. package/esm/tree/index.d.ts +5 -5
  148. package/esm/tree/index.mjs +42 -45
  149. package/esm/tree/index.mjs.map +1 -1
  150. package/esm/tree/tree.d.ts +2 -2
  151. package/esm/tree/types.d.ts +1 -1
  152. package/esm/tree/utils.mjs.map +1 -1
  153. package/esm/tree-select/index.d.ts +3 -19
  154. package/esm/tree-select/index.mjs +22 -32
  155. package/esm/tree-select/index.mjs.map +1 -1
  156. package/esm/tree-select/tree-select.d.ts +1 -8
  157. package/esm/upload/index.d.ts +5 -5
  158. package/esm/upload/index.mjs +14 -16
  159. package/esm/upload/index.mjs.map +1 -1
  160. package/esm/upload/upload.d.ts +2 -2
  161. package/esm/vendor/sizes.mjs.map +1 -1
  162. package/package.json +114 -116
@@ -1,21 +1,14 @@
1
- import { connect as e, mapProps as t } from "@formily/vue";
2
- import { ElTimeSelect as o } from "element-plus";
3
- import "vue";
4
- import "@formily/reactive";
5
- import { transformComponent as m, mapReadPretty as r } from "../__builtins__/shared/transform-component.mjs";
6
- import { PreviewText as a } from "../preview-text/index.mjs";
7
- const l = m(
8
- o,
9
- {
10
- change: "update:modelValue"
11
- }
12
- ), f = e(
13
- l,
14
- t({ value: "modelValue", disabled: "disabled", editable: "editable" }),
15
- r(a.Input)
1
+ import { connect as e, mapProps as t } from "@silver-formily/vue";
2
+ import { ElTimeSelect as m } from "element-plus";
3
+ import { PreviewText as o } from "../preview-text/index.mjs";
4
+ import { mapReadPretty as r } from "../__builtins__/shared/transform-component.mjs";
5
+ const l = e(
6
+ m,
7
+ t({ disabled: "disabled", editable: "editable" }),
8
+ r(o.Input)
16
9
  );
17
10
  export {
18
- f as TimeSelect,
19
- f as default
11
+ l as TimeSelect,
12
+ l as default
20
13
  };
21
14
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":["../../src/time-select/index.ts"],"sourcesContent":["import type { TimeSelectProps } from 'element-plus'\r\nimport { connect, mapProps } from '@formily/vue'\r\nimport { ElTimeSelect } from 'element-plus'\r\nimport { mapReadPretty, transformComponent } from '../__builtins__'\r\nimport { PreviewText } from '../preview-text'\r\n\r\nconst TransformElTimeSelect = transformComponent<TimeSelectProps>(\r\n ElTimeSelect,\r\n {\r\n change: 'update:modelValue',\r\n },\r\n)\r\n\r\nexport const TimeSelect = connect(\r\n TransformElTimeSelect,\r\n mapProps({ value: 'modelValue', disabled: 'disabled', editable: 'editable' }),\r\n mapReadPretty(PreviewText.Input),\r\n)\r\n\r\nexport default TimeSelect\r\n"],"names":["TransformElTimeSelect","transformComponent","ElTimeSelect","TimeSelect","connect","mapProps","mapReadPretty","PreviewText"],"mappings":";;;;;;AAMA,MAAMA,IAAwBC;AAAA,EAC5BC;AAAA,EACA;AAAA,IACE,QAAQ;AAAA,EAAA;AAEZ,GAEaC,IAAaC;AAAA,EACxBJ;AAAA,EACAK,EAAS,EAAE,OAAO,cAAc,UAAU,YAAY,UAAU,YAAY;AAAA,EAC5EC,EAAcC,EAAY,KAAK;AACjC;"}
1
+ {"version":3,"file":"index.mjs","sources":["../../src/time-select/index.ts"],"sourcesContent":["import { connect, mapProps } from '@silver-formily/vue'\r\nimport { ElTimeSelect } from 'element-plus'\r\nimport { mapReadPretty } from '../__builtins__'\r\nimport { PreviewText } from '../preview-text'\r\n\r\nexport const TimeSelect = connect<typeof ElTimeSelect>(\n ElTimeSelect,\n mapProps({ disabled: 'disabled', editable: 'editable' }),\r\n mapReadPretty(PreviewText.Input),\r\n)\r\n\r\nexport default TimeSelect\r\n"],"names":["TimeSelect","connect","ElTimeSelect","mapProps","mapReadPretty","PreviewText"],"mappings":";;;;AAKO,MAAMA,IAAaC;AAAA,EACxBC;AAAA,EACAC,EAAS,EAAE,UAAU,YAAY,UAAU,YAAY;AAAA,EACvDC,EAAcC,EAAY,KAAK;AACjC;"}
@@ -1,11 +1,11 @@
1
- import { connect as a, mapProps as r } from "@formily/vue";
1
+ import { connect as r, mapProps as a } from "@silver-formily/vue";
2
2
  import { ElTransfer as o } from "element-plus";
3
- const m = a(
3
+ const f = r(
4
4
  o,
5
- r({ dataSource: "data", value: "modelValue" })
5
+ a({ dataSource: "data" })
6
6
  );
7
7
  export {
8
- m as Transfer,
9
- m as default
8
+ f as Transfer,
9
+ f as default
10
10
  };
11
11
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":["../../src/transfer/index.ts"],"sourcesContent":["import { connect, mapProps } from '@formily/vue'\n\nimport { ElTransfer } from 'element-plus'\n\nexport type TransferProps = typeof ElTransfer\n\nexport const Transfer = connect(\n ElTransfer,\n mapProps({ dataSource: 'data', value: 'modelValue' }),\n)\n\nexport default Transfer\n"],"names":["Transfer","connect","ElTransfer","mapProps"],"mappings":";;AAMO,MAAMA,IAAWC;AAAA,EACtBC;AAAA,EACAC,EAAS,EAAE,YAAY,QAAQ,OAAO,cAAc;AACtD;"}
1
+ {"version":3,"file":"index.mjs","sources":["../../src/transfer/index.ts"],"sourcesContent":["import { connect, mapProps } from '@silver-formily/vue'\r\nimport { ElTransfer } from 'element-plus'\r\n\r\nexport type TransferProps = typeof ElTransfer\r\n\r\nexport const Transfer = connect(\r\n ElTransfer,\r\n mapProps({ dataSource: 'data' }),\r\n)\r\n\r\nexport default Transfer\r\n"],"names":["Transfer","connect","ElTransfer","mapProps"],"mappings":";;AAKO,MAAMA,IAAWC;AAAA,EACtBC;AAAA,EACAC,EAAS,EAAE,YAAY,OAAA,CAAQ;AACjC;"}
@@ -1,8 +1,8 @@
1
1
  declare const Tree: {
2
2
  new (...args: any[]): import('vue').CreateComponentPublicInstanceWithMixins<Readonly<import('./types').TreeValueTypeProps> & Readonly<{
3
- onChange?: (value: any) => any;
3
+ "onUpdate:modelValue"?: (value: any) => any;
4
4
  }>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
5
- change: (value: any) => any;
5
+ "update:modelValue": (value: any) => any;
6
6
  }, import('vue').PublicProps, {
7
7
  props: any;
8
8
  valueType: "all" | "parent" | "child" | "path";
@@ -16,7 +16,7 @@ declare const Tree: {
16
16
  M: {};
17
17
  Defaults: {};
18
18
  }, Readonly<import('./types').TreeValueTypeProps> & Readonly<{
19
- onChange?: (value: any) => any;
19
+ "onUpdate:modelValue"?: (value: any) => any;
20
20
  }>, {}, {}, {}, {}, {
21
21
  props: any;
22
22
  valueType: "all" | "parent" | "child" | "path";
@@ -27,9 +27,9 @@ declare const Tree: {
27
27
  __isTeleport?: never;
28
28
  __isSuspense?: never;
29
29
  } & import('vue').ComponentOptionsBase<Readonly<import('./types').TreeValueTypeProps> & Readonly<{
30
- onChange?: (value: any) => any;
30
+ "onUpdate:modelValue"?: (value: any) => any;
31
31
  }>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
32
- change: (value: any) => any;
32
+ "update:modelValue": (value: any) => any;
33
33
  }, string, {
34
34
  props: any;
35
35
  valueType: "all" | "parent" | "child" | "path";
@@ -1,14 +1,11 @@
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";
1
+ import { useField as _, connect as A, mapProps as D } from "@silver-formily/vue";
2
+ import { PreviewText as H } from "../preview-text/index.mjs";
3
+ import { defineComponent as F, useSlots as P, ref as h, 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 E, renderSlot as L, normalizeProps as j, guardReactiveProps as z } from "vue";
4
+ import { isFn as I } from "@formily/shared";
5
+ import { ElScrollbar as N, ElTree as O, vLoading as $ } from "element-plus";
6
+ import { addDisabledToNodes as q, flattenTree as G, getInputKeys as J, getOutputData as M } from "./utils.mjs";
7
+ import { useCleanAttrs as Q } from "../__builtins__/shared/utils.mjs";
8
+ import { mapReadPretty as U } from "../__builtins__/shared/transform-component.mjs";
12
9
  const W = /* @__PURE__ */ F({
13
10
  name: "Tree",
14
11
  inheritAttrs: !1,
@@ -16,7 +13,7 @@ const W = /* @__PURE__ */ F({
16
13
  props: {
17
14
  nodeKey: null,
18
15
  data: null,
19
- value: null,
16
+ modelValue: null,
20
17
  valueType: { default: "all" },
21
18
  includeHalfChecked: { type: Boolean, default: !1 },
22
19
  optionAsValue: { type: Boolean, default: !1 },
@@ -29,76 +26,76 @@ const W = /* @__PURE__ */ F({
29
26
  height: null,
30
27
  maxHeight: null
31
28
  },
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() {
29
+ emits: ["update:modelValue"],
30
+ setup(K, { emit: V }) {
31
+ const e = K, n = V, b = P(), { props: o } = Q(), l = h(), d = h([]), i = y(() => q(e.data ?? [], o.value.disabled, e.props)), u = y(() => G(i.value ?? [], [], e.props.children));
32
+ async function c() {
36
33
  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,
34
+ const t = l.value.getCheckedKeys(), f = l.value.getHalfCheckedKeys() || [];
35
+ d.value = t;
36
+ const { value: m, nodes: r } = M(t, f, {
37
+ flatData: u.value,
41
38
  nodeKey: e.nodeKey,
42
39
  propsConfig: e.props,
43
40
  data: e.data ?? [],
44
41
  valueType: e.valueType,
45
42
  includeHalfChecked: e.includeHalfChecked,
46
- checkStrictly: l.value.checkStrictly
43
+ checkStrictly: o.value.checkStrictly
47
44
  });
48
- e.optionAsValue ? q(e.optionFormatter) ? i("change", r.map((s, S, _) => e.optionFormatter(s, S, _))) : i("change", r) : i("change", h);
45
+ e.optionAsValue ? I(e.optionFormatter) ? n("update:modelValue", r.map((s, x, S) => e.optionFormatter(s, x, S))) : n("update:modelValue", r) : n("update:modelValue", m);
49
46
  }
50
- v(() => e.value, (t) => {
51
- t !== void 0 && (n.value = Q(t, {
47
+ v(() => e.modelValue, (t) => {
48
+ t !== void 0 && (d.value = J(t, {
52
49
  optionAsValue: e.optionAsValue,
53
50
  nodeKey: e.nodeKey,
54
- flatData: d.value,
51
+ flatData: u.value,
55
52
  propsConfig: e.props,
56
53
  data: e.data ?? [],
57
54
  valueType: e.valueType,
58
- checkStrictly: l.value.checkStrictly
55
+ checkStrictly: o.value.checkStrictly
59
56
  }), k(() => {
60
- o.value && o.value.setCheckedKeys(n.value);
57
+ l.value && l.value.setCheckedKeys(d.value);
61
58
  }));
62
59
  }, { immediate: !0 }), v(() => [e.valueType, e.optionAsValue, e.includeHalfChecked], () => {
63
- p();
60
+ c();
64
61
  }, { immediate: !1 });
65
- const u = A();
66
- return u.value?.inject({
67
- getTreeRef: () => o
68
- }), (t, f) => (C(), g(a(z), {
62
+ const p = _();
63
+ return p.value?.inject({
64
+ getTreeRef: () => l
65
+ }), (t, f) => (C(), g(a(N), {
69
66
  height: e.height,
70
67
  "max-height": e.maxHeight
71
68
  }, {
72
69
  default: T(() => [
73
- R((C(), g(a(I), w({
70
+ R((C(), g(a(O), w({
74
71
  ref_key: "treeRef",
75
- ref: o,
76
- data: c.value,
72
+ ref: l,
73
+ data: i.value,
77
74
  props: e.props,
78
75
  "node-key": e.nodeKey,
79
- "default-checked-keys": n.value,
76
+ "default-checked-keys": d.value,
80
77
  "show-checkbox": !0
81
- }, a(l), { onCheck: p }), B({ _: 2 }, [
82
- V(a(x), (h, r) => ({
78
+ }, a(o), { onCheck: c }), B({ _: 2 }, [
79
+ E(a(b), (m, r) => ({
83
80
  name: r,
84
81
  fn: T((s) => [
85
- E(t.$slots, r, L(j({ field: a(u), ...s })))
82
+ L(t.$slots, r, j(z({ field: a(p), ...s })))
86
83
  ])
87
84
  }))
88
85
  ]), 1040, ["data", "props", "node-key", "default-checked-keys"])), [
89
- [a(N), a(l).loading]
86
+ [a($), a(o).loading]
90
87
  ])
91
88
  ]),
92
89
  _: 3
93
90
  }, 8, ["height", "max-height"]));
94
91
  }
95
- }), se = D(
92
+ }), re = A(
96
93
  W,
97
- H({ dataSource: "data", loading: "loading", disabled: !0 }),
98
- O($.Tree)
94
+ D({ dataSource: "data", loading: "loading", disabled: !0 }),
95
+ U(H.Tree)
99
96
  );
100
97
  export {
101
- se as Tree,
102
- se as default
98
+ re as Tree,
99
+ re as default
103
100
  };
104
101
  //# sourceMappingURL=index.mjs.map
@@ -1 +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,EAA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,wBAAsBU,EAAA;AAAA,UACtB,iBAAe;AAAA,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;"}
1
+ {"version":3,"file":"index.mjs","sources":["../../src/tree/tree.vue","../../src/tree/index.ts"],"sourcesContent":["<script setup lang=\"ts\">\r\nimport type { Field } from '@formily/core'\r\nimport type { TreeValueTypeProps } from './types'\r\nimport { isFn } from '@formily/shared'\r\nimport { useField } from '@silver-formily/vue'\r\nimport { ElScrollbar, ElTree, vLoading } from 'element-plus'\r\nimport { computed, nextTick, ref, useSlots, watch } from 'vue'\r\nimport { useCleanAttrs } from '../__builtins__'\r\nimport { addDisabledToNodes, flattenTree, getInputKeys, getOutputData } from './utils'\r\n\r\ndefineOptions({\r\n name: 'Tree',\r\n inheritAttrs: false,\r\n})\r\n\r\nconst props = defineProps({\n nodeKey: null,\n data: null,\n modelValue: null,\n valueType: { default: 'all' },\n includeHalfChecked: { type: Boolean, default: false },\n optionAsValue: { type: Boolean, default: false },\n props: { default: {\r\n children: 'children',\r\n label: 'label',\r\n disabled: 'disabled',\r\n } },\n optionFormatter: { type: Function },\n height: null,\n maxHeight: null\n})\r\n\r\nconst emit = defineEmits([\"update:modelValue\"])\r\n\r\nconst slots = useSlots()\r\n\r\nconst { props: attrs } = useCleanAttrs()\r\nconst treeRef = ref<InstanceType<typeof ElTree>>()\r\nconst checkedKeys = ref<any[]>([])\r\n\r\nconst processedData = computed(() => {\r\n return addDisabledToNodes(props.data ?? [], attrs.value.disabled, props.props)\r\n})\r\n\r\nconst flatData = computed(() => flattenTree(processedData.value ?? [], [], props.props.children))\r\n\r\nasync function handleCheck() {\r\n await nextTick()\r\n const keys = treeRef.value.getCheckedKeys()\r\n const halfCheckedKeys = treeRef.value.getHalfCheckedKeys() || []\r\n checkedKeys.value = keys\r\n\r\n const { value, nodes } = getOutputData(keys, halfCheckedKeys, {\r\n flatData: flatData.value,\r\n nodeKey: props.nodeKey,\r\n propsConfig: props.props,\r\n data: props.data ?? [],\r\n valueType: props.valueType,\r\n includeHalfChecked: props.includeHalfChecked,\r\n checkStrictly: attrs.value.checkStrictly,\r\n })\r\n\r\n if (props.optionAsValue) {\r\n isFn(props.optionFormatter)\r\n ? emit('update:modelValue', nodes.map((element, index, array) => {\r\n return props.optionFormatter(element, index, array)\r\n }))\r\n : emit('update:modelValue', nodes)\r\n }\r\n else {\r\n emit('update:modelValue', value)\r\n }\r\n}\r\n\r\nwatch(() => props.modelValue, (newValue) => {\r\n if (newValue !== undefined) {\r\n checkedKeys.value = getInputKeys(newValue, {\r\n optionAsValue: props.optionAsValue,\r\n nodeKey: props.nodeKey,\r\n flatData: flatData.value,\r\n propsConfig: props.props,\r\n data: props.data ?? [],\r\n valueType: props.valueType,\r\n checkStrictly: attrs.value.checkStrictly,\r\n })\r\n nextTick(() => {\r\n if (treeRef.value) {\r\n treeRef.value.setCheckedKeys(checkedKeys.value)\r\n }\r\n })\r\n }\r\n}, { immediate: true })\r\n\r\nwatch(() => [props.valueType, props.optionAsValue, props.includeHalfChecked], () => {\r\n handleCheck()\r\n}, { immediate: false })\r\n\r\nconst fieldRef = useField<Field>()\r\nfieldRef.value?.inject({\r\n getTreeRef: () => {\r\n return treeRef\r\n },\r\n})\r\n</script>\r\n\r\n<template>\r\n <ElScrollbar :height=\"props.height\" :max-height=\"props.maxHeight\">\r\n <ElTree\r\n ref=\"treeRef\"\r\n v-loading=\"attrs.loading\"\r\n :data=\"processedData\"\r\n :props=\"props.props\"\r\n :node-key=\"props.nodeKey\"\r\n :default-checked-keys=\"checkedKeys\"\r\n :show-checkbox=\"true\"\r\n v-bind=\"attrs\"\r\n @check=\"handleCheck\"\r\n >\r\n <template v-for=\"(_, name) of slots\" #[name]=\"slotData\">\r\n <slot :name=\"name\" v-bind=\"{ field: fieldRef, ...slotData }\" />\r\n </template>\r\n </ElTree>\r\n </ElScrollbar>\r\n</template>\r\n","import { connect, mapProps } from '@silver-formily/vue'\r\nimport { mapReadPretty } from '../__builtins__'\r\nimport { PreviewText } from '../preview-text'\r\nimport InnerTree from './tree.vue'\r\n\r\nconst Tree = connect(\r\n InnerTree,\r\n mapProps({ dataSource: 'data', loading: 'loading', disabled: true }),\r\n mapReadPretty(PreviewText.Tree),\r\n)\r\n\r\nexport { Tree }\r\n\r\nexport default Tree\r\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,EA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
4
  declare const __VLS_component: import('vue').DefineComponent<TreeValueTypeProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
5
- change: (value: any) => any;
5
+ "update:modelValue": (value: any) => any;
6
6
  }, string, import('vue').PublicProps, Readonly<TreeValueTypeProps> & Readonly<{
7
- onChange?: (value: any) => any;
7
+ "onUpdate:modelValue"?: (value: any) => any;
8
8
  }>, {
9
9
  props: any;
10
10
  valueType: "all" | "parent" | "child" | "path";
@@ -2,7 +2,7 @@ import { TreeNodeData } from 'element-plus';
2
2
  export interface TreeValueTypeProps {
3
3
  nodeKey: string;
4
4
  data?: TreeNodeData[];
5
- value?: any;
5
+ modelValue?: any;
6
6
  valueType?: 'all' | 'parent' | 'child' | 'path';
7
7
  includeHalfChecked?: boolean;
8
8
  optionAsValue?: boolean;
@@ -1 +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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;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;"}
1
+ {"version":3,"file":"utils.mjs","sources":["../../src/tree/utils.ts"],"sourcesContent":["import type { TreeNodeData } from 'element-plus'\r\n\r\nexport function flattenTree(nodes: TreeNodeData[], result: TreeNodeData[] = [], childrenKey = 'children'): TreeNodeData[] {\r\n for (const node of nodes) {\r\n result.push(node)\r\n if (node[childrenKey] && node[childrenKey].length > 0) {\r\n flattenTree(node[childrenKey], result, childrenKey)\r\n }\r\n }\r\n return result\r\n}\r\n\r\nexport function addDisabledToNodes(nodes: TreeNodeData[], disabled: boolean, propsConfig: any): TreeNodeData[] {\r\n if (!disabled) {\r\n return nodes\r\n }\r\n\r\n return nodes.map((node) => {\r\n const newNode = { ...node }\r\n newNode[propsConfig.disabled!] = true\r\n\r\n if (node[propsConfig.children!] && node[propsConfig.children!].length > 0) {\r\n newNode[propsConfig.children!] = addDisabledToNodes(node[propsConfig.children!], disabled, propsConfig)\r\n }\r\n\r\n return newNode\r\n })\r\n}\r\n\r\nexport function traverseTree(\r\n nodes: TreeNodeData[],\r\n callback: (node: TreeNodeData) => void,\r\n options: {\r\n leafOnly?: boolean\r\n childrenKey?: string\r\n } = {},\r\n) {\r\n const { leafOnly = false, childrenKey = 'children' } = options\r\n\r\n for (const node of nodes) {\r\n const children = node[childrenKey] || []\r\n const isLeaf = children.length === 0\r\n\r\n if (!leafOnly || isLeaf) {\r\n callback(node)\r\n }\r\n if (children.length > 0) {\r\n traverseTree(children, callback, options)\r\n }\r\n }\r\n}\r\n\r\nexport function getChildrenKeys(node: TreeNodeData, nodeKey: string, propsConfig: any): any[] {\r\n const children = node[propsConfig.children!] || []\r\n if (children.length === 0)\r\n return []\r\n\r\n const keys: any[] = []\r\n traverseTree(children, (child) => {\r\n keys.push(child[nodeKey])\r\n }, { childrenKey: propsConfig.children })\r\n\r\n return keys\r\n}\r\n\r\nexport function extractKeysFromPath(pathNodes: TreeNodeData[], nodeKey: string, propsConfig: any): any[] {\r\n const keys: any[] = []\r\n traverseTree(pathNodes, (node) => {\r\n keys.push(node[nodeKey])\r\n }, { leafOnly: true, childrenKey: propsConfig.children })\r\n\r\n return keys\r\n}\r\n\r\nexport function getSelectedPath(nodes: TreeNodeData[], selectedKeys: any[], nodeKey: string, propsConfig: any): TreeNodeData[] {\r\n const result: TreeNodeData[] = []\r\n\r\n for (const node of nodes) {\r\n const children = node[propsConfig.children!] || []\r\n const hasSelectedChild = children.length > 0\r\n ? getSelectedPath(children, selectedKeys, nodeKey, propsConfig).length > 0\r\n : false\r\n\r\n if (selectedKeys.includes(node[nodeKey]) || hasSelectedChild) {\r\n const newNode = { ...node }\r\n if (hasSelectedChild && children.length > 0) {\r\n newNode[propsConfig.children!] = getSelectedPath(children, selectedKeys, nodeKey, propsConfig)\r\n }\r\n result.push(newNode)\r\n }\r\n }\r\n\r\n return result\r\n}\r\n\r\n/**\r\n * 查找节点的所有父节点路径\r\n */\r\nexport function findParents(nodes: TreeNodeData[], targetKey: any, nodeKey: string, propsConfig: any, parents: any[] = []): any[] {\r\n for (const node of nodes) {\r\n const currentPath = [...parents, node[nodeKey]]\r\n\r\n if (node[nodeKey] === targetKey) {\r\n return currentPath\r\n }\r\n\r\n const children = node[propsConfig.children!] || []\r\n if (children.length > 0) {\r\n const found = findParents(children, targetKey, nodeKey, propsConfig, currentPath)\r\n if (found.length > 0) {\r\n return found\r\n }\r\n }\r\n }\r\n /* istanbul ignore next -- @preserve */\r\n return []\r\n}\r\n\r\n/**\r\n * 过滤叶子节点\r\n */\r\nexport function filterLeafNodes(keys: any[], flatData: TreeNodeData[], nodeKey: string, propsConfig: any): any[] {\r\n return keys.filter((key) => {\r\n const node = flatData.find(n => n[nodeKey] === key)\r\n if (!node)\r\n return false\r\n const children = node[propsConfig.children!] || []\r\n return children.length === 0\r\n })\r\n}\r\n\r\n/**\r\n * 获取输出数据\r\n */\r\nexport function getOutputData(\r\n keys: any[],\r\n halfCheckedKeys: any[] = [],\r\n options: {\r\n flatData: TreeNodeData[]\r\n nodeKey: string\r\n propsConfig: any\r\n data: TreeNodeData[]\r\n valueType: string\r\n includeHalfChecked: boolean\r\n checkStrictly: boolean\r\n },\r\n) {\r\n const { flatData, nodeKey, propsConfig, data, valueType, includeHalfChecked, checkStrictly } = options\r\n\r\n const selectedNodes = flatData.filter(node =>\r\n keys.includes(node[nodeKey]),\r\n )\r\n\r\n let outputKeys = [...keys]\r\n let outputNodes = [...selectedNodes]\r\n\r\n if (checkStrictly) {\r\n return {\r\n value: outputKeys,\r\n nodes: outputNodes,\r\n }\r\n }\r\n\r\n switch (valueType) {\r\n case 'parent': {\r\n const allChildKeys: any[] = []\r\n for (const node of selectedNodes) {\r\n allChildKeys.push(...getChildrenKeys(node, nodeKey, propsConfig))\r\n }\r\n outputKeys = keys.filter(key => !allChildKeys.includes(key))\r\n outputNodes = selectedNodes.filter(node =>\r\n outputKeys.includes(node[nodeKey]),\r\n )\r\n break\r\n }\r\n\r\n case 'child': {\r\n for (const node of selectedNodes) {\r\n const childKeys = getChildrenKeys(node, nodeKey, propsConfig)\r\n const hasSelectedChild = childKeys.some(key => keys.includes(key))\r\n if (hasSelectedChild) {\r\n outputKeys = outputKeys.filter(key => key !== node[nodeKey])\r\n outputNodes = outputNodes.filter(n =>\r\n n[nodeKey] !== node[nodeKey],\r\n )\r\n }\r\n }\r\n break\r\n }\r\n\r\n case 'path': {\r\n const selectedPath = getSelectedPath(data, keys, nodeKey, propsConfig)\r\n return {\r\n value: selectedPath,\r\n nodes: selectedPath,\r\n }\r\n }\r\n\r\n default: { // 'all'\r\n if (includeHalfChecked && halfCheckedKeys.length > 0) {\r\n const halfCheckedNodes = flatData.filter(node =>\r\n halfCheckedKeys.includes(node[nodeKey]),\r\n )\r\n outputKeys = [...outputKeys, ...halfCheckedKeys]\r\n outputNodes = [...outputNodes, ...halfCheckedNodes]\r\n }\r\n break\r\n }\r\n }\r\n\r\n return {\r\n value: outputKeys,\r\n nodes: outputNodes,\r\n }\r\n}\r\n\r\n/**\r\n * 根据valueType将输入值转换为checkedKeys\r\n */\r\nexport function getInputKeys(\r\n inputValue: any,\r\n options: {\r\n optionAsValue: boolean\r\n nodeKey: string\r\n flatData: TreeNodeData[]\r\n propsConfig: any\r\n data: TreeNodeData[]\r\n valueType: string\r\n checkStrictly: boolean\r\n },\r\n): any[] {\r\n const { optionAsValue, nodeKey, flatData, propsConfig, data, valueType, checkStrictly } = options\r\n\r\n /* istanbul ignore if -- @preserve */\r\n if (!inputValue || !Array.isArray(inputValue))\r\n return []\r\n\r\n const valueArray = optionAsValue ? inputValue.map((item: any) => item[nodeKey]) : inputValue\r\n\r\n if (checkStrictly) {\r\n return valueArray\r\n }\r\n\r\n switch (valueType) {\r\n case 'parent': {\r\n const allKeys = [...valueArray]\r\n\r\n for (const key of valueArray) {\r\n const node = flatData.find(n => n[nodeKey] === key)\r\n if (node) {\r\n const childKeys = getChildrenKeys(node, nodeKey, propsConfig)\r\n allKeys.push(...childKeys)\r\n }\r\n }\r\n return filterLeafNodes(allKeys, flatData, nodeKey, propsConfig)\r\n }\r\n\r\n case 'child': {\r\n const allKeys = [...valueArray]\r\n for (const key of valueArray) {\r\n const parentPath = findParents(data, key, nodeKey, propsConfig)\r\n allKeys.push(...parentPath)\r\n }\r\n return filterLeafNodes(allKeys, flatData, nodeKey, propsConfig)\r\n }\r\n\r\n case 'path': {\r\n return extractKeysFromPath(valueArray, nodeKey, propsConfig)\r\n }\r\n\r\n default: { // 'all'\r\n return filterLeafNodes(valueArray, flatData, nodeKey, propsConfig)\r\n }\r\n }\r\n}\r\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,EA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;AAAA,EAAA;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;"}
@@ -1,32 +1,16 @@
1
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, {
2
+ new (...args: any[]): import('vue').CreateComponentPublicInstanceWithMixins<Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, import('vue').PublicProps, {}, true, {}, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, any, any, import('vue').ComponentProvideOptions, {
9
3
  P: {};
10
4
  B: {};
11
5
  D: {};
12
6
  C: {};
13
7
  M: {};
14
8
  Defaults: {};
15
- }, Readonly<{
16
- value: any;
17
- }> & Readonly<{
18
- onChange?: (...args: any[]) => any;
19
- }>, {}, {}, {}, {}, {}>;
9
+ }, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, {}>;
20
10
  __isFragment?: never;
21
11
  __isTeleport?: never;
22
12
  __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 () => {
13
+ } & import('vue').ComponentOptionsBase<Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, {}, {}, string, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, import('vue').ComponentProvideOptions> & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps & (new () => {
30
14
  $slots: any;
31
15
  });
32
16
  export default TreeSelect;
@@ -1,47 +1,37 @@
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({
1
+ import { useField as c, connect as i, mapProps as f } from "@silver-formily/vue";
2
+ import { PreviewText as p } from "../preview-text/index.mjs";
3
+ import { defineComponent as m, useSlots as d, ref as u, createBlock as S, openBlock as _, unref as e, mergeProps as g, createSlots as P, renderList as R, withCtx as T, renderSlot as v, normalizeProps as y, guardReactiveProps as h } from "vue";
4
+ import { ElTreeSelect as k } from "element-plus";
5
+ import { useCleanAttrs as x } from "../__builtins__/shared/utils.mjs";
6
+ import { mapReadPretty as C } from "../__builtins__/shared/transform-component.mjs";
7
+ const w = /* @__PURE__ */ m({
11
8
  name: "FSelectTree",
12
9
  inheritAttrs: !1,
13
10
  __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();
11
+ setup(A) {
12
+ const n = d(), { props: l } = x(), r = u(), t = c();
20
13
  return t.value?.inject({
21
14
  getTreeSelectRef: () => r
22
- }), (u, o) => (T(), _(e(B), y({
15
+ }), (s, B) => (_(), S(e(k), g({
23
16
  ref_key: "treeSelectRef",
24
17
  ref: r,
25
- "model-value": m.value,
26
18
  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 })))
19
+ }, e(l)), P({ _: 2 }, [
20
+ R(e(n), (F, o) => ({
21
+ name: o,
22
+ fn: T((a) => [
23
+ v(s.$slots, o, y(h({ field: e(t), ...a })))
34
24
  ])
35
25
  }))
36
- ]), 1040, ["model-value", "loading"]));
26
+ ]), 1040, ["loading"]));
37
27
  }
38
- }), H = S(
39
- z,
40
- v({ value: "modelValue", readOnly: "readonly", dataSource: "data" }),
41
- F(V.Select)
28
+ }), b = i(
29
+ w,
30
+ f({ readOnly: "readonly", dataSource: "data" }),
31
+ C(p.Select)
42
32
  );
43
33
  export {
44
- H as TreeSelect,
45
- H as default
34
+ b as TreeSelect,
35
+ b as default
46
36
  };
47
37
  //# sourceMappingURL=index.mjs.map
@@ -1 +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;"}
1
+ {"version":3,"file":"index.mjs","sources":["../../src/tree-select/tree-select.vue","../../src/tree-select/index.ts"],"sourcesContent":["<script setup lang=\"ts\">\r\nimport type { Field } from '@formily/core'\r\nimport { useField } from '@silver-formily/vue'\r\nimport { ElTreeSelect } from 'element-plus'\r\nimport { ref, useSlots } from 'vue'\r\nimport { useCleanAttrs } from '../__builtins__'\r\n\r\ndefineOptions({\r\n name: 'FSelectTree',\r\n inheritAttrs: false,\r\n})\r\n\r\nconst slots = useSlots()\r\n\r\nconst { props: attrs } = useCleanAttrs()\r\n\r\nconst treeSelectRef = ref()\r\n\r\nconst fieldRef = useField<Field>()\r\n\r\nfieldRef.value?.inject({\r\n getTreeSelectRef: () => {\r\n return treeSelectRef\r\n },\r\n})\r\n</script>\r\n\r\n<template>\r\n <ElTreeSelect\r\n ref=\"treeSelectRef\"\r\n :loading=\"fieldRef.value?.loading\"\r\n v-bind=\"attrs\"\r\n >\r\n <template v-for=\"(_, name) of slots\" #[name]=\"slotData\">\r\n <slot :name=\"name\" v-bind=\"{ field: fieldRef, ...slotData }\" />\r\n </template>\r\n </ElTreeSelect>\r\n</template>\r\n","import { connect, mapProps } from '@silver-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({ readOnly: 'readonly', dataSource: 'data' }),\r\n mapReadPretty(PreviewText.Select),\r\n)\r\n\r\nexport default TreeSelect\r\n"],"names":["slots","useSlots","attrs","useCleanAttrs","treeSelectRef","ref","fieldRef","useField","_openBlock","_createBlock","_unref","_mergeProps","_createSlots","_","name","_withCtx","slotData","_renderSlot","_ctx","_normalizeProps","_guardReactiveProps","TreeSelect","connect","FTreeSelect","mapProps","mapReadPretty","PreviewText"],"mappings":";;;;;;;;;;;AAYA,UAAMA,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,EAQeC,MARfC,EAQe;AAAA,eAPT;AAAA,MAAJ,KAAIP;AAAA,MACH,SAASM,EAAAJ,CAAA,EAAS,OAAO;AAAA,IAAA,GAClBI,EAAAR,CAAA,CAAK,GAAAU,EAAA,EAAA,GAAA,KAAA;AAAA,QAEiBF,EAAAV,CAAA,GAAK,CAAjBa,GAAGC;;QACnB,IAAAC,EAAA,CAD4CC,MAAQ;AAAA,UACpDC,EAA+DC,EAAA,QAAlDJ,GAAIK,EAAAC,EAAA,EAAA,OAAmBV,EAAAJ,CAAA,MAAaU,EAAA,CAAQ,CAAA,CAAA;AAAA,QAAA;;;;IC7BlDK,IAAaC;AAAA,EACxBC;AAAAA,EACAC,EAAS,EAAE,UAAU,YAAY,YAAY,QAAQ;AAAA,EACrDC,EAAcC,EAAY,MAAM;AAClC;"}
@@ -1,13 +1,6 @@
1
- type __VLS_Props = {
2
- value: any;
3
- };
4
1
  declare function __VLS_template(): any;
5
2
  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>;
3
+ declare const __VLS_component: import('vue').DefineComponent<{}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, any, any>;
11
4
  declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
12
5
  export default _default;
13
6
  type __VLS_WithTemplateSlots<T, S> = T & {
@@ -24,9 +24,9 @@ export declare const Upload: {
24
24
  };
25
25
  };
26
26
  }>> & Readonly<{
27
- onChange?: (...args: any[]) => any;
27
+ "onUpdate:modelValue"?: (...args: any[]) => any;
28
28
  }>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
29
- change: (...args: any[]) => void;
29
+ "update:modelValue": (...args: any[]) => void;
30
30
  }, import('vue').PublicProps, {
31
31
  textContent: string;
32
32
  errorAdaptor: (error?: Error) => string;
@@ -648,7 +648,7 @@ export declare const Upload: {
648
648
  };
649
649
  };
650
650
  }>> & Readonly<{
651
- onChange?: (...args: any[]) => any;
651
+ "onUpdate:modelValue"?: (...args: any[]) => any;
652
652
  }>, {}, {}, {}, {}, {
653
653
  textContent: string;
654
654
  errorAdaptor: (error?: Error) => string;
@@ -684,9 +684,9 @@ export declare const Upload: {
684
684
  };
685
685
  };
686
686
  }>> & Readonly<{
687
- onChange?: (...args: any[]) => any;
687
+ "onUpdate:modelValue"?: (...args: any[]) => any;
688
688
  }>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
689
- change: (...args: any[]) => void;
689
+ "update:modelValue": (...args: any[]) => void;
690
690
  }, string, {
691
691
  textContent: string;
692
692
  errorAdaptor: (error?: Error) => string;