@worknice/whiteboard 0.35.0 → 0.37.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.
@@ -0,0 +1,831 @@
1
+ import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__ from "react/jsx-runtime";
2
+ import * as __WEBPACK_EXTERNAL_MODULE__floating_ui_react_dom_d5bb3c23__ from "@floating-ui/react-dom";
3
+ import * as __WEBPACK_EXTERNAL_MODULE__react_hook_throttle_d66151d4__ from "@react-hook/throttle";
4
+ import * as __WEBPACK_EXTERNAL_MODULE__tanstack_react_table_777e1b4b__ from "@tanstack/react-table";
5
+ import * as __WEBPACK_EXTERNAL_MODULE__tanstack_react_virtual_e7b31bc6__ from "@tanstack/react-virtual";
6
+ import * as __WEBPACK_EXTERNAL_MODULE_clsx__ from "clsx";
7
+ import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
8
+ import * as __WEBPACK_EXTERNAL_MODULE_utf8__ from "utf8";
9
+ import * as __WEBPACK_EXTERNAL_MODULE__controls_Button_js_f591ba2e__ from "../controls/Button.js";
10
+ import * as __WEBPACK_EXTERNAL_MODULE__controls_Disclosure_js_6e4cc59c__ from "../controls/Disclosure.js";
11
+ import * as __WEBPACK_EXTERNAL_MODULE__controls_MenuButton_js_b23cdd05__ from "../controls/MenuButton.js";
12
+ import * as __WEBPACK_EXTERNAL_MODULE__fields_CheckboxSetField_js_bce910a4__ from "../fields/CheckboxSetField.js";
13
+ import * as __WEBPACK_EXTERNAL_MODULE__fields_ListBoxField_js_b7d4cb12__ from "../fields/ListBoxField.js";
14
+ import * as __WEBPACK_EXTERNAL_MODULE__fields_SimpleRadioSetField_js_118e9421__ from "../fields/SimpleRadioSetField.js";
15
+ import * as __WEBPACK_EXTERNAL_MODULE__forms_FormButtonSet_js_c160eb1a__ from "../forms/FormButtonSet.js";
16
+ import * as __WEBPACK_EXTERNAL_MODULE__forms_useForm_js_e756b4e7__ from "../forms/useForm.js";
17
+ import * as __WEBPACK_EXTERNAL_MODULE__inputs_CheckboxInput_js_3a83f64b__ from "../inputs/CheckboxInput.js";
18
+ import * as __WEBPACK_EXTERNAL_MODULE__inputs_SelectInput_js_d1a6f32e__ from "../inputs/SelectInput.js";
19
+ import * as __WEBPACK_EXTERNAL_MODULE__inputs_StringInput_js_091f1e06__ from "../inputs/StringInput.js";
20
+ import * as __WEBPACK_EXTERNAL_MODULE__utils_encodeCsv_js_1d824629__ from "../utils/encodeCsv.js";
21
+ import * as __WEBPACK_EXTERNAL_MODULE__Card_js_d67c086a__ from "./Card.js";
22
+ import * as __WEBPACK_EXTERNAL_MODULE__CardContent_js_20e3f6de__ from "./CardContent.js";
23
+ import * as __WEBPACK_EXTERNAL_MODULE__HStack_js_cc26058d__ from "./HStack.js";
24
+ import * as __WEBPACK_EXTERNAL_MODULE__Icon_js_0d271bb6__ from "./Icon.js";
25
+ import * as __WEBPACK_EXTERNAL_MODULE__Modal_js_50f53bdf__ from "./Modal.js";
26
+ import * as __WEBPACK_EXTERNAL_MODULE__PlainText_js_cd0b6798__ from "./PlainText.js";
27
+ import * as __WEBPACK_EXTERNAL_MODULE__Table_v2_module_js_4f5732a4__ from "./Table_v2.module.js";
28
+ import * as __WEBPACK_EXTERNAL_MODULE__VStack_js_02eb6792__ from "./VStack.js";
29
+ const selectColumnId = "_selectColumn";
30
+ const actionsColumnId = "_actionsColumn";
31
+ const Table = ({ data, columns, bulkActions = [], secondaryBulkActions = [], csvFilename, estimatedRowSize = 100, emptyState = "No results", pathName, id, localStorageSchema, getRowId, rowActions })=>{
32
+ const [searchTerm, setSearchTerm] = (0, __WEBPACK_EXTERNAL_MODULE_react__.useState)("");
33
+ const [isFilterModalOpen, setIsFilterModalOpen] = (0, __WEBPACK_EXTERNAL_MODULE_react__.useState)(false);
34
+ const lastSelectedRow = (0, __WEBPACK_EXTERNAL_MODULE_react__.useRef)(void 0);
35
+ const { refs, x: bulkSelectionModalXCoordinate } = (0, __WEBPACK_EXTERNAL_MODULE__floating_ui_react_dom_d5bb3c23__.useFloating)({
36
+ placement: "bottom",
37
+ whileElementsMounted: __WEBPACK_EXTERNAL_MODULE__floating_ui_react_dom_d5bb3c23__.autoUpdate
38
+ });
39
+ const enableRowSelection = bulkActions.length + secondaryBulkActions.length > 0;
40
+ const isRowSelectable = (0, __WEBPACK_EXTERNAL_MODULE_react__.useCallback)((row)=>{
41
+ const allBulkActions = [
42
+ ...bulkActions,
43
+ ...secondaryBulkActions
44
+ ];
45
+ return allBulkActions.some((bulkAction)=>!bulkAction.predicate || bulkAction.predicate(row.original));
46
+ }, [
47
+ bulkActions,
48
+ secondaryBulkActions
49
+ ]);
50
+ const columnDefs = (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>{
51
+ const columnHelper = (0, __WEBPACK_EXTERNAL_MODULE__tanstack_react_table_777e1b4b__.createColumnHelper)();
52
+ const result = columns.map((column)=>{
53
+ const { filter, grouping, header, id, cell, globalFiltering, type, size, enableSorting, sortUndefined } = column;
54
+ if ("accessor" == type || void 0 == type) return columnHelper.accessor((row)=>column.value(row), {
55
+ cell: cell ? (props)=>cell(props.row.original) : void 0,
56
+ enableGlobalFilter: false !== globalFiltering,
57
+ enableSorting,
58
+ filterFn: filter ? (row, _, filterValue)=>{
59
+ if (filter.isMulti && Array.isArray(filterValue)) {
60
+ if (0 === filterValue.length) return true;
61
+ return filterValue.some((optionId)=>{
62
+ const option = filter.options.find((opt)=>opt.id === optionId);
63
+ return option ? option.predicate(row.original) : false;
64
+ });
65
+ }
66
+ if (!filter.isMulti && "string" == typeof filterValue) {
67
+ const option = filter.options.find((opt)=>opt.id === filterValue);
68
+ return option?.predicate?.(row.original) ?? true;
69
+ }
70
+ return true;
71
+ } : void 0,
72
+ getGroupingValue: grouping ? (row)=>grouping.fn(row) : void 0,
73
+ header,
74
+ id,
75
+ size,
76
+ sortUndefined: sortUndefined ?? 1
77
+ });
78
+ return columnHelper.display({
79
+ cell: cell ? (props)=>cell(props.row.original) : void 0,
80
+ header,
81
+ id,
82
+ size
83
+ });
84
+ });
85
+ const rowSelectionColumn = enableRowSelection ? columnHelper.display({
86
+ id: selectColumnId,
87
+ header: ({ table })=>{
88
+ const selectableRows = table.getRowModel().rows.filter((row)=>row.getCanSelect());
89
+ const allRowsSelected = table.getIsAllRowsSelected();
90
+ return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__inputs_CheckboxInput_js_3a83f64b__["default"], {
91
+ disabled: 0 === selectableRows.length,
92
+ value: allRowsSelected,
93
+ onChange: ()=>{
94
+ table.toggleAllRowsSelected(!(allRowsSelected || table.getIsSomeRowsSelected()));
95
+ },
96
+ indeterminate: table.getIsSomeRowsSelected()
97
+ });
98
+ },
99
+ cell: ({ table, row })=>/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__inputs_CheckboxInput_js_3a83f64b__["default"], {
100
+ disabled: !row.getCanSelect(),
101
+ value: row.getIsSelected(),
102
+ onClick: (event)=>{
103
+ if (event.shiftKey && lastSelectedRow.current) {
104
+ const visibleRows = table.getRowModel().rows;
105
+ const visibleIndex = visibleRows.findIndex((r)=>r.id === row.id);
106
+ const lastIndex = visibleRows.findIndex((r)=>r.id === lastSelectedRow.current?.id);
107
+ const startIndex = Math.min(lastIndex, visibleIndex);
108
+ const endIndex = Math.max(lastIndex, visibleIndex);
109
+ const rowsToSelect = visibleRows.slice(startIndex, endIndex + 1).filter((r)=>0 === r.subRows.length && r.getCanSelect());
110
+ rowsToSelect.forEach((rowToSelect)=>rowToSelect.toggleSelected(!row.getIsSelected()));
111
+ }
112
+ lastSelectedRow.current = row;
113
+ },
114
+ onChange: (value)=>{
115
+ row.toggleSelected(value);
116
+ }
117
+ }),
118
+ size: 24,
119
+ enableSorting: false,
120
+ enableResizing: false,
121
+ enableColumnFilter: false
122
+ }) : void 0;
123
+ const actionsColumn = rowActions ? columnHelper.display({
124
+ id: actionsColumnId,
125
+ header: "",
126
+ size: 38,
127
+ cell: ({ row })=>/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__controls_MenuButton_js_b23cdd05__["default"], {
128
+ options: rowActions(row.original).filter((action)=>null !== action),
129
+ icon: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__Icon_js_0d271bb6__["default"], {
130
+ symbol: "Overflow"
131
+ })
132
+ }),
133
+ enableSorting: false,
134
+ enableHiding: false,
135
+ enableResizing: false,
136
+ enableColumnFilter: false
137
+ }) : void 0;
138
+ return [
139
+ rowSelectionColumn,
140
+ ...result,
141
+ actionsColumn
142
+ ].filter((column)=>void 0 !== column);
143
+ }, [
144
+ columns,
145
+ enableRowSelection,
146
+ rowActions
147
+ ]);
148
+ const globalFilterableColumns = columns.filter((column)=>false !== column.globalFiltering && "display" !== column.type);
149
+ const filterableColumns = columns.filter((column)=>void 0 !== column.filter);
150
+ const groupableColumns = columns.filter((column)=>void 0 !== column.grouping);
151
+ const csvExportableColumns = columns.filter((column)=>true === column.csvExport);
152
+ const columnFiltersInitialState = (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>filterableColumns.map((col)=>{
153
+ const filter = col.filter;
154
+ if (filter.isMulti) return {
155
+ id: col.id,
156
+ value: []
157
+ };
158
+ return {
159
+ id: col.id,
160
+ value: filter.options[0].id
161
+ };
162
+ }), [
163
+ filterableColumns
164
+ ]);
165
+ const storageKey = (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>pathName && id ? `${pathName}#${id}_table` : null, [
166
+ pathName,
167
+ id
168
+ ]);
169
+ const localStorageData = "undefined" != typeof window && storageKey ? window.localStorage.getItem(storageKey) : null;
170
+ let parsedLocalStorage = {};
171
+ if (localStorageData && localStorageSchema) try {
172
+ parsedLocalStorage = JSON.parse(localStorageData);
173
+ localStorageSchema.parse(parsedLocalStorage);
174
+ } catch (error) {
175
+ console.error("Error parsing localStorage data:", error);
176
+ parsedLocalStorage = {};
177
+ }
178
+ const table = (0, __WEBPACK_EXTERNAL_MODULE__tanstack_react_table_777e1b4b__.useReactTable)({
179
+ data,
180
+ getRowId,
181
+ columns: columnDefs,
182
+ groupedColumnMode: false,
183
+ getCoreRowModel: (0, __WEBPACK_EXTERNAL_MODULE__tanstack_react_table_777e1b4b__.getCoreRowModel)(),
184
+ getSortedRowModel: (0, __WEBPACK_EXTERNAL_MODULE__tanstack_react_table_777e1b4b__.getSortedRowModel)(),
185
+ getGroupedRowModel: (0, __WEBPACK_EXTERNAL_MODULE__tanstack_react_table_777e1b4b__.getGroupedRowModel)(),
186
+ getFilteredRowModel: (0, __WEBPACK_EXTERNAL_MODULE__tanstack_react_table_777e1b4b__.getFilteredRowModel)(),
187
+ getExpandedRowModel: (0, __WEBPACK_EXTERNAL_MODULE__tanstack_react_table_777e1b4b__.getExpandedRowModel)(),
188
+ getColumnCanGlobalFilter: ()=>true,
189
+ enableRowSelection: enableRowSelection ? isRowSelectable : false,
190
+ initialState: {
191
+ expanded: true,
192
+ columnFilters: parsedLocalStorage.columnFilters ?? columnFiltersInitialState,
193
+ sorting: parsedLocalStorage.sorting ?? [],
194
+ grouping: parsedLocalStorage.grouping ?? [],
195
+ columnVisibility: Object.fromEntries(columns.filter((col)=>true === col.hiddenByDefault).map((col)=>[
196
+ col.id,
197
+ false
198
+ ])),
199
+ globalFilter: ""
200
+ },
201
+ defaultColumn: {
202
+ enableGrouping: false,
203
+ enableColumnFilter: false,
204
+ enableGlobalFilter: false,
205
+ enableSorting: false
206
+ }
207
+ });
208
+ const tableState = table.getState();
209
+ const tBodyRef = (0, __WEBPACK_EXTERNAL_MODULE_react__.useRef)(null);
210
+ const rows = table.getRowModel().rows;
211
+ const estimateSize = (0, __WEBPACK_EXTERNAL_MODULE_react__.useCallback)((index)=>{
212
+ if (!rows[index].getIsGrouped()) return estimatedRowSize;
213
+ {
214
+ const groupColumn = groupableColumns.find((column)=>column.id === rows[index].groupingColumnId);
215
+ return groupColumn?.grouping.size ?? estimatedRowSize;
216
+ }
217
+ }, [
218
+ estimatedRowSize,
219
+ groupableColumns,
220
+ rows
221
+ ]);
222
+ const rowVirtualizer = (0, __WEBPACK_EXTERNAL_MODULE__tanstack_react_virtual_e7b31bc6__.useWindowVirtualizer)({
223
+ count: rows.length,
224
+ estimateSize,
225
+ overscan: 10,
226
+ scrollMargin: tBodyRef.current?.offsetTop ?? 0,
227
+ initialRect: {
228
+ height: 1080,
229
+ width: 1920
230
+ },
231
+ getItemKey: (index)=>{
232
+ const row = rows[index];
233
+ return `${row.id}-${table.getState().grouping.join(",")}`;
234
+ },
235
+ measureElement: (element, _, instance)=>{
236
+ const rect = element.getBoundingClientRect();
237
+ if (rect.height > 0 && rect.width > 0) return Math.round(rect.height);
238
+ const cachedSize = instance.measurementsCache[instance.indexFromElement(element)].size;
239
+ return cachedSize;
240
+ }
241
+ });
242
+ const createCsvDataUrl = (columns, rows)=>{
243
+ const csvContent = (0, __WEBPACK_EXTERNAL_MODULE__utils_encodeCsv_js_1d824629__["default"])([
244
+ columns.map((col)=>col.header),
245
+ ...rows.map((row)=>columns.map((col)=>row.getValue(col.id)))
246
+ ]);
247
+ return `data:text/csv;charset=utf-8,${__WEBPACK_EXTERNAL_MODULE_utf8__["default"].encode(csvContent)}`;
248
+ };
249
+ const handleDownloadCsv = (columns, rows)=>{
250
+ if (!csvFilename) return;
251
+ const csvDataUrl = createCsvDataUrl(columns, rows);
252
+ const a = document.createElement("a");
253
+ a.href = csvDataUrl;
254
+ a.download = csvFilename.endsWith(".csv") ? csvFilename : `${csvFilename}.csv`;
255
+ a.click();
256
+ };
257
+ const throttledSetGlobalFilter = (0, __WEBPACK_EXTERNAL_MODULE__react_hook_throttle_d66151d4__.useThrottleCallback)((value)=>table.setGlobalFilter(value), 4);
258
+ const activeFilterCount = (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>{
259
+ const currentFilters = tableState.columnFilters;
260
+ return columnFiltersInitialState.filter((initialFilter)=>{
261
+ const currentFilter = currentFilters.find((f)=>f.id === initialFilter.id);
262
+ const currentValue = currentFilter?.value;
263
+ const initialValue = initialFilter.value;
264
+ if (Array.isArray(initialValue) && Array.isArray(currentValue)) return currentValue.length !== initialValue.length || initialValue.some((v, i)=>v !== currentValue[i]);
265
+ return currentValue !== initialValue;
266
+ }).length;
267
+ }, [
268
+ tableState.columnFilters,
269
+ columnFiltersInitialState
270
+ ]);
271
+ const showSearchReset = activeFilterCount > 0 || "" !== tableState.globalFilter;
272
+ const filteredSelectedRows = table.getFilteredSelectedRowModel();
273
+ const validPrimaryBulkActions = bulkActions.filter((bulkAction)=>filteredSelectedRows.rows.some((row)=>bulkAction.predicate ? bulkAction.predicate(row.original) : true));
274
+ const validSecondaryBulkActions = secondaryBulkActions.filter((bulkAction)=>filteredSelectedRows.rows.some((row)=>bulkAction.predicate ? bulkAction.predicate(row.original) : true));
275
+ (0, __WEBPACK_EXTERNAL_MODULE_react__.useEffect)(()=>{
276
+ if (storageKey) window.localStorage.setItem(storageKey, JSON.stringify({
277
+ columnFilters: tableState.columnFilters,
278
+ sorting: tableState.sorting,
279
+ grouping: tableState.grouping
280
+ }));
281
+ }, [
282
+ tableState.columnFilters,
283
+ tableState.sorting,
284
+ tableState.grouping,
285
+ storageKey
286
+ ]);
287
+ const shouldShowCsvExport = csvExportableColumns.length > 0 && csvFilename;
288
+ const shouldShowMoreActions = validSecondaryBulkActions.length > 0 || shouldShowCsvExport;
289
+ const getbulkActionRows = (bulkAction)=>filteredSelectedRows.flatRows.filter((row)=>bulkAction.predicate ? bulkAction.predicate(row.original) : true).map((row)=>row.original);
290
+ const primaryBulkActionRowsMap = new Map(validPrimaryBulkActions.map((bulkAction)=>[
291
+ bulkAction.key,
292
+ getbulkActionRows(bulkAction)
293
+ ]));
294
+ const secondaryBulkActionRowsMap = new Map(validSecondaryBulkActions.map((bulkAction)=>[
295
+ bulkAction.key,
296
+ getbulkActionRows(bulkAction)
297
+ ]));
298
+ const allBulkActionRowCounts = [
299
+ ...Array.from(primaryBulkActionRowsMap.values()).map((rows)=>rows.length),
300
+ ...Array.from(secondaryBulkActionRowsMap.values()).map((rows)=>rows.length)
301
+ ];
302
+ const bulkActionRowCountsDiffer = new Set(allBulkActionRowCounts).size > 1;
303
+ const hasMultipleActions = allBulkActionRowCounts.length > 1;
304
+ const allRowsCanDoAllActions = hasMultipleActions && allBulkActionRowCounts.every((count)=>count === filteredSelectedRows.rows.length);
305
+ const showBulkActionCounts = bulkActionRowCountsDiffer || hasMultipleActions && !allRowsCanDoAllActions;
306
+ return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)(__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.Fragment, {
307
+ children: [
308
+ /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)("div", {
309
+ ref: refs.setReference,
310
+ children: [
311
+ validPrimaryBulkActions.length > 0 || validSecondaryBulkActions.length > 0 ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("div", {
312
+ ref: refs.setFloating,
313
+ className: __WEBPACK_EXTERNAL_MODULE__Table_v2_module_js_4f5732a4__["default"].bulkSelectionModal,
314
+ style: {
315
+ left: bulkSelectionModalXCoordinate
316
+ },
317
+ children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__Card_js_d67c086a__["default"], {
318
+ hasShadow: true,
319
+ children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__CardContent_js_20e3f6de__["default"], {
320
+ spacing: "00",
321
+ children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)("div", {
322
+ className: __WEBPACK_EXTERNAL_MODULE__Table_v2_module_js_4f5732a4__["default"].bulkSelectionModalContent,
323
+ children: [
324
+ /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)(__WEBPACK_EXTERNAL_MODULE__PlainText_js_cd0b6798__["default"], {
325
+ font: "regular-bold",
326
+ children: [
327
+ filteredSelectedRows.rows.length,
328
+ " ",
329
+ 1 === filteredSelectedRows.rows.length ? "selection" : "selections"
330
+ ]
331
+ }),
332
+ /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)("div", {
333
+ className: __WEBPACK_EXTERNAL_MODULE__Table_v2_module_js_4f5732a4__["default"].bulkSelectionActions,
334
+ children: [
335
+ validPrimaryBulkActions.map((bulkAction)=>{
336
+ const rows = primaryBulkActionRowsMap.get(bulkAction.key) ?? [];
337
+ return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__controls_Disclosure_js_6e4cc59c__["default"], {
338
+ render: (onClose)=>bulkAction.render({
339
+ rows: primaryBulkActionRowsMap.get(bulkAction.key) ?? [],
340
+ resetRowSelection: ()=>table.resetRowSelection(),
341
+ onClose: onClose
342
+ }),
343
+ children: showBulkActionCounts ? `${bulkAction.label} (${rows.length})` : bulkAction.label
344
+ }, bulkAction.key);
345
+ }),
346
+ shouldShowMoreActions ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__controls_MenuButton_js_b23cdd05__["default"], {
347
+ id: "bulkActionOverflow",
348
+ options: [
349
+ ...validSecondaryBulkActions.map((bulkAction)=>{
350
+ const rows = secondaryBulkActionRowsMap.get(bulkAction.key) ?? [];
351
+ return {
352
+ id: bulkAction.key,
353
+ label: showBulkActionCounts ? `${bulkAction.label} (${rows.length})` : bulkAction.label,
354
+ type: "render",
355
+ render: (onClose)=>bulkAction.render({
356
+ rows: rows,
357
+ resetRowSelection: ()=>table.resetRowSelection(),
358
+ onClose: onClose
359
+ })
360
+ };
361
+ }),
362
+ ...shouldShowCsvExport ? [
363
+ {
364
+ id: "download-selected-rows",
365
+ label: "Download selected rows as CSV",
366
+ type: "onClick",
367
+ onClick: ()=>handleDownloadCsv(csvExportableColumns, table.getSelectedRowModel().rows)
368
+ }
369
+ ] : []
370
+ ],
371
+ icon: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__Icon_js_0d271bb6__["default"], {
372
+ symbol: "Plus"
373
+ }),
374
+ children: "More actions"
375
+ }) : null,
376
+ /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__controls_Button_js_f591ba2e__["default"], {
377
+ icon: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__Icon_js_0d271bb6__["default"], {
378
+ symbol: "Close"
379
+ }),
380
+ onClick: ()=>{
381
+ table.resetRowSelection(true);
382
+ },
383
+ title: `Deselect ${table.getFilteredSelectedRowModel().rows.length} ${1 === table.getFilteredSelectedRowModel().rows.length ? "selection" : "selections"}`,
384
+ type: "secondary"
385
+ })
386
+ ]
387
+ })
388
+ ]
389
+ })
390
+ })
391
+ })
392
+ }) : null,
393
+ /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)(__WEBPACK_EXTERNAL_MODULE__VStack_js_02eb6792__["default"], {
394
+ spacing: "p1",
395
+ children: [
396
+ 0 !== globalFilterableColumns.length || 0 !== filterableColumns.length || 0 !== groupableColumns.length ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)("div", {
397
+ className: __WEBPACK_EXTERNAL_MODULE__Table_v2_module_js_4f5732a4__["default"].filterBar,
398
+ children: [
399
+ 0 !== globalFilterableColumns.length ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__inputs_StringInput_js_091f1e06__["default"], {
400
+ prefix: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__Icon_js_0d271bb6__["default"], {
401
+ symbol: "Search"
402
+ }),
403
+ placeholder: "Search",
404
+ id: "globalSearch",
405
+ value: searchTerm,
406
+ onChange: (value)=>{
407
+ setSearchTerm(value ?? "");
408
+ throttledSetGlobalFilter(value ?? "");
409
+ }
410
+ }) : null,
411
+ 0 !== filterableColumns.length || 0 !== groupableColumns.length ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)("div", {
412
+ className: __WEBPACK_EXTERNAL_MODULE__Table_v2_module_js_4f5732a4__["default"].filterSelectMenus,
413
+ children: [
414
+ /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)(__WEBPACK_EXTERNAL_MODULE__controls_Button_js_f591ba2e__["default"], {
415
+ type: "secondary",
416
+ onClick: ()=>setIsFilterModalOpen(true),
417
+ icon: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__Icon_js_0d271bb6__["default"], {
418
+ symbol: "Filter"
419
+ }),
420
+ children: [
421
+ "Filters",
422
+ activeFilterCount > 0 ? ` (${activeFilterCount})` : ""
423
+ ]
424
+ }),
425
+ 0 !== groupableColumns.length ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__inputs_SelectInput_js_d1a6f32e__["default"], {
426
+ id: "columnGroupings",
427
+ onChange: (value)=>table.setGrouping(value ? [
428
+ value.id
429
+ ] : []),
430
+ options: [
431
+ void 0,
432
+ ...groupableColumns
433
+ ],
434
+ optionToId: (option)=>void 0 === option ? "noGrouping" : option.id,
435
+ optionToLabel: (option)=>void 0 === option ? "No grouping" : option.grouping.label,
436
+ value: groupableColumns.find((column)=>table.getState().grouping.some((id)=>id === column.id))
437
+ }) : null
438
+ ]
439
+ }) : null
440
+ ]
441
+ }) : null,
442
+ showSearchReset ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)(__WEBPACK_EXTERNAL_MODULE__HStack_js_cc26058d__["default"], {
443
+ children: [
444
+ /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)("p", {
445
+ children: [
446
+ "Showing ",
447
+ table.getPreGroupedRowModel().flatRows.length,
448
+ " of",
449
+ " ",
450
+ table.getPreFilteredRowModel().flatRows.length
451
+ ]
452
+ }),
453
+ /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__controls_Button_js_f591ba2e__["default"], {
454
+ onClick: ()=>{
455
+ table.setColumnFilters(columnFiltersInitialState);
456
+ table.resetGlobalFilter();
457
+ setSearchTerm("");
458
+ },
459
+ type: "secondary",
460
+ size: "small",
461
+ children: "Reset filters and search"
462
+ })
463
+ ]
464
+ }) : null,
465
+ /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("div", {
466
+ className: __WEBPACK_EXTERNAL_MODULE__Table_v2_module_js_4f5732a4__["default"].tableContainer,
467
+ children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)("table", {
468
+ className: __WEBPACK_EXTERNAL_MODULE__Table_v2_module_js_4f5732a4__["default"].table,
469
+ children: [
470
+ /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("thead", {
471
+ className: __WEBPACK_EXTERNAL_MODULE__Table_v2_module_js_4f5732a4__["default"].tableHead,
472
+ children: table.getHeaderGroups().map((headerGroup)=>/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("tr", {
473
+ className: (0, __WEBPACK_EXTERNAL_MODULE_clsx__["default"])([
474
+ __WEBPACK_EXTERNAL_MODULE__Table_v2_module_js_4f5732a4__["default"].tableRow,
475
+ enableRowSelection ? __WEBPACK_EXTERNAL_MODULE__Table_v2_module_js_4f5732a4__["default"].selectableRows : ""
476
+ ]),
477
+ children: headerGroup.headers.map((header)=>/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("th", {
478
+ className: (0, __WEBPACK_EXTERNAL_MODULE_clsx__["default"])([
479
+ __WEBPACK_EXTERNAL_MODULE__Table_v2_module_js_4f5732a4__["default"].tableCell,
480
+ __WEBPACK_EXTERNAL_MODULE__Table_v2_module_js_4f5732a4__["default"].tableHeader,
481
+ header.column.id === selectColumnId ? __WEBPACK_EXTERNAL_MODULE__Table_v2_module_js_4f5732a4__["default"].selectionCell : void 0,
482
+ header.column.id === actionsColumnId ? __WEBPACK_EXTERNAL_MODULE__Table_v2_module_js_4f5732a4__["default"].actionsCell : void 0
483
+ ]),
484
+ style: {
485
+ width: header.column.getSize(),
486
+ flexGrow: header.column.id === selectColumnId || header.column.id === actionsColumnId ? 0 : header.column.getSize()
487
+ },
488
+ children: header.isPlaceholder ? null : header.column.getCanSort() ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)("button", {
489
+ onClick: header.column.getToggleSortingHandler(),
490
+ className: __WEBPACK_EXTERNAL_MODULE__Table_v2_module_js_4f5732a4__["default"].sortableTableHeader,
491
+ title: "asc" === header.column.getIsSorted() ? "Sorted by ascending order" : "desc" === header.column.getIsSorted() ? "Sorted by descending order" : "Default sorting order",
492
+ children: [
493
+ (0, __WEBPACK_EXTERNAL_MODULE__tanstack_react_table_777e1b4b__.flexRender)(header.column.columnDef.header, header.getContext()),
494
+ "asc" === header.column.getIsSorted() ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__Icon_js_0d271bb6__["default"], {
495
+ size: "small",
496
+ symbol: "SortAsc",
497
+ className: __WEBPACK_EXTERNAL_MODULE__Table_v2_module_js_4f5732a4__["default"].sortIcon
498
+ }) : "desc" === header.column.getIsSorted() ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__Icon_js_0d271bb6__["default"], {
499
+ size: "small",
500
+ symbol: "SortDes",
501
+ className: __WEBPACK_EXTERNAL_MODULE__Table_v2_module_js_4f5732a4__["default"].sortIcon
502
+ }) : /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__Icon_js_0d271bb6__["default"], {
503
+ size: "small",
504
+ symbol: "SortDefault",
505
+ className: __WEBPACK_EXTERNAL_MODULE__Table_v2_module_js_4f5732a4__["default"].sortIcon
506
+ })
507
+ ]
508
+ }) : /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("div", {
509
+ children: (0, __WEBPACK_EXTERNAL_MODULE__tanstack_react_table_777e1b4b__.flexRender)(header.column.columnDef.header, header.getContext())
510
+ })
511
+ }, header.id))
512
+ }, headerGroup.id))
513
+ }),
514
+ /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("tbody", {
515
+ ref: tBodyRef,
516
+ className: __WEBPACK_EXTERNAL_MODULE__Table_v2_module_js_4f5732a4__["default"].tableBody,
517
+ style: {
518
+ height: rows.length > 0 ? `${rowVirtualizer.getTotalSize()}px` : "auto"
519
+ },
520
+ children: table.getRowModel().rows.length ? rowVirtualizer.getVirtualItems().map((virtualRow)=>{
521
+ const row = rows[virtualRow.index];
522
+ const groupColumn = groupableColumns.find((column)=>column.id === row.groupingColumnId);
523
+ return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("tr", {
524
+ "data-state": row.getIsSelected() ? "selected" : "",
525
+ className: (0, __WEBPACK_EXTERNAL_MODULE_clsx__["default"])([
526
+ __WEBPACK_EXTERNAL_MODULE__Table_v2_module_js_4f5732a4__["default"].tableRow,
527
+ enableRowSelection ? __WEBPACK_EXTERNAL_MODULE__Table_v2_module_js_4f5732a4__["default"].selectableRows : "",
528
+ row.getIsGrouped() && groupColumn ? __WEBPACK_EXTERNAL_MODULE__Table_v2_module_js_4f5732a4__["default"].tableRowGrouped : ""
529
+ ]),
530
+ "data-index": virtualRow.index,
531
+ ref: rowVirtualizer.measureElement,
532
+ style: {
533
+ position: "absolute",
534
+ transform: `translateY(${virtualRow.start - rowVirtualizer.options.scrollMargin}px)`
535
+ },
536
+ children: row.getIsGrouped() && groupColumn ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("td", {
537
+ className: __WEBPACK_EXTERNAL_MODULE__Table_v2_module_js_4f5732a4__["default"].tableCell,
538
+ children: groupColumn.grouping.header(row.original)
539
+ }) : /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.Fragment, {
540
+ children: row.getVisibleCells().map((cell)=>/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("td", {
541
+ className: (0, __WEBPACK_EXTERNAL_MODULE_clsx__["default"])([
542
+ __WEBPACK_EXTERNAL_MODULE__Table_v2_module_js_4f5732a4__["default"].tableCell,
543
+ cell.column.id === selectColumnId ? __WEBPACK_EXTERNAL_MODULE__Table_v2_module_js_4f5732a4__["default"].selectionCell : void 0,
544
+ cell.column.id === actionsColumnId ? __WEBPACK_EXTERNAL_MODULE__Table_v2_module_js_4f5732a4__["default"].actionsCell : void 0
545
+ ]),
546
+ style: {
547
+ width: cell.column.getSize(),
548
+ flexGrow: cell.column.id === selectColumnId || cell.column.id === actionsColumnId ? 0 : cell.column.getSize()
549
+ },
550
+ children: (0, __WEBPACK_EXTERNAL_MODULE__tanstack_react_table_777e1b4b__.flexRender)(cell.column.columnDef.cell, cell.getContext())
551
+ }, cell.id))
552
+ })
553
+ }, row.id);
554
+ }) : /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("tr", {
555
+ className: __WEBPACK_EXTERNAL_MODULE__Table_v2_module_js_4f5732a4__["default"].tableRow,
556
+ children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("td", {
557
+ className: __WEBPACK_EXTERNAL_MODULE__Table_v2_module_js_4f5732a4__["default"].noRows,
558
+ children: emptyState
559
+ })
560
+ })
561
+ })
562
+ ]
563
+ })
564
+ }),
565
+ /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)("div", {
566
+ className: __WEBPACK_EXTERNAL_MODULE__Table_v2_module_js_4f5732a4__["default"].downloadLink,
567
+ children: [
568
+ /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)("p", {
569
+ children: [
570
+ "Showing ",
571
+ table.getPreGroupedRowModel().flatRows.length,
572
+ " of",
573
+ " ",
574
+ table.getPreFilteredRowModel().flatRows.length
575
+ ]
576
+ }),
577
+ shouldShowCsvExport ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__controls_Button_js_f591ba2e__["default"], {
578
+ type: "secondary",
579
+ onClick: ()=>handleDownloadCsv(csvExportableColumns, table.getRowModel().rows),
580
+ children: "Download all rows as CSV"
581
+ }) : null
582
+ ]
583
+ })
584
+ ]
585
+ })
586
+ ]
587
+ }),
588
+ isFilterModalOpen && /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(FilterModal, {
589
+ onClose: ()=>setIsFilterModalOpen(false),
590
+ filterableColumns: filterableColumns,
591
+ currentFilters: tableState.columnFilters,
592
+ onFiltersChange: (filters)=>table.setColumnFilters(filters)
593
+ })
594
+ ]
595
+ });
596
+ };
597
+ const FilterExpander = ({ label, children, highlight = false })=>/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)("details", {
598
+ className: (0, __WEBPACK_EXTERNAL_MODULE_clsx__["default"])(__WEBPACK_EXTERNAL_MODULE__Table_v2_module_js_4f5732a4__["default"].filterExpander, {
599
+ [__WEBPACK_EXTERNAL_MODULE__Table_v2_module_js_4f5732a4__["default"].filterExpanderHighlight]: highlight
600
+ }),
601
+ children: [
602
+ /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)("summary", {
603
+ className: __WEBPACK_EXTERNAL_MODULE__Table_v2_module_js_4f5732a4__["default"].filterExpanderRow,
604
+ children: [
605
+ /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("span", {
606
+ className: __WEBPACK_EXTERNAL_MODULE__Table_v2_module_js_4f5732a4__["default"].filterExpanderIcon,
607
+ children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__Icon_js_0d271bb6__["default"], {
608
+ symbol: "ChevronRight"
609
+ })
610
+ }),
611
+ /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("span", {
612
+ className: __WEBPACK_EXTERNAL_MODULE__Table_v2_module_js_4f5732a4__["default"].filterExpanderLabel,
613
+ children: label
614
+ })
615
+ ]
616
+ }),
617
+ /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("div", {
618
+ className: __WEBPACK_EXTERNAL_MODULE__Table_v2_module_js_4f5732a4__["default"].filterExpanderWrapper,
619
+ children: children
620
+ })
621
+ ]
622
+ });
623
+ const FilterModal = ({ onClose, filterableColumns, currentFilters, onFiltersChange })=>{
624
+ const initialFilterValues = (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>{
625
+ const result = {};
626
+ for (const column of filterableColumns){
627
+ const current = currentFilters.find((f)=>f.id === column.id);
628
+ const filter = column.filter;
629
+ if (filter.isMulti) result[column.id] = Array.isArray(current?.value) ? current.value : [];
630
+ else result[column.id] = ("string" == typeof current?.value ? current.value : null) ?? filter.options[0].id;
631
+ }
632
+ return result;
633
+ }, [
634
+ filterableColumns,
635
+ currentFilters
636
+ ]);
637
+ const resetFilterValues = (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>{
638
+ const result = {};
639
+ for (const col of filterableColumns){
640
+ const filter = col.filter;
641
+ result[col.id] = filter.isMulti ? [] : filter.options[0].id;
642
+ }
643
+ return result;
644
+ }, [
645
+ filterableColumns
646
+ ]);
647
+ const { data, setData, status, submit } = (0, __WEBPACK_EXTERNAL_MODULE__forms_useForm_js_e756b4e7__["default"])({
648
+ initialValues: {
649
+ filters: initialFilterValues
650
+ },
651
+ onSubmit: async (values)=>{
652
+ const filters = Object.entries(values.filters).map(([columnId, value])=>({
653
+ id: columnId,
654
+ value
655
+ }));
656
+ onFiltersChange(filters);
657
+ }
658
+ });
659
+ const handleMultiFilterChange = (0, __WEBPACK_EXTERNAL_MODULE_react__.useCallback)((columnId, option)=>{
660
+ setData((prev)=>{
661
+ const prevValue = prev.filters[columnId];
662
+ const current = Array.isArray(prevValue) ? prevValue : [];
663
+ const next = current.includes(option.id) ? current.filter((id)=>id !== option.id) : [
664
+ ...current,
665
+ option.id
666
+ ];
667
+ return {
668
+ filters: {
669
+ ...prev.filters,
670
+ [columnId]: next
671
+ }
672
+ };
673
+ });
674
+ }, [
675
+ setData
676
+ ]);
677
+ return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__Modal_js_50f53bdf__["default"], {
678
+ onClose: onClose,
679
+ children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__Card_js_d67c086a__["default"], {
680
+ header: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__PlainText_js_cd0b6798__["default"], {
681
+ font: "h6",
682
+ tagName: "h6",
683
+ children: "Filters"
684
+ }),
685
+ footer: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)(__WEBPACK_EXTERNAL_MODULE__HStack_js_cc26058d__["default"], {
686
+ justify: "space-between",
687
+ children: [
688
+ /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__controls_Button_js_f591ba2e__["default"], {
689
+ type: "secondary",
690
+ onClick: ()=>{
691
+ setData(()=>({
692
+ filters: resetFilterValues
693
+ }));
694
+ },
695
+ icon: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__Icon_js_0d271bb6__["default"], {
696
+ symbol: "Restore"
697
+ }),
698
+ children: "Reset all filters"
699
+ }),
700
+ /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__forms_FormButtonSet_js_c160eb1a__["default"], {
701
+ formStatus: status,
702
+ primary: {
703
+ action: async ()=>{
704
+ submit();
705
+ onClose();
706
+ },
707
+ label: "Apply filters"
708
+ },
709
+ secondary: {
710
+ action: onClose,
711
+ label: "Cancel"
712
+ }
713
+ })
714
+ ]
715
+ }),
716
+ children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("div", {
717
+ className: __WEBPACK_EXTERNAL_MODULE__Table_v2_module_js_4f5732a4__["default"].filterExpandersContainer,
718
+ children: filterableColumns.map((column)=>{
719
+ const filter = column.filter;
720
+ if (filter.isMulti) {
721
+ const filterValue = data.filters[column.id];
722
+ const selectedIds = Array.isArray(filterValue) ? filterValue : [];
723
+ const selectedOptions = filter.options.filter((opt)=>selectedIds.includes(opt.id));
724
+ const multiFilterLabel = /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)(__WEBPACK_EXTERNAL_MODULE__HStack_js_cc26058d__["default"], {
725
+ justify: "space-between",
726
+ children: [
727
+ /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("span", {
728
+ children: selectedIds.length > 0 ? `${filter.label} (${selectedIds.length} selected)` : filter.label
729
+ }),
730
+ /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("span", {
731
+ style: {
732
+ visibility: selectedIds.length > 0 ? "visible" : "hidden"
733
+ },
734
+ children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__controls_Button_js_f591ba2e__["default"], {
735
+ type: "secondary",
736
+ size: "small",
737
+ onClick: (e)=>{
738
+ e.stopPropagation();
739
+ setData((prev)=>({
740
+ filters: {
741
+ ...prev.filters,
742
+ [column.id]: []
743
+ }
744
+ }));
745
+ },
746
+ children: "Reset"
747
+ })
748
+ })
749
+ ]
750
+ });
751
+ return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(FilterExpander, {
752
+ label: multiFilterLabel,
753
+ highlight: selectedIds.length > 0,
754
+ children: filter.useListBox ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("div", {
755
+ className: __WEBPACK_EXTERNAL_MODULE__Table_v2_module_js_4f5732a4__["default"].listBoxFilterContainer,
756
+ children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__fields_ListBoxField_js_b7d4cb12__["default"], {
757
+ id: `${column.id}-filter`,
758
+ label: "",
759
+ options: filter.options,
760
+ optionToId: (opt)=>opt.id,
761
+ optionToLabel: (opt)=>opt.label,
762
+ searchField: "label",
763
+ value: selectedOptions,
764
+ onChange: (option)=>handleMultiFilterChange(column.id, option)
765
+ })
766
+ }) : /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__fields_CheckboxSetField_js_bce910a4__["default"], {
767
+ id: `${column.id}-filter`,
768
+ label: "",
769
+ options: filter.options,
770
+ optionToId: (opt)=>opt.id,
771
+ optionToLabel: (opt)=>opt.label,
772
+ values: selectedOptions,
773
+ onChange: (option)=>handleMultiFilterChange(column.id, option)
774
+ })
775
+ }, column.id);
776
+ }
777
+ const rawValue = data.filters[column.id];
778
+ const value = "string" == typeof rawValue ? rawValue : filter.options[0].id;
779
+ const hasNonDefaultValue = "string" == typeof rawValue && rawValue !== filter.options[0].id;
780
+ const singleFilterLabel = /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)(__WEBPACK_EXTERNAL_MODULE__HStack_js_cc26058d__["default"], {
781
+ justify: "space-between",
782
+ children: [
783
+ /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("span", {
784
+ children: hasNonDefaultValue ? `${filter.label} (Selected)` : filter.label
785
+ }),
786
+ /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("span", {
787
+ style: {
788
+ visibility: hasNonDefaultValue ? "visible" : "hidden"
789
+ },
790
+ children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__controls_Button_js_f591ba2e__["default"], {
791
+ type: "secondary",
792
+ size: "small",
793
+ onClick: (e)=>{
794
+ e.stopPropagation();
795
+ setData((prev)=>({
796
+ filters: {
797
+ ...prev.filters,
798
+ [column.id]: filter.options[0].id
799
+ }
800
+ }));
801
+ },
802
+ children: "Reset"
803
+ })
804
+ })
805
+ ]
806
+ });
807
+ return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(FilterExpander, {
808
+ label: singleFilterLabel,
809
+ highlight: hasNonDefaultValue,
810
+ children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__fields_SimpleRadioSetField_js_118e9421__["default"], {
811
+ id: `${column.id}-filter`,
812
+ label: "",
813
+ options: filter.options,
814
+ value: value,
815
+ onChange: (optionId)=>{
816
+ setData((prev)=>({
817
+ filters: {
818
+ ...prev.filters,
819
+ [column.id]: optionId
820
+ }
821
+ }));
822
+ }
823
+ })
824
+ }, column.id);
825
+ })
826
+ })
827
+ })
828
+ });
829
+ };
830
+ const Table_v2_rslib_entry_ = Table;
831
+ export { Table_v2_rslib_entry_ as default };