@farris/ui-vue
Version:
Farris Vue, a Farris Design based Vue3 component library.
785 lines (784 loc) • 27 kB
JavaScript
import { ref as E, computed as V, defineComponent as U, provide as _, onMounted as fe, createVNode as h, createTextVNode as R, inject as L } from "vue";
import { FButtonEdit as me } from "../button-edit/index.esm.js";
import { cloneDeep as H, isPlainObject as G } from "lodash-es";
import { FPropertyPanel as pe } from "../property-panel/index.esm.js";
import { FTreeView as ve } from "../tree-view/index.esm.js";
function W(e, t) {
let n;
function a(r) {
const { properties: l, title: f, ignore: o } = r, i = o && Array.isArray(o), c = Object.keys(l).reduce((v, b) => ((!i || !o.find((F) => F === b)) && (v[b] = l[b].type === "object" && l[b].properties ? a(l[b]) : H(l[b].default)), v), {});
if (f && (!i || !o.find((v) => v === "id"))) {
const v = f.toLowerCase().replace(/-/g, "_");
c.id = `${v}_${Math.random().toString().slice(2, 6)}`;
}
return c;
}
function g(r) {
const { properties: l, title: f, required: o } = r;
if (o && Array.isArray(o)) {
const i = o.reduce((c, v) => (c[v] = l[v].type === "object" && l[v].properties ? a(l[v]) : H(l[v].default), c), {});
if (f && o.find((c) => c === "id")) {
const c = f.toLowerCase().replace(/-/g, "_");
i.id = `${c}_${Math.random().toString().slice(2, 6)}`;
}
return i;
}
return {
type: f
};
}
function C(r, l = {}, f) {
const o = e[r];
if (o) {
let i = g(o);
const c = t[r];
return i = c ? c({ getSchemaByType: C }, i, l, f) : i, n != null && n.appendIdentifyForNewControl && n.appendIdentifyForNewControl(i), i;
}
return null;
}
function y(r, l) {
const f = a(l);
return Object.keys(f).reduce((o, i) => (Object.prototype.hasOwnProperty.call(r, i) && (o[i] && G(o[i]) && G(r[i] || !r[i]) ? Object.assign(o[i], r[i] || {}) : o[i] = r[i]), o), f), f;
}
function T(r, l) {
return Object.keys(r).filter((o) => r[o] != null).reduce((o, i) => {
if (l.has(i)) {
const c = l.get(i);
if (typeof c == "string")
o[c] = r[i];
else {
const v = c(i, r[i], r);
Object.assign(o, v);
}
} else
o[i] = r[i];
return o;
}, {});
}
function m(r, l, f = /* @__PURE__ */ new Map()) {
const o = y(r, l);
return T(o, f);
}
function d(r) {
var f;
const l = r.type;
if (l) {
const o = e[l];
if (!o)
return r;
const i = y(r, o), c = ((f = r.editor) == null ? void 0 : f.type) || "";
if (c) {
const v = e[c], b = y(r.editor, v);
i.editor = b;
}
return i;
}
return r;
}
function p(r) {
n = r;
}
return { getSchemaByType: C, resolveSchemaWithDefaultValue: d, resolveSchemaToProps: m, mappingSchemaToProps: T, setDesignerContext: p };
}
const J = {}, Q = {}, { getSchemaByType: at, resolveSchemaWithDefaultValue: ge, resolveSchemaToProps: be, mappingSchemaToProps: ye, setDesignerContext: lt } = W(J, Q);
function Ce(e = {}) {
function t(d, p, r, l) {
if (typeof r == "number")
return l[d].length === r;
if (typeof r == "object") {
const f = Object.keys(r)[0], o = r[f];
if (f === "not")
return Number(l[d].length) !== Number(o);
if (f === "moreThan")
return Number(l[d].length) >= Number(o);
if (f === "lessThan")
return Number(l[d].length) <= Number(o);
}
return !1;
}
function n(d, p, r, l) {
return l[d] && l[d].propertyValue && String(l[d].propertyValue.value) === String(r);
}
const a = /* @__PURE__ */ new Map([
["length", t],
["getProperty", n]
]);
Object.keys(e).reduce((d, p) => (d.set(p, e[p]), d), a);
function g(d, p) {
const r = d;
return typeof p == "number" ? [{ target: r, operator: "length", param: null, value: Number(p) }] : typeof p == "boolean" ? [{ target: r, operator: "getProperty", param: d, value: !!p }] : typeof p == "object" ? Object.keys(p).map((l) => {
if (l === "length")
return { target: r, operator: "length", param: null, value: p[l] };
const f = l, o = p[l];
return { target: r, operator: "getProperty", param: f, value: o };
}) : [];
}
function C(d) {
return Object.keys(d).reduce((r, l) => {
const f = g(l, d[l]);
return r.push(...f), r;
}, []);
}
function y(d, p) {
if (a.has(d.operator)) {
const r = a.get(d.operator);
return r && r(d.target, d.param, d.value, p) || !1;
}
return !1;
}
function T(d, p) {
return C(d).reduce((f, o) => f && y(o, p), !0);
}
function m(d, p) {
const r = Object.keys(d), l = r.includes("allOf"), f = r.includes("anyOf"), o = l || f, v = (o ? d[o ? l ? "allOf" : "anyOf" : "allOf"] : [d]).map((F) => T(F, p));
return l ? !v.includes(!1) : v.includes(!0);
}
return { parseValueSchema: m };
}
const Fe = {
convertTo: (e, t, n, a) => {
e.appearance || (e.appearance = {}), e.appearance[t] = n;
},
convertFrom: (e, t, n) => e.appearance ? e.appearance[t] : e[t]
}, Se = {
convertFrom: (e, t, n) => e.buttons && e.buttons.length ? `共 ${e.buttons.length} 项` : "无"
}, Te = {
convertTo: (e, t, n, a) => {
e.editor && (e.editor[t] = n);
},
convertFrom: (e, t, n) => e.editor && Object.prototype.hasOwnProperty.call(e.editor, t) ? e.editor[t] : e[t]
}, he = {
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 g;
const a = e.editor && e.editor[t] ? e.editor[t] : e[t];
return ((g = he[a]) == null ? void 0 : g.name) || a;
}
}, Pe = {
convertTo: (e, t, n, a) => {
e[t] = e[t];
},
convertFrom: (e, t, n) => e.editor ? n.getRealEditorType(e.editor.type) : ""
}, Me = {
convertTo: (e, t, n, a) => {
(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";
}
}, Oe = {
convertTo: (e, t, n, a) => {
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 : ""
}, we = {
convertTo: (e, t, n, a) => {
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 "";
}
}, De = {
convertTo: (e, t, n, a) => {
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 : ""
}, Ee = {
convertTo: (e, t, n, a) => {
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;
}
}
}, Ne = {
convertFrom: (e, t) => e.binding ? e.binding.path : "",
convertTo: (e, t, n) => {
if (n && n.length > 0) {
const a = n[0];
e.binding || (e.binding = {}), e.binding.type = "Form", e.binding.path = a.bindingField, e.binding.field = a.id, e.binding.fullPath = a.path, e.path = a.bindingPath;
}
}
}, je = {
convertTo: (e, t, n, a) => {
e.pagination || (e.pagination = {}), e.pagination[t] = n;
},
convertFrom: (e, t, n) => e.pagination ? e.pagination[t] : e[t]
}, ke = {
convertTo: (e, t, n, a) => {
e.rowNumber || (e.rowNumber = {}), e.rowNumber[t] = n;
},
convertFrom: (e, t, n) => e.rowNumber ? e.rowNumber[t] : e[t]
}, $e = {
convertTo: (e, t, n, a) => {
e.selection || (e.selection = {}), e.selection[t] = n;
},
convertFrom: (e, t, n) => e.selection ? e.selection[t] : e[t]
}, Be = {
convertFrom: (e, t, n) => e[t] && e[t].length ? `共 ${e[t].length} 项` : ""
}, Re = {
convertFrom: (e, t) => e[t] || "",
convertTo: (e, t, n) => {
e[t] = n;
}
}, He = {
convertTo: (e, t, n, a) => {
e.size || (e.size = {}), e.size[t] = n;
},
convertFrom: (e, t, n) => e.size ? e.size[t] : e[t]
}, ze = {
convertFrom: (e, t, n) => {
var a, g;
return (a = e.formatter) != null && a.data && t === "formatterEnumData" && !e.formatterEnumData ? (g = e.formatter) == null ? void 0 : g.data : e.formatterEnumData;
}
}, Ae = {
convertTo: (e, t, n, a) => {
e.sort || (e.sort = {}), e.sort[t] = n;
},
convertFrom: (e, t, n) => {
var a, g;
if (t === "mode")
return ((a = e.sort) == null ? void 0 : a.mode) || "client";
if (t === "multiSort")
return !!((g = e.sort) != null && g.multiSort);
}
}, qe = {
convertTo: (e, t, n, a) => {
e.filter || (e.filter = {}), e.filter[t] = n;
},
convertFrom: (e, t, n) => {
var a;
if (t === "mode")
return ((a = e.filter) == null ? void 0 : a.mode) || "client";
}
}, Ve = {
convertTo: (e, t, n, a) => {
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 X(e, t, n) {
const a = /* @__PURE__ */ new Map([
["/converter/appearance.converter", Fe],
["/converter/buttons.converter", Se],
["/converter/property-editor.converter", Te],
["/converter/items-count.converter", Be],
["/converter/type.converter", xe],
["/converter/change-editor.converter", Pe],
["/converter/change-formatter.converter", Me],
["/converter/column-command.converter", Oe],
["/converter/column-option.converter", we],
["/converter/summary.converter", De],
["/converter/group.converter", Ee],
["/converter/form-group-label.converter", Re],
["/converter/field-selector.converter", Ne],
["/converter/pagination.converter", je],
["/converter/row-number.converter", ke],
["/converter/grid-selection.converter", $e],
["/converter/size.converter", He],
["/converter/change-formatter-enum.converter", ze],
["/converter/grid-sort.converter", Ae],
["/converter/grid-filter.converter", qe],
["/converter/row-option.converter", Ve]
]), g = /* @__PURE__ */ new Map([
["string", { type: "input-group", enableClear: !1 }],
["boolean", {
type: "combo-list",
textField: "name",
valueField: "value",
idField: "value",
enableClear: !1,
editable: !1,
data: [
{
value: !0,
name: "是"
},
{
value: !1,
name: "否"
}
]
}],
["enum", { type: "combo-list", maxHeight: 128, enableClear: !1, editable: !1 }],
["array", { type: "button-edit" }],
["number", { type: "number-spinner", placeholder: "" }],
["events-editor", { type: "events-editor", hide: !0 }]
]), C = Ce();
function y(o, i) {
return () => C.parseValueSchema(o, i);
}
function T(o, i, c) {
return o.includes("visible") && i.visible !== void 0 ? typeof i.visible == "boolean" ? () => !!i.visible : i.visible === void 0 ? !0 : y(i.visible, c) : () => !0;
}
function m(o, i, c) {
return o.includes("readonly") && i.readonly !== void 0 ? typeof i.readonly == "boolean" ? () => !!i.readonly : y(i.readonly, c) : () => !1;
}
function d(o, i) {
const c = o.$converter || i;
return typeof c == "string" && c && a.has(c) ? a.get(c) || null : c || null;
}
function p(o, i, c, v, b, F = "", M = "") {
return Object.keys(o).map((s) => {
const S = E(1), O = s, u = o[s], P = Object.keys(u), $ = u.title, j = u.type, k = g.get(j) || { type: "input-group", enableClear: !1 }, N = u.editor ? Object.assign({}, k, u.editor) : Object.assign({}, k), z = T(P, u, i), B = m(P, u, i);
N.readonly = N.readonly === void 0 ? B() : N.readonly;
const A = u.type === "cascade" ? p(u.properties, i, c, v, b, F, M) : [], ie = !0;
let w = d(u, M);
const ae = V({
get() {
if (S.value) {
if (["class", "style"].find((de) => de === O) && !w && (w = a.get("/converter/appearance.converter") || null), w && w.convertFrom)
return w.convertFrom(c, s, b, F);
const D = c[s];
return Object.prototype.hasOwnProperty.call(u, "defaultValue") && (D === void 0 || typeof D == "string" && D === "") ? u.type === "boolean" ? u.defaultValue : u.defaultValue || "" : D;
}
return null;
},
set(D) {
S.value += 1, w && w.convertTo ? (w.convertTo(v, s, D, b, F), w.convertTo(c, s, D, b, F)) : (v[s] = D, c[s] = D);
}
}), { refreshPanelAfterChanged: le, description: ce, isExpand: se, parentPropertyID: ue } = u, I = { propertyID: O, propertyName: $, propertyType: j, propertyValue: ae, editor: N, visible: z, readonly: B, cascadeConfig: A, hideCascadeTitle: ie, refreshPanelAfterChanged: le, description: ce, isExpand: se, parentPropertyID: ue };
return i[O] = I, I;
});
}
function r(o, i, c = {}) {
const v = {}, b = e[o];
return b && b.categories ? Object.keys(b.categories).map((M) => {
const x = b.categories[M], s = x == null ? void 0 : x.title, S = p(x.properties || {}, v, {}, c, i);
return { categoryId: M, categoryName: s, properties: S };
}) : [];
}
function l(o, i, c, v, b = "") {
const F = i.$ref.schema, M = i.$ref.converter, x = c[F], s = x.type, S = n(x), O = {}, u = e[s];
if (u && u.categories) {
const P = u.categories[o], $ = P == null ? void 0 : P.title;
M && Object.keys(P.properties).forEach((N) => {
P.properties[N].$converter = M;
});
const j = (P == null ? void 0 : P.properties) || {}, k = p(j, O, S, x, v, b);
return { categoryId: o, categoryName: $, properties: k };
}
return { categoryId: o, categoryName: "", properties: [] };
}
function f(o, i, c, v, b) {
const F = o.type, M = n(o), x = {};
let s = b || e[F];
if (s && Object.keys(s).length === 0 && c && c.getPropConfig && (s = c.getPropConfig(v)), s && s.categories) {
const S = [];
return Object.keys(s.categories).map((O) => {
const u = s.categories[O];
if (u.$ref) {
S.push(l(O, u, o, i, v));
return;
}
const P = u == null ? void 0 : u.title, $ = u == null ? void 0 : u.tabId, j = u == null ? void 0 : u.tabName, k = u == null ? void 0 : u.hide, N = u == null ? void 0 : u.hideTitle, z = p(u.properties || {}, x, M, o, i, v, u.$converter), { setPropertyRelates: B } = u, A = u == null ? void 0 : u.parentPropertyID;
S.push({ categoryId: O, categoryName: P, tabId: $, tabName: j, hide: k, properties: z, hideTitle: N, setPropertyRelates: B, parentPropertyID: A });
}), S;
}
return [];
}
return {
getPropertyConfigBySchema: f,
getPropertyConfigByType: r,
propertyConverterMap: a
};
}
const Y = {}, Z = {};
X(Y, Z, ge);
const K = {}, ee = {}, { getSchemaByType: ct, resolveSchemaWithDefaultValue: Ie, resolveSchemaToProps: st, mappingSchemaToProps: ut, setDesignerContext: dt } = W(K, ee), te = {}, ne = {};
X(te, ne, Ie);
function _e(e, t, n = /* @__PURE__ */ new Map(), a = (y, T, m, d) => T, g = {}, C = (y) => y) {
return J[t.title] = t, Q[t.title] = a, Y[t.title] = g, Z[t.title] = C, K[t.title] = t, ee[t.title] = a, te[t.title] = g, ne[t.title] = C, (y = {}, T = !0) => {
if (!T)
return ye(y, n);
const m = be(y, t, n), d = Object.keys(e).reduce((p, r) => (p[r] = e[r].default, p), {});
return Object.assign(d, m);
};
}
const Le = "https://json-schema.org/draft/2020-12/schema", Ge = "https://farris-design.gitee.io/collection-property-editor.schema.json", Ue = "collection-property-editor", We = "A Farris Component", Je = "object", Qe = {
id: {
description: "The unique identifier for collection-property-editor",
type: "string"
},
type: {
description: "The type string of collection-property-editor",
type: "string",
default: "collection-property-editor"
},
appearance: {
description: "",
type: "object",
properties: {
class: {
type: "string"
},
style: {
type: "string"
}
},
default: {}
},
modelValue: {
type: "array",
default: []
},
idField: {
type: "string",
default: "id"
},
textField: {
type: "string",
default: ""
},
defaultComponentSchema: {
type: "object",
default: {}
},
modalTitle: {
type: "string",
default: "编辑器"
}
}, Xe = [
"type"
], Ye = [
"id"
], Ze = {
$schema: Le,
$id: Ge,
title: Ue,
description: We,
type: Je,
properties: Qe,
required: Xe,
ignore: Ye
}, re = {
modelValue: {
type: Array,
default: []
},
idField: {
type: String,
default: "id"
},
textField: {
type: String,
default: ""
},
defaultComponentSchema: {
type: Object,
default: {}
},
isToolbarHidden: {
type: Boolean,
default: !1
},
useFormCommand: {
type: Object,
default: {}
},
useFormSchema: {
type: Object,
default: {}
}
}, oe = {
...re,
modalTitle: {
type: String,
default: "编辑器"
}
}, Ke = _e(oe, Ze), et = /* @__PURE__ */ U({
name: "CollectionPropertyContainer",
props: re,
emits: ["valueChange", "selectionChange"],
setup(e, t) {
const n = E(), a = E(), {
idField: g,
textField: C,
defaultComponentSchema: y,
isToolbarHidden: T
} = e, m = E(e.modelValue), d = E(), p = E("collection-property-editor");
_("useFormCommand", e.useFormCommand), _("useFormSchema", e.useFormSchema);
const r = E(), l = V(() => !m.value || m.value.length === 0), f = [{
field: C,
title: "名称",
width: 340,
resizable: !0,
dataType: "string"
}];
function o() {
const s = H(y), S = Math.random().toString().slice(2, 6);
return s[g] = s[g] + "_" + S, s[C] = s[C] + "_" + S, s;
}
function i() {
const s = o();
m.value.push(s), n.value.updateDataSource(m.value), n.value.selectItemById(s[g]);
}
function c() {
const s = m.value && m.value.length > 0 ? m.value[0] : null;
s && n.value.selectItemById(s[g]);
}
function v() {
const s = m.value.indexOf(r.value);
m.value.splice(s, 1), n.value.updateDataSource(m.value), c();
}
function b() {
if (!r.value)
return;
const s = m.value.indexOf(r.value);
s !== m.value.length - 1 && (m.value[s] = m.value[s + 1], m.value[s + 1] = r.value, n.value.updateDataSource(m.value));
}
function F() {
if (!r.value)
return;
const s = m.value.indexOf(r.value);
s !== 0 && (m.value[s] = m.value[s - 1], m.value[s - 1] = r.value, n.value.updateDataSource(m.value));
}
function M(s) {
r.value = s[0], t.emit("selectionChange", {
selectedData: r,
propertyConfig: d
}), a.value.updatePropertyConfig(d.value, r.value, !0);
}
function x() {
n.value.updateDataSource(m.value);
}
return fe(() => {
c();
}), () => h("div", {
class: "f-utils-fill-flex-column h-100 pt-2 pl-2 border-bottom"
}, [h("div", {
hidden: T,
class: "border-bottom pb-2"
}, [h("button", {
class: "btn btn-primary mr-2",
onClick: i
}, [R("新增")]), h("button", {
class: "btn btn-secondary mr-2",
onClick: v
}, [R("删除")]), h("button", {
class: "btn btn-secondary mr-2",
onClick: F
}, [R("上移")]), h("button", {
class: "btn btn-secondary mr-2",
onClick: b
}, [R("下移")])]), h("div", {
class: "f-utils-fill-flex-row"
}, [h("div", {
class: "f-utils-fill f-utils-overflow-auto"
}, [h(ve, {
ref: n,
columns: f,
data: m.value,
rowOption: {
disabledField: void 0
},
fit: "true",
idField: g,
onSelectionChange: M
}, null)]), h("div", {
hidden: l.value,
style: "height:550px;display: flex;"
}, [h(pe, {
propertyConfig: d.value,
ref: a,
propertyName: p.value,
enableSearch: !1,
onPropertyChanged: x
}, null)])])]);
}
}), q = /* @__PURE__ */ U({
name: "FCollectionPropertyEditor",
props: oe,
emits: ["valueChange", "selectionChange"],
setup(e, t) {
const n = E(), a = L("useFormCommand"), g = L("useFormSchema"), C = E(H(e.modelValue) || []), y = V(() => {
var r;
return `共 ${((r = C.value) == null ? void 0 : r.length) || 0} 项`;
});
function T() {
return t.emit("valueChange", C.value), !0;
}
function m() {
return !0;
}
function d({
selectedData: r,
propertyConfig: l
}) {
t.emit("selectionChange", {
selectedData: r,
propertyConfig: l
});
}
const p = {
title: e.modalTitle || "编辑器",
width: 650,
height: 700,
fitContent: !1,
showMaxButton: !0,
resizeable: !0,
draggable: !0,
enableEsc: !0,
buttons: [{
name: "cancel",
text: "取消",
class: "btn btn-secondary",
handle: m
}, {
name: "accept",
text: "确定",
class: "btn btn-primary",
handle: T
}]
};
return () => h(me, {
modelValue: y.value,
"onUpdate:modelValue": (r) => y.value = r,
editable: !1,
enableTitle: !0,
inputType: "text",
buttonBehavior: "Modal",
modalOptions: p
}, {
default: () => [h("div", {
class: "h-100 d-flex flex-column"
}, [h(et, {
ref: n,
modelValue: C.value,
"onUpdate:modelValue": (r) => C.value = r,
idField: e.idField,
textField: e.textField,
defaultComponentSchema: e.defaultComponentSchema,
onSelectionChange: d,
useFormCommand: a,
useFormSchema: g
}, null)])]
});
}
}), ft = {
install(e) {
e.component(q.name, q);
},
register(e, t, n, a) {
e["collection-property-editor"] = q, t["collection-property-editor"] = Ke;
}
};
export {
ft as default
};