@trackunit/react-table 1.10.17 → 1.10.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.cjs.js CHANGED
@@ -256,10 +256,107 @@ const ActionContainerAndOverflow = ({ actions, dropdownActions, moreActions, "da
256
256
  };
257
257
 
258
258
  /**
259
- * The Action Sheet appears when one or more items are selected from a table.
260
- * It primarily accommodates 1-3 main actions that represent the most crucial and frequently accessed functions on the specific page.
261
- * If the page supports more than 3 actions, the ones that are performed less often can be placed in a contextual menu, represented by the ‘three dots’ icon.
259
+ * The `<ActionSheet>` component appears as a floating bar when one or more items
260
+ * are selected from a table, providing bulk actions for the selection.
262
261
  *
262
+ * It primarily accommodates 1-3 main actions that represent the most crucial and
263
+ * frequently accessed functions on the specific page. If the page supports more
264
+ * than 3 actions, the ones that are performed less often can be placed in a
265
+ * contextual menu, represented by the 'three dots' icon via `moreActions`.
266
+ *
267
+ * ### When to use
268
+ * - Provide bulk operations when users select multiple table rows
269
+ * - For batch actions like delete, export, assign, or status changes
270
+ * - When actions need to operate on a collection of selected items
271
+ *
272
+ * ### When not to use
273
+ * - For single row actions - use `RowActions` instead
274
+ * - For page-level actions not tied to selection - use regular buttons
275
+ * - When the table doesn't support multi-selection
276
+ *
277
+ * @example Basic usage with table selection
278
+ * ```tsx
279
+ * import { Table, ActionSheet, useTableSelection } from "@trackunit/react-table";
280
+ *
281
+ * const MyTable = ({ data }) => {
282
+ * const { selections, resetSelection, rowSelection, onRowSelectionChange } =
283
+ * useTableSelection(data);
284
+ *
285
+ * return (
286
+ * <>
287
+ * <Table
288
+ * data={data}
289
+ * columns={columns}
290
+ * state={{ rowSelection }}
291
+ * onRowSelectionChange={onRowSelectionChange}
292
+ * enableRowSelection
293
+ * />
294
+ * {selections.length > 0 && (
295
+ * <ActionSheet
296
+ * selections={selections}
297
+ * resetSelection={resetSelection}
298
+ * actions={[
299
+ * {
300
+ * label: "Export",
301
+ * iconName: "ArrowDownTray",
302
+ * onClick: () => handleExport(selections),
303
+ * },
304
+ * {
305
+ * label: "Delete",
306
+ * iconName: "Trash",
307
+ * variant: "danger",
308
+ * onClick: () => handleDelete(selections),
309
+ * },
310
+ * ]}
311
+ * />
312
+ * )}
313
+ * </>
314
+ * );
315
+ * };
316
+ * ```
317
+ * @example With overflow actions
318
+ * ```tsx
319
+ * import { ActionSheet } from "@trackunit/react-table";
320
+ *
321
+ * <ActionSheet
322
+ * selections={selectedIds}
323
+ * resetSelection={() => setSelectedIds([])}
324
+ * actions={[
325
+ * { label: "Export", iconName: "ArrowDownTray", onClick: handleExport },
326
+ * { label: "Assign", iconName: "UserPlus", onClick: handleAssign },
327
+ * ]}
328
+ * moreActions={[
329
+ * { label: "Archive", iconName: "ArchiveBox", onClick: handleArchive },
330
+ * { label: "Move", iconName: "FolderArrowDown", onClick: handleMove },
331
+ * { label: "Delete", iconName: "Trash", variant: "danger", onClick: handleDelete },
332
+ * ]}
333
+ * />
334
+ * ```
335
+ * @example With dropdown actions
336
+ * ```tsx
337
+ * import { ActionSheet } from "@trackunit/react-table";
338
+ * import { MenuList, MenuItem } from "@trackunit/react-components";
339
+ *
340
+ * <ActionSheet
341
+ * selections={selectedIds}
342
+ * resetSelection={resetSelection}
343
+ * actions={[
344
+ * { label: "Export", iconName: "ArrowDownTray", onClick: handleExport },
345
+ * ]}
346
+ * dropdownActions={[
347
+ * {
348
+ * label: "Change Status",
349
+ * iconName: "Flag",
350
+ * dropdownContent: (close) => (
351
+ * <MenuList>
352
+ * <MenuItem label="Active" onClick={() => { setStatus("active"); close(); }} />
353
+ * <MenuItem label="Inactive" onClick={() => { setStatus("inactive"); close(); }} />
354
+ * </MenuList>
355
+ * ),
356
+ * },
357
+ * ]}
358
+ * />
359
+ * ```
263
360
  * @param {ActionSheetProps} props - The props for the ActionSheet component
264
361
  * @returns {ReactElement} ActionSheet component
265
362
  */
package/index.esm.js CHANGED
@@ -9,7 +9,7 @@ import { cvaLabel, ToggleSwitch, Search, RadioGroup, RadioItem, Checkbox } from
9
9
  import update from 'immutability-helper';
10
10
  import { useDrop, useDrag, DndProvider } from 'react-dnd';
11
11
  import { HTML5Backend } from 'react-dnd-html5-backend';
12
- import { flexRender, createColumnHelper, useReactTable, getSortedRowModel, getCoreRowModel } from '@tanstack/react-table';
12
+ import { flexRender, createColumnHelper, useReactTable, getCoreRowModel, getSortedRowModel } from '@tanstack/react-table';
13
13
  export { createColumnHelper } from '@tanstack/react-table';
14
14
  import { TableRoot, Thead, Tr, Th, ResizeHandle, Tbody, Td } from '@trackunit/react-table-base-components';
15
15
  import { twMerge } from 'tailwind-merge';
@@ -255,10 +255,107 @@ const ActionContainerAndOverflow = ({ actions, dropdownActions, moreActions, "da
255
255
  };
256
256
 
257
257
  /**
258
- * The Action Sheet appears when one or more items are selected from a table.
259
- * It primarily accommodates 1-3 main actions that represent the most crucial and frequently accessed functions on the specific page.
260
- * If the page supports more than 3 actions, the ones that are performed less often can be placed in a contextual menu, represented by the ‘three dots’ icon.
258
+ * The `<ActionSheet>` component appears as a floating bar when one or more items
259
+ * are selected from a table, providing bulk actions for the selection.
261
260
  *
261
+ * It primarily accommodates 1-3 main actions that represent the most crucial and
262
+ * frequently accessed functions on the specific page. If the page supports more
263
+ * than 3 actions, the ones that are performed less often can be placed in a
264
+ * contextual menu, represented by the 'three dots' icon via `moreActions`.
265
+ *
266
+ * ### When to use
267
+ * - Provide bulk operations when users select multiple table rows
268
+ * - For batch actions like delete, export, assign, or status changes
269
+ * - When actions need to operate on a collection of selected items
270
+ *
271
+ * ### When not to use
272
+ * - For single row actions - use `RowActions` instead
273
+ * - For page-level actions not tied to selection - use regular buttons
274
+ * - When the table doesn't support multi-selection
275
+ *
276
+ * @example Basic usage with table selection
277
+ * ```tsx
278
+ * import { Table, ActionSheet, useTableSelection } from "@trackunit/react-table";
279
+ *
280
+ * const MyTable = ({ data }) => {
281
+ * const { selections, resetSelection, rowSelection, onRowSelectionChange } =
282
+ * useTableSelection(data);
283
+ *
284
+ * return (
285
+ * <>
286
+ * <Table
287
+ * data={data}
288
+ * columns={columns}
289
+ * state={{ rowSelection }}
290
+ * onRowSelectionChange={onRowSelectionChange}
291
+ * enableRowSelection
292
+ * />
293
+ * {selections.length > 0 && (
294
+ * <ActionSheet
295
+ * selections={selections}
296
+ * resetSelection={resetSelection}
297
+ * actions={[
298
+ * {
299
+ * label: "Export",
300
+ * iconName: "ArrowDownTray",
301
+ * onClick: () => handleExport(selections),
302
+ * },
303
+ * {
304
+ * label: "Delete",
305
+ * iconName: "Trash",
306
+ * variant: "danger",
307
+ * onClick: () => handleDelete(selections),
308
+ * },
309
+ * ]}
310
+ * />
311
+ * )}
312
+ * </>
313
+ * );
314
+ * };
315
+ * ```
316
+ * @example With overflow actions
317
+ * ```tsx
318
+ * import { ActionSheet } from "@trackunit/react-table";
319
+ *
320
+ * <ActionSheet
321
+ * selections={selectedIds}
322
+ * resetSelection={() => setSelectedIds([])}
323
+ * actions={[
324
+ * { label: "Export", iconName: "ArrowDownTray", onClick: handleExport },
325
+ * { label: "Assign", iconName: "UserPlus", onClick: handleAssign },
326
+ * ]}
327
+ * moreActions={[
328
+ * { label: "Archive", iconName: "ArchiveBox", onClick: handleArchive },
329
+ * { label: "Move", iconName: "FolderArrowDown", onClick: handleMove },
330
+ * { label: "Delete", iconName: "Trash", variant: "danger", onClick: handleDelete },
331
+ * ]}
332
+ * />
333
+ * ```
334
+ * @example With dropdown actions
335
+ * ```tsx
336
+ * import { ActionSheet } from "@trackunit/react-table";
337
+ * import { MenuList, MenuItem } from "@trackunit/react-components";
338
+ *
339
+ * <ActionSheet
340
+ * selections={selectedIds}
341
+ * resetSelection={resetSelection}
342
+ * actions={[
343
+ * { label: "Export", iconName: "ArrowDownTray", onClick: handleExport },
344
+ * ]}
345
+ * dropdownActions={[
346
+ * {
347
+ * label: "Change Status",
348
+ * iconName: "Flag",
349
+ * dropdownContent: (close) => (
350
+ * <MenuList>
351
+ * <MenuItem label="Active" onClick={() => { setStatus("active"); close(); }} />
352
+ * <MenuItem label="Inactive" onClick={() => { setStatus("inactive"); close(); }} />
353
+ * </MenuList>
354
+ * ),
355
+ * },
356
+ * ]}
357
+ * />
358
+ * ```
262
359
  * @param {ActionSheetProps} props - The props for the ActionSheet component
263
360
  * @returns {ReactElement} ActionSheet component
264
361
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/react-table",
3
- "version": "1.10.17",
3
+ "version": "1.10.19",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "engines": {
@@ -14,14 +14,14 @@
14
14
  "react-dnd-html5-backend": "16.0.1",
15
15
  "@tanstack/react-router": "1.114.29",
16
16
  "tailwind-merge": "^2.0.0",
17
- "@trackunit/react-components": "1.14.17",
18
- "@trackunit/shared-utils": "1.12.14",
19
- "@trackunit/css-class-variance-utilities": "1.10.14",
20
- "@trackunit/ui-icons": "1.10.14",
21
- "@trackunit/react-table-base-components": "1.10.17",
22
- "@trackunit/react-form-components": "1.11.17",
23
- "@trackunit/i18n-library-translation": "1.10.14",
24
- "@trackunit/iris-app-runtime-core-api": "1.10.14",
17
+ "@trackunit/react-components": "1.14.19",
18
+ "@trackunit/shared-utils": "1.12.16",
19
+ "@trackunit/css-class-variance-utilities": "1.10.16",
20
+ "@trackunit/ui-icons": "1.10.16",
21
+ "@trackunit/react-table-base-components": "1.10.19",
22
+ "@trackunit/react-form-components": "1.11.19",
23
+ "@trackunit/i18n-library-translation": "1.10.16",
24
+ "@trackunit/iris-app-runtime-core-api": "1.10.16",
25
25
  "graphql": "^16.10.0"
26
26
  },
27
27
  "module": "./index.esm.js",
@@ -23,10 +23,107 @@ export interface ActionSheetProps extends CommonProps {
23
23
  resetSelection: () => void;
24
24
  }
25
25
  /**
26
- * The Action Sheet appears when one or more items are selected from a table.
27
- * It primarily accommodates 1-3 main actions that represent the most crucial and frequently accessed functions on the specific page.
28
- * If the page supports more than 3 actions, the ones that are performed less often can be placed in a contextual menu, represented by the ‘three dots’ icon.
26
+ * The `<ActionSheet>` component appears as a floating bar when one or more items
27
+ * are selected from a table, providing bulk actions for the selection.
29
28
  *
29
+ * It primarily accommodates 1-3 main actions that represent the most crucial and
30
+ * frequently accessed functions on the specific page. If the page supports more
31
+ * than 3 actions, the ones that are performed less often can be placed in a
32
+ * contextual menu, represented by the 'three dots' icon via `moreActions`.
33
+ *
34
+ * ### When to use
35
+ * - Provide bulk operations when users select multiple table rows
36
+ * - For batch actions like delete, export, assign, or status changes
37
+ * - When actions need to operate on a collection of selected items
38
+ *
39
+ * ### When not to use
40
+ * - For single row actions - use `RowActions` instead
41
+ * - For page-level actions not tied to selection - use regular buttons
42
+ * - When the table doesn't support multi-selection
43
+ *
44
+ * @example Basic usage with table selection
45
+ * ```tsx
46
+ * import { Table, ActionSheet, useTableSelection } from "@trackunit/react-table";
47
+ *
48
+ * const MyTable = ({ data }) => {
49
+ * const { selections, resetSelection, rowSelection, onRowSelectionChange } =
50
+ * useTableSelection(data);
51
+ *
52
+ * return (
53
+ * <>
54
+ * <Table
55
+ * data={data}
56
+ * columns={columns}
57
+ * state={{ rowSelection }}
58
+ * onRowSelectionChange={onRowSelectionChange}
59
+ * enableRowSelection
60
+ * />
61
+ * {selections.length > 0 && (
62
+ * <ActionSheet
63
+ * selections={selections}
64
+ * resetSelection={resetSelection}
65
+ * actions={[
66
+ * {
67
+ * label: "Export",
68
+ * iconName: "ArrowDownTray",
69
+ * onClick: () => handleExport(selections),
70
+ * },
71
+ * {
72
+ * label: "Delete",
73
+ * iconName: "Trash",
74
+ * variant: "danger",
75
+ * onClick: () => handleDelete(selections),
76
+ * },
77
+ * ]}
78
+ * />
79
+ * )}
80
+ * </>
81
+ * );
82
+ * };
83
+ * ```
84
+ * @example With overflow actions
85
+ * ```tsx
86
+ * import { ActionSheet } from "@trackunit/react-table";
87
+ *
88
+ * <ActionSheet
89
+ * selections={selectedIds}
90
+ * resetSelection={() => setSelectedIds([])}
91
+ * actions={[
92
+ * { label: "Export", iconName: "ArrowDownTray", onClick: handleExport },
93
+ * { label: "Assign", iconName: "UserPlus", onClick: handleAssign },
94
+ * ]}
95
+ * moreActions={[
96
+ * { label: "Archive", iconName: "ArchiveBox", onClick: handleArchive },
97
+ * { label: "Move", iconName: "FolderArrowDown", onClick: handleMove },
98
+ * { label: "Delete", iconName: "Trash", variant: "danger", onClick: handleDelete },
99
+ * ]}
100
+ * />
101
+ * ```
102
+ * @example With dropdown actions
103
+ * ```tsx
104
+ * import { ActionSheet } from "@trackunit/react-table";
105
+ * import { MenuList, MenuItem } from "@trackunit/react-components";
106
+ *
107
+ * <ActionSheet
108
+ * selections={selectedIds}
109
+ * resetSelection={resetSelection}
110
+ * actions={[
111
+ * { label: "Export", iconName: "ArrowDownTray", onClick: handleExport },
112
+ * ]}
113
+ * dropdownActions={[
114
+ * {
115
+ * label: "Change Status",
116
+ * iconName: "Flag",
117
+ * dropdownContent: (close) => (
118
+ * <MenuList>
119
+ * <MenuItem label="Active" onClick={() => { setStatus("active"); close(); }} />
120
+ * <MenuItem label="Inactive" onClick={() => { setStatus("inactive"); close(); }} />
121
+ * </MenuList>
122
+ * ),
123
+ * },
124
+ * ]}
125
+ * />
126
+ * ```
30
127
  * @param {ActionSheetProps} props - The props for the ActionSheet component
31
128
  * @returns {ReactElement} ActionSheet component
32
129
  */
package/src/Table.d.ts CHANGED
@@ -3,18 +3,71 @@ import { CommonProps, EmptyStateProps, RelayPagination } from "@trackunit/react-
3
3
  import { ReactElement, ReactNode } from "react";
4
4
  import "./table-animations.css";
5
5
  export interface TableProps<TData extends object> extends ReactTable<TData>, CommonProps {
6
+ /**
7
+ * Relay-style pagination object for infinite scroll. Use with `usePaginationQuery` hook
8
+ * to automatically handle fetching more data as the user scrolls.
9
+ */
6
10
  pagination?: RelayPagination;
11
+ /**
12
+ * ReactNode rendered on the left side of the table header area.
13
+ * Commonly used for column settings, search inputs or filter controls.
14
+ */
7
15
  headerLeftActions?: ReactNode;
16
+ /**
17
+ * ReactNode rendered on the right side of the table header area.
18
+ * Commonly used for primary actions for the table.
19
+ */
8
20
  headerRightActions?: ReactNode;
21
+ /**
22
+ * ReactNode rendered on the right side of the table footer.
23
+ * Commonly used for export actions.
24
+ */
9
25
  footerRightActions?: ReactNode;
26
+ /**
27
+ * Callback fired when a row is clicked. Receives the full Tanstack Row object
28
+ * which includes the original data via `row.original`.
29
+ */
10
30
  onRowClick?: (row: Row<TData>) => void;
31
+ /**
32
+ * Custom message or element shown when the table has no data.
33
+ * If not provided, a default empty state with search icon is displayed.
34
+ */
11
35
  noDataMessage?: ReactElement | string;
36
+ /**
37
+ * Shows a centered loading spinner when true. Use for initial data loading
38
+ * or when refreshing the entire table.
39
+ */
12
40
  loading?: boolean;
41
+ /**
42
+ * Height of each row in pixels. Used by the virtual scroll to estimate row sizes.
43
+ *
44
+ * @default 50
45
+ */
13
46
  rowHeight?: number;
47
+ /**
48
+ * Hides the footer that shows row count when true.
49
+ * Useful for compact tables or when count information isn't needed.
50
+ */
14
51
  hideFooter?: boolean;
52
+ /**
53
+ * Props passed to the EmptyState component shown when there's no data.
54
+ * Allows customizing the empty state image, title, and description.
55
+ */
15
56
  emptyState?: EmptyStateProps;
57
+ /**
58
+ * Column ID used to identify the selection checkbox column.
59
+ * When set, clicking on this column won't trigger `onRowClick`.
60
+ */
16
61
  selectionColId?: string;
62
+ /**
63
+ * Function to render custom filter buttons in column headers.
64
+ * Receives the filter key(s) from column meta and should return filter UI.
65
+ */
17
66
  renderFilterButton?: (filterKey: string | Array<string>) => ReactNode;
67
+ /**
68
+ * Function to determine if a specific row should be clickable.
69
+ * When provided, only rows returning true will have pointer cursor and trigger `onRowClick`.
70
+ */
18
71
  isRowClickable?: (row: TData) => boolean;
19
72
  onColumnDragStart?: (columnId: string) => void;
20
73
  }