@trackunit/react-components 1.0.13 → 1.1.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 +56 -68
- package/index.esm.js +65 -77
- package/package.json +1 -1
- package/src/components/Alert/Alert.d.ts +2 -2
- package/src/components/Card/Card.d.ts +6 -6
- package/src/components/Card/CardBody.d.ts +2 -2
- package/src/components/Card/CardFooter.d.ts +2 -2
- package/src/components/Card/CardHeader.d.ts +5 -5
- package/src/components/Collapse/Collapse.d.ts +5 -5
- package/src/components/Heading/Heading.d.ts +2 -2
- package/src/components/Page/Page.d.ts +2 -2
- package/src/components/Page/PageContent.d.ts +3 -3
- package/src/components/PageHeader/PageHeader.d.ts +5 -5
- package/src/components/Popover/PopoverContent.d.ts +4 -4
- package/src/components/Popover/PopoverTitle.d.ts +3 -3
- package/src/components/Sidebar/Sidebar.d.ts +4 -4
- package/src/components/Tag/Tag.d.ts +4 -4
- package/src/components/Text/Text.d.ts +7 -3
- package/src/components/Tooltip/Tooltip.d.ts +3 -3
- package/src/components/Widget/WidgetBody.d.ts +2 -2
- package/src/components/buttons/Button/Button.d.ts +6 -6
- package/src/components/buttons/IconButton/IconButton.d.ts +4 -4
- package/src/components/buttons/StarButton/StarButton.d.ts +2 -2
- package/src/test-utils/test-utils.d.ts +2 -2
package/index.cjs.js
CHANGED
|
@@ -273,7 +273,7 @@ const cvaTagIcon = cssClassVarianceUtilities.cvaMerge(["cursor-pointer", "transi
|
|
|
273
273
|
* @param {TagProps} props - The props for the tag component
|
|
274
274
|
* @returns {JSX.Element} tag component
|
|
275
275
|
*/
|
|
276
|
-
const Tag =
|
|
276
|
+
const Tag = React.forwardRef(({ className, dataTestId, children, size = "medium", onClose, color = "primary", disabled = false }, ref) => {
|
|
277
277
|
return (jsxRuntime.jsxs("span", { className: cvaTag({ className, size, color, layout: onClose ? "withIcon" : "default" }), "data-testid": dataTestId, ref: ref, children: [children, Boolean(onClose) && !disabled ? (
|
|
278
278
|
// a fix for multiselect deselecting tags working together with fade out animation
|
|
279
279
|
jsxRuntime.jsx("div", { className: cvaTagIconContainer(), onMouseDown: onClose, children: jsxRuntime.jsx(Icon, { className: cvaTagIcon(), dataTestId: dataTestId + "Icon", name: "XCircle", size: size, style: { WebkitTransition: "-webkit-transform 0.150s" }, type: "solid" }) })) : null] }));
|
|
@@ -284,7 +284,7 @@ Tag.displayName = "Tag";
|
|
|
284
284
|
* A component used to display the package name and version in the Storybook docs.
|
|
285
285
|
*/
|
|
286
286
|
const PackageNameStoryComponent = ({ packageJSON }) => {
|
|
287
|
-
return (jsxRuntime.jsxs("div", { className: "flex gap-2", children: [jsxRuntime.jsx(Tag, { color: "secondary", children: packageJSON
|
|
287
|
+
return (jsxRuntime.jsxs("div", { className: "flex gap-2", children: [jsxRuntime.jsx(Tag, { color: "secondary", children: packageJSON?.name }), jsxRuntime.jsxs(Tag, { color: "secondary", children: ["v", packageJSON?.version] })] }));
|
|
288
288
|
};
|
|
289
289
|
|
|
290
290
|
/**
|
|
@@ -294,7 +294,6 @@ const PackageNameStoryComponent = ({ packageJSON }) => {
|
|
|
294
294
|
* @returns {boolean} True if the text spans multiple lines
|
|
295
295
|
*/
|
|
296
296
|
const useIsTextWrapping = (ref) => {
|
|
297
|
-
var _a, _b;
|
|
298
297
|
const [isWrapping, setIsWrapping] = React.useState(false);
|
|
299
298
|
React.useEffect(() => {
|
|
300
299
|
if (!ref.current) {
|
|
@@ -302,7 +301,7 @@ const useIsTextWrapping = (ref) => {
|
|
|
302
301
|
return;
|
|
303
302
|
}
|
|
304
303
|
setIsWrapping(ref.current.clientHeight > ref.current.scrollHeight / 2);
|
|
305
|
-
}, [
|
|
304
|
+
}, [ref.current?.clientHeight, ref.current?.scrollHeight, ref]);
|
|
306
305
|
return isWrapping;
|
|
307
306
|
};
|
|
308
307
|
|
|
@@ -369,8 +368,8 @@ const cvaText = cssClassVarianceUtilities.cvaMerge(["text-black", "m-0", "relati
|
|
|
369
368
|
* @param {TextProps} props - The props for the Text component
|
|
370
369
|
* @returns {JSX.Element} Text component
|
|
371
370
|
*/
|
|
372
|
-
const Text =
|
|
373
|
-
return
|
|
371
|
+
const Text = React.forwardRef(({ children, type = "p", size = "medium", align = "left", weight = "normal", underline = false, inverted = false, subtle = false, italicize = false, uppercase = false, disabled = false, className, dataTestId, ...rest }, ref) => {
|
|
372
|
+
return React.createElement(type, {
|
|
374
373
|
ref,
|
|
375
374
|
className: cvaText({
|
|
376
375
|
inverted,
|
|
@@ -700,7 +699,7 @@ const cvaIconButton = cssClassVarianceUtilities.cvaMerge([], {
|
|
|
700
699
|
* @param {ButtonProps} props - The props for the Button component
|
|
701
700
|
* @returns {JSX.Element} Button component
|
|
702
701
|
*/
|
|
703
|
-
const Button =
|
|
702
|
+
const Button = React.forwardRef(({ onClick, children, loading, disabled, className, fullWidth = false, prefix, suffix, variant = "primary", type = "button", size = "medium", square = false, dataTestId, title, role, tabIndex, asChild = false, circular, ...rest }, ref) => {
|
|
704
703
|
const Comp = asChild ? reactSlot.Slot : "button";
|
|
705
704
|
const sharedCompProps = {
|
|
706
705
|
ref,
|
|
@@ -725,7 +724,7 @@ Button.displayName = "Button";
|
|
|
725
724
|
/**
|
|
726
725
|
* Buttons are clickable elements that are used to trigger actions. They communicate calls to action to the user and allow users to interact with pages in a variety of ways. The Icon Button is a version of the standard Button component without the text label.
|
|
727
726
|
*/
|
|
728
|
-
const IconButton =
|
|
727
|
+
const IconButton = React.forwardRef(({ icon, size = "medium", square = true, loading, disabled, className, ...rest }, ref) => {
|
|
729
728
|
return (jsxRuntime.jsx(Button, { className: cvaIconButton({ size: size, className }), disabled: disabled || loading, loading: loading,
|
|
730
729
|
// eslint-disable-next-line local-rules/design-guideline-button-icon-size-match
|
|
731
730
|
prefix: !loading ? icon : undefined, ref: ref, size: size, square: square, ...rest }));
|
|
@@ -775,14 +774,13 @@ const cvaAlertIconContainer = cssClassVarianceUtilities.cvaMerge(["self-start",
|
|
|
775
774
|
* @returns {JSX.Element} Alert component
|
|
776
775
|
*/
|
|
777
776
|
const Alert = ({ color = "info", title, className, children, primaryAction, secondaryAction, onClose, dataTestId, autoScroll, }) => {
|
|
778
|
-
const ref =
|
|
779
|
-
const titleRef =
|
|
777
|
+
const ref = React.useRef(null);
|
|
778
|
+
const titleRef = React.useRef(null);
|
|
780
779
|
const isWrapping = useIsTextWrapping(titleRef);
|
|
781
|
-
|
|
782
|
-
var _a, _b;
|
|
780
|
+
React.useEffect(() => {
|
|
783
781
|
if (autoScroll) {
|
|
784
782
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
785
|
-
|
|
783
|
+
ref.current?.scrollIntoView?.();
|
|
786
784
|
}
|
|
787
785
|
}, [ref, autoScroll]);
|
|
788
786
|
return (jsxRuntime.jsxs("div", { className: cvaAlert({ color, className }), "data-testid": dataTestId, ref: ref, role: "alert", children: [jsxRuntime.jsxs("div", { className: cvaAlertContentContainer({ inline: !isWrapping && !children }), children: [jsxRuntime.jsx("div", { className: cvaAlertIconContainer(), children: jsxRuntime.jsx(Icon, { color: color, name: getIconName(color) }) }), jsxRuntime.jsxs("div", { className: cvaContent(), children: [title ? (jsxRuntime.jsx(Text, { dataTestId: `${dataTestId}-title`, ref: titleRef, weight: "bold", children: title })) : null, children ? (jsxRuntime.jsx(Text, { type: typeof children === "string" || typeof children === "number" ? "p" : "span", weight: !title ? "bold" : "normal", children: children })) : null] }), onClose ? (jsxRuntime.jsx("div", { className: cvaAlertCloseButtonContainer(), children: jsxRuntime.jsx(IconButton, { circular: true, icon: jsxRuntime.jsx(Icon, { name: "XMark", size: "small" }), onClick: onClose, size: "small", title: "Close Alert", variant: "ghost-neutral" }) })) : null] }), primaryAction || secondaryAction ? (jsxRuntime.jsxs("div", { className: cvaAlertActionsContainer(), children: [secondaryAction ? (jsxRuntime.jsx(Button, { loading: secondaryAction.loading, onClick: secondaryAction.onClick, size: "small", variant: "ghost-neutral", children: secondaryAction.label })) : null, primaryAction ? (jsxRuntime.jsx(Button, { loading: primaryAction.loading, onClick: primaryAction.onClick, size: "small", variant: color === "danger" ? "primary-danger" : "primary", children: primaryAction.label })) : null] })) : null] }));
|
|
@@ -1048,7 +1046,7 @@ const useContinuousTimeout = ({ onTimeout, onMaxRetries, duration, maxRetries })
|
|
|
1048
1046
|
retries.current++;
|
|
1049
1047
|
}
|
|
1050
1048
|
else {
|
|
1051
|
-
onMaxRetries
|
|
1049
|
+
onMaxRetries?.();
|
|
1052
1050
|
retries.current = 0;
|
|
1053
1051
|
}
|
|
1054
1052
|
startTimeout(); // Restart the timeout if it's still running
|
|
@@ -1084,7 +1082,7 @@ const useDebounce = (value, delay = 500, direction, onBounce) => {
|
|
|
1084
1082
|
!direction) {
|
|
1085
1083
|
handler = setTimeout(() => {
|
|
1086
1084
|
setDebouncedValue(value);
|
|
1087
|
-
onBounce
|
|
1085
|
+
onBounce?.(value);
|
|
1088
1086
|
}, delay);
|
|
1089
1087
|
}
|
|
1090
1088
|
else {
|
|
@@ -1145,7 +1143,7 @@ function getDevicePixelRatio(options) {
|
|
|
1145
1143
|
*/
|
|
1146
1144
|
const useElevatedState = (initialState, customState) => {
|
|
1147
1145
|
const fallbackState = React.useState(initialState);
|
|
1148
|
-
return customState
|
|
1146
|
+
return customState ?? fallbackState;
|
|
1149
1147
|
};
|
|
1150
1148
|
|
|
1151
1149
|
/**
|
|
@@ -1253,7 +1251,6 @@ const useIsFullscreen = () => {
|
|
|
1253
1251
|
* @returns {boolean} True if the text is cut off.
|
|
1254
1252
|
*/
|
|
1255
1253
|
const useIsTextCutOff = (ref) => {
|
|
1256
|
-
var _a, _b;
|
|
1257
1254
|
const [isTextCutOff, setIsTextCutOff] = React.useState(false);
|
|
1258
1255
|
React.useEffect(() => {
|
|
1259
1256
|
if (!ref.current) {
|
|
@@ -1261,7 +1258,7 @@ const useIsTextCutOff = (ref) => {
|
|
|
1261
1258
|
return;
|
|
1262
1259
|
}
|
|
1263
1260
|
setIsTextCutOff(ref.current.offsetWidth < ref.current.scrollWidth);
|
|
1264
|
-
}, [
|
|
1261
|
+
}, [ref.current?.offsetWidth, ref.current?.scrollWidth, ref]);
|
|
1265
1262
|
return isTextCutOff;
|
|
1266
1263
|
};
|
|
1267
1264
|
|
|
@@ -1424,11 +1421,11 @@ const useWindowActivity = ({ onFocus, onBlur } = { onBlur: undefined, onFocus: u
|
|
|
1424
1421
|
const [focused, setFocused] = React.useState(hasFocus());
|
|
1425
1422
|
const onFocusInternal = React.useCallback(() => {
|
|
1426
1423
|
setFocused(hasFocus());
|
|
1427
|
-
onFocus
|
|
1424
|
+
onFocus?.();
|
|
1428
1425
|
}, [onFocus]);
|
|
1429
1426
|
const onBlurInternal = React.useCallback(() => {
|
|
1430
1427
|
setFocused(hasFocus());
|
|
1431
|
-
onBlur
|
|
1428
|
+
onBlur?.();
|
|
1432
1429
|
}, [onBlur]);
|
|
1433
1430
|
React.useEffect(() => {
|
|
1434
1431
|
setFocused(hasFocus()); // Focus for additional renders
|
|
@@ -1726,7 +1723,7 @@ const Heading = ({ variant = "primary", inverted = false, subtle = false, classN
|
|
|
1726
1723
|
tertiary: "h3",
|
|
1727
1724
|
subtitle: "h4",
|
|
1728
1725
|
};
|
|
1729
|
-
return
|
|
1726
|
+
return React.createElement(semanticType[variant], {
|
|
1730
1727
|
...rest,
|
|
1731
1728
|
className: cvaHeading({ subtle, inverted, size: variant, className }),
|
|
1732
1729
|
"data-testid": dataTestId,
|
|
@@ -1823,8 +1820,8 @@ const cvaChevronIcon = cssClassVarianceUtilities.cvaMerge(["transition-transform
|
|
|
1823
1820
|
*/
|
|
1824
1821
|
const Collapse = ({ id, initialExpanded = false, onToggle, label, children, className, headerClassName, headerAddon, dataTestId, animate = true, extraPadding = true, }) => {
|
|
1825
1822
|
const LABEL_ID = sharedUtils.uuidv4();
|
|
1826
|
-
const [expanded, setExpanded] =
|
|
1827
|
-
const handleClick =
|
|
1823
|
+
const [expanded, setExpanded] = React.useState(initialExpanded);
|
|
1824
|
+
const handleClick = React.useCallback((e) => {
|
|
1828
1825
|
if (onToggle) {
|
|
1829
1826
|
onToggle(e, !expanded);
|
|
1830
1827
|
}
|
|
@@ -1896,8 +1893,7 @@ const cvaCopyableText = cssClassVarianceUtilities.cvaMerge([
|
|
|
1896
1893
|
* @returns {JSX.Element} CopyableText component
|
|
1897
1894
|
*/
|
|
1898
1895
|
const CopyableText = ({ text, alternativeText, dataTestId, className }) => {
|
|
1899
|
-
|
|
1900
|
-
const value = (_a = alternativeText !== null && alternativeText !== void 0 ? alternativeText : text) !== null && _a !== void 0 ? _a : "";
|
|
1896
|
+
const value = alternativeText ?? text ?? "";
|
|
1901
1897
|
const [animating, setAnimating] = React.useState(false);
|
|
1902
1898
|
const [, copyToClipboard] = usehooksTs.useCopyToClipboard();
|
|
1903
1899
|
const handleOnClick = () => {
|
|
@@ -3271,7 +3267,6 @@ var ForwardRef = /*#__PURE__*/React.forwardRef(SvgWorkerWithSign);
|
|
|
3271
3267
|
* - In celebratory instances (e.g., no new notifications, services up to date).
|
|
3272
3268
|
*/
|
|
3273
3269
|
const EmptyState = ({ description, altText, image = "SEARCH_DOCUMENT", customImageSrc, loading, dataTestId, className, primaryAction, secondaryAction, additionalHelpAction, }) => {
|
|
3274
|
-
var _a, _b, _c;
|
|
3275
3270
|
const ImageSource = React.useMemo(() => {
|
|
3276
3271
|
switch (image) {
|
|
3277
3272
|
case "WORKER_WITH_SIGN":
|
|
@@ -3289,7 +3284,7 @@ const EmptyState = ({ description, altText, image = "SEARCH_DOCUMENT", customIma
|
|
|
3289
3284
|
return ForwardRef$2;
|
|
3290
3285
|
}
|
|
3291
3286
|
}, [image]);
|
|
3292
|
-
return (jsxRuntime.jsx("div", { className: cvaContainerStyles({ className }), "data-testid": dataTestId
|
|
3287
|
+
return (jsxRuntime.jsx("div", { className: cvaContainerStyles({ className }), "data-testid": dataTestId ?? "empty-state", children: loading ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Spinner, { centering: "centered", dataTestId: "spinner" }), jsxRuntime.jsx(SkeletonLines, { dataTestId: "skeleton-lines", width: 50 })] })) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [customImageSrc ? (jsxRuntime.jsx("img", { alt: altText, className: cvaImgStyles(), height: 200, src: customImageSrc, width: 200 })) : (typeof ImageSource !== "undefined" && (jsxRuntime.jsx(ImageSource, { "data-testid": "empty-state-image", height: 200, width: 200 }, image))), description ? (jsxRuntime.jsx(Text, { align: "center", size: "large", children: description })) : null, jsxRuntime.jsxs("div", { className: "grid gap-3", children: [jsxRuntime.jsxs("div", { className: "flex gap-3", children: [secondaryAction ? (jsxRuntime.jsx(Button, { dataTestId: "empty-state-secondary-button", disabled: secondaryAction.disabled, onClick: secondaryAction.onClick, variant: "secondary", children: secondaryAction.to ? (jsxRuntime.jsx(reactRouter.Link, { params: secondaryAction.to.parameters, to: secondaryAction.to.pathname, children: secondaryAction.title })) : (secondaryAction.title) })) : null, primaryAction ? (jsxRuntime.jsx(Button, { dataTestId: "empty-state-primary-button", disabled: primaryAction.disabled, onClick: primaryAction.onClick, children: primaryAction.to ? (jsxRuntime.jsx(reactRouter.Link, { params: primaryAction.to.parameters, to: primaryAction.to.pathname, children: primaryAction.title })) : (primaryAction.title) })) : null] }), additionalHelpAction ? (jsxRuntime.jsx(Button, { asChild: true, dataTestId: "empty-state-additional-button", disabled: additionalHelpAction.disabled, onClick: additionalHelpAction.onClick, suffix: jsxRuntime.jsx(Icon, { name: "ArrowTopRightOnSquare", size: "small" }), variant: "ghost", children: jsxRuntime.jsx(reactRouter.Link, { params: additionalHelpAction.to?.parameters, target: additionalHelpAction.to?.target, to: additionalHelpAction.to?.pathname, children: additionalHelpAction.title }) })) : null] })] })) }));
|
|
3293
3288
|
};
|
|
3294
3289
|
|
|
3295
3290
|
const cvaEmptyValue = cssClassVarianceUtilities.cvaMerge(["text-gray-400"]);
|
|
@@ -3431,13 +3426,13 @@ const usePopover = ({ initialOpen = false, placement = "bottom", isModal, isOpen
|
|
|
3431
3426
|
const [uncontrolledIsOpen, setUncontrolledIsOpen] = React.useState(initialOpen);
|
|
3432
3427
|
const [labelId, setLabelId] = React.useState();
|
|
3433
3428
|
const [descriptionId, setDescriptionId] = React.useState();
|
|
3434
|
-
const isOpen = controlledIsOpen
|
|
3429
|
+
const isOpen = controlledIsOpen ?? uncontrolledIsOpen;
|
|
3435
3430
|
const popoverData = react.useFloating({
|
|
3436
3431
|
placement,
|
|
3437
3432
|
open: isOpen,
|
|
3438
3433
|
onOpenChange: open => {
|
|
3439
3434
|
setUncontrolledIsOpen(open);
|
|
3440
|
-
onOpenStateChange
|
|
3435
|
+
onOpenStateChange?.(open);
|
|
3441
3436
|
},
|
|
3442
3437
|
whileElementsMounted: react.autoUpdate,
|
|
3443
3438
|
middleware: [
|
|
@@ -3567,8 +3562,7 @@ const getDefaultPortalContainer = () => {
|
|
|
3567
3562
|
* alongside other portalled elements.
|
|
3568
3563
|
*/
|
|
3569
3564
|
const Portal = (props) => {
|
|
3570
|
-
|
|
3571
|
-
return jsxRuntime.jsx(react.FloatingPortal, { ...props, root: (_a = props.root) !== null && _a !== void 0 ? _a : getDefaultPortalContainer() });
|
|
3565
|
+
return jsxRuntime.jsx(react.FloatingPortal, { ...props, root: props.root ?? getDefaultPortalContainer() });
|
|
3572
3566
|
};
|
|
3573
3567
|
|
|
3574
3568
|
const cvaPopoverContainer = cssClassVarianceUtilities.cvaMerge(["component-popover-border", "z-popover", "animate-fade-in-fast"]);
|
|
@@ -3583,10 +3577,9 @@ const cvaPopoverTitleContainer = cssClassVarianceUtilities.cvaMerge(["flex", "it
|
|
|
3583
3577
|
const cvaPopoverTitleText = cssClassVarianceUtilities.cvaMerge(["flex-1", "text-neutral-500"]);
|
|
3584
3578
|
|
|
3585
3579
|
const PopoverContent = React.forwardRef(function PopoverContent({ className, dataTestId, children, portalId, ...props }, propRef) {
|
|
3586
|
-
var _a;
|
|
3587
3580
|
const { context: floatingContext, customProps, ...context } = usePopoverContext();
|
|
3588
3581
|
const ref = react.useMergeRefs([context.refs.setFloating, propRef]);
|
|
3589
|
-
return (jsxRuntime.jsx(Portal, { id: portalId, children: context.isOpen ? (jsxRuntime.jsx(react.FloatingFocusManager, { closeOnFocusOut: false, context: floatingContext, guards: true, modal: context.isModal, order: ["reference", "content"], returnFocus: true, children: jsxRuntime.jsx("div", { "aria-describedby": context.descriptionId, "aria-labelledby": context.labelId, className: cvaPopoverContainer({ className: className
|
|
3582
|
+
return (jsxRuntime.jsx(Portal, { id: portalId, children: context.isOpen ? (jsxRuntime.jsx(react.FloatingFocusManager, { closeOnFocusOut: false, context: floatingContext, guards: true, modal: context.isModal, order: ["reference", "content"], returnFocus: true, children: jsxRuntime.jsx("div", { "aria-describedby": context.descriptionId, "aria-labelledby": context.labelId, className: cvaPopoverContainer({ className: className ?? customProps.className }), "data-testid": dataTestId ?? customProps.dataTestId ?? "popover-content", ref: ref, style: {
|
|
3590
3583
|
position: context.strategy,
|
|
3591
3584
|
top: context.y,
|
|
3592
3585
|
left: context.x,
|
|
@@ -3697,8 +3690,8 @@ const FloatingArrowContainer = ({ arrowRef, mode = "dark", }) => {
|
|
|
3697
3690
|
* @returns {JSX.Element} Tooltip component
|
|
3698
3691
|
*/
|
|
3699
3692
|
const Tooltip = ({ children, dataTestId = "tool-tip", disabled, className, label, placement = "auto", mode = "dark", iconProps, id, }) => {
|
|
3700
|
-
const [isOpen, setIsOpen] =
|
|
3701
|
-
const arrowRef =
|
|
3693
|
+
const [isOpen, setIsOpen] = React.useState(false);
|
|
3694
|
+
const arrowRef = React.useRef(null);
|
|
3702
3695
|
const { refs, floatingStyles, context } = react.useFloating({
|
|
3703
3696
|
placement: placement === "auto" ? "bottom" : placement,
|
|
3704
3697
|
open: isOpen,
|
|
@@ -3710,13 +3703,13 @@ const Tooltip = ({ children, dataTestId = "tool-tip", disabled, className, label
|
|
|
3710
3703
|
// Please don't try to move this into the component body directly
|
|
3711
3704
|
// I tried and it caused infinite re-renders some places (for whatever reason)
|
|
3712
3705
|
const wrappedChildren = (jsxRuntime.jsx("div", { className: cvaTooltipContainer({ className }), "data-testid": dataTestId ? `${dataTestId}-parent` : undefined, children: children }));
|
|
3713
|
-
const openTooltip =
|
|
3706
|
+
const openTooltip = React.useCallback(() => {
|
|
3714
3707
|
if (disabled) {
|
|
3715
3708
|
return;
|
|
3716
3709
|
}
|
|
3717
3710
|
setIsOpen(true);
|
|
3718
3711
|
}, [disabled]);
|
|
3719
|
-
const closeTooltip =
|
|
3712
|
+
const closeTooltip = React.useCallback(() => {
|
|
3720
3713
|
if (disabled) {
|
|
3721
3714
|
return;
|
|
3722
3715
|
}
|
|
@@ -3905,15 +3898,14 @@ const KPICard = ({ asChild = false, title, value, loading, unit, className, data
|
|
|
3905
3898
|
const Comp = asChild ? reactSlot.Slot : "div";
|
|
3906
3899
|
const isSmallVariant = variant === "small";
|
|
3907
3900
|
return (jsxRuntime.jsxs(Comp, { className: cvaKPICardContainer({ className, isClickable: Boolean(asChild || onClick) }), "data-testid": `${dataTestId}-comp`, onClick: onClick, ...rest, children: [jsxRuntime.jsx(Tooltip, { className: "w-full", disabled: !tooltipLabel, label: tooltipLabel, placement: "bottom", children: jsxRuntime.jsx(Card, { className: cvaKPICard({ isClickable: Boolean((onClick || asChild) && !loading), isActive, variant }), children: loading ? (jsxRuntime.jsx(LoadingContent, {})) : (jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx(Text, { dataTestId: `${dataTestId}-title`, size: isSmallVariant ? "small" : "medium", subtle: true, weight: isSmallVariant ? "normal" : "bold", children: title }), jsxRuntime.jsx(Text, { className: isSmallVariant ? "mt-0.5" : "", dataTestId: `${dataTestId}-value`, size: isSmallVariant ? "small" : "large", type: "div", weight: isSmallVariant ? "bold" : "thick", children: jsxRuntime.jsxs("div", { className: cvaKPICardValueContainer({
|
|
3908
|
-
isDefaultAndHasTrendValue: Boolean(
|
|
3901
|
+
isDefaultAndHasTrendValue: Boolean(trend?.value && !isSmallVariant),
|
|
3909
3902
|
}), children: [jsxRuntime.jsxs("span", { children: [value, " ", unit] }), jsxRuntime.jsx(TrendIndicator, { isSmallVariant: isSmallVariant, trend: trend, unit: unit })] }) })] })) }) }), !loading && jsxRuntime.jsx(reactSlot.Slottable, { children: rest.children })] }));
|
|
3910
3903
|
};
|
|
3911
3904
|
const TrendIndicator = ({ trend, unit, isSmallVariant }) => {
|
|
3912
|
-
var _a, _b;
|
|
3913
3905
|
if (!trend) {
|
|
3914
3906
|
return null;
|
|
3915
3907
|
}
|
|
3916
|
-
return (jsxRuntime.jsxs("div", { className: "flex flex-row items-center gap-1", "data-testid": "trend-indicator", children: [!isSmallVariant && trend.value ? (jsxRuntime.jsxs(Text, { dataTestId: "trend-value", size: "small", weight: "normal", children: [trend.value, " ", unit] })) : null,
|
|
3908
|
+
return (jsxRuntime.jsxs("div", { className: "flex flex-row items-center gap-1", "data-testid": "trend-indicator", children: [!isSmallVariant && trend.value ? (jsxRuntime.jsxs(Text, { dataTestId: "trend-value", size: "small", weight: "normal", children: [trend.value, " ", unit] })) : null, trend.variant?.icon ? jsxRuntime.jsx(Icon, { color: trend.variant.color, name: trend.variant.icon, size: "small" }) : null, trend.percentage ? (jsxRuntime.jsxs(Text, { className: cvaKPICardTrendPercentage({ color: trend.variant?.color }), size: "small", weight: "bold", children: [trend.percentage, "%"] })) : null] }));
|
|
3917
3909
|
};
|
|
3918
3910
|
|
|
3919
3911
|
const cvaMenuList = cssClassVarianceUtilities.cvaMerge([
|
|
@@ -4003,7 +3995,7 @@ const cvaInteractableItem = cssClassVarianceUtilities.cvaMerge("", {
|
|
|
4003
3995
|
* The cvaInteractableItem variant is used to set the standardized styles that change through interaction with the element (background color, hover, focus, and disabled).
|
|
4004
3996
|
*/
|
|
4005
3997
|
const cvaMenuItem = (props) => {
|
|
4006
|
-
const { selected, disabled, focused, className, variant } = props
|
|
3998
|
+
const { selected, disabled, focused, className, variant } = props ?? {};
|
|
4007
3999
|
return tailwindMerge.twMerge(cvaMenuItemStyle({ variant, selected, disabled }), cvaInteractableItem({ selected, disabled, cursor: "pointer", focused }), className);
|
|
4008
4000
|
};
|
|
4009
4001
|
const cvaMenuItemStyle = cssClassVarianceUtilities.cvaMerge(["py-2", "px-2", "h-auto", "flex", "flex-row", "items-center", "gap-x-2", "select-none", "rounded", "text-sm"], {
|
|
@@ -4120,8 +4112,8 @@ const MenuItem = ({ className, dataTestId, label, children, selected, prefix, su
|
|
|
4120
4112
|
variant,
|
|
4121
4113
|
}), "data-testid": dataTestId ? `${dataTestId}-menu-item` : "menu-item", id: id, onClick: e => {
|
|
4122
4114
|
stopPropagation && e.stopPropagation();
|
|
4123
|
-
onClick
|
|
4124
|
-
}, onKeyDown: handleKeyDown, role: "menuitem", tabIndex: disabled ? -1 : (tabIndex
|
|
4115
|
+
onClick?.(e);
|
|
4116
|
+
}, 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 }), "data-testid": dataTestId ? `${dataTestId}-suffix` : "menu-item-suffix", children: suffix })) : null] }));
|
|
4125
4117
|
};
|
|
4126
4118
|
|
|
4127
4119
|
/**
|
|
@@ -4137,8 +4129,8 @@ const MenuItem = ({ className, dataTestId, label, children, selected, prefix, su
|
|
|
4137
4129
|
*/
|
|
4138
4130
|
const MenuList = ({ dataTestId, className, children, withStickyHeader = false, isMulti = false, selectedItems: controlledSelectedItems, onSelectionChange, ...args }) => {
|
|
4139
4131
|
const childrenArr = React.Children.toArray(children);
|
|
4140
|
-
const [internalSelectedItems, setInternalSelectedItems] = React.useState(controlledSelectedItems
|
|
4141
|
-
const selectedItems = controlledSelectedItems
|
|
4132
|
+
const [internalSelectedItems, setInternalSelectedItems] = React.useState(controlledSelectedItems ?? []);
|
|
4133
|
+
const selectedItems = controlledSelectedItems ?? internalSelectedItems;
|
|
4142
4134
|
const handleItemClick = React.useCallback((id, disabled) => {
|
|
4143
4135
|
if (disabled) {
|
|
4144
4136
|
return;
|
|
@@ -4156,22 +4148,21 @@ const MenuList = ({ dataTestId, className, children, withStickyHeader = false, i
|
|
|
4156
4148
|
}
|
|
4157
4149
|
}, [isMulti, selectedItems, onSelectionChange]);
|
|
4158
4150
|
return (jsxRuntime.jsx("div", { className: cvaMenuList({ stickyHeader: withStickyHeader, className }), "data-testid": dataTestId ? `${dataTestId}-menu-list` : "menu-list", onClick: args.onClick, role: "list", tabIndex: 0, children: childrenArr.map((menuItem, index) => {
|
|
4159
|
-
var _a, _b;
|
|
4160
4151
|
if (React.isValidElement(menuItem)) {
|
|
4161
|
-
const isSelected = selectedItems.includes(
|
|
4152
|
+
const isSelected = selectedItems.includes(menuItem.props.id ?? `${index}`) || menuItem.props.selected;
|
|
4162
4153
|
return React.cloneElement(menuItem, {
|
|
4163
4154
|
...menuItem.props,
|
|
4164
4155
|
key: index,
|
|
4165
4156
|
onClick: (event) => {
|
|
4166
|
-
|
|
4167
|
-
(
|
|
4168
|
-
handleItemClick((_c = menuItem.props.id) !== null && _c !== void 0 ? _c : `${index}`, menuItem.props.disabled);
|
|
4157
|
+
menuItem.props.onClick?.(event);
|
|
4158
|
+
handleItemClick(menuItem.props.id ?? `${index}`, menuItem.props.disabled);
|
|
4169
4159
|
},
|
|
4170
4160
|
className: isMulti && isSelected
|
|
4171
4161
|
? cvaMenuListMultiSelect({ className: menuItem.props.className })
|
|
4172
4162
|
: cvaMenuListItem({ className: menuItem.props.className }),
|
|
4173
4163
|
selected: isSelected,
|
|
4174
|
-
suffix:
|
|
4164
|
+
suffix: menuItem.props.suffix ??
|
|
4165
|
+
(isMulti && isSelected ? jsxRuntime.jsx(Icon, { className: "block text-blue-600", name: "Check", size: "medium" }) : null),
|
|
4175
4166
|
});
|
|
4176
4167
|
}
|
|
4177
4168
|
return null;
|
|
@@ -4197,7 +4188,7 @@ const MoreMenu = ({ className, dataTestId, popoverProps, iconProps = {
|
|
|
4197
4188
|
variant: "secondary",
|
|
4198
4189
|
}, customButton, customPortalId, children, }) => {
|
|
4199
4190
|
const actionMenuRef = React.useRef(null);
|
|
4200
|
-
return (jsxRuntime.jsx("div", { className: cvaMoreMenu({ className }), "data-testid": dataTestId ? dataTestId : "more-menu", ref: actionMenuRef, children: jsxRuntime.jsxs(Popover, { placement: "bottom-end", ...popoverProps, children: [jsxRuntime.jsx(PopoverTrigger, { children: customButton
|
|
4191
|
+
return (jsxRuntime.jsx("div", { className: cvaMoreMenu({ className }), "data-testid": dataTestId ? dataTestId : "more-menu", ref: actionMenuRef, children: jsxRuntime.jsxs(Popover, { placement: "bottom-end", ...popoverProps, children: [jsxRuntime.jsx(PopoverTrigger, { children: customButton ?? (jsxRuntime.jsx(IconButton, { dataTestId: "more-menu-icon", ...iconButtonProps, icon: jsxRuntime.jsx(Icon, { name: "EllipsisHorizontal", ...iconProps }) })) }), jsxRuntime.jsx(PopoverContent, { portalId: customPortalId, children: close => (typeof children === "function" ? children(close) : children) })] }) }));
|
|
4201
4192
|
};
|
|
4202
4193
|
|
|
4203
4194
|
const cvaNotice = cssClassVarianceUtilities.cvaMerge(["flex", "items-center"]);
|
|
@@ -4302,7 +4293,7 @@ const Page = ({ layout, className, children, dataTestId }) => {
|
|
|
4302
4293
|
* Applies padding to content. To be used within a <Page/>
|
|
4303
4294
|
*
|
|
4304
4295
|
* @param {PageContentProps} props - The component props.
|
|
4305
|
-
* @returns {
|
|
4296
|
+
* @returns {ReactNode} - The rendered component.
|
|
4306
4297
|
*/
|
|
4307
4298
|
const PageContent = ({ className, children, dataTestId, layout }) => {
|
|
4308
4299
|
return (jsxRuntime.jsx("div", { className: cvaPageContent({ className, layout }), "data-testid": dataTestId ? dataTestId : "page-content", children: children }));
|
|
@@ -4362,7 +4353,7 @@ const PageHeader = ({ className, dataTestId, action, actionPosition, showLoading
|
|
|
4362
4353
|
withBorder: !tabsList,
|
|
4363
4354
|
}), "data-testid": dataTestId, children: [jsxRuntime.jsxs("div", { className: cvaPageHeader(), children: [jsxRuntime.jsxs("div", { className: cvaPageHeaderHeadingAccessoriesContainer({
|
|
4364
4355
|
actionPosition: actionPosition ? actionPosition : null,
|
|
4365
|
-
}), "data-testid": dataTestId ? `${dataTestId}-heading-container` : undefined, children: [jsxRuntime.jsxs("div", { className: cvaPageHeaderHeadingContainer(), children: [backTo ? (jsxRuntime.jsx(Button, { asChild: true, className: "bg-black/5 hover:bg-black/10", prefix: jsxRuntime.jsx(Icon, { name: "ArrowLeft", size: "small" }), size: "small", square: true, variant: "ghost-neutral", children: jsxRuntime.jsx(reactRouter.Link, { to: backTo }) })) : undefined, jsxRuntime.jsxs("div", { className: "flex flex-col", children: [jsxRuntime.jsxs("div", { className: "flex flex-row flex-wrap items-center gap-x-4 gap-y-2", children: [jsxRuntime.jsx("h1", { className: cvaPageHeaderHeading(), "data-testid": dataTestId ? `${dataTestId}-heading` : undefined, children: title }), description && !showLoading ? (jsxRuntime.jsx(Tooltip, { dataTestId: dataTestId ? `${dataTestId}-tooltip` : undefined, iconProps: { name: descriptionIcon
|
|
4356
|
+
}), "data-testid": dataTestId ? `${dataTestId}-heading-container` : undefined, children: [jsxRuntime.jsxs("div", { className: cvaPageHeaderHeadingContainer(), children: [backTo ? (jsxRuntime.jsx(Button, { asChild: true, className: "bg-black/5 hover:bg-black/10", prefix: jsxRuntime.jsx(Icon, { name: "ArrowLeft", size: "small" }), size: "small", square: true, variant: "ghost-neutral", children: jsxRuntime.jsx(reactRouter.Link, { to: backTo }) })) : undefined, jsxRuntime.jsxs("div", { className: "flex flex-col", children: [jsxRuntime.jsxs("div", { className: "flex flex-row flex-wrap items-center gap-x-4 gap-y-2", children: [jsxRuntime.jsx("h1", { className: cvaPageHeaderHeading(), "data-testid": dataTestId ? `${dataTestId}-heading` : undefined, children: title }), description && !showLoading ? (jsxRuntime.jsx(Tooltip, { dataTestId: dataTestId ? `${dataTestId}-tooltip` : undefined, iconProps: { name: descriptionIcon ?? "QuestionMarkCircle" }, label: description, placement: "bottom" })) : undefined, tag && !showLoading ? (jsxRuntime.jsx(Tag, { color: tagColor, dataTestId: dataTestId ? `${dataTestId}-tag` : undefined, children: tag })) : undefined] }), link ? (jsxRuntime.jsxs(reactRouter.Link, { className: cvaPageHeaderLink(), "data-testid": "tooltip-link", target: "_blank", to: link, children: [linkText, jsxRuntime.jsx(Icon, { name: "ArrowTopRightOnSquare", size: "small" })] })) : undefined] }), showLoading ? (jsxRuntime.jsx(Spinner, { centering: "vertically", dataTestId: dataTestId ? `${dataTestId}-spinner` : undefined })) : null] }), jsxRuntime.jsx("div", { children: action })] }), children ? jsxRuntime.jsx("div", { className: cvaPageHeaderChildContainer(), children: children }) : null] }), tabsList] }));
|
|
4366
4357
|
};
|
|
4367
4358
|
|
|
4368
4359
|
const cvaPagination = cssClassVarianceUtilities.cvaMerge(["flex", "items-center", "gap-1"]);
|
|
@@ -4406,7 +4397,7 @@ const Pagination = ({ previousPage, nextPage, canPreviousPage, canNextPage, page
|
|
|
4406
4397
|
setPage(to);
|
|
4407
4398
|
setCurrentPage(String(to + 1));
|
|
4408
4399
|
}
|
|
4409
|
-
onPageChange
|
|
4400
|
+
onPageChange?.({ from, to, description });
|
|
4410
4401
|
}, [page, onPageChange, previousPage, nextPage]);
|
|
4411
4402
|
if (loading) {
|
|
4412
4403
|
return (jsxRuntime.jsx("div", { className: cvaPagination({ className }), children: jsxRuntime.jsx(SkeletonLines, { height: 16, width: 150 }) }));
|
|
@@ -4577,7 +4568,7 @@ const useOverflowItems = ({ threshold = 1, childUniqueIdentifierAttribute = "id"
|
|
|
4577
4568
|
}, [handleIntersection, threshold]);
|
|
4578
4569
|
const unobserve = React.useCallback(() => {
|
|
4579
4570
|
const currentObserver = observerRef.current;
|
|
4580
|
-
currentObserver
|
|
4571
|
+
currentObserver?.disconnect();
|
|
4581
4572
|
observerRef.current = null;
|
|
4582
4573
|
}, []);
|
|
4583
4574
|
const initializeObserver = React.useCallback(() => {
|
|
@@ -4608,7 +4599,7 @@ const Sidebar = ({ childContainerClassName, children, breakpoint = "lg", classNa
|
|
|
4608
4599
|
const { overflowContainerRef, itemOverflowMap } = useOverflowItems({
|
|
4609
4600
|
children,
|
|
4610
4601
|
childUniqueIdentifierAttribute: "id",
|
|
4611
|
-
threshold: overflowThreshold
|
|
4602
|
+
threshold: overflowThreshold ?? 0.8,
|
|
4612
4603
|
});
|
|
4613
4604
|
const overflowItemCount = sharedUtils.objectValues(itemOverflowMap).filter(isOverflowing => isOverflowing).length;
|
|
4614
4605
|
const itemVisibilityClassName = (id) => {
|
|
@@ -4623,12 +4614,11 @@ const Sidebar = ({ childContainerClassName, children, breakpoint = "lg", classNa
|
|
|
4623
4614
|
});
|
|
4624
4615
|
}) }), overflowItemCount > 0 ? (jsxRuntime.jsx(MoreMenu, { iconButtonProps: {
|
|
4625
4616
|
variant: "ghost-neutral",
|
|
4626
|
-
}, ...moreMenuProps, className: moreMenuProps
|
|
4617
|
+
}, ...moreMenuProps, className: moreMenuProps?.className, dataTestId: dataTestId ? `${dataTestId}-more-menu` : undefined, children: close => (jsxRuntime.jsx(MenuList, { ...menuListProps, dataTestId: dataTestId, children: React.Children.map(children, child => {
|
|
4627
4618
|
return itemOverflowMap[child.props.id]
|
|
4628
4619
|
? React.cloneElement(child, {
|
|
4629
4620
|
onClick: () => {
|
|
4630
|
-
|
|
4631
|
-
(_b = (_a = child.props).onClick) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
4621
|
+
child.props.onClick?.();
|
|
4632
4622
|
close();
|
|
4633
4623
|
},
|
|
4634
4624
|
className: "w-full",
|
|
@@ -4752,7 +4742,7 @@ const cvaToggleItemText = cssClassVarianceUtilities.cvaMerge(["text-ellipsis", "
|
|
|
4752
4742
|
const ToggleGroup = ({ list, selected, setSelected, onChange, disabled = false, size = "medium", isIconOnly = false, className, dataTestId, }) => {
|
|
4753
4743
|
return (jsxRuntime.jsx("div", { className: cvaToggleGroup(), "data-testid": dataTestId, children: list.map((item, index) => (jsxRuntime.jsx(ToggleItem, { className: tailwindMerge.twMerge(className, index === 0 ? ["rounded-l-md", "border-l"] : "", index === list.length - 1 ? ["rounded-r-md", "border-r"] : ""), dataTestId: item.dataTestId, disabled: disabled, iconName: item.iconName, isIconOnly: isIconOnly, onClick: () => {
|
|
4754
4744
|
setSelected(item.id);
|
|
4755
|
-
onChange
|
|
4745
|
+
onChange?.(item.id);
|
|
4756
4746
|
}, selected: selected === item.id, size: size, text: item.text, title: item.title, tooltip: item.tooltip }, item.id))) }));
|
|
4757
4747
|
};
|
|
4758
4748
|
/**
|
|
@@ -4760,7 +4750,7 @@ const ToggleGroup = ({ list, selected, setSelected, onChange, disabled = false,
|
|
|
4760
4750
|
*/
|
|
4761
4751
|
const ToggleItem = ({ title, onClick, disabled = false, isIconOnly = false, iconName, size, className, selected = false, text, tooltip, dataTestId, }) => {
|
|
4762
4752
|
// eslint-disable-next-line sonarjs/no-selector-parameter
|
|
4763
|
-
return isIconOnly ? (jsxRuntime.jsx(Tooltip, { label:
|
|
4753
|
+
return isIconOnly ? (jsxRuntime.jsx(Tooltip, { label: tooltip?.content || title, placement: tooltip?.placement || "top", children: jsxRuntime.jsx(IconButton, { className: cvaToggleItem({ className, selected }), "data-testid": dataTestId, disabled: disabled, icon: iconName ? (jsxRuntime.jsx(Icon, { className: selected ? "text-slate-600" : "text-slate-400", name: iconName, size: "small" })) : null, onClick: onClick, size: size, title: iconName, variant: "secondary" }) })) : (jsxRuntime.jsx(Tooltip, { disabled: !text?.truncate && tooltip?.content === undefined, label: tooltip?.content || title, placement: tooltip?.placement || "top", children: jsxRuntime.jsx(Button, { className: cvaToggleItem({ className, selected }), "data-testid": dataTestId, disabled: disabled, onClick: onClick, prefix: iconName ? (jsxRuntime.jsx(Icon, { className: selected ? "text-slate-600" : "text-slate-400", name: iconName, size: "small" })) : null, size: size, variant: "secondary", children: jsxRuntime.jsx("span", { className: cvaToggleItemText({ disabledAndSelected: disabled && selected, maxWidth: text?.maxWidth }), children: title }) }) }));
|
|
4764
4754
|
};
|
|
4765
4755
|
|
|
4766
4756
|
const cvaValueBar = cssClassVarianceUtilities.cvaMerge(["w-full"], {
|
|
@@ -4843,14 +4833,13 @@ const getDefaultFillColor = (score) => {
|
|
|
4843
4833
|
* @returns {string} color value
|
|
4844
4834
|
*/
|
|
4845
4835
|
const getFillColor = (score, levelColors) => {
|
|
4846
|
-
var _a, _b;
|
|
4847
4836
|
if (levelColors.low && score < (levelColors.low.level || 0)) {
|
|
4848
4837
|
return levelColors.low.color;
|
|
4849
4838
|
}
|
|
4850
4839
|
if (levelColors.high && score >= (levelColors.high.level || 0)) {
|
|
4851
4840
|
return levelColors.high.color;
|
|
4852
4841
|
}
|
|
4853
|
-
return
|
|
4842
|
+
return levelColors.medium?.color ?? uiDesignTokens.color("WARNING", 300);
|
|
4854
4843
|
};
|
|
4855
4844
|
/**
|
|
4856
4845
|
* Helper function to get color used by the ValueBar
|
|
@@ -4876,7 +4865,7 @@ const ValueBar = ({ value, min = 0, max = 100, unit, size = "small", levelColors
|
|
|
4876
4865
|
const score = getScore(value, min, max, zeroScoreAllowed);
|
|
4877
4866
|
const barFillColor = levelColors ? getFillColor(score, levelColors) : getDefaultFillColor(score);
|
|
4878
4867
|
const barWidth = showValue && size === "small" ? 90 : 100;
|
|
4879
|
-
return (jsxRuntime.jsx("svg", { className: cvaValueBar({ size, className }), "data-testid": dataTestId, role: "img", children: jsxRuntime.jsxs("g", { children: [jsxRuntime.jsx("rect", { className: cvaValueBarProgress({ fill: "background", className }), "data-testid": "value-bar-svg-rect-0", rx: size === "extraSmall" ? "2" : "5", width: `${barWidth}%` }), jsxRuntime.jsx("rect", { className: cvaValueBarProgress(), "data-testid": "value-bar-svg-rect-1", fill: barFillColor, rx: size === "extraSmall" ? "2" : "5", width: `${score * barWidth}%` }), showValue && size === "large" ? (jsxRuntime.jsxs("text", { className: cvaValueBarText({ size }), fill: valueColor
|
|
4868
|
+
return (jsxRuntime.jsx("svg", { className: cvaValueBar({ size, className }), "data-testid": dataTestId, role: "img", children: jsxRuntime.jsxs("g", { children: [jsxRuntime.jsx("rect", { className: cvaValueBarProgress({ fill: "background", className }), "data-testid": "value-bar-svg-rect-0", rx: size === "extraSmall" ? "2" : "5", width: `${barWidth}%` }), jsxRuntime.jsx("rect", { className: cvaValueBarProgress(), "data-testid": "value-bar-svg-rect-1", fill: barFillColor, rx: size === "extraSmall" ? "2" : "5", width: `${score * barWidth}%` }), showValue && size === "large" ? (jsxRuntime.jsxs("text", { className: cvaValueBarText({ size }), fill: valueColor ?? "white", x: "12", y: "23", children: [Number(value.toFixed(1)), unit || ""] })) : null, showValue && size === "small" ? (jsxRuntime.jsxs("text", { className: cvaValueBarText({ size }), fill: valueColor ?? uiDesignTokens.color("NEUTRAL", 400, "CSS"), x: `${barWidth + 2}%`, y: "11", children: [Number(value.toFixed(1)), unit || ""] })) : null] }) }));
|
|
4880
4869
|
};
|
|
4881
4870
|
|
|
4882
4871
|
const cvaVirtualizedListContainer = cssClassVarianceUtilities.cvaMerge(["h-full", "overflow-auto"]);
|
|
@@ -4907,13 +4896,12 @@ const cvaVirtualizedListItem = cssClassVarianceUtilities.cvaMerge(["absolute", "
|
|
|
4907
4896
|
* @property {skeletonLinesHeight} [skeletonLinesHeight="2rem"] - The height of the skeleton lines.
|
|
4908
4897
|
*/
|
|
4909
4898
|
const VirtualizedList = ({ count, rowHeight = 40, pagination, children, className, dataTestId, separator = "none", loadingIndicator = "spinner", skeletonLinesHeight = rowHeight + "px", onRowClick, }) => {
|
|
4910
|
-
var _a;
|
|
4911
4899
|
const containerRef = React.useRef(null);
|
|
4912
4900
|
const listRef = React.useRef(null);
|
|
4913
4901
|
const { fetchMoreOnBottomReached, getVirtualItems, getTotalSize, measureElement } = reactTablePagination.useInfiniteScroll({
|
|
4914
4902
|
pagination: pagination || reactTablePagination.noPagination,
|
|
4915
4903
|
containerRef,
|
|
4916
|
-
rowSize:
|
|
4904
|
+
rowSize: pagination?.pageInfo?.hasNextPage && pagination.isLoading ? count + 1 : count,
|
|
4917
4905
|
rowHeight,
|
|
4918
4906
|
});
|
|
4919
4907
|
return (jsxRuntime.jsx("div", { className: cvaVirtualizedListContainer({ className }), "data-testid": dataTestId,
|
|
@@ -4922,7 +4910,7 @@ const VirtualizedList = ({ count, rowHeight = 40, pagination, children, classNam
|
|
|
4922
4910
|
const isLoaderRow = virtualRow.index > count - 1;
|
|
4923
4911
|
return (jsxRuntime.jsx("li", { className: cvaVirtualizedListItem({ separator }), "data-index": virtualRow.index, onClick: onRowClick ? () => onRowClick(virtualRow.index) : undefined, ref: measureElement, style: {
|
|
4924
4912
|
transform: `translateY(${virtualRow.start}px)`,
|
|
4925
|
-
}, tabIndex: -1, children: isLoaderRow ? (
|
|
4913
|
+
}, tabIndex: -1, children: isLoaderRow ? (pagination?.isLoading ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [loadingIndicator === "spinner" && jsxRuntime.jsx(Spinner, { centering: "horizontally", containerClassName: "p-4" }), loadingIndicator === "skeletonLines" && (jsxRuntime.jsx(SkeletonLines, { height: skeletonLinesHeight, lines: 3, width: "full" }))] })) : null) : (children(virtualRow.index)) }, virtualRow.key));
|
|
4926
4914
|
}) }) }));
|
|
4927
4915
|
};
|
|
4928
4916
|
|