@farris/ui-vue
Version:
Farris Vue, a Farris Design based Vue3 component library.
1,057 lines (1,056 loc) • 33.5 kB
JavaScript
import { ref as w, computed as H, defineComponent as Z, watch as ne, createVNode as E, createTextVNode as C, inject as oe, onMounted as ae } from "vue";
import { createPropsResolver as ie, getSchemaByTypeForDesigner as ce } from "../dynamic-resolver/index.esm.js";
import { cloneDeep as Q, isPlainObject as X } from "lodash-es";
function V(e, t) {
let r;
function l(c) {
const { properties: o, title: a, ignore: n } = c, i = n && Array.isArray(n), u = Object.keys(o).reduce((m, g) => ((!i || !n.find((k) => k === g)) && (m[g] = o[g].type === "object" && o[g].properties ? l(o[g]) : Q(o[g].default)), m), {});
if (a && (!i || !n.find((m) => m === "id"))) {
const m = a.toLowerCase().replace(/-/g, "_");
u.id = `${m}_${Math.random().toString().slice(2, 6)}`;
}
return u;
}
function h(c) {
const { properties: o, title: a, required: n } = c;
if (n && Array.isArray(n)) {
const i = n.reduce((u, m) => (u[m] = o[m].type === "object" && o[m].properties ? l(o[m]) : Q(o[m].default), u), {});
if (a && n.find((u) => u === "id")) {
const u = a.toLowerCase().replace(/-/g, "_");
i.id = `${u}_${Math.random().toString().slice(2, 6)}`;
}
return i;
}
return {
type: a
};
}
function P(c, o = {}, a) {
const n = e[c];
if (n) {
let i = h(n);
const u = t[c];
return i = u ? u({ getSchemaByType: P }, i, o, a) : i, r != null && r.appendIdentifyForNewControl && r.appendIdentifyForNewControl(i), i;
}
return null;
}
function N(c, o) {
const a = l(o);
return Object.keys(a).reduce((n, i) => (Object.prototype.hasOwnProperty.call(c, i) && (n[i] && X(n[i]) && X(c[i] || !c[i]) ? Object.assign(n[i], c[i] || {}) : n[i] = c[i]), n), a), a;
}
function T(c, o) {
return Object.keys(c).filter((n) => c[n] != null).reduce((n, i) => {
if (o.has(i)) {
const u = o.get(i);
if (typeof u == "string")
n[u] = c[i];
else {
const m = u(i, c[i], c);
Object.assign(n, m);
}
} else
n[i] = c[i];
return n;
}, {});
}
function D(c, o, a = /* @__PURE__ */ new Map()) {
const n = N(c, o);
return T(n, a);
}
function p(c) {
var a;
const o = c.type;
if (o) {
const n = e[o];
if (!n)
return c;
const i = N(c, n), u = ((a = c.editor) == null ? void 0 : a.type) || "";
if (u) {
const m = e[u], g = N(c.editor, m);
i.editor = g;
}
return i;
}
return c;
}
function d(c) {
r = c;
}
return { getSchemaByType: P, resolveSchemaWithDefaultValue: p, resolveSchemaToProps: D, mappingSchemaToProps: T, setDesignerContext: d };
}
const le = {}, se = {}, { getSchemaByType: ct, resolveSchemaWithDefaultValue: ue, resolveSchemaToProps: lt, mappingSchemaToProps: st, setDesignerContext: ut } = V(le, se);
function fe(e = {}) {
function t(p, d, c, o) {
if (typeof c == "number")
return o[p].length === c;
if (typeof c == "object") {
const a = Object.keys(c)[0], n = c[a];
if (a === "not")
return Number(o[p].length) !== Number(n);
if (a === "moreThan")
return Number(o[p].length) >= Number(n);
if (a === "lessThan")
return Number(o[p].length) <= Number(n);
}
return !1;
}
function r(p, d, c, o) {
return o[p] && o[p].propertyValue && String(o[p].propertyValue.value) === String(c);
}
const l = /* @__PURE__ */ new Map([
["length", t],
["getProperty", r]
]);
Object.keys(e).reduce((p, d) => (p.set(d, e[d]), p), l);
function h(p, d) {
const c = p;
return typeof d == "number" ? [{ target: c, operator: "length", param: null, value: Number(d) }] : typeof d == "boolean" ? [{ target: c, operator: "getProperty", param: p, value: !!d }] : typeof d == "object" ? Object.keys(d).map((o) => {
if (o === "length")
return { target: c, operator: "length", param: null, value: d[o] };
const a = o, n = d[o];
return { target: c, operator: "getProperty", param: a, value: n };
}) : [];
}
function P(p) {
return Object.keys(p).reduce((c, o) => {
const a = h(o, p[o]);
return c.push(...a), c;
}, []);
}
function N(p, d) {
if (l.has(p.operator)) {
const c = l.get(p.operator);
return c && c(p.target, p.param, p.value, d) || !1;
}
return !1;
}
function T(p, d) {
return P(p).reduce((a, n) => a && N(n, d), !0);
}
function D(p, d) {
const c = Object.keys(p), o = c.includes("allOf"), a = c.includes("anyOf"), n = o || a, m = (n ? p[n ? o ? "allOf" : "anyOf" : "allOf"] : [p]).map((k) => T(k, d));
return o ? !m.includes(!1) : m.includes(!0);
}
return { parseValueSchema: D };
}
const pe = {
convertTo: (e, t, r, l) => {
e.appearance || (e.appearance = {}), e.appearance[t] = r;
},
convertFrom: (e, t, r) => e.appearance ? e.appearance[t] : e[t]
}, ve = {
convertFrom: (e, t, r) => e.buttons && e.buttons.length ? `共 ${e.buttons.length} 项` : "无"
}, de = {
convertTo: (e, t, r, l) => {
e.editor && (e.editor[t] = r);
},
convertFrom: (e, t, r) => e.editor && Object.prototype.hasOwnProperty.call(e.editor, t) ? e.editor[t] : e[t]
}, x = {
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: "多语输入框" }
}, me = {
convertFrom: (e, t, r) => {
var h;
const l = e.editor && e.editor[t] ? e.editor[t] : e[t];
return ((h = x[l]) == null ? void 0 : h.name) || l;
}
}, ye = {
convertTo: (e, t, r, l) => {
e[t] = e[t];
},
convertFrom: (e, t, r) => e.editor ? r.getRealEditorType(e.editor.type) : ""
}, be = {
convertTo: (e, t, r, l) => {
(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";
}
}, ge = {
convertTo: (e, t, r, l) => {
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 : ""
}, he = {
convertTo: (e, t, r, l) => {
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 "";
}
}, Se = {
convertTo: (e, t, r, l) => {
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 : ""
}, Fe = {
convertTo: (e, t, r, l) => {
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;
}
}
}, Te = {
convertFrom: (e, t) => e.binding ? e.binding.path : "",
convertTo: (e, t, r) => {
if (r && r.length > 0) {
const l = r[0];
e.binding || (e.binding = {}), e.binding.type = "Form", e.binding.path = l.bindingField, e.binding.field = l.id, e.binding.fullPath = l.path, e.path = l.bindingPath;
}
}
}, Ne = {
convertTo: (e, t, r, l) => {
e.pagination || (e.pagination = {}), e.pagination[t] = r;
},
convertFrom: (e, t, r) => e.pagination ? e.pagination[t] : e[t]
}, De = {
convertTo: (e, t, r, l) => {
e.rowNumber || (e.rowNumber = {}), e.rowNumber[t] = r;
},
convertFrom: (e, t, r) => e.rowNumber ? e.rowNumber[t] : e[t]
}, Me = {
convertTo: (e, t, r, l) => {
e.selection || (e.selection = {}), e.selection[t] = r;
},
convertFrom: (e, t, r) => e.selection ? e.selection[t] : e[t]
}, Pe = {
convertFrom: (e, t, r) => e[t] && e[t].length ? `共 ${e[t].length} 项` : ""
}, ke = {
convertFrom: (e, t) => e[t] || "",
convertTo: (e, t, r) => {
e[t] = r;
}
}, Oe = {
convertTo: (e, t, r, l) => {
e.size || (e.size = {}), e.size[t] = r;
},
convertFrom: (e, t, r) => e.size ? e.size[t] : e[t]
}, Ee = {
convertFrom: (e, t, r) => {
var l, h;
return (l = e.formatter) != null && l.data && t === "formatterEnumData" && !e.formatterEnumData ? (h = e.formatter) == null ? void 0 : h.data : e.formatterEnumData;
}
}, we = {
convertTo: (e, t, r, l) => {
e.sort || (e.sort = {}), e.sort[t] = r;
},
convertFrom: (e, t, r) => {
var l, h;
if (t === "mode")
return ((l = e.sort) == null ? void 0 : l.mode) || "client";
if (t === "multiSort")
return !!((h = e.sort) != null && h.multiSort);
}
}, je = {
convertTo: (e, t, r, l) => {
e.filter || (e.filter = {}), e.filter[t] = r;
},
convertFrom: (e, t, r) => {
var l;
if (t === "mode")
return ((l = e.filter) == null ? void 0 : l.mode) || "client";
}
}, $e = {
convertTo: (e, t, r, l) => {
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 I(e, t, r) {
const l = /* @__PURE__ */ new Map([
["/converter/appearance.converter", pe],
["/converter/buttons.converter", ve],
["/converter/property-editor.converter", de],
["/converter/items-count.converter", Pe],
["/converter/type.converter", me],
["/converter/change-editor.converter", ye],
["/converter/change-formatter.converter", be],
["/converter/column-command.converter", ge],
["/converter/column-option.converter", he],
["/converter/summary.converter", Se],
["/converter/group.converter", Fe],
["/converter/form-group-label.converter", ke],
["/converter/field-selector.converter", Te],
["/converter/pagination.converter", Ne],
["/converter/row-number.converter", De],
["/converter/grid-selection.converter", Me],
["/converter/size.converter", Oe],
["/converter/change-formatter-enum.converter", Ee],
["/converter/grid-sort.converter", we],
["/converter/grid-filter.converter", je],
["/converter/row-option.converter", $e]
]), h = /* @__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 }]
]), P = fe();
function N(n, i) {
return () => P.parseValueSchema(n, i);
}
function T(n, i, u) {
return n.includes("visible") && i.visible !== void 0 ? typeof i.visible == "boolean" ? () => !!i.visible : i.visible === void 0 ? !0 : N(i.visible, u) : () => !0;
}
function D(n, i, u) {
return n.includes("readonly") && i.readonly !== void 0 ? typeof i.readonly == "boolean" ? () => !!i.readonly : N(i.readonly, u) : () => !1;
}
function p(n, i) {
const u = n.$converter || i;
return typeof u == "string" && u && l.has(u) ? l.get(u) || null : u || null;
}
function d(n, i, u, m, g, k = "", B = "") {
return Object.keys(n).map((S) => {
const R = w(1), A = S, f = n[S], O = Object.keys(f), q = f.title, s = f.type, y = h.get(s) || { type: "input-group", enableClear: !1 }, v = f.editor ? Object.assign({}, y, f.editor) : Object.assign({}, y), b = T(O, f, i), F = D(O, f, i);
v.readonly = v.readonly === void 0 ? F() : v.readonly;
const $ = f.type === "cascade" ? d(f.properties, i, u, m, g, k, B) : [], L = !0;
let M = p(f, B);
const z = H({
get() {
if (R.value) {
if (["class", "style"].find((re) => re === A) && !M && (M = l.get("/converter/appearance.converter") || null), M && M.convertFrom)
return M.convertFrom(u, S, g, k);
const _ = u[S];
return Object.prototype.hasOwnProperty.call(f, "defaultValue") && (_ === void 0 || typeof _ == "string" && _ === "") ? f.type === "boolean" ? f.defaultValue : f.defaultValue || "" : _;
}
return null;
},
set(_) {
R.value += 1, M && M.convertTo ? (M.convertTo(m, S, _, g, k), M.convertTo(u, S, _, g, k)) : (m[S] = _, u[S] = _);
}
}), { refreshPanelAfterChanged: W, description: K, isExpand: ee, parentPropertyID: te } = f, J = { propertyID: A, propertyName: q, propertyType: s, propertyValue: z, editor: v, visible: b, readonly: F, cascadeConfig: $, hideCascadeTitle: L, refreshPanelAfterChanged: W, description: K, isExpand: ee, parentPropertyID: te };
return i[A] = J, J;
});
}
function c(n, i, u = {}) {
const m = {}, g = e[n];
return g && g.categories ? Object.keys(g.categories).map((B) => {
const j = g.categories[B], S = j == null ? void 0 : j.title, R = d(j.properties || {}, m, {}, u, i);
return { categoryId: B, categoryName: S, properties: R };
}) : [];
}
function o(n, i, u, m, g = "") {
const k = i.$ref.schema, B = i.$ref.converter, j = u[k], S = j.type, R = r(j), A = {}, f = e[S];
if (f && f.categories) {
const O = f.categories[n], q = O == null ? void 0 : O.title;
B && Object.keys(O.properties).forEach((v) => {
O.properties[v].$converter = B;
});
const s = (O == null ? void 0 : O.properties) || {}, y = d(s, A, R, j, m, g);
return { categoryId: n, categoryName: q, properties: y };
}
return { categoryId: n, categoryName: "", properties: [] };
}
function a(n, i, u, m, g) {
const k = n.type, B = r(n), j = {};
let S = g || e[k];
if (S && Object.keys(S).length === 0 && u && u.getPropConfig && (S = u.getPropConfig(m)), S && S.categories) {
const R = [];
return Object.keys(S.categories).map((A) => {
const f = S.categories[A];
if (f.$ref) {
R.push(o(A, f, n, i, m));
return;
}
const O = f == null ? void 0 : f.title, q = f == null ? void 0 : f.tabId, s = f == null ? void 0 : f.tabName, y = f == null ? void 0 : f.hide, v = f == null ? void 0 : f.hideTitle, b = d(f.properties || {}, j, B, n, i, m, f.$converter), { setPropertyRelates: F } = f, $ = f == null ? void 0 : f.parentPropertyID;
R.push({ categoryId: A, categoryName: O, tabId: q, tabName: s, hide: y, properties: b, hideTitle: v, setPropertyRelates: F, parentPropertyID: $ });
}), R;
}
return [];
}
return {
getPropertyConfigBySchema: a,
getPropertyConfigByType: c,
propertyConverterMap: l
};
}
const Be = {}, Re = {};
I(Be, Re, ue);
const Ae = {}, ze = {}, { getSchemaByType: ft, resolveSchemaWithDefaultValue: _e, resolveSchemaToProps: pt, mappingSchemaToProps: vt, setDesignerContext: dt } = V(Ae, ze), qe = {}, Le = {};
I(qe, Le, _e);
function He(e, t) {
return { customClass: t.class, customStyle: t.style };
}
const We = /* @__PURE__ */ new Map([
["appearance", He]
]);
function Ge(e, t, r) {
return t;
}
const Ue = "https://json-schema.org/draft/2020-12/schema", Je = "https://farris-design.gitee.io/nav.schema.json", Qe = "nav", Xe = "A Farris Component", Ye = "object", Ze = {
id: {
description: "The unique identifier for a nav",
type: "string"
},
type: {
description: "The type string of nav component",
type: "string",
default: "nav"
},
appearance: {
description: "",
type: "object",
properties: {
class: {
type: "string"
},
style: {
type: "string"
}
},
default: {}
},
binding: {
description: "",
type: "object",
default: {}
},
editable: {
description: "",
type: "boolean",
default: !0
},
enableLinkLabel: {
description: "",
type: "boolean",
default: !1
},
label: {
description: "",
type: "string",
default: ""
},
lableWidth: {
description: "",
type: "number"
},
placeholder: {
description: "",
type: "string",
default: ""
},
readonly: {
description: "",
type: "boolean",
default: !1
},
required: {
description: "",
type: "boolean",
default: !1
},
tabindex: {
description: "",
type: "number",
default: -1
},
textAlign: {
description: "",
type: "string",
enum: [
"left",
"middle",
"right"
],
default: "left"
},
visible: {
description: "",
type: "boolean",
default: !0
},
onBlur: {
description: "",
type: "string",
default: ""
},
onClickLinkLabel: {
description: "",
type: "sting",
default: ""
}
}, Ce = [
"id",
"type"
], Ve = {
$schema: Ue,
$id: Je,
title: Qe,
description: Xe,
type: Ye,
properties: Ze,
required: Ce
}, xe = "nav", Ie = "A Farris Component", Ke = "object", et = {
basic: {
description: "Basic Infomation",
title: "基本信息",
properties: {
id: {
description: "组件标识",
title: "标识",
type: "string",
readonly: !0
},
type: {
description: "组件类型",
title: "控件类型",
type: "select",
editor: {
type: "waiting for modification",
enum: []
}
}
}
},
behavior: {
description: "Basic Infomation",
title: "行为",
properties: {
editable: {
description: "",
title: "允许编辑",
type: "boolean"
},
readonly: {
description: "",
title: "只读",
type: "string"
},
required: {
description: "",
title: "必填",
type: "boolean"
},
visible: {
description: "",
title: "可见",
type: "boolean"
},
placeholder: {
description: "",
title: "提示文本",
type: "string"
},
tabindex: {
description: "",
title: "tab索引",
type: "number"
},
textAlign: {
description: "",
title: "对齐方式",
type: "enum",
editor: {
type: "combo-list",
textField: "name",
valueField: "value",
data: [
{
value: "left",
name: "左对齐"
},
{
value: "center",
name: "居中"
},
{
value: "right",
name: "右对齐"
}
]
}
}
}
}
}, tt = {
title: xe,
description: Ie,
type: Ke,
categories: et
}, U = {
/** 当前激活的id */
activeNavId: { Type: String, default: "1" },
/** 导航文本字段 */
displayField: { Type: String, default: "text" },
/** 控制禁用字段 */
disableField: { Type: String, default: "disable" },
/** 水平或垂直方向 */
horizontal: { Type: Boolean, default: !0 },
/** 标识字段 */
idField: { Type: String, default: "id" },
/** 最大数值 */
maxNum: { Type: Number, default: 99 },
/** 导航数据 */
navData: {
Type: Array,
default: [
{
id: "1",
text: "全部"
},
{
id: "2",
text: "已回复",
disable: !0
},
{
id: "3",
text: "待回复",
num: 200
},
{
id: "4",
text: "@我",
num: 33
}
]
},
/** 切换前事件 */
navPicking: {
type: Function,
default: () => (e) => !0
},
/** 徽标值字段 */
valueField: { Type: String, default: "num" }
}, Y = ie(U, Ve, We, Ge, tt), G = /* @__PURE__ */ Z({
name: "FNav",
props: U,
emits: ["nav", "update:activeNavId"],
setup(e, t) {
const r = w(e.activeNavId), l = w(e.navData), h = w(e.horizontal), P = w(e.navPicking), N = H(() => ({
paddingTop: "1rem"
}));
ne(() => e.activeNavId, (o, a) => {
o !== a && (r.value = o);
});
const T = H({
get() {
return l.value;
},
set(o) {
l.value = o, d();
}
}), D = H({
get() {
return r.value;
},
set(o) {
if (r.value = o, r.value && T && T.value.length) {
const a = T.value.find((n) => n.id === r.value);
a && t.emit("nav", a);
}
}
}), p = H({
set(o) {
h.value = o;
},
get() {
return h.value;
}
});
function d() {
if (T.value && T.value.length && !r.value) {
const o = T.value.find((a) => !a.disable);
o && (r.value = o.id);
}
}
function c(o) {
o.disable || o.id === r.value || Promise.resolve().then(() => P.value(o)).then((a) => {
a && (r.value = o.id, t.emit("update:activeNavId", o.id), t.emit("nav", o));
});
}
return () => {
var o;
return E("div", {
class: ["farris-nav", {
"farris-nav-vertical": !p.value
}]
}, [(o = T.value) == null ? void 0 : o.map((a) => E("div", {
class: ["farris-nav-item", {
active: a[e.idField] === D.value
}, {
disabled: a[e.disableField]
}],
onClick: () => c(a)
}, [E("div", {
class: "farris-nav-item-link",
style: N.value
}, [E("span", {
class: "farris-nav-item-link-text"
}, [typeof a[e.displayField] == "function" ? a[e.displayField]() : a[e.displayField], a[e.valueField] && E("div", {
class: "farris-nav-item-tag"
}, [a[e.valueField] <= e.maxNum && E("span", {
class: "tag-text"
}, [a[e.valueField]]), a[e.valueField] > e.maxNum && E("span", {
class: "tag-text"
}, [e.maxNum, C("+")])])]), E("div", {
class: "farris-nav-item-bottom-line"
}, null)])]))]);
};
}
});
function rt(e, t, r) {
var q;
const l = "", h = "", P = w();
let N;
function T() {
return (t == null ? void 0 : t.schema.componentType) !== "frame";
}
function D() {
return !1;
}
function p() {
return (t == null ? void 0 : t.schema.componentType) !== "frame";
}
function d() {
return (t == null ? void 0 : t.schema.componentType) === "frame";
}
function c(s) {
if (!s || !s.value)
return null;
if (s.value.schema && s.value.schema.type === "component")
return s.value;
const y = w(s == null ? void 0 : s.value.parent), v = c(y);
return v || null;
}
function o(s = t) {
var F;
const { componentInstance: y, designerItemElementRef: v } = s;
if (!y || !y.value)
return null;
const { getCustomButtons: b } = y.value;
return y.value.canMove || b && ((F = b()) != null && F.length) ? v : o(s.parent);
}
function a(s) {
return !!r;
}
function n() {
return (t == null ? void 0 : t.schema.label) || (t == null ? void 0 : t.schema.title) || (t == null ? void 0 : t.schema.name);
}
function i() {
}
function u(s, y) {
var v;
!s || !y || (v = t == null ? void 0 : t.setupContext) == null || v.emit("dragEnd");
}
function m(s, y) {
const { componentType: v } = s;
let b = ce(v, s, y);
const F = v.toLowerCase().replace(/-/g, "_");
return b && !b.id && b.type === v && (b.id = `${F}_${Math.random().toString().slice(2, 6)}`), b;
}
function g(s) {
}
function k(...s) {
}
function B(s) {
if (!s)
return;
const y = t == null ? void 0 : t.schema, { formSchemaUtils: v } = s;
if (y && v.getExpressions().length) {
const b = v.getExpressions().findIndex((F) => F.target === y.id);
b > -1 && v.getExpressions().splice(b, 1);
}
}
function j(s) {
if (!s || !(t != null && t.schema))
return;
const y = t.schema, { formSchemaUtils: v } = s;
v.removeCommunicationInComponent(y);
}
function S(s) {
B(s), j(s), t != null && t.schema.contents && t.schema.contents.map((y) => {
let v = y.id;
y.type === "component-ref" && (v = y.component);
const b = e.value.querySelectorAll(`#${v}-design-item`);
b != null && b.length && Array.from(b).map((F) => {
var $;
($ = F == null ? void 0 : F.componentInstance) != null && $.value.onRemoveComponent && F.componentInstance.value.onRemoveComponent(s);
});
});
}
function R() {
}
function A(s) {
var v, b;
if (!((v = t == null ? void 0 : t.schema) != null && v.id))
return;
!N && s && (N = s.formSchemaUtils);
let y = "";
{
const { text: F, title: $, label: L, mainTitle: M, name: z, type: W } = t.schema;
y = F || $ || L || M || z || ((b = x[W]) == null ? void 0 : b.name);
}
y && N.getControlBasicInfoMap().set(t.schema.id, {
componentTitle: y,
parentPathName: y
});
}
function f(s) {
var F;
const { changeObject: y } = s, { propertyID: v, propertyValue: b } = y;
if (["text", "title", "label", "name", "mainTitle"].includes((F = s == null ? void 0 : s.changeObject) == null ? void 0 : F.propertyID) && v && b && (A(), N)) {
const $ = N.getControlBasicInfoMap(), L = $.keys().toArray().filter((M) => {
var z, W;
return ((z = $.get(M)) == null ? void 0 : z.reliedComponentId) === ((W = t == null ? void 0 : t.schema) == null ? void 0 : W.id);
});
L != null && L.length && L.forEach((M) => {
const z = $.get(M).parentPathName.split(" > ");
z[0] = b, $.get(M).parentPathName = z.join(" > ");
});
}
}
function O(s) {
f(s);
}
return P.value = {
canMove: T(),
canSelectParent: D(),
canDelete: p(),
canNested: !d(),
contents: t == null ? void 0 : t.schema.contents,
elementRef: e,
parent: (q = t == null ? void 0 : t.parent) == null ? void 0 : q.componentInstance,
schema: t == null ? void 0 : t.schema,
styles: l,
designerClass: h,
canAccepts: a,
getBelongedComponentInstance: c,
getDraggableDesignItemElement: o,
getDraggingDisplayText: n,
getPropConfig: k,
getDragScopeElement: i,
onAcceptMovedChildElement: u,
onChildElementMovedOut: g,
addNewChildComponentSchema: m,
triggerBelongedComponentToMoveWhenMoved: w(!1),
triggerBelongedComponentToDeleteWhenDeleted: w(!1),
onRemoveComponent: S,
getCustomButtons: R,
onPropertyChanged: O,
setComponentBasicInfoMap: A,
updateContextSchema: t == null ? void 0 : t.updateContextSchema
}, P;
}
const nt = /* @__PURE__ */ Z({
name: "FNavDesign",
props: U,
emits: ["nav"],
setup(e, t) {
const r = w(e.activeNavId), l = w(e.navData), h = w(e.horizontal);
w(e.navPicking);
const P = w(), N = oe("design-item-context"), T = rt(P, N);
ae(() => {
P.value.componentInstance = T;
}), t.expose(T.value);
const D = H({
get() {
return l.value;
},
set(a) {
l.value = a, c();
}
}), p = H({
get() {
return r.value;
},
set(a) {
if (r.value = a, r.value && D && D.value.length) {
const n = D.value.find((i) => i.id === r.value);
n && t.emit("nav", n);
}
}
}), d = H({
set(a) {
h.value = a;
},
get() {
return h.value;
}
});
function c() {
if (D.value && D.value.length && !r.value) {
const a = D.value.find((n) => !n.disable);
a && (r.value = a.id);
}
}
function o(a) {
a.disable || a.id === r.value || (r.value = a.id, t.emit("nav", a));
}
return () => {
var a;
return E("div", {
ref: P,
class: ["farris-nav", {
"farris-nav-vertical": !d.value
}]
}, [(a = D.value) == null ? void 0 : a.map((n) => E("div", {
class: ["farris-nav-item", {
active: n.id === p.value
}, {
disabled: n.disable
}],
onClick: () => o(n)
}, [E("div", {
class: "farris-nav-item-link"
}, [E("span", {
class: "farris-nav-item-link-text"
}, [n.text, n.num && E("div", {
class: "farris-nav-item-tag"
}, [n.num <= e.maxNum && E("span", {
class: "tag-text"
}, [n.num]), n.num > e.maxNum && E("span", {
class: "tag-text"
}, [e.maxNum, C("+")])])])])]))]);
};
}
}), mt = {
install(e) {
e.component(G.name, G);
},
register(e, t, r, l) {
e.nav = G, t.nav = Y;
},
registerDesigner(e, t, r) {
e.nav = nt, t.nav = Y;
}
};
export {
G as FNav,
mt as default,
U as navProps,
Y as propsResolver
};