UNPKG

@farris/ui-vue

Version:

Farris Vue, a Farris Design based Vue3 component library.

1,390 lines (1,389 loc) 44.2 kB
import { ref as O, computed as F, watch as H, createVNode as f, defineComponent as I, watchEffect as we, Fragment as _, createTextVNode as V, inject as Te, onMounted as Pe } from "vue"; import { cloneDeep as Y, isPlainObject as Z } from "lodash-es"; import { useI18n as J } from "vue-i18n"; import { getSchemaByTypeForDesigner as Fe } from "../dynamic-resolver/index.esm.js"; import { withInstall as Me } from "../common/index.esm.js"; function K(e, t) { let n; function o(r) { const { properties: v, title: h, ignore: i } = r, a = i && Array.isArray(i), d = Object.keys(v).reduce((m, S) => ((!a || !i.find((N) => N === S)) && (m[S] = v[S].type === "object" && v[S].properties ? o(v[S]) : Y(v[S].default)), m), {}); if (h && (!a || !i.find((m) => m === "id"))) { const m = h.toLowerCase().replace(/-/g, "_"); d.id = `${m}_${Math.random().toString().slice(2, 6)}`; } return d; } function c(r) { const { properties: v, title: h, required: i } = r; if (i && Array.isArray(i)) { const a = i.reduce((d, m) => (d[m] = v[m].type === "object" && v[m].properties ? o(v[m]) : Y(v[m].default), d), {}); if (h && i.find((d) => d === "id")) { const d = h.toLowerCase().replace(/-/g, "_"); a.id = `${d}_${Math.random().toString().slice(2, 6)}`; } return a; } return { type: h }; } function T(r, v = {}, h) { const i = e[r]; if (i) { let a = c(i); const d = t[r]; return a = d ? d({ getSchemaByType: T }, a, v, h) : a, n != null && n.appendIdentifyForNewControl && n.appendIdentifyForNewControl(a), a; } return null; } function u(r, v) { const h = o(v); return Object.keys(h).reduce((i, a) => (Object.prototype.hasOwnProperty.call(r, a) && (i[a] && Z(i[a]) && Z(r[a] || !r[a]) ? Object.assign(i[a], r[a] || {}) : i[a] = r[a]), i), h), h; } function s(r, v) { return Object.keys(r).filter((i) => r[i] != null).reduce((i, a) => { if (v.has(a)) { const d = v.get(a); if (typeof d == "string") i[d] = r[a]; else { const m = d(a, r[a], r); Object.assign(i, m); } } else i[a] = r[a]; return i; }, {}); } function y(r, v, h = /* @__PURE__ */ new Map()) { const i = u(r, v); return s(i, h); } function l(r) { var h; const v = r.type; if (v) { const i = e[v]; if (!i) return r; const a = u(r, i), d = ((h = r.editor) == null ? void 0 : h.type) || ""; if (d) { const m = e[d], S = u(r.editor, m); a.editor = S; } return a; } return r; } function p(r) { n = r; } return { getSchemaByType: T, resolveSchemaWithDefaultValue: l, resolveSchemaToProps: y, mappingSchemaToProps: s, setDesignerContext: p }; } const ee = {}, te = {}, { getSchemaByType: Tt, resolveSchemaWithDefaultValue: Oe, resolveSchemaToProps: ke, mappingSchemaToProps: Ne, setDesignerContext: Pt } = K(ee, te); function je(e = {}) { function t(l, p, r, v) { if (typeof r == "number") return v[l].length === r; if (typeof r == "object") { const h = Object.keys(r)[0], i = r[h]; if (h === "not") return Number(v[l].length) !== Number(i); if (h === "moreThan") return Number(v[l].length) >= Number(i); if (h === "lessThan") return Number(v[l].length) <= Number(i); } return !1; } function n(l, p, r, v) { return v[l] && v[l].propertyValue && String(v[l].propertyValue.value) === String(r); } const o = /* @__PURE__ */ new Map([ ["length", t], ["getProperty", n] ]); Object.keys(e).reduce((l, p) => (l.set(p, e[p]), l), o); function c(l, p) { const r = l; return typeof p == "number" ? [{ target: r, operator: "length", param: null, value: Number(p) }] : typeof p == "boolean" ? [{ target: r, operator: "getProperty", param: l, value: !!p }] : typeof p == "object" ? Object.keys(p).map((v) => { if (v === "length") return { target: r, operator: "length", param: null, value: p[v] }; const h = v, i = p[v]; return { target: r, operator: "getProperty", param: h, value: i }; }) : []; } function T(l) { return Object.keys(l).reduce((r, v) => { const h = c(v, l[v]); return r.push(...h), r; }, []); } function u(l, p) { if (o.has(l.operator)) { const r = o.get(l.operator); return r && r(l.target, l.param, l.value, p) || !1; } return !1; } function s(l, p) { return T(l).reduce((h, i) => h && u(i, p), !0); } function y(l, p) { const r = Object.keys(l), v = r.includes("allOf"), h = r.includes("anyOf"), i = v || h, m = (i ? l[i ? v ? "allOf" : "anyOf" : "allOf"] : [l]).map((N) => s(N, p)); return v ? !m.includes(!1) : m.includes(!0); } return { parseValueSchema: y }; } const Be = { convertTo: (e, t, n, o) => { e.appearance || (e.appearance = {}), e.appearance[t] = n; }, convertFrom: (e, t, n) => e.appearance ? e.appearance[t] : e[t] }, De = { convertFrom: (e, t, n) => e.buttons && e.buttons.length ? `共 ${e.buttons.length} 项` : "无" }, Ee = { convertTo: (e, t, n, o) => { e.editor && (e.editor[t] = n); }, convertFrom: (e, t, n) => e.editor && Object.prototype.hasOwnProperty.call(e.editor, t) ? e.editor[t] : e[t] }, ne = { 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: "多语输入框" } }, Ce = { convertFrom: (e, t, n) => { var c; const o = e.editor && e.editor[t] ? e.editor[t] : e[t]; return ((c = ne[o]) == null ? void 0 : c.name) || o; } }, $e = { convertTo: (e, t, n, o) => { e[t] = e[t]; }, convertFrom: (e, t, n) => e.editor ? n.getRealEditorType(e.editor.type) : "" }, Le = { convertTo: (e, t, n, o) => { (e.type === "data-grid-column" || e.type === "tree-grid-column") && (e.formatter ? e.formatter[t] = n : e.formatter = { [t]: n }); }, convertFrom: (e, t, n) => { if (e.formatter) { if (t === "trueText") return e.formatter.trueText; if (t === "falseText") return e.formatter.falseText; if (t === "prefix") return e.formatter.prefix; if (t === "suffix") return e.formatter.suffix; if (t === "precision") return e.formatter.precision; if (t === "decimal") return e.formatter.decimal; if (t === "thousand") return e.formatter.thousand; if (t === "tempDateFormat") return e.formatter.dateFormat === "yyyy年MM月dd日" ? "yearMonthDay" : e.formatter.dateFormat === "yyyy-MM-dd HH:mm:ss" ? "yyyy-MM-ddTHH:mm:ss" : e.formatter.dateFormat === "yyyy/MM/dd HH:mm:ss" ? "yyyy/MM/ddTHH:mm:ss" : e.formatter.dateFormat === "yyyy年MM月dd日 HH时mm分ss秒" ? "yearMonthDayHourMinuteSecond" : e.formatter.tempDateFormat || e.formatter.dateFormat || "yyyy-MM-dd"; if (t === "customFormat") return e.formatter.customFormat; if (t === "type") return e.formatter.type || "none"; } return "none"; } }, ze = { convertTo: (e, t, n, o) => { e.command ? e.command[t] = n : e.command = { [t]: n }, t === "enable" && n && (e.command.commands || (e.command.commands = [ { text: "编辑", type: "primary", command: "edit" }, { text: "删除", type: "danger", command: "remove" } ])); }, convertFrom: (e, t, n) => e.command && t === "enable" ? e.command.enable : "" }, Re = { convertTo: (e, t, n, o) => { e.column ? e.column[t] = n : e.column = { [t]: n }, t === "fitColumns" && n && (e.column.fitMode || (e.column.fitMode = "average")); }, convertFrom: (e, t, n) => { if (e.column) { if (t === "fitColumns") return e.column.fitColumns; if (t === "fitMode") return e.column.fitMode; } return ""; } }, xe = { convertTo: (e, t, n, o) => { e.summary ? e.summary[t] = n : e.summary = { [t]: n }, t === "enable" && n && (e.summary ? e.summary.groupFields || (e.summary.groupFields = []) : e.summary = { enable: n, groupFields: [] }); }, convertFrom: (e, t, n) => e.summary && t === "enable" ? e.summary.enable : e.type === "data-grid-column" ? e.enableSummary === void 0 ? !1 : e.enableSummary : "" }, Ae = { convertTo: (e, t, n, o) => { e.group ? e.group[t] = n : e.group = { [t]: n }, t === "enable" && n && (e.group ? e.group.groupFields || (e.group.groupFields = []) : e.group = { enable: n, groupFields: [], showSummary: !1 }); }, convertFrom: (e, t, n) => { if (e.group) { if (t === "enable") return e.group.enable; if (t === "showSummary") return e.group.showSummary; } } }, qe = { convertFrom: (e, t) => e.binding ? e.binding.path : "", convertTo: (e, t, n) => { if (n && n.length > 0) { const o = n[0]; e.binding || (e.binding = {}), e.binding.type = "Form", e.binding.path = o.bindingField, e.binding.field = o.id, e.binding.fullPath = o.path, e.path = o.bindingPath; } } }, Ge = { convertTo: (e, t, n, o) => { e.pagination || (e.pagination = {}), e.pagination[t] = n; }, convertFrom: (e, t, n) => e.pagination ? e.pagination[t] : e[t] }, He = { convertTo: (e, t, n, o) => { e.rowNumber || (e.rowNumber = {}), e.rowNumber[t] = n; }, convertFrom: (e, t, n) => e.rowNumber ? e.rowNumber[t] : e[t] }, We = { convertTo: (e, t, n, o) => { e.selection || (e.selection = {}), e.selection[t] = n; }, convertFrom: (e, t, n) => e.selection ? e.selection[t] : e[t] }, _e = { convertFrom: (e, t, n) => e[t] && e[t].length ? `共 ${e[t].length} 项` : "" }, Ve = { convertFrom: (e, t) => e[t] || "", convertTo: (e, t, n) => { e[t] = n; } }, Ue = { convertTo: (e, t, n, o) => { e.size || (e.size = {}), e.size[t] = n; }, convertFrom: (e, t, n) => e.size ? e.size[t] : e[t] }, Je = { convertFrom: (e, t, n) => { var o, c; return (o = e.formatter) != null && o.data && t === "formatterEnumData" && !e.formatterEnumData ? (c = e.formatter) == null ? void 0 : c.data : e.formatterEnumData; } }, Qe = { convertTo: (e, t, n, o) => { e.sort || (e.sort = {}), e.sort[t] = n; }, convertFrom: (e, t, n) => { var o, c; if (t === "mode") return ((o = e.sort) == null ? void 0 : o.mode) || "client"; if (t === "multiSort") return !!((c = e.sort) != null && c.multiSort); } }, Xe = { convertTo: (e, t, n, o) => { e.filter || (e.filter = {}), e.filter[t] = n; }, convertFrom: (e, t, n) => { var o; if (t === "mode") return ((o = e.filter) == null ? void 0 : o.mode) || "client"; } }, Ye = { convertTo: (e, t, n, o) => { e.rowOption ? e.rowOption[t] = n : e.rowOption = { [t]: n }; }, convertFrom: (e, t, n) => { if (e.rowOption) { if (t === "customRowStyle") return e.rowOption.customRowStyle; if (t === "customCellStyle") return e.rowOption.customCellStyle; } return ""; } }; function re(e, t, n) { const o = /* @__PURE__ */ new Map([ ["/converter/appearance.converter", Be], ["/converter/buttons.converter", De], ["/converter/property-editor.converter", Ee], ["/converter/items-count.converter", _e], ["/converter/type.converter", Ce], ["/converter/change-editor.converter", $e], ["/converter/change-formatter.converter", Le], ["/converter/column-command.converter", ze], ["/converter/column-option.converter", Re], ["/converter/summary.converter", xe], ["/converter/group.converter", Ae], ["/converter/form-group-label.converter", Ve], ["/converter/field-selector.converter", qe], ["/converter/pagination.converter", Ge], ["/converter/row-number.converter", He], ["/converter/grid-selection.converter", We], ["/converter/size.converter", Ue], ["/converter/change-formatter-enum.converter", Je], ["/converter/grid-sort.converter", Qe], ["/converter/grid-filter.converter", Xe], ["/converter/row-option.converter", Ye] ]), c = /* @__PURE__ */ new Map([ ["string", { type: "input-group", enableClear: !1 }], ["boolean", { type: "combo-list", textField: "name", valueField: "value", idField: "value", enableClear: !1, editable: !1, data: [ { value: !0, name: "是" }, { value: !1, name: "否" } ] }], ["enum", { type: "combo-list", maxHeight: 128, enableClear: !1, editable: !1 }], ["array", { type: "button-edit" }], ["number", { type: "number-spinner", placeholder: "" }], ["events-editor", { type: "events-editor", hide: !0 }] ]), T = je(); function u(i, a) { return () => T.parseValueSchema(i, a); } function s(i, a, d) { return i.includes("visible") && a.visible !== void 0 ? typeof a.visible == "boolean" ? () => !!a.visible : a.visible === void 0 ? !0 : u(a.visible, d) : () => !0; } function y(i, a, d) { return i.includes("readonly") && a.readonly !== void 0 ? typeof a.readonly == "boolean" ? () => !!a.readonly : u(a.readonly, d) : () => !1; } function l(i, a) { const d = i.$converter || a; return typeof d == "string" && d && o.has(d) ? o.get(d) || null : d || null; } function p(i, a, d, m, S, N = "", z = "") { return Object.keys(i).map((k) => { const D = O(1), B = k, b = i[k], E = Object.keys(b), x = b.title, g = b.type, P = c.get(g) || { type: "input-group", enableClear: !1 }, w = b.editor ? Object.assign({}, P, b.editor) : Object.assign({}, P), M = s(E, b, a), j = y(E, b, a); w.readonly = w.readonly === void 0 ? j() : w.readonly; const R = b.type === "cascade" ? p(b.properties, a, d, m, S, N, z) : [], q = !0; let $ = l(b, z); const A = F({ get() { if (D.value) { if (["class", "style"].find((Se) => Se === B) && !$ && ($ = o.get("/converter/appearance.converter") || null), $ && $.convertFrom) return $.convertFrom(d, k, S, N); const G = d[k]; return Object.prototype.hasOwnProperty.call(b, "defaultValue") && (G === void 0 || typeof G == "string" && G === "") ? b.type === "boolean" ? b.defaultValue : b.defaultValue || "" : G; } return null; }, set(G) { D.value += 1, $ && $.convertTo ? ($.convertTo(m, k, G, S, N), $.convertTo(d, k, G, S, N)) : (m[k] = G, d[k] = G); } }), { refreshPanelAfterChanged: C, description: W, isExpand: ye, parentPropertyID: he } = b, X = { propertyID: B, propertyName: x, propertyType: g, propertyValue: A, editor: w, visible: M, readonly: j, cascadeConfig: R, hideCascadeTitle: q, refreshPanelAfterChanged: C, description: W, isExpand: ye, parentPropertyID: he }; return a[B] = X, X; }); } function r(i, a, d = {}) { const m = {}, S = e[i]; return S && S.categories ? Object.keys(S.categories).map((z) => { const L = S.categories[z], k = L == null ? void 0 : L.title, D = p(L.properties || {}, m, {}, d, a); return { categoryId: z, categoryName: k, properties: D }; }) : []; } function v(i, a, d, m, S = "") { const N = a.$ref.schema, z = a.$ref.converter, L = d[N], k = L.type, D = n(L), B = {}, b = e[k]; if (b && b.categories) { const E = b.categories[i], x = E == null ? void 0 : E.title; z && Object.keys(E.properties).forEach((w) => { E.properties[w].$converter = z; }); const g = (E == null ? void 0 : E.properties) || {}, P = p(g, B, D, L, m, S); return { categoryId: i, categoryName: x, properties: P }; } return { categoryId: i, categoryName: "", properties: [] }; } function h(i, a, d, m, S) { const N = i.type, z = n(i), L = {}; let k = S || e[N]; if (k && Object.keys(k).length === 0 && d && d.getPropConfig && (k = d.getPropConfig(m)), k && k.categories) { const D = []; return Object.keys(k.categories).map((B) => { const b = k.categories[B]; if (b.$ref) { D.push(v(B, b, i, a, m)); return; } const E = b == null ? void 0 : b.title, x = b == null ? void 0 : b.tabId, g = b == null ? void 0 : b.tabName, P = b == null ? void 0 : b.hide, w = b == null ? void 0 : b.hideTitle, M = p(b.properties || {}, L, z, i, a, m, b.$converter), { setPropertyRelates: j } = b, R = b == null ? void 0 : b.parentPropertyID; D.push({ categoryId: B, categoryName: E, tabId: x, tabName: g, hide: P, properties: M, hideTitle: w, setPropertyRelates: j, parentPropertyID: R }); }), D; } return []; } return { getPropertyConfigBySchema: h, getPropertyConfigByType: r, propertyConverterMap: o }; } const oe = {}, ae = {}; re(oe, ae, Oe); const ie = {}, le = {}, { getSchemaByType: Ft, resolveSchemaWithDefaultValue: Ze, resolveSchemaToProps: Mt, mappingSchemaToProps: Ot, setDesignerContext: kt } = K(ie, le), se = {}, ue = {}; re(se, ue, Ze); function Ie(e, t, n = /* @__PURE__ */ new Map(), o = (u, s, y, l) => s, c = {}, T = (u) => u) { return ee[t.title] = t, te[t.title] = o, oe[t.title] = c, ae[t.title] = T, ie[t.title] = t, le[t.title] = o, se[t.title] = c, ue[t.title] = T, (u = {}, s = !0) => { if (!s) return Ne(u, n); const y = ke(u, t, n), l = Object.keys(e).reduce((p, r) => (p[r] = e[r].default, p), {}); return Object.assign(l, y); }; } function Ke(e, t) { return { customClass: t.class, customStyle: t.style }; } const et = /* @__PURE__ */ new Map([ ["appearance", Ke] ]), tt = "https://json-schema.org/draft/2020-12/schema", nt = "https://farris-design.gitee.io/pagination.schema.json", rt = "pagination", ot = "A Farris Component", at = "object", it = { id: { description: "The unique identifier for a pagination", type: "string" }, type: { description: "The type string of pagination component", type: "string", default: "pagination" }, 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: "" } }, lt = [ "id", "type" ], st = { $schema: tt, $id: nt, title: rt, description: ot, type: at, properties: it, required: lt }, ut = "pagination", ct = "A Farris Component", pt = "object", ft = { 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: "右对齐" } ] } } } } }, vt = { title: ut, description: ct, type: pt, categories: ft }; function dt(e, t, n) { return t; } const Q = { /** * 当前页码 */ currentPage: { type: Number, default: 1 }, /** * 禁止点击分页组件 */ disabled: { type: Boolean, default: !1 }, /** * 分页模式 */ mode: { type: String, default: "default" }, /** * 每页数量 */ pageSize: { type: Number, default: 20 }, /** * 总数量 */ totalItems: { type: Number, default: 0 }, /** * 是否显示跳转按钮 */ showGoButton: { type: Boolean, default: !1 }, /** * 是否展示每个数量下拉 */ showPageList: { type: Boolean, default: !0 }, /** * 是否展示页码 */ showPageNumbers: { type: Boolean, default: !0 }, /** * 是否展示跳转到哪一页 */ showRedirection: { type: Boolean, default: !0 }, /** * 自定义每页数量 */ pageList: { type: Array, default: [20, 50, 100] }, /** * 是否展示分页汇总信息 */ showPageInfo: { type: Boolean, default: !1 } }, ce = Ie(Q, st, et, dt, vt); function pe(e, t, n, o) { const { t: c } = J(), T = O(c("pagination.goto.prefix")), u = O(""), s = O(e.value); H(s, (r, v) => { r >= 1 && r <= t.value ? e.value = r : s.value = v; }), H(e, (r) => { s.value !== r && (s.value = r); }); function y(r) { s.value = r.target.valueAsNumber, o.emit("update:currentPage", s.value), o.emit("changed", { pageIndex: s.value, pageSize: n.value }), o.emit("pageIndexChanged", { pageIndex: s.value, pageSize: n.value }); } function l(r) { r.key === "Enter" && (s.value = r.target.valueAsNumber, o.emit("update:currentPage", s.value), o.emit("changed", { pageIndex: s.value, pageSize: n.value }), o.emit("pageIndexChanged", { pageIndex: s.value, pageSize: n.value })); } function p() { return f("li", { class: "page-goto-input d-flex flex-row", style: "padding-left: 10px; white-space: nowrap;" }, [f("span", { class: "pagination-message" }, [T.value]), f("input", { title: "page-index-spinner", type: "number", class: "form-control farris-gotopagenumber", value: s.value, min: 1, max: t.value, style: "display: inline-block;margin-left:3px;", onBlur: (r) => y(r), onKeyup: (r) => l(r) }, null), u.value]); } return { renderGotoButton: p }; } function fe(e, t, n, o, c) { const T = F(() => ({ "page-item": !0, disabled: t.value })); function u(p) { e.value = e.value < n.value ? e.value + 1 : n.value, c.emit("update:currentPage", e.value), c.emit("changed", { pageIndex: e.value, pageSize: o.value }), c.emit("pageIndexChanged", { pageIndex: e.value, pageSize: o.value }); } function s(p) { e.value = n.value, c.emit("update:currentPage", e.value), c.emit("changed", { pageIndex: e.value, pageSize: o.value }), c.emit("pageIndexChanged", { pageIndex: e.value, pageSize: o.value }); } function y() { return f("li", { class: T.value }, [!t.value && f("a", { class: "page-link", tabindex: "0", onClick: (p) => u() }, [f("span", { class: "f-icon f-page-next" }, null)]), t.value && f("span", { class: "page-link" }, [f("span", { class: "f-icon f-page-next" }, null)])]); } function l() { return f("li", { class: T.value }, [!t.value && f("a", { class: "page-link", tabindex: "0", onClick: (p) => s() }, [f("span", { class: "f-icon f-page-last" }, null)]), t.value && f("span", { class: "page-link" }, [f("span", { class: "f-icon f-page-last" }, null)])]); } return { renderLastPage: l, renderNextPage: y }; } function ve(e, t) { const { t: n } = J(), o = O(n("pagination.totalInfo.firstText")), c = O(n("pagination.totalInfo.lastText")), T = F(() => ({ "pagination-message": !0, "text-truncate": !0, "d-flex": !0, "ml-auto": e.value === "right", "flex-fill": e.value === "right" })); function u() { return f("li", { class: T.value }, [f("div", { class: "text-truncate" }, [f("span", { class: "pg-message-text" }, [o.value]), f("b", { class: "pg-message-total" }, [t.value]), f("span", { class: "pg-message-text" }, [c.value])])]); } return { renderPageInfo: u }; } function de(e, t, n, o, c) { const { t: T } = J(), u = O(!1), s = O(T("pagination.show")), y = O(T("pagination.totalInfo.lastText")), l = F(() => ({ dropup: !0, "dropdown-right": !0, "pg-pagelist": !0, "pagelist-disabled": o.value === 0, show: u.value })), p = F(() => ({ "dropdown-menu": !0, show: u.value })), r = (m) => ({ "w-100": !0, "dropdown-item": !0, active: t.value === m }); function v(m) { u.value = !0; } function h(m) { u.value = !1; } function i(m, S, N) { const L = m * S - S + 1; return Math.ceil(L / N); } function a(m, S) { const N = e.value; e.value = i(e.value, t.value, S), N !== e.value && c.emit("update:currentPage", e.value), t.value = S, u.value = !1, c.emit("update:pageSize", t.value), c.emit("changed", { pageIndex: e.value, pageSize: t.value }), c.emit("pageSizeChanged", { pageIndex: e.value, pageSize: t.value }); } function d() { return f("li", { class: "pagination-pagelist" }, [f("div", { class: l.value, onMouseenter: (m) => v(), onMouseleave: (m) => h() }, [f("div", { class: "pg-pagelist-info" }, [f("span", { class: "pagelist-text" }, [s.value]), f("b", { class: "cur-pagesize" }, [t.value]), f("span", { class: "pagelist-text" }, [y.value]), f("i", { class: "f-icon f-icon-dropdown" }, null)]), f("div", { class: p.value, style: "margin-bottom: -1px;" }, [n.value.map((m) => f("li", { class: r(m), onClick: (S) => a(S, m) }, [f("span", null, [m])]))])])]); } return { renderPageList: d }; } function me(e, t, n, o, c) { const T = (l) => ({ "page-item": !0, current: t.value === l.value, ellipsis: l.label === "...", disabled: e.disabled }), u = (l) => ({ "f-icon": !0, "f-icon-arrow-seek-left": l.value < t.value, "f-icon-arrow-seek-right": l.value > t.value }); function s(l, p) { t.value = p, c.emit("update:currentPage", t.value), c.emit("changed", { pageIndex: t.value, pageSize: o.value }), c.emit("pageIndexChanged", { pageIndex: t.value, pageSize: o.value }); } function y() { return n.value.map((l) => f("li", { class: T(l), key: l.value + "" }, [t.value !== l.value && f("a", { class: "page-link", tabindex: "0", onClick: (p) => s(p, l.value) }, [f("span", { class: "page-link-label" }, [l.label]), l.label === "..." && f("i", { class: u(l) }, null)]), t.value === l.value && f("span", { class: "page-link" }, [l.label])])); } return { renderPageNumbers: y }; } function ge(e, t, n, o, c) { const T = F(() => ({ "page-item": !0, disabled: t.value })); function u(p) { e.value = 1, c.emit("update:currentPage", e.value), c.emit("changed", { pageIndex: e.value, pageSize: o.value }), c.emit("pageIndexChanged", { pageIndex: e.value, pageSize: o.value }); } function s(p) { e.value = e.value > 2 ? e.value - 1 : 1, c.emit("update:currentPage", e.value), c.emit("changed", { pageIndex: e.value, pageSize: o.value }), c.emit("pageIndexChanged", { pageIndex: e.value, pageSize: o.value }); } function y() { return f("li", { class: T.value }, [n.value && f("a", { tabindex: "0", class: "page-link", onClick: (p) => u() }, [f("span", { class: "f-icon f-page-first" }, null)]), t.value && f("span", { class: "page-link" }, [f("span", { class: "f-icon f-page-first" }, null)])]); } function l() { return f("li", { class: T.value }, [n.value && f("a", { tabindex: "0", class: "page-link", onClick: (p) => s() }, [f("span", { class: "f-icon f-page-pre" }, null)]), t.value && f("span", { class: "page-link" }, [f("span", { class: "f-icon f-page-pre" }, null)])]); } return { renderFirstPage: y, renderPreviousPage: l }; } function be(e) { const t = O([]); function n(c, T, u, s) { const y = Math.ceil(u / 2); return c === u ? s : c === 1 ? c : u < s ? s - y < T ? s - u + c : y < T ? T - y + c : c : c; } function o(c, T, u, s) { const y = [], l = Math.ceil(u / T), p = Math.ceil(s / 2), r = c <= p, v = l - p < c, h = !r && !v, i = s < l; let a = 1; for (; a <= l && a <= s; ) { const d = n(a, c, s, l), m = a === 2 && (h || v), S = a === s - 1 && (h || r), N = i && (m || S) ? "..." : "" + d; y.push({ label: N, value: d }), a++; } t.value = y; } return { pages: t, updatePages: o }; } const U = /* @__PURE__ */ I({ name: "FPagination", props: Q, emits: ["changed", "pageIndexChanged", "pageSizeChanged", "update:currentPage", "update:pageSize"], setup(e, t) { const n = O(!1), o = O(e.mode), c = O(""), T = O(!1), u = O(e.pageSize), s = O(e.currentPage), y = O(e.totalItems), { pages: l, updatePages: p } = be(), r = { position: "relative" }, v = { position: "absolute", right: "0", zIndex: 1, background: "rgba(250,250,252,.6)", width: "100%", height: "100%" }, h = F(() => !y.value || s.value === 1), i = F(() => e.pageList), a = F(() => Math.ceil(y.value / u.value)), d = F(() => !y.value || s.value === a.value), m = F(() => e.showGoButton), S = F(() => !!y.value && s.value > 1), N = F(() => !(T.value && l.value.length <= 1)), z = F(() => e.showPageInfo), L = F(() => e.showPageList), k = F(() => e.showPageNumbers), D = F(() => !0), { renderFirstPage: B, renderPreviousPage: b } = ge(s, h, S, u, t), { renderLastPage: E, renderNextPage: x } = fe(s, d, a, u, t), { renderPageInfo: g } = ve(c, y), { renderPageList: P } = de(s, u, i, y, t), { renderPageNumbers: w } = me(e, s, l, u, t), { renderGotoButton: M } = pe(s, a, u, t); p(s.value, u.value, y.value, 7), H(() => e.totalItems, (C) => { y.value = C, p(s.value, u.value, y.value, 7); }), H(() => e.currentPage, (C, W) => { C !== W && (s.value = C, p(s.value, u.value, y.value, 7)); }), H(() => e.pageSize, (C, W) => { C !== W && (u.value = C, p(s.value, u.value, y.value, 7)); }), we(() => { if (!i.value || !i.value.length) return; const C = i.value.includes(u.value); u.value = C ? u.value : i.value[0], C || t.emit("update:pageSize", u.value); })(); const R = F(() => ({ "d-flex": !0, "flex-wrap": !0, "justify-content-end": !0, "w-100": !0, "ngx-pagination": !0, pagination: !0, responsive: n.value, "pager-viewmode-default": o.value === "default", "pager-viewmode-simple": o.value === "simple" })), q = F(() => ({ position: "relative", "justify-content": c.value === "center" ? "center" : "start" })); function $() { return f(_, null, [z.value && g(), L.value && P(), D.value && B(), D.value && b(), k.value && w(), D.value && x(), D.value && E(), m.value && M()]); } function A() { return f(_, null, [f("li", { class: "page-item d-flex flex-fill" }, null), D.value && B(), D.value && b(), M(), f("li", { class: "page-item page-separator", style: "margin-left: 10px" }, [f("span", { style: "font-size: 15px; font-weight: 200;" }, [V(" /")])]), f("li", { class: "page-item page-total", style: "margin-left: 5px" }, [f("span", { style: "font-size: 16px; font-weight: 600;" }, [V(" "), a.value])]), D.value && x(), D.value && E()]); } return () => f("div", { class: "pagination-container", style: r }, [e.disabled && f("div", { style: v }, null), N.value && f("ul", { role: "navigation", class: R.value, style: q.value }, [o.value === "default" ? $() : A()])]); } }); function mt(e, t, n) { var x; const o = "", c = "", T = O(); let u; function s() { return (t == null ? void 0 : t.schema.componentType) !== "frame"; } function y() { return !1; } function l() { return (t == null ? void 0 : t.schema.componentType) !== "frame"; } function p() { return (t == null ? void 0 : t.schema.componentType) === "frame"; } function r(g) { if (!g || !g.value) return null; if (g.value.schema && g.value.schema.type === "component") return g.value; const P = O(g == null ? void 0 : g.value.parent), w = r(P); return w || null; } function v(g = t) { var j; const { componentInstance: P, designerItemElementRef: w } = g; if (!P || !P.value) return null; const { getCustomButtons: M } = P.value; return P.value.canMove || M && ((j = M()) != null && j.length) ? w : v(g.parent); } function h(g) { return !!n; } function i() { return (t == null ? void 0 : t.schema.label) || (t == null ? void 0 : t.schema.title) || (t == null ? void 0 : t.schema.name); } function a() { } function d(g, P) { var w; !g || !P || (w = t == null ? void 0 : t.setupContext) == null || w.emit("dragEnd"); } function m(g, P) { const { componentType: w } = g; let M = Fe(w, g, P); const j = w.toLowerCase().replace(/-/g, "_"); return M && !M.id && M.type === w && (M.id = `${j}_${Math.random().toString().slice(2, 6)}`), M; } function S(g) { } function N(...g) { } function z(g) { if (!g) return; const P = t == null ? void 0 : t.schema, { formSchemaUtils: w } = g; if (P && w.getExpressions().length) { const M = w.getExpressions().findIndex((j) => j.target === P.id); M > -1 && w.getExpressions().splice(M, 1); } } function L(g) { if (!g || !(t != null && t.schema)) return; const P = t.schema, { formSchemaUtils: w } = g; w.removeCommunicationInComponent(P); } function k(g) { z(g), L(g), t != null && t.schema.contents && t.schema.contents.map((P) => { let w = P.id; P.type === "component-ref" && (w = P.component); const M = e.value.querySelectorAll(`#${w}-design-item`); M != null && M.length && Array.from(M).map((j) => { var R; (R = j == null ? void 0 : j.componentInstance) != null && R.value.onRemoveComponent && j.componentInstance.value.onRemoveComponent(g); }); }); } function D() { } function B(g) { var w, M; if (!((w = t == null ? void 0 : t.schema) != null && w.id)) return; !u && g && (u = g.formSchemaUtils); let P = ""; { const { text: j, title: R, label: q, mainTitle: $, name: A, type: C } = t.schema; P = j || R || q || $ || A || ((M = ne[C]) == null ? void 0 : M.name); } P && u.getControlBasicInfoMap().set(t.schema.id, { componentTitle: P, parentPathName: P }); } function b(g) { var j; const { changeObject: P } = g, { propertyID: w, propertyValue: M } = P; if (["text", "title", "label", "name", "mainTitle"].includes((j = g == null ? void 0 : g.changeObject) == null ? void 0 : j.propertyID) && w && M && (B(), u)) { const R = u.getControlBasicInfoMap(), q = R.keys().toArray().filter(($) => { var A, C; return ((A = R.get($)) == null ? void 0 : A.reliedComponentId) === ((C = t == null ? void 0 : t.schema) == null ? void 0 : C.id); }); q != null && q.length && q.forEach(($) => { const A = R.get($).parentPathName.split(" > "); A[0] = M, R.get($).parentPathName = A.join(" > "); }); } } function E(g) { b(g); } return T.value = { canMove: s(), canSelectParent: y(), canDelete: l(), canNested: !p(), contents: t == null ? void 0 : t.schema.contents, elementRef: e, parent: (x = t == null ? void 0 : t.parent) == null ? void 0 : x.componentInstance, schema: t == null ? void 0 : t.schema, styles: o, designerClass: c, canAccepts: h, getBelongedComponentInstance: r, getDraggableDesignItemElement: v, getDraggingDisplayText: i, getPropConfig: N, getDragScopeElement: a, onAcceptMovedChildElement: d, onChildElementMovedOut: S, addNewChildComponentSchema: m, triggerBelongedComponentToMoveWhenMoved: O(!1), triggerBelongedComponentToDeleteWhenDeleted: O(!1), onRemoveComponent: k, getCustomButtons: D, onPropertyChanged: E, setComponentBasicInfoMap: B, updateContextSchema: t == null ? void 0 : t.updateContextSchema }, T; } const gt = /* @__PURE__ */ I({ name: "FPagination", props: Q, emits: ["pageIndexChanged", "pageSizeChanged"], setup(e, t) { const n = O(!1), o = O(e.mode), c = O(""), T = O(!1), u = O(e.pageSize), s = O(e.currentPage), y = O(e.totalItems), l = O(), p = Te("design-item-context"), r = mt(l, p); Pe(() => { l.value.componentInstance = r; }), t.expose(r.value); const { pages: v, updatePages: h } = be(), i = F(() => s.value === 1), a = F(() => [20, 50, 100]), d = F(() => Math.ceil(y.value / u.value)), m = F(() => s.value === d.value), S = F(() => !0), N = F(() => s.value > 1), z = F(() => !(T.value && v.value.length <= 1)), L = F(() => !0), k = F(() => !0), D = F(() => !0), B = F(() => !0), { renderFirstPage: b, renderPreviousPage: E } = ge(s, i, N, u, t), { renderLastPage: x, renderNextPage: g } = fe(s, m, d, u, t), { renderPageInfo: P } = ve(c, y), { renderPageList: w } = de(s, u, a, y, t), { renderPageNumbers: M } = me(e, s, v, u, t), { renderGotoButton: j } = pe(s, d, u, t); h(s.value, u.value, y.value, 7), H([s, u], () => { h(s.value, u.value, y.value, 7); }), H(s, () => { t.emit("pageIndexChanged", s.value); }), H(u, () => { t.emit("pageSizeChanged", u.value); }); const R = F(() => ({ "ngx-pagination": !0, pagination: !0, responsive: n.value, "pager-viewmode-default": o.value === "default", "pager-viewmode-simple": o.value === "simple" })), q = F(() => ({ position: "relative", "justify-content": c.value === "center" ? "center" : "start" })); function $() { return f(_, null, [L.value && P(), k.value && w(), B.value && b(), B.value && E(), D.value && M(), B.value && g(), B.value && x(), S.value && j()]); } function A() { return f(_, null, [f("li", { class: "page-item d-flex flex-fill" }, null), B.value && b(), B.value && E(), j(), f("li", { class: "page-item page-separator", style: "margin-left: 10px" }, [f("span", { style: "font-size: 15px; font-weight: 200;" }, [V(" /")])]), f("li", { class: "page-item page-total", style: "margin-left: 5px" }, [f("span", { style: "font-size: 16px; font-weight: 600;" }, [V(" "), d.value])]), B.value && g(), B.value && x()]); } return () => f("div", { ref: l, class: "pagination-container" }, [z.value && f("ul", { role: "navigation", class: R.value, style: q.value }, [o.value === "default" ? $() : A()])]); } }); U.register = (e, t, n) => { e.pagination = U, t.pagination = ce; }; U.registerDesigner = (e, t, n) => { e.pagination = gt, t.pagination = ce; }; const Nt = Me(U); export { U as FPagination, Nt as default, Q as paginationProps, ce as propsResolver };