@epilot/zenith-react 0.3.0-next.3 → 0.3.0-next.4
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/CHANGELOG.md
CHANGED
|
@@ -5,7 +5,7 @@ history belongs to the source project and remains available through Git.
|
|
|
5
5
|
|
|
6
6
|
## Unreleased
|
|
7
7
|
|
|
8
|
-
## [0.3.0-next.
|
|
8
|
+
## [0.3.0-next.4] - 2026-10-30
|
|
9
9
|
|
|
10
10
|
- changed: @epilot/zenith-react depends on @epilot/zenith-runtime ^0.2.0 so compatible runtime releases reach consumers independently. — @wmolinari ([!153](https://gitlab.com/e-pilot/product/frontend/zenith/-/merge_requests/153))
|
|
11
11
|
- changed: **BREAKING**: FieldCombobox and Command, the search list inside it, run on Base UI's Autocomplete instead of `cmdk`. Options are data: pass them as `items` on `FieldComboboxContent` and render them with a function in `FieldComboboxList` (and in `FieldComboboxCollection` inside each `FieldComboboxGroup`, which takes its group's `items`). `FieldComboboxItem`'s `value` is the item, and `onClick`, which also runs on Enter, replaces `onSelect`. `items` is required on `FieldComboboxContent`. The search text moves from `FieldComboboxInput`'s `value`/`onValueChange` to `FieldComboboxContent`'s, `FieldComboboxGroupLabel` replaces `FieldComboboxGroup`'s `heading`, and filtering is a case-insensitive "contains" that keeps the items' order. The Combobox page's "Changed in this version" section shows the new form (#106) — @wmolinari ([!151](https://gitlab.com/e-pilot/product/frontend/zenith/-/merge_requests/151)) (experiment: https://gitlab.com/e-pilot/product/frontend/zenith/-/merge_requests/151)
|
|
@@ -14,6 +14,7 @@ history belongs to the source project and remains available through Git.
|
|
|
14
14
|
- added: `FieldComboboxCollection`, and `@epilot/zenith-runtime/v1` serves Base UI's `autocomplete`; publish the runtime before `@epilot/zenith-react` (#106) — @wmolinari ([!151](https://gitlab.com/e-pilot/product/frontend/zenith/-/merge_requests/151)) (experiment: https://gitlab.com/e-pilot/product/frontend/zenith/-/merge_requests/151)
|
|
15
15
|
- fixed: CalloutAction no longer runs past the right edge of its Callout when the callout has an icon; its width is no longer forced to 100% on top of the icon indent, so a wrapping label or full-width row now wraps inside the callout (#61) — @wmolinari ([!139](https://gitlab.com/e-pilot/product/frontend/zenith/-/merge_requests/139))
|
|
16
16
|
- fixed: a `List` row whose children are not all React nodes, such as react-i18next's `<Trans>` with `{{ name }}` interpolation, no longer crashes the list; `0.3.0-next.1` was affected — @wmolinari ([!158](https://gitlab.com/e-pilot/product/frontend/zenith/-/merge_requests/158)) (experiment: https://gitlab.com/e-pilot/product/frontend/zenith/-/merge_requests/158)
|
|
17
|
+
- changed: `TooltipContent` wraps long text at about 40 characters (`max-width: 40ch`) instead of stretching across the page, and spaces wrapped lines with a 1.35 line height; one-line tooltips are 4 px taller — @wmolinari ([!158](https://gitlab.com/e-pilot/product/frontend/zenith/-/merge_requests/158)) (experiment: https://gitlab.com/e-pilot/product/frontend/zenith/-/merge_requests/158)
|
|
17
18
|
- fixed: the Radix to Base UI codemod reads the parameter count of an imported handler declared with `satisfies`, so a zero-parameter handler no longer gets an event argument — @wmolinari ([!149](https://gitlab.com/e-pilot/product/frontend/zenith/-/merge_requests/149))
|
|
18
19
|
- fixed: `SortableList` keeps the lifted row under the pointer and drops it where the pointer is inside a transformed container, such as a `PopoverContent` — @josh.stewart.epilot ([!155](https://gitlab.com/e-pilot/product/frontend/zenith/-/merge_requests/155))
|
|
19
20
|
- changed: `SortableList` drag grips are named after the row's text instead of its `value`; the new `ListItem` `textValue` names rows without text — @josh.stewart.epilot ([!155](https://gitlab.com/e-pilot/product/frontend/zenith/-/merge_requests/155))
|
|
@@ -29,14 +29,16 @@ const B = ft({
|
|
|
29
29
|
popup: {
|
|
30
30
|
...q,
|
|
31
31
|
width: "fit-content",
|
|
32
|
+
// About 40 characters a line: long hints wrap instead of stretching across the page (ER-5571).
|
|
33
|
+
maxWidth: "40ch",
|
|
32
34
|
transformOrigin: "var(--transform-origin)",
|
|
33
35
|
...z.borderRadius(Tt),
|
|
34
36
|
...z.padding(wt),
|
|
35
37
|
// v1 shadow-md; elevation has no token in this package.
|
|
36
38
|
boxShadow: "0 4px 6px -1px #0000001a, 0 2px 4px -2px #0000001a",
|
|
37
39
|
fontSize: Pt,
|
|
38
|
-
// v1 leading-none
|
|
39
|
-
lineHeight: "1",
|
|
40
|
+
// Wrapped lines need room; v1's leading-none suited one-line tooltips only. No line-height token exists.
|
|
41
|
+
lineHeight: "1.35",
|
|
40
42
|
zIndex: J,
|
|
41
43
|
"&[data-variant='default']": {
|
|
42
44
|
backgroundColor: Q,
|
|
@@ -251,7 +253,7 @@ const Ut = t.forwardRef(function({ asChild: e = !1, children: n, className: r, .
|
|
|
251
253
|
id: k,
|
|
252
254
|
...P
|
|
253
255
|
}, g) {
|
|
254
|
-
const s = B(), f = rt("TooltipContent"), w = t.useContext(nt), V = ut(), it = pt(), X = t.useRef(null), [A, at] = t.useState(null), st = yt(g, at), { open: H, closeOnEscape:
|
|
256
|
+
const s = B(), f = rt("TooltipContent"), w = t.useContext(nt), V = ut(), it = pt(), X = t.useRef(null), [A, at] = t.useState(null), st = yt(g, at), { open: H, closeOnEscape: W } = f;
|
|
255
257
|
t.useEffect(() => {
|
|
256
258
|
if (!H || !A) return;
|
|
257
259
|
const l = A;
|
|
@@ -260,15 +262,15 @@ const Ut = t.forwardRef(function({ asChild: e = !1, children: n, className: r, .
|
|
|
260
262
|
function K(m) {
|
|
261
263
|
if (m.key !== "Escape" || m.defaultPrevented || m.isComposing || T[T.length - 1] !== l) return;
|
|
262
264
|
const M = m.target;
|
|
263
|
-
!(M instanceof Node) || l.contains(M) || !(l.compareDocumentPosition(M) & Node.DOCUMENT_POSITION_PRECEDING) || (m.preventDefault(),
|
|
265
|
+
!(M instanceof Node) || l.contains(M) || !(l.compareDocumentPosition(M) & Node.DOCUMENT_POSITION_PRECEDING) || (m.preventDefault(), W(m));
|
|
264
266
|
}
|
|
265
267
|
return F.addEventListener("keydown", K, !0), () => {
|
|
266
268
|
F.removeEventListener("keydown", K, !0), T.splice(T.indexOf(l), 1);
|
|
267
269
|
};
|
|
268
|
-
}, [H, A,
|
|
269
|
-
const N = k ?? f.generatedId, L = P["aria-label"],
|
|
270
|
-
t.useEffect(() => (_(
|
|
271
|
-
const
|
|
270
|
+
}, [H, A, W]);
|
|
271
|
+
const N = k ?? f.generatedId, L = P["aria-label"], Y = `${N}-label`, $ = L ? Y : N, { setDescriptionId: _ } = f;
|
|
272
|
+
t.useEffect(() => (_($), () => _(void 0)), [$, _]);
|
|
273
|
+
const j = L && /* @__PURE__ */ i("span", { id: Y, hidden: !0, children: L }), G = !a && /* @__PURE__ */ i(
|
|
272
274
|
c.Arrow,
|
|
273
275
|
{
|
|
274
276
|
ref: X,
|
|
@@ -282,14 +284,14 @@ const Ut = t.forwardRef(function({ asChild: e = !1, children: n, className: r, .
|
|
|
282
284
|
D,
|
|
283
285
|
void 0,
|
|
284
286
|
D.props.children,
|
|
285
|
-
|
|
286
|
-
|
|
287
|
+
j,
|
|
288
|
+
G
|
|
287
289
|
)
|
|
288
290
|
} : {
|
|
289
291
|
children: /* @__PURE__ */ ct(dt, { children: [
|
|
290
292
|
r,
|
|
291
|
-
|
|
292
|
-
|
|
293
|
+
j,
|
|
294
|
+
G
|
|
293
295
|
] })
|
|
294
296
|
}, Z = /* @__PURE__ */ i(
|
|
295
297
|
c.Positioner,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tooltip.js","sources":["../../../src/components/tooltip/tooltip.tsx"],"sourcesContent":["import * as React from \"react\"\n\nimport { Tooltip as TooltipPrimitive } from \"@base-ui/react/tooltip\"\nimport { mergeClasses, shorthands } from \"@epilot/zenith-runtime/v1\"\n\nimport { useAppearanceAttributes } from \"../appearance-boundary/appearance-boundary\"\nimport { useDensity } from \"../density-provider/density-provider\"\nimport { SLOT_ATTR } from \"../../renderer/contract\"\nimport { makeZenithStyles } from \"../../styles/make-styles\"\nimport { boxModel, nativeControl } from \"../../styles/host-reset\"\nimport { OVERLAY_Z_INDEX } from \"../../styles/overlay-layer\"\nimport * as tokens from \"../../tokens\"\n\nconst useStyles = makeZenithStyles({\n // For the bare native `<button>` a Trigger/Close renders. Not applied under `asChild`, where the\n // child owns its own element and two atom sets would race for the same properties.\n nativeTrigger: {\n ...nativeControl,\n },\n positioner: {\n zIndex: OVERLAY_Z_INDEX,\n },\n // Radix's `hideWhenDetached`: hide the content once its trigger is scrolled out of view.\n hideWhenDetached: {\n \"&[data-anchor-hidden]\": {\n visibility: \"hidden\",\n pointerEvents: \"none\",\n },\n },\n // No enter or exit motion: the Radix version keyed its keyframes on `data-state='open'`, a value\n // Radix's tooltip never sets (it sets `delayed-open` or `instant-open`), so it never animated.\n popup: {\n ...boxModel,\n width: \"fit-content\",\n transformOrigin: \"var(--transform-origin)\",\n ...shorthands.borderRadius(tokens.radiusLg),\n ...shorthands.padding(tokens.spacingElement2),\n // v1 shadow-md; elevation has no token in this package.\n boxShadow: \"0 4px 6px -1px #0000001a, 0 2px 4px -2px #0000001a\",\n fontSize: tokens.textXs,\n // v1 leading-none; no line-height token exists.\n lineHeight: \"1\",\n zIndex: OVERLAY_Z_INDEX,\n \"&[data-variant='default']\": {\n backgroundColor: tokens.gray12,\n color: tokens.gray1,\n },\n \"&[data-variant='destructive']\": {\n backgroundColor: tokens.errorA12,\n color: tokens.error1,\n },\n },\n // Base UI places the arrow on the cross axis only; the anchored edge is set per side here. The\n // diamond's centre sits 2px inside the content's edge, where Radix's arrow wrapper put it.\n arrow: {\n ...boxModel,\n zIndex: 50,\n width: \"0.625rem\",\n height: \"0.625rem\",\n ...shorthands.borderRadius(\"2px\"),\n \"&[data-side='top']\": {\n top: \"100%\",\n transform: \"translateY(calc(-50% - 2px)) rotate(45deg)\",\n },\n \"&[data-side='bottom']\": {\n top: 0,\n transform: \"translateY(calc(-50% + 2px)) rotate(45deg)\",\n },\n \"&[data-side='left']\": {\n left: \"100%\",\n transform: \"translateX(calc(-50% - 2px)) rotate(45deg)\",\n },\n \"&[data-side='right']\": {\n left: 0,\n transform: \"translateX(calc(-50% + 2px)) rotate(45deg)\",\n },\n // Radix hid the arrow when it could not point at the trigger's centre.\n \"&[data-uncentered]\": {\n visibility: \"hidden\",\n },\n \"&[data-variant='default']\": {\n backgroundColor: tokens.gray12,\n },\n \"&[data-variant='destructive']\": {\n backgroundColor: tokens.error12,\n },\n },\n})\n\n// A single child can arrive wrapped in a one-element array depending on the JSX runtime (MDX call\n// sites do this). Radix's Slot normalised that, so the `asChild` shim has to as well.\nfunction onlySlotChild(children: React.ReactNode) {\n const elements = React.Children.toArray(children).filter(React.isValidElement)\n return elements.length === 1 ? elements[0] : undefined\n}\n\n/**\n * Radix's `asChild` over Base UI's `render`: the single child element becomes the part and keeps\n * its own children, since Base UI lets the rendered element's props win the merge.\n */\nfunction slotProps(asChild: boolean, children: React.ReactNode) {\n const child = asChild ? onlySlotChild(children) : undefined\n return child ? { render: child } : { children }\n}\n\n/**\n * A part's props as they were under Radix: its native element's own (DOM attributes, React's\n * handler types, a `CSSProperties` style, a string `className`, `ref`) plus `asChild`. Base UI's\n * prop types widen `style` and `className` to functions of the part's state, wrap every handler's\n * event in `BaseUIEvent` and add props of their own; none of that reaches the public surface.\n */\ntype NativePartProps<Tag extends \"button\" | \"div\"> =\n React.ComponentProps<Tag> & {\n /** Renders the single child element as this part, merging its props and behaviour onto it. */\n asChild?: boolean\n }\n\nfunction useMergedRef<T>(a: React.Ref<T> | undefined, b: React.Ref<T>) {\n return React.useCallback(\n (node: T | null) => {\n for (const ref of [a, b]) {\n if (typeof ref === \"function\") ref(node)\n else if (ref) (ref as React.MutableRefObject<T | null>).current = node\n }\n },\n [a, b]\n )\n}\n\n/**\n * What `onOpenChange` receives as its second argument: Base UI's change details, declared in\n * Zenith. Base UI's own type would put its internals in the published declarations, which\n * TypeScript 4 consumers cannot parse. `event` narrows with `reason`, as it does in Base UI.\n */\ntype TooltipOpenChangeDetails = (\n | { reason: \"trigger-hover\"; event: MouseEvent }\n | { reason: \"trigger-focus\"; event: FocusEvent }\n | {\n reason: \"trigger-press\"\n event: MouseEvent | PointerEvent | TouchEvent | KeyboardEvent\n }\n | { reason: \"outside-press\"; event: MouseEvent | PointerEvent | TouchEvent }\n | { reason: \"escape-key\"; event: KeyboardEvent }\n | { reason: \"disabled\"; event: Event }\n | { reason: \"imperative-action\"; event: Event }\n | { reason: \"none\"; event: Event }\n) & {\n /** Keeps the tooltip in its current state. */\n cancel: () => void\n /** Lets the event propagate where the tooltip would otherwise stop it. */\n allowPropagation: () => void\n isCanceled: boolean\n isPropagationAllowed: boolean\n /** The element that caused the change, if any. */\n trigger: Element | undefined\n /** Keeps the tooltip's elements mounted after it closes. */\n preventUnmountOnClose: () => void\n}\n\n/** Base UI's details of the imperative close, reported as the Escape that caused it. */\nfunction escapeDetails(\n details: TooltipOpenChangeDetails,\n event: KeyboardEvent\n): TooltipOpenChangeDetails {\n return {\n reason: \"escape-key\",\n event,\n cancel: () => details.cancel(),\n allowPropagation: () => details.allowPropagation(),\n get isCanceled() {\n return details.isCanceled\n },\n get isPropagationAllowed() {\n return details.isPropagationAllowed\n },\n trigger: details.trigger,\n preventUnmountOnClose: () => details.preventUnmountOnClose(),\n }\n}\n\n// The open tooltips' popups, in the order they opened. Escape goes to the last one, as it went to\n// Radix's topmost layer.\nconst openPopups: HTMLElement[] = []\n\n// Radix's provider-level `disableHoverableContent`, which Base UI only takes per tooltip, and the\n// skip delay a tooltip with its own `delayDuration` carries into its own Base UI provider.\nconst TooltipProviderContext = React.createContext<{\n skipDelayDuration?: number\n disableHoverableContent?: boolean\n}>({})\n\nexport type TooltipProviderProps = {\n children: React.ReactNode\n /** How long the pointer rests on a trigger before its tooltip opens, in ms. Defaults to 0. */\n delayDuration?: number\n /** How soon after one tooltip closes the next one opens without a delay, in ms. Defaults to 300. */\n skipDelayDuration?: number\n /** Closes tooltips as soon as the pointer leaves the trigger, even towards the content. */\n disableHoverableContent?: boolean\n}\n\nexport const TooltipProvider = React.forwardRef<\n HTMLElement,\n TooltipProviderProps\n>(function TooltipProvider(\n {\n children,\n delayDuration = 0,\n skipDelayDuration = 300,\n disableHoverableContent,\n },\n _ref\n) {\n const value = React.useMemo(\n () => ({ skipDelayDuration, disableHoverableContent }),\n [skipDelayDuration, disableHoverableContent]\n )\n\n return (\n <TooltipProviderContext.Provider value={value}>\n <TooltipPrimitive.Provider\n data-slot=\"tooltip-provider\"\n delay={delayDuration}\n timeout={skipDelayDuration}\n >\n {children}\n </TooltipPrimitive.Provider>\n </TooltipProviderContext.Provider>\n )\n})\n\n// What the trigger and the content share through the root: the open state, the id of the element\n// that describes the trigger (the content, or its label) for `aria-describedby`, and the close the\n// content's Escape listener calls.\ntype TooltipContextValue = {\n open: boolean\n generatedId: string\n descriptionId: string\n setDescriptionId: (id: string | undefined) => void\n closeOnEscape: (event: KeyboardEvent) => void\n}\n\nconst TooltipContext = React.createContext<TooltipContextValue | null>(null)\n\nexport type TooltipProps = {\n children?: React.ReactNode\n open?: boolean\n defaultOpen?: boolean\n /**\n * Called when the tooltip opens or closes. `eventDetails.reason` says why (`trigger-hover`,\n * `trigger-focus`, `trigger-press`, `escape-key`, `outside-press`) and `eventDetails.cancel()`\n * keeps the tooltip in its current state.\n */\n onOpenChange?: (open: boolean, eventDetails: TooltipOpenChangeDetails) => void\n /** This tooltip's hover delay in ms, overriding the provider's. */\n delayDuration?: number\n /** Closes this tooltip as soon as the pointer leaves the trigger, even towards the content. */\n disableHoverableContent?: boolean\n}\n\nexport const Tooltip = React.forwardRef<HTMLElement, TooltipProps>(\n function Tooltip(\n {\n children,\n open: openProp,\n defaultOpen = false,\n onOpenChange,\n delayDuration,\n disableHoverableContent,\n },\n _ref\n ) {\n const provider = React.useContext(TooltipProviderContext)\n // Base UI is always controlled from here, so the trigger's `aria-describedby` follows the\n // same open state Base UI renders.\n const [uncontrolledOpen, setUncontrolledOpen] = React.useState(defaultOpen)\n const open = openProp ?? uncontrolledOpen\n const generatedId = React.useId()\n const [descriptionId, setDescriptionId] = React.useState<string>()\n const actionsRef = React.useRef<TooltipPrimitive.Root.Actions>(null)\n // Set while the content's Escape listener closes the tooltip, so `onOpenChange` reports it.\n const escapeRef = React.useRef<KeyboardEvent | null>(null)\n const closeOnEscape = React.useCallback((event: KeyboardEvent) => {\n escapeRef.current = event\n try {\n actionsRef.current?.close()\n } finally {\n escapeRef.current = null\n }\n }, [])\n\n const context = React.useMemo(\n () => ({\n open,\n generatedId,\n descriptionId: descriptionId ?? generatedId,\n setDescriptionId,\n closeOnEscape,\n }),\n [open, generatedId, descriptionId, closeOnEscape]\n )\n\n const root = (\n <TooltipContext.Provider value={context}>\n <TooltipPrimitive.Root\n data-slot=\"tooltip\"\n open={open}\n actionsRef={actionsRef}\n onOpenChange={(nextOpen, baseDetails) => {\n const escape = escapeRef.current\n const eventDetails = escape\n ? escapeDetails(baseDetails, escape)\n : baseDetails\n // An Escape that arrives prevented was taken already: by this tooltip's own listener,\n // or by a layer above it. Base UI dismisses regardless, so one Escape would close two.\n if (\n !escape &&\n eventDetails.reason === \"escape-key\" &&\n eventDetails.event.defaultPrevented\n ) {\n baseDetails.cancel()\n return\n }\n onOpenChange?.(nextOpen, eventDetails)\n if (!baseDetails.isCanceled) setUncontrolledOpen(nextOpen)\n }}\n disableHoverablePopup={\n disableHoverableContent ?? provider.disableHoverableContent\n }\n >\n {children}\n </TooltipPrimitive.Root>\n </TooltipContext.Provider>\n )\n\n // Base UI ignores a trigger's own delay while its provider's is 0, and Zenith's provider\n // defaults to 0, so a tooltip with its own delay gets a provider of its own. It leaves the\n // surrounding provider's skip-delay group, which Radix kept it in.\n return delayDuration === undefined ? (\n root\n ) : (\n <TooltipPrimitive.Provider\n delay={delayDuration}\n timeout={provider.skipDelayDuration ?? 300}\n >\n {root}\n </TooltipPrimitive.Provider>\n )\n }\n)\n\nfunction useTooltipContext(part: string) {\n const context = React.useContext(TooltipContext)\n if (!context) throw new Error(`\\`${part}\\` must be used within \\`Tooltip\\``)\n return context\n}\n\nexport type TooltipTriggerProps = NativePartProps<\"button\">\n\nexport const TooltipTrigger = React.forwardRef<\n HTMLButtonElement,\n TooltipTriggerProps\n>(function TooltipTrigger(\n { asChild = false, children, className, ...props },\n ref\n) {\n const styles = useStyles()\n const tooltip = useTooltipContext(\"TooltipTrigger\")\n\n return (\n <TooltipPrimitive.Trigger\n ref={ref}\n data-slot=\"tooltip-trigger\"\n {...{ [SLOT_ATTR]: \"tooltip-trigger\" }}\n // Base UI links nothing; Radix described the trigger by the content while it was open.\n aria-describedby={tooltip.open ? tooltip.descriptionId : undefined}\n className={mergeClasses(!asChild && styles.nativeTrigger, className)}\n {...props}\n {...slotProps(asChild, children)}\n />\n )\n})\n\n// Lets TooltipContent supply Base UI's required Portal itself when no TooltipPortal wraps it, as\n// Radix rendered content without one.\nconst TooltipPortalPresenceContext = React.createContext(false)\n\nexport type TooltipPortalProps = {\n children?: React.ReactNode\n /** The element the content portals into; `document.body` when omitted or null. */\n container?: Element | DocumentFragment | null\n /** Keeps the content mounted while the tooltip is closed. */\n forceMount?: true\n}\n\nexport const TooltipPortal = React.forwardRef<HTMLElement, TooltipPortalProps>(\n function TooltipPortal({ container, forceMount, ...props }, ref) {\n return (\n <TooltipPortalPresenceContext.Provider value={true}>\n <TooltipPrimitive.Portal\n // Base UI types the ref as its portal div, which any HTMLElement ref can hold.\n ref={ref as React.Ref<HTMLDivElement>}\n data-slot=\"tooltip-portal\"\n {...{ [SLOT_ATTR]: \"tooltip-portal\" }}\n // Radix took any Element or DocumentFragment, null meaning the body. Base UI hands a\n // node straight to createPortal, which takes either, but reads null as \"wait for one\".\n container={(container ?? undefined) as HTMLElement | undefined}\n keepMounted={forceMount}\n {...props}\n />\n </TooltipPortalPresenceContext.Provider>\n )\n }\n)\n\ntype Side = \"top\" | \"right\" | \"bottom\" | \"left\"\n\nexport type TooltipContentProps = NativePartProps<\"div\"> & {\n /** The side of the trigger the content opens on. Flips when it would not fit. Defaults to top. */\n side?: Side\n /** Distance from the trigger in px, on top of the arrow's own height. Defaults to 0. */\n sideOffset?: number\n /** Alignment against the trigger. Defaults to center. */\n align?: \"start\" | \"center\" | \"end\"\n /** Offset from the `start` or `end` alignment in px. Defaults to 0. */\n alignOffset?: number\n /** Distance between the arrow and the content's corners in px. Defaults to 0. */\n arrowPadding?: number\n /** Flips and shifts the content to keep it in view. Defaults to true. */\n avoidCollisions?: boolean\n /** Elements the content must stay inside, besides the viewport. */\n collisionBoundary?: Element | null | Array<Element | null>\n /** Distance in px from the boundary edges before the content avoids them. Defaults to 0. */\n collisionPadding?: number | Partial<Record<Side, number>>\n /** `partial` keeps the content attached to its trigger; `always` keeps it in the boundary. */\n sticky?: \"partial\" | \"always\"\n /** Hides the content once its trigger is scrolled out of view. */\n hideWhenDetached?: boolean\n /** Accepted for compatibility; the position follows layout changes either way. */\n updatePositionStrategy?: \"optimized\" | \"always\"\n /**\n * Keeps the content mounted while the tooltip is closed. Inside TooltipPortal, the portal's\n * `forceMount` decides.\n */\n forceMount?: true\n /** Hides the arrow that points at the trigger. */\n hideArrow?: boolean\n variant?: \"default\" | \"destructive\"\n}\n\n// Radix's collision handling: flip to the opposite side or alignment, never to the other axis.\nconst AVOID_COLLISIONS = {\n side: \"flip\",\n align: \"flip\",\n fallbackAxisSide: \"none\",\n} as const\nconst IGNORE_COLLISIONS = {\n side: \"none\",\n align: \"none\",\n fallbackAxisSide: \"none\",\n} as const\n\nexport const TooltipContent = React.forwardRef<\n HTMLDivElement,\n TooltipContentProps\n>(function TooltipContent(\n {\n asChild = false,\n className,\n children,\n hideArrow = false,\n variant = \"default\",\n side = \"top\",\n sideOffset = 0,\n align = \"center\",\n alignOffset = 0,\n arrowPadding = 0,\n avoidCollisions = true,\n collisionBoundary = [],\n collisionPadding = 0,\n sticky = \"partial\",\n hideWhenDetached = false,\n updatePositionStrategy: _updatePositionStrategy,\n forceMount,\n id: idProp,\n ...props\n },\n ref\n) {\n const styles = useStyles()\n const tooltip = useTooltipContext(\"TooltipContent\")\n const hasPortal = React.useContext(TooltipPortalPresenceContext)\n // DENSITY-SPEC.md §4.4 — portal content boundary; see dialog.tsx's identical comment. Tooltip\n // content rarely nests density-consuming children, but the mechanism is applied uniformly across\n // every portal-content component rather than special-cased per component.\n const override = useDensity()\n // SPEC.md §2 rule 3 — the same portal asymmetry, for the appearance pair: re-stamp the\n // nearest explicit AppearanceBoundary's mode+surface, or neither attribute when there is\n // none, leaving live shell inheritance in place.\n const appearance = useAppearanceAttributes()\n const arrowRef = React.useRef<HTMLDivElement>(null)\n const [popup, setPopup] = React.useState<HTMLDivElement | null>(null)\n const popupRef = useMergedRef(ref, setPopup)\n\n // Radix's tooltip was the topmost layer while open, so Escape closed it before anything under it:\n // a Dialog or a Radix menu it sits in, or a control. Base UI's listens later, after a Dialog has\n // taken the key. Taking it on the window in the capture phase, before Radix's layers and Zenith's\n // Base UI roots see it, and preventing it makes them leave it alone.\n const { open, closeOnEscape } = tooltip\n React.useEffect(() => {\n if (!open || !popup) return\n const element = popup\n openPopups.push(element)\n const view = element.ownerDocument.defaultView ?? window\n function onKeyDown(event: KeyboardEvent) {\n if (event.key !== \"Escape\" || event.defaultPrevented || event.isComposing)\n return\n if (openPopups[openPopups.length - 1] !== element) return\n // Only an Escape from under the tooltip, earlier in the document. From inside it (a layer\n // nested in the content, or the content itself) Base UI's own handler runs first; from later\n // in the document, a layer opened over the tooltip takes its own.\n const target = event.target\n if (\n !(target instanceof Node) ||\n element.contains(target) ||\n !(\n element.compareDocumentPosition(target) &\n Node.DOCUMENT_POSITION_PRECEDING\n )\n )\n return\n event.preventDefault()\n closeOnEscape(event)\n }\n view.addEventListener(\"keydown\", onKeyDown, true)\n return () => {\n view.removeEventListener(\"keydown\", onKeyDown, true)\n openPopups.splice(openPopups.indexOf(element), 1)\n }\n }, [open, popup, closeOnEscape])\n\n // The trigger's `aria-describedby` points here, so a caller's own id has to reach it. Radix\n // described the trigger by `aria-label` when one was given; a hidden node carries it, because\n // not every accessibility engine reads the `aria-label` of a describing element.\n const popupId = idProp ?? tooltip.generatedId\n const ariaLabel = props[\"aria-label\"]\n const labelId = `${popupId}-label`\n const descriptionId = ariaLabel ? labelId : popupId\n const { setDescriptionId } = tooltip\n React.useEffect(() => {\n setDescriptionId(descriptionId)\n return () => setDescriptionId(undefined)\n }, [descriptionId, setDescriptionId])\n\n const label = ariaLabel && (\n <span id={labelId} hidden>\n {ariaLabel}\n </span>\n )\n\n const arrow = !hideArrow && (\n <TooltipPrimitive.Arrow\n ref={arrowRef}\n data-slot=\"tooltip-arrow\"\n {...{ [SLOT_ATTR]: \"tooltip-arrow\" }}\n data-variant={variant}\n className={styles.arrow}\n />\n )\n const child = asChild ? onlySlotChild(children) : undefined\n // The child keeps its own children, so the label and the arrow join them there.\n const content = child\n ? {\n render: React.cloneElement(\n child,\n undefined,\n (child.props as { children?: React.ReactNode }).children,\n label,\n arrow\n ),\n }\n : {\n children: (\n <>\n {children}\n {label}\n {arrow}\n </>\n ),\n }\n\n const positioner = (\n <TooltipPrimitive.Positioner\n className={mergeClasses(\n styles.positioner,\n hideWhenDetached && styles.hideWhenDetached\n )}\n positionMethod=\"fixed\"\n side={side}\n // Radix moved the content away by the arrow's own height on top of `sideOffset`.\n sideOffset={() => sideOffset + (arrowRef.current?.offsetHeight ?? 0)}\n align={align}\n // Radix applied the offset to `start` and `end` only; Base UI also shifts centred content.\n alignOffset={align === \"center\" ? 0 : alignOffset}\n arrowPadding={arrowPadding}\n // Radix's default is the viewport alone, not every clipping ancestor.\n collisionBoundary={\n Array.isArray(collisionBoundary)\n ? collisionBoundary.filter((boundary) => boundary !== null)\n : collisionBoundary === null\n ? []\n : collisionBoundary\n }\n collisionPadding={collisionPadding}\n sticky={sticky === \"always\"}\n collisionAvoidance={\n avoidCollisions ? AVOID_COLLISIONS : IGNORE_COLLISIONS\n }\n >\n <TooltipPrimitive.Popup\n ref={popupRef}\n id={popupId}\n // Base UI renders no role; Radix exposed the content as role=\"tooltip\".\n role=\"tooltip\"\n data-slot=\"tooltip-content\"\n {...{ [SLOT_ATTR]: \"tooltip-content\" }}\n {...(override !== undefined ? { \"data-density\": override } : {})}\n {...appearance}\n data-variant={variant}\n className={mergeClasses(styles.popup, className)}\n {...props}\n {...content}\n />\n </TooltipPrimitive.Positioner>\n )\n\n // Base UI's Positioner requires a Portal ancestor; Radix rendered inline without one.\n return hasPortal ? (\n positioner\n ) : (\n <TooltipPrimitive.Portal keepMounted={forceMount}>\n {positioner}\n </TooltipPrimitive.Portal>\n )\n})\n"],"names":["useStyles","makeZenithStyles","nativeControl","OVERLAY_Z_INDEX","boxModel","shorthands","tokens.radiusLg","tokens.spacingElement2","tokens.textXs","tokens.gray12","tokens.gray1","tokens.errorA12","tokens.error1","tokens.error12","onlySlotChild","children","elements","React","slotProps","asChild","child","useMergedRef","a","b","node","ref","escapeDetails","details","event","openPopups","TooltipProviderContext","TooltipProvider","delayDuration","skipDelayDuration","disableHoverableContent","_ref","value","jsx","TooltipPrimitive","TooltipContext","Tooltip","openProp","defaultOpen","onOpenChange","provider","uncontrolledOpen","setUncontrolledOpen","open","generatedId","descriptionId","setDescriptionId","actionsRef","escapeRef","closeOnEscape","_a","context","root","nextOpen","baseDetails","escape","eventDetails","useTooltipContext","part","TooltipTrigger","className","props","styles","tooltip","SLOT_ATTR","mergeClasses","TooltipPortalPresenceContext","TooltipPortal","container","forceMount","AVOID_COLLISIONS","IGNORE_COLLISIONS","TooltipContent","hideArrow","variant","side","sideOffset","align","alignOffset","arrowPadding","avoidCollisions","collisionBoundary","collisionPadding","sticky","hideWhenDetached","_updatePositionStrategy","idProp","hasPortal","override","useDensity","appearance","useAppearanceAttributes","arrowRef","popup","setPopup","popupRef","element","view","onKeyDown","target","popupId","ariaLabel","labelId","label","arrow","content","jsxs","Fragment","positioner","boundary"],"mappings":";;;;;;;;;;AAaA,MAAMA,IAAYC,GAAiB;AAAA;AAAA;AAAA,EAGjC,eAAe;AAAA,IACb,GAAGC;AAAA,EAAA;AAAA,EAEL,YAAY;AAAA,IACV,QAAQC;AAAA,E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aAAU;AAAA,UACJ,CAACpC,CAAS,GAAG;AAAA,UAClB,GAAIwB,MAAa,SAAY,EAAE,gBAAgBA,EAAA,IAAa,CAAA;AAAA,UAC5D,GAAGE;AAAA,UACJ,gBAAchB;AAAA,UACd,WAAWT,EAAaH,EAAO,OAAOF,CAAS;AAAA,UAC9C,GAAGC;AAAA,UACH,GAAG4C;AAAA,QAAA;AAAA,MAAA;AAAA,IACN;AAAA,EAAA;AAKJ,SAAOlB,IACLqB,IAEA,gBAAA3E,EAACC,EAAiB,QAAjB,EAAwB,aAAamC,GACnC,UAAAuC,GACH;AAEJ,CAAC;"}
|
|
1
|
+
{"version":3,"file":"tooltip.js","sources":["../../../src/components/tooltip/tooltip.tsx"],"sourcesContent":["import * as React from \"react\"\n\nimport { Tooltip as TooltipPrimitive } from \"@base-ui/react/tooltip\"\nimport { mergeClasses, shorthands } from \"@epilot/zenith-runtime/v1\"\n\nimport { useAppearanceAttributes } from \"../appearance-boundary/appearance-boundary\"\nimport { useDensity } from \"../density-provider/density-provider\"\nimport { SLOT_ATTR } from \"../../renderer/contract\"\nimport { makeZenithStyles } from \"../../styles/make-styles\"\nimport { boxModel, nativeControl } from \"../../styles/host-reset\"\nimport { OVERLAY_Z_INDEX } from \"../../styles/overlay-layer\"\nimport * as tokens from \"../../tokens\"\n\nconst useStyles = makeZenithStyles({\n // For the bare native `<button>` a Trigger/Close renders. Not applied under `asChild`, where the\n // child owns its own element and two atom sets would race for the same properties.\n nativeTrigger: {\n ...nativeControl,\n },\n positioner: {\n zIndex: OVERLAY_Z_INDEX,\n },\n // Radix's `hideWhenDetached`: hide the content once its trigger is scrolled out of view.\n hideWhenDetached: {\n \"&[data-anchor-hidden]\": {\n visibility: \"hidden\",\n pointerEvents: \"none\",\n },\n },\n // No enter or exit motion: the Radix version keyed its keyframes on `data-state='open'`, a value\n // Radix's tooltip never sets (it sets `delayed-open` or `instant-open`), so it never animated.\n popup: {\n ...boxModel,\n width: \"fit-content\",\n // About 40 characters a line: long hints wrap instead of stretching across the page (ER-5571).\n maxWidth: \"40ch\",\n transformOrigin: \"var(--transform-origin)\",\n ...shorthands.borderRadius(tokens.radiusLg),\n ...shorthands.padding(tokens.spacingElement2),\n // v1 shadow-md; elevation has no token in this package.\n boxShadow: \"0 4px 6px -1px #0000001a, 0 2px 4px -2px #0000001a\",\n fontSize: tokens.textXs,\n // Wrapped lines need room; v1's leading-none suited one-line tooltips only. No line-height token exists.\n lineHeight: \"1.35\",\n zIndex: OVERLAY_Z_INDEX,\n \"&[data-variant='default']\": {\n backgroundColor: tokens.gray12,\n color: tokens.gray1,\n },\n \"&[data-variant='destructive']\": {\n backgroundColor: tokens.errorA12,\n color: tokens.error1,\n },\n },\n // Base UI places the arrow on the cross axis only; the anchored edge is set per side here. The\n // diamond's centre sits 2px inside the content's edge, where Radix's arrow wrapper put it.\n arrow: {\n ...boxModel,\n zIndex: 50,\n width: \"0.625rem\",\n height: \"0.625rem\",\n ...shorthands.borderRadius(\"2px\"),\n \"&[data-side='top']\": {\n top: \"100%\",\n transform: \"translateY(calc(-50% - 2px)) rotate(45deg)\",\n },\n \"&[data-side='bottom']\": {\n top: 0,\n transform: \"translateY(calc(-50% + 2px)) rotate(45deg)\",\n },\n \"&[data-side='left']\": {\n left: \"100%\",\n transform: \"translateX(calc(-50% - 2px)) rotate(45deg)\",\n },\n \"&[data-side='right']\": {\n left: 0,\n transform: \"translateX(calc(-50% + 2px)) rotate(45deg)\",\n },\n // Radix hid the arrow when it could not point at the trigger's centre.\n \"&[data-uncentered]\": {\n visibility: \"hidden\",\n },\n \"&[data-variant='default']\": {\n backgroundColor: tokens.gray12,\n },\n \"&[data-variant='destructive']\": {\n backgroundColor: tokens.error12,\n },\n },\n})\n\n// A single child can arrive wrapped in a one-element array depending on the JSX runtime (MDX call\n// sites do this). Radix's Slot normalised that, so the `asChild` shim has to as well.\nfunction onlySlotChild(children: React.ReactNode) {\n const elements = React.Children.toArray(children).filter(React.isValidElement)\n return elements.length === 1 ? elements[0] : undefined\n}\n\n/**\n * Radix's `asChild` over Base UI's `render`: the single child element becomes the part and keeps\n * its own children, since Base UI lets the rendered element's props win the merge.\n */\nfunction slotProps(asChild: boolean, children: React.ReactNode) {\n const child = asChild ? onlySlotChild(children) : undefined\n return child ? { render: child } : { children }\n}\n\n/**\n * A part's props as they were under Radix: its native element's own (DOM attributes, React's\n * handler types, a `CSSProperties` style, a string `className`, `ref`) plus `asChild`. Base UI's\n * prop types widen `style` and `className` to functions of the part's state, wrap every handler's\n * event in `BaseUIEvent` and add props of their own; none of that reaches the public surface.\n */\ntype NativePartProps<Tag extends \"button\" | \"div\"> =\n React.ComponentProps<Tag> & {\n /** Renders the single child element as this part, merging its props and behaviour onto it. */\n asChild?: boolean\n }\n\nfunction useMergedRef<T>(a: React.Ref<T> | undefined, b: React.Ref<T>) {\n return React.useCallback(\n (node: T | null) => {\n for (const ref of [a, b]) {\n if (typeof ref === \"function\") ref(node)\n else if (ref) (ref as React.MutableRefObject<T | null>).current = node\n }\n },\n [a, b]\n )\n}\n\n/**\n * What `onOpenChange` receives as its second argument: Base UI's change details, declared in\n * Zenith. Base UI's own type would put its internals in the published declarations, which\n * TypeScript 4 consumers cannot parse. `event` narrows with `reason`, as it does in Base UI.\n */\ntype TooltipOpenChangeDetails = (\n | { reason: \"trigger-hover\"; event: MouseEvent }\n | { reason: \"trigger-focus\"; event: FocusEvent }\n | {\n reason: \"trigger-press\"\n event: MouseEvent | PointerEvent | TouchEvent | KeyboardEvent\n }\n | { reason: \"outside-press\"; event: MouseEvent | PointerEvent | TouchEvent }\n | { reason: \"escape-key\"; event: KeyboardEvent }\n | { reason: \"disabled\"; event: Event }\n | { reason: \"imperative-action\"; event: Event }\n | { reason: \"none\"; event: Event }\n) & {\n /** Keeps the tooltip in its current state. */\n cancel: () => void\n /** Lets the event propagate where the tooltip would otherwise stop it. */\n allowPropagation: () => void\n isCanceled: boolean\n isPropagationAllowed: boolean\n /** The element that caused the change, if any. */\n trigger: Element | undefined\n /** Keeps the tooltip's elements mounted after it closes. */\n preventUnmountOnClose: () => void\n}\n\n/** Base UI's details of the imperative close, reported as the Escape that caused it. */\nfunction escapeDetails(\n details: TooltipOpenChangeDetails,\n event: KeyboardEvent\n): TooltipOpenChangeDetails {\n return {\n reason: \"escape-key\",\n event,\n cancel: () => details.cancel(),\n allowPropagation: () => details.allowPropagation(),\n get isCanceled() {\n return details.isCanceled\n },\n get isPropagationAllowed() {\n return details.isPropagationAllowed\n },\n trigger: details.trigger,\n preventUnmountOnClose: () => details.preventUnmountOnClose(),\n }\n}\n\n// The open tooltips' popups, in the order they opened. Escape goes to the last one, as it went to\n// Radix's topmost layer.\nconst openPopups: HTMLElement[] = []\n\n// Radix's provider-level `disableHoverableContent`, which Base UI only takes per tooltip, and the\n// skip delay a tooltip with its own `delayDuration` carries into its own Base UI provider.\nconst TooltipProviderContext = React.createContext<{\n skipDelayDuration?: number\n disableHoverableContent?: boolean\n}>({})\n\nexport type TooltipProviderProps = {\n children: React.ReactNode\n /** How long the pointer rests on a trigger before its tooltip opens, in ms. Defaults to 0. */\n delayDuration?: number\n /** How soon after one tooltip closes the next one opens without a delay, in ms. Defaults to 300. */\n skipDelayDuration?: number\n /** Closes tooltips as soon as the pointer leaves the trigger, even towards the content. */\n disableHoverableContent?: boolean\n}\n\nexport const TooltipProvider = React.forwardRef<\n HTMLElement,\n TooltipProviderProps\n>(function TooltipProvider(\n {\n children,\n delayDuration = 0,\n skipDelayDuration = 300,\n disableHoverableContent,\n },\n _ref\n) {\n const value = React.useMemo(\n () => ({ skipDelayDuration, disableHoverableContent }),\n [skipDelayDuration, disableHoverableContent]\n )\n\n return (\n <TooltipProviderContext.Provider value={value}>\n <TooltipPrimitive.Provider\n data-slot=\"tooltip-provider\"\n delay={delayDuration}\n timeout={skipDelayDuration}\n >\n {children}\n </TooltipPrimitive.Provider>\n </TooltipProviderContext.Provider>\n )\n})\n\n// What the trigger and the content share through the root: the open state, the id of the element\n// that describes the trigger (the content, or its label) for `aria-describedby`, and the close the\n// content's Escape listener calls.\ntype TooltipContextValue = {\n open: boolean\n generatedId: string\n descriptionId: string\n setDescriptionId: (id: string | undefined) => void\n closeOnEscape: (event: KeyboardEvent) => void\n}\n\nconst TooltipContext = React.createContext<TooltipContextValue | null>(null)\n\nexport type TooltipProps = {\n children?: React.ReactNode\n open?: boolean\n defaultOpen?: boolean\n /**\n * Called when the tooltip opens or closes. `eventDetails.reason` says why (`trigger-hover`,\n * `trigger-focus`, `trigger-press`, `escape-key`, `outside-press`) and `eventDetails.cancel()`\n * keeps the tooltip in its current state.\n */\n onOpenChange?: (open: boolean, eventDetails: TooltipOpenChangeDetails) => void\n /** This tooltip's hover delay in ms, overriding the provider's. */\n delayDuration?: number\n /** Closes this tooltip as soon as the pointer leaves the trigger, even towards the content. */\n disableHoverableContent?: boolean\n}\n\nexport const Tooltip = React.forwardRef<HTMLElement, TooltipProps>(\n function Tooltip(\n {\n children,\n open: openProp,\n defaultOpen = false,\n onOpenChange,\n delayDuration,\n disableHoverableContent,\n },\n _ref\n ) {\n const provider = React.useContext(TooltipProviderContext)\n // Base UI is always controlled from here, so the trigger's `aria-describedby` follows the\n // same open state Base UI renders.\n const [uncontrolledOpen, setUncontrolledOpen] = React.useState(defaultOpen)\n const open = openProp ?? uncontrolledOpen\n const generatedId = React.useId()\n const [descriptionId, setDescriptionId] = React.useState<string>()\n const actionsRef = React.useRef<TooltipPrimitive.Root.Actions>(null)\n // Set while the content's Escape listener closes the tooltip, so `onOpenChange` reports it.\n const escapeRef = React.useRef<KeyboardEvent | null>(null)\n const closeOnEscape = React.useCallback((event: KeyboardEvent) => {\n escapeRef.current = event\n try {\n actionsRef.current?.close()\n } finally {\n escapeRef.current = null\n }\n }, [])\n\n const context = React.useMemo(\n () => ({\n open,\n generatedId,\n descriptionId: descriptionId ?? generatedId,\n setDescriptionId,\n closeOnEscape,\n }),\n [open, generatedId, descriptionId, closeOnEscape]\n )\n\n const root = (\n <TooltipContext.Provider value={context}>\n <TooltipPrimitive.Root\n data-slot=\"tooltip\"\n open={open}\n actionsRef={actionsRef}\n onOpenChange={(nextOpen, baseDetails) => {\n const escape = escapeRef.current\n const eventDetails = escape\n ? escapeDetails(baseDetails, escape)\n : baseDetails\n // An Escape that arrives prevented was taken already: by this tooltip's own listener,\n // or by a layer above it. Base UI dismisses regardless, so one Escape would close two.\n if (\n !escape &&\n eventDetails.reason === \"escape-key\" &&\n eventDetails.event.defaultPrevented\n ) {\n baseDetails.cancel()\n return\n }\n onOpenChange?.(nextOpen, eventDetails)\n if (!baseDetails.isCanceled) setUncontrolledOpen(nextOpen)\n }}\n disableHoverablePopup={\n disableHoverableContent ?? provider.disableHoverableContent\n }\n >\n {children}\n </TooltipPrimitive.Root>\n </TooltipContext.Provider>\n )\n\n // Base UI ignores a trigger's own delay while its provider's is 0, and Zenith's provider\n // defaults to 0, so a tooltip with its own delay gets a provider of its own. It leaves the\n // surrounding provider's skip-delay group, which Radix kept it in.\n return delayDuration === undefined ? (\n root\n ) : (\n <TooltipPrimitive.Provider\n delay={delayDuration}\n timeout={provider.skipDelayDuration ?? 300}\n >\n {root}\n </TooltipPrimitive.Provider>\n )\n }\n)\n\nfunction useTooltipContext(part: string) {\n const context = React.useContext(TooltipContext)\n if (!context) throw new Error(`\\`${part}\\` must be used within \\`Tooltip\\``)\n return context\n}\n\nexport type TooltipTriggerProps = NativePartProps<\"button\">\n\nexport const TooltipTrigger = React.forwardRef<\n HTMLButtonElement,\n TooltipTriggerProps\n>(function TooltipTrigger(\n { asChild = false, children, className, ...props },\n ref\n) {\n const styles = useStyles()\n const tooltip = useTooltipContext(\"TooltipTrigger\")\n\n return (\n <TooltipPrimitive.Trigger\n ref={ref}\n data-slot=\"tooltip-trigger\"\n {...{ [SLOT_ATTR]: \"tooltip-trigger\" }}\n // Base UI links nothing; Radix described the trigger by the content while it was open.\n aria-describedby={tooltip.open ? tooltip.descriptionId : undefined}\n className={mergeClasses(!asChild && styles.nativeTrigger, className)}\n {...props}\n {...slotProps(asChild, children)}\n />\n )\n})\n\n// Lets TooltipContent supply Base UI's required Portal itself when no TooltipPortal wraps it, as\n// Radix rendered content without one.\nconst TooltipPortalPresenceContext = React.createContext(false)\n\nexport type TooltipPortalProps = {\n children?: React.ReactNode\n /** The element the content portals into; `document.body` when omitted or null. */\n container?: Element | DocumentFragment | null\n /** Keeps the content mounted while the tooltip is closed. */\n forceMount?: true\n}\n\nexport const TooltipPortal = React.forwardRef<HTMLElement, TooltipPortalProps>(\n function TooltipPortal({ container, forceMount, ...props }, ref) {\n return (\n <TooltipPortalPresenceContext.Provider value={true}>\n <TooltipPrimitive.Portal\n // Base UI types the ref as its portal div, which any HTMLElement ref can hold.\n ref={ref as React.Ref<HTMLDivElement>}\n data-slot=\"tooltip-portal\"\n {...{ [SLOT_ATTR]: \"tooltip-portal\" }}\n // Radix took any Element or DocumentFragment, null meaning the body. Base UI hands a\n // node straight to createPortal, which takes either, but reads null as \"wait for one\".\n container={(container ?? undefined) as HTMLElement | undefined}\n keepMounted={forceMount}\n {...props}\n />\n </TooltipPortalPresenceContext.Provider>\n )\n }\n)\n\ntype Side = \"top\" | \"right\" | \"bottom\" | \"left\"\n\nexport type TooltipContentProps = NativePartProps<\"div\"> & {\n /** The side of the trigger the content opens on. Flips when it would not fit. Defaults to top. */\n side?: Side\n /** Distance from the trigger in px, on top of the arrow's own height. Defaults to 0. */\n sideOffset?: number\n /** Alignment against the trigger. Defaults to center. */\n align?: \"start\" | \"center\" | \"end\"\n /** Offset from the `start` or `end` alignment in px. Defaults to 0. */\n alignOffset?: number\n /** Distance between the arrow and the content's corners in px. Defaults to 0. */\n arrowPadding?: number\n /** Flips and shifts the content to keep it in view. Defaults to true. */\n avoidCollisions?: boolean\n /** Elements the content must stay inside, besides the viewport. */\n collisionBoundary?: Element | null | Array<Element | null>\n /** Distance in px from the boundary edges before the content avoids them. Defaults to 0. */\n collisionPadding?: number | Partial<Record<Side, number>>\n /** `partial` keeps the content attached to its trigger; `always` keeps it in the boundary. */\n sticky?: \"partial\" | \"always\"\n /** Hides the content once its trigger is scrolled out of view. */\n hideWhenDetached?: boolean\n /** Accepted for compatibility; the position follows layout changes either way. */\n updatePositionStrategy?: \"optimized\" | \"always\"\n /**\n * Keeps the content mounted while the tooltip is closed. Inside TooltipPortal, the portal's\n * `forceMount` decides.\n */\n forceMount?: true\n /** Hides the arrow that points at the trigger. */\n hideArrow?: boolean\n variant?: \"default\" | \"destructive\"\n}\n\n// Radix's collision handling: flip to the opposite side or alignment, never to the other axis.\nconst AVOID_COLLISIONS = {\n side: \"flip\",\n align: \"flip\",\n fallbackAxisSide: \"none\",\n} as const\nconst IGNORE_COLLISIONS = {\n side: \"none\",\n align: \"none\",\n fallbackAxisSide: \"none\",\n} as const\n\nexport const TooltipContent = React.forwardRef<\n HTMLDivElement,\n TooltipContentProps\n>(function TooltipContent(\n {\n asChild = false,\n className,\n children,\n hideArrow = false,\n variant = \"default\",\n side = \"top\",\n sideOffset = 0,\n align = \"center\",\n alignOffset = 0,\n arrowPadding = 0,\n avoidCollisions = true,\n collisionBoundary = [],\n collisionPadding = 0,\n sticky = \"partial\",\n hideWhenDetached = false,\n updatePositionStrategy: _updatePositionStrategy,\n forceMount,\n id: idProp,\n ...props\n },\n ref\n) {\n const styles = useStyles()\n const tooltip = useTooltipContext(\"TooltipContent\")\n const hasPortal = React.useContext(TooltipPortalPresenceContext)\n // DENSITY-SPEC.md §4.4 — portal content boundary; see dialog.tsx's identical comment. Tooltip\n // content rarely nests density-consuming children, but the mechanism is applied uniformly across\n // every portal-content component rather than special-cased per component.\n const override = useDensity()\n // SPEC.md §2 rule 3 — the same portal asymmetry, for the appearance pair: re-stamp the\n // nearest explicit AppearanceBoundary's mode+surface, or neither attribute when there is\n // none, leaving live shell inheritance in place.\n const appearance = useAppearanceAttributes()\n const arrowRef = React.useRef<HTMLDivElement>(null)\n const [popup, setPopup] = React.useState<HTMLDivElement | null>(null)\n const popupRef = useMergedRef(ref, setPopup)\n\n // Radix's tooltip was the topmost layer while open, so Escape closed it before anything under it:\n // a Dialog or a Radix menu it sits in, or a control. Base UI's listens later, after a Dialog has\n // taken the key. Taking it on the window in the capture phase, before Radix's layers and Zenith's\n // Base UI roots see it, and preventing it makes them leave it alone.\n const { open, closeOnEscape } = tooltip\n React.useEffect(() => {\n if (!open || !popup) return\n const element = popup\n openPopups.push(element)\n const view = element.ownerDocument.defaultView ?? window\n function onKeyDown(event: KeyboardEvent) {\n if (event.key !== \"Escape\" || event.defaultPrevented || event.isComposing)\n return\n if (openPopups[openPopups.length - 1] !== element) return\n // Only an Escape from under the tooltip, earlier in the document. From inside it (a layer\n // nested in the content, or the content itself) Base UI's own handler runs first; from later\n // in the document, a layer opened over the tooltip takes its own.\n const target = event.target\n if (\n !(target instanceof Node) ||\n element.contains(target) ||\n !(\n element.compareDocumentPosition(target) &\n Node.DOCUMENT_POSITION_PRECEDING\n )\n )\n return\n event.preventDefault()\n closeOnEscape(event)\n }\n view.addEventListener(\"keydown\", onKeyDown, true)\n return () => {\n view.removeEventListener(\"keydown\", onKeyDown, true)\n openPopups.splice(openPopups.indexOf(element), 1)\n }\n }, [open, popup, closeOnEscape])\n\n // The trigger's `aria-describedby` points here, so a caller's own id has to reach it. Radix\n // described the trigger by `aria-label` when one was given; a hidden node carries it, because\n // not every accessibility engine reads the `aria-label` of a describing element.\n const popupId = idProp ?? tooltip.generatedId\n const ariaLabel = props[\"aria-label\"]\n const labelId = `${popupId}-label`\n const descriptionId = ariaLabel ? labelId : popupId\n const { setDescriptionId } = tooltip\n React.useEffect(() => {\n setDescriptionId(descriptionId)\n return () => setDescriptionId(undefined)\n }, [descriptionId, setDescriptionId])\n\n const label = ariaLabel && (\n <span id={labelId} hidden>\n {ariaLabel}\n </span>\n )\n\n const arrow = !hideArrow && (\n <TooltipPrimitive.Arrow\n ref={arrowRef}\n data-slot=\"tooltip-arrow\"\n {...{ [SLOT_ATTR]: \"tooltip-arrow\" }}\n data-variant={variant}\n className={styles.arrow}\n />\n )\n const child = asChild ? onlySlotChild(children) : undefined\n // The child keeps its own children, so the label and the arrow join them there.\n const content = child\n ? {\n render: React.cloneElement(\n child,\n undefined,\n (child.props as { children?: React.ReactNode }).children,\n label,\n arrow\n ),\n }\n : {\n children: (\n <>\n {children}\n {label}\n {arrow}\n </>\n ),\n }\n\n const positioner = (\n <TooltipPrimitive.Positioner\n className={mergeClasses(\n styles.positioner,\n hideWhenDetached && styles.hideWhenDetached\n )}\n positionMethod=\"fixed\"\n side={side}\n // Radix moved the content away by the arrow's own height on top of `sideOffset`.\n sideOffset={() => sideOffset + (arrowRef.current?.offsetHeight ?? 0)}\n align={align}\n // Radix applied the offset to `start` and `end` only; Base UI also shifts centred content.\n alignOffset={align === \"center\" ? 0 : alignOffset}\n arrowPadding={arrowPadding}\n // Radix's default is the viewport alone, not every clipping ancestor.\n collisionBoundary={\n Array.isArray(collisionBoundary)\n ? collisionBoundary.filter((boundary) => boundary !== null)\n : collisionBoundary === null\n ? []\n : collisionBoundary\n }\n collisionPadding={collisionPadding}\n sticky={sticky === \"always\"}\n collisionAvoidance={\n avoidCollisions ? AVOID_COLLISIONS : IGNORE_COLLISIONS\n }\n >\n <TooltipPrimitive.Popup\n ref={popupRef}\n id={popupId}\n // Base UI renders no role; Radix exposed the content as role=\"tooltip\".\n role=\"tooltip\"\n data-slot=\"tooltip-content\"\n {...{ [SLOT_ATTR]: \"tooltip-content\" }}\n {...(override !== undefined ? { \"data-density\": override } : {})}\n {...appearance}\n data-variant={variant}\n className={mergeClasses(styles.popup, className)}\n {...props}\n {...content}\n />\n </TooltipPrimitive.Positioner>\n )\n\n // Base UI's Positioner requires a Portal ancestor; Radix rendered inline without one.\n return hasPortal ? (\n positioner\n ) : (\n <TooltipPrimitive.Portal keepMounted={forceMount}>\n {positioner}\n </TooltipPrimitive.Portal>\n )\n})\n"],"names":["useStyles","makeZenithStyles","nativeControl","OVERLAY_Z_INDEX","boxModel","shorthands","tokens.radiusLg","tokens.spacingElement2","tokens.textXs","tokens.gray12","tokens.gray1","tokens.errorA12","tokens.error1","tokens.error12","onlySlotChild","children","elements","React","slotProps","asChild","child","useMergedRef","a","b","node","ref","escapeDetails","details","event","openPopups","TooltipProviderContext","TooltipProvider","delayDuration","skipDelayDuration","disableHoverableContent","_ref","value","jsx","TooltipPrimitive","TooltipContext","Tooltip","openProp","defaultOpen","onOpenChange","provider","uncontrolledOpen","setUncontrolledOpen","open","generatedId","descriptionId","setDescriptionId","actionsRef","escapeRef","closeOnEscape","_a","context","root","nextOpen","baseDetails","escape","eventDetails","useTooltipContext","part","TooltipTrigger","className","props","styles","tooltip","SLOT_ATTR","mergeClasses","TooltipPortalPresenceContext","TooltipPortal","container","forceMount","AVOID_COLLISIONS","IGNORE_COLLISIONS","TooltipContent","hideArrow","variant","side","sideOffset","align","alignOffset","arrowPadding","avoidCollisions","collisionBoundary","collisionPadding","sticky","hideWhenDetached","_updatePositionStrategy","idProp","hasPortal","override","useDensity","appearance","useAppearanceAttributes","arrowRef","popup","setPopup","popupRef","element","view","onKeyDown","target","popupId","ariaLabel","labelId","label","arrow","content","jsxs","Fragment","positioner","boundary"],"mappings":";;;;;;;;;;AAaA,MAAMA,IAAYC,GAAiB;AAAA;AAAA;AAAA,EAGjC,eAAe;AAAA,IACb,GAAGC;AAAA,EAAA;AAAA,EAEL,YAAY;AAAA,IACV,QAAQC;AAAA,EAAA;AAAA;AAAA,EAGV,kBAAkB;AAAA,IAChB,yBAAyB;AAAA,MACvB,YAAY;AAAA,MACZ,eAAe;AAAA,IAAA;AAAA,EACjB;AAAA;AAAA;AAAA,EAIF,OAAO;AAAA,IACL,GAAGC;AAAA,IACH,OAAO;AAAA;AAAA,IAEP,UAAU;AAAA,IACV,iBAAiB;AAAA,IACjB,GAAGC,EAAW,aAAaC,EAAe;AAAA,IAC1C,GAAGD,EAAW,QAAQE,EAAsB;AAAA;AAAA,IAE5C,WAAW;AAAA,IACX,UAAUC;AAAAA;AAAAA,IAEV,YAAY;AAAA,IACZ,Q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AuC,GACH;AAEJ,CAAC;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@epilot/zenith-react",
|
|
3
|
-
"version": "0.3.0-next.
|
|
3
|
+
"version": "0.3.0-next.4",
|
|
4
4
|
"description": "Zenith React components, styled with Griffel and designed for isolated micro-frontend delivery",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -150,7 +150,7 @@
|
|
|
150
150
|
"zenith": {
|
|
151
151
|
"next": {
|
|
152
152
|
"mainSha": "139e14faaec9474269303ecf8f473413c4659fcd",
|
|
153
|
-
"pipelineId":
|
|
153
|
+
"pipelineId": 3008274351,
|
|
154
154
|
"included": [
|
|
155
155
|
{
|
|
156
156
|
"iid": 151,
|
|
@@ -160,14 +160,14 @@
|
|
|
160
160
|
},
|
|
161
161
|
{
|
|
162
162
|
"iid": 158,
|
|
163
|
-
"headSha": "
|
|
163
|
+
"headSha": "a72f0dbe76969fa6f4ec24b143394f33a9a91bf0",
|
|
164
164
|
"url": "https://gitlab.com/e-pilot/product/frontend/zenith/-/merge_requests/158",
|
|
165
165
|
"order": 2
|
|
166
166
|
}
|
|
167
167
|
],
|
|
168
168
|
"leftOut": [],
|
|
169
169
|
"versions": {
|
|
170
|
-
"react": "0.3.0-next.
|
|
170
|
+
"react": "0.3.0-next.4",
|
|
171
171
|
"runtime": "0.3.0-next.1"
|
|
172
172
|
},
|
|
173
173
|
"runtime": {
|