@aplus-frontend/ui 0.1.32 → 0.1.34

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 (103) hide show
  1. package/es/src/ap-form/ap-form-item.vue.d.ts +1 -1
  2. package/es/src/ap-form/ap-form-item.vue.mjs +68 -62
  3. package/es/src/ap-form/ap-form-list.vue.mjs +23 -21
  4. package/es/src/ap-form/ap-form.vue.d.ts +3 -1
  5. package/es/src/ap-form/ap-form.vue2.mjs +130 -80
  6. package/es/src/ap-form/interface.d.ts +51 -1
  7. package/es/src/ap-form/items/checkbox/index.vue.mjs +6 -5
  8. package/es/src/ap-form/items/date/index.vue.mjs +10 -9
  9. package/es/src/ap-form/items/date-range/index.vue.mjs +8 -7
  10. package/es/src/ap-form/items/number/index.vue.mjs +12 -11
  11. package/es/src/ap-form/items/radio/index.vue.mjs +5 -4
  12. package/es/src/ap-form/items/select/index.vue.mjs +1 -0
  13. package/es/src/ap-form/items/switch/index.vue.mjs +10 -9
  14. package/es/src/ap-form/items/text/index.vue2.mjs +1 -0
  15. package/es/src/ap-form/items/text/password.vue.mjs +1 -0
  16. package/es/src/ap-form/items/text-area/index.vue.mjs +7 -6
  17. package/es/src/ap-form/modal-form/index.vue.d.ts +7 -3
  18. package/es/src/ap-form/search-form/index.vue.d.ts +7 -3
  19. package/es/src/ap-form/utils/get.d.ts +1 -0
  20. package/es/src/ap-form/utils/get.mjs +12 -0
  21. package/es/src/ap-form/utils/set.d.ts +6 -0
  22. package/es/src/ap-form/utils/set.mjs +41 -0
  23. package/es/src/ap-list/index.vue.d.ts +3 -0
  24. package/es/src/ap-list/index.vue.mjs +51 -49
  25. package/es/src/ap-table/ap-table.vue.d.ts +4 -1
  26. package/es/src/ap-table/ap-table.vue.mjs +65 -59
  27. package/es/src/ap-table/components/setting/select-group/index.vue2.mjs +8 -8
  28. package/es/src/ap-table/components/setting/tree-select/index.vue2.mjs +14 -11
  29. package/es/src/ap-table/components/setting/utils.mjs +29 -29
  30. package/es/src/ap-table/constants.d.ts +121 -1
  31. package/es/src/ap-table/interface.d.ts +6 -1
  32. package/es/src/ap-table/utils.d.ts +121 -1
  33. package/es/src/business/ap-card/ApCard.vue2.mjs +31 -26
  34. package/es/src/business/ap-expand-alert/ApExpandAlert.vue.d.ts +30 -100
  35. package/es/src/business/ap-expand-alert/ApExpandAlert.vue2.mjs +104 -64
  36. package/es/src/business/ap-expand-alert/interface.d.ts +24 -6
  37. package/es/src/business/ap-expand-alert/style.css +9 -0
  38. package/es/src/business/ap-title/style.css +4 -4
  39. package/es/src/business/hooks/usePageListApTable.d.ts +2 -0
  40. package/es/src/business/index.d.ts +53 -187
  41. package/es/src/check-card/group.vue.d.ts +7 -1
  42. package/es/src/check-card/group.vue.mjs +26 -22
  43. package/es/src/check-card/index.vue.d.ts +5 -2
  44. package/es/src/check-card/index.vue2.mjs +69 -60
  45. package/es/src/check-card/interface.d.ts +12 -0
  46. package/es/src/check-card/style/index.css +9 -5
  47. package/es/src/locale/lang/en.mjs +4 -0
  48. package/es/src/locale/lang/zh-cn.mjs +4 -0
  49. package/es/src/theme/ap-expand-alert/ap-expand-alert.css +9 -0
  50. package/es/src/theme/ap-title/ap-title.css +4 -4
  51. package/es/src/theme/check-card/index.css +9 -5
  52. package/lib/src/ap-form/ap-form-item.vue.d.ts +1 -1
  53. package/lib/src/ap-form/ap-form-item.vue.js +1 -1
  54. package/lib/src/ap-form/ap-form-list.vue.js +1 -1
  55. package/lib/src/ap-form/ap-form.vue.d.ts +3 -1
  56. package/lib/src/ap-form/ap-form.vue2.js +1 -1
  57. package/lib/src/ap-form/interface.d.ts +51 -1
  58. package/lib/src/ap-form/items/checkbox/index.vue.js +1 -1
  59. package/lib/src/ap-form/items/date/index.vue.js +1 -1
  60. package/lib/src/ap-form/items/date-range/index.vue.js +1 -1
  61. package/lib/src/ap-form/items/number/index.vue.js +1 -1
  62. package/lib/src/ap-form/items/radio/index.vue.js +1 -1
  63. package/lib/src/ap-form/items/select/index.vue.js +1 -1
  64. package/lib/src/ap-form/items/switch/index.vue.js +1 -1
  65. package/lib/src/ap-form/items/text/index.vue2.js +1 -1
  66. package/lib/src/ap-form/items/text/password.vue.js +1 -1
  67. package/lib/src/ap-form/items/text-area/index.vue.js +1 -1
  68. package/lib/src/ap-form/modal-form/index.vue.d.ts +7 -3
  69. package/lib/src/ap-form/search-form/index.vue.d.ts +7 -3
  70. package/lib/src/ap-form/utils/get.d.ts +1 -0
  71. package/lib/src/ap-form/utils/get.js +1 -0
  72. package/lib/src/ap-form/utils/set.d.ts +6 -0
  73. package/lib/src/ap-form/utils/set.js +1 -0
  74. package/lib/src/ap-list/index.vue.d.ts +3 -0
  75. package/lib/src/ap-list/index.vue.js +1 -1
  76. package/lib/src/ap-table/ap-table.vue.d.ts +4 -1
  77. package/lib/src/ap-table/ap-table.vue.js +1 -1
  78. package/lib/src/ap-table/components/setting/select-group/index.vue2.js +1 -1
  79. package/lib/src/ap-table/components/setting/tree-select/index.vue2.js +1 -1
  80. package/lib/src/ap-table/components/setting/utils.js +1 -1
  81. package/lib/src/ap-table/constants.d.ts +121 -1
  82. package/lib/src/ap-table/interface.d.ts +6 -1
  83. package/lib/src/ap-table/utils.d.ts +121 -1
  84. package/lib/src/business/ap-card/ApCard.vue2.js +1 -1
  85. package/lib/src/business/ap-expand-alert/ApExpandAlert.vue.d.ts +30 -100
  86. package/lib/src/business/ap-expand-alert/ApExpandAlert.vue2.js +1 -1
  87. package/lib/src/business/ap-expand-alert/interface.d.ts +24 -6
  88. package/lib/src/business/ap-expand-alert/style.css +9 -0
  89. package/lib/src/business/ap-title/style.css +4 -4
  90. package/lib/src/business/hooks/usePageListApTable.d.ts +2 -0
  91. package/lib/src/business/index.d.ts +53 -187
  92. package/lib/src/check-card/group.vue.d.ts +7 -1
  93. package/lib/src/check-card/group.vue.js +1 -1
  94. package/lib/src/check-card/index.vue.d.ts +5 -2
  95. package/lib/src/check-card/index.vue2.js +1 -1
  96. package/lib/src/check-card/interface.d.ts +12 -0
  97. package/lib/src/check-card/style/index.css +9 -5
  98. package/lib/src/locale/lang/en.js +1 -1
  99. package/lib/src/locale/lang/zh-cn.js +1 -1
  100. package/lib/src/theme/ap-expand-alert/ap-expand-alert.css +9 -0
  101. package/lib/src/theme/ap-title/ap-title.css +4 -4
  102. package/lib/src/theme/check-card/index.css +9 -5
  103. package/package.json +1 -1
@@ -9,7 +9,7 @@ declare function onFieldBlur(): void;
9
9
  declare function onFieldChange(): void;
10
10
  declare function clearValidate(): void;
11
11
  declare function resetField(): void;
12
- declare function getFieldValue(): any;
12
+ declare function getFieldValue(shouldFormat?: boolean): any;
13
13
  declare function __VLS_template(): {
14
14
  slots: Readonly<ApFormItemSlots> & ApFormItemSlots;
15
15
  refs: {
@@ -1,15 +1,15 @@
1
- import { defineComponent as $, useSlots as j, ref as f, onMounted as q, computed as B, unref as l, watch as E, cloneVNode as K, openBlock as g, createBlock as V, mergeProps as Q, createSlots as U, withCtx as i, resolveDynamicComponent as G, createCommentVNode as H, createElementVNode as C, normalizeClass as J, createVNode as k, normalizeStyle as M, toDisplayString as W, renderList as X, renderSlot as Y, normalizeProps as Z, guardReactiveProps as ee } from "vue";
2
- import { Form as oe, Tooltip as le } from "ant-design-vue";
3
- import { useToken as te } from "ant-design-vue/es/theme/internal";
4
- import { isFunction as ae, cloneDeep as re, isArray as ne, omit as N } from "lodash-unified";
1
+ import { defineComponent as j, useSlots as q, ref as d, onMounted as E, computed as B, unref as t, watch as K, cloneVNode as Q, openBlock as V, createBlock as g, mergeProps as U, createSlots as G, withCtx as i, resolveDynamicComponent as H, createCommentVNode as J, createElementVNode as C, normalizeClass as M, createVNode as k, normalizeStyle as W, toDisplayString as X, renderList as Y, renderSlot as Z, normalizeProps as ee, guardReactiveProps as oe } from "vue";
2
+ import { Form as te, Tooltip as le } from "ant-design-vue";
3
+ import { useToken as re } from "ant-design-vue/es/theme/internal";
4
+ import { isFunction as N, cloneDeep as ae, isArray as ne, omit as P } from "lodash-unified";
5
5
  import { apFormItemColPropKeys as ie } from "./constant.mjs";
6
6
  import { QuestionCircleOutlined as ue } from "@ant-design/icons-vue";
7
7
  import "../config-provider/index.mjs";
8
8
  import { useInjectForm as se } from "./context.mjs";
9
9
  import "./style/ap-form-item.css";
10
- import { isPromise as de } from "@fruits-chain/utils";
11
- import { useNamespace as me } from "../config-provider/hooks/use-namespace.mjs";
12
- const fe = ["title"], ke = /* @__PURE__ */ $({
10
+ import { isPromise as me } from "@fruits-chain/utils";
11
+ import { useNamespace as fe } from "../config-provider/hooks/use-namespace.mjs";
12
+ const de = ["title"], ke = /* @__PURE__ */ j({
13
13
  name: "ApFormItem",
14
14
  __name: "ap-form-item",
15
15
  props: {
@@ -50,103 +50,109 @@ const fe = ["title"], ke = /* @__PURE__ */ $({
50
50
  bordered: { type: Boolean, default: !1 },
51
51
  valuePropName: { default: "value" },
52
52
  initialValue: {},
53
- _signal: {}
53
+ _signal: {},
54
+ transform: {}
54
55
  },
55
- setup(P, { expose: S }) {
56
+ setup(S, { expose: w }) {
56
57
  var b, F;
57
- const o = P, t = j(), { model: u, updateModel: s, internalInstance: d } = se(), { m: p, b: w } = me("ap-form-item"), m = f(!1), a = f(), [, x] = te();
58
- q(async () => {
59
- let e = ae(o.initialValue) ? o.initialValue() : o.initialValue;
60
- de(e) && (e = await e), d == null || d.registerField({
58
+ const o = S, r = q(), { model: u, updateModel: s, internalInstance: m } = se(), { m: p, b: x } = fe("ap-form-item"), f = d(!1), n = d(), [, I] = re();
59
+ E(async () => {
60
+ let e = N(o.initialValue) ? o.initialValue() : o.initialValue;
61
+ me(e) && (e = await e), m == null || m.registerField({
61
62
  name: o.name,
62
- initialValue: re(e)
63
+ initialValue: ae(e),
64
+ transform: o.transform
63
65
  });
64
66
  });
65
- const c = B(() => o.name ? ne(o.name) ? o.name.reduce((e, r) => e == null ? void 0 : e[r], l(u)) : u == null ? void 0 : u.value[o.name] : null), v = f((F = (b = t.default) == null ? void 0 : b.call(t)) == null ? void 0 : F[0]);
66
- E(
67
+ const c = B(() => o.name ? ne(o.name) ? o.name.reduce((e, l) => e == null ? void 0 : e[l], t(u)) : u == null ? void 0 : u.value[o.name] : null), v = d((F = (b = r.default) == null ? void 0 : b.call(r)) == null ? void 0 : F[0]);
68
+ K(
67
69
  () => {
68
70
  var e;
69
- return (e = t.default) == null ? void 0 : e.call(t);
71
+ return (e = r.default) == null ? void 0 : e.call(r);
70
72
  },
71
73
  (e) => {
72
74
  v.value = e == null ? void 0 : e[0];
73
75
  }
74
76
  );
75
- function I(e) {
77
+ function _(e) {
76
78
  s == null || s(o.name, e);
77
79
  }
78
- function _() {
79
- m.value = !0;
80
- }
81
80
  function z() {
82
- m.value = !1;
81
+ f.value = !0;
82
+ }
83
+ function A() {
84
+ f.value = !1;
83
85
  }
84
86
  const y = B(() => {
85
- var r, n;
87
+ var l, a;
86
88
  if (!o.name)
87
- return (r = t.default()) == null ? void 0 : r[0];
88
- const e = l(v);
89
- return e ? K(e, {
90
- [o.valuePropName]: l(c),
91
- [`onUpdate:${o.valuePropName}`]: I,
92
- bordered: o.bordered ? !1 : (n = e == null ? void 0 : e.props) == null ? void 0 : n.bordered,
93
- onFocus: _,
94
- onBlur: z
89
+ return (l = r.default()) == null ? void 0 : l[0];
90
+ const e = t(v);
91
+ return e ? Q(e, {
92
+ [o.valuePropName]: t(c),
93
+ [`onUpdate:${o.valuePropName}`]: _,
94
+ bordered: o.bordered ? !1 : (a = e == null ? void 0 : e.props) == null ? void 0 : a.bordered,
95
+ onFocus: z,
96
+ onBlur: A
95
97
  }) : null;
96
98
  });
97
- function A() {
98
- var e;
99
- (e = a.value) == null || e.onFieldBlur();
100
- }
101
99
  function D() {
102
100
  var e;
103
- (e = a.value) == null || e.onFieldChange();
101
+ (e = n.value) == null || e.onFieldBlur();
104
102
  }
105
103
  function R() {
106
104
  var e;
107
- (e = a.value) == null || e.clearValidate();
105
+ (e = n.value) == null || e.onFieldChange();
108
106
  }
109
107
  function T() {
110
108
  var e;
111
- (e = a.value) == null || e.resetField();
109
+ (e = n.value) == null || e.clearValidate();
112
110
  }
113
111
  function L() {
114
- return l(c);
112
+ var e;
113
+ (e = n.value) == null || e.resetField();
114
+ }
115
+ function O(e = !1) {
116
+ const l = t(c);
117
+ if (!e || !o.transform)
118
+ return l;
119
+ const a = N(o.transform) ? o.transform : o.transform.transformer;
120
+ return o.transform ? a(l) : l;
115
121
  }
116
- return S({
117
- onFieldBlur: A,
118
- onFieldChange: D,
119
- clearValidate: R,
120
- resetField: T,
121
- getFieldValue: L
122
- }), (e, r) => (g(), V(l(oe).Item, Q({
122
+ return w({
123
+ onFieldBlur: D,
124
+ onFieldChange: R,
125
+ clearValidate: T,
126
+ resetField: L,
127
+ getFieldValue: O
128
+ }), (e, l) => (V(), g(t(te).Item, U({
123
129
  ref_key: "formItemRef",
124
- ref: a
125
- }, l(N)(o, [...l(ie), "tooltip", "label"]), {
130
+ ref: n
131
+ }, t(P)(o, [...t(ie), "tooltip", "label"]), {
126
132
  class: {
127
- [l(p)("bordered")]: e.bordered,
128
- [l(p)("focused")]: e.bordered && m.value,
129
- [l(w)()]: !0
133
+ [t(p)("bordered")]: e.bordered,
134
+ [t(p)("focused")]: e.bordered && f.value,
135
+ [t(x)()]: !0
130
136
  },
131
137
  colon: e.bordered ? !1 : o.colon
132
- }), U({
138
+ }), G({
133
139
  default: i(() => [
134
- y.value ? (g(), V(G(y.value), { key: 0 })) : H("", !0)
140
+ y.value ? (V(), g(H(y.value), { key: 0 })) : J("", !0)
135
141
  ]),
136
142
  _: 2
137
143
  }, [
138
144
  o.tooltip ? {
139
145
  name: "tooltip",
140
- fn: i(({ class: n }) => [
146
+ fn: i(({ class: a }) => [
141
147
  C("span", {
142
- class: J(n)
148
+ class: M(a)
143
149
  }, [
144
- k(l(le), {
150
+ k(t(le), {
145
151
  title: o.tooltip
146
152
  }, {
147
153
  default: i(() => [
148
- k(l(ue), {
149
- style: M({ color: l(x).colorPrimary })
154
+ k(t(ue), {
155
+ style: W({ color: t(I).colorPrimary })
150
156
  }, null, 8, ["style"])
151
157
  ]),
152
158
  _: 1
@@ -165,14 +171,14 @@ const fe = ["title"], ke = /* @__PURE__ */ $({
165
171
  overflow: "hidden",
166
172
  textOverflow: "ellipsis"
167
173
  }
168
- }, W(e.label), 9, fe)
174
+ }, X(e.label), 9, de)
169
175
  ]),
170
176
  key: "1"
171
177
  } : void 0,
172
- X(l(N)(t, "default"), (n, h) => ({
178
+ Y(t(P)(r, "default"), (a, h) => ({
173
179
  name: h,
174
- fn: i((O) => [
175
- Y(e.$slots, h, Z(ee(O || {})))
180
+ fn: i(($) => [
181
+ Z(e.$slots, h, ee(oe($ || {})))
176
182
  ])
177
183
  }))
178
184
  ]), 1040, ["class", "colon"]));
@@ -1,49 +1,51 @@
1
- import { defineComponent as F, onMounted as V, computed as f, unref as m, renderSlot as k } from "vue";
1
+ import { defineComponent as v, onMounted as V, computed as f, unref as u, renderSlot as k } from "vue";
2
2
  import { useInjectForm as h } from "./context.mjs";
3
- import { isArray as A } from "lodash-unified";
4
- const w = /* @__PURE__ */ F({
3
+ import { isArray as j } from "lodash-unified";
4
+ const g = /* @__PURE__ */ v({
5
5
  name: "ApFormList",
6
6
  __name: "ap-form-list",
7
7
  props: {
8
8
  name: {},
9
- initialValue: {}
9
+ initialValue: {},
10
+ transform: { type: [Function, Object] }
10
11
  },
11
12
  setup(p) {
12
- let s = 1;
13
- const o = [], t = p, { model: i, updateModel: r, internalInstance: l } = h();
13
+ let o = 1;
14
+ const s = [], t = p, { model: a, updateModel: r, internalInstance: c } = h();
14
15
  V(() => {
15
- l == null || l.registerField({
16
+ c == null || c.registerField({
16
17
  name: t.name,
17
- initialValue: t.initialValue
18
+ initialValue: t.initialValue,
19
+ transform: t.transform
18
20
  });
19
21
  });
20
- const a = f(() => A(t.name) ? t.name.reduce((e, n) => e == null ? void 0 : e.value[n], i) : i == null ? void 0 : i.value[t.name]);
22
+ const i = f(() => j(t.name) ? t.name.reduce((e, n) => e == null ? void 0 : e.value[n], a) : a == null ? void 0 : a.value[t.name]);
21
23
  function y(e = void 0) {
22
- const n = m(a) ? [...m(a), e] : [e];
23
- o.push(s), s += 1, r == null || r(t.name, n);
24
+ const n = u(i) ? [...u(i), e] : [e];
25
+ s.push(o), o += 1, r == null || r(t.name, n);
24
26
  }
25
27
  function _(e) {
26
- let n = m(a) || [];
27
- n = [...n.slice(0, e), ...n.slice(e + 1)], o.splice(e, 1), r == null || r(t.name, n);
28
+ let n = u(i) || [];
29
+ n = [...n.slice(0, e), ...n.slice(e + 1)], s.splice(e, 1), r == null || r(t.name, n);
28
30
  }
29
31
  const d = {
30
32
  add: y,
31
33
  remove: _
32
- }, v = f(() => (m(a) || []).map((n, u) => {
33
- let c = o[u];
34
- return typeof c > "u" && (o[u] = s, c = s, s += 1), {
35
- key: c,
36
- fieldName: u,
37
- name: [t.name, u],
34
+ }, F = f(() => (u(i) || []).map((n, m) => {
35
+ let l = s[m];
36
+ return typeof l > "u" && (s[m] = o, l = o, o += 1), {
37
+ key: l,
38
+ fieldName: m,
39
+ name: [t.name, m],
38
40
  value: n
39
41
  };
40
42
  }));
41
43
  return (e, n) => k(e.$slots, "default", {
42
- fields: v.value,
44
+ fields: F.value,
43
45
  actions: d
44
46
  });
45
47
  }
46
48
  });
47
49
  export {
48
- w as default
50
+ g as default
49
51
  };
@@ -17,7 +17,7 @@ declare function registerWatch(callback: WatchFunc, inner: boolean): () => void;
17
17
  * 注册表单项
18
18
  * @param field
19
19
  */
20
- declare function registerField({ initialValue, name }: RegistedFieldType): void;
20
+ declare function registerField({ initialValue, name, transform }: RegistedFieldType): void;
21
21
  declare function getInternalInstance(mark: string): {
22
22
  registerField: typeof registerField;
23
23
  registerWatch: typeof registerWatch;
@@ -911,6 +911,8 @@ declare const __VLS_component: DefineComponent<__VLS_WithDefaults<__VLS_TypeProp
911
911
  setFieldsValue: (values: Record<string, any>) => void;
912
912
  setFieldValue: (name: NamePath, newValue: any) => void;
913
913
  registerWatch: typeof registerWatch;
914
+ validateFieldsReturnTransformed: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<any>;
915
+ getFieldsValueTransformed: (nameList?: InternalNamePath[] | true) => any;
914
916
  getInternalInstance: typeof getInternalInstance;
915
917
  }, unknown, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly< ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToOption<ApFormProps>, {
916
918
  layout: string;
@@ -1,10 +1,11 @@
1
- import { defineComponent as A, ref as E, reactive as N, nextTick as O, toRaw as m, computed as j, openBlock as S, createBlock as W, unref as C, mergeProps as q, withCtx as z, renderSlot as D } from "vue";
2
- import { Form as L } from "ant-design-vue";
3
- import { useProvideForm as P } from "./context.mjs";
4
- import { isArray as p, cloneDeep as V, omit as K } from "lodash-unified";
5
- import { INTERNAL_FORM_INSTANCE_MARK as $ } from "./constant.mjs";
6
- import { isDef as h } from "../utils/index.mjs";
7
- const Y = /* @__PURE__ */ A({
1
+ import { defineComponent as D, ref as L, reactive as k, nextTick as K, toRaw as T, computed as $, openBlock as G, createBlock as H, unref as b, mergeProps as J, withCtx as Q, renderSlot as U } from "vue";
2
+ import { Form as X } from "ant-design-vue";
3
+ import { useProvideForm as Y } from "./context.mjs";
4
+ import { isArray as d, cloneDeep as B, isFunction as V, isPlainObject as C, omit as Z } from "lodash-unified";
5
+ import { INTERNAL_FORM_INSTANCE_MARK as ee } from "./constant.mjs";
6
+ import { isDef as _ } from "../utils/index.mjs";
7
+ import te from "./utils/set.mjs";
8
+ const ue = /* @__PURE__ */ D({
8
9
  __name: "ap-form",
9
10
  props: {
10
11
  layout: { default: "horizontal" },
@@ -32,112 +33,161 @@ const Y = /* @__PURE__ */ A({
32
33
  onValidate: {},
33
34
  initialValues: {}
34
35
  },
35
- setup(_, { expose: R }) {
36
- const i = _;
37
- function f(e, t, l = !0) {
38
- var y;
39
- if (p(e)) {
40
- let n = o;
36
+ setup(I, { expose: M }) {
37
+ const a = I;
38
+ function p(e, t, l = !0) {
39
+ var r;
40
+ if (d(e)) {
41
+ let i = s;
41
42
  for (let u = 0; u < e.length - 1; u++)
42
- e[u] in n || (n[e[u]] = {}), n = n[e[u]];
43
- n[e[e.length - 1]] = t;
43
+ e[u] in i || (i[e[u]] = {}), i = i[e[u]];
44
+ i[e[e.length - 1]] = t;
44
45
  } else
45
- o[e] = t;
46
- let r = p(e) ? e[0] : e;
47
- l && ((y = i.onValuesChange) == null || y.call(i, { [r]: o[r] }, o)), d();
46
+ s[e] = t;
47
+ let o = d(e) ? e[0] : e;
48
+ l && ((r = a.onValuesChange) == null || r.call(a, { [o]: s[o] }, s)), F();
48
49
  }
49
- const a = E();
50
- let c = i.initialValues ? V(i.initialValues) : {};
51
- const o = N(i.initialValues || {});
52
- let s = [];
53
- const B = async () => {
50
+ function O(e) {
51
+ var l;
52
+ const t = g(e, c);
53
+ (l = a.onFinish) == null || l.call(a, t);
54
+ }
55
+ const n = L();
56
+ let m = a.initialValues ? B(a.initialValues) : {}, c = {};
57
+ const s = k(a.initialValues || {});
58
+ let h = [];
59
+ const w = async () => {
54
60
  var e;
55
- (e = a.value) == null || e.resetFields(), await O(() => {
56
- Object.keys(o).forEach((t) => delete o[t]), Object.assign(o, V(c)), d();
61
+ (e = n.value) == null || e.resetFields(), await K(() => {
62
+ Object.keys(s).forEach((t) => delete s[t]), Object.assign(s, B(m)), F();
57
63
  });
58
- }, I = (e) => {
64
+ }, E = (e) => {
59
65
  var t;
60
- (t = a.value) == null || t.clearValidate(e);
61
- }, M = (e, t) => {
66
+ (t = n.value) == null || t.clearValidate(e);
67
+ }, j = (e, t) => {
62
68
  var l;
63
- return (l = a.value) == null ? void 0 : l.validateFields(e, t);
64
- }, T = (e) => {
69
+ return (l = n.value) == null ? void 0 : l.validateFields(e, t);
70
+ }, x = async (e, t) => {
71
+ var o;
72
+ const l = await ((o = n.value) == null ? void 0 : o.validateFields(
73
+ e,
74
+ t
75
+ ));
76
+ return g(l, c);
77
+ }, A = (e) => {
65
78
  var t;
66
- return (t = a.value) == null ? void 0 : t.getFieldsValue(e);
67
- }, b = (e, t) => {
79
+ return (t = n.value) == null ? void 0 : t.getFieldsValue(e);
80
+ }, N = (e) => {
68
81
  var l;
69
- return (l = a.value) == null ? void 0 : l.validate(e, t);
70
- }, k = (e, t = {}) => {
82
+ const t = (l = n.value) == null ? void 0 : l.getFieldsValue(e);
83
+ return g(t, c);
84
+ }, P = (e, t) => {
71
85
  var l;
72
- (l = a.value) == null || l.scrollToField(e, t);
73
- }, w = (e) => {
74
- Object.assign(o, e), d();
75
- }, F = (e, t) => {
76
- f(e, t), d();
86
+ return (l = n.value) == null ? void 0 : l.validate(e, t);
87
+ }, S = (e, t = {}) => {
88
+ var l;
89
+ (l = n.value) == null || l.scrollToField(e, t);
90
+ }, W = (e) => {
91
+ Object.assign(s, e), F();
92
+ }, y = (e, t) => {
93
+ p(e, t), F();
77
94
  };
78
- function g(e, t) {
79
- return t || e(m(o)), s.push(e), () => {
80
- s = s.filter((l) => l !== e);
95
+ function v(e, t) {
96
+ return t || e(T(s)), h.push(e), () => {
97
+ h = h.filter((l) => l !== e);
81
98
  };
82
99
  }
83
- function v({ initialValue: e, name: t }) {
84
- if (h(e) && h(t))
85
- if (f(t, e, !1), p(t)) {
86
- let l = c;
100
+ function R({ initialValue: e, name: t, transform: l }) {
101
+ if (_(e) && _(t))
102
+ if (p(t, e, !1), d(t)) {
103
+ let o = m;
87
104
  for (let r = 0; r < t.length - 1; r++)
88
- h(l[t[r]]) || (l[t[r]] = {}), l = l[t[r]];
89
- l[t[t.length - 1]] = e;
105
+ _(o[t[r]]) || (o[t[r]] = {}), o = o[t[r]];
106
+ o[t[t.length - 1]] = e;
90
107
  } else
91
- c[t] = e;
108
+ m[t] = e;
109
+ c = te(
110
+ c,
111
+ [t].flat(1),
112
+ l,
113
+ !0
114
+ );
92
115
  }
93
- function x(e) {
94
- if (e !== $) {
116
+ function q(e) {
117
+ if (e !== ee) {
95
118
  console.warn("getInternalInstance should only used at internal");
96
119
  return;
97
120
  }
98
121
  return {
99
- registerField: v,
100
- registerWatch: g
122
+ registerField: R,
123
+ registerWatch: v
101
124
  };
102
125
  }
103
- function d() {
104
- if (s.length) {
105
- const e = m(o);
106
- s.forEach((t) => {
126
+ function F() {
127
+ if (h.length) {
128
+ const e = T(s);
129
+ h.forEach((t) => {
107
130
  t(e);
108
131
  });
109
132
  }
110
133
  }
111
- return P({
112
- model: j(() => o),
113
- updateModel: f,
134
+ function g(e, t) {
135
+ if (e == null)
136
+ return;
137
+ let l = d(e) ? [] : {};
138
+ return Object.keys(e).forEach((o) => {
139
+ const r = e[o], i = t[o], u = V(i) ? i : i == null ? void 0 : i.transformer, z = V(i) ? !0 : i == null ? void 0 : i.flat;
140
+ if (V(u)) {
141
+ const f = u(r);
142
+ z ? d(f) && d(l) ? l = [...l, ...f] : C(f) && C(l) ? l = {
143
+ ...l,
144
+ ...f
145
+ } : l[o] = f : l[o] = f;
146
+ } else if (C(r) || d(r)) {
147
+ const f = g(
148
+ r,
149
+ i
150
+ );
151
+ l[o] = f;
152
+ } else
153
+ l[o] = r;
154
+ }), l;
155
+ }
156
+ return Y({
157
+ model: $(() => s),
158
+ updateModel: p,
114
159
  internalInstance: {
115
- registerWatch: g,
116
- registerField: v,
117
- setFieldValue: F
160
+ registerWatch: v,
161
+ registerField: R,
162
+ setFieldValue: y
118
163
  }
119
- }), R({
120
- resetFields: B,
121
- clearValidate: I,
122
- validateFields: M,
123
- getFieldsValue: T,
124
- validate: b,
125
- scrollToField: k,
126
- setFieldsValue: w,
127
- setFieldValue: F,
128
- registerWatch: g,
129
- getInternalInstance: x
130
- }), (e, t) => (S(), W(C(L), q({
164
+ }), M({
165
+ resetFields: w,
166
+ clearValidate: E,
167
+ validateFields: j,
168
+ getFieldsValue: A,
169
+ validate: P,
170
+ scrollToField: S,
171
+ setFieldsValue: W,
172
+ setFieldValue: y,
173
+ registerWatch: v,
174
+ validateFieldsReturnTransformed: x,
175
+ getFieldsValueTransformed: N,
176
+ getInternalInstance: q
177
+ }), (e, t) => (G(), H(b(X), J({
131
178
  ref_key: "formRef",
132
- ref: a
133
- }, C(K)(i, ["initialValues"]), { model: o }), {
134
- default: z(() => [
135
- D(e.$slots, "default")
179
+ ref: n
180
+ }, b(Z)(a, ["initialValues", "onValuesChange", "onFinish"]), {
181
+ onFinish: O,
182
+ model: s
183
+ }), {
184
+ default: Q(() => [
185
+ U(e.$slots, "default")
136
186
  ]),
137
187
  _: 3
138
188
  }, 16, ["model"]));
139
189
  }
140
190
  });
141
191
  export {
142
- Y as default
192
+ ue as default
143
193
  };
@@ -4,6 +4,14 @@ import { InternalNamePath, NamePath, ValidateOptions } from 'ant-design-vue/es/f
4
4
  import { Recordable } from '../type';
5
5
  import { VNode } from 'vue';
6
6
  export type ApFormColProps = Omit<ColProps, 'prefixCls'>;
7
+ export type ApFormItemTransformFn = (value: any) => any;
8
+ export type ApFormItemTransformType = ApFormItemTransformFn | {
9
+ transformer: ApFormItemTransformFn;
10
+ /**
11
+ * 是否进行扁平化处理(只向上扁平化一层)
12
+ */
13
+ flat?: boolean;
14
+ };
7
15
  export type ApFormItemProps = FormItemProps & Partial<ApFormColProps> & {
8
16
  /**
9
17
  * 是否展示包含了输入框&label的border
@@ -18,6 +26,12 @@ export type ApFormItemProps = FormItemProps & Partial<ApFormColProps> & {
18
26
  * 内部使用,请勿传入
19
27
  */
20
28
  _signal?: number;
29
+ /**
30
+ * 数据转换(提交/或者手动调用时才会)
31
+ * @param value
32
+ * @returns
33
+ */
34
+ transform?: ApFormItemTransformType;
21
35
  };
22
36
  export type ApFormItemGroupProps = RowProps & {
23
37
  countPerRow?: number;
@@ -48,6 +62,19 @@ export type ApFormExpose<ModelType = any> = {
48
62
  * @returns
49
63
  */
50
64
  getInternalInstance: (mark: string) => ApFormInternalInstance;
65
+ /**
66
+ * 校验表单并返回转换后的数据
67
+ * @param nameList
68
+ * @param options
69
+ * @returns
70
+ */
71
+ validateFieldsReturnTransformed: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<Partial<ModelType>> | undefined;
72
+ /**
73
+ * 获取表单数据并转换
74
+ * @param nameList
75
+ * @returns
76
+ */
77
+ getFieldsValueTransformed: (nameList?: true | InternalNamePath[]) => Partial<ModelType> | undefined;
51
78
  };
52
79
  /**
53
80
  * 被注册的表单项
@@ -55,6 +82,7 @@ export type ApFormExpose<ModelType = any> = {
55
82
  export type RegistedFieldType = {
56
83
  name: FormItemProps['name'];
57
84
  initialValue?: any;
85
+ transform?: ApFormItemTransformType;
58
86
  };
59
87
  export type ApFormInternalInstance = {
60
88
  /**
@@ -72,7 +100,12 @@ export type ApFormInternalInstance = {
72
100
  registerField: (field: RegistedFieldType) => void;
73
101
  } & Pick<ApFormExpose, 'setFieldValue'>;
74
102
  export type ApFormItemExpose = FormItemExpose & {
75
- getFieldValue: () => any;
103
+ /**
104
+ * 是否需要格式化(默认为false)
105
+ * @param shouldFormat
106
+ * @returns
107
+ */
108
+ getFieldValue: (shouldFormat?: boolean) => any;
76
109
  };
77
110
  export type ApFormListProps = {
78
111
  name: FormItemProps['name'];
@@ -80,6 +113,7 @@ export type ApFormListProps = {
80
113
  * 设置FormList的默认值
81
114
  */
82
115
  initialValue?: any[];
116
+ transform?: ApFormItemTransformType;
83
117
  };
84
118
  export type ApFormSearchFormProps = ApFormProps & {
85
119
  collapse?: boolean;
@@ -129,3 +163,19 @@ export type ApFormItemSlots = {
129
163
  export type ApFormDependencyProps = {
130
164
  nameList: NamePath[];
131
165
  };
166
+ export type ApFormSetProps = {
167
+ /**
168
+ * 需要聚合成的字段名
169
+ */
170
+ name: NamePath;
171
+ /**
172
+ * 聚合成(数组/对象)
173
+ */
174
+ as?: 'array' | 'object';
175
+ /**
176
+ * 转换函数(表单提交时触发)
177
+ * @param value
178
+ * @returns
179
+ */
180
+ transform?: ApFormItemTransformType;
181
+ };