UNPKG

@farris/ui-vue

Version:

Farris Vue, a Farris Design based Vue3 component library.

1,449 lines 212 kB
var Vn = Object.defineProperty; var An = (n, e, t) => e in n ? Vn(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t; var Q = (n, e, t) => An(n, typeof e != "symbol" ? e + "" : e, t); import { ref as I, computed as H, defineComponent as we, createVNode as w, inject as tt, onMounted as Ye, watch as Se, Fragment as ct, reactive as $e, createApp as rn, onUnmounted as bt, Transition as ln, mergeProps as $t, nextTick as Vt, createTextVNode as mt, onBeforeMount as zn, Teleport as Un, shallowRef as qn, render as Lt, h as Wn, cloneVNode as _n } from "vue"; import { cloneDeep as yt, isPlainObject as Zt, isUndefined as je } from "lodash-es"; import { getSchemaByTypeForDesigner as Gn, schemaMap as Hn, createPropsResolver as cn, resolveAppearance as Xn } from "../dynamic-resolver/index.esm.js"; import { useI18n as At } from "vue-i18n"; import { LocaleService as Ct } from "../locale/index.esm.js"; import { getCustomClass as jt, withInstall as Yn, FormSchemaEntityField$Type as Kt, FormSchemaEntityFieldTypeName as en, useGuid as tn } from "../common/index.esm.js"; import { useResizeObserver as Jn } from "@vueuse/core"; import { getHierarchyRow as Qn, useIdentify as Zn, useGroupData as Kn, useFilter as eo, useHierarchy as to, useLoading as no, useDataView as oo, useSelection as io, useSelectHierarchyItem as ao, usePagination as so, useDataViewContainerStyle as ro, useCommandColumn as lo, useSettingColumn as co, useColumn as uo, useSort as po, useGroupColumn as fo, useRow as mo, useEdit as vo, useVisualDataBound as ho, useVisualDataCell as yo, useVisualDataRow as go, useVisualData as bo, useCellPosition as Co, useSidebar as wo, useVirtualScroll as To, useFitColumn as So, useFilterHistory as Mo, useColumnFilter as xo, useDragColumn as Io, getColumnHeader as Fo, getSidebar as Eo, getDisableMask as Bo, getHorizontalScrollbar as ko, getVerticalScrollbar as Oo, getEmpty as Po, getPagination as Lo, getSummary as Do } from "../data-view/index.esm.js"; import { DgControl as ut } from "../designer-canvas/index.esm.js"; import { FormBindingType as Ge } from "../property-panel/index.esm.js"; import "../accordion/index.esm.js"; import "../avatar/index.esm.js"; import "../../designer/button-edit/index.esm.js"; import "../button-group/index.esm.js"; import "../calendar/index.esm.js"; import "../capsule/index.esm.js"; import "../../designer/checkbox/index.esm.js"; import "../../designer/checkbox-group/index.esm.js"; import "../combo-list/index.esm.js"; import "../combo-tree/index.esm.js"; import "../component/index.esm.js"; import "../color-picker/index.esm.js"; import "../content-container/index.esm.js"; import "../date-picker/index.esm.js"; import "../../designer/data-grid/index.esm.js"; import "../dropdown/index.esm.js"; import "../dynamic-form/index.esm.js"; import "../events-editor/index.esm.js"; import "../filter-bar/index.esm.js"; import "../field-selector/index.esm.js"; import "../binding-selector/index.esm.js"; import "../image-cropper/index.esm.js"; import "../../designer/input-group/index.esm.js"; import "../layout/index.esm.js"; import "../list-nav/index.esm.js"; import "../../designer/list-view/index.esm.js"; import "../lookup/index.esm.js"; import "../mapping-editor/index.esm.js"; import "../nav/index.esm.js"; import "../number-range/index.esm.js"; import "../number-spinner/index.esm.js"; import "../order/index.esm.js"; import "../page-header/index.esm.js"; import "../page-footer/index.esm.js"; import "../pagination/index.esm.js"; import "../progress/index.esm.js"; import "../query-solution/index.esm.js"; import "../../designer/radio-group/index.esm.js"; import "../rate/index.esm.js"; import "../response-toolbar/index.esm.js"; import "../response-layout/index.esm.js"; import "../response-layout-editor/index.esm.js"; import "../search-box/index.esm.js"; import "../section/index.esm.js"; import "../smoke-detector/index.esm.js"; import "../splitter/index.esm.js"; import "../step/index.esm.js"; import "../switch/index.esm.js"; import "../tabs/index.esm.js"; import "../tags/index.esm.js"; import "../text/index.esm.js"; import "../time-picker/index.esm.js"; import "../transfer/index.esm.js"; import "../tree-view/index.esm.js"; import "../uploader/index.esm.js"; import "../verify-detail/index.esm.js"; import "../video/index.esm.js"; import "../textarea/index.esm.js"; import "../schema-selector/index.esm.js"; import "../../designer/tree-grid/index.esm.js"; import "../event-parameter/index.esm.js"; import "../filter-condition-editor/index.esm.js"; import "../fieldset/index.esm.js"; import "../sort-condition-editor/index.esm.js"; import "../menu-lookup/index.esm.js"; import "../../designer/drawer/index.esm.js"; import "../json-editor/index.esm.js"; import "../property-editor/index.esm.js"; import "../expression-editor/index.esm.js"; import "../code-editor/index.esm.js"; import "../html-template/index.esm.js"; import "../collection-property-editor/index.esm.js"; import "../modal/index.esm.js"; import "../external-container/index.esm.js"; import "../language-textbox/index.esm.js"; import "../notify/index.esm.js"; function un(n, e) { let t; function o(l) { const { properties: m, title: d, ignore: p } = l, v = p && Array.isArray(p), b = Object.keys(m).reduce((T, k) => ((!v || !p.find((A) => A === k)) && (T[k] = m[k].type === "object" && m[k].properties ? o(m[k]) : yt(m[k].default)), T), {}); if (d && (!v || !p.find((T) => T === "id"))) { const T = d.toLowerCase().replace(/-/g, "_"); b.id = `${T}_${Math.random().toString().slice(2, 6)}`; } return b; } function i(l) { const { properties: m, title: d, required: p } = l; if (p && Array.isArray(p)) { const v = p.reduce((b, T) => (b[T] = m[T].type === "object" && m[T].properties ? o(m[T]) : yt(m[T].default), b), {}); if (d && p.find((b) => b === "id")) { const b = d.toLowerCase().replace(/-/g, "_"); v.id = `${b}_${Math.random().toString().slice(2, 6)}`; } return v; } return { type: d }; } function a(l, m = {}, d) { const p = n[l]; if (p) { let v = i(p); const b = e[l]; return v = b ? b({ getSchemaByType: a }, v, m, d) : v, t != null && t.appendIdentifyForNewControl && t.appendIdentifyForNewControl(v), v; } return null; } function s(l, m) { const d = o(m); return Object.keys(d).reduce((p, v) => (Object.prototype.hasOwnProperty.call(l, v) && (p[v] && Zt(p[v]) && Zt(l[v] || !l[v]) ? Object.assign(p[v], l[v] || {}) : p[v] = l[v]), p), d), d; } function u(l, m) { return Object.keys(l).filter((p) => l[p] != null).reduce((p, v) => { if (m.has(v)) { const b = m.get(v); if (typeof b == "string") p[b] = l[v]; else { const T = b(v, l[v], l); Object.assign(p, T); } } else p[v] = l[v]; return p; }, {}); } function c(l, m, d = /* @__PURE__ */ new Map()) { const p = s(l, m); return u(p, d); } function r(l) { var d; const m = l.type; if (m) { const p = n[m]; if (!p) return l; const v = s(l, p), b = ((d = l.editor) == null ? void 0 : d.type) || ""; if (b) { const T = n[b], k = s(l.editor, T); v.editor = k; } return v; } return l; } function f(l) { t = l; } return { getSchemaByType: a, resolveSchemaWithDefaultValue: r, resolveSchemaToProps: c, mappingSchemaToProps: u, setDesignerContext: f }; } const dn = {}, pn = {}, { getSchemaByType: No, resolveSchemaWithDefaultValue: jo, resolveSchemaToProps: Ro, mappingSchemaToProps: $o, setDesignerContext: fl } = un(dn, pn); function Vo(n = {}) { function e(r, f, l, m) { if (typeof l == "number") return m[r].length === l; if (typeof l == "object") { const d = Object.keys(l)[0], p = l[d]; if (d === "not") return Number(m[r].length) !== Number(p); if (d === "moreThan") return Number(m[r].length) >= Number(p); if (d === "lessThan") return Number(m[r].length) <= Number(p); } return !1; } function t(r, f, l, m) { return m[r] && m[r].propertyValue && String(m[r].propertyValue.value) === String(l); } const o = /* @__PURE__ */ new Map([ ["length", e], ["getProperty", t] ]); Object.keys(n).reduce((r, f) => (r.set(f, n[f]), r), o); function i(r, f) { const l = r; return typeof f == "number" ? [{ target: l, operator: "length", param: null, value: Number(f) }] : typeof f == "boolean" ? [{ target: l, operator: "getProperty", param: r, value: !!f }] : typeof f == "object" ? Object.keys(f).map((m) => { if (m === "length") return { target: l, operator: "length", param: null, value: f[m] }; const d = m, p = f[m]; return { target: l, operator: "getProperty", param: d, value: p }; }) : []; } function a(r) { return Object.keys(r).reduce((l, m) => { const d = i(m, r[m]); return l.push(...d), l; }, []); } function s(r, f) { if (o.has(r.operator)) { const l = o.get(r.operator); return l && l(r.target, r.param, r.value, f) || !1; } return !1; } function u(r, f) { return a(r).reduce((d, p) => d && s(p, f), !0); } function c(r, f) { const l = Object.keys(r), m = l.includes("allOf"), d = l.includes("anyOf"), p = m || d, T = (p ? r[p ? m ? "allOf" : "anyOf" : "allOf"] : [r]).map((A) => u(A, f)); return m ? !T.includes(!1) : T.includes(!0); } return { parseValueSchema: c }; } const Ao = { convertTo: (n, e, t, o) => { n.appearance || (n.appearance = {}), n.appearance[e] = t; }, convertFrom: (n, e, t) => n.appearance ? n.appearance[e] : n[e] }, zo = { convertFrom: (n, e, t) => n.buttons && n.buttons.length ? `共 ${n.buttons.length} 项` : "无" }, Uo = { convertTo: (n, e, t, o) => { n.editor && (n.editor[e] = t); }, convertFrom: (n, e, t) => n.editor && Object.prototype.hasOwnProperty.call(n.editor, e) ? n.editor[e] : n[e] }, R = { 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: "多语输入框" } }, qo = { convertFrom: (n, e, t) => { var i; const o = n.editor && n.editor[e] ? n.editor[e] : n[e]; return ((i = R[o]) == null ? void 0 : i.name) || o; } }, Wo = { convertTo: (n, e, t, o) => { n[e] = n[e]; }, convertFrom: (n, e, t) => n.editor ? t.getRealEditorType(n.editor.type) : "" }, _o = { convertTo: (n, e, t, o) => { (n.type === "data-grid-column" || n.type === "tree-grid-column") && (n.formatter ? n.formatter[e] = t : n.formatter = { [e]: t }); }, convertFrom: (n, e, t) => { if (n.formatter) { if (e === "trueText") return n.formatter.trueText; if (e === "falseText") return n.formatter.falseText; if (e === "prefix") return n.formatter.prefix; if (e === "suffix") return n.formatter.suffix; if (e === "precision") return n.formatter.precision; if (e === "decimal") return n.formatter.decimal; if (e === "thousand") return n.formatter.thousand; if (e === "tempDateFormat") return n.formatter.dateFormat === "yyyy年MM月dd日" ? "yearMonthDay" : n.formatter.dateFormat === "yyyy-MM-dd HH:mm:ss" ? "yyyy-MM-ddTHH:mm:ss" : n.formatter.dateFormat === "yyyy/MM/dd HH:mm:ss" ? "yyyy/MM/ddTHH:mm:ss" : n.formatter.dateFormat === "yyyy年MM月dd日 HH时mm分ss秒" ? "yearMonthDayHourMinuteSecond" : n.formatter.tempDateFormat || n.formatter.dateFormat || "yyyy-MM-dd"; if (e === "customFormat") return n.formatter.customFormat; if (e === "type") return n.formatter.type || "none"; } return "none"; } }, Go = { convertTo: (n, e, t, o) => { n.command ? n.command[e] = t : n.command = { [e]: t }, e === "enable" && t && (n.command.commands || (n.command.commands = [ { text: "编辑", type: "primary", command: "edit" }, { text: "删除", type: "danger", command: "remove" } ])); }, convertFrom: (n, e, t) => n.command && e === "enable" ? n.command.enable : "" }, Ho = { convertTo: (n, e, t, o) => { n.column ? n.column[e] = t : n.column = { [e]: t }, e === "fitColumns" && t && (n.column.fitMode || (n.column.fitMode = "average")); }, convertFrom: (n, e, t) => { if (n.column) { if (e === "fitColumns") return n.column.fitColumns; if (e === "fitMode") return n.column.fitMode; } return ""; } }, Xo = { convertTo: (n, e, t, o) => { n.summary ? n.summary[e] = t : n.summary = { [e]: t }, e === "enable" && t && (n.summary ? n.summary.groupFields || (n.summary.groupFields = []) : n.summary = { enable: t, groupFields: [] }); }, convertFrom: (n, e, t) => n.summary && e === "enable" ? n.summary.enable : n.type === "data-grid-column" ? n.enableSummary === void 0 ? !1 : n.enableSummary : "" }, Yo = { convertTo: (n, e, t, o) => { n.group ? n.group[e] = t : n.group = { [e]: t }, e === "enable" && t && (n.group ? n.group.groupFields || (n.group.groupFields = []) : n.group = { enable: t, groupFields: [], showSummary: !1 }); }, convertFrom: (n, e, t) => { if (n.group) { if (e === "enable") return n.group.enable; if (e === "showSummary") return n.group.showSummary; } } }, Jo = { convertFrom: (n, e) => n.binding ? n.binding.path : "", convertTo: (n, e, t) => { if (t && t.length > 0) { const o = t[0]; n.binding || (n.binding = {}), n.binding.type = "Form", n.binding.path = o.bindingField, n.binding.field = o.id, n.binding.fullPath = o.path, n.path = o.bindingPath; } } }, Qo = { convertTo: (n, e, t, o) => { n.pagination || (n.pagination = {}), n.pagination[e] = t; }, convertFrom: (n, e, t) => n.pagination ? n.pagination[e] : n[e] }, Zo = { convertTo: (n, e, t, o) => { n.rowNumber || (n.rowNumber = {}), n.rowNumber[e] = t; }, convertFrom: (n, e, t) => n.rowNumber ? n.rowNumber[e] : n[e] }, Ko = { convertTo: (n, e, t, o) => { n.selection || (n.selection = {}), n.selection[e] = t; }, convertFrom: (n, e, t) => n.selection ? n.selection[e] : n[e] }, ei = { convertFrom: (n, e, t) => n[e] && n[e].length ? `共 ${n[e].length} 项` : "" }, ti = { convertFrom: (n, e) => n[e] || "", convertTo: (n, e, t) => { n[e] = t; } }, ni = { convertTo: (n, e, t, o) => { n.size || (n.size = {}), n.size[e] = t; }, convertFrom: (n, e, t) => n.size ? n.size[e] : n[e] }, oi = { convertFrom: (n, e, t) => { var o, i; return (o = n.formatter) != null && o.data && e === "formatterEnumData" && !n.formatterEnumData ? (i = n.formatter) == null ? void 0 : i.data : n.formatterEnumData; } }, ii = { convertTo: (n, e, t, o) => { n.sort || (n.sort = {}), n.sort[e] = t; }, convertFrom: (n, e, t) => { var o, i; if (e === "mode") return ((o = n.sort) == null ? void 0 : o.mode) || "client"; if (e === "multiSort") return !!((i = n.sort) != null && i.multiSort); } }, ai = { convertTo: (n, e, t, o) => { n.filter || (n.filter = {}), n.filter[e] = t; }, convertFrom: (n, e, t) => { var o; if (e === "mode") return ((o = n.filter) == null ? void 0 : o.mode) || "client"; } }, si = { convertTo: (n, e, t, o) => { n.rowOption ? n.rowOption[e] = t : n.rowOption = { [e]: t }; }, convertFrom: (n, e, t) => { if (n.rowOption) { if (e === "customRowStyle") return n.rowOption.customRowStyle; if (e === "customCellStyle") return n.rowOption.customCellStyle; } return ""; } }; function fn(n, e, t) { const o = /* @__PURE__ */ new Map([ ["/converter/appearance.converter", Ao], ["/converter/buttons.converter", zo], ["/converter/property-editor.converter", Uo], ["/converter/items-count.converter", ei], ["/converter/type.converter", qo], ["/converter/change-editor.converter", Wo], ["/converter/change-formatter.converter", _o], ["/converter/column-command.converter", Go], ["/converter/column-option.converter", Ho], ["/converter/summary.converter", Xo], ["/converter/group.converter", Yo], ["/converter/form-group-label.converter", ti], ["/converter/field-selector.converter", Jo], ["/converter/pagination.converter", Qo], ["/converter/row-number.converter", Zo], ["/converter/grid-selection.converter", Ko], ["/converter/size.converter", ni], ["/converter/change-formatter-enum.converter", oi], ["/converter/grid-sort.converter", ii], ["/converter/grid-filter.converter", ai], ["/converter/row-option.converter", si] ]), i = /* @__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 }] ]), a = Vo(); function s(p, v) { return () => a.parseValueSchema(p, v); } function u(p, v, b) { return p.includes("visible") && v.visible !== void 0 ? typeof v.visible == "boolean" ? () => !!v.visible : v.visible === void 0 ? !0 : s(v.visible, b) : () => !0; } function c(p, v, b) { return p.includes("readonly") && v.readonly !== void 0 ? typeof v.readonly == "boolean" ? () => !!v.readonly : s(v.readonly, b) : () => !1; } function r(p, v) { const b = p.$converter || v; return typeof b == "string" && b && o.has(b) ? o.get(b) || null : b || null; } function f(p, v, b, T, k, A = "", S = "") { return Object.keys(p).map((y) => { const N = I(1), P = y, E = p[y], j = Object.keys(E), M = E.title, D = E.type, V = i.get(D) || { type: "input-group", enableClear: !1 }, h = E.editor ? Object.assign({}, V, E.editor) : Object.assign({}, V), C = u(j, E, v), L = c(j, E, v); h.readonly = h.readonly === void 0 ? L() : h.readonly; const G = E.type === "cascade" ? f(E.properties, v, b, T, k, A, S) : [], B = !0; let F = r(E, S); const z = H({ get() { if (N.value) { if (["class", "style"].find((se) => se === P) && !F && (F = o.get("/converter/appearance.converter") || null), F && F.convertFrom) return F.convertFrom(b, y, k, A); const ie = b[y]; return Object.prototype.hasOwnProperty.call(E, "defaultValue") && (ie === void 0 || typeof ie == "string" && ie === "") ? E.type === "boolean" ? E.defaultValue : E.defaultValue || "" : ie; } return null; }, set(ie) { N.value += 1, F && F.convertTo ? (F.convertTo(T, y, ie, k, A), F.convertTo(b, y, ie, k, A)) : (T[y] = ie, b[y] = ie); } }), { refreshPanelAfterChanged: O, description: U, isExpand: K, parentPropertyID: te } = E, J = { propertyID: P, propertyName: M, propertyType: D, propertyValue: z, editor: h, visible: C, readonly: L, cascadeConfig: G, hideCascadeTitle: B, refreshPanelAfterChanged: O, description: U, isExpand: K, parentPropertyID: te }; return v[P] = J, J; }); } function l(p, v, b = {}) { const T = {}, k = n[p]; return k && k.categories ? Object.keys(k.categories).map((S) => { const g = k.categories[S], y = g == null ? void 0 : g.title, N = f(g.properties || {}, T, {}, b, v); return { categoryId: S, categoryName: y, properties: N }; }) : []; } function m(p, v, b, T, k = "") { const A = v.$ref.schema, S = v.$ref.converter, g = b[A], y = g.type, N = t(g), P = {}, E = n[y]; if (E && E.categories) { const j = E.categories[p], M = j == null ? void 0 : j.title; S && Object.keys(j.properties).forEach((h) => { j.properties[h].$converter = S; }); const D = (j == null ? void 0 : j.properties) || {}, V = f(D, P, N, g, T, k); return { categoryId: p, categoryName: M, properties: V }; } return { categoryId: p, categoryName: "", properties: [] }; } function d(p, v, b, T, k) { const A = p.type, S = t(p), g = {}; let y = k || n[A]; if (y && Object.keys(y).length === 0 && b && b.getPropConfig && (y = b.getPropConfig(T)), y && y.categories) { const N = []; return Object.keys(y.categories).map((P) => { const E = y.categories[P]; if (E.$ref) { N.push(m(P, E, p, v, T)); return; } const j = E == null ? void 0 : E.title, M = E == null ? void 0 : E.tabId, D = E == null ? void 0 : E.tabName, V = E == null ? void 0 : E.hide, h = E == null ? void 0 : E.hideTitle, C = f(E.properties || {}, g, S, p, v, T, E.$converter), { setPropertyRelates: L } = E, G = E == null ? void 0 : E.parentPropertyID; N.push({ categoryId: P, categoryName: j, tabId: M, tabName: D, hide: V, properties: C, hideTitle: h, setPropertyRelates: L, parentPropertyID: G }); }), N; } return []; } return { getPropertyConfigBySchema: d, getPropertyConfigByType: l, propertyConverterMap: o }; } const mn = {}, vn = {}; fn(mn, vn, jo); const hn = {}, yn = {}, { getSchemaByType: ml, resolveSchemaWithDefaultValue: ri, resolveSchemaToProps: vl, mappingSchemaToProps: hl, setDesignerContext: yl } = un(hn, yn), gn = {}, bn = {}; fn(gn, bn, ri); function Je(n, e, t = /* @__PURE__ */ new Map(), o = (s, u, c, r) => u, i = {}, a = (s) => s) { return dn[e.title] = e, pn[e.title] = o, mn[e.title] = i, vn[e.title] = a, hn[e.title] = e, yn[e.title] = o, gn[e.title] = i, bn[e.title] = a, (s = {}, u = !0) => { if (!u) return $o(s, t); const c = Ro(s, e, t), r = Object.keys(n).reduce((f, l) => (f[l] = n[l].default, f), {}); return Object.assign(r, c); }; } function zt(n, e) { return { customClass: e.class, customStyle: e.style }; } const Cn = /* @__PURE__ */ new Map([ ["appearance", zt] ]); function li(n, e, t) { if (t.componentFeature) { const o = JSON.parse(t.componentFeature); e.appearance = { class: "bg-white" }, e.contents = String(o.splitter).split(":").map((i) => { const a = n.getSchemaByType("response-layout-item"); return a.appearance = { class: `h-100 col-${i} px-0` }, a; }); } return e; } const ci = "https://json-schema.org/draft/2020-12/schema", ui = "https://farris-design.gitee.io/response-layout.schema.json", di = "response-layout", pi = "A Farris Container Component", fi = "object", mi = { id: { description: "The unique identifier for a Respnse Layout", type: "string" }, type: { description: "The type string of Respnse Layout component", type: "string", default: "response-layout" }, appearance: { description: "", type: "object", properties: { class: { type: "string" }, style: { type: "string" } }, default: {} }, contents: { description: "", type: "array", default: [] }, size: { description: "", type: "object", properties: { width: { type: "number" }, height: { type: "number" } }, default: null }, visible: { description: "", type: "boolean", default: !0 } }, vi = [ "id", "type", "contents" ], hi = { $schema: ci, $id: ui, title: di, description: pi, type: fi, properties: mi, required: vi }, Ut = { customClass: { type: String, default: "" }, customStyle: { type: String, default: "" } }, nn = Je(Ut, hi, Cn, li), Dt = /* @__PURE__ */ we({ name: "FResponseLayout", props: Ut, emits: [], setup(n, e) { function t(i, a) { i && a && a.split(" ").reduce((u, c) => (u[c] = !0, u), i); } const o = H(() => { const i = { "d-flex": !0 }; return t(i, n.customClass), i; }); return () => w("div", { class: o.value, style: n.customStyle }, [e.slots.default && e.slots.default()]); } }), yi = "https://json-schema.org/draft/2020-12/schema", gi = "https://farris-design.gitee.io/response-layout-item.schema.json", bi = "response-layout-item", Ci = "A Farris Container Component", wi = "object", Ti = { id: { description: "The unique identifier for a Respnse Layout Item", type: "string" }, type: { description: "The type string of Respnse Layout Item component", type: "string", default: "response-layout-item" }, appearance: { description: "", type: "object", properties: { class: { type: "string" }, style: { type: "string" } }, default: {} }, contents: { description: "", type: "array", default: [] }, size: { description: "", type: "object", properties: { width: { type: "number" }, height: { type: "number" } }, default: null }, visible: { description: "", type: "boolean", default: !0 } }, Si = [ "id", "type", "contents" ], Mi = { $schema: yi, $id: gi, title: bi, description: Ci, type: wi, properties: Ti, required: Si }, qt = { customClass: { type: String, default: "" }, customStyle: { type: String, default: "" } }, on = Je(qt, Mi, Cn), Nt = /* @__PURE__ */ we({ name: "FResponseLayoutItem", props: qt, emits: [], setup(n, e) { return () => w("div", { class: n.customClass, style: n.customStyle }, [e.slots.default && e.slots.default()]); } }); function Wt(n, e, t) { var M; const o = t && t.getStyles && t.getStyles() || "", i = t && t.getDesignerClass && t.getDesignerClass() || "", a = I(); let s; function u() { return (e == null ? void 0 : e.schema.componentType) === "frame" ? !1 : t && t.checkCanMoveComponent ? t.checkCanMoveComponent() : !0; } function c() { return !1; } function r() { return (e == null ? void 0 : e.schema.componentType) === "frame" ? !1 : t && t.checkCanDeleteComponent ? t.checkCanDeleteComponent() : !0; } function f() { return (e == null ? void 0 : e.schema.componentType) === "frame" ? !0 : t && t.hideNestedPaddingInDesginerView ? t.hideNestedPaddingInDesginerView() : !1; } function l(D) { if (!D || !D.value) return null; if (D.value.schema && D.value.schema.type === "component") return D.value; const V = I(D == null ? void 0 : D.value.parent), h = l(V); return h || null; } function m(D = e) { var L; if (t != null && t.getDraggableDesignItemElement) return t.getDraggableDesignItemElement(D); const { componentInstance: V, designerItemElementRef: h } = D; if (!V || !V.value) return null; const { getCustomButtons: C } = V.value; return V.value.canMove || C && ((L = C()) != null && L.length) ? h : m(D.parent); } function d(D) { return !!t && t.canAccepts(D); } function p() { return (e == null ? void 0 : e.schema.label) || (e == null ? void 0 : e.schema.title) || (e == null ? void 0 : e.schema.name); } function v() { } function b(D, V) { var h; !D || !V || (t != null && t.onAcceptMovedChildElement && t.onAcceptMovedChildElement(D, V), (h = e == null ? void 0 : e.setupContext) == null || h.emit("dragEnd")); } function T(D, V) { const { componentType: h } = D; let C = Gn(h, D, V); t && t.onResolveNewComponentSchema && (C = t.onResolveNewComponentSchema(D, C)); const L = h.toLowerCase().replace(/-/g, "_"); return C && !C.id && C.type === h && (C.id = `${L}_${Math.random().toString().slice(2, 6)}`), C; } function k(D) { D && t != null && t.onChildElementMovedOut && t.onChildElementMovedOut(D); } function A(...D) { if (t && t.getPropsConfig) return t.getPropsConfig(...D); } function S(D) { if (!D) return; const V = e == null ? void 0 : e.schema, { formSchemaUtils: h } = D; if (V && h.getExpressions().length) { const C = h.getExpressions().findIndex((L) => L.target === V.id); C > -1 && h.getExpressions().splice(C, 1); } } function g(D) { if (!D || !(e != null && e.schema)) return; const V = e.schema, { formSchemaUtils: h } = D; h.removeCommunicationInComponent(V); } function y(D) { t && t.onRemoveComponent && t.onRemoveComponent(), S(D), g(D), e != null && e.schema.contents && e.schema.contents.map((V) => { let h = V.id; V.type === "component-ref" && (h = V.component); const C = n.value.querySelectorAll(`#${h}-design-item`); C != null && C.length && Array.from(C).map((L) => { var G; (G = L == null ? void 0 : L.componentInstance) != null && G.value.onRemoveComponent && L.componentInstance.value.onRemoveComponent(D); }); }); } function N() { if (t && t.getCustomButtons) return t.getCustomButtons(); } function P(D) { var h, C; if (!((h = e == null ? void 0 : e.schema) != null && h.id)) return; if (!s && D && (s = D.formSchemaUtils), t != null && t.setComponentBasicInfoMap) { t.setComponentBasicInfoMap(); return; } let V = ""; if (t != null && t.getComponentTitle) V = t.getComponentTitle(); else { const { text: L, title: G, label: B, mainTitle: F, name: z, type: O } = e.schema; V = L || G || B || F || z || ((C = R[O]) == null ? void 0 : C.name); } V && s.getControlBasicInfoMap().set(e.schema.id, { componentTitle: V, parentPathName: V }); } function E(D) { var L; const { changeObject: V } = D, { propertyID: h, propertyValue: C } = V; if (["text", "title", "label", "name", "mainTitle"].includes((L = D == null ? void 0 : D.changeObject) == null ? void 0 : L.propertyID) && h && C && (P(), s)) { const G = s.getControlBasicInfoMap(), B = G.keys().toArray().filter((F) => { var z, O; return ((z = G.get(F)) == null ? void 0 : z.reliedComponentId) === ((O = e == null ? void 0 : e.schema) == null ? void 0 : O.id); }); B != null && B.length && B.forEach((F) => { const z = G.get(F).parentPathName.split(" > "); z[0] = C, G.get(F).parentPathName = z.join(" > "); }); } } function j(D) { if (E(D), t && t.onPropertyChanged) return t.onPropertyChanged(D); } return a.value = { canMove: u(), canSelectParent: c(), canDelete: r(), canNested: !f(), contents: e == null ? void 0 : e.schema.contents, elementRef: n, parent: (M = e == null ? void 0 : e.parent) == null ? void 0 : M.componentInstance, schema: e == null ? void 0 : e.schema, styles: o, designerClass: i, canAccepts: d, getBelongedComponentInstance: l, getDraggableDesignItemElement: m, getDraggingDisplayText: p, getPropConfig: A, getDragScopeElement: v, onAcceptMovedChildElement: b, onChildElementMovedOut: k, addNewChildComponentSchema: T, triggerBelongedComponentToMoveWhenMoved: !!t && t.triggerBelongedComponentToMoveWhenMoved || I(!1), triggerBelongedComponentToDeleteWhenDeleted: !!t && t.triggerBelongedComponentToDeleteWhenDeleted || I(!1), onRemoveComponent: y, getCustomButtons: N, onPropertyChanged: j, setComponentBasicInfoMap: P, updateContextSchema: e == null ? void 0 : e.updateContextSchema }, a; } const wn = I(0), xi = I(0); function Tn() { xi.value++; } function Ii(n) { const { formSchemaUtils: e, formStateMachineUtils: t } = n; function o(c, r = "") { return { path: r + c.code, field: c.id, fullPath: c.code }; } function i(c, r = "") { return e.getViewModelById(c).states.map((l) => o(l, r)); } function a(c) { const r = e.getRootViewModelId(), f = i(c); if (c === r) return f; const l = i(r, "root-component."); return [...f, ...l]; } function s(c) { return c.binding && c.binding.path || c.id || ""; } function u() { return t && t.getRenderStates() || []; } return { getVariables: a, getControlName: s, getStateMachines: u }; } class Fi { constructor(e) { Q(this, "sessionVariables", [ { key: "CurrentSysOrgName", name: "当前组织Name", description: "当前组织Name" }, // { // key: "CurrentSysOrgCode", // name: "当前组织Code", // description: "当前组织Code" // }, { key: "CurrentSysOrgId", name: "当前组织Id", description: "当前组织Id" }, { key: "CurrentUserName", name: "当前用户Name", description: "当前用户Name" }, { key: "CurrentUserCode", name: "当前用户Code", description: "当前用户Code" }, { key: "CurrentUserId", name: "当前用户Id", description: "当前用户Id" }, { key: "CurrentLanguage", name: "当前语言编号", description: "当前登录的语言编号,例如简体中文返回'zh-CHS',英文返回'en',繁体中文'zh-CHT'" } ]); Q(this, "expressionNames", { compute: "计算表达式", dependency: "依赖表达式", validate: "验证表达式", dataPicking: "帮助前表达式", visible: "可见表达式", readonly: "只读表达式", required: "必填表达式" }); Q(this, "getExpressionConverter", (e, t) => ({ convertFrom: (o, i, a, s) => { const u = a.getExpressionRuleValue(e, t || i); return u && u.value || ""; }, convertTo: (o, i, a, s, u) => { var c; if (i === "dataPicking" && (a != null && a.target)) { const r = `${a.target}_dataPicking`; ((c = a.rules) == null ? void 0 : c.some( (l) => l.id === r && l.value )) ? o.dictPickingExpressionId = r : delete o.dictPickingExpressionId; } s.updateExpression(a); } })); this.formSchemaService = e; } getExpressionRule(e, t) { const o = this.formSchemaService.getExpressions(); if (!o) return ""; const i = o.find((s) => s.target === e); if (!i) return ""; const a = i.rules.find((s) => s.type === t); return a || ""; } // 获取上下文表单变量 getContextFormVariables() { const { module: e } = this.formSchemaService.getFormSchema(); if (!e.viewmodels || e.viewmodels.length === 0) return []; const t = this.formSchemaService.getRootViewModelId(), o = this.formSchemaService.getViewModelById(t); if (!o || !o.states || o.states.length === 0) return []; const i = []; return o.states.forEach((a) => { i.push({ key: a.code, name: a.name, description: a.name, category: a.category }); }), i; } createTreeNode(e, t, o = "label") { return { id: e.id, name: e.name, bindingPath: e[o], parents: t, type: "field" }; } buildEntityFieldsTreeData(e = null, t) { const o = []; return e == null || e.forEach((i) => { var u; const a = this.createTreeNode(i, t); let s = []; (u = i.type) != null && u.fields && (s = this.buildEntityFieldsTreeData(i.type.fields, [...t, i.label])), o.push({ data: a, children: s, expanded: !0 }); }), o; } buildChildEntityTreeData(e = null, t) { const o = []; return e == null || e.forEach((i) => { var c, r; const a = this.createTreeNode(i, t); a.type = "entity"; const s = this.buildEntityFieldsTreeData((c = i.type) == null ? void 0 : c.fields, [...t, i.label]), u = this.buildChildEntityTreeData((r = i.type) == null ? void 0 : r.entities, [...t, i.label]); u != null && u.length && (s == null || s.push(...u)), o.push({ data: a, children: s || [], // 空值回退 expanded: !0 }); }), o; } getEntitiesTreeData() { const e = this.formSchemaService.getSchemaEntities(); if (!(e != null && e.length)) return []; const t = e[0]; if (!(t != null && t.type)) return []; const o = this.buildEntityFieldsTreeData(t.type.fields, [t.code]), i = this.buildChildEntityTreeData(t.type.entities, [t.code]); return i != null && i.length && (o == null || o.push(...i)), { entityCode: t.code, fields: [{ data: this.createTreeNode(t, [], "code"), children: o || [] }] }; } getEntitiesAndVariables() { return { entities: this.getEntitiesTreeData(), variables: { session: { name: "系统变量", items: this.sessionVariables, visible: !1 }, forms: { name: "表单变量", items: this.getContextFormVariables(), visible: !0 } } }; } onBeforeOpenExpression(e, t, o) { const i = o === "Field" ? e.binding.field : e.id, a = this.getExpressionRule(i, t), s = this.getEntitiesAndVariables(), u = { message: ["validate", "required", "dataPicking"].includes(t) && a ? a.message : "", ...s }; return a.messageType != null && (u.messageType = a.messageType), u; } buildRule(e, t, o, i) { const { expression: a, message: s, messageType: u } = t, c = { id: `${e}_${o}`, type: o, value: a }; return (o === "validate" || o === "dataPicking" || o === "required") && (c.message = s), o === "dataPicking" && (c.messageType = u), o === "validate" && i && (c.elementId = i), c; } getExpressionData() { const { expressions: e } = this.formSchemaService.getFormSchema().module; return e || []; } updateExpression(e, t, o, i) { const a = t === "Field" ? e.binding.field : e.id, s = this.buildRule(a, o, i, e.type === "form-group" ? e.id : ""); let c = this.getExpressionData().find((f) => f.targetType === t && f.target === a); const r = (f) => f.value.trim() === ""; if (c) { const f = c.rules.find((l) => l.id === s.id); if (f) r(s) ? c.rules = c.rules.filter((l) => l.id !== s.id) : (Object.assign(f, s), i === "validate" && e.type === "form-group" && (f.elementId = e.id)); else { if (r(s)) return null; c.rules = c.rules || [], c.rules.push(s); } } else { if (r(s)) return null; c = { target: `${a}`, rules: [s], targetType: t }; } return c; } getExpressionEditorOptions(e, t, o, i) { return o.reduce((a, s) => { var c, r; const u = t === "Field" ? (c = e == null ? void 0 : e.binding) == null ? void 0 : c.field : e.id; return a[s] = { hide: t === "Field" ? !!((r = e == null ? void 0 : e.binding) != null && r.field) : !1, description: "", title: this.expressionNames[s], type: "string", $converter: this.getExpressionConverter(u), refreshPanelAfterChanged: !0, editor: { type: "expression-editor", singleExpand: !1, dialogTitle: `${this.expressionNames[s]}编辑器`, showMessage: s === "validate" || s === "dataPicking" || s === "required", showMessageType: s === "dataPicking", beforeOpen: () => this.onBeforeOpenExpression(e, s, t), onSubmitModal: (f) => { const l = this.updateExpression(e, t, f, s); if (i) { const m = this.buildRule(u, f, s); i(m); } return l; } } }, a; }, {}); } getExpressionInfo(e, t, o) { const i = t === "Field" ? e.binding.field : e.id, a = this.getExpressionRule(i, o), s = { value: a && a.value, targetId: i, targetType: t, expressionType: o }; return a && a.message && (s.message = a.message), s; } getExpressionConfig(e, t, o = ["compute", "dependency", "validate"], i) { return { description: "表达式", title: "表达式", hide: !e.binding, properties: { ...this.getExpressionEditorOptions(e, t, o, i) } }; } getExpressionOptions(e, t, o) { const i = this.getExpressionInfo(e, t, o); return { dialogTitle: `${this.expressionNames[o]}编辑器`, singleExpand: !1, showMessage: o === "required", beforeOpen: () => this.onBeforeOpenExpression(e, o, t), expressionInfo: i }; } } class _t { constructor(e, t) { Q(this, "componentId"); Q(this, "viewModelId"); Q(this, "eventsEditorUtils"); Q(this, "formSchemaUtils"); Q(this, "formMetadataConverter"); Q(this, "designViewModelUtils"); Q(this, "designViewModelField"); Q(this, "controlCreatorUtils"); Q(this, "designerHostService"); Q(this, "designerContext"); Q(this, "schemaService", null); Q(this, "metadataService", null); Q(this, "propertyConfig", { type: "object", categories: {} }); var o; this.componentId = e, this.designerHostService = t, this.eventsEditorUtils = t.eventsEditorUtils, this.formSchemaUtils = t.formSchemaUtils, this.formMetadataConverter = t.formMetadataConverter, this.viewModelId = ((o = this.formSchemaUtils) == null ? void 0 : o.getViewModelIdByComponentId(e)) || "", this.designViewModelUtils = t.designViewModelUtils, this.controlCreatorUtils = t.controlCreatorUtils, this.metadataService = t.metadataService, this.schemaService = t.schemaService, this.designerContext = t.designerContext; } getFormDesignerInstance() { var e, t; return (t = (e = this.designerContext) == null ? void 0 : e.instances) == null ? void 0 : t.formDesigner.value; } getTableInfo() { var e; return (e = this.schemaService) == null ? void 0 : e.getTableInfoByViewModelId(this.viewModelId); } setDesignViewModelField(e) { var o; const t = e.binding && e.binding.type === "Form" && e.binding.field; if (t) { if (!this.designViewModelField) { const i = this.designViewModelUtils.getDgViewModel(this.viewModelId); this.designViewModelField = i.fields.find((a) => a.id === t); } e.updateOn = (o = this.designViewModelField) == null ? void 0 : o.updateOn; } } getBasicPropConfig(e) { return { description: "Basic Information", title: "基本信息", properties: { id: { description: "组件标识", title: "标识", type: "string", readonly: !0 }, type: { description: "组件类型", title: "控件类型", type: "select", editor: { type: "combo-list", textField: "name", valueField: "value", idField: "value", editable: !1, data: [{ value: e.type, name: R[e.type] && R[e.type].name }] } } } }; } getAppearanceConfig(e = null, t = {}, o) { const i = { title: "外观", description: "Appearance" }, a = { class: { title: "class样式", type: "string", description: "组件的CSS样式", $converter: "/converter/appearance.converter", parentPropertyID: "appearance" }, style: { title: "style样式", type: "string", description: "组件的样式", $converter: "/converter/appearance.converter", parentPropertyID: "appearance" } }; for (const s in t) a[s] = Object.assign(a[s] || {}, t[s]); return { ...i, properties: { ...a }, setPropertyRelates(s, u) { if (s) { switch (s && s.propertyID) { case "class": case "style": { wn.value++; break; } } o && o(s, e, u); } } }; } getPropertyEditorParams(e, t = [], o = "visible", i = {}, a = {}) { const { getVariables: s, getControlName: u, getStateMachines: c } = Ii(this.designerHostService), r = this.getRealTargetType(e), f = t && t.length > 0 ? t : ["Const", "Variable", "StateMachine", "Expression"], l = { type: "property-editor", propertyTypes: f }; return f.map((m) => { switch (m) { case "Const": Object.assign(l, { constType: "enum", constEnums: [{ id: !0, name: "是" }, { id: !1, name: "否" }] }, i); break; case "Expression": l.expressionConfig = this.getExpressionOptions(e, r, o); break; case "StateMachine": l.stateMachines = c(); break; case "Variable": Object.assign(l, { controlName: u(e), newVariablePrefix: "is", newVariableType: "Boolean", variables: s(this.viewModelId), onBeforeOpenVariables: (d) => { d.value = s(this.viewModelId); } }, a); break; } }), l; } getVisibleProperty(e, t = "") { var a; let o = ["Const", "Variable", "StateMachine", "Expression"]; return t === "gridFieldEditor" ? o = ["Const", "Expression"] : t === "form-group" && !((a = e.binding) != null && a.field) && (o = ["Const", "Variable", "StateMachine"]), { visible: { title: "是否可见", type: "boolean", description: "运行时组件是否可见", editor: this.getPropertyEditorParams(e, o, "visible") } }; } /** * 获取行为 * @param propertyData * @param viewModelId * @returns */ getBehaviorConfig(e, t = "", o = {}, i) { const a = { title: "行为", description: "" }, s = this.getVisibleProperty(e, t); for (const c in o) s[c] = Object.assign(s[c] || {}, o[c]); const u = this; return { ...a, properties: { ...s }, setPropertyRelates(c, r) { if (c) { switch (c.propertyID) { case "disabled": case "readonly": case "visible": u.afterMutilEditorChanged(e, c); break; } i && i(c, r); } } }; } /** * 当多值编辑器变更时 * @param propertyData * @param changeObject */ afterMutilEditorChanged(e, t) { this.addNewVariableToViewModel(t, this.viewModelId), this.updateExpressionValue(t), this.clearExpression(t, e); } /** * * @param propertyId * @param componentInstance * @returns */ updateElementByParentContainer(e, t) { const o = t && t.parent && t.parent.schema; if (!o) return; const i = o.contents.findIndex((s) => s.id === e), a = yt(o.contents[i]); o.contents.splice(i, 1), o.contents.splice(i, 0, a), Tn(); } /** * 属性编辑器,在编辑过程中会新增变量,此处需要将新增的变量追加到ViewModel中 * @param changeObject * @param viewModelId * @returns */ addNewVariableToViewModel(e, t) { const o = e.propertyValue; if (!(o && typeof o == "object") || !(o.type === "Variable" && o.isNewVariable)) return; const s = { id: o.field, category: "locale", code: o.fullPath, name: o.fullPath, type: o.newVariableType || "String" }; delete o.newVariableType, delete o.isNewVariable, this.formSchemaUtils.getVariableByCode(s.code) || this.formSchemaUtils.getViewModelById(t).states.push(s); } /** * 更新表达式到expressions节点 * @param changeObject */ updateExpressionValue(