@trackunit/react-components 6.0.30 → 6.0.31
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 +13 -5
- package/index.esm.js +14 -6
- package/migrations/assets/react-router-components/package.json +6 -6
- package/package.json +6 -6
- package/src/components/Popover/PopoverTypes.d.ts +12 -1
- package/src/components/Tooltip/Tooltip.d.ts +10 -1
- package/src/components/buttons/IconButton/IconButton.d.ts +7 -1
package/index.cjs.js
CHANGED
|
@@ -1120,6 +1120,8 @@ const usePopover = ({ initialOpen = false, placement = "bottom", isModal, isOpen
|
|
|
1120
1120
|
? react$1.safePolygon({ blockPointerEvents: isInsideMenuTree })
|
|
1121
1121
|
: undefined,
|
|
1122
1122
|
});
|
|
1123
|
+
const focusEnabled = resolvedActivation.focus === true;
|
|
1124
|
+
const focusInteraction = react$1.useFocus(popoverContext, { enabled: focusEnabled });
|
|
1123
1125
|
const roleInteraction = react$1.useRole(popoverContext, { role });
|
|
1124
1126
|
// Distinguishes a genuine open -> close transition from this node simply mounting closed (the
|
|
1125
1127
|
// common case: every unrelated sibling elsewhere in the tree mounts with `isOpen === false`).
|
|
@@ -1142,6 +1144,7 @@ const usePopover = ({ initialOpen = false, placement = "bottom", isModal, isOpen
|
|
|
1142
1144
|
const combinedInteractions = react$1.useInteractions([
|
|
1143
1145
|
clickInteraction,
|
|
1144
1146
|
hoverInteraction,
|
|
1147
|
+
focusInteraction,
|
|
1145
1148
|
dismissInteraction,
|
|
1146
1149
|
roleInteraction,
|
|
1147
1150
|
]);
|
|
@@ -1159,6 +1162,7 @@ const usePopover = ({ initialOpen = false, placement = "bottom", isModal, isOpen
|
|
|
1159
1162
|
...combinedInteractions,
|
|
1160
1163
|
isModal,
|
|
1161
1164
|
isNested,
|
|
1165
|
+
closeOnFocusOut: focusEnabled,
|
|
1162
1166
|
labelId,
|
|
1163
1167
|
descriptionId,
|
|
1164
1168
|
setLabelId,
|
|
@@ -1176,6 +1180,7 @@ const usePopover = ({ initialOpen = false, placement = "bottom", isModal, isOpen
|
|
|
1176
1180
|
setUncontrolledIsOpen,
|
|
1177
1181
|
nodeId,
|
|
1178
1182
|
isNested,
|
|
1183
|
+
focusEnabled,
|
|
1179
1184
|
combinedInteractions,
|
|
1180
1185
|
popoverData,
|
|
1181
1186
|
isModal,
|
|
@@ -1382,7 +1387,7 @@ const PopoverContent = function PopoverContent({ className, "data-testid": dataT
|
|
|
1382
1387
|
// Floating UI's own app-wide "previously focused element" tracking, which isn't exposed here to
|
|
1383
1388
|
// check against.
|
|
1384
1389
|
const resolvedReturnFocus = typeof returnFocus === "boolean" ? returnFocus : withVisibilityCheck(returnFocus);
|
|
1385
|
-
return (jsxRuntime.jsx(react$1.FloatingPortal, { id: portalId, root: document.body, children: context.isOpen === true ? (jsxRuntime.jsx(react$1.FloatingFocusManager, { closeOnFocusOut:
|
|
1390
|
+
return (jsxRuntime.jsx(react$1.FloatingPortal, { id: portalId, root: document.body, children: context.isOpen === true ? (jsxRuntime.jsx(react$1.FloatingFocusManager, { closeOnFocusOut: context.closeOnFocusOut, context: floatingContext, guards: true, initialFocus: initialFocus, modal: context.isModal, order: ["reference", "content"], returnFocus: resolvedReturnFocus, children: jsxRuntime.jsx("div", { "aria-describedby": context.descriptionId, "aria-labelledby": context.labelId, className: cvaPopoverContainer({ className: className ?? customProps.className }), "data-testid": dataTestId ?? customProps["data-testid"] ?? "popover-content", ref: ref, style: {
|
|
1386
1391
|
position: context.strategy,
|
|
1387
1392
|
top: context.y,
|
|
1388
1393
|
left: context.x,
|
|
@@ -2194,7 +2199,7 @@ const FloatingArrowContainer = ({ arrowRef, mode = "dark", }) => {
|
|
|
2194
2199
|
* @returns {ReactElement} Tooltip component
|
|
2195
2200
|
*/
|
|
2196
2201
|
// eslint-disable-next-line @trackunit/require-component-prop-contracts -- `className` is deliberately omitted (Omit<CommonProps, "className">): the tooltip clones its trigger and renders a floating popover, so a single className has no unambiguous target; decide in SDK-584
|
|
2197
|
-
const Tooltip = ({ children, "data-testid": dataTestId, disabled = false, label, placement = "auto", mode = "dark", iconProps, id, style, delayed = false, interactable = true, "data-state": dataState, ref, ...rest }) => {
|
|
2202
|
+
const Tooltip = ({ children, "data-testid": dataTestId, disabled = false, label, placement = "auto", mode = "dark", iconProps, id, style, delayed = false, interactable = true, openOnFocus = false, "data-state": dataState, ref, ...rest }) => {
|
|
2198
2203
|
const [isOpen, setIsOpen] = react.useState(false);
|
|
2199
2204
|
// PopoverTrigger marks the element that opened a menu or popover with data-state="open".
|
|
2200
2205
|
// That state lands on this tooltip when it is the trigger, or on the child when a parent
|
|
@@ -2209,6 +2214,9 @@ const Tooltip = ({ children, "data-testid": dataTestId, disabled = false, label,
|
|
|
2209
2214
|
if (triggerHasOpenPopup && isOpen) {
|
|
2210
2215
|
setIsOpen(false);
|
|
2211
2216
|
}
|
|
2217
|
+
// A label that repeats the trigger's accessible name would be read twice as its description.
|
|
2218
|
+
const labelIsTriggerName = react.isValidElement(children) &&
|
|
2219
|
+
(children.props.ariaLabel === label || children.props["aria-label"] === label);
|
|
2212
2220
|
const arrowRef = react.useRef(null);
|
|
2213
2221
|
const { refs, floatingStyles, context } = react$1.useFloating({
|
|
2214
2222
|
placement: placement === "auto" ? "bottom" : placement,
|
|
@@ -2231,7 +2239,7 @@ const Tooltip = ({ children, "data-testid": dataTestId, disabled = false, label,
|
|
|
2231
2239
|
const wrappedChildren = react.useMemo(() => {
|
|
2232
2240
|
return jsxRuntime.jsx(reactSlot.Slot, { children: children });
|
|
2233
2241
|
}, [children]);
|
|
2234
|
-
return (jsxRuntime.jsxs(Popover, { activation: { click: false, hover: { delayed, interactable } }, className: cvaTooltipPopover(), "data-testid": dataTestId, id: id, onOpenStateChange: setIsOpen, placement: placement === "auto" ? "bottom" : placement, children: [jsxRuntime.jsx(PopoverTrigger, { ...rest, "data-testid": dataTestId ? `${dataTestId}-trigger` : null, ref: mergedRef, style: style, children: children === undefined ? (jsxRuntime.jsx(Icon, { className: cvaTooltipIcon({ color: mode }), "data-testid": dataTestId ? `${dataTestId}-icon` : undefined, name: "QuestionMarkCircle", size: "small", ...iconProps })) : (wrappedChildren) }), tooltipSuppressed || !isMounted ? null : (jsxRuntime.jsx("div", { ref: refs.setFloating, style: floatingStyles, children: jsxRuntime.jsx(PopoverContent, { initialFocus: -1, returnFocus: false, children: jsxRuntime.jsxs("div", { "aria-label": typeof label === "string" ? label : undefined, className: cvaTooltipPopoverContent({ color: mode }), "data-testid": dataTestId ? `${dataTestId}-content` : undefined, onClick: e => e.stopPropagation(), onDoubleClick: e => e.stopPropagation(), onMouseDown: e => e.stopPropagation(), onPointerDown: e => e.stopPropagation(), children: [jsxRuntime.jsx(Text, { "data-testid": dataTestId ? `${dataTestId}-text` : undefined, inverted: mode === "dark", size: "small", type: typeof label === "string" ? "p" : "span", children: label }), placement !== "auto" && jsxRuntime.jsx(FloatingArrowContainer, { arrowRef: arrowRef, mode: mode })] }) }) }))] }));
|
|
2242
|
+
return (jsxRuntime.jsxs(Popover, { activation: { click: false, hover: { delayed, interactable }, focus: openOnFocus }, className: cvaTooltipPopover(), "data-testid": dataTestId, id: id, onOpenStateChange: setIsOpen, placement: placement === "auto" ? "bottom" : placement, role: openOnFocus ? (labelIsTriggerName ? "label" : "tooltip") : undefined, children: [jsxRuntime.jsx(PopoverTrigger, { ...rest, "data-testid": dataTestId ? `${dataTestId}-trigger` : null, ref: mergedRef, style: style, children: children === undefined ? (jsxRuntime.jsx(Icon, { className: cvaTooltipIcon({ color: mode }), "data-testid": dataTestId ? `${dataTestId}-icon` : undefined, name: "QuestionMarkCircle", size: "small", ...iconProps })) : (wrappedChildren) }), tooltipSuppressed || !isMounted ? null : (jsxRuntime.jsx("div", { ref: refs.setFloating, style: floatingStyles, children: jsxRuntime.jsx(PopoverContent, { initialFocus: -1, returnFocus: false, children: jsxRuntime.jsxs("div", { "aria-label": typeof label === "string" ? label : undefined, className: cvaTooltipPopoverContent({ color: mode }), "data-testid": dataTestId ? `${dataTestId}-content` : undefined, onClick: e => e.stopPropagation(), onDoubleClick: e => e.stopPropagation(), onMouseDown: e => e.stopPropagation(), onPointerDown: e => e.stopPropagation(), children: [jsxRuntime.jsx(Text, { "data-testid": dataTestId ? `${dataTestId}-text` : undefined, inverted: mode === "dark", size: "small", type: typeof label === "string" ? "p" : "span", children: label }), placement !== "auto" && jsxRuntime.jsx(FloatingArrowContainer, { arrowRef: arrowRef, mode: mode })] }) }) }))] }));
|
|
2235
2243
|
};
|
|
2236
2244
|
|
|
2237
2245
|
/**
|
|
@@ -2615,9 +2623,9 @@ const toButtonSize = (size) => (size === "extraSmall" ? "small" : size);
|
|
|
2615
2623
|
* @param {IconButtonProps} props - The props for the IconButton component
|
|
2616
2624
|
* @returns {ReactElement} IconButton component
|
|
2617
2625
|
*/
|
|
2618
|
-
const IconButton = ({ icon, variant = "primary", size = "medium", square = true, loading = false, disabled = false, className, title, ariaLabel, "data-testid": dataTestId, ref, ...rest }) => {
|
|
2626
|
+
const IconButton = ({ icon, variant = "primary", size = "medium", square = true, loading = false, disabled = false, className, title, ariaLabel, tooltipOpenOnFocus = false, "data-testid": dataTestId, ref, ...rest }) => {
|
|
2619
2627
|
const accessibleLabel = ariaLabel ?? title;
|
|
2620
|
-
return (jsxRuntime.jsx(Tooltip, { "data-testid": "iconButton-tooltip", delayed: true, disabled: !title || disabled || loading, interactable: false, label: title, children: jsxRuntime.jsx(Button, { ...rest, ariaLabel: accessibleLabel, className: cvaIconButton({ size: size, className }), "data-testid": dataTestId ? dataTestId : undefined, disabled: disabled || loading, loading: loading, prefix: !loading ? react.cloneElement(icon, { ariaHidden: true }) : undefined, ref: ref, size: toButtonSize(size), square: square, title: undefined, variant: variant }) }));
|
|
2628
|
+
return (jsxRuntime.jsx(Tooltip, { "data-testid": "iconButton-tooltip", delayed: true, disabled: !title || disabled || loading, interactable: false, label: title, openOnFocus: tooltipOpenOnFocus, children: jsxRuntime.jsx(Button, { ...rest, ariaLabel: accessibleLabel, className: cvaIconButton({ size: size, className }), "data-testid": dataTestId ? dataTestId : undefined, disabled: disabled || loading, loading: loading, prefix: !loading ? react.cloneElement(icon, { ariaHidden: true }) : undefined, ref: ref, size: toButtonSize(size), square: square, title: undefined, variant: variant }) }));
|
|
2621
2629
|
};
|
|
2622
2630
|
IconButton.displayName = "IconButton";
|
|
2623
2631
|
|
package/index.esm.js
CHANGED
|
@@ -12,7 +12,7 @@ import IconSpriteOutline from '@trackunit/ui-icons/icons-sprite-outline.svg';
|
|
|
12
12
|
import IconSpriteSolid from '@trackunit/ui-icons/icons-sprite-solid.svg';
|
|
13
13
|
import { snakeCase, titleCase } from 'string-ts';
|
|
14
14
|
import { cva } from '@trackunit/css-class-variance-utilities';
|
|
15
|
-
import { FloatingTree, useFloatingNodeId, useFloatingParentNodeId, useFloatingTree, offset, flip, shift, size, useFloating, autoUpdate, useClick, useDismiss, useHover as useHover$1, safePolygon, useRole, useInteractions, FloatingNode, useMergeRefs as useMergeRefs$1, FloatingPortal, FloatingFocusManager, arrow, useTransitionStatus, FloatingArrow, useListNavigation, useTypeahead, FloatingList, useListItem } from '@floating-ui/react';
|
|
15
|
+
import { FloatingTree, useFloatingNodeId, useFloatingParentNodeId, useFloatingTree, offset, flip, shift, size, useFloating, autoUpdate, useClick, useDismiss, useHover as useHover$1, safePolygon, useFocus, useRole, useInteractions, FloatingNode, useMergeRefs as useMergeRefs$1, FloatingPortal, FloatingFocusManager, arrow, useTransitionStatus, FloatingArrow, useListNavigation, useTypeahead, FloatingList, useListItem } from '@floating-ui/react';
|
|
16
16
|
import { Slot, Slottable } from '@radix-ui/react-slot';
|
|
17
17
|
import { omit, isEqual } from 'es-toolkit';
|
|
18
18
|
import { Link, useBlocker } from '@tanstack/react-router';
|
|
@@ -1119,6 +1119,8 @@ const usePopover = ({ initialOpen = false, placement = "bottom", isModal, isOpen
|
|
|
1119
1119
|
? safePolygon({ blockPointerEvents: isInsideMenuTree })
|
|
1120
1120
|
: undefined,
|
|
1121
1121
|
});
|
|
1122
|
+
const focusEnabled = resolvedActivation.focus === true;
|
|
1123
|
+
const focusInteraction = useFocus(popoverContext, { enabled: focusEnabled });
|
|
1122
1124
|
const roleInteraction = useRole(popoverContext, { role });
|
|
1123
1125
|
// Distinguishes a genuine open -> close transition from this node simply mounting closed (the
|
|
1124
1126
|
// common case: every unrelated sibling elsewhere in the tree mounts with `isOpen === false`).
|
|
@@ -1141,6 +1143,7 @@ const usePopover = ({ initialOpen = false, placement = "bottom", isModal, isOpen
|
|
|
1141
1143
|
const combinedInteractions = useInteractions([
|
|
1142
1144
|
clickInteraction,
|
|
1143
1145
|
hoverInteraction,
|
|
1146
|
+
focusInteraction,
|
|
1144
1147
|
dismissInteraction,
|
|
1145
1148
|
roleInteraction,
|
|
1146
1149
|
]);
|
|
@@ -1158,6 +1161,7 @@ const usePopover = ({ initialOpen = false, placement = "bottom", isModal, isOpen
|
|
|
1158
1161
|
...combinedInteractions,
|
|
1159
1162
|
isModal,
|
|
1160
1163
|
isNested,
|
|
1164
|
+
closeOnFocusOut: focusEnabled,
|
|
1161
1165
|
labelId,
|
|
1162
1166
|
descriptionId,
|
|
1163
1167
|
setLabelId,
|
|
@@ -1175,6 +1179,7 @@ const usePopover = ({ initialOpen = false, placement = "bottom", isModal, isOpen
|
|
|
1175
1179
|
setUncontrolledIsOpen,
|
|
1176
1180
|
nodeId,
|
|
1177
1181
|
isNested,
|
|
1182
|
+
focusEnabled,
|
|
1178
1183
|
combinedInteractions,
|
|
1179
1184
|
popoverData,
|
|
1180
1185
|
isModal,
|
|
@@ -1381,7 +1386,7 @@ const PopoverContent = function PopoverContent({ className, "data-testid": dataT
|
|
|
1381
1386
|
// Floating UI's own app-wide "previously focused element" tracking, which isn't exposed here to
|
|
1382
1387
|
// check against.
|
|
1383
1388
|
const resolvedReturnFocus = typeof returnFocus === "boolean" ? returnFocus : withVisibilityCheck(returnFocus);
|
|
1384
|
-
return (jsx(FloatingPortal, { id: portalId, root: document.body, children: context.isOpen === true ? (jsx(FloatingFocusManager, { closeOnFocusOut:
|
|
1389
|
+
return (jsx(FloatingPortal, { id: portalId, root: document.body, children: context.isOpen === true ? (jsx(FloatingFocusManager, { closeOnFocusOut: context.closeOnFocusOut, context: floatingContext, guards: true, initialFocus: initialFocus, modal: context.isModal, order: ["reference", "content"], returnFocus: resolvedReturnFocus, children: jsx("div", { "aria-describedby": context.descriptionId, "aria-labelledby": context.labelId, className: cvaPopoverContainer({ className: className ?? customProps.className }), "data-testid": dataTestId ?? customProps["data-testid"] ?? "popover-content", ref: ref, style: {
|
|
1385
1390
|
position: context.strategy,
|
|
1386
1391
|
top: context.y,
|
|
1387
1392
|
left: context.x,
|
|
@@ -2193,7 +2198,7 @@ const FloatingArrowContainer = ({ arrowRef, mode = "dark", }) => {
|
|
|
2193
2198
|
* @returns {ReactElement} Tooltip component
|
|
2194
2199
|
*/
|
|
2195
2200
|
// eslint-disable-next-line @trackunit/require-component-prop-contracts -- `className` is deliberately omitted (Omit<CommonProps, "className">): the tooltip clones its trigger and renders a floating popover, so a single className has no unambiguous target; decide in SDK-584
|
|
2196
|
-
const Tooltip = ({ children, "data-testid": dataTestId, disabled = false, label, placement = "auto", mode = "dark", iconProps, id, style, delayed = false, interactable = true, "data-state": dataState, ref, ...rest }) => {
|
|
2201
|
+
const Tooltip = ({ children, "data-testid": dataTestId, disabled = false, label, placement = "auto", mode = "dark", iconProps, id, style, delayed = false, interactable = true, openOnFocus = false, "data-state": dataState, ref, ...rest }) => {
|
|
2197
2202
|
const [isOpen, setIsOpen] = useState(false);
|
|
2198
2203
|
// PopoverTrigger marks the element that opened a menu or popover with data-state="open".
|
|
2199
2204
|
// That state lands on this tooltip when it is the trigger, or on the child when a parent
|
|
@@ -2208,6 +2213,9 @@ const Tooltip = ({ children, "data-testid": dataTestId, disabled = false, label,
|
|
|
2208
2213
|
if (triggerHasOpenPopup && isOpen) {
|
|
2209
2214
|
setIsOpen(false);
|
|
2210
2215
|
}
|
|
2216
|
+
// A label that repeats the trigger's accessible name would be read twice as its description.
|
|
2217
|
+
const labelIsTriggerName = isValidElement(children) &&
|
|
2218
|
+
(children.props.ariaLabel === label || children.props["aria-label"] === label);
|
|
2211
2219
|
const arrowRef = useRef(null);
|
|
2212
2220
|
const { refs, floatingStyles, context } = useFloating({
|
|
2213
2221
|
placement: placement === "auto" ? "bottom" : placement,
|
|
@@ -2230,7 +2238,7 @@ const Tooltip = ({ children, "data-testid": dataTestId, disabled = false, label,
|
|
|
2230
2238
|
const wrappedChildren = useMemo(() => {
|
|
2231
2239
|
return jsx(Slot, { children: children });
|
|
2232
2240
|
}, [children]);
|
|
2233
|
-
return (jsxs(Popover, { activation: { click: false, hover: { delayed, interactable } }, className: cvaTooltipPopover(), "data-testid": dataTestId, id: id, onOpenStateChange: setIsOpen, placement: placement === "auto" ? "bottom" : placement, children: [jsx(PopoverTrigger, { ...rest, "data-testid": dataTestId ? `${dataTestId}-trigger` : null, ref: mergedRef, style: style, children: children === undefined ? (jsx(Icon, { className: cvaTooltipIcon({ color: mode }), "data-testid": dataTestId ? `${dataTestId}-icon` : undefined, name: "QuestionMarkCircle", size: "small", ...iconProps })) : (wrappedChildren) }), tooltipSuppressed || !isMounted ? null : (jsx("div", { ref: refs.setFloating, style: floatingStyles, children: jsx(PopoverContent, { initialFocus: -1, returnFocus: false, children: jsxs("div", { "aria-label": typeof label === "string" ? label : undefined, className: cvaTooltipPopoverContent({ color: mode }), "data-testid": dataTestId ? `${dataTestId}-content` : undefined, onClick: e => e.stopPropagation(), onDoubleClick: e => e.stopPropagation(), onMouseDown: e => e.stopPropagation(), onPointerDown: e => e.stopPropagation(), children: [jsx(Text, { "data-testid": dataTestId ? `${dataTestId}-text` : undefined, inverted: mode === "dark", size: "small", type: typeof label === "string" ? "p" : "span", children: label }), placement !== "auto" && jsx(FloatingArrowContainer, { arrowRef: arrowRef, mode: mode })] }) }) }))] }));
|
|
2241
|
+
return (jsxs(Popover, { activation: { click: false, hover: { delayed, interactable }, focus: openOnFocus }, className: cvaTooltipPopover(), "data-testid": dataTestId, id: id, onOpenStateChange: setIsOpen, placement: placement === "auto" ? "bottom" : placement, role: openOnFocus ? (labelIsTriggerName ? "label" : "tooltip") : undefined, children: [jsx(PopoverTrigger, { ...rest, "data-testid": dataTestId ? `${dataTestId}-trigger` : null, ref: mergedRef, style: style, children: children === undefined ? (jsx(Icon, { className: cvaTooltipIcon({ color: mode }), "data-testid": dataTestId ? `${dataTestId}-icon` : undefined, name: "QuestionMarkCircle", size: "small", ...iconProps })) : (wrappedChildren) }), tooltipSuppressed || !isMounted ? null : (jsx("div", { ref: refs.setFloating, style: floatingStyles, children: jsx(PopoverContent, { initialFocus: -1, returnFocus: false, children: jsxs("div", { "aria-label": typeof label === "string" ? label : undefined, className: cvaTooltipPopoverContent({ color: mode }), "data-testid": dataTestId ? `${dataTestId}-content` : undefined, onClick: e => e.stopPropagation(), onDoubleClick: e => e.stopPropagation(), onMouseDown: e => e.stopPropagation(), onPointerDown: e => e.stopPropagation(), children: [jsx(Text, { "data-testid": dataTestId ? `${dataTestId}-text` : undefined, inverted: mode === "dark", size: "small", type: typeof label === "string" ? "p" : "span", children: label }), placement !== "auto" && jsx(FloatingArrowContainer, { arrowRef: arrowRef, mode: mode })] }) }) }))] }));
|
|
2234
2242
|
};
|
|
2235
2243
|
|
|
2236
2244
|
/**
|
|
@@ -2614,9 +2622,9 @@ const toButtonSize = (size) => (size === "extraSmall" ? "small" : size);
|
|
|
2614
2622
|
* @param {IconButtonProps} props - The props for the IconButton component
|
|
2615
2623
|
* @returns {ReactElement} IconButton component
|
|
2616
2624
|
*/
|
|
2617
|
-
const IconButton = ({ icon, variant = "primary", size = "medium", square = true, loading = false, disabled = false, className, title, ariaLabel, "data-testid": dataTestId, ref, ...rest }) => {
|
|
2625
|
+
const IconButton = ({ icon, variant = "primary", size = "medium", square = true, loading = false, disabled = false, className, title, ariaLabel, tooltipOpenOnFocus = false, "data-testid": dataTestId, ref, ...rest }) => {
|
|
2618
2626
|
const accessibleLabel = ariaLabel ?? title;
|
|
2619
|
-
return (jsx(Tooltip, { "data-testid": "iconButton-tooltip", delayed: true, disabled: !title || disabled || loading, interactable: false, label: title, children: jsx(Button, { ...rest, ariaLabel: accessibleLabel, className: cvaIconButton({ size: size, className }), "data-testid": dataTestId ? dataTestId : undefined, disabled: disabled || loading, loading: loading, prefix: !loading ? cloneElement(icon, { ariaHidden: true }) : undefined, ref: ref, size: toButtonSize(size), square: square, title: undefined, variant: variant }) }));
|
|
2627
|
+
return (jsx(Tooltip, { "data-testid": "iconButton-tooltip", delayed: true, disabled: !title || disabled || loading, interactable: false, label: title, openOnFocus: tooltipOpenOnFocus, children: jsx(Button, { ...rest, ariaLabel: accessibleLabel, className: cvaIconButton({ size: size, className }), "data-testid": dataTestId ? dataTestId : undefined, disabled: disabled || loading, loading: loading, prefix: !loading ? cloneElement(icon, { ariaHidden: true }) : undefined, ref: ref, size: toButtonSize(size), square: square, title: undefined, variant: variant }) }));
|
|
2620
2628
|
};
|
|
2621
2629
|
IconButton.displayName = "IconButton";
|
|
2622
2630
|
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/react-router-components",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.34",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"engines": {
|
|
7
7
|
"node": ">=24.x"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@trackunit/css-class-variance-utilities": "2.6.
|
|
11
|
-
"@trackunit/i18n-library-translation": "2.14.
|
|
12
|
-
"@trackunit/react-components": "6.0.
|
|
13
|
-
"@trackunit/react-drawer": "2.17.
|
|
14
|
-
"@trackunit/shared-utils": "1.22.
|
|
10
|
+
"@trackunit/css-class-variance-utilities": "2.6.37",
|
|
11
|
+
"@trackunit/i18n-library-translation": "2.14.29",
|
|
12
|
+
"@trackunit/react-components": "6.0.31",
|
|
13
|
+
"@trackunit/react-drawer": "2.17.32",
|
|
14
|
+
"@trackunit/shared-utils": "1.22.37",
|
|
15
15
|
"dequal": "^2.0.3",
|
|
16
16
|
"zod": "^3.25.76"
|
|
17
17
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/react-components",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.31",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"migrations": "./migrations.json",
|
|
@@ -14,15 +14,15 @@
|
|
|
14
14
|
"@floating-ui/react": "^0.26.25",
|
|
15
15
|
"string-ts": "^2.0.0",
|
|
16
16
|
"tailwind-merge": "^3.7.0",
|
|
17
|
-
"@trackunit/ui-design-tokens": "1.21.
|
|
18
|
-
"@trackunit/css-class-variance-utilities": "2.6.
|
|
19
|
-
"@trackunit/shared-utils": "1.22.
|
|
20
|
-
"@trackunit/ui-icons": "1.20.
|
|
17
|
+
"@trackunit/ui-design-tokens": "1.21.36",
|
|
18
|
+
"@trackunit/css-class-variance-utilities": "2.6.37",
|
|
19
|
+
"@trackunit/shared-utils": "1.22.37",
|
|
20
|
+
"@trackunit/ui-icons": "1.20.36",
|
|
21
21
|
"es-toolkit": "^1.52.0",
|
|
22
22
|
"@tanstack/react-virtual": "^3.14.13",
|
|
23
23
|
"fflate": "^0.8.3",
|
|
24
24
|
"zod": "^3.25.76",
|
|
25
|
-
"@trackunit/i18n-library-translation": "2.14.
|
|
25
|
+
"@trackunit/i18n-library-translation": "2.14.29"
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
28
28
|
"react": "^19.0.0",
|
|
@@ -25,6 +25,12 @@ export type PopoverHoverOptions = {
|
|
|
25
25
|
export type PopoverActivation = {
|
|
26
26
|
click?: boolean;
|
|
27
27
|
hover?: boolean | PopoverHoverOptions;
|
|
28
|
+
/**
|
|
29
|
+
* Whether keyboard focus on the trigger opens the floating element. Pointer focus does not.
|
|
30
|
+
*
|
|
31
|
+
* @default false
|
|
32
|
+
*/
|
|
33
|
+
focus?: boolean;
|
|
28
34
|
keyboardHandlers?: boolean;
|
|
29
35
|
};
|
|
30
36
|
export type PopoverDismissal = Pick<UseDismissProps, "ancestorScroll" | "enabled" | "outsidePress">;
|
|
@@ -38,7 +44,7 @@ export type PopoverSizing = {
|
|
|
38
44
|
minHeight?: HeightSizeLimit;
|
|
39
45
|
maxHeight?: HeightSizeLimit;
|
|
40
46
|
};
|
|
41
|
-
export type PopoverRole = "dialog" | "menu" | "listbox" | "grid" | "tree";
|
|
47
|
+
export type PopoverRole = "dialog" | "menu" | "listbox" | "grid" | "tree" | "tooltip" | "label";
|
|
42
48
|
export interface PopoverProps extends CommonProps {
|
|
43
49
|
/**
|
|
44
50
|
* Size constraints for the popover
|
|
@@ -107,6 +113,11 @@ export type UsePopoverType = {
|
|
|
107
113
|
* should read this flag instead of calling `useMenuTree()` a second time from within.
|
|
108
114
|
*/
|
|
109
115
|
isNested: boolean;
|
|
116
|
+
/**
|
|
117
|
+
* Whether focus leaving the trigger and the floating element closes it. On for focus
|
|
118
|
+
* activation, so Tabbing past a non-focusable floating element still closes it.
|
|
119
|
+
*/
|
|
120
|
+
closeOnFocusOut: boolean;
|
|
110
121
|
labelId?: string;
|
|
111
122
|
descriptionId?: string;
|
|
112
123
|
setLabelId: (id: string) => void;
|
|
@@ -48,6 +48,15 @@ export interface TooltipProps extends Omit<CommonProps, "className">, Styleable,
|
|
|
48
48
|
* @default true
|
|
49
49
|
*/
|
|
50
50
|
interactable?: Pick<PopoverHoverOptions, "interactable">["interactable"];
|
|
51
|
+
/**
|
|
52
|
+
* Whether keyboard focus on the trigger opens the tooltip, as hover does. Pointer focus does not.
|
|
53
|
+
* The tooltip then uses `role="tooltip"`, so screen readers read it as the trigger's description
|
|
54
|
+
* instead of announcing the trigger as opening a dialog. A label equal to the trigger's
|
|
55
|
+
* `ariaLabel` or `aria-label` is not added as a description.
|
|
56
|
+
*
|
|
57
|
+
* @default false
|
|
58
|
+
*/
|
|
59
|
+
openOnFocus?: boolean;
|
|
51
60
|
/**
|
|
52
61
|
* Set by `PopoverTrigger` when this tooltip is the element that opens a menu or popover.
|
|
53
62
|
* While that popup is open the tooltip stays dismissed so the two overlays don't overlap.
|
|
@@ -95,4 +104,4 @@ export interface TooltipProps extends Omit<CommonProps, "className">, Styleable,
|
|
|
95
104
|
* @param {TooltipProps} props - The props for the Tooltip component
|
|
96
105
|
* @returns {ReactElement} Tooltip component
|
|
97
106
|
*/
|
|
98
|
-
export declare const Tooltip: ({ children, "data-testid": dataTestId, disabled, label, placement, mode, iconProps, id, style, delayed, interactable, "data-state": dataState, ref, ...rest }: TooltipProps) => ReactElement;
|
|
107
|
+
export declare const Tooltip: ({ children, "data-testid": dataTestId, disabled, label, placement, mode, iconProps, id, style, delayed, interactable, openOnFocus, "data-state": dataState, ref, ...rest }: TooltipProps) => ReactElement;
|
|
@@ -21,6 +21,12 @@ interface IconButtonBaseProps extends MappedOmit<ButtonCommonProps, "ariaLabel"
|
|
|
21
21
|
* single text line.
|
|
22
22
|
*/
|
|
23
23
|
size?: IconButtonSize;
|
|
24
|
+
/**
|
|
25
|
+
* Whether keyboard focus on the button opens the `title` tooltip, as hover does. Pointer focus does not.
|
|
26
|
+
*
|
|
27
|
+
* @default false
|
|
28
|
+
*/
|
|
29
|
+
tooltipOpenOnFocus?: boolean;
|
|
24
30
|
}
|
|
25
31
|
type IconButtonAccessibleNameProps = {
|
|
26
32
|
/**
|
|
@@ -85,7 +91,7 @@ export type IconButtonProps = IconButtonBaseProps & IconButtonAccessibleNameProp
|
|
|
85
91
|
* @returns {ReactElement} IconButton component
|
|
86
92
|
*/
|
|
87
93
|
export declare const IconButton: {
|
|
88
|
-
({ icon, variant, size, square, loading, disabled, className, title, ariaLabel, "data-testid": dataTestId, ref, ...rest }: IconButtonProps): ReactElement;
|
|
94
|
+
({ icon, variant, size, square, loading, disabled, className, title, ariaLabel, tooltipOpenOnFocus, "data-testid": dataTestId, ref, ...rest }: IconButtonProps): ReactElement;
|
|
89
95
|
displayName: string;
|
|
90
96
|
};
|
|
91
97
|
export {};
|