@aplus-frontend/ui 0.0.4 → 0.0.6

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 (47) hide show
  1. package/es/src/ap-field/date-range/index.vue.mjs +65 -58
  2. package/es/src/ap-field/interface.d.ts +2 -2
  3. package/es/src/ap-form/ap-form-item-group/index.vue.mjs +23 -21
  4. package/es/src/ap-form/ap-form.vue.d.ts +7 -2
  5. package/es/src/ap-form/ap-form.vue2.mjs +85 -52
  6. package/es/src/ap-form/context.d.ts +14 -0
  7. package/es/src/ap-form/hooks/use-watch.d.ts +7 -0
  8. package/es/src/ap-form/hooks/use-watch.mjs +30 -0
  9. package/es/src/ap-form/index.d.ts +2 -0
  10. package/es/src/ap-form/index.mjs +13 -11
  11. package/es/src/ap-form/interface.d.ts +17 -7
  12. package/es/src/ap-form/modal-form/index.vue.d.ts +2 -2
  13. package/es/src/ap-form/modal-form/index.vue.mjs +1 -1
  14. package/es/src/ap-form/search-form/index.vue.mjs +27 -27
  15. package/es/src/ap-table/ap-table.vue.d.ts +2 -0
  16. package/es/src/ap-table/ap-table.vue.mjs +98 -93
  17. package/es/src/ap-table/interface.d.ts +18 -1
  18. package/es/src/pro-form/helper.mjs +7 -7
  19. package/es/src/theme/antd-global-overwrite/admin/alert.css +3 -0
  20. package/es/src/theme/antd-global-overwrite/admin/index.css +3 -0
  21. package/es/src/theme/antd-global-overwrite/aplus/alert.css +3 -0
  22. package/es/src/theme/antd-global-overwrite/aplus/index.css +3 -0
  23. package/es/src/utils/index.mjs +32 -32
  24. package/lib/src/ap-field/date-range/index.vue.js +1 -1
  25. package/lib/src/ap-field/interface.d.ts +2 -2
  26. package/lib/src/ap-form/ap-form-item-group/index.vue.js +1 -1
  27. package/lib/src/ap-form/ap-form.vue.d.ts +7 -2
  28. package/lib/src/ap-form/ap-form.vue2.js +1 -1
  29. package/lib/src/ap-form/context.d.ts +14 -0
  30. package/lib/src/ap-form/hooks/use-watch.d.ts +7 -0
  31. package/lib/src/ap-form/hooks/use-watch.js +1 -0
  32. package/lib/src/ap-form/index.d.ts +2 -0
  33. package/lib/src/ap-form/index.js +1 -1
  34. package/lib/src/ap-form/interface.d.ts +17 -7
  35. package/lib/src/ap-form/modal-form/index.vue.d.ts +2 -2
  36. package/lib/src/ap-form/modal-form/index.vue.js +1 -1
  37. package/lib/src/ap-form/search-form/index.vue.js +1 -1
  38. package/lib/src/ap-table/ap-table.vue.d.ts +2 -0
  39. package/lib/src/ap-table/ap-table.vue.js +1 -1
  40. package/lib/src/ap-table/interface.d.ts +18 -1
  41. package/lib/src/pro-form/helper.js +1 -1
  42. package/lib/src/theme/antd-global-overwrite/admin/alert.css +3 -0
  43. package/lib/src/theme/antd-global-overwrite/admin/index.css +3 -0
  44. package/lib/src/theme/antd-global-overwrite/aplus/alert.css +3 -0
  45. package/lib/src/theme/antd-global-overwrite/aplus/index.css +3 -0
  46. package/lib/src/utils/index.js +1 -1
  47. package/package.json +2 -2
@@ -1,14 +1,14 @@
1
- import { defineComponent as A, computed as f, unref as o, openBlock as y, createElementBlock as h, Fragment as B, createTextVNode as O, toDisplayString as P, createVNode as x, createBlock as E, mergeProps as F, createSlots as N, renderList as V, withCtx as I, renderSlot as j, normalizeProps as U, guardReactiveProps as H } from "vue";
2
- import { ApFieldDatePresetFormats as z, PRESET_FORMAT_MAP as K, PRESET_FORMAT_PICK_MAP as $, PRESET_FORMAT_TIME_MAP as L } from "../date/constant.mjs";
1
+ import { defineComponent as E, computed as p, unref as t, openBlock as y, createElementBlock as k, Fragment as B, createTextVNode as O, toDisplayString as C, createVNode as F, createBlock as N, mergeProps as V, createSlots as I, renderList as j, withCtx as U, renderSlot as H, normalizeProps as z, guardReactiveProps as K } from "vue";
2
+ import { ApFieldDatePresetFormats as $, PRESET_FORMAT_MAP as L, PRESET_FORMAT_PICK_MAP as Y, PRESET_FORMAT_TIME_MAP as q } from "../date/constant.mjs";
3
3
  import "../../hooks/index.mjs";
4
- import { isNil as Y, omit as q, isString as s } from "lodash-unified";
4
+ import { isNil as b, omit as G, isString as s } from "lodash-unified";
5
5
  import u from "dayjs";
6
- import { DatePicker as G } from "ant-design-vue";
7
- import { formatDay as p, formatValue as C } from "../date/helper.mjs";
8
- import { SwapRightOutlined as J } from "@ant-design/icons-vue";
9
- import { omitUndefined as Q } from "../../utils/index.mjs";
10
- import { useControllableValue as W } from "../../hooks/useControllableValue.mjs";
11
- const ie = /* @__PURE__ */ A({
6
+ import { DatePicker as J } from "ant-design-vue";
7
+ import { formatDay as f, formatValue as S } from "../date/helper.mjs";
8
+ import { SwapRightOutlined as Q } from "@ant-design/icons-vue";
9
+ import { omitUndefined as W } from "../../utils/index.mjs";
10
+ import { useControllableValue as X } from "../../hooks/useControllableValue.mjs";
11
+ const de = /* @__PURE__ */ E({
12
12
  __name: "index",
13
13
  props: {
14
14
  mode: { default: "edit" },
@@ -84,26 +84,26 @@ const ie = /* @__PURE__ */ A({
84
84
  onOk: {}
85
85
  },
86
86
  emits: ["update:value"],
87
- setup(S, { emit: b }) {
88
- const t = S, T = b, r = f(
89
- () => z.indexOf(t.format) > -1
90
- ), l = f(
91
- () => r.value ? K[t.format] : t.format
92
- ), { value: k, updateValue: g } = W(
93
- t,
94
- T
95
- ), m = f(() => {
96
- var e, a;
97
- if (!Y(o(k)))
98
- return [
99
- u((e = o(k)) == null ? void 0 : e[0]),
100
- u((a = o(k)) == null ? void 0 : a[1])
101
- ];
102
- }), R = f(() => o(r) ? t.picker ?? $[t.format] : t.picker), w = f(() => {
103
- const e = o(r) ? L[t.format] : {};
87
+ setup(T, { emit: R }) {
88
+ const o = T, w = R, r = p(
89
+ () => $.indexOf(o.format) > -1
90
+ ), l = p(
91
+ () => r.value ? L[o.format] : o.format
92
+ ), { value: g, updateValue: h } = X(
93
+ o,
94
+ w
95
+ ), m = p(() => {
96
+ var a, n;
97
+ const e = t(g);
98
+ return b(e) || !(e != null && e.length) ? e : [
99
+ u((a = t(g)) == null ? void 0 : a[0]),
100
+ u((n = t(g)) == null ? void 0 : n[1])
101
+ ];
102
+ }), _ = p(() => t(r) ? o.picker ?? Y[o.format] : o.picker), D = p(() => {
103
+ const e = t(r) ? q[o.format] : {};
104
104
  return {
105
- ...Q(
106
- q(t, [
105
+ ...W(
106
+ G(o, [
107
107
  "value",
108
108
  "onUpdate:value",
109
109
  "onChange",
@@ -115,46 +115,53 @@ const ie = /* @__PURE__ */ A({
115
115
  ...e
116
116
  };
117
117
  });
118
- function _(e) {
119
- e || g(null);
118
+ function M(e) {
119
+ if (!e) {
120
+ h(e);
121
+ return;
122
+ }
120
123
  const a = s(e[0]) ? u(e[0]) : e[0], n = s(e[1]) ? u(e[1]) : e[1];
121
- o(r) ? g([
122
- p(a, o(l)),
123
- p(n, o(l), !1)
124
- ]) : g([C(a), C(n)]);
124
+ t(r) ? h([
125
+ f(a, t(l)),
126
+ f(n, t(l), !1)
127
+ ]) : h([S(a), S(n)]);
125
128
  }
126
- function D(e) {
129
+ function A(e) {
127
130
  var d;
128
- const a = s(e[0]) ? u(e[0]) : e[0], n = s(e[1]) ? u(e[1]) : e[1], i = e[0] ? o(r) ? p(a, o(l)) : a.valueOf() : null, c = e[1] ? o(r) ? p(n, o(l), !1) : n.valueOf() : null;
129
- (d = t.onOk) == null || d.call(t, [i, c]);
131
+ const a = s(e[0]) ? u(e[0]) : e[0], n = s(e[1]) ? u(e[1]) : e[1], i = e[0] ? t(r) ? f(a, t(l)) : a.valueOf() : null, c = e[1] ? t(r) ? f(n, t(l), !1) : n.valueOf() : null;
132
+ (d = o.onOk) == null || d.call(o, [i, c]);
130
133
  }
131
- function M(e, a) {
132
- var v;
133
- const n = s(e[0]) ? u(e[0]) : e[0], i = s(e[1]) ? u(e[1]) : e[1], c = e[0] ? o(r) ? p(n, o(l)) : n.valueOf() : null, d = e[1] ? o(r) ? p(i, o(l), !1) : i.valueOf() : null;
134
- (v = t.onChange) == null || v.call(t, [c, d], a);
134
+ function x(e, a) {
135
+ var v, P;
136
+ if (b(e)) {
137
+ (v = o.onChange) == null || v.call(o, e, a);
138
+ return;
139
+ }
140
+ const n = s(e[0]) ? u(e[0]) : e[0], i = s(e[1]) ? u(e[1]) : e[1], c = e[0] ? t(r) ? f(n, t(l)) : n.valueOf() : null, d = e[1] ? t(r) ? f(i, t(l), !1) : i.valueOf() : null;
141
+ (P = o.onChange) == null || P.call(o, [c, d], a);
135
142
  }
136
143
  return (e, a) => {
137
144
  var n, i;
138
- return e.mode === "read" ? (y(), h(B, { key: 0 }, [
139
- m.value ? (y(), h(B, { key: 0 }, [
140
- O(P((n = m.value[0]) == null ? void 0 : n.format(l.value)) + " ", 1),
141
- x(o(J)),
142
- O(" " + P((i = m.value[1]) == null ? void 0 : i.format(l.value)), 1)
143
- ], 64)) : (y(), h(B, { key: 1 }, [
144
- O(P(e.emptyText), 1)
145
+ return e.mode === "read" ? (y(), k(B, { key: 0 }, [
146
+ m.value ? (y(), k(B, { key: 0 }, [
147
+ O(C((n = m.value[0]) == null ? void 0 : n.format(l.value)) + " ", 1),
148
+ F(t(Q)),
149
+ O(" " + C((i = m.value[1]) == null ? void 0 : i.format(l.value)), 1)
150
+ ], 64)) : (y(), k(B, { key: 1 }, [
151
+ O(C(e.emptyText), 1)
145
152
  ], 64))
146
- ], 64)) : (y(), E(o(G).RangePicker, F({ key: 1 }, w.value, {
153
+ ], 64)) : (y(), N(t(J).RangePicker, V({ key: 1 }, D.value, {
147
154
  value: m.value,
148
- "onUpdate:value": _,
149
- onChange: M,
150
- picker: R.value,
155
+ "onUpdate:value": M,
156
+ onChange: x,
157
+ picker: _.value,
151
158
  format: l.value,
152
- onOk: D
153
- }), N({ _: 2 }, [
154
- V(e.$slots, (c, d) => ({
159
+ onOk: A
160
+ }), I({ _: 2 }, [
161
+ j(e.$slots, (c, d) => ({
155
162
  name: d,
156
- fn: I((v) => [
157
- j(e.$slots, d, U(H(v || {})))
163
+ fn: U((v) => [
164
+ H(e.$slots, d, z(K(v || {})))
158
165
  ])
159
166
  }))
160
167
  ]), 1040, ["value", "picker", "format"]));
@@ -162,5 +169,5 @@ const ie = /* @__PURE__ */ A({
162
169
  }
163
170
  });
164
171
  export {
165
- ie as default
172
+ de as default
166
173
  };
@@ -69,9 +69,9 @@ export type ApFieldTextAreaExpose = {
69
69
  };
70
70
  export type ApFieldDateRangeProps = BasicApFieldProps<Omit<RangePickerProps, 'value' | 'onChange' | 'onPanelChange' | 'defaultValue' | 'onOk' | 'renderExtraFooter' | 'onUpdate:value' | 'mode'>> & {
71
71
  emptyText?: string;
72
- value?: RangeValue<number>;
72
+ value?: RangeValue<number> | null;
73
73
  defaultValue?: RangeValue<number>;
74
- onChange?: (ts: RangeValue<number>, dayStr: [string, string]) => void;
74
+ onChange?: (ts: RangeValue<number> | null, dayStr: [string, string]) => void;
75
75
  onOk?: (ts: RangeValue<number>) => void;
76
76
  format?: LiteralUnion<ApFormatPresetType, string>;
77
77
  };
@@ -1,12 +1,12 @@
1
- import { isVNode as w, defineComponent as _, useSlots as k, watch as b, shallowRef as h, computed as x, unref as n, createVNode as R, mergeProps as u, openBlock as a, createBlock as m, withCtx as S, createElementBlock as j, Fragment as B, renderList as N, resolveDynamicComponent as P } from "vue";
2
- import { Col as v, Row as F } from "ant-design-vue";
3
- import { pick as I } from "lodash-unified";
4
- import { apFormItemColPropKeys as O } from "../constant.mjs";
5
- import { genRealChildren as i, buildColSpan as V } from "./helper.mjs";
1
+ import { isVNode as w, defineComponent as _, useSlots as k, watch as b, onBeforeUpdate as h, shallowRef as x, computed as B, unref as p, createVNode as R, mergeProps as m, openBlock as s, createBlock as i, withCtx as S, createElementBlock as j, Fragment as v, renderList as N, resolveDynamicComponent as P } from "vue";
2
+ import { Col as F, Row as I } from "ant-design-vue";
3
+ import { pick as O } from "lodash-unified";
4
+ import { apFormItemColPropKeys as V } from "../constant.mjs";
5
+ import { genRealChildren as l, buildColSpan as A } from "./helper.mjs";
6
6
  import "../../config-provider/index.mjs";
7
7
  import "../style/ap-form-item-group.css";
8
- import { useNamespace as A } from "../../config-provider/hooks/use-namespace.mjs";
9
- function D(r) {
8
+ import { useNamespace as D } from "../../config-provider/hooks/use-namespace.mjs";
9
+ function E(r) {
10
10
  return typeof r == "function" || Object.prototype.toString.call(r) === "[object Object]" && !w(r);
11
11
  }
12
12
  const M = /* @__PURE__ */ _({
@@ -29,28 +29,30 @@ const M = /* @__PURE__ */ _({
29
29
  },
30
30
  setup(r) {
31
31
  const {
32
- b: s
33
- } = A("ap-form-item-group"), {
32
+ b: c
33
+ } = D("ap-form-item-group"), {
34
34
  countPerRow: f,
35
35
  ...d
36
- } = r, p = k();
37
- b(() => p.default(), (e) => {
38
- c.value = i(e);
36
+ } = r, n = k();
37
+ b(() => n.default(), (e) => {
38
+ a.value = l(e);
39
+ }), h(() => {
40
+ a.value = l(n.default());
39
41
  });
40
- const c = h(i(p.default())), y = x(() => n(c).map((e, l) => {
41
- const t = e.props, o = I(t, O), C = o != null && o.span ? {} : V(f), g = !!(t != null && t.hidden);
42
- return R(v, u({
43
- key: l
42
+ const a = x(l(n.default())), y = B(() => p(a).map((e, u) => {
43
+ const t = e.props, o = O(t, V), C = o != null && o.span ? {} : A(f), g = !!(t != null && t.hidden);
44
+ return R(F, m({
45
+ key: u
44
46
  }, C, o, {
45
- class: g ? s("col-hidden") : ""
46
- }), D(e) ? e : {
47
+ class: g ? c("col-hidden") : ""
48
+ }), E(e) ? e : {
47
49
  default: () => [e]
48
50
  });
49
51
  }));
50
- return (e, l) => (a(), m(n(F), u({
51
- class: n(s)()
52
+ return (e, u) => (s(), i(p(I), m({
53
+ class: p(c)()
52
54
  }, d), {
53
- default: S(() => [(a(!0), j(B, null, N(y.value, (t, o) => (a(), m(P(t), {
55
+ default: S(() => [(s(!0), j(v, null, N(y.value, (t, o) => (s(), i(P(t), {
54
56
  key: o
55
57
  }))), 128))]),
56
58
  _: 1
@@ -1,7 +1,11 @@
1
- import { ApFormProps } from './interface';
1
+ import { ApFormProps, WatchFunc } from './interface';
2
2
  import { InternalNamePath, NamePath, ValidateOptions, FormLabelAlign } from 'ant-design-vue/es/form/interface';
3
3
  import { DefineComponent, ComponentOptionsMixin, PublicProps, ExtractPropTypes, PropType } from 'vue';
4
4
 
5
+ /**
6
+ * 订阅事件
7
+ */
8
+ declare function registerWatch(callback: WatchFunc): () => void;
5
9
  declare const _default: __VLS_WithTemplateSlots< DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<ApFormProps>, {
6
10
  layout: string;
7
11
  hideRequiredMark: boolean;
@@ -23,7 +27,8 @@ declare const _default: __VLS_WithTemplateSlots< DefineComponent<__VLS_WithDefau
23
27
  }> | undefined;
24
28
  scrollToField: (name: NamePath, options?: {}) => void;
25
29
  setFieldsValue: (values: Record<string, any>) => void;
26
- setFieldValue: (key: string, newValue: any) => void;
30
+ setFieldValue: (key: any, newValue: any) => void;
31
+ registerWatch: typeof registerWatch;
27
32
  }, unknown, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly< ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<ApFormProps>, {
28
33
  layout: string;
29
34
  hideRequiredMark: boolean;
@@ -1,11 +1,10 @@
1
- import { defineComponent as u, ref as c, reactive as f, computed as p, openBlock as F, createBlock as m, unref as g, mergeProps as v, withCtx as h, renderSlot as V } from "vue";
2
- import { Form as y } from "ant-design-vue";
3
- import { useProvideForm as C } from "./context.mjs";
4
- import { isArray as B } from "lodash-unified";
5
- const S = /* @__PURE__ */ u({
1
+ import { defineComponent as b, ref as k, reactive as x, computed as M, openBlock as R, createBlock as T, unref as W, mergeProps as q, withCtx as w, renderSlot as z } from "vue";
2
+ import { Form as A } from "ant-design-vue";
3
+ import { useProvideForm as E } from "./context.mjs";
4
+ import { isArray as y } from "lodash-unified";
5
+ const I = /* @__PURE__ */ b({
6
6
  __name: "ap-form",
7
7
  props: {
8
- initialValues: {},
9
8
  layout: { default: "horizontal" },
10
9
  labelCol: {},
11
10
  wrapperCol: {},
@@ -28,62 +27,96 @@ const S = /* @__PURE__ */ u({
28
27
  onFieldsChange: {},
29
28
  onFinish: {},
30
29
  onFinishFailed: {},
31
- onValidate: {}
30
+ onValidate: {},
31
+ initialValues: {}
32
32
  },
33
- setup(s, { expose: d }) {
34
- const i = s;
35
- function n(e, l) {
36
- if (B(e)) {
37
- let t = o;
38
- for (let r = 0; r < e.length - 1; r++)
39
- t = t[e[r]];
40
- t[e[e.length - 1]] = l;
33
+ setup(C, { expose: B }) {
34
+ const r = C;
35
+ function _(e, t) {
36
+ var V;
37
+ if (y(e)) {
38
+ let u = o;
39
+ for (let d = 0; d < e.length - 1; d++)
40
+ u = u[e[d]];
41
+ u[e[e.length - 1]] = t;
41
42
  } else
42
- o[e] = l;
43
+ o[e] = t;
44
+ let l = y(e) ? e[0] : e;
45
+ (V = r.onValuesChange) == null || V.call(r, { [l]: o[l] }, o), s();
43
46
  }
44
- const a = c(), o = f(i.initialValues || {});
45
- return C({ model: p(() => o), updateModel: n }), d({
46
- resetFields: (e) => {
47
- var l;
48
- (l = a.value) == null || l.resetFields(e);
49
- },
50
- clearValidate: (e) => {
51
- var l;
52
- (l = a.value) == null || l.clearValidate(e);
53
- },
54
- validateFields: (e, l) => {
55
- var t;
56
- return (t = a.value) == null ? void 0 : t.validateFields(e, l);
57
- },
58
- getFieldsValue: (e) => {
59
- var l;
60
- return (l = a.value) == null ? void 0 : l.getFieldsValue(e);
61
- },
62
- validate: (e, l) => {
63
- var t;
64
- return (t = a.value) == null ? void 0 : t.validate(e, l);
65
- },
66
- scrollToField: (e, l = {}) => {
67
- var t;
68
- (t = a.value) == null || t.scrollToField(e, l);
69
- },
70
- setFieldsValue: (e) => {
71
- Object.assign(o, e);
72
- },
73
- setFieldValue: (e, l) => {
74
- o[e] = l;
47
+ const a = k(), o = x(r.initialValues || {});
48
+ let i = [];
49
+ const f = (e) => {
50
+ var t;
51
+ (t = a.value) == null || t.resetFields(e), s();
52
+ }, c = (e) => {
53
+ var t;
54
+ (t = a.value) == null || t.clearValidate(e);
55
+ }, p = (e, t) => {
56
+ var l;
57
+ return (l = a.value) == null ? void 0 : l.validateFields(e, t);
58
+ }, n = (e) => {
59
+ var t;
60
+ return (t = a.value) == null ? void 0 : t.getFieldsValue(e);
61
+ }, h = (e, t) => {
62
+ var l;
63
+ return (l = a.value) == null ? void 0 : l.validate(e, t);
64
+ }, g = (e, t = {}) => {
65
+ var l;
66
+ (l = a.value) == null || l.scrollToField(e, t);
67
+ }, F = (e) => {
68
+ Object.assign(o, e), s();
69
+ }, m = (e, t) => {
70
+ o[e] = t, s();
71
+ };
72
+ function v(e) {
73
+ return i.push(e), () => {
74
+ i = i.filter((t) => t !== e);
75
+ };
76
+ }
77
+ function s() {
78
+ if (i.length) {
79
+ const e = n(!0);
80
+ i.forEach((t) => {
81
+ t(e);
82
+ });
83
+ }
84
+ }
85
+ return E({
86
+ model: M(() => o),
87
+ updateModel: _,
88
+ formInstance: {
89
+ resetFields: f,
90
+ clearValidate: c,
91
+ validateFields: p,
92
+ getFieldsValue: n,
93
+ validate: h,
94
+ scrollToField: g,
95
+ setFieldsValue: F,
96
+ setFieldValue: m,
97
+ registerWatch: v
75
98
  }
76
- }), (e, l) => (F(), m(g(y), v({
99
+ }), B({
100
+ resetFields: f,
101
+ clearValidate: c,
102
+ validateFields: p,
103
+ getFieldsValue: n,
104
+ validate: h,
105
+ scrollToField: g,
106
+ setFieldsValue: F,
107
+ setFieldValue: m,
108
+ registerWatch: v
109
+ }), (e, t) => (R(), T(W(A), q({
77
110
  ref_key: "formRef",
78
111
  ref: a
79
- }, i, { model: o }), {
80
- default: h(() => [
81
- V(e.$slots, "default")
112
+ }, r, { model: o }), {
113
+ default: w(() => [
114
+ z(e.$slots, "default")
82
115
  ]),
83
116
  _: 3
84
117
  }, 16, ["model"]));
85
118
  }
86
119
  });
87
120
  export {
88
- S as default
121
+ I as default
89
122
  };
@@ -1,9 +1,23 @@
1
1
  import { NamePath } from 'ant-design-vue/es/form/interface';
2
2
  import { ComputedRef, InjectionKey } from 'vue';
3
+ import { ApFormExpose } from './interface';
3
4
 
4
5
  type ApFormContextProps<ModelType> = {
6
+ /**
7
+ * Form数据源
8
+ */
5
9
  model?: ComputedRef<ModelType>;
10
+ /**
11
+ * 更新数据源的方法
12
+ * @param name
13
+ * @param value
14
+ * @returns
15
+ */
6
16
  updateModel?: (name: NamePath, value: any) => void;
17
+ /**
18
+ * ApForm内部实例
19
+ */
20
+ formInstance?: ApFormExpose;
7
21
  };
8
22
  export declare const ApFormContextKey: InjectionKey<ApFormContextProps<any>>;
9
23
  export declare function useProvideForm<ModelType>(state: ApFormContextProps<ModelType>): void;
@@ -0,0 +1,7 @@
1
+ import { NamePath } from 'ant-design-vue/es/form/interface';
2
+ import { ApFormExpose } from '../interface';
3
+ import { Ref } from 'vue';
4
+
5
+ type ApFormIns = ApFormExpose;
6
+ declare const useWatch: <ValueType = any>(name: NamePath, form?: Ref<ApFormIns | undefined>) => Ref<ValueType | undefined>;
7
+ export default useWatch;
@@ -0,0 +1,30 @@
1
+ import { useInjectForm as l } from "../context.mjs";
2
+ import { ref as g, watchEffect as h } from "vue";
3
+ import { isArray as S } from "lodash-unified";
4
+ function V(t, r) {
5
+ return S(r) ? r.reduce((e, n) => e == null ? void 0 : e[n], t) : t == null ? void 0 : t[r];
6
+ }
7
+ function w(t) {
8
+ try {
9
+ return JSON.stringify(t);
10
+ } catch {
11
+ return Math.random();
12
+ }
13
+ }
14
+ const M = (t, r) => {
15
+ const { formInstance: e } = l(), n = g();
16
+ let c = "";
17
+ return h((s) => {
18
+ const u = (r == null ? void 0 : r.value) || e;
19
+ if (!u)
20
+ return;
21
+ const o = u.registerWatch((f) => {
22
+ const a = V(f, t), i = w(a);
23
+ i !== c && (n.value = a, c = i);
24
+ });
25
+ s(o);
26
+ }), n;
27
+ };
28
+ export {
29
+ M as default
30
+ };
@@ -4,6 +4,7 @@ import { default as ApFormItemGroup } from './ap-form-item-group/index.vue';
4
4
  import { default as ApFormList } from './ap-form-list.vue';
5
5
  import { default as ApFormSearchForm } from './search-form/index.vue';
6
6
  import { default as ApFormModalForm } from './modal-form/index.vue';
7
+ import { default as useWatch } from './hooks/use-watch';
7
8
 
8
9
  type ApFormMixedProps = typeof _ApForm & {
9
10
  FormItem: typeof ApFormItem;
@@ -11,6 +12,7 @@ type ApFormMixedProps = typeof _ApForm & {
11
12
  FormList: typeof ApFormList;
12
13
  SearchForm: typeof ApFormSearchForm;
13
14
  ModalForm: typeof ApFormModalForm;
15
+ useWatch: typeof useWatch;
14
16
  };
15
17
  declare const ApForm: ApFormMixedProps;
16
18
  export * from './items';
@@ -4,25 +4,27 @@ import "./ap-form-item-group/index.vue2.mjs";
4
4
  import "./ap-form-list.vue2.mjs";
5
5
  import "./search-form/index.vue2.mjs";
6
6
  import "./modal-form/index.vue2.mjs";
7
+ import o from "./hooks/use-watch.mjs";
7
8
  import "./items/index.mjs";
8
9
  import "./interface.mjs";
9
- import o from "./ap-form.vue2.mjs";
10
- import r from "./ap-form-item.vue.mjs";
10
+ import r from "./ap-form.vue2.mjs";
11
+ import t from "./ap-form-item.vue.mjs";
11
12
  import p from "./ap-form-item-group/index.vue.mjs";
12
13
  import i from "./ap-form-list.vue.mjs";
13
- import t from "./search-form/index.vue.mjs";
14
- import a from "./modal-form/index.vue.mjs";
15
- const m = o;
16
- m.FormItem = r;
14
+ import a from "./search-form/index.vue.mjs";
15
+ import s from "./modal-form/index.vue.mjs";
16
+ const m = r;
17
+ m.FormItem = t;
17
18
  m.FormItemGroup = p;
18
19
  m.FormList = i;
19
- m.SearchForm = t;
20
- m.ModalForm = a;
20
+ m.SearchForm = a;
21
+ m.ModalForm = s;
22
+ m.useWatch = o;
21
23
  export {
22
24
  m as ApForm,
23
- r as ApFormItem,
25
+ t as ApFormItem,
24
26
  p as ApFormItemGroup,
25
27
  i as ApFormList,
26
- a as ApFormModalForm,
27
- t as ApFormSearchForm
28
+ s as ApFormModalForm,
29
+ a as ApFormSearchForm
28
30
  };
@@ -1,6 +1,7 @@
1
1
  import { ButtonProps, ColProps, FormItemProps, FormProps, ModalProps, RowProps } from 'ant-design-vue';
2
2
  import { FormItemExpose } from 'ant-design-vue/es/form/FormItem';
3
- import { NamePath, ValidateOptions } from 'ant-design-vue/es/form/interface';
3
+ import { InternalNamePath, NamePath, ValidateOptions } from 'ant-design-vue/es/form/interface';
4
+ import { Recordable } from '../type';
4
5
 
5
6
  export type ApFormColProps = Omit<ColProps, 'prefixCls'>;
6
7
  export type ApFormItemProps = FormItemProps & Partial<ApFormColProps> & {
@@ -13,18 +14,27 @@ export type ApFormItemProps = FormItemProps & Partial<ApFormColProps> & {
13
14
  export type ApFormItemGroupProps = RowProps & {
14
15
  countPerRow?: number;
15
16
  };
16
- export type ApFormProps = {
17
- initialValues?: Record<string, any>;
18
- } & Omit<FormProps, 'model'>;
17
+ export type ApFormProps = Omit<FormProps, 'model'> & {
18
+ initialValues?: Recordable;
19
+ /**
20
+ * 字段值更新时触发
21
+ * @param changedValues 更改的字段值
22
+ * @param allValues 更改后的字段值
23
+ * @returns
24
+ */
25
+ onValuesChange?: (changedValues: Recordable, allValues: Recordable) => void;
26
+ };
27
+ export type WatchFunc = (values?: Recordable) => void;
19
28
  export type ApFormExpose<ModelType = any> = {
20
29
  setFieldsValue?: (fields: Partial<ModelType>) => void;
21
30
  setFieldValue?: (key: keyof ModelType, value: any) => void;
22
31
  resetFields: (name?: NamePath) => void;
23
32
  clearValidate: (name?: NamePath) => void;
24
- validateFields: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<Partial<ModelType>>;
25
- getFieldsValue: (nameList?: (string | number)[] | true) => Partial<ModelType>;
26
- validate: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<Partial<ModelType>>;
33
+ validateFields: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<Partial<ModelType>> | undefined;
34
+ getFieldsValue: (nameList?: true | InternalNamePath[]) => Partial<ModelType> | undefined;
35
+ validate: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<Partial<ModelType>> | undefined;
27
36
  scrollToField: (name: NamePath, options?: any) => void;
37
+ registerWatch: (callback: WatchFunc) => () => void;
28
38
  };
29
39
  export type ApFormItemExpose = FormItemExpose & {
30
40
  getFieldValue: () => any;
@@ -1,6 +1,6 @@
1
1
  import { ApFormModalFormProps, ApFormSubmitterConfig } from '../interface';
2
2
  import { VNode, DefineComponent, ComponentOptionsMixin, PublicProps, ExtractPropTypes, PropType, CSSProperties } from 'vue';
3
- import { NamePath, ValidateOptions, FormLabelAlign } from 'ant-design-vue/es/form/interface';
3
+ import { InternalNamePath, NamePath, ValidateOptions, FormLabelAlign } from 'ant-design-vue/es/form/interface';
4
4
  import { VueTypeValidableDef } from '../../../node_modules/vue-types';
5
5
  import { LegacyButtonType, ButtonHTMLType } from 'ant-design-vue/es/button/buttonTypes';
6
6
  import { ButtonType, ButtonShape, ButtonSize } from 'ant-design-vue/es/button';
@@ -31,7 +31,7 @@ declare const _default: __VLS_WithTemplateSlots< DefineComponent<__VLS_WithDefau
31
31
  resetFields: (name?: NamePath | undefined) => void;
32
32
  clearValidate: (name?: NamePath | undefined) => void;
33
33
  validateFields: (nameList?: string | NamePath[] | undefined, options?: ValidateOptions | undefined) => Promise<Partial<any>> | undefined;
34
- getFieldsValue: (nameList?: true | (string | number)[] | undefined) => Partial<any> | undefined;
34
+ getFieldsValue: (nameList?: true | InternalNamePath[] | undefined) => Partial<any> | undefined;
35
35
  validate: (nameList?: string | NamePath[] | undefined, options?: ValidateOptions | undefined) => Promise<Partial<any>> | undefined;
36
36
  scrollToField: (name: NamePath, options?: {}) => void;
37
37
  setFieldValue: (key: string, newValue: any) => void;
@@ -17,7 +17,6 @@ function C(d) {
17
17
  const xe = /* @__PURE__ */ L({
18
18
  __name: "index",
19
19
  props: {
20
- initialValues: {},
21
20
  layout: {
22
21
  default: "horizontal"
23
22
  },
@@ -59,6 +58,7 @@ const xe = /* @__PURE__ */ L({
59
58
  onFieldsChange: {},
60
59
  onFinishFailed: {},
61
60
  onValidate: {},
61
+ initialValues: {},
62
62
  open: {
63
63
  type: Boolean,
64
64
  default: void 0