UNPKG

@farris/ui-vue

Version:

Farris Vue, a Farris Design based Vue3 component library.

1,273 lines (1,272 loc) 314 kB
var zn = Object.defineProperty; var Gn = (t, e, n) => e in t ? zn(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n; var q = (t, e, n) => Gn(t, typeof e != "symbol" ? e + "" : e, n); import { defineComponent as He, toRefs as rn, ref as x, computed as L, watch as we, createVNode as I, Fragment as St, reactive as at, createApp as an, onUnmounted as Vt, onMounted as yt, Transition as ln, mergeProps as mt, createTextVNode as ht, onBeforeUnmount as sn, withDirectives as qn, resolveDirective as Un, onBeforeMount as Yn, Teleport as Xn, shallowRef as Kn, nextTick as Gt, render as $t, h as Qn, cloneVNode as Jn, inject as vt, provide as Zn, triggerRef as eo, isVNode as to } from "vue"; import { isPlainObject as Qt, cloneDeep as dt, isUndefined as Jt } from "lodash-es"; import { DgControl as Zt } from "../designer-canvas/index.esm.js"; import { useDateFormat as no, useNumberFormat as oo, resolveField as Ye, setFieldValue as jt, getCustomClass as Pt, withInstall as un, FormSchemaEntityField$Type as en, FormSchemaEntityFieldType$Type as io } from "../common/index.esm.js"; import { useResizeObserver as cn } from "@vueuse/core"; import { useIdentify as ro, useGroupData as ao, useFilter as lo, useHierarchy as so, useLoading as uo, useDataView as co, useSelection as fo, useSelectHierarchyItem as po, useDataViewContainerStyle as mo, useCommandColumn as ho, useColumn as vo, useSort as go, useGroupColumn as yo, useRow as bo, useEdit as Co, useVisualDataBound as wo, useVisualDataCell as _o, useVisualDataRow as So, useVisualData as xo, useCellPosition as To, useSidebar as Fo, useVirtualScroll as ko, useFitColumn as Io, useFilterHistory as Eo, useColumnFilter as Mo, useDragColumn as Oo, getColumnHeader as Bo, getSidebar as Vo, getDisableMask as Do, getHorizontalScrollbar as No, getVerticalScrollbar as Ro, getEmpty as $o } from "../data-view/index.esm.js"; import "../modal/index.esm.js"; import Po from "../transfer/index.esm.js"; import Lo from "../tabs/index.esm.js"; import jo from "../order/index.esm.js"; import "../condition/index.esm.js"; import Wo, { FCheckbox as Ho } from "../checkbox/index.esm.js"; import Ao from "../filter-bar/index.esm.js"; import tn from "../tooltip/index.esm.js"; import zo from "../pagination/index.esm.js"; import Go from "../button/index.esm.js"; import qo from "../search-box/index.esm.js"; import Uo from "../tags/index.esm.js"; import Yo, { FDynamicFormGroup as Xo, FDynamicFormInput as Ko } from "../dynamic-form/index.esm.js"; import Qo from "../binding-selector/index.esm.js"; import "../notify/index.esm.js"; import Jo from "../accordion/index.esm.js"; import Zo from "../avatar/index.esm.js"; import ei from "../button-edit/index.esm.js"; import ti from "../button-group/index.esm.js"; import ni from "../calendar/index.esm.js"; import oi from "../capsule/index.esm.js"; import ii from "../color-picker/index.esm.js"; import Wt from "../combo-list/index.esm.js"; import ri from "../content-container/index.esm.js"; import ai from "../data-grid/index.esm.js"; import li from "../date-picker/index.esm.js"; import si from "../dropdown/index.esm.js"; import "../external-container/index.esm.js"; import ui from "../events-editor/index.esm.js"; import ci from "../image-cropper/index.esm.js"; import di from "../input-group/index.esm.js"; import fi from "../layout/index.esm.js"; import pi from "../list-nav/index.esm.js"; import mi from "../list-view/index.esm.js"; import hi from "../lookup/index.esm.js"; import vi from "../nav/index.esm.js"; import gi from "../number-spinner/index.esm.js"; import yi from "../number-range/index.esm.js"; import bi from "../page-header/index.esm.js"; import Ci from "../page-footer/index.esm.js"; import wi from "../progress/index.esm.js"; import _i from "../query-solution/index.esm.js"; import Si from "../radio-group/index.esm.js"; import xi from "../rate/index.esm.js"; import Ti from "../response-toolbar/index.esm.js"; import Fi from "../response-layout/index.esm.js"; import ki from "../response-layout-editor/index.esm.js"; import Ii from "../section/index.esm.js"; import Ei from "../smoke-detector/index.esm.js"; import Mi from "../splitter/index.esm.js"; import Oi from "../step/index.esm.js"; import Bi from "../switch/index.esm.js"; import Vi from "../text/index.esm.js"; import Di from "../time-picker/index.esm.js"; import Ni from "../tree-view/index.esm.js"; import Ri from "../uploader/index.esm.js"; import $i from "../verify-detail/index.esm.js"; import Pi from "../component/index.esm.js"; import Li from "../video/index.esm.js"; import ji from "../textarea/index.esm.js"; import Wi from "../tree-grid/index.esm.js"; import Hi from "../fieldset/index.esm.js"; import Ai from "../drawer/index.esm.js"; import zi from "../combo-tree/index.esm.js"; import Gi from "../field-selector/index.esm.js"; import qi from "../mapping-editor/index.esm.js"; import Ui from "../schema-selector/index.esm.js"; import Yi from "../event-parameter/index.esm.js"; import Xi from "../filter-condition-editor/index.esm.js"; import Ki from "../sort-condition-editor/index.esm.js"; import Qi from "../menu-lookup/index.esm.js"; import { createPropsResolver as Ji } from "../dynamic-resolver/index.esm.js"; const dn = {}, fn = {}; function qt(t) { const { properties: e, title: n, ignore: o } = t, i = o && Array.isArray(o), r = Object.keys(e).reduce((a, u) => ((!i || !o.find((s) => s === u)) && (a[u] = e[u].type === "object" && e[u].properties ? qt(e[u]) : dt(e[u].default)), a), {}); if (n && (!i || !o.find((a) => a === "id"))) { const a = n.toLowerCase().replace(/-/g, "_"); r.id = `${a}_${Math.random().toString().slice(2, 6)}`; } return r; } function Zi(t) { const { properties: e, title: n, required: o } = t; if (o && Array.isArray(o)) { const i = o.reduce((r, a) => (r[a] = e[a].type === "object" && e[a].properties ? qt(e[a]) : dt(e[a].default), r), {}); if (n && o.find((r) => r === "id")) { const r = n.toLowerCase().replace(/-/g, "_"); i.id = `${r}_${Math.random().toString().slice(2, 6)}`; } return i; } return { type: n }; } function pn(t, e = {}, n) { const o = dn[t]; if (o) { let i = Zi(o); const r = fn[t]; return i = r ? r({ getSchemaByType: pn }, i, e, n) : i, i; } return null; } function er(t, e) { const n = qt(e); return Object.keys(n).reduce((o, i) => (Object.prototype.hasOwnProperty.call(t, i) && (o[i] && Qt(o[i]) && Qt(t[i] || !t[i]) ? Object.assign(o[i], t[i] || {}) : o[i] = t[i]), o), n), n; } function mn(t, e) { return Object.keys(t).filter((o) => t[o] != null).reduce((o, i) => { if (e.has(i)) { const r = e.get(i); if (typeof r == "string") o[r] = t[i]; else { const a = r(i, t[i], t); Object.assign(o, a); } } else o[i] = t[i]; return o; }, {}); } function tr(t, e, n = /* @__PURE__ */ new Map()) { const o = er(t, e); return mn(o, n); } function nr(t = {}) { function e(p, c, l, f) { if (typeof l == "number") return f[p].length === l; if (typeof l == "object") { const y = Object.keys(l)[0], g = l[y]; if (y === "not") return Number(f[p].length) !== Number(g); if (y === "moreThan") return Number(f[p].length) >= Number(g); if (y === "lessThan") return Number(f[p].length) <= Number(g); } return !1; } function n(p, c, l, f) { return f[p] && f[p].propertyValue && String(f[p].propertyValue.value) === String(l); } const o = /* @__PURE__ */ new Map([ ["length", e], ["getProperty", n] ]); Object.keys(t).reduce((p, c) => (p.set(c, t[c]), p), o); function i(p, c) { const l = p; return typeof c == "number" ? [{ target: l, operator: "length", param: null, value: Number(c) }] : typeof c == "boolean" ? [{ target: l, operator: "getProperty", param: p, value: !!c }] : typeof c == "object" ? Object.keys(c).map((f) => { if (f === "length") return { target: l, operator: "length", param: null, value: c[f] }; const y = f, g = c[f]; return { target: l, operator: "getProperty", param: y, value: g }; }) : []; } function r(p) { return Object.keys(p).reduce((l, f) => { const y = i(f, p[f]); return l.push(...y), l; }, []); } function a(p, c) { if (o.has(p.operator)) { const l = o.get(p.operator); return l && l(p.target, p.param, p.value, c) || !1; } return !1; } function u(p, c) { return r(p).reduce((y, g) => y && a(g, c), !0); } function s(p, c) { const l = Object.keys(p), f = l.includes("allOf"), y = l.includes("anyOf"), g = f || y, m = (g ? p[g ? f ? "allOf" : "anyOf" : "allOf"] : [p]).map((T) => u(T, c)); return f ? !m.includes(!1) : m.includes(!0); } return { parseValueSchema: s }; } const le = { 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: "标签页工具栏按钮" }, "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: "抽屉" } }, or = {}, ir = {}; nr(); function ft(t, e, n = /* @__PURE__ */ new Map(), o = (a, u, s, p) => u, i = {}, r = (a) => a) { return dn[e.title] = e, fn[e.title] = o, or[e.title] = i, ir[e.title] = r, (a = {}, u = !0) => { if (!u) return mn(a, n); const s = tr(a, e, n), p = Object.keys(t).reduce((c, l) => (c[l] = t[l].default, c), {}); return Object.assign(p, s); }; } function xt(t, e) { return { customClass: e.class, customStyle: e.style }; } function rr() { function t(e, n) { const { dataSource: o } = e || {}; return o === void 0 ? {} : {}; } return { resolve: t }; } function ar() { function t(e, n) { return e.selectItemById(n); } return { selectItemById: t }; } function lr() { function t(e, n) { const { columns: o } = n; return e.updateColumns(o); } return { updateColumns: t }; } const sr = /* @__PURE__ */ new Map([ ["appearance", xt] ]), ur = "https://json-schema.org/draft/2020-12/schema", cr = "https://farris-design.gitee.io/switch.schema.json", dr = "switch", fr = "A Farris Component", pr = "object", mr = { 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 } }, hr = [ "type" ], vr = [ "id", "appearance", "binding" ], gr = { $schema: ur, $id: cr, title: dr, description: fr, type: pr, properties: mr, required: hr, ignore: vr }; function yr(t, e, n) { return e; } const Ut = { /** 组件值*/ 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: () => { } } }, hn = ft(Ut, gr, sr, yr), It = /* @__PURE__ */ He({ name: "FSwitch", props: Ut, emits: ["update:modelValue", "modelValueChanged"], setup(t, e) { const { disabled: n, size: o, onLabel: i, offLabel: r, onBackground: a, offBackground: u, onColor: s, offColor: p, readonly: c } = rn(t), l = x(t.modelValue), f = L(() => ({ switch: !0, "f-cmp-switch": !0, checked: l.value, disabled: c.value || n.value, "switch-large": o.value === "large", "switch-medium": o.value === "medium", "switch-small": o.value === "small" })), y = L(() => l.value ? { outline: "none", background: a.value } : { outline: "none", backgroundColor: u.value }), g = L(() => l.value ? { background: s.value } : { backgroundColor: p.value }), B = L(() => (i == null ? void 0 : i.value) || (r == null ? void 0 : r.value)); function S() { c.value || n.value || (l.value = !l.value, e.emit("update:modelValue", l.value)); } return we(l, (m, v) => { m !== v && e.emit("modelValueChanged", m); }), we(() => t.modelValue, (m, v) => { m !== v && (l.value = m); }), () => I("span", { tabindex: "0", role: "button", class: f.value, style: y.value, onClick: S }, [B.value && I("span", { class: "switch-pane" }, [I("span", { class: "switch-label-checked" }, [i == null ? void 0 : i.value]), I("span", { class: "switch-label-unchecked" }, [r == null ? void 0 : r.value])]), I("small", { style: g.value }, [e.slots.default && e.slots.default()])]); } }); function vn(t, e, n) { var M; const o = n && n.getStyles && n.getStyles() || "", i = n && n.getDesignerClass && n.getDesignerClass() || "", r = x(); function a() { return (e == null ? void 0 : e.schema.componentType) === "frame" ? !1 : n && n.checkCanMoveComponent ? n.checkCanMoveComponent() : !0; } function u() { return !1; } function s() { return (e == null ? void 0 : e.schema.componentType) === "frame" ? !1 : n && n.checkCanDeleteComponent ? n.checkCanDeleteComponent() : !0; } function p() { return (e == null ? void 0 : e.schema.componentType) === "frame" ? !0 : n && n.hideNestedPaddingInDesginerView ? n.hideNestedPaddingInDesginerView() : !1; } function c(d) { if (!d || !d.value) return null; if (d.value.schema && d.value.schema.type === "component") return d.value; const b = x(d == null ? void 0 : d.value.parent), C = c(b); return C || null; } function l(d = e) { var w; if (n != null && n.getDraggableDesignItemElement) return n.getDraggableDesignItemElement(d); const { componentInstance: b, designerItemElementRef: C } = d; if (!b || !b.value) return null; const { getCustomButtons: F } = b.value; return b.value.canMove || F && ((w = F()) != null && w.length) ? C : l(d.parent); } function f(d) { return !!n && n.canAccepts(d); } function y() { return (e == null ? void 0 : e.schema.label) || (e == null ? void 0 : e.schema.title) || (e == null ? void 0 : e.schema.name); } function g() { } function B(d, b) { var C; !d || !b || (n != null && n.onAcceptMovedChildElement && n.onAcceptMovedChildElement(d, b), (C = e == null ? void 0 : e.setupContext) == null || C.emit("dragEnd")); } function S(d, b) { const { componentType: C } = d; let F = pn(C, d, b); n && n.onResolveNewComponentSchema && (F = n.onResolveNewComponentSchema(d, F)); const w = C.toLowerCase().replace(/-/g, "_"); return F && !F.id && F.type === C && (F.id = `${w}_${Math.random().toString().slice(2, 6)}`), F; } function m(d) { d && n != null && n.onChildElementMovedOut && n.onChildElementMovedOut(d); } function v(...d) { if (n && n.getPropsConfig) return n.getPropsConfig(...d); } function T() { n && n.onRemoveComponent && n.onRemoveComponent(), e != null && e.schema.contents && e.schema.contents.map((d) => { let b = d.id; d.type === "component-ref" && (b = d.component); const C = t.value.querySelectorAll(`#${b}-design-item`); C != null && C.length && Array.from(C).map((F) => { var w; (w = F == null ? void 0 : F.componentInstance) != null && w.value.onRemoveComponent && F.componentInstance.value.onRemoveComponent(); }); }); } function h() { if (n && n.getCustomButtons) return n.getCustomButtons(); } function _(d) { if (n && n.onPropertyChanged) return n.onPropertyChanged(d); } return r.value = { canMove: a(), canSelectParent: u(), canDelete: s(), canNested: !p(), contents: e == null ? void 0 : e.schema.contents, elementRef: t, 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: f, getBelongedComponentInstance: c, getDraggableDesignItemElement: l, getDraggingDisplayText: y, getPropConfig: v, getDragScopeElement: g, onAcceptMovedChildElement: B, onChildElementMovedOut: m, addNewChildComponentSchema: S, triggerBelongedComponentToMoveWhenMoved: !!n && n.triggerBelongedComponentToMoveWhenMoved || x(!1), triggerBelongedComponentToDeleteWhenDeleted: !!n && n.triggerBelongedComponentToDeleteWhenDeleted || x(!1), onRemoveComponent: T, getCustomButtons: h, onPropertyChanged: _ }, r; } const br = x(0); function Cr() { br.value++; } const gt = x(0); function wr(t, e) { const n = e.getBoundingClientRect(), o = t.getBoundingClientRect(), i = o.top >= n.top, r = o.top <= n.bottom; return i && r; } function _r(t) { const e = t.querySelector(".component-btn-group"); if (!e) return; e.style.display = ""; const n = e.getBoundingClientRect(); if (!(n.top === 0 && n.left === 0)) { const o = e.querySelector("div"); if (o) { const i = o.getBoundingClientRect(); o.style.top = n.top + "px"; let r = n.left - i.width; const a = document.querySelector(".editorDiv"); if (a) { const u = a.getBoundingClientRect(); r < u.left && ({ left: r } = t.getBoundingClientRect()); } o.style.left = r + "px"; } } } function Sr(t) { if (!window.scrollContainerList) return; const e = Array.from(window.scrollContainerList); if (e.length && e.length === 1) { const n = e[0], o = document.querySelector(`[id=${n}]`); if (o && o.contains(t)) return o; } } function gn(t) { if (!t) return; const e = t.getBoundingClientRect(); if (e.width === 0 && e.height === 0) return; const n = t.querySelector(".component-btn-group"); if (n) { let o = !0; const i = Sr(t); if (i && (o = wr(t, i)), !o) { n.style.display = "none"; return; } _r(t); } } function xr(t) { if (!t) return; let e; t.className.includes("dgComponentSelected") ? e = t : e = t.querySelector(".dgComponentSelected"), e && gn(e); } class yn { constructor(e, n) { 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, "schemaService", null); q(this, "metadataService", null); q(this, "propertyConfig", { type: "object", categories: {} }); var o; this.componentId = e, this.designerHostService = n, this.eventsEditorUtils = n.eventsEditorUtils, this.formSchemaUtils = n.formSchemaUtils, this.formMetadataConverter = n.formMetadataConverter, this.viewModelId = ((o = this.formSchemaUtils) == null ? void 0 : o.getViewModelIdByComponentId(e)) || "", this.designViewModelUtils = n.designViewModelUtils, this.controlCreatorUtils = n.controlCreatorUtils, this.metadataService = n.metadataService, this.schemaService = n.schemaService; } getTableInfo() { var e; return (e = this.schemaService) == null ? void 0 : e.getTableInfoByViewModelId(this.viewModelId); } setDesignViewModelField(e) { var o; const n = e.binding && e.binding.type === "Form" && e.binding.field; if (n) { if (!this.designViewModelField) { const i = this.designViewModelUtils.getDgViewModel(this.viewModelId); this.designViewModelField = i.fields.find((r) => r.id === n); } 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", editable: !1, data: [{ value: e.type, name: le[e.type].name }] } } } }; } getAppearanceConfig(e = null) { return { title: "外观", description: "Appearance", properties: { class: { title: "class样式", type: "string", description: "组件的CSS样式", $converter: "/converter/appearance.converter" }, style: { title: "style样式", type: "string", description: "组件的样式", $converter: "/converter/appearance.converter" } }, setPropertyRelates(n, o) { if (n) switch (n && n.propertyID) { case "class": case "style": { gt.value++; break; } } } }; } /** * * @param propertyId * @param componentInstance * @returns */ updateElementByParentContainer(e, n) { const o = n && n.parent && n.parent.schema; if (!o) return; const i = o.contents.findIndex((a) => a.id === e), r = dt(o.contents[i]); o.contents.splice(i, 1), o.contents.splice(i, 0, r), Cr(); } } const bt = class bt { /** * 根据绑定字段类型获取可用的输入类控件 */ static getEditorTypesByMDataType(e, n = "") { let o = bt.fieldControlTypeMapping[e]; if (n === "data-grid-column" && (o != null && o.length)) { const i = [le["check-group"].type, le["radio-group"].type]; o = o.filter((r) => !i.includes(r.key)); } return o; } /** * 获取所有输入类控件 */ static getAllInputTypes() { const e = []; for (const n in bt.fieldControlTypeMapping) bt.fieldControlTypeMapping[n].forEach((o) => { e.find((i) => i.key === o.key && i.value === o.value) || e.push({ key: o.key, value: o.value }); }); return e; } /** * 提供schema字段基础属性和DOM控件属性的映射 * @param control 控件元数据 */ static mappingDomPropAndSchemaProp(e) { var i; const n = (i = e.editor) == null ? void 0 : i.type, o = []; return (e.type === le["data-grid-column"].type || e.type === le["tree-grid-column"].type) && o.push({ domField: "title", schemaField: "name" }), o.push({ domField: "label", schemaField: "name" }), o.push({ domField: "editor.required", schemaField: "require" }), o.push({ domField: "editor.readonly", schemaField: "readonly" }), (n === le["input-group"].type || n === le.textarea.type || n === le["number-spinner"].type) && o.push({ domField: "editor.maxLength", schemaField: "type.length" }), n === le["number-spinner"].type && o.push({ domField: "editor.precision", schemaField: "type.precision" }), (e.type === le["data-grid-column"].type || e.type === le["tree-grid-column"].type) && o.push({ domField: "formatter.precision", schemaField: "type.precision" }), (n === le["combo-list"].type || n === le["radio-group"].type) && o.push({ domField: "editor.data", schemaField: "type.enumValues" }), (e.type === le["data-grid-column"].type || e.type === le["tree-grid-column"].type) && o.push({ domField: "formatter.data", schemaField: "type.enumValues" }), n === le["date-picker"].type && (o.push({ domField: "editor.displayFormat", schemaField: "editor.format" }), o.push({ domField: "editor.fieldType", schemaField: "type.name" })), n === le["number-spinner"].type && (o.push({ domField: "editor.max", schemaField: "editor.maxValue" }), o.push({ domField: "editor.min", schemaField: "editor.minValue" })), n === le.lookup.type && (o.push({ domField: "editor.dataSource", schemaField: "editor.dataSource" }), o.push({ domField: "editor.valueField", schemaField: "editor.valueField" }), o.push({ domField: "editor.textField", schemaField: "editor.textField" }), o.push({ domField: "editor.displayType", schemaField: "editor.displayType" }), o.push({ domField: "editor.mapFields", schemaField: "editor.mapFields" }), o.push({ domField: "editor.helpId", schemaField: "editor.helpId" })), o.push({ domField: "path", schemaField: "bindingPath" }), o.push({ domField: "binding.path", schemaField: "bindingField" }), o.push({ domField: "binding.fullPath", schemaField: "path" }), (e.type === le["data-grid-column"].type || e.type === le["tree-grid-column"].type) && o.push({ domField: "field", schemaField: "bindingPath" }), o; } }; /** * <字段类型,可配置的控件类型列表>的映射 */ q(bt, "fieldControlTypeMapping", { String: [ { key: le["input-group"].type, value: le["input-group"].name }, { key: le.lookup.type, value: le.lookup.name }, { key: le["date-picker"].type, value: le["date-picker"].name }, { key: le["check-group"].type, value: le["check-group"].name }, { key: le["radio-group"].type, value: le["radio-group"].name }, { key: le["combo-list"].type, value: le["combo-list"].name }, { key: le.textarea.type, value: le.textarea.name }, { key: le["time-picker"].type, value: le["time-picker"].name } ], Text: [ { key: le.textarea.type, value: le.textarea.name }, { key: le.lookup.type, value: le.lookup.name } ], Decimal: [ { key: le["number-spinner"].type, value: le["number-spinner"].name } ], Integer: [ { key: le["number-spinner"].type, value: le["number-spinner"].name } ], Number: [ { key: le["number-spinner"].type, value: le["number-spinner"].name } ], BigNumber: [ { key: le["number-spinner"].type, value: le["number-spinner"].name } ], Date: [ { key: le["date-picker"].type, value: le["date-picker"].name } ], DateTime: [ { key: le["date-picker"].type, value: le["date-picker"].name } ], Boolean: [ { key: le.switch.type, value: le.switch.name }, { key: le["check-box"].type, value: le["check-box"].name } ], Enum: [ { key: le["combo-list"].type, value: le["combo-list"].name }, { key: le["radio-group"].type, value: le["radio-group"].name } ], Object: [ { key: le.lookup.type, value: le.lookup.name }, { key: le["combo-list"].type, value: le["combo-list"].name }, { key: le["radio-group"].type, value: le["radio-group"].name } ] }); let Et = bt; class Tr { constructor() { /** 控件标题 */ q(this, "label", ""); /** 控件id */ q(this, "id", ""); /** 每个控件占用的栅格数 */ q(this, "columnInSM", 12); q(this, "columnInMD", 6); q(this, "columnInLG", 3); q(this, "columnInEL", 2); /** 每个控件占用的列数 */ q(this, "displayWidthInSM", 1); q(this, "displayWidthInMD", 1); q(this, "displayWidthInLG", 1); q(this, "displayWidthInEL", 1); /** 编辑器内部默认显示的屏幕大小-----可以去掉 */ q(this, "displayColumnCountAtBreakPoint", "md"); /** 控件所在行,传0即可-----编辑器内部使用 */ q(this, "tagRow", 0); /** 控件是否显示上方空白:传0即可-----编辑器内部使用 */ q(this, "showTopBorder", 0); /** 区域,从1开始。卡片内的控件从上往下,从左往右划分区域,遇到分组fieldSet时group+1,分组结束后group+1 */ q(this, "group", 1); /** 控件是否符合标准的class配置(设计器用的) */ q(this, "isSupportedClass", !0); /** 控件所在分组id(设计器用的) */ q(this, "fieldSetId", ""); } } function Fr(t) { let e, n; const o = /* @__PURE__ */ new Map(); let i = []; function r(c, l) { const y = c.split(" ").filter((v) => v.startsWith("col-")); if (y.length === 0) { l.isSupportedClass = !1; return; } let g = y.find((v) => /^col-([1-9]|10|11|12)$/.test(v)), B = y.find((v) => /^col-md-([1-9]|10|11|12)$/.test(v)), S = y.find((v) => /^col-xl-([1-9]|10|11|12)$/.test(v)), m = y.find((v) => /^col-el-([1-9]|10|11|12)$/.test(v)); g = g || "col-12", l.columnInSM = parseInt(g.replace("col-", ""), 10), l.displayWidthInSM = l.columnInSM / 12, l.displayWidthInSM !== 1 && (l.isSupportedClass = !1), B = B || "col-md-" + l.columnInSM, l.columnInMD = parseInt(B.replace("col-md-", ""), 10), l.displayWidthInMD = l.columnInMD / 6, [1, 2].includes(l.displayWidthInMD) || (l.isSupportedClass = !1), S = S || "col-xl-" + l.columnInMD, l.columnInLG = parseInt(S.replace("col-xl-", ""), 10), l.displayWidthInLG = l.columnInLG / 3, [1, 2, 3, 4].includes(l.displayWidthInLG) || (l.isSupportedClass = !1), m = m || "col-el-" + l.columnInLG, l.columnInEL = parseInt(m.replace("col-el-", ""), 10), l.displayWidthInEL = l.columnInEL / 2, [1, 2, 3, 4, 5, 6].includes(l.displayWidthInEL) || (l.isSupportedClass = !1); } function a(c, l, f, y = !1) { let g = !1; c.contents.forEach((B) => { if (B.type === "fieldset") { f += 1, a(B, l, f, !0), g = !0; return; } g && (f += 1, g = !1); const S = B.appearance && B.appearance.class, m = new Tr(); S ? r(S, m) : m.isSupportedClass = !1, m.label = B.label || B.id, m.id = B.id, m.group = f, y && (m.fieldSetId = c.id), n === B.id && (e = f), o.set(B.id, B), l.push(m); }); } function u(c) { const l = t.getComponentById(c); if (!l || !l.componentType || !l.componentType.startsWith("form")) return { result: !1, message: "只可以在响应式表单组件中调整响应式布局配置" }; const f = t.selectNode(l, (y) => y.type === Zt["response-form"].type); return !f || !f.contents || f.contents.length === 0 ? { result: !1, message: "Form区域内没有控件,请先添加控件" } : { result: !0, message: "", formNode: f }; } function s(c, l) { l = l || c.id; const { result: f, message: y, formNode: g } = u(l); if (!f) return { result: f, message: y }; n = c.id, i = [], o.clear(); const B = g.contents[0].type === Zt.fieldset.type ? 0 : 1; a(g, i, B); const S = i.find((v) => !v.isSupportedClass); return { defaultState: { defaultGroupNumber: e || 1, model: S ? "customize" : "standard" }, importData: i }; } function p(c, l) { l = l; const { result: f, formNode: y } = u(l); if (!f) return ""; const g = []; return c.forEach((B) => { var v; const S = o.get(B.id), m = S.appearance && S.appearance.class; if (m) { const h = m.split(" ").filter((F) => !F.startsWith("col-")), _ = "col-" + B.columnInSM, M = "col-md-" + B.columnInMD, d = "col-xl-" + B.columnInLG, b = "col-el-" + B.columnInEL, C = [_, M, d, b].concat(h); S.appearance.class = C.join(" "); } if (B.fieldSetId) { const T = y.contents.find((_) => _.id === B.fieldSetId), h = g.find((_) => _.id === B.fieldSetId); h ? (v = h.contents) == null || v.push(S) : (g.push(T), T.contents = [S]); } else g.push(S); }), y.contents = g, y.id; } return { checkCanFindFormNode: u, checkCanOpenLayoutEditor: s, changeFormControlsByResponseLayoutConfig: p, getResonseFormLayoutConfig: a }; } var ut = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}; function Tt(t) { throw new Error('Could not dynamically require "' + t + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.'); } var kr = { exports: {} }; (function(t, e) { (function(n) { t.exports = n(); })(function() { return (/* @__PURE__ */ function() { function n(o, i, r) { function a(p, c) { if (!i[p]) { if (!o[p]) { var l = typeof Tt == "function" && Tt; if (!c && l) return l(p, !0); if (u) return u(p, !0); var f = new Error("Cannot find module '" + p + "'"); throw f.code = "MODULE_NOT_FOUND", f; } var y = i[p] = { exports: {} }; o[p][0].call(y.exports, function(g) { var B = o[p][1][g]; return a(B || g); }, y, y.exports, n, o, i, r); } return i[p].exports; } for (var u = typeof Tt == "function" && Tt, s = 0; s < r.length; s++) a(r[s]); return a; } return n; }())({ 1: [function(n, o, i) { var r = {}, a = "(?:^|\\s)", u = "(?:\\s|$)"; function s(l) { var f = r[l]; return f ? f.lastIndex = 0 : r[l] = f = new RegExp(a + l + u, "g"), f; } function p(l, f) { var y = l.className; y.length ? s(f).test(y) || (l.className += " " + f) : l.className = f; } function c(l, f) { l.className = l.className.replace(s(f), " ").trim(); } o.exports = { add: p, rm: c }; }, {}], 2: [function(n, o, i) { (function(r) { var a = n("contra/emitter"), u = n("crossvent"), s = n("./classes"), p = document, c = p.documentElement; function l(w, N) { var V = arguments.length; V === 1 && Array.isArray(w) === !1 && (N = w, w = []); var D, k, O, E, R, H, K, oe, te, pe = null, W, j, A = !1, Y = 0, J, X = N || {}; X.moves === void 0 && (X.moves = v), X.accepts === void 0 && (X.accepts = v), X.invalid === void 0 && (X.invalid = it), X.containers === void 0 && (X.containers = w || []), X.isContainer === void 0 && (X.isContainer = m), X.copy === void 0 && (X.copy = !1), X.copySortSource === void 0 && (X.copySortSource = !1), X.revertOnSpill === void 0 && (X.revertOnSpill = !1), X.removeOnSpill === void 0 && (X.removeOnSpill = !1), X.direction === void 0 && (X.direction = "vertical"), X.ignoreInputTextSelection === void 0 && (X.ignoreInputTextSelection = !0), X.mirrorContainer === void 0 && (X.mirrorContainer = p.body); var $ = a({ containers: X.containers, start: Ge, end: ne, cancel: rt, remove: ke, destroy: xe, canMove: Me, dragging: !1 }); return X.removeOnSpill === !0 && $.on("over", me).on("out", ve), re(), $; function G(P) { return $.containers.indexOf(P) !== -1 || X.isContainer(P); } function re(P) { var Q = P ? "remove" : "add"; g(c, Q, "mousedown", Te), g(c, Q, "mouseup", Ie); } function Z(P) { var Q = P ? "remove" : "add"; g(c, Q, "mousemove", je); } function ee(P) { var Q = P ? "remove" : "add"; u[Q](c, "selectstart", Fe), u[Q](c, "click", Fe); } function xe() { re(!0), Ie({}); } function Fe(P) { W && P.preventDefault(); } function Te(P) { E = P.clientX, R = P.clientY; var Q = B(P) !== 1 || P.metaKey || P.ctrlKey; if (!Q) { var U = P.target, ce = Ne(U); ce && (W = ce, Z(), P.type === "mousedown" && (M(U) ? U.focus() : P.preventDefault())); } } function je(P) { if (W) { if (B(P) === 0) { Ie({}); return; } if (!(P.clientX !== void 0 && Math.abs(P.clientX - E) <= (X.slideFactorX || 0) && P.clientY !== void 0 && Math.abs(P.clientY - R) <= (X.slideFactorY || 0))) { if (X.ignoreInputTextSelection) { var Q = F("clientX", P) || 0, U = F("clientY", P) || 0, ce = p.elementFromPoint(Q, U); if (M(ce)) return; } var ge = W; Z(!0), ee(), ne(), Ae(ge), s.add(oe || O, "gu-transit"), Ee(), Se(), Y = 0, qe(P); } } } function Ne(P) { if (!($.dragging && D) && !G(P)) { for (var Q = P; _(P) && G(_(P)) === !1; ) if (X.invalid(P, Q) || (P = _(P), !P)) return; var U = _(P); if (U && !X.invalid(P, Q)) { var ce = X.moves(P, U, Q, b(P)); if (ce) return { item: P, source: U }; } } } function Me(P) { return !!Ne(P); } function Ge(P) { var Q = Ne(P); Q && Ae(Q); } function Ae(P) { $e(P.item, P.source) && (oe = P.item.cloneNode(!0), $.emit("cloned", oe, P.item, "copy")), k = P.source, O = P.item, H = K = b(P.item), $.dragging = !0, $.emit("drag", O, k); } function it() { return !1; } function ne() { if ($.dragging) { var P = oe || O; Ve(P, _(P)); } } function be() { W = !1, Z(!0), ee(!0); } function Ie(P) { if (be(), !!$.dragging) { var Q = oe || O, U = F("clientX", P) || 0, ce = F("clientY", P) || 0, ge = S(D, U, ce), ye = lt(ge, U, ce); ye && (oe && X.copySortSource || !oe || ye !== k) ? Ve(Q, ye) : X.removeOnSpill ? ke() : rt(); } } function Ve(P, Q) { var U = _(P); oe && X.copySortSource && Q === k && U.removeChild(O), et(Q) ? $.emit("cancel", P, k) : $.emit("drop", P, Q, k, K), Ze(); } function ke() { if ($.dragging) { var P = oe || O, Q = _(P); Q && Q.removeChild(P), $.emit(oe ? "cancel" : "remove", P, Q, k), Ze(); } } function rt(P) { if ($.dragging) { var Q = arguments.length > 0 ? P : X.revertOnSpill, U = oe || O, ce = _(U), ge = et(ce); ge === !1 && Q && (oe ? ce && ce.removeChild(oe) : k.insertBefore(U, H)), ge || Q ? $.emit("cancel", U, k, k) : $.emit("drop", U, ce, k, K), Ze(); } } function Ze() { var P = oe || O; be(), Re(), ze(), P && s.rm(P, "gu-transit"), te && clearTimeout(te), $.dragging = !1, pe && $.emit("out", P, pe, k), $.emit("dragend", P, Y), k = O = oe = H = K = te = pe = null; } function et(P, Q) { var U; return Q !== void 0 ? U = Q : D ? U = K : U = b(oe || O), P === k && U === H; } function lt(P, Q, U) { for (var ce = P; ce && !ge(); ) ce = _(ce); return ce; function ge() { var ye = G(ce); if (ye === !1) return !1; var ae = tt(ce, P), _e = Be(ce, ae, Q, U), De = et(ce, _e); return De ? !0 : X.accepts(O, ce, k, _e); } } function qe(P) { if (!D) return; P.preventDefault(); var Q = F("clientX", P) || 0, U = F("clientY", P) || 0; D.style.left = Q - 2 + "px", D.style.top = U - 2 + "px"; var ce = oe || O, ge = S(D, Q, U), ye = lt(ge, Q, U), ae = ye !== null && ye !== pe; (ae || ye === null) && (Ke(), pe = ye, st()), Ce(ge, U); var _e = _(ce); if (ye === k && oe && !X.copySortSource) { _e && _e.removeChild(ce); return; } var De, Xe = tt(ye, ge); if (A = nt(Xe, ye), Xe !== null) De = Be(ye, Xe, Q, U); else if (X.revertOnSpill === !0 && !oe) De = H, ye = k; else { oe && _e && _e.removeChild(ce), oe && j && (j.style.display = "none"); return; } j.style.display = "block", ie(De, ce, ae), De ? z(Xe, De) : he(ye); function Pe(We) { $.emit(We, ce, pe, k); } function st() { ae && Pe("over"); } function Ke() { pe && Pe("out"); } } function ie(P, Q, U) { (P === Q || P === b(Q)) && (K = b(Q)), (P === null && U || P !== Q && P !== b(Q)) && (K = P); } function me(P) { s.rm(P, "gu-hide"); } function ve(P) { $.dragging && s.add(P, "gu-hide"); } function Se() { D || (D = document.createElement("div"), D.style = "background: grey; color: white; height: 24px; text-align: center; padding: 3px 10px; min-width: 100px;border-radius: 4px; box-shadow: 0 0 6px grey;", D.innerHTML = X.getMirrorText && X.getMirrorText(O) || "控件", s.add(D, "gu-mirror"), X.mirrorContainer.appendChild(D), g(c, "add", "mousemove", qe), s.add(X.mirrorContainer, "gu-unselectable"), $.emit("cloned", D, O, "mirror")); } function Ee() { if (j = document.createElement("div"), s.add(j, "gu-insertion"), O) { var P = O.getBoundingClientRect(); j.style.left = P.left + "px", j.style.top = P.top + "px"; } A = !1, X.mirrorContainer.appendChild(j); } function Re() { D && (s.rm(X.mirrorContainer, "gu-unselectable"), g(c, "remove", "mousemove", qe), _(D).removeChild(D), D = null); } function ze() { j && (_(j).removeChild(j), j = null); } function tt(P, Q) { for (var U = Q; U !== P && _(U) !== P; ) U = _(U); return U === c ? null : U; } function nt(P, Q) { if (!Q) return A; var U = P || Q && Q.lastElementChild; if (!U) return !0; var ce = getComputedStyle(P), ge = /^inline/.test(ce.getPropertyValue("display")) || /^(left|right)$/.test(ce.getPropertyValue("float")); if (ge) return !0; if (Q) { var ye = getComputedStyle(Q), ae = ye.getPropertyValue("display"); if (/flex$/.test(ae)) { var _e = ye.getPropertyValue("flex-direction") || "row"; if (_e === "row" || _e === "row-reverse") return !Ue(Q); } return !1; } return !0; } function Ue(P) { if (!P.children || !P.children.length) return !1; for (const Q of Array.from(P.children)) { const ce = (Q.className && Q.className.split(" ") || []).filter((ge) => /^col(-md|-xl|-el){0,1}-([1-9]|10|11|12)$/.test(ge)); if (!ce.length) return !1; for (const ge of ce) { const ye = ge.slice(ge.lastIndexOf("-") + 1); if (parseInt(ye, 10) !== 12) return !1; } } return !0; } function z(P, Q) { const U = Q.getBoundingClientRect(); if (j.style.left = U.left + "px", j.style.top = U.top + "px", A) { if (j.style.height = U.height + "px", j.style.width = "4px", P) { const ce = P.getBoundingClientRect(); ce.top !== U.top && (j.style.left = ce.right + "px", j.style.top = ce.top + "px", j.style.height = ce.height + "px"); } } else if (j.style.height = "4px", j.style.width = U.width + "px", J) { const ce = J.getBoundingClientRect(); U.top < ce.top && (j.style.display = "none"); } Q === O && O && (j.style.display = "none"); } function he(P) { K = null; var Q = P.lastElementChild; if (Q) { var U = Q.getBoundingClientRect(); A ? (j.style.left = U.right + "px", j.style.top = U.top + "px", j.style.height = U.height + "px", j.style.width = "4px") : (j.style.left = U.left + "px", j.style.top = U.bottom + "px", j.style.height = "4px", j.style.width = U.width + "px"), Q === O && O && (j.style.display = "none"); } else j.style.display = "none"; } function Ce(P, Q) { if (!X.mirrorContainer.contains(P) || !window.scrollContainerList || !Array.from(window.scrollContainerList).length || (J = f(P), !J || !J.contains(P))) return; const U = document.querySelector(".dgComponentSelected"), ce = J.getBoundingClientRect(); if (Q - 30 < ce.top && J.scrollTop > 0) { let ge = J.scrollTop < 10 ? J.scrollTop : 10; J.scrollBy(0, -1 * ge), U && J.contains(U) && (Y = Y + -1 * ge); } if (Q + 30 > ce.bottom && J.scrollTop < J.scrollHeight - J.clientHeight) { const ge = J.scrollHeight - J.clientHeight - J.scrollTop; let ye = ge < 10 ? ge : 10; J.scrollBy(0, ye), U && J.contains(U) && (Y = Y + ye); } } function Be(P, Q, U, ce) { var ge = X.direction === "horizontal", ye = X.direction === "mixed", ae = Q !== P ? De() : _e(); return ae; function _e() { var Pe = P.children.length, st, Ke, We; for (st = 0; st < Pe; st++) if (Ke = P.children[st], We = Ke.getBoundingClientRect(), ge && We.left + We.width / 2 > U || !ye && !ge && We.top + We.height / 2 > ce || ye && We.left + We.width > U && We.top + We.height > ce) return Ke; return null; } function De() { var Pe = Q.getBoundingClientRect(); if (ye) { var st = ce - Pe.top, Ke = U - Pe.left, We = Pe.bottom - ce, Dt = Pe.right - U, Nt = Math.min(Ke, Dt, st, We), Rt; return A ? Rt = Dt < Ke : Rt = We === Nt || Dt === Nt || Ke === Nt, Xe(Rt); } return Xe(ge ? U > Pe.left + T(Pe) / 2 : ce > Pe.top + h(Pe) / 2); } function Xe(Pe) { return Pe ? b(Q) : Q; } } function $e(P, Q) { return typeof X.copy == "boolean" ? X.copy : X.copy(P, Q); } } function f(w) { const N = Array.from(window.scrollContainerList); if (N.length === 1) { const D = Array.from(window.scrollContainerList)[0]; return document.getElementById(D); } const V = y(N);