@bwp-web/components 0.12.0 → 0.13.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.cjs CHANGED
@@ -51,12 +51,21 @@ __export(index_exports, {
51
51
  BiampTableToolbarExport: () => BiampTableToolbarExport,
52
52
  BiampTableToolbarFilters: () => BiampTableToolbarFilters,
53
53
  BiampTableToolbarSearch: () => BiampTableToolbarSearch,
54
+ BiampTableTruncatedCell: () => BiampTableTruncatedCell,
54
55
  BiampWrapper: () => BiampWrapper,
55
56
  buildCsvString: () => buildCsvString,
56
57
  exportToCsv: () => exportToCsv,
57
58
  getColumnVisibilityDirtyCount: () => getColumnVisibilityDirtyCount,
58
59
  getDefaultColumnVisibility: () => getDefaultColumnVisibility,
60
+ getDefaultColumnVisibilityFromDefs: () => getDefaultColumnVisibilityFromDefs,
61
+ getDirtyColumnVisibility: () => getDirtyColumnVisibility,
62
+ getOrderFieldMappings: () => getOrderFieldMappings,
63
+ orderToSorting: () => orderToSorting,
64
+ rowSelectionToSelectedIds: () => rowSelectionToSelectedIds,
65
+ selectedIdsToRowSelection: () => selectedIdsToRowSelection,
66
+ sortingToOrder: () => sortingToOrder,
59
67
  toVisibilityState: () => toVisibilityState,
68
+ useBiampServerSideTable: () => useBiampServerSideTable,
60
69
  useDebouncedCallback: () => useDebouncedCallback
61
70
  });
62
71
  module.exports = __toCommonJS(index_exports);
@@ -514,10 +523,10 @@ function BiampLayout({
514
523
  }
515
524
 
516
525
  // src/BiampTable/BiampTable.tsx
517
- var import_material6 = require("@mui/material");
526
+ var import_material7 = require("@mui/material");
518
527
  var import_assets5 = require("@bwp-web/assets");
519
528
  var import_react_table = require("@tanstack/react-table");
520
- var import_react3 = require("react");
529
+ var import_react4 = require("react");
521
530
 
522
531
  // src/BiampTable/BiampTableEmptyState.tsx
523
532
  var import_assets3 = require("@bwp-web/assets");
@@ -533,7 +542,7 @@ function BiampTableStatusMessage({
533
542
  children,
534
543
  ...stackProps
535
544
  }) {
536
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_material5.Stack, { alignItems: "center", gap: 2, ...stackProps, children: [
545
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_material5.Stack, { alignItems: "center", gap: 1.5, ...stackProps, children: [
537
546
  (0, import_react.cloneElement)(icon, {
538
547
  "aria-hidden": true,
539
548
  sx: { width: 56, height: 56, ...icon.props.sx }
@@ -573,18 +582,63 @@ function BiampTableErrorState({
573
582
  return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(BiampTableStatusMessage, { role: "alert", icon, title, ...rest });
574
583
  }
575
584
 
576
- // src/BiampTable/useLoadingDelay.ts
585
+ // src/BiampTable/BiampTableTruncatedCell.tsx
586
+ var import_material6 = require("@mui/material");
577
587
  var import_react2 = require("react");
588
+ var import_jsx_runtime8 = require("react/jsx-runtime");
589
+ function BiampTableTruncatedCell({
590
+ children
591
+ }) {
592
+ const textRef = (0, import_react2.useRef)(null);
593
+ const [open, setOpen] = (0, import_react2.useState)(false);
594
+ const handleMouseEnter = (0, import_react2.useCallback)(() => {
595
+ const el = textRef.current;
596
+ if (el && el.scrollWidth > el.clientWidth) {
597
+ setOpen(true);
598
+ }
599
+ }, []);
600
+ const handleMouseLeave = (0, import_react2.useCallback)(() => {
601
+ setOpen(false);
602
+ }, []);
603
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
604
+ import_material6.Tooltip,
605
+ {
606
+ title: children,
607
+ open,
608
+ arrow: true,
609
+ placement: "top",
610
+ disableInteractive: true,
611
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
612
+ import_material6.Box,
613
+ {
614
+ ref: textRef,
615
+ onMouseEnter: handleMouseEnter,
616
+ onMouseLeave: handleMouseLeave,
617
+ sx: {
618
+ overflow: "hidden",
619
+ textOverflow: "ellipsis",
620
+ whiteSpace: "nowrap",
621
+ minWidth: 0
622
+ },
623
+ children
624
+ }
625
+ )
626
+ }
627
+ );
628
+ }
629
+
630
+ // src/BiampTable/useLoadingDelay.ts
631
+ var import_react3 = require("react");
578
632
  function useLoadingDelay(loading, { delay = 150, minDuration = 500 } = {}) {
579
- const [status, setStatus] = (0, import_react2.useState)("idle");
580
- const timeoutRef = (0, import_react2.useRef)(null);
633
+ const [status, setStatus] = (0, import_react3.useState)("idle");
634
+ const timeoutRef = (0, import_react3.useRef)(null);
581
635
  function clearPending() {
582
636
  if (timeoutRef.current !== null) {
583
637
  clearTimeout(timeoutRef.current);
584
638
  timeoutRef.current = null;
585
639
  }
586
640
  }
587
- (0, import_react2.useEffect)(() => {
641
+ (0, import_react3.useEffect)(() => {
588
642
  if (loading && status === "idle") {
589
643
  clearPending();
590
644
  timeoutRef.current = setTimeout(() => {
@@ -600,12 +654,44 @@ function useLoadingDelay(loading, { delay = 150, minDuration = 500 } = {}) {
600
654
  setStatus("idle");
601
655
  }
602
656
  }, [loading, delay, minDuration, status]);
603
- (0, import_react2.useEffect)(() => clearPending, []);
657
+ (0, import_react3.useEffect)(() => clearPending, []);
604
658
  return status === "loading" || status === "ending";
605
659
  }
606
660
 
607
661
  // src/BiampTable/BiampTable.tsx
608
- var import_jsx_runtime8 = require("react/jsx-runtime");
662
+ var import_jsx_runtime9 = require("react/jsx-runtime");
663
+ var overlaySx = {
664
+ position: "absolute",
665
+ top: 0,
666
+ left: 0,
667
+ right: 0,
668
+ bottom: 0,
669
+ display: "flex",
670
+ alignItems: "center",
671
+ justifyContent: "center",
672
+ pointerEvents: "none"
673
+ };
674
+ var stickyHoverBg = {
675
+ ".MuiTableRow-hover:hover > &, .Mui-selected > &": {
676
+ bgcolor: ({ palette }) => palette.mode === "dark" ? palette.grey[800] : palette.grey[100]
677
+ }
678
+ };
679
+ function cellSx(sticky, minWidth, zIndex) {
680
+ if (sticky) {
681
+ return {
682
+ position: "sticky",
683
+ [sticky]: 0,
684
+ zIndex,
685
+ width: 0,
686
+ whiteSpace: "nowrap",
687
+ textAlign: "center",
688
+ bgcolor: "background.paper",
689
+ ...zIndex < 3 && stickyHoverBg
690
+ };
691
+ }
692
+ const mw = minWidth ?? 40;
693
+ return { minWidth: mw, maxWidth: mw };
694
+ }
609
695
  function BiampTable({
610
696
  table,
611
697
  onRowClick,
@@ -616,6 +702,7 @@ function BiampTable({
616
702
  enableRowSelection = false,
617
703
  enableExpanding = false,
618
704
  hideSelectAll,
705
+ selectChildrenWithParent = false,
619
706
  getRowLabel,
620
707
  sx,
621
708
  ...boxProps
@@ -627,16 +714,16 @@ function BiampTable({
627
714
  },
628
715
  enableRowSelection ? 48 : 0
629
716
  );
630
- const containerRef = (0, import_react3.useRef)(null);
717
+ const containerRef = (0, import_react4.useRef)(null);
631
718
  const showLoading = useLoadingDelay(!!loading);
632
719
  const rows = table.getRowModel().rows;
633
720
  const hasExpandableRows = enableExpanding && rows.some((r) => r.getCanExpand());
634
721
  const showError = !!error && !loading;
635
722
  const showEmpty = !showError && !loading && rows.length === 0;
636
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
637
- import_material6.TableContainer,
723
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
724
+ import_material7.TableContainer,
638
725
  {
639
- component: import_material6.Box,
726
+ component: import_material7.Box,
640
727
  ...boxProps,
641
728
  ref: containerRef,
642
729
  sx: {
@@ -649,15 +736,15 @@ function BiampTable({
649
736
  ...sx
650
737
  },
651
738
  children: [
652
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
653
- import_material6.Table,
739
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
740
+ import_material7.Table,
654
741
  {
655
742
  "aria-busy": showLoading || void 0,
656
743
  sx: { minWidth: tableMinWidth, tableLayout: "auto" },
657
744
  children: [
658
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_material6.TableHead, { children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_material6.TableRow, { children: [
659
- enableRowSelection && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
660
- import_material6.TableCell,
745
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_material7.TableHead, { children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_material7.TableRow, { children: [
746
+ enableRowSelection && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
747
+ import_material7.TableCell,
661
748
  {
662
749
  padding: "checkbox",
663
750
  sx: {
@@ -666,8 +753,8 @@ function BiampTable({
666
753
  zIndex: 3,
667
754
  bgcolor: "background.paper"
668
755
  },
669
- children: !hideSelectAll && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
670
- import_material6.Checkbox,
756
+ children: !hideSelectAll && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
757
+ import_material7.Checkbox,
671
758
  {
672
759
  checked: table.getIsAllPageRowsSelected(),
673
760
  indeterminate: table.getIsSomePageRowsSelected(),
@@ -680,28 +767,21 @@ function BiampTable({
680
767
  ),
681
768
  headerGroup.headers.map((header) => {
682
769
  const sticky = header.column.columnDef.meta?.sticky;
683
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
684
- import_material6.TableCell,
770
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
771
+ import_material7.TableCell,
685
772
  {
686
773
  "data-sticky": sticky || void 0,
687
774
  sortDirection: header.column.getIsSorted() || false,
688
775
  ...header.column.getCanSort() && {
689
776
  "aria-sort": header.column.getIsSorted() ? header.column.getIsSorted() === "asc" ? "ascending" : "descending" : "none"
690
777
  },
691
- sx: {
692
- minWidth: sticky ? void 0 : header.column.columnDef.meta?.minWidth ?? 40,
693
- ...sticky && {
694
- position: "sticky",
695
- [sticky]: 0,
696
- zIndex: 3,
697
- width: 0,
698
- whiteSpace: "nowrap",
699
- textAlign: "center",
700
- bgcolor: "background.paper"
701
- }
702
- },
703
- children: header.isPlaceholder ? null : header.column.getCanSort() ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
704
- import_material6.TableSortLabel,
778
+ sx: cellSx(
779
+ sticky,
780
+ header.column.columnDef.meta?.minWidth,
781
+ 3
782
+ ),
783
+ children: header.isPlaceholder ? null : header.column.getCanSort() ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
784
+ import_material7.TableSortLabel,
705
785
  {
706
786
  active: !!header.column.getIsSorted(),
707
787
  direction: header.column.getIsSorted() || "asc",
@@ -723,10 +803,10 @@ function BiampTable({
723
803
  );
724
804
  })
725
805
  ] }, headerGroup.id)) }),
726
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_material6.TableBody, { sx: { opacity: showLoading ? 0.3 : 1 }, children: !showError && rows.map((row) => {
806
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_material7.TableBody, { sx: { opacity: showLoading ? 0.3 : 1 }, children: !showError && rows.map((row) => {
727
807
  const clickable = onRowClick ? isRowClickable ? isRowClickable(row.original) : true : false;
728
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
729
- import_material6.TableRow,
808
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
809
+ import_material7.TableRow,
730
810
  {
731
811
  hover: clickable,
732
812
  selected: enableRowSelection ? row.getIsSelected() : void 0,
@@ -741,8 +821,8 @@ function BiampTable({
741
821
  }
742
822
  } : void 0,
743
823
  children: [
744
- enableRowSelection && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
745
- import_material6.TableCell,
824
+ enableRowSelection && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
825
+ import_material7.TableCell,
746
826
  {
747
827
  padding: "checkbox",
748
828
  sx: {
@@ -754,12 +834,14 @@ function BiampTable({
754
834
  bgcolor: ({ palette }) => palette.mode === "dark" ? palette.grey[800] : palette.grey[100]
755
835
  }
756
836
  },
757
- children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
758
- import_material6.Checkbox,
837
+ children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
838
+ import_material7.Checkbox,
759
839
  {
760
840
  checked: row.getIsSelected(),
761
841
  disabled: !row.getCanSelect(),
762
- onChange: row.getToggleSelectedHandler(),
842
+ onChange: (e) => row.toggleSelected(e.target.checked, {
843
+ selectChildren: selectChildrenWithParent
844
+ }),
763
845
  onClick: (e) => e.stopPropagation(),
764
846
  sx: !row.getCanSelect() ? { visibility: "hidden" } : void 0,
765
847
  slotProps: {
@@ -776,67 +858,61 @@ function BiampTable({
776
858
  const isExpandCell = enableExpanding && !sticky && cellIndex === cells.findIndex(
777
859
  (c) => !c.column.columnDef.meta?.sticky
778
860
  );
779
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
780
- import_material6.TableCell,
861
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
862
+ import_material7.TableCell,
781
863
  {
782
864
  "data-sticky": sticky || void 0,
783
- sx: {
784
- minWidth: sticky ? void 0 : cell.column.columnDef.meta?.minWidth ?? 40,
785
- ...sticky && {
786
- position: "sticky",
787
- [sticky]: 0,
788
- zIndex: 2,
789
- width: 0,
790
- whiteSpace: "nowrap",
791
- textAlign: "center",
792
- bgcolor: "background.paper",
793
- ".MuiTableRow-hover:hover > &, .Mui-selected > &": {
794
- bgcolor: ({ palette }) => palette.mode === "dark" ? palette.grey[800] : palette.grey[100]
795
- }
796
- }
797
- },
798
- children: isExpandCell ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
799
- import_material6.Box,
800
- {
801
- sx: {
802
- display: "flex",
803
- alignItems: "center",
804
- pl: `${row.depth * 12}px`
805
- },
806
- children: [
807
- row.getCanExpand() ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
808
- import_material6.IconButton,
809
- {
810
- variant: "none",
811
- onClick: (e) => {
812
- e.stopPropagation();
813
- row.toggleExpanded();
814
- },
815
- "aria-label": row.getIsExpanded() ? `Collapse ${getRowLabel ? getRowLabel(row.original) : `row ${row.index + 1}`}` : `Expand ${getRowLabel ? getRowLabel(row.original) : `row ${row.index + 1}`}`,
816
- "aria-expanded": row.getIsExpanded(),
817
- children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
818
- import_assets5.ChevronRightIcon,
819
- {
820
- variant: "xs",
821
- sx: {
822
- color: ({ palette }) => palette.text.secondary,
823
- transition: "transform 150ms ease",
824
- transform: row.getIsExpanded() ? "rotate(90deg)" : "rotate(0deg)"
865
+ sx: cellSx(
866
+ sticky,
867
+ cell.column.columnDef.meta?.minWidth,
868
+ 2
869
+ ),
870
+ children: (() => {
871
+ const content = (0, import_react_table.flexRender)(
872
+ cell.column.columnDef.cell,
873
+ cell.getContext()
874
+ );
875
+ if (sticky) return content;
876
+ const truncated = /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(BiampTableTruncatedCell, { children: content });
877
+ if (!isExpandCell) return truncated;
878
+ const rowLabel = getRowLabel ? getRowLabel(row.original) : `row ${row.index + 1}`;
879
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
880
+ import_material7.Box,
881
+ {
882
+ sx: {
883
+ display: "flex",
884
+ alignItems: "center",
885
+ pl: `${row.depth * 12}px`
886
+ },
887
+ children: [
888
+ row.getCanExpand() ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
889
+ import_material7.IconButton,
890
+ {
891
+ variant: "none",
892
+ onClick: (e) => {
893
+ e.stopPropagation();
894
+ row.toggleExpanded();
895
+ },
896
+ "aria-label": row.getIsExpanded() ? `Collapse ${rowLabel}` : `Expand ${rowLabel}`,
897
+ "aria-expanded": row.getIsExpanded(),
898
+ children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
899
+ import_assets5.ChevronRightIcon,
900
+ {
901
+ variant: "xs",
902
+ sx: {
903
+ color: ({ palette }) => palette.text.secondary,
904
+ transition: "transform 150ms ease",
905
+ transform: row.getIsExpanded() ? "rotate(90deg)" : "rotate(0deg)"
906
+ }
825
907
  }
826
- }
827
- )
828
- }
829
- ) : hasExpandableRows ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_material6.Box, { sx: { width: 28 } }) : null,
830
- (0, import_react_table.flexRender)(
831
- cell.column.columnDef.cell,
832
- cell.getContext()
833
- )
834
- ]
835
- }
836
- ) : (0, import_react_table.flexRender)(
837
- cell.column.columnDef.cell,
838
- cell.getContext()
839
- )
908
+ )
909
+ }
910
+ ) : hasExpandableRows ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_material7.Box, { sx: { width: 28 } }) : null,
911
+ truncated
912
+ ]
913
+ }
914
+ );
915
+ })()
840
916
  },
841
917
  cell.id
842
918
  );
@@ -849,54 +925,22 @@ function BiampTable({
849
925
  ]
850
926
  }
851
927
  ),
852
- showError && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
853
- import_material6.Box,
928
+ showError && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_material7.Box, { sx: overlaySx, children: error === true ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(BiampTableErrorState, { sx: { pointerEvents: "auto" } }) : error instanceof Error ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
929
+ BiampTableErrorState,
854
930
  {
855
- sx: {
856
- position: "absolute",
857
- top: 0,
858
- left: 0,
859
- right: 0,
860
- bottom: 0,
861
- display: "flex",
862
- alignItems: "center",
863
- justifyContent: "center",
864
- pointerEvents: "none"
865
- },
866
- children: error === true ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(BiampTableErrorState, { sx: { pointerEvents: "auto" } }) : error instanceof Error ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
867
- BiampTableErrorState,
868
- {
869
- description: error.message,
870
- sx: { pointerEvents: "auto" }
871
- }
872
- ) : error
931
+ description: error.message,
932
+ sx: { pointerEvents: "auto" }
873
933
  }
874
- ),
875
- showEmpty && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
876
- import_material6.Box,
877
- {
878
- sx: {
879
- position: "absolute",
880
- top: 0,
881
- left: 0,
882
- right: 0,
883
- bottom: 0,
884
- display: "flex",
885
- alignItems: "center",
886
- justifyContent: "center",
887
- pointerEvents: "none"
888
- },
889
- children: empty && empty !== true ? empty : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(BiampTableEmptyState, { sx: { pointerEvents: "auto" } })
890
- }
891
- )
934
+ ) : error }),
935
+ showEmpty && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_material7.Box, { sx: overlaySx, children: empty && empty !== true ? empty : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(BiampTableEmptyState, { sx: { pointerEvents: "auto" } }) })
892
936
  ]
893
937
  }
894
938
  );
895
939
  }
896
940
 
897
941
  // src/BiampTable/BiampTableContainer.tsx
898
- var import_material7 = require("@mui/material");
899
- var import_jsx_runtime9 = require("react/jsx-runtime");
942
+ var import_material8 = require("@mui/material");
943
+ var import_jsx_runtime10 = require("react/jsx-runtime");
900
944
  function BiampTableContainer({
901
945
  withBorderTop = true,
902
946
  withBorderBottom = false,
@@ -904,8 +948,8 @@ function BiampTableContainer({
904
948
  sx,
905
949
  ...props
906
950
  }) {
907
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
908
- import_material7.Stack,
951
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
952
+ import_material8.Stack,
909
953
  {
910
954
  direction: "column",
911
955
  height: "100%",
@@ -923,25 +967,25 @@ function BiampTableContainer({
923
967
  }
924
968
 
925
969
  // src/BiampTable/BiampTableCellActionButton.tsx
926
- var import_material8 = require("@mui/material");
927
- var import_jsx_runtime10 = require("react/jsx-runtime");
970
+ var import_material9 = require("@mui/material");
971
+ var import_jsx_runtime11 = require("react/jsx-runtime");
928
972
  function BiampTableCellActionButton({ label, icon, ...props }) {
929
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
930
- import_material8.Tooltip,
973
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
974
+ import_material9.Tooltip,
931
975
  {
932
976
  title: label,
933
977
  placement: "top",
934
978
  enterDelay: 500,
935
979
  enterNextDelay: 500,
936
980
  disableInteractive: true,
937
- children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_material8.IconButton, { "aria-label": label, ...props, children: icon }) })
981
+ children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_material9.IconButton, { "aria-label": label, ...props, children: icon }) })
938
982
  }
939
983
  );
940
984
  }
941
985
 
942
986
  // src/BiampTable/BiampTableColumnVisibility.tsx
943
- var import_material9 = require("@mui/material");
944
- var import_jsx_runtime11 = require("react/jsx-runtime");
987
+ var import_material10 = require("@mui/material");
988
+ var import_jsx_runtime12 = require("react/jsx-runtime");
945
989
  function toVisibilityState(visibility) {
946
990
  return visibility;
947
991
  }
@@ -984,9 +1028,8 @@ function BiampTableColumnVisibility({
984
1028
  ...popoverProps
985
1029
  }) {
986
1030
  const allVisible = table.getAllLeafColumns().every((col) => col.getIsVisible());
987
- const someVisible = table.getAllLeafColumns().some((col) => col.getIsVisible());
988
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
989
- import_material9.Popover,
1031
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1032
+ import_material10.Popover,
990
1033
  {
991
1034
  anchorEl,
992
1035
  open: Boolean(anchorEl),
@@ -999,49 +1042,48 @@ function BiampTableColumnVisibility({
999
1042
  borderRadius: "6px",
1000
1043
  backgroundImage: "none",
1001
1044
  border: `0.6px solid ${palette.dividers.secondary}`,
1002
- boxShadow: `0px 1px 1px 0px ${(0, import_material9.alpha)(palette.common.black, 0.05)}`,
1045
+ boxShadow: `0px 1px 1px 0px ${(0, import_material10.alpha)(palette.common.black, 0.05)}`,
1003
1046
  minWidth: "150px"
1004
1047
  }),
1005
1048
  ...slotProps?.paper ?? {}
1006
1049
  }
1007
1050
  },
1008
1051
  ...popoverProps,
1009
- children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_material9.List, { dense: true, disablePadding: true, children: [
1010
- /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
1011
- import_material9.ListItem,
1052
+ children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_material10.List, { dense: true, disablePadding: true, children: [
1053
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
1054
+ import_material10.ListItem,
1012
1055
  {
1013
1056
  dense: true,
1014
1057
  sx: columnListItemSx,
1015
1058
  onClick: () => table.toggleAllColumnsVisible(!allVisible),
1016
1059
  children: [
1017
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1018
- import_material9.Checkbox,
1060
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1061
+ import_material10.Checkbox,
1019
1062
  {
1020
1063
  checked: allVisible,
1021
- indeterminate: !allVisible && someVisible,
1022
1064
  slotProps: { input: { "aria-label": `${showAllLabel} columns` } }
1023
1065
  }
1024
1066
  ),
1025
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_material9.Typography, { variant: "caption", fontWeight: 600, children: showAllLabel })
1067
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_material10.Typography, { variant: "caption", fontWeight: 600, children: showAllLabel })
1026
1068
  ]
1027
1069
  }
1028
1070
  ),
1029
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_material9.Divider, {}),
1030
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1031
- import_material9.Box,
1071
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_material10.Divider, {}),
1072
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1073
+ import_material10.Box,
1032
1074
  {
1033
1075
  sx: { maxHeight: 340, overflow: "auto", overscrollBehavior: "none" },
1034
1076
  children: table.getAllLeafColumns().map((column) => {
1035
1077
  const columnName = column.columnDef.meta?.columnLabel ?? (typeof column.columnDef.header === "string" ? column.columnDef.header : column.id);
1036
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
1037
- import_material9.ListItem,
1078
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
1079
+ import_material10.ListItem,
1038
1080
  {
1039
1081
  dense: true,
1040
1082
  sx: columnListItemSx,
1041
1083
  onClick: column.getToggleVisibilityHandler(),
1042
1084
  children: [
1043
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1044
- import_material9.Checkbox,
1085
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1086
+ import_material10.Checkbox,
1045
1087
  {
1046
1088
  checked: column.getIsVisible(),
1047
1089
  sx: { py: 1 },
@@ -1050,7 +1092,7 @@ function BiampTableColumnVisibility({
1050
1092
  }
1051
1093
  }
1052
1094
  ),
1053
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_material9.Typography, { variant: "caption", children: columnName })
1095
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_material10.Typography, { variant: "caption", children: columnName })
1054
1096
  ]
1055
1097
  },
1056
1098
  column.id
@@ -1065,11 +1107,11 @@ function BiampTableColumnVisibility({
1065
1107
 
1066
1108
  // src/BiampTable/BiampTableToolbarColumnVisibility.tsx
1067
1109
  var import_assets6 = require("@bwp-web/assets");
1068
- var import_react4 = require("react");
1110
+ var import_react5 = require("react");
1069
1111
 
1070
1112
  // src/BiampTable/BiampTableToolbarActionButton.tsx
1071
- var import_material10 = require("@mui/material");
1072
- var import_jsx_runtime12 = require("react/jsx-runtime");
1113
+ var import_material11 = require("@mui/material");
1114
+ var import_jsx_runtime13 = require("react/jsx-runtime");
1073
1115
  function BiampTableToolbarActionButton({
1074
1116
  label,
1075
1117
  icon,
@@ -1077,13 +1119,13 @@ function BiampTableToolbarActionButton({
1077
1119
  ...props
1078
1120
  }) {
1079
1121
  const showBadge = badgeContent != null && badgeContent !== 0;
1080
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1081
- import_material10.IconButton,
1122
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1123
+ import_material11.IconButton,
1082
1124
  {
1083
1125
  "aria-label": showBadge ? `${label} (${badgeContent})` : label,
1084
1126
  ...props,
1085
- children: showBadge ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1086
- import_material10.Badge,
1127
+ children: showBadge ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1128
+ import_material11.Badge,
1087
1129
  {
1088
1130
  badgeContent,
1089
1131
  color: "info",
@@ -1106,20 +1148,20 @@ function BiampTableToolbarActionButton({
1106
1148
  }
1107
1149
 
1108
1150
  // src/BiampTable/BiampTableToolbarColumnVisibility.tsx
1109
- var import_jsx_runtime13 = require("react/jsx-runtime");
1151
+ var import_jsx_runtime14 = require("react/jsx-runtime");
1110
1152
  function BiampTableToolbarColumnVisibility({
1111
1153
  table,
1112
- icon = /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_assets6.ColumnsIcon, { variant: "xs" }),
1154
+ icon = /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_assets6.ColumnsIcon, { variant: "xs" }),
1113
1155
  label = "Columns",
1114
1156
  defaultColumnVisibility,
1115
1157
  showAllLabel,
1116
1158
  ...actionButtonProps
1117
1159
  }) {
1118
- const [anchorEl, setAnchorEl] = (0, import_react4.useState)(null);
1160
+ const [anchorEl, setAnchorEl] = (0, import_react5.useState)(null);
1119
1161
  const defaults = defaultColumnVisibility ?? getDefaultColumnVisibility(table);
1120
1162
  const dirtyCount = getColumnVisibilityDirtyCount(table, defaults);
1121
- return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
1122
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1163
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_jsx_runtime14.Fragment, { children: [
1164
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1123
1165
  BiampTableToolbarActionButton,
1124
1166
  {
1125
1167
  label,
@@ -1129,7 +1171,7 @@ function BiampTableToolbarColumnVisibility({
1129
1171
  ...actionButtonProps
1130
1172
  }
1131
1173
  ),
1132
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1174
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1133
1175
  BiampTableColumnVisibility,
1134
1176
  {
1135
1177
  table,
@@ -1142,9 +1184,9 @@ function BiampTableToolbarColumnVisibility({
1142
1184
  }
1143
1185
 
1144
1186
  // src/BiampTable/BiampTablePagination.tsx
1145
- var import_react5 = require("react");
1146
- var import_material11 = require("@mui/material");
1147
- var import_jsx_runtime14 = require("react/jsx-runtime");
1187
+ var import_react6 = require("react");
1188
+ var import_material12 = require("@mui/material");
1189
+ var import_jsx_runtime15 = require("react/jsx-runtime");
1148
1190
  var positionMap = {
1149
1191
  left: "flex-start",
1150
1192
  center: "center",
@@ -1160,19 +1202,21 @@ function BiampTablePagination({
1160
1202
  ...paginationProps
1161
1203
  }) {
1162
1204
  const rowCount = table.getRowCount();
1163
- const lastRowCountRef = (0, import_react5.useRef)(rowCount);
1205
+ const lastRowCountRef = (0, import_react6.useRef)(rowCount);
1164
1206
  if (!loading && rowCount >= 0) {
1165
1207
  lastRowCountRef.current = rowCount;
1166
1208
  }
1167
1209
  const stableCount = loading ? lastRowCountRef.current : rowCount;
1168
1210
  const { pageSize, pageIndex } = table.getState().pagination;
1169
1211
  const maxPage = Math.max(0, Math.ceil(stableCount / pageSize) - 1);
1170
- if (!loading && pageIndex > maxPage) {
1171
- table.setPageIndex(maxPage);
1172
- }
1212
+ (0, import_react6.useEffect)(() => {
1213
+ if (!loading && pageIndex > maxPage) {
1214
+ table.setPageIndex(maxPage);
1215
+ }
1216
+ }, [loading, pageIndex, maxPage, table]);
1173
1217
  if (autoHide && (!stableCount || stableCount <= pageSize)) return null;
1174
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1175
- import_material11.TablePagination,
1218
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
1219
+ import_material12.TablePagination,
1176
1220
  {
1177
1221
  component: "div",
1178
1222
  count: stableCount,
@@ -1203,15 +1247,15 @@ function BiampTablePagination({
1203
1247
  }
1204
1248
 
1205
1249
  // src/BiampTable/BiampTableToolbar.tsx
1206
- var import_material12 = require("@mui/material");
1207
- var import_jsx_runtime15 = require("react/jsx-runtime");
1250
+ var import_material13 = require("@mui/material");
1251
+ var import_jsx_runtime16 = require("react/jsx-runtime");
1208
1252
  function BiampTableToolbar({
1209
1253
  children,
1210
1254
  sx,
1211
1255
  ...props
1212
1256
  }) {
1213
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
1214
- import_material12.Box,
1257
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1258
+ import_material13.Box,
1215
1259
  {
1216
1260
  role: "toolbar",
1217
1261
  display: "flex",
@@ -1229,14 +1273,14 @@ function BiampTableToolbar({
1229
1273
  }
1230
1274
 
1231
1275
  // src/BiampTable/BiampTableToolbarActions.tsx
1232
- var import_material13 = require("@mui/material");
1233
- var import_jsx_runtime16 = require("react/jsx-runtime");
1276
+ var import_material14 = require("@mui/material");
1277
+ var import_jsx_runtime17 = require("react/jsx-runtime");
1234
1278
  function BiampTableToolbarActions({
1235
1279
  children,
1236
1280
  ...props
1237
1281
  }) {
1238
- return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1239
- import_material13.Box,
1282
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
1283
+ import_material14.Box,
1240
1284
  {
1241
1285
  display: "flex",
1242
1286
  alignItems: "center",
@@ -1250,21 +1294,21 @@ function BiampTableToolbarActions({
1250
1294
  }
1251
1295
 
1252
1296
  // src/BiampTable/BiampTableToolbarExport.tsx
1253
- var import_material14 = require("@mui/material");
1297
+ var import_material15 = require("@mui/material");
1254
1298
  var import_assets7 = require("@bwp-web/assets");
1255
- var import_jsx_runtime17 = require("react/jsx-runtime");
1299
+ var import_jsx_runtime18 = require("react/jsx-runtime");
1256
1300
  function BiampTableToolbarExport({
1257
1301
  onExport,
1258
1302
  loading,
1259
- icon = /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_assets7.DownloadIcon, { variant: "xs" }),
1303
+ icon = /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_assets7.DownloadIcon, { variant: "xs" }),
1260
1304
  label = "Export",
1261
1305
  ...props
1262
1306
  }) {
1263
- return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
1307
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1264
1308
  BiampTableToolbarActionButton,
1265
1309
  {
1266
1310
  label: loading ? `${label}, loading` : label,
1267
- icon: loading ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_material14.CircularProgress, { size: 20, color: "inherit" }) : icon,
1311
+ icon: loading ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_material15.CircularProgress, { size: 20, color: "inherit" }) : icon,
1268
1312
  disabled: loading,
1269
1313
  onClick: onExport,
1270
1314
  ...props
@@ -1273,16 +1317,16 @@ function BiampTableToolbarExport({
1273
1317
  }
1274
1318
 
1275
1319
  // src/BiampTable/BiampTableToolbarFilters.tsx
1276
- var import_material15 = require("@mui/material");
1320
+ var import_material16 = require("@mui/material");
1277
1321
  var import_assets8 = require("@bwp-web/assets");
1278
- var import_react6 = require("react");
1279
- var import_jsx_runtime18 = require("react/jsx-runtime");
1322
+ var import_react7 = require("react");
1323
+ var import_jsx_runtime19 = require("react/jsx-runtime");
1280
1324
  function BiampTableToolbarFilters({
1281
1325
  activeFilterCount,
1282
1326
  children,
1283
1327
  onReset,
1284
1328
  onApply,
1285
- icon = /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_assets8.FilterIcon, { variant: "xs" }),
1329
+ icon = /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_assets8.FilterIcon, { variant: "xs" }),
1286
1330
  title = "Filters",
1287
1331
  resetLabel = "Clear filters",
1288
1332
  applyLabel = "Apply",
@@ -1290,14 +1334,14 @@ function BiampTableToolbarFilters({
1290
1334
  buttonLabel = "Filters",
1291
1335
  DrawerProps: drawerProps
1292
1336
  }) {
1293
- const [open, setOpen] = (0, import_react6.useState)(false);
1294
- const titleId = (0, import_react6.useId)();
1337
+ const [open, setOpen] = (0, import_react7.useState)(false);
1338
+ const titleId = (0, import_react7.useId)();
1295
1339
  function handleClose() {
1296
1340
  onApply?.();
1297
1341
  setOpen(false);
1298
1342
  }
1299
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_jsx_runtime18.Fragment, { children: [
1300
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1343
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_jsx_runtime19.Fragment, { children: [
1344
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
1301
1345
  BiampTableToolbarActionButton,
1302
1346
  {
1303
1347
  label: buttonLabel,
@@ -1306,8 +1350,8 @@ function BiampTableToolbarFilters({
1306
1350
  onClick: () => setOpen(true)
1307
1351
  }
1308
1352
  ),
1309
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1310
- import_material15.Drawer,
1353
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
1354
+ import_material16.Drawer,
1311
1355
  {
1312
1356
  anchor: "right",
1313
1357
  open,
@@ -1318,17 +1362,17 @@ function BiampTableToolbarFilters({
1318
1362
  sx: { width: { xs: "100%", sm: 480 } },
1319
1363
  ...drawerProps?.PaperProps
1320
1364
  },
1321
- children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
1322
- import_material15.Box,
1365
+ children: /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
1366
+ import_material16.Box,
1323
1367
  {
1324
1368
  height: "100%",
1325
1369
  display: "flex",
1326
1370
  flexDirection: "column",
1327
1371
  justifyContent: "space-between",
1328
1372
  children: [
1329
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_material15.Box, { children: [
1330
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
1331
- import_material15.Box,
1373
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_material16.Box, { children: [
1374
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
1375
+ import_material16.Box,
1332
1376
  {
1333
1377
  display: "flex",
1334
1378
  justifyContent: "space-between",
@@ -1336,10 +1380,10 @@ function BiampTableToolbarFilters({
1336
1380
  px: 3.5,
1337
1381
  py: 2.5,
1338
1382
  children: [
1339
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_material15.Typography, { id: titleId, variant: "h2", children: [
1383
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_material16.Typography, { id: titleId, variant: "h2", children: [
1340
1384
  title,
1341
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1342
- import_material15.Badge,
1385
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
1386
+ import_material16.Badge,
1343
1387
  {
1344
1388
  badgeContent: activeFilterCount,
1345
1389
  color: "secondary",
@@ -1347,21 +1391,21 @@ function BiampTableToolbarFilters({
1347
1391
  }
1348
1392
  )
1349
1393
  ] }),
1350
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1351
- import_material15.IconButton,
1394
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
1395
+ import_material16.IconButton,
1352
1396
  {
1353
1397
  size: "medium",
1354
1398
  onClick: handleClose,
1355
1399
  "aria-label": closeLabel,
1356
- children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_assets8.CloseIcon, {})
1400
+ children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_assets8.CloseIcon, {})
1357
1401
  }
1358
1402
  )
1359
1403
  ]
1360
1404
  }
1361
1405
  ),
1362
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_material15.Divider, {}),
1363
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1364
- import_material15.Box,
1406
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_material16.Divider, {}),
1407
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
1408
+ import_material16.Box,
1365
1409
  {
1366
1410
  role: "group",
1367
1411
  "aria-label": "Filter options",
@@ -1374,9 +1418,9 @@ function BiampTableToolbarFilters({
1374
1418
  }
1375
1419
  )
1376
1420
  ] }),
1377
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_material15.Box, { display: "flex", children: [
1378
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1379
- import_material15.Button,
1421
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_material16.Box, { display: "flex", children: [
1422
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
1423
+ import_material16.Button,
1380
1424
  {
1381
1425
  variant: "overlay",
1382
1426
  color: "secondary",
@@ -1386,8 +1430,8 @@ function BiampTableToolbarFilters({
1386
1430
  children: resetLabel
1387
1431
  }
1388
1432
  ),
1389
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1390
- import_material15.Button,
1433
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
1434
+ import_material16.Button,
1391
1435
  {
1392
1436
  variant: "overlay",
1393
1437
  color: "primary",
@@ -1406,23 +1450,23 @@ function BiampTableToolbarFilters({
1406
1450
  }
1407
1451
 
1408
1452
  // src/BiampTable/BiampTableToolbarSearch.tsx
1409
- var import_material16 = require("@mui/material");
1453
+ var import_material17 = require("@mui/material");
1410
1454
  var import_assets9 = require("@bwp-web/assets");
1411
- var import_react8 = require("react");
1455
+ var import_react9 = require("react");
1412
1456
 
1413
1457
  // src/BiampTable/useDebouncedCallback.ts
1414
- var import_react7 = require("react");
1458
+ var import_react8 = require("react");
1415
1459
  var BIAMP_TABLE_DEBOUNCE_DELAY = 300;
1416
1460
  function useDebouncedCallback(callback, delay = BIAMP_TABLE_DEBOUNCE_DELAY) {
1417
- const timeoutRef = (0, import_react7.useRef)(null);
1418
- const callbackRef = (0, import_react7.useRef)(callback);
1461
+ const timeoutRef = (0, import_react8.useRef)(null);
1462
+ const callbackRef = (0, import_react8.useRef)(callback);
1419
1463
  callbackRef.current = callback;
1420
- (0, import_react7.useEffect)(() => {
1464
+ (0, import_react8.useEffect)(() => {
1421
1465
  return () => {
1422
1466
  if (timeoutRef.current !== null) clearTimeout(timeoutRef.current);
1423
1467
  };
1424
1468
  }, []);
1425
- return (0, import_react7.useCallback)(
1469
+ return (0, import_react8.useCallback)(
1426
1470
  (...args) => {
1427
1471
  if (timeoutRef.current !== null) clearTimeout(timeoutRef.current);
1428
1472
  timeoutRef.current = setTimeout(
@@ -1435,7 +1479,7 @@ function useDebouncedCallback(callback, delay = BIAMP_TABLE_DEBOUNCE_DELAY) {
1435
1479
  }
1436
1480
 
1437
1481
  // src/BiampTable/BiampTableToolbarSearch.tsx
1438
- var import_jsx_runtime19 = require("react/jsx-runtime");
1482
+ var import_jsx_runtime20 = require("react/jsx-runtime");
1439
1483
  var searchFieldSx = {
1440
1484
  "& .MuiInputBase-root": {
1441
1485
  height: "36px !important",
@@ -1459,11 +1503,11 @@ function BiampTableToolbarSearch({
1459
1503
  sx,
1460
1504
  ...textFieldProps
1461
1505
  }) {
1462
- const isMobile = (0, import_material16.useMediaQuery)((t) => t.breakpoints.down("md"));
1463
- const [inputValue, setInputValue] = (0, import_react8.useState)(defaultValue);
1464
- const [isExpanded, setIsExpanded] = (0, import_react8.useState)(false);
1506
+ const isMobile = (0, import_material17.useMediaQuery)((t) => t.breakpoints.down("md"));
1507
+ const [inputValue, setInputValue] = (0, import_react9.useState)(defaultValue);
1508
+ const [isExpanded, setIsExpanded] = (0, import_react9.useState)(false);
1465
1509
  const debouncedOnChange = useDebouncedCallback(onChange, debounceDelay);
1466
- (0, import_react8.useEffect)(() => {
1510
+ (0, import_react9.useEffect)(() => {
1467
1511
  setInputValue(defaultValue);
1468
1512
  }, [defaultValue]);
1469
1513
  const handleChange = (e) => {
@@ -1479,18 +1523,18 @@ function BiampTableToolbarSearch({
1479
1523
  setIsExpanded(false);
1480
1524
  }
1481
1525
  };
1482
- const clearButton = inputValue ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_material16.InputAdornment, { position: "end", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
1483
- import_material16.IconButton,
1526
+ const clearButton = inputValue ? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_material17.InputAdornment, { position: "end", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
1527
+ import_material17.IconButton,
1484
1528
  {
1485
1529
  size: "small",
1486
1530
  onClick: handleClear,
1487
1531
  "aria-label": clearLabel,
1488
1532
  sx: { mr: 0.5 },
1489
- children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_assets9.CloseIcon, { variant: "xs", sx: { width: 20, height: 20 } })
1533
+ children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_assets9.CloseIcon, { variant: "xs", sx: { width: 20, height: 20 } })
1490
1534
  }
1491
1535
  ) }) : null;
1492
- const textField = /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
1493
- import_material16.TextField,
1536
+ const textField = /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
1537
+ import_material17.TextField,
1494
1538
  {
1495
1539
  name: "search",
1496
1540
  type: "text",
@@ -1498,7 +1542,7 @@ function BiampTableToolbarSearch({
1498
1542
  slotProps: {
1499
1543
  htmlInput: { maxLength, "aria-label": placeholder },
1500
1544
  input: {
1501
- startAdornment: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_material16.InputAdornment, { position: "start", sx: { ml: 1 }, children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
1545
+ startAdornment: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_material17.InputAdornment, { position: "start", sx: { ml: 1 }, children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
1502
1546
  import_assets9.SearchIcon,
1503
1547
  {
1504
1548
  variant: "xs",
@@ -1524,10 +1568,10 @@ function BiampTableToolbarSearch({
1524
1568
  }
1525
1569
  );
1526
1570
  if (isMobile && enableMobileView) {
1527
- return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_material16.Box, { display: "flex", alignItems: "center", width: "100%", pr: 1, gap: 1, children: [
1528
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_assets9.SearchIcon, { sx: { width: 16, height: 16 } }),
1529
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
1530
- import_material16.InputBase,
1571
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(import_material17.Box, { display: "flex", alignItems: "center", width: "100%", pr: 1, gap: 1, children: [
1572
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_assets9.SearchIcon, { sx: { width: 16, height: 16 } }),
1573
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
1574
+ import_material17.InputBase,
1531
1575
  {
1532
1576
  name: "search",
1533
1577
  type: "text",
@@ -1548,14 +1592,14 @@ function BiampTableToolbarSearch({
1548
1592
  ] });
1549
1593
  }
1550
1594
  if (expandable) {
1551
- return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_material16.Box, { display: "flex", alignItems: "center", minWidth: 28, children: [
1552
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
1553
- import_material16.IconButton,
1595
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(import_material17.Box, { display: "flex", alignItems: "center", minWidth: 28, children: [
1596
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
1597
+ import_material17.IconButton,
1554
1598
  {
1555
1599
  "aria-label": expandLabel ?? placeholder,
1556
1600
  onClick: () => setIsExpanded(true),
1557
1601
  sx: { display: isExpanded || inputValue ? "none" : "flex" },
1558
- children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
1602
+ children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
1559
1603
  import_assets9.SearchIcon,
1560
1604
  {
1561
1605
  variant: "xs",
@@ -1565,8 +1609,8 @@ function BiampTableToolbarSearch({
1565
1609
  )
1566
1610
  }
1567
1611
  ),
1568
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
1569
- import_material16.Collapse,
1612
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
1613
+ import_material17.Collapse,
1570
1614
  {
1571
1615
  in: isExpanded || !!inputValue,
1572
1616
  orientation: "horizontal",
@@ -1579,6 +1623,155 @@ function BiampTableToolbarSearch({
1579
1623
  return textField;
1580
1624
  }
1581
1625
 
1626
+ // src/BiampTable/useBiampServerSideTable.ts
1627
+ var import_react_table2 = require("@tanstack/react-table");
1628
+ var import_react10 = require("react");
1629
+
1630
+ // src/BiampTable/serverSideTableUtils.ts
1631
+ function orderToSorting(order, fieldToColumnId) {
1632
+ if (!order) return [];
1633
+ const id = fieldToColumnId?.[order.field] ?? order.field;
1634
+ return [{ id, desc: order.desc ?? false }];
1635
+ }
1636
+ function sortingToOrder(sorting, columnIdToField) {
1637
+ if (sorting.length === 0) return void 0;
1638
+ const { id, desc } = sorting[0];
1639
+ const field = columnIdToField?.[id] ?? id;
1640
+ return { field, desc };
1641
+ }
1642
+ function selectedIdsToRowSelection(ids) {
1643
+ const state = {};
1644
+ for (const id of ids) {
1645
+ state[id] = true;
1646
+ }
1647
+ return state;
1648
+ }
1649
+ function rowSelectionToSelectedIds(selection) {
1650
+ return Object.keys(selection).filter((key) => selection[key]);
1651
+ }
1652
+ function getOrderFieldMappings(columns) {
1653
+ const columnIdToField = {};
1654
+ const fieldToColumnId = {};
1655
+ for (const col of columns) {
1656
+ const orderField = col.meta?.orderField;
1657
+ if (col.id && orderField) {
1658
+ columnIdToField[col.id] = orderField;
1659
+ fieldToColumnId[orderField] = col.id;
1660
+ }
1661
+ }
1662
+ return { columnIdToField, fieldToColumnId };
1663
+ }
1664
+ function getDefaultColumnVisibilityFromDefs(columns) {
1665
+ const defaults = {};
1666
+ for (const col of columns) {
1667
+ if (col.id != null && col.meta?.defaultVisible !== void 0) {
1668
+ defaults[col.id] = col.meta.defaultVisible;
1669
+ }
1670
+ }
1671
+ return defaults;
1672
+ }
1673
+ function getDirtyColumnVisibility(visibility, defaults) {
1674
+ const dirty = {};
1675
+ for (const [id, visible] of Object.entries(visibility)) {
1676
+ if (visible !== (defaults[id] ?? true)) {
1677
+ dirty[id] = visible;
1678
+ }
1679
+ }
1680
+ return dirty;
1681
+ }
1682
+
1683
+ // src/BiampTable/useBiampServerSideTable.ts
1684
+ var coreRowModel = (0, import_react_table2.getCoreRowModel)();
1685
+ function useBiampServerSideTable({
1686
+ data,
1687
+ columns,
1688
+ getRowId = (row) => row.id,
1689
+ order,
1690
+ onOrderChange,
1691
+ page,
1692
+ rowsPerPage,
1693
+ onPageChange,
1694
+ rowCount,
1695
+ columnVisibility,
1696
+ onColumnVisibilityChange,
1697
+ selectedRowIds,
1698
+ onSelectedRowIdsChange,
1699
+ enableRowSelection
1700
+ }) {
1701
+ const defaultColumnVisibility = (0, import_react10.useMemo)(
1702
+ () => getDefaultColumnVisibilityFromDefs(columns),
1703
+ [columns]
1704
+ );
1705
+ const { columnIdToField, fieldToColumnId } = (0, import_react10.useMemo)(
1706
+ () => getOrderFieldMappings(columns),
1707
+ [columns]
1708
+ );
1709
+ const sorting = (0, import_react10.useMemo)(
1710
+ () => orderToSorting(order, fieldToColumnId),
1711
+ [order, fieldToColumnId]
1712
+ );
1713
+ const hasPagination = page != null && rowsPerPage != null;
1714
+ const pagination = (0, import_react10.useMemo)(
1715
+ () => hasPagination ? { pageIndex: page, pageSize: rowsPerPage } : void 0,
1716
+ [hasPagination, page, rowsPerPage]
1717
+ );
1718
+ const hasSelection = selectedRowIds != null;
1719
+ const rowSelection = (0, import_react10.useMemo)(
1720
+ () => hasSelection ? selectedIdsToRowSelection(selectedRowIds) : void 0,
1721
+ [hasSelection, selectedRowIds]
1722
+ );
1723
+ const mergedVisibility = (0, import_react10.useMemo)(
1724
+ () => toVisibilityState({
1725
+ ...defaultColumnVisibility,
1726
+ ...columnVisibility
1727
+ }),
1728
+ [defaultColumnVisibility, columnVisibility]
1729
+ );
1730
+ return (0, import_react_table2.useReactTable)({
1731
+ data,
1732
+ columns,
1733
+ getCoreRowModel: coreRowModel,
1734
+ getRowId,
1735
+ // Sorting — always manual for server-side tables
1736
+ manualSorting: true,
1737
+ sortDescFirst: false,
1738
+ state: {
1739
+ sorting,
1740
+ ...pagination && { pagination },
1741
+ columnVisibility: mergedVisibility,
1742
+ ...rowSelection && { rowSelection }
1743
+ },
1744
+ onSortingChange: onOrderChange ? (updater) => {
1745
+ const next = typeof updater === "function" ? updater(sorting) : updater;
1746
+ onOrderChange(sortingToOrder(next, columnIdToField));
1747
+ } : void 0,
1748
+ // Pagination — only when page/rowsPerPage are provided
1749
+ ...hasPagination && {
1750
+ manualPagination: true,
1751
+ rowCount: rowCount ?? 0,
1752
+ onPaginationChange: onPageChange ? (updater) => {
1753
+ const next = typeof updater === "function" ? updater(pagination) : updater;
1754
+ onPageChange(next.pageIndex);
1755
+ } : void 0
1756
+ },
1757
+ // Column visibility
1758
+ onColumnVisibilityChange: onColumnVisibilityChange ? (updater) => {
1759
+ const next = typeof updater === "function" ? updater(mergedVisibility) : updater;
1760
+ onColumnVisibilityChange(
1761
+ getDirtyColumnVisibility(next, defaultColumnVisibility)
1762
+ );
1763
+ } : void 0,
1764
+ // Row selection — only when selectedRowIds is provided
1765
+ ...hasSelection && {
1766
+ enableRowSelection: enableRowSelection ?? true,
1767
+ onRowSelectionChange: onSelectedRowIdsChange ? (updater) => {
1768
+ const next = typeof updater === "function" ? updater(rowSelection) : updater;
1769
+ onSelectedRowIdsChange(rowSelectionToSelectedIds(next));
1770
+ } : void 0
1771
+ }
1772
+ });
1773
+ }
1774
+
1582
1775
  // src/BiampTable/exportCsv.ts
1583
1776
  function exportToCsv(rows, columns, filename = "export") {
1584
1777
  const csvContent = buildCsvString(rows, columns);
@@ -1647,12 +1840,21 @@ function downloadCsv(csvContent, filename) {
1647
1840
  BiampTableToolbarExport,
1648
1841
  BiampTableToolbarFilters,
1649
1842
  BiampTableToolbarSearch,
1843
+ BiampTableTruncatedCell,
1650
1844
  BiampWrapper,
1651
1845
  buildCsvString,
1652
1846
  exportToCsv,
1653
1847
  getColumnVisibilityDirtyCount,
1654
1848
  getDefaultColumnVisibility,
1849
+ getDefaultColumnVisibilityFromDefs,
1850
+ getDirtyColumnVisibility,
1851
+ getOrderFieldMappings,
1852
+ orderToSorting,
1853
+ rowSelectionToSelectedIds,
1854
+ selectedIdsToRowSelection,
1855
+ sortingToOrder,
1655
1856
  toVisibilityState,
1857
+ useBiampServerSideTable,
1656
1858
  useDebouncedCallback
1657
1859
  });
1658
1860
  //# sourceMappingURL=index.cjs.map