@bwp-web/components 0.11.7 → 0.12.0

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
@@ -467,6 +467,7 @@ function BiampLayout({
467
467
  import {
468
468
  Box as Box3,
469
469
  Checkbox,
470
+ IconButton,
470
471
  Table as MuiTable,
471
472
  TableBody,
472
473
  TableCell,
@@ -476,6 +477,7 @@ import {
476
477
  TableSortLabel
477
478
  } from "@mui/material";
478
479
  import {
480
+ ChevronRightIcon,
479
481
  DropdownChevronDownIcon,
480
482
  DropdownChevronUpIcon
481
483
  } from "@bwp-web/assets";
@@ -577,6 +579,7 @@ function BiampTable({
577
579
  error,
578
580
  empty,
579
581
  enableRowSelection = false,
582
+ enableExpanding = false,
580
583
  hideSelectAll,
581
584
  getRowLabel,
582
585
  sx,
@@ -592,6 +595,7 @@ function BiampTable({
592
595
  const containerRef = useRef2(null);
593
596
  const showLoading = useLoadingDelay(!!loading);
594
597
  const rows = table.getRowModel().rows;
598
+ const hasExpandableRows = enableExpanding && rows.some((r) => r.getCanExpand());
595
599
  const showError = !!error && !loading;
596
600
  const showEmpty = !showError && !loading && rows.length === 0;
597
601
  return /* @__PURE__ */ jsxs5(
@@ -732,8 +736,11 @@ function BiampTable({
732
736
  )
733
737
  }
734
738
  ),
735
- row.getVisibleCells().map((cell) => {
739
+ row.getVisibleCells().map((cell, cellIndex, cells) => {
736
740
  const sticky = cell.column.columnDef.meta?.sticky;
741
+ const isExpandCell = enableExpanding && !sticky && cellIndex === cells.findIndex(
742
+ (c) => !c.column.columnDef.meta?.sticky
743
+ );
737
744
  return /* @__PURE__ */ jsx7(
738
745
  TableCell,
739
746
  {
@@ -753,7 +760,45 @@ function BiampTable({
753
760
  }
754
761
  }
755
762
  },
756
- children: flexRender(
763
+ children: isExpandCell ? /* @__PURE__ */ jsxs5(
764
+ Box3,
765
+ {
766
+ sx: {
767
+ display: "flex",
768
+ alignItems: "center",
769
+ pl: `${row.depth * 12}px`
770
+ },
771
+ children: [
772
+ row.getCanExpand() ? /* @__PURE__ */ jsx7(
773
+ IconButton,
774
+ {
775
+ variant: "none",
776
+ onClick: (e) => {
777
+ e.stopPropagation();
778
+ row.toggleExpanded();
779
+ },
780
+ "aria-label": row.getIsExpanded() ? `Collapse ${getRowLabel ? getRowLabel(row.original) : `row ${row.index + 1}`}` : `Expand ${getRowLabel ? getRowLabel(row.original) : `row ${row.index + 1}`}`,
781
+ "aria-expanded": row.getIsExpanded(),
782
+ children: /* @__PURE__ */ jsx7(
783
+ ChevronRightIcon,
784
+ {
785
+ variant: "xs",
786
+ sx: {
787
+ color: ({ palette }) => palette.text.secondary,
788
+ transition: "transform 150ms ease",
789
+ transform: row.getIsExpanded() ? "rotate(90deg)" : "rotate(0deg)"
790
+ }
791
+ }
792
+ )
793
+ }
794
+ ) : hasExpandableRows ? /* @__PURE__ */ jsx7(Box3, { sx: { width: 28 } }) : null,
795
+ flexRender(
796
+ cell.column.columnDef.cell,
797
+ cell.getContext()
798
+ )
799
+ ]
800
+ }
801
+ ) : flexRender(
757
802
  cell.column.columnDef.cell,
758
803
  cell.getContext()
759
804
  )
@@ -843,7 +888,7 @@ function BiampTableContainer({
843
888
  }
844
889
 
845
890
  // src/BiampTable/BiampTableCellActionButton.tsx
846
- import { IconButton, Tooltip } from "@mui/material";
891
+ import { IconButton as IconButton2, Tooltip } from "@mui/material";
847
892
  import { jsx as jsx9 } from "react/jsx-runtime";
848
893
  function BiampTableCellActionButton({ label, icon, ...props }) {
849
894
  return /* @__PURE__ */ jsx9(
@@ -854,7 +899,7 @@ function BiampTableCellActionButton({ label, icon, ...props }) {
854
899
  enterDelay: 500,
855
900
  enterNextDelay: 500,
856
901
  disableInteractive: true,
857
- children: /* @__PURE__ */ jsx9("span", { children: /* @__PURE__ */ jsx9(IconButton, { "aria-label": label, ...props, children: icon }) })
902
+ children: /* @__PURE__ */ jsx9("span", { children: /* @__PURE__ */ jsx9(IconButton2, { "aria-label": label, ...props, children: icon }) })
858
903
  }
859
904
  );
860
905
  }
@@ -939,6 +984,7 @@ function BiampTableColumnVisibility({
939
984
  /* @__PURE__ */ jsxs6(
940
985
  ListItem,
941
986
  {
987
+ dense: true,
942
988
  sx: columnListItemSx,
943
989
  onClick: () => table.toggleAllColumnsVisible(!allVisible),
944
990
  children: [
@@ -947,39 +993,45 @@ function BiampTableColumnVisibility({
947
993
  {
948
994
  checked: allVisible,
949
995
  indeterminate: !allVisible && someVisible,
950
- size: "small",
951
996
  slotProps: { input: { "aria-label": `${showAllLabel} columns` } }
952
997
  }
953
998
  ),
954
- /* @__PURE__ */ jsx10(Typography3, { variant: "caption", children: showAllLabel })
999
+ /* @__PURE__ */ jsx10(Typography3, { variant: "caption", fontWeight: 600, children: showAllLabel })
955
1000
  ]
956
1001
  }
957
1002
  ),
958
1003
  /* @__PURE__ */ jsx10(Divider, {}),
959
- /* @__PURE__ */ jsx10(Box4, { sx: { maxHeight: 340, overflow: "auto" }, children: table.getAllLeafColumns().map((column) => {
960
- const columnName = typeof column.columnDef.header === "string" ? column.columnDef.header : column.id;
961
- return /* @__PURE__ */ jsxs6(
962
- ListItem,
963
- {
964
- sx: columnListItemSx,
965
- onClick: column.getToggleVisibilityHandler(),
966
- children: [
967
- /* @__PURE__ */ jsx10(
968
- Checkbox2,
969
- {
970
- checked: column.getIsVisible(),
971
- size: "small",
972
- slotProps: {
973
- input: { "aria-label": `Show ${columnName}` }
974
- }
975
- }
976
- ),
977
- /* @__PURE__ */ jsx10(Typography3, { variant: "caption", children: columnName })
978
- ]
979
- },
980
- column.id
981
- );
982
- }) })
1004
+ /* @__PURE__ */ jsx10(
1005
+ Box4,
1006
+ {
1007
+ sx: { maxHeight: 340, overflow: "auto", overscrollBehavior: "none" },
1008
+ children: table.getAllLeafColumns().map((column) => {
1009
+ const columnName = column.columnDef.meta?.columnLabel ?? (typeof column.columnDef.header === "string" ? column.columnDef.header : column.id);
1010
+ return /* @__PURE__ */ jsxs6(
1011
+ ListItem,
1012
+ {
1013
+ dense: true,
1014
+ sx: columnListItemSx,
1015
+ onClick: column.getToggleVisibilityHandler(),
1016
+ children: [
1017
+ /* @__PURE__ */ jsx10(
1018
+ Checkbox2,
1019
+ {
1020
+ checked: column.getIsVisible(),
1021
+ sx: { py: 1 },
1022
+ slotProps: {
1023
+ input: { "aria-label": `Show ${columnName}` }
1024
+ }
1025
+ }
1026
+ ),
1027
+ /* @__PURE__ */ jsx10(Typography3, { variant: "caption", children: columnName })
1028
+ ]
1029
+ },
1030
+ column.id
1031
+ );
1032
+ })
1033
+ }
1034
+ )
983
1035
  ] })
984
1036
  }
985
1037
  );
@@ -992,7 +1044,7 @@ import { useState as useState2 } from "react";
992
1044
  // src/BiampTable/BiampTableToolbarActionButton.tsx
993
1045
  import {
994
1046
  Badge,
995
- IconButton as IconButton2
1047
+ IconButton as IconButton3
996
1048
  } from "@mui/material";
997
1049
  import { jsx as jsx11 } from "react/jsx-runtime";
998
1050
  function BiampTableToolbarActionButton({
@@ -1003,7 +1055,7 @@ function BiampTableToolbarActionButton({
1003
1055
  }) {
1004
1056
  const showBadge = badgeContent != null && badgeContent !== 0;
1005
1057
  return /* @__PURE__ */ jsx11(
1006
- IconButton2,
1058
+ IconButton3,
1007
1059
  {
1008
1060
  "aria-label": showBadge ? `${label} (${badgeContent})` : label,
1009
1061
  ...props,
@@ -1204,7 +1256,7 @@ import {
1204
1256
  Button,
1205
1257
  Divider as Divider2,
1206
1258
  Drawer,
1207
- IconButton as IconButton3,
1259
+ IconButton as IconButton4,
1208
1260
  Typography as Typography4
1209
1261
  } from "@mui/material";
1210
1262
  import { CloseIcon, FilterIcon } from "@bwp-web/assets";
@@ -1281,7 +1333,7 @@ function BiampTableToolbarFilters({
1281
1333
  )
1282
1334
  ] }),
1283
1335
  /* @__PURE__ */ jsx17(
1284
- IconButton3,
1336
+ IconButton4,
1285
1337
  {
1286
1338
  size: "medium",
1287
1339
  onClick: handleClose,
@@ -1342,7 +1394,7 @@ function BiampTableToolbarFilters({
1342
1394
  import {
1343
1395
  Box as Box8,
1344
1396
  Collapse,
1345
- IconButton as IconButton4,
1397
+ IconButton as IconButton5,
1346
1398
  InputAdornment as InputAdornment2,
1347
1399
  InputBase,
1348
1400
  TextField as TextField2,
@@ -1421,7 +1473,7 @@ function BiampTableToolbarSearch({
1421
1473
  }
1422
1474
  };
1423
1475
  const clearButton = inputValue ? /* @__PURE__ */ jsx18(InputAdornment2, { position: "end", children: /* @__PURE__ */ jsx18(
1424
- IconButton4,
1476
+ IconButton5,
1425
1477
  {
1426
1478
  size: "small",
1427
1479
  onClick: handleClear,
@@ -1491,7 +1543,7 @@ function BiampTableToolbarSearch({
1491
1543
  if (expandable) {
1492
1544
  return /* @__PURE__ */ jsxs9(Box8, { display: "flex", alignItems: "center", minWidth: 28, children: [
1493
1545
  /* @__PURE__ */ jsx18(
1494
- IconButton4,
1546
+ IconButton5,
1495
1547
  {
1496
1548
  "aria-label": expandLabel ?? placeholder,
1497
1549
  onClick: () => setIsExpanded(true),