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