UNPKG

epic-designer-cjh

Version:

基于vue3的设计器,可视化开发页面表单

281 lines (280 loc) 9.94 kB
import { i as U } from "./interopRequireDefault-40f894e3.js"; import { r as L } from "./_vue_commonjs-external-eb7fec7f.js"; import { r as Q, a as Y } from "./public_api-1267ff2a.js"; import { f as me, d as he, b as xe, h as Ce, e as Z, g as ge } from "./useConfigInject-d85d8c62.js"; import { r as ye } from "./Checkbox-017588c3.js"; import { r as ee } from "./FormItemContext-6c3deaca.js"; import { r as ke } from "./index-f96a976e.js"; import { r as te } from "./index-16f6c6c6.js"; function _e(t, o) { for (var u = 0; u < o.length; u++) { const e = o[u]; if (typeof e != "string" && !Array.isArray(e)) { for (const c in e) if (c !== "default" && !(c in t)) { const b = Object.getOwnPropertyDescriptor(e, c); b && Object.defineProperty(t, c, b.get ? b : { enumerable: !0, get: () => e[c] }); } } } return Object.freeze(Object.defineProperty(t, Symbol.toStringTag, { value: "Module" })); } var M = {}, T = {}, d = {}, H; function ae() { if (H) return d; H = 1; var t = U; Object.defineProperty(d, "__esModule", { value: !0 }), d.checkboxProps = d.checkboxGroupProps = d.abstractCheckboxProps = d.abstractCheckboxGroupProps = d.CheckboxGroupContextKey = void 0; var o = t(Q()), u = t(ke()), e = me(); const c = () => ({ name: String, prefixCls: String, options: (0, e.arrayType)([]), disabled: Boolean, id: String }); d.abstractCheckboxGroupProps = c; const b = () => (0, o.default)((0, o.default)({}, c()), { defaultValue: (0, e.arrayType)(), value: (0, e.arrayType)(), onChange: (0, e.functionType)(), "onUpdate:value": (0, e.functionType)() }); d.checkboxGroupProps = b; const k = () => ({ prefixCls: String, defaultChecked: (0, e.booleanType)(), checked: (0, e.booleanType)(), disabled: (0, e.booleanType)(), isGroup: (0, e.booleanType)(), value: u.default.any, name: String, id: String, indeterminate: (0, e.booleanType)(), type: (0, e.stringType)("checkbox"), autofocus: (0, e.booleanType)(), onChange: (0, e.functionType)(), "onUpdate:checked": (0, e.functionType)(), onClick: (0, e.functionType)(), skipGroup: (0, e.booleanType)(!1) }); d.abstractCheckboxProps = k; const _ = () => (0, o.default)((0, o.default)({}, k()), { indeterminate: (0, e.booleanType)(!1) }); d.checkboxProps = _; const I = Symbol("CheckboxGroupContext"); return d.CheckboxGroupContextKey = I, d; } var W; function Ie() { if (W) return T; W = 1; var t = U; Object.defineProperty(T, "__esModule", { value: !0 }), T.default = void 0; var o = L, u = t(Y()), e = t(Q()), c = t(he()), b = t(ye()), k = xe(), _ = t(Ce()), I = ee(), P = t(Z()), $ = ge(), q = ae(), m = t(te()), y = function(a, O) { var h = {}; for (var l in a) Object.prototype.hasOwnProperty.call(a, l) && O.indexOf(l) < 0 && (h[l] = a[l]); if (a != null && typeof Object.getOwnPropertySymbols == "function") for (var v = 0, l = Object.getOwnPropertySymbols(a); v < l.length; v++) O.indexOf(l[v]) < 0 && Object.prototype.propertyIsEnumerable.call(a, l[v]) && (h[l[v]] = a[l[v]]); return h; }, G = (0, o.defineComponent)({ compatConfig: { MODE: 3 }, name: "ACheckbox", inheritAttrs: !1, __ANT_CHECKBOX: !0, props: (0, q.checkboxProps)(), // emits: ['change', 'update:checked'], setup(a, O) { let { emit: h, attrs: l, slots: v, expose: r } = O; const p = (0, I.useInjectFormItemContext)(), x = I.FormItemInputContext.useInject(), { prefixCls: n, direction: C, disabled: D } = (0, P.default)("checkbox", a), A = (0, $.useInjectDisabled)(), [N, S] = (0, m.default)(n), f = (0, o.inject)(q.CheckboxGroupContextKey, void 0), E = Symbol("checkboxUniId"), K = (0, o.computed)(() => (f == null ? void 0 : f.disabled.value) || D.value); (0, o.watchEffect)(() => { !a.skipGroup && f && f.registerValue(E, a.value); }), (0, o.onBeforeUnmount)(() => { f && f.cancelValue(E); }), (0, o.onMounted)(() => { (0, _.default)(!!(a.checked !== void 0 || f || a.value === void 0), "Checkbox", "`value` is not validate prop, do you mean `checked`?"); }); const ne = (s) => { const j = s.target.checked; h("update:checked", j), h("change", s), p.onFieldChange(); }, F = (0, o.ref)(); return r({ focus: () => { var s; (s = F.value) === null || s === void 0 || s.focus(); }, blur: () => { var s; (s = F.value) === null || s === void 0 || s.blur(); } }), () => { var s; const j = (0, k.flattenChildren)((s = v.default) === null || s === void 0 ? void 0 : s.call(v)), { indeterminate: R, skipGroup: oe, id: le = p.id.value } = a, ue = y(a, ["indeterminate", "skipGroup", "id"]), { onMouseenter: ce, onMouseleave: se, onInput: we, class: ie, style: de } = l, fe = y(l, ["onMouseenter", "onMouseleave", "onInput", "class", "style"]), g = (0, e.default)((0, e.default)((0, e.default)((0, e.default)({}, ue), { id: le, prefixCls: n.value }), fe), { disabled: K.value }); f && !oe ? (g.onChange = function() { for (var B = arguments.length, z = new Array(B), w = 0; w < B; w++) z[w] = arguments[w]; h("change", ...z), f.toggleOption({ label: j, value: a.value }); }, g.name = f.name.value, g.checked = f.mergedValue.value.includes(a.value), g.disabled = K.value || A.value, g.indeterminate = R) : g.onChange = ne; const ve = (0, c.default)({ [`${n.value}-wrapper`]: !0, [`${n.value}-rtl`]: C.value === "rtl", [`${n.value}-wrapper-checked`]: g.checked, [`${n.value}-wrapper-disabled`]: g.disabled, [`${n.value}-wrapper-in-form-item`]: x.isFormItemInput }, ie, S.value), pe = (0, c.default)({ [`${n.value}-indeterminate`]: R }, S.value), be = R ? "mixed" : void 0; return N((0, o.createVNode)("label", { class: ve, style: de, onMouseenter: ce, onMouseleave: se }, [(0, o.createVNode)(b.default, (0, u.default)((0, u.default)({ "aria-checked": be }, g), {}, { class: pe, ref: F }), null), j.length ? (0, o.createVNode)("span", null, [j]) : null])); }; } }); return T.default = G, T; } var V = U; Object.defineProperty(M, "__esModule", { value: !0 }); var re = M.default = void 0, i = L, X = V(Y()), Pe = V(Ie()), Oe = ee(), Se = V(Z()), J = ae(), Ge = V(te()), je = (0, i.defineComponent)({ compatConfig: { MODE: 3 }, name: "ACheckboxGroup", inheritAttrs: !1, props: (0, J.checkboxGroupProps)(), // emits: ['change', 'update:value'], setup(t, o) { let { slots: u, attrs: e, emit: c, expose: b } = o; const k = (0, Oe.useInjectFormItemContext)(), { prefixCls: _, direction: I } = (0, Se.default)("checkbox", t), P = (0, i.computed)(() => `${_.value}-group`), [$, q] = (0, Ge.default)(P), m = (0, i.ref)((t.value === void 0 ? t.defaultValue : t.value) || []); (0, i.watch)(() => t.value, () => { m.value = t.value || []; }); const y = (0, i.computed)(() => t.options.map((r) => typeof r == "string" || typeof r == "number" ? { label: r, value: r } : r)), G = (0, i.ref)(Symbol()), a = (0, i.ref)(/* @__PURE__ */ new Map()), O = (r) => { a.value.delete(r), G.value = Symbol(); }, h = (r, p) => { a.value.set(r, p), G.value = Symbol(); }, l = (0, i.ref)(/* @__PURE__ */ new Map()); (0, i.watch)(G, () => { const r = /* @__PURE__ */ new Map(); for (const p of a.value.values()) r.set(p, !0); l.value = r; }); const v = (r) => { const p = m.value.indexOf(r.value), x = [...m.value]; p === -1 ? x.push(r.value) : x.splice(p, 1), t.value === void 0 && (m.value = x); const n = x.filter((C) => l.value.has(C)).sort((C, D) => { const A = y.value.findIndex((S) => S.value === C), N = y.value.findIndex((S) => S.value === D); return A - N; }); c("update:value", n), c("change", n), k.onFieldChange(); }; return (0, i.provide)(J.CheckboxGroupContextKey, { cancelValue: O, registerValue: h, toggleOption: v, mergedValue: m, name: (0, i.computed)(() => t.name), disabled: (0, i.computed)(() => t.disabled) }), b({ mergedValue: m }), () => { var r; const { id: p = k.id.value } = t; let x = null; return y.value && y.value.length > 0 && (x = y.value.map((n) => { var C; return (0, i.createVNode)(Pe.default, { prefixCls: _.value, key: n.value.toString(), disabled: "disabled" in n ? n.disabled : t.disabled, indeterminate: n.indeterminate, value: n.value, checked: m.value.indexOf(n.value) !== -1, onChange: n.onChange, class: `${P.value}-item` }, { default: () => [u.label !== void 0 ? (C = u.label) === null || C === void 0 ? void 0 : C.call(u, n) : n.label] }); })), $((0, i.createVNode)("div", (0, X.default)((0, X.default)({}, e), {}, { class: [P.value, { [`${P.value}-rtl`]: I.value === "rtl" }, e.class, q.value], id: p }), [x || ((r = u.default) === null || r === void 0 ? void 0 : r.call(u))])); }; } }); re = M.default = je; const Ue = /* @__PURE__ */ _e({ __proto__: null, get default() { return re; } }, [M]); export { Ue as G };