@aspire-ui/element-component-pro 1.0.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.
- package/README.md +203 -0
- package/dist/ProForm/FormActions.vue.d.ts +98 -0
- package/dist/ProForm/ProForm.vue.d.ts +223 -0
- package/dist/ProForm/ProFormItem.vue.d.ts +39 -0
- package/dist/ProForm/index.d.ts +7 -0
- package/dist/ProForm/useForm.d.ts +28 -0
- package/dist/element-component-pro.es.js +444 -0
- package/dist/element-component-pro.es.js.map +1 -0
- package/dist/element-component-pro.umd.js +3 -0
- package/dist/element-component-pro.umd.js.map +1 -0
- package/dist/index.d.ts +769 -0
- package/dist/style.css +1 -0
- package/dist/types/index.d.ts +178 -0
- package/package.json +49 -0
- package/src/ProForm/FormActions.vue +76 -0
- package/src/ProForm/ProForm.vue +423 -0
- package/src/ProForm/ProFormItem.vue +250 -0
- package/src/ProForm/index.ts +6 -0
- package/src/ProForm/useForm.ts +114 -0
- package/src/index.ts +32 -0
- package/src/shims-vue.d.ts +5 -0
- package/src/types/index.ts +179 -0
- package/src/vite-env.d.ts +1 -0
|
@@ -0,0 +1,444 @@
|
|
|
1
|
+
import { defineComponent as D, useSlots as te, computed as w, h as ce, ref as B, onMounted as ue, onUnmounted as fe, watch as oe, unref as ee } from "vue";
|
|
2
|
+
const de = /* @__PURE__ */ D({
|
|
3
|
+
__name: "ProFormItem",
|
|
4
|
+
props: {
|
|
5
|
+
schema: null,
|
|
6
|
+
formModel: null,
|
|
7
|
+
formDisabled: { type: Boolean },
|
|
8
|
+
autoPlaceholder: { type: Boolean },
|
|
9
|
+
formActionType: null
|
|
10
|
+
},
|
|
11
|
+
setup(_) {
|
|
12
|
+
const e = _, l = te(), t = w(() => ({
|
|
13
|
+
schema: e.schema,
|
|
14
|
+
values: e.formModel,
|
|
15
|
+
model: e.formModel,
|
|
16
|
+
field: e.schema.field
|
|
17
|
+
})), s = w(() => {
|
|
18
|
+
const c = e.schema.ifShow;
|
|
19
|
+
return c === void 0 ? !0 : typeof c == "boolean" ? c : c(t.value);
|
|
20
|
+
}), b = w(() => {
|
|
21
|
+
const c = e.schema.show;
|
|
22
|
+
return c === void 0 ? !0 : typeof c == "boolean" ? c : c(t.value);
|
|
23
|
+
}), P = w(() => {
|
|
24
|
+
if (e.formDisabled)
|
|
25
|
+
return !0;
|
|
26
|
+
const c = e.schema.dynamicDisabled;
|
|
27
|
+
return c === void 0 ? !1 : typeof c == "boolean" ? c : c(t.value);
|
|
28
|
+
}), C = w(() => {
|
|
29
|
+
const c = e.schema.dynamicRules;
|
|
30
|
+
return c ? Array.isArray(c) ? c : c(t.value) : e.schema.rules;
|
|
31
|
+
}), v = w(() => {
|
|
32
|
+
const c = e.schema.componentProps;
|
|
33
|
+
if (!c)
|
|
34
|
+
return { props: {}, listeners: {} };
|
|
35
|
+
const d = typeof c == "function" ? c({
|
|
36
|
+
...t.value,
|
|
37
|
+
formActionType: e.formActionType
|
|
38
|
+
}) : { ...c }, R = {}, S = {};
|
|
39
|
+
for (const [n, f] of Object.entries(d))
|
|
40
|
+
if (n.length > 2 && /^on[A-Za-z]/.test(n) && typeof f == "function") {
|
|
41
|
+
const x = n.slice(2).charAt(0).toLowerCase() + n.slice(3);
|
|
42
|
+
S[x] = f;
|
|
43
|
+
} else
|
|
44
|
+
R[n] = f;
|
|
45
|
+
return { props: R, listeners: S };
|
|
46
|
+
}), m = w(() => v.value.props), M = w(() => v.value.listeners), h = w(() => !!l.default), y = (c) => {
|
|
47
|
+
const d = c == null ? void 0 : c.options;
|
|
48
|
+
return Array.isArray(d) ? d : void 0;
|
|
49
|
+
}, g = w(() => {
|
|
50
|
+
const c = e.schema.render;
|
|
51
|
+
return c ? {
|
|
52
|
+
render() {
|
|
53
|
+
const d = c(t.value);
|
|
54
|
+
return Array.isArray(d) ? ce("span", d) : d;
|
|
55
|
+
}
|
|
56
|
+
} : null;
|
|
57
|
+
});
|
|
58
|
+
return { __sfc: !0, props: e, slots: l, renderParams: t, shouldRender: s, shouldShow: b, effectiveDisabled: P, effectiveRules: C, effectiveComponentPropsAndListeners: v, effectiveComponentProps: m, effectiveComponentListeners: M, hasSlot: h, getOptions: y, renderComponent: g };
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
function W(_, e, l, t, s, b, P, C) {
|
|
62
|
+
var v = typeof _ == "function" ? _.options : _;
|
|
63
|
+
e && (v.render = e, v.staticRenderFns = l, v._compiled = !0), t && (v.functional = !0), b && (v._scopeId = "data-v-" + b);
|
|
64
|
+
var m;
|
|
65
|
+
if (P ? (m = function(y) {
|
|
66
|
+
y = y || // cached call
|
|
67
|
+
this.$vnode && this.$vnode.ssrContext || // stateful
|
|
68
|
+
this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext, !y && typeof __VUE_SSR_CONTEXT__ < "u" && (y = __VUE_SSR_CONTEXT__), s && s.call(this, y), y && y._registeredComponents && y._registeredComponents.add(P);
|
|
69
|
+
}, v._ssrRegister = m) : s && (m = C ? function() {
|
|
70
|
+
s.call(
|
|
71
|
+
this,
|
|
72
|
+
(v.functional ? this.parent : this).$root.$options.shadowRoot
|
|
73
|
+
);
|
|
74
|
+
} : s), m)
|
|
75
|
+
if (v.functional) {
|
|
76
|
+
v._injectStyles = m;
|
|
77
|
+
var M = v.render;
|
|
78
|
+
v.render = function(g, c) {
|
|
79
|
+
return m.call(c), M(g, c);
|
|
80
|
+
};
|
|
81
|
+
} else {
|
|
82
|
+
var h = v.beforeCreate;
|
|
83
|
+
v.beforeCreate = h ? [].concat(h, m) : [m];
|
|
84
|
+
}
|
|
85
|
+
return {
|
|
86
|
+
exports: _,
|
|
87
|
+
options: v
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
var me = function() {
|
|
91
|
+
var e = this, l = e._self._c, t = e._self._setupProxy;
|
|
92
|
+
return t.shouldRender ? l("el-form-item", { directives: [{ name: "show", rawName: "v-show", value: t.shouldShow, expression: "shouldShow" }], attrs: { prop: e.schema.field, required: e.schema.required, rules: t.effectiveRules } }, [l("template", { slot: "label" }, [l("span", [e._v(e._s(e.schema.label))]), e.schema.helpMessage ? l("el-tooltip", e._b({ attrs: { placement: "top", effect: "light" } }, "el-tooltip", e.schema.helpComponentProps || {}, !1), [l("template", { slot: "content" }, [Array.isArray(e.schema.helpMessage) ? e._l(e.schema.helpMessage, function(s, b) {
|
|
93
|
+
return l("div", { key: b, staticClass: "ecp-pro-form-item__help-item" }, [e._v(" " + e._s(s) + " ")]);
|
|
94
|
+
}) : l("span", [e._v(e._s(e.schema.helpMessage))])], 2), l("i", { staticClass: "el-icon-question ecp-pro-form-item__help-icon" })], 2) : e._e()], 1), e.schema.render ? [l(t.renderComponent, { tag: "component" })] : t.hasSlot ? e._t("default", null, { model: e.formModel, schema: e.schema, field: e.schema.field, values: e.formModel }) : [e.schema.component === "input" || !e.schema.component ? l("el-input", e._g(e._b({ attrs: { placeholder: e.schema.placeholder || (e.autoPlaceholder ? `请输入${e.schema.label}` : void 0), disabled: t.effectiveDisabled }, model: { value: e.formModel[e.schema.field], callback: function(s) {
|
|
95
|
+
e.$set(e.formModel, e.schema.field, s);
|
|
96
|
+
}, expression: "formModel[schema.field]" } }, "el-input", t.effectiveComponentProps, !1), t.effectiveComponentListeners)) : e.schema.component === "input-number" ? l("el-input-number", e._g(e._b({ attrs: { placeholder: e.schema.placeholder, disabled: t.effectiveDisabled }, model: { value: e.formModel[e.schema.field], callback: function(s) {
|
|
97
|
+
e.$set(e.formModel, e.schema.field, s);
|
|
98
|
+
}, expression: "formModel[schema.field]" } }, "el-input-number", t.effectiveComponentProps, !1), t.effectiveComponentListeners)) : e.schema.component === "select" ? l("el-select", e._g(e._b({ staticClass: "ecp-pro-form-item__select", attrs: { placeholder: e.schema.placeholder || (e.autoPlaceholder ? `请选择${e.schema.label}` : void 0), disabled: t.effectiveDisabled }, model: { value: e.formModel[e.schema.field], callback: function(s) {
|
|
99
|
+
e.$set(e.formModel, e.schema.field, s);
|
|
100
|
+
}, expression: "formModel[schema.field]" } }, "el-select", t.effectiveComponentProps, !1), t.effectiveComponentListeners), e._l(t.getOptions(t.effectiveComponentProps) || [], function(s) {
|
|
101
|
+
return l("el-option", { key: String(s.value), attrs: { label: s.label, value: s.value } });
|
|
102
|
+
}), 1) : e.schema.component === "date-picker" ? l("el-date-picker", e._g(e._b({ attrs: { placeholder: e.schema.placeholder || (e.autoPlaceholder ? `请选择${e.schema.label}` : void 0), disabled: t.effectiveDisabled }, model: { value: e.formModel[e.schema.field], callback: function(s) {
|
|
103
|
+
e.$set(e.formModel, e.schema.field, s);
|
|
104
|
+
}, expression: "formModel[schema.field]" } }, "el-date-picker", t.effectiveComponentProps, !1), t.effectiveComponentListeners)) : e.schema.component === "date-range" ? l("el-date-picker", e._g(e._b({ attrs: { type: "daterange", "range-separator": "至", "start-placeholder": "开始日期", "end-placeholder": "结束日期", "value-format": "yyyy-MM-dd", disabled: t.effectiveDisabled }, model: { value: e.formModel[e.schema.field], callback: function(s) {
|
|
105
|
+
e.$set(e.formModel, e.schema.field, s);
|
|
106
|
+
}, expression: "formModel[schema.field]" } }, "el-date-picker", t.effectiveComponentProps, !1), t.effectiveComponentListeners)) : e.schema.component === "switch" ? l("el-switch", e._g(e._b({ attrs: { disabled: t.effectiveDisabled }, model: { value: e.formModel[e.schema.field], callback: function(s) {
|
|
107
|
+
e.$set(e.formModel, e.schema.field, s);
|
|
108
|
+
}, expression: "formModel[schema.field]" } }, "el-switch", t.effectiveComponentProps, !1), t.effectiveComponentListeners)) : e.schema.component === "cascader" ? l("el-cascader", e._g(e._b({ attrs: { placeholder: e.schema.placeholder || (e.autoPlaceholder ? `请选择${e.schema.label}` : void 0), disabled: t.effectiveDisabled }, model: { value: e.formModel[e.schema.field], callback: function(s) {
|
|
109
|
+
e.$set(e.formModel, e.schema.field, s);
|
|
110
|
+
}, expression: "formModel[schema.field]" } }, "el-cascader", t.effectiveComponentProps, !1), t.effectiveComponentListeners)) : e.schema.component === "checkbox" ? l("el-checkbox-group", e._g(e._b({ attrs: { disabled: t.effectiveDisabled }, model: { value: e.formModel[e.schema.field], callback: function(s) {
|
|
111
|
+
e.$set(e.formModel, e.schema.field, s);
|
|
112
|
+
}, expression: "formModel[schema.field]" } }, "el-checkbox-group", t.effectiveComponentProps, !1), t.effectiveComponentListeners), e._l(t.getOptions(t.effectiveComponentProps) || [], function(s) {
|
|
113
|
+
return l("el-checkbox", { key: String(s.value), attrs: { label: s.value } }, [e._v(" " + e._s(s.label) + " ")]);
|
|
114
|
+
}), 1) : e.schema.component === "radio" ? l("el-radio-group", e._g(e._b({ attrs: { disabled: t.effectiveDisabled }, model: { value: e.formModel[e.schema.field], callback: function(s) {
|
|
115
|
+
e.$set(e.formModel, e.schema.field, s);
|
|
116
|
+
}, expression: "formModel[schema.field]" } }, "el-radio-group", t.effectiveComponentProps, !1), t.effectiveComponentListeners), e._l(t.getOptions(t.effectiveComponentProps) || [], function(s) {
|
|
117
|
+
return l("el-radio", { key: String(s.value), attrs: { label: s.value } }, [e._v(" " + e._s(s.label) + " ")]);
|
|
118
|
+
}), 1) : e._e()]], 2) : e._e();
|
|
119
|
+
}, pe = [], ve = /* @__PURE__ */ W(
|
|
120
|
+
de,
|
|
121
|
+
me,
|
|
122
|
+
pe,
|
|
123
|
+
!1,
|
|
124
|
+
null,
|
|
125
|
+
"0e0e5ebb",
|
|
126
|
+
null,
|
|
127
|
+
null
|
|
128
|
+
);
|
|
129
|
+
const se = ve.exports, he = /* @__PURE__ */ D({
|
|
130
|
+
__name: "FormActions",
|
|
131
|
+
props: {
|
|
132
|
+
showActionButtonGroup: { type: Boolean, default: !0 },
|
|
133
|
+
showSubmitButton: { type: Boolean, default: !0 },
|
|
134
|
+
showResetButton: { type: Boolean, default: !0 },
|
|
135
|
+
submitButtonText: { default: "提交" },
|
|
136
|
+
resetButtonText: { default: "重置" },
|
|
137
|
+
submitButtonIcon: { default: "el-icon-search" },
|
|
138
|
+
resetButtonIcon: { default: "el-icon-refresh-left" },
|
|
139
|
+
submitLoading: { type: Boolean, default: !1 },
|
|
140
|
+
showAdvancedButton: { type: Boolean, default: !1 },
|
|
141
|
+
hasMoreFields: { type: Boolean, default: !1 },
|
|
142
|
+
collapsed: { type: Boolean, default: !0 },
|
|
143
|
+
actionColOptions: null
|
|
144
|
+
},
|
|
145
|
+
emits: ["submit", "reset", "toggle"],
|
|
146
|
+
setup(_) {
|
|
147
|
+
return { __sfc: !0 };
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
var _e = function() {
|
|
151
|
+
var e = this, l = e._self._c;
|
|
152
|
+
return e._self._setupProxy, l("div", { staticClass: "ecp-form-actions" }, [e._t("submitBefore"), e.showSubmitButton ? l("el-button", { attrs: { type: "primary", icon: e.submitButtonIcon, loading: e.submitLoading }, on: { click: function(t) {
|
|
153
|
+
return e.$emit("submit");
|
|
154
|
+
} } }, [e._v(" " + e._s(e.submitButtonText) + " ")]) : e._e(), e._t("resetBefore"), e.showResetButton ? l("el-button", { attrs: { icon: e.resetButtonIcon }, on: { click: function(t) {
|
|
155
|
+
return e.$emit("reset");
|
|
156
|
+
} } }, [e._v(" " + e._s(e.resetButtonText) + " ")]) : e._e(), e._t("actions")], 2);
|
|
157
|
+
}, be = [], ye = /* @__PURE__ */ W(
|
|
158
|
+
he,
|
|
159
|
+
_e,
|
|
160
|
+
be,
|
|
161
|
+
!1,
|
|
162
|
+
null,
|
|
163
|
+
"489c88d2",
|
|
164
|
+
null,
|
|
165
|
+
null
|
|
166
|
+
);
|
|
167
|
+
const le = ye.exports, we = /* @__PURE__ */ D({
|
|
168
|
+
__name: "ProForm",
|
|
169
|
+
props: {
|
|
170
|
+
schemas: null,
|
|
171
|
+
initialValues: null,
|
|
172
|
+
labelWidth: { default: "120px" },
|
|
173
|
+
labelPosition: { default: "right" },
|
|
174
|
+
gutter: { default: 24 },
|
|
175
|
+
size: { default: "medium" },
|
|
176
|
+
disabled: { type: Boolean },
|
|
177
|
+
baseColProps: { default: () => ({ xs: 24, sm: 12, md: 12, lg: 8, xl: 6 }) },
|
|
178
|
+
baseRowStyle: null,
|
|
179
|
+
autoSetPlaceholder: { type: Boolean, default: !0 },
|
|
180
|
+
showSubmitButton: { type: Boolean, default: !0 },
|
|
181
|
+
showResetButton: { type: Boolean, default: !0 },
|
|
182
|
+
submitButtonText: { default: "提交" },
|
|
183
|
+
resetButtonText: { default: "重置" },
|
|
184
|
+
submitButtonIcon: { default: "el-icon-search" },
|
|
185
|
+
resetButtonIcon: { default: "el-icon-refresh-left" },
|
|
186
|
+
showActionButtonGroup: { type: Boolean, default: !0 },
|
|
187
|
+
actionColOptions: { default: () => ({ xs: 24, sm: 12, md: 12, lg: 8, xl: 6 }) },
|
|
188
|
+
showAdvancedButton: { type: Boolean, default: !1 },
|
|
189
|
+
autoAdvancedLine: { default: 3 },
|
|
190
|
+
alwaysShowLines: { default: 1 },
|
|
191
|
+
submitFunc: null,
|
|
192
|
+
resetFunc: null,
|
|
193
|
+
submitOnReset: { type: Boolean, default: !1 },
|
|
194
|
+
formListeners: null
|
|
195
|
+
},
|
|
196
|
+
emits: ["submit", "reset", "register"],
|
|
197
|
+
setup(_, { expose: e, emit: l }) {
|
|
198
|
+
const t = _, s = te(), b = B(), P = B(), C = B(!1), v = B(!0), m = B({}), M = B({}), h = B([]), y = B({}), g = { xl: 1920, lg: 1200, md: 992, sm: 768 }, c = (o, r, u) => {
|
|
199
|
+
const i = u ?? (typeof window < "u" ? window.innerWidth : 1920), a = o ?? {}, p = r ?? {}, F = p.span ?? 8;
|
|
200
|
+
return i >= g.xl ? a.xl ?? p.xl ?? a.lg ?? p.lg ?? a.md ?? p.md ?? a.sm ?? p.sm ?? a.xs ?? p.xs ?? a.span ?? F : i >= g.lg ? a.lg ?? p.lg ?? a.md ?? p.md ?? a.sm ?? p.sm ?? a.xs ?? p.xs ?? a.span ?? F : i >= g.md ? a.md ?? p.md ?? a.sm ?? p.sm ?? a.xs ?? p.xs ?? a.span ?? F : i >= g.sm || i < g.sm ? a.sm ?? p.sm ?? a.xs ?? p.xs ?? a.span ?? F : a.xs ?? p.xs ?? a.span ?? F;
|
|
201
|
+
}, d = w(() => ({ ...t, ...y.value })), R = w(() => d.value.actionColOptions ?? { span: 24 }), S = B(typeof window < "u" ? window.innerWidth : 1920), n = (o, r, u, i) => {
|
|
202
|
+
let a = 24, p = 1, F = 0;
|
|
203
|
+
for (const $ of o) {
|
|
204
|
+
const E = c($.colProps, r, i);
|
|
205
|
+
if (E > a) {
|
|
206
|
+
if (p++, p > u)
|
|
207
|
+
break;
|
|
208
|
+
a = 24 - E;
|
|
209
|
+
} else
|
|
210
|
+
a -= E;
|
|
211
|
+
F++;
|
|
212
|
+
}
|
|
213
|
+
return F;
|
|
214
|
+
}, f = w(() => {
|
|
215
|
+
const o = h.value.filter((a) => !a.hidden);
|
|
216
|
+
if (!d.value.showAdvancedButton)
|
|
217
|
+
return !1;
|
|
218
|
+
const r = d.value.alwaysShowLines ?? 1, u = d.value.baseColProps, i = n(o, u, r, S.value);
|
|
219
|
+
return console.log(o.length, i), o.length > i;
|
|
220
|
+
}), x = w(() => d.value.formListeners ?? {}), k = w(() => {
|
|
221
|
+
const o = h.value.filter((a) => z(a));
|
|
222
|
+
if (!d.value.showAdvancedButton || !v.value)
|
|
223
|
+
return o;
|
|
224
|
+
const r = d.value.alwaysShowLines ?? 1, u = d.value.baseColProps, i = n(o, u, r, S.value);
|
|
225
|
+
return o.slice(0, i);
|
|
226
|
+
}), z = (o) => {
|
|
227
|
+
let r = !0, u = !0;
|
|
228
|
+
return typeof o.ifShow == "function" && (r = o.ifShow({ schema: o, values: m.value, model: m.value, field: o.field })), typeof o.ifShow == "boolean" && (r = o.ifShow), typeof o.show == "function" && (u = o.show({ schema: o, values: m.value, model: m.value, field: o.field })), typeof o.show == "boolean" && (u = o.show), r && u;
|
|
229
|
+
}, ae = (o) => o.colProps ?? d.value.baseColProps ?? {}, re = (o) => o.slot || o.field, A = () => {
|
|
230
|
+
const o = {}, r = {}, u = d.value.initialValues ?? t.initialValues;
|
|
231
|
+
h.value.forEach((i) => {
|
|
232
|
+
var a;
|
|
233
|
+
o[i.field] = i.defaultValue ?? (u == null ? void 0 : u[i.field]), (a = i.rules) != null && a.length && (r[i.field] = i.rules);
|
|
234
|
+
}), m.value = { ...m.value, ...o }, M.value = r;
|
|
235
|
+
}, N = (o) => {
|
|
236
|
+
const r = { ...o };
|
|
237
|
+
return h.value.forEach((u) => {
|
|
238
|
+
const i = u.ifShow;
|
|
239
|
+
if (i === void 0)
|
|
240
|
+
return;
|
|
241
|
+
(typeof i == "boolean" ? i : i({ schema: u, values: o, model: o, field: u.field })) || delete r[u.field];
|
|
242
|
+
}), r;
|
|
243
|
+
}, T = (o) => {
|
|
244
|
+
const r = N(o), u = y.value.fieldMapToTime;
|
|
245
|
+
if (!(u != null && u.length))
|
|
246
|
+
return r;
|
|
247
|
+
const i = { ...r };
|
|
248
|
+
return u.forEach(([a, [p, F]]) => {
|
|
249
|
+
const $ = i[a];
|
|
250
|
+
Array.isArray($) && $.length === 2 && (delete i[a], i[p] = $[0], i[F] = $[1]);
|
|
251
|
+
}), i;
|
|
252
|
+
}, V = async () => {
|
|
253
|
+
var o;
|
|
254
|
+
try {
|
|
255
|
+
await ((o = b.value) == null ? void 0 : o.validate()), d.value.submitFunc ? await d.value.submitFunc() : (C.value = !0, l("submit", T({ ...m.value })));
|
|
256
|
+
} catch (r) {
|
|
257
|
+
console.error("Form validation failed:", r);
|
|
258
|
+
} finally {
|
|
259
|
+
C.value = !1;
|
|
260
|
+
}
|
|
261
|
+
}, ie = async () => {
|
|
262
|
+
var o;
|
|
263
|
+
d.value.resetFunc ? await d.value.resetFunc() : ((o = b.value) == null || o.resetFields(), A(), l("reset"), d.value.submitOnReset && await V());
|
|
264
|
+
}, q = (o) => (m.value = { ...m.value, ...o }, Promise.resolve()), G = () => T({ ...m.value }), U = async () => {
|
|
265
|
+
var o;
|
|
266
|
+
(o = b.value) == null || o.resetFields(), A();
|
|
267
|
+
}, X = (o) => {
|
|
268
|
+
var r;
|
|
269
|
+
return ((r = b.value) == null ? void 0 : r.validate(o)) ?? Promise.resolve();
|
|
270
|
+
}, H = (o) => b.value ? o != null && o.length ? Promise.all(o.map((r) => new Promise((u, i) => {
|
|
271
|
+
b.value.validateField(r, (a) => a ? u(void 0) : i(new Error("Validation failed")));
|
|
272
|
+
}))) : b.value.validate() : Promise.resolve(), K = async (o, r) => {
|
|
273
|
+
var i;
|
|
274
|
+
const u = (i = P.value) == null ? void 0 : i.querySelector(`[data-field="${o}"]`);
|
|
275
|
+
return u && u.scrollIntoView({ behavior: (r == null ? void 0 : r.behavior) ?? "smooth", block: (r == null ? void 0 : r.block) ?? "nearest" }), Promise.resolve();
|
|
276
|
+
}, Z = (o) => {
|
|
277
|
+
var r;
|
|
278
|
+
(r = b.value) == null || r.clearValidate(o);
|
|
279
|
+
}, j = async (o) => {
|
|
280
|
+
(Array.isArray(o) ? o : [o]).forEach((u) => {
|
|
281
|
+
const i = h.value.findIndex((a) => a.field === u.field);
|
|
282
|
+
i >= 0 && (h.value[i] = { ...h.value[i], ...u });
|
|
283
|
+
});
|
|
284
|
+
}, J = async (o, r, u) => {
|
|
285
|
+
if (u)
|
|
286
|
+
h.value.unshift(o);
|
|
287
|
+
else if (r) {
|
|
288
|
+
const i = h.value.findIndex((a) => a.field === r);
|
|
289
|
+
h.value.splice(i + 1, 0, o);
|
|
290
|
+
} else
|
|
291
|
+
h.value.push(o);
|
|
292
|
+
A();
|
|
293
|
+
}, Q = async (o) => {
|
|
294
|
+
const r = Array.isArray(o) ? o : [o];
|
|
295
|
+
h.value = h.value.filter((u) => !r.includes(u.field));
|
|
296
|
+
}, Y = async (o) => {
|
|
297
|
+
if (y.value = { ...y.value, ...o }, o.schemas) {
|
|
298
|
+
h.value = [...o.schemas];
|
|
299
|
+
debugger;
|
|
300
|
+
A();
|
|
301
|
+
}
|
|
302
|
+
}, L = {
|
|
303
|
+
getFieldsValue: G,
|
|
304
|
+
setFieldsValue: q,
|
|
305
|
+
resetFields: U,
|
|
306
|
+
validate: X,
|
|
307
|
+
validateFields: H,
|
|
308
|
+
submit: V,
|
|
309
|
+
scrollToField: K,
|
|
310
|
+
clearValidate: Z,
|
|
311
|
+
updateSchema: j,
|
|
312
|
+
appendSchemaByField: J,
|
|
313
|
+
removeSchemaByField: Q,
|
|
314
|
+
setProps: Y
|
|
315
|
+
};
|
|
316
|
+
e(L);
|
|
317
|
+
const I = () => {
|
|
318
|
+
h.value = [...t.schemas ?? []], A();
|
|
319
|
+
}, O = () => {
|
|
320
|
+
typeof window < "u" && (S.value = window.innerWidth);
|
|
321
|
+
};
|
|
322
|
+
return ue(() => {
|
|
323
|
+
I(), l("register", L), typeof window < "u" && window.addEventListener("resize", O);
|
|
324
|
+
}), fe(() => {
|
|
325
|
+
typeof window < "u" && window.removeEventListener("resize", O);
|
|
326
|
+
}), oe(() => [t.schemas, t.initialValues], I, { deep: !0 }), { __sfc: !0, props: t, emit: l, slots: s, formRef: b, formWrapRef: P, submitLoading: C, collapsed: v, formModel: m, formRules: M, innerSchemas: h, innerProps: y, BREAKPOINTS: g, getEffectiveSpan: c, effectiveProps: d, effectiveActionColOptions: R, windowWidth: S, getVisibleSchemaCount: n, hasMoreFields: f, formListeners: x, displaySchemas: k, shouldShow: z, getColProps: ae, getSlotName: re, initForm: A, filterByIfShow: N, processFieldMapToTime: T, handleSubmit: V, handleReset: ie, setFieldsValue: q, getFieldsValue: G, resetFields: U, validate: X, validateFields: H, scrollToField: K, clearValidate: Z, updateSchema: j, appendSchemaByField: J, removeSchemaByField: Q, setProps: Y, formActionRef: L, syncSchemas: I, handleResize: O, ProFormItem: se, FormActions: le };
|
|
327
|
+
}
|
|
328
|
+
});
|
|
329
|
+
var Pe = function() {
|
|
330
|
+
var e = this, l = e._self._c, t = e._self._setupProxy;
|
|
331
|
+
return l("div", { ref: "formWrapRef", staticClass: "ecp-pro-form" }, [l("el-form", e._g(e._b({ ref: "formRef", staticClass: "ecp-pro-form", attrs: { model: t.formModel, rules: t.formRules, "label-width": t.effectiveProps.labelWidth, "label-position": t.effectiveProps.labelPosition, size: t.effectiveProps.size, disabled: t.effectiveProps.disabled } }, "el-form", e.$attrs, !1), t.formListeners), [e._t("formHeader"), l("el-row", { style: t.effectiveProps.baseRowStyle, attrs: { gutter: t.effectiveProps.gutter } }, [e._l(t.displaySchemas, function(s) {
|
|
332
|
+
var b, P;
|
|
333
|
+
return [t.shouldShow(s) ? l("el-col", e._b({ key: s.field, attrs: { offset: ((b = s.colProps) == null ? void 0 : b.offset) ?? ((P = t.effectiveProps.baseColProps) == null ? void 0 : P.offset) ?? 0, "data-field": s.field } }, "el-col", t.getColProps(s), !1), [l(t.ProFormItem, { attrs: { schema: s, "form-model": t.formModel, "form-disabled": t.effectiveProps.disabled, "auto-placeholder": t.effectiveProps.autoSetPlaceholder, "form-action-type": t.formActionRef } }, [t.slots[t.getSlotName(s)] ? [e._t(t.getSlotName(s), null, { model: t.formModel, schema: s, field: s.field, values: t.formModel })] : e._e()], 2)], 1) : e._e()];
|
|
334
|
+
}), t.effectiveProps.showActionButtonGroup ? l("el-col", e._b({ staticClass: "ecp-pro-form_col" }, "el-col", t.hasMoreFields ? { span: 24 } : t.effectiveProps.actionColOptions || { span: 6 }, !1), [l(t.FormActions, { attrs: { "show-action-button-group": t.effectiveProps.showActionButtonGroup, "show-submit-button": t.effectiveProps.showSubmitButton, "show-reset-button": t.effectiveProps.showResetButton, "submit-button-text": t.effectiveProps.submitButtonText, "reset-button-text": t.effectiveProps.resetButtonText, "submit-button-icon": t.effectiveProps.submitButtonIcon, "reset-button-icon": t.effectiveProps.resetButtonIcon, "submit-loading": t.submitLoading, "show-advanced-button": t.effectiveProps.showAdvancedButton, "has-more-fields": t.hasMoreFields, collapsed: t.collapsed, "action-col-options": t.effectiveActionColOptions }, on: { submit: t.handleSubmit, reset: t.handleReset, toggle: function(s) {
|
|
335
|
+
t.collapsed = !t.collapsed;
|
|
336
|
+
} } }, [l("template", { slot: "submitBefore" }, [e._t("submitBefore")], 2), l("template", { slot: "resetBefore" }, [e._t("resetBefore")], 2), l("template", { slot: "advanceBefore" }, [e._t("advanceBefore")], 2), l("template", { slot: "advanceAfter" }, [e._t("advanceAfter")], 2), l("template", { slot: "actions" }, [e._t("actions")], 2)], 2)], 1) : e._e()], 2), t.effectiveProps.showAdvancedButton && t.hasMoreFields ? l("el-button", { staticClass: "ecp-form-actions__advance", attrs: { type: "text" }, on: { click: function(s) {
|
|
337
|
+
t.collapsed = !t.collapsed;
|
|
338
|
+
} } }, [l("i", { staticClass: "el-icon-d-arrow-left", class: t.collapsed ? "down" : "up" }), e._v(" " + e._s(t.collapsed ? "展开" : "收起") + " ")]) : e._e(), e._t("formFooter")], 2)], 1);
|
|
339
|
+
}, ge = [], Fe = /* @__PURE__ */ W(
|
|
340
|
+
we,
|
|
341
|
+
Pe,
|
|
342
|
+
ge,
|
|
343
|
+
!1,
|
|
344
|
+
null,
|
|
345
|
+
"d75b0fb1",
|
|
346
|
+
null,
|
|
347
|
+
null
|
|
348
|
+
);
|
|
349
|
+
const ne = Fe.exports;
|
|
350
|
+
function xe(_) {
|
|
351
|
+
const e = B(null), l = B(_ ? ee(_) : void 0), t = () => _ ? ee(_) : void 0, s = (n) => {
|
|
352
|
+
e.value = n;
|
|
353
|
+
const f = t();
|
|
354
|
+
debugger;
|
|
355
|
+
f && Object.keys(f).length > 0 && n.setProps(f);
|
|
356
|
+
};
|
|
357
|
+
return _ && oe(
|
|
358
|
+
() => t(),
|
|
359
|
+
(n) => {
|
|
360
|
+
l.value = n, n && e.value && e.value.setProps(n);
|
|
361
|
+
},
|
|
362
|
+
{ deep: !0 }
|
|
363
|
+
), [s, {
|
|
364
|
+
register: s,
|
|
365
|
+
formAction: e,
|
|
366
|
+
getFieldsValue: () => {
|
|
367
|
+
var n;
|
|
368
|
+
return ((n = e.value) == null ? void 0 : n.getFieldsValue()) ?? {};
|
|
369
|
+
},
|
|
370
|
+
setFieldsValue: async (n) => {
|
|
371
|
+
var f;
|
|
372
|
+
await ((f = e.value) == null ? void 0 : f.setFieldsValue(n));
|
|
373
|
+
},
|
|
374
|
+
resetFields: async () => {
|
|
375
|
+
var n;
|
|
376
|
+
await ((n = e.value) == null ? void 0 : n.resetFields());
|
|
377
|
+
},
|
|
378
|
+
validate: (n) => {
|
|
379
|
+
var f;
|
|
380
|
+
return ((f = e.value) == null ? void 0 : f.validate(n)) ?? Promise.resolve();
|
|
381
|
+
},
|
|
382
|
+
validateFields: (n) => {
|
|
383
|
+
var f;
|
|
384
|
+
return ((f = e.value) == null ? void 0 : f.validateFields(n)) ?? Promise.resolve();
|
|
385
|
+
},
|
|
386
|
+
submit: () => {
|
|
387
|
+
var n;
|
|
388
|
+
return ((n = e.value) == null ? void 0 : n.submit()) ?? Promise.resolve();
|
|
389
|
+
},
|
|
390
|
+
scrollToField: (n, f) => {
|
|
391
|
+
var x;
|
|
392
|
+
return ((x = e.value) == null ? void 0 : x.scrollToField(n, f)) ?? Promise.resolve();
|
|
393
|
+
},
|
|
394
|
+
clearValidate: (n) => {
|
|
395
|
+
var f;
|
|
396
|
+
(f = e.value) == null || f.clearValidate(n);
|
|
397
|
+
},
|
|
398
|
+
updateSchema: (n) => {
|
|
399
|
+
var f;
|
|
400
|
+
return ((f = e.value) == null ? void 0 : f.updateSchema(n)) ?? Promise.resolve();
|
|
401
|
+
},
|
|
402
|
+
appendSchemaByField: (n, f, x) => {
|
|
403
|
+
var k;
|
|
404
|
+
return ((k = e.value) == null ? void 0 : k.appendSchemaByField(n, f, x)) ?? Promise.resolve();
|
|
405
|
+
},
|
|
406
|
+
removeSchemaByField: (n) => {
|
|
407
|
+
var f;
|
|
408
|
+
return ((f = e.value) == null ? void 0 : f.removeSchemaByField(n)) ?? Promise.resolve();
|
|
409
|
+
},
|
|
410
|
+
setProps: async (n) => {
|
|
411
|
+
var f;
|
|
412
|
+
l.value = { ...l.value, ...n }, await ((f = e.value) == null ? void 0 : f.setProps(n));
|
|
413
|
+
}
|
|
414
|
+
}];
|
|
415
|
+
}
|
|
416
|
+
const Be = [
|
|
417
|
+
// { name: 'ProTable', component: ProTable },
|
|
418
|
+
{ name: "ProForm", component: ne },
|
|
419
|
+
{ name: "ProFormItem", component: se },
|
|
420
|
+
{ name: "FormActions", component: le }
|
|
421
|
+
// { name: 'ProCard', component: ProCard },
|
|
422
|
+
// { name: 'ProDescriptions', component: ProDescriptions },
|
|
423
|
+
];
|
|
424
|
+
function Ce(_) {
|
|
425
|
+
Be.forEach(({ name: e, component: l }) => {
|
|
426
|
+
_.component(e, l);
|
|
427
|
+
});
|
|
428
|
+
}
|
|
429
|
+
const Me = {
|
|
430
|
+
install: Ce,
|
|
431
|
+
// ProTable,
|
|
432
|
+
ProForm: ne
|
|
433
|
+
// ProCard,
|
|
434
|
+
// ProDescriptions,
|
|
435
|
+
};
|
|
436
|
+
export {
|
|
437
|
+
le as FormActions,
|
|
438
|
+
ne as ProForm,
|
|
439
|
+
se as ProFormItem,
|
|
440
|
+
Me as default,
|
|
441
|
+
Ce as install,
|
|
442
|
+
xe as useForm
|
|
443
|
+
};
|
|
444
|
+
//# sourceMappingURL=element-component-pro.es.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"element-component-pro.es.js","sources":["../src/ProForm/ProFormItem.vue","../src/ProForm/ProForm.vue","../src/ProForm/useForm.ts","../src/index.ts"],"sourcesContent":["<template>\n <el-form-item\n v-if=\"shouldRender\"\n v-show=\"shouldShow\"\n :prop=\"schema.field\"\n :required=\"schema.required\"\n :rules=\"effectiveRules\"\n >\n <template slot=\"label\">\n <span>{{ schema.label }}</span>\n <el-tooltip\n v-if=\"schema.helpMessage\"\n placement=\"top\"\n effect=\"light\"\n v-bind=\"schema.helpComponentProps || {}\"\n >\n <template slot=\"content\">\n <template v-if=\"Array.isArray(schema.helpMessage)\">\n <div v-for=\"(msg, i) in schema.helpMessage\" :key=\"i\" class=\"ecp-pro-form-item__help-item\">\n {{ msg }}\n </div>\n </template>\n <span v-else>{{ schema.helpMessage }}</span>\n </template>\n <i class=\"el-icon-question ecp-pro-form-item__help-icon\" />\n </el-tooltip>\n </template>\n <!-- render 自定义渲染 -->\n <template v-if=\"schema.render\">\n <component :is=\"renderComponent\" />\n </template>\n <!-- slot 自定义插槽(由 ProForm 传入 default slot) -->\n <slot v-else-if=\"hasSlot\" :model=\"formModel\" :schema=\"schema\" :field=\"schema.field\" :values=\"formModel\" />\n <!-- 默认组件渲染 -->\n <template v-else>\n <el-input\n v-if=\"schema.component === 'input' || !schema.component\"\n v-model=\"formModel[schema.field]\"\n :placeholder=\"schema.placeholder || (autoPlaceholder ? `请输入${schema.label}` : undefined)\"\n :disabled=\"effectiveDisabled\"\n v-bind=\"effectiveComponentProps\"\n v-on=\"effectiveComponentListeners\"\n />\n <el-input-number\n v-else-if=\"schema.component === 'input-number'\"\n v-model=\"formModel[schema.field]\"\n :placeholder=\"schema.placeholder\"\n :disabled=\"effectiveDisabled\"\n v-bind=\"effectiveComponentProps\"\n v-on=\"effectiveComponentListeners\"\n />\n <el-select\n class=\"ecp-pro-form-item__select\"\n v-else-if=\"schema.component === 'select'\"\n v-model=\"formModel[schema.field]\"\n :placeholder=\"schema.placeholder || (autoPlaceholder ? `请选择${schema.label}` : undefined)\"\n :disabled=\"effectiveDisabled\"\n v-bind=\"effectiveComponentProps\"\n v-on=\"effectiveComponentListeners\"\n >\n <el-option\n v-for=\"opt in (getOptions(effectiveComponentProps) || [])\"\n :key=\"String(opt.value)\"\n :label=\"opt.label\"\n :value=\"opt.value\"\n />\n </el-select>\n <el-date-picker\n v-else-if=\"schema.component === 'date-picker'\"\n v-model=\"formModel[schema.field]\"\n :placeholder=\"schema.placeholder || (autoPlaceholder ? `请选择${schema.label}` : undefined)\"\n :disabled=\"effectiveDisabled\"\n v-bind=\"effectiveComponentProps\"\n v-on=\"effectiveComponentListeners\"\n />\n <el-date-picker\n v-else-if=\"schema.component === 'date-range'\"\n v-model=\"formModel[schema.field]\"\n type=\"daterange\"\n range-separator=\"至\"\n start-placeholder=\"开始日期\"\n end-placeholder=\"结束日期\"\n value-format=\"yyyy-MM-dd\"\n :disabled=\"effectiveDisabled\"\n v-bind=\"effectiveComponentProps\"\n v-on=\"effectiveComponentListeners\"\n />\n <el-switch\n v-else-if=\"schema.component === 'switch'\"\n v-model=\"formModel[schema.field]\"\n :disabled=\"effectiveDisabled\"\n v-bind=\"effectiveComponentProps\"\n v-on=\"effectiveComponentListeners\"\n />\n <el-cascader\n v-else-if=\"schema.component === 'cascader'\"\n v-model=\"formModel[schema.field]\"\n :placeholder=\"schema.placeholder || (autoPlaceholder ? `请选择${schema.label}` : undefined)\"\n :disabled=\"effectiveDisabled\"\n v-bind=\"effectiveComponentProps\"\n v-on=\"effectiveComponentListeners\"\n />\n <el-checkbox-group\n v-else-if=\"schema.component === 'checkbox'\"\n v-model=\"formModel[schema.field]\"\n :disabled=\"effectiveDisabled\"\n v-bind=\"effectiveComponentProps\"\n v-on=\"effectiveComponentListeners\"\n >\n <el-checkbox\n v-for=\"opt in (getOptions(effectiveComponentProps) || [])\"\n :key=\"String(opt.value)\"\n :label=\"opt.value\"\n >\n {{ opt.label }}\n </el-checkbox>\n </el-checkbox-group>\n <el-radio-group\n v-else-if=\"schema.component === 'radio'\"\n v-model=\"formModel[schema.field]\"\n :disabled=\"effectiveDisabled\"\n v-bind=\"effectiveComponentProps\"\n v-on=\"effectiveComponentListeners\"\n >\n <el-radio\n v-for=\"opt in (getOptions(effectiveComponentProps) || [])\"\n :key=\"String(opt.value)\"\n :label=\"opt.value\"\n >\n {{ opt.label }}\n </el-radio>\n </el-radio-group>\n </template>\n </el-form-item>\n</template>\n\n<script setup lang=\"ts\">\nimport { computed, useSlots, h } from 'vue'\nimport type { ProFormSchema, RenderCallbackParams } from '../types'\n\nconst props = defineProps<{\n schema: ProFormSchema\n formModel: Record<string, unknown>\n formDisabled?: boolean\n autoPlaceholder?: boolean\n formActionType?: import('../types').FormActionType\n}>()\n\nconst slots = useSlots()\n\nconst renderParams = computed<RenderCallbackParams>(() => ({\n schema: props.schema,\n values: props.formModel,\n model: props.formModel,\n field: props.schema.field,\n}))\n\nconst shouldRender = computed(() => {\n const ifShow = props.schema.ifShow\n if (ifShow === undefined) return true\n if (typeof ifShow === 'boolean') return ifShow\n return ifShow(renderParams.value)\n})\n\nconst shouldShow = computed(() => {\n const show = props.schema.show\n if (show === undefined) return true\n if (typeof show === 'boolean') return show\n return show(renderParams.value)\n})\n\nconst effectiveDisabled = computed(() => {\n if (props.formDisabled) return true\n const dyn = props.schema.dynamicDisabled\n if (dyn === undefined) return false\n if (typeof dyn === 'boolean') return dyn\n return dyn(renderParams.value)\n})\n\nconst effectiveRules = computed(() => {\n const dyn = props.schema.dynamicRules\n if (!dyn) return props.schema.rules\n if (Array.isArray(dyn)) return dyn\n return dyn(renderParams.value)\n})\n\nconst effectiveComponentPropsAndListeners = computed(() => {\n const cp = props.schema.componentProps\n if (!cp) return { props: {}, listeners: {} }\n const raw = typeof cp === 'function'\n ? cp({\n ...renderParams.value,\n formActionType: props.formActionType,\n })\n : { ...cp }\n const propsOnly: Record<string, unknown> = {}\n const listeners: Record<string, (...args: unknown[]) => unknown> = {}\n for (const [key, value] of Object.entries(raw)) {\n if (key.length > 2 && /^on[A-Za-z]/.test(key) && typeof value === 'function') {\n const eventName = key.slice(2).charAt(0).toLowerCase() + key.slice(3)\n listeners[eventName] = value as (...args: unknown[]) => unknown\n } else {\n propsOnly[key] = value\n }\n }\n return { props: propsOnly, listeners }\n})\n\nconst effectiveComponentProps = computed(() => effectiveComponentPropsAndListeners.value.props)\nconst effectiveComponentListeners = computed(() => effectiveComponentPropsAndListeners.value.listeners)\n\nconst hasSlot = computed(() => !!slots.default)\n\nconst getOptions = (props: Record<string, unknown>): Array<{ label: string; value: unknown }> | undefined => {\n const opts = props?.options\n return Array.isArray(opts) ? opts : undefined\n}\n\nconst renderComponent = computed(() => {\n const renderFn = props.schema.render\n if (!renderFn) return null\n return {\n render() {\n const result = renderFn(renderParams.value)\n if (Array.isArray(result)) {\n return h('span', result)\n }\n return result\n },\n }\n})\n</script>\n\n<style scoped>\n.ecp-pro-form-item__help-icon {\n margin-left: 4px;\n color: #909399;\n cursor: help;\n font-size: 14px;\n}\n.ecp-pro-form-item__help-icon:hover {\n color: #409eff;\n}\n.ecp-pro-form-item__help-item {\n margin-bottom: 4px;\n}\n.ecp-pro-form-item__help-item:last-child {\n margin-bottom: 0;\n}\n.ecp-pro-form-item__select {\n display: block;\n}\n</style>\n","<template>\n <div ref=\"formWrapRef\" class=\"ecp-pro-form\">\n <el-form class=\"ecp-pro-form\" ref=\"formRef\" :model=\"formModel\" :rules=\"formRules\" :label-width=\"effectiveProps.labelWidth\"\n :label-position=\"effectiveProps.labelPosition\" :size=\"effectiveProps.size\" :disabled=\"effectiveProps.disabled\"\n v-bind=\"$attrs\" v-on=\"formListeners\">\n <slot name=\"formHeader\" />\n <el-row :gutter=\"effectiveProps.gutter\" :style=\"effectiveProps.baseRowStyle\">\n <template v-for=\"schema in displaySchemas\">\n <el-col v-if=\"shouldShow(schema)\" :key=\"schema.field\" v-bind=\"getColProps(schema)\"\n :offset=\"schema.colProps?.offset ?? effectiveProps.baseColProps?.offset ?? 0\" :data-field=\"schema.field\">\n <ProFormItem :schema=\"schema\" :form-model=\"formModel\" :form-disabled=\"effectiveProps.disabled\"\n :auto-placeholder=\"effectiveProps.autoSetPlaceholder\" :form-action-type=\"formActionRef\">\n <template v-if=\"slots[getSlotName(schema)]\">\n <slot :name=\"getSlotName(schema)\" :model=\"formModel\" :schema=\"schema\" :field=\"schema.field\"\n :values=\"formModel\" />\n </template>\n </ProFormItem>\n </el-col>\n </template>\n <el-col class=\"ecp-pro-form_col\" v-if=\"effectiveProps.showActionButtonGroup\"\n v-bind=\"hasMoreFields ? { span: 24 } : effectiveProps.actionColOptions || { span: 6 }\">\n <FormActions :show-action-button-group=\"effectiveProps.showActionButtonGroup\"\n :show-submit-button=\"effectiveProps.showSubmitButton\" :show-reset-button=\"effectiveProps.showResetButton\"\n :submit-button-text=\"effectiveProps.submitButtonText\" :reset-button-text=\"effectiveProps.resetButtonText\"\n :submit-button-icon=\"effectiveProps.submitButtonIcon\" :reset-button-icon=\"effectiveProps.resetButtonIcon\"\n :submit-loading=\"submitLoading\" :show-advanced-button=\"effectiveProps.showAdvancedButton\"\n :has-more-fields=\"hasMoreFields\" :collapsed=\"collapsed\" :action-col-options=\"effectiveActionColOptions\"\n @submit=\"handleSubmit\" @reset=\"handleReset\" @toggle=\"collapsed = !collapsed\">\n <template slot=\"submitBefore\">\n <slot name=\"submitBefore\" />\n </template>\n <template slot=\"resetBefore\">\n <slot name=\"resetBefore\" />\n </template>\n <template slot=\"advanceBefore\">\n <slot name=\"advanceBefore\" />\n </template>\n <template slot=\"advanceAfter\">\n <slot name=\"advanceAfter\" />\n </template>\n <template slot=\"actions\">\n <slot name=\"actions\" />\n </template>\n </FormActions>\n </el-col>\n </el-row>\n <el-button v-if=\"effectiveProps.showAdvancedButton && hasMoreFields\" type=\"text\" class=\"ecp-form-actions__advance\"\n @click=\"collapsed = !collapsed\">\n <i class=\"el-icon-d-arrow-left\" :class=\"collapsed ? 'down' : 'up'\" />\n {{ collapsed ? '展开' : '收起' }}\n </el-button>\n <slot name=\"formFooter\" />\n </el-form>\n </div>\n</template>\n\n<script setup lang=\"ts\">\nimport { ref, computed, watch, useSlots, onMounted, onUnmounted } from 'vue'\nimport ProFormItem from './ProFormItem.vue'\nimport FormActions from './FormActions.vue'\nimport type { ProFormSchema, ProFormProps, FormActionType, ColEx, ScrollToFieldOptions, FormListeners } from '../types'\n\nconst props = withDefaults(\n defineProps<{\n schemas?: ProFormSchema[]\n initialValues?: Record<string, unknown>\n labelWidth?: string\n labelPosition?: 'left' | 'right' | 'top'\n gutter?: number\n size?: 'medium' | 'small' | 'large'\n disabled?: boolean\n baseColProps?: ColEx\n baseRowStyle?: Record<string, string | number>\n autoSetPlaceholder?: boolean\n showSubmitButton?: boolean\n showResetButton?: boolean\n submitButtonText?: string\n resetButtonText?: string\n submitButtonIcon?: string\n resetButtonIcon?: string\n showActionButtonGroup?: boolean\n actionColOptions?: ColEx\n showAdvancedButton?: boolean\n autoAdvancedLine?: number\n alwaysShowLines?: number\n submitFunc?: () => Promise<void>\n resetFunc?: () => Promise<void>\n submitOnReset?: boolean\n formListeners?: FormListeners\n }>(),\n {\n labelWidth: '120px',\n labelPosition: 'right',\n gutter: 24,\n size: 'medium',\n autoSetPlaceholder: true,\n showSubmitButton: true,\n showResetButton: true,\n submitButtonText: '提交',\n resetButtonText: '重置',\n submitButtonIcon: 'el-icon-search',\n resetButtonIcon: 'el-icon-refresh-left',\n showActionButtonGroup: true,\n showAdvancedButton: false,\n autoAdvancedLine: 3,\n alwaysShowLines: 1,\n baseColProps: () => ({ xs: 24, sm: 12, md: 12, lg: 8, xl: 6 }),\n actionColOptions: () => ({ xs: 24, sm: 12, md: 12, lg: 8, xl: 6 }),\n submitOnReset: false,\n }\n)\n\nconst emit = defineEmits<{\n (e: 'submit', values: Record<string, unknown>): void\n (e: 'reset'): void\n (e: 'register', formAction: FormActionType): void\n}>()\nconst slots = useSlots()\nconst formRef = ref()\nconst formWrapRef = ref()\nconst submitLoading = ref(false)\nconst collapsed = ref(true)\nconst formModel = ref<Record<string, unknown>>({})\nconst formRules = ref<Record<string, unknown[]>>({})\nconst innerSchemas = ref<ProFormSchema[]>([])\nconst innerProps = ref<Partial<ProFormProps>>({})\n\n/** Element UI 栅格断点 (px) */\nconst BREAKPOINTS = { xl: 1920, lg: 1200, md: 992, sm: 768 }\n\n/** 根据当前视口宽度获取 ColEx 的有效 span(与 el-col 断点逻辑一致) */\nconst getEffectiveSpan = (colProps?: ColEx | null, baseColProps?: ColEx | null, width?: number): number => {\n const w = width ?? (typeof window !== 'undefined' ? window.innerWidth : 1920)\n const col = colProps ?? {}\n const base = baseColProps ?? {}\n const fallback = base.span ?? 8\n if (w >= BREAKPOINTS.xl) return col.xl ?? base.xl ?? col.lg ?? base.lg ?? col.md ?? base.md ?? col.sm ?? base.sm ?? col.xs ?? base.xs ?? col.span ?? fallback\n if (w >= BREAKPOINTS.lg) return col.lg ?? base.lg ?? col.md ?? base.md ?? col.sm ?? base.sm ?? col.xs ?? base.xs ?? col.span ?? fallback\n if (w >= BREAKPOINTS.md) return col.md ?? base.md ?? col.sm ?? base.sm ?? col.xs ?? base.xs ?? col.span ?? fallback\n if (w >= BREAKPOINTS.sm) return col.sm ?? base.sm ?? col.xs ?? base.xs ?? col.span ?? fallback\n if (w < BREAKPOINTS.sm) return col.sm ?? base.sm ?? col.xs ?? base.xs ?? col.span ?? fallback\n return col.xs ?? base.xs ?? col.span ?? fallback\n}\n\nconst effectiveProps = computed(() => ({ ...props, ...innerProps.value }))\nconst effectiveActionColOptions = computed(() => effectiveProps.value.actionColOptions ?? { span: 24 })\n\n/** 当前视口宽度,用于响应式计算 span */\nconst windowWidth = ref(typeof window !== 'undefined' ? window.innerWidth : 1920)\n\n/** 计算前 maxLines 行能容纳的 schema 数量(考虑栅格断点,每个 field 可有自己的 span) */\nconst getVisibleSchemaCount = (\n schemas: ProFormSchema[],\n baseColProps: ColEx | undefined,\n maxLines: number,\n width: number\n) => {\n let remaining = 24\n let rows = 1\n let count = 0\n for (const schema of schemas) {\n const span = getEffectiveSpan(schema.colProps, baseColProps, width)\n if (span > remaining) {\n rows++\n if (rows > maxLines) break\n remaining = 24 - span\n } else {\n remaining -= span\n }\n count++\n }\n return count\n}\n\nconst hasMoreFields = computed(() => {\n const schemas = innerSchemas.value.filter((s) => !s.hidden)\n\n if (!effectiveProps.value.showAdvancedButton) return false\n const lines = effectiveProps.value.alwaysShowLines ?? 1\n const baseColProps = effectiveProps.value.baseColProps\n const maxVisible = getVisibleSchemaCount(schemas, baseColProps, lines, windowWidth.value)\n console.log(schemas.length, maxVisible)\n return schemas.length > maxVisible\n})\n\nconst formListeners = computed((): FormListeners => {\n return effectiveProps.value.formListeners ?? {}\n})\n\nconst displaySchemas = computed(() => {\n const schemas = innerSchemas.value.filter((s) => {\n return shouldShow(s)\n })\n if (!effectiveProps.value.showAdvancedButton || !collapsed.value) return schemas\n const lines = effectiveProps.value.alwaysShowLines ?? 1\n const baseColProps = effectiveProps.value.baseColProps\n const maxVisible = getVisibleSchemaCount(schemas, baseColProps, lines, windowWidth.value)\n return schemas.slice(0, maxVisible)\n})\n\nconst shouldShow = (schema: ProFormSchema) => {\n let ifShow = true\n let show = true\n if (typeof schema.ifShow === 'function') {\n ifShow = schema.ifShow({ schema, values: formModel.value, model: formModel.value, field: schema.field })\n }\n if (typeof schema.ifShow === 'boolean') {\n ifShow = schema.ifShow\n }\n if (typeof schema.show === 'function') {\n show = schema.show({ schema, values: formModel.value, model: formModel.value, field: schema.field })\n }\n if (typeof schema.show === 'boolean') {\n show = schema.show\n }\n return ifShow && show\n}\nconst getColProps = (schema: ProFormSchema) => {\n return schema.colProps ?? effectiveProps.value.baseColProps ?? {}\n}\nconst getSlotName = (schema: ProFormSchema) => schema.slot || schema.field\n\nconst initForm = () => {\n const model: Record<string, unknown> = {}\n const rules: Record<string, unknown[]> = {}\n const initialValues = effectiveProps.value.initialValues ?? props.initialValues\n innerSchemas.value.forEach((schema) => {\n model[schema.field] = schema.defaultValue ?? initialValues?.[schema.field]\n if (schema.rules?.length) rules[schema.field] = schema.rules\n })\n formModel.value = { ...formModel.value, ...model }\n formRules.value = rules\n}\n\nconst filterByIfShow = (values: Record<string, unknown>) => {\n const result = { ...values }\n innerSchemas.value.forEach((schema) => {\n const ifShow = schema.ifShow\n if (ifShow === undefined) return\n const visible = typeof ifShow === 'boolean' ? ifShow : ifShow({ schema, values, model: values, field: schema.field })\n if (!visible) delete result[schema.field]\n })\n return result\n}\n\nconst processFieldMapToTime = (values: Record<string, unknown>) => {\n const filtered = filterByIfShow(values)\n const fieldMap = innerProps.value.fieldMapToTime\n if (!fieldMap?.length) return filtered\n const result = { ...filtered }\n fieldMap.forEach(([field, [startKey, endKey]]) => {\n const val = result[field]\n if (Array.isArray(val) && val.length === 2) {\n delete result[field]\n ; (result as Record<string, unknown>)[startKey] = val[0]\n ; (result as Record<string, unknown>)[endKey] = val[1]\n }\n })\n return result\n}\n\nconst handleSubmit = async () => {\n try {\n await formRef.value?.validate()\n if (effectiveProps.value.submitFunc) {\n await effectiveProps.value.submitFunc()\n } else {\n submitLoading.value = true\n emit('submit', processFieldMapToTime({ ...formModel.value }))\n }\n } catch (e) {\n console.error('Form validation failed:', e)\n } finally {\n submitLoading.value = false\n }\n}\n\nconst handleReset = async () => {\n if (effectiveProps.value.resetFunc) {\n await effectiveProps.value.resetFunc()\n } else {\n formRef.value?.resetFields()\n initForm()\n emit('reset')\n if (effectiveProps.value.submitOnReset) await handleSubmit()\n }\n}\n\nconst setFieldsValue = (values: Record<string, unknown>) => {\n formModel.value = { ...formModel.value, ...values }\n return Promise.resolve()\n}\n\nconst getFieldsValue = () => processFieldMapToTime({ ...formModel.value })\n\nconst resetFields = async () => {\n formRef.value?.resetFields()\n initForm()\n}\n\nconst validate = (nameList?: string[]) =>\n formRef.value?.validate(nameList) ?? Promise.resolve()\n\nconst validateFields = (nameList?: string[]) => {\n if (!formRef.value) return Promise.resolve()\n if (!nameList?.length) return formRef.value.validate()\n return Promise.all(nameList.map((prop) => new Promise((resolve, reject) => {\n formRef.value.validateField(prop, (valid: boolean) => (valid ? resolve(undefined) : reject(new Error('Validation failed'))))\n })))\n}\n\nconst scrollToField = async (name: string, options?: ScrollToFieldOptions) => {\n const el = formWrapRef.value?.querySelector(`[data-field=\"${name}\"]`)\n if (el) {\n el.scrollIntoView({ behavior: options?.behavior ?? 'smooth', block: options?.block ?? 'nearest' })\n }\n return Promise.resolve()\n}\n\nconst clearValidate = (name?: string | string[]) => {\n formRef.value?.clearValidate(name)\n}\n\nconst updateSchema = async (data: Partial<ProFormSchema> | Partial<ProFormSchema>[]) => {\n const list = Array.isArray(data) ? data : [data]\n list.forEach((item) => {\n const idx = innerSchemas.value.findIndex((s) => s.field === item.field)\n if (idx >= 0) innerSchemas.value[idx] = { ...innerSchemas.value[idx], ...item }\n })\n}\n\nconst appendSchemaByField = async (schema: ProFormSchema, prefixField?: string, first?: boolean) => {\n if (first) innerSchemas.value.unshift(schema)\n else if (prefixField) {\n const idx = innerSchemas.value.findIndex((s) => s.field === prefixField)\n innerSchemas.value.splice(idx + 1, 0, schema)\n } else innerSchemas.value.push(schema)\n initForm()\n}\n\nconst removeSchemaByField = async (field: string | string[]) => {\n const fields = Array.isArray(field) ? field : [field]\n innerSchemas.value = innerSchemas.value.filter((s) => !fields.includes(s.field))\n}\n\nconst setProps = async (formProps: Partial<ProFormProps>) => {\n innerProps.value = { ...innerProps.value, ...formProps }\n if (formProps.schemas) {\n innerSchemas.value = [...formProps.schemas]\n debugger\n initForm()\n }\n}\n\nconst formActionRef: FormActionType = {\n getFieldsValue,\n setFieldsValue,\n resetFields,\n validate,\n validateFields,\n submit: handleSubmit,\n scrollToField,\n clearValidate,\n updateSchema,\n appendSchemaByField,\n removeSchemaByField,\n setProps,\n}\n\ndefineExpose(formActionRef)\n\nconst syncSchemas = () => {\n innerSchemas.value = [...(props.schemas ?? [])]\n initForm()\n}\n\nconst handleResize = () => {\n if (typeof window !== 'undefined') windowWidth.value = window.innerWidth\n}\n\nonMounted(() => {\n syncSchemas()\n emit('register', formActionRef)\n if (typeof window !== 'undefined') window.addEventListener('resize', handleResize)\n})\n\nonUnmounted(() => {\n if (typeof window !== 'undefined') window.removeEventListener('resize', handleResize)\n})\n\nwatch(() => [props.schemas, props.initialValues], syncSchemas, { deep: true })\n</script>\n\n<style scoped>\n.ecp-pro-form {\n padding: 16px;\n position: relative;\n}\n\n.ecp-pro-form__advance {\n margin-bottom: 16px;\n}\n\n.ecp-pro-form_col {\n position: relative;\n float: right;\n}\n\n.el-icon-d-arrow-left.up {\n transform: rotate(90deg);\n}\n\n.el-icon-d-arrow-left.down {\n transform: rotate(-90deg);\n}\n\n.ecp-form-actions__advance {\n position: absolute;\n bottom: 0;\n left: 50%;\n transform: translate(-50%, -50%);\n}\n</style>\n","import { ref, watch, unref, type Ref } from 'vue'\nimport type { ProFormSchema, ProFormProps, FormActionType } from '../types'\n\nexport interface UseFormProps extends ProFormProps {\n schemas?: ProFormSchema[]\n}\n\n/** 支持 ref/computed 的 props(参考 Vben Admin:参数 props 内的值可以是 computed 或者 ref 类型) */\nexport type UseFormPropsReactive = UseFormProps | Ref<UseFormProps | undefined>\n\nexport interface UseFormReturn {\n /** 用于 @register,接收表单实例的 formAction */\n register: (formAction: FormActionType) => void\n formAction: { value: FormActionType | null }\n getFieldsValue: () => Record<string, unknown>\n setFieldsValue: (values: Record<string, unknown>) => Promise<void>\n resetFields: () => Promise<void>\n validate: (nameList?: string[]) => Promise<unknown>\n validateFields: (nameList?: string[]) => Promise<unknown>\n submit: () => Promise<void>\n scrollToField: (name: string, options?: import('../types').ScrollToFieldOptions) => Promise<void>\n clearValidate: (name?: string | string[]) => void\n updateSchema: (data: Partial<ProFormSchema> | Partial<ProFormSchema>[]) => Promise<void>\n appendSchemaByField: (schema: ProFormSchema, prefixField?: string, first?: boolean) => Promise<void>\n removeSchemaByField: (field: string | string[]) => Promise<void>\n setProps: (props: Partial<ProFormProps>) => Promise<void>\n}\n\nexport function useForm(props?: UseFormPropsReactive): [UseFormReturn['register'], Omit<UseFormReturn, 'register'>] {\n const formAction = ref<FormActionType | null>(null)\n const formPropsRef = ref<UseFormProps | undefined>(props ? unref(props as Ref<UseFormProps | undefined>) : undefined)\n\n const getFormProps = () => (props ? unref(props as Ref<UseFormProps | undefined>) : undefined) as UseFormProps | undefined\n\n const register = (action: FormActionType) => {\n formAction.value = action\n const formProps = getFormProps()\n debugger\n if (formProps && Object.keys(formProps).length > 0) {\n action.setProps(formProps)\n }\n }\n\n if (props) {\n watch(\n () => getFormProps(),\n (formProps) => {\n formPropsRef.value = formProps\n if (formProps && formAction.value) {\n formAction.value.setProps(formProps)\n }\n },\n { deep: true }\n )\n }\n\n const getFieldsValue = () => formAction.value?.getFieldsValue() ?? {}\n\n const setFieldsValue = async (values: Record<string, unknown>) => {\n await formAction.value?.setFieldsValue(values)\n }\n\n const resetFields = async () => {\n await formAction.value?.resetFields()\n }\n\n const validate = (nameList?: string[]) =>\n formAction.value?.validate(nameList) ?? Promise.resolve()\n\n const validateFields = (nameList?: string[]) =>\n formAction.value?.validateFields(nameList) ?? Promise.resolve()\n\n const submit = () => formAction.value?.submit() ?? Promise.resolve()\n\n const scrollToField = (name: string, options?: import('../types').ScrollToFieldOptions) =>\n formAction.value?.scrollToField(name, options) ?? Promise.resolve()\n\n const clearValidate = (name?: string | string[]) => {\n formAction.value?.clearValidate(name)\n }\n\n const updateSchema = (data: Partial<ProFormSchema> | Partial<ProFormSchema>[]) =>\n formAction.value?.updateSchema(data) ?? Promise.resolve()\n\n const appendSchemaByField = (schema: ProFormSchema, prefixField?: string, first?: boolean) =>\n formAction.value?.appendSchemaByField(schema, prefixField, first) ?? Promise.resolve()\n\n const removeSchemaByField = (field: string | string[]) =>\n formAction.value?.removeSchemaByField(field) ?? Promise.resolve()\n\n const setProps = async (formProps: Partial<ProFormProps>) => {\n formPropsRef.value = { ...formPropsRef.value, ...formProps }\n await formAction.value?.setProps(formProps)\n }\n\n const result: UseFormReturn = {\n register,\n formAction,\n getFieldsValue,\n setFieldsValue,\n resetFields,\n validate,\n validateFields,\n submit,\n scrollToField,\n clearValidate,\n updateSchema,\n appendSchemaByField,\n removeSchemaByField,\n setProps,\n }\n\n return [register, result]\n}\n","import type { VueConstructor } from 'vue'\n// import ProTable from './ProTable'\nimport ProForm, { ProFormItem, FormActions } from './ProForm'\n// import ProCard from './ProCard'\n// import ProDescriptions from './ProDescriptions'\nimport { useForm } from './ProForm/useForm'\n\nexport { ProForm, ProFormItem, FormActions, useForm }\nexport * from './types'\n\nconst components = [\n // { name: 'ProTable', component: ProTable },\n { name: 'ProForm', component: ProForm },\n { name: 'ProFormItem', component: ProFormItem },\n { name: 'FormActions', component: FormActions }\n // { name: 'ProCard', component: ProCard },\n // { name: 'ProDescriptions', component: ProDescriptions },\n]\n\nexport function install(Vue: VueConstructor) {\n components.forEach(({ name, component }) => {\n Vue.component(name, component)\n })\n}\n\nexport default {\n install,\n // ProTable,\n ProForm,\n // ProCard,\n // ProDescriptions,\n}\n"],"names":["slots","useSlots","renderParams","computed","props","shouldRender","ifShow","shouldShow","show","effectiveDisabled","dyn","effectiveRules","effectiveComponentPropsAndListeners","cp","raw","propsOnly","listeners","key","value","eventName","effectiveComponentProps","effectiveComponentListeners","hasSlot","getOptions","opts","renderComponent","renderFn","result","h","formRef","ref","formWrapRef","submitLoading","collapsed","formModel","formRules","innerSchemas","innerProps","BREAKPOINTS","getEffectiveSpan","colProps","baseColProps","width","w","col","base","fallback","effectiveProps","effectiveActionColOptions","windowWidth","getVisibleSchemaCount","schemas","maxLines","remaining","rows","count","schema","span","hasMoreFields","s","lines","maxVisible","formListeners","displaySchemas","getColProps","getSlotName","initForm","model","rules","initialValues","_a","filterByIfShow","values","processFieldMapToTime","filtered","fieldMap","field","startKey","endKey","val","handleSubmit","emit","e","handleReset","setFieldsValue","getFieldsValue","resetFields","validate","nameList","validateFields","prop","resolve","reject","valid","scrollToField","name","options","el","clearValidate","updateSchema","data","item","idx","appendSchemaByField","prefixField","first","removeSchemaByField","fields","setProps","formProps","formActionRef","expose","syncSchemas","handleResize","onMounted","onUnmounted","watch","useForm","formAction","formPropsRef","unref","getFormProps","register","action","components","ProForm","ProFormItem","FormActions","install","Vue","component","index"],"mappings":";;;;;;;;;;;iBAoJMA,IAAQC,MAERC,IAAeC,EAA+B,OAAO;AAAA,MACzD,QAAQC,EAAM;AAAA,MACd,QAAQA,EAAM;AAAA,MACd,OAAOA,EAAM;AAAA,MACb,OAAOA,EAAM,OAAO;AAAA,IACpB,EAAA,GAEIC,IAAeF,EAAS,MAAM;AAC5B,YAAAG,IAASF,EAAM,OAAO;AAC5B,aAAIE,MAAW,SAAkB,KAC7B,OAAOA,KAAW,YAAkBA,IACjCA,EAAOJ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A6B;;AACvC,OAAAzB,IAAAgD,EAAA,UAAA,QAAAhD,EAAO,cAAcyB;AAAA,IAAI;AAAA,IA4BpC,cAzBmB,CAACK,MACpB;;AAAA,eAAA9B,IAAAgD,EAAW,UAAX,gBAAAhD,EAAkB,aAAa8B,OAAS,QAAQ;;IAyBhD,qBAvB0B,CAAC5C,GAAuBgD,GAAsBC,MACxE;;AAAA,eAAAnC,IAAAgD,EAAW,UAAX,gBAAAhD,EAAkB,oBAAoBd,GAAQgD,GAAaC,OAAU,QAAQ,QAAQ;AAAA;AAAA,IAuBrF,qBArB0B,CAAC7B,MAC3B;;AAAA,eAAAN,IAAAgD,EAAW,UAAX,gBAAAhD,EAAkB,oBAAoBM,OAAU,QAAQ;;IAqBxD,UAnBe,OAAOiC,MAAqC;;AAC3D,MAAAU,EAAa,QAAQ,EAAE,GAAGA,EAAa,OAAO,GAAGV,KAC3C,QAAAvC,IAAAgD,EAAW,UAAX,gBAAAhD,EAAkB,SAASuC;AAAA,IAAS;AAAA,EAiB1C,CAGsB;AAC1B;ACvGA,MAAMe,KAAa;AAAA;AAAA,EAEjB,EAAE,MAAM,WAAW,WAAWC,GAAQ;AAAA,EACtC,EAAE,MAAM,eAAe,WAAWC,GAAY;AAAA,EAC9C,EAAE,MAAM,eAAe,WAAWC,GAAY;AAAA;AAAA;AAGhD;AAEO,SAASC,GAAQC,GAAqB;AAC3C,EAAAL,GAAW,QAAQ,CAAC,EAAE,MAAA7B,GAAM,WAAAmC,QAAgB;AACtC,IAAAD,EAAA,UAAUlC,GAAMmC,CAAS;AAAA,EAAA,CAC9B;AACH;AAEA,MAAeC,KAAA;AAAA,EACb,SAAAH;AAAA;AAAA,EAEA,SAAAH;AAAA;AAAA;AAGF;"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
(function(g,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],i):(g=typeof globalThis<"u"?globalThis:g||self,i(g.ElementComponentPro={},g.Vue))})(this,function(g,i){"use strict";var q=document.createElement("style");q.textContent=`.ecp-pro-form-item__help-icon[data-v-0e0e5ebb]{margin-left:4px;color:#909399;cursor:help;font-size:14px}.ecp-pro-form-item__help-icon[data-v-0e0e5ebb]:hover{color:#409eff}.ecp-pro-form-item__help-item[data-v-0e0e5ebb]{margin-bottom:4px}.ecp-pro-form-item__help-item[data-v-0e0e5ebb]:last-child{margin-bottom:0}.ecp-pro-form-item__select[data-v-0e0e5ebb]{display:block}.ecp-form-actions[data-v-489c88d2]{text-align:right}.ecp-form-actions__advance[data-v-489c88d2]{margin-right:8px}.el-icon-d-arrow-left.up[data-v-489c88d2]{transform:rotate(90deg)}.el-icon-d-arrow-left.down[data-v-489c88d2]{transform:rotate(-90deg)}.ecp-pro-form[data-v-d75b0fb1]{padding:16px;position:relative}.ecp-pro-form__advance[data-v-d75b0fb1]{margin-bottom:16px}.ecp-pro-form_col[data-v-d75b0fb1]{position:relative;float:right}.el-icon-d-arrow-left.up[data-v-d75b0fb1]{transform:rotate(90deg)}.el-icon-d-arrow-left.down[data-v-d75b0fb1]{transform:rotate(-90deg)}.ecp-form-actions__advance[data-v-d75b0fb1]{position:absolute;bottom:0;left:50%;transform:translate(-50%,-50%)}
|
|
2
|
+
`,document.head.appendChild(q);const le=i.defineComponent({__name:"ProFormItem",props:{schema:null,formModel:null,formDisabled:{type:Boolean},autoPlaceholder:{type:Boolean},formActionType:null},setup(b){const e=b,l=i.useSlots(),t=i.computed(()=>({schema:e.schema,values:e.formModel,model:e.formModel,field:e.schema.field})),s=i.computed(()=>{const f=e.schema.ifShow;return f===void 0?!0:typeof f=="boolean"?f:f(t.value)}),y=i.computed(()=>{const f=e.schema.show;return f===void 0?!0:typeof f=="boolean"?f:f(t.value)}),P=i.computed(()=>{if(e.formDisabled)return!0;const f=e.schema.dynamicDisabled;return f===void 0?!1:typeof f=="boolean"?f:f(t.value)}),C=i.computed(()=>{const f=e.schema.dynamicRules;return f?Array.isArray(f)?f:f(t.value):e.schema.rules}),h=i.computed(()=>{const f=e.schema.componentProps;if(!f)return{props:{},listeners:{}};const m=typeof f=="function"?f({...t.value,formActionType:e.formActionType}):{...f},k={},S={};for(const[n,u]of Object.entries(m))if(n.length>2&&/^on[A-Za-z]/.test(n)&&typeof u=="function"){const x=n.slice(2).charAt(0).toLowerCase()+n.slice(3);S[x]=u}else k[n]=u;return{props:k,listeners:S}}),p=i.computed(()=>h.value.props),M=i.computed(()=>h.value.listeners),_=i.computed(()=>!!l.default),w=f=>{const m=f==null?void 0:f.options;return Array.isArray(m)?m:void 0},F=i.computed(()=>{const f=e.schema.render;return f?{render(){const m=f(t.value);return Array.isArray(m)?i.h("span",m):m}}:null});return{__sfc:!0,props:e,slots:l,renderParams:t,shouldRender:s,shouldShow:y,effectiveDisabled:P,effectiveRules:C,effectiveComponentPropsAndListeners:h,effectiveComponentProps:p,effectiveComponentListeners:M,hasSlot:_,getOptions:w,renderComponent:F}}}),Pe="";function T(b,e,l,t,s,y,P,C){var h=typeof b=="function"?b.options:b;e&&(h.render=e,h.staticRenderFns=l,h._compiled=!0),t&&(h.functional=!0),y&&(h._scopeId="data-v-"+y);var p;if(P?(p=function(w){w=w||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,!w&&typeof __VUE_SSR_CONTEXT__<"u"&&(w=__VUE_SSR_CONTEXT__),s&&s.call(this,w),w&&w._registeredComponents&&w._registeredComponents.add(P)},h._ssrRegister=p):s&&(p=C?function(){s.call(this,(h.functional?this.parent:this).$root.$options.shadowRoot)}:s),p)if(h.functional){h._injectStyles=p;var M=h.render;h.render=function(F,f){return p.call(f),M(F,f)}}else{var _=h.beforeCreate;h.beforeCreate=_?[].concat(_,p):[p]}return{exports:b,options:h}}var ne=function(){var e=this,l=e._self._c,t=e._self._setupProxy;return t.shouldRender?l("el-form-item",{directives:[{name:"show",rawName:"v-show",value:t.shouldShow,expression:"shouldShow"}],attrs:{prop:e.schema.field,required:e.schema.required,rules:t.effectiveRules}},[l("template",{slot:"label"},[l("span",[e._v(e._s(e.schema.label))]),e.schema.helpMessage?l("el-tooltip",e._b({attrs:{placement:"top",effect:"light"}},"el-tooltip",e.schema.helpComponentProps||{},!1),[l("template",{slot:"content"},[Array.isArray(e.schema.helpMessage)?e._l(e.schema.helpMessage,function(s,y){return l("div",{key:y,staticClass:"ecp-pro-form-item__help-item"},[e._v(" "+e._s(s)+" ")])}):l("span",[e._v(e._s(e.schema.helpMessage))])],2),l("i",{staticClass:"el-icon-question ecp-pro-form-item__help-icon"})],2):e._e()],1),e.schema.render?[l(t.renderComponent,{tag:"component"})]:t.hasSlot?e._t("default",null,{model:e.formModel,schema:e.schema,field:e.schema.field,values:e.formModel}):[e.schema.component==="input"||!e.schema.component?l("el-input",e._g(e._b({attrs:{placeholder:e.schema.placeholder||(e.autoPlaceholder?`请输入${e.schema.label}`:void 0),disabled:t.effectiveDisabled},model:{value:e.formModel[e.schema.field],callback:function(s){e.$set(e.formModel,e.schema.field,s)},expression:"formModel[schema.field]"}},"el-input",t.effectiveComponentProps,!1),t.effectiveComponentListeners)):e.schema.component==="input-number"?l("el-input-number",e._g(e._b({attrs:{placeholder:e.schema.placeholder,disabled:t.effectiveDisabled},model:{value:e.formModel[e.schema.field],callback:function(s){e.$set(e.formModel,e.schema.field,s)},expression:"formModel[schema.field]"}},"el-input-number",t.effectiveComponentProps,!1),t.effectiveComponentListeners)):e.schema.component==="select"?l("el-select",e._g(e._b({staticClass:"ecp-pro-form-item__select",attrs:{placeholder:e.schema.placeholder||(e.autoPlaceholder?`请选择${e.schema.label}`:void 0),disabled:t.effectiveDisabled},model:{value:e.formModel[e.schema.field],callback:function(s){e.$set(e.formModel,e.schema.field,s)},expression:"formModel[schema.field]"}},"el-select",t.effectiveComponentProps,!1),t.effectiveComponentListeners),e._l(t.getOptions(t.effectiveComponentProps)||[],function(s){return l("el-option",{key:String(s.value),attrs:{label:s.label,value:s.value}})}),1):e.schema.component==="date-picker"?l("el-date-picker",e._g(e._b({attrs:{placeholder:e.schema.placeholder||(e.autoPlaceholder?`请选择${e.schema.label}`:void 0),disabled:t.effectiveDisabled},model:{value:e.formModel[e.schema.field],callback:function(s){e.$set(e.formModel,e.schema.field,s)},expression:"formModel[schema.field]"}},"el-date-picker",t.effectiveComponentProps,!1),t.effectiveComponentListeners)):e.schema.component==="date-range"?l("el-date-picker",e._g(e._b({attrs:{type:"daterange","range-separator":"至","start-placeholder":"开始日期","end-placeholder":"结束日期","value-format":"yyyy-MM-dd",disabled:t.effectiveDisabled},model:{value:e.formModel[e.schema.field],callback:function(s){e.$set(e.formModel,e.schema.field,s)},expression:"formModel[schema.field]"}},"el-date-picker",t.effectiveComponentProps,!1),t.effectiveComponentListeners)):e.schema.component==="switch"?l("el-switch",e._g(e._b({attrs:{disabled:t.effectiveDisabled},model:{value:e.formModel[e.schema.field],callback:function(s){e.$set(e.formModel,e.schema.field,s)},expression:"formModel[schema.field]"}},"el-switch",t.effectiveComponentProps,!1),t.effectiveComponentListeners)):e.schema.component==="cascader"?l("el-cascader",e._g(e._b({attrs:{placeholder:e.schema.placeholder||(e.autoPlaceholder?`请选择${e.schema.label}`:void 0),disabled:t.effectiveDisabled},model:{value:e.formModel[e.schema.field],callback:function(s){e.$set(e.formModel,e.schema.field,s)},expression:"formModel[schema.field]"}},"el-cascader",t.effectiveComponentProps,!1),t.effectiveComponentListeners)):e.schema.component==="checkbox"?l("el-checkbox-group",e._g(e._b({attrs:{disabled:t.effectiveDisabled},model:{value:e.formModel[e.schema.field],callback:function(s){e.$set(e.formModel,e.schema.field,s)},expression:"formModel[schema.field]"}},"el-checkbox-group",t.effectiveComponentProps,!1),t.effectiveComponentListeners),e._l(t.getOptions(t.effectiveComponentProps)||[],function(s){return l("el-checkbox",{key:String(s.value),attrs:{label:s.value}},[e._v(" "+e._s(s.label)+" ")])}),1):e.schema.component==="radio"?l("el-radio-group",e._g(e._b({attrs:{disabled:t.effectiveDisabled},model:{value:e.formModel[e.schema.field],callback:function(s){e.$set(e.formModel,e.schema.field,s)},expression:"formModel[schema.field]"}},"el-radio-group",t.effectiveComponentProps,!1),t.effectiveComponentListeners),e._l(t.getOptions(t.effectiveComponentProps)||[],function(s){return l("el-radio",{key:String(s.value),attrs:{label:s.value}},[e._v(" "+e._s(s.label)+" ")])}),1):e._e()]],2):e._e()},ae=[],re=T(le,ne,ae,!1,null,"0e0e5ebb",null,null);const V=re.exports,ie=i.defineComponent({__name:"FormActions",props:{showActionButtonGroup:{type:Boolean,default:!0},showSubmitButton:{type:Boolean,default:!0},showResetButton:{type:Boolean,default:!0},submitButtonText:{default:"提交"},resetButtonText:{default:"重置"},submitButtonIcon:{default:"el-icon-search"},resetButtonIcon:{default:"el-icon-refresh-left"},submitLoading:{type:Boolean,default:!1},showAdvancedButton:{type:Boolean,default:!1},hasMoreFields:{type:Boolean,default:!1},collapsed:{type:Boolean,default:!0},actionColOptions:null},emits:["submit","reset","toggle"],setup(b){return{__sfc:!0}}}),Fe="";var ce=function(){var e=this,l=e._self._c;return e._self._setupProxy,l("div",{staticClass:"ecp-form-actions"},[e._t("submitBefore"),e.showSubmitButton?l("el-button",{attrs:{type:"primary",icon:e.submitButtonIcon,loading:e.submitLoading},on:{click:function(t){return e.$emit("submit")}}},[e._v(" "+e._s(e.submitButtonText)+" ")]):e._e(),e._t("resetBefore"),e.showResetButton?l("el-button",{attrs:{icon:e.resetButtonIcon},on:{click:function(t){return e.$emit("reset")}}},[e._v(" "+e._s(e.resetButtonText)+" ")]):e._e(),e._t("actions")],2)},fe=[],de=T(ie,ce,fe,!1,null,"489c88d2",null,null);const L=de.exports,ue=i.defineComponent({__name:"ProForm",props:{schemas:null,initialValues:null,labelWidth:{default:"120px"},labelPosition:{default:"right"},gutter:{default:24},size:{default:"medium"},disabled:{type:Boolean},baseColProps:{default:()=>({xs:24,sm:12,md:12,lg:8,xl:6})},baseRowStyle:null,autoSetPlaceholder:{type:Boolean,default:!0},showSubmitButton:{type:Boolean,default:!0},showResetButton:{type:Boolean,default:!0},submitButtonText:{default:"提交"},resetButtonText:{default:"重置"},submitButtonIcon:{default:"el-icon-search"},resetButtonIcon:{default:"el-icon-refresh-left"},showActionButtonGroup:{type:Boolean,default:!0},actionColOptions:{default:()=>({xs:24,sm:12,md:12,lg:8,xl:6})},showAdvancedButton:{type:Boolean,default:!1},autoAdvancedLine:{default:3},alwaysShowLines:{default:1},submitFunc:null,resetFunc:null,submitOnReset:{type:Boolean,default:!1},formListeners:null},emits:["submit","reset","register"],setup(b,{expose:e,emit:l}){const t=b,s=i.useSlots(),y=i.ref(),P=i.ref(),C=i.ref(!1),h=i.ref(!0),p=i.ref({}),M=i.ref({}),_=i.ref([]),w=i.ref({}),F={xl:1920,lg:1200,md:992,sm:768},f=(o,r,d)=>{const c=d??(typeof window<"u"?window.innerWidth:1920),a=o??{},v=r??{},B=v.span??8;return c>=F.xl?a.xl??v.xl??a.lg??v.lg??a.md??v.md??a.sm??v.sm??a.xs??v.xs??a.span??B:c>=F.lg?a.lg??v.lg??a.md??v.md??a.sm??v.sm??a.xs??v.xs??a.span??B:c>=F.md?a.md??v.md??a.sm??v.sm??a.xs??v.xs??a.span??B:c>=F.sm||c<F.sm?a.sm??v.sm??a.xs??v.xs??a.span??B:a.xs??v.xs??a.span??B},m=i.computed(()=>({...t,...w.value})),k=i.computed(()=>m.value.actionColOptions??{span:24}),S=i.ref(typeof window<"u"?window.innerWidth:1920),n=(o,r,d,c)=>{let a=24,v=1,B=0;for(const $ of o){const N=f($.colProps,r,c);if(N>a){if(v++,v>d)break;a=24-N}else a-=N;B++}return B},u=i.computed(()=>{const o=_.value.filter(a=>!a.hidden);if(!m.value.showAdvancedButton)return!1;const r=m.value.alwaysShowLines??1,d=m.value.baseColProps,c=n(o,d,r,S.value);return console.log(o.length,c),o.length>c}),x=i.computed(()=>m.value.formListeners??{}),R=i.computed(()=>{const o=_.value.filter(a=>U(a));if(!m.value.showAdvancedButton||!h.value)return o;const r=m.value.alwaysShowLines??1,d=m.value.baseColProps,c=n(o,d,r,S.value);return o.slice(0,c)}),U=o=>{let r=!0,d=!0;return typeof o.ifShow=="function"&&(r=o.ifShow({schema:o,values:p.value,model:p.value,field:o.field})),typeof o.ifShow=="boolean"&&(r=o.ifShow),typeof o.show=="function"&&(d=o.show({schema:o,values:p.value,model:p.value,field:o.field})),typeof o.show=="boolean"&&(d=o.show),r&&d},ye=o=>o.colProps??m.value.baseColProps??{},we=o=>o.slot||o.field,A=()=>{const o={},r={},d=m.value.initialValues??t.initialValues;_.value.forEach(c=>{var a;o[c.field]=c.defaultValue??(d==null?void 0:d[c.field]),(a=c.rules)!=null&&a.length&&(r[c.field]=c.rules)}),p.value={...p.value,...o},M.value=r},j=o=>{const r={...o};return _.value.forEach(d=>{const c=d.ifShow;if(c===void 0)return;(typeof c=="boolean"?c:c({schema:d,values:o,model:o,field:d.field}))||delete r[d.field]}),r},I=o=>{const r=j(o),d=w.value.fieldMapToTime;if(!(d!=null&&d.length))return r;const c={...r};return d.forEach(([a,[v,B]])=>{const $=c[a];Array.isArray($)&&$.length===2&&(delete c[a],c[v]=$[0],c[B]=$[1])}),c},O=async()=>{var o;try{await((o=y.value)==null?void 0:o.validate()),m.value.submitFunc?await m.value.submitFunc():(C.value=!0,l("submit",I({...p.value})))}catch(r){console.error("Form validation failed:",r)}finally{C.value=!1}},ge=async()=>{var o;m.value.resetFunc?await m.value.resetFunc():((o=y.value)==null||o.resetFields(),A(),l("reset"),m.value.submitOnReset&&await O())},X=o=>(p.value={...p.value,...o},Promise.resolve()),H=()=>I({...p.value}),K=async()=>{var o;(o=y.value)==null||o.resetFields(),A()},Z=o=>{var r;return((r=y.value)==null?void 0:r.validate(o))??Promise.resolve()},J=o=>y.value?o!=null&&o.length?Promise.all(o.map(r=>new Promise((d,c)=>{y.value.validateField(r,a=>a?d(void 0):c(new Error("Validation failed")))}))):y.value.validate():Promise.resolve(),Q=async(o,r)=>{var c;const d=(c=P.value)==null?void 0:c.querySelector(`[data-field="${o}"]`);return d&&d.scrollIntoView({behavior:(r==null?void 0:r.behavior)??"smooth",block:(r==null?void 0:r.block)??"nearest"}),Promise.resolve()},Y=o=>{var r;(r=y.value)==null||r.clearValidate(o)},ee=async o=>{(Array.isArray(o)?o:[o]).forEach(d=>{const c=_.value.findIndex(a=>a.field===d.field);c>=0&&(_.value[c]={..._.value[c],...d})})},te=async(o,r,d)=>{if(d)_.value.unshift(o);else if(r){const c=_.value.findIndex(a=>a.field===r);_.value.splice(c+1,0,o)}else _.value.push(o);A()},oe=async o=>{const r=Array.isArray(o)?o:[o];_.value=_.value.filter(d=>!r.includes(d.field))},se=async o=>{if(w.value={...w.value,...o},o.schemas){_.value=[...o.schemas];debugger;A()}},D={getFieldsValue:H,setFieldsValue:X,resetFields:K,validate:Z,validateFields:J,submit:O,scrollToField:Q,clearValidate:Y,updateSchema:ee,appendSchemaByField:te,removeSchemaByField:oe,setProps:se};e(D);const z=()=>{_.value=[...t.schemas??[]],A()},W=()=>{typeof window<"u"&&(S.value=window.innerWidth)};return i.onMounted(()=>{z(),l("register",D),typeof window<"u"&&window.addEventListener("resize",W)}),i.onUnmounted(()=>{typeof window<"u"&&window.removeEventListener("resize",W)}),i.watch(()=>[t.schemas,t.initialValues],z,{deep:!0}),{__sfc:!0,props:t,emit:l,slots:s,formRef:y,formWrapRef:P,submitLoading:C,collapsed:h,formModel:p,formRules:M,innerSchemas:_,innerProps:w,BREAKPOINTS:F,getEffectiveSpan:f,effectiveProps:m,effectiveActionColOptions:k,windowWidth:S,getVisibleSchemaCount:n,hasMoreFields:u,formListeners:x,displaySchemas:R,shouldShow:U,getColProps:ye,getSlotName:we,initForm:A,filterByIfShow:j,processFieldMapToTime:I,handleSubmit:O,handleReset:ge,setFieldsValue:X,getFieldsValue:H,resetFields:K,validate:Z,validateFields:J,scrollToField:Q,clearValidate:Y,updateSchema:ee,appendSchemaByField:te,removeSchemaByField:oe,setProps:se,formActionRef:D,syncSchemas:z,handleResize:W,ProFormItem:V,FormActions:L}}}),Be="";var me=function(){var e=this,l=e._self._c,t=e._self._setupProxy;return l("div",{ref:"formWrapRef",staticClass:"ecp-pro-form"},[l("el-form",e._g(e._b({ref:"formRef",staticClass:"ecp-pro-form",attrs:{model:t.formModel,rules:t.formRules,"label-width":t.effectiveProps.labelWidth,"label-position":t.effectiveProps.labelPosition,size:t.effectiveProps.size,disabled:t.effectiveProps.disabled}},"el-form",e.$attrs,!1),t.formListeners),[e._t("formHeader"),l("el-row",{style:t.effectiveProps.baseRowStyle,attrs:{gutter:t.effectiveProps.gutter}},[e._l(t.displaySchemas,function(s){var y,P;return[t.shouldShow(s)?l("el-col",e._b({key:s.field,attrs:{offset:((y=s.colProps)==null?void 0:y.offset)??((P=t.effectiveProps.baseColProps)==null?void 0:P.offset)??0,"data-field":s.field}},"el-col",t.getColProps(s),!1),[l(t.ProFormItem,{attrs:{schema:s,"form-model":t.formModel,"form-disabled":t.effectiveProps.disabled,"auto-placeholder":t.effectiveProps.autoSetPlaceholder,"form-action-type":t.formActionRef}},[t.slots[t.getSlotName(s)]?[e._t(t.getSlotName(s),null,{model:t.formModel,schema:s,field:s.field,values:t.formModel})]:e._e()],2)],1):e._e()]}),t.effectiveProps.showActionButtonGroup?l("el-col",e._b({staticClass:"ecp-pro-form_col"},"el-col",t.hasMoreFields?{span:24}:t.effectiveProps.actionColOptions||{span:6},!1),[l(t.FormActions,{attrs:{"show-action-button-group":t.effectiveProps.showActionButtonGroup,"show-submit-button":t.effectiveProps.showSubmitButton,"show-reset-button":t.effectiveProps.showResetButton,"submit-button-text":t.effectiveProps.submitButtonText,"reset-button-text":t.effectiveProps.resetButtonText,"submit-button-icon":t.effectiveProps.submitButtonIcon,"reset-button-icon":t.effectiveProps.resetButtonIcon,"submit-loading":t.submitLoading,"show-advanced-button":t.effectiveProps.showAdvancedButton,"has-more-fields":t.hasMoreFields,collapsed:t.collapsed,"action-col-options":t.effectiveActionColOptions},on:{submit:t.handleSubmit,reset:t.handleReset,toggle:function(s){t.collapsed=!t.collapsed}}},[l("template",{slot:"submitBefore"},[e._t("submitBefore")],2),l("template",{slot:"resetBefore"},[e._t("resetBefore")],2),l("template",{slot:"advanceBefore"},[e._t("advanceBefore")],2),l("template",{slot:"advanceAfter"},[e._t("advanceAfter")],2),l("template",{slot:"actions"},[e._t("actions")],2)],2)],1):e._e()],2),t.effectiveProps.showAdvancedButton&&t.hasMoreFields?l("el-button",{staticClass:"ecp-form-actions__advance",attrs:{type:"text"},on:{click:function(s){t.collapsed=!t.collapsed}}},[l("i",{staticClass:"el-icon-d-arrow-left",class:t.collapsed?"down":"up"}),e._v(" "+e._s(t.collapsed?"展开":"收起")+" ")]):e._e(),e._t("formFooter")],2)],1)},pe=[],ve=T(ue,me,pe,!1,null,"d75b0fb1",null,null);const E=ve.exports;function he(b){const e=i.ref(null),l=i.ref(b?i.unref(b):void 0),t=()=>b?i.unref(b):void 0,s=n=>{e.value=n;const u=t();debugger;u&&Object.keys(u).length>0&&n.setProps(u)};return b&&i.watch(()=>t(),n=>{l.value=n,n&&e.value&&e.value.setProps(n)},{deep:!0}),[s,{register:s,formAction:e,getFieldsValue:()=>{var n;return((n=e.value)==null?void 0:n.getFieldsValue())??{}},setFieldsValue:async n=>{var u;await((u=e.value)==null?void 0:u.setFieldsValue(n))},resetFields:async()=>{var n;await((n=e.value)==null?void 0:n.resetFields())},validate:n=>{var u;return((u=e.value)==null?void 0:u.validate(n))??Promise.resolve()},validateFields:n=>{var u;return((u=e.value)==null?void 0:u.validateFields(n))??Promise.resolve()},submit:()=>{var n;return((n=e.value)==null?void 0:n.submit())??Promise.resolve()},scrollToField:(n,u)=>{var x;return((x=e.value)==null?void 0:x.scrollToField(n,u))??Promise.resolve()},clearValidate:n=>{var u;(u=e.value)==null||u.clearValidate(n)},updateSchema:n=>{var u;return((u=e.value)==null?void 0:u.updateSchema(n))??Promise.resolve()},appendSchemaByField:(n,u,x)=>{var R;return((R=e.value)==null?void 0:R.appendSchemaByField(n,u,x))??Promise.resolve()},removeSchemaByField:n=>{var u;return((u=e.value)==null?void 0:u.removeSchemaByField(n))??Promise.resolve()},setProps:async n=>{var u;l.value={...l.value,...n},await((u=e.value)==null?void 0:u.setProps(n))}}]}const _e=[{name:"ProForm",component:E},{name:"ProFormItem",component:V},{name:"FormActions",component:L}];function G(b){_e.forEach(({name:e,component:l})=>{b.component(e,l)})}const be={install:G,ProForm:E};g.FormActions=L,g.ProForm=E,g.ProFormItem=V,g.default=be,g.install=G,g.useForm=he,Object.defineProperties(g,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
3
|
+
//# sourceMappingURL=element-component-pro.umd.js.map
|