@ntbjs/react-components 3.0.0-rc.3 → 3.0.0-rc.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.
@@ -71,6 +71,7 @@ const Popover = React__default.forwardRef(function Popover({
71
71
  offset: offsetTuple,
72
72
  arrow: arrowDrivesTheOffset,
73
73
  interactive,
74
+ role: 'dialog',
74
75
  disabled,
75
76
  duration,
76
77
  constrainHeight: true,
@@ -117,7 +118,6 @@ const Popover = React__default.forwardRef(function Popover({
117
118
  "data-placement": resolvedPlacement,
118
119
  "data-context-menu": contextMenu ? 'true' : undefined,
119
120
  "data-context-menu-sublevel": contextMenuSublevel ? 'true' : undefined,
120
- role: "tooltip",
121
121
  tabIndex: -1,
122
122
  style: {
123
123
  ...transitionStyles,
@@ -1 +1 @@
1
- {"version":3,"file":"Popover.js","sources":["../../../src/components/data/Popover/Popover.tsx"],"sourcesContent":["import React from 'react';\n\nimport { FloatingNode, FloatingPortal, useFloatingNodeId, useMergeRefs } from '@floating-ui/react';\n\nimport useFloatingPopover from '../../../hooks/useFloatingPopover';\nimport { getElementRef } from '../../../utils/getElementRef';\nimport { POPOVER_ARROW, SharedFloatingArrow } from '../_shared/FloatingArrow.styled';\nimport * as S from './Popover.styled';\n\nimport type { Middleware, OpenChangeReason } from '@floating-ui/react';\nimport type { PopoverPlacement, PopperOffset } from '../../../hooks/useFloatingPopover';\n\n// tippy's default z-index; 10 consumer call sites override it, which is why it's declared as a prop.\nconst TIPPY_DEFAULT_Z_INDEX = 9999;\n\n// tippy.css applied this viewport cap through [data-tippy-root] (the positioner), carried over.\nconst POSITIONER_MAX_WIDTH = 'calc(100vw - 10px)';\n\n// Placement and trigger that contextMenuSublevel forces, unchanged from old implementation.\nconst CONTEXT_MENU_SUBLEVEL_PLACEMENT = 'right-start' as const;\nconst CONTEXT_MENU_SUBLEVEL_TRIGGER = 'mouseenter click focus';\n\n/**\n * The class `ContextMenuItem` writes (`ContextMenuItem.tsx:81`), and the one it adds for an\n * item that opens a submenu. A click on a LEAF item closes the menu; a click on a sublevel\n * opener must not, or the submenu would close the parent it just opened.\n */\nconst CONTEXT_MENU_ITEM_SELECTOR = '.context-menu-item';\nconst CONTEXT_MENU_SUBLEVEL_OPENER_CLASS = 'opens-sublevel';\n\n// tippy's three-way appendTo: given value portals, absent+interactive=true (default) renders INLINE into reference's parent, absent+interactive=false portals to body. Plan C4 confirms behaviour-preserving.\nexport type PopoverAppendTo = 'parent' | Element | ((reference: Element) => Element);\n\ntype PopoverOwnProps = {\n /**\n * The content of the `Popover`.\n */\n content: string | React.ReactElement<any>;\n /**\n * Whether the popover's content is interactive and where it renders (inline by default for interactive popovers).\n */\n interactive?: boolean;\n /**\n * Preferred placement; 12 concrete names need no Popper→Floating UI translation. Three `auto*` values select `autoPlacement()` instead of `flip()`.\n */\n placement?: PopoverPlacement;\n /**\n * Duration in ms of the transition animation.\n */\n duration?: number;\n /**\n * Events that cause the popover to show (space-separated). `''` means no triggers, `undefined` means `'mouseenter focus'`, component defaults to `'click focus'`.\n */\n trigger?: string;\n /**\n * `[skidding, distance]`; distance is the gap between reference and arrow tip (not box), absorbing the old `+15` offset.\n */\n offset?: number[];\n /**\n * Whether the popover has an arrow; also moves the box even when not drawn (existing behaviour, reproduced).\n */\n arrow?: boolean;\n /**\n * Pass a boolean to control visibility; both `true` and `false` disable native triggers. `onClickOutside` still fires in controlled mode.\n */\n visible?: boolean;\n /**\n * @deprecated Accepted and ignored; use `middleware` instead.\n */\n modifiers?: any[];\n /**\n * Extra Floating UI middleware, appended after the built-in chain; one internal caller needed this for width matching.\n */\n middleware?: Middleware[];\n /**\n * Max-width of the popover box, as a CSS length. Defaults to `'none'`, which is what tippy\n * received and wrote inline on every popover in both consumers.\n */\n maxWidth?: string;\n /**\n * Whether the `Popover` contains a context menu.\n * This will remove the default arrow, and apply styling.\n *\n * It also makes a click on a `ContextMenuItem` close the menu — see\n * `handleContextMenuClick`.\n */\n contextMenu?: boolean;\n /**\n * Whether the `Popover` contains a context menu which is the sublevel of another context menu.\n * This will automatically set placement, spacing and trigger events, add a dropdown icon, etc.\n */\n contextMenuSublevel?: boolean;\n /**\n * `z-index` of the positioned element (default: 9999, tippy's default).\n */\n zIndex?: number;\n /**\n * A disabled popover can never open, even under a controlled `visible={true}` — tippy's\n * semantics.\n */\n disabled?: boolean;\n /**\n * Where the popover is rendered (default: inline for interactive popovers, document.body otherwise).\n */\n appendTo?: PopoverAppendTo;\n /** Fired when a press lands outside both the reference and the popover. */\n onClickOutside?: (event?: Event) => void;\n /**\n * Fired when the popover opens. tippy's `onShow`, minus its instance argument.\n */\n onShow?: () => void;\n /**\n * Fired when the popover closes; one internal caller (inputs/Button) depends on it to reset dropdown-is-active class.\n */\n onHide?: () => void;\n /**\n * Content of the `Popover`.\n */\n children: React.ReactNode;\n};\n\n// Props spreads onto S.Popover, so the published type must admit its props. Base moved from styled(Tippy) to styled.div, requiring explicit declaration of zIndex, disabled, appendTo, onClickOutside, onHide.\ntype Props = Omit<React.ComponentPropsWithoutRef<typeof S.Popover>, keyof PopoverOwnProps> &\n PopoverOwnProps;\n\n// Props accepted-but-ignored: onClick/onChange/onSubmit filter is load-bearing (would activate dead handlers); popperOptions is plan C6 deprecation.\nconst PROPS_NEVER_FORWARDED = ['onClick', 'onChange', 'onSubmit', 'popperOptions'];\n\n/**\n * The `Popover` is a transient view that shows on a content screen when a user clicks on a control button or within a defined area.\n * A `Popover` renders a temporary context to get user’s attention and to hide unnecessary interactions.\n *\n * This component is used with the `Button` and `ContextMenu` components to create dropdown menus and context menus.\n * See their documentation for usage examples.\n *\n * ### Import\n *\n * ``` js\n * import { Popover } from '@ntbjs/react-components/data'\n * // or\n * import Popover from '@ntbjs/react-components/data/Popover'\n * ```\n *\n * ### Usage example\n *\n * ``` js\n<Popover content={<img alt=\"Dummy content\" src={dummyImage} />}>\n <ActionButton icon={<DeleteIcon />} onClick={() => {}} />\n</Popover>\n * ```\n */\n\nconst Popover = React.forwardRef<any, Props>(function Popover(\n {\n content = 'Tooltip',\n interactive = true,\n placement = 'bottom-end',\n duration = 350,\n trigger = 'click focus',\n offset = [0, 8],\n arrow = true,\n visible = undefined,\n contextMenu = false,\n contextMenuSublevel = false,\n children,\n modifiers = [],\n middleware,\n maxWidth = 'none',\n zIndex = TIPPY_DEFAULT_Z_INDEX,\n disabled = false,\n appendTo,\n onClickOutside,\n onShow,\n onHide,\n ...props\n },\n ref\n) {\n void modifiers.length;\n\n const onOpenChange = React.useCallback(\n (open: boolean, event?: Event, reason?: OpenChangeReason) => {\n if (!open && reason === 'outside-press') {\n onClickOutside?.(event);\n }\n\n if (open) {\n onShow?.();\n } else {\n onHide?.();\n }\n },\n [onClickOutside, onShow, onHide]\n );\n\n // Registers in FloatingTree if present; safe with no tree (guarded reads in useDismiss).\n const nodeId = useFloatingNodeId();\n\n // Normalize to fixed-length tuple; public prop stays number[] for compat.\n const offsetTuple: PopperOffset = [offset[0] ?? 0, offset[1] ?? 0];\n\n // Arrow position drives offset even when not drawn (existing behavior). arrowDrivesTheOffset feeds hook; drawsArrow decides rendering.\n const arrowDrivesTheOffset = arrow;\n const drawsArrow = contextMenu ? false : arrow;\n\n const {\n refs,\n floatingStyles,\n context,\n getReferenceProps,\n getFloatingProps,\n isMounted,\n transitionStyles,\n arrowRef,\n setOpen,\n placement: resolvedPlacement,\n pointerEvents\n } = useFloatingPopover({\n placement: contextMenuSublevel ? CONTEXT_MENU_SUBLEVEL_PLACEMENT : placement,\n open: visible,\n onOpenChange,\n trigger: contextMenuSublevel ? CONTEXT_MENU_SUBLEVEL_TRIGGER : trigger,\n offset: offsetTuple,\n arrow: arrowDrivesTheOffset,\n interactive,\n disabled,\n duration,\n // Always on, replacing popper-max-size-modifier behavior (but clears cap when content fits, unlike applyMaxSize).\n constrainHeight: true,\n nodeId,\n middleware\n });\n\n // Reference is the CHILD (not wrapper) for positioning compat; ref merges forwarded ref, child's ref, and setReference.\n const childRef = React.isValidElement(children) ? getElementRef(children) : null;\n const referenceRef = useMergeRefs([ref, childRef, refs.setReference]);\n\n const filteredProps = Object.fromEntries(\n Object.entries(props).filter(([key]) => !PROPS_NEVER_FORWARDED.includes(key))\n );\n\n // Floating UI composes handlers with existing ones, so child's own handlers still work.\n const reference = React.isValidElement(children)\n ? React.cloneElement(\n children as React.ReactElement<Record<string, unknown>>,\n {\n ...getReferenceProps((children as React.ReactElement<Record<string, unknown>>).props),\n ref: referenceRef\n } as never\n )\n : children;\n\n // Delegated click handler closes this menu on item click (inline rendering means ancestor menus close automatically via bubbling).\n const handleContextMenuClick = (event: React.MouseEvent<HTMLDivElement>) => {\n if (!contextMenu) return;\n\n const target = event.target;\n if (!(target instanceof Element)) return;\n\n const item = target.closest(CONTEXT_MENU_ITEM_SELECTOR);\n if (!item || item.classList.contains(CONTEXT_MENU_SUBLEVEL_OPENER_CLASS)) return;\n\n setOpen(false, event.nativeEvent, 'click');\n };\n\n // Inline rendering: 'parent' or (interactive && no explicit appendTo).\n const renderInline = appendTo === 'parent' || (interactive && appendTo === undefined);\n\n // null/undefined NOT interchangeable: undefined→document.body default, null→defer until reference exists.\n const resolvePortalRoot = (): HTMLElement | null | undefined => {\n if (renderInline || appendTo === undefined) return undefined;\n if (typeof appendTo === 'function') {\n const node = refs.reference.current;\n return node instanceof Element ? (appendTo(node) as HTMLElement) : null;\n }\n return appendTo as HTMLElement;\n };\n\n const floating = isMounted ? (\n <div\n ref={refs.setFloating}\n style={{ ...floatingStyles, zIndex, pointerEvents, maxWidth: POSITIONER_MAX_WIDTH }}\n {...getFloatingProps({ onClick: handleContextMenuClick })}\n >\n {/*\n * filteredProps first so explicit attrs can't override transition/placement styles. role/tabindex from tippy (not changed for compat).\n */}\n <S.Popover\n {...filteredProps}\n data-placement={resolvedPlacement}\n data-context-menu={contextMenu ? 'true' : undefined}\n data-context-menu-sublevel={contextMenuSublevel ? 'true' : undefined}\n role=\"tooltip\"\n tabIndex={-1}\n style={{ ...transitionStyles, maxWidth }}\n >\n <div className=\"tippy-content\">{content}</div>\n {drawsArrow && (\n <SharedFloatingArrow\n ref={arrowRef}\n context={context}\n data-arrow-surface=\"popover\"\n {...POPOVER_ARROW}\n />\n )}\n </S.Popover>\n </div>\n ) : null;\n\n // FloatingNode publishes ID to nested popovers; no DOM cost in standalone case. Bare wrapper preserved for compat.\n return (\n <div>\n {reference}\n <FloatingNode id={nodeId}>\n {renderInline ? (\n floating\n ) : (\n <FloatingPortal root={resolvePortalRoot()}>{floating}</FloatingPortal>\n )}\n </FloatingNode>\n </div>\n );\n});\n\nexport default Popover;\n"],"names":["TIPPY_DEFAULT_Z_INDEX","POSITIONER_MAX_WIDTH","CONTEXT_MENU_SUBLEVEL_PLACEMENT","CONTEXT_MENU_SUBLEVEL_TRIGGER","CONTEXT_MENU_ITEM_SELECTOR","CONTEXT_MENU_SUBLEVEL_OPENER_CLASS","PROPS_NEVER_FORWARDED","Popover","React","forwardRef","content","interactive","placement","duration","trigger","offset","arrow","visible","undefined","contextMenu","contextMenuSublevel","children","modifiers","middleware","maxWidth","zIndex","disabled","appendTo","onClickOutside","onShow","onHide","props","ref","length","onOpenChange","useCallback","open","event","reason","nodeId","useFloatingNodeId","offsetTuple","arrowDrivesTheOffset","drawsArrow","refs","floatingStyles","context","getReferenceProps","getFloatingProps","isMounted","transitionStyles","arrowRef","setOpen","resolvedPlacement","pointerEvents","useFloatingPopover","constrainHeight","childRef","isValidElement","getElementRef","referenceRef","useMergeRefs","setReference","filteredProps","Object","fromEntries","entries","filter","key","includes","reference","cloneElement","handleContextMenuClick","target","Element","item","closest","classList","contains","nativeEvent","renderInline","resolvePortalRoot","node","current","floating","_jsx","setFloating","style","onClick","_jsxs","S","role","tabIndex","className","SharedFloatingArrow","POPOVER_ARROW","FloatingNode","id","FloatingPortal","root"],"mappings":";;;;;;;;AAaA,MAAMA,qBAAqB,GAAG,IAAI;AAGlC,MAAMC,oBAAoB,GAAG,oBAAoB;AAGjD,MAAMC,+BAA+B,GAAG,aAAsB;AAC9D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AAAAlB,MAAAA,QAAA,EACtB2D,YAAY,GACXI,QAAQ,GAERC,GAAA,CAACa,cAAc,EAAA;QAACC,IAAI,EAAElB,iBAAiB,EAAG;AAAA5D,QAAAA,QAAA,EAAE+D;OAAyB;AACtE,KACW,CAAC;AAAA,GACZ,CAAC;AAEV,CAAC;;;;"}
1
+ {"version":3,"file":"Popover.js","sources":["../../../src/components/data/Popover/Popover.tsx"],"sourcesContent":["import React from 'react';\n\nimport { FloatingNode, FloatingPortal, useFloatingNodeId, useMergeRefs } from '@floating-ui/react';\n\nimport useFloatingPopover from '../../../hooks/useFloatingPopover';\nimport { getElementRef } from '../../../utils/getElementRef';\nimport { POPOVER_ARROW, SharedFloatingArrow } from '../_shared/FloatingArrow.styled';\nimport * as S from './Popover.styled';\n\nimport type { Middleware, OpenChangeReason } from '@floating-ui/react';\nimport type { PopoverPlacement, PopperOffset } from '../../../hooks/useFloatingPopover';\n\n// tippy's default z-index; 10 consumer call sites override it, which is why it's declared as a prop.\nconst TIPPY_DEFAULT_Z_INDEX = 9999;\n\n// tippy.css applied this viewport cap through [data-tippy-root] (the positioner), carried over.\nconst POSITIONER_MAX_WIDTH = 'calc(100vw - 10px)';\n\n// Placement and trigger that contextMenuSublevel forces, unchanged from old implementation.\nconst CONTEXT_MENU_SUBLEVEL_PLACEMENT = 'right-start' as const;\nconst CONTEXT_MENU_SUBLEVEL_TRIGGER = 'mouseenter click focus';\n\n/**\n * The class `ContextMenuItem` writes (`ContextMenuItem.tsx:81`), and the one it adds for an\n * item that opens a submenu. A click on a LEAF item closes the menu; a click on a sublevel\n * opener must not, or the submenu would close the parent it just opened.\n */\nconst CONTEXT_MENU_ITEM_SELECTOR = '.context-menu-item';\nconst CONTEXT_MENU_SUBLEVEL_OPENER_CLASS = 'opens-sublevel';\n\n// tippy's three-way appendTo: given value portals, absent+interactive=true (default) renders INLINE into reference's parent, absent+interactive=false portals to body. Plan C4 confirms behaviour-preserving.\nexport type PopoverAppendTo = 'parent' | Element | ((reference: Element) => Element);\n\ntype PopoverOwnProps = {\n /**\n * The content of the `Popover`.\n */\n content: string | React.ReactElement<any>;\n /**\n * Whether the popover's content is interactive and where it renders (inline by default for interactive popovers).\n */\n interactive?: boolean;\n /**\n * Preferred placement; 12 concrete names need no Popper→Floating UI translation. Three `auto*` values select `autoPlacement()` instead of `flip()`.\n */\n placement?: PopoverPlacement;\n /**\n * Duration in ms of the transition animation.\n */\n duration?: number;\n /**\n * Events that cause the popover to show (space-separated). `''` means no triggers, `undefined` means `'mouseenter focus'`, component defaults to `'click focus'`.\n */\n trigger?: string;\n /**\n * `[skidding, distance]`; distance is the gap between reference and arrow tip (not box), absorbing the old `+15` offset.\n */\n offset?: number[];\n /**\n * Whether the popover has an arrow; also moves the box even when not drawn (existing behaviour, reproduced).\n */\n arrow?: boolean;\n /**\n * Pass a boolean to control visibility; both `true` and `false` disable native triggers. `onClickOutside` still fires in controlled mode.\n */\n visible?: boolean;\n /**\n * @deprecated Accepted and ignored; use `middleware` instead.\n */\n modifiers?: any[];\n /**\n * Extra Floating UI middleware, appended after the built-in chain; one internal caller needed this for width matching.\n */\n middleware?: Middleware[];\n /**\n * Max-width of the popover box, as a CSS length. Defaults to `'none'`, which is what tippy\n * received and wrote inline on every popover in both consumers.\n */\n maxWidth?: string;\n /**\n * Whether the `Popover` contains a context menu.\n * This will remove the default arrow, and apply styling.\n *\n * It also makes a click on a `ContextMenuItem` close the menu — see\n * `handleContextMenuClick`.\n */\n contextMenu?: boolean;\n /**\n * Whether the `Popover` contains a context menu which is the sublevel of another context menu.\n * This will automatically set placement, spacing and trigger events, add a dropdown icon, etc.\n */\n contextMenuSublevel?: boolean;\n /**\n * `z-index` of the positioned element (default: 9999, tippy's default).\n */\n zIndex?: number;\n /**\n * A disabled popover can never open, even under a controlled `visible={true}` — tippy's\n * semantics.\n */\n disabled?: boolean;\n /**\n * Where the popover is rendered (default: inline for interactive popovers, document.body otherwise).\n */\n appendTo?: PopoverAppendTo;\n /** Fired when a press lands outside both the reference and the popover. */\n onClickOutside?: (event?: Event) => void;\n /**\n * Fired when the popover opens. tippy's `onShow`, minus its instance argument.\n */\n onShow?: () => void;\n /**\n * Fired when the popover closes; one internal caller (inputs/Button) depends on it to reset dropdown-is-active class.\n */\n onHide?: () => void;\n /**\n * Content of the `Popover`.\n */\n children: React.ReactNode;\n};\n\n// Props spreads onto S.Popover, so the published type must admit its props. Base moved from styled(Tippy) to styled.div, requiring explicit declaration of zIndex, disabled, appendTo, onClickOutside, onHide.\ntype Props = Omit<React.ComponentPropsWithoutRef<typeof S.Popover>, keyof PopoverOwnProps> &\n PopoverOwnProps;\n\n// Props accepted-but-ignored: onClick/onChange/onSubmit filter is load-bearing (would activate dead handlers); popperOptions is plan C6 deprecation.\nconst PROPS_NEVER_FORWARDED = ['onClick', 'onChange', 'onSubmit', 'popperOptions'];\n\n/**\n * The `Popover` is a transient view that shows on a content screen when a user clicks on a control button or within a defined area.\n * A `Popover` renders a temporary context to get user’s attention and to hide unnecessary interactions.\n *\n * This component is used with the `Button` and `ContextMenu` components to create dropdown menus and context menus.\n * See their documentation for usage examples.\n *\n * ### Import\n *\n * ``` js\n * import { Popover } from '@ntbjs/react-components/data'\n * // or\n * import Popover from '@ntbjs/react-components/data/Popover'\n * ```\n *\n * ### Usage example\n *\n * ``` js\n<Popover content={<img alt=\"Dummy content\" src={dummyImage} />}>\n <ActionButton icon={<DeleteIcon />} onClick={() => {}} />\n</Popover>\n * ```\n */\n\nconst Popover = React.forwardRef<any, Props>(function Popover(\n {\n content = 'Tooltip',\n interactive = true,\n placement = 'bottom-end',\n duration = 350,\n trigger = 'click focus',\n offset = [0, 8],\n arrow = true,\n visible = undefined,\n contextMenu = false,\n contextMenuSublevel = false,\n children,\n modifiers = [],\n middleware,\n maxWidth = 'none',\n zIndex = TIPPY_DEFAULT_Z_INDEX,\n disabled = false,\n appendTo,\n onClickOutside,\n onShow,\n onHide,\n ...props\n },\n ref\n) {\n void modifiers.length;\n\n const onOpenChange = React.useCallback(\n (open: boolean, event?: Event, reason?: OpenChangeReason) => {\n if (!open && reason === 'outside-press') {\n onClickOutside?.(event);\n }\n\n if (open) {\n onShow?.();\n } else {\n onHide?.();\n }\n },\n [onClickOutside, onShow, onHide]\n );\n\n // Registers in FloatingTree if present; safe with no tree (guarded reads in useDismiss).\n const nodeId = useFloatingNodeId();\n\n // Normalize to fixed-length tuple; public prop stays number[] for compat.\n const offsetTuple: PopperOffset = [offset[0] ?? 0, offset[1] ?? 0];\n\n // Arrow position drives offset even when not drawn (existing behavior). arrowDrivesTheOffset feeds hook; drawsArrow decides rendering.\n const arrowDrivesTheOffset = arrow;\n const drawsArrow = contextMenu ? false : arrow;\n\n const {\n refs,\n floatingStyles,\n context,\n getReferenceProps,\n getFloatingProps,\n isMounted,\n transitionStyles,\n arrowRef,\n setOpen,\n placement: resolvedPlacement,\n pointerEvents\n } = useFloatingPopover({\n placement: contextMenuSublevel ? CONTEXT_MENU_SUBLEVEL_PLACEMENT : placement,\n open: visible,\n onOpenChange,\n trigger: contextMenuSublevel ? CONTEXT_MENU_SUBLEVEL_TRIGGER : trigger,\n offset: offsetTuple,\n arrow: arrowDrivesTheOffset,\n interactive,\n // A popover holds interactive content, so it is a dialog, not a tooltip: useRole gives\n // the reference aria-expanded + aria-haspopup. Full menu semantics (role=\"menu\" +\n // menuitem + arrow-key nav) for contextMenu is deliberately out of scope here.\n role: 'dialog',\n disabled,\n duration,\n // Always on, replacing popper-max-size-modifier behavior (but clears cap when content fits, unlike applyMaxSize).\n constrainHeight: true,\n nodeId,\n middleware\n });\n\n // Reference is the CHILD (not wrapper) for positioning compat; ref merges forwarded ref, child's ref, and setReference.\n const childRef = React.isValidElement(children) ? getElementRef(children) : null;\n const referenceRef = useMergeRefs([ref, childRef, refs.setReference]);\n\n const filteredProps = Object.fromEntries(\n Object.entries(props).filter(([key]) => !PROPS_NEVER_FORWARDED.includes(key))\n );\n\n // Floating UI composes handlers with existing ones, so child's own handlers still work.\n const reference = React.isValidElement(children)\n ? React.cloneElement(\n children as React.ReactElement<Record<string, unknown>>,\n {\n ...getReferenceProps((children as React.ReactElement<Record<string, unknown>>).props),\n ref: referenceRef\n } as never\n )\n : children;\n\n // Delegated click handler closes this menu on item click (inline rendering means ancestor menus close automatically via bubbling).\n const handleContextMenuClick = (event: React.MouseEvent<HTMLDivElement>) => {\n if (!contextMenu) return;\n\n const target = event.target;\n if (!(target instanceof Element)) return;\n\n const item = target.closest(CONTEXT_MENU_ITEM_SELECTOR);\n if (!item || item.classList.contains(CONTEXT_MENU_SUBLEVEL_OPENER_CLASS)) return;\n\n setOpen(false, event.nativeEvent, 'click');\n };\n\n // Inline rendering: 'parent' or (interactive && no explicit appendTo).\n const renderInline = appendTo === 'parent' || (interactive && appendTo === undefined);\n\n // null/undefined NOT interchangeable: undefined→document.body default, null→defer until reference exists.\n const resolvePortalRoot = (): HTMLElement | null | undefined => {\n if (renderInline || appendTo === undefined) return undefined;\n if (typeof appendTo === 'function') {\n const node = refs.reference.current;\n return node instanceof Element ? (appendTo(node) as HTMLElement) : null;\n }\n return appendTo as HTMLElement;\n };\n\n const floating = isMounted ? (\n <div\n ref={refs.setFloating}\n style={{ ...floatingStyles, zIndex, pointerEvents, maxWidth: POSITIONER_MAX_WIDTH }}\n {...getFloatingProps({ onClick: handleContextMenuClick })}\n >\n {/*\n * filteredProps first so explicit attrs can't override transition/placement styles. role/tabindex from tippy (not changed for compat).\n */}\n {/* role + id are on the floating wrapper above via getFloatingProps() (useRole\n 'dialog'); the box no longer hardcodes role. */}\n <S.Popover\n {...filteredProps}\n data-placement={resolvedPlacement}\n data-context-menu={contextMenu ? 'true' : undefined}\n data-context-menu-sublevel={contextMenuSublevel ? 'true' : undefined}\n tabIndex={-1}\n style={{ ...transitionStyles, maxWidth }}\n >\n <div className=\"tippy-content\">{content}</div>\n {drawsArrow && (\n <SharedFloatingArrow\n ref={arrowRef}\n context={context}\n data-arrow-surface=\"popover\"\n {...POPOVER_ARROW}\n />\n )}\n </S.Popover>\n </div>\n ) : null;\n\n // FloatingNode publishes ID to nested popovers; no DOM cost in standalone case. Bare wrapper preserved for compat.\n return (\n <div>\n {reference}\n <FloatingNode id={nodeId}>\n {renderInline ? (\n floating\n ) : (\n <FloatingPortal root={resolvePortalRoot()}>{floating}</FloatingPortal>\n )}\n </FloatingNode>\n </div>\n );\n});\n\nexport default Popover;\n"],"names":["TIPPY_DEFAULT_Z_INDEX","POSITIONER_MAX_WIDTH","CONTEXT_MENU_SUBLEVEL_PLACEMENT","CONTEXT_MENU_SUBLEVEL_TRIGGER","CONTEXT_MENU_ITEM_SELECTOR","CONTEXT_MENU_SUBLEVEL_OPENER_CLASS","PROPS_NEVER_FORWARDED","Popover","React","forwardRef","content","interactive","placement","duration","trigger","offset","arrow","visible","undefined","contextMenu","contextMenuSublevel","children","modifiers","middleware","maxWidth","zIndex","disabled","appendTo","onClickOutside","onShow","onHide","props","ref","length","onOpenChange","useCallback","open","event","reason","nodeId","useFloatingNodeId","offsetTuple","arrowDrivesTheOffset","drawsArrow","refs","floatingStyles","context","getReferenceProps","getFloatingProps","isMounted","transitionStyles","arrowRef","setOpen","resolvedPlacement","pointerEvents","useFloatingPopover","role","constrainHeight","childRef","isValidElement","getElementRef","referenceRef","useMergeRefs","setReference","filteredProps","Object","fromEntries","entries","filter","key","includes","reference","cloneElement","handleContextMenuClick","target","Element","item","closest","classList","contains","nativeEvent","renderInline","resolvePortalRoot","node","current","floating","_jsx","setFloating","style","onClick","_jsxs","S","tabIndex","className","SharedFloatingArrow","POPOVER_ARROW","FloatingNode","id","FloatingPortal","root"],"mappings":";;;;;;;;AAaA,MAAMA,qBAAqB,GAAG,IAAI;AAGlC,MAAMC,oBAAoB,GAAG,oBAAoB;AAGjD,MAAMC,+BAA+B,GAAG,aAAsB;AAC9D,MAAMC,6BAA6B,GAAG,wBAAwB;AAO9D,MAAMC,0BAA0B,GAAG,oBAAoB;AACvD,MAAMC,kCAAkC,GAAG,gBAAgB;AAkG3D,MAAMC,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AAA7D,QAAAA,QAAA,EAAEgE;OAAyB;AACtE,KACW,CAAC;AAAA,GACZ,CAAC;AAEV,CAAC;;;;"}
@@ -86,7 +86,6 @@ const Tooltip = React__default.forwardRef(function Tooltip({
86
86
  children: jsxs(Tooltip$1, {
87
87
  ...filteredProps,
88
88
  "data-placement": resolvedPlacement,
89
- role: "tooltip",
90
89
  tabIndex: -1,
91
90
  style: {
92
91
  ...transitionStyles,
@@ -1 +1 @@
1
- {"version":3,"file":"Tooltip.js","sources":["../../../src/components/data/Tooltip/Tooltip.tsx"],"sourcesContent":["import React from 'react';\n\nimport { FloatingPortal, useMergeRefs } from '@floating-ui/react';\n\nimport useFloatingPopover from '../../../hooks/useFloatingPopover';\nimport { getElementRef } from '../../../utils/getElementRef';\nimport { SharedFloatingArrow, TOOLTIP_ARROW } from '../_shared/FloatingArrow.styled';\nimport * as S from './Tooltip.styled';\n\nimport type { OpenChangeReason } from '@floating-ui/react';\nimport type { PopoverPlacement, PopperOffset } from '../../../hooks/useFloatingPopover';\n\n// tippy's observable defaults: arrow=true, maxWidth=350 (decides wrap), zIndex=9999. All reproduced, not dropped.\nconst TIPPY_DEFAULT_ARROW = true;\nconst TIPPY_DEFAULT_MAX_WIDTH = 350;\nconst TIPPY_DEFAULT_Z_INDEX = 9999;\n\n// Tooltip offset is box distance (not tip gap like Popover); arrowHeight: 0 keeps hook's axis equal to offset[1] exactly.\nconst TOOLTIP_OFFSET: PopperOffset = [0, 10];\nconst TOOLTIP_ARROW_HEIGHT_IS_IN_THE_OFFSET_ALREADY = 0;\n\n// tippy.css applied this viewport cap through [data-tippy-root] (the positioner), carried over.\nconst POSITIONER_MAX_WIDTH = 'calc(100vw - 10px)';\n\n// tippy's three-way appendTo: given value portals, absent+interactive=true renders INLINE, absent+interactive=false portals to body. Safe for Tooltip (interactive defaults false).\nexport type TooltipAppendTo = 'parent' | Element | ((reference: Element) => Element);\n\ntype TooltipOwnProps = {\n /**\n * The content of the `Tooltip`.\n *\n * **NB!** If the content is a `string`, it should be wrapped in a tag, e.g.\n * `<span>{content}</span>`. The requirement outlived its original cause — it was a\n * `@tippyjs/react` quirk — but it is kept because consumers have written to it.\n */\n content: string | React.ReactElement<any>;\n /**\n * Determines if the tooltip has interactive content inside of it, so that it can be\n * hovered over and clicked inside without hiding.\n */\n interactive?: boolean;\n /**\n * The preferred placement of the tooltip. Note that the flip middleware can change this\n * to the opposite placement if it has more space.\n */\n placement?: PopoverPlacement;\n /**\n * Duration in ms of the transition animation.\n */\n duration?: number;\n /**\n * Events that cause the tooltip to show (space-separated). Defaults to `'mouseenter focus'`, `''` means no triggers.\n */\n trigger?: 'mouseenter' | 'mouseenter focus' | 'click' | 'focusin' | 'mouseenter click' | '';\n /**\n * Pass a boolean to control visibility; both `true` and `false` disable native triggers. `undefined` leaves uncontrolled.\n */\n visible?: boolean;\n /**\n * Whether the arrow is rendered. Defaults to `true`, which is tippy's default and was\n * therefore already the behaviour; 6 consumer call sites pass `false`.\n */\n arrow?: boolean;\n /**\n * `z-index` of the positioned element (default: 9999, tippy's default).\n */\n zIndex?: number;\n /**\n * Disabled tooltip can never open, even under controlled `visible={true}` (tippy semantics).\n */\n disabled?: boolean;\n /**\n * `[skidding, distance]`, Popper's convention, where `distance` is the gap between the\n * reference and the tooltip BOX. Defaults to tippy's `[0, 10]`.\n */\n offset?: PopperOffset;\n /**\n * Cap on the box's width, in px. Defaults to 350 — tippy's default, and applied to every\n * tooltip today, so it decides where text wraps.\n */\n maxWidth?: number;\n /**\n * Where the tooltip is rendered. Defaults to `document.body`. See `TooltipAppendTo`.\n */\n appendTo?: TooltipAppendTo;\n /** Fired when a press lands outside both the reference and the tooltip. */\n onClickOutside?: (event?: Event) => void;\n /**\n * @deprecated Accepted and IGNORED. This was a Popper `modifiers` array; Floating UI has\n * middleware instead and the two are not translatable prop-for-prop. Kept so that no\n * existing call site throws — plan C6.\n */\n modifiers?: unknown;\n /**\n * @deprecated Accepted and IGNORED, for the same reason as `modifiers`.\n */\n popperOptions?: unknown;\n children?: React.ReactNode;\n};\n\n// Props spreads onto S.Tooltip, so published type must admit its props. Base moved from styled(Tippy) to styled.div, requiring explicit declaration of zIndex, arrow, disabled, maxWidth.\ntype Props = Omit<React.ComponentPropsWithoutRef<typeof S.Tooltip>, keyof TooltipOwnProps> &\n TooltipOwnProps;\n\n// Props accepted-but-ignored: onClick/onChange/onSubmit filter is load-bearing (would activate dead handlers); modifiers/popperOptions are plan C6 deprecations.\nconst PROPS_NEVER_FORWARDED = ['onClick', 'onChange', 'onSubmit', 'modifiers', 'popperOptions'];\n\n/**\n * Tooltips display informative text when users hover over, focus on, or tap an element.\n *\n * ### Import\n *\n * ``` js\n * import { Tooltip } from '@ntbjs/react-components/data'\n * // or\n * import Tooltip from '@ntbjs/react-components/data/Tooltip'\n * ```\n */\nconst Tooltip = React.forwardRef<any, Props>(function Tooltip(\n {\n content = 'Tooltip',\n interactive = false,\n placement = 'top',\n duration = 350,\n trigger,\n visible,\n children,\n arrow: hasArrow = TIPPY_DEFAULT_ARROW,\n zIndex = TIPPY_DEFAULT_Z_INDEX,\n disabled = false,\n offset = TOOLTIP_OFFSET,\n maxWidth = TIPPY_DEFAULT_MAX_WIDTH,\n appendTo,\n onClickOutside,\n ...props\n },\n ref\n) {\n const onOpenChange = React.useCallback(\n (open: boolean, event?: Event, reason?: OpenChangeReason) => {\n if (!open && reason === 'outside-press') {\n onClickOutside?.(event);\n }\n },\n [onClickOutside]\n );\n\n const {\n refs,\n floatingStyles,\n context,\n getReferenceProps,\n getFloatingProps,\n isMounted,\n transitionStyles,\n arrowRef,\n placement: resolvedPlacement,\n pointerEvents\n } = useFloatingPopover({\n placement,\n open: visible,\n onOpenChange,\n trigger,\n offset,\n arrow: hasArrow,\n arrowHeight: TOOLTIP_ARROW_HEIGHT_IS_IN_THE_OFFSET_ALREADY,\n interactive,\n disabled,\n duration\n });\n\n // Reference is the CHILD (not wrapper) for positioning compat; ref merges forwarded ref, child's ref, and setReference.\n const childRef = React.isValidElement(children) ? getElementRef(children) : null;\n const referenceRef = useMergeRefs([ref, childRef, refs.setReference]);\n\n const filteredProps = Object.fromEntries(\n Object.entries(props).filter(([key]) => !PROPS_NEVER_FORWARDED.includes(key))\n );\n\n // Floating UI composes handlers with existing ones, so child's own handlers still work.\n const reference = React.isValidElement(children)\n ? React.cloneElement(\n children as React.ReactElement<Record<string, unknown>>,\n {\n ...getReferenceProps((children as React.ReactElement<Record<string, unknown>>).props),\n ref: referenceRef\n } as never\n )\n : children;\n\n // Inline rendering: 'parent' or (interactive && no explicit appendTo).\n const renderInline = appendTo === 'parent' || (interactive && appendTo === undefined);\n\n // null/undefined NOT interchangeable: undefined→document.body default, null→defer until reference exists.\n const resolvePortalRoot = (): HTMLElement | null | undefined => {\n if (renderInline || appendTo === undefined) return undefined;\n if (typeof appendTo === 'function') {\n const node = refs.reference.current;\n return node instanceof Element ? (appendTo(node) as HTMLElement) : null;\n }\n return appendTo as HTMLElement;\n };\n\n const floating = isMounted ? (\n <div\n ref={refs.setFloating}\n style={{ ...floatingStyles, zIndex, pointerEvents, maxWidth: POSITIONER_MAX_WIDTH }}\n {...getFloatingProps()}\n >\n {/*\n * filteredProps first so explicit attrs can't override transition/placement styles.\n */}\n <S.Tooltip\n {...filteredProps}\n data-placement={resolvedPlacement}\n role=\"tooltip\"\n tabIndex={-1}\n style={{ ...transitionStyles, maxWidth }}\n >\n <div className=\"tippy-content\">{content}</div>\n {hasArrow && (\n <SharedFloatingArrow\n ref={arrowRef}\n context={context}\n data-arrow-surface=\"tooltip\"\n {...TOOLTIP_ARROW}\n />\n )}\n </S.Tooltip>\n </div>\n ) : null;\n\n // Bare wrapper preserved for compat; load-bearing for TextArea/CompactTextInput onMouseLeave.\n return (\n <div>\n {reference}\n {renderInline ? (\n floating\n ) : (\n <FloatingPortal root={resolvePortalRoot()}>{floating}</FloatingPortal>\n )}\n </div>\n );\n});\n\nexport default Tooltip;\n"],"names":["TIPPY_DEFAULT_ARROW","TIPPY_DEFAULT_MAX_WIDTH","TIPPY_DEFAULT_Z_INDEX","TOOLTIP_OFFSET","TOOLTIP_ARROW_HEIGHT_IS_IN_THE_OFFSET_ALREADY","POSITIONER_MAX_WIDTH","PROPS_NEVER_FORWARDED","Tooltip","React","forwardRef","content","interactive","placement","duration","trigger","visible","children","arrow","hasArrow","zIndex","disabled","offset","maxWidth","appendTo","onClickOutside","props","ref","onOpenChange","useCallback","open","event","reason","refs","floatingStyles","context","getReferenceProps","getFloatingProps","isMounted","transitionStyles","arrowRef","resolvedPlacement","pointerEvents","useFloatingPopover","arrowHeight","childRef","isValidElement","getElementRef","referenceRef","useMergeRefs","setReference","filteredProps","Object","fromEntries","entries","filter","key","includes","reference","cloneElement","renderInline","undefined","resolvePortalRoot","node","current","Element","floating","_jsx","setFloating","style","_jsxs","S","role","tabIndex","className","SharedFloatingArrow","TOOLTIP_ARROW","FloatingPortal","root"],"mappings":";;;;;;;;AAaA,MAAMA,mBAAmB,GAAG,IAAI;AAChC,MAAMC,uBAAuB,GAAG,GAAG;AACnC,MAAMC,qBAAqB,GAAG,IAAI;AAGlC,MAAMC,cAA4B,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC;AAC5C,MAAMC,6CAA6C,GAAG,CAAC;AAGvD,MAAMC,oBAAoB,GAAG,oBAAoB;AAmFjD,MAAMC,qBAAqB,GAAG,CAAC,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,eAAe,CAAC;AAa/F,MAAMC,OAAO,GAAGC,cAAK,CAACC,UAAU,CAAa,SAASF,OAAOA,CAC3D;AACEG,EAAAA,OAAO,GAAG,SAAS;AACnBC,EAAAA,WAAW,GAAG,KAAK;AACnBC,EAAAA,SAAS,GAAG,KAAK;AACjBC,EAAAA,QAAQ,GAAG,GAAG;EACdC,OAAO;EACPC,OAAO;EACPC,QAAQ;EACRC,KAAK,EAAEC,QAAQ,GAAGlB,mBAAmB;AACrCmB,EAAAA,MAAM,GAAGjB,qBAAqB;AAC9BkB,EAAA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gB;AAAEhB,QAAAA;OAAW;AAAAN,MAAAA,QAAA,GAEzCkD,GAAA,CAAA,KAAA,EAAA;AAAKO,QAAAA,SAAS,EAAC,eAAe;AAAAzD,QAAAA,QAAA,EAAEN;AAAO,OAAM,CAAC,EAC7CQ,QAAQ,IACPgD,GAAA,CAACQ,mBAAmB,EAAA;AAClBhD,QAAAA,GAAG,EAAEa,QAAS;AACdL,QAAAA,OAAO,EAAEA,OAAQ;AACjB,QAAA,oBAAA,EAAmB,SAAS;QAAA,GACxByC;AAAa,OAClB,CACF;KACQ;GACR,CAAC,GACJ,IAAI;AAGR,EAAA,OACEN,IAAA,CAAA,KAAA,EAAA;IAAArD,QAAA,EAAA,CACGyC,SAAS,EACTE,YAAY,GACXM,QAAQ,GAERC,GAAA,CAACU,cAAc,EAAA;MAACC,IAAI,EAAEhB,iBAAiB,EAAG;AAAA7C,MAAAA,QAAA,EAAEiD;AAAQ,KAAiB,CACtE;AAAA,GACE,CAAC;AAEV,CAAC;;;;"}
1
+ {"version":3,"file":"Tooltip.js","sources":["../../../src/components/data/Tooltip/Tooltip.tsx"],"sourcesContent":["import React from 'react';\n\nimport { FloatingPortal, useMergeRefs } from '@floating-ui/react';\n\nimport useFloatingPopover from '../../../hooks/useFloatingPopover';\nimport { getElementRef } from '../../../utils/getElementRef';\nimport { SharedFloatingArrow, TOOLTIP_ARROW } from '../_shared/FloatingArrow.styled';\nimport * as S from './Tooltip.styled';\n\nimport type { OpenChangeReason } from '@floating-ui/react';\nimport type { PopoverPlacement, PopperOffset } from '../../../hooks/useFloatingPopover';\n\n// tippy's observable defaults: arrow=true, maxWidth=350 (decides wrap), zIndex=9999. All reproduced, not dropped.\nconst TIPPY_DEFAULT_ARROW = true;\nconst TIPPY_DEFAULT_MAX_WIDTH = 350;\nconst TIPPY_DEFAULT_Z_INDEX = 9999;\n\n// Tooltip offset is box distance (not tip gap like Popover); arrowHeight: 0 keeps hook's axis equal to offset[1] exactly.\nconst TOOLTIP_OFFSET: PopperOffset = [0, 10];\nconst TOOLTIP_ARROW_HEIGHT_IS_IN_THE_OFFSET_ALREADY = 0;\n\n// tippy.css applied this viewport cap through [data-tippy-root] (the positioner), carried over.\nconst POSITIONER_MAX_WIDTH = 'calc(100vw - 10px)';\n\n// tippy's three-way appendTo: given value portals, absent+interactive=true renders INLINE, absent+interactive=false portals to body. Safe for Tooltip (interactive defaults false).\nexport type TooltipAppendTo = 'parent' | Element | ((reference: Element) => Element);\n\ntype TooltipOwnProps = {\n /**\n * The content of the `Tooltip`.\n *\n * **NB!** If the content is a `string`, it should be wrapped in a tag, e.g.\n * `<span>{content}</span>`. The requirement outlived its original cause — it was a\n * `@tippyjs/react` quirk — but it is kept because consumers have written to it.\n */\n content: string | React.ReactElement<any>;\n /**\n * Determines if the tooltip has interactive content inside of it, so that it can be\n * hovered over and clicked inside without hiding.\n */\n interactive?: boolean;\n /**\n * The preferred placement of the tooltip. Note that the flip middleware can change this\n * to the opposite placement if it has more space.\n */\n placement?: PopoverPlacement;\n /**\n * Duration in ms of the transition animation.\n */\n duration?: number;\n /**\n * Events that cause the tooltip to show (space-separated). Defaults to `'mouseenter focus'`, `''` means no triggers.\n */\n trigger?: 'mouseenter' | 'mouseenter focus' | 'click' | 'focusin' | 'mouseenter click' | '';\n /**\n * Pass a boolean to control visibility; both `true` and `false` disable native triggers. `undefined` leaves uncontrolled.\n */\n visible?: boolean;\n /**\n * Whether the arrow is rendered. Defaults to `true`, which is tippy's default and was\n * therefore already the behaviour; 6 consumer call sites pass `false`.\n */\n arrow?: boolean;\n /**\n * `z-index` of the positioned element (default: 9999, tippy's default).\n */\n zIndex?: number;\n /**\n * Disabled tooltip can never open, even under controlled `visible={true}` (tippy semantics).\n */\n disabled?: boolean;\n /**\n * `[skidding, distance]`, Popper's convention, where `distance` is the gap between the\n * reference and the tooltip BOX. Defaults to tippy's `[0, 10]`.\n */\n offset?: PopperOffset;\n /**\n * Cap on the box's width, in px. Defaults to 350 — tippy's default, and applied to every\n * tooltip today, so it decides where text wraps.\n */\n maxWidth?: number;\n /**\n * Where the tooltip is rendered. Defaults to `document.body`. See `TooltipAppendTo`.\n */\n appendTo?: TooltipAppendTo;\n /** Fired when a press lands outside both the reference and the tooltip. */\n onClickOutside?: (event?: Event) => void;\n /**\n * @deprecated Accepted and IGNORED. This was a Popper `modifiers` array; Floating UI has\n * middleware instead and the two are not translatable prop-for-prop. Kept so that no\n * existing call site throws — plan C6.\n */\n modifiers?: unknown;\n /**\n * @deprecated Accepted and IGNORED, for the same reason as `modifiers`.\n */\n popperOptions?: unknown;\n children?: React.ReactNode;\n};\n\n// Props spreads onto S.Tooltip, so published type must admit its props. Base moved from styled(Tippy) to styled.div, requiring explicit declaration of zIndex, arrow, disabled, maxWidth.\ntype Props = Omit<React.ComponentPropsWithoutRef<typeof S.Tooltip>, keyof TooltipOwnProps> &\n TooltipOwnProps;\n\n// Props accepted-but-ignored: onClick/onChange/onSubmit filter is load-bearing (would activate dead handlers); modifiers/popperOptions are plan C6 deprecations.\nconst PROPS_NEVER_FORWARDED = ['onClick', 'onChange', 'onSubmit', 'modifiers', 'popperOptions'];\n\n/**\n * Tooltips display informative text when users hover over, focus on, or tap an element.\n *\n * ### Import\n *\n * ``` js\n * import { Tooltip } from '@ntbjs/react-components/data'\n * // or\n * import Tooltip from '@ntbjs/react-components/data/Tooltip'\n * ```\n */\nconst Tooltip = React.forwardRef<any, Props>(function Tooltip(\n {\n content = 'Tooltip',\n interactive = false,\n placement = 'top',\n duration = 350,\n trigger,\n visible,\n children,\n arrow: hasArrow = TIPPY_DEFAULT_ARROW,\n zIndex = TIPPY_DEFAULT_Z_INDEX,\n disabled = false,\n offset = TOOLTIP_OFFSET,\n maxWidth = TIPPY_DEFAULT_MAX_WIDTH,\n appendTo,\n onClickOutside,\n ...props\n },\n ref\n) {\n const onOpenChange = React.useCallback(\n (open: boolean, event?: Event, reason?: OpenChangeReason) => {\n if (!open && reason === 'outside-press') {\n onClickOutside?.(event);\n }\n },\n [onClickOutside]\n );\n\n const {\n refs,\n floatingStyles,\n context,\n getReferenceProps,\n getFloatingProps,\n isMounted,\n transitionStyles,\n arrowRef,\n placement: resolvedPlacement,\n pointerEvents\n } = useFloatingPopover({\n placement,\n open: visible,\n onOpenChange,\n trigger,\n offset,\n arrow: hasArrow,\n arrowHeight: TOOLTIP_ARROW_HEIGHT_IS_IN_THE_OFFSET_ALREADY,\n interactive,\n disabled,\n duration\n });\n\n // Reference is the CHILD (not wrapper) for positioning compat; ref merges forwarded ref, child's ref, and setReference.\n const childRef = React.isValidElement(children) ? getElementRef(children) : null;\n const referenceRef = useMergeRefs([ref, childRef, refs.setReference]);\n\n const filteredProps = Object.fromEntries(\n Object.entries(props).filter(([key]) => !PROPS_NEVER_FORWARDED.includes(key))\n );\n\n // Floating UI composes handlers with existing ones, so child's own handlers still work.\n const reference = React.isValidElement(children)\n ? React.cloneElement(\n children as React.ReactElement<Record<string, unknown>>,\n {\n ...getReferenceProps((children as React.ReactElement<Record<string, unknown>>).props),\n ref: referenceRef\n } as never\n )\n : children;\n\n // Inline rendering: 'parent' or (interactive && no explicit appendTo).\n const renderInline = appendTo === 'parent' || (interactive && appendTo === undefined);\n\n // null/undefined NOT interchangeable: undefined→document.body default, null→defer until reference exists.\n const resolvePortalRoot = (): HTMLElement | null | undefined => {\n if (renderInline || appendTo === undefined) return undefined;\n if (typeof appendTo === 'function') {\n const node = refs.reference.current;\n return node instanceof Element ? (appendTo(node) as HTMLElement) : null;\n }\n return appendTo as HTMLElement;\n };\n\n const floating = isMounted ? (\n <div\n ref={refs.setFloating}\n style={{ ...floatingStyles, zIndex, pointerEvents, maxWidth: POSITIONER_MAX_WIDTH }}\n {...getFloatingProps()}\n >\n {/*\n * filteredProps first so explicit attrs can't override transition/placement styles.\n */}\n {/* role + id are on the floating wrapper above via getFloatingProps() (useRole\n 'tooltip', the hook default); the box no longer hardcodes role. */}\n <S.Tooltip\n {...filteredProps}\n data-placement={resolvedPlacement}\n tabIndex={-1}\n style={{ ...transitionStyles, maxWidth }}\n >\n <div className=\"tippy-content\">{content}</div>\n {hasArrow && (\n <SharedFloatingArrow\n ref={arrowRef}\n context={context}\n data-arrow-surface=\"tooltip\"\n {...TOOLTIP_ARROW}\n />\n )}\n </S.Tooltip>\n </div>\n ) : null;\n\n // Bare wrapper preserved for compat; load-bearing for TextArea/CompactTextInput onMouseLeave.\n return (\n <div>\n {reference}\n {renderInline ? (\n floating\n ) : (\n <FloatingPortal root={resolvePortalRoot()}>{floating}</FloatingPortal>\n )}\n </div>\n );\n});\n\nexport default Tooltip;\n"],"names":["TIPPY_DEFAULT_ARROW","TIPPY_DEFAULT_MAX_WIDTH","TIPPY_DEFAULT_Z_INDEX","TOOLTIP_OFFSET","TOOLTIP_ARROW_HEIGHT_IS_IN_THE_OFFSET_ALREADY","POSITIONER_MAX_WIDTH","PROPS_NEVER_FORWARDED","Tooltip","React","forwardRef","content","interactive","placement","duration","trigger","visible","children","arrow","hasArrow","zIndex","disabled","offset","maxWidth","appendTo","onClickOutside","props","ref","onOpenChange","useCallback","open","event","reason","refs","floatingStyles","context","getReferenceProps","getFloatingProps","isMounted","transitionStyles","arrowRef","resolvedPlacement","pointerEvents","useFloatingPopover","arrowHeight","childRef","isValidElement","getElementRef","referenceRef","useMergeRefs","setReference","filteredProps","Object","fromEntries","entries","filter","key","includes","reference","cloneElement","renderInline","undefined","resolvePortalRoot","node","current","Element","floating","_jsx","setFloating","style","_jsxs","S","tabIndex","className","SharedFloatingArrow","TOOLTIP_ARROW","FloatingPortal","root"],"mappings":";;;;;;;;AAaA,MAAMA,mBAAmB,GAAG,IAAI;AAChC,MAAMC,uBAAuB,GAAG,GAAG;AACnC,MAAMC,qBAAqB,GAAG,IAAI;AAGlC,MAAMC,cAA4B,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC;AAC5C,MAAMC,6CAA6C,GAAG,CAAC;AAGvD,MAAMC,oBAAoB,GAAG,oBAAoB;AAmFjD,MAAMC,qBAAqB,GAAG,CAAC,SA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IAAI,CAACmC,WAAY;AACtBC,IAAAA,KAAK,EAAE;AAAE,MAAA,GAAGnC,cAAc;MAAEd,MAAM;MAAEsB,aAAa;AAAEnB,MAAAA,QAAQ,EAAEjB;KAAuB;IAAA,GAChF+B,gBAAgB,EAAE;AAAApB,IAAAA,QAAA,EAOtBqD,IAAA,CAACC,SAAS,EAAA;AAAA,MAAA,GACJpB,aAAa;AACjB,MAAA,gBAAA,EAAgBV,iBAAkB;MAClC+B,QAAQ,EAAE,EAAG;AACbH,MAAAA,KAAK,EAAE;AAAE,QAAA,GAAG9B,gBAAgB;AAAEhB,QAAAA;OAAW;AAAAN,MAAAA,QAAA,GAEzCkD,GAAA,CAAA,KAAA,EAAA;AAAKM,QAAAA,SAAS,EAAC,eAAe;AAAAxD,QAAAA,QAAA,EAAEN;AAAO,OAAM,CAAC,EAC7CQ,QAAQ,IACPgD,GAAA,CAACO,mBAAmB,EAAA;AAClB/C,QAAAA,GAAG,EAAEa,QAAS;AACdL,QAAAA,OAAO,EAAEA,OAAQ;AACjB,QAAA,oBAAA,EAAmB,SAAS;QAAA,GACxBwC;AAAa,OAClB,CACF;KACQ;GACR,CAAC,GACJ,IAAI;AAGR,EAAA,OACEL,IAAA,CAAA,KAAA,EAAA;IAAArD,QAAA,EAAA,CACGyC,SAAS,EACTE,YAAY,GACXM,QAAQ,GAERC,GAAA,CAACS,cAAc,EAAA;MAACC,IAAI,EAAEf,iBAAiB,EAAG;AAAA7C,MAAAA,QAAA,EAAEiD;AAAQ,KAAiB,CACtE;AAAA,GACE,CAAC;AAEV,CAAC;;;;"}
@@ -14,7 +14,7 @@ function useEventListener(eventName, handler, element, options) {
14
14
  return () => {
15
15
  targetElement.removeEventListener(eventName, listener, options);
16
16
  };
17
- }, [eventName, element, options]);
17
+ }, [eventName, element, element?.current, options]);
18
18
  }
19
19
 
20
20
  export { useEventListener };
@@ -1 +1 @@
1
- {"version":3,"file":"useEventListner.js","sources":["../../src/hooks/useEventListner.ts"],"sourcesContent":["import { useEffect, useRef } from 'react';\nimport useIsomorphicLayoutEffect from './useIsomorphicLayoutEffect';\n\nimport type { RefObject } from 'react';\n\n// Intersection, not interface extending all three — avoids lib.dom type incompatibilities\n// across TypeScript versions. All three maps are needed: target is runtime-chosen.\nexport type DomEventMap = WindowEventMap & HTMLElementEventMap & DocumentEventMap;\n\nexport type DomEventName = keyof DomEventMap;\n\n/**\n * Subscribes to a DOM event for the component lifetime, always calling the latest handler.\n * Element and options are optional (fall back to window and no options).\n *\n * @param eventName any DOM event name; selects the handler's event type\n * @param handler received event; stored in a ref so closures don't rebind the listener\n * @param element target ref; omit to listen on `window`\n * @param options forwarded to addEventListener and removeEventListener\n */\nfunction useEventListener<K extends DomEventName, T extends EventTarget = HTMLElement>(\n eventName: K,\n handler: (event: DomEventMap[K]) => void,\n element?: RefObject<T | null> | null,\n options?: boolean | AddEventListenerOptions\n): void {\n const savedHandler = useRef(handler);\n\n useIsomorphicLayoutEffect(() => {\n savedHandler.current = handler;\n }, [handler]);\n\n useEffect(() => {\n // Typed as EventTarget base — union of HTMLElement | Window would break overload\n // resolution for names valid on one but not the other. Precision belongs at the call site.\n const targetElement: EventTarget = element?.current ?? window;\n\n if (!(targetElement && targetElement.addEventListener)) return;\n\n // Cast event to DomEventMap[K] — EventListener signature is bare Event,\n // but K checked at call site guarantees which subclass arrives.\n const listener: EventListener = event => savedHandler.current(event as DomEventMap[K]);\n\n targetElement.addEventListener(eventName, listener, options);\n\n return () => {\n targetElement.removeEventListener(eventName, listener, options);\n };\n }, [eventName, element, options]);\n}\n\nexport { useEventListener };\n"],"names":["useEventListener","eventName","handler","element","options","savedHandler","useRef","useIsomorphicLayoutEffect","current","useEffect","targetElement","window","addEventListener","listener","event","removeEventListener"],"mappings":";;;AAoBA,SAASA,gBAAgBA,CACvBC,SAAY,EACZC,OAAwC,EACxCC,OAAoC,EACpCC,OAA2C,EACrC;AACN,EAAA,MAAMC,YAAY,GAAGC,MAAM,CAACJ,OAAO,CAAC;AAEpCK,EAAAA,yBAAyB,CAAC,MAAM;IAC9BF,YAAY,CAACG,OAAO,GAAGN,OAAO;AAChC,EAAA,CAAC,EAAE,CAACA,OAAO,CAAC,CAAC;AAEbO,EAAAA,SAAS,CAAC,MAAM;AAGd,IAAA,MAAMC,aAA0B,GAAGP,OAAO,EAAEK,OAAO,IAAIG,MAAM;AAE7D,IAAA,IAAI,EAAED,aAAa,IAAIA,aAAa,CAACE,gBAAgB,CAAC,EAAE;IAIxD,MAAMC,QAAuB,GAAGC,KAAK,IAAIT,YAAY,CAACG,OAAO,CAACM,KAAuB,CAAC;IAEtFJ,aAAa,CAACE,gBAAgB,CAACX,SAAS,EAAEY,QAAQ,EAAET,OAAO,CAAC;AAE5D,IAAA,OAAO,MAAM;MACXM,aAAa,CAACK,mBAAmB,CAACd,SAAS,EAAEY,QAAQ,EAAET,OAAO,CAAC;IACjE,CAAC;EACH,CAAC,EAAE,CAACH,SAAS,EAAEE,OAAO,EAAEC,OAAO,CAAC,CAAC;AACnC;;;;"}
1
+ {"version":3,"file":"useEventListner.js","sources":["../../src/hooks/useEventListner.ts"],"sourcesContent":["import { useEffect, useRef } from 'react';\nimport useIsomorphicLayoutEffect from './useIsomorphicLayoutEffect';\n\nimport type { RefObject } from 'react';\n\n// Intersection, not interface extending all three — avoids lib.dom type incompatibilities\n// across TypeScript versions. All three maps are needed: target is runtime-chosen.\nexport type DomEventMap = WindowEventMap & HTMLElementEventMap & DocumentEventMap;\n\nexport type DomEventName = keyof DomEventMap;\n\n/**\n * Subscribes to a DOM event for the component lifetime, always calling the latest handler.\n * Element and options are optional (fall back to window and no options).\n *\n * @param eventName any DOM event name; selects the handler's event type\n * @param handler received event; stored in a ref so closures don't rebind the listener\n * @param element target ref; omit to listen on `window`\n * @param options forwarded to addEventListener and removeEventListener\n */\nfunction useEventListener<K extends DomEventName, T extends EventTarget = HTMLElement>(\n eventName: K,\n handler: (event: DomEventMap[K]) => void,\n element?: RefObject<T | null> | null,\n options?: boolean | AddEventListenerOptions\n): void {\n const savedHandler = useRef(handler);\n\n useIsomorphicLayoutEffect(() => {\n savedHandler.current = handler;\n }, [handler]);\n\n useEffect(() => {\n // Typed as EventTarget base — union of HTMLElement | Window would break overload\n // resolution for names valid on one but not the other. Precision belongs at the call site.\n const targetElement: EventTarget = element?.current ?? window;\n\n if (!(targetElement && targetElement.addEventListener)) return;\n\n // Cast event to DomEventMap[K] — EventListener signature is bare Event,\n // but K checked at call site guarantees which subclass arrives.\n const listener: EventListener = event => savedHandler.current(event as DomEventMap[K]);\n\n targetElement.addEventListener(eventName, listener, options);\n\n return () => {\n targetElement.removeEventListener(eventName, listener, options);\n };\n // element?.current, not just element: a ref that is null at mount and assigned later\n // keeps the same ref-object identity, so without the resolved node here the listener\n // would stay bound to `window` forever. No-op for the window callers (element is\n // undefined), which is every caller today.\n }, [eventName, element, element?.current, options]);\n}\n\nexport { useEventListener };\n"],"names":["useEventListener","eventName","handler","element","options","savedHandler","useRef","useIsomorphicLayoutEffect","current","useEffect","targetElement","window","addEventListener","listener","event","removeEventListener"],"mappings":";;;AAoBA,SAASA,gBAAgBA,CACvBC,SAAY,EACZC,OAAwC,EACxCC,OAAoC,EACpCC,OAA2C,EACrC;AACN,EAAA,MAAMC,YAAY,GAAGC,MAAM,CAACJ,OAAO,CAAC;AAEpCK,EAAAA,yBAAyB,CAAC,MAAM;IAC9BF,YAAY,CAACG,OAAO,GAAGN,OAAO;AAChC,EAAA,CAAC,EAAE,CAACA,OAAO,CAAC,CAAC;AAEbO,EAAAA,SAAS,CAAC,MAAM;AAGd,IAAA,MAAMC,aAA0B,GAAGP,OAAO,EAAEK,OAAO,IAAIG,MAAM;AAE7D,IAAA,IAAI,EAAED,aAAa,IAAIA,aAAa,CAACE,gBAAgB,CAAC,EAAE;IAIxD,MAAMC,QAAuB,GAAGC,KAAK,IAAIT,YAAY,CAACG,OAAO,CAACM,KAAuB,CAAC;IAEtFJ,aAAa,CAACE,gBAAgB,CAACX,SAAS,EAAEY,QAAQ,EAAET,OAAO,CAAC;AAE5D,IAAA,OAAO,MAAM;MACXM,aAAa,CAACK,mBAAmB,CAACd,SAAS,EAAEY,QAAQ,EAAET,OAAO,CAAC;IACjE,CAAC;AAKH,EAAA,CAAC,EAAE,CAACH,SAAS,EAAEE,OAAO,EAAEA,OAAO,EAAEK,OAAO,EAAEJ,OAAO,CAAC,CAAC;AACrD;;;;"}
@@ -1,5 +1,5 @@
1
1
  import { useRef, useState, useEffect, useCallback, useMemo } from 'react';
2
- import { useFloating, autoUpdate, safePolygon, useClick, useHover, useFocus, useDismiss, useInteractions, useTransitionStyles, offset, autoPlacement, flip, shift, arrow, size } from '@floating-ui/react';
2
+ import { useFloating, autoUpdate, safePolygon, useClick, useHover, useFocus, useDismiss, useRole, useInteractions, useTransitionStyles, offset, autoPlacement, flip, shift, arrow, size } from '@floating-ui/react';
3
3
  import { parseTrigger } from '../utils/parseTrigger.js';
4
4
 
5
5
  const DEFAULT_ARROW_HEIGHT = 15;
@@ -78,6 +78,7 @@ function useFloatingPopover(options = {}) {
78
78
  arrow: hasArrow = false,
79
79
  arrowHeight = DEFAULT_ARROW_HEIGHT,
80
80
  interactive = false,
81
+ role: roleType = 'tooltip',
81
82
  disabled = false,
82
83
  duration,
83
84
  transition,
@@ -155,10 +156,13 @@ function useFloatingPopover(options = {}) {
155
156
  ...dismissProps,
156
157
  enabled: !disabled
157
158
  });
159
+ const role = useRole(context, {
160
+ role: roleType
161
+ });
158
162
  const {
159
163
  getReferenceProps,
160
164
  getFloatingProps
161
- } = useInteractions([click, hover, focus, dismiss]);
165
+ } = useInteractions([click, hover, focus, dismiss, role]);
162
166
  const {
163
167
  isMounted,
164
168
  styles: transitionStyles
@@ -1 +1 @@
1
- {"version":3,"file":"useFloatingPopover.js","sources":["../../src/hooks/useFloatingPopover.ts"],"sourcesContent":["/**\n * Positions and drives one floating element, replacing `@tippyjs/react`.\n *\n * This hook handles POSITION and INTERACTION; the caller renders elements,\n * wrappers, portal, and arrow. That separation is intentional — different\n * consumers need different markup (`.tippy-content` shim for `Popover`,\n * context-menu variant for menus, different arrows for summary cards).\n *\n * Four non-obvious compatibility rules are documented in the impl: controlled\n * mode disables triggers but not dismiss; `disabled` means \"cannot open\";\n * `offset[1]` is arrow-tip gap not box distance (see `DEFAULT_ARROW_HEIGHT`);\n * escape is off by default (WAI-ARIA change, requires explicit opt-in).\n */\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react';\n\nimport {\n arrow,\n autoPlacement,\n autoUpdate,\n flip,\n offset,\n safePolygon,\n shift,\n size,\n useClick,\n useDismiss,\n useFloating,\n useFocus,\n useHover,\n useInteractions,\n useTransitionStyles\n} from '@floating-ui/react';\n\nimport { parseTrigger } from '../utils/parseTrigger';\n\nimport type {\n Middleware,\n OpenChangeReason,\n Placement,\n Side,\n UseClickProps,\n UseDismissProps,\n UseFloatingReturn,\n UseFocusProps,\n UseHoverProps,\n UseTransitionStylesProps\n} from '@floating-ui/react';\n\n// Arrow height in px. The `Popover` offset prop means \"gap between arrow tip and reference\",\n// not box distance, so `mainAxis = distance + height` must use this value — see\n// `Popover.styled.ts` and `FloatingArrow.styled.ts` for the full measurement chain.\nexport const DEFAULT_ARROW_HEIGHT = 15;\n\nconst DEFAULT_MAX_HEIGHT_PADDING = 10;\nconst DEFAULT_COLLISION_PADDING = 5;\n\n// From tippy's shift-away-subtle animation — matches the `translate` distance in its CSS.\nconst SHIFT_AWAY_SUBTLE_DISTANCE = 5;\n\n// Floating UI Placement plus Popper's auto values (handled by autoPlacement middleware).\nexport type PopoverPlacement = Placement | AutoPlacement;\nexport type AutoPlacement = 'auto' | 'auto-start' | 'auto-end';\n\nexport type PopperOffset = readonly [skidding: number, distance: number];\n\n// Type predicate (not just boolean) so placement narrows to Exclude<PopoverPlacement, AutoPlacement>.\nfunction isAutoPlacement(placement: PopoverPlacement): placement is AutoPlacement {\n return placement === 'auto' || placement === 'auto-start' || placement === 'auto-end';\n}\n\n// Placement-aware transition matching tippy's shift-away-subtle animation.\n// Function form lets useTransitionStyles hand us the resolved side after flip.\nconst shiftAwaySubtle = ({ side }: { side: Side }) => {\n const transform = {\n top: `translateY(${SHIFT_AWAY_SUBTLE_DISTANCE}px)`,\n bottom: `translateY(-${SHIFT_AWAY_SUBTLE_DISTANCE}px)`,\n left: `translateX(${SHIFT_AWAY_SUBTLE_DISTANCE}px)`,\n right: `translateX(-${SHIFT_AWAY_SUBTLE_DISTANCE}px)`\n }[side];\n\n return { opacity: 0, transform };\n};\n\n/** What `useFloatingPopover` accepts. Every member is optional. */\nexport interface UseFloatingPopoverOptions {\n /**\n * Preferred placement, in the shared Popper/Floating UI vocabulary. `auto`,\n * `auto-start` and `auto-end` swap `flip()` for `autoPlacement()`.\n *\n * @default 'bottom'\n */\n placement?: PopoverPlacement;\n /**\n * Controlled open state — our `visible` prop. `undefined` (the default) means\n * UNCONTROLLED: the hook owns the state and the parsed `trigger` drives it. Any\n * boolean, INCLUDING `false`, means controlled and turns the trigger Hooks off;\n * see rule 1 in the file header.\n */\n open?: boolean;\n /**\n * Called on every open-state change, controlled or not, with Floating UI's\n * `reason`. `reason === 'outside-press'` is what `Popover`'s `onClickOutside`\n * prop maps onto.\n */\n onOpenChange?: (open: boolean, event?: Event, reason?: OpenChangeReason) => void;\n /**\n * tippy's `trigger` space-string, e.g. `'click focus'`, `'mouseenter'`, `''`.\n * `undefined` means tippy's default (`'mouseenter focus'`) and `''` means no\n * triggers at all — `parseTrigger` owns both rules and documents where `''` is\n * used in the consumers.\n */\n trigger?: string | null;\n /**\n * `[skidding, distance]` where distance is the arrow-tip gap (see `DEFAULT_ARROW_HEIGHT`).\n * Skidding maps to Floating UI's `crossAxis` (no sign flip for `-end` placements).\n * @default [0, 0]\n */\n offset?: PopperOffset;\n /**\n * Whether an arrow is rendered. The hook does not render it — it only adds the\n * `arrow()` middleware, exposes `arrowRef`, and adds `arrowHeight` to the\n * main-axis offset.\n *\n * @default false\n */\n arrow?: boolean;\n /**\n * Height in px of the arrow the caller renders, i.e. how far it protrudes from\n * the floating element. Only read when `arrow` is `true`.\n *\n * @default DEFAULT_ARROW_HEIGHT (15 — the popover arrow; see its derivation)\n */\n arrowHeight?: number;\n /**\n * Pointer can travel from reference to floating element without closing.\n * Also determines `pointerEvents` in the return value.\n * @default false\n */\n interactive?: boolean;\n /**\n * tippy's `disabled`: can never open. Forces the resolved open state to `false`\n * and disables every interaction Hook (rule 2 in the file header).\n *\n * @default false\n */\n disabled?: boolean;\n /**\n * Transition duration in ms — our `duration` prop, fed to\n * `useTransitionStyles`. tippy's own default is the asymmetric `[300, 250]`;\n * both our components default it to `350`, so there is no default here and the\n * caller states it.\n */\n duration?: UseTransitionStylesProps['duration'];\n /**\n * Overrides for the transition. `initial` defaults to a placement-aware\n * reproduction of tippy's `animation=\"shift-away-subtle\"`, which both\n * components hardcode.\n */\n transition?: Omit<UseTransitionStylesProps, 'duration'>;\n /**\n * `useDismiss` overrides. Defaults match tippy: `outsidePress: true`,\n * `referencePress: false`, `escapeKey: false`. `enabled` is `!disabled`.\n */\n dismiss?: Omit<UseDismissProps, 'enabled'>;\n /** `useHover` overrides, e.g. `restMs`. `enabled` and `handleClose` are owned here. */\n hover?: Omit<UseHoverProps, 'enabled' | 'handleClose'>;\n /** `useClick` overrides. `enabled` is owned here. */\n click?: Omit<UseClickProps, 'enabled'>;\n /**\n * `useFocus` overrides. `visibleOnly` defaults to `false` (not Floating UI's `true`)\n * to match tippy's plain focusin listener without :focus-visible test.\n */\n focus?: Omit<UseFocusProps, 'enabled'>;\n /**\n * Cap floating element height to available space. Opt-in; only Popover uses it.\n * @default false\n */\n constrainHeight?: boolean;\n /** `padding` for the height cap. @default 10, from the modifier it replaces */\n maxHeightPadding?: number;\n /** `padding` for `flip()` / `shift()`. @default 5 */\n collisionPadding?: number;\n /**\n * `FloatingTree` node id, for nested context-menu submenus. Passed straight to\n * `useFloating`; unused until the `contextMenuSublevel` work (plan C5).\n */\n nodeId?: string;\n /** Extra middleware, appended last. */\n middleware?: Middleware[];\n}\n\n/** What `useFloatingPopover` returns. */\nexport interface UseFloatingPopoverReturn {\n /** `refs.setReference` / `refs.setFloating`, straight from `useFloating`. */\n refs: UseFloatingReturn['refs'];\n /** Absolute-position styles for the floating element. */\n floatingStyles: UseFloatingReturn['floatingStyles'];\n /** The Floating UI context — needed by `FloatingArrow`, `FloatingPortal`, `FloatingTree`. */\n context: UseFloatingReturn['context'];\n /** Spread onto the reference element. */\n getReferenceProps: ReturnType<typeof useInteractions>['getReferenceProps'];\n /** Spread onto the floating element. */\n getFloatingProps: ReturnType<typeof useInteractions>['getFloatingProps'];\n /** `true` while the element should be in the DOM, including during the close transition. */\n isMounted: boolean;\n /**\n * The transition styles for the current phase. Named `transitionStyles` and not\n * `styles` so a call site cannot confuse it with `floatingStyles` — the two are\n * applied to different elements (position on the outer, transition on the\n * inner) in all three existing implementations.\n */\n transitionStyles: ReturnType<typeof useTransitionStyles>['styles'];\n /** Attach to the rendered arrow. Already wired into the `arrow()` middleware. */\n arrowRef: React.MutableRefObject<SVGSVGElement | null>;\n /** The resolved open state, after `disabled` and controlled/uncontrolled resolution. */\n isOpen: boolean;\n /**\n * Imperative open/close, honouring controlled mode by reporting through\n * `onOpenChange`. This is what replaces the `_tippy.hide()` + `[data-tippy-root]`\n * DOM sweep in `Popover.tsx`'s `handleContextMenuItemClick`.\n */\n setOpen: (open: boolean, event?: Event, reason?: OpenChangeReason) => void;\n /** The placement actually used after `flip()` / `autoPlacement()` resolved it. */\n placement: Placement;\n /**\n * `'none'` when `interactive` is `false`, otherwise `undefined`. tippy sets\n * `pointer-events: none` on the popper root of a non-interactive instance; the\n * hook reports the value rather than applying it, because which element carries\n * it differs per call site.\n */\n pointerEvents: 'none' | undefined;\n}\n\n// Middleware order is part of the contract: offset, flip/autoPlacement (mutually exclusive),\n// shift, arrow, then size last (must come after flip for bestFit to see constrained size).\nfunction buildMiddleware(options: {\n placement: PopoverPlacement;\n mainAxis: number;\n crossAxis: number;\n arrow: boolean;\n arrowRef: React.MutableRefObject<SVGSVGElement | null>;\n constrainHeight: boolean;\n maxHeightPadding: number;\n collisionPadding: number;\n extra?: Middleware[];\n}): Middleware[] {\n const middleware: Middleware[] = [\n offset({ mainAxis: options.mainAxis, crossAxis: options.crossAxis })\n ];\n\n if (isAutoPlacement(options.placement)) {\n // auto-start/auto-end mean \"best base placement, keep alignment\", so autoAlignment: false.\n // No consumer uses it today, but both components' types allow it.\n const alignment =\n options.placement === 'auto-start'\n ? ('start' as const)\n : options.placement === 'auto-end'\n ? ('end' as const)\n : undefined;\n\n middleware.push(\n autoPlacement({\n padding: options.collisionPadding,\n ...(alignment ? { alignment, autoAlignment: false } : {})\n })\n );\n } else {\n middleware.push(flip({ padding: options.collisionPadding }));\n }\n\n middleware.push(shift({ padding: options.collisionPadding }));\n\n if (options.arrow) {\n middleware.push(arrow({ element: options.arrowRef }));\n }\n\n if (options.constrainHeight) {\n middleware.push(\n size({\n padding: options.maxHeightPadding,\n // Clear max-height before reading scrollHeight to avoid latching on clamped measurements.\n // Avoids spurious scrollbars in content that fits (like 3-item context menus).\n apply({ availableHeight, elements }) {\n elements.floating.style.maxHeight = '';\n\n const fits = elements.floating.scrollHeight <= availableHeight;\n\n elements.floating.style.maxHeight = fits ? '' : `${Math.max(0, availableHeight)}px`;\n }\n })\n );\n }\n\n if (options.extra?.length) {\n middleware.push(...options.extra);\n }\n\n return middleware;\n}\n\n/**\n * Positions and drives one floating element.\n *\n * @param options see `UseFloatingPopoverOptions`; every member is optional\n */\nexport function useFloatingPopover(\n options: UseFloatingPopoverOptions = {}\n): UseFloatingPopoverReturn {\n const {\n placement = 'bottom',\n open,\n onOpenChange,\n trigger,\n offset: offsetProp = [0, 0],\n arrow: hasArrow = false,\n arrowHeight = DEFAULT_ARROW_HEIGHT,\n interactive = false,\n disabled = false,\n duration,\n transition,\n dismiss: dismissProps,\n hover: hoverProps,\n click: clickProps,\n focus: focusProps,\n constrainHeight = false,\n maxHeightPadding = DEFAULT_MAX_HEIGHT_PADDING,\n collisionPadding = DEFAULT_COLLISION_PADDING,\n nodeId,\n middleware: extraMiddleware\n } = options;\n\n const arrowRef = useRef<SVGSVGElement | null>(null);\n\n // Use typeof, not !== undefined: null (from computed refs) must mean uncontrolled.\n const isControlled = typeof open === 'boolean';\n const [uncontrolledOpen, setUncontrolledOpen] = useState(false);\n const isOpen = disabled ? false : isControlled ? open : uncontrolledOpen;\n\n // Clear uncontrolled state when disabled, not just mask in isOpen — otherwise stale true reopens it.\n useEffect(() => {\n if (disabled) {\n setUncontrolledOpen(false);\n }\n }, [disabled]);\n\n const setOpen = useCallback(\n (next: boolean, event?: Event, reason?: OpenChangeReason) => {\n if (!isControlled) {\n setUncontrolledOpen(next);\n }\n\n onOpenChange?.(next, event, reason);\n },\n [isControlled, onOpenChange]\n );\n\n const [skidding, distance] = offsetProp;\n\n const middleware = useMemo(\n () =>\n buildMiddleware({\n placement,\n mainAxis: distance + (hasArrow ? arrowHeight : 0),\n crossAxis: skidding,\n arrow: hasArrow,\n arrowRef,\n constrainHeight,\n maxHeightPadding,\n collisionPadding,\n extra: extraMiddleware\n }),\n [\n placement,\n distance,\n skidding,\n hasArrow,\n arrowHeight,\n constrainHeight,\n maxHeightPadding,\n collisionPadding,\n extraMiddleware\n ]\n );\n\n const {\n refs,\n floatingStyles,\n context,\n placement: resolvedPlacement\n } = useFloating({\n // Undefined for auto* placements: autoPlacement() overwrites it anyway.\n placement: isAutoPlacement(placement) ? undefined : placement,\n open: isOpen,\n onOpenChange: setOpen,\n whileElementsMounted: autoUpdate,\n middleware,\n nodeId\n });\n\n const triggers = useMemo(() => parseTrigger(trigger), [trigger]);\n\n // Controlled mode and disabled both turn off triggers (tippy semantics).\n const triggersEnabled = !disabled && !isControlled;\n\n // Memoized so useHover doesn't re-attach handlers when safePolygon() is called.\n const handleClose = useMemo(() => (interactive ? safePolygon() : null), [interactive]);\n\n const click = useClick(context, { ...clickProps, enabled: triggersEnabled && triggers.click });\n const hover = useHover(context, {\n ...hoverProps,\n enabled: triggersEnabled && triggers.hover,\n handleClose\n });\n const focus = useFocus(context, {\n visibleOnly: false,\n ...focusProps,\n enabled: triggersEnabled && triggers.focus\n });\n const dismiss = useDismiss(context, {\n escapeKey: false,\n outsidePress: true,\n referencePress: false,\n ...dismissProps,\n enabled: !disabled\n });\n\n const { getReferenceProps, getFloatingProps } = useInteractions([click, hover, focus, dismiss]);\n\n const { isMounted, styles: transitionStyles } = useTransitionStyles(context, {\n initial: shiftAwaySubtle,\n ...transition,\n duration\n });\n\n return {\n refs,\n floatingStyles,\n context,\n getReferenceProps,\n getFloatingProps,\n isMounted,\n transitionStyles,\n arrowRef,\n isOpen,\n setOpen,\n placement: resolvedPlacement,\n pointerEvents: interactive ? undefined : 'none'\n };\n}\n\nexport default useFloatingPopover;\n"],"names":["DEFAULT_ARROW_HEIGHT","DEFAULT_MAX_HEIGHT_PADDING","DEFAULT_COLLISION_PADDING","SHIFT_AWAY_SUBTLE_DISTANCE","isAutoPlacement","placement","shiftAwaySubtle","side","transform","top","bottom","left","right","opacity","buildMiddleware","options","middleware","offset","mainAxis","crossAxis","alignment","undefined","push","autoPlacement","padding","collisionPadding","autoAlignment","flip","shift","arrow","element","arrowRef","constrainHeight","size","maxHeightPadding","apply","availableHeight","elements","floating","style","maxHeight","fits","scrollHeight","Math","max","extra","length","useFloatingPopover","open","onOpenChange","trigger","offsetProp","hasArrow","arrowHeight","interactive","disabled","duration","transition","dismiss","dismissProps","hover","hoverProps","click","clickProps","focus","focusProps","nodeId","extraMiddleware","useRef","isControlled","uncontrolledOpen","setUncontrolledOpen","useState","isOpen","useEffect","setOpen","useCallback","next","event","reason","skidding","distance","useMemo","refs","floatingStyles","context","resolvedPlacement","useFloating","whileElementsMounted","autoUpdate","triggers","parseTrigger","triggersEnabled","handleClose","safePolygon","useClick","enabled","useHover","useFocus","visibleOnly","useDismiss","escapeKey","outsidePress","referencePress","getReferenceProps","getFloatingProps","useInteractions","isMounted","styles","transitionStyles","useTransitionStyles","init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IAAA,GAAGmD,UAAU;AACbD,IAAAA;AACF,GAAC,CAAC;EAEF,OAAO;IACL2B,IAAI;IACJC,cAAc;IACdC,OAAO;IACPmB,iBAAiB;IACjBC,gBAAgB;IAChBE,SAAS;IACTE,gBAAgB;IAChB9E,QAAQ;IACR0C,MAAM;IACNE,OAAO;AACPtE,IAAAA,SAAS,EAAEiF,iBAAiB;AAC5B0B,IAAAA,aAAa,EAAE1D,WAAW,GAAGjC,SAAS,GAAG;GAC1C;AACH;;;;"}
1
+ {"version":3,"file":"useFloatingPopover.js","sources":["../../src/hooks/useFloatingPopover.ts"],"sourcesContent":["/**\n * Positions and drives one floating element, replacing `@tippyjs/react`.\n *\n * This hook handles POSITION and INTERACTION; the caller renders elements,\n * wrappers, portal, and arrow. That separation is intentional — different\n * consumers need different markup (`.tippy-content` shim for `Popover`,\n * context-menu variant for menus, different arrows for summary cards).\n *\n * Four non-obvious compatibility rules are documented in the impl: controlled\n * mode disables triggers but not dismiss; `disabled` means \"cannot open\";\n * `offset[1]` is arrow-tip gap not box distance (see `DEFAULT_ARROW_HEIGHT`);\n * escape is off by default (WAI-ARIA change, requires explicit opt-in).\n */\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react';\n\nimport {\n arrow,\n autoPlacement,\n autoUpdate,\n flip,\n offset,\n safePolygon,\n shift,\n size,\n useClick,\n useDismiss,\n useFloating,\n useFocus,\n useHover,\n useInteractions,\n useRole,\n useTransitionStyles\n} from '@floating-ui/react';\n\nimport { parseTrigger } from '../utils/parseTrigger';\n\nimport type {\n Middleware,\n OpenChangeReason,\n Placement,\n Side,\n UseClickProps,\n UseDismissProps,\n UseFloatingReturn,\n UseFocusProps,\n UseHoverProps,\n UseRoleProps,\n UseTransitionStylesProps\n} from '@floating-ui/react';\n\n// Arrow height in px. The `Popover` offset prop means \"gap between arrow tip and reference\",\n// not box distance, so `mainAxis = distance + height` must use this value — see\n// `Popover.styled.ts` and `FloatingArrow.styled.ts` for the full measurement chain.\nexport const DEFAULT_ARROW_HEIGHT = 15;\n\nconst DEFAULT_MAX_HEIGHT_PADDING = 10;\nconst DEFAULT_COLLISION_PADDING = 5;\n\n// From tippy's shift-away-subtle animation — matches the `translate` distance in its CSS.\nconst SHIFT_AWAY_SUBTLE_DISTANCE = 5;\n\n// Floating UI Placement plus Popper's auto values (handled by autoPlacement middleware).\nexport type PopoverPlacement = Placement | AutoPlacement;\nexport type AutoPlacement = 'auto' | 'auto-start' | 'auto-end';\n\nexport type PopperOffset = readonly [skidding: number, distance: number];\n\n// Type predicate (not just boolean) so placement narrows to Exclude<PopoverPlacement, AutoPlacement>.\nfunction isAutoPlacement(placement: PopoverPlacement): placement is AutoPlacement {\n return placement === 'auto' || placement === 'auto-start' || placement === 'auto-end';\n}\n\n// Placement-aware transition matching tippy's shift-away-subtle animation.\n// Function form lets useTransitionStyles hand us the resolved side after flip.\nconst shiftAwaySubtle = ({ side }: { side: Side }) => {\n const transform = {\n top: `translateY(${SHIFT_AWAY_SUBTLE_DISTANCE}px)`,\n bottom: `translateY(-${SHIFT_AWAY_SUBTLE_DISTANCE}px)`,\n left: `translateX(${SHIFT_AWAY_SUBTLE_DISTANCE}px)`,\n right: `translateX(-${SHIFT_AWAY_SUBTLE_DISTANCE}px)`\n }[side];\n\n return { opacity: 0, transform };\n};\n\n/** What `useFloatingPopover` accepts. Every member is optional. */\nexport interface UseFloatingPopoverOptions {\n /**\n * Preferred placement, in the shared Popper/Floating UI vocabulary. `auto`,\n * `auto-start` and `auto-end` swap `flip()` for `autoPlacement()`.\n *\n * @default 'bottom'\n */\n placement?: PopoverPlacement;\n /**\n * Controlled open state — our `visible` prop. `undefined` (the default) means\n * UNCONTROLLED: the hook owns the state and the parsed `trigger` drives it. Any\n * boolean, INCLUDING `false`, means controlled and turns the trigger Hooks off;\n * see rule 1 in the file header.\n */\n open?: boolean;\n /**\n * Called on every open-state change, controlled or not, with Floating UI's\n * `reason`. `reason === 'outside-press'` is what `Popover`'s `onClickOutside`\n * prop maps onto.\n */\n onOpenChange?: (open: boolean, event?: Event, reason?: OpenChangeReason) => void;\n /**\n * tippy's `trigger` space-string, e.g. `'click focus'`, `'mouseenter'`, `''`.\n * `undefined` means tippy's default (`'mouseenter focus'`) and `''` means no\n * triggers at all — `parseTrigger` owns both rules and documents where `''` is\n * used in the consumers.\n */\n trigger?: string | null;\n /**\n * `[skidding, distance]` where distance is the arrow-tip gap (see `DEFAULT_ARROW_HEIGHT`).\n * Skidding maps to Floating UI's `crossAxis` (no sign flip for `-end` placements).\n * @default [0, 0]\n */\n offset?: PopperOffset;\n /**\n * Whether an arrow is rendered. The hook does not render it — it only adds the\n * `arrow()` middleware, exposes `arrowRef`, and adds `arrowHeight` to the\n * main-axis offset.\n *\n * @default false\n */\n arrow?: boolean;\n /**\n * Height in px of the arrow the caller renders, i.e. how far it protrudes from\n * the floating element. Only read when `arrow` is `true`.\n *\n * @default DEFAULT_ARROW_HEIGHT (15 — the popover arrow; see its derivation)\n */\n arrowHeight?: number;\n /**\n * Pointer can travel from reference to floating element without closing.\n * Also determines `pointerEvents` in the return value.\n * @default false\n */\n interactive?: boolean;\n /**\n * ARIA role for the floating element, wired through `useRole`. Sets the role and an\n * `id` on the floating element and the matching `aria-*` on the reference while open —\n * `aria-describedby` for `'tooltip'`, `aria-expanded` + `aria-haspopup` for `'dialog'`.\n * tippy set these from its `aria` option; the Floating UI port dropped them, so callers\n * pass the role that restores the announcement. Omit to leave the floating element\n * without a managed role.\n *\n * @default 'tooltip'\n */\n role?: UseRoleProps['role'];\n /**\n * tippy's `disabled`: can never open. Forces the resolved open state to `false`\n * and disables every interaction Hook (rule 2 in the file header).\n *\n * @default false\n */\n disabled?: boolean;\n /**\n * Transition duration in ms — our `duration` prop, fed to\n * `useTransitionStyles`. tippy's own default is the asymmetric `[300, 250]`;\n * both our components default it to `350`, so there is no default here and the\n * caller states it.\n */\n duration?: UseTransitionStylesProps['duration'];\n /**\n * Overrides for the transition. `initial` defaults to a placement-aware\n * reproduction of tippy's `animation=\"shift-away-subtle\"`, which both\n * components hardcode.\n */\n transition?: Omit<UseTransitionStylesProps, 'duration'>;\n /**\n * `useDismiss` overrides. Defaults match tippy: `outsidePress: true`,\n * `referencePress: false`, `escapeKey: false`. `enabled` is `!disabled`.\n */\n dismiss?: Omit<UseDismissProps, 'enabled'>;\n /** `useHover` overrides, e.g. `restMs`. `enabled` and `handleClose` are owned here. */\n hover?: Omit<UseHoverProps, 'enabled' | 'handleClose'>;\n /** `useClick` overrides. `enabled` is owned here. */\n click?: Omit<UseClickProps, 'enabled'>;\n /**\n * `useFocus` overrides. `visibleOnly` defaults to `false` (not Floating UI's `true`)\n * to match tippy's plain focusin listener without :focus-visible test.\n */\n focus?: Omit<UseFocusProps, 'enabled'>;\n /**\n * Cap floating element height to available space. Opt-in; only Popover uses it.\n * @default false\n */\n constrainHeight?: boolean;\n /** `padding` for the height cap. @default 10, from the modifier it replaces */\n maxHeightPadding?: number;\n /** `padding` for `flip()` / `shift()`. @default 5 */\n collisionPadding?: number;\n /**\n * `FloatingTree` node id, for nested context-menu submenus. Passed straight to\n * `useFloating`; unused until the `contextMenuSublevel` work (plan C5).\n */\n nodeId?: string;\n /** Extra middleware, appended last. */\n middleware?: Middleware[];\n}\n\n/** What `useFloatingPopover` returns. */\nexport interface UseFloatingPopoverReturn {\n /** `refs.setReference` / `refs.setFloating`, straight from `useFloating`. */\n refs: UseFloatingReturn['refs'];\n /** Absolute-position styles for the floating element. */\n floatingStyles: UseFloatingReturn['floatingStyles'];\n /** The Floating UI context — needed by `FloatingArrow`, `FloatingPortal`, `FloatingTree`. */\n context: UseFloatingReturn['context'];\n /** Spread onto the reference element. */\n getReferenceProps: ReturnType<typeof useInteractions>['getReferenceProps'];\n /** Spread onto the floating element. */\n getFloatingProps: ReturnType<typeof useInteractions>['getFloatingProps'];\n /** `true` while the element should be in the DOM, including during the close transition. */\n isMounted: boolean;\n /**\n * The transition styles for the current phase. Named `transitionStyles` and not\n * `styles` so a call site cannot confuse it with `floatingStyles` — the two are\n * applied to different elements (position on the outer, transition on the\n * inner) in all three existing implementations.\n */\n transitionStyles: ReturnType<typeof useTransitionStyles>['styles'];\n /** Attach to the rendered arrow. Already wired into the `arrow()` middleware. */\n arrowRef: React.MutableRefObject<SVGSVGElement | null>;\n /** The resolved open state, after `disabled` and controlled/uncontrolled resolution. */\n isOpen: boolean;\n /**\n * Imperative open/close, honouring controlled mode by reporting through\n * `onOpenChange`. This is what replaces the `_tippy.hide()` + `[data-tippy-root]`\n * DOM sweep in `Popover.tsx`'s `handleContextMenuItemClick`.\n */\n setOpen: (open: boolean, event?: Event, reason?: OpenChangeReason) => void;\n /** The placement actually used after `flip()` / `autoPlacement()` resolved it. */\n placement: Placement;\n /**\n * `'none'` when `interactive` is `false`, otherwise `undefined`. tippy sets\n * `pointer-events: none` on the popper root of a non-interactive instance; the\n * hook reports the value rather than applying it, because which element carries\n * it differs per call site.\n */\n pointerEvents: 'none' | undefined;\n}\n\n// Middleware order is part of the contract: offset, flip/autoPlacement (mutually exclusive),\n// shift, arrow, then size last (must come after flip for bestFit to see constrained size).\nfunction buildMiddleware(options: {\n placement: PopoverPlacement;\n mainAxis: number;\n crossAxis: number;\n arrow: boolean;\n arrowRef: React.MutableRefObject<SVGSVGElement | null>;\n constrainHeight: boolean;\n maxHeightPadding: number;\n collisionPadding: number;\n extra?: Middleware[];\n}): Middleware[] {\n const middleware: Middleware[] = [\n offset({ mainAxis: options.mainAxis, crossAxis: options.crossAxis })\n ];\n\n if (isAutoPlacement(options.placement)) {\n // auto-start/auto-end mean \"best base placement, keep alignment\", so autoAlignment: false.\n // No consumer uses it today, but both components' types allow it.\n const alignment =\n options.placement === 'auto-start'\n ? ('start' as const)\n : options.placement === 'auto-end'\n ? ('end' as const)\n : undefined;\n\n middleware.push(\n autoPlacement({\n padding: options.collisionPadding,\n ...(alignment ? { alignment, autoAlignment: false } : {})\n })\n );\n } else {\n middleware.push(flip({ padding: options.collisionPadding }));\n }\n\n middleware.push(shift({ padding: options.collisionPadding }));\n\n if (options.arrow) {\n middleware.push(arrow({ element: options.arrowRef }));\n }\n\n if (options.constrainHeight) {\n middleware.push(\n size({\n padding: options.maxHeightPadding,\n // Clear max-height before reading scrollHeight to avoid latching on clamped measurements.\n // Avoids spurious scrollbars in content that fits (like 3-item context menus).\n apply({ availableHeight, elements }) {\n elements.floating.style.maxHeight = '';\n\n const fits = elements.floating.scrollHeight <= availableHeight;\n\n elements.floating.style.maxHeight = fits ? '' : `${Math.max(0, availableHeight)}px`;\n }\n })\n );\n }\n\n if (options.extra?.length) {\n middleware.push(...options.extra);\n }\n\n return middleware;\n}\n\n/**\n * Positions and drives one floating element.\n *\n * @param options see `UseFloatingPopoverOptions`; every member is optional\n */\nexport function useFloatingPopover(\n options: UseFloatingPopoverOptions = {}\n): UseFloatingPopoverReturn {\n const {\n placement = 'bottom',\n open,\n onOpenChange,\n trigger,\n offset: offsetProp = [0, 0],\n arrow: hasArrow = false,\n arrowHeight = DEFAULT_ARROW_HEIGHT,\n interactive = false,\n role: roleType = 'tooltip',\n disabled = false,\n duration,\n transition,\n dismiss: dismissProps,\n hover: hoverProps,\n click: clickProps,\n focus: focusProps,\n constrainHeight = false,\n maxHeightPadding = DEFAULT_MAX_HEIGHT_PADDING,\n collisionPadding = DEFAULT_COLLISION_PADDING,\n nodeId,\n middleware: extraMiddleware\n } = options;\n\n const arrowRef = useRef<SVGSVGElement | null>(null);\n\n // Use typeof, not !== undefined: null (from computed refs) must mean uncontrolled.\n const isControlled = typeof open === 'boolean';\n const [uncontrolledOpen, setUncontrolledOpen] = useState(false);\n const isOpen = disabled ? false : isControlled ? open : uncontrolledOpen;\n\n // Clear uncontrolled state when disabled, not just mask in isOpen — otherwise stale true reopens it.\n useEffect(() => {\n if (disabled) {\n setUncontrolledOpen(false);\n }\n }, [disabled]);\n\n const setOpen = useCallback(\n (next: boolean, event?: Event, reason?: OpenChangeReason) => {\n if (!isControlled) {\n setUncontrolledOpen(next);\n }\n\n onOpenChange?.(next, event, reason);\n },\n [isControlled, onOpenChange]\n );\n\n const [skidding, distance] = offsetProp;\n\n const middleware = useMemo(\n () =>\n buildMiddleware({\n placement,\n mainAxis: distance + (hasArrow ? arrowHeight : 0),\n crossAxis: skidding,\n arrow: hasArrow,\n arrowRef,\n constrainHeight,\n maxHeightPadding,\n collisionPadding,\n extra: extraMiddleware\n }),\n [\n placement,\n distance,\n skidding,\n hasArrow,\n arrowHeight,\n constrainHeight,\n maxHeightPadding,\n collisionPadding,\n extraMiddleware\n ]\n );\n\n const {\n refs,\n floatingStyles,\n context,\n placement: resolvedPlacement\n } = useFloating({\n // Undefined for auto* placements: autoPlacement() overwrites it anyway.\n placement: isAutoPlacement(placement) ? undefined : placement,\n open: isOpen,\n onOpenChange: setOpen,\n whileElementsMounted: autoUpdate,\n middleware,\n nodeId\n });\n\n const triggers = useMemo(() => parseTrigger(trigger), [trigger]);\n\n // Controlled mode and disabled both turn off triggers (tippy semantics).\n const triggersEnabled = !disabled && !isControlled;\n\n // Memoized so useHover doesn't re-attach handlers when safePolygon() is called.\n const handleClose = useMemo(() => (interactive ? safePolygon() : null), [interactive]);\n\n const click = useClick(context, { ...clickProps, enabled: triggersEnabled && triggers.click });\n const hover = useHover(context, {\n ...hoverProps,\n enabled: triggersEnabled && triggers.hover,\n handleClose\n });\n const focus = useFocus(context, {\n visibleOnly: false,\n ...focusProps,\n enabled: triggersEnabled && triggers.focus\n });\n const dismiss = useDismiss(context, {\n escapeKey: false,\n outsidePress: true,\n referencePress: false,\n ...dismissProps,\n enabled: !disabled\n });\n\n // Restores the aria tippy set from its `aria` option: `aria-describedby` (tooltip) or\n // `aria-expanded` + `aria-haspopup` (dialog) on the reference, role + id on the floating\n // element. Static attributes only — no effect on looks or pointer/keyboard behaviour.\n const role = useRole(context, { role: roleType });\n\n const { getReferenceProps, getFloatingProps } = useInteractions([\n click,\n hover,\n focus,\n dismiss,\n role\n ]);\n\n const { isMounted, styles: transitionStyles } = useTransitionStyles(context, {\n initial: shiftAwaySubtle,\n ...transition,\n duration\n });\n\n return {\n refs,\n floatingStyles,\n context,\n getReferenceProps,\n getFloatingProps,\n isMounted,\n transitionStyles,\n arrowRef,\n isOpen,\n setOpen,\n placement: resolvedPlacement,\n pointerEvents: interactive ? undefined : 'none'\n };\n}\n\nexport default useFloatingPopover;\n"],"names":["DEFAULT_ARROW_HEIGHT","DEFAULT_MAX_HEIGHT_PADDING","DEFAULT_COLLISION_PADDING","SHIFT_AWAY_SUBTLE_DISTANCE","isAutoPlacement","placement","shiftAwaySubtle","side","transform","top","bottom","left","right","opacity","buildMiddleware","options","middleware","offset","mainAxis","crossAxis","alignment","undefined","push","autoPlacement","padding","collisionPadding","autoAlignment","flip","shift","arrow","element","arrowRef","constrainHeight","size","maxHeightPadding","apply","availableHeight","elements","floating","style","maxHeight","fits","scrollHeight","Math","max","extra","length","useFloatingPopover","open","onOpenChange","trigger","offsetProp","hasArrow","arrowHeight","interactive","role","roleType","disabled","duration","transition","dismiss","dismissProps","hover","hoverProps","click","clickProps","focus","focusProps","nodeId","extraMiddleware","useRef","isControlled","uncontrolledOpen","setUncontrolledOpen","useState","isOpen","useEffect","setOpen","useCallback","next","event","reason","skidding","distance","useMemo","refs","floatingStyles","context","resolvedPlacement","useFloating","whileElementsMounted","autoUpdate","triggers","parseTrigger","triggersEnabled","handleClose","safePolygon","useClick","enabled","useHover","useFocus","visibleOnly","useDismiss","escapeKey","outsidePress","referencePress","useRole","getReferenceProps","getFloatingProps","useInteractions","isMounted","styles","transitionStyles","useTransitionStyles","initial","pointerEvents"],"mappings":";;;;AAqDO,MAAMA,oBAAoB,GAAG;AAEpC,MAAMC,0BAA0B,GAAG,EAAE;AACrC,MAAMC,yBAAyB,GAAG,CAAC;AAGnC,MAAMC,0BAA0B,GAAG,CAAC;AASpC,SAASC,eAAeA,CAACC,SAA2B,EAA8B;EAChF,OAAOA,SAAS,KAAK,MAAM,IAAIA,SAAS,KAAK,YAAY,IAAIA,SAAS,KAAK,UAAU;AAC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,gBAAgB;IAChBE,SAAS;IACTE,gBAAgB;IAChBjF,QAAQ;IACR4C,MAAM;IACNE,OAAO;AACPxE,IAAAA,SAAS,EAAEmF,iBAAiB;AAC5B2B,IAAAA,aAAa,EAAE7D,WAAW,GAAGjC,SAAS,GAAG;GAC1C;AACH;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ntbjs/react-components",
3
- "version": "3.0.0-rc.3",
3
+ "version": "3.0.0-rc.4",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -69,8 +69,6 @@
69
69
  ],
70
70
  "scripts": {
71
71
  "build": "cross-env NODE_ENV=production rollup -c",
72
- "test": "jest --passWithNoTests",
73
- "test:watch": "jest --watch",
74
72
  "typecheck": "tsc -p tsconfig.check.json",
75
73
  "types": "tsc -p tsconfig.json",
76
74
  "types:emit": "node scripts/emit-types.cjs",
@@ -98,7 +96,7 @@
98
96
  "peerDependencies": {
99
97
  "react": ">=16.14.0",
100
98
  "react-dom": ">=16.14.0",
101
- "styled-components": ">=5.1.0"
99
+ "styled-components": ">=6.0.0"
102
100
  },
103
101
  "devDependencies": {
104
102
  "@babel/core": "^7.28.5",
@@ -130,9 +128,6 @@
130
128
  "eslint": "^9.39.5",
131
129
  "eslint-plugin-react": "^7.35.0",
132
130
  "globals": "^17.9.0",
133
- "identity-obj-proxy": "^3.0.0",
134
- "jest": "^27.0.4",
135
- "jsdom": "^16.7.0",
136
131
  "postcss": "^8.3.0",
137
132
  "react": "^19.2.4",
138
133
  "react-dom": "^19.2.4",
@@ -1,5 +1,5 @@
1
1
  import { useInteractions, useTransitionStyles } from '@floating-ui/react';
2
- import type { Middleware, OpenChangeReason, Placement, UseClickProps, UseDismissProps, UseFloatingReturn, UseFocusProps, UseHoverProps, UseTransitionStylesProps } from '@floating-ui/react';
2
+ import type { Middleware, OpenChangeReason, Placement, UseClickProps, UseDismissProps, UseFloatingReturn, UseFocusProps, UseHoverProps, UseRoleProps, UseTransitionStylesProps } from '@floating-ui/react';
3
3
  export declare const DEFAULT_ARROW_HEIGHT = 15;
4
4
  export type PopoverPlacement = Placement | AutoPlacement;
5
5
  export type AutoPlacement = 'auto' | 'auto-start' | 'auto-end';
@@ -60,6 +60,17 @@ export interface UseFloatingPopoverOptions {
60
60
  * @default false
61
61
  */
62
62
  interactive?: boolean;
63
+ /**
64
+ * ARIA role for the floating element, wired through `useRole`. Sets the role and an
65
+ * `id` on the floating element and the matching `aria-*` on the reference while open —
66
+ * `aria-describedby` for `'tooltip'`, `aria-expanded` + `aria-haspopup` for `'dialog'`.
67
+ * tippy set these from its `aria` option; the Floating UI port dropped them, so callers
68
+ * pass the role that restores the announcement. Omit to leave the floating element
69
+ * without a managed role.
70
+ *
71
+ * @default 'tooltip'
72
+ */
73
+ role?: UseRoleProps['role'];
63
74
  /**
64
75
  * tippy's `disabled`: can never open. Forces the resolved open state to `false`
65
76
  * and disables every interaction Hook (rule 2 in the file header).