@bwp-web/components 0.11.3 → 0.11.5
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 +3 -1
- package/dist/BiampTable/BiampTable.d.ts.map +1 -1
- package/dist/BiampTable/BiampTablePagination.d.ts +5 -3
- package/dist/BiampTable/BiampTablePagination.d.ts.map +1 -1
- package/dist/BiampTable/BiampTableToolbarSearch.d.ts.map +1 -1
- package/dist/index.cjs +246 -185
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +252 -191
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
|
@@ -18,10 +18,12 @@ export type BiampTableProps<TData> = BoxProps & {
|
|
|
18
18
|
error?: boolean | Error | ReactNode;
|
|
19
19
|
/** When truthy and the table has no rows, shown instead of an empty body. Pass `true` for the default empty state, or a custom ReactNode. */
|
|
20
20
|
empty?: boolean | ReactNode;
|
|
21
|
+
/** When true, renders a checkbox column for row selection. @default false */
|
|
22
|
+
enableRowSelection?: boolean;
|
|
21
23
|
/** When true, hides the "select all" header checkbox while keeping individual row checkboxes. */
|
|
22
24
|
hideSelectAll?: boolean;
|
|
23
25
|
/** Returns a human-readable name for a row, used in ARIA labels (e.g. "Select: Conference Room A"). Falls back to row index. */
|
|
24
26
|
getRowLabel?: (row: TData) => string;
|
|
25
27
|
};
|
|
26
|
-
export declare function BiampTable<TData>({ table, onRowClick, isRowClickable, loading, error, empty, hideSelectAll, getRowLabel, sx, ...boxProps }: BiampTableProps<TData>): import("react/jsx-runtime").JSX.Element;
|
|
28
|
+
export declare function BiampTable<TData>({ table, onRowClick, isRowClickable, loading, error, empty, enableRowSelection, hideSelectAll, getRowLabel, sx, ...boxProps }: BiampTableProps<TData>): import("react/jsx-runtime").JSX.Element;
|
|
27
29
|
//# sourceMappingURL=BiampTable.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BiampTable.d.ts","sourceRoot":"","sources":["../../src/BiampTable/BiampTable.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,QAAQ,EAUd,MAAM,eAAe,CAAC;AAKvB,OAAO,EAAc,KAAK,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAc,EAAE,KAAK,SAAS,
|
|
1
|
+
{"version":3,"file":"BiampTable.d.ts","sourceRoot":"","sources":["../../src/BiampTable/BiampTable.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,QAAQ,EAUd,MAAM,eAAe,CAAC;AAKvB,OAAO,EAAc,KAAK,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAc,EAAE,KAAK,SAAS,EAAkC,MAAM,OAAO,CAAC;AAG9E,OAAO,iBAAiB,CAAC;AAGzB,MAAM,MAAM,eAAe,CAAC,KAAK,IAAI,QAAQ,GAAG;IAC9C,6CAA6C;IAC7C,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;IACpB,qFAAqF;IACrF,UAAU,CAAC,EAAE,CAAC,GAAG,EAAE,KAAK,KAAK,IAAI,CAAC;IAClC;;;OAGG;IACH,cAAc,CAAC,EAAE,CAAC,GAAG,EAAE,KAAK,KAAK,OAAO,CAAC;IACzC,oEAAoE;IACpE,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,wKAAwK;IACxK,KAAK,CAAC,EAAE,OAAO,GAAG,KAAK,GAAG,SAAS,CAAC;IACpC,6IAA6I;IAC7I,KAAK,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC5B,6EAA6E;IAC7E,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,iGAAiG;IACjG,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,gIAAgI;IAChI,WAAW,CAAC,EAAE,CAAC,GAAG,EAAE,KAAK,KAAK,MAAM,CAAC;CACtC,CAAC;AAEF,wBAAgB,UAAU,CAAC,KAAK,EAAE,EAChC,KAAK,EACL,UAAU,EACV,cAAc,EACd,OAAO,EACP,KAAK,EACL,KAAK,EACL,kBAA0B,EAC1B,aAAa,EACb,WAAW,EACX,EAAE,EACF,GAAG,QAAQ,EACZ,EAAE,eAAe,CAAC,KAAK,CAAC,2CAwSxB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type TablePaginationProps } from '@mui/material';
|
|
2
2
|
import type { Table } from '@tanstack/react-table';
|
|
3
3
|
export type BiampTablePaginationProps<TData> = {
|
|
4
4
|
/** TanStack Table instance to connect to. */
|
|
@@ -9,6 +9,8 @@ export type BiampTablePaginationProps<TData> = {
|
|
|
9
9
|
loading?: boolean;
|
|
10
10
|
/** Hide pagination when all rows fit on one page. @default true */
|
|
11
11
|
autoHide?: boolean;
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
/** Horizontal alignment of the pagination controls. @default 'center' */
|
|
13
|
+
position?: 'left' | 'center' | 'right';
|
|
14
|
+
} & Omit<TablePaginationProps<'div'>, 'component' | 'count' | 'page' | 'rowsPerPage' | 'onPageChange' | 'onRowsPerPageChange' | 'rowsPerPageOptions' | 'position'>;
|
|
15
|
+
export declare function BiampTablePagination<TData>({ table, rowsPerPageOptions, loading, autoHide, position, sx, ...paginationProps }: BiampTablePaginationProps<TData>): import("react/jsx-runtime").JSX.Element | null;
|
|
14
16
|
//# sourceMappingURL=BiampTablePagination.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BiampTablePagination.d.ts","sourceRoot":"","sources":["../../src/BiampTable/BiampTablePagination.tsx"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"BiampTablePagination.d.ts","sourceRoot":"","sources":["../../src/BiampTable/BiampTablePagination.tsx"],"names":[],"mappings":"AACA,OAAO,EAAmB,KAAK,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAC3E,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAEnD,MAAM,MAAM,yBAAyB,CAAC,KAAK,IAAI;IAC7C,6CAA6C;IAC7C,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;IACpB,sFAAsF;IACtF,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC9B,gFAAgF;IAChF,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,mEAAmE;IACnE,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,yEAAyE;IACzE,QAAQ,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC;CACxC,GAAG,IAAI,CACN,oBAAoB,CAAC,KAAK,CAAC,EACzB,WAAW,GACX,OAAO,GACP,MAAM,GACN,aAAa,GACb,cAAc,GACd,qBAAqB,GACrB,oBAAoB,GACpB,UAAU,CACb,CAAC;AAQF,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,EAC1C,KAAK,EACL,kBAAkB,EAClB,OAAO,EACP,QAAe,EACf,QAAmB,EACnB,EAAE,EACF,GAAG,eAAe,EACnB,EAAE,yBAAyB,CAAC,KAAK,CAAC,kDAkDlC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BiampTableToolbarSearch.d.ts","sourceRoot":"","sources":["../../src/BiampTable/BiampTableToolbarSearch.tsx"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,cAAc,EACpB,MAAM,eAAe,CAAC;AAQvB,MAAM,MAAM,4BAA4B,GAAG;IACzC,0EAA0E;IAC1E,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,mFAAmF;IACnF,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,gFAAgF;IAChF,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,2DAA2D;IAC3D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,oDAAoD;IACpD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,0CAA0C;IAC1C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,qEAAqE;IACrE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,uGAAuG;IACvG,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,+GAA+G;IAC/G,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,GAAG,IAAI,CAAC,cAAc,EAAE,UAAU,GAAG,OAAO,GAAG,cAAc,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"BiampTableToolbarSearch.d.ts","sourceRoot":"","sources":["../../src/BiampTable/BiampTableToolbarSearch.tsx"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,cAAc,EACpB,MAAM,eAAe,CAAC;AAQvB,MAAM,MAAM,4BAA4B,GAAG;IACzC,0EAA0E;IAC1E,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,mFAAmF;IACnF,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,gFAAgF;IAChF,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,2DAA2D;IAC3D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,oDAAoD;IACpD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,0CAA0C;IAC1C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,qEAAqE;IACrE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,uGAAuG;IACvG,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,+GAA+G;IAC/G,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,GAAG,IAAI,CAAC,cAAc,EAAE,UAAU,GAAG,OAAO,GAAG,cAAc,CAAC,CAAC;AAYhE,wBAAgB,uBAAuB,CAAC,EACtC,QAAQ,EACR,YAAiB,EACjB,aAA0C,EAC1C,SAAe,EACf,QAAc,EACd,WAAsB,EACtB,UAA2B,EAC3B,UAAkB,EAClB,WAAW,EACX,EAAE,EACF,GAAG,cAAc,EAClB,EAAE,4BAA4B,2CAmG9B"}
|
package/dist/index.cjs
CHANGED
|
@@ -517,6 +517,7 @@ function BiampLayout({
|
|
|
517
517
|
var import_material6 = require("@mui/material");
|
|
518
518
|
var import_assets5 = require("@bwp-web/assets");
|
|
519
519
|
var import_react_table = require("@tanstack/react-table");
|
|
520
|
+
var import_react3 = require("react");
|
|
520
521
|
|
|
521
522
|
// src/BiampTable/BiampTableEmptyState.tsx
|
|
522
523
|
var import_assets3 = require("@bwp-web/assets");
|
|
@@ -612,12 +613,12 @@ function BiampTable({
|
|
|
612
613
|
loading,
|
|
613
614
|
error,
|
|
614
615
|
empty,
|
|
616
|
+
enableRowSelection = false,
|
|
615
617
|
hideSelectAll,
|
|
616
618
|
getRowLabel,
|
|
617
619
|
sx,
|
|
618
620
|
...boxProps
|
|
619
621
|
}) {
|
|
620
|
-
const enableRowSelection = table.options.enableRowSelection === true || typeof table.options.enableRowSelection === "function";
|
|
621
622
|
const tableMinWidth = table.getVisibleLeafColumns().reduce(
|
|
622
623
|
(sum, col) => {
|
|
623
624
|
const mw = col.columnDef.meta?.minWidth;
|
|
@@ -625,198 +626,242 @@ function BiampTable({
|
|
|
625
626
|
},
|
|
626
627
|
enableRowSelection ? 48 : 0
|
|
627
628
|
);
|
|
628
|
-
const
|
|
629
|
+
const containerRef = (0, import_react3.useRef)(null);
|
|
630
|
+
const lastScrollLeftRef = (0, import_react3.useRef)(null);
|
|
631
|
+
const onContainerScroll = (0, import_react3.useCallback)((target) => {
|
|
632
|
+
const { scrollLeft, scrollWidth, clientWidth } = target;
|
|
633
|
+
if (!containerRef.current || lastScrollLeftRef.current === scrollLeft)
|
|
634
|
+
return;
|
|
635
|
+
containerRef.current.dataset["rightShadow"] = scrollWidth - clientWidth > scrollLeft ? "true" : "false";
|
|
636
|
+
lastScrollLeftRef.current = scrollLeft;
|
|
637
|
+
}, []);
|
|
638
|
+
(0, import_react3.useEffect)(() => {
|
|
639
|
+
if (!containerRef.current) return;
|
|
640
|
+
const observer = new ResizeObserver(
|
|
641
|
+
([{ target }]) => onContainerScroll(target)
|
|
642
|
+
);
|
|
643
|
+
observer.observe(containerRef.current);
|
|
644
|
+
return () => observer.disconnect();
|
|
645
|
+
}, [onContainerScroll]);
|
|
629
646
|
const showLoading = useLoadingDelay(!!loading);
|
|
630
647
|
const rows = table.getRowModel().rows;
|
|
631
|
-
const showError = !!error;
|
|
632
|
-
const showEmpty = !showError && rows.length === 0;
|
|
633
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.
|
|
648
|
+
const showError = !!error && !loading;
|
|
649
|
+
const showEmpty = !showError && !loading && rows.length === 0;
|
|
650
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
634
651
|
import_material6.TableContainer,
|
|
635
652
|
{
|
|
636
653
|
component: import_material6.Box,
|
|
637
654
|
...boxProps,
|
|
655
|
+
ref: containerRef,
|
|
656
|
+
onScroll: (e) => onContainerScroll(e.currentTarget),
|
|
638
657
|
sx: {
|
|
639
658
|
display: "flex",
|
|
640
659
|
flexDirection: "column",
|
|
641
660
|
height: "100%",
|
|
642
661
|
overflow: "auto",
|
|
643
662
|
overscrollBehavior: "none",
|
|
663
|
+
position: "relative",
|
|
664
|
+
'& [data-sticky="right"]': {
|
|
665
|
+
transition: "box-shadow .2s"
|
|
666
|
+
},
|
|
667
|
+
'&[data-right-shadow="true"] [data-sticky="right"]': {
|
|
668
|
+
boxShadow: ({ palette }) => `-16px 0px 12px -2px ${palette.background.default}`
|
|
669
|
+
},
|
|
644
670
|
...sx
|
|
645
671
|
},
|
|
646
|
-
children:
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
minWidth: tableMinWidth,
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_material6.TableHead, { children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_material6.TableRow, { children: [
|
|
656
|
-
enableRowSelection && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
657
|
-
import_material6.TableCell,
|
|
658
|
-
{
|
|
659
|
-
padding: "checkbox",
|
|
660
|
-
sx: {
|
|
661
|
-
position: "sticky",
|
|
662
|
-
left: 0,
|
|
663
|
-
zIndex: 3,
|
|
664
|
-
bgcolor: "background.paper"
|
|
665
|
-
},
|
|
666
|
-
children: !hideSelectAll && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
667
|
-
import_material6.Checkbox,
|
|
668
|
-
{
|
|
669
|
-
checked: table.getIsAllPageRowsSelected(),
|
|
670
|
-
indeterminate: table.getIsSomePageRowsSelected(),
|
|
671
|
-
onChange: table.getToggleAllPageRowsSelectedHandler(),
|
|
672
|
-
slotProps: { input: { "aria-label": "Select all rows" } }
|
|
673
|
-
}
|
|
674
|
-
)
|
|
675
|
-
}
|
|
676
|
-
),
|
|
677
|
-
headerGroup.headers.map((header) => {
|
|
678
|
-
const sticky = header.column.columnDef.meta?.sticky;
|
|
679
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
672
|
+
children: [
|
|
673
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
674
|
+
import_material6.Table,
|
|
675
|
+
{
|
|
676
|
+
"aria-busy": showLoading || void 0,
|
|
677
|
+
sx: { minWidth: tableMinWidth, tableLayout: "auto" },
|
|
678
|
+
children: [
|
|
679
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_material6.TableHead, { children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_material6.TableRow, { children: [
|
|
680
|
+
enableRowSelection && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
680
681
|
import_material6.TableCell,
|
|
681
682
|
{
|
|
682
|
-
|
|
683
|
-
...header.column.getCanSort() && {
|
|
684
|
-
"aria-sort": header.column.getIsSorted() ? header.column.getIsSorted() === "asc" ? "ascending" : "descending" : "none"
|
|
685
|
-
},
|
|
683
|
+
padding: "checkbox",
|
|
686
684
|
sx: {
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
zIndex: 3,
|
|
692
|
-
bgcolor: "background.paper"
|
|
693
|
-
}
|
|
685
|
+
position: "sticky",
|
|
686
|
+
left: 0,
|
|
687
|
+
zIndex: 3,
|
|
688
|
+
bgcolor: "background.paper"
|
|
694
689
|
},
|
|
695
|
-
children:
|
|
696
|
-
import_material6.
|
|
690
|
+
children: !hideSelectAll && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
691
|
+
import_material6.Checkbox,
|
|
697
692
|
{
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
IconComponent: header.column.getIsSorted() === "asc" ? import_assets5.DropdownChevronUpIcon : import_assets5.DropdownChevronDownIcon
|
|
703
|
-
},
|
|
704
|
-
children: (0, import_react_table.flexRender)(
|
|
705
|
-
header.column.columnDef.header,
|
|
706
|
-
header.getContext()
|
|
707
|
-
)
|
|
693
|
+
checked: table.getIsAllPageRowsSelected(),
|
|
694
|
+
indeterminate: table.getIsSomePageRowsSelected(),
|
|
695
|
+
onChange: table.getToggleAllPageRowsSelectedHandler(),
|
|
696
|
+
slotProps: { input: { "aria-label": "Select all rows" } }
|
|
708
697
|
}
|
|
709
|
-
) : (0, import_react_table.flexRender)(
|
|
710
|
-
header.column.columnDef.header,
|
|
711
|
-
header.getContext()
|
|
712
698
|
)
|
|
713
|
-
}
|
|
714
|
-
|
|
715
|
-
)
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
}
|
|
729
|
-
) }) : showEmpty ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_material6.TableRow, { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
730
|
-
import_material6.TableCell,
|
|
731
|
-
{
|
|
732
|
-
colSpan: totalColumns,
|
|
733
|
-
sx: {
|
|
734
|
-
textAlign: "center",
|
|
735
|
-
verticalAlign: "middle",
|
|
736
|
-
height: "100%"
|
|
737
|
-
},
|
|
738
|
-
children: empty && empty !== true ? empty : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(BiampTableEmptyState, {})
|
|
739
|
-
}
|
|
740
|
-
) }) : rows.map((row) => {
|
|
741
|
-
const clickable = onRowClick ? isRowClickable ? isRowClickable(row.original) : true : false;
|
|
742
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
743
|
-
import_material6.TableRow,
|
|
744
|
-
{
|
|
745
|
-
hover: clickable,
|
|
746
|
-
selected: enableRowSelection ? row.getIsSelected() : void 0,
|
|
747
|
-
role: clickable ? "button" : void 0,
|
|
748
|
-
tabIndex: clickable ? 0 : void 0,
|
|
749
|
-
sx: { cursor: clickable ? "pointer" : void 0 },
|
|
750
|
-
onClick: clickable && onRowClick ? () => onRowClick(row.original) : void 0,
|
|
751
|
-
onKeyDown: clickable && onRowClick ? (e) => {
|
|
752
|
-
if (e.key === "Enter" || e.key === " ") {
|
|
753
|
-
e.preventDefault();
|
|
754
|
-
onRowClick(row.original);
|
|
755
|
-
}
|
|
756
|
-
} : void 0,
|
|
757
|
-
children: [
|
|
758
|
-
enableRowSelection && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
759
|
-
import_material6.TableCell,
|
|
760
|
-
{
|
|
761
|
-
padding: "checkbox",
|
|
762
|
-
sx: {
|
|
699
|
+
}
|
|
700
|
+
),
|
|
701
|
+
headerGroup.headers.map((header) => {
|
|
702
|
+
const sticky = header.column.columnDef.meta?.sticky;
|
|
703
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
704
|
+
import_material6.TableCell,
|
|
705
|
+
{
|
|
706
|
+
"data-sticky": sticky || void 0,
|
|
707
|
+
sortDirection: header.column.getIsSorted() || false,
|
|
708
|
+
...header.column.getCanSort() && {
|
|
709
|
+
"aria-sort": header.column.getIsSorted() ? header.column.getIsSorted() === "asc" ? "ascending" : "descending" : "none"
|
|
710
|
+
},
|
|
711
|
+
sx: {
|
|
712
|
+
minWidth: header.column.columnDef.meta?.minWidth ?? 40,
|
|
713
|
+
...sticky && {
|
|
763
714
|
position: "sticky",
|
|
764
|
-
|
|
765
|
-
zIndex:
|
|
766
|
-
bgcolor: "background.paper"
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
715
|
+
[sticky]: 0,
|
|
716
|
+
zIndex: 3,
|
|
717
|
+
bgcolor: "background.paper"
|
|
718
|
+
}
|
|
719
|
+
},
|
|
720
|
+
children: header.isPlaceholder ? null : header.column.getCanSort() ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
721
|
+
import_material6.TableSortLabel,
|
|
722
|
+
{
|
|
723
|
+
active: !!header.column.getIsSorted(),
|
|
724
|
+
direction: header.column.getIsSorted() || "asc",
|
|
725
|
+
onClick: header.column.getToggleSortingHandler(),
|
|
726
|
+
...header.column.getIsSorted() && {
|
|
727
|
+
IconComponent: header.column.getIsSorted() === "asc" ? import_assets5.DropdownChevronUpIcon : import_assets5.DropdownChevronDownIcon
|
|
728
|
+
},
|
|
729
|
+
children: (0, import_react_table.flexRender)(
|
|
730
|
+
header.column.columnDef.header,
|
|
731
|
+
header.getContext()
|
|
732
|
+
)
|
|
733
|
+
}
|
|
734
|
+
) : (0, import_react_table.flexRender)(
|
|
735
|
+
header.column.columnDef.header,
|
|
736
|
+
header.getContext()
|
|
737
|
+
)
|
|
738
|
+
},
|
|
739
|
+
header.id
|
|
740
|
+
);
|
|
741
|
+
})
|
|
742
|
+
] }, headerGroup.id)) }),
|
|
743
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_material6.TableBody, { sx: { opacity: showLoading ? 0.3 : 1 }, children: !showError && rows.map((row) => {
|
|
744
|
+
const clickable = onRowClick ? isRowClickable ? isRowClickable(row.original) : true : false;
|
|
745
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
746
|
+
import_material6.TableRow,
|
|
747
|
+
{
|
|
748
|
+
hover: clickable,
|
|
749
|
+
selected: enableRowSelection ? row.getIsSelected() : void 0,
|
|
750
|
+
role: clickable ? "button" : void 0,
|
|
751
|
+
tabIndex: clickable ? 0 : void 0,
|
|
752
|
+
sx: { cursor: clickable ? "pointer" : void 0 },
|
|
753
|
+
onClick: clickable && onRowClick ? () => onRowClick(row.original) : void 0,
|
|
754
|
+
onKeyDown: clickable && onRowClick ? (e) => {
|
|
755
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
756
|
+
e.preventDefault();
|
|
757
|
+
onRowClick(row.original);
|
|
785
758
|
}
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
759
|
+
} : void 0,
|
|
760
|
+
children: [
|
|
761
|
+
enableRowSelection && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
790
762
|
import_material6.TableCell,
|
|
791
763
|
{
|
|
764
|
+
padding: "checkbox",
|
|
792
765
|
sx: {
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
bgcolor: "
|
|
799
|
-
".MuiTableRow-hover:hover > &, .Mui-selected > &": {
|
|
800
|
-
bgcolor: ({ palette }) => palette.mode === "dark" ? palette.grey[800] : palette.grey[100]
|
|
801
|
-
}
|
|
766
|
+
position: "sticky",
|
|
767
|
+
left: 0,
|
|
768
|
+
zIndex: 2,
|
|
769
|
+
bgcolor: "background.paper",
|
|
770
|
+
".MuiTableRow-hover:hover > &, .Mui-selected > &": {
|
|
771
|
+
bgcolor: ({ palette }) => palette.mode === "dark" ? palette.grey[800] : palette.grey[100]
|
|
802
772
|
}
|
|
803
773
|
},
|
|
804
|
-
children: (0,
|
|
805
|
-
|
|
806
|
-
|
|
774
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
775
|
+
import_material6.Checkbox,
|
|
776
|
+
{
|
|
777
|
+
checked: row.getIsSelected(),
|
|
778
|
+
disabled: !row.getCanSelect(),
|
|
779
|
+
onChange: row.getToggleSelectedHandler(),
|
|
780
|
+
onClick: (e) => e.stopPropagation(),
|
|
781
|
+
slotProps: {
|
|
782
|
+
input: {
|
|
783
|
+
"aria-label": getRowLabel ? `Select ${getRowLabel(row.original)}` : `Select row ${row.index + 1}`
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
}
|
|
807
787
|
)
|
|
808
|
-
}
|
|
809
|
-
|
|
810
|
-
)
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
788
|
+
}
|
|
789
|
+
),
|
|
790
|
+
row.getVisibleCells().map((cell) => {
|
|
791
|
+
const sticky = cell.column.columnDef.meta?.sticky;
|
|
792
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
793
|
+
import_material6.TableCell,
|
|
794
|
+
{
|
|
795
|
+
"data-sticky": sticky || void 0,
|
|
796
|
+
sx: {
|
|
797
|
+
minWidth: cell.column.columnDef.meta?.minWidth ?? 40,
|
|
798
|
+
...sticky && {
|
|
799
|
+
position: "sticky",
|
|
800
|
+
[sticky]: 0,
|
|
801
|
+
zIndex: 2,
|
|
802
|
+
bgcolor: "background.paper",
|
|
803
|
+
".MuiTableRow-hover:hover > &, .Mui-selected > &": {
|
|
804
|
+
bgcolor: ({ palette }) => palette.mode === "dark" ? palette.grey[800] : palette.grey[100]
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
},
|
|
808
|
+
children: (0, import_react_table.flexRender)(
|
|
809
|
+
cell.column.columnDef.cell,
|
|
810
|
+
cell.getContext()
|
|
811
|
+
)
|
|
812
|
+
},
|
|
813
|
+
cell.id
|
|
814
|
+
);
|
|
815
|
+
})
|
|
816
|
+
]
|
|
817
|
+
},
|
|
818
|
+
row.id
|
|
819
|
+
);
|
|
820
|
+
}) })
|
|
821
|
+
]
|
|
822
|
+
}
|
|
823
|
+
),
|
|
824
|
+
showError && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
825
|
+
import_material6.Box,
|
|
826
|
+
{
|
|
827
|
+
sx: {
|
|
828
|
+
position: "absolute",
|
|
829
|
+
top: 0,
|
|
830
|
+
left: 0,
|
|
831
|
+
right: 0,
|
|
832
|
+
bottom: 0,
|
|
833
|
+
display: "flex",
|
|
834
|
+
alignItems: "center",
|
|
835
|
+
justifyContent: "center",
|
|
836
|
+
pointerEvents: "none"
|
|
837
|
+
},
|
|
838
|
+
children: error === true ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(BiampTableErrorState, { sx: { pointerEvents: "auto" } }) : error instanceof Error ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
839
|
+
BiampTableErrorState,
|
|
840
|
+
{
|
|
841
|
+
description: error.message,
|
|
842
|
+
sx: { pointerEvents: "auto" }
|
|
843
|
+
}
|
|
844
|
+
) : error
|
|
845
|
+
}
|
|
846
|
+
),
|
|
847
|
+
showEmpty && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
848
|
+
import_material6.Box,
|
|
849
|
+
{
|
|
850
|
+
sx: {
|
|
851
|
+
position: "absolute",
|
|
852
|
+
top: 0,
|
|
853
|
+
left: 0,
|
|
854
|
+
right: 0,
|
|
855
|
+
bottom: 0,
|
|
856
|
+
display: "flex",
|
|
857
|
+
alignItems: "center",
|
|
858
|
+
justifyContent: "center",
|
|
859
|
+
pointerEvents: "none"
|
|
860
|
+
},
|
|
861
|
+
children: empty && empty !== true ? empty : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(BiampTableEmptyState, { sx: { pointerEvents: "auto" } })
|
|
862
|
+
}
|
|
863
|
+
)
|
|
864
|
+
]
|
|
820
865
|
}
|
|
821
866
|
);
|
|
822
867
|
}
|
|
@@ -985,7 +1030,7 @@ function BiampTableColumnVisibility({
|
|
|
985
1030
|
|
|
986
1031
|
// src/BiampTable/BiampTableToolbarColumnVisibility.tsx
|
|
987
1032
|
var import_assets6 = require("@bwp-web/assets");
|
|
988
|
-
var
|
|
1033
|
+
var import_react4 = require("react");
|
|
989
1034
|
|
|
990
1035
|
// src/BiampTable/BiampTableToolbarActionButton.tsx
|
|
991
1036
|
var import_material10 = require("@mui/material");
|
|
@@ -1035,7 +1080,7 @@ function BiampTableToolbarColumnVisibility({
|
|
|
1035
1080
|
showAllLabel,
|
|
1036
1081
|
...actionButtonProps
|
|
1037
1082
|
}) {
|
|
1038
|
-
const [anchorEl, setAnchorEl] = (0,
|
|
1083
|
+
const [anchorEl, setAnchorEl] = (0, import_react4.useState)(null);
|
|
1039
1084
|
const defaults = defaultColumnVisibility ?? getDefaultColumnVisibility(table);
|
|
1040
1085
|
const dirtyCount = getColumnVisibilityDirtyCount(table, defaults);
|
|
1041
1086
|
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
|
|
@@ -1062,29 +1107,40 @@ function BiampTableToolbarColumnVisibility({
|
|
|
1062
1107
|
}
|
|
1063
1108
|
|
|
1064
1109
|
// src/BiampTable/BiampTablePagination.tsx
|
|
1065
|
-
var
|
|
1110
|
+
var import_react5 = require("react");
|
|
1066
1111
|
var import_material11 = require("@mui/material");
|
|
1067
1112
|
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
1113
|
+
var positionMap = {
|
|
1114
|
+
left: "flex-start",
|
|
1115
|
+
center: "center",
|
|
1116
|
+
right: "flex-end"
|
|
1117
|
+
};
|
|
1068
1118
|
function BiampTablePagination({
|
|
1069
1119
|
table,
|
|
1070
1120
|
rowsPerPageOptions,
|
|
1071
1121
|
loading,
|
|
1072
1122
|
autoHide = true,
|
|
1123
|
+
position = "center",
|
|
1073
1124
|
sx,
|
|
1074
1125
|
...paginationProps
|
|
1075
1126
|
}) {
|
|
1076
1127
|
const rowCount = table.getRowCount();
|
|
1077
|
-
const lastRowCountRef = (0,
|
|
1128
|
+
const lastRowCountRef = (0, import_react5.useRef)(rowCount);
|
|
1078
1129
|
if (!loading && rowCount >= 0) {
|
|
1079
1130
|
lastRowCountRef.current = rowCount;
|
|
1080
1131
|
}
|
|
1081
1132
|
const stableCount = loading ? lastRowCountRef.current : rowCount;
|
|
1082
|
-
const pageSize = table.getState().pagination
|
|
1083
|
-
|
|
1133
|
+
const { pageSize, pageIndex } = table.getState().pagination;
|
|
1134
|
+
const maxPage = Math.max(0, Math.ceil(stableCount / pageSize) - 1);
|
|
1135
|
+
if (!loading && pageIndex > maxPage) {
|
|
1136
|
+
table.setPageIndex(maxPage);
|
|
1137
|
+
}
|
|
1138
|
+
if (autoHide && !loading && (!stableCount || stableCount <= pageSize))
|
|
1139
|
+
return null;
|
|
1084
1140
|
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1085
1141
|
import_material11.TablePagination,
|
|
1086
1142
|
{
|
|
1087
|
-
component:
|
|
1143
|
+
component: "div",
|
|
1088
1144
|
count: stableCount,
|
|
1089
1145
|
page: table.getState().pagination.pageIndex,
|
|
1090
1146
|
rowsPerPage: table.getState().pagination.pageSize,
|
|
@@ -1097,6 +1153,8 @@ function BiampTablePagination({
|
|
|
1097
1153
|
showFirstButton: true,
|
|
1098
1154
|
showLastButton: true,
|
|
1099
1155
|
sx: {
|
|
1156
|
+
display: "flex",
|
|
1157
|
+
justifyContent: positionMap[position],
|
|
1100
1158
|
height: 40,
|
|
1101
1159
|
minHeight: 40,
|
|
1102
1160
|
"& .MuiToolbar-root": {
|
|
@@ -1172,7 +1230,7 @@ function BiampTableToolbarExport({
|
|
|
1172
1230
|
// src/BiampTable/BiampTableToolbarFilters.tsx
|
|
1173
1231
|
var import_material15 = require("@mui/material");
|
|
1174
1232
|
var import_assets8 = require("@bwp-web/assets");
|
|
1175
|
-
var
|
|
1233
|
+
var import_react6 = require("react");
|
|
1176
1234
|
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
1177
1235
|
function BiampTableToolbarFilters({
|
|
1178
1236
|
activeFilterCount,
|
|
@@ -1187,8 +1245,8 @@ function BiampTableToolbarFilters({
|
|
|
1187
1245
|
buttonLabel = "Filters",
|
|
1188
1246
|
DrawerProps: drawerProps
|
|
1189
1247
|
}) {
|
|
1190
|
-
const [open, setOpen] = (0,
|
|
1191
|
-
const titleId = (0,
|
|
1248
|
+
const [open, setOpen] = (0, import_react6.useState)(false);
|
|
1249
|
+
const titleId = (0, import_react6.useId)();
|
|
1192
1250
|
function handleClose() {
|
|
1193
1251
|
onApply?.();
|
|
1194
1252
|
setOpen(false);
|
|
@@ -1305,21 +1363,21 @@ function BiampTableToolbarFilters({
|
|
|
1305
1363
|
// src/BiampTable/BiampTableToolbarSearch.tsx
|
|
1306
1364
|
var import_material16 = require("@mui/material");
|
|
1307
1365
|
var import_assets9 = require("@bwp-web/assets");
|
|
1308
|
-
var
|
|
1366
|
+
var import_react8 = require("react");
|
|
1309
1367
|
|
|
1310
1368
|
// src/BiampTable/useDebouncedCallback.ts
|
|
1311
|
-
var
|
|
1369
|
+
var import_react7 = require("react");
|
|
1312
1370
|
var BIAMP_TABLE_DEBOUNCE_DELAY = 300;
|
|
1313
1371
|
function useDebouncedCallback(callback, delay = BIAMP_TABLE_DEBOUNCE_DELAY) {
|
|
1314
|
-
const timeoutRef = (0,
|
|
1315
|
-
const callbackRef = (0,
|
|
1372
|
+
const timeoutRef = (0, import_react7.useRef)(null);
|
|
1373
|
+
const callbackRef = (0, import_react7.useRef)(callback);
|
|
1316
1374
|
callbackRef.current = callback;
|
|
1317
|
-
(0,
|
|
1375
|
+
(0, import_react7.useEffect)(() => {
|
|
1318
1376
|
return () => {
|
|
1319
1377
|
if (timeoutRef.current !== null) clearTimeout(timeoutRef.current);
|
|
1320
1378
|
};
|
|
1321
1379
|
}, []);
|
|
1322
|
-
return (0,
|
|
1380
|
+
return (0, import_react7.useCallback)(
|
|
1323
1381
|
(...args) => {
|
|
1324
1382
|
if (timeoutRef.current !== null) clearTimeout(timeoutRef.current);
|
|
1325
1383
|
timeoutRef.current = setTimeout(
|
|
@@ -1335,8 +1393,11 @@ function useDebouncedCallback(callback, delay = BIAMP_TABLE_DEBOUNCE_DELAY) {
|
|
|
1335
1393
|
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
1336
1394
|
var searchFieldSx = {
|
|
1337
1395
|
"& .MuiInputBase-root": {
|
|
1338
|
-
height:
|
|
1339
|
-
minHeight:
|
|
1396
|
+
height: "36px !important",
|
|
1397
|
+
minHeight: "36px !important"
|
|
1398
|
+
},
|
|
1399
|
+
"& .MuiOutlinedInput-notchedOutline": {
|
|
1400
|
+
height: "36px !important"
|
|
1340
1401
|
}
|
|
1341
1402
|
};
|
|
1342
1403
|
function BiampTableToolbarSearch({
|
|
@@ -1352,10 +1413,10 @@ function BiampTableToolbarSearch({
|
|
|
1352
1413
|
sx,
|
|
1353
1414
|
...textFieldProps
|
|
1354
1415
|
}) {
|
|
1355
|
-
const [inputValue, setInputValue] = (0,
|
|
1356
|
-
const [isExpanded, setIsExpanded] = (0,
|
|
1416
|
+
const [inputValue, setInputValue] = (0, import_react8.useState)(defaultValue);
|
|
1417
|
+
const [isExpanded, setIsExpanded] = (0, import_react8.useState)(false);
|
|
1357
1418
|
const debouncedOnChange = useDebouncedCallback(onChange, debounceDelay);
|
|
1358
|
-
(0,
|
|
1419
|
+
(0, import_react8.useEffect)(() => {
|
|
1359
1420
|
setInputValue(defaultValue);
|
|
1360
1421
|
}, [defaultValue]);
|
|
1361
1422
|
const handleChange = (e) => {
|