UNPKG

hightable

Version:

A dynamic windowed scrolling table component for react

1,550 lines (1,549 loc) 50.7 kB
import { jsx as m, jsxs as j, Fragment as We } from "react/jsx-runtime"; import { createContext as ee, useContext as Y, useEffect as G, useCallback as w, useState as A, useMemo as W, useRef as X, forwardRef as Ze, useImperativeHandle as et, useId as Ae } from "react"; import { arrayDataFrame as tt, serializeOrderBy as Me, checkSignal as nt, toggleColumnExclusive as rt, toggleColumn as ot, stringify as Ie } from "./dataframe.js"; import { createEventTarget as un, createGetRowNumber as dn, sortableDataFrame as fn, validateColumn as hn, validateFetchParams as gn, validateGetCellParams as pn, validateGetRowNumberParams as vn, validateOrderBy as bn, validateRow as wn } from "./dataframe.js"; import { createPortal as it, flushSync as st } from "react-dom"; function at(t) { if (t === void 0) return {}; const e = `${t}px`; return { minWidth: e, maxWidth: e }; } function Ke(t) { return t.offsetWidth; } function ct(t) { return t.clientWidth; } const re = { cellPosition: { colIndex: 1, // the cursor cell is initially the top-left cell rowIndex: 1 // }, shouldFocus: !1, shouldScroll: !1 }, ge = ee(re); function lt({ colCount: t, rowCount: e, rowPadding: n, children: c }) { const [s, o] = A(e), [r, u] = A(re.cellPosition.colIndex), [i, a] = A(re.cellPosition.rowIndex), [d, h] = A(!1), [f, p] = A(!1); e !== s && (o(e), i > e && a(e)); const b = w((g) => { const { key: x, altKey: F, ctrlKey: E, metaKey: N, shiftKey: D } = g; if (!(F || N || D)) { if (x === "ArrowRight") u(E ? t : (C) => C < t ? C + 1 : C); else if (x === "ArrowLeft") u(E ? 1 : (C) => C > 1 ? C - 1 : C); else if (x === "ArrowDown") a(E ? e : (C) => C < e ? C + 1 : C); else if (x === "ArrowUp") a(E ? 1 : (C) => C > 1 ? C - 1 : C); else if (x === "Home") E && a(1), u(1); else if (x === "End") E && a(e), u(t); else if (x === "PageDown") a((C) => C + n <= e ? C + n : e); else if (x === "PageUp") a((C) => C - n >= 1 ? C - n : 1); else if (x !== " ") return; g.stopPropagation(), g.preventDefault(), p(!0), h(!0); } }, [t, e, n]), y = w((g) => { const { key: x } = g; (x === "Tab" && !g.shiftKey || x === "Enter" || x === " ") && (g.stopPropagation(), g.preventDefault(), p(!0), h(!0)); }, []), l = w(() => { u(re.cellPosition.colIndex), a(re.cellPosition.rowIndex), p(!0), h(!0); }, []), k = W(() => ({ colIndex: r, rowIndex: i }), [r, i]), S = W(() => ({ cellPosition: k, onTableKeyDown: b, onScrollKeyDown: y, setColIndex: u, setRowIndex: a, shouldFocus: d, setShouldFocus: h, shouldScroll: f, setShouldScroll: p, focusFirstCell: l }), [k, b, y, d, f, l]); return /* @__PURE__ */ m(ge.Provider, { value: S, children: c }); } function ce({ ref: t, ariaColIndex: e, ariaRowIndex: n }) { const { cellPosition: { colIndex: c, rowIndex: s }, setColIndex: o, setRowIndex: r, shouldFocus: u, setShouldFocus: i } = Y(ge), a = e === c && n === s, d = n === 1 || e === 1; G(() => { t.current && a && u && (d || t.current.scrollIntoView({ behavior: "auto", block: "nearest", inline: "nearest" }), t.current.focus(), i?.(!1)); }, [t, a, d, u, i]); const h = a ? 0 : -1, f = w(() => { o?.(e), r?.(n), i?.(!0); }, [o, r, i, e, n]); return { tabIndex: h, navigateToCell: f }; } function pe() { return Y(ge); } const Te = ee([]); function ut({ columnConfiguration: t, columnDescriptors: e, children: n }) { const c = W(() => { const s = new Set(e.map((r) => r.name)), o = e.map(({ name: r, sortable: u }, i) => ({ name: r, index: i, sortable: u ?? !1, // Default to false if not specified ...t?.[r] ?? {} })); if (t) for (const r of Object.keys(t)) s.has(r) || console.warn( `[HighTable] columnConfiguration has unknown key “${r}”. It will be ignored.` ); return o; }, [e, t]); return /* @__PURE__ */ m(Te.Provider, { value: c, children: n }); } function Oe() { return Y(Te); } function dt() { const t = Oe(); return W(() => t.map((n) => n.minWidth), [t]); } function ft({ key: t, parse: e }) { const n = localStorage.getItem(t); return n ? (e ?? JSON.parse)(n) : void 0; } function ht({ key: t, value: e, stringify: n }) { t !== void 0 && (e === void 0 ? localStorage.removeItem(t) : localStorage.setItem(t, (n ?? JSON.stringify)(e))); } function Fe({ key: t, parse: e, stringify: n } = {}) { const [c, s] = A(void 0), [o, r] = A(void 0); return t !== o && (t !== void 0 && s(ft({ key: t, parse: e })), r(t)), G(() => { ht({ key: t, value: c, stringify: n }); }, [c, t, n]), [c, s]; } const gt = 50, pt = 3, vt = 150, bt = 3, $e = ee({}); function wt({ children: t, localStorageKey: e, numColumns: n, minWidth: c }) { if (!Number.isInteger(n) || n < 0) throw new Error(`Invalid numColumns: ${n}. It must be a positive integer.`); const s = w((v) => v !== void 0 && Number.isInteger(v) && v >= 0 && v < n, [n]); if (c ??= gt, !te(c)) throw new Error(`Invalid minWidth: ${c}. It must be a positive number.`); const o = dt(), r = w((v) => (s(v) ? o[v] : void 0) ?? c, [s, o, c]), u = w((v) => { if (!v) return v; function M(_, R) { return _ !== void 0 && (!te(_) || _ < r(R)); } return v.some((_, R) => M(_, R)) ? v.map((_, R) => { if (!M(_, R)) return _; }) : v; }, [r]), [i, a] = A(void 0), d = w((v) => { te(v) && a(v); }, []), [h, f] = Fe({ key: e, parse: p, stringify: JSON.stringify }); function p(v) { const M = JSON.parse(v); return Array.isArray(M) ? M.map((T) => typeof T == "number" ? T : void 0) : []; } const b = X(h), y = w((v) => { f((M) => { const T = v(M); return b.current = T ?? [], T; }); }, [f]), l = w((v, M) => { if (!te(M) || !s(v)) return; const T = Math.max(M, r(v)); y((_) => { const R = [..._ ?? []]; return R[v] = T, R; }); }, [s, r, y]), k = w(() => { y((v) => u(v)); }, [y, u]), S = w((v) => { if (s(v) && h?.[v] !== void 0) return !0; }, [h, s]), [g, x] = A(), F = w((v, M) => { if (!te(M) || !s(v)) return; const T = Math.max(M + 1, r(v)); x((_) => { const R = [..._ ?? []]; return R[v] = T, R; }); }, [s, r, x]), E = w(() => { x((v) => u(v)); }, [x, u]), N = w((v) => { s(v) && (y((M) => { const T = [...M ?? []]; return T[v] = void 0, T; }), x((M) => { const T = [...M ?? []]; return T[v] = void 0, T; })); }, [s, y, x]), [D, C] = A(); G(() => { k(), E(), C(yt({ fixedWidths: b.current, measuredWidths: g, maxTotalWidth: i, numColumns: n, getMinWidth: r })); }, [n, g, i, r, k, E]); const P = w((v) => { if (s(v)) return h?.[v] ?? D?.[v] ?? g?.[v]; }, [s, h, g, D]), H = w((v) => at(P(v)), [P]), I = W(() => ({ getWidth: P, getStyle: H, getDataFixedWidth: S, releaseWidth: N, setAvailableWidth: d, setFixedWidth: l, setMeasuredWidth: F }), [P, H, S, N, d, l, F]); return /* @__PURE__ */ m($e.Provider, { value: I, children: t }); } function ve() { return Y($e); } function yt({ fixedWidths: t, measuredWidths: e, maxTotalWidth: n, getMinWidth: c, numColumns: s }) { if (n === void 0) return []; if (!e || e.every((h) => h === void 0)) return []; const o = new Array(s).fill(void 0); let r = 0; for (const h of o.keys()) { const f = t?.[h] ?? e[h] ?? c(h); r += f; } let u = r - Math.max(0, n - bt); if (u <= 0) return []; const i = /* @__PURE__ */ new Map(); for (const [h, f] of e.entries()) if (f !== void 0) { const p = Math.max( c(h), Math.floor(f / pt), vt ); if (f < p) continue; const b = i.get(f); b ? b.push({ index: h, minWidth: p }) : i.set(f, [{ index: h, minWidth: p }]); } const a = [...i.entries()].map( ([h, f]) => ({ width: h, columns: f }) ).sort((h, f) => h.width - f.width); let d = 0; for (; a.length > 0 && d < 100 && u > 0; ) { d++; const h = a.pop(); if (h === void 0) break; const { width: f, columns: p } = h; if (p.length === 0) throw new Error(`Incoherent width group with no columns: ${f}`); const b = a.pop(), y = Math.max(...p.map((g) => g.minWidth)), l = b === void 0 ? y : Math.max(y, b.width), k = Math.ceil(f - u / p.length); if (k >= l) { for (const g of p) o[g.index] = k; u -= (f - k) * p.length; break; } for (const g of p) o[g.index] = l; u -= (f - l) * p.length; const S = p.filter((g) => g.minWidth < l); b?.width === l ? a.push({ width: l, columns: [...b.columns, ...S] }) : (b !== void 0 && a.push(b), S.length > 0 && a.push({ width: l, columns: S })); } if (u < 0 && u > -10) { const h = o.map((p, b) => { const y = t?.[b], l = e[b]; return { index: b, fixed: y !== void 0, width: p ?? l }; }).filter( // tell typescript that width is defined (p) => !p.fixed && p.width !== void 0 ), f = h.length; if (f > 0) { const p = Math.floor(-u / f), b = -u % f; for (const { index: y, width: l } of h.slice(0, b)) o[y] = l + p + 1; for (const { index: y, width: l } of h.slice(b)) o[y] = l + p; } } return o; } function te(t) { return typeof t == "number" && Number.isFinite(t) && !isNaN(t) && t >= 0; } const Ne = ee({}); function mt({ children: t, localStorageKey: e, columnNames: n, initialVisibilityStates: c, onColumnsVisibilityChange: s }) { const o = n.length, [r, u] = Fe({ key: e, parse: a, stringify: i }); function i(S) { return JSON.stringify(S); } function a(S) { const g = JSON.parse(S); if (typeof g != "object" || g === null) return {}; const x = {}; for (const [F, E] of Object.entries(g)) E != null && typeof E == "object" && "hidden" in E && E.hidden === !0 && (x[F] = { hidden: !0 }); return x; } const d = W( () => r ?? c ?? {}, [r, c] ), h = w((S) => d[S]?.hidden === !0, [d]), { numberOfHiddenColumns: f, numberOfVisibleColumns: p } = W(() => { let S = 0; for (const g of n) h(g) && S++; return { numberOfHiddenColumns: S, numberOfVisibleColumns: o - S }; }, [n, h, o]), b = w((S) => !h(S) && p > 1, [h, p]), y = w((S) => { if (!(!n.includes(S) || !b(S))) return () => { u((g) => { const x = { ...g ?? c ?? {} }; return x[S] = { hidden: !0 }, s?.(x), x; }); }; }, [b, n, u, s, c]), l = W(() => { if (f !== 0) return () => { const S = {}; u(S), s?.(S); }; }, [f, u, s]), k = W(() => ({ getHideColumn: y, showAllColumns: l, isHiddenColumn: h }), [y, l, h]); return /* @__PURE__ */ m(Ne.Provider, { value: k, children: t }); } function He() { return Y(Ne); } function Ct() { return { data: tt([]), key: 0, version: 0, maxRowNumber: 0, numRows: 0 }; } const Le = ee(Ct()); function xt({ children: t, data: e, maxRowNumber: n }) { const [c, s] = A(0), [o, r] = A(e), [u, i] = A(0), [a, d] = A(e.numRows); G(() => { function f() { i((b) => b + 1); } function p() { d(e.numRows); } return e.eventTarget?.addEventListener("numrowschange", p), e.eventTarget?.addEventListener("resolve", f), e.eventTarget?.addEventListener("update", f), () => { e.eventTarget?.removeEventListener("numrowschange", p), e.eventTarget?.removeEventListener("resolve", f), e.eventTarget?.removeEventListener("update", f); }; }, [e]), e !== o && (s((f) => f + 1), r(e), i(0), d(e.numRows)); const h = W(() => n ?? a, [n, a]); return /* @__PURE__ */ m(Le.Provider, { value: { data: e, key: c, version: u, maxRowNumber: h, numRows: a }, children: t }); } function St() { return Y(Le); } function Ve({ value: t, onChange: e, defaultValue: n, disabled: c }) { const [s] = A(t), [o] = A(t !== void 0), [r] = A(c ?? !1), [u, i] = A(n), a = w((d) => { e?.(d), i(d); }, [e]); return r ? {} : o ? (t === void 0 && console.warn("The value is controlled (it has no local state) because the property was initially defined. It cannot be set to undefined now (it is set back to the initial value)."), { value: t ?? s, // read-only if onChange is undefined onChange: e }) : (t !== void 0 && console.warn("The value is uncontrolled (it only has a local state) because the property was initially undefined. It cannot be set to a value now and is ignored."), { value: u, onChange: a }); } const _e = ee({}); function kt({ children: t, orderBy: e, onOrderByChange: n }) { const c = Ve({ value: e, onChange: n, defaultValue: [] }); return /* @__PURE__ */ m(_e.Provider, { value: { orderBy: c.value, onOrderByChange: c.onChange }, children: t }); } function be() { return Y(_e); } const Be = ee({ containerRef: { current: null } }); function Dt({ children: t }) { const e = X(null); return /* @__PURE__ */ m(Be.Provider, { value: { containerRef: e }, children: t }); } function Ue() { return Y(Be); } function Se() { return { ranges: [], anchor: void 0 }; } function ae(t) { return Number.isInteger(t) && t >= 0; } function we(t) { return ae(t.start) && ae(t.end) && t.end > t.start; } function ye(t) { if (t.length === 0) return !0; if (t.some((e) => !we(e))) return !1; for (let e = 0; e < t.length - 1; e++) { const n = t[e], c = t[e + 1]; if (!n || !c || n.end >= c.start) return !1; } return !0; } function le({ ranges: t, index: e }) { if (!ae(e)) throw new Error("Invalid index"); if (!ye(t)) throw new Error("Invalid ranges"); return t.some((n) => n.start <= e && e < n.end); } function je({ ranges: t, range: e }) { if (!ye(t)) throw new Error("Invalid ranges"); if (!we(e)) throw new Error("Invalid range"); const n = [], { start: c, end: s } = e; let o = 0; for (; o < t.length; ) { const r = t[o]; if (!r) throw new Error("Invalid range"); if (r.end >= c) break; n.push({ ...r }), o++; } for (; o < t.length; ) { const r = t[o]; if (!r) throw new Error("Invalid range"); if (r.start > s) break; e.start = Math.min(e.start, r.start), e.end = Math.max(e.end, r.end), o++; } for (n.push(e); o < t.length; ) { const r = t[o]; if (!r) throw new Error("Invalid range"); n.push({ ...r }), o++; } return n; } function Ge({ ranges: t, index: e }) { return je({ ranges: t, range: { start: e, end: e + 1 } }); } function Je({ ranges: t, index: e }) { return ze({ ranges: t, range: { start: e, end: e + 1 } }); } function ze({ ranges: t, range: e }) { if (!ye(t)) throw new Error("Invalid ranges"); if (!we(e)) throw new Error("Invalid range"); const n = [], { start: c, end: s } = e; let o = 0; for (; o < t.length; ) { const r = t[o]; if (!r) throw new Error("Invalid range"); if (r.end >= c) break; n.push({ ...r }), o++; } for (; o < t.length; ) { const r = t[o]; if (!r) throw new Error("Invalid range"); if (r.start >= s) break; r.start < c && n.push({ start: r.start, end: c }), r.end > s && n.push({ start: s, end: r.end }), o++; } for (; o < t.length; ) { const r = t[o]; if (!r) throw new Error("Invalid range"); n.push({ ...r }), o++; } return n; } function Xe({ ranges: t, index: e }) { if (!ae(e)) throw new Error("Invalid index"); const n = { start: e, end: e + 1 }; return le({ ranges: t, index: e }) ? ze({ ranges: t, range: n }) : je({ ranges: t, range: n }); } function fe({ selection: t, index: e }) { return { ranges: Xe({ ranges: t.ranges, index: e }), anchor: e }; } function Pt({ selection: t }) { return t.ranges.reduce((e, n) => e + (n.end - n.start), 0); } const qe = ee({}); function Et({ children: t, data: e, numRows: n, onError: c, selection: s, onSelectionChange: o }) { const [r, u] = A(n), { value: i, onChange: a } = Ve({ value: s, onChange: o, defaultValue: Se(), disabled: s === void 0 && o === void 0 }), [d] = A(() => /* @__PURE__ */ new Map()), [h, f] = A(he({ numRows: n, selection: i })), { orderBy: p } = be(); n !== r && (u(n), f(he({ numRows: n, selection: i })), d.clear()); const [b, y] = A(void 0), l = w(({ gesture: D }) => { D.controller.abort(), y((C) => { if (C !== D) return C; }); }, [y]), k = w(() => { const D = { controller: new AbortController() }; return y((C) => (C && C.controller.abort(), D)), D; }, []), S = W(() => i !== void 0, [i]), g = W(() => { if (i) return ({ rowNumber: D }) => { if (D !== void 0) return le({ ranges: i.ranges, index: D }); }; }, [i]), x = W(() => { if (!(!i || !a)) return ({ rowNumber: D }) => { const C = k(); try { a(fe({ selection: i, index: D })); } finally { l({ gesture: C }); } }; }, [a, i, k, l]), F = W(() => { if (!(!i || !a)) return ({ row: D, rowNumber: C }) => { const P = k(), { signal: H } = P.controller; At({ data: e, numRows: n, row: D, rowNumber: C, selection: i, orderBy: p, signal: H, rowByRowNumberAndOrderBy: d }).finally(() => { l({ gesture: P }); }).then((I) => { a(I); }).catch((I) => { I instanceof Error && I.name === "AbortError" || c?.(I); }); }; }, [a, i, d, e, n, p, k, l, c]), E = W(() => { if (!(!i || !a)) return () => { const D = k(), { signal: C } = D.controller; ke({ data: e, numRows: n, selection: i, signal: C }).finally(() => { l({ gesture: D }); }).then((P) => { a(P); }).catch((P) => { P instanceof Error && P.name === "AbortError" || c?.(P); }); }; }, [a, e, n, i, k, l, c]), N = w((D) => { const { key: C, shiftKey: P } = D; if (C === "Escape") { const H = k(); try { a?.(Se()); } finally { l({ gesture: H }); } } else if (C === "a" && (D.ctrlKey || D.metaKey)) { const H = k(), { signal: I } = H.controller; D.preventDefault(), i && a && ke({ data: e, numRows: n, selection: i, signal: I }).finally(() => { l({ gesture: H }); }).then((v) => { a(v); }).catch((v) => { v instanceof Error && v.name === "AbortError" || c?.(v); }); } else if (C === " " && P) { const { target: H } = D; if (!i || !a || !(H instanceof HTMLTableCellElement)) return; const I = Number(H.getAttribute("data-rownumber")); if (!(H.getAttribute("role") === "cell") || isNaN(I) || !Number.isInteger(I) || I < 0 || I >= n) return; D.preventDefault(); const M = k(); try { a({ ranges: Xe({ ranges: i.ranges, index: I }), anchor: I }); } finally { l({ gesture: M }); } } }, [i, a, k, l, e, n, c]); return G(() => { if (!i) return; const D = k(), { signal: C } = D.controller; Qe({ data: e, numRows: n, selection: i, signal: C }).finally(() => { l({ gesture: D }); }).then((P) => { f(P); }).catch((P) => { P instanceof Error && P.name === "AbortError" || c?.(P); }); }, [i, e, n, k, l, c]), /* @__PURE__ */ m(qe.Provider, { value: { selectable: S, pendingSelectionGesture: b !== void 0, isRowSelected: g, toggleRowNumber: x, toggleRangeToRowNumber: F, onTableKeyDown: N, toggleAllRows: E, allRowsSelected: h }, children: t }); } function Rt() { return Y(qe); } async function me({ data: t, rowStart: e, rowEnd: n, orderBy: c, signal: s }) { return await t.fetch?.({ rowStart: e, rowEnd: n, orderBy: c, signal: s }), Array.from({ length: n - e }, (r, u) => { const i = u + e, a = t.getRowNumber({ row: i, orderBy: c })?.value; if (a === void 0) throw new Error(`Row number is undefined for row ${i} with orderBy ${JSON.stringify(c ?? [])}`); return a; }); } async function Wt({ data: t, numRows: e, rowNumber: n, orderBy: c, signal: s, rowByRowNumberAndOrderBy: o }) { nt(s); const r = Me(c ?? []), u = o?.get(r); if (u) return u.get(n); const i = /* @__PURE__ */ new Map(); await t.fetch?.({ rowStart: 0, rowEnd: e, orderBy: c, signal: s }); for (let a = 0; a < e; a++) { const d = t.getRowNumber({ row: a, orderBy: c })?.value; if (d === void 0) throw new Error(`Row number is undefined for row ${a} with orderBy ${r}`); i.set(d, a); } return o?.set(r, i), i.get(n); } async function At({ data: t, numRows: e, row: n, rowNumber: c, selection: s, orderBy: o, signal: r, rowByRowNumberAndOrderBy: u }) { const { anchor: i } = s; if (i === void 0 || i === c) return fe({ selection: s, index: c }); const a = await Wt({ data: t, numRows: e, rowNumber: i, orderBy: o, signal: r, rowByRowNumberAndOrderBy: u }); if (a === void 0 || a === n) return fe({ selection: s, index: c }); const [d, h] = a < n ? [a + 1, n + 1] : [n, a], f = await me({ data: t, rowStart: d, rowEnd: h, orderBy: o, signal: r }); let { ranges: p } = s; const b = t.getRowNumber({ row: n, orderBy: o })?.value; if (b === void 0) throw new Error(`Row number for row ${n} not found in orderBy ${Me(o ?? [])}`); const y = le({ ranges: p, index: i }); for (const l of f) p = y ? Ge({ ranges: p, index: l }) : Je({ ranges: p, index: l }); return { ranges: p, anchor: b }; } async function ke({ data: t, numRows: e, selection: n, signal: c }) { const s = await Qe({ data: t, numRows: e, selection: n, signal: c }), o = await me({ data: t, rowStart: 0, rowEnd: e, signal: c }); let { ranges: r } = n; for (const u of o) r = s ? Je({ ranges: r, index: u }) : Ge({ ranges: r, index: u }); return { ranges: r }; } function he({ numRows: t, selection: e }) { if (!e || t === 0 || Pt({ selection: e }) < t) return !1; } async function Qe({ data: t, numRows: e, selection: n, signal: c }) { const s = he({ numRows: e, selection: n }); if (s !== void 0) return s; const o = await me({ data: t, rowStart: 0, rowEnd: e, signal: c }); return o.length > 0 && o.every((r) => le({ ranges: n.ranges, index: r })); } function Ce(t) { return w((e) => { t === void 0 || !document.getSelection()?.isCollapsed || (e.preventDefault(), navigator.clipboard.writeText(t).catch((n) => { console.debug("Failed to write to clipboard: ", n); })); }, [t]); } function Mt({ cell: t, onDoubleClickCell: e, onMouseDownCell: n, onKeyDownCell: c, stringify: s, columnIndex: o, visibleColumnIndex: r, className: u, ariaColIndex: i, ariaRowIndex: a, rowNumber: d, renderCellContent: h }) { const f = X(null), { tabIndex: p, navigateToCell: b } = ce({ ref: f, ariaColIndex: i, ariaRowIndex: a }), y = ve().getStyle?.(r), l = W(() => s(t?.value), [s, t]), k = W(() => { if (l !== void 0) { if (l.length > 400) return `${l.slice(0, 397)}…`; if (l.length > 100) return l; } }, [l]), S = W(() => h?.({ cell: t, stringify: s, col: o, row: d }) ?? l, [t, s, o, d, h, l]), g = w((N) => { b(), n && d !== void 0 && n(N, o, d); }, [b, n, d, o]), x = w((N) => { b(), e && d !== void 0 && e(N, o, d); }, [b, e, d, o]), F = w((N) => { c && d !== void 0 && c(N, o, d); }, [c, d, o]), E = Ce(l); return /* @__PURE__ */ m( "td", { ref: f, role: "cell", "aria-busy": t === void 0, "aria-rowindex": a, "aria-colindex": i, "data-rownumber": d, tabIndex: p, onCopy: E, onDoubleClick: x, onMouseDown: g, onKeyDown: F, style: y, className: u, title: k, children: S } ); } function ie({ children: t, ariaRowIndex: e, selected: n, rowNumber: c, title: s }) { return /* @__PURE__ */ m( "tr", { role: "row", "aria-rowindex": e, title: s, "aria-selected": n, "data-rownumber": c, children: t } ); } function It(t) { return t === void 0 ? "" : (t + 1).toLocaleString("en-US"); } function ue({ onCheckboxPress: t, pendingSelectionGesture: e, style: n, ariaColIndex: c, ariaRowIndex: s, selected: o, rowNumber: r }) { const u = X(null), { tabIndex: i, navigateToCell: a } = ce({ ref: u, ariaColIndex: c, ariaRowIndex: s }), d = w((l) => { a(), t?.({ shiftKey: l.shiftKey }); }, [t, a]), h = w((l) => { (l.key === "Enter" || l.key === " ") && (l.preventDefault(), l.stopPropagation(), t?.({ shiftKey: l.shiftKey })); }, [t]), f = t === void 0, p = w((l) => { l.preventDefault(); }, []), b = W(() => It(r), [r]), y = Ce(b); return /* @__PURE__ */ j( "th", { ref: u, scope: "row", role: "rowheader", style: n, onClick: d, onCopy: y, onKeyDown: h, "aria-busy": r === void 0, "aria-checked": o, "aria-rowindex": s, "aria-colindex": c, "aria-disabled": f, tabIndex: i, "data-rownumber": r, children: [ /* @__PURE__ */ m("span", { children: b }), o !== void 0 && /* @__PURE__ */ m( "input", { type: "checkbox", onChange: p, readOnly: f, disabled: f, "aria-busy": e, checked: o, role: "presentation", tabIndex: -1 } ) ] } ); } function Kt({ children: t, checked: e, onCheckboxPress: n, pendingSelectionGesture: c, style: s, ariaColIndex: o, ariaRowIndex: r }, u) { const i = X(null); et(u, () => ({ get offsetWidth() { return i.current?.offsetWidth ?? 0; } }), []); const { tabIndex: a, navigateToCell: d } = ce({ ref: i, ariaColIndex: o, ariaRowIndex: r }), h = w(() => { d(), n?.(); }, [n, d]), f = w((l) => { (l.key === "Enter" || l.key === " ") && (l.preventDefault(), l.stopPropagation(), n?.()); }, [n]), p = e !== void 0, b = n === void 0, y = w((l) => { l.preventDefault(); }, []); return /* @__PURE__ */ m( "td", { ref: i, style: s, onClick: h, onKeyDown: f, "aria-checked": e, "aria-rowindex": r, "aria-colindex": o, "aria-disabled": b, tabIndex: a, children: p ? /* @__PURE__ */ m( "input", { type: "checkbox", onChange: y, readOnly: b, disabled: b, "aria-busy": c, checked: e, role: "presentation", tabIndex: -1 } ) : /* @__PURE__ */ m("span", { children: t }) } ); } const Ye = Ze(Kt); Ye.displayName = "TableCorner"; function Tt(t, e) { const [n, c] = A({ left: 0, top: 0 }), [s, o] = A(!1), r = Ae(), u = w(() => { o(!1); }, []), i = w( (a) => { a.stopPropagation(); const d = t.current?.getBoundingClientRect(), h = a.currentTarget.getBoundingClientRect(); c({ left: h.left, top: d?.bottom ?? 0 }), e(), o((f) => !f); }, [t, e] ); return { isOpen: s, position: n, menuId: r, close: u, handleMenuClick: i }; } const Ot = 'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'; function Ft(t, e) { const n = X(null), c = w(() => [...e.current?.querySelectorAll(Ot) ?? []].filter((o) => o instanceof HTMLElement), [e]); G(() => { if (t) { const { activeElement: o } = document; o instanceof HTMLElement && (n.current = document.activeElement); const r = c().at(0); r && requestAnimationFrame(() => { r.focus(); }); } else n.current && (n.current.focus(), n.current = null); }, [t, c]); const s = w((o) => { const r = c(); if (!r.length) return; const { activeElement: u } = document; if (!u || !(u instanceof HTMLElement)) return; const i = Array.from(r).indexOf(u); let a; switch (o) { case "first": a = 0; break; case "last": a = r.length - 1; break; case "next": a = i >= r.length - 1 ? 0 : i + 1; break; case "previous": a = i <= 0 ? r.length - 1 : i - 1; break; } r[a]?.focus(); }, [c]); return { getFocusableElements: c, navigateFocus: s }; } function $t(t) { switch (t) { case "ascending": return "Ascending"; case "descending": return "Descending"; default: return "No sort"; } } function De({ title: t, children: e }) { return /* @__PURE__ */ j(We, { children: [ /* @__PURE__ */ m("div", { role: "separator", children: t }), e ] }); } function de({ onClick: t, label: e }) { const n = w((s) => { s.preventDefault(), s.stopPropagation(), t?.(); }, [t]), c = w((s) => { (s.key === "Enter" || s.key === " ") && (s.stopPropagation(), s.preventDefault(), t?.()); }, [t]); return /* @__PURE__ */ m( "button", { role: "menuitem", onClick: n, onKeyDown: c, tabIndex: 0, type: "button", children: e } ); } function Nt({ onClick: t }) { return /* @__PURE__ */ m("div", { role: "presentation", onClick: t }); } function Ht({ columnName: t, isOpen: e, position: n, direction: c, sortable: s, toggleOrderBy: o, hideColumn: r, showAllColumns: u, close: i, id: a }) { const { containerRef: d } = Ue(), [h, f] = A(void 0); G(() => { h || !d.current || f(d.current); }, [h, d]); const { top: p, left: b } = n, y = X(null), l = Ae(), { navigateFocus: k } = Ft(e, y), { focusFirstCell: S } = pe(), g = w((P) => { switch (P.preventDefault(), P.stopPropagation(), P.key) { case "Escape": i(); break; case "Enter": case " ": break; case "ArrowUp": case "ArrowLeft": k("previous"); break; case "ArrowDown": case "ArrowRight": k("next"); break; case "Home": k("first"); break; case "End": k("last"); break; case "Tab": k(P.shiftKey ? "previous" : "next"); break; } }, [k, i]), x = w( (P) => { P.preventDefault(), P.stopPropagation(), i(); }, [i] ), F = w((P) => { P.preventDefault(), P.stopPropagation(); }, []), E = W(() => { if (r) return () => { r(), S?.(), i(); }; }, [r, i, S]), N = W(() => { if (u) return () => { u(), i(); }; }, [u, i]); if (!e) return null; const D = $t(c), C = !(!E && !N); return h ? it( /* @__PURE__ */ j(We, { children: [ /* @__PURE__ */ m(Nt, { onClick: x }), /* @__PURE__ */ j( "div", { id: a, role: "menu", style: { top: p, left: b }, ref: y, tabIndex: -1, "aria-labelledby": l, "aria-orientation": "vertical", onKeyDown: g, onClick: F, children: [ /* @__PURE__ */ m("div", { role: "presentation", id: l, "aria-hidden": "true", children: t }), s && /* @__PURE__ */ m(De, { title: "Sort order", children: /* @__PURE__ */ m( de, { onClick: o, label: D } ) }), C && /* @__PURE__ */ j(De, { title: "Visibility", children: [ E && /* @__PURE__ */ m( de, { onClick: E, label: "Hide column" } ), N && /* @__PURE__ */ m( de, { onClick: N, label: "Show all columns" } ) ] }) ] } ) ] }), h ) : null; } function Pe({ onClick: t, onEscape: e, tabIndex: n = 0, isExpanded: c = !1, menuId: s, disabled: o = !1, "aria-label": r = "Column menu", icon: u = /* @__PURE__ */ m("span", { "aria-hidden": "true", children: "⋮" }) }) { const i = w((d) => { d.key === "Enter" || d.key === " " ? (d.preventDefault(), d.stopPropagation(), t?.(d)) : d.key === "Escape" && (d.preventDefault(), d.stopPropagation(), e?.(d)); }, [t, e]), a = w((d) => { t?.(d); }, [t]); return /* @__PURE__ */ m( "button", { type: "button", onClick: o ? void 0 : a, onKeyDown: o ? void 0 : i, "aria-label": r, "aria-haspopup": "menu", "aria-expanded": c, "aria-controls": s, disabled: o, tabIndex: o ? -1 : n, children: u } ); } const Ee = 10, Re = 100; function Lt({ autoResize: t, resizeTo: e, width: n, tabIndex: c, navigateToCell: s }) { const [o, r] = A(void 0), [u, i] = A(!1), a = w(() => { o || t?.(), s?.(); }, [t, s, o]), d = w((g) => { g.stopPropagation(); }, []), h = w((g) => { if (g.button !== 0 || g.ctrlKey || g.metaKey || (s?.(), g.stopPropagation(), n === void 0)) return; const { clientX: x, currentTarget: F, pointerId: E } = g; r({ clientX: x, pointerId: E, width: n }), "setPointerCapture" in F && F.setPointerCapture(E); }, [s, n]), f = w((g) => { !o || g.pointerId !== o.pointerId || e?.(o.width - o.clientX + g.clientX); }, [e, o]), p = w((g) => { g.stopPropagation(), r((x) => { if (!(x && g.pointerId === x.pointerId)) return x; }); }, []), b = w(() => { i(!0); }, []), y = w(() => { i(!1); }, []), l = w((g) => { if (u && ([" ", "ArrowRight", "ArrowLeft", "ArrowUp", "ArrowDown", "PageUp", "PageDown", "Home", "End"].includes(g.key) && g.preventDefault(), g.stopPropagation(), !o)) { if (g.key === "Escape") { i(!1), s?.(); return; } if (g.key === "Enter" || g.key === " ") { a(); return; } n !== void 0 && (g.key === "ArrowRight" || g.key === "ArrowUp" ? e?.(n + Ee) : g.key === "ArrowLeft" || g.key === "ArrowDown" ? e?.(n - Ee) : g.key === "PageUp" ? e?.(n + Re) : g.key === "PageDown" ? e?.(n - Re) : g.key === "Home" && e?.(0)); } }, [a, o, e, n, u, s]), k = o !== void 0 || u, S = W(() => n === void 0 ? "No width set." : `Width set to ${n} pixels.`, [n]); return /* @__PURE__ */ m( "span", { role: "spinbutton", "aria-orientation": "vertical", "aria-busy": k, "aria-valuemin": 0, "aria-valuenow": n, "aria-valuetext": S, "aria-label": "Resize column", "aria-description": 'Press "Enter" or "Space" to autoresize the column (press again to unset the width). Press "Escape" to cancel resizing. Press "ArrowRight/ArrowUp" or "ArrowLeft/ArrowDown" to resize the column by 10 pixels. Press PageUp/PageDown to resize the column by 100 pixels.', onDoubleClick: a, onPointerDown: h, onPointerMove: f, onPointerUp: p, onClick: d, onFocus: b, onBlur: y, onKeyDown: l, tabIndex: c } ); } function Vt({ columnIndex: t, columnName: e, columnConfig: n, canMeasureWidth: c, direction: s, toggleOrderBy: o, orderByIndex: r, orderBySize: u, ariaColIndex: i, ariaRowIndex: a, className: d, children: h }) { const f = X(null), { tabIndex: p, navigateToCell: b } = ce({ ref: f, ariaColIndex: i, ariaRowIndex: a }), { sortable: y } = n, { isOpen: l, position: k, menuId: S, close: g, handleMenuClick: x } = Tt(f, b), { getHideColumn: F, showAllColumns: E } = He(), N = w(() => { b(), y && o?.(); }, [o, b, y]), D = W(() => F?.(e), [F, e]), C = W(() => !(!y && !D && !E), [y, D, E]), { getStyle: P, getDataFixedWidth: H, getWidth: I, setMeasuredWidth: v, setFixedWidth: M, releaseWidth: T } = ve(), _ = P?.(t), R = H?.(t), B = I?.(t), J = w((K) => { M?.(t, K); }, [M, t]), L = w(() => { const K = f.current; if (c && K && B === void 0 && v) { const z = Ke(K); if (isNaN(z)) return; v(t, z); } }, [c, v, B, t]); G(() => { L(); }, [L]); const O = w(() => { T && (st(() => { T(t); }), L()); }, [L, T, t]), $ = W(() => y ? r !== void 0 && r > 0 ? `Press to sort by ${e} in ascending order` : s === "ascending" ? `Press to sort by ${e} in descending order` : s === "descending" ? `Press to stop sorting by ${e}` : `Press to sort by ${e} in ascending order` : `The column ${e} cannot be sorted`, [y, e, s, r]), V = w((K) => { K.target === f.current && (K.key === "Enter" || K.key === " ") && (K.preventDefault(), K.stopPropagation(), o?.()); }, [o]), q = Ce(e), Q = W( () => /* @__PURE__ */ j("div", { role: "group", children: [ y && /* @__PURE__ */ m("span", { role: "img", "aria-hidden": "true", children: s === "ascending" ? "⭡" : s === "descending" ? "⭣" : "⇅" }), C && /* @__PURE__ */ m( Pe, { onClick: x, onEscape: b, tabIndex: p, isExpanded: l, menuId: S, "aria-label": `Column menu for ${e}` } ) ] }), [y, s, C, x, b, p, l, S, e] ), Z = W(() => { const { headerComponent: K } = n; return typeof K == "function" ? K(Q) : K ?? h; }, [n, Q, h]), U = W(() => typeof n.headerComponent == "function", [n]); return /* @__PURE__ */ j( "th", { ref: f, scope: "col", role: "columnheader", "aria-sort": s ?? (y ? "none" : void 0), "data-order-by-index": u !== void 0 ? r : void 0, "data-order-by-size": u, "data-functional-header": U ? "true" : void 0, "aria-label": e, "aria-description": $, "aria-rowindex": a, "aria-colindex": i, tabIndex: p, title: $, onClick: N, onCopy: q, onKeyDown: V, style: _, className: d, "data-fixed-width": R, children: [ Z, U ? null : C && /* @__PURE__ */ m( Pe, { onClick: x, onEscape: b, tabIndex: p, isExpanded: l, menuId: S, "aria-label": `Column menu for ${e}` } ), /* @__PURE__ */ m( Lt, { resizeTo: J, autoResize: O, width: B, tabIndex: p, navigateToCell: b } ), /* @__PURE__ */ m( Ht, { columnName: e, isOpen: l, position: k, direction: s, sortable: y, toggleOrderBy: o, hideColumn: D, showAllColumns: E, close: g, id: S } ) ] } ); } function _t({ columnsParameters: t, orderBy: e, onOrderByChange: n, canMeasureColumn: c, ariaRowIndex: s, exclusiveSort: o }) { const r = w( (i) => { if (!(!n || !e)) return () => { const a = o ? rt(i, e) : ot(i, e); n(a); }; }, [e, n, o] ), u = W(() => new Map((e ?? []).map(({ column: i, direction: a }, d) => [i, { direction: a, index: d }])), [e]); return t.map((i) => { const { name: a, index: d, className: h, ...f } = i, p = d + 2; return ( // The ColumnHeader component width is controlled by the parent /* @__PURE__ */ m( Vt, { canMeasureWidth: c?.[a] === !0, direction: u.get(a)?.direction, orderByIndex: u.get(a)?.index, orderBySize: e?.length, toggleOrderBy: r(a), columnName: a, columnIndex: d, className: h, ariaColIndex: p, ariaRowIndex: s, columnConfig: f, children: a }, d ) ); }); } const Bt = "_hightable_16k3h_1", Ut = "_table-scroll_16k3h_19", jt = "_mock-row-label_16k3h_207", Gt = "_styled_16k3h_221", Jt = "_top-border_16k3h_319", ne = { hightable: Bt, tableScroll: Ut, mockRowLabel: jt, styled: Gt, topBorder: Jt }, se = 33, xe = 20, zt = 20, oe = 2, Xt = "2", qt = `:${Xt}:column:widths`, Qt = "2", Yt = `:${Qt}:column:visibility`; function an(t) { return /* @__PURE__ */ m(xt, { data: t.data, maxRowNumber: t.maxRowNumber, children: /* @__PURE__ */ m(Zt, { ...t }) }); } function Zt(t) { const { data: e, key: n, version: c, maxRowNumber: s, numRows: o } = St(), { cacheKey: r, orderBy: u, onOrderByChange: i, selection: a, onSelectionChange: d, onError: h, onColumnsVisibilityChange: f } = t, p = W(() => e.columnDescriptors.map((y) => y.name), [e.columnDescriptors]), b = W(() => { if (!t.columnConfiguration) return; const y = {}; for (const l of e.columnDescriptors) t.columnConfiguration[l.name]?.initiallyHidden && (y[l.name] = { hidden: !0 }); return y; }, [t.columnConfiguration, e.columnDescriptors]); return ( /* Provide the column configuration to the table */ /* @__PURE__ */ m(ut, { columnConfiguration: t.columnConfiguration, columnDescriptors: e.columnDescriptors, children: /* @__PURE__ */ m(wt, { localStorageKey: r ? `${r}${qt}` : void 0, numColumns: e.columnDescriptors.length, children: /* @__PURE__ */ m(mt, { localStorageKey: r ? `${r}${Yt}` : void 0, columnNames: p, initialVisibilityStates: b, onColumnsVisibilityChange: f, children: /* @__PURE__ */ m(kt, { orderBy: u, onOrderByChange: i, children: /* @__PURE__ */ m(Et, { selection: a, onSelectionChange: d, data: e, numRows: o, onError: h, children: /* @__PURE__ */ m(lt, { colCount: e.columnDescriptors.length + 1, rowCount: o + 1, rowPadding: t.padding ?? xe, children: /* @__PURE__ */ j(Dt, { children: [ " ", /* @__PURE__ */ m(en, { data: e, numRows: o, version: c, ...t, maxRowNumber: s }) ] }) }, n) }, n) }, n) }, r ?? n) }, r ?? n) }) ); } function en({ data: t, numRows: e, overscan: n = zt, padding: c = xe, focus: s = !0, onDoubleClickCell: o, onMouseDownCell: r, onKeyDownCell: u, onError: i = console.error, stringify: a = Ie, className: d = "", styled: h = !0, version: f, renderCellContent: p, maxRowNumber: b }) { const { containerRef: y } = Ue(), l = X(null), k = X(null), { shouldScroll: S, setShouldScroll: g, onScrollKeyDown: x, cellPosition: F } = pe(), { setAvailableWidth: E } = ve(), { orderBy: N } = be(), D = Oe(), { isHiddenColumn: C } = He(), P = W(() => D.filter((R) => !C?.(R.name)), [D, C]), [H, I] = A({ start: 0, end: 0 }), v = (e + 1) * se, M = Math.max(0, H.start - c) * se, T = W(() => { const R = Math.max(b.toLocaleString("en-US").length, 3); return { "--column-header-height": `${se}px`, "--row-number-characters": `${R}` }; }, [b]); G(() => { const R = l.current; if (!S || !R || !("scrollTo" in R)) return; g?.(!1); const B = F.rowIndex - oe; let J = R.scrollTop; (B < H.start || B >= H.end) && (J = B * se), J !== R.scrollTop && R.scrollTo({ top: J, behavior: "auto" }); }, [F, S, H, g]), G(() => { let R; function B() { R?.abort(), R = new AbortController(); const $ = l.current?.clientHeight, V = $ === void 0 || $ === 0 ? 100 : $, q = l.current?.scrollTop ?? 0, Q = Math.floor(e * q / v), Z = Math.ceil(e * (q + V) / v), U = Math.max(0, Q - n), K = Math.min(e, Z + n); if (isNaN(U)) throw new Error(`invalid start row ${U}`); if (isNaN(K)) throw new Error(`invalid end row ${K}`); if (K - U > 1e3) throw new Error(`attempted to render too many rows ${K - U} table must be contained in a scrollable div`); I({ start: U, end: K }), t.fetch && t.fetch({ rowStart: U, rowEnd: K, columns: P.map(({ name: z }) => z), orderBy: N, signal: R.signal }).catch((z) => { z instanceof DOMException && z.name === "AbortError" || i(z); }); } function J() { if (l.current && k.current) { const $ = ct(l.current), V = Ke(k.current); E?.($ - V); } } const L = window.ResizeObserver && new window.ResizeObserver(($) => { for (const V of $) V.target === l.current && (B(), J()); }); B(), J(); const O = l.current; return O && (O.addEventListener("scroll", B), L?.observe(O)), () => { R?.abort(), O && (O.removeEventListener("scroll", B), L?.unobserve(O)), L?.disconnect(); }; }, [e, n, c, v, E, t, N, i, P]); const _ = w((R) => { R.target === l.current && x?.(R); }, [x]); return /* @__PURE__ */ j("div", { ref: y, className: `${ne.hightable} ${h ? ne.styled : ""} ${d}`, style: T, children: [ /* @__PURE__ */ m("div", { className: ne.topBorder, role: "presentation" }), /* @__PURE__ */ m("div", { className: ne.tableScroll, ref: l, role: "group", "aria-labelledby": "caption", onKeyDown: _, tabIndex: 0, children: /* @__PURE__ */ m("div", { style: { height: `${v}px` }, children: /* @__PURE__ */ m( tn, { data: t, numRows: e, padding: c, focus: s, onDoubleClickCell: o, onMouseDownCell: r, onKeyDownCell: u, stringify: a, version: f, renderCellContent: p, offsetTop: M, rowsRange: H, columnsParameters: P, tableCornerRef: k } ) }) }), /* @__PURE__ */ m("div", { className: ne.mockRowLabel, children: " " }) ] }); } function tn({ data: t, numRows: e, padding: n = xe, focus: c = !0, onDoubleClickCell: s, onMouseDownCell: o, onKeyDownCell: r, stringify: u = Ie, version: i, renderCellContent: a, offsetTop: d, rowsRange: h, columnsParameters: f, tableCornerRef: p }) { const { onTableKeyDown: b, focusFirstCell: y } = pe(), { orderBy: l, onOrderByChange: k } = be(), { selectable: S, toggleAllRows: g, pendingSelectionGesture: x, onTableKeyDown: F, allRowsSelected: E, isRowSelected: N, toggleRowNumber: D, toggleRangeToRowNumber: C } = Rt(), P = w((L) => { b?.(L), F?.(L); }, [b, F]), H = w(({ row: L, rowNumber: O }) => { if (!(O === void 0 || !D || !C)) return ({ shiftKey: $ }) => { $ ? C({ row: L, rowNumber: O }) : D({ rowNumber: O }); }; }, [D, C]); G(() => { c && y?.(); }, [c, y]); const I = h.start, v = h.end - h.start, M = Array.from({ length: Math.min(n, I) }, () => []), T = Array.from({ length: v }, (L, O) => O + I), _ = Array.from({ length: Math.min(n, e - I - v) }, () => []), R = W(() => { const L = {}; return { rowContents: T.map(($) => { const V = t.getRowNumber({ row: $, orderBy: l })?.value, q = f.map(({ name: Q, index: Z }) => { const U = t.getCell({ row: $, column: Q, orderBy: l }); return L[Q] ||= U !== void 0, { columnIndex: Z, cell: U }; }); return { row: $, rowNumber: V, cells: q }; }), canMeasureColumn: L, version: i }; }, [t, f, T, l, i]); if (!f.length) return; const B = f.length + 1, J = e + 1; return /* @__PURE__ */ j( "table", { "aria-readonly": !0, "aria-colcount": B, "aria-rowcount": J, "aria-multiselectable": S, "aria-busy": x, role: "grid", style: { top: `${d}px` }, onKeyDown: P, children: [ /* @__PURE__ */ m("caption", { id: "caption", hidden: !0, children: "Virtual-scroll table" }), /* @__PURE__ */ m("thead", { role: "rowgroup", children: /* @__PURE__ */ j(ie, { ariaRowIndex: 1, children: [ /* @__PURE__ */ m( Ye, { onCheckboxPress: g, checked: E, pendingSelectionGesture: x, ariaColIndex: 1, ariaRowIndex: 1, ref: p } ), /* @__PURE__ */ m( _t, { canMeasureColumn: R.canMeasureColumn, columnsParameters: f, orderBy: l, onOrderByChange: k, ariaRowIndex: 1, exclusiveSort: t.exclusiveSort === !0 } ) ] }) }), /* @__PURE__ */ j("tbody", { role: "rowgroup", children: [ M.map((L, O) => { const $ = I - M.length + O, V = $ + oe; return /* @__PURE__ */ m(ie, { ariaRowIndex: V, children: /* @__PURE__ */ m(ue, { ariaColIndex: 1, ariaRowIndex: V }) }, $); }), R.rowContents.map(({ row: L, rowNumber: O, cells: $ }) => { const V = L + oe, q = N?.({ rowNumber: O }), Q = `${L}`; return /* @__PURE__ */ j( ie, { ariaRowIndex: V, selected: q, rowNumber: O, children: [ /* @__PURE__ */ m( ue, { selected: q, rowNumber: O, onCheckboxPress: H({ rowNumber: O, row: L }), pendingSelectionGesture: x, ariaColIndex: 1, ariaRowIndex: V } ), $.map(({ columnIndex: Z, cell: U }, K) => { const z = f[K]?.className; return /* @__PURE__ */ m( Mt, { onDoubleClickCell: s, onMouseDownCell: o, onKeyDownCell: r, stringify: u, columnIndex: Z, visibleColumnIndex: K, className: z, ariaColIndex: K + oe, ariaRowIndex: V, cell: U, rowNumber: O, renderCellContent: a }, Z ); }) ] }, Q ); }),