@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
|
@@ -9202,7 +9202,7 @@ var require_lz_string = __commonJS({
|
|
|
9202
9202
|
});
|
|
9203
9203
|
|
|
9204
9204
|
// src/components/table/table.test.tsx
|
|
9205
|
-
var
|
|
9205
|
+
var React4 = __toESM(require("react"));
|
|
9206
9206
|
|
|
9207
9207
|
// ../../node_modules/@testing-library/react/dist/@testing-library/react.esm.js
|
|
9208
9208
|
var React = __toESM(require("react"));
|
|
@@ -13142,7 +13142,17 @@ var checkbox = tv({
|
|
|
13142
13142
|
// src/components/table/table-head.tsx
|
|
13143
13143
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
13144
13144
|
var import_react3 = require("react");
|
|
13145
|
-
var TableHead = ({
|
|
13145
|
+
var TableHead = ({
|
|
13146
|
+
columns: columns2,
|
|
13147
|
+
slots,
|
|
13148
|
+
size,
|
|
13149
|
+
color,
|
|
13150
|
+
isExpanded,
|
|
13151
|
+
isSelected,
|
|
13152
|
+
isAllSelected,
|
|
13153
|
+
classNames,
|
|
13154
|
+
onSelectAll
|
|
13155
|
+
}) => {
|
|
13146
13156
|
const getTheadProps = (0, import_react2.useCallback)(
|
|
13147
13157
|
() => ({
|
|
13148
13158
|
className: slots.thead({ class: clsx(classNames == null ? void 0 : classNames.thead) })
|
|
@@ -13159,14 +13169,16 @@ var TableHead = ({ columns: columns2, slots, size, color, isSelected, isExpanded
|
|
|
13159
13169
|
({ className }) => ({
|
|
13160
13170
|
className: slots.th({ class: clsx(classNames == null ? void 0 : classNames.th, className) })
|
|
13161
13171
|
}),
|
|
13162
|
-
[classNames == null ? void 0 : classNames.th,
|
|
13172
|
+
[classNames == null ? void 0 : classNames.th, slots]
|
|
13163
13173
|
);
|
|
13174
|
+
const handleClickSelectAll = (e) => {
|
|
13175
|
+
e.preventDefault();
|
|
13176
|
+
onSelectAll(!isAllSelected);
|
|
13177
|
+
};
|
|
13164
13178
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("thead", { ...getTheadProps(), children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("tr", { ...getTrProps(), children: [
|
|
13165
|
-
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" } }) }),
|
|
13179
|
+
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" } }) }),
|
|
13166
13180
|
isExpanded && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("th", { className: "w-[40px]" }),
|
|
13167
|
-
columns2.map((column, index) => {
|
|
13168
|
-
return /* @__PURE__ */ (0, import_react3.createElement)("th", { ...getThProps(column), key: column.field + index + "th" }, column.headerName);
|
|
13169
|
-
})
|
|
13181
|
+
columns2.map((column, index) => /* @__PURE__ */ (0, import_react3.createElement)("th", { ...getThProps(column), key: column.field + index + "th" }, column.headerName))
|
|
13170
13182
|
] }) });
|
|
13171
13183
|
};
|
|
13172
13184
|
var table_head_default = TableHead;
|
|
@@ -15575,12 +15587,15 @@ var TableBody = ({
|
|
|
15575
15587
|
slots,
|
|
15576
15588
|
rows: rows2,
|
|
15577
15589
|
columns: columns2,
|
|
15578
|
-
isSelected,
|
|
15579
15590
|
isExpanded,
|
|
15591
|
+
isSelected,
|
|
15592
|
+
isSelectedRow,
|
|
15593
|
+
selectedRows,
|
|
15580
15594
|
emptyContent,
|
|
15595
|
+
onSelectRow,
|
|
15581
15596
|
onRowAction
|
|
15582
15597
|
}) => {
|
|
15583
|
-
const
|
|
15598
|
+
const COL_SPAN_COUNT = columns2.length + (isExpanded ? 1 : 0) + (isSelected ? 1 : 0);
|
|
15584
15599
|
const [expandedRows, setExpandedRows] = (0, import_react4.useState)(/* @__PURE__ */ new Set());
|
|
15585
15600
|
(0, import_react4.useEffect)(() => {
|
|
15586
15601
|
setExpandedRows(/* @__PURE__ */ new Set());
|
|
@@ -15632,20 +15647,22 @@ var TableBody = ({
|
|
|
15632
15647
|
},
|
|
15633
15648
|
[classNames == null ? void 0 : classNames.td, columns2, slots]
|
|
15634
15649
|
);
|
|
15650
|
+
const onChangeExpandedRow = (index) => {
|
|
15651
|
+
setExpandedRows((prevIndices) => {
|
|
15652
|
+
const newIndices = new Set(prevIndices);
|
|
15653
|
+
if (newIndices.has(index)) {
|
|
15654
|
+
newIndices.delete(index);
|
|
15655
|
+
} else {
|
|
15656
|
+
newIndices.add(index);
|
|
15657
|
+
}
|
|
15658
|
+
return newIndices;
|
|
15659
|
+
});
|
|
15660
|
+
};
|
|
15635
15661
|
const handleRowClick = (index) => (e) => {
|
|
15636
|
-
|
|
15637
|
-
|
|
15638
|
-
if (isExpanded)
|
|
15639
|
-
|
|
15640
|
-
const newIndices = new Set(prevIndices);
|
|
15641
|
-
if (newIndices.has(index)) {
|
|
15642
|
-
newIndices.delete(index);
|
|
15643
|
-
} else {
|
|
15644
|
-
newIndices.add(index);
|
|
15645
|
-
}
|
|
15646
|
-
return newIndices;
|
|
15647
|
-
});
|
|
15648
|
-
}
|
|
15662
|
+
e.stopPropagation();
|
|
15663
|
+
e.preventDefault();
|
|
15664
|
+
if (isExpanded) onChangeExpandedRow(index);
|
|
15665
|
+
if (isSelected && isSelectedRow) onSelectRow(index);
|
|
15649
15666
|
const row = rows2[index];
|
|
15650
15667
|
if (row !== void 0) {
|
|
15651
15668
|
onRowAction == null ? void 0 : onRowAction(e, row);
|
|
@@ -15655,7 +15672,7 @@ var TableBody = ({
|
|
|
15655
15672
|
const keys = Object.keys(row);
|
|
15656
15673
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_react4.default.Fragment, { children: [
|
|
15657
15674
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("tr", { ...getTrProps(rowIndex), onClick: handleRowClick(rowIndex), children: [
|
|
15658
|
-
isSelected && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("td", { ...getTdProps({ field: "checkbox" }, row, keys), children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(checkbox_default, { color, size }) }),
|
|
15675
|
+
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) }) }),
|
|
15659
15676
|
isExpanded && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("td", { ...getTdProps({ field: "expandIcon" }, row, keys), children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
15660
15677
|
Icon_default,
|
|
15661
15678
|
{
|
|
@@ -15666,9 +15683,9 @@ var TableBody = ({
|
|
|
15666
15683
|
) }),
|
|
15667
15684
|
columns2.map((column, colIndex) => /* @__PURE__ */ (0, import_react5.createElement)("td", { ...getTdProps(column, row, keys), key: colIndex }))
|
|
15668
15685
|
] }),
|
|
15669
|
-
isExpanded && expandedRows.has(rowIndex) && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("tr", { ...getExpandedContentProps(), children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("td", { colSpan:
|
|
15686
|
+
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() }) })
|
|
15670
15687
|
] }, rowIndex);
|
|
15671
|
-
}) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("tr", { ...getTrProps(-1), children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("td", { colSpan:
|
|
15688
|
+
}) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("tr", { ...getTrProps(-1), children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("td", { colSpan: COL_SPAN_COUNT, children: emptyContent }) }) });
|
|
15672
15689
|
};
|
|
15673
15690
|
var table_body_default = TableBody;
|
|
15674
15691
|
|
|
@@ -15678,6 +15695,7 @@ var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
|
15678
15695
|
var Table = (0, import_react6.forwardRef)((originalProps, ref) => {
|
|
15679
15696
|
const [props, variantProps] = mapPropsVariants(originalProps, table.variantKeys);
|
|
15680
15697
|
const { classNames, rows: rows2, columns: columns2, isLoading, className, emptyContent, onRowAction, ...tableComponentsProps } = props;
|
|
15698
|
+
const [selectedRows, setSelectedRows] = (0, import_react6.useState)(/* @__PURE__ */ new Set());
|
|
15681
15699
|
const slots = (0, import_react6.useMemo)(() => table({ ...variantProps }), [...Object.values(variantProps)]);
|
|
15682
15700
|
const getBaseProps = (0, import_react6.useCallback)(
|
|
15683
15701
|
(props2) => ({
|
|
@@ -15693,6 +15711,23 @@ var Table = (0, import_react6.forwardRef)((originalProps, ref) => {
|
|
|
15693
15711
|
}),
|
|
15694
15712
|
[classNames == null ? void 0 : classNames.table, slots]
|
|
15695
15713
|
);
|
|
15714
|
+
const handleSelectAll = (isSelected) => {
|
|
15715
|
+
const newSelectedRows = isSelected ? new Set(rows2.map((_, index) => index)) : /* @__PURE__ */ new Set();
|
|
15716
|
+
setSelectedRows(newSelectedRows);
|
|
15717
|
+
};
|
|
15718
|
+
const handleSelectRow = (index) => {
|
|
15719
|
+
const newSelectedRows = new Set(selectedRows);
|
|
15720
|
+
if (newSelectedRows.has(index)) {
|
|
15721
|
+
newSelectedRows.delete(index);
|
|
15722
|
+
} else {
|
|
15723
|
+
newSelectedRows.add(index);
|
|
15724
|
+
}
|
|
15725
|
+
setSelectedRows(newSelectedRows);
|
|
15726
|
+
};
|
|
15727
|
+
(0, import_react6.useImperativeHandle)(ref, () => ({
|
|
15728
|
+
selectedRows,
|
|
15729
|
+
setSelectedRows
|
|
15730
|
+
}));
|
|
15696
15731
|
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { ref, "data-table": "base", ...getBaseProps(), children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("table", { ...getTableProps(tableComponentsProps), children: [
|
|
15697
15732
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
15698
15733
|
table_head_default,
|
|
@@ -15703,7 +15738,9 @@ var Table = (0, import_react6.forwardRef)((originalProps, ref) => {
|
|
|
15703
15738
|
size: originalProps.size,
|
|
15704
15739
|
color: originalProps.color === "neutral" ? "primary" : originalProps.color,
|
|
15705
15740
|
isSelected: originalProps.isSelected,
|
|
15706
|
-
isExpanded: originalProps.isExpanded
|
|
15741
|
+
isExpanded: originalProps.isExpanded,
|
|
15742
|
+
onSelectAll: handleSelectAll,
|
|
15743
|
+
isAllSelected: selectedRows.size === rows2.length
|
|
15707
15744
|
}
|
|
15708
15745
|
),
|
|
15709
15746
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
@@ -15715,10 +15752,13 @@ var Table = (0, import_react6.forwardRef)((originalProps, ref) => {
|
|
|
15715
15752
|
size: originalProps.size,
|
|
15716
15753
|
color: originalProps.color === "neutral" ? "primary" : originalProps.color,
|
|
15717
15754
|
isSelected: originalProps.isSelected,
|
|
15755
|
+
isSelectedRow: originalProps.isSelectedRow,
|
|
15718
15756
|
isExpanded: originalProps.isExpanded,
|
|
15719
15757
|
isLoading,
|
|
15720
15758
|
classNames,
|
|
15721
15759
|
emptyContent,
|
|
15760
|
+
selectedRows,
|
|
15761
|
+
onSelectRow: handleSelectRow,
|
|
15722
15762
|
onRowAction
|
|
15723
15763
|
}
|
|
15724
15764
|
)
|
|
@@ -15820,6 +15860,9 @@ var table = (0, import_tailwind_variants3.tv)({
|
|
|
15820
15860
|
isSelected: {
|
|
15821
15861
|
true: {}
|
|
15822
15862
|
},
|
|
15863
|
+
isSelectedRow: {
|
|
15864
|
+
true: {}
|
|
15865
|
+
},
|
|
15823
15866
|
hideHeader: {
|
|
15824
15867
|
true: {
|
|
15825
15868
|
thead: "hidden"
|
|
@@ -15947,7 +15990,7 @@ describe("Table", () => {
|
|
|
15947
15990
|
expect(() => wrapper.unmount()).not.toThrow();
|
|
15948
15991
|
});
|
|
15949
15992
|
it("ref should be forwarded", () => {
|
|
15950
|
-
const ref =
|
|
15993
|
+
const ref = React4.createRef();
|
|
15951
15994
|
render(/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(table_default, { ref, rows, columns }));
|
|
15952
15995
|
expect(ref.current).not.toBeNull();
|
|
15953
15996
|
});
|
|
@@ -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";
|
package/dist/index.js
CHANGED
|
@@ -3726,7 +3726,17 @@ var checkbox = tv({
|
|
|
3726
3726
|
// src/components/table/table-head.tsx
|
|
3727
3727
|
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
3728
3728
|
var import_react8 = require("react");
|
|
3729
|
-
var TableHead = ({
|
|
3729
|
+
var TableHead = ({
|
|
3730
|
+
columns,
|
|
3731
|
+
slots,
|
|
3732
|
+
size,
|
|
3733
|
+
color,
|
|
3734
|
+
isExpanded,
|
|
3735
|
+
isSelected,
|
|
3736
|
+
isAllSelected,
|
|
3737
|
+
classNames,
|
|
3738
|
+
onSelectAll
|
|
3739
|
+
}) => {
|
|
3730
3740
|
const getTheadProps = (0, import_react7.useCallback)(
|
|
3731
3741
|
() => ({
|
|
3732
3742
|
className: slots.thead({ class: clsx(classNames == null ? void 0 : classNames.thead) })
|
|
@@ -3743,14 +3753,16 @@ var TableHead = ({ columns, slots, size, color, isSelected, isExpanded, classNam
|
|
|
3743
3753
|
({ className }) => ({
|
|
3744
3754
|
className: slots.th({ class: clsx(classNames == null ? void 0 : classNames.th, className) })
|
|
3745
3755
|
}),
|
|
3746
|
-
[classNames == null ? void 0 : classNames.th,
|
|
3756
|
+
[classNames == null ? void 0 : classNames.th, slots]
|
|
3747
3757
|
);
|
|
3758
|
+
const handleClickSelectAll = (e) => {
|
|
3759
|
+
e.preventDefault();
|
|
3760
|
+
onSelectAll(!isAllSelected);
|
|
3761
|
+
};
|
|
3748
3762
|
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("thead", { ...getTheadProps(), children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("tr", { ...getTrProps(), children: [
|
|
3749
|
-
isSelected && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("th", { className: "w-[40px]", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(checkbox_default, { size, color, classNames: { wrapper: "bg-background" } }) }),
|
|
3763
|
+
isSelected && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("th", { className: "w-[40px]", onClick: handleClickSelectAll, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(checkbox_default, { size, color, checked: isAllSelected, classNames: { wrapper: "bg-background" } }) }),
|
|
3750
3764
|
isExpanded && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("th", { className: "w-[40px]" }),
|
|
3751
|
-
columns.map((column, index) => {
|
|
3752
|
-
return /* @__PURE__ */ (0, import_react8.createElement)("th", { ...getThProps(column), key: column.field + index + "th" }, column.headerName);
|
|
3753
|
-
})
|
|
3765
|
+
columns.map((column, index) => /* @__PURE__ */ (0, import_react8.createElement)("th", { ...getThProps(column), key: column.field + index + "th" }, column.headerName))
|
|
3754
3766
|
] }) });
|
|
3755
3767
|
};
|
|
3756
3768
|
var table_head_default = TableHead;
|
|
@@ -3766,12 +3778,15 @@ var TableBody = ({
|
|
|
3766
3778
|
slots,
|
|
3767
3779
|
rows,
|
|
3768
3780
|
columns,
|
|
3769
|
-
isSelected,
|
|
3770
3781
|
isExpanded,
|
|
3782
|
+
isSelected,
|
|
3783
|
+
isSelectedRow,
|
|
3784
|
+
selectedRows,
|
|
3771
3785
|
emptyContent,
|
|
3786
|
+
onSelectRow,
|
|
3772
3787
|
onRowAction
|
|
3773
3788
|
}) => {
|
|
3774
|
-
const
|
|
3789
|
+
const COL_SPAN_COUNT = columns.length + (isExpanded ? 1 : 0) + (isSelected ? 1 : 0);
|
|
3775
3790
|
const [expandedRows, setExpandedRows] = (0, import_react9.useState)(/* @__PURE__ */ new Set());
|
|
3776
3791
|
(0, import_react9.useEffect)(() => {
|
|
3777
3792
|
setExpandedRows(/* @__PURE__ */ new Set());
|
|
@@ -3823,20 +3838,22 @@ var TableBody = ({
|
|
|
3823
3838
|
},
|
|
3824
3839
|
[classNames == null ? void 0 : classNames.td, columns, slots]
|
|
3825
3840
|
);
|
|
3841
|
+
const onChangeExpandedRow = (index) => {
|
|
3842
|
+
setExpandedRows((prevIndices) => {
|
|
3843
|
+
const newIndices = new Set(prevIndices);
|
|
3844
|
+
if (newIndices.has(index)) {
|
|
3845
|
+
newIndices.delete(index);
|
|
3846
|
+
} else {
|
|
3847
|
+
newIndices.add(index);
|
|
3848
|
+
}
|
|
3849
|
+
return newIndices;
|
|
3850
|
+
});
|
|
3851
|
+
};
|
|
3826
3852
|
const handleRowClick = (index) => (e) => {
|
|
3827
|
-
|
|
3828
|
-
|
|
3829
|
-
if (isExpanded)
|
|
3830
|
-
|
|
3831
|
-
const newIndices = new Set(prevIndices);
|
|
3832
|
-
if (newIndices.has(index)) {
|
|
3833
|
-
newIndices.delete(index);
|
|
3834
|
-
} else {
|
|
3835
|
-
newIndices.add(index);
|
|
3836
|
-
}
|
|
3837
|
-
return newIndices;
|
|
3838
|
-
});
|
|
3839
|
-
}
|
|
3853
|
+
e.stopPropagation();
|
|
3854
|
+
e.preventDefault();
|
|
3855
|
+
if (isExpanded) onChangeExpandedRow(index);
|
|
3856
|
+
if (isSelected && isSelectedRow) onSelectRow(index);
|
|
3840
3857
|
const row = rows[index];
|
|
3841
3858
|
if (row !== void 0) {
|
|
3842
3859
|
onRowAction == null ? void 0 : onRowAction(e, row);
|
|
@@ -3846,7 +3863,7 @@ var TableBody = ({
|
|
|
3846
3863
|
const keys = Object.keys(row);
|
|
3847
3864
|
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_react9.default.Fragment, { children: [
|
|
3848
3865
|
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("tr", { ...getTrProps(rowIndex), onClick: handleRowClick(rowIndex), children: [
|
|
3849
|
-
isSelected && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("td", { ...getTdProps({ field: "checkbox" }, row, keys), children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(checkbox_default, { color, size }) }),
|
|
3866
|
+
isSelected && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("td", { ...getTdProps({ field: "checkbox" }, row, keys), onClick: () => onSelectRow(rowIndex), children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(checkbox_default, { color, size, checked: selectedRows.has(rowIndex) }) }),
|
|
3850
3867
|
isExpanded && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("td", { ...getTdProps({ field: "expandIcon" }, row, keys), children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
3851
3868
|
Icon_default,
|
|
3852
3869
|
{
|
|
@@ -3857,9 +3874,9 @@ var TableBody = ({
|
|
|
3857
3874
|
) }),
|
|
3858
3875
|
columns.map((column, colIndex) => /* @__PURE__ */ (0, import_react10.createElement)("td", { ...getTdProps(column, row, keys), key: colIndex }))
|
|
3859
3876
|
] }),
|
|
3860
|
-
isExpanded && expandedRows.has(rowIndex) && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("tr", { ...getExpandedContentProps(), children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("td", { colSpan:
|
|
3877
|
+
isExpanded && expandedRows.has(rowIndex) && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("tr", { ...getExpandedContentProps(), children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("td", { colSpan: COL_SPAN_COUNT, ...getTdProps({ field: "expandedRow" }, row, keys), children: row.renderExpandedRow && row.renderExpandedRow() }) })
|
|
3861
3878
|
] }, rowIndex);
|
|
3862
|
-
}) : /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("tr", { ...getTrProps(-1), children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("td", { colSpan:
|
|
3879
|
+
}) : /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("tr", { ...getTrProps(-1), children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("td", { colSpan: COL_SPAN_COUNT, children: emptyContent }) }) });
|
|
3863
3880
|
};
|
|
3864
3881
|
var table_body_default = TableBody;
|
|
3865
3882
|
|
|
@@ -3869,6 +3886,7 @@ var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
|
3869
3886
|
var Table = (0, import_react11.forwardRef)((originalProps, ref) => {
|
|
3870
3887
|
const [props, variantProps] = mapPropsVariants(originalProps, table.variantKeys);
|
|
3871
3888
|
const { classNames, rows, columns, isLoading, className, emptyContent, onRowAction, ...tableComponentsProps } = props;
|
|
3889
|
+
const [selectedRows, setSelectedRows] = (0, import_react11.useState)(/* @__PURE__ */ new Set());
|
|
3872
3890
|
const slots = (0, import_react11.useMemo)(() => table({ ...variantProps }), [...Object.values(variantProps)]);
|
|
3873
3891
|
const getBaseProps = (0, import_react11.useCallback)(
|
|
3874
3892
|
(props2) => ({
|
|
@@ -3884,6 +3902,23 @@ var Table = (0, import_react11.forwardRef)((originalProps, ref) => {
|
|
|
3884
3902
|
}),
|
|
3885
3903
|
[classNames == null ? void 0 : classNames.table, slots]
|
|
3886
3904
|
);
|
|
3905
|
+
const handleSelectAll = (isSelected) => {
|
|
3906
|
+
const newSelectedRows = isSelected ? new Set(rows.map((_, index) => index)) : /* @__PURE__ */ new Set();
|
|
3907
|
+
setSelectedRows(newSelectedRows);
|
|
3908
|
+
};
|
|
3909
|
+
const handleSelectRow = (index) => {
|
|
3910
|
+
const newSelectedRows = new Set(selectedRows);
|
|
3911
|
+
if (newSelectedRows.has(index)) {
|
|
3912
|
+
newSelectedRows.delete(index);
|
|
3913
|
+
} else {
|
|
3914
|
+
newSelectedRows.add(index);
|
|
3915
|
+
}
|
|
3916
|
+
setSelectedRows(newSelectedRows);
|
|
3917
|
+
};
|
|
3918
|
+
(0, import_react11.useImperativeHandle)(ref, () => ({
|
|
3919
|
+
selectedRows,
|
|
3920
|
+
setSelectedRows
|
|
3921
|
+
}));
|
|
3887
3922
|
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { ref, "data-table": "base", ...getBaseProps(), children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("table", { ...getTableProps(tableComponentsProps), children: [
|
|
3888
3923
|
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
3889
3924
|
table_head_default,
|
|
@@ -3894,7 +3929,9 @@ var Table = (0, import_react11.forwardRef)((originalProps, ref) => {
|
|
|
3894
3929
|
size: originalProps.size,
|
|
3895
3930
|
color: originalProps.color === "neutral" ? "primary" : originalProps.color,
|
|
3896
3931
|
isSelected: originalProps.isSelected,
|
|
3897
|
-
isExpanded: originalProps.isExpanded
|
|
3932
|
+
isExpanded: originalProps.isExpanded,
|
|
3933
|
+
onSelectAll: handleSelectAll,
|
|
3934
|
+
isAllSelected: selectedRows.size === rows.length
|
|
3898
3935
|
}
|
|
3899
3936
|
),
|
|
3900
3937
|
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
@@ -3906,10 +3943,13 @@ var Table = (0, import_react11.forwardRef)((originalProps, ref) => {
|
|
|
3906
3943
|
size: originalProps.size,
|
|
3907
3944
|
color: originalProps.color === "neutral" ? "primary" : originalProps.color,
|
|
3908
3945
|
isSelected: originalProps.isSelected,
|
|
3946
|
+
isSelectedRow: originalProps.isSelectedRow,
|
|
3909
3947
|
isExpanded: originalProps.isExpanded,
|
|
3910
3948
|
isLoading,
|
|
3911
3949
|
classNames,
|
|
3912
3950
|
emptyContent,
|
|
3951
|
+
selectedRows,
|
|
3952
|
+
onSelectRow: handleSelectRow,
|
|
3913
3953
|
onRowAction
|
|
3914
3954
|
}
|
|
3915
3955
|
)
|
|
@@ -4011,6 +4051,9 @@ var table = (0, import_tailwind_variants8.tv)({
|
|
|
4011
4051
|
isSelected: {
|
|
4012
4052
|
true: {}
|
|
4013
4053
|
},
|
|
4054
|
+
isSelectedRow: {
|
|
4055
|
+
true: {}
|
|
4056
|
+
},
|
|
4014
4057
|
hideHeader: {
|
|
4015
4058
|
true: {
|
|
4016
4059
|
thead: "hidden"
|
package/dist/index.mjs
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import "./chunk-
|
|
2
|
+
import "./chunk-RRAZM5D3.mjs";
|
|
3
3
|
import {
|
|
4
|
-
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-DSBSLSJW.mjs";
|
|
7
|
-
import "./chunk-ODMRJXLJ.mjs";
|
|
4
|
+
textarea_default
|
|
5
|
+
} from "./chunk-WOX3SLJB.mjs";
|
|
8
6
|
import "./chunk-3MY6LO7N.mjs";
|
|
9
7
|
import {
|
|
10
8
|
tabs_default
|
|
11
9
|
} from "./chunk-KRI5IALM.mjs";
|
|
12
|
-
import "./chunk-
|
|
10
|
+
import "./chunk-HIE2YRGA.mjs";
|
|
13
11
|
import {
|
|
14
|
-
|
|
15
|
-
} from "./chunk-
|
|
12
|
+
tooltip_default
|
|
13
|
+
} from "./chunk-P6AZMYVR.mjs";
|
|
14
|
+
import "./chunk-DSBSLSJW.mjs";
|
|
15
|
+
import "./chunk-ODMRJXLJ.mjs";
|
|
16
16
|
import "./chunk-MV2WCFK7.mjs";
|
|
17
17
|
import {
|
|
18
18
|
slider_default
|
|
@@ -24,9 +24,9 @@ import {
|
|
|
24
24
|
import "./chunk-2UUH2MBF.mjs";
|
|
25
25
|
import {
|
|
26
26
|
table_default
|
|
27
|
-
} from "./chunk-
|
|
28
|
-
import "./chunk-
|
|
29
|
-
import "./chunk-
|
|
27
|
+
} from "./chunk-6U736HAX.mjs";
|
|
28
|
+
import "./chunk-PUFNT5LS.mjs";
|
|
29
|
+
import "./chunk-BHSCW5D6.mjs";
|
|
30
30
|
import "./chunk-TPFN22HR.mjs";
|
|
31
31
|
import {
|
|
32
32
|
radio_default
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deepnoid/ui",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.83",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"build:fast": "tsup src",
|
|
14
14
|
"clean": "rm -rf .turbo",
|
|
15
15
|
"lint": "TIMING=1 eslint \"**/*.{ts,tsx,js,jsx}\" --fix",
|
|
16
|
-
"publish": "npm version patch --no-git-tag-version && npm publish --access=public",
|
|
16
|
+
"publish:npm": "npm version patch --no-git-tag-version && npm publish --access=public",
|
|
17
17
|
"test": "jest"
|
|
18
18
|
},
|
|
19
19
|
"jest": {
|