@farris/ui-vue
Version:
Farris Vue, a Farris Design based Vue3 component library.
879 lines (878 loc) • 29.5 kB
JavaScript
import { ref as E, computed as F, defineComponent as B, provide as ge, createVNode as y, inject as J, onMounted as Q } from "vue";
import { cloneDeep as U, isPlainObject as W } from "lodash-es";
import { resolveAppearance as be, createPropsResolver as ye } from "../dynamic-resolver/index.esm.js";
import { getCustomClass as X } from "../common/index.esm.js";
import { useDesignerComponent as he } from "../designer-canvas/index.esm.js";
function Y(e, t) {
let n;
function o(s) {
const { properties: a, title: d, ignore: r } = s, i = r && Array.isArray(r), c = Object.keys(a).reduce((m, g) => ((!i || !r.find((T) => T === g)) && (m[g] = a[g].type === "object" && a[g].properties ? o(a[g]) : U(a[g].default)), m), {});
if (d && (!i || !r.find((m) => m === "id"))) {
const m = d.toLowerCase().replace(/-/g, "_");
c.id = `${m}_${Math.random().toString().slice(2, 6)}`;
}
return c;
}
function p(s) {
const { properties: a, title: d, required: r } = s;
if (r && Array.isArray(r)) {
const i = r.reduce((c, m) => (c[m] = a[m].type === "object" && a[m].properties ? o(a[m]) : U(a[m].default), c), {});
if (d && r.find((c) => c === "id")) {
const c = d.toLowerCase().replace(/-/g, "_");
i.id = `${c}_${Math.random().toString().slice(2, 6)}`;
}
return i;
}
return {
type: d
};
}
function v(s, a = {}, d) {
const r = e[s];
if (r) {
let i = p(r);
const c = t[s];
return i = c ? c({ getSchemaByType: v }, i, a, d) : i, n != null && n.appendIdentifyForNewControl && n.appendIdentifyForNewControl(i), i;
}
return null;
}
function b(s, a) {
const d = o(a);
return Object.keys(d).reduce((r, i) => (Object.prototype.hasOwnProperty.call(s, i) && (r[i] && W(r[i]) && W(s[i] || !s[i]) ? Object.assign(r[i], s[i] || {}) : r[i] = s[i]), r), d), d;
}
function C(s, a) {
return Object.keys(s).filter((r) => s[r] != null).reduce((r, i) => {
if (a.has(i)) {
const c = a.get(i);
if (typeof c == "string")
r[c] = s[i];
else {
const m = c(i, s[i], s);
Object.assign(r, m);
}
} else
r[i] = s[i];
return r;
}, {});
}
function S(s, a, d = /* @__PURE__ */ new Map()) {
const r = b(s, a);
return C(r, d);
}
function l(s) {
var d;
const a = s.type;
if (a) {
const r = e[a];
if (!r)
return s;
const i = b(s, r), c = ((d = s.editor) == null ? void 0 : d.type) || "";
if (c) {
const m = e[c], g = b(s.editor, m);
i.editor = g;
}
return i;
}
return s;
}
function f(s) {
n = s;
}
return { getSchemaByType: v, resolveSchemaWithDefaultValue: l, resolveSchemaToProps: S, mappingSchemaToProps: C, setDesignerContext: f };
}
const Z = {}, V = {}, { getSchemaByType: Tt, resolveSchemaWithDefaultValue: Ce, resolveSchemaToProps: Se, mappingSchemaToProps: Fe, setDesignerContext: wt } = Y(Z, V);
function Te(e = {}) {
function t(l, f, s, a) {
if (typeof s == "number")
return a[l].length === s;
if (typeof s == "object") {
const d = Object.keys(s)[0], r = s[d];
if (d === "not")
return Number(a[l].length) !== Number(r);
if (d === "moreThan")
return Number(a[l].length) >= Number(r);
if (d === "lessThan")
return Number(a[l].length) <= Number(r);
}
return !1;
}
function n(l, f, s, a) {
return a[l] && a[l].propertyValue && String(a[l].propertyValue.value) === String(s);
}
const o = /* @__PURE__ */ new Map([
["length", t],
["getProperty", n]
]);
Object.keys(e).reduce((l, f) => (l.set(f, e[f]), l), o);
function p(l, f) {
const s = l;
return typeof f == "number" ? [{ target: s, operator: "length", param: null, value: Number(f) }] : typeof f == "boolean" ? [{ target: s, operator: "getProperty", param: l, value: !!f }] : typeof f == "object" ? Object.keys(f).map((a) => {
if (a === "length")
return { target: s, operator: "length", param: null, value: f[a] };
const d = a, r = f[a];
return { target: s, operator: "getProperty", param: d, value: r };
}) : [];
}
function v(l) {
return Object.keys(l).reduce((s, a) => {
const d = p(a, l[a]);
return s.push(...d), s;
}, []);
}
function b(l, f) {
if (o.has(l.operator)) {
const s = o.get(l.operator);
return s && s(l.target, l.param, l.value, f) || !1;
}
return !1;
}
function C(l, f) {
return v(l).reduce((d, r) => d && b(r, f), !0);
}
function S(l, f) {
const s = Object.keys(l), a = s.includes("allOf"), d = s.includes("anyOf"), r = a || d, m = (r ? l[r ? a ? "allOf" : "anyOf" : "allOf"] : [l]).map((T) => C(T, f));
return a ? !m.includes(!1) : m.includes(!0);
}
return { parseValueSchema: S };
}
const we = {
convertTo: (e, t, n, o) => {
e.appearance || (e.appearance = {}), e.appearance[t] = n;
},
convertFrom: (e, t, n) => e.appearance ? e.appearance[t] : e[t]
}, $e = {
convertFrom: (e, t, n) => e.buttons && e.buttons.length ? `共 ${e.buttons.length} 项` : "无"
}, Pe = {
convertTo: (e, t, n, o) => {
e.editor && (e.editor[t] = n);
},
convertFrom: (e, t, n) => e.editor && Object.prototype.hasOwnProperty.call(e.editor, t) ? e.editor[t] : e[t]
}, Oe = {
button: { type: "button", name: "按钮" },
"response-toolbar": { type: "response-toolbar", name: "工具栏" },
"response-toolbar-item": { type: "response-toolbar-item", name: "按钮" },
"content-container": { type: "content-container", name: "容器" },
"input-group": { type: "input-group", name: "文本" },
textarea: { type: "textarea", name: "多行文本" },
lookup: { type: "lookup", name: "帮助" },
"number-spinner": { type: "number-spinner", name: "数值" },
"date-picker": { type: "date-picker", name: "日期" },
switch: { type: "switch", name: "开关" },
"radio-group": { type: "radio-group", name: "单选组" },
"check-box": { type: "check-box", name: "复选框" },
"check-group": { type: "check-group", name: "复选框组" },
"combo-list": { type: "combo-list", name: "下拉列表" },
"response-form": { type: "response-form", name: "卡片面板" },
"response-layout": { type: "response-layout", name: "布局容器", icon: "response-layout-3" },
"response-layout-item": { type: "response-layout-item", name: "布局", icon: "response-layout-1" },
"tree-grid": { type: "tree-grid", name: "树表格" },
"tree-grid-column": { type: "tree-grid-column", name: "树表格列" },
"data-grid": { type: "data-grid", name: "表格" },
"data-grid-column": { type: "data-grid-column", name: "表格列" },
module: { type: "Module", name: "模块" },
component: { type: "component", name: "组件" },
tabs: { type: "tabs", name: "标签页" },
"tab-page": { type: "tab-page", name: "标签页项", dependentParentControl: "Tab" },
"tab-toolbar-item": { type: "tab-toolbar-item", name: "标签页工具栏按钮" },
"html-template": { type: "html-template", name: "模板容器" },
"time-picker": { type: "time-picker", name: "时间选择" },
section: { type: "section", name: "分组面板" },
"section-toolbar": { type: "section-toolbar", name: "分组面板工具栏" },
"section-toolbar-item": { type: "section-toolbar-item", name: "分组面板按钮" },
splitter: { type: "splitter", name: "分栏面板" },
"splitter-pane": { type: "splitter-pane", name: "分栏面板项", dependentParentControl: "Splitter" },
"component-ref": { type: "component-ref", name: "组件引用节点" },
uploader: { type: "uploader", name: "附件上传" },
"page-header": { type: "page-header", name: "页头" },
"page-footer": { type: "page-footer", name: "页脚" },
"tab-toolbar": { type: "tab-toolbar", name: "标签页工具栏" },
fieldset: { type: "fieldset", name: "分组" },
"query-solution": { type: "query-solution", name: "筛选方案" },
drawer: { type: "drawer", name: "抽屉" },
"external-container": { type: "external-container", name: "外部容器", icon: "content-container" },
"list-nav": { type: "list-nav", name: "列表导航" },
"list-view": { type: "list-view", name: "列表" },
"filter-bar": { type: "filter-bar", name: "筛选条" },
"language-textbox": { type: "language-textbox", name: "多语输入框" }
}, xe = {
convertFrom: (e, t, n) => {
var p;
const o = e.editor && e.editor[t] ? e.editor[t] : e[t];
return ((p = Oe[o]) == null ? void 0 : p.name) || o;
}
}, je = {
convertTo: (e, t, n, o) => {
e[t] = e[t];
},
convertFrom: (e, t, n) => e.editor ? n.getRealEditorType(e.editor.type) : ""
}, Me = {
convertTo: (e, t, n, o) => {
(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 === "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";
}
}, De = {
convertTo: (e, t, n, o) => {
e.command ? e.command[t] = n : e.command = {
[t]: n
}, t === "enable" && n && (e.command.commands || (e.command.commands = [
{
text: "编辑",
type: "primary",
command: "edit"
},
{
text: "删除",
type: "danger",
command: "remove"
}
]));
},
convertFrom: (e, t, n) => e.command && t === "enable" ? e.command.enable : ""
}, Ee = {
convertTo: (e, t, n, o) => {
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 "";
}
}, Ne = {
convertTo: (e, t, n, o) => {
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) => e.summary && t === "enable" ? e.summary.enable : e.type === "data-grid-column" ? e.enableSummary === void 0 ? !1 : e.enableSummary : ""
}, ke = {
convertTo: (e, t, n, o) => {
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
});
},
convertFrom: (e, t, n) => {
if (e.group) {
if (t === "enable")
return e.group.enable;
if (t === "showSummary")
return e.group.showSummary;
}
}
}, Ae = {
convertFrom: (e, t) => e.binding ? e.binding.path : "",
convertTo: (e, t, n) => {
if (n && n.length > 0) {
const o = n[0];
e.binding || (e.binding = {}), e.binding.type = "Form", e.binding.path = o.bindingField, e.binding.field = o.id, e.binding.fullPath = o.path, e.path = o.bindingPath;
}
}
}, He = {
convertTo: (e, t, n, o) => {
e.pagination || (e.pagination = {}), e.pagination[t] = n;
},
convertFrom: (e, t, n) => e.pagination ? e.pagination[t] : e[t]
}, Re = {
convertTo: (e, t, n, o) => {
e.rowNumber || (e.rowNumber = {}), e.rowNumber[t] = n;
},
convertFrom: (e, t, n) => e.rowNumber ? e.rowNumber[t] : e[t]
}, Be = {
convertTo: (e, t, n, o) => {
e.selection || (e.selection = {}), e.selection[t] = n;
},
convertFrom: (e, t, n) => e.selection ? e.selection[t] : e[t]
}, Ie = {
convertFrom: (e, t, n) => e[t] && e[t].length ? `共 ${e[t].length} 项` : ""
}, qe = {
convertFrom: (e, t) => e[t] || "",
convertTo: (e, t, n) => {
e[t] = n;
}
}, ze = {
convertTo: (e, t, n, o) => {
e.size || (e.size = {}), e.size[t] = n;
},
convertFrom: (e, t, n) => e.size ? e.size[t] : e[t]
}, Le = {
convertFrom: (e, t, n) => {
var o, p;
return (o = e.formatter) != null && o.data && t === "formatterEnumData" && !e.formatterEnumData ? (p = e.formatter) == null ? void 0 : p.data : e.formatterEnumData;
}
}, _e = {
convertTo: (e, t, n, o) => {
e.sort || (e.sort = {}), e.sort[t] = n;
},
convertFrom: (e, t, n) => {
var o, p;
if (t === "mode")
return ((o = e.sort) == null ? void 0 : o.mode) || "client";
if (t === "multiSort")
return !!((p = e.sort) != null && p.multiSort);
}
}, Ge = {
convertTo: (e, t, n, o) => {
e.filter || (e.filter = {}), e.filter[t] = n;
},
convertFrom: (e, t, n) => {
var o;
if (t === "mode")
return ((o = e.filter) == null ? void 0 : o.mode) || "client";
}
}, Ue = {
convertTo: (e, t, n, o) => {
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;
}
return "";
}
};
function K(e, t, n) {
const o = /* @__PURE__ */ new Map([
["/converter/appearance.converter", we],
["/converter/buttons.converter", $e],
["/converter/property-editor.converter", Pe],
["/converter/items-count.converter", Ie],
["/converter/type.converter", xe],
["/converter/change-editor.converter", je],
["/converter/change-formatter.converter", Me],
["/converter/column-command.converter", De],
["/converter/column-option.converter", Ee],
["/converter/summary.converter", Ne],
["/converter/group.converter", ke],
["/converter/form-group-label.converter", qe],
["/converter/field-selector.converter", Ae],
["/converter/pagination.converter", He],
["/converter/row-number.converter", Re],
["/converter/grid-selection.converter", Be],
["/converter/size.converter", ze],
["/converter/change-formatter-enum.converter", Le],
["/converter/grid-sort.converter", _e],
["/converter/grid-filter.converter", Ge],
["/converter/row-option.converter", Ue]
]), p = /* @__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 }]
]), v = Te();
function b(r, i) {
return () => v.parseValueSchema(r, i);
}
function C(r, i, c) {
return r.includes("visible") && i.visible !== void 0 ? typeof i.visible == "boolean" ? () => !!i.visible : i.visible === void 0 ? !0 : b(i.visible, c) : () => !0;
}
function S(r, i, c) {
return r.includes("readonly") && i.readonly !== void 0 ? typeof i.readonly == "boolean" ? () => !!i.readonly : b(i.readonly, c) : () => !1;
}
function l(r, i) {
const c = r.$converter || i;
return typeof c == "string" && c && o.has(c) ? o.get(c) || null : c || null;
}
function f(r, i, c, m, g, T = "", P = "") {
return Object.keys(r).map((h) => {
const O = E(1), x = h, u = r[h], w = Object.keys(u), H = u.title, N = u.type, k = p.get(N) || { type: "input-group", enableClear: !1 }, D = u.editor ? Object.assign({}, k, u.editor) : Object.assign({}, k), I = C(w, u, i), R = S(w, u, i);
D.readonly = D.readonly === void 0 ? R() : D.readonly;
const q = u.type === "cascade" ? f(u.properties, i, c, m, g, T, P) : [], le = !0;
let j = l(u, P);
const ue = F({
get() {
if (O.value) {
if (["class", "style"].find((ve) => ve === x) && !j && (j = o.get("/converter/appearance.converter") || null), j && j.convertFrom)
return j.convertFrom(c, h, g, T);
const M = c[h];
return Object.prototype.hasOwnProperty.call(u, "defaultValue") && (M === void 0 || typeof M == "string" && M === "") ? u.type === "boolean" ? u.defaultValue : u.defaultValue || "" : M;
}
return null;
},
set(M) {
O.value += 1, j && j.convertTo ? (j.convertTo(m, h, M, g, T), j.convertTo(c, h, M, g, T)) : (m[h] = M, c[h] = M);
}
}), { refreshPanelAfterChanged: de, description: fe, isExpand: me, parentPropertyID: pe } = u, G = { propertyID: x, propertyName: H, propertyType: N, propertyValue: ue, editor: D, visible: I, readonly: R, cascadeConfig: q, hideCascadeTitle: le, refreshPanelAfterChanged: de, description: fe, isExpand: me, parentPropertyID: pe };
return i[x] = G, G;
});
}
function s(r, i, c = {}) {
const m = {}, g = e[r];
return g && g.categories ? Object.keys(g.categories).map((P) => {
const $ = g.categories[P], h = $ == null ? void 0 : $.title, O = f($.properties || {}, m, {}, c, i);
return { categoryId: P, categoryName: h, properties: O };
}) : [];
}
function a(r, i, c, m, g = "") {
const T = i.$ref.schema, P = i.$ref.converter, $ = c[T], h = $.type, O = n($), x = {}, u = e[h];
if (u && u.categories) {
const w = u.categories[r], H = w == null ? void 0 : w.title;
P && Object.keys(w.properties).forEach((D) => {
w.properties[D].$converter = P;
});
const N = (w == null ? void 0 : w.properties) || {}, k = f(N, x, O, $, m, g);
return { categoryId: r, categoryName: H, properties: k };
}
return { categoryId: r, categoryName: "", properties: [] };
}
function d(r, i, c, m, g) {
const T = r.type, P = n(r), $ = {};
let h = g || e[T];
if (h && Object.keys(h).length === 0 && c && c.getPropConfig && (h = c.getPropConfig(m)), h && h.categories) {
const O = [];
return Object.keys(h.categories).map((x) => {
const u = h.categories[x];
if (u.$ref) {
O.push(a(x, u, r, i, m));
return;
}
const w = u == null ? void 0 : u.title, H = u == null ? void 0 : u.tabId, N = u == null ? void 0 : u.tabName, k = u == null ? void 0 : u.hide, D = u == null ? void 0 : u.hideTitle, I = f(u.properties || {}, $, P, r, i, m, u.$converter), { setPropertyRelates: R } = u, q = u == null ? void 0 : u.parentPropertyID;
O.push({ categoryId: x, categoryName: w, tabId: H, tabName: N, hide: k, properties: I, hideTitle: D, setPropertyRelates: R, parentPropertyID: q });
}), O;
}
return [];
}
return {
getPropertyConfigBySchema: d,
getPropertyConfigByType: s,
propertyConverterMap: o
};
}
const ee = {}, te = {};
K(ee, te, Ce);
const ne = {}, re = {}, { getSchemaByType: $t, resolveSchemaWithDefaultValue: We, resolveSchemaToProps: Pt, mappingSchemaToProps: Ot, setDesignerContext: xt } = Y(ne, re), oe = {}, ie = {};
K(oe, ie, We);
function Je(e, t, n = /* @__PURE__ */ new Map(), o = (b, C, S, l) => C, p = {}, v = (b) => b) {
return Z[t.title] = t, V[t.title] = o, ee[t.title] = p, te[t.title] = v, ne[t.title] = t, re[t.title] = o, oe[t.title] = p, ie[t.title] = v, (b = {}, C = !0) => {
if (!C)
return Fe(b, n);
const S = Se(b, t, n), l = Object.keys(e).reduce((f, s) => (f[s] = e[s].default, f), {});
return Object.assign(l, S);
};
}
const se = /* @__PURE__ */ new Map([
["appearance", be],
["size", (e, t) => {
const n = {};
return t.width && (n.width = Number(t.width)), t.height && (n.height = Number(t.height)), n;
}]
]), Qe = "https://json-schema.org/draft/2020-12/schema", Xe = "https://farris-design.gitee.io/accordion.schema.json", Ye = "accordion", Ze = "A Farris Container Component", Ve = "object", Ke = {
id: {
description: "The unique identifier for a Accordion",
type: "string"
},
type: {
description: "The type string of Accordion component",
type: "string",
default: "accordion"
},
appearance: {
description: "",
type: "object",
properties: {
class: {
type: "string"
},
style: {
type: "string"
}
},
default: {}
},
contents: {
description: "",
type: "array",
default: []
},
customClass: {
description: "",
type: "string",
default: ""
},
size: {
description: "",
type: "object",
properties: {
width: {
type: "number"
},
height: {
type: "number"
}
},
default: null
},
enableFold: {
description: "",
type: "boolean",
default: !0
},
expanded: {
description: "",
type: "boolean",
default: !1
}
}, et = [
"id",
"type",
"contents"
], tt = {
$schema: Qe,
$id: Xe,
title: Ye,
description: Ze,
type: Ve,
properties: Ke,
required: et
};
function nt(e, t, n) {
return t;
}
const rt = "accordion", ot = "A Farris Component", it = "object", st = {
basic: {
description: "Basic Infomation",
title: "基本信息",
properties: {
id: {
description: "组件标识",
title: "标识",
type: "string",
readonly: !0
},
type: {
description: "组件类型",
title: "控件类型",
type: "select",
editor: {
type: "waiting for modification",
enum: []
}
}
}
}
}, at = {
title: rt,
description: ot,
type: it,
categories: st
}, L = {
customClass: { type: String, default: "" },
enableFold: { type: Boolean, default: !0 },
expanded: { type: Boolean, default: !1 },
height: { type: Number },
width: { type: Number }
}, ae = Je(L, tt, se, nt, at), A = /* @__PURE__ */ B({
name: "FAccordion",
props: L,
emits: [],
setup(e, t) {
const n = F(() => ({
height: e.height ? `${e.height}px` : "",
width: e.width ? `${e.width}px` : ""
}));
ge("accordionContext", {
parentProps: e
});
const o = F(() => X({
"farris-panel": !0,
accordion: !0
}, e.customClass));
return () => y("div", {
class: o.value,
style: n.value
}, [t.slots.default && t.slots.default()]);
}
}), ct = "https://json-schema.org/draft/2020-12/schema", lt = "https://farris-design.gitee.io/accordion-item.schema.json", ut = "AccordionItem", dt = "A Farris Container Component", ft = "object", mt = {
id: {
description: "The unique identifier for a Accordion Item",
type: "string"
},
type: {
description: "The type string of Accordion Item component",
type: "string"
},
contents: {
description: "",
type: "array",
default: []
},
size: {
description: "",
type: "object",
properties: {
width: {
type: "number"
},
height: {
type: "number"
}
},
default: null
},
title: {
description: "",
type: "string",
default: ""
},
disable: {
description: "",
type: "boolean",
default: !1
}
}, pt = [
"id",
"type",
"contents"
], vt = {
$schema: ct,
$id: lt,
title: ut,
description: dt,
type: ft,
properties: mt,
required: pt
}, _ = {
active: { type: Boolean, default: !1 },
customClass: { type: String, default: "" },
disabled: { type: Boolean, default: !1 },
enableFold: { type: Boolean, default: !0 },
height: { type: Number },
iconUri: { type: String, default: "" },
maxHeight: { type: Number },
title: { type: String, default: "" },
width: { type: Number }
}, ce = ye(_, vt, se), z = /* @__PURE__ */ B({
name: "FAccordionItem",
props: _,
emits: ["ClickHeader"],
setup(e, t) {
const n = E(), o = J("accordionContext"), p = E(e.title), v = E(e.active), b = F(() => {
var r;
return !!((r = o == null ? void 0 : o.parentProps) != null && r.enableFold) && e.enableFold;
});
function C() {
e.disabled || !b.value || (v.value = !v.value);
}
function S(r) {
t.emit("ClickHeader"), C();
}
const l = F(() => {
const r = {
card: !0,
"farris-panel-item": !0,
"f-state-disabled": e.disabled,
"f-state-selected": v.value
};
return X(r, e.customClass);
}), f = F(() => !0), s = F(() => ({
"f-icon": !0,
"f-accordion-collapse": !v.value,
"f-accordion-expand": v.value
}));
function a() {
return n.value ? n.value.getBoundingClientRect().height : 0;
}
const d = F(() => {
const r = e.maxHeight ? {
transition: "maxHeight 0.36s ease 0s",
"max-height": v.value ? `${e.maxHeight}px` : 0
} : {
transition: "height 0.36s ease 0s",
height: v.value ? `${a()}px` : 0
};
return v.value || (r.overflow = "hidden"), r;
});
return Q(() => {
var r;
(r = o == null ? void 0 : o.parentProps) != null && r.expanded && (v.value = !0);
}), () => y("div", {
class: l.value
}, [y("div", {
class: "card-header",
onClick: S
}, [y("div", {
class: "panel-item-title"
}, [e.iconUri && y("img", {
class: "panel-item-title-image",
src: e.iconUri,
title: "title-icon"
}, null), f.value && y("span", null, [p.value]), t.slots.head && t.slots.head(), b.value && y("i", {
class: s.value
}, null)]), y("div", {
class: "panel-item-tool"
}, [t.slots.toolbar && t.slots.toolbar()]), y("div", {
class: "panel-item-clear"
}, null)]), y("div", {
style: d.value
}, [y("div", {
class: "card-body",
ref: n
}, [t.slots.default && t.slots.default()])])]);
}
}), gt = /* @__PURE__ */ B({
name: "FAccordionDesign",
props: L,
emits: [],
setup(e, t) {
const n = F(() => ({
height: e.height ? `${e.height}px` : "",
width: e.width ? `${e.width}px` : ""
})), o = F(() => {
const C = e.customClass.split(" "), S = {
"farris-panel": !0,
accordion: !0
};
return C.reduce((l, f) => (l[f] = !0, l), S), S;
}), p = E(), v = J("design-item-context"), b = he(p, v);
return Q(() => {
p.value.componentInstance = b;
}), t.expose(b.value), () => y("div", {
ref: p,
class: o.value,
style: n.value
}, [t.slots.default && t.slots.default()]);
}
}), bt = /* @__PURE__ */ B({
name: "FAccordionItemDesign",
props: _,
emits: [],
setup(e, t) {
const n = E(e.title), o = E(!1), p = E(!1);
function v() {
o.value = !o.value;
}
function b(i) {
v();
}
const C = F(() => ({
"f-state-disabled": p.value,
card: !0,
"farris-panel-item": !0,
"f-state-selected": o.value
})), S = F(() => !0), l = F(() => !1), f = F(() => ({
"f-icon": !0,
"f-accordion-collapse": !o.value,
"f-accordion-expand": o.value
})), s = F(() => {
const i = e.maxHeight ? {
transition: "maxHeight 0.36s ease 0s",
"max-height": o.value ? `${e.maxHeight}px` : 0
} : {
transition: "height 0.36s ease 0s",
height: o.value ? `${e.height}px` : 0
};
return o.value || (i.overflow = "hidden"), i;
});
function a() {
return !0;
}
function d() {
return !1;
}
function r() {
return !0;
}
return t.expose({
canMove: a(),
canSelectParent: d(),
canDelete: r(),
canNested: !0
}), () => y("div", {
class: C.value
}, [y("div", {
class: "card-header",
onClick: b
}, [y("div", {
class: "panel-item-title"
}, [S.value && y("span", null, [n.value]), l.value && t.slots.head && t.slots.head(), y("span", {
class: f.value
}, null)]), y("div", {
class: "panel-item-tool"
}, [t.slots.toolbar && t.slots.toolbar()]), y("div", {
class: "panel-item-clear"
}, null)]), y("div", {
style: s.value
}, [y("div", {
class: "card-body drag-container"
}, [t.slots.default && t.slots.default()])])]);
}
});
A.install = (e) => {
e.component(A.name, A), e.component(z.name, z);
};
A.register = (e, t, n, o) => {
e.accordion = A, e["accordion-item"] = z, t.accordion = ae, t["accordion-item"] = ce;
};
A.registerDesigner = (e, t, n) => {
e.accordion = gt, e["accordion-item"] = bt, t.accordion = ae, t["accordion-item"] = ce;
};
export {
A as FAccordion,
z as FAccordionItem,
_ as accordionItemProps,
ce as accordionItemPropsResolver,
L as accordionProps,
ae as accordionPropsResolver,
A as default
};