UNPKG

vexip-ui

Version:

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

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