@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/BiampTable/BiampTable.d.ts +34 -12
- package/dist/BiampTable/BiampTable.d.ts.map +1 -1
- package/dist/BiampTable/BiampTableColumnVisibility.d.ts.map +1 -1
- package/dist/BiampTable/BiampTablePagination.d.ts.map +1 -1
- package/dist/BiampTable/BiampTableToolbarSearch.d.ts +11 -5
- package/dist/BiampTable/BiampTableToolbarSearch.d.ts.map +1 -1
- package/dist/BiampTable/BiampTableTruncatedCell.d.ts +11 -0
- package/dist/BiampTable/BiampTableTruncatedCell.d.ts.map +1 -0
- package/dist/BiampTable/index.d.ts +3 -0
- package/dist/BiampTable/index.d.ts.map +1 -1
- package/dist/BiampTable/serverSideTableUtils.d.ts +58 -0
- package/dist/BiampTable/serverSideTableUtils.d.ts.map +1 -0
- package/dist/BiampTable/tanstack-meta.d.ts +2 -0
- package/dist/BiampTable/tanstack-meta.d.ts.map +1 -1
- package/dist/BiampTable/useBiampServerSideTable.d.ts +43 -0
- package/dist/BiampTable/useBiampServerSideTable.d.ts.map +1 -0
- package/dist/index.cjs +464 -262
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +409 -213
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -465,7 +465,7 @@ function BiampLayout({
|
|
|
465
465
|
|
|
466
466
|
// src/BiampTable/BiampTable.tsx
|
|
467
467
|
import {
|
|
468
|
-
Box as
|
|
468
|
+
Box as Box4,
|
|
469
469
|
Checkbox,
|
|
470
470
|
IconButton,
|
|
471
471
|
Table as MuiTable,
|
|
@@ -482,7 +482,7 @@ import {
|
|
|
482
482
|
DropdownChevronUpIcon
|
|
483
483
|
} from "@bwp-web/assets";
|
|
484
484
|
import { flexRender } from "@tanstack/react-table";
|
|
485
|
-
import { useRef as
|
|
485
|
+
import { useRef as useRef3 } from "react";
|
|
486
486
|
|
|
487
487
|
// src/BiampTable/BiampTableEmptyState.tsx
|
|
488
488
|
import { NoResultsIcon } from "@bwp-web/assets";
|
|
@@ -498,7 +498,7 @@ function BiampTableStatusMessage({
|
|
|
498
498
|
children,
|
|
499
499
|
...stackProps
|
|
500
500
|
}) {
|
|
501
|
-
return /* @__PURE__ */ jsxs4(Stack5, { alignItems: "center", gap:
|
|
501
|
+
return /* @__PURE__ */ jsxs4(Stack5, { alignItems: "center", gap: 1.5, ...stackProps, children: [
|
|
502
502
|
cloneElement(icon, {
|
|
503
503
|
"aria-hidden": true,
|
|
504
504
|
sx: { width: 56, height: 56, ...icon.props.sx }
|
|
@@ -538,11 +538,56 @@ function BiampTableErrorState({
|
|
|
538
538
|
return /* @__PURE__ */ jsx6(BiampTableStatusMessage, { role: "alert", icon, title, ...rest });
|
|
539
539
|
}
|
|
540
540
|
|
|
541
|
+
// src/BiampTable/BiampTableTruncatedCell.tsx
|
|
542
|
+
import { Box as Box3, Tooltip } from "@mui/material";
|
|
543
|
+
import { useCallback, useRef, useState } from "react";
|
|
544
|
+
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
545
|
+
function BiampTableTruncatedCell({
|
|
546
|
+
children
|
|
547
|
+
}) {
|
|
548
|
+
const textRef = useRef(null);
|
|
549
|
+
const [open, setOpen] = useState(false);
|
|
550
|
+
const handleMouseEnter = useCallback(() => {
|
|
551
|
+
const el = textRef.current;
|
|
552
|
+
if (el && el.scrollWidth > el.clientWidth) {
|
|
553
|
+
setOpen(true);
|
|
554
|
+
}
|
|
555
|
+
}, []);
|
|
556
|
+
const handleMouseLeave = useCallback(() => {
|
|
557
|
+
setOpen(false);
|
|
558
|
+
}, []);
|
|
559
|
+
return /* @__PURE__ */ jsx7(
|
|
560
|
+
Tooltip,
|
|
561
|
+
{
|
|
562
|
+
title: children,
|
|
563
|
+
open,
|
|
564
|
+
arrow: true,
|
|
565
|
+
placement: "top",
|
|
566
|
+
disableInteractive: true,
|
|
567
|
+
children: /* @__PURE__ */ jsx7(
|
|
568
|
+
Box3,
|
|
569
|
+
{
|
|
570
|
+
ref: textRef,
|
|
571
|
+
onMouseEnter: handleMouseEnter,
|
|
572
|
+
onMouseLeave: handleMouseLeave,
|
|
573
|
+
sx: {
|
|
574
|
+
overflow: "hidden",
|
|
575
|
+
textOverflow: "ellipsis",
|
|
576
|
+
whiteSpace: "nowrap",
|
|
577
|
+
minWidth: 0
|
|
578
|
+
},
|
|
579
|
+
children
|
|
580
|
+
}
|
|
581
|
+
)
|
|
582
|
+
}
|
|
583
|
+
);
|
|
584
|
+
}
|
|
585
|
+
|
|
541
586
|
// src/BiampTable/useLoadingDelay.ts
|
|
542
|
-
import { useEffect, useRef, useState } from "react";
|
|
587
|
+
import { useEffect, useRef as useRef2, useState as useState2 } from "react";
|
|
543
588
|
function useLoadingDelay(loading, { delay = 150, minDuration = 500 } = {}) {
|
|
544
|
-
const [status, setStatus] =
|
|
545
|
-
const timeoutRef =
|
|
589
|
+
const [status, setStatus] = useState2("idle");
|
|
590
|
+
const timeoutRef = useRef2(null);
|
|
546
591
|
function clearPending() {
|
|
547
592
|
if (timeoutRef.current !== null) {
|
|
548
593
|
clearTimeout(timeoutRef.current);
|
|
@@ -570,7 +615,39 @@ function useLoadingDelay(loading, { delay = 150, minDuration = 500 } = {}) {
|
|
|
570
615
|
}
|
|
571
616
|
|
|
572
617
|
// src/BiampTable/BiampTable.tsx
|
|
573
|
-
import { jsx as
|
|
618
|
+
import { jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
619
|
+
var overlaySx = {
|
|
620
|
+
position: "absolute",
|
|
621
|
+
top: 0,
|
|
622
|
+
left: 0,
|
|
623
|
+
right: 0,
|
|
624
|
+
bottom: 0,
|
|
625
|
+
display: "flex",
|
|
626
|
+
alignItems: "center",
|
|
627
|
+
justifyContent: "center",
|
|
628
|
+
pointerEvents: "none"
|
|
629
|
+
};
|
|
630
|
+
var stickyHoverBg = {
|
|
631
|
+
".MuiTableRow-hover:hover > &, .Mui-selected > &": {
|
|
632
|
+
bgcolor: ({ palette }) => palette.mode === "dark" ? palette.grey[800] : palette.grey[100]
|
|
633
|
+
}
|
|
634
|
+
};
|
|
635
|
+
function cellSx(sticky, minWidth, zIndex) {
|
|
636
|
+
if (sticky) {
|
|
637
|
+
return {
|
|
638
|
+
position: "sticky",
|
|
639
|
+
[sticky]: 0,
|
|
640
|
+
zIndex,
|
|
641
|
+
width: 0,
|
|
642
|
+
whiteSpace: "nowrap",
|
|
643
|
+
textAlign: "center",
|
|
644
|
+
bgcolor: "background.paper",
|
|
645
|
+
...zIndex < 3 && stickyHoverBg
|
|
646
|
+
};
|
|
647
|
+
}
|
|
648
|
+
const mw = minWidth ?? 40;
|
|
649
|
+
return { minWidth: mw, maxWidth: mw };
|
|
650
|
+
}
|
|
574
651
|
function BiampTable({
|
|
575
652
|
table,
|
|
576
653
|
onRowClick,
|
|
@@ -581,6 +658,7 @@ function BiampTable({
|
|
|
581
658
|
enableRowSelection = false,
|
|
582
659
|
enableExpanding = false,
|
|
583
660
|
hideSelectAll,
|
|
661
|
+
selectChildrenWithParent = false,
|
|
584
662
|
getRowLabel,
|
|
585
663
|
sx,
|
|
586
664
|
...boxProps
|
|
@@ -592,7 +670,7 @@ function BiampTable({
|
|
|
592
670
|
},
|
|
593
671
|
enableRowSelection ? 48 : 0
|
|
594
672
|
);
|
|
595
|
-
const containerRef =
|
|
673
|
+
const containerRef = useRef3(null);
|
|
596
674
|
const showLoading = useLoadingDelay(!!loading);
|
|
597
675
|
const rows = table.getRowModel().rows;
|
|
598
676
|
const hasExpandableRows = enableExpanding && rows.some((r) => r.getCanExpand());
|
|
@@ -601,7 +679,7 @@ function BiampTable({
|
|
|
601
679
|
return /* @__PURE__ */ jsxs5(
|
|
602
680
|
TableContainer,
|
|
603
681
|
{
|
|
604
|
-
component:
|
|
682
|
+
component: Box4,
|
|
605
683
|
...boxProps,
|
|
606
684
|
ref: containerRef,
|
|
607
685
|
sx: {
|
|
@@ -620,8 +698,8 @@ function BiampTable({
|
|
|
620
698
|
"aria-busy": showLoading || void 0,
|
|
621
699
|
sx: { minWidth: tableMinWidth, tableLayout: "auto" },
|
|
622
700
|
children: [
|
|
623
|
-
/* @__PURE__ */
|
|
624
|
-
enableRowSelection && /* @__PURE__ */
|
|
701
|
+
/* @__PURE__ */ jsx8(TableHead, { children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ jsxs5(TableRow, { children: [
|
|
702
|
+
enableRowSelection && /* @__PURE__ */ jsx8(
|
|
625
703
|
TableCell,
|
|
626
704
|
{
|
|
627
705
|
padding: "checkbox",
|
|
@@ -631,7 +709,7 @@ function BiampTable({
|
|
|
631
709
|
zIndex: 3,
|
|
632
710
|
bgcolor: "background.paper"
|
|
633
711
|
},
|
|
634
|
-
children: !hideSelectAll && /* @__PURE__ */
|
|
712
|
+
children: !hideSelectAll && /* @__PURE__ */ jsx8(
|
|
635
713
|
Checkbox,
|
|
636
714
|
{
|
|
637
715
|
checked: table.getIsAllPageRowsSelected(),
|
|
@@ -645,7 +723,7 @@ function BiampTable({
|
|
|
645
723
|
),
|
|
646
724
|
headerGroup.headers.map((header) => {
|
|
647
725
|
const sticky = header.column.columnDef.meta?.sticky;
|
|
648
|
-
return /* @__PURE__ */
|
|
726
|
+
return /* @__PURE__ */ jsx8(
|
|
649
727
|
TableCell,
|
|
650
728
|
{
|
|
651
729
|
"data-sticky": sticky || void 0,
|
|
@@ -653,19 +731,12 @@ function BiampTable({
|
|
|
653
731
|
...header.column.getCanSort() && {
|
|
654
732
|
"aria-sort": header.column.getIsSorted() ? header.column.getIsSorted() === "asc" ? "ascending" : "descending" : "none"
|
|
655
733
|
},
|
|
656
|
-
sx:
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
width: 0,
|
|
663
|
-
whiteSpace: "nowrap",
|
|
664
|
-
textAlign: "center",
|
|
665
|
-
bgcolor: "background.paper"
|
|
666
|
-
}
|
|
667
|
-
},
|
|
668
|
-
children: header.isPlaceholder ? null : header.column.getCanSort() ? /* @__PURE__ */ jsx7(
|
|
734
|
+
sx: cellSx(
|
|
735
|
+
sticky,
|
|
736
|
+
header.column.columnDef.meta?.minWidth,
|
|
737
|
+
3
|
|
738
|
+
),
|
|
739
|
+
children: header.isPlaceholder ? null : header.column.getCanSort() ? /* @__PURE__ */ jsx8(
|
|
669
740
|
TableSortLabel,
|
|
670
741
|
{
|
|
671
742
|
active: !!header.column.getIsSorted(),
|
|
@@ -688,7 +759,7 @@ function BiampTable({
|
|
|
688
759
|
);
|
|
689
760
|
})
|
|
690
761
|
] }, headerGroup.id)) }),
|
|
691
|
-
/* @__PURE__ */
|
|
762
|
+
/* @__PURE__ */ jsx8(TableBody, { sx: { opacity: showLoading ? 0.3 : 1 }, children: !showError && rows.map((row) => {
|
|
692
763
|
const clickable = onRowClick ? isRowClickable ? isRowClickable(row.original) : true : false;
|
|
693
764
|
return /* @__PURE__ */ jsxs5(
|
|
694
765
|
TableRow,
|
|
@@ -706,7 +777,7 @@ function BiampTable({
|
|
|
706
777
|
}
|
|
707
778
|
} : void 0,
|
|
708
779
|
children: [
|
|
709
|
-
enableRowSelection && /* @__PURE__ */
|
|
780
|
+
enableRowSelection && /* @__PURE__ */ jsx8(
|
|
710
781
|
TableCell,
|
|
711
782
|
{
|
|
712
783
|
padding: "checkbox",
|
|
@@ -719,12 +790,14 @@ function BiampTable({
|
|
|
719
790
|
bgcolor: ({ palette }) => palette.mode === "dark" ? palette.grey[800] : palette.grey[100]
|
|
720
791
|
}
|
|
721
792
|
},
|
|
722
|
-
children: /* @__PURE__ */
|
|
793
|
+
children: /* @__PURE__ */ jsx8(
|
|
723
794
|
Checkbox,
|
|
724
795
|
{
|
|
725
796
|
checked: row.getIsSelected(),
|
|
726
797
|
disabled: !row.getCanSelect(),
|
|
727
|
-
onChange: row.
|
|
798
|
+
onChange: (e) => row.toggleSelected(e.target.checked, {
|
|
799
|
+
selectChildren: selectChildrenWithParent
|
|
800
|
+
}),
|
|
728
801
|
onClick: (e) => e.stopPropagation(),
|
|
729
802
|
sx: !row.getCanSelect() ? { visibility: "hidden" } : void 0,
|
|
730
803
|
slotProps: {
|
|
@@ -741,67 +814,61 @@ function BiampTable({
|
|
|
741
814
|
const isExpandCell = enableExpanding && !sticky && cellIndex === cells.findIndex(
|
|
742
815
|
(c) => !c.column.columnDef.meta?.sticky
|
|
743
816
|
);
|
|
744
|
-
return /* @__PURE__ */
|
|
817
|
+
return /* @__PURE__ */ jsx8(
|
|
745
818
|
TableCell,
|
|
746
819
|
{
|
|
747
820
|
"data-sticky": sticky || void 0,
|
|
748
|
-
sx:
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
}
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
821
|
+
sx: cellSx(
|
|
822
|
+
sticky,
|
|
823
|
+
cell.column.columnDef.meta?.minWidth,
|
|
824
|
+
2
|
|
825
|
+
),
|
|
826
|
+
children: (() => {
|
|
827
|
+
const content = flexRender(
|
|
828
|
+
cell.column.columnDef.cell,
|
|
829
|
+
cell.getContext()
|
|
830
|
+
);
|
|
831
|
+
if (sticky) return content;
|
|
832
|
+
const truncated = /* @__PURE__ */ jsx8(BiampTableTruncatedCell, { children: content });
|
|
833
|
+
if (!isExpandCell) return truncated;
|
|
834
|
+
const rowLabel = getRowLabel ? getRowLabel(row.original) : `row ${row.index + 1}`;
|
|
835
|
+
return /* @__PURE__ */ jsxs5(
|
|
836
|
+
Box4,
|
|
837
|
+
{
|
|
838
|
+
sx: {
|
|
839
|
+
display: "flex",
|
|
840
|
+
alignItems: "center",
|
|
841
|
+
pl: `${row.depth * 12}px`
|
|
842
|
+
},
|
|
843
|
+
children: [
|
|
844
|
+
row.getCanExpand() ? /* @__PURE__ */ jsx8(
|
|
845
|
+
IconButton,
|
|
846
|
+
{
|
|
847
|
+
variant: "none",
|
|
848
|
+
onClick: (e) => {
|
|
849
|
+
e.stopPropagation();
|
|
850
|
+
row.toggleExpanded();
|
|
851
|
+
},
|
|
852
|
+
"aria-label": row.getIsExpanded() ? `Collapse ${rowLabel}` : `Expand ${rowLabel}`,
|
|
853
|
+
"aria-expanded": row.getIsExpanded(),
|
|
854
|
+
children: /* @__PURE__ */ jsx8(
|
|
855
|
+
ChevronRightIcon,
|
|
856
|
+
{
|
|
857
|
+
variant: "xs",
|
|
858
|
+
sx: {
|
|
859
|
+
color: ({ palette }) => palette.text.secondary,
|
|
860
|
+
transition: "transform 150ms ease",
|
|
861
|
+
transform: row.getIsExpanded() ? "rotate(90deg)" : "rotate(0deg)"
|
|
862
|
+
}
|
|
790
863
|
}
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
}
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
]
|
|
800
|
-
}
|
|
801
|
-
) : flexRender(
|
|
802
|
-
cell.column.columnDef.cell,
|
|
803
|
-
cell.getContext()
|
|
804
|
-
)
|
|
864
|
+
)
|
|
865
|
+
}
|
|
866
|
+
) : hasExpandableRows ? /* @__PURE__ */ jsx8(Box4, { sx: { width: 28 } }) : null,
|
|
867
|
+
truncated
|
|
868
|
+
]
|
|
869
|
+
}
|
|
870
|
+
);
|
|
871
|
+
})()
|
|
805
872
|
},
|
|
806
873
|
cell.id
|
|
807
874
|
);
|
|
@@ -814,46 +881,14 @@ function BiampTable({
|
|
|
814
881
|
]
|
|
815
882
|
}
|
|
816
883
|
),
|
|
817
|
-
showError && /* @__PURE__ */
|
|
818
|
-
|
|
884
|
+
showError && /* @__PURE__ */ jsx8(Box4, { sx: overlaySx, children: error === true ? /* @__PURE__ */ jsx8(BiampTableErrorState, { sx: { pointerEvents: "auto" } }) : error instanceof Error ? /* @__PURE__ */ jsx8(
|
|
885
|
+
BiampTableErrorState,
|
|
819
886
|
{
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
top: 0,
|
|
823
|
-
left: 0,
|
|
824
|
-
right: 0,
|
|
825
|
-
bottom: 0,
|
|
826
|
-
display: "flex",
|
|
827
|
-
alignItems: "center",
|
|
828
|
-
justifyContent: "center",
|
|
829
|
-
pointerEvents: "none"
|
|
830
|
-
},
|
|
831
|
-
children: error === true ? /* @__PURE__ */ jsx7(BiampTableErrorState, { sx: { pointerEvents: "auto" } }) : error instanceof Error ? /* @__PURE__ */ jsx7(
|
|
832
|
-
BiampTableErrorState,
|
|
833
|
-
{
|
|
834
|
-
description: error.message,
|
|
835
|
-
sx: { pointerEvents: "auto" }
|
|
836
|
-
}
|
|
837
|
-
) : error
|
|
887
|
+
description: error.message,
|
|
888
|
+
sx: { pointerEvents: "auto" }
|
|
838
889
|
}
|
|
839
|
-
),
|
|
840
|
-
showEmpty && /* @__PURE__ */
|
|
841
|
-
Box3,
|
|
842
|
-
{
|
|
843
|
-
sx: {
|
|
844
|
-
position: "absolute",
|
|
845
|
-
top: 0,
|
|
846
|
-
left: 0,
|
|
847
|
-
right: 0,
|
|
848
|
-
bottom: 0,
|
|
849
|
-
display: "flex",
|
|
850
|
-
alignItems: "center",
|
|
851
|
-
justifyContent: "center",
|
|
852
|
-
pointerEvents: "none"
|
|
853
|
-
},
|
|
854
|
-
children: empty && empty !== true ? empty : /* @__PURE__ */ jsx7(BiampTableEmptyState, { sx: { pointerEvents: "auto" } })
|
|
855
|
-
}
|
|
856
|
-
)
|
|
890
|
+
) : error }),
|
|
891
|
+
showEmpty && /* @__PURE__ */ jsx8(Box4, { sx: overlaySx, children: empty && empty !== true ? empty : /* @__PURE__ */ jsx8(BiampTableEmptyState, { sx: { pointerEvents: "auto" } }) })
|
|
857
892
|
]
|
|
858
893
|
}
|
|
859
894
|
);
|
|
@@ -861,7 +896,7 @@ function BiampTable({
|
|
|
861
896
|
|
|
862
897
|
// src/BiampTable/BiampTableContainer.tsx
|
|
863
898
|
import { Stack as Stack6 } from "@mui/material";
|
|
864
|
-
import { jsx as
|
|
899
|
+
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
865
900
|
function BiampTableContainer({
|
|
866
901
|
withBorderTop = true,
|
|
867
902
|
withBorderBottom = false,
|
|
@@ -869,7 +904,7 @@ function BiampTableContainer({
|
|
|
869
904
|
sx,
|
|
870
905
|
...props
|
|
871
906
|
}) {
|
|
872
|
-
return /* @__PURE__ */
|
|
907
|
+
return /* @__PURE__ */ jsx9(
|
|
873
908
|
Stack6,
|
|
874
909
|
{
|
|
875
910
|
direction: "column",
|
|
@@ -888,18 +923,18 @@ function BiampTableContainer({
|
|
|
888
923
|
}
|
|
889
924
|
|
|
890
925
|
// src/BiampTable/BiampTableCellActionButton.tsx
|
|
891
|
-
import { IconButton as IconButton2, Tooltip } from "@mui/material";
|
|
892
|
-
import { jsx as
|
|
926
|
+
import { IconButton as IconButton2, Tooltip as Tooltip2 } from "@mui/material";
|
|
927
|
+
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
893
928
|
function BiampTableCellActionButton({ label, icon, ...props }) {
|
|
894
|
-
return /* @__PURE__ */
|
|
895
|
-
|
|
929
|
+
return /* @__PURE__ */ jsx10(
|
|
930
|
+
Tooltip2,
|
|
896
931
|
{
|
|
897
932
|
title: label,
|
|
898
933
|
placement: "top",
|
|
899
934
|
enterDelay: 500,
|
|
900
935
|
enterNextDelay: 500,
|
|
901
936
|
disableInteractive: true,
|
|
902
|
-
children: /* @__PURE__ */
|
|
937
|
+
children: /* @__PURE__ */ jsx10("span", { children: /* @__PURE__ */ jsx10(IconButton2, { "aria-label": label, ...props, children: icon }) })
|
|
903
938
|
}
|
|
904
939
|
);
|
|
905
940
|
}
|
|
@@ -907,7 +942,7 @@ function BiampTableCellActionButton({ label, icon, ...props }) {
|
|
|
907
942
|
// src/BiampTable/BiampTableColumnVisibility.tsx
|
|
908
943
|
import {
|
|
909
944
|
alpha as alpha2,
|
|
910
|
-
Box as
|
|
945
|
+
Box as Box5,
|
|
911
946
|
Checkbox as Checkbox2,
|
|
912
947
|
Divider,
|
|
913
948
|
List,
|
|
@@ -915,7 +950,7 @@ import {
|
|
|
915
950
|
Popover as Popover2,
|
|
916
951
|
Typography as Typography3
|
|
917
952
|
} from "@mui/material";
|
|
918
|
-
import { jsx as
|
|
953
|
+
import { jsx as jsx11, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
919
954
|
function toVisibilityState(visibility) {
|
|
920
955
|
return visibility;
|
|
921
956
|
}
|
|
@@ -958,8 +993,7 @@ function BiampTableColumnVisibility({
|
|
|
958
993
|
...popoverProps
|
|
959
994
|
}) {
|
|
960
995
|
const allVisible = table.getAllLeafColumns().every((col) => col.getIsVisible());
|
|
961
|
-
|
|
962
|
-
return /* @__PURE__ */ jsx10(
|
|
996
|
+
return /* @__PURE__ */ jsx11(
|
|
963
997
|
Popover2,
|
|
964
998
|
{
|
|
965
999
|
anchorEl,
|
|
@@ -988,21 +1022,20 @@ function BiampTableColumnVisibility({
|
|
|
988
1022
|
sx: columnListItemSx,
|
|
989
1023
|
onClick: () => table.toggleAllColumnsVisible(!allVisible),
|
|
990
1024
|
children: [
|
|
991
|
-
/* @__PURE__ */
|
|
1025
|
+
/* @__PURE__ */ jsx11(
|
|
992
1026
|
Checkbox2,
|
|
993
1027
|
{
|
|
994
1028
|
checked: allVisible,
|
|
995
|
-
indeterminate: !allVisible && someVisible,
|
|
996
1029
|
slotProps: { input: { "aria-label": `${showAllLabel} columns` } }
|
|
997
1030
|
}
|
|
998
1031
|
),
|
|
999
|
-
/* @__PURE__ */
|
|
1032
|
+
/* @__PURE__ */ jsx11(Typography3, { variant: "caption", fontWeight: 600, children: showAllLabel })
|
|
1000
1033
|
]
|
|
1001
1034
|
}
|
|
1002
1035
|
),
|
|
1003
|
-
/* @__PURE__ */
|
|
1004
|
-
/* @__PURE__ */
|
|
1005
|
-
|
|
1036
|
+
/* @__PURE__ */ jsx11(Divider, {}),
|
|
1037
|
+
/* @__PURE__ */ jsx11(
|
|
1038
|
+
Box5,
|
|
1006
1039
|
{
|
|
1007
1040
|
sx: { maxHeight: 340, overflow: "auto", overscrollBehavior: "none" },
|
|
1008
1041
|
children: table.getAllLeafColumns().map((column) => {
|
|
@@ -1014,7 +1047,7 @@ function BiampTableColumnVisibility({
|
|
|
1014
1047
|
sx: columnListItemSx,
|
|
1015
1048
|
onClick: column.getToggleVisibilityHandler(),
|
|
1016
1049
|
children: [
|
|
1017
|
-
/* @__PURE__ */
|
|
1050
|
+
/* @__PURE__ */ jsx11(
|
|
1018
1051
|
Checkbox2,
|
|
1019
1052
|
{
|
|
1020
1053
|
checked: column.getIsVisible(),
|
|
@@ -1024,7 +1057,7 @@ function BiampTableColumnVisibility({
|
|
|
1024
1057
|
}
|
|
1025
1058
|
}
|
|
1026
1059
|
),
|
|
1027
|
-
/* @__PURE__ */
|
|
1060
|
+
/* @__PURE__ */ jsx11(Typography3, { variant: "caption", children: columnName })
|
|
1028
1061
|
]
|
|
1029
1062
|
},
|
|
1030
1063
|
column.id
|
|
@@ -1039,14 +1072,14 @@ function BiampTableColumnVisibility({
|
|
|
1039
1072
|
|
|
1040
1073
|
// src/BiampTable/BiampTableToolbarColumnVisibility.tsx
|
|
1041
1074
|
import { ColumnsIcon } from "@bwp-web/assets";
|
|
1042
|
-
import { useState as
|
|
1075
|
+
import { useState as useState3 } from "react";
|
|
1043
1076
|
|
|
1044
1077
|
// src/BiampTable/BiampTableToolbarActionButton.tsx
|
|
1045
1078
|
import {
|
|
1046
1079
|
Badge,
|
|
1047
1080
|
IconButton as IconButton3
|
|
1048
1081
|
} from "@mui/material";
|
|
1049
|
-
import { jsx as
|
|
1082
|
+
import { jsx as jsx12 } from "react/jsx-runtime";
|
|
1050
1083
|
function BiampTableToolbarActionButton({
|
|
1051
1084
|
label,
|
|
1052
1085
|
icon,
|
|
@@ -1054,12 +1087,12 @@ function BiampTableToolbarActionButton({
|
|
|
1054
1087
|
...props
|
|
1055
1088
|
}) {
|
|
1056
1089
|
const showBadge = badgeContent != null && badgeContent !== 0;
|
|
1057
|
-
return /* @__PURE__ */
|
|
1090
|
+
return /* @__PURE__ */ jsx12(
|
|
1058
1091
|
IconButton3,
|
|
1059
1092
|
{
|
|
1060
1093
|
"aria-label": showBadge ? `${label} (${badgeContent})` : label,
|
|
1061
1094
|
...props,
|
|
1062
|
-
children: showBadge ? /* @__PURE__ */
|
|
1095
|
+
children: showBadge ? /* @__PURE__ */ jsx12(
|
|
1063
1096
|
Badge,
|
|
1064
1097
|
{
|
|
1065
1098
|
badgeContent,
|
|
@@ -1083,20 +1116,20 @@ function BiampTableToolbarActionButton({
|
|
|
1083
1116
|
}
|
|
1084
1117
|
|
|
1085
1118
|
// src/BiampTable/BiampTableToolbarColumnVisibility.tsx
|
|
1086
|
-
import { Fragment, jsx as
|
|
1119
|
+
import { Fragment, jsx as jsx13, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1087
1120
|
function BiampTableToolbarColumnVisibility({
|
|
1088
1121
|
table,
|
|
1089
|
-
icon = /* @__PURE__ */
|
|
1122
|
+
icon = /* @__PURE__ */ jsx13(ColumnsIcon, { variant: "xs" }),
|
|
1090
1123
|
label = "Columns",
|
|
1091
1124
|
defaultColumnVisibility,
|
|
1092
1125
|
showAllLabel,
|
|
1093
1126
|
...actionButtonProps
|
|
1094
1127
|
}) {
|
|
1095
|
-
const [anchorEl, setAnchorEl] =
|
|
1128
|
+
const [anchorEl, setAnchorEl] = useState3(null);
|
|
1096
1129
|
const defaults = defaultColumnVisibility ?? getDefaultColumnVisibility(table);
|
|
1097
1130
|
const dirtyCount = getColumnVisibilityDirtyCount(table, defaults);
|
|
1098
1131
|
return /* @__PURE__ */ jsxs7(Fragment, { children: [
|
|
1099
|
-
/* @__PURE__ */
|
|
1132
|
+
/* @__PURE__ */ jsx13(
|
|
1100
1133
|
BiampTableToolbarActionButton,
|
|
1101
1134
|
{
|
|
1102
1135
|
label,
|
|
@@ -1106,7 +1139,7 @@ function BiampTableToolbarColumnVisibility({
|
|
|
1106
1139
|
...actionButtonProps
|
|
1107
1140
|
}
|
|
1108
1141
|
),
|
|
1109
|
-
/* @__PURE__ */
|
|
1142
|
+
/* @__PURE__ */ jsx13(
|
|
1110
1143
|
BiampTableColumnVisibility,
|
|
1111
1144
|
{
|
|
1112
1145
|
table,
|
|
@@ -1119,9 +1152,9 @@ function BiampTableToolbarColumnVisibility({
|
|
|
1119
1152
|
}
|
|
1120
1153
|
|
|
1121
1154
|
// src/BiampTable/BiampTablePagination.tsx
|
|
1122
|
-
import { useRef as
|
|
1155
|
+
import { useEffect as useEffect2, useRef as useRef4 } from "react";
|
|
1123
1156
|
import { TablePagination } from "@mui/material";
|
|
1124
|
-
import { jsx as
|
|
1157
|
+
import { jsx as jsx14 } from "react/jsx-runtime";
|
|
1125
1158
|
var positionMap = {
|
|
1126
1159
|
left: "flex-start",
|
|
1127
1160
|
center: "center",
|
|
@@ -1137,18 +1170,20 @@ function BiampTablePagination({
|
|
|
1137
1170
|
...paginationProps
|
|
1138
1171
|
}) {
|
|
1139
1172
|
const rowCount = table.getRowCount();
|
|
1140
|
-
const lastRowCountRef =
|
|
1173
|
+
const lastRowCountRef = useRef4(rowCount);
|
|
1141
1174
|
if (!loading && rowCount >= 0) {
|
|
1142
1175
|
lastRowCountRef.current = rowCount;
|
|
1143
1176
|
}
|
|
1144
1177
|
const stableCount = loading ? lastRowCountRef.current : rowCount;
|
|
1145
1178
|
const { pageSize, pageIndex } = table.getState().pagination;
|
|
1146
1179
|
const maxPage = Math.max(0, Math.ceil(stableCount / pageSize) - 1);
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1180
|
+
useEffect2(() => {
|
|
1181
|
+
if (!loading && pageIndex > maxPage) {
|
|
1182
|
+
table.setPageIndex(maxPage);
|
|
1183
|
+
}
|
|
1184
|
+
}, [loading, pageIndex, maxPage, table]);
|
|
1150
1185
|
if (autoHide && (!stableCount || stableCount <= pageSize)) return null;
|
|
1151
|
-
return /* @__PURE__ */
|
|
1186
|
+
return /* @__PURE__ */ jsx14(
|
|
1152
1187
|
TablePagination,
|
|
1153
1188
|
{
|
|
1154
1189
|
component: "div",
|
|
@@ -1180,15 +1215,15 @@ function BiampTablePagination({
|
|
|
1180
1215
|
}
|
|
1181
1216
|
|
|
1182
1217
|
// src/BiampTable/BiampTableToolbar.tsx
|
|
1183
|
-
import { Box as
|
|
1184
|
-
import { jsx as
|
|
1218
|
+
import { Box as Box6 } from "@mui/material";
|
|
1219
|
+
import { jsx as jsx15 } from "react/jsx-runtime";
|
|
1185
1220
|
function BiampTableToolbar({
|
|
1186
1221
|
children,
|
|
1187
1222
|
sx,
|
|
1188
1223
|
...props
|
|
1189
1224
|
}) {
|
|
1190
|
-
return /* @__PURE__ */
|
|
1191
|
-
|
|
1225
|
+
return /* @__PURE__ */ jsx15(
|
|
1226
|
+
Box6,
|
|
1192
1227
|
{
|
|
1193
1228
|
role: "toolbar",
|
|
1194
1229
|
display: "flex",
|
|
@@ -1206,14 +1241,14 @@ function BiampTableToolbar({
|
|
|
1206
1241
|
}
|
|
1207
1242
|
|
|
1208
1243
|
// src/BiampTable/BiampTableToolbarActions.tsx
|
|
1209
|
-
import { Box as
|
|
1210
|
-
import { jsx as
|
|
1244
|
+
import { Box as Box7 } from "@mui/material";
|
|
1245
|
+
import { jsx as jsx16 } from "react/jsx-runtime";
|
|
1211
1246
|
function BiampTableToolbarActions({
|
|
1212
1247
|
children,
|
|
1213
1248
|
...props
|
|
1214
1249
|
}) {
|
|
1215
|
-
return /* @__PURE__ */
|
|
1216
|
-
|
|
1250
|
+
return /* @__PURE__ */ jsx16(
|
|
1251
|
+
Box7,
|
|
1217
1252
|
{
|
|
1218
1253
|
display: "flex",
|
|
1219
1254
|
alignItems: "center",
|
|
@@ -1229,19 +1264,19 @@ function BiampTableToolbarActions({
|
|
|
1229
1264
|
// src/BiampTable/BiampTableToolbarExport.tsx
|
|
1230
1265
|
import { CircularProgress } from "@mui/material";
|
|
1231
1266
|
import { DownloadIcon } from "@bwp-web/assets";
|
|
1232
|
-
import { jsx as
|
|
1267
|
+
import { jsx as jsx17 } from "react/jsx-runtime";
|
|
1233
1268
|
function BiampTableToolbarExport({
|
|
1234
1269
|
onExport,
|
|
1235
1270
|
loading,
|
|
1236
|
-
icon = /* @__PURE__ */
|
|
1271
|
+
icon = /* @__PURE__ */ jsx17(DownloadIcon, { variant: "xs" }),
|
|
1237
1272
|
label = "Export",
|
|
1238
1273
|
...props
|
|
1239
1274
|
}) {
|
|
1240
|
-
return /* @__PURE__ */
|
|
1275
|
+
return /* @__PURE__ */ jsx17(
|
|
1241
1276
|
BiampTableToolbarActionButton,
|
|
1242
1277
|
{
|
|
1243
1278
|
label: loading ? `${label}, loading` : label,
|
|
1244
|
-
icon: loading ? /* @__PURE__ */
|
|
1279
|
+
icon: loading ? /* @__PURE__ */ jsx17(CircularProgress, { size: 20, color: "inherit" }) : icon,
|
|
1245
1280
|
disabled: loading,
|
|
1246
1281
|
onClick: onExport,
|
|
1247
1282
|
...props
|
|
@@ -1252,7 +1287,7 @@ function BiampTableToolbarExport({
|
|
|
1252
1287
|
// src/BiampTable/BiampTableToolbarFilters.tsx
|
|
1253
1288
|
import {
|
|
1254
1289
|
Badge as Badge2,
|
|
1255
|
-
Box as
|
|
1290
|
+
Box as Box8,
|
|
1256
1291
|
Button,
|
|
1257
1292
|
Divider as Divider2,
|
|
1258
1293
|
Drawer,
|
|
@@ -1260,14 +1295,14 @@ import {
|
|
|
1260
1295
|
Typography as Typography4
|
|
1261
1296
|
} from "@mui/material";
|
|
1262
1297
|
import { CloseIcon, FilterIcon } from "@bwp-web/assets";
|
|
1263
|
-
import { useId, useState as
|
|
1264
|
-
import { Fragment as Fragment2, jsx as
|
|
1298
|
+
import { useId, useState as useState4 } from "react";
|
|
1299
|
+
import { Fragment as Fragment2, jsx as jsx18, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
1265
1300
|
function BiampTableToolbarFilters({
|
|
1266
1301
|
activeFilterCount,
|
|
1267
1302
|
children,
|
|
1268
1303
|
onReset,
|
|
1269
1304
|
onApply,
|
|
1270
|
-
icon = /* @__PURE__ */
|
|
1305
|
+
icon = /* @__PURE__ */ jsx18(FilterIcon, { variant: "xs" }),
|
|
1271
1306
|
title = "Filters",
|
|
1272
1307
|
resetLabel = "Clear filters",
|
|
1273
1308
|
applyLabel = "Apply",
|
|
@@ -1275,14 +1310,14 @@ function BiampTableToolbarFilters({
|
|
|
1275
1310
|
buttonLabel = "Filters",
|
|
1276
1311
|
DrawerProps: drawerProps
|
|
1277
1312
|
}) {
|
|
1278
|
-
const [open, setOpen] =
|
|
1313
|
+
const [open, setOpen] = useState4(false);
|
|
1279
1314
|
const titleId = useId();
|
|
1280
1315
|
function handleClose() {
|
|
1281
1316
|
onApply?.();
|
|
1282
1317
|
setOpen(false);
|
|
1283
1318
|
}
|
|
1284
1319
|
return /* @__PURE__ */ jsxs8(Fragment2, { children: [
|
|
1285
|
-
/* @__PURE__ */
|
|
1320
|
+
/* @__PURE__ */ jsx18(
|
|
1286
1321
|
BiampTableToolbarActionButton,
|
|
1287
1322
|
{
|
|
1288
1323
|
label: buttonLabel,
|
|
@@ -1291,7 +1326,7 @@ function BiampTableToolbarFilters({
|
|
|
1291
1326
|
onClick: () => setOpen(true)
|
|
1292
1327
|
}
|
|
1293
1328
|
),
|
|
1294
|
-
/* @__PURE__ */
|
|
1329
|
+
/* @__PURE__ */ jsx18(
|
|
1295
1330
|
Drawer,
|
|
1296
1331
|
{
|
|
1297
1332
|
anchor: "right",
|
|
@@ -1304,16 +1339,16 @@ function BiampTableToolbarFilters({
|
|
|
1304
1339
|
...drawerProps?.PaperProps
|
|
1305
1340
|
},
|
|
1306
1341
|
children: /* @__PURE__ */ jsxs8(
|
|
1307
|
-
|
|
1342
|
+
Box8,
|
|
1308
1343
|
{
|
|
1309
1344
|
height: "100%",
|
|
1310
1345
|
display: "flex",
|
|
1311
1346
|
flexDirection: "column",
|
|
1312
1347
|
justifyContent: "space-between",
|
|
1313
1348
|
children: [
|
|
1314
|
-
/* @__PURE__ */ jsxs8(
|
|
1349
|
+
/* @__PURE__ */ jsxs8(Box8, { children: [
|
|
1315
1350
|
/* @__PURE__ */ jsxs8(
|
|
1316
|
-
|
|
1351
|
+
Box8,
|
|
1317
1352
|
{
|
|
1318
1353
|
display: "flex",
|
|
1319
1354
|
justifyContent: "space-between",
|
|
@@ -1323,7 +1358,7 @@ function BiampTableToolbarFilters({
|
|
|
1323
1358
|
children: [
|
|
1324
1359
|
/* @__PURE__ */ jsxs8(Typography4, { id: titleId, variant: "h2", children: [
|
|
1325
1360
|
title,
|
|
1326
|
-
/* @__PURE__ */
|
|
1361
|
+
/* @__PURE__ */ jsx18(
|
|
1327
1362
|
Badge2,
|
|
1328
1363
|
{
|
|
1329
1364
|
badgeContent: activeFilterCount,
|
|
@@ -1332,21 +1367,21 @@ function BiampTableToolbarFilters({
|
|
|
1332
1367
|
}
|
|
1333
1368
|
)
|
|
1334
1369
|
] }),
|
|
1335
|
-
/* @__PURE__ */
|
|
1370
|
+
/* @__PURE__ */ jsx18(
|
|
1336
1371
|
IconButton4,
|
|
1337
1372
|
{
|
|
1338
1373
|
size: "medium",
|
|
1339
1374
|
onClick: handleClose,
|
|
1340
1375
|
"aria-label": closeLabel,
|
|
1341
|
-
children: /* @__PURE__ */
|
|
1376
|
+
children: /* @__PURE__ */ jsx18(CloseIcon, {})
|
|
1342
1377
|
}
|
|
1343
1378
|
)
|
|
1344
1379
|
]
|
|
1345
1380
|
}
|
|
1346
1381
|
),
|
|
1347
|
-
/* @__PURE__ */
|
|
1348
|
-
/* @__PURE__ */
|
|
1349
|
-
|
|
1382
|
+
/* @__PURE__ */ jsx18(Divider2, {}),
|
|
1383
|
+
/* @__PURE__ */ jsx18(
|
|
1384
|
+
Box8,
|
|
1350
1385
|
{
|
|
1351
1386
|
role: "group",
|
|
1352
1387
|
"aria-label": "Filter options",
|
|
@@ -1359,8 +1394,8 @@ function BiampTableToolbarFilters({
|
|
|
1359
1394
|
}
|
|
1360
1395
|
)
|
|
1361
1396
|
] }),
|
|
1362
|
-
/* @__PURE__ */ jsxs8(
|
|
1363
|
-
/* @__PURE__ */
|
|
1397
|
+
/* @__PURE__ */ jsxs8(Box8, { display: "flex", children: [
|
|
1398
|
+
/* @__PURE__ */ jsx18(
|
|
1364
1399
|
Button,
|
|
1365
1400
|
{
|
|
1366
1401
|
variant: "overlay",
|
|
@@ -1371,7 +1406,7 @@ function BiampTableToolbarFilters({
|
|
|
1371
1406
|
children: resetLabel
|
|
1372
1407
|
}
|
|
1373
1408
|
),
|
|
1374
|
-
/* @__PURE__ */
|
|
1409
|
+
/* @__PURE__ */ jsx18(
|
|
1375
1410
|
Button,
|
|
1376
1411
|
{
|
|
1377
1412
|
variant: "overlay",
|
|
@@ -1392,7 +1427,7 @@ function BiampTableToolbarFilters({
|
|
|
1392
1427
|
|
|
1393
1428
|
// src/BiampTable/BiampTableToolbarSearch.tsx
|
|
1394
1429
|
import {
|
|
1395
|
-
Box as
|
|
1430
|
+
Box as Box9,
|
|
1396
1431
|
Collapse,
|
|
1397
1432
|
IconButton as IconButton5,
|
|
1398
1433
|
InputAdornment as InputAdornment2,
|
|
@@ -1401,21 +1436,21 @@ import {
|
|
|
1401
1436
|
useMediaQuery
|
|
1402
1437
|
} from "@mui/material";
|
|
1403
1438
|
import { CloseIcon as CloseIcon2, SearchIcon as SearchIcon2 } from "@bwp-web/assets";
|
|
1404
|
-
import { useEffect as
|
|
1439
|
+
import { useEffect as useEffect4, useState as useState5 } from "react";
|
|
1405
1440
|
|
|
1406
1441
|
// src/BiampTable/useDebouncedCallback.ts
|
|
1407
|
-
import { useCallback, useEffect as
|
|
1442
|
+
import { useCallback as useCallback2, useEffect as useEffect3, useRef as useRef5 } from "react";
|
|
1408
1443
|
var BIAMP_TABLE_DEBOUNCE_DELAY = 300;
|
|
1409
1444
|
function useDebouncedCallback(callback, delay = BIAMP_TABLE_DEBOUNCE_DELAY) {
|
|
1410
|
-
const timeoutRef =
|
|
1411
|
-
const callbackRef =
|
|
1445
|
+
const timeoutRef = useRef5(null);
|
|
1446
|
+
const callbackRef = useRef5(callback);
|
|
1412
1447
|
callbackRef.current = callback;
|
|
1413
|
-
|
|
1448
|
+
useEffect3(() => {
|
|
1414
1449
|
return () => {
|
|
1415
1450
|
if (timeoutRef.current !== null) clearTimeout(timeoutRef.current);
|
|
1416
1451
|
};
|
|
1417
1452
|
}, []);
|
|
1418
|
-
return
|
|
1453
|
+
return useCallback2(
|
|
1419
1454
|
(...args) => {
|
|
1420
1455
|
if (timeoutRef.current !== null) clearTimeout(timeoutRef.current);
|
|
1421
1456
|
timeoutRef.current = setTimeout(
|
|
@@ -1428,7 +1463,7 @@ function useDebouncedCallback(callback, delay = BIAMP_TABLE_DEBOUNCE_DELAY) {
|
|
|
1428
1463
|
}
|
|
1429
1464
|
|
|
1430
1465
|
// src/BiampTable/BiampTableToolbarSearch.tsx
|
|
1431
|
-
import { jsx as
|
|
1466
|
+
import { jsx as jsx19, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
1432
1467
|
var searchFieldSx = {
|
|
1433
1468
|
"& .MuiInputBase-root": {
|
|
1434
1469
|
height: "36px !important",
|
|
@@ -1453,10 +1488,10 @@ function BiampTableToolbarSearch({
|
|
|
1453
1488
|
...textFieldProps
|
|
1454
1489
|
}) {
|
|
1455
1490
|
const isMobile = useMediaQuery((t) => t.breakpoints.down("md"));
|
|
1456
|
-
const [inputValue, setInputValue] =
|
|
1457
|
-
const [isExpanded, setIsExpanded] =
|
|
1491
|
+
const [inputValue, setInputValue] = useState5(defaultValue);
|
|
1492
|
+
const [isExpanded, setIsExpanded] = useState5(false);
|
|
1458
1493
|
const debouncedOnChange = useDebouncedCallback(onChange, debounceDelay);
|
|
1459
|
-
|
|
1494
|
+
useEffect4(() => {
|
|
1460
1495
|
setInputValue(defaultValue);
|
|
1461
1496
|
}, [defaultValue]);
|
|
1462
1497
|
const handleChange = (e) => {
|
|
@@ -1472,17 +1507,17 @@ function BiampTableToolbarSearch({
|
|
|
1472
1507
|
setIsExpanded(false);
|
|
1473
1508
|
}
|
|
1474
1509
|
};
|
|
1475
|
-
const clearButton = inputValue ? /* @__PURE__ */
|
|
1510
|
+
const clearButton = inputValue ? /* @__PURE__ */ jsx19(InputAdornment2, { position: "end", children: /* @__PURE__ */ jsx19(
|
|
1476
1511
|
IconButton5,
|
|
1477
1512
|
{
|
|
1478
1513
|
size: "small",
|
|
1479
1514
|
onClick: handleClear,
|
|
1480
1515
|
"aria-label": clearLabel,
|
|
1481
1516
|
sx: { mr: 0.5 },
|
|
1482
|
-
children: /* @__PURE__ */
|
|
1517
|
+
children: /* @__PURE__ */ jsx19(CloseIcon2, { variant: "xs", sx: { width: 20, height: 20 } })
|
|
1483
1518
|
}
|
|
1484
1519
|
) }) : null;
|
|
1485
|
-
const textField = /* @__PURE__ */
|
|
1520
|
+
const textField = /* @__PURE__ */ jsx19(
|
|
1486
1521
|
TextField2,
|
|
1487
1522
|
{
|
|
1488
1523
|
name: "search",
|
|
@@ -1491,7 +1526,7 @@ function BiampTableToolbarSearch({
|
|
|
1491
1526
|
slotProps: {
|
|
1492
1527
|
htmlInput: { maxLength, "aria-label": placeholder },
|
|
1493
1528
|
input: {
|
|
1494
|
-
startAdornment: /* @__PURE__ */
|
|
1529
|
+
startAdornment: /* @__PURE__ */ jsx19(InputAdornment2, { position: "start", sx: { ml: 1 }, children: /* @__PURE__ */ jsx19(
|
|
1495
1530
|
SearchIcon2,
|
|
1496
1531
|
{
|
|
1497
1532
|
variant: "xs",
|
|
@@ -1517,9 +1552,9 @@ function BiampTableToolbarSearch({
|
|
|
1517
1552
|
}
|
|
1518
1553
|
);
|
|
1519
1554
|
if (isMobile && enableMobileView) {
|
|
1520
|
-
return /* @__PURE__ */ jsxs9(
|
|
1521
|
-
/* @__PURE__ */
|
|
1522
|
-
/* @__PURE__ */
|
|
1555
|
+
return /* @__PURE__ */ jsxs9(Box9, { display: "flex", alignItems: "center", width: "100%", pr: 1, gap: 1, children: [
|
|
1556
|
+
/* @__PURE__ */ jsx19(SearchIcon2, { sx: { width: 16, height: 16 } }),
|
|
1557
|
+
/* @__PURE__ */ jsx19(
|
|
1523
1558
|
InputBase,
|
|
1524
1559
|
{
|
|
1525
1560
|
name: "search",
|
|
@@ -1541,14 +1576,14 @@ function BiampTableToolbarSearch({
|
|
|
1541
1576
|
] });
|
|
1542
1577
|
}
|
|
1543
1578
|
if (expandable) {
|
|
1544
|
-
return /* @__PURE__ */ jsxs9(
|
|
1545
|
-
/* @__PURE__ */
|
|
1579
|
+
return /* @__PURE__ */ jsxs9(Box9, { display: "flex", alignItems: "center", minWidth: 28, children: [
|
|
1580
|
+
/* @__PURE__ */ jsx19(
|
|
1546
1581
|
IconButton5,
|
|
1547
1582
|
{
|
|
1548
1583
|
"aria-label": expandLabel ?? placeholder,
|
|
1549
1584
|
onClick: () => setIsExpanded(true),
|
|
1550
1585
|
sx: { display: isExpanded || inputValue ? "none" : "flex" },
|
|
1551
|
-
children: /* @__PURE__ */
|
|
1586
|
+
children: /* @__PURE__ */ jsx19(
|
|
1552
1587
|
SearchIcon2,
|
|
1553
1588
|
{
|
|
1554
1589
|
variant: "xs",
|
|
@@ -1558,7 +1593,7 @@ function BiampTableToolbarSearch({
|
|
|
1558
1593
|
)
|
|
1559
1594
|
}
|
|
1560
1595
|
),
|
|
1561
|
-
/* @__PURE__ */
|
|
1596
|
+
/* @__PURE__ */ jsx19(
|
|
1562
1597
|
Collapse,
|
|
1563
1598
|
{
|
|
1564
1599
|
in: isExpanded || !!inputValue,
|
|
@@ -1572,6 +1607,158 @@ function BiampTableToolbarSearch({
|
|
|
1572
1607
|
return textField;
|
|
1573
1608
|
}
|
|
1574
1609
|
|
|
1610
|
+
// src/BiampTable/useBiampServerSideTable.ts
|
|
1611
|
+
import {
|
|
1612
|
+
getCoreRowModel,
|
|
1613
|
+
useReactTable
|
|
1614
|
+
} from "@tanstack/react-table";
|
|
1615
|
+
import { useMemo } from "react";
|
|
1616
|
+
|
|
1617
|
+
// src/BiampTable/serverSideTableUtils.ts
|
|
1618
|
+
function orderToSorting(order, fieldToColumnId) {
|
|
1619
|
+
if (!order) return [];
|
|
1620
|
+
const id = fieldToColumnId?.[order.field] ?? order.field;
|
|
1621
|
+
return [{ id, desc: order.desc ?? false }];
|
|
1622
|
+
}
|
|
1623
|
+
function sortingToOrder(sorting, columnIdToField) {
|
|
1624
|
+
if (sorting.length === 0) return void 0;
|
|
1625
|
+
const { id, desc } = sorting[0];
|
|
1626
|
+
const field = columnIdToField?.[id] ?? id;
|
|
1627
|
+
return { field, desc };
|
|
1628
|
+
}
|
|
1629
|
+
function selectedIdsToRowSelection(ids) {
|
|
1630
|
+
const state = {};
|
|
1631
|
+
for (const id of ids) {
|
|
1632
|
+
state[id] = true;
|
|
1633
|
+
}
|
|
1634
|
+
return state;
|
|
1635
|
+
}
|
|
1636
|
+
function rowSelectionToSelectedIds(selection) {
|
|
1637
|
+
return Object.keys(selection).filter((key) => selection[key]);
|
|
1638
|
+
}
|
|
1639
|
+
function getOrderFieldMappings(columns) {
|
|
1640
|
+
const columnIdToField = {};
|
|
1641
|
+
const fieldToColumnId = {};
|
|
1642
|
+
for (const col of columns) {
|
|
1643
|
+
const orderField = col.meta?.orderField;
|
|
1644
|
+
if (col.id && orderField) {
|
|
1645
|
+
columnIdToField[col.id] = orderField;
|
|
1646
|
+
fieldToColumnId[orderField] = col.id;
|
|
1647
|
+
}
|
|
1648
|
+
}
|
|
1649
|
+
return { columnIdToField, fieldToColumnId };
|
|
1650
|
+
}
|
|
1651
|
+
function getDefaultColumnVisibilityFromDefs(columns) {
|
|
1652
|
+
const defaults = {};
|
|
1653
|
+
for (const col of columns) {
|
|
1654
|
+
if (col.id != null && col.meta?.defaultVisible !== void 0) {
|
|
1655
|
+
defaults[col.id] = col.meta.defaultVisible;
|
|
1656
|
+
}
|
|
1657
|
+
}
|
|
1658
|
+
return defaults;
|
|
1659
|
+
}
|
|
1660
|
+
function getDirtyColumnVisibility(visibility, defaults) {
|
|
1661
|
+
const dirty = {};
|
|
1662
|
+
for (const [id, visible] of Object.entries(visibility)) {
|
|
1663
|
+
if (visible !== (defaults[id] ?? true)) {
|
|
1664
|
+
dirty[id] = visible;
|
|
1665
|
+
}
|
|
1666
|
+
}
|
|
1667
|
+
return dirty;
|
|
1668
|
+
}
|
|
1669
|
+
|
|
1670
|
+
// src/BiampTable/useBiampServerSideTable.ts
|
|
1671
|
+
var coreRowModel = getCoreRowModel();
|
|
1672
|
+
function useBiampServerSideTable({
|
|
1673
|
+
data,
|
|
1674
|
+
columns,
|
|
1675
|
+
getRowId = (row) => row.id,
|
|
1676
|
+
order,
|
|
1677
|
+
onOrderChange,
|
|
1678
|
+
page,
|
|
1679
|
+
rowsPerPage,
|
|
1680
|
+
onPageChange,
|
|
1681
|
+
rowCount,
|
|
1682
|
+
columnVisibility,
|
|
1683
|
+
onColumnVisibilityChange,
|
|
1684
|
+
selectedRowIds,
|
|
1685
|
+
onSelectedRowIdsChange,
|
|
1686
|
+
enableRowSelection
|
|
1687
|
+
}) {
|
|
1688
|
+
const defaultColumnVisibility = useMemo(
|
|
1689
|
+
() => getDefaultColumnVisibilityFromDefs(columns),
|
|
1690
|
+
[columns]
|
|
1691
|
+
);
|
|
1692
|
+
const { columnIdToField, fieldToColumnId } = useMemo(
|
|
1693
|
+
() => getOrderFieldMappings(columns),
|
|
1694
|
+
[columns]
|
|
1695
|
+
);
|
|
1696
|
+
const sorting = useMemo(
|
|
1697
|
+
() => orderToSorting(order, fieldToColumnId),
|
|
1698
|
+
[order, fieldToColumnId]
|
|
1699
|
+
);
|
|
1700
|
+
const hasPagination = page != null && rowsPerPage != null;
|
|
1701
|
+
const pagination = useMemo(
|
|
1702
|
+
() => hasPagination ? { pageIndex: page, pageSize: rowsPerPage } : void 0,
|
|
1703
|
+
[hasPagination, page, rowsPerPage]
|
|
1704
|
+
);
|
|
1705
|
+
const hasSelection = selectedRowIds != null;
|
|
1706
|
+
const rowSelection = useMemo(
|
|
1707
|
+
() => hasSelection ? selectedIdsToRowSelection(selectedRowIds) : void 0,
|
|
1708
|
+
[hasSelection, selectedRowIds]
|
|
1709
|
+
);
|
|
1710
|
+
const mergedVisibility = useMemo(
|
|
1711
|
+
() => toVisibilityState({
|
|
1712
|
+
...defaultColumnVisibility,
|
|
1713
|
+
...columnVisibility
|
|
1714
|
+
}),
|
|
1715
|
+
[defaultColumnVisibility, columnVisibility]
|
|
1716
|
+
);
|
|
1717
|
+
return useReactTable({
|
|
1718
|
+
data,
|
|
1719
|
+
columns,
|
|
1720
|
+
getCoreRowModel: coreRowModel,
|
|
1721
|
+
getRowId,
|
|
1722
|
+
// Sorting — always manual for server-side tables
|
|
1723
|
+
manualSorting: true,
|
|
1724
|
+
sortDescFirst: false,
|
|
1725
|
+
state: {
|
|
1726
|
+
sorting,
|
|
1727
|
+
...pagination && { pagination },
|
|
1728
|
+
columnVisibility: mergedVisibility,
|
|
1729
|
+
...rowSelection && { rowSelection }
|
|
1730
|
+
},
|
|
1731
|
+
onSortingChange: onOrderChange ? (updater) => {
|
|
1732
|
+
const next = typeof updater === "function" ? updater(sorting) : updater;
|
|
1733
|
+
onOrderChange(sortingToOrder(next, columnIdToField));
|
|
1734
|
+
} : void 0,
|
|
1735
|
+
// Pagination — only when page/rowsPerPage are provided
|
|
1736
|
+
...hasPagination && {
|
|
1737
|
+
manualPagination: true,
|
|
1738
|
+
rowCount: rowCount ?? 0,
|
|
1739
|
+
onPaginationChange: onPageChange ? (updater) => {
|
|
1740
|
+
const next = typeof updater === "function" ? updater(pagination) : updater;
|
|
1741
|
+
onPageChange(next.pageIndex);
|
|
1742
|
+
} : void 0
|
|
1743
|
+
},
|
|
1744
|
+
// Column visibility
|
|
1745
|
+
onColumnVisibilityChange: onColumnVisibilityChange ? (updater) => {
|
|
1746
|
+
const next = typeof updater === "function" ? updater(mergedVisibility) : updater;
|
|
1747
|
+
onColumnVisibilityChange(
|
|
1748
|
+
getDirtyColumnVisibility(next, defaultColumnVisibility)
|
|
1749
|
+
);
|
|
1750
|
+
} : void 0,
|
|
1751
|
+
// Row selection — only when selectedRowIds is provided
|
|
1752
|
+
...hasSelection && {
|
|
1753
|
+
enableRowSelection: enableRowSelection ?? true,
|
|
1754
|
+
onRowSelectionChange: onSelectedRowIdsChange ? (updater) => {
|
|
1755
|
+
const next = typeof updater === "function" ? updater(rowSelection) : updater;
|
|
1756
|
+
onSelectedRowIdsChange(rowSelectionToSelectedIds(next));
|
|
1757
|
+
} : void 0
|
|
1758
|
+
}
|
|
1759
|
+
});
|
|
1760
|
+
}
|
|
1761
|
+
|
|
1575
1762
|
// src/BiampTable/exportCsv.ts
|
|
1576
1763
|
function exportToCsv(rows, columns, filename = "export") {
|
|
1577
1764
|
const csvContent = buildCsvString(rows, columns);
|
|
@@ -1639,12 +1826,21 @@ export {
|
|
|
1639
1826
|
BiampTableToolbarExport,
|
|
1640
1827
|
BiampTableToolbarFilters,
|
|
1641
1828
|
BiampTableToolbarSearch,
|
|
1829
|
+
BiampTableTruncatedCell,
|
|
1642
1830
|
BiampWrapper,
|
|
1643
1831
|
buildCsvString,
|
|
1644
1832
|
exportToCsv,
|
|
1645
1833
|
getColumnVisibilityDirtyCount,
|
|
1646
1834
|
getDefaultColumnVisibility,
|
|
1835
|
+
getDefaultColumnVisibilityFromDefs,
|
|
1836
|
+
getDirtyColumnVisibility,
|
|
1837
|
+
getOrderFieldMappings,
|
|
1838
|
+
orderToSorting,
|
|
1839
|
+
rowSelectionToSelectedIds,
|
|
1840
|
+
selectedIdsToRowSelection,
|
|
1841
|
+
sortingToOrder,
|
|
1647
1842
|
toVisibilityState,
|
|
1843
|
+
useBiampServerSideTable,
|
|
1648
1844
|
useDebouncedCallback
|
|
1649
1845
|
};
|
|
1650
1846
|
//# sourceMappingURL=index.js.map
|