import { useAttrs as g, ref as d, computed as f, watchEffect as v, openBlock as S, createElementBlock as w, createVNode as V, mergeProps as _, withCtx as C, renderSlot as x } from "vue"; import { n as O } from "./index2.js"; import { F as B } from "./index4.js"; const A = { class: "s-form" }, j = { __name: "SForm", props: { model: { type: Object, default() { return {}; } }, rules: { type: Object, default() { return {}; } }, layout: { type: String, default() { return "vertical"; } }, column: { type: [Number, String], default() { return 1; } }, labelWidth: { type: [Number, String], default() { return 80; } } }, setup(u, { expose: m }) { const i = g(), o = u, n = d(), p = d(o.column >= 5 ? 4 : o.column), h = /* @__PURE__ */ new Set([ "disabled", "allowClear", "clearable", "showSearch", "multiple", "readonly", "autofocus", "bordered", "checked", "open", "autoClearSearchValue", "noDrag", "isManual", "expandAll", "recursionChildren", "treeCheckable", "showOnlyOrganization", "isDataScopeFilter" ]), y = (e) => typeof e == "boolean" ? e : e === "" || e === null || e === void 0 ? e === "" ? !0 : e : typeof e == "string" ? !(e === "false" || e === "0") : !!e, F = f(() => { const e = {}; return Object.keys(i || {}).forEach((t) => { const l = i[t]; e[t] = h.has(t) ? y(l) : l; }), e; }), b = f(() => { const e = o.layout, t = (o == null ? void 0 : o.labelWidth) + ""; return e === "horizontal" ? { style: { width: t.includes("px") ? t : t + "px" } } : {}; }); return v(() => { o.column > 4 && console.warn(`当前设置表单列column【${o.column}】最多显示为4列,已默认为最多4列`); }), m({ validate: (e, t) => { const l = typeof e == "function" ? e : typeof t == "function" ? t : null, r = typeof e == "function" ? void 0 : e; return new Promise((s, a) => { (r && r.length ? n.value.validateFields(r) : n.value.validate()).then((c) => { l && l(!0), s(c); }).catch((c) => { if (l) { l(!1, c), s(void 0); return; } a(c); }); }); }, validateField: (e, t) => { const l = typeof t == "function" ? t : null; return new Promise((r, s) => { if (!n.value) { r(void 0); return; } n.value.validateFields(e).then((a) => { l && l(!0), r(a); }).catch((a) => { if (l) { l(!1, a), r(void 0); return; } s(a); }); }); }, clearValidate: (e) => { n.value && n.value.clearValidate(e); }, resetFields: (e) => { n.value && n.value.resetFields(e); }, getFieldsValue: (e) => n.value ? n.value.getFieldsValue(e) : {}, setFieldsValue: (e) => { n.value && n.value.setFieldsValue(e); } }), (e, t) => { const l = B; return S(), w("div", A, [ V(l, _({ labelCol: b.value.labelCol, model: u.model, rules: u.rules, layout: u.layout }, F.value, { ref_key: "form", ref: n, style: { display: "grid", gridTemplateColumns: `repeat(${p.value}, 1fr)`, gap: "20px" } }), { default: C(() => [ x(e.$slots, "default", {}, void 0, !0) ]), _: 3 }, 16, ["labelCol", "model", "rules", "layout", "style"]) ]); }; } }, M = /* @__PURE__ */ O(j, [["__scopeId", "data-v-633f4395"]]); export { M as default };