@farris/ui-vue
Version:
Farris Vue, a Farris Design based Vue3 component library.
988 lines (987 loc) • 34.2 kB
JavaScript
import { ref as P, computed as q, defineComponent as J, onMounted as Q, watch as pe, createVNode as X, inject as me } from "vue";
import { cloneDeep as Y, isPlainObject as _ } from "lodash-es";
import { useTimeAgo as de, useDateFormat as ve, useNumberFormat as ge } from "../common/index.esm.js";
import { getSchemaByTypeForDesigner as be } from "../dynamic-resolver/index.esm.js";
function Z(e, t) {
let r;
function c(o) {
const { properties: l, title: d, ignore: i } = o, a = i && Array.isArray(i), n = Object.keys(l).reduce((m, S) => ((!a || !i.find((w) => w === S)) && (m[S] = l[S].type === "object" && l[S].properties ? c(l[S]) : Y(l[S].default)), m), {});
if (d && (!a || !i.find((m) => m === "id"))) {
const m = d.toLowerCase().replace(/-/g, "_");
n.id = `${m}_${Math.random().toString().slice(2, 6)}`;
}
return n;
}
function y(o) {
const { properties: l, title: d, required: i } = o;
if (i && Array.isArray(i)) {
const a = i.reduce((n, m) => (n[m] = l[m].type === "object" && l[m].properties ? c(l[m]) : Y(l[m].default), n), {});
if (d && i.find((n) => n === "id")) {
const n = d.toLowerCase().replace(/-/g, "_");
a.id = `${n}_${Math.random().toString().slice(2, 6)}`;
}
return a;
}
return {
type: d
};
}
function T(o, l = {}, d) {
const i = e[o];
if (i) {
let a = y(i);
const n = t[o];
return a = n ? n({ getSchemaByType: T }, a, l, d) : a, r != null && r.appendIdentifyForNewControl && r.appendIdentifyForNewControl(a), a;
}
return null;
}
function g(o, l) {
const d = c(l);
return Object.keys(d).reduce((i, a) => (Object.prototype.hasOwnProperty.call(o, a) && (i[a] && _(i[a]) && _(o[a] || !o[a]) ? Object.assign(i[a], o[a] || {}) : i[a] = o[a]), i), d), d;
}
function h(o, l) {
return Object.keys(o).filter((i) => o[i] != null).reduce((i, a) => {
if (l.has(a)) {
const n = l.get(a);
if (typeof n == "string")
i[n] = o[a];
else {
const m = n(a, o[a], o);
Object.assign(i, m);
}
} else
i[a] = o[a];
return i;
}, {});
}
function D(o, l, d = /* @__PURE__ */ new Map()) {
const i = g(o, l);
return h(i, d);
}
function s(o) {
var d;
const l = o.type;
if (l) {
const i = e[l];
if (!i)
return o;
const a = g(o, i), n = ((d = o.editor) == null ? void 0 : d.type) || "";
if (n) {
const m = e[n], S = g(o.editor, m);
a.editor = S;
}
return a;
}
return o;
}
function u(o) {
r = o;
}
return { getSchemaByType: T, resolveSchemaWithDefaultValue: s, resolveSchemaToProps: D, mappingSchemaToProps: h, setDesignerContext: u };
}
const K = {}, I = {}, { getSchemaByType: Tt, resolveSchemaWithDefaultValue: ye, resolveSchemaToProps: he, mappingSchemaToProps: Se, setDesignerContext: Ft } = Z(K, I);
function Te(e = {}) {
function t(s, u, o, l) {
if (typeof o == "number")
return l[s].length === o;
if (typeof o == "object") {
const d = Object.keys(o)[0], i = o[d];
if (d === "not")
return Number(l[s].length) !== Number(i);
if (d === "moreThan")
return Number(l[s].length) >= Number(i);
if (d === "lessThan")
return Number(l[s].length) <= Number(i);
}
return !1;
}
function r(s, u, o, l) {
return l[s] && l[s].propertyValue && String(l[s].propertyValue.value) === String(o);
}
const c = /* @__PURE__ */ new Map([
["length", t],
["getProperty", r]
]);
Object.keys(e).reduce((s, u) => (s.set(u, e[u]), s), c);
function y(s, u) {
const o = s;
return typeof u == "number" ? [{ target: o, operator: "length", param: null, value: Number(u) }] : typeof u == "boolean" ? [{ target: o, operator: "getProperty", param: s, value: !!u }] : typeof u == "object" ? Object.keys(u).map((l) => {
if (l === "length")
return { target: o, operator: "length", param: null, value: u[l] };
const d = l, i = u[l];
return { target: o, operator: "getProperty", param: d, value: i };
}) : [];
}
function T(s) {
return Object.keys(s).reduce((o, l) => {
const d = y(l, s[l]);
return o.push(...d), o;
}, []);
}
function g(s, u) {
if (c.has(s.operator)) {
const o = c.get(s.operator);
return o && o(s.target, s.param, s.value, u) || !1;
}
return !1;
}
function h(s, u) {
return T(s).reduce((d, i) => d && g(i, u), !0);
}
function D(s, u) {
const o = Object.keys(s), l = o.includes("allOf"), d = o.includes("anyOf"), i = l || d, m = (i ? s[i ? l ? "allOf" : "anyOf" : "allOf"] : [s]).map((w) => h(w, u));
return l ? !m.includes(!1) : m.includes(!0);
}
return { parseValueSchema: D };
}
const Fe = {
convertTo: (e, t, r, c) => {
e.appearance || (e.appearance = {}), e.appearance[t] = r;
},
convertFrom: (e, t, r) => e.appearance ? e.appearance[t] : e[t]
}, De = {
convertFrom: (e, t, r) => e.buttons && e.buttons.length ? `共 ${e.buttons.length} 项` : "无"
}, Me = {
convertTo: (e, t, r, c) => {
e.editor && (e.editor[t] = r);
},
convertFrom: (e, t, r) => e.editor && Object.prototype.hasOwnProperty.call(e.editor, t) ? e.editor[t] : e[t]
}, ee = {
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: "多语输入框" }
}, Oe = {
convertFrom: (e, t, r) => {
var y;
const c = e.editor && e.editor[t] ? e.editor[t] : e[t];
return ((y = ee[c]) == null ? void 0 : y.name) || c;
}
}, Pe = {
convertTo: (e, t, r, c) => {
e[t] = e[t];
},
convertFrom: (e, t, r) => e.editor ? r.getRealEditorType(e.editor.type) : ""
}, we = {
convertTo: (e, t, r, c) => {
(e.type === "data-grid-column" || e.type === "tree-grid-column") && (e.formatter ? e.formatter[t] = r : e.formatter = {
[t]: r
});
},
convertFrom: (e, t, r) => {
if (e.formatter) {
if (t === "trueText")
return e.formatter.trueText;
if (t === "falseText")
return e.formatter.falseText;
if (t === "prefix")
return e.formatter.prefix;
if (t === "suffix")
return e.formatter.suffix;
if (t === "precision")
return e.formatter.precision;
if (t === "decimal")
return e.formatter.decimal;
if (t === "thousand")
return e.formatter.thousand;
if (t === "tempDateFormat")
return e.formatter.dateFormat === "yyyy年MM月dd日" ? "yearMonthDay" : e.formatter.dateFormat === "yyyy-MM-dd HH:mm:ss" ? "yyyy-MM-ddTHH:mm:ss" : e.formatter.dateFormat === "yyyy/MM/dd HH:mm:ss" ? "yyyy/MM/ddTHH:mm:ss" : e.formatter.dateFormat === "yyyy年MM月dd日 HH时mm分ss秒" ? "yearMonthDayHourMinuteSecond" : e.formatter.tempDateFormat || e.formatter.dateFormat || "yyyy-MM-dd";
if (t === "customFormat")
return e.formatter.customFormat;
if (t === "type")
return e.formatter.type || "none";
}
return "none";
}
}, Ne = {
convertTo: (e, t, r, c) => {
e.command ? e.command[t] = r : e.command = {
[t]: r
}, t === "enable" && r && (e.command.commands || (e.command.commands = [
{
text: "编辑",
type: "primary",
command: "edit"
},
{
text: "删除",
type: "danger",
command: "remove"
}
]));
},
convertFrom: (e, t, r) => e.command && t === "enable" ? e.command.enable : ""
}, je = {
convertTo: (e, t, r, c) => {
e.column ? e.column[t] = r : e.column = {
[t]: r
}, t === "fitColumns" && r && (e.column.fitMode || (e.column.fitMode = "average"));
},
convertFrom: (e, t, r) => {
if (e.column) {
if (t === "fitColumns")
return e.column.fitColumns;
if (t === "fitMode")
return e.column.fitMode;
}
return "";
}
}, Ee = {
convertTo: (e, t, r, c) => {
e.summary ? e.summary[t] = r : e.summary = {
[t]: r
}, t === "enable" && r && (e.summary ? e.summary.groupFields || (e.summary.groupFields = []) : e.summary = {
enable: r,
groupFields: []
});
},
convertFrom: (e, t, r) => e.summary && t === "enable" ? e.summary.enable : e.type === "data-grid-column" ? e.enableSummary === void 0 ? !1 : e.enableSummary : ""
}, ke = {
convertTo: (e, t, r, c) => {
e.group ? e.group[t] = r : e.group = {
[t]: r
}, t === "enable" && r && (e.group ? e.group.groupFields || (e.group.groupFields = []) : e.group = {
enable: r,
groupFields: [],
showSummary: !1
});
},
convertFrom: (e, t, r) => {
if (e.group) {
if (t === "enable")
return e.group.enable;
if (t === "showSummary")
return e.group.showSummary;
}
}
}, $e = {
convertFrom: (e, t) => e.binding ? e.binding.path : "",
convertTo: (e, t, r) => {
if (r && r.length > 0) {
const c = r[0];
e.binding || (e.binding = {}), e.binding.type = "Form", e.binding.path = c.bindingField, e.binding.field = c.id, e.binding.fullPath = c.path, e.path = c.bindingPath;
}
}
}, Be = {
convertTo: (e, t, r, c) => {
e.pagination || (e.pagination = {}), e.pagination[t] = r;
},
convertFrom: (e, t, r) => e.pagination ? e.pagination[t] : e[t]
}, Re = {
convertTo: (e, t, r, c) => {
e.rowNumber || (e.rowNumber = {}), e.rowNumber[t] = r;
},
convertFrom: (e, t, r) => e.rowNumber ? e.rowNumber[t] : e[t]
}, xe = {
convertTo: (e, t, r, c) => {
e.selection || (e.selection = {}), e.selection[t] = r;
},
convertFrom: (e, t, r) => e.selection ? e.selection[t] : e[t]
}, Ae = {
convertFrom: (e, t, r) => e[t] && e[t].length ? `共 ${e[t].length} 项` : ""
}, He = {
convertFrom: (e, t) => e[t] || "",
convertTo: (e, t, r) => {
e[t] = r;
}
}, ze = {
convertTo: (e, t, r, c) => {
e.size || (e.size = {}), e.size[t] = r;
},
convertFrom: (e, t, r) => e.size ? e.size[t] : e[t]
}, qe = {
convertFrom: (e, t, r) => {
var c, y;
return (c = e.formatter) != null && c.data && t === "formatterEnumData" && !e.formatterEnumData ? (y = e.formatter) == null ? void 0 : y.data : e.formatterEnumData;
}
}, Le = {
convertTo: (e, t, r, c) => {
e.sort || (e.sort = {}), e.sort[t] = r;
},
convertFrom: (e, t, r) => {
var c, y;
if (t === "mode")
return ((c = e.sort) == null ? void 0 : c.mode) || "client";
if (t === "multiSort")
return !!((y = e.sort) != null && y.multiSort);
}
}, We = {
convertTo: (e, t, r, c) => {
e.filter || (e.filter = {}), e.filter[t] = r;
},
convertFrom: (e, t, r) => {
var c;
if (t === "mode")
return ((c = e.filter) == null ? void 0 : c.mode) || "client";
}
}, Ce = {
convertTo: (e, t, r, c) => {
e.rowOption ? e.rowOption[t] = r : e.rowOption = {
[t]: r
};
},
convertFrom: (e, t, r) => {
if (e.rowOption) {
if (t === "customRowStyle")
return e.rowOption.customRowStyle;
if (t === "customCellStyle")
return e.rowOption.customCellStyle;
}
return "";
}
};
function te(e, t, r) {
const c = /* @__PURE__ */ new Map([
["/converter/appearance.converter", Fe],
["/converter/buttons.converter", De],
["/converter/property-editor.converter", Me],
["/converter/items-count.converter", Ae],
["/converter/type.converter", Oe],
["/converter/change-editor.converter", Pe],
["/converter/change-formatter.converter", we],
["/converter/column-command.converter", Ne],
["/converter/column-option.converter", je],
["/converter/summary.converter", Ee],
["/converter/group.converter", ke],
["/converter/form-group-label.converter", He],
["/converter/field-selector.converter", $e],
["/converter/pagination.converter", Be],
["/converter/row-number.converter", Re],
["/converter/grid-selection.converter", xe],
["/converter/size.converter", ze],
["/converter/change-formatter-enum.converter", qe],
["/converter/grid-sort.converter", Le],
["/converter/grid-filter.converter", We],
["/converter/row-option.converter", Ce]
]), y = /* @__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 }]
]), T = Te();
function g(i, a) {
return () => T.parseValueSchema(i, a);
}
function h(i, a, n) {
return i.includes("visible") && a.visible !== void 0 ? typeof a.visible == "boolean" ? () => !!a.visible : a.visible === void 0 ? !0 : g(a.visible, n) : () => !0;
}
function D(i, a, n) {
return i.includes("readonly") && a.readonly !== void 0 ? typeof a.readonly == "boolean" ? () => !!a.readonly : g(a.readonly, n) : () => !1;
}
function s(i, a) {
const n = i.$converter || a;
return typeof n == "string" && n && c.has(n) ? c.get(n) || null : n || null;
}
function u(i, a, n, m, S, w = "", j = "") {
return Object.keys(i).map((M) => {
const B = P(1), R = M, p = i[M], k = Object.keys(p), H = p.title, f = p.type, b = y.get(f) || { type: "input-group", enableClear: !1 }, v = p.editor ? Object.assign({}, b, p.editor) : Object.assign({}, b), F = h(k, p, a), O = D(k, p, a);
v.readonly = v.readonly === void 0 ? O() : v.readonly;
const $ = p.type === "cascade" ? u(p.properties, a, n, m, S, w, j) : [], z = !0;
let N = s(p, j);
const x = q({
get() {
if (B.value) {
if (["class", "style"].find((fe) => fe === R) && !N && (N = c.get("/converter/appearance.converter") || null), N && N.convertFrom)
return N.convertFrom(n, M, S, w);
const A = n[M];
return Object.prototype.hasOwnProperty.call(p, "defaultValue") && (A === void 0 || typeof A == "string" && A === "") ? p.type === "boolean" ? p.defaultValue : p.defaultValue || "" : A;
}
return null;
},
set(A) {
B.value += 1, N && N.convertTo ? (N.convertTo(m, M, A, S, w), N.convertTo(n, M, A, S, w)) : (m[M] = A, n[M] = A);
}
}), { refreshPanelAfterChanged: L, description: se, isExpand: le, parentPropertyID: ue } = p, U = { propertyID: R, propertyName: H, propertyType: f, propertyValue: x, editor: v, visible: F, readonly: O, cascadeConfig: $, hideCascadeTitle: z, refreshPanelAfterChanged: L, description: se, isExpand: le, parentPropertyID: ue };
return a[R] = U, U;
});
}
function o(i, a, n = {}) {
const m = {}, S = e[i];
return S && S.categories ? Object.keys(S.categories).map((j) => {
const E = S.categories[j], M = E == null ? void 0 : E.title, B = u(E.properties || {}, m, {}, n, a);
return { categoryId: j, categoryName: M, properties: B };
}) : [];
}
function l(i, a, n, m, S = "") {
const w = a.$ref.schema, j = a.$ref.converter, E = n[w], M = E.type, B = r(E), R = {}, p = e[M];
if (p && p.categories) {
const k = p.categories[i], H = k == null ? void 0 : k.title;
j && Object.keys(k.properties).forEach((v) => {
k.properties[v].$converter = j;
});
const f = (k == null ? void 0 : k.properties) || {}, b = u(f, R, B, E, m, S);
return { categoryId: i, categoryName: H, properties: b };
}
return { categoryId: i, categoryName: "", properties: [] };
}
function d(i, a, n, m, S) {
const w = i.type, j = r(i), E = {};
let M = S || e[w];
if (M && Object.keys(M).length === 0 && n && n.getPropConfig && (M = n.getPropConfig(m)), M && M.categories) {
const B = [];
return Object.keys(M.categories).map((R) => {
const p = M.categories[R];
if (p.$ref) {
B.push(l(R, p, i, a, m));
return;
}
const k = p == null ? void 0 : p.title, H = p == null ? void 0 : p.tabId, f = p == null ? void 0 : p.tabName, b = p == null ? void 0 : p.hide, v = p == null ? void 0 : p.hideTitle, F = u(p.properties || {}, E, j, i, a, m, p.$converter), { setPropertyRelates: O } = p, $ = p == null ? void 0 : p.parentPropertyID;
B.push({ categoryId: R, categoryName: k, tabId: H, tabName: f, hide: b, properties: F, hideTitle: v, setPropertyRelates: O, parentPropertyID: $ });
}), B;
}
return [];
}
return {
getPropertyConfigBySchema: d,
getPropertyConfigByType: o,
propertyConverterMap: c
};
}
const re = {}, ne = {};
te(re, ne, ye);
const oe = {}, ie = {}, { getSchemaByType: Dt, resolveSchemaWithDefaultValue: Ue, resolveSchemaToProps: Mt, mappingSchemaToProps: Ot, setDesignerContext: Pt } = Z(oe, ie), ae = {}, ce = {};
te(ae, ce, Ue);
function Ye(e, t, r = /* @__PURE__ */ new Map(), c = (g, h, D, s) => h, y = {}, T = (g) => g) {
return K[t.title] = t, I[t.title] = c, re[t.title] = y, ne[t.title] = T, oe[t.title] = t, ie[t.title] = c, ae[t.title] = y, ce[t.title] = T, (g = {}, h = !0) => {
if (!h)
return Se(g, r);
const D = he(g, t, r), s = Object.keys(e).reduce((u, o) => (u[o] = e[o].default, u), {});
return Object.assign(s, D);
};
}
function _e(e, t) {
return { customClass: t.class, customStyle: t.style };
}
const Ve = /* @__PURE__ */ new Map([
["appearance", _e]
]);
function Ge(e, t, r) {
return t;
}
const Je = "text", Qe = "A Farris Component", Xe = "object", Ze = {
basic: {
description: "Basic Infomation",
title: "基本信息",
properties: {
id: {
description: "组件标识",
title: "标识",
type: "string",
readonly: !0
},
type: {
description: "组件类型",
title: "控件类型",
type: "select",
editor: {
type: "waiting for modification",
enum: []
}
}
}
}
}, Ke = {
title: Je,
description: Qe,
type: Xe,
categories: Ze
}, Ie = "https://json-schema.org/draft/2020-12/schema", et = "https://farris-design.gitee.io/text.schema.json", tt = "text", rt = "A Farris Component", nt = "object", ot = {
id: {
description: "The unique identifier for text",
type: "string"
},
type: {
description: "The type string of text",
type: "string",
default: "text"
},
appearance: {
description: "",
type: "object",
properties: {
class: {
type: "string"
},
style: {
type: "string"
}
},
default: {}
},
binding: {
description: "",
type: "object",
default: {}
},
disable: {
type: "string",
default: !1
},
editable: {
description: "",
type: "boolean",
default: !0
},
placeholder: {
description: "",
type: "string",
default: ""
},
readonly: {
description: "",
type: "boolean",
default: !1
},
require: {
description: "",
type: "boolean",
default: !1
},
tabindex: {
description: "",
type: "number",
default: -1
},
visible: {
description: "",
type: "boolean",
default: !0
}
}, it = [
"id",
"type"
], at = {
$schema: Ie,
$id: et,
title: tt,
description: rt,
type: nt,
properties: ot,
required: it
}, C = {
// 组件值
modelValue: { type: [String, Number, Boolean], default: "" },
// 是否是密码
password: { type: Boolean, default: !1 },
// 是否多行文本
textarea: { type: Boolean, default: !1 },
// 是否自动尺寸
autoSize: { type: Boolean, default: !1 },
// 是否是日期范围
dateRange: { type: Boolean, default: !1 },
// 最大高度
maxHeight: { type: Number, default: 0 },
// 指定高度
height: { type: Number, default: 0 },
// 控件类型
type: { type: String, default: "string" },
// 格式化
format: { type: String, default: "" },
// 转换类型用到的数据
enumConvertedDatas: { default: void 0 },
// 千分位符号
groupSeparator: { type: String, default: "," },
// 小数点处符号
decimalSeparator: { type: String, default: "." },
// 十进制补位符
decimalFilledSymbol: { type: String, default: "0" },
// 数字参数
numberOptions: { type: Object, default: void 0 },
// 金额表达式
amountExpression: { type: String, default: "%s%v" },
// 文本字段
textField: { type: String, default: "name" },
// 值字段
valueField: { type: String, default: "value" },
// 文本方向
textAlign: { type: String, default: "" },
// 日期范围模式下input的显示分割符合
dateRangeDelimiter: { type: String, default: "~" },
// 枚举项的分隔符
enumDelimiter: { type: String, default: "," }
}, V = Ye(C, at, Ve, Ge, Ke);
function ct(e) {
let t;
return /Y/g.test(e) === !0 ? t = e.replace(/Y/g, "y") : t = e, /D/g.test(t) === !0 && (t = t.replace(/D/g, "d")), t;
}
function st(e, t, r, c, y) {
if (e == null || e === "")
return "";
if (t && t.length) {
const T = ("" + e).split(r), g = [];
for (let h = 0; h < T.length; h++) {
const D = t.find((s) => s[y] === T[h]);
D ? g.push(D[c]) : g.push(T[h]);
}
return g.length > 0 ? g.join(r) : "";
}
return e;
}
function G(e, t) {
let r;
return t || (t = "YYYY-MM-DD"), t === "timeago" ? de().formatTo(e) : (t === "hh:mm:ss" || t === "HH:mm:ss" ? r = e : r = ve().formatTo(e, ct(t)), r);
}
function lt(e, t) {
return !e && !t || t && t.type && t.type === "number" && (t.formatter || (t.useThousands ? t.precision !== void 0 ? e = "n" + t.precision : e = "n2" : t.precision !== void 0 ? e = "f" + t.precision : e = "f2")), e;
}
function ut(e) {
return e.replace(/[a-z]+/g, (t) => t.toUpperCase());
}
function ft(e, t, r) {
return e.toString().indexOf(".") > -1 ? (console.warn("十进制转换仅限整型类型"), "") : (Array(t).join(r) + e).slice(-t);
}
function pt(e, t) {
return Number(e * 100).toFixed(Number(t)) + "%";
}
function mt(e, t, r, c, y, T, g) {
if (!t && !r)
return e.toString();
if (r && r.type && r.type === "number" && r.formatter)
return r.formatter(e);
const h = ut(t.substring(0, 1)), D = Number(t.substring(1)), s = {};
let u;
if (!/C|D|F|N|P/g.test(h))
return;
c && Object.assign(s, { groupSeparator: c }), y && Object.assign(s, { decimalSeparator: y }), T && Object.assign(s, { format: T });
const { formatTo: o } = ge();
switch (h) {
case "C":
Object.assign(s, { prefix: "¥", precision: D }), u = o(e, s);
break;
case "D":
u = ft(e, D, g);
break;
case "F":
Object.assign(s, { prefix: "", groupSeparator: "", precision: D }), u = o(e, s);
break;
case "N":
Object.assign(s, { prefix: "", precision: D }), u = o(e, s);
break;
case "P":
u = pt(e, D);
break;
}
return u;
}
function dt(e) {
return e === !0 ? "是" : e === !1 || e == null || e === "" || typeof e > "u" ? "否" : e;
}
const W = /* @__PURE__ */ J({
name: "FText",
props: C,
emits: ["update:modelValue", "valueChange"],
setup(e, t) {
const r = P(e.textarea), c = P(e.password), y = P(e.autoSize), T = P(e.dateRange), g = P(e.type), h = P(e.format), D = P(), s = P(), u = P(""), o = q(() => ({
"f-form-control-text": !r.value,
"f-form-context-textarea": r,
"f-component-text-auto-size": y.value
})), l = q(() => ({
"text-align": e.textAlign,
height: !y.value && e.height > 0 ? `${e.height}px` : "",
"min-height": y.value && e.height > 0 ? `${e.height}px` : "",
"max-height": y.value && e.maxHeight > 0 ? `${e.maxHeight}px` : ""
}));
Q(() => {
if (r.value) {
const n = s.value.parentElement.className;
s.value.parentElement.className = n + " f-cmp-text-is-textarea";
}
});
function d(n) {
if (c.value)
return n ? "******" : "";
if (g.value !== "boolean" && (n == null || typeof n > "u"))
return "";
let m = "";
switch (g.value) {
case "string":
m = n;
break;
case "date":
case "datetime":
if (!T.value)
m = G(n, h.value);
else {
const S = e.dateRangeDelimiter, w = n.split(S), j = [];
w && w.length && w.forEach((E) => {
j.push(G(E, h.value));
}), m = j.join(S);
}
break;
case "number":
h.value = lt(h.value, e.numberOptions), m = mt(n, h.value, e.numberOptions, e.groupSeparator, e.decimalSeparator, e.amountExpression, e.decimalFilledSymbol);
break;
case "enum":
m = st(n, e.enumConvertedDatas, e.enumDelimiter, e.textField, e.valueField);
break;
case "boolean":
m = dt(n);
break;
}
return m;
}
const i = q(() => {
const n = d(e.modelValue);
return D.value !== n && (t.emit("valueChange", n), D.value = n), n;
});
function a() {
const n = s.value;
Math.abs(n.scrollWidth - n.clientWidth) > 2 || Math.abs(n.scrollHeight - n.clientHeight) > 2 ? u.value = i.value : u.value = "";
}
return pe(() => e.modelValue, (n, m) => {
n !== m && t.emit("update:modelValue", n);
}), () => X("span", {
class: o.value,
style: l.value,
ref: s,
onMouseenter: () => a(),
title: u.value
}, [i.value]);
}
});
function vt(e, t, r) {
var H;
const c = "", y = "", T = P();
let g;
function h() {
return (t == null ? void 0 : t.schema.componentType) !== "frame";
}
function D() {
return !1;
}
function s() {
return (t == null ? void 0 : t.schema.componentType) !== "frame";
}
function u() {
return (t == null ? void 0 : t.schema.componentType) === "frame";
}
function o(f) {
if (!f || !f.value)
return null;
if (f.value.schema && f.value.schema.type === "component")
return f.value;
const b = P(f == null ? void 0 : f.value.parent), v = o(b);
return v || null;
}
function l(f = t) {
var O;
const { componentInstance: b, designerItemElementRef: v } = f;
if (!b || !b.value)
return null;
const { getCustomButtons: F } = b.value;
return b.value.canMove || F && ((O = F()) != null && O.length) ? v : l(f.parent);
}
function d(f) {
return !!r;
}
function i() {
return (t == null ? void 0 : t.schema.label) || (t == null ? void 0 : t.schema.title) || (t == null ? void 0 : t.schema.name);
}
function a() {
}
function n(f, b) {
var v;
!f || !b || (v = t == null ? void 0 : t.setupContext) == null || v.emit("dragEnd");
}
function m(f, b) {
const { componentType: v } = f;
let F = be(v, f, b);
const O = v.toLowerCase().replace(/-/g, "_");
return F && !F.id && F.type === v && (F.id = `${O}_${Math.random().toString().slice(2, 6)}`), F;
}
function S(f) {
}
function w(...f) {
}
function j(f) {
if (!f)
return;
const b = t == null ? void 0 : t.schema, { formSchemaUtils: v } = f;
if (b && v.getExpressions().length) {
const F = v.getExpressions().findIndex((O) => O.target === b.id);
F > -1 && v.getExpressions().splice(F, 1);
}
}
function E(f) {
if (!f || !(t != null && t.schema))
return;
const b = t.schema, { formSchemaUtils: v } = f;
v.removeCommunicationInComponent(b);
}
function M(f) {
j(f), E(f), t != null && t.schema.contents && t.schema.contents.map((b) => {
let v = b.id;
b.type === "component-ref" && (v = b.component);
const F = e.value.querySelectorAll(`#${v}-design-item`);
F != null && F.length && Array.from(F).map((O) => {
var $;
($ = O == null ? void 0 : O.componentInstance) != null && $.value.onRemoveComponent && O.componentInstance.value.onRemoveComponent(f);
});
});
}
function B() {
}
function R(f) {
var v, F;
if (!((v = t == null ? void 0 : t.schema) != null && v.id))
return;
!g && f && (g = f.formSchemaUtils);
let b = "";
{
const { text: O, title: $, label: z, mainTitle: N, name: x, type: L } = t.schema;
b = O || $ || z || N || x || ((F = ee[L]) == null ? void 0 : F.name);
}
b && g.getControlBasicInfoMap().set(t.schema.id, {
componentTitle: b,
parentPathName: b
});
}
function p(f) {
var O;
const { changeObject: b } = f, { propertyID: v, propertyValue: F } = b;
if (["text", "title", "label", "name", "mainTitle"].includes((O = f == null ? void 0 : f.changeObject) == null ? void 0 : O.propertyID) && v && F && (R(), g)) {
const $ = g.getControlBasicInfoMap(), z = $.keys().toArray().filter((N) => {
var x, L;
return ((x = $.get(N)) == null ? void 0 : x.reliedComponentId) === ((L = t == null ? void 0 : t.schema) == null ? void 0 : L.id);
});
z != null && z.length && z.forEach((N) => {
const x = $.get(N).parentPathName.split(" > ");
x[0] = F, $.get(N).parentPathName = x.join(" > ");
});
}
}
function k(f) {
p(f);
}
return T.value = {
canMove: h(),
canSelectParent: D(),
canDelete: s(),
canNested: !u(),
contents: t == null ? void 0 : t.schema.contents,
elementRef: e,
parent: (H = t == null ? void 0 : t.parent) == null ? void 0 : H.componentInstance,
schema: t == null ? void 0 : t.schema,
styles: c,
designerClass: y,
canAccepts: d,
getBelongedComponentInstance: o,
getDraggableDesignItemElement: l,
getDraggingDisplayText: i,
getPropConfig: w,
getDragScopeElement: a,
onAcceptMovedChildElement: n,
onChildElementMovedOut: S,
addNewChildComponentSchema: m,
triggerBelongedComponentToMoveWhenMoved: P(!1),
triggerBelongedComponentToDeleteWhenDeleted: P(!1),
onRemoveComponent: M,
getCustomButtons: B,
onPropertyChanged: k,
setComponentBasicInfoMap: R,
updateContextSchema: t == null ? void 0 : t.updateContextSchema
}, T;
}
const gt = /* @__PURE__ */ J({
name: "FTextDesign",
props: C,
emits: ["update:modelValue"],
setup(e, t) {
const r = P(!0), c = P(!0), y = P(""), T = P(0), g = P(0), h = P(e.modelValue), D = q(() => ({
"f-form-control-text": !r.value,
"f-form-context-textarea": r,
"f-component-text-auto-size": c.value
})), s = q(() => ({
textalign: y.value,
height: !c.value && T.value > 0 ? `${T.value}px` : "",
"min-height": !c.value && T.value > 0 ? `${T.value}px` : "",
"max-height": !c.value && g.value > 0 ? `${g.value}px` : ""
}));
q(() => "");
const u = P(), o = me("design-item-context"), l = vt(u, o);
return Q(() => {
u.value.componentInstance = l;
}), t.expose(l.value), () => X("span", {
ref: u,
class: D.value,
style: s.value
}, [h.value]);
}
}), wt = {
install(e) {
e.component(W.name, W);
},
register(e, t, r, c) {
e.text = W, t.text = V;
},
registerDesigner(e, t, r) {
e.text = gt, t.text = V;
}
};
export {
W as FText,
wt as default,
V as propsResolver,
C as textProps
};