@trackunit/react-table-base-components 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 +464 -15
- package/index.esm.js +464 -15
- package/package.json +7 -7
- package/src/components/ButtonCell/ButtonCell.d.ts +78 -1
- package/src/components/DateTimeCell/DateTimeCell.d.ts +51 -1
- package/src/components/IdentityCell/IdentityCell.d.ts +66 -3
- package/src/components/LinkCell/LinkCell.d.ts +54 -1
- package/src/components/NumberCell/NumberCell.d.ts +42 -1
- package/src/components/RowActions/RowActions.d.ts +117 -6
- package/src/components/TagsCell/TagsCell.d.ts +42 -1
- package/src/components/TextCell/TextCell.d.ts +42 -1
package/index.cjs.js
CHANGED
|
@@ -11,8 +11,74 @@ var polyfill = require('@js-temporal/polyfill');
|
|
|
11
11
|
var sharedUtils = require('@trackunit/shared-utils');
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
|
-
* The ButtonCell
|
|
14
|
+
* The `<ButtonCell>` component renders an interactive button within a table cell.
|
|
15
|
+
* Uses a ghost-neutral variant by default for subtle inline actions.
|
|
16
|
+
* Commonly used for quick actions on individual rows without opening a menu.
|
|
15
17
|
*
|
|
18
|
+
* ### When to use
|
|
19
|
+
* - Provide a single quick action directly in a table cell
|
|
20
|
+
* - When the action is contextual and specific to that row's data
|
|
21
|
+
* - For inline edit, view details, or quick status change actions
|
|
22
|
+
*
|
|
23
|
+
* ### When not to use
|
|
24
|
+
* - For multiple actions per row - use `RowActions` instead
|
|
25
|
+
* - For primary page-level actions - use regular `Button` component
|
|
26
|
+
* - For navigation links - use `LinkCell` or `IdentityCell` with link prop
|
|
27
|
+
*
|
|
28
|
+
* @example Basic usage
|
|
29
|
+
* ```tsx
|
|
30
|
+
* import { ButtonCell } from "@trackunit/react-table-base-components";
|
|
31
|
+
* import { createColumnHelper } from "@tanstack/react-table";
|
|
32
|
+
*
|
|
33
|
+
* const columnHelper = createColumnHelper<Asset>();
|
|
34
|
+
*
|
|
35
|
+
* const columns = [
|
|
36
|
+
* columnHelper.display({
|
|
37
|
+
* id: "action",
|
|
38
|
+
* header: "Action",
|
|
39
|
+
* cell: ({ row }) => (
|
|
40
|
+
* <ButtonCell onClick={() => handleView(row.original.id)}>
|
|
41
|
+
* View Details
|
|
42
|
+
* </ButtonCell>
|
|
43
|
+
* ),
|
|
44
|
+
* }),
|
|
45
|
+
* ];
|
|
46
|
+
* ```
|
|
47
|
+
* @example With icon
|
|
48
|
+
* ```tsx
|
|
49
|
+
* import { ButtonCell } from "@trackunit/react-table-base-components";
|
|
50
|
+
*
|
|
51
|
+
* // Edit action with icon
|
|
52
|
+
* <ButtonCell
|
|
53
|
+
* iconName="PencilSquare"
|
|
54
|
+
* onClick={() => handleEdit(assetId)}
|
|
55
|
+
* >
|
|
56
|
+
* Edit
|
|
57
|
+
* </ButtonCell>
|
|
58
|
+
*
|
|
59
|
+
* // Download action
|
|
60
|
+
* <ButtonCell
|
|
61
|
+
* iconName="ArrowDownTray"
|
|
62
|
+
* iconColor="primary"
|
|
63
|
+
* onClick={() => handleDownload(reportId)}
|
|
64
|
+
* >
|
|
65
|
+
* Download
|
|
66
|
+
* </ButtonCell>
|
|
67
|
+
* ```
|
|
68
|
+
* @example Different button states
|
|
69
|
+
* ```tsx
|
|
70
|
+
* import { ButtonCell } from "@trackunit/react-table-base-components";
|
|
71
|
+
*
|
|
72
|
+
* // Disabled state
|
|
73
|
+
* <ButtonCell disabled onClick={() => {}}>
|
|
74
|
+
* Unavailable
|
|
75
|
+
* </ButtonCell>
|
|
76
|
+
*
|
|
77
|
+
* // Loading state
|
|
78
|
+
* <ButtonCell loading onClick={() => {}}>
|
|
79
|
+
* Processing
|
|
80
|
+
* </ButtonCell>
|
|
81
|
+
* ```
|
|
16
82
|
* @param {ButtonCellProps} props - The props for the ButtonCell component
|
|
17
83
|
* @returns {ReactElement} ButtonCell component
|
|
18
84
|
*/
|
|
@@ -38,8 +104,58 @@ const cvaDateTime$1 = cssClassVarianceUtilities.cvaMerge(["slashed-zero", "text-
|
|
|
38
104
|
const cvaDateTimeSince$1 = cssClassVarianceUtilities.cvaMerge(["slashed-zero", "text-neutral-500", "text-xs", "text-ellipsis"]);
|
|
39
105
|
|
|
40
106
|
/**
|
|
41
|
-
* DateTimeCell
|
|
107
|
+
* The `<DateTimeCell>` component renders a formatted date/time in a table cell.
|
|
108
|
+
* It displays the formatted date with an optional "time since" indicator
|
|
109
|
+
* (e.g., "2 hours ago") on a second line for quick context.
|
|
110
|
+
*
|
|
111
|
+
* ### When to use
|
|
112
|
+
* - Display timestamps, created/updated dates in tables
|
|
113
|
+
* - When users need to quickly understand how recent an event was
|
|
114
|
+
* - For date columns that benefit from relative time context
|
|
115
|
+
*
|
|
116
|
+
* ### When not to use
|
|
117
|
+
* - For date-only display without time - use `PlainDateCell` instead
|
|
118
|
+
* - For duration values - use `NumberCell` with appropriate units
|
|
119
|
+
* - For editable date inputs - use form components instead
|
|
120
|
+
*
|
|
121
|
+
* @example Basic usage
|
|
122
|
+
* ```tsx
|
|
123
|
+
* import { DateTimeCell } from "@trackunit/react-table-base-components";
|
|
124
|
+
* import { createColumnHelper } from "@tanstack/react-table";
|
|
125
|
+
*
|
|
126
|
+
* const columnHelper = createColumnHelper<Event>();
|
|
127
|
+
*
|
|
128
|
+
* const columns = [
|
|
129
|
+
* columnHelper.accessor("createdAt", {
|
|
130
|
+
* header: "Created",
|
|
131
|
+
* cell: ({ getValue }) => <DateTimeCell date={getValue()} />,
|
|
132
|
+
* }),
|
|
133
|
+
* ];
|
|
134
|
+
* ```
|
|
135
|
+
* @example With timezone and format options
|
|
136
|
+
* ```tsx
|
|
137
|
+
* import { DateTimeCell } from "@trackunit/react-table-base-components";
|
|
138
|
+
*
|
|
139
|
+
* // Default format with time since
|
|
140
|
+
* <DateTimeCell date={new Date("2024-01-15T14:30:00Z")} />
|
|
141
|
+
* // Output: "Jan 15, 2024, 2:30 PM" + "3 days ago"
|
|
142
|
+
*
|
|
143
|
+
* // Without time since indicator
|
|
144
|
+
* <DateTimeCell date={new Date()} withTimeSince={false} />
|
|
42
145
|
*
|
|
146
|
+
* // With specific timezone
|
|
147
|
+
* <DateTimeCell
|
|
148
|
+
* date={new Date()}
|
|
149
|
+
* timeZone="America/New_York"
|
|
150
|
+
* locale="en-US"
|
|
151
|
+
* />
|
|
152
|
+
*
|
|
153
|
+
* // Custom format
|
|
154
|
+
* <DateTimeCell
|
|
155
|
+
* date={new Date()}
|
|
156
|
+
* format="dateTime"
|
|
157
|
+
* />
|
|
158
|
+
* ```
|
|
43
159
|
* @param {DateTimeCellProps} props - The props for the DateTimeCell component
|
|
44
160
|
* @returns {ReactElement} DateTimeCell component
|
|
45
161
|
*/
|
|
@@ -87,13 +203,76 @@ const cvaIdentityCell = cssClassVarianceUtilities.cvaMerge(["grid", "items-cente
|
|
|
87
203
|
});
|
|
88
204
|
|
|
89
205
|
/**
|
|
90
|
-
* The IdentityCell
|
|
206
|
+
* The `<IdentityCell>` component renders an identity or entity in a table cell,
|
|
207
|
+
* typically showing a title with optional thumbnail and supporting details.
|
|
208
|
+
* Commonly used for displaying assets, users, or other entities with rich metadata.
|
|
91
209
|
*
|
|
92
210
|
* When displaying asset information, always use the `type` field
|
|
93
211
|
* (e.g., "excavator", "boom lift") instead of `assetType` (e.g., "machine", "attachment").
|
|
94
212
|
*
|
|
95
|
-
*
|
|
96
|
-
*
|
|
213
|
+
* ### When to use
|
|
214
|
+
* - Display entities with name + additional identifying details (model, serial number, etc.)
|
|
215
|
+
* - When a thumbnail/avatar helps users identify the item
|
|
216
|
+
* - For the primary identifying column in asset, user, or entity tables
|
|
217
|
+
*
|
|
218
|
+
* ### When not to use
|
|
219
|
+
* - For simple text values - use `TextCell` instead
|
|
220
|
+
* - For numeric data - use `NumberCell` instead
|
|
221
|
+
* - For standalone links without identity context - use `LinkCell` instead
|
|
222
|
+
*
|
|
223
|
+
* @example Basic usage with asset data
|
|
224
|
+
* ```tsx
|
|
225
|
+
* import { IdentityCell } from "@trackunit/react-table-base-components";
|
|
226
|
+
* import { createColumnHelper } from "@tanstack/react-table";
|
|
227
|
+
*
|
|
228
|
+
* const columnHelper = createColumnHelper<Asset>();
|
|
229
|
+
*
|
|
230
|
+
* const columns = [
|
|
231
|
+
* columnHelper.accessor("name", {
|
|
232
|
+
* header: "Asset",
|
|
233
|
+
* cell: ({ row }) => (
|
|
234
|
+
* <IdentityCell
|
|
235
|
+
* title={row.original.name}
|
|
236
|
+
* details={[row.original.type, row.original.serialNumber]}
|
|
237
|
+
* />
|
|
238
|
+
* ),
|
|
239
|
+
* }),
|
|
240
|
+
* ];
|
|
241
|
+
* ```
|
|
242
|
+
* @example With thumbnail and link
|
|
243
|
+
* ```tsx
|
|
244
|
+
* import { IdentityCell } from "@trackunit/react-table-base-components";
|
|
245
|
+
* import { AssetImage } from "@trackunit/react-components";
|
|
246
|
+
* import { useIrisRouting } from "@trackunit/react-core-contexts-and-hooks";
|
|
247
|
+
*
|
|
248
|
+
* const { createHref, goto } = useIrisRouting();
|
|
249
|
+
*
|
|
250
|
+
* <IdentityCell
|
|
251
|
+
* title="Excavator CAT 320"
|
|
252
|
+
* details={["Caterpillar", "SN: ABC123456"]}
|
|
253
|
+
* thumbnail={<AssetImage assetId={assetId} size="small" />}
|
|
254
|
+
* link={{
|
|
255
|
+
* href: () => createHref({ page: "asset", assetId }),
|
|
256
|
+
* goto: () => goto({ page: "asset", assetId }),
|
|
257
|
+
* title: "View asset details",
|
|
258
|
+
* }}
|
|
259
|
+
* />
|
|
260
|
+
* ```
|
|
261
|
+
* @example Simple identity without extras
|
|
262
|
+
* ```tsx
|
|
263
|
+
* import { IdentityCell } from "@trackunit/react-table-base-components";
|
|
264
|
+
*
|
|
265
|
+
* // Just title
|
|
266
|
+
* <IdentityCell title="John Smith" />
|
|
267
|
+
*
|
|
268
|
+
* // Title with details array
|
|
269
|
+
* <IdentityCell
|
|
270
|
+
* title="Boom Lift JLG 600S"
|
|
271
|
+
* details={["JLG Industries", "Serial: XYZ789"]}
|
|
272
|
+
* />
|
|
273
|
+
* ```
|
|
274
|
+
* @param {IdentityCellProps} props - The props for the IdentityCell component
|
|
275
|
+
* @returns {ReactElement} IdentityCell component
|
|
97
276
|
*/
|
|
98
277
|
const IdentityCell = ({ link, className, "data-testid": dataTestId, title, details = [], thumbnail, }) => {
|
|
99
278
|
const [href, setHref] = react.useState(undefined);
|
|
@@ -139,8 +318,61 @@ const IndicatorCell = ({ withBackground = false, weight = "normal", ...rest }) =
|
|
|
139
318
|
const cvaLinkCell = cssClassVarianceUtilities.cvaMerge(["text-sm"]);
|
|
140
319
|
|
|
141
320
|
/**
|
|
142
|
-
* The LinkCell
|
|
321
|
+
* The `<LinkCell>` component renders a clickable link in a table cell.
|
|
322
|
+
* Supports URLs, phone numbers (tel:), and email addresses (mailto:).
|
|
323
|
+
* Clicking the link opens it without triggering the table row click handler.
|
|
324
|
+
*
|
|
325
|
+
* ### When to use
|
|
326
|
+
* - Display clickable URLs, emails, or phone numbers in table columns
|
|
327
|
+
* - When users need to contact someone or visit an external link from table data
|
|
328
|
+
* - For contact information columns (email, phone)
|
|
329
|
+
*
|
|
330
|
+
* ### When not to use
|
|
331
|
+
* - For internal navigation - use `IdentityCell` with link prop instead
|
|
332
|
+
* - For action buttons - use `ButtonCell` or `RowActions` instead
|
|
333
|
+
* - For non-interactive text - use `TextCell` instead
|
|
334
|
+
*
|
|
335
|
+
* @example Basic usage with different link types
|
|
336
|
+
* ```tsx
|
|
337
|
+
* import { LinkCell } from "@trackunit/react-table-base-components";
|
|
338
|
+
* import { createColumnHelper } from "@tanstack/react-table";
|
|
339
|
+
*
|
|
340
|
+
* const columnHelper = createColumnHelper<Contact>();
|
|
143
341
|
*
|
|
342
|
+
* const columns = [
|
|
343
|
+
* columnHelper.accessor("email", {
|
|
344
|
+
* header: "Email",
|
|
345
|
+
* cell: ({ getValue }) => (
|
|
346
|
+
* <LinkCell type="EMAIL" link={getValue()} />
|
|
347
|
+
* ),
|
|
348
|
+
* }),
|
|
349
|
+
* columnHelper.accessor("phone", {
|
|
350
|
+
* header: "Phone",
|
|
351
|
+
* cell: ({ getValue }) => (
|
|
352
|
+
* <LinkCell type="PHONE" link={getValue()} />
|
|
353
|
+
* ),
|
|
354
|
+
* }),
|
|
355
|
+
* columnHelper.accessor("website", {
|
|
356
|
+
* header: "Website",
|
|
357
|
+
* cell: ({ getValue }) => (
|
|
358
|
+
* <LinkCell type="LINK" link={getValue()} />
|
|
359
|
+
* ),
|
|
360
|
+
* }),
|
|
361
|
+
* ];
|
|
362
|
+
* ```
|
|
363
|
+
* @example Link type examples
|
|
364
|
+
* ```tsx
|
|
365
|
+
* import { LinkCell } from "@trackunit/react-table-base-components";
|
|
366
|
+
*
|
|
367
|
+
* // Email - opens mail client
|
|
368
|
+
* <LinkCell type="EMAIL" link="contact@example.com" />
|
|
369
|
+
*
|
|
370
|
+
* // Phone - opens phone dialer
|
|
371
|
+
* <LinkCell type="PHONE" link="+1-555-123-4567" />
|
|
372
|
+
*
|
|
373
|
+
* // URL - opens in browser
|
|
374
|
+
* <LinkCell type="LINK" link="https://example.com" />
|
|
375
|
+
* ```
|
|
144
376
|
* @param {LinkCellProps} props - The props for the LinkCell component
|
|
145
377
|
* @returns {ReactElement} LinkCell component
|
|
146
378
|
*/
|
|
@@ -248,8 +480,49 @@ const NoticeCell = ({ ...rest }) => {
|
|
|
248
480
|
const cvaNumberCell = cssClassVarianceUtilities.cvaMerge(["flex", "gap-1", "slashed-zero", "text-sm", "text-ellipsis"]);
|
|
249
481
|
|
|
250
482
|
/**
|
|
251
|
-
* The `<NumberCell>` component is used for displaying numbers with units in a table cell.
|
|
483
|
+
* The `<NumberCell>` component is used for displaying numbers with optional units in a table cell.
|
|
484
|
+
* Numbers are right-aligned by default for easy scanning and comparison in data tables.
|
|
485
|
+
*
|
|
486
|
+
* ### When to use
|
|
487
|
+
* - Display numeric values like quantities, measurements, or counts
|
|
488
|
+
* - When values need to be accompanied by units (km, hours, %, etc.)
|
|
489
|
+
* - For right-aligned numeric columns in data tables
|
|
490
|
+
*
|
|
491
|
+
* ### When not to use
|
|
492
|
+
* - For non-numeric text content - use `TextCell` instead
|
|
493
|
+
* - For dates and times - use `DateTimeCell` instead
|
|
494
|
+
* - For formatted currency - consider specialized formatting
|
|
495
|
+
*
|
|
496
|
+
* @example Basic usage
|
|
497
|
+
* ```tsx
|
|
498
|
+
* import { NumberCell } from "@trackunit/react-table-base-components";
|
|
499
|
+
* import { createColumnHelper } from "@tanstack/react-table";
|
|
500
|
+
*
|
|
501
|
+
* const columnHelper = createColumnHelper<Asset>();
|
|
502
|
+
*
|
|
503
|
+
* const columns = [
|
|
504
|
+
* columnHelper.accessor("engineHours", {
|
|
505
|
+
* header: "Engine Hours",
|
|
506
|
+
* cell: ({ getValue }) => <NumberCell value={getValue()} unit="h" />,
|
|
507
|
+
* }),
|
|
508
|
+
* ];
|
|
509
|
+
* ```
|
|
510
|
+
* @example Different unit types
|
|
511
|
+
* ```tsx
|
|
512
|
+
* import { NumberCell } from "@trackunit/react-table-base-components";
|
|
252
513
|
*
|
|
514
|
+
* // Distance
|
|
515
|
+
* <NumberCell value={1250} unit="km" />
|
|
516
|
+
*
|
|
517
|
+
* // Percentage
|
|
518
|
+
* <NumberCell value={85} unit="%" />
|
|
519
|
+
*
|
|
520
|
+
* // Temperature
|
|
521
|
+
* <NumberCell value={23.5} unit="°C" />
|
|
522
|
+
*
|
|
523
|
+
* // Without unit
|
|
524
|
+
* <NumberCell value={42} />
|
|
525
|
+
* ```
|
|
253
526
|
* @param {NumberCellProps} props - The props for the NumberCell component.
|
|
254
527
|
* @returns {ReactElement} A React JSX element representing the NumberCell component.
|
|
255
528
|
*/
|
|
@@ -335,15 +608,114 @@ const cvaResizeHandel = cssClassVarianceUtilities.cvaMerge([
|
|
|
335
608
|
});
|
|
336
609
|
|
|
337
610
|
/**
|
|
338
|
-
* RowActions component displays actions
|
|
339
|
-
* based on the number of actions
|
|
611
|
+
* The `<RowActions>` component displays contextual actions for a table row.
|
|
612
|
+
* Automatically adapts its rendering based on the number of actions:
|
|
613
|
+
* - Single action: renders as a standalone button
|
|
614
|
+
* - Multiple actions: renders selected actions as icon buttons + overflow menu
|
|
615
|
+
*
|
|
616
|
+
* Actions can be marked as `isSelected` to display them as quick-access icon buttons
|
|
617
|
+
* outside the dropdown menu. Danger actions are automatically separated with a divider.
|
|
618
|
+
*
|
|
619
|
+
* ### When to use
|
|
620
|
+
* - Provide row-level actions like Edit, Delete, Download, etc.
|
|
621
|
+
* - When rows need multiple contextual actions
|
|
622
|
+
* - For consistent action patterns across data tables
|
|
623
|
+
*
|
|
624
|
+
* ### When not to use
|
|
625
|
+
* - For bulk actions on selected rows - use `ActionSheet` instead
|
|
626
|
+
* - For a single simple action - consider `ButtonCell` for simpler UI
|
|
627
|
+
* - For navigation - use `IdentityCell` with link prop
|
|
628
|
+
*
|
|
629
|
+
* @example Basic usage with multiple actions
|
|
630
|
+
* ```tsx
|
|
631
|
+
* import { RowActions } from "@trackunit/react-table-base-components";
|
|
632
|
+
* import { createColumnHelper } from "@tanstack/react-table";
|
|
340
633
|
*
|
|
341
|
-
*
|
|
342
|
-
* - If there are multiple actions, they are grouped into a dropdown menu.
|
|
634
|
+
* const columnHelper = createColumnHelper<Asset>();
|
|
343
635
|
*
|
|
636
|
+
* const columns = [
|
|
637
|
+
* columnHelper.display({
|
|
638
|
+
* id: "actions",
|
|
639
|
+
* header: "",
|
|
640
|
+
* cell: ({ row }) => (
|
|
641
|
+
* <RowActions
|
|
642
|
+
* actions={[
|
|
643
|
+
* {
|
|
644
|
+
* label: "Edit",
|
|
645
|
+
* iconName: "PencilSquare",
|
|
646
|
+
* onClick: () => handleEdit(row.original.id),
|
|
647
|
+
* },
|
|
648
|
+
* {
|
|
649
|
+
* label: "Download",
|
|
650
|
+
* iconName: "ArrowDownTray",
|
|
651
|
+
* onClick: () => handleDownload(row.original.id),
|
|
652
|
+
* },
|
|
653
|
+
* {
|
|
654
|
+
* label: "Delete",
|
|
655
|
+
* iconName: "Trash",
|
|
656
|
+
* variant: "danger",
|
|
657
|
+
* onClick: () => handleDelete(row.original.id),
|
|
658
|
+
* },
|
|
659
|
+
* ]}
|
|
660
|
+
* />
|
|
661
|
+
* ),
|
|
662
|
+
* }),
|
|
663
|
+
* ];
|
|
664
|
+
* ```
|
|
665
|
+
* @example With selected (pinned) actions
|
|
666
|
+
* ```tsx
|
|
667
|
+
* import { RowActions } from "@trackunit/react-table-base-components";
|
|
668
|
+
*
|
|
669
|
+
* <RowActions
|
|
670
|
+
* actions={[
|
|
671
|
+
* {
|
|
672
|
+
* label: "Edit",
|
|
673
|
+
* iconName: "PencilSquare",
|
|
674
|
+
* isSelected: true, // Shows as icon button outside menu
|
|
675
|
+
* onClick: () => handleEdit(id),
|
|
676
|
+
* },
|
|
677
|
+
* {
|
|
678
|
+
* label: "Duplicate",
|
|
679
|
+
* iconName: "DocumentDuplicate",
|
|
680
|
+
* onClick: () => handleDuplicate(id),
|
|
681
|
+
* },
|
|
682
|
+
* {
|
|
683
|
+
* label: "Delete",
|
|
684
|
+
* iconName: "Trash",
|
|
685
|
+
* variant: "danger",
|
|
686
|
+
* onClick: () => handleDelete(id),
|
|
687
|
+
* },
|
|
688
|
+
* ]}
|
|
689
|
+
* />
|
|
690
|
+
* ```
|
|
691
|
+
* @example With loading and disabled states
|
|
692
|
+
* ```tsx
|
|
693
|
+
* import { RowActions } from "@trackunit/react-table-base-components";
|
|
694
|
+
*
|
|
695
|
+
* <RowActions
|
|
696
|
+
* actions={[
|
|
697
|
+
* {
|
|
698
|
+
* label: "Processing...",
|
|
699
|
+
* iconName: "ArrowPath",
|
|
700
|
+
* loading: true,
|
|
701
|
+
* onClick: () => {},
|
|
702
|
+
* },
|
|
703
|
+
* {
|
|
704
|
+
* label: "Unavailable",
|
|
705
|
+
* iconName: "NoSymbol",
|
|
706
|
+
* disabled: true,
|
|
707
|
+
* onClick: () => {},
|
|
708
|
+
* },
|
|
709
|
+
* {
|
|
710
|
+
* label: "Hidden Action",
|
|
711
|
+
* isVisible: false, // Will not be rendered
|
|
712
|
+
* onClick: () => {},
|
|
713
|
+
* },
|
|
714
|
+
* ]}
|
|
715
|
+
* />
|
|
716
|
+
* ```
|
|
344
717
|
* @param {RowActionsProps} props - The properties for the component.
|
|
345
|
-
* @
|
|
346
|
-
* @returns {Element} A React component rendering the actions.
|
|
718
|
+
* @returns {ReactElement} A React component rendering the row actions.
|
|
347
719
|
*/
|
|
348
720
|
const RowActions = ({ actions }) => {
|
|
349
721
|
const selectedActions = actions.filter(action => action.isSelected);
|
|
@@ -446,8 +818,49 @@ const cvaTableRoot = cssClassVarianceUtilities.cvaMerge(["border-spacing-0", "mi
|
|
|
446
818
|
const cvaTagsCell = cssClassVarianceUtilities.cvaMerge(["flex", "gap-2"]);
|
|
447
819
|
|
|
448
820
|
/**
|
|
449
|
-
* The TagsCell
|
|
821
|
+
* The `<TagsCell>` component renders a list of tags in a table cell.
|
|
822
|
+
* Useful for displaying categories, labels, or status indicators in a compact format.
|
|
823
|
+
*
|
|
824
|
+
* ### When to use
|
|
825
|
+
* - Display multiple tags, categories, or labels for an entity
|
|
826
|
+
* - Show groupings, classifications, or metadata as visual tags
|
|
827
|
+
* - When items have multiple attributes that should be shown together
|
|
828
|
+
*
|
|
829
|
+
* ### When not to use
|
|
830
|
+
* - For a single status indicator - use `Tag` component directly or `IndicatorCell`
|
|
831
|
+
* - For text content - use `TextCell` instead
|
|
832
|
+
* - For interactive chip selection - use form components instead
|
|
833
|
+
*
|
|
834
|
+
* @example Basic usage with string array
|
|
835
|
+
* ```tsx
|
|
836
|
+
* import { TagsCell } from "@trackunit/react-table-base-components";
|
|
837
|
+
* import { createColumnHelper } from "@tanstack/react-table";
|
|
838
|
+
*
|
|
839
|
+
* const columnHelper = createColumnHelper<Asset>();
|
|
840
|
+
*
|
|
841
|
+
* const columns = [
|
|
842
|
+
* columnHelper.accessor("tags", {
|
|
843
|
+
* header: "Tags",
|
|
844
|
+
* cell: ({ getValue }) => <TagsCell tags={getValue()} />,
|
|
845
|
+
* }),
|
|
846
|
+
* ];
|
|
847
|
+
* ```
|
|
848
|
+
* @example With custom tag props
|
|
849
|
+
* ```tsx
|
|
850
|
+
* import { TagsCell } from "@trackunit/react-table-base-components";
|
|
450
851
|
*
|
|
852
|
+
* // Simple string tags
|
|
853
|
+
* <TagsCell tags={["Active", "Premium", "Verified"]} />
|
|
854
|
+
*
|
|
855
|
+
* // Tags with custom styling using TagProps
|
|
856
|
+
* <TagsCell
|
|
857
|
+
* tags={[
|
|
858
|
+
* { children: "Active", color: "success" },
|
|
859
|
+
* { children: "Warning", color: "warning" },
|
|
860
|
+
* { children: "Inactive", color: "neutral" },
|
|
861
|
+
* ]}
|
|
862
|
+
* />
|
|
863
|
+
* ```
|
|
451
864
|
* @param {TagsCellProps} props - The props for the TagsCell component
|
|
452
865
|
* @returns {ReactElement} TagsCell component
|
|
453
866
|
*/
|
|
@@ -504,8 +917,44 @@ const cvaTextCellTooltip = cssClassVarianceUtilities.cvaMerge(["grid"]);
|
|
|
504
917
|
|
|
505
918
|
/**
|
|
506
919
|
* The `<TextCell>` component is used for displaying text in a table cell.
|
|
507
|
-
* The text is not editable and will be truncated if the cell is too narrow.
|
|
920
|
+
* The text is not editable and will be truncated with an ellipsis if the cell is too narrow.
|
|
921
|
+
* When truncated, a tooltip automatically appears on hover showing the full content.
|
|
922
|
+
*
|
|
923
|
+
* ### When to use
|
|
924
|
+
* - Display simple text values in table columns (names, descriptions, statuses)
|
|
925
|
+
* - When text content might be longer than the column width
|
|
926
|
+
* - For read-only text display in data grids
|
|
927
|
+
*
|
|
928
|
+
* ### When not to use
|
|
929
|
+
* - For numeric values - use `NumberCell` instead
|
|
930
|
+
* - For dates and times - use `DateTimeCell` instead
|
|
931
|
+
* - For clickable links - use `LinkCell` or `ButtonCell` instead
|
|
932
|
+
* - For multi-line content - consider `IdentityCell` with details
|
|
933
|
+
*
|
|
934
|
+
* @example Basic usage
|
|
935
|
+
* ```tsx
|
|
936
|
+
* import { TextCell } from "@trackunit/react-table-base-components";
|
|
937
|
+
* import { createColumnHelper } from "@tanstack/react-table";
|
|
938
|
+
*
|
|
939
|
+
* const columnHelper = createColumnHelper<Asset>();
|
|
940
|
+
*
|
|
941
|
+
* const columns = [
|
|
942
|
+
* columnHelper.accessor("name", {
|
|
943
|
+
* header: "Name",
|
|
944
|
+
* cell: ({ getValue }) => <TextCell content={getValue()} />,
|
|
945
|
+
* }),
|
|
946
|
+
* ];
|
|
947
|
+
* ```
|
|
948
|
+
* @example With custom content
|
|
949
|
+
* ```tsx
|
|
950
|
+
* import { TextCell } from "@trackunit/react-table-base-components";
|
|
951
|
+
*
|
|
952
|
+
* // Text content - will show tooltip if truncated
|
|
953
|
+
* <TextCell content="This is a long description that might get truncated" />
|
|
508
954
|
*
|
|
955
|
+
* // ReactElement content
|
|
956
|
+
* <TextCell content={<span className="font-bold">Bold text</span>} />
|
|
957
|
+
* ```
|
|
509
958
|
* @param {TextCellProps} props - The props for the TextCell component
|
|
510
959
|
* @returns {ReactElement} TextCell component
|
|
511
960
|
*/
|