@aplus-frontend/ui 0.2.10 → 0.2.11

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 (65) hide show
  1. package/es/src/ap-form/ap-form.vue.d.ts +4 -0
  2. package/es/src/ap-form/ap-form.vue2.mjs +131 -108
  3. package/es/src/ap-form/drawer-form/index.vue.d.ts +27 -2
  4. package/es/src/ap-form/drawer-form/index.vue.mjs +43 -37
  5. package/es/src/ap-form/interface.d.ts +8 -0
  6. package/es/src/ap-form/modal-form/index.vue.d.ts +27 -2
  7. package/es/src/ap-form/modal-form/index.vue.mjs +26 -20
  8. package/es/src/ap-form/search-form/index.vue.d.ts +27 -2
  9. package/es/src/ap-form/search-form/index.vue.mjs +37 -31
  10. package/es/src/ap-form/utils/params.d.ts +17 -0
  11. package/es/src/ap-form/utils/params.mjs +19 -0
  12. package/es/src/ap-table/interface.d.ts +1 -0
  13. package/es/src/business/ap-group-search/ap-group-search.vue.d.ts +3 -1
  14. package/es/src/business/ap-group-search/ap-group-search.vue2.mjs +80 -70
  15. package/es/src/business/ap-group-search/extension-select/index.vue.d.ts +6 -2
  16. package/es/src/business/ap-group-search/extension-select/index.vue2.mjs +44 -34
  17. package/es/src/business/ap-group-search/extension-select/style/css.d.ts +0 -0
  18. package/es/src/business/ap-group-search/extension-select/style/css.js +1 -0
  19. package/es/src/business/ap-group-search/extension-select/style/index.d.ts +0 -0
  20. package/es/src/business/ap-group-search/extension-select/style/index.js +1 -0
  21. package/es/src/business/ap-group-search/images/icon-line-select.vue.mjs +9 -9
  22. package/es/src/business/ap-group-search/index.d.ts +28 -0
  23. package/es/src/business/ap-group-search/popover-select/index.vue.d.ts +6 -2
  24. package/es/src/business/ap-group-search/popover-select/index.vue2.mjs +50 -50
  25. package/es/src/business/ap-group-search/popover-select/style/css.js +1 -1
  26. package/es/src/business/ap-group-search/popover-select/style/index.js +1 -1
  27. package/es/src/business/ap-summary/ap-summary.vue2.mjs +58 -38
  28. package/es/src/locale/lang/en.mjs +1 -1
  29. package/es/src/locale/lang/zh-cn.mjs +1 -1
  30. package/es/src/path-map.mjs +2 -1
  31. package/es/src/utils/index.d.ts +12 -0
  32. package/es/src/utils/index.mjs +27 -18
  33. package/lib/src/ap-form/ap-form.vue.d.ts +4 -0
  34. package/lib/src/ap-form/ap-form.vue2.js +1 -1
  35. package/lib/src/ap-form/drawer-form/index.vue.d.ts +27 -2
  36. package/lib/src/ap-form/drawer-form/index.vue.js +1 -1
  37. package/lib/src/ap-form/interface.d.ts +8 -0
  38. package/lib/src/ap-form/modal-form/index.vue.d.ts +27 -2
  39. package/lib/src/ap-form/modal-form/index.vue.js +1 -1
  40. package/lib/src/ap-form/search-form/index.vue.d.ts +27 -2
  41. package/lib/src/ap-form/search-form/index.vue.js +1 -1
  42. package/lib/src/ap-form/utils/params.d.ts +17 -0
  43. package/lib/src/ap-form/utils/params.js +1 -0
  44. package/lib/src/ap-table/interface.d.ts +1 -0
  45. package/lib/src/business/ap-group-search/ap-group-search.vue.d.ts +3 -1
  46. package/lib/src/business/ap-group-search/ap-group-search.vue2.js +1 -1
  47. package/lib/src/business/ap-group-search/extension-select/index.vue.d.ts +6 -2
  48. package/lib/src/business/ap-group-search/extension-select/index.vue2.js +1 -1
  49. package/lib/src/business/ap-group-search/extension-select/style/css.d.ts +0 -0
  50. package/lib/src/business/ap-group-search/extension-select/style/css.js +1 -0
  51. package/lib/src/business/ap-group-search/extension-select/style/index.d.ts +0 -0
  52. package/lib/src/business/ap-group-search/extension-select/style/index.js +1 -0
  53. package/lib/src/business/ap-group-search/images/icon-line-select.vue.js +1 -1
  54. package/lib/src/business/ap-group-search/index.d.ts +28 -0
  55. package/lib/src/business/ap-group-search/popover-select/index.vue.d.ts +6 -2
  56. package/lib/src/business/ap-group-search/popover-select/index.vue2.js +2 -2
  57. package/lib/src/business/ap-group-search/popover-select/style/css.js +1 -1
  58. package/lib/src/business/ap-group-search/popover-select/style/index.js +1 -1
  59. package/lib/src/business/ap-summary/ap-summary.vue2.js +1 -1
  60. package/lib/src/locale/lang/en.js +1 -1
  61. package/lib/src/locale/lang/zh-cn.js +1 -1
  62. package/lib/src/path-map.js +1 -1
  63. package/lib/src/utils/index.d.ts +12 -0
  64. package/lib/src/utils/index.js +1 -1
  65. package/package.json +4 -4
@@ -1,12 +1,12 @@
1
- import { defineComponent as O, ref as d, watchEffect as T, openBlock as z, createElementBlock as G, normalizeClass as p, unref as e, createVNode as a, withCtx as n, createElementVNode as s, mergeProps as R, createTextVNode as m, toDisplayString as f } from "vue";
2
- import { Popover as A, Select as D, Button as h, Space as F } from "@aplus-frontend/antdv";
1
+ import { defineComponent as P, ref as u, watchEffect as R, openBlock as L, createElementBlock as M, normalizeClass as p, unref as e, createVNode as a, withCtx as n, createElementVNode as s, mergeProps as O, createTextVNode as d, toDisplayString as m } from "vue";
2
+ import { Popover as T, Select as z, Button as f, Space as G } from "@aplus-frontend/antdv";
3
3
  import "../../../config-provider/index.mjs";
4
- import E from "../images/icon-line-select.vue.mjs";
5
- import { wait as K } from "@aplus-frontend/utils";
6
- import { useLocale as q } from "../../../config-provider/hooks/use-locale.mjs";
7
- import { useGlobalConfig as B } from "../../../config-provider/hooks/use-global-config.mjs";
8
- import { useNamespace as H } from "../../../config-provider/hooks/use-namespace.mjs";
9
- const Z = /* @__PURE__ */ O({
4
+ import A from "../images/icon-line-select.vue.mjs";
5
+ import { wait as D } from "@aplus-frontend/utils";
6
+ import { useLocale as F } from "../../../config-provider/hooks/use-locale.mjs";
7
+ import { useGlobalConfig as E } from "../../../config-provider/hooks/use-global-config.mjs";
8
+ import { useNamespace as K } from "../../../config-provider/hooks/use-namespace.mjs";
9
+ const Y = /* @__PURE__ */ P({
10
10
  __name: "index",
11
11
  props: {
12
12
  value: {},
@@ -81,54 +81,52 @@ const Z = /* @__PURE__ */ O({
81
81
  optionFilterProp: {},
82
82
  optionLabelProp: {},
83
83
  defaultActiveFirstOption: { type: Boolean },
84
- labelInValue: { type: Boolean }
84
+ labelInValue: { type: Boolean },
85
+ __parentRef: {}
85
86
  },
86
87
  emits: ["submit", "open-change"],
87
- setup(b, { emit: k }) {
88
- const { t: l } = q(), x = B("uiMode", "aplus"), v = b, C = k, t = d([]), c = d(!1), g = d();
89
- T(() => {
90
- t.value = v.value;
88
+ setup(S, { emit: w }) {
89
+ const { t: r } = F(), h = E("uiMode", "aplus"), i = S, v = w, t = u([]), c = u(!1), g = u();
90
+ R(() => {
91
+ t.value = i.value;
91
92
  });
92
- const V = (o) => {
93
- var S, w;
94
- const u = `.${B("namespace").value}-ap-group-search`;
95
- return document.querySelector(u) || ((w = (S = o == null ? void 0 : o.parentNode) == null ? void 0 : S.parentNode) == null ? void 0 : w.parentNode) || o;
96
- }, _ = (o) => {
97
- c.value = o, C("open-change", o);
98
- }, y = () => {
93
+ const B = (o) => i.__parentRef || o, b = (o) => {
94
+ c.value = o, v("open-change", o);
95
+ }, C = () => {
99
96
  c.value = !1;
100
- }, I = () => {
97
+ }, _ = () => {
101
98
  t.value = [];
102
- }, N = (o) => {
103
- console.log("change!!!", o), t.value = o;
104
- }, P = async () => {
99
+ }, x = (o) => {
100
+ t.value = o;
101
+ }, k = async () => {
105
102
  var o;
106
- (o = g.value) == null || o.blur(), y(), await K(150), C("submit", t.value);
107
- }, { b: L, e: M, em: r } = H("ap-popover-select");
108
- return (o, i) => (z(), G("div", {
109
- class: p(e(L)())
103
+ (o = g.value) == null || o.blur(), C(), await D(150), v("submit", t.value);
104
+ }, { b: N, e: V, em: l } = K("ap-popover-select");
105
+ return (o, y) => (L(), M("div", {
106
+ class: p(e(N)())
110
107
  }, [
111
- a(e(A), {
112
- overlayClassName: e(M)("popover"),
113
- "get-popup-container": V,
108
+ a(e(T), {
109
+ overlayClassName: e(V)("popover"),
110
+ "get-popup-container": B,
114
111
  trigger: "click",
115
112
  open: c.value,
116
113
  placement: "bottomLeft",
117
- onOpenChange: _
114
+ onOpenChange: b
118
115
  }, {
119
116
  content: n(() => [
120
117
  s("div", null, [
121
118
  s("div", {
122
- class: p(e(r)("popover", "content"))
119
+ class: p(e(l)("popover", "content"))
123
120
  }, [
124
- a(e(D), R({ ...v }, {
121
+ a(e(z), O({ ...i }, {
125
122
  mode: "tags",
126
123
  bordered: !1,
127
124
  value: t.value,
128
- onChange: i[0] || (i[0] = (u) => N(u)),
129
- placeholder: e(l)("ap.apGroupSearch.tokenSeparatorsPlaceholder"),
125
+ onChange: y[0] || (y[0] = (I) => x(I)),
126
+ placeholder: e(r)("ap.apGroupSearch.tokenSeparatorsPlaceholder"),
130
127
  tokenSeparators: [",", `
131
128
  `, "\r"],
129
+ "max-tag-count": 200,
132
130
  open: !1,
133
131
  ref_key: "selectRef",
134
132
  ref: g
@@ -136,36 +134,36 @@ const Z = /* @__PURE__ */ O({
136
134
  ], 2),
137
135
  s("div", {
138
136
  class: p(
139
- e(x) === "aplus" ? e(r)("popover", "footer") : e(r)("popover", "footer--admin")
137
+ e(h) === "aplus" ? e(l)("popover", "footer") : e(l)("popover", "footer--admin")
140
138
  )
141
139
  }, [
142
- a(e(h), {
140
+ a(e(f), {
143
141
  size: "small",
144
- onClick: y
142
+ onClick: C
145
143
  }, {
146
144
  default: n(() => [
147
- m(f(e(l)("ap.apGroupSearch.close")), 1)
145
+ d(m(e(r)("ap.apGroupSearch.close")), 1)
148
146
  ]),
149
147
  _: 1
150
148
  }),
151
- a(e(F), null, {
149
+ a(e(G), null, {
152
150
  default: n(() => [
153
- a(e(h), {
151
+ a(e(f), {
154
152
  size: "small",
155
- onClick: I
153
+ onClick: _
156
154
  }, {
157
155
  default: n(() => [
158
- m(f(e(l)("ap.apGroupSearch.clear")), 1)
156
+ d(m(e(r)("ap.apGroupSearch.clear")), 1)
159
157
  ]),
160
158
  _: 1
161
159
  }),
162
- a(e(h), {
160
+ a(e(f), {
163
161
  size: "small",
164
162
  type: "primary",
165
- onClick: P
163
+ onClick: k
166
164
  }, {
167
165
  default: n(() => [
168
- m(f(e(l)("ap.apGroupSearch.confirm")), 1)
166
+ d(m(e(r)("ap.apGroupSearch.confirm")), 1)
169
167
  ]),
170
168
  _: 1
171
169
  })
@@ -177,9 +175,11 @@ const Z = /* @__PURE__ */ O({
177
175
  ]),
178
176
  default: n(() => [
179
177
  s("span", {
180
- class: p(e(r)("popover", "trigger"))
178
+ class: p(
179
+ e(h) === "aplus" ? e(l)("popover", "trigger") : e(l)("popover", "trigger--admin")
180
+ )
181
181
  }, [
182
- a(E)
182
+ a(A)
183
183
  ], 2)
184
184
  ]),
185
185
  _: 1
@@ -188,5 +188,5 @@ const Z = /* @__PURE__ */ O({
188
188
  }
189
189
  });
190
190
  export {
191
- Z as default
191
+ Y as default
192
192
  };
@@ -1 +1 @@
1
- import '@aplus-frontend/ui-theme/src/ap-group-search/ap-group-search.css';
1
+ import '@aplus-frontend/ui-theme/src/ap-group-search/ap-popover-select.css';
@@ -1 +1 @@
1
- import '@aplus-frontend/ui-theme/src/ap-group-search/ap-group-search.less';
1
+ import '@aplus-frontend/ui-theme/src/ap-group-search/ap-popover-select.less';
@@ -1,11 +1,11 @@
1
- import { defineComponent as S, computed as g, openBlock as o, createBlock as u, unref as r, normalizeClass as i, withCtx as c, createElementBlock as T, Fragment as _, renderList as C, normalizeStyle as b, createTextVNode as L, toDisplayString as N } from "vue";
2
- import { isNil as w, get as z } from "lodash-unified";
3
- import { TableSummaryRow as B, TableSummaryCell as A } from "@aplus-frontend/antdv";
4
- import { flattenColumns as D, formatDataIndex as F } from "./utils.mjs";
1
+ import { defineComponent as I, computed as v, openBlock as m, createBlock as l, unref as r, normalizeClass as y, withCtx as f, createElementBlock as L, Fragment as w, renderList as z, normalizeStyle as B, resolveDynamicComponent as N } from "vue";
2
+ import { isNil as R, get as c } from "lodash-unified";
3
+ import { TableSummaryRow as A, TableSummaryCell as D } from "@aplus-frontend/antdv";
4
+ import { flattenColumns as F, formatDataIndex as u } from "./utils.mjs";
5
5
  import "../../config-provider/index.mjs";
6
- import { isNumeric as I, toThousand as v, toFixed as E } from "@aplus-frontend/utils";
7
- import { useNamespace as P } from "../../config-provider/hooks/use-namespace.mjs";
8
- const J = /* @__PURE__ */ S({
6
+ import { isNumeric as E, toThousand as P, toFixed as V } from "@aplus-frontend/utils";
7
+ import { useNamespace as $ } from "../../config-provider/hooks/use-namespace.mjs";
8
+ const O = /* @__PURE__ */ I({
9
9
  name: "ApSummary",
10
10
  __name: "ap-summary",
11
11
  props: {
@@ -22,45 +22,65 @@ const J = /* @__PURE__ */ S({
22
22
  default: "middle"
23
23
  }
24
24
  },
25
- setup(p) {
26
- const s = p, d = (e) => e === 0, f = (e, n) => {
27
- var l;
28
- if (!e || !I(e) || n.valueType !== "number")
29
- return e;
30
- const t = (l = n.fieldProps) == null ? void 0 : l.field, a = (t == null ? void 0 : t.precision) || 0;
31
- return (w(t == null ? void 0 : t.thousands) ? !0 : t == null ? void 0 : t.thousands) ? v(e, a) : E(e, a);
32
- }, y = g(() => {
33
- let e = [];
34
- s.hasSelect && e.push({
25
+ setup(x) {
26
+ const n = x, k = (a) => a === 0, h = (a, o) => {
27
+ var s;
28
+ if (!a || !E(a) || o.valueType !== "number")
29
+ return a;
30
+ const e = (s = o.fieldProps) == null ? void 0 : s.field, t = (e == null ? void 0 : e.precision) || 0;
31
+ return (R(e == null ? void 0 : e.thousands) ? !0 : e == null ? void 0 : e.thousands) ? P(a, t) : V(a, t);
32
+ }, T = v(() => {
33
+ let a = [];
34
+ n.hasSelect && a.push({
35
35
  key: "select",
36
36
  rowSpan: 1,
37
37
  align: "left",
38
38
  value: ""
39
39
  });
40
- const t = D(s.columns).map((a, m) => ({
41
- key: a.key,
42
- rowSpan: 1,
43
- align: a.align,
44
- value: d(m) ? s.summaryTitle : f(z(s.data, F(a.dataIndex || a.key)), a)
45
- }));
46
- return e.concat(t);
40
+ const e = F(n.columns).map((t, d) => {
41
+ let s;
42
+ const g = c(n.data, u(t.dataIndex || t.key));
43
+ if (k(d))
44
+ s = n.summaryTitle;
45
+ else if (g && (t.customRender || t.renderText)) {
46
+ const p = c(n.data, u(t.dataIndex || t.key)), b = u(t.dataIndex || t.key), i = t.customRender || t.renderText;
47
+ s = i == null ? void 0 : i({
48
+ value: p,
49
+ record: {
50
+ [b]: p
51
+ },
52
+ text: void 0,
53
+ index: 0,
54
+ renderIndex: 0,
55
+ column: {}
56
+ });
57
+ } else
58
+ s = h(c(n.data, u(t.dataIndex || t.key)), t);
59
+ return {
60
+ key: t.key,
61
+ rowSpan: 1,
62
+ align: t.align,
63
+ value: s
64
+ };
65
+ });
66
+ return a.concat(e);
47
67
  }), {
48
- b: h,
49
- e: x,
50
- em: k
51
- } = P("ap-summary");
52
- return (e, n) => (o(), u(r(B), {
53
- class: i(r(h)())
68
+ b: C,
69
+ e: S,
70
+ em: _
71
+ } = $("ap-summary");
72
+ return (a, o) => (m(), l(r(A), {
73
+ class: y(r(C)())
54
74
  }, {
55
- default: c(() => [(o(!0), T(_, null, C(y.value, (t, a) => (o(), u(r(A), {
56
- class: i(`${s.size === "small" ? r(k)("item", "small") : r(x)("item")}`),
57
- key: t.key,
58
- index: a,
59
- style: b({
60
- textAlign: t.align
75
+ default: f(() => [(m(!0), L(w, null, z(T.value, (e, t) => (m(), l(r(D), {
76
+ class: y(`${n.size === "small" ? r(_)("item", "small") : r(S)("item")}`),
77
+ key: e.key,
78
+ index: t,
79
+ style: B({
80
+ textAlign: e.align
61
81
  })
62
82
  }, {
63
- default: c(() => [L(N(t.value), 1)]),
83
+ default: f(() => [(m(), l(N(e.value)))]),
64
84
  _: 2
65
85
  }, 1032, ["class", "index", "style"]))), 128))]),
66
86
  _: 1
@@ -68,5 +88,5 @@ const J = /* @__PURE__ */ S({
68
88
  }
69
89
  });
70
90
  export {
71
- J as default
91
+ O as default
72
92
  };
@@ -125,7 +125,7 @@ const e = {
125
125
  close: "Close",
126
126
  clear: "Clear",
127
127
  confirm: "Confirm",
128
- tokenSeparatorsPlaceholder: "Supports batch input and can be separated by commas and newline symbols"
128
+ tokenSeparatorsPlaceholder: "A maximum of 200 entries can be entered in batches, separated by commas and newlines"
129
129
  }
130
130
  }
131
131
  };
@@ -134,7 +134,7 @@ const e = {
134
134
  close: "关闭",
135
135
  clear: "清空",
136
136
  confirm: "确定",
137
- tokenSeparatorsPlaceholder: "支持批量输入,可用逗号、换行符号分割"
137
+ tokenSeparatorsPlaceholder: "支持批量输入,可用逗号、换行符号分隔,最多输入200条"
138
138
  }
139
139
  }
140
140
  };
@@ -78,7 +78,8 @@ const e = {
78
78
  ApScrollBar: ["ap-scroll-bar"],
79
79
  ApAppendix: ["business", "ap-appendix"],
80
80
  ApGroupSearch: ["business", "ap-group-search"],
81
- ApPopoverSelect: ["business", "ap-group-search", "popover-select"]
81
+ ApPopoverSelect: ["business", "ap-group-search", "popover-select"],
82
+ ApExtensionSelect: ["business", "ap-group-search", "extension-select"]
82
83
  };
83
84
  export {
84
85
  e as default
@@ -27,3 +27,15 @@ export declare function convertReactiveToRaw(obj: Recordable<any>): Recordable<a
27
27
  export declare function omitUndefined(value: Recordable<any>): {
28
28
  [x: string]: any;
29
29
  };
30
+ /**
31
+ * 如果是一个函数则执行它,否则直接返回该值
32
+ * @param func
33
+ * @param restParams
34
+ * @returns
35
+ */
36
+ export declare function runFunction<T extends any[]>(func: any, ...restParams: T): any;
37
+ /**
38
+ * 获取当前的路由类型
39
+ * @returns
40
+ */
41
+ export declare function getRouteType(): "history" | "hash";
@@ -1,51 +1,60 @@
1
- import { unref as s, markRaw as u } from "vue";
1
+ import { unref as f, markRaw as s } from "vue";
2
2
  import { isUndefined as a } from "lodash-unified";
3
- function m(t) {
3
+ function d(t) {
4
4
  return (t == null ? void 0 : t.parentNode) ?? document.body;
5
5
  }
6
6
  function p(t) {
7
7
  return typeof t < "u";
8
8
  }
9
- function d(t) {
9
+ function m(t) {
10
10
  const e = {};
11
11
  return Object.keys(t).map((n) => {
12
- e[n] = s(t[n]);
12
+ e[n] = f(t[n]);
13
13
  }), e;
14
14
  }
15
15
  function g(t, e = [], n) {
16
- const r = Object.assign({}, t), c = Object.keys(r);
17
- for (let o = 0; o < c.length; o += 1) {
18
- const i = c[o];
19
- (e.includes(i) || n != null && n(i, r[i])) && delete r[i];
16
+ const r = Object.assign({}, t), u = Object.keys(r);
17
+ for (let i = 0; i < u.length; i += 1) {
18
+ const o = u[i];
19
+ (e.includes(o) || n != null && n(o, r[o])) && delete r[o];
20
20
  }
21
21
  return r;
22
22
  }
23
23
  function k(t) {
24
24
  return /^[A-Z][A-Za-z]*$/.test(t);
25
25
  }
26
- function f(t) {
26
+ function c(t) {
27
27
  if (Array.isArray(t))
28
- return t.map((e) => f(e));
28
+ return t.map((e) => c(e));
29
29
  if (typeof t == "object" && t !== null) {
30
30
  const e = {};
31
31
  for (const n in t)
32
- e[n] = f(t[n]);
33
- return u(e);
32
+ e[n] = c(t[n]);
33
+ return s(e);
34
34
  }
35
35
  return t;
36
36
  }
37
- function O(t) {
37
+ function R(t) {
38
38
  const e = { ...t };
39
39
  for (const n of Object.keys(e))
40
40
  a(e[n]) && delete e[n];
41
41
  return e;
42
42
  }
43
+ function O(t, ...e) {
44
+ return typeof t == "function" ? t(...e) : t;
45
+ }
46
+ function A() {
47
+ const t = "history";
48
+ return typeof window > "u" ? t : window.location.href.includes("#/") ? "hash" : t;
49
+ }
43
50
  export {
44
- f as convertReactiveToRaw,
45
- d as getDynamicProps,
46
- m as getPopupContainer,
51
+ c as convertReactiveToRaw,
52
+ m as getDynamicProps,
53
+ d as getPopupContainer,
54
+ A as getRouteType,
47
55
  p as isDef,
48
56
  k as isPascalCase,
49
- O as omitUndefined,
50
- g as omitWhen
57
+ R as omitUndefined,
58
+ g as omitWhen,
59
+ O as runFunction
51
60
  };
@@ -1,5 +1,6 @@
1
1
  import { ApFormProps, RegistedFieldType, WatchFunc } from './interface';
2
2
  import { InternalNamePath, NamePath, ValidateOptions, FormLabelAlign, RuleObject, ValidateMessages, FieldData, ValidateErrorEntity } from '@aplus-frontend/antdv/es/form/interface';
3
+ import { Recordable } from '../type';
3
4
  import { CreateComponentPublicInstance, ExtractPropTypes, PropType, HTMLAttributes, ComponentOptionsMixin, VNodeProps, AllowedComponentProps, ComponentCustomProps, DefineComponent, PublicProps } from 'vue';
4
5
  import { VueTypeDef, VueTypeValidableDef } from '../../node_modules/vue-types';
5
6
  import { ColSize } from '@aplus-frontend/antdv/es/grid';
@@ -895,6 +896,7 @@ declare const __VLS_component: DefineComponent<__VLS_WithDefaults<__VLS_TypeProp
895
896
  labelAlign: string;
896
897
  validateOnRuleChange: boolean;
897
898
  validateTrigger: string;
899
+ syncToUrl: boolean;
898
900
  }>, {
899
901
  resetFields: () => Promise<void>;
900
902
  clearValidate: (name?: NamePath | NamePath[]) => void;
@@ -921,6 +923,7 @@ declare const __VLS_component: DefineComponent<__VLS_WithDefaults<__VLS_TypeProp
921
923
  labelAlign: string;
922
924
  validateOnRuleChange: boolean;
923
925
  validateTrigger: string;
926
+ syncToUrl: boolean;
924
927
  }>>>, {
925
928
  layout: string;
926
929
  colon: boolean;
@@ -928,6 +931,7 @@ declare const __VLS_component: DefineComponent<__VLS_WithDefaults<__VLS_TypeProp
928
931
  validateTrigger: string | string[];
929
932
  hideRequiredMark: boolean;
930
933
  validateOnRuleChange: boolean;
934
+ syncToUrl: boolean | ((values: Recordable, type: "get" | "set") => Recordable);
931
935
  }, {}>;
932
936
  declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
933
937
  export default _default;
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const a=require("vue"),S=require("@aplus-frontend/antdv"),W=require("./context.js"),n=require("lodash-unified"),m=require("./constant.js"),b=require("../utils/index.js"),z=require("./utils/set.js"),C=a.defineComponent({__name:"ap-form",props:{layout:{default:"horizontal"},labelCol:{},wrapperCol:{},colon:{type:Boolean,default:!0},labelAlign:{default:"right"},labelWrap:{type:Boolean},prefixCls:{},requiredMark:{},hideRequiredMark:{type:Boolean,default:!1},rules:{},validateMessages:{},validateOnRuleChange:{type:Boolean,default:!0},scrollToFirstError:{},onSubmit:{},name:{},validateTrigger:{default:"change"},size:{},disabled:{type:Boolean},onValuesChange:{},onFieldsChange:{},onFinish:{},onFinishFailed:{},onValidate:{},initialValues:{}},setup(O,{expose:R}){const u=O;function p(e,t,l=!0){var r;if(n.isArray(e)){let s=o;for(let d=0;d<e.length-1;d++)e[d]in s||(s[e[d]]={}),s=s[e[d]];s[e[e.length-1]]=t}else o[e]=t;let i=n.isArray(e)?e[0]:e;l&&((r=u.onValuesChange)==null||r.call(u,{[i]:o[i]},o)),g()}function T(e){var l;const t=v(e,F);(l=u.onFinish)==null||l.call(u,t)}const c=a.ref();let V=u.initialValues?n.cloneDeep(u.initialValues):{},F={};const o=a.reactive(u.initialValues||{});let h=[];const q=async()=>{var e;(e=c.value)==null||e.resetFields(),await a.nextTick(()=>{Object.keys(o).forEach(t=>delete o[t]),Object.assign(o,n.cloneDeep(V)),g()})},M=e=>{var t;(t=c.value)==null||t.clearValidate(e)},j=(e,t)=>{var l;return(l=c.value)==null?void 0:l.validateFields(e,t)},w=async(e,t)=>{var i;const l=await((i=c.value)==null?void 0:i.validateFields(e,t));return v(l,F)},B=e=>{var t;return(t=c.value)==null?void 0:t.getFieldsValue(e)},I=e=>{var l;const t=(l=c.value)==null?void 0:l.getFieldsValue(e);return v(t,F)},x=(e,t)=>{var l;return(l=c.value)==null?void 0:l.validate(e,t)},E=(e,t={})=>{var l;(l=c.value)==null||l.scrollToField(e,t)},P=e=>{Object.assign(o,e),g()},_=(e,t)=>{p(e,t),g()};function y(e,t){return t||e(a.toRaw(o)),h.push(e),()=>{h=h.filter(l=>l!==e)}}function A({initialValue:e,name:t,transform:l}){if(b.isDef(e)&&b.isDef(t))if(p(t,e,!1),n.isArray(t)){let i=V;for(let r=0;r<t.length-1;r++)b.isDef(i[t[r]])||(i[t[r]]={}),i=i[t[r]];i[t[t.length-1]]=e}else V[t]=e;l&&(F=z.default(F,[t].flat(1),l,!0))}function D(e){if(e!==m.INTERNAL_FORM_INSTANCE_MARK){console.warn("getInternalInstance should only used at internal");return}return{registerField:A,registerWatch:y}}function g(){if(h.length){const e=a.toRaw(o);h.forEach(t=>{t(e)})}}function v(e,t){if(e==null)return;let l=n.isArray(e)?[]:{};return Object.keys(e).forEach(i=>{const r=e[i],s=t==null?void 0:t[i],d=n.isFunction(s)?s:s==null?void 0:s.transformer,N=n.isFunction(s)?!0:s==null?void 0:s.flat;if(n.isFunction(d)){const f=d(r);N?n.isArray(f)&&n.isArray(l)?l=[...l,...f]:n.isPlainObject(f)&&n.isPlainObject(l)?l={...l,...f}:l[i]=f:l[i]=f}else if(n.isPlainObject(r)||n.isArray(r)){const f=v(r,s);l[i]=f}else l[i]=r}),l}return W.useProvideForm({model:a.computed(()=>o),updateModel:p,internalInstance:{registerWatch:y,registerField:A,setFieldValue:_}}),R({resetFields:q,clearValidate:M,validateFields:j,getFieldsValue:B,validate:x,scrollToField:E,setFieldsValue:P,setFieldValue:_,registerWatch:y,validateFieldsReturnTransformed:w,getFieldsValueTransformed:I,getInternalInstance:D}),(e,t)=>(a.openBlock(),a.createBlock(a.unref(S.Form),a.mergeProps({ref_key:"formRef",ref:c},a.unref(n.omit)(u,["initialValues","onValuesChange","onFinish"]),{onFinish:T,model:o}),{default:a.withCtx(()=>[a.renderSlot(e.$slots,"default")]),_:3},16,["model"]))}});exports.default=C;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const l=require("vue"),z=require("@aplus-frontend/antdv"),C=require("./context.js"),a=require("lodash-unified"),L=require("@vueuse/core"),$=require("./constant.js"),T=require("../utils/index.js"),k=require("./utils/set.js"),y=require("./utils/params.js"),K=l.defineComponent({__name:"ap-form",props:{layout:{default:"horizontal"},labelCol:{},wrapperCol:{},colon:{type:Boolean,default:!0},labelAlign:{default:"right"},labelWrap:{type:Boolean},prefixCls:{},requiredMark:{},hideRequiredMark:{type:Boolean,default:!1},rules:{},validateMessages:{},validateOnRuleChange:{type:Boolean,default:!0},scrollToFirstError:{},onSubmit:{},name:{},validateTrigger:{default:"change"},size:{},disabled:{type:Boolean},onValuesChange:{},onFieldsChange:{},onFinish:{},onFinishFailed:{},onValidate:{},initialValues:{},syncToUrl:{type:[Boolean,Function],default:!1},syncToUrlPriority:{type:Boolean}},setup(R,{expose:U}){const i=R;function V(e,t,s=!0){var o;if(a.isArray(e)){let n=u;for(let d=0;d<e.length-1;d++)e[d]in n||(n[e[d]]={}),n=n[e[d]];n[e[e.length-1]]=t}else u[e]=t;let r=a.isArray(e)?e[0]:e;s&&((o=i.onValuesChange)==null||o.call(i,{[r]:u[r]},u)),p()}const c=l.ref(),P=L.useUrlSearchParams(T.getRouteType()),_=l.ref(i.syncToUrl?y.genParams(i.syncToUrl,P,"get"):{});let v=a.cloneDeep(m()),F={};const u=l.reactive(m());let g=[];function m(){const e=i.initialValues||{};return i.syncToUrlPriority?{...e,...l.unref(_)}:{...l.unref(_),...e}}function M(e){var s;const t=h(e,F);i.syncToUrl&&y.setToParams(P,y.genParams(i.syncToUrl,t,"set")),(s=i.onFinish)==null||s.call(i,t)}const O=async()=>{var e;(e=c.value)==null||e.resetFields(),await l.nextTick(()=>{Object.keys(u).forEach(t=>delete u[t]),Object.assign(u,v),p(),i.syncToUrl&&y.setToParams(P,y.genParams(i.syncToUrl,h(v,F),"set"))})},B=e=>{var t;(t=c.value)==null||t.clearValidate(e)},I=(e,t)=>{var s;return(s=c.value)==null?void 0:s.validateFields(e,t)},j=async(e,t)=>{var r;const s=await((r=c.value)==null?void 0:r.validateFields(e,t));return h(s,F)},w=e=>{var t;return(t=c.value)==null?void 0:t.getFieldsValue(e)},x=e=>{var s;const t=(s=c.value)==null?void 0:s.getFieldsValue(e);return h(t,F)},E=(e,t)=>{var s;return(s=c.value)==null?void 0:s.validate(e,t)},S=(e,t={})=>{var s;(s=c.value)==null||s.scrollToField(e,t)},N=e=>{Object.assign(u,e),p()},q=(e,t)=>{V(e,t),p()};function b(e,t){return t||e(l.toRaw(u)),g.push(e),()=>{g=g.filter(s=>s!==e)}}function A({initialValue:e,name:t,transform:s}){if(T.isDef(e)&&T.isDef(t))if(V(t,e,!1),a.isArray(t)){let r=v;for(let o=0;o<t.length-1;o++)T.isDef(r[t[o]])||(r[t[o]]={}),r=r[t[o]];r[t[t.length-1]]=e}else v[t]=e;s&&(F=k.default(F,[t].flat(1),s,!0))}function D(e){if(e!==$.INTERNAL_FORM_INSTANCE_MARK){console.warn("getInternalInstance should only used at internal");return}return{registerField:A,registerWatch:b}}function p(){if(g.length){const e=l.toRaw(u);g.forEach(t=>{t(e)})}}function h(e,t){if(e==null)return;let s=a.isArray(e)?[]:{};return Object.keys(e).forEach(r=>{const o=e[r],n=t==null?void 0:t[r],d=a.isFunction(n)?n:n==null?void 0:n.transformer,W=a.isFunction(n)?!0:n==null?void 0:n.flat;if(a.isFunction(d)){const f=d(o);W?a.isArray(f)&&a.isArray(s)?s=[...s,...f]:a.isPlainObject(f)&&a.isPlainObject(s)?s={...s,...f}:s[r]=f:s[r]=f}else if(a.isPlainObject(o)||a.isArray(o)){const f=h(o,n);s[r]=f}else s[r]=o}),s}return C.useProvideForm({model:l.computed(()=>u),updateModel:V,internalInstance:{registerWatch:b,registerField:A,setFieldValue:q}}),U({resetFields:O,clearValidate:B,validateFields:I,getFieldsValue:w,validate:E,scrollToField:S,setFieldsValue:N,setFieldValue:q,registerWatch:b,validateFieldsReturnTransformed:j,getFieldsValueTransformed:x,getInternalInstance:D}),(e,t)=>(l.openBlock(),l.createBlock(l.unref(z.Form),l.mergeProps({ref_key:"formRef",ref:c},l.unref(a.omit)(i,["initialValues","onValuesChange","onFinish"]),{onFinish:M,model:u}),{default:l.withCtx(()=>[l.renderSlot(e.$slots,"default")]),_:3},16,["model"]))}});exports.default=K;
@@ -1,11 +1,11 @@
1
1
  import { ApFormDrawerFormProps, CustomizeResizeType } from '../interface';
2
2
  import { VNode, ComponentInternalInstance, ExtractPropTypes, PropType, HTMLAttributes, VNodeProps, AllowedComponentProps, ComponentCustomProps, Slot, ComponentPublicInstance, ComponentOptionsBase, ComponentOptionsMixin, DebuggerEvent, nextTick, WatchOptions, WatchStopHandle, ShallowUnwrapRef, ComponentCustomProperties, DefineComponent, PublicProps, CSSProperties } from 'vue';
3
3
  import { InternalNamePath, NamePath, ValidateOptions, FormLabelAlign, ValidateMessages, FieldData, ValidateErrorEntity } from '@aplus-frontend/antdv/es/form/interface';
4
+ import { Recordable } from '../../type';
4
5
  import { RequiredMark } from '@aplus-frontend/antdv/es/form/Form';
5
6
  import { ColSize } from '@aplus-frontend/antdv/es/grid';
6
7
  import { RuleObject } from '@aplus-frontend/antdv/es/form';
7
8
  import { Options } from '../../../node_modules/scroll-into-view-if-needed';
8
- import { Recordable } from '../../type';
9
9
  import { WatchFunc, RegistedFieldType, ApFormInternalInstance, ApFormSubmitterConfig } from '..';
10
10
  import { VueTypeValidableDef, VueTypeDef } from '../../../node_modules/vue-types';
11
11
  import { PushState } from '@aplus-frontend/antdv/es/drawer';
@@ -29,6 +29,7 @@ declare function __VLS_template(): {
29
29
  validateTrigger: string | string[];
30
30
  hideRequiredMark: boolean;
31
31
  validateOnRuleChange: boolean;
32
+ syncToUrl: boolean | ((values: Recordable, type: "get" | "set") => Recordable);
32
33
  }> & Omit<{
33
34
  readonly layout: string;
34
35
  readonly colon: boolean;
@@ -36,6 +37,7 @@ declare function __VLS_template(): {
36
37
  readonly validateTrigger: string | string[];
37
38
  readonly hideRequiredMark: boolean;
38
39
  readonly validateOnRuleChange: boolean;
40
+ readonly syncToUrl: boolean | ((values: Recordable, type: "get" | "set") => Recordable);
39
41
  readonly size?: "small" | "large" | "middle" | undefined;
40
42
  readonly onSubmit?: ((e: Event) => void) | undefined;
41
43
  readonly disabled?: boolean | undefined;
@@ -120,6 +122,7 @@ declare function __VLS_template(): {
120
122
  readonly onFinishFailed?: ((errorInfo: ValidateErrorEntity<any>) => void) | undefined;
121
123
  readonly onValidate?: ((name: string | number | string[] | number[], status: boolean, errors: string[]) => void) | undefined;
122
124
  readonly initialValues?: Recordable | undefined;
125
+ readonly syncToUrlPriority?: boolean | undefined;
123
126
  } & VNodeProps & AllowedComponentProps & ComponentCustomProps & Readonly< ExtractPropTypes<{
124
127
  size: {
125
128
  type: PropType<"small" | "large" | "middle">;
@@ -265,7 +268,14 @@ declare function __VLS_template(): {
265
268
  initialValues: {
266
269
  type: PropType<Recordable>;
267
270
  };
268
- }>>, "layout" | "colon" | "labelAlign" | "validateTrigger" | "hideRequiredMark" | "validateOnRuleChange">;
271
+ syncToUrl: {
272
+ type: PropType<boolean | ((values: Recordable, type: "get" | "set") => Recordable)>;
273
+ default: boolean;
274
+ };
275
+ syncToUrlPriority: {
276
+ type: PropType<boolean>;
277
+ };
278
+ }>>, "layout" | "colon" | "labelAlign" | "validateTrigger" | "hideRequiredMark" | "validateOnRuleChange" | "syncToUrl">;
269
279
  $attrs: {
270
280
  [x: string]: unknown;
271
281
  };
@@ -424,6 +434,13 @@ declare function __VLS_template(): {
424
434
  initialValues: {
425
435
  type: PropType<Recordable>;
426
436
  };
437
+ syncToUrl: {
438
+ type: PropType<boolean | ((values: Recordable, type: "get" | "set") => Recordable)>;
439
+ default: boolean;
440
+ };
441
+ syncToUrlPriority: {
442
+ type: PropType<boolean>;
443
+ };
427
444
  }>>, {
428
445
  resetFields: () => Promise<void>;
429
446
  clearValidate: (name?: NamePath | NamePath[]) => void;
@@ -453,6 +470,7 @@ declare function __VLS_template(): {
453
470
  validateTrigger: string | string[];
454
471
  hideRequiredMark: boolean;
455
472
  validateOnRuleChange: boolean;
473
+ syncToUrl: boolean | ((values: Recordable, type: "get" | "set") => Recordable);
456
474
  }, {}, string, {}> & {
457
475
  beforeCreate?: (() => void) | (() => void)[];
458
476
  created?: (() => void) | (() => void)[];
@@ -618,6 +636,13 @@ declare function __VLS_template(): {
618
636
  initialValues: {
619
637
  type: PropType<Recordable>;
620
638
  };
639
+ syncToUrl: {
640
+ type: PropType<boolean | ((values: Recordable, type: "get" | "set") => Recordable)>;
641
+ default: boolean;
642
+ };
643
+ syncToUrlPriority: {
644
+ type: PropType<boolean>;
645
+ };
621
646
  }>>, "validate" | "setFieldValue" | "setFieldsValue" | "resetFields" | "clearValidate" | "validateFields" | "getFieldsValue" | "scrollToField" | "getInternalInstance" | "validateFieldsReturnTransformed" | "getFieldsValueTransformed" | "registerWatch"> & ShallowUnwrapRef<{
622
647
  resetFields: () => Promise<void>;
623
648
  clearValidate: (name?: NamePath | NamePath[]) => void;
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("vue"),c=require("@aplus-frontend/antdv");require("../ap-form.vue.js");require("../../hooks/index.js");const j=require("../../utils/slot.js");require("../../config-provider/index.js");const g=require("lodash-unified"),E=require("../../utils/index.js"),U=require("../../hooks/useControllableValue.js"),D=require("../../config-provider/hooks/use-locale.js"),I=require("../../config-provider/hooks/use-namespace.js"),$=require("../ap-form.vue2.js");function k(f){return typeof f=="function"||Object.prototype.toString.call(f)==="[object Object]"&&!t.isVNode(f)}const A=t.defineComponent({__name:"index",props:{layout:{default:"horizontal"},labelCol:{},wrapperCol:{},colon:{type:Boolean,default:!0},labelAlign:{default:"right"},labelWrap:{type:Boolean},prefixCls:{},requiredMark:{},hideRequiredMark:{type:Boolean,default:!1},rules:{},validateMessages:{},validateOnRuleChange:{type:Boolean,default:!0},scrollToFirstError:{},onSubmit:{},name:{},validateTrigger:{default:"change"},size:{},disabled:{type:Boolean},onValuesChange:{},onFieldsChange:{},onFinishFailed:{},onValidate:{},initialValues:{},open:{type:Boolean,default:void 0},"onUpdate:open":{},drawerProps:{default:()=>({})},title:{},width:{default:378},onFinish:{},submitter:{type:[Boolean,Object],default:()=>({resetButtonProps:!1})},showCancel:{type:Boolean,default:!0},submitTimeout:{},resize:{type:[Object,Boolean],default:!1}},emits:["update:open"],setup(f,{expose:x,emit:N}){const o=f,v=t.useSlots(),T=N,a=t.ref(),p=t.ref(),u=t.ref(!1),{value:V,updateValue:h}=U.useControllableValue(o,T,{valuePropName:"open",defaultValue:!1}),d=t.computed(()=>{var n,i,r,s;const e={onResize:()=>{},minWidth:300,maxWidth:window.innerWidth*.8,resizeOnOpen:!0};return g.isBoolean(o.resize)?o.resize?e:{}:{minWidth:((n=o.resize)==null?void 0:n.minWidth)??e.minWidth,maxWidth:((i=o.resize)==null?void 0:i.maxWidth)??e.maxWidth,onResize:((r=o.resize)==null?void 0:r.onResize)??e.onResize,resizeOnOpen:g.isUndefined((s=o.resize)==null?void 0:s.resizeOnOpen)?e.onResize:o.resize.resizeOnOpen}}),m=t.ref(F()),{t:b}=D.useLocale(),{e:O,em:y}=I.useNamespace("ap-form-drawer-form"),_=t.computed(()=>[O("resize-bar"),{[y("resize-bar","min-disabled")]:t.unref(m)===t.unref(d).minWidth},{[y("resize-bar","max-disabled")]:t.unref(m)===t.unref(d).maxWidth}]);t.watch(()=>a.value,e=>{var n;e&&p.value&&((n=e.setFieldsValue)==null||n.call(e,p.value),p.value=void 0)}),t.watch(()=>t.unref(V),e=>{var n;e&&(n=t.unref(d))!=null&&n.resizeOnOpen&&(m.value=F())});function F(){var n;const e=(n=t.unref(d))==null?void 0:n.minWidth;return!e||e&&e<o.width?o.width:e}const C=j.getSingleVNode(v.trigger),w=C?t.cloneVNode(C,{onClick:()=>{h(!0)}}):null,P=t.computed(()=>{var n,i,r,s;const e=[];if(o.submitter===!1)return null;if(o.showCancel){let l;e.push(t.createVNode(c.Button,{onClick:W,disabled:u.value},k(l=b("ap.common.cancelText"))?l:{default:()=>[l]}))}return((n=o.submitter)==null?void 0:n.resetButtonProps)!==!1&&e.push(t.createVNode(c.Button,t.mergeProps(((i=o.submitter)==null?void 0:i.resetButtonProps)||{},{key:"submit",disabled:u.value,onClick:q}),{default:()=>{var l;return[((l=o.submitter)==null?void 0:l.resetText)||b("ap.common.resetText")]}})),((r=o.submitter)==null?void 0:r.submitButtonProps)!==!1&&e.push(t.createVNode(c.Button,t.mergeProps({type:"primary",key:"submit"},((s=o.submitter)==null?void 0:s.submitButtonProps)||{},{loading:u.value,onClick:S}),{default:()=>{var l;return[((l=o.submitter)==null?void 0:l.submitText)||b("ap.common.okText")]}})),t.createVNode(c.Flex,{justify:"flex-end"},{default:()=>[v.submitter?v.submitter(e):t.createVNode(c.Space,null,k(e)?e:{default:()=>[e]})]})});function R(){var e,n;(n=(e=d.value)==null?void 0:e.onResize)==null||n.call(e),document.addEventListener("mousemove",z),document.addEventListener("mouseup",B)}function z(e){const n=t.unref(d),i=(document.body.offsetWidth||1e3)-(e.clientX-document.body.offsetLeft),r=(n==null?void 0:n.minWidth)??(o.width||800),s=(n==null?void 0:n.maxWidth)??window.innerWidth*.8;let l=i;i<r&&(l=r),i>s&&(l=s),m.value=l}function B(){document.removeEventListener("mousemove",z),document.removeEventListener("mouseup",B)}function q(){var e,n,i;o.submitter!==!1&&((e=a.value)==null||e.resetFields(),(i=(n=o.submitter)==null?void 0:n.onReset)==null||i.call(n))}async function S(){var e,n,i,r;if(o.submitter!==!1)try{const s=await((e=a.value)==null?void 0:e.validateFields());(i=(n=o.submitter)==null?void 0:n.onSubmit)==null||i.call(n),u.value=!0;const l=(r=o.onFinish)==null?void 0:r.call(o,E.convertReactiveToRaw(s));if(o.submitTimeout&&l instanceof Promise){const L=setTimeout(()=>u.value=!1,o.submitTimeout);l.finally(()=>{clearTimeout(L),u.value=!1})}await l&&h(!1)}finally{u.value=!1}}function W(){t.unref(u)||h(!1)}function M(e){!e&&t.unref(u)||h(e)}return x({resetFields:()=>{var e;(e=a.value)==null||e.resetFields()},clearValidate:e=>{var n;(n=a.value)==null||n.clearValidate(e)},validateFields:(e,n)=>{var i;return(i=a.value)==null?void 0:i.validateFields(e,n)},getFieldsValue:e=>{var n;return(n=a.value)==null?void 0:n.getFieldsValue(e)},validate:(e,n)=>{var i;return(i=a.value)==null?void 0:i.validate(e,n)},scrollToField:(e,n={})=>{var i;(i=a.value)==null||i.scrollToField(e,n)},setFieldValue:(e,n)=>{var i,r;(r=(i=a.value)==null?void 0:i.setFieldValue)==null||r.call(i,e,n)},setFieldsValue:e=>{var n,i;if(!a.value){p.value=e;return}(i=(n=a.value)==null?void 0:n.setFieldsValue)==null||i.call(n,e)},getInternalInstance:e=>{var n;return(n=a.value)==null?void 0:n.getInternalInstance(e)}}),(e,n)=>(t.openBlock(),t.createElementBlock(t.Fragment,null,[t.createVNode(t.unref(c.Drawer),t.mergeProps(e.drawerProps,{open:t.unref(V),"onUpdate:open":M,onCancel:W,width:m.value}),{title:t.withCtx(()=>[t.renderSlot(e.$slots,"title",{},()=>[t.createTextVNode(t.toDisplayString(o.title),1)])]),footer:t.withCtx(()=>[(t.openBlock(),t.createBlock(t.resolveDynamicComponent(P.value)))]),default:t.withCtx(()=>[t.createVNode($.default,t.mergeProps({ref_key:"formRef",ref:a},t.unref(g.omit)(o,["drawerProps","open","onUpdate:open","title","width","onFinish","submitter"])),{default:t.withCtx(()=>[t.renderSlot(e.$slots,"default")]),_:3},16),e.resize?(t.openBlock(),t.createElementBlock("div",{key:0,class:t.normalizeClass(_.value),onMousedown:t.withModifiers(R,["stop","prevent"])},null,34)):t.createCommentVNode("",!0)]),_:3},16,["open","width"]),t.unref(w)?(t.openBlock(),t.createBlock(t.resolveDynamicComponent(t.unref(w)),{key:0})):t.createCommentVNode("",!0)],64))}});exports.default=A;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("vue"),c=require("@aplus-frontend/antdv");require("../ap-form.vue.js");require("../../hooks/index.js");const U=require("../../utils/slot.js");require("../../config-provider/index.js");const g=require("lodash-unified"),j=require("../../utils/index.js"),E=require("../../hooks/useControllableValue.js"),D=require("../../config-provider/hooks/use-locale.js"),I=require("../../config-provider/hooks/use-namespace.js"),$=require("../ap-form.vue2.js");function k(f){return typeof f=="function"||Object.prototype.toString.call(f)==="[object Object]"&&!t.isVNode(f)}const A=t.defineComponent({__name:"index",props:{layout:{default:"horizontal"},labelCol:{},wrapperCol:{},colon:{type:Boolean,default:!0},labelAlign:{default:"right"},labelWrap:{type:Boolean},prefixCls:{},requiredMark:{},hideRequiredMark:{type:Boolean,default:!1},rules:{},validateMessages:{},validateOnRuleChange:{type:Boolean,default:!0},scrollToFirstError:{},onSubmit:{},name:{},validateTrigger:{default:"change"},size:{},disabled:{type:Boolean},onValuesChange:{},onFieldsChange:{},onFinishFailed:{},onValidate:{},initialValues:{},syncToUrl:{type:[Boolean,Function]},syncToUrlPriority:{type:Boolean},open:{type:Boolean,default:void 0},"onUpdate:open":{},drawerProps:{default:()=>({})},title:{},width:{default:378},onFinish:{},submitter:{type:[Boolean,Object],default:()=>({resetButtonProps:!1})},showCancel:{type:Boolean,default:!0},submitTimeout:{},resize:{type:[Object,Boolean],default:!1}},emits:["update:open"],setup(f,{expose:x,emit:T}){const i=f,v=t.useSlots(),N=T,a=t.ref(),p=t.ref(),u=t.ref(!1),{value:y,updateValue:h}=E.useControllableValue(i,N,{valuePropName:"open",defaultValue:!1}),d=t.computed(()=>{var n,o,r,s;const e={onResize:()=>{},minWidth:300,maxWidth:window.innerWidth*.8,resizeOnOpen:!0};return g.isBoolean(i.resize)?i.resize?e:{}:{minWidth:((n=i.resize)==null?void 0:n.minWidth)??e.minWidth,maxWidth:((o=i.resize)==null?void 0:o.maxWidth)??e.maxWidth,onResize:((r=i.resize)==null?void 0:r.onResize)??e.onResize,resizeOnOpen:g.isUndefined((s=i.resize)==null?void 0:s.resizeOnOpen)?e.onResize:i.resize.resizeOnOpen}}),m=t.ref(F()),{t:b}=D.useLocale(),{e:O,em:V}=I.useNamespace("ap-form-drawer-form"),P=t.computed(()=>[O("resize-bar"),{[V("resize-bar","min-disabled")]:t.unref(m)===t.unref(d).minWidth},{[V("resize-bar","max-disabled")]:t.unref(m)===t.unref(d).maxWidth}]);t.watch(()=>a.value,e=>{var n;e&&p.value&&((n=e.setFieldsValue)==null||n.call(e,p.value),p.value=void 0)}),t.watch(()=>t.unref(y),e=>{var n;e&&(n=t.unref(d))!=null&&n.resizeOnOpen&&(m.value=F())});function F(){var n;const e=(n=t.unref(d))==null?void 0:n.minWidth;return!e||e&&e<i.width?i.width:e}const C=U.getSingleVNode(v.trigger),w=C?t.cloneVNode(C,{onClick:()=>{h(!0)}}):null,_=t.computed(()=>{var n,o,r,s;const e=[];if(i.submitter===!1)return null;if(i.showCancel){let l;e.push(t.createVNode(c.Button,{onClick:W,disabled:u.value},k(l=b("ap.common.cancelText"))?l:{default:()=>[l]}))}return((n=i.submitter)==null?void 0:n.resetButtonProps)!==!1&&e.push(t.createVNode(c.Button,t.mergeProps(((o=i.submitter)==null?void 0:o.resetButtonProps)||{},{key:"submit",disabled:u.value,onClick:q}),{default:()=>{var l;return[((l=i.submitter)==null?void 0:l.resetText)||b("ap.common.resetText")]}})),((r=i.submitter)==null?void 0:r.submitButtonProps)!==!1&&e.push(t.createVNode(c.Button,t.mergeProps({type:"primary",key:"submit"},((s=i.submitter)==null?void 0:s.submitButtonProps)||{},{loading:u.value,onClick:S}),{default:()=>{var l;return[((l=i.submitter)==null?void 0:l.submitText)||b("ap.common.okText")]}})),t.createVNode(c.Flex,{justify:"flex-end"},{default:()=>[v.submitter?v.submitter(e):t.createVNode(c.Space,null,k(e)?e:{default:()=>[e]})]})});function R(){var e,n;(n=(e=d.value)==null?void 0:e.onResize)==null||n.call(e),document.addEventListener("mousemove",B),document.addEventListener("mouseup",z)}function B(e){const n=t.unref(d),o=(document.body.offsetWidth||1e3)-(e.clientX-document.body.offsetLeft),r=(n==null?void 0:n.minWidth)??(i.width||800),s=(n==null?void 0:n.maxWidth)??window.innerWidth*.8;let l=o;o<r&&(l=r),o>s&&(l=s),m.value=l}function z(){document.removeEventListener("mousemove",B),document.removeEventListener("mouseup",z)}function q(){var e,n,o;i.submitter!==!1&&((e=a.value)==null||e.resetFields(),(o=(n=i.submitter)==null?void 0:n.onReset)==null||o.call(n))}async function S(){var e,n,o,r;if(i.submitter!==!1)try{const s=await((e=a.value)==null?void 0:e.validateFields());(o=(n=i.submitter)==null?void 0:n.onSubmit)==null||o.call(n),u.value=!0;const l=(r=i.onFinish)==null?void 0:r.call(i,j.convertReactiveToRaw(s));if(i.submitTimeout&&l instanceof Promise){const L=setTimeout(()=>u.value=!1,i.submitTimeout);l.finally(()=>{clearTimeout(L),u.value=!1})}await l&&h(!1)}finally{u.value=!1}}function W(){t.unref(u)||h(!1)}function M(e){!e&&t.unref(u)||h(e)}return x({resetFields:()=>{var e;(e=a.value)==null||e.resetFields()},clearValidate:e=>{var n;(n=a.value)==null||n.clearValidate(e)},validateFields:(e,n)=>{var o;return(o=a.value)==null?void 0:o.validateFields(e,n)},getFieldsValue:e=>{var n;return(n=a.value)==null?void 0:n.getFieldsValue(e)},validate:(e,n)=>{var o;return(o=a.value)==null?void 0:o.validate(e,n)},scrollToField:(e,n={})=>{var o;(o=a.value)==null||o.scrollToField(e,n)},setFieldValue:(e,n)=>{var o,r;(r=(o=a.value)==null?void 0:o.setFieldValue)==null||r.call(o,e,n)},setFieldsValue:e=>{var n,o;if(!a.value){p.value=e;return}(o=(n=a.value)==null?void 0:n.setFieldsValue)==null||o.call(n,e)},getInternalInstance:e=>{var n;return(n=a.value)==null?void 0:n.getInternalInstance(e)}}),(e,n)=>(t.openBlock(),t.createElementBlock(t.Fragment,null,[t.createVNode(t.unref(c.Drawer),t.mergeProps(e.drawerProps,{open:t.unref(y),"onUpdate:open":M,onCancel:W,width:m.value}),{title:t.withCtx(()=>[t.renderSlot(e.$slots,"title",{},()=>[t.createTextVNode(t.toDisplayString(i.title),1)])]),footer:t.withCtx(()=>[(t.openBlock(),t.createBlock(t.resolveDynamicComponent(_.value)))]),default:t.withCtx(()=>[t.createVNode($.default,t.mergeProps({ref_key:"formRef",ref:a},t.unref(g.omit)(i,["drawerProps","open","onUpdate:open","title","width","onFinish","submitter"])),{default:t.withCtx(()=>[t.renderSlot(e.$slots,"default")]),_:3},16),e.resize?(t.openBlock(),t.createElementBlock("div",{key:0,class:t.normalizeClass(P.value),onMousedown:t.withModifiers(R,["stop","prevent"])},null,34)):t.createCommentVNode("",!0)]),_:3},16,["open","width"]),t.unref(w)?(t.openBlock(),t.createBlock(t.resolveDynamicComponent(t.unref(w)),{key:0})):t.createCommentVNode("",!0)],64))}});exports.default=A;
@@ -46,6 +46,14 @@ export type ApFormProps = Omit<FormProps, 'model'> & {
46
46
  * @returns
47
47
  */
48
48
  onValuesChange?: (changedValues: Recordable, allValues: Recordable) => void;
49
+ /**
50
+ * 同步表单数据到url中
51
+ */
52
+ syncToUrl?: boolean | ((values: Recordable, type: 'get' | 'set') => Recordable);
53
+ /**
54
+ * syncToUrl和initialValues合并是否优先,默认为false
55
+ */
56
+ syncToUrlPriority?: boolean;
49
57
  };
50
58
  export type WatchFunc = (values?: Recordable) => void;
51
59
  export type ApFormExpose<ModelType = any> = {