@farris/ui-vue
Version:
Farris Vue, a Farris Design based Vue3 component library.
1,378 lines • 203 kB
JavaScript
var Pn = Object.defineProperty;
var On = (n, e, t) => e in n ? Pn(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
var _ = (n, e, t) => On(n, typeof e != "symbol" ? e + "" : e, t);
import { ref as C, computed as L, defineComponent as Be, createVNode as b, watch as Se, Fragment as at, reactive as De, createApp as Zt, onUnmounted as Ct, onMounted as Je, Transition as Jt, mergeProps as Lt, nextTick as wt, createTextVNode as Rn, inject as jt, onBeforeMount as Vn, Teleport as Nn, shallowRef as jn, render as Nt, h as Dn, cloneVNode as Hn } from "vue";
import { cloneDeep as vt, isPlainObject as _t, isUndefined as Ne } from "lodash-es";
import { resolveAppearance as Kt, getSchemaByTypeForDesigner as Ln, createPropsResolver as en } from "../dynamic-resolver/index.esm.js";
import { useI18n as St } from "vue-i18n";
import { DgControl as Xt, useDesignerComponent as $n } from "../designer-canvas/index.esm.js";
import { getCustomClass as Dt, withInstall as tn, FormSchemaEntityField$Type as gt, FormSchemaEntityFieldTypeName as Yt, FormSchemaEntityFieldType$Type as zn } from "../common/index.esm.js";
import { LocaleService as At } from "../locale/index.esm.js";
import { useResizeObserver as qn } from "@vueuse/core";
import { getHierarchyRow as Un, useIdentify as Wn, useGroupData as Gn, useFilter as Qn, useHierarchy as _n, useLoading as Xn, useDataView as Yn, useSelection as Zn, useSelectHierarchyItem as Jn, usePagination as Kn, useDataViewContainerStyle as eo, useCommandColumn as to, useSettingColumn as no, useColumn as oo, useSort as io, useGroupColumn as ro, useRow as ao, useEdit as so, useVisualDataBound as lo, useVisualDataCell as co, useVisualDataRow as uo, useVisualData as fo, useCellPosition as po, useSidebar as mo, useVirtualScroll as vo, useFitColumn as go, useFilterHistory as ho, useColumnFilter as yo, useDragColumn as bo, getColumnHeader as Co, getSidebar as wo, getDisableMask as So, getHorizontalScrollbar as Ao, getVerticalScrollbar as xo, getEmpty as To, getPagination as Eo, getSummary as Mo } from "../data-view/index.esm.js";
import "../property-panel/index.esm.js";
import "../accordion/index.esm.js";
import "../avatar/index.esm.js";
import "../../designer/button-edit/index.esm.js";
import "../button-group/index.esm.js";
import "../calendar/index.esm.js";
import "../capsule/index.esm.js";
import "../../designer/checkbox/index.esm.js";
import "../../designer/checkbox-group/index.esm.js";
import "../combo-list/index.esm.js";
import "../combo-tree/index.esm.js";
import "../component/index.esm.js";
import "../color-picker/index.esm.js";
import "../content-container/index.esm.js";
import "../date-picker/index.esm.js";
import "../../designer/data-grid/index.esm.js";
import "../dropdown/index.esm.js";
import "../dynamic-form/index.esm.js";
import "../events-editor/index.esm.js";
import "../filter-bar/index.esm.js";
import "../field-selector/index.esm.js";
import "../binding-selector/index.esm.js";
import "../image-cropper/index.esm.js";
import "../../designer/input-group/index.esm.js";
import "../layout/index.esm.js";
import "../list-nav/index.esm.js";
import "../../designer/list-view/index.esm.js";
import "../lookup/index.esm.js";
import "../mapping-editor/index.esm.js";
import "../nav/index.esm.js";
import "../number-range/index.esm.js";
import "../number-spinner/index.esm.js";
import "../order/index.esm.js";
import "../page-header/index.esm.js";
import "../page-footer/index.esm.js";
import "../pagination/index.esm.js";
import "../progress/index.esm.js";
import "../query-solution/index.esm.js";
import "../../designer/radio-group/index.esm.js";
import "../rate/index.esm.js";
import "../response-toolbar/index.esm.js";
import "../response-layout/index.esm.js";
import "../response-layout-editor/index.esm.js";
import "../search-box/index.esm.js";
import "../section/index.esm.js";
import "../smoke-detector/index.esm.js";
import "../splitter/index.esm.js";
import "../step/index.esm.js";
import "../switch/index.esm.js";
import "../tabs/index.esm.js";
import "../tags/index.esm.js";
import "../text/index.esm.js";
import "../time-picker/index.esm.js";
import "../transfer/index.esm.js";
import "../tree-view/index.esm.js";
import "../uploader/index.esm.js";
import "../verify-detail/index.esm.js";
import "../video/index.esm.js";
import "../textarea/index.esm.js";
import "../schema-selector/index.esm.js";
import "../../designer/tree-grid/index.esm.js";
import "../event-parameter/index.esm.js";
import "../filter-condition-editor/index.esm.js";
import "../fieldset/index.esm.js";
import "../sort-condition-editor/index.esm.js";
import "../menu-lookup/index.esm.js";
import "../../designer/drawer/index.esm.js";
import "../json-editor/index.esm.js";
import "../property-editor/index.esm.js";
import "../expression-editor/index.esm.js";
import "../code-editor/index.esm.js";
import "../html-template/index.esm.js";
import "../collection-property-editor/index.esm.js";
import "../modal/index.esm.js";
import "../external-container/index.esm.js";
import "../language-textbox/index.esm.js";
import "../notify/index.esm.js";
function nn(n, e) {
let t;
function o(s) {
const { properties: m, title: d, ignore: f } = s, v = f && Array.isArray(f), S = Object.keys(m).reduce((E, F) => ((!v || !f.find(($) => $ === F)) && (E[F] = m[F].type === "object" && m[F].properties ? o(m[F]) : vt(m[F].default)), E), {});
if (d && (!v || !f.find((E) => E === "id"))) {
const E = d.toLowerCase().replace(/-/g, "_");
S.id = `${E}_${Math.random().toString().slice(2, 6)}`;
}
return S;
}
function i(s) {
const { properties: m, title: d, required: f } = s;
if (f && Array.isArray(f)) {
const v = f.reduce((S, E) => (S[E] = m[E].type === "object" && m[E].properties ? o(m[E]) : vt(m[E].default), S), {});
if (d && f.find((S) => S === "id")) {
const S = d.toLowerCase().replace(/-/g, "_");
v.id = `${S}_${Math.random().toString().slice(2, 6)}`;
}
return v;
}
return {
type: d
};
}
function a(s, m = {}, d) {
const f = n[s];
if (f) {
let v = i(f);
const S = e[s];
return v = S ? S({ getSchemaByType: a }, v, m, d) : v, t != null && t.appendIdentifyForNewControl && t.appendIdentifyForNewControl(v), v;
}
return null;
}
function r(s, m) {
const d = o(m);
return Object.keys(d).reduce((f, v) => (Object.prototype.hasOwnProperty.call(s, v) && (f[v] && _t(f[v]) && _t(s[v] || !s[v]) ? Object.assign(f[v], s[v] || {}) : f[v] = s[v]), f), d), d;
}
function u(s, m) {
return Object.keys(s).filter((f) => s[f] != null).reduce((f, v) => {
if (m.has(v)) {
const S = m.get(v);
if (typeof S == "string")
f[S] = s[v];
else {
const E = S(v, s[v], s);
Object.assign(f, E);
}
} else
f[v] = s[v];
return f;
}, {});
}
function l(s, m, d = /* @__PURE__ */ new Map()) {
const f = r(s, m);
return u(f, d);
}
function c(s) {
var d;
const m = s.type;
if (m) {
const f = n[m];
if (!f)
return s;
const v = r(s, f), S = ((d = s.editor) == null ? void 0 : d.type) || "";
if (S) {
const E = n[S], F = r(s.editor, E);
v.editor = F;
}
return v;
}
return s;
}
function p(s) {
t = s;
}
return { getSchemaByType: a, resolveSchemaWithDefaultValue: c, resolveSchemaToProps: l, mappingSchemaToProps: u, setDesignerContext: p };
}
const on = {}, rn = {}, { getSchemaByType: Ds, resolveSchemaWithDefaultValue: Fo, resolveSchemaToProps: Bo, mappingSchemaToProps: ko, setDesignerContext: Hs } = nn(on, rn);
function Io(n = {}) {
function e(c, p, s, m) {
if (typeof s == "number")
return m[c].length === s;
if (typeof s == "object") {
const d = Object.keys(s)[0], f = s[d];
if (d === "not")
return Number(m[c].length) !== Number(f);
if (d === "moreThan")
return Number(m[c].length) >= Number(f);
if (d === "lessThan")
return Number(m[c].length) <= Number(f);
}
return !1;
}
function t(c, p, s, m) {
return m[c] && m[c].propertyValue && String(m[c].propertyValue.value) === String(s);
}
const o = /* @__PURE__ */ new Map([
["length", e],
["getProperty", t]
]);
Object.keys(n).reduce((c, p) => (c.set(p, n[p]), c), o);
function i(c, p) {
const s = c;
return typeof p == "number" ? [{ target: s, operator: "length", param: null, value: Number(p) }] : typeof p == "boolean" ? [{ target: s, operator: "getProperty", param: c, value: !!p }] : typeof p == "object" ? Object.keys(p).map((m) => {
if (m === "length")
return { target: s, operator: "length", param: null, value: p[m] };
const d = m, f = p[m];
return { target: s, operator: "getProperty", param: d, value: f };
}) : [];
}
function a(c) {
return Object.keys(c).reduce((s, m) => {
const d = i(m, c[m]);
return s.push(...d), s;
}, []);
}
function r(c, p) {
if (o.has(c.operator)) {
const s = o.get(c.operator);
return s && s(c.target, c.param, c.value, p) || !1;
}
return !1;
}
function u(c, p) {
return a(c).reduce((d, f) => d && r(f, p), !0);
}
function l(c, p) {
const s = Object.keys(c), m = s.includes("allOf"), d = s.includes("anyOf"), f = m || d, E = (f ? c[f ? m ? "allOf" : "anyOf" : "allOf"] : [c]).map(($) => u($, p));
return m ? !E.includes(!1) : E.includes(!0);
}
return { parseValueSchema: l };
}
const Po = {
convertTo: (n, e, t, o) => {
n.appearance || (n.appearance = {}), n.appearance[e] = t;
},
convertFrom: (n, e, t) => n.appearance ? n.appearance[e] : n[e]
}, Oo = {
convertFrom: (n, e, t) => n.buttons && n.buttons.length ? `共 ${n.buttons.length} 项` : "无"
}, Ro = {
convertTo: (n, e, t, o) => {
n.editor && (n.editor[e] = t);
},
convertFrom: (n, e, t) => n.editor && Object.prototype.hasOwnProperty.call(n.editor, e) ? n.editor[e] : n[e]
}, j = {
button: { type: "button", name: "按钮" },
"response-toolbar": { type: "response-toolbar", name: "工具栏" },
"response-toolbar-item": { type: "response-toolbar-item", name: "按钮" },
"content-container": { type: "content-container", name: "容器" },
"input-group": { type: "input-group", name: "文本" },
textarea: { type: "textarea", name: "多行文本" },
lookup: { type: "lookup", name: "帮助" },
"number-spinner": { type: "number-spinner", name: "数值" },
"date-picker": { type: "date-picker", name: "日期" },
switch: { type: "switch", name: "开关" },
"radio-group": { type: "radio-group", name: "单选组" },
"check-box": { type: "check-box", name: "复选框" },
"check-group": { type: "check-group", name: "复选框组" },
"combo-list": { type: "combo-list", name: "下拉列表" },
"response-form": { type: "response-form", name: "卡片面板" },
"response-layout": { type: "response-layout", name: "布局容器", icon: "response-layout-3" },
"response-layout-item": { type: "response-layout-item", name: "布局", icon: "response-layout-1" },
"tree-grid": { type: "tree-grid", name: "树表格" },
"tree-grid-column": { type: "tree-grid-column", name: "树表格列" },
"data-grid": { type: "data-grid", name: "表格" },
"data-grid-column": { type: "data-grid-column", name: "表格列" },
module: { type: "Module", name: "模块" },
component: { type: "component", name: "组件" },
tabs: { type: "tabs", name: "标签页" },
"tab-page": { type: "tab-page", name: "标签页项", dependentParentControl: "Tab" },
"tab-toolbar-item": { type: "tab-toolbar-item", name: "标签页工具栏按钮" },
"html-template": { type: "html-template", name: "模板容器" },
"time-picker": { type: "time-picker", name: "时间选择" },
section: { type: "section", name: "分组面板" },
"section-toolbar": { type: "section-toolbar", name: "分组面板工具栏" },
"section-toolbar-item": { type: "section-toolbar-item", name: "分组面板按钮" },
splitter: { type: "splitter", name: "分栏面板" },
"splitter-pane": { type: "splitter-pane", name: "分栏面板项", dependentParentControl: "Splitter" },
"component-ref": { type: "component-ref", name: "组件引用节点" },
uploader: { type: "uploader", name: "附件上传" },
"page-header": { type: "page-header", name: "页头" },
"page-footer": { type: "page-footer", name: "页脚" },
"tab-toolbar": { type: "tab-toolbar", name: "标签页工具栏" },
fieldset: { type: "fieldset", name: "分组" },
"query-solution": { type: "query-solution", name: "筛选方案" },
drawer: { type: "drawer", name: "抽屉" },
"external-container": { type: "external-container", name: "外部容器", icon: "content-container" },
"list-nav": { type: "list-nav", name: "列表导航" },
"list-view": { type: "list-view", name: "列表" },
"filter-bar": { type: "filter-bar", name: "筛选条" },
"language-textbox": { type: "language-textbox", name: "多语输入框" }
}, Vo = {
convertFrom: (n, e, t) => {
var i;
const o = n.editor && n.editor[e] ? n.editor[e] : n[e];
return ((i = j[o]) == null ? void 0 : i.name) || o;
}
}, No = {
convertTo: (n, e, t, o) => {
n[e] = n[e];
},
convertFrom: (n, e, t) => n.editor ? t.getRealEditorType(n.editor.type) : ""
}, jo = {
convertTo: (n, e, t, o) => {
(n.type === "data-grid-column" || n.type === "tree-grid-column") && (n.formatter ? n.formatter[e] = t : n.formatter = {
[e]: t
});
},
convertFrom: (n, e, t) => {
if (n.formatter) {
if (e === "trueText")
return n.formatter.trueText;
if (e === "falseText")
return n.formatter.falseText;
if (e === "prefix")
return n.formatter.prefix;
if (e === "suffix")
return n.formatter.suffix;
if (e === "precision")
return n.formatter.precision;
if (e === "decimal")
return n.formatter.decimal;
if (e === "thousand")
return n.formatter.thousand;
if (e === "tempDateFormat")
return n.formatter.dateFormat === "yyyy年MM月dd日" ? "yearMonthDay" : n.formatter.dateFormat === "yyyy-MM-dd HH:mm:ss" ? "yyyy-MM-ddTHH:mm:ss" : n.formatter.dateFormat === "yyyy/MM/dd HH:mm:ss" ? "yyyy/MM/ddTHH:mm:ss" : n.formatter.dateFormat === "yyyy年MM月dd日 HH时mm分ss秒" ? "yearMonthDayHourMinuteSecond" : n.formatter.tempDateFormat || n.formatter.dateFormat || "yyyy-MM-dd";
if (e === "customFormat")
return n.formatter.customFormat;
if (e === "type")
return n.formatter.type || "none";
}
return "none";
}
}, Do = {
convertTo: (n, e, t, o) => {
n.command ? n.command[e] = t : n.command = {
[e]: t
}, e === "enable" && t && (n.command.commands || (n.command.commands = [
{
text: "编辑",
type: "primary",
command: "edit"
},
{
text: "删除",
type: "danger",
command: "remove"
}
]));
},
convertFrom: (n, e, t) => n.command && e === "enable" ? n.command.enable : ""
}, Ho = {
convertTo: (n, e, t, o) => {
n.column ? n.column[e] = t : n.column = {
[e]: t
}, e === "fitColumns" && t && (n.column.fitMode || (n.column.fitMode = "average"));
},
convertFrom: (n, e, t) => {
if (n.column) {
if (e === "fitColumns")
return n.column.fitColumns;
if (e === "fitMode")
return n.column.fitMode;
}
return "";
}
}, Lo = {
convertTo: (n, e, t, o) => {
n.summary ? n.summary[e] = t : n.summary = {
[e]: t
}, e === "enable" && t && (n.summary ? n.summary.groupFields || (n.summary.groupFields = []) : n.summary = {
enable: t,
groupFields: []
});
},
convertFrom: (n, e, t) => n.summary && e === "enable" ? n.summary.enable : n.type === "data-grid-column" ? n.enableSummary === void 0 ? !1 : n.enableSummary : ""
}, $o = {
convertTo: (n, e, t, o) => {
n.group ? n.group[e] = t : n.group = {
[e]: t
}, e === "enable" && t && (n.group ? n.group.groupFields || (n.group.groupFields = []) : n.group = {
enable: t,
groupFields: [],
showSummary: !1
});
},
convertFrom: (n, e, t) => {
if (n.group) {
if (e === "enable")
return n.group.enable;
if (e === "showSummary")
return n.group.showSummary;
}
}
}, zo = {
convertFrom: (n, e) => n.binding ? n.binding.path : "",
convertTo: (n, e, t) => {
if (t && t.length > 0) {
const o = t[0];
n.binding || (n.binding = {}), n.binding.type = "Form", n.binding.path = o.bindingField, n.binding.field = o.id, n.binding.fullPath = o.path, n.path = o.bindingPath;
}
}
}, qo = {
convertTo: (n, e, t, o) => {
n.pagination || (n.pagination = {}), n.pagination[e] = t;
},
convertFrom: (n, e, t) => n.pagination ? n.pagination[e] : n[e]
}, Uo = {
convertTo: (n, e, t, o) => {
n.rowNumber || (n.rowNumber = {}), n.rowNumber[e] = t;
},
convertFrom: (n, e, t) => n.rowNumber ? n.rowNumber[e] : n[e]
}, Wo = {
convertTo: (n, e, t, o) => {
n.selection || (n.selection = {}), n.selection[e] = t;
},
convertFrom: (n, e, t) => n.selection ? n.selection[e] : n[e]
}, Go = {
convertFrom: (n, e, t) => n[e] && n[e].length ? `共 ${n[e].length} 项` : ""
}, Qo = {
convertFrom: (n, e) => n[e] || "",
convertTo: (n, e, t) => {
n[e] = t;
}
}, _o = {
convertTo: (n, e, t, o) => {
n.size || (n.size = {}), n.size[e] = t;
},
convertFrom: (n, e, t) => n.size ? n.size[e] : n[e]
}, Xo = {
convertFrom: (n, e, t) => {
var o, i;
return (o = n.formatter) != null && o.data && e === "formatterEnumData" && !n.formatterEnumData ? (i = n.formatter) == null ? void 0 : i.data : n.formatterEnumData;
}
}, Yo = {
convertTo: (n, e, t, o) => {
n.sort || (n.sort = {}), n.sort[e] = t;
},
convertFrom: (n, e, t) => {
var o, i;
if (e === "mode")
return ((o = n.sort) == null ? void 0 : o.mode) || "client";
if (e === "multiSort")
return !!((i = n.sort) != null && i.multiSort);
}
}, Zo = {
convertTo: (n, e, t, o) => {
n.filter || (n.filter = {}), n.filter[e] = t;
},
convertFrom: (n, e, t) => {
var o;
if (e === "mode")
return ((o = n.filter) == null ? void 0 : o.mode) || "client";
}
}, Jo = {
convertTo: (n, e, t, o) => {
n.rowOption ? n.rowOption[e] = t : n.rowOption = {
[e]: t
};
},
convertFrom: (n, e, t) => {
if (n.rowOption) {
if (e === "customRowStyle")
return n.rowOption.customRowStyle;
if (e === "customCellStyle")
return n.rowOption.customCellStyle;
}
return "";
}
};
function an(n, e, t) {
const o = /* @__PURE__ */ new Map([
["/converter/appearance.converter", Po],
["/converter/buttons.converter", Oo],
["/converter/property-editor.converter", Ro],
["/converter/items-count.converter", Go],
["/converter/type.converter", Vo],
["/converter/change-editor.converter", No],
["/converter/change-formatter.converter", jo],
["/converter/column-command.converter", Do],
["/converter/column-option.converter", Ho],
["/converter/summary.converter", Lo],
["/converter/group.converter", $o],
["/converter/form-group-label.converter", Qo],
["/converter/field-selector.converter", zo],
["/converter/pagination.converter", qo],
["/converter/row-number.converter", Uo],
["/converter/grid-selection.converter", Wo],
["/converter/size.converter", _o],
["/converter/change-formatter-enum.converter", Xo],
["/converter/grid-sort.converter", Yo],
["/converter/grid-filter.converter", Zo],
["/converter/row-option.converter", Jo]
]), i = /* @__PURE__ */ new Map([
["string", { type: "input-group", enableClear: !1 }],
["boolean", {
type: "combo-list",
textField: "name",
valueField: "value",
idField: "value",
enableClear: !1,
editable: !1,
data: [
{
value: !0,
name: "是"
},
{
value: !1,
name: "否"
}
]
}],
["enum", { type: "combo-list", maxHeight: 128, enableClear: !1, editable: !1 }],
["array", { type: "button-edit" }],
["number", { type: "number-spinner", placeholder: "" }],
["events-editor", { type: "events-editor", hide: !0 }]
]), a = Io();
function r(f, v) {
return () => a.parseValueSchema(f, v);
}
function u(f, v, S) {
return f.includes("visible") && v.visible !== void 0 ? typeof v.visible == "boolean" ? () => !!v.visible : v.visible === void 0 ? !0 : r(v.visible, S) : () => !0;
}
function l(f, v, S) {
return f.includes("readonly") && v.readonly !== void 0 ? typeof v.readonly == "boolean" ? () => !!v.readonly : r(v.readonly, S) : () => !1;
}
function c(f, v) {
const S = f.$converter || v;
return typeof S == "string" && S && o.has(S) ? o.get(S) || null : S || null;
}
function p(f, v, S, E, F, $ = "", x = "") {
return Object.keys(f).map((h) => {
const M = C(1), T = h, A = f[h], I = Object.keys(A), w = A.title, B = A.type, O = i.get(B) || { type: "input-group", enableClear: !1 }, R = A.editor ? Object.assign({}, O, A.editor) : Object.assign({}, O), D = u(I, A, v), G = l(I, A, v);
R.readonly = R.readonly === void 0 ? G() : R.readonly;
const ee = A.type === "cascade" ? p(A.properties, v, S, E, F, $, x) : [], V = !0;
let P = c(A, x);
const Q = L({
get() {
if (M.value) {
if (["class", "style"].find((le) => le === T) && !P && (P = o.get("/converter/appearance.converter") || null), P && P.convertFrom)
return P.convertFrom(S, h, F, $);
const ie = S[h];
return Object.prototype.hasOwnProperty.call(A, "defaultValue") && (ie === void 0 || typeof ie == "string" && ie === "") ? A.type === "boolean" ? A.defaultValue : A.defaultValue || "" : ie;
}
return null;
},
set(ie) {
M.value += 1, P && P.convertTo ? (P.convertTo(E, h, ie, F, $), P.convertTo(S, h, ie, F, $)) : (E[h] = ie, S[h] = ie);
}
}), { refreshPanelAfterChanged: z, description: te, isExpand: ve, parentPropertyID: ge } = A, Y = { propertyID: T, propertyName: w, propertyType: B, propertyValue: Q, editor: R, visible: D, readonly: G, cascadeConfig: ee, hideCascadeTitle: V, refreshPanelAfterChanged: z, description: te, isExpand: ve, parentPropertyID: ge };
return v[T] = Y, Y;
});
}
function s(f, v, S = {}) {
const E = {}, F = n[f];
return F && F.categories ? Object.keys(F.categories).map((x) => {
const g = F.categories[x], h = g == null ? void 0 : g.title, M = p(g.properties || {}, E, {}, S, v);
return { categoryId: x, categoryName: h, properties: M };
}) : [];
}
function m(f, v, S, E, F = "") {
const $ = v.$ref.schema, x = v.$ref.converter, g = S[$], h = g.type, M = t(g), T = {}, A = n[h];
if (A && A.categories) {
const I = A.categories[f], w = I == null ? void 0 : I.title;
x && Object.keys(I.properties).forEach((R) => {
I.properties[R].$converter = x;
});
const B = (I == null ? void 0 : I.properties) || {}, O = p(B, T, M, g, E, F);
return { categoryId: f, categoryName: w, properties: O };
}
return { categoryId: f, categoryName: "", properties: [] };
}
function d(f, v, S, E, F) {
const $ = f.type, x = t(f), g = {};
let h = F || n[$];
if (h && Object.keys(h).length === 0 && S && S.getPropConfig && (h = S.getPropConfig(E)), h && h.categories) {
const M = [];
return Object.keys(h.categories).map((T) => {
const A = h.categories[T];
if (A.$ref) {
M.push(m(T, A, f, v, E));
return;
}
const I = A == null ? void 0 : A.title, w = A == null ? void 0 : A.tabId, B = A == null ? void 0 : A.tabName, O = A == null ? void 0 : A.hide, R = A == null ? void 0 : A.hideTitle, D = p(A.properties || {}, g, x, f, v, E, A.$converter), { setPropertyRelates: G } = A, ee = A == null ? void 0 : A.parentPropertyID;
M.push({ categoryId: T, categoryName: I, tabId: w, tabName: B, hide: O, properties: D, hideTitle: R, setPropertyRelates: G, parentPropertyID: ee });
}), M;
}
return [];
}
return {
getPropertyConfigBySchema: d,
getPropertyConfigByType: s,
propertyConverterMap: o
};
}
const sn = {}, ln = {};
an(sn, ln, Fo);
const cn = {}, un = {}, { getSchemaByType: Ls, resolveSchemaWithDefaultValue: Ko, resolveSchemaToProps: $s, mappingSchemaToProps: zs, setDesignerContext: qs } = nn(cn, un), dn = {}, fn = {};
an(dn, fn, Ko);
function st(n, e, t = /* @__PURE__ */ new Map(), o = (r, u, l, c) => u, i = {}, a = (r) => r) {
return on[e.title] = e, rn[e.title] = o, sn[e.title] = i, ln[e.title] = a, cn[e.title] = e, un[e.title] = o, dn[e.title] = i, fn[e.title] = a, (r = {}, u = !0) => {
if (!u)
return ko(r, t);
const l = Bo(r, e, t), c = Object.keys(n).reduce((p, s) => (p[s] = n[s].default, p), {});
return Object.assign(c, l);
};
}
function ei(n, e, t) {
return e;
}
const ti = /* @__PURE__ */ new Map([
["appearance", Kt]
]), ni = "https://json-schema.org/draft/2020-12/schema", oi = "https://farris-design.gitee.io/avatar.schema.json", ii = "avatar", ri = "A Farris Component", ai = "object", si = {
id: {
description: "The unique identifier for avatar",
type: "string"
},
type: {
description: "The type string of avatar",
type: "string",
default: "avatar"
},
appearance: {
description: "",
type: "object",
properties: {
class: {
type: "string"
},
style: {
type: "string"
}
},
default: {}
},
binding: {
description: "",
type: "object",
default: {}
},
disabled: {
type: "boolean",
default: !1
},
avatarWidth: {
description: "",
type: "number",
default: 100
},
avatarHeight: {
description: "",
type: "number",
default: 100
},
readonly: {
description: "",
type: "boolean",
default: !1
},
cover: {
description: "",
type: "string",
default: ""
},
tabindex: {
description: "",
type: "number",
default: -1
},
visible: {
description: "",
type: "boolean",
default: !0
}
}, li = [
"id",
"type"
], ci = [
"id",
"appearance",
"binding",
"visible"
], ui = {
$schema: ni,
$id: oi,
title: ii,
description: ri,
type: ai,
properties: si,
required: li,
ignore: ci
}, $t = {
/**
* 头像宽度
*/
avatarWidth: { type: Number, default: 100 },
/**
* 头像高度
*/
avatarHeight: { type: Number, default: 100 },
/**
* 组件标识
*/
cover: { type: String },
/**
* 只读
*/
readonly: { type: Boolean, default: !1 },
/**
* 头像形状
*/
shape: { type: String, default: "circle" },
/**
* 头像最大尺寸, 单位MB
*/
maxSize: { type: Number, default: 1 },
/**
* 组件值
*/
modelValue: { type: String, default: "" },
/**
* 头像标题
*/
title: { type: String, default: "" },
/**
* 支持的头像类型
*/
imageType: { type: Array, default: ["jpeg"] }
}, pn = st($t, ui, ti, ei);
function mn(n, e, t, o) {
const i = "data:image/jpeg;base64,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", a = C(n.readonly);
function r(d) {
return d.match(/\.(jpeg|jpg|gif|png|svg|bmp|webp)$/) != null;
}
function u(d) {
return d.indexOf("data:image/") > -1;
}
function l(d) {
return d ? "data:image/jpeg;base64," + d : "";
}
const c = L(() => {
var f;
if (!n.imageType || !n.imageType.length)
return "";
const d = (f = n.imageType) == null ? void 0 : f.map((v) => (v === "jpg" && (v = "jpeg"), `image/${v}`));
return !d || !d.length ? "image/*" : d.join(",");
}), p = L(() => {
const d = o.value || n.cover || i;
return r(d) || u(d) ? d : l(d);
}), s = L(() => a.value ? "" : n.title);
function m() {
a.value || t && t.value && t.value.click();
}
return { acceptTypes: c, imageSource: p, imageTitle: s, onClickImage: m };
}
const ht = /* @__PURE__ */ Be({
name: "FAvatar",
props: $t,
emits: ["change", "update:modelValue"],
setup(n, e) {
St();
const t = L(() => ({
"f-avatar": !0,
"f-avatar-readonly": n.readonly,
"f-avatar-circle": n.shape === "circle",
"f-avatar-square": n.shape === "square"
})), o = C(n.modelValue), i = L(() => ({
width: n.avatarWidth + "px",
height: n.avatarHeight + "px"
})), a = !1;
function r() {
return "";
}
function u() {
}
const l = C(null), {
acceptTypes: c,
imageSource: p,
onClickImage: s
} = mn(n, e, l, o);
return () => b("div", {
class: t.value,
style: i.value,
onClick: s
}, [a, b("img", {
title: n.title,
class: "f-avatar-image",
src: p.value,
onError: r
}, null), !n.readonly && b("div", {
class: "f-avatar-icon"
}, [b("span", {
class: "f-icon f-icon-camera"
}, null)]), b("input", {
ref: "file",
name: "file-input",
type: "file",
class: "f-avatar-upload",
accept: c.value,
onChange: u,
style: "display: none;"
}, null)]);
}
}), di = C(0);
function fi() {
di.value++;
}
const dt = C(0);
function pi(n) {
const { formSchemaUtils: e, formStateMachineUtils: t } = n;
function o(l, c = "") {
return {
path: c + l.code,
field: l.id,
fullPath: l.code
};
}
function i(l, c = "") {
return e.getViewModelById(l).states.map((s) => o(s, c));
}
function a(l) {
const c = e.getRootViewModelId(), p = i(l);
if (l === c)
return p;
const s = i(c, "root-component.");
return [...p, ...s];
}
function r(l) {
return l.binding && l.binding.path || l.id || "";
}
function u() {
return t && t.getRenderStates() || [];
}
return { getVariables: a, getControlName: r, getStateMachines: u };
}
class vn {
constructor(e) {
_(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'"
}
]);
_(this, "expressionNames", {
compute: "计算表达式",
dependency: "依赖表达式",
validate: "验证表达式",
dataPicking: "帮助前表达式",
visible: "可见表达式",
readonly: "只读表达式",
required: "必填表达式"
});
_(this, "getExpressionConverter", (e, t) => ({
convertFrom: (o, i, a, r) => {
const u = a.getExpressionRuleValue(e, t || i);
return u && u.value || "";
},
convertTo: (o, i, a, r, u) => {
var l;
if (i === "dataPicking" && (a != null && a.target)) {
const c = `${a.target}_dataPicking`;
((l = a.rules) == null ? void 0 : l.some(
(s) => s.id === c && s.value
)) ? o.dictPickingExpressionId = c : delete o.dictPickingExpressionId;
}
r.updateExpression(a);
}
}));
this.formSchemaService = e;
}
getExpressionRule(e, t) {
const o = this.formSchemaService.getExpressions();
if (!o)
return "";
const i = o.find((r) => r.target === e);
if (!i)
return "";
const a = i.rules.find((r) => r.type === t);
return a || "";
}
// 获取上下文表单变量
getContextFormVariables() {
const { module: e } = this.formSchemaService.getFormSchema();
if (!e.viewmodels || e.viewmodels.length === 0)
return [];
const t = this.formSchemaService.getRootViewModelId(), o = this.formSchemaService.getViewModelById(t);
if (!o || !o.states || o.states.length === 0)
return [];
const i = [];
return o.states.forEach((a) => {
i.push({
key: a.code,
name: a.name,
description: a.name,
category: a.category
});
}), i;
}
createTreeNode(e, t, o = "label") {
return {
id: e.id,
name: e.name,
bindingPath: e[o],
parents: t,
type: "field"
};
}
buildEntityFieldsTreeData(e = null, t) {
const o = [];
return e == null || e.forEach((i) => {
var u;
const a = this.createTreeNode(i, t);
let r = [];
(u = i.type) != null && u.fields && (r = this.buildEntityFieldsTreeData(i.type.fields, [...t, i.label])), o.push({
data: a,
children: r,
expanded: !0
});
}), o;
}
buildChildEntityTreeData(e = null, t) {
const o = [];
return e == null || e.forEach((i) => {
var l, c;
const a = this.createTreeNode(i, t);
a.type = "entity";
const r = this.buildEntityFieldsTreeData((l = i.type) == null ? void 0 : l.fields, [...t, i.label]), u = this.buildChildEntityTreeData((c = i.type) == null ? void 0 : c.entities, [...t, i.label]);
u != null && u.length && (r == null || r.push(...u)), o.push({
data: a,
children: r || [],
// 空值回退
expanded: !0
});
}), o;
}
getEntitiesTreeData() {
const e = this.formSchemaService.getSchemaEntities();
if (!(e != null && e.length))
return [];
const t = e[0];
if (!(t != null && t.type))
return [];
const o = this.buildEntityFieldsTreeData(t.type.fields, [t.code]), i = this.buildChildEntityTreeData(t.type.entities, [t.code]);
return i != null && i.length && (o == null || o.push(...i)), {
entityCode: t.code,
fields: [{
data: this.createTreeNode(t, [], "code"),
children: o || []
}]
};
}
getEntitiesAndVariables() {
return {
entities: this.getEntitiesTreeData(),
variables: {
session: {
name: "系统变量",
items: this.sessionVariables,
visible: !1
},
forms: {
name: "表单变量",
items: this.getContextFormVariables(),
visible: !0
}
}
};
}
onBeforeOpenExpression(e, t, o) {
const i = o === "Field" ? e.binding.field : e.id, a = this.getExpressionRule(i, t), r = this.getEntitiesAndVariables(), u = {
message: ["validate", "required", "dataPicking"].includes(t) && a ? a.message : "",
...r
};
return a.messageType != null && (u.messageType = a.messageType), u;
}
buildRule(e, t, o, i) {
const { expression: a, message: r, messageType: u } = t, l = {
id: `${e}_${o}`,
type: o,
value: a
};
return (o === "validate" || o === "dataPicking" || o === "required") && (l.message = r), o === "dataPicking" && (l.messageType = u), o === "validate" && i && (l.elementId = i), l;
}
getExpressionData() {
const { expressions: e } = this.formSchemaService.getFormSchema().module;
return e || [];
}
updateExpression(e, t, o, i) {
const a = t === "Field" ? e.binding.field : e.id, r = this.buildRule(a, o, i, e.type === "form-group" ? e.id : "");
let l = this.getExpressionData().find((p) => p.targetType === t && p.target === a);
const c = (p) => p.value.trim() === "";
if (l) {
const p = l.rules.find((s) => s.id === r.id);
if (p)
c(r) ? l.rules = l.rules.filter((s) => s.id !== r.id) : (Object.assign(p, r), i === "validate" && e.type === "form-group" && (p.elementId = e.id));
else {
if (c(r))
return null;
l.rules = l.rules || [], l.rules.push(r);
}
} else {
if (c(r))
return null;
l = {
target: `${a}`,
rules: [r],
targetType: t
};
}
return l;
}
getExpressionEditorOptions(e, t, o, i) {
return o.reduce((a, r) => {
var l, c;
const u = t === "Field" ? (l = e == null ? void 0 : e.binding) == null ? void 0 : l.field : e.id;
return a[r] = {
hide: t === "Field" ? !!((c = e == null ? void 0 : e.binding) != null && c.field) : !1,
description: "",
title: this.expressionNames[r],
type: "string",
$converter: this.getExpressionConverter(u),
refreshPanelAfterChanged: !0,
editor: {
type: "expression-editor",
singleExpand: !1,
dialogTitle: `${this.expressionNames[r]}编辑器`,
showMessage: r === "validate" || r === "dataPicking" || r === "required",
showMessageType: r === "dataPicking",
beforeOpen: () => this.onBeforeOpenExpression(e, r, t),
onSubmitModal: (p) => {
const s = this.updateExpression(e, t, p, r);
if (i) {
const m = this.buildRule(u, p, r);
i(m);
}
return s;
}
}
}, a;
}, {});
}
getExpressionInfo(e, t, o) {
const i = t === "Field" ? e.binding.field : e.id, a = this.getExpressionRule(i, o), r = {
value: a && a.value,
targetId: i,
targetType: t,
expressionType: o
};
return a && a.message && (r.message = a.message), r;
}
getExpressionConfig(e, t, o = ["compute", "dependency", "validate"], i) {
return {
description: "表达式",
title: "表达式",
hide: !e.binding,
properties: {
...this.getExpressionEditorOptions(e, t, o, i)
}
};
}
getExpressionOptions(e, t, o) {
const i = this.getExpressionInfo(e, t, o);
return {
dialogTitle: `${this.expressionNames[o]}编辑器`,
singleExpand: !1,
showMessage: o === "required",
beforeOpen: () => this.onBeforeOpenExpression(e, o, t),
expressionInfo: i
};
}
}
class mi {
constructor(e, t) {
_(this, "componentId");
_(this, "viewModelId");
_(this, "eventsEditorUtils");
_(this, "formSchemaUtils");
_(this, "formMetadataConverter");
_(this, "designViewModelUtils");
_(this, "designViewModelField");
_(this, "controlCreatorUtils");
_(this, "designerHostService");
_(this, "designerContext");
_(this, "schemaService", null);
_(this, "metadataService", null);
_(this, "propertyConfig", {
type: "object",
categories: {}
});
var o;
this.componentId = e, this.designerHostService = t, this.eventsEditorUtils = t.eventsEditorUtils, this.formSchemaUtils = t.formSchemaUtils, this.formMetadataConverter = t.formMetadataConverter, this.viewModelId = ((o = this.formSchemaUtils) == null ? void 0 : o.getViewModelIdByComponentId(e)) || "", this.designViewModelUtils = t.designViewModelUtils, this.controlCreatorUtils = t.controlCreatorUtils, this.metadataService = t.metadataService, this.schemaService = t.schemaService, this.designerContext = t.designerContext;
}
getFormDesignerInstance() {
var e, t;
return (t = (e = this.designerContext) == null ? void 0 : e.instances) == null ? void 0 : t.formDesigner.value;
}
getTableInfo() {
var e;
return (e = this.schemaService) == null ? void 0 : e.getTableInfoByViewModelId(this.viewModelId);
}
setDesignViewModelField(e) {
var o;
const t = e.binding && e.binding.type === "Form" && e.binding.field;
if (t) {
if (!this.designViewModelField) {
const i = this.designViewModelUtils.getDgViewModel(this.viewModelId);
this.designViewModelField = i.fields.find((a) => a.id === t);
}
e.updateOn = (o = this.designViewModelField) == null ? void 0 : o.updateOn;
}
}
getBasicPropConfig(e) {
return {
description: "Basic Information",
title: "基本信息",
properties: {
id: {
description: "组件标识",
title: "标识",
type: "string",
readonly: !0
},
type: {
description: "组件类型",
title: "控件类型",
type: "select",
editor: {
type: "combo-list",
textField: "name",
valueField: "value",
idField: "value",
editable: !1,
data: [{ value: e.type, name: j[e.type] && j[e.type].name }]
}
}
}
};
}
getAppearanceConfig(e = null, t = {}, o) {
const i = {
title: "外观",
description: "Appearance"
}, a = {
class: {
title: "class样式",
type: "string",
description: "组件的CSS样式",
$converter: "/converter/appearance.converter",
parentPropertyID: "appearance"
},
style: {
title: "style样式",
type: "string",
description: "组件的样式",
$converter: "/converter/appearance.converter",
parentPropertyID: "appearance"
}
};
for (const r in t)
a[r] = Object.assign(a[r] || {}, t[r]);
return {
...i,
properties: { ...a },
setPropertyRelates(r, u) {
if (r) {
switch (r && r.propertyID) {
case "class":
case "style": {
dt.value++;
break;
}
}
o && o(r, e, u);
}
}
};
}
getPropertyEditorParams(e, t = [], o = "visible", i = {}, a = {}) {
const { getVariables: r, getControlName: u, getStateMachines: l } = pi(this.designerHostService), c = this.getRealTargetType(e), p = t && t.length > 0 ? t : ["Const", "Variable", "StateMachine", "Expression"], s = {
type: "property-editor",
propertyTypes: p
};
return p.map((m) => {
switch (m) {
case "Const":
Object.assign(s, {
constType: "enum",
constEnums: [{ id: !0, name: "是" }, { id: !1, name: "否" }]
}, i);
break;
case "Expression":
s.expressionConfig = this.getExpressionOptions(e, c, o);
break;
case "StateMachine":
s.stateMachines = l();
break;
case "Variable":
Object.assign(s, {
controlName: u(e),
newVariablePrefix: "is",
newVariableType: "Boolean",
variables: r(this.viewModelId),
onBeforeOpenVariables: (d) => {
d.value = r(this.viewModelId);
}
}, a);
break;
}
}), s;
}
getVisibleProperty(e, t = "") {
var a;
let o = ["Const", "Variable", "StateMachine", "Expression"];
return t === "gridFieldEditor" ? o = ["Const", "Expression"] : t === "form-group" && !((a = e.binding) != null && a.field) && (o = ["Const", "Variable", "StateMachine"]), {
visible: {
title: "是否可见",
type: "boolean",
description: "运行时组件是否可见",
editor: this.getPropertyEditorParams(e, o, "visible")
}
};
}
/**
* 获取行为
* @param propertyData
* @param viewModelId
* @returns
*/
getBehaviorConfig(e, t = "", o = {}, i) {
const a = {
title: "行为",
description: ""
}, r = this.getVisibleProperty(e, t);
for (const l in o)
r[l] = Object.assign(r[l] || {}, o[l]);
const u = this;
return {
...a,
properties: { ...r },
setPropertyRelates(l, c) {
if (l) {
switch (l.propertyID) {
case "disabled":
case "readonly":
case "visible":
u.afterMutilEditorChanged(e, l);
break;
}
i && i(l, c);
}
}
};
}
/**
* 当多值编辑器变更时
* @param propertyData
* @param changeObject
*/
afterMutilEditorChanged(e, t) {
this.addNewVariableToViewModel(t, this.viewModelId), this.updateExpressionValue(t), this.clearExpression(t, e);
}
/**
*
* @param propertyId
* @param componentInstance
* @returns
*/
updateElementByParentContainer(e, t) {
const o = t && t.parent && t.parent.schema;
if (!o)
return;
const i = o.contents.findIndex((r) => r.id === e), a = vt(o.contents[i]);
o.contents.splice(i, 1), o.contents.splice(i, 0, a), fi();
}
/**
* 属性编辑器,在编辑过程中会新增变量,此处需要将新增的变量追加到ViewModel中
* @param changeObject
* @param viewModelId
* @returns
*/
addNewVariableToViewModel(e, t) {
const o = e.propertyValue;
if (!(o && typeof o == "object") || !(o.type === "Variable" && o.isNewVariable))
return;
const r = {
id: o.field,
category: "locale",
code: o.fullPath,
name: o.fullPath,
type: o.newVariableType || "String"
};
delete o.newVariableType, delete o.isNewVariable, this.formSchemaUtils.getVariableByCode(r.code) || this.formSchemaUtils.getViewModelById(t).states.push(r);
}
/**
* 更新表达式到expressions节点
* @param changeObject
*/
updateExpressionValue(e) {
const t = e.propertyValue;
if (!((t && t.type) === "Expression" && t.expressionInfo))
return;
const { expressionId: a, expressionInfo: r } = t, { targetId: u, targetType: l, expressionType: c, value: p, message: s } = r, m = this.formSchemaUtils.getModule();
m.expressions = m.expressions || [];
const { expressions: d } = m;
let f = d.find((S) => S.target === u);
f || (f = { target: u, rules: [], targetType: l }, d.push(f));
const v = f.rules.find((S) => S.type === c);
if (v)
v.value = p, v.message = s;
else {
const S = { id: a, type: c, value: p, message: s };
f.rules.push(S);
}
delete t.expressionInfo;
}
/**
* 属性类型切换为非表达式后,清除原表达式
* @param changeObject
* @param propertyData
* @returns
*/
clearExpression(e, t) {
const o = e.propertyValue;
if (o && o.type === "Expression")
return;
const a = e.propertyID, r = this.formSchemaUtils.getExpressions(), u = t.binding ? t.binding.field : t.id, l = r.find((c) => c.target === u);
!l || !l.rules || (l.rules = l.rules.filter((c) => c.type !== a));
}
getExpressionOptions(e, t, o) {
return new vn(this.formSchemaUtils).getExpressionOptions(e, t, o);
}
getRealTargetType(e) {
return ["response-toolbar-item", "tab-toolbar-item", "section-toolbar-item"].indexOf(e.type) > -1 ? "Button" : e.binding && e.binding.field ? "Field" : "Container";
}
createBaseEventProperty(e) {
const t = {};
return t[this.viewModelId] = {
type: "events-editor",
editor: {
initialData: e,
viewSourceHandle: (o) => {
var i;
((i = o.controller) == null ? void 0 : i.label.indexOf(this.formSchemaUtils.getModule().code)) > -1 && this.eventsEditorUtils.jumpToMethod(o);
}
}
}, t;
}
}
const Ye = class Ye {
/**
* 根据绑定字段类型获取可用的输入类控件
*/
static getEditorTypesByMDataType(e, t = !1, o = "") {
if (t)
return [{ key: j["language-textbox"].type, value: j["language-textbox"].name }];
let i = Ye.fieldControlTypeMapping[e];
if (o === "data-grid-column" && (i != null && i.lengt