@trackunit/react-table-base-components 1.7.45 → 1.7.48
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
|
@@ -111,8 +111,18 @@ const cvaIdentityCellLayout = cssClassVarianceUtilities.cvaMerge(["grid", "items
|
|
|
111
111
|
* @param {IdentityCellProps} props - The props for the LinkCell component
|
|
112
112
|
* @returns {ReactElement} LinkCell component
|
|
113
113
|
*/
|
|
114
|
-
const IdentityCell = ({ className, dataTestId, density = "default", title, details = [], thumbnail, }) => {
|
|
115
|
-
|
|
114
|
+
const IdentityCell = ({ link, className, dataTestId, density = "default", title, details = [], thumbnail, }) => {
|
|
115
|
+
const [href, setHref] = react.useState(undefined);
|
|
116
|
+
react.useEffect(() => {
|
|
117
|
+
if (link) {
|
|
118
|
+
link.href().then(setHref);
|
|
119
|
+
}
|
|
120
|
+
}, [link]);
|
|
121
|
+
return (jsxRuntime.jsxs("div", { className: cvaIdentityCell({ className, density, hasThumbnail: !!thumbnail }), "data-testid": dataTestId, children: [thumbnail ? (jsxRuntime.jsx("div", { className: "mr-1 flex h-8 w-8 items-center justify-center overflow-hidden rounded-md", children: thumbnail })) : null, jsxRuntime.jsxs("div", { className: cvaIdentityCellLayout({ className, density }), children: [jsxRuntime.jsx("div", { className: "gap-responsive-space-sm flex w-full min-w-0 items-center truncate text-sm", children: jsxRuntime.jsx(reactComponents.Heading, { className: "truncate text-sm", dataTestId: dataTestId ? `${dataTestId}-name` : undefined, variant: "tertiary", children: !link ? (title) : (jsxRuntime.jsx(reactComponents.ExternalLink, { color: "neutral", href: href ?? "", onClick: async (e) => {
|
|
122
|
+
e.preventDefault();
|
|
123
|
+
e.stopPropagation();
|
|
124
|
+
await link.goto();
|
|
125
|
+
}, target: "_blank", title: link.title, children: title })) }) }), details.length > 0 && (jsxRuntime.jsx(reactComponents.DetailsList, { className: className, density: density, details: details, hasLink: !!link }))] })] }));
|
|
116
126
|
};
|
|
117
127
|
|
|
118
128
|
/**
|
|
@@ -148,7 +158,7 @@ const LinkCell = ({ link, type, className, ...rest }) => {
|
|
|
148
158
|
const handleClick = (event) => {
|
|
149
159
|
event.stopPropagation();
|
|
150
160
|
};
|
|
151
|
-
return (jsxRuntime.jsx(reactComponents.ExternalLink, { className: cvaLinkCell({ className }), href: `${linkPrefix}${link}`, ...rest, onClick: handleClick, children: link }));
|
|
161
|
+
return (jsxRuntime.jsx(reactComponents.ExternalLink, { className: cvaLinkCell({ className }), href: `${linkPrefix}${link}`, ...rest, color: "neutral", onClick: handleClick, children: link }));
|
|
152
162
|
};
|
|
153
163
|
|
|
154
164
|
const cvaMultiRowTableCellSection = cssClassVarianceUtilities.cvaMerge(["flex", "flex-col", "justify-center", "overflow-hidden"]);
|
package/index.esm.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
-
import { Button, Icon, Highlight, Heading, DetailsList, Indicator,
|
|
2
|
+
import { Button, Icon, Highlight, Heading, ExternalLink, DetailsList, Indicator, Spinner, Tooltip, Tag, Notice, IconButton, MoreMenu, MenuList, MenuItem, MenuDivider } from '@trackunit/react-components';
|
|
3
3
|
import { twMerge } from 'tailwind-merge';
|
|
4
4
|
import { Checkbox } from '@trackunit/react-form-components';
|
|
5
5
|
import { cvaMerge } from '@trackunit/css-class-variance-utilities';
|
|
6
6
|
import { formatDateUtil, timeSinceAuto, timeSinceInDays } from '@trackunit/date-and-time-utils';
|
|
7
|
-
import {
|
|
7
|
+
import { useState, useEffect, isValidElement, cloneElement } from 'react';
|
|
8
8
|
import { Temporal } from '@js-temporal/polyfill';
|
|
9
9
|
import { DateTimeFormat } from '@trackunit/shared-utils';
|
|
10
10
|
|
|
@@ -109,8 +109,18 @@ const cvaIdentityCellLayout = cvaMerge(["grid", "items-center", "text-sm"], {
|
|
|
109
109
|
* @param {IdentityCellProps} props - The props for the LinkCell component
|
|
110
110
|
* @returns {ReactElement} LinkCell component
|
|
111
111
|
*/
|
|
112
|
-
const IdentityCell = ({ className, dataTestId, density = "default", title, details = [], thumbnail, }) => {
|
|
113
|
-
|
|
112
|
+
const IdentityCell = ({ link, className, dataTestId, density = "default", title, details = [], thumbnail, }) => {
|
|
113
|
+
const [href, setHref] = useState(undefined);
|
|
114
|
+
useEffect(() => {
|
|
115
|
+
if (link) {
|
|
116
|
+
link.href().then(setHref);
|
|
117
|
+
}
|
|
118
|
+
}, [link]);
|
|
119
|
+
return (jsxs("div", { className: cvaIdentityCell({ className, density, hasThumbnail: !!thumbnail }), "data-testid": dataTestId, children: [thumbnail ? (jsx("div", { className: "mr-1 flex h-8 w-8 items-center justify-center overflow-hidden rounded-md", children: thumbnail })) : null, jsxs("div", { className: cvaIdentityCellLayout({ className, density }), children: [jsx("div", { className: "gap-responsive-space-sm flex w-full min-w-0 items-center truncate text-sm", children: jsx(Heading, { className: "truncate text-sm", dataTestId: dataTestId ? `${dataTestId}-name` : undefined, variant: "tertiary", children: !link ? (title) : (jsx(ExternalLink, { color: "neutral", href: href ?? "", onClick: async (e) => {
|
|
120
|
+
e.preventDefault();
|
|
121
|
+
e.stopPropagation();
|
|
122
|
+
await link.goto();
|
|
123
|
+
}, target: "_blank", title: link.title, children: title })) }) }), details.length > 0 && (jsx(DetailsList, { className: className, density: density, details: details, hasLink: !!link }))] })] }));
|
|
114
124
|
};
|
|
115
125
|
|
|
116
126
|
/**
|
|
@@ -146,7 +156,7 @@ const LinkCell = ({ link, type, className, ...rest }) => {
|
|
|
146
156
|
const handleClick = (event) => {
|
|
147
157
|
event.stopPropagation();
|
|
148
158
|
};
|
|
149
|
-
return (jsx(ExternalLink, { className: cvaLinkCell({ className }), href: `${linkPrefix}${link}`, ...rest, onClick: handleClick, children: link }));
|
|
159
|
+
return (jsx(ExternalLink, { className: cvaLinkCell({ className }), href: `${linkPrefix}${link}`, ...rest, color: "neutral", onClick: handleClick, children: link }));
|
|
150
160
|
};
|
|
151
161
|
|
|
152
162
|
const cvaMultiRowTableCellSection = cvaMerge(["flex", "flex-col", "justify-center", "overflow-hidden"]);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/react-table-base-components",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.48",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"engines": {
|
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"react": "19.0.0",
|
|
11
|
-
"@trackunit/react-components": "1.9.
|
|
12
|
-
"@trackunit/ui-icons": "1.7.
|
|
13
|
-
"@trackunit/react-form-components": "1.8.
|
|
14
|
-
"@trackunit/css-class-variance-utilities": "1.7.
|
|
15
|
-
"@trackunit/date-and-time-utils": "1.7.
|
|
16
|
-
"@trackunit/shared-utils": "1.9.
|
|
17
|
-
"@trackunit/react-test-setup": "1.4.
|
|
11
|
+
"@trackunit/react-components": "1.9.46",
|
|
12
|
+
"@trackunit/ui-icons": "1.7.33",
|
|
13
|
+
"@trackunit/react-form-components": "1.8.48",
|
|
14
|
+
"@trackunit/css-class-variance-utilities": "1.7.31",
|
|
15
|
+
"@trackunit/date-and-time-utils": "1.7.31",
|
|
16
|
+
"@trackunit/shared-utils": "1.9.31",
|
|
17
|
+
"@trackunit/react-test-setup": "1.4.31",
|
|
18
18
|
"tailwind-merge": "^2.0.0",
|
|
19
19
|
"@js-temporal/polyfill": "^0.5.1"
|
|
20
20
|
},
|
|
@@ -7,6 +7,11 @@ export interface IdentityCellProps extends CommonProps {
|
|
|
7
7
|
title?: ReactNode;
|
|
8
8
|
details?: Array<string>;
|
|
9
9
|
thumbnail?: ReactNode;
|
|
10
|
+
link?: {
|
|
11
|
+
href: () => Promise<string>;
|
|
12
|
+
goto: () => Promise<boolean>;
|
|
13
|
+
title?: string;
|
|
14
|
+
};
|
|
10
15
|
}
|
|
11
16
|
/**
|
|
12
17
|
* The IdentityCell is used for render an identity in a table cell.
|
|
@@ -17,4 +22,4 @@ export interface IdentityCellProps extends CommonProps {
|
|
|
17
22
|
* @param {IdentityCellProps} props - The props for the LinkCell component
|
|
18
23
|
* @returns {ReactElement} LinkCell component
|
|
19
24
|
*/
|
|
20
|
-
export declare const IdentityCell: ({ className, dataTestId, density, title, details, thumbnail, }: IdentityCellProps) => ReactElement;
|
|
25
|
+
export declare const IdentityCell: ({ link, className, dataTestId, density, title, details, thumbnail, }: IdentityCellProps) => ReactElement;
|
|
@@ -5,3 +5,5 @@ declare const meta: Meta<typeof IdentityCell>;
|
|
|
5
5
|
export default meta;
|
|
6
6
|
export declare const packageName: () => import("react/jsx-runtime").JSX.Element;
|
|
7
7
|
export declare const Default: Story;
|
|
8
|
+
export declare const WithoutLink: Story;
|
|
9
|
+
export declare const WithLink: Story;
|