@farris/ui-vue
Version:
Farris Vue, a Farris Design based Vue3 component library.
1,744 lines • 486 kB
JavaScript
var Bi = Object.defineProperty;
var Ei = (t, e, n) => e in t ? Bi(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
var U = (t, e, n) => Ei(t, typeof e != "symbol" ? e + "" : e, n);
import { ref as b, watch as Te, createVNode as _, createTextVNode as Ct, computed as D, defineComponent as je, Fragment as gt, reactive as ht, createApp as dn, onUnmounted as Vt, onMounted as it, Transition as Un, mergeProps as wt, onBeforeUnmount as qn, withDirectives as fn, resolveDirective as Vi, nextTick as St, inject as ot, provide as Oi, triggerRef as Pi, isVNode as Yn, onBeforeMount as $i, Teleport as Xn, shallowRef as Ri, render as Qt, h as Di, cloneVNode as Ni, Comment as Li, vShow as ji, withModifiers as Hi, vModelText as Ai } from "vue";
import { isPlainObject as $n, cloneDeep as vt, isUndefined as Rn } from "lodash-es";
import "bignumber.js";
import { getCustomClass as Zt, withInstall as Wi, FormSchemaEntityField$Type as nn, FormSchemaEntityFieldType$Type as Gi, useDateFormat as zi, useNumberFormat as Ui, resolveField as ct, setFieldValue as on } from "../common/index.esm.js";
import { useResizeObserver as Yt } from "@vueuse/core";
import "../modal/index.esm.js";
import qi from "../transfer/index.esm.js";
import Yi from "../tabs/index.esm.js";
import Xi from "../order/index.esm.js";
import "../condition/index.esm.js";
import Ji, { FCheckbox as Xt } from "../checkbox/index.esm.js";
import Ki from "../filter-bar/index.esm.js";
import Dn from "../tooltip/index.esm.js";
import Qi from "../pagination/index.esm.js";
import Zi from "../button/index.esm.js";
import el from "../search-box/index.esm.js";
import Jn from "../tags/index.esm.js";
import tl, { FDynamicFormGroup as nl, FDynamicFormInput as ol } from "../dynamic-form/index.esm.js";
import { DgControl as Nn } from "../designer-canvas/index.esm.js";
import { useIdentify as pn, useGroupData as mn, useFilter as hn, useHierarchy as gn, useLoading as Kn, useDataView as vn, useSelection as yn, useSelectHierarchyItem as il, useDataViewContainerStyle as Qn, useCommandColumn as Zn, useColumn as eo, useSort as to, useGroupColumn as no, useRow as bn, useEdit as Cn, useVisualDataBound as wn, useVisualDataCell as Sn, useVisualDataRow as Fn, useVisualData as Tn, useCellPosition as oo, useSidebar as io, useVirtualScroll as lo, useFitColumn as ao, useFilterHistory as ro, useColumnFilter as so, useDragColumn as uo, getColumnHeader as co, getSidebar as fo, getDisableMask as po, getHorizontalScrollbar as mo, getVerticalScrollbar as ho, getEmpty as go, usePagination as ll, useVisualGroupRow as vo, useVisualSummaryRow as yo, useCellContentStyle as al, getPagination as rl, getSummary as sl, getFilterPanel as ul, getGroupPanel as cl, useNavigation as dl } from "../data-view/index.esm.js";
import fl from "../accordion/index.esm.js";
import pl from "../avatar/index.esm.js";
import ml from "../button-edit/index.esm.js";
import hl from "../button-group/index.esm.js";
import gl from "../calendar/index.esm.js";
import vl from "../capsule/index.esm.js";
import yl from "../color-picker/index.esm.js";
import ln from "../combo-list/index.esm.js";
import bl from "../content-container/index.esm.js";
import Cl from "../data-grid/index.esm.js";
import wl from "../date-picker/index.esm.js";
import Sl from "../dropdown/index.esm.js";
import "../external-container/index.esm.js";
import Fl from "../events-editor/index.esm.js";
import Tl from "../image-cropper/index.esm.js";
import xl from "../input-group/index.esm.js";
import _l from "../layout/index.esm.js";
import Ml from "../list-nav/index.esm.js";
import Il from "../list-view/index.esm.js";
import kl from "../lookup/index.esm.js";
import Bl from "../nav/index.esm.js";
import El from "../number-spinner/index.esm.js";
import Vl from "../number-range/index.esm.js";
import Ol from "../page-header/index.esm.js";
import Pl from "../page-footer/index.esm.js";
import $l from "../progress/index.esm.js";
import Rl from "../query-solution/index.esm.js";
import Dl from "../radio-group/index.esm.js";
import Nl from "../rate/index.esm.js";
import Ll from "../response-toolbar/index.esm.js";
import jl from "../response-layout/index.esm.js";
import Hl from "../response-layout-editor/index.esm.js";
import Al from "../section/index.esm.js";
import Wl from "../smoke-detector/index.esm.js";
import Gl from "../splitter/index.esm.js";
import zl from "../step/index.esm.js";
import Ul from "../switch/index.esm.js";
import ql from "../text/index.esm.js";
import Yl from "../time-picker/index.esm.js";
import bo from "../tree-view/index.esm.js";
import Xl from "../uploader/index.esm.js";
import Jl from "../verify-detail/index.esm.js";
import Kl from "../component/index.esm.js";
import Ql from "../video/index.esm.js";
import Zl from "../textarea/index.esm.js";
import ea from "../tree-grid/index.esm.js";
import ta from "../fieldset/index.esm.js";
import na from "../drawer/index.esm.js";
import oa from "../binding-selector/index.esm.js";
import "../notify/index.esm.js";
import ia from "../combo-tree/index.esm.js";
import la from "../field-selector/index.esm.js";
import aa from "../mapping-editor/index.esm.js";
import ra from "../schema-selector/index.esm.js";
import sa from "../event-parameter/index.esm.js";
import ua from "../filter-condition-editor/index.esm.js";
import ca from "../sort-condition-editor/index.esm.js";
import da from "../menu-lookup/index.esm.js";
import { createPropsResolver as fa, resolveAppearance as pa } from "../dynamic-resolver/index.esm.js";
import ma from "../popover/index.esm.js";
const Co = {}, wo = {};
function xn(t) {
const { properties: e, title: n, ignore: o } = t, i = o && Array.isArray(o), l = Object.keys(e).reduce((a, r) => ((!i || !o.find((s) => s === r)) && (a[r] = e[r].type === "object" && e[r].properties ? xn(e[r]) : vt(e[r].default)), a), {});
if (n && (!i || !o.find((a) => a === "id"))) {
const a = n.toLowerCase().replace(/-/g, "_");
l.id = `${a}_${Math.random().toString().slice(2, 6)}`;
}
return l;
}
function ha(t) {
const { properties: e, title: n, required: o } = t;
if (o && Array.isArray(o)) {
const i = o.reduce((l, a) => (l[a] = e[a].type === "object" && e[a].properties ? xn(e[a]) : vt(e[a].default), l), {});
if (n && o.find((l) => l === "id")) {
const l = n.toLowerCase().replace(/-/g, "_");
i.id = `${l}_${Math.random().toString().slice(2, 6)}`;
}
return i;
}
return {
type: n
};
}
function So(t, e = {}, n) {
const o = Co[t];
if (o) {
let i = ha(o);
const l = wo[t];
return i = l ? l({ getSchemaByType: So }, i, e, n) : i, i;
}
return null;
}
function ga(t, e) {
const n = xn(e);
return Object.keys(n).reduce((o, i) => (Object.prototype.hasOwnProperty.call(t, i) && (o[i] && $n(o[i]) && $n(t[i] || !t[i]) ? Object.assign(o[i], t[i] || {}) : o[i] = t[i]), o), n), n;
}
function Fo(t, e) {
return Object.keys(t).filter((o) => t[o] != null).reduce((o, i) => {
if (e.has(i)) {
const l = e.get(i);
if (typeof l == "string")
o[l] = t[i];
else {
const a = l(i, t[i], t);
Object.assign(o, a);
}
} else
o[i] = t[i];
return o;
}, {});
}
function va(t, e, n = /* @__PURE__ */ new Map()) {
const o = ga(t, e);
return Fo(o, n);
}
function ya(t = {}) {
function e(d, f, u, c) {
if (typeof u == "number")
return c[d].length === u;
if (typeof u == "object") {
const h = Object.keys(u)[0], g = u[h];
if (h === "not")
return Number(c[d].length) !== Number(g);
if (h === "moreThan")
return Number(c[d].length) >= Number(g);
if (h === "lessThan")
return Number(c[d].length) <= Number(g);
}
return !1;
}
function n(d, f, u, c) {
return c[d] && c[d].propertyValue && String(c[d].propertyValue.value) === String(u);
}
const o = /* @__PURE__ */ new Map([
["length", e],
["getProperty", n]
]);
Object.keys(t).reduce((d, f) => (d.set(f, t[f]), d), o);
function i(d, f) {
const u = d;
return typeof f == "number" ? [{ target: u, operator: "length", param: null, value: Number(f) }] : typeof f == "boolean" ? [{ target: u, operator: "getProperty", param: d, value: !!f }] : typeof f == "object" ? Object.keys(f).map((c) => {
if (c === "length")
return { target: u, operator: "length", param: null, value: f[c] };
const h = c, g = f[c];
return { target: u, operator: "getProperty", param: h, value: g };
}) : [];
}
function l(d) {
return Object.keys(d).reduce((u, c) => {
const h = i(c, d[c]);
return u.push(...h), u;
}, []);
}
function a(d, f) {
if (o.has(d.operator)) {
const u = o.get(d.operator);
return u && u(d.target, d.param, d.value, f) || !1;
}
return !1;
}
function r(d, f) {
return l(d).reduce((h, g) => h && a(g, f), !0);
}
function s(d, f) {
const u = Object.keys(d), c = u.includes("allOf"), h = u.includes("anyOf"), g = c || h, v = (g ? d[g ? c ? "allOf" : "anyOf" : "allOf"] : [d]).map((M) => r(M, f));
return c ? !v.includes(!1) : v.includes(!0);
}
return { parseValueSchema: s };
}
const se = {
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: "标签页工具栏按钮" },
"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: "抽屉" }
}, ba = {}, Ca = {};
ya();
function Ke(t, e, n = /* @__PURE__ */ new Map(), o = (a, r, s, d) => r, i = {}, l = (a) => a) {
return Co[e.title] = e, wo[e.title] = o, ba[e.title] = i, Ca[e.title] = l, (a = {}, r = !0) => {
if (!r)
return Fo(a, n);
const s = va(a, e, n), d = Object.keys(t).reduce((f, u) => (f[u] = t[u].default, f), {});
return Object.assign(d, s);
};
}
function It(t, e) {
return { customClass: e.class, customStyle: e.style };
}
function wa() {
function t(e, n) {
const { id: o } = e || {}, { dataSource: i } = e || {};
return i === void 0 ? {} : {
data: n.getValue(o),
"onUpdate:data": (...l) => {
}
};
}
return {
resolve: t
};
}
function Sa() {
function t(e, n) {
const { dataSource: o } = e || {};
return o === void 0 ? {} : {};
}
return {
resolve: t
};
}
function Fa() {
function t(e, n) {
return e.selectItemById(n);
}
return {
selectItemById: t
};
}
function Ta() {
function t(e, n) {
return e.selectItemById(n);
}
return {
selectItemById: t
};
}
function To() {
function t(e, n) {
const { columns: o } = n;
return e.updateColumns(o);
}
return {
updateColumns: t
};
}
const xo = /* @__PURE__ */ new Map([
["appearance", It],
["column", "columnOption"]
// ['fields', resolveGridColumns]
]), _o = /* @__PURE__ */ new Map([]);
var Lt = /* @__PURE__ */ ((t) => (t.SimpleField = "SimpleField", t.ComplexField = "ComplexField", t))(Lt || {}), Mo = /* @__PURE__ */ ((t) => (t.StringType = "StringType", t.TextType = "TextType", t.NumericType = "NumericType", t.BooleanType = "BooleanType", t.DateType = "DateType", t.DateTimeType = "DateTimeType", t.EnumType = "EnumType", t.EntityType = "EntityType", t.HierarchyType = "HierarchyType", t.ObjectType = "ObjectType", t.BigNumericType = "BigNumericType", t))(Mo || {}), Et = /* @__PURE__ */ ((t) => (t.String = "String", t.DateTime = "DateTime", t.Date = "Date", t.Enum = "Enum", t.Boolean = "Boolean", t.Number = "Number", t.Text = "Text", t.BigNumber = "BigNumber", t))(Et || {});
function Ln() {
function t() {
const n = (o) => {
const i = Math.random() * 16 | 0;
return (o === "x" ? i : i & 3 | 8).toString(16);
};
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, n);
}
function e(n, o) {
const i = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""), l = [];
let a;
if (o = o || i.length, n)
for (a = 0; a < n; a++)
l[a] = i[0 | Math.random() * o];
else {
let r;
for (l[8] = l[13] = l[18] = l[23] = "-", l[14] = "4", a = 0; a < 36; a++)
l[a] || (r = 0 | Math.random() * 16, l[a] = i[a === 19 ? r & 3 | 8 : r]);
}
return l.join("");
}
return { guid: t, uuid: e };
}
const xa = ["moz", "ms", "webkit"];
function _a() {
let t = 0;
return (e) => {
const n = (/* @__PURE__ */ new Date()).getTime(), o = Math.max(0, 16 - (n - t)), i = setTimeout(() => {
e(n + o);
}, o);
return t = n + o, i;
};
}
function Ma() {
if (typeof window > "u")
return () => 0;
if (window.requestAnimationFrame)
return window.requestAnimationFrame.bind(window);
const t = xa.filter((e) => `${e}RequestAnimationFrame` in window)[0];
return t ? window[`${t}RequestAnimationFrame`] : _a();
}
Ma();
const Ia = "root-viewmodel";
class ka {
constructor(e, n) {
U(this, "formSchemaUtils");
U(this, "controlCreatorUtils");
U(this, "designViewModelUtils");
U(this, "useFormCommand");
U(this, "formStateMachineUtils");
this.resolver = e, this.designerHostService = n, this.formSchemaUtils = this.designerHostService.formSchemaUtils, this.controlCreatorUtils = this.designerHostService.controlCreatorUtils, this.designViewModelUtils = this.designerHostService.designViewModelUtils, this.useFormCommand = this.designerHostService.useFormCommand, this.formStateMachineUtils = this.designerHostService.formStateMachineUtils;
}
createComponent(e) {
const n = this.createComponentRefNode(e), o = this.createComponentNode(e), i = this.createViewModeNode(e), l = this.formSchemaUtils.getFormSchema();
return l.module.viewmodels.push(i), l.module.components.push(o), this.designViewModelUtils.assembleDesignViewModel(), this.wrapContainerSectionForComponent(n, e, i);
}
/**
* 追加父容器
* @param componentRefNode
* @param buildInfo
* @returns
*/
wrapContainerSectionForComponent(e, n, o) {
var r, s, d, f, u, c, h, g;
const i = (s = (r = n == null ? void 0 : n.parentComponentInstance) == null ? void 0 : r.schema) == null ? void 0 : s.type, l = (f = (d = this.formSchemaUtils.getFormSchema()) == null ? void 0 : d.module) == null ? void 0 : f.templateId;
if (i === se["splitter-pane"].type && ["double-list-template", "tree-list-template"].includes(l))
return e;
const a = [se["content-container"].type, se["response-layout-item"].type, se["splitter-pane"].type];
if (i && a.includes(i)) {
const k = this.resolver.getSchemaByType(
"section",
{
parentComponentInstance: n.parentComponentInstance,
mainTitle: n.componentName
},
this.designerHostService
);
if (k && k.contents && k.contents.length) {
const S = k.contents[0];
return S.contents = [e], this.appendAddDeleteBtnToParentContainer(S, n, o), k;
}
}
return this.appendAddDeleteBtnToParentContainer((u = n == null ? void 0 : n.parentComponentInstance) == null ? void 0 : u.schema, n, o), i === se["tab-page"].type && (c = n.parentComponentInstance) != null && c.parent && (h = n.parentComponentInstance) != null && h.parent.updateToolbarItems && ((g = n.parentComponentInstance) == null || g.parent.updateToolbarItems()), e;
}
/**
* 为父容器追加新增、删除按钮
*/
appendAddDeleteBtnToParentContainer(e, n, o) {
const i = e.type, l = o.id.replace(/-/g, "").replace(/_/g, "").replace("component", "").replace("viewmodel", "");
if (n.bindTo === "/" || n.componentType !== "data-grid" && n.componentType !== "form")
return;
const a = this.formStateMachineUtils && this.formStateMachineUtils.getRenderStates(), r = se["tab-page"].type === i ? "tab-toolbar-item" : "section-toolbar-item", s = [
{
id: `button-add-${n.componentId}`,
type: r,
text: "新增",
disabled: a.find((d) => d.id === "canAddDetail") ? "!viewModel.stateMachine['canAddDetail']" : !1,
appearance: {
class: ""
},
onClick: `root-viewModel.${o.id}.${l}AddItem1`
},
{
id: `button-remove-${n.componentId}`,
type: r,
text: "删除",
disabled: a.find((d) => d.id === "canRemoveDetail") ? "!viewModel.stateMachine['canRemoveDetail']" : !1,
appearance: {
class: ""
},
onClick: `root-viewModel.${o.id}.${l}RemoveItem1`
}
];
e.toolbar || (e.toolbar = { buttons: [] }), e.toolbar.buttons || (e.toolbar.buttons = []), e.toolbar.buttons = e.toolbar.buttons.concat(s), this.appendAddAndDeleteCommands(o);
}
/**
* 向视图模型添加新增删除命令
*/
appendAddAndDeleteCommands(e) {
const n = e.id.replace(/-/g, "").replace(/_/g, "").replace("component", "").replace("viewmodel", ""), o = Ln().guid(), i = Ln().guid(), l = this.resolveCommandController();
e.commands.push(
{
id: o,
code: `${n}AddItem1`,
name: "增加一条子表数据",
params: [],
handlerName: "AddItem",
cmpId: l,
shortcut: {},
extensions: []
},
{
id: i,
code: `${n}RemoveItem1`,
name: "删除一条子表数据",
params: [
{
name: "id",
shownName: "待删除子表数据的标识",
value: `{DATA~${e.bindTo}/id}`
}
],
handlerName: "RemoveItem",
cmpId: l,
shortcut: {},
extensions: []
}
), this.formSchemaUtils.getFormSchema().module.webcmds.find((s) => s.id === l).refedHandlers.push(
{
host: o,
handler: "AddItem"
},
{
host: i,
handler: "RemoveItem"
}
);
}
/**
* 获取新增删除子表命令可用的控制器id。
*/
resolveCommandController() {
const e = this.formSchemaUtils.getFormSchema().module.webcmds, n = [
"8172a979-2c80-4637-ace7-b13074d3f393",
"8fe977a1-2b32-4f0f-a6b3-2657c4d03574",
"45be24f9-c1f7-44f7-b447-fe2ada458a61"
], o = e.find((l) => n.includes(l.id));
if (o)
return o.id;
const i = "45be24f9-c1f7-44f7-b447-fe2ada458a61";
return e.push({
id: i,
path: "/projects/packages/Inspur.GS.Gsp.Web.WebCmp/webcmd",
name: "AdvancedListCardController.webcmd",
refedHandlers: []
}), this.useFormCommand && this.useFormCommand.checkCommands(), i;
}
createComponentRefNode(e) {
const n = this.resolver.getSchemaByType("component-ref");
return Object.assign(n, {
id: `${e.componentId}-component-ref`,
component: `${e.componentId}-component`
}), n;
}
createComponentNode(e) {
const n = this.resolver.getSchemaByType("component"), o = this.createDateGridComponentContents(e);
return Object.assign(n, {
id: `${e.componentId}-component`,
viewModel: `${e.componentId}-component-viewmodel`,
componentType: e.componentType,
appearance: {
class: this.getDataGridComponentClass()
},
contents: o
}), n;
}
/**
* 添加viewModel节点
*/
createViewModeNode(e) {
return {
id: `${e.componentId}-component-viewmodel`,
code: `${e.componentId}-component-viewmodel`,
name: e.componentName,
bindTo: e.bindTo,
parent: Ia,
fields: this.assembleViewModelFields(e),
commands: [],
states: [],
enableValidation: !0
};
}
/**
* 获取表格组件层级的class样式
*/
getDataGridComponentClass() {
const { templateId: e } = this.formSchemaUtils.getFormSchema().module;
return ["double-list-in-tab-template", "double-list-template", "tree-list-template"].includes(e) ? "f-struct-wrapper f-utils-fill-flex-column" : "f-struct-is-subgrid";
}
/**
* 创建表格组件内层级结构
*/
createDateGridComponentContents(e) {
const { templateId: n } = this.formSchemaUtils.getFormSchema().module;
let o;
if (n === "double-list-in-tab-template") {
const d = this.resolver.getSchemaByType("section");
Object.assign(d, {
id: e.componentId + "-section",
appearance: {
class: "f-section-grid f-section-in-main px-0 pt-0"
},
fill: !0,
showHeader: !1
}), o = d;
} else if (n === "double-list-template" || n === "tree-list-template") {
const d = this.resolver.getSchemaByType("section");
Object.assign(d, {
id: e.componentId + "-section",
appearance: {
class: "f-section-grid f-section-in-main"
},
fill: !0,
showHeader: !1
}), o = d;
} else {
const d = this.resolver.getSchemaByType("content-container");
Object.assign(d, {
id: e.componentId + "-container",
appearance: {
class: "f-grid-is-sub f-utils-flex-column"
}
}), o = d;
}
const i = this.resolver.getSchemaByType("data-grid"), l = [], a = this.formStateMachineUtils && this.formStateMachineUtils.getRenderStates(), r = e.bindTo === "/";
Object.assign(i, {
id: e.componentId + "-dataGrid",
appearance: {
class: "f-component-grid"
},
columns: l,
fieldEditable: e.editable,
dataSource: e.dataSource || "",
editable: !r && a.find((d) => d.id === "editable") ? "viewModel.stateMachine['editable']" : !1,
pagination: {
enable: !e.editable
}
}), o.contents = [i];
const { selectedFields: s } = e;
return s == null || s.forEach((d) => {
if (d.$type === Lt.ComplexField)
return;
const f = vt(d), u = this.controlCreatorUtils.setGridFieldProperty("data-grid-column", f, "", e.editable);
u && l.push(u);
}), [o];
}
/**
* 组装viewModel fields 节点
*/
assembleViewModelFields(e) {
const n = [], { selectedFields: o } = e;
return o == null || o.forEach((i) => {
let l = "blur";
const a = i.type.name;
(a === Et.Enum || a === Et.Boolean) && (l = "change"), n.push({
type: "Form",
id: i.id,
fieldName: i.bindingField,
groupId: null,
groupName: null,
updateOn: l,
fieldSchema: {}
});
}), n;
}
}
function Io(t, e, n, o) {
var l, a, r, s, d, f, u;
const i = n.parentComponentInstance;
if (i && o) {
const c = Math.random().toString(36).slice(2, 6), h = {
componentId: `data-grid-${c}`,
componentName: ((l = n.bindingSourceContext) == null ? void 0 : l.entityTitle) || ((r = (a = n.bindingSourceContext) == null ? void 0 : a.bindingEntity) == null ? void 0 : r.name) || `表格-${c}`,
componentType: "data-grid",
parentContainerId: i.schema.id,
parentComponentInstance: i,
editable: !0,
bindTo: ((s = n.bindingSourceContext) == null ? void 0 : s.bindTo) || "",
dataSource: (f = (d = n.bindingSourceContext) == null ? void 0 : d.bindingEntity) == null ? void 0 : f.label,
selectedFields: (u = n.bindingSourceContext) == null ? void 0 : u.bindingEntityFields
};
return new ka(t, o).createComponent(h);
} else
return e;
}
function ko(t, e, n) {
return e;
}
const Ba = "https://json-schema.org/draft/2020-12/schema", Ea = "https://farris-design.gitee.io/data-grid.schema.json", Va = "data-grid", Oa = "A Farris Data Grid Component", Pa = "object", $a = {
id: {
description: "The unique identifier for a Input Group",
type: "string"
},
type: {
description: "The type string of Input Group component",
type: "string",
default: "data-grid"
},
appearance: {
description: "",
type: "object",
properties: {
class: {
type: "string"
},
style: {
type: "string"
}
},
default: {}
},
fit: {
type: "boolean",
default: !1
},
showStripe: {
type: "boolean",
default: !0
},
showBorder: {
type: "boolean",
default: !1
},
showSetting: {
type: "boolean",
default: !1
},
size: {
description: "",
type: "object",
properties: {
width: {
type: "number"
},
height: {
type: "number"
}
},
default: null
},
dataSource: {
description: "",
type: "string",
default: ""
},
columns: {
description: "",
type: "array",
default: []
},
identifyField: {
description: "",
type: "string"
},
editable: {
description: "",
type: "boolean",
default: !1
},
disabled: {
description: "",
type: "boolean",
default: !1
},
visible: {
description: "",
type: "boolean",
default: !0
},
fieldEditable: {
description: "是否可编辑",
type: "boolean",
default: !1
},
cell: {
type: "object",
properties: {
highlightFocusingCell: {
description: "",
type: "boolean",
default: !1
},
mergeCell: {
description: "",
type: "boolean",
default: !1
},
showEditableIcon: {
description: "",
type: "boolean",
default: !1
}
}
},
column: {
type: "object",
properties: {
fitColumns: {
description: "",
type: "boolean",
default: !1
},
fitMode: {
description: "",
type: "string",
default: "average"
},
groups: {
description: "",
type: "array",
default: []
},
reorderColumn: {
description: "Enable to drag column to reorder",
type: "boolean",
default: !1
},
resizeColumn: {
type: "boolean",
default: !0
},
resizeColumnOnDoubleClick: {
description: "",
type: "boolean",
default: !0
}
}
},
command: {
type: "object",
properties: {
enable: {
description: "",
type: "boolean",
default: !1
},
commands: {
type: "array",
default: []
},
commandColumnWidth: {
description: "",
type: "number",
default: 120
},
onClickDeleteCommand: {
description: "",
type: "string",
default: ""
},
onClickEditCommand: {
description: "",
type: "string",
default: ""
}
}
},
contextMenu: {
description: "",
type: "object",
properties: {
enable: {
description: "",
type: "boolean",
default: !1
}
}
},
customizaiton: {
type: "object",
properties: {
enableScheme: {
description: "",
type: "boolean",
default: !1
},
enableSetting: {
description: "",
type: "boolean",
default: !1
}
}
},
edit: {
type: "obejct",
properties: {
mode: {
description: "",
type: "string",
default: "cell",
enum: [
"cell",
"row",
"card"
]
},
selectOnEditing: {
description: "",
type: "boolean",
default: !1
},
onAppendRow: {
description: "",
type: "string",
default: ""
},
onBeforeEdit: {
description: "",
type: "string",
default: ""
}
}
},
filter: {
type: "object",
properties: {
enable: {
description: "",
type: "boolean",
default: !1
},
filterStyle: {
description: "",
type: "string",
default: "filter-column",
enum: [
"filter-column",
"filter-row"
]
},
mode: {
description: "",
type: "string",
default: "server",
enum: [
"client",
"server"
]
},
showSummary: {
description: "",
type: "boolean",
default: !0
},
onFilterChange: {
description: "",
type: "string",
default: ""
}
}
},
footer: {
type: "object",
properties: {
enable: {
description: "",
type: "boolean",
default: !1
},
customFooterStyle: {
description: "",
type: "object"
},
footerDataCommand: {
description: "",
type: "string",
default: ""
},
footerDataFrom: {
description: "",
type: "string",
default: "client"
},
footerHeight: {
description: "",
type: "number",
default: 29
},
footerPosition: {
description: "",
type: "string",
default: "bottom"
},
footerTemplate: {
description: "",
type: "string",
default: ""
}
}
},
group: {
description: "",
type: "object",
properties: {
enable: {
description: "",
type: "boolean",
default: !1
},
customGroupRow: {
description: "",
type: "object"
},
customGroupRowStyle: {
description: "",
type: "obejct"
},
customSummaryStyle: {
description: "",
type: "obejct"
},
groupColSpan: {
description: "",
type: "number",
default: 1
},
groupFields: {
description: "",
type: "array",
default: []
},
showGroupedColumn: {
description: "",
type: "boolean",
default: !0
},
showGroupPanel: {
description: "",
type: "boolean",
default: !1
},
showSummary: {
description: "",
type: "boolean",
default: !1
},
summaryPosition: {
description: "",
type: "string",
default: "separate",
enum: [
"separate",
"merge-to-group"
]
},
disableGroupOnEditing: {
description: "",
type: "boolean",
default: !0
},
expandGroupRows: {
description: "",
type: "boolean",
default: !0
}
}
},
header: {
type: "object",
properties: {
wrapHeadings: {
description: "",
type: "boolean",
default: !1
}
}
},
pagination: {
type: "object",
properties: {
enable: {
description: "",
type: "boolean",
default: !1
},
disablePagination: {
description: "",
type: "string",
default: ""
},
contentTemplate: {
description: "",
type: "string",
default: ""
},
index: {
description: "",
type: "number",
default: 1
},
mode: {
description: "",
type: "enum",
default: "server",
enum: [
"server",
"client"
]
},
showGoto: {
description: "",
type: "boolean",
default: !1
},
showIndex: {
description: "",
type: "boolean",
default: !0
},
showLimits: {
description: "",
type: "boolean",
default: !1
},
showPageInfo: {
description: "",
type: "boolean",
default: !0
},
size: {
description: "",
type: "number",
default: 20
},
sizeLimits: {
description: "",
type: "array",
default: [
10,
20,
30,
50,
100
]
},
onPageChange: {
description: "",
type: "string",
default: ""
},
onPageSizeChange: {
description: "",
type: "string",
default: ""
}
}
},
row: {
type: "object",
properties: {
customRowStyle: {
description: "",
type: "object"
},
disable: {
description: "",
type: "obejct"
},
height: {
description: "",
type: "number",
default: 30
},
showHovering: {
type: "boolean",
default: !0
},
wrapContent: {
type: "boolean",
default: !1
}
}
},
rowNumber: {
description: "",
type: "object",
properties: {
enable: {
description: "",
type: "boolean",
default: !0
},
heading: {
description: "",
type: "string",
default: "序号"
},
width: {
description: "",
type: "number",
default: 36
},
showEllipsis: {
description: "",
type: "boolean",
default: !0
}
}
},
onClickRow: {
description: "行点击事件",
type: "string",
default: ""
},
onSelectionChange: {
description: "行切换事件",
type: "string",
default: ""
},
onPageIndexChanged: {
description: "切换页码事件",
type: "string",
default: ""
},
onPageSizeChanged: {
description: "分页条数变化事件",
type: "string",
default: ""
},
selection: {
type: "object",
properties: {
enableSelectRow: {
description: "允许选中行",
type: "boolean",
default: !0
},
enable: {
description: "",
type: "boolean",
default: !0
},
checkOnSelect: {
description: "",
type: "boolean",
default: !1
},
clearSelectionOnEmpty: {
description: "",
type: "boolean",
default: !0
},
customSelectionItem: {
description: "",
type: "object"
},
focusSelection: {
description: "",
type: "string",
default: "current",
enum: [
"current",
"all"
]
},
keepSelectingOnClick: {
description: "",
type: "boolean",
default: !0
},
keepSelectingOnPaging: {
description: "",
type: "boolean",
default: !0
},
multiSelect: {
description: "",
type: "boolean",
default: !1
},
selectionMode: {
description: "",
type: "string",
default: "default"
},
selectOnCheck: {
description: "",
type: "boolean",
default: !1
},
selectOnEditing: {
description: "",
type: "boolean",
default: !1
},
showCheckbox: {
description: "",
type: "boolean",
default: !1
},
showSelectAll: {
description: "",
type: "boolean",
default: !1
},
showSelection: {
description: "",
type: "boolean",
default: !1
},
onBeforeSelect: {
description: "",
type: "string",
default: ""
},
onBeforeUnCheck: {
description: "",
type: "",
default: ""
},
onBeforeUnSelect: {
description: "",
type: "string",
default: ""
},
onCheckAll: {
description: "",
type: "string",
default: ""
},
onChecked: {
description: "",
type: "string",
default: ""
},
onSelectionChange: {
description: "",
type: "string",
default: ""
},
onUnCheckAll: {
description: "",
type: "string",
default: ""
},
onUnChecked: {
description: "",
type: "string",
default: ""
},
onCheckedChange: {
description: "",
type: "string"
}
}
},
sort: {
type: "object",
properties: {
enable: {
description: "",
type: "boolean",
default: !1
},
fields: {
description: "",
type: "array",
default: []
},
mode: {
description: "",
type: "string",
default: "client",
enum: [
"client",
"server"
]
},
multiSort: {
description: "",
type: "boolean",
default: !1
}
}
},
summary: {
description: "",
type: "object",
properties: {
enable: {
description: "",
type: "boolean",
default: !1
},
customSummaryStyle: {
description: "",
type: "object"
},
groupFields: {
description: "",
type: "array",
default: []
},
mode: {
description: "",
type: "string",
default: "client",
enum: [
"client",
"server"
]
},
position: {
description: "",
type: "boolean",
default: "bottom",
enum: [
"bottom",
"top",
"both"
]
}
}
},
toolbar: {
description: "",
type: "object",
properties: {
enable: {
description: "",
type: "boolean",
default: !1
}
}
},
visualization: {
autoHeight: {
description: "",
type: "boolean",
default: !1
},
emptyDataHeight: {
description: "",
type: "number",
default: 36
},
emptyTemplate: {
description: "",
type: "string",
default: ""
},
maxHeight: {
description: "",
type: "number",
default: 300
},
scrollBarShowMode: {
description: "",
type: "string",
default: "auto"
},
showBorder: {
description: "",
type: "boolean",
default: !1
},
showScrollArrow: {
description: "",
type: "boolean",
default: !1
},
striped: {
description: "",
type: "boolean",
default: !0
},
useBlankWhenDataIsEmpty: {
description: "",
type: "boolean",
default: !1
}
}
}, Ra = [
"id",
"type",
"columns"
], Da = {
$schema: Ba,
$id: Ea,
title: Va,
description: Oa,
type: Pa,
properties: $a,
required: Ra
};
function Na() {
function t(e, n) {
const o = {};
return o.beforeEditCell = (i) => n.call("beforeEditCell", [i]), o;
}
return {
resolve: t
};
}
const Wp = {
/** 启用分页 */
enable: { type: Boolean, default: !1 },
/** 当前页码 */
index: { type: Number, default: 1 },
/** 分页交互模式 */
mode: { type: String, default: "client" },
/** 显示页码输入框 */
showGoto: { type: Boolean, default: !1 },
/** 显示页码 */
showIndex: { type: Boolean, default: !0 },
/** 显示每页记录数 */
showLimits: { type: Boolean, default: !1 },
/** 显示分页汇总信息 */
showPageInfo: { type: Boolean, default: !0 },
/** 默认每页记录数 */
size: { type: Number, default: 20 },
/** 可选择的没有记录数据 */
sizeLimits: { type: Array, default: [10, 20, 30, 50, 100] },
/** 总记录数 */
total: { type: Number, default: 0 },
/** 禁用分页 */
disabled: { type: Boolean, default: !1 }
}, Gp = {
/** 启用排序 */
enable: { type: Boolean, default: !1 },
/** 排序字段集合 */
fields: { type: Array, default: [] },
/** 排序交互模式 */
mode: { type: String, default: "client" },
/** 多列排序 */
multiSort: { type: Boolean, default: !1 }
}, zp = {
/** 自定义分组合计内容 */
customGroupRow: { type: Function, default: () => {
} },
/** 自定义分组行样式 */
customGroupRowStyle: { type: Function, default: () => {
} },
/** 自行分组合计行样式 */
customSummaryStyle: { type: Function, default: () => {
} },
/** 启用行数据分组 */
enable: { type: Boolean, default: !1 },
/** 分组行合并列数 */
groupColSpan: { type: Number, default: 1 },
/** 行数据分组字段;多字段分组以英文逗号分隔 */
groupFields: { type: Array, default: [] },
/** 在DataGrid中显示被分组的列 */
showGroupedColumn: { type: Boolean, default: !0 },
/** 显示分组面板 */
showGroupPanel: { type: Boolean, default: !1 },
/** 启用合计行 */
showSummary: { type: Boolean, default: !1 },
/** 显示合计行位置; */
summaryPosition: { type: String, default: "separate" }
}, Up = {
/** 启用筛选 */
enable: { type: Boolean, default: !1 },
/** DataGrid筛选风格 */
filterStyle: { type: String, default: "filter-column" },
/** 筛选交互模式 */
mode: { type: String, default: "server" },
/** 显示过滤条件工具条 */
showSummary: { type: Boolean, default: !0 }
}, qp = {
/** 允许折行显示列标题 */
wrapHeadings: { type: Boolean, default: !1 }
}, Yp = {
/** 显示行号 */
enable: { type: Boolean, default: !1 },
/** 行号列表头标题 */
heading: { type: String, default: "序号" },
/** 行号宽度,默认为 36px */
width: { type: Number, default: 36 },
/** 是否展示省略号 */
showEllipsis: { type: Boolean, default: !0 }
}, Xp = {
/** 自定义行样式 */
customRowStyle: { type: Function, default: () => {
} },
/** 自定义行状态 */
customRowStatus: { type: Function, default: () => {
} },
/** 禁止行选中表达式 */
disable: { type: Function, default: () => {
} },
/** 默认行高度为 29px */
height: { type: Number, default: 28 },
/** 鼠标滑过行效果 */
showHovering: { type: Boolean, default: !0 },
/** 禁止数据折行 */
wrapContent: { type: Boolean, default: !1 }
}, Jp = {
/** 显示合计信息 */
enable: { type: Boolean, default: !1 },
/** 合计行自定义样式,对启用合计行模板无效 */
customSummaryStyle: { type: Function, default: () => {
} },
/** 分组合计字段 */
groupFields: { type: Array, default: [] },
/** 合计交互模式 */
mode: { type: String, default: "client" },
/** 合计行显示位置, top: 顶部 bottom: 底部, both: 顶部与底部同时显示 */
position: { type: String, default: "bottom" }
}, Kp = {
/** 自动列宽。设为true后,所有列将填满表格并不会出现横向滚动条。 */
fitColumns: { type: Boolean, default: !1 },
/** 自动适配列宽度模式 */
fitMode: { type: String, default: "average" },
groups: { type: Array, defaut: [] },
/** 允许拖动表头改变列显示顺序 */
reorderColumn: { type: Boolean, default: !1 },
/** 允许拖动改变列宽度 */
resizeColumn: { type: Boolean, default: !0 },
/** 双击表头列自适应内容宽度 */
resizeColumnOnDoubleClick: { type: Boolean, default: !0 }
}, Qp = {
/** 启用多选且显示checkbox, 选中行后勾选前面的checkbox */
checkOnSelect: { type: Boolean, default: !1 },
/** 当数据源为空时,清空已选记录 */
clearSelectionOnEmpty: { type: Boolean, default: !0 },
/** 自定义已选记录列表中的显示内容 */
customSelectionItem: { type: Function, default: () => {
} },
/** 允许选中行 */
enabelSelectRow: { type: Boolean, default: !0 },
/** 允许重复点击行是保留选中状态 */
keepSelectingOnClick: { type: Boolean, default: !0 },
/** 允许跨页多选 */
keepSelectingOnPaging: { type: Boolean, default: !0 },
/** 启用多选 */
multiSelect: { type: Boolean, default: !1 },
/** 启用多选时,点击行选中,只允许且只有一行被选中 */
focusSelection: { type: String, default: "current" },
/** 启用多选且显示checkbox, 勾选后并且选中行 */
selectOnCheck: { type: Boolean, default: !1 },
/** 每行前边显示 checkbox */
showCheckbox: { type: Boolean, default: !1 },
/** 显示全选checkbox */
showSelectAll: { type: Boolean, default: !1 },
/** 显示已选数据 */
showSelection: { type: Boolean, default: !1 }
}, Zp = {
/** 编辑时选中文本 */
selectOnEditing: { type: Boolean, default: !1 },
/** 编辑模式; row:整行编辑,cell: 单元格编辑 */
editMode: { type: String, default: "cell" }
}, em = {
/** show loading */
show: { type: Boolean, default: !1 },
/** message on display when loading */
message: { type: String, default: "加载中..." }
}, _n = {
/** 允许在最后一个单元回车新增一行 */
appendOnEnterAtLastCell: { type: Boolean, default: !1 },
/** 编辑单元格前事件 */
beforeEditCell: {
type: Function,
default: (t) => !0
},
/** 结束编辑前校验 */
beforeEndEditCell: { type: Function, default: () => !0 },
/** 变更策略 默认主动更新 */
changePolicy: { type: String, default: "push" },
/** 列集合 */
columns: { type: Array, default: [] },
/** 列配置 */
columnOption: { type: Object },
/** 列配置 */
commandOption: {
type: Object,
default: {
enable: !1,
commands: []
}
},
/** 被绑定数据 */
data: { type: Array, default: [] },
/** 禁用组件 */
disabled: { type: Boolean, default: !1 },
/** 行数据禁用属性 */
disabledField: { type: String, default: "disabled" },
/** 允许编辑 */
editable: { type: Boolean, default: !1 },
/** 编辑配置 */
editOption: { type: Object, default: { selectOnEditing: !1, editMode: "cell" } },
enableCommands: { type: Boolean, default: !1 },
/** 表格启用过滤 */
enableFilter: { type: Boolean, default: !1 },
/** 筛选配置 */
filter: { type: Object },
/** 适配父组件尺寸 ---此属性没有实际效用*/
fit: { type: Boolean, default: !1 },
/** 编辑单元格时默认获得焦点 */
focusOnEditingCell: { type: Boolean, default: !0 },
/** 分组配置 */
group: { type: Object },
/** 列标题配置 */
header: { type: Object },
/** 高度 */
height: { type: Number, default: -1 },
/** DataGrid组件唯一标识 */
id: { type: String, default: "" },
/** 被绑定数据的标识字段 */
idField: { type: String, default: "id", require: !0 },
/** 展示loading */
loading: { type: Boolean, default: !1 },
/** 纵向合并具有相同值的单元格 */
mergeCell: { type: Boolean, default: !1 },
/** 最小高度 */
minHeight: { type: Number, default: 300 },
/** 最小宽度 */
minWidth: { type: Number, default: 400 },
/** 新建数据 */
newDataItem: { type: Function, default: () => {
} },
/** 分页配置 */
pagination: { type: Object, default: { enable: !1, size: 20 } },
/** 行号配置 */
rowNumber: {
type: Object,
default: {
enable: !0,
width: 32,
heading: "序号"
}
},
/** 行配置 */
rowOption: { type: Object, default: { wrapContent: !1 } },
/** 选择配置 */
selection: {
type: Object,
default: {
enableSelectRow: !0,
multiSelect: !1,
multiSelectMode: "DependOnCheck",
showCheckbox: !1,
showSelectAll: !1,
showSelection: !0
}
},
/** 已选数据标识 */
selectionValues: { type: Array, default: [] },
/** 编辑单元格时默认选中单元格文本 */
selectOnEditingCell: { type: Boolean, default: !1 },
/** 显示边框 */
showBorder: { type: Boolean, default: !1 },
/** 显示底部面板 */
showFooter: { type: Boolean, default: !1 },
/** 显示顶部面板 */
showHeader: { type: Boolean, default: !0 },
/** 显示横向行分割线 */
showHorizontalLines: { type: Boolean, default: !0 },
/** 显示滚动条 */
showScrollBar: { type: String, default: "auto" },
/** 显示设置按钮 */
showSetting: { type: Boolean, default: !1 },
/** 显示条纹 */
showStripe: { type: Boolean, default: !0 },
/** 显示纵向列分割线 */
showVerticallLines: { type: Boolean, default: !1 },
/** 排序配置 */
sort: { type: Object },
/** 合计配置 */
summary: {
type: Object,
default: {
// 默认合计行开启后,后面不展示值,所以默认不开启
enable: !1,
groupFields: ["numericField1", "numericField2"]
}
},
/** 启用虚拟渲染 */
virtualized: { type: Boolean, default: !0 },
/** 宽度 */
width: { type: Number, default: -1 }
}, La = Object.assign({}, _n, {
disabled: {},
editable: {},
componentId: { type: String, default: "" }
}), Bo = Ke(_n, Da, xo, Io), ja = wa(), Ha = Fa(), Aa = To(), Wa = Na();
var Ue = /* @__PURE__ */ ((t) => (t[t.readonly = 0] = "readonly", t[t.editable = 1] = "editable", t[t.editing = 2] = "editing", t))(Ue || {}), mt = /* @__PURE__ */ ((t) => (t[t.initial = 0] = "initial", t[t.editing = 1] = "editing", t))(mt || {}), Mt = /* @__PURE__ */ ((t) => (t[t.data = 0] = "data", t[t.group = 1] = "group", t[t.summary = 2] = "summary", t))(Mt || {}), Je = /* @__PURE__ */ ((t) => (t[t.none = 0] = "none", t[t.filterable = 1] = "filterable", t[t.sortable = 2] = "sortable", t[t.filtered = 4] = "filtered", t[t.sorted = 8] = "sorted", t[t.ascending = 16] = "ascending", t[t.descending = 32] = "descending", t))(Je || {});
function Ga(t, e) {
var h;
const n = String(Date.now()), o = ((h = t.rowOption) == null ? void 0 : h.height) || 28, i = b(e.value.primaryColumnsWidth);
function l(g) {
const k = {};
return g.reduce(
(S, v, C) => {
const M = C < g.length - 1 ? g[C + 1] : null;
return C === 0 && (S[v.field] = { left: 0 }), v.actualWidth !== void 0 && (S[v.field].width = v.actualWidth), M && (S[M.field] = {
left: S[v.field].left + (v.actualWidth || 0)
}), S;
},
k
), k;
}
function a(g, k, S) {
const v = o * (S + 1), M = k[g.field].left - v + (k[g.field].width || 0), m = g.parent.height ? `${g.parent.height}px` : "";
return {
left: `${v}px`,
width: `${M}px`,
height: `${m}`
};
}
function r(g, k, S) {
return {
right: "0px",
height: `${g.parent.height ? `${g.parent.height}px` : ""}`
};
}
function s(g, k) {
const S = g.parent.height ? `${g.parent.height}px` : "";
return {
left: `${k[g.field].left}px`,
height: `${S}`,
width: isNaN(Number(k[g.field].width)) ? "100%" : `${k[g.field].width}px`
};
}
function d(g, k,