@bwp-web/components 0.13.2 → 0.13.3
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.js
CHANGED
|
@@ -647,6 +647,44 @@ function cellSx(sticky, minWidth, zIndex) {
|
|
|
647
647
|
const mw = minWidth ?? 40;
|
|
648
648
|
return { minWidth: mw, maxWidth: mw };
|
|
649
649
|
}
|
|
650
|
+
var rowCursorPointerSx = { cursor: "pointer" };
|
|
651
|
+
var selectionCellSx = {
|
|
652
|
+
position: "sticky",
|
|
653
|
+
left: 0,
|
|
654
|
+
zIndex: 2,
|
|
655
|
+
bgcolor: "background.paper",
|
|
656
|
+
...stickyHoverBg
|
|
657
|
+
};
|
|
658
|
+
var checkboxHiddenSx = { visibility: "hidden" };
|
|
659
|
+
var expandCellBaseSx = {
|
|
660
|
+
display: "flex",
|
|
661
|
+
alignItems: "center",
|
|
662
|
+
gap: 1
|
|
663
|
+
};
|
|
664
|
+
var chevronExpandedSx = {
|
|
665
|
+
color: ({ palette }) => palette.text.secondary,
|
|
666
|
+
transition: "transform 150ms ease",
|
|
667
|
+
transform: "rotate(90deg)",
|
|
668
|
+
width: 16,
|
|
669
|
+
height: 16,
|
|
670
|
+
cursor: "pointer"
|
|
671
|
+
};
|
|
672
|
+
var chevronCollapsedSx = {
|
|
673
|
+
color: ({ palette }) => palette.text.secondary,
|
|
674
|
+
transition: "transform 150ms ease",
|
|
675
|
+
transform: "rotate(0deg)",
|
|
676
|
+
width: 16,
|
|
677
|
+
height: 16,
|
|
678
|
+
cursor: "pointer"
|
|
679
|
+
};
|
|
680
|
+
var expandPlaceholderSx = { width: 16 };
|
|
681
|
+
var headerSelectionCellSx = {
|
|
682
|
+
position: "sticky",
|
|
683
|
+
left: 0,
|
|
684
|
+
zIndex: 3,
|
|
685
|
+
bgcolor: "background.paper"
|
|
686
|
+
};
|
|
687
|
+
var checkboxHiddenHeaderSx = { visibility: "hidden" };
|
|
650
688
|
function BiampTableRowInner({
|
|
651
689
|
row,
|
|
652
690
|
onRowClick,
|
|
@@ -665,7 +703,7 @@ function BiampTableRowInner({
|
|
|
665
703
|
selected: enableRowSelection ? row.getIsSelected() : void 0,
|
|
666
704
|
role: clickable ? "button" : void 0,
|
|
667
705
|
tabIndex: clickable ? 0 : void 0,
|
|
668
|
-
sx:
|
|
706
|
+
sx: clickable ? rowCursorPointerSx : void 0,
|
|
669
707
|
onClick: clickable && onRowClick ? () => onRowClick(row.original) : void 0,
|
|
670
708
|
onKeyDown: clickable && onRowClick ? (e) => {
|
|
671
709
|
if (e.key === "Enter" || e.key === " ") {
|
|
@@ -674,38 +712,23 @@ function BiampTableRowInner({
|
|
|
674
712
|
}
|
|
675
713
|
} : void 0,
|
|
676
714
|
children: [
|
|
677
|
-
enableRowSelection && /* @__PURE__ */ jsx8(
|
|
678
|
-
|
|
715
|
+
enableRowSelection && /* @__PURE__ */ jsx8(TableCell, { padding: "checkbox", sx: selectionCellSx, children: /* @__PURE__ */ jsx8(
|
|
716
|
+
Checkbox,
|
|
679
717
|
{
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
718
|
+
checked: row.getIsSelected(),
|
|
719
|
+
disabled: !row.getCanSelect(),
|
|
720
|
+
onChange: (e) => row.toggleSelected(e.target.checked, {
|
|
721
|
+
selectChildren: selectChildrenWithParent
|
|
722
|
+
}),
|
|
723
|
+
onClick: (e) => e.stopPropagation(),
|
|
724
|
+
sx: !row.getCanSelect() ? checkboxHiddenSx : void 0,
|
|
725
|
+
slotProps: {
|
|
726
|
+
input: {
|
|
727
|
+
"aria-label": getRowLabel ? `Select ${getRowLabel(row.original)}` : `Select row ${row.index + 1}`
|
|
688
728
|
}
|
|
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
|
-
)
|
|
729
|
+
}
|
|
707
730
|
}
|
|
708
|
-
),
|
|
731
|
+
) }),
|
|
709
732
|
row.getVisibleCells().map((cell, cellIndex, cells) => {
|
|
710
733
|
const sticky = cell.column.columnDef.meta?.sticky;
|
|
711
734
|
const isExpandCell = enableExpanding && !sticky && cellIndex === cells.findIndex((c) => !c.column.columnDef.meta?.sticky);
|
|
@@ -726,12 +749,7 @@ function BiampTableRowInner({
|
|
|
726
749
|
return /* @__PURE__ */ jsxs5(
|
|
727
750
|
Box4,
|
|
728
751
|
{
|
|
729
|
-
sx: {
|
|
730
|
-
display: "flex",
|
|
731
|
-
alignItems: "center",
|
|
732
|
-
pl: `${row.depth * 12}px`,
|
|
733
|
-
gap: 1
|
|
734
|
-
},
|
|
752
|
+
sx: row.depth > 0 ? { ...expandCellBaseSx, pl: `${row.depth * 12}px` } : expandCellBaseSx,
|
|
735
753
|
children: [
|
|
736
754
|
row.getCanExpand() ? /* @__PURE__ */ jsx8(
|
|
737
755
|
ChevronRightIcon,
|
|
@@ -743,16 +761,9 @@ function BiampTableRowInner({
|
|
|
743
761
|
"aria-label": row.getIsExpanded() ? `Collapse ${rowLabel}` : `Expand ${rowLabel}`,
|
|
744
762
|
"aria-expanded": row.getIsExpanded(),
|
|
745
763
|
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
|
-
}
|
|
764
|
+
sx: row.getIsExpanded() ? chevronExpandedSx : chevronCollapsedSx
|
|
754
765
|
}
|
|
755
|
-
) : hasExpandableRows ? /* @__PURE__ */ jsx8(Box4, { sx:
|
|
766
|
+
) : hasExpandableRows ? /* @__PURE__ */ jsx8(Box4, { sx: expandPlaceholderSx }) : null,
|
|
756
767
|
truncated
|
|
757
768
|
]
|
|
758
769
|
}
|
|
@@ -825,28 +836,16 @@ function BiampTable({
|
|
|
825
836
|
sx: { minWidth: tableMinWidth, tableLayout: "auto" },
|
|
826
837
|
children: [
|
|
827
838
|
/* @__PURE__ */ jsx8(TableHead, { children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ jsxs5(TableRow, { children: [
|
|
828
|
-
enableRowSelection && /* @__PURE__ */ jsx8(
|
|
829
|
-
|
|
839
|
+
enableRowSelection && /* @__PURE__ */ jsx8(TableCell, { padding: "checkbox", sx: headerSelectionCellSx, children: !hideSelectAll && /* @__PURE__ */ jsx8(
|
|
840
|
+
Checkbox,
|
|
830
841
|
{
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
bgcolor: "background.paper"
|
|
837
|
-
},
|
|
838
|
-
children: !hideSelectAll && /* @__PURE__ */ jsx8(
|
|
839
|
-
Checkbox,
|
|
840
|
-
{
|
|
841
|
-
checked: table.getIsAllPageRowsSelected(),
|
|
842
|
-
indeterminate: table.getIsSomePageRowsSelected(),
|
|
843
|
-
onChange: table.getToggleAllPageRowsSelectedHandler(),
|
|
844
|
-
sx: rows.length === 0 ? { visibility: "hidden" } : void 0,
|
|
845
|
-
slotProps: { input: { "aria-label": "Select all rows" } }
|
|
846
|
-
}
|
|
847
|
-
)
|
|
842
|
+
checked: table.getIsAllPageRowsSelected(),
|
|
843
|
+
indeterminate: table.getIsSomePageRowsSelected(),
|
|
844
|
+
onChange: table.getToggleAllPageRowsSelectedHandler(),
|
|
845
|
+
sx: rows.length === 0 ? checkboxHiddenHeaderSx : void 0,
|
|
846
|
+
slotProps: { input: { "aria-label": "Select all rows" } }
|
|
848
847
|
}
|
|
849
|
-
),
|
|
848
|
+
) }),
|
|
850
849
|
headerGroup.headers.map((header) => {
|
|
851
850
|
const sticky = header.column.columnDef.meta?.sticky;
|
|
852
851
|
return /* @__PURE__ */ jsx8(
|
|
@@ -1692,10 +1691,11 @@ function getDirtyColumnVisibility(visibility, defaults) {
|
|
|
1692
1691
|
// src/BiampTable/useBiampServerSideTable.ts
|
|
1693
1692
|
var coreRowModel = getCoreRowModel();
|
|
1694
1693
|
var expandedRowModel = getExpandedRowModel();
|
|
1694
|
+
var defaultGetRowId = (row) => row.id;
|
|
1695
1695
|
function useBiampServerSideTable({
|
|
1696
1696
|
data,
|
|
1697
1697
|
columns,
|
|
1698
|
-
getRowId =
|
|
1698
|
+
getRowId = defaultGetRowId,
|
|
1699
1699
|
order,
|
|
1700
1700
|
onOrderChange,
|
|
1701
1701
|
page,
|
|
@@ -1711,12 +1711,11 @@ function useBiampServerSideTable({
|
|
|
1711
1711
|
onExpandedChange,
|
|
1712
1712
|
getSubRows
|
|
1713
1713
|
}) {
|
|
1714
|
-
const defaultColumnVisibility = useMemo(
|
|
1715
|
-
() =>
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
() => getOrderFieldMappings(columns),
|
|
1714
|
+
const { defaultColumnVisibility, columnIdToField, fieldToColumnId } = useMemo(
|
|
1715
|
+
() => ({
|
|
1716
|
+
defaultColumnVisibility: getDefaultColumnVisibilityFromDefs(columns),
|
|
1717
|
+
...getOrderFieldMappings(columns)
|
|
1718
|
+
}),
|
|
1720
1719
|
[columns]
|
|
1721
1720
|
);
|
|
1722
1721
|
const sorting = useMemo(
|