@done-coding/admin-core 0.9.0 → 0.10.0

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 (58) hide show
  1. package/docs/nested-config-paradigm.md +80 -0
  2. package/es/bridge/theme.mjs +41 -38
  3. package/es/components/app-layout/AppTheme.vue.mjs +2 -2
  4. package/es/components/app-layout/AppTheme.vue2.mjs +19 -19
  5. package/es/components/form/FormItemNestForm.vue.mjs +7 -0
  6. package/es/components/form/FormItemNestForm.vue2.mjs +49 -0
  7. package/es/components/form/FormItemNestFormList.vue.mjs +7 -0
  8. package/es/components/form/FormItemNestFormList.vue2.mjs +137 -0
  9. package/es/components/form/FormMain.vue.mjs +5 -140
  10. package/es/components/form/FormMain.vue2.mjs +160 -2
  11. package/es/components/form/FormSearch.vue.mjs +2 -2
  12. package/es/components/form/FormSearch.vue2.mjs +43 -42
  13. package/es/components/form/FormSubmitPanel.vue2.mjs +21 -20
  14. package/es/components/form/nest-form-item-list.mjs +71 -0
  15. package/es/components/form/nest-form-item.mjs +42 -0
  16. package/es/components/form/nest-registry.mjs +7 -0
  17. package/es/components/form/use-nest-form-list.mjs +22 -0
  18. package/es/components/form/use-nest-form.mjs +34 -0
  19. package/es/components/form/use-nest-layout-scale.mjs +14 -0
  20. package/es/components/form/utils.mjs +77 -61
  21. package/es/components/modal/ConfirmModal.vue.mjs +1 -2
  22. package/es/components/modal/ConfirmModal.vue2.mjs +73 -94
  23. package/es/components/modal/DetailModal.vue.mjs +6 -6
  24. package/es/components/panel/PanelItemNestForm.vue.mjs +7 -0
  25. package/es/components/panel/PanelItemNestForm.vue2.mjs +69 -0
  26. package/es/components/panel/PanelItemNestPanel.vue.mjs +34 -0
  27. package/es/components/panel/PanelItemNestPanel.vue2.mjs +4 -0
  28. package/es/components/panel/PanelMain.vue.mjs +2 -2
  29. package/es/components/panel/PanelMain.vue2.mjs +52 -45
  30. package/es/components/panel/nest-panel-form.mjs +53 -0
  31. package/es/components/panel/nest-panel-item.mjs +25 -0
  32. package/es/index.mjs +182 -153
  33. package/es/inject/key.mjs +12 -6
  34. package/es/style.css +1 -1
  35. package/package.json +2 -2
  36. package/types/bridge/index.d.ts +3 -3
  37. package/types/bridge/theme.d.ts +22 -3
  38. package/types/components/form/FormItemNestForm.vue.d.ts +36 -0
  39. package/types/components/form/FormItemNestFormList.vue.d.ts +63 -0
  40. package/types/components/form/FormMain.vue.d.ts +2 -2
  41. package/types/components/form/FormSearch.vue.d.ts +2 -2
  42. package/types/components/form/index.d.ts +9 -1
  43. package/types/components/form/nest-form-item-list.d.ts +63 -0
  44. package/types/components/form/nest-form-item.d.ts +36 -0
  45. package/types/components/form/nest-registry.d.ts +22 -0
  46. package/types/components/form/types.d.ts +2 -0
  47. package/types/components/form/use-nest-form-list.d.ts +20 -0
  48. package/types/components/form/use-nest-form.d.ts +26 -0
  49. package/types/components/form/use-nest-layout-scale.d.ts +17 -0
  50. package/types/components/form/utils.d.ts +26 -1
  51. package/types/components/panel/PanelItemNestForm.vue.d.ts +35 -0
  52. package/types/components/panel/PanelItemNestPanel.vue.d.ts +22 -0
  53. package/types/components/panel/index.d.ts +5 -1
  54. package/types/components/panel/nest-panel-form.d.ts +38 -0
  55. package/types/components/panel/nest-panel-item.d.ts +28 -0
  56. package/types/components/panel/types.d.ts +2 -0
  57. package/types/components/table/TableMain.vue.d.ts +2 -2
  58. package/types/inject/key.d.ts +28 -1
@@ -1,4 +1,162 @@
1
- import f from "./FormMain.vue.mjs";
1
+ import { defineComponent as Y, shallowRef as B, provide as p, computed as o, ref as L, watch as b, openBlock as E, createBlock as V, unref as F, withCtx as v, createVNode as j, createElementBlock as H, Fragment as U, renderList as q, withDirectives as z, mergeProps as x, renderSlot as R, vShow as J } from "vue";
2
+ import { ElForm as Q, ElRow as W, ElCol as X } from "element-plus";
3
+ import Z from "./FormItem.vue.mjs";
4
+ import { FORM_ITEM_CHANGE_LOADING as ee, stringifyFormData as te, parseFormData as le, generateFormData as ae, resolveFormLayout as M } from "./utils.mjs";
5
+ import { createNestFormExposeMap as re } from "./nest-registry.mjs";
6
+ import { FORM_NEST_REGISTRY_KEY as oe, NEST_LAYOUT_SCALE_KEY as se } from "../../inject/key.mjs";
7
+ const pe = /* @__PURE__ */ Y({
8
+ name: "FormMain",
9
+ inheritAttrs: !0,
10
+ __name: "FormMain",
11
+ props: {
12
+ list: {},
13
+ data: {},
14
+ layout: {},
15
+ rowGutter: { default: 8 },
16
+ layoutScale: { default: 1 }
17
+ },
18
+ emits: ["loadingChange", "visibleChange", "submit"],
19
+ setup(d, { expose: K, emit: N }) {
20
+ const r = d, y = N, s = B(), f = re();
21
+ p(oe, f);
22
+ const A = o(() => r.layoutScale ?? 1);
23
+ p(se, A);
24
+ const n = L([]), i = L({}), w = o(() => !!n.value.length), g = o(() => Object.keys(i.value).filter(
25
+ (e) => i.value[e]
26
+ )), D = o(() => r.list.filter((e) => !g.value.includes(e.key))), G = o(() => D.value.length > 0), I = (e) => e;
27
+ K({
28
+ validate: async () => {
29
+ if (!s.value) return Promise.reject(new Error("实例化未完成"));
30
+ const e = new Promise((l, a) => {
31
+ var u;
32
+ (u = s.value) == null || u.validate((P, C) => {
33
+ if (P)
34
+ l();
35
+ else {
36
+ const m = { ...C || {} };
37
+ Object.keys(m).forEach((c) => {
38
+ var _;
39
+ g.value.includes(c) && (console.log(`当前${c}被隐藏,移除校验`, m[c]), delete m[c], (_ = s.value) == null || _.clearValidate(c));
40
+ }), Object.keys(m).length === 0 ? l() : a(C);
41
+ }
42
+ });
43
+ }), t = Object.entries(f).filter(([l]) => !g.value.includes(l)).map(([, l]) => l.validate());
44
+ await Promise.all([e, ...t]);
45
+ },
46
+ resetFields: () => {
47
+ if (!s.value) return console.error("实例化未完成");
48
+ s.value.resetFields(), Object.values(f).forEach((e) => e.resetFields());
49
+ },
50
+ clearValidate: (e) => {
51
+ if (!s.value) return console.error("实例化未完成");
52
+ s.value.clearValidate(e), Object.values(f).forEach((t) => t.clearValidate());
53
+ },
54
+ generate: () => ae(r.list),
55
+ parse: (e) => le(e, r.list),
56
+ stringify: () => te(r.data, r.list)
57
+ });
58
+ const h = o(() => r.list), S = o(() => h.value.reduce((e, t) => (t.rules && (typeof t.rules == "function" ? e[t.key] = t.rules({
59
+ data: r.data,
60
+ config: t
61
+ }) : e[t.key] = t.rules), e), {})), k = o(() => n.value.reduce(
62
+ (e, t) => (e[t.key] = [
63
+ {
64
+ validator: () => [new Error(`${t.label}${t.message}`)]
65
+ }
66
+ ], e),
67
+ {}
68
+ )), T = o(() => {
69
+ const e = Object.keys(S.value), t = Object.keys(k.value);
70
+ return [...new Set(e.concat(t))].reduce((a, u) => (a[u] = [
71
+ ...S.value[u] || [],
72
+ ...k.value[u] || []
73
+ ], a), {});
74
+ });
75
+ p(ee, ({ key: e, message: t }) => {
76
+ if (!e)
77
+ return console.error("更新状态未传入key, 此处忽略");
78
+ const l = n.value.findIndex((a) => a.key === e);
79
+ l === -1 ? t && n.value.push({
80
+ key: e,
81
+ message: t,
82
+ label: r.list.find((a) => a.key === e).label
83
+ }) : t ? n.value.splice(l, 1, {
84
+ key: e,
85
+ message: t,
86
+ label: r.list.find((a) => a.key === e).label
87
+ }) : n.value.splice(l, 1);
88
+ });
89
+ const $ = ({
90
+ status: e,
91
+ config: { key: t }
92
+ }) => {
93
+ (i.value[t] || !1) !== e && (i.value[t] = e);
94
+ }, O = (e) => {
95
+ const t = r.layoutScale ?? 1;
96
+ return {
97
+ ...M(r.layout, t),
98
+ ...M(e, t)
99
+ };
100
+ };
101
+ return b(
102
+ h,
103
+ (e) => {
104
+ const t = e.map((l) => l.key);
105
+ Object.keys(i.value).forEach((l) => {
106
+ t.includes(l) || delete i.value[l];
107
+ });
108
+ },
109
+ {
110
+ immediate: !0
111
+ }
112
+ ), b(w, () => {
113
+ y("loadingChange", w.value);
114
+ }), b(
115
+ G,
116
+ (e) => {
117
+ y("visibleChange", e);
118
+ },
119
+ {
120
+ immediate: !0
121
+ }
122
+ ), (e, t) => (E(), V(F(Q), {
123
+ ref_key: "elForm",
124
+ ref: s,
125
+ model: d.data,
126
+ rules: T.value
127
+ }, {
128
+ default: v(() => [
129
+ j(F(W), { gutter: d.rowGutter }, {
130
+ default: v(() => [
131
+ (E(!0), H(U, null, q(h.value, (l) => z((E(), V(F(X), x({
132
+ key: l.key
133
+ }, { ref_for: !0 }, O(l.layout)), {
134
+ default: v(() => [
135
+ j(Z, {
136
+ data: d.data,
137
+ config: I(l),
138
+ onViewHideChange: $,
139
+ onSubmit: t[0] || (t[0] = (a) => y("submit", a))
140
+ }, {
141
+ default: v((a) => [
142
+ R(e.$slots, l.key, x({ ref_for: !0 }, a), void 0, !0)
143
+ ]),
144
+ _: 2
145
+ }, 1032, ["data", "config"])
146
+ ]),
147
+ _: 2
148
+ }, 1040)), [
149
+ [J, !(i.value[l.key] ?? !1)]
150
+ ])), 128)),
151
+ R(e.$slots, "default", { mergeLayout: O }, void 0, !0)
152
+ ]),
153
+ _: 3
154
+ }, 8, ["gutter"])
155
+ ]),
156
+ _: 3
157
+ }, 8, ["model", "rules"]));
158
+ }
159
+ });
2
160
  export {
3
- f as default
161
+ pe as default
4
162
  };
@@ -1,7 +1,7 @@
1
1
  import o from "./FormSearch.vue2.mjs";
2
2
  /* empty css */
3
3
  import r from "../../_virtual/_plugin-vue_export-helper.mjs";
4
- const f = /* @__PURE__ */ r(o, [["__scopeId", "data-v-72f1475d"]]);
4
+ const m = /* @__PURE__ */ r(o, [["__scopeId", "data-v-9a9f48af"]]);
5
5
  export {
6
- f as default
6
+ m as default
7
7
  };
@@ -1,9 +1,9 @@
1
- import { defineComponent as z, useAttrs as G, ref as x, computed as i, shallowRef as L, openBlock as d, createBlock as f, normalizeClass as T, withCtx as a, withDirectives as _, createVNode as m, mergeProps as H, unref as s, createSlots as U, normalizeProps as k, guardReactiveProps as R, createElementVNode as j, createTextVNode as w, toDisplayString as q, createCommentVNode as J, renderList as K, renderSlot as O, vShow as X } from "vue";
2
- import { stringifyFormData as Y } from "./utils.mjs";
3
- import { getCurrentSpan as Z, computeButtonColProps as ee, computeItemsPerRow as te } from "./form-search-utils.mjs";
1
+ import { defineComponent as z, useAttrs as G, ref as x, computed as i, shallowRef as L, openBlock as d, createBlock as f, normalizeClass as T, withCtx as a, withDirectives as H, createVNode as m, mergeProps as U, unref as l, createSlots as j, normalizeProps as S, guardReactiveProps as k, createElementVNode as q, createTextVNode as w, toDisplayString as J, createCommentVNode as K, renderList as O, renderSlot as X, vShow as Y } from "vue";
2
+ import { stringifyFormData as Z } from "./utils.mjs";
3
+ import { getCurrentSpan as _, computeButtonColProps as ee, computeItemsPerRow as te } from "./form-search-utils.mjs";
4
4
  import { ElCol as oe, ElButton as g, ElIcon as re } from "element-plus";
5
- import { ArrowDown as ae, ArrowUp as se } from "@element-plus/icons-vue";
6
- import le from "./FormMain.vue.mjs";
5
+ import { ArrowDown as ae, ArrowUp as le } from "@element-plus/icons-vue";
6
+ import se from "./FormMain.vue.mjs";
7
7
  import ne from "../display/WatchSize.vue.mjs";
8
8
  import { useBreakpoint as ie } from "../../hooks/use-breakpoint.mjs";
9
9
  const ue = { class: "btn-box" }, ge = /* @__PURE__ */ z({
@@ -24,35 +24,36 @@ const ue = { class: "btn-box" }, ge = /* @__PURE__ */ z({
24
24
  lg: 8,
25
25
  xl: 6
26
26
  }) },
27
- rowGutter: {}
27
+ rowGutter: {},
28
+ layoutScale: {}
28
29
  },
29
30
  emits: ["search", "heightChange", "visibleChange"],
30
- setup(u, { expose: S, emit: P }) {
31
- const o = u, c = P, F = G(), h = x(!1), { activeBreakpoint: B } = ie(), l = x(!0), V = i(() => o.data), v = i(() => {
31
+ setup(u, { expose: R, emit: P }) {
32
+ const o = u, c = P, F = G(), h = x(!1), { activeBreakpoint: B } = ie(), s = x(!0), M = i(() => o.data), v = i(() => {
32
33
  if (o.maxRows <= 0) return 1 / 0;
33
- const e = Z(o.layout, B.value), t = te(e), r = t > 1 ? 1 : 0;
34
+ const e = _(o.layout, B.value), t = te(e), r = t > 1 ? 1 : 0;
34
35
  return Math.max(0, o.maxRows * t - r);
35
- }), E = i(() => o.maxRows <= 0 ? !1 : o.list.filter(
36
+ }), V = i(() => o.maxRows <= 0 ? !1 : o.list.filter(
36
37
  (t) => t.hide !== !0
37
- ).length > v.value), M = i(() => {
38
+ ).length > v.value), E = i(() => {
38
39
  let e = 0;
39
40
  for (let t = 0; t < o.list.length; t++)
40
- o.list[t].hide !== !0 && (l.value && o.maxRows > 0 && t >= v.value || e++);
41
+ o.list[t].hide !== !0 && (s.value && o.maxRows > 0 && t >= v.value || e++);
41
42
  return e;
42
- }), D = i(() => ee(o.layout, M.value)), I = i(() => {
43
- if (!l.value || o.maxRows <= 0)
43
+ }), D = i(() => ee(o.layout, E.value)), I = i(() => {
44
+ if (!s.value || o.maxRows <= 0)
44
45
  return o.list;
45
46
  const e = v.value;
46
47
  return o.list.map(
47
48
  (t, r) => r >= e ? { ...t, hide: !0 } : t
48
49
  );
49
- }), y = (e = !l.value) => {
50
- l.value = e;
51
- }, $ = (e) => {
50
+ }), y = (e = !s.value) => {
51
+ s.value = e;
52
+ }, A = (e) => {
52
53
  c("heightChange", e);
53
54
  }, n = L(), b = (e) => ({
54
55
  ...o.staticQuery || {},
55
- ...Y(e, o.list)
56
+ ...Z(e, o.list)
56
57
  }), C = () => {
57
58
  var e;
58
59
  (e = n.value) == null || e.resetFields(), c("search", b(o.data), "reset");
@@ -61,9 +62,9 @@ const ue = { class: "btn-box" }, ge = /* @__PURE__ */ z({
61
62
  (t = n.value) == null || t.validate().then(() => {
62
63
  c("search", b(o.data), e);
63
64
  });
64
- }, A = (e) => {
65
+ }, N = (e) => {
65
66
  p(e);
66
- }, N = {
67
+ }, W = {
67
68
  validate: () => {
68
69
  if (n.value)
69
70
  return n.value.validate();
@@ -80,54 +81,54 @@ const ue = { class: "btn-box" }, ge = /* @__PURE__ */ z({
80
81
  triggerReset: C,
81
82
  triggerSearch: () => p(),
82
83
  toggleCollapse: y,
83
- isCollapsed: i(() => l.value)
84
+ isCollapsed: i(() => s.value)
84
85
  };
85
- S(N);
86
- const W = (e) => {
86
+ R(W);
87
+ const $ = (e) => {
87
88
  h.value = e, c("visibleChange", e);
88
89
  };
89
90
  return (e, t) => (d(), f(ne, {
90
91
  class: T(["form-search", {
91
92
  "form-search_show": h.value
92
93
  }]),
93
- onHeightChange: $
94
+ onHeightChange: A
94
95
  }, {
95
96
  default: a(() => [
96
- _(m(le, H({
97
+ H(m(se, U({
97
98
  ref_key: "formMain",
98
99
  ref: n,
99
100
  list: I.value,
100
- data: V.value,
101
+ data: M.value,
101
102
  "row-gutter": u.rowGutter
102
- }, s(F), {
103
+ }, l(F), {
103
104
  layout: u.layout,
104
105
  labelPosition: u.labelPosition,
105
106
  labelWidth: u.labelWidth,
106
- onSubmit: A,
107
- onVisibleChange: W
108
- }), U({
107
+ onSubmit: N,
108
+ onVisibleChange: $
109
+ }), j({
109
110
  default: a(() => [
110
- m(s(oe), k(R(D.value)), {
111
+ m(l(oe), S(k(D.value)), {
111
112
  default: a(() => [
112
- j("div", ue, [
113
- E.value ? (d(), f(s(g), {
113
+ q("div", ue, [
114
+ V.value ? (d(), f(l(g), {
114
115
  key: 0,
115
116
  type: "primary",
116
117
  link: "",
117
118
  onMousedown: t[0] || (t[0] = (r) => y())
118
119
  }, {
119
120
  default: a(() => [
120
- m(s(re), { class: "btn-box-expand-icon" }, {
121
+ m(l(re), { class: "btn-box-expand-icon" }, {
121
122
  default: a(() => [
122
- l.value ? (d(), f(s(ae), { key: 0 })) : (d(), f(s(se), { key: 1 }))
123
+ s.value ? (d(), f(l(ae), { key: 0 })) : (d(), f(l(le), { key: 1 }))
123
124
  ]),
124
125
  _: 1
125
126
  }),
126
- w(" " + q(l.value ? "展开更多" : "收起更多"), 1)
127
+ w(" " + J(s.value ? "展开更多" : "收起更多"), 1)
127
128
  ]),
128
129
  _: 1
129
- })) : J("", !0),
130
- m(s(g), {
130
+ })) : K("", !0),
131
+ m(l(g), {
131
132
  type: "warning",
132
133
  onMousedown: C
133
134
  }, {
@@ -136,7 +137,7 @@ const ue = { class: "btn-box" }, ge = /* @__PURE__ */ z({
136
137
  ])]),
137
138
  _: 1
138
139
  }),
139
- m(s(g), {
140
+ m(l(g), {
140
141
  type: "primary",
141
142
  onMousedown: t[1] || (t[1] = (r) => p())
142
143
  }, {
@@ -152,14 +153,14 @@ const ue = { class: "btn-box" }, ge = /* @__PURE__ */ z({
152
153
  ]),
153
154
  _: 2
154
155
  }, [
155
- K(u.list, (r) => ({
156
+ O(u.list, (r) => ({
156
157
  name: r.key,
157
158
  fn: a((Q) => [
158
- O(e.$slots, r.key, k(R(Q)), void 0, !0)
159
+ X(e.$slots, r.key, S(k(Q)), void 0, !0)
159
160
  ])
160
161
  }))
161
162
  ]), 1040, ["list", "data", "row-gutter", "layout", "labelPosition", "labelWidth"]), [
162
- [X, h.value]
163
+ [Y, h.value]
163
164
  ])
164
165
  ]),
165
166
  _: 3
@@ -1,11 +1,11 @@
1
- import { defineComponent as E, useAttrs as M, shallowRef as R, ref as T, computed as r, watch as P, openBlock as n, createElementBlock as j, normalizeClass as z, createVNode as G, mergeProps as c, unref as i, createSlots as H, renderList as I, withCtx as l, renderSlot as m, normalizeProps as L, guardReactiveProps as O, createBlock as u, resolveDynamicComponent as q, createElementVNode as J, createTextVNode as h, toDisplayString as C, createCommentVNode as D } from "vue";
1
+ import { defineComponent as W, useAttrs as E, shallowRef as R, ref as T, computed as r, watch as F, openBlock as n, createElementBlock as j, normalizeClass as z, createVNode as G, mergeProps as c, unref as i, createSlots as H, renderList as I, withCtx as l, renderSlot as m, normalizeProps as L, guardReactiveProps as O, createBlock as u, resolveDynamicComponent as q, createElementVNode as J, createTextVNode as P, toDisplayString as S, createCommentVNode as h } from "vue";
2
2
  import { ElAffix as K } from "element-plus";
3
3
  import Q from "./FormMain.vue.mjs";
4
4
  import U from "./FormSubmitBtn.vue.mjs";
5
5
  import { useFormSubmit as X } from "./use-form-submit.mjs";
6
- import F from "../display/ActionBtn.vue.mjs";
6
+ import C from "../display/ActionBtn.vue.mjs";
7
7
  import { parseFormData as Y, generateFormData as Z } from "./utils.mjs";
8
- const _ = { class: "form-submit-panel-operation-inner" }, lt = /* @__PURE__ */ E({
8
+ const _ = { class: "form-submit-panel-operation-inner" }, lt = /* @__PURE__ */ W({
9
9
  name: "FormSubmitPanel",
10
10
  inheritAttrs: !1,
11
11
  __name: "FormSubmitPanel",
@@ -15,6 +15,7 @@ const _ = { class: "form-submit-panel-operation-inner" }, lt = /* @__PURE__ */ E
15
15
  span: 24
16
16
  }) },
17
17
  rowGutter: {},
18
+ layoutScale: {},
18
19
  stringifyData: {},
19
20
  submitText: {},
20
21
  submitFn: {},
@@ -30,8 +31,8 @@ const _ = { class: "form-submit-panel-operation-inner" }, lt = /* @__PURE__ */ E
30
31
  rootClass: {}
31
32
  },
32
33
  emits: ["cancel", "fail", "success", "parseDataChange"],
33
- setup(a, { emit: S }) {
34
- const t = a, o = S, k = M(), f = R(), s = T({}), x = (e) => e, b = r(() => f.value), $ = r(() => t.operationAffix ? K : "div"), w = r(() => t.operationAffix ? typeof t.operationAffix == "object" ? t.operationAffix : { position: "bottom" } : {}), A = r(() => [
34
+ setup(a, { emit: D }) {
35
+ const t = a, o = D, k = E(), f = R(), s = T({}), x = (e) => e, b = r(() => f.value), w = r(() => t.operationAffix ? K : "div"), A = r(() => t.operationAffix ? typeof t.operationAffix == "object" ? t.operationAffix : { position: "bottom" } : {}), $ = r(() => [
35
36
  `form-submit-panel_${t.operationPosition}`,
36
37
  {
37
38
  "form-submit-panel_no-divider": !t.divider,
@@ -40,15 +41,15 @@ const _ = { class: "form-submit-panel-operation-inner" }, lt = /* @__PURE__ */ E
40
41
  t.rootClass
41
42
  ]), d = () => t.stringifyData ? Y(t.stringifyData, t.list) : Z(t.list), p = () => o("cancel"), y = () => {
42
43
  s.value = d();
43
- }, B = (e) => o("success", e), v = (e) => o("fail", e), { submitting: N, submit: V } = X({
44
+ }, B = (e) => o("success", e), v = (e) => o("fail", e), { submitting: M, submit: N } = X({
44
45
  getFormMainInstance: () => b.value,
45
46
  submitFn: (e) => t.submitFn(e),
46
47
  onSuccess: B,
47
48
  onFail: v
48
49
  });
49
- return P(s, (e) => {
50
+ return F(s, (e) => {
50
51
  o("parseDataChange", e);
51
- }), P(
52
+ }), F(
52
53
  [() => t.stringifyData, () => t.list],
53
54
  () => {
54
55
  s.value = d();
@@ -57,7 +58,7 @@ const _ = { class: "form-submit-panel-operation-inner" }, lt = /* @__PURE__ */ E
57
58
  immediate: !0
58
59
  }
59
60
  ), (e, tt) => (n(), j("div", {
60
- class: z(["form-submit-panel", A.value])
61
+ class: z(["form-submit-panel", $.value])
61
62
  }, [
62
63
  G(Q, c({
63
64
  ref_key: "formMain",
@@ -73,41 +74,41 @@ const _ = { class: "form-submit-panel-operation-inner" }, lt = /* @__PURE__ */ E
73
74
  }), H({ _: 2 }, [
74
75
  I(a.list, (g) => ({
75
76
  name: g.key,
76
- fn: l((W) => [
77
- m(e.$slots, g.key, L(O(W)), void 0, !0)
77
+ fn: l((V) => [
78
+ m(e.$slots, g.key, L(O(V)), void 0, !0)
78
79
  ])
79
80
  }))
80
81
  ]), 1040, ["list", "data", "row-gutter", "layout", "labelPosition", "labelWidth"]),
81
- (n(), u(q($.value), c(w.value, { class: "form-submit-panel-operation" }), {
82
+ (n(), u(q(w.value), c(A.value, { class: "form-submit-panel-operation" }), {
82
83
  default: l(() => [
83
84
  J("div", _, [
84
85
  m(e.$slots, "cancelBtn", { cancel: p }, () => [
85
- a.cancelBtn ? (n(), u(i(F), {
86
+ a.cancelBtn ? (n(), u(i(C), {
86
87
  key: 0,
87
88
  onClick: p
88
89
  }, {
89
90
  default: l(() => [
90
- h(C(a.cancelBtn), 1)
91
+ P(S(a.cancelBtn), 1)
91
92
  ]),
92
93
  _: 1
93
- })) : D("", !0)
94
+ })) : h("", !0)
94
95
  ], !0),
95
96
  m(e.$slots, "resetBtn", { reset: y }, () => [
96
- a.resetBtn ? (n(), u(i(F), {
97
+ a.resetBtn ? (n(), u(i(C), {
97
98
  key: 0,
98
99
  type: "warning",
99
100
  onClick: y
100
101
  }, {
101
102
  default: l(() => [
102
- h(C(a.resetBtn), 1)
103
+ P(S(a.resetBtn), 1)
103
104
  ]),
104
105
  _: 1
105
- })) : D("", !0)
106
+ })) : h("", !0)
106
107
  ], !0),
107
108
  e.$slots.submitBtn ? m(e.$slots, "submitBtn", {
108
109
  key: 0,
109
- submit: i(V),
110
- submitting: i(N)
110
+ submit: i(N),
111
+ submitting: i(M)
111
112
  }, void 0, !0) : (n(), u(U, c({ key: 1 }, a.submitBtnProps, {
112
113
  "submit-fn": a.submitFn,
113
114
  "submit-text": a.submitText,
@@ -0,0 +1,71 @@
1
+ import { markRaw as K } from "vue";
2
+ import M from "./FormItemNestFormList.vue.mjs";
3
+ import { resolveLayoutSpan as N, parseFormData as S, stringifyFormData as T } from "./utils.mjs";
4
+ const v = K(M);
5
+ function k(l) {
6
+ const {
7
+ key: m,
8
+ label: n,
9
+ list: o,
10
+ rowKey: d,
11
+ itemFactory: h,
12
+ min: f,
13
+ max: y,
14
+ layout: p,
15
+ rowGutter: c,
16
+ addText: F,
17
+ removeText: R,
18
+ headerRender: w,
19
+ footerRender: A,
20
+ shadowColor: L,
21
+ rules: t,
22
+ init: x,
23
+ stringify: I,
24
+ parse: $,
25
+ rebase: C,
26
+ removeConfirm: D
27
+ } = l, i = f ?? 0, s = y ?? 1 / 0, u = {
28
+ validator: (r, e, a) => {
29
+ const g = Array.isArray(e) ? e.length : 0;
30
+ return g < i ? a(new Error(`${n}至少需要 ${i} 项`)) : g > s ? a(new Error(`${n}最多 ${s} 项`)) : a();
31
+ },
32
+ trigger: "change"
33
+ }, E = i > 0 || s !== 1 / 0 ? typeof t == "function" ? (r) => [u, ...t(r)] : [u, ...t ?? []] : t;
34
+ return {
35
+ key: m,
36
+ label: n,
37
+ layout: p,
38
+ rules: E,
39
+ // 自动 pack(可覆盖):父 generate/stringify/parse 对数组逐项递归。
40
+ // init 缺省 = 空数组 []([MUST NOT] 补 min 行改初始值;min/max 由上方 rules 校验)
41
+ init: x ?? (() => []),
42
+ stringify: I ?? ((r) => (Array.isArray(r) ? r : []).map(
43
+ (e) => T(e, o)
44
+ )),
45
+ parse: $ ?? ((r) => (Array.isArray(r) ? r : []).map((e) => S(e, o))),
46
+ // render 用【组件本体引用】(非包裹 fn):FormItem 经 vModel sugar 注入 modelValue/onUpdate,
47
+ // 固定配置走 props。便于消费方按 `config.render === FormItemNestFormList` 判定"是联结组件"。
48
+ render: v,
49
+ props: {
50
+ nestKey: m,
51
+ list: o,
52
+ rowKey: d,
53
+ itemFactory: h,
54
+ min: f,
55
+ max: y,
56
+ rowGutter: c,
57
+ addText: F,
58
+ removeText: R,
59
+ headerRender: w,
60
+ footerRender: A,
61
+ shadowColor: L,
62
+ // P3:把父 item 代表 span 传薄壳,供其叠 rebase 因子算每行子 FormMain 的 layoutScale
63
+ parentSpan: N(p),
64
+ rebase: C,
65
+ removeConfirm: D
66
+ }
67
+ };
68
+ }
69
+ export {
70
+ k as nestFormItemList
71
+ };
@@ -0,0 +1,42 @@
1
+ import { markRaw as y } from "vue";
2
+ import l from "./FormItemNestForm.vue.mjs";
3
+ import { resolveLayoutSpan as u, parseFormData as g, stringifyFormData as w, generateFormData as c } from "./utils.mjs";
4
+ const D = y(l);
5
+ function k(a) {
6
+ const {
7
+ key: e,
8
+ label: m,
9
+ list: r,
10
+ layout: o,
11
+ rowGutter: n,
12
+ shadowColor: s,
13
+ init: i,
14
+ stringify: p,
15
+ parse: F,
16
+ rebase: f
17
+ } = a;
18
+ return {
19
+ key: e,
20
+ label: m,
21
+ layout: o,
22
+ // 自动 pack(可覆盖):父 generate/stringify/parse 递归进子 list
23
+ init: i ?? (() => c(r)),
24
+ stringify: p ?? ((t) => w(t ?? {}, r)),
25
+ parse: F ?? ((t) => g(t ?? {}, r)),
26
+ // render 用【组件本体引用】(非包裹 fn):FormItem 经 vModel sugar 注入 modelValue/onUpdate,
27
+ // 固定配置走 props。便于消费方按 `config.render === FormItemNestForm` 判定"是联结组件"。
28
+ render: D,
29
+ props: {
30
+ nestKey: e,
31
+ list: r,
32
+ rowGutter: n,
33
+ shadowColor: s,
34
+ // P3:把父 item 代表 span 传薄壳,供其叠 rebase 因子算子 FormMain 的 layoutScale
35
+ parentSpan: u(o),
36
+ rebase: f
37
+ }
38
+ };
39
+ }
40
+ export {
41
+ k as nestFormItem
42
+ };
@@ -0,0 +1,7 @@
1
+ import { shallowReactive as e } from "vue";
2
+ function r() {
3
+ return e({});
4
+ }
5
+ export {
6
+ r as createNestFormExposeMap
7
+ };
@@ -0,0 +1,22 @@
1
+ import { inject as s, onMounted as l, toValue as a, onBeforeUnmount as c } from "vue";
2
+ import { FORM_NEST_REGISTRY_KEY as d } from "../../inject/key.mjs";
3
+ function u(n) {
4
+ const { rowInstances: t, key: r } = n, o = s(d, null);
5
+ if (!o) return;
6
+ const i = {
7
+ validate: () => Promise.all(t().map((e) => e.validate())).then(() => {
8
+ }),
9
+ clearValidate: () => t().forEach((e) => e.clearValidate()),
10
+ resetFields: () => t().forEach((e) => e.resetFields())
11
+ };
12
+ l(() => {
13
+ const e = a(r);
14
+ e !== void 0 && (o[e] = i);
15
+ }), c(() => {
16
+ const e = a(r);
17
+ e !== void 0 && delete o[e];
18
+ });
19
+ }
20
+ export {
21
+ u as useNestFormList
22
+ };
@@ -0,0 +1,34 @@
1
+ import { inject as d, onMounted as u, toValue as a, onBeforeUnmount as f } from "vue";
2
+ import { FORM_NEST_REGISTRY_KEY as p } from "../../inject/key.mjs";
3
+ function x(c) {
4
+ const { childRef: s, key: i } = c, l = () => {
5
+ var o;
6
+ return ((o = s.value) == null ? void 0 : o.validate()) ?? Promise.resolve();
7
+ }, r = (o) => {
8
+ var e;
9
+ return (e = s.value) == null ? void 0 : e.clearValidate(o);
10
+ }, n = () => {
11
+ var o;
12
+ return (o = s.value) == null ? void 0 : o.resetFields();
13
+ }, t = d(p, null);
14
+ if (t) {
15
+ const o = {
16
+ validate: () => l(),
17
+ clearValidate: (e) => r(e),
18
+ resetFields: () => n()
19
+ };
20
+ u(() => {
21
+ const e = a(i);
22
+ e !== void 0 && (e in t && t[e] === o && console.error(
23
+ `[useNestForm] 嵌套 exposeMap 重复注册同一 expose(key="${e}"),疑似生命周期重复挂载;已继续挂载。`
24
+ ), t[e] = o);
25
+ }), f(() => {
26
+ const e = a(i);
27
+ e !== void 0 && delete t[e];
28
+ });
29
+ }
30
+ return { validateChild: l, clearChild: r, resetChild: n };
31
+ }
32
+ export {
33
+ x as useNestForm
34
+ };
@@ -0,0 +1,14 @@
1
+ import { inject as u, computed as c, toValue as o } from "vue";
2
+ import { NEST_LAYOUT_SCALE_KEY as f } from "../../inject/key.mjs";
3
+ function m(t) {
4
+ const r = u(f, void 0);
5
+ return c(() => {
6
+ const n = r ? r.value : 1;
7
+ if (o(t.rebase) === !1) return n;
8
+ const e = o(t.parentSpan), a = typeof e == "number" && e > 0 ? e : 24;
9
+ return n * (24 / a);
10
+ });
11
+ }
12
+ export {
13
+ m as useNestLayoutScale
14
+ };