@bwp-web/components 0.13.2 → 0.13.4

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: { cursor: clickable ? "pointer" : void 0 },
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
- TableCell,
715
+ enableRowSelection && /* @__PURE__ */ jsx8(TableCell, { padding: "checkbox", sx: selectionCellSx, children: /* @__PURE__ */ jsx8(
716
+ Checkbox,
679
717
  {
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]
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);
@@ -720,18 +743,14 @@ function BiampTableRowInner({
720
743
  cell.getContext()
721
744
  );
722
745
  if (sticky) return content;
723
- const truncated = /* @__PURE__ */ jsx8(BiampTableTruncatedCell, { children: content });
746
+ const isText = typeof content === "string" || typeof content === "number" || typeof content === "bigint";
747
+ const truncated = isText ? /* @__PURE__ */ jsx8(BiampTableTruncatedCell, { children: content }) : content;
724
748
  if (!isExpandCell) return truncated;
725
749
  const rowLabel = getRowLabel ? getRowLabel(row.original) : `row ${row.index + 1}`;
726
750
  return /* @__PURE__ */ jsxs5(
727
751
  Box4,
728
752
  {
729
- sx: {
730
- display: "flex",
731
- alignItems: "center",
732
- pl: `${row.depth * 12}px`,
733
- gap: 1
734
- },
753
+ sx: row.depth > 0 ? { ...expandCellBaseSx, pl: `${row.depth * 12}px` } : expandCellBaseSx,
735
754
  children: [
736
755
  row.getCanExpand() ? /* @__PURE__ */ jsx8(
737
756
  ChevronRightIcon,
@@ -743,16 +762,9 @@ function BiampTableRowInner({
743
762
  "aria-label": row.getIsExpanded() ? `Collapse ${rowLabel}` : `Expand ${rowLabel}`,
744
763
  "aria-expanded": row.getIsExpanded(),
745
764
  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
- }
765
+ sx: row.getIsExpanded() ? chevronExpandedSx : chevronCollapsedSx
754
766
  }
755
- ) : hasExpandableRows ? /* @__PURE__ */ jsx8(Box4, { sx: { width: 16 } }) : null,
767
+ ) : hasExpandableRows ? /* @__PURE__ */ jsx8(Box4, { sx: expandPlaceholderSx }) : null,
756
768
  truncated
757
769
  ]
758
770
  }
@@ -825,28 +837,16 @@ function BiampTable({
825
837
  sx: { minWidth: tableMinWidth, tableLayout: "auto" },
826
838
  children: [
827
839
  /* @__PURE__ */ jsx8(TableHead, { children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ jsxs5(TableRow, { children: [
828
- enableRowSelection && /* @__PURE__ */ jsx8(
829
- TableCell,
840
+ enableRowSelection && /* @__PURE__ */ jsx8(TableCell, { padding: "checkbox", sx: headerSelectionCellSx, children: !hideSelectAll && /* @__PURE__ */ jsx8(
841
+ Checkbox,
830
842
  {
831
- padding: "checkbox",
832
- sx: {
833
- position: "sticky",
834
- left: 0,
835
- zIndex: 3,
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
- )
843
+ checked: table.getIsAllPageRowsSelected(),
844
+ indeterminate: table.getIsSomePageRowsSelected(),
845
+ onChange: table.getToggleAllPageRowsSelectedHandler(),
846
+ sx: rows.length === 0 ? checkboxHiddenHeaderSx : void 0,
847
+ slotProps: { input: { "aria-label": "Select all rows" } }
848
848
  }
849
- ),
849
+ ) }),
850
850
  headerGroup.headers.map((header) => {
851
851
  const sticky = header.column.columnDef.meta?.sticky;
852
852
  return /* @__PURE__ */ jsx8(
@@ -1692,10 +1692,11 @@ function getDirtyColumnVisibility(visibility, defaults) {
1692
1692
  // src/BiampTable/useBiampServerSideTable.ts
1693
1693
  var coreRowModel = getCoreRowModel();
1694
1694
  var expandedRowModel = getExpandedRowModel();
1695
+ var defaultGetRowId = (row) => row.id;
1695
1696
  function useBiampServerSideTable({
1696
1697
  data,
1697
1698
  columns,
1698
- getRowId = (row) => row.id,
1699
+ getRowId = defaultGetRowId,
1699
1700
  order,
1700
1701
  onOrderChange,
1701
1702
  page,
@@ -1711,12 +1712,11 @@ function useBiampServerSideTable({
1711
1712
  onExpandedChange,
1712
1713
  getSubRows
1713
1714
  }) {
1714
- const defaultColumnVisibility = useMemo(
1715
- () => getDefaultColumnVisibilityFromDefs(columns),
1716
- [columns]
1717
- );
1718
- const { columnIdToField, fieldToColumnId } = useMemo(
1719
- () => getOrderFieldMappings(columns),
1715
+ const { defaultColumnVisibility, columnIdToField, fieldToColumnId } = useMemo(
1716
+ () => ({
1717
+ defaultColumnVisibility: getDefaultColumnVisibilityFromDefs(columns),
1718
+ ...getOrderFieldMappings(columns)
1719
+ }),
1720
1720
  [columns]
1721
1721
  );
1722
1722
  const sorting = useMemo(