@trackunit/react-components 1.8.22 → 1.8.24
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 +257 -205
- package/index.esm.js +256 -204
- 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/{VirtualizedList/VirtualizedList.d.ts → List/List.d.ts} +4 -4
- package/src/components/{VirtualizedList/VirtualizedList.variants.d.ts → List/List.variants.d.ts} +3 -3
- 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/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/components/index.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
|
@@ -17,9 +17,9 @@ var reactRouter = require('@tanstack/react-router');
|
|
|
17
17
|
var react$1 = require('@floating-ui/react');
|
|
18
18
|
var omit = require('lodash/omit');
|
|
19
19
|
var tailwindMerge = require('tailwind-merge');
|
|
20
|
+
var reactTablePagination = require('@trackunit/react-table-pagination');
|
|
20
21
|
var reactHelmetAsync = require('react-helmet-async');
|
|
21
22
|
var reactTabs = require('@radix-ui/react-tabs');
|
|
22
|
-
var reactTablePagination = require('@trackunit/react-table-pagination');
|
|
23
23
|
|
|
24
24
|
const docs = {
|
|
25
25
|
source: {
|
|
@@ -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();
|
|
@@ -1634,7 +1644,11 @@ const useWatch = ({ value, onChange, immediate = false, isEqual }) => {
|
|
|
1634
1644
|
const prevValue = react.useRef(UNINITIALIZED);
|
|
1635
1645
|
react.useEffect(() => {
|
|
1636
1646
|
const prev = prevValue.current;
|
|
1637
|
-
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);
|
|
1638
1652
|
if (immediate && prev === UNINITIALIZED) {
|
|
1639
1653
|
onChange(value, null);
|
|
1640
1654
|
}
|
|
@@ -1894,7 +1908,7 @@ const Card = ({ children, onClick, fullHeight = false, onMouseEnter, onMouseLeav
|
|
|
1894
1908
|
* @param {CardBodyProps} props - The props for the CardBody component
|
|
1895
1909
|
* @returns {ReactElement} CardBody component
|
|
1896
1910
|
*/
|
|
1897
|
-
const CardBody = ({ density = "auto", children, dataTestId, className, direction, disableGap, id, }) => {
|
|
1911
|
+
const CardBody = ({ density = "auto", children, dataTestId, className, direction = "column", disableGap = false, id, }) => {
|
|
1898
1912
|
return (jsxRuntime.jsx("div", { className: cvaCardBodyDensityContainer$1({ density, disableGap, className, direction }), "data-testid": dataTestId, id: id, children: children }));
|
|
1899
1913
|
};
|
|
1900
1914
|
|
|
@@ -1906,7 +1920,7 @@ const CardBody = ({ density = "auto", children, dataTestId, className, direction
|
|
|
1906
1920
|
* @param {CardFooterProps} props - The props for the CardFooter component
|
|
1907
1921
|
* @returns {ReactElement} CardFooter component
|
|
1908
1922
|
*/
|
|
1909
|
-
const CardFooter = ({ dataTestId, className, children, density, hideSeparator = false }) => {
|
|
1923
|
+
const CardFooter = ({ dataTestId, className, children, density = "auto", hideSeparator = false, }) => {
|
|
1910
1924
|
return (jsxRuntime.jsx("div", { className: cvaCardFooterDensityContainer({
|
|
1911
1925
|
density,
|
|
1912
1926
|
border: hideSeparator ? "borderless" : "default",
|
|
@@ -1971,12 +1985,12 @@ const Heading = ({ variant = "primary", inverted = false, subtle = false, classN
|
|
|
1971
1985
|
* @param {CardHeaderProps} props - The props for the CardHeader component
|
|
1972
1986
|
* @returns {ReactElement} CardHeader component
|
|
1973
1987
|
*/
|
|
1974
|
-
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, }) => {
|
|
1975
1989
|
return (jsxRuntime.jsx("div", { className: cvaCardHeaderDensityContainer({
|
|
1976
1990
|
density,
|
|
1977
1991
|
border: hideSeparator ? "borderless" : "default",
|
|
1978
1992
|
className,
|
|
1979
|
-
}), "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] })] }) }));
|
|
1980
1994
|
};
|
|
1981
1995
|
|
|
1982
1996
|
const cvaCollapse = cssClassVarianceUtilities.cvaMerge([
|
|
@@ -2062,9 +2076,9 @@ const Collapse = ({ id, initialExpanded = false, onToggle, label, children, clas
|
|
|
2062
2076
|
}
|
|
2063
2077
|
setExpanded(!expanded);
|
|
2064
2078
|
}, [expanded, onToggle]);
|
|
2065
|
-
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 })] }));
|
|
2066
2080
|
};
|
|
2067
|
-
const Collapsible = ({ children, expanded, id, extraPadding }) => {
|
|
2081
|
+
const Collapsible = ({ children, expanded, id, extraPadding = true }) => {
|
|
2068
2082
|
const ref = react.useRef(null);
|
|
2069
2083
|
const { height } = useGeometry(ref);
|
|
2070
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 }) }) }));
|
|
@@ -2083,7 +2097,7 @@ const Collapsible = ({ children, expanded, id, extraPadding }) => {
|
|
|
2083
2097
|
* @param {boolean} props.warning - Indicates if the process has a warning.
|
|
2084
2098
|
* @param {boolean} props.success - Indicates if the process was successful.
|
|
2085
2099
|
*/
|
|
2086
|
-
const CompletionStatusIndicator = ({ loading, error, success, ...rest }) => {
|
|
2100
|
+
const CompletionStatusIndicator = ({ loading = false, error, success, ...rest }) => {
|
|
2087
2101
|
if (loading) {
|
|
2088
2102
|
return jsxRuntime.jsx(Spinner, { className: "h-[22px] w-[22px]", containerClassName: "w-min", ...rest });
|
|
2089
2103
|
}
|
|
@@ -2177,17 +2191,17 @@ const cvaSkeletonLine = cssClassVarianceUtilities.cvaMerge([
|
|
|
2177
2191
|
/**
|
|
2178
2192
|
* Display placeholder lines before the data gets loaded to reduce load-time frustration.
|
|
2179
2193
|
*/
|
|
2180
|
-
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, }) => {
|
|
2181
2195
|
const skeletonLines = [];
|
|
2182
2196
|
const getWidth = (index) => {
|
|
2183
|
-
if (width
|
|
2184
|
-
return width[index]
|
|
2197
|
+
if (Array.isArray(width)) {
|
|
2198
|
+
return width[index] ?? "100%";
|
|
2185
2199
|
}
|
|
2186
2200
|
return width;
|
|
2187
2201
|
};
|
|
2188
2202
|
const getHeight = (index) => {
|
|
2189
|
-
if (height
|
|
2190
|
-
return height[index]
|
|
2203
|
+
if (Array.isArray(height)) {
|
|
2204
|
+
return height[index] ?? "auto";
|
|
2191
2205
|
}
|
|
2192
2206
|
return height;
|
|
2193
2207
|
};
|
|
@@ -2271,7 +2285,7 @@ WorkerWithSignSVG.displayName = "WorkerWithSignSVG";
|
|
|
2271
2285
|
* - For guidance purposes (e.g., onboarding, adjusting filters, exploring alternative approaches).
|
|
2272
2286
|
* - In celebratory instances (e.g., no new notifications, services up to date).
|
|
2273
2287
|
*/
|
|
2274
|
-
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, }) => {
|
|
2275
2289
|
const ImageSource = react.useMemo(() => {
|
|
2276
2290
|
switch (image) {
|
|
2277
2291
|
case "WORKER_WITH_SIGN":
|
|
@@ -2289,7 +2303,7 @@ const EmptyState = ({ description, altText, image = "SEARCH_DOCUMENT", customIma
|
|
|
2289
2303
|
return SearchDocumentSVG;
|
|
2290
2304
|
}
|
|
2291
2305
|
}, [image]);
|
|
2292
|
-
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] })] })) }));
|
|
2293
2307
|
};
|
|
2294
2308
|
|
|
2295
2309
|
const cvaEmptyValue = cssClassVarianceUtilities.cvaMerge(["text-neutral-400"]);
|
|
@@ -2640,7 +2654,7 @@ const cvaPopoverTitleText = cssClassVarianceUtilities.cvaMerge(["flex-1", "text-
|
|
|
2640
2654
|
const PopoverContent = function PopoverContent({ className, dataTestId, children, portalId, ref: propRef, ...props }) {
|
|
2641
2655
|
const { context: floatingContext, customProps, ...context } = usePopoverContext();
|
|
2642
2656
|
const ref = react$1.useMergeRefs([context.refs.setFloating, propRef]);
|
|
2643
|
-
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: {
|
|
2644
2658
|
position: context.strategy,
|
|
2645
2659
|
top: context.y,
|
|
2646
2660
|
left: context.x,
|
|
@@ -2655,7 +2669,7 @@ const PopoverContent = function PopoverContent({ className, dataTestId, children
|
|
|
2655
2669
|
* @param {PopoverTitleProps} props - The props for the PopoverTitle component
|
|
2656
2670
|
* @returns {ReactElement} PopoverTitle component
|
|
2657
2671
|
*/
|
|
2658
|
-
const PopoverTitle = ({ children, action, divider = false, className, dataTestId }) => {
|
|
2672
|
+
const PopoverTitle = ({ children, action, divider = false, className, dataTestId, }) => {
|
|
2659
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] }));
|
|
2660
2674
|
};
|
|
2661
2675
|
|
|
@@ -2665,7 +2679,7 @@ const PopoverTitle = ({ children, action, divider = false, className, dataTestId
|
|
|
2665
2679
|
* @param {PopoverTriggerProps} props - The props for the PopoverTrigger component
|
|
2666
2680
|
* @returns {ReactElement} PopoverTrigger component
|
|
2667
2681
|
*/
|
|
2668
|
-
const PopoverTrigger = function PopoverTrigger({ children, renderButton, ref: propRef, ...props }) {
|
|
2682
|
+
const PopoverTrigger = function PopoverTrigger({ children, renderButton = false, ref: propRef, ...props }) {
|
|
2669
2683
|
const context = usePopoverContext();
|
|
2670
2684
|
const ref = react$1.useMergeRefs([context.refs.setReference, propRef]);
|
|
2671
2685
|
if (!renderButton && react.isValidElement(children)) {
|
|
@@ -2673,10 +2687,10 @@ const PopoverTrigger = function PopoverTrigger({ children, renderButton, ref: pr
|
|
|
2673
2687
|
ref,
|
|
2674
2688
|
...props,
|
|
2675
2689
|
...children.props,
|
|
2676
|
-
"data-state": context.isOpen ? "open" : "closed",
|
|
2690
|
+
"data-state": context.isOpen === true ? "open" : "closed",
|
|
2677
2691
|
}));
|
|
2678
2692
|
}
|
|
2679
|
-
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 }));
|
|
2680
2694
|
};
|
|
2681
2695
|
|
|
2682
2696
|
const cvaTooltipContainer = cssClassVarianceUtilities.cvaMerge(["flex", "leading-5"]);
|
|
@@ -2752,7 +2766,7 @@ const FloatingArrowContainer = ({ arrowRef, mode = "dark", }) => {
|
|
|
2752
2766
|
* @param {TooltipProps} props - The props for the Tooltip component
|
|
2753
2767
|
* @returns {ReactElement} Tooltip component
|
|
2754
2768
|
*/
|
|
2755
|
-
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, }) => {
|
|
2756
2770
|
const [isOpen, setIsOpen] = react.useState(false);
|
|
2757
2771
|
const arrowRef = react.useRef(null);
|
|
2758
2772
|
const { refs, floatingStyles, context } = react$1.useFloating({
|
|
@@ -2918,8 +2932,8 @@ const cvaIndicatorIconBackground = cssClassVarianceUtilities.cvaMerge(["rounded-
|
|
|
2918
2932
|
* @param {IndicatorProps} props - The props for the Indicator component
|
|
2919
2933
|
* @returns {ReactElement} Indicator component
|
|
2920
2934
|
*/
|
|
2921
|
-
const Indicator = ({ dataTestId, icon, label, color = "unknown", withBackground = true, withLabel = true, ping = false, size, weight, className, ...rest }) => {
|
|
2922
|
-
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] }) }));
|
|
2923
2937
|
};
|
|
2924
2938
|
|
|
2925
2939
|
const cvaKPI = cssClassVarianceUtilities.cvaMerge(["w-full", "px-4", "py-2", "flex", "flex-col"], {
|
|
@@ -2979,10 +2993,10 @@ const LoadingContent$1 = () => (jsxRuntime.jsx("div", { className: "flex h-11 fl
|
|
|
2979
2993
|
* @param {KPIProps} props - The props for the KPI component
|
|
2980
2994
|
* @returns {ReactElement} KPI component
|
|
2981
2995
|
*/
|
|
2982
|
-
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 }) => {
|
|
2983
2997
|
const isSmallVariant = variant === "small";
|
|
2984
|
-
return (jsxRuntime.jsx(Tooltip, { dataTestId: dataTestId ? `${dataTestId}-tooltip` : undefined, disabled:
|
|
2985
|
-
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),
|
|
2986
3000
|
className,
|
|
2987
3001
|
}), children: [jsxRuntime.jsxs("span", { className: cvaKPIvalueText({ variant }), children: [value, " ", unit] }), jsxRuntime.jsx(TrendIndicator, { isSmallVariant: isSmallVariant, trend: trend, unit: unit })] }) })] })) }) }));
|
|
2988
3002
|
};
|
|
@@ -2990,7 +3004,7 @@ const TrendIndicator = ({ trend, unit, isSmallVariant }) => {
|
|
|
2990
3004
|
if (!trend) {
|
|
2991
3005
|
return null;
|
|
2992
3006
|
}
|
|
2993
|
-
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] }));
|
|
2994
3008
|
};
|
|
2995
3009
|
|
|
2996
3010
|
const cvaKPICard = cssClassVarianceUtilities.cvaMerge([
|
|
@@ -3035,14 +3049,14 @@ const cvaKPIIconContainer = cssClassVarianceUtilities.cvaMerge(["flex", "items-c
|
|
|
3035
3049
|
* @param {KPICardProps} props - The props for the KPICard component
|
|
3036
3050
|
* @returns {ReactElement} KPICard component
|
|
3037
3051
|
*/
|
|
3038
|
-
const KPICard = ({ isActive, onClick, className, dataTestId, children, iconName, iconColor, ...rest }) => {
|
|
3039
|
-
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);
|
|
3040
3054
|
return (jsxRuntime.jsx(Card, { className: cvaKPICard({
|
|
3041
3055
|
isClickable,
|
|
3042
3056
|
isActive,
|
|
3043
3057
|
minHeight: rest.trend ? "withTrends" : "default",
|
|
3044
3058
|
className,
|
|
3045
|
-
}), "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] }) }));
|
|
3046
3060
|
};
|
|
3047
3061
|
const cvaCardBodyDensityContainer = cssClassVarianceUtilities.cvaMerge(["grid", "grid-cols-[1fr_auto]"], {
|
|
3048
3062
|
variants: {
|
|
@@ -3053,6 +3067,92 @@ const cvaCardBodyDensityContainer = cssClassVarianceUtilities.cvaMerge(["grid",
|
|
|
3053
3067
|
},
|
|
3054
3068
|
});
|
|
3055
3069
|
|
|
3070
|
+
const cvaListContainer = cssClassVarianceUtilities.cvaMerge(["h-full"], {
|
|
3071
|
+
variants: {
|
|
3072
|
+
parentControlledScrollable: {
|
|
3073
|
+
true: [""],
|
|
3074
|
+
false: ["overflow-auto"],
|
|
3075
|
+
},
|
|
3076
|
+
},
|
|
3077
|
+
defaultVariants: {
|
|
3078
|
+
parentControlledScrollable: false,
|
|
3079
|
+
},
|
|
3080
|
+
});
|
|
3081
|
+
const cvaList = cssClassVarianceUtilities.cvaMerge(["relative"]);
|
|
3082
|
+
const cvaListItem$1 = cssClassVarianceUtilities.cvaMerge(["absolute", "top-0", "left-0", "w-full"], {
|
|
3083
|
+
variants: {
|
|
3084
|
+
separator: {
|
|
3085
|
+
alternating: ["even:bg-slate-100"],
|
|
3086
|
+
line: ["[&:not(:last-child)]:border-b", "border-gray-200"],
|
|
3087
|
+
none: "",
|
|
3088
|
+
space: "[&:not(:last-child)]:pb-0.5",
|
|
3089
|
+
},
|
|
3090
|
+
},
|
|
3091
|
+
defaultVariants: {
|
|
3092
|
+
separator: "none",
|
|
3093
|
+
},
|
|
3094
|
+
});
|
|
3095
|
+
|
|
3096
|
+
/**
|
|
3097
|
+
* Render a performant virtualized list of items. Optionally with infinite scrolling.
|
|
3098
|
+
*
|
|
3099
|
+
* @property {number} count - The total number of items in the list.
|
|
3100
|
+
* @property {number} [rowHeight="40"] - The estimated height of each row in the list.
|
|
3101
|
+
* @property {RelayPagination | undefined} pagination - Pagination configuration for the list.
|
|
3102
|
+
* @property {separator} [separator="line"] - The separator style between items in the list.
|
|
3103
|
+
* @property {(index: number) =>ReactElement} children - A function that takes an index and returns the JSX element to be rendered at said index.
|
|
3104
|
+
* @property {loadingIndicator} [loadingIndicator="spinner"] - The type of loading indicator in the list.
|
|
3105
|
+
* @property {skeletonLinesHeight} [skeletonLinesHeight="2rem"] - The height of the skeleton lines.
|
|
3106
|
+
*/
|
|
3107
|
+
const List = ({ count, rowHeight = 40, pagination, children, className, dataTestId, separator = "none", loadingIndicator = "spinner", skeletonLinesHeight = rowHeight + "px", onRowClick, scrollRef, }) => {
|
|
3108
|
+
const containerRef = react.useRef(null);
|
|
3109
|
+
const listRef = react.useRef(null);
|
|
3110
|
+
const [scrollParent, setScrollParent] = react.useState(null);
|
|
3111
|
+
const [parentControlledScrollable, setParentControlledScrollable] = react.useState(false);
|
|
3112
|
+
react.useEffect(() => {
|
|
3113
|
+
if (scrollRef?.current) {
|
|
3114
|
+
setParentControlledScrollable(true);
|
|
3115
|
+
setScrollParent(scrollRef.current);
|
|
3116
|
+
}
|
|
3117
|
+
else {
|
|
3118
|
+
setParentControlledScrollable(false);
|
|
3119
|
+
setScrollParent(containerRef.current);
|
|
3120
|
+
}
|
|
3121
|
+
}, [scrollRef]);
|
|
3122
|
+
const infiniteScrollProps = react.useMemo(() => {
|
|
3123
|
+
return {
|
|
3124
|
+
pagination: pagination || reactTablePagination.noPagination,
|
|
3125
|
+
containerRef: { current: scrollParent },
|
|
3126
|
+
rowSize: pagination !== undefined &&
|
|
3127
|
+
pagination.pageInfo !== undefined &&
|
|
3128
|
+
pagination.pageInfo.hasNextPage === true &&
|
|
3129
|
+
pagination.isLoading === true
|
|
3130
|
+
? count + 1
|
|
3131
|
+
: count,
|
|
3132
|
+
rowHeight,
|
|
3133
|
+
};
|
|
3134
|
+
}, [pagination, scrollParent, count, rowHeight]);
|
|
3135
|
+
const { fetchMoreOnBottomReached, getVirtualItems, getTotalSize, measureElement } = reactTablePagination.useInfiniteScroll(infiniteScrollProps);
|
|
3136
|
+
react.useEffect(() => {
|
|
3137
|
+
if (scrollParent) {
|
|
3138
|
+
const handleScroll = () => {
|
|
3139
|
+
fetchMoreOnBottomReached(scrollParent);
|
|
3140
|
+
};
|
|
3141
|
+
scrollParent.addEventListener("scroll", handleScroll);
|
|
3142
|
+
return () => {
|
|
3143
|
+
scrollParent.removeEventListener("scroll", handleScroll);
|
|
3144
|
+
};
|
|
3145
|
+
}
|
|
3146
|
+
return undefined;
|
|
3147
|
+
}, [scrollParent, fetchMoreOnBottomReached]);
|
|
3148
|
+
return (jsxRuntime.jsx("div", { className: cvaListContainer({ parentControlledScrollable, className }), "data-testid": dataTestId, ref: containerRef, children: jsxRuntime.jsx("ul", { className: cvaList(), ref: listRef, style: { height: `${getTotalSize()}px`, outline: "none" }, children: getVirtualItems().map(virtualRow => {
|
|
3149
|
+
const isLoaderRow = virtualRow.index > count - 1;
|
|
3150
|
+
return (jsxRuntime.jsx("li", { className: cvaListItem$1({ separator }), "data-index": virtualRow.index, onClick: onRowClick !== undefined ? () => onRowClick(virtualRow.index) : undefined, ref: measureElement, style: {
|
|
3151
|
+
transform: `translateY(${virtualRow.start}px)`,
|
|
3152
|
+
}, 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));
|
|
3153
|
+
}) }) }));
|
|
3154
|
+
};
|
|
3155
|
+
|
|
3056
3156
|
/**
|
|
3057
3157
|
* Applies standardized interaction-related styles to an element.
|
|
3058
3158
|
*
|
|
@@ -3078,9 +3178,9 @@ const cvaInteractableItem = cssClassVarianceUtilities.cvaMerge("", {
|
|
|
3078
3178
|
default: "cursor-default",
|
|
3079
3179
|
"not-allowed": "cursor-not-allowed",
|
|
3080
3180
|
},
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
|
|
3181
|
+
selection: {
|
|
3182
|
+
selected: ["bg-primary-50", "hover:bg-primary-50", "focus-within:bg-primary-50"],
|
|
3183
|
+
unselected: "",
|
|
3084
3184
|
auto: [
|
|
3085
3185
|
"hover:bg-neutral-100",
|
|
3086
3186
|
"has-[:checked]:bg-primary-50",
|
|
@@ -3093,24 +3193,24 @@ const cvaInteractableItem = cssClassVarianceUtilities.cvaMerge("", {
|
|
|
3093
3193
|
true: ["pointer-events-none", "!bg-neutral-100", "!cursor-not-allowed"],
|
|
3094
3194
|
false: "", // use compoundVariants instead
|
|
3095
3195
|
},
|
|
3096
|
-
|
|
3097
|
-
|
|
3098
|
-
|
|
3196
|
+
focus: {
|
|
3197
|
+
focused: ["bg-neutral-600/5"],
|
|
3198
|
+
unfocused: "",
|
|
3099
3199
|
auto: "[&:has(:focus-visible)]:outline-native",
|
|
3100
3200
|
},
|
|
3101
3201
|
},
|
|
3102
3202
|
compoundVariants: [
|
|
3103
3203
|
{
|
|
3104
3204
|
disabled: false,
|
|
3105
|
-
|
|
3205
|
+
selection: "unselected",
|
|
3106
3206
|
className: ["hover:bg-neutral-600/5", "focus-within:bg-neutral-600/5"],
|
|
3107
3207
|
},
|
|
3108
3208
|
],
|
|
3109
3209
|
defaultVariants: {
|
|
3110
3210
|
cursor: "auto",
|
|
3111
|
-
|
|
3211
|
+
selection: "auto",
|
|
3112
3212
|
disabled: false,
|
|
3113
|
-
|
|
3213
|
+
focus: "auto",
|
|
3114
3214
|
},
|
|
3115
3215
|
});
|
|
3116
3216
|
|
|
@@ -3147,7 +3247,7 @@ const ListItem = ({ className, dataTestId, onClick, details, title, description,
|
|
|
3147
3247
|
}), 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, {
|
|
3148
3248
|
className: tailwindMerge.twMerge(title.props.className, "neutral-900 text-sm font-medium truncate"),
|
|
3149
3249
|
dataTestId: !title.props.dataTestId && dataTestId ? `${dataTestId}-title` : undefined,
|
|
3150
|
-
})) }), 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, {
|
|
3250
|
+
})) }), 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, {
|
|
3151
3251
|
className: tailwindMerge.twMerge(description.props.className, "text-neutral-500 text-xs font-medium truncate"),
|
|
3152
3252
|
dataTestId: !description.props.dataTestId && dataTestId ? `${dataTestId}-description` : undefined,
|
|
3153
3253
|
})) })) : 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] })] }));
|
|
@@ -3189,7 +3289,12 @@ const MenuDivider = () => {
|
|
|
3189
3289
|
*/
|
|
3190
3290
|
const cvaMenuItem = (props) => {
|
|
3191
3291
|
const { selected, disabled, focused, className, variant, fieldSize } = props ?? {};
|
|
3192
|
-
return tailwindMerge.twMerge(cvaMenuItemStyle({ variant, selected, disabled, fieldSize }), cvaInteractableItem({
|
|
3292
|
+
return tailwindMerge.twMerge(cvaMenuItemStyle({ variant, selected, disabled, fieldSize }), cvaInteractableItem({
|
|
3293
|
+
selection: selected === true ? "selected" : "unselected",
|
|
3294
|
+
disabled,
|
|
3295
|
+
cursor: "pointer",
|
|
3296
|
+
focus: focused === true ? "focused" : "unfocused",
|
|
3297
|
+
}), className);
|
|
3193
3298
|
};
|
|
3194
3299
|
const cvaMenuItemStyle = cssClassVarianceUtilities.cvaMerge(["py-2", "px-2", "h-auto", "flex", "flex-row", "items-center", "gap-x-2", "select-none", "rounded", "text-sm"], {
|
|
3195
3300
|
variants: {
|
|
@@ -3302,10 +3407,10 @@ const cvaMenuItemSuffix = cssClassVarianceUtilities.cvaMerge(["text-secondary-40
|
|
|
3302
3407
|
* @param {MenuItemProps} props - The props for the MenuItem component
|
|
3303
3408
|
* @returns {ReactElement} MenuItem component
|
|
3304
3409
|
*/
|
|
3305
|
-
const MenuItem = ({ className, dataTestId, label, children, selected, focused, prefix, suffix, disabled, onClick, stopPropagation = true, id, tabIndex, optionLabelDescription, optionPrefix, fieldSize = "medium", variant = "primary", }) => {
|
|
3410
|
+
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", }) => {
|
|
3306
3411
|
/* Handle tab navigation */
|
|
3307
3412
|
const handleKeyDown = (e) => {
|
|
3308
|
-
if (e.key === "Enter" && onClick &&
|
|
3413
|
+
if (e.key === "Enter" && onClick !== undefined && disabled !== true) {
|
|
3309
3414
|
if (stopPropagation) {
|
|
3310
3415
|
e.stopPropagation();
|
|
3311
3416
|
}
|
|
@@ -3325,7 +3430,7 @@ const MenuItem = ({ className, dataTestId, label, children, selected, focused, p
|
|
|
3325
3430
|
e.stopPropagation();
|
|
3326
3431
|
}
|
|
3327
3432
|
onClick?.(e);
|
|
3328
|
-
}, 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] }));
|
|
3433
|
+
}, 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] }));
|
|
3329
3434
|
};
|
|
3330
3435
|
|
|
3331
3436
|
/**
|
|
@@ -3343,16 +3448,13 @@ const MenuList = ({ dataTestId, className, children, withStickyHeader = false, i
|
|
|
3343
3448
|
const childrenArr = react.Children.toArray(children);
|
|
3344
3449
|
const [internalSelectedItems, setInternalSelectedItems] = react.useState(controlledSelectedItems ?? []);
|
|
3345
3450
|
const selectedItems = controlledSelectedItems ?? internalSelectedItems;
|
|
3346
|
-
const handleItemClick = react.useCallback((id
|
|
3347
|
-
if (disabled) {
|
|
3348
|
-
return;
|
|
3349
|
-
}
|
|
3451
|
+
const handleItemClick = react.useCallback((id) => {
|
|
3350
3452
|
const newSelectedItems = isMulti
|
|
3351
3453
|
? selectedItems.includes(id)
|
|
3352
3454
|
? selectedItems.filter(item => item !== id)
|
|
3353
3455
|
: [...selectedItems, id]
|
|
3354
3456
|
: [id];
|
|
3355
|
-
if (onSelectionChange) {
|
|
3457
|
+
if (onSelectionChange !== undefined) {
|
|
3356
3458
|
onSelectionChange(newSelectedItems);
|
|
3357
3459
|
}
|
|
3358
3460
|
else {
|
|
@@ -3361,13 +3463,15 @@ const MenuList = ({ dataTestId, className, children, withStickyHeader = false, i
|
|
|
3361
3463
|
}, [isMulti, selectedItems, onSelectionChange]);
|
|
3362
3464
|
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) => {
|
|
3363
3465
|
if (react.isValidElement(menuItem)) {
|
|
3364
|
-
const isSelected = selectedItems.includes(menuItem.props.id ?? `${index}`) || menuItem.props.selected;
|
|
3466
|
+
const isSelected = (selectedItems.includes(menuItem.props.id ?? `${index}`) || menuItem.props.selected) ?? false;
|
|
3365
3467
|
return react.cloneElement(menuItem, {
|
|
3366
3468
|
...menuItem.props,
|
|
3367
3469
|
key: index,
|
|
3368
3470
|
onClick: (event) => {
|
|
3369
3471
|
menuItem.props.onClick?.(event);
|
|
3370
|
-
|
|
3472
|
+
if (menuItem.props.disabled !== true) {
|
|
3473
|
+
handleItemClick(menuItem.props.id ?? `${index}`);
|
|
3474
|
+
}
|
|
3371
3475
|
},
|
|
3372
3476
|
className: isMulti && isSelected
|
|
3373
3477
|
? cvaMenuListMultiSelect({ className: menuItem.props.className })
|
|
@@ -3449,7 +3553,7 @@ const cvaNoticeIcon = cssClassVarianceUtilities.cvaMerge(["rounded-full", "items
|
|
|
3449
3553
|
* @returns {ReactElement} Notice component
|
|
3450
3554
|
*/
|
|
3451
3555
|
const Notice = ({ dataTestId, icon, label, color = "neutral", withLabel = true, className, tooltipLabel = label, withTooltip = false, size = "medium", ...rest }) => {
|
|
3452
|
-
return (jsxRuntime.jsx(Tooltip, { className: className, disabled:
|
|
3556
|
+
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] }) }));
|
|
3453
3557
|
};
|
|
3454
3558
|
|
|
3455
3559
|
const cvaPage = cssClassVarianceUtilities.cvaMerge(["grid", "h-full"], {
|
|
@@ -3482,7 +3586,7 @@ const cvaPageContent = cssClassVarianceUtilities.cvaMerge(["overflow-auto", "pag
|
|
|
3482
3586
|
* Renders the page component. Adds padding and layout to the page.
|
|
3483
3587
|
*/
|
|
3484
3588
|
const Page = ({ layout, className, children, dataTestId }) => {
|
|
3485
|
-
return (jsxRuntime.jsx("div", { className: cvaPage({ className, layout }), "data-testid": dataTestId
|
|
3589
|
+
return (jsxRuntime.jsx("div", { className: cvaPage({ className, layout }), "data-testid": dataTestId ? dataTestId : "page", children: children }));
|
|
3486
3590
|
};
|
|
3487
3591
|
|
|
3488
3592
|
/**
|
|
@@ -3497,17 +3601,30 @@ const PageContent = ({ className, children, dataTestId, layout }) => {
|
|
|
3497
3601
|
};
|
|
3498
3602
|
|
|
3499
3603
|
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] }) }) }));
|
|
3604
|
+
/**
|
|
3605
|
+
* The PageHeaderKpiMetrics component is used to render the KPI metrics in the PageHeader component.
|
|
3606
|
+
*
|
|
3607
|
+
* @param {object} props - The props for the PageHeaderKpiMetrics component
|
|
3608
|
+
* @param {Array<PageHeaderKpiMetricsType>} props.kpiMetrics - The KPI metrics to render
|
|
3609
|
+
* @returns {ReactElement} PageHeaderKpiMetrics component
|
|
3610
|
+
*/
|
|
3500
3611
|
const PageHeaderKpiMetrics = ({ kpiMetrics }) => {
|
|
3501
3612
|
return (jsxRuntime.jsx("div", { className: "hidden items-center gap-4 md:flex", children: kpiMetrics
|
|
3502
|
-
.filter(kpi =>
|
|
3613
|
+
.filter(kpi => kpi.hidden === false || kpi.hidden === undefined)
|
|
3503
3614
|
.map((kpi, index) => {
|
|
3504
|
-
if (kpi.loading) {
|
|
3615
|
+
if (kpi.loading === true) {
|
|
3505
3616
|
return jsxRuntime.jsx(LoadingContent, {}, `${kpi}-${index}`);
|
|
3506
3617
|
}
|
|
3507
3618
|
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}`));
|
|
3508
3619
|
}) }));
|
|
3509
3620
|
};
|
|
3510
3621
|
|
|
3622
|
+
/**
|
|
3623
|
+
* The ActionRenderer component is used to render the action in the PageHeaderSecondaryActions component.
|
|
3624
|
+
*
|
|
3625
|
+
* @param {ActionRendererProps} props - The props for the ActionRenderer component
|
|
3626
|
+
* @returns {ReactElement} ActionRenderer component
|
|
3627
|
+
*/
|
|
3511
3628
|
function ActionRenderer({ action, isMenuItem = false, externalOnClick }) {
|
|
3512
3629
|
const { to, tooltipLabel, prefixIconName, disabled, actionText, actionCallback, dataTestId, target, variant } = action;
|
|
3513
3630
|
// This component handles all the "wrapping" logic for Link/Tooltip
|
|
@@ -3522,10 +3639,18 @@ function ActionRenderer({ action, isMenuItem = false, externalOnClick }) {
|
|
|
3522
3639
|
// Wrap `content` with Tooltip
|
|
3523
3640
|
const wrappedWithTooltip = tooltipLabel ? (jsxRuntime.jsx(Tooltip, { className: "block", label: tooltipLabel, children: content })) : (content);
|
|
3524
3641
|
// Finally, wrap with Link if `to` is provided
|
|
3525
|
-
return to ? (jsxRuntime.jsx(reactRouter.Link, { target: target, to: to, children: wrappedWithTooltip })) : (wrappedWithTooltip);
|
|
3642
|
+
return to !== undefined && to !== "" ? (jsxRuntime.jsx(reactRouter.Link, { target: target, to: to, children: wrappedWithTooltip })) : (wrappedWithTooltip);
|
|
3526
3643
|
}
|
|
3527
|
-
|
|
3528
|
-
|
|
3644
|
+
/**
|
|
3645
|
+
* The PageHeaderSecondaryActions component is used to render the secondary actions in the PageHeader component.
|
|
3646
|
+
*
|
|
3647
|
+
* @param {object} props - The props for the PageHeaderSecondaryActions component
|
|
3648
|
+
* @param {Array<PageHeaderSecondaryActionType>} props.actions - The secondary actions to render
|
|
3649
|
+
* @param {boolean} [props.hasPrimaryAction] - Whether there is a primary action present
|
|
3650
|
+
* @returns {ReactElement} PageHeaderSecondaryActions component
|
|
3651
|
+
*/
|
|
3652
|
+
const PageHeaderSecondaryActions = ({ actions, hasPrimaryAction = false, }) => {
|
|
3653
|
+
const enabledActions = react.useMemo(() => actions.filter(action => action.hidden === false || action.hidden === undefined), [actions]);
|
|
3529
3654
|
// If we need to render a "More Menu" because we have too many actions:
|
|
3530
3655
|
if (enabledActions.length > 2 || (hasPrimaryAction && enabledActions.length > 1)) {
|
|
3531
3656
|
// Separate them into danger vs. other
|
|
@@ -3537,7 +3662,7 @@ const PageHeaderSecondaryActions = ({ actions, hasPrimaryAction, }) => {
|
|
|
3537
3662
|
return [danger, [...others, action]];
|
|
3538
3663
|
}
|
|
3539
3664
|
}, [[], []]);
|
|
3540
|
-
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}`)))] })) }));
|
|
3665
|
+
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}`)))] })) }));
|
|
3541
3666
|
}
|
|
3542
3667
|
// Otherwise, render them inline as buttons
|
|
3543
3668
|
return (jsxRuntime.jsx("div", { className: "flex flex-row items-center gap-2", children: enabledActions
|
|
@@ -3564,6 +3689,14 @@ const cvaPageHeaderContainer = cssClassVarianceUtilities.cvaMerge(["bg-white", "
|
|
|
3564
3689
|
const cvaPageHeader = cssClassVarianceUtilities.cvaMerge(["box-border", "py-4", "px-6", "flex", "items-center", "gap-y-1"]);
|
|
3565
3690
|
const cvaPageHeaderHeading = cssClassVarianceUtilities.cvaMerge(["text-slate-900", "text-xl", "font-semibold", "truncate"]);
|
|
3566
3691
|
|
|
3692
|
+
/**
|
|
3693
|
+
* The PageHeaderTitle component is used to display the title of the page header.
|
|
3694
|
+
*
|
|
3695
|
+
* @param {object} props - The props for the PageHeaderTitle component
|
|
3696
|
+
* @param {string} props.title - The title of the page header
|
|
3697
|
+
* @param {string} [props.dataTestId] - The data test id of the page header title
|
|
3698
|
+
* @returns {ReactElement} PageHeaderTitle component
|
|
3699
|
+
*/
|
|
3567
3700
|
const PageHeaderTitle = ({ title, dataTestId }) => {
|
|
3568
3701
|
const { ref, isTextTruncated } = useIsTextTruncated();
|
|
3569
3702
|
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 }) }) }));
|
|
@@ -3579,21 +3712,21 @@ const PageHeaderTitle = ({ title, dataTestId }) => {
|
|
|
3579
3712
|
* @param {PageHeaderProps} props - The props for the PageHeader component
|
|
3580
3713
|
* @returns {ReactElement} PageHeader component
|
|
3581
3714
|
*/
|
|
3582
|
-
const PageHeader = ({ className, dataTestId, secondaryActions, showLoading, description, title, tagLabel, backTo, tagColor, tabsList, descriptionIcon, kpiMetrics, tagTooltipLabel, primaryAction, }) => {
|
|
3715
|
+
const PageHeader = ({ className, dataTestId, secondaryActions, showLoading = false, description, title, tagLabel, backTo, tagColor, tabsList, descriptionIcon = "QuestionMarkCircle", kpiMetrics, tagTooltipLabel, primaryAction, }) => {
|
|
3583
3716
|
const tagRenderer = react.useMemo(() => {
|
|
3584
|
-
if (
|
|
3717
|
+
if (tagLabel === undefined || tagLabel === "" || showLoading) {
|
|
3585
3718
|
return null;
|
|
3586
3719
|
}
|
|
3587
3720
|
// If the user passes a string, we render the string as a tag with props provided.
|
|
3588
|
-
return (jsxRuntime.jsx("div", { className: "ml-auto flex flex-row gap-2", children: jsxRuntime.jsx(Tooltip, { dataTestId: "page-header-tag-tooltip", disabled:
|
|
3721
|
+
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 }) }) }));
|
|
3589
3722
|
}, [showLoading, tagColor, tagLabel, tagTooltipLabel]);
|
|
3590
3723
|
return (jsxRuntime.jsxs("div", { className: cvaPageHeaderContainer({
|
|
3591
3724
|
className,
|
|
3592
|
-
withBorder:
|
|
3593
|
-
}), "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: {
|
|
3594
|
-
name: descriptionIcon
|
|
3725
|
+
withBorder: tabsList === undefined,
|
|
3726
|
+
}), "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: {
|
|
3727
|
+
name: descriptionIcon,
|
|
3595
3728
|
dataTestId: "page-header-description-icon",
|
|
3596
|
-
}, 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 &&
|
|
3729
|
+
}, 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] }));
|
|
3597
3730
|
};
|
|
3598
3731
|
|
|
3599
3732
|
const cvaPagination = cssClassVarianceUtilities.cvaMerge(["flex", "items-center", "gap-1"]);
|
|
@@ -3605,7 +3738,7 @@ const cvaPaginationText = cssClassVarianceUtilities.cvaMerge("whitespace-nowrap"
|
|
|
3605
3738
|
* @param {PaginationProps} props - The props for the Pagination component
|
|
3606
3739
|
* @returns {ReactElement} Pagination component
|
|
3607
3740
|
*/
|
|
3608
|
-
const Pagination = ({ previousPage, nextPage, canPreviousPage, canNextPage, pageCount, pageIndex, loading, className, dataTestId, getTranslatedCount, onPageChange, cursorBase, }) => {
|
|
3741
|
+
const Pagination = ({ previousPage, nextPage, canPreviousPage = false, canNextPage = false, pageCount, pageIndex, loading = false, className, dataTestId, getTranslatedCount, onPageChange, cursorBase = false, }) => {
|
|
3609
3742
|
const [page, setPage] = react.useState(pageIndex);
|
|
3610
3743
|
const [currentPage, setCurrentPage] = react.useState(String(pageIndex !== undefined ? pageIndex + 1 : 1));
|
|
3611
3744
|
if (!loading && pageCount === undefined) {
|
|
@@ -3654,7 +3787,7 @@ const STROKE_WIDTH_THRESHOLD = 32;
|
|
|
3654
3787
|
* @param { PolygonProps} props - The props for the Polygon component
|
|
3655
3788
|
* @returns {ReactElement} Polygon component
|
|
3656
3789
|
*/
|
|
3657
|
-
const Polygon = ({ points, size, color = "black", opaque = true, className, dataTestId }) => {
|
|
3790
|
+
const Polygon = ({ points, size, color = "black", opaque = true, className, dataTestId, }) => {
|
|
3658
3791
|
// Calculate the bounds of the points
|
|
3659
3792
|
const minX = Math.min(...points.map(coord => coord[0]));
|
|
3660
3793
|
const maxX = Math.max(...points.map(coord => coord[0]));
|
|
@@ -3757,7 +3890,7 @@ const Spacer = ({ size = "medium", border = false, dataTestId, className }) => {
|
|
|
3757
3890
|
* @returns {ReactElement} SectionHeader component
|
|
3758
3891
|
*/
|
|
3759
3892
|
const SectionHeader = ({ title, subtitle, dataTestId, addons }) => {
|
|
3760
|
-
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" })] }));
|
|
3893
|
+
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" })] }));
|
|
3761
3894
|
};
|
|
3762
3895
|
|
|
3763
3896
|
const cvaSidebar = cssClassVarianceUtilities.cvaMerge(["apply", "grid", "grid-cols-fr-min", "items-center"]);
|
|
@@ -3791,7 +3924,7 @@ const useOverflowItems = ({ threshold = 1, childUniqueIdentifierAttribute = "id"
|
|
|
3791
3924
|
entries.forEach(entry => {
|
|
3792
3925
|
// @ts-expect-error - suppressImplicitAnyIndexErrors
|
|
3793
3926
|
const targetElementId = entry.target[childUniqueIdentifierAttribute];
|
|
3794
|
-
if (targetElementId) {
|
|
3927
|
+
if (targetElementId !== null && targetElementId !== undefined) {
|
|
3795
3928
|
updatedEntries[targetElementId] = entry.isIntersecting ? false : true;
|
|
3796
3929
|
}
|
|
3797
3930
|
});
|
|
@@ -3847,19 +3980,19 @@ const Sidebar = ({ childContainerClassName, children, breakpoint = "lg", classNa
|
|
|
3847
3980
|
});
|
|
3848
3981
|
const overflowItemCount = sharedUtils.objectValues(itemOverflowMap).filter(isOverflowing => isOverflowing).length;
|
|
3849
3982
|
const itemVisibilityClassName = (id) => {
|
|
3850
|
-
if (itemOverflowMap[id]) {
|
|
3983
|
+
if (itemOverflowMap[id] === true) {
|
|
3851
3984
|
return "invisible";
|
|
3852
3985
|
}
|
|
3853
3986
|
return "visible";
|
|
3854
3987
|
};
|
|
3855
|
-
return (jsxRuntime.jsxs("div", { className: cvaSidebar({ className }), "data-testid": dataTestId, children: [jsxRuntime.jsx("div", { className: cvaSidebarChildContainer({ breakpoint, className: childContainerClassName }), "data-testid":
|
|
3988
|
+
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 => {
|
|
3856
3989
|
return react.cloneElement(child, {
|
|
3857
3990
|
className: tailwindMerge.twMerge(child.props.className, itemVisibilityClassName(child.props.id)),
|
|
3858
3991
|
});
|
|
3859
3992
|
}) }), overflowItemCount > 0 ? (jsxRuntime.jsx(MoreMenu, { iconButtonProps: {
|
|
3860
3993
|
variant: "ghost-neutral",
|
|
3861
|
-
}, ...moreMenuProps, className: moreMenuProps?.className, dataTestId:
|
|
3862
|
-
return itemOverflowMap[child.props.id]
|
|
3994
|
+
}, ...moreMenuProps, className: moreMenuProps?.className, dataTestId: `${dataTestId}-more-menu`, children: close => (jsxRuntime.jsx(MenuList, { ...menuListProps, dataTestId: dataTestId, children: react.Children.map(children, child => {
|
|
3995
|
+
return itemOverflowMap[child.props.id] === true
|
|
3863
3996
|
? react.cloneElement(child, {
|
|
3864
3997
|
onClick: () => {
|
|
3865
3998
|
child.props.onClick?.();
|
|
@@ -3922,8 +4055,8 @@ const cvaTab = cssClassVarianceUtilities.cvaMerge([
|
|
|
3922
4055
|
* Wrapper for radix tab component.
|
|
3923
4056
|
* We add a custom implementation of the asChild prop to make it easy to make the child element look like other tabs.
|
|
3924
4057
|
*/
|
|
3925
|
-
const Tab = ({ value, isFullWidth = false, iconName, dataTestId, className, children, suffix, asChild, appendTabStylesToChildIfAsChild = true, ...rest }) => {
|
|
3926
|
-
const renderContent = () => (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [iconName ? jsxRuntime.jsx(Icon, { name: iconName, size: "small" }) : null, react.isValidElement(children) ? children.props.children : children, suffix] }));
|
|
4058
|
+
const Tab = ({ value, isFullWidth = false, iconName = undefined, dataTestId, className, children, suffix, asChild = false, appendTabStylesToChildIfAsChild = true, ...rest }) => {
|
|
4059
|
+
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] }));
|
|
3927
4060
|
const commonProps = {
|
|
3928
4061
|
className: appendTabStylesToChildIfAsChild ? cvaTab({ className, isFullWidth }) : className,
|
|
3929
4062
|
...rest,
|
|
@@ -4083,8 +4216,8 @@ const ToggleGroup = ({ list, selected, setSelected, onChange, disabled = false,
|
|
|
4083
4216
|
const containerPadding = 2; // p-0.5 = 2px
|
|
4084
4217
|
const gap = 4;
|
|
4085
4218
|
const slidingLeft = containerPadding +
|
|
4086
|
-
buttonRefs.current.slice(0, validIndex).reduce((sum, ref) => sum + (ref?.offsetWidth
|
|
4087
|
-
const slidingWidth = buttonRefs.current[validIndex]?.offsetWidth
|
|
4219
|
+
buttonRefs.current.slice(0, validIndex).reduce((sum, ref) => sum + (ref?.offsetWidth ?? 0) + gap, 0);
|
|
4220
|
+
const slidingWidth = buttonRefs.current[validIndex]?.offsetWidth ?? 0;
|
|
4088
4221
|
react.useEffect(() => {
|
|
4089
4222
|
setIsMounted(true);
|
|
4090
4223
|
}, []);
|
|
@@ -4104,7 +4237,7 @@ const ToggleItem = ({ title, onClick, disabled, isIconOnly, iconName, size, clas
|
|
|
4104
4237
|
className,
|
|
4105
4238
|
selected,
|
|
4106
4239
|
disabled,
|
|
4107
|
-
}), 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 &&
|
|
4240
|
+
}), 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({
|
|
4108
4241
|
className,
|
|
4109
4242
|
selected,
|
|
4110
4243
|
disabled,
|
|
@@ -4170,7 +4303,7 @@ const cvaValueBarText = cssClassVarianceUtilities.cvaMerge(["whitespace-nowrap"]
|
|
|
4170
4303
|
*/
|
|
4171
4304
|
const getScore = (value, min, max, zeroScoreAllowed) => {
|
|
4172
4305
|
if (value <= min) {
|
|
4173
|
-
if (zeroScoreAllowed) {
|
|
4306
|
+
if (zeroScoreAllowed === true) {
|
|
4174
4307
|
return 0;
|
|
4175
4308
|
}
|
|
4176
4309
|
return 0.01; // always render at least some small fragment
|
|
@@ -4203,10 +4336,10 @@ const getDefaultFillColor = (score) => {
|
|
|
4203
4336
|
* @returns {string} color value
|
|
4204
4337
|
*/
|
|
4205
4338
|
const getFillColor = (score, levelColors) => {
|
|
4206
|
-
if (levelColors.low && score < (levelColors.low.level
|
|
4339
|
+
if (levelColors.low !== undefined && score < (levelColors.low.level !== undefined ? levelColors.low.level : 0)) {
|
|
4207
4340
|
return levelColors.low.color;
|
|
4208
4341
|
}
|
|
4209
|
-
if (levelColors.high && score >= (levelColors.high.level
|
|
4342
|
+
if (levelColors.high !== undefined && score >= (levelColors.high.level !== undefined ? levelColors.high.level : 0)) {
|
|
4210
4343
|
return levelColors.high.color;
|
|
4211
4344
|
}
|
|
4212
4345
|
return levelColors.medium?.color ?? uiDesignTokens.color("WARNING", 300);
|
|
@@ -4231,94 +4364,13 @@ const getValueBarColorByValue = (value, min, max, levelColors) => {
|
|
|
4231
4364
|
* @param {ValueBarProps} props - The props for the ValueBar component
|
|
4232
4365
|
* @returns {ReactElement} ValueBar component
|
|
4233
4366
|
*/
|
|
4234
|
-
const ValueBar = ({ value, min = 0, max = 100, unit, size = "small", levelColors, valueColor, showValue, className, dataTestId, zeroScoreAllowed, }) => {
|
|
4367
|
+
const ValueBar = ({ value, min = 0, max = 100, unit, size = "small", levelColors, valueColor, showValue = false, className, dataTestId, zeroScoreAllowed = false, }) => {
|
|
4235
4368
|
const score = getScore(value, min, max, zeroScoreAllowed);
|
|
4236
4369
|
const barFillColor = levelColors ? getFillColor(score, levelColors) : getDefaultFillColor(score);
|
|
4237
4370
|
const valueText = `${Number(value.toFixed(1))}${sharedUtils.nonNullable(unit) ? unit : ""}`;
|
|
4238
4371
|
return (jsxRuntime.jsxs("span", { className: "relative flex items-center gap-2", "data-testid": dataTestId, children: [jsxRuntime.jsx("progress", { "aria-label": valueText, className: cvaValueBar({ className, size }), max: 100, style: { color: barFillColor }, value: score * 100 }), showValue && (size === "small" || size === "large") ? (jsxRuntime.jsx(Text, { className: cvaValueBarText({ size }), dataTestId: dataTestId ? `${dataTestId}-value` : undefined, children: jsxRuntime.jsx("span", { style: valueColor ? { color: valueColor } : undefined, children: valueText }) })) : null] }));
|
|
4239
4372
|
};
|
|
4240
4373
|
|
|
4241
|
-
const cvaVirtualizedListContainer = cssClassVarianceUtilities.cvaMerge(["h-full"], {
|
|
4242
|
-
variants: {
|
|
4243
|
-
parentControlledScrollable: {
|
|
4244
|
-
true: [""],
|
|
4245
|
-
false: ["overflow-auto"],
|
|
4246
|
-
},
|
|
4247
|
-
},
|
|
4248
|
-
defaultVariants: {
|
|
4249
|
-
parentControlledScrollable: false,
|
|
4250
|
-
},
|
|
4251
|
-
});
|
|
4252
|
-
const cvaVirtualizedList = cssClassVarianceUtilities.cvaMerge(["relative"]);
|
|
4253
|
-
const cvaVirtualizedListItem = cssClassVarianceUtilities.cvaMerge(["absolute", "top-0", "left-0", "w-full"], {
|
|
4254
|
-
variants: {
|
|
4255
|
-
separator: {
|
|
4256
|
-
alternating: ["even:bg-slate-100"],
|
|
4257
|
-
line: ["[&:not(:last-child)]:border-b", "border-gray-200"],
|
|
4258
|
-
none: "",
|
|
4259
|
-
space: "[&:not(:last-child)]:pb-0.5",
|
|
4260
|
-
},
|
|
4261
|
-
},
|
|
4262
|
-
defaultVariants: {
|
|
4263
|
-
separator: "none",
|
|
4264
|
-
},
|
|
4265
|
-
});
|
|
4266
|
-
|
|
4267
|
-
/**
|
|
4268
|
-
* Render a performant virtualized list of items. Optionally with infinite scrolling.
|
|
4269
|
-
*
|
|
4270
|
-
* @property {number} count - The total number of items in the list.
|
|
4271
|
-
* @property {number} [rowHeight="40"] - The estimated height of each row in the list.
|
|
4272
|
-
* @property {RelayPagination | undefined} pagination - Pagination configuration for the list.
|
|
4273
|
-
* @property {separator} [separator="line"] - The separator style between items in the list.
|
|
4274
|
-
* @property {(index: number) =>ReactElement} children - A function that takes an index and returns the JSX element to be rendered at said index.
|
|
4275
|
-
* @property {loadingIndicator} [loadingIndicator="spinner"] - The type of loading indicator in the list.
|
|
4276
|
-
* @property {skeletonLinesHeight} [skeletonLinesHeight="2rem"] - The height of the skeleton lines.
|
|
4277
|
-
*/
|
|
4278
|
-
const VirtualizedList = ({ count, rowHeight = 40, pagination, children, className, dataTestId, separator = "none", loadingIndicator = "spinner", skeletonLinesHeight = rowHeight + "px", onRowClick, scrollRef, }) => {
|
|
4279
|
-
const containerRef = react.useRef(null);
|
|
4280
|
-
const listRef = react.useRef(null);
|
|
4281
|
-
const [scrollParent, setScrollParent] = react.useState(null);
|
|
4282
|
-
const [parentControlledScrollable, setParentControlledScrollable] = react.useState(false);
|
|
4283
|
-
react.useEffect(() => {
|
|
4284
|
-
if (scrollRef?.current) {
|
|
4285
|
-
setParentControlledScrollable(true);
|
|
4286
|
-
setScrollParent(scrollRef.current);
|
|
4287
|
-
}
|
|
4288
|
-
else {
|
|
4289
|
-
setParentControlledScrollable(false);
|
|
4290
|
-
setScrollParent(containerRef.current);
|
|
4291
|
-
}
|
|
4292
|
-
}, [scrollRef]);
|
|
4293
|
-
const infiniteScrollProps = react.useMemo(() => {
|
|
4294
|
-
return {
|
|
4295
|
-
pagination: pagination || reactTablePagination.noPagination,
|
|
4296
|
-
containerRef: { current: scrollParent },
|
|
4297
|
-
rowSize: pagination?.pageInfo?.hasNextPage && pagination.isLoading ? count + 1 : count,
|
|
4298
|
-
rowHeight,
|
|
4299
|
-
};
|
|
4300
|
-
}, [pagination, scrollParent, count, rowHeight]);
|
|
4301
|
-
const { fetchMoreOnBottomReached, getVirtualItems, getTotalSize, measureElement } = reactTablePagination.useInfiniteScroll(infiniteScrollProps);
|
|
4302
|
-
react.useEffect(() => {
|
|
4303
|
-
if (scrollParent) {
|
|
4304
|
-
const handleScroll = () => {
|
|
4305
|
-
fetchMoreOnBottomReached(scrollParent);
|
|
4306
|
-
};
|
|
4307
|
-
scrollParent.addEventListener("scroll", handleScroll);
|
|
4308
|
-
return () => {
|
|
4309
|
-
scrollParent.removeEventListener("scroll", handleScroll);
|
|
4310
|
-
};
|
|
4311
|
-
}
|
|
4312
|
-
return undefined;
|
|
4313
|
-
}, [scrollParent, fetchMoreOnBottomReached]);
|
|
4314
|
-
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 => {
|
|
4315
|
-
const isLoaderRow = virtualRow.index > count - 1;
|
|
4316
|
-
return (jsxRuntime.jsx("li", { className: cvaVirtualizedListItem({ separator }), "data-index": virtualRow.index, onClick: onRowClick ? () => onRowClick(virtualRow.index) : undefined, ref: measureElement, style: {
|
|
4317
|
-
transform: `translateY(${virtualRow.start}px)`,
|
|
4318
|
-
}, 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));
|
|
4319
|
-
}) }) }));
|
|
4320
|
-
};
|
|
4321
|
-
|
|
4322
4374
|
const cvaZStackContainer = cssClassVarianceUtilities.cvaMerge(["grid", "grid-cols-1", "grid-rows-1"]);
|
|
4323
4375
|
const cvaZStackItem = cssClassVarianceUtilities.cvaMerge(["col-start-1", "col-end-1", "row-start-1", "row-end-2"]);
|
|
4324
4376
|
|
|
@@ -4389,6 +4441,7 @@ exports.IconButton = IconButton;
|
|
|
4389
4441
|
exports.Indicator = Indicator;
|
|
4390
4442
|
exports.KPI = KPI;
|
|
4391
4443
|
exports.KPICard = KPICard;
|
|
4444
|
+
exports.List = List;
|
|
4392
4445
|
exports.ListItem = ListItem;
|
|
4393
4446
|
exports.MenuDivider = MenuDivider;
|
|
4394
4447
|
exports.MenuItem = MenuItem;
|
|
@@ -4426,7 +4479,6 @@ exports.Text = Text;
|
|
|
4426
4479
|
exports.ToggleGroup = ToggleGroup;
|
|
4427
4480
|
exports.Tooltip = Tooltip;
|
|
4428
4481
|
exports.ValueBar = ValueBar;
|
|
4429
|
-
exports.VirtualizedList = VirtualizedList;
|
|
4430
4482
|
exports.ZStack = ZStack;
|
|
4431
4483
|
exports.cvaButton = cvaButton;
|
|
4432
4484
|
exports.cvaButtonPrefixSuffix = cvaButtonPrefixSuffix;
|
|
@@ -4442,6 +4494,9 @@ exports.cvaIndicatorIconBackground = cvaIndicatorIconBackground;
|
|
|
4442
4494
|
exports.cvaIndicatorLabel = cvaIndicatorLabel;
|
|
4443
4495
|
exports.cvaIndicatorPing = cvaIndicatorPing;
|
|
4444
4496
|
exports.cvaInteractableItem = cvaInteractableItem;
|
|
4497
|
+
exports.cvaList = cvaList;
|
|
4498
|
+
exports.cvaListContainer = cvaListContainer;
|
|
4499
|
+
exports.cvaListItem = cvaListItem$1;
|
|
4445
4500
|
exports.cvaMenuItem = cvaMenuItem;
|
|
4446
4501
|
exports.cvaMenuItemLabel = cvaMenuItemLabel;
|
|
4447
4502
|
exports.cvaMenuItemPrefix = cvaMenuItemPrefix;
|
|
@@ -4455,9 +4510,6 @@ exports.cvaToggleGroupWithSlidingBackground = cvaToggleGroupWithSlidingBackgroun
|
|
|
4455
4510
|
exports.cvaToggleItem = cvaToggleItem;
|
|
4456
4511
|
exports.cvaToggleItemContent = cvaToggleItemContent;
|
|
4457
4512
|
exports.cvaToggleItemText = cvaToggleItemText;
|
|
4458
|
-
exports.cvaVirtualizedList = cvaVirtualizedList;
|
|
4459
|
-
exports.cvaVirtualizedListContainer = cvaVirtualizedListContainer;
|
|
4460
|
-
exports.cvaVirtualizedListItem = cvaVirtualizedListItem;
|
|
4461
4513
|
exports.cvaZStackContainer = cvaZStackContainer;
|
|
4462
4514
|
exports.cvaZStackItem = cvaZStackItem;
|
|
4463
4515
|
exports.docs = docs;
|