UNPKG

vexip-ui

Version:

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

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