@bwp-web/components 0.10.0 → 0.11.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.
Files changed (43) hide show
  1. package/dist/BiampTable/BiampTable.d.ts +27 -0
  2. package/dist/BiampTable/BiampTable.d.ts.map +1 -0
  3. package/dist/BiampTable/BiampTableCellActionButton.d.ts +13 -0
  4. package/dist/BiampTable/BiampTableCellActionButton.d.ts.map +1 -0
  5. package/dist/BiampTable/BiampTableColumnVisibility.d.ts +18 -0
  6. package/dist/BiampTable/BiampTableColumnVisibility.d.ts.map +1 -0
  7. package/dist/BiampTable/BiampTableContainer.d.ts +9 -0
  8. package/dist/BiampTable/BiampTableContainer.d.ts.map +1 -0
  9. package/dist/BiampTable/BiampTableEmptyState.d.ts +4 -0
  10. package/dist/BiampTable/BiampTableEmptyState.d.ts.map +1 -0
  11. package/dist/BiampTable/BiampTableErrorState.d.ts +4 -0
  12. package/dist/BiampTable/BiampTableErrorState.d.ts.map +1 -0
  13. package/dist/BiampTable/BiampTablePagination.d.ts +14 -0
  14. package/dist/BiampTable/BiampTablePagination.d.ts.map +1 -0
  15. package/dist/BiampTable/BiampTableStatusMessage.d.ts +14 -0
  16. package/dist/BiampTable/BiampTableStatusMessage.d.ts.map +1 -0
  17. package/dist/BiampTable/BiampTableToolbar.d.ts +4 -0
  18. package/dist/BiampTable/BiampTableToolbar.d.ts.map +1 -0
  19. package/dist/BiampTable/BiampTableToolbarActionButton.d.ts +12 -0
  20. package/dist/BiampTable/BiampTableToolbarActionButton.d.ts.map +1 -0
  21. package/dist/BiampTable/BiampTableToolbarActions.d.ts +4 -0
  22. package/dist/BiampTable/BiampTableToolbarActions.d.ts.map +1 -0
  23. package/dist/BiampTable/BiampTableToolbarExport.d.ts +13 -0
  24. package/dist/BiampTable/BiampTableToolbarExport.d.ts.map +1 -0
  25. package/dist/BiampTable/BiampTableToolbarFilters.d.ts +28 -0
  26. package/dist/BiampTable/BiampTableToolbarFilters.d.ts.map +1 -0
  27. package/dist/BiampTable/BiampTableToolbarSearch.d.ts +19 -0
  28. package/dist/BiampTable/BiampTableToolbarSearch.d.ts.map +1 -0
  29. package/dist/BiampTable/index.d.ts +16 -0
  30. package/dist/BiampTable/index.d.ts.map +1 -0
  31. package/dist/BiampTable/tanstack-meta.d.ts +10 -0
  32. package/dist/BiampTable/tanstack-meta.d.ts.map +1 -0
  33. package/dist/BiampTable/useDebouncedCallback.d.ts +9 -0
  34. package/dist/BiampTable/useDebouncedCallback.d.ts.map +1 -0
  35. package/dist/BiampTable/useLoadingDelay.d.ts +17 -0
  36. package/dist/BiampTable/useLoadingDelay.d.ts.map +1 -0
  37. package/dist/index.cjs +867 -2
  38. package/dist/index.cjs.map +1 -1
  39. package/dist/index.d.ts +1 -0
  40. package/dist/index.d.ts.map +1 -1
  41. package/dist/index.js +886 -1
  42. package/dist/index.js.map +1 -1
  43. package/package.json +6 -2
package/dist/index.js CHANGED
@@ -462,7 +462,876 @@ function BiampLayout({
462
462
  }
463
463
  );
464
464
  }
465
+
466
+ // src/BiampTable/BiampTable.tsx
467
+ import {
468
+ Box as Box3,
469
+ Checkbox,
470
+ Table as MuiTable,
471
+ TableBody,
472
+ TableCell,
473
+ TableContainer,
474
+ TableHead,
475
+ TableRow,
476
+ TableSortLabel
477
+ } from "@mui/material";
478
+ import {
479
+ DropdownChevronDownIcon,
480
+ DropdownChevronUpIcon
481
+ } from "@bwp-web/assets";
482
+ import { flexRender } from "@tanstack/react-table";
483
+
484
+ // src/BiampTable/BiampTableEmptyState.tsx
485
+ import { NoResultsIcon } from "@bwp-web/assets";
486
+
487
+ // src/BiampTable/BiampTableStatusMessage.tsx
488
+ import { Stack as Stack5, Typography as Typography2 } from "@mui/material";
489
+ import { cloneElement } from "react";
490
+ import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
491
+ function BiampTableStatusMessage({
492
+ icon,
493
+ title,
494
+ description,
495
+ children,
496
+ ...stackProps
497
+ }) {
498
+ return /* @__PURE__ */ jsxs4(Stack5, { alignItems: "center", gap: 2, ...stackProps, children: [
499
+ cloneElement(icon, {
500
+ "aria-hidden": true,
501
+ sx: { width: 56, height: 56, ...icon.props.sx }
502
+ }),
503
+ /* @__PURE__ */ jsx4(Typography2, { variant: "h2", children: title }),
504
+ description && /* @__PURE__ */ jsx4(Typography2, { variant: "body1", children: description }),
505
+ children
506
+ ] });
507
+ }
508
+
509
+ // src/BiampTable/BiampTableEmptyState.tsx
510
+ import { jsx as jsx5 } from "react/jsx-runtime";
511
+ function BiampTableEmptyState({
512
+ icon = /* @__PURE__ */ jsx5(NoResultsIcon, {}),
513
+ title = "Nothing to show",
514
+ ...rest
515
+ }) {
516
+ return /* @__PURE__ */ jsx5(
517
+ BiampTableStatusMessage,
518
+ {
519
+ role: "status",
520
+ icon,
521
+ title,
522
+ ...rest
523
+ }
524
+ );
525
+ }
526
+
527
+ // src/BiampTable/BiampTableErrorState.tsx
528
+ import { ServiceNotReachableIcon } from "@bwp-web/assets";
529
+ import { jsx as jsx6 } from "react/jsx-runtime";
530
+ function BiampTableErrorState({
531
+ icon = /* @__PURE__ */ jsx6(ServiceNotReachableIcon, {}),
532
+ title = "Failed to load",
533
+ ...rest
534
+ }) {
535
+ return /* @__PURE__ */ jsx6(BiampTableStatusMessage, { role: "alert", icon, title, ...rest });
536
+ }
537
+
538
+ // src/BiampTable/useLoadingDelay.ts
539
+ import { useEffect, useRef, useState } from "react";
540
+ function useLoadingDelay(loading, { delay = 150, minDuration = 500 } = {}) {
541
+ const [status, setStatus] = useState("idle");
542
+ const timeoutRef = useRef(null);
543
+ function clearPending() {
544
+ if (timeoutRef.current !== null) {
545
+ clearTimeout(timeoutRef.current);
546
+ timeoutRef.current = null;
547
+ }
548
+ }
549
+ useEffect(() => {
550
+ if (loading && status === "idle") {
551
+ clearPending();
552
+ timeoutRef.current = setTimeout(() => {
553
+ timeoutRef.current = setTimeout(() => {
554
+ setStatus("ending");
555
+ }, minDuration);
556
+ setStatus("loading");
557
+ }, delay);
558
+ setStatus("delaying");
559
+ }
560
+ if (!loading && status !== "loading") {
561
+ clearPending();
562
+ setStatus("idle");
563
+ }
564
+ }, [loading, delay, minDuration, status]);
565
+ useEffect(() => clearPending, []);
566
+ return status === "loading" || status === "ending";
567
+ }
568
+
569
+ // src/BiampTable/BiampTable.tsx
570
+ import { jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
571
+ function BiampTable({
572
+ table,
573
+ onRowClick,
574
+ isRowClickable,
575
+ loading,
576
+ error,
577
+ empty,
578
+ hideSelectAll,
579
+ getRowLabel,
580
+ sx,
581
+ ...boxProps
582
+ }) {
583
+ const enableRowSelection = table.options.enableRowSelection === true || typeof table.options.enableRowSelection === "function";
584
+ const tableMinWidth = table.getVisibleLeafColumns().reduce(
585
+ (sum, col) => {
586
+ const mw = col.columnDef.meta?.minWidth;
587
+ return sum + (typeof mw === "number" ? mw : 40);
588
+ },
589
+ enableRowSelection ? 48 : 0
590
+ );
591
+ const totalColumns = table.getVisibleLeafColumns().length + (enableRowSelection ? 1 : 0);
592
+ const showLoading = useLoadingDelay(!!loading);
593
+ const rows = table.getRowModel().rows;
594
+ const showError = !!error;
595
+ const showEmpty = !showError && rows.length === 0;
596
+ return /* @__PURE__ */ jsx7(
597
+ TableContainer,
598
+ {
599
+ component: Box3,
600
+ ...boxProps,
601
+ sx: {
602
+ display: "flex",
603
+ flexDirection: "column",
604
+ height: "100%",
605
+ overflow: "auto",
606
+ overscrollBehavior: "none",
607
+ ...sx
608
+ },
609
+ children: /* @__PURE__ */ jsxs5(
610
+ MuiTable,
611
+ {
612
+ "aria-busy": showLoading || void 0,
613
+ sx: {
614
+ minWidth: tableMinWidth,
615
+ height: showError || showEmpty ? "100%" : void 0
616
+ },
617
+ children: [
618
+ /* @__PURE__ */ jsx7(TableHead, { children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ jsxs5(TableRow, { children: [
619
+ enableRowSelection && /* @__PURE__ */ jsx7(
620
+ TableCell,
621
+ {
622
+ padding: "checkbox",
623
+ sx: {
624
+ position: "sticky",
625
+ left: 0,
626
+ zIndex: 3,
627
+ bgcolor: "background.paper"
628
+ },
629
+ children: !hideSelectAll && /* @__PURE__ */ jsx7(
630
+ Checkbox,
631
+ {
632
+ checked: table.getIsAllPageRowsSelected(),
633
+ indeterminate: table.getIsSomePageRowsSelected(),
634
+ onChange: table.getToggleAllPageRowsSelectedHandler(),
635
+ slotProps: { input: { "aria-label": "Select all rows" } }
636
+ }
637
+ )
638
+ }
639
+ ),
640
+ headerGroup.headers.map((header) => {
641
+ const sticky = header.column.columnDef.meta?.sticky;
642
+ return /* @__PURE__ */ jsx7(
643
+ TableCell,
644
+ {
645
+ sortDirection: header.column.getIsSorted() || false,
646
+ ...header.column.getCanSort() && {
647
+ "aria-sort": header.column.getIsSorted() ? header.column.getIsSorted() === "asc" ? "ascending" : "descending" : "none"
648
+ },
649
+ sx: {
650
+ minWidth: header.column.columnDef.meta?.minWidth ?? 40,
651
+ ...sticky && {
652
+ position: "sticky",
653
+ [sticky]: 0,
654
+ zIndex: 3,
655
+ bgcolor: "background.paper"
656
+ }
657
+ },
658
+ children: header.isPlaceholder ? null : header.column.getCanSort() ? /* @__PURE__ */ jsx7(
659
+ TableSortLabel,
660
+ {
661
+ active: !!header.column.getIsSorted(),
662
+ direction: header.column.getIsSorted() || "asc",
663
+ onClick: header.column.getToggleSortingHandler(),
664
+ ...header.column.getIsSorted() && {
665
+ IconComponent: header.column.getIsSorted() === "asc" ? DropdownChevronUpIcon : DropdownChevronDownIcon
666
+ },
667
+ children: flexRender(
668
+ header.column.columnDef.header,
669
+ header.getContext()
670
+ )
671
+ }
672
+ ) : flexRender(
673
+ header.column.columnDef.header,
674
+ header.getContext()
675
+ )
676
+ },
677
+ header.id
678
+ );
679
+ })
680
+ ] }, headerGroup.id)) }),
681
+ /* @__PURE__ */ jsx7(TableBody, { sx: { opacity: showLoading ? 0.3 : 1 }, children: showError ? /* @__PURE__ */ jsx7(TableRow, { children: /* @__PURE__ */ jsx7(
682
+ TableCell,
683
+ {
684
+ colSpan: totalColumns,
685
+ sx: {
686
+ textAlign: "center",
687
+ verticalAlign: "middle",
688
+ height: "100%"
689
+ },
690
+ children: error === true ? /* @__PURE__ */ jsx7(BiampTableErrorState, {}) : error
691
+ }
692
+ ) }) : showEmpty ? /* @__PURE__ */ jsx7(TableRow, { children: /* @__PURE__ */ jsx7(
693
+ TableCell,
694
+ {
695
+ colSpan: totalColumns,
696
+ sx: {
697
+ textAlign: "center",
698
+ verticalAlign: "middle",
699
+ height: "100%"
700
+ },
701
+ children: empty && empty !== true ? empty : /* @__PURE__ */ jsx7(BiampTableEmptyState, {})
702
+ }
703
+ ) }) : rows.map((row) => {
704
+ const clickable = onRowClick ? isRowClickable ? isRowClickable(row.original) : true : false;
705
+ return /* @__PURE__ */ jsxs5(
706
+ TableRow,
707
+ {
708
+ hover: clickable,
709
+ selected: enableRowSelection ? row.getIsSelected() : void 0,
710
+ role: clickable ? "button" : void 0,
711
+ tabIndex: clickable ? 0 : void 0,
712
+ sx: { cursor: clickable ? "pointer" : void 0 },
713
+ onClick: clickable && onRowClick ? () => onRowClick(row.original) : void 0,
714
+ onKeyDown: clickable && onRowClick ? (e) => {
715
+ if (e.key === "Enter" || e.key === " ") {
716
+ e.preventDefault();
717
+ onRowClick(row.original);
718
+ }
719
+ } : void 0,
720
+ children: [
721
+ enableRowSelection && /* @__PURE__ */ jsx7(
722
+ TableCell,
723
+ {
724
+ padding: "checkbox",
725
+ sx: {
726
+ position: "sticky",
727
+ left: 0,
728
+ zIndex: 2,
729
+ bgcolor: "background.paper",
730
+ ".MuiTableRow-hover:hover > &, .Mui-selected > &": {
731
+ bgcolor: ({ palette }) => palette.mode === "dark" ? palette.grey[800] : palette.grey[100]
732
+ }
733
+ },
734
+ children: /* @__PURE__ */ jsx7(
735
+ Checkbox,
736
+ {
737
+ checked: row.getIsSelected(),
738
+ disabled: !row.getCanSelect(),
739
+ onChange: row.getToggleSelectedHandler(),
740
+ onClick: (e) => e.stopPropagation(),
741
+ slotProps: {
742
+ input: {
743
+ "aria-label": getRowLabel ? `Select ${getRowLabel(row.original)}` : `Select row ${row.index + 1}`
744
+ }
745
+ }
746
+ }
747
+ )
748
+ }
749
+ ),
750
+ row.getVisibleCells().map((cell) => {
751
+ const sticky = cell.column.columnDef.meta?.sticky;
752
+ return /* @__PURE__ */ jsx7(
753
+ TableCell,
754
+ {
755
+ sx: {
756
+ minWidth: cell.column.columnDef.meta?.minWidth ?? 40,
757
+ ...sticky && {
758
+ position: "sticky",
759
+ [sticky]: 0,
760
+ zIndex: 2,
761
+ bgcolor: "background.paper",
762
+ ".MuiTableRow-hover:hover > &, .Mui-selected > &": {
763
+ bgcolor: ({ palette }) => palette.mode === "dark" ? palette.grey[800] : palette.grey[100]
764
+ }
765
+ }
766
+ },
767
+ children: flexRender(
768
+ cell.column.columnDef.cell,
769
+ cell.getContext()
770
+ )
771
+ },
772
+ cell.id
773
+ );
774
+ })
775
+ ]
776
+ },
777
+ row.id
778
+ );
779
+ }) })
780
+ ]
781
+ }
782
+ )
783
+ }
784
+ );
785
+ }
786
+
787
+ // src/BiampTable/BiampTableContainer.tsx
788
+ import { Stack as Stack6 } from "@mui/material";
789
+ import { jsx as jsx8 } from "react/jsx-runtime";
790
+ function BiampTableContainer({
791
+ withBorderTop = true,
792
+ withBorderBottom = false,
793
+ children,
794
+ ...props
795
+ }) {
796
+ return /* @__PURE__ */ jsx8(
797
+ Stack6,
798
+ {
799
+ direction: "column",
800
+ height: "100%",
801
+ overflow: "hidden",
802
+ py: { xs: 0, md: 1.5 },
803
+ gap: { xs: 0, md: 1 },
804
+ borderTop: withBorderTop ? ({ palette }) => `0.6px solid ${palette.divider}` : void 0,
805
+ borderBottom: withBorderBottom ? ({ palette }) => `0.6px solid ${palette.divider}` : void 0,
806
+ ...props,
807
+ children
808
+ }
809
+ );
810
+ }
811
+
812
+ // src/BiampTable/BiampTableCellActionButton.tsx
813
+ import { IconButton, Tooltip } from "@mui/material";
814
+ import { jsx as jsx9 } from "react/jsx-runtime";
815
+ function BiampTableCellActionButton({ label, icon, ...props }) {
816
+ return /* @__PURE__ */ jsx9(
817
+ Tooltip,
818
+ {
819
+ title: label,
820
+ placement: "top",
821
+ enterDelay: 500,
822
+ enterNextDelay: 500,
823
+ disableInteractive: true,
824
+ children: /* @__PURE__ */ jsx9("span", { children: /* @__PURE__ */ jsx9(IconButton, { "aria-label": label, ...props, children: icon }) })
825
+ }
826
+ );
827
+ }
828
+
829
+ // src/BiampTable/BiampTableColumnVisibility.tsx
830
+ import {
831
+ alpha as alpha2,
832
+ Box as Box4,
833
+ Checkbox as Checkbox2,
834
+ Divider,
835
+ List,
836
+ ListItem,
837
+ Popover as Popover2,
838
+ Typography as Typography3
839
+ } from "@mui/material";
840
+ import { useEffect as useEffect2, useRef as useRef2 } from "react";
841
+ import { jsx as jsx10, jsxs as jsxs6 } from "react/jsx-runtime";
842
+ function getColumnVisibilityDirtyCount(table, defaultVisibility = {}) {
843
+ const current = table.getState().columnVisibility;
844
+ let count = 0;
845
+ for (const col of table.getAllLeafColumns()) {
846
+ const isVisible = current[col.id] ?? true;
847
+ const wasVisible = defaultVisibility[col.id] ?? true;
848
+ if (isVisible !== wasVisible) count++;
849
+ }
850
+ return count;
851
+ }
852
+ var columnListItemSx = {
853
+ py: 0,
854
+ pr: 1.5,
855
+ pl: 0,
856
+ alignItems: "center",
857
+ cursor: "pointer",
858
+ "&:hover": {
859
+ backgroundColor: ({ palette }) => palette.mode === "dark" ? palette.grey[800] : palette.grey[100]
860
+ }
861
+ };
862
+ function BiampTableColumnVisibility({
863
+ table,
864
+ onChange,
865
+ showAllLabel = "Show all",
866
+ anchorEl,
867
+ anchorOrigin = { vertical: "bottom", horizontal: "right" },
868
+ transformOrigin = { vertical: "top", horizontal: "right" },
869
+ slotProps,
870
+ ...popoverProps
871
+ }) {
872
+ const visibility = table.getState().columnVisibility;
873
+ const prevVisibilityRef = useRef2(visibility);
874
+ useEffect2(() => {
875
+ if (prevVisibilityRef.current === visibility) return;
876
+ prevVisibilityRef.current = visibility;
877
+ onChange?.(visibility);
878
+ }, [visibility, onChange]);
879
+ const allVisible = table.getAllLeafColumns().every((col) => col.getIsVisible());
880
+ const someVisible = table.getAllLeafColumns().some((col) => col.getIsVisible());
881
+ return /* @__PURE__ */ jsx10(
882
+ Popover2,
883
+ {
884
+ anchorEl,
885
+ open: Boolean(anchorEl),
886
+ anchorOrigin,
887
+ transformOrigin,
888
+ slotProps: {
889
+ ...slotProps,
890
+ paper: {
891
+ sx: ({ palette }) => ({
892
+ borderRadius: "6px",
893
+ backgroundImage: "none",
894
+ border: `0.6px solid ${palette.dividers.secondary}`,
895
+ boxShadow: `0px 1px 1px 0px ${alpha2(palette.common.black, 0.05)}`,
896
+ minWidth: "150px"
897
+ }),
898
+ ...slotProps?.paper ?? {}
899
+ }
900
+ },
901
+ ...popoverProps,
902
+ children: /* @__PURE__ */ jsxs6(List, { dense: true, disablePadding: true, children: [
903
+ /* @__PURE__ */ jsxs6(
904
+ ListItem,
905
+ {
906
+ sx: columnListItemSx,
907
+ onClick: () => table.toggleAllColumnsVisible(!allVisible),
908
+ children: [
909
+ /* @__PURE__ */ jsx10(
910
+ Checkbox2,
911
+ {
912
+ checked: allVisible,
913
+ indeterminate: !allVisible && someVisible,
914
+ size: "small",
915
+ slotProps: { input: { "aria-label": `${showAllLabel} columns` } }
916
+ }
917
+ ),
918
+ /* @__PURE__ */ jsx10(Typography3, { variant: "caption", children: showAllLabel })
919
+ ]
920
+ }
921
+ ),
922
+ /* @__PURE__ */ jsx10(Divider, {}),
923
+ /* @__PURE__ */ jsx10(Box4, { sx: { maxHeight: 340, overflow: "auto" }, children: table.getAllLeafColumns().map((column) => {
924
+ const columnName = typeof column.columnDef.header === "string" ? column.columnDef.header : column.id;
925
+ return /* @__PURE__ */ jsxs6(
926
+ ListItem,
927
+ {
928
+ sx: columnListItemSx,
929
+ onClick: column.getToggleVisibilityHandler(),
930
+ children: [
931
+ /* @__PURE__ */ jsx10(
932
+ Checkbox2,
933
+ {
934
+ checked: column.getIsVisible(),
935
+ size: "small",
936
+ slotProps: {
937
+ input: { "aria-label": `Show ${columnName}` }
938
+ }
939
+ }
940
+ ),
941
+ /* @__PURE__ */ jsx10(Typography3, { variant: "caption", children: columnName })
942
+ ]
943
+ },
944
+ column.id
945
+ );
946
+ }) })
947
+ ] })
948
+ }
949
+ );
950
+ }
951
+
952
+ // src/BiampTable/BiampTablePagination.tsx
953
+ import { useRef as useRef3 } from "react";
954
+ import { Box as Box5, TablePagination } from "@mui/material";
955
+ import { jsx as jsx11 } from "react/jsx-runtime";
956
+ function BiampTablePagination({
957
+ table,
958
+ rowsPerPageOptions,
959
+ loading,
960
+ autoHide = true,
961
+ ...boxProps
962
+ }) {
963
+ const rowCount = table.getRowCount();
964
+ const lastRowCountRef = useRef3(rowCount);
965
+ if (!loading && rowCount >= 0) {
966
+ lastRowCountRef.current = rowCount;
967
+ }
968
+ const stableCount = loading ? lastRowCountRef.current : rowCount;
969
+ const pageSize = table.getState().pagination.pageSize;
970
+ if (autoHide && !loading && stableCount <= pageSize) return null;
971
+ return /* @__PURE__ */ jsx11(Box5, { ...boxProps, children: /* @__PURE__ */ jsx11(
972
+ TablePagination,
973
+ {
974
+ component: "div",
975
+ count: stableCount,
976
+ page: table.getState().pagination.pageIndex,
977
+ rowsPerPage: table.getState().pagination.pageSize,
978
+ onPageChange: (_, page) => table.setPageIndex(page),
979
+ onRowsPerPageChange: (e) => {
980
+ table.setPageSize(Number(e.target.value));
981
+ table.setPageIndex(0);
982
+ },
983
+ rowsPerPageOptions: rowsPerPageOptions ?? [],
984
+ showFirstButton: true,
985
+ showLastButton: true
986
+ }
987
+ ) });
988
+ }
989
+
990
+ // src/BiampTable/BiampTableToolbar.tsx
991
+ import { Box as Box6 } from "@mui/material";
992
+ import { jsx as jsx12 } from "react/jsx-runtime";
993
+ function BiampTableToolbar({
994
+ children,
995
+ ...props
996
+ }) {
997
+ return /* @__PURE__ */ jsx12(
998
+ Box6,
999
+ {
1000
+ role: "toolbar",
1001
+ display: "flex",
1002
+ justifyContent: "space-between",
1003
+ alignItems: "center",
1004
+ gap: 1,
1005
+ ...props,
1006
+ children
1007
+ }
1008
+ );
1009
+ }
1010
+
1011
+ // src/BiampTable/BiampTableToolbarActionButton.tsx
1012
+ import {
1013
+ Badge,
1014
+ IconButton as IconButton2
1015
+ } from "@mui/material";
1016
+ import { jsx as jsx13 } from "react/jsx-runtime";
1017
+ function BiampTableToolbarActionButton({
1018
+ label,
1019
+ icon,
1020
+ badgeContent,
1021
+ ...props
1022
+ }) {
1023
+ const showBadge = badgeContent != null && badgeContent !== 0;
1024
+ return /* @__PURE__ */ jsx13(
1025
+ IconButton2,
1026
+ {
1027
+ "aria-label": showBadge ? `${label} (${badgeContent})` : label,
1028
+ ...props,
1029
+ children: showBadge ? /* @__PURE__ */ jsx13(
1030
+ Badge,
1031
+ {
1032
+ badgeContent,
1033
+ color: "info",
1034
+ variant: "dot",
1035
+ sx: {
1036
+ "& .MuiBadge-badge": {
1037
+ width: 6,
1038
+ height: 6,
1039
+ minWidth: 6,
1040
+ borderRadius: "50%",
1041
+ top: 0,
1042
+ right: -3
1043
+ }
1044
+ },
1045
+ children: icon
1046
+ }
1047
+ ) : icon
1048
+ }
1049
+ );
1050
+ }
1051
+
1052
+ // src/BiampTable/BiampTableToolbarActions.tsx
1053
+ import { Box as Box7 } from "@mui/material";
1054
+ import { jsx as jsx14 } from "react/jsx-runtime";
1055
+ function BiampTableToolbarActions({
1056
+ children,
1057
+ ...props
1058
+ }) {
1059
+ return /* @__PURE__ */ jsx14(Box7, { display: "flex", alignItems: "center", gap: 1, ml: "auto", ...props, children });
1060
+ }
1061
+
1062
+ // src/BiampTable/BiampTableToolbarExport.tsx
1063
+ import { CircularProgress } from "@mui/material";
1064
+ import { DownloadIcon } from "@bwp-web/assets";
1065
+ import { jsx as jsx15 } from "react/jsx-runtime";
1066
+ function BiampTableToolbarExport({
1067
+ onExport,
1068
+ loading,
1069
+ icon = /* @__PURE__ */ jsx15(DownloadIcon, { variant: "xs" }),
1070
+ label = "Export",
1071
+ ...props
1072
+ }) {
1073
+ return /* @__PURE__ */ jsx15(
1074
+ BiampTableToolbarActionButton,
1075
+ {
1076
+ label: loading ? `${label}, loading` : label,
1077
+ icon: loading ? /* @__PURE__ */ jsx15(CircularProgress, { size: 20, color: "inherit" }) : icon,
1078
+ disabled: loading,
1079
+ onClick: onExport,
1080
+ ...props
1081
+ }
1082
+ );
1083
+ }
1084
+
1085
+ // src/BiampTable/BiampTableToolbarFilters.tsx
1086
+ import {
1087
+ Badge as Badge2,
1088
+ Box as Box8,
1089
+ Button,
1090
+ Divider as Divider2,
1091
+ Drawer,
1092
+ IconButton as IconButton3,
1093
+ Typography as Typography4
1094
+ } from "@mui/material";
1095
+ import { CloseIcon, FilterIcon } from "@bwp-web/assets";
1096
+ import { useId, useState as useState2 } from "react";
1097
+ import { Fragment, jsx as jsx16, jsxs as jsxs7 } from "react/jsx-runtime";
1098
+ function BiampTableToolbarFilters({
1099
+ activeFilterCount,
1100
+ children,
1101
+ onReset,
1102
+ onApply,
1103
+ icon = /* @__PURE__ */ jsx16(FilterIcon, { variant: "xs" }),
1104
+ title = "Filters",
1105
+ resetLabel = "Clear filters",
1106
+ applyLabel = "Apply",
1107
+ closeLabel = "Close",
1108
+ buttonLabel = "Filters",
1109
+ DrawerProps: drawerProps
1110
+ }) {
1111
+ const [open, setOpen] = useState2(false);
1112
+ const titleId = useId();
1113
+ function handleClose() {
1114
+ onApply?.();
1115
+ setOpen(false);
1116
+ }
1117
+ return /* @__PURE__ */ jsxs7(Fragment, { children: [
1118
+ /* @__PURE__ */ jsx16(
1119
+ BiampTableToolbarActionButton,
1120
+ {
1121
+ label: buttonLabel,
1122
+ icon,
1123
+ badgeContent: activeFilterCount,
1124
+ onClick: () => setOpen(true)
1125
+ }
1126
+ ),
1127
+ /* @__PURE__ */ jsx16(
1128
+ Drawer,
1129
+ {
1130
+ anchor: "right",
1131
+ open,
1132
+ onClose: handleClose,
1133
+ "aria-labelledby": titleId,
1134
+ ...drawerProps,
1135
+ PaperProps: {
1136
+ sx: { width: { xs: "100%", sm: 480 } },
1137
+ ...drawerProps?.PaperProps
1138
+ },
1139
+ children: /* @__PURE__ */ jsxs7(
1140
+ Box8,
1141
+ {
1142
+ height: "100%",
1143
+ display: "flex",
1144
+ flexDirection: "column",
1145
+ justifyContent: "space-between",
1146
+ children: [
1147
+ /* @__PURE__ */ jsxs7(Box8, { children: [
1148
+ /* @__PURE__ */ jsxs7(
1149
+ Box8,
1150
+ {
1151
+ display: "flex",
1152
+ justifyContent: "space-between",
1153
+ alignItems: "center",
1154
+ px: 3.5,
1155
+ py: 2.5,
1156
+ children: [
1157
+ /* @__PURE__ */ jsxs7(Typography4, { id: titleId, variant: "h2", children: [
1158
+ title,
1159
+ /* @__PURE__ */ jsx16(
1160
+ Badge2,
1161
+ {
1162
+ badgeContent: activeFilterCount,
1163
+ color: "secondary",
1164
+ sx: { ml: 1.5, mb: 0.5 }
1165
+ }
1166
+ )
1167
+ ] }),
1168
+ /* @__PURE__ */ jsx16(
1169
+ IconButton3,
1170
+ {
1171
+ size: "medium",
1172
+ onClick: handleClose,
1173
+ "aria-label": closeLabel,
1174
+ children: /* @__PURE__ */ jsx16(CloseIcon, {})
1175
+ }
1176
+ )
1177
+ ]
1178
+ }
1179
+ ),
1180
+ /* @__PURE__ */ jsx16(Divider2, {}),
1181
+ /* @__PURE__ */ jsx16(
1182
+ Box8,
1183
+ {
1184
+ role: "group",
1185
+ "aria-label": "Filter options",
1186
+ display: "flex",
1187
+ flexDirection: "column",
1188
+ gap: 2,
1189
+ p: 3.5,
1190
+ overflow: "auto",
1191
+ children
1192
+ }
1193
+ )
1194
+ ] }),
1195
+ /* @__PURE__ */ jsxs7(Box8, { display: "flex", children: [
1196
+ /* @__PURE__ */ jsx16(
1197
+ Button,
1198
+ {
1199
+ variant: "overlay",
1200
+ color: "secondary",
1201
+ fullWidth: true,
1202
+ onClick: onReset,
1203
+ disabled: activeFilterCount === 0,
1204
+ children: resetLabel
1205
+ }
1206
+ ),
1207
+ /* @__PURE__ */ jsx16(
1208
+ Button,
1209
+ {
1210
+ variant: "overlay",
1211
+ color: "primary",
1212
+ fullWidth: true,
1213
+ onClick: handleClose,
1214
+ children: applyLabel
1215
+ }
1216
+ )
1217
+ ] })
1218
+ ]
1219
+ }
1220
+ )
1221
+ }
1222
+ )
1223
+ ] });
1224
+ }
1225
+
1226
+ // src/BiampTable/BiampTableToolbarSearch.tsx
1227
+ import {
1228
+ IconButton as IconButton4,
1229
+ InputAdornment as InputAdornment2,
1230
+ TextField as TextField2
1231
+ } from "@mui/material";
1232
+ import { CloseIcon as CloseIcon2, SearchIcon as SearchIcon2 } from "@bwp-web/assets";
1233
+ import { useEffect as useEffect4, useState as useState3 } from "react";
1234
+
1235
+ // src/BiampTable/useDebouncedCallback.ts
1236
+ import { useCallback, useEffect as useEffect3, useRef as useRef4 } from "react";
1237
+ var BIAMP_TABLE_DEBOUNCE_DELAY = 300;
1238
+ function useDebouncedCallback(callback, delay = BIAMP_TABLE_DEBOUNCE_DELAY) {
1239
+ const timeoutRef = useRef4(null);
1240
+ const callbackRef = useRef4(callback);
1241
+ callbackRef.current = callback;
1242
+ useEffect3(() => {
1243
+ return () => {
1244
+ if (timeoutRef.current !== null) clearTimeout(timeoutRef.current);
1245
+ };
1246
+ }, []);
1247
+ return useCallback(
1248
+ (...args) => {
1249
+ if (timeoutRef.current !== null) clearTimeout(timeoutRef.current);
1250
+ timeoutRef.current = setTimeout(
1251
+ () => callbackRef.current(...args),
1252
+ delay
1253
+ );
1254
+ },
1255
+ [delay]
1256
+ );
1257
+ }
1258
+
1259
+ // src/BiampTable/BiampTableToolbarSearch.tsx
1260
+ import { jsx as jsx17 } from "react/jsx-runtime";
1261
+ var searchFieldSx = {
1262
+ "& .MuiInputBase-root": {
1263
+ height: 36,
1264
+ minHeight: 36
1265
+ }
1266
+ };
1267
+ function BiampTableToolbarSearch({
1268
+ onChange,
1269
+ defaultValue = "",
1270
+ debounceDelay = BIAMP_TABLE_DEBOUNCE_DELAY,
1271
+ maxLength = 120,
1272
+ maxWidth = 280,
1273
+ placeholder = "Search",
1274
+ clearLabel = "Clear search",
1275
+ sx,
1276
+ ...textFieldProps
1277
+ }) {
1278
+ const [inputValue, setInputValue] = useState3(defaultValue);
1279
+ const debouncedOnChange = useDebouncedCallback(onChange, debounceDelay);
1280
+ useEffect4(() => {
1281
+ setInputValue(defaultValue);
1282
+ }, [defaultValue]);
1283
+ const handleChange = (e) => {
1284
+ setInputValue(e.target.value);
1285
+ debouncedOnChange(e.target.value);
1286
+ };
1287
+ const handleClear = () => {
1288
+ setInputValue("");
1289
+ debouncedOnChange("");
1290
+ };
1291
+ return /* @__PURE__ */ jsx17(
1292
+ TextField2,
1293
+ {
1294
+ name: "search",
1295
+ type: "text",
1296
+ placeholder,
1297
+ slotProps: {
1298
+ htmlInput: { maxLength, "aria-label": placeholder },
1299
+ input: {
1300
+ startAdornment: /* @__PURE__ */ jsx17(InputAdornment2, { position: "start", sx: { ml: 1 }, children: /* @__PURE__ */ jsx17(
1301
+ SearchIcon2,
1302
+ {
1303
+ variant: "xs",
1304
+ color: "inherit",
1305
+ sx: { width: 16, height: 16 }
1306
+ }
1307
+ ) }),
1308
+ endAdornment: inputValue ? /* @__PURE__ */ jsx17(InputAdornment2, { position: "end", children: /* @__PURE__ */ jsx17(
1309
+ IconButton4,
1310
+ {
1311
+ size: "small",
1312
+ onClick: handleClear,
1313
+ "aria-label": clearLabel,
1314
+ sx: { mr: 0.5 },
1315
+ children: /* @__PURE__ */ jsx17(CloseIcon2, { variant: "xs", sx: { width: 20, height: 20 } })
1316
+ }
1317
+ ) }) : null
1318
+ }
1319
+ },
1320
+ fullWidth: true,
1321
+ sx: [
1322
+ searchFieldSx,
1323
+ { maxWidth },
1324
+ ...Array.isArray(sx) ? sx : sx ? [sx] : []
1325
+ ],
1326
+ variant: "outlined",
1327
+ value: inputValue,
1328
+ onChange: handleChange,
1329
+ ...textFieldProps
1330
+ }
1331
+ );
1332
+ }
465
1333
  export {
1334
+ BIAMP_TABLE_DEBOUNCE_DELAY,
466
1335
  BiampAppDialog,
467
1336
  BiampAppDialogItem,
468
1337
  BiampAppPopover,
@@ -478,6 +1347,22 @@ export {
478
1347
  BiampSidebarComponent,
479
1348
  BiampSidebarIcon,
480
1349
  BiampSidebarIconList,
481
- BiampWrapper
1350
+ BiampTable,
1351
+ BiampTableCellActionButton,
1352
+ BiampTableColumnVisibility,
1353
+ BiampTableContainer,
1354
+ BiampTableEmptyState,
1355
+ BiampTableErrorState,
1356
+ BiampTablePagination,
1357
+ BiampTableStatusMessage,
1358
+ BiampTableToolbar,
1359
+ BiampTableToolbarActionButton,
1360
+ BiampTableToolbarActions,
1361
+ BiampTableToolbarExport,
1362
+ BiampTableToolbarFilters,
1363
+ BiampTableToolbarSearch,
1364
+ BiampWrapper,
1365
+ getColumnVisibilityDirtyCount,
1366
+ useDebouncedCallback
482
1367
  };
483
1368
  //# sourceMappingURL=index.js.map