@bwp-web/components 0.11.0 → 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/index.cjs CHANGED
@@ -47,11 +47,15 @@ __export(index_exports, {
47
47
  BiampTableToolbar: () => BiampTableToolbar,
48
48
  BiampTableToolbarActionButton: () => BiampTableToolbarActionButton,
49
49
  BiampTableToolbarActions: () => BiampTableToolbarActions,
50
+ BiampTableToolbarColumnVisibility: () => BiampTableToolbarColumnVisibility,
50
51
  BiampTableToolbarExport: () => BiampTableToolbarExport,
51
52
  BiampTableToolbarFilters: () => BiampTableToolbarFilters,
52
53
  BiampTableToolbarSearch: () => BiampTableToolbarSearch,
53
54
  BiampWrapper: () => BiampWrapper,
55
+ buildCsvString: () => buildCsvString,
56
+ exportToCsv: () => exportToCsv,
54
57
  getColumnVisibilityDirtyCount: () => getColumnVisibilityDirtyCount,
58
+ getDefaultColumnVisibility: () => getDefaultColumnVisibility,
55
59
  useDebouncedCallback: () => useDebouncedCallback
56
60
  });
57
61
  module.exports = __toCommonJS(index_exports);
@@ -719,7 +723,7 @@ function BiampTable({
719
723
  verticalAlign: "middle",
720
724
  height: "100%"
721
725
  },
722
- children: error === true ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(BiampTableErrorState, {}) : error
726
+ children: error === true ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(BiampTableErrorState, {}) : error instanceof Error ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(BiampTableErrorState, { description: error.message }) : error
723
727
  }
724
728
  ) }) : showEmpty ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_material6.TableRow, { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
725
729
  import_material6.TableCell,
@@ -823,6 +827,7 @@ function BiampTableContainer({
823
827
  withBorderTop = true,
824
828
  withBorderBottom = false,
825
829
  children,
830
+ sx,
826
831
  ...props
827
832
  }) {
828
833
  return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
@@ -831,10 +836,12 @@ function BiampTableContainer({
831
836
  direction: "column",
832
837
  height: "100%",
833
838
  overflow: "hidden",
839
+ px: { xs: 2, sm: 3, xl: 12.5 },
834
840
  py: { xs: 0, md: 1.5 },
835
841
  gap: { xs: 0, md: 1 },
836
842
  borderTop: withBorderTop ? ({ palette }) => `0.6px solid ${palette.divider}` : void 0,
837
843
  borderBottom: withBorderBottom ? ({ palette }) => `0.6px solid ${palette.divider}` : void 0,
844
+ sx: { ...sx },
838
845
  ...props,
839
846
  children
840
847
  }
@@ -862,12 +869,21 @@ function BiampTableCellActionButton({ label, icon, ...props }) {
862
869
  var import_material9 = require("@mui/material");
863
870
  var import_react3 = require("react");
864
871
  var import_jsx_runtime11 = require("react/jsx-runtime");
865
- function getColumnVisibilityDirtyCount(table, defaultVisibility = {}) {
872
+ function getDefaultColumnVisibility(table) {
873
+ const result = {};
874
+ for (const col of table.getAllLeafColumns()) {
875
+ const dv = col.columnDef.meta?.defaultVisible;
876
+ if (dv !== void 0) result[col.id] = dv;
877
+ }
878
+ return result;
879
+ }
880
+ function getColumnVisibilityDirtyCount(table, defaultVisibility) {
866
881
  const current = table.getState().columnVisibility;
882
+ const defaults = defaultVisibility ?? getDefaultColumnVisibility(table);
867
883
  let count = 0;
868
884
  for (const col of table.getAllLeafColumns()) {
869
885
  const isVisible = current[col.id] ?? true;
870
- const wasVisible = defaultVisibility[col.id] ?? true;
886
+ const wasVisible = defaults[col.id] ?? true;
871
887
  if (isVisible !== wasVisible) count++;
872
888
  }
873
889
  return count;
@@ -972,10 +988,90 @@ function BiampTableColumnVisibility({
972
988
  );
973
989
  }
974
990
 
975
- // src/BiampTable/BiampTablePagination.tsx
991
+ // src/BiampTable/BiampTableToolbarColumnVisibility.tsx
992
+ var import_assets6 = require("@bwp-web/assets");
976
993
  var import_react4 = require("react");
994
+
995
+ // src/BiampTable/BiampTableToolbarActionButton.tsx
977
996
  var import_material10 = require("@mui/material");
978
997
  var import_jsx_runtime12 = require("react/jsx-runtime");
998
+ function BiampTableToolbarActionButton({
999
+ label,
1000
+ icon,
1001
+ badgeContent,
1002
+ ...props
1003
+ }) {
1004
+ const showBadge = badgeContent != null && badgeContent !== 0;
1005
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1006
+ import_material10.IconButton,
1007
+ {
1008
+ "aria-label": showBadge ? `${label} (${badgeContent})` : label,
1009
+ ...props,
1010
+ children: showBadge ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1011
+ import_material10.Badge,
1012
+ {
1013
+ badgeContent,
1014
+ color: "info",
1015
+ variant: "dot",
1016
+ sx: {
1017
+ "& .MuiBadge-badge": {
1018
+ width: 6,
1019
+ height: 6,
1020
+ minWidth: 6,
1021
+ borderRadius: "50%",
1022
+ top: 0,
1023
+ right: -3
1024
+ }
1025
+ },
1026
+ children: icon
1027
+ }
1028
+ ) : icon
1029
+ }
1030
+ );
1031
+ }
1032
+
1033
+ // src/BiampTable/BiampTableToolbarColumnVisibility.tsx
1034
+ var import_jsx_runtime13 = require("react/jsx-runtime");
1035
+ function BiampTableToolbarColumnVisibility({
1036
+ table,
1037
+ icon = /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_assets6.ColumnsIcon, { variant: "xs" }),
1038
+ label = "Columns",
1039
+ defaultColumnVisibility,
1040
+ onChange,
1041
+ showAllLabel,
1042
+ ...actionButtonProps
1043
+ }) {
1044
+ const [anchorEl, setAnchorEl] = (0, import_react4.useState)(null);
1045
+ const defaults = defaultColumnVisibility ?? getDefaultColumnVisibility(table);
1046
+ const dirtyCount = getColumnVisibilityDirtyCount(table, defaults);
1047
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
1048
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1049
+ BiampTableToolbarActionButton,
1050
+ {
1051
+ label,
1052
+ icon,
1053
+ badgeContent: dirtyCount,
1054
+ onClick: (e) => setAnchorEl(e.currentTarget),
1055
+ ...actionButtonProps
1056
+ }
1057
+ ),
1058
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1059
+ BiampTableColumnVisibility,
1060
+ {
1061
+ table,
1062
+ anchorEl,
1063
+ onClose: () => setAnchorEl(null),
1064
+ onChange,
1065
+ showAllLabel
1066
+ }
1067
+ )
1068
+ ] });
1069
+ }
1070
+
1071
+ // src/BiampTable/BiampTablePagination.tsx
1072
+ var import_react5 = require("react");
1073
+ var import_material11 = require("@mui/material");
1074
+ var import_jsx_runtime14 = require("react/jsx-runtime");
979
1075
  function BiampTablePagination({
980
1076
  table,
981
1077
  rowsPerPageOptions,
@@ -984,15 +1080,15 @@ function BiampTablePagination({
984
1080
  ...boxProps
985
1081
  }) {
986
1082
  const rowCount = table.getRowCount();
987
- const lastRowCountRef = (0, import_react4.useRef)(rowCount);
1083
+ const lastRowCountRef = (0, import_react5.useRef)(rowCount);
988
1084
  if (!loading && rowCount >= 0) {
989
1085
  lastRowCountRef.current = rowCount;
990
1086
  }
991
1087
  const stableCount = loading ? lastRowCountRef.current : rowCount;
992
1088
  const pageSize = table.getState().pagination.pageSize;
993
1089
  if (autoHide && !loading && stableCount <= pageSize) return null;
994
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_material10.Box, { ...boxProps, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
995
- import_material10.TablePagination,
1090
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material11.Box, { ...boxProps, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1091
+ import_material11.TablePagination,
996
1092
  {
997
1093
  component: "div",
998
1094
  count: stableCount,
@@ -1011,90 +1107,57 @@ function BiampTablePagination({
1011
1107
  }
1012
1108
 
1013
1109
  // src/BiampTable/BiampTableToolbar.tsx
1014
- var import_material11 = require("@mui/material");
1015
- var import_jsx_runtime13 = require("react/jsx-runtime");
1110
+ var import_material12 = require("@mui/material");
1111
+ var import_jsx_runtime15 = require("react/jsx-runtime");
1016
1112
  function BiampTableToolbar({
1017
1113
  children,
1114
+ sx,
1018
1115
  ...props
1019
1116
  }) {
1020
- return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1021
- import_material11.Box,
1117
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
1118
+ import_material12.Box,
1022
1119
  {
1023
1120
  role: "toolbar",
1024
1121
  display: "flex",
1025
1122
  justifyContent: "space-between",
1026
1123
  alignItems: "center",
1027
- gap: 1,
1124
+ gap: { xs: 0, md: 1 },
1125
+ minHeight: 44,
1126
+ pl: { xs: 2, sm: 3, xl: 12.5 },
1127
+ pr: { xs: 0, md: 3, xl: 12.5 },
1128
+ sx: { ...sx },
1028
1129
  ...props,
1029
1130
  children
1030
1131
  }
1031
1132
  );
1032
1133
  }
1033
1134
 
1034
- // src/BiampTable/BiampTableToolbarActionButton.tsx
1035
- var import_material12 = require("@mui/material");
1036
- var import_jsx_runtime14 = require("react/jsx-runtime");
1037
- function BiampTableToolbarActionButton({
1038
- label,
1039
- icon,
1040
- badgeContent,
1041
- ...props
1042
- }) {
1043
- const showBadge = badgeContent != null && badgeContent !== 0;
1044
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1045
- import_material12.IconButton,
1046
- {
1047
- "aria-label": showBadge ? `${label} (${badgeContent})` : label,
1048
- ...props,
1049
- children: showBadge ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1050
- import_material12.Badge,
1051
- {
1052
- badgeContent,
1053
- color: "info",
1054
- variant: "dot",
1055
- sx: {
1056
- "& .MuiBadge-badge": {
1057
- width: 6,
1058
- height: 6,
1059
- minWidth: 6,
1060
- borderRadius: "50%",
1061
- top: 0,
1062
- right: -3
1063
- }
1064
- },
1065
- children: icon
1066
- }
1067
- ) : icon
1068
- }
1069
- );
1070
- }
1071
-
1072
1135
  // src/BiampTable/BiampTableToolbarActions.tsx
1073
1136
  var import_material13 = require("@mui/material");
1074
- var import_jsx_runtime15 = require("react/jsx-runtime");
1137
+ var import_jsx_runtime16 = require("react/jsx-runtime");
1075
1138
  function BiampTableToolbarActions({
1076
1139
  children,
1077
1140
  ...props
1078
1141
  }) {
1079
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_material13.Box, { display: "flex", alignItems: "center", gap: 1, ml: "auto", ...props, children });
1142
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_material13.Box, { display: "flex", alignItems: "center", gap: 1, ml: "auto", ...props, children });
1080
1143
  }
1081
1144
 
1082
1145
  // src/BiampTable/BiampTableToolbarExport.tsx
1083
1146
  var import_material14 = require("@mui/material");
1084
- var import_assets6 = require("@bwp-web/assets");
1085
- var import_jsx_runtime16 = require("react/jsx-runtime");
1147
+ var import_assets7 = require("@bwp-web/assets");
1148
+ var import_jsx_runtime17 = require("react/jsx-runtime");
1086
1149
  function BiampTableToolbarExport({
1087
1150
  onExport,
1088
1151
  loading,
1089
- icon = /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_assets6.DownloadIcon, { variant: "xs" }),
1152
+ icon = /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_assets7.DownloadIcon, { variant: "xs" }),
1090
1153
  label = "Export",
1091
1154
  ...props
1092
1155
  }) {
1093
- return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1156
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
1094
1157
  BiampTableToolbarActionButton,
1095
1158
  {
1096
1159
  label: loading ? `${label}, loading` : label,
1097
- icon: loading ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_material14.CircularProgress, { size: 20, color: "inherit" }) : icon,
1160
+ icon: loading ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_material14.CircularProgress, { size: 20, color: "inherit" }) : icon,
1098
1161
  disabled: loading,
1099
1162
  onClick: onExport,
1100
1163
  ...props
@@ -1104,15 +1167,15 @@ function BiampTableToolbarExport({
1104
1167
 
1105
1168
  // src/BiampTable/BiampTableToolbarFilters.tsx
1106
1169
  var import_material15 = require("@mui/material");
1107
- var import_assets7 = require("@bwp-web/assets");
1108
- var import_react5 = require("react");
1109
- var import_jsx_runtime17 = require("react/jsx-runtime");
1170
+ var import_assets8 = require("@bwp-web/assets");
1171
+ var import_react6 = require("react");
1172
+ var import_jsx_runtime18 = require("react/jsx-runtime");
1110
1173
  function BiampTableToolbarFilters({
1111
1174
  activeFilterCount,
1112
1175
  children,
1113
1176
  onReset,
1114
1177
  onApply,
1115
- icon = /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_assets7.FilterIcon, { variant: "xs" }),
1178
+ icon = /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_assets8.FilterIcon, { variant: "xs" }),
1116
1179
  title = "Filters",
1117
1180
  resetLabel = "Clear filters",
1118
1181
  applyLabel = "Apply",
@@ -1120,14 +1183,14 @@ function BiampTableToolbarFilters({
1120
1183
  buttonLabel = "Filters",
1121
1184
  DrawerProps: drawerProps
1122
1185
  }) {
1123
- const [open, setOpen] = (0, import_react5.useState)(false);
1124
- const titleId = (0, import_react5.useId)();
1186
+ const [open, setOpen] = (0, import_react6.useState)(false);
1187
+ const titleId = (0, import_react6.useId)();
1125
1188
  function handleClose() {
1126
1189
  onApply?.();
1127
1190
  setOpen(false);
1128
1191
  }
1129
- return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_jsx_runtime17.Fragment, { children: [
1130
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
1192
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_jsx_runtime18.Fragment, { children: [
1193
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1131
1194
  BiampTableToolbarActionButton,
1132
1195
  {
1133
1196
  label: buttonLabel,
@@ -1136,7 +1199,7 @@ function BiampTableToolbarFilters({
1136
1199
  onClick: () => setOpen(true)
1137
1200
  }
1138
1201
  ),
1139
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
1202
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1140
1203
  import_material15.Drawer,
1141
1204
  {
1142
1205
  anchor: "right",
@@ -1148,7 +1211,7 @@ function BiampTableToolbarFilters({
1148
1211
  sx: { width: { xs: "100%", sm: 480 } },
1149
1212
  ...drawerProps?.PaperProps
1150
1213
  },
1151
- children: /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
1214
+ children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
1152
1215
  import_material15.Box,
1153
1216
  {
1154
1217
  height: "100%",
@@ -1156,8 +1219,8 @@ function BiampTableToolbarFilters({
1156
1219
  flexDirection: "column",
1157
1220
  justifyContent: "space-between",
1158
1221
  children: [
1159
- /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_material15.Box, { children: [
1160
- /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
1222
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_material15.Box, { children: [
1223
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
1161
1224
  import_material15.Box,
1162
1225
  {
1163
1226
  display: "flex",
@@ -1166,9 +1229,9 @@ function BiampTableToolbarFilters({
1166
1229
  px: 3.5,
1167
1230
  py: 2.5,
1168
1231
  children: [
1169
- /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_material15.Typography, { id: titleId, variant: "h2", children: [
1232
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_material15.Typography, { id: titleId, variant: "h2", children: [
1170
1233
  title,
1171
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
1234
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1172
1235
  import_material15.Badge,
1173
1236
  {
1174
1237
  badgeContent: activeFilterCount,
@@ -1177,20 +1240,20 @@ function BiampTableToolbarFilters({
1177
1240
  }
1178
1241
  )
1179
1242
  ] }),
1180
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
1243
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1181
1244
  import_material15.IconButton,
1182
1245
  {
1183
1246
  size: "medium",
1184
1247
  onClick: handleClose,
1185
1248
  "aria-label": closeLabel,
1186
- children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_assets7.CloseIcon, {})
1249
+ children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_assets8.CloseIcon, {})
1187
1250
  }
1188
1251
  )
1189
1252
  ]
1190
1253
  }
1191
1254
  ),
1192
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_material15.Divider, {}),
1193
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
1255
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_material15.Divider, {}),
1256
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1194
1257
  import_material15.Box,
1195
1258
  {
1196
1259
  role: "group",
@@ -1204,8 +1267,8 @@ function BiampTableToolbarFilters({
1204
1267
  }
1205
1268
  )
1206
1269
  ] }),
1207
- /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_material15.Box, { display: "flex", children: [
1208
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
1270
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_material15.Box, { display: "flex", children: [
1271
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1209
1272
  import_material15.Button,
1210
1273
  {
1211
1274
  variant: "overlay",
@@ -1216,7 +1279,7 @@ function BiampTableToolbarFilters({
1216
1279
  children: resetLabel
1217
1280
  }
1218
1281
  ),
1219
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
1282
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1220
1283
  import_material15.Button,
1221
1284
  {
1222
1285
  variant: "overlay",
@@ -1237,22 +1300,22 @@ function BiampTableToolbarFilters({
1237
1300
 
1238
1301
  // src/BiampTable/BiampTableToolbarSearch.tsx
1239
1302
  var import_material16 = require("@mui/material");
1240
- var import_assets8 = require("@bwp-web/assets");
1241
- var import_react7 = require("react");
1303
+ var import_assets9 = require("@bwp-web/assets");
1304
+ var import_react8 = require("react");
1242
1305
 
1243
1306
  // src/BiampTable/useDebouncedCallback.ts
1244
- var import_react6 = require("react");
1307
+ var import_react7 = require("react");
1245
1308
  var BIAMP_TABLE_DEBOUNCE_DELAY = 300;
1246
1309
  function useDebouncedCallback(callback, delay = BIAMP_TABLE_DEBOUNCE_DELAY) {
1247
- const timeoutRef = (0, import_react6.useRef)(null);
1248
- const callbackRef = (0, import_react6.useRef)(callback);
1310
+ const timeoutRef = (0, import_react7.useRef)(null);
1311
+ const callbackRef = (0, import_react7.useRef)(callback);
1249
1312
  callbackRef.current = callback;
1250
- (0, import_react6.useEffect)(() => {
1313
+ (0, import_react7.useEffect)(() => {
1251
1314
  return () => {
1252
1315
  if (timeoutRef.current !== null) clearTimeout(timeoutRef.current);
1253
1316
  };
1254
1317
  }, []);
1255
- return (0, import_react6.useCallback)(
1318
+ return (0, import_react7.useCallback)(
1256
1319
  (...args) => {
1257
1320
  if (timeoutRef.current !== null) clearTimeout(timeoutRef.current);
1258
1321
  timeoutRef.current = setTimeout(
@@ -1265,7 +1328,7 @@ function useDebouncedCallback(callback, delay = BIAMP_TABLE_DEBOUNCE_DELAY) {
1265
1328
  }
1266
1329
 
1267
1330
  // src/BiampTable/BiampTableToolbarSearch.tsx
1268
- var import_jsx_runtime18 = require("react/jsx-runtime");
1331
+ var import_jsx_runtime19 = require("react/jsx-runtime");
1269
1332
  var searchFieldSx = {
1270
1333
  "& .MuiInputBase-root": {
1271
1334
  height: 36,
@@ -1280,12 +1343,15 @@ function BiampTableToolbarSearch({
1280
1343
  maxWidth = 280,
1281
1344
  placeholder = "Search",
1282
1345
  clearLabel = "Clear search",
1346
+ expandable = false,
1347
+ expandLabel,
1283
1348
  sx,
1284
1349
  ...textFieldProps
1285
1350
  }) {
1286
- const [inputValue, setInputValue] = (0, import_react7.useState)(defaultValue);
1351
+ const [inputValue, setInputValue] = (0, import_react8.useState)(defaultValue);
1352
+ const [isExpanded, setIsExpanded] = (0, import_react8.useState)(false);
1287
1353
  const debouncedOnChange = useDebouncedCallback(onChange, debounceDelay);
1288
- (0, import_react7.useEffect)(() => {
1354
+ (0, import_react8.useEffect)(() => {
1289
1355
  setInputValue(defaultValue);
1290
1356
  }, [defaultValue]);
1291
1357
  const handleChange = (e) => {
@@ -1296,7 +1362,22 @@ function BiampTableToolbarSearch({
1296
1362
  setInputValue("");
1297
1363
  debouncedOnChange("");
1298
1364
  };
1299
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1365
+ const handleBlur = () => {
1366
+ if (expandable && !inputValue) {
1367
+ setIsExpanded(false);
1368
+ }
1369
+ };
1370
+ const clearButton = inputValue ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_material16.InputAdornment, { position: "end", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
1371
+ import_material16.IconButton,
1372
+ {
1373
+ size: "small",
1374
+ onClick: handleClear,
1375
+ "aria-label": clearLabel,
1376
+ sx: { mr: 0.5 },
1377
+ children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_assets9.CloseIcon, { variant: "xs", sx: { width: 20, height: 20 } })
1378
+ }
1379
+ ) }) : null;
1380
+ const textField = /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
1300
1381
  import_material16.TextField,
1301
1382
  {
1302
1383
  name: "search",
@@ -1305,38 +1386,97 @@ function BiampTableToolbarSearch({
1305
1386
  slotProps: {
1306
1387
  htmlInput: { maxLength, "aria-label": placeholder },
1307
1388
  input: {
1308
- startAdornment: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_material16.InputAdornment, { position: "start", sx: { ml: 1 }, children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1309
- import_assets8.SearchIcon,
1389
+ startAdornment: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_material16.InputAdornment, { position: "start", sx: { ml: 1 }, children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
1390
+ import_assets9.SearchIcon,
1310
1391
  {
1311
1392
  variant: "xs",
1312
1393
  color: "inherit",
1313
1394
  sx: { width: 16, height: 16 }
1314
1395
  }
1315
1396
  ) }),
1316
- endAdornment: inputValue ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_material16.InputAdornment, { position: "end", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1317
- import_material16.IconButton,
1318
- {
1319
- size: "small",
1320
- onClick: handleClear,
1321
- "aria-label": clearLabel,
1322
- sx: { mr: 0.5 },
1323
- children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_assets8.CloseIcon, { variant: "xs", sx: { width: 20, height: 20 } })
1324
- }
1325
- ) }) : null
1397
+ endAdornment: clearButton
1326
1398
  }
1327
1399
  },
1328
1400
  fullWidth: true,
1329
1401
  sx: [
1330
1402
  searchFieldSx,
1331
- { maxWidth },
1403
+ expandable ? { width: 170 } : { maxWidth },
1332
1404
  ...Array.isArray(sx) ? sx : sx ? [sx] : []
1333
1405
  ],
1334
1406
  variant: "outlined",
1335
1407
  value: inputValue,
1336
1408
  onChange: handleChange,
1409
+ onBlur: handleBlur,
1410
+ ...expandable && isExpanded && !defaultValue && { autoFocus: true },
1337
1411
  ...textFieldProps
1338
1412
  }
1339
1413
  );
1414
+ if (expandable) {
1415
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_material16.Box, { display: "flex", alignItems: "center", minWidth: 28, children: [
1416
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
1417
+ import_material16.IconButton,
1418
+ {
1419
+ "aria-label": expandLabel ?? placeholder,
1420
+ onClick: () => setIsExpanded(true),
1421
+ sx: { display: isExpanded || inputValue ? "none" : "flex" },
1422
+ children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
1423
+ import_assets9.SearchIcon,
1424
+ {
1425
+ variant: "xs",
1426
+ color: "inherit",
1427
+ sx: { width: 16, height: 16 }
1428
+ }
1429
+ )
1430
+ }
1431
+ ),
1432
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
1433
+ import_material16.Collapse,
1434
+ {
1435
+ in: isExpanded || !!inputValue,
1436
+ orientation: "horizontal",
1437
+ unmountOnExit: true,
1438
+ children: textField
1439
+ }
1440
+ )
1441
+ ] });
1442
+ }
1443
+ return textField;
1444
+ }
1445
+
1446
+ // src/BiampTable/exportCsv.ts
1447
+ function exportToCsv(rows, columns, filename = "export") {
1448
+ const csvContent = buildCsvString(rows, columns);
1449
+ downloadCsv(csvContent, filename);
1450
+ }
1451
+ function buildCsvString(rows, columns) {
1452
+ const header = columns.map((col) => escapeCsvField(col.header)).join(",");
1453
+ const dataRows = rows.map(
1454
+ (row) => columns.map((col) => escapeCsvField(formatCsvValue(col.accessor(row)))).join(",")
1455
+ );
1456
+ return [header, ...dataRows].join("\n");
1457
+ }
1458
+ function escapeCsvField(value) {
1459
+ if (value.includes(",") || value.includes('"') || value.includes("\n")) {
1460
+ return `"${value.replace(/"/g, '""')}"`;
1461
+ }
1462
+ return value;
1463
+ }
1464
+ function formatCsvValue(value) {
1465
+ if (value == null) return "";
1466
+ if (value instanceof Date) return value.toISOString();
1467
+ return String(value);
1468
+ }
1469
+ function downloadCsv(csvContent, filename) {
1470
+ const blob = new Blob([csvContent], { type: "text/csv;charset=utf-8;" });
1471
+ const url = URL.createObjectURL(blob);
1472
+ const link = document.createElement("a");
1473
+ link.setAttribute("href", url);
1474
+ link.setAttribute("download", `${filename}.csv`);
1475
+ link.style.display = "none";
1476
+ document.body.appendChild(link);
1477
+ link.click();
1478
+ document.body.removeChild(link);
1479
+ URL.revokeObjectURL(url);
1340
1480
  }
1341
1481
  // Annotate the CommonJS export names for ESM import in node:
1342
1482
  0 && (module.exports = {
@@ -1367,11 +1507,15 @@ function BiampTableToolbarSearch({
1367
1507
  BiampTableToolbar,
1368
1508
  BiampTableToolbarActionButton,
1369
1509
  BiampTableToolbarActions,
1510
+ BiampTableToolbarColumnVisibility,
1370
1511
  BiampTableToolbarExport,
1371
1512
  BiampTableToolbarFilters,
1372
1513
  BiampTableToolbarSearch,
1373
1514
  BiampWrapper,
1515
+ buildCsvString,
1516
+ exportToCsv,
1374
1517
  getColumnVisibilityDirtyCount,
1518
+ getDefaultColumnVisibility,
1375
1519
  useDebouncedCallback
1376
1520
  });
1377
1521
  //# sourceMappingURL=index.cjs.map