@deepnoid/ui 0.0.80 → 0.0.83
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/{chunk-TDMXAHWR.mjs → chunk-6U736HAX.mjs} +30 -4
- package/dist/{chunk-DLVQWKQG.mjs → chunk-BHSCW5D6.mjs} +23 -18
- package/dist/{chunk-G3CX6IWH.mjs → chunk-PUFNT5LS.mjs} +18 -6
- package/dist/components/table/index.d.mts +1 -1
- package/dist/components/table/index.d.ts +1 -1
- package/dist/components/table/index.js +68 -25
- package/dist/components/table/index.mjs +3 -3
- package/dist/components/table/table-body.d.mts +5 -2
- package/dist/components/table/table-body.d.ts +5 -2
- package/dist/components/table/table-body.js +23 -18
- package/dist/components/table/table-body.mjs +1 -1
- package/dist/components/table/table-head.d.mts +4 -2
- package/dist/components/table/table-head.d.ts +4 -2
- package/dist/components/table/table-head.js +18 -6
- package/dist/components/table/table-head.mjs +1 -1
- package/dist/components/table/table.d.mts +32 -59
- package/dist/components/table/table.d.ts +32 -59
- package/dist/components/table/table.js +68 -25
- package/dist/components/table/table.mjs +3 -3
- package/dist/components/table/table.test.js +70 -27
- package/dist/components/table/table.test.mjs +3 -3
- package/dist/index.js +68 -25
- package/dist/index.mjs +11 -11
- package/package.json +2 -2
|
@@ -1,71 +1,23 @@
|
|
|
1
1
|
import * as tailwind_variants from 'tailwind-variants';
|
|
2
2
|
import { VariantProps } from 'tailwind-variants';
|
|
3
3
|
import * as tailwind_variants_dist_config from 'tailwind-variants/dist/config';
|
|
4
|
-
import
|
|
5
|
-
import { ReactElement, ReactNode } from 'react';
|
|
4
|
+
import react__default, { ReactElement } from 'react';
|
|
6
5
|
import { SlotsToClasses } from '../../utils/types.mjs';
|
|
7
6
|
|
|
8
|
-
interface Props extends Omit<
|
|
7
|
+
interface Props extends Omit<react__default.ComponentPropsWithRef<"table">, "ref" | "color" | "slot" | "size" | "defaultChecked" | "defaultValue"> {
|
|
9
8
|
rows: TableRow[];
|
|
10
9
|
columns: TableColumn[];
|
|
11
10
|
isLoading?: boolean;
|
|
12
|
-
emptyContent?:
|
|
13
|
-
onRowAction?: (e: React.MouseEvent, params: TableRow) => void;
|
|
14
|
-
/**
|
|
15
|
-
* @example
|
|
16
|
-
* ```ts
|
|
17
|
-
* <Table classNames={{
|
|
18
|
-
* base:"base-classes", // table wrapper
|
|
19
|
-
* table: "table-classes",
|
|
20
|
-
* thead: "thead-classes",
|
|
21
|
-
* tbody: "tbody-classes",
|
|
22
|
-
* tr: "tr-classes",
|
|
23
|
-
* th: "th-classes",
|
|
24
|
-
* td: "td-classes",
|
|
25
|
-
* tfoot: "tfoot-classes",
|
|
26
|
-
* sortIcon: "sort-icon-classes",
|
|
27
|
-
* emptyWrapper: "empty-wrapper-classes",
|
|
28
|
-
* }} />
|
|
29
|
-
* ```
|
|
30
|
-
*/
|
|
11
|
+
emptyContent?: ReactElement;
|
|
31
12
|
classNames?: SlotsToClasses<TableSlots>;
|
|
13
|
+
onRowAction?: (e: react__default.MouseEvent, params: TableRow) => void;
|
|
32
14
|
}
|
|
33
|
-
|
|
15
|
+
interface TableRef {
|
|
16
|
+
selectedRows: Set<number>;
|
|
17
|
+
setSelectedRows: (rows: Set<number>) => void;
|
|
18
|
+
}
|
|
19
|
+
declare const Table: react__default.ForwardRefExoticComponent<Props & TableVariantProps & react__default.RefAttributes<TableRef>>;
|
|
34
20
|
|
|
35
|
-
/**
|
|
36
|
-
* Table 테일 윈드
|
|
37
|
-
*
|
|
38
|
-
* @example
|
|
39
|
-
* ```js
|
|
40
|
-
* const {base, table, thead, tbody, th, th, th, tfoot} = table({...})
|
|
41
|
-
*
|
|
42
|
-
* <div className={base()}>
|
|
43
|
-
* <table className={table()}>
|
|
44
|
-
* <thead className={thead()}>
|
|
45
|
-
* <tr className={tr()}>
|
|
46
|
-
* <th className={th()}>...</th>
|
|
47
|
-
* <th className={th()}>...</th>
|
|
48
|
-
* </tr>
|
|
49
|
-
* </thead>
|
|
50
|
-
* <tbody className={tbody()}>
|
|
51
|
-
* <tr className={tr()}>
|
|
52
|
-
* <td className={td()}>...</td>
|
|
53
|
-
* <td className={td()}>...</td>
|
|
54
|
-
* </tr>
|
|
55
|
-
* <tr className={tr()}>
|
|
56
|
-
* <td className={td()}>...</td>
|
|
57
|
-
* <td className={td()}>...</td>
|
|
58
|
-
* </tr>
|
|
59
|
-
* </tbody>
|
|
60
|
-
* <tfoot className={tfoot()}>
|
|
61
|
-
* <tr className={tr()}>
|
|
62
|
-
* <td className={td()}>...</td>
|
|
63
|
-
* <td className={td()}>...</td>
|
|
64
|
-
* </tr>
|
|
65
|
-
* </tfoot>
|
|
66
|
-
* </table>
|
|
67
|
-
* </div>
|
|
68
|
-
*/
|
|
69
21
|
declare const table: tailwind_variants.TVReturnType<{
|
|
70
22
|
variant: {
|
|
71
23
|
solid: {
|
|
@@ -113,6 +65,9 @@ declare const table: tailwind_variants.TVReturnType<{
|
|
|
113
65
|
isSelected: {
|
|
114
66
|
true: {};
|
|
115
67
|
};
|
|
68
|
+
isSelectedRow: {
|
|
69
|
+
true: {};
|
|
70
|
+
};
|
|
116
71
|
hideHeader: {
|
|
117
72
|
true: {
|
|
118
73
|
thead: string;
|
|
@@ -194,6 +149,9 @@ declare const table: tailwind_variants.TVReturnType<{
|
|
|
194
149
|
isSelected: {
|
|
195
150
|
true: {};
|
|
196
151
|
};
|
|
152
|
+
isSelectedRow: {
|
|
153
|
+
true: {};
|
|
154
|
+
};
|
|
197
155
|
hideHeader: {
|
|
198
156
|
true: {
|
|
199
157
|
thead: string;
|
|
@@ -262,6 +220,9 @@ declare const table: tailwind_variants.TVReturnType<{
|
|
|
262
220
|
isSelected: {
|
|
263
221
|
true: {};
|
|
264
222
|
};
|
|
223
|
+
isSelectedRow: {
|
|
224
|
+
true: {};
|
|
225
|
+
};
|
|
265
226
|
hideHeader: {
|
|
266
227
|
true: {
|
|
267
228
|
thead: string;
|
|
@@ -330,6 +291,9 @@ declare const table: tailwind_variants.TVReturnType<{
|
|
|
330
291
|
isSelected: {
|
|
331
292
|
true: {};
|
|
332
293
|
};
|
|
294
|
+
isSelectedRow: {
|
|
295
|
+
true: {};
|
|
296
|
+
};
|
|
333
297
|
hideHeader: {
|
|
334
298
|
true: {
|
|
335
299
|
thead: string;
|
|
@@ -411,6 +375,9 @@ declare const table: tailwind_variants.TVReturnType<{
|
|
|
411
375
|
isSelected: {
|
|
412
376
|
true: {};
|
|
413
377
|
};
|
|
378
|
+
isSelectedRow: {
|
|
379
|
+
true: {};
|
|
380
|
+
};
|
|
414
381
|
hideHeader: {
|
|
415
382
|
true: {
|
|
416
383
|
thead: string;
|
|
@@ -492,6 +459,9 @@ declare const table: tailwind_variants.TVReturnType<{
|
|
|
492
459
|
isSelected: {
|
|
493
460
|
true: {};
|
|
494
461
|
};
|
|
462
|
+
isSelectedRow: {
|
|
463
|
+
true: {};
|
|
464
|
+
};
|
|
495
465
|
hideHeader: {
|
|
496
466
|
true: {
|
|
497
467
|
thead: string;
|
|
@@ -560,6 +530,9 @@ declare const table: tailwind_variants.TVReturnType<{
|
|
|
560
530
|
isSelected: {
|
|
561
531
|
true: {};
|
|
562
532
|
};
|
|
533
|
+
isSelectedRow: {
|
|
534
|
+
true: {};
|
|
535
|
+
};
|
|
563
536
|
hideHeader: {
|
|
564
537
|
true: {
|
|
565
538
|
thead: string;
|
|
@@ -604,7 +577,7 @@ type TableColumn<R extends RowValue = RowValue, V = any, F = V> = {
|
|
|
604
577
|
headerName?: string | ReactElement;
|
|
605
578
|
className?: string;
|
|
606
579
|
valueFormatter?: (params: ValueFormatterParams<V>) => F;
|
|
607
|
-
renderCell?: (params: CellParams<R, V, F>) =>
|
|
580
|
+
renderCell?: (params: CellParams<R, V, F>) => react__default.ReactNode;
|
|
608
581
|
};
|
|
609
582
|
|
|
610
|
-
export { type TableColumn, type TableReturnType, type TableRow, type TableSlots, type TableVariantProps, Table as default };
|
|
583
|
+
export { type TableColumn, type TableRef, type TableReturnType, type TableRow, type TableSlots, type TableVariantProps, Table as default };
|
|
@@ -1,71 +1,23 @@
|
|
|
1
1
|
import * as tailwind_variants from 'tailwind-variants';
|
|
2
2
|
import { VariantProps } from 'tailwind-variants';
|
|
3
3
|
import * as tailwind_variants_dist_config from 'tailwind-variants/dist/config';
|
|
4
|
-
import
|
|
5
|
-
import { ReactElement, ReactNode } from 'react';
|
|
4
|
+
import react__default, { ReactElement } from 'react';
|
|
6
5
|
import { SlotsToClasses } from '../../utils/types.js';
|
|
7
6
|
|
|
8
|
-
interface Props extends Omit<
|
|
7
|
+
interface Props extends Omit<react__default.ComponentPropsWithRef<"table">, "ref" | "color" | "slot" | "size" | "defaultChecked" | "defaultValue"> {
|
|
9
8
|
rows: TableRow[];
|
|
10
9
|
columns: TableColumn[];
|
|
11
10
|
isLoading?: boolean;
|
|
12
|
-
emptyContent?:
|
|
13
|
-
onRowAction?: (e: React.MouseEvent, params: TableRow) => void;
|
|
14
|
-
/**
|
|
15
|
-
* @example
|
|
16
|
-
* ```ts
|
|
17
|
-
* <Table classNames={{
|
|
18
|
-
* base:"base-classes", // table wrapper
|
|
19
|
-
* table: "table-classes",
|
|
20
|
-
* thead: "thead-classes",
|
|
21
|
-
* tbody: "tbody-classes",
|
|
22
|
-
* tr: "tr-classes",
|
|
23
|
-
* th: "th-classes",
|
|
24
|
-
* td: "td-classes",
|
|
25
|
-
* tfoot: "tfoot-classes",
|
|
26
|
-
* sortIcon: "sort-icon-classes",
|
|
27
|
-
* emptyWrapper: "empty-wrapper-classes",
|
|
28
|
-
* }} />
|
|
29
|
-
* ```
|
|
30
|
-
*/
|
|
11
|
+
emptyContent?: ReactElement;
|
|
31
12
|
classNames?: SlotsToClasses<TableSlots>;
|
|
13
|
+
onRowAction?: (e: react__default.MouseEvent, params: TableRow) => void;
|
|
32
14
|
}
|
|
33
|
-
|
|
15
|
+
interface TableRef {
|
|
16
|
+
selectedRows: Set<number>;
|
|
17
|
+
setSelectedRows: (rows: Set<number>) => void;
|
|
18
|
+
}
|
|
19
|
+
declare const Table: react__default.ForwardRefExoticComponent<Props & TableVariantProps & react__default.RefAttributes<TableRef>>;
|
|
34
20
|
|
|
35
|
-
/**
|
|
36
|
-
* Table 테일 윈드
|
|
37
|
-
*
|
|
38
|
-
* @example
|
|
39
|
-
* ```js
|
|
40
|
-
* const {base, table, thead, tbody, th, th, th, tfoot} = table({...})
|
|
41
|
-
*
|
|
42
|
-
* <div className={base()}>
|
|
43
|
-
* <table className={table()}>
|
|
44
|
-
* <thead className={thead()}>
|
|
45
|
-
* <tr className={tr()}>
|
|
46
|
-
* <th className={th()}>...</th>
|
|
47
|
-
* <th className={th()}>...</th>
|
|
48
|
-
* </tr>
|
|
49
|
-
* </thead>
|
|
50
|
-
* <tbody className={tbody()}>
|
|
51
|
-
* <tr className={tr()}>
|
|
52
|
-
* <td className={td()}>...</td>
|
|
53
|
-
* <td className={td()}>...</td>
|
|
54
|
-
* </tr>
|
|
55
|
-
* <tr className={tr()}>
|
|
56
|
-
* <td className={td()}>...</td>
|
|
57
|
-
* <td className={td()}>...</td>
|
|
58
|
-
* </tr>
|
|
59
|
-
* </tbody>
|
|
60
|
-
* <tfoot className={tfoot()}>
|
|
61
|
-
* <tr className={tr()}>
|
|
62
|
-
* <td className={td()}>...</td>
|
|
63
|
-
* <td className={td()}>...</td>
|
|
64
|
-
* </tr>
|
|
65
|
-
* </tfoot>
|
|
66
|
-
* </table>
|
|
67
|
-
* </div>
|
|
68
|
-
*/
|
|
69
21
|
declare const table: tailwind_variants.TVReturnType<{
|
|
70
22
|
variant: {
|
|
71
23
|
solid: {
|
|
@@ -113,6 +65,9 @@ declare const table: tailwind_variants.TVReturnType<{
|
|
|
113
65
|
isSelected: {
|
|
114
66
|
true: {};
|
|
115
67
|
};
|
|
68
|
+
isSelectedRow: {
|
|
69
|
+
true: {};
|
|
70
|
+
};
|
|
116
71
|
hideHeader: {
|
|
117
72
|
true: {
|
|
118
73
|
thead: string;
|
|
@@ -194,6 +149,9 @@ declare const table: tailwind_variants.TVReturnType<{
|
|
|
194
149
|
isSelected: {
|
|
195
150
|
true: {};
|
|
196
151
|
};
|
|
152
|
+
isSelectedRow: {
|
|
153
|
+
true: {};
|
|
154
|
+
};
|
|
197
155
|
hideHeader: {
|
|
198
156
|
true: {
|
|
199
157
|
thead: string;
|
|
@@ -262,6 +220,9 @@ declare const table: tailwind_variants.TVReturnType<{
|
|
|
262
220
|
isSelected: {
|
|
263
221
|
true: {};
|
|
264
222
|
};
|
|
223
|
+
isSelectedRow: {
|
|
224
|
+
true: {};
|
|
225
|
+
};
|
|
265
226
|
hideHeader: {
|
|
266
227
|
true: {
|
|
267
228
|
thead: string;
|
|
@@ -330,6 +291,9 @@ declare const table: tailwind_variants.TVReturnType<{
|
|
|
330
291
|
isSelected: {
|
|
331
292
|
true: {};
|
|
332
293
|
};
|
|
294
|
+
isSelectedRow: {
|
|
295
|
+
true: {};
|
|
296
|
+
};
|
|
333
297
|
hideHeader: {
|
|
334
298
|
true: {
|
|
335
299
|
thead: string;
|
|
@@ -411,6 +375,9 @@ declare const table: tailwind_variants.TVReturnType<{
|
|
|
411
375
|
isSelected: {
|
|
412
376
|
true: {};
|
|
413
377
|
};
|
|
378
|
+
isSelectedRow: {
|
|
379
|
+
true: {};
|
|
380
|
+
};
|
|
414
381
|
hideHeader: {
|
|
415
382
|
true: {
|
|
416
383
|
thead: string;
|
|
@@ -492,6 +459,9 @@ declare const table: tailwind_variants.TVReturnType<{
|
|
|
492
459
|
isSelected: {
|
|
493
460
|
true: {};
|
|
494
461
|
};
|
|
462
|
+
isSelectedRow: {
|
|
463
|
+
true: {};
|
|
464
|
+
};
|
|
495
465
|
hideHeader: {
|
|
496
466
|
true: {
|
|
497
467
|
thead: string;
|
|
@@ -560,6 +530,9 @@ declare const table: tailwind_variants.TVReturnType<{
|
|
|
560
530
|
isSelected: {
|
|
561
531
|
true: {};
|
|
562
532
|
};
|
|
533
|
+
isSelectedRow: {
|
|
534
|
+
true: {};
|
|
535
|
+
};
|
|
563
536
|
hideHeader: {
|
|
564
537
|
true: {
|
|
565
538
|
thead: string;
|
|
@@ -604,7 +577,7 @@ type TableColumn<R extends RowValue = RowValue, V = any, F = V> = {
|
|
|
604
577
|
headerName?: string | ReactElement;
|
|
605
578
|
className?: string;
|
|
606
579
|
valueFormatter?: (params: ValueFormatterParams<V>) => F;
|
|
607
|
-
renderCell?: (params: CellParams<R, V, F>) =>
|
|
580
|
+
renderCell?: (params: CellParams<R, V, F>) => react__default.ReactNode;
|
|
608
581
|
};
|
|
609
582
|
|
|
610
|
-
export { type TableColumn, type TableReturnType, type TableRow, type TableSlots, type TableVariantProps, Table as default };
|
|
583
|
+
export { type TableColumn, type TableRef, type TableReturnType, type TableRow, type TableSlots, type TableVariantProps, Table as default };
|
|
@@ -305,7 +305,17 @@ var checkbox = tv({
|
|
|
305
305
|
// src/components/table/table-head.tsx
|
|
306
306
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
307
307
|
var import_react3 = require("react");
|
|
308
|
-
var TableHead = ({
|
|
308
|
+
var TableHead = ({
|
|
309
|
+
columns,
|
|
310
|
+
slots,
|
|
311
|
+
size,
|
|
312
|
+
color,
|
|
313
|
+
isExpanded,
|
|
314
|
+
isSelected,
|
|
315
|
+
isAllSelected,
|
|
316
|
+
classNames,
|
|
317
|
+
onSelectAll
|
|
318
|
+
}) => {
|
|
309
319
|
const getTheadProps = (0, import_react2.useCallback)(
|
|
310
320
|
() => ({
|
|
311
321
|
className: slots.thead({ class: clsx(classNames == null ? void 0 : classNames.thead) })
|
|
@@ -322,14 +332,16 @@ var TableHead = ({ columns, slots, size, color, isSelected, isExpanded, classNam
|
|
|
322
332
|
({ className }) => ({
|
|
323
333
|
className: slots.th({ class: clsx(classNames == null ? void 0 : classNames.th, className) })
|
|
324
334
|
}),
|
|
325
|
-
[classNames == null ? void 0 : classNames.th,
|
|
335
|
+
[classNames == null ? void 0 : classNames.th, slots]
|
|
326
336
|
);
|
|
337
|
+
const handleClickSelectAll = (e) => {
|
|
338
|
+
e.preventDefault();
|
|
339
|
+
onSelectAll(!isAllSelected);
|
|
340
|
+
};
|
|
327
341
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("thead", { ...getTheadProps(), children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("tr", { ...getTrProps(), children: [
|
|
328
|
-
isSelected && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("th", { className: "w-[40px]", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(checkbox_default, { size, color, classNames: { wrapper: "bg-background" } }) }),
|
|
342
|
+
isSelected && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("th", { className: "w-[40px]", onClick: handleClickSelectAll, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(checkbox_default, { size, color, checked: isAllSelected, classNames: { wrapper: "bg-background" } }) }),
|
|
329
343
|
isExpanded && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("th", { className: "w-[40px]" }),
|
|
330
|
-
columns.map((column, index) => {
|
|
331
|
-
return /* @__PURE__ */ (0, import_react3.createElement)("th", { ...getThProps(column), key: column.field + index + "th" }, column.headerName);
|
|
332
|
-
})
|
|
344
|
+
columns.map((column, index) => /* @__PURE__ */ (0, import_react3.createElement)("th", { ...getThProps(column), key: column.field + index + "th" }, column.headerName))
|
|
333
345
|
] }) });
|
|
334
346
|
};
|
|
335
347
|
var table_head_default = TableHead;
|
|
@@ -2738,12 +2750,15 @@ var TableBody = ({
|
|
|
2738
2750
|
slots,
|
|
2739
2751
|
rows,
|
|
2740
2752
|
columns,
|
|
2741
|
-
isSelected,
|
|
2742
2753
|
isExpanded,
|
|
2754
|
+
isSelected,
|
|
2755
|
+
isSelectedRow,
|
|
2756
|
+
selectedRows,
|
|
2743
2757
|
emptyContent,
|
|
2758
|
+
onSelectRow,
|
|
2744
2759
|
onRowAction
|
|
2745
2760
|
}) => {
|
|
2746
|
-
const
|
|
2761
|
+
const COL_SPAN_COUNT = columns.length + (isExpanded ? 1 : 0) + (isSelected ? 1 : 0);
|
|
2747
2762
|
const [expandedRows, setExpandedRows] = (0, import_react4.useState)(/* @__PURE__ */ new Set());
|
|
2748
2763
|
(0, import_react4.useEffect)(() => {
|
|
2749
2764
|
setExpandedRows(/* @__PURE__ */ new Set());
|
|
@@ -2795,20 +2810,22 @@ var TableBody = ({
|
|
|
2795
2810
|
},
|
|
2796
2811
|
[classNames == null ? void 0 : classNames.td, columns, slots]
|
|
2797
2812
|
);
|
|
2813
|
+
const onChangeExpandedRow = (index) => {
|
|
2814
|
+
setExpandedRows((prevIndices) => {
|
|
2815
|
+
const newIndices = new Set(prevIndices);
|
|
2816
|
+
if (newIndices.has(index)) {
|
|
2817
|
+
newIndices.delete(index);
|
|
2818
|
+
} else {
|
|
2819
|
+
newIndices.add(index);
|
|
2820
|
+
}
|
|
2821
|
+
return newIndices;
|
|
2822
|
+
});
|
|
2823
|
+
};
|
|
2798
2824
|
const handleRowClick = (index) => (e) => {
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
if (isExpanded)
|
|
2802
|
-
|
|
2803
|
-
const newIndices = new Set(prevIndices);
|
|
2804
|
-
if (newIndices.has(index)) {
|
|
2805
|
-
newIndices.delete(index);
|
|
2806
|
-
} else {
|
|
2807
|
-
newIndices.add(index);
|
|
2808
|
-
}
|
|
2809
|
-
return newIndices;
|
|
2810
|
-
});
|
|
2811
|
-
}
|
|
2825
|
+
e.stopPropagation();
|
|
2826
|
+
e.preventDefault();
|
|
2827
|
+
if (isExpanded) onChangeExpandedRow(index);
|
|
2828
|
+
if (isSelected && isSelectedRow) onSelectRow(index);
|
|
2812
2829
|
const row = rows[index];
|
|
2813
2830
|
if (row !== void 0) {
|
|
2814
2831
|
onRowAction == null ? void 0 : onRowAction(e, row);
|
|
@@ -2818,7 +2835,7 @@ var TableBody = ({
|
|
|
2818
2835
|
const keys = Object.keys(row);
|
|
2819
2836
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_react4.default.Fragment, { children: [
|
|
2820
2837
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("tr", { ...getTrProps(rowIndex), onClick: handleRowClick(rowIndex), children: [
|
|
2821
|
-
isSelected && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("td", { ...getTdProps({ field: "checkbox" }, row, keys), children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(checkbox_default, { color, size }) }),
|
|
2838
|
+
isSelected && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("td", { ...getTdProps({ field: "checkbox" }, row, keys), onClick: () => onSelectRow(rowIndex), children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(checkbox_default, { color, size, checked: selectedRows.has(rowIndex) }) }),
|
|
2822
2839
|
isExpanded && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("td", { ...getTdProps({ field: "expandIcon" }, row, keys), children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2823
2840
|
Icon_default,
|
|
2824
2841
|
{
|
|
@@ -2829,9 +2846,9 @@ var TableBody = ({
|
|
|
2829
2846
|
) }),
|
|
2830
2847
|
columns.map((column, colIndex) => /* @__PURE__ */ (0, import_react5.createElement)("td", { ...getTdProps(column, row, keys), key: colIndex }))
|
|
2831
2848
|
] }),
|
|
2832
|
-
isExpanded && expandedRows.has(rowIndex) && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("tr", { ...getExpandedContentProps(), children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("td", { colSpan:
|
|
2849
|
+
isExpanded && expandedRows.has(rowIndex) && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("tr", { ...getExpandedContentProps(), children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("td", { colSpan: COL_SPAN_COUNT, ...getTdProps({ field: "expandedRow" }, row, keys), children: row.renderExpandedRow && row.renderExpandedRow() }) })
|
|
2833
2850
|
] }, rowIndex);
|
|
2834
|
-
}) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("tr", { ...getTrProps(-1), children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("td", { colSpan:
|
|
2851
|
+
}) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("tr", { ...getTrProps(-1), children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("td", { colSpan: COL_SPAN_COUNT, children: emptyContent }) }) });
|
|
2835
2852
|
};
|
|
2836
2853
|
var table_body_default = TableBody;
|
|
2837
2854
|
|
|
@@ -2841,6 +2858,7 @@ var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
|
2841
2858
|
var Table = (0, import_react6.forwardRef)((originalProps, ref) => {
|
|
2842
2859
|
const [props, variantProps] = mapPropsVariants(originalProps, table.variantKeys);
|
|
2843
2860
|
const { classNames, rows, columns, isLoading, className, emptyContent, onRowAction, ...tableComponentsProps } = props;
|
|
2861
|
+
const [selectedRows, setSelectedRows] = (0, import_react6.useState)(/* @__PURE__ */ new Set());
|
|
2844
2862
|
const slots = (0, import_react6.useMemo)(() => table({ ...variantProps }), [...Object.values(variantProps)]);
|
|
2845
2863
|
const getBaseProps = (0, import_react6.useCallback)(
|
|
2846
2864
|
(props2) => ({
|
|
@@ -2856,6 +2874,23 @@ var Table = (0, import_react6.forwardRef)((originalProps, ref) => {
|
|
|
2856
2874
|
}),
|
|
2857
2875
|
[classNames == null ? void 0 : classNames.table, slots]
|
|
2858
2876
|
);
|
|
2877
|
+
const handleSelectAll = (isSelected) => {
|
|
2878
|
+
const newSelectedRows = isSelected ? new Set(rows.map((_, index) => index)) : /* @__PURE__ */ new Set();
|
|
2879
|
+
setSelectedRows(newSelectedRows);
|
|
2880
|
+
};
|
|
2881
|
+
const handleSelectRow = (index) => {
|
|
2882
|
+
const newSelectedRows = new Set(selectedRows);
|
|
2883
|
+
if (newSelectedRows.has(index)) {
|
|
2884
|
+
newSelectedRows.delete(index);
|
|
2885
|
+
} else {
|
|
2886
|
+
newSelectedRows.add(index);
|
|
2887
|
+
}
|
|
2888
|
+
setSelectedRows(newSelectedRows);
|
|
2889
|
+
};
|
|
2890
|
+
(0, import_react6.useImperativeHandle)(ref, () => ({
|
|
2891
|
+
selectedRows,
|
|
2892
|
+
setSelectedRows
|
|
2893
|
+
}));
|
|
2859
2894
|
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { ref, "data-table": "base", ...getBaseProps(), children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("table", { ...getTableProps(tableComponentsProps), children: [
|
|
2860
2895
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
2861
2896
|
table_head_default,
|
|
@@ -2866,7 +2901,9 @@ var Table = (0, import_react6.forwardRef)((originalProps, ref) => {
|
|
|
2866
2901
|
size: originalProps.size,
|
|
2867
2902
|
color: originalProps.color === "neutral" ? "primary" : originalProps.color,
|
|
2868
2903
|
isSelected: originalProps.isSelected,
|
|
2869
|
-
isExpanded: originalProps.isExpanded
|
|
2904
|
+
isExpanded: originalProps.isExpanded,
|
|
2905
|
+
onSelectAll: handleSelectAll,
|
|
2906
|
+
isAllSelected: selectedRows.size === rows.length
|
|
2870
2907
|
}
|
|
2871
2908
|
),
|
|
2872
2909
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
@@ -2878,10 +2915,13 @@ var Table = (0, import_react6.forwardRef)((originalProps, ref) => {
|
|
|
2878
2915
|
size: originalProps.size,
|
|
2879
2916
|
color: originalProps.color === "neutral" ? "primary" : originalProps.color,
|
|
2880
2917
|
isSelected: originalProps.isSelected,
|
|
2918
|
+
isSelectedRow: originalProps.isSelectedRow,
|
|
2881
2919
|
isExpanded: originalProps.isExpanded,
|
|
2882
2920
|
isLoading,
|
|
2883
2921
|
classNames,
|
|
2884
2922
|
emptyContent,
|
|
2923
|
+
selectedRows,
|
|
2924
|
+
onSelectRow: handleSelectRow,
|
|
2885
2925
|
onRowAction
|
|
2886
2926
|
}
|
|
2887
2927
|
)
|
|
@@ -2983,6 +3023,9 @@ var table = (0, import_tailwind_variants3.tv)({
|
|
|
2983
3023
|
isSelected: {
|
|
2984
3024
|
true: {}
|
|
2985
3025
|
},
|
|
3026
|
+
isSelectedRow: {
|
|
3027
|
+
true: {}
|
|
3028
|
+
},
|
|
2986
3029
|
hideHeader: {
|
|
2987
3030
|
true: {
|
|
2988
3031
|
thead: "hidden"
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
3
|
table_default
|
|
4
|
-
} from "../../chunk-
|
|
5
|
-
import "../../chunk-
|
|
6
|
-
import "../../chunk-
|
|
4
|
+
} from "../../chunk-6U736HAX.mjs";
|
|
5
|
+
import "../../chunk-PUFNT5LS.mjs";
|
|
6
|
+
import "../../chunk-BHSCW5D6.mjs";
|
|
7
7
|
import "../../chunk-QZ3LVYJW.mjs";
|
|
8
8
|
import "../../chunk-BE2OG6M4.mjs";
|
|
9
9
|
import "../../chunk-27Y6K5NK.mjs";
|