@trackunit/react-components 6.1.10-alpha-a26b9286de8.0 → 7.0.0
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
|
@@ -30,7 +30,8 @@ var defaultTranslations = {
|
|
|
30
30
|
"copyButton.copy": "Copy",
|
|
31
31
|
"horizontalOverflowScroller.scrollLeft": "Scroll left",
|
|
32
32
|
"horizontalOverflowScroller.scrollRight": "Scroll right",
|
|
33
|
-
"moreMenu.buttonLabel": "Show more"
|
|
33
|
+
"moreMenu.buttonLabel": "Show more",
|
|
34
|
+
"spinner.loading": "Loading"
|
|
34
35
|
};
|
|
35
36
|
|
|
36
37
|
/** The translation namespace for this library */
|
|
@@ -1493,11 +1494,11 @@ const useSyncedSpinDelay = (ref, durationMs = DEFAULT_SPIN_DURATION_MS) => {
|
|
|
1493
1494
|
* during short operations (1-5 seconds) such as saving, loading, or refreshing data.
|
|
1494
1495
|
*
|
|
1495
1496
|
* ### When to use
|
|
1496
|
-
* Use Spinner for short-duration loading states: button actions, table refreshes, inline data fetches,
|
|
1497
|
+
* Use Spinner for short-duration loading states: button actions, table refreshes, inline data fetches, modal content loading, or full-page loading when the page layout isn't known yet (a centered Spinner in a full-height container).
|
|
1498
|
+
* Show `EmptyState` only once loading has finished with nothing to show.
|
|
1497
1499
|
*
|
|
1498
1500
|
* ### When not to use
|
|
1499
1501
|
* Do not use Spinner for long loading states where content structure is known — use `SkeletonBlock` or `SkeletonLabel` instead.
|
|
1500
|
-
* Do not use Spinner for full-page loading — use `EmptyState` with `loading` prop.
|
|
1501
1502
|
*
|
|
1502
1503
|
* @example Centered spinner during data load
|
|
1503
1504
|
* ```tsx
|
|
@@ -1528,7 +1529,8 @@ const Spinner = ({ mode = "light", size = "medium", centering = "centered", clas
|
|
|
1528
1529
|
// spinners rendered in other iframes -- since the delay is derived from the shared wall clock.
|
|
1529
1530
|
const spinnerElRef = react.useRef(null);
|
|
1530
1531
|
useSyncedSpinDelay(spinnerElRef);
|
|
1531
|
-
|
|
1532
|
+
const [t] = useTranslation();
|
|
1533
|
+
return (jsxRuntime.jsx("div", { className: cvaSpinnerContainer({ centering, className: containerClassName }), ref: ref, style: style, children: jsxRuntime.jsxs("div", { className: cvaSpinnerContainerInner(), children: [jsxRuntime.jsx("div", { "aria-label": label || t("spinner.loading"), className: cvaSpinner({ size, mode, className }), "data-testid": dataTestId, ref: spinnerElRef, role: "spinbutton" }), label ? jsxRuntime.jsx("span", { className: cvaSpinnerLabel(), children: label }) : null] }) }));
|
|
1532
1534
|
};
|
|
1533
1535
|
|
|
1534
1536
|
const cvaButton = cssClassVarianceUtilities.cva({
|
|
@@ -4846,6 +4848,9 @@ WorkerWithSignSVG.displayName = "WorkerWithSignSVG";
|
|
|
4846
4848
|
* - For guidance purposes (e.g., onboarding, adjusting filters, exploring alternative approaches).
|
|
4847
4849
|
* - In celebratory instances (e.g., no new notifications, services up to date).
|
|
4848
4850
|
*
|
|
4851
|
+
* ## **When not to use**
|
|
4852
|
+
* - While content is loading. Show a `Spinner` (or a skeleton when the shape of the content is known) and render the empty state only once loading has finished with nothing to show.
|
|
4853
|
+
*
|
|
4849
4854
|
* @example Empty state with actions for no search results
|
|
4850
4855
|
* ```tsx
|
|
4851
4856
|
* import { EmptyState } from "@trackunit/react-components";
|
|
@@ -4885,7 +4890,7 @@ WorkerWithSignSVG.displayName = "WorkerWithSignSVG";
|
|
|
4885
4890
|
* );
|
|
4886
4891
|
* ```
|
|
4887
4892
|
*/
|
|
4888
|
-
const EmptyState = ({ description, altText, image = "SEARCH_DOCUMENT", customImageSrc,
|
|
4893
|
+
const EmptyState = ({ description, altText, image = "SEARCH_DOCUMENT", customImageSrc, "data-testid": dataTestId, className, primaryAction, secondaryAction, additionalHelpAction, style, ref, }) => {
|
|
4889
4894
|
const ImageSource = react.useMemo(() => {
|
|
4890
4895
|
switch (image) {
|
|
4891
4896
|
case "WORKER_WITH_SIGN":
|
|
@@ -4908,7 +4913,7 @@ const EmptyState = ({ description, altText, image = "SEARCH_DOCUMENT", customIma
|
|
|
4908
4913
|
const secondaryLink = secondaryAction?.disabled ? undefined : secondaryAction?.to;
|
|
4909
4914
|
const primaryLink = primaryAction?.disabled ? undefined : primaryAction?.to;
|
|
4910
4915
|
const helpLink = additionalHelpAction?.disabled ? undefined : additionalHelpAction?.to;
|
|
4911
|
-
return (jsxRuntime.
|
|
4916
|
+
return (jsxRuntime.jsxs("div", { className: cvaContainerStyles({ className }), "data-testid": dataTestId ?? "empty-state", ref: ref, style: style, children: [customImageSrc !== null && customImageSrc !== undefined ? (typeof customImageSrc === "string" ? (jsxRuntime.jsx("img", { alt: altText, className: cvaImgStyles(), height: 200, src: customImageSrc, width: 200 })) : (customImageSrc)) : (typeof ImageSource !== "undefined" && (jsxRuntime.jsx(ImageSource, { "data-testid": "empty-state-image", height: 200, width: 200 }, image))), description !== undefined && description !== "" ? (jsxRuntime.jsx(Text, { align: "center", size: "medium", children: description })) : null, jsxRuntime.jsxs("div", { className: "mt-4 grid gap-3", children: [primaryAction || secondaryAction ? (jsxRuntime.jsxs("div", { className: "flex justify-center gap-3", "data-testid": "empty-state-actions", children: [secondaryAction ? (jsxRuntime.jsx(Button, { asChild: Boolean(secondaryLink), "data-testid": "empty-state-secondary-button", disabled: secondaryAction.disabled, onClick: secondaryAction.onClick, variant: "secondary", children: secondaryLink ? (jsxRuntime.jsx(reactRouter.Link, { params: secondaryLink.parameters, to: secondaryLink.pathname, children: secondaryAction.title })) : (secondaryAction.title) })) : null, primaryAction ? (jsxRuntime.jsx(Button, { asChild: Boolean(primaryLink), "data-testid": "empty-state-primary-button", disabled: primaryAction.disabled, onClick: primaryAction.onClick, children: primaryLink ? (jsxRuntime.jsx(reactRouter.Link, { params: primaryLink.parameters, to: primaryLink.pathname, children: primaryAction.title })) : (primaryAction.title) })) : null] })) : null, additionalHelpAction?.to ? (jsxRuntime.jsx(Button, { asChild: Boolean(helpLink), "data-testid": "empty-state-additional-button", disabled: additionalHelpAction.disabled, onClick: additionalHelpAction.onClick, suffix: jsxRuntime.jsx(Icon, { name: "ArrowTopRightOnSquare", size: "small" }), variant: "ghost", children: helpLink ? (jsxRuntime.jsx(reactRouter.Link, { params: helpLink.parameters, target: helpLink.target, to: helpLink.pathname, children: additionalHelpAction.title })) : (additionalHelpAction.title) })) : null] })] }));
|
|
4912
4917
|
};
|
|
4913
4918
|
|
|
4914
4919
|
const cvaExternalLink = cssClassVarianceUtilities.cva({
|
package/index.esm.js
CHANGED
|
@@ -29,7 +29,8 @@ var defaultTranslations = {
|
|
|
29
29
|
"copyButton.copy": "Copy",
|
|
30
30
|
"horizontalOverflowScroller.scrollLeft": "Scroll left",
|
|
31
31
|
"horizontalOverflowScroller.scrollRight": "Scroll right",
|
|
32
|
-
"moreMenu.buttonLabel": "Show more"
|
|
32
|
+
"moreMenu.buttonLabel": "Show more",
|
|
33
|
+
"spinner.loading": "Loading"
|
|
33
34
|
};
|
|
34
35
|
|
|
35
36
|
/** The translation namespace for this library */
|
|
@@ -1492,11 +1493,11 @@ const useSyncedSpinDelay = (ref, durationMs = DEFAULT_SPIN_DURATION_MS) => {
|
|
|
1492
1493
|
* during short operations (1-5 seconds) such as saving, loading, or refreshing data.
|
|
1493
1494
|
*
|
|
1494
1495
|
* ### When to use
|
|
1495
|
-
* Use Spinner for short-duration loading states: button actions, table refreshes, inline data fetches,
|
|
1496
|
+
* Use Spinner for short-duration loading states: button actions, table refreshes, inline data fetches, modal content loading, or full-page loading when the page layout isn't known yet (a centered Spinner in a full-height container).
|
|
1497
|
+
* Show `EmptyState` only once loading has finished with nothing to show.
|
|
1496
1498
|
*
|
|
1497
1499
|
* ### When not to use
|
|
1498
1500
|
* Do not use Spinner for long loading states where content structure is known — use `SkeletonBlock` or `SkeletonLabel` instead.
|
|
1499
|
-
* Do not use Spinner for full-page loading — use `EmptyState` with `loading` prop.
|
|
1500
1501
|
*
|
|
1501
1502
|
* @example Centered spinner during data load
|
|
1502
1503
|
* ```tsx
|
|
@@ -1527,7 +1528,8 @@ const Spinner = ({ mode = "light", size = "medium", centering = "centered", clas
|
|
|
1527
1528
|
// spinners rendered in other iframes -- since the delay is derived from the shared wall clock.
|
|
1528
1529
|
const spinnerElRef = useRef(null);
|
|
1529
1530
|
useSyncedSpinDelay(spinnerElRef);
|
|
1530
|
-
|
|
1531
|
+
const [t] = useTranslation();
|
|
1532
|
+
return (jsx("div", { className: cvaSpinnerContainer({ centering, className: containerClassName }), ref: ref, style: style, children: jsxs("div", { className: cvaSpinnerContainerInner(), children: [jsx("div", { "aria-label": label || t("spinner.loading"), className: cvaSpinner({ size, mode, className }), "data-testid": dataTestId, ref: spinnerElRef, role: "spinbutton" }), label ? jsx("span", { className: cvaSpinnerLabel(), children: label }) : null] }) }));
|
|
1531
1533
|
};
|
|
1532
1534
|
|
|
1533
1535
|
const cvaButton = cva({
|
|
@@ -4845,6 +4847,9 @@ WorkerWithSignSVG.displayName = "WorkerWithSignSVG";
|
|
|
4845
4847
|
* - For guidance purposes (e.g., onboarding, adjusting filters, exploring alternative approaches).
|
|
4846
4848
|
* - In celebratory instances (e.g., no new notifications, services up to date).
|
|
4847
4849
|
*
|
|
4850
|
+
* ## **When not to use**
|
|
4851
|
+
* - While content is loading. Show a `Spinner` (or a skeleton when the shape of the content is known) and render the empty state only once loading has finished with nothing to show.
|
|
4852
|
+
*
|
|
4848
4853
|
* @example Empty state with actions for no search results
|
|
4849
4854
|
* ```tsx
|
|
4850
4855
|
* import { EmptyState } from "@trackunit/react-components";
|
|
@@ -4884,7 +4889,7 @@ WorkerWithSignSVG.displayName = "WorkerWithSignSVG";
|
|
|
4884
4889
|
* );
|
|
4885
4890
|
* ```
|
|
4886
4891
|
*/
|
|
4887
|
-
const EmptyState = ({ description, altText, image = "SEARCH_DOCUMENT", customImageSrc,
|
|
4892
|
+
const EmptyState = ({ description, altText, image = "SEARCH_DOCUMENT", customImageSrc, "data-testid": dataTestId, className, primaryAction, secondaryAction, additionalHelpAction, style, ref, }) => {
|
|
4888
4893
|
const ImageSource = useMemo(() => {
|
|
4889
4894
|
switch (image) {
|
|
4890
4895
|
case "WORKER_WITH_SIGN":
|
|
@@ -4907,7 +4912,7 @@ const EmptyState = ({ description, altText, image = "SEARCH_DOCUMENT", customIma
|
|
|
4907
4912
|
const secondaryLink = secondaryAction?.disabled ? undefined : secondaryAction?.to;
|
|
4908
4913
|
const primaryLink = primaryAction?.disabled ? undefined : primaryAction?.to;
|
|
4909
4914
|
const helpLink = additionalHelpAction?.disabled ? undefined : additionalHelpAction?.to;
|
|
4910
|
-
return (
|
|
4915
|
+
return (jsxs("div", { className: cvaContainerStyles({ className }), "data-testid": dataTestId ?? "empty-state", ref: ref, style: style, children: [customImageSrc !== null && customImageSrc !== undefined ? (typeof customImageSrc === "string" ? (jsx("img", { alt: altText, className: cvaImgStyles(), height: 200, src: customImageSrc, width: 200 })) : (customImageSrc)) : (typeof ImageSource !== "undefined" && (jsx(ImageSource, { "data-testid": "empty-state-image", height: 200, width: 200 }, image))), description !== undefined && description !== "" ? (jsx(Text, { align: "center", size: "medium", children: description })) : null, jsxs("div", { className: "mt-4 grid gap-3", children: [primaryAction || secondaryAction ? (jsxs("div", { className: "flex justify-center gap-3", "data-testid": "empty-state-actions", children: [secondaryAction ? (jsx(Button, { asChild: Boolean(secondaryLink), "data-testid": "empty-state-secondary-button", disabled: secondaryAction.disabled, onClick: secondaryAction.onClick, variant: "secondary", children: secondaryLink ? (jsx(Link, { params: secondaryLink.parameters, to: secondaryLink.pathname, children: secondaryAction.title })) : (secondaryAction.title) })) : null, primaryAction ? (jsx(Button, { asChild: Boolean(primaryLink), "data-testid": "empty-state-primary-button", disabled: primaryAction.disabled, onClick: primaryAction.onClick, children: primaryLink ? (jsx(Link, { params: primaryLink.parameters, to: primaryLink.pathname, children: primaryAction.title })) : (primaryAction.title) })) : null] })) : null, additionalHelpAction?.to ? (jsx(Button, { asChild: Boolean(helpLink), "data-testid": "empty-state-additional-button", disabled: additionalHelpAction.disabled, onClick: additionalHelpAction.onClick, suffix: jsx(Icon, { name: "ArrowTopRightOnSquare", size: "small" }), variant: "ghost", children: helpLink ? (jsx(Link, { params: helpLink.parameters, target: helpLink.target, to: helpLink.pathname, children: additionalHelpAction.title })) : (additionalHelpAction.title) })) : null] })] }));
|
|
4911
4916
|
};
|
|
4912
4917
|
|
|
4913
4918
|
const cvaExternalLink = cva({
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/react-router-components",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
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/css-class-variance-utilities": "2.6.56
|
|
11
|
-
"@trackunit/i18n-library-translation": "2.14.49
|
|
12
|
-
"@trackunit/react-components": "
|
|
13
|
-
"@trackunit/react-drawer": "
|
|
14
|
-
"@trackunit/shared-utils": "1.22.56
|
|
10
|
+
"@trackunit/css-class-variance-utilities": "^2.6.56",
|
|
11
|
+
"@trackunit/i18n-library-translation": "^2.14.49",
|
|
12
|
+
"@trackunit/react-components": "^7.0.0",
|
|
13
|
+
"@trackunit/react-drawer": "^3.0.0",
|
|
14
|
+
"@trackunit/shared-utils": "^1.22.56",
|
|
15
15
|
"dequal": "^2.0.3",
|
|
16
16
|
"zod": "^3.25.76"
|
|
17
17
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/react-components",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"migrations": "./migrations.json",
|
|
@@ -14,15 +14,15 @@
|
|
|
14
14
|
"@floating-ui/react": "^0.26.25",
|
|
15
15
|
"string-ts": "^2.0.0",
|
|
16
16
|
"tailwind-merge": "^3.7.0",
|
|
17
|
-
"@trackunit/ui-design-tokens": "1.21.53
|
|
18
|
-
"@trackunit/css-class-variance-utilities": "2.6.56
|
|
19
|
-
"@trackunit/shared-utils": "1.22.56
|
|
20
|
-
"@trackunit/ui-icons": "1.20.53
|
|
17
|
+
"@trackunit/ui-design-tokens": "^1.21.53",
|
|
18
|
+
"@trackunit/css-class-variance-utilities": "^2.6.56",
|
|
19
|
+
"@trackunit/shared-utils": "^1.22.56",
|
|
20
|
+
"@trackunit/ui-icons": "^1.20.53",
|
|
21
21
|
"es-toolkit": "^1.52.0",
|
|
22
22
|
"@tanstack/react-virtual": "^3.14.13",
|
|
23
23
|
"fflate": "^0.8.3",
|
|
24
24
|
"zod": "^3.25.76",
|
|
25
|
-
"@trackunit/i18n-library-translation": "2.14.49
|
|
25
|
+
"@trackunit/i18n-library-translation": "^2.14.49"
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
28
28
|
"react": "^19.0.0",
|
|
@@ -42,10 +42,6 @@ export interface EmptyStateProps extends CommonProps, Styleable, Refable<HTMLDiv
|
|
|
42
42
|
* Additional help action (e.g., a link to external documentation or support). Only rendered when `to` is set.
|
|
43
43
|
*/
|
|
44
44
|
additionalHelpAction?: EmptyStateButtonAction;
|
|
45
|
-
/**
|
|
46
|
-
* Whether the component is in a loading state. Shows a spinner and skeleton text instead of the illustration.
|
|
47
|
-
*/
|
|
48
|
-
loading?: boolean;
|
|
49
45
|
}
|
|
50
46
|
/**
|
|
51
47
|
*
|
|
@@ -57,6 +53,9 @@ export interface EmptyStateProps extends CommonProps, Styleable, Refable<HTMLDiv
|
|
|
57
53
|
* - For guidance purposes (e.g., onboarding, adjusting filters, exploring alternative approaches).
|
|
58
54
|
* - In celebratory instances (e.g., no new notifications, services up to date).
|
|
59
55
|
*
|
|
56
|
+
* ## **When not to use**
|
|
57
|
+
* - While content is loading. Show a `Spinner` (or a skeleton when the shape of the content is known) and render the empty state only once loading has finished with nothing to show.
|
|
58
|
+
*
|
|
60
59
|
* @example Empty state with actions for no search results
|
|
61
60
|
* ```tsx
|
|
62
61
|
* import { EmptyState } from "@trackunit/react-components";
|
|
@@ -96,5 +95,5 @@ export interface EmptyStateProps extends CommonProps, Styleable, Refable<HTMLDiv
|
|
|
96
95
|
* );
|
|
97
96
|
* ```
|
|
98
97
|
*/
|
|
99
|
-
export declare const EmptyState: ({ description, altText, image, customImageSrc,
|
|
98
|
+
export declare const EmptyState: ({ description, altText, image, customImageSrc, "data-testid": dataTestId, className, primaryAction, secondaryAction, additionalHelpAction, style, ref, }: EmptyStateProps) => ReactElement;
|
|
100
99
|
export {};
|
|
@@ -33,11 +33,11 @@ export interface SpinnerProps extends CommonProps, Styleable, Refable<HTMLDivEle
|
|
|
33
33
|
* during short operations (1-5 seconds) such as saving, loading, or refreshing data.
|
|
34
34
|
*
|
|
35
35
|
* ### When to use
|
|
36
|
-
* Use Spinner for short-duration loading states: button actions, table refreshes, inline data fetches,
|
|
36
|
+
* Use Spinner for short-duration loading states: button actions, table refreshes, inline data fetches, modal content loading, or full-page loading when the page layout isn't known yet (a centered Spinner in a full-height container).
|
|
37
|
+
* Show `EmptyState` only once loading has finished with nothing to show.
|
|
37
38
|
*
|
|
38
39
|
* ### When not to use
|
|
39
40
|
* Do not use Spinner for long loading states where content structure is known — use `SkeletonBlock` or `SkeletonLabel` instead.
|
|
40
|
-
* Do not use Spinner for full-page loading — use `EmptyState` with `loading` prop.
|
|
41
41
|
*
|
|
42
42
|
* @example Centered spinner during data load
|
|
43
43
|
* ```tsx
|