@worknice/whiteboard 0.52.1 → 0.53.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 (75) hide show
  1. package/dist/{presentation/TableColumnFilterModal.d.ts → controls/FilterModal.d.ts} +10 -3
  2. package/dist/{presentation/TableColumnFilterModal.js → controls/FilterModal.js} +32 -32
  3. package/dist/controls/FilterModal.module.js +13 -0
  4. package/dist/controls/FilterModal_module.css +60 -0
  5. package/dist/controls/MenuButton.js +1 -1
  6. package/dist/icons/MessagesIcon.d.ts +3 -0
  7. package/dist/icons/MessagesIcon.js +11 -0
  8. package/dist/icons/SlidersIcon.d.ts +3 -0
  9. package/dist/icons/SlidersIcon.js +12 -0
  10. package/dist/icons/WarningIcon.js +3 -3
  11. package/dist/icons/index.d.ts +2 -0
  12. package/dist/icons/index.js +3 -1
  13. package/dist/presentation/CustomizableTable/CustomizableTable.d.ts +1 -1
  14. package/dist/presentation/CustomizableTable/CustomizableTable.js +3 -3
  15. package/dist/presentation/RichList/RichList.d.ts +150 -0
  16. package/dist/presentation/RichList/RichList.js +507 -0
  17. package/dist/presentation/RichList/RichList.module.js +12 -0
  18. package/dist/presentation/RichList/RichList.stories.d.ts +24 -0
  19. package/dist/presentation/RichList/RichList.stories.js +334 -0
  20. package/dist/presentation/RichList/RichListBulkActionBar.d.ts +21 -0
  21. package/dist/presentation/RichList/RichListBulkActionBar.js +112 -0
  22. package/dist/presentation/RichList/RichListBulkActionBar.module.js +7 -0
  23. package/dist/presentation/RichList/RichListBulkActionBar_module.css +18 -0
  24. package/dist/presentation/RichList/RichListDisplayModal.d.ts +33 -0
  25. package/dist/presentation/RichList/RichListDisplayModal.js +198 -0
  26. package/dist/presentation/RichList/RichListRow.d.ts +39 -0
  27. package/dist/presentation/RichList/RichListRow.js +278 -0
  28. package/dist/presentation/RichList/RichListRow.module.js +34 -0
  29. package/dist/presentation/RichList/RichListRow_module.css +313 -0
  30. package/dist/presentation/RichList/RichListToolbar.d.ts +21 -0
  31. package/dist/presentation/RichList/RichListToolbar.js +104 -0
  32. package/dist/presentation/RichList/RichListToolbar.module.js +12 -0
  33. package/dist/presentation/RichList/RichListToolbar_module.css +100 -0
  34. package/dist/presentation/RichList/RichList_module.css +77 -0
  35. package/dist/presentation/RichList/helpers.d.ts +77 -0
  36. package/dist/presentation/RichList/helpers.js +121 -0
  37. package/dist/presentation/RichList/stories/ComplianceGroups.d.ts +9 -0
  38. package/dist/presentation/RichList/stories/ComplianceGroups.js +141 -0
  39. package/dist/presentation/RichList/stories/CustomFields.d.ts +13 -0
  40. package/dist/presentation/RichList/stories/CustomFields.js +80 -0
  41. package/dist/presentation/RichList/stories/EmployeeCompliance.d.ts +15 -0
  42. package/dist/presentation/RichList/stories/EmployeeCompliance.js +300 -0
  43. package/dist/presentation/RichList/stories/EmployeePaperwork.d.ts +21 -0
  44. package/dist/presentation/RichList/stories/EmployeePaperwork.js +225 -0
  45. package/dist/presentation/RichList/stories/EmployeePeople.d.ts +10 -0
  46. package/dist/presentation/RichList/stories/EmployeePeople.js +170 -0
  47. package/dist/presentation/RichList/stories/Leave.d.ts +21 -0
  48. package/dist/presentation/RichList/stories/Leave.js +332 -0
  49. package/dist/presentation/RichList/stories/Paperwork.d.ts +22 -0
  50. package/dist/presentation/RichList/stories/Paperwork.js +446 -0
  51. package/dist/presentation/RichList/stories/PaperworkApprovals.d.ts +23 -0
  52. package/dist/presentation/RichList/stories/PaperworkApprovals.js +342 -0
  53. package/dist/presentation/RichList/stories/PeopleList.d.ts +19 -0
  54. package/dist/presentation/RichList/stories/PeopleList.js +391 -0
  55. package/dist/presentation/RichList/stories/PeopleTags.d.ts +14 -0
  56. package/dist/presentation/RichList/stories/PeopleTags.js +106 -0
  57. package/dist/presentation/RichList/stories/Positions.d.ts +22 -0
  58. package/dist/presentation/RichList/stories/Positions.js +519 -0
  59. package/dist/presentation/RichList/stories/SavedQuestions.d.ts +13 -0
  60. package/dist/presentation/RichList/stories/SavedQuestions.js +152 -0
  61. package/dist/presentation/RichList/stories/Tables.d.ts +9 -0
  62. package/dist/presentation/RichList/stories/Tables.js +85 -0
  63. package/dist/presentation/RichList/stories/Tasks.d.ts +16 -0
  64. package/dist/presentation/RichList/stories/Tasks.js +340 -0
  65. package/dist/presentation/RichList/stories/shared/bulkActionStubs.d.ts +9 -0
  66. package/dist/presentation/RichList/stories/shared/bulkActionStubs.js +122 -0
  67. package/dist/presentation/RichList/stories/shared.d.ts +8 -0
  68. package/dist/presentation/RichList/stories/shared.js +2 -0
  69. package/dist/presentation/RichList/types.d.ts +342 -0
  70. package/dist/presentation/RichList/types.js +0 -0
  71. package/dist/presentation/Table.d.ts +1 -1
  72. package/dist/presentation/Table.js +2 -2
  73. package/dist/presentation/Table.module.js +0 -10
  74. package/dist/presentation/Table_module.css +1 -61
  75. package/package.json +2 -2
@@ -0,0 +1,507 @@
1
+ "use client";
2
+ import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__ from "react/jsx-runtime";
3
+ import * as __WEBPACK_EXTERNAL_MODULE__floating_ui_react_dom_d5bb3c23__ from "@floating-ui/react-dom";
4
+ import * as __WEBPACK_EXTERNAL_MODULE__react_hook_throttle_d66151d4__ from "@react-hook/throttle";
5
+ import * as __WEBPACK_EXTERNAL_MODULE__tanstack_react_table_777e1b4b__ from "@tanstack/react-table";
6
+ import * as __WEBPACK_EXTERNAL_MODULE_clsx__ from "clsx";
7
+ import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
8
+ import * as __WEBPACK_EXTERNAL_MODULE__controls_Button_js_2f50b64a__ from "../../controls/Button.js";
9
+ import * as __WEBPACK_EXTERNAL_MODULE__controls_FilterModal_js_c5dcd344__ from "../../controls/FilterModal.js";
10
+ import * as __WEBPACK_EXTERNAL_MODULE__utils_customProperties_js_3d9c174d__ from "../../utils/customProperties.js";
11
+ import * as __WEBPACK_EXTERNAL_MODULE__PlainText_js_6d36b5d5__ from "../PlainText.js";
12
+ import * as __WEBPACK_EXTERNAL_MODULE__helpers_js_87289b43__ from "./helpers.js";
13
+ import * as __WEBPACK_EXTERNAL_MODULE__RichList_module_js_320d4975__ from "./RichList.module.js";
14
+ import * as __WEBPACK_EXTERNAL_MODULE__RichListBulkActionBar_js_d46cecae__ from "./RichListBulkActionBar.js";
15
+ import * as __WEBPACK_EXTERNAL_MODULE__RichListDisplayModal_js_6277e838__ from "./RichListDisplayModal.js";
16
+ import * as __WEBPACK_EXTERNAL_MODULE__RichListRow_js_08189b13__ from "./RichListRow.js";
17
+ import * as __WEBPACK_EXTERNAL_MODULE__RichListToolbar_js_747b658d__ from "./RichListToolbar.js";
18
+ const RichList = ({ data, getRowId, leadingSlot, mainSlot, contentSlots = [], contentAlignment = "space-evenly", trailingSlot, href, rowActions, bulkActions = [], secondaryBulkActions = [], rowHeight = "medium", csvFilename, fillContainerHeight = false, compactBreakpoint: compactBreakpointProp, enableSorting = false, emptyState = "No results", id, pathName, localStorageSchema, header })=>{
19
+ const [searchTerm, setSearchTerm] = (0, __WEBPACK_EXTERNAL_MODULE_react__.useState)("");
20
+ const [isFilterModalOpen, setIsFilterModalOpen] = (0, __WEBPACK_EXTERNAL_MODULE_react__.useState)(false);
21
+ const [isDisplayModalOpen, setIsDisplayModalOpen] = (0, __WEBPACK_EXTERNAL_MODULE_react__.useState)(false);
22
+ const lastSelectedRowRef = (0, __WEBPACK_EXTERNAL_MODULE_react__.useRef)(void 0);
23
+ const { refs, x: bulkSelectionModalXCoordinate } = (0, __WEBPACK_EXTERNAL_MODULE__floating_ui_react_dom_d5bb3c23__.useFloating)({
24
+ placement: "bottom",
25
+ whileElementsMounted: __WEBPACK_EXTERNAL_MODULE__floating_ui_react_dom_d5bb3c23__.autoUpdate
26
+ });
27
+ const listScopeRef = (0, __WEBPACK_EXTERNAL_MODULE_react__.useRef)(null);
28
+ const [isCompactContentSlots, setIsCompactContentSlots] = (0, __WEBPACK_EXTERNAL_MODULE_react__.useState)(false);
29
+ const compactBreakpointPx = compactBreakpointProp ?? __WEBPACK_EXTERNAL_MODULE__helpers_js_87289b43__.RICH_LIST_CONTENT_COMPACT_MAX_PX;
30
+ (0, __WEBPACK_EXTERNAL_MODULE_react__.useLayoutEffect)(()=>{
31
+ const el = listScopeRef.current;
32
+ if (!el) return;
33
+ const update = ()=>{
34
+ const w = el.clientWidth;
35
+ setIsCompactContentSlots(w > 0 && w <= compactBreakpointPx);
36
+ };
37
+ update();
38
+ const ro = new ResizeObserver(update);
39
+ ro.observe(el);
40
+ return ()=>ro.disconnect();
41
+ }, [
42
+ compactBreakpointPx
43
+ ]);
44
+ const enableRowSelection = bulkActions.length + secondaryBulkActions.length > 0;
45
+ const normalizedPrimary = (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>(0, __WEBPACK_EXTERNAL_MODULE__helpers_js_87289b43__.normalizeTextField)(mainSlot.primary, "primary"), [
46
+ mainSlot.primary
47
+ ]);
48
+ const normalizedSecondary = (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>mainSlot.secondary ? (0, __WEBPACK_EXTERNAL_MODULE__helpers_js_87289b43__.normalizeTextField)(mainSlot.secondary, "secondary") : null, [
49
+ mainSlot.secondary
50
+ ]);
51
+ const normalizedLeadingSlots = (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>{
52
+ const arr = Array.isArray(leadingSlot) ? leadingSlot : void 0 !== leadingSlot ? [
53
+ leadingSlot
54
+ ] : [];
55
+ return arr.map((slot, index)=>(0, __WEBPACK_EXTERNAL_MODULE__helpers_js_87289b43__.normalizeSlot)(slot, "leading", index));
56
+ }, [
57
+ leadingSlot
58
+ ]);
59
+ const normalizedContentSlots = (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>contentSlots.map((slot, index)=>(0, __WEBPACK_EXTERNAL_MODULE__helpers_js_87289b43__.normalizeSlot)(slot, "content", index)), [
60
+ contentSlots
61
+ ]);
62
+ const normalizedTrailingSlots = (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>{
63
+ const arr = Array.isArray(trailingSlot) ? trailingSlot : void 0 !== trailingSlot ? [
64
+ trailingSlot
65
+ ] : [];
66
+ return arr.map((slot, index)=>(0, __WEBPACK_EXTERNAL_MODULE__helpers_js_87289b43__.normalizeSlot)(slot, "trailing", index));
67
+ }, [
68
+ trailingSlot
69
+ ]);
70
+ const rowMainHidesContentSlotColumns = isCompactContentSlots && !normalizedContentSlots.some((s)=>(0, __WEBPACK_EXTERNAL_MODULE__helpers_js_87289b43__.isVisibleAtBreakpoint)(s.layoutVisibility, true));
71
+ const allEntries = (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>[
72
+ ...normalizedLeadingSlots,
73
+ normalizedPrimary,
74
+ normalizedSecondary,
75
+ ...normalizedContentSlots,
76
+ ...normalizedTrailingSlots
77
+ ], [
78
+ normalizedLeadingSlots,
79
+ normalizedPrimary,
80
+ normalizedSecondary,
81
+ normalizedContentSlots,
82
+ normalizedTrailingSlots
83
+ ]);
84
+ const entriesWithFilter = (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>allEntries.filter((e)=>null !== e && void 0 !== e.filter && e.filter.options.length > 0), [
85
+ allEntries
86
+ ]);
87
+ const entriesWithGlobalFilter = (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>allEntries.filter((e)=>null !== e && e.globalFiltering && void 0 !== e.value), [
88
+ allEntries
89
+ ]);
90
+ const entriesWithCsvExport = (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>allEntries.filter((e)=>null !== e && e.csvExport), [
91
+ allEntries
92
+ ]);
93
+ const csvExportColumns = (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>entriesWithCsvExport.filter((e)=>void 0 !== e.value).map((entry)=>({
94
+ id: entry.id,
95
+ header: entry.label ?? entry.id
96
+ })), [
97
+ entriesWithCsvExport
98
+ ]);
99
+ const toggleableContentSlots = (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>allEntries.filter((e)=>(0, __WEBPACK_EXTERNAL_MODULE__helpers_js_87289b43__.isToggleableContentColumn)(e)), [
100
+ allEntries
101
+ ]);
102
+ const sortableEntries = (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>allEntries.filter((e)=>null !== e && void 0 !== e.value), [
103
+ allEntries
104
+ ]);
105
+ const columnDefs = (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>{
106
+ const columnHelper = (0, __WEBPACK_EXTERNAL_MODULE__tanstack_react_table_777e1b4b__.createColumnHelper)();
107
+ const columns = allEntries.filter((e)=>null !== e).map((entry)=>{
108
+ if (void 0 === entry.value) return columnHelper.display({
109
+ id: entry.id,
110
+ cell: ({ row })=>entry.render(row.original),
111
+ enableHiding: (0, __WEBPACK_EXTERNAL_MODULE__helpers_js_87289b43__.isColumnWithVisibilityState)(entry),
112
+ enableGlobalFilter: false,
113
+ enableColumnFilter: void 0 !== entry.filter
114
+ });
115
+ const value = entry.value;
116
+ return columnHelper.accessor((row)=>value(row), {
117
+ id: entry.id,
118
+ cell: ({ row })=>entry.render(row.original),
119
+ enableHiding: (0, __WEBPACK_EXTERNAL_MODULE__helpers_js_87289b43__.isColumnWithVisibilityState)(entry),
120
+ enableGlobalFilter: entry.globalFiltering,
121
+ ...enableSorting ? {
122
+ enableSorting: true,
123
+ sortUndefined: 1
124
+ } : {
125
+ enableSorting: false
126
+ },
127
+ filterFn: entry.filter ? (row, _columnId, filterValue)=>{
128
+ const filter = entry.filter;
129
+ if (!filter) return true;
130
+ if (filter.isMulti && Array.isArray(filterValue)) {
131
+ if (0 === filterValue.length) return true;
132
+ return filterValue.some((optionId)=>{
133
+ const option = filter.options.find((opt)=>opt.id === optionId);
134
+ return option ? option.predicate(row.original) : false;
135
+ });
136
+ }
137
+ if (!filter.isMulti && "string" == typeof filterValue) {
138
+ const option = filter.options.find((opt)=>opt.id === filterValue);
139
+ return option?.predicate?.(row.original) ?? true;
140
+ }
141
+ return true;
142
+ } : void 0
143
+ });
144
+ });
145
+ const selectColumn = enableRowSelection ? columnHelper.display({
146
+ id: __WEBPACK_EXTERNAL_MODULE__helpers_js_87289b43__.SELECT_COLUMN_ID,
147
+ enableHiding: false
148
+ }) : void 0;
149
+ return selectColumn ? [
150
+ selectColumn,
151
+ ...columns
152
+ ] : columns;
153
+ }, [
154
+ allEntries,
155
+ enableRowSelection,
156
+ enableSorting
157
+ ]);
158
+ const columnFiltersInitialState = (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>entriesWithFilter.map((entry)=>{
159
+ const filter = entry.filter;
160
+ if (filter.isMulti) return {
161
+ id: entry.id,
162
+ value: []
163
+ };
164
+ return {
165
+ id: entry.id,
166
+ value: filter.options[0].id
167
+ };
168
+ }), [
169
+ entriesWithFilter
170
+ ]);
171
+ const storageKey = (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>pathName && id ? `${pathName}#${id}_richList` : null, [
172
+ pathName,
173
+ id
174
+ ]);
175
+ const localStorageData = "undefined" != typeof window && storageKey ? window.localStorage.getItem(storageKey) : null;
176
+ let parsedLocalStorage = {};
177
+ if (localStorageData && localStorageSchema) try {
178
+ parsedLocalStorage = JSON.parse(localStorageData);
179
+ localStorageSchema.parse(parsedLocalStorage);
180
+ } catch (error) {
181
+ console.error("Error parsing localStorage data:", error);
182
+ parsedLocalStorage = {};
183
+ }
184
+ const permanentlyHiddenColumnIds = (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>new Set(allEntries.filter((e)=>null !== e && "canToggleVisibility" in e && e.hiddenByDefault && !e.canToggleVisibility).map((e)=>e.id)), [
185
+ allEntries
186
+ ]);
187
+ const columnVisibilityDefaultForHiddenByDefault = (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>Object.fromEntries(allEntries.filter((e)=>null !== e && "canToggleVisibility" in e && e.hiddenByDefault).map((e)=>[
188
+ e.id,
189
+ false
190
+ ])), [
191
+ allEntries
192
+ ]);
193
+ const initialColumnVisibility = (()=>{
194
+ const base = columnVisibilityDefaultForHiddenByDefault;
195
+ const saved = parsedLocalStorage.columnVisibility;
196
+ if (!saved) return base;
197
+ const next = {
198
+ ...base,
199
+ ...saved
200
+ };
201
+ for (const id of permanentlyHiddenColumnIds)next[id] = false;
202
+ return next;
203
+ })();
204
+ const isRowSelectable = (0, __WEBPACK_EXTERNAL_MODULE_react__.useCallback)((row)=>{
205
+ const all = [
206
+ ...bulkActions,
207
+ ...secondaryBulkActions
208
+ ];
209
+ return all.some((action)=>!action.predicate || action.predicate(row.original));
210
+ }, [
211
+ bulkActions,
212
+ secondaryBulkActions
213
+ ]);
214
+ const table = (0, __WEBPACK_EXTERNAL_MODULE__tanstack_react_table_777e1b4b__.useReactTable)({
215
+ data,
216
+ columns: columnDefs,
217
+ getRowId,
218
+ getCoreRowModel: (0, __WEBPACK_EXTERNAL_MODULE__tanstack_react_table_777e1b4b__.getCoreRowModel)(),
219
+ getFilteredRowModel: (0, __WEBPACK_EXTERNAL_MODULE__tanstack_react_table_777e1b4b__.getFilteredRowModel)(),
220
+ ...enableSorting ? {
221
+ getSortedRowModel: (0, __WEBPACK_EXTERNAL_MODULE__tanstack_react_table_777e1b4b__.getSortedRowModel)()
222
+ } : {},
223
+ getColumnCanGlobalFilter: ()=>true,
224
+ enableRowSelection: enableRowSelection ? isRowSelectable : false,
225
+ initialState: {
226
+ columnFilters: parsedLocalStorage.columnFilters ?? columnFiltersInitialState,
227
+ columnVisibility: initialColumnVisibility,
228
+ globalFilter: "",
229
+ sorting: parsedLocalStorage.sorting ?? []
230
+ },
231
+ defaultColumn: {
232
+ enableColumnFilter: false,
233
+ enableGlobalFilter: false,
234
+ enableSorting: false
235
+ }
236
+ });
237
+ (0, __WEBPACK_EXTERNAL_MODULE_react__.useLayoutEffect)(()=>{
238
+ if (0 === permanentlyHiddenColumnIds.size) return;
239
+ let anyVisible = false;
240
+ const next = {};
241
+ for (const id of permanentlyHiddenColumnIds)if (table.getColumn(id)?.getIsVisible()) {
242
+ anyVisible = true;
243
+ next[id] = false;
244
+ }
245
+ if (anyVisible) table.setColumnVisibility((prev)=>({
246
+ ...prev,
247
+ ...next
248
+ }));
249
+ }, [
250
+ permanentlyHiddenColumnIds,
251
+ table
252
+ ]);
253
+ const tableState = table.getState();
254
+ const rows = table.getRowModel().rows;
255
+ const filteredSelectedRows = table.getFilteredSelectedRowModel();
256
+ const throttledSetGlobalFilter = (0, __WEBPACK_EXTERNAL_MODULE__react_hook_throttle_d66151d4__.useThrottleCallback)((value)=>table.setGlobalFilter(value), 4);
257
+ const activeFilterCount = (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>{
258
+ const currentFilters = tableState.columnFilters;
259
+ return columnFiltersInitialState.filter((initialFilter)=>{
260
+ const currentFilter = currentFilters.find((f)=>f.id === initialFilter.id);
261
+ const currentValue = currentFilter?.value;
262
+ const initialValue = initialFilter.value;
263
+ if (Array.isArray(initialValue) && Array.isArray(currentValue)) return currentValue.length !== initialValue.length || initialValue.some((v, i)=>v !== currentValue[i]);
264
+ return currentValue !== initialValue;
265
+ }).length;
266
+ }, [
267
+ tableState.columnFilters,
268
+ columnFiltersInitialState
269
+ ]);
270
+ const showSearchReset = activeFilterCount > 0 || "" !== tableState.globalFilter;
271
+ (0, __WEBPACK_EXTERNAL_MODULE_react__.useEffect)(()=>{
272
+ if (storageKey) window.localStorage.setItem(storageKey, JSON.stringify({
273
+ columnFilters: tableState.columnFilters,
274
+ columnVisibility: tableState.columnVisibility,
275
+ sorting: tableState.sorting
276
+ }));
277
+ }, [
278
+ tableState.columnFilters,
279
+ tableState.columnVisibility,
280
+ tableState.sorting,
281
+ storageKey
282
+ ]);
283
+ const validPrimaryBulkActions = bulkActions.filter((bulkAction)=>filteredSelectedRows.rows.some((row)=>bulkAction.predicate ? bulkAction.predicate(row.original) : true));
284
+ const validSecondaryBulkActions = secondaryBulkActions.filter((bulkAction)=>filteredSelectedRows.rows.some((row)=>bulkAction.predicate ? bulkAction.predicate(row.original) : true));
285
+ const shouldShowCsvExport = csvExportColumns.length > 0 && Boolean(csvFilename);
286
+ const getBulkActionRows = (bulkAction)=>filteredSelectedRows.flatRows.filter((row)=>bulkAction.predicate ? bulkAction.predicate(row.original) : true).map((row)=>row.original);
287
+ const primaryBulkActionRowsMap = new Map(validPrimaryBulkActions.map((bulkAction)=>[
288
+ bulkAction.key,
289
+ getBulkActionRows(bulkAction)
290
+ ]));
291
+ const secondaryBulkActionRowsMap = new Map(validSecondaryBulkActions.map((bulkAction)=>[
292
+ bulkAction.key,
293
+ getBulkActionRows(bulkAction)
294
+ ]));
295
+ const allBulkActionRowCounts = [
296
+ ...Array.from(primaryBulkActionRowsMap.values()).map((xs)=>xs.length),
297
+ ...Array.from(secondaryBulkActionRowsMap.values()).map((xs)=>xs.length)
298
+ ];
299
+ const bulkActionRowCountsDiffer = new Set(allBulkActionRowCounts).size > 1;
300
+ const hasMultipleActions = allBulkActionRowCounts.length > 1;
301
+ const allRowsCanDoAllActions = hasMultipleActions && allBulkActionRowCounts.every((count)=>count === filteredSelectedRows.rows.length);
302
+ const showBulkActionCounts = bulkActionRowCountsDiffer || hasMultipleActions && !allRowsCanDoAllActions;
303
+ const resolvedRowHeightPx = "number" == typeof rowHeight ? rowHeight : __WEBPACK_EXTERNAL_MODULE__helpers_js_87289b43__.ROW_HEIGHT_PRESETS[rowHeight];
304
+ const listRootStyle = (0, __WEBPACK_EXTERNAL_MODULE__utils_customProperties_js_3d9c174d__["default"])({
305
+ "--row-height": `${resolvedRowHeightPx}px`,
306
+ "--richlist-padding-inline": `${(0, __WEBPACK_EXTERNAL_MODULE__helpers_js_87289b43__.richListInlinePaddingPx)(rowHeight)}px`
307
+ });
308
+ const showDisplayForColumnVisibility = !isCompactContentSlots && toggleableContentSlots.length > 0;
309
+ const showDisplayButton = enableSorting && sortableEntries.length > 0 || showDisplayForColumnVisibility;
310
+ const defaultDisplayColumnVisibility = (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>Object.fromEntries(toggleableContentSlots.map((entry)=>[
311
+ entry.id,
312
+ !("hiddenByDefault" in entry && entry.hiddenByDefault)
313
+ ])), [
314
+ toggleableContentSlots
315
+ ]);
316
+ const sortableColumnsForModal = (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>sortableEntries.map((entry)=>({
317
+ id: entry.id,
318
+ label: entry.label ?? entry.id
319
+ })), [
320
+ sortableEntries
321
+ ]);
322
+ const displayColumnsForModal = toggleableContentSlots.map((entry)=>({
323
+ id: entry.id,
324
+ label: entry.label ?? entry.id,
325
+ visible: table.getColumn(entry.id)?.getIsVisible() ?? true,
326
+ defaultVisible: !("hiddenByDefault" in entry && entry.hiddenByDefault)
327
+ }));
328
+ const displayColumnsForDisplayModal = isCompactContentSlots ? [] : displayColumnsForModal;
329
+ const displayActiveCount = (0, __WEBPACK_EXTERNAL_MODULE__RichListDisplayModal_js_6277e838__.getDisplayFormActiveExpanderCount)(enableSorting && sortableEntries.length > 0, tableState.sorting, displayColumnsForDisplayModal);
330
+ const hasToolbar = enableRowSelection || entriesWithGlobalFilter.length > 0 || entriesWithFilter.length > 0 || showDisplayButton || shouldShowCsvExport;
331
+ const actionsByRowId = (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>{
332
+ const map = new Map();
333
+ if (!rowActions) return map;
334
+ for (const row of data){
335
+ const resolved = rowActions(row).filter((a)=>null !== a).filter((a)=>!a.predicate || a.predicate(row));
336
+ map.set(getRowId(row), resolved);
337
+ }
338
+ return map;
339
+ }, [
340
+ data,
341
+ rowActions,
342
+ getRowId
343
+ ]);
344
+ const maxAlwaysVisibleActions = (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>{
345
+ let max = 0;
346
+ for (const actions of actionsByRowId.values()){
347
+ const count = actions.filter((a)=>a.alwaysVisible).length;
348
+ if (count > max) max = count;
349
+ }
350
+ return max;
351
+ }, [
352
+ actionsByRowId
353
+ ]);
354
+ const anyRowHasOverflowAction = (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>{
355
+ for (const actions of actionsByRowId.values())if (actions.some((a)=>!a.alwaysVisible)) return true;
356
+ return false;
357
+ }, [
358
+ actionsByRowId
359
+ ]);
360
+ const filterableColumnsForModal = (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>entriesWithFilter.map((entry)=>({
361
+ id: entry.id,
362
+ filter: entry.filter
363
+ })), [
364
+ entriesWithFilter
365
+ ]);
366
+ const showBulkBar = validPrimaryBulkActions.length > 0 || validSecondaryBulkActions.length > 0;
367
+ return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)(__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.Fragment, {
368
+ children: [
369
+ /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("div", {
370
+ ref: refs.setReference,
371
+ className: (0, __WEBPACK_EXTERNAL_MODULE_clsx__["default"])(__WEBPACK_EXTERNAL_MODULE__RichList_module_js_320d4975__["default"].root, fillContainerHeight && __WEBPACK_EXTERNAL_MODULE__RichList_module_js_320d4975__["default"].rootFillHeight),
372
+ style: listRootStyle,
373
+ children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)("div", {
374
+ ref: listScopeRef,
375
+ className: __WEBPACK_EXTERNAL_MODULE__RichList_module_js_320d4975__["default"].richListQueryScope,
376
+ "data-richlist-compact": isCompactContentSlots ? "" : void 0,
377
+ children: [
378
+ /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)("div", {
379
+ className: __WEBPACK_EXTERNAL_MODULE__RichList_module_js_320d4975__["default"].richListHead,
380
+ children: [
381
+ showBulkBar ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__RichListBulkActionBar_js_d46cecae__["default"], {
382
+ table: table,
383
+ floatingRef: refs.setFloating,
384
+ leftCoordinate: bulkSelectionModalXCoordinate,
385
+ selectedCount: filteredSelectedRows.rows.length,
386
+ primaryBulkActions: validPrimaryBulkActions,
387
+ secondaryBulkActions: validSecondaryBulkActions,
388
+ primaryBulkActionRowsMap: primaryBulkActionRowsMap,
389
+ secondaryBulkActionRowsMap: secondaryBulkActionRowsMap,
390
+ showBulkActionCounts: showBulkActionCounts,
391
+ csvExportColumns: csvExportColumns,
392
+ csvFilename: csvFilename
393
+ }) : null,
394
+ header ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("div", {
395
+ className: __WEBPACK_EXTERNAL_MODULE__RichList_module_js_320d4975__["default"].listHeader,
396
+ children: header()
397
+ }) : null,
398
+ hasToolbar ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__RichListToolbar_js_747b658d__["default"], {
399
+ hasGlobalSearch: entriesWithGlobalFilter.length > 0,
400
+ searchTerm: searchTerm,
401
+ onSearchTermChange: (value)=>{
402
+ setSearchTerm(value);
403
+ throttledSetGlobalFilter(value);
404
+ },
405
+ hasFilters: entriesWithFilter.length > 0,
406
+ activeFilterCount: activeFilterCount,
407
+ onOpenFilterModal: ()=>setIsFilterModalOpen(true),
408
+ showDisplay: showDisplayButton,
409
+ onOpenDisplayModal: ()=>setIsDisplayModalOpen(true),
410
+ displayActiveCount: displayActiveCount,
411
+ showCsvExport: shouldShowCsvExport && Boolean(csvFilename),
412
+ onDownloadCsv: ()=>(0, __WEBPACK_EXTERNAL_MODULE__helpers_js_87289b43__.handleDownloadCsv)(csvFilename, csvExportColumns, table.getRowModel().rows),
413
+ showSelectAll: enableRowSelection,
414
+ selectAllAllSelected: table.getIsAllRowsSelected(),
415
+ selectAllSomeSelected: table.getIsSomeRowsSelected(),
416
+ selectAllDisabled: 0 === table.getRowModel().rows.filter((r)=>r.getCanSelect()).length,
417
+ onSelectAllChange: ()=>{
418
+ const all = table.getIsAllRowsSelected();
419
+ const some = table.getIsSomeRowsSelected();
420
+ table.toggleAllRowsSelected(!(all || some));
421
+ }
422
+ }) : null,
423
+ showSearchReset ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)("div", {
424
+ className: __WEBPACK_EXTERNAL_MODULE__RichList_module_js_320d4975__["default"].toolbarStatus,
425
+ children: [
426
+ /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)(__WEBPACK_EXTERNAL_MODULE__PlainText_js_6d36b5d5__["default"], {
427
+ font: "small",
428
+ tone: "muted",
429
+ children: [
430
+ "Showing ",
431
+ table.getFilteredRowModel().flatRows.length,
432
+ " of",
433
+ " ",
434
+ table.getPreFilteredRowModel().flatRows.length
435
+ ]
436
+ }),
437
+ /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__controls_Button_js_2f50b64a__["default"], {
438
+ onClick: ()=>{
439
+ table.setColumnFilters(columnFiltersInitialState);
440
+ table.resetGlobalFilter();
441
+ setSearchTerm("");
442
+ },
443
+ type: "secondary",
444
+ size: "small",
445
+ children: "Reset"
446
+ })
447
+ ]
448
+ }) : null
449
+ ]
450
+ }),
451
+ rows.length > 0 ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("ul", {
452
+ className: __WEBPACK_EXTERNAL_MODULE__RichList_module_js_320d4975__["default"].list,
453
+ children: rows.map((row)=>/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__RichListRow_js_08189b13__["default"], {
454
+ row: row,
455
+ table: table,
456
+ enableRowSelection: enableRowSelection,
457
+ href: href,
458
+ normalizedLeadingSlots: normalizedLeadingSlots,
459
+ normalizedPrimary: normalizedPrimary,
460
+ normalizedSecondary: normalizedSecondary,
461
+ mainSlotMaxWidthPx: mainSlot.size,
462
+ normalizedContentSlots: normalizedContentSlots,
463
+ normalizedTrailingSlots: normalizedTrailingSlots,
464
+ isCompactContentSlots: isCompactContentSlots,
465
+ rowMainHidesContentSlotColumns: rowMainHidesContentSlotColumns,
466
+ contentSlotsJustifyContent: contentAlignment,
467
+ actionsForRow: actionsByRowId.get(row.id) ?? [],
468
+ maxAlwaysVisibleActions: maxAlwaysVisibleActions,
469
+ anyRowHasOverflowAction: anyRowHasOverflowAction,
470
+ lastSelectedRowRef: lastSelectedRowRef
471
+ }, row.id))
472
+ }) : /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("div", {
473
+ className: __WEBPACK_EXTERNAL_MODULE__RichList_module_js_320d4975__["default"].emptyState,
474
+ children: emptyState
475
+ })
476
+ ]
477
+ })
478
+ }),
479
+ isFilterModalOpen && /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__controls_FilterModal_js_c5dcd344__["default"], {
480
+ onClose: ()=>setIsFilterModalOpen(false),
481
+ filterableColumns: filterableColumnsForModal,
482
+ currentFilters: tableState.columnFilters,
483
+ onFiltersChange: (filters)=>table.setColumnFilters(filters)
484
+ }),
485
+ isDisplayModalOpen && /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__RichListDisplayModal_js_6277e838__["default"], {
486
+ onClose: ()=>setIsDisplayModalOpen(false),
487
+ sortableColumns: enableSorting ? sortableColumnsForModal : [],
488
+ currentSorting: tableState.sorting,
489
+ onApplySorting: (sorting)=>table.setSorting(sorting),
490
+ displayColumns: displayColumnsForDisplayModal,
491
+ onApplyColumnVisibility: (vis)=>{
492
+ table.setColumnVisibility((prev)=>{
493
+ const next = {
494
+ ...prev
495
+ };
496
+ for (const [id, visible] of Object.entries(vis))next[id] = visible;
497
+ return next;
498
+ });
499
+ },
500
+ defaultSorting: [],
501
+ defaultColumnVisibility: defaultDisplayColumnVisibility
502
+ })
503
+ ]
504
+ });
505
+ };
506
+ const RichList_rslib_entry_ = RichList;
507
+ export { RichList_rslib_entry_ as default };
@@ -0,0 +1,12 @@
1
+ import "./RichList_module.css";
2
+ const RichList_module_rslib_entry_ = {
3
+ root: "root-S5afi_",
4
+ rootFillHeight: "rootFillHeight-F5N1tt",
5
+ richListQueryScope: "richListQueryScope-_rCOEN",
6
+ richListHead: "richListHead-YX3P21",
7
+ listHeader: "listHeader-LmUwi0",
8
+ toolbarStatus: "toolbarStatus-OBimHB",
9
+ list: "list-j1kaiA",
10
+ emptyState: "emptyState-xAYoQA"
11
+ };
12
+ export { RichList_module_rslib_entry_ as default };
@@ -0,0 +1,24 @@
1
+ import type { Meta, StoryObj } from "@storybook/nextjs-vite";
2
+ import RichList from "./RichList";
3
+ declare const meta: Meta<typeof RichList>;
4
+ export default meta;
5
+ type Story = StoryObj<typeof RichList>;
6
+ export declare const PeopleDirectory: Story;
7
+ /**
8
+ * Both bulk actions and href are used.
9
+ */
10
+ export declare const EmployeePaperwork: Story;
11
+ export declare const Paperwork: Story;
12
+ export declare const PaperworkApprovals: Story;
13
+ export declare const Leave: Story;
14
+ export declare const Tasks: Story;
15
+ export declare const EmployeeCompliance: Story;
16
+ export declare const ComplianceGroups: Story;
17
+ export declare const CustomFields: Story;
18
+ export declare const SavedQuestions: Story;
19
+ export declare const PeopleTags: Story;
20
+ export declare const Tables: Story;
21
+ export declare const Positions: Story;
22
+ /** Mobile-friendly list of people with actions. */
23
+ export declare const EmployeePeople: Story;
24
+ export declare const EmptyList: Story;