UNPKG

@farris/ui-vue

Version:

Farris Vue, a Farris Design based Vue3 component library.

856 lines (855 loc) 29.4 kB
import { ref as R, computed as B, defineComponent as Q, toRefs as U, watch as G, onMounted as X, createVNode as x, nextTick as me, inject as W } from "vue"; import { cloneDeep as I, isPlainObject as _ } from "lodash-es"; import { resolveAppearance as ve } from "../dynamic-resolver/index.esm.js"; import { useDesignerComponent as ge } from "../designer-canvas/index.esm.js"; import { FormSchemaEntityFieldTypeName as J, withInstall as be } from "../common/index.esm.js"; import { InputBaseProperty as ye } from "../property-panel/index.esm.js"; function Y(e, t) { let n; function s(r) { const { properties: a, title: f, ignore: o } = r, i = o && Array.isArray(o), l = Object.keys(a).reduce((m, b) => ((!i || !o.find((w) => w === b)) && (m[b] = a[b].type === "object" && a[b].properties ? s(a[b]) : I(a[b].default)), m), {}); if (f && (!i || !o.find((m) => m === "id"))) { const m = f.toLowerCase().replace(/-/g, "_"); l.id = `${m}_${Math.random().toString().slice(2, 6)}`; } return l; } function u(r) { const { properties: a, title: f, required: o } = r; if (o && Array.isArray(o)) { const i = o.reduce((l, m) => (l[m] = a[m].type === "object" && a[m].properties ? s(a[m]) : I(a[m].default), l), {}); if (f && o.find((l) => l === "id")) { const l = f.toLowerCase().replace(/-/g, "_"); i.id = `${l}_${Math.random().toString().slice(2, 6)}`; } return i; } return { type: f }; } function v(r, a = {}, f) { const o = e[r]; if (o) { let i = u(o); const l = t[r]; return i = l ? l({ getSchemaByType: v }, i, a, f) : i, n != null && n.appendIdentifyForNewControl && n.appendIdentifyForNewControl(i), i; } return null; } function y(r, a) { const f = s(a); return Object.keys(f).reduce((o, i) => (Object.prototype.hasOwnProperty.call(r, i) && (o[i] && _(o[i]) && _(r[i] || !r[i]) ? Object.assign(o[i], r[i] || {}) : o[i] = r[i]), o), f), f; } function S(r, a) { return Object.keys(r).filter((o) => r[o] != null).reduce((o, i) => { if (a.has(i)) { const l = a.get(i); if (typeof l == "string") o[l] = r[i]; else { const m = l(i, r[i], r); Object.assign(o, m); } } else o[i] = r[i]; return o; }, {}); } function F(r, a, f = /* @__PURE__ */ new Map()) { const o = y(r, a); return S(o, f); } function d(r) { var f; const a = r.type; if (a) { const o = e[a]; if (!o) return r; const i = y(r, o), l = ((f = r.editor) == null ? void 0 : f.type) || ""; if (l) { const m = e[l], b = y(r.editor, m); i.editor = b; } return i; } return r; } function p(r) { n = r; } return { getSchemaByType: v, resolveSchemaWithDefaultValue: d, resolveSchemaToProps: F, mappingSchemaToProps: S, setDesignerContext: p }; } const Z = {}, L = {}, { getSchemaByType: pt, resolveSchemaWithDefaultValue: he, resolveSchemaToProps: Se, mappingSchemaToProps: we, setDesignerContext: mt } = Y(Z, L); function Ce(e = {}) { function t(d, p, r, a) { if (typeof r == "number") return a[d].length === r; if (typeof r == "object") { const f = Object.keys(r)[0], o = r[f]; if (f === "not") return Number(a[d].length) !== Number(o); if (f === "moreThan") return Number(a[d].length) >= Number(o); if (f === "lessThan") return Number(a[d].length) <= Number(o); } return !1; } function n(d, p, r, a) { return a[d] && a[d].propertyValue && String(a[d].propertyValue.value) === String(r); } const s = /* @__PURE__ */ new Map([ ["length", t], ["getProperty", n] ]); Object.keys(e).reduce((d, p) => (d.set(p, e[p]), d), s); function u(d, p) { const r = d; return typeof p == "number" ? [{ target: r, operator: "length", param: null, value: Number(p) }] : typeof p == "boolean" ? [{ target: r, operator: "getProperty", param: d, value: !!p }] : typeof p == "object" ? Object.keys(p).map((a) => { if (a === "length") return { target: r, operator: "length", param: null, value: p[a] }; const f = a, o = p[a]; return { target: r, operator: "getProperty", param: f, value: o }; }) : []; } function v(d) { return Object.keys(d).reduce((r, a) => { const f = u(a, d[a]); return r.push(...f), r; }, []); } function y(d, p) { if (s.has(d.operator)) { const r = s.get(d.operator); return r && r(d.target, d.param, d.value, p) || !1; } return !1; } function S(d, p) { return v(d).reduce((f, o) => f && y(o, p), !0); } function F(d, p) { const r = Object.keys(d), a = r.includes("allOf"), f = r.includes("anyOf"), o = a || f, m = (o ? d[o ? a ? "allOf" : "anyOf" : "allOf"] : [d]).map((w) => S(w, p)); return a ? !m.includes(!1) : m.includes(!0); } return { parseValueSchema: F }; } const Fe = { convertTo: (e, t, n, s) => { e.appearance || (e.appearance = {}), e.appearance[t] = n; }, convertFrom: (e, t, n) => e.appearance ? e.appearance[t] : e[t] }, Te = { convertFrom: (e, t, n) => e.buttons && e.buttons.length ? `共 ${e.buttons.length} 项` : "无" }, Pe = { convertTo: (e, t, n, s) => { e.editor && (e.editor[t] = n); }, convertFrom: (e, t, n) => e.editor && Object.prototype.hasOwnProperty.call(e.editor, t) ? e.editor[t] : e[t] }, Oe = { button: { type: "button", name: "按钮" }, "response-toolbar": { type: "response-toolbar", name: "工具栏" }, "response-toolbar-item": { type: "response-toolbar-item", name: "按钮" }, "content-container": { type: "content-container", name: "容器" }, "input-group": { type: "input-group", name: "文本" }, textarea: { type: "textarea", name: "多行文本" }, lookup: { type: "lookup", name: "帮助" }, "number-spinner": { type: "number-spinner", name: "数值" }, "date-picker": { type: "date-picker", name: "日期" }, switch: { type: "switch", name: "开关" }, "radio-group": { type: "radio-group", name: "单选组" }, "check-box": { type: "check-box", name: "复选框" }, "check-group": { type: "check-group", name: "复选框组" }, "combo-list": { type: "combo-list", name: "下拉列表" }, "response-form": { type: "response-form", name: "卡片面板" }, "response-layout": { type: "response-layout", name: "布局容器", icon: "response-layout-3" }, "response-layout-item": { type: "response-layout-item", name: "布局", icon: "response-layout-1" }, "tree-grid": { type: "tree-grid", name: "树表格" }, "tree-grid-column": { type: "tree-grid-column", name: "树表格列" }, "data-grid": { type: "data-grid", name: "表格" }, "data-grid-column": { type: "data-grid-column", name: "表格列" }, module: { type: "Module", name: "模块" }, component: { type: "component", name: "组件" }, tabs: { type: "tabs", name: "标签页" }, "tab-page": { type: "tab-page", name: "标签页项", dependentParentControl: "Tab" }, "tab-toolbar-item": { type: "tab-toolbar-item", name: "标签页工具栏按钮" }, "html-template": { type: "html-template", name: "模板容器" }, "time-picker": { type: "time-picker", name: "时间选择" }, section: { type: "section", name: "分组面板" }, "section-toolbar": { type: "section-toolbar", name: "分组面板工具栏" }, "section-toolbar-item": { type: "section-toolbar-item", name: "分组面板按钮" }, splitter: { type: "splitter", name: "分栏面板" }, "splitter-pane": { type: "splitter-pane", name: "分栏面板项", dependentParentControl: "Splitter" }, "component-ref": { type: "component-ref", name: "组件引用节点" }, uploader: { type: "uploader", name: "附件上传" }, "page-header": { type: "page-header", name: "页头" }, "page-footer": { type: "page-footer", name: "页脚" }, "tab-toolbar": { type: "tab-toolbar", name: "标签页工具栏" }, fieldset: { type: "fieldset", name: "分组" }, "query-solution": { type: "query-solution", name: "筛选方案" }, drawer: { type: "drawer", name: "抽屉" }, "external-container": { type: "external-container", name: "外部容器", icon: "content-container" }, "list-nav": { type: "list-nav", name: "列表导航" }, "list-view": { type: "list-view", name: "列表" }, "filter-bar": { type: "filter-bar", name: "筛选条" }, "language-textbox": { type: "language-textbox", name: "多语输入框" } }, ke = { convertFrom: (e, t, n) => { var u; const s = e.editor && e.editor[t] ? e.editor[t] : e[t]; return ((u = Oe[s]) == null ? void 0 : u.name) || s; } }, Me = { convertTo: (e, t, n, s) => { e[t] = e[t]; }, convertFrom: (e, t, n) => e.editor ? n.getRealEditorType(e.editor.type) : "" }, xe = { convertTo: (e, t, n, s) => { (e.type === "data-grid-column" || e.type === "tree-grid-column") && (e.formatter ? e.formatter[t] = n : e.formatter = { [t]: n }); }, convertFrom: (e, t, n) => { if (e.formatter) { if (t === "trueText") return e.formatter.trueText; if (t === "falseText") return e.formatter.falseText; if (t === "prefix") return e.formatter.prefix; if (t === "suffix") return e.formatter.suffix; if (t === "precision") return e.formatter.precision; if (t === "decimal") return e.formatter.decimal; if (t === "thousand") return e.formatter.thousand; if (t === "tempDateFormat") return e.formatter.dateFormat === "yyyy年MM月dd日" ? "yearMonthDay" : e.formatter.dateFormat === "yyyy-MM-dd HH:mm:ss" ? "yyyy-MM-ddTHH:mm:ss" : e.formatter.dateFormat === "yyyy/MM/dd HH:mm:ss" ? "yyyy/MM/ddTHH:mm:ss" : e.formatter.dateFormat === "yyyy年MM月dd日 HH时mm分ss秒" ? "yearMonthDayHourMinuteSecond" : e.formatter.tempDateFormat || e.formatter.dateFormat || "yyyy-MM-dd"; if (t === "customFormat") return e.formatter.customFormat; if (t === "type") return e.formatter.type || "none"; } return "none"; } }, Ee = { convertTo: (e, t, n, s) => { e.command ? e.command[t] = n : e.command = { [t]: n }, t === "enable" && n && (e.command.commands || (e.command.commands = [ { text: "编辑", type: "primary", command: "edit" }, { text: "删除", type: "danger", command: "remove" } ])); }, convertFrom: (e, t, n) => e.command && t === "enable" ? e.command.enable : "" }, Be = { convertTo: (e, t, n, s) => { e.column ? e.column[t] = n : e.column = { [t]: n }, t === "fitColumns" && n && (e.column.fitMode || (e.column.fitMode = "average")); }, convertFrom: (e, t, n) => { if (e.column) { if (t === "fitColumns") return e.column.fitColumns; if (t === "fitMode") return e.column.fitMode; } return ""; } }, De = { convertTo: (e, t, n, s) => { e.summary ? e.summary[t] = n : e.summary = { [t]: n }, t === "enable" && n && (e.summary ? e.summary.groupFields || (e.summary.groupFields = []) : e.summary = { enable: n, groupFields: [] }); }, convertFrom: (e, t, n) => e.summary && t === "enable" ? e.summary.enable : e.type === "data-grid-column" ? e.enableSummary === void 0 ? !1 : e.enableSummary : "" }, je = { convertTo: (e, t, n, s) => { e.group ? e.group[t] = n : e.group = { [t]: n }, t === "enable" && n && (e.group ? e.group.groupFields || (e.group.groupFields = []) : e.group = { enable: n, groupFields: [], showSummary: !1 }); }, convertFrom: (e, t, n) => { if (e.group) { if (t === "enable") return e.group.enable; if (t === "showSummary") return e.group.showSummary; } } }, Ne = { convertFrom: (e, t) => e.binding ? e.binding.path : "", convertTo: (e, t, n) => { if (n && n.length > 0) { const s = n[0]; e.binding || (e.binding = {}), e.binding.type = "Form", e.binding.path = s.bindingField, e.binding.field = s.id, e.binding.fullPath = s.path, e.path = s.bindingPath; } } }, Re = { convertTo: (e, t, n, s) => { e.pagination || (e.pagination = {}), e.pagination[t] = n; }, convertFrom: (e, t, n) => e.pagination ? e.pagination[t] : e[t] }, $e = { convertTo: (e, t, n, s) => { e.rowNumber || (e.rowNumber = {}), e.rowNumber[t] = n; }, convertFrom: (e, t, n) => e.rowNumber ? e.rowNumber[t] : e[t] }, Ve = { convertTo: (e, t, n, s) => { e.selection || (e.selection = {}), e.selection[t] = n; }, convertFrom: (e, t, n) => e.selection ? e.selection[t] : e[t] }, He = { convertFrom: (e, t, n) => e[t] && e[t].length ? `共 ${e[t].length} 项` : "" }, ze = { convertFrom: (e, t) => e[t] || "", convertTo: (e, t, n) => { e[t] = n; } }, qe = { convertTo: (e, t, n, s) => { e.size || (e.size = {}), e.size[t] = n; }, convertFrom: (e, t, n) => e.size ? e.size[t] : e[t] }, Ae = { convertFrom: (e, t, n) => { var s, u; return (s = e.formatter) != null && s.data && t === "formatterEnumData" && !e.formatterEnumData ? (u = e.formatter) == null ? void 0 : u.data : e.formatterEnumData; } }, Ge = { convertTo: (e, t, n, s) => { e.sort || (e.sort = {}), e.sort[t] = n; }, convertFrom: (e, t, n) => { var s, u; if (t === "mode") return ((s = e.sort) == null ? void 0 : s.mode) || "client"; if (t === "multiSort") return !!((u = e.sort) != null && u.multiSort); } }, We = { convertTo: (e, t, n, s) => { e.filter || (e.filter = {}), e.filter[t] = n; }, convertFrom: (e, t, n) => { var s; if (t === "mode") return ((s = e.filter) == null ? void 0 : s.mode) || "client"; } }, Ie = { convertTo: (e, t, n, s) => { e.rowOption ? e.rowOption[t] = n : e.rowOption = { [t]: n }; }, convertFrom: (e, t, n) => { if (e.rowOption) { if (t === "customRowStyle") return e.rowOption.customRowStyle; if (t === "customCellStyle") return e.rowOption.customCellStyle; } return ""; } }; function K(e, t, n) { const s = /* @__PURE__ */ new Map([ ["/converter/appearance.converter", Fe], ["/converter/buttons.converter", Te], ["/converter/property-editor.converter", Pe], ["/converter/items-count.converter", He], ["/converter/type.converter", ke], ["/converter/change-editor.converter", Me], ["/converter/change-formatter.converter", xe], ["/converter/column-command.converter", Ee], ["/converter/column-option.converter", Be], ["/converter/summary.converter", De], ["/converter/group.converter", je], ["/converter/form-group-label.converter", ze], ["/converter/field-selector.converter", Ne], ["/converter/pagination.converter", Re], ["/converter/row-number.converter", $e], ["/converter/grid-selection.converter", Ve], ["/converter/size.converter", qe], ["/converter/change-formatter-enum.converter", Ae], ["/converter/grid-sort.converter", Ge], ["/converter/grid-filter.converter", We], ["/converter/row-option.converter", Ie] ]), u = /* @__PURE__ */ new Map([ ["string", { type: "input-group", enableClear: !1 }], ["boolean", { type: "combo-list", textField: "name", valueField: "value", idField: "value", enableClear: !1, editable: !1, data: [ { value: !0, name: "是" }, { value: !1, name: "否" } ] }], ["enum", { type: "combo-list", maxHeight: 128, enableClear: !1, editable: !1 }], ["array", { type: "button-edit" }], ["number", { type: "number-spinner", placeholder: "" }], ["events-editor", { type: "events-editor", hide: !0 }] ]), v = Ce(); function y(o, i) { return () => v.parseValueSchema(o, i); } function S(o, i, l) { return o.includes("visible") && i.visible !== void 0 ? typeof i.visible == "boolean" ? () => !!i.visible : i.visible === void 0 ? !0 : y(i.visible, l) : () => !0; } function F(o, i, l) { return o.includes("readonly") && i.readonly !== void 0 ? typeof i.readonly == "boolean" ? () => !!i.readonly : y(i.readonly, l) : () => !1; } function d(o, i) { const l = o.$converter || i; return typeof l == "string" && l && s.has(l) ? s.get(l) || null : l || null; } function p(o, i, l, m, b, w = "", T = "") { return Object.keys(o).map((g) => { const P = R(1), O = g, c = o[g], C = Object.keys(c), N = c.title, D = c.type, j = u.get(D) || { type: "input-group", enableClear: !1 }, E = c.editor ? Object.assign({}, j, c.editor) : Object.assign({}, j), H = S(C, c, i), $ = F(C, c, i); E.readonly = E.readonly === void 0 ? $() : E.readonly; const z = c.type === "cascade" ? p(c.properties, i, l, m, b, w, T) : [], ae = !0; let k = d(c, T); const le = B({ get() { if (P.value) { if (["class", "style"].find((pe) => pe === O) && !k && (k = s.get("/converter/appearance.converter") || null), k && k.convertFrom) return k.convertFrom(l, g, b, w); const M = l[g]; return Object.prototype.hasOwnProperty.call(c, "defaultValue") && (M === void 0 || typeof M == "string" && M === "") ? c.type === "boolean" ? c.defaultValue : c.defaultValue || "" : M; } return null; }, set(M) { P.value += 1, k && k.convertTo ? (k.convertTo(m, g, M, b, w), k.convertTo(l, g, M, b, w)) : (m[g] = M, l[g] = M); } }), { refreshPanelAfterChanged: ce, description: ue, isExpand: de, parentPropertyID: fe } = c, A = { propertyID: O, propertyName: N, propertyType: D, propertyValue: le, editor: E, visible: H, readonly: $, cascadeConfig: z, hideCascadeTitle: ae, refreshPanelAfterChanged: ce, description: ue, isExpand: de, parentPropertyID: fe }; return i[O] = A, A; }); } function r(o, i, l = {}) { const m = {}, b = e[o]; return b && b.categories ? Object.keys(b.categories).map((T) => { const h = b.categories[T], g = h == null ? void 0 : h.title, P = p(h.properties || {}, m, {}, l, i); return { categoryId: T, categoryName: g, properties: P }; }) : []; } function a(o, i, l, m, b = "") { const w = i.$ref.schema, T = i.$ref.converter, h = l[w], g = h.type, P = n(h), O = {}, c = e[g]; if (c && c.categories) { const C = c.categories[o], N = C == null ? void 0 : C.title; T && Object.keys(C.properties).forEach((E) => { C.properties[E].$converter = T; }); const D = (C == null ? void 0 : C.properties) || {}, j = p(D, O, P, h, m, b); return { categoryId: o, categoryName: N, properties: j }; } return { categoryId: o, categoryName: "", properties: [] }; } function f(o, i, l, m, b) { const w = o.type, T = n(o), h = {}; let g = b || e[w]; if (g && Object.keys(g).length === 0 && l && l.getPropConfig && (g = l.getPropConfig(m)), g && g.categories) { const P = []; return Object.keys(g.categories).map((O) => { const c = g.categories[O]; if (c.$ref) { P.push(a(O, c, o, i, m)); return; } const C = c == null ? void 0 : c.title, N = c == null ? void 0 : c.tabId, D = c == null ? void 0 : c.tabName, j = c == null ? void 0 : c.hide, E = c == null ? void 0 : c.hideTitle, H = p(c.properties || {}, h, T, o, i, m, c.$converter), { setPropertyRelates: $ } = c, z = c == null ? void 0 : c.parentPropertyID; P.push({ categoryId: O, categoryName: C, tabId: N, tabName: D, hide: j, properties: H, hideTitle: E, setPropertyRelates: $, parentPropertyID: z }); }), P; } return []; } return { getPropertyConfigBySchema: f, getPropertyConfigByType: r, propertyConverterMap: s }; } const ee = {}, te = {}; K(ee, te, he); const ne = {}, re = {}, { getSchemaByType: vt, resolveSchemaWithDefaultValue: _e, resolveSchemaToProps: gt, mappingSchemaToProps: bt, setDesignerContext: yt } = Y(ne, re), oe = {}, ie = {}; K(oe, ie, _e); function Je(e, t, n = /* @__PURE__ */ new Map(), s = (y, S, F, d) => S, u = {}, v = (y) => y) { return Z[t.title] = t, L[t.title] = s, ee[t.title] = u, te[t.title] = v, ne[t.title] = t, re[t.title] = s, oe[t.title] = u, ie[t.title] = v, (y = {}, S = !0) => { if (!S) return we(y, n); const F = Se(y, t, n), d = Object.keys(e).reduce((p, r) => (p[r] = e[r].default, p), {}); return Object.assign(d, F); }; } const Qe = /* @__PURE__ */ new Map([ ["appearance", ve] ]), Ue = "https://json-schema.org/draft/2020-12/schema", Xe = "https://farris-design.gitee.io/switch.schema.json", Ye = "switch", Ze = "A Farris Component", Le = "object", Ke = { id: { description: "The unique identifier for a switch", type: "string" }, type: { description: "The type string of switch component", type: "string", default: "switch" }, appearance: { description: "", type: "object", properties: { class: { type: "string" }, style: { type: "string" } }, default: {} }, binding: { description: "", type: "object", default: {} }, disabled: { type: "boolean", default: !1 }, onBackground: { description: "", type: "string", default: "" }, offBackground: { description: "", type: "string", default: "" }, onColor: { description: "", type: "string", default: "" }, offColor: { description: "", type: "string", default: "" }, onLabel: { description: "", type: "string", default: "" }, offLabel: { description: "", type: "string", default: "" }, readonly: { description: "", type: "boolean", default: !1 }, size: { description: "", type: "enum", default: "medium" }, required: { description: "", type: "boolean", default: !1 }, trueValue: { description: "", type: "boolean", default: !0 }, falseValue: { description: "", type: "boolean", default: !1 } }, et = [ "type" ], tt = [ "id", "appearance", "binding" ], nt = { $schema: Ue, $id: Xe, title: Ye, description: Ze, type: Le, properties: Ke, required: et, ignore: tt }; function rt(e, t, n) { return t; } const q = { modelValue: { type: [String, Number, Boolean], default: !1 }, /** 禁用 */ disabled: { type: Boolean, default: !1 }, /** * 同disabled */ readonly: { type: Boolean, default: !1 }, onBackground: { type: String }, offBackground: { type: String }, onColor: { type: String }, offColor: { type: String }, onLabel: { type: String }, offLabel: { type: String }, /** 尺寸大小 */ size: { type: String, default: "medium" }, /** 开关值变化事件 */ onModelValueChanged: { type: Function, default: () => { } }, focusOnCreated: { type: Boolean, default: !1 }, trueValue: { type: [String, Number, Boolean], default: !0 }, falseValue: { type: [String, Number, Boolean], default: !1 } }, se = Je(q, nt, Qe, rt), V = /* @__PURE__ */ Q({ name: "FSwitch", props: q, emits: ["update:modelValue", "modelValueChanged"], setup(e, t) { const { disabled: n, size: s, onLabel: u, offLabel: v, onBackground: y, offBackground: S, onColor: F, offColor: d, readonly: p } = U(e), r = R(e.modelValue), a = R(), f = R(""), o = B(() => e.trueValue != null ? r.value === e.trueValue : !!r.value), i = B(() => ({ switch: !0, "f-cmp-switch": !0, checked: o.value, disabled: p.value || n.value, "switch-large": s.value === "large", "switch-medium": s.value === "medium", "switch-small": s.value === "small" })), l = B(() => o.value ? { outline: "none", background: y.value } : { outline: "none", backgroundColor: S.value }), m = B(() => o.value ? { background: F.value } : { backgroundColor: d.value }), b = B(() => (u == null ? void 0 : u.value) || (v == null ? void 0 : v.value)); function w() { !b.value || a.value || me(() => { const h = r.value, g = a.value.querySelector(h ? ".switch-label-checked" : ".switch-label-unchecked"); g && g.scrollWidth > g.clientWidth ? f.value = h ? u == null ? void 0 : u.value : v == null ? void 0 : v.value : f.value = ""; }); } function T() { p.value || n.value || (r.value = o.value ? e.falseValue : e.trueValue, t.emit("update:modelValue", r.value), w()); } return G(r, (h, g) => { h !== g && t.emit("modelValueChanged", h); }), G(() => e.modelValue, (h, g) => { h !== g && (r.value = h); }), X(() => { var h; e.focusOnCreated && ((h = a.value) == null || h.focus()), w(); }), () => x("span", { ref: a, tabindex: "0", role: "button", class: i.value, style: l.value, onClick: T, title: f.value }, [b.value && x("span", { class: "switch-pane" }, [x("span", { class: "switch-label-checked" }, [u == null ? void 0 : u.value]), x("span", { class: "switch-label-unchecked" }, [v == null ? void 0 : v.value])]), x("small", { style: m.value }, [t.slots.default && t.slots.default()])]); } }); class ot extends ye { constructor(t, n) { super(t, n); } getEditorProperties(t) { var n, s; return this.getComponentConfig(t, { type: "switch" }, { disabled: { visible: !1 }, placeholder: { visible: !1 }, onLabel: { description: "", title: "打开标签", type: "string" }, offLabel: { description: "", title: "关闭标签", type: "string" }, onBackground: { description: "值可以是颜色或者16进制颜色字符串,比如:blue或者#2A87FF", title: "打开背景色", type: "string" }, offBackground: { description: "值可以是颜色或者16进制颜色字符串,比如:gray或者#D9DEE7", title: "关闭背景色", type: "string" }, size: { description: "", title: "尺寸", type: "enum", editor: { data: [ { id: "small", name: "小号" }, { id: "medium", name: "中号" }, { id: "large", name: "大号" } ] } }, trueValue: { description: "打开时的值", title: "打开的值", type: this.getBindingDataType(), visible: ((n = this.designViewModelField) == null ? void 0 : n.type.name) !== "Boolean", refreshPanelAfterChanged: !0, editor: this.getEditor(), $converter: this.getBooleanValueConverter() }, falseValue: { description: "关闭时的值", title: "关闭的值", type: this.getBindingDataType(), visible: ((s = this.designViewModelField) == null ? void 0 : s.type.name) !== "Boolean", refreshPanelAfterChanged: !0, editor: this.getEditor(), $converter: this.getBooleanValueConverter() } }); } /** * 切换绑定属性 */ changeBindingField(t, n, s) { var v; super.changeBindingField(t, n); const u = s; if (t.editor && ((v = u == null ? void 0 : u.type) != null && v.name)) { let y, S; u.type.name === J.String && (y = "true", S = "false"), u.type.name === J.Number && (y = 1, S = 0), !Object.prototype.hasOwnProperty.call(t.editor, "trueValue") && y !== void 0 && (t.editor.trueValue = y), !Object.prototype.hasOwnProperty.call(t.editor, "falseValue") && S !== void 0 && (t.editor.falseValue = S); } } } function it(e, t) { const n = e.schema; function s(u, v) { return new ot(u, t).getPropertyConfig(n, v); } return { getPropsConfig: s }; } const st = /* @__PURE__ */ Q({ name: "FSwitchDesign", props: q, emits: ["update:modelValue"], setup(e, t) { const { size: n, onLabel: s, offLabel: u } = U(e), v = R(), y = W("designer-host-service"), S = W("design-item-context"), F = it(S, y), d = ge(v, S, F); X(() => { v.value.componentInstance = d; }), t.expose(d.value); const p = B(() => ({ switch: !0, "f-cmp-switch": !0, checked: !1, "switch-large": n.value === "large", "switch-medium": n.value === "medium", "switch-small": n.value === "small" })), r = B(() => (s == null ? void 0 : s.value) || (u == null ? void 0 : u.value)); return () => x("span", { ref: v, tabindex: "0", role: "button", class: p.value }, [r.value && x("span", { class: "switch-pane" }, [x("span", { class: "switch-label-unchecked" }, [u == null ? void 0 : u.value])]), x("small", null, [t.slots.default && t.slots.default()])]); } }); V.register = (e, t, n, s) => { e.switch = V, t.switch = se; }; V.registerDesigner = (e, t, n) => { e.switch = st, t.switch = se; }; const ht = be(V); export { V as FSwitch, ht as default, se as propsResolver, q as switchProps };