@worknice/whiteboard 0.37.0 → 0.38.0

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.
Files changed (47) hide show
  1. package/dist/controls/Action.stories.d.ts +2 -2
  2. package/dist/controls/Button.d.ts +1 -1
  3. package/dist/controls/Button.js +1 -0
  4. package/dist/controls/Button.module.js +1 -0
  5. package/dist/controls/Button.stories.d.ts +2 -2
  6. package/dist/controls/ButtonCard.stories.d.ts +1 -1
  7. package/dist/controls/Button_module.css +5 -0
  8. package/dist/controls/Disclosure.stories.d.ts +1 -1
  9. package/dist/controls/MenuButton.d.ts +8 -2
  10. package/dist/controls/MenuButton.js +50 -11
  11. package/dist/controls/MenuButton.module.js +8 -0
  12. package/dist/controls/MenuButton.stories.d.ts +8 -5
  13. package/dist/controls/MenuButton_module.css +47 -1
  14. package/dist/controls/Sortable.stories.d.ts +1 -1
  15. package/dist/controls/TabSet.stories.d.ts +1 -1
  16. package/dist/fields/CheckboxSetField.stories.d.ts +1 -1
  17. package/dist/fields/ColorPickerField.stories.d.ts +1 -1
  18. package/dist/fields/OrgLogoField.stories.d.ts +1 -1
  19. package/dist/fields/PaletteColorPickerField.stories.d.ts +1 -1
  20. package/dist/fields/TimezoneField.stories.d.ts +1 -1
  21. package/dist/icons/BookOpenLinesIcon.d.ts +3 -0
  22. package/dist/icons/BookOpenLinesIcon.js +11 -0
  23. package/dist/icons/BugIcon.d.ts +3 -0
  24. package/dist/icons/BugIcon.js +11 -0
  25. package/dist/icons/CommentIcon.d.ts +3 -0
  26. package/dist/icons/CommentIcon.js +11 -0
  27. package/dist/icons/LightbulbIcon.d.ts +3 -0
  28. package/dist/icons/LightbulbIcon.js +11 -0
  29. package/dist/icons/NewspaperIcon.d.ts +3 -0
  30. package/dist/icons/NewspaperIcon.js +11 -0
  31. package/dist/icons/index.d.ts +5 -0
  32. package/dist/icons/index.js +6 -1
  33. package/dist/inputs/ColorInput.stories.d.ts +1 -1
  34. package/dist/inputs/PaletteColorInput.stories.d.ts +1 -1
  35. package/dist/layouts/FullLayout.js +5 -1
  36. package/dist/presentation/HeadlineStatisticCard.d.ts +2 -1
  37. package/dist/presentation/HeadlineStatisticCard.js +6 -1
  38. package/dist/presentation/Table.d.ts +23 -8
  39. package/dist/presentation/Table.js +569 -260
  40. package/dist/presentation/Table.module.js +14 -0
  41. package/dist/presentation/Table_module.css +91 -21
  42. package/dist/utils/useNextContext.d.ts +1 -1
  43. package/package.json +4 -4
  44. package/dist/presentation/Table_v2.d.ts +0 -87
  45. package/dist/presentation/Table_v2.js +0 -831
  46. package/dist/presentation/Table_v2.module.js +0 -33
  47. package/dist/presentation/Table_v2_module.css +0 -196
@@ -9,21 +9,30 @@ import * as __WEBPACK_EXTERNAL_MODULE_utf8__ from "utf8";
9
9
  import * as __WEBPACK_EXTERNAL_MODULE__controls_Button_js_f591ba2e__ from "../controls/Button.js";
10
10
  import * as __WEBPACK_EXTERNAL_MODULE__controls_Disclosure_js_6e4cc59c__ from "../controls/Disclosure.js";
11
11
  import * as __WEBPACK_EXTERNAL_MODULE__controls_MenuButton_js_b23cdd05__ from "../controls/MenuButton.js";
12
- import * as __WEBPACK_EXTERNAL_MODULE__fields_SelectField_js_8b78efe2__ from "../fields/SelectField.js";
13
- import * as __WEBPACK_EXTERNAL_MODULE__fields_StringField_js_cab546d4__ from "../fields/StringField.js";
12
+ import * as __WEBPACK_EXTERNAL_MODULE__fields_BooleanField_js_dc79ee46__ from "../fields/BooleanField.js";
13
+ import * as __WEBPACK_EXTERNAL_MODULE__fields_CheckboxSetField_js_bce910a4__ from "../fields/CheckboxSetField.js";
14
+ import * as __WEBPACK_EXTERNAL_MODULE__fields_ListBoxField_js_b7d4cb12__ from "../fields/ListBoxField.js";
15
+ import * as __WEBPACK_EXTERNAL_MODULE__fields_SimpleRadioSetField_js_118e9421__ from "../fields/SimpleRadioSetField.js";
16
+ import * as __WEBPACK_EXTERNAL_MODULE__forms_FormButtonSet_js_c160eb1a__ from "../forms/FormButtonSet.js";
17
+ import * as __WEBPACK_EXTERNAL_MODULE__forms_useForm_js_e756b4e7__ from "../forms/useForm.js";
14
18
  import * as __WEBPACK_EXTERNAL_MODULE__inputs_CheckboxInput_js_3a83f64b__ from "../inputs/CheckboxInput.js";
19
+ import * as __WEBPACK_EXTERNAL_MODULE__inputs_SelectInput_js_d1a6f32e__ from "../inputs/SelectInput.js";
20
+ import * as __WEBPACK_EXTERNAL_MODULE__inputs_StringInput_js_091f1e06__ from "../inputs/StringInput.js";
15
21
  import * as __WEBPACK_EXTERNAL_MODULE__utils_encodeCsv_js_1d824629__ from "../utils/encodeCsv.js";
16
22
  import * as __WEBPACK_EXTERNAL_MODULE__Card_js_d67c086a__ from "./Card.js";
17
23
  import * as __WEBPACK_EXTERNAL_MODULE__CardContent_js_20e3f6de__ from "./CardContent.js";
18
24
  import * as __WEBPACK_EXTERNAL_MODULE__HStack_js_cc26058d__ from "./HStack.js";
19
25
  import * as __WEBPACK_EXTERNAL_MODULE__Icon_js_0d271bb6__ from "./Icon.js";
26
+ import * as __WEBPACK_EXTERNAL_MODULE__Modal_js_50f53bdf__ from "./Modal.js";
20
27
  import * as __WEBPACK_EXTERNAL_MODULE__PlainText_js_cd0b6798__ from "./PlainText.js";
21
28
  import * as __WEBPACK_EXTERNAL_MODULE__Table_module_js_1c0e33be__ from "./Table.module.js";
22
29
  import * as __WEBPACK_EXTERNAL_MODULE__VStack_js_02eb6792__ from "./VStack.js";
23
30
  const selectColumnId = "_selectColumn";
24
31
  const actionsColumnId = "_actionsColumn";
32
+ const MIN_LIST_BOX_FILTER_OPTIONS = 10;
25
33
  const Table = ({ data, columns, bulkActions = [], secondaryBulkActions = [], csvFilename, estimatedRowSize = 100, emptyState = "No results", pathName, id, localStorageSchema, getRowId, rowActions })=>{
26
34
  const [searchTerm, setSearchTerm] = (0, __WEBPACK_EXTERNAL_MODULE_react__.useState)("");
35
+ const [isFilterModalOpen, setIsFilterModalOpen] = (0, __WEBPACK_EXTERNAL_MODULE_react__.useState)(false);
27
36
  const lastSelectedRow = (0, __WEBPACK_EXTERNAL_MODULE_react__.useRef)(void 0);
28
37
  const { refs, x: bulkSelectionModalXCoordinate } = (0, __WEBPACK_EXTERNAL_MODULE__floating_ui_react_dom_d5bb3c23__.useFloating)({
29
38
  placement: "bottom",
@@ -49,8 +58,18 @@ const Table = ({ data, columns, bulkActions = [], secondaryBulkActions = [], csv
49
58
  enableGlobalFilter: false !== globalFiltering,
50
59
  enableSorting,
51
60
  filterFn: filter ? (row, _, filterValue)=>{
52
- const option = filter.options.find((option)=>option.id === filterValue);
53
- return option?.predicate?.(row.original) ?? true;
61
+ if (filter.isMulti && Array.isArray(filterValue)) {
62
+ if (0 === filterValue.length) return true;
63
+ return filterValue.some((optionId)=>{
64
+ const option = filter.options.find((opt)=>opt.id === optionId);
65
+ return option ? option.predicate(row.original) : false;
66
+ });
67
+ }
68
+ if (!filter.isMulti && "string" == typeof filterValue) {
69
+ const option = filter.options.find((opt)=>opt.id === filterValue);
70
+ return option?.predicate?.(row.original) ?? true;
71
+ }
72
+ return true;
54
73
  } : void 0,
55
74
  getGroupingValue: grouping ? (row)=>grouping.fn(row) : void 0,
56
75
  header,
@@ -108,6 +127,8 @@ const Table = ({ data, columns, bulkActions = [], secondaryBulkActions = [], csv
108
127
  header: "",
109
128
  size: 38,
110
129
  cell: ({ row })=>/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__controls_MenuButton_js_b23cdd05__["default"], {
130
+ type: "ghost",
131
+ size: "small",
111
132
  options: rowActions(row.original).filter((action)=>null !== action),
112
133
  icon: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__Icon_js_0d271bb6__["default"], {
113
134
  symbol: "Overflow"
@@ -129,14 +150,27 @@ const Table = ({ data, columns, bulkActions = [], secondaryBulkActions = [], csv
129
150
  rowActions
130
151
  ]);
131
152
  const globalFilterableColumns = columns.filter((column)=>false !== column.globalFiltering && "display" !== column.type);
132
- const filterableColumns = columns.filter((column)=>void 0 !== column.filter);
153
+ const filterableColumns = columns.filter((column)=>void 0 !== column.filter && column.filter.options.length > 0);
133
154
  const groupableColumns = columns.filter((column)=>void 0 !== column.grouping);
134
155
  const csvExportableColumns = columns.filter((column)=>true === column.csvExport);
135
- const columnFiltersInitialState = filterableColumns.map((col)=>({
136
- id: col.id,
137
- value: col.filter.options[0].id
138
- }));
139
- const localStorageData = "undefined" != typeof window && pathName && id ? window.localStorage.getItem(`${pathName}#${id}`) : null;
156
+ const columnFiltersInitialState = (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>filterableColumns.map((col)=>{
157
+ const filter = col.filter;
158
+ if (filter.isMulti) return {
159
+ id: col.id,
160
+ value: []
161
+ };
162
+ return {
163
+ id: col.id,
164
+ value: filter.options[0].id
165
+ };
166
+ }), [
167
+ filterableColumns
168
+ ]);
169
+ const storageKey = (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>pathName && id ? `${pathName}#${id}_table` : null, [
170
+ pathName,
171
+ id
172
+ ]);
173
+ const localStorageData = "undefined" != typeof window && storageKey ? window.localStorage.getItem(storageKey) : null;
140
174
  let parsedLocalStorage = {};
141
175
  if (localStorageData && localStorageSchema) try {
142
176
  parsedLocalStorage = JSON.parse(localStorageData);
@@ -225,12 +259,25 @@ const Table = ({ data, columns, bulkActions = [], secondaryBulkActions = [], csv
225
259
  a.click();
226
260
  };
227
261
  const throttledSetGlobalFilter = (0, __WEBPACK_EXTERNAL_MODULE__react_hook_throttle_d66151d4__.useThrottleCallback)((value)=>table.setGlobalFilter(value), 4);
228
- const showSearchReset = columnFiltersInitialState.some((filter, index)=>filter.value !== table.getState().columnFilters[index].value) || table.initialState.globalFilter !== table.getState().globalFilter;
262
+ const activeFilterCount = (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>{
263
+ const currentFilters = tableState.columnFilters;
264
+ return columnFiltersInitialState.filter((initialFilter)=>{
265
+ const currentFilter = currentFilters.find((f)=>f.id === initialFilter.id);
266
+ const currentValue = currentFilter?.value;
267
+ const initialValue = initialFilter.value;
268
+ if (Array.isArray(initialValue) && Array.isArray(currentValue)) return currentValue.length !== initialValue.length || initialValue.some((v, i)=>v !== currentValue[i]);
269
+ return currentValue !== initialValue;
270
+ }).length;
271
+ }, [
272
+ tableState.columnFilters,
273
+ columnFiltersInitialState
274
+ ]);
275
+ const showSearchReset = activeFilterCount > 0 || "" !== tableState.globalFilter;
229
276
  const filteredSelectedRows = table.getFilteredSelectedRowModel();
230
277
  const validPrimaryBulkActions = bulkActions.filter((bulkAction)=>filteredSelectedRows.rows.some((row)=>bulkAction.predicate ? bulkAction.predicate(row.original) : true));
231
278
  const validSecondaryBulkActions = secondaryBulkActions.filter((bulkAction)=>filteredSelectedRows.rows.some((row)=>bulkAction.predicate ? bulkAction.predicate(row.original) : true));
232
279
  (0, __WEBPACK_EXTERNAL_MODULE_react__.useEffect)(()=>{
233
- if (pathName && id) window.localStorage.setItem(`${pathName}#${id}`, JSON.stringify({
280
+ if (storageKey) window.localStorage.setItem(storageKey, JSON.stringify({
234
281
  columnFilters: tableState.columnFilters,
235
282
  sorting: tableState.sorting,
236
283
  grouping: tableState.grouping
@@ -239,8 +286,7 @@ const Table = ({ data, columns, bulkActions = [], secondaryBulkActions = [], csv
239
286
  tableState.columnFilters,
240
287
  tableState.sorting,
241
288
  tableState.grouping,
242
- pathName,
243
- id
289
+ storageKey
244
290
  ]);
245
291
  const shouldShowCsvExport = csvExportableColumns.length > 0 && csvFilename;
246
292
  const shouldShowMoreActions = validSecondaryBulkActions.length > 0 || shouldShowCsvExport;
@@ -261,283 +307,546 @@ const Table = ({ data, columns, bulkActions = [], secondaryBulkActions = [], csv
261
307
  const hasMultipleActions = allBulkActionRowCounts.length > 1;
262
308
  const allRowsCanDoAllActions = hasMultipleActions && allBulkActionRowCounts.every((count)=>count === filteredSelectedRows.rows.length);
263
309
  const showBulkActionCounts = bulkActionRowCountsDiffer || hasMultipleActions && !allRowsCanDoAllActions;
264
- return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)("div", {
265
- ref: refs.setReference,
310
+ return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)(__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.Fragment, {
266
311
  children: [
267
- validPrimaryBulkActions.length > 0 || validSecondaryBulkActions.length > 0 ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("div", {
268
- ref: refs.setFloating,
269
- className: __WEBPACK_EXTERNAL_MODULE__Table_module_js_1c0e33be__["default"].bulkSelectionModal,
270
- style: {
271
- left: bulkSelectionModalXCoordinate
272
- },
273
- children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__Card_js_d67c086a__["default"], {
274
- hasShadow: true,
275
- children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__CardContent_js_20e3f6de__["default"], {
276
- spacing: "00",
277
- children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)("div", {
278
- className: __WEBPACK_EXTERNAL_MODULE__Table_module_js_1c0e33be__["default"].bulkSelectionModalContent,
279
- children: [
280
- /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)(__WEBPACK_EXTERNAL_MODULE__PlainText_js_cd0b6798__["default"], {
281
- font: "regular-bold",
282
- children: [
283
- filteredSelectedRows.rows.length,
284
- " ",
285
- 1 === filteredSelectedRows.rows.length ? "selection" : "selections"
286
- ]
287
- }),
288
- /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)("div", {
289
- className: __WEBPACK_EXTERNAL_MODULE__Table_module_js_1c0e33be__["default"].bulkSelectionActions,
312
+ /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)("div", {
313
+ ref: refs.setReference,
314
+ children: [
315
+ validPrimaryBulkActions.length > 0 || validSecondaryBulkActions.length > 0 ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("div", {
316
+ ref: refs.setFloating,
317
+ className: __WEBPACK_EXTERNAL_MODULE__Table_module_js_1c0e33be__["default"].bulkSelectionModal,
318
+ style: {
319
+ left: bulkSelectionModalXCoordinate
320
+ },
321
+ children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__Card_js_d67c086a__["default"], {
322
+ hasShadow: true,
323
+ children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__CardContent_js_20e3f6de__["default"], {
324
+ spacing: "00",
325
+ children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)("div", {
326
+ className: __WEBPACK_EXTERNAL_MODULE__Table_module_js_1c0e33be__["default"].bulkSelectionModalContent,
290
327
  children: [
291
- validPrimaryBulkActions.map((bulkAction)=>{
292
- const rows = primaryBulkActionRowsMap.get(bulkAction.key) ?? [];
293
- return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__controls_Disclosure_js_6e4cc59c__["default"], {
294
- render: (onClose)=>bulkAction.render({
295
- rows: primaryBulkActionRowsMap.get(bulkAction.key) ?? [],
296
- resetRowSelection: ()=>table.resetRowSelection(),
297
- onClose: onClose
298
- }),
299
- children: showBulkActionCounts ? `${bulkAction.label} (${rows.length})` : bulkAction.label
300
- }, bulkAction.key);
328
+ /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)(__WEBPACK_EXTERNAL_MODULE__PlainText_js_cd0b6798__["default"], {
329
+ font: "regular-bold",
330
+ children: [
331
+ filteredSelectedRows.rows.length,
332
+ " ",
333
+ 1 === filteredSelectedRows.rows.length ? "selection" : "selections"
334
+ ]
301
335
  }),
302
- shouldShowMoreActions ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__controls_MenuButton_js_b23cdd05__["default"], {
303
- id: "bulkActionOverflow",
304
- options: [
305
- ...validSecondaryBulkActions.map((bulkAction)=>{
306
- const rows = secondaryBulkActionRowsMap.get(bulkAction.key) ?? [];
307
- return {
308
- id: bulkAction.key,
309
- label: showBulkActionCounts ? `${bulkAction.label} (${rows.length})` : bulkAction.label,
310
- type: "render",
336
+ /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)("div", {
337
+ className: __WEBPACK_EXTERNAL_MODULE__Table_module_js_1c0e33be__["default"].bulkSelectionActions,
338
+ children: [
339
+ validPrimaryBulkActions.map((bulkAction)=>{
340
+ const rows = primaryBulkActionRowsMap.get(bulkAction.key) ?? [];
341
+ return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__controls_Disclosure_js_6e4cc59c__["default"], {
311
342
  render: (onClose)=>bulkAction.render({
312
- rows: rows,
343
+ rows: primaryBulkActionRowsMap.get(bulkAction.key) ?? [],
313
344
  resetRowSelection: ()=>table.resetRowSelection(),
314
345
  onClose: onClose
315
- })
316
- };
346
+ }),
347
+ children: showBulkActionCounts ? `${bulkAction.label} (${rows.length})` : bulkAction.label
348
+ }, bulkAction.key);
317
349
  }),
318
- ...shouldShowCsvExport ? [
319
- {
320
- id: "download-selected-rows",
321
- label: "Download selected rows as CSV",
322
- type: "onClick",
323
- onClick: ()=>handleDownloadCsv(csvExportableColumns, table.getSelectedRowModel().rows)
324
- }
325
- ] : []
326
- ],
327
- icon: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__Icon_js_0d271bb6__["default"], {
328
- symbol: "Plus"
329
- }),
330
- children: "More actions"
331
- }) : null,
332
- /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__controls_Button_js_f591ba2e__["default"], {
333
- icon: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__Icon_js_0d271bb6__["default"], {
334
- symbol: "Close"
335
- }),
336
- onClick: ()=>{
337
- table.resetRowSelection(true);
338
- },
339
- title: `Deselect ${table.getFilteredSelectedRowModel().rows.length} ${1 === table.getFilteredSelectedRowModel().rows.length ? "selection" : "selections"}`,
340
- type: "secondary"
350
+ shouldShowMoreActions ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__controls_MenuButton_js_b23cdd05__["default"], {
351
+ id: "bulkActionOverflow",
352
+ options: [
353
+ ...validSecondaryBulkActions.map((bulkAction)=>{
354
+ const rows = secondaryBulkActionRowsMap.get(bulkAction.key) ?? [];
355
+ return {
356
+ id: bulkAction.key,
357
+ label: showBulkActionCounts ? `${bulkAction.label} (${rows.length})` : bulkAction.label,
358
+ type: "render",
359
+ render: (onClose)=>bulkAction.render({
360
+ rows: rows,
361
+ resetRowSelection: ()=>table.resetRowSelection(),
362
+ onClose: onClose
363
+ })
364
+ };
365
+ }),
366
+ ...shouldShowCsvExport ? [
367
+ {
368
+ id: "download-selected-rows",
369
+ label: "Download selected rows as CSV",
370
+ type: "onClick",
371
+ onClick: ()=>handleDownloadCsv(csvExportableColumns, table.getSelectedRowModel().rows)
372
+ }
373
+ ] : []
374
+ ],
375
+ icon: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__Icon_js_0d271bb6__["default"], {
376
+ symbol: "Plus"
377
+ }),
378
+ children: "More actions"
379
+ }) : null,
380
+ /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__controls_Button_js_f591ba2e__["default"], {
381
+ icon: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__Icon_js_0d271bb6__["default"], {
382
+ symbol: "Close"
383
+ }),
384
+ onClick: ()=>{
385
+ table.resetRowSelection(true);
386
+ },
387
+ title: `Deselect ${table.getFilteredSelectedRowModel().rows.length} ${1 === table.getFilteredSelectedRowModel().rows.length ? "selection" : "selections"}`,
388
+ type: "secondary"
389
+ })
390
+ ]
341
391
  })
342
392
  ]
343
393
  })
344
- ]
394
+ })
345
395
  })
346
- })
347
- })
348
- }) : null,
349
- /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)(__WEBPACK_EXTERNAL_MODULE__VStack_js_02eb6792__["default"], {
350
- spacing: "p1",
351
- children: [
352
- 0 !== globalFilterableColumns.length || 0 !== filterableColumns.length || 0 !== groupableColumns.length ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)("div", {
353
- className: __WEBPACK_EXTERNAL_MODULE__Table_module_js_1c0e33be__["default"].filterBar,
396
+ }) : null,
397
+ /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)(__WEBPACK_EXTERNAL_MODULE__VStack_js_02eb6792__["default"], {
398
+ spacing: "p1",
354
399
  children: [
355
- 0 !== globalFilterableColumns.length ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__fields_StringField_js_cab546d4__["default"], {
356
- label: "Search",
357
- id: "globalSearch",
358
- value: searchTerm,
359
- onChange: (value)=>{
360
- setSearchTerm(value ?? "");
361
- throttledSetGlobalFilter(value ?? "");
362
- }
363
- }) : null,
364
- 0 !== filterableColumns.length || 0 !== groupableColumns.length ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)("div", {
365
- className: __WEBPACK_EXTERNAL_MODULE__Table_module_js_1c0e33be__["default"].filterSelectMenus,
400
+ 0 !== globalFilterableColumns.length || 0 !== filterableColumns.length || 0 !== groupableColumns.length ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)("div", {
401
+ className: __WEBPACK_EXTERNAL_MODULE__Table_module_js_1c0e33be__["default"].filterBar,
366
402
  children: [
367
- filterableColumns.map((column)=>/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__fields_SelectField_js_8b78efe2__["default"], {
368
- label: column.filter.label,
369
- id: `${column.id}Filter`,
403
+ 0 !== globalFilterableColumns.length ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("div", {
404
+ className: __WEBPACK_EXTERNAL_MODULE__Table_module_js_1c0e33be__["default"].filterBarSearch,
405
+ children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__inputs_StringInput_js_091f1e06__["default"], {
406
+ prefix: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__Icon_js_0d271bb6__["default"], {
407
+ symbol: "Search"
408
+ }),
409
+ placeholder: "Search",
410
+ id: "globalSearch",
411
+ value: searchTerm,
370
412
  onChange: (value)=>{
371
- table.getColumn(column.id)?.setFilterValue(value.id);
372
- },
373
- options: column.filter.options,
374
- optionToId: (option)=>option.id,
375
- optionToLabel: (option)=>option.label,
376
- value: column.filter.options.find((option)=>option.id === table.getColumn(column.id)?.getFilterValue()) ?? column.filter.options[0]
377
- }, column.id)),
378
- 0 !== groupableColumns.length ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__fields_SelectField_js_8b78efe2__["default"], {
379
- label: "Group by",
380
- id: "columnGroupings",
381
- onChange: (value)=>table.setGrouping(value ? [
382
- value.id
383
- ] : []),
384
- options: [
385
- void 0,
386
- ...groupableColumns
387
- ],
388
- optionToId: (option)=>void 0 === option ? "noGrouping" : option.id,
389
- optionToLabel: (option)=>void 0 === option ? "No grouping" : option.grouping.label,
390
- value: groupableColumns.find((column)=>table.getState().grouping.some((id)=>id === column.id))
413
+ setSearchTerm(value ?? "");
414
+ throttledSetGlobalFilter(value ?? "");
415
+ }
416
+ })
417
+ }) : null,
418
+ 0 !== filterableColumns.length || 0 !== groupableColumns.length ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)("div", {
419
+ className: __WEBPACK_EXTERNAL_MODULE__Table_module_js_1c0e33be__["default"].filterSelectMenus,
420
+ children: [
421
+ /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)(__WEBPACK_EXTERNAL_MODULE__controls_Button_js_f591ba2e__["default"], {
422
+ type: "secondary",
423
+ onClick: ()=>setIsFilterModalOpen(true),
424
+ icon: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__Icon_js_0d271bb6__["default"], {
425
+ symbol: "Filter"
426
+ }),
427
+ children: [
428
+ "Filters",
429
+ activeFilterCount > 0 ? ` (${activeFilterCount})` : ""
430
+ ]
431
+ }),
432
+ 0 !== groupableColumns.length ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("div", {
433
+ children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__inputs_SelectInput_js_d1a6f32e__["default"], {
434
+ id: "columnGroupings",
435
+ onChange: (value)=>table.setGrouping(value ? [
436
+ value.id
437
+ ] : []),
438
+ options: [
439
+ void 0,
440
+ ...groupableColumns
441
+ ],
442
+ optionToId: (option)=>void 0 === option ? "noGrouping" : option.id,
443
+ optionToLabel: (option)=>void 0 === option ? "No grouping" : option.grouping.label,
444
+ value: groupableColumns.find((column)=>table.getState().grouping.some((id)=>id === column.id))
445
+ })
446
+ }) : null
447
+ ]
448
+ }) : null,
449
+ showSearchReset ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("div", {
450
+ className: __WEBPACK_EXTERNAL_MODULE__Table_module_js_1c0e33be__["default"].filterBarSearchReset,
451
+ children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)("div", {
452
+ className: __WEBPACK_EXTERNAL_MODULE__Table_module_js_1c0e33be__["default"].filterBarSearchResetContent,
453
+ children: [
454
+ /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)("p", {
455
+ children: [
456
+ "Showing ",
457
+ table.getPreGroupedRowModel().flatRows.length,
458
+ " of",
459
+ " ",
460
+ table.getPreFilteredRowModel().flatRows.length
461
+ ]
462
+ }),
463
+ /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__controls_Button_js_f591ba2e__["default"], {
464
+ onClick: ()=>{
465
+ table.setColumnFilters(columnFiltersInitialState);
466
+ table.resetGlobalFilter();
467
+ setSearchTerm("");
468
+ },
469
+ type: "secondary",
470
+ size: "small",
471
+ children: "Reset filters and search"
472
+ })
473
+ ]
474
+ })
391
475
  }) : null
392
476
  ]
393
- }) : null
394
- ]
395
- }) : null,
396
- showSearchReset ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)(__WEBPACK_EXTERNAL_MODULE__HStack_js_cc26058d__["default"], {
397
- children: [
398
- /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)("p", {
399
- children: [
400
- "Showing ",
401
- table.getPreGroupedRowModel().flatRows.length,
402
- " of",
403
- " ",
404
- table.getPreFilteredRowModel().flatRows.length
405
- ]
406
- }),
407
- /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__controls_Button_js_f591ba2e__["default"], {
408
- onClick: ()=>{
409
- table.setColumnFilters(columnFiltersInitialState);
410
- table.resetGlobalFilter();
411
- setSearchTerm("");
412
- },
413
- type: "secondary",
414
- size: "small",
415
- children: "Reset filters and search"
416
- })
417
- ]
418
- }) : null,
419
- /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("div", {
420
- className: __WEBPACK_EXTERNAL_MODULE__Table_module_js_1c0e33be__["default"].tableContainer,
421
- children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)("table", {
422
- className: __WEBPACK_EXTERNAL_MODULE__Table_module_js_1c0e33be__["default"].table,
423
- children: [
424
- /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("thead", {
425
- className: __WEBPACK_EXTERNAL_MODULE__Table_module_js_1c0e33be__["default"].tableHead,
426
- children: table.getHeaderGroups().map((headerGroup)=>/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("tr", {
427
- className: (0, __WEBPACK_EXTERNAL_MODULE_clsx__["default"])([
428
- __WEBPACK_EXTERNAL_MODULE__Table_module_js_1c0e33be__["default"].tableRow,
429
- enableRowSelection ? __WEBPACK_EXTERNAL_MODULE__Table_module_js_1c0e33be__["default"].selectableRows : ""
430
- ]),
431
- children: headerGroup.headers.map((header)=>/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("th", {
477
+ }) : null,
478
+ /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("div", {
479
+ className: __WEBPACK_EXTERNAL_MODULE__Table_module_js_1c0e33be__["default"].tableContainer,
480
+ children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)("table", {
481
+ className: __WEBPACK_EXTERNAL_MODULE__Table_module_js_1c0e33be__["default"].table,
482
+ children: [
483
+ /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("thead", {
484
+ className: __WEBPACK_EXTERNAL_MODULE__Table_module_js_1c0e33be__["default"].tableHead,
485
+ children: table.getHeaderGroups().map((headerGroup)=>/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("tr", {
432
486
  className: (0, __WEBPACK_EXTERNAL_MODULE_clsx__["default"])([
433
- __WEBPACK_EXTERNAL_MODULE__Table_module_js_1c0e33be__["default"].tableCell,
434
- __WEBPACK_EXTERNAL_MODULE__Table_module_js_1c0e33be__["default"].tableHeader,
435
- header.column.id === selectColumnId ? __WEBPACK_EXTERNAL_MODULE__Table_module_js_1c0e33be__["default"].selectionCell : void 0,
436
- header.column.id === actionsColumnId ? __WEBPACK_EXTERNAL_MODULE__Table_module_js_1c0e33be__["default"].actionsCell : void 0
487
+ __WEBPACK_EXTERNAL_MODULE__Table_module_js_1c0e33be__["default"].tableRow,
488
+ enableRowSelection ? __WEBPACK_EXTERNAL_MODULE__Table_module_js_1c0e33be__["default"].selectableRows : ""
437
489
  ]),
490
+ children: headerGroup.headers.map((header)=>/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("th", {
491
+ className: (0, __WEBPACK_EXTERNAL_MODULE_clsx__["default"])([
492
+ __WEBPACK_EXTERNAL_MODULE__Table_module_js_1c0e33be__["default"].tableCell,
493
+ __WEBPACK_EXTERNAL_MODULE__Table_module_js_1c0e33be__["default"].tableHeader,
494
+ header.column.id === selectColumnId ? __WEBPACK_EXTERNAL_MODULE__Table_module_js_1c0e33be__["default"].selectionCell : void 0,
495
+ header.column.id === actionsColumnId ? __WEBPACK_EXTERNAL_MODULE__Table_module_js_1c0e33be__["default"].actionsCell : void 0
496
+ ]),
497
+ style: {
498
+ width: header.column.getSize(),
499
+ flexGrow: header.column.id === selectColumnId || header.column.id === actionsColumnId ? 0 : header.column.getSize()
500
+ },
501
+ children: header.isPlaceholder ? null : header.column.getCanSort() ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)("button", {
502
+ onClick: header.column.getToggleSortingHandler(),
503
+ className: __WEBPACK_EXTERNAL_MODULE__Table_module_js_1c0e33be__["default"].sortableTableHeader,
504
+ title: "asc" === header.column.getIsSorted() ? "Sorted by ascending order" : "desc" === header.column.getIsSorted() ? "Sorted by descending order" : "Default sorting order",
505
+ children: [
506
+ (0, __WEBPACK_EXTERNAL_MODULE__tanstack_react_table_777e1b4b__.flexRender)(header.column.columnDef.header, header.getContext()),
507
+ "asc" === header.column.getIsSorted() ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__Icon_js_0d271bb6__["default"], {
508
+ size: "small",
509
+ symbol: "SortAsc",
510
+ className: __WEBPACK_EXTERNAL_MODULE__Table_module_js_1c0e33be__["default"].sortIcon
511
+ }) : "desc" === header.column.getIsSorted() ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__Icon_js_0d271bb6__["default"], {
512
+ size: "small",
513
+ symbol: "SortDes",
514
+ className: __WEBPACK_EXTERNAL_MODULE__Table_module_js_1c0e33be__["default"].sortIcon
515
+ }) : /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__Icon_js_0d271bb6__["default"], {
516
+ size: "small",
517
+ symbol: "SortDefault",
518
+ className: __WEBPACK_EXTERNAL_MODULE__Table_module_js_1c0e33be__["default"].sortIcon
519
+ })
520
+ ]
521
+ }) : /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("div", {
522
+ children: (0, __WEBPACK_EXTERNAL_MODULE__tanstack_react_table_777e1b4b__.flexRender)(header.column.columnDef.header, header.getContext())
523
+ })
524
+ }, header.id))
525
+ }, headerGroup.id))
526
+ }),
527
+ /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("tbody", {
528
+ ref: tBodyRef,
529
+ className: __WEBPACK_EXTERNAL_MODULE__Table_module_js_1c0e33be__["default"].tableBody,
530
+ style: {
531
+ height: rows.length > 0 ? `${rowVirtualizer.getTotalSize()}px` : "auto"
532
+ },
533
+ children: table.getRowModel().rows.length ? rowVirtualizer.getVirtualItems().map((virtualRow)=>{
534
+ const row = rows[virtualRow.index];
535
+ const groupColumn = groupableColumns.find((column)=>column.id === row.groupingColumnId);
536
+ return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("tr", {
537
+ "data-state": row.getIsSelected() ? "selected" : "",
538
+ className: (0, __WEBPACK_EXTERNAL_MODULE_clsx__["default"])([
539
+ __WEBPACK_EXTERNAL_MODULE__Table_module_js_1c0e33be__["default"].tableRow,
540
+ enableRowSelection ? __WEBPACK_EXTERNAL_MODULE__Table_module_js_1c0e33be__["default"].selectableRows : "",
541
+ row.getIsGrouped() && groupColumn ? __WEBPACK_EXTERNAL_MODULE__Table_module_js_1c0e33be__["default"].tableRowGrouped : ""
542
+ ]),
543
+ "data-index": virtualRow.index,
544
+ ref: rowVirtualizer.measureElement,
438
545
  style: {
439
- width: header.column.getSize(),
440
- flexGrow: header.column.id === selectColumnId || header.column.id === actionsColumnId ? 0 : header.column.getSize()
546
+ position: "absolute",
547
+ transform: `translateY(${virtualRow.start - rowVirtualizer.options.scrollMargin}px)`
441
548
  },
442
- children: header.isPlaceholder ? null : header.column.getCanSort() ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)("button", {
443
- onClick: header.column.getToggleSortingHandler(),
444
- className: __WEBPACK_EXTERNAL_MODULE__Table_module_js_1c0e33be__["default"].sortableTableHeader,
445
- title: "asc" === header.column.getIsSorted() ? "Sorted by ascending order" : "desc" === header.column.getIsSorted() ? "Sorted by descending order" : "Default sorting order",
446
- children: [
447
- (0, __WEBPACK_EXTERNAL_MODULE__tanstack_react_table_777e1b4b__.flexRender)(header.column.columnDef.header, header.getContext()),
448
- "asc" === header.column.getIsSorted() ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__Icon_js_0d271bb6__["default"], {
449
- size: "small",
450
- symbol: "SortAsc",
451
- className: __WEBPACK_EXTERNAL_MODULE__Table_module_js_1c0e33be__["default"].sortIcon
452
- }) : "desc" === header.column.getIsSorted() ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__Icon_js_0d271bb6__["default"], {
453
- size: "small",
454
- symbol: "SortDes",
455
- className: __WEBPACK_EXTERNAL_MODULE__Table_module_js_1c0e33be__["default"].sortIcon
456
- }) : /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__Icon_js_0d271bb6__["default"], {
457
- size: "small",
458
- symbol: "SortDefault",
459
- className: __WEBPACK_EXTERNAL_MODULE__Table_module_js_1c0e33be__["default"].sortIcon
460
- })
461
- ]
462
- }) : /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("div", {
463
- children: (0, __WEBPACK_EXTERNAL_MODULE__tanstack_react_table_777e1b4b__.flexRender)(header.column.columnDef.header, header.getContext())
549
+ children: row.getIsGrouped() && groupColumn ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("td", {
550
+ className: __WEBPACK_EXTERNAL_MODULE__Table_module_js_1c0e33be__["default"].tableCell,
551
+ children: groupColumn.grouping.header(row.original)
552
+ }) : /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.Fragment, {
553
+ children: row.getVisibleCells().map((cell)=>/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("td", {
554
+ className: (0, __WEBPACK_EXTERNAL_MODULE_clsx__["default"])([
555
+ __WEBPACK_EXTERNAL_MODULE__Table_module_js_1c0e33be__["default"].tableCell,
556
+ cell.column.id === selectColumnId ? __WEBPACK_EXTERNAL_MODULE__Table_module_js_1c0e33be__["default"].selectionCell : void 0,
557
+ cell.column.id === actionsColumnId ? __WEBPACK_EXTERNAL_MODULE__Table_module_js_1c0e33be__["default"].actionsCell : void 0
558
+ ]),
559
+ style: {
560
+ width: cell.column.getSize(),
561
+ flexGrow: cell.column.id === selectColumnId || cell.column.id === actionsColumnId ? 0 : cell.column.getSize()
562
+ },
563
+ children: (0, __WEBPACK_EXTERNAL_MODULE__tanstack_react_table_777e1b4b__.flexRender)(cell.column.columnDef.cell, cell.getContext())
564
+ }, cell.id))
464
565
  })
465
- }, header.id))
466
- }, headerGroup.id))
566
+ }, row.id);
567
+ }) : /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("tr", {
568
+ className: __WEBPACK_EXTERNAL_MODULE__Table_module_js_1c0e33be__["default"].tableRow,
569
+ children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("td", {
570
+ className: __WEBPACK_EXTERNAL_MODULE__Table_module_js_1c0e33be__["default"].noRows,
571
+ children: emptyState
572
+ })
573
+ })
574
+ })
575
+ ]
576
+ })
577
+ }),
578
+ /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("div", {
579
+ className: __WEBPACK_EXTERNAL_MODULE__Table_module_js_1c0e33be__["default"].downloadLink,
580
+ children: shouldShowCsvExport ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__controls_Button_js_f591ba2e__["default"], {
581
+ type: "secondary",
582
+ onClick: ()=>handleDownloadCsv(csvExportableColumns, table.getRowModel().rows),
583
+ children: "Download all rows as CSV"
584
+ }) : null
585
+ })
586
+ ]
587
+ })
588
+ ]
589
+ }),
590
+ isFilterModalOpen && /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(FilterModal, {
591
+ onClose: ()=>setIsFilterModalOpen(false),
592
+ filterableColumns: filterableColumns,
593
+ currentFilters: tableState.columnFilters,
594
+ onFiltersChange: (filters)=>table.setColumnFilters(filters)
595
+ })
596
+ ]
597
+ });
598
+ };
599
+ const FilterExpander = ({ label, children, highlight = false, defaultOpen = false })=>/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)("details", {
600
+ open: defaultOpen,
601
+ className: (0, __WEBPACK_EXTERNAL_MODULE_clsx__["default"])(__WEBPACK_EXTERNAL_MODULE__Table_module_js_1c0e33be__["default"].filterExpander, {
602
+ [__WEBPACK_EXTERNAL_MODULE__Table_module_js_1c0e33be__["default"].filterExpanderHighlight]: highlight
603
+ }),
604
+ children: [
605
+ /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)("summary", {
606
+ className: __WEBPACK_EXTERNAL_MODULE__Table_module_js_1c0e33be__["default"].filterExpanderRow,
607
+ children: [
608
+ /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("span", {
609
+ className: __WEBPACK_EXTERNAL_MODULE__Table_module_js_1c0e33be__["default"].filterExpanderIcon,
610
+ children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__Icon_js_0d271bb6__["default"], {
611
+ symbol: "ChevronRight"
612
+ })
613
+ }),
614
+ /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("span", {
615
+ className: __WEBPACK_EXTERNAL_MODULE__Table_module_js_1c0e33be__["default"].filterExpanderLabel,
616
+ children: label
617
+ })
618
+ ]
619
+ }),
620
+ /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("div", {
621
+ className: __WEBPACK_EXTERNAL_MODULE__Table_module_js_1c0e33be__["default"].filterExpanderWrapper,
622
+ children: children
623
+ })
624
+ ]
625
+ });
626
+ const FilterModal = ({ onClose, filterableColumns, currentFilters, onFiltersChange })=>{
627
+ const initialFilterValues = (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>{
628
+ const result = {};
629
+ for (const column of filterableColumns){
630
+ const current = currentFilters.find((f)=>f.id === column.id);
631
+ const filter = column.filter;
632
+ if (filter.isMulti) result[column.id] = Array.isArray(current?.value) ? current.value : [];
633
+ else result[column.id] = ("string" == typeof current?.value ? current.value : null) ?? filter.options[0].id;
634
+ }
635
+ return result;
636
+ }, [
637
+ filterableColumns,
638
+ currentFilters
639
+ ]);
640
+ const resetFilterValues = (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>{
641
+ const result = {};
642
+ for (const col of filterableColumns){
643
+ const filter = col.filter;
644
+ result[col.id] = filter.isMulti ? [] : filter.options[0].id;
645
+ }
646
+ return result;
647
+ }, [
648
+ filterableColumns
649
+ ]);
650
+ const { data, setData, status, submit } = (0, __WEBPACK_EXTERNAL_MODULE__forms_useForm_js_e756b4e7__["default"])({
651
+ initialValues: {
652
+ filters: initialFilterValues
653
+ },
654
+ onSubmit: async (values)=>{
655
+ const filters = Object.entries(values.filters).map(([columnId, value])=>({
656
+ id: columnId,
657
+ value
658
+ }));
659
+ onFiltersChange(filters);
660
+ }
661
+ });
662
+ const handleMultiFilterChange = (0, __WEBPACK_EXTERNAL_MODULE_react__.useCallback)((columnId, option)=>{
663
+ setData((prev)=>{
664
+ const prevValue = prev.filters[columnId];
665
+ const current = Array.isArray(prevValue) ? prevValue : [];
666
+ const next = current.includes(option.id) ? current.filter((id)=>id !== option.id) : [
667
+ ...current,
668
+ option.id
669
+ ];
670
+ return {
671
+ filters: {
672
+ ...prev.filters,
673
+ [columnId]: next
674
+ }
675
+ };
676
+ });
677
+ }, [
678
+ setData
679
+ ]);
680
+ return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__Modal_js_50f53bdf__["default"], {
681
+ onClose: onClose,
682
+ children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__Card_js_d67c086a__["default"], {
683
+ header: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__PlainText_js_cd0b6798__["default"], {
684
+ font: "h6",
685
+ tagName: "h6",
686
+ children: "Filters"
687
+ }),
688
+ footer: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)(__WEBPACK_EXTERNAL_MODULE__HStack_js_cc26058d__["default"], {
689
+ justify: "space-between",
690
+ children: [
691
+ /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__controls_Button_js_f591ba2e__["default"], {
692
+ type: "secondary",
693
+ onClick: ()=>{
694
+ setData(()=>({
695
+ filters: resetFilterValues
696
+ }));
697
+ },
698
+ icon: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__Icon_js_0d271bb6__["default"], {
699
+ symbol: "Restore"
700
+ }),
701
+ children: "Reset all filters"
702
+ }),
703
+ /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__forms_FormButtonSet_js_c160eb1a__["default"], {
704
+ formStatus: status,
705
+ primary: {
706
+ action: async ()=>{
707
+ submit();
708
+ onClose();
709
+ },
710
+ label: "Apply filters"
711
+ },
712
+ secondary: {
713
+ action: onClose,
714
+ label: "Cancel"
715
+ }
716
+ })
717
+ ]
718
+ }),
719
+ children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("div", {
720
+ className: __WEBPACK_EXTERNAL_MODULE__Table_module_js_1c0e33be__["default"].filterExpandersContainer,
721
+ children: filterableColumns.map((column)=>{
722
+ const filter = column.filter;
723
+ if (filter.isMulti) {
724
+ const filterValue = data.filters[column.id];
725
+ const selectedIds = Array.isArray(filterValue) ? filterValue : [];
726
+ const selectedOptions = filter.options.filter((opt)=>selectedIds.includes(opt.id));
727
+ const multiFilterLabel = /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)(__WEBPACK_EXTERNAL_MODULE__HStack_js_cc26058d__["default"], {
728
+ justify: "space-between",
729
+ children: [
730
+ /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("span", {
731
+ children: selectedIds.length > 0 ? `${filter.label} (${selectedIds.length} selected)` : filter.label
467
732
  }),
468
- /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("tbody", {
469
- ref: tBodyRef,
470
- className: __WEBPACK_EXTERNAL_MODULE__Table_module_js_1c0e33be__["default"].tableBody,
733
+ /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("span", {
471
734
  style: {
472
- height: rows.length > 0 ? `${rowVirtualizer.getTotalSize()}px` : "auto"
735
+ visibility: selectedIds.length > 0 ? "visible" : "hidden"
473
736
  },
474
- children: table.getRowModel().rows.length ? rowVirtualizer.getVirtualItems().map((virtualRow)=>{
475
- const row = rows[virtualRow.index];
476
- const groupColumn = groupableColumns.find((column)=>column.id === row.groupingColumnId);
477
- return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("tr", {
478
- "data-state": row.getIsSelected() ? "selected" : "",
479
- className: (0, __WEBPACK_EXTERNAL_MODULE_clsx__["default"])([
480
- __WEBPACK_EXTERNAL_MODULE__Table_module_js_1c0e33be__["default"].tableRow,
481
- enableRowSelection ? __WEBPACK_EXTERNAL_MODULE__Table_module_js_1c0e33be__["default"].selectableRows : "",
482
- row.getIsGrouped() && groupColumn ? __WEBPACK_EXTERNAL_MODULE__Table_module_js_1c0e33be__["default"].tableRowGrouped : ""
483
- ]),
484
- "data-index": virtualRow.index,
485
- ref: rowVirtualizer.measureElement,
486
- style: {
487
- position: "absolute",
488
- transform: `translateY(${virtualRow.start - rowVirtualizer.options.scrollMargin}px)`
489
- },
490
- children: row.getIsGrouped() && groupColumn ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("td", {
491
- className: __WEBPACK_EXTERNAL_MODULE__Table_module_js_1c0e33be__["default"].tableCell,
492
- children: groupColumn.grouping.header(row.original)
493
- }) : /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.Fragment, {
494
- children: row.getVisibleCells().map((cell)=>/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("td", {
495
- className: (0, __WEBPACK_EXTERNAL_MODULE_clsx__["default"])([
496
- __WEBPACK_EXTERNAL_MODULE__Table_module_js_1c0e33be__["default"].tableCell,
497
- cell.column.id === selectColumnId ? __WEBPACK_EXTERNAL_MODULE__Table_module_js_1c0e33be__["default"].selectionCell : void 0,
498
- cell.column.id === actionsColumnId ? __WEBPACK_EXTERNAL_MODULE__Table_module_js_1c0e33be__["default"].actionsCell : void 0
499
- ]),
500
- style: {
501
- width: cell.column.getSize(),
502
- flexGrow: cell.column.id === selectColumnId || cell.column.id === actionsColumnId ? 0 : cell.column.getSize()
503
- },
504
- children: (0, __WEBPACK_EXTERNAL_MODULE__tanstack_react_table_777e1b4b__.flexRender)(cell.column.columnDef.cell, cell.getContext())
505
- }, cell.id))
506
- })
507
- }, row.id);
508
- }) : /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("tr", {
509
- className: __WEBPACK_EXTERNAL_MODULE__Table_module_js_1c0e33be__["default"].tableRow,
510
- children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("td", {
511
- className: __WEBPACK_EXTERNAL_MODULE__Table_module_js_1c0e33be__["default"].noRows,
512
- children: emptyState
513
- })
737
+ children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__controls_Button_js_f591ba2e__["default"], {
738
+ type: "secondary",
739
+ size: "small",
740
+ onClick: (e)=>{
741
+ e.stopPropagation();
742
+ setData((prev)=>({
743
+ filters: {
744
+ ...prev.filters,
745
+ [column.id]: []
746
+ }
747
+ }));
748
+ },
749
+ children: "Reset"
514
750
  })
515
751
  })
516
752
  ]
517
- })
518
- }),
519
- /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)("div", {
520
- className: __WEBPACK_EXTERNAL_MODULE__Table_module_js_1c0e33be__["default"].downloadLink,
753
+ });
754
+ return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(FilterExpander, {
755
+ label: multiFilterLabel,
756
+ highlight: selectedIds.length > 0,
757
+ defaultOpen: 1 === filterableColumns.length,
758
+ children: filter.options.length > MIN_LIST_BOX_FILTER_OPTIONS ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("div", {
759
+ className: __WEBPACK_EXTERNAL_MODULE__Table_module_js_1c0e33be__["default"].listBoxFilterContainer,
760
+ children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__fields_ListBoxField_js_b7d4cb12__["default"], {
761
+ id: `${column.id}-filter`,
762
+ label: "",
763
+ options: filter.options,
764
+ optionToId: (opt)=>opt.id,
765
+ optionToLabel: (opt)=>opt.label,
766
+ searchField: "label",
767
+ value: selectedOptions,
768
+ onChange: (option)=>handleMultiFilterChange(column.id, option)
769
+ })
770
+ }) : /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__fields_CheckboxSetField_js_bce910a4__["default"], {
771
+ id: `${column.id}-filter`,
772
+ label: "",
773
+ options: filter.options,
774
+ optionToId: (opt)=>opt.id,
775
+ optionToLabel: (opt)=>opt.label,
776
+ values: selectedOptions,
777
+ onChange: (option)=>handleMultiFilterChange(column.id, option)
778
+ })
779
+ }, column.id);
780
+ }
781
+ const rawValue = data.filters[column.id];
782
+ const value = "string" == typeof rawValue ? rawValue : filter.options[0].id;
783
+ const hasNonDefaultValue = "string" == typeof rawValue && rawValue !== filter.options[0].id;
784
+ const isBooleanFilter = 2 === filter.options.length;
785
+ const booleanValue = isBooleanFilter && value === filter.options[1].id;
786
+ const singleFilterLabel = /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)(__WEBPACK_EXTERNAL_MODULE__HStack_js_cc26058d__["default"], {
787
+ justify: "space-between",
521
788
  children: [
522
- /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)("p", {
523
- children: [
524
- "Showing ",
525
- table.getPreGroupedRowModel().flatRows.length,
526
- " of",
527
- " ",
528
- table.getPreFilteredRowModel().flatRows.length
529
- ]
789
+ /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("span", {
790
+ children: hasNonDefaultValue ? `${filter.label} (Selected)` : filter.label
530
791
  }),
531
- shouldShowCsvExport ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__controls_Button_js_f591ba2e__["default"], {
532
- type: "secondary",
533
- onClick: ()=>handleDownloadCsv(csvExportableColumns, table.getRowModel().rows),
534
- children: "Download all rows as CSV"
535
- }) : null
792
+ /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("span", {
793
+ style: {
794
+ visibility: hasNonDefaultValue ? "visible" : "hidden"
795
+ },
796
+ children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__controls_Button_js_f591ba2e__["default"], {
797
+ type: "secondary",
798
+ size: "small",
799
+ onClick: (e)=>{
800
+ e.stopPropagation();
801
+ setData((prev)=>({
802
+ filters: {
803
+ ...prev.filters,
804
+ [column.id]: filter.options[0].id
805
+ }
806
+ }));
807
+ },
808
+ children: "Reset"
809
+ })
810
+ })
536
811
  ]
537
- })
538
- ]
812
+ });
813
+ return isBooleanFilter ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("div", {
814
+ className: __WEBPACK_EXTERNAL_MODULE__Table_module_js_1c0e33be__["default"].filterBooleanFieldWrapper,
815
+ children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__fields_BooleanField_js_dc79ee46__["default"], {
816
+ id: `${column.id}-filter`,
817
+ label: filter.label,
818
+ value: booleanValue,
819
+ onChange: (checked)=>{
820
+ setData((prev)=>({
821
+ filters: {
822
+ ...prev.filters,
823
+ [column.id]: checked ? filter.options[1].id : filter.options[0].id
824
+ }
825
+ }));
826
+ }
827
+ })
828
+ }) : /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(FilterExpander, {
829
+ label: singleFilterLabel,
830
+ highlight: hasNonDefaultValue,
831
+ defaultOpen: 1 === filterableColumns.length,
832
+ children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__fields_SimpleRadioSetField_js_118e9421__["default"], {
833
+ id: `${column.id}-filter`,
834
+ label: "",
835
+ options: filter.options,
836
+ value: value,
837
+ onChange: (optionId)=>{
838
+ setData((prev)=>({
839
+ filters: {
840
+ ...prev.filters,
841
+ [column.id]: optionId
842
+ }
843
+ }));
844
+ }
845
+ })
846
+ }, column.id);
847
+ })
539
848
  })
540
- ]
849
+ })
541
850
  });
542
851
  };
543
852
  const Table_rslib_entry_ = Table;