@trackunit/react-components 1.17.4 → 1.17.6
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 +19 -14
- package/index.esm.js +19 -14
- package/package.json +5 -5
- package/src/components/Tooltip/Tooltip.d.ts +12 -3
package/index.cjs.js
CHANGED
|
@@ -4086,7 +4086,7 @@ const FloatingArrowContainer = ({ arrowRef, mode = "dark", }) => {
|
|
|
4086
4086
|
* import { Tooltip, IconButton, Icon } from "@trackunit/react-components";
|
|
4087
4087
|
*
|
|
4088
4088
|
* const SettingsButton = () => (
|
|
4089
|
-
* <Tooltip label="Open settings" placement="bottom">
|
|
4089
|
+
* <Tooltip asChild={false} label="Open settings" placement="bottom">
|
|
4090
4090
|
* <IconButton
|
|
4091
4091
|
* icon={<Icon name="Cog6Tooth" size="small" />}
|
|
4092
4092
|
* variant="ghost-neutral"
|
|
@@ -4102,7 +4102,7 @@ const FloatingArrowContainer = ({ arrowRef, mode = "dark", }) => {
|
|
|
4102
4102
|
* const FieldWithHelp = () => (
|
|
4103
4103
|
* <div className="flex items-center gap-2">
|
|
4104
4104
|
* <span>Utilization Rate</span>
|
|
4105
|
-
* <Tooltip
|
|
4105
|
+
* <Tooltip asChild={false}
|
|
4106
4106
|
* label="The percentage of time the asset was actively in use during the selected period"
|
|
4107
4107
|
* placement="right"
|
|
4108
4108
|
* mode="light"
|
|
@@ -4113,7 +4113,7 @@ const FloatingArrowContainer = ({ arrowRef, mode = "dark", }) => {
|
|
|
4113
4113
|
* @param {TooltipProps} props - The props for the Tooltip component
|
|
4114
4114
|
* @returns {ReactElement} Tooltip component
|
|
4115
4115
|
*/
|
|
4116
|
-
const Tooltip = ({ children, "data-testid": dataTestId, disabled = false, className, label, placement = "auto", mode = "dark", iconProps, id, style, }) => {
|
|
4116
|
+
const Tooltip = ({ children, "data-testid": dataTestId, disabled = false, className, label, placement = "auto", mode = "dark", iconProps, id, style, asChild = true, }) => {
|
|
4117
4117
|
const [isOpen, setIsOpen] = react.useState(false);
|
|
4118
4118
|
const arrowRef = react.useRef(null);
|
|
4119
4119
|
const { refs, floatingStyles, context } = react$1.useFloating({
|
|
@@ -4133,7 +4133,12 @@ const Tooltip = ({ children, "data-testid": dataTestId, disabled = false, classN
|
|
|
4133
4133
|
const { isMounted } = react$1.useTransitionStatus(context);
|
|
4134
4134
|
// Please don't try to move this into the component body directly
|
|
4135
4135
|
// I tried and it caused infinite re-renders some places (for whatever reason)
|
|
4136
|
-
const wrappedChildren = react.useMemo(() =>
|
|
4136
|
+
const wrappedChildren = react.useMemo(() => {
|
|
4137
|
+
if (asChild) {
|
|
4138
|
+
return (jsxRuntime.jsx(reactSlot.Slot, { className: className, "data-testid": dataTestId ? `${dataTestId}-child` : undefined, children: children }));
|
|
4139
|
+
}
|
|
4140
|
+
return (jsxRuntime.jsx("div", { className: cvaTooltipContainer({ className }), "data-testid": dataTestId ? `${dataTestId}-parent` : undefined, children: children }));
|
|
4141
|
+
}, [asChild, children, className, dataTestId]);
|
|
4137
4142
|
const openTooltip = react.useCallback(() => {
|
|
4138
4143
|
if (disabled) {
|
|
4139
4144
|
return;
|
|
@@ -4305,7 +4310,7 @@ const cvaIndicatorIconBackground = cssClassVarianceUtilities.cvaMerge(["rounded-
|
|
|
4305
4310
|
* @returns {ReactElement} Indicator component
|
|
4306
4311
|
*/
|
|
4307
4312
|
const Indicator = ({ "data-testid": dataTestId, icon, label, color = "unknown", withBackground = true, withLabel = true, ping = false, size = "medium", weight = "normal", className, ...rest }) => {
|
|
4308
|
-
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] }) }));
|
|
4313
|
+
return (jsxRuntime.jsx(Tooltip, { asChild: false, 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] }) }));
|
|
4309
4314
|
};
|
|
4310
4315
|
|
|
4311
4316
|
/**
|
|
@@ -4439,7 +4444,7 @@ const cvaKPITrendPercentage = cssClassVarianceUtilities.cvaMerge([""], {
|
|
|
4439
4444
|
*/
|
|
4440
4445
|
const KPI = ({ title, value, unit, className, "data-testid": dataTestId, tooltipLabel, variant = "default", style, ...rest }) => {
|
|
4441
4446
|
const isSmallVariant = variant === "small";
|
|
4442
|
-
return (jsxRuntime.jsx(Tooltip, { className: "min-w-8 shrink-0", "data-testid": dataTestId ? `${dataTestId}-tooltip` : undefined, disabled: tooltipLabel === undefined || tooltipLabel === "", label: tooltipLabel, placement: "bottom", children: jsxRuntime.jsxs("div", { className: cvaKPI({ variant, className }), "data-testid": dataTestId, style: style, ...rest, children: [jsxRuntime.jsx(Text, { className: tailwindMerge.twMerge("truncate", "whitespace-nowrap"), "data-testid": dataTestId ? `${dataTestId}-title` : undefined, size: isSmallVariant ? "small" : "medium", subtle: true, weight: isSmallVariant ? "normal" : "bold", children: title }), jsxRuntime.jsx("div", { className: tailwindMerge.twMerge("truncate", "whitespace-nowrap"), children: jsxRuntime.jsxs(Text, { className: "truncate whitespace-nowrap text-lg font-medium", "data-testid": dataTestId ? `${dataTestId}-value` : undefined, size: isSmallVariant ? "small" : "large", type: "div", weight: isSmallVariant ? "bold" : "thick", children: [value, " ", unit] }) })] }) }));
|
|
4447
|
+
return (jsxRuntime.jsx(Tooltip, { asChild: false, className: "min-w-8 shrink-0", "data-testid": dataTestId ? `${dataTestId}-tooltip` : undefined, disabled: tooltipLabel === undefined || tooltipLabel === "", label: tooltipLabel, placement: "bottom", children: jsxRuntime.jsxs("div", { className: cvaKPI({ variant, className }), "data-testid": dataTestId, style: style, ...rest, children: [jsxRuntime.jsx(Text, { className: tailwindMerge.twMerge("truncate", "whitespace-nowrap"), "data-testid": dataTestId ? `${dataTestId}-title` : undefined, size: isSmallVariant ? "small" : "medium", subtle: true, weight: isSmallVariant ? "normal" : "bold", children: title }), jsxRuntime.jsx("div", { className: tailwindMerge.twMerge("truncate", "whitespace-nowrap"), children: jsxRuntime.jsxs(Text, { className: "truncate whitespace-nowrap text-lg font-medium", "data-testid": dataTestId ? `${dataTestId}-value` : undefined, size: isSmallVariant ? "small" : "large", type: "div", weight: isSmallVariant ? "bold" : "thick", children: [value, " ", unit] }) })] }) }));
|
|
4443
4448
|
};
|
|
4444
4449
|
|
|
4445
4450
|
/**
|
|
@@ -5701,7 +5706,7 @@ const cvaNoticeIcon = cssClassVarianceUtilities.cvaMerge(["rounded-full", "items
|
|
|
5701
5706
|
* @returns {ReactElement} Notice component
|
|
5702
5707
|
*/
|
|
5703
5708
|
const Notice = ({ "data-testid": dataTestId, iconName = undefined, iconSize = "medium", iconColor = undefined, label, color = "neutral", withLabel = true, className, tooltipLabel = label, withTooltip = false, size = "medium", ...rest }) => {
|
|
5704
|
-
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: [sharedUtils.nonNullable(iconName) ? (jsxRuntime.jsx("div", { className: cvaNoticeIcon({ color: iconColor || color }), "data-testid": dataTestId ? `${dataTestId}-icon` : "notice-icon", children: jsxRuntime.jsx(Icon, { name: iconName, size: iconSize }) })) : null, label && withLabel ? (jsxRuntime.jsx("div", { className: cvaNoticeLabel({ color, size }), "data-testid": dataTestId ? `${dataTestId}-label` : "notice-label", children: label })) : null] }) }));
|
|
5709
|
+
return (jsxRuntime.jsx(Tooltip, { asChild: false, className: className, disabled: withTooltip === false, label: tooltipLabel, placement: "bottom", children: jsxRuntime.jsxs("div", { "aria-label": label, className: cvaNotice(), "data-testid": dataTestId, ...rest, children: [sharedUtils.nonNullable(iconName) ? (jsxRuntime.jsx("div", { className: cvaNoticeIcon({ color: iconColor || color }), "data-testid": dataTestId ? `${dataTestId}-icon` : "notice-icon", children: jsxRuntime.jsx(Icon, { name: iconName, size: iconSize }) })) : null, label && withLabel ? (jsxRuntime.jsx("div", { className: cvaNoticeLabel({ color, size }), "data-testid": dataTestId ? `${dataTestId}-label` : "notice-label", children: label })) : null] }) }));
|
|
5705
5710
|
};
|
|
5706
5711
|
|
|
5707
5712
|
const cvaPage = cssClassVarianceUtilities.cvaMerge(["grid", "h-full"], {
|
|
@@ -5918,7 +5923,7 @@ function ActionRenderer({ action, isMenuItem = false, externalOnClick }) {
|
|
|
5918
5923
|
externalOnClick?.();
|
|
5919
5924
|
}, prefix: prefixIconName ? jsxRuntime.jsx(Icon, { name: prefixIconName, size: "small" }) : undefined, size: "small", variant: variant, children: actionText }));
|
|
5920
5925
|
// Wrap `content` with Tooltip
|
|
5921
|
-
const wrappedWithTooltip = tooltipLabel ? (jsxRuntime.jsx(Tooltip, { className: "block", label: tooltipLabel, children: content })) : (content);
|
|
5926
|
+
const wrappedWithTooltip = tooltipLabel ? (jsxRuntime.jsx(Tooltip, { asChild: false, className: "block", label: tooltipLabel, children: content })) : (content);
|
|
5922
5927
|
// Finally, wrap with Link if `to` is provided
|
|
5923
5928
|
return to !== undefined && to !== "" ? (jsxRuntime.jsx(reactRouter.Link, { target: target, to: to, children: wrappedWithTooltip })) : (wrappedWithTooltip);
|
|
5924
5929
|
}
|
|
@@ -6036,7 +6041,7 @@ const cvaPageHeaderHeading = cssClassVarianceUtilities.cvaMerge(["text-neutral-9
|
|
|
6036
6041
|
*/
|
|
6037
6042
|
const PageHeaderTitle = ({ title, "data-testid": dataTestId, className, }) => {
|
|
6038
6043
|
const { ref, isTextTruncated } = useIsTextTruncated();
|
|
6039
|
-
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({ className }), "data-testid": dataTestId ? `${dataTestId}-heading` : undefined, ref: ref, children: title }) }) }));
|
|
6044
|
+
return (jsxRuntime.jsx("div", { className: "flex flex-row items-center", children: jsxRuntime.jsx(Tooltip, { asChild: false, className: "grid min-w-16", disabled: !isTextTruncated, label: title, placement: "top", children: jsxRuntime.jsx("h1", { className: cvaPageHeaderHeading({ className }), "data-testid": dataTestId ? `${dataTestId}-heading` : undefined, ref: ref, children: title }) }) }));
|
|
6040
6045
|
};
|
|
6041
6046
|
|
|
6042
6047
|
/**
|
|
@@ -6094,18 +6099,18 @@ const PageHeader = ({ className, "data-testid": dataTestId, showLoading = false,
|
|
|
6094
6099
|
return null;
|
|
6095
6100
|
}
|
|
6096
6101
|
// If the user passes a string, we render the string as a tag with props provided.
|
|
6097
|
-
return (jsxRuntime.jsx("div", { className: "ml-auto flex flex-row gap-2", children: jsxRuntime.jsx(Tooltip, { "data-testid": "page-header-tag-tooltip", disabled: tagTooltipLabel === undefined || tagTooltipLabel === "", label: tagTooltipLabel, placement: "top", children: jsxRuntime.jsx(Tag, { color: tagColor, "data-testid": "page-header-tag", children: tagLabel }) }) }));
|
|
6102
|
+
return (jsxRuntime.jsx("div", { className: "ml-auto flex flex-row gap-2", children: jsxRuntime.jsx(Tooltip, { asChild: false, "data-testid": "page-header-tag-tooltip", disabled: tagTooltipLabel === undefined || tagTooltipLabel === "", label: tagTooltipLabel, placement: "top", children: jsxRuntime.jsx(Tag, { color: tagColor, "data-testid": "page-header-tag", children: tagLabel }) }) }));
|
|
6098
6103
|
}, [showLoading, tagColor, tagLabel, tagTooltipLabel]);
|
|
6099
6104
|
return (jsxRuntime.jsxs("div", { className: cvaPageHeaderContainer({
|
|
6100
6105
|
className,
|
|
6101
6106
|
withBorder: tabsList === undefined,
|
|
6102
|
-
}), "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: "small", square: true, variant: "ghost-neutral" }) })) : undefined, typeof title === "string" ? jsxRuntime.jsx(PageHeaderTitle, { "data-testid": 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, { "data-testid": dataTestId ? `${dataTestId}-description-tooltip` : undefined, iconProps: {
|
|
6107
|
+
}), "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: "small", square: true, variant: "ghost-neutral" }) })) : undefined, typeof title === "string" ? jsxRuntime.jsx(PageHeaderTitle, { "data-testid": 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, { asChild: false, "data-testid": dataTestId ? `${dataTestId}-description-tooltip` : undefined, iconProps: {
|
|
6103
6108
|
name: descriptionIcon,
|
|
6104
6109
|
"data-testid": "page-header-description-icon",
|
|
6105
6110
|
}, label: description, placement: "bottom" })) : undefined, tagRenderer] })) : null, jsxRuntime.jsxs("div", { className: "ml-auto flex gap-2", children: [discriminatedProps.accessoryType === "kpi-metrics" ? (jsxRuntime.jsx(PageHeaderKpiMetrics, { kpiMetrics: discriminatedProps.kpiMetrics })) : null, discriminatedProps.accessoryType === "actions" ? (Array.isArray(discriminatedProps.secondaryActions) ? (jsxRuntime.jsx(PageHeaderSecondaryActions, { actions: discriminatedProps.secondaryActions, groupActions: discriminatedProps.groupSecondaryActions ?? false, hasPrimaryAction: !!discriminatedProps.primaryAction })) : discriminatedProps.secondaryActions !== null && discriminatedProps.secondaryActions !== undefined ? (discriminatedProps.secondaryActions) : null) : null, discriminatedProps.accessoryType === "actions" &&
|
|
6106
6111
|
discriminatedProps.primaryAction !== undefined &&
|
|
6107
6112
|
(discriminatedProps.primaryAction.hidden === false ||
|
|
6108
|
-
discriminatedProps.primaryAction.hidden === undefined) ? (jsxRuntime.jsx(Tooltip, { disabled: discriminatedProps.primaryAction.tooltipLabel === undefined ||
|
|
6113
|
+
discriminatedProps.primaryAction.hidden === undefined) ? (jsxRuntime.jsx(Tooltip, { asChild: false, disabled: discriminatedProps.primaryAction.tooltipLabel === undefined ||
|
|
6109
6114
|
discriminatedProps.primaryAction.tooltipLabel === "", label: discriminatedProps.primaryAction.tooltipLabel, children: jsxRuntime.jsx(Button, { "data-testid": discriminatedProps.primaryAction["data-testid"], disabled: discriminatedProps.primaryAction.disabled, loading: discriminatedProps.primaryAction.loading, onClick: () => discriminatedProps.primaryAction?.actionCallback?.(), prefix: discriminatedProps.primaryAction.prefixIconName !== undefined ? (jsxRuntime.jsx(Icon, { name: discriminatedProps.primaryAction.prefixIconName, size: "small" })) : undefined, size: "small", variant: discriminatedProps.primaryAction.variant, children: discriminatedProps.primaryAction.actionText }) })) : null] })] }), tabsList] }));
|
|
6110
6115
|
};
|
|
6111
6116
|
|
|
@@ -6953,11 +6958,11 @@ const ToggleGroup = ({ list, selected, setSelected, onChange, disabled = false,
|
|
|
6953
6958
|
}, ref: el => (buttonRefs.current[index] = el), selected: selected === item.id, size: size, text: item.text, title: item.title, tooltip: item.tooltip }, item.id))) }));
|
|
6954
6959
|
};
|
|
6955
6960
|
const ToggleItem = ({ title, onClick, disabled, isIconOnly, iconName = undefined, size, className, selected, text, tooltip, "data-testid": dataTestId, ref, }) => {
|
|
6956
|
-
return isIconOnly ? (jsxRuntime.jsx(Tooltip, { label: tooltip?.content || title, placement: tooltip?.placement || "top", children: jsxRuntime.jsx(ToggleButton, { className: cvaToggleItem({
|
|
6961
|
+
return isIconOnly ? (jsxRuntime.jsx(Tooltip, { asChild: false, label: tooltip?.content || title, placement: tooltip?.placement || "top", children: jsxRuntime.jsx(ToggleButton, { className: cvaToggleItem({
|
|
6957
6962
|
className,
|
|
6958
6963
|
selected,
|
|
6959
6964
|
disabled,
|
|
6960
|
-
}), "data-testid": 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({
|
|
6965
|
+
}), "data-testid": 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, { asChild: false, disabled: !tooltip?.content && text?.truncate === false, label: tooltip?.content || title, placement: tooltip?.placement || "top", children: jsxRuntime.jsx(ToggleButton, { className: cvaToggleItem({
|
|
6961
6966
|
className,
|
|
6962
6967
|
selected,
|
|
6963
6968
|
disabled,
|
package/index.esm.js
CHANGED
|
@@ -4084,7 +4084,7 @@ const FloatingArrowContainer = ({ arrowRef, mode = "dark", }) => {
|
|
|
4084
4084
|
* import { Tooltip, IconButton, Icon } from "@trackunit/react-components";
|
|
4085
4085
|
*
|
|
4086
4086
|
* const SettingsButton = () => (
|
|
4087
|
-
* <Tooltip label="Open settings" placement="bottom">
|
|
4087
|
+
* <Tooltip asChild={false} label="Open settings" placement="bottom">
|
|
4088
4088
|
* <IconButton
|
|
4089
4089
|
* icon={<Icon name="Cog6Tooth" size="small" />}
|
|
4090
4090
|
* variant="ghost-neutral"
|
|
@@ -4100,7 +4100,7 @@ const FloatingArrowContainer = ({ arrowRef, mode = "dark", }) => {
|
|
|
4100
4100
|
* const FieldWithHelp = () => (
|
|
4101
4101
|
* <div className="flex items-center gap-2">
|
|
4102
4102
|
* <span>Utilization Rate</span>
|
|
4103
|
-
* <Tooltip
|
|
4103
|
+
* <Tooltip asChild={false}
|
|
4104
4104
|
* label="The percentage of time the asset was actively in use during the selected period"
|
|
4105
4105
|
* placement="right"
|
|
4106
4106
|
* mode="light"
|
|
@@ -4111,7 +4111,7 @@ const FloatingArrowContainer = ({ arrowRef, mode = "dark", }) => {
|
|
|
4111
4111
|
* @param {TooltipProps} props - The props for the Tooltip component
|
|
4112
4112
|
* @returns {ReactElement} Tooltip component
|
|
4113
4113
|
*/
|
|
4114
|
-
const Tooltip = ({ children, "data-testid": dataTestId, disabled = false, className, label, placement = "auto", mode = "dark", iconProps, id, style, }) => {
|
|
4114
|
+
const Tooltip = ({ children, "data-testid": dataTestId, disabled = false, className, label, placement = "auto", mode = "dark", iconProps, id, style, asChild = true, }) => {
|
|
4115
4115
|
const [isOpen, setIsOpen] = useState(false);
|
|
4116
4116
|
const arrowRef = useRef(null);
|
|
4117
4117
|
const { refs, floatingStyles, context } = useFloating({
|
|
@@ -4131,7 +4131,12 @@ const Tooltip = ({ children, "data-testid": dataTestId, disabled = false, classN
|
|
|
4131
4131
|
const { isMounted } = useTransitionStatus(context);
|
|
4132
4132
|
// Please don't try to move this into the component body directly
|
|
4133
4133
|
// I tried and it caused infinite re-renders some places (for whatever reason)
|
|
4134
|
-
const wrappedChildren = useMemo(() =>
|
|
4134
|
+
const wrappedChildren = useMemo(() => {
|
|
4135
|
+
if (asChild) {
|
|
4136
|
+
return (jsx(Slot, { className: className, "data-testid": dataTestId ? `${dataTestId}-child` : undefined, children: children }));
|
|
4137
|
+
}
|
|
4138
|
+
return (jsx("div", { className: cvaTooltipContainer({ className }), "data-testid": dataTestId ? `${dataTestId}-parent` : undefined, children: children }));
|
|
4139
|
+
}, [asChild, children, className, dataTestId]);
|
|
4135
4140
|
const openTooltip = useCallback(() => {
|
|
4136
4141
|
if (disabled) {
|
|
4137
4142
|
return;
|
|
@@ -4303,7 +4308,7 @@ const cvaIndicatorIconBackground = cvaMerge(["rounded-full", "items-center", "ju
|
|
|
4303
4308
|
* @returns {ReactElement} Indicator component
|
|
4304
4309
|
*/
|
|
4305
4310
|
const Indicator = ({ "data-testid": dataTestId, icon, label, color = "unknown", withBackground = true, withLabel = true, ping = false, size = "medium", weight = "normal", className, ...rest }) => {
|
|
4306
|
-
return (jsx(Tooltip, { className: className, disabled: withLabel, label: label, placement: "bottom", children: jsxs("div", { "aria-label": label, className: cvaIndicator(), "data-testid": dataTestId, ...rest, children: [jsxs("div", { className: cvaIndicatorIconBackground({ color, background: withBackground ? "visible" : "hidden" }), "data-testid": dataTestId ? `${dataTestId}-background` : "indicator-background", children: [ping ? (jsx("div", { className: cvaIndicatorPing({ color }), "data-testid": dataTestId ? `${dataTestId}-ping` : "indicator-ping" })) : null, icon] }), label && withLabel ? (jsx("div", { className: cvaIndicatorLabel({ size, weight, background: withBackground ? "visible" : "hidden" }), "data-testid": dataTestId ? `${dataTestId}-label` : undefined, children: label })) : null] }) }));
|
|
4311
|
+
return (jsx(Tooltip, { asChild: false, className: className, disabled: withLabel, label: label, placement: "bottom", children: jsxs("div", { "aria-label": label, className: cvaIndicator(), "data-testid": dataTestId, ...rest, children: [jsxs("div", { className: cvaIndicatorIconBackground({ color, background: withBackground ? "visible" : "hidden" }), "data-testid": dataTestId ? `${dataTestId}-background` : "indicator-background", children: [ping ? (jsx("div", { className: cvaIndicatorPing({ color }), "data-testid": dataTestId ? `${dataTestId}-ping` : "indicator-ping" })) : null, icon] }), label && withLabel ? (jsx("div", { className: cvaIndicatorLabel({ size, weight, background: withBackground ? "visible" : "hidden" }), "data-testid": dataTestId ? `${dataTestId}-label` : undefined, children: label })) : null] }) }));
|
|
4307
4312
|
};
|
|
4308
4313
|
|
|
4309
4314
|
/**
|
|
@@ -4437,7 +4442,7 @@ const cvaKPITrendPercentage = cvaMerge([""], {
|
|
|
4437
4442
|
*/
|
|
4438
4443
|
const KPI = ({ title, value, unit, className, "data-testid": dataTestId, tooltipLabel, variant = "default", style, ...rest }) => {
|
|
4439
4444
|
const isSmallVariant = variant === "small";
|
|
4440
|
-
return (jsx(Tooltip, { className: "min-w-8 shrink-0", "data-testid": dataTestId ? `${dataTestId}-tooltip` : undefined, disabled: tooltipLabel === undefined || tooltipLabel === "", label: tooltipLabel, placement: "bottom", children: jsxs("div", { className: cvaKPI({ variant, className }), "data-testid": dataTestId, style: style, ...rest, children: [jsx(Text, { className: twMerge("truncate", "whitespace-nowrap"), "data-testid": dataTestId ? `${dataTestId}-title` : undefined, size: isSmallVariant ? "small" : "medium", subtle: true, weight: isSmallVariant ? "normal" : "bold", children: title }), jsx("div", { className: twMerge("truncate", "whitespace-nowrap"), children: jsxs(Text, { className: "truncate whitespace-nowrap text-lg font-medium", "data-testid": dataTestId ? `${dataTestId}-value` : undefined, size: isSmallVariant ? "small" : "large", type: "div", weight: isSmallVariant ? "bold" : "thick", children: [value, " ", unit] }) })] }) }));
|
|
4445
|
+
return (jsx(Tooltip, { asChild: false, className: "min-w-8 shrink-0", "data-testid": dataTestId ? `${dataTestId}-tooltip` : undefined, disabled: tooltipLabel === undefined || tooltipLabel === "", label: tooltipLabel, placement: "bottom", children: jsxs("div", { className: cvaKPI({ variant, className }), "data-testid": dataTestId, style: style, ...rest, children: [jsx(Text, { className: twMerge("truncate", "whitespace-nowrap"), "data-testid": dataTestId ? `${dataTestId}-title` : undefined, size: isSmallVariant ? "small" : "medium", subtle: true, weight: isSmallVariant ? "normal" : "bold", children: title }), jsx("div", { className: twMerge("truncate", "whitespace-nowrap"), children: jsxs(Text, { className: "truncate whitespace-nowrap text-lg font-medium", "data-testid": dataTestId ? `${dataTestId}-value` : undefined, size: isSmallVariant ? "small" : "large", type: "div", weight: isSmallVariant ? "bold" : "thick", children: [value, " ", unit] }) })] }) }));
|
|
4441
4446
|
};
|
|
4442
4447
|
|
|
4443
4448
|
/**
|
|
@@ -5699,7 +5704,7 @@ const cvaNoticeIcon = cvaMerge(["rounded-full", "items-center", "justify-center"
|
|
|
5699
5704
|
* @returns {ReactElement} Notice component
|
|
5700
5705
|
*/
|
|
5701
5706
|
const Notice = ({ "data-testid": dataTestId, iconName = undefined, iconSize = "medium", iconColor = undefined, label, color = "neutral", withLabel = true, className, tooltipLabel = label, withTooltip = false, size = "medium", ...rest }) => {
|
|
5702
|
-
return (jsx(Tooltip, { className: className, disabled: withTooltip === false, label: tooltipLabel, placement: "bottom", children: jsxs("div", { "aria-label": label, className: cvaNotice(), "data-testid": dataTestId, ...rest, children: [nonNullable(iconName) ? (jsx("div", { className: cvaNoticeIcon({ color: iconColor || color }), "data-testid": dataTestId ? `${dataTestId}-icon` : "notice-icon", children: jsx(Icon, { name: iconName, size: iconSize }) })) : null, label && withLabel ? (jsx("div", { className: cvaNoticeLabel({ color, size }), "data-testid": dataTestId ? `${dataTestId}-label` : "notice-label", children: label })) : null] }) }));
|
|
5707
|
+
return (jsx(Tooltip, { asChild: false, className: className, disabled: withTooltip === false, label: tooltipLabel, placement: "bottom", children: jsxs("div", { "aria-label": label, className: cvaNotice(), "data-testid": dataTestId, ...rest, children: [nonNullable(iconName) ? (jsx("div", { className: cvaNoticeIcon({ color: iconColor || color }), "data-testid": dataTestId ? `${dataTestId}-icon` : "notice-icon", children: jsx(Icon, { name: iconName, size: iconSize }) })) : null, label && withLabel ? (jsx("div", { className: cvaNoticeLabel({ color, size }), "data-testid": dataTestId ? `${dataTestId}-label` : "notice-label", children: label })) : null] }) }));
|
|
5703
5708
|
};
|
|
5704
5709
|
|
|
5705
5710
|
const cvaPage = cvaMerge(["grid", "h-full"], {
|
|
@@ -5916,7 +5921,7 @@ function ActionRenderer({ action, isMenuItem = false, externalOnClick }) {
|
|
|
5916
5921
|
externalOnClick?.();
|
|
5917
5922
|
}, prefix: prefixIconName ? jsx(Icon, { name: prefixIconName, size: "small" }) : undefined, size: "small", variant: variant, children: actionText }));
|
|
5918
5923
|
// Wrap `content` with Tooltip
|
|
5919
|
-
const wrappedWithTooltip = tooltipLabel ? (jsx(Tooltip, { className: "block", label: tooltipLabel, children: content })) : (content);
|
|
5924
|
+
const wrappedWithTooltip = tooltipLabel ? (jsx(Tooltip, { asChild: false, className: "block", label: tooltipLabel, children: content })) : (content);
|
|
5920
5925
|
// Finally, wrap with Link if `to` is provided
|
|
5921
5926
|
return to !== undefined && to !== "" ? (jsx(Link, { target: target, to: to, children: wrappedWithTooltip })) : (wrappedWithTooltip);
|
|
5922
5927
|
}
|
|
@@ -6034,7 +6039,7 @@ const cvaPageHeaderHeading = cvaMerge(["text-neutral-900", "text-xl", "font-semi
|
|
|
6034
6039
|
*/
|
|
6035
6040
|
const PageHeaderTitle = ({ title, "data-testid": dataTestId, className, }) => {
|
|
6036
6041
|
const { ref, isTextTruncated } = useIsTextTruncated();
|
|
6037
|
-
return (jsx("div", { className: "flex flex-row items-center", children: jsx(Tooltip, { className: "grid min-w-16", disabled: !isTextTruncated, label: title, placement: "top", children: jsx("h1", { className: cvaPageHeaderHeading({ className }), "data-testid": dataTestId ? `${dataTestId}-heading` : undefined, ref: ref, children: title }) }) }));
|
|
6042
|
+
return (jsx("div", { className: "flex flex-row items-center", children: jsx(Tooltip, { asChild: false, className: "grid min-w-16", disabled: !isTextTruncated, label: title, placement: "top", children: jsx("h1", { className: cvaPageHeaderHeading({ className }), "data-testid": dataTestId ? `${dataTestId}-heading` : undefined, ref: ref, children: title }) }) }));
|
|
6038
6043
|
};
|
|
6039
6044
|
|
|
6040
6045
|
/**
|
|
@@ -6092,18 +6097,18 @@ const PageHeader = ({ className, "data-testid": dataTestId, showLoading = false,
|
|
|
6092
6097
|
return null;
|
|
6093
6098
|
}
|
|
6094
6099
|
// If the user passes a string, we render the string as a tag with props provided.
|
|
6095
|
-
return (jsx("div", { className: "ml-auto flex flex-row gap-2", children: jsx(Tooltip, { "data-testid": "page-header-tag-tooltip", disabled: tagTooltipLabel === undefined || tagTooltipLabel === "", label: tagTooltipLabel, placement: "top", children: jsx(Tag, { color: tagColor, "data-testid": "page-header-tag", children: tagLabel }) }) }));
|
|
6100
|
+
return (jsx("div", { className: "ml-auto flex flex-row gap-2", children: jsx(Tooltip, { asChild: false, "data-testid": "page-header-tag-tooltip", disabled: tagTooltipLabel === undefined || tagTooltipLabel === "", label: tagTooltipLabel, placement: "top", children: jsx(Tag, { color: tagColor, "data-testid": "page-header-tag", children: tagLabel }) }) }));
|
|
6096
6101
|
}, [showLoading, tagColor, tagLabel, tagTooltipLabel]);
|
|
6097
6102
|
return (jsxs("div", { className: cvaPageHeaderContainer({
|
|
6098
6103
|
className,
|
|
6099
6104
|
withBorder: tabsList === undefined,
|
|
6100
|
-
}), "data-testid": dataTestId, children: [jsxs("div", { className: cvaPageHeader(), children: [backTo ? (jsx(Link, { to: backTo, children: jsx(Button, { className: "mr-4 bg-black/5 hover:bg-black/10", prefix: jsx(Icon, { name: "ArrowLeft", size: "small" }), size: "small", square: true, variant: "ghost-neutral" }) })) : undefined, typeof title === "string" ? jsx(PageHeaderTitle, { "data-testid": dataTestId, title: title }) : title, tagRenderer || (description !== null && description !== undefined) ? (jsxs("div", { className: "mx-2 flex items-center gap-2", children: [description !== null && description !== undefined && !showLoading ? (jsx(Tooltip, { "data-testid": dataTestId ? `${dataTestId}-description-tooltip` : undefined, iconProps: {
|
|
6105
|
+
}), "data-testid": dataTestId, children: [jsxs("div", { className: cvaPageHeader(), children: [backTo ? (jsx(Link, { to: backTo, children: jsx(Button, { className: "mr-4 bg-black/5 hover:bg-black/10", prefix: jsx(Icon, { name: "ArrowLeft", size: "small" }), size: "small", square: true, variant: "ghost-neutral" }) })) : undefined, typeof title === "string" ? jsx(PageHeaderTitle, { "data-testid": dataTestId, title: title }) : title, tagRenderer || (description !== null && description !== undefined) ? (jsxs("div", { className: "mx-2 flex items-center gap-2", children: [description !== null && description !== undefined && !showLoading ? (jsx(Tooltip, { asChild: false, "data-testid": dataTestId ? `${dataTestId}-description-tooltip` : undefined, iconProps: {
|
|
6101
6106
|
name: descriptionIcon,
|
|
6102
6107
|
"data-testid": "page-header-description-icon",
|
|
6103
6108
|
}, label: description, placement: "bottom" })) : undefined, tagRenderer] })) : null, jsxs("div", { className: "ml-auto flex gap-2", children: [discriminatedProps.accessoryType === "kpi-metrics" ? (jsx(PageHeaderKpiMetrics, { kpiMetrics: discriminatedProps.kpiMetrics })) : null, discriminatedProps.accessoryType === "actions" ? (Array.isArray(discriminatedProps.secondaryActions) ? (jsx(PageHeaderSecondaryActions, { actions: discriminatedProps.secondaryActions, groupActions: discriminatedProps.groupSecondaryActions ?? false, hasPrimaryAction: !!discriminatedProps.primaryAction })) : discriminatedProps.secondaryActions !== null && discriminatedProps.secondaryActions !== undefined ? (discriminatedProps.secondaryActions) : null) : null, discriminatedProps.accessoryType === "actions" &&
|
|
6104
6109
|
discriminatedProps.primaryAction !== undefined &&
|
|
6105
6110
|
(discriminatedProps.primaryAction.hidden === false ||
|
|
6106
|
-
discriminatedProps.primaryAction.hidden === undefined) ? (jsx(Tooltip, { disabled: discriminatedProps.primaryAction.tooltipLabel === undefined ||
|
|
6111
|
+
discriminatedProps.primaryAction.hidden === undefined) ? (jsx(Tooltip, { asChild: false, disabled: discriminatedProps.primaryAction.tooltipLabel === undefined ||
|
|
6107
6112
|
discriminatedProps.primaryAction.tooltipLabel === "", label: discriminatedProps.primaryAction.tooltipLabel, children: jsx(Button, { "data-testid": discriminatedProps.primaryAction["data-testid"], disabled: discriminatedProps.primaryAction.disabled, loading: discriminatedProps.primaryAction.loading, onClick: () => discriminatedProps.primaryAction?.actionCallback?.(), prefix: discriminatedProps.primaryAction.prefixIconName !== undefined ? (jsx(Icon, { name: discriminatedProps.primaryAction.prefixIconName, size: "small" })) : undefined, size: "small", variant: discriminatedProps.primaryAction.variant, children: discriminatedProps.primaryAction.actionText }) })) : null] })] }), tabsList] }));
|
|
6108
6113
|
};
|
|
6109
6114
|
|
|
@@ -6951,11 +6956,11 @@ const ToggleGroup = ({ list, selected, setSelected, onChange, disabled = false,
|
|
|
6951
6956
|
}, ref: el => (buttonRefs.current[index] = el), selected: selected === item.id, size: size, text: item.text, title: item.title, tooltip: item.tooltip }, item.id))) }));
|
|
6952
6957
|
};
|
|
6953
6958
|
const ToggleItem = ({ title, onClick, disabled, isIconOnly, iconName = undefined, size, className, selected, text, tooltip, "data-testid": dataTestId, ref, }) => {
|
|
6954
|
-
return isIconOnly ? (jsx(Tooltip, { label: tooltip?.content || title, placement: tooltip?.placement || "top", children: jsx(ToggleButton, { className: cvaToggleItem({
|
|
6959
|
+
return isIconOnly ? (jsx(Tooltip, { asChild: false, label: tooltip?.content || title, placement: tooltip?.placement || "top", children: jsx(ToggleButton, { className: cvaToggleItem({
|
|
6955
6960
|
className,
|
|
6956
6961
|
selected,
|
|
6957
6962
|
disabled,
|
|
6958
|
-
}), "data-testid": dataTestId, disabled: disabled, icon: iconName ? (jsx(Icon, { className: cvaToggleItemContent({ selected, disabled }), name: iconName, size: size === "large" ? "medium" : "small" })) : null, isIconOnly: isIconOnly, onClick: onClick, ref: ref, size: size, title: title }) })) : (jsx(Tooltip, { disabled: !tooltip?.content && text?.truncate === false, label: tooltip?.content || title, placement: tooltip?.placement || "top", children: jsx(ToggleButton, { className: cvaToggleItem({
|
|
6963
|
+
}), "data-testid": dataTestId, disabled: disabled, icon: iconName ? (jsx(Icon, { className: cvaToggleItemContent({ selected, disabled }), name: iconName, size: size === "large" ? "medium" : "small" })) : null, isIconOnly: isIconOnly, onClick: onClick, ref: ref, size: size, title: title }) })) : (jsx(Tooltip, { asChild: false, disabled: !tooltip?.content && text?.truncate === false, label: tooltip?.content || title, placement: tooltip?.placement || "top", children: jsx(ToggleButton, { className: cvaToggleItem({
|
|
6959
6964
|
className,
|
|
6960
6965
|
selected,
|
|
6961
6966
|
disabled,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/react-components",
|
|
3
|
-
"version": "1.17.
|
|
3
|
+
"version": "1.17.6",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"engines": {
|
|
@@ -14,10 +14,10 @@
|
|
|
14
14
|
"@floating-ui/react": "^0.26.25",
|
|
15
15
|
"string-ts": "^2.0.0",
|
|
16
16
|
"tailwind-merge": "^2.0.0",
|
|
17
|
-
"@trackunit/ui-design-tokens": "1.11.
|
|
18
|
-
"@trackunit/css-class-variance-utilities": "1.11.
|
|
19
|
-
"@trackunit/shared-utils": "1.13.
|
|
20
|
-
"@trackunit/ui-icons": "1.11.
|
|
17
|
+
"@trackunit/ui-design-tokens": "1.11.35",
|
|
18
|
+
"@trackunit/css-class-variance-utilities": "1.11.35",
|
|
19
|
+
"@trackunit/shared-utils": "1.13.35",
|
|
20
|
+
"@trackunit/ui-icons": "1.11.34",
|
|
21
21
|
"@tanstack/react-router": "1.114.29",
|
|
22
22
|
"es-toolkit": "^1.39.10",
|
|
23
23
|
"@tanstack/react-virtual": "3.13.12",
|
|
@@ -33,6 +33,15 @@ export interface TooltipProps extends CommonProps, Styleable {
|
|
|
33
33
|
* Ihe id of the html element
|
|
34
34
|
*/
|
|
35
35
|
id?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Specifies whether the current component or element should be rendered as a child element.
|
|
38
|
+
* When set to `true`, the behavior or structure of the component may adapt to fit within
|
|
39
|
+
* a parent context, altering its default rendering logic. Typically used in scenarios
|
|
40
|
+
* where nesting or parent-child relationships are relevant.
|
|
41
|
+
*
|
|
42
|
+
* @deprecated - Do not use this prop. It will be removed in a future release.
|
|
43
|
+
*/
|
|
44
|
+
asChild?: boolean;
|
|
36
45
|
}
|
|
37
46
|
/**
|
|
38
47
|
* Tooltips display additional information upon hover. The information included should be contextual, helpful, and nonessential while providing that extra ability to communicate and give clarity to a user.
|
|
@@ -48,7 +57,7 @@ export interface TooltipProps extends CommonProps, Styleable {
|
|
|
48
57
|
* import { Tooltip, IconButton, Icon } from "@trackunit/react-components";
|
|
49
58
|
*
|
|
50
59
|
* const SettingsButton = () => (
|
|
51
|
-
* <Tooltip label="Open settings" placement="bottom">
|
|
60
|
+
* <Tooltip asChild={false} label="Open settings" placement="bottom">
|
|
52
61
|
* <IconButton
|
|
53
62
|
* icon={<Icon name="Cog6Tooth" size="small" />}
|
|
54
63
|
* variant="ghost-neutral"
|
|
@@ -64,7 +73,7 @@ export interface TooltipProps extends CommonProps, Styleable {
|
|
|
64
73
|
* const FieldWithHelp = () => (
|
|
65
74
|
* <div className="flex items-center gap-2">
|
|
66
75
|
* <span>Utilization Rate</span>
|
|
67
|
-
* <Tooltip
|
|
76
|
+
* <Tooltip asChild={false}
|
|
68
77
|
* label="The percentage of time the asset was actively in use during the selected period"
|
|
69
78
|
* placement="right"
|
|
70
79
|
* mode="light"
|
|
@@ -75,4 +84,4 @@ export interface TooltipProps extends CommonProps, Styleable {
|
|
|
75
84
|
* @param {TooltipProps} props - The props for the Tooltip component
|
|
76
85
|
* @returns {ReactElement} Tooltip component
|
|
77
86
|
*/
|
|
78
|
-
export declare const Tooltip: ({ children, "data-testid": dataTestId, disabled, className, label, placement, mode, iconProps, id, style, }: TooltipProps) => ReactElement;
|
|
87
|
+
export declare const Tooltip: ({ children, "data-testid": dataTestId, disabled, className, label, placement, mode, iconProps, id, style, asChild, }: TooltipProps) => ReactElement;
|