@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
|
@@ -31,8 +31,58 @@ export interface DateTimeCellProps extends CommonProps {
|
|
|
31
31
|
locale?: string;
|
|
32
32
|
}
|
|
33
33
|
/**
|
|
34
|
-
* DateTimeCell
|
|
34
|
+
* The `<DateTimeCell>` component renders a formatted date/time in a table cell.
|
|
35
|
+
* It displays the formatted date with an optional "time since" indicator
|
|
36
|
+
* (e.g., "2 hours ago") on a second line for quick context.
|
|
35
37
|
*
|
|
38
|
+
* ### When to use
|
|
39
|
+
* - Display timestamps, created/updated dates in tables
|
|
40
|
+
* - When users need to quickly understand how recent an event was
|
|
41
|
+
* - For date columns that benefit from relative time context
|
|
42
|
+
*
|
|
43
|
+
* ### When not to use
|
|
44
|
+
* - For date-only display without time - use `PlainDateCell` instead
|
|
45
|
+
* - For duration values - use `NumberCell` with appropriate units
|
|
46
|
+
* - For editable date inputs - use form components instead
|
|
47
|
+
*
|
|
48
|
+
* @example Basic usage
|
|
49
|
+
* ```tsx
|
|
50
|
+
* import { DateTimeCell } from "@trackunit/react-table-base-components";
|
|
51
|
+
* import { createColumnHelper } from "@tanstack/react-table";
|
|
52
|
+
*
|
|
53
|
+
* const columnHelper = createColumnHelper<Event>();
|
|
54
|
+
*
|
|
55
|
+
* const columns = [
|
|
56
|
+
* columnHelper.accessor("createdAt", {
|
|
57
|
+
* header: "Created",
|
|
58
|
+
* cell: ({ getValue }) => <DateTimeCell date={getValue()} />,
|
|
59
|
+
* }),
|
|
60
|
+
* ];
|
|
61
|
+
* ```
|
|
62
|
+
* @example With timezone and format options
|
|
63
|
+
* ```tsx
|
|
64
|
+
* import { DateTimeCell } from "@trackunit/react-table-base-components";
|
|
65
|
+
*
|
|
66
|
+
* // Default format with time since
|
|
67
|
+
* <DateTimeCell date={new Date("2024-01-15T14:30:00Z")} />
|
|
68
|
+
* // Output: "Jan 15, 2024, 2:30 PM" + "3 days ago"
|
|
69
|
+
*
|
|
70
|
+
* // Without time since indicator
|
|
71
|
+
* <DateTimeCell date={new Date()} withTimeSince={false} />
|
|
72
|
+
*
|
|
73
|
+
* // With specific timezone
|
|
74
|
+
* <DateTimeCell
|
|
75
|
+
* date={new Date()}
|
|
76
|
+
* timeZone="America/New_York"
|
|
77
|
+
* locale="en-US"
|
|
78
|
+
* />
|
|
79
|
+
*
|
|
80
|
+
* // Custom format
|
|
81
|
+
* <DateTimeCell
|
|
82
|
+
* date={new Date()}
|
|
83
|
+
* format="dateTime"
|
|
84
|
+
* />
|
|
85
|
+
* ```
|
|
36
86
|
* @param {DateTimeCellProps} props - The props for the DateTimeCell component
|
|
37
87
|
* @returns {ReactElement} DateTimeCell component
|
|
38
88
|
*/
|
|
@@ -18,12 +18,75 @@ export interface IdentityCellProps extends CommonProps {
|
|
|
18
18
|
};
|
|
19
19
|
}
|
|
20
20
|
/**
|
|
21
|
-
* The IdentityCell
|
|
21
|
+
* The `<IdentityCell>` component renders an identity or entity in a table cell,
|
|
22
|
+
* typically showing a title with optional thumbnail and supporting details.
|
|
23
|
+
* Commonly used for displaying assets, users, or other entities with rich metadata.
|
|
22
24
|
*
|
|
23
25
|
* When displaying asset information, always use the `type` field
|
|
24
26
|
* (e.g., "excavator", "boom lift") instead of `assetType` (e.g., "machine", "attachment").
|
|
25
27
|
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
+
* ### When to use
|
|
29
|
+
* - Display entities with name + additional identifying details (model, serial number, etc.)
|
|
30
|
+
* - When a thumbnail/avatar helps users identify the item
|
|
31
|
+
* - For the primary identifying column in asset, user, or entity tables
|
|
32
|
+
*
|
|
33
|
+
* ### When not to use
|
|
34
|
+
* - For simple text values - use `TextCell` instead
|
|
35
|
+
* - For numeric data - use `NumberCell` instead
|
|
36
|
+
* - For standalone links without identity context - use `LinkCell` instead
|
|
37
|
+
*
|
|
38
|
+
* @example Basic usage with asset data
|
|
39
|
+
* ```tsx
|
|
40
|
+
* import { IdentityCell } from "@trackunit/react-table-base-components";
|
|
41
|
+
* import { createColumnHelper } from "@tanstack/react-table";
|
|
42
|
+
*
|
|
43
|
+
* const columnHelper = createColumnHelper<Asset>();
|
|
44
|
+
*
|
|
45
|
+
* const columns = [
|
|
46
|
+
* columnHelper.accessor("name", {
|
|
47
|
+
* header: "Asset",
|
|
48
|
+
* cell: ({ row }) => (
|
|
49
|
+
* <IdentityCell
|
|
50
|
+
* title={row.original.name}
|
|
51
|
+
* details={[row.original.type, row.original.serialNumber]}
|
|
52
|
+
* />
|
|
53
|
+
* ),
|
|
54
|
+
* }),
|
|
55
|
+
* ];
|
|
56
|
+
* ```
|
|
57
|
+
* @example With thumbnail and link
|
|
58
|
+
* ```tsx
|
|
59
|
+
* import { IdentityCell } from "@trackunit/react-table-base-components";
|
|
60
|
+
* import { AssetImage } from "@trackunit/react-components";
|
|
61
|
+
* import { useIrisRouting } from "@trackunit/react-core-contexts-and-hooks";
|
|
62
|
+
*
|
|
63
|
+
* const { createHref, goto } = useIrisRouting();
|
|
64
|
+
*
|
|
65
|
+
* <IdentityCell
|
|
66
|
+
* title="Excavator CAT 320"
|
|
67
|
+
* details={["Caterpillar", "SN: ABC123456"]}
|
|
68
|
+
* thumbnail={<AssetImage assetId={assetId} size="small" />}
|
|
69
|
+
* link={{
|
|
70
|
+
* href: () => createHref({ page: "asset", assetId }),
|
|
71
|
+
* goto: () => goto({ page: "asset", assetId }),
|
|
72
|
+
* title: "View asset details",
|
|
73
|
+
* }}
|
|
74
|
+
* />
|
|
75
|
+
* ```
|
|
76
|
+
* @example Simple identity without extras
|
|
77
|
+
* ```tsx
|
|
78
|
+
* import { IdentityCell } from "@trackunit/react-table-base-components";
|
|
79
|
+
*
|
|
80
|
+
* // Just title
|
|
81
|
+
* <IdentityCell title="John Smith" />
|
|
82
|
+
*
|
|
83
|
+
* // Title with details array
|
|
84
|
+
* <IdentityCell
|
|
85
|
+
* title="Boom Lift JLG 600S"
|
|
86
|
+
* details={["JLG Industries", "Serial: XYZ789"]}
|
|
87
|
+
* />
|
|
88
|
+
* ```
|
|
89
|
+
* @param {IdentityCellProps} props - The props for the IdentityCell component
|
|
90
|
+
* @returns {ReactElement} IdentityCell component
|
|
28
91
|
*/
|
|
29
92
|
export declare const IdentityCell: ({ link, className, "data-testid": dataTestId, title, details, thumbnail, }: IdentityCellProps) => ReactElement;
|
|
@@ -19,8 +19,61 @@ export interface LinkCellProps extends CommonProps, HTMLAttributes<HTMLTableSect
|
|
|
19
19
|
link: string;
|
|
20
20
|
}
|
|
21
21
|
/**
|
|
22
|
-
* The LinkCell
|
|
22
|
+
* The `<LinkCell>` component renders a clickable link in a table cell.
|
|
23
|
+
* Supports URLs, phone numbers (tel:), and email addresses (mailto:).
|
|
24
|
+
* Clicking the link opens it without triggering the table row click handler.
|
|
23
25
|
*
|
|
26
|
+
* ### When to use
|
|
27
|
+
* - Display clickable URLs, emails, or phone numbers in table columns
|
|
28
|
+
* - When users need to contact someone or visit an external link from table data
|
|
29
|
+
* - For contact information columns (email, phone)
|
|
30
|
+
*
|
|
31
|
+
* ### When not to use
|
|
32
|
+
* - For internal navigation - use `IdentityCell` with link prop instead
|
|
33
|
+
* - For action buttons - use `ButtonCell` or `RowActions` instead
|
|
34
|
+
* - For non-interactive text - use `TextCell` instead
|
|
35
|
+
*
|
|
36
|
+
* @example Basic usage with different link types
|
|
37
|
+
* ```tsx
|
|
38
|
+
* import { LinkCell } from "@trackunit/react-table-base-components";
|
|
39
|
+
* import { createColumnHelper } from "@tanstack/react-table";
|
|
40
|
+
*
|
|
41
|
+
* const columnHelper = createColumnHelper<Contact>();
|
|
42
|
+
*
|
|
43
|
+
* const columns = [
|
|
44
|
+
* columnHelper.accessor("email", {
|
|
45
|
+
* header: "Email",
|
|
46
|
+
* cell: ({ getValue }) => (
|
|
47
|
+
* <LinkCell type="EMAIL" link={getValue()} />
|
|
48
|
+
* ),
|
|
49
|
+
* }),
|
|
50
|
+
* columnHelper.accessor("phone", {
|
|
51
|
+
* header: "Phone",
|
|
52
|
+
* cell: ({ getValue }) => (
|
|
53
|
+
* <LinkCell type="PHONE" link={getValue()} />
|
|
54
|
+
* ),
|
|
55
|
+
* }),
|
|
56
|
+
* columnHelper.accessor("website", {
|
|
57
|
+
* header: "Website",
|
|
58
|
+
* cell: ({ getValue }) => (
|
|
59
|
+
* <LinkCell type="LINK" link={getValue()} />
|
|
60
|
+
* ),
|
|
61
|
+
* }),
|
|
62
|
+
* ];
|
|
63
|
+
* ```
|
|
64
|
+
* @example Link type examples
|
|
65
|
+
* ```tsx
|
|
66
|
+
* import { LinkCell } from "@trackunit/react-table-base-components";
|
|
67
|
+
*
|
|
68
|
+
* // Email - opens mail client
|
|
69
|
+
* <LinkCell type="EMAIL" link="contact@example.com" />
|
|
70
|
+
*
|
|
71
|
+
* // Phone - opens phone dialer
|
|
72
|
+
* <LinkCell type="PHONE" link="+1-555-123-4567" />
|
|
73
|
+
*
|
|
74
|
+
* // URL - opens in browser
|
|
75
|
+
* <LinkCell type="LINK" link="https://example.com" />
|
|
76
|
+
* ```
|
|
24
77
|
* @param {LinkCellProps} props - The props for the LinkCell component
|
|
25
78
|
* @returns {ReactElement} LinkCell component
|
|
26
79
|
*/
|
|
@@ -19,8 +19,49 @@ export interface NumberCellProps extends CommonProps {
|
|
|
19
19
|
"data-testid"?: string;
|
|
20
20
|
}
|
|
21
21
|
/**
|
|
22
|
-
* The `<NumberCell>` component is used for displaying numbers with units in a table cell.
|
|
22
|
+
* The `<NumberCell>` component is used for displaying numbers with optional units in a table cell.
|
|
23
|
+
* Numbers are right-aligned by default for easy scanning and comparison in data tables.
|
|
23
24
|
*
|
|
25
|
+
* ### When to use
|
|
26
|
+
* - Display numeric values like quantities, measurements, or counts
|
|
27
|
+
* - When values need to be accompanied by units (km, hours, %, etc.)
|
|
28
|
+
* - For right-aligned numeric columns in data tables
|
|
29
|
+
*
|
|
30
|
+
* ### When not to use
|
|
31
|
+
* - For non-numeric text content - use `TextCell` instead
|
|
32
|
+
* - For dates and times - use `DateTimeCell` instead
|
|
33
|
+
* - For formatted currency - consider specialized formatting
|
|
34
|
+
*
|
|
35
|
+
* @example Basic usage
|
|
36
|
+
* ```tsx
|
|
37
|
+
* import { NumberCell } from "@trackunit/react-table-base-components";
|
|
38
|
+
* import { createColumnHelper } from "@tanstack/react-table";
|
|
39
|
+
*
|
|
40
|
+
* const columnHelper = createColumnHelper<Asset>();
|
|
41
|
+
*
|
|
42
|
+
* const columns = [
|
|
43
|
+
* columnHelper.accessor("engineHours", {
|
|
44
|
+
* header: "Engine Hours",
|
|
45
|
+
* cell: ({ getValue }) => <NumberCell value={getValue()} unit="h" />,
|
|
46
|
+
* }),
|
|
47
|
+
* ];
|
|
48
|
+
* ```
|
|
49
|
+
* @example Different unit types
|
|
50
|
+
* ```tsx
|
|
51
|
+
* import { NumberCell } from "@trackunit/react-table-base-components";
|
|
52
|
+
*
|
|
53
|
+
* // Distance
|
|
54
|
+
* <NumberCell value={1250} unit="km" />
|
|
55
|
+
*
|
|
56
|
+
* // Percentage
|
|
57
|
+
* <NumberCell value={85} unit="%" />
|
|
58
|
+
*
|
|
59
|
+
* // Temperature
|
|
60
|
+
* <NumberCell value={23.5} unit="°C" />
|
|
61
|
+
*
|
|
62
|
+
* // Without unit
|
|
63
|
+
* <NumberCell value={42} />
|
|
64
|
+
* ```
|
|
24
65
|
* @param {NumberCellProps} props - The props for the NumberCell component.
|
|
25
66
|
* @returns {ReactElement} A React JSX element representing the NumberCell component.
|
|
26
67
|
*/
|
|
@@ -1,27 +1,138 @@
|
|
|
1
1
|
import { MenuItemVariant } from "@trackunit/react-components";
|
|
2
2
|
import { IconName } from "@trackunit/ui-icons";
|
|
3
3
|
export type Action = {
|
|
4
|
+
/** The display text for the action button or menu item */
|
|
4
5
|
label: string;
|
|
6
|
+
/** Visual variant of the action, use "danger" for destructive actions */
|
|
5
7
|
variant?: MenuItemVariant;
|
|
8
|
+
/** Callback function triggered when the action is clicked */
|
|
6
9
|
onClick: () => void;
|
|
10
|
+
/** Optional icon to display alongside the action label */
|
|
7
11
|
iconName?: IconName;
|
|
12
|
+
/** When true, the action is shown as an icon button outside the dropdown menu */
|
|
8
13
|
isSelected?: boolean;
|
|
14
|
+
/** When true, the action is visually disabled and cannot be clicked */
|
|
9
15
|
disabled?: boolean;
|
|
16
|
+
/** When true, shows a spinner instead of the icon to indicate processing */
|
|
10
17
|
loading?: boolean;
|
|
18
|
+
/** Controls visibility of the action. Defaults to true if not specified */
|
|
11
19
|
isVisible?: boolean | null;
|
|
12
20
|
};
|
|
13
21
|
export interface RowActionsProps {
|
|
22
|
+
/**
|
|
23
|
+
* Array of actions to display. Single actions render as a button,
|
|
24
|
+
* multiple actions render as a dropdown menu with selected actions as icon buttons.
|
|
25
|
+
*/
|
|
14
26
|
actions: Array<Action>;
|
|
15
27
|
}
|
|
16
28
|
/**
|
|
17
|
-
* RowActions component displays actions
|
|
18
|
-
* based on the number of actions
|
|
29
|
+
* The `<RowActions>` component displays contextual actions for a table row.
|
|
30
|
+
* Automatically adapts its rendering based on the number of actions:
|
|
31
|
+
* - Single action: renders as a standalone button
|
|
32
|
+
* - Multiple actions: renders selected actions as icon buttons + overflow menu
|
|
19
33
|
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
34
|
+
* Actions can be marked as `isSelected` to display them as quick-access icon buttons
|
|
35
|
+
* outside the dropdown menu. Danger actions are automatically separated with a divider.
|
|
22
36
|
*
|
|
37
|
+
* ### When to use
|
|
38
|
+
* - Provide row-level actions like Edit, Delete, Download, etc.
|
|
39
|
+
* - When rows need multiple contextual actions
|
|
40
|
+
* - For consistent action patterns across data tables
|
|
41
|
+
*
|
|
42
|
+
* ### When not to use
|
|
43
|
+
* - For bulk actions on selected rows - use `ActionSheet` instead
|
|
44
|
+
* - For a single simple action - consider `ButtonCell` for simpler UI
|
|
45
|
+
* - For navigation - use `IdentityCell` with link prop
|
|
46
|
+
*
|
|
47
|
+
* @example Basic usage with multiple actions
|
|
48
|
+
* ```tsx
|
|
49
|
+
* import { RowActions } from "@trackunit/react-table-base-components";
|
|
50
|
+
* import { createColumnHelper } from "@tanstack/react-table";
|
|
51
|
+
*
|
|
52
|
+
* const columnHelper = createColumnHelper<Asset>();
|
|
53
|
+
*
|
|
54
|
+
* const columns = [
|
|
55
|
+
* columnHelper.display({
|
|
56
|
+
* id: "actions",
|
|
57
|
+
* header: "",
|
|
58
|
+
* cell: ({ row }) => (
|
|
59
|
+
* <RowActions
|
|
60
|
+
* actions={[
|
|
61
|
+
* {
|
|
62
|
+
* label: "Edit",
|
|
63
|
+
* iconName: "PencilSquare",
|
|
64
|
+
* onClick: () => handleEdit(row.original.id),
|
|
65
|
+
* },
|
|
66
|
+
* {
|
|
67
|
+
* label: "Download",
|
|
68
|
+
* iconName: "ArrowDownTray",
|
|
69
|
+
* onClick: () => handleDownload(row.original.id),
|
|
70
|
+
* },
|
|
71
|
+
* {
|
|
72
|
+
* label: "Delete",
|
|
73
|
+
* iconName: "Trash",
|
|
74
|
+
* variant: "danger",
|
|
75
|
+
* onClick: () => handleDelete(row.original.id),
|
|
76
|
+
* },
|
|
77
|
+
* ]}
|
|
78
|
+
* />
|
|
79
|
+
* ),
|
|
80
|
+
* }),
|
|
81
|
+
* ];
|
|
82
|
+
* ```
|
|
83
|
+
* @example With selected (pinned) actions
|
|
84
|
+
* ```tsx
|
|
85
|
+
* import { RowActions } from "@trackunit/react-table-base-components";
|
|
86
|
+
*
|
|
87
|
+
* <RowActions
|
|
88
|
+
* actions={[
|
|
89
|
+
* {
|
|
90
|
+
* label: "Edit",
|
|
91
|
+
* iconName: "PencilSquare",
|
|
92
|
+
* isSelected: true, // Shows as icon button outside menu
|
|
93
|
+
* onClick: () => handleEdit(id),
|
|
94
|
+
* },
|
|
95
|
+
* {
|
|
96
|
+
* label: "Duplicate",
|
|
97
|
+
* iconName: "DocumentDuplicate",
|
|
98
|
+
* onClick: () => handleDuplicate(id),
|
|
99
|
+
* },
|
|
100
|
+
* {
|
|
101
|
+
* label: "Delete",
|
|
102
|
+
* iconName: "Trash",
|
|
103
|
+
* variant: "danger",
|
|
104
|
+
* onClick: () => handleDelete(id),
|
|
105
|
+
* },
|
|
106
|
+
* ]}
|
|
107
|
+
* />
|
|
108
|
+
* ```
|
|
109
|
+
* @example With loading and disabled states
|
|
110
|
+
* ```tsx
|
|
111
|
+
* import { RowActions } from "@trackunit/react-table-base-components";
|
|
112
|
+
*
|
|
113
|
+
* <RowActions
|
|
114
|
+
* actions={[
|
|
115
|
+
* {
|
|
116
|
+
* label: "Processing...",
|
|
117
|
+
* iconName: "ArrowPath",
|
|
118
|
+
* loading: true,
|
|
119
|
+
* onClick: () => {},
|
|
120
|
+
* },
|
|
121
|
+
* {
|
|
122
|
+
* label: "Unavailable",
|
|
123
|
+
* iconName: "NoSymbol",
|
|
124
|
+
* disabled: true,
|
|
125
|
+
* onClick: () => {},
|
|
126
|
+
* },
|
|
127
|
+
* {
|
|
128
|
+
* label: "Hidden Action",
|
|
129
|
+
* isVisible: false, // Will not be rendered
|
|
130
|
+
* onClick: () => {},
|
|
131
|
+
* },
|
|
132
|
+
* ]}
|
|
133
|
+
* />
|
|
134
|
+
* ```
|
|
23
135
|
* @param {RowActionsProps} props - The properties for the component.
|
|
24
|
-
* @
|
|
25
|
-
* @returns {Element} A React component rendering the actions.
|
|
136
|
+
* @returns {ReactElement} A React component rendering the row actions.
|
|
26
137
|
*/
|
|
27
138
|
export declare const RowActions: ({ actions }: RowActionsProps) => false | import("react/jsx-runtime").JSX.Element | null | undefined;
|
|
@@ -15,8 +15,49 @@ export interface TagsCellProps extends CommonProps, HTMLAttributes<HTMLTableSect
|
|
|
15
15
|
tags: Array<string> | Array<TagProps>;
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
|
-
* The TagsCell
|
|
18
|
+
* The `<TagsCell>` component renders a list of tags in a table cell.
|
|
19
|
+
* Useful for displaying categories, labels, or status indicators in a compact format.
|
|
19
20
|
*
|
|
21
|
+
* ### When to use
|
|
22
|
+
* - Display multiple tags, categories, or labels for an entity
|
|
23
|
+
* - Show groupings, classifications, or metadata as visual tags
|
|
24
|
+
* - When items have multiple attributes that should be shown together
|
|
25
|
+
*
|
|
26
|
+
* ### When not to use
|
|
27
|
+
* - For a single status indicator - use `Tag` component directly or `IndicatorCell`
|
|
28
|
+
* - For text content - use `TextCell` instead
|
|
29
|
+
* - For interactive chip selection - use form components instead
|
|
30
|
+
*
|
|
31
|
+
* @example Basic usage with string array
|
|
32
|
+
* ```tsx
|
|
33
|
+
* import { TagsCell } from "@trackunit/react-table-base-components";
|
|
34
|
+
* import { createColumnHelper } from "@tanstack/react-table";
|
|
35
|
+
*
|
|
36
|
+
* const columnHelper = createColumnHelper<Asset>();
|
|
37
|
+
*
|
|
38
|
+
* const columns = [
|
|
39
|
+
* columnHelper.accessor("tags", {
|
|
40
|
+
* header: "Tags",
|
|
41
|
+
* cell: ({ getValue }) => <TagsCell tags={getValue()} />,
|
|
42
|
+
* }),
|
|
43
|
+
* ];
|
|
44
|
+
* ```
|
|
45
|
+
* @example With custom tag props
|
|
46
|
+
* ```tsx
|
|
47
|
+
* import { TagsCell } from "@trackunit/react-table-base-components";
|
|
48
|
+
*
|
|
49
|
+
* // Simple string tags
|
|
50
|
+
* <TagsCell tags={["Active", "Premium", "Verified"]} />
|
|
51
|
+
*
|
|
52
|
+
* // Tags with custom styling using TagProps
|
|
53
|
+
* <TagsCell
|
|
54
|
+
* tags={[
|
|
55
|
+
* { children: "Active", color: "success" },
|
|
56
|
+
* { children: "Warning", color: "warning" },
|
|
57
|
+
* { children: "Inactive", color: "neutral" },
|
|
58
|
+
* ]}
|
|
59
|
+
* />
|
|
60
|
+
* ```
|
|
20
61
|
* @param {TagsCellProps} props - The props for the TagsCell component
|
|
21
62
|
* @returns {ReactElement} TagsCell component
|
|
22
63
|
*/
|
|
@@ -1,12 +1,53 @@
|
|
|
1
1
|
import { CommonProps } from "@trackunit/react-components";
|
|
2
2
|
import { ReactElement } from "react";
|
|
3
3
|
export interface TextCellProps extends CommonProps {
|
|
4
|
+
/**
|
|
5
|
+
* The text or React element to display in the cell.
|
|
6
|
+
* When text overflows the cell width, it will be truncated with an ellipsis
|
|
7
|
+
* and a tooltip will appear on hover showing the full content.
|
|
8
|
+
*/
|
|
4
9
|
content?: string | ReactElement;
|
|
5
10
|
}
|
|
6
11
|
/**
|
|
7
12
|
* The `<TextCell>` component is used for displaying text in a table cell.
|
|
8
|
-
* The text is not editable and will be truncated if the cell is too narrow.
|
|
13
|
+
* The text is not editable and will be truncated with an ellipsis if the cell is too narrow.
|
|
14
|
+
* When truncated, a tooltip automatically appears on hover showing the full content.
|
|
9
15
|
*
|
|
16
|
+
* ### When to use
|
|
17
|
+
* - Display simple text values in table columns (names, descriptions, statuses)
|
|
18
|
+
* - When text content might be longer than the column width
|
|
19
|
+
* - For read-only text display in data grids
|
|
20
|
+
*
|
|
21
|
+
* ### When not to use
|
|
22
|
+
* - For numeric values - use `NumberCell` instead
|
|
23
|
+
* - For dates and times - use `DateTimeCell` instead
|
|
24
|
+
* - For clickable links - use `LinkCell` or `ButtonCell` instead
|
|
25
|
+
* - For multi-line content - consider `IdentityCell` with details
|
|
26
|
+
*
|
|
27
|
+
* @example Basic usage
|
|
28
|
+
* ```tsx
|
|
29
|
+
* import { TextCell } from "@trackunit/react-table-base-components";
|
|
30
|
+
* import { createColumnHelper } from "@tanstack/react-table";
|
|
31
|
+
*
|
|
32
|
+
* const columnHelper = createColumnHelper<Asset>();
|
|
33
|
+
*
|
|
34
|
+
* const columns = [
|
|
35
|
+
* columnHelper.accessor("name", {
|
|
36
|
+
* header: "Name",
|
|
37
|
+
* cell: ({ getValue }) => <TextCell content={getValue()} />,
|
|
38
|
+
* }),
|
|
39
|
+
* ];
|
|
40
|
+
* ```
|
|
41
|
+
* @example With custom content
|
|
42
|
+
* ```tsx
|
|
43
|
+
* import { TextCell } from "@trackunit/react-table-base-components";
|
|
44
|
+
*
|
|
45
|
+
* // Text content - will show tooltip if truncated
|
|
46
|
+
* <TextCell content="This is a long description that might get truncated" />
|
|
47
|
+
*
|
|
48
|
+
* // ReactElement content
|
|
49
|
+
* <TextCell content={<span className="font-bold">Bold text</span>} />
|
|
50
|
+
* ```
|
|
10
51
|
* @param {TextCellProps} props - The props for the TextCell component
|
|
11
52
|
* @returns {ReactElement} TextCell component
|
|
12
53
|
*/
|