@trackunit/react-components 1.7.8 → 1.7.13
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
|
@@ -1046,7 +1046,9 @@ const useTimeout = ({ onTimeout, duration }) => {
|
|
|
1046
1046
|
const callback = react.useRef(onTimeout);
|
|
1047
1047
|
const startTimeout = react.useCallback(() => {
|
|
1048
1048
|
ready.current = false;
|
|
1049
|
-
|
|
1049
|
+
if (timeout.current) {
|
|
1050
|
+
clearTimeout(timeout.current);
|
|
1051
|
+
}
|
|
1050
1052
|
timeout.current = setTimeout(() => {
|
|
1051
1053
|
ready.current = true;
|
|
1052
1054
|
callback.current();
|
|
@@ -1054,7 +1056,9 @@ const useTimeout = ({ onTimeout, duration }) => {
|
|
|
1054
1056
|
}, [duration]);
|
|
1055
1057
|
const stopTimeout = react.useCallback(() => {
|
|
1056
1058
|
ready.current = null;
|
|
1057
|
-
|
|
1059
|
+
if (timeout.current) {
|
|
1060
|
+
clearTimeout(timeout.current);
|
|
1061
|
+
}
|
|
1058
1062
|
}, []);
|
|
1059
1063
|
react.useEffect(() => {
|
|
1060
1064
|
// Use the latest callback function provided by the parent component.
|
|
@@ -1063,7 +1067,9 @@ const useTimeout = ({ onTimeout, duration }) => {
|
|
|
1063
1067
|
react.useEffect(() => {
|
|
1064
1068
|
// Cleanup function to clear the timeout when component unmounts
|
|
1065
1069
|
return () => {
|
|
1066
|
-
|
|
1070
|
+
if (timeout.current) {
|
|
1071
|
+
clearTimeout(timeout.current);
|
|
1072
|
+
}
|
|
1067
1073
|
};
|
|
1068
1074
|
}, []);
|
|
1069
1075
|
return { startTimeout, stopTimeout };
|
|
@@ -1681,7 +1687,7 @@ const useBreadcrumbItemsToRender = (breadcrumbItems) => {
|
|
|
1681
1687
|
*/
|
|
1682
1688
|
const Breadcrumb = ({ className, dataTestId, breadcrumbItems, back }) => {
|
|
1683
1689
|
const breadCrumbItemsToJSX = useBreadcrumbItemsToRender(breadcrumbItems);
|
|
1684
|
-
return (jsxRuntime.jsxs("div", { className: cvaBreadcrumb({ className }), "data-testid": dataTestId, children: [jsxRuntime.jsx(IconButton, { dataTestId: `backButton-${dataTestId}`, icon: jsxRuntime.jsx(Icon, { name: "ArrowLeft", size: "small" }), onClick:
|
|
1690
|
+
return (jsxRuntime.jsxs("div", { className: cvaBreadcrumb({ className }), "data-testid": dataTestId, children: [jsxRuntime.jsx(IconButton, { dataTestId: `backButton-${dataTestId}`, icon: jsxRuntime.jsx(Icon, { name: "ArrowLeft", size: "small" }), onClick: back, size: "small", variant: "ghost-neutral" }), jsxRuntime.jsx("div", { children: jsxRuntime.jsx(BreadcrumbContainer, { breadcrumbItems: breadCrumbItemsToJSX, dataTestId: dataTestId }) })] }));
|
|
1685
1691
|
};
|
|
1686
1692
|
/**
|
|
1687
1693
|
* BreadcrumbContainer is a helper component that renders the breadcrumb items based on the screen size.
|
|
@@ -2055,7 +2061,7 @@ const CopyableText = ({ text, alternativeText, dataTestId, className }) => {
|
|
|
2055
2061
|
const [animating, setAnimating] = react.useState(false);
|
|
2056
2062
|
const [, copyToClipboard] = usehooksTs.useCopyToClipboard();
|
|
2057
2063
|
const handleOnClick = () => {
|
|
2058
|
-
copyToClipboard(value);
|
|
2064
|
+
void copyToClipboard(value);
|
|
2059
2065
|
setAnimating(true);
|
|
2060
2066
|
};
|
|
2061
2067
|
return (jsxRuntime.jsx("span", { className: cvaCopyableText({ animating, className }), "data-testid": dataTestId, onAnimationEnd: () => setAnimating(false), onClick: handleOnClick, title: value, children: text }));
|
|
@@ -3165,7 +3171,9 @@ const MenuItem = ({ className, dataTestId, label, children, selected, focused, p
|
|
|
3165
3171
|
/* Handle tab navigation */
|
|
3166
3172
|
const handleKeyDown = (e) => {
|
|
3167
3173
|
if (e.key === "Enter" && onClick && !disabled) {
|
|
3168
|
-
|
|
3174
|
+
if (stopPropagation) {
|
|
3175
|
+
e.stopPropagation();
|
|
3176
|
+
}
|
|
3169
3177
|
// eslint-disable-next-line local-rules/no-typescript-assertion
|
|
3170
3178
|
onClick(e);
|
|
3171
3179
|
}
|
|
@@ -3178,7 +3186,9 @@ const MenuItem = ({ className, dataTestId, label, children, selected, focused, p
|
|
|
3178
3186
|
variant,
|
|
3179
3187
|
focused,
|
|
3180
3188
|
}), "data-testid": dataTestId ? `${dataTestId}-menu-item` : "menu-item", id: id, onClick: e => {
|
|
3181
|
-
|
|
3189
|
+
if (stopPropagation) {
|
|
3190
|
+
e.stopPropagation();
|
|
3191
|
+
}
|
|
3182
3192
|
onClick?.(e);
|
|
3183
3193
|
}, onKeyDown: handleKeyDown, role: "menuitem", tabIndex: disabled ? -1 : (tabIndex ?? 0), children: [prefix ? (jsxRuntime.jsx("div", { className: cvaMenuItemPrefix({ selected, variant, disabled }), "data-testid": dataTestId ? `${dataTestId}-prefix` : "menu-item-prefix", children: prefix })) : null, children && typeof children !== "string" ? (children) : (jsxRuntime.jsxs("div", { className: cvaMenuItemLabel({ variant, disabled }), "data-testid": dataTestId ? `${dataTestId}-label` : "menu-item-label", children: [children ?? label, optionLabelDescription ? jsxRuntime.jsxs("span", { className: "text-secondary-400 ml-1", children: ["(", optionLabelDescription, ")"] }) : null] })), suffix ? (jsxRuntime.jsx("div", { className: cvaMenuItemSuffix({ selected, variant, disabled, className: "flex items-center" }), "data-testid": dataTestId ? `${dataTestId}-suffix` : "menu-item-suffix", children: suffix })) : null] }));
|
|
3184
3194
|
};
|
|
@@ -3634,7 +3644,7 @@ const cvaSidebarChildContainer = cssClassVarianceUtilities.cvaMerge(["apply", "f
|
|
|
3634
3644
|
* A hook used to detect what children are overflowing a container.
|
|
3635
3645
|
*
|
|
3636
3646
|
* @param {OverflowItemsOptions} root0 The options for the hook.
|
|
3637
|
-
* @param {
|
|
3647
|
+
* @param {number | Array<number>} root0.threshold The threshold for the intersection observer.
|
|
3638
3648
|
* @returns {object} The overflow items and the ref to the container.
|
|
3639
3649
|
*/
|
|
3640
3650
|
const useOverflowItems = ({ threshold = 1, childUniqueIdentifierAttribute = "id", children, }) => {
|
|
@@ -3644,7 +3654,7 @@ const useOverflowItems = ({ threshold = 1, childUniqueIdentifierAttribute = "id"
|
|
|
3644
3654
|
const handleIntersection = react.useCallback(entries => {
|
|
3645
3655
|
const updatedEntries = {};
|
|
3646
3656
|
entries.forEach(entry => {
|
|
3647
|
-
// @ts-
|
|
3657
|
+
// @ts-expect-error - suppressImplicitAnyIndexErrors
|
|
3648
3658
|
const targetElementId = entry.target[childUniqueIdentifierAttribute];
|
|
3649
3659
|
if (targetElementId) {
|
|
3650
3660
|
updatedEntries[targetElementId] = entry.isIntersecting ? false : true;
|
|
@@ -4037,7 +4047,7 @@ const VirtualizedList = ({ count, rowHeight = 40, pagination, children, classNam
|
|
|
4037
4047
|
scrollParent.removeEventListener("scroll", handleScroll);
|
|
4038
4048
|
};
|
|
4039
4049
|
}
|
|
4040
|
-
return
|
|
4050
|
+
return undefined;
|
|
4041
4051
|
}, [scrollParent, fetchMoreOnBottomReached]);
|
|
4042
4052
|
return (jsxRuntime.jsx("div", { className: cvaVirtualizedListContainer({ parentControlledScrollable, className }), "data-testid": dataTestId, ref: containerRef, children: jsxRuntime.jsx("ul", { className: cvaVirtualizedList(), ref: listRef, style: { height: `${getTotalSize()}px`, outline: "none" }, children: getVirtualItems().map(virtualRow => {
|
|
4043
4053
|
const isLoaderRow = virtualRow.index > count - 1;
|
|
@@ -4055,7 +4065,7 @@ const cvaZStackItem = cssClassVarianceUtilities.cvaMerge(["col-start-1", "col-en
|
|
|
4055
4065
|
* Is a good alternative to "position: absolute" that avoids some of the unfortunate side effects of absolute positioning.
|
|
4056
4066
|
*
|
|
4057
4067
|
* @param { ZStackProps} props - The props for the ZStack component
|
|
4058
|
-
* @returns {
|
|
4068
|
+
* @returns {Element} ZStack component
|
|
4059
4069
|
*/
|
|
4060
4070
|
const ZStack = ({ children, className, dataTestId }) => {
|
|
4061
4071
|
return (jsxRuntime.jsx("div", { className: cvaZStackContainer({ className }), "data-testid": dataTestId, children: react.Children.map(children, (child, index) => {
|
package/index.esm.js
CHANGED
|
@@ -1044,7 +1044,9 @@ const useTimeout = ({ onTimeout, duration }) => {
|
|
|
1044
1044
|
const callback = useRef(onTimeout);
|
|
1045
1045
|
const startTimeout = useCallback(() => {
|
|
1046
1046
|
ready.current = false;
|
|
1047
|
-
|
|
1047
|
+
if (timeout.current) {
|
|
1048
|
+
clearTimeout(timeout.current);
|
|
1049
|
+
}
|
|
1048
1050
|
timeout.current = setTimeout(() => {
|
|
1049
1051
|
ready.current = true;
|
|
1050
1052
|
callback.current();
|
|
@@ -1052,7 +1054,9 @@ const useTimeout = ({ onTimeout, duration }) => {
|
|
|
1052
1054
|
}, [duration]);
|
|
1053
1055
|
const stopTimeout = useCallback(() => {
|
|
1054
1056
|
ready.current = null;
|
|
1055
|
-
|
|
1057
|
+
if (timeout.current) {
|
|
1058
|
+
clearTimeout(timeout.current);
|
|
1059
|
+
}
|
|
1056
1060
|
}, []);
|
|
1057
1061
|
useEffect(() => {
|
|
1058
1062
|
// Use the latest callback function provided by the parent component.
|
|
@@ -1061,7 +1065,9 @@ const useTimeout = ({ onTimeout, duration }) => {
|
|
|
1061
1065
|
useEffect(() => {
|
|
1062
1066
|
// Cleanup function to clear the timeout when component unmounts
|
|
1063
1067
|
return () => {
|
|
1064
|
-
|
|
1068
|
+
if (timeout.current) {
|
|
1069
|
+
clearTimeout(timeout.current);
|
|
1070
|
+
}
|
|
1065
1071
|
};
|
|
1066
1072
|
}, []);
|
|
1067
1073
|
return { startTimeout, stopTimeout };
|
|
@@ -1679,7 +1685,7 @@ const useBreadcrumbItemsToRender = (breadcrumbItems) => {
|
|
|
1679
1685
|
*/
|
|
1680
1686
|
const Breadcrumb = ({ className, dataTestId, breadcrumbItems, back }) => {
|
|
1681
1687
|
const breadCrumbItemsToJSX = useBreadcrumbItemsToRender(breadcrumbItems);
|
|
1682
|
-
return (jsxs("div", { className: cvaBreadcrumb({ className }), "data-testid": dataTestId, children: [jsx(IconButton, { dataTestId: `backButton-${dataTestId}`, icon: jsx(Icon, { name: "ArrowLeft", size: "small" }), onClick:
|
|
1688
|
+
return (jsxs("div", { className: cvaBreadcrumb({ className }), "data-testid": dataTestId, children: [jsx(IconButton, { dataTestId: `backButton-${dataTestId}`, icon: jsx(Icon, { name: "ArrowLeft", size: "small" }), onClick: back, size: "small", variant: "ghost-neutral" }), jsx("div", { children: jsx(BreadcrumbContainer, { breadcrumbItems: breadCrumbItemsToJSX, dataTestId: dataTestId }) })] }));
|
|
1683
1689
|
};
|
|
1684
1690
|
/**
|
|
1685
1691
|
* BreadcrumbContainer is a helper component that renders the breadcrumb items based on the screen size.
|
|
@@ -2053,7 +2059,7 @@ const CopyableText = ({ text, alternativeText, dataTestId, className }) => {
|
|
|
2053
2059
|
const [animating, setAnimating] = useState(false);
|
|
2054
2060
|
const [, copyToClipboard] = useCopyToClipboard();
|
|
2055
2061
|
const handleOnClick = () => {
|
|
2056
|
-
copyToClipboard(value);
|
|
2062
|
+
void copyToClipboard(value);
|
|
2057
2063
|
setAnimating(true);
|
|
2058
2064
|
};
|
|
2059
2065
|
return (jsx("span", { className: cvaCopyableText({ animating, className }), "data-testid": dataTestId, onAnimationEnd: () => setAnimating(false), onClick: handleOnClick, title: value, children: text }));
|
|
@@ -3163,7 +3169,9 @@ const MenuItem = ({ className, dataTestId, label, children, selected, focused, p
|
|
|
3163
3169
|
/* Handle tab navigation */
|
|
3164
3170
|
const handleKeyDown = (e) => {
|
|
3165
3171
|
if (e.key === "Enter" && onClick && !disabled) {
|
|
3166
|
-
|
|
3172
|
+
if (stopPropagation) {
|
|
3173
|
+
e.stopPropagation();
|
|
3174
|
+
}
|
|
3167
3175
|
// eslint-disable-next-line local-rules/no-typescript-assertion
|
|
3168
3176
|
onClick(e);
|
|
3169
3177
|
}
|
|
@@ -3176,7 +3184,9 @@ const MenuItem = ({ className, dataTestId, label, children, selected, focused, p
|
|
|
3176
3184
|
variant,
|
|
3177
3185
|
focused,
|
|
3178
3186
|
}), "data-testid": dataTestId ? `${dataTestId}-menu-item` : "menu-item", id: id, onClick: e => {
|
|
3179
|
-
|
|
3187
|
+
if (stopPropagation) {
|
|
3188
|
+
e.stopPropagation();
|
|
3189
|
+
}
|
|
3180
3190
|
onClick?.(e);
|
|
3181
3191
|
}, onKeyDown: handleKeyDown, role: "menuitem", tabIndex: disabled ? -1 : (tabIndex ?? 0), children: [prefix ? (jsx("div", { className: cvaMenuItemPrefix({ selected, variant, disabled }), "data-testid": dataTestId ? `${dataTestId}-prefix` : "menu-item-prefix", children: prefix })) : null, children && typeof children !== "string" ? (children) : (jsxs("div", { className: cvaMenuItemLabel({ variant, disabled }), "data-testid": dataTestId ? `${dataTestId}-label` : "menu-item-label", children: [children ?? label, optionLabelDescription ? jsxs("span", { className: "text-secondary-400 ml-1", children: ["(", optionLabelDescription, ")"] }) : null] })), suffix ? (jsx("div", { className: cvaMenuItemSuffix({ selected, variant, disabled, className: "flex items-center" }), "data-testid": dataTestId ? `${dataTestId}-suffix` : "menu-item-suffix", children: suffix })) : null] }));
|
|
3182
3192
|
};
|
|
@@ -3632,7 +3642,7 @@ const cvaSidebarChildContainer = cvaMerge(["apply", "flex", "overflow-hidden", "
|
|
|
3632
3642
|
* A hook used to detect what children are overflowing a container.
|
|
3633
3643
|
*
|
|
3634
3644
|
* @param {OverflowItemsOptions} root0 The options for the hook.
|
|
3635
|
-
* @param {
|
|
3645
|
+
* @param {number | Array<number>} root0.threshold The threshold for the intersection observer.
|
|
3636
3646
|
* @returns {object} The overflow items and the ref to the container.
|
|
3637
3647
|
*/
|
|
3638
3648
|
const useOverflowItems = ({ threshold = 1, childUniqueIdentifierAttribute = "id", children, }) => {
|
|
@@ -3642,7 +3652,7 @@ const useOverflowItems = ({ threshold = 1, childUniqueIdentifierAttribute = "id"
|
|
|
3642
3652
|
const handleIntersection = useCallback(entries => {
|
|
3643
3653
|
const updatedEntries = {};
|
|
3644
3654
|
entries.forEach(entry => {
|
|
3645
|
-
// @ts-
|
|
3655
|
+
// @ts-expect-error - suppressImplicitAnyIndexErrors
|
|
3646
3656
|
const targetElementId = entry.target[childUniqueIdentifierAttribute];
|
|
3647
3657
|
if (targetElementId) {
|
|
3648
3658
|
updatedEntries[targetElementId] = entry.isIntersecting ? false : true;
|
|
@@ -4035,7 +4045,7 @@ const VirtualizedList = ({ count, rowHeight = 40, pagination, children, classNam
|
|
|
4035
4045
|
scrollParent.removeEventListener("scroll", handleScroll);
|
|
4036
4046
|
};
|
|
4037
4047
|
}
|
|
4038
|
-
return
|
|
4048
|
+
return undefined;
|
|
4039
4049
|
}, [scrollParent, fetchMoreOnBottomReached]);
|
|
4040
4050
|
return (jsx("div", { className: cvaVirtualizedListContainer({ parentControlledScrollable, className }), "data-testid": dataTestId, ref: containerRef, children: jsx("ul", { className: cvaVirtualizedList(), ref: listRef, style: { height: `${getTotalSize()}px`, outline: "none" }, children: getVirtualItems().map(virtualRow => {
|
|
4041
4051
|
const isLoaderRow = virtualRow.index > count - 1;
|
|
@@ -4053,7 +4063,7 @@ const cvaZStackItem = cvaMerge(["col-start-1", "col-end-1", "row-start-1", "row-
|
|
|
4053
4063
|
* Is a good alternative to "position: absolute" that avoids some of the unfortunate side effects of absolute positioning.
|
|
4054
4064
|
*
|
|
4055
4065
|
* @param { ZStackProps} props - The props for the ZStack component
|
|
4056
|
-
* @returns {
|
|
4066
|
+
* @returns {Element} ZStack component
|
|
4057
4067
|
*/
|
|
4058
4068
|
const ZStack = ({ children, className, dataTestId }) => {
|
|
4059
4069
|
return (jsx("div", { className: cvaZStackContainer({ className }), "data-testid": dataTestId, children: Children.map(children, (child, index) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/react-components",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.13",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"engines": {
|
|
@@ -15,15 +15,15 @@
|
|
|
15
15
|
"lodash": "4.17.21",
|
|
16
16
|
"@testing-library/react": "16.2.0",
|
|
17
17
|
"@floating-ui/react": "^0.26.25",
|
|
18
|
-
"@tanstack/react-router": "1.114.29",
|
|
19
18
|
"string-ts": "^2.0.0",
|
|
20
19
|
"tailwind-merge": "^2.0.0",
|
|
21
|
-
"@trackunit/ui-design-tokens": "1.6.
|
|
22
|
-
"@trackunit/css-class-variance-utilities": "1.6.
|
|
23
|
-
"@trackunit/shared-utils": "1.8.
|
|
24
|
-
"@trackunit/ui-icons": "1.6.
|
|
25
|
-
"@trackunit/react-table-pagination": "1.6.
|
|
26
|
-
"@trackunit/react-test-setup": "1.3.
|
|
20
|
+
"@trackunit/ui-design-tokens": "1.6.11",
|
|
21
|
+
"@trackunit/css-class-variance-utilities": "1.6.11",
|
|
22
|
+
"@trackunit/shared-utils": "1.8.11",
|
|
23
|
+
"@trackunit/ui-icons": "1.6.10",
|
|
24
|
+
"@trackunit/react-table-pagination": "1.6.10",
|
|
25
|
+
"@trackunit/react-test-setup": "1.3.11",
|
|
26
|
+
"@tanstack/react-router": "1.114.29"
|
|
27
27
|
},
|
|
28
28
|
"module": "./index.esm.js",
|
|
29
29
|
"main": "./index.cjs.js",
|
|
@@ -30,7 +30,7 @@ export type OverflowMap = {
|
|
|
30
30
|
* A hook used to detect what children are overflowing a container.
|
|
31
31
|
*
|
|
32
32
|
* @param {OverflowItemsOptions} root0 The options for the hook.
|
|
33
|
-
* @param {
|
|
33
|
+
* @param {number | Array<number>} root0.threshold The threshold for the intersection observer.
|
|
34
34
|
* @returns {object} The overflow items and the ref to the container.
|
|
35
35
|
*/
|
|
36
36
|
export declare const useOverflowItems: ({ threshold, childUniqueIdentifierAttribute, children, }: OverflowItemsOptions) => {
|
|
@@ -8,6 +8,6 @@ export type ZStackProps = CommonProps & {
|
|
|
8
8
|
* Is a good alternative to "position: absolute" that avoids some of the unfortunate side effects of absolute positioning.
|
|
9
9
|
*
|
|
10
10
|
* @param { ZStackProps} props - The props for the ZStack component
|
|
11
|
-
* @returns {
|
|
11
|
+
* @returns {Element} ZStack component
|
|
12
12
|
*/
|
|
13
13
|
export declare const ZStack: ({ children, className, dataTestId }: ZStackProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RenderHookOptions } from "@testing-library/react";
|
|
1
|
+
import { RenderHookOptions, RenderHookResult } from "@testing-library/react";
|
|
2
2
|
/**
|
|
3
3
|
* Custom renderHook function to avoid boilerplate
|
|
4
4
|
*
|
|
@@ -7,6 +7,6 @@ import { RenderHookOptions } from "@testing-library/react";
|
|
|
7
7
|
* @param {(props: T) => K} callback - callback function
|
|
8
8
|
* @param {RenderHookOptions<T>} [options] - options
|
|
9
9
|
*/
|
|
10
|
-
declare const customRenderHook: <TProps, TReturn>(callback: (props: TProps) => TReturn, options?: RenderHookOptions<TProps>) =>
|
|
10
|
+
declare const customRenderHook: <TProps, TReturn>(callback: (props: TProps) => TReturn, options?: RenderHookOptions<TProps>) => RenderHookResult<TReturn, TProps>;
|
|
11
11
|
export * from "@testing-library/react";
|
|
12
12
|
export { customRenderHook as renderHook };
|