@trackunit/react-components 1.8.21 → 1.8.23
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 +182 -124
- package/index.esm.js +182 -124
- package/package.json +7 -7
- package/src/common/PackageNameStoryComponent.d.ts +2 -1
- package/src/components/Alert/Alert.d.ts +2 -2
- package/src/components/Badge/Badge.d.ts +2 -1
- package/src/components/Breadcrumb/Breadcrumb.d.ts +3 -2
- package/src/components/Breadcrumb/BreadcrumbForLargeScreen.d.ts +2 -1
- package/src/components/Breadcrumb/BreadcrumbForMediumScreen.d.ts +2 -1
- package/src/components/Breadcrumb/BreadcrumbForSmallScreen.d.ts +2 -1
- package/src/components/Breadcrumb/BreadcrumbItem.d.ts +2 -1
- package/src/components/Card/Card.d.ts +2 -2
- 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 +3 -3
- package/src/components/Collapse/Collapse.d.ts +2 -2
- package/src/components/CompletionStatusIndicator/CompletionStatusIndicator.d.ts +2 -1
- package/src/components/CopyableText/CopyableText.d.ts +2 -1
- package/src/components/EmptyState/EmptyState.d.ts +2 -1
- package/src/components/Highlight/Highlight.d.ts +2 -2
- package/src/components/Icon/Icon.d.ts +2 -2
- package/src/components/InteractableItem/InteractableItem.variants.d.ts +2 -2
- package/src/components/KPICard/KPICard.d.ts +1 -1
- package/src/components/Menu/MenuDivider/MenuDivider.d.ts +2 -1
- package/src/components/Menu/MenuItem/MenuItem.d.ts +2 -2
- package/src/components/Menu/MenuItem/MenuItem.variants.d.ts +3 -2
- package/src/components/Menu/MoreMenu/MoreMenu.d.ts +2 -2
- package/src/components/Page/Page.d.ts +2 -2
- package/src/components/Page/PageContent.d.ts +2 -2
- package/src/components/PageHeader/components/PageHeaderKpiMetrics.d.ts +9 -1
- package/src/components/PageHeader/components/PageHeaderSecondaryActions.d.ts +17 -2
- package/src/components/PageHeader/components/PageHeaderTitle.d.ts +10 -1
- package/src/components/Pagination/Pagination.d.ts +2 -1
- package/src/components/Polygon/Polygon.d.ts +2 -1
- package/src/components/Popover/PopoverContent.d.ts +2 -2
- package/src/components/Popover/PopoverTitle.d.ts +2 -2
- package/src/components/Popover/PopoverTrigger.d.ts +2 -2
- package/src/components/Portal/Portal.d.ts +2 -1
- package/src/components/Sidebar/Sidebar.d.ts +1 -1
- package/src/components/Sidebar/useOverflowItems.d.ts +1 -1
- package/src/components/SkeletonLines/SkeletonLines.d.ts +2 -1
- package/src/components/Spacer/Spacer.d.ts +2 -1
- package/src/components/Spinner/Spinner.d.ts +2 -1
- package/src/components/Tabs/Tab.d.ts +1 -1
- package/src/components/Tabs/TabContent.d.ts +2 -2
- package/src/components/Tabs/TabList.d.ts +1 -1
- package/src/components/Tabs/Tabs.d.ts +2 -2
- package/src/components/Tag/Tag.d.ts +2 -2
- package/src/components/ToggleGroup/ToggleGroup.d.ts +3 -3
- package/src/components/ValueBar/ValueBar.d.ts +2 -1
- package/src/components/VirtualizedList/VirtualizedList.d.ts +1 -1
- package/src/components/ZStack/ZStack.d.ts +2 -2
- package/src/components/buttons/Button/Button.d.ts +2 -2
- package/src/components/buttons/IconButton/IconButton.d.ts +4 -3
- package/src/components/buttons/StarButton/StarButton.d.ts +2 -2
- package/src/hooks/useContinuousTimeout.d.ts +1 -1
- package/src/hooks/useSelfUpdatingRef.d.ts +1 -1
package/index.cjs.js
CHANGED
|
@@ -135,33 +135,29 @@ const isSafari = () => {
|
|
|
135
135
|
* @param {IconProps} props - The props for the Icon component
|
|
136
136
|
* @returns {ReactElement} Icon component
|
|
137
137
|
*/
|
|
138
|
-
const Icon = ({ name, size = "medium", className, dataTestId, color, onClick, type, style, forwardedRef, ariaLabel, fontSize, ariaLabelledBy, ariaDescribedBy, ariaHidden, }) => {
|
|
138
|
+
const Icon = ({ name, size = "medium", className, dataTestId, color = undefined, onClick, type = size === "large" ? "outline" : "solid", style, forwardedRef, ariaLabel, fontSize = false, ariaLabelledBy, ariaDescribedBy, ariaHidden, }) => {
|
|
139
139
|
const useTagRef = react.useRef(null);
|
|
140
140
|
const ICON_CONTAINER_ID = sharedUtils.uuidv4();
|
|
141
141
|
const correctIconType = react.useMemo(() => {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
return "solid";
|
|
142
|
+
switch (size) {
|
|
143
|
+
case "small":
|
|
144
|
+
return "micro";
|
|
145
|
+
case "medium":
|
|
146
|
+
return "mini";
|
|
147
|
+
default:
|
|
148
|
+
return type === "solid" ? "solid" : "outline";
|
|
150
149
|
}
|
|
151
|
-
return "outline";
|
|
152
150
|
}, [type, size]);
|
|
153
151
|
const correctViewBox = react.useMemo(() => {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
return "0 0 24 24";
|
|
152
|
+
switch (size) {
|
|
153
|
+
case "small":
|
|
154
|
+
return "0 0 16 16";
|
|
155
|
+
case "medium":
|
|
156
|
+
return "0 0 20 20";
|
|
157
|
+
default:
|
|
158
|
+
return "0 0 24 24";
|
|
162
159
|
}
|
|
163
|
-
|
|
164
|
-
}, [size, type]);
|
|
160
|
+
}, [size]);
|
|
165
161
|
const iconName = uiIcons.iconNames[name];
|
|
166
162
|
const href = react.useMemo(() => ({
|
|
167
163
|
solid: `${IconSpriteSolid}#${iconName}`,
|
|
@@ -260,15 +256,15 @@ const Tag = ({ className, dataTestId, children, size = "medium", onClose, color
|
|
|
260
256
|
return false;
|
|
261
257
|
}, [color]);
|
|
262
258
|
const layout = react.useMemo(() => {
|
|
263
|
-
if (onClose && isSupportedDismissColor) {
|
|
259
|
+
if (onClose !== undefined && isSupportedDismissColor) {
|
|
264
260
|
return "containsDismiss";
|
|
265
261
|
}
|
|
266
|
-
if (icon) {
|
|
262
|
+
if (icon !== null && icon !== undefined) {
|
|
267
263
|
return "containsIcon";
|
|
268
264
|
}
|
|
269
265
|
return "default";
|
|
270
266
|
}, [onClose, icon, isSupportedDismissColor]);
|
|
271
|
-
return (jsxRuntime.jsxs("div", { className: cvaTag({ className, size, color, layout, border: color === "white" ? "default" : "none" }), "data-testid": dataTestId, onMouseEnter: onMouseEnter, ref: ref, children: [icon && size === "medium" ? jsxRuntime.jsx("div", { className: cvaTagIconContainer(), children: icon }) : null, jsxRuntime.jsx("span", { className: cvaTagText(), children: children }), Boolean(onClose) && isSupportedDismissColor && size === "medium" && !disabled ? (
|
|
267
|
+
return (jsxRuntime.jsxs("div", { className: cvaTag({ className, size, color, layout, border: color === "white" ? "default" : "none" }), "data-testid": dataTestId, onMouseEnter: onMouseEnter, ref: ref, children: [icon !== null && icon !== undefined && size === "medium" ? (jsxRuntime.jsx("div", { className: cvaTagIconContainer(), children: icon })) : null, jsxRuntime.jsx("span", { className: cvaTagText(), children: children }), Boolean(onClose) && isSupportedDismissColor && size === "medium" && !disabled ? (
|
|
272
268
|
// a fix for multiselect deselecting tags working together with fade out animation
|
|
273
269
|
jsxRuntime.jsx("div", { className: cvaTagIconContainer(), onMouseDown: onClose, children: jsxRuntime.jsx(Icon, { className: cvaTagIcon(), dataTestId: dataTestId + "Icon", name: "XCircle", size: "small", style: { WebkitTransition: "-webkit-transform 0.150s" }, type: "solid" }) })) : null] }));
|
|
274
270
|
};
|
|
@@ -750,7 +746,7 @@ const cvaIconButton = cssClassVarianceUtilities.cvaMerge([], {
|
|
|
750
746
|
* @param {ButtonProps} props - The props for the Button component
|
|
751
747
|
* @returns {ReactElement} Button component
|
|
752
748
|
*/
|
|
753
|
-
const Button = ({ onClick, children, loading, disabled, className, fullWidth = false, prefix, suffix, variant = "primary", type = "button", size = "medium", square = false, dataTestId, title, role, tabIndex, asChild = false, circular, ref, ...rest }) => {
|
|
749
|
+
const Button = ({ onClick, children, loading = false, disabled = false, className, fullWidth = false, prefix, suffix, variant = "primary", type = "button", size = "medium", square = false, dataTestId, title, role, tabIndex, asChild = false, circular = false, ref, ...rest }) => {
|
|
754
750
|
const Comp = asChild ? reactSlot.Slot : "button";
|
|
755
751
|
const sharedCompProps = {
|
|
756
752
|
ref,
|
|
@@ -768,7 +764,7 @@ const Button = ({ onClick, children, loading, disabled, className, fullWidth = f
|
|
|
768
764
|
disabled: disabled || loading,
|
|
769
765
|
type,
|
|
770
766
|
};
|
|
771
|
-
return (jsxRuntime.jsxs(Comp, { ...sharedCompProps, ...(asChild ? {} : buttonSpecificProps), children: [loading ? (jsxRuntime.jsx(Spinner, { centering: "vertically", className: cvaButtonSpinner({ variant }), containerClassName: cvaButtonSpinnerContainer(), size: "small" })) : null, prefix && !loading ? jsxRuntime.jsx("div", { className: cvaButtonPrefixSuffix({ size, variant }), children: prefix }) : null, jsxRuntime.jsx(reactSlot.Slottable, { children: children }), suffix && !loading ? jsxRuntime.jsx("div", { className: cvaButtonPrefixSuffix({ size, variant }), children: suffix }) : null] }));
|
|
767
|
+
return (jsxRuntime.jsxs(Comp, { ...sharedCompProps, ...(asChild ? {} : buttonSpecificProps), children: [loading ? (jsxRuntime.jsx(Spinner, { centering: "vertically", className: cvaButtonSpinner({ variant }), containerClassName: cvaButtonSpinnerContainer(), size: "small" })) : null, prefix !== null && prefix !== undefined && !loading ? (jsxRuntime.jsx("div", { className: cvaButtonPrefixSuffix({ size, variant }), children: prefix })) : null, jsxRuntime.jsx(reactSlot.Slottable, { children: children }), suffix !== null && suffix !== undefined && !loading ? (jsxRuntime.jsx("div", { className: cvaButtonPrefixSuffix({ size, variant }), children: suffix })) : null] }));
|
|
772
768
|
};
|
|
773
769
|
Button.displayName = "Button";
|
|
774
770
|
|
|
@@ -778,10 +774,8 @@ Button.displayName = "Button";
|
|
|
778
774
|
/**
|
|
779
775
|
*
|
|
780
776
|
*/
|
|
781
|
-
const IconButton = ({ icon, size = "medium", square = true, loading, disabled, className, ref, ...rest }) => {
|
|
782
|
-
return (jsxRuntime.jsx(Button, { className: cvaIconButton({ size: size, className }), disabled: disabled || loading, loading: loading,
|
|
783
|
-
// eslint-disable-next-line local-rules/design-guideline-button-icon-size-match
|
|
784
|
-
prefix: !loading ? icon : undefined, ref: ref, size: size, square: square, ...rest }));
|
|
777
|
+
const IconButton = ({ icon, size = "medium", square = true, loading = false, disabled = false, className, ref, ...rest }) => {
|
|
778
|
+
return (jsxRuntime.jsx(Button, { className: cvaIconButton({ size: size, className }), disabled: disabled || loading, loading: loading, prefix: !loading ? icon : undefined, ref: ref, size: size, square: square, ...rest }));
|
|
785
779
|
};
|
|
786
780
|
IconButton.displayName = "IconButton";
|
|
787
781
|
|
|
@@ -885,7 +879,7 @@ const cvaAlertIconContainer = cssClassVarianceUtilities.cvaMerge(["shrink-0", "g
|
|
|
885
879
|
* @param {AlertProps} props - The props for the Alert component
|
|
886
880
|
* @returns {ReactElement} Alert component
|
|
887
881
|
*/
|
|
888
|
-
const Alert = ({ color = "info", title, className, children, primaryAction, secondaryAction, onClose, dataTestId, autoScroll, actionsInline = false, }) => {
|
|
882
|
+
const Alert = ({ color = "info", title, className, children, primaryAction, secondaryAction, onClose, dataTestId, autoScroll = false, actionsInline = false, }) => {
|
|
889
883
|
const ref = react.useRef(null);
|
|
890
884
|
const { isTextWrapping, ref: titleRef } = useIsTextWrapping();
|
|
891
885
|
react.useEffect(() => {
|
|
@@ -894,7 +888,19 @@ const Alert = ({ color = "info", title, className, children, primaryAction, seco
|
|
|
894
888
|
ref.current?.scrollIntoView?.();
|
|
895
889
|
}
|
|
896
890
|
}, [ref, autoScroll]);
|
|
897
|
-
return (jsxRuntime.jsxs("div", { className: cvaAlert({ color, actionsInline, className }), "data-testid": dataTestId, ref: ref, role: "alert", children: [jsxRuntime.jsxs("div", { className: cvaAlertContentContainer({
|
|
891
|
+
return (jsxRuntime.jsxs("div", { className: cvaAlert({ color, actionsInline, className }), "data-testid": dataTestId, ref: ref, role: "alert", children: [jsxRuntime.jsxs("div", { className: cvaAlertContentContainer({
|
|
892
|
+
inline: !isTextWrapping && (children === null || children === undefined),
|
|
893
|
+
actionsInline,
|
|
894
|
+
}), children: [jsxRuntime.jsx("div", { className: cvaAlertIconContainer({
|
|
895
|
+
inline: !isTextWrapping && (children === null || children === undefined),
|
|
896
|
+
actionsInline,
|
|
897
|
+
}), 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 !== null && children !== undefined ? (jsxRuntime.jsx(Text, { type: typeof children === "string" || typeof children === "number" ? "p" : "span", weight: "normal", children: children })) : null] }), onClose !== undefined && !actionsInline ? (jsxRuntime.jsx("div", { className: cvaAlertCloseButtonContainer({
|
|
898
|
+
inline: !isTextWrapping && (children === null || children === undefined),
|
|
899
|
+
actionsInline,
|
|
900
|
+
}), children: jsxRuntime.jsx(IconButton, { className: "!h-5 !min-h-0 !w-5 !p-0", icon: jsxRuntime.jsx(Icon, { name: "XMark", size: "small" }), onClick: onClose, size: "small", title: "Close Alert", variant: "ghost-neutral" }) })) : null] }), primaryAction !== undefined || secondaryAction !== undefined ? (jsxRuntime.jsxs("div", { className: cvaAlertActionsContainer({ actionsInline }), children: [secondaryAction !== undefined ? (jsxRuntime.jsx(Button, { loading: secondaryAction.loading, onClick: secondaryAction.onClick, size: "small", variant: "ghost-neutral", children: secondaryAction.label })) : null, primaryAction !== undefined ? (jsxRuntime.jsx(Button, { loading: primaryAction.loading, onClick: primaryAction.onClick, size: "small", variant: color === "danger" ? "primary-danger" : "primary", children: primaryAction.label })) : null] })) : null, onClose !== undefined && actionsInline ? (jsxRuntime.jsx("div", { className: cvaAlertCloseButtonContainer({
|
|
901
|
+
inline: !isTextWrapping && (children === null || children === undefined),
|
|
902
|
+
actionsInline,
|
|
903
|
+
}), children: jsxRuntime.jsx(IconButton, { className: "!h-5 !min-h-0 !w-5 !p-0", icon: jsxRuntime.jsx(Icon, { name: "XMark", size: "small" }), onClick: onClose, size: "small", title: "Close Alert", variant: "ghost-neutral" }) })) : null] }));
|
|
898
904
|
};
|
|
899
905
|
const getIconName = (color) => {
|
|
900
906
|
switch (color) {
|
|
@@ -968,7 +974,11 @@ const Badge = ({ color = "primary", compact = false, className, count, max, hide
|
|
|
968
974
|
if (hideZero && count === 0) {
|
|
969
975
|
return null;
|
|
970
976
|
}
|
|
971
|
-
const displayedCount = count &&
|
|
977
|
+
const displayedCount = count !== undefined && count !== 0 && !Number.isNaN(count) && max !== undefined && max !== 0 && !Number.isNaN(max)
|
|
978
|
+
? count > max
|
|
979
|
+
? `${max}+`
|
|
980
|
+
: count
|
|
981
|
+
: count;
|
|
972
982
|
const isSingleChar = displayedCount?.toString().length === 1;
|
|
973
983
|
return (jsxRuntime.jsx("span", { className: cvaBadge({ color, className, compact, isSingleChar }), "data-testid": dataTestId, children: compact ? null : displayedCount }));
|
|
974
984
|
};
|
|
@@ -1204,10 +1214,10 @@ const useDebounce = (value, delay = 500, direction, onBounce) => {
|
|
|
1204
1214
|
const [debouncedValue, setDebouncedValue] = react.useState(value);
|
|
1205
1215
|
react.useEffect(() => {
|
|
1206
1216
|
let handler;
|
|
1207
|
-
if ((direction === "in" && !debouncedValue && value) ||
|
|
1208
|
-
(direction === "out" && debouncedValue && !value) ||
|
|
1217
|
+
if ((direction === "in" && !Boolean(debouncedValue) && Boolean(value)) ||
|
|
1218
|
+
(direction === "out" && Boolean(debouncedValue) && !Boolean(value)) ||
|
|
1209
1219
|
direction === "both" ||
|
|
1210
|
-
|
|
1220
|
+
direction === undefined) {
|
|
1211
1221
|
handler = setTimeout(() => {
|
|
1212
1222
|
setDebouncedValue(value);
|
|
1213
1223
|
onBounce?.(value);
|
|
@@ -1428,7 +1438,7 @@ const useIsTextTruncated = (text) => {
|
|
|
1428
1438
|
}, [updateTextVisibility]);
|
|
1429
1439
|
// Re-check whenever text changes
|
|
1430
1440
|
react.useEffect(() => {
|
|
1431
|
-
if (
|
|
1441
|
+
if (text === undefined || text === "") {
|
|
1432
1442
|
return;
|
|
1433
1443
|
}
|
|
1434
1444
|
updateTextVisibility();
|
|
@@ -1588,7 +1598,13 @@ const useSelfUpdatingRef = (initialState) => {
|
|
|
1588
1598
|
* }
|
|
1589
1599
|
*/
|
|
1590
1600
|
const useViewportBreakpoints = () => {
|
|
1591
|
-
const [viewportSize, setViewportSize] = react.useState(() =>
|
|
1601
|
+
const [viewportSize, setViewportSize] = react.useState(() => {
|
|
1602
|
+
const newViewportSize = sharedUtils.objectEntries(uiDesignTokens.themeScreenSizeAsNumber).reduce((acc, [size, minWidth]) => ({
|
|
1603
|
+
...acc,
|
|
1604
|
+
[breakpointPropsMap[size]]: window.matchMedia(`(min-width: ${minWidth}px)`).matches,
|
|
1605
|
+
}), { ...defaultBreakpointState });
|
|
1606
|
+
return newViewportSize;
|
|
1607
|
+
});
|
|
1592
1608
|
const updateViewportSize = react.useCallback(() => {
|
|
1593
1609
|
const newViewportSize = sharedUtils.objectEntries(uiDesignTokens.themeScreenSizeAsNumber).reduce((acc, [size, minWidth]) => ({
|
|
1594
1610
|
...acc,
|
|
@@ -1628,7 +1644,11 @@ const useWatch = ({ value, onChange, immediate = false, isEqual }) => {
|
|
|
1628
1644
|
const prevValue = react.useRef(UNINITIALIZED);
|
|
1629
1645
|
react.useEffect(() => {
|
|
1630
1646
|
const prev = prevValue.current;
|
|
1631
|
-
const hasChanged = prev === UNINITIALIZED
|
|
1647
|
+
const hasChanged = prev === UNINITIALIZED
|
|
1648
|
+
? false
|
|
1649
|
+
: isEqual !== undefined
|
|
1650
|
+
? !isEqual(value, prev)
|
|
1651
|
+
: JSON.stringify(value) !== JSON.stringify(prev);
|
|
1632
1652
|
if (immediate && prev === UNINITIALIZED) {
|
|
1633
1653
|
onChange(value, null);
|
|
1634
1654
|
}
|
|
@@ -1888,7 +1908,7 @@ const Card = ({ children, onClick, fullHeight = false, onMouseEnter, onMouseLeav
|
|
|
1888
1908
|
* @param {CardBodyProps} props - The props for the CardBody component
|
|
1889
1909
|
* @returns {ReactElement} CardBody component
|
|
1890
1910
|
*/
|
|
1891
|
-
const CardBody = ({ density = "auto", children, dataTestId, className, direction, disableGap, id, }) => {
|
|
1911
|
+
const CardBody = ({ density = "auto", children, dataTestId, className, direction = "column", disableGap = false, id, }) => {
|
|
1892
1912
|
return (jsxRuntime.jsx("div", { className: cvaCardBodyDensityContainer$1({ density, disableGap, className, direction }), "data-testid": dataTestId, id: id, children: children }));
|
|
1893
1913
|
};
|
|
1894
1914
|
|
|
@@ -1900,7 +1920,7 @@ const CardBody = ({ density = "auto", children, dataTestId, className, direction
|
|
|
1900
1920
|
* @param {CardFooterProps} props - The props for the CardFooter component
|
|
1901
1921
|
* @returns {ReactElement} CardFooter component
|
|
1902
1922
|
*/
|
|
1903
|
-
const CardFooter = ({ dataTestId, className, children, density, hideSeparator = false }) => {
|
|
1923
|
+
const CardFooter = ({ dataTestId, className, children, density = "auto", hideSeparator = false, }) => {
|
|
1904
1924
|
return (jsxRuntime.jsx("div", { className: cvaCardFooterDensityContainer({
|
|
1905
1925
|
density,
|
|
1906
1926
|
border: hideSeparator ? "borderless" : "default",
|
|
@@ -1965,12 +1985,12 @@ const Heading = ({ variant = "primary", inverted = false, subtle = false, classN
|
|
|
1965
1985
|
* @param {CardHeaderProps} props - The props for the CardHeader component
|
|
1966
1986
|
* @returns {ReactElement} CardHeader component
|
|
1967
1987
|
*/
|
|
1968
|
-
const CardHeader = ({ heading, headingVariant = "secondary", subHeading, onClose, dataTestId, className, children, accessories, actions, density, hideSeparator = false, }) => {
|
|
1988
|
+
const CardHeader = ({ heading, headingVariant = "secondary", subHeading, onClose, dataTestId, className, children, accessories, actions, density = "auto", hideSeparator = false, }) => {
|
|
1969
1989
|
return (jsxRuntime.jsx("div", { className: cvaCardHeaderDensityContainer({
|
|
1970
1990
|
density,
|
|
1971
1991
|
border: hideSeparator ? "borderless" : "default",
|
|
1972
1992
|
className,
|
|
1973
|
-
}), "data-testid": dataTestId, children: jsxRuntime.jsxs("div", { className: cvaCardHeader(), children: [jsxRuntime.jsxs("div", { children: [jsxRuntime.jsxs("div", { className: cvaCardHeaderHeadingContainer(), children: [jsxRuntime.jsx(Heading, { className: "self-center", variant: headingVariant, children: heading }), accessories] }), subHeading ? (jsxRuntime.jsx(Heading, { subtle: true, variant: "subtitle", children: subHeading })) : null, children] }), jsxRuntime.jsxs("div", { className: "flex place-items-center gap-x-2 gap-y-1", children: [actions, onClose ? (jsxRuntime.jsx(IconButton, { className: "!h-min", dataTestId: "card-header-close-button", icon: jsxRuntime.jsx(Icon, { name: "XMark", size: "small" }), onClick: onClose, variant: "ghost-neutral" })) : null] })] }) }));
|
|
1993
|
+
}), "data-testid": dataTestId, children: jsxRuntime.jsxs("div", { className: cvaCardHeader(), children: [jsxRuntime.jsxs("div", { children: [jsxRuntime.jsxs("div", { className: cvaCardHeaderHeadingContainer(), children: [jsxRuntime.jsx(Heading, { className: "self-center", variant: headingVariant, children: heading }), accessories] }), subHeading !== null && subHeading !== undefined ? (jsxRuntime.jsx(Heading, { subtle: true, variant: "subtitle", children: subHeading })) : null, children] }), jsxRuntime.jsxs("div", { className: "flex place-items-center gap-x-2 gap-y-1", children: [actions, onClose ? (jsxRuntime.jsx(IconButton, { className: "!h-min", dataTestId: "card-header-close-button", icon: jsxRuntime.jsx(Icon, { name: "XMark", size: "small" }), onClick: onClose, variant: "ghost-neutral" })) : null] })] }) }));
|
|
1974
1994
|
};
|
|
1975
1995
|
|
|
1976
1996
|
const cvaCollapse = cssClassVarianceUtilities.cvaMerge([
|
|
@@ -2056,9 +2076,9 @@ const Collapse = ({ id, initialExpanded = false, onToggle, label, children, clas
|
|
|
2056
2076
|
}
|
|
2057
2077
|
setExpanded(!expanded);
|
|
2058
2078
|
}, [expanded, onToggle]);
|
|
2059
|
-
return (jsxRuntime.jsxs("div", { className: cvaCollapse({ className }), "data-testid": dataTestId, children: [jsxRuntime.jsx("div", { "aria-controls": id, "aria-expanded": expanded, className: cvaCollapseHeader({ expanded, className: headerClassName }), onClick: handleClick, role: "button", children: jsxRuntime.jsxs("div", { className: cvaCollapseLabelContainer(), children: [jsxRuntime.jsx(Text, { id: LABEL_ID, type: "span", weight: "bold", children: label }), jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [headerAddon ? headerAddon : null, jsxRuntime.jsx(Icon, { ariaLabelledBy: LABEL_ID, className: cvaChevronIcon({ expanded }), name: "ChevronUp", size: "medium" })] })] }) }), jsxRuntime.jsx(Collapsible, { expanded: expanded, extraPadding: extraPadding, id: id, children: expanded || animate ? children : null })] }));
|
|
2079
|
+
return (jsxRuntime.jsxs("div", { className: cvaCollapse({ className }), "data-testid": dataTestId, children: [jsxRuntime.jsx("div", { "aria-controls": id, "aria-expanded": expanded, className: cvaCollapseHeader({ expanded, className: headerClassName }), onClick: handleClick, role: "button", children: jsxRuntime.jsxs("div", { className: cvaCollapseLabelContainer(), children: [jsxRuntime.jsx(Text, { id: LABEL_ID, type: "span", weight: "bold", children: label }), jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [headerAddon !== null && headerAddon !== undefined ? headerAddon : null, jsxRuntime.jsx(Icon, { ariaLabelledBy: LABEL_ID, className: cvaChevronIcon({ expanded }), name: "ChevronUp", size: "medium" })] })] }) }), jsxRuntime.jsx(Collapsible, { expanded: expanded, extraPadding: extraPadding, id: id, children: expanded || animate ? children : null })] }));
|
|
2060
2080
|
};
|
|
2061
|
-
const Collapsible = ({ children, expanded, id, extraPadding }) => {
|
|
2081
|
+
const Collapsible = ({ children, expanded, id, extraPadding = true }) => {
|
|
2062
2082
|
const ref = react.useRef(null);
|
|
2063
2083
|
const { height } = useGeometry(ref);
|
|
2064
2084
|
return (jsxRuntime.jsx("div", { className: cvaCollapseAnimated({ expanded }), id: id, style: { height: expanded ? height : "0" }, children: jsxRuntime.jsx("div", { ref: ref, children: jsxRuntime.jsx("div", { className: cvaCollapsible({ extraPadding }), children: children }) }) }));
|
|
@@ -2077,7 +2097,7 @@ const Collapsible = ({ children, expanded, id, extraPadding }) => {
|
|
|
2077
2097
|
* @param {boolean} props.warning - Indicates if the process has a warning.
|
|
2078
2098
|
* @param {boolean} props.success - Indicates if the process was successful.
|
|
2079
2099
|
*/
|
|
2080
|
-
const CompletionStatusIndicator = ({ loading, error, success, ...rest }) => {
|
|
2100
|
+
const CompletionStatusIndicator = ({ loading = false, error, success, ...rest }) => {
|
|
2081
2101
|
if (loading) {
|
|
2082
2102
|
return jsxRuntime.jsx(Spinner, { className: "h-[22px] w-[22px]", containerClassName: "w-min", ...rest });
|
|
2083
2103
|
}
|
|
@@ -2171,17 +2191,17 @@ const cvaSkeletonLine = cssClassVarianceUtilities.cvaMerge([
|
|
|
2171
2191
|
/**
|
|
2172
2192
|
* Display placeholder lines before the data gets loaded to reduce load-time frustration.
|
|
2173
2193
|
*/
|
|
2174
|
-
const SkeletonLines = react.memo(({ margin = "10px 0", lines = 1, height, width = "100%", className, dataTestId }) => {
|
|
2194
|
+
const SkeletonLines = react.memo(({ margin = "10px 0", lines = 1, height, width = "100%", className, dataTestId, }) => {
|
|
2175
2195
|
const skeletonLines = [];
|
|
2176
2196
|
const getWidth = (index) => {
|
|
2177
|
-
if (width
|
|
2178
|
-
return width[index]
|
|
2197
|
+
if (Array.isArray(width)) {
|
|
2198
|
+
return width[index] ?? "100%";
|
|
2179
2199
|
}
|
|
2180
2200
|
return width;
|
|
2181
2201
|
};
|
|
2182
2202
|
const getHeight = (index) => {
|
|
2183
|
-
if (height
|
|
2184
|
-
return height[index]
|
|
2203
|
+
if (Array.isArray(height)) {
|
|
2204
|
+
return height[index] ?? "auto";
|
|
2185
2205
|
}
|
|
2186
2206
|
return height;
|
|
2187
2207
|
};
|
|
@@ -2265,7 +2285,7 @@ WorkerWithSignSVG.displayName = "WorkerWithSignSVG";
|
|
|
2265
2285
|
* - For guidance purposes (e.g., onboarding, adjusting filters, exploring alternative approaches).
|
|
2266
2286
|
* - In celebratory instances (e.g., no new notifications, services up to date).
|
|
2267
2287
|
*/
|
|
2268
|
-
const EmptyState = ({ description, altText, image = "SEARCH_DOCUMENT", customImageSrc, loading, dataTestId, className, primaryAction, secondaryAction, additionalHelpAction, }) => {
|
|
2288
|
+
const EmptyState = ({ description, altText, image = "SEARCH_DOCUMENT", customImageSrc, loading = false, dataTestId, className, primaryAction, secondaryAction, additionalHelpAction, }) => {
|
|
2269
2289
|
const ImageSource = react.useMemo(() => {
|
|
2270
2290
|
switch (image) {
|
|
2271
2291
|
case "WORKER_WITH_SIGN":
|
|
@@ -2283,7 +2303,7 @@ const EmptyState = ({ description, altText, image = "SEARCH_DOCUMENT", customIma
|
|
|
2283
2303
|
return SearchDocumentSVG;
|
|
2284
2304
|
}
|
|
2285
2305
|
}, [image]);
|
|
2286
|
-
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 ? (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 ? (jsxRuntime.jsx(Text, { align: "center", size: "large", children: description })) : null, jsxRuntime.jsxs("div", { className: "mt-4 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?.to ? (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] })] })) }));
|
|
2306
|
+
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 !== 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: "large", children: description })) : null, jsxRuntime.jsxs("div", { className: "mt-4 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?.to ? (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] })] })) }));
|
|
2287
2307
|
};
|
|
2288
2308
|
|
|
2289
2309
|
const cvaEmptyValue = cssClassVarianceUtilities.cvaMerge(["text-neutral-400"]);
|
|
@@ -2634,7 +2654,7 @@ const cvaPopoverTitleText = cssClassVarianceUtilities.cvaMerge(["flex-1", "text-
|
|
|
2634
2654
|
const PopoverContent = function PopoverContent({ className, dataTestId, children, portalId, ref: propRef, ...props }) {
|
|
2635
2655
|
const { context: floatingContext, customProps, ...context } = usePopoverContext();
|
|
2636
2656
|
const ref = react$1.useMergeRefs([context.refs.setFloating, propRef]);
|
|
2637
|
-
return (jsxRuntime.jsx(Portal, { id: portalId, children: context.isOpen ? (jsxRuntime.jsx(react$1.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: {
|
|
2657
|
+
return (jsxRuntime.jsx(Portal, { id: portalId, children: context.isOpen === true ? (jsxRuntime.jsx(react$1.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: {
|
|
2638
2658
|
position: context.strategy,
|
|
2639
2659
|
top: context.y,
|
|
2640
2660
|
left: context.x,
|
|
@@ -2649,7 +2669,7 @@ const PopoverContent = function PopoverContent({ className, dataTestId, children
|
|
|
2649
2669
|
* @param {PopoverTitleProps} props - The props for the PopoverTitle component
|
|
2650
2670
|
* @returns {ReactElement} PopoverTitle component
|
|
2651
2671
|
*/
|
|
2652
|
-
const PopoverTitle = ({ children, action, divider = false, className, dataTestId }) => {
|
|
2672
|
+
const PopoverTitle = ({ children, action, divider = false, className, dataTestId, }) => {
|
|
2653
2673
|
return (jsxRuntime.jsxs("div", { className: cvaPopoverTitleContainer({ divider, className }), "data-testid": dataTestId, children: [jsxRuntime.jsx(Text, { className: cvaPopoverTitleText(), size: "small", subtle: true, type: "div", uppercase: true, weight: "bold", children: children }), action] }));
|
|
2654
2674
|
};
|
|
2655
2675
|
|
|
@@ -2659,7 +2679,7 @@ const PopoverTitle = ({ children, action, divider = false, className, dataTestId
|
|
|
2659
2679
|
* @param {PopoverTriggerProps} props - The props for the PopoverTrigger component
|
|
2660
2680
|
* @returns {ReactElement} PopoverTrigger component
|
|
2661
2681
|
*/
|
|
2662
|
-
const PopoverTrigger = function PopoverTrigger({ children, renderButton, ref: propRef, ...props }) {
|
|
2682
|
+
const PopoverTrigger = function PopoverTrigger({ children, renderButton = false, ref: propRef, ...props }) {
|
|
2663
2683
|
const context = usePopoverContext();
|
|
2664
2684
|
const ref = react$1.useMergeRefs([context.refs.setReference, propRef]);
|
|
2665
2685
|
if (!renderButton && react.isValidElement(children)) {
|
|
@@ -2667,10 +2687,10 @@ const PopoverTrigger = function PopoverTrigger({ children, renderButton, ref: pr
|
|
|
2667
2687
|
ref,
|
|
2668
2688
|
...props,
|
|
2669
2689
|
...children.props,
|
|
2670
|
-
"data-state": context.isOpen ? "open" : "closed",
|
|
2690
|
+
"data-state": context.isOpen === true ? "open" : "closed",
|
|
2671
2691
|
}));
|
|
2672
2692
|
}
|
|
2673
|
-
return (jsxRuntime.jsx(Button, { "data-state": context.isOpen ? "open" : "closed", ref: ref, type: "button", ...context.getReferenceProps(props), children: children }));
|
|
2693
|
+
return (jsxRuntime.jsx(Button, { "data-state": context.isOpen === true ? "open" : "closed", ref: ref, type: "button", ...context.getReferenceProps(props), children: children }));
|
|
2674
2694
|
};
|
|
2675
2695
|
|
|
2676
2696
|
const cvaTooltipContainer = cssClassVarianceUtilities.cvaMerge(["flex", "leading-5"]);
|
|
@@ -2746,7 +2766,7 @@ const FloatingArrowContainer = ({ arrowRef, mode = "dark", }) => {
|
|
|
2746
2766
|
* @param {TooltipProps} props - The props for the Tooltip component
|
|
2747
2767
|
* @returns {ReactElement} Tooltip component
|
|
2748
2768
|
*/
|
|
2749
|
-
const Tooltip = ({ children, dataTestId, disabled, className, label, placement = "auto", mode = "dark", iconProps, id, }) => {
|
|
2769
|
+
const Tooltip = ({ children, dataTestId, disabled = false, className, label, placement = "auto", mode = "dark", iconProps, id, }) => {
|
|
2750
2770
|
const [isOpen, setIsOpen] = react.useState(false);
|
|
2751
2771
|
const arrowRef = react.useRef(null);
|
|
2752
2772
|
const { refs, floatingStyles, context } = react$1.useFloating({
|
|
@@ -2766,7 +2786,7 @@ const Tooltip = ({ children, dataTestId, disabled, className, label, placement =
|
|
|
2766
2786
|
const { isMounted } = react$1.useTransitionStatus(context);
|
|
2767
2787
|
// Please don't try to move this into the component body directly
|
|
2768
2788
|
// I tried and it caused infinite re-renders some places (for whatever reason)
|
|
2769
|
-
const wrappedChildren = (jsxRuntime.jsx("div", { className: cvaTooltipContainer({ className }), "data-testid": dataTestId ? `${dataTestId}-parent` : undefined, children: children }));
|
|
2789
|
+
const wrappedChildren = react.useMemo(() => (jsxRuntime.jsx("div", { className: cvaTooltipContainer({ className }), "data-testid": dataTestId ? `${dataTestId}-parent` : undefined, children: children })), [children, className, dataTestId]);
|
|
2770
2790
|
const openTooltip = react.useCallback(() => {
|
|
2771
2791
|
if (disabled) {
|
|
2772
2792
|
return;
|
|
@@ -2912,8 +2932,8 @@ const cvaIndicatorIconBackground = cssClassVarianceUtilities.cvaMerge(["rounded-
|
|
|
2912
2932
|
* @param {IndicatorProps} props - The props for the Indicator component
|
|
2913
2933
|
* @returns {ReactElement} Indicator component
|
|
2914
2934
|
*/
|
|
2915
|
-
const Indicator = ({ dataTestId, icon, label, color = "unknown", withBackground = true, withLabel = true, ping = false, size, weight, className, ...rest }) => {
|
|
2916
|
-
return (jsxRuntime.jsx(Tooltip, { className: className, disabled: withLabel, label: label, placement: "bottom", children: jsxRuntime.jsxs("div", { "aria-label": label, className: cvaIndicator(), "data-testid": dataTestId, ...rest, children: [jsxRuntime.jsxs("div", { className: cvaIndicatorIconBackground({ color, background: withBackground ? "visible" : "hidden" }), "data-testid": dataTestId ? `${dataTestId}-background` : "indicator-background", children: [ping ? (jsxRuntime.jsx("div", { className: cvaIndicatorPing({ color }), "data-testid": dataTestId ? `${dataTestId}-ping` : "indicator-ping" })) : null, icon] }), label
|
|
2935
|
+
const Indicator = ({ dataTestId, icon, label, color = "unknown", withBackground = true, withLabel = true, ping = false, size = "medium", weight = "normal", className, ...rest }) => {
|
|
2936
|
+
return (jsxRuntime.jsx(Tooltip, { className: className, disabled: withLabel, label: label, placement: "bottom", children: jsxRuntime.jsxs("div", { "aria-label": label, className: cvaIndicator(), "data-testid": dataTestId, ...rest, children: [jsxRuntime.jsxs("div", { className: cvaIndicatorIconBackground({ color, background: withBackground ? "visible" : "hidden" }), "data-testid": dataTestId ? `${dataTestId}-background` : "indicator-background", children: [ping ? (jsxRuntime.jsx("div", { className: cvaIndicatorPing({ color }), "data-testid": dataTestId ? `${dataTestId}-ping` : "indicator-ping" })) : null, icon] }), label && withLabel ? (jsxRuntime.jsx("div", { className: cvaIndicatorLabel({ size, weight, background: withBackground ? "visible" : "hidden" }), "data-testid": dataTestId ? `${dataTestId}-label` : undefined, children: label })) : null] }) }));
|
|
2917
2937
|
};
|
|
2918
2938
|
|
|
2919
2939
|
const cvaKPI = cssClassVarianceUtilities.cvaMerge(["w-full", "px-4", "py-2", "flex", "flex-col"], {
|
|
@@ -2973,10 +2993,10 @@ const LoadingContent$1 = () => (jsxRuntime.jsx("div", { className: "flex h-11 fl
|
|
|
2973
2993
|
* @param {KPIProps} props - The props for the KPI component
|
|
2974
2994
|
* @returns {ReactElement} KPI component
|
|
2975
2995
|
*/
|
|
2976
|
-
const KPI = ({ title, value, loading, unit, className, dataTestId, tooltipLabel, variant = "default", trend, ...rest }) => {
|
|
2996
|
+
const KPI = ({ title, value, loading = false, unit, className, dataTestId, tooltipLabel, variant = "default", trend, ...rest }) => {
|
|
2977
2997
|
const isSmallVariant = variant === "small";
|
|
2978
|
-
return (jsxRuntime.jsx(Tooltip, { dataTestId: dataTestId ? `${dataTestId}-tooltip` : undefined, disabled:
|
|
2979
|
-
isDefaultAndHasTrendValue: Boolean(trend
|
|
2998
|
+
return (jsxRuntime.jsx(Tooltip, { dataTestId: dataTestId ? `${dataTestId}-tooltip` : undefined, disabled: tooltipLabel === undefined || tooltipLabel === "", label: tooltipLabel, placement: "bottom", children: jsxRuntime.jsx("div", { className: cvaKPI({ variant, className }), "data-testid": dataTestId ? `${dataTestId}` : undefined, ...rest, children: loading ? (jsxRuntime.jsx(LoadingContent$1, {})) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { className: cvaKPIHeader(), children: jsxRuntime.jsx(Text, { className: cvaKPITitleText(), dataTestId: dataTestId ? `${dataTestId}-title` : undefined, size: isSmallVariant ? "small" : "medium", subtle: true, weight: isSmallVariant ? "normal" : "bold", children: title }) }), jsxRuntime.jsx(Text, { className: cvaKPIvalueText({ variant }), dataTestId: dataTestId ? `${dataTestId}-value` : undefined, size: isSmallVariant ? "small" : "large", type: "div", weight: isSmallVariant ? "bold" : "thick", children: jsxRuntime.jsxs("div", { className: cvaKPIValueContainer({
|
|
2999
|
+
isDefaultAndHasTrendValue: Boolean(trend !== undefined && trend.value !== undefined && !isSmallVariant),
|
|
2980
3000
|
className,
|
|
2981
3001
|
}), children: [jsxRuntime.jsxs("span", { className: cvaKPIvalueText({ variant }), children: [value, " ", unit] }), jsxRuntime.jsx(TrendIndicator, { isSmallVariant: isSmallVariant, trend: trend, unit: unit })] }) })] })) }) }));
|
|
2982
3002
|
};
|
|
@@ -2984,7 +3004,7 @@ const TrendIndicator = ({ trend, unit, isSmallVariant }) => {
|
|
|
2984
3004
|
if (!trend) {
|
|
2985
3005
|
return null;
|
|
2986
3006
|
}
|
|
2987
|
-
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
|
|
3007
|
+
return (jsxRuntime.jsxs("div", { className: "flex flex-row items-center gap-1", "data-testid": "trend-indicator", children: [!isSmallVariant && trend.value !== undefined ? (jsxRuntime.jsxs(Text, { dataTestId: "trend-value", size: "small", weight: "normal", children: [trend.value, " ", unit] })) : null, trend.variant !== undefined && trend.variant.icon !== undefined ? (jsxRuntime.jsx(Icon, { color: trend.variant.color, name: trend.variant.icon, size: "small" })) : null, trend.percentage !== undefined ? (jsxRuntime.jsxs(Text, { className: cvaKPITrendPercentage({ color: trend.variant?.color }), size: "small", weight: "bold", children: [trend.percentage, "%"] })) : null] }));
|
|
2988
3008
|
};
|
|
2989
3009
|
|
|
2990
3010
|
const cvaKPICard = cssClassVarianceUtilities.cvaMerge([
|
|
@@ -3029,14 +3049,14 @@ const cvaKPIIconContainer = cssClassVarianceUtilities.cvaMerge(["flex", "items-c
|
|
|
3029
3049
|
* @param {KPICardProps} props - The props for the KPICard component
|
|
3030
3050
|
* @returns {ReactElement} KPICard component
|
|
3031
3051
|
*/
|
|
3032
|
-
const KPICard = ({ isActive, onClick, className, dataTestId, children, iconName, iconColor, ...rest }) => {
|
|
3033
|
-
const isClickable = Boolean(onClick &&
|
|
3052
|
+
const KPICard = ({ isActive = false, onClick, className, dataTestId, children, iconName = undefined, iconColor = "info", loading = false, ...rest }) => {
|
|
3053
|
+
const isClickable = Boolean(onClick !== undefined && loading !== true);
|
|
3034
3054
|
return (jsxRuntime.jsx(Card, { className: cvaKPICard({
|
|
3035
3055
|
isClickable,
|
|
3036
3056
|
isActive,
|
|
3037
3057
|
minHeight: rest.trend ? "withTrends" : "default",
|
|
3038
3058
|
className,
|
|
3039
|
-
}), "data-testid": dataTestId ? dataTestId : undefined, onClick: onClick, children: jsxRuntime.jsxs(CardBody, { className: cvaCardBodyDensityContainer({ iconName: Boolean(iconName) }), density: "none", children: [jsxRuntime.jsx(KPI, { ...rest, className: tailwindMerge.twMerge(iconName ? "gap-2" : "", "p-0"), dataTestId: dataTestId ? `${dataTestId}-kpi` : undefined }), iconName ? (jsxRuntime.jsx("div", { className: cvaKPIIconContainer({ iconColor
|
|
3059
|
+
}), "data-testid": dataTestId ? dataTestId : undefined, onClick: onClick, children: jsxRuntime.jsxs(CardBody, { className: cvaCardBodyDensityContainer({ iconName: Boolean(iconName) }), density: "none", children: [jsxRuntime.jsx(KPI, { ...rest, className: tailwindMerge.twMerge(iconName ? "gap-2" : "", "p-0"), dataTestId: dataTestId ? `${dataTestId}-kpi` : undefined, loading: loading }), iconName ? (jsxRuntime.jsx("div", { className: cvaKPIIconContainer({ iconColor }), children: jsxRuntime.jsx(Icon, { name: iconName, size: "small", type: "solid" }) })) : null, children] }) }));
|
|
3040
3060
|
};
|
|
3041
3061
|
const cvaCardBodyDensityContainer = cssClassVarianceUtilities.cvaMerge(["grid", "grid-cols-[1fr_auto]"], {
|
|
3042
3062
|
variants: {
|
|
@@ -3072,9 +3092,9 @@ const cvaInteractableItem = cssClassVarianceUtilities.cvaMerge("", {
|
|
|
3072
3092
|
default: "cursor-default",
|
|
3073
3093
|
"not-allowed": "cursor-not-allowed",
|
|
3074
3094
|
},
|
|
3075
|
-
|
|
3076
|
-
|
|
3077
|
-
|
|
3095
|
+
selection: {
|
|
3096
|
+
selected: ["bg-primary-50", "hover:bg-primary-50", "focus-within:bg-primary-50"],
|
|
3097
|
+
unselected: "",
|
|
3078
3098
|
auto: [
|
|
3079
3099
|
"hover:bg-neutral-100",
|
|
3080
3100
|
"has-[:checked]:bg-primary-50",
|
|
@@ -3087,24 +3107,24 @@ const cvaInteractableItem = cssClassVarianceUtilities.cvaMerge("", {
|
|
|
3087
3107
|
true: ["pointer-events-none", "!bg-neutral-100", "!cursor-not-allowed"],
|
|
3088
3108
|
false: "", // use compoundVariants instead
|
|
3089
3109
|
},
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
|
|
3110
|
+
focus: {
|
|
3111
|
+
focused: ["bg-neutral-600/5"],
|
|
3112
|
+
unfocused: "",
|
|
3093
3113
|
auto: "[&:has(:focus-visible)]:outline-native",
|
|
3094
3114
|
},
|
|
3095
3115
|
},
|
|
3096
3116
|
compoundVariants: [
|
|
3097
3117
|
{
|
|
3098
3118
|
disabled: false,
|
|
3099
|
-
|
|
3119
|
+
selection: "unselected",
|
|
3100
3120
|
className: ["hover:bg-neutral-600/5", "focus-within:bg-neutral-600/5"],
|
|
3101
3121
|
},
|
|
3102
3122
|
],
|
|
3103
3123
|
defaultVariants: {
|
|
3104
3124
|
cursor: "auto",
|
|
3105
|
-
|
|
3125
|
+
selection: "auto",
|
|
3106
3126
|
disabled: false,
|
|
3107
|
-
|
|
3127
|
+
focus: "auto",
|
|
3108
3128
|
},
|
|
3109
3129
|
});
|
|
3110
3130
|
|
|
@@ -3141,7 +3161,7 @@ const ListItem = ({ className, dataTestId, onClick, details, title, description,
|
|
|
3141
3161
|
}), children: thumbnail })) : null, jsxRuntime.jsxs("div", { className: "grid-rows-min-fr grid items-center text-sm", children: [jsxRuntime.jsx("div", { className: "gap-responsive-space-sm flex w-full min-w-0 items-center text-sm", children: typeof title === "string" ? (jsxRuntime.jsx(Text, { className: "truncate", dataTestId: dataTestId ? `${dataTestId}-title` : undefined, weight: "bold", children: title })) : (react.cloneElement(title, {
|
|
3142
3162
|
className: tailwindMerge.twMerge(title.props.className, "neutral-900 text-sm font-medium truncate"),
|
|
3143
3163
|
dataTestId: !title.props.dataTestId && dataTestId ? `${dataTestId}-title` : undefined,
|
|
3144
|
-
})) }), description ? (jsxRuntime.jsx("div", { className: "gap-responsive-space-sm flex w-full min-w-0 items-center", children: typeof description === "string" ? (jsxRuntime.jsx(Text, { className: "truncate text-xs text-neutral-500", dataTestId: dataTestId ? `${dataTestId}-description` : undefined, weight: "bold", children: description })) : (react.cloneElement(description, {
|
|
3164
|
+
})) }), description !== undefined && description !== "" ? (jsxRuntime.jsx("div", { className: "gap-responsive-space-sm flex w-full min-w-0 items-center", children: typeof description === "string" ? (jsxRuntime.jsx(Text, { className: "truncate text-xs text-neutral-500", dataTestId: dataTestId ? `${dataTestId}-description` : undefined, weight: "bold", children: description })) : (react.cloneElement(description, {
|
|
3145
3165
|
className: tailwindMerge.twMerge(description.props.className, "text-neutral-500 text-xs font-medium truncate"),
|
|
3146
3166
|
dataTestId: !description.props.dataTestId && dataTestId ? `${dataTestId}-description` : undefined,
|
|
3147
3167
|
})) })) : null, meta ? (jsxRuntime.jsx("div", { className: "gap-responsive-space-sm flex w-full min-w-0 items-center pt-0.5", children: jsxRuntime.jsx(Text, { className: "truncate text-xs text-neutral-400", dataTestId: dataTestId ? `${dataTestId}-meta` : undefined, weight: "bold", children: meta }) })) : null] })] }), jsxRuntime.jsxs("div", { className: "flex items-center gap-0.5 pl-2", children: [details, onClick ? jsxRuntime.jsx(Icon, { color: "neutral", name: "ChevronRight", size: "medium" }) : null] })] }));
|
|
@@ -3183,7 +3203,12 @@ const MenuDivider = () => {
|
|
|
3183
3203
|
*/
|
|
3184
3204
|
const cvaMenuItem = (props) => {
|
|
3185
3205
|
const { selected, disabled, focused, className, variant, fieldSize } = props ?? {};
|
|
3186
|
-
return tailwindMerge.twMerge(cvaMenuItemStyle({ variant, selected, disabled, fieldSize }), cvaInteractableItem({
|
|
3206
|
+
return tailwindMerge.twMerge(cvaMenuItemStyle({ variant, selected, disabled, fieldSize }), cvaInteractableItem({
|
|
3207
|
+
selection: selected === true ? "selected" : "unselected",
|
|
3208
|
+
disabled,
|
|
3209
|
+
cursor: "pointer",
|
|
3210
|
+
focus: focused === true ? "focused" : "unfocused",
|
|
3211
|
+
}), className);
|
|
3187
3212
|
};
|
|
3188
3213
|
const cvaMenuItemStyle = cssClassVarianceUtilities.cvaMerge(["py-2", "px-2", "h-auto", "flex", "flex-row", "items-center", "gap-x-2", "select-none", "rounded", "text-sm"], {
|
|
3189
3214
|
variants: {
|
|
@@ -3296,10 +3321,10 @@ const cvaMenuItemSuffix = cssClassVarianceUtilities.cvaMerge(["text-secondary-40
|
|
|
3296
3321
|
* @param {MenuItemProps} props - The props for the MenuItem component
|
|
3297
3322
|
* @returns {ReactElement} MenuItem component
|
|
3298
3323
|
*/
|
|
3299
|
-
const MenuItem = ({ className, dataTestId, label, children, selected, focused, prefix, suffix, disabled, onClick, stopPropagation = true, id, tabIndex, optionLabelDescription, optionPrefix, fieldSize = "medium", variant = "primary", }) => {
|
|
3324
|
+
const MenuItem = ({ className, dataTestId, label, children, selected = false, focused = false, prefix, suffix, disabled = false, onClick, stopPropagation = true, id, tabIndex, optionLabelDescription, optionPrefix, fieldSize = "medium", variant = "primary", }) => {
|
|
3300
3325
|
/* Handle tab navigation */
|
|
3301
3326
|
const handleKeyDown = (e) => {
|
|
3302
|
-
if (e.key === "Enter" && onClick &&
|
|
3327
|
+
if (e.key === "Enter" && onClick !== undefined && disabled !== true) {
|
|
3303
3328
|
if (stopPropagation) {
|
|
3304
3329
|
e.stopPropagation();
|
|
3305
3330
|
}
|
|
@@ -3319,7 +3344,7 @@ const MenuItem = ({ className, dataTestId, label, children, selected, focused, p
|
|
|
3319
3344
|
e.stopPropagation();
|
|
3320
3345
|
}
|
|
3321
3346
|
onClick?.(e);
|
|
3322
|
-
}, 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: [optionPrefix ? optionPrefix : null, 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] }));
|
|
3347
|
+
}, onKeyDown: handleKeyDown, role: "menuitem", tabIndex: disabled ? -1 : (tabIndex ?? 0), children: [prefix !== null && prefix !== undefined ? (jsxRuntime.jsx("div", { className: cvaMenuItemPrefix({ selected, variant, disabled }), "data-testid": dataTestId ? `${dataTestId}-prefix` : "menu-item-prefix", children: prefix })) : null, children !== null && children !== undefined && typeof children !== "string" ? (children) : (jsxRuntime.jsxs("div", { className: cvaMenuItemLabel({ variant, disabled }), "data-testid": dataTestId ? `${dataTestId}-label` : "menu-item-label", children: [optionPrefix !== null && optionPrefix !== undefined ? optionPrefix : null, children ?? label, optionLabelDescription !== undefined && optionLabelDescription !== "" ? (jsxRuntime.jsxs("span", { className: "text-secondary-400 ml-1", children: ["(", optionLabelDescription, ")"] })) : null] })), suffix !== null && suffix !== undefined ? (jsxRuntime.jsx("div", { className: cvaMenuItemSuffix({ selected, variant, disabled }), "data-testid": dataTestId ? `${dataTestId}-suffix` : "menu-item-suffix", children: suffix })) : null] }));
|
|
3323
3348
|
};
|
|
3324
3349
|
|
|
3325
3350
|
/**
|
|
@@ -3337,16 +3362,13 @@ const MenuList = ({ dataTestId, className, children, withStickyHeader = false, i
|
|
|
3337
3362
|
const childrenArr = react.Children.toArray(children);
|
|
3338
3363
|
const [internalSelectedItems, setInternalSelectedItems] = react.useState(controlledSelectedItems ?? []);
|
|
3339
3364
|
const selectedItems = controlledSelectedItems ?? internalSelectedItems;
|
|
3340
|
-
const handleItemClick = react.useCallback((id
|
|
3341
|
-
if (disabled) {
|
|
3342
|
-
return;
|
|
3343
|
-
}
|
|
3365
|
+
const handleItemClick = react.useCallback((id) => {
|
|
3344
3366
|
const newSelectedItems = isMulti
|
|
3345
3367
|
? selectedItems.includes(id)
|
|
3346
3368
|
? selectedItems.filter(item => item !== id)
|
|
3347
3369
|
: [...selectedItems, id]
|
|
3348
3370
|
: [id];
|
|
3349
|
-
if (onSelectionChange) {
|
|
3371
|
+
if (onSelectionChange !== undefined) {
|
|
3350
3372
|
onSelectionChange(newSelectedItems);
|
|
3351
3373
|
}
|
|
3352
3374
|
else {
|
|
@@ -3355,13 +3377,15 @@ const MenuList = ({ dataTestId, className, children, withStickyHeader = false, i
|
|
|
3355
3377
|
}, [isMulti, selectedItems, onSelectionChange]);
|
|
3356
3378
|
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) => {
|
|
3357
3379
|
if (react.isValidElement(menuItem)) {
|
|
3358
|
-
const isSelected = selectedItems.includes(menuItem.props.id ?? `${index}`) || menuItem.props.selected;
|
|
3380
|
+
const isSelected = (selectedItems.includes(menuItem.props.id ?? `${index}`) || menuItem.props.selected) ?? false;
|
|
3359
3381
|
return react.cloneElement(menuItem, {
|
|
3360
3382
|
...menuItem.props,
|
|
3361
3383
|
key: index,
|
|
3362
3384
|
onClick: (event) => {
|
|
3363
3385
|
menuItem.props.onClick?.(event);
|
|
3364
|
-
|
|
3386
|
+
if (menuItem.props.disabled !== true) {
|
|
3387
|
+
handleItemClick(menuItem.props.id ?? `${index}`);
|
|
3388
|
+
}
|
|
3365
3389
|
},
|
|
3366
3390
|
className: isMulti && isSelected
|
|
3367
3391
|
? cvaMenuListMultiSelect({ className: menuItem.props.className })
|
|
@@ -3443,7 +3467,7 @@ const cvaNoticeIcon = cssClassVarianceUtilities.cvaMerge(["rounded-full", "items
|
|
|
3443
3467
|
* @returns {ReactElement} Notice component
|
|
3444
3468
|
*/
|
|
3445
3469
|
const Notice = ({ dataTestId, icon, label, color = "neutral", withLabel = true, className, tooltipLabel = label, withTooltip = false, size = "medium", ...rest }) => {
|
|
3446
|
-
return (jsxRuntime.jsx(Tooltip, { className: className, disabled:
|
|
3470
|
+
return (jsxRuntime.jsx(Tooltip, { className: className, disabled: withTooltip === false, label: tooltipLabel, placement: "bottom", children: jsxRuntime.jsxs("div", { "aria-label": label, className: cvaNotice(), "data-testid": dataTestId, ...rest, children: [jsxRuntime.jsx("div", { className: cvaNoticeIcon({ color }), "data-testid": dataTestId ? `${dataTestId}-icon` : "notice-icon", children: icon }), label && withLabel ? (jsxRuntime.jsx("div", { className: cvaNoticeLabel({ color, size }), "data-testid": dataTestId ? `${dataTestId}-label` : "notice-label", children: label })) : null] }) }));
|
|
3447
3471
|
};
|
|
3448
3472
|
|
|
3449
3473
|
const cvaPage = cssClassVarianceUtilities.cvaMerge(["grid", "h-full"], {
|
|
@@ -3476,7 +3500,7 @@ const cvaPageContent = cssClassVarianceUtilities.cvaMerge(["overflow-auto", "pag
|
|
|
3476
3500
|
* Renders the page component. Adds padding and layout to the page.
|
|
3477
3501
|
*/
|
|
3478
3502
|
const Page = ({ layout, className, children, dataTestId }) => {
|
|
3479
|
-
return (jsxRuntime.jsx("div", { className: cvaPage({ className, layout }), "data-testid": dataTestId
|
|
3503
|
+
return (jsxRuntime.jsx("div", { className: cvaPage({ className, layout }), "data-testid": dataTestId ? dataTestId : "page", children: children }));
|
|
3480
3504
|
};
|
|
3481
3505
|
|
|
3482
3506
|
/**
|
|
@@ -3491,17 +3515,30 @@ const PageContent = ({ className, children, dataTestId, layout }) => {
|
|
|
3491
3515
|
};
|
|
3492
3516
|
|
|
3493
3517
|
const LoadingContent = () => (jsxRuntime.jsx("div", { className: "flex flex-row items-center gap-3", "data-testid": "kpi-card-loading-content", children: jsxRuntime.jsx("div", { className: "w-full", children: jsxRuntime.jsx(SkeletonLines, { height: [16, 25], lines: 2, margin: "3px 0 0 0", width: [75, 50] }) }) }));
|
|
3518
|
+
/**
|
|
3519
|
+
* The PageHeaderKpiMetrics component is used to render the KPI metrics in the PageHeader component.
|
|
3520
|
+
*
|
|
3521
|
+
* @param {object} props - The props for the PageHeaderKpiMetrics component
|
|
3522
|
+
* @param {Array<PageHeaderKpiMetricsType>} props.kpiMetrics - The KPI metrics to render
|
|
3523
|
+
* @returns {ReactElement} PageHeaderKpiMetrics component
|
|
3524
|
+
*/
|
|
3494
3525
|
const PageHeaderKpiMetrics = ({ kpiMetrics }) => {
|
|
3495
3526
|
return (jsxRuntime.jsx("div", { className: "hidden items-center gap-4 md:flex", children: kpiMetrics
|
|
3496
|
-
.filter(kpi =>
|
|
3527
|
+
.filter(kpi => kpi.hidden === false || kpi.hidden === undefined)
|
|
3497
3528
|
.map((kpi, index) => {
|
|
3498
|
-
if (kpi.loading) {
|
|
3529
|
+
if (kpi.loading === true) {
|
|
3499
3530
|
return jsxRuntime.jsx(LoadingContent, {}, `${kpi}-${index}`);
|
|
3500
3531
|
}
|
|
3501
3532
|
return (jsxRuntime.jsxs("div", { className: "flex flex-col text-nowrap text-left", children: [jsxRuntime.jsx("span", { className: "text-xs text-slate-500", children: kpi.header }), jsxRuntime.jsxs("div", { className: "flex flex-row items-center gap-1", children: [jsxRuntime.jsx("span", { className: "text-lg font-medium text-slate-900", children: kpi.value }), kpi.unit ? jsxRuntime.jsx("span", { className: "text-xs text-slate-900", children: kpi.unit }) : null] })] }, `${kpi}-${index}`));
|
|
3502
3533
|
}) }));
|
|
3503
3534
|
};
|
|
3504
3535
|
|
|
3536
|
+
/**
|
|
3537
|
+
* The ActionRenderer component is used to render the action in the PageHeaderSecondaryActions component.
|
|
3538
|
+
*
|
|
3539
|
+
* @param {ActionRendererProps} props - The props for the ActionRenderer component
|
|
3540
|
+
* @returns {ReactElement} ActionRenderer component
|
|
3541
|
+
*/
|
|
3505
3542
|
function ActionRenderer({ action, isMenuItem = false, externalOnClick }) {
|
|
3506
3543
|
const { to, tooltipLabel, prefixIconName, disabled, actionText, actionCallback, dataTestId, target, variant } = action;
|
|
3507
3544
|
// This component handles all the "wrapping" logic for Link/Tooltip
|
|
@@ -3516,10 +3553,18 @@ function ActionRenderer({ action, isMenuItem = false, externalOnClick }) {
|
|
|
3516
3553
|
// Wrap `content` with Tooltip
|
|
3517
3554
|
const wrappedWithTooltip = tooltipLabel ? (jsxRuntime.jsx(Tooltip, { className: "block", label: tooltipLabel, children: content })) : (content);
|
|
3518
3555
|
// Finally, wrap with Link if `to` is provided
|
|
3519
|
-
return to ? (jsxRuntime.jsx(reactRouter.Link, { target: target, to: to, children: wrappedWithTooltip })) : (wrappedWithTooltip);
|
|
3556
|
+
return to !== undefined && to !== "" ? (jsxRuntime.jsx(reactRouter.Link, { target: target, to: to, children: wrappedWithTooltip })) : (wrappedWithTooltip);
|
|
3520
3557
|
}
|
|
3521
|
-
|
|
3522
|
-
|
|
3558
|
+
/**
|
|
3559
|
+
* The PageHeaderSecondaryActions component is used to render the secondary actions in the PageHeader component.
|
|
3560
|
+
*
|
|
3561
|
+
* @param {object} props - The props for the PageHeaderSecondaryActions component
|
|
3562
|
+
* @param {Array<PageHeaderSecondaryActionType>} props.actions - The secondary actions to render
|
|
3563
|
+
* @param {boolean} [props.hasPrimaryAction] - Whether there is a primary action present
|
|
3564
|
+
* @returns {ReactElement} PageHeaderSecondaryActions component
|
|
3565
|
+
*/
|
|
3566
|
+
const PageHeaderSecondaryActions = ({ actions, hasPrimaryAction = false, }) => {
|
|
3567
|
+
const enabledActions = react.useMemo(() => actions.filter(action => action.hidden === false || action.hidden === undefined), [actions]);
|
|
3523
3568
|
// If we need to render a "More Menu" because we have too many actions:
|
|
3524
3569
|
if (enabledActions.length > 2 || (hasPrimaryAction && enabledActions.length > 1)) {
|
|
3525
3570
|
// Separate them into danger vs. other
|
|
@@ -3531,7 +3576,7 @@ const PageHeaderSecondaryActions = ({ actions, hasPrimaryAction, }) => {
|
|
|
3531
3576
|
return [danger, [...others, action]];
|
|
3532
3577
|
}
|
|
3533
3578
|
}, [[], []]);
|
|
3534
|
-
return (jsxRuntime.jsx(MoreMenu, { dataTestId: "secondary-actions-more-menu", iconButtonProps: { size: "small", variant: "secondary" }, children: close => (jsxRuntime.jsxs(MenuList, { className: "min-w-[160px]", children: [otherActions.map((action, index) => (jsxRuntime.jsx(ActionRenderer, { action: action, externalOnClick: close, isMenuItem: true }, `${action.actionText}-${index}`))), dangerActions.length ? jsxRuntime.jsx(MenuDivider, {}) : null, dangerActions.map((action, index) => (jsxRuntime.jsx(ActionRenderer, { action: action, externalOnClick: close, isMenuItem: true }, `${action.actionText}-${index}`)))] })) }));
|
|
3579
|
+
return (jsxRuntime.jsx(MoreMenu, { dataTestId: "secondary-actions-more-menu", iconButtonProps: { size: "small", variant: "secondary" }, children: close => (jsxRuntime.jsxs(MenuList, { className: "min-w-[160px]", children: [otherActions.map((action, index) => (jsxRuntime.jsx(ActionRenderer, { action: action, externalOnClick: close, isMenuItem: true }, `${action.actionText}-${index}`))), dangerActions.length > 0 ? jsxRuntime.jsx(MenuDivider, {}) : null, dangerActions.map((action, index) => (jsxRuntime.jsx(ActionRenderer, { action: action, externalOnClick: close, isMenuItem: true }, `${action.actionText}-${index}`)))] })) }));
|
|
3535
3580
|
}
|
|
3536
3581
|
// Otherwise, render them inline as buttons
|
|
3537
3582
|
return (jsxRuntime.jsx("div", { className: "flex flex-row items-center gap-2", children: enabledActions
|
|
@@ -3558,6 +3603,14 @@ const cvaPageHeaderContainer = cssClassVarianceUtilities.cvaMerge(["bg-white", "
|
|
|
3558
3603
|
const cvaPageHeader = cssClassVarianceUtilities.cvaMerge(["box-border", "py-4", "px-6", "flex", "items-center", "gap-y-1"]);
|
|
3559
3604
|
const cvaPageHeaderHeading = cssClassVarianceUtilities.cvaMerge(["text-slate-900", "text-xl", "font-semibold", "truncate"]);
|
|
3560
3605
|
|
|
3606
|
+
/**
|
|
3607
|
+
* The PageHeaderTitle component is used to display the title of the page header.
|
|
3608
|
+
*
|
|
3609
|
+
* @param {object} props - The props for the PageHeaderTitle component
|
|
3610
|
+
* @param {string} props.title - The title of the page header
|
|
3611
|
+
* @param {string} [props.dataTestId] - The data test id of the page header title
|
|
3612
|
+
* @returns {ReactElement} PageHeaderTitle component
|
|
3613
|
+
*/
|
|
3561
3614
|
const PageHeaderTitle = ({ title, dataTestId }) => {
|
|
3562
3615
|
const { ref, isTextTruncated } = useIsTextTruncated();
|
|
3563
3616
|
return (jsxRuntime.jsx("div", { className: "flex flex-row items-center", children: jsxRuntime.jsx(Tooltip, { className: "grid min-w-16", disabled: !isTextTruncated, label: title, placement: "top", children: jsxRuntime.jsx("h1", { className: cvaPageHeaderHeading(), "data-testid": dataTestId ? `${dataTestId}-heading` : undefined, ref: ref, children: title }) }) }));
|
|
@@ -3573,21 +3626,21 @@ const PageHeaderTitle = ({ title, dataTestId }) => {
|
|
|
3573
3626
|
* @param {PageHeaderProps} props - The props for the PageHeader component
|
|
3574
3627
|
* @returns {ReactElement} PageHeader component
|
|
3575
3628
|
*/
|
|
3576
|
-
const PageHeader = ({ className, dataTestId, secondaryActions, showLoading, description, title, tagLabel, backTo, tagColor, tabsList, descriptionIcon, kpiMetrics, tagTooltipLabel, primaryAction, }) => {
|
|
3629
|
+
const PageHeader = ({ className, dataTestId, secondaryActions, showLoading = false, description, title, tagLabel, backTo, tagColor, tabsList, descriptionIcon = "QuestionMarkCircle", kpiMetrics, tagTooltipLabel, primaryAction, }) => {
|
|
3577
3630
|
const tagRenderer = react.useMemo(() => {
|
|
3578
|
-
if (
|
|
3631
|
+
if (tagLabel === undefined || tagLabel === "" || showLoading) {
|
|
3579
3632
|
return null;
|
|
3580
3633
|
}
|
|
3581
3634
|
// If the user passes a string, we render the string as a tag with props provided.
|
|
3582
|
-
return (jsxRuntime.jsx("div", { className: "ml-auto flex flex-row gap-2", children: jsxRuntime.jsx(Tooltip, { dataTestId: "page-header-tag-tooltip", disabled:
|
|
3635
|
+
return (jsxRuntime.jsx("div", { className: "ml-auto flex flex-row gap-2", children: jsxRuntime.jsx(Tooltip, { dataTestId: "page-header-tag-tooltip", disabled: tagTooltipLabel === undefined || tagTooltipLabel === "", label: tagTooltipLabel, placement: "top", children: jsxRuntime.jsx(Tag, { color: tagColor, dataTestId: "page-header-tag", children: tagLabel }) }) }));
|
|
3583
3636
|
}, [showLoading, tagColor, tagLabel, tagTooltipLabel]);
|
|
3584
3637
|
return (jsxRuntime.jsxs("div", { className: cvaPageHeaderContainer({
|
|
3585
3638
|
className,
|
|
3586
|
-
withBorder:
|
|
3587
|
-
}), "data-testid": dataTestId, children: [jsxRuntime.jsxs("div", { className: cvaPageHeader(), children: [backTo ? (jsxRuntime.jsx(reactRouter.Link, { to: backTo, children: jsxRuntime.jsx(Button, { className: "mr-4 bg-black/5 hover:bg-black/10", prefix: jsxRuntime.jsx(Icon, { name: "ArrowLeft", size: "small" }), size: "medium", square: true, variant: "ghost-neutral" }) })) : undefined, typeof title === "string" ? jsxRuntime.jsx(PageHeaderTitle, { dataTestId: dataTestId, title: title }) : title, tagRenderer || description ? (jsxRuntime.jsxs("div", { className: "mx-2 flex items-center gap-2", children: [description && !showLoading ? (jsxRuntime.jsx(Tooltip, { dataTestId: dataTestId ? `${dataTestId}-description-tooltip` : undefined, iconProps: {
|
|
3588
|
-
name: descriptionIcon
|
|
3639
|
+
withBorder: tabsList === undefined,
|
|
3640
|
+
}), "data-testid": dataTestId, children: [jsxRuntime.jsxs("div", { className: cvaPageHeader(), children: [backTo ? (jsxRuntime.jsx(reactRouter.Link, { to: backTo, children: jsxRuntime.jsx(Button, { className: "mr-4 bg-black/5 hover:bg-black/10", prefix: jsxRuntime.jsx(Icon, { name: "ArrowLeft", size: "small" }), size: "medium", square: true, variant: "ghost-neutral" }) })) : undefined, typeof title === "string" ? jsxRuntime.jsx(PageHeaderTitle, { dataTestId: dataTestId, title: title }) : title, tagRenderer || (description !== null && description !== undefined) ? (jsxRuntime.jsxs("div", { className: "mx-2 flex items-center gap-2", children: [description !== null && description !== undefined && !showLoading ? (jsxRuntime.jsx(Tooltip, { dataTestId: dataTestId ? `${dataTestId}-description-tooltip` : undefined, iconProps: {
|
|
3641
|
+
name: descriptionIcon,
|
|
3589
3642
|
dataTestId: "page-header-description-icon",
|
|
3590
|
-
}, label: description, placement: "bottom" })) : undefined, tagRenderer] })) : null, jsxRuntime.jsxs("div", { className: "ml-auto flex gap-2", children: [kpiMetrics ? jsxRuntime.jsx(PageHeaderKpiMetrics, { kpiMetrics: kpiMetrics }) : null, Array.isArray(secondaryActions) ? (jsxRuntime.jsx(PageHeaderSecondaryActions, { actions: secondaryActions, hasPrimaryAction: !!primaryAction })) : secondaryActions ? (secondaryActions) : null, primaryAction &&
|
|
3643
|
+
}, label: description, placement: "bottom" })) : undefined, tagRenderer] })) : null, jsxRuntime.jsxs("div", { className: "ml-auto flex gap-2", children: [kpiMetrics ? jsxRuntime.jsx(PageHeaderKpiMetrics, { kpiMetrics: kpiMetrics }) : null, Array.isArray(secondaryActions) ? (jsxRuntime.jsx(PageHeaderSecondaryActions, { actions: secondaryActions, hasPrimaryAction: !!primaryAction })) : secondaryActions !== null && secondaryActions !== undefined ? (secondaryActions) : null, primaryAction !== undefined && (primaryAction.hidden === false || primaryAction.hidden === undefined) ? (jsxRuntime.jsx(Tooltip, { disabled: primaryAction.tooltipLabel === undefined || primaryAction.tooltipLabel === "", label: primaryAction.tooltipLabel, children: jsxRuntime.jsx(Button, { dataTestId: primaryAction.dataTestId, disabled: primaryAction.disabled, loading: primaryAction.loading, onClick: () => primaryAction.actionCallback?.(), prefix: primaryAction.prefixIconName !== undefined ? (jsxRuntime.jsx(Icon, { name: primaryAction.prefixIconName, size: "small" })) : undefined, size: "medium", variant: primaryAction.variant, children: primaryAction.actionText }) })) : null] })] }), tabsList] }));
|
|
3591
3644
|
};
|
|
3592
3645
|
|
|
3593
3646
|
const cvaPagination = cssClassVarianceUtilities.cvaMerge(["flex", "items-center", "gap-1"]);
|
|
@@ -3599,7 +3652,7 @@ const cvaPaginationText = cssClassVarianceUtilities.cvaMerge("whitespace-nowrap"
|
|
|
3599
3652
|
* @param {PaginationProps} props - The props for the Pagination component
|
|
3600
3653
|
* @returns {ReactElement} Pagination component
|
|
3601
3654
|
*/
|
|
3602
|
-
const Pagination = ({ previousPage, nextPage, canPreviousPage, canNextPage, pageCount, pageIndex, loading, className, dataTestId, getTranslatedCount, onPageChange, cursorBase, }) => {
|
|
3655
|
+
const Pagination = ({ previousPage, nextPage, canPreviousPage = false, canNextPage = false, pageCount, pageIndex, loading = false, className, dataTestId, getTranslatedCount, onPageChange, cursorBase = false, }) => {
|
|
3603
3656
|
const [page, setPage] = react.useState(pageIndex);
|
|
3604
3657
|
const [currentPage, setCurrentPage] = react.useState(String(pageIndex !== undefined ? pageIndex + 1 : 1));
|
|
3605
3658
|
if (!loading && pageCount === undefined) {
|
|
@@ -3648,7 +3701,7 @@ const STROKE_WIDTH_THRESHOLD = 32;
|
|
|
3648
3701
|
* @param { PolygonProps} props - The props for the Polygon component
|
|
3649
3702
|
* @returns {ReactElement} Polygon component
|
|
3650
3703
|
*/
|
|
3651
|
-
const Polygon = ({ points, size, color = "black", opaque = true, className, dataTestId }) => {
|
|
3704
|
+
const Polygon = ({ points, size, color = "black", opaque = true, className, dataTestId, }) => {
|
|
3652
3705
|
// Calculate the bounds of the points
|
|
3653
3706
|
const minX = Math.min(...points.map(coord => coord[0]));
|
|
3654
3707
|
const maxX = Math.max(...points.map(coord => coord[0]));
|
|
@@ -3751,7 +3804,7 @@ const Spacer = ({ size = "medium", border = false, dataTestId, className }) => {
|
|
|
3751
3804
|
* @returns {ReactElement} SectionHeader component
|
|
3752
3805
|
*/
|
|
3753
3806
|
const SectionHeader = ({ title, subtitle, dataTestId, addons }) => {
|
|
3754
|
-
return (jsxRuntime.jsxs("div", { className: "flex flex-col", children: [jsxRuntime.jsx(reactHelmetAsync.HelmetProvider, { children: jsxRuntime.jsx(reactHelmetAsync.Helmet, { title: title }) }), jsxRuntime.jsxs("div", { className: "mb-2 flex flex-row gap-2", children: [jsxRuntime.jsxs("div", { className: "flex grow flex-col gap-2", children: [jsxRuntime.jsx(Heading, { dataTestId: dataTestId, variant: "secondary", children: title }), subtitle ? (jsxRuntime.jsx(Heading, { subtle: true, variant: "subtitle", children: subtitle })) : null] }), addons ? jsxRuntime.jsx("div", { className: "flex gap-2", children: addons }) : null] }), jsxRuntime.jsx(Spacer, { size: "small" })] }));
|
|
3807
|
+
return (jsxRuntime.jsxs("div", { className: "flex flex-col", children: [jsxRuntime.jsx(reactHelmetAsync.HelmetProvider, { children: jsxRuntime.jsx(reactHelmetAsync.Helmet, { title: title }) }), jsxRuntime.jsxs("div", { className: "mb-2 flex flex-row gap-2", children: [jsxRuntime.jsxs("div", { className: "flex grow flex-col gap-2", children: [jsxRuntime.jsx(Heading, { dataTestId: dataTestId, variant: "secondary", children: title }), subtitle ? (jsxRuntime.jsx(Heading, { subtle: true, variant: "subtitle", children: subtitle })) : null] }), addons !== null && addons !== undefined ? jsxRuntime.jsx("div", { className: "flex gap-2", children: addons }) : null] }), jsxRuntime.jsx(Spacer, { size: "small" })] }));
|
|
3755
3808
|
};
|
|
3756
3809
|
|
|
3757
3810
|
const cvaSidebar = cssClassVarianceUtilities.cvaMerge(["apply", "grid", "grid-cols-fr-min", "items-center"]);
|
|
@@ -3785,7 +3838,7 @@ const useOverflowItems = ({ threshold = 1, childUniqueIdentifierAttribute = "id"
|
|
|
3785
3838
|
entries.forEach(entry => {
|
|
3786
3839
|
// @ts-expect-error - suppressImplicitAnyIndexErrors
|
|
3787
3840
|
const targetElementId = entry.target[childUniqueIdentifierAttribute];
|
|
3788
|
-
if (targetElementId) {
|
|
3841
|
+
if (targetElementId !== null && targetElementId !== undefined) {
|
|
3789
3842
|
updatedEntries[targetElementId] = entry.isIntersecting ? false : true;
|
|
3790
3843
|
}
|
|
3791
3844
|
});
|
|
@@ -3841,19 +3894,19 @@ const Sidebar = ({ childContainerClassName, children, breakpoint = "lg", classNa
|
|
|
3841
3894
|
});
|
|
3842
3895
|
const overflowItemCount = sharedUtils.objectValues(itemOverflowMap).filter(isOverflowing => isOverflowing).length;
|
|
3843
3896
|
const itemVisibilityClassName = (id) => {
|
|
3844
|
-
if (itemOverflowMap[id]) {
|
|
3897
|
+
if (itemOverflowMap[id] === true) {
|
|
3845
3898
|
return "invisible";
|
|
3846
3899
|
}
|
|
3847
3900
|
return "visible";
|
|
3848
3901
|
};
|
|
3849
|
-
return (jsxRuntime.jsxs("div", { className: cvaSidebar({ className }), "data-testid": dataTestId, children: [jsxRuntime.jsx("div", { className: cvaSidebarChildContainer({ breakpoint, className: childContainerClassName }), "data-testid":
|
|
3902
|
+
return (jsxRuntime.jsxs("div", { className: cvaSidebar({ className }), "data-testid": dataTestId, children: [jsxRuntime.jsx("div", { className: cvaSidebarChildContainer({ breakpoint, className: childContainerClassName }), "data-testid": `${dataTestId}-child-container`, ref: overflowContainerRef, children: react.Children.map(children, child => {
|
|
3850
3903
|
return react.cloneElement(child, {
|
|
3851
3904
|
className: tailwindMerge.twMerge(child.props.className, itemVisibilityClassName(child.props.id)),
|
|
3852
3905
|
});
|
|
3853
3906
|
}) }), overflowItemCount > 0 ? (jsxRuntime.jsx(MoreMenu, { iconButtonProps: {
|
|
3854
3907
|
variant: "ghost-neutral",
|
|
3855
|
-
}, ...moreMenuProps, className: moreMenuProps?.className, dataTestId:
|
|
3856
|
-
return itemOverflowMap[child.props.id]
|
|
3908
|
+
}, ...moreMenuProps, className: moreMenuProps?.className, dataTestId: `${dataTestId}-more-menu`, children: close => (jsxRuntime.jsx(MenuList, { ...menuListProps, dataTestId: dataTestId, children: react.Children.map(children, child => {
|
|
3909
|
+
return itemOverflowMap[child.props.id] === true
|
|
3857
3910
|
? react.cloneElement(child, {
|
|
3858
3911
|
onClick: () => {
|
|
3859
3912
|
child.props.onClick?.();
|
|
@@ -3916,8 +3969,8 @@ const cvaTab = cssClassVarianceUtilities.cvaMerge([
|
|
|
3916
3969
|
* Wrapper for radix tab component.
|
|
3917
3970
|
* We add a custom implementation of the asChild prop to make it easy to make the child element look like other tabs.
|
|
3918
3971
|
*/
|
|
3919
|
-
const Tab = ({ value, isFullWidth = false, iconName, dataTestId, className, children, suffix, asChild, appendTabStylesToChildIfAsChild = true, ...rest }) => {
|
|
3920
|
-
const renderContent = () => (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [iconName ? jsxRuntime.jsx(Icon, { name: iconName, size: "small" }) : null, react.isValidElement(children) ? children.props.children : children, suffix] }));
|
|
3972
|
+
const Tab = ({ value, isFullWidth = false, iconName = undefined, dataTestId, className, children, suffix, asChild = false, appendTabStylesToChildIfAsChild = true, ...rest }) => {
|
|
3973
|
+
const renderContent = () => (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [iconName !== undefined ? jsxRuntime.jsx(Icon, { name: iconName, size: "small" }) : null, react.isValidElement(children) ? children.props.children : children, suffix] }));
|
|
3921
3974
|
const commonProps = {
|
|
3922
3975
|
className: appendTabStylesToChildIfAsChild ? cvaTab({ className, isFullWidth }) : className,
|
|
3923
3976
|
...rest,
|
|
@@ -4077,8 +4130,8 @@ const ToggleGroup = ({ list, selected, setSelected, onChange, disabled = false,
|
|
|
4077
4130
|
const containerPadding = 2; // p-0.5 = 2px
|
|
4078
4131
|
const gap = 4;
|
|
4079
4132
|
const slidingLeft = containerPadding +
|
|
4080
|
-
buttonRefs.current.slice(0, validIndex).reduce((sum, ref) => sum + (ref?.offsetWidth
|
|
4081
|
-
const slidingWidth = buttonRefs.current[validIndex]?.offsetWidth
|
|
4133
|
+
buttonRefs.current.slice(0, validIndex).reduce((sum, ref) => sum + (ref?.offsetWidth ?? 0) + gap, 0);
|
|
4134
|
+
const slidingWidth = buttonRefs.current[validIndex]?.offsetWidth ?? 0;
|
|
4082
4135
|
react.useEffect(() => {
|
|
4083
4136
|
setIsMounted(true);
|
|
4084
4137
|
}, []);
|
|
@@ -4098,7 +4151,7 @@ const ToggleItem = ({ title, onClick, disabled, isIconOnly, iconName, size, clas
|
|
|
4098
4151
|
className,
|
|
4099
4152
|
selected,
|
|
4100
4153
|
disabled,
|
|
4101
|
-
}), dataTestId: dataTestId, disabled: disabled, icon: iconName ? (jsxRuntime.jsx(Icon, { className: cvaToggleItemContent({ selected, disabled }), name: iconName, size: size === "large" ? "medium" : "small" })) : null, isIconOnly: isIconOnly, onClick: onClick, ref: ref, size: size, title: title }) })) : (jsxRuntime.jsx(Tooltip, { disabled: !tooltip?.content &&
|
|
4154
|
+
}), dataTestId: dataTestId, disabled: disabled, icon: iconName ? (jsxRuntime.jsx(Icon, { className: cvaToggleItemContent({ selected, disabled }), name: iconName, size: size === "large" ? "medium" : "small" })) : null, isIconOnly: isIconOnly, onClick: onClick, ref: ref, size: size, title: title }) })) : (jsxRuntime.jsx(Tooltip, { disabled: !tooltip?.content && text?.truncate === false, label: tooltip?.content || title, placement: tooltip?.placement || "top", children: jsxRuntime.jsx(ToggleButton, { className: cvaToggleItem({
|
|
4102
4155
|
className,
|
|
4103
4156
|
selected,
|
|
4104
4157
|
disabled,
|
|
@@ -4164,7 +4217,7 @@ const cvaValueBarText = cssClassVarianceUtilities.cvaMerge(["whitespace-nowrap"]
|
|
|
4164
4217
|
*/
|
|
4165
4218
|
const getScore = (value, min, max, zeroScoreAllowed) => {
|
|
4166
4219
|
if (value <= min) {
|
|
4167
|
-
if (zeroScoreAllowed) {
|
|
4220
|
+
if (zeroScoreAllowed === true) {
|
|
4168
4221
|
return 0;
|
|
4169
4222
|
}
|
|
4170
4223
|
return 0.01; // always render at least some small fragment
|
|
@@ -4197,10 +4250,10 @@ const getDefaultFillColor = (score) => {
|
|
|
4197
4250
|
* @returns {string} color value
|
|
4198
4251
|
*/
|
|
4199
4252
|
const getFillColor = (score, levelColors) => {
|
|
4200
|
-
if (levelColors.low && score < (levelColors.low.level
|
|
4253
|
+
if (levelColors.low !== undefined && score < (levelColors.low.level !== undefined ? levelColors.low.level : 0)) {
|
|
4201
4254
|
return levelColors.low.color;
|
|
4202
4255
|
}
|
|
4203
|
-
if (levelColors.high && score >= (levelColors.high.level
|
|
4256
|
+
if (levelColors.high !== undefined && score >= (levelColors.high.level !== undefined ? levelColors.high.level : 0)) {
|
|
4204
4257
|
return levelColors.high.color;
|
|
4205
4258
|
}
|
|
4206
4259
|
return levelColors.medium?.color ?? uiDesignTokens.color("WARNING", 300);
|
|
@@ -4225,7 +4278,7 @@ const getValueBarColorByValue = (value, min, max, levelColors) => {
|
|
|
4225
4278
|
* @param {ValueBarProps} props - The props for the ValueBar component
|
|
4226
4279
|
* @returns {ReactElement} ValueBar component
|
|
4227
4280
|
*/
|
|
4228
|
-
const ValueBar = ({ value, min = 0, max = 100, unit, size = "small", levelColors, valueColor, showValue, className, dataTestId, zeroScoreAllowed, }) => {
|
|
4281
|
+
const ValueBar = ({ value, min = 0, max = 100, unit, size = "small", levelColors, valueColor, showValue = false, className, dataTestId, zeroScoreAllowed = false, }) => {
|
|
4229
4282
|
const score = getScore(value, min, max, zeroScoreAllowed);
|
|
4230
4283
|
const barFillColor = levelColors ? getFillColor(score, levelColors) : getDefaultFillColor(score);
|
|
4231
4284
|
const valueText = `${Number(value.toFixed(1))}${sharedUtils.nonNullable(unit) ? unit : ""}`;
|
|
@@ -4288,7 +4341,12 @@ const VirtualizedList = ({ count, rowHeight = 40, pagination, children, classNam
|
|
|
4288
4341
|
return {
|
|
4289
4342
|
pagination: pagination || reactTablePagination.noPagination,
|
|
4290
4343
|
containerRef: { current: scrollParent },
|
|
4291
|
-
rowSize: pagination
|
|
4344
|
+
rowSize: pagination !== undefined &&
|
|
4345
|
+
pagination.pageInfo !== undefined &&
|
|
4346
|
+
pagination.pageInfo.hasNextPage === true &&
|
|
4347
|
+
pagination.isLoading === true
|
|
4348
|
+
? count + 1
|
|
4349
|
+
: count,
|
|
4292
4350
|
rowHeight,
|
|
4293
4351
|
};
|
|
4294
4352
|
}, [pagination, scrollParent, count, rowHeight]);
|
|
@@ -4307,9 +4365,9 @@ const VirtualizedList = ({ count, rowHeight = 40, pagination, children, classNam
|
|
|
4307
4365
|
}, [scrollParent, fetchMoreOnBottomReached]);
|
|
4308
4366
|
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 => {
|
|
4309
4367
|
const isLoaderRow = virtualRow.index > count - 1;
|
|
4310
|
-
return (jsxRuntime.jsx("li", { className: cvaVirtualizedListItem({ separator }), "data-index": virtualRow.index, onClick: onRowClick ? () => onRowClick(virtualRow.index) : undefined, ref: measureElement, style: {
|
|
4368
|
+
return (jsxRuntime.jsx("li", { className: cvaVirtualizedListItem({ separator }), "data-index": virtualRow.index, onClick: onRowClick !== undefined ? () => onRowClick(virtualRow.index) : undefined, ref: measureElement, style: {
|
|
4311
4369
|
transform: `translateY(${virtualRow.start}px)`,
|
|
4312
|
-
}, 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));
|
|
4370
|
+
}, tabIndex: -1, children: isLoaderRow ? (pagination?.isLoading === true ? (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));
|
|
4313
4371
|
}) }) }));
|
|
4314
4372
|
};
|
|
4315
4373
|
|