@bwp-web/components 0.13.0 → 0.13.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/BiampTable/BiampTable.d.ts.map +1 -1
- package/dist/BiampTable/useBiampServerSideTable.d.ts +8 -2
- package/dist/BiampTable/useBiampServerSideTable.d.ts.map +1 -1
- package/dist/index.cjs +170 -122
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +170 -132
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -467,7 +467,6 @@ function BiampLayout({
|
|
|
467
467
|
import {
|
|
468
468
|
Box as Box4,
|
|
469
469
|
Checkbox,
|
|
470
|
-
IconButton,
|
|
471
470
|
Table as MuiTable,
|
|
472
471
|
TableBody,
|
|
473
472
|
TableCell,
|
|
@@ -482,7 +481,7 @@ import {
|
|
|
482
481
|
DropdownChevronUpIcon
|
|
483
482
|
} from "@bwp-web/assets";
|
|
484
483
|
import { flexRender } from "@tanstack/react-table";
|
|
485
|
-
import { useRef as useRef3 } from "react";
|
|
484
|
+
import React2, { useRef as useRef3 } from "react";
|
|
486
485
|
|
|
487
486
|
// src/BiampTable/BiampTableEmptyState.tsx
|
|
488
487
|
import { NoResultsIcon } from "@bwp-web/assets";
|
|
@@ -648,6 +647,133 @@ function cellSx(sticky, minWidth, zIndex) {
|
|
|
648
647
|
const mw = minWidth ?? 40;
|
|
649
648
|
return { minWidth: mw, maxWidth: mw };
|
|
650
649
|
}
|
|
650
|
+
function BiampTableRowInner({
|
|
651
|
+
row,
|
|
652
|
+
onRowClick,
|
|
653
|
+
isRowClickable,
|
|
654
|
+
enableRowSelection,
|
|
655
|
+
enableExpanding,
|
|
656
|
+
selectChildrenWithParent,
|
|
657
|
+
getRowLabel,
|
|
658
|
+
hasExpandableRows
|
|
659
|
+
}) {
|
|
660
|
+
const clickable = onRowClick ? isRowClickable ? isRowClickable(row.original) : true : false;
|
|
661
|
+
return /* @__PURE__ */ jsxs5(
|
|
662
|
+
TableRow,
|
|
663
|
+
{
|
|
664
|
+
hover: clickable,
|
|
665
|
+
selected: enableRowSelection ? row.getIsSelected() : void 0,
|
|
666
|
+
role: clickable ? "button" : void 0,
|
|
667
|
+
tabIndex: clickable ? 0 : void 0,
|
|
668
|
+
sx: { cursor: clickable ? "pointer" : void 0 },
|
|
669
|
+
onClick: clickable && onRowClick ? () => onRowClick(row.original) : void 0,
|
|
670
|
+
onKeyDown: clickable && onRowClick ? (e) => {
|
|
671
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
672
|
+
e.preventDefault();
|
|
673
|
+
onRowClick(row.original);
|
|
674
|
+
}
|
|
675
|
+
} : void 0,
|
|
676
|
+
children: [
|
|
677
|
+
enableRowSelection && /* @__PURE__ */ jsx8(
|
|
678
|
+
TableCell,
|
|
679
|
+
{
|
|
680
|
+
padding: "checkbox",
|
|
681
|
+
sx: {
|
|
682
|
+
position: "sticky",
|
|
683
|
+
left: 0,
|
|
684
|
+
zIndex: 2,
|
|
685
|
+
bgcolor: "background.paper",
|
|
686
|
+
".MuiTableRow-hover:hover > &, .Mui-selected > &": {
|
|
687
|
+
bgcolor: ({ palette }) => palette.mode === "dark" ? palette.grey[800] : palette.grey[100]
|
|
688
|
+
}
|
|
689
|
+
},
|
|
690
|
+
children: /* @__PURE__ */ jsx8(
|
|
691
|
+
Checkbox,
|
|
692
|
+
{
|
|
693
|
+
checked: row.getIsSelected(),
|
|
694
|
+
disabled: !row.getCanSelect(),
|
|
695
|
+
onChange: (e) => row.toggleSelected(e.target.checked, {
|
|
696
|
+
selectChildren: selectChildrenWithParent
|
|
697
|
+
}),
|
|
698
|
+
onClick: (e) => e.stopPropagation(),
|
|
699
|
+
sx: !row.getCanSelect() ? { visibility: "hidden" } : void 0,
|
|
700
|
+
slotProps: {
|
|
701
|
+
input: {
|
|
702
|
+
"aria-label": getRowLabel ? `Select ${getRowLabel(row.original)}` : `Select row ${row.index + 1}`
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
)
|
|
707
|
+
}
|
|
708
|
+
),
|
|
709
|
+
row.getVisibleCells().map((cell, cellIndex, cells) => {
|
|
710
|
+
const sticky = cell.column.columnDef.meta?.sticky;
|
|
711
|
+
const isExpandCell = enableExpanding && !sticky && cellIndex === cells.findIndex((c) => !c.column.columnDef.meta?.sticky);
|
|
712
|
+
return /* @__PURE__ */ jsx8(
|
|
713
|
+
TableCell,
|
|
714
|
+
{
|
|
715
|
+
"data-sticky": sticky || void 0,
|
|
716
|
+
sx: cellSx(sticky, cell.column.columnDef.meta?.minWidth, 2),
|
|
717
|
+
children: (() => {
|
|
718
|
+
const content = flexRender(
|
|
719
|
+
cell.column.columnDef.cell,
|
|
720
|
+
cell.getContext()
|
|
721
|
+
);
|
|
722
|
+
if (sticky) return content;
|
|
723
|
+
const truncated = /* @__PURE__ */ jsx8(BiampTableTruncatedCell, { children: content });
|
|
724
|
+
if (!isExpandCell) return truncated;
|
|
725
|
+
const rowLabel = getRowLabel ? getRowLabel(row.original) : `row ${row.index + 1}`;
|
|
726
|
+
return /* @__PURE__ */ jsxs5(
|
|
727
|
+
Box4,
|
|
728
|
+
{
|
|
729
|
+
sx: {
|
|
730
|
+
display: "flex",
|
|
731
|
+
alignItems: "center",
|
|
732
|
+
pl: `${row.depth * 12}px`,
|
|
733
|
+
gap: 1
|
|
734
|
+
},
|
|
735
|
+
children: [
|
|
736
|
+
row.getCanExpand() ? /* @__PURE__ */ jsx8(
|
|
737
|
+
ChevronRightIcon,
|
|
738
|
+
{
|
|
739
|
+
onClick: (e) => {
|
|
740
|
+
e.stopPropagation();
|
|
741
|
+
row.toggleExpanded();
|
|
742
|
+
},
|
|
743
|
+
"aria-label": row.getIsExpanded() ? `Collapse ${rowLabel}` : `Expand ${rowLabel}`,
|
|
744
|
+
"aria-expanded": row.getIsExpanded(),
|
|
745
|
+
variant: "xs",
|
|
746
|
+
sx: {
|
|
747
|
+
color: ({ palette }) => palette.text.secondary,
|
|
748
|
+
transition: "transform 150ms ease",
|
|
749
|
+
transform: row.getIsExpanded() ? "rotate(90deg)" : "rotate(0deg)",
|
|
750
|
+
width: 16,
|
|
751
|
+
height: 16,
|
|
752
|
+
cursor: "pointer"
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
) : hasExpandableRows ? /* @__PURE__ */ jsx8(Box4, { sx: { width: 16 } }) : null,
|
|
756
|
+
truncated
|
|
757
|
+
]
|
|
758
|
+
}
|
|
759
|
+
);
|
|
760
|
+
})()
|
|
761
|
+
},
|
|
762
|
+
cell.id
|
|
763
|
+
);
|
|
764
|
+
})
|
|
765
|
+
]
|
|
766
|
+
},
|
|
767
|
+
row.id
|
|
768
|
+
);
|
|
769
|
+
}
|
|
770
|
+
function biampTableRowPropsAreEqual(prev, next) {
|
|
771
|
+
return prev.row.id === next.row.id && prev.row.original === next.row.original && prev.row.getIsSelected() === next.row.getIsSelected() && prev.row.getIsExpanded() === next.row.getIsExpanded() && prev.row.getVisibleCells().length === next.row.getVisibleCells().length && prev.enableRowSelection === next.enableRowSelection && prev.enableExpanding === next.enableExpanding && prev.hasExpandableRows === next.hasExpandableRows && prev.selectChildrenWithParent === next.selectChildrenWithParent && prev.onRowClick === next.onRowClick && prev.isRowClickable === next.isRowClickable && prev.getRowLabel === next.getRowLabel;
|
|
772
|
+
}
|
|
773
|
+
var BiampTableRow = React2.memo(
|
|
774
|
+
BiampTableRowInner,
|
|
775
|
+
biampTableRowPropsAreEqual
|
|
776
|
+
);
|
|
651
777
|
function BiampTable({
|
|
652
778
|
table,
|
|
653
779
|
onRowClick,
|
|
@@ -759,125 +885,20 @@ function BiampTable({
|
|
|
759
885
|
);
|
|
760
886
|
})
|
|
761
887
|
] }, headerGroup.id)) }),
|
|
762
|
-
/* @__PURE__ */ jsx8(TableBody, { sx: { opacity: showLoading ? 0.3 : 1 }, children: !showError && rows.map((row) =>
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
onRowClick(row.original);
|
|
777
|
-
}
|
|
778
|
-
} : void 0,
|
|
779
|
-
children: [
|
|
780
|
-
enableRowSelection && /* @__PURE__ */ jsx8(
|
|
781
|
-
TableCell,
|
|
782
|
-
{
|
|
783
|
-
padding: "checkbox",
|
|
784
|
-
sx: {
|
|
785
|
-
position: "sticky",
|
|
786
|
-
left: 0,
|
|
787
|
-
zIndex: 2,
|
|
788
|
-
bgcolor: "background.paper",
|
|
789
|
-
".MuiTableRow-hover:hover > &, .Mui-selected > &": {
|
|
790
|
-
bgcolor: ({ palette }) => palette.mode === "dark" ? palette.grey[800] : palette.grey[100]
|
|
791
|
-
}
|
|
792
|
-
},
|
|
793
|
-
children: /* @__PURE__ */ jsx8(
|
|
794
|
-
Checkbox,
|
|
795
|
-
{
|
|
796
|
-
checked: row.getIsSelected(),
|
|
797
|
-
disabled: !row.getCanSelect(),
|
|
798
|
-
onChange: (e) => row.toggleSelected(e.target.checked, {
|
|
799
|
-
selectChildren: selectChildrenWithParent
|
|
800
|
-
}),
|
|
801
|
-
onClick: (e) => e.stopPropagation(),
|
|
802
|
-
sx: !row.getCanSelect() ? { visibility: "hidden" } : void 0,
|
|
803
|
-
slotProps: {
|
|
804
|
-
input: {
|
|
805
|
-
"aria-label": getRowLabel ? `Select ${getRowLabel(row.original)}` : `Select row ${row.index + 1}`
|
|
806
|
-
}
|
|
807
|
-
}
|
|
808
|
-
}
|
|
809
|
-
)
|
|
810
|
-
}
|
|
811
|
-
),
|
|
812
|
-
row.getVisibleCells().map((cell, cellIndex, cells) => {
|
|
813
|
-
const sticky = cell.column.columnDef.meta?.sticky;
|
|
814
|
-
const isExpandCell = enableExpanding && !sticky && cellIndex === cells.findIndex(
|
|
815
|
-
(c) => !c.column.columnDef.meta?.sticky
|
|
816
|
-
);
|
|
817
|
-
return /* @__PURE__ */ jsx8(
|
|
818
|
-
TableCell,
|
|
819
|
-
{
|
|
820
|
-
"data-sticky": sticky || void 0,
|
|
821
|
-
sx: cellSx(
|
|
822
|
-
sticky,
|
|
823
|
-
cell.column.columnDef.meta?.minWidth,
|
|
824
|
-
2
|
|
825
|
-
),
|
|
826
|
-
children: (() => {
|
|
827
|
-
const content = flexRender(
|
|
828
|
-
cell.column.columnDef.cell,
|
|
829
|
-
cell.getContext()
|
|
830
|
-
);
|
|
831
|
-
if (sticky) return content;
|
|
832
|
-
const truncated = /* @__PURE__ */ jsx8(BiampTableTruncatedCell, { children: content });
|
|
833
|
-
if (!isExpandCell) return truncated;
|
|
834
|
-
const rowLabel = getRowLabel ? getRowLabel(row.original) : `row ${row.index + 1}`;
|
|
835
|
-
return /* @__PURE__ */ jsxs5(
|
|
836
|
-
Box4,
|
|
837
|
-
{
|
|
838
|
-
sx: {
|
|
839
|
-
display: "flex",
|
|
840
|
-
alignItems: "center",
|
|
841
|
-
pl: `${row.depth * 12}px`
|
|
842
|
-
},
|
|
843
|
-
children: [
|
|
844
|
-
row.getCanExpand() ? /* @__PURE__ */ jsx8(
|
|
845
|
-
IconButton,
|
|
846
|
-
{
|
|
847
|
-
variant: "none",
|
|
848
|
-
onClick: (e) => {
|
|
849
|
-
e.stopPropagation();
|
|
850
|
-
row.toggleExpanded();
|
|
851
|
-
},
|
|
852
|
-
"aria-label": row.getIsExpanded() ? `Collapse ${rowLabel}` : `Expand ${rowLabel}`,
|
|
853
|
-
"aria-expanded": row.getIsExpanded(),
|
|
854
|
-
children: /* @__PURE__ */ jsx8(
|
|
855
|
-
ChevronRightIcon,
|
|
856
|
-
{
|
|
857
|
-
variant: "xs",
|
|
858
|
-
sx: {
|
|
859
|
-
color: ({ palette }) => palette.text.secondary,
|
|
860
|
-
transition: "transform 150ms ease",
|
|
861
|
-
transform: row.getIsExpanded() ? "rotate(90deg)" : "rotate(0deg)"
|
|
862
|
-
}
|
|
863
|
-
}
|
|
864
|
-
)
|
|
865
|
-
}
|
|
866
|
-
) : hasExpandableRows ? /* @__PURE__ */ jsx8(Box4, { sx: { width: 28 } }) : null,
|
|
867
|
-
truncated
|
|
868
|
-
]
|
|
869
|
-
}
|
|
870
|
-
);
|
|
871
|
-
})()
|
|
872
|
-
},
|
|
873
|
-
cell.id
|
|
874
|
-
);
|
|
875
|
-
})
|
|
876
|
-
]
|
|
877
|
-
},
|
|
878
|
-
row.id
|
|
879
|
-
);
|
|
880
|
-
}) })
|
|
888
|
+
/* @__PURE__ */ jsx8(TableBody, { sx: { opacity: showLoading ? 0.3 : 1 }, children: !showError && rows.map((row) => /* @__PURE__ */ jsx8(
|
|
889
|
+
BiampTableRow,
|
|
890
|
+
{
|
|
891
|
+
row,
|
|
892
|
+
onRowClick,
|
|
893
|
+
isRowClickable,
|
|
894
|
+
enableRowSelection,
|
|
895
|
+
enableExpanding,
|
|
896
|
+
selectChildrenWithParent,
|
|
897
|
+
getRowLabel,
|
|
898
|
+
hasExpandableRows
|
|
899
|
+
},
|
|
900
|
+
row.id
|
|
901
|
+
)) })
|
|
881
902
|
]
|
|
882
903
|
}
|
|
883
904
|
),
|
|
@@ -923,7 +944,7 @@ function BiampTableContainer({
|
|
|
923
944
|
}
|
|
924
945
|
|
|
925
946
|
// src/BiampTable/BiampTableCellActionButton.tsx
|
|
926
|
-
import { IconButton
|
|
947
|
+
import { IconButton, Tooltip as Tooltip2 } from "@mui/material";
|
|
927
948
|
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
928
949
|
function BiampTableCellActionButton({ label, icon, ...props }) {
|
|
929
950
|
return /* @__PURE__ */ jsx10(
|
|
@@ -934,7 +955,7 @@ function BiampTableCellActionButton({ label, icon, ...props }) {
|
|
|
934
955
|
enterDelay: 500,
|
|
935
956
|
enterNextDelay: 500,
|
|
936
957
|
disableInteractive: true,
|
|
937
|
-
children: /* @__PURE__ */ jsx10("span", { children: /* @__PURE__ */ jsx10(
|
|
958
|
+
children: /* @__PURE__ */ jsx10("span", { children: /* @__PURE__ */ jsx10(IconButton, { "aria-label": label, ...props, children: icon }) })
|
|
938
959
|
}
|
|
939
960
|
);
|
|
940
961
|
}
|
|
@@ -1077,7 +1098,7 @@ import { useState as useState3 } from "react";
|
|
|
1077
1098
|
// src/BiampTable/BiampTableToolbarActionButton.tsx
|
|
1078
1099
|
import {
|
|
1079
1100
|
Badge,
|
|
1080
|
-
IconButton as
|
|
1101
|
+
IconButton as IconButton2
|
|
1081
1102
|
} from "@mui/material";
|
|
1082
1103
|
import { jsx as jsx12 } from "react/jsx-runtime";
|
|
1083
1104
|
function BiampTableToolbarActionButton({
|
|
@@ -1088,7 +1109,7 @@ function BiampTableToolbarActionButton({
|
|
|
1088
1109
|
}) {
|
|
1089
1110
|
const showBadge = badgeContent != null && badgeContent !== 0;
|
|
1090
1111
|
return /* @__PURE__ */ jsx12(
|
|
1091
|
-
|
|
1112
|
+
IconButton2,
|
|
1092
1113
|
{
|
|
1093
1114
|
"aria-label": showBadge ? `${label} (${badgeContent})` : label,
|
|
1094
1115
|
...props,
|
|
@@ -1291,7 +1312,7 @@ import {
|
|
|
1291
1312
|
Button,
|
|
1292
1313
|
Divider as Divider2,
|
|
1293
1314
|
Drawer,
|
|
1294
|
-
IconButton as
|
|
1315
|
+
IconButton as IconButton3,
|
|
1295
1316
|
Typography as Typography4
|
|
1296
1317
|
} from "@mui/material";
|
|
1297
1318
|
import { CloseIcon, FilterIcon } from "@bwp-web/assets";
|
|
@@ -1368,7 +1389,7 @@ function BiampTableToolbarFilters({
|
|
|
1368
1389
|
)
|
|
1369
1390
|
] }),
|
|
1370
1391
|
/* @__PURE__ */ jsx18(
|
|
1371
|
-
|
|
1392
|
+
IconButton3,
|
|
1372
1393
|
{
|
|
1373
1394
|
size: "medium",
|
|
1374
1395
|
onClick: handleClose,
|
|
@@ -1429,7 +1450,7 @@ function BiampTableToolbarFilters({
|
|
|
1429
1450
|
import {
|
|
1430
1451
|
Box as Box9,
|
|
1431
1452
|
Collapse,
|
|
1432
|
-
IconButton as
|
|
1453
|
+
IconButton as IconButton4,
|
|
1433
1454
|
InputAdornment as InputAdornment2,
|
|
1434
1455
|
InputBase,
|
|
1435
1456
|
TextField as TextField2,
|
|
@@ -1508,7 +1529,7 @@ function BiampTableToolbarSearch({
|
|
|
1508
1529
|
}
|
|
1509
1530
|
};
|
|
1510
1531
|
const clearButton = inputValue ? /* @__PURE__ */ jsx19(InputAdornment2, { position: "end", children: /* @__PURE__ */ jsx19(
|
|
1511
|
-
|
|
1532
|
+
IconButton4,
|
|
1512
1533
|
{
|
|
1513
1534
|
size: "small",
|
|
1514
1535
|
onClick: handleClear,
|
|
@@ -1578,7 +1599,7 @@ function BiampTableToolbarSearch({
|
|
|
1578
1599
|
if (expandable) {
|
|
1579
1600
|
return /* @__PURE__ */ jsxs9(Box9, { display: "flex", alignItems: "center", minWidth: 28, children: [
|
|
1580
1601
|
/* @__PURE__ */ jsx19(
|
|
1581
|
-
|
|
1602
|
+
IconButton4,
|
|
1582
1603
|
{
|
|
1583
1604
|
"aria-label": expandLabel ?? placeholder,
|
|
1584
1605
|
onClick: () => setIsExpanded(true),
|
|
@@ -1610,6 +1631,7 @@ function BiampTableToolbarSearch({
|
|
|
1610
1631
|
// src/BiampTable/useBiampServerSideTable.ts
|
|
1611
1632
|
import {
|
|
1612
1633
|
getCoreRowModel,
|
|
1634
|
+
getExpandedRowModel,
|
|
1613
1635
|
useReactTable
|
|
1614
1636
|
} from "@tanstack/react-table";
|
|
1615
1637
|
import { useMemo } from "react";
|
|
@@ -1669,6 +1691,7 @@ function getDirtyColumnVisibility(visibility, defaults) {
|
|
|
1669
1691
|
|
|
1670
1692
|
// src/BiampTable/useBiampServerSideTable.ts
|
|
1671
1693
|
var coreRowModel = getCoreRowModel();
|
|
1694
|
+
var expandedRowModel = getExpandedRowModel();
|
|
1672
1695
|
function useBiampServerSideTable({
|
|
1673
1696
|
data,
|
|
1674
1697
|
columns,
|
|
@@ -1683,7 +1706,10 @@ function useBiampServerSideTable({
|
|
|
1683
1706
|
onColumnVisibilityChange,
|
|
1684
1707
|
selectedRowIds,
|
|
1685
1708
|
onSelectedRowIdsChange,
|
|
1686
|
-
enableRowSelection
|
|
1709
|
+
enableRowSelection,
|
|
1710
|
+
expanded,
|
|
1711
|
+
onExpandedChange,
|
|
1712
|
+
getSubRows
|
|
1687
1713
|
}) {
|
|
1688
1714
|
const defaultColumnVisibility = useMemo(
|
|
1689
1715
|
() => getDefaultColumnVisibilityFromDefs(columns),
|
|
@@ -1726,7 +1752,8 @@ function useBiampServerSideTable({
|
|
|
1726
1752
|
sorting,
|
|
1727
1753
|
...pagination && { pagination },
|
|
1728
1754
|
columnVisibility: mergedVisibility,
|
|
1729
|
-
...rowSelection && { rowSelection }
|
|
1755
|
+
...rowSelection && { rowSelection },
|
|
1756
|
+
...expanded != null && { expanded }
|
|
1730
1757
|
},
|
|
1731
1758
|
onSortingChange: onOrderChange ? (updater) => {
|
|
1732
1759
|
const next = typeof updater === "function" ? updater(sorting) : updater;
|
|
@@ -1755,6 +1782,17 @@ function useBiampServerSideTable({
|
|
|
1755
1782
|
const next = typeof updater === "function" ? updater(rowSelection) : updater;
|
|
1756
1783
|
onSelectedRowIdsChange(rowSelectionToSelectedIds(next));
|
|
1757
1784
|
} : void 0
|
|
1785
|
+
},
|
|
1786
|
+
// Expanding — only when expanded state is provided
|
|
1787
|
+
...expanded != null && {
|
|
1788
|
+
// Only attach getExpandedRowModel when getSubRows is provided.
|
|
1789
|
+
// Without it, the expanded model recomputes on every state change
|
|
1790
|
+
// (including selection), adding unnecessary overhead.
|
|
1791
|
+
...getSubRows && { getExpandedRowModel: expandedRowModel, getSubRows },
|
|
1792
|
+
onExpandedChange: onExpandedChange ? (updater) => {
|
|
1793
|
+
const next = typeof updater === "function" ? updater(expanded) : updater;
|
|
1794
|
+
onExpandedChange(next);
|
|
1795
|
+
} : void 0
|
|
1758
1796
|
}
|
|
1759
1797
|
});
|
|
1760
1798
|
}
|