@trackunit/react-table-base-components 1.17.22-alpha-192bcb42ded.0 → 1.17.24
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 +126 -31
- package/index.esm.js +127 -33
- package/package.json +8 -7
- package/src/components/CopyableCell/CopyableCell.d.ts +44 -0
- package/src/components/CopyableCell/CopyableCell.variants.d.ts +1 -0
- package/src/index.d.ts +2 -0
- package/src/translation.d.ts +25 -0
- package/translation.cjs.js +7 -0
- package/translation.cjs10.js +7 -0
- package/translation.cjs11.js +7 -0
- package/translation.cjs12.js +7 -0
- package/translation.cjs13.js +7 -0
- package/translation.cjs14.js +7 -0
- package/translation.cjs15.js +7 -0
- package/translation.cjs16.js +7 -0
- package/translation.cjs17.js +7 -0
- package/translation.cjs2.js +7 -0
- package/translation.cjs3.js +7 -0
- package/translation.cjs4.js +7 -0
- package/translation.cjs5.js +7 -0
- package/translation.cjs6.js +7 -0
- package/translation.cjs7.js +7 -0
- package/translation.cjs8.js +7 -0
- package/translation.cjs9.js +7 -0
- package/translation.esm.js +5 -0
- package/translation.esm10.js +5 -0
- package/translation.esm11.js +5 -0
- package/translation.esm12.js +5 -0
- package/translation.esm13.js +5 -0
- package/translation.esm14.js +5 -0
- package/translation.esm15.js +5 -0
- package/translation.esm16.js +5 -0
- package/translation.esm17.js +5 -0
- package/translation.esm2.js +5 -0
- package/translation.esm3.js +5 -0
- package/translation.esm4.js +5 -0
- package/translation.esm5.js +5 -0
- package/translation.esm6.js +5 -0
- package/translation.esm7.js +5 -0
- package/translation.esm8.js +5 -0
- package/translation.esm9.js +5 -0
package/index.cjs.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var i18nLibraryTranslation = require('@trackunit/i18n-library-translation');
|
|
4
5
|
var reactComponents = require('@trackunit/react-components');
|
|
5
6
|
var tailwindMerge = require('tailwind-merge');
|
|
6
7
|
var reactFormComponents = require('@trackunit/react-form-components');
|
|
@@ -9,6 +10,46 @@ var dateAndTimeUtils = require('@trackunit/date-and-time-utils');
|
|
|
9
10
|
var react = require('react');
|
|
10
11
|
var sharedUtils = require('@trackunit/shared-utils');
|
|
11
12
|
|
|
13
|
+
var defaultTranslations = {
|
|
14
|
+
"copyableCell.copied": "Copied!",
|
|
15
|
+
"copyableCell.copy": "Copy"
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const namespace = "react.table-base-components";
|
|
19
|
+
const translations = {
|
|
20
|
+
ns: namespace,
|
|
21
|
+
default: defaultTranslations,
|
|
22
|
+
languages: {
|
|
23
|
+
de: () => Promise.resolve().then(function () { return require('./translation.cjs.js'); }),
|
|
24
|
+
da: () => Promise.resolve().then(function () { return require('./translation.cjs2.js'); }),
|
|
25
|
+
cs: () => Promise.resolve().then(function () { return require('./translation.cjs3.js'); }),
|
|
26
|
+
nl: () => Promise.resolve().then(function () { return require('./translation.cjs4.js'); }),
|
|
27
|
+
fr: () => Promise.resolve().then(function () { return require('./translation.cjs5.js'); }),
|
|
28
|
+
fi: () => Promise.resolve().then(function () { return require('./translation.cjs6.js'); }),
|
|
29
|
+
hu: () => Promise.resolve().then(function () { return require('./translation.cjs7.js'); }),
|
|
30
|
+
it: () => Promise.resolve().then(function () { return require('./translation.cjs8.js'); }),
|
|
31
|
+
nb: () => Promise.resolve().then(function () { return require('./translation.cjs9.js'); }),
|
|
32
|
+
pl: () => Promise.resolve().then(function () { return require('./translation.cjs10.js'); }),
|
|
33
|
+
pt: () => Promise.resolve().then(function () { return require('./translation.cjs11.js'); }),
|
|
34
|
+
ru: () => Promise.resolve().then(function () { return require('./translation.cjs12.js'); }),
|
|
35
|
+
ro: () => Promise.resolve().then(function () { return require('./translation.cjs13.js'); }),
|
|
36
|
+
es: () => Promise.resolve().then(function () { return require('./translation.cjs14.js'); }),
|
|
37
|
+
sv: () => Promise.resolve().then(function () { return require('./translation.cjs15.js'); }),
|
|
38
|
+
ja: () => Promise.resolve().then(function () { return require('./translation.cjs16.js'); }),
|
|
39
|
+
th: () => Promise.resolve().then(function () { return require('./translation.cjs17.js'); }),
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Local useTranslation for this specific library
|
|
44
|
+
*/
|
|
45
|
+
const useTranslation = () => i18nLibraryTranslation.useNamespaceTranslation(namespace);
|
|
46
|
+
/**
|
|
47
|
+
* Registers the translations for this library
|
|
48
|
+
*/
|
|
49
|
+
const setupLibraryTranslations = () => {
|
|
50
|
+
i18nLibraryTranslation.registerTranslations(translations);
|
|
51
|
+
};
|
|
52
|
+
|
|
12
53
|
/**
|
|
13
54
|
* The `<ButtonCell>` component renders an interactive button within a table cell.
|
|
14
55
|
* Uses a ghost-neutral variant by default for subtle inline actions.
|
|
@@ -110,6 +151,81 @@ const CheckboxCell = ({ checked, className, "data-testid": dataTestId }) => {
|
|
|
110
151
|
return (jsxRuntime.jsx("div", { className: cvaCheckboxCell({ className }), "data-testid": dataTestId, children: jsxRuntime.jsx(reactFormComponents.Checkbox, { checked: checked, readOnly: true }) }));
|
|
111
152
|
};
|
|
112
153
|
|
|
154
|
+
const cvaMultiRowTableCellSection = cssClassVarianceUtilities.cvaMerge(["flex", "flex-col", "justify-center", "overflow-hidden"]);
|
|
155
|
+
const cvaMultiRowTableCell = cssClassVarianceUtilities.cvaMerge(["flex", "justify-start"]);
|
|
156
|
+
const cvaMainRowText = cssClassVarianceUtilities.cvaMerge(["overflow-hidden", "text-ellipsis", "text-sm"]);
|
|
157
|
+
const cvaSecondaryRowText = cssClassVarianceUtilities.cvaMerge(["overflow-hidden", "text-ellipsis", "text-neutral-500", "text-xs"]);
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* MultiRowTableCell renders two stacked rows inside a single table cell — a primary `main` row
|
|
161
|
+
* and a secondary row below it. String values are automatically styled with appropriate text sizes.
|
|
162
|
+
*
|
|
163
|
+
* ### When to use
|
|
164
|
+
* Use MultiRowTableCell when a table cell needs to display a primary value with secondary metadata below —
|
|
165
|
+
* for example, an asset name with its serial number, or a user name with their email.
|
|
166
|
+
*
|
|
167
|
+
* ### When not to use
|
|
168
|
+
* Do not use MultiRowTableCell for single-line text — use `TextCell`.
|
|
169
|
+
*
|
|
170
|
+
* @example Name with description in a table cell
|
|
171
|
+
* ```tsx
|
|
172
|
+
* import { MultiRowTableCell } from "@trackunit/react-table-base-components";
|
|
173
|
+
*
|
|
174
|
+
* const cell = ({ row }) => (
|
|
175
|
+
* <MultiRowTableCell main={row.original.name} secondary={row.original.serialNumber} />
|
|
176
|
+
* );
|
|
177
|
+
* ```
|
|
178
|
+
* @param {MultiRowTableCellProps} props - The props for the MultiRowTableCell component
|
|
179
|
+
* @returns {ReactElement} MultiRowTableCell component
|
|
180
|
+
*/
|
|
181
|
+
const MultiRowTableCell = ({ main, secondary, "data-testid": dataTestId, className, }) => {
|
|
182
|
+
return (jsxRuntime.jsx("div", { className: cvaMultiRowTableCell({ className }), children: jsxRuntime.jsxs("section", { className: cvaMultiRowTableCellSection(), "data-testid": dataTestId, children: [typeof main === "string" ? jsxRuntime.jsx("div", { className: cvaMainRowText(), children: main }) : main, typeof secondary === "string" && secondary !== "" ? (jsxRuntime.jsx("div", { className: cvaSecondaryRowText(), children: secondary })) : (secondary)] }) }));
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
const cvaCopyableCell = cssClassVarianceUtilities.cvaMerge(["overflow-hidden", "w-fit"]);
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* CopyableCell renders a table cell with click-to-copy functionality.
|
|
189
|
+
* Supports single-line and multi-line layouts.
|
|
190
|
+
*
|
|
191
|
+
* ### When to use
|
|
192
|
+
* Use CopyableCell inside table column definitions when a cell value (ID, name, reference) should be copyable.
|
|
193
|
+
*
|
|
194
|
+
* ### When not to use
|
|
195
|
+
* For standalone copyable text outside of tables, use `CopyableText` from `@trackunit/react-components`.
|
|
196
|
+
*
|
|
197
|
+
* @example Single-line copyable cell
|
|
198
|
+
* ```tsx
|
|
199
|
+
* import { CopyableCell } from "@trackunit/react-table-base-components";
|
|
200
|
+
*
|
|
201
|
+
* const cell = ({ getValue }) => (
|
|
202
|
+
* <CopyableCell text={getValue()} />
|
|
203
|
+
* );
|
|
204
|
+
* ```
|
|
205
|
+
* @example Multi-line copyable cell
|
|
206
|
+
* ```tsx
|
|
207
|
+
* import { CopyableCell } from "@trackunit/react-table-base-components";
|
|
208
|
+
*
|
|
209
|
+
* const cell = ({ row }) => (
|
|
210
|
+
* <CopyableCell
|
|
211
|
+
* text={String(row.original.customerId)}
|
|
212
|
+
* secondary={{ text: row.original.name }}
|
|
213
|
+
* />
|
|
214
|
+
* );
|
|
215
|
+
* ```
|
|
216
|
+
* @param {CopyableCellProps} props - The props for the CopyableCell component
|
|
217
|
+
* @returns {ReactElement} CopyableCell component
|
|
218
|
+
*/
|
|
219
|
+
const CopyableCell = ({ text, secondary, "data-testid": dataTestId, className, }) => {
|
|
220
|
+
const [t] = useTranslation();
|
|
221
|
+
const copyLabel = t("copyableCell.copy");
|
|
222
|
+
const copiedLabel = t("copyableCell.copied");
|
|
223
|
+
if (secondary !== undefined) {
|
|
224
|
+
return (jsxRuntime.jsx(MultiRowTableCell, { className: cvaCopyableCell({ className }), "data-testid": dataTestId, main: jsxRuntime.jsx(reactComponents.CopyableText, { className: "self-start", copiedLabel: copiedLabel, copyLabel: copyLabel, text: text }), secondary: jsxRuntime.jsx(reactComponents.CopyableText, { className: "self-start", copiedLabel: copiedLabel, copyLabel: copyLabel, size: "xs", text: secondary.text }) }));
|
|
225
|
+
}
|
|
226
|
+
return (jsxRuntime.jsx(reactComponents.CopyableText, { className: cvaCopyableCell({ className }), copiedLabel: copiedLabel, copyLabel: copyLabel, "data-testid": dataTestId, text: text }));
|
|
227
|
+
};
|
|
228
|
+
|
|
113
229
|
const cvaDateTimeCell = cssClassVarianceUtilities.cvaMerge([""]);
|
|
114
230
|
const cvaDateTime$1 = cssClassVarianceUtilities.cvaMerge(["slashed-zero", "text-sm", "text-ellipsis"]);
|
|
115
231
|
const cvaDateTimeSince$1 = cssClassVarianceUtilities.cvaMerge(["slashed-zero", "text-neutral-500", "text-xs", "text-ellipsis"]);
|
|
@@ -450,37 +566,6 @@ const LinkCell = ({ link, type, className, ref, ...rest }) => {
|
|
|
450
566
|
return (jsxRuntime.jsx(reactComponents.ExternalLink, { className: cvaLinkCell({ className }), href: `${linkPrefix}${link}`, ref: ref, ...rest, color: "neutral", onClick: handleClick, children: link }));
|
|
451
567
|
};
|
|
452
568
|
|
|
453
|
-
const cvaMultiRowTableCellSection = cssClassVarianceUtilities.cvaMerge(["flex", "flex-col", "justify-center", "overflow-hidden"]);
|
|
454
|
-
const cvaMultiRowTableCell = cssClassVarianceUtilities.cvaMerge(["flex", "justify-start"]);
|
|
455
|
-
const cvaMainRowText = cssClassVarianceUtilities.cvaMerge(["overflow-hidden", "text-ellipsis", "text-sm"]);
|
|
456
|
-
const cvaSecondaryRowText = cssClassVarianceUtilities.cvaMerge(["overflow-hidden", "text-ellipsis", "text-neutral-500", "text-xs"]);
|
|
457
|
-
|
|
458
|
-
/**
|
|
459
|
-
* MultiRowTableCell renders two stacked rows inside a single table cell — a primary `main` row
|
|
460
|
-
* and a secondary row below it. String values are automatically styled with appropriate text sizes.
|
|
461
|
-
*
|
|
462
|
-
* ### When to use
|
|
463
|
-
* Use MultiRowTableCell when a table cell needs to display a primary value with secondary metadata below —
|
|
464
|
-
* for example, an asset name with its serial number, or a user name with their email.
|
|
465
|
-
*
|
|
466
|
-
* ### When not to use
|
|
467
|
-
* Do not use MultiRowTableCell for single-line text — use `TextCell`.
|
|
468
|
-
*
|
|
469
|
-
* @example Name with description in a table cell
|
|
470
|
-
* ```tsx
|
|
471
|
-
* import { MultiRowTableCell } from "@trackunit/react-table-base-components";
|
|
472
|
-
*
|
|
473
|
-
* const cell = ({ row }) => (
|
|
474
|
-
* <MultiRowTableCell main={row.original.name} secondary={row.original.serialNumber} />
|
|
475
|
-
* );
|
|
476
|
-
* ```
|
|
477
|
-
* @param {MultiRowTableCellProps} props - The props for the MultiRowTableCell component
|
|
478
|
-
* @returns {ReactElement} MultiRowTableCell component
|
|
479
|
-
*/
|
|
480
|
-
const MultiRowTableCell = ({ main, secondary, "data-testid": dataTestId, className, }) => {
|
|
481
|
-
return (jsxRuntime.jsx("div", { className: cvaMultiRowTableCell({ className }), children: jsxRuntime.jsxs("section", { className: cvaMultiRowTableCellSection(), "data-testid": dataTestId, children: [typeof main === "string" ? jsxRuntime.jsx("div", { className: cvaMainRowText(), children: main }) : main, typeof secondary === "string" && secondary !== "" ? (jsxRuntime.jsx("div", { className: cvaSecondaryRowText(), children: secondary })) : (secondary)] }) }));
|
|
482
|
-
};
|
|
483
|
-
|
|
484
569
|
/**
|
|
485
570
|
* Generic list to be used as tooltip content.
|
|
486
571
|
* The component is data-shape agnostic. It supports primitives, React elements,
|
|
@@ -1201,8 +1286,18 @@ const cvaTr = cssClassVarianceUtilities.cvaMerge(["w-full", "h-max", "border-b",
|
|
|
1201
1286
|
},
|
|
1202
1287
|
});
|
|
1203
1288
|
|
|
1289
|
+
/*
|
|
1290
|
+
* ----------------------------
|
|
1291
|
+
* | SETUP TRANSLATIONS START |
|
|
1292
|
+
* ----------------------------
|
|
1293
|
+
* This import and function call is needed to register translations for this library.
|
|
1294
|
+
* Do not remove this if this library has translations.
|
|
1295
|
+
*/
|
|
1296
|
+
setupLibraryTranslations();
|
|
1297
|
+
|
|
1204
1298
|
exports.ButtonCell = ButtonCell;
|
|
1205
1299
|
exports.CheckboxCell = CheckboxCell;
|
|
1300
|
+
exports.CopyableCell = CopyableCell;
|
|
1206
1301
|
exports.DateTimeCell = DateTimeCell;
|
|
1207
1302
|
exports.HighlightCell = HighlightCell;
|
|
1208
1303
|
exports.IdentityCell = IdentityCell;
|
package/index.esm.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
-
import {
|
|
2
|
+
import { registerTranslations, useNamespaceTranslation } from '@trackunit/i18n-library-translation';
|
|
3
|
+
import { Button, Icon, CopyableText, Highlight, Heading, ExternalLink, DetailsList, Indicator, Spinner, Tooltip, Text, Tag, Notice, IconButton, MoreMenu, MenuList, MenuItem, MenuDivider, useMergeRefs } from '@trackunit/react-components';
|
|
3
4
|
import { twMerge } from 'tailwind-merge';
|
|
4
5
|
import { Checkbox } from '@trackunit/react-form-components';
|
|
5
6
|
import { cvaMerge } from '@trackunit/css-class-variance-utilities';
|
|
@@ -7,6 +8,46 @@ import { formatDateUtil, timeSinceAuto, timeSinceInDays, Temporal } from '@track
|
|
|
7
8
|
import { useMemo, useState, useEffect, isValidElement, cloneElement } from 'react';
|
|
8
9
|
import { DateTimeFormat } from '@trackunit/shared-utils';
|
|
9
10
|
|
|
11
|
+
var defaultTranslations = {
|
|
12
|
+
"copyableCell.copied": "Copied!",
|
|
13
|
+
"copyableCell.copy": "Copy"
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const namespace = "react.table-base-components";
|
|
17
|
+
const translations = {
|
|
18
|
+
ns: namespace,
|
|
19
|
+
default: defaultTranslations,
|
|
20
|
+
languages: {
|
|
21
|
+
de: () => import('./translation.esm.js'),
|
|
22
|
+
da: () => import('./translation.esm2.js'),
|
|
23
|
+
cs: () => import('./translation.esm3.js'),
|
|
24
|
+
nl: () => import('./translation.esm4.js'),
|
|
25
|
+
fr: () => import('./translation.esm5.js'),
|
|
26
|
+
fi: () => import('./translation.esm6.js'),
|
|
27
|
+
hu: () => import('./translation.esm7.js'),
|
|
28
|
+
it: () => import('./translation.esm8.js'),
|
|
29
|
+
nb: () => import('./translation.esm9.js'),
|
|
30
|
+
pl: () => import('./translation.esm10.js'),
|
|
31
|
+
pt: () => import('./translation.esm11.js'),
|
|
32
|
+
ru: () => import('./translation.esm12.js'),
|
|
33
|
+
ro: () => import('./translation.esm13.js'),
|
|
34
|
+
es: () => import('./translation.esm14.js'),
|
|
35
|
+
sv: () => import('./translation.esm15.js'),
|
|
36
|
+
ja: () => import('./translation.esm16.js'),
|
|
37
|
+
th: () => import('./translation.esm17.js'),
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Local useTranslation for this specific library
|
|
42
|
+
*/
|
|
43
|
+
const useTranslation = () => useNamespaceTranslation(namespace);
|
|
44
|
+
/**
|
|
45
|
+
* Registers the translations for this library
|
|
46
|
+
*/
|
|
47
|
+
const setupLibraryTranslations = () => {
|
|
48
|
+
registerTranslations(translations);
|
|
49
|
+
};
|
|
50
|
+
|
|
10
51
|
/**
|
|
11
52
|
* The `<ButtonCell>` component renders an interactive button within a table cell.
|
|
12
53
|
* Uses a ghost-neutral variant by default for subtle inline actions.
|
|
@@ -108,6 +149,81 @@ const CheckboxCell = ({ checked, className, "data-testid": dataTestId }) => {
|
|
|
108
149
|
return (jsx("div", { className: cvaCheckboxCell({ className }), "data-testid": dataTestId, children: jsx(Checkbox, { checked: checked, readOnly: true }) }));
|
|
109
150
|
};
|
|
110
151
|
|
|
152
|
+
const cvaMultiRowTableCellSection = cvaMerge(["flex", "flex-col", "justify-center", "overflow-hidden"]);
|
|
153
|
+
const cvaMultiRowTableCell = cvaMerge(["flex", "justify-start"]);
|
|
154
|
+
const cvaMainRowText = cvaMerge(["overflow-hidden", "text-ellipsis", "text-sm"]);
|
|
155
|
+
const cvaSecondaryRowText = cvaMerge(["overflow-hidden", "text-ellipsis", "text-neutral-500", "text-xs"]);
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* MultiRowTableCell renders two stacked rows inside a single table cell — a primary `main` row
|
|
159
|
+
* and a secondary row below it. String values are automatically styled with appropriate text sizes.
|
|
160
|
+
*
|
|
161
|
+
* ### When to use
|
|
162
|
+
* Use MultiRowTableCell when a table cell needs to display a primary value with secondary metadata below —
|
|
163
|
+
* for example, an asset name with its serial number, or a user name with their email.
|
|
164
|
+
*
|
|
165
|
+
* ### When not to use
|
|
166
|
+
* Do not use MultiRowTableCell for single-line text — use `TextCell`.
|
|
167
|
+
*
|
|
168
|
+
* @example Name with description in a table cell
|
|
169
|
+
* ```tsx
|
|
170
|
+
* import { MultiRowTableCell } from "@trackunit/react-table-base-components";
|
|
171
|
+
*
|
|
172
|
+
* const cell = ({ row }) => (
|
|
173
|
+
* <MultiRowTableCell main={row.original.name} secondary={row.original.serialNumber} />
|
|
174
|
+
* );
|
|
175
|
+
* ```
|
|
176
|
+
* @param {MultiRowTableCellProps} props - The props for the MultiRowTableCell component
|
|
177
|
+
* @returns {ReactElement} MultiRowTableCell component
|
|
178
|
+
*/
|
|
179
|
+
const MultiRowTableCell = ({ main, secondary, "data-testid": dataTestId, className, }) => {
|
|
180
|
+
return (jsx("div", { className: cvaMultiRowTableCell({ className }), children: jsxs("section", { className: cvaMultiRowTableCellSection(), "data-testid": dataTestId, children: [typeof main === "string" ? jsx("div", { className: cvaMainRowText(), children: main }) : main, typeof secondary === "string" && secondary !== "" ? (jsx("div", { className: cvaSecondaryRowText(), children: secondary })) : (secondary)] }) }));
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
const cvaCopyableCell = cvaMerge(["overflow-hidden", "w-fit"]);
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* CopyableCell renders a table cell with click-to-copy functionality.
|
|
187
|
+
* Supports single-line and multi-line layouts.
|
|
188
|
+
*
|
|
189
|
+
* ### When to use
|
|
190
|
+
* Use CopyableCell inside table column definitions when a cell value (ID, name, reference) should be copyable.
|
|
191
|
+
*
|
|
192
|
+
* ### When not to use
|
|
193
|
+
* For standalone copyable text outside of tables, use `CopyableText` from `@trackunit/react-components`.
|
|
194
|
+
*
|
|
195
|
+
* @example Single-line copyable cell
|
|
196
|
+
* ```tsx
|
|
197
|
+
* import { CopyableCell } from "@trackunit/react-table-base-components";
|
|
198
|
+
*
|
|
199
|
+
* const cell = ({ getValue }) => (
|
|
200
|
+
* <CopyableCell text={getValue()} />
|
|
201
|
+
* );
|
|
202
|
+
* ```
|
|
203
|
+
* @example Multi-line copyable cell
|
|
204
|
+
* ```tsx
|
|
205
|
+
* import { CopyableCell } from "@trackunit/react-table-base-components";
|
|
206
|
+
*
|
|
207
|
+
* const cell = ({ row }) => (
|
|
208
|
+
* <CopyableCell
|
|
209
|
+
* text={String(row.original.customerId)}
|
|
210
|
+
* secondary={{ text: row.original.name }}
|
|
211
|
+
* />
|
|
212
|
+
* );
|
|
213
|
+
* ```
|
|
214
|
+
* @param {CopyableCellProps} props - The props for the CopyableCell component
|
|
215
|
+
* @returns {ReactElement} CopyableCell component
|
|
216
|
+
*/
|
|
217
|
+
const CopyableCell = ({ text, secondary, "data-testid": dataTestId, className, }) => {
|
|
218
|
+
const [t] = useTranslation();
|
|
219
|
+
const copyLabel = t("copyableCell.copy");
|
|
220
|
+
const copiedLabel = t("copyableCell.copied");
|
|
221
|
+
if (secondary !== undefined) {
|
|
222
|
+
return (jsx(MultiRowTableCell, { className: cvaCopyableCell({ className }), "data-testid": dataTestId, main: jsx(CopyableText, { className: "self-start", copiedLabel: copiedLabel, copyLabel: copyLabel, text: text }), secondary: jsx(CopyableText, { className: "self-start", copiedLabel: copiedLabel, copyLabel: copyLabel, size: "xs", text: secondary.text }) }));
|
|
223
|
+
}
|
|
224
|
+
return (jsx(CopyableText, { className: cvaCopyableCell({ className }), copiedLabel: copiedLabel, copyLabel: copyLabel, "data-testid": dataTestId, text: text }));
|
|
225
|
+
};
|
|
226
|
+
|
|
111
227
|
const cvaDateTimeCell = cvaMerge([""]);
|
|
112
228
|
const cvaDateTime$1 = cvaMerge(["slashed-zero", "text-sm", "text-ellipsis"]);
|
|
113
229
|
const cvaDateTimeSince$1 = cvaMerge(["slashed-zero", "text-neutral-500", "text-xs", "text-ellipsis"]);
|
|
@@ -448,37 +564,6 @@ const LinkCell = ({ link, type, className, ref, ...rest }) => {
|
|
|
448
564
|
return (jsx(ExternalLink, { className: cvaLinkCell({ className }), href: `${linkPrefix}${link}`, ref: ref, ...rest, color: "neutral", onClick: handleClick, children: link }));
|
|
449
565
|
};
|
|
450
566
|
|
|
451
|
-
const cvaMultiRowTableCellSection = cvaMerge(["flex", "flex-col", "justify-center", "overflow-hidden"]);
|
|
452
|
-
const cvaMultiRowTableCell = cvaMerge(["flex", "justify-start"]);
|
|
453
|
-
const cvaMainRowText = cvaMerge(["overflow-hidden", "text-ellipsis", "text-sm"]);
|
|
454
|
-
const cvaSecondaryRowText = cvaMerge(["overflow-hidden", "text-ellipsis", "text-neutral-500", "text-xs"]);
|
|
455
|
-
|
|
456
|
-
/**
|
|
457
|
-
* MultiRowTableCell renders two stacked rows inside a single table cell — a primary `main` row
|
|
458
|
-
* and a secondary row below it. String values are automatically styled with appropriate text sizes.
|
|
459
|
-
*
|
|
460
|
-
* ### When to use
|
|
461
|
-
* Use MultiRowTableCell when a table cell needs to display a primary value with secondary metadata below —
|
|
462
|
-
* for example, an asset name with its serial number, or a user name with their email.
|
|
463
|
-
*
|
|
464
|
-
* ### When not to use
|
|
465
|
-
* Do not use MultiRowTableCell for single-line text — use `TextCell`.
|
|
466
|
-
*
|
|
467
|
-
* @example Name with description in a table cell
|
|
468
|
-
* ```tsx
|
|
469
|
-
* import { MultiRowTableCell } from "@trackunit/react-table-base-components";
|
|
470
|
-
*
|
|
471
|
-
* const cell = ({ row }) => (
|
|
472
|
-
* <MultiRowTableCell main={row.original.name} secondary={row.original.serialNumber} />
|
|
473
|
-
* );
|
|
474
|
-
* ```
|
|
475
|
-
* @param {MultiRowTableCellProps} props - The props for the MultiRowTableCell component
|
|
476
|
-
* @returns {ReactElement} MultiRowTableCell component
|
|
477
|
-
*/
|
|
478
|
-
const MultiRowTableCell = ({ main, secondary, "data-testid": dataTestId, className, }) => {
|
|
479
|
-
return (jsx("div", { className: cvaMultiRowTableCell({ className }), children: jsxs("section", { className: cvaMultiRowTableCellSection(), "data-testid": dataTestId, children: [typeof main === "string" ? jsx("div", { className: cvaMainRowText(), children: main }) : main, typeof secondary === "string" && secondary !== "" ? (jsx("div", { className: cvaSecondaryRowText(), children: secondary })) : (secondary)] }) }));
|
|
480
|
-
};
|
|
481
|
-
|
|
482
567
|
/**
|
|
483
568
|
* Generic list to be used as tooltip content.
|
|
484
569
|
* The component is data-shape agnostic. It supports primitives, React elements,
|
|
@@ -1199,4 +1284,13 @@ const cvaTr = cvaMerge(["w-full", "h-max", "border-b", "border-neutral-200"], {
|
|
|
1199
1284
|
},
|
|
1200
1285
|
});
|
|
1201
1286
|
|
|
1202
|
-
|
|
1287
|
+
/*
|
|
1288
|
+
* ----------------------------
|
|
1289
|
+
* | SETUP TRANSLATIONS START |
|
|
1290
|
+
* ----------------------------
|
|
1291
|
+
* This import and function call is needed to register translations for this library.
|
|
1292
|
+
* Do not remove this if this library has translations.
|
|
1293
|
+
*/
|
|
1294
|
+
setupLibraryTranslations();
|
|
1295
|
+
|
|
1296
|
+
export { ButtonCell, CheckboxCell, CopyableCell, DateTimeCell, HighlightCell, IdentityCell, ImageCell, IndicatorCell, LinkCell, ListTooltip, MultiRowTableCell, MultiValueTextCell, NoticeCell, NumberCell, PlainDateCell, ResizeHandle, RowActions, SortIndicator, TableRoot, TagsCell, Tbody, Td, TextCell, Tfoot, Th, Thead, Tr };
|
package/package.json
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/react-table-base-components",
|
|
3
|
-
"version": "1.17.
|
|
3
|
+
"version": "1.17.24",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"engines": {
|
|
7
7
|
"node": ">=24.x"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@trackunit/react-components": "1.20.
|
|
11
|
-
"@trackunit/ui-icons": "1.11.83
|
|
12
|
-
"@trackunit/react-form-components": "1.18.
|
|
13
|
-
"@trackunit/css-class-variance-utilities": "1.11.87
|
|
14
|
-
"@trackunit/date-and-time-utils": "1.11.89
|
|
15
|
-
"@trackunit/shared-utils": "1.13.87
|
|
10
|
+
"@trackunit/react-components": "1.20.18",
|
|
11
|
+
"@trackunit/ui-icons": "1.11.83",
|
|
12
|
+
"@trackunit/react-form-components": "1.18.24",
|
|
13
|
+
"@trackunit/css-class-variance-utilities": "1.11.87",
|
|
14
|
+
"@trackunit/date-and-time-utils": "1.11.89",
|
|
15
|
+
"@trackunit/shared-utils": "1.13.87",
|
|
16
|
+
"@trackunit/i18n-library-translation": "1.15.18",
|
|
16
17
|
"tailwind-merge": "^2.0.0"
|
|
17
18
|
},
|
|
18
19
|
"peerDependencies": {
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { CommonProps, type CopyableTextProps } from "@trackunit/react-components";
|
|
2
|
+
import type { ReactElement } from "react";
|
|
3
|
+
type CopyableCellSecondary = Pick<CopyableTextProps, "text">;
|
|
4
|
+
export interface CopyableCellProps extends CommonProps, Pick<CopyableTextProps, "text"> {
|
|
5
|
+
/**
|
|
6
|
+
* When provided, renders a multi-line cell with a secondary row below the primary.
|
|
7
|
+
* The secondary row is independently copyable.
|
|
8
|
+
*/
|
|
9
|
+
readonly secondary?: CopyableCellSecondary;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* CopyableCell renders a table cell with click-to-copy functionality.
|
|
13
|
+
* Supports single-line and multi-line layouts.
|
|
14
|
+
*
|
|
15
|
+
* ### When to use
|
|
16
|
+
* Use CopyableCell inside table column definitions when a cell value (ID, name, reference) should be copyable.
|
|
17
|
+
*
|
|
18
|
+
* ### When not to use
|
|
19
|
+
* For standalone copyable text outside of tables, use `CopyableText` from `@trackunit/react-components`.
|
|
20
|
+
*
|
|
21
|
+
* @example Single-line copyable cell
|
|
22
|
+
* ```tsx
|
|
23
|
+
* import { CopyableCell } from "@trackunit/react-table-base-components";
|
|
24
|
+
*
|
|
25
|
+
* const cell = ({ getValue }) => (
|
|
26
|
+
* <CopyableCell text={getValue()} />
|
|
27
|
+
* );
|
|
28
|
+
* ```
|
|
29
|
+
* @example Multi-line copyable cell
|
|
30
|
+
* ```tsx
|
|
31
|
+
* import { CopyableCell } from "@trackunit/react-table-base-components";
|
|
32
|
+
*
|
|
33
|
+
* const cell = ({ row }) => (
|
|
34
|
+
* <CopyableCell
|
|
35
|
+
* text={String(row.original.customerId)}
|
|
36
|
+
* secondary={{ text: row.original.name }}
|
|
37
|
+
* />
|
|
38
|
+
* );
|
|
39
|
+
* ```
|
|
40
|
+
* @param {CopyableCellProps} props - The props for the CopyableCell component
|
|
41
|
+
* @returns {ReactElement} CopyableCell component
|
|
42
|
+
*/
|
|
43
|
+
export declare const CopyableCell: ({ text, secondary, "data-testid": dataTestId, className, }: CopyableCellProps) => ReactElement;
|
|
44
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const cvaCopyableCell: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
package/src/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export * from "./components/ButtonCell/ButtonCell";
|
|
2
2
|
export * from "./components/CheckboxCell/CheckboxCell";
|
|
3
|
+
export { CopyableCell } from "./components/CopyableCell/CopyableCell";
|
|
4
|
+
export type { CopyableCellProps } from "./components/CopyableCell/CopyableCell";
|
|
3
5
|
export * from "./components/DateTimeCell/DateTimeCell";
|
|
4
6
|
export { HighlightCell } from "./components/HighlightCell/HighlightCell";
|
|
5
7
|
export type { HighlightCellProps } from "./components/HighlightCell/HighlightCell";
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { NamespaceTransProps, TransForLibs, TranslationResource } from "@trackunit/i18n-library-translation";
|
|
2
|
+
import defaultTranslations from "./locales/en/translation.json";
|
|
3
|
+
export type TranslationKeys = keyof typeof defaultTranslations;
|
|
4
|
+
export declare const namespace = "react.table-base-components";
|
|
5
|
+
export declare const translations: TranslationResource<TranslationKeys>;
|
|
6
|
+
/**
|
|
7
|
+
* Local useTranslation for this specific library
|
|
8
|
+
*/
|
|
9
|
+
export declare const useTranslation: () => [TransForLibs<"copyableCell.copied" | "copyableCell.copy">, import("i18next").i18n, boolean] & {
|
|
10
|
+
t: TransForLibs<"copyableCell.copied" | "copyableCell.copy">;
|
|
11
|
+
i18n: import("i18next").i18n;
|
|
12
|
+
ready: boolean;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Type of the t function for the local useTranslation for this specific library
|
|
16
|
+
*/
|
|
17
|
+
export type TranslationFunction = TransForLibs<TranslationKeys>;
|
|
18
|
+
/**
|
|
19
|
+
* Trans for this specific library.
|
|
20
|
+
*/
|
|
21
|
+
export declare const Trans: (props: NamespaceTransProps<TranslationKeys>) => import("react/jsx-runtime").JSX.Element;
|
|
22
|
+
/**
|
|
23
|
+
* Registers the translations for this library
|
|
24
|
+
*/
|
|
25
|
+
export declare const setupLibraryTranslations: () => void;
|