@farris/ui-vue
Version:
Farris Vue, a Farris Design based Vue3 component library.
1,178 lines (1,177 loc) • 41.1 kB
JavaScript
import { ref as E, computed as w, createVNode as T, defineComponent as de, watch as fe, onMounted as me } from "vue";
import { getCustomClass as L, getCustomStyle as W, withInstall as pe } from "../common/index.esm.js";
import { isPlainObject as _, cloneDeep as G } from "lodash-es";
import { resolveAppearance as ve } from "../dynamic-resolver/index.esm.js";
import { DgControl as Z } from "../designer-canvas/index.esm.js";
import be from "../response-toolbar/index.esm.js";
import { LocaleService as J } from "../locale/index.esm.js";
import { commonToolbarItemDesignProps as ge } from "../../designer/response-toolbar/index.esm.js";
function Q(e, t) {
let n;
function r(i) {
const { properties: l, title: f, ignore: o } = i, a = o && Array.isArray(o), s = Object.keys(l).reduce((b, v) => ((!a || !o.find((x) => x === v)) && (b[v] = l[v].type === "object" && l[v].properties ? r(l[v]) : G(l[v].default)), b), {});
if (f && (!a || !o.find((b) => b === "id"))) {
const b = f.toLowerCase().replace(/-/g, "_");
s.id = `${b}_${Math.random().toString().slice(2, 6)}`;
}
return s;
}
function c(i) {
const { properties: l, title: f, required: o } = i;
if (o && Array.isArray(o)) {
const a = o.reduce((s, b) => (s[b] = l[b].type === "object" && l[b].properties ? r(l[b]) : G(l[b].default), s), {});
if (f && o.find((s) => s === "id")) {
const s = f.toLowerCase().replace(/-/g, "_");
a.id = `${s}_${Math.random().toString().slice(2, 6)}`;
}
return a;
}
return {
type: f
};
}
function p(i, l = {}, f) {
const o = e[i];
if (o) {
let a = c(o);
const s = t[i];
return a = s ? s({ getSchemaByType: p }, a, l, f) : a, n != null && n.appendIdentifyForNewControl && n.appendIdentifyForNewControl(a), a;
}
return null;
}
function d(i, l) {
const f = r(l);
return Object.keys(f).reduce((o, a) => (Object.prototype.hasOwnProperty.call(i, a) && (o[a] && _(o[a]) && _(i[a] || !i[a]) ? Object.assign(o[a], i[a] || {}) : o[a] = i[a]), o), f), f;
}
function C(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 b = s(a, i[a], i);
Object.assign(o, b);
}
} else
o[a] = i[a];
return o;
}, {});
}
function S(i, l, f = /* @__PURE__ */ new Map()) {
const o = d(i, l);
return C(o, f);
}
function u(i) {
var f;
const l = i.type;
if (l) {
const o = e[l];
if (!o)
return i;
const a = d(i, o), s = ((f = i.editor) == null ? void 0 : f.type) || "";
if (s) {
const b = e[s], v = d(i.editor, b);
a.editor = v;
}
return a;
}
return i;
}
function m(i) {
n = i;
}
return { getSchemaByType: p, resolveSchemaWithDefaultValue: u, resolveSchemaToProps: S, mappingSchemaToProps: C, setDesignerContext: m };
}
const U = {}, X = {}, { resolveSchemaWithDefaultValue: ye, resolveSchemaToProps: Ce, mappingSchemaToProps: Se } = Q(U, X);
function Te(e = {}) {
function t(u, m, i, l) {
if (typeof i == "number")
return l[u].length === i;
if (typeof i == "object") {
const f = Object.keys(i)[0], o = i[f];
if (f === "not")
return Number(l[u].length) !== Number(o);
if (f === "moreThan")
return Number(l[u].length) >= Number(o);
if (f === "lessThan")
return Number(l[u].length) <= Number(o);
}
return !1;
}
function n(u, m, 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, m) => (u.set(m, e[m]), u), r);
function c(u, m) {
const i = u;
return typeof m == "number" ? [{ target: i, operator: "length", param: null, value: Number(m) }] : typeof m == "boolean" ? [{ target: i, operator: "getProperty", param: u, value: !!m }] : typeof m == "object" ? Object.keys(m).map((l) => {
if (l === "length")
return { target: i, operator: "length", param: null, value: m[l] };
const f = l, o = m[l];
return { target: i, operator: "getProperty", param: f, value: o };
}) : [];
}
function p(u) {
return Object.keys(u).reduce((i, l) => {
const f = c(l, u[l]);
return i.push(...f), i;
}, []);
}
function d(u, m) {
if (r.has(u.operator)) {
const i = r.get(u.operator);
return i && i(u.target, u.param, u.value, m) || !1;
}
return !1;
}
function C(u, m) {
return p(u).reduce((f, o) => f && d(o, m), !0);
}
function S(u, m) {
const i = Object.keys(u), l = i.includes("allOf"), f = i.includes("anyOf"), o = l || f, b = (o ? u[o ? l ? "allOf" : "anyOf" : "allOf"] : [u]).map((x) => C(x, m));
return l ? !b.includes(!1) : b.includes(!0);
}
return { parseValueSchema: S };
}
const Fe = {
convertTo: (e, t, n, r) => {
e.appearance || (e.appearance = {}), e.appearance[t] = n;
},
convertFrom: (e, t, n) => e.appearance ? e.appearance[t] : e[t]
}, he = {
convertFrom: (e, t, n) => e.buttons && e.buttons.length ? `共 ${e.buttons.length} 项` : "无"
}, xe = {
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: "列表导航" },
nav: { type: "nav", name: "标签类导航" },
"list-view": { type: "list-view", name: "列表" },
"filter-bar": { type: "filter-bar", name: "筛选条" },
"language-textbox": { type: "language-textbox", name: "多语输入框" },
image: { type: "image", name: "图像" },
avatar: { type: "avatar", name: "头像" },
"discussion-editor": { type: "discussion-editor", name: "评论编辑区" },
"discussion-list": { type: "discussion-list", name: "评论列表" },
comment: { type: "comment", name: "评论区" },
"approval-logs": { type: "approval-logs", 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: "动态表单" }
}, ke = {
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;
}
}, Oe = {
convertTo: (e, t, n, r) => {
e[t] = e[t];
},
convertFrom: (e, t, n) => e.editor ? n.getRealEditorType(e.editor.type) : ""
}, Pe = {
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";
}
return "none";
}
}, Re = {
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.formatter = "", 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: "link"
},
{
value: "remove",
text: "删除",
type: "link"
}
]), t === "enableType" && n === "unable" && (e.command.enable = !1, e.command.formatter = "");
},
convertFrom: (e, t, n) => {
var r, c;
if (e.command) {
if (t === "enableType") {
if (e.command.enableType)
return e.command.enableType;
const p = (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 ? p ? "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 "";
}
}, je = {
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 "";
}
}, Me = {
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 : "";
}
}, Ee = {
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;
}
}
}, ze = {
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;
}
}
}, Ae = {
convertTo: (e, t, n, r) => {
e.pagination || (e.pagination = {}), t === "sizeLimits" ? e.pagination.sizeLimits = n.split(",") : e.pagination[t] = n;
},
convertFrom: (e, t, n) => {
var r;
return e.pagination ? t === "sizeLimits" ? (r = e.pagination.sizeLimits) == null ? void 0 : r.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]
}, Le = {
convertTo: (e, t, n, r) => {
e.selection || (e.selection = {}), e.selection[t] = n;
},
convertFrom: (e, t, n) => {
if (!e.selection)
return !!e[t];
const r = !!e.selection[t];
return t === "showCheckbox" && r == null && e.selection.multiSelect === !0 ? !0 : r;
}
}, Ne = {
convertFrom: (e, t, n) => e[t] && e[t].length ? `共 ${e[t].length} 项` : ""
}, $e = {
convertFrom: (e, t) => e[t] || "",
convertTo: (e, t, n) => {
e[t] = n;
}
}, He = {
convertTo: (e, t, n, r) => {
e.size || (e.size = {}), e.size[t] = n;
},
convertFrom: (e, t, n) => e.size ? e.size[t] : e[t]
}, Be = {
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;
}
}, Ie = {
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);
}
}, qe = {
convertTo: (e, t, n, r) => {
e.filter || (e.filter = {}), e.filter[t] = n, t === "enable" && (e.enableFilter = !1);
},
convertFrom: (e, t, n) => {
var r, c, p, d;
return t === "mode" ? ((r = e.filter) == null ? void 0 : r.mode) || "server" : t === "filterStyle" ? ((c = e.filter) == null ? void 0 : c.filterStyle) || "filter-column" : t === "enable" ? ((p = e.filter) == null ? void 0 : p.enable) !== void 0 ? !!e.filter.enable : !!e.enableFilter : ((d = e.filter) == null ? void 0 : d[t]) || void 0;
}
}, We = {
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 "";
}
}, _e = {
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" : ""
}, Ge = {
convertTo: (e, t, n, r) => {
e.hierarchy || (e.hierarchy = {
cascadeOption: {}
}), e.hierarchy.cascadeOption || (e.hierarchy.cascadeOption = {}), e.hierarchy.cascadeOption[t] = n;
},
convertFrom: (e, t, n) => {
var r, c;
return !!((c = (r = e.hierarchy) == null ? void 0 : r.cascadeOption) != null && c[t]);
}
};
function Y(e, t, n) {
const r = /* @__PURE__ */ new Map([
["/converter/appearance.converter", Fe],
["/converter/buttons.converter", he],
["/converter/property-editor.converter", xe],
["/converter/items-count.converter", Ne],
["/converter/type.converter", ke],
["/converter/change-editor.converter", Oe],
["/converter/change-formatter.converter", Pe],
["/converter/column-command.converter", Re],
["/converter/column-option.converter", je],
["/converter/summary.converter", Me],
["/converter/group.converter", Ee],
["/converter/form-group-label.converter", $e],
["/converter/field-selector.converter", ze],
["/converter/pagination.converter", Ae],
["/converter/row-number.converter", De],
["/converter/grid-selection.converter", Le],
["/converter/size.converter", He],
["/converter/change-formatter-enum.converter", Be],
["/converter/grid-sort.converter", Ie],
["/converter/grid-filter.converter", qe],
["/converter/row-option.converter", We],
["/converter/change-formatter-type.converter", _e],
["/converter/tree-auto-check.converter", Ge]
]), 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" }]
]), p = Te();
function d(o, a) {
return () => p.parseValueSchema(o, a);
}
function C(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 S(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 m(o, a, s, b, v, x = "", h = "") {
return Object.keys(o).map((F) => {
const M = E(1), O = F, y = o[F], g = Object.keys(y), D = y.title, z = y.type, A = c.get(z) || { type: "input-group", enableClear: !1 }, j = y.editor ? Object.assign({}, A, y.editor) : Object.assign({}, A), H = C(g, y, a), N = S(g, y, a);
j.readonly = j.readonly === void 0 ? N() : j.readonly;
const B = y.type === "cascade" ? m(y.properties, a, s, b, v, x, h) : [], I = !0;
let P = u(y, h);
const ae = w({
get() {
if (M.value) {
if (["class", "style"].find(($) => $ === O) && !P && (P = r.get("/converter/appearance.converter") || null), P && P.convertFrom) {
const $ = P.convertFrom(s, F, v, x);
return $ === void 0 && Object.prototype.hasOwnProperty.call(y, "defaultValue") ? y.type === "boolean" ? y.defaultValue : y.defaultValue || "" : $;
}
const R = s[F];
return Object.prototype.hasOwnProperty.call(y, "defaultValue") && (R === void 0 || typeof R == "string" && R === "") ? y.type === "boolean" ? y.defaultValue : y.defaultValue || "" : R;
}
return null;
},
set(R) {
M.value += 1, P && P.convertTo ? (P.convertTo(b, F, R, v, x), P.convertTo(s, F, R, v, x)) : (b[F] = R, s[F] = R);
}
}), { refreshPanelAfterChanged: le, description: ce, isExpand: se, parentPropertyID: ue } = y, q = { propertyID: O, propertyName: D, propertyType: z, propertyValue: ae, editor: j, visible: H, readonly: N, cascadeConfig: B, hideCascadeTitle: I, refreshPanelAfterChanged: le, description: ce, isExpand: se, parentPropertyID: ue };
return a[O] = q, q;
});
}
function i(o, a, s = {}) {
const b = {}, v = e[o];
return v && v.categories ? Object.keys(v.categories).map((h) => {
const k = v.categories[h], F = k == null ? void 0 : k.title, M = m(k.properties || {}, b, {}, s, a);
return { categoryId: h, categoryName: F, properties: M };
}) : [];
}
function l(o, a, s, b, v = "") {
const x = a.$ref.schema, h = a.$ref.converter, k = s[x], F = k.type, M = n(k), O = {}, y = e[F];
if (y && y.categories) {
const g = y.categories[o], D = g == null ? void 0 : g.title;
h && Object.keys(g.properties).forEach((j) => {
g.properties[j].$converter = h;
});
const z = (g == null ? void 0 : g.properties) || {}, A = m(z, O, M, k, b, v);
return { categoryId: o, categoryName: D, properties: A };
}
return { categoryId: o, categoryName: "", properties: [] };
}
function f(o, a, s, b, v) {
const x = o.type, h = n(o), k = {};
let F = v || e[x];
if (!(F && Object.keys(F).length > 0) && s && s.getPropConfig && (F = s.getPropConfig(b)), F && F.categories) {
const O = [];
return Object.keys(F.categories).map((y) => {
const g = F.categories[y];
if (g.$ref) {
O.push(l(y, g, o, a, b));
return;
}
const D = g == null ? void 0 : g.title, z = g == null ? void 0 : g.tabId, A = g == null ? void 0 : g.tabName, j = g == null ? void 0 : g.hide, H = g == null ? void 0 : g.hideTitle, N = m(g.properties || {}, k, h, o, a, b, g.$converter), { setPropertyRelates: B } = g, I = g == null ? void 0 : g.parentPropertyID;
O.push({ categoryId: y, categoryName: D, tabId: z, tabName: A, hide: j, properties: N, hideTitle: H, setPropertyRelates: B, parentPropertyID: I });
}), O;
}
return [];
}
return {
getPropertyConfigBySchema: f,
getPropertyConfigByType: i,
propertyConverterMap: r
};
}
const V = {}, K = {};
Y(V, K, ye);
const ee = {}, te = {}, { resolveSchemaWithDefaultValue: Ze } = Q(ee, te), ne = {}, re = {};
Y(ne, re, Ze);
function Je(e, t, n = /* @__PURE__ */ new Map(), r = (d, C, S, u) => C, c = {}, p = (d) => d) {
return U[t.title] = t, X[t.title] = r, V[t.title] = c, K[t.title] = p, ee[t.title] = t, te[t.title] = r, ne[t.title] = c, re[t.title] = p, (d = {}, C = !0) => {
if (!C)
return Se(d, n);
const S = Ce(d, t, n), u = Object.keys(e).reduce((m, i) => (m[i] = e[i].default, m), {});
return Object.assign(u, S);
};
}
function Qe(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 Ue() {
function e(t, n) {
var C;
const r = (C = t.toolbar) == null ? void 0 : C.buttons;
if (!r || r.length < 1)
return null;
const [c, p] = n.payloads, d = Qe(r, p);
return d ? d.onClick || d.click : null;
}
return {
resolve: e
};
}
function Xe(e, t, n) {
return t ? { enableAccordion: t } : { enableAccordion: "" };
}
function Ye(e, t) {
var r, c;
const n = {
buttons: t.buttons,
buttonPosition: t.position,
buttonsVisible: t.visible
};
return (r = t.appearance) != null && r.class && (n.buttonsClass = (c = t.appearance) == null ? void 0 : c.class), n;
}
const Ve = /* @__PURE__ */ new Map([
["appearance", ve],
["expanded", "expandStatus"],
["enableAccordion", Xe],
["toolbar", Ye]
]);
function Ke(e, t) {
var p, d;
if (!(t != null && t.schema))
return;
const n = ((d = (p = t.schema) == null ? void 0 : p.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 et(e, t) {
var S;
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 p = e.getSchemaByType("content-container");
Object.assign(p, {
id: `container-${n}`,
appearance: {
class: "f-struct-wrapper"
},
contents: [c]
});
const d = r.schema, C = ((S = d.appearance) == null ? void 0 : S.class) || "";
switch (d && d.type) {
case Z["splitter-pane"].type: {
c.appearance.class = "f-section-in-main", C.includes("f-page-child-fill") && (p.appearance.class += " f-struct-wrapper-child", c.fill = !0);
break;
}
case Z["content-container"].type:
d.isLikeCardContainer && C.includes("f-struct-like-card-child-fill") && (p.appearance.class += " f-struct-wrapper-child", c.fill = !0);
}
return Ke(p, r), p;
}
function tt(e, t, n) {
return n.parentComponentInstance ? et(e, n) : t;
}
const nt = "https://json-schema.org/draft/2020-12/schema", rt = "https://farris-design.gitee.io/section.schema.json", ot = "section", it = "A Farris Container Component", at = "object", lt = {
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: ""
},
extendedAreaClass: {
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
},
extendedAreaHtml: {
description: "",
type: "string",
default: ""
},
extendedAreaRenderFunction: {
description: "",
type: "function",
default: null
},
footerClass: {
description: "",
type: "string",
default: ""
},
footerRenderFunction: {
description: "",
type: "function",
default: null
},
moreButtonClass: {
description: "���������˵�ʱ����ʽ",
type: "string",
default: "btn-secondary"
}
}, ct = [
"id",
"type",
"contents"
], st = {
$schema: nt,
$id: rt,
title: ot,
description: it,
type: at,
properties: lt,
required: ct
}, oe = {
/** 设置内容区域样式 */
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: "" },
/** 头部扩展区域的自定义样式。配置头部扩展区域模板后,此属性有效。 */
headerContentClass: { type: String, default: "" },
/** 设置是否启用最大化 */
enableMaximize: { type: Boolean, default: !1 },
/** 扩展区域的自定义样式。配置扩展区域模板后,此属性有效。 */
extendedAreaClass: { type: String, default: "" },
/** 扩展区域的自定义模版。 */
extendedAreaRenderFunction: { type: Function },
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: {} }
}, Tt = Je(oe, st, Ve, tt), Ft = Ue();
function ut(e, t, n) {
let r;
function c(S = 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"
], m = Array.from(document.body.querySelectorAll(u.join(","))).filter((l) => l).map((l) => {
const { display: f, zIndex: o } = window.getComputedStyle(l);
return f === "none" ? 0 : parseInt(o, 10);
}).filter((l) => l);
let i = Math.max(...m);
return i < 1040 && (i = 1040), i + S;
}
function p() {
r = e.value.nextElementSibling;
const S = document && document.querySelector("body");
S && (S.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 C() {
!e || !t.value || (n.value = !n.value, n.value ? p() : d());
}
return { onClickMaxMinIcon: C };
}
function ie(e, t) {
const n = E(e.buttons), r = w(() => e.buttonPosition === "inHead" ? "right" : "left"), c = w(() => "f-section-toolbar col-6" + (e.buttonPosition === "inHead" ? " f-toolbar f-section-header--toolbar" : " f-section-content--toolbar") + (e.buttonsClass ? " " + e.buttonsClass : "")), p = w(() => e.buttons && e.buttons.length > 0 && e.buttonPosition === "inHead");
function d(u, m) {
t.emit("click", u, m);
}
function C() {
return p.value && T(be, {
customClass: c.value,
items: n.value,
onClick: d,
alignment: r.value,
visible: e.buttonsVisible
}, null);
}
function S() {
return T("div", {
class: c.value
}, [T("div", {
class: "w-100",
style: "flex:1"
}, [e.toolbarRenderFunction()])]);
}
return () => e.toolbarRenderFunction ? S() : C();
}
function dt(e, t, n, r, c, p) {
const d = {
collapseLabel: J.getRealPropertyValue(e.collapseLabel, "收起", "section.collapseLabel"),
expandLabel: J.getRealPropertyValue(e.expandLabel, "展开", "section.expandLabel")
}, C = w(() => e.buttonPosition), S = ie(e, t), {
onClickMaxMinIcon: u
} = ut(r, c, p), m = w(() => e.enableMaximize), i = w(() => e.enableAccordion !== ""), l = w(() => L({
"f-section-header": !0
}, e.headerClass));
function f(h) {
h.stopPropagation(), e.enableAccordion !== "" && (n.value = !n.value);
}
function o() {
const h = w(() => ({
btn: !0,
"f-btn-collapse-expand": !0,
"f-btn-mx": !0,
"f-state-expand": n.value
})), k = w(() => ({
"f-icon": !0,
"f-icon-maximize": !p.value,
"f-icon-minimize": p.value
}));
return T("div", {
class: "f-max-accordion"
}, [m.value ? T("span", {
class: k.value,
onClick: u
}, null) : "", i.value ? T("button", {
class: h.value,
onClick: f
}, [T("span", null, [n.value ? d.collapseLabel : d.expandLabel])]) : ""]);
}
function a() {
return T("div", {
class: "f-title"
}, [T("h4", {
class: "f-title-text"
}, [e.mainTitle]), e.subTitle && T("span", null, [e.subTitle])]);
}
function s() {
const h = w(() => L({
"f-content": !0
}, e.headerContentClass));
return t.slots.headerContent ? T("div", {
class: h.value
}, [t.slots.headerContent()]) : e.headerContentRenderFunction ? T("div", {
class: h.value
}, [e.headerContentRenderFunction()]) : T("div", {
class: h.value
}, null);
}
function b() {
return t.slots.headerTitle ? t.slots.headerTitle() : e.headerTitleRenderFunction ? e.headerTitleRenderFunction() : a();
}
function v() {
return T("div", {
class: l.value
}, [b(), s(), C.value === "inHead" && S(), (m.value || i.value) && o()]);
}
function x() {
return t.slots.header ? T("div", {
class: l.value
}, [t.slots.header()]) : e.headerRenderFunction ? T("div", {
class: l.value
}, [e.headerRenderFunction()]) : v();
}
return () => e.showHeader && x();
}
const ft = /* @__PURE__ */ de({
name: "FSection",
props: oe,
emits: ["click"],
setup(e, t) {
const n = E(), r = E(), c = E(e.customClass), p = w(() => e.enableAccordion), d = E(e.expandStatus), C = w(() => e.buttonPosition), S = E(!1), u = dt(e, t, d, n, r, S), m = ie(e, t), i = w(() => {
const v = {
"f-section": !0,
"f-section-accordion": p.value === "default",
"f-state-collapse": p.value && !d.value,
"f-section-custom-accordion": p.value === "custom",
"f-section-fill": e.fill,
"f-section-maximize": S.value
};
return L(v, c.value);
}), l = w(() => L({
"f-section-content": !0
}, e.contentClass)), f = w(() => L({
"f-section-extend": !0
}, e.extendedAreaClass));
function o() {
if (t.slots.extend)
return T("div", {
class: f.value
}, [t.slots.extend()]);
if (e.extendedAreaRenderFunction)
return T("div", {
class: f.value
}, [e.extendedAreaRenderFunction()]);
}
function a() {
return T("div", {
class: l.value
}, [C.value === "inContent" && m(), t.slots.default && t.slots.default()]);
}
const s = w(() => {
const v = {};
return e.footerStyle ? typeof e.headerStyle == "function" ? W(v, e.footerStyle()) : W(v, e.footerStyle) : v;
});
function b() {
return t.slots.footer ? t.slots.footer && T("div", {
class: "f-section-footer " + e.footerClass,
style: s.value
}, [t.slots.footer()]) : e.footerRenderFunction ? T("div", {
class: "f-section-footer " + e.footerClass,
style: s.value
}, [e.footerRenderFunction()]) : null;
}
return fe(() => e.expandStatus, (v, x) => {
v !== x && (d.value = v);
}), me(() => {
n.value && n.value && (r.value = n.value.parentElement);
}), () => e.visible ? T("div", {
class: i.value,
ref: n,
style: e.customStyle
}, [u(), o(), a(), b()]) : null;
}
}), ht = Object.assign({}, ge), xt = pe(ft);
export {
ft as Section,
xt as default,
Ft as eventHandlerResolver,
Tt as propsResolver,
oe as sectionProps,
ht as sectionToolbarItemProps
};