UNPKG

@farris/ui-vue

Version:

Farris Vue, a Farris Design based Vue3 component library.

1,622 lines 85.6 kB
import { ref as T, computed as $, createVNode as C, Fragment as W, watch as G, withModifiers as xe, withDirectives as Ne, vModelText as Ge, defineComponent as z, onMounted as re, inject as ne } from "vue"; import { cloneDeep as de, isPlainObject as fe, isUndefined as _e } from "lodash-es"; import { getCustomClass as oe, getCustomStyle as me, FormSchemaEntityFieldType$Type as ze, withInstall as qe } from "../common/index.esm.js"; import { useFilter as We, useIdentify as Ue, useHierarchy as Xe, useGroupData as Ye, useDataView as Je, useSelection as Qe, usePagination as Ze, useRow as Ke, useEdit as et, useVisualDataBound as tt, useVisualDataCell as nt, useVisualDataRow as ot, useVisualGroupRow as rt, useVisualSummaryRow as it, useVisualData as lt, useSidebar as at, useColumn as st, useVirtualScroll as ct, getPagination as ut } from "../data-view/index.esm.js"; import { useI18n as ie } from "vue-i18n"; import { FCheckbox as le } from "../checkbox/index.esm.js"; import dt from "../button-edit/index.esm.js"; import { resolveAppearance as ft, createPropsResolver as mt, getSchemaByTypeForDesigner as vt } from "../dynamic-resolver/index.esm.js"; import pt from "../list-view/index.esm.js"; import gt from "../../designer/button-edit/index.esm.js"; import { useDesignerComponent as yt } from "../designer-canvas/index.esm.js"; import { InputBaseProperty as ht } from "../property-panel/index.esm.js"; function he(e, t) { let n; function r(i) { const { properties: o, title: s, ignore: a } = i, l = a && Array.isArray(a), c = Object.keys(o).reduce((h, u) => ((!l || !a.find((p) => p === u)) && (h[u] = o[u].type === "object" && o[u].properties ? r(o[u]) : de(o[u].default)), h), {}); if (s && (!l || !a.find((h) => h === "id"))) { const h = s.toLowerCase().replace(/-/g, "_"); c.id = `${h}_${Math.random().toString().slice(2, 6)}`; } return c; } function f(i) { const { properties: o, title: s, required: a } = i; if (a && Array.isArray(a)) { const l = a.reduce((c, h) => (c[h] = o[h].type === "object" && o[h].properties ? r(o[h]) : de(o[h].default), c), {}); if (s && a.find((c) => c === "id")) { const c = s.toLowerCase().replace(/-/g, "_"); l.id = `${c}_${Math.random().toString().slice(2, 6)}`; } return l; } return { type: s }; } function v(i, o = {}, s) { const a = e[i]; if (a) { let l = f(a); const c = t[i]; return l = c ? c({ getSchemaByType: v }, l, o, s) : l, n != null && n.appendIdentifyForNewControl && n.appendIdentifyForNewControl(l), l; } return null; } function d(i, o) { const s = r(o); return Object.keys(s).reduce((a, l) => (Object.prototype.hasOwnProperty.call(i, l) && (a[l] && fe(a[l]) && fe(i[l] || !i[l]) ? Object.assign(a[l], i[l] || {}) : a[l] = i[l]), a), s), s; } function S(i, o) { return Object.keys(i).filter((a) => i[a] != null).reduce((a, l) => { if (o.has(l)) { const c = o.get(l); if (typeof c == "string") a[c] = i[l]; else { const h = c(l, i[l], i); Object.assign(a, h); } } else a[l] = i[l]; return a; }, {}); } function M(i, o, s = /* @__PURE__ */ new Map()) { const a = d(i, o); return S(a, s); } function g(i) { var s; const o = i.type; if (o) { const a = e[o]; if (!a) return i; const l = d(i, a), c = ((s = i.editor) == null ? void 0 : s.type) || ""; if (c) { const h = e[c], u = d(i.editor, h); l.editor = u; } return l; } return i; } function y(i) { n = i; } return { getSchemaByType: v, resolveSchemaWithDefaultValue: g, resolveSchemaToProps: M, mappingSchemaToProps: S, setDesignerContext: y }; } const be = {}, Se = {}, { getSchemaByType: ro, resolveSchemaWithDefaultValue: bt, resolveSchemaToProps: St, mappingSchemaToProps: Ct, setDesignerContext: io } = he(be, Se); function Ft(e = {}) { function t(g, y, i, o) { if (typeof i == "number") return o[g].length === i; if (typeof i == "object") { const s = Object.keys(i)[0], a = i[s]; if (s === "not") return Number(o[g].length) !== Number(a); if (s === "moreThan") return Number(o[g].length) >= Number(a); if (s === "lessThan") return Number(o[g].length) <= Number(a); } return !1; } function n(g, y, i, o) { return o[g] && o[g].propertyValue && String(o[g].propertyValue.value) === String(i); } const r = /* @__PURE__ */ new Map([ ["length", t], ["getProperty", n] ]); Object.keys(e).reduce((g, y) => (g.set(y, e[y]), g), r); function f(g, y) { const i = g; return typeof y == "number" ? [{ target: i, operator: "length", param: null, value: Number(y) }] : typeof y == "boolean" ? [{ target: i, operator: "getProperty", param: g, value: !!y }] : typeof y == "object" ? Object.keys(y).map((o) => { if (o === "length") return { target: i, operator: "length", param: null, value: y[o] }; const s = o, a = y[o]; return { target: i, operator: "getProperty", param: s, value: a }; }) : []; } function v(g) { return Object.keys(g).reduce((i, o) => { const s = f(o, g[o]); return i.push(...s), i; }, []); } function d(g, y) { if (r.has(g.operator)) { const i = r.get(g.operator); return i && i(g.target, g.param, g.value, y) || !1; } return !1; } function S(g, y) { return v(g).reduce((s, a) => s && d(a, y), !0); } function M(g, y) { const i = Object.keys(g), o = i.includes("allOf"), s = i.includes("anyOf"), a = o || s, h = (a ? g[a ? o ? "allOf" : "anyOf" : "allOf"] : [g]).map((p) => S(p, y)); return o ? !h.includes(!1) : h.includes(!0); } return { parseValueSchema: M }; } const wt = { convertTo: (e, t, n, r) => { e.appearance || (e.appearance = {}), e.appearance[t] = n; }, convertFrom: (e, t, n) => e.appearance ? e.appearance[t] : e[t] }, Tt = { convertFrom: (e, t, n) => e.buttons && e.buttons.length ? `共 ${e.buttons.length} 项` : "无" }, kt = { 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] }, Ce = { 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: "多语输入框" } }, Mt = { convertFrom: (e, t, n) => { var f; const r = e.editor && e.editor[t] ? e.editor[t] : e[t]; return ((f = Ce[r]) == null ? void 0 : f.name) || r; } }, Ot = { convertTo: (e, t, n, r) => { e[t] = e[t]; }, convertFrom: (e, t, n) => e.editor ? n.getRealEditorType(e.editor.type) : "" }, Vt = { 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 === "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"; } }, Pt = { convertTo: (e, t, n, r) => { 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 : "" }, Bt = { 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 ""; } }, It = { 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) => e.summary && t === "enable" ? e.summary.enable : e.type === "data-grid-column" ? e.enableSummary === void 0 ? !1 : e.enableSummary : "" }, Rt = { 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 }); }, convertFrom: (e, t, n) => { if (e.group) { if (t === "enable") return e.group.enable; if (t === "showSummary") return e.group.showSummary; } } }, Dt = { 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; } } }, Et = { convertTo: (e, t, n, r) => { e.pagination || (e.pagination = {}), e.pagination[t] = n; }, convertFrom: (e, t, n) => e.pagination ? e.pagination[t] : e[t] }, jt = { convertTo: (e, t, n, r) => { e.rowNumber || (e.rowNumber = {}), e.rowNumber[t] = n; }, convertFrom: (e, t, n) => e.rowNumber ? e.rowNumber[t] : e[t] }, Lt = { convertTo: (e, t, n, r) => { e.selection || (e.selection = {}), e.selection[t] = n; }, convertFrom: (e, t, n) => e.selection ? e.selection[t] : e[t] }, $t = { convertFrom: (e, t, n) => e[t] && e[t].length ? `共 ${e[t].length} 项` : "" }, At = { convertFrom: (e, t) => e[t] || "", convertTo: (e, t, n) => { e[t] = n; } }, Ht = { convertTo: (e, t, n, r) => { e.size || (e.size = {}), e.size[t] = n; }, convertFrom: (e, t, n) => e.size ? e.size[t] : e[t] }, xt = { convertFrom: (e, t, n) => { var r, f; return (r = e.formatter) != null && r.data && t === "formatterEnumData" && !e.formatterEnumData ? (f = e.formatter) == null ? void 0 : f.data : e.formatterEnumData; } }, Nt = { convertTo: (e, t, n, r) => { e.sort || (e.sort = {}), e.sort[t] = n; }, convertFrom: (e, t, n) => { var r, f; if (t === "mode") return ((r = e.sort) == null ? void 0 : r.mode) || "client"; if (t === "multiSort") return !!((f = e.sort) != null && f.multiSort); } }, Gt = { convertTo: (e, t, n, r) => { e.filter || (e.filter = {}), e.filter[t] = n; }, convertFrom: (e, t, n) => { var r; if (t === "mode") return ((r = e.filter) == null ? void 0 : r.mode) || "client"; } }, _t = { 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; } return ""; } }; function Fe(e, t, n) { const r = /* @__PURE__ */ new Map([ ["/converter/appearance.converter", wt], ["/converter/buttons.converter", Tt], ["/converter/property-editor.converter", kt], ["/converter/items-count.converter", $t], ["/converter/type.converter", Mt], ["/converter/change-editor.converter", Ot], ["/converter/change-formatter.converter", Vt], ["/converter/column-command.converter", Pt], ["/converter/column-option.converter", Bt], ["/converter/summary.converter", It], ["/converter/group.converter", Rt], ["/converter/form-group-label.converter", At], ["/converter/field-selector.converter", Dt], ["/converter/pagination.converter", Et], ["/converter/row-number.converter", jt], ["/converter/grid-selection.converter", Lt], ["/converter/size.converter", Ht], ["/converter/change-formatter-enum.converter", xt], ["/converter/grid-sort.converter", Nt], ["/converter/grid-filter.converter", Gt], ["/converter/row-option.converter", _t] ]), f = /* @__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 = Ft(); function d(a, l) { return () => v.parseValueSchema(a, l); } function S(a, l, c) { return a.includes("visible") && l.visible !== void 0 ? typeof l.visible == "boolean" ? () => !!l.visible : l.visible === void 0 ? !0 : d(l.visible, c) : () => !0; } function M(a, l, c) { return a.includes("readonly") && l.readonly !== void 0 ? typeof l.readonly == "boolean" ? () => !!l.readonly : d(l.readonly, c) : () => !1; } function g(a, l) { const c = a.$converter || l; return typeof c == "string" && c && r.has(c) ? r.get(c) || null : c || null; } function y(a, l, c, h, u, p = "", B = "") { return Object.keys(a).map((O) => { const P = T(1), F = O, m = a[O], D = Object.keys(m), E = m.title, b = m.type, I = f.get(b) || { type: "input-group", enableClear: !1 }, w = m.editor ? Object.assign({}, I, m.editor) : Object.assign({}, I), k = S(D, m, l), V = M(D, m, l); w.readonly = w.readonly === void 0 ? V() : w.readonly; const L = m.type === "cascade" ? y(m.properties, l, c, h, u, p, B) : [], j = !0; let H = g(m, B); const x = $({ get() { if (P.value) { if (["class", "style"].find((K) => K === F) && !H && (H = r.get("/converter/appearance.converter") || null), H && H.convertFrom) return H.convertFrom(c, O, u, p); const N = c[O]; return Object.prototype.hasOwnProperty.call(m, "defaultValue") && (N === void 0 || typeof N == "string" && N === "") ? m.type === "boolean" ? m.defaultValue : m.defaultValue || "" : N; } return null; }, set(N) { P.value += 1, H && H.convertTo ? (H.convertTo(h, O, N, u, p), H.convertTo(c, O, N, u, p)) : (h[O] = N, c[O] = N); } }), { refreshPanelAfterChanged: _, description: Q, isExpand: Z, parentPropertyID: U } = m, X = { propertyID: F, propertyName: E, propertyType: b, propertyValue: x, editor: w, visible: k, readonly: V, cascadeConfig: L, hideCascadeTitle: j, refreshPanelAfterChanged: _, description: Q, isExpand: Z, parentPropertyID: U }; return l[F] = X, X; }); } function i(a, l, c = {}) { const h = {}, u = e[a]; return u && u.categories ? Object.keys(u.categories).map((B) => { const R = u.categories[B], O = R == null ? void 0 : R.title, P = y(R.properties || {}, h, {}, c, l); return { categoryId: B, categoryName: O, properties: P }; }) : []; } function o(a, l, c, h, u = "") { const p = l.$ref.schema, B = l.$ref.converter, R = c[p], O = R.type, P = n(R), F = {}, m = e[O]; if (m && m.categories) { const D = m.categories[a], E = D == null ? void 0 : D.title; B && Object.keys(D.properties).forEach((w) => { D.properties[w].$converter = B; }); const b = (D == null ? void 0 : D.properties) || {}, I = y(b, F, P, R, h, u); return { categoryId: a, categoryName: E, properties: I }; } return { categoryId: a, categoryName: "", properties: [] }; } function s(a, l, c, h, u) { const p = a.type, B = n(a), R = {}; let O = u || e[p]; if (O && Object.keys(O).length === 0 && c && c.getPropConfig && (O = c.getPropConfig(h)), O && O.categories) { const P = []; return Object.keys(O.categories).map((F) => { const m = O.categories[F]; if (m.$ref) { P.push(o(F, m, a, l, h)); return; } const D = m == null ? void 0 : m.title, E = m == null ? void 0 : m.tabId, b = m == null ? void 0 : m.tabName, I = m == null ? void 0 : m.hide, w = m == null ? void 0 : m.hideTitle, k = y(m.properties || {}, R, B, a, l, h, m.$converter), { setPropertyRelates: V } = m, L = m == null ? void 0 : m.parentPropertyID; P.push({ categoryId: F, categoryName: D, tabId: E, tabName: b, hide: I, properties: k, hideTitle: w, setPropertyRelates: V, parentPropertyID: L }); }), P; } return []; } return { getPropertyConfigBySchema: s, getPropertyConfigByType: i, propertyConverterMap: r }; } const we = {}, Te = {}; Fe(we, Te, bt); const ke = {}, Me = {}, { getSchemaByType: lo, resolveSchemaWithDefaultValue: zt, resolveSchemaToProps: ao, mappingSchemaToProps: so, setDesignerContext: co } = he(ke, Me), Oe = {}, Ve = {}; Fe(Oe, Ve, zt); function qt(e, t, n = /* @__PURE__ */ new Map(), r = (d, S, M, g) => S, f = {}, v = (d) => d) { return be[t.title] = t, Se[t.title] = r, we[t.title] = f, Te[t.title] = v, ke[t.title] = t, Me[t.title] = r, Oe[t.title] = f, Ve[t.title] = v, (d = {}, S = !0) => { if (!S) return Ct(d, n); const M = St(d, t, n), g = Object.keys(e).reduce((y, i) => (y[i] = e[i].default, y), {}); return Object.assign(g, M); }; } function Wt(e, t) { return { customClass: t.class, customStyle: t.style }; } const Ut = /* @__PURE__ */ new Map([ ["appearance", Wt] ]), Xt = "https://json-schema.org/draft/2020-12/schema", Yt = "https://farris-design.gitee.io/order.schema.json", Jt = "order", Qt = "A Farris Component", Zt = "object", Kt = { id: { description: "The unique identifier for a order", type: "string" }, type: { description: "The type string of order component", type: "string", default: "order" }, appearance: { description: "", type: "object", properties: { class: { type: "string" }, style: { type: "string" } }, default: {} }, binding: { description: "", type: "object", default: {} }, editable: { description: "", type: "boolean", default: !0 }, enableLinkLabel: { description: "", type: "boolean", default: !1 }, label: { description: "", type: "string", default: "" }, lableWidth: { description: "", type: "number" }, placeholder: { description: "", type: "string", default: "" }, readonly: { description: "", type: "boolean", default: !1 }, required: { description: "", type: "boolean", default: !1 }, tabindex: { description: "", type: "number", default: -1 }, textAlign: { description: "", type: "string", enum: [ "left", "middle", "right" ], default: "left" }, visible: { description: "", type: "boolean", default: !0 }, onBlur: { description: "", type: "string", default: "" }, onClickLinkLabel: { description: "", type: "sting", default: "" } }, en = [ "id", "type" ], tn = { $schema: Xt, $id: Yt, title: Jt, description: Qt, type: Zt, properties: Kt, required: en }; function nn(e, t, n) { return t; } const on = "order", rn = "A Farris Component", ln = "object", an = { basic: { description: "Basic Infomation", title: "基本信息", properties: { id: { description: "组件标识", title: "标识", type: "string", readonly: !0 }, type: { description: "组件类型", title: "控件类型", type: "select", editor: { type: "waiting for modification", enum: [] } } } }, behavior: { description: "Basic Infomation", title: "行为", properties: { editable: { description: "", title: "允许编辑", type: "boolean" }, readonly: { description: "", title: "只读", type: "string" }, required: { description: "", title: "必填", type: "boolean" }, visible: { description: "", title: "可见", type: "boolean" }, placeholder: { description: "", title: "提示文本", type: "string" }, tabindex: { description: "", title: "tab索引", type: "number" }, textAlign: { description: "", title: "对齐方式", type: "enum", editor: { type: "combo-list", textField: "name", valueField: "value", data: [ { value: "left", name: "左对齐" }, { value: "center", name: "居中" }, { value: "right", name: "右对齐" } ] } } } } }, sn = { title: on, description: rn, type: ln, categories: an }, ae = { /** 排序列数据源 */ dataSource: { type: Array, default: [] }, /** 当前排序数组 */ items: { type: Array, default: [] } }, ve = qt(ae, tn, Ut, nn, sn), cn = { /** 列集合 */ columns: { type: Array, default: [ { field: "name", title: "", dataType: "string" } ] }, customClass: { type: String, default: "" }, data: { type: Array, default: [] }, draggable: { type: Boolean, default: !1 }, multiSelect: { type: Boolean, default: !1 }, multiSelectMode: { type: String, default: "OnCheck" }, idField: { type: String, default: "id" }, valueField: { type: String, default: "id" }, textField: { type: String, default: "name" }, titleField: { type: String, default: "name" }, view: { type: String, default: "ContentView" }, size: { type: String, default: "default" }, placeholder: { type: String, default: "" }, header: { type: String, default: "ContentHeader" }, headerClass: { type: String, default: "" }, /** 可能根据数据每各项的样式不同 */ itemClass: { type: [String, Function], default: "", validator: (e) => typeof e == "string" || typeof e == "function" }, itemStyle: { type: [String, Function], default: "", validator: (e) => typeof e == "string" || typeof e == "function" }, itemContentClass: { type: String, default: "" }, selectionValues: { type: Array, default: [] }, /** 分组配置 */ group: { type: Object }, /** 选择配置 */ selection: { type: Object, default: { enableSelectRow: !0, multiSelect: !1, multiSelectMode: "DependOnCheck", showCheckbox: !1, showSelectAll: !1, showSelection: !0 } }, keepOrder: { type: Boolean, default: !1 }, disableField: { type: String, default: "disabled" }, // 搜索启用高亮 enableHighlightSearch: { type: Boolean, default: !0 }, /** 虚拟化渲染数据 */ virtualized: { type: Boolean, default: !0 }, /** 删除数据前的检查方法,返回值为true时可以删除当前数据 */ checkBeforeRemoveItem: { type: Function, default: null }, /** 头部模板 */ headerTemplate: { type: Object }, /** 内容模板 */ contentTemplate: { type: Object }, /** 底部模板 */ footerTemplate: { type: Object }, /** 空数据模板 */ emptyTemplate: { type: Object }, /** 分页 */ pagination: { type: Object, default: { enable: !1, size: 20 } } }; function un(e, t) { function n(v) { const d = []; let S = v.nextNode(); for (; S; ) d.push(S), S = v.nextNode(); return d; } function r(v, d) { const S = document.createTreeWalker(v, NodeFilter.SHOW_TEXT); return n(S).map((i) => ({ textNode: i, text: (i.textContent || "").toLocaleLowerCase() })).map(({ textNode: i, text: o }) => { const s = []; let a = 0; for (; a < o.length; ) { const l = o.indexOf(d, a); if (l === -1) break; s.push(l), a = l + d.length; } return s.map((l) => { const c = new Range(); return c.setStart(i, l), c.setEnd(i, l + d.length), c; }); }).flat(); } function f(v) { if (!CSS.highlights || (CSS.highlights.clear(), !v || !t)) return; const d = r(t.value, v.toLocaleLowerCase()), S = new Highlight(...d); CSS.highlights.set("search-result", S); } return { search: f }; } function pe(e, t, n, r, f, v, d, S, M, g) { const y = T(e.size), i = T(e.textField), o = T(e.titleField), s = T(e.disableField), a = $(() => { var F, m; return ((F = e.selection) == null ? void 0 : F.multiSelect) && ((m = e.selection) == null ? void 0 : m.showCheckbox); }), { onMouseenterItem: l, onMouseoverItem: c, onMouseoutItem: h } = v, { getKey: u, listViewItemClass: p, onCheckItem: B, onClickItem: R } = d, O = $(() => { const F = { "text-overflow": "ellipsis", overflow: "hidden", "white-space": "nowrap" }; return e.itemClass ? F : { margin: y.value === "small" ? "0.25rem 0" : "8px 0", ...F }; }); function P(F, m, D) { return F.checked = S.findIndexInSelectedItems(F) > -1, C("li", { class: p(F, m), id: u(F, m), key: u(F, m), onClick: (E) => R(F, m, E), onMouseenter: (E) => l(E, F, m), onMouseover: (E) => c(E, F, m), onMouseout: (E) => h(E, F, m) }, [a.value && C("div", { class: "f-list-select", onClick: (E) => E.stopPropagation() }, [C(le, { id: "list-" + u(F, m), customClass: "listview-checkbox float-left", disabled: F[s.value], checked: F.checked, "onUpdate:checked": (E) => F.checked = E, onChange: (E) => { B(F, m, !E.checked); } }, null)]), C("div", { class: "f-list-content" }, [C("div", { class: e.itemContentClass, style: O.value, title: F.raw[o.value] || F.raw[i.value] }, [F.raw[i.value]])])]); } return { renderItem: P }; } function dn(e, t, n, r, f, v, d, S, M, g) { const y = T(e.multiSelect), i = T(e.disableField), o = T(e.textField), { onMouseenterItem: s, onMouseoverItem: a, onMouseoutItem: l } = v, { getKey: c, listViewItemClass: h, listViewItemStyle: u, onCheckItem: p, onClickItem: B } = d; function R(P, F, m) { return e.contentTemplate ? C(W, null, [e.contentTemplate({ item: P.raw, index: F, selectedItem: m })]) : t.slots.content ? C(W, null, [t.slots.content && t.slots.content({ item: P.raw, index: F, selectedItem: m })]) : C("div", { style: "margin: 10px 0;" }, [P.raw[o.value || "name"]]); } function O(P, F, m) { return C("li", { class: h(P, F), id: c(P, F), key: c(P, F), style: u(P, F), onClick: (D) => B(P, F, D), onMouseenter: (D) => s(D, P, F), onMouseover: (D) => a(D, P, F), onMouseout: (D) => l(D, P, F) }, [y.value && C("div", { class: "f-list-select", onClick: (D) => D.stopPropagation() }, [C(le, { id: "list-" + c(P, F), customClass: "listview-checkbox", disabled: P[i.value] || !P.checked, checked: P.checked, "onUpdate:checked": (D) => P.checked = D, onChange: (D) => p(P, F, !D.checked) }, null)]), C("div", { class: "f-list-content" }, [R(P, F, m)])]); } return { renderItem: O }; } function fn(e, t, n, r, f, v, d, S, M, g) { const y = T(e.multiSelect), i = T(e.disableField), o = T(e.textField), { onMouseenterItem: s, onMouseoverItem: a, onMouseoutItem: l } = v, { getKey: c, listViewItemClass: h, onCheckItem: u, onClickItem: p } = d, { dragstart: B, dragenter: R, dragover: O, dragend: P } = r, { removeItem: F } = M, m = $(() => ({ margin: y.value ? "10px 0" : "10px 0px 10px 14px" })); function D(k, V = "") { const L = k.target; L.title = L.scrollWidth > L.clientWidth ? V : ""; } function E(k) { return C("div", { style: m.value, onMouseenter: (V) => D(V, k.raw[o.value || "name"]) }, [k.raw[o.value || "name"]]); } function b() { return t.slots.itemContent ? t.slots.itemContent : E; } const I = b(); function w(k, V, L) { return C("li", { class: h(k, V), id: c(k, V), key: c(k, V), onClick: (j) => p(k, V, j), onMouseenter: (j) => s(j, k, V), onMouseover: (j) => a(j, k, V), onMouseout: (j) => l(j, k, V), draggable: "true", onDragstart: (j) => B(j, k, V), onDragenter: (j) => R(j, V), onDragend: (j) => P(j, k), onDragover: (j) => O(j) }, [y.value && C("div", { class: "f-list-select", onClick: (j) => j.stopPropagation() }, [C(le, { id: "list-" + c(k, V), customClass: "listview-checkbox", disabled: k[i.value] || !k.checked, checked: k.checked, "onUpdate:checked": (j) => k.checked = j, onChange: (j) => u(k, V, !j.checked) }, null)]), C("div", { class: "f-list-content" }, [I(k)]), C("div", { class: "f-list-remove", onClick: (j) => F(V) }, [C("div", { class: "f-list-remove-icon" }, [C("i", { class: "f-icon f-icon-remove_face" }, null)])]), C("div", { class: "f-list-handle" }, [C("div", null, [C("i", { class: "f-icon f-icon-drag-vertical" }, null)])])]); } return { renderItem: w }; } function mn(e, t, n, r, f, v, d, S, M, g) { var c; const y = T(((c = e.group) == null ? void 0 : c.groupFields) || []), { collpaseGroupIconClass: i } = f, { toggleGroupRow: o } = g; function s(h, u) { u.collapse = !u.collapse, n.value = o(u.collapse ? "collapse" : "expand", u, n.value); } function a(h, u, p) { return t.slots.group ? C(W, null, [t.slots.content && t.slots.group({ item: h.raw, index: u, selectedItem: p })]) : C("div", { class: "f-navlookup-recentHeader", onClick: (B) => s(B, h) }, [C("div", { class: "fv-grid-group-row-icon" }, [C("span", { class: i(h) }, null)]), C("div", { class: "f-navlookup-recommandLabel" }, [h.raw[y.value[h.layer]]])]); } function l(h, u, p) { return h.layer > -1 && a(h, u, p); } return { renderItem: l }; } function vn(e, t, n, r) { const { dataView: f } = n, { updateSelectedItems: v } = r; function d(S) { if (S > -1 && S < f.value.length) { if (e != null && e.checkBeforeRemoveItem && !e.checkBeforeRemoveItem(f.value[S])) return; const M = f.value.splice(S, 1); v(), t.emit("removeItem", M[0]); } } return { removeItem: d }; } function pn(e, t, n, r, f, v, d, S, M, g) { const { t: y } = ie(), i = T(e.view), o = T(e.view === "CardView"), s = T({}), a = T(y("listView.emptyMessage")), l = vn(e, t, r, M), c = $(() => ({ "f-list-view-group": !0, "f-list-view-group-multiselect": e.multiSelect, "d-flex": o.value, "flex-wrap": o.value })), h = $(() => !!n.value && n.value.length > 0), u = $(() => n.value.length === 0); $(() => u.value && !t.slots.empty); function p() { return i.value === "SingleView" ? pe : i.value === "DraggableView" ? fn : (i.value === "ContentView" || i.value === "CardView") && (e.contentTemplate || t.slots.content) ? dn : pe; } const B = p(), { renderItem: R } = B(e, t, n, g, f, v, M, d, l, S), { renderItem: O } = mn(e, t, n, g, f, v, M, d, l, S), P = [R, O]; function F() { return n.value.filter((E) => E.visible !== !1).map((E, b) => P[E.type](E, b, s)); } function m() { return C("div", { class: "f-list-view-emptydata", style: "margin: 0 auto;" }, [C("p", { class: "f-empty-title" }, [e.emptyTemplate ? e.emptyTemplate() : t.slots.empty ? t.slots.empty() : a.value])]); } function D() { return C("ul", { class: c.value, style: "list-style: none;" }, [h.value && F(), u.value && m()]); } return { renderListArea: D }; } function gn(e, t, n) { function r() { return t.slots.header && C("div", { class: "f-list-view-header" }, [t.slots.header()]); } return { renderHeader: r }; } function ge(e, t, n) { const r = T(e.headerClass), f = T(e.placeholder), v = T(""), d = $(() => !v.value), S = $(() => !!v.value); function M(o) { v.value = ""; } G(v, (o) => { e.enableHighlightSearch && n.search(o), t.emit("afterSearch", o); }); const g = $(() => { const o = { "form-group": !0, "farris-form-group": !0 }; return r.value && r.value.split(" ").reduce((a, l) => (a[l] = !0, a), o), o; }); function y(o) { } function i() { return C("div", { class: "f-list-view-header", onClick: xe(() => y, ["prevent", "stop"]) }, [C("div", { class: g.value }, [C("div", { class: "farris-input-wrap" }, [C("div", { class: "f-cmp-inputgroup" }, [C("div", { class: "input-group f-state-editable" }, [Ne(C("input", { class: "form-control f-utils-fill text-left", "onUpdate:modelValue": (o) => v.value = o, name: "input-group-value", type: "text", placeholder: f.value, autocomplete: "off" }, null), [[Ge, v.value]]), C("div", { class: "input-group-append" }, [S.value && C("span", { class: "input-group-text input-group-clear", onClick: (o) => M() }, [C("i", { class: "f-icon f-icon-close-circle" }, null)]), d.value && C("span", { class: "input-group-text" }, [C("span", { class: "f-icon f-icon-search" }, null)])])])])])])]); } return { renderHeader: i }; } function yn() { const e = T(""), t = T(-1), n = T(""), r = T(-1), f = T(!1); function v(i, o, s) { r.value = s; } function d(i, o, s) { f.value || (r.value = s); } function S(i, o, s) { r.value = -1; } function M() { f.value = !0; } function g() { f.value = !1; } function y() { t.value = -1, e.value = ""; } return { activeIndex: t, focusedItemId: n, hoverIndex: r, clearActiveItem: y, onMouseenterItem: v, onMouseoverItem: d, onMouseoutItem: S, resumeHover: g, suspendHover: M }; } function hn(e, t, n, r) { const f = T(e.idField), { dataView: v } = n, d = T(-1), S = T(!1), { activeIndex: M, focusedItemId: g, hoverIndex: y, resumeHover: i, suspendHover: o } = r; let s, a = 0, l = 0; function c(O, P) { const F = O - a, m = P - l; s.style.left = parseInt(s.style.left) + F + "px", s.style.top = parseInt(s.style.top) + m + "px", a = O, l = P; } function h(O) { const { left: P, top: F } = O.getBoundingClientRect(), m = O.cloneNode(!0); return m.style.cssText = ` position:absolute; left:${P}px; top:${document.documentElement.scrollTop ? F + document.documentElement.scrollTop : F}px; z-index: 999999; border: 1px solid #e2e3e5; pointer-events: none; background-color: #edf5ff; border-radius: 10px; margin: 4px 2px; display: flex; align-items: center; float: none; text-align: initial; width:${getComputedStyle(O).width}; height:${getComputedStyle(O).height}; `, m.children[0].style.cssText = "overflow: hidden;flex: 1 1 auto;width: 100%;", m.children[0].children[0].style.cssText = ` margin: 10px 0px 10px 14px; overflow: hidden;text-overflow: ellipsis;white-space: nowrap; `, m.children[1].style.cssText = "width: 30px;color: #f4625f;padding: 0 14px 0 0", m.children[2].style.cssText = "padding: 0 14px 0 0;", document.body.appendChild(m), m; } function u(O, P, F) { if (O.stopPropagation(), o(), P) { if (s = h(O.target), O.dataTransfer) { const m = new Image(); m.src = "", O.dataTransfer.setDragImage(m, 0, 0); } a = O.pageX, l = O.pageY, setTimeout(() => { d.value = F, S.value = !0, P.moving = !0; }); } } function p(O, P) { if (O.preventDefault(), d.value !== P) { const F = v.value[d.value], m = v.value; m.splice(d.value, 1), m.splice(P, 0, F), d.value = P, c(O.pageX, O.pageY); } } function B(O) { O.preventDefault(), O.dataTransfer && (O.dataTransfer.dropEffect = "move"), c(O.pageX, O.pageY); } function R(O, P) { P && (P.moving = !1, s && (document.body.removeChild(s), s = null)), v.value.forEach((F, m) => { F.__fv_index__ = m; }), S.value = !1, i(), y.value = P.raw.__fv_index__, M.value = P.raw.__fv_index__, g.value = P.raw[f.value], t.emit("change", v.value), t.emit("activeChange", [P.raw]); } return { dragstart: u, dragenter: p, dragover: B, dragend: R, isDragging: S }; } function bn(e, t, n, r, f, v) { const d = T(e.idField), S = T(e.disableField), M = T(e.draggable); T(e.itemClass); const g = T(e.selection.multiSelect ?? !1), y = T(e.selection.multiSelectMode), { isDragging: i } = r, { activeIndex: o, focusedItemId: s, hoverIndex: a } = f, { clearSelection: l, getSelectedItems: c, toggleSelectItem: h, currentSelectedDataId: u } = v, p = T(c()), B = (w) => p.value.length === 0 ? !1 : p.value.some((k) => { let V = ""; return k.data ? V = k.data[d.value] : V = k[d.value], V === w; }); function R() { p.value = c(); } function O(w, k) { return w.raw[d.value] != null ? w.raw[d.value] : ""; } function P(w, k) { const V = { "f-list-view-group-item": !0, "f-list-view-draggable-item": M.value, "f-un-click": !w.checked, "f-un-select": !!w.raw[S.value], "f-listview-active": ( // 多选 g.value && B(O(w)) || // 单选 !g.value && w.raw[d.value] === u.value ), "f-listview-hover": !i.value && k === a.value, moving: !!w.moving }; if (typeof e.itemClass == "string") return oe(V, e.itemClass); if (typeof e.itemClass == "function") { const L = e.itemClass(w); return oe(V, L); } return V; } function F(w, k) { const V = ( // 多选 g.value && B(O(w)) || // 单选 !g.value && w.raw[d.value] === u.value ), L = {}; if (V && (L.backgroundColor = "#dae9ff"), typeof e.itemStyle == "string") return me(L, e.itemStyle); if (typeof e.itemStyle == "function") { const j = e.itemStyle(w); return me(L, j); } return L; } const m = $(() => !g.value); function D(w, k, V) { w.checked = V, !w.raw[S.value] && (m.value && (s.value = w.raw[d.value]), h(w)); } const E = $(() => g.value && y.value === "OnCheckClearByClick"), b = $(() => !g.value || g.value && (y.value === "OnCheckAndClick" || y.value === "OnClick")); function I(w, k, V) { if (w.raw[S.value]) { V == null || V.preventDefault(), V == null || V.stopPropagation(); return; } s.value = w.raw[d.value], o.value = k, E.value && l(), b.value && (h(w), R()), t.emit("clickItem", { data: p.value, index: k, dataItem: w.raw }), t.emit("activeChange", p.value); } return { getKey: O, selectedItems: p, listViewItemClass: P, listViewItemStyle: F, updateSelectedItems: R, onCheckItem: D, onClickItem: I }; } const Pe = /* @__PURE__ */ z({ name: "FListView", props: cn, emits: ["afterSearch", "checkValuesChange", "clickItem", "selectItem", "unSelectItem", "selectionChange", "removeItem", "change", "activeChange", "pageIndexChanged", "pageSizeChanged", "changed"], setup(e, t) { const n = T(), r = T(!0), f = T(!1), v = T([]), d = 0, S = T(e.columns), M = We(e, t), g = Ue(e), y = Xe(e), i = Ye(e, g), o = Je(e, /* @__PURE__ */ new Map(), M, y, g), s = Qe(e, o, g, v, t), a = un(e, n), l = Ze(e, o), c = $(() => o.dataView.value.length), h = Ke(e, t, s, g), u = et(e, t, g, h, v), p = tt(e), B = nt(e, {}, p), R = ot(e, o, u, y, g, p, B), O = rt(e, g, B, R), P = it(e, g, B, R), F = lt(e, S, o, c, d, R, O, P), { getVisualData: m } = F; v.value = m(0, c.value + d - 1); const D = $(() => { const A = { "f-list-view": !0, "f-list-view-multiple": e.multiSelect }; return e.size !== "default" && (A[`${e.size}-item`] = !0), oe(A, e.customClass); }), E = $(() => !!t.slots.footer || r.value); function b() { return e.header === "SearchBar" ? ge : e.header === "ContentHeader" ? gn : ge; } const I = b(), { renderHeader: w } = I(e, t, a), k = yn(), V = hn(e, t, o, k), L = bn(e, t, v, V, k, s), { renderListArea: j } = pn(e, t, v, o, i, k, s, F, L, V); function H(A) { a.search(A); } function x(A) { A && (o.load(A), v.value = m(0, c.value + d - 1)); } function _() { s.clearSelection(), k.clearActiveItem(); } function Q() { return L.selectedItems.value; } function Z() { return L.selectedItems.value.map((A) => A[g.idField.value]); } function U(A) { s.selectedValues.value = A, L.updateSelectedItems(); } function X() { return s.currentSelectedDataId.value; } function N(A) { h.activeRowById(A); } function K(A) { const q = g.idField.value, ce = v.value.find((ee) => ee.raw[q] === A), ue = v.value.findIndex((ee) => ee.raw[q] === A); ce && ue > -1 && L.onClickItem(ce, ue); } function Re(A) { l.updatePagination(A); } function De(A) { return v.value.filter((q) => A.includes(q.raw[e.idField])); } t.expose({ search: H, updateDataSource: x, clearSelection: _, getSelections: Q, updateSelectionByIds: U, getSelectionIds: Z, activeRowById: N, getCurrentRowId: X, clickRowItemById: K, updatePagination: Re, getVisibleDataByIds: De }); function Ee(A) { e.multiSelect && (A.preventDefault(), A.stopPropagation()); } G(() => e.selectionValues, (A, q) => { A !== q && U(A); }); const je = at(e, s), { sidebarWidth: Le, showSidebarCheckBox: _n } = je, $e = st(e, t), { applyColumnSorter: zn, columnContext: Ae, updateColumnRenderContext: qn } = $e, He = ct(e, o, v, Ae, F, c, d, Le, u); return ut(e, t, o, He, l, s), () => C("div", { class: D.value, onClick: Ee }, [w(), C("div", { ref: n, class: "f-list-view-content", onMouseover: () => { f.value = !0; }, onMouseleave: () => { f.value = !1; } }, [j()]), E.value && C("div", { class: "f-list-view-footer" }, [e.footerTemplate ? e.footerTemplate() : t.slots.footer && t.slots.footer()])]); } }), Sn = { /** * 组件标识 */ id: String, /** * 设置按钮类型 */ type: { type: String, default: "primary" }, /** * 是否禁用 */ disabled: { type: Boolean, default: !1 }, /** * 按钮尺寸 */ size: { type: String, default: "middle" }, /** * 按钮图标 */ icon: { type: String }, /** * 自定义class */ customClass: { type: Object, default: {} } }; function Cn(e, t) { function n(r) { r.stopPropagation(), e.disabled || t.emit("click", r); } return { onClickButton: n }; } function Fn(e) { const t = $(() => { const r = { "f-icon": !0 }; if (e.icon) { const f = e.icon.trim().split(" "); f && f.length && f.reduce((v, d) => (v[d] = !0, v), r); } return r; }), n = $(() => !!(e.icon && e.icon.trim())); return { iconClass: t, shouldShowIcon: n }; } const Be = /* @__PURE__ */ z({ name: "FButton", props: Sn, emits: ["click"], setup(e, t) { const { onClickButton: n } = Cn(e, t), { iconClass: r, shouldShowIcon: f } = Fn(e), v = $(() => { const d = { btn: !0, "btn-lg": e.size === "large", "btn-md": e.size !== "large" && e.size !== "small", "btn-sm": e.size === "small", "btn-icontext": f.value }; return d[`btn-${e.type}`] = !0, e.customClass && Object.keys(e.customClass).reduce((S, M) => (S[M] = e.customClass[M], S), d), d; }); return () => C("button", { class: v.value, disabled: e.disabled, onClick: (d) => n(d) }, [f.value && C("i", { class: r.value }, null), t.slots.default && t.slots.default()]); } }), wn = /* @__PURE__ */ new Map([ ["appearance", ft] ]), Tn = "https://json-schema.org/draft/2020-12/schema", kn = "https://farris-design.gitee.io/combo-list.schema.json", Mn = "combo-list", On = "A Farris Input Component", Vn = "object", Pn = { id: { description: "The unique identifier for a combo list", type: "string" }, type: { description: "The type string of number combo list component", type: "string", default: "combo-list" }, appearance: { description: "", type: "object", properties: { class: { type: "string" }, style: { type: "string" } }, default: {} }, binding: { description: "", type: "object", default: {} }, disabled: { description: "", type: "boolean", default: !1 }, enableClear: { description: "", type: "boolean", default: !1 }, editable: { description: "", type: "boolean", default: !1 }, enableLinkLabel: { description: "", type: "boolean", default: !1 }, label: { description: "", type: "string", default: "" }, lableWidth: { description: "", type: "number" }, placeholder: { description: "", type: "string", default: "请选择" }, idField: { description: "", type: "string", default: "id" }, valueField: { description: "", type: "string", default: "id" }, titleField: { description: "", type: "string", default: "name" }, textField: { description: "", type: "string", default: "name" }, dataSourceType: { description: "", type: "string", default: "static" }, data: { description: "", type: "array" }, remote: { description: "", type: "string" }, readonly: { description: "", type: "boolean", default: !1 }, required: { description: "", type: "boolean", default: !1 }, tabindex: { description: "", type: "number", default: -1 }, textAlign: { description: "", type: "string", enum: [ "left", "middle", "right" ], default: "l