UNPKG

@farris/ui-vue

Version:

Farris Vue, a Farris Design based Vue3 component library.

1,412 lines 401 kB
var zo = Object.defineProperty; var Yo = (n, t, e) => t in n ? zo(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e; var P = (n, t, e) => Yo(n, typeof t != "symbol" ? t + "" : t, e); import { defineComponent as tt, toRefs as qn, ref as S, computed as A, watch as ke, onMounted as Mt, createVNode as I, Fragment as Xt, reactive as yt, createApp as Gn, onUnmounted as ln, Transition as zn, mergeProps as Bt, createTextVNode as Rt, onBeforeUnmount as Yn, withDirectives as Uo, resolveDirective as Xo, nextTick as un, onBeforeMount as Qo, Teleport as Ko, shallowRef as Jo, render as dn, h as Zo, cloneVNode as er, inject as Tt, provide as tr, triggerRef as nr, isVNode as or } from "vue"; import { isPlainObject as In, cloneDeep as kt, isUndefined as ut, throttle as rr } from "lodash-es"; import { DgControl as On } from "../designer-canvas/index.esm.js"; import { useGuid as ir, resolveField as rt, FormSchemaEntityFieldTypeName as Pn, useCommonUtils as ar, useDateFormat as sr, useNumberFormat as lr, setFieldValue as hn, getCustomClass as fn, withInstall as Un, FormSchemaEntityField$Type as Dn, FormSchemaEntityFieldType$Type as ur } from "../common/index.esm.js"; import { useResizeObserver as Xn } from "@vueuse/core"; import { useIdentify as cr, useGroupData as dr, useFilter as fr, useHierarchy as pr, useLoading as mr, useDataView as hr, useSelection as vr, useSelectHierarchyItem as gr, useDataViewContainerStyle as yr, useCommandColumn as br, useColumn as wr, useSort as Cr, useGroupColumn as _r, useRow as xr, useEdit as Sr, useVisualDataBound as Tr, useVisualDataCell as kr, useVisualDataRow as Er, useVisualData as Mr, useCellPosition as Fr, useSidebar as Ir, useVirtualScroll as Or, useFitColumn as Pr, useFilterHistory as Dr, useColumnFilter as Vr, useDragColumn as Nr, getColumnHeader as Br, getSidebar as Rr, getDisableMask as Lr, getHorizontalScrollbar as Wr, getVerticalScrollbar as $r, getEmpty as Hr } from "../data-view/index.esm.js"; import "../modal/index.esm.js"; import jr from "../transfer/index.esm.js"; import Ar from "../tabs/index.esm.js"; import qr from "../order/index.esm.js"; import "../condition/index.esm.js"; import { FCheckbox as Gr } from "../checkbox/index.esm.js"; import zr from "../filter-bar/index.esm.js"; import Vn from "../tooltip/index.esm.js"; import Yr from "../pagination/index.esm.js"; import Ur from "../button/index.esm.js"; import Xr from "../search-box/index.esm.js"; import Qr from "../tags/index.esm.js"; import Kr, { FDynamicFormGroup as Jr, FDynamicFormInput as Zr } from "../dynamic-form/index.esm.js"; import { createPropsResolver as ei } from "../dynamic-resolver/index.esm.js"; import "../property-panel/index.esm.js"; import ti from "../accordion/index.esm.js"; import ni from "../avatar/index.esm.js"; import oi from "../../designer/button-edit/index.esm.js"; import ri from "../button-group/index.esm.js"; import ii from "../calendar/index.esm.js"; import ai from "../capsule/index.esm.js"; import Nn from "../../designer/checkbox/index.esm.js"; import Bn from "../../designer/checkbox-group/index.esm.js"; import vn from "../combo-list/index.esm.js"; import si from "../combo-tree/index.esm.js"; import li from "../component/index.esm.js"; import ui from "../color-picker/index.esm.js"; import ci from "../content-container/index.esm.js"; import di from "../date-picker/index.esm.js"; import fi from "../../designer/data-grid/index.esm.js"; import pi from "../dropdown/index.esm.js"; import mi from "../events-editor/index.esm.js"; import hi from "../field-selector/index.esm.js"; import vi from "../binding-selector/index.esm.js"; import gi from "../image-cropper/index.esm.js"; import yi from "../../designer/input-group/index.esm.js"; import bi from "../layout/index.esm.js"; import wi from "../list-nav/index.esm.js"; import Ci from "../list-view/index.esm.js"; import _i from "../lookup/index.esm.js"; import xi from "../mapping-editor/index.esm.js"; import Si from "../nav/index.esm.js"; import Ti from "../number-range/index.esm.js"; import ki from "../number-spinner/index.esm.js"; import Ei from "../page-header/index.esm.js"; import Mi from "../page-footer/index.esm.js"; import Fi from "../progress/index.esm.js"; import Ii from "../query-solution/index.esm.js"; import Oi from "../../designer/radio-group/index.esm.js"; import Pi from "../rate/index.esm.js"; import Di from "../response-toolbar/index.esm.js"; import Vi from "../response-layout/index.esm.js"; import Ni from "../response-layout-editor/index.esm.js"; import Bi from "../section/index.esm.js"; import Ri from "../smoke-detector/index.esm.js"; import Li from "../splitter/index.esm.js"; import Wi from "../step/index.esm.js"; import $i from "../switch/index.esm.js"; import Hi from "../text/index.esm.js"; import ji from "../time-picker/index.esm.js"; import Ai from "../tree-view/index.esm.js"; import qi from "../uploader/index.esm.js"; import Gi from "../verify-detail/index.esm.js"; import zi from "../video/index.esm.js"; import Yi from "../textarea/index.esm.js"; import Ui from "../schema-selector/index.esm.js"; import Xi from "../tree-grid/index.esm.js"; import Qi from "../event-parameter/index.esm.js"; import Ki from "../filter-condition-editor/index.esm.js"; import Ji from "../fieldset/index.esm.js"; import Zi from "../sort-condition-editor/index.esm.js"; import ea from "../menu-lookup/index.esm.js"; import ta from "../drawer/index.esm.js"; import na from "../json-editor/index.esm.js"; import oa from "../property-editor/index.esm.js"; import ra from "../expression-editor/index.esm.js"; import ia from "../code-editor/index.esm.js"; import aa from "../html-template/index.esm.js"; import "../external-container/index.esm.js"; import "../notify/index.esm.js"; const Qn = {}, Kn = {}; function Cn(n) { const { properties: t, title: e, ignore: o } = n, r = o && Array.isArray(o), i = Object.keys(t).reduce((a, s) => ((!r || !o.find((l) => l === s)) && (a[s] = t[s].type === "object" && t[s].properties ? Cn(t[s]) : kt(t[s].default)), a), {}); if (e && (!r || !o.find((a) => a === "id"))) { const a = e.toLowerCase().replace(/-/g, "_"); i.id = `${a}_${Math.random().toString().slice(2, 6)}`; } return i; } function sa(n) { const { properties: t, title: e, required: o } = n; if (o && Array.isArray(o)) { const r = o.reduce((i, a) => (i[a] = t[a].type === "object" && t[a].properties ? Cn(t[a]) : kt(t[a].default), i), {}); if (e && o.find((i) => i === "id")) { const i = e.toLowerCase().replace(/-/g, "_"); r.id = `${i}_${Math.random().toString().slice(2, 6)}`; } return r; } return { type: e }; } function Jn(n, t = {}, e) { const o = Qn[n]; if (o) { let r = sa(o); const i = Kn[n]; return r = i ? i({ getSchemaByType: Jn }, r, t, e) : r, r; } return null; } function la(n, t) { const e = Cn(t); return Object.keys(e).reduce((o, r) => (Object.prototype.hasOwnProperty.call(n, r) && (o[r] && In(o[r]) && In(n[r] || !n[r]) ? Object.assign(o[r], n[r] || {}) : o[r] = n[r]), o), e), e; } function Zn(n, t) { return Object.keys(n).filter((o) => n[o] != null).reduce((o, r) => { if (t.has(r)) { const i = t.get(r); if (typeof i == "string") o[i] = n[r]; else { const a = i(r, n[r], n); Object.assign(o, a); } } else o[r] = n[r]; return o; }, {}); } function ua(n, t, e = /* @__PURE__ */ new Map()) { const o = la(n, t); return Zn(o, e); } function ca(n = {}) { function t(c, d, u, f) { if (typeof u == "number") return f[c].length === u; if (typeof u == "object") { const m = Object.keys(u)[0], p = u[m]; if (m === "not") return Number(f[c].length) !== Number(p); if (m === "moreThan") return Number(f[c].length) >= Number(p); if (m === "lessThan") return Number(f[c].length) <= Number(p); } return !1; } function e(c, d, u, f) { return f[c] && f[c].propertyValue && String(f[c].propertyValue.value) === String(u); } const o = /* @__PURE__ */ new Map([ ["length", t], ["getProperty", e] ]); Object.keys(n).reduce((c, d) => (c.set(d, n[d]), c), o); function r(c, d) { const u = c; return typeof d == "number" ? [{ target: u, operator: "length", param: null, value: Number(d) }] : typeof d == "boolean" ? [{ target: u, operator: "getProperty", param: c, value: !!d }] : typeof d == "object" ? Object.keys(d).map((f) => { if (f === "length") return { target: u, operator: "length", param: null, value: d[f] }; const m = f, p = d[f]; return { target: u, operator: "getProperty", param: m, value: p }; }) : []; } function i(c) { return Object.keys(c).reduce((u, f) => { const m = r(f, c[f]); return u.push(...m), u; }, []); } function a(c, d) { if (o.has(c.operator)) { const u = o.get(c.operator); return u && u(c.target, c.param, c.value, d) || !1; } return !1; } function s(c, d) { return i(c).reduce((m, p) => m && a(p, d), !0); } function l(c, d) { const u = Object.keys(c), f = u.includes("allOf"), m = u.includes("anyOf"), p = f || m, v = (p ? c[p ? f ? "allOf" : "anyOf" : "allOf"] : [c]).map((g) => s(g, d)); return f ? !v.includes(!1) : v.includes(!0); } return { parseValueSchema: l }; } const de = { 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: "列表导航" }, "filter-bar": { type: "filter-bar", name: "筛选条" } }, da = {}, fa = {}; ca(); function Wt(n, t, e = /* @__PURE__ */ new Map(), o = (a, s, l, c) => s, r = {}, i = (a) => a) { return Qn[t.title] = t, Kn[t.title] = o, da[t.title] = r, fa[t.title] = i, (a = {}, s = !0) => { if (!s) return Zn(a, e); const l = ua(a, t, e), c = Object.keys(n).reduce((d, u) => (d[u] = n[u].default, d), {}); return Object.assign(c, l); }; } function cn(n, t) { return { customClass: t.class, customStyle: t.style }; } function pa() { function n(t, e) { const { dataSource: o } = t || {}; return o === void 0 ? {} : {}; } return { resolve: n }; } function ma() { function n(t, e) { return t.selectItemById(e); } return { selectItemById: n }; } function ha() { function n(t, e) { const { columns: o } = e; return t.updateColumns(o); } return { updateColumns: n }; } const va = /* @__PURE__ */ new Map([ ["appearance", cn] ]), ga = "https://json-schema.org/draft/2020-12/schema", ya = "https://farris-design.gitee.io/switch.schema.json", ba = "switch", wa = "A Farris Component", Ca = "object", _a = { 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 } }, xa = [ "type" ], Sa = [ "id", "appearance", "binding" ], Ta = { $schema: ga, $id: ya, title: ba, description: wa, type: Ca, properties: _a, required: xa, ignore: Sa }; function ka(n, t, e) { return t; } const _n = { modelValue: { type: 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 } }, eo = Wt(_n, Ta, va, ka), en = /* @__PURE__ */ tt({ name: "FSwitch", props: _n, emits: ["update:modelValue", "modelValueChanged"], setup(n, t) { const { disabled: e, size: o, onLabel: r, offLabel: i, onBackground: a, offBackground: s, onColor: l, offColor: c, readonly: d } = qn(n), u = S(!!n.modelValue), f = S(), m = A(() => ({ switch: !0, "f-cmp-switch": !0, checked: u.value, disabled: d.value || e.value, "switch-large": o.value === "large", "switch-medium": o.value === "medium", "switch-small": o.value === "small" })), p = A(() => u.value ? { outline: "none", background: a.value } : { outline: "none", backgroundColor: s.value }), M = A(() => u.value ? { background: l.value } : { backgroundColor: c.value }), w = A(() => (r == null ? void 0 : r.value) || (i == null ? void 0 : i.value)); function v() { d.value || e.value || (u.value = !u.value, t.emit("update:modelValue", u.value)); } return ke(u, (b, g) => { b !== g && t.emit("modelValueChanged", b); }), ke(() => n.modelValue, (b, g) => { b !== g && (u.value = b); }), Mt(() => { var b; n.focusOnCreated && ((b = f.value) == null || b.focus()); }), () => I("span", { ref: f, tabindex: "0", role: "button", class: m.value, style: p.value, onClick: v }, [w.value && I("span", { class: "switch-pane" }, [I("span", { class: "switch-label-checked" }, [r == null ? void 0 : r.value]), I("span", { class: "switch-label-unchecked" }, [i == null ? void 0 : i.value])]), I("small", { style: M.value }, [t.slots.default && t.slots.default()])]); } }); function to(n, t, e) { var h; const o = e && e.getStyles && e.getStyles() || "", r = e && e.getDesignerClass && e.getDesignerClass() || "", i = S(); function a() { return (t == null ? void 0 : t.schema.componentType) === "frame" ? !1 : e && e.checkCanMoveComponent ? e.checkCanMoveComponent() : !0; } function s() { return !1; } function l() { return (t == null ? void 0 : t.schema.componentType) === "frame" ? !1 : e && e.checkCanDeleteComponent ? e.checkCanDeleteComponent() : !0; } function c() { return (t == null ? void 0 : t.schema.componentType) === "frame" ? !0 : e && e.hideNestedPaddingInDesginerView ? e.hideNestedPaddingInDesginerView() : !1; } function d(x) { if (!x || !x.value) return null; if (x.value.schema && x.value.schema.type === "component") return x.value; const C = S(x == null ? void 0 : x.value.parent), E = d(C); return E || null; } function u(x = t) { var D; if (e != null && e.getDraggableDesignItemElement) return e.getDraggableDesignItemElement(x); const { componentInstance: C, designerItemElementRef: E } = x; if (!C || !C.value) return null; const { getCustomButtons: y } = C.value; return C.value.canMove || y && ((D = y()) != null && D.length) ? E : u(x.parent); } function f(x) { return !!e && e.canAccepts(x); } function m() { return (t == null ? void 0 : t.schema.label) || (t == null ? void 0 : t.schema.title) || (t == null ? void 0 : t.schema.name); } function p() { } function M(x, C) { var E; !x || !C || (e != null && e.onAcceptMovedChildElement && e.onAcceptMovedChildElement(x, C), (E = t == null ? void 0 : t.setupContext) == null || E.emit("dragEnd")); } function w(x, C) { const { componentType: E } = x; let y = Jn(E, x, C); e && e.onResolveNewComponentSchema && (y = e.onResolveNewComponentSchema(x, y)); const D = E.toLowerCase().replace(/-/g, "_"); return y && !y.id && y.type === E && (y.id = `${D}_${Math.random().toString().slice(2, 6)}`), y; } function v(x) { x && e != null && e.onChildElementMovedOut && e.onChildElementMovedOut(x); } function b(...x) { if (e && e.getPropsConfig) return e.getPropsConfig(...x); } function g(x) { if (!x) return; const C = t == null ? void 0 : t.schema, { formSchemaUtils: E } = x; if (C && E.getExpressions().length) { const y = E.getExpressions().findIndex((D) => D.target === C.id); y > -1 && E.getExpressions().splice(y, 1); } } function _(x) { e && e.onRemoveComponent && e.onRemoveComponent(), g(x), t != null && t.schema.contents && t.schema.contents.map((C) => { let E = C.id; C.type === "component-ref" && (E = C.component); const y = n.value.querySelectorAll(`#${E}-design-item`); y != null && y.length && Array.from(y).map((D) => { var V; (V = D == null ? void 0 : D.componentInstance) != null && V.value.onRemoveComponent && D.componentInstance.value.onRemoveComponent(x); }); }); } function T() { if (e && e.getCustomButtons) return e.getCustomButtons(); } function k(x) { if (e && e.onPropertyChanged) return e.onPropertyChanged(x); } return i.value = { canMove: a(), canSelectParent: s(), canDelete: l(), canNested: !c(), contents: t == null ? void 0 : t.schema.contents, elementRef: n, parent: (h = t == null ? void 0 : t.parent) == null ? void 0 : h.componentInstance, schema: t == null ? void 0 : t.schema, styles: o, designerClass: r, canAccepts: f, getBelongedComponentInstance: d, getDraggableDesignItemElement: u, getDraggingDisplayText: m, getPropConfig: b, getDragScopeElement: p, onAcceptMovedChildElement: M, onChildElementMovedOut: v, addNewChildComponentSchema: w, triggerBelongedComponentToMoveWhenMoved: !!e && e.triggerBelongedComponentToMoveWhenMoved || S(!1), triggerBelongedComponentToDeleteWhenDeleted: !!e && e.triggerBelongedComponentToDeleteWhenDeleted || S(!1), onRemoveComponent: _, getCustomButtons: T, onPropertyChanged: k }, i; } const Ea = S(0); function Ma() { Ea.value++; } const Lt = S(0); function Fa(n, t) { const e = t.getBoundingClientRect(), o = n.getBoundingClientRect(), r = o.top >= e.top, i = o.top <= e.bottom; return r && i; } function Ia(n) { const t = n.querySelector(".component-btn-group"); if (!t) return; t.style.display = ""; const e = t.getBoundingClientRect(); if (!(e.top === 0 && e.left === 0)) { const o = t.querySelector("div"); if (o) { const r = o.getBoundingClientRect(); o.style.top = e.top + "px"; let i = e.left - r.width; const a = document.querySelector(".editorDiv"); if (a) { const s = a.getBoundingClientRect(); i < s.left && ({ left: i } = n.getBoundingClientRect()); } o.style.left = i + "px"; } } } function Oa(n) { if (!window.scrollContainerList) return; const t = Array.from(window.scrollContainerList); if (t.length && t.length === 1) { const e = t[0], o = document.querySelector(`[id=${e}]`); if (o && o.contains(n)) return o; } } function no(n) { if (!n) return; const t = n.getBoundingClientRect(); if (t.width === 0 && t.height === 0) return; const e = n.querySelector(".component-btn-group"); if (e) { let o = !0; const r = Oa(n); if (r && (o = Fa(n, r)), !o) { e.style.display = "none"; return; } Ia(n); } } function Pa(n) { if (!n) return; let t; n.className.includes("dgComponentSelected") ? t = n : t = n.querySelector(".dgComponentSelected"), t && no(t); } function Da(n) { const { formSchemaUtils: t, formStateMachineUtils: e } = n; function o(l, c = "") { return { path: c + l.code, field: l.id, fullPath: l.code }; } function r(l, c = "") { return t.getViewModelById(l).states.map((u) => o(u, c)); } function i(l) { const c = t.getRootViewModelId(), d = r(l); if (l === c) return d; const u = r(c, "root-component."); return [...d, ...u]; } function a(l) { return l.binding && l.binding.path || l.id || ""; } function s() { return e && e.getRenderStates() || []; } return { getVariables: i, getControlName: a, getStateMachines: s }; } class oo { constructor(t) { P(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'" } ]); P(this, "expressionNames", { compute: "计算表达式", dependency: "依赖表达式", validate: "验证表达式", dataPicking: "帮助前表达式", visible: "可见表达式", readonly: "只读表达式", required: "必填表达式" }); P(this, "getExpressionConverter", (t, e) => ({ convertFrom: (o, r, i, a) => { const s = i.getExpressionRuleValue(t, e || r); return s && s.value || ""; }, convertTo: (o, r, i, a, s) => { var l; if (r === "dataPicking" && (i != null && i.target)) { const c = `${i.target}_dataPicking`; ((l = i.rules) == null ? void 0 : l.some( (u) => u.id === c && u.value )) ? o.dictPickingExpressionId = c : delete o.dictPickingExpressionId; } a.updateExpression(i); } })); this.formSchemaService = t; } getExpressionRule(t, e) { const o = this.formSchemaService.getExpressions(); if (!o) return ""; const r = o.find((a) => a.target === t); if (!r) return ""; const i = r.rules.find((a) => a.type === e); return i || ""; } // 获取上下文表单变量 getContextFormVariables() { const { module: t } = this.formSchemaService.getFormSchema(); if (!t.viewmodels || t.viewmodels.length === 0) return []; const e = this.formSchemaService.getRootViewModelId(), o = this.formSchemaService.getViewModelById(e); if (!o || !o.states || o.states.length === 0) return []; const r = []; return o.states.forEach((i) => { r.push({ key: i.code, name: i.name, description: i.name, category: i.category }); }), r; } createTreeNode(t, e, o = "label") { return { id: t.id, name: t.name, bindingPath: t[o], parents: e }; } buildEntityFieldsTreeData(t = null, e) { const o = []; return t == null || t.forEach((r) => { var s; const i = this.createTreeNode(r, e); let a = []; (s = r.type) != null && s.fields && (a = this.buildEntityFieldsTreeData(r.type.fields, [...e, r.label])), o.push({ data: i, children: a, expanded: !0 }); }), o; } buildChildEntityTreeData(t = null, e) { const o = []; return t == null || t.forEach((r) => { var l, c; const i = this.createTreeNode(r, e), a = this.buildEntityFieldsTreeData((l = r.type) == null ? void 0 : l.fields, [...e, r.label]), s = this.buildChildEntityTreeData((c = r.type) == null ? void 0 : c.entities, [...e, r.label]); s != null && s.length && (a == null || a.push(...s)), o.push({ data: i, children: a || [], // 空值回退 expanded: !0 }); }), o; } getEntitiesTreeData() { const t = this.formSchemaService.getSchemaEntities(); if (!(t != null && t.length)) return []; const e = t[0]; if (!(e != null && e.type)) return []; const o = this.buildEntityFieldsTreeData(e.type.fields, [e.code]), r = this.buildChildEntityTreeData(e.type.entities, [e.code]); return r != null && r.length && (o == null || o.push(...r)), { entityCode: e.code, fields: [{ data: this.createTreeNode(e, [], "code"), children: o || [] }] }; } getEntitiesAndVariables() { return { entities: this.getEntitiesTreeData(), variables: { session: { name: "系统变量", items: this.sessionVariables, visible: !1 }, forms: { name: "表单变量", items: this.getContextFormVariables(), visible: !0 } } }; } onBeforeOpenExpression(t, e, o) { const r = o === "Field" ? t.binding.field : t.id, i = this.getExpressionRule(r, e), a = this.getEntitiesAndVariables(), s = { message: ["validate", "required", "dataPicking"].includes(e) && i ? i.message : "", ...a }; return i.messageType != null && (s.messageType = i.messageType), s; } buildRule(t, e, o, r) { const { expression: i, message: a, messageType: s } = e, l = { id: `${t}_${o}`, type: o, value: i }; return (o === "validate" || o === "dataPicking" || o === "required") && (l.message = a), o === "dataPicking" && (l.messageType = s), o === "validate" && r && (l.elementId = r), l; } getExpressionData() { const { expressions: t } = this.formSchemaService.getFormSchema().module; return t || []; } updateExpression(t, e, o, r) { const i = e === "Field" ? t.binding.field : t.id, a = this.buildRule(i, o, r, t.type === "form-group" ? t.id : ""); let l = this.getExpressionData().find((d) => d.targetType === e && d.target === i); const c = (d) => d.value.trim() === ""; if (l) { const d = l.rules.find((u) => u.id === a.id); if (d) c(a) ? l.rules = l.rules.filter((u) => u.id !== a.id) : (Object.assign(d, a), r === "validate" && t.type === "form-group" && (d.elementId = t.id)); else { if (c(a)) return null; l.rules = l.rules || [], l.rules.push(a); } } else { if (c(a)) return null; l = { target: `${i}`, rules: [a], targetType: e }; } return l; } getExpressionEditorOptions(t, e, o, r) { return o.reduce((i, a) => { var l, c; const s = e === "Field" ? (l = t == null ? void 0 : t.binding) == null ? void 0 : l.field : t.id; return i[a] = { hide: e === "Field" ? !!((c = t == null ? void 0 : t.binding) != null && c.field) : !1, description: "", title: this.expressionNames[a], type: "string", $converter: this.getExpressionConverter(s), editor: { type: "expression-editor", singleExpand: !1, dialogTitle: `${this.expressionNames[a]}编辑器`, showMessage: a === "validate" || a === "dataPicking" || a === "required", showMessageType: a === "dataPicking", beforeOpen: () => this.onBeforeOpenExpression(t, a, e), onSubmitModal: (d) => { const u = this.updateExpression(t, e, d, a); if (r) { const f = this.buildRule(s, d, a); r(f); } return u; } } }, i; }, {}); } getExpressionInfo(t, e, o) { const r = e === "Field" ? t.binding.field : t.id, i = this.getExpressionRule(r, o), a = { value: i && i.value, targetId: r, targetType: e, expressionType: o }; return i && i.message && (a.message = i.message), a; } getExpressionConfig(t, e, o = ["compute", "dependency", "validate"], r) { return { description: "表达式", title: "表达式", properties: { ...this.getExpressionEditorOptions(t, e, o, r) } }; } getExpressionOptions(t, e, o) { const r = this.getExpressionInfo(t, e, o); return { dialogTitle: `${this.expressionNames[o]}编辑器`, singleExpand: !1, showMessage: o === "required", beforeOpen: () => this.onBeforeOpenExpression(t, o, e), expressionInfo: r }; } } class ro { constructor(t, e) { P(this, "componentId"); P(this, "viewModelId"); P(this, "eventsEditorUtils"); P(this, "formSchemaUtils"); P(this, "formMetadataConverter"); P(this, "designViewModelUtils"); P(this, "designViewModelField"); P(this, "controlCreatorUtils"); P(this, "designerHostService"); P(this, "schemaService", null); P(this, "metadataService", null); P(this, "propertyConfig", { type: "object", categories: {} }); var o; this.componentId = t, this.designerHostService = e, this.eventsEditorUtils = e.eventsEditorUtils, this.formSchemaUtils = e.formSchemaUtils, this.formMetadataConverter = e.formMetadataConverter, this.viewModelId = ((o = this.formSchemaUtils) == null ? void 0 : o.getViewModelIdByComponentId(t)) || "", this.designViewModelUtils = e.designViewModelUtils, this.controlCreatorUtils = e.controlCreatorUtils, this.metadataService = e.metadataService, this.schemaService = e.schemaService; } getTableInfo() { var t; return (t = this.schemaService) == null ? void 0 : t.getTableInfoByViewModelId(this.viewModelId); } setDesignViewModelField(t) { var o; const e = t.binding && t.binding.type === "Form" && t.binding.field; if (e) { if (!this.designViewModelField) { const r = this.designViewModelUtils.getDgViewModel(this.viewModelId); this.designViewModelField = r.fields.find((i) => i.id === e); } t.updateOn = (o = this.designViewModelField) == null ? void 0 : o.updateOn; } } getBasicPropConfig(t) { 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: t.type, name: de[t.type].name }] } } } }; } getAppearanceConfig(t = null, e = {}, o) { const r = { title: "外观", description: "Appearance" }, i = { class: { title: "class样式", type: "string", description: "组件的CSS样式", $converter: "/converter/appearance.converter" }, style: { title: "style样式", type: "string", description: "组件的样式", $converter: "/converter/appearance.converter" } }; for (const a in e) i[a] = Object.assign(i[a] || {}, e[a]); return { ...r, properties: { ...i }, setPropertyRelates(a, s) { if (a) { switch (a && a.propertyID) { case "class": case "style": { Lt.value++; break; } } o && o(a, t, s); } } }; } getPropertyEditorParams(t, e = [], o = "visible", r = {}, i = {}) { const { getVariables: a, getControlName: s, getStateMachines: l } = Da(this.designerHostService), c = this.getRealTargetType(t), d = e && e.length > 0 ? e : ["Const", "Variable", "StateMachine", "Expression"], u = { type: "property-editor", propertyTypes: d }; return d.map((f) => { switch (f) { case "Const": Object.assign(u, { constType: "enum", constEnums: [{ id: !0, name: "是" }, { id: !1, name: "否" }] }, r); break; case "Expression": u.expressionConfig = this.getExpressionOptions(t, c, o); break; case "StateMachine": u.stateMachines = l(); break; case "Variable": Object.assign(u, { controlName: s(t), newVariablePrefix: "is", newVariableType: "Boolean", variables: a(this.viewModelId), onBeforeOpenVariables: (m) => { m.value = a(this.viewModelId); } }, i); break; } }), u; } getVisibleProperty(t, e = "") { return { visible: { title: "是否可见", type: "boolean", description: "运行时组件是否可见", editor: this.getPropertyEditorParams(t, e === "gridFieldEditor" ? ["Const", "Expression"] : ["Const", "Variable", "StateMachine", "Expression"], "visible") } }; } /** * 获取行为 * @param propertyData * @param viewModelId * @returns */ getBehaviorConfig(t, e = "", o = {}, r) { const i = { title: "行为", description: "" }, a = this.getVisibleProperty(t, e); for (const l in o) a[l] = Object.assign(a[l] || {}, o[l]); const s = this; return { ...i, properties: { ...a }, setPropertyRelates(l, c) { if (l) { switch (l.propertyID) { case "disabled": case "readonly": case "visible": s.afterMutilEditorChanged(t, l); break; } r && r(l, c); } } }; } /** * 当多值编辑器变更时 * @param propertyData * @param changeObject */ afterMutilEditorChanged(t, e) { this.addNewVariableToViewModel(e, this.viewModelId), this.updateExpressionValue(e), this.clearExpression(e, t); } /** * * @param propertyId * @param componentInstance * @returns */ updateElementByParentContainer(t, e) { const o = e && e.parent && e.parent.schema; if (!o) return; const r = o.contents.findIndex((a) => a.id === t), i = kt(o.contents[r]); o.contents.splice(r, 1), o.contents.splice(r, 0, i), Ma(); } /** * 属性编辑器,在编辑过程中会新增变量,此处需要将新增的变量追加到ViewModel中 * @param changeObject * @param viewModelId * @returns */ addNewVariableToViewModel(t, e) { const o = t.propertyValue; if (!(o && typeof o == "object") || !(o.type === "Variable" && o.isNewVariable)) return; const a = { id: o.field, category: "locale", code: o.fullPath, name: o.fullPath, type: o.newVariableType || "String" }; delete o.newVariableType, delete o.isNewVariable, this.formSchemaUtils.getVariableByCode(a.code) || this.formSchemaUtils.getViewModelById(e).states.push(a); } /** * 更新表达式到expressions节点 * @param changeObject */ updateExpressionValue(t) { const e = t.propertyValue; if (!((e && e.type) === "Expression" && e.expressionInfo)) return; const { expressionId: i, expressionInfo: a } = e, { targetId: s, targetType: l, expressionType: c, value: d, message: u } = a, f = this.formSchemaUtils.getModule(); f.expressions ?? (f.expressions = []); const { expressions: m } = f; let p = m.find((w) => w.target === s); p || (p = { target: s, rules: [], targetType: l }, m.push(p)); const M = p.rules.find((w) => w.type === c); if (M) M.value = d, M.message = u; else { const w = { id: i, type: c, value: d, message: u }; p.rules.push(w); } delete e.expressionInfo; } /** * 属性类型切换为非表达式后,清除原表达式 * @param changeObject * @param propertyData * @returns */ clearExpression(t, e) { const o = t.propertyValue; if (o && o.type === "Expression") return; const i = t.propertyID, a = this.formSchemaUtils.getExpressions(), s = e.binding ? e.binding.field : e.id, l = a.find((c) => c.target === s); !l || !l.rules || (l.rules = l.rules.filter((c) => c.type !== i)); } getExpressionOptions(t, e, o) { return new oo(this.formSchemaUtils).getExpressionOptions(t, e, o); } getRealTargetType(t) { return ["response-toolbar-item", "tab-toolbar-item", "section-toolbar-item"].indexOf(t.type) > -1 ? "Button" : t.binding && t.binding.field ? "Field" : "Container"; } } const Ht = class Ht { /** * 根据绑定字段类型获取可用的输入类控件 */ static getEditorTypesByMDataType(t, e = "") { let o = Ht.fieldControlTypeMapping[t]; if (e === "data-grid-column" && (o != null && o.length)) { const r = [de["check-group"].type, de["radio-group"].type]; o = o.filter((i) => !r.includes(i.key)); } return o; } /** * 获取所有输入类控件 */ static getAllInputTypes() { const t = []; for (const e in Ht.fieldControlTypeMapping) Ht.fieldControlTypeMapping[e].forEach((o) => { t.find((r) => r.key === o.key && r.value === o.value) || t.push({ key: o.key, value: o.value }); }); return t; } /** * 提供schema字段基础属性和DOM控件属性的映射 * @param control 控件元数据 */ static mappingDomPropAndSchemaProp(t, e) { var i; const o = (i = t.editor) == null ? void 0 : i.type, r = []; return (t.type === de["data-grid-column"].type || t.type === de["tree-grid-column"].type) && e && e.categoryId && e.categoryId.indexOf("gridFieldEditor") < 0 && r.push({ domField: "title", schemaField: "name" }), r.push({ domField: "label", schemaField: "name" }), r.push({ domField: "editor.required", schemaField: "require" }), r.push({ domField: "editor.readonly", schemaField: "readonly" }), (o === de["input-group"].type || o === de.textarea.type || o === de["number-spinner"].type) && r.push({ domField: "editor.maxLength", schemaField: "type.length" }), o === de["number-spinner"].type && r.push({ domField: "editor.precision", schemaField: "type.precision" }), (t.type === de["data-grid-column"].type || t.type === de["tree-grid-column"].type) && r.push({ domField: "formatter.precision", schemaField: "type.precision" }), (o === de["combo-list"].type || o === de["radio-group"].type) && r.push({ domField: "editor.data", schemaField: "type.enumValues" }), (t.type === de["data-grid-column"].type || t.type === de["tree-grid-column"].type) && r.push({ domField: "formatter.data", schemaField: "type.enumValues" }), o === de["date-picker"].type && (r.push({ domField: "editor.displayFormat", schemaField: "editor.format" }), r.push({ domField: "editor.fieldType", schemaField: "type.name" })), o === de["number-spinner"].type && (r.push({ domField: "editor.max", schemaField: "editor.maxValue" }), r.push({ domField: "editor.min", schemaField: "editor.minValue" })), o === de.lookup.type && (r.push({ domField: "editor.dataSource", schemaField: "editor.dataSource" }), r.push({ domField: "editor.valueField", schemaField: "editor.valueField" }), r.push({ domField: "editor.textField", schemaField: "editor.textField" }), r.push({ domField: "editor.displayType", schemaField: "editor.displayType" }), r.push({ domField: "editor.mapFields", schemaField: "editor.mapFields" }), r.push({ domField: "editor.helpId", schemaField: "editor.helpId" })), r.push({ domField: "path", schemaField: "bindingPath" }), r.push({ domField: "binding.path", schemaField: "bindingField" }), r.push({ domField: "binding.fullPath", schemaField: "path" }), (t.type === de["data-grid-column"].type || t.type === de["tree-grid-column"].type) && r.push({ domField: "field", schemaField: "bindingPath" }), r; } }; /** * <字段类型,可配置的控件类型列表>的映射 */ P(Ht, "fieldControlTypeMapping", { String: [ { key: de["input-group"].type, value: de["input-group"].name }, { key: de.lookup.type, value: de.lookup.name }, { key: de["date-picker"].type, value: de["date-picker"].name }, { key: de["check-group"].type, value: de["check-group"].name }, { key: de["radio-group"].type, value: de["radio-group"].name }, { key: de["combo-list"].type, value: de["combo-list"].name }, { key: de.textarea.type, value: de.textarea.name }, { key: de["time-picker"].type, value: de["time-picker"].name } ], Text: [ { key: de.textarea.type, value: de.textarea.name }, { key: de.lookup.type, value: de.lookup.name } ], Decimal: [ { key: de["number-spinner"].type, value: de["number-spinner"].name } ], Integer: [ { key: de["number-spinner"].type, value: de["number-spinner"].name } ], Number: [ { key: de["number-spinner"].type, value: de["number-spinner"].name } ], BigNumber: [ { key: de["number-spinner"].type, value: de["number-spinner"].name } ], Date: [ { key: de["date-picker"].type, value: de["date-picker"].name } ], DateTime: [ { key: de["date-picker"].type, value: de["date-picker"].name } ], Boolean: [ { key: de.switch.type, value: de.switch.name }, { key: de["check-box"].type, value: de["check-box"].name } ], Enum: [ { key: de["combo-list"].type, value: de["combo-list"].name }, { key: de["radio-group"].type, value: de["radio-group"].name } ], Object: [ { key: de.lookup.type, value: de.lookup.name }, { key: de["combo-list"].type, value: de["combo-list"].name }, { key: de["radio-group"].type, value: de["radio-group"].name } ] }); let tn = Ht; var Kt = /* @__PURE__ */ ((n) => (n.Form = "Form", n.Variable = "Variable", n))(Kt || {}); class Va { constructor() { /** 控件标题 */ P(this, "label", ""); /** 控件id */ P(this, "id", ""); /** 每个控件占用的栅格数 */ P(this, "columnInSM", 12); P(this, "columnInMD", 6); P(this, "columnInLG", 3); P(this, "columnInEL", 2); /** 每个控件占用的列数 */ P(this, "displayWidthInSM", 1); P(this, "displayWidthInMD", 1); P(this, "displayWidthInLG", 1); P(this, "displayWidthInEL", 1); /** 编辑器内部默认显示的屏幕大小-----可以去掉 */ P(this, "displayColumnCountAtBreakPoint", "md"); /** 控件所在行,传0即可-----编辑器内部使用 */ P(this, "tagRow", 0); /** 控件是否显示上方空白:传0即可-----编辑器内部使用 */ P(this, "showTopBorder", 0); /** 区域,从1开始。卡片内的控件从上往下,从左往右划分区域,遇到分组fieldSet时group+1,分组结束后group+1 */ P(this, "group", 1); /** 控件是否符合标准的class配置(设计器用的) */ P(this, "isSupportedClass", !0); /** 控件所在分组id(设计器用的) */ P(this, "fieldSetId", ""); } } function Na(n) { let t, e; const o = /* @__PURE__ */ new Map(); let r = []; function i(d, u) { const m = d.split(" ").filter((b) => b.startsWith("col-")); if (m.length === 0) { u.isSupportedClass = !1; return; } let p = m.find((b) => /^col-([1-9]|10|11|12)$/.test(b)), M = m.find((b) => /^col-md-([1-9]|10|11|12)$/.test(b)), w = m.find((b) => /^col-xl-([1-9]|10|11|12)$/.test(b)), v = m.find((b) => /^col-el-([1-9]|10|11|12)$/.test(b)); p = p || "col-12", u.columnInSM = parseInt(p.replace("col-", ""), 10), u.displayWidthInSM = u.columnInSM / 12, u.displayWidthInSM !== 1 && (u.isSupportedClass = !1), M = M || "col-md-" + u.columnInSM, u.columnInMD = parseInt(M.replace("col-md-", ""), 10), u.displayWidthInMD = u.columnInMD / 6, [1, 2].includes(u.displayWidthInMD) || (u.isSupportedClass = !1), w = w || "col-xl-" + u.columnInMD, u.columnInLG = parseInt(w.replace("col-xl-", ""), 10), u.displayWidthInLG = u.columnInLG / 3, [1, 2, 3, 4].includes(u.displayWidthInLG) || (u.isSupportedClass = !1), v = v || "col-el-" + u.columnInLG, u.columnInEL = parseInt(v.replace("col-el-", ""), 10), u.displayWidthInEL = u.columnInEL / 2, [1, 2, 3, 4, 5, 6].includes(u.displayWidthInEL) || (u.isSupportedClass = !1); } function a(d, u, f, m = !1) { let p = !1; d.contents.forEach((M) => { if (M.type === "fieldset") { f += 1, a(M, u, f, !0), p = !0; return; } p && (f += 1, p = !1); const w = M.appearance && M.appearance.class, v = new Va(); w ? i(w, v) : v.isSupportedClass = !1, v.label = M.label || M.id, v.id = M.id, v.group = f, m && (v.fieldSetId = d.id), e === M.id && (t = f), o.set(M.id, M), u.push(v); }); } function s(d) { const u = n.getComponentById(d); if (!u || !u.componentType || !u.componentType.startsWith("form")) return { result: !1, message: "只可以在响应式表单组件中调整响应式布局配置" }; const f = n.selectNode(u, (m) => m.type === On["response-form"].type); return !f || !f.contents || f.contents.length === 0 ? { result: !1, message: "Form区域内没有控件,请先添加控件" } : { result: !0, message: "", formNode: f }; } function l(d, u) { u = u || d.id; const { result: f, message: m, formNode: p } = s(u); if (!f) return { result: f, message: m }; e = d.id, r = [], o.clear(); const M = p.contents[0].type === On.fieldset.type ? 0 : 1; a(p, r, M); const w = r.find((b) => !b.isSupportedClass); return { defaultState: { defaultGroupNumber: t || 1, model: w ? "customize" : "standard" }, importData: r }; } function c(d, u) { u = u; const { result: f, formNode: m } = s(u); if (!f) return ""; const p = []; return d.forEach((M) => { var b; const w = o.get(M.id), v = w.appearance && w.appearance.class; if (v) { const _ = v.split(" ").filter((E) => !E.startsWith("col-")), T = "col-" + M.columnInSM, k = "col-md-" + M.columnInMD, h = "col-xl-" + M.columnInLG, x = "col-el-" + M.columnInEL, C = [T, k, h, x].concat(_); w.appearance.class = C.join(" "); } if (M.fieldSetId) { const g = m.contents.find((T) => T.id === M.fieldSetId), _ = p.find((T) => T.id === M.fieldSetId); _ ? (b = _.contents) == null || b.push(w) : (p.push(g), g.contents = [w]); } else p.push(w); }), m.contents = p, m.id; } return { checkCanFindFormNode: s, checkCanOpenLayoutEditor: l, changeFormControlsByResponseLayoutConfig: c, getResonseFormLayoutConfig: a }; } var _t = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}; function Qt(n) { throw new Error('Could not dynamically require "' + n + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.'); } var Ba = { exports: {} }; (function(n, t) { (function(e) { n.exports = e(); })(function() { return (/* @__PURE__ */ function() { function e(o, r, i) { function a(c, d) { if (!r[c]) { if (!o[c]) { var u = typeof Qt == "function" && Qt; if (!d && u) return u(c, !0); if (s) return s(c, !0); var f = new Error("Cannot find module '" + c + "'"); throw f.code = "MODULE_NOT_FOUND", f; } var m = r[c] = { exports: {} }; o[c][0].call(m.exports, function(p) { var M = o[c][1][p]; return a(M || p); }, m, m.exports, e, o, r, i); } return r[c].exports; } for (var s = typeof Qt == "function" && Qt, l = 0; l < i.length; l++) a(i[l]); return a; } return e; }())({ 1: [function(e, o, r) { var i = {}, a = "(?:^|\\s)", s = "(?:\\s|$)"; function l(u) { var f = i[u]; return f ? f.lastIndex