UNPKG

@extclp/vexip-ui

Version:

A Vue 3 UI library, Highly customizability, full TypeScript, performance pretty good

952 lines (951 loc) 29.5 kB
import { useCascadedChecked as Qt } from "../tree/hooks.mjs"; import { reactive as q, computed as C, watchEffect as ue } from "vue"; import { debounceMinor as B, createBITree as Zt, isNull as R, getLast as j, toFalse as G, toNumber as V, walkTree as en, deepClone as tn, sortByProps as nn, toFixed as on, boundRange as $, mapTree as sn } from "@vexip-ui/utils"; import { DEFAULT_KEY_FIELD as ln, columnTypes as he, TABLE_HEAD_PREFIX as J, TABLE_FOOT_PREFIX as an } from "./symbol.mjs"; const pe = Object.freeze({ sum: NaN, min: NaN, max: NaN }); let rn = 1; function O() { return `__vxp-table-key-${rn++}`; } function cn(v) { return v + 1; } function pn(v) { const t = q({ ...v, columns: [], normalColumns: [], allColumns: [], summaries: [], data: [], dataKey: v.dataKey ?? ln, rowData: [], treeRowData: [], width: 0, rightFixedColumns: [], leftFixedColumns: [], aboveSummaries: [], belowSummaries: [], rowMinHeight: v.rowMinHeight || 36, rowDraggable: !!v.rowDraggable, columnMap: /* @__PURE__ */ new Map(), rowMap: /* @__PURE__ */ new Map(), summaryMap: /* @__PURE__ */ new Map(), idMaps: /* @__PURE__ */ new WeakMap(), checkedAll: !1, partial: !1, widths: /* @__PURE__ */ new Map(), sorters: /* @__PURE__ */ new Map(), filters: /* @__PURE__ */ new Map(), resized: /* @__PURE__ */ new Set(), bodyYScroll: 0, bodyXScroll: 0, padTop: 0, startRow: 0, endRow: 0, dragging: !1, heightBITree: null, virtualData: [], totalHeight: v.rowMinHeight * v.data.length, colResizing: !1, resizeLeft: 0, cellSpanMap: /* @__PURE__ */ new Map(), collapseMap: /* @__PURE__ */ new Map(), sidePadding: v.sidePadding || [0, 0], locked: !1, barScrolling: !1, heightTrigger: 0 }); oe(v.columns), se(v.summaries), le(v.data); const Q = C(() => typeof t.dataFilter == "function" ? t.rowData.filter((e) => t.dataFilter(e.data)) : t.rowData), X = C(() => t.customFilter ? Q.value : Ot(t.filters, Q.value, t.singleFilter)), Z = C(() => t.customSorter ? X.value : Xt(t.sorters, X.value, t.columns, t.singleSorter)), E = C(() => { const e = Ut(t.currentPage, t.pageSize, Z.value); for (let n = 0, o = e.length; n < o; ++n) e[n].listIndex = n, e[n].last = n === o - 1; return e; }), ge = C(() => new Set(E.value.map((e) => e.key))), ee = C(() => { const e = E.value, n = t.columns.find( (s) => s.type === "selection" ), o = /* @__PURE__ */ new Set(); if (n && typeof n.disableRow == "function") { const s = n.disableRow; for (let a = 0, i = e.length; a < i; ++a) { const c = e[a]; s(c.data) && o.add(c.key); } } return o; }), me = C(() => { const e = E.value, n = t.columns.find( (s) => s.type === "expand" ), o = /* @__PURE__ */ new Set(); if (n && typeof n.disableRow == "function") { const s = n.disableRow; for (let a = 0, i = e.length; a < i; ++a) { const c = e[a]; s(c.data) && o.add(c.key); } } return o; }), we = C(() => { const e = E.value, n = t.columns.find((s) => s.type === "drag"), o = /* @__PURE__ */ new Set(); if (n && typeof n.disableRow == "function") { const s = n.disableRow; for (let a = 0, i = e.length; a < i; ++a) { const c = e[a]; s(c.data) && o.add(c.key); } } return o; }), te = C(() => !t.disabledTree && t.rowData.some((e) => { var n; return (n = e.children) == null ? void 0 : n.length; })), ye = C(() => !!t.columns.find((e) => "type" in e && e.type === "drag")), be = C(() => !!E.value.find((e) => e.dragging)), xe = C(() => N()), Ce = C(() => N(t.normalColumns)), Se = C(() => N(t.leftFixedColumns)), ke = C(() => N(t.rightFixedColumns)), Me = C(() => t.columns.find((e) => e.type === "expand")), Re = C(() => { const { columns: e, summaries: n, data: o } = t, s = /* @__PURE__ */ new Map(); if (!n.length) return s; for (const a of e) { const i = a.key; if (a.type || a.noSummary) { s.set(i, pe); continue; } const c = typeof a.accessor == "function" ? a.accessor : (u) => u[i]; let f = 0, r = 1 / 0, h = -1 / 0, d = !1; for (let u = 0, l = o.length; u < l; ++u) { const m = c(o[u], u), w = parseFloat(m); Number.isNaN(w) || (f += w, r = Math.min(r, w), h = Math.max(h, w), d = !0); } d ? s.set(i, { sum: f, min: r, max: h }) : s.set(i, pe); } return s; }), De = C(() => ne(t.aboveSummaries)), ve = C(() => ne()), Fe = C(() => t.columns.find((e) => !e.type && e.indented)), Te = C(() => !!(t.leftFixedColumns.length || t.rightFixedColumns.length)), T = q({ filteredData: X, sortedData: Z, processedData: E, visibleKeys: ge, disableCheckRows: ee, disableExpandRows: me, disableDragRows: we, usingTree: te, hasDragColumn: ye, rowDragging: be, totalWidths: xe, normalWidths: Ce, leftFixedWidths: Se, rightFixedWidths: ke, expandColumn: Me, summaryData: Re, topFixedHeights: De, bottomFixedHeights: ve, indentedColumn: Fe, hasFixedColumn: Te }), Ae = { // 这几个个方法被 deep watch 回调 // 需要防止在一个微任务内被多次调用 setColumns: B(oe), // setColumns, setSummaries: B(se), setData: B(le), // 这个方法被大量的 watch 回调,需要防抖 updateTotalHeight: B(fe), isGroupColumn: U, buildSummaryKey: z, setColumnProp: Ie, setSummaryProp: Ke, setDataKey: We, setCurrentPage: $e, setPageSize: Ne, setRowClass: Pe, setRowStyle: _e, setRowAttrs: Le, setCellClass: Be, setCellStyle: je, setCellAttrs: Oe, setHeadClass: Xe, setHeadStyle: Ue, setHeadAttrs: Ye, setFootClass: qe, setFootStyle: Ge, setFootAttrs: Ve, setTableWidth: Je, setRowHeight: Qe, setRowMinHeight: Ze, setCellHeight: et, setVirtual: it, setRowDraggable: tt, setBodyYScroll: nt, setBodyXScroll: ot, setBorder: st, setStripe: lt, setHighlight: at, setRowProp: rt, setLocale: ct, setTooltipTheme: dt, setTooltipWidth: ft, setSingleSorter: ut, setSingleFilter: ht, setDragging: pt, setKeyConfig: gt, setDisabledTree: mt, setNoCascaded: wt, setColResizable: yt, setCustomSorter: bt, setCustomFilter: xt, setColumnResizing: Ct, setResizeLeft: St, setExpandRenderer: kt, setCellSpan: Mt, setSidePadding: Rt, setBorderWidth: Dt, setDataFilter: vt, setEllipsis: Ft, setLocked: Tt, setBarScrolling: At, handleSort: Et, clearSort: ie, handleFilter: Ht, clearFilter: re, toggleFilterItemActive: Lt, refreshRowIndex: Y, handleCheck: zt, handleCheckAll: $t, clearCheckAll: ce, setRenderRows: de, handleExpand: Nt, handleDrag: Pt, collectUnderRows: P, setTreeExpanded: _t, getParentRow: Yt, handleColumnResize: qt, getCurrentData: Vt, createMinRowState: W, flatTreeRows: ae, refreshRowDepth: ze, triggerHeightChange: Ee, queryRow: Jt }; ue(() => { t.heightBITree = Zt( E.value.length, t.rowHeight || t.rowMinHeight ), t.totalHeight = -1, fe(); }), ue(Gt); function Ee() { ++t.heightTrigger, t.heightTrigger >= Number.MAX_SAFE_INTEGER && (t.heightTrigger = 0); } function N(e = t.columns) { const n = t.widths, o = [0]; let s = 0; for (let a = 0, i = e.length; a < i; ++a) { const f = e[a].key, r = n.get(f) || 0; s += r, o.push(s); } return o; } function ne(e = t.belowSummaries) { const n = t.rowMap, o = [0]; let s = 0; for (let a = 0, i = e.length; a < i; ++a) { const c = e[a], f = z(c.key), r = n.get(f); r && (s += r.height || 0), o.push(s); } return o; } function W(e) { return { key: e, cellHeights: {}, height: t.rowHeight ?? t.rowMinHeight }; } function U(e) { var n; return !!((n = e.children) != null && n.length); } function He(e) { const n = [], o = [], s = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Set(), i = (r) => r === !0 || r === "left" ? -1 : r === "right" ? 1 : 0, c = (r, h, d = 0, u = []) => { r = r.filter((p) => !("children" in p) || U(p)).sort((p, g) => (p.order || 0) - (g.order || 0)).sort((p, g) => i(p.fixed) - i(g.fixed)), h = h === !0 ? "left" : h; const l = r, m = u[d] ?? (u[d] = []); let w = d > 0 ? u[d - 1].length - 1 : 0; for (const { ...p } of l) { if (R(h) || (p.fixed = h), m[w] = p, U(p)) { const g = c(p.children, p.fixed, d + 1, u); p.key = Symbol("TableColumnGroup"), p.headSpan = g - w, w = g; } else { const g = p.type && he.includes(p.type); g && (a.has(p.type) && console.warn(`[vexip-ui:Table] Table has duplicate column with type '${p.type}'`), a.add(p.type)); let k = p.key; R(k) && (g ? k = `__vxp_${p.type}` : (console.warn("[vexip-ui:Table] Table column requires key prop, but missing"), k = O())), p.key = k, o.push(p), w += 1; } s.set(p.key, p); } return w; }; c(e, void 0, 0, n); let f = 0; for (const r of n) f = Math.max(r.length, f); for (const r of n) r.length && (j(r).last = !0), r.length = f; for (let r = 0, h = n.length; r < f; ++r) { let d = 1; for (let u = h - 1; u >= 0; --u) { const l = n[u][r]; l ? (l.colIndex = r, l.rowSpan = d, d = 1) : ++d; } } return { allColumns: n, baseColumns: o, columnMap: s }; } function oe(e) { const { widths: n, sorters: o, filters: s } = t, { allColumns: a, baseColumns: i, columnMap: c } = He(e), f = [], r = [], h = []; for (let d = 0, u = i.length; d < u; ++d) { const l = i[d]; if (l.first = !1, l.last = !1, l.index = d, l.type && he.includes(l.type)) { switch (l.type) { case "order": { l.truthIndex = !!l.truthIndex, typeof l.orderLabel != "function" && (l.orderLabel = cn), R(l.width) && (l.width = 60); break; } case "selection": { l.selectionSize = l.selectionSize || "default", typeof l.disableRow != "function" && (l.disableRow = G), R(l.width) && (l.width = 40); break; } case "expand": { typeof l.disableRow != "function" && (l.disableRow = G), R(l.width) && (l.width = 40); break; } case "drag": { typeof l.disableRow != "function" && (l.disableRow = G), R(l.width) && (l.width = 40); break; } } l.key || (l.key = `__vxp_${l.type}-${d}`); } else l.type = void 0; n.set(l.key, l.width || 100), o.set(l.key, Bt(l.sorter)), s.set(l.key, jt(l.filter)); const m = l.fixed; m === !0 || m === "left" ? h.push(l) : m === "right" ? r.push(l) : f.push(l); } if (t.allColumns.length > a.length) for (let d = a.length - 1, u = t.allColumns.length; d < u; ++d) t.rowMap.delete(`${J}${d}`); for (let d = 0, u = a.length; d < u; ++d) { const l = `${J}${d}`; t.rowMap.set(l, W(l)); } if (t.columnMap = c, t.columns = Array.from(h).concat(f, r), t.normalColumns = f, t.allColumns = a, t.columns.length) { for (const d of t.columns) if (!d.type) { d.first = !0; break; } j(t.columns).last = !0; } h.length && (t.leftFixedColumns = h), r.length && (t.rightFixedColumns = r); } function Ie(e, n, o) { t.columnMap.has(e) && (t.columnMap.get(e)[n] = o); } function z(e) { return typeof e == "symbol" ? e : `${an}${e}`; } function se(e) { e = Array.from(e).sort((i, c) => (i.order || 0) - (c.order || 0)); const n = new Set(t.summaries.map((i) => i.key)), o = [], s = [], a = /* @__PURE__ */ new Map(); for (let i = 0, c = e.length; i < c; ++i) { const f = { ...e[i] }; let r = f.key; if (R(r) && (console.error("[vexip-ui:Table] Table summary requires key prop, but missing"), r = O()), f.key = r, (f.above ? o : s).push(f), !n.has(f.key)) { const h = z(f.key); t.rowMap.set(h, W(h)); } n.delete(f.key), a.set(f.key, f); } if (t.summaries = Array.from(o).concat(s), t.summaryMap = a, o.length && (t.aboveSummaries = o), s.length && (t.belowSummaries = s), n.size) for (const i of n) t.rowMap.delete(z(i)); } function Ke(e, n, o) { t.summaryMap.has(e) && (t.summaryMap.get(e)[n] = o); } function We(e) { const n = t.dataKey; if (!R(e) && n !== e) { const { rowData: o, idMaps: s } = t; t.dataKey = e, o.forEach((a) => { let i = a.data[e]; R(i) && (i = O()), a.key = i, s.set(a.data, i); }); } } function P(e, n = []) { var o; if (e.treeExpanded && ((o = e.children) != null && o.length)) for (const s of e.children) n.push(s), P(s, n); return n; } function le(e) { const n = [], o = /* @__PURE__ */ new Map(), { allColumns: s, dataKey: a, keyConfig: i, idMaps: c, disabledTree: f } = t, r = t.rowMap, h = !!t.virtual, { children: d, checked: u, height: l, expanded: m, treeExpanded: w } = i; for (let g = 0, k = s.length; g < k; ++g) { const x = `${J}${g}`; o.set(x, r.get(x) || W(x)); } for (const g of t.summaries) { const k = z(g.key); o.set(k, r.get(k) || W(k)); } const p = (g, k, x) => { for (let S = 0, M = g.length; S < M; ++S) { const b = g[S]; let D = b[a]; R(D) && (D = c.get(b), R(D) && (D = O())); let y; if (r.has(D)) { y = r.get(D); const { [u]: H, [l]: K, [m]: F, [w]: L } = y.data !== b ? Object.assign(y.data, b) : y.data; y.checked = R(H) ? y.checked : !!H, y.height = R(K) ? y.height : V(K), y.expanded = R(F) ? y.expanded : !!F, y.treeExpanded = R(L) ? y.treeExpanded : !!L; } else { const { [u]: H, [l]: K, [m]: F, [w]: L } = b; y = { key: D, hidden: h, checked: !!H, height: V(K), expanded: !!F, hover: !1, expandHeight: 0, index: -1, children: [], depth: 0, treeExpanded: !!L, partial: !1, dragging: !1, listIndex: 0, cellHeights: q({}), last: !1, expandAnimate: !1, data: b }, c.set(b, D); } x && (y.parent = x.key, y.depth = x.depth + 1), y.children = []; const A = y.data[d]; A != null && A.length && p(A, y.children, y), k.push(y), o.set(D, y); } }; p(e, n), t.rowMap = o, t.treeRowData = n, f ? t.rowData = n : ae(), t.data = e, Y(), _(); } function ae() { if (t.disabledTree) return; const e = []; for (const n of t.treeRowData) e.push(n), P(n, e); t.rowData = e; } function ze() { en(t.treeRowData, (e, n) => { e.depth = n; }); } function $e(e) { t.currentPage = e ?? 1; } function Ne(e) { t.pageSize = e || 0; } function Pe(e) { t.rowClass = e ?? ""; } function _e(e) { t.rowStyle = e ?? ""; } function Le(e) { t.rowAttrs = e ?? null; } function Be(e) { t.cellClass = e ?? ""; } function je(e) { t.cellStyle = e ?? ""; } function Oe(e) { t.cellAttrs = e ?? null; } function Xe(e) { t.headClass = e ?? ""; } function Ue(e) { t.headStyle = e ?? ""; } function Ye(e) { t.headAttrs = e ?? null; } function qe(e) { t.footClass = e ?? ""; } function Ge(e) { t.footStyle = e ?? ""; } function Ve(e) { t.footAttrs = e ?? null; } function Je(e) { if (t.resized.size) return; e = V(e); const { columns: n, widths: o, resized: s, sidePadding: a } = t, i = [], c = []; let f = e - (a[0] || 0) - (a[1] || 0); for (let u = 0, l = n.length; u < l; ++u) { const m = n[u]; m.width || s.has(m.key) ? (f -= m.width ?? o.get(m.key), i.push(m)) : c.push(m); } const r = c.length; let h = 100; r && (h = Math.max(f / r, 100)); let d = 0; for (let u = 0; u < r; ++u) { const l = c[u], m = Math[u % 2 ? "ceil" : "floor"](h); u < r - 1 && (d += m), o.set(l.key, m); } r && f >= r * h && o.set(j(c).key, f - d), t.width = e; } function Qe(e) { t.rowHeight = e; } function Ze(e) { t.rowMinHeight = e; } function et(e, n, o) { !R(o) && t.rowMap.has(e) && (t.rowMap.get(e).cellHeights[n] = o); } function tt(e) { t.rowDraggable = !!e; } function nt(e) { t.bodyYScroll = e; } function ot(e) { t.bodyXScroll = e; } function st(e) { t.border = !!e; } function lt(e) { t.stripe = !!e; } function at(e) { t.highlight = !!e; } function it(e) { t.virtual = !!e; } function rt(e, n, o) { const s = t.rowMap.get(e); s && s[n] !== o && (s[n] = o); } function ct(e) { t.locale = e; } function dt(e) { t.tooltipTheme = e; } function ft(e) { t.tooltipWidth = e; } function ut(e) { t.singleSorter = !!e; } function ht(e) { t.singleFilter = !!e; } function pt(e) { t.dragging = !!e; } function gt(e) { t.keyConfig = e; } function mt(e) { t.disabledTree = !!e; } function wt(e) { t.noCascaded = !!e; } function yt(e) { t.colResizable = e === !0 ? "lazy" : e; } function bt(e) { t.customSorter = !!e; } function xt(e) { t.customFilter = !!e; } function Ct(e) { t.colResizing = !!e; } function St(e) { t.resizeLeft = e; } function kt(e) { t.expandRenderer = e; } function Mt(e) { t.cellSpan = e; } function Rt(e) { t.sidePadding = Array.isArray(e) ? e : [e, e]; } function Dt(e) { t.borderWidth = Math.max(e, 0); } function vt(e) { t.dataFilter = e; } function Ft(e) { t.ellipsis = e; } function Tt(e) { t.locked = e; } function At(e) { t.barScrolling = e; } function Et(e, n) { t.sorters.has(e) && (t.singleSorter && n && ie(), t.sorters.get(e).type = n); } function ie() { const e = t.sorters; for (const n of e.values()) n.type = null; } function Ht(e, n) { t.filters.has(e) && (t.singleFilter && (Array.isArray(n) ? n.length : n) && re(), t.filters.get(e).active = Array.isArray(n) ? Array.from(n) : n); } function re() { const e = t.filters; for (const n of e.values()) { n.active = null; for (const o of n.options) o.active = !1; } } const { updateCheckedUpward: It, updateCheckedDown: Kt } = Qt({ getNode: (e) => t.rowMap.get(e), disableNode: (e) => ee.value.has(e.key) }); function Wt(e) { const { rowMap: n, rowData: o } = t, { disableCheckRows: s } = T; if (!n.has(e)) return; const a = [n.get(e)].concat( // 需要包含被禁用且被勾选的节点 o.filter((i) => s.has(i.key) && i.checked) ); for (let i = 0, c = a.length; i < c; ++i) It(a[i].key), Kt(a[i].key); } function zt(e, n, o = !1) { const { rowMap: s, noCascaded: a } = t, { disableCheckRows: i } = T, c = s.get(e); c && (o && (ce(!0), c.checked = !!n), i.has(e) || (c.checked = !!n, c.partial = !1), !a && Wt(e), _()); } function $t() { const { rowData: e, checkedAll: n } = t, { disableCheckRows: o } = T; let s = !n; if (o.size) { let a = !0; for (const i of e) if (!o.has(i.key) && !i.checked) { a = !1; break; } s = !a; } for (const a of e) o.has(a.key) || (a.checked = s); t.checkedAll = s, t.partial = !1, _(); } function ce(e = !1) { const { rowData: n } = t, { disableCheckRows: o } = T; for (const s of n) (e || !o.has(s.key)) && (s.checked = !1), e && (s.partial = !1); t.checkedAll = !1, t.partial = !1, !e && _(); } function _() { const e = t.rowData; let n = !1, o = !1, s = !1; for (let a = 0, i = e.length; a < i; ++a) if (e[a].checked ? n = !0 : o = !0, n && o) { s = !0; break; } n && !s ? t.checkedAll = !0 : t.checkedAll = !1, t.partial = s; } function de(e, n, o = !1) { const { startRow: s, endRow: a, heightBITree: i, virtualData: c } = t; if (!o && e === s && n === a) return; const { processedData: f } = T; if (!f.length) { c.length = 0; return; } const r = /* @__PURE__ */ new Set([...c]), h = [], d = []; for (let l = 0, m = f.length; l < m; ++l) { const w = f[l]; w.hidden = !(l >= e && l < n), w.hidden ? (w.hover = !1, r.has(w) && d.push(w)) : r.has(w) || h.push(w), r.delete(w); } d.push(...r); const u = Math.min(h.length, d.length); for (let l = 0; l < u; ++l) c[c.indexOf(d[l])] = h[l]; h.length > d.length ? c.push(...h.slice(u)) : h.length < d.length && (t.virtualData = c.filter((l) => !d.includes(l))), t.padTop = (i == null ? void 0 : i.sum(e)) ?? 0, t.startRow = e, t.endRow = n; } function Nt(e, n) { const { rowMap: o } = t, { disableExpandRows: s } = T; o.has(e) && !s.has(e) && (o.get(e).expanded = !!n); } function Pt(e, n) { const { rowMap: o } = t, { disableDragRows: s } = T; o.has(e) && !s.has(e) && (o.get(e).dragging = !!n); } function _t(e, n) { var f; if (!te.value) return; const { rowMap: o, rowData: s, virtual: a } = t, i = o.get(e); if (!((f = i == null ? void 0 : i.children) != null && f.length)) return; const c = P({ ...i, treeExpanded: !0 }); n ? s.splice(i.index + 1, 0, ...c) : s.splice(i.index + 1, c.length), i.treeExpanded = !!n, Y(), a && de(t.startRow, t.endRow, !0); } function Lt(e) { const { key: n, value: o, active: s = !1, disableOthers: a = !1 } = e; if (t.filters.has(n)) { const i = t.filters.get(n).options; if (a) for (let f = 0, r = i.length; f < r; ++f) i[f].active = !1; const c = i.find((f) => f.value === o); c && (c.active = s); } } function Y() { const e = t.rowData; for (let n = 0, o = e.length; n < o; ++n) e[n].index = n; } function fe() { const { heightBITree: e } = t; e ? t.totalHeight = e.sum() ?? 0 : t.totalHeight = 0; } function Bt(e = !1) { const n = typeof e == "boolean" ? { able: e } : e, { able: o = !0, type: s = null, order: a = 0, method: i = null } = n; return { able: o, type: s, order: a, method: i }; } function jt(e) { e = e || { able: !1, options: [] }; const { able: n = !0, custom: o = !1, multiple: s = !1, active: a = null, method: i = null, meta: c } = e, f = tn(e.options ?? []), r = []; for (let h = 0, d = f.length; h < d; ++h) { const u = f[h], l = typeof u == "string" ? { value: u } : { ...u }; l.label = l.label ?? l.value.toString(); let m = !1; s && Array.isArray(a) ? m = a.includes(l.value) : R(a) || (m = Object.is(l.value, a)), l.active = m, r.push(l); } return { able: n, custom: o, meta: c, options: r, multiple: s, active: a, method: i }; } function Ot(e, n, o) { const s = [], a = []; for (const c of e.values()) { const { able: f, active: r, method: h } = c; if (f && r && typeof h == "function" && (s.push(c), o)) break; } const i = s.length; for (let c = 0, f = n.length; c < f; ++c) { const r = n[c]; let h = !0; for (let d = 0; d < i; d++) { const { active: u, method: l } = s[d]; if (h = l(u, r.data), !h) break; } h && a.push(r); } return a; } function Xt(e, n, o, s) { const a = []; for (const [i, c] of e) { const f = i, { able: r, type: h, order: d, method: u } = c; if (r && h) { const l = o.find((w) => w.key === f), m = l == null ? void 0 : l.accessor; if (a.push({ able: r, key: f, order: d, type: h, method: u ?? void 0, accessor(w) { return typeof m == "function" ? m(w.data, w.index) : w.data[f]; } }), s) break; } } return a.sort((i, c) => i.order - c.order), nn(n, a); } function Ut(e, n, o) { return n > 0 ? o.slice((e - 1) * n, e * n) : o; } function Yt(e) { const { rowMap: n } = t, o = n.get(e); return R(o == null ? void 0 : o.parent) ? null : n.get(o.parent) ?? null; } let I; function qt(e, n) { const { resized: o, widths: s, columns: a, width: i } = t, c = e.length; if (!a.length || !c) return; const f = n / c, r = j(a).key; for (let d = 0; d < c; ++d) { const u = e[d]; o.add(u), s.set( u, c === 1 ? Math.round(f) : Math[d % 2 ? "ceil" : "floor"](f) ); } let h = 0; for (const d of s.values()) h += d; h = on(h, 1), h - s.get(r) < i - (I ?? s.get(r)) ? (I || (I = s.get(r)), s.set(r, s.get(r) + i - h)) : I && (s.set(r, I), I = void 0); } function Gt() { const { normalColumns: e, leftFixedColumns: n, rightFixedColumns: o, aboveSummaries: s, belowSummaries: a, rowData: i, cellSpanMap: c, collapseMap: f } = t, { processedData: r } = T; for (const d of ["left", "default", "right"]) c.set(d, /* @__PURE__ */ new Map()), f.set(d, /* @__PURE__ */ new Map()); function h(d, u, l, m, w = "") { const p = `${w}${d},${u}`, g = f.get(l); if (g.has(p)) { c.get(l).set(p, { colSpan: 0, rowSpan: 0 }); return; } const k = m(), { colSpan: x, rowSpan: S } = k; for (let M = 0; M < x; ++M) for (let b = 0; b < S; ++b) { if (!M && !b) continue; const D = `${w}${d + b},${u + M}`; let y = g.get(D); y || (y = /* @__PURE__ */ new Set(), g.set(D, y)), y.add(p); } c.get(l).set(p, k); } for (const d of [e, n, o]) { if (!d.length) continue; const u = d[0].fixed === !0 ? "left" : d[0].fixed || "default", l = d[0].fixed === !0 ? "left" : d[0].fixed || void 0, m = t.leftFixedColumns.length, w = t.allColumns[0].length - t.rightFixedColumns.length; let p; u === "left" ? p = t.allColumns.map((g) => g.slice(0, m)) : u === "right" ? p = t.allColumns.map( (g) => g.slice(w, t.allColumns[0].length) ) : p = t.allColumns.map((g) => g.slice(m, w)); for (let g = 0, k = p.length; g < k; ++g) { const x = p[g]; for (let S = 0, M = x.length; S < M; ++S) { const b = x[S]; if (!b) continue; const D = b.fixed === !0 ? "left" : b.fixed || "default"; h( g, S, D, () => { const y = D === "left" ? n : D === "right" ? o : e; return { colSpan: $(b.headSpan ?? 1, 0, y.length - S), rowSpan: b.rowSpan }; }, "h" ); } } for (let g = 0, k = d.length; g < k; ++g) { const x = d[g]; for (const S of i) h(S.index, x.index, u, () => { let M; typeof x.cellSpan == "function" ? M = x.cellSpan({ row: S.data, index: S.index, fixed: l }) : typeof t.cellSpan == "function" && (M = t.cellSpan({ row: S.data, rowIndex: S.index, column: x, columnIndex: x.index, fixed: l })), M = M || { colSpan: 1, rowSpan: 1 }; const b = { colSpan: M.colSpan ?? 1, rowSpan: M.rowSpan ?? 1 }; return b.colSpan = $(b.colSpan, 0, d.length - g), b.rowSpan = $(b.rowSpan, 0, r.length - S.listIndex), b; }); for (const { prefix: S, summaries: M } of [ { prefix: "af", summaries: s }, { prefix: "bf", summaries: a } ]) for (let b = 0, D = M.length; b < D; ++b) { const y = M[b]; h( b, x.index, u, () => { let A; typeof y.cellSpan == "function" && (A = y.cellSpan({ column: x, index: x.index, fixed: l })); const { colSpan: H, rowSpan: K } = A || { colSpan: 1, rowSpan: 1 }, F = { colSpan: H ?? 1, rowSpan: K ?? 1 }; return F.colSpan = $(F.colSpan, 0, d.length - g), F.rowSpan = $(F.rowSpan, 0, M.length - b), F; }, S ); } } } } function Vt() { const { treeRowData: e, disabledTree: n, keyConfig: o } = t; return n ? e.map((s) => ({ ...s.data })) : sn(e, (s) => ({ ...s.data }), { childField: o.children }); } function Jt(e) { const { dataKey: n, rowMap: o, idMaps: s } = t; let a; return typeof e == "object" ? a = s.get(e) ?? e[n] : a = e, R(a) ? void 0 : o.get(a); } return { state: t, getters: T, mutations: Ae }; } export { pn as useStore }; //# sourceMappingURL=store.mjs.map