@shoplflow/templates 0.2.46 → 0.2.47
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/dist/index.cjs +2874 -972
- package/dist/index.d.cts +136 -65
- package/dist/index.d.ts +136 -65
- package/dist/index.js +2797 -895
- package/package.json +4 -1
package/dist/index.js
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
import { colorTokens,
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import { RefreshIcon, CloseSmallIcon, HelpLineIcon, DeleteIcon,
|
|
1
|
+
import { colorTokens, fontWeightTokens, typographyTokens, StackContainer, IconButton, Icon, Tag, Text, Stack, Skeleton, Pagination, Checkbox, Tooltip, Popper, shift, ScrollArea, flip, Menu } from '@shoplflow/base';
|
|
2
|
+
import React3, { createContext, memo, forwardRef, useRef, useImperativeHandle, useEffect, useMemo, useCallback, useContext, useState, Children, isValidElement, Fragment as Fragment$1, useSyncExternalStore } from 'react';
|
|
3
|
+
import styled3 from '@emotion/styled';
|
|
4
|
+
import { RefreshIcon, CloseSmallIcon, HelpLineIcon, DeleteIcon, MoreIcon, AscIcon, DescIcon, UpArrowSolidXsmallIcon, DownArrowSolidXsmallIcon, ListMoveIcon } from '@shoplflow/shopl-assets';
|
|
5
5
|
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
6
|
-
import { useReactTable, getCoreRowModel, getFilteredRowModel, getPaginationRowModel, getSortedRowModel
|
|
6
|
+
import { flexRender, useReactTable, getCoreRowModel, getFilteredRowModel, getPaginationRowModel, getSortedRowModel } from '@tanstack/react-table';
|
|
7
7
|
export { createColumnHelper } from '@tanstack/react-table';
|
|
8
8
|
import { isEqual } from 'lodash-es';
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
9
|
+
import { useSensors, useSensor, PointerSensor, KeyboardSensor, DndContext, closestCenter } from '@dnd-kit/core';
|
|
10
|
+
import { sortableKeyboardCoordinates, SortableContext, verticalListSortingStrategy, useSortable, arrayMove } from '@dnd-kit/sortable';
|
|
11
|
+
import { usePopover } from '@shoplflow/utils';
|
|
12
|
+
import { CSS } from '@dnd-kit/utilities';
|
|
13
|
+
import { useVirtualizer } from '@tanstack/react-virtual';
|
|
11
14
|
|
|
12
15
|
var __defProp = Object.defineProperty;
|
|
13
16
|
var __defProps = Object.defineProperties;
|
|
@@ -40,6 +43,26 @@ var __objRest = (source, exclude) => {
|
|
|
40
43
|
}
|
|
41
44
|
return target;
|
|
42
45
|
};
|
|
46
|
+
var __async = (__this, __arguments, generator) => {
|
|
47
|
+
return new Promise((resolve, reject) => {
|
|
48
|
+
var fulfilled = (value) => {
|
|
49
|
+
try {
|
|
50
|
+
step(generator.next(value));
|
|
51
|
+
} catch (e) {
|
|
52
|
+
reject(e);
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
var rejected = (value) => {
|
|
56
|
+
try {
|
|
57
|
+
step(generator.throw(value));
|
|
58
|
+
} catch (e) {
|
|
59
|
+
reject(e);
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
63
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
64
|
+
});
|
|
65
|
+
};
|
|
43
66
|
var getTypographyAndColor = (depth) => {
|
|
44
67
|
switch (depth) {
|
|
45
68
|
case 1:
|
|
@@ -51,7 +74,7 @@ var getTypographyAndColor = (depth) => {
|
|
|
51
74
|
return { typography: "body1_700", color: "neutral500" };
|
|
52
75
|
}
|
|
53
76
|
};
|
|
54
|
-
var StyledRequired =
|
|
77
|
+
var StyledRequired = styled3.div`
|
|
55
78
|
color: ${colorTokens.red300};
|
|
56
79
|
font-weight: 700;
|
|
57
80
|
font-size: 14px;
|
|
@@ -120,6 +143,37 @@ TitleGroup.Header = Header;
|
|
|
120
143
|
TitleGroup.Actions = Actions;
|
|
121
144
|
TitleGroup.Description = Description;
|
|
122
145
|
var TitleGroup_default = TitleGroup;
|
|
146
|
+
var TableBtn = styled3.button`
|
|
147
|
+
display: flex;
|
|
148
|
+
align-items: center;
|
|
149
|
+
gap: 2px;
|
|
150
|
+
border: 1px solid ${colorTokens.neutral200};
|
|
151
|
+
border-radius: 4px;
|
|
152
|
+
padding: 4px;
|
|
153
|
+
background: ${colorTokens.neutral150};
|
|
154
|
+
color: ${colorTokens.neutral700};
|
|
155
|
+
cursor: ${({ onClick }) => onClick ? "pointer" : "default"};
|
|
156
|
+
|
|
157
|
+
&:hover {
|
|
158
|
+
background: ${({ disabled }) => disabled ? colorTokens.neutral150 : colorTokens.neutral200};
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
&:disabled {
|
|
162
|
+
cursor: not-allowed;
|
|
163
|
+
opacity: 0.5;
|
|
164
|
+
}
|
|
165
|
+
`;
|
|
166
|
+
var TableButton = (_a) => {
|
|
167
|
+
var _b = _a, { children, leftSource, rightSource } = _b, buttonProps = __objRest(_b, ["children", "leftSource", "rightSource"]);
|
|
168
|
+
return /* @__PURE__ */ jsxs(TableBtn, __spreadProps(__spreadValues({}, buttonProps), { children: [
|
|
169
|
+
leftSource && leftSource,
|
|
170
|
+
/* @__PURE__ */ jsx(Text, { typography: "body2_500", lineClamp: 2, children }),
|
|
171
|
+
rightSource && rightSource
|
|
172
|
+
] }));
|
|
173
|
+
};
|
|
174
|
+
var TableBadge = ({ children }) => {
|
|
175
|
+
return /* @__PURE__ */ jsx(StackContainer, { radius: "borderRadius04", background: "neutral150", padding: "2px 4px", children: /* @__PURE__ */ jsx(Text, { typography: "body2_400", children }) });
|
|
176
|
+
};
|
|
123
177
|
var TableContext = createContext(void 0);
|
|
124
178
|
var useTable = () => {
|
|
125
179
|
const context = useContext(TableContext);
|
|
@@ -129,7 +183,7 @@ var useTable = () => {
|
|
|
129
183
|
return context;
|
|
130
184
|
};
|
|
131
185
|
var TableProvider = TableContext.Provider;
|
|
132
|
-
var TableContainer =
|
|
186
|
+
var TableContainer = styled3.div`
|
|
133
187
|
border: ${({ hasToolbar }) => !hasToolbar && `1px solid ${colorTokens.neutral200}`};
|
|
134
188
|
border-radius: 8px;
|
|
135
189
|
background-color: ${colorTokens.neutral0};
|
|
@@ -163,134 +217,169 @@ var TableContainer = styled2.div`
|
|
|
163
217
|
}
|
|
164
218
|
}
|
|
165
219
|
`;
|
|
166
|
-
var TableHeader =
|
|
167
|
-
color: ${colorTokens.neutral400};
|
|
220
|
+
var TableHeader = styled3.thead`
|
|
168
221
|
background-color: ${colorTokens.neutral100};
|
|
169
|
-
font-size: 13px;
|
|
170
|
-
font-weight: 400;
|
|
171
|
-
line-height: 16px;
|
|
172
222
|
|
|
173
223
|
tr {
|
|
174
224
|
border-radius: 8px 8px 0 0;
|
|
175
225
|
}
|
|
176
226
|
|
|
177
|
-
th {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
227
|
+
th:last-of-type::after {
|
|
228
|
+
display: none;
|
|
229
|
+
}
|
|
230
|
+
`;
|
|
231
|
+
var TableRow = styled3.tr`
|
|
232
|
+
&.clickable[data-has-pinned='true']:hover td {
|
|
182
233
|
background-color: ${colorTokens.neutral100};
|
|
183
|
-
|
|
184
|
-
// 일반 컬럼의 border를 가상 요소로 처리
|
|
185
|
-
&::after {
|
|
186
|
-
content: '';
|
|
187
|
-
position: absolute;
|
|
188
|
-
top: 0;
|
|
189
|
-
right: 0;
|
|
190
|
-
height: 100%;
|
|
191
|
-
width: 1px;
|
|
192
|
-
background-color: ${colorTokens.neutral200};
|
|
193
|
-
pointer-events: none;
|
|
194
|
-
}
|
|
234
|
+
}
|
|
195
235
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
236
|
+
&.clickable:hover td {
|
|
237
|
+
background-color: ${colorTokens.neutral400_5};
|
|
238
|
+
cursor: pointer;
|
|
199
239
|
|
|
200
|
-
|
|
240
|
+
/* neutral400_5 컬럼의 경우 호버 시 neutral150 컬러 적용 */
|
|
241
|
+
&[data-has-custom-style='true'] {
|
|
242
|
+
position: relative;
|
|
201
243
|
&::after {
|
|
202
244
|
content: '';
|
|
203
245
|
position: absolute;
|
|
204
246
|
top: 0;
|
|
205
247
|
right: 0;
|
|
206
|
-
height: 100%;
|
|
207
|
-
width: 1px;
|
|
208
|
-
background-color: ${colorTokens.neutral200};
|
|
209
|
-
pointer-events: none;
|
|
210
|
-
display: block;
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
// Add bottom border for spanning headers to make them visually distinct
|
|
214
|
-
&::before {
|
|
215
|
-
content: '';
|
|
216
|
-
position: absolute;
|
|
217
|
-
bottom: 0;
|
|
218
248
|
left: 0;
|
|
249
|
+
bottom: 0;
|
|
250
|
+
height: 100%;
|
|
219
251
|
width: 100%;
|
|
220
|
-
|
|
221
|
-
background-color: ${colorTokens.neutral200};
|
|
252
|
+
background-color: ${colorTokens.neutral400_5};
|
|
222
253
|
pointer-events: none;
|
|
223
254
|
}
|
|
224
255
|
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
&.clickable[data-has-pinned='true']:hover td[data-no-hover='true'] {
|
|
259
|
+
background-color: ${colorTokens.neutral100};
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
&:hover td[data-no-hover='true'] {
|
|
263
|
+
background-color: ${colorTokens.neutral400_5};
|
|
264
|
+
}
|
|
265
|
+
`;
|
|
266
|
+
var TableHead = styled3.th`
|
|
267
|
+
padding: ${({ sortable, filterable }) => sortable || filterable ? "4px" : "8px"};
|
|
268
|
+
height: 48px;
|
|
269
|
+
font-weight: ${fontWeightTokens.fontWeightRegular};
|
|
270
|
+
line-height: 16px;
|
|
271
|
+
font-size: 13px;
|
|
272
|
+
border-bottom: 1px solid ${colorTokens.neutral200};
|
|
273
|
+
border-right: 1px solid ${colorTokens.neutral200};
|
|
225
274
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
275
|
+
position: relative;
|
|
276
|
+
background-color: ${colorTokens.neutral100};
|
|
277
|
+
vertical-align: middle;
|
|
278
|
+
// 고정 컬럼의 border를 가상 요소로 처리하여 스크롤 시 고정되도록 함
|
|
279
|
+
// borderRight: 'none'이 설정된 경우 ::after를 표시하지 않음
|
|
280
|
+
&[data-pinned='left']:not([data-last-left-pinned='true']):not([data-no-border-right='true']) {
|
|
281
|
+
border-right: none;
|
|
282
|
+
&::after {
|
|
229
283
|
content: '';
|
|
230
284
|
position: absolute;
|
|
231
285
|
top: 0;
|
|
286
|
+
right: 0;
|
|
232
287
|
height: 100%;
|
|
233
288
|
width: 1px;
|
|
234
289
|
background-color: ${colorTokens.neutral200};
|
|
235
290
|
pointer-events: none;
|
|
236
|
-
|
|
237
|
-
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
// Fixed border for multi-column headers (colspan)
|
|
295
|
+
&[colspan] {
|
|
296
|
+
position: relative;
|
|
238
297
|
|
|
239
|
-
|
|
298
|
+
// Ensure the right border is visible for colspan cells
|
|
299
|
+
// *주석 처리한 이유: 가상 요소로 border를 처리하여 바디 셀에 있는 borderRight과 너비가 다름 (borderRight 스타일 새로 추가 및 last-left-pinned 스타일에는 borderRight 스타일 적용 X) 이슈티켓 SH-16534
|
|
300
|
+
/* &::after {
|
|
301
|
+
content: '';
|
|
302
|
+
position: absolute;
|
|
303
|
+
top: 0;
|
|
240
304
|
right: 0;
|
|
241
|
-
|
|
305
|
+
height: 100%;
|
|
306
|
+
width: 1px;
|
|
307
|
+
background-color: ${colorTokens.neutral200};
|
|
308
|
+
pointer-events: none;
|
|
309
|
+
display: block;
|
|
310
|
+
} */
|
|
242
311
|
|
|
243
|
-
|
|
312
|
+
// Add bottom border for spanning headers to make them visually distinct
|
|
313
|
+
/* &::before {
|
|
314
|
+
content: '';
|
|
315
|
+
position: absolute;
|
|
316
|
+
bottom: 0;
|
|
244
317
|
left: 0;
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
318
|
+
width: 100%;
|
|
319
|
+
height: 1px;
|
|
320
|
+
background-color: ${colorTokens.neutral200};
|
|
321
|
+
pointer-events: none;
|
|
322
|
+
} */
|
|
323
|
+
}
|
|
249
324
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
}
|
|
325
|
+
// fixed 컬럼의 border를 별도의 가상 요소로 처리
|
|
326
|
+
/* &[data-pinned='left']::before,
|
|
327
|
+
&[data-pinned='right']::before {
|
|
328
|
+
content: '';
|
|
329
|
+
position: absolute;
|
|
330
|
+
top: 0;
|
|
331
|
+
height: 100%;
|
|
332
|
+
width: 1px;
|
|
333
|
+
background-color: ${colorTokens.neutral200};
|
|
334
|
+
pointer-events: none;
|
|
335
|
+
z-index: 5;
|
|
336
|
+
} */
|
|
263
337
|
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
content: '';
|
|
267
|
-
position: absolute;
|
|
268
|
-
top: 0;
|
|
269
|
-
left: -5px; // border 바깥으로 이동
|
|
270
|
-
height: 100%;
|
|
271
|
-
width: 4px;
|
|
272
|
-
pointer-events: none;
|
|
273
|
-
z-index: 11;
|
|
274
|
-
background: linear-gradient(to left, rgba(0, 0, 0, 0.1), transparent);
|
|
275
|
-
}
|
|
276
|
-
}
|
|
338
|
+
&[data-pinned='left']::before {
|
|
339
|
+
right: 0;
|
|
277
340
|
}
|
|
278
341
|
|
|
279
|
-
|
|
280
|
-
|
|
342
|
+
&[data-pinned='right']::before {
|
|
343
|
+
left: 0;
|
|
281
344
|
}
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
345
|
+
&:last-child {
|
|
346
|
+
border-right: none;
|
|
347
|
+
|
|
348
|
+
/* &[data-first-right-pinned='true'] {
|
|
349
|
+
border-bottom: 1px solid ${colorTokens.neutral200};
|
|
350
|
+
} */
|
|
287
351
|
}
|
|
288
352
|
|
|
289
|
-
|
|
290
|
-
|
|
353
|
+
&[data-last-left-pinned='true'] {
|
|
354
|
+
/* //!고정 컬럼은 borderRight 스타일 적용 X */
|
|
355
|
+
border-right: none;
|
|
356
|
+
&::after {
|
|
357
|
+
content: '';
|
|
358
|
+
position: absolute;
|
|
359
|
+
top: 0;
|
|
360
|
+
right: -4px; // border 바깥으로 이동
|
|
361
|
+
height: 100%;
|
|
362
|
+
width: 4px;
|
|
363
|
+
pointer-events: none;
|
|
364
|
+
z-index: 11;
|
|
365
|
+
background: linear-gradient(to right, rgba(0, 0, 0, 0.1), transparent);
|
|
366
|
+
}
|
|
291
367
|
}
|
|
292
|
-
|
|
293
|
-
|
|
368
|
+
|
|
369
|
+
&[data-first-right-pinned='true'] {
|
|
370
|
+
&::before {
|
|
371
|
+
content: '';
|
|
372
|
+
position: absolute;
|
|
373
|
+
top: 0;
|
|
374
|
+
left: -5px; // border 바깥으로 이동
|
|
375
|
+
height: 100%;
|
|
376
|
+
width: 4px;
|
|
377
|
+
pointer-events: none;
|
|
378
|
+
z-index: 11;
|
|
379
|
+
background: linear-gradient(to left, rgba(0, 0, 0, 0.1), transparent);
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
|
|
294
383
|
.table-head[data-filter-open='true'] {
|
|
295
384
|
background-color: black;
|
|
296
385
|
}
|
|
@@ -298,7 +387,7 @@ var TableHead = styled2.th`
|
|
|
298
387
|
color: ${colorTokens.neutral400};
|
|
299
388
|
}
|
|
300
389
|
`;
|
|
301
|
-
var TableRootContainer =
|
|
390
|
+
var TableRootContainer = styled3.div`
|
|
302
391
|
-ms-overflow-style: none; /* IE and Edge */
|
|
303
392
|
scrollbar-width: none; /* Firefox */
|
|
304
393
|
border: ${({ hasFilterBar, hasToolbar }) => hasFilterBar && !hasToolbar && `1px solid ${colorTokens.neutral200}`};
|
|
@@ -308,9 +397,9 @@ var TableRootContainer = styled2.div`
|
|
|
308
397
|
display: none; /* Chrome, Safari, Opera*/
|
|
309
398
|
}
|
|
310
399
|
`;
|
|
311
|
-
var HeaderTableContainer =
|
|
400
|
+
var HeaderTableContainer = styled3.div`
|
|
312
401
|
width: 100%;
|
|
313
|
-
z-index:
|
|
402
|
+
z-index: 12;
|
|
314
403
|
position: ${({ isSticky }) => isSticky ? "sticky" : ""};
|
|
315
404
|
top: ${({ stickyHeaderMarginTop }) => stickyHeaderMarginTop}px;
|
|
316
405
|
overflow-x: hidden;
|
|
@@ -323,12 +412,12 @@ var HeaderTableContainer = styled2.div`
|
|
|
323
412
|
display: none; /* Chrome, Safari, Opera*/
|
|
324
413
|
}
|
|
325
414
|
`;
|
|
326
|
-
var BodyTableContainer =
|
|
415
|
+
var BodyTableContainer = styled3.div`
|
|
327
416
|
width: 100%;
|
|
328
417
|
overflow-x: scroll;
|
|
329
418
|
-ms-overflow-style: none; /* IE and Edge */
|
|
330
419
|
scrollbar-width: none; /* Firefox */
|
|
331
|
-
border-radius: ${({ hasPagination }) => hasPagination ? "0 0 8px 8px"
|
|
420
|
+
border-radius: ${({ hasPagination, hasFooter }) => hasPagination || hasFooter ? "0" : "0 0 8px 8px"};
|
|
332
421
|
|
|
333
422
|
opacity: ${({ isFetching }) => isFetching && 0.7};
|
|
334
423
|
pointer-events: ${({ isFetching }) => isFetching && "none"};
|
|
@@ -336,7 +425,91 @@ var BodyTableContainer = styled2.div`
|
|
|
336
425
|
display: none; /* Chrome, Safari, Opera*/
|
|
337
426
|
}
|
|
338
427
|
`;
|
|
339
|
-
var
|
|
428
|
+
var FooterTableContainer = styled3.div`
|
|
429
|
+
width: 100%;
|
|
430
|
+
z-index: 11;
|
|
431
|
+
position: ${({ isSticky }) => isSticky ? "sticky" : ""};
|
|
432
|
+
bottom: 0;
|
|
433
|
+
overflow-x: hidden;
|
|
434
|
+
border-radius: ${({ hasPagination, hasHeader }) => {
|
|
435
|
+
if (hasPagination)
|
|
436
|
+
return "0";
|
|
437
|
+
if (hasHeader)
|
|
438
|
+
return "0 0 8px 8px";
|
|
439
|
+
return "0 0 8px 8px";
|
|
440
|
+
}};
|
|
441
|
+
|
|
442
|
+
-ms-overflow-style: none; /* IE and Edge */
|
|
443
|
+
scrollbar-width: none; /* Firefox */
|
|
444
|
+
|
|
445
|
+
&::-webkit-scrollbar {
|
|
446
|
+
display: none; /* Chrome, Safari, Opera*/
|
|
447
|
+
}
|
|
448
|
+
`;
|
|
449
|
+
var TableFooter = styled3.tfoot`
|
|
450
|
+
color: ${colorTokens.neutral400};
|
|
451
|
+
${typographyTokens.body2_400};
|
|
452
|
+
border-top: ${`1px solid ${colorTokens.neutral200}`};
|
|
453
|
+
|
|
454
|
+
tr {
|
|
455
|
+
border-radius: 0 0 8px 8px;
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
td:last-of-type::after {
|
|
459
|
+
display: none;
|
|
460
|
+
}
|
|
461
|
+
`;
|
|
462
|
+
var TableFoot = styled3.td`
|
|
463
|
+
padding: ${({ sortable, filterable }) => sortable || filterable ? "4px" : "8px"};
|
|
464
|
+
height: 48px;
|
|
465
|
+
min-height: 48px;
|
|
466
|
+
font-weight: ${fontWeightTokens.fontWeightRegular};
|
|
467
|
+
line-height: 16px;
|
|
468
|
+
font-size: 13px;
|
|
469
|
+
|
|
470
|
+
position: relative;
|
|
471
|
+
vertical-align: middle;
|
|
472
|
+
|
|
473
|
+
&[data-pinned='left']::before {
|
|
474
|
+
right: 0;
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
&[data-pinned='right']::before {
|
|
478
|
+
left: 0;
|
|
479
|
+
}
|
|
480
|
+
&:last-child {
|
|
481
|
+
border-right: none;
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
&[data-last-left-pinned='true'] {
|
|
485
|
+
&::after {
|
|
486
|
+
content: '';
|
|
487
|
+
position: absolute;
|
|
488
|
+
top: 0;
|
|
489
|
+
right: -4px; // border 바깥으로 이동
|
|
490
|
+
height: 100%;
|
|
491
|
+
width: 4px;
|
|
492
|
+
pointer-events: none;
|
|
493
|
+
z-index: 11;
|
|
494
|
+
background: linear-gradient(to right, rgba(0, 0, 0, 0.1), transparent);
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
&[data-first-right-pinned='true'] {
|
|
499
|
+
&::before {
|
|
500
|
+
content: '';
|
|
501
|
+
position: absolute;
|
|
502
|
+
top: 0;
|
|
503
|
+
left: -5px; // border 바깥으로 이동
|
|
504
|
+
height: 100%;
|
|
505
|
+
width: 4px;
|
|
506
|
+
pointer-events: none;
|
|
507
|
+
z-index: 11;
|
|
508
|
+
background: linear-gradient(to left, rgba(0, 0, 0, 0.1), transparent);
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
`;
|
|
512
|
+
var TableCell = styled3.td`
|
|
340
513
|
position: relative;
|
|
341
514
|
padding: 8px;
|
|
342
515
|
vertical-align: middle;
|
|
@@ -374,7 +547,7 @@ var TableCell = styled2.td`
|
|
|
374
547
|
}
|
|
375
548
|
}
|
|
376
549
|
`;
|
|
377
|
-
var TableBody =
|
|
550
|
+
var TableBody = styled3.tbody`
|
|
378
551
|
color: ${colorTokens.neutral700};
|
|
379
552
|
font-size: 14px;
|
|
380
553
|
position: relative;
|
|
@@ -387,10 +560,6 @@ var TableBody = styled2.tbody`
|
|
|
387
560
|
border-bottom: ${({ innerBorder }) => innerBorder != null ? innerBorder : "1px solid #eaeaea"};
|
|
388
561
|
}
|
|
389
562
|
|
|
390
|
-
&:hover {
|
|
391
|
-
background-color: ${colorTokens.neutral100};
|
|
392
|
-
}
|
|
393
|
-
|
|
394
563
|
// 데이터가 minRows 이하여서 빈칸을 채워준 경우 호버 액션, 커서 액션 모두 OFF
|
|
395
564
|
&[data-empty='true'] {
|
|
396
565
|
border: none; /* 테두리 제거 */
|
|
@@ -416,33 +585,36 @@ var TableBody = styled2.tbody`
|
|
|
416
585
|
}
|
|
417
586
|
}
|
|
418
587
|
`;
|
|
419
|
-
var PaginationWrapper =
|
|
588
|
+
var PaginationWrapper = styled3.div`
|
|
420
589
|
position: relative;
|
|
421
590
|
display: flex;
|
|
422
591
|
justify-content: space-between;
|
|
423
592
|
align-items: center;
|
|
424
593
|
width: 100%;
|
|
425
|
-
height: 56px;
|
|
594
|
+
height: ${({ sizeVar }) => sizeVar === "XS" ? "40px" : "56px"};
|
|
595
|
+
background-color: ${colorTokens.neutral0};
|
|
426
596
|
border-top: ${`1px solid ${colorTokens.neutral200}`};
|
|
427
|
-
|
|
597
|
+
border-radius: ${({ isEndOfPage }) => isEndOfPage && "0 0 12px 12px"};
|
|
428
598
|
.table-pagination {
|
|
429
599
|
border-top: none;
|
|
430
600
|
}
|
|
431
601
|
`;
|
|
432
|
-
var BottomContainer =
|
|
433
|
-
position: sticky;
|
|
602
|
+
var BottomContainer = styled3.div`
|
|
603
|
+
position: ${({ disableStickyFooter }) => disableStickyFooter ? "relative" : "sticky"};
|
|
434
604
|
width: 100%;
|
|
435
|
-
bottom: 0;
|
|
605
|
+
bottom: ${({ disableStickyFooter }) => disableStickyFooter ? "auto" : "0"};
|
|
436
606
|
background-color: ${colorTokens.neutral0};
|
|
437
|
-
z-index:
|
|
607
|
+
z-index: ${({ disableStickyFooter }) => disableStickyFooter ? 1 : 20};
|
|
608
|
+
${({ disableStickyFooter }) => !disableStickyFooter ? "isolation: isolate;" : ""}
|
|
438
609
|
border-radius: ${({ isEndOfPage }) => isEndOfPage && "0 0 12px 12px"};
|
|
439
|
-
border: ${({ hasFilterBar, hasToolbar }) => hasFilterBar && !hasToolbar && `1px solid ${colorTokens.neutral200}`};
|
|
610
|
+
border: ${({ hasFilterBar, hasToolbar, hideBorder }) => !hideBorder && hasFilterBar && !hasToolbar && `1px solid ${colorTokens.neutral200}`};
|
|
440
611
|
border-top: none;
|
|
441
612
|
`;
|
|
442
|
-
var ScrollContainer =
|
|
613
|
+
var ScrollContainer = styled3.div`
|
|
443
614
|
height: 6px;
|
|
444
615
|
position: absolute;
|
|
445
|
-
|
|
616
|
+
//* JIRA SH-18674: 테이블 스크롤바 테이블 바디 내에 위치할 수 있도록 푸터 위로 올림. 없을 때는 푸터에 2px 여유
|
|
617
|
+
bottom: ${({ isPagination }) => isPagination ? "56px" : "2px"};
|
|
446
618
|
width: 100%;
|
|
447
619
|
z-index: 12;
|
|
448
620
|
overflow-x: scroll;
|
|
@@ -457,45 +629,235 @@ var ScrollContainer = styled2.div`
|
|
|
457
629
|
border-radius: 100px;
|
|
458
630
|
}
|
|
459
631
|
`;
|
|
460
|
-
var TableResizer =
|
|
461
|
-
|
|
632
|
+
var TableResizer = styled3.div``;
|
|
633
|
+
styled3.div`
|
|
462
634
|
width: 60px;
|
|
463
635
|
`;
|
|
464
|
-
var PaginationLeftSlot =
|
|
636
|
+
var PaginationLeftSlot = styled3.div`
|
|
465
637
|
position: absolute;
|
|
466
638
|
left: 16px;
|
|
467
639
|
top: 50%;
|
|
468
640
|
transform: translateY(-50%);
|
|
469
641
|
`;
|
|
470
|
-
var
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
642
|
+
var PaginationSizeSelectorSlot = styled3.div`
|
|
643
|
+
[data-shoplflow='Dropdown-Content-Area'],
|
|
644
|
+
[data-shoplflow='Text'],
|
|
645
|
+
[data-shoplflow='Menu'] {
|
|
646
|
+
white-space: nowrap;
|
|
474
647
|
}
|
|
475
648
|
`;
|
|
476
|
-
var
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
649
|
+
var TableFilterBar = memo(
|
|
650
|
+
forwardRef(({ onReset, onRemoveFilter }, ref) => {
|
|
651
|
+
const { table, setFilterValue, hasToolbar, outsideFilters } = useTable();
|
|
652
|
+
const filters = table.getState().columnFilters;
|
|
653
|
+
const prevFiltersRef = useRef();
|
|
654
|
+
const allFilters = [
|
|
655
|
+
...outsideFilters || [],
|
|
656
|
+
...filters.filter((filter) => {
|
|
657
|
+
return !(outsideFilters == null ? void 0 : outsideFilters.some((outsideFilter) => outsideFilter.id === filter.id));
|
|
658
|
+
})
|
|
659
|
+
];
|
|
660
|
+
const onSearch = (value) => {
|
|
661
|
+
setFilterValue(value);
|
|
662
|
+
table.resetColumnFilters();
|
|
663
|
+
};
|
|
664
|
+
const resetFilters = () => {
|
|
665
|
+
table.setColumnFilters([]);
|
|
666
|
+
onReset == null ? void 0 : onReset();
|
|
667
|
+
const resetColumnFilters = (columns) => {
|
|
668
|
+
columns.forEach((column) => {
|
|
669
|
+
var _a, _b;
|
|
670
|
+
if ((_b = (_a = column.columnDef) == null ? void 0 : _a.meta) == null ? void 0 : _b.onFilterChange) {
|
|
671
|
+
column.columnDef.meta.onFilterChange("");
|
|
672
|
+
}
|
|
673
|
+
if (column.columns && column.columns.length > 0) {
|
|
674
|
+
resetColumnFilters(column.columns);
|
|
675
|
+
}
|
|
676
|
+
});
|
|
677
|
+
};
|
|
678
|
+
resetColumnFilters(table.getAllColumns());
|
|
679
|
+
};
|
|
680
|
+
useImperativeHandle(ref, () => ({
|
|
681
|
+
resetFilters
|
|
682
|
+
}));
|
|
683
|
+
const handleRemoveFilter = (columnId, filterValue) => {
|
|
684
|
+
var _a, _b, _c;
|
|
685
|
+
const isOutsideFilter = outsideFilters == null ? void 0 : outsideFilters.some((f) => f.id === columnId && f.value === filterValue);
|
|
686
|
+
if (isOutsideFilter && onRemoveFilter) {
|
|
687
|
+
onRemoveFilter(columnId);
|
|
688
|
+
}
|
|
689
|
+
const column = table.getColumn(columnId);
|
|
690
|
+
const newFilters = table.getState().columnFilters.filter((filter) => filter.id !== columnId);
|
|
691
|
+
table.setColumnFilters(newFilters);
|
|
692
|
+
column == null ? void 0 : column.setFilterValue(void 0);
|
|
693
|
+
(_c = (_b = (_a = column == null ? void 0 : column.columnDef) == null ? void 0 : _a.meta) == null ? void 0 : _b.onFilterChange) == null ? void 0 : _c.call(_b, "");
|
|
694
|
+
};
|
|
695
|
+
const getFilterLabel = (columnId, value) => {
|
|
696
|
+
var _a;
|
|
697
|
+
const outsideFilter = outsideFilters == null ? void 0 : outsideFilters.find((f) => f.id === columnId && f.value === value);
|
|
698
|
+
if (outsideFilter == null ? void 0 : outsideFilter.label) {
|
|
699
|
+
return outsideFilter.label;
|
|
700
|
+
}
|
|
701
|
+
const column = table.getColumn(columnId);
|
|
702
|
+
if (column && ((_a = column.columnDef.meta) == null ? void 0 : _a.filterOptions)) {
|
|
703
|
+
const filterOption = column.columnDef.meta.filterOptions.find((option) => option.value === value);
|
|
704
|
+
if (filterOption) {
|
|
705
|
+
return filterOption.label;
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
return value;
|
|
709
|
+
};
|
|
710
|
+
useEffect(() => {
|
|
711
|
+
var _a;
|
|
712
|
+
const outsideFilterIds = [...new Set((_a = outsideFilters == null ? void 0 : outsideFilters.map((f) => f.id)) != null ? _a : [])];
|
|
713
|
+
const tableFilters = table.getState().columnFilters;
|
|
714
|
+
const validTableFilters = tableFilters.filter((f) => !outsideFilterIds.includes(f.id));
|
|
715
|
+
if (!isEqual(prevFiltersRef.current, validTableFilters)) {
|
|
716
|
+
prevFiltersRef.current = validTableFilters;
|
|
717
|
+
table.setColumnFilters(validTableFilters);
|
|
718
|
+
}
|
|
719
|
+
outsideFilterIds.forEach((columnId) => {
|
|
720
|
+
const column = table.getColumn(columnId);
|
|
721
|
+
if (column && column.getFilterValue() != null && column.getFilterValue() !== "") {
|
|
722
|
+
column.setFilterValue(void 0);
|
|
723
|
+
}
|
|
724
|
+
});
|
|
725
|
+
}, [outsideFilters, table]);
|
|
726
|
+
const _allFilters = allFilters.filter((filter) => filter.value !== "ALL");
|
|
727
|
+
return /* @__PURE__ */ jsx(Fragment, { children: _allFilters.length > 0 && /* @__PURE__ */ jsxs(
|
|
728
|
+
StackContainer.Horizontal,
|
|
729
|
+
{
|
|
730
|
+
width: "100%",
|
|
731
|
+
align: "center",
|
|
732
|
+
padding: hasToolbar ? "0px 16px 8px" : "0px 0px 8px 0px",
|
|
733
|
+
spacing: "spacing08",
|
|
734
|
+
"data-component": "table-filter-bar",
|
|
735
|
+
children: [
|
|
736
|
+
/* @__PURE__ */ jsx(
|
|
737
|
+
IconButton,
|
|
738
|
+
{
|
|
739
|
+
sizeVar: "XS",
|
|
740
|
+
styleVar: "GHOST",
|
|
741
|
+
onClick: () => {
|
|
742
|
+
resetFilters();
|
|
743
|
+
if (filters) {
|
|
744
|
+
onSearch("");
|
|
745
|
+
}
|
|
746
|
+
},
|
|
747
|
+
"data-component": "reset-button",
|
|
748
|
+
children: /* @__PURE__ */ jsx(Icon, { iconSource: RefreshIcon, color: "neutral700" })
|
|
749
|
+
}
|
|
750
|
+
),
|
|
751
|
+
allFilters.map((filter) => {
|
|
752
|
+
const filterValueString = filter.value;
|
|
753
|
+
const filterLabel = getFilterLabel(filter.id, filterValueString);
|
|
754
|
+
const truncatedLabel = filterLabel.length > 50 ? `${filterLabel.slice(0, 50)}...` : filterLabel;
|
|
755
|
+
return /* @__PURE__ */ jsx(
|
|
756
|
+
Tag,
|
|
757
|
+
{
|
|
758
|
+
sizeVar: "XS",
|
|
759
|
+
styleVar: "TINT",
|
|
760
|
+
color: "neutral600",
|
|
761
|
+
background: "neutral150",
|
|
762
|
+
radius: true,
|
|
763
|
+
rightSource: /* @__PURE__ */ jsx(
|
|
764
|
+
Icon,
|
|
765
|
+
{
|
|
766
|
+
iconSource: CloseSmallIcon,
|
|
767
|
+
sizeVar: "XS",
|
|
768
|
+
color: "neutral350",
|
|
769
|
+
onClick: () => handleRemoveFilter(filter.id, filterValueString),
|
|
770
|
+
style: { cursor: "pointer" },
|
|
771
|
+
"data-component": "filter-tag-delete-button",
|
|
772
|
+
role: "button"
|
|
773
|
+
}
|
|
774
|
+
),
|
|
775
|
+
children: /* @__PURE__ */ jsx(Text, { typography: "caption_400", color: "neutral600", lineClamp: 1, children: truncatedLabel })
|
|
776
|
+
},
|
|
777
|
+
`${filter.id}-${filterValueString}`
|
|
778
|
+
);
|
|
779
|
+
})
|
|
780
|
+
]
|
|
781
|
+
}
|
|
782
|
+
) });
|
|
783
|
+
})
|
|
784
|
+
);
|
|
785
|
+
var TableEmpty = ({ children, minHeight }) => {
|
|
786
|
+
return /* @__PURE__ */ jsx(StackContainer, { width: "100%", minHeight, height: "max-content", align: "center", justify: "center", children });
|
|
787
|
+
};
|
|
788
|
+
|
|
789
|
+
// src/components/Table/utils/getColumnActiveHoverDataAttribute.ts
|
|
790
|
+
function getColumnActiveHoverDataAttribute(activeHover, rowOriginal) {
|
|
791
|
+
if (activeHover === void 0)
|
|
792
|
+
return void 0;
|
|
793
|
+
const enabled = typeof activeHover === "function" ? activeHover(rowOriginal) : activeHover;
|
|
794
|
+
return enabled ? "true" : void 0;
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
// src/components/Table/utils/getTableHeadSortModel.ts
|
|
798
|
+
function getTableHeadSortModel(header) {
|
|
799
|
+
var _a, _b;
|
|
800
|
+
const meta = header.column.columnDef.meta;
|
|
801
|
+
const hasChildColumns = ((_b = (_a = header.column.columns) == null ? void 0 : _a.length) != null ? _b : 0) > 0;
|
|
802
|
+
if ((meta == null ? void 0 : meta.delegateSortToSingleLeaf) === true && hasChildColumns) {
|
|
803
|
+
const leafColumns = header.column.getLeafColumns();
|
|
804
|
+
if (leafColumns.length === 1) {
|
|
805
|
+
return {
|
|
806
|
+
showSortMenu: true,
|
|
807
|
+
sortColumn: leafColumns[0]
|
|
808
|
+
};
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
return {
|
|
812
|
+
showSortMenu: header.column.getCanSort(),
|
|
813
|
+
sortColumn: header.column
|
|
814
|
+
};
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
// src/components/Table/utils/resolveBodyRowStyle.ts
|
|
818
|
+
var DEFAULT_TABLE_BODY_ROW_HEIGHT_PX = 60;
|
|
819
|
+
var parseCssSizeToPx = (value) => {
|
|
820
|
+
if (typeof value === "number" && Number.isFinite(value)) {
|
|
821
|
+
return value;
|
|
822
|
+
}
|
|
823
|
+
if (typeof value !== "string") {
|
|
824
|
+
return void 0;
|
|
825
|
+
}
|
|
826
|
+
const parsed = Number.parseInt(value, 10);
|
|
827
|
+
if (Number.isNaN(parsed)) {
|
|
828
|
+
return void 0;
|
|
829
|
+
}
|
|
830
|
+
return parsed;
|
|
831
|
+
};
|
|
832
|
+
var resolveBodyRowCss = (bodyRowStyle, rowIndex, row) => {
|
|
833
|
+
if (typeof bodyRowStyle === "function") {
|
|
834
|
+
if (rowIndex === void 0) {
|
|
835
|
+
return void 0;
|
|
836
|
+
}
|
|
837
|
+
return bodyRowStyle(rowIndex, row);
|
|
838
|
+
}
|
|
839
|
+
return bodyRowStyle;
|
|
840
|
+
};
|
|
841
|
+
var resolveHeightPx = (style) => {
|
|
842
|
+
const fromHeight = parseCssSizeToPx(style.height);
|
|
843
|
+
if (fromHeight !== void 0) {
|
|
844
|
+
return fromHeight;
|
|
845
|
+
}
|
|
846
|
+
const fromMinHeight = parseCssSizeToPx(style.minHeight);
|
|
847
|
+
if (fromMinHeight !== void 0) {
|
|
848
|
+
return fromMinHeight;
|
|
849
|
+
}
|
|
850
|
+
return DEFAULT_TABLE_BODY_ROW_HEIGHT_PX;
|
|
851
|
+
};
|
|
852
|
+
var resolveBodyRowStyle = (bodyRowStyle, rowIndex, row) => {
|
|
853
|
+
if (!bodyRowStyle) {
|
|
854
|
+
return { heightPx: DEFAULT_TABLE_BODY_ROW_HEIGHT_PX };
|
|
855
|
+
}
|
|
856
|
+
const style = resolveBodyRowCss(bodyRowStyle, rowIndex, row);
|
|
857
|
+
if (!style) {
|
|
858
|
+
return { heightPx: DEFAULT_TABLE_BODY_ROW_HEIGHT_PX };
|
|
859
|
+
}
|
|
860
|
+
return { style, heightPx: resolveHeightPx(style) };
|
|
499
861
|
};
|
|
500
862
|
|
|
501
863
|
// src/components/Table/utils/index.ts
|
|
@@ -516,461 +878,159 @@ var PAGE_SIZE = [
|
|
|
516
878
|
{ key: "50", label: "50" },
|
|
517
879
|
{ key: "100", label: "100" }
|
|
518
880
|
];
|
|
519
|
-
var
|
|
881
|
+
var FilterMenu = ({ header, onFilterChange, triggerWidth }) => {
|
|
882
|
+
var _a;
|
|
883
|
+
const { outsideFilters } = useTable();
|
|
884
|
+
const columnFilterValue = header.column.getFilterValue();
|
|
885
|
+
const meta = (_a = header.column.columnDef.meta) != null ? _a : {};
|
|
886
|
+
const { filterOptions, filterMenuWidth = "trigger" } = meta;
|
|
887
|
+
const [maxLabelWidth, setMaxLabelWidth] = useState(0);
|
|
888
|
+
const measureRefs = useRef([]);
|
|
889
|
+
const outsideFilterValues = outsideFilters == null ? void 0 : outsideFilters.filter((filter) => filter.id === header.column.id).map((filter) => filter.value);
|
|
890
|
+
const activeFilterValues = outsideFilterValues && outsideFilterValues.length > 0 ? outsideFilterValues : columnFilterValue != null && columnFilterValue !== "" ? [String(columnFilterValue)] : [];
|
|
520
891
|
useEffect(() => {
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
};
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
const [isEndOfPage, setIsEndOfPage] = useState(false);
|
|
542
|
-
const handleScroll = useCallback(() => {
|
|
543
|
-
if (!headerRef.current || !bodyRef.current || !tableScrollRef.current) {
|
|
544
|
-
return;
|
|
892
|
+
var _a2;
|
|
893
|
+
const count = (_a2 = filterOptions == null ? void 0 : filterOptions.length) != null ? _a2 : 0;
|
|
894
|
+
const widths = measureRefs.current.slice(0, count).map((ref) => {
|
|
895
|
+
var _a3;
|
|
896
|
+
return (_a3 = ref == null ? void 0 : ref.offsetWidth) != null ? _a3 : 0;
|
|
897
|
+
});
|
|
898
|
+
setMaxLabelWidth(widths.length ? Math.max(...widths, 0) : 0);
|
|
899
|
+
}, [filterOptions]);
|
|
900
|
+
const handleFilterChange = (value) => {
|
|
901
|
+
const isCurrentlySelected = activeFilterValues.includes(value);
|
|
902
|
+
if (isCurrentlySelected) {
|
|
903
|
+
header.column.setFilterValue("");
|
|
904
|
+
if (onFilterChange) {
|
|
905
|
+
onFilterChange("");
|
|
906
|
+
}
|
|
907
|
+
} else {
|
|
908
|
+
header.column.setFilterValue(value);
|
|
909
|
+
if (onFilterChange) {
|
|
910
|
+
onFilterChange(value);
|
|
911
|
+
}
|
|
545
912
|
}
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
}
|
|
550
|
-
const
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
const newPage = typeof updater === "function" ? updater(pageIndex) : updater;
|
|
565
|
-
table.setPageIndex(newPage);
|
|
566
|
-
setCurrentPage == null ? void 0 : setCurrentPage({ pageIndex: newPage, pageSize });
|
|
567
|
-
},
|
|
568
|
-
[pageIndex, pageSize, table, setCurrentPage]
|
|
569
|
-
);
|
|
570
|
-
const handlePageSizeChange = useCallback(
|
|
571
|
-
(value) => {
|
|
572
|
-
const newSize = Number(value);
|
|
573
|
-
table.setPageSize(newSize);
|
|
574
|
-
table.setPageIndex(0);
|
|
575
|
-
setCurrentPage == null ? void 0 : setCurrentPage({ pageIndex: 0, pageSize: newSize });
|
|
576
|
-
},
|
|
577
|
-
[table, setCurrentPage]
|
|
578
|
-
);
|
|
579
|
-
const TableColumns = () => /* @__PURE__ */ jsx("colgroup", { children: table.getAllColumns().map((column) => {
|
|
580
|
-
const size = column.columnDef.size;
|
|
581
|
-
const minSize = column.columnDef.minSize;
|
|
582
|
-
const maxSize = column.columnDef.maxSize;
|
|
583
|
-
const style = size === 0 ? { width: "100%" } : {
|
|
584
|
-
width: `${size}px`,
|
|
585
|
-
minWidth: `${minSize}px`,
|
|
586
|
-
maxWidth: `${maxSize}px`
|
|
587
|
-
};
|
|
588
|
-
return /* @__PURE__ */ jsx("col", { style }, column.id);
|
|
589
|
-
}) });
|
|
590
|
-
useEffect(() => {
|
|
591
|
-
table.setPageSize(defaultPageSize);
|
|
592
|
-
}, [defaultPageSize, table]);
|
|
593
|
-
useEffect(() => {
|
|
594
|
-
table.setPageIndex(currentPage != null ? currentPage : 0);
|
|
595
|
-
}, [table, currentPage]);
|
|
596
|
-
return /* @__PURE__ */ jsxs(BottomContainer, { ref: footerRef, isEndOfPage, hasFilterBar, hasToolbar, children: [
|
|
597
|
-
/* @__PURE__ */ jsx(ScrollContainer, { ref: tableScrollRef, onScroll: handleScroll, children: /* @__PURE__ */ jsx("table", { style: { width: table.getTotalSize() || "100%", height: "6px", tableLayout: "fixed" }, children: /* @__PURE__ */ jsx(TableColumns, {}) }) }),
|
|
598
|
-
/* @__PURE__ */ jsxs(PaginationWrapper, { children: [
|
|
599
|
-
/* @__PURE__ */ jsx(PaginationLeftSlot, { children }),
|
|
600
|
-
/* @__PURE__ */ jsx(
|
|
601
|
-
Pagination,
|
|
602
|
-
{
|
|
603
|
-
pageSize: `${pageSize}`,
|
|
604
|
-
currentPage: pageIndex,
|
|
605
|
-
itemsTotalCount: total,
|
|
606
|
-
totalCount: Math.ceil(total / Number(pageSize)),
|
|
607
|
-
previousPage: () => handlePageChange(pageIndex - 1),
|
|
608
|
-
nextPage: () => handlePageChange(pageIndex + 1),
|
|
609
|
-
sizeVar,
|
|
610
|
-
style: { paddingInline: "16px" },
|
|
611
|
-
gotoPage: handlePageChange,
|
|
612
|
-
rightSource: notSizeOption ? /* @__PURE__ */ jsx(EmptySource, {}) : /* @__PURE__ */ jsx(
|
|
613
|
-
Pagination.SizeSelector,
|
|
614
|
-
{
|
|
615
|
-
data: pageSizeList.map((item) => ({ label: item.label, value: item.key })),
|
|
616
|
-
pageSize: `${pageSize}`,
|
|
617
|
-
setPageSize: handlePageSizeChange
|
|
618
|
-
}
|
|
619
|
-
)
|
|
913
|
+
};
|
|
914
|
+
if (!header.column.getCanFilter()) {
|
|
915
|
+
return null;
|
|
916
|
+
}
|
|
917
|
+
const menuWidth = filterMenuWidth === "auto" && maxLabelWidth > triggerWidth ? "100%" : `${triggerWidth}px`;
|
|
918
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
919
|
+
/* @__PURE__ */ jsx(
|
|
920
|
+
"div",
|
|
921
|
+
{
|
|
922
|
+
style: {
|
|
923
|
+
position: "absolute",
|
|
924
|
+
left: "-9999px",
|
|
925
|
+
top: 0,
|
|
926
|
+
visibility: "hidden",
|
|
927
|
+
pointerEvents: "none",
|
|
928
|
+
display: "flex",
|
|
929
|
+
flexDirection: "column",
|
|
930
|
+
alignItems: "flex-start"
|
|
620
931
|
},
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
932
|
+
children: filterOptions == null ? void 0 : filterOptions.map((option, idx) => /* @__PURE__ */ jsx(
|
|
933
|
+
Text,
|
|
934
|
+
{
|
|
935
|
+
typography: "body1_400",
|
|
936
|
+
ref: (el) => measureRefs.current[idx] = el,
|
|
937
|
+
style: { whiteSpace: "nowrap" },
|
|
938
|
+
children: option.label
|
|
939
|
+
},
|
|
940
|
+
option.value
|
|
941
|
+
))
|
|
942
|
+
}
|
|
943
|
+
),
|
|
944
|
+
/* @__PURE__ */ jsx(
|
|
945
|
+
StackContainer.Vertical,
|
|
946
|
+
{
|
|
947
|
+
padding: "4px",
|
|
948
|
+
radius: "borderRadius04",
|
|
949
|
+
background: "neutral0",
|
|
950
|
+
width: menuWidth,
|
|
951
|
+
style: { boxShadow: "0px 8px 16px 0px rgba(0, 0, 0, 0.12)" },
|
|
952
|
+
onWheel: (e) => e.stopPropagation(),
|
|
953
|
+
onScroll: (e) => e.stopPropagation(),
|
|
954
|
+
children: /* @__PURE__ */ jsx(ScrollArea, { autoHeight: true, autoHeightMax: 240, children: /* @__PURE__ */ jsx("ul", { children: filterOptions == null ? void 0 : filterOptions.map((option) => /* @__PURE__ */ jsx(
|
|
955
|
+
Menu,
|
|
956
|
+
{
|
|
957
|
+
isSelected: activeFilterValues.includes(option.value),
|
|
958
|
+
onClick: () => handleFilterChange(option.value),
|
|
959
|
+
leftSource: option.icon,
|
|
960
|
+
children: /* @__PURE__ */ jsx(Text, { typography: "body1_400", lineClamp: 2, children: option.label })
|
|
961
|
+
},
|
|
962
|
+
option.value
|
|
963
|
+
)) }) })
|
|
964
|
+
}
|
|
965
|
+
)
|
|
624
966
|
] });
|
|
625
967
|
};
|
|
626
|
-
var
|
|
627
|
-
|
|
628
|
-
const
|
|
629
|
-
const
|
|
630
|
-
const
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
const resetColumnFilters = (columns) => {
|
|
637
|
-
columns.forEach((column) => {
|
|
638
|
-
var _a, _b;
|
|
639
|
-
if ((_b = (_a = column.columnDef) == null ? void 0 : _a.meta) == null ? void 0 : _b.onFilterChange) {
|
|
640
|
-
column.columnDef.meta.onFilterChange("");
|
|
641
|
-
}
|
|
642
|
-
if (column.columns && column.columns.length > 0) {
|
|
643
|
-
resetColumnFilters(column.columns);
|
|
644
|
-
}
|
|
645
|
-
});
|
|
646
|
-
};
|
|
647
|
-
resetColumnFilters(table.getAllColumns());
|
|
648
|
-
};
|
|
649
|
-
const handleRemoveFilter = (columnId, filterValue) => {
|
|
650
|
-
var _a, _b, _c, _d;
|
|
651
|
-
const newFilters = table.getState().columnFilters.filter((filter) => !(filter.id === columnId && filter.value === filterValue));
|
|
652
|
-
table.setColumnFilters(newFilters);
|
|
653
|
-
(_d = (_c = (_b = (_a = table.getColumn(columnId)) == null ? void 0 : _a.columnDef) == null ? void 0 : _b.meta) == null ? void 0 : _c.onFilterChange) == null ? void 0 : _d.call(_c, "");
|
|
654
|
-
};
|
|
655
|
-
const getFilterLabel = (columnId, value) => {
|
|
656
|
-
var _a;
|
|
657
|
-
const column = table.getColumn(columnId);
|
|
658
|
-
if (!column || !((_a = column.columnDef.meta) == null ? void 0 : _a.filterOptions)) {
|
|
659
|
-
return value;
|
|
968
|
+
var SortMenu = ({ onSortChange, header, sortColumn, triggerWidth }) => {
|
|
969
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
970
|
+
const column = sortColumn != null ? sortColumn : header.column;
|
|
971
|
+
const sortLabels = (_d = (_c = (_a = header.column.columnDef.meta) == null ? void 0 : _a.sortLabels) != null ? _c : (_b = column.columnDef.meta) == null ? void 0 : _b.sortLabels) != null ? _d : ["\uC815\uB82C \uD574\uC81C", "\uC624\uB984\uCC28\uC21C", "\uB0B4\uB9BC\uCC28\uC21C"];
|
|
972
|
+
const currentSort = column.getIsSorted();
|
|
973
|
+
const handleSortChange = (value) => {
|
|
974
|
+
if (value === void 0) {
|
|
975
|
+
column.clearSorting();
|
|
976
|
+
} else {
|
|
977
|
+
column.toggleSorting(value === "desc", false);
|
|
660
978
|
}
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
};
|
|
664
|
-
useEffect(() => {
|
|
665
|
-
const validFilters = outsideFilters == null ? void 0 : outsideFilters.filter((item) => item.value !== void 0 && item.value !== "").map((item) => ({ id: item.id, value: item.value }));
|
|
666
|
-
if (!isEqual(prevFiltersRef.current, validFilters)) {
|
|
667
|
-
prevFiltersRef.current = validFilters;
|
|
668
|
-
if (validFilters && validFilters.length > 0) {
|
|
669
|
-
table.setColumnFilters(validFilters);
|
|
670
|
-
} else {
|
|
671
|
-
table.setColumnFilters([]);
|
|
672
|
-
}
|
|
979
|
+
if (onSortChange) {
|
|
980
|
+
onSortChange(value);
|
|
673
981
|
}
|
|
674
|
-
}
|
|
675
|
-
|
|
676
|
-
|
|
982
|
+
};
|
|
983
|
+
const delegatedSingleLeaf = ((_e = header.column.columnDef.meta) == null ? void 0 : _e.delegateSortToSingleLeaf) === true && ((_g = (_f = header.column.columns) == null ? void 0 : _f.length) != null ? _g : 0) > 0 && header.column.getLeafColumns().length === 1;
|
|
984
|
+
if (!delegatedSingleLeaf && !column.getCanSort()) {
|
|
985
|
+
return null;
|
|
986
|
+
}
|
|
987
|
+
return /* @__PURE__ */ jsxs(
|
|
988
|
+
StackContainer.Vertical,
|
|
677
989
|
{
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
990
|
+
padding: "4px",
|
|
991
|
+
radius: "borderRadius04",
|
|
992
|
+
background: "neutral0",
|
|
993
|
+
width: `${triggerWidth}px`,
|
|
994
|
+
style: { boxShadow: "0px 8px 16px 0px rgba(0, 0, 0, 0.12)" },
|
|
995
|
+
as: "ul",
|
|
682
996
|
children: [
|
|
683
997
|
/* @__PURE__ */ jsx(
|
|
684
|
-
|
|
998
|
+
Menu,
|
|
685
999
|
{
|
|
686
|
-
sizeVar: "
|
|
687
|
-
|
|
688
|
-
onClick: () =>
|
|
689
|
-
|
|
690
|
-
if (filters) {
|
|
691
|
-
onSearch("");
|
|
692
|
-
}
|
|
693
|
-
},
|
|
694
|
-
children: /* @__PURE__ */ jsx(Icon, { iconSource: RefreshIcon, color: "neutral700" })
|
|
1000
|
+
leftSource: /* @__PURE__ */ jsx(Icon, { iconSource: MoreIcon, sizeVar: "S" }),
|
|
1001
|
+
isSelected: !currentSort,
|
|
1002
|
+
onClick: () => handleSortChange(void 0),
|
|
1003
|
+
children: sortLabels[0]
|
|
695
1004
|
}
|
|
696
1005
|
),
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
style: { cursor: "pointer" }
|
|
716
|
-
}
|
|
717
|
-
),
|
|
718
|
-
children: /* @__PURE__ */ jsx(Text, { typography: "caption_400", color: "neutral600", children: filterLabel })
|
|
719
|
-
},
|
|
720
|
-
`${filter.id}-${filterValueString}`
|
|
721
|
-
);
|
|
722
|
-
})
|
|
1006
|
+
/* @__PURE__ */ jsx(
|
|
1007
|
+
Menu,
|
|
1008
|
+
{
|
|
1009
|
+
leftSource: /* @__PURE__ */ jsx(Icon, { iconSource: AscIcon, sizeVar: "S" }),
|
|
1010
|
+
isSelected: currentSort === "asc",
|
|
1011
|
+
onClick: () => handleSortChange("asc"),
|
|
1012
|
+
children: sortLabels[1]
|
|
1013
|
+
}
|
|
1014
|
+
),
|
|
1015
|
+
/* @__PURE__ */ jsx(
|
|
1016
|
+
Menu,
|
|
1017
|
+
{
|
|
1018
|
+
leftSource: /* @__PURE__ */ jsx(Icon, { iconSource: DescIcon, sizeVar: "S" }),
|
|
1019
|
+
isSelected: currentSort === "desc",
|
|
1020
|
+
onClick: () => handleSortChange("desc"),
|
|
1021
|
+
children: sortLabels[2]
|
|
1022
|
+
}
|
|
1023
|
+
)
|
|
723
1024
|
]
|
|
724
1025
|
}
|
|
725
|
-
) });
|
|
726
|
-
});
|
|
727
|
-
var Table = ({
|
|
728
|
-
data,
|
|
729
|
-
columns,
|
|
730
|
-
columnResizing = false,
|
|
731
|
-
children,
|
|
732
|
-
manualPagination = false,
|
|
733
|
-
manualFiltering = false,
|
|
734
|
-
manualSorting = true,
|
|
735
|
-
selectedRows = [],
|
|
736
|
-
onSelectedRowsChange,
|
|
737
|
-
onClickRow
|
|
738
|
-
}) => {
|
|
739
|
-
const [sorting, setSorting] = useState([]);
|
|
740
|
-
const [columnFilters, setColumnFilters] = useState([]);
|
|
741
|
-
const [globalFilter, setGlobalFilter] = useState([]);
|
|
742
|
-
const [columnVisibility, setColumnVisibility] = useState({});
|
|
743
|
-
const [columnPinning, setColumnPinning] = useState({});
|
|
744
|
-
const [rowSelection, setRowSelection] = useState({});
|
|
745
|
-
const [filterValue, setFilterValue] = useState("");
|
|
746
|
-
const visibleColumns = useMemo(() => columns.filter((column) => {
|
|
747
|
-
var _a;
|
|
748
|
-
return !((_a = column.meta) == null ? void 0 : _a.hiddenColumn);
|
|
749
|
-
}), [columns]);
|
|
750
|
-
const table = useReactTable({
|
|
751
|
-
data,
|
|
752
|
-
columns: visibleColumns,
|
|
753
|
-
columnResizeMode: "onChange",
|
|
754
|
-
initialState: {
|
|
755
|
-
pagination: {
|
|
756
|
-
pageSize: 100
|
|
757
|
-
}
|
|
758
|
-
},
|
|
759
|
-
state: {
|
|
760
|
-
sorting,
|
|
761
|
-
columnFilters,
|
|
762
|
-
globalFilter,
|
|
763
|
-
columnVisibility,
|
|
764
|
-
columnPinning,
|
|
765
|
-
rowSelection
|
|
766
|
-
},
|
|
767
|
-
defaultColumn: {
|
|
768
|
-
size: 0,
|
|
769
|
-
// TODO: 필터링 기능 추가 시 props로 옵션 처리
|
|
770
|
-
enableColumnFilter: false,
|
|
771
|
-
enableSorting: false,
|
|
772
|
-
enableResizing: true
|
|
773
|
-
},
|
|
774
|
-
onSortingChange: (updater) => {
|
|
775
|
-
var _a, _b;
|
|
776
|
-
const newSorting = typeof updater === "function" ? updater(table.getState().sorting) : updater;
|
|
777
|
-
setSorting(newSorting);
|
|
778
|
-
if (newSorting.length > 0) {
|
|
779
|
-
const { id, desc } = newSorting[0];
|
|
780
|
-
const column = table.getAllLeafColumns().find((col) => col.id === id);
|
|
781
|
-
(_b = (_a = column == null ? void 0 : column.columnDef.meta) == null ? void 0 : _a.onSortChange) == null ? void 0 : _b.call(_a, desc ? "desc" : "asc");
|
|
782
|
-
} else {
|
|
783
|
-
table.getAllLeafColumns().forEach((column) => {
|
|
784
|
-
var _a2, _b2;
|
|
785
|
-
(_b2 = (_a2 = column.columnDef.meta) == null ? void 0 : _a2.onSortChange) == null ? void 0 : _b2.call(_a2, void 0);
|
|
786
|
-
});
|
|
787
|
-
}
|
|
788
|
-
},
|
|
789
|
-
onColumnFiltersChange: (updater) => {
|
|
790
|
-
const newFilters = typeof updater === "function" ? updater(table.getState().columnFilters) : updater;
|
|
791
|
-
setColumnFilters(newFilters);
|
|
792
|
-
newFilters.forEach((filter) => {
|
|
793
|
-
var _a, _b;
|
|
794
|
-
const column = table.getColumn(filter.id);
|
|
795
|
-
if ((_b = (_a = column == null ? void 0 : column.columnDef) == null ? void 0 : _a.meta) == null ? void 0 : _b.onFilterChange) {
|
|
796
|
-
column.columnDef.meta.onFilterChange(filter.value || "");
|
|
797
|
-
}
|
|
798
|
-
});
|
|
799
|
-
},
|
|
800
|
-
onGlobalFilterChange: (updater) => {
|
|
801
|
-
var _a;
|
|
802
|
-
const newGlobalFilter = typeof updater === "function" ? updater(globalFilter) : updater;
|
|
803
|
-
setGlobalFilter(newGlobalFilter);
|
|
804
|
-
if ((_a = table.options.meta) == null ? void 0 : _a.onGlobalFilterChange) {
|
|
805
|
-
table.options.meta.onGlobalFilterChange(newGlobalFilter || "");
|
|
806
|
-
}
|
|
807
|
-
if (newGlobalFilter) {
|
|
808
|
-
table.getAllLeafColumns().forEach((column) => {
|
|
809
|
-
var _a2;
|
|
810
|
-
if (column.getCanFilter() && ((_a2 = column.columnDef.meta) == null ? void 0 : _a2.onFilterChange)) {
|
|
811
|
-
column.columnDef.meta.onFilterChange(newGlobalFilter);
|
|
812
|
-
}
|
|
813
|
-
});
|
|
814
|
-
}
|
|
815
|
-
},
|
|
816
|
-
onColumnVisibilityChange: setColumnVisibility,
|
|
817
|
-
onColumnPinningChange: setColumnPinning,
|
|
818
|
-
onRowSelectionChange: (updater) => {
|
|
819
|
-
const newSelection = typeof updater === "function" ? updater(rowSelection) : updater;
|
|
820
|
-
setRowSelection(newSelection);
|
|
821
|
-
const newSelectedRows = table.getRowModel().rows.filter((row) => newSelection[row.id]).map((row) => row.original);
|
|
822
|
-
onSelectedRowsChange == null ? void 0 : onSelectedRowsChange(newSelectedRows);
|
|
823
|
-
},
|
|
824
|
-
getCoreRowModel: getCoreRowModel(),
|
|
825
|
-
getFilteredRowModel: getFilteredRowModel(),
|
|
826
|
-
getPaginationRowModel: getPaginationRowModel(),
|
|
827
|
-
getSortedRowModel: getSortedRowModel(),
|
|
828
|
-
enableColumnResizing: columnResizing,
|
|
829
|
-
manualPagination,
|
|
830
|
-
manualFiltering,
|
|
831
|
-
manualSorting
|
|
832
|
-
});
|
|
833
|
-
const headerRef = useRef(null);
|
|
834
|
-
const bodyRef = useRef(null);
|
|
835
|
-
const footerRef = useRef(null);
|
|
836
|
-
const tableScrollRef = useRef(null);
|
|
837
|
-
const hasToolbar = Children.toArray(children).some((child) => isValidElement(child) && child.type === TableToolbar);
|
|
838
|
-
const hasPagination = Children.toArray(children).some(
|
|
839
|
-
(child) => isValidElement(child) && child.type === TablePagination
|
|
840
|
-
);
|
|
841
|
-
const hasFilterBar = Children.toArray(children).some(
|
|
842
|
-
(child) => isValidElement(child) && child.type === TableFilterBar
|
|
843
|
-
);
|
|
844
|
-
const contextValue = {
|
|
845
|
-
table,
|
|
846
|
-
headerRef,
|
|
847
|
-
bodyRef,
|
|
848
|
-
footerRef,
|
|
849
|
-
tableScrollRef,
|
|
850
|
-
selectedRows,
|
|
851
|
-
onClickRow,
|
|
852
|
-
hasToolbar,
|
|
853
|
-
hasFilterBar,
|
|
854
|
-
hasPagination,
|
|
855
|
-
columnResizing,
|
|
856
|
-
filterValue,
|
|
857
|
-
setFilterValue
|
|
858
|
-
};
|
|
859
|
-
useEffect(() => {
|
|
860
|
-
if (selectedRows.length === 0) {
|
|
861
|
-
table.resetRowSelection();
|
|
862
|
-
}
|
|
863
|
-
}, [onSelectedRowsChange, selectedRows.length, table]);
|
|
864
|
-
return /* @__PURE__ */ jsx(TableContainer, { hasToolbar: hasToolbar || hasFilterBar, children: /* @__PURE__ */ jsx(TableProvider, { value: contextValue, children }) });
|
|
865
|
-
};
|
|
866
|
-
var TableEmpty = ({ children }) => {
|
|
867
|
-
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
868
|
-
};
|
|
869
|
-
var FilterMenu = ({ header, onFilterChange, triggerWidth }) => {
|
|
870
|
-
var _a;
|
|
871
|
-
const columnFilterValue = header.column.getFilterValue();
|
|
872
|
-
const { filterOptions } = (_a = header.column.columnDef.meta) != null ? _a : {};
|
|
873
|
-
const [maxLabelWidth, setMaxLabelWidth] = useState(0);
|
|
874
|
-
const labelRefs = useRef([]);
|
|
875
|
-
useEffect(() => {
|
|
876
|
-
const widths = labelRefs.current.map((ref) => (ref == null ? void 0 : ref.offsetWidth) || 0);
|
|
877
|
-
setMaxLabelWidth(Math.max(...widths, 0));
|
|
878
|
-
}, [filterOptions]);
|
|
879
|
-
const handleFilterChange = (value) => {
|
|
880
|
-
header.column.setFilterValue(value);
|
|
881
|
-
if (onFilterChange) {
|
|
882
|
-
onFilterChange(value);
|
|
883
|
-
}
|
|
884
|
-
};
|
|
885
|
-
if (!header.column.getCanFilter()) {
|
|
886
|
-
return null;
|
|
887
|
-
}
|
|
888
|
-
return /* @__PURE__ */ jsx(
|
|
889
|
-
StackContainer.Vertical,
|
|
890
|
-
{
|
|
891
|
-
padding: "4px",
|
|
892
|
-
radius: "borderRadius04",
|
|
893
|
-
background: "neutral0",
|
|
894
|
-
width: maxLabelWidth > triggerWidth ? "100%" : `${triggerWidth}px`,
|
|
895
|
-
style: { boxShadow: "0px 8px 16px 0px rgba(0, 0, 0, 0.12)" },
|
|
896
|
-
children: /* @__PURE__ */ jsx(ScrollArea, { autoHeight: true, autoHeightMax: 240, children: filterOptions == null ? void 0 : filterOptions.map((option, idx) => /* @__PURE__ */ jsx(
|
|
897
|
-
Menu,
|
|
898
|
-
{
|
|
899
|
-
isSelected: columnFilterValue === option.value,
|
|
900
|
-
onClick: () => handleFilterChange(option.value),
|
|
901
|
-
leftSource: option.icon,
|
|
902
|
-
children: /* @__PURE__ */ jsx(
|
|
903
|
-
Text,
|
|
904
|
-
{
|
|
905
|
-
typography: "body1_400",
|
|
906
|
-
whiteSpace: "nowrap",
|
|
907
|
-
ref: (el) => labelRefs.current[idx] = el,
|
|
908
|
-
children: option.label
|
|
909
|
-
}
|
|
910
|
-
)
|
|
911
|
-
},
|
|
912
|
-
option.value
|
|
913
|
-
)) })
|
|
914
|
-
}
|
|
915
1026
|
);
|
|
916
1027
|
};
|
|
917
|
-
var
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
const handleSortChange = (value) => {
|
|
922
|
-
if (value === void 0) {
|
|
923
|
-
header.column.clearSorting();
|
|
924
|
-
} else {
|
|
925
|
-
header.column.toggleSorting(value === "asc", false);
|
|
926
|
-
}
|
|
927
|
-
if (onSortChange) {
|
|
928
|
-
onSortChange(value);
|
|
929
|
-
}
|
|
930
|
-
};
|
|
931
|
-
if (!header.column.getCanSort()) {
|
|
932
|
-
return null;
|
|
1028
|
+
var SmallIconButton = styled3(IconButton)`
|
|
1029
|
+
svg {
|
|
1030
|
+
width: 12px !important;
|
|
1031
|
+
height: 12px !important;
|
|
933
1032
|
}
|
|
934
|
-
|
|
935
|
-
StackContainer.Vertical,
|
|
936
|
-
{
|
|
937
|
-
padding: "4px",
|
|
938
|
-
radius: "borderRadius04",
|
|
939
|
-
background: "neutral0",
|
|
940
|
-
width: `${triggerWidth}px`,
|
|
941
|
-
style: { boxShadow: "0px 8px 16px 0px rgba(0, 0, 0, 0.12)" },
|
|
942
|
-
children: [
|
|
943
|
-
/* @__PURE__ */ jsx(
|
|
944
|
-
Menu,
|
|
945
|
-
{
|
|
946
|
-
leftSource: /* @__PURE__ */ jsx(Icon, { iconSource: DescIcon, sizeVar: "S" }),
|
|
947
|
-
isSelected: currentSort === "desc",
|
|
948
|
-
onClick: () => handleSortChange("asc"),
|
|
949
|
-
children: sortLabels[0]
|
|
950
|
-
}
|
|
951
|
-
),
|
|
952
|
-
/* @__PURE__ */ jsx(
|
|
953
|
-
Menu,
|
|
954
|
-
{
|
|
955
|
-
leftSource: /* @__PURE__ */ jsx(Icon, { iconSource: AscIcon, sizeVar: "S" }),
|
|
956
|
-
isSelected: currentSort === "asc",
|
|
957
|
-
onClick: () => handleSortChange("desc"),
|
|
958
|
-
children: sortLabels[1]
|
|
959
|
-
}
|
|
960
|
-
),
|
|
961
|
-
/* @__PURE__ */ jsx(
|
|
962
|
-
Menu,
|
|
963
|
-
{
|
|
964
|
-
leftSource: /* @__PURE__ */ jsx(Icon, { iconSource: MoreIcon, sizeVar: "S" }),
|
|
965
|
-
isSelected: !currentSort,
|
|
966
|
-
onClick: () => handleSortChange(void 0),
|
|
967
|
-
children: sortLabels[2]
|
|
968
|
-
}
|
|
969
|
-
)
|
|
970
|
-
]
|
|
971
|
-
}
|
|
972
|
-
);
|
|
973
|
-
};
|
|
1033
|
+
`;
|
|
974
1034
|
var TableHeadTrigger = ({
|
|
975
1035
|
header,
|
|
976
1036
|
uniqueClass,
|
|
@@ -980,8 +1040,9 @@ var TableHeadTrigger = ({
|
|
|
980
1040
|
}) => {
|
|
981
1041
|
var _a, _b;
|
|
982
1042
|
const showFilterMenu = header.column.getCanFilter();
|
|
983
|
-
const showSortMenu = header
|
|
984
|
-
const
|
|
1043
|
+
const { showSortMenu, sortColumn } = getTableHeadSortModel(header);
|
|
1044
|
+
const headerStyle = (_b = (_a = header.column.columnDef.meta) == null ? void 0 : _a.headerProps) == null ? void 0 : _b.style;
|
|
1045
|
+
const currentSort = sortColumn.getIsSorted();
|
|
985
1046
|
let triggerIcon;
|
|
986
1047
|
if (currentSort === "asc") {
|
|
987
1048
|
triggerIcon = AscIcon;
|
|
@@ -994,43 +1055,40 @@ var TableHeadTrigger = ({
|
|
|
994
1055
|
StackContainer.Horizontal,
|
|
995
1056
|
{
|
|
996
1057
|
width: "100%",
|
|
1058
|
+
height: "100%",
|
|
997
1059
|
align: "center",
|
|
998
|
-
style: (
|
|
1060
|
+
style: __spreadValues(__spreadValues({
|
|
1061
|
+
alignItems: "center",
|
|
1062
|
+
boxSizing: "border-box"
|
|
1063
|
+
}, showSortMenu || showFilterMenu ? { justifyContent: "space-between" } : {}), headerStyle),
|
|
999
1064
|
className: uniqueClass,
|
|
1000
1065
|
ref: tableHeadRef,
|
|
1066
|
+
onClick: (e) => {
|
|
1067
|
+
e.stopPropagation();
|
|
1068
|
+
onTriggerClick();
|
|
1069
|
+
},
|
|
1070
|
+
role: "button",
|
|
1001
1071
|
children: [
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
IconButton,
|
|
1072
|
+
/* @__PURE__ */ jsx(
|
|
1073
|
+
Text,
|
|
1005
1074
|
{
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
},
|
|
1012
|
-
children: /* @__PURE__ */ jsx(Icon, { iconSource: triggerIcon, sizeVar: "S", color: "neutral400", className: uniqueClass })
|
|
1075
|
+
typography: "body2_400",
|
|
1076
|
+
color: "neutral400",
|
|
1077
|
+
lineClamp: 2,
|
|
1078
|
+
style: showSortMenu || showFilterMenu ? { flex: 1, minWidth: 0 } : void 0,
|
|
1079
|
+
children: flexRender(header.column.columnDef.header, header.getContext())
|
|
1013
1080
|
}
|
|
1014
1081
|
),
|
|
1015
|
-
|
|
1016
|
-
|
|
1082
|
+
showSortMenu && /* @__PURE__ */ jsx(IconButton, { sizeVar: "XS", styleVar: "GHOST", "data-component": "sort-button", children: /* @__PURE__ */ jsx(Icon, { iconSource: triggerIcon, sizeVar: "S", color: "neutral400", className: uniqueClass }) }),
|
|
1083
|
+
showFilterMenu && /* @__PURE__ */ jsx(SmallIconButton, { sizeVar: "XS", styleVar: "GHOST", className: uniqueClass, "data-component": "filter-button", children: /* @__PURE__ */ jsx(
|
|
1084
|
+
Icon,
|
|
1017
1085
|
{
|
|
1086
|
+
iconSource: isOpen ? UpArrowSolidXsmallIcon : DownArrowSolidXsmallIcon,
|
|
1087
|
+
className: uniqueClass,
|
|
1018
1088
|
sizeVar: "XS",
|
|
1019
|
-
|
|
1020
|
-
onClick: (e) => {
|
|
1021
|
-
e.stopPropagation();
|
|
1022
|
-
onTriggerClick();
|
|
1023
|
-
},
|
|
1024
|
-
children: /* @__PURE__ */ jsx(
|
|
1025
|
-
Icon,
|
|
1026
|
-
{
|
|
1027
|
-
iconSource: isOpen ? UpArrowSolidXsmallIcon : DownArrowSolidXsmallIcon,
|
|
1028
|
-
sizeVar: "XS",
|
|
1029
|
-
color: "neutral400"
|
|
1030
|
-
}
|
|
1031
|
-
)
|
|
1089
|
+
color: "neutral400"
|
|
1032
1090
|
}
|
|
1033
|
-
)
|
|
1091
|
+
) })
|
|
1034
1092
|
]
|
|
1035
1093
|
}
|
|
1036
1094
|
);
|
|
@@ -1038,75 +1096,221 @@ var TableHeadTrigger = ({
|
|
|
1038
1096
|
var TableHeadCell = ({ header, onFilterChange, onSortChange }) => {
|
|
1039
1097
|
const tableHeadRef = useRef(null);
|
|
1040
1098
|
const [triggerWidth, setTriggerWidth] = useState(0);
|
|
1041
|
-
const uniqueClass =
|
|
1042
|
-
|
|
1043
|
-
|
|
1099
|
+
const uniqueClass = useMemo(() => {
|
|
1100
|
+
return `filter-menu-${crypto.randomUUID()}`;
|
|
1101
|
+
}, []);
|
|
1102
|
+
const { isOpen: isPopoverOpen, onClickTrigger: onClickPopoverTrigger } = usePopover({
|
|
1103
|
+
popoverSelector: `.${uniqueClass}`
|
|
1044
1104
|
});
|
|
1105
|
+
const sortModel = getTableHeadSortModel(header);
|
|
1045
1106
|
const showFilterMenu = header.column.getCanFilter();
|
|
1046
|
-
const showSortMenu =
|
|
1107
|
+
const showSortMenu = sortModel.showSortMenu;
|
|
1047
1108
|
const hasInteraction = showFilterMenu || showSortMenu;
|
|
1048
1109
|
const cursorStyle = hasInteraction ? "pointer" : "default";
|
|
1049
1110
|
useEffect(() => {
|
|
1050
1111
|
if (tableHeadRef.current) {
|
|
1051
1112
|
setTriggerWidth(tableHeadRef.current.clientWidth);
|
|
1052
1113
|
}
|
|
1053
|
-
}, [
|
|
1054
|
-
return /* @__PURE__ */ jsxs(
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
{
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
padding: `${(showFilterMenu || showSortMenu) && "8px"}`,
|
|
1066
|
-
borderRadius: `${isOpen ? "6px" : "0px"}`
|
|
1067
|
-
},
|
|
1068
|
-
width: "100%",
|
|
1069
|
-
children: /* @__PURE__ */ jsx(
|
|
1070
|
-
TableHeadTrigger,
|
|
1114
|
+
}, [isPopoverOpen, tableHeadRef]);
|
|
1115
|
+
return /* @__PURE__ */ jsxs(
|
|
1116
|
+
Popper,
|
|
1117
|
+
{
|
|
1118
|
+
offset: { mainAxis: 4, crossAxis: -4 },
|
|
1119
|
+
autoPlacement: { allowedPlacements: ["bottom-start", "bottom-end"] },
|
|
1120
|
+
placement: "bottom-start",
|
|
1121
|
+
strategy: "absolute",
|
|
1122
|
+
middlewares: [shift({ padding: 6 })],
|
|
1123
|
+
children: [
|
|
1124
|
+
/* @__PURE__ */ jsx(
|
|
1125
|
+
Popper.Trigger,
|
|
1071
1126
|
{
|
|
1072
|
-
isOpen,
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1127
|
+
isOpen: isPopoverOpen,
|
|
1128
|
+
"data-expanded": isPopoverOpen,
|
|
1129
|
+
onClick: () => {
|
|
1130
|
+
onClickPopoverTrigger();
|
|
1131
|
+
},
|
|
1132
|
+
style: {
|
|
1133
|
+
cursor: cursorStyle,
|
|
1134
|
+
background: `${(showFilterMenu || showSortMenu) && isPopoverOpen ? colorTokens.neutral400_5 : "transparent"}`,
|
|
1135
|
+
padding: `${(showFilterMenu || showSortMenu) && "4px"}`,
|
|
1136
|
+
borderRadius: `${isPopoverOpen ? "6px" : "0px"}`,
|
|
1137
|
+
display: "flex",
|
|
1138
|
+
alignItems: "center",
|
|
1139
|
+
boxSizing: "border-box",
|
|
1140
|
+
width: "100%",
|
|
1141
|
+
height: "100%",
|
|
1142
|
+
minHeight: "100%"
|
|
1143
|
+
},
|
|
1144
|
+
width: "100%",
|
|
1145
|
+
children: /* @__PURE__ */ jsx(
|
|
1146
|
+
TableHeadTrigger,
|
|
1147
|
+
{
|
|
1148
|
+
isOpen: isPopoverOpen,
|
|
1149
|
+
header,
|
|
1150
|
+
uniqueClass,
|
|
1151
|
+
tableHeadRef,
|
|
1152
|
+
onTriggerClick: () => {
|
|
1153
|
+
onClickPopoverTrigger();
|
|
1154
|
+
}
|
|
1155
|
+
}
|
|
1156
|
+
)
|
|
1077
1157
|
}
|
|
1078
|
-
)
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1158
|
+
),
|
|
1159
|
+
isPopoverOpen && /* @__PURE__ */ jsxs(Popper.Portal, { children: [
|
|
1160
|
+
showFilterMenu && /* @__PURE__ */ jsx(
|
|
1161
|
+
FilterMenu,
|
|
1162
|
+
{
|
|
1163
|
+
header,
|
|
1164
|
+
onFilterChange: (value) => {
|
|
1165
|
+
onFilterChange == null ? void 0 : onFilterChange(value);
|
|
1166
|
+
},
|
|
1167
|
+
triggerWidth: triggerWidth + 16
|
|
1168
|
+
}
|
|
1169
|
+
),
|
|
1170
|
+
showSortMenu && /* @__PURE__ */ jsx(
|
|
1171
|
+
SortMenu,
|
|
1172
|
+
{
|
|
1173
|
+
header,
|
|
1174
|
+
sortColumn: sortModel.sortColumn,
|
|
1175
|
+
onSortChange: (value) => {
|
|
1176
|
+
onSortChange == null ? void 0 : onSortChange(value);
|
|
1177
|
+
},
|
|
1178
|
+
triggerWidth: triggerWidth + 16
|
|
1179
|
+
}
|
|
1180
|
+
)
|
|
1181
|
+
] })
|
|
1182
|
+
]
|
|
1183
|
+
}
|
|
1184
|
+
);
|
|
1104
1185
|
};
|
|
1105
1186
|
var TableHeadCell_default = TableHeadCell;
|
|
1106
|
-
var
|
|
1107
|
-
|
|
1187
|
+
var DragHandle = ({ listeners, attributes }) => /* @__PURE__ */ jsx(
|
|
1188
|
+
StackContainer.Horizontal,
|
|
1189
|
+
__spreadProps(__spreadValues(__spreadValues({
|
|
1190
|
+
align: "center",
|
|
1191
|
+
justify: "center",
|
|
1192
|
+
padding: "4px"
|
|
1193
|
+
}, listeners), attributes), {
|
|
1194
|
+
style: {
|
|
1195
|
+
cursor: "grab",
|
|
1196
|
+
touchAction: "none"
|
|
1197
|
+
},
|
|
1198
|
+
background: "neutral0",
|
|
1199
|
+
children: /* @__PURE__ */ jsx(Icon, { iconSource: ListMoveIcon, sizeVar: "S", color: "neutral700" })
|
|
1200
|
+
})
|
|
1201
|
+
);
|
|
1202
|
+
var SortableRow = ({
|
|
1203
|
+
row,
|
|
1204
|
+
index,
|
|
1205
|
+
cells,
|
|
1206
|
+
hasPinned,
|
|
1207
|
+
onClickRow,
|
|
1208
|
+
getFixedCellStyle,
|
|
1209
|
+
showDragHandle,
|
|
1210
|
+
shouldFixDragHandle = false,
|
|
1211
|
+
dragColWidth = 40,
|
|
1212
|
+
bodyRowStyle
|
|
1213
|
+
}) => {
|
|
1108
1214
|
const {
|
|
1109
|
-
|
|
1215
|
+
attributes,
|
|
1216
|
+
listeners,
|
|
1217
|
+
setNodeRef,
|
|
1218
|
+
transform,
|
|
1219
|
+
transition,
|
|
1220
|
+
isDragging: isSortableDragging
|
|
1221
|
+
} = useSortable({
|
|
1222
|
+
id: row.id || `row-${index}`
|
|
1223
|
+
});
|
|
1224
|
+
const baseRowStyle = typeof bodyRowStyle === "function" ? bodyRowStyle(index, row.original) : bodyRowStyle;
|
|
1225
|
+
const style = __spreadProps(__spreadValues({}, baseRowStyle), {
|
|
1226
|
+
transform: CSS.Transform.toString(transform),
|
|
1227
|
+
transition,
|
|
1228
|
+
opacity: isSortableDragging ? 0.5 : 1,
|
|
1229
|
+
backgroundColor: isSortableDragging ? "#f5f5f5" : void 0
|
|
1230
|
+
});
|
|
1231
|
+
return /* @__PURE__ */ jsxs(
|
|
1232
|
+
TableRow,
|
|
1233
|
+
{
|
|
1234
|
+
ref: setNodeRef,
|
|
1235
|
+
style,
|
|
1236
|
+
"data-index": index,
|
|
1237
|
+
"data-has-pinned": hasPinned,
|
|
1238
|
+
onClick: () => {
|
|
1239
|
+
var _a;
|
|
1240
|
+
if (typeof row.getVisibleCells === "function") {
|
|
1241
|
+
onClickRow == null ? void 0 : onClickRow(row.original);
|
|
1242
|
+
} else if (Array.isArray(row) && row.length > 0 && ((_a = row[0].row) == null ? void 0 : _a.original)) {
|
|
1243
|
+
onClickRow == null ? void 0 : onClickRow(row[0].row.original);
|
|
1244
|
+
}
|
|
1245
|
+
},
|
|
1246
|
+
className: onClickRow !== void 0 ? "clickable" : `row-${index}`,
|
|
1247
|
+
children: [
|
|
1248
|
+
showDragHandle && /* @__PURE__ */ jsx(
|
|
1249
|
+
TableCell,
|
|
1250
|
+
{
|
|
1251
|
+
style: shouldFixDragHandle ? {
|
|
1252
|
+
position: "sticky",
|
|
1253
|
+
left: 0,
|
|
1254
|
+
zIndex: 11,
|
|
1255
|
+
width: `${dragColWidth}px`,
|
|
1256
|
+
minWidth: `${dragColWidth}px`,
|
|
1257
|
+
maxWidth: `${dragColWidth}px`,
|
|
1258
|
+
backgroundColor: "neutral0"
|
|
1259
|
+
} : void 0,
|
|
1260
|
+
"data-last-left-pinned": shouldFixDragHandle ? false : void 0,
|
|
1261
|
+
children: /* @__PURE__ */ jsx(DragHandle, { listeners, attributes })
|
|
1262
|
+
}
|
|
1263
|
+
),
|
|
1264
|
+
cells.map((cell) => {
|
|
1265
|
+
var _a;
|
|
1266
|
+
const isPinned = cell.column.getIsPinned();
|
|
1267
|
+
const isLastLeftPinned = isPinned === "left" && cell.column.getIsLastColumn("left");
|
|
1268
|
+
const isFirstRightPinned = isPinned === "right" && cell.column.getIsFirstColumn("right");
|
|
1269
|
+
const cellContext = cell.getContext();
|
|
1270
|
+
const overriddenContext = __spreadProps(__spreadValues({}, cellContext), {
|
|
1271
|
+
row: __spreadProps(__spreadValues({}, cellContext.row), {
|
|
1272
|
+
index
|
|
1273
|
+
})
|
|
1274
|
+
});
|
|
1275
|
+
return /* @__PURE__ */ jsx(Fragment$1, { children: /* @__PURE__ */ jsx(
|
|
1276
|
+
TableCell,
|
|
1277
|
+
{
|
|
1278
|
+
"data-last-left-pinned": isLastLeftPinned,
|
|
1279
|
+
"data-first-right-pinned": isFirstRightPinned,
|
|
1280
|
+
"data-no-hover": getColumnActiveHoverDataAttribute(
|
|
1281
|
+
(_a = cell.column.columnDef.meta) == null ? void 0 : _a.activeHover,
|
|
1282
|
+
cell.row.original
|
|
1283
|
+
),
|
|
1284
|
+
style: getFixedCellStyle(cell.column),
|
|
1285
|
+
children: flexRender(cell.column.columnDef.cell, overriddenContext)
|
|
1286
|
+
}
|
|
1287
|
+
) }, cell.id);
|
|
1288
|
+
})
|
|
1289
|
+
]
|
|
1290
|
+
}
|
|
1291
|
+
);
|
|
1292
|
+
};
|
|
1293
|
+
var CellSkeleton = () => /* @__PURE__ */ jsx(Skeleton, { styleVar: "rectangle", width: "80%", height: "20px" });
|
|
1294
|
+
var SkeletonRows = ({ rowCount, columns, enableDragDrop }) => /* @__PURE__ */ jsx(Fragment, { children: Array.from({ length: rowCount }).map((_, rowIndex) => /* @__PURE__ */ jsxs(TableRow, { children: [
|
|
1295
|
+
enableDragDrop && /* @__PURE__ */ jsx(TableCell, { style: { width: 40, minWidth: 40, height: "60px" }, children: /* @__PURE__ */ jsx(CellSkeleton, {}) }),
|
|
1296
|
+
columns.map((column) => /* @__PURE__ */ jsx(TableCell, { style: { height: "60px" }, children: /* @__PURE__ */ jsx(CellSkeleton, {}) }, column.id))
|
|
1297
|
+
] }, `skeleton-row-${rowIndex}`)) });
|
|
1298
|
+
var FixedTable = ({ tableState }) => {
|
|
1299
|
+
const {
|
|
1300
|
+
table,
|
|
1301
|
+
headerRef,
|
|
1302
|
+
bodyRef,
|
|
1303
|
+
tableScrollRef,
|
|
1304
|
+
footerRef,
|
|
1305
|
+
hasToolbar,
|
|
1306
|
+
hasPagination,
|
|
1307
|
+
onClickRow,
|
|
1308
|
+
hasFooter,
|
|
1309
|
+
hasFilterBar,
|
|
1310
|
+
isLoading
|
|
1311
|
+
} = useTable();
|
|
1312
|
+
const {
|
|
1313
|
+
displayedRows: initialDisplayedRows,
|
|
1110
1314
|
paddingTop,
|
|
1111
1315
|
paddingBottom,
|
|
1112
1316
|
isEmpty,
|
|
@@ -1115,43 +1319,122 @@ var FixedTable = ({ tableState }) => {
|
|
|
1115
1319
|
isSticky,
|
|
1116
1320
|
stickyHeaderTopPosition,
|
|
1117
1321
|
maxHeight = "100%",
|
|
1118
|
-
emptyRowCount = 8
|
|
1322
|
+
emptyRowCount = 8,
|
|
1323
|
+
enableDragDrop = false,
|
|
1324
|
+
dragColWidth = 40,
|
|
1325
|
+
onRowReorder,
|
|
1326
|
+
shouldFixDragHandle = false,
|
|
1327
|
+
footerRowProps,
|
|
1328
|
+
headerRowStyle,
|
|
1329
|
+
bodyRowStyle
|
|
1119
1330
|
} = tableState;
|
|
1331
|
+
const [displayedRows, setDisplayedRows] = useState(initialDisplayedRows);
|
|
1332
|
+
const sensors = useSensors(
|
|
1333
|
+
useSensor(PointerSensor, {
|
|
1334
|
+
activationConstraint: {
|
|
1335
|
+
distance: 8
|
|
1336
|
+
}
|
|
1337
|
+
}),
|
|
1338
|
+
useSensor(KeyboardSensor, {
|
|
1339
|
+
coordinateGetter: sortableKeyboardCoordinates
|
|
1340
|
+
})
|
|
1341
|
+
);
|
|
1120
1342
|
const handleScroll = useCallback(() => {
|
|
1121
|
-
if (!bodyRef.current)
|
|
1343
|
+
if (!bodyRef.current)
|
|
1122
1344
|
return;
|
|
1123
|
-
}
|
|
1124
1345
|
const bodyScrollLeft = bodyRef.current.scrollLeft;
|
|
1125
1346
|
if (headerRef.current) {
|
|
1126
1347
|
headerRef.current.scrollLeft = bodyScrollLeft;
|
|
1127
1348
|
}
|
|
1349
|
+
if (footerRef.current) {
|
|
1350
|
+
footerRef.current.scrollLeft = bodyScrollLeft;
|
|
1351
|
+
}
|
|
1128
1352
|
if (tableScrollRef.current) {
|
|
1129
1353
|
tableScrollRef.current.scrollLeft = bodyScrollLeft;
|
|
1130
1354
|
}
|
|
1131
|
-
}, [bodyRef, headerRef, tableScrollRef]);
|
|
1132
|
-
const
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1355
|
+
}, [bodyRef, headerRef, footerRef, tableScrollRef]);
|
|
1356
|
+
const handleScrollBarScroll = useCallback(() => {
|
|
1357
|
+
if (!tableScrollRef.current || !bodyRef.current)
|
|
1358
|
+
return;
|
|
1359
|
+
bodyRef.current.scrollLeft = tableScrollRef.current.scrollLeft;
|
|
1360
|
+
}, [bodyRef, tableScrollRef]);
|
|
1361
|
+
const dragColWidthPx = `${dragColWidth}px`;
|
|
1362
|
+
const TableColumns = ({ showDragHandle = false }) => {
|
|
1363
|
+
const leafColumns = table.getVisibleLeafColumns();
|
|
1364
|
+
return /* @__PURE__ */ jsxs("colgroup", { children: [
|
|
1365
|
+
showDragHandle && /* @__PURE__ */ jsx("col", { style: { width: dragColWidthPx, minWidth: dragColWidthPx, maxWidth: dragColWidthPx } }),
|
|
1366
|
+
leafColumns.map((column) => {
|
|
1367
|
+
var _a, _b;
|
|
1368
|
+
const size = column.columnDef.size;
|
|
1369
|
+
const minSize = (_a = column.columnDef.minSize) != null ? _a : size;
|
|
1370
|
+
const maxSize = (_b = column.columnDef.maxSize) != null ? _b : size;
|
|
1371
|
+
const style = size === 0 ? { width: "100%" } : {
|
|
1372
|
+
width: `${size}px`,
|
|
1373
|
+
minWidth: `${minSize}px`,
|
|
1374
|
+
maxWidth: `${maxSize}px`
|
|
1375
|
+
};
|
|
1376
|
+
return /* @__PURE__ */ jsx("col", { style }, column.id);
|
|
1377
|
+
})
|
|
1378
|
+
] });
|
|
1379
|
+
};
|
|
1380
|
+
const getFixedCellStyle = (column, isHeader = false, isFooter = false) => {
|
|
1381
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1382
|
+
const baseStyle = __spreadValues(__spreadValues({}, getCommonPinningStyles(column)), isHeader ? (_b = (_a = column.columnDef.meta) == null ? void 0 : _a.headerProps) == null ? void 0 : _b.style : isFooter ? (_d = (_c = column.columnDef.meta) == null ? void 0 : _c.footerProps) == null ? void 0 : _d.style : (_f = (_e = column.columnDef.meta) == null ? void 0 : _e.cellProps) == null ? void 0 : _f.style);
|
|
1146
1383
|
const size = column.columnDef.size;
|
|
1147
1384
|
const minSize = column.columnDef.minSize;
|
|
1148
1385
|
const maxSize = column.columnDef.maxSize;
|
|
1149
|
-
|
|
1386
|
+
const isPinned = column.getIsPinned();
|
|
1387
|
+
const adjustedLeft = shouldFixDragHandle && isPinned === "left" && baseStyle.left ? `${parseFloat(baseStyle.left.toString()) + dragColWidth}px` : baseStyle.left;
|
|
1388
|
+
return __spreadValues(__spreadProps(__spreadValues({}, baseStyle), {
|
|
1389
|
+
left: adjustedLeft
|
|
1390
|
+
}), size === 0 ? { width: "100%" } : {
|
|
1150
1391
|
width: `${size}px`,
|
|
1151
1392
|
minWidth: `${minSize}px`,
|
|
1152
1393
|
maxWidth: `${maxSize}px`
|
|
1153
1394
|
});
|
|
1154
1395
|
};
|
|
1396
|
+
const handleDragEnd = (event) => {
|
|
1397
|
+
const { active, over } = event;
|
|
1398
|
+
if (over && active.id !== over.id) {
|
|
1399
|
+
setDisplayedRows((rows) => {
|
|
1400
|
+
const oldIndex = rows.findIndex((r) => {
|
|
1401
|
+
const row = r.row;
|
|
1402
|
+
const id = typeof row.id !== "undefined" ? row.id : rows.indexOf(r);
|
|
1403
|
+
return id === active.id;
|
|
1404
|
+
});
|
|
1405
|
+
const newIndex = rows.findIndex((r) => {
|
|
1406
|
+
const row = r.row;
|
|
1407
|
+
const id = typeof row.id !== "undefined" ? row.id : rows.indexOf(r);
|
|
1408
|
+
return id === over.id;
|
|
1409
|
+
});
|
|
1410
|
+
const newOrder = arrayMove(rows, oldIndex, newIndex);
|
|
1411
|
+
if (onRowReorder) {
|
|
1412
|
+
const reorderedData = newOrder.map((r) => {
|
|
1413
|
+
var _a;
|
|
1414
|
+
const row = r.row;
|
|
1415
|
+
if (typeof row.getVisibleCells === "function") {
|
|
1416
|
+
return row.original;
|
|
1417
|
+
} else if (Array.isArray(row) && row.length > 0 && ((_a = row[0].row) == null ? void 0 : _a.original)) {
|
|
1418
|
+
return row[0].row.original;
|
|
1419
|
+
}
|
|
1420
|
+
return null;
|
|
1421
|
+
}).filter(Boolean);
|
|
1422
|
+
onRowReorder(reorderedData);
|
|
1423
|
+
}
|
|
1424
|
+
return newOrder;
|
|
1425
|
+
});
|
|
1426
|
+
}
|
|
1427
|
+
};
|
|
1428
|
+
const rowIds = React3.useMemo(
|
|
1429
|
+
() => displayedRows.map((r) => {
|
|
1430
|
+
var _a, _b, _c;
|
|
1431
|
+
return r.row.id || `row-${((_a = r.row.original) == null ? void 0 : _a.id) || ((_c = (_b = r.row.original) == null ? void 0 : _b.userName) == null ? void 0 : _c.name) || "fallback"}`;
|
|
1432
|
+
}),
|
|
1433
|
+
[displayedRows]
|
|
1434
|
+
);
|
|
1435
|
+
useEffect(() => {
|
|
1436
|
+
setDisplayedRows(initialDisplayedRows);
|
|
1437
|
+
}, [initialDisplayedRows]);
|
|
1155
1438
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1156
1439
|
/* @__PURE__ */ jsx(
|
|
1157
1440
|
HeaderTableContainer,
|
|
@@ -1169,40 +1452,108 @@ var FixedTable = ({ tableState }) => {
|
|
|
1169
1452
|
tableLayout: "fixed"
|
|
1170
1453
|
},
|
|
1171
1454
|
children: [
|
|
1172
|
-
/* @__PURE__ */ jsx(TableColumns, {}),
|
|
1173
|
-
/* @__PURE__ */ jsx(TableHeader, { children: table.getHeaderGroups().map((headerGroup
|
|
1174
|
-
const
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1455
|
+
/* @__PURE__ */ jsx(TableColumns, { showDragHandle: enableDragDrop }),
|
|
1456
|
+
/* @__PURE__ */ jsx(TableHeader, { children: table.getHeaderGroups().map((headerGroup, i) => {
|
|
1457
|
+
const rowStyle = typeof headerRowStyle === "function" ? headerRowStyle(i, headerGroup) : headerRowStyle;
|
|
1458
|
+
return /* @__PURE__ */ jsxs(TableRow, { style: rowStyle, children: [
|
|
1459
|
+
enableDragDrop && /* @__PURE__ */ jsx(
|
|
1460
|
+
TableHead,
|
|
1461
|
+
{
|
|
1462
|
+
colSpan: 1,
|
|
1463
|
+
style: shouldFixDragHandle ? {
|
|
1464
|
+
position: "sticky",
|
|
1465
|
+
left: 0,
|
|
1466
|
+
zIndex: 11,
|
|
1467
|
+
width: dragColWidthPx,
|
|
1468
|
+
minWidth: dragColWidthPx,
|
|
1469
|
+
maxWidth: dragColWidthPx,
|
|
1470
|
+
backgroundColor: (rowStyle == null ? void 0 : rowStyle.backgroundColor) || "neutral400"
|
|
1471
|
+
} : rowStyle ? {
|
|
1472
|
+
backgroundColor: (rowStyle == null ? void 0 : rowStyle.backgroundColor) || "neutral400",
|
|
1473
|
+
height: rowStyle == null ? void 0 : rowStyle.height,
|
|
1474
|
+
maxHeight: rowStyle == null ? void 0 : rowStyle.maxHeight,
|
|
1475
|
+
minHeight: rowStyle == null ? void 0 : rowStyle.minHeight
|
|
1476
|
+
} : void 0,
|
|
1477
|
+
"data-pinned": shouldFixDragHandle ? "left" : void 0,
|
|
1478
|
+
"data-last-left-pinned": shouldFixDragHandle ? false : void 0
|
|
1479
|
+
}
|
|
1480
|
+
),
|
|
1481
|
+
headerGroup.headers.map((header) => {
|
|
1482
|
+
var _a, _b, _c, _d, _e;
|
|
1483
|
+
const isPinned = header.column.getIsPinned();
|
|
1484
|
+
const leafHeaders = header.getLeafHeaders();
|
|
1485
|
+
const hasLastLeftPinnedLeaf = leafHeaders.some(
|
|
1486
|
+
(leaf) => leaf.column.getIsPinned() === "left" && leaf.column.getIsLastColumn("left")
|
|
1487
|
+
);
|
|
1488
|
+
const hasFirstRightPinnedLeaf = leafHeaders.some(
|
|
1489
|
+
(leaf) => leaf.column.getIsPinned() === "right" && leaf.column.getIsFirstColumn("right")
|
|
1490
|
+
);
|
|
1491
|
+
const isLastLeftPinned = isPinned === "left" && header.column.getIsLastColumn("left") || hasLastLeftPinnedLeaf;
|
|
1492
|
+
const isFirstRightPinned = isPinned === "right" && header.column.getIsFirstColumn("right") || hasFirstRightPinnedLeaf;
|
|
1493
|
+
const columnRelativeDepth = header.depth - header.column.depth;
|
|
1494
|
+
if (!header.isPlaceholder && columnRelativeDepth > 1 && header.id === header.column.id) {
|
|
1495
|
+
return null;
|
|
1496
|
+
}
|
|
1497
|
+
let rowSpan = 1;
|
|
1498
|
+
if (header.isPlaceholder) {
|
|
1499
|
+
const leafs = header.getLeafHeaders();
|
|
1500
|
+
rowSpan = leafs[leafs.length - 1].depth - header.depth;
|
|
1501
|
+
}
|
|
1502
|
+
let headerStyle = {};
|
|
1503
|
+
if (header.colSpan > 1) {
|
|
1504
|
+
const leafHeaders2 = header.getLeafHeaders();
|
|
1505
|
+
const groupId = header.column.id;
|
|
1506
|
+
const totalWidth = leafHeaders2.filter((leaf) => leaf.column.id !== groupId).reduce((sum, leaf) => {
|
|
1507
|
+
const size = leaf.column.columnDef.size || 0;
|
|
1508
|
+
return sum + size;
|
|
1509
|
+
}, 0);
|
|
1510
|
+
const firstLeaf = leafHeaders2[0];
|
|
1511
|
+
const firstLeafPinned = firstLeaf.column.getIsPinned();
|
|
1512
|
+
headerStyle = __spreadProps(__spreadValues({}, (_b = (_a = header.column.columnDef.meta) == null ? void 0 : _a.headerProps) == null ? void 0 : _b.style), {
|
|
1513
|
+
width: `${totalWidth}px`,
|
|
1514
|
+
minWidth: `${totalWidth}px`,
|
|
1515
|
+
maxWidth: `${totalWidth}px`,
|
|
1516
|
+
left: firstLeafPinned === "left" ? `${firstLeaf.column.getStart("left")}px` : void 0,
|
|
1517
|
+
right: firstLeafPinned === "right" ? `${firstLeaf.column.getAfter("right")}px` : void 0,
|
|
1518
|
+
position: firstLeafPinned ? "sticky" : "relative",
|
|
1519
|
+
zIndex: firstLeafPinned ? 10 : 0
|
|
1520
|
+
});
|
|
1521
|
+
} else {
|
|
1522
|
+
headerStyle = getFixedCellStyle(header.column, true);
|
|
1523
|
+
}
|
|
1524
|
+
const hasNoBorderRight = headerStyle.borderRight === "none" || ((_e = (_d = (_c = header.column.columnDef.meta) == null ? void 0 : _c.headerProps) == null ? void 0 : _d.style) == null ? void 0 : _e.borderRight) === "none";
|
|
1525
|
+
return /* @__PURE__ */ jsx(
|
|
1526
|
+
TableHead,
|
|
1527
|
+
{
|
|
1528
|
+
"data-last-left-pinned": isLastLeftPinned,
|
|
1529
|
+
"data-first-right-pinned": isFirstRightPinned,
|
|
1530
|
+
"data-pinned": isPinned,
|
|
1531
|
+
"data-no-border-right": hasNoBorderRight,
|
|
1532
|
+
style: __spreadValues(__spreadValues({}, headerStyle), rowStyle && {
|
|
1533
|
+
backgroundColor: rowStyle.backgroundColor,
|
|
1534
|
+
height: rowStyle.height,
|
|
1535
|
+
maxHeight: rowStyle.maxHeight,
|
|
1536
|
+
minHeight: rowStyle.minHeight
|
|
1537
|
+
}),
|
|
1538
|
+
colSpan: header.colSpan,
|
|
1539
|
+
rowSpan,
|
|
1540
|
+
sortable: getTableHeadSortModel(header).showSortMenu,
|
|
1541
|
+
filterable: header.column.getCanFilter(),
|
|
1542
|
+
"data-sortable": getTableHeadSortModel(header).showSortMenu,
|
|
1543
|
+
"data-filterable": header.column.getCanFilter(),
|
|
1544
|
+
children: /* @__PURE__ */ jsx(TableHeadCell_default, { header })
|
|
1545
|
+
},
|
|
1546
|
+
header.id
|
|
1547
|
+
);
|
|
1548
|
+
})
|
|
1549
|
+
] }, headerGroup.id);
|
|
1550
|
+
}) })
|
|
1200
1551
|
]
|
|
1201
1552
|
}
|
|
1202
1553
|
)
|
|
1203
1554
|
}
|
|
1204
1555
|
),
|
|
1205
|
-
/* @__PURE__ */ jsx(ScrollArea, { autoHeightMax: maxHeight, autoHeight: true, children: /* @__PURE__ */ jsx(BodyTableContainer, { hasPagination, onScroll: handleScroll, ref: bodyRef, children:
|
|
1556
|
+
/* @__PURE__ */ jsx(ScrollArea, { autoHeightMax: maxHeight, autoHeight: true, children: /* @__PURE__ */ jsx(BodyTableContainer, { hasPagination, hasFooter, onScroll: handleScroll, ref: bodyRef, children: /* @__PURE__ */ jsx(DndContext, { sensors, collisionDetection: closestCenter, onDragEnd: handleDragEnd, children: /* @__PURE__ */ jsx(SortableContext, { items: rowIds, strategy: verticalListSortingStrategy, children: /* @__PURE__ */ jsxs(
|
|
1206
1557
|
"table",
|
|
1207
1558
|
{
|
|
1208
1559
|
style: {
|
|
@@ -1211,51 +1562,104 @@ var FixedTable = ({ tableState }) => {
|
|
|
1211
1562
|
tableLayout: "fixed"
|
|
1212
1563
|
},
|
|
1213
1564
|
children: [
|
|
1214
|
-
/* @__PURE__ */ jsx(TableColumns, {}),
|
|
1565
|
+
/* @__PURE__ */ jsx(TableColumns, { showDragHandle: enableDragDrop }),
|
|
1215
1566
|
/* @__PURE__ */ jsxs(TableBody, { children: [
|
|
1216
1567
|
paddingTop > 0 && /* @__PURE__ */ jsx(TableRow, { children: /* @__PURE__ */ jsx("td", { style: { height: `${paddingTop}px` } }) }),
|
|
1217
|
-
|
|
1568
|
+
isLoading && /* @__PURE__ */ jsx(
|
|
1569
|
+
SkeletonRows,
|
|
1570
|
+
{
|
|
1571
|
+
rowCount: emptyRowCount || 8,
|
|
1572
|
+
columns: table.getVisibleLeafColumns(),
|
|
1573
|
+
enableDragDrop
|
|
1574
|
+
}
|
|
1575
|
+
),
|
|
1576
|
+
!isLoading && isEmpty && /* @__PURE__ */ jsx(TableRow, { children: /* @__PURE__ */ jsx(
|
|
1577
|
+
TableCell,
|
|
1578
|
+
{
|
|
1579
|
+
colSpan: table.getAllColumns().length + (enableDragDrop ? 1 : 0),
|
|
1580
|
+
style: { padding: 0, border: "none" },
|
|
1581
|
+
children: children || emptyElement
|
|
1582
|
+
}
|
|
1583
|
+
) }),
|
|
1584
|
+
!isLoading && !isEmpty && displayedRows.map((rowObj, i) => {
|
|
1585
|
+
var _a, _b, _c;
|
|
1218
1586
|
const isVirtual = "virtualRow" in rowObj && rowObj.virtualRow;
|
|
1219
1587
|
const row = rowObj.row;
|
|
1220
1588
|
const cells = typeof row.getVisibleCells === "function" ? row.getVisibleCells() : row;
|
|
1589
|
+
const hasPinned = cells.some((cell) => cell.column.getIsPinned());
|
|
1590
|
+
const rowId = row.id || `row-${((_a = row.original) == null ? void 0 : _a.id) || ((_c = (_b = row.original) == null ? void 0 : _b.userName) == null ? void 0 : _c.name) || i}`;
|
|
1591
|
+
if (enableDragDrop) {
|
|
1592
|
+
return /* @__PURE__ */ jsx(
|
|
1593
|
+
SortableRow,
|
|
1594
|
+
{
|
|
1595
|
+
row,
|
|
1596
|
+
index: i,
|
|
1597
|
+
cells,
|
|
1598
|
+
hasPinned,
|
|
1599
|
+
onClickRow,
|
|
1600
|
+
getFixedCellStyle,
|
|
1601
|
+
showDragHandle: true,
|
|
1602
|
+
shouldFixDragHandle,
|
|
1603
|
+
dragColWidth,
|
|
1604
|
+
bodyRowStyle
|
|
1605
|
+
},
|
|
1606
|
+
rowId
|
|
1607
|
+
);
|
|
1608
|
+
}
|
|
1609
|
+
const rowStyle = typeof bodyRowStyle === "function" ? bodyRowStyle(i, row.original) : bodyRowStyle;
|
|
1610
|
+
const cellBackgroundColor = rowStyle == null ? void 0 : rowStyle.backgroundColor;
|
|
1221
1611
|
return /* @__PURE__ */ jsx(
|
|
1222
1612
|
TableRow,
|
|
1223
1613
|
{
|
|
1224
1614
|
"data-index": isVirtual ? rowObj.virtualRow.index : i,
|
|
1615
|
+
"data-has-pinned": hasPinned,
|
|
1616
|
+
style: rowStyle,
|
|
1225
1617
|
onClick: () => {
|
|
1226
|
-
var
|
|
1618
|
+
var _a2;
|
|
1227
1619
|
if (typeof row.getVisibleCells === "function") {
|
|
1228
1620
|
onClickRow == null ? void 0 : onClickRow(row.original);
|
|
1229
|
-
} else if (Array.isArray(row) && row.length > 0 && ((
|
|
1621
|
+
} else if (Array.isArray(row) && row.length > 0 && ((_a2 = row[0].row) == null ? void 0 : _a2.original)) {
|
|
1230
1622
|
onClickRow == null ? void 0 : onClickRow(row[0].row.original);
|
|
1231
1623
|
}
|
|
1232
1624
|
},
|
|
1233
|
-
className: onClickRow !== void 0 ? "clickable" :
|
|
1625
|
+
className: onClickRow !== void 0 ? "clickable" : `row-${i}`,
|
|
1234
1626
|
children: cells.map((cell) => {
|
|
1235
|
-
var
|
|
1627
|
+
var _a2, _b2, _c2, _d;
|
|
1236
1628
|
const isPinned = cell.column.getIsPinned();
|
|
1237
1629
|
const isLastLeftPinned = isPinned === "left" && cell.column.getIsLastColumn("left");
|
|
1238
1630
|
const isFirstRightPinned = isPinned === "right" && cell.column.getIsFirstColumn("right");
|
|
1631
|
+
const cellContext = cell.getContext();
|
|
1632
|
+
const overriddenContext = __spreadProps(__spreadValues({}, cellContext), {
|
|
1633
|
+
row: __spreadProps(__spreadValues({}, cellContext.row), {
|
|
1634
|
+
index: i
|
|
1635
|
+
})
|
|
1636
|
+
});
|
|
1239
1637
|
return /* @__PURE__ */ jsx(Fragment$1, { children: /* @__PURE__ */ jsx(
|
|
1240
1638
|
TableCell,
|
|
1241
1639
|
{
|
|
1242
1640
|
"data-last-left-pinned": isLastLeftPinned,
|
|
1243
1641
|
"data-first-right-pinned": isFirstRightPinned,
|
|
1244
|
-
"data-no-hover": (
|
|
1245
|
-
|
|
1246
|
-
|
|
1642
|
+
"data-no-hover": getColumnActiveHoverDataAttribute(
|
|
1643
|
+
(_a2 = cell.column.columnDef.meta) == null ? void 0 : _a2.activeHover,
|
|
1644
|
+
cell.row.original
|
|
1645
|
+
),
|
|
1646
|
+
"data-has-custom-style": ((_d = (_c2 = (_b2 = cell.column.columnDef.meta) == null ? void 0 : _b2.cellProps) == null ? void 0 : _c2.style) == null ? void 0 : _d.backgroundColor) ? "true" : void 0,
|
|
1647
|
+
style: __spreadValues(__spreadValues({}, getFixedCellStyle(cell.column)), cellBackgroundColor && {
|
|
1648
|
+
backgroundColor: cellBackgroundColor
|
|
1649
|
+
}),
|
|
1650
|
+
children: isLoading ? /* @__PURE__ */ jsx(CellSkeleton, {}) : flexRender(cell.column.columnDef.cell, overriddenContext)
|
|
1247
1651
|
}
|
|
1248
1652
|
) }, cell.id);
|
|
1249
1653
|
})
|
|
1250
1654
|
},
|
|
1251
|
-
|
|
1655
|
+
rowId
|
|
1252
1656
|
);
|
|
1253
1657
|
}),
|
|
1254
1658
|
paddingBottom > 0 && /* @__PURE__ */ jsx(TableRow, { children: /* @__PURE__ */ jsx("td", { style: { height: `${paddingBottom}px` } }) }),
|
|
1255
|
-
emptyRowCount !== 0 && displayedRows.length < emptyRowCount && Array.from({ length: emptyRowCount - displayedRows.length }).map((_, index) => /* @__PURE__ */ jsx(TableRow, { "data-empty": true, children: /* @__PURE__ */ jsx(
|
|
1659
|
+
emptyRowCount !== 0 && displayedRows.length < emptyRowCount && !isLoading && !isEmpty && Array.from({ length: emptyRowCount - displayedRows.length }).map((_, index) => /* @__PURE__ */ jsx(TableRow, { "data-empty": true, children: /* @__PURE__ */ jsx(
|
|
1256
1660
|
TableCell,
|
|
1257
1661
|
{
|
|
1258
|
-
colSpan: table.getAllColumns().length,
|
|
1662
|
+
colSpan: table.getAllColumns().length + (enableDragDrop ? 1 : 0),
|
|
1259
1663
|
style: {
|
|
1260
1664
|
height: `${60}px`
|
|
1261
1665
|
}
|
|
@@ -1264,7 +1668,89 @@ var FixedTable = ({ tableState }) => {
|
|
|
1264
1668
|
] })
|
|
1265
1669
|
]
|
|
1266
1670
|
}
|
|
1267
|
-
) }) })
|
|
1671
|
+
) }) }) }) }),
|
|
1672
|
+
!hasPagination && /* @__PURE__ */ jsx(
|
|
1673
|
+
BottomContainer,
|
|
1674
|
+
{
|
|
1675
|
+
ref: footerRef,
|
|
1676
|
+
isEndOfPage: true,
|
|
1677
|
+
hasFilterBar,
|
|
1678
|
+
hasToolbar,
|
|
1679
|
+
hideBorder: true,
|
|
1680
|
+
children: /* @__PURE__ */ jsx(ScrollContainer, { ref: tableScrollRef, onScroll: handleScrollBarScroll, isPagination: false, children: /* @__PURE__ */ jsx(
|
|
1681
|
+
"table",
|
|
1682
|
+
{
|
|
1683
|
+
style: {
|
|
1684
|
+
width: enableDragDrop ? (table.getTotalSize() || 0) + dragColWidth : table.getTotalSize() || "100%",
|
|
1685
|
+
height: "6px",
|
|
1686
|
+
tableLayout: "fixed"
|
|
1687
|
+
},
|
|
1688
|
+
children: /* @__PURE__ */ jsx(TableColumns, { showDragHandle: enableDragDrop })
|
|
1689
|
+
}
|
|
1690
|
+
) })
|
|
1691
|
+
}
|
|
1692
|
+
),
|
|
1693
|
+
hasFooter && /* @__PURE__ */ jsx(FooterTableContainer, { ref: footerRef, isSticky, hasPagination, hasHeader: hasToolbar, children: /* @__PURE__ */ jsxs(
|
|
1694
|
+
"table",
|
|
1695
|
+
{
|
|
1696
|
+
style: {
|
|
1697
|
+
width: "100%",
|
|
1698
|
+
overflow: "auto",
|
|
1699
|
+
tableLayout: "fixed"
|
|
1700
|
+
},
|
|
1701
|
+
children: [
|
|
1702
|
+
/* @__PURE__ */ jsx(TableColumns, { showDragHandle: enableDragDrop }),
|
|
1703
|
+
/* @__PURE__ */ jsx(TableFooter, { children: table.getFooterGroups().map((footerGroup) => {
|
|
1704
|
+
var _a;
|
|
1705
|
+
return /* @__PURE__ */ jsxs(TableRow, { style: footerRowProps == null ? void 0 : footerRowProps.style, children: [
|
|
1706
|
+
enableDragDrop && /* @__PURE__ */ jsx(
|
|
1707
|
+
TableFoot,
|
|
1708
|
+
{
|
|
1709
|
+
colSpan: 1,
|
|
1710
|
+
style: shouldFixDragHandle ? {
|
|
1711
|
+
position: "sticky",
|
|
1712
|
+
left: 0,
|
|
1713
|
+
zIndex: 11,
|
|
1714
|
+
width: dragColWidthPx,
|
|
1715
|
+
minWidth: dragColWidthPx,
|
|
1716
|
+
maxWidth: dragColWidthPx,
|
|
1717
|
+
backgroundColor: ((_a = footerRowProps == null ? void 0 : footerRowProps.style) == null ? void 0 : _a.backgroundColor) || "inherit"
|
|
1718
|
+
} : void 0,
|
|
1719
|
+
"data-last-left-pinned": shouldFixDragHandle ? false : void 0
|
|
1720
|
+
}
|
|
1721
|
+
),
|
|
1722
|
+
footerGroup.headers.map((footer) => {
|
|
1723
|
+
const isPinned = footer.column.getIsPinned();
|
|
1724
|
+
const isLastLeftPinned = isPinned === "left" && footer.column.getIsLastColumn("left");
|
|
1725
|
+
const isFirstRightPinned = isPinned === "right" && footer.column.getIsFirstColumn("right");
|
|
1726
|
+
const columnRelativeDepth = footer.depth - footer.column.depth;
|
|
1727
|
+
if (!footer.isPlaceholder && columnRelativeDepth > 1 && footer.id === footer.column.id) {
|
|
1728
|
+
return null;
|
|
1729
|
+
}
|
|
1730
|
+
let rowSpan = 1;
|
|
1731
|
+
if (footer.isPlaceholder) {
|
|
1732
|
+
const leafs = footer.getLeafHeaders();
|
|
1733
|
+
rowSpan = leafs[leafs.length - 1].depth - footer.depth;
|
|
1734
|
+
}
|
|
1735
|
+
return /* @__PURE__ */ jsx(
|
|
1736
|
+
TableFoot,
|
|
1737
|
+
{
|
|
1738
|
+
"data-last-left-pinned": isLastLeftPinned,
|
|
1739
|
+
"data-first-right-pinned": isFirstRightPinned,
|
|
1740
|
+
"data-pinned": isPinned,
|
|
1741
|
+
style: getFixedCellStyle(footer.column, false, true),
|
|
1742
|
+
colSpan: footer.colSpan,
|
|
1743
|
+
rowSpan,
|
|
1744
|
+
children: footer.isPlaceholder ? null : flexRender(footer.column.columnDef.footer, footer.getContext())
|
|
1745
|
+
},
|
|
1746
|
+
footer.id
|
|
1747
|
+
);
|
|
1748
|
+
})
|
|
1749
|
+
] }, footerGroup.id);
|
|
1750
|
+
}) })
|
|
1751
|
+
]
|
|
1752
|
+
}
|
|
1753
|
+
) })
|
|
1268
1754
|
] });
|
|
1269
1755
|
};
|
|
1270
1756
|
var ResizableTable = ({ tableState }) => {
|
|
@@ -1279,29 +1765,33 @@ var ResizableTable = ({ tableState }) => {
|
|
|
1279
1765
|
isSticky,
|
|
1280
1766
|
stickyHeaderTopPosition,
|
|
1281
1767
|
maxHeight = "100%",
|
|
1282
|
-
emptyRowCount = 8
|
|
1768
|
+
emptyRowCount = 8,
|
|
1769
|
+
headerRowStyle,
|
|
1770
|
+
bodyRowStyle
|
|
1283
1771
|
} = tableState;
|
|
1284
1772
|
const handleScroll = useCallback(() => {
|
|
1285
|
-
if (
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1773
|
+
if (!bodyRef.current)
|
|
1774
|
+
return;
|
|
1775
|
+
const bodyScrollLeft = bodyRef.current.scrollLeft;
|
|
1776
|
+
if (headerRef.current) {
|
|
1777
|
+
headerRef.current.scrollLeft = bodyScrollLeft;
|
|
1289
1778
|
}
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1779
|
+
if (tableScrollRef.current) {
|
|
1780
|
+
tableScrollRef.current.scrollLeft = bodyScrollLeft;
|
|
1781
|
+
}
|
|
1782
|
+
}, [bodyRef, headerRef, tableScrollRef]);
|
|
1783
|
+
const columnSizeVars = React3.useMemo(() => {
|
|
1293
1784
|
const headers = table.getFlatHeaders();
|
|
1294
1785
|
const colSizes = {};
|
|
1295
1786
|
const visibleHeaders = headers.filter((header) => header.column.getIsVisible());
|
|
1296
|
-
const lastLeafColumns = table.getLeafHeaders();
|
|
1297
|
-
const lastColumnId = (_a = lastLeafColumns[lastLeafColumns.length - 1]) == null ? void 0 : _a.id;
|
|
1298
1787
|
visibleHeaders.forEach((header) => {
|
|
1299
1788
|
const currentSize = header.column.getSize();
|
|
1300
1789
|
const defaultSize = header.column.columnDef.size;
|
|
1301
1790
|
const maxSize = header.column.columnDef.maxSize;
|
|
1302
|
-
const
|
|
1791
|
+
const isPinned = header.column.getIsPinned();
|
|
1792
|
+
const canResize = header.column.getCanResize();
|
|
1303
1793
|
let size;
|
|
1304
|
-
if (
|
|
1794
|
+
if (!isPinned && canResize) {
|
|
1305
1795
|
size = "auto";
|
|
1306
1796
|
} else if (currentSize !== void 0) {
|
|
1307
1797
|
size = currentSize;
|
|
@@ -1310,7 +1800,7 @@ var ResizableTable = ({ tableState }) => {
|
|
|
1310
1800
|
} else {
|
|
1311
1801
|
size = 200;
|
|
1312
1802
|
}
|
|
1313
|
-
if (
|
|
1803
|
+
if (maxSize && typeof size === "number" && size > maxSize) {
|
|
1314
1804
|
size = maxSize;
|
|
1315
1805
|
}
|
|
1316
1806
|
colSizes[`--header-${header.id}-size`] = size;
|
|
@@ -1318,8 +1808,11 @@ var ResizableTable = ({ tableState }) => {
|
|
|
1318
1808
|
});
|
|
1319
1809
|
return colSizes;
|
|
1320
1810
|
}, [table.getState().columnSizingInfo, table.getState().columnSizing]);
|
|
1811
|
+
const totalTableWidth = React3.useMemo(() => {
|
|
1812
|
+
return table.getLeftTotalSize() + table.getCenterTotalSize() + table.getRightTotalSize();
|
|
1813
|
+
}, [table.getState().columnSizingInfo, table.getState().columnSizing, table.getState().columnPinning]);
|
|
1321
1814
|
const getResizableCellStyle = (column, isHeader = false) => {
|
|
1322
|
-
var _a, _b, _c, _d
|
|
1815
|
+
var _a, _b, _c, _d;
|
|
1323
1816
|
const baseStyle = __spreadValues(__spreadValues({}, getCommonPinningStyles(column)), isHeader ? (_b = (_a = column.columnDef.meta) == null ? void 0 : _a.headerProps) == null ? void 0 : _b.style : (_d = (_c = column.columnDef.meta) == null ? void 0 : _c.cellProps) == null ? void 0 : _d.style);
|
|
1324
1817
|
const colId = column.id;
|
|
1325
1818
|
const headerId = isHeader ? colId : null;
|
|
@@ -1327,11 +1820,18 @@ var ResizableTable = ({ tableState }) => {
|
|
|
1327
1820
|
const maxSize = column.columnDef.maxSize;
|
|
1328
1821
|
const sizeKey = isHeader ? `--header-${headerId}-size` : `--col-${colId}-size`;
|
|
1329
1822
|
const size = columnSizeVars[sizeKey];
|
|
1330
|
-
const
|
|
1331
|
-
|
|
1823
|
+
const canResize = column.getCanResize();
|
|
1824
|
+
const isPinned = column.getIsPinned();
|
|
1825
|
+
const ellipsisStyle = !canResize && !isPinned ? {
|
|
1826
|
+
overflow: "hidden",
|
|
1827
|
+
textOverflow: "ellipsis",
|
|
1828
|
+
whiteSpace: "nowrap"
|
|
1829
|
+
} : {};
|
|
1830
|
+
return __spreadValues(__spreadProps(__spreadValues(__spreadValues({}, baseStyle), size === "auto" ? { width: "auto", flex: "1 1 auto" } : { width: size ? `${size}px` : "auto" }), {
|
|
1332
1831
|
minWidth: `${minSize}px`,
|
|
1333
|
-
maxWidth: isLastColumn ?
|
|
1334
|
-
|
|
1832
|
+
// maxWidth: isLastColumn && canResize ? 'none' : `${maxSize || 'none'}`,
|
|
1833
|
+
maxWidth: canResize ? "none" : `${maxSize || "none"}`
|
|
1834
|
+
}), ellipsisStyle);
|
|
1335
1835
|
};
|
|
1336
1836
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1337
1837
|
/* @__PURE__ */ jsx(
|
|
@@ -1345,48 +1845,67 @@ var ResizableTable = ({ tableState }) => {
|
|
|
1345
1845
|
"table",
|
|
1346
1846
|
{
|
|
1347
1847
|
style: {
|
|
1348
|
-
width: `${
|
|
1848
|
+
width: `${totalTableWidth}px`,
|
|
1349
1849
|
minWidth: "100%",
|
|
1350
1850
|
tableLayout: "fixed"
|
|
1351
1851
|
},
|
|
1352
|
-
children: /* @__PURE__ */ jsx(TableHeader, { children: table.getHeaderGroups().map((headerGroup
|
|
1353
|
-
const
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1852
|
+
children: /* @__PURE__ */ jsx(TableHeader, { children: table.getHeaderGroups().map((headerGroup, i) => {
|
|
1853
|
+
const rowStyle = typeof headerRowStyle === "function" ? headerRowStyle(i, headerGroup) : headerRowStyle;
|
|
1854
|
+
return /* @__PURE__ */ jsx(TableRow, { style: rowStyle, children: headerGroup.headers.map((header) => {
|
|
1855
|
+
const isPinned = header.column.getIsPinned();
|
|
1856
|
+
const leafHeaders = header.getLeafHeaders();
|
|
1857
|
+
const hasLastLeftPinnedLeaf = leafHeaders.some(
|
|
1858
|
+
(leaf) => leaf.column.getIsPinned() === "left" && leaf.column.getIsLastColumn("left")
|
|
1859
|
+
);
|
|
1860
|
+
const hasFirstRightPinnedLeaf = leafHeaders.some(
|
|
1861
|
+
(leaf) => leaf.column.getIsPinned() === "right" && leaf.column.getIsFirstColumn("right")
|
|
1862
|
+
);
|
|
1863
|
+
const isLastLeftPinned = isPinned === "left" && header.column.getIsLastColumn("left") || hasLastLeftPinnedLeaf;
|
|
1864
|
+
const isFirstRightPinned = isPinned === "right" && header.column.getIsFirstColumn("right") || hasFirstRightPinnedLeaf;
|
|
1865
|
+
const columnRelativeDepth = header.depth - header.column.depth;
|
|
1866
|
+
if (!header.isPlaceholder && columnRelativeDepth > 1 && header.id === header.column.id) {
|
|
1867
|
+
return null;
|
|
1868
|
+
}
|
|
1869
|
+
let rowSpan = 1;
|
|
1870
|
+
if (header.isPlaceholder) {
|
|
1871
|
+
const leafs = header.getLeafHeaders();
|
|
1872
|
+
rowSpan = leafs[leafs.length - 1].depth - header.depth;
|
|
1873
|
+
}
|
|
1874
|
+
return /* @__PURE__ */ jsxs(
|
|
1875
|
+
TableHead,
|
|
1876
|
+
{
|
|
1877
|
+
"data-last-left-pinned": isLastLeftPinned,
|
|
1878
|
+
"data-first-right-pinned": isFirstRightPinned,
|
|
1879
|
+
"data-pinned": isPinned,
|
|
1880
|
+
style: __spreadValues(__spreadValues({}, getResizableCellStyle(header.column, true)), rowStyle && {
|
|
1881
|
+
backgroundColor: rowStyle.backgroundColor,
|
|
1882
|
+
height: rowStyle.height,
|
|
1883
|
+
maxHeight: rowStyle.maxHeight,
|
|
1884
|
+
minHeight: rowStyle.minHeight
|
|
1885
|
+
}),
|
|
1886
|
+
colSpan: header.colSpan,
|
|
1887
|
+
rowSpan,
|
|
1888
|
+
sortable: getTableHeadSortModel(header).showSortMenu,
|
|
1889
|
+
filterable: header.column.getCanFilter(),
|
|
1890
|
+
"data-sortable": getTableHeadSortModel(header).showSortMenu,
|
|
1891
|
+
"data-filterable": header.column.getCanFilter(),
|
|
1892
|
+
children: [
|
|
1893
|
+
/* @__PURE__ */ jsx(TableHeadCell_default, { header }),
|
|
1894
|
+
header.column.getCanResize() && /* @__PURE__ */ jsx(
|
|
1895
|
+
TableResizer,
|
|
1896
|
+
__spreadValues({}, {
|
|
1897
|
+
onDoubleClick: () => header.column.resetSize(),
|
|
1898
|
+
onMouseDown: header.getResizeHandler(),
|
|
1899
|
+
onTouchStart: header.getResizeHandler(),
|
|
1900
|
+
className: `resizer ${header.column.getIsResizing() ? "isResizing" : ""}`
|
|
1901
|
+
})
|
|
1902
|
+
)
|
|
1903
|
+
]
|
|
1904
|
+
},
|
|
1905
|
+
header.id
|
|
1906
|
+
);
|
|
1907
|
+
}) }, headerGroup.id);
|
|
1908
|
+
}) })
|
|
1390
1909
|
}
|
|
1391
1910
|
)
|
|
1392
1911
|
}
|
|
@@ -1395,7 +1914,7 @@ var ResizableTable = ({ tableState }) => {
|
|
|
1395
1914
|
"table",
|
|
1396
1915
|
{
|
|
1397
1916
|
style: {
|
|
1398
|
-
width: `${
|
|
1917
|
+
width: `${totalTableWidth}px`,
|
|
1399
1918
|
minWidth: "100%",
|
|
1400
1919
|
tableLayout: "fixed"
|
|
1401
1920
|
},
|
|
@@ -1416,21 +1935,19 @@ var ResizableTable = ({ tableState }) => {
|
|
|
1416
1935
|
const isVirtual = "virtualRow" in rowObj && rowObj.virtualRow;
|
|
1417
1936
|
const row = rowObj.row;
|
|
1418
1937
|
const cells = typeof row.getVisibleCells === "function" ? row.getVisibleCells() : row;
|
|
1938
|
+
const rowStyle = typeof bodyRowStyle === "function" ? bodyRowStyle(i, row.original) : bodyRowStyle;
|
|
1939
|
+
const cellBackgroundColor = rowStyle == null ? void 0 : rowStyle.backgroundColor;
|
|
1419
1940
|
return /* @__PURE__ */ jsx(
|
|
1420
1941
|
TableRow,
|
|
1421
1942
|
{
|
|
1422
1943
|
"data-index": isVirtual ? rowObj.virtualRow.index : i,
|
|
1423
1944
|
onClick: () => {
|
|
1424
|
-
|
|
1425
|
-
if (typeof row.getVisibleCells === "function") {
|
|
1426
|
-
onClickRow == null ? void 0 : onClickRow(row.original);
|
|
1427
|
-
} else if (Array.isArray(row) && row.length > 0 && ((_a = row[0].row) == null ? void 0 : _a.original)) {
|
|
1428
|
-
onClickRow == null ? void 0 : onClickRow(row[0].row.original);
|
|
1429
|
-
}
|
|
1945
|
+
onClickRow == null ? void 0 : onClickRow(row.original);
|
|
1430
1946
|
},
|
|
1431
1947
|
className: onClickRow !== void 0 ? "clickable" : "",
|
|
1948
|
+
style: rowStyle,
|
|
1432
1949
|
children: cells.map((cell) => {
|
|
1433
|
-
var _a;
|
|
1950
|
+
var _a, _b, _c, _d;
|
|
1434
1951
|
const isPinned = cell.column.getIsPinned();
|
|
1435
1952
|
const isLastLeftPinned = isPinned === "left" && cell.column.getIsLastColumn("left");
|
|
1436
1953
|
const isFirstRightPinned = isPinned === "right" && cell.column.getIsFirstColumn("right");
|
|
@@ -1439,8 +1956,14 @@ var ResizableTable = ({ tableState }) => {
|
|
|
1439
1956
|
{
|
|
1440
1957
|
"data-last-left-pinned": isLastLeftPinned,
|
|
1441
1958
|
"data-first-right-pinned": isFirstRightPinned,
|
|
1442
|
-
"data-no-hover": (
|
|
1443
|
-
|
|
1959
|
+
"data-no-hover": getColumnActiveHoverDataAttribute(
|
|
1960
|
+
(_a = cell.column.columnDef.meta) == null ? void 0 : _a.activeHover,
|
|
1961
|
+
cell.row.original
|
|
1962
|
+
),
|
|
1963
|
+
"data-has-custom-style": ((_d = (_c = (_b = cell.column.columnDef.meta) == null ? void 0 : _b.cellProps) == null ? void 0 : _c.style) == null ? void 0 : _d.backgroundColor) ? "true" : void 0,
|
|
1964
|
+
style: __spreadValues(__spreadValues({}, getResizableCellStyle(cell.column)), cellBackgroundColor && {
|
|
1965
|
+
backgroundColor: cellBackgroundColor
|
|
1966
|
+
}),
|
|
1444
1967
|
children: flexRender(cell.column.columnDef.cell, cell.getContext())
|
|
1445
1968
|
},
|
|
1446
1969
|
cell.id
|
|
@@ -1462,79 +1985,1489 @@ var ResizableTable = ({ tableState }) => {
|
|
|
1462
1985
|
) }, `empty-row-${index}`))
|
|
1463
1986
|
] }) })
|
|
1464
1987
|
}
|
|
1465
|
-
) }) })
|
|
1466
|
-
] });
|
|
1988
|
+
) }) })
|
|
1989
|
+
] });
|
|
1990
|
+
};
|
|
1991
|
+
var distributeResponsiveWidths = ({
|
|
1992
|
+
baseWidths,
|
|
1993
|
+
autoIndexes,
|
|
1994
|
+
maxWidths,
|
|
1995
|
+
targetTotalWidth
|
|
1996
|
+
}) => {
|
|
1997
|
+
const widths = [...baseWidths];
|
|
1998
|
+
const baseTotal = baseWidths.reduce((sum, width) => sum + width, 0);
|
|
1999
|
+
let remaining = Math.max(0, targetTotalWidth - baseTotal);
|
|
2000
|
+
if (remaining === 0 || autoIndexes.length === 0)
|
|
2001
|
+
return widths;
|
|
2002
|
+
const growable = new Set(autoIndexes);
|
|
2003
|
+
while (remaining > 0.01 && growable.size > 0) {
|
|
2004
|
+
const share = remaining / growable.size;
|
|
2005
|
+
let distributed = 0;
|
|
2006
|
+
Array.from(growable).forEach((index) => {
|
|
2007
|
+
var _a;
|
|
2008
|
+
const maxWidth = (_a = maxWidths[index]) != null ? _a : Number.POSITIVE_INFINITY;
|
|
2009
|
+
const capacity = Math.max(0, maxWidth - widths[index]);
|
|
2010
|
+
const delta = Math.min(share, capacity);
|
|
2011
|
+
widths[index] += delta;
|
|
2012
|
+
distributed += delta;
|
|
2013
|
+
if (capacity <= share + 0.01)
|
|
2014
|
+
growable.delete(index);
|
|
2015
|
+
});
|
|
2016
|
+
if (distributed <= 0.01)
|
|
2017
|
+
break;
|
|
2018
|
+
remaining -= distributed;
|
|
2019
|
+
}
|
|
2020
|
+
return widths;
|
|
2021
|
+
};
|
|
2022
|
+
var useResponsiveViewportWidth = (tableContainerRef, headerRef) => {
|
|
2023
|
+
const subscribe = useCallback(
|
|
2024
|
+
(onStoreChange) => {
|
|
2025
|
+
let rafId = null;
|
|
2026
|
+
const notifyWithBatch = () => {
|
|
2027
|
+
if (rafId !== null)
|
|
2028
|
+
return;
|
|
2029
|
+
rafId = window.requestAnimationFrame(() => {
|
|
2030
|
+
rafId = null;
|
|
2031
|
+
onStoreChange();
|
|
2032
|
+
});
|
|
2033
|
+
};
|
|
2034
|
+
const resizeObserver = new ResizeObserver(() => {
|
|
2035
|
+
notifyWithBatch();
|
|
2036
|
+
});
|
|
2037
|
+
if (tableContainerRef.current)
|
|
2038
|
+
resizeObserver.observe(tableContainerRef.current);
|
|
2039
|
+
if (headerRef.current)
|
|
2040
|
+
resizeObserver.observe(headerRef.current);
|
|
2041
|
+
window.addEventListener("resize", notifyWithBatch);
|
|
2042
|
+
return () => {
|
|
2043
|
+
if (rafId !== null) {
|
|
2044
|
+
window.cancelAnimationFrame(rafId);
|
|
2045
|
+
rafId = null;
|
|
2046
|
+
}
|
|
2047
|
+
resizeObserver.disconnect();
|
|
2048
|
+
window.removeEventListener("resize", notifyWithBatch);
|
|
2049
|
+
};
|
|
2050
|
+
},
|
|
2051
|
+
[tableContainerRef, headerRef]
|
|
2052
|
+
);
|
|
2053
|
+
const getSnapshot = useCallback(
|
|
2054
|
+
() => {
|
|
2055
|
+
var _a, _b, _c, _d;
|
|
2056
|
+
return (_d = (_c = (_a = tableContainerRef.current) == null ? void 0 : _a.clientWidth) != null ? _c : (_b = headerRef.current) == null ? void 0 : _b.clientWidth) != null ? _d : 0;
|
|
2057
|
+
},
|
|
2058
|
+
[tableContainerRef, headerRef]
|
|
2059
|
+
);
|
|
2060
|
+
return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
|
|
2061
|
+
};
|
|
2062
|
+
var useResponsiveColumnLayout = ({
|
|
2063
|
+
unpinnedColumns,
|
|
2064
|
+
leftPinnedColumns,
|
|
2065
|
+
rightPinnedColumns,
|
|
2066
|
+
viewportWidth
|
|
2067
|
+
}) => {
|
|
2068
|
+
const getColumnMaxSize = useCallback((column) => {
|
|
2069
|
+
var _a;
|
|
2070
|
+
const maxSize = (_a = column == null ? void 0 : column.columnDef) == null ? void 0 : _a.maxSize;
|
|
2071
|
+
return typeof maxSize === "number" && maxSize > 0 ? maxSize : Number.POSITIVE_INFINITY;
|
|
2072
|
+
}, []);
|
|
2073
|
+
const getActualColumnSize = useCallback(
|
|
2074
|
+
(column) => {
|
|
2075
|
+
var _a;
|
|
2076
|
+
if (!column)
|
|
2077
|
+
return 150;
|
|
2078
|
+
const tableSize = (_a = column.getSize) == null ? void 0 : _a.call(column);
|
|
2079
|
+
if (typeof tableSize === "number" && Number.isFinite(tableSize) && tableSize > 0)
|
|
2080
|
+
return tableSize;
|
|
2081
|
+
const size = column.columnDef.size;
|
|
2082
|
+
if (typeof size === "number" && size > 0)
|
|
2083
|
+
return size;
|
|
2084
|
+
const minSize = column.columnDef.minSize;
|
|
2085
|
+
if (typeof minSize === "number" && minSize > 0) {
|
|
2086
|
+
return Math.min(minSize, getColumnMaxSize(column));
|
|
2087
|
+
}
|
|
2088
|
+
return Math.min(150, getColumnMaxSize(column));
|
|
2089
|
+
},
|
|
2090
|
+
[getColumnMaxSize]
|
|
2091
|
+
);
|
|
2092
|
+
const leftPinnedWidth = useMemo(
|
|
2093
|
+
() => leftPinnedColumns.reduce((sum, header) => sum + getActualColumnSize(header.column), 0),
|
|
2094
|
+
[leftPinnedColumns, getActualColumnSize]
|
|
2095
|
+
);
|
|
2096
|
+
const rightPinnedWidth = useMemo(
|
|
2097
|
+
() => rightPinnedColumns.reduce((sum, header) => sum + getActualColumnSize(header.column), 0),
|
|
2098
|
+
[rightPinnedColumns, getActualColumnSize]
|
|
2099
|
+
);
|
|
2100
|
+
const baseUnpinnedWidths = useMemo(
|
|
2101
|
+
() => unpinnedColumns.map((header) => getActualColumnSize(header.column)),
|
|
2102
|
+
[unpinnedColumns, getActualColumnSize]
|
|
2103
|
+
);
|
|
2104
|
+
const autoColumnIndexes = useMemo(
|
|
2105
|
+
() => unpinnedColumns.map((header, index) => ({ index, size: header.column.columnDef.size })).filter(({ size }) => typeof size !== "number").map(({ index }) => index),
|
|
2106
|
+
[unpinnedColumns]
|
|
2107
|
+
);
|
|
2108
|
+
const baseUnpinnedWidth = useMemo(
|
|
2109
|
+
() => baseUnpinnedWidths.reduce((sum, width) => sum + width, 0),
|
|
2110
|
+
[baseUnpinnedWidths]
|
|
2111
|
+
);
|
|
2112
|
+
const availableUnpinnedWidth = Math.max(0, viewportWidth - leftPinnedWidth - rightPinnedWidth);
|
|
2113
|
+
const targetUnpinnedWidth = Math.max(baseUnpinnedWidth, availableUnpinnedWidth);
|
|
2114
|
+
const unpinnedMaxWidths = useMemo(
|
|
2115
|
+
() => unpinnedColumns.map((header) => getColumnMaxSize(header.column)),
|
|
2116
|
+
[getColumnMaxSize, unpinnedColumns]
|
|
2117
|
+
);
|
|
2118
|
+
const computedUnpinnedWidths = useMemo(
|
|
2119
|
+
() => distributeResponsiveWidths({
|
|
2120
|
+
baseWidths: baseUnpinnedWidths,
|
|
2121
|
+
autoIndexes: autoColumnIndexes,
|
|
2122
|
+
maxWidths: unpinnedMaxWidths,
|
|
2123
|
+
targetTotalWidth: targetUnpinnedWidth
|
|
2124
|
+
}),
|
|
2125
|
+
[autoColumnIndexes, baseUnpinnedWidths, targetUnpinnedWidth, unpinnedMaxWidths]
|
|
2126
|
+
);
|
|
2127
|
+
const totalUnpinnedWidth = useMemo(
|
|
2128
|
+
() => computedUnpinnedWidths.reduce((sum, width) => sum + width, 0),
|
|
2129
|
+
[computedUnpinnedWidths]
|
|
2130
|
+
);
|
|
2131
|
+
const getUnpinnedColumnWidth = useCallback(
|
|
2132
|
+
(index) => {
|
|
2133
|
+
var _a;
|
|
2134
|
+
return (_a = computedUnpinnedWidths[index]) != null ? _a : 150;
|
|
2135
|
+
},
|
|
2136
|
+
[computedUnpinnedWidths]
|
|
2137
|
+
);
|
|
2138
|
+
const totalTableWidth = useMemo(
|
|
2139
|
+
() => leftPinnedWidth + totalUnpinnedWidth + rightPinnedWidth,
|
|
2140
|
+
[leftPinnedWidth, totalUnpinnedWidth, rightPinnedWidth]
|
|
2141
|
+
);
|
|
2142
|
+
return {
|
|
2143
|
+
getActualColumnSize,
|
|
2144
|
+
getUnpinnedColumnWidth,
|
|
2145
|
+
totalUnpinnedWidth,
|
|
2146
|
+
totalTableWidth
|
|
2147
|
+
};
|
|
2148
|
+
};
|
|
2149
|
+
var PinnedColumnEdgeShadow = styled3.div`
|
|
2150
|
+
position: absolute;
|
|
2151
|
+
top: 0;
|
|
2152
|
+
right: -4px;
|
|
2153
|
+
height: 100%;
|
|
2154
|
+
width: 4px;
|
|
2155
|
+
pointer-events: none;
|
|
2156
|
+
z-index: 11;
|
|
2157
|
+
background: linear-gradient(to right, rgba(0, 0, 0, 0.1), transparent);
|
|
2158
|
+
`;
|
|
2159
|
+
var VirtualTableRoot = styled3.div`
|
|
2160
|
+
position: relative;
|
|
2161
|
+
width: 100%;
|
|
2162
|
+
`;
|
|
2163
|
+
var VirtualTableScrollAreaInner = styled3.div`
|
|
2164
|
+
position: relative;
|
|
2165
|
+
width: 100%;
|
|
2166
|
+
`;
|
|
2167
|
+
var VirtualTableHeaderRoot = styled3.div`
|
|
2168
|
+
width: 100%;
|
|
2169
|
+
z-index: 11;
|
|
2170
|
+
position: sticky;
|
|
2171
|
+
top: 0;
|
|
2172
|
+
overflow-x: scroll;
|
|
2173
|
+
-ms-overflow-style: none;
|
|
2174
|
+
scrollbar-width: none;
|
|
2175
|
+
|
|
2176
|
+
&::-webkit-scrollbar {
|
|
2177
|
+
display: none;
|
|
2178
|
+
}
|
|
2179
|
+
`;
|
|
2180
|
+
var VirtualTableHeaderInner = styled3.div`
|
|
2181
|
+
background-color: ${colorTokens.neutral100};
|
|
2182
|
+
`;
|
|
2183
|
+
var VirtualTableHeaderRow = styled3.div`
|
|
2184
|
+
display: flex;
|
|
2185
|
+
width: ${({ $tableWidthPx }) => `${$tableWidthPx}px`};
|
|
2186
|
+
min-width: 100%;
|
|
2187
|
+
`;
|
|
2188
|
+
var VirtualTableGroupHeaderCell = styled3.div`
|
|
2189
|
+
display: flex;
|
|
2190
|
+
align-items: center;
|
|
2191
|
+
padding: 8px;
|
|
2192
|
+
height: 48px;
|
|
2193
|
+
font-weight: 400;
|
|
2194
|
+
line-height: 16px;
|
|
2195
|
+
font-size: 13px;
|
|
2196
|
+
border-bottom: 1px solid ${colorTokens.neutral200};
|
|
2197
|
+
background-color: ${colorTokens.neutral100};
|
|
2198
|
+
box-sizing: border-box;
|
|
2199
|
+
border-right: 1px solid ${colorTokens.neutral200};
|
|
2200
|
+
|
|
2201
|
+
&[data-last-left-pinned='true'] {
|
|
2202
|
+
border-right: none;
|
|
2203
|
+
}
|
|
2204
|
+
|
|
2205
|
+
position: relative;
|
|
2206
|
+
z-index: 0;
|
|
2207
|
+
|
|
2208
|
+
&[data-pinned='left'],
|
|
2209
|
+
&[data-pinned='right'] {
|
|
2210
|
+
position: sticky;
|
|
2211
|
+
z-index: 10;
|
|
2212
|
+
}
|
|
2213
|
+
`;
|
|
2214
|
+
var VirtualTableLeafHeaderPinnedLeft = styled3.div`
|
|
2215
|
+
display: flex;
|
|
2216
|
+
align-items: center;
|
|
2217
|
+
padding: 8px;
|
|
2218
|
+
height: 48px;
|
|
2219
|
+
font-weight: 400;
|
|
2220
|
+
line-height: 16px;
|
|
2221
|
+
font-size: 13px;
|
|
2222
|
+
border-bottom: 1px solid ${colorTokens.neutral200};
|
|
2223
|
+
background-color: ${colorTokens.neutral100};
|
|
2224
|
+
box-sizing: border-box;
|
|
2225
|
+
border-right: 1px solid ${colorTokens.neutral200};
|
|
2226
|
+
position: sticky;
|
|
2227
|
+
z-index: 10;
|
|
2228
|
+
|
|
2229
|
+
&[data-last-left-pinned='true'] {
|
|
2230
|
+
border-right: none;
|
|
2231
|
+
}
|
|
2232
|
+
`;
|
|
2233
|
+
var VirtualTableVirtualizedColumnsOuter = styled3.div`
|
|
2234
|
+
display: flex;
|
|
2235
|
+
width: ${({ $unpinnedWidthPx }) => `${$unpinnedWidthPx}px`};
|
|
2236
|
+
min-width: ${({ $unpinnedWidthPx }) => `${$unpinnedWidthPx}px`};
|
|
2237
|
+
position: relative;
|
|
2238
|
+
flex-shrink: 0;
|
|
2239
|
+
overflow: hidden;
|
|
2240
|
+
`;
|
|
2241
|
+
var VirtualTableHorizontalVirtualTrack = styled3.div`
|
|
2242
|
+
display: flex;
|
|
2243
|
+
transform: translateX(${(p) => p.$translateX}px);
|
|
2244
|
+
will-change: transform;
|
|
2245
|
+
${({ $fillHeight }) => $fillHeight ? `height: 100%;` : ""}
|
|
2246
|
+
`;
|
|
2247
|
+
var VirtualTableLeafHeaderUnpinnedCell = styled3.div`
|
|
2248
|
+
display: flex;
|
|
2249
|
+
align-items: center;
|
|
2250
|
+
padding: 8px;
|
|
2251
|
+
height: 48px;
|
|
2252
|
+
font-weight: 400;
|
|
2253
|
+
line-height: 16px;
|
|
2254
|
+
font-size: 13px;
|
|
2255
|
+
border-bottom: 1px solid ${colorTokens.neutral200};
|
|
2256
|
+
border-right: 1px solid ${colorTokens.neutral200};
|
|
2257
|
+
background-color: ${colorTokens.neutral100};
|
|
2258
|
+
box-sizing: border-box;
|
|
2259
|
+
flex-shrink: 0;
|
|
2260
|
+
`;
|
|
2261
|
+
var VirtualTableLeafHeaderPinnedRight = styled3.div`
|
|
2262
|
+
display: flex;
|
|
2263
|
+
align-items: center;
|
|
2264
|
+
padding: 8px;
|
|
2265
|
+
height: 48px;
|
|
2266
|
+
font-weight: 400;
|
|
2267
|
+
line-height: 16px;
|
|
2268
|
+
font-size: 13px;
|
|
2269
|
+
border-bottom: 1px solid ${colorTokens.neutral200};
|
|
2270
|
+
border-right: none;
|
|
2271
|
+
background-color: ${colorTokens.neutral100};
|
|
2272
|
+
box-sizing: border-box;
|
|
2273
|
+
position: sticky;
|
|
2274
|
+
z-index: 10;
|
|
2275
|
+
`;
|
|
2276
|
+
var VirtualTableBodyRow = styled3.div`
|
|
2277
|
+
display: flex;
|
|
2278
|
+
width: ${({ $tableWidthPx }) => `${$tableWidthPx}px`};
|
|
2279
|
+
min-width: 100%;
|
|
2280
|
+
height: ${({ $rowHeightPx }) => `${$rowHeightPx != null ? $rowHeightPx : 60}px`};
|
|
2281
|
+
min-height: ${({ $rowHeightPx }) => `${$rowHeightPx != null ? $rowHeightPx : 60}px`};
|
|
2282
|
+
border-bottom: 1px solid ${colorTokens.neutral200};
|
|
2283
|
+
`;
|
|
2284
|
+
var VirtualTableBodyPinnedCell = styled3.div`
|
|
2285
|
+
display: flex;
|
|
2286
|
+
align-items: center;
|
|
2287
|
+
padding: 8px;
|
|
2288
|
+
height: 100%;
|
|
2289
|
+
background-color: ${colorTokens.neutral0};
|
|
2290
|
+
position: sticky;
|
|
2291
|
+
z-index: 10;
|
|
2292
|
+
box-sizing: border-box;
|
|
2293
|
+
`;
|
|
2294
|
+
var VirtualTableBodyUnpinnedSlice = styled3.div`
|
|
2295
|
+
display: flex;
|
|
2296
|
+
width: ${({ $unpinnedWidthPx }) => `${$unpinnedWidthPx}px`};
|
|
2297
|
+
min-width: ${({ $unpinnedWidthPx }) => `${$unpinnedWidthPx}px`};
|
|
2298
|
+
position: relative;
|
|
2299
|
+
flex-shrink: 0;
|
|
2300
|
+
overflow: hidden;
|
|
2301
|
+
`;
|
|
2302
|
+
var VirtualTableBodyUnpinnedCell = styled3.div`
|
|
2303
|
+
display: flex;
|
|
2304
|
+
align-items: center;
|
|
2305
|
+
padding: 8px;
|
|
2306
|
+
height: 100%;
|
|
2307
|
+
background-color: ${colorTokens.neutral0};
|
|
2308
|
+
box-sizing: border-box;
|
|
2309
|
+
flex-shrink: 0;
|
|
2310
|
+
`;
|
|
2311
|
+
var VirtualTableBodyGrid = styled3.div`
|
|
2312
|
+
display: grid;
|
|
2313
|
+
height: ${({ $totalHeightPx }) => `${$totalHeightPx}px`};
|
|
2314
|
+
position: relative;
|
|
2315
|
+
color: ${colorTokens.neutral700};
|
|
2316
|
+
font-size: 14px;
|
|
2317
|
+
overflow-x: scroll;
|
|
2318
|
+
overflow-y: hidden;
|
|
2319
|
+
-ms-overflow-style: none;
|
|
2320
|
+
scrollbar-width: none;
|
|
2321
|
+
|
|
2322
|
+
&::-webkit-scrollbar {
|
|
2323
|
+
display: none;
|
|
2324
|
+
}
|
|
2325
|
+
`;
|
|
2326
|
+
var VirtualTableVerticalVirtualTrack = styled3.div`
|
|
2327
|
+
position: absolute;
|
|
2328
|
+
top: 0;
|
|
2329
|
+
left: 0;
|
|
2330
|
+
width: 100%;
|
|
2331
|
+
transform: translateY(${(p) => p.$translateY}px);
|
|
2332
|
+
will-change: transform;
|
|
2333
|
+
display: flex;
|
|
2334
|
+
flex-direction: column;
|
|
2335
|
+
`;
|
|
2336
|
+
var CellSkeleton2 = () => /* @__PURE__ */ jsx(Skeleton, { styleVar: "rectangle", width: "80%", height: "20px" });
|
|
2337
|
+
var GroupHeaderRow = React3.memo(({ headerGroup, getActualColumnSize }) => {
|
|
2338
|
+
return /* @__PURE__ */ jsx(Fragment, { children: headerGroup.headers.map((header) => {
|
|
2339
|
+
const leafHeaders = header.getLeafHeaders ? header.getLeafHeaders() : [];
|
|
2340
|
+
const groupId = header.column.id;
|
|
2341
|
+
const filteredLeafHeaders = leafHeaders.filter((leaf) => leaf.column.id !== groupId);
|
|
2342
|
+
const firstLeaf = filteredLeafHeaders[0];
|
|
2343
|
+
const firstLeafPinned = firstLeaf == null ? void 0 : firstLeaf.column.getIsPinned();
|
|
2344
|
+
const totalWidth = filteredLeafHeaders.reduce((sum, leaf) => {
|
|
2345
|
+
return sum + getActualColumnSize(leaf.column);
|
|
2346
|
+
}, 0);
|
|
2347
|
+
const hasLastLeftPinnedLeaf = filteredLeafHeaders.some(
|
|
2348
|
+
(leaf) => leaf.column.getIsPinned() === "left" && leaf.column.getIsLastColumn("left")
|
|
2349
|
+
);
|
|
2350
|
+
const hasFirstRightPinnedLeaf = filteredLeafHeaders.some(
|
|
2351
|
+
(leaf) => leaf.column.getIsPinned() === "right" && leaf.column.getIsFirstColumn("right")
|
|
2352
|
+
);
|
|
2353
|
+
const positionStyle = {
|
|
2354
|
+
width: `${totalWidth}px`,
|
|
2355
|
+
minWidth: `${totalWidth}px`,
|
|
2356
|
+
maxWidth: `${totalWidth}px`,
|
|
2357
|
+
left: firstLeafPinned === "left" ? `${firstLeaf == null ? void 0 : firstLeaf.column.getStart("left")}px` : void 0,
|
|
2358
|
+
right: firstLeafPinned === "right" ? `${firstLeaf == null ? void 0 : firstLeaf.column.getAfter("right")}px` : void 0
|
|
2359
|
+
};
|
|
2360
|
+
return /* @__PURE__ */ jsxs(
|
|
2361
|
+
VirtualTableGroupHeaderCell,
|
|
2362
|
+
{
|
|
2363
|
+
"data-last-left-pinned": hasLastLeftPinnedLeaf,
|
|
2364
|
+
"data-first-right-pinned": hasFirstRightPinnedLeaf,
|
|
2365
|
+
"data-pinned": firstLeafPinned || void 0,
|
|
2366
|
+
style: positionStyle,
|
|
2367
|
+
children: [
|
|
2368
|
+
header.isPlaceholder ? null : /* @__PURE__ */ jsx(TableHeadCell_default, { header }),
|
|
2369
|
+
hasLastLeftPinnedLeaf && /* @__PURE__ */ jsx(PinnedColumnEdgeShadow, {})
|
|
2370
|
+
]
|
|
2371
|
+
},
|
|
2372
|
+
header.id
|
|
2373
|
+
);
|
|
2374
|
+
}) });
|
|
2375
|
+
});
|
|
2376
|
+
GroupHeaderRow.displayName = "GroupHeaderRow";
|
|
2377
|
+
var LeafHeaderRow = React3.memo(
|
|
2378
|
+
({
|
|
2379
|
+
leftPinnedColumns,
|
|
2380
|
+
rightPinnedColumns,
|
|
2381
|
+
unpinnedColumns,
|
|
2382
|
+
virtualItems,
|
|
2383
|
+
totalUnpinnedWidth,
|
|
2384
|
+
getActualColumnSize,
|
|
2385
|
+
getUnpinnedColumnWidth
|
|
2386
|
+
}) => {
|
|
2387
|
+
var _a, _b;
|
|
2388
|
+
const leftPinnedPrepared = useMemo(
|
|
2389
|
+
() => leftPinnedColumns.map((header) => {
|
|
2390
|
+
const isPinned = header.column.getIsPinned();
|
|
2391
|
+
const isLastLeftPinned = isPinned === "left" && header.column.getIsLastColumn("left");
|
|
2392
|
+
const headerWidth = getActualColumnSize(header.column);
|
|
2393
|
+
const leftPosition = header.column.getStart("left");
|
|
2394
|
+
return {
|
|
2395
|
+
header,
|
|
2396
|
+
isPinned,
|
|
2397
|
+
isLastLeftPinned,
|
|
2398
|
+
style: {
|
|
2399
|
+
width: `${headerWidth}px`,
|
|
2400
|
+
minWidth: `${headerWidth}px`,
|
|
2401
|
+
left: `${leftPosition}px`
|
|
2402
|
+
}
|
|
2403
|
+
};
|
|
2404
|
+
}),
|
|
2405
|
+
[leftPinnedColumns, getActualColumnSize]
|
|
2406
|
+
);
|
|
2407
|
+
const rightPinnedPrepared = useMemo(
|
|
2408
|
+
() => rightPinnedColumns.map((header) => {
|
|
2409
|
+
const isPinned = header.column.getIsPinned();
|
|
2410
|
+
const isFirstRightPinned = isPinned === "right" && header.column.getIsFirstColumn("right");
|
|
2411
|
+
const headerWidth = getActualColumnSize(header.column);
|
|
2412
|
+
const rightPosition = header.column.getAfter("right");
|
|
2413
|
+
return {
|
|
2414
|
+
header,
|
|
2415
|
+
isPinned,
|
|
2416
|
+
isFirstRightPinned,
|
|
2417
|
+
style: {
|
|
2418
|
+
width: `${headerWidth}px`,
|
|
2419
|
+
minWidth: `${headerWidth}px`,
|
|
2420
|
+
right: `${rightPosition}px`
|
|
2421
|
+
}
|
|
2422
|
+
};
|
|
2423
|
+
}),
|
|
2424
|
+
[rightPinnedColumns, getActualColumnSize]
|
|
2425
|
+
);
|
|
2426
|
+
const virtualItemsLayoutKey = useMemo(
|
|
2427
|
+
() => virtualItems.map((v) => `${v.index}:${v.start}`).join("|"),
|
|
2428
|
+
[virtualItems]
|
|
2429
|
+
);
|
|
2430
|
+
const unpinnedPrepared = useMemo(() => {
|
|
2431
|
+
return virtualItems.map((virtualColumn) => {
|
|
2432
|
+
const header = unpinnedColumns[virtualColumn.index];
|
|
2433
|
+
if (!header)
|
|
2434
|
+
return null;
|
|
2435
|
+
const columnWidth = getUnpinnedColumnWidth(virtualColumn.index);
|
|
2436
|
+
return {
|
|
2437
|
+
header,
|
|
2438
|
+
style: {
|
|
2439
|
+
width: `${columnWidth}px`,
|
|
2440
|
+
minWidth: `${columnWidth}px`,
|
|
2441
|
+
maxWidth: `${columnWidth}px`
|
|
2442
|
+
}
|
|
2443
|
+
};
|
|
2444
|
+
});
|
|
2445
|
+
}, [virtualItemsLayoutKey, unpinnedColumns, getUnpinnedColumnWidth]);
|
|
2446
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2447
|
+
leftPinnedPrepared.map(({ header, isPinned, isLastLeftPinned, style }) => /* @__PURE__ */ jsxs(
|
|
2448
|
+
VirtualTableLeafHeaderPinnedLeft,
|
|
2449
|
+
{
|
|
2450
|
+
"data-last-left-pinned": isLastLeftPinned,
|
|
2451
|
+
"data-pinned": isPinned,
|
|
2452
|
+
style,
|
|
2453
|
+
children: [
|
|
2454
|
+
header.isPlaceholder ? null : /* @__PURE__ */ jsx(TableHeadCell_default, { header }),
|
|
2455
|
+
isLastLeftPinned && /* @__PURE__ */ jsx(PinnedColumnEdgeShadow, {})
|
|
2456
|
+
]
|
|
2457
|
+
},
|
|
2458
|
+
header.id
|
|
2459
|
+
)),
|
|
2460
|
+
/* @__PURE__ */ jsx(VirtualTableVirtualizedColumnsOuter, { $unpinnedWidthPx: totalUnpinnedWidth, children: /* @__PURE__ */ jsx(VirtualTableHorizontalVirtualTrack, { $translateX: (_b = (_a = virtualItems[0]) == null ? void 0 : _a.start) != null ? _b : 0, children: unpinnedPrepared.map((item) => {
|
|
2461
|
+
if (!item)
|
|
2462
|
+
return null;
|
|
2463
|
+
const { header, style } = item;
|
|
2464
|
+
return /* @__PURE__ */ jsx(VirtualTableLeafHeaderUnpinnedCell, { style, children: /* @__PURE__ */ jsx(TableHeadCell_default, { header }) }, header.id);
|
|
2465
|
+
}) }) }),
|
|
2466
|
+
rightPinnedPrepared.map(({ header, isPinned, isFirstRightPinned, style }) => /* @__PURE__ */ jsx(
|
|
2467
|
+
VirtualTableLeafHeaderPinnedRight,
|
|
2468
|
+
{
|
|
2469
|
+
"data-first-right-pinned": isFirstRightPinned,
|
|
2470
|
+
"data-pinned": isPinned,
|
|
2471
|
+
style,
|
|
2472
|
+
children: header.isPlaceholder ? null : /* @__PURE__ */ jsx(TableHeadCell_default, { header })
|
|
2473
|
+
},
|
|
2474
|
+
header.id
|
|
2475
|
+
))
|
|
2476
|
+
] });
|
|
2477
|
+
}
|
|
2478
|
+
);
|
|
2479
|
+
LeafHeaderRow.displayName = "LeafHeaderRow";
|
|
2480
|
+
var VirtualTableHeader = ({
|
|
2481
|
+
table,
|
|
2482
|
+
headerRef,
|
|
2483
|
+
getFixedCellStyle: _getFixedCellStyle,
|
|
2484
|
+
tableContainerRef: _tableContainerRef,
|
|
2485
|
+
scrollViewportRef: _scrollViewportRef,
|
|
2486
|
+
onVirtualItemsChange,
|
|
2487
|
+
onHeaderScroll,
|
|
2488
|
+
viewportWidth
|
|
2489
|
+
}) => {
|
|
2490
|
+
const headerGroups = table.getHeaderGroups();
|
|
2491
|
+
const leafHeaderGroup = headerGroups[headerGroups.length - 1];
|
|
2492
|
+
const allHeaders = useMemo(() => {
|
|
2493
|
+
const headers = (leafHeaderGroup == null ? void 0 : leafHeaderGroup.headers) || [];
|
|
2494
|
+
return headers.filter((h) => {
|
|
2495
|
+
const columns = h.column.columnDef.columns;
|
|
2496
|
+
return !columns || columns.length === 0;
|
|
2497
|
+
});
|
|
2498
|
+
}, [leafHeaderGroup]);
|
|
2499
|
+
const { leftPinnedColumns, rightPinnedColumns, unpinnedColumns } = useMemo(() => {
|
|
2500
|
+
const left = allHeaders.filter((h) => h.column.getIsPinned() === "left");
|
|
2501
|
+
const right = allHeaders.filter((h) => h.column.getIsPinned() === "right");
|
|
2502
|
+
const unpinned = allHeaders.filter((h) => !h.column.getIsPinned());
|
|
2503
|
+
return {
|
|
2504
|
+
leftPinnedColumns: left,
|
|
2505
|
+
rightPinnedColumns: right,
|
|
2506
|
+
unpinnedColumns: unpinned
|
|
2507
|
+
};
|
|
2508
|
+
}, [allHeaders]);
|
|
2509
|
+
const { getActualColumnSize, getUnpinnedColumnWidth, totalUnpinnedWidth, totalTableWidth } = useResponsiveColumnLayout({
|
|
2510
|
+
unpinnedColumns,
|
|
2511
|
+
leftPinnedColumns,
|
|
2512
|
+
rightPinnedColumns,
|
|
2513
|
+
viewportWidth
|
|
2514
|
+
});
|
|
2515
|
+
const estimateSize = useCallback((index) => getUnpinnedColumnWidth(index), [getUnpinnedColumnWidth]);
|
|
2516
|
+
const columnVirtualizer = useVirtualizer({
|
|
2517
|
+
// flushSync는 중첩 렌더/레이아웃 효과와 충돌 시 경고를 유발하므로 비활성화
|
|
2518
|
+
// useFlushSync: false,
|
|
2519
|
+
count: unpinnedColumns.length,
|
|
2520
|
+
getScrollElement: () => headerRef.current,
|
|
2521
|
+
estimateSize,
|
|
2522
|
+
horizontal: true,
|
|
2523
|
+
overscan: 5
|
|
2524
|
+
});
|
|
2525
|
+
const virtualItems = columnVirtualizer.getVirtualItems();
|
|
2526
|
+
React3.useEffect(() => {
|
|
2527
|
+
if (onVirtualItemsChange) {
|
|
2528
|
+
onVirtualItemsChange(virtualItems);
|
|
2529
|
+
}
|
|
2530
|
+
}, [virtualItems, onVirtualItemsChange]);
|
|
2531
|
+
React3.useEffect(() => {
|
|
2532
|
+
if (headerRef.current) {
|
|
2533
|
+
const timeoutId = setTimeout(() => {
|
|
2534
|
+
columnVirtualizer.measure();
|
|
2535
|
+
}, 0);
|
|
2536
|
+
return () => clearTimeout(timeoutId);
|
|
2537
|
+
}
|
|
2538
|
+
}, [columnVirtualizer, headerRef]);
|
|
2539
|
+
const handleHeaderScroll = useCallback(() => {
|
|
2540
|
+
if (!headerRef.current || !onHeaderScroll)
|
|
2541
|
+
return;
|
|
2542
|
+
onHeaderScroll();
|
|
2543
|
+
}, [headerRef, onHeaderScroll]);
|
|
2544
|
+
return /* @__PURE__ */ jsx(VirtualTableHeaderRoot, { ref: headerRef, onScroll: handleHeaderScroll, children: /* @__PURE__ */ jsx(VirtualTableHeaderInner, { children: headerGroups.map((headerGroup, groupIndex) => {
|
|
2545
|
+
const isLeafRow = groupIndex === headerGroups.length - 1;
|
|
2546
|
+
return /* @__PURE__ */ jsx(VirtualTableHeaderRow, { $tableWidthPx: totalTableWidth, children: isLeafRow ? /* @__PURE__ */ jsx(
|
|
2547
|
+
LeafHeaderRow,
|
|
2548
|
+
{
|
|
2549
|
+
leftPinnedColumns,
|
|
2550
|
+
rightPinnedColumns,
|
|
2551
|
+
unpinnedColumns,
|
|
2552
|
+
virtualItems,
|
|
2553
|
+
totalUnpinnedWidth,
|
|
2554
|
+
getActualColumnSize,
|
|
2555
|
+
getUnpinnedColumnWidth
|
|
2556
|
+
}
|
|
2557
|
+
) : /* @__PURE__ */ jsx(GroupHeaderRow, { headerGroup, getActualColumnSize }) }, headerGroup.id);
|
|
2558
|
+
}) }) });
|
|
2559
|
+
};
|
|
2560
|
+
if (typeof VirtualTableHeader === "object" && VirtualTableHeader !== null) {
|
|
2561
|
+
VirtualTableHeader.displayName = "VirtualTableHeader";
|
|
2562
|
+
}
|
|
2563
|
+
var TableBodyRow = React3.memo(
|
|
2564
|
+
({
|
|
2565
|
+
row,
|
|
2566
|
+
virtualRow,
|
|
2567
|
+
rowVirtualizer,
|
|
2568
|
+
getFixedCellStyle,
|
|
2569
|
+
tableContainerRef: _tableContainerRef,
|
|
2570
|
+
columnVirtualizer,
|
|
2571
|
+
unpinnedColumns,
|
|
2572
|
+
scrollMargin: _scrollMargin = 0,
|
|
2573
|
+
totalUnpinnedWidth,
|
|
2574
|
+
totalTableWidth,
|
|
2575
|
+
getUnpinnedColumnWidth,
|
|
2576
|
+
headerVirtualItems,
|
|
2577
|
+
isLoading = false,
|
|
2578
|
+
bodyRowStyle
|
|
2579
|
+
}) => {
|
|
2580
|
+
var _a, _b;
|
|
2581
|
+
const { style: rowStyle, heightPx: rowHeightPx } = resolveBodyRowStyle(
|
|
2582
|
+
bodyRowStyle,
|
|
2583
|
+
virtualRow.index,
|
|
2584
|
+
row.original
|
|
2585
|
+
);
|
|
2586
|
+
const cells = row.getVisibleCells();
|
|
2587
|
+
const { leftPinnedCells, rightPinnedCells, unpinnedCells } = useMemo(() => {
|
|
2588
|
+
const left = cells.filter((cell) => cell.column.getIsPinned() === "left");
|
|
2589
|
+
const right = cells.filter((cell) => cell.column.getIsPinned() === "right");
|
|
2590
|
+
const unpinnedCellsMap = new Map(
|
|
2591
|
+
cells.filter((cell) => !cell.column.getIsPinned()).map((cell) => [cell.column.id, cell])
|
|
2592
|
+
);
|
|
2593
|
+
const unpinned = unpinnedColumns.map((header) => unpinnedCellsMap.get(header.column.id)).filter((cell) => cell !== void 0);
|
|
2594
|
+
return {
|
|
2595
|
+
leftPinnedCells: left,
|
|
2596
|
+
rightPinnedCells: right,
|
|
2597
|
+
unpinnedCells: unpinned
|
|
2598
|
+
};
|
|
2599
|
+
}, [cells, unpinnedColumns]);
|
|
2600
|
+
const hasPinned = useMemo(() => cells.some((cell) => cell.column.getIsPinned()), [cells]);
|
|
2601
|
+
const virtualItems = columnVirtualizer.getVirtualItems();
|
|
2602
|
+
const effectiveVirtualItems = headerVirtualItems && headerVirtualItems.length > 0 ? headerVirtualItems : virtualItems;
|
|
2603
|
+
return /* @__PURE__ */ jsxs(
|
|
2604
|
+
VirtualTableBodyRow,
|
|
2605
|
+
{
|
|
2606
|
+
"data-index": virtualRow.index,
|
|
2607
|
+
"data-has-pinned": hasPinned,
|
|
2608
|
+
ref: (node) => rowVirtualizer.measureElement(node),
|
|
2609
|
+
$tableWidthPx: totalTableWidth,
|
|
2610
|
+
$rowHeightPx: rowHeightPx,
|
|
2611
|
+
style: rowStyle,
|
|
2612
|
+
children: [
|
|
2613
|
+
leftPinnedCells.map((cell) => {
|
|
2614
|
+
var _a2, _b2, _c, _d, _e, _f;
|
|
2615
|
+
const isPinned = cell.column.getIsPinned();
|
|
2616
|
+
const isLastLeftPinned = isPinned === "left" && cell.column.getIsLastColumn("left");
|
|
2617
|
+
const leftPosition = cell.column.getStart("left");
|
|
2618
|
+
const size = cell.column.columnDef.size;
|
|
2619
|
+
const minSize = cell.column.columnDef.minSize;
|
|
2620
|
+
const cellWidth = typeof size === "number" && size > 0 ? size : typeof minSize === "number" && minSize > 0 ? minSize : 150;
|
|
2621
|
+
return /* @__PURE__ */ jsxs(
|
|
2622
|
+
VirtualTableBodyPinnedCell,
|
|
2623
|
+
{
|
|
2624
|
+
"data-last-left-pinned": isLastLeftPinned,
|
|
2625
|
+
"data-pinned": isPinned,
|
|
2626
|
+
"data-no-hover": getColumnActiveHoverDataAttribute(
|
|
2627
|
+
(_a2 = cell.column.columnDef.meta) == null ? void 0 : _a2.activeHover,
|
|
2628
|
+
cell.row.original
|
|
2629
|
+
),
|
|
2630
|
+
"data-has-custom-style": ((_d = (_c = (_b2 = cell.column.columnDef.meta) == null ? void 0 : _b2.cellProps) == null ? void 0 : _c.style) == null ? void 0 : _d.backgroundColor) ? "true" : void 0,
|
|
2631
|
+
style: __spreadProps(__spreadValues({}, ((_f = (_e = cell.column.columnDef.meta) == null ? void 0 : _e.cellProps) == null ? void 0 : _f.style) || {}), {
|
|
2632
|
+
width: `${cellWidth}px`,
|
|
2633
|
+
minWidth: `${cellWidth}px`,
|
|
2634
|
+
left: `${leftPosition}px`
|
|
2635
|
+
}),
|
|
2636
|
+
children: [
|
|
2637
|
+
isLoading ? /* @__PURE__ */ jsx(CellSkeleton2, {}) : flexRender(cell.column.columnDef.cell, cell.getContext()),
|
|
2638
|
+
isLastLeftPinned && /* @__PURE__ */ jsx(PinnedColumnEdgeShadow, {})
|
|
2639
|
+
]
|
|
2640
|
+
},
|
|
2641
|
+
cell.id
|
|
2642
|
+
);
|
|
2643
|
+
}),
|
|
2644
|
+
/* @__PURE__ */ jsx(VirtualTableBodyUnpinnedSlice, { $unpinnedWidthPx: totalUnpinnedWidth, children: /* @__PURE__ */ jsx(VirtualTableHorizontalVirtualTrack, { $translateX: (_b = (_a = effectiveVirtualItems[0]) == null ? void 0 : _a.start) != null ? _b : 0, $fillHeight: true, children: effectiveVirtualItems.map((virtualColumn) => {
|
|
2645
|
+
var _b2, _c, _d, _e;
|
|
2646
|
+
const header = unpinnedColumns[virtualColumn.index];
|
|
2647
|
+
if (!header)
|
|
2648
|
+
return null;
|
|
2649
|
+
const cell = unpinnedCells[virtualColumn.index];
|
|
2650
|
+
if (!cell)
|
|
2651
|
+
return null;
|
|
2652
|
+
const baseStyle = getFixedCellStyle(cell.column);
|
|
2653
|
+
const _a2 = baseStyle, restBaseStyle = __objRest(_a2, [
|
|
2654
|
+
"left",
|
|
2655
|
+
"right",
|
|
2656
|
+
"position",
|
|
2657
|
+
"width",
|
|
2658
|
+
"transform"
|
|
2659
|
+
]);
|
|
2660
|
+
const columnWidth = getUnpinnedColumnWidth(virtualColumn.index);
|
|
2661
|
+
return /* @__PURE__ */ jsx(
|
|
2662
|
+
VirtualTableBodyUnpinnedCell,
|
|
2663
|
+
{
|
|
2664
|
+
"data-no-hover": getColumnActiveHoverDataAttribute(
|
|
2665
|
+
(_b2 = cell.column.columnDef.meta) == null ? void 0 : _b2.activeHover,
|
|
2666
|
+
cell.row.original
|
|
2667
|
+
),
|
|
2668
|
+
"data-has-custom-style": ((_e = (_d = (_c = cell.column.columnDef.meta) == null ? void 0 : _c.cellProps) == null ? void 0 : _d.style) == null ? void 0 : _e.backgroundColor) ? "true" : void 0,
|
|
2669
|
+
style: __spreadProps(__spreadValues({}, restBaseStyle), {
|
|
2670
|
+
width: `${columnWidth}px`,
|
|
2671
|
+
minWidth: `${columnWidth}px`,
|
|
2672
|
+
maxWidth: `${columnWidth}px`
|
|
2673
|
+
}),
|
|
2674
|
+
children: isLoading ? /* @__PURE__ */ jsx(CellSkeleton2, {}) : flexRender(cell.column.columnDef.cell, cell.getContext())
|
|
2675
|
+
},
|
|
2676
|
+
cell.id
|
|
2677
|
+
);
|
|
2678
|
+
}) }) }),
|
|
2679
|
+
rightPinnedCells.map((cell) => {
|
|
2680
|
+
var _a2, _b2, _c, _d, _e, _f;
|
|
2681
|
+
const isPinned = cell.column.getIsPinned();
|
|
2682
|
+
const isFirstRightPinned = isPinned === "right" && cell.column.getIsFirstColumn("right");
|
|
2683
|
+
const rightPosition = cell.column.getAfter("right");
|
|
2684
|
+
const size = cell.column.columnDef.size;
|
|
2685
|
+
const minSize = cell.column.columnDef.minSize;
|
|
2686
|
+
const cellWidth = typeof size === "number" && size > 0 ? size : typeof minSize === "number" && minSize > 0 ? minSize : 150;
|
|
2687
|
+
return /* @__PURE__ */ jsx(
|
|
2688
|
+
VirtualTableBodyPinnedCell,
|
|
2689
|
+
{
|
|
2690
|
+
"data-first-right-pinned": isFirstRightPinned,
|
|
2691
|
+
"data-pinned": isPinned,
|
|
2692
|
+
"data-no-hover": getColumnActiveHoverDataAttribute(
|
|
2693
|
+
(_a2 = cell.column.columnDef.meta) == null ? void 0 : _a2.activeHover,
|
|
2694
|
+
cell.row.original
|
|
2695
|
+
),
|
|
2696
|
+
"data-has-custom-style": ((_d = (_c = (_b2 = cell.column.columnDef.meta) == null ? void 0 : _b2.cellProps) == null ? void 0 : _c.style) == null ? void 0 : _d.backgroundColor) ? "true" : void 0,
|
|
2697
|
+
style: __spreadProps(__spreadValues({}, ((_f = (_e = cell.column.columnDef.meta) == null ? void 0 : _e.cellProps) == null ? void 0 : _f.style) || {}), {
|
|
2698
|
+
width: `${cellWidth}px`,
|
|
2699
|
+
minWidth: `${cellWidth}px`,
|
|
2700
|
+
right: `${rightPosition}px`
|
|
2701
|
+
}),
|
|
2702
|
+
children: isLoading ? /* @__PURE__ */ jsx(CellSkeleton2, {}) : flexRender(cell.column.columnDef.cell, cell.getContext())
|
|
2703
|
+
},
|
|
2704
|
+
cell.id
|
|
2705
|
+
);
|
|
2706
|
+
})
|
|
2707
|
+
]
|
|
2708
|
+
}
|
|
2709
|
+
);
|
|
2710
|
+
},
|
|
2711
|
+
(prevProps, nextProps) => {
|
|
2712
|
+
var _a, _b;
|
|
2713
|
+
if (prevProps.row.id !== nextProps.row.id)
|
|
2714
|
+
return false;
|
|
2715
|
+
if (prevProps.virtualRow.start !== nextProps.virtualRow.start)
|
|
2716
|
+
return false;
|
|
2717
|
+
if (prevProps.virtualRow.index !== nextProps.virtualRow.index)
|
|
2718
|
+
return false;
|
|
2719
|
+
if (prevProps.isLoading !== nextProps.isLoading)
|
|
2720
|
+
return false;
|
|
2721
|
+
if (prevProps.isRowSelected !== nextProps.isRowSelected)
|
|
2722
|
+
return false;
|
|
2723
|
+
const prevHeaderItems = prevProps.headerVirtualItems;
|
|
2724
|
+
const nextHeaderItems = nextProps.headerVirtualItems;
|
|
2725
|
+
if ((prevHeaderItems == null ? void 0 : prevHeaderItems.length) !== (nextHeaderItems == null ? void 0 : nextHeaderItems.length))
|
|
2726
|
+
return false;
|
|
2727
|
+
if (prevHeaderItems && nextHeaderItems && ((_a = prevHeaderItems[0]) == null ? void 0 : _a.index) !== ((_b = nextHeaderItems[0]) == null ? void 0 : _b.index))
|
|
2728
|
+
return false;
|
|
2729
|
+
if (prevProps.totalUnpinnedWidth !== nextProps.totalUnpinnedWidth)
|
|
2730
|
+
return false;
|
|
2731
|
+
if (prevProps.totalTableWidth !== nextProps.totalTableWidth)
|
|
2732
|
+
return false;
|
|
2733
|
+
return true;
|
|
2734
|
+
}
|
|
2735
|
+
);
|
|
2736
|
+
if (typeof TableBodyRow === "object" && TableBodyRow !== null) {
|
|
2737
|
+
TableBodyRow.displayName = "TableBodyRow";
|
|
2738
|
+
}
|
|
2739
|
+
var VirtualTableBody = React3.memo(
|
|
2740
|
+
({
|
|
2741
|
+
table,
|
|
2742
|
+
tableContainerRef,
|
|
2743
|
+
getFixedCellStyle,
|
|
2744
|
+
headerRef,
|
|
2745
|
+
headerVirtualItems,
|
|
2746
|
+
bodyRef,
|
|
2747
|
+
scrollViewportRef,
|
|
2748
|
+
onBodyScroll,
|
|
2749
|
+
viewportWidth,
|
|
2750
|
+
bodyRowStyle
|
|
2751
|
+
}) => {
|
|
2752
|
+
var _a, _b;
|
|
2753
|
+
const { rows } = table.getRowModel();
|
|
2754
|
+
const { isLoading } = useTable();
|
|
2755
|
+
const currentHeaderGroups = table.getHeaderGroups();
|
|
2756
|
+
const leafHeaderGroup = currentHeaderGroups[currentHeaderGroups.length - 1];
|
|
2757
|
+
const allHeaders = useMemo(() => {
|
|
2758
|
+
const headers = (leafHeaderGroup == null ? void 0 : leafHeaderGroup.headers) || [];
|
|
2759
|
+
const filtered = headers.filter((h) => {
|
|
2760
|
+
const columns = h.column.columnDef.columns;
|
|
2761
|
+
return !columns || columns.length === 0;
|
|
2762
|
+
});
|
|
2763
|
+
return filtered;
|
|
2764
|
+
}, [leafHeaderGroup]);
|
|
2765
|
+
const unpinnedColumns = useMemo(() => allHeaders.filter((h) => !h.column.getIsPinned()), [allHeaders]);
|
|
2766
|
+
const leftPinnedColumns = useMemo(() => allHeaders.filter((h) => h.column.getIsPinned() === "left"), [allHeaders]);
|
|
2767
|
+
const rightPinnedColumns = useMemo(
|
|
2768
|
+
() => allHeaders.filter((h) => h.column.getIsPinned() === "right"),
|
|
2769
|
+
[allHeaders]
|
|
2770
|
+
);
|
|
2771
|
+
const { getUnpinnedColumnWidth, totalUnpinnedWidth, totalTableWidth } = useResponsiveColumnLayout({
|
|
2772
|
+
unpinnedColumns,
|
|
2773
|
+
leftPinnedColumns,
|
|
2774
|
+
rightPinnedColumns,
|
|
2775
|
+
viewportWidth
|
|
2776
|
+
});
|
|
2777
|
+
const [headerHeight, setHeaderHeight] = React3.useState(48);
|
|
2778
|
+
React3.useEffect(() => {
|
|
2779
|
+
if (headerRef.current) {
|
|
2780
|
+
const updateHeaderHeight = () => {
|
|
2781
|
+
if (headerRef.current) {
|
|
2782
|
+
const firstRow = headerRef.current.querySelector("div > div");
|
|
2783
|
+
if (firstRow) {
|
|
2784
|
+
const height = firstRow.getBoundingClientRect().height;
|
|
2785
|
+
if (height > 0) {
|
|
2786
|
+
setHeaderHeight(height);
|
|
2787
|
+
}
|
|
2788
|
+
} else {
|
|
2789
|
+
const height = headerRef.current.getBoundingClientRect().height;
|
|
2790
|
+
if (height > 0) {
|
|
2791
|
+
setHeaderHeight(height);
|
|
2792
|
+
}
|
|
2793
|
+
}
|
|
2794
|
+
}
|
|
2795
|
+
};
|
|
2796
|
+
const timeoutId = setTimeout(updateHeaderHeight, 0);
|
|
2797
|
+
const resizeObserver = new ResizeObserver(() => {
|
|
2798
|
+
updateHeaderHeight();
|
|
2799
|
+
});
|
|
2800
|
+
resizeObserver.observe(headerRef.current);
|
|
2801
|
+
return () => {
|
|
2802
|
+
clearTimeout(timeoutId);
|
|
2803
|
+
resizeObserver.disconnect();
|
|
2804
|
+
};
|
|
2805
|
+
}
|
|
2806
|
+
}, [headerRef]);
|
|
2807
|
+
const estimateSize = useCallback((index) => getUnpinnedColumnWidth(index), [getUnpinnedColumnWidth]);
|
|
2808
|
+
const columnVirtualizer = useVirtualizer({
|
|
2809
|
+
// 헤더와 동일: flushSync 경고 방지
|
|
2810
|
+
// useFlushSync: false,
|
|
2811
|
+
count: unpinnedColumns.length,
|
|
2812
|
+
getScrollElement: () => headerRef.current || bodyRef.current,
|
|
2813
|
+
estimateSize,
|
|
2814
|
+
horizontal: true,
|
|
2815
|
+
overscan: 5
|
|
2816
|
+
});
|
|
2817
|
+
const getItemKey = useCallback(
|
|
2818
|
+
(index) => {
|
|
2819
|
+
const row = rows[index];
|
|
2820
|
+
return (row == null ? void 0 : row.id) || `row-${index}`;
|
|
2821
|
+
},
|
|
2822
|
+
[rows]
|
|
2823
|
+
);
|
|
2824
|
+
const rowVirtualizer = useVirtualizer({
|
|
2825
|
+
// useFlushSync: false,
|
|
2826
|
+
count: rows.length,
|
|
2827
|
+
getScrollElement: () => (scrollViewportRef == null ? void 0 : scrollViewportRef.current) || tableContainerRef.current,
|
|
2828
|
+
estimateSize: (index) => {
|
|
2829
|
+
var _a2;
|
|
2830
|
+
return resolveBodyRowStyle(bodyRowStyle, index, (_a2 = rows[index]) == null ? void 0 : _a2.original).heightPx;
|
|
2831
|
+
},
|
|
2832
|
+
overscan: 10,
|
|
2833
|
+
// row의 안정적인 key를 제공하여 sync 상태 변경 시에도 row 추적 안정화
|
|
2834
|
+
getItemKey
|
|
2835
|
+
// 실제 row 높이를 측정하여 깜빡임 방지 (DOM layout 측정 비활성화)
|
|
2836
|
+
// measureElement,
|
|
2837
|
+
});
|
|
2838
|
+
const virtualRows = rowVirtualizer.getVirtualItems();
|
|
2839
|
+
React3.useEffect(() => {
|
|
2840
|
+
const scrollElement = (scrollViewportRef == null ? void 0 : scrollViewportRef.current) || tableContainerRef.current;
|
|
2841
|
+
if (scrollElement) {
|
|
2842
|
+
const timeoutId = setTimeout(() => {
|
|
2843
|
+
rowVirtualizer.measure();
|
|
2844
|
+
columnVirtualizer.measure();
|
|
2845
|
+
}, 0);
|
|
2846
|
+
return () => clearTimeout(timeoutId);
|
|
2847
|
+
}
|
|
2848
|
+
}, [rowVirtualizer, columnVirtualizer, scrollViewportRef, tableContainerRef]);
|
|
2849
|
+
const handleBodyScroll = useCallback(() => {
|
|
2850
|
+
if (!onBodyScroll)
|
|
2851
|
+
return;
|
|
2852
|
+
onBodyScroll();
|
|
2853
|
+
}, [onBodyScroll]);
|
|
2854
|
+
const bodyGridHeightPx = rowVirtualizer.getTotalSize();
|
|
2855
|
+
return /* @__PURE__ */ jsx(VirtualTableBodyGrid, { ref: bodyRef, $totalHeightPx: bodyGridHeightPx, onScroll: handleBodyScroll, children: /* @__PURE__ */ jsx(VirtualTableVerticalVirtualTrack, { $translateY: (_b = (_a = virtualRows[0]) == null ? void 0 : _a.start) != null ? _b : 0, children: virtualRows.map((virtualRow) => {
|
|
2856
|
+
const row = rows[virtualRow.index];
|
|
2857
|
+
const rowKey = row.id || `row-${virtualRow.index}`;
|
|
2858
|
+
return /* @__PURE__ */ jsx(
|
|
2859
|
+
TableBodyRow,
|
|
2860
|
+
{
|
|
2861
|
+
row,
|
|
2862
|
+
isRowSelected: row.getIsSelected(),
|
|
2863
|
+
virtualRow,
|
|
2864
|
+
rowVirtualizer,
|
|
2865
|
+
getFixedCellStyle,
|
|
2866
|
+
tableContainerRef,
|
|
2867
|
+
columnVirtualizer,
|
|
2868
|
+
bodyRowStyle,
|
|
2869
|
+
unpinnedColumns,
|
|
2870
|
+
scrollMargin: headerHeight,
|
|
2871
|
+
totalUnpinnedWidth,
|
|
2872
|
+
totalTableWidth,
|
|
2873
|
+
getUnpinnedColumnWidth,
|
|
2874
|
+
headerVirtualItems,
|
|
2875
|
+
isLoading
|
|
2876
|
+
},
|
|
2877
|
+
rowKey
|
|
2878
|
+
);
|
|
2879
|
+
}) }) });
|
|
2880
|
+
}
|
|
2881
|
+
);
|
|
2882
|
+
if (typeof VirtualTableBody === "object" && VirtualTableBody !== null) {
|
|
2883
|
+
VirtualTableBody.displayName = "VirtualTableBody";
|
|
2884
|
+
}
|
|
2885
|
+
function VirtualTable({
|
|
2886
|
+
maxHeight = "800px",
|
|
2887
|
+
bodyRowStyle
|
|
2888
|
+
}) {
|
|
2889
|
+
const tableContainerRef = useRef(null);
|
|
2890
|
+
const scrollAreaRef = useRef(null);
|
|
2891
|
+
const scrollViewportRef = useRef(null);
|
|
2892
|
+
const { table, tableScrollRef, bodyRef, headerRef } = useTable();
|
|
2893
|
+
const [headerVirtualItems, setHeaderVirtualItems] = React3.useState([]);
|
|
2894
|
+
const viewportWidth = useResponsiveViewportWidth(tableContainerRef, headerRef);
|
|
2895
|
+
React3.useEffect(() => {
|
|
2896
|
+
var _a;
|
|
2897
|
+
if ((_a = scrollAreaRef.current) == null ? void 0 : _a.view) {
|
|
2898
|
+
scrollViewportRef.current = scrollAreaRef.current.view;
|
|
2899
|
+
scrollViewportRef.current.dispatchEvent(new Event("scroll", { bubbles: true }));
|
|
2900
|
+
}
|
|
2901
|
+
}, []);
|
|
2902
|
+
const handleBodyScroll = useCallback(() => {
|
|
2903
|
+
if (!bodyRef.current)
|
|
2904
|
+
return;
|
|
2905
|
+
const bodyScrollLeft = bodyRef.current.scrollLeft;
|
|
2906
|
+
if (headerRef.current) {
|
|
2907
|
+
headerRef.current.scrollLeft = bodyScrollLeft;
|
|
2908
|
+
}
|
|
2909
|
+
if (tableScrollRef == null ? void 0 : tableScrollRef.current) {
|
|
2910
|
+
tableScrollRef.current.scrollLeft = bodyScrollLeft;
|
|
2911
|
+
}
|
|
2912
|
+
}, [tableScrollRef]);
|
|
2913
|
+
const handleHeaderScroll = useCallback(() => {
|
|
2914
|
+
if (!headerRef.current)
|
|
2915
|
+
return;
|
|
2916
|
+
const headerScrollLeft = headerRef.current.scrollLeft;
|
|
2917
|
+
if (bodyRef.current) {
|
|
2918
|
+
bodyRef.current.scrollLeft = headerScrollLeft;
|
|
2919
|
+
}
|
|
2920
|
+
if (tableScrollRef == null ? void 0 : tableScrollRef.current) {
|
|
2921
|
+
tableScrollRef.current.scrollLeft = headerScrollLeft;
|
|
2922
|
+
}
|
|
2923
|
+
}, [tableScrollRef]);
|
|
2924
|
+
const columnStyleCacheRef = useRef(/* @__PURE__ */ new WeakMap());
|
|
2925
|
+
const getColumnStyle = useCallback(
|
|
2926
|
+
(column, isHeader) => {
|
|
2927
|
+
var _a, _b, _c, _d;
|
|
2928
|
+
const cached = columnStyleCacheRef.current.get(column);
|
|
2929
|
+
if (cached) {
|
|
2930
|
+
return isHeader ? cached.header : cached.cell;
|
|
2931
|
+
}
|
|
2932
|
+
const pinningStyles = getCommonPinningStyles(column);
|
|
2933
|
+
const size = column.columnDef.size;
|
|
2934
|
+
const minSize = column.columnDef.minSize;
|
|
2935
|
+
const maxSize = column.columnDef.maxSize;
|
|
2936
|
+
const widthStyle = size === 0 ? { width: "100%" } : {
|
|
2937
|
+
width: pinningStyles.width || `${size}px`,
|
|
2938
|
+
minWidth: `${minSize}px`,
|
|
2939
|
+
maxWidth: `${maxSize}px`
|
|
2940
|
+
};
|
|
2941
|
+
const headerStyle = __spreadValues(__spreadValues(__spreadValues({}, pinningStyles), ((_b = (_a = column.columnDef.meta) == null ? void 0 : _a.headerProps) == null ? void 0 : _b.style) || {}), widthStyle);
|
|
2942
|
+
const cellStyle = __spreadValues(__spreadValues(__spreadValues({}, pinningStyles), ((_d = (_c = column.columnDef.meta) == null ? void 0 : _c.cellProps) == null ? void 0 : _d.style) || {}), widthStyle);
|
|
2943
|
+
columnStyleCacheRef.current.set(column, {
|
|
2944
|
+
header: headerStyle,
|
|
2945
|
+
cell: cellStyle
|
|
2946
|
+
});
|
|
2947
|
+
return isHeader ? headerStyle : cellStyle;
|
|
2948
|
+
},
|
|
2949
|
+
[]
|
|
2950
|
+
// 의존성 없음 - 컬럼 객체 자체가 변경되면 WeakMap에서 자동으로 가비지 컬렉션됨
|
|
2951
|
+
);
|
|
2952
|
+
const getFixedCellStyle = useCallback(
|
|
2953
|
+
(column, isHeader = false) => {
|
|
2954
|
+
return getColumnStyle(column, isHeader);
|
|
2955
|
+
},
|
|
2956
|
+
[getColumnStyle]
|
|
2957
|
+
);
|
|
2958
|
+
return /* @__PURE__ */ jsxs(VirtualTableRoot, { children: [
|
|
2959
|
+
/* @__PURE__ */ jsx(
|
|
2960
|
+
VirtualTableHeader,
|
|
2961
|
+
{
|
|
2962
|
+
table,
|
|
2963
|
+
headerRef,
|
|
2964
|
+
getFixedCellStyle,
|
|
2965
|
+
tableContainerRef,
|
|
2966
|
+
scrollViewportRef,
|
|
2967
|
+
onVirtualItemsChange: setHeaderVirtualItems,
|
|
2968
|
+
onHeaderScroll: handleHeaderScroll,
|
|
2969
|
+
viewportWidth
|
|
2970
|
+
}
|
|
2971
|
+
),
|
|
2972
|
+
/* @__PURE__ */ jsx("div", { ref: scrollViewportRef, style: { maxHeight, overflowY: "auto", overflowX: "hidden" }, children: /* @__PURE__ */ jsx(VirtualTableScrollAreaInner, { ref: tableContainerRef, children: /* @__PURE__ */ jsx(
|
|
2973
|
+
VirtualTableBody,
|
|
2974
|
+
{
|
|
2975
|
+
table,
|
|
2976
|
+
tableContainerRef,
|
|
2977
|
+
getFixedCellStyle,
|
|
2978
|
+
headerRef,
|
|
2979
|
+
headerVirtualItems,
|
|
2980
|
+
bodyRef,
|
|
2981
|
+
scrollViewportRef,
|
|
2982
|
+
onBodyScroll: handleBodyScroll,
|
|
2983
|
+
viewportWidth,
|
|
2984
|
+
bodyRowStyle
|
|
2985
|
+
}
|
|
2986
|
+
) }) })
|
|
2987
|
+
] });
|
|
2988
|
+
}
|
|
2989
|
+
var TableMain = (props) => {
|
|
2990
|
+
const {
|
|
2991
|
+
fixedColumns = [],
|
|
2992
|
+
useVirtualization = false,
|
|
2993
|
+
isSticky = true,
|
|
2994
|
+
stickyHeaderTopPosition = 120,
|
|
2995
|
+
children,
|
|
2996
|
+
maxHeight,
|
|
2997
|
+
emptyRowCount = 8,
|
|
2998
|
+
enableDragDrop = false,
|
|
2999
|
+
dragColWidth = 40,
|
|
3000
|
+
onRowReorder,
|
|
3001
|
+
footerRowProps,
|
|
3002
|
+
headerRowStyle,
|
|
3003
|
+
bodyRowStyle,
|
|
3004
|
+
containerStyle
|
|
3005
|
+
} = props;
|
|
3006
|
+
const { table, hasToolbar, hasFilterBar, columnResizing } = useTable();
|
|
3007
|
+
const { rows } = table.getRowModel();
|
|
3008
|
+
const shouldFixDragHandle = enableDragDrop && fixedColumns.some((fc) => fc.index === 0 && fc.position === "left");
|
|
3009
|
+
useEffect(() => {
|
|
3010
|
+
const pinningState = {
|
|
3011
|
+
left: [],
|
|
3012
|
+
right: []
|
|
3013
|
+
};
|
|
3014
|
+
fixedColumns.forEach(({ index, position }) => {
|
|
3015
|
+
if (enableDragDrop && index === 0) {
|
|
3016
|
+
return;
|
|
3017
|
+
}
|
|
3018
|
+
const actualIndex = enableDragDrop ? index - 1 : index;
|
|
3019
|
+
const column = table.getAllLeafColumns()[actualIndex];
|
|
3020
|
+
if (column == null ? void 0 : column.id) {
|
|
3021
|
+
pinningState[position].push(column.id);
|
|
3022
|
+
}
|
|
3023
|
+
});
|
|
3024
|
+
table.setColumnPinning(pinningState);
|
|
3025
|
+
}, []);
|
|
3026
|
+
const isEmpty = rows.length === 0;
|
|
3027
|
+
let emptyElement;
|
|
3028
|
+
React3.Children.forEach(children, (child) => {
|
|
3029
|
+
if (React3.isValidElement(child) && child.type === TableEmpty) {
|
|
3030
|
+
emptyElement = child;
|
|
3031
|
+
}
|
|
3032
|
+
});
|
|
3033
|
+
const nonVirtualizedRows = rows.map((row) => __spreadValues({ row }, row));
|
|
3034
|
+
const tableState = {
|
|
3035
|
+
displayedRows: nonVirtualizedRows,
|
|
3036
|
+
paddingTop: 0,
|
|
3037
|
+
paddingBottom: 0,
|
|
3038
|
+
isEmpty,
|
|
3039
|
+
emptyElement,
|
|
3040
|
+
children,
|
|
3041
|
+
maxHeight,
|
|
3042
|
+
hasToolbar,
|
|
3043
|
+
isSticky,
|
|
3044
|
+
stickyHeaderTopPosition,
|
|
3045
|
+
emptyRowCount,
|
|
3046
|
+
enableDragDrop,
|
|
3047
|
+
dragColWidth,
|
|
3048
|
+
shouldFixDragHandle,
|
|
3049
|
+
onRowReorder,
|
|
3050
|
+
footerRowProps,
|
|
3051
|
+
headerRowStyle,
|
|
3052
|
+
bodyRowStyle
|
|
3053
|
+
};
|
|
3054
|
+
return /* @__PURE__ */ jsx(TableRootContainer, { hasFilterBar, hasToolbar, style: containerStyle, children: useVirtualization ? /* @__PURE__ */ jsx(VirtualTable, { maxHeight, bodyRowStyle }) : (
|
|
3055
|
+
// <VirtualizedContent
|
|
3056
|
+
// {...props}
|
|
3057
|
+
// rows={rows}
|
|
3058
|
+
// emptyElement={emptyElement}
|
|
3059
|
+
// isEmpty={isEmpty}
|
|
3060
|
+
// enableDragDrop={enableDragDrop}
|
|
3061
|
+
// />
|
|
3062
|
+
columnResizing ? /* @__PURE__ */ jsx(ResizableTable, { tableState }) : /* @__PURE__ */ jsx(FixedTable, { tableState })
|
|
3063
|
+
) });
|
|
3064
|
+
};
|
|
3065
|
+
var useIntersectionObserver = (target, callback, options) => {
|
|
3066
|
+
useEffect(() => {
|
|
3067
|
+
if (!target.current) {
|
|
3068
|
+
return;
|
|
3069
|
+
}
|
|
3070
|
+
const observer = new IntersectionObserver(callback, options);
|
|
3071
|
+
observer.observe(target.current);
|
|
3072
|
+
return () => observer.disconnect();
|
|
3073
|
+
}, [callback]);
|
|
3074
|
+
};
|
|
3075
|
+
var TablePagination = ({
|
|
3076
|
+
total,
|
|
3077
|
+
defaultPageSize,
|
|
3078
|
+
leftSource,
|
|
3079
|
+
children,
|
|
3080
|
+
pageSizeList = PAGE_SIZE,
|
|
3081
|
+
setCurrentPage,
|
|
3082
|
+
notSizeOption = false,
|
|
3083
|
+
currentPage,
|
|
3084
|
+
showPagination = true,
|
|
3085
|
+
sizeVar = "S",
|
|
3086
|
+
hasPaddingInline = true
|
|
3087
|
+
}) => {
|
|
3088
|
+
const { table, headerRef, bodyRef, tableScrollRef, footerRef, hasFilterBar, hasToolbar, isVirtualTableLayout } = useTable();
|
|
3089
|
+
const { pageSize, pageIndex } = table.getState().pagination;
|
|
3090
|
+
const [isEndOfPage, setIsEndOfPage] = useState(false);
|
|
3091
|
+
const handleScroll = useCallback(() => {
|
|
3092
|
+
if (!headerRef.current || !bodyRef.current || !tableScrollRef.current) {
|
|
3093
|
+
return;
|
|
3094
|
+
}
|
|
3095
|
+
const scrollLeft = tableScrollRef.current.scrollLeft;
|
|
3096
|
+
headerRef.current.scrollLeft = scrollLeft;
|
|
3097
|
+
bodyRef.current.scrollLeft = scrollLeft;
|
|
3098
|
+
}, []);
|
|
3099
|
+
const onIntersect = useCallback(
|
|
3100
|
+
(entries) => __async(void 0, null, function* () {
|
|
3101
|
+
const entry = entries[0];
|
|
3102
|
+
entry.isIntersecting ? setIsEndOfPage(true) : setIsEndOfPage(false);
|
|
3103
|
+
}),
|
|
3104
|
+
[isEndOfPage]
|
|
3105
|
+
);
|
|
3106
|
+
useIntersectionObserver(footerRef, onIntersect, {
|
|
3107
|
+
threshold: 1,
|
|
3108
|
+
rootMargin: "0px 0px -1px"
|
|
3109
|
+
});
|
|
3110
|
+
const handlePageChange = useCallback(
|
|
3111
|
+
(updater) => {
|
|
3112
|
+
const newPage = typeof updater === "function" ? updater(pageIndex) : updater;
|
|
3113
|
+
table.setPageIndex(newPage);
|
|
3114
|
+
setCurrentPage == null ? void 0 : setCurrentPage({ pageIndex: newPage, pageSize });
|
|
3115
|
+
},
|
|
3116
|
+
[pageIndex, pageSize, table, setCurrentPage]
|
|
3117
|
+
);
|
|
3118
|
+
const handlePageSizeChange = useCallback(
|
|
3119
|
+
(value) => {
|
|
3120
|
+
const newSize = Number(value);
|
|
3121
|
+
table.setPageSize(newSize);
|
|
3122
|
+
table.setPageIndex(0);
|
|
3123
|
+
setCurrentPage == null ? void 0 : setCurrentPage({ pageIndex: 0, pageSize: newSize });
|
|
3124
|
+
},
|
|
3125
|
+
[table, setCurrentPage]
|
|
3126
|
+
);
|
|
3127
|
+
const TableColumns = () => {
|
|
3128
|
+
const leafColumns = table.getVisibleLeafColumns();
|
|
3129
|
+
return /* @__PURE__ */ jsx("colgroup", { children: leafColumns.map((column) => {
|
|
3130
|
+
const size = column.columnDef.size;
|
|
3131
|
+
const minSize = column.columnDef.minSize;
|
|
3132
|
+
const maxSize = column.columnDef.maxSize;
|
|
3133
|
+
const style = size === 0 ? { width: "100%" } : {
|
|
3134
|
+
width: `${size}px`,
|
|
3135
|
+
minWidth: `${minSize}px`,
|
|
3136
|
+
maxWidth: `${maxSize}px`
|
|
3137
|
+
};
|
|
3138
|
+
return /* @__PURE__ */ jsx("col", { style }, column.id);
|
|
3139
|
+
}) });
|
|
3140
|
+
};
|
|
3141
|
+
const renderRightSource = () => {
|
|
3142
|
+
if (sizeVar === "XS") {
|
|
3143
|
+
return null;
|
|
3144
|
+
}
|
|
3145
|
+
if (notSizeOption) {
|
|
3146
|
+
return;
|
|
3147
|
+
}
|
|
3148
|
+
return /* @__PURE__ */ jsx(PaginationSizeSelectorSlot, { children: /* @__PURE__ */ jsx(
|
|
3149
|
+
Pagination.SizeSelector,
|
|
3150
|
+
{
|
|
3151
|
+
data: pageSizeList.map((item) => ({ label: item.label, value: item.key })),
|
|
3152
|
+
pageSize: `${pageSize}`,
|
|
3153
|
+
setPageSize: handlePageSizeChange,
|
|
3154
|
+
middlewares: [
|
|
3155
|
+
flip({ padding: 8, rootBoundary: "viewport" }),
|
|
3156
|
+
shift({ padding: 8, rootBoundary: "viewport" })
|
|
3157
|
+
]
|
|
3158
|
+
}
|
|
3159
|
+
) });
|
|
3160
|
+
};
|
|
3161
|
+
useEffect(() => {
|
|
3162
|
+
table.setPageSize(defaultPageSize);
|
|
3163
|
+
}, [defaultPageSize, table]);
|
|
3164
|
+
useEffect(() => {
|
|
3165
|
+
table.setPageIndex(currentPage != null ? currentPage : 0);
|
|
3166
|
+
}, [table, currentPage]);
|
|
3167
|
+
useEffect(() => {
|
|
3168
|
+
if (table.options.manualPagination) {
|
|
3169
|
+
return;
|
|
3170
|
+
}
|
|
3171
|
+
const pageCount = Math.max(1, Math.ceil(total / Number(pageSize)));
|
|
3172
|
+
if (pageIndex > pageCount - 1) {
|
|
3173
|
+
table.setPageIndex(pageCount - 1);
|
|
3174
|
+
}
|
|
3175
|
+
}, [total, pageSize, pageIndex, table]);
|
|
3176
|
+
const scrollbarTableWidth = table.getTotalSize() || "100%";
|
|
3177
|
+
const leftSlotContent = leftSource != null ? leftSource : children;
|
|
3178
|
+
return /* @__PURE__ */ jsxs(
|
|
3179
|
+
BottomContainer,
|
|
3180
|
+
{
|
|
3181
|
+
ref: footerRef,
|
|
3182
|
+
isEndOfPage,
|
|
3183
|
+
hasFilterBar,
|
|
3184
|
+
hasToolbar,
|
|
3185
|
+
disableStickyFooter: Boolean(isVirtualTableLayout),
|
|
3186
|
+
children: [
|
|
3187
|
+
/* @__PURE__ */ jsx(ScrollContainer, { ref: tableScrollRef, onScroll: handleScroll, isPagination: showPagination, children: /* @__PURE__ */ jsx(
|
|
3188
|
+
"table",
|
|
3189
|
+
{
|
|
3190
|
+
style: {
|
|
3191
|
+
width: scrollbarTableWidth,
|
|
3192
|
+
height: "6px",
|
|
3193
|
+
tableLayout: "fixed"
|
|
3194
|
+
},
|
|
3195
|
+
children: /* @__PURE__ */ jsx(TableColumns, {})
|
|
3196
|
+
}
|
|
3197
|
+
) }),
|
|
3198
|
+
/* @__PURE__ */ jsxs(PaginationWrapper, { sizeVar, isEndOfPage, children: [
|
|
3199
|
+
!showPagination && /* @__PURE__ */ jsx(PaginationLeftSlot, { children: leftSlotContent }),
|
|
3200
|
+
showPagination && /* @__PURE__ */ jsx(
|
|
3201
|
+
Pagination,
|
|
3202
|
+
{
|
|
3203
|
+
sizeVar,
|
|
3204
|
+
pageSize: `${pageSize}`,
|
|
3205
|
+
currentPage: pageIndex,
|
|
3206
|
+
itemsTotalCount: total,
|
|
3207
|
+
totalCount: Math.ceil(total / Number(pageSize)),
|
|
3208
|
+
previousPage: () => handlePageChange(pageIndex - 1),
|
|
3209
|
+
nextPage: () => handlePageChange(pageIndex + 1),
|
|
3210
|
+
style: { paddingInline: hasPaddingInline ? "16px" : "0px" },
|
|
3211
|
+
gotoPage: handlePageChange,
|
|
3212
|
+
rightSource: renderRightSource(),
|
|
3213
|
+
leftSource: leftSlotContent
|
|
3214
|
+
},
|
|
3215
|
+
Math.ceil(total / Number(pageSize))
|
|
3216
|
+
)
|
|
3217
|
+
] })
|
|
3218
|
+
]
|
|
3219
|
+
}
|
|
3220
|
+
);
|
|
1467
3221
|
};
|
|
1468
|
-
var
|
|
1469
|
-
fixedColumns = [],
|
|
1470
|
-
useVirtualization = false,
|
|
1471
|
-
isSticky = true,
|
|
1472
|
-
stickyHeaderTopPosition = 120,
|
|
3222
|
+
var TableToolbar = ({
|
|
1473
3223
|
children,
|
|
1474
|
-
|
|
1475
|
-
|
|
3224
|
+
filterAccessor,
|
|
3225
|
+
height = "56px",
|
|
3226
|
+
padding = "12px 20px",
|
|
3227
|
+
totalCount
|
|
1476
3228
|
}) => {
|
|
1477
|
-
const { table,
|
|
1478
|
-
const
|
|
1479
|
-
const
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
const rowVirtualizer = useWindowVirtualizer({
|
|
1486
|
-
estimateSize: () => 60,
|
|
1487
|
-
// 각 행의 높이를 60px로 예측
|
|
1488
|
-
count: rows.length,
|
|
1489
|
-
overscan: 10,
|
|
1490
|
-
// 실제 보이는 영역 외에 추가로 렌더링할 아이템 수
|
|
1491
|
-
isScrollingResetDelay: 100,
|
|
1492
|
-
// 스크롤이 멈추고 100ms 후에 스크롤 상태 초기화
|
|
1493
|
-
observeElementOffset: (instance, cb) => observeWindowOffset(instance, (offset, isScrolling) => cb(offset - 120, isScrolling)),
|
|
1494
|
-
scrollToFn
|
|
1495
|
-
});
|
|
1496
|
-
const { getVirtualItems: virtualRows } = rowVirtualizer;
|
|
1497
|
-
const displayedRows = useVirtualization ? virtualRows().map((virtualRow) => ({ row: rows[virtualRow.index], virtualRow })) : rows.map((row) => ({ row }));
|
|
1498
|
-
const hasVirtualRow = (item) => {
|
|
1499
|
-
return "virtualRow" in item;
|
|
3229
|
+
const { table, filterValue, setFilterValue } = useTable();
|
|
3230
|
+
const _totalCount = totalCount || table.getPrePaginationRowModel().rows.length;
|
|
3231
|
+
const onSearch = (value) => {
|
|
3232
|
+
var _a;
|
|
3233
|
+
if (!filterAccessor)
|
|
3234
|
+
return null;
|
|
3235
|
+
setFilterValue(value);
|
|
3236
|
+
(_a = table.getColumn(filterAccessor)) == null ? void 0 : _a.setFilterValue(value);
|
|
1500
3237
|
};
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
3238
|
+
return /* @__PURE__ */ jsx(StackContainer.Horizontal, { width: "100%", height, align: "center", padding, justify: "space-between", children: children({
|
|
3239
|
+
totalCount: _totalCount,
|
|
3240
|
+
filterAccessor: filterAccessor != null ? filterAccessor : "",
|
|
3241
|
+
onSearch,
|
|
3242
|
+
filterValue
|
|
3243
|
+
}) });
|
|
3244
|
+
};
|
|
3245
|
+
var Table = ({
|
|
3246
|
+
data,
|
|
3247
|
+
columns,
|
|
3248
|
+
columnResizing = false,
|
|
3249
|
+
children,
|
|
3250
|
+
manualPagination = false,
|
|
3251
|
+
manualFiltering = false,
|
|
3252
|
+
manualSorting = true,
|
|
3253
|
+
selectedRows = [],
|
|
3254
|
+
onSelectedRowsChange,
|
|
3255
|
+
onClickRow,
|
|
3256
|
+
initPageSize = 100,
|
|
3257
|
+
noBorder = false,
|
|
3258
|
+
isLoading = false,
|
|
3259
|
+
getRowId,
|
|
3260
|
+
globalSorting,
|
|
3261
|
+
outsideFilters,
|
|
3262
|
+
autoResetPageIndex = false
|
|
3263
|
+
}) => {
|
|
3264
|
+
const [sorting, setSorting] = useState([]);
|
|
3265
|
+
const [columnFilters, setColumnFilters] = useState([]);
|
|
3266
|
+
const [globalFilter, setGlobalFilter] = useState([]);
|
|
3267
|
+
const [columnVisibility, setColumnVisibility] = useState({});
|
|
3268
|
+
const [columnPinning, setColumnPinning] = useState({});
|
|
3269
|
+
const [rowSelection, setRowSelection] = useState({});
|
|
3270
|
+
const [filterValue, setFilterValue] = useState("");
|
|
3271
|
+
const currentSorting = globalSorting != null ? globalSorting : sorting;
|
|
3272
|
+
const rowIdMapRef = useRef(/* @__PURE__ */ new WeakMap());
|
|
3273
|
+
const rowIdCounterRef = useRef(0);
|
|
3274
|
+
const filterHiddenColumns = (cols) => {
|
|
3275
|
+
return cols.filter((column) => {
|
|
3276
|
+
var _a;
|
|
3277
|
+
return column && !((_a = column.meta) == null ? void 0 : _a.hiddenColumn);
|
|
3278
|
+
}).map((column) => {
|
|
3279
|
+
if ("columns" in column && Array.isArray(column.columns)) {
|
|
3280
|
+
return __spreadProps(__spreadValues({}, column), {
|
|
3281
|
+
columns: filterHiddenColumns(column.columns)
|
|
3282
|
+
});
|
|
1513
3283
|
}
|
|
3284
|
+
return column;
|
|
3285
|
+
}).filter((column) => {
|
|
3286
|
+
if ("columns" in column && Array.isArray(column.columns)) {
|
|
3287
|
+
return column.columns.length > 0;
|
|
3288
|
+
}
|
|
3289
|
+
return true;
|
|
1514
3290
|
});
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
const
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
3291
|
+
};
|
|
3292
|
+
const visibleColumns = useMemo(() => filterHiddenColumns(columns), [columns]);
|
|
3293
|
+
const safeGetRowId = useMemo(() => {
|
|
3294
|
+
if (getRowId) {
|
|
3295
|
+
return (row) => {
|
|
3296
|
+
const id = getRowId(row);
|
|
3297
|
+
if (id === void 0 || id === null || id === "") {
|
|
3298
|
+
if (rowIdMapRef.current.has(row)) {
|
|
3299
|
+
return rowIdMapRef.current.get(row);
|
|
3300
|
+
}
|
|
3301
|
+
const newId = `row-${rowIdCounterRef.current++}`;
|
|
3302
|
+
rowIdMapRef.current.set(row, newId);
|
|
3303
|
+
return newId;
|
|
3304
|
+
}
|
|
3305
|
+
return String(id);
|
|
3306
|
+
};
|
|
1522
3307
|
}
|
|
3308
|
+
return (row) => {
|
|
3309
|
+
if (typeof row === "object" && row !== null && "id" in row) {
|
|
3310
|
+
const id = row.id;
|
|
3311
|
+
if (id !== void 0 && id !== null && id !== "") {
|
|
3312
|
+
return String(id);
|
|
3313
|
+
}
|
|
3314
|
+
}
|
|
3315
|
+
if (rowIdMapRef.current.has(row)) {
|
|
3316
|
+
return rowIdMapRef.current.get(row);
|
|
3317
|
+
}
|
|
3318
|
+
const newId = `row-${rowIdCounterRef.current++}`;
|
|
3319
|
+
rowIdMapRef.current.set(row, newId);
|
|
3320
|
+
return newId;
|
|
3321
|
+
};
|
|
3322
|
+
}, [getRowId]);
|
|
3323
|
+
const table = useReactTable({
|
|
3324
|
+
data,
|
|
3325
|
+
columns: visibleColumns,
|
|
3326
|
+
columnResizeMode: "onChange",
|
|
3327
|
+
getRowId: safeGetRowId,
|
|
3328
|
+
initialState: {
|
|
3329
|
+
pagination: {
|
|
3330
|
+
pageSize: initPageSize
|
|
3331
|
+
}
|
|
3332
|
+
},
|
|
3333
|
+
state: {
|
|
3334
|
+
sorting: currentSorting,
|
|
3335
|
+
columnFilters,
|
|
3336
|
+
globalFilter,
|
|
3337
|
+
columnVisibility,
|
|
3338
|
+
columnPinning,
|
|
3339
|
+
rowSelection
|
|
3340
|
+
},
|
|
3341
|
+
defaultColumn: {
|
|
3342
|
+
size: 0,
|
|
3343
|
+
// TODO: 필터링 기능 추가 시 props로 옵션 처리
|
|
3344
|
+
enableColumnFilter: false,
|
|
3345
|
+
enableSorting: false,
|
|
3346
|
+
enableResizing: true
|
|
3347
|
+
},
|
|
3348
|
+
onSortingChange: (updater) => {
|
|
3349
|
+
var _a, _b;
|
|
3350
|
+
const newSorting = typeof updater === "function" ? updater(table.getState().sorting) : updater;
|
|
3351
|
+
if (!globalSorting) {
|
|
3352
|
+
setSorting(newSorting);
|
|
3353
|
+
}
|
|
3354
|
+
if (newSorting.length > 0) {
|
|
3355
|
+
const { id, desc } = newSorting[0];
|
|
3356
|
+
const column = table.getAllLeafColumns().find((col) => col.id === id);
|
|
3357
|
+
(_b = (_a = column == null ? void 0 : column.columnDef.meta) == null ? void 0 : _a.onSortChange) == null ? void 0 : _b.call(_a, desc ? "desc" : "asc");
|
|
3358
|
+
} else {
|
|
3359
|
+
table.getAllLeafColumns().forEach((column) => {
|
|
3360
|
+
var _a2, _b2;
|
|
3361
|
+
(_b2 = (_a2 = column.columnDef.meta) == null ? void 0 : _a2.onSortChange) == null ? void 0 : _b2.call(_a2, void 0);
|
|
3362
|
+
});
|
|
3363
|
+
}
|
|
3364
|
+
},
|
|
3365
|
+
onColumnFiltersChange: (updater) => {
|
|
3366
|
+
const newFilters = typeof updater === "function" ? updater(table.getState().columnFilters) : updater;
|
|
3367
|
+
setColumnFilters(newFilters);
|
|
3368
|
+
newFilters.forEach((filter) => {
|
|
3369
|
+
var _a, _b;
|
|
3370
|
+
const column = table.getColumn(filter.id);
|
|
3371
|
+
if ((_b = (_a = column == null ? void 0 : column.columnDef) == null ? void 0 : _a.meta) == null ? void 0 : _b.onFilterChange) {
|
|
3372
|
+
column.columnDef.meta.onFilterChange(filter.value || "");
|
|
3373
|
+
}
|
|
3374
|
+
});
|
|
3375
|
+
},
|
|
3376
|
+
onGlobalFilterChange: (updater) => {
|
|
3377
|
+
var _a;
|
|
3378
|
+
const newGlobalFilter = typeof updater === "function" ? updater(globalFilter) : updater;
|
|
3379
|
+
setGlobalFilter(newGlobalFilter);
|
|
3380
|
+
if ((_a = table.options.meta) == null ? void 0 : _a.onGlobalFilterChange) {
|
|
3381
|
+
table.options.meta.onGlobalFilterChange(newGlobalFilter || "");
|
|
3382
|
+
}
|
|
3383
|
+
if (newGlobalFilter) {
|
|
3384
|
+
table.getAllLeafColumns().forEach((column) => {
|
|
3385
|
+
var _a2;
|
|
3386
|
+
if (column.getCanFilter() && ((_a2 = column.columnDef.meta) == null ? void 0 : _a2.onFilterChange)) {
|
|
3387
|
+
column.columnDef.meta.onFilterChange(newGlobalFilter);
|
|
3388
|
+
}
|
|
3389
|
+
});
|
|
3390
|
+
}
|
|
3391
|
+
},
|
|
3392
|
+
onColumnVisibilityChange: setColumnVisibility,
|
|
3393
|
+
onColumnPinningChange: setColumnPinning,
|
|
3394
|
+
onRowSelectionChange: (updater) => {
|
|
3395
|
+
const newSelection = typeof updater === "function" ? updater(rowSelection) : updater;
|
|
3396
|
+
setRowSelection(newSelection);
|
|
3397
|
+
const selectedRowIds = Object.keys(newSelection).filter((id) => newSelection[id]);
|
|
3398
|
+
const newSelectedRows = selectedRowIds.map((rowId) => {
|
|
3399
|
+
const found = data.find((row) => safeGetRowId(row) === rowId);
|
|
3400
|
+
if (found)
|
|
3401
|
+
return found;
|
|
3402
|
+
return selectedRows.find((row) => safeGetRowId(row) === rowId);
|
|
3403
|
+
}).filter(Boolean);
|
|
3404
|
+
onSelectedRowsChange == null ? void 0 : onSelectedRowsChange(newSelectedRows, newSelection);
|
|
3405
|
+
},
|
|
3406
|
+
getCoreRowModel: getCoreRowModel(),
|
|
3407
|
+
getFilteredRowModel: getFilteredRowModel(),
|
|
3408
|
+
getPaginationRowModel: getPaginationRowModel(),
|
|
3409
|
+
getSortedRowModel: getSortedRowModel(),
|
|
3410
|
+
enableColumnResizing: columnResizing,
|
|
3411
|
+
manualPagination,
|
|
3412
|
+
manualFiltering,
|
|
3413
|
+
manualSorting,
|
|
3414
|
+
autoResetPageIndex
|
|
1523
3415
|
});
|
|
1524
|
-
const
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
3416
|
+
const headerRef = useRef(null);
|
|
3417
|
+
const bodyRef = useRef(null);
|
|
3418
|
+
const footerRef = useRef(null);
|
|
3419
|
+
const tableScrollRef = useRef(null);
|
|
3420
|
+
const hasToolbar = Children.toArray(children).some((child) => isValidElement(child) && child.type === TableToolbar) || noBorder;
|
|
3421
|
+
const hasPagination = Children.toArray(children).some((child) => {
|
|
3422
|
+
if (!isValidElement(child))
|
|
3423
|
+
return false;
|
|
3424
|
+
if (child.type === TablePagination)
|
|
3425
|
+
return true;
|
|
3426
|
+
if (typeof child.type !== "function")
|
|
3427
|
+
return false;
|
|
3428
|
+
const component = child.type;
|
|
3429
|
+
const componentName = component.displayName || component.name || "";
|
|
3430
|
+
return componentName.includes("Pagination");
|
|
3431
|
+
});
|
|
3432
|
+
const hasFilterBar = Children.toArray(children).some(
|
|
3433
|
+
(child) => isValidElement(child) && child.type === TableFilterBar
|
|
3434
|
+
);
|
|
3435
|
+
const hasFooter = table.getVisibleFlatColumns().some((column) => column.columnDef.footer !== void 0);
|
|
3436
|
+
const isVirtualTableLayout = useMemo(() => {
|
|
3437
|
+
let virtual = false;
|
|
3438
|
+
Children.forEach(children, (child) => {
|
|
3439
|
+
if (isValidElement(child) && child.type === TableMain) {
|
|
3440
|
+
const p = child.props;
|
|
3441
|
+
virtual = Boolean(p.useVirtualization);
|
|
3442
|
+
}
|
|
3443
|
+
});
|
|
3444
|
+
return virtual;
|
|
3445
|
+
}, [children]);
|
|
3446
|
+
const contextValue = {
|
|
3447
|
+
table,
|
|
3448
|
+
headerRef,
|
|
3449
|
+
bodyRef,
|
|
3450
|
+
footerRef,
|
|
3451
|
+
tableScrollRef,
|
|
3452
|
+
selectedRows,
|
|
3453
|
+
onClickRow,
|
|
1532
3454
|
hasToolbar,
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
3455
|
+
hasFilterBar,
|
|
3456
|
+
hasPagination,
|
|
3457
|
+
columnResizing,
|
|
3458
|
+
filterValue,
|
|
3459
|
+
setFilterValue,
|
|
3460
|
+
outsideFilters,
|
|
3461
|
+
hasFooter,
|
|
3462
|
+
isLoading,
|
|
3463
|
+
isVirtualTableLayout
|
|
1536
3464
|
};
|
|
1537
|
-
|
|
3465
|
+
useEffect(() => {
|
|
3466
|
+
if (selectedRows.length === 0) {
|
|
3467
|
+
table.resetRowSelection();
|
|
3468
|
+
}
|
|
3469
|
+
}, [onSelectedRowsChange, selectedRows.length, table]);
|
|
3470
|
+
return /* @__PURE__ */ jsx(TableContainer, { hasToolbar: hasToolbar || hasFilterBar, children: /* @__PURE__ */ jsx(TableProvider, { value: contextValue, children }) });
|
|
1538
3471
|
};
|
|
1539
3472
|
var TableColumnVisibility = () => {
|
|
1540
3473
|
const { table } = useTable();
|
|
@@ -1542,7 +3475,7 @@ var TableColumnVisibility = () => {
|
|
|
1542
3475
|
var _a;
|
|
1543
3476
|
const header = column.columnDef.header;
|
|
1544
3477
|
if (typeof header === "function") {
|
|
1545
|
-
const headerContent = header();
|
|
3478
|
+
const headerContent = header({ table, column, header: column.columnDef.header });
|
|
1546
3479
|
if (typeof headerContent === "string") {
|
|
1547
3480
|
return headerContent;
|
|
1548
3481
|
}
|
|
@@ -1563,37 +3496,6 @@ var TableColumnVisibility = () => {
|
|
|
1563
3496
|
}) })
|
|
1564
3497
|
] });
|
|
1565
3498
|
};
|
|
1566
|
-
var TableBtn = styled2.button`
|
|
1567
|
-
display: flex;
|
|
1568
|
-
align-items: center;
|
|
1569
|
-
gap: 2px;
|
|
1570
|
-
border: 1px solid ${colorTokens.neutral200};
|
|
1571
|
-
border-radius: 4px;
|
|
1572
|
-
padding: 4px;
|
|
1573
|
-
background: ${colorTokens.neutral150};
|
|
1574
|
-
color: ${colorTokens.neutral700};
|
|
1575
|
-
cursor: ${({ onClick }) => onClick ? "pointer" : "default"};
|
|
1576
|
-
|
|
1577
|
-
&:hover {
|
|
1578
|
-
background: ${({ disabled }) => disabled ? colorTokens.neutral150 : colorTokens.neutral200};
|
|
1579
|
-
}
|
|
1580
|
-
|
|
1581
|
-
&:disabled {
|
|
1582
|
-
cursor: not-allowed;
|
|
1583
|
-
opacity: 0.5;
|
|
1584
|
-
}
|
|
1585
|
-
`;
|
|
1586
|
-
var TableButton = (_a) => {
|
|
1587
|
-
var _b = _a, { children, leftSource, rightSource } = _b, buttonProps = __objRest(_b, ["children", "leftSource", "rightSource"]);
|
|
1588
|
-
return /* @__PURE__ */ jsxs(TableBtn, __spreadProps(__spreadValues({}, buttonProps), { children: [
|
|
1589
|
-
leftSource && leftSource,
|
|
1590
|
-
/* @__PURE__ */ jsx(Text, { typography: "body2_500", lineClamp: 2, children }),
|
|
1591
|
-
rightSource && rightSource
|
|
1592
|
-
] }));
|
|
1593
|
-
};
|
|
1594
|
-
var TableBadge = ({ children }) => {
|
|
1595
|
-
return /* @__PURE__ */ jsx(StackContainer, { radius: "borderRadius04", background: "neutral150", padding: "2px 4px", children: /* @__PURE__ */ jsx(Text, { typography: "body2_400", children }) });
|
|
1596
|
-
};
|
|
1597
3499
|
|
|
1598
3500
|
// src/components/Table/components/Table/index.ts
|
|
1599
3501
|
var TableComponent = Object.assign(Table, {
|
|
@@ -1624,7 +3526,7 @@ var AttachmentList = (_a) => {
|
|
|
1624
3526
|
return /* @__PURE__ */ jsx(AttachmentListContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx(StackContainer.Horizontal, __spreadProps(__spreadValues({ spacing: "spacing08" }, rest), { children })) });
|
|
1625
3527
|
};
|
|
1626
3528
|
var AttachmentList_default = AttachmentList;
|
|
1627
|
-
var StyledSeparator =
|
|
3529
|
+
var StyledSeparator = styled3.div`
|
|
1628
3530
|
width: 2px;
|
|
1629
3531
|
height: 2px;
|
|
1630
3532
|
background-color: var(--neutral400);
|