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