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