@farris/ui-vue
Version:
Farris Vue, a Farris Design based Vue3 component library.
1,159 lines (1,158 loc) • 40.2 kB
JavaScript
import { ref as E, computed as w, createVNode as h, defineComponent as de, watch as fe, onMounted as me } from "vue";
import { getCustomClass as L, getCustomStyle as $, withInstall as pe } from "../common/index.esm.js";
import { isPlainObject as W, cloneDeep as _ } from "lodash-es";
import { resolveAppearance as be } from "../dynamic-resolver/index.esm.js";
import { DgControl as G } from "../designer-canvas/index.esm.js";
import ve from "../response-toolbar/index.esm.js";
import { LocaleService as Z } from "../locale/index.esm.js";
function J(e, t) {
let n;
function r(i) {
const { properties: l, title: m, ignore: o } = i, a = o && Array.isArray(o), s = Object.keys(l).reduce((v, p) => ((!a || !o.find((x) => x === p)) && (v[p] = l[p].type === "object" && l[p].properties ? r(l[p]) : _(l[p].default)), v), {});
if (m && (!a || !o.find((v) => v === "id"))) {
const v = m.toLowerCase().replace(/-/g, "_");
s.id = `${v}_${Math.random().toString().slice(2, 6)}`;
}
return s;
}
function c(i) {
const { properties: l, title: m, required: o } = i;
if (o && Array.isArray(o)) {
const a = o.reduce((s, v) => (s[v] = l[v].type === "object" && l[v].properties ? r(l[v]) : _(l[v].default), s), {});
if (m && o.find((s) => s === "id")) {
const s = m.toLowerCase().replace(/-/g, "_");
a.id = `${s}_${Math.random().toString().slice(2, 6)}`;
}
return a;
}
return {
type: m
};
}
function b(i, l = {}, m) {
const o = e[i];
if (o) {
let a = c(o);
const s = t[i];
return a = s ? s({ getSchemaByType: b }, a, l, m) : a, n != null && n.appendIdentifyForNewControl && n.appendIdentifyForNewControl(a), a;
}
return null;
}
function d(i, l) {
const m = r(l);
return Object.keys(m).reduce((o, a) => (Object.prototype.hasOwnProperty.call(i, a) && (o[a] && W(o[a]) && W(i[a] || !i[a]) ? Object.assign(o[a], i[a] || {}) : o[a] = i[a]), o), m), m;
}
function y(i, l) {
return Object.keys(i).filter((o) => i[o] != null).reduce((o, a) => {
if (l.has(a)) {
const s = l.get(a);
if (typeof s == "string")
o[s] = i[a];
else {
const v = s(a, i[a], i);
Object.assign(o, v);
}
} else
o[a] = i[a];
return o;
}, {});
}
function C(i, l, m = /* @__PURE__ */ new Map()) {
const o = d(i, l);
return y(o, m);
}
function u(i) {
var m;
const l = i.type;
if (l) {
const o = e[l];
if (!o)
return i;
const a = d(i, o), s = ((m = i.editor) == null ? void 0 : m.type) || "";
if (s) {
const v = e[s], p = d(i.editor, v);
a.editor = p;
}
return a;
}
return i;
}
function f(i) {
n = i;
}
return { getSchemaByType: b, resolveSchemaWithDefaultValue: u, resolveSchemaToProps: C, mappingSchemaToProps: y, setDesignerContext: f };
}
const Q = {}, U = {}, { resolveSchemaWithDefaultValue: ge, resolveSchemaToProps: ye, mappingSchemaToProps: Ce } = J(Q, U);
function Se(e = {}) {
function t(u, f, i, l) {
if (typeof i == "number")
return l[u].length === i;
if (typeof i == "object") {
const m = Object.keys(i)[0], o = i[m];
if (m === "not")
return Number(l[u].length) !== Number(o);
if (m === "moreThan")
return Number(l[u].length) >= Number(o);
if (m === "lessThan")
return Number(l[u].length) <= Number(o);
}
return !1;
}
function n(u, f, i, l) {
return l[u] && l[u].propertyValue && String(l[u].propertyValue.value) === String(i);
}
const r = /* @__PURE__ */ new Map([
["length", t],
["getProperty", n]
]);
Object.keys(e).reduce((u, f) => (u.set(f, e[f]), u), r);
function c(u, f) {
const i = u;
return typeof f == "number" ? [{ target: i, operator: "length", param: null, value: Number(f) }] : typeof f == "boolean" ? [{ target: i, operator: "getProperty", param: u, value: !!f }] : typeof f == "object" ? Object.keys(f).map((l) => {
if (l === "length")
return { target: i, operator: "length", param: null, value: f[l] };
const m = l, o = f[l];
return { target: i, operator: "getProperty", param: m, value: o };
}) : [];
}
function b(u) {
return Object.keys(u).reduce((i, l) => {
const m = c(l, u[l]);
return i.push(...m), i;
}, []);
}
function d(u, f) {
if (r.has(u.operator)) {
const i = r.get(u.operator);
return i && i(u.target, u.param, u.value, f) || !1;
}
return !1;
}
function y(u, f) {
return b(u).reduce((m, o) => m && d(o, f), !0);
}
function C(u, f) {
const i = Object.keys(u), l = i.includes("allOf"), m = i.includes("anyOf"), o = l || m, v = (o ? u[o ? l ? "allOf" : "anyOf" : "allOf"] : [u]).map((x) => y(x, f));
return l ? !v.includes(!1) : v.includes(!0);
}
return { parseValueSchema: C };
}
const Te = {
convertTo: (e, t, n, r) => {
e.appearance || (e.appearance = {}), e.appearance[t] = n;
},
convertFrom: (e, t, n) => e.appearance ? e.appearance[t] : e[t]
}, Fe = {
convertFrom: (e, t, n) => e.buttons && e.buttons.length ? `共 ${e.buttons.length} 项` : "无"
}, he = {
convertTo: (e, t, n, r) => {
e.editor && (e.editor[t] = n);
},
convertFrom: (e, t, n) => e.editor && Object.prototype.hasOwnProperty.call(e.editor, t) ? e.editor[t] : e[t]
}, we = {
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: "标签页工具栏按钮" },
"drawer-toolbar-item": { type: "drawer-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: "标签页工具栏" },
"drawer-toolbar": { type: "drawer-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: "多语输入框" },
image: { type: "image", name: "图像" },
"discussion-editor": { type: "discussion-editor", name: "评论编辑区" },
"discussion-list": { type: "discussion-list", name: "评论列表" },
comment: { type: "comment", name: "评论区" },
"rich-text-editor": { type: "rich-text-editor", name: "富文本", icon: "rich-text-box" },
calendar: { type: "calendar", name: "日历", icon: "date-picker" },
wizard: { type: "wizard", name: "向导", icon: "wizard" },
"wizard-page": { type: "wizard-page", name: "向导页", icon: "wizard" },
"wizard-page-detail": { type: "wizard-page-detail", name: "向导详情", icon: "wizard" },
step: { type: "step", name: "步骤条", icon: "step" },
"dynamic-form": { type: "dynamic-form", name: "动态表单" }
}, xe = {
convertFrom: (e, t, n) => {
var c;
const r = e.editor && e.editor[t] ? e.editor[t] : e[t];
return ((c = we[r]) == null ? void 0 : c.name) || r;
}
}, ke = {
convertTo: (e, t, n, r) => {
e[t] = e[t];
},
convertFrom: (e, t, n) => e.editor ? n.getRealEditorType(e.editor.type) : ""
}, Oe = {
convertTo: (e, t, n, r) => {
(e.type === "data-grid-column" || e.type === "tree-grid-column") && (e.formatter ? e.formatter[t] = n : e.formatter = {
[t]: n
});
},
convertFrom: (e, t, n) => {
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 === "dateFormat")
return e.formatter.dateFormat || "yyyy-MM-dd";
if (t === "customFormat")
return e.formatter.customFormat;
if (t === "type")
return e.formatter.type || "none";
if (t === "customFormat")
return e.formmater.customFormat;
}
return "none";
}
}, Pe = {
convertTo: (e, t, n, r) => {
e.command ? e.command[t] = n : e.command = {
[t]: n
}, t === "enableType" && n === "default" && (e.command.enable = !0, e.command.commands = [
{
text: "编辑",
type: "primary",
command: "edit"
},
{
text: "删除",
type: "danger",
command: "remove"
}
]), t === "enableType" && n === "custom" && (e.command.enable = !0, e.command.commands = [
{
value: "add",
text: "增加",
type: "link"
},
{
value: "edit",
text: "编辑",
type: "danger"
},
{
value: "remove",
text: "删除",
type: "remove"
}
]), t === "enableType" && n === "unable" && (e.command.enable = !1);
},
convertFrom: (e, t, n) => {
var r, c;
if (e.command) {
if (t === "enableType") {
const b = (c = (r = e.command) == null ? void 0 : r.commands) == null ? void 0 : c.find((d) => d.command === "edit" && d.type === "primary");
return e.command.enable ? b ? "default" : "custom" : "unable";
}
if (t === "commands")
return e.command.enableType === "custom" ? e.command.commands : [];
if (t === "formatter")
return e.command.formatter;
if (t === "count")
return e.command.count;
if (t === "columnWidth")
return e.command.columnWidth || 200;
}
return "";
}
}, Re = {
convertTo: (e, t, n, r) => {
e.column ? e.column[t] = n : e.column = {
[t]: n
}, t === "fitColumns" && n && (e.column.fitMode || (e.column.fitMode = "average"));
},
convertFrom: (e, t, n) => {
if (e.column) {
if (t === "fitColumns")
return e.column.fitColumns;
if (t === "fitMode")
return e.column.fitMode;
}
return "";
}
}, je = {
convertTo: (e, t, n, r) => {
e.summary ? e.summary[t] = n : e.summary = {
[t]: n
}, t === "enable" && n && (e.summary ? e.summary.groupFields || (e.summary.groupFields = []) : e.summary = {
enable: n,
groupFields: []
});
},
convertFrom: (e, t, n) => {
var r, c;
return t === "customSummaryStyle" ? e.summary.customSummaryStyle : t === "position" ? ((r = e.summary) == null ? void 0 : r[t]) || "bottom" : t === "customRender" ? ((c = e.summary) == null ? void 0 : c[t]) || "" : e.summary && t === "enable" ? e.summary.enable : e.type === "data-grid-column" ? e.enableSummary === void 0 ? !1 : e.enableSummary : "";
}
}, Me = {
convertTo: (e, t, n, r) => {
e.group ? e.group[t] = n : e.group = {
[t]: n
}, t === "enable" && n && (e.group ? e.group.groupFields || (e.group.groupFields = []) : e.group = {
enable: n,
groupFields: [],
showSummary: !1,
customRender: ""
});
},
convertFrom: (e, t, n) => {
if (e.group) {
if (t === "enable")
return e.group.enable;
if (t === "showSummary")
return e.group.showSummary;
if (t === "customRender")
return e.group.customRender;
if (t === "groupFields")
return e.group.groupFields;
}
}
}, Ee = {
convertFrom: (e, t) => e.binding ? e.binding.path : "",
convertTo: (e, t, n) => {
if (n && n.length > 0) {
const r = n[0];
e.binding || (e.binding = {}), e.binding.type = "Form", e.binding.path = r.bindingField, e.binding.field = r.id, e.binding.fullPath = r.path, e.path = r.bindingPath;
}
}
}, ze = {
convertTo: (e, t, n, r) => {
e.pagination || (e.pagination = {}), t === "sizeLimits" ? e.pagination.sizeLimits = n.split(",") : e.pagination[t] = n;
},
convertFrom: (e, t, n) => e.pagination ? t === "sizeLimits" ? e.pagination.sizeLimits.join(",") : e.pagination[t] : e[t]
}, De = {
convertTo: (e, t, n, r) => {
e.rowNumber || (e.rowNumber = {}), e.rowNumber[t] = n;
},
convertFrom: (e, t, n) => e.rowNumber ? e.rowNumber[t] : e[t]
}, Be = {
convertTo: (e, t, n, r) => {
e.selection || (e.selection = {}), e.selection[t] = n;
},
convertFrom: (e, t, n) => {
var r, c;
return t === "showCheckbox" ? (r = e.selection) != null && r.multiSelect ? !0 : (c = e.selection) == null ? void 0 : c.showCheckbox : e.selection ? e.selection[t] : e[t];
}
}, Le = {
convertFrom: (e, t, n) => e[t] && e[t].length ? `共 ${e[t].length} 项` : ""
}, Ne = {
convertFrom: (e, t) => e[t] || "",
convertTo: (e, t, n) => {
e[t] = n;
}
}, $e = {
convertTo: (e, t, n, r) => {
e.size || (e.size = {}), e.size[t] = n;
},
convertFrom: (e, t, n) => e.size ? e.size[t] : e[t]
}, Ae = {
convertFrom: (e, t, n) => {
var r, c;
return (r = e.formatter) != null && r.data && t === "formatterEnumData" && !e.formatterEnumData ? (c = e.formatter) == null ? void 0 : c.data : e.formatterEnumData;
}
}, He = {
convertTo: (e, t, n, r) => {
e.sort || (e.sort = {}), e.sort[t] = n;
},
convertFrom: (e, t, n) => {
var r, c;
if (t === "mode")
return ((r = e.sort) == null ? void 0 : r.mode) || "client";
if (t === "multiSort")
return !!((c = e.sort) != null && c.multiSort);
}
}, Ie = {
convertTo: (e, t, n, r) => {
e.filter || (e.filter = {}), e.filter[t] = n;
},
convertFrom: (e, t, n) => {
var r;
if (t === "mode")
return ((r = e.filter) == null ? void 0 : r.mode) || "client";
}
}, qe = {
convertTo: (e, t, n, r) => {
e.rowOption ? e.rowOption[t] = n : e.rowOption = {
[t]: n
};
},
convertFrom: (e, t, n) => {
if (e.rowOption) {
if (t === "customRowStyle")
return e.rowOption.customRowStyle;
if (t === "customCellStyle")
return e.rowOption.customCellStyle;
if (t === "height")
return e.rowOption.height;
}
return "";
}
}, We = {
convertTo: (e, t, n, r) => {
(e.type === "data-grid-column" || e.type === "tree-grid-column") && (e[t] = n, t === "columnTemplateType" && n === "hyperlink" && (e.onClickLinkCommand ? e.columnTemplate = `
<span class="f-pretend-link f-cursor-pointer"
@click="(ctx)=>viewModel.current.${e.onClickLinkCommand || ""}({id: rowData.id,context: ctx})">
{{rowData.${e.field}}}
</span>` : e.columnTemplate = `
<span class="f-pretend-link f-cursor-pointer">
{{rowData.${e.field}}}
</span>`), t === "columnTemplateType" && n === "default" && (e.columnTemplate = ""), t === "columnTemplateType" && n === "custom" && (e.columnTemplate = ""));
},
convertFrom: (e, t, n) => t === "columnTemplate" ? e.columnTemplate : t === "columnTemplateType" ? e.columnTemplateType ? e.columnTemplateType || "default" : e.columnTemplate && !e.onClickLinkCommand ? "custom" : e.columnTemplate && e.onClickLinkCommand ? "hyperlink" : "default" : ""
};
function X(e, t, n) {
const r = /* @__PURE__ */ new Map([
["/converter/appearance.converter", Te],
["/converter/buttons.converter", Fe],
["/converter/property-editor.converter", he],
["/converter/items-count.converter", Le],
["/converter/type.converter", xe],
["/converter/change-editor.converter", ke],
["/converter/change-formatter.converter", Oe],
["/converter/column-command.converter", Pe],
["/converter/column-option.converter", Re],
["/converter/summary.converter", je],
["/converter/group.converter", Me],
["/converter/form-group-label.converter", Ne],
["/converter/field-selector.converter", Ee],
["/converter/pagination.converter", ze],
["/converter/row-number.converter", De],
["/converter/grid-selection.converter", Be],
["/converter/size.converter", $e],
["/converter/change-formatter-enum.converter", Ae],
["/converter/grid-sort.converter", He],
["/converter/grid-filter.converter", Ie],
["/converter/row-option.converter", qe],
["/converter/change-formatter-type.converter", We]
]), c = /* @__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 }],
["multiLanguage", { type: "language-textbox" }]
]), b = Se();
function d(o, a) {
return () => b.parseValueSchema(o, a);
}
function y(o, a, s) {
return o.includes("visible") && a.visible !== void 0 ? typeof a.visible == "boolean" ? () => !!a.visible : a.visible === void 0 ? !0 : d(a.visible, s) : () => !0;
}
function C(o, a, s) {
return o.includes("readonly") && a.readonly !== void 0 ? typeof a.readonly == "boolean" ? () => !!a.readonly : d(a.readonly, s) : () => !1;
}
function u(o, a) {
const s = o.$converter || a;
return typeof s == "string" && s && r.has(s) ? r.get(s) || null : s || null;
}
function f(o, a, s, v, p, x = "", k = "") {
return Object.keys(o).map((T) => {
const M = E(1), O = T, F = o[T], g = Object.keys(F), B = F.title, z = F.type, D = c.get(z) || { type: "input-group", enableClear: !1 }, j = F.editor ? Object.assign({}, D, F.editor) : Object.assign({}, D), A = y(g, F, a), N = C(g, F, a);
j.readonly = j.readonly === void 0 ? N() : j.readonly;
const H = F.type === "cascade" ? f(F.properties, a, s, v, p, x, k) : [], I = !0;
let P = u(F, k);
const ie = w({
get() {
if (M.value) {
if (["class", "style"].find((ue) => ue === O) && !P && (P = r.get("/converter/appearance.converter") || null), P && P.convertFrom)
return P.convertFrom(s, T, p, x);
const R = s[T];
return Object.prototype.hasOwnProperty.call(F, "defaultValue") && (R === void 0 || typeof R == "string" && R === "") ? F.type === "boolean" ? F.defaultValue : F.defaultValue || "" : R;
}
return null;
},
set(R) {
M.value += 1, P && P.convertTo ? (P.convertTo(v, T, R, p, x), P.convertTo(s, T, R, p, x)) : (v[T] = R, s[T] = R);
}
}), { refreshPanelAfterChanged: ae, description: le, isExpand: se, parentPropertyID: ce } = F, q = { propertyID: O, propertyName: B, propertyType: z, propertyValue: ie, editor: j, visible: A, readonly: N, cascadeConfig: H, hideCascadeTitle: I, refreshPanelAfterChanged: ae, description: le, isExpand: se, parentPropertyID: ce };
return a[O] = q, q;
});
}
function i(o, a, s = {}) {
const v = {}, p = e[o];
return p && p.categories ? Object.keys(p.categories).map((k) => {
const S = p.categories[k], T = S == null ? void 0 : S.title, M = f(S.properties || {}, v, {}, s, a);
return { categoryId: k, categoryName: T, properties: M };
}) : [];
}
function l(o, a, s, v, p = "") {
const x = a.$ref.schema, k = a.$ref.converter, S = s[x], T = S.type, M = n(S), O = {}, F = e[T];
if (F && F.categories) {
const g = F.categories[o], B = g == null ? void 0 : g.title;
k && Object.keys(g.properties).forEach((j) => {
g.properties[j].$converter = k;
});
const z = (g == null ? void 0 : g.properties) || {}, D = f(z, O, M, S, v, p);
return { categoryId: o, categoryName: B, properties: D };
}
return { categoryId: o, categoryName: "", properties: [] };
}
function m(o, a, s, v, p) {
const x = o.type, k = n(o), S = {};
let T = p || e[x];
if (!(T && Object.keys(T).length > 0) && s && s.getPropConfig && (T = s.getPropConfig(v)), T && T.categories) {
const O = [];
return Object.keys(T.categories).map((F) => {
const g = T.categories[F];
if (g.$ref) {
O.push(l(F, g, o, a, v));
return;
}
const B = g == null ? void 0 : g.title, z = g == null ? void 0 : g.tabId, D = g == null ? void 0 : g.tabName, j = g == null ? void 0 : g.hide, A = g == null ? void 0 : g.hideTitle, N = f(g.properties || {}, S, k, o, a, v, g.$converter), { setPropertyRelates: H } = g, I = g == null ? void 0 : g.parentPropertyID;
O.push({ categoryId: F, categoryName: B, tabId: z, tabName: D, hide: j, properties: N, hideTitle: A, setPropertyRelates: H, parentPropertyID: I });
}), O;
}
return [];
}
return {
getPropertyConfigBySchema: m,
getPropertyConfigByType: i,
propertyConverterMap: r
};
}
const Y = {}, V = {};
X(Y, V, ge);
const K = {}, ee = {}, { resolveSchemaWithDefaultValue: _e } = J(K, ee), te = {}, ne = {};
X(te, ne, _e);
function Ge(e, t, n = /* @__PURE__ */ new Map(), r = (d, y, C, u) => y, c = {}, b = (d) => d) {
return Q[t.title] = t, U[t.title] = r, Y[t.title] = c, V[t.title] = b, K[t.title] = t, ee[t.title] = r, te[t.title] = c, ne[t.title] = b, (d = {}, y = !0) => {
if (!y)
return Ce(d, n);
const C = ye(d, t, n), u = Object.keys(e).reduce((f, i) => (f[i] = e[i].default, f), {});
return Object.assign(u, C);
};
}
function Ze(e, t) {
if (!e || e.length < 1)
return null;
for (const n of e) {
if (n.id === t)
return n;
if (n.children) {
const r = n.children.find((c) => c.id === t);
if (r)
return r;
}
}
return null;
}
function Je() {
function e(t, n) {
var y;
const r = (y = t.toolbar) == null ? void 0 : y.buttons;
if (!r || r.length < 1)
return null;
const [c, b] = n.payloads, d = Ze(r, b);
return d ? d.onClick || d.click : null;
}
return {
resolve: e
};
}
function Qe(e, t, n) {
return t ? { enableAccordion: n.accordionMode } : { enableAccordion: "" };
}
function Ue(e, t) {
var n;
return {
buttons: t.buttons,
buttonPosition: t.position,
buttonsClass: (n = t.appearance) == null ? void 0 : n.class,
buttonsVisible: t.visible
};
}
const Xe = /* @__PURE__ */ new Map([
["appearance", be],
["expanded", "expandStatus"],
["enableAccordion", Qe],
["toolbar", Ue]
]);
function Ye(e, t) {
var b, d;
if (!(t != null && t.schema))
return;
const n = ((d = (b = t.schema) == null ? void 0 : b.appearance) == null ? void 0 : d.class) || "", r = t.elementRef, c = window.getComputedStyle(r);
c && c.display === "flex" && !n.includes("f-page-child-fill") && (e.appearance.class += " d-block");
}
function Ve(e, t) {
var C;
const n = Math.random().toString().slice(2, 6), r = t.parentComponentInstance, c = e.getSchemaByType("section");
Object.assign(c, {
id: `section-${n}`,
appearance: {
class: "f-section-in-mainsubcard"
},
mainTitle: t.mainTitle || c.mainTitle || "标题"
});
const b = e.getSchemaByType("content-container");
Object.assign(b, {
id: `container-${n}`,
appearance: {
class: "f-struct-wrapper"
},
contents: [c]
});
const d = r.schema, y = ((C = d.appearance) == null ? void 0 : C.class) || "";
switch (d && d.type) {
case G["splitter-pane"].type: {
c.appearance.class = "f-section-in-main", y.includes("f-page-child-fill") && (b.appearance.class += " f-struct-wrapper-child", c.fill = !0);
break;
}
case G["content-container"].type:
d.isLikeCardContainer && y.includes("f-struct-like-card-child-fill") && (b.appearance.class += " f-struct-wrapper-child", c.fill = !0);
}
return Ye(b, r), b;
}
function Ke(e, t, n) {
return n.parentComponentInstance ? Ve(e, n) : t;
}
const et = "https://json-schema.org/draft/2020-12/schema", tt = "https://farris-design.gitee.io/section.schema.json", nt = "section", rt = "A Farris Container Component", ot = "object", it = {
id: {
description: "The unique identifier for a Section",
type: "string"
},
type: {
description: "The type string of Section component",
type: "string",
default: "section"
},
appearance: {
description: "",
type: "object",
properties: {
class: {
type: "string"
},
style: {
type: "string"
}
},
default: {}
},
contentClass: {
description: "",
type: "string",
default: ""
},
contents: {
description: "",
type: "array",
default: []
},
enableAccordion: {
description: "",
type: "string",
default: ""
},
accordionMode: {
description: "",
type: "string",
default: "default"
},
enableMaximize: {
description: "",
type: "boolean",
default: !1
},
expanded: {
description: "",
type: "boolean",
default: !0
},
fill: {
description: "",
type: "boolean",
default: !1
},
headerClass: {
description: "",
type: "string",
default: ""
},
size: {
description: "",
type: "object",
properties: {
width: {
type: "number"
},
height: {
type: "number"
}
},
default: null
},
showHeader: {
description: "",
type: "string",
default: !0
},
mainTitle: {
description: "",
type: "string",
default: ""
},
subTitle: {
description: "",
type: "string",
default: ""
},
headerContentClass: {
description: "",
type: "string",
default: ""
},
extendClass: {
description: "",
type: "string",
default: ""
},
visible: {
description: "",
type: "boolean",
default: !0
},
expandStatus: {
description: "",
type: "boolean",
default: !0
},
toolbar: {
description: "",
type: "object",
properties: {
type: {
type: "string",
default: "section-toolbar"
},
position: {
type: "string",
default: "inHead"
},
buttons: {
type: "array",
default: []
},
appearance: {
description: "",
type: "object",
properties: {
class: {
type: "string",
default: ""
}
}
}
},
default: null
},
headerTitleHtml: {
description: "",
type: "string",
default: ""
},
headerTitleRenderFunction: {
description: "",
type: "function",
default: null
},
headerHtml: {
description: "",
type: "string",
default: ""
},
headerRenderFunction: {
description: "",
type: "function",
default: null
},
headerContentHtml: {
description: "",
type: "string",
default: ""
},
headerContentRenderFunction: {
description: "",
type: "function",
default: null
},
toolbarHtml: {
description: "",
type: "string",
default: ""
},
toolbarRenderFunction: {
description: "",
type: "function",
default: null
},
footerClass: {
description: "",
type: "string",
default: ""
},
footerRenderFunction: {
description: "",
type: "function",
default: null
},
moreButtonClass: {
description: "处于下拉菜单时的样式",
type: "string",
default: "btn-secondary"
}
}, at = [
"id",
"type",
"contents"
], lt = {
$schema: et,
$id: tt,
title: nt,
description: rt,
type: ot,
properties: it,
required: at
}, re = {
/** 设置内容区域样式 */
contentClass: { type: String, default: "" },
/** 自定义样式 */
customClass: { type: String, default: "" },
customStyle: { type: String, default: "" },
/** 设置是否启用収折功能。支持:空字符串,不启用収折 | default 默认収折方式 || custom自定义収折方式 */
enableAccordion: { type: String, default: "" },
/** 设置初始是否处于展开状态,支持:true 内容区域被展开|false 内容区域被収折 */
expandStatus: { type: Boolean, default: !0 },
/** 设置Section的主标题 */
mainTitle: { type: String, default: "" },
/** 设置是否显示头部区域 */
showHeader: { type: Boolean, default: !0 },
/** 设置Section的副标题 */
subTitle: { type: String, default: "" },
/** 展开文本 */
expandLabel: { type: String, default: "展开" },
/** 收起文本 */
collapseLabel: { type: String, default: "收起" },
/** 头部区域的自定义样式。配置头部自定义模板后,此属性有效。 */
headerClass: { type: String, default: "" },
headerStyle: { type: [String, Function], default: "" },
/** 设置是否启用最大化 */
enableMaximize: { type: Boolean, default: !1 },
/** 头部扩展区域的自定义样式。配置头部扩展区域模板后,此属性有效。 */
headerContentClass: { type: String, default: "" },
/** 扩展区域的自定义样式。配置扩展区域模板后,此属性有效。 */
extendClass: { type: String, default: "" },
footerClass: { type: String, default: "" },
footerStyle: { type: [String, Function], default: "" },
/** 按钮组 */
buttons: { type: Array, default: [] },
/** 按钮组的位置,inHead:头部区域| inContent:内容区域 */
buttonPosition: { type: String, default: "inHead" },
/** 按钮组整体样式*/
buttonsClass: { type: String, default: "" },
/** 按钮组是否可见*/
buttonsVisible: { type: Boolean, default: !0 },
/** 设置是否铺满剩余空间,支持:false按照内容自动高度|true 铺满剩余空间 */
fill: { type: Boolean, default: !1 },
/** 控制是否可见 */
visible: { type: Boolean, default: !0 },
/** 标题 */
headerTitleRenderFunction: { type: Function },
/** 头部区域 */
headerRenderFunction: { type: Function },
/** 头部扩展区区域 */
headerContentRenderFunction: { type: Function },
/** 尾部扩展区域 */
footerRenderFunction: { type: Function },
/** 工具栏区域 */
toolbarRenderFunction: { type: Function },
/** 更多按钮的样式 */
moreButtonClass: { type: String, default: "btn-secondary" }
// 暂未使用该属性
// clickThrottleTime: { type: Number, default: 350 },
// context: { type: Object },
// 暂未使用该属性
// index: { type: Number },
// maxStatus: { type: Boolean, default: false },
// showToolbarMoreButton: { type: Boolean, default: true },
// 暂未使用该属性
// toolbarPosition: { type: String, default: '' },
// toolbarButtons: { type: Array<object>, default: [] },
// toolbar: { type: Object as PropType<ToolbarConfig>, default: {} }
}, yt = Ge(re, lt, Xe, Ke), Ct = Je();
function st(e, t, n) {
let r;
function c(C = 1) {
const u = [
"body>.f-datagrid-settings-simple-host",
"body>div",
"body>farris-dialog>.farris-modal.show",
"body>.farris-modal.show",
"body>farris-filter-panel>.f-filter-panel-wrapper",
"body .f-sidebar-show>.f-sidebar-main",
"body>.popover.show",
"body>filter-row-panel>.f-datagrid-filter-panel",
"body>.f-section-maximize"
], f = Array.from(document.body.querySelectorAll(u.join(","))).filter((l) => l).map((l) => {
const { display: m, zIndex: o } = window.getComputedStyle(l);
return m === "none" ? 0 : parseInt(o, 10);
}).filter((l) => l);
let i = Math.max(...f);
return i < 1040 && (i = 1040), i + C;
}
function b() {
r = e.value.nextElementSibling;
const C = document && document.querySelector("body");
C && (C.appendChild(e.value), e.value.style.zIndex = c());
}
function d() {
r ? t.value.insertBefore(
e.value,
r
) : t.value.appendChild(e.value), e.value.style.zIndex = null;
}
function y() {
!e || !t.value || (n.value = !n.value, n.value ? b() : d());
}
return { onClickMaxMinIcon: y };
}
function oe(e, t) {
const n = E(e.buttons), r = w(() => e.buttonPosition === "inHead" ? "right" : "left"), c = w(() => "f-section-toolbar" + (e.buttonPosition === "inHead" ? " f-toolbar f-section-header--toolbar" : " f-section-content--toolbar") + (e.buttonsClass ? " " + e.buttonsClass : " col-6")), b = w(() => e.buttons && e.buttons.length > 0 && e.buttonPosition === "inHead");
function d(u, f) {
t.emit("click", u, f);
}
function y() {
return b.value && h(ve, {
customClass: c.value,
moreButtonClass: e.moreButtonClass,
items: n.value,
onClick: d,
alignment: r.value,
visible: e.buttonsVisible
}, null);
}
function C() {
return h("div", {
class: c.value
}, [h("div", {
class: "w-100",
style: "flex:1"
}, [e.toolbarRenderFunction()])]);
}
return () => e.toolbarRenderFunction ? C() : y();
}
function ct(e, t, n, r, c, b) {
const d = {
collapseLabel: Z.getRealPropertyValue(e.collapseLabel, "收起", "section.collapseLabel"),
expandLabel: Z.getRealPropertyValue(e.expandLabel, "展开", "section.expandLabel")
}, y = w(() => e.buttonPosition), C = oe(e, t), {
onClickMaxMinIcon: u
} = st(r, c, b), f = w(() => e.enableMaximize), i = w(() => e.enableAccordion !== ""), l = w(() => L({
"f-section-header": !0
}, e.headerClass)), m = w(() => {
const S = {};
return e.headerStyle ? typeof e.headerStyle == "function" ? $(S, e.headerStyle()) : $(S, e.headerStyle) : S;
});
function o(S) {
S.stopPropagation(), e.enableAccordion !== "" && (n.value = !n.value);
}
function a() {
const S = w(() => ({
btn: !0,
"f-btn-collapse-expand": !0,
"f-btn-mx": !0,
"f-state-expand": n.value
})), T = w(() => ({
"f-icon": !0,
"f-icon-maximize": !b.value,
"f-icon-minimize": b.value
}));
return h("div", {
class: "f-max-accordion"
}, [f.value ? h("span", {
class: T.value,
onClick: u
}, null) : "", i.value ? h("button", {
class: S.value,
onClick: o
}, [h("span", null, [n.value ? d.collapseLabel : d.expandLabel])]) : ""]);
}
function s() {
return h("div", {
class: "f-title"
}, [h("h4", {
class: "f-title-text"
}, [e.mainTitle]), e.subTitle && h("span", null, [e.subTitle])]);
}
function v() {
const S = w(() => L({
"f-content": !0
}, e.headerContentClass));
return t.slots.headerContent ? h("div", {
class: S.value
}, [t.slots.headerContent()]) : e.headerContentRenderFunction ? h("div", {
class: S.value
}, [e.headerContentRenderFunction()]) : null;
}
function p() {
return t.slots.headerTitle ? t.slots.headerTitle() : e.headerTitleRenderFunction ? e.headerTitleRenderFunction() : s();
}
function x() {
return h("div", {
class: l.value,
style: m.value
}, [p(), v(), y.value === "inHead" && C(), (f.value || i.value) && a()]);
}
function k() {
return t.slots.header ? h("div", {
class: l.value
}, [t.slots.header()]) : e.headerRenderFunction ? h("div", {
class: l.value
}, [e.headerRenderFunction()]) : x();
}
return () => e.showHeader && k();
}
const ut = /* @__PURE__ */ de({
name: "FSection",
props: re,
emits: ["click"],
setup(e, t) {
const n = E(), r = E(), c = E(e.customClass), b = w(() => e.enableAccordion), d = E(e.expandStatus), y = w(() => e.buttonPosition), C = E(!1), u = ct(e, t, d, n, r, C), f = oe(e, t), i = w(() => {
const p = {
"f-section": !0,
"f-section-accordion": b.value === "default",
"f-state-collapse": (b.value === "default" || b.value === "custom") && !d.value,
"f-section-custom-accordion": b.value === "custom",
"f-section-fill": e.fill,
"f-section-maximize": C.value
};
return L(p, c.value);
}), l = w(() => L({
"f-section-content": !0
}, e.contentClass)), m = w(() => L({
"f-section-extend": !0
}, e.extendClass));
function o() {
return t.slots.extend && h("div", {
class: m.value
}, [t.slots.extend()]);
}
function a() {
return h("div", {
class: l.value
}, [y.value === "inContent" && f(), t.slots.default && t.slots.default()]);
}
const s = w(() => {
const p = {};
return e.footerStyle ? typeof e.headerStyle == "function" ? $(p, e.footerStyle()) : $(p, e.footerStyle) : p;
});
function v() {
return t.slots.footer ? t.slots.footer && h("div", {
class: "f-section-footer " + e.footerClass,
style: s.value
}, [t.slots.footer()]) : e.footerRenderFunction ? h("div", {
class: "f-section-footer " + e.footerClass,
style: s.value
}, [e.footerRenderFunction()]) : null;
}
return fe(() => e.expandStatus, (p, x) => {
p !== x && (d.value = p);
}), me(() => {
n.value && n.value && (r.value = n.value.parentElement);
}), () => e.visible ? h("div", {
class: i.value,
ref: n,
style: e.customStyle
}, [u(), o(), a(), v()]) : null;
}
}), St = {
id: { type: String, default: "" },
items: { type: Object, default: {} },
class: { type: String, default: "" },
text: { type: String, default: "" },
disabled: { type: Boolean, default: !1 },
icon: { type: String, default: "" },
componentId: { type: String, default: "" },
// 是否展开子级
expanded: { type: Boolean, default: !1 },
alignment: { Type: String, default: "right" },
split: { type: Boolean, default: !1 },
// 是否下拉
isDP: { type: Boolean, default: !1 },
// 是否下拉项
isDPItem: { type: Boolean, default: !1 }
}, Tt = pe(ut);
export {
ut as Section,
Tt as default,
Ct as eventHandlerResolver,
yt as propsResolver,
re as sectionProps,
St as sectionToolbarItemProps
};