UNPKG

@farris/ui-vue

Version:

Farris Vue, a Farris Design based Vue3 component library.

1,559 lines 411 kB
var Uo = Object.defineProperty; var Xo = (n, t, e) => t in n ? Uo(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e; var P = (n, t, e) => Xo(n, typeof t != "symbol" ? t + "" : t, e); import { computed as $, ref as T, createVNode as M, onMounted as wt, nextTick as At, defineComponent as tt, watch as Te, Fragment as Kt, reactive as bt, createApp as Gn, onUnmounted as cn, Transition as zn, mergeProps as Rt, createTextVNode as Lt, onBeforeUnmount as Yn, withDirectives as Qo, resolveDirective as Ko, onBeforeMount as Zo, Teleport as Jo, shallowRef as er, render as fn, h as tr, cloneVNode as nr, inject as Ft, provide as or, triggerRef as rr, isVNode as ir } from "vue"; import { isPlainObject as Pn, cloneDeep as kt, isUndefined as ct, throttle as ar } from "lodash-es"; import rt from "bignumber.js"; import { useGuid as sr, resolveField as it, FormSchemaEntityFieldTypeName as gn, useCommonUtils as lr, useDateFormat as ur, useNumberFormat as cr, setFieldValue as vn, getCustomClass as mn, withInstall as Un, FormSchemaEntityField$Type as Nn, FormSchemaEntityFieldType$Type as dr } from "../common/index.esm.js"; import { DgControl as Vn } from "../designer-canvas/index.esm.js"; import { useResizeObserver as Xn } from "@vueuse/core"; import { useIdentify as fr, useGroupData as mr, useFilter as pr, useHierarchy as hr, useLoading as gr, useDataView as vr, useSelection as yr, useSelectHierarchyItem as br, useDataViewContainerStyle as wr, useCommandColumn as Cr, useColumn as xr, useSort as _r, useGroupColumn as Sr, useRow as Tr, useEdit as Er, useVisualDataBound as Fr, useVisualDataCell as kr, useVisualDataRow as Mr, useVisualData as Or, useCellPosition as Ir, useSidebar as Pr, useVirtualScroll as Nr, useFitColumn as Vr, useFilterHistory as Br, useColumnFilter as Dr, useDragColumn as Rr, getColumnHeader as Lr, getSidebar as Wr, getDisableMask as $r, getHorizontalScrollbar as Hr, getVerticalScrollbar as jr, getEmpty as Ar } from "../data-view/index.esm.js"; import "../modal/index.esm.js"; import qr from "../transfer/index.esm.js"; import Gr from "../tabs/index.esm.js"; import zr from "../order/index.esm.js"; import "../condition/index.esm.js"; import { FCheckbox as Yr } from "../checkbox/index.esm.js"; import Ur from "../filter-bar/index.esm.js"; import Bn from "../tooltip/index.esm.js"; import Xr from "../pagination/index.esm.js"; import Qr from "../button/index.esm.js"; import Kr from "../search-box/index.esm.js"; import Zr from "../tags/index.esm.js"; import Jr, { FDynamicFormGroup as ei, FDynamicFormInput as ti } from "../dynamic-form/index.esm.js"; import { createPropsResolver as ni } from "../dynamic-resolver/index.esm.js"; import "../property-panel/index.esm.js"; import oi from "../accordion/index.esm.js"; import ri from "../avatar/index.esm.js"; import ii from "../../designer/button-edit/index.esm.js"; import ai from "../button-group/index.esm.js"; import si from "../calendar/index.esm.js"; import li from "../capsule/index.esm.js"; import Dn from "../../designer/checkbox/index.esm.js"; import Rn from "../../designer/checkbox-group/index.esm.js"; import yn from "../combo-list/index.esm.js"; import ui from "../combo-tree/index.esm.js"; import ci from "../component/index.esm.js"; import di from "../color-picker/index.esm.js"; import fi from "../content-container/index.esm.js"; import mi from "../date-picker/index.esm.js"; import pi from "../../designer/data-grid/index.esm.js"; import hi from "../dropdown/index.esm.js"; import gi from "../events-editor/index.esm.js"; import vi from "../field-selector/index.esm.js"; import yi from "../binding-selector/index.esm.js"; import bi from "../image-cropper/index.esm.js"; import wi from "../../designer/input-group/index.esm.js"; import Ci from "../layout/index.esm.js"; import xi from "../list-nav/index.esm.js"; import _i from "../list-view/index.esm.js"; import Si from "../lookup/index.esm.js"; import Ti from "../mapping-editor/index.esm.js"; import Ei from "../nav/index.esm.js"; import Fi from "../number-range/index.esm.js"; import ki from "../number-spinner/index.esm.js"; import Mi from "../page-header/index.esm.js"; import Oi from "../page-footer/index.esm.js"; import Ii from "../progress/index.esm.js"; import Pi from "../query-solution/index.esm.js"; import Ni from "../../designer/radio-group/index.esm.js"; import Vi from "../rate/index.esm.js"; import Bi from "../response-toolbar/index.esm.js"; import Di from "../response-layout/index.esm.js"; import Ri from "../response-layout-editor/index.esm.js"; import Li from "../section/index.esm.js"; import Wi from "../smoke-detector/index.esm.js"; import $i from "../splitter/index.esm.js"; import Hi from "../step/index.esm.js"; import ji from "../switch/index.esm.js"; import Ai from "../text/index.esm.js"; import qi from "../time-picker/index.esm.js"; import Gi from "../tree-view/index.esm.js"; import zi from "../uploader/index.esm.js"; import Yi from "../verify-detail/index.esm.js"; import Ui from "../video/index.esm.js"; import Xi from "../textarea/index.esm.js"; import Qi from "../schema-selector/index.esm.js"; import Ki from "../tree-grid/index.esm.js"; import Zi from "../event-parameter/index.esm.js"; import Ji from "../filter-condition-editor/index.esm.js"; import ea from "../fieldset/index.esm.js"; import ta from "../sort-condition-editor/index.esm.js"; import na from "../menu-lookup/index.esm.js"; import oa from "../drawer/index.esm.js"; import ra from "../json-editor/index.esm.js"; import ia from "../property-editor/index.esm.js"; import aa from "../expression-editor/index.esm.js"; import sa from "../code-editor/index.esm.js"; import la from "../html-template/index.esm.js"; import "../external-container/index.esm.js"; import "../notify/index.esm.js"; const Qn = {}, Kn = {}; function _n(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 ? _n(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 ua(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 ? _n(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 Zn(n, t = {}, e) { const o = Qn[n]; if (o) { let r = ua(o); const i = Kn[n]; return r = i ? i({ getSchemaByType: Zn }, r, t, e) : r, r; } return null; } function ca(n, t) { const e = _n(t); return Object.keys(e).reduce((o, r) => (Object.prototype.hasOwnProperty.call(n, r) && (o[r] && Pn(o[r]) && Pn(n[r] || !n[r]) ? Object.assign(o[r], n[r] || {}) : o[r] = n[r]), o), e), e; } function Jn(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 da(n, t, e = /* @__PURE__ */ new Map()) { const o = ca(n, t); return Jn(o, e); } function fa(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, g = (p ? c[p ? f ? "allOf" : "anyOf" : "allOf"] : [c]).map((v) => s(v, d)); return f ? !g.includes(!1) : g.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: "筛选条" } }, ma = {}, pa = {}; fa(); function $t(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, ma[t.title] = r, pa[t.title] = i, (a = {}, s = !0) => { if (!s) return Jn(a, e); const l = da(a, t, e), c = Object.keys(n).reduce((d, u) => (d[u] = n[u].default, d), {}); return Object.assign(c, l); }; } function dn(n, t) { return { customClass: t.class, customStyle: t.style }; } function ha() { function n(t, e) { const { dataSource: o } = t || {}; return o === void 0 ? {} : {}; } return { resolve: n }; } function ga() { function n(t, e) { return t.selectItemById(e); } return { selectItemById: n }; } function va() { function n(t, e) { const { columns: o } = e; return t.updateColumns(o); } return { updateColumns: n }; } const ya = /* @__PURE__ */ new Map([ ["appearance", dn] ]), ba = "https://json-schema.org/draft/2020-12/schema", wa = "https://farris-design.gitee.io/number-spinner.schema.json", Ca = "number-spinner", xa = "A Farris Input Component", _a = "object", Sa = { id: { description: "The unique identifier for a number spinner", type: "string" }, type: { description: "The type string of number spinner component", type: "string", default: "number-spinner" }, appearance: { description: "", type: "object", properties: { class: { type: "string" }, style: { type: "string" } }, default: {} }, binding: { description: "", type: "object", default: {} }, editable: { description: "", type: "boolean", default: !0 }, placeholder: { description: "", type: "string", default: "请输入数字" }, readonly: { description: "", type: "boolean", default: !1 }, disabled: { description: "", type: "boolean", default: !1 }, required: { description: "", type: "boolean", default: !1 }, precision: { description: "", type: "number", default: 0 }, min: { description: "", type: "number" }, step: { description: "", type: "number", default: 1 }, tabindex: { description: "", type: "number", default: -1 }, textAlign: { description: "", type: "string", enum: [ "left", "middle", "right" ], default: "left" }, nullable: { description: "", type: "boolean", default: !1 }, max: { description: "", type: "number" }, onBlur: { description: "", type: "string", default: "" }, onClickLinkLabel: { description: "", type: "sting", default: "" }, showZero: { description: "", type: "boolean", default: !0 }, useThousands: { description: "", type: "boolean", default: !0 }, keyboard: { description: "", type: "boolean", default: !0 }, bigNumber: { description: "", type: "boolean", default: !1 } }, Ta = [ "type" ], Ea = [ "id", "appearance", "binding", "visible" ], Fa = { $schema: ba, $id: wa, title: Ca, description: xa, type: _a, properties: Sa, required: Ta, ignore: Ea }; function ka(n, t, e) { return t; } const Sn = { /** * 组件标识 */ id: String, /** * 是否禁用 */ disabled: { type: Boolean, default: !1 }, /** * 是否只读 */ readonly: { type: Boolean, default: !1 }, /** * 是否可编辑 */ editable: { type: Boolean, default: !0 }, /** * 格式化 formatter 和 parser 必须同时存在 * formatter: (val: number) => string; * parser: (val: string | number) => number; */ formatter: { type: Function }, parser: { type: Function }, /** * 空白提示文本 */ placeholder: { type: String, default: "请输入数字" }, /** * up or down 步长 */ step: { type: Number, default: 1 }, /** * 最大值 */ max: { type: [Number, String] }, /** * 最小值 */ min: { type: [Number, String] }, /** * 是否显示加减按钮 */ showButton: { type: Boolean, default: !0 }, /** * 是否使用千分值 */ useThousands: { type: Boolean, default: !0 }, /** * 文本方向 */ textAlign: { type: String, default: "left" }, /** * 自动补全小数---未实现 */ autoDecimal: { type: Boolean, default: !0 }, /** * 允许为空 */ nullable: { type: Boolean, default: !1 }, /** * 精度 */ precision: { type: Number, default: 0 }, /** * 前缀 */ prefix: { type: String, default: "" }, /** * 后缀 */ suffix: { type: String, default: "" }, /** * 小数点符号 */ decimalSeparator: { type: String, default: "." }, /** * 千分位符号 */ groupSeparator: { type: String, default: "," }, /** * 使用千分位时,每组显示的字符数 */ groupSize: { type: Number, default: 3 }, /** * 值 */ value: { type: [Number, String], default: "" }, /** * 显示0值 */ showZero: { type: Boolean, default: !0 }, /** * 组件值 */ modelValue: { type: [Number, String], default: "" }, /** * 作为内嵌编辑器被创建后默认获得焦点 */ focusOnCreated: { type: Boolean, default: !1 }, /** * 作为内嵌编辑器被创建后默认选中文本 */ selectOnCreated: { type: Boolean, default: !1 }, /** * 是否启用快捷键 */ keyboard: { type: Boolean, default: !0 }, /** * 是否启用大数 */ bigNumber: { type: Boolean, default: !1 } }, Ma = Object.assign({}, Sn, { readonly: {} }), eo = $t(Sn, Fa, ya, ka); function Oa(n, t, e, o) { const { format: r } = e, { displayValue: i, getRealValue: a, modelValue: s, onNumberValueChanged: l } = o; function c() { const b = new rt(s.value || 0); return !((n.max || n.max === 0) && !new rt(n.max).isNaN() && b.gte(new rt(n.max)) && (s.value || s.value === 0)); } function d() { const b = new rt(s.value || 0); return !((n.min || n.min === 0) && !new rt(n.min).isNaN() && b.lte(new rt(n.min)) && (s.value || s.value === 0)); } function u(b) { if (n.readonly || n.disabled) return; const g = b === "up" ? c : d, w = b === "up" ? "plus" : "minus"; if (g()) { const C = new rt(s.value || 0)[w](Number(n.step)), _ = C.toFixed(); i.value = r(_), l(a(C)); } } function f() { u("up"); } function m() { u("down"); } function p(b) { f(), b.stopPropagation(); } function E(b) { m(), b.stopPropagation(); } return { canDownward: d, canUpward: c, downward: m, onClickDownButton: E, onClickUpButton: p, upward: f }; } function to(n, t, e) { const o = $(() => ({ prefix: n.prefix, suffix: n.suffix, decimalSeparator: n.decimalSeparator, groupSeparator: n.useThousands ? n.groupSeparator : "", groupSize: n.groupSize })), { getValidNumberObject: r, precision: i } = e; function a(c) { return c = c == null || c === "" ? "" : String(c), c = c.replace(new RegExp(n.prefix, "g"), "").replace(new RegExp(n.suffix, "g"), "").replace(/,/g, ""), n.groupSeparator && n.groupSeparator !== "," && (c = c.replace(new RegExp(`\\${n.groupSeparator}`, "g"), "")), n.decimalSeparator && n.decimalSeparator !== "." && (c = c.replace(new RegExp(`\\${n.decimalSeparator}`, "g"), ".")), c; } function s(c, d) { return n.precision !== null && n.precision !== void 0 ? c.toFormat(i.value, d) : c.toFormat(d); } function l(c, d = !0) { const u = a(c), f = new rt(u, 10); let m = f; return d && (m = r(f)), m.valueOf() === "0" && !n.showZero || m.isNaN() ? "" : n.formatter ? n.formatter(m.toNumber()) : s(m, o.value); } return { cleanFormat: a, format: l }; } function no(n, t) { const e = T(""), o = T(n.modelValue), r = $(() => Number(n.precision) || 0); function i(d) { return d.toFixed(r.value); } function a(d) { return isNaN(d) || d === null || d === void 0 || d === ""; } function s(d) { const u = a(n.max) ? null : new rt(String(n.max), 10), f = a(n.min) ? null : new rt(String(n.min), 10); return u && d.gt(u) ? u : f && d.lt(f) ? f : d; } function l(d, u = !0) { if (n.parser) return isNaN(Number(d)) ? n.parser(d) : d; let f = new rt(d, 10); if (u && (f = s(f)), f.isNaN()) { if (n.nullable) return null; const p = new rt("" + n.min, 10), E = new rt("" + n.max, 10); if (!p.isNaN()) f = p; else if (!E.isNaN()) f = E; else return 0; } return i(f); } function c(d) { let u = n.bigNumber ? d : Number(d); n.nullable && d === null && (u = null), u !== n.modelValue && (t.emit("update:modelValue", u), t.emit("valueChange", u), t.emit("change", u)); } return { displayValue: e, getRealValue: l, modelValue: o, isEmpty: a, onNumberValueChanged: c, precision: r, getValidNumberObject: s }; } function Ia(n, t, e, o, r) { const { cleanFormat: i, format: a } = e, { displayValue: s, getRealValue: l, modelValue: c, isEmpty: d, onNumberValueChanged: u } = o, { downward: f, upward: m } = r, p = T(!1), E = $(() => s.value); function b(C) { var h; if (C.stopPropagation(), p.value = !1, n.readonly || n.disabled) return; let _ = (h = C.target) == null ? void 0 : h.value; n.nullable || (_ = _ || 0); const F = i(_); s.value = a(l(F)), u(l(F)), t.emit("blur", { event: C, formatted: s.value, value: c.value }); } function g(C) { C.stopPropagation(), p.value = !0, !(n.readonly || n.disabled) && (s.value = d(c.value) || !n.showZero && c.value === "0" ? "" : String(c.value), t.emit("focus", { event: C, formatted: s.value, value: c.value })); } function w(C) { var h; C.stopPropagation(); let _ = (h = C.target) == null ? void 0 : h.value; n.nullable || (_ = _ || 0); const F = i(_); s.value = F, u(l(F)); } function v(C) { n.keyboard && C.key === "ArrowDown" && (C.preventDefault(), f()), n.keyboard && C.key === "ArrowUp" && (C.preventDefault(), m()), C.stopPropagation(); } return { textBoxValue: E, onBlurTextBox: b, onFocusTextBox: g, onInput: w, onKeyDown: v, isFocus: p }; } function Pa(n, t, e) { const { canDownward: o, canUpward: r, onClickDownButton: i, onClickUpButton: a } = e, s = $(() => ({ "input-group-append": !0, "btn-group": !0, "btn-group-number": !0 })), l = $(() => ({ btn: !0, "btn-secondary": !0, "btn-number-flag": !0 })), c = $(() => ({ cursor: r() ? "pointer" : "not-allowed", "margin-left": 0 })), d = $(() => ({ cursor: o() ? "pointer" : "not-allowed", "margin-left": 0 })); return () => M("div", { class: s.value }, [M("button", { class: l.value, style: c.value, onClick: a, disabled: !r() }, [M("span", { class: "f-icon f-icon-arrow-chevron-up number-arrow-chevron", style: "cursor: inherit" }, null)]), M("button", { class: l.value, style: d.value, onClick: i, disabled: !o() }, [M("span", { class: "f-icon f-icon-arrow-chevron-down number-arrow-chevron", style: "cursor: inherit" }, null)])]); } function Na(n, t, e) { const o = T(), { onBlurTextBox: r, onFocusTextBox: i, onInput: a, onKeyDown: s, textBoxValue: l } = e, c = $(() => n.disabled || n.readonly || !n.editable ? "" : n.placeholder), d = $(() => ({ "form-control": !0, "f-utils-fill": !0 })), u = $(() => ({ "text-align": n.textAlign })); function f(E) { E.stopPropagation(); } function m() { var E, b; n.selectOnCreated && ((E = o.value) == null || E.select()), n.focusOnCreated && ((b = o.value) == null || b.focus({ preventScroll: !0 })); } async function p(E) { i(E), await At, m(); } return wt(async () => { await At, m(); }), () => M("input", { ref: o, class: d.value, style: u.value, type: "text", value: l.value, disabled: n.disabled, readonly: n.readonly || !n.editable, placeholder: c.value, onBlur: r, onChange: f, onFocus: p, onInput: a, onKeydown: s }, null); } const nn = /* @__PURE__ */ tt({ name: "FNumberSpinner", props: Sn, emits: ["update:modelValue", "valueChange", "change", "blur", "focus", "click", "input"], setup(n, t) { const e = no(n, t), o = to(n, t, e), r = Oa(n, t, o, e), i = Ia(n, t, o, e, r), a = Pa(n, t, r), { displayValue: s, modelValue: l, getRealValue: c } = e, d = Na(n, t, i), { format: u } = o, { isFocus: f } = i, m = $(() => !n.disabled && !n.readonly && n.showButton), p = $(() => ({ "input-group": !0, "flex-row": !0, "f-cmp-number-spinner": !0, "f-state-disabled": n.disable, "f-state-readonly": n.readonly && !n.disable, "f-state-focus": f.value })); return wt(() => { const E = c(n.modelValue, !1); s.value = u(E, !1); }), Te(() => [n.value], ([E]) => { const b = c(E, !1); l.value = b, s.value = u(b, !1); }), Te(() => [n.modelValue], ([E]) => { E !== l.value && (l.value = E, !f.value && (s.value = u(c(E, !1), !1))); }), Te(() => [n.precision, n.useThousands, n.prefix, n.suffix, n.showZero], () => { s.value = u(l.value, !1); }), () => M("div", { class: p.value }, [d(), m.value && a()]); } }); function Va() { const n = $(() => ({ "input-group-append": !0, "btn-group": !0, "btn-group-number": !0 })), t = $(() => ({ btn: !0, "btn-secondary": !0, "btn-number-flag": !0 })), e = $(() => ({ cursor: "pointer", "margin-left": 0 })), o = $(() => ({ cursor: "pointer", "margin-left": 0 })); return () => M("div", { class: n.value }, [M("button", { class: t.value, style: e.value }, [M("span", { class: "f-icon f-icon-arrow-chevron-up number-arrow-chevron" }, null)]), M("button", { class: t.value, style: o.value }, [M("span", { class: "f-icon f-icon-arrow-chevron-down number-arrow-chevron" }, null)])]); } function oo(n, t, e) { var h; const o = e && e.getStyles && e.getStyles() || "", r = e && e.getDesignerClass && e.getDesignerClass() || "", i = T(); 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(S) { if (!S || !S.value) return null; if (S.value.schema && S.value.schema.type === "component") return S.value; const x = T(S == null ? void 0 : S.value.parent), k = d(x); return k || null; } function u(S = t) { var N; if (e != null && e.getDraggableDesignItemElement) return e.getDraggableDesignItemElement(S); const { componentInstance: x, designerItemElementRef: k } = S; if (!x || !x.value) return null; const { getCustomButtons: y } = x.value; return x.value.canMove || y && ((N = y()) != null && N.length) ? k : u(S.parent); } function f(S) { return !!e && e.canAccepts(S); } 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 E(S, x) { var k; !S || !x || (e != null && e.onAcceptMovedChildElement && e.onAcceptMovedChildElement(S, x), (k = t == null ? void 0 : t.setupContext) == null || k.emit("dragEnd")); } function b(S, x) { const { componentType: k } = S; let y = Zn(k, S, x); e && e.onResolveNewComponentSchema && (y = e.onResolveNewComponentSchema(S, y)); const N = k.toLowerCase().replace(/-/g, "_"); return y && !y.id && y.type === k && (y.id = `${N}_${Math.random().toString().slice(2, 6)}`), y; } function g(S) { S && e != null && e.onChildElementMovedOut && e.onChildElementMovedOut(S); } function w(...S) { if (e && e.getPropsConfig) return e.getPropsConfig(...S); } function v(S) { if (!S) return; const x = t == null ? void 0 : t.schema, { formSchemaUtils: k } = S; if (x && k.getExpressions().length) { const y = k.getExpressions().findIndex((N) => N.target === x.id); y > -1 && k.getExpressions().splice(y, 1); } } function C(S) { e && e.onRemoveComponent && e.onRemoveComponent(), v(S), t != null && t.schema.contents && t.schema.contents.map((x) => { let k = x.id; x.type === "component-ref" && (k = x.component); const y = n.value.querySelectorAll(`#${k}-design-item`); y != null && y.length && Array.from(y).map((N) => { var V; (V = N == null ? void 0 : N.componentInstance) != null && V.value.onRemoveComponent && N.componentInstance.value.onRemoveComponent(S); }); }); } function _() { if (e && e.getCustomButtons) return e.getCustomButtons(); } function F(S) { if (e && e.onPropertyChanged) return e.onPropertyChanged(S); } 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: w, getDragScopeElement: p, onAcceptMovedChildElement: E, onChildElementMovedOut: g, addNewChildComponentSchema: b, triggerBelongedComponentToMoveWhenMoved: !!e && e.triggerBelongedComponentToMoveWhenMoved || T(!1), triggerBelongedComponentToDeleteWhenDeleted: !!e && e.triggerBelongedComponentToDeleteWhenDeleted || T(!1), onRemoveComponent: C, getCustomButtons: _, onPropertyChanged: F }, i; } const Ba = T(0); function Da() { Ba.value++; } const Wt = T(0); function Ra(n, t) { const e = t.getBoundingClientRect(), o = n.getBoundingClientRect(), r = o.top >= e.top, i = o.top <= e.bottom; return r && i; } function La(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 Wa(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 ro(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 = Wa(n); if (r && (o = Ra(n, r)), !o) { e.style.display = "none"; return; } La(n); } } function $a(n) { if (!n) return; let t; n.className.includes("dgComponentSelected") ? t = n : t = n.querySelector(".dgComponentSelected"), t && ro(t); } function Ha(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 io { 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 ao { 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": { Wt.value++; break; } } o && o(a, t, s); } } }; } getPropertyEditorParams(t, e = [], o = "visible", r = {}, i = {}) { const { getVariables: a, getControlName: s, getStateMachines: l } = Ha(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), Da(); } /** * 属性编辑器,在编辑过程中会新增变量,此处需要将新增的变量追加到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((b) => b.target === s); p || (p = { target: s, rules: [], targetType: l }, m.push(p)); const E = p.rules.find((b) => b.type === c); if (E) E.value = d, E.message = u; else { const b = { id: i, type: c, value: d, message: u }; p.rules.push(b); } 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 io(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 jt = class jt { /** * 根据绑定字段类型获取可用的输入类控件 */ static getEditorTypesByMDataType(t, e = "") { let o = jt.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 jt.fieldControlTypeMapping) jt.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["da