@trsys-tech/matrix-library 1.1.8-alpha.2 → 1.1.8-alpha.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,376 +1,391 @@
1
- import { jsxs as S, jsx as m } from "react/jsx-runtime";
2
- import * as r from "react";
3
- import { DragDropProvider as be, DragOverlay as we } from "@dnd-kit/react";
4
- import { useVirtualizer as ye } from "@tanstack/react-virtual";
5
- import { cn as Ct } from "./utils.es.js";
6
- import { Button as kt } from "./button.es.js";
7
- import { useDataTable as Ie, DataTableAlignmentContext as ve } from "./datatablecontext.es.js";
8
- import { dataTableColumnSensors as Re } from "./datatablecolumndrag.es.js";
9
- import { getActiveDataTableCell as Ce } from "./datatablemodel.es.js";
10
- import { useDataTableInstance as ke } from "./usedatatableinstance.es.js";
11
- import { DataTableHeader as Ee } from "./datatableheader.es.js";
12
- import { DataTablePagination as Se } from "./datatablepagination.es.js";
13
- import { DataTableRowView as _e } from "./datatablerowview.es.js";
14
- import { useDataTableColumnDrag as Pe } from "./usedatatablecolumndrag.es.js";
15
- import { useDataTableMotion as De } from "./usedatatablemotion.es.js";
1
+ import { jsxs as C, jsx as d } from "react/jsx-runtime";
2
+ import * as n from "react";
3
+ import { DragDropProvider as ye, DragOverlay as ve } from "@dnd-kit/react";
4
+ import { useVirtualizer as Ie } from "@tanstack/react-virtual";
5
+ import { cn as kt } from "./utils.es.js";
6
+ import { Button as Et } from "./button.es.js";
7
+ import { useDataTable as Re, DataTableAlignmentContext as Ce } from "./datatablecontext.es.js";
8
+ import { dataTableColumnSensors as Se } from "./datatablecolumndrag.es.js";
9
+ import { getActiveDataTableCell as ke } from "./datatablemodel.es.js";
10
+ import { useDataTableInstance as Ee } from "./usedatatableinstance.es.js";
11
+ import { DataTableHeader as _e } from "./datatableheader.es.js";
12
+ import { DataTablePagination as Pe } from "./datatablepagination.es.js";
13
+ import { DataTableRowView as De } from "./datatablerowview.es.js";
14
+ import { useDataTableColumnDrag as ze } from "./usedatatablecolumndrag.es.js";
15
+ import { useDataTableMotion as Le } from "./usedatatablemotion.es.js";
16
16
  import { useDataTableApi as Te } from "./usedatatableapi.es.js";
17
- const Et = [], Ae = {};
18
- function ze({
19
- rowData: St,
20
- columnDefs: J,
21
- defaultColDef: _t = Ae,
22
- getRowId: Pt,
17
+ const _t = [], Ae = {};
18
+ function Ne({
19
+ rowData: Pt,
20
+ columnDefs: H,
21
+ defaultColDef: Dt = Ae,
22
+ getRowId: zt,
23
23
  onReady: et,
24
- rowSelection: p,
25
- renderSubComponent: z,
26
- getRowCanExpand: Dt,
27
- onSelectionChanged: nt,
24
+ rowSelection: h,
25
+ renderSubComponent: T,
26
+ getRowCanExpand: Lt,
27
+ onSelectionChanged: rt,
28
28
  quickFilterText: Tt,
29
29
  onQuickFilterTextChange: At,
30
- externalFilter: zt,
31
- loading: N = !1,
32
- emptyContent: Nt = "No rows to display",
33
- loadingContent: jt = "Loading…",
34
- rowHeight: K = 36,
35
- headerHeight: j = 40,
36
- getRowClass: Mt,
37
- rowClassRules: Lt,
38
- pinnedTopRowData: _ = Et,
39
- pinnedBottomRowData: M = Et,
40
- pagination: L = !1,
41
- paginationPageSize: Vt = 25,
42
- paginationPageSizeSelector: Wt = [10, 25, 50, 100],
43
- virtualize: Ft = !0,
44
- overscan: $t = 8,
45
- domLayout: rt = "normal",
46
- suppressHorizontalScroll: Ot = !1,
30
+ externalFilter: Nt,
31
+ loading: A = !1,
32
+ emptyContent: jt = "No rows to display",
33
+ loadingContent: Mt = "Loading…",
34
+ rowHeight: O = 40,
35
+ headerHeight: Vt = 40,
36
+ getRowClass: Wt,
37
+ rowClassRules: Ft,
38
+ pinnedTopRowData: P = _t,
39
+ pinnedBottomRowData: N = _t,
40
+ pagination: j = !1,
41
+ paginationPageSize: $t = 25,
42
+ paginationPageSizeSelector: Ht = [10, 25, 50, 100],
43
+ virtualize: Ot = !0,
44
+ overscan: Jt = 8,
45
+ domLayout: nt = "normal",
46
+ suppressHorizontalScroll: Kt = !1,
47
47
  editType: st = "cell",
48
- suppressClickEdit: Jt = !1,
48
+ suppressClickEdit: Ut = !1,
49
49
  readOnlyEdit: ot = !1,
50
50
  validateRow: it,
51
51
  onEditCommit: lt,
52
52
  onEditRequest: at,
53
53
  onEditCancel: ct,
54
- onRowClick: Kt,
55
- tableOptions: P,
56
- containerStyle: U,
57
- className: Ut,
58
- style: Xt,
54
+ onRowClick: Xt,
55
+ tableOptions: D,
56
+ containerStyle: J,
57
+ className: Bt,
58
+ style: Yt,
59
59
  ...dt
60
- }, Bt) {
60
+ }, Gt) {
61
61
  "use no memo";
62
- const { setApi: X, search: Ht, hasSearch: Yt, setSearch: Gt, setCounts: mt } = Ie(), D = r.useContext(ve), Qt = r.useId(), y = r.useRef(null), B = r.useRef(null), [Zt, qt] = r.useState(0), [te, ee] = r.useState(!1), [H, ne] = r.useState(null), [re, se] = r.useState(null), [oe, ut] = r.useState({}), [T, ie] = r.useState(null), [le] = r.useState(() => P?.initialState?.globalFilter ?? ""), x = r.useRef(T), ft = r.useRef({ columnDefs: J, validateRow: it, readOnlyEdit: ot, onEditCommit: lt, onEditRequest: at, onEditCancel: ct });
63
- ft.current = { columnDefs: J, validateRow: it, readOnlyEdit: ot, onEditCommit: lt, onEditRequest: at, onEditCancel: ct };
64
- const gt = r.useCallback((t) => {
65
- x.current = t, ie(t);
66
- }, []), l = te || rt === "print", pt = l || rt === "autoHeight", ae = Tt ?? P?.state?.globalFilter ?? (Yt ? Ht : le), V = !!p && p.checkboxes !== !1 && !l, W = !!z && !l, Y = W ? 44 : 0, G = (V ? 44 : 0) + Y, { table: o, definitionsById: R, sourcesById: h, data: ce, rowIndices: F, resolveId: xt } = ke({
67
- rowData: St,
68
- columnDefs: J,
69
- defaultColDef: _t,
70
- getRowId: Pt,
71
- paginationPageSize: Vt,
72
- tableOptions: P,
73
- externalFilter: zt,
74
- rowSelection: p,
75
- pagination: L,
76
- renderSubComponent: z,
77
- getRowCanExpand: Dt,
62
+ const { setApi: K, search: Qt, hasSearch: Zt, setSearch: qt, setCounts: mt } = Re(), x = n.useContext(Ce), te = n.useId(), g = n.useRef(null), ut = n.useRef(null), U = n.useRef(null), X = n.useRef(null), [ft, ee] = n.useState(0), [re, ne] = n.useState(!1), [B, se] = n.useState(null), [oe, ie] = n.useState(null), [le, gt] = n.useState({}), [z, ae] = n.useState(null), [ce] = n.useState(() => D?.initialState?.globalFilter ?? ""), b = n.useRef(z), pt = n.useRef({ columnDefs: H, validateRow: it, readOnlyEdit: ot, onEditCommit: lt, onEditRequest: at, onEditCancel: ct });
63
+ pt.current = { columnDefs: H, validateRow: it, readOnlyEdit: ot, onEditCommit: lt, onEditRequest: at, onEditCancel: ct };
64
+ const ht = n.useCallback((t) => {
65
+ b.current = t, ae(t);
66
+ }, []), s = re || nt === "print", xt = s || nt === "autoHeight", de = Tt ?? D?.state?.globalFilter ?? (Zt ? Qt : ce), M = !!h && h.checkboxes !== !1 && !s, V = !!T && !s, Y = V ? 44 : 0, G = (M ? 44 : 0) + Y, { table: a, definitionsById: S, sourcesById: w, data: me, rowIndices: W, resolveId: bt } = Ee({
67
+ rowData: Pt,
68
+ columnDefs: H,
69
+ defaultColDef: Dt,
70
+ getRowId: zt,
71
+ paginationPageSize: $t,
72
+ tableOptions: D,
73
+ externalFilter: Nt,
74
+ rowSelection: h,
75
+ pagination: j,
76
+ renderSubComponent: T,
77
+ getRowCanExpand: Lt,
78
78
  onQuickFilterTextChange: At,
79
- patches: oe,
80
- alignment: D,
81
- isPrinting: l,
82
- viewportWidth: Zt,
79
+ patches: le,
80
+ alignment: x,
81
+ isPrinting: s,
82
+ viewportWidth: ft,
83
83
  selectionWidth: G,
84
- searchText: ae,
85
- setSearch: Gt
86
- }), a = [...o.getStartVisibleLeafColumns(), ...o.getCenterVisibleLeafColumns(), ...o.getEndVisibleLeafColumns()].filter(
87
- (t) => t.id !== "__external" && (!l || !R.get(t.id)?.hideInPrint)
84
+ searchText: de,
85
+ setSearch: qt
86
+ }), c = [...a.getStartVisibleLeafColumns(), ...a.getCenterVisibleLeafColumns(), ...a.getEndVisibleLeafColumns()].filter(
87
+ (t) => t.id !== "__external" && (!s || !S.get(t.id)?.hideInPrint)
88
88
  );
89
- if (H) {
90
- const t = a.findIndex((n) => n.id === H.sourceId), e = a.findIndex((n) => n.id === H.targetId);
91
- t >= 0 && e >= 0 && a.splice(e, 0, a.splice(t, 1)[0]);
89
+ if (B) {
90
+ const t = c.findIndex((r) => r.id === B.sourceId), e = c.findIndex((r) => r.id === B.targetId);
91
+ t >= 0 && e >= 0 && c.splice(e, 0, c.splice(t, 1)[0]);
92
92
  }
93
- const A = new Map(a.map((t) => [t.id, t.getSize()])), Q = G + a.reduce((t, e) => t + A.get(e.id), 0), g = o.getTopRows(), b = o.getBottomRows(), ht = new Set([...g, ...b].map((t) => t.id)), d = (l ? o.getPrePaginatedRowModel().rows : o.getRowModel().rows).filter((t) => !ht.has(t.id)), Z = (t) => !!z && t.getCanExpand() && t.getIsExpanded(), de = [...g, ...d, ...b].some(Z), C = Ft && !pt && !de, bt = (g.length + _.length) * K, $ = ye({
94
- count: d.length,
95
- getScrollElement: () => y.current,
96
- estimateSize: () => K,
97
- getItemKey: (t) => d[t].id,
98
- overscan: $t,
99
- scrollMargin: j + bt,
100
- enabled: C,
93
+ const L = new Map(c.map((t) => [t.id, t.getSize()])), Q = G + c.reduce((t, e) => t + L.get(e.id), 0), p = a.getTopRows(), y = a.getBottomRows(), wt = new Set([...p, ...y].map((t) => t.id)), m = (s ? a.getPrePaginatedRowModel().rows : a.getRowModel().rows).filter((t) => !wt.has(t.id)), Z = (t) => !!T && t.getCanExpand() && t.getIsExpanded(), ue = [...p, ...m, ...y].some(Z), k = Ot && !xt && !ue, yt = (p.length + P.length) * O, F = Ie({
94
+ count: m.length,
95
+ getScrollElement: () => g.current,
96
+ estimateSize: () => O,
97
+ getItemKey: (t) => m[t].id,
98
+ overscan: Jt,
99
+ scrollMargin: yt,
100
+ enabled: k,
101
101
  useFlushSync: !1
102
- }), I = r.useRef({
103
- table: o,
104
- definitionsById: R,
105
- centerRows: d,
106
- virtualizer: $,
107
- resolveId: xt,
108
- rowIndices: F,
109
- sourcesById: h,
110
- useVirtualRows: C,
111
- pagination: L,
112
- serverPagination: P?.manualPagination === !0
102
+ }), I = n.useRef({
103
+ table: a,
104
+ definitionsById: S,
105
+ centerRows: m,
106
+ virtualizer: F,
107
+ resolveId: bt,
108
+ rowIndices: W,
109
+ sourcesById: w,
110
+ useVirtualRows: k,
111
+ pagination: j,
112
+ serverPagination: D?.manualPagination === !0
113
113
  });
114
114
  I.current = {
115
- table: o,
116
- definitionsById: R,
117
- centerRows: d,
118
- virtualizer: $,
119
- resolveId: xt,
120
- rowIndices: F,
121
- sourcesById: h,
122
- useVirtualRows: C,
123
- pagination: L,
124
- serverPagination: P?.manualPagination === !0
115
+ table: a,
116
+ definitionsById: S,
117
+ centerRows: m,
118
+ virtualizer: F,
119
+ resolveId: bt,
120
+ rowIndices: W,
121
+ sourcesById: w,
122
+ useVirtualRows: k,
123
+ pagination: j,
124
+ serverPagination: D?.manualPagination === !0
125
125
  };
126
- const me = Pe({ runtime: I, viewportRef: y, contentRef: B, setColumnDrag: ne }), s = Te({ runtime: I, editRef: x, configRef: ft, updateEdit: gt, setPatches: ut, contentRef: B, viewportRef: y, setPrinting: ee });
127
- r.useImperativeHandle(Bt, () => s, [s]), r.useEffect(() => (X(s), () => X((t) => t === s ? null : t)), [s, X]);
128
- const wt = r.useRef(et);
129
- wt.current = et, r.useEffect(() => {
130
- wt.current?.(s);
131
- }, [s]);
132
- const yt = r.useRef(nt);
133
- yt.current = nt, r.useEffect(() => {
134
- const t = I.current.table, e = t.getSelectedRowModel().rows.map((n) => n.original);
135
- yt.current?.(e, t.getSelectedRowIds());
136
- }, [o.state.rowSelection, ce]), r.useEffect(() => {
137
- const t = I.current.table, e = t.getSelectedRowIds().length, n = (t.state.rowPinning.top?.length ?? 0) + (t.state.rowPinning.bottom?.length ?? 0);
126
+ const fe = ze({ runtime: I, viewportRef: g, contentRef: X, setColumnDrag: se }), o = Te({ runtime: I, editRef: b, configRef: pt, updateEdit: ht, setPatches: gt, contentRef: X, viewportRef: g, setPrinting: ne });
127
+ n.useImperativeHandle(Gt, () => o, [o]), n.useEffect(() => (K(o), () => K((t) => t === o ? null : t)), [o, K]);
128
+ const vt = n.useRef(et);
129
+ vt.current = et, n.useEffect(() => {
130
+ vt.current?.(o);
131
+ }, [o]);
132
+ const It = n.useRef(rt);
133
+ It.current = rt, n.useEffect(() => {
134
+ const t = I.current.table, e = t.getSelectedRowModel().rows.map((r) => r.original);
135
+ It.current?.(e, t.getSelectedRowIds());
136
+ }, [a.state.rowSelection, me]), n.useEffect(() => {
137
+ const t = I.current.table, e = t.getSelectedRowIds().length, r = (t.state.rowPinning.top?.length ?? 0) + (t.state.rowPinning.bottom?.length ?? 0);
138
138
  mt(
139
- (i) => i.selectedCount === e && i.pinnedCount === n ? i : { selectedCount: e, pinnedCount: n }
139
+ (i) => i.selectedCount === e && i.pinnedCount === r ? i : { selectedCount: e, pinnedCount: r }
140
140
  );
141
- }, [o.state.rowSelection, o.state.rowPinning, mt]), r.useEffect(() => {
142
- const t = y.current;
141
+ }, [a.state.rowSelection, a.state.rowPinning, mt]), n.useEffect(() => {
142
+ const t = g.current;
143
143
  if (!t) return;
144
- const e = () => qt(t.clientWidth);
144
+ const e = () => ee(t.clientWidth);
145
145
  e();
146
- const n = new ResizeObserver(e);
147
- return n.observe(t), () => n.disconnect();
148
- }, []), r.useEffect(() => {
149
- const t = y.current, e = D?.viewports.current;
146
+ const r = new ResizeObserver(e);
147
+ return r.observe(t), () => r.disconnect();
148
+ }, []), n.useEffect(() => {
149
+ const t = g.current, e = x?.viewports.current;
150
150
  if (!(!t || !e))
151
151
  return e.add(t), () => {
152
152
  e.delete(t);
153
153
  };
154
- }, [D?.viewports]), r.useEffect(() => {
155
- x.current && h.get(x.current.rowId) !== x.current.source && s.stopEditing(!0), ut((e) => {
156
- const n = Object.entries(e).filter(([i, c]) => h.get(i) === c.source);
157
- return n.length === Object.keys(e).length ? e : Object.fromEntries(n);
154
+ }, [x?.viewports]), n.useEffect(() => {
155
+ b.current && w.get(b.current.rowId) !== b.current.source && o.stopEditing(!0), gt((e) => {
156
+ const r = Object.entries(e).filter(([i, l]) => w.get(i) === l.source);
157
+ return r.length === Object.keys(e).length ? e : Object.fromEntries(r);
158
158
  });
159
159
  const t = I.current.table;
160
160
  if (!I.current.serverPagination) {
161
- const e = t.atoms.rowSelection.get(), n = Object.entries(e).filter(([u]) => h.has(u));
162
- n.length !== Object.keys(e).length && t.setRowSelection(Object.fromEntries(n));
163
- const i = t.atoms.rowPinning.get(), c = i.top?.filter((u) => h.has(u)), w = i.bottom?.filter((u) => h.has(u));
164
- (c?.length !== i.top?.length || w?.length !== i.bottom?.length) && t.setRowPinning({ top: c, bottom: w });
161
+ const e = t.atoms.rowSelection.get(), r = Object.entries(e).filter(([u]) => w.has(u));
162
+ r.length !== Object.keys(e).length && t.setRowSelection(Object.fromEntries(r));
163
+ const i = t.atoms.rowPinning.get(), l = i.top?.filter((u) => w.has(u)), v = i.bottom?.filter((u) => w.has(u));
164
+ (l?.length !== i.top?.length || v?.length !== i.bottom?.length) && t.setRowPinning({ top: l, bottom: v });
165
165
  }
166
- }, [h, s]);
167
- const O = [...g, ...d, ...b], q = [
168
- ..._.map((t, e) => `__summary_top_${e}`),
169
- ...g.map((t) => t.id),
170
- ...d.map((t) => t.id),
171
- ...b.map((t) => t.id),
172
- ...M.map((t, e) => `__summary_bottom_${e}`)
173
- ], ue = new Set(O.filter(Z).map((t) => t.id));
166
+ }, [w, o]);
167
+ const $ = [...p, ...m, ...y], q = [
168
+ ...P.map((t, e) => `__summary_top_${e}`),
169
+ ...p.map((t) => t.id),
170
+ ...m.map((t) => t.id),
171
+ ...y.map((t) => t.id),
172
+ ...N.map((t, e) => `__summary_bottom_${e}`)
173
+ ], ge = new Set($.filter(Z).map((t) => t.id));
174
174
  let tt = 0;
175
- const fe = new Map(
175
+ const pe = new Map(
176
176
  q.map((t) => {
177
177
  const e = tt;
178
- return tt += ue.has(t) ? 2 : 1, [t, e];
178
+ return tt += ge.has(t) ? 2 : 1, [t, e];
179
179
  })
180
- ), It = C ? $.getVirtualItems() : [], ge = C ? [
181
- ...q.slice(0, _.length + g.length),
182
- ...It.map((t) => d[t.index].id),
183
- ...b.map((t) => t.id),
184
- ...M.map((t, e) => `__summary_bottom_${e}`)
185
- ] : q, pe = Ce(
186
- re,
187
- ge,
188
- a.map((t) => t.id)
180
+ ), Rt = k ? F.getVirtualItems() : [], he = k ? [
181
+ ...q.slice(0, P.length + p.length),
182
+ ...Rt.map((t) => m[t.index].id),
183
+ ...y.map((t) => t.id),
184
+ ...N.map((t, e) => `__summary_bottom_${e}`)
185
+ ] : q, xe = ke(
186
+ oe,
187
+ he,
188
+ c.map((t) => t.id)
189
189
  );
190
- De(y, JSON.stringify(d.map((t) => t.id)), JSON.stringify(a.map((t) => t.id)), l);
191
- const vt = (t, e = !1) => {
192
- const n = l ? !1 : t.getIsPinned(), i = a.filter((f) => f.getIsPinned() === n), c = i.findIndex((f) => f.id === t.id), w = i.slice(0, c).reduce((f, E) => f + A.get(E.id), G), u = i.slice(c + 1).reduce((f, E) => f + A.get(E.id), 0);
190
+ Le(g, JSON.stringify(m.map((t) => t.id)), JSON.stringify(c.map((t) => t.id)), s);
191
+ const Ct = (t, e = !1) => {
192
+ const r = s ? !1 : t.getIsPinned(), i = c.filter((f) => f.getIsPinned() === r), l = i.findIndex((f) => f.id === t.id), v = i.slice(0, l).reduce((f, _) => f + L.get(_.id), G), u = i.slice(l + 1).reduce((f, _) => f + L.get(_.id), 0);
193
193
  return {
194
- width: A.get(t.id),
194
+ width: L.get(t.id),
195
195
  flexShrink: 0,
196
- position: n ? "sticky" : "relative",
197
- insetInlineStart: n === "start" ? w : void 0,
198
- insetInlineEnd: n === "end" ? u : void 0,
199
- zIndex: n ? 2 : void 0,
200
- background: n ? e ? "oklch(var(--mtx-primary-50))" : "inherit" : void 0
196
+ position: r ? "sticky" : "relative",
197
+ insetInlineStart: r === "start" ? v : void 0,
198
+ insetInlineEnd: r === "end" ? u : void 0,
199
+ zIndex: r ? 2 : void 0,
200
+ background: r ? e ? "oklch(var(--mtx-primary-50))" : "inherit" : void 0
201
201
  };
202
- }, xe = (t, e, n) => {
202
+ }, be = (t, e, r) => {
203
203
  if (t.defaultPrevented) return;
204
- if (t.key === "Escape" && x.current) {
205
- t.preventDefault(), s.stopEditing(!0);
204
+ if (t.key === "Escape" && b.current) {
205
+ t.preventDefault(), o.stopEditing(!0);
206
206
  return;
207
207
  }
208
- if (t.key === "Enter" && x.current) {
208
+ if (t.key === "Enter" && b.current) {
209
209
  if (t.target.closest("button,select,textarea,[contenteditable=true],[role=combobox],[role=listbox]")) return;
210
- t.preventDefault(), s.stopEditing();
210
+ t.preventDefault(), o.stopEditing();
211
211
  return;
212
212
  }
213
213
  if (t.target.closest("input,select,textarea,button,[contenteditable=true]")) return;
214
214
  if (t.key === "Enter" || t.key === "F2") {
215
- t.preventDefault(), st === "fullRow" ? s.startEditingRow(e.id) : s.startEditingCell({ rowId: e.id, columnId: n.id });
215
+ t.preventDefault(), st === "fullRow" ? o.startEditingRow(e.id) : o.startEditingCell({ rowId: e.id, columnId: r.id });
216
216
  return;
217
217
  }
218
- const c = O.findIndex((v) => v.id === e.id), w = a.findIndex((v) => v.id === n.id), u = t.key === "ArrowDown" ? c + 1 : t.key === "ArrowUp" ? c - 1 : c, f = getComputedStyle(t.currentTarget).direction === "rtl" ? -1 : 1, E = t.key === "ArrowRight" ? w + f : t.key === "ArrowLeft" ? w - f : w;
219
- if (["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"].includes(t.key) && O[u] && a[E]) {
218
+ const l = $.findIndex((R) => R.id === e.id), v = c.findIndex((R) => R.id === r.id), u = t.key === "ArrowDown" ? l + 1 : t.key === "ArrowUp" ? l - 1 : l, f = getComputedStyle(t.currentTarget).direction === "rtl" ? -1 : 1, _ = t.key === "ArrowRight" ? v + f : t.key === "ArrowLeft" ? v - f : v;
219
+ if (["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"].includes(t.key) && $[u] && c[_]) {
220
220
  t.preventDefault();
221
- const v = O[u];
222
- ht.has(v.id) || s.scrollToRow(v.id), s.focusCell(v.id, a[E].id);
221
+ const R = $[u];
222
+ wt.has(R.id) || o.scrollToRow(R.id), o.focusCell(R.id, c[_].id);
223
223
  }
224
- }, k = (t, e, n, i, c) => /* @__PURE__ */ m(
225
- _e,
224
+ }, E = (t, e, r, i, l) => /* @__PURE__ */ d(
225
+ De,
226
226
  {
227
227
  data: t,
228
228
  rowId: e,
229
- index: n,
229
+ index: r,
230
230
  row: i,
231
- pinned: c,
232
- edit: T,
233
- editRef: x,
234
- updateEdit: gt,
235
- api: s,
236
- table: o,
237
- detailId: Qt,
238
- displayedIndices: fe,
239
- rowSelection: p,
240
- rowHeight: K,
231
+ pinned: l,
232
+ edit: z,
233
+ editRef: b,
234
+ updateEdit: ht,
235
+ api: o,
236
+ table: a,
237
+ detailId: te,
238
+ displayedIndices: pe,
239
+ rowSelection: h,
240
+ rowHeight: O,
241
241
  totalWidth: Q,
242
- getRowClass: Mt,
243
- rowClassRules: Lt,
244
- onRowClick: Kt,
245
- showExpanders: W,
242
+ getRowClass: Wt,
243
+ rowClassRules: Ft,
244
+ onRowClick: Xt,
245
+ showExpanders: V,
246
246
  expanderWidth: Y,
247
- showCheckboxes: V,
248
- visibleColumns: a,
249
- definitionsById: R,
250
- activeCell: pe,
251
- setFocusedCell: se,
252
- columnStyle: vt,
253
- handleCellKeyDown: xe,
254
- suppressClickEdit: Jt,
247
+ showCheckboxes: M,
248
+ visibleColumns: c,
249
+ definitionsById: S,
250
+ activeCell: xe,
251
+ setFocusedCell: ie,
252
+ columnStyle: Ct,
253
+ handleCellKeyDown: be,
254
+ suppressClickEdit: Ut,
255
255
  editType: st,
256
- renderSubComponent: z,
256
+ renderSubComponent: T,
257
257
  isDetailExpanded: Z
258
258
  },
259
259
  e
260
- ), Rt = (p?.selectAll === "all" ? o.getCoreRowModel() : p?.selectAll === "currentPage" ? o.getRowModel() : o.getFilteredRowModel()).rows.filter((t) => t.getCanSelect()), he = Rt.filter((t) => t.getIsSelected()).length;
261
- return /* @__PURE__ */ S(be, { sensors: Re, ...me, children: [
262
- /* @__PURE__ */ m(we, { dropAnimation: null, style: { position: "fixed", pointerEvents: "none" }, children: (t) => {
263
- const e = R.get(t.data.columnId);
264
- return /* @__PURE__ */ m("div", { className: "mtx-rounded-sm mtx-border mtx-border-gray-200 mtx-bg-primary-50 mtx-px-3 mtx-py-2 mtx-text-xs mtx-font-bold mtx-shadow-md", children: e?.headerName ?? t.data.columnId });
260
+ ), St = (h?.selectAll === "all" ? a.getCoreRowModel() : h?.selectAll === "currentPage" ? a.getRowModel() : a.getFilteredRowModel()).rows.filter((t) => t.getCanSelect()), we = St.filter((t) => t.getIsSelected()).length;
261
+ return /* @__PURE__ */ C(ye, { sensors: Se, ...fe, children: [
262
+ /* @__PURE__ */ d(ve, { dropAnimation: null, style: { position: "fixed", pointerEvents: "none" }, children: (t) => {
263
+ const e = S.get(t.data.columnId);
264
+ return /* @__PURE__ */ d("div", { className: "mtx-rounded-sm mtx-border mtx-border-gray-200 mtx-bg-primary-50 mtx-px-3 mtx-py-2 mtx-text-xs mtx-font-bold mtx-shadow-md", children: e?.headerName ?? t.data.columnId });
265
265
  } }),
266
- /* @__PURE__ */ S(
266
+ /* @__PURE__ */ C(
267
267
  "div",
268
268
  {
269
- ref: B,
269
+ ref: X,
270
270
  "data-data-table-content": "",
271
- "data-print-layout": l || void 0,
272
- className: Ct("mtx-relative mtx-flex mtx-min-h-0 mtx-flex-1 mtx-flex-col mtx-rounded-b-lg", Ut),
273
- style: Xt,
271
+ "data-print-layout": s || void 0,
272
+ className: kt("mtx-relative mtx-flex mtx-min-h-0 mtx-flex-1 mtx-flex-col mtx-rounded-b-lg", Bt),
273
+ style: Yt,
274
274
  ...dt,
275
275
  children: [
276
- T && /* @__PURE__ */ S("div", { "data-print-hidden": "", className: "mtx-flex mtx-shrink-0 mtx-items-center mtx-gap-2 mtx-border-b mtx-border-gray-200 mtx-p-2", children: [
277
- /* @__PURE__ */ m(kt, { type: "button", size: "sm", onClick: () => s.stopEditing(), children: "Save" }),
278
- /* @__PURE__ */ m(kt, { type: "button", size: "sm", variant: "text", onClick: () => s.stopEditing(!0), children: "Cancel" }),
279
- T.errors.length > 0 && /* @__PURE__ */ m("span", { role: "alert", className: "mtx-text-danger", children: T.errors.join(". ") })
276
+ z && /* @__PURE__ */ C("div", { "data-print-hidden": "", className: "mtx-flex mtx-shrink-0 mtx-items-center mtx-gap-2 mtx-border-b mtx-border-gray-200 mtx-p-2", children: [
277
+ /* @__PURE__ */ d(Et, { type: "button", size: "sm", onClick: () => o.stopEditing(), children: "Save" }),
278
+ /* @__PURE__ */ d(Et, { type: "button", size: "sm", variant: "text", onClick: () => o.stopEditing(!0), children: "Cancel" }),
279
+ z.errors.length > 0 && /* @__PURE__ */ d("span", { role: "alert", className: "mtx-text-danger", children: z.errors.join(". ") })
280
280
  ] }),
281
- /* @__PURE__ */ S(
281
+ /* @__PURE__ */ C(
282
282
  "div",
283
283
  {
284
- ref: y,
285
- "data-data-table-viewport": "",
286
284
  role: "grid",
287
285
  "aria-label": dt["aria-label"] ?? "Data table",
288
- "aria-busy": N,
286
+ "aria-busy": A,
289
287
  "aria-rowcount": tt + 1,
290
- "aria-colcount": a.length + (V ? 1 : 0) + (W ? 1 : 0),
291
- "aria-multiselectable": p?.mode === "multiRow" || void 0,
292
- className: "mtx-relative mtx-min-h-0 mtx-flex-1 mtx-rounded-b-lg",
293
- style: {
294
- ...U,
295
- overflow: pt ? "visible" : U?.overflow ?? "auto",
296
- overflowX: l ? "visible" : Ot ? "hidden" : U?.overflowX
297
- },
298
- onScroll: (t) => {
299
- if (D && !l)
300
- for (const e of D.viewports.current)
301
- e !== t.currentTarget && e.scrollLeft !== t.currentTarget.scrollLeft && (e.scrollLeft = t.currentTarget.scrollLeft);
302
- },
288
+ "aria-colcount": c.length + (M ? 1 : 0) + (V ? 1 : 0),
289
+ "aria-multiselectable": h?.mode === "multiRow" || void 0,
290
+ className: "mtx-flex mtx-min-h-0 mtx-flex-1 mtx-flex-col",
303
291
  children: [
304
- /* @__PURE__ */ m(
305
- Ee,
292
+ /* @__PURE__ */ d("div", { className: "mtx-shrink-0 mtx-bg-primary-50", children: /* @__PURE__ */ d(
293
+ "div",
306
294
  {
307
- table: o,
308
- api: s,
309
- headerHeight: j,
310
- totalWidth: Q,
311
- isPrinting: l,
312
- showExpanders: W,
313
- expanderWidth: Y,
314
- showCheckboxes: V,
315
- rowSelection: p,
316
- selectionRows: Rt,
317
- selectedInScope: he,
318
- visibleColumns: a,
319
- definitionsById: R,
320
- columnStyle: vt,
321
- widths: A
295
+ ref: ut,
296
+ style: { overflow: s ? "visible" : "hidden", width: s ? "100%" : ft || "100%" },
297
+ onScroll: (t) => {
298
+ const e = U.current === t.currentTarget.scrollLeft;
299
+ U.current = null, !e && !s && g.current && (g.current.scrollLeft = t.currentTarget.scrollLeft);
300
+ },
301
+ children: /* @__PURE__ */ d(
302
+ _e,
303
+ {
304
+ table: a,
305
+ api: o,
306
+ headerHeight: Vt,
307
+ totalWidth: Q,
308
+ isPrinting: s,
309
+ showExpanders: V,
310
+ expanderWidth: Y,
311
+ showCheckboxes: M,
312
+ rowSelection: h,
313
+ selectionRows: St,
314
+ selectedInScope: we,
315
+ visibleColumns: c,
316
+ definitionsById: S,
317
+ columnStyle: Ct,
318
+ widths: L
319
+ }
320
+ )
322
321
  }
323
- ),
324
- (g.length > 0 || _.length > 0) && /* @__PURE__ */ S(
322
+ ) }),
323
+ /* @__PURE__ */ C(
325
324
  "div",
326
325
  {
327
- role: "rowgroup",
328
- className: "mtx-sticky mtx-z-20",
329
- style: { top: l ? void 0 : j, position: l ? "relative" : "sticky" },
326
+ ref: g,
327
+ "data-data-table-viewport": "",
328
+ className: "mtx-relative mtx-min-h-0 mtx-flex-1 mtx-rounded-b-lg",
329
+ style: {
330
+ ...J,
331
+ overflow: xt ? "visible" : J?.overflow ?? "auto",
332
+ overflowX: s ? "visible" : Kt ? "hidden" : J?.overflowX
333
+ },
334
+ onScroll: (t) => {
335
+ const e = t.currentTarget, r = ut.current;
336
+ r && r.scrollLeft !== e.scrollLeft && (r.scrollLeft = e.scrollLeft, U.current = r.scrollLeft);
337
+ const i = x?.synchronizedScrolls.current.get(e) === e.scrollLeft;
338
+ if (x?.synchronizedScrolls.current.delete(e), x && !s && !i)
339
+ for (const l of x.viewports.current)
340
+ l !== e && l.scrollLeft !== e.scrollLeft && (l.scrollLeft = e.scrollLeft, x.synchronizedScrolls.current.set(l, l.scrollLeft));
341
+ },
330
342
  children: [
331
- _.map((t, e) => k(t, `__summary_top_${e}`, e, void 0, "top")),
332
- g.map((t) => k(t.original, t.id, t.index, t, "top"))
343
+ (p.length > 0 || P.length > 0) && /* @__PURE__ */ C(
344
+ "div",
345
+ {
346
+ role: "rowgroup",
347
+ className: "mtx-sticky mtx-z-20",
348
+ style: { top: s ? void 0 : 0, position: s ? "relative" : "sticky" },
349
+ children: [
350
+ P.map((t, e) => E(t, `__summary_top_${e}`, e, void 0, "top")),
351
+ p.map((t) => E(t.original, t.id, t.index, t, "top"))
352
+ ]
353
+ }
354
+ ),
355
+ /* @__PURE__ */ d("div", { role: "rowgroup", children: k ? /* @__PURE__ */ d("div", { style: { height: F.getTotalSize(), position: "relative", width: Q, minWidth: "100%" }, children: Rt.map((t) => {
356
+ const e = m[t.index];
357
+ return /* @__PURE__ */ d("div", { style: { position: "absolute", top: 0, width: "100%", transform: `translateY(${t.start - yt}px)` }, children: E(e.original, e.id, W.get(e.original) ?? e.index, e) }, e.id);
358
+ }) }) : m.map((t) => E(t.original, t.id, W.get(t.original) ?? t.index, t)) }),
359
+ (y.length > 0 || N.length > 0) && /* @__PURE__ */ C("div", { role: "rowgroup", className: "mtx-sticky mtx-bottom-0 mtx-z-20", style: { position: s ? "relative" : "sticky" }, children: [
360
+ y.map((t) => E(t.original, t.id, t.index, t, "bottom")),
361
+ N.map((t, e) => E(t, `__summary_bottom_${e}`, e, void 0, "bottom"))
362
+ ] }),
363
+ (A || !m.length && !p.length && !y.length) && /* @__PURE__ */ d(
364
+ "div",
365
+ {
366
+ role: "status",
367
+ className: kt(
368
+ "mtx-flex mtx-items-center mtx-justify-center mtx-p-6 mtx-text-text-300",
369
+ A && "mtx-absolute mtx-top-0 mtx-start-0 mtx-z-50 mtx-h-full mtx-w-full mtx-bg-gray-100/25"
370
+ ),
371
+ children: A ? Mt : jt
372
+ }
373
+ )
333
374
  ]
334
375
  }
335
- ),
336
- /* @__PURE__ */ m("div", { role: "rowgroup", children: C ? /* @__PURE__ */ m("div", { style: { height: $.getTotalSize(), position: "relative", width: Q, minWidth: "100%" }, children: It.map((t) => {
337
- const e = d[t.index];
338
- return /* @__PURE__ */ m(
339
- "div",
340
- {
341
- style: { position: "absolute", top: 0, width: "100%", transform: `translateY(${t.start - j - bt}px)` },
342
- children: k(e.original, e.id, F.get(e.original) ?? e.index, e)
343
- },
344
- e.id
345
- );
346
- }) }) : d.map((t) => k(t.original, t.id, F.get(t.original) ?? t.index, t)) }),
347
- (b.length > 0 || M.length > 0) && /* @__PURE__ */ S("div", { role: "rowgroup", className: "mtx-sticky mtx-bottom-0 mtx-z-20", style: { position: l ? "relative" : "sticky" }, children: [
348
- b.map((t) => k(t.original, t.id, t.index, t, "bottom")),
349
- M.map((t, e) => k(t, `__summary_bottom_${e}`, e, void 0, "bottom"))
350
- ] }),
351
- (N || !d.length && !g.length && !b.length) && /* @__PURE__ */ m(
352
- "div",
353
- {
354
- role: "status",
355
- className: Ct(
356
- "mtx-flex mtx-items-center mtx-justify-center mtx-p-6 mtx-text-text-300",
357
- N && "mtx-absolute mtx-top-0 mtx-start-0 mtx-z-50 mtx-h-full mtx-w-full mtx-bg-gray-100/25"
358
- ),
359
- children: N ? jt : Nt
360
- }
361
376
  )
362
377
  ]
363
378
  }
364
379
  ),
365
- L && !l && /* @__PURE__ */ m(Se, { table: o, paginationPageSizeSelector: Wt })
380
+ j && !s && /* @__PURE__ */ d(Pe, { table: a, paginationPageSizeSelector: Ht })
366
381
  ]
367
382
  }
368
383
  )
369
384
  ] });
370
385
  }
371
- const Ne = r.forwardRef(ze);
372
- Ne.displayName = "DataTableContent";
386
+ const je = n.forwardRef(Ne);
387
+ je.displayName = "DataTableContent";
373
388
  export {
374
- Ne as DataTableContent
389
+ je as DataTableContent
375
390
  };
376
391
  //# sourceMappingURL=datatablecontent.es.js.map