@plumile/ui 0.1.162 → 0.1.164
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.
- package/lib/esm/admin/organisms/admin_sidebar/adminSidebar.css.js +2 -0
- package/lib/esm/admin/theme/adminDensity.css.js +0 -1
- package/lib/esm/atomic/atoms/label/label.css.js +0 -1
- package/lib/esm/atomic/molecules/markdown/components/MarkdownArticleContainer.css.js +1 -0
- package/lib/esm/atomic/molecules/markdown/components/MarkdownHeading.css.js +0 -1
- package/lib/esm/backoffice/templates/list_page_template/listPageTemplate.css.js.map +1 -1
- package/lib/esm/components/data-table/DataTable.css.js +45 -45
- package/lib/esm/components/data-table/DataTable.css.js.map +1 -1
- package/lib/esm/components/data-table/DataTable.js +88 -52
- package/lib/esm/components/data-table/DataTable.js.map +1 -1
- package/lib/esm/components/data-table/VirtualizedConnectionTable.js +169 -161
- package/lib/esm/components/data-table/VirtualizedConnectionTable.js.map +1 -1
- package/lib/esm/internal/data-table/layout.js +19 -2
- package/lib/esm/internal/data-table/layout.js.map +1 -1
- package/lib/esm/style.css +1 -1
- package/lib/types/components/data-table/DataTable.css.d.ts.map +1 -1
- package/lib/types/components/data-table/DataTable.d.ts +13 -2
- package/lib/types/components/data-table/DataTable.d.ts.map +1 -1
- package/lib/types/components/data-table/VirtualizedConnectionTable.d.ts.map +1 -1
- package/lib/types/internal/data-table/layout.d.ts +5 -0
- package/lib/types/internal/data-table/layout.d.ts.map +1 -1
- package/package.json +3 -3
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { DataTableBody as e, DataTableEmptyRow as t, DataTableHeader as n, DataTableRoot as r, DataTableRow as i } from "./DataTable.js";
|
|
2
|
-
import { resolveInfiniteRootMargin as
|
|
3
|
-
import { bodyViewport as
|
|
4
|
-
import { clamp as
|
|
5
|
-
import { useCallback as
|
|
6
|
-
import { Fragment as
|
|
1
|
+
import { DataTableBody as e, DataTableEmptyRow as t, DataTableHeader as n, DataTableRoot as r, DataTableRow as i, getVisibleDataTableColumnEntries as a, getVisibleDataTableGridTemplateColumns as o, useDataTableContainerWidth as s } from "./DataTable.js";
|
|
2
|
+
import { resolveInfiniteRootMargin as ee, shouldTriggerInfiniteLoad as c } from "../../internal/infinite/infiniteLoad.js";
|
|
3
|
+
import { bodyViewport as l, sentinel as u, spacer as d } from "./VirtualizedConnectionTable.css.js";
|
|
4
|
+
import { clamp as te, computeVirtualWindowBounds as ne, isVerticallyScrollable as f, shouldTriggerVirtualizedInfiniteLoad as re } from "../../internal/data-table/virtualization.js";
|
|
5
|
+
import { useCallback as p, useEffect as m, useLayoutEffect as h, useMemo as g, useRef as _, useState as ie } from "react";
|
|
6
|
+
import { Fragment as ae, jsx as v, jsxs as y } from "react/jsx-runtime";
|
|
7
7
|
//#region src/components/data-table/VirtualizedConnectionTable.tsx
|
|
8
|
-
var
|
|
8
|
+
var oe = (e) => {
|
|
9
9
|
let t = e;
|
|
10
10
|
for (; t != null;) {
|
|
11
|
-
if (
|
|
11
|
+
if (f({
|
|
12
12
|
overflowY: window.getComputedStyle(t).overflowY,
|
|
13
13
|
scrollHeight: t.scrollHeight,
|
|
14
14
|
clientHeight: t.clientHeight
|
|
@@ -16,225 +16,233 @@ var ae = (e) => {
|
|
|
16
16
|
t = t.parentElement;
|
|
17
17
|
}
|
|
18
18
|
return null;
|
|
19
|
-
},
|
|
20
|
-
let
|
|
21
|
-
if (!
|
|
22
|
-
let e =
|
|
19
|
+
}, b = ({ columns: f, rows: b, getRowId: x, emptyState: se, className: ce, headerClassName: le, bodyClassName: ue, rowClassName: de, gridTemplateClassName: S, gridTemplateColumns: fe, kind: C, density: w, headerBehavior: pe, rowState: me, classes: T, bodyScrollMode: E = "page", bodyFooterNode: he, virtualization: D, infiniteScroll: O, hasNextPage: k = !1, isLoadingMore: A = !1, onLoadMore: j, ariaLabel: ge, ariaLabelledBy: _e }) => {
|
|
20
|
+
let M = _(null), N = _(null), P = _(null), F = _(null), I = _(null), L = _(null), R = _(null), z = _(!1), B = D?.enabled === !0, V = g(() => {
|
|
21
|
+
if (!B) return null;
|
|
22
|
+
let e = D.rowHeightPx;
|
|
23
23
|
return typeof e == "number" && Number.isFinite(e) && e > 0 ? e : 56;
|
|
24
|
-
}, [
|
|
25
|
-
if (!
|
|
26
|
-
let e = 10, t =
|
|
24
|
+
}, [B, D]), ve = g(() => {
|
|
25
|
+
if (!B) return 0;
|
|
26
|
+
let e = 10, t = D.overscan;
|
|
27
27
|
return typeof t == "number" && Number.isFinite(t) && (e = t), Math.max(0, e);
|
|
28
|
-
}, [
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
}, [B, D]), H = O?.thresholdPx ?? 800, U = O?.autoLoad ?? !0, W = O?.enabled === !0, G = E === "contained", ye = s(M), K = g(() => a(f, ye), [f, ye]), q = g(() => K.map((e) => e.column), [K]), J = g(() => o({
|
|
29
|
+
columns: f,
|
|
30
|
+
gridTemplateColumns: fe,
|
|
31
|
+
visibleColumnEntries: K
|
|
32
|
+
}), [
|
|
33
|
+
f,
|
|
34
|
+
fe,
|
|
35
|
+
K
|
|
36
|
+
]), Y = W && k && !A && j != null, X = p(() => {
|
|
37
|
+
j?.();
|
|
38
|
+
}, [j]), Z = p(() => {
|
|
39
|
+
z.current = !0, R.current != null && window.clearTimeout(R.current), R.current = window.setTimeout(() => {
|
|
40
|
+
z.current = !1, R.current = null;
|
|
33
41
|
}, 250);
|
|
34
|
-
}, []), [
|
|
42
|
+
}, []), [be, xe] = ie(() => ({
|
|
35
43
|
startIndex: 0,
|
|
36
|
-
endIndex: Math.min(
|
|
37
|
-
})),
|
|
44
|
+
endIndex: Math.min(b.length, 50)
|
|
45
|
+
})), Se = p((e, t, n) => {
|
|
38
46
|
let r = {};
|
|
39
|
-
return typeof n == "number" && (r.height = n), /* @__PURE__ */
|
|
47
|
+
return typeof n == "number" && (r.height = n), /* @__PURE__ */ v(i, {
|
|
40
48
|
row: e,
|
|
41
49
|
index: t,
|
|
42
|
-
columns:
|
|
43
|
-
getRowId:
|
|
50
|
+
columns: q,
|
|
51
|
+
getRowId: x,
|
|
44
52
|
kind: C,
|
|
45
53
|
density: w,
|
|
46
|
-
rowClassName:
|
|
47
|
-
rowState:
|
|
48
|
-
gridTemplateClassName:
|
|
49
|
-
gridTemplateColumns:
|
|
50
|
-
classes:
|
|
54
|
+
rowClassName: de,
|
|
55
|
+
rowState: me,
|
|
56
|
+
gridTemplateClassName: S,
|
|
57
|
+
gridTemplateColumns: J,
|
|
58
|
+
classes: T,
|
|
51
59
|
style: r,
|
|
52
60
|
cellMode: "singleLine"
|
|
53
|
-
},
|
|
61
|
+
}, x(e, t));
|
|
54
62
|
}, [
|
|
55
|
-
|
|
56
|
-
u,
|
|
63
|
+
T,
|
|
57
64
|
w,
|
|
58
|
-
y,
|
|
59
65
|
x,
|
|
60
66
|
S,
|
|
61
67
|
C,
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
68
|
+
de,
|
|
69
|
+
me,
|
|
70
|
+
q,
|
|
71
|
+
J
|
|
72
|
+
]), Ce = p(() => {
|
|
73
|
+
if (!B) return;
|
|
74
|
+
let e = V;
|
|
67
75
|
if (e == null) return;
|
|
68
|
-
let t =
|
|
76
|
+
let t = P.current;
|
|
69
77
|
if (t == null) return;
|
|
70
|
-
let n =
|
|
71
|
-
if (
|
|
78
|
+
let n = N.current, r = I.current, i = r?.clientHeight ?? window.innerHeight, a = 0;
|
|
79
|
+
if (G && n != null) i = n.clientHeight, a = n.scrollTop;
|
|
72
80
|
else {
|
|
73
81
|
let e = r?.getBoundingClientRect().top ?? 0, n = t.getBoundingClientRect().top - e;
|
|
74
82
|
a = Math.max(0, -n);
|
|
75
83
|
}
|
|
76
|
-
let
|
|
77
|
-
rowCount:
|
|
84
|
+
let o = a + i, s = b.length * e, ee = te(o, 0, s), { startIndex: l, endIndex: u } = ne({
|
|
85
|
+
rowCount: b.length,
|
|
78
86
|
rowHeightPx: e,
|
|
79
|
-
overscan:
|
|
87
|
+
overscan: ve,
|
|
80
88
|
visibleTop: a,
|
|
81
|
-
visibleBottom:
|
|
89
|
+
visibleBottom: o
|
|
82
90
|
});
|
|
83
|
-
|
|
84
|
-
startIndex:
|
|
85
|
-
endIndex:
|
|
86
|
-
}),
|
|
87
|
-
enabled:
|
|
88
|
-
hasNext:
|
|
89
|
-
isLoading:
|
|
90
|
-
autoLoad:
|
|
91
|
-
isCoolingDown:
|
|
92
|
-
}) &&
|
|
93
|
-
autoLoad:
|
|
94
|
-
canLoadMore:
|
|
95
|
-
totalHeight:
|
|
96
|
-
visibleBottom:
|
|
97
|
-
thresholdPx:
|
|
98
|
-
isCoolingDown:
|
|
99
|
-
}) && (
|
|
91
|
+
xe((e) => e.startIndex === l && e.endIndex === u ? e : {
|
|
92
|
+
startIndex: l,
|
|
93
|
+
endIndex: u
|
|
94
|
+
}), c({
|
|
95
|
+
enabled: W,
|
|
96
|
+
hasNext: k,
|
|
97
|
+
isLoading: A,
|
|
98
|
+
autoLoad: U,
|
|
99
|
+
isCoolingDown: z.current
|
|
100
|
+
}) && Y && re({
|
|
101
|
+
autoLoad: U,
|
|
102
|
+
canLoadMore: Y,
|
|
103
|
+
totalHeight: s,
|
|
104
|
+
visibleBottom: ee,
|
|
105
|
+
thresholdPx: H,
|
|
106
|
+
isCoolingDown: z.current
|
|
107
|
+
}) && (Z(), X());
|
|
100
108
|
}, [
|
|
109
|
+
U,
|
|
110
|
+
Y,
|
|
111
|
+
k,
|
|
101
112
|
G,
|
|
102
|
-
|
|
113
|
+
B,
|
|
114
|
+
W,
|
|
103
115
|
A,
|
|
104
|
-
|
|
116
|
+
ve,
|
|
105
117
|
V,
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
U,
|
|
118
|
+
b.length,
|
|
119
|
+
Z,
|
|
109
120
|
H,
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
]), Z = d(() => {
|
|
115
|
-
R.current ??= window.requestAnimationFrame(() => {
|
|
116
|
-
R.current = null, _e();
|
|
121
|
+
X
|
|
122
|
+
]), Q = p(() => {
|
|
123
|
+
L.current ??= window.requestAnimationFrame(() => {
|
|
124
|
+
L.current = null, Ce();
|
|
117
125
|
});
|
|
118
|
-
}, [
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
}, []),
|
|
122
|
-
if (!
|
|
123
|
-
let e =
|
|
124
|
-
e != null && (
|
|
126
|
+
}, [Ce]);
|
|
127
|
+
m(() => () => {
|
|
128
|
+
L.current != null && (window.cancelAnimationFrame(L.current), L.current = null), R.current != null && (window.clearTimeout(R.current), R.current = null);
|
|
129
|
+
}, []), h(() => {
|
|
130
|
+
if (!B) return;
|
|
131
|
+
let e = M.current;
|
|
132
|
+
e != null && (G ? I.current = N.current : I.current = oe(e), Q());
|
|
125
133
|
}, [
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
]),
|
|
130
|
-
if (!
|
|
131
|
-
let e =
|
|
132
|
-
|
|
134
|
+
G,
|
|
135
|
+
B,
|
|
136
|
+
Q
|
|
137
|
+
]), m(() => {
|
|
138
|
+
if (!B) return;
|
|
139
|
+
let e = I.current ?? window, t = () => {
|
|
140
|
+
Q();
|
|
133
141
|
};
|
|
134
142
|
return e.addEventListener("scroll", t, { passive: !0 }), window.addEventListener("resize", t), () => {
|
|
135
143
|
e.removeEventListener("scroll", t), window.removeEventListener("resize", t);
|
|
136
144
|
};
|
|
137
|
-
}, [
|
|
138
|
-
if (
|
|
139
|
-
enabled:
|
|
140
|
-
hasNext:
|
|
141
|
-
isLoading:
|
|
142
|
-
autoLoad:
|
|
145
|
+
}, [B, Q]), m(() => {
|
|
146
|
+
if (B || !c({
|
|
147
|
+
enabled: W,
|
|
148
|
+
hasNext: k,
|
|
149
|
+
isLoading: A,
|
|
150
|
+
autoLoad: U,
|
|
143
151
|
isCoolingDown: !1
|
|
144
|
-
}) || !
|
|
145
|
-
let e =
|
|
152
|
+
}) || !Y) return;
|
|
153
|
+
let e = F.current;
|
|
146
154
|
if (e == null || typeof window > "u" || typeof IntersectionObserver > "u") return;
|
|
147
|
-
let t =
|
|
155
|
+
let t = I.current, n = new IntersectionObserver((e) => {
|
|
148
156
|
let [t] = e;
|
|
149
|
-
t != null && t.isIntersecting &&
|
|
150
|
-
enabled:
|
|
151
|
-
hasNext:
|
|
152
|
-
isLoading:
|
|
153
|
-
autoLoad:
|
|
154
|
-
isCoolingDown:
|
|
155
|
-
}) && (
|
|
157
|
+
t != null && t.isIntersecting && c({
|
|
158
|
+
enabled: W,
|
|
159
|
+
hasNext: k,
|
|
160
|
+
isLoading: A,
|
|
161
|
+
autoLoad: U,
|
|
162
|
+
isCoolingDown: z.current
|
|
163
|
+
}) && (Z(), X());
|
|
156
164
|
}, {
|
|
157
165
|
root: t,
|
|
158
|
-
rootMargin:
|
|
166
|
+
rootMargin: ee({ thresholdPx: H })
|
|
159
167
|
});
|
|
160
168
|
return n.observe(e), () => {
|
|
161
169
|
n.disconnect();
|
|
162
170
|
};
|
|
163
171
|
}, [
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
K,
|
|
168
|
-
V,
|
|
169
|
-
j,
|
|
170
|
-
X,
|
|
172
|
+
U,
|
|
173
|
+
Y,
|
|
174
|
+
k,
|
|
171
175
|
W,
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
176
|
+
B,
|
|
177
|
+
A,
|
|
178
|
+
Z,
|
|
179
|
+
H,
|
|
180
|
+
X
|
|
181
|
+
]), h(() => {
|
|
182
|
+
if (B) return;
|
|
183
|
+
let e = M.current;
|
|
184
|
+
e != null && (G ? I.current = N.current : I.current = oe(e));
|
|
185
|
+
}, [G, B]);
|
|
186
|
+
let $;
|
|
187
|
+
if (b.length === 0) $ = /* @__PURE__ */ v(t, {
|
|
188
|
+
emptyState: se,
|
|
181
189
|
density: w,
|
|
182
|
-
classes:
|
|
190
|
+
classes: T
|
|
183
191
|
});
|
|
184
|
-
else if (
|
|
185
|
-
let { startIndex: e, endIndex: t } =
|
|
186
|
-
|
|
187
|
-
className:
|
|
188
|
-
ref:
|
|
192
|
+
else if (B && V != null) {
|
|
193
|
+
let { startIndex: e, endIndex: t } = be, n = e * V, r = (b.length - t) * V, i = b.slice(e, t);
|
|
194
|
+
$ = /* @__PURE__ */ y("div", {
|
|
195
|
+
className: l,
|
|
196
|
+
ref: P,
|
|
189
197
|
children: [
|
|
190
|
-
/* @__PURE__ */
|
|
191
|
-
className:
|
|
198
|
+
/* @__PURE__ */ v("div", {
|
|
199
|
+
className: d,
|
|
192
200
|
style: { height: n }
|
|
193
201
|
}),
|
|
194
|
-
i.map((t, n) =>
|
|
195
|
-
/* @__PURE__ */
|
|
196
|
-
className:
|
|
202
|
+
i.map((t, n) => Se(t, e + n, V)),
|
|
203
|
+
/* @__PURE__ */ v("div", {
|
|
204
|
+
className: d,
|
|
197
205
|
style: { height: r }
|
|
198
206
|
})
|
|
199
207
|
]
|
|
200
208
|
});
|
|
201
|
-
} else
|
|
202
|
-
let
|
|
203
|
-
return !
|
|
204
|
-
ref:
|
|
205
|
-
className:
|
|
206
|
-
})), /* @__PURE__ */
|
|
207
|
-
ref:
|
|
208
|
-
className:
|
|
209
|
+
} else $ = /* @__PURE__ */ v(ae, { children: b.map((e, t) => Se(e, t, null)) });
|
|
210
|
+
let we = null;
|
|
211
|
+
return !B && W && U && (we = /* @__PURE__ */ v("div", {
|
|
212
|
+
ref: F,
|
|
213
|
+
className: u
|
|
214
|
+
})), /* @__PURE__ */ y(r, {
|
|
215
|
+
ref: M,
|
|
216
|
+
className: ce,
|
|
209
217
|
kind: C,
|
|
210
|
-
bodyScrollMode:
|
|
211
|
-
classes:
|
|
212
|
-
ariaLabel:
|
|
213
|
-
ariaLabelledBy:
|
|
214
|
-
children: [/* @__PURE__ */
|
|
215
|
-
columns:
|
|
218
|
+
bodyScrollMode: E,
|
|
219
|
+
classes: T,
|
|
220
|
+
ariaLabel: ge,
|
|
221
|
+
ariaLabelledBy: _e,
|
|
222
|
+
children: [/* @__PURE__ */ v(n, {
|
|
223
|
+
columns: q,
|
|
216
224
|
kind: C,
|
|
217
225
|
density: w,
|
|
218
|
-
headerBehavior:
|
|
219
|
-
headerClassName:
|
|
220
|
-
gridTemplateClassName:
|
|
221
|
-
gridTemplateColumns:
|
|
222
|
-
classes:
|
|
223
|
-
}), /* @__PURE__ */
|
|
224
|
-
ref:
|
|
225
|
-
className:
|
|
226
|
+
headerBehavior: pe,
|
|
227
|
+
headerClassName: le,
|
|
228
|
+
gridTemplateClassName: S,
|
|
229
|
+
gridTemplateColumns: J,
|
|
230
|
+
classes: T
|
|
231
|
+
}), /* @__PURE__ */ y(e, {
|
|
232
|
+
ref: N,
|
|
233
|
+
className: ue,
|
|
226
234
|
kind: C,
|
|
227
|
-
bodyScrollMode:
|
|
228
|
-
classes:
|
|
235
|
+
bodyScrollMode: E,
|
|
236
|
+
classes: T,
|
|
229
237
|
children: [
|
|
230
|
-
Q,
|
|
231
238
|
$,
|
|
232
|
-
|
|
239
|
+
we,
|
|
240
|
+
he
|
|
233
241
|
]
|
|
234
242
|
})]
|
|
235
243
|
});
|
|
236
244
|
};
|
|
237
245
|
//#endregion
|
|
238
|
-
export {
|
|
246
|
+
export { b as VirtualizedConnectionTable };
|
|
239
247
|
|
|
240
248
|
//# sourceMappingURL=VirtualizedConnectionTable.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VirtualizedConnectionTable.js","names":[],"sources":["../../../../src/components/data-table/VirtualizedConnectionTable.tsx"],"sourcesContent":["import {\n useCallback,\n useEffect,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n type CSSProperties,\n type JSX,\n type ReactNode,\n} from 'react';\n\nimport {\n DataTableBody,\n DataTableEmptyRow,\n DataTableHeader,\n DataTableRoot,\n DataTableRow,\n type DataTableBodyScrollMode,\n type DataTableColumn,\n type DataTableDensity,\n type DataTableHeaderBehavior,\n type DataTableKind,\n type DataTableRowState,\n type DataTableSlot,\n type GetRowId,\n} from './DataTable.js';\nimport * as styles from './VirtualizedConnectionTable.css.js';\n\nimport {\n clamp,\n computeVirtualWindowBounds,\n isVerticallyScrollable,\n shouldTriggerVirtualizedInfiniteLoad,\n type VirtualWindow,\n} from '../../internal/data-table/virtualization.js';\nimport {\n resolveInfiniteRootMargin,\n shouldTriggerInfiniteLoad,\n} from '../../internal/infinite/infiniteLoad.js';\nimport type { SlotClasses } from '../../styles/slots.js';\n\nexport type VirtualizationConfig = {\n enabled: boolean;\n rowHeightPx: number;\n overscan: number;\n};\n\nexport type InfiniteScrollConfig = {\n enabled: boolean;\n thresholdPx?: number;\n autoLoad?: boolean;\n};\n\nexport type VirtualizedConnectionTableProps<Row> = {\n columns: readonly DataTableColumn<Row>[];\n rows: readonly Row[];\n getRowId: GetRowId<Row>;\n emptyState?: JSX.Element;\n className?: string;\n headerClassName?: string;\n bodyClassName?: string;\n rowClassName?: (row: Row, index: number) => string | null | undefined;\n gridTemplateClassName?: string;\n gridTemplateColumns?: string;\n kind?: DataTableKind;\n density?: DataTableDensity;\n headerBehavior?: DataTableHeaderBehavior;\n rowState?: (row: Row, index: number) => DataTableRowState;\n classes?: SlotClasses<DataTableSlot>;\n bodyScrollMode?: DataTableBodyScrollMode;\n bodyFooterNode?: ReactNode;\n\n virtualization?: VirtualizationConfig;\n\n infiniteScroll?: InfiniteScrollConfig;\n hasNextPage?: boolean;\n isLoadingMore?: boolean;\n onLoadMore?: () => void;\n ariaLabel?: string;\n ariaLabelledBy?: string;\n};\n\nconst findScrollParent = (el: HTMLElement | null): HTMLElement | null => {\n let current: HTMLElement | null = el;\n while (current != null) {\n const style = window.getComputedStyle(current);\n if (\n isVerticallyScrollable({\n overflowY: style.overflowY,\n scrollHeight: current.scrollHeight,\n clientHeight: current.clientHeight,\n })\n ) {\n return current;\n }\n current = current.parentElement;\n }\n return null;\n};\n\nexport const VirtualizedConnectionTable = <Row,>({\n columns,\n rows,\n getRowId,\n emptyState,\n className,\n headerClassName,\n bodyClassName,\n rowClassName,\n gridTemplateClassName,\n gridTemplateColumns,\n kind,\n density,\n headerBehavior,\n rowState,\n classes,\n bodyScrollMode = 'page',\n bodyFooterNode,\n virtualization,\n infiniteScroll,\n hasNextPage = false,\n isLoadingMore = false,\n onLoadMore,\n ariaLabel,\n ariaLabelledBy,\n}: VirtualizedConnectionTableProps<Row>): JSX.Element => {\n const containerRef = useRef<HTMLDivElement>(null);\n const bodyScrollerRef = useRef<HTMLDivElement>(null);\n const bodyRef = useRef<HTMLDivElement>(null);\n const sentinelRef = useRef<HTMLDivElement>(null);\n const scrollParentRef = useRef<HTMLElement | null>(null);\n const rafRef = useRef<number | null>(null);\n const cooldownTimeoutRef = useRef<number | null>(null);\n const loadMoreCooldownRef = useRef(false);\n\n const isVirtualized = virtualization?.enabled === true;\n const rowHeightPx = useMemo(() => {\n if (!isVirtualized) {\n return null;\n }\n\n const configuredRowHeight = virtualization.rowHeightPx;\n if (\n typeof configuredRowHeight === 'number' &&\n Number.isFinite(configuredRowHeight) &&\n configuredRowHeight > 0\n ) {\n return configuredRowHeight;\n }\n\n return 56;\n }, [isVirtualized, virtualization]);\n\n const overscan = useMemo(() => {\n if (!isVirtualized) {\n return 0;\n }\n\n let nextOverscan = 10;\n const configuredOverscan = virtualization.overscan;\n if (\n typeof configuredOverscan === 'number' &&\n Number.isFinite(configuredOverscan)\n ) {\n nextOverscan = configuredOverscan;\n }\n return Math.max(0, nextOverscan);\n }, [isVirtualized, virtualization]);\n\n const thresholdPx = infiniteScroll?.thresholdPx ?? 800;\n const autoLoad = infiniteScroll?.autoLoad ?? true;\n const infiniteEnabled = infiniteScroll?.enabled === true;\n const hasContainedBodyScroll = bodyScrollMode === 'contained';\n\n const canLoadMore =\n infiniteEnabled && hasNextPage && !isLoadingMore && onLoadMore != null;\n\n const triggerLoadMore = useCallback(() => {\n if (onLoadMore == null) {\n return;\n }\n onLoadMore();\n }, [onLoadMore]);\n\n const startLoadMoreCooldown = useCallback(() => {\n loadMoreCooldownRef.current = true;\n if (cooldownTimeoutRef.current != null) {\n window.clearTimeout(cooldownTimeoutRef.current);\n }\n cooldownTimeoutRef.current = window.setTimeout(() => {\n loadMoreCooldownRef.current = false;\n cooldownTimeoutRef.current = null;\n }, 250);\n }, []);\n\n const [windowState, setWindowState] = useState<VirtualWindow>(() => {\n return { startIndex: 0, endIndex: Math.min(rows.length, 50) };\n });\n\n const renderRow = useCallback(\n (row: Row, index: number, heightPx?: number | null): JSX.Element => {\n const rowStyle: CSSProperties = {};\n if (typeof heightPx === 'number') {\n rowStyle.height = heightPx;\n }\n return (\n <DataTableRow\n key={getRowId(row, index)}\n row={row}\n index={index}\n columns={columns}\n getRowId={getRowId}\n kind={kind}\n density={density}\n rowClassName={rowClassName}\n rowState={rowState}\n gridTemplateClassName={gridTemplateClassName}\n gridTemplateColumns={gridTemplateColumns}\n classes={classes}\n style={rowStyle}\n cellMode=\"singleLine\"\n />\n );\n },\n [\n classes,\n columns,\n density,\n getRowId,\n gridTemplateClassName,\n gridTemplateColumns,\n kind,\n rowClassName,\n rowState,\n ],\n );\n\n const computeVirtualWindow = useCallback(() => {\n if (!isVirtualized) {\n return;\n }\n const height = rowHeightPx;\n if (height == null) {\n return;\n }\n const bodyEl = bodyRef.current;\n if (bodyEl == null) {\n return;\n }\n\n const bodyScroller = bodyScrollerRef.current;\n const scrollParent = scrollParentRef.current;\n let viewportHeight = scrollParent?.clientHeight ?? window.innerHeight;\n let visibleTop = 0;\n if (hasContainedBodyScroll && bodyScroller != null) {\n viewportHeight = bodyScroller.clientHeight;\n visibleTop = bodyScroller.scrollTop;\n } else {\n const parentRectTop = scrollParent?.getBoundingClientRect().top ?? 0;\n const bodyRectTop = bodyEl.getBoundingClientRect().top;\n const relativeTop = bodyRectTop - parentRectTop;\n visibleTop = Math.max(0, -relativeTop);\n }\n const visibleBottom = visibleTop + viewportHeight;\n\n const totalHeight = rows.length * height;\n const clampedBottom = clamp(visibleBottom, 0, totalHeight);\n const { startIndex, endIndex } = computeVirtualWindowBounds({\n rowCount: rows.length,\n rowHeightPx: height,\n overscan,\n visibleTop,\n visibleBottom,\n });\n\n setWindowState((prev) => {\n if (prev.startIndex === startIndex && prev.endIndex === endIndex) {\n return prev;\n }\n return { startIndex, endIndex };\n });\n\n if (\n shouldTriggerInfiniteLoad({\n enabled: infiniteEnabled,\n hasNext: hasNextPage,\n isLoading: isLoadingMore,\n autoLoad,\n isCoolingDown: loadMoreCooldownRef.current,\n }) &&\n canLoadMore &&\n shouldTriggerVirtualizedInfiniteLoad({\n autoLoad,\n canLoadMore,\n totalHeight,\n visibleBottom: clampedBottom,\n thresholdPx,\n isCoolingDown: loadMoreCooldownRef.current,\n })\n ) {\n startLoadMoreCooldown();\n triggerLoadMore();\n }\n }, [\n autoLoad,\n canLoadMore,\n hasNextPage,\n hasContainedBodyScroll,\n isVirtualized,\n infiniteEnabled,\n isLoadingMore,\n overscan,\n rowHeightPx,\n rows.length,\n startLoadMoreCooldown,\n thresholdPx,\n triggerLoadMore,\n ]);\n\n const scheduleCompute = useCallback(() => {\n if (rafRef.current != null) {\n return;\n }\n rafRef.current = window.requestAnimationFrame(() => {\n rafRef.current = null;\n computeVirtualWindow();\n });\n }, [computeVirtualWindow]);\n\n useEffect(() => {\n return () => {\n if (rafRef.current != null) {\n window.cancelAnimationFrame(rafRef.current);\n rafRef.current = null;\n }\n if (cooldownTimeoutRef.current != null) {\n window.clearTimeout(cooldownTimeoutRef.current);\n cooldownTimeoutRef.current = null;\n }\n };\n }, []);\n\n useLayoutEffect(() => {\n if (!isVirtualized) {\n return;\n }\n const container = containerRef.current;\n if (container == null) {\n return;\n }\n if (hasContainedBodyScroll) {\n scrollParentRef.current = bodyScrollerRef.current;\n } else {\n scrollParentRef.current = findScrollParent(container);\n }\n scheduleCompute();\n }, [hasContainedBodyScroll, isVirtualized, scheduleCompute]);\n\n useEffect(() => {\n if (!isVirtualized) {\n return undefined;\n }\n const scrollParent = scrollParentRef.current;\n const target: HTMLElement | Window = scrollParent ?? window;\n\n const handler = () => {\n scheduleCompute();\n };\n\n target.addEventListener('scroll', handler, { passive: true });\n window.addEventListener('resize', handler);\n\n return () => {\n target.removeEventListener('scroll', handler);\n window.removeEventListener('resize', handler);\n };\n }, [isVirtualized, scheduleCompute]);\n\n useEffect(() => {\n if (isVirtualized) {\n return undefined;\n }\n if (\n !shouldTriggerInfiniteLoad({\n enabled: infiniteEnabled,\n hasNext: hasNextPage,\n isLoading: isLoadingMore,\n autoLoad,\n isCoolingDown: false,\n }) ||\n !canLoadMore\n ) {\n return undefined;\n }\n const sentinel = sentinelRef.current;\n if (sentinel == null) {\n return undefined;\n }\n if (\n typeof window === 'undefined' ||\n typeof IntersectionObserver === 'undefined'\n ) {\n return undefined;\n }\n\n const scrollParent = scrollParentRef.current;\n\n const observer = new IntersectionObserver(\n (entries) => {\n const [entry] = entries;\n if (entry == null) {\n return;\n }\n\n if (\n entry.isIntersecting &&\n shouldTriggerInfiniteLoad({\n enabled: infiniteEnabled,\n hasNext: hasNextPage,\n isLoading: isLoadingMore,\n autoLoad,\n isCoolingDown: loadMoreCooldownRef.current,\n })\n ) {\n startLoadMoreCooldown();\n triggerLoadMore();\n }\n },\n {\n root: scrollParent,\n rootMargin: resolveInfiniteRootMargin({ thresholdPx }),\n },\n );\n\n observer.observe(sentinel);\n return () => {\n observer.disconnect();\n };\n }, [\n autoLoad,\n canLoadMore,\n hasNextPage,\n infiniteEnabled,\n isVirtualized,\n isLoadingMore,\n startLoadMoreCooldown,\n thresholdPx,\n triggerLoadMore,\n ]);\n\n useLayoutEffect(() => {\n if (isVirtualized) {\n return;\n }\n const container = containerRef.current;\n if (container == null) {\n return;\n }\n if (hasContainedBodyScroll) {\n scrollParentRef.current = bodyScrollerRef.current;\n } else {\n scrollParentRef.current = findScrollParent(container);\n }\n }, [hasContainedBodyScroll, isVirtualized]);\n\n let bodyRows: JSX.Element;\n if (rows.length === 0) {\n bodyRows = (\n <DataTableEmptyRow\n emptyState={emptyState}\n density={density}\n classes={classes}\n />\n );\n } else if (isVirtualized && rowHeightPx != null) {\n const { startIndex, endIndex } = windowState;\n const topSpacerHeight = startIndex * rowHeightPx;\n const bottomSpacerHeight = (rows.length - endIndex) * rowHeightPx;\n const slice = rows.slice(startIndex, endIndex);\n bodyRows = (\n <div className={styles.bodyViewport} ref={bodyRef}>\n <div className={styles.spacer} style={{ height: topSpacerHeight }} />\n {slice.map((row, sliceIndex) => {\n const absoluteIndex = startIndex + sliceIndex;\n return renderRow(row, absoluteIndex, rowHeightPx);\n })}\n <div className={styles.spacer} style={{ height: bottomSpacerHeight }} />\n </div>\n );\n } else {\n bodyRows = (\n <>\n {rows.map((row, index) => {\n return renderRow(row, index, null);\n })}\n </>\n );\n }\n\n let sentinelNode: JSX.Element | null = null;\n if (!isVirtualized && infiniteEnabled && autoLoad) {\n sentinelNode = <div ref={sentinelRef} className={styles.sentinel} />;\n }\n\n return (\n <DataTableRoot\n ref={containerRef}\n className={className}\n kind={kind}\n bodyScrollMode={bodyScrollMode}\n classes={classes}\n ariaLabel={ariaLabel}\n ariaLabelledBy={ariaLabelledBy}\n >\n <DataTableHeader\n columns={columns}\n kind={kind}\n density={density}\n headerBehavior={headerBehavior}\n headerClassName={headerClassName}\n gridTemplateClassName={gridTemplateClassName}\n gridTemplateColumns={gridTemplateColumns}\n classes={classes}\n />\n <DataTableBody\n ref={bodyScrollerRef}\n className={bodyClassName}\n kind={kind}\n bodyScrollMode={bodyScrollMode}\n classes={classes}\n >\n {bodyRows}\n {sentinelNode}\n {bodyFooterNode}\n </DataTableBody>\n </DataTableRoot>\n );\n};\n"],"mappings":";;;;;;;AAmFA,IAAM,MAAoB,MAA+C;CACvE,IAAI,IAA8B;CAClC,OAAO,KAAW,OAAM;EAEtB,IACE,EAAuB;GACrB,WAHU,OAAO,iBAAiB,CAGv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AAK,KAAK,GAAK,MACP,GAAU,GAAK,GAAO,IAAI,CAClC,EACD,CAAA;CAIN,IAAI,IAAmC;CAKvC,OAJI,CAAC,KAAiB,KAAmB,MACvC,IAAe,kBAAC,OAAD;EAAK,KAAK;EAAa,WAAW;CAAkB,CAAA,IAInE,kBAAC,GAAD;EACE,KAAK;EACM;EACL;EACU;EACP;EACE;EACK;YAPlB,CASE,kBAAC,GAAD;GACW;GACH;GACG;GACO;GACC;GACM;GACF;GACZ;EACV,CAAA,GACD,kBAAC,GAAD;GACE,KAAK;GACL,WAAW;GACL;GACU;GACP;aALX;IAOG;IACA;IACA;GACY;IACF;;AAEnB"}
|
|
1
|
+
{"version":3,"file":"VirtualizedConnectionTable.js","names":[],"sources":["../../../../src/components/data-table/VirtualizedConnectionTable.tsx"],"sourcesContent":["import {\n useCallback,\n useEffect,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n type CSSProperties,\n type JSX,\n type ReactNode,\n} from 'react';\n\nimport {\n DataTableBody,\n DataTableEmptyRow,\n DataTableHeader,\n DataTableRoot,\n DataTableRow,\n getVisibleDataTableColumnEntries,\n getVisibleDataTableGridTemplateColumns,\n type DataTableBodyScrollMode,\n type DataTableColumn,\n type DataTableDensity,\n type DataTableHeaderBehavior,\n type DataTableKind,\n type DataTableRowState,\n type DataTableSlot,\n type GetRowId,\n useDataTableContainerWidth,\n} from './DataTable.js';\nimport * as styles from './VirtualizedConnectionTable.css.js';\n\nimport {\n clamp,\n computeVirtualWindowBounds,\n isVerticallyScrollable,\n shouldTriggerVirtualizedInfiniteLoad,\n type VirtualWindow,\n} from '../../internal/data-table/virtualization.js';\nimport {\n resolveInfiniteRootMargin,\n shouldTriggerInfiniteLoad,\n} from '../../internal/infinite/infiniteLoad.js';\nimport type { SlotClasses } from '../../styles/slots.js';\n\nexport type VirtualizationConfig = {\n enabled: boolean;\n rowHeightPx: number;\n overscan: number;\n};\n\nexport type InfiniteScrollConfig = {\n enabled: boolean;\n thresholdPx?: number;\n autoLoad?: boolean;\n};\n\nexport type VirtualizedConnectionTableProps<Row> = {\n columns: readonly DataTableColumn<Row>[];\n rows: readonly Row[];\n getRowId: GetRowId<Row>;\n emptyState?: JSX.Element;\n className?: string;\n headerClassName?: string;\n bodyClassName?: string;\n rowClassName?: (row: Row, index: number) => string | null | undefined;\n gridTemplateClassName?: string;\n gridTemplateColumns?: string;\n kind?: DataTableKind;\n density?: DataTableDensity;\n headerBehavior?: DataTableHeaderBehavior;\n rowState?: (row: Row, index: number) => DataTableRowState;\n classes?: SlotClasses<DataTableSlot>;\n bodyScrollMode?: DataTableBodyScrollMode;\n bodyFooterNode?: ReactNode;\n\n virtualization?: VirtualizationConfig;\n\n infiniteScroll?: InfiniteScrollConfig;\n hasNextPage?: boolean;\n isLoadingMore?: boolean;\n onLoadMore?: () => void;\n ariaLabel?: string;\n ariaLabelledBy?: string;\n};\n\nconst findScrollParent = (el: HTMLElement | null): HTMLElement | null => {\n let current: HTMLElement | null = el;\n while (current != null) {\n const style = window.getComputedStyle(current);\n if (\n isVerticallyScrollable({\n overflowY: style.overflowY,\n scrollHeight: current.scrollHeight,\n clientHeight: current.clientHeight,\n })\n ) {\n return current;\n }\n current = current.parentElement;\n }\n return null;\n};\n\nexport const VirtualizedConnectionTable = <Row,>({\n columns,\n rows,\n getRowId,\n emptyState,\n className,\n headerClassName,\n bodyClassName,\n rowClassName,\n gridTemplateClassName,\n gridTemplateColumns,\n kind,\n density,\n headerBehavior,\n rowState,\n classes,\n bodyScrollMode = 'page',\n bodyFooterNode,\n virtualization,\n infiniteScroll,\n hasNextPage = false,\n isLoadingMore = false,\n onLoadMore,\n ariaLabel,\n ariaLabelledBy,\n}: VirtualizedConnectionTableProps<Row>): JSX.Element => {\n const containerRef = useRef<HTMLDivElement>(null);\n const bodyScrollerRef = useRef<HTMLDivElement>(null);\n const bodyRef = useRef<HTMLDivElement>(null);\n const sentinelRef = useRef<HTMLDivElement>(null);\n const scrollParentRef = useRef<HTMLElement | null>(null);\n const rafRef = useRef<number | null>(null);\n const cooldownTimeoutRef = useRef<number | null>(null);\n const loadMoreCooldownRef = useRef(false);\n\n const isVirtualized = virtualization?.enabled === true;\n const rowHeightPx = useMemo(() => {\n if (!isVirtualized) {\n return null;\n }\n\n const configuredRowHeight = virtualization.rowHeightPx;\n if (\n typeof configuredRowHeight === 'number' &&\n Number.isFinite(configuredRowHeight) &&\n configuredRowHeight > 0\n ) {\n return configuredRowHeight;\n }\n\n return 56;\n }, [isVirtualized, virtualization]);\n\n const overscan = useMemo(() => {\n if (!isVirtualized) {\n return 0;\n }\n\n let nextOverscan = 10;\n const configuredOverscan = virtualization.overscan;\n if (\n typeof configuredOverscan === 'number' &&\n Number.isFinite(configuredOverscan)\n ) {\n nextOverscan = configuredOverscan;\n }\n return Math.max(0, nextOverscan);\n }, [isVirtualized, virtualization]);\n\n const thresholdPx = infiniteScroll?.thresholdPx ?? 800;\n const autoLoad = infiniteScroll?.autoLoad ?? true;\n const infiniteEnabled = infiniteScroll?.enabled === true;\n const hasContainedBodyScroll = bodyScrollMode === 'contained';\n const containerWidth = useDataTableContainerWidth(containerRef);\n const visibleColumnEntries = useMemo(() => {\n return getVisibleDataTableColumnEntries(columns, containerWidth);\n }, [columns, containerWidth]);\n const visibleColumns = useMemo(() => {\n return visibleColumnEntries.map((entry) => {\n return entry.column;\n });\n }, [visibleColumnEntries]);\n const visibleGridTemplateColumns = useMemo(() => {\n return getVisibleDataTableGridTemplateColumns({\n columns,\n gridTemplateColumns,\n visibleColumnEntries,\n });\n }, [columns, gridTemplateColumns, visibleColumnEntries]);\n\n const canLoadMore =\n infiniteEnabled && hasNextPage && !isLoadingMore && onLoadMore != null;\n\n const triggerLoadMore = useCallback(() => {\n if (onLoadMore == null) {\n return;\n }\n onLoadMore();\n }, [onLoadMore]);\n\n const startLoadMoreCooldown = useCallback(() => {\n loadMoreCooldownRef.current = true;\n if (cooldownTimeoutRef.current != null) {\n window.clearTimeout(cooldownTimeoutRef.current);\n }\n cooldownTimeoutRef.current = window.setTimeout(() => {\n loadMoreCooldownRef.current = false;\n cooldownTimeoutRef.current = null;\n }, 250);\n }, []);\n\n const [windowState, setWindowState] = useState<VirtualWindow>(() => {\n return { startIndex: 0, endIndex: Math.min(rows.length, 50) };\n });\n\n const renderRow = useCallback(\n (row: Row, index: number, heightPx?: number | null): JSX.Element => {\n const rowStyle: CSSProperties = {};\n if (typeof heightPx === 'number') {\n rowStyle.height = heightPx;\n }\n return (\n <DataTableRow\n key={getRowId(row, index)}\n row={row}\n index={index}\n columns={visibleColumns}\n getRowId={getRowId}\n kind={kind}\n density={density}\n rowClassName={rowClassName}\n rowState={rowState}\n gridTemplateClassName={gridTemplateClassName}\n gridTemplateColumns={visibleGridTemplateColumns}\n classes={classes}\n style={rowStyle}\n cellMode=\"singleLine\"\n />\n );\n },\n [\n classes,\n density,\n getRowId,\n gridTemplateClassName,\n kind,\n rowClassName,\n rowState,\n visibleColumns,\n visibleGridTemplateColumns,\n ],\n );\n\n const computeVirtualWindow = useCallback(() => {\n if (!isVirtualized) {\n return;\n }\n const height = rowHeightPx;\n if (height == null) {\n return;\n }\n const bodyEl = bodyRef.current;\n if (bodyEl == null) {\n return;\n }\n\n const bodyScroller = bodyScrollerRef.current;\n const scrollParent = scrollParentRef.current;\n let viewportHeight = scrollParent?.clientHeight ?? window.innerHeight;\n let visibleTop = 0;\n if (hasContainedBodyScroll && bodyScroller != null) {\n viewportHeight = bodyScroller.clientHeight;\n visibleTop = bodyScroller.scrollTop;\n } else {\n const parentRectTop = scrollParent?.getBoundingClientRect().top ?? 0;\n const bodyRectTop = bodyEl.getBoundingClientRect().top;\n const relativeTop = bodyRectTop - parentRectTop;\n visibleTop = Math.max(0, -relativeTop);\n }\n const visibleBottom = visibleTop + viewportHeight;\n\n const totalHeight = rows.length * height;\n const clampedBottom = clamp(visibleBottom, 0, totalHeight);\n const { startIndex, endIndex } = computeVirtualWindowBounds({\n rowCount: rows.length,\n rowHeightPx: height,\n overscan,\n visibleTop,\n visibleBottom,\n });\n\n setWindowState((prev) => {\n if (prev.startIndex === startIndex && prev.endIndex === endIndex) {\n return prev;\n }\n return { startIndex, endIndex };\n });\n\n if (\n shouldTriggerInfiniteLoad({\n enabled: infiniteEnabled,\n hasNext: hasNextPage,\n isLoading: isLoadingMore,\n autoLoad,\n isCoolingDown: loadMoreCooldownRef.current,\n }) &&\n canLoadMore &&\n shouldTriggerVirtualizedInfiniteLoad({\n autoLoad,\n canLoadMore,\n totalHeight,\n visibleBottom: clampedBottom,\n thresholdPx,\n isCoolingDown: loadMoreCooldownRef.current,\n })\n ) {\n startLoadMoreCooldown();\n triggerLoadMore();\n }\n }, [\n autoLoad,\n canLoadMore,\n hasNextPage,\n hasContainedBodyScroll,\n isVirtualized,\n infiniteEnabled,\n isLoadingMore,\n overscan,\n rowHeightPx,\n rows.length,\n startLoadMoreCooldown,\n thresholdPx,\n triggerLoadMore,\n ]);\n\n const scheduleCompute = useCallback(() => {\n if (rafRef.current != null) {\n return;\n }\n rafRef.current = window.requestAnimationFrame(() => {\n rafRef.current = null;\n computeVirtualWindow();\n });\n }, [computeVirtualWindow]);\n\n useEffect(() => {\n return () => {\n if (rafRef.current != null) {\n window.cancelAnimationFrame(rafRef.current);\n rafRef.current = null;\n }\n if (cooldownTimeoutRef.current != null) {\n window.clearTimeout(cooldownTimeoutRef.current);\n cooldownTimeoutRef.current = null;\n }\n };\n }, []);\n\n useLayoutEffect(() => {\n if (!isVirtualized) {\n return;\n }\n const container = containerRef.current;\n if (container == null) {\n return;\n }\n if (hasContainedBodyScroll) {\n scrollParentRef.current = bodyScrollerRef.current;\n } else {\n scrollParentRef.current = findScrollParent(container);\n }\n scheduleCompute();\n }, [hasContainedBodyScroll, isVirtualized, scheduleCompute]);\n\n useEffect(() => {\n if (!isVirtualized) {\n return undefined;\n }\n const scrollParent = scrollParentRef.current;\n const target: HTMLElement | Window = scrollParent ?? window;\n\n const handler = () => {\n scheduleCompute();\n };\n\n target.addEventListener('scroll', handler, { passive: true });\n window.addEventListener('resize', handler);\n\n return () => {\n target.removeEventListener('scroll', handler);\n window.removeEventListener('resize', handler);\n };\n }, [isVirtualized, scheduleCompute]);\n\n useEffect(() => {\n if (isVirtualized) {\n return undefined;\n }\n if (\n !shouldTriggerInfiniteLoad({\n enabled: infiniteEnabled,\n hasNext: hasNextPage,\n isLoading: isLoadingMore,\n autoLoad,\n isCoolingDown: false,\n }) ||\n !canLoadMore\n ) {\n return undefined;\n }\n const sentinel = sentinelRef.current;\n if (sentinel == null) {\n return undefined;\n }\n if (\n typeof window === 'undefined' ||\n typeof IntersectionObserver === 'undefined'\n ) {\n return undefined;\n }\n\n const scrollParent = scrollParentRef.current;\n\n const observer = new IntersectionObserver(\n (entries) => {\n const [entry] = entries;\n if (entry == null) {\n return;\n }\n\n if (\n entry.isIntersecting &&\n shouldTriggerInfiniteLoad({\n enabled: infiniteEnabled,\n hasNext: hasNextPage,\n isLoading: isLoadingMore,\n autoLoad,\n isCoolingDown: loadMoreCooldownRef.current,\n })\n ) {\n startLoadMoreCooldown();\n triggerLoadMore();\n }\n },\n {\n root: scrollParent,\n rootMargin: resolveInfiniteRootMargin({ thresholdPx }),\n },\n );\n\n observer.observe(sentinel);\n return () => {\n observer.disconnect();\n };\n }, [\n autoLoad,\n canLoadMore,\n hasNextPage,\n infiniteEnabled,\n isVirtualized,\n isLoadingMore,\n startLoadMoreCooldown,\n thresholdPx,\n triggerLoadMore,\n ]);\n\n useLayoutEffect(() => {\n if (isVirtualized) {\n return;\n }\n const container = containerRef.current;\n if (container == null) {\n return;\n }\n if (hasContainedBodyScroll) {\n scrollParentRef.current = bodyScrollerRef.current;\n } else {\n scrollParentRef.current = findScrollParent(container);\n }\n }, [hasContainedBodyScroll, isVirtualized]);\n\n let bodyRows: JSX.Element;\n if (rows.length === 0) {\n bodyRows = (\n <DataTableEmptyRow\n emptyState={emptyState}\n density={density}\n classes={classes}\n />\n );\n } else if (isVirtualized && rowHeightPx != null) {\n const { startIndex, endIndex } = windowState;\n const topSpacerHeight = startIndex * rowHeightPx;\n const bottomSpacerHeight = (rows.length - endIndex) * rowHeightPx;\n const slice = rows.slice(startIndex, endIndex);\n bodyRows = (\n <div className={styles.bodyViewport} ref={bodyRef}>\n <div className={styles.spacer} style={{ height: topSpacerHeight }} />\n {slice.map((row, sliceIndex) => {\n const absoluteIndex = startIndex + sliceIndex;\n return renderRow(row, absoluteIndex, rowHeightPx);\n })}\n <div className={styles.spacer} style={{ height: bottomSpacerHeight }} />\n </div>\n );\n } else {\n bodyRows = (\n <>\n {rows.map((row, index) => {\n return renderRow(row, index, null);\n })}\n </>\n );\n }\n\n let sentinelNode: JSX.Element | null = null;\n if (!isVirtualized && infiniteEnabled && autoLoad) {\n sentinelNode = <div ref={sentinelRef} className={styles.sentinel} />;\n }\n\n return (\n <DataTableRoot\n ref={containerRef}\n className={className}\n kind={kind}\n bodyScrollMode={bodyScrollMode}\n classes={classes}\n ariaLabel={ariaLabel}\n ariaLabelledBy={ariaLabelledBy}\n >\n <DataTableHeader\n columns={visibleColumns}\n kind={kind}\n density={density}\n headerBehavior={headerBehavior}\n headerClassName={headerClassName}\n gridTemplateClassName={gridTemplateClassName}\n gridTemplateColumns={visibleGridTemplateColumns}\n classes={classes}\n />\n <DataTableBody\n ref={bodyScrollerRef}\n className={bodyClassName}\n kind={kind}\n bodyScrollMode={bodyScrollMode}\n classes={classes}\n >\n {bodyRows}\n {sentinelNode}\n {bodyFooterNode}\n </DataTableBody>\n </DataTableRoot>\n );\n};\n"],"mappings":";;;;;;;AAsFA,IAAM,MAAoB,MAA+C;CACvE,IAAI,IAA8B;CAClC,OAAO,KAAW,OAAM;EAEtB,IACE,EAAuB;GACrB,WAHU,OAAO,iBAAiB,CAGvB,EAAM;GACjB,cAAc,EAAQ;GACtB,cAAc,EAAQ;EACxB,CAAC,GAED,OAAO;EAET,IAAU,EAAQ;CACpB;CACA,OAAO;AACT,GAEa,KAAoC,EAC/C,YACA,SACA,aACA,gBACA,eACA,q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IACD,kBAAC,OAAD;KAAK,WAAW;KAAe,OAAO,EAAE,QAAQ,EAAmB;IAAI,CAAA;GACpE;;CAET,OACE,IACE,kBAAA,IAAA,EAAA,UACG,EAAK,KAAK,GAAK,MACP,GAAU,GAAK,GAAO,IAAI,CAClC,EACD,CAAA;CAIN,IAAI,KAAmC;CAKvC,OAJI,CAAC,KAAiB,KAAmB,MACvC,KAAe,kBAAC,OAAD;EAAK,KAAK;EAAa,WAAW;CAAkB,CAAA,IAInE,kBAAC,GAAD;EACE,KAAK;EACM;EACL;EACU;EACP;EACE;EACK;YAPlB,CASE,kBAAC,GAAD;GACE,SAAS;GACH;GACG;GACO;GACC;GACM;GACvB,qBAAqB;GACZ;EACV,CAAA,GACD,kBAAC,GAAD;GACE,KAAK;GACL,WAAW;GACL;GACU;GACP;aALX;IAOG;IACA;IACA;GACY;IACF;;AAEnB"}
|
|
@@ -1,6 +1,23 @@
|
|
|
1
1
|
//#region src/internal/data-table/layout.ts
|
|
2
|
-
var e = "minmax(0, 1fr)", t = (
|
|
2
|
+
var e = "minmax(0, 1fr)", t = (e) => {
|
|
3
|
+
let t = [], n = 0, r = 0;
|
|
4
|
+
for (let i = 0; i < e.length; i += 1) {
|
|
5
|
+
let a = e.charAt(i);
|
|
6
|
+
if (a === "(") n += 1;
|
|
7
|
+
else if (a === ")") n = Math.max(0, n - 1);
|
|
8
|
+
else if (n === 0 && /\s/.test(a)) {
|
|
9
|
+
let n = e.slice(r, i).trim();
|
|
10
|
+
n !== "" && t.push(n), r = i + 1;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
let i = e.slice(r).trim();
|
|
14
|
+
return i !== "" && t.push(i), t;
|
|
15
|
+
}, n = ({ gridTemplateColumns: e, visibleColumnIndexes: n, columnCount: r }) => {
|
|
16
|
+
if (typeof e != "string" || e === "") return;
|
|
17
|
+
let i = t(e);
|
|
18
|
+
return i.length === r ? n.map((e) => i[e]).filter((e) => e != null && e !== "").join(" ") : e;
|
|
19
|
+
}, r = (t, n) => typeof n == "string" && n !== "" ? { gridTemplateColumns: n } : { gridTemplateColumns: `repeat(${t}, ${e})` };
|
|
3
20
|
//#endregion
|
|
4
|
-
export { e as DEFAULT_DATA_TABLE_TEMPLATE_CELL,
|
|
21
|
+
export { e as DEFAULT_DATA_TABLE_TEMPLATE_CELL, r as buildDataTableInlineTemplate, n as filterDataTableGridTemplateColumns };
|
|
5
22
|
|
|
6
23
|
//# sourceMappingURL=layout.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layout.js","names":[],"sources":["../../../../src/internal/data-table/layout.ts"],"sourcesContent":["import type { CSSProperties } from 'react';\n\nexport const DEFAULT_DATA_TABLE_TEMPLATE_CELL = 'minmax(0, 1fr)';\n\nexport const buildDataTableInlineTemplate = (\n columnCount: number,\n gridTemplateColumns?: string,\n): CSSProperties => {\n if (typeof gridTemplateColumns === 'string' && gridTemplateColumns !== '') {\n return { gridTemplateColumns };\n }\n\n return {\n gridTemplateColumns: `repeat(${columnCount}, ${DEFAULT_DATA_TABLE_TEMPLATE_CELL})`,\n };\n};\n"],"mappings":";AAEA,IAAa,IAAmC,
|
|
1
|
+
{"version":3,"file":"layout.js","names":[],"sources":["../../../../src/internal/data-table/layout.ts"],"sourcesContent":["import type { CSSProperties } from 'react';\n\nexport const DEFAULT_DATA_TABLE_TEMPLATE_CELL = 'minmax(0, 1fr)';\n\nconst splitGridTemplateColumns = (gridTemplateColumns: string): string[] => {\n const tracks: string[] = [];\n let depth = 0;\n let start = 0;\n\n for (let index = 0; index < gridTemplateColumns.length; index += 1) {\n const char = gridTemplateColumns.charAt(index);\n if (char === '(') {\n depth += 1;\n } else if (char === ')') {\n depth = Math.max(0, depth - 1);\n } else if (depth === 0 && /\\s/.test(char)) {\n const track = gridTemplateColumns.slice(start, index).trim();\n if (track !== '') {\n tracks.push(track);\n }\n start = index + 1;\n }\n }\n\n const finalTrack = gridTemplateColumns.slice(start).trim();\n if (finalTrack !== '') {\n tracks.push(finalTrack);\n }\n\n return tracks;\n};\n\nexport const filterDataTableGridTemplateColumns = ({\n gridTemplateColumns,\n visibleColumnIndexes,\n columnCount,\n}: {\n gridTemplateColumns?: string;\n visibleColumnIndexes: readonly number[];\n columnCount: number;\n}): string | undefined => {\n if (typeof gridTemplateColumns !== 'string' || gridTemplateColumns === '') {\n return undefined;\n }\n\n const tracks = splitGridTemplateColumns(gridTemplateColumns);\n if (tracks.length !== columnCount) {\n return gridTemplateColumns;\n }\n\n return visibleColumnIndexes\n .map((index) => {\n return tracks[index];\n })\n .filter((track): track is string => {\n return track != null && track !== '';\n })\n .join(' ');\n};\n\nexport const buildDataTableInlineTemplate = (\n columnCount: number,\n gridTemplateColumns?: string,\n): CSSProperties => {\n if (typeof gridTemplateColumns === 'string' && gridTemplateColumns !== '') {\n return { gridTemplateColumns };\n }\n\n return {\n gridTemplateColumns: `repeat(${columnCount}, ${DEFAULT_DATA_TABLE_TEMPLATE_CELL})`,\n };\n};\n"],"mappings":";AAEA,IAAa,IAAmC,kBAE1C,KAA4B,MAA0C;CAC1E,IAAM,IAAmB,CAAC,GACtB,IAAQ,GACR,IAAQ;CAEZ,KAAK,IAAI,IAAQ,GAAG,IAAQ,EAAoB,QAAQ,KAAS,GAAG;EAClE,IAAM,IAAO,EAAoB,OAAO,CAAK;EAC7C,IAAI,MAAS,KACX,KAAS;OACJ,IAAI,MAAS,KAClB,IAAQ,KAAK,IAAI,GAAG,IAAQ,CAAC;OACxB,IAAI,MAAU,KAAK,KAAK,KAAK,CAAI,GAAG;GACzC,IAAM,IAAQ,EAAoB,MAAM,GAAO,CAAK,EAAE,KAAK;GAI3D,AAHI,MAAU,MACZ,EAAO,KAAK,CAAK,GAEnB,IAAQ,IAAQ;EAClB;CACF;CAEA,IAAM,IAAa,EAAoB,MAAM,CAAK,EAAE,KAAK;CAKzD,OAJI,MAAe,MACjB,EAAO,KAAK,CAAU,GAGjB;AACT,GAEa,KAAsC,EACjD,wBACA,yBACA,qBAKwB;CACxB,IAAI,OAAO,KAAwB,YAAY,MAAwB,IACrE;CAGF,IAAM,IAAS,EAAyB,CAAmB;CAK3D,OAJI,EAAO,WAAW,IAIf,EACJ,KAAK,MACG,EAAO,EACf,EACA,QAAQ,MACA,KAAS,QAAQ,MAAU,EACnC,EACA,KAAK,GAAG,IAVF;AAWX,GAEa,KACX,GACA,MAEI,OAAO,KAAwB,YAAY,MAAwB,KAC9D,EAAE,uBAAoB,IAGxB,EACL,qBAAqB,UAAU,EAAY,IAAI,EAAiC,GAClF"}
|