@jetbrains/ring-ui-built 7.0.115 → 8.0.0-beta.2
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/components/_helpers/table.js +2 -2
- package/components/_helpers/table2.js +3 -0
- package/components/data-list/data-list.d.ts +4 -4
- package/components/data-list/data-list.js +2 -2
- package/components/data-list/data-list.mock.d.ts +1 -1
- package/components/data-list/item.d.ts +1 -1
- package/components/data-list/selection.d.ts +1 -1
- package/components/data-list/selection.js +1 -1
- package/components/date-picker/date-picker.js +1 -1
- package/components/date-picker/date-popup.js +1 -1
- package/components/date-picker/month.d.ts +0 -2
- package/components/date-picker/month.js +16 -17
- package/components/date-picker/months.js +42 -33
- package/components/date-picker/years.js +60 -52
- package/components/global/intersection-observer-context.d.ts +26 -0
- package/components/global/intersection-observer-context.js +140 -0
- package/components/{table → legacy-table}/cell.js +1 -1
- package/components/{table → legacy-table}/header-cell.js +3 -3
- package/components/{table → legacy-table}/header.js +1 -1
- package/components/{table → legacy-table}/row-with-focus-sensor.js +1 -1
- package/components/{table → legacy-table}/row.js +1 -1
- package/components/{table → legacy-table}/selection.d.ts +2 -2
- package/components/{table → legacy-table}/selection.js +1 -1
- package/components/{table → legacy-table}/simple-table.js +1 -1
- package/components/{table → legacy-table}/smart-table.js +1 -1
- package/components/legacy-table/table.d.ts +109 -0
- package/components/legacy-table/table.js +369 -0
- package/components/old-browsers-message/white-list.js +2 -2
- package/components/style.css +1 -1
- package/components/table/default-item-renderer.d.ts +25 -0
- package/components/table/default-item-renderer.js +241 -0
- package/components/table/table-base.d.ts +24 -0
- package/components/table/table-base.js +311 -0
- package/components/table/table-component.d.ts +53 -0
- package/components/table/table-component.js +316 -0
- package/components/table/table-const.d.ts +8 -0
- package/components/table/table-const.js +11 -0
- package/components/table/table-virtualize.d.ts +32 -0
- package/components/table/table-virtualize.js +330 -0
- package/components/table/table.d.ts +221 -104
- package/components/table/table.js +18 -362
- package/package.json +1 -1
- /package/components/{table → legacy-table}/cell.d.ts +0 -0
- /package/components/{table → legacy-table}/disable-hover-hoc.d.ts +0 -0
- /package/components/{table → legacy-table}/disable-hover-hoc.js +0 -0
- /package/components/{table → legacy-table}/header-cell.d.ts +0 -0
- /package/components/{table → legacy-table}/header.d.ts +0 -0
- /package/components/{table → legacy-table}/multitable.d.ts +0 -0
- /package/components/{table → legacy-table}/multitable.js +0 -0
- /package/components/{table → legacy-table}/row-with-focus-sensor.d.ts +0 -0
- /package/components/{table → legacy-table}/row.d.ts +0 -0
- /package/components/{table → legacy-table}/selection-adapter.d.ts +0 -0
- /package/components/{table → legacy-table}/selection-adapter.js +0 -0
- /package/components/{table → legacy-table}/selection-shortcuts-hoc.d.ts +0 -0
- /package/components/{table → legacy-table}/selection-shortcuts-hoc.js +0 -0
- /package/components/{table → legacy-table}/simple-table.d.ts +0 -0
- /package/components/{table → legacy-table}/smart-table.d.ts +0 -0
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
import { c } from 'react-compiler-runtime';
|
|
2
|
+
import { useRef } from 'react';
|
|
3
|
+
import classNames from 'classnames';
|
|
4
|
+
import { IntersectionObserverContext } from '../global/intersection-observer-context.js';
|
|
5
|
+
import { useTableVirtualize, SpacerRow } from './table-virtualize.js';
|
|
6
|
+
import { DefaultItemRenderer } from './default-item-renderer.js';
|
|
7
|
+
import { defaultMinScrollAndResizeDeltaPx, defaultRetentionMarginPx, defaultLookaheadPx, TablePropsContext, CollapseItemIntoSpacerContext, defaultRowHeight, ColumnIndexContext } from './table-const.js';
|
|
8
|
+
import { s as styles } from '../_helpers/table.js';
|
|
9
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
10
|
+
import '../global/use-event-callback.js';
|
|
11
|
+
import './table-base.js';
|
|
12
|
+
import '@jetbrains/icons/unsorted-12px';
|
|
13
|
+
import '@jetbrains/icons/arrow-12px-down';
|
|
14
|
+
import '@jetbrains/icons/arrow-12px-up';
|
|
15
|
+
import '@jetbrains/icons/trash-12px';
|
|
16
|
+
import '../icon/icon.js';
|
|
17
|
+
import 'util-deprecate';
|
|
18
|
+
import '../icon/icon.constants.js';
|
|
19
|
+
import '../_helpers/icon-svg.js';
|
|
20
|
+
import '../global/memoize.js';
|
|
21
|
+
|
|
22
|
+
function Table(props) {
|
|
23
|
+
var _userRef;
|
|
24
|
+
const $ = c(66);
|
|
25
|
+
if ($[0] !== "c5cbf342ef76906cf21ee6f16da41c5d4e7db7a707456ae37dfa4f28ed5d910a") {
|
|
26
|
+
for (let $i = 0; $i < 66; $i += 1) {
|
|
27
|
+
$[$i] = Symbol.for("react.memo_cache_sentinel");
|
|
28
|
+
}
|
|
29
|
+
$[0] = "c5cbf342ef76906cf21ee6f16da41c5d4e7db7a707456ae37dfa4f28ed5d910a";
|
|
30
|
+
}
|
|
31
|
+
let className;
|
|
32
|
+
let columns;
|
|
33
|
+
let data;
|
|
34
|
+
let renderItem;
|
|
35
|
+
let restProps;
|
|
36
|
+
let scrollerRef;
|
|
37
|
+
let t0;
|
|
38
|
+
let t1;
|
|
39
|
+
let t2;
|
|
40
|
+
let t3;
|
|
41
|
+
let t4;
|
|
42
|
+
let tbodyClassName;
|
|
43
|
+
let theadClassName;
|
|
44
|
+
let theadTrClassName;
|
|
45
|
+
let userRef;
|
|
46
|
+
if ($[1] !== props) {
|
|
47
|
+
const {
|
|
48
|
+
data: t5,
|
|
49
|
+
columns: t6,
|
|
50
|
+
getKey,
|
|
51
|
+
selection,
|
|
52
|
+
isItemKeyboardFocusable,
|
|
53
|
+
onItemFocus,
|
|
54
|
+
onItemMove,
|
|
55
|
+
onSort,
|
|
56
|
+
onColumnDelete,
|
|
57
|
+
onColumnMove,
|
|
58
|
+
renderItem: t7,
|
|
59
|
+
virtualizeRows: t8,
|
|
60
|
+
scrollerRef: t9,
|
|
61
|
+
estimateHeight: t10,
|
|
62
|
+
lookaheadPx: t11,
|
|
63
|
+
retentionMarginPx: t12,
|
|
64
|
+
minScrollAndResizeDeltaPx: t13,
|
|
65
|
+
columnEditButton,
|
|
66
|
+
ref: t14,
|
|
67
|
+
className: t15,
|
|
68
|
+
theadClassName: t16,
|
|
69
|
+
theadTrClassName: t17,
|
|
70
|
+
tbodyClassName: t18,
|
|
71
|
+
...t19
|
|
72
|
+
} = props;
|
|
73
|
+
data = t5;
|
|
74
|
+
columns = t6;
|
|
75
|
+
renderItem = t7;
|
|
76
|
+
t0 = t8;
|
|
77
|
+
scrollerRef = t9;
|
|
78
|
+
t1 = t10;
|
|
79
|
+
t2 = t11;
|
|
80
|
+
t3 = t12;
|
|
81
|
+
t4 = t13;
|
|
82
|
+
userRef = t14;
|
|
83
|
+
className = t15;
|
|
84
|
+
theadClassName = t16;
|
|
85
|
+
theadTrClassName = t17;
|
|
86
|
+
tbodyClassName = t18;
|
|
87
|
+
restProps = t19;
|
|
88
|
+
$[1] = props;
|
|
89
|
+
$[2] = className;
|
|
90
|
+
$[3] = columns;
|
|
91
|
+
$[4] = data;
|
|
92
|
+
$[5] = renderItem;
|
|
93
|
+
$[6] = restProps;
|
|
94
|
+
$[7] = scrollerRef;
|
|
95
|
+
$[8] = t0;
|
|
96
|
+
$[9] = t1;
|
|
97
|
+
$[10] = t2;
|
|
98
|
+
$[11] = t3;
|
|
99
|
+
$[12] = t4;
|
|
100
|
+
$[13] = tbodyClassName;
|
|
101
|
+
$[14] = theadClassName;
|
|
102
|
+
$[15] = theadTrClassName;
|
|
103
|
+
$[16] = userRef;
|
|
104
|
+
} else {
|
|
105
|
+
className = $[2];
|
|
106
|
+
columns = $[3];
|
|
107
|
+
data = $[4];
|
|
108
|
+
renderItem = $[5];
|
|
109
|
+
restProps = $[6];
|
|
110
|
+
scrollerRef = $[7];
|
|
111
|
+
t0 = $[8];
|
|
112
|
+
t1 = $[9];
|
|
113
|
+
t2 = $[10];
|
|
114
|
+
t3 = $[11];
|
|
115
|
+
t4 = $[12];
|
|
116
|
+
tbodyClassName = $[13];
|
|
117
|
+
theadClassName = $[14];
|
|
118
|
+
theadTrClassName = $[15];
|
|
119
|
+
userRef = $[16];
|
|
120
|
+
}
|
|
121
|
+
const virtualizeRows = t0 === undefined ? false : t0;
|
|
122
|
+
const estimateHeight = t1 === undefined ? _temp : t1;
|
|
123
|
+
const lookaheadPx = t2 === undefined ? defaultLookaheadPx : t2;
|
|
124
|
+
const retentionMarginPx = t3 === undefined ? defaultRetentionMarginPx : t3;
|
|
125
|
+
const minScrollAndResizeDeltaPx = t4 === undefined ? defaultMinScrollAndResizeDeltaPx : t4;
|
|
126
|
+
const selfRef = useRef(null);
|
|
127
|
+
const tableRef = (_userRef = userRef) !== null && _userRef !== void 0 ? _userRef : selfRef;
|
|
128
|
+
let t5;
|
|
129
|
+
if ($[17] !== data.length || $[18] !== estimateHeight || $[19] !== lookaheadPx || $[20] !== minScrollAndResizeDeltaPx || $[21] !== retentionMarginPx || $[22] !== scrollerRef || $[23] !== tableRef || $[24] !== virtualizeRows) {
|
|
130
|
+
t5 = {
|
|
131
|
+
enabled: virtualizeRows,
|
|
132
|
+
length: data.length,
|
|
133
|
+
scrollerRef,
|
|
134
|
+
tableRef,
|
|
135
|
+
estimateHeight,
|
|
136
|
+
lookaheadPx,
|
|
137
|
+
retentionMarginPx,
|
|
138
|
+
minScrollAndResizeDeltaPx
|
|
139
|
+
};
|
|
140
|
+
$[17] = data.length;
|
|
141
|
+
$[18] = estimateHeight;
|
|
142
|
+
$[19] = lookaheadPx;
|
|
143
|
+
$[20] = minScrollAndResizeDeltaPx;
|
|
144
|
+
$[21] = retentionMarginPx;
|
|
145
|
+
$[22] = scrollerRef;
|
|
146
|
+
$[23] = tableRef;
|
|
147
|
+
$[24] = virtualizeRows;
|
|
148
|
+
$[25] = t5;
|
|
149
|
+
} else {
|
|
150
|
+
t5 = $[25];
|
|
151
|
+
}
|
|
152
|
+
const {
|
|
153
|
+
virtualItems,
|
|
154
|
+
intersectionObserverHandle,
|
|
155
|
+
collapseItemIntoSpacer
|
|
156
|
+
} = useTableVirtualize(t5);
|
|
157
|
+
let t6;
|
|
158
|
+
if ($[26] !== className) {
|
|
159
|
+
t6 = classNames(styles.table, className);
|
|
160
|
+
$[26] = className;
|
|
161
|
+
$[27] = t6;
|
|
162
|
+
} else {
|
|
163
|
+
t6 = $[27];
|
|
164
|
+
}
|
|
165
|
+
let t7;
|
|
166
|
+
if ($[28] !== theadTrClassName) {
|
|
167
|
+
t7 = classNames(styles.headerRow, theadTrClassName);
|
|
168
|
+
$[28] = theadTrClassName;
|
|
169
|
+
$[29] = t7;
|
|
170
|
+
} else {
|
|
171
|
+
t7 = $[29];
|
|
172
|
+
}
|
|
173
|
+
let t8;
|
|
174
|
+
if ($[30] !== columns) {
|
|
175
|
+
t8 = columns.map(_temp2);
|
|
176
|
+
$[30] = columns;
|
|
177
|
+
$[31] = t8;
|
|
178
|
+
} else {
|
|
179
|
+
t8 = $[31];
|
|
180
|
+
}
|
|
181
|
+
let t9;
|
|
182
|
+
if ($[32] !== t7 || $[33] !== t8) {
|
|
183
|
+
t9 = /*#__PURE__*/jsx("tr", {
|
|
184
|
+
className: t7,
|
|
185
|
+
children: t8
|
|
186
|
+
});
|
|
187
|
+
$[32] = t7;
|
|
188
|
+
$[33] = t8;
|
|
189
|
+
$[34] = t9;
|
|
190
|
+
} else {
|
|
191
|
+
t9 = $[34];
|
|
192
|
+
}
|
|
193
|
+
let t10;
|
|
194
|
+
if ($[35] !== t9 || $[36] !== theadClassName) {
|
|
195
|
+
t10 = /*#__PURE__*/jsx("thead", {
|
|
196
|
+
className: theadClassName,
|
|
197
|
+
children: t9
|
|
198
|
+
});
|
|
199
|
+
$[35] = t9;
|
|
200
|
+
$[36] = theadClassName;
|
|
201
|
+
$[37] = t10;
|
|
202
|
+
} else {
|
|
203
|
+
t10 = $[37];
|
|
204
|
+
}
|
|
205
|
+
let t11;
|
|
206
|
+
if ($[38] !== collapseItemIntoSpacer || $[39] !== columns.length || $[40] !== data || $[41] !== props || $[42] !== renderItem || $[43] !== virtualItems) {
|
|
207
|
+
let t12;
|
|
208
|
+
if ($[45] !== collapseItemIntoSpacer || $[46] !== columns.length || $[47] !== data || $[48] !== props || $[49] !== renderItem) {
|
|
209
|
+
t12 = virtualItem => {
|
|
210
|
+
if (virtualItem.type === "spacer") {
|
|
211
|
+
return /*#__PURE__*/jsx(SpacerRow, {
|
|
212
|
+
spacer: virtualItem,
|
|
213
|
+
colSpan: columns.length
|
|
214
|
+
}, virtualItem.key);
|
|
215
|
+
}
|
|
216
|
+
const index = virtualItem.index;
|
|
217
|
+
const item = data[index];
|
|
218
|
+
const key = props.getKey(item, index);
|
|
219
|
+
return /*#__PURE__*/jsx(CollapseItemIntoSpacerContext.Provider, {
|
|
220
|
+
value: height => collapseItemIntoSpacer(index, height),
|
|
221
|
+
children: renderItem ? renderItem(item, index, data) : /*#__PURE__*/jsx(DefaultItemRenderer, {
|
|
222
|
+
index: index
|
|
223
|
+
})
|
|
224
|
+
}, key);
|
|
225
|
+
};
|
|
226
|
+
$[45] = collapseItemIntoSpacer;
|
|
227
|
+
$[46] = columns.length;
|
|
228
|
+
$[47] = data;
|
|
229
|
+
$[48] = props;
|
|
230
|
+
$[49] = renderItem;
|
|
231
|
+
$[50] = t12;
|
|
232
|
+
} else {
|
|
233
|
+
t12 = $[50];
|
|
234
|
+
}
|
|
235
|
+
t11 = virtualItems.map(t12);
|
|
236
|
+
$[38] = collapseItemIntoSpacer;
|
|
237
|
+
$[39] = columns.length;
|
|
238
|
+
$[40] = data;
|
|
239
|
+
$[41] = props;
|
|
240
|
+
$[42] = renderItem;
|
|
241
|
+
$[43] = virtualItems;
|
|
242
|
+
$[44] = t11;
|
|
243
|
+
} else {
|
|
244
|
+
t11 = $[44];
|
|
245
|
+
}
|
|
246
|
+
let t12;
|
|
247
|
+
if ($[51] !== t11 || $[52] !== tbodyClassName) {
|
|
248
|
+
t12 = /*#__PURE__*/jsx("tbody", {
|
|
249
|
+
className: tbodyClassName,
|
|
250
|
+
children: t11
|
|
251
|
+
});
|
|
252
|
+
$[51] = t11;
|
|
253
|
+
$[52] = tbodyClassName;
|
|
254
|
+
$[53] = t12;
|
|
255
|
+
} else {
|
|
256
|
+
t12 = $[53];
|
|
257
|
+
}
|
|
258
|
+
let t13;
|
|
259
|
+
if ($[54] !== restProps || $[55] !== t10 || $[56] !== t12 || $[57] !== t6 || $[58] !== tableRef) {
|
|
260
|
+
t13 = /*#__PURE__*/jsxs("table", {
|
|
261
|
+
className: t6,
|
|
262
|
+
ref: tableRef,
|
|
263
|
+
...restProps,
|
|
264
|
+
children: [t10, t12]
|
|
265
|
+
});
|
|
266
|
+
$[54] = restProps;
|
|
267
|
+
$[55] = t10;
|
|
268
|
+
$[56] = t12;
|
|
269
|
+
$[57] = t6;
|
|
270
|
+
$[58] = tableRef;
|
|
271
|
+
$[59] = t13;
|
|
272
|
+
} else {
|
|
273
|
+
t13 = $[59];
|
|
274
|
+
}
|
|
275
|
+
let t14;
|
|
276
|
+
if ($[60] !== intersectionObserverHandle || $[61] !== t13) {
|
|
277
|
+
t14 = /*#__PURE__*/jsx(IntersectionObserverContext.Provider, {
|
|
278
|
+
value: intersectionObserverHandle,
|
|
279
|
+
children: t13
|
|
280
|
+
});
|
|
281
|
+
$[60] = intersectionObserverHandle;
|
|
282
|
+
$[61] = t13;
|
|
283
|
+
$[62] = t14;
|
|
284
|
+
} else {
|
|
285
|
+
t14 = $[62];
|
|
286
|
+
}
|
|
287
|
+
let t15;
|
|
288
|
+
if ($[63] !== props || $[64] !== t14) {
|
|
289
|
+
t15 = /*#__PURE__*/jsx(TablePropsContext.Provider, {
|
|
290
|
+
value: props,
|
|
291
|
+
children: t14
|
|
292
|
+
});
|
|
293
|
+
$[63] = props;
|
|
294
|
+
$[64] = t14;
|
|
295
|
+
$[65] = t15;
|
|
296
|
+
} else {
|
|
297
|
+
t15 = $[65];
|
|
298
|
+
}
|
|
299
|
+
return t15;
|
|
300
|
+
}
|
|
301
|
+
function _temp2(column, columnIndex) {
|
|
302
|
+
var _ref, _column$renderHeader;
|
|
303
|
+
return /*#__PURE__*/jsx("th", {
|
|
304
|
+
className: classNames(styles.headerCell, column.thClassName),
|
|
305
|
+
"aria-sort": column.sortOrder,
|
|
306
|
+
children: /*#__PURE__*/jsx(ColumnIndexContext.Provider, {
|
|
307
|
+
value: columnIndex,
|
|
308
|
+
children: (_ref = (_column$renderHeader = column.renderHeader?.()) !== null && _column$renderHeader !== void 0 ? _column$renderHeader : column.name) !== null && _ref !== void 0 ? _ref : String(column.key)
|
|
309
|
+
})
|
|
310
|
+
}, column.key);
|
|
311
|
+
}
|
|
312
|
+
function _temp() {
|
|
313
|
+
return defaultRowHeight;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
export { Table as default };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { TableProps } from './table';
|
|
2
|
+
export declare const TablePropsContext: import("react").Context<TableProps<unknown> | null>;
|
|
3
|
+
export declare const ColumnIndexContext: import("react").Context<number>;
|
|
4
|
+
export declare const CollapseItemIntoSpacerContext: import("react").Context<(height: number) => void>;
|
|
5
|
+
export declare const defaultRowHeight = 37;
|
|
6
|
+
export declare const defaultLookaheadPx = 400;
|
|
7
|
+
export declare const defaultRetentionMarginPx = 450;
|
|
8
|
+
export declare const defaultMinScrollAndResizeDeltaPx = 50;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createContext } from 'react';
|
|
2
|
+
|
|
3
|
+
const TablePropsContext = /*#__PURE__*/createContext(null);
|
|
4
|
+
const ColumnIndexContext = /*#__PURE__*/createContext(-1);
|
|
5
|
+
const CollapseItemIntoSpacerContext = /*#__PURE__*/createContext(() => {});
|
|
6
|
+
const defaultRowHeight = 37;
|
|
7
|
+
const defaultLookaheadPx = 400;
|
|
8
|
+
const defaultRetentionMarginPx = 450;
|
|
9
|
+
const defaultMinScrollAndResizeDeltaPx = 50;
|
|
10
|
+
|
|
11
|
+
export { CollapseItemIntoSpacerContext, ColumnIndexContext, TablePropsContext, defaultLookaheadPx, defaultMinScrollAndResizeDeltaPx, defaultRetentionMarginPx, defaultRowHeight };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { type RefObject } from 'react';
|
|
2
|
+
export type VirtualItem = RenderedItem | Spacer;
|
|
3
|
+
interface RenderedItem {
|
|
4
|
+
type: 'rendered';
|
|
5
|
+
index: number;
|
|
6
|
+
}
|
|
7
|
+
interface Spacer {
|
|
8
|
+
type: 'spacer';
|
|
9
|
+
from: number;
|
|
10
|
+
to: number;
|
|
11
|
+
height: number;
|
|
12
|
+
key: string;
|
|
13
|
+
}
|
|
14
|
+
export declare function useTableVirtualize({ enabled, length, scrollerRef, tableRef, estimateHeight, lookaheadPx, retentionMarginPx, minScrollAndResizeDeltaPx, }: {
|
|
15
|
+
enabled: boolean;
|
|
16
|
+
length: number;
|
|
17
|
+
scrollerRef: RefObject<HTMLElement | null> | undefined;
|
|
18
|
+
tableRef: RefObject<HTMLTableElement | null>;
|
|
19
|
+
estimateHeight: (index: number) => number;
|
|
20
|
+
lookaheadPx: number;
|
|
21
|
+
retentionMarginPx: number;
|
|
22
|
+
minScrollAndResizeDeltaPx: number;
|
|
23
|
+
}): {
|
|
24
|
+
virtualItems: VirtualItem[];
|
|
25
|
+
intersectionObserverHandle: import("../global/intersection-observer-context").IntersectionObserverHandle | null;
|
|
26
|
+
collapseItemIntoSpacer: (index: number, height: number) => void;
|
|
27
|
+
};
|
|
28
|
+
export declare function SpacerRow({ spacer: { from, to, height }, colSpan }: {
|
|
29
|
+
spacer: Spacer;
|
|
30
|
+
colSpan: number;
|
|
31
|
+
}): import("react").JSX.Element;
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
import { c } from 'react-compiler-runtime';
|
|
2
|
+
import { useRef, useState, useEffect } from 'react';
|
|
3
|
+
import useEventCallback from '../global/use-event-callback.js';
|
|
4
|
+
import { useIntersectionObserverHandle } from '../global/intersection-observer-context.js';
|
|
5
|
+
import { s as styles } from '../_helpers/table.js';
|
|
6
|
+
import { jsx } from 'react/jsx-runtime';
|
|
7
|
+
|
|
8
|
+
const virtualizationThrottleDelay = 50;
|
|
9
|
+
function useTableVirtualize(t0) {
|
|
10
|
+
const $ = c(33);
|
|
11
|
+
if ($[0] !== "43a8daad27f2d756ec5346c25f1057b419a001b3d7cb998cd41acf333e829c58") {
|
|
12
|
+
for (let $i = 0; $i < 33; $i += 1) {
|
|
13
|
+
$[$i] = Symbol.for("react.memo_cache_sentinel");
|
|
14
|
+
}
|
|
15
|
+
$[0] = "43a8daad27f2d756ec5346c25f1057b419a001b3d7cb998cd41acf333e829c58";
|
|
16
|
+
}
|
|
17
|
+
const {
|
|
18
|
+
enabled,
|
|
19
|
+
length,
|
|
20
|
+
scrollerRef,
|
|
21
|
+
tableRef,
|
|
22
|
+
estimateHeight,
|
|
23
|
+
lookaheadPx,
|
|
24
|
+
retentionMarginPx,
|
|
25
|
+
minScrollAndResizeDeltaPx
|
|
26
|
+
} = t0;
|
|
27
|
+
let t1;
|
|
28
|
+
if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
|
|
29
|
+
t1 = [];
|
|
30
|
+
$[1] = t1;
|
|
31
|
+
} else {
|
|
32
|
+
t1 = $[1];
|
|
33
|
+
}
|
|
34
|
+
const itemsMaterialization = useRef(t1);
|
|
35
|
+
let t2;
|
|
36
|
+
if ($[2] !== estimateHeight || $[3] !== length) {
|
|
37
|
+
t2 = () => [{
|
|
38
|
+
type: "spacer",
|
|
39
|
+
from: 0,
|
|
40
|
+
to: length,
|
|
41
|
+
height: Array.from({
|
|
42
|
+
length
|
|
43
|
+
}, (_, i) => estimateHeight(i)).reduce(_temp, 0),
|
|
44
|
+
key: `${styles.spacerRow}-0`
|
|
45
|
+
}];
|
|
46
|
+
$[2] = estimateHeight;
|
|
47
|
+
$[3] = length;
|
|
48
|
+
$[4] = t2;
|
|
49
|
+
} else {
|
|
50
|
+
t2 = $[4];
|
|
51
|
+
}
|
|
52
|
+
const [virtualItems, setVirtualItems] = useState(t2);
|
|
53
|
+
let t3;
|
|
54
|
+
if ($[5] !== estimateHeight || $[6] !== lookaheadPx || $[7] !== scrollerRef || $[8] !== tableRef) {
|
|
55
|
+
t3 = () => {
|
|
56
|
+
var _scrollerRef$current$;
|
|
57
|
+
if (!tableRef.current) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
const containerHeight = (_scrollerRef$current$ = scrollerRef?.current?.clientHeight) !== null && _scrollerRef$current$ !== void 0 ? _scrollerRef$current$ : window.innerHeight;
|
|
61
|
+
for (const spacerRow of tableRef.current.querySelectorAll(`.${styles.spacerRow}`)) {
|
|
62
|
+
const rect = spacerRow.getBoundingClientRect();
|
|
63
|
+
const spacerIntersectsLookaheadArea = rect.top < containerHeight + lookaheadPx && rect.bottom > -lookaheadPx;
|
|
64
|
+
if (!spacerIntersectsLookaheadArea) {
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
const visibleOffsetStart = Math.max(0, -rect.top);
|
|
68
|
+
const visibleOffsetEnd = Math.min(rect.height, containerHeight - rect.top);
|
|
69
|
+
const materializeOffsetStart = visibleOffsetStart - lookaheadPx;
|
|
70
|
+
const materializeOffsetEnd = visibleOffsetEnd + lookaheadPx;
|
|
71
|
+
let offsetInSpacer = 0;
|
|
72
|
+
const from = Number(spacerRow.dataset.from);
|
|
73
|
+
const to = Number(spacerRow.dataset.to);
|
|
74
|
+
for (let i_0 = from; i_0 < to; i_0++) {
|
|
75
|
+
const itemMaterialization = itemsMaterialization.current[i_0];
|
|
76
|
+
const itemHeight = typeof itemMaterialization === "number" ? itemMaterialization : estimateHeight(i_0);
|
|
77
|
+
const itemOffsetStart = offsetInSpacer;
|
|
78
|
+
const itemOffsetEnd = offsetInSpacer + itemHeight;
|
|
79
|
+
if (itemOffsetStart < materializeOffsetEnd && itemOffsetEnd > materializeOffsetStart) {
|
|
80
|
+
itemsMaterialization.current[i_0] = true;
|
|
81
|
+
} else {
|
|
82
|
+
if (itemOffsetStart > materializeOffsetEnd) {
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
offsetInSpacer = offsetInSpacer + itemHeight;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
$[5] = estimateHeight;
|
|
91
|
+
$[6] = lookaheadPx;
|
|
92
|
+
$[7] = scrollerRef;
|
|
93
|
+
$[8] = tableRef;
|
|
94
|
+
$[9] = t3;
|
|
95
|
+
} else {
|
|
96
|
+
t3 = $[9];
|
|
97
|
+
}
|
|
98
|
+
const materializeVisibleSpacerItems = useEventCallback(t3);
|
|
99
|
+
let t4;
|
|
100
|
+
if ($[10] !== estimateHeight || $[11] !== length) {
|
|
101
|
+
t4 = () => {
|
|
102
|
+
const newVirtualItems = [];
|
|
103
|
+
let spacerCounter = 0;
|
|
104
|
+
for (let i_1 = 0; i_1 < length; i_1++) {
|
|
105
|
+
const itemMaterialization_0 = itemsMaterialization.current[i_1];
|
|
106
|
+
if (itemMaterialization_0 === true) {
|
|
107
|
+
newVirtualItems.push({
|
|
108
|
+
type: "rendered",
|
|
109
|
+
index: i_1
|
|
110
|
+
});
|
|
111
|
+
} else {
|
|
112
|
+
const lastItemOrSpacer = newVirtualItems[newVirtualItems.length - 1];
|
|
113
|
+
const lastSpacer = lastItemOrSpacer?.type === "spacer" ? lastItemOrSpacer : undefined;
|
|
114
|
+
const height = typeof itemMaterialization_0 === "number" ? itemMaterialization_0 : estimateHeight(i_1);
|
|
115
|
+
if (lastSpacer) {
|
|
116
|
+
lastSpacer.to = i_1 + 1;
|
|
117
|
+
lastSpacer.height = lastSpacer.height + height;
|
|
118
|
+
} else {
|
|
119
|
+
newVirtualItems.push({
|
|
120
|
+
type: "spacer",
|
|
121
|
+
from: i_1,
|
|
122
|
+
to: i_1 + 1,
|
|
123
|
+
height,
|
|
124
|
+
key: `${styles.spacerRow}-${spacerCounter++}`
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
setVirtualItems(newVirtualItems);
|
|
130
|
+
};
|
|
131
|
+
$[10] = estimateHeight;
|
|
132
|
+
$[11] = length;
|
|
133
|
+
$[12] = t4;
|
|
134
|
+
} else {
|
|
135
|
+
t4 = $[12];
|
|
136
|
+
}
|
|
137
|
+
const recomputeVirtualItems = useEventCallback(t4);
|
|
138
|
+
const timerIdRef = useRef(null);
|
|
139
|
+
const callbacksRef = useRef(null);
|
|
140
|
+
let t5;
|
|
141
|
+
if ($[13] === Symbol.for("react.memo_cache_sentinel")) {
|
|
142
|
+
t5 = (...t6) => {
|
|
143
|
+
const callbacks = t6;
|
|
144
|
+
if (timerIdRef.current != null) {
|
|
145
|
+
callbacks.forEach(cb => {
|
|
146
|
+
callbacksRef.current.delete(cb);
|
|
147
|
+
callbacksRef.current.add(cb);
|
|
148
|
+
});
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
callbacksRef.current = new Set(callbacks);
|
|
152
|
+
timerIdRef.current = window.setTimeout(() => {
|
|
153
|
+
callbacksRef.current.forEach(_temp2);
|
|
154
|
+
timerIdRef.current = null;
|
|
155
|
+
callbacksRef.current = null;
|
|
156
|
+
}, virtualizationThrottleDelay);
|
|
157
|
+
};
|
|
158
|
+
$[13] = t5;
|
|
159
|
+
} else {
|
|
160
|
+
t5 = $[13];
|
|
161
|
+
}
|
|
162
|
+
const throttle = useEventCallback(t5);
|
|
163
|
+
let t6;
|
|
164
|
+
let t7;
|
|
165
|
+
if ($[14] !== enabled || $[15] !== materializeVisibleSpacerItems || $[16] !== minScrollAndResizeDeltaPx || $[17] !== recomputeVirtualItems || $[18] !== scrollerRef || $[19] !== throttle) {
|
|
166
|
+
t6 = () => {
|
|
167
|
+
if (!enabled) {
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
const scroller = scrollerRef?.current;
|
|
171
|
+
let lastHandledScrollTop = -Infinity;
|
|
172
|
+
let lastHandledHeight = -Infinity;
|
|
173
|
+
let lastHandledWidth = -Infinity;
|
|
174
|
+
const handleViewportChange = function handleViewportChange() {
|
|
175
|
+
const scrollTop = scroller ? scroller.scrollTop : window.scrollY;
|
|
176
|
+
const height_0 = scroller ? scroller.clientHeight : window.innerHeight;
|
|
177
|
+
const width = scroller ? scroller.clientWidth : window.innerWidth;
|
|
178
|
+
if (Math.abs(scrollTop - lastHandledScrollTop) >= minScrollAndResizeDeltaPx || Math.abs(height_0 - lastHandledHeight) >= minScrollAndResizeDeltaPx || Math.abs(width - lastHandledWidth) >= minScrollAndResizeDeltaPx) {
|
|
179
|
+
lastHandledScrollTop = scrollTop;
|
|
180
|
+
lastHandledHeight = height_0;
|
|
181
|
+
lastHandledWidth = width;
|
|
182
|
+
throttle(materializeVisibleSpacerItems, recomputeVirtualItems);
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
const scrollTarget = scroller !== null && scroller !== void 0 ? scroller : window;
|
|
186
|
+
scrollTarget.addEventListener("scroll", handleViewportChange, {
|
|
187
|
+
passive: true
|
|
188
|
+
});
|
|
189
|
+
const resizeObserver = new ResizeObserver(handleViewportChange);
|
|
190
|
+
const resizeTarget = scroller !== null && scroller !== void 0 ? scroller : document.documentElement;
|
|
191
|
+
resizeObserver.observe(resizeTarget);
|
|
192
|
+
handleViewportChange();
|
|
193
|
+
return () => {
|
|
194
|
+
scrollTarget.removeEventListener("scroll", handleViewportChange);
|
|
195
|
+
resizeObserver.unobserve(resizeTarget);
|
|
196
|
+
resizeObserver.disconnect();
|
|
197
|
+
};
|
|
198
|
+
};
|
|
199
|
+
t7 = [enabled, materializeVisibleSpacerItems, minScrollAndResizeDeltaPx, recomputeVirtualItems, scrollerRef, throttle];
|
|
200
|
+
$[14] = enabled;
|
|
201
|
+
$[15] = materializeVisibleSpacerItems;
|
|
202
|
+
$[16] = minScrollAndResizeDeltaPx;
|
|
203
|
+
$[17] = recomputeVirtualItems;
|
|
204
|
+
$[18] = scrollerRef;
|
|
205
|
+
$[19] = throttle;
|
|
206
|
+
$[20] = t6;
|
|
207
|
+
$[21] = t7;
|
|
208
|
+
} else {
|
|
209
|
+
t6 = $[20];
|
|
210
|
+
t7 = $[21];
|
|
211
|
+
}
|
|
212
|
+
useEffect(t6, t7);
|
|
213
|
+
const intersectionObserverHandle = useIntersectionObserverHandle(scrollerRef, scrollerRef ? retentionMarginPx : undefined, !scrollerRef ? retentionMarginPx : undefined);
|
|
214
|
+
let t8;
|
|
215
|
+
if ($[22] !== enabled || $[23] !== recomputeVirtualItems || $[24] !== throttle) {
|
|
216
|
+
t8 = (index, height_1) => {
|
|
217
|
+
if (!enabled) {
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
itemsMaterialization.current[index] = height_1;
|
|
221
|
+
throttle(recomputeVirtualItems);
|
|
222
|
+
};
|
|
223
|
+
$[22] = enabled;
|
|
224
|
+
$[23] = recomputeVirtualItems;
|
|
225
|
+
$[24] = throttle;
|
|
226
|
+
$[25] = t8;
|
|
227
|
+
} else {
|
|
228
|
+
t8 = $[25];
|
|
229
|
+
}
|
|
230
|
+
const collapseItemIntoSpacer = useEventCallback(t8);
|
|
231
|
+
let t9;
|
|
232
|
+
if ($[26] !== enabled || $[27] !== length) {
|
|
233
|
+
t9 = Array.from({
|
|
234
|
+
length: enabled ? 0 : length
|
|
235
|
+
}, _temp3);
|
|
236
|
+
$[26] = enabled;
|
|
237
|
+
$[27] = length;
|
|
238
|
+
$[28] = t9;
|
|
239
|
+
} else {
|
|
240
|
+
t9 = $[28];
|
|
241
|
+
}
|
|
242
|
+
const allVisibleVirtualItems = t9;
|
|
243
|
+
const t10 = enabled ? virtualItems : allVisibleVirtualItems;
|
|
244
|
+
let t11;
|
|
245
|
+
if ($[29] !== collapseItemIntoSpacer || $[30] !== intersectionObserverHandle || $[31] !== t10) {
|
|
246
|
+
t11 = {
|
|
247
|
+
virtualItems: t10,
|
|
248
|
+
intersectionObserverHandle,
|
|
249
|
+
collapseItemIntoSpacer
|
|
250
|
+
};
|
|
251
|
+
$[29] = collapseItemIntoSpacer;
|
|
252
|
+
$[30] = intersectionObserverHandle;
|
|
253
|
+
$[31] = t10;
|
|
254
|
+
$[32] = t11;
|
|
255
|
+
} else {
|
|
256
|
+
t11 = $[32];
|
|
257
|
+
}
|
|
258
|
+
return t11;
|
|
259
|
+
}
|
|
260
|
+
function _temp3(__0, index_0) {
|
|
261
|
+
return {
|
|
262
|
+
type: "rendered",
|
|
263
|
+
index: index_0
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
function _temp2(cb_0) {
|
|
267
|
+
return cb_0();
|
|
268
|
+
}
|
|
269
|
+
function _temp(a, b) {
|
|
270
|
+
return a + b;
|
|
271
|
+
}
|
|
272
|
+
function SpacerRow(t0) {
|
|
273
|
+
const $ = c(10);
|
|
274
|
+
if ($[0] !== "43a8daad27f2d756ec5346c25f1057b419a001b3d7cb998cd41acf333e829c58") {
|
|
275
|
+
for (let $i = 0; $i < 10; $i += 1) {
|
|
276
|
+
$[$i] = Symbol.for("react.memo_cache_sentinel");
|
|
277
|
+
}
|
|
278
|
+
$[0] = "43a8daad27f2d756ec5346c25f1057b419a001b3d7cb998cd41acf333e829c58";
|
|
279
|
+
}
|
|
280
|
+
const {
|
|
281
|
+
spacer: t1,
|
|
282
|
+
colSpan
|
|
283
|
+
} = t0;
|
|
284
|
+
const {
|
|
285
|
+
from,
|
|
286
|
+
to,
|
|
287
|
+
height
|
|
288
|
+
} = t1;
|
|
289
|
+
let t2;
|
|
290
|
+
if ($[1] !== height) {
|
|
291
|
+
t2 = {
|
|
292
|
+
height
|
|
293
|
+
};
|
|
294
|
+
$[1] = height;
|
|
295
|
+
$[2] = t2;
|
|
296
|
+
} else {
|
|
297
|
+
t2 = $[2];
|
|
298
|
+
}
|
|
299
|
+
let t3;
|
|
300
|
+
if ($[3] !== colSpan || $[4] !== t2) {
|
|
301
|
+
t3 = /*#__PURE__*/jsx("td", {
|
|
302
|
+
className: styles.spacerCell,
|
|
303
|
+
colSpan: colSpan,
|
|
304
|
+
style: t2
|
|
305
|
+
});
|
|
306
|
+
$[3] = colSpan;
|
|
307
|
+
$[4] = t2;
|
|
308
|
+
$[5] = t3;
|
|
309
|
+
} else {
|
|
310
|
+
t3 = $[5];
|
|
311
|
+
}
|
|
312
|
+
let t4;
|
|
313
|
+
if ($[6] !== from || $[7] !== t3 || $[8] !== to) {
|
|
314
|
+
t4 = /*#__PURE__*/jsx("tr", {
|
|
315
|
+
className: styles.spacerRow,
|
|
316
|
+
"data-from": from,
|
|
317
|
+
"data-to": to,
|
|
318
|
+
children: t3
|
|
319
|
+
});
|
|
320
|
+
$[6] = from;
|
|
321
|
+
$[7] = t3;
|
|
322
|
+
$[8] = to;
|
|
323
|
+
$[9] = t4;
|
|
324
|
+
} else {
|
|
325
|
+
t4 = $[9];
|
|
326
|
+
}
|
|
327
|
+
return t4;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
export { SpacerRow, useTableVirtualize };
|