@farris/ui-vue
Version:
Farris Vue, a Farris Design based Vue3 component library.
1,150 lines (1,149 loc) • 35.8 kB
JavaScript
import { ref as T, computed as B, createVNode as S, withDirectives as ue, vModelText as ce, watch as z, mergeProps as pe, defineComponent as de } from "vue";
import { cloneDeep as D, isPlainObject as q } from "lodash-es";
import { FComboList as A } from "../combo-list/index.esm.js";
import { FNumberSpinner as fe } from "../number-spinner/index.esm.js";
import { useGuid as me, withInstall as ve } from "../common/index.esm.js";
import { FExpressionTextbox as ye } from "../expression-editor/index.esm.js";
function _(e, t) {
let r;
function s(a) {
const { properties: u, title: f, ignore: o } = a, n = o && Array.isArray(o), l = Object.keys(u).reduce((m, b) => ((!n || !o.find((V) => V === b)) && (m[b] = u[b].type === "object" && u[b].properties ? s(u[b]) : D(u[b].default)), m), {});
if (f && (!n || !o.find((m) => m === "id"))) {
const m = f.toLowerCase().replace(/-/g, "_");
l.id = `${m}_${Math.random().toString().slice(2, 6)}`;
}
return l;
}
function y(a) {
const { properties: u, title: f, required: o } = a;
if (o && Array.isArray(o)) {
const n = o.reduce((l, m) => (l[m] = u[m].type === "object" && u[m].properties ? s(u[m]) : D(u[m].default), l), {});
if (f && o.find((l) => l === "id")) {
const l = f.toLowerCase().replace(/-/g, "_");
n.id = `${l}_${Math.random().toString().slice(2, 6)}`;
}
return n;
}
return {
type: f
};
}
function C(a, u = {}, f) {
const o = e[a];
if (o) {
let n = y(o);
const l = t[a];
return n = l ? l({ getSchemaByType: C }, n, u, f) : n, r != null && r.appendIdentifyForNewControl && r.appendIdentifyForNewControl(n), n;
}
return null;
}
function c(a, u) {
const f = s(u);
return Object.keys(f).reduce((o, n) => (Object.prototype.hasOwnProperty.call(a, n) && (o[n] && q(o[n]) && q(a[n] || !a[n]) ? Object.assign(o[n], a[n] || {}) : o[n] = a[n]), o), f), f;
}
function d(a, u) {
return Object.keys(a).filter((o) => a[o] != null).reduce((o, n) => {
if (u.has(n)) {
const l = u.get(n);
if (typeof l == "string")
o[l] = a[n];
else {
const m = l(n, a[n], a);
Object.assign(o, m);
}
} else
o[n] = a[n];
return o;
}, {});
}
function p(a, u, f = /* @__PURE__ */ new Map()) {
const o = c(a, u);
return d(o, f);
}
function i(a) {
var f;
const u = a.type;
if (u) {
const o = e[u];
if (!o)
return a;
const n = c(a, o), l = ((f = a.editor) == null ? void 0 : f.type) || "";
if (l) {
const m = e[l], b = c(a.editor, m);
n.editor = b;
}
return n;
}
return a;
}
function v(a) {
r = a;
}
return { getSchemaByType: C, resolveSchemaWithDefaultValue: i, resolveSchemaToProps: p, mappingSchemaToProps: d, setDesignerContext: v };
}
const G = {}, W = {}, { getSchemaByType: Nt, resolveSchemaWithDefaultValue: ge, resolveSchemaToProps: be, mappingSchemaToProps: Ce, setDesignerContext: jt } = _(G, W);
function he(e = {}) {
function t(i, v, a, u) {
if (typeof a == "number")
return u[i].length === a;
if (typeof a == "object") {
const f = Object.keys(a)[0], o = a[f];
if (f === "not")
return Number(u[i].length) !== Number(o);
if (f === "moreThan")
return Number(u[i].length) >= Number(o);
if (f === "lessThan")
return Number(u[i].length) <= Number(o);
}
return !1;
}
function r(i, v, a, u) {
return u[i] && u[i].propertyValue && String(u[i].propertyValue.value) === String(a);
}
const s = /* @__PURE__ */ new Map([
["length", t],
["getProperty", r]
]);
Object.keys(e).reduce((i, v) => (i.set(v, e[v]), i), s);
function y(i, v) {
const a = i;
return typeof v == "number" ? [{ target: a, operator: "length", param: null, value: Number(v) }] : typeof v == "boolean" ? [{ target: a, operator: "getProperty", param: i, value: !!v }] : typeof v == "object" ? Object.keys(v).map((u) => {
if (u === "length")
return { target: a, operator: "length", param: null, value: v[u] };
const f = u, o = v[u];
return { target: a, operator: "getProperty", param: f, value: o };
}) : [];
}
function C(i) {
return Object.keys(i).reduce((a, u) => {
const f = y(u, i[u]);
return a.push(...f), a;
}, []);
}
function c(i, v) {
if (s.has(i.operator)) {
const a = s.get(i.operator);
return a && a(i.target, i.param, i.value, v) || !1;
}
return !1;
}
function d(i, v) {
return C(i).reduce((f, o) => f && c(o, v), !0);
}
function p(i, v) {
const a = Object.keys(i), u = a.includes("allOf"), f = a.includes("anyOf"), o = u || f, m = (o ? i[o ? u ? "allOf" : "anyOf" : "allOf"] : [i]).map((V) => d(V, v));
return u ? !m.includes(!1) : m.includes(!0);
}
return { parseValueSchema: p };
}
const Te = {
convertTo: (e, t, r, s) => {
e.appearance || (e.appearance = {}), e.appearance[t] = r;
},
convertFrom: (e, t, r) => e.appearance ? e.appearance[t] : e[t]
}, Pe = {
convertFrom: (e, t, r) => e.buttons && e.buttons.length ? `共 ${e.buttons.length} 项` : "无"
}, Ve = {
convertTo: (e, t, r, s) => {
e.editor && (e.editor[t] = r);
},
convertFrom: (e, t, r) => e.editor && Object.prototype.hasOwnProperty.call(e.editor, t) ? e.editor[t] : e[t]
}, Se = {
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: "多语输入框" }
}, xe = {
convertFrom: (e, t, r) => {
var y;
const s = e.editor && e.editor[t] ? e.editor[t] : e[t];
return ((y = Se[s]) == null ? void 0 : y.name) || s;
}
}, we = {
convertTo: (e, t, r, s) => {
e[t] = e[t];
},
convertFrom: (e, t, r) => e.editor ? r.getRealEditorType(e.editor.type) : ""
}, Me = {
convertTo: (e, t, r, s) => {
(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";
}
}, Fe = {
convertTo: (e, t, r, s) => {
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 : ""
}, Oe = {
convertTo: (e, t, r, s) => {
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, s) => {
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 : ""
}, Ne = {
convertTo: (e, t, r, s) => {
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;
}
}
}, je = {
convertFrom: (e, t) => e.binding ? e.binding.path : "",
convertTo: (e, t, r) => {
if (r && r.length > 0) {
const s = r[0];
e.binding || (e.binding = {}), e.binding.type = "Form", e.binding.path = s.bindingField, e.binding.field = s.id, e.binding.fullPath = s.path, e.path = s.bindingPath;
}
}
}, Re = {
convertTo: (e, t, r, s) => {
e.pagination || (e.pagination = {}), e.pagination[t] = r;
},
convertFrom: (e, t, r) => e.pagination ? e.pagination[t] : e[t]
}, $e = {
convertTo: (e, t, r, s) => {
e.rowNumber || (e.rowNumber = {}), e.rowNumber[t] = r;
},
convertFrom: (e, t, r) => e.rowNumber ? e.rowNumber[t] : e[t]
}, ke = {
convertTo: (e, t, r, s) => {
e.selection || (e.selection = {}), e.selection[t] = r;
},
convertFrom: (e, t, r) => e.selection ? e.selection[t] : e[t]
}, De = {
convertFrom: (e, t, r) => e[t] && e[t].length ? `共 ${e[t].length} 项` : ""
}, Be = {
convertFrom: (e, t) => e[t] || "",
convertTo: (e, t, r) => {
e[t] = r;
}
}, Ae = {
convertTo: (e, t, r, s) => {
e.size || (e.size = {}), e.size[t] = r;
},
convertFrom: (e, t, r) => e.size ? e.size[t] : e[t]
}, Le = {
convertFrom: (e, t, r) => {
var s, y;
return (s = e.formatter) != null && s.data && t === "formatterEnumData" && !e.formatterEnumData ? (y = e.formatter) == null ? void 0 : y.data : e.formatterEnumData;
}
}, He = {
convertTo: (e, t, r, s) => {
e.sort || (e.sort = {}), e.sort[t] = r;
},
convertFrom: (e, t, r) => {
var s, y;
if (t === "mode")
return ((s = e.sort) == null ? void 0 : s.mode) || "client";
if (t === "multiSort")
return !!((y = e.sort) != null && y.multiSort);
}
}, Ie = {
convertTo: (e, t, r, s) => {
e.filter || (e.filter = {}), e.filter[t] = r;
},
convertFrom: (e, t, r) => {
var s;
if (t === "mode")
return ((s = e.filter) == null ? void 0 : s.mode) || "client";
}
}, Ue = {
convertTo: (e, t, r, s) => {
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 Y(e, t, r) {
const s = /* @__PURE__ */ new Map([
["/converter/appearance.converter", Te],
["/converter/buttons.converter", Pe],
["/converter/property-editor.converter", Ve],
["/converter/items-count.converter", De],
["/converter/type.converter", xe],
["/converter/change-editor.converter", we],
["/converter/change-formatter.converter", Me],
["/converter/column-command.converter", Fe],
["/converter/column-option.converter", Oe],
["/converter/summary.converter", Ee],
["/converter/group.converter", Ne],
["/converter/form-group-label.converter", Be],
["/converter/field-selector.converter", je],
["/converter/pagination.converter", Re],
["/converter/row-number.converter", $e],
["/converter/grid-selection.converter", ke],
["/converter/size.converter", Ae],
["/converter/change-formatter-enum.converter", Le],
["/converter/grid-sort.converter", He],
["/converter/grid-filter.converter", Ie],
["/converter/row-option.converter", Ue]
]), 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 }]
]), C = he();
function c(o, n) {
return () => C.parseValueSchema(o, n);
}
function d(o, n, l) {
return o.includes("visible") && n.visible !== void 0 ? typeof n.visible == "boolean" ? () => !!n.visible : n.visible === void 0 ? !0 : c(n.visible, l) : () => !0;
}
function p(o, n, l) {
return o.includes("readonly") && n.readonly !== void 0 ? typeof n.readonly == "boolean" ? () => !!n.readonly : c(n.readonly, l) : () => !1;
}
function i(o, n) {
const l = o.$converter || n;
return typeof l == "string" && l && s.has(l) ? s.get(l) || null : l || null;
}
function v(o, n, l, m, b, V = "", h = "") {
return Object.keys(o).map((P) => {
const M = T(1), F = P, g = o[P], w = Object.keys(g), $ = g.title, j = g.type, R = y.get(j) || { type: "input-group", enableClear: !1 }, N = g.editor ? Object.assign({}, R, g.editor) : Object.assign({}, R), L = d(w, g, n), k = p(w, g, n);
N.readonly = N.readonly === void 0 ? k() : N.readonly;
const H = g.type === "cascade" ? v(g.properties, n, l, m, b, V, h) : [], ne = !0;
let O = i(g, h);
const re = B({
get() {
if (M.value) {
if (["class", "style"].find((le) => le === F) && !O && (O = s.get("/converter/appearance.converter") || null), O && O.convertFrom)
return O.convertFrom(l, P, b, V);
const E = l[P];
return Object.prototype.hasOwnProperty.call(g, "defaultValue") && (E === void 0 || typeof E == "string" && E === "") ? g.type === "boolean" ? g.defaultValue : g.defaultValue || "" : E;
}
return null;
},
set(E) {
M.value += 1, O && O.convertTo ? (O.convertTo(m, P, E, b, V), O.convertTo(l, P, E, b, V)) : (m[P] = E, l[P] = E);
}
}), { refreshPanelAfterChanged: oe, description: ie, isExpand: ae, parentPropertyID: se } = g, U = { propertyID: F, propertyName: $, propertyType: j, propertyValue: re, editor: N, visible: L, readonly: k, cascadeConfig: H, hideCascadeTitle: ne, refreshPanelAfterChanged: oe, description: ie, isExpand: ae, parentPropertyID: se };
return n[F] = U, U;
});
}
function a(o, n, l = {}) {
const m = {}, b = e[o];
return b && b.categories ? Object.keys(b.categories).map((h) => {
const x = b.categories[h], P = x == null ? void 0 : x.title, M = v(x.properties || {}, m, {}, l, n);
return { categoryId: h, categoryName: P, properties: M };
}) : [];
}
function u(o, n, l, m, b = "") {
const V = n.$ref.schema, h = n.$ref.converter, x = l[V], P = x.type, M = r(x), F = {}, g = e[P];
if (g && g.categories) {
const w = g.categories[o], $ = w == null ? void 0 : w.title;
h && Object.keys(w.properties).forEach((N) => {
w.properties[N].$converter = h;
});
const j = (w == null ? void 0 : w.properties) || {}, R = v(j, F, M, x, m, b);
return { categoryId: o, categoryName: $, properties: R };
}
return { categoryId: o, categoryName: "", properties: [] };
}
function f(o, n, l, m, b) {
const V = o.type, h = r(o), x = {};
let P = b || e[V];
if (P && Object.keys(P).length === 0 && l && l.getPropConfig && (P = l.getPropConfig(m)), P && P.categories) {
const M = [];
return Object.keys(P.categories).map((F) => {
const g = P.categories[F];
if (g.$ref) {
M.push(u(F, g, o, n, m));
return;
}
const w = g == null ? void 0 : g.title, $ = g == null ? void 0 : g.tabId, j = g == null ? void 0 : g.tabName, R = g == null ? void 0 : g.hide, N = g == null ? void 0 : g.hideTitle, L = v(g.properties || {}, x, h, o, n, m, g.$converter), { setPropertyRelates: k } = g, H = g == null ? void 0 : g.parentPropertyID;
M.push({ categoryId: F, categoryName: w, tabId: $, tabName: j, hide: R, properties: L, hideTitle: N, setPropertyRelates: k, parentPropertyID: H });
}), M;
}
return [];
}
return {
getPropertyConfigBySchema: f,
getPropertyConfigByType: a,
propertyConverterMap: s
};
}
const J = {}, Q = {};
Y(J, Q, ge);
const X = {}, Z = {}, { getSchemaByType: Rt, resolveSchemaWithDefaultValue: qe, resolveSchemaToProps: $t, mappingSchemaToProps: kt, setDesignerContext: Dt } = _(X, Z), K = {}, ee = {};
Y(K, ee, qe);
function ze(e, t, r = /* @__PURE__ */ new Map(), s = (c, d, p, i) => d, y = {}, C = (c) => c) {
return G[t.title] = t, W[t.title] = s, J[t.title] = y, Q[t.title] = C, X[t.title] = t, Z[t.title] = s, K[t.title] = y, ee[t.title] = C, (c = {}, d = !0) => {
if (!d)
return Ce(c, r);
const p = be(c, t, r), i = Object.keys(e).reduce((v, a) => (v[a] = e[a].default, v), {});
return Object.assign(i, p);
};
}
function _e(e, t) {
return { customClass: t.class, customStyle: t.style };
}
const Ge = /* @__PURE__ */ new Map([
["appearance", _e]
]);
function We(e, t, r) {
return t;
}
const Ye = "https://json-schema.org/draft/2020-12/schema", Je = "https://farris-design.gitee.io/property-editor.schema.json", Qe = "property-editor", Xe = "A Farris Component", Ze = "object", Ke = {
id: {
description: "The unique identifier for property-editor",
type: "string"
},
type: {
description: "The type string of property-editor",
type: "string",
default: "property-editor"
},
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
},
propertyTypes: {
description: "",
type: "Array",
default: []
},
constEnums: {
description: "",
type: "Array",
default: []
},
constType: {
description: "",
type: "String",
default: ""
},
variables: {
description: "",
type: "Array",
default: []
},
controlName: {
description: "",
type: "string",
default: ""
},
newVariablePrefix: {
description: "",
type: "string",
default: ""
},
newVariableType: {
description: "",
type: "string",
default: ""
},
stateMachines: {
description: "",
type: "Array",
default: []
},
expressionConfig: {
description: "",
type: "Object",
default: {}
}
}, et = [
"type"
], tt = [
"id"
], nt = {
$schema: Ye,
$id: Je,
title: Qe,
description: Xe,
type: Ze,
properties: Ke,
required: et,
ignore: tt
}, rt = "property-editor", ot = "A Farris Component", it = "object", at = {
basic: {
description: "Basic Infomation",
title: "基本信息",
properties: {
id: {
description: "组件标识",
title: "标识",
type: "string",
readonly: !0
},
type: {
description: "组件类型",
title: "控件类型",
type: "select",
editor: {
type: "waiting for modification",
enum: []
}
}
}
}
}, st = {
title: rt,
description: ot,
type: it,
categories: at
}, lt = {
/** 静态值的类型 */
constType: { type: String, default: "" },
/** 静态值的枚举项(静态值类型为enum时使用) */
constEnums: { type: Array, default: [] }
}, ut = {
variables: { type: Array, default: [] },
controlName: { type: String, default: "" },
/** 新增变量名称的前缀 */
newVariablePrefix: { type: String, default: "" },
/** 新增变量的类型 */
newVariableType: { type: String, default: "" }
}, ct = {
/** 状态机列表 */
stateMachines: { type: Array, default: [] }
}, pt = {}, dt = {
expressionConfig: { type: Object, default: {} }
}, te = {
...lt,
...ut,
...pt,
...ct,
...dt,
id: { Type: String, default: "" },
modelValue: { type: [Number, String, Boolean, Object] },
/** 属性类型列表 */
propertyTypes: { type: Array, default: [] }
}, ft = ze(te, nt, Ge, We, st);
function mt(e, t, r) {
const s = T(!1), y = T(e.constType), C = T(e.constEnums), {
getPropertyValue: c,
triggerValueChange: d
} = r, p = c("Const"), i = B(() => (n) => n === y.value);
function v(n) {
d(n);
}
function a(n) {
v(n);
}
function u(n) {
if (!n || n.length < 1)
return;
const l = n[0].id;
v(l);
}
function f() {
return S(fe, {
nullable: !0,
readonly: s.value,
modelValue: p.value,
"onUpdate:modelValue": (n) => p.value = n,
onChange: a
}, null);
}
function o() {
return S(A, {
key: "const-combo-list",
modelValue: p.value,
"onUpdate:modelValue": (n) => p.value = n,
placeholder: "",
viewType: "text",
enableClear: !1,
valueField: "id",
textField: "name",
data: C.value,
editable: !1,
readonly: s.value,
onChange: u
}, null);
}
return () => S("div", {
class: "f-property-editor-const-container"
}, [i.value("number") && f(), i.value("enum") && o()]);
}
function vt(e, t, r) {
const s = T(e.newVariablePrefix), y = T(e.newVariableType), C = T(e.id), c = T(e.controlName), d = T(e.variables), { getPropertyValue: p } = r;
function i(n) {
return n[0].toUpperCase() + n.slice(1);
}
function v(n) {
return n[0].toLowerCase() + n.slice(1);
}
function a(n) {
return n.replace(/[-_](.)/g, (l, m) => m.toUpperCase());
}
function u() {
const n = s.value ? i(c.value) : v(c.value), l = i(C.value);
let m = `${s.value}${n}${l}`;
m = a(m);
const { guid: b } = me();
return {
type: "Variable",
path: m,
field: b(),
fullPath: m,
isNewVariable: !0,
newVariableType: y.value
};
}
function f(n) {
return d.value.find((m) => m.path === n);
}
function o() {
const n = p("Variable");
return n.value || (n.value = {
type: "Variable",
field: "",
path: "",
fullPath: ""
}), n;
}
return { generateVariable: u, getVariableByPath: f, getVariableValue: o };
}
function yt(e, t, r) {
const s = T(!1), y = T(e.variables), C = T(e.controlName), c = T(!!C.value), {
generateVariable: d,
getVariableByPath: p,
getVariableValue: i
} = vt(e, t, r), {
triggerValueChange: v
} = r, a = i(), u = T(a.value.field), f = B(() => [{
"form-control-select-show": c.value
}, {
"form-control-select-hide": !c.value
}]);
function o(h) {
Object.assign(a.value, {
field: h.field,
path: h.path,
fullPath: h.fullPath,
isNewVariable: h.isNewVariable,
newVariableType: h.isNewVariable && h.newVariableType
}), u.value = a.value.field, v(a.value);
}
function n() {
const h = d(), x = p(h.path);
x ? o(x) : (y.value.push(h), o(h));
}
const l = () => (t.emit("beforeOpenVariables", y), Promise.resolve(!0));
function m(h) {
if (!h || h.length < 1)
return;
const x = h[0], P = {
path: x.path,
fullPath: x.fullPath,
field: x.field,
type: "Variable"
};
o(P);
}
function b() {
return S(A, {
key: "variable-combo-list",
class: f.value,
modelValue: u.value,
"onUpdate:modelValue": (h) => u.value = h,
placeholder: "",
viewType: "text",
enableClear: !1,
valueField: "field",
idField: "field",
textField: "fullPath",
data: y.value,
beforeOpen: l,
readonly: s.value,
editable: !1,
onChange: m
}, null);
}
function V() {
return S("div", {
class: "f-property-editor-variable-add-button"
}, [S("button", {
title: "新增变量",
class: "f-variable-button",
onClick: n
}, [S("span", {
class: "f-icon f-icon-add",
style: "margin:unset;"
}, null)])]);
}
return () => S("div", {
class: "f-property-editor-variable-container"
}, [b(), c.value && V()]);
}
function gt(e, t, r) {
const s = /^(?:(!)?)viewModel\.stateMachine\['([^']+)'\]$/, { getPropertyValue: y } = r;
function C(d) {
if (!(typeof d.value == "string"))
return;
const i = d.value.match(s);
if (!i || i.length < 3)
return;
const a = {
type: "StateMachine",
status: i[1] !== "!",
field: i[2]
};
d.value = a, r.triggerValueChange(a);
}
function c() {
const d = y("StateMachine");
return d.value ? (C(d), d) : (d.value = {
type: "StateMachine",
field: "",
status: !1
}, d);
}
return { getStateMachineValue: c };
}
function bt(e, t, r) {
const s = T(!1), y = T(e.stateMachines), {
getStateMachineValue: C
} = gt(e, t, r), {
triggerValueChange: c
} = r, d = C(), p = T(d.value.field), i = T(d.value.status);
function v() {
i.value = !i.value, d.value.status = i.value, c(d.value);
}
function a(o) {
if (!o || o.length < 1)
return;
const n = o[0];
d.value.field = n.id, c(d.value);
}
function u() {
return S("div", {
class: "f-stateMachine-status",
onClick: v
}, [i.value ? "是" : "非"]);
}
function f() {
return S("div", {
class: "f-stateMachine-combo-list"
}, [S(A, {
key: "state-machine-combo-list",
modelValue: p.value,
"onUpdate:modelValue": (o) => p.value = o,
placeholder: "",
viewType: "text",
enableClear: !1,
valueField: "id",
textField: "name",
data: y.value,
editable: !1,
readonly: s.value,
onChange: a
}, null)]);
}
return () => S("div", {
class: "f-property-editor-stateMachine-container"
}, [u(), f()]);
}
function Ct(e, t, r) {
const s = T(!1), {
getPropertyValue: y,
triggerValueChange: C
} = r, c = y("Custom");
function d(p) {
const i = p.target.value;
C(i);
}
return () => S("div", {
class: "f-property-editor-customize-container"
}, [ue(S("input", {
class: "form-control",
placeholder: "输入自定义内容",
"onUpdate:modelValue": (p) => c.value = p,
onChange: d,
disabled: s.value
}, null), [[ce, c.value]])]);
}
function ht(e, t, r) {
const { getPropertyValue: s } = r, y = e.id;
function C(p) {
return p + "_" + y;
}
function c(p) {
return {
type: "Expression",
expressionId: C((p == null ? void 0 : p.targetId) || ""),
expressionInfo: p
};
}
function d() {
const { expressionInfo: p = { value: "", targetId: "", targetType: "", expressionType: "" } } = e.expressionConfig, i = s("Expression");
return i.value ? (i.value.expressionInfo = p, i.value.expressionId = C(p == null ? void 0 : p.targetId), i) : (i.value = c(p), i);
}
return { getExpressionValue: d };
}
function Tt(e, t, r) {
const s = T(!1), {
triggerValueChange: y
} = r, {
getExpressionValue: C
} = ht(e, t, r);
let c = C();
const {
expressionInfo: d
} = c.value, p = T(d.value), i = T(d.message), v = T(e.expressionConfig);
z(() => [e.expressionConfig], () => {
v.value = e.expressionConfig, c = C(), p.value = c.value.expressionInfo.value;
});
function a({
expression: f,
message: o
}) {
f && (c.value.expressionInfo.value = f, o ? c.value.expressionInfo.message = o : delete c.value.expressionInfo.message, y(c.value));
}
function u({
expressionValue: f,
notifyService: o
}) {
return f ? !0 : (o.warning({
message: "请先配置表达式",
position: "top-center"
}), !1);
}
return () => S("div", {
class: "f-property-editor-expression-container"
}, [S(ye, pe(v.value, {
modelValue: p.value,
"onUpdate:modelValue": (f) => p.value = f,
validateMessage: i.value,
enableClear: !1,
readonly: s.value,
beforeSubmit: u,
onSubmitModal: a
}), null)]);
}
function Pt(e, t, r) {
const s = T(e.modelValue), y = /* @__PURE__ */ new Map();
y.set(r, T(D(s.value)));
function C(p) {
t.emit("valueChange", D(p));
}
function c(p) {
const i = y.get(p);
if (i)
return i;
const v = T();
return y.set(p, v), v;
}
function d(p, i) {
switch (p) {
case "Const":
return i !== void 0;
case "Variable":
return i && i.field;
case "Custom":
return !0;
case "Expression":
return i && i.expressionInfo && i.expressionInfo.value;
case "StateMachine":
return i && i.field;
}
}
return { triggerValueChange: C, getPropertyValue: c, isPropertyValueValid: d };
}
const Vt = [
{
id: "Const",
name: "常量"
},
{
id: "Variable",
name: "变量"
},
{
id: "Custom",
name: "自定义"
},
{
id: "StateMachine",
name: "状态机"
},
{
id: "Expression",
name: "表达式"
}
];
function St(e, t) {
const r = T(e.constType), s = T(e.constEnums), y = T(e.propertyTypes), C = T([]), c = T();
function d() {
const n = y.value;
return C.value = Vt.filter((l) => n.includes(l.id)), C;
}
z(() => [e.propertyTypes], () => {
y.value = e.propertyTypes, d();
});
function p(n) {
return typeof n != "string" ? !1 : /^(?:(!)?)viewModel\.stateMachine\['([^']+)'\]$/.test(n);
}
function i(n) {
const l = y.value, m = l.includes("Const") && r.value === "enum" && s.value.findIndex((V) => V.id === n) > -1, b = l.includes("Const") && r.value === "number" && typeof n == "number";
return m || b;
}
function v(n) {
return y.value.includes("Custom") && typeof n == "string";
}
function a(n) {
if (n && typeof n == "object")
return n.type;
}
function u(n) {
const l = /* @__PURE__ */ new Map([
["Const", i],
["StateMachine", p],
["Custom", v]
]);
for (const [m, b] of l.entries())
if (b(n))
return m;
}
function f() {
const n = e.modelValue, l = y.value[0], m = a(n), b = u(n);
return m || b || l;
}
function o() {
return c.value || (c.value = f()), c;
}
return { getAllowedPropertyTypeItems: d, getCurrentPropertyType: o };
}
const I = /* @__PURE__ */ de({
name: "FPropertyEditor",
props: te,
emits: ["valueChange", "beforeOpenVariables"],
setup(e, t) {
const r = T(!1), {
getAllowedPropertyTypeItems: s,
getCurrentPropertyType: y
} = St(e), C = s(), c = y(), d = Pt(e, t, c.value), {
getPropertyValue: p,
triggerValueChange: i,
isPropertyValueValid: v
} = d, a = mt(e, t, d), u = yt(e, t, d), f = Ct(e, t, d), o = bt(e, t, d), n = Tt(e, t, d), l = B(() => (h) => h === c.value);
t.expose({
currentPropertyType: c
});
function m() {
const h = p(c.value);
v(c.value, h.value) && i(h.value);
}
function b() {
return S("div", {
class: "f-property-editor-left"
}, [S(A, {
modelValue: c.value,
"onUpdate:modelValue": (h) => c.value = h,
placeholder: "",
enableClear: !1,
valueField: "id",
textField: "name",
data: C.value,
editable: !1,
readonly: r.value,
onChange: m
}, null)]);
}
function V() {
return S("div", {
class: "f-property-editor-right"
}, [l.value("Const") && a(), l.value("Variable") && u(), l.value("Custom") && f(), l.value("StateMachine") && o(), l.value("Expression") && n()]);
}
return () => S("div", {
class: "f-property-editor-container clearfix"
}, [b(), V()]);
}
});
I.register = (e, t, r, s) => {
e["property-editor"] = I, t["property-editor"] = ft;
};
const Bt = ve(I);
export {
I as FPropertyEditor,
Bt as default,
te as propertyEditorProps,
ft as propsResolver
};