@bwp-web/components 0.11.1 → 0.11.3
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/BiampTableColumnVisibility.d.ts +23 -6
- package/dist/BiampTable/BiampTableColumnVisibility.d.ts.map +1 -1
- package/dist/BiampTable/BiampTableContainer.d.ts +1 -1
- package/dist/BiampTable/BiampTableContainer.d.ts.map +1 -1
- package/dist/BiampTable/BiampTablePagination.d.ts +4 -4
- package/dist/BiampTable/BiampTablePagination.d.ts.map +1 -1
- package/dist/BiampTable/BiampTableToolbar.d.ts +1 -1
- package/dist/BiampTable/BiampTableToolbar.d.ts.map +1 -1
- package/dist/BiampTable/BiampTableToolbarColumnVisibility.d.ts +21 -0
- package/dist/BiampTable/BiampTableToolbarColumnVisibility.d.ts.map +1 -0
- package/dist/BiampTable/BiampTableToolbarSearch.d.ts +5 -1
- package/dist/BiampTable/BiampTableToolbarSearch.d.ts.map +1 -1
- package/dist/BiampTable/exportCsv.d.ts +15 -0
- package/dist/BiampTable/exportCsv.d.ts.map +1 -0
- package/dist/BiampTable/index.d.ts +3 -1
- package/dist/BiampTable/index.d.ts.map +1 -1
- package/dist/BiampTable/tanstack-meta.d.ts +2 -0
- package/dist/BiampTable/tanstack-meta.d.ts.map +1 -1
- package/dist/index.cjs +252 -103
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +255 -109
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -791,6 +791,7 @@ function BiampTableContainer({
|
|
|
791
791
|
withBorderTop = true,
|
|
792
792
|
withBorderBottom = false,
|
|
793
793
|
children,
|
|
794
|
+
sx,
|
|
794
795
|
...props
|
|
795
796
|
}) {
|
|
796
797
|
return /* @__PURE__ */ jsx8(
|
|
@@ -799,10 +800,12 @@ function BiampTableContainer({
|
|
|
799
800
|
direction: "column",
|
|
800
801
|
height: "100%",
|
|
801
802
|
overflow: "hidden",
|
|
803
|
+
px: { xs: 2, sm: 3, xl: 12.5 },
|
|
802
804
|
py: { xs: 0, md: 1.5 },
|
|
803
805
|
gap: { xs: 0, md: 1 },
|
|
804
806
|
borderTop: withBorderTop ? ({ palette }) => `0.6px solid ${palette.divider}` : void 0,
|
|
805
807
|
borderBottom: withBorderBottom ? ({ palette }) => `0.6px solid ${palette.divider}` : void 0,
|
|
808
|
+
sx: { ...sx },
|
|
806
809
|
...props,
|
|
807
810
|
children
|
|
808
811
|
}
|
|
@@ -837,14 +840,25 @@ import {
|
|
|
837
840
|
Popover as Popover2,
|
|
838
841
|
Typography as Typography3
|
|
839
842
|
} from "@mui/material";
|
|
840
|
-
import { useEffect as useEffect2, useRef as useRef2 } from "react";
|
|
841
843
|
import { jsx as jsx10, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
842
|
-
function
|
|
844
|
+
function toVisibilityState(visibility) {
|
|
845
|
+
return visibility;
|
|
846
|
+
}
|
|
847
|
+
function getDefaultColumnVisibility(table) {
|
|
848
|
+
const result = {};
|
|
849
|
+
for (const col of table.getAllLeafColumns()) {
|
|
850
|
+
const dv = col.columnDef.meta?.defaultVisible;
|
|
851
|
+
if (dv !== void 0) result[col.id] = dv;
|
|
852
|
+
}
|
|
853
|
+
return result;
|
|
854
|
+
}
|
|
855
|
+
function getColumnVisibilityDirtyCount(table, defaultVisibility) {
|
|
843
856
|
const current = table.getState().columnVisibility;
|
|
857
|
+
const defaults = defaultVisibility ?? getDefaultColumnVisibility(table);
|
|
844
858
|
let count = 0;
|
|
845
859
|
for (const col of table.getAllLeafColumns()) {
|
|
846
860
|
const isVisible = current[col.id] ?? true;
|
|
847
|
-
const wasVisible =
|
|
861
|
+
const wasVisible = defaults[col.id] ?? true;
|
|
848
862
|
if (isVisible !== wasVisible) count++;
|
|
849
863
|
}
|
|
850
864
|
return count;
|
|
@@ -861,7 +875,6 @@ var columnListItemSx = {
|
|
|
861
875
|
};
|
|
862
876
|
function BiampTableColumnVisibility({
|
|
863
877
|
table,
|
|
864
|
-
onChange,
|
|
865
878
|
showAllLabel = "Show all",
|
|
866
879
|
anchorEl,
|
|
867
880
|
anchorOrigin = { vertical: "bottom", horizontal: "right" },
|
|
@@ -869,13 +882,6 @@ function BiampTableColumnVisibility({
|
|
|
869
882
|
slotProps,
|
|
870
883
|
...popoverProps
|
|
871
884
|
}) {
|
|
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
885
|
const allVisible = table.getAllLeafColumns().every((col) => col.getIsVisible());
|
|
880
886
|
const someVisible = table.getAllLeafColumns().some((col) => col.getIsVisible());
|
|
881
887
|
return /* @__PURE__ */ jsx10(
|
|
@@ -949,29 +955,111 @@ function BiampTableColumnVisibility({
|
|
|
949
955
|
);
|
|
950
956
|
}
|
|
951
957
|
|
|
958
|
+
// src/BiampTable/BiampTableToolbarColumnVisibility.tsx
|
|
959
|
+
import { ColumnsIcon } from "@bwp-web/assets";
|
|
960
|
+
import { useState as useState2 } from "react";
|
|
961
|
+
|
|
962
|
+
// src/BiampTable/BiampTableToolbarActionButton.tsx
|
|
963
|
+
import {
|
|
964
|
+
Badge,
|
|
965
|
+
IconButton as IconButton2
|
|
966
|
+
} from "@mui/material";
|
|
967
|
+
import { jsx as jsx11 } from "react/jsx-runtime";
|
|
968
|
+
function BiampTableToolbarActionButton({
|
|
969
|
+
label,
|
|
970
|
+
icon,
|
|
971
|
+
badgeContent,
|
|
972
|
+
...props
|
|
973
|
+
}) {
|
|
974
|
+
const showBadge = badgeContent != null && badgeContent !== 0;
|
|
975
|
+
return /* @__PURE__ */ jsx11(
|
|
976
|
+
IconButton2,
|
|
977
|
+
{
|
|
978
|
+
"aria-label": showBadge ? `${label} (${badgeContent})` : label,
|
|
979
|
+
...props,
|
|
980
|
+
children: showBadge ? /* @__PURE__ */ jsx11(
|
|
981
|
+
Badge,
|
|
982
|
+
{
|
|
983
|
+
badgeContent,
|
|
984
|
+
color: "info",
|
|
985
|
+
variant: "dot",
|
|
986
|
+
sx: {
|
|
987
|
+
"& .MuiBadge-badge": {
|
|
988
|
+
width: 6,
|
|
989
|
+
height: 6,
|
|
990
|
+
minWidth: 6,
|
|
991
|
+
borderRadius: "50%",
|
|
992
|
+
top: 0,
|
|
993
|
+
right: -3
|
|
994
|
+
}
|
|
995
|
+
},
|
|
996
|
+
children: icon
|
|
997
|
+
}
|
|
998
|
+
) : icon
|
|
999
|
+
}
|
|
1000
|
+
);
|
|
1001
|
+
}
|
|
1002
|
+
|
|
1003
|
+
// src/BiampTable/BiampTableToolbarColumnVisibility.tsx
|
|
1004
|
+
import { Fragment, jsx as jsx12, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1005
|
+
function BiampTableToolbarColumnVisibility({
|
|
1006
|
+
table,
|
|
1007
|
+
icon = /* @__PURE__ */ jsx12(ColumnsIcon, { variant: "xs" }),
|
|
1008
|
+
label = "Columns",
|
|
1009
|
+
defaultColumnVisibility,
|
|
1010
|
+
showAllLabel,
|
|
1011
|
+
...actionButtonProps
|
|
1012
|
+
}) {
|
|
1013
|
+
const [anchorEl, setAnchorEl] = useState2(null);
|
|
1014
|
+
const defaults = defaultColumnVisibility ?? getDefaultColumnVisibility(table);
|
|
1015
|
+
const dirtyCount = getColumnVisibilityDirtyCount(table, defaults);
|
|
1016
|
+
return /* @__PURE__ */ jsxs7(Fragment, { children: [
|
|
1017
|
+
/* @__PURE__ */ jsx12(
|
|
1018
|
+
BiampTableToolbarActionButton,
|
|
1019
|
+
{
|
|
1020
|
+
label,
|
|
1021
|
+
icon,
|
|
1022
|
+
badgeContent: dirtyCount,
|
|
1023
|
+
onClick: (e) => setAnchorEl(e.currentTarget),
|
|
1024
|
+
...actionButtonProps
|
|
1025
|
+
}
|
|
1026
|
+
),
|
|
1027
|
+
/* @__PURE__ */ jsx12(
|
|
1028
|
+
BiampTableColumnVisibility,
|
|
1029
|
+
{
|
|
1030
|
+
table,
|
|
1031
|
+
anchorEl,
|
|
1032
|
+
onClose: () => setAnchorEl(null),
|
|
1033
|
+
showAllLabel
|
|
1034
|
+
}
|
|
1035
|
+
)
|
|
1036
|
+
] });
|
|
1037
|
+
}
|
|
1038
|
+
|
|
952
1039
|
// src/BiampTable/BiampTablePagination.tsx
|
|
953
|
-
import { useRef as
|
|
1040
|
+
import { useRef as useRef2 } from "react";
|
|
954
1041
|
import { Box as Box5, TablePagination } from "@mui/material";
|
|
955
|
-
import { jsx as
|
|
1042
|
+
import { jsx as jsx13 } from "react/jsx-runtime";
|
|
956
1043
|
function BiampTablePagination({
|
|
957
1044
|
table,
|
|
958
1045
|
rowsPerPageOptions,
|
|
959
1046
|
loading,
|
|
960
1047
|
autoHide = true,
|
|
961
|
-
|
|
1048
|
+
sx,
|
|
1049
|
+
...paginationProps
|
|
962
1050
|
}) {
|
|
963
1051
|
const rowCount = table.getRowCount();
|
|
964
|
-
const lastRowCountRef =
|
|
1052
|
+
const lastRowCountRef = useRef2(rowCount);
|
|
965
1053
|
if (!loading && rowCount >= 0) {
|
|
966
1054
|
lastRowCountRef.current = rowCount;
|
|
967
1055
|
}
|
|
968
1056
|
const stableCount = loading ? lastRowCountRef.current : rowCount;
|
|
969
1057
|
const pageSize = table.getState().pagination.pageSize;
|
|
970
1058
|
if (autoHide && !loading && stableCount <= pageSize) return null;
|
|
971
|
-
return /* @__PURE__ */
|
|
1059
|
+
return /* @__PURE__ */ jsx13(
|
|
972
1060
|
TablePagination,
|
|
973
1061
|
{
|
|
974
|
-
component:
|
|
1062
|
+
component: Box5,
|
|
975
1063
|
count: stableCount,
|
|
976
1064
|
page: table.getState().pagination.pageIndex,
|
|
977
1065
|
rowsPerPage: table.getState().pagination.pageSize,
|
|
@@ -982,99 +1070,73 @@ function BiampTablePagination({
|
|
|
982
1070
|
},
|
|
983
1071
|
rowsPerPageOptions: rowsPerPageOptions ?? [],
|
|
984
1072
|
showFirstButton: true,
|
|
985
|
-
showLastButton: true
|
|
1073
|
+
showLastButton: true,
|
|
1074
|
+
sx: {
|
|
1075
|
+
height: 40,
|
|
1076
|
+
minHeight: 40,
|
|
1077
|
+
"& .MuiToolbar-root": {
|
|
1078
|
+
minHeight: 40,
|
|
1079
|
+
px: 0
|
|
1080
|
+
},
|
|
1081
|
+
...sx
|
|
1082
|
+
},
|
|
1083
|
+
...paginationProps
|
|
986
1084
|
}
|
|
987
|
-
)
|
|
1085
|
+
);
|
|
988
1086
|
}
|
|
989
1087
|
|
|
990
1088
|
// src/BiampTable/BiampTableToolbar.tsx
|
|
991
1089
|
import { Box as Box6 } from "@mui/material";
|
|
992
|
-
import { jsx as
|
|
1090
|
+
import { jsx as jsx14 } from "react/jsx-runtime";
|
|
993
1091
|
function BiampTableToolbar({
|
|
994
1092
|
children,
|
|
1093
|
+
sx,
|
|
995
1094
|
...props
|
|
996
1095
|
}) {
|
|
997
|
-
return /* @__PURE__ */
|
|
1096
|
+
return /* @__PURE__ */ jsx14(
|
|
998
1097
|
Box6,
|
|
999
1098
|
{
|
|
1000
1099
|
role: "toolbar",
|
|
1001
1100
|
display: "flex",
|
|
1002
1101
|
justifyContent: "space-between",
|
|
1003
1102
|
alignItems: "center",
|
|
1004
|
-
gap: 1,
|
|
1103
|
+
gap: { xs: 0, md: 1 },
|
|
1104
|
+
minHeight: 44,
|
|
1105
|
+
pl: { xs: 2, sm: 3, xl: 12.5 },
|
|
1106
|
+
pr: { xs: 0, md: 3, xl: 12.5 },
|
|
1107
|
+
sx: { ...sx },
|
|
1005
1108
|
...props,
|
|
1006
1109
|
children
|
|
1007
1110
|
}
|
|
1008
1111
|
);
|
|
1009
1112
|
}
|
|
1010
1113
|
|
|
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
1114
|
// src/BiampTable/BiampTableToolbarActions.tsx
|
|
1053
1115
|
import { Box as Box7 } from "@mui/material";
|
|
1054
|
-
import { jsx as
|
|
1116
|
+
import { jsx as jsx15 } from "react/jsx-runtime";
|
|
1055
1117
|
function BiampTableToolbarActions({
|
|
1056
1118
|
children,
|
|
1057
1119
|
...props
|
|
1058
1120
|
}) {
|
|
1059
|
-
return /* @__PURE__ */
|
|
1121
|
+
return /* @__PURE__ */ jsx15(Box7, { display: "flex", alignItems: "center", gap: 1, ml: "auto", ...props, children });
|
|
1060
1122
|
}
|
|
1061
1123
|
|
|
1062
1124
|
// src/BiampTable/BiampTableToolbarExport.tsx
|
|
1063
1125
|
import { CircularProgress } from "@mui/material";
|
|
1064
1126
|
import { DownloadIcon } from "@bwp-web/assets";
|
|
1065
|
-
import { jsx as
|
|
1127
|
+
import { jsx as jsx16 } from "react/jsx-runtime";
|
|
1066
1128
|
function BiampTableToolbarExport({
|
|
1067
1129
|
onExport,
|
|
1068
1130
|
loading,
|
|
1069
|
-
icon = /* @__PURE__ */
|
|
1131
|
+
icon = /* @__PURE__ */ jsx16(DownloadIcon, { variant: "xs" }),
|
|
1070
1132
|
label = "Export",
|
|
1071
1133
|
...props
|
|
1072
1134
|
}) {
|
|
1073
|
-
return /* @__PURE__ */
|
|
1135
|
+
return /* @__PURE__ */ jsx16(
|
|
1074
1136
|
BiampTableToolbarActionButton,
|
|
1075
1137
|
{
|
|
1076
1138
|
label: loading ? `${label}, loading` : label,
|
|
1077
|
-
icon: loading ? /* @__PURE__ */
|
|
1139
|
+
icon: loading ? /* @__PURE__ */ jsx16(CircularProgress, { size: 20, color: "inherit" }) : icon,
|
|
1078
1140
|
disabled: loading,
|
|
1079
1141
|
onClick: onExport,
|
|
1080
1142
|
...props
|
|
@@ -1093,14 +1155,14 @@ import {
|
|
|
1093
1155
|
Typography as Typography4
|
|
1094
1156
|
} from "@mui/material";
|
|
1095
1157
|
import { CloseIcon, FilterIcon } from "@bwp-web/assets";
|
|
1096
|
-
import { useId, useState as
|
|
1097
|
-
import { Fragment, jsx as
|
|
1158
|
+
import { useId, useState as useState3 } from "react";
|
|
1159
|
+
import { Fragment as Fragment2, jsx as jsx17, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
1098
1160
|
function BiampTableToolbarFilters({
|
|
1099
1161
|
activeFilterCount,
|
|
1100
1162
|
children,
|
|
1101
1163
|
onReset,
|
|
1102
1164
|
onApply,
|
|
1103
|
-
icon = /* @__PURE__ */
|
|
1165
|
+
icon = /* @__PURE__ */ jsx17(FilterIcon, { variant: "xs" }),
|
|
1104
1166
|
title = "Filters",
|
|
1105
1167
|
resetLabel = "Clear filters",
|
|
1106
1168
|
applyLabel = "Apply",
|
|
@@ -1108,14 +1170,14 @@ function BiampTableToolbarFilters({
|
|
|
1108
1170
|
buttonLabel = "Filters",
|
|
1109
1171
|
DrawerProps: drawerProps
|
|
1110
1172
|
}) {
|
|
1111
|
-
const [open, setOpen] =
|
|
1173
|
+
const [open, setOpen] = useState3(false);
|
|
1112
1174
|
const titleId = useId();
|
|
1113
1175
|
function handleClose() {
|
|
1114
1176
|
onApply?.();
|
|
1115
1177
|
setOpen(false);
|
|
1116
1178
|
}
|
|
1117
|
-
return /* @__PURE__ */
|
|
1118
|
-
/* @__PURE__ */
|
|
1179
|
+
return /* @__PURE__ */ jsxs8(Fragment2, { children: [
|
|
1180
|
+
/* @__PURE__ */ jsx17(
|
|
1119
1181
|
BiampTableToolbarActionButton,
|
|
1120
1182
|
{
|
|
1121
1183
|
label: buttonLabel,
|
|
@@ -1124,7 +1186,7 @@ function BiampTableToolbarFilters({
|
|
|
1124
1186
|
onClick: () => setOpen(true)
|
|
1125
1187
|
}
|
|
1126
1188
|
),
|
|
1127
|
-
/* @__PURE__ */
|
|
1189
|
+
/* @__PURE__ */ jsx17(
|
|
1128
1190
|
Drawer,
|
|
1129
1191
|
{
|
|
1130
1192
|
anchor: "right",
|
|
@@ -1136,7 +1198,7 @@ function BiampTableToolbarFilters({
|
|
|
1136
1198
|
sx: { width: { xs: "100%", sm: 480 } },
|
|
1137
1199
|
...drawerProps?.PaperProps
|
|
1138
1200
|
},
|
|
1139
|
-
children: /* @__PURE__ */
|
|
1201
|
+
children: /* @__PURE__ */ jsxs8(
|
|
1140
1202
|
Box8,
|
|
1141
1203
|
{
|
|
1142
1204
|
height: "100%",
|
|
@@ -1144,8 +1206,8 @@ function BiampTableToolbarFilters({
|
|
|
1144
1206
|
flexDirection: "column",
|
|
1145
1207
|
justifyContent: "space-between",
|
|
1146
1208
|
children: [
|
|
1147
|
-
/* @__PURE__ */
|
|
1148
|
-
/* @__PURE__ */
|
|
1209
|
+
/* @__PURE__ */ jsxs8(Box8, { children: [
|
|
1210
|
+
/* @__PURE__ */ jsxs8(
|
|
1149
1211
|
Box8,
|
|
1150
1212
|
{
|
|
1151
1213
|
display: "flex",
|
|
@@ -1154,9 +1216,9 @@ function BiampTableToolbarFilters({
|
|
|
1154
1216
|
px: 3.5,
|
|
1155
1217
|
py: 2.5,
|
|
1156
1218
|
children: [
|
|
1157
|
-
/* @__PURE__ */
|
|
1219
|
+
/* @__PURE__ */ jsxs8(Typography4, { id: titleId, variant: "h2", children: [
|
|
1158
1220
|
title,
|
|
1159
|
-
/* @__PURE__ */
|
|
1221
|
+
/* @__PURE__ */ jsx17(
|
|
1160
1222
|
Badge2,
|
|
1161
1223
|
{
|
|
1162
1224
|
badgeContent: activeFilterCount,
|
|
@@ -1165,20 +1227,20 @@ function BiampTableToolbarFilters({
|
|
|
1165
1227
|
}
|
|
1166
1228
|
)
|
|
1167
1229
|
] }),
|
|
1168
|
-
/* @__PURE__ */
|
|
1230
|
+
/* @__PURE__ */ jsx17(
|
|
1169
1231
|
IconButton3,
|
|
1170
1232
|
{
|
|
1171
1233
|
size: "medium",
|
|
1172
1234
|
onClick: handleClose,
|
|
1173
1235
|
"aria-label": closeLabel,
|
|
1174
|
-
children: /* @__PURE__ */
|
|
1236
|
+
children: /* @__PURE__ */ jsx17(CloseIcon, {})
|
|
1175
1237
|
}
|
|
1176
1238
|
)
|
|
1177
1239
|
]
|
|
1178
1240
|
}
|
|
1179
1241
|
),
|
|
1180
|
-
/* @__PURE__ */
|
|
1181
|
-
/* @__PURE__ */
|
|
1242
|
+
/* @__PURE__ */ jsx17(Divider2, {}),
|
|
1243
|
+
/* @__PURE__ */ jsx17(
|
|
1182
1244
|
Box8,
|
|
1183
1245
|
{
|
|
1184
1246
|
role: "group",
|
|
@@ -1192,8 +1254,8 @@ function BiampTableToolbarFilters({
|
|
|
1192
1254
|
}
|
|
1193
1255
|
)
|
|
1194
1256
|
] }),
|
|
1195
|
-
/* @__PURE__ */
|
|
1196
|
-
/* @__PURE__ */
|
|
1257
|
+
/* @__PURE__ */ jsxs8(Box8, { display: "flex", children: [
|
|
1258
|
+
/* @__PURE__ */ jsx17(
|
|
1197
1259
|
Button,
|
|
1198
1260
|
{
|
|
1199
1261
|
variant: "overlay",
|
|
@@ -1204,7 +1266,7 @@ function BiampTableToolbarFilters({
|
|
|
1204
1266
|
children: resetLabel
|
|
1205
1267
|
}
|
|
1206
1268
|
),
|
|
1207
|
-
/* @__PURE__ */
|
|
1269
|
+
/* @__PURE__ */ jsx17(
|
|
1208
1270
|
Button,
|
|
1209
1271
|
{
|
|
1210
1272
|
variant: "overlay",
|
|
@@ -1225,21 +1287,23 @@ function BiampTableToolbarFilters({
|
|
|
1225
1287
|
|
|
1226
1288
|
// src/BiampTable/BiampTableToolbarSearch.tsx
|
|
1227
1289
|
import {
|
|
1290
|
+
Box as Box9,
|
|
1291
|
+
Collapse,
|
|
1228
1292
|
IconButton as IconButton4,
|
|
1229
1293
|
InputAdornment as InputAdornment2,
|
|
1230
1294
|
TextField as TextField2
|
|
1231
1295
|
} from "@mui/material";
|
|
1232
1296
|
import { CloseIcon as CloseIcon2, SearchIcon as SearchIcon2 } from "@bwp-web/assets";
|
|
1233
|
-
import { useEffect as
|
|
1297
|
+
import { useEffect as useEffect3, useState as useState4 } from "react";
|
|
1234
1298
|
|
|
1235
1299
|
// src/BiampTable/useDebouncedCallback.ts
|
|
1236
|
-
import { useCallback, useEffect as
|
|
1300
|
+
import { useCallback, useEffect as useEffect2, useRef as useRef3 } from "react";
|
|
1237
1301
|
var BIAMP_TABLE_DEBOUNCE_DELAY = 300;
|
|
1238
1302
|
function useDebouncedCallback(callback, delay = BIAMP_TABLE_DEBOUNCE_DELAY) {
|
|
1239
|
-
const timeoutRef =
|
|
1240
|
-
const callbackRef =
|
|
1303
|
+
const timeoutRef = useRef3(null);
|
|
1304
|
+
const callbackRef = useRef3(callback);
|
|
1241
1305
|
callbackRef.current = callback;
|
|
1242
|
-
|
|
1306
|
+
useEffect2(() => {
|
|
1243
1307
|
return () => {
|
|
1244
1308
|
if (timeoutRef.current !== null) clearTimeout(timeoutRef.current);
|
|
1245
1309
|
};
|
|
@@ -1257,7 +1321,7 @@ function useDebouncedCallback(callback, delay = BIAMP_TABLE_DEBOUNCE_DELAY) {
|
|
|
1257
1321
|
}
|
|
1258
1322
|
|
|
1259
1323
|
// src/BiampTable/BiampTableToolbarSearch.tsx
|
|
1260
|
-
import { jsx as
|
|
1324
|
+
import { jsx as jsx18, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
1261
1325
|
var searchFieldSx = {
|
|
1262
1326
|
"& .MuiInputBase-root": {
|
|
1263
1327
|
height: 36,
|
|
@@ -1272,12 +1336,15 @@ function BiampTableToolbarSearch({
|
|
|
1272
1336
|
maxWidth = 280,
|
|
1273
1337
|
placeholder = "Search",
|
|
1274
1338
|
clearLabel = "Clear search",
|
|
1339
|
+
expandable = false,
|
|
1340
|
+
expandLabel,
|
|
1275
1341
|
sx,
|
|
1276
1342
|
...textFieldProps
|
|
1277
1343
|
}) {
|
|
1278
|
-
const [inputValue, setInputValue] =
|
|
1344
|
+
const [inputValue, setInputValue] = useState4(defaultValue);
|
|
1345
|
+
const [isExpanded, setIsExpanded] = useState4(false);
|
|
1279
1346
|
const debouncedOnChange = useDebouncedCallback(onChange, debounceDelay);
|
|
1280
|
-
|
|
1347
|
+
useEffect3(() => {
|
|
1281
1348
|
setInputValue(defaultValue);
|
|
1282
1349
|
}, [defaultValue]);
|
|
1283
1350
|
const handleChange = (e) => {
|
|
@@ -1288,7 +1355,22 @@ function BiampTableToolbarSearch({
|
|
|
1288
1355
|
setInputValue("");
|
|
1289
1356
|
debouncedOnChange("");
|
|
1290
1357
|
};
|
|
1291
|
-
|
|
1358
|
+
const handleBlur = () => {
|
|
1359
|
+
if (expandable && !inputValue) {
|
|
1360
|
+
setIsExpanded(false);
|
|
1361
|
+
}
|
|
1362
|
+
};
|
|
1363
|
+
const clearButton = inputValue ? /* @__PURE__ */ jsx18(InputAdornment2, { position: "end", children: /* @__PURE__ */ jsx18(
|
|
1364
|
+
IconButton4,
|
|
1365
|
+
{
|
|
1366
|
+
size: "small",
|
|
1367
|
+
onClick: handleClear,
|
|
1368
|
+
"aria-label": clearLabel,
|
|
1369
|
+
sx: { mr: 0.5 },
|
|
1370
|
+
children: /* @__PURE__ */ jsx18(CloseIcon2, { variant: "xs", sx: { width: 20, height: 20 } })
|
|
1371
|
+
}
|
|
1372
|
+
) }) : null;
|
|
1373
|
+
const textField = /* @__PURE__ */ jsx18(
|
|
1292
1374
|
TextField2,
|
|
1293
1375
|
{
|
|
1294
1376
|
name: "search",
|
|
@@ -1297,7 +1379,7 @@ function BiampTableToolbarSearch({
|
|
|
1297
1379
|
slotProps: {
|
|
1298
1380
|
htmlInput: { maxLength, "aria-label": placeholder },
|
|
1299
1381
|
input: {
|
|
1300
|
-
startAdornment: /* @__PURE__ */
|
|
1382
|
+
startAdornment: /* @__PURE__ */ jsx18(InputAdornment2, { position: "start", sx: { ml: 1 }, children: /* @__PURE__ */ jsx18(
|
|
1301
1383
|
SearchIcon2,
|
|
1302
1384
|
{
|
|
1303
1385
|
variant: "xs",
|
|
@@ -1305,30 +1387,89 @@ function BiampTableToolbarSearch({
|
|
|
1305
1387
|
sx: { width: 16, height: 16 }
|
|
1306
1388
|
}
|
|
1307
1389
|
) }),
|
|
1308
|
-
endAdornment:
|
|
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
|
|
1390
|
+
endAdornment: clearButton
|
|
1318
1391
|
}
|
|
1319
1392
|
},
|
|
1320
1393
|
fullWidth: true,
|
|
1321
1394
|
sx: [
|
|
1322
1395
|
searchFieldSx,
|
|
1323
|
-
{ maxWidth },
|
|
1396
|
+
expandable ? { width: 170 } : { maxWidth },
|
|
1324
1397
|
...Array.isArray(sx) ? sx : sx ? [sx] : []
|
|
1325
1398
|
],
|
|
1326
1399
|
variant: "outlined",
|
|
1327
1400
|
value: inputValue,
|
|
1328
1401
|
onChange: handleChange,
|
|
1402
|
+
onBlur: handleBlur,
|
|
1403
|
+
...expandable && isExpanded && !defaultValue && { autoFocus: true },
|
|
1329
1404
|
...textFieldProps
|
|
1330
1405
|
}
|
|
1331
1406
|
);
|
|
1407
|
+
if (expandable) {
|
|
1408
|
+
return /* @__PURE__ */ jsxs9(Box9, { display: "flex", alignItems: "center", minWidth: 28, children: [
|
|
1409
|
+
/* @__PURE__ */ jsx18(
|
|
1410
|
+
IconButton4,
|
|
1411
|
+
{
|
|
1412
|
+
"aria-label": expandLabel ?? placeholder,
|
|
1413
|
+
onClick: () => setIsExpanded(true),
|
|
1414
|
+
sx: { display: isExpanded || inputValue ? "none" : "flex" },
|
|
1415
|
+
children: /* @__PURE__ */ jsx18(
|
|
1416
|
+
SearchIcon2,
|
|
1417
|
+
{
|
|
1418
|
+
variant: "xs",
|
|
1419
|
+
color: "inherit",
|
|
1420
|
+
sx: { width: 16, height: 16 }
|
|
1421
|
+
}
|
|
1422
|
+
)
|
|
1423
|
+
}
|
|
1424
|
+
),
|
|
1425
|
+
/* @__PURE__ */ jsx18(
|
|
1426
|
+
Collapse,
|
|
1427
|
+
{
|
|
1428
|
+
in: isExpanded || !!inputValue,
|
|
1429
|
+
orientation: "horizontal",
|
|
1430
|
+
unmountOnExit: true,
|
|
1431
|
+
children: textField
|
|
1432
|
+
}
|
|
1433
|
+
)
|
|
1434
|
+
] });
|
|
1435
|
+
}
|
|
1436
|
+
return textField;
|
|
1437
|
+
}
|
|
1438
|
+
|
|
1439
|
+
// src/BiampTable/exportCsv.ts
|
|
1440
|
+
function exportToCsv(rows, columns, filename = "export") {
|
|
1441
|
+
const csvContent = buildCsvString(rows, columns);
|
|
1442
|
+
downloadCsv(csvContent, filename);
|
|
1443
|
+
}
|
|
1444
|
+
function buildCsvString(rows, columns) {
|
|
1445
|
+
const header = columns.map((col) => escapeCsvField(col.header)).join(",");
|
|
1446
|
+
const dataRows = rows.map(
|
|
1447
|
+
(row) => columns.map((col) => escapeCsvField(formatCsvValue(col.accessor(row)))).join(",")
|
|
1448
|
+
);
|
|
1449
|
+
return [header, ...dataRows].join("\n");
|
|
1450
|
+
}
|
|
1451
|
+
function escapeCsvField(value) {
|
|
1452
|
+
if (value.includes(",") || value.includes('"') || value.includes("\n")) {
|
|
1453
|
+
return `"${value.replace(/"/g, '""')}"`;
|
|
1454
|
+
}
|
|
1455
|
+
return value;
|
|
1456
|
+
}
|
|
1457
|
+
function formatCsvValue(value) {
|
|
1458
|
+
if (value == null) return "";
|
|
1459
|
+
if (value instanceof Date) return value.toISOString();
|
|
1460
|
+
return String(value);
|
|
1461
|
+
}
|
|
1462
|
+
function downloadCsv(csvContent, filename) {
|
|
1463
|
+
const blob = new Blob([csvContent], { type: "text/csv;charset=utf-8;" });
|
|
1464
|
+
const url = URL.createObjectURL(blob);
|
|
1465
|
+
const link = document.createElement("a");
|
|
1466
|
+
link.setAttribute("href", url);
|
|
1467
|
+
link.setAttribute("download", `${filename}.csv`);
|
|
1468
|
+
link.style.display = "none";
|
|
1469
|
+
document.body.appendChild(link);
|
|
1470
|
+
link.click();
|
|
1471
|
+
document.body.removeChild(link);
|
|
1472
|
+
URL.revokeObjectURL(url);
|
|
1332
1473
|
}
|
|
1333
1474
|
export {
|
|
1334
1475
|
BIAMP_TABLE_DEBOUNCE_DELAY,
|
|
@@ -1358,11 +1499,16 @@ export {
|
|
|
1358
1499
|
BiampTableToolbar,
|
|
1359
1500
|
BiampTableToolbarActionButton,
|
|
1360
1501
|
BiampTableToolbarActions,
|
|
1502
|
+
BiampTableToolbarColumnVisibility,
|
|
1361
1503
|
BiampTableToolbarExport,
|
|
1362
1504
|
BiampTableToolbarFilters,
|
|
1363
1505
|
BiampTableToolbarSearch,
|
|
1364
1506
|
BiampWrapper,
|
|
1507
|
+
buildCsvString,
|
|
1508
|
+
exportToCsv,
|
|
1365
1509
|
getColumnVisibilityDirtyCount,
|
|
1510
|
+
getDefaultColumnVisibility,
|
|
1511
|
+
toVisibilityState,
|
|
1366
1512
|
useDebouncedCallback
|
|
1367
1513
|
};
|
|
1368
1514
|
//# sourceMappingURL=index.js.map
|