@neo4j-ndl/react 4.18.11 → 4.18.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/next/tree-view/TreeView.js +1 -1
- package/lib/cjs/next/tree-view/TreeView.js.map +1 -1
- package/lib/cjs/tooltip/Tooltip.js.map +1 -1
- package/lib/cjs/tooltip/stories/tooltip-follow-cursor.story.js +1 -1
- package/lib/cjs/tooltip/stories/tooltip-follow-cursor.story.js.map +1 -1
- package/lib/cjs/tooltip/use-tooltip.js +37 -5
- package/lib/cjs/tooltip/use-tooltip.js.map +1 -1
- package/lib/esm/next/tree-view/TreeView.js +1 -1
- package/lib/esm/next/tree-view/TreeView.js.map +1 -1
- package/lib/esm/tooltip/Tooltip.js.map +1 -1
- package/lib/esm/tooltip/stories/tooltip-follow-cursor.story.js +1 -1
- package/lib/esm/tooltip/stories/tooltip-follow-cursor.story.js.map +1 -1
- package/lib/esm/tooltip/use-tooltip.js +38 -6
- package/lib/esm/tooltip/use-tooltip.js.map +1 -1
- package/lib/types/tooltip/Tooltip.d.ts +6 -2
- package/lib/types/tooltip/Tooltip.d.ts.map +1 -1
- package/lib/types/tooltip/stories/tooltip-follow-cursor.story.d.ts.map +1 -1
- package/lib/types/tooltip/use-tooltip.d.ts +6 -2
- package/lib/types/tooltip/use-tooltip.d.ts.map +1 -1
- package/package.json +2 -2
- package/skills/ndl-react/components/tooltip.md +39 -7
|
@@ -434,7 +434,7 @@ const Item = (_a) => {
|
|
|
434
434
|
},
|
|
435
435
|
tabIndex: -1,
|
|
436
436
|
}, children: (0, jsx_runtime_1.jsx)(EllipsisHorizontalIconOutline_1.EllipsisHorizontalIconOutline, {}) }), (0, jsx_runtime_1.jsx)(menu_1.Menu, Object.assign({ isOpen: isMenuOpen, anchorRef: actionButtonRef, onClose: handleMenuClose }, actionMenuProps, { children: actionMenuItems }))] }))] }) })));
|
|
437
|
-
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(conditional_wrap_1.ConditionalWrap, { shouldWrap: tooltipContent !== undefined && tooltipContent !== null, wrap: (children) => ((0, jsx_runtime_1.jsxs)(tooltip_1.Tooltip, Object.assign({ type: "simple", hoverDelay: { close: 0, open: 500 }, isDisabled: isMenuOpen, followCursor:
|
|
437
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(conditional_wrap_1.ConditionalWrap, { shouldWrap: tooltipContent !== undefined && tooltipContent !== null, wrap: (children) => ((0, jsx_runtime_1.jsxs)(tooltip_1.Tooltip, Object.assign({ type: "simple", hoverDelay: { close: 0, open: 500 }, isDisabled: isMenuOpen, followCursor: "initial" }, tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.root, { children: [(0, jsx_runtime_1.jsx)(tooltip_1.Tooltip.Trigger, Object.assign({ hasButtonWrapper: true }, tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.trigger, { children: children })), (0, jsx_runtime_1.jsx)(tooltip_1.Tooltip.Content, Object.assign({}, tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.content, { children: tooltipContent }))] }))), children: itemElement }), hasChildren && ((0, jsx_runtime_1.jsx)(TreeViewContext.Provider, { value: { focusedId, level: level + 1, selectionMode, setFocusedId }, children: (0, jsx_runtime_1.jsx)("div", { role: "group", id: groupId, hidden: !isExpanded, style: { '--tree-level': level - 1 }, children: annotateTreeItems(children) }) }))] }));
|
|
438
438
|
};
|
|
439
439
|
/**
|
|
440
440
|
* A skeleton placeholder for tree items that are being loaded. Renders one or
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeView.js","sourceRoot":"","sources":["../../../../src/next/tree-view/TreeView.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,8CAAkD;AAClD,4DAAoC;AACpC,iCAUe;AAGf,uFA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KAAK,EAAE,gBAAE,cAAc,EAAE,KAAK,GAAG,CAAC,IAAK,KAAK,CAAyB,IACjE,cAAc,EACd,SAAS,cAEZ,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CACtC,uBAAC,mBAAQ,IAAS,MAAM,EAAC,MAAM,EAAC,KAAK,EAAC,MAAM,IAA7B,CAAC,CAA+B,CAChD,CAAC,IACE,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC,CAAC;AACpD,4BAAQ","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nimport { useMergeRefs } from '@floating-ui/react';\nimport classNames from 'classnames';\nimport {\n Children,\n cloneElement,\n createContext,\n isValidElement,\n useCallback,\n useContext,\n useId,\n useRef,\n useState,\n} from 'react';\n\nimport { type CommonProps, type TooltipObjectProps } from '../../_common/types';\nimport { useSemicontrolledState } from '../../_common/use-semi-controlled-state';\nimport { Checkbox } from '../../checkbox';\nimport { CleanIconButton } from '../../clean-icon-button';\nimport { ConditionalWrap } from '../../conditional-wrap';\nimport { ChevronRightIconOutline } from '../../icons/generated/heroIcons/ChevronRightIconOutline';\nimport { EllipsisHorizontalIconOutline } from '../../icons/generated/heroIcons/EllipsisHorizontalIconOutline';\nimport { Menu } from '../../menu';\nimport { Skeleton } from '../../skeleton';\nimport { Tooltip } from '../../tooltip';\n\ntype SelectionMode = 'single' | 'multiple';\n\ntype TreeViewContextValue = {\n focusedId: string | null;\n level: number;\n selectionMode: SelectionMode;\n setFocusedId: (id: string | null) => void;\n};\n\nconst noop = () => undefined;\n\nconst TREE_EVENTS = {\n action: 'treeitem-action',\n collapse: 'treeitem-collapse',\n expand: 'treeitem-expand',\n select: 'treeitem-select',\n} as const;\n\nconst TreeViewContext = createContext<TreeViewContextValue>({\n focusedId: null,\n level: 1,\n selectionMode: 'single',\n setFocusedId: noop,\n});\n\nfunction getVisibleTreeItems(root: HTMLElement): HTMLElement[] {\n return Array.from(\n root.querySelectorAll<HTMLElement>(\n '[role=\"treeitem\"]:not([role=\"group\"][hidden] [role=\"treeitem\"])',\n ),\n ).filter((el) => {\n let parent = el.parentElement;\n while (parent && parent !== root) {\n if (parent.getAttribute('role') === 'group' && parent.hidden) {\n return false;\n }\n parent = parent.parentElement;\n }\n return true;\n });\n}\n\nfunction annotateTreeItems(children: React.ReactNode): React.ReactNode {\n const items = Children.toArray(children);\n const treeItemCount = items.filter(\n (child): child is React.ReactElement =>\n isValidElement(child) && child.type === Item,\n ).length;\n\n let posInSet = 0;\n return Children.map(children, (child) => {\n if (isValidElement(child) && child.type === Item) {\n posInSet++;\n return cloneElement(\n child as React.ReactElement<React.HTMLAttributes<HTMLElement>>,\n {\n 'aria-posinset': posInSet,\n 'aria-setsize': treeItemCount,\n },\n );\n }\n return child;\n });\n}\n\ntype RootProps = {\n /** The aria-label for the tree. Required for accessibility, unless using ariaLabelledby. Pass null to omit. */\n ariaLabel: string | null;\n /** The aria-labelledby for the tree. Pass a string of space-separated IDs of elements that label the tree. */\n ariaLabelledby?: string;\n /** The children of the tree. Should be TreeView.Item components or TreeView.SkeletonItem components only. */\n children?: React.ReactNode;\n /** Selection mode for the tree. Defaults to \"single\". */\n selectionMode?: SelectionMode;\n};\n\n/**\n * Root container for a tree view. Renders a `role=\"tree\"` element with full\n * keyboard navigation (arrow keys, Home/End, Enter/Space) following the\n * WAI-ARIA TreeView pattern.\n *\n * Direct children should be `TreeView.Item` or `TreeView.SkeletonItem`.\n *\n * @example\n * ```tsx\n * <TreeView ariaLabel=\"Files\">\n * <TreeView.Item title=\"README.md\" onSelectedChange={setSelected} isSelected={selected} />\n * </TreeView>\n * ```\n *\n * @alpha - this component is still in development and may change in the future. It might not have feature parity with the old tree view yet.\n */\nconst Root = ({\n children,\n selectionMode = 'single',\n ariaLabel,\n ariaLabelledby,\n className,\n style,\n htmlAttributes,\n ref,\n ...restProps\n}: CommonProps<'div', RootProps>) => {\n const treeRef = useRef<HTMLDivElement>(null);\n const mergedRef = useMergeRefs([treeRef, ref]);\n const [focusedId, setFocusedId] = useState<string | null>(null);\n\n const handleKeyDown = useCallback(\n (e: React.KeyboardEvent<HTMLDivElement>) => {\n const root = treeRef.current;\n if (!root) {\n return;\n }\n\n const items = getVisibleTreeItems(root);\n if (items.length === 0) {\n return;\n }\n\n const currentIndex = items.findIndex((el) => el.id === focusedId);\n let isHandled = true;\n\n switch (e.key) {\n case 'ArrowDown': {\n const nextIndex =\n currentIndex < items.length - 1 ? currentIndex + 1 : currentIndex;\n const nextItem = items[nextIndex];\n if (nextItem) {\n setFocusedId(nextItem.id);\n nextItem.focus();\n }\n break;\n }\n case 'ArrowUp': {\n const prevIndex = currentIndex > 0 ? currentIndex - 1 : 0;\n const prevItem = items[prevIndex];\n if (prevItem) {\n setFocusedId(prevItem.id);\n prevItem.focus();\n }\n break;\n }\n case 'ArrowRight': {\n const current = currentIndex >= 0 ? items[currentIndex] : null;\n if (!current) {\n break;\n }\n const isExpanded = current.getAttribute('aria-expanded');\n if (isExpanded === 'false') {\n current.dispatchEvent(new CustomEvent(TREE_EVENTS.expand));\n } else if (isExpanded === 'true') {\n const nextIndex = currentIndex + 1;\n if (nextIndex < items.length) {\n const nextItem = items[nextIndex];\n setFocusedId(nextItem.id);\n nextItem.focus();\n }\n }\n break;\n }\n case 'ArrowLeft': {\n const current = currentIndex >= 0 ? items[currentIndex] : null;\n if (!current) {\n break;\n }\n const isExpanded = current.getAttribute('aria-expanded');\n if (isExpanded === 'true') {\n current.dispatchEvent(new CustomEvent(TREE_EVENTS.collapse));\n } else {\n const parentGroup = current.closest('[role=\"group\"]');\n if (parentGroup?.id) {\n const parentItem = root.querySelector<HTMLElement>(\n `[aria-owns=\"${parentGroup.id}\"]`,\n );\n if (parentItem) {\n setFocusedId(parentItem.id);\n parentItem.focus();\n }\n }\n }\n break;\n }\n case 'Home': {\n const first = items[0];\n if (first) {\n setFocusedId(first.id);\n first.focus();\n }\n break;\n }\n case 'End': {\n const last = items[items.length - 1];\n if (last) {\n setFocusedId(last.id);\n last.focus();\n }\n break;\n }\n case 'Enter':\n case ' ': {\n const current = currentIndex >= 0 ? items[currentIndex] : null;\n if (current) {\n current.dispatchEvent(new CustomEvent(TREE_EVENTS.select));\n }\n break;\n }\n case 'F10': {\n if (e.shiftKey) {\n const current = currentIndex >= 0 ? items[currentIndex] : null;\n if (current) {\n current.dispatchEvent(new CustomEvent(TREE_EVENTS.action));\n }\n } else {\n isHandled = false;\n }\n break;\n }\n default:\n isHandled = false;\n }\n\n if (isHandled) {\n e.preventDefault();\n e.stopPropagation();\n }\n },\n [focusedId],\n );\n\n const handleFocus = useCallback(\n (e: React.FocusEvent<HTMLDivElement>) => {\n const root = treeRef.current;\n if (!root) {\n return;\n }\n\n if (e.target === root) {\n const items = getVisibleTreeItems(root);\n const alreadyFocused = focusedId\n ? items.find((el) => el.id === focusedId)\n : null;\n const target = alreadyFocused ?? items[0];\n if (target) {\n setFocusedId(target.id);\n target.focus();\n }\n }\n },\n [focusedId],\n );\n\n const classes = classNames(className, 'ndl-tree-view-new');\n\n return (\n <TreeViewContext.Provider\n value={{ focusedId, level: 1, selectionMode, setFocusedId }}\n >\n <div\n ref={mergedRef}\n role=\"tree\"\n aria-multiselectable={selectionMode === 'multiple' || undefined}\n tabIndex={0}\n className={classes}\n onKeyDown={handleKeyDown}\n onFocus={handleFocus}\n aria-label={ariaLabel ?? undefined}\n aria-labelledby={ariaLabelledby}\n style={style}\n {...htmlAttributes}\n {...restProps}\n >\n {annotateTreeItems(children)}\n </div>\n </TreeViewContext.Provider>\n );\n};\n\ntype ItemProps = {\n /** Nested TreeView.Item or TreeView.SkeletonItem elements rendered as sub-items in a collapsible group. */\n children?: React.ReactNode;\n /** The label content displayed in the item row. */\n title?: React.ReactNode;\n /** Default expansion for uncontrolled items */\n // TODO v5: fix boolean naming convention\n // eslint-disable-next-line @typescript-eslint/naming-convention\n defaultExpanded?: boolean;\n /** Whether the item has children. Decides if the item should render a chevron for expansion. Needed for lazy loading. */\n hasChildren?: boolean;\n /** Whether the item is disabled */\n isDisabled?: boolean;\n /** Whether the item is expanded. Makes the item controlled. */\n isExpanded?: boolean;\n /** Whether the item is in an indeterminate state. Only meaningful in multi-select mode for parent nodes. */\n isIndeterminate?: boolean;\n /** Whether the item is loading. Applies aria-busy=\"true\" to the item. */\n isLoading?: boolean;\n /** Whether the item is selected */\n isSelected?: boolean;\n /** Leading visual for the item. */\n leadingVisual?: React.ReactNode;\n /** Trailing content for the item. Shown after the children but before the action menu. */\n trailingContent?: React.ReactNode;\n /** ReactNode containing Menu.Item elements to render in an action menu. When provided, an action button is rendered. */\n actionMenuItems?: React.ReactNode;\n /** Props forwarded to the Menu sub-components (anchorRef, onClose). */\n actionMenuProps?: React.ComponentProps<typeof Menu>;\n /** Content rendered inside the tooltip. When provided, the item is wrapped in a Tooltip. */\n tooltipContent?: React.ReactNode;\n /** Props forwarded to the Tooltip sub-components (root, trigger, content). */\n tooltipProps?: TooltipObjectProps;\n /** Callback called when the item is expanded/collapsed. */\n onExpandedChange?: (isExpanded: boolean) => void;\n /** Callback called when the item is selected/deselected. */\n onSelectedChange?: (isSelected: boolean) => void;\n};\n\n/**\n * A single item within a `TreeView`. Renders a `role=\"treeitem\"` element that\n * supports selection, expansion, leading/trailing visuals, and an action menu.\n *\n * The `title` prop provides the item's label content. Nesting `TreeView.Item`\n * elements as `children` creates a hierarchical tree structure.\n *\n * Supports both controlled (`isExpanded`) and uncontrolled (`defaultExpanded`)\n * expansion, as well as lazy loading via `hasChildren` + `isLoading`.\n *\n * @example\n * ```tsx\n * <TreeView.Item\n * title=\"src\"\n * leadingVisual={<FolderIcon />}\n * isSelected={selected}\n * onSelectedChange={setSelected}\n * >\n * <TreeView.Item title=\"index.ts\" />\n * </TreeView.Item>\n * ```\n */\nconst Item = ({\n actionMenuItems,\n children,\n defaultExpanded = false,\n hasChildren: hasChildrenProp,\n isDisabled,\n isExpanded: isExpandedProp,\n isIndeterminate,\n isLoading,\n isSelected,\n leadingVisual,\n title,\n tooltipContent,\n tooltipProps,\n trailingContent,\n onExpandedChange,\n onSelectedChange,\n actionMenuProps,\n className,\n style,\n htmlAttributes,\n ref,\n ...restProps\n}: CommonProps<'div', ItemProps>) => {\n const generatedId = useId();\n const itemId = `ndl-treeitem-${generatedId}`;\n const titleId = `ndl-treeitem-title-${generatedId}`;\n const groupId = `ndl-treegroup-${generatedId}`;\n const itemRef = useRef<HTMLDivElement>(null);\n const actionButtonRef = useRef<HTMLButtonElement>(null);\n const didOpenViaKeyboard = useRef(false);\n const [isMenuOpen, setIsMenuOpen] = useState(false);\n const { focusedId, level, selectionMode, setFocusedId } =\n useContext(TreeViewContext);\n\n const isControlledExpansion = isExpandedProp !== undefined;\n const [isExpanded, setIsExpanded] = useSemicontrolledState({\n isControlled: isControlledExpansion,\n onChange: onExpandedChange,\n state: isExpandedProp ?? defaultExpanded,\n });\n\n const hasChildren = hasChildrenProp ?? Children.count(children) > 0;\n const isSelectable = onSelectedChange !== undefined;\n const isMultiple = selectionMode === 'multiple';\n\n const toggleExpanded = useCallback(() => {\n if (isDisabled) {\n return;\n }\n if (hasChildren) {\n setIsExpanded(!isExpanded);\n }\n }, [isDisabled, hasChildren, setIsExpanded, isExpanded]);\n\n const handleSelect = useCallback(() => {\n if (isDisabled) {\n return;\n }\n onSelectedChange?.(!isSelected);\n }, [isDisabled, isSelected, onSelectedChange]);\n\n const handleClick = useCallback(() => {\n if (isDisabled) {\n return;\n }\n setFocusedId(itemId);\n if (isSelectable) {\n handleSelect();\n } else {\n toggleExpanded();\n }\n }, [\n isDisabled,\n setFocusedId,\n itemId,\n isSelectable,\n handleSelect,\n toggleExpanded,\n ]);\n\n const handleChevronClick = useCallback(\n (e: React.MouseEvent) => {\n e.stopPropagation();\n if (isDisabled) {\n return;\n }\n setFocusedId(itemId);\n toggleExpanded();\n },\n [isDisabled, setFocusedId, itemId, toggleExpanded],\n );\n\n const handleMenuClose = useCallback(() => {\n setIsMenuOpen(false);\n if (didOpenViaKeyboard.current) {\n itemRef.current?.focus();\n didOpenViaKeyboard.current = false;\n }\n }, []);\n\n const handleCustomEvents = useCallback(\n (e: Event) => {\n if (e.type === TREE_EVENTS.expand) {\n e.stopPropagation();\n if (hasChildren && !isExpanded && !isDisabled) {\n setIsExpanded(true);\n }\n } else if (e.type === TREE_EVENTS.collapse) {\n e.stopPropagation();\n if (hasChildren && isExpanded && !isDisabled) {\n setIsExpanded(false);\n }\n } else if (e.type === TREE_EVENTS.select) {\n e.stopPropagation();\n if (isSelectable) {\n handleSelect();\n } else {\n toggleExpanded();\n }\n } else if (e.type === TREE_EVENTS.action) {\n e.stopPropagation();\n if (actionMenuItems && !isDisabled) {\n didOpenViaKeyboard.current = true;\n setIsMenuOpen(true);\n }\n }\n },\n [\n actionMenuItems,\n hasChildren,\n isExpanded,\n isDisabled,\n isSelectable,\n setIsExpanded,\n handleSelect,\n toggleExpanded,\n ],\n );\n\n const callbackRef = useCallback(\n (node: HTMLDivElement | null) => {\n const prev = itemRef.current;\n if (prev) {\n prev.removeEventListener(TREE_EVENTS.expand, handleCustomEvents);\n prev.removeEventListener(TREE_EVENTS.collapse, handleCustomEvents);\n prev.removeEventListener(TREE_EVENTS.select, handleCustomEvents);\n prev.removeEventListener(TREE_EVENTS.action, handleCustomEvents);\n }\n (itemRef as React.MutableRefObject<HTMLDivElement | null>).current = node;\n if (node) {\n node.addEventListener(TREE_EVENTS.expand, handleCustomEvents);\n node.addEventListener(TREE_EVENTS.collapse, handleCustomEvents);\n node.addEventListener(TREE_EVENTS.select, handleCustomEvents);\n node.addEventListener(TREE_EVENTS.action, handleCustomEvents);\n }\n },\n [handleCustomEvents],\n );\n\n const mergedRef = useMergeRefs([callbackRef, ref]);\n\n const isFocused = focusedId === itemId;\n\n const selectionAriaProps = (() => {\n if (!isSelectable) {\n return {};\n }\n if (isMultiple) {\n return {\n 'aria-checked': isIndeterminate\n ? ('mixed' as const)\n : (isSelected ?? false),\n };\n }\n return { 'aria-selected': isSelected ?? false };\n })();\n\n const itemElement = (\n // eslint-disable-next-line jsx-a11y/click-events-have-key-events -- keyboard handled on tree root; aria-selected/aria-checked applied via spread\n <div\n ref={mergedRef}\n id={itemId}\n // eslint-disable-next-line jsx-a11y/role-has-required-aria-props -- aria-selected/aria-checked applied conditionally via spread\n role=\"treeitem\"\n {...selectionAriaProps}\n aria-expanded={hasChildren ? isExpanded : undefined}\n aria-owns={hasChildren ? groupId : undefined}\n aria-disabled={isDisabled || undefined}\n aria-busy={isLoading || undefined}\n aria-keyshortcuts={actionMenuItems ? 'Shift+F10' : undefined}\n aria-labelledby={titleId}\n aria-level={level}\n tabIndex={isFocused ? 0 : -1}\n className={classNames('ndl-tree-view-new-item', className, {\n 'ndl-tree-view-new-item--disabled': isDisabled,\n 'ndl-tree-view-new-item--parent': hasChildren,\n 'ndl-tree-view-new-item--selected': isSelected && isSelectable,\n })}\n style={{ '--tree-level': level - 1, ...style } as React.CSSProperties}\n onClick={(e) => {\n e.stopPropagation();\n handleClick();\n }}\n {...htmlAttributes}\n {...restProps}\n >\n <div\n className={classNames('ndl-tree-view-new-item-content', {\n 'ndl-tree-view-new-item-content--parent': hasChildren,\n })}\n >\n {hasChildren && (\n // eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions -- keyboard handled on tree root\n <span\n className=\"ndl-tree-view-new-chevron\"\n aria-disabled={isDisabled}\n onClick={handleChevronClick}\n >\n <ChevronRightIconOutline\n className={classNames('ndl-tree-view-new-chevron-icon', {\n 'ndl-tree-view-new-chevron-icon--open': isExpanded,\n })}\n />\n </span>\n )}\n {leadingVisual && (\n <div className=\"ndl-tree-view-new-item-content-leading-visual\">\n {leadingVisual}\n </div>\n )}\n {isMultiple && isSelectable && (\n <div className=\"ndl-tree-view-new-checkbox\" inert>\n <Checkbox\n style={{ borderWidth: '1.5px' }}\n ariaLabel=\"Select\"\n isChecked={isSelected}\n isIndeterminate={isIndeterminate}\n isDisabled={isDisabled}\n onChange={noop}\n />\n </div>\n )}\n <div id={titleId} className=\"ndl-tree-view-new-item-content-title\">\n {title}\n </div>\n {trailingContent && (\n <div className=\"ndl-tree-view-new-item-content-trailing-content\">\n {trailingContent}\n </div>\n )}\n {actionMenuItems && (\n <div\n className={classNames('ndl-tree-view-new-action', {\n 'ndl-tree-view-new-action--visible': isMenuOpen,\n })}\n >\n <CleanIconButton\n ref={actionButtonRef}\n size=\"small\"\n description={null}\n isDisabled={isDisabled}\n style={{ height: '24px', width: '24px' }}\n htmlAttributes={{\n 'aria-expanded': isMenuOpen || undefined,\n 'aria-haspopup': 'menu',\n 'aria-label': 'Actions',\n onClick: (e: React.MouseEvent) => {\n e.stopPropagation();\n didOpenViaKeyboard.current = false;\n setIsMenuOpen((prev) => !prev);\n },\n tabIndex: -1,\n }}\n >\n <EllipsisHorizontalIconOutline />\n </CleanIconButton>\n <Menu\n isOpen={isMenuOpen}\n anchorRef={actionButtonRef}\n onClose={handleMenuClose}\n {...actionMenuProps}\n >\n {actionMenuItems}\n </Menu>\n </div>\n )}\n </div>\n </div>\n );\n\n return (\n <>\n <ConditionalWrap\n shouldWrap={tooltipContent !== undefined && tooltipContent !== null}\n wrap={(children) => (\n <Tooltip\n type=\"simple\"\n hoverDelay={{ close: 0, open: 500 }}\n isDisabled={isMenuOpen}\n followCursor={true}\n {...tooltipProps?.root}\n >\n <Tooltip.Trigger hasButtonWrapper {...tooltipProps?.trigger}>\n {children}\n </Tooltip.Trigger>\n <Tooltip.Content {...tooltipProps?.content}>\n {tooltipContent}\n </Tooltip.Content>\n </Tooltip>\n )}\n >\n {itemElement}\n </ConditionalWrap>\n {hasChildren && (\n <TreeViewContext.Provider\n value={{ focusedId, level: level + 1, selectionMode, setFocusedId }}\n >\n <div\n role=\"group\"\n id={groupId}\n hidden={!isExpanded}\n style={{ '--tree-level': level - 1 } as React.CSSProperties}\n >\n {annotateTreeItems(children)}\n </div>\n </TreeViewContext.Provider>\n )}\n </>\n );\n};\n\ntype SkeletonItemProps = {\n /** The number of rows to render. */\n rows?: number;\n};\n\n/**\n * A skeleton placeholder for tree items that are being loaded. Renders one or\n * more `Skeleton` rows at the current nesting depth. The element is\n * `aria-hidden` since it is purely a visual indicator and not interactive.\n *\n * Typically used inside a `TreeView.Item` that has `isLoading` set, to give\n * the user a visual hint that child items are being fetched.\n *\n * @example\n * ```tsx\n * <TreeView.Item title=\"Lazy folder\" hasChildren isLoading={isLoading} isExpanded>\n * {isLoading && <TreeView.SkeletonItem rows={3} />}\n * </TreeView.Item>\n * ```\n */\nconst SkeletonItem = ({\n rows = 1,\n className,\n style,\n htmlAttributes,\n ref,\n ...restProps\n}: CommonProps<'div', SkeletonItemProps>) => {\n const { level } = useContext(TreeViewContext);\n return (\n <div\n ref={ref}\n aria-hidden=\"true\"\n className={classNames('ndl-tree-view-new-skeleton', className)}\n style={{ '--tree-level': level - 1, ...style } as React.CSSProperties}\n {...htmlAttributes}\n {...restProps}\n >\n {Array.from({ length: rows }, (_, i) => (\n <Skeleton key={i} height=\"18px\" width=\"100%\" />\n ))}\n </div>\n );\n};\n\nconst TreeView = Object.assign(Root, { Item, SkeletonItem });\nexport { TreeView };\n"]}
|
|
1
|
+
{"version":3,"file":"TreeView.js","sourceRoot":"","sources":["../../../../src/next/tree-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AAC,CAAC;IAC9C,OAAO,CACL,8CACE,GAAG,EAAE,GAAG,iBACI,MAAM,EAClB,SAAS,EAAE,IAAA,oBAAU,EAAC,4BAA4B,EAAE,SAAS,CAAC,EAC9D,KAAK,EAAE,gBAAE,cAAc,EAAE,KAAK,GAAG,CAAC,IAAK,KAAK,CAAyB,IACjE,cAAc,EACd,SAAS,cAEZ,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CACtC,uBAAC,mBAAQ,IAAS,MAAM,EAAC,MAAM,EAAC,KAAK,EAAC,MAAM,IAA7B,CAAC,CAA+B,CAChD,CAAC,IACE,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC,CAAC;AACpD,4BAAQ","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nimport { useMergeRefs } from '@floating-ui/react';\nimport classNames from 'classnames';\nimport {\n Children,\n cloneElement,\n createContext,\n isValidElement,\n useCallback,\n useContext,\n useId,\n useRef,\n useState,\n} from 'react';\n\nimport { type CommonProps, type TooltipObjectProps } from '../../_common/types';\nimport { useSemicontrolledState } from '../../_common/use-semi-controlled-state';\nimport { Checkbox } from '../../checkbox';\nimport { CleanIconButton } from '../../clean-icon-button';\nimport { ConditionalWrap } from '../../conditional-wrap';\nimport { ChevronRightIconOutline } from '../../icons/generated/heroIcons/ChevronRightIconOutline';\nimport { EllipsisHorizontalIconOutline } from '../../icons/generated/heroIcons/EllipsisHorizontalIconOutline';\nimport { Menu } from '../../menu';\nimport { Skeleton } from '../../skeleton';\nimport { Tooltip } from '../../tooltip';\n\ntype SelectionMode = 'single' | 'multiple';\n\ntype TreeViewContextValue = {\n focusedId: string | null;\n level: number;\n selectionMode: SelectionMode;\n setFocusedId: (id: string | null) => void;\n};\n\nconst noop = () => undefined;\n\nconst TREE_EVENTS = {\n action: 'treeitem-action',\n collapse: 'treeitem-collapse',\n expand: 'treeitem-expand',\n select: 'treeitem-select',\n} as const;\n\nconst TreeViewContext = createContext<TreeViewContextValue>({\n focusedId: null,\n level: 1,\n selectionMode: 'single',\n setFocusedId: noop,\n});\n\nfunction getVisibleTreeItems(root: HTMLElement): HTMLElement[] {\n return Array.from(\n root.querySelectorAll<HTMLElement>(\n '[role=\"treeitem\"]:not([role=\"group\"][hidden] [role=\"treeitem\"])',\n ),\n ).filter((el) => {\n let parent = el.parentElement;\n while (parent && parent !== root) {\n if (parent.getAttribute('role') === 'group' && parent.hidden) {\n return false;\n }\n parent = parent.parentElement;\n }\n return true;\n });\n}\n\nfunction annotateTreeItems(children: React.ReactNode): React.ReactNode {\n const items = Children.toArray(children);\n const treeItemCount = items.filter(\n (child): child is React.ReactElement =>\n isValidElement(child) && child.type === Item,\n ).length;\n\n let posInSet = 0;\n return Children.map(children, (child) => {\n if (isValidElement(child) && child.type === Item) {\n posInSet++;\n return cloneElement(\n child as React.ReactElement<React.HTMLAttributes<HTMLElement>>,\n {\n 'aria-posinset': posInSet,\n 'aria-setsize': treeItemCount,\n },\n );\n }\n return child;\n });\n}\n\ntype RootProps = {\n /** The aria-label for the tree. Required for accessibility, unless using ariaLabelledby. Pass null to omit. */\n ariaLabel: string | null;\n /** The aria-labelledby for the tree. Pass a string of space-separated IDs of elements that label the tree. */\n ariaLabelledby?: string;\n /** The children of the tree. Should be TreeView.Item components or TreeView.SkeletonItem components only. */\n children?: React.ReactNode;\n /** Selection mode for the tree. Defaults to \"single\". */\n selectionMode?: SelectionMode;\n};\n\n/**\n * Root container for a tree view. Renders a `role=\"tree\"` element with full\n * keyboard navigation (arrow keys, Home/End, Enter/Space) following the\n * WAI-ARIA TreeView pattern.\n *\n * Direct children should be `TreeView.Item` or `TreeView.SkeletonItem`.\n *\n * @example\n * ```tsx\n * <TreeView ariaLabel=\"Files\">\n * <TreeView.Item title=\"README.md\" onSelectedChange={setSelected} isSelected={selected} />\n * </TreeView>\n * ```\n *\n * @alpha - this component is still in development and may change in the future. It might not have feature parity with the old tree view yet.\n */\nconst Root = ({\n children,\n selectionMode = 'single',\n ariaLabel,\n ariaLabelledby,\n className,\n style,\n htmlAttributes,\n ref,\n ...restProps\n}: CommonProps<'div', RootProps>) => {\n const treeRef = useRef<HTMLDivElement>(null);\n const mergedRef = useMergeRefs([treeRef, ref]);\n const [focusedId, setFocusedId] = useState<string | null>(null);\n\n const handleKeyDown = useCallback(\n (e: React.KeyboardEvent<HTMLDivElement>) => {\n const root = treeRef.current;\n if (!root) {\n return;\n }\n\n const items = getVisibleTreeItems(root);\n if (items.length === 0) {\n return;\n }\n\n const currentIndex = items.findIndex((el) => el.id === focusedId);\n let isHandled = true;\n\n switch (e.key) {\n case 'ArrowDown': {\n const nextIndex =\n currentIndex < items.length - 1 ? currentIndex + 1 : currentIndex;\n const nextItem = items[nextIndex];\n if (nextItem) {\n setFocusedId(nextItem.id);\n nextItem.focus();\n }\n break;\n }\n case 'ArrowUp': {\n const prevIndex = currentIndex > 0 ? currentIndex - 1 : 0;\n const prevItem = items[prevIndex];\n if (prevItem) {\n setFocusedId(prevItem.id);\n prevItem.focus();\n }\n break;\n }\n case 'ArrowRight': {\n const current = currentIndex >= 0 ? items[currentIndex] : null;\n if (!current) {\n break;\n }\n const isExpanded = current.getAttribute('aria-expanded');\n if (isExpanded === 'false') {\n current.dispatchEvent(new CustomEvent(TREE_EVENTS.expand));\n } else if (isExpanded === 'true') {\n const nextIndex = currentIndex + 1;\n if (nextIndex < items.length) {\n const nextItem = items[nextIndex];\n setFocusedId(nextItem.id);\n nextItem.focus();\n }\n }\n break;\n }\n case 'ArrowLeft': {\n const current = currentIndex >= 0 ? items[currentIndex] : null;\n if (!current) {\n break;\n }\n const isExpanded = current.getAttribute('aria-expanded');\n if (isExpanded === 'true') {\n current.dispatchEvent(new CustomEvent(TREE_EVENTS.collapse));\n } else {\n const parentGroup = current.closest('[role=\"group\"]');\n if (parentGroup?.id) {\n const parentItem = root.querySelector<HTMLElement>(\n `[aria-owns=\"${parentGroup.id}\"]`,\n );\n if (parentItem) {\n setFocusedId(parentItem.id);\n parentItem.focus();\n }\n }\n }\n break;\n }\n case 'Home': {\n const first = items[0];\n if (first) {\n setFocusedId(first.id);\n first.focus();\n }\n break;\n }\n case 'End': {\n const last = items[items.length - 1];\n if (last) {\n setFocusedId(last.id);\n last.focus();\n }\n break;\n }\n case 'Enter':\n case ' ': {\n const current = currentIndex >= 0 ? items[currentIndex] : null;\n if (current) {\n current.dispatchEvent(new CustomEvent(TREE_EVENTS.select));\n }\n break;\n }\n case 'F10': {\n if (e.shiftKey) {\n const current = currentIndex >= 0 ? items[currentIndex] : null;\n if (current) {\n current.dispatchEvent(new CustomEvent(TREE_EVENTS.action));\n }\n } else {\n isHandled = false;\n }\n break;\n }\n default:\n isHandled = false;\n }\n\n if (isHandled) {\n e.preventDefault();\n e.stopPropagation();\n }\n },\n [focusedId],\n );\n\n const handleFocus = useCallback(\n (e: React.FocusEvent<HTMLDivElement>) => {\n const root = treeRef.current;\n if (!root) {\n return;\n }\n\n if (e.target === root) {\n const items = getVisibleTreeItems(root);\n const alreadyFocused = focusedId\n ? items.find((el) => el.id === focusedId)\n : null;\n const target = alreadyFocused ?? items[0];\n if (target) {\n setFocusedId(target.id);\n target.focus();\n }\n }\n },\n [focusedId],\n );\n\n const classes = classNames(className, 'ndl-tree-view-new');\n\n return (\n <TreeViewContext.Provider\n value={{ focusedId, level: 1, selectionMode, setFocusedId }}\n >\n <div\n ref={mergedRef}\n role=\"tree\"\n aria-multiselectable={selectionMode === 'multiple' || undefined}\n tabIndex={0}\n className={classes}\n onKeyDown={handleKeyDown}\n onFocus={handleFocus}\n aria-label={ariaLabel ?? undefined}\n aria-labelledby={ariaLabelledby}\n style={style}\n {...htmlAttributes}\n {...restProps}\n >\n {annotateTreeItems(children)}\n </div>\n </TreeViewContext.Provider>\n );\n};\n\ntype ItemProps = {\n /** Nested TreeView.Item or TreeView.SkeletonItem elements rendered as sub-items in a collapsible group. */\n children?: React.ReactNode;\n /** The label content displayed in the item row. */\n title?: React.ReactNode;\n /** Default expansion for uncontrolled items */\n // TODO v5: fix boolean naming convention\n // eslint-disable-next-line @typescript-eslint/naming-convention\n defaultExpanded?: boolean;\n /** Whether the item has children. Decides if the item should render a chevron for expansion. Needed for lazy loading. */\n hasChildren?: boolean;\n /** Whether the item is disabled */\n isDisabled?: boolean;\n /** Whether the item is expanded. Makes the item controlled. */\n isExpanded?: boolean;\n /** Whether the item is in an indeterminate state. Only meaningful in multi-select mode for parent nodes. */\n isIndeterminate?: boolean;\n /** Whether the item is loading. Applies aria-busy=\"true\" to the item. */\n isLoading?: boolean;\n /** Whether the item is selected */\n isSelected?: boolean;\n /** Leading visual for the item. */\n leadingVisual?: React.ReactNode;\n /** Trailing content for the item. Shown after the children but before the action menu. */\n trailingContent?: React.ReactNode;\n /** ReactNode containing Menu.Item elements to render in an action menu. When provided, an action button is rendered. */\n actionMenuItems?: React.ReactNode;\n /** Props forwarded to the Menu sub-components (anchorRef, onClose). */\n actionMenuProps?: React.ComponentProps<typeof Menu>;\n /** Content rendered inside the tooltip. When provided, the item is wrapped in a Tooltip. */\n tooltipContent?: React.ReactNode;\n /** Props forwarded to the Tooltip sub-components (root, trigger, content). */\n tooltipProps?: TooltipObjectProps;\n /** Callback called when the item is expanded/collapsed. */\n onExpandedChange?: (isExpanded: boolean) => void;\n /** Callback called when the item is selected/deselected. */\n onSelectedChange?: (isSelected: boolean) => void;\n};\n\n/**\n * A single item within a `TreeView`. Renders a `role=\"treeitem\"` element that\n * supports selection, expansion, leading/trailing visuals, and an action menu.\n *\n * The `title` prop provides the item's label content. Nesting `TreeView.Item`\n * elements as `children` creates a hierarchical tree structure.\n *\n * Supports both controlled (`isExpanded`) and uncontrolled (`defaultExpanded`)\n * expansion, as well as lazy loading via `hasChildren` + `isLoading`.\n *\n * @example\n * ```tsx\n * <TreeView.Item\n * title=\"src\"\n * leadingVisual={<FolderIcon />}\n * isSelected={selected}\n * onSelectedChange={setSelected}\n * >\n * <TreeView.Item title=\"index.ts\" />\n * </TreeView.Item>\n * ```\n */\nconst Item = ({\n actionMenuItems,\n children,\n defaultExpanded = false,\n hasChildren: hasChildrenProp,\n isDisabled,\n isExpanded: isExpandedProp,\n isIndeterminate,\n isLoading,\n isSelected,\n leadingVisual,\n title,\n tooltipContent,\n tooltipProps,\n trailingContent,\n onExpandedChange,\n onSelectedChange,\n actionMenuProps,\n className,\n style,\n htmlAttributes,\n ref,\n ...restProps\n}: CommonProps<'div', ItemProps>) => {\n const generatedId = useId();\n const itemId = `ndl-treeitem-${generatedId}`;\n const titleId = `ndl-treeitem-title-${generatedId}`;\n const groupId = `ndl-treegroup-${generatedId}`;\n const itemRef = useRef<HTMLDivElement>(null);\n const actionButtonRef = useRef<HTMLButtonElement>(null);\n const didOpenViaKeyboard = useRef(false);\n const [isMenuOpen, setIsMenuOpen] = useState(false);\n const { focusedId, level, selectionMode, setFocusedId } =\n useContext(TreeViewContext);\n\n const isControlledExpansion = isExpandedProp !== undefined;\n const [isExpanded, setIsExpanded] = useSemicontrolledState({\n isControlled: isControlledExpansion,\n onChange: onExpandedChange,\n state: isExpandedProp ?? defaultExpanded,\n });\n\n const hasChildren = hasChildrenProp ?? Children.count(children) > 0;\n const isSelectable = onSelectedChange !== undefined;\n const isMultiple = selectionMode === 'multiple';\n\n const toggleExpanded = useCallback(() => {\n if (isDisabled) {\n return;\n }\n if (hasChildren) {\n setIsExpanded(!isExpanded);\n }\n }, [isDisabled, hasChildren, setIsExpanded, isExpanded]);\n\n const handleSelect = useCallback(() => {\n if (isDisabled) {\n return;\n }\n onSelectedChange?.(!isSelected);\n }, [isDisabled, isSelected, onSelectedChange]);\n\n const handleClick = useCallback(() => {\n if (isDisabled) {\n return;\n }\n setFocusedId(itemId);\n if (isSelectable) {\n handleSelect();\n } else {\n toggleExpanded();\n }\n }, [\n isDisabled,\n setFocusedId,\n itemId,\n isSelectable,\n handleSelect,\n toggleExpanded,\n ]);\n\n const handleChevronClick = useCallback(\n (e: React.MouseEvent) => {\n e.stopPropagation();\n if (isDisabled) {\n return;\n }\n setFocusedId(itemId);\n toggleExpanded();\n },\n [isDisabled, setFocusedId, itemId, toggleExpanded],\n );\n\n const handleMenuClose = useCallback(() => {\n setIsMenuOpen(false);\n if (didOpenViaKeyboard.current) {\n itemRef.current?.focus();\n didOpenViaKeyboard.current = false;\n }\n }, []);\n\n const handleCustomEvents = useCallback(\n (e: Event) => {\n if (e.type === TREE_EVENTS.expand) {\n e.stopPropagation();\n if (hasChildren && !isExpanded && !isDisabled) {\n setIsExpanded(true);\n }\n } else if (e.type === TREE_EVENTS.collapse) {\n e.stopPropagation();\n if (hasChildren && isExpanded && !isDisabled) {\n setIsExpanded(false);\n }\n } else if (e.type === TREE_EVENTS.select) {\n e.stopPropagation();\n if (isSelectable) {\n handleSelect();\n } else {\n toggleExpanded();\n }\n } else if (e.type === TREE_EVENTS.action) {\n e.stopPropagation();\n if (actionMenuItems && !isDisabled) {\n didOpenViaKeyboard.current = true;\n setIsMenuOpen(true);\n }\n }\n },\n [\n actionMenuItems,\n hasChildren,\n isExpanded,\n isDisabled,\n isSelectable,\n setIsExpanded,\n handleSelect,\n toggleExpanded,\n ],\n );\n\n const callbackRef = useCallback(\n (node: HTMLDivElement | null) => {\n const prev = itemRef.current;\n if (prev) {\n prev.removeEventListener(TREE_EVENTS.expand, handleCustomEvents);\n prev.removeEventListener(TREE_EVENTS.collapse, handleCustomEvents);\n prev.removeEventListener(TREE_EVENTS.select, handleCustomEvents);\n prev.removeEventListener(TREE_EVENTS.action, handleCustomEvents);\n }\n (itemRef as React.MutableRefObject<HTMLDivElement | null>).current = node;\n if (node) {\n node.addEventListener(TREE_EVENTS.expand, handleCustomEvents);\n node.addEventListener(TREE_EVENTS.collapse, handleCustomEvents);\n node.addEventListener(TREE_EVENTS.select, handleCustomEvents);\n node.addEventListener(TREE_EVENTS.action, handleCustomEvents);\n }\n },\n [handleCustomEvents],\n );\n\n const mergedRef = useMergeRefs([callbackRef, ref]);\n\n const isFocused = focusedId === itemId;\n\n const selectionAriaProps = (() => {\n if (!isSelectable) {\n return {};\n }\n if (isMultiple) {\n return {\n 'aria-checked': isIndeterminate\n ? ('mixed' as const)\n : (isSelected ?? false),\n };\n }\n return { 'aria-selected': isSelected ?? false };\n })();\n\n const itemElement = (\n // eslint-disable-next-line jsx-a11y/click-events-have-key-events -- keyboard handled on tree root; aria-selected/aria-checked applied via spread\n <div\n ref={mergedRef}\n id={itemId}\n // eslint-disable-next-line jsx-a11y/role-has-required-aria-props -- aria-selected/aria-checked applied conditionally via spread\n role=\"treeitem\"\n {...selectionAriaProps}\n aria-expanded={hasChildren ? isExpanded : undefined}\n aria-owns={hasChildren ? groupId : undefined}\n aria-disabled={isDisabled || undefined}\n aria-busy={isLoading || undefined}\n aria-keyshortcuts={actionMenuItems ? 'Shift+F10' : undefined}\n aria-labelledby={titleId}\n aria-level={level}\n tabIndex={isFocused ? 0 : -1}\n className={classNames('ndl-tree-view-new-item', className, {\n 'ndl-tree-view-new-item--disabled': isDisabled,\n 'ndl-tree-view-new-item--parent': hasChildren,\n 'ndl-tree-view-new-item--selected': isSelected && isSelectable,\n })}\n style={{ '--tree-level': level - 1, ...style } as React.CSSProperties}\n onClick={(e) => {\n e.stopPropagation();\n handleClick();\n }}\n {...htmlAttributes}\n {...restProps}\n >\n <div\n className={classNames('ndl-tree-view-new-item-content', {\n 'ndl-tree-view-new-item-content--parent': hasChildren,\n })}\n >\n {hasChildren && (\n // eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions -- keyboard handled on tree root\n <span\n className=\"ndl-tree-view-new-chevron\"\n aria-disabled={isDisabled}\n onClick={handleChevronClick}\n >\n <ChevronRightIconOutline\n className={classNames('ndl-tree-view-new-chevron-icon', {\n 'ndl-tree-view-new-chevron-icon--open': isExpanded,\n })}\n />\n </span>\n )}\n {leadingVisual && (\n <div className=\"ndl-tree-view-new-item-content-leading-visual\">\n {leadingVisual}\n </div>\n )}\n {isMultiple && isSelectable && (\n <div className=\"ndl-tree-view-new-checkbox\" inert>\n <Checkbox\n style={{ borderWidth: '1.5px' }}\n ariaLabel=\"Select\"\n isChecked={isSelected}\n isIndeterminate={isIndeterminate}\n isDisabled={isDisabled}\n onChange={noop}\n />\n </div>\n )}\n <div id={titleId} className=\"ndl-tree-view-new-item-content-title\">\n {title}\n </div>\n {trailingContent && (\n <div className=\"ndl-tree-view-new-item-content-trailing-content\">\n {trailingContent}\n </div>\n )}\n {actionMenuItems && (\n <div\n className={classNames('ndl-tree-view-new-action', {\n 'ndl-tree-view-new-action--visible': isMenuOpen,\n })}\n >\n <CleanIconButton\n ref={actionButtonRef}\n size=\"small\"\n description={null}\n isDisabled={isDisabled}\n style={{ height: '24px', width: '24px' }}\n htmlAttributes={{\n 'aria-expanded': isMenuOpen || undefined,\n 'aria-haspopup': 'menu',\n 'aria-label': 'Actions',\n onClick: (e: React.MouseEvent) => {\n e.stopPropagation();\n didOpenViaKeyboard.current = false;\n setIsMenuOpen((prev) => !prev);\n },\n tabIndex: -1,\n }}\n >\n <EllipsisHorizontalIconOutline />\n </CleanIconButton>\n <Menu\n isOpen={isMenuOpen}\n anchorRef={actionButtonRef}\n onClose={handleMenuClose}\n {...actionMenuProps}\n >\n {actionMenuItems}\n </Menu>\n </div>\n )}\n </div>\n </div>\n );\n\n return (\n <>\n <ConditionalWrap\n shouldWrap={tooltipContent !== undefined && tooltipContent !== null}\n wrap={(children) => (\n <Tooltip\n type=\"simple\"\n hoverDelay={{ close: 0, open: 500 }}\n isDisabled={isMenuOpen}\n followCursor=\"initial\"\n {...tooltipProps?.root}\n >\n <Tooltip.Trigger hasButtonWrapper {...tooltipProps?.trigger}>\n {children}\n </Tooltip.Trigger>\n <Tooltip.Content {...tooltipProps?.content}>\n {tooltipContent}\n </Tooltip.Content>\n </Tooltip>\n )}\n >\n {itemElement}\n </ConditionalWrap>\n {hasChildren && (\n <TreeViewContext.Provider\n value={{ focusedId, level: level + 1, selectionMode, setFocusedId }}\n >\n <div\n role=\"group\"\n id={groupId}\n hidden={!isExpanded}\n style={{ '--tree-level': level - 1 } as React.CSSProperties}\n >\n {annotateTreeItems(children)}\n </div>\n </TreeViewContext.Provider>\n )}\n </>\n );\n};\n\ntype SkeletonItemProps = {\n /** The number of rows to render. */\n rows?: number;\n};\n\n/**\n * A skeleton placeholder for tree items that are being loaded. Renders one or\n * more `Skeleton` rows at the current nesting depth. The element is\n * `aria-hidden` since it is purely a visual indicator and not interactive.\n *\n * Typically used inside a `TreeView.Item` that has `isLoading` set, to give\n * the user a visual hint that child items are being fetched.\n *\n * @example\n * ```tsx\n * <TreeView.Item title=\"Lazy folder\" hasChildren isLoading={isLoading} isExpanded>\n * {isLoading && <TreeView.SkeletonItem rows={3} />}\n * </TreeView.Item>\n * ```\n */\nconst SkeletonItem = ({\n rows = 1,\n className,\n style,\n htmlAttributes,\n ref,\n ...restProps\n}: CommonProps<'div', SkeletonItemProps>) => {\n const { level } = useContext(TreeViewContext);\n return (\n <div\n ref={ref}\n aria-hidden=\"true\"\n className={classNames('ndl-tree-view-new-skeleton', className)}\n style={{ '--tree-level': level - 1, ...style } as React.CSSProperties}\n {...htmlAttributes}\n {...restProps}\n >\n {Array.from({ length: rows }, (_, i) => (\n <Skeleton key={i} height=\"18px\" width=\"100%\" />\n ))}\n </div>\n );\n};\n\nconst TreeView = Object.assign(Root, { Item, SkeletonItem });\nexport { TreeView };\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tooltip.js","sourceRoot":"","sources":["../../../src/tooltip/Tooltip.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,8CAO4B;AAC5B,4DAAoC;AACpC,+CAAyC;AAGzC,0DAAsD;AACtD,6DAA6D;AAC7D,oCAA0C;AAC1C,8CAAoE;AACpE,+CAA8E;AAuC9E,MAAM,gBAAgB,GAAG,CAAC,EACxB,QAAQ,EACR,UAAU,GAAG,KAAK,EAClB,IAAI,EACJ,aAAa,EACb,SAAS,EACT,MAAM,EACN,YAAY,EACZ,UAAU,EAAE,cAAc,EAC1B,gBAAgB,EAAE,YAAY,EAC9B,UAAU,EACV,2BAA2B,EAC3B,iBAAiB,EACjB,YAAY,GACC,EAAE,EAAE;IACjB,MAAM,cAAc,GAAG,IAAA,kCAAiB,GAAE,CAAC;IAC3C,MAAM,QAAQ,GAAG,cAAc,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,UAAU,CAAC;IACvD,MAAM,UAAU,GAAG,CAAC,cAAc,CAAC;IAEnC,MAAM,OAAO,GAAG,IAAA,wBAAU,EAAC;QACzB,iBAAiB;QACjB,YAAY;QACZ,UAAU;QACV,UAAU;QACV,aAAa;QACb,2HAA2H;QAC3H,MAAM,EAAE,UAAU,KAAK,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM;QAC5C,UAAU,EAAE,cAAc,aAAd,cAAc,cAAd,cAAc,GAAI,UAAU;QACxC,YAAY;QACZ,SAAS;QACT,2BAA2B;QAC3B,QAAQ,EAAE,YAAY,aAAZ,YAAY,cAAZ,YAAY,GAAI,QAAQ;QAClC,IAAI;KACL,CAAC,CAAC;IA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AAW;IACjB,OAAO,EAAE,cAAc;IACvB,MAAM,EAAE,aAAa;IACrB,OAAO,EAAE,cAAc;CACxB,CAAC,CAAC;AAEM,0BAAO","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\nimport {\n type AutoUpdateOptions,\n FloatingFocusManager,\n FloatingPortal,\n type Placement,\n type UseFloatingOptions,\n useMergeRefs,\n} from '@floating-ui/react';\nimport classNames from 'classnames';\nimport React, { useEffect } from 'react';\n\nimport { type CommonProps } from '../_common/types';\nimport { ConditionalWrap } from '../conditional-wrap';\nimport { useIsInsideDialog } from '../dialog/dialog-context';\nimport { useNeedleTheme } from '../theme';\nimport { Typography, type TypographyVariants } from '../typography';\nimport { TooltipContext, useTooltip, useTooltipContext } from './use-tooltip';\n\nexport type TooltipProps = {\n /** Content displayed inside the tooltip. Wraps `Tooltip.Trigger`, `Tooltip.Content`, and optional parts */\n children: React.ReactNode;\n /** Whether the tooltip is disabled */\n isDisabled?: boolean;\n /** Whether the tooltip should be open on first render */\n isInitialOpen?: boolean;\n /** Placement of the tooltip content relative to the trigger */\n placement?: Placement;\n /** Controls the open state . If omitted, the tooltip manages its own state */\n isOpen?: boolean;\n // TODO v5: deprecate this prop\n /**\n * Visual style of the tooltip content. `simple` renders plain text, `rich` renders a composable panel\n * @deprecated rich type will be removed in v5, use simple type instead.\n */\n type: 'simple' | 'rich';\n /** Whether the content is rendered in a portal. */\n isPortaled?: boolean;\n /** Callback fired when the open state changes, if omitted, the tooltip manages its own state using internal hooks */\n onOpenChange?: UseFloatingOptions['onOpenChange'];\n /** Positioning strategy of the tooltip. Defaults to `fixed` when inside a dialog, otherwise `absolute` */\n floatingStrategy?: 'absolute' | 'fixed';\n /** Hover open/close delays in milliseconds */\n hoverDelay?: {\n open: number;\n close: number;\n };\n /** Whether the tooltip should close when the reference element is clicked. Useful when the trigger moves after click. */\n shouldCloseOnReferenceClick?: boolean;\n autoUpdateOptions?: AutoUpdateOptions;\n /** Whether the tooltip should follow the mouse cursor. Only applies to 'simple' tooltips with mouse hover. */\n // TODO v5: rename this prop to follow lint rule\n // eslint-disable-next-line @typescript-eslint/naming-convention\n followCursor?: boolean;\n};\n\nconst TooltipComponent = ({\n children,\n isDisabled = false,\n type,\n isInitialOpen,\n placement,\n isOpen,\n onOpenChange,\n isPortaled: isPortaledProp,\n floatingStrategy: strategyProp,\n hoverDelay,\n shouldCloseOnReferenceClick,\n autoUpdateOptions,\n followCursor,\n}: TooltipProps) => {\n const isInsideDialog = useIsInsideDialog();\n const strategy = isInsideDialog ? 'fixed' : 'absolute';\n const isPortaled = !isInsideDialog;\n\n const tooltip = useTooltip({\n autoUpdateOptions,\n followCursor,\n hoverDelay,\n isDisabled,\n isInitialOpen,\n // if isDisabled is true tooltip will not open otherwise either controlled or uncontrolled depending on if isOpen is passed\n isOpen: isDisabled === true ? false : isOpen,\n isPortaled: isPortaledProp ?? isPortaled,\n onOpenChange,\n placement,\n shouldCloseOnReferenceClick,\n strategy: strategyProp ?? strategy,\n type,\n });\n\n return (\n <TooltipContext.Provider value={tooltip}>\n {children}\n </TooltipContext.Provider>\n );\n};\n\nTooltipComponent.displayName = 'Tooltip';\n\ntype TooltipTriggerProps = {\n /** Content displayed inside the trigger element */\n children: React.ReactNode;\n /** Whether the trigger element can be any element without an extra button wrapper. The child element will be cloned with the necessary trigger props and merged refs */\n hasButtonWrapper?: boolean;\n};\n\nconst TooltipTrigger = ({\n children,\n hasButtonWrapper = false,\n htmlAttributes,\n className,\n style,\n ref,\n ...restProps\n}: CommonProps<'button', TooltipTriggerProps>) => {\n const context = useTooltipContext();\n\n // Example from floating-ui\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n const childrenProps = (children as any).props;\n const mergedRefs = useMergeRefs([\n context.refs.setReference,\n ref,\n childrenProps?.ref,\n ]);\n\n const triggerClasses = classNames(\n {\n 'ndl-closed': !context.isOpen,\n 'ndl-open': context.isOpen,\n },\n 'ndl-tooltip-trigger',\n className,\n );\n\n // `hasButtonWrapper=true` allows the user to pass any element as the anchor\n if (hasButtonWrapper && React.isValidElement(children)) {\n const props: Record<string, unknown> = {\n className: triggerClasses,\n ...htmlAttributes,\n ...childrenProps,\n ref: mergedRefs,\n };\n\n return React.cloneElement(children, context.getReferenceProps(props));\n }\n\n return (\n <button\n type=\"button\"\n className={triggerClasses}\n style={style}\n ref={mergedRefs}\n {...context.getReferenceProps(htmlAttributes)}\n {...restProps}\n >\n {children}\n </button>\n );\n};\n\ntype TooltipContentProps = {\n /** Content displayed inside the tooltip */\n children: React.ReactNode;\n};\n\nconst TooltipContent = ({\n children,\n style,\n htmlAttributes,\n className,\n ref,\n ...restProps\n}: CommonProps<'div', TooltipContentProps>) => {\n const context = useTooltipContext();\n const mergedRef = useMergeRefs([context.refs.setFloating, ref]);\n const { themeClassName } = useNeedleTheme();\n\n const hasHeaderChild = React.useMemo(() => {\n if (context.type !== 'rich') {\n return false;\n }\n const childrenArray = React.Children.toArray(children);\n return childrenArray.some(\n (child) => React.isValidElement(child) && child.type === TooltipHeader,\n );\n }, [children, context.type]);\n\n if (!context.isOpen) {\n return null;\n }\n\n const classes = classNames('ndl-tooltip-content', themeClassName, className, {\n 'ndl-tooltip-content-rich': context.type === 'rich',\n 'ndl-tooltip-content-simple': context.type === 'simple',\n });\n\n if (context.type === 'simple') {\n return (\n <ConditionalWrap\n shouldWrap={context.isPortaled}\n wrap={(wrapChildren) => <FloatingPortal>{wrapChildren}</FloatingPortal>}\n >\n <div\n ref={mergedRef}\n className={classes}\n style={{\n ...context.floatingStyles,\n ...style,\n }}\n {...restProps}\n {...context.getFloatingProps(htmlAttributes)}\n >\n <Typography variant=\"body-medium\">{children}</Typography>\n </div>\n </ConditionalWrap>\n );\n }\n\n const ariaLabelledBy =\n htmlAttributes?.['aria-labelledby'] ??\n (hasHeaderChild ? context.headerId : undefined);\n\n if (htmlAttributes?.['aria-label'] === undefined && !ariaLabelledBy) {\n console.warn(\n 'The rich Tooltip is missing aria-label and Header. Please add one of them for accessibility.',\n );\n }\n\n return (\n <ConditionalWrap\n shouldWrap={context.isPortaled}\n wrap={(wrapChildren) => <FloatingPortal>{wrapChildren}</FloatingPortal>}\n >\n <FloatingFocusManager\n context={context.context}\n returnFocus={true}\n modal={false}\n initialFocus={0}\n closeOnFocusOut\n >\n <div\n ref={mergedRef}\n className={classes}\n style={{\n ...context.floatingStyles,\n ...style,\n }}\n {...restProps}\n {...context.getFloatingProps({\n ...htmlAttributes,\n 'aria-labelledby': ariaLabelledBy,\n })}\n >\n {children}\n </div>\n </FloatingFocusManager>\n </ConditionalWrap>\n );\n};\n\ntype TooltipHeaderProps = {\n /** Content displayed inside the header */\n children: React.ReactNode;\n /** @deprecated Use `typographyVariant` instead */\n passThroughProps?: Partial<React.ComponentPropsWithoutRef<typeof Typography>>;\n typographyVariant?: TypographyVariants;\n};\n\nconst TooltipHeader = ({\n children,\n passThroughProps,\n typographyVariant = 'subheading-medium',\n className,\n style,\n htmlAttributes,\n ref,\n ...restProps\n}: CommonProps<'span', TooltipHeaderProps>) => {\n const context = useTooltipContext();\n\n const classes = classNames('ndl-tooltip-header', className);\n\n useEffect(() => {\n if (Boolean(htmlAttributes?.id) === true) {\n context.setHeaderId?.(htmlAttributes?.id);\n }\n }, [context, htmlAttributes?.id]);\n\n if (!context.isOpen) {\n return null;\n }\n\n return (\n <Typography\n ref={ref}\n variant={typographyVariant}\n className={classes}\n style={style}\n htmlAttributes={{ ...htmlAttributes, id: context.headerId }}\n {...passThroughProps}\n {...restProps}\n >\n {children}\n </Typography>\n );\n};\n\nexport type TooltipBodyProps = {\n /** Content displayed inside the body */\n children: React.ReactNode;\n /** Additional props to pass to the Typography component */\n // TODO v5: Deprecate passThroughProps and use restProps instead\n passThroughProps?: Partial<React.ComponentPropsWithoutRef<typeof Typography>>;\n};\n\nconst TooltipBody = ({\n children,\n className,\n style,\n htmlAttributes,\n passThroughProps,\n ref,\n ...restProps\n}: CommonProps<'span', TooltipBodyProps>) => {\n const context = useTooltipContext();\n\n const classes = classNames('ndl-tooltip-body', className);\n if (!context.isOpen) {\n return null;\n }\n\n return (\n <Typography\n ref={ref}\n variant=\"body-medium\"\n className={classes}\n style={style}\n htmlAttributes={htmlAttributes}\n {...passThroughProps}\n {...restProps}\n >\n {children}\n </Typography>\n );\n};\n\ntype ToolTipActionsProps = {\n /** Content displayed inside the actions container */\n children: React.ReactNode;\n};\n\nconst Actions = ({\n children,\n className,\n style,\n htmlAttributes,\n ref,\n ...restProps\n}: CommonProps<'div', ToolTipActionsProps>) => {\n const context = useTooltipContext();\n const mergedRefs = useMergeRefs([context.refs.setFloating, ref]);\n\n if (!context.isOpen) {\n return null;\n }\n\n const classes = classNames('ndl-tooltip-actions', className);\n\n return (\n <div\n className={classes}\n ref={mergedRefs}\n style={style}\n {...restProps}\n {...htmlAttributes}\n >\n {children}\n </div>\n );\n};\n\nActions.displayName = 'Tooltip.Actions';\n\nconst Tooltip = Object.assign(TooltipComponent, {\n Actions: Actions,\n Body: TooltipBody,\n Content: TooltipContent,\n Header: TooltipHeader,\n Trigger: TooltipTrigger,\n});\n\nexport { Tooltip };\n"]}
|
|
1
|
+
{"version":3,"file":"Tooltip.js","sourceRoot":"","sources":["../../../src/tooltip/Tooltip.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,8CAO4B;AAC5B,4DAAoC;A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S,EAAE,OAAO,EAClB,KAAK,EAAE,KAAK,EACZ,cAAc,EAAE,cAAc,IAC1B,gBAAgB,EAChB,SAAS,cAEZ,QAAQ,IACE,CACd,CAAC;AACJ,CAAC,CAAC;AAOF,MAAM,OAAO,GAAG,CAAC,EAOyB,EAAE,EAAE;QAP7B,EACf,QAAQ,EACR,SAAS,EACT,KAAK,EACL,cAAc,EACd,GAAG,OAEqC,EADrC,SAAS,cANG,2DAOhB,CADa;IAEZ,MAAM,OAAO,GAAG,IAAA,+BAAiB,GAAE,CAAC;IACpC,MAAM,UAAU,GAAG,IAAA,oBAAY,EAAC,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC,CAAC;IAEjE,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;QACpB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,OAAO,GAAG,IAAA,oBAAU,EAAC,qBAAqB,EAAE,SAAS,CAAC,CAAC;IAE7D,OAAO,CACL,8CACE,SAAS,EAAE,OAAO,EAClB,GAAG,EAAE,UAAU,EACf,KAAK,EAAE,KAAK,IACR,SAAS,EACT,cAAc,cAEjB,QAAQ,IACL,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,OAAO,CAAC,WAAW,GAAG,iBAAiB,CAAC;AAExC,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,gBAAgB,EAAE;IAC9C,OAAO,EAAE,OAAO;IAChB,IAAI,EAAE,WAAW;IACjB,OAAO,EAAE,cAAc;IACvB,MAAM,EAAE,aAAa;IACrB,OAAO,EAAE,cAAc;CACxB,CAAC,CAAC;AAEM,0BAAO","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\nimport {\n type AutoUpdateOptions,\n FloatingFocusManager,\n FloatingPortal,\n type Placement,\n type UseFloatingOptions,\n useMergeRefs,\n} from '@floating-ui/react';\nimport classNames from 'classnames';\nimport React, { useEffect } from 'react';\n\nimport { type CommonProps } from '../_common/types';\nimport { ConditionalWrap } from '../conditional-wrap';\nimport { useIsInsideDialog } from '../dialog/dialog-context';\nimport { useNeedleTheme } from '../theme';\nimport { Typography, type TypographyVariants } from '../typography';\nimport { TooltipContext, useTooltip, useTooltipContext } from './use-tooltip';\n\nexport type TooltipProps = {\n /** Content displayed inside the tooltip. Wraps `Tooltip.Trigger`, `Tooltip.Content`, and optional parts */\n children: React.ReactNode;\n /** Whether the tooltip is disabled */\n isDisabled?: boolean;\n /** Whether the tooltip should be open on first render */\n isInitialOpen?: boolean;\n /** Placement of the tooltip content relative to the trigger */\n placement?: Placement;\n /** Controls the open state . If omitted, the tooltip manages its own state */\n isOpen?: boolean;\n // TODO v5: deprecate this prop\n /**\n * Visual style of the tooltip content. `simple` renders plain text, `rich` renders a composable panel\n * @deprecated rich type will be removed in v5, use simple type instead.\n */\n type: 'simple' | 'rich';\n /** Whether the content is rendered in a portal. */\n isPortaled?: boolean;\n /** Callback fired when the open state changes, if omitted, the tooltip manages its own state using internal hooks */\n onOpenChange?: UseFloatingOptions['onOpenChange'];\n /** Positioning strategy of the tooltip. Defaults to `fixed` when inside a dialog, otherwise `absolute` */\n floatingStrategy?: 'absolute' | 'fixed';\n /** Hover open/close delays in milliseconds */\n hoverDelay?: {\n open: number;\n close: number;\n };\n /** Whether the tooltip should close when the reference element is clicked. Useful when the trigger moves after click. */\n shouldCloseOnReferenceClick?: boolean;\n autoUpdateOptions?: AutoUpdateOptions;\n // TODO v5: align followCursor with the Tippy.js convention: `true` should follow\n // the cursor continuously on both axes, with explicit 'horizontal' / 'vertical'\n // values for single-axis following (instead of deriving the axis from `placement`).\n /**\n * Whether the tooltip should be positioned at the mouse cursor. Only applies to 'simple' tooltips with mouse hover.\n * `true` follows the cursor continuously along one axis derived from `placement` (horizontal for top/bottom, vertical for left/right).\n * `'initial'` opens the tooltip at the cursor's position (both axes) and keeps it there, like the native `title` attribute; `placement` controls which side of that point the tooltip appears on.\n */\n followCursor?: boolean | 'initial';\n};\n\nconst TooltipComponent = ({\n children,\n isDisabled = false,\n type,\n isInitialOpen,\n placement,\n isOpen,\n onOpenChange,\n isPortaled: isPortaledProp,\n floatingStrategy: strategyProp,\n hoverDelay,\n shouldCloseOnReferenceClick,\n autoUpdateOptions,\n followCursor,\n}: TooltipProps) => {\n const isInsideDialog = useIsInsideDialog();\n const strategy = isInsideDialog ? 'fixed' : 'absolute';\n const isPortaled = !isInsideDialog;\n\n const tooltip = useTooltip({\n autoUpdateOptions,\n followCursor,\n hoverDelay,\n isDisabled,\n isInitialOpen,\n // if isDisabled is true tooltip will not open otherwise either controlled or uncontrolled depending on if isOpen is passed\n isOpen: isDisabled === true ? false : isOpen,\n isPortaled: isPortaledProp ?? isPortaled,\n onOpenChange,\n placement,\n shouldCloseOnReferenceClick,\n strategy: strategyProp ?? strategy,\n type,\n });\n\n return (\n <TooltipContext.Provider value={tooltip}>\n {children}\n </TooltipContext.Provider>\n );\n};\n\nTooltipComponent.displayName = 'Tooltip';\n\ntype TooltipTriggerProps = {\n /** Content displayed inside the trigger element */\n children: React.ReactNode;\n /** Whether the trigger element can be any element without an extra button wrapper. The child element will be cloned with the necessary trigger props and merged refs */\n hasButtonWrapper?: boolean;\n};\n\nconst TooltipTrigger = ({\n children,\n hasButtonWrapper = false,\n htmlAttributes,\n className,\n style,\n ref,\n ...restProps\n}: CommonProps<'button', TooltipTriggerProps>) => {\n const context = useTooltipContext();\n\n // Example from floating-ui\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n const childrenProps = (children as any).props;\n const mergedRefs = useMergeRefs([\n context.refs.setReference,\n ref,\n childrenProps?.ref,\n ]);\n\n const triggerClasses = classNames(\n {\n 'ndl-closed': !context.isOpen,\n 'ndl-open': context.isOpen,\n },\n 'ndl-tooltip-trigger',\n className,\n );\n\n // `hasButtonWrapper=true` allows the user to pass any element as the anchor\n if (hasButtonWrapper && React.isValidElement(children)) {\n const props: Record<string, unknown> = {\n className: triggerClasses,\n ...htmlAttributes,\n ...childrenProps,\n ref: mergedRefs,\n };\n\n return React.cloneElement(children, context.getReferenceProps(props));\n }\n\n return (\n <button\n type=\"button\"\n className={triggerClasses}\n style={style}\n ref={mergedRefs}\n {...context.getReferenceProps(htmlAttributes)}\n {...restProps}\n >\n {children}\n </button>\n );\n};\n\ntype TooltipContentProps = {\n /** Content displayed inside the tooltip */\n children: React.ReactNode;\n};\n\nconst TooltipContent = ({\n children,\n style,\n htmlAttributes,\n className,\n ref,\n ...restProps\n}: CommonProps<'div', TooltipContentProps>) => {\n const context = useTooltipContext();\n const mergedRef = useMergeRefs([context.refs.setFloating, ref]);\n const { themeClassName } = useNeedleTheme();\n\n const hasHeaderChild = React.useMemo(() => {\n if (context.type !== 'rich') {\n return false;\n }\n const childrenArray = React.Children.toArray(children);\n return childrenArray.some(\n (child) => React.isValidElement(child) && child.type === TooltipHeader,\n );\n }, [children, context.type]);\n\n if (!context.isOpen) {\n return null;\n }\n\n const classes = classNames('ndl-tooltip-content', themeClassName, className, {\n 'ndl-tooltip-content-rich': context.type === 'rich',\n 'ndl-tooltip-content-simple': context.type === 'simple',\n });\n\n if (context.type === 'simple') {\n return (\n <ConditionalWrap\n shouldWrap={context.isPortaled}\n wrap={(wrapChildren) => <FloatingPortal>{wrapChildren}</FloatingPortal>}\n >\n <div\n ref={mergedRef}\n className={classes}\n style={{\n ...context.floatingStyles,\n ...style,\n }}\n {...restProps}\n {...context.getFloatingProps(htmlAttributes)}\n >\n <Typography variant=\"body-medium\">{children}</Typography>\n </div>\n </ConditionalWrap>\n );\n }\n\n const ariaLabelledBy =\n htmlAttributes?.['aria-labelledby'] ??\n (hasHeaderChild ? context.headerId : undefined);\n\n if (htmlAttributes?.['aria-label'] === undefined && !ariaLabelledBy) {\n console.warn(\n 'The rich Tooltip is missing aria-label and Header. Please add one of them for accessibility.',\n );\n }\n\n return (\n <ConditionalWrap\n shouldWrap={context.isPortaled}\n wrap={(wrapChildren) => <FloatingPortal>{wrapChildren}</FloatingPortal>}\n >\n <FloatingFocusManager\n context={context.context}\n returnFocus={true}\n modal={false}\n initialFocus={0}\n closeOnFocusOut\n >\n <div\n ref={mergedRef}\n className={classes}\n style={{\n ...context.floatingStyles,\n ...style,\n }}\n {...restProps}\n {...context.getFloatingProps({\n ...htmlAttributes,\n 'aria-labelledby': ariaLabelledBy,\n })}\n >\n {children}\n </div>\n </FloatingFocusManager>\n </ConditionalWrap>\n );\n};\n\ntype TooltipHeaderProps = {\n /** Content displayed inside the header */\n children: React.ReactNode;\n /** @deprecated Use `typographyVariant` instead */\n passThroughProps?: Partial<React.ComponentPropsWithoutRef<typeof Typography>>;\n typographyVariant?: TypographyVariants;\n};\n\nconst TooltipHeader = ({\n children,\n passThroughProps,\n typographyVariant = 'subheading-medium',\n className,\n style,\n htmlAttributes,\n ref,\n ...restProps\n}: CommonProps<'span', TooltipHeaderProps>) => {\n const context = useTooltipContext();\n\n const classes = classNames('ndl-tooltip-header', className);\n\n useEffect(() => {\n if (Boolean(htmlAttributes?.id) === true) {\n context.setHeaderId?.(htmlAttributes?.id);\n }\n }, [context, htmlAttributes?.id]);\n\n if (!context.isOpen) {\n return null;\n }\n\n return (\n <Typography\n ref={ref}\n variant={typographyVariant}\n className={classes}\n style={style}\n htmlAttributes={{ ...htmlAttributes, id: context.headerId }}\n {...passThroughProps}\n {...restProps}\n >\n {children}\n </Typography>\n );\n};\n\nexport type TooltipBodyProps = {\n /** Content displayed inside the body */\n children: React.ReactNode;\n /** Additional props to pass to the Typography component */\n // TODO v5: Deprecate passThroughProps and use restProps instead\n passThroughProps?: Partial<React.ComponentPropsWithoutRef<typeof Typography>>;\n};\n\nconst TooltipBody = ({\n children,\n className,\n style,\n htmlAttributes,\n passThroughProps,\n ref,\n ...restProps\n}: CommonProps<'span', TooltipBodyProps>) => {\n const context = useTooltipContext();\n\n const classes = classNames('ndl-tooltip-body', className);\n if (!context.isOpen) {\n return null;\n }\n\n return (\n <Typography\n ref={ref}\n variant=\"body-medium\"\n className={classes}\n style={style}\n htmlAttributes={htmlAttributes}\n {...passThroughProps}\n {...restProps}\n >\n {children}\n </Typography>\n );\n};\n\ntype ToolTipActionsProps = {\n /** Content displayed inside the actions container */\n children: React.ReactNode;\n};\n\nconst Actions = ({\n children,\n className,\n style,\n htmlAttributes,\n ref,\n ...restProps\n}: CommonProps<'div', ToolTipActionsProps>) => {\n const context = useTooltipContext();\n const mergedRefs = useMergeRefs([context.refs.setFloating, ref]);\n\n if (!context.isOpen) {\n return null;\n }\n\n const classes = classNames('ndl-tooltip-actions', className);\n\n return (\n <div\n className={classes}\n ref={mergedRefs}\n style={style}\n {...restProps}\n {...htmlAttributes}\n >\n {children}\n </div>\n );\n};\n\nActions.displayName = 'Tooltip.Actions';\n\nconst Tooltip = Object.assign(TooltipComponent, {\n Actions: Actions,\n Body: TooltipBody,\n Content: TooltipContent,\n Header: TooltipHeader,\n Trigger: TooltipTrigger,\n});\n\nexport { Tooltip };\n"]}
|
|
@@ -35,7 +35,7 @@ const triggerStyle = {
|
|
|
35
35
|
width: '300px',
|
|
36
36
|
};
|
|
37
37
|
const Component = () => {
|
|
38
|
-
return ((0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', gap: '24px' }, children: [(0, jsx_runtime_1.jsxs)(react_1.Tooltip, { type: "simple", followCursor: true, placement: "bottom", children: [(0, jsx_runtime_1.jsx)(react_1.Tooltip.Trigger, { children: (0, jsx_runtime_1.jsx)("div", { style: triggerStyle, children: "
|
|
38
|
+
return ((0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', gap: '24px' }, children: [(0, jsx_runtime_1.jsxs)(react_1.Tooltip, { type: "simple", followCursor: true, placement: "bottom", hoverDelay: { close: 0, open: 500 }, children: [(0, jsx_runtime_1.jsx)(react_1.Tooltip.Trigger, { children: (0, jsx_runtime_1.jsx)("div", { style: triggerStyle, children: "followCursor with placement=\"bottom\": follows on the x-axis" }) }), (0, jsx_runtime_1.jsx)(react_1.Tooltip.Content, { children: "Follows cursor along the x-axis" })] }), (0, jsx_runtime_1.jsxs)(react_1.Tooltip, { type: "simple", followCursor: true, placement: "right", hoverDelay: { close: 0, open: 500 }, children: [(0, jsx_runtime_1.jsx)(react_1.Tooltip.Trigger, { children: (0, jsx_runtime_1.jsx)("div", { style: triggerStyle, children: "followCursor with placement=\"right\": follows on the y-axis" }) }), (0, jsx_runtime_1.jsx)(react_1.Tooltip.Content, { children: "Follows cursor along the y-axis" })] }), (0, jsx_runtime_1.jsxs)(react_1.Tooltip, { type: "simple", followCursor: "initial", placement: "bottom", hoverDelay: { close: 0, open: 500 }, children: [(0, jsx_runtime_1.jsx)(react_1.Tooltip.Trigger, { children: (0, jsx_runtime_1.jsx)("div", { style: triggerStyle, children: "followCursor=\"initial\": opens at the cursor point and stays there" }) }), (0, jsx_runtime_1.jsx)(react_1.Tooltip.Content, { children: "Pinned at the cursor position it opened at" })] })] }));
|
|
39
39
|
};
|
|
40
40
|
exports.default = Component;
|
|
41
41
|
//# sourceMappingURL=tooltip-follow-cursor.story.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tooltip-follow-cursor.story.js","sourceRoot":"","sources":["../../../../src/tooltip/stories/tooltip-follow-cursor.story.tsx"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,mDAAiD;AAEjD,4CAA2C;AAE3C,MAAM,YAAY,GAAwB;IACxC,UAAU,EAAE,QAAQ;IACpB,eAAe,EAAE,oCAAoC;IACrD,YAAY,EAAE,KAAK;IACnB,KAAK,EAAE,yCAAyC;IAChD,OAAO,EAAE,MAAM;IACf,MAAM,EAAE,OAAO;IACf,cAAc,EAAE,QAAQ;IACxB,OAAO,EAAE,KAAK;IACd,KAAK,EAAE,OAAO;CACf,CAAC;AAEF,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,OAAO,CACL,iCAAK,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,aAC1C,wBAAC,eAAO,
|
|
1
|
+
{"version":3,"file":"tooltip-follow-cursor.story.js","sourceRoot":"","sources":["../../../../src/tooltip/stories/tooltip-follow-cursor.story.tsx"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,mDAAiD;AAEjD,4CAA2C;AAE3C,MAAM,YAAY,GAAwB;IACxC,UAAU,EAAE,QAAQ;IACpB,eAAe,EAAE,oCAAoC;IACrD,YAAY,EAAE,KAAK;IACnB,KAAK,EAAE,yCAAyC;IAChD,OAAO,EAAE,MAAM;IACf,MAAM,EAAE,OAAO;IACf,cAAc,EAAE,QAAQ;IACxB,OAAO,EAAE,KAAK;IACd,KAAK,EAAE,OAAO;CACf,CAAC;AAEF,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,OAAO,CACL,iCAAK,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,aAC1C,wBAAC,eAAO,IACN,IAAI,EAAC,QAAQ,EACb,YAAY,QACZ,SAAS,EAAC,QAAQ,EAClB,UAAU,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,aAEnC,uBAAC,eAAO,CAAC,OAAO,cACd,gCAAK,KAAK,EAAE,YAAY,8EAGlB,GACU,EAClB,uBAAC,eAAO,CAAC,OAAO,kDAAkD,IAC1D,EAEV,wBAAC,eAAO,IACN,IAAI,EAAC,QAAQ,EACb,YAAY,QACZ,SAAS,EAAC,OAAO,EACjB,UAAU,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,aAEnC,uBAAC,eAAO,CAAC,OAAO,cACd,gCAAK,KAAK,EAAE,YAAY,6EAElB,GACU,EAClB,uBAAC,eAAO,CAAC,OAAO,kDAAkD,IAC1D,EAEV,wBAAC,eAAO,IACN,IAAI,EAAC,QAAQ,EACb,YAAY,EAAC,SAAS,EACtB,SAAS,EAAC,QAAQ,EAClB,UAAU,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,aAEnC,uBAAC,eAAO,CAAC,OAAO,cACd,gCAAK,KAAK,EAAE,YAAY,oFAGlB,GACU,EAClB,uBAAC,eAAO,CAAC,OAAO,6DAEE,IACV,IACN,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,SAAS,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nimport '@neo4j-ndl/base/lib/neo4j-ds-styles.css';\n\nimport { Tooltip } from '@neo4j-ndl/react';\n\nconst triggerStyle: React.CSSProperties = {\n alignItems: 'center',\n backgroundColor: 'var(--theme-color-primary-bg-weak)',\n borderRadius: '4px',\n color: 'var(--theme-color-primary-text-inverse)',\n display: 'flex',\n height: '300px',\n justifyContent: 'center',\n padding: '8px',\n width: '300px',\n};\n\nconst Component = () => {\n return (\n <div style={{ display: 'flex', gap: '24px' }}>\n <Tooltip\n type=\"simple\"\n followCursor\n placement=\"bottom\"\n hoverDelay={{ close: 0, open: 500 }}\n >\n <Tooltip.Trigger>\n <div style={triggerStyle}>\n followCursor with placement="bottom": follows on the\n x-axis\n </div>\n </Tooltip.Trigger>\n <Tooltip.Content>Follows cursor along the x-axis</Tooltip.Content>\n </Tooltip>\n\n <Tooltip\n type=\"simple\"\n followCursor\n placement=\"right\"\n hoverDelay={{ close: 0, open: 500 }}\n >\n <Tooltip.Trigger>\n <div style={triggerStyle}>\n followCursor with placement="right": follows on the y-axis\n </div>\n </Tooltip.Trigger>\n <Tooltip.Content>Follows cursor along the y-axis</Tooltip.Content>\n </Tooltip>\n\n <Tooltip\n type=\"simple\"\n followCursor=\"initial\"\n placement=\"bottom\"\n hoverDelay={{ close: 0, open: 500 }}\n >\n <Tooltip.Trigger>\n <div style={triggerStyle}>\n followCursor="initial": opens at the cursor point and\n stays there\n </div>\n </Tooltip.Trigger>\n <Tooltip.Content>\n Pinned at the cursor position it opened at\n </Tooltip.Content>\n </Tooltip>\n </div>\n );\n};\n\nexport default Component;\n"]}
|
|
@@ -25,11 +25,16 @@ exports.useTooltip = useTooltip;
|
|
|
25
25
|
const react_1 = require("@floating-ui/react");
|
|
26
26
|
const react_2 = require("react");
|
|
27
27
|
function useTooltip({ isInitialOpen = false, placement = 'top', isOpen: controlledOpen, onOpenChange: setControlledOpen, type = 'simple', isPortaled = true, strategy = 'absolute', hoverDelay = undefined, shouldCloseOnReferenceClick = false, autoUpdateOptions, isDisabled = false, followCursor = false, } = {}) {
|
|
28
|
+
var _a, _b;
|
|
28
29
|
const id = (0, react_2.useId)();
|
|
29
30
|
const [headerId, setHeaderId] = (0, react_2.useState)(id);
|
|
30
31
|
const [isUncontrolledOpen, setIsUncontrolledOpen] = (0, react_2.useState)(isInitialOpen);
|
|
31
32
|
const isOpen = controlledOpen !== null && controlledOpen !== void 0 ? controlledOpen : isUncontrolledOpen;
|
|
32
33
|
const setOpen = setControlledOpen !== null && setControlledOpen !== void 0 ? setControlledOpen : setIsUncontrolledOpen;
|
|
34
|
+
// For followCursor='initial': the latest pointer position over the trigger,
|
|
35
|
+
// and a snapshot of it frozen at the moment the tooltip opens.
|
|
36
|
+
const pointerPositionRef = (0, react_2.useRef)(null);
|
|
37
|
+
const [initialCursorPoint, setInitialCursorPoint] = (0, react_2.useState)(null);
|
|
33
38
|
const data = (0, react_1.useFloating)({
|
|
34
39
|
middleware: [
|
|
35
40
|
(0, react_1.offset)(5),
|
|
@@ -40,7 +45,15 @@ function useTooltip({ isInitialOpen = false, placement = 'top', isOpen: controll
|
|
|
40
45
|
}),
|
|
41
46
|
(0, react_1.shift)({ padding: 5 }),
|
|
42
47
|
],
|
|
43
|
-
onOpenChange
|
|
48
|
+
onOpenChange(open, event, reason) {
|
|
49
|
+
if (followCursor === 'initial') {
|
|
50
|
+
// Only anchor to the cursor for pointer-driven opens; keyboard focus
|
|
51
|
+
// opens fall back to positioning relative to the trigger element.
|
|
52
|
+
const isPointerDrivenOpen = event !== undefined && 'clientX' in event;
|
|
53
|
+
setInitialCursorPoint(open && isPointerDrivenOpen ? pointerPositionRef.current : null);
|
|
54
|
+
}
|
|
55
|
+
setOpen(open, event, reason);
|
|
56
|
+
},
|
|
44
57
|
open: isOpen,
|
|
45
58
|
placement,
|
|
46
59
|
strategy,
|
|
@@ -72,10 +85,28 @@ function useTooltip({ isInitialOpen = false, placement = 'top', isOpen: controll
|
|
|
72
85
|
role: type === 'simple' ? 'tooltip' : 'dialog',
|
|
73
86
|
});
|
|
74
87
|
const followAxis = placement.startsWith('left') || placement.startsWith('right') ? 'y' : 'x';
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
88
|
+
const isInitialFollowCursor = followCursor === 'initial';
|
|
89
|
+
const clientPoint = (0, react_1.useClientPoint)(context, Object.assign({
|
|
90
|
+
// 'initial' anchors to the exact cursor point (both axes); `true` follows
|
|
91
|
+
// continuously along the axis derived from `placement`.
|
|
92
|
+
axis: isInitialFollowCursor ? 'both' : followAxis, enabled: followCursor !== false && type === 'simple' && !isDisabled }, (isInitialFollowCursor && {
|
|
93
|
+
x: (_a = initialCursorPoint === null || initialCursorPoint === void 0 ? void 0 : initialCursorPoint.x) !== null && _a !== void 0 ? _a : null,
|
|
94
|
+
y: (_b = initialCursorPoint === null || initialCursorPoint === void 0 ? void 0 : initialCursorPoint.y) !== null && _b !== void 0 ? _b : null,
|
|
95
|
+
})));
|
|
96
|
+
const initialCursorTracking = (0, react_2.useMemo)(() => {
|
|
97
|
+
if (!isInitialFollowCursor) {
|
|
98
|
+
return {};
|
|
99
|
+
}
|
|
100
|
+
const capturePointerPosition = (event) => {
|
|
101
|
+
pointerPositionRef.current = { x: event.clientX, y: event.clientY };
|
|
102
|
+
};
|
|
103
|
+
return {
|
|
104
|
+
reference: {
|
|
105
|
+
onPointerEnter: capturePointerPosition,
|
|
106
|
+
onPointerMove: capturePointerPosition,
|
|
107
|
+
},
|
|
108
|
+
};
|
|
109
|
+
}, [isInitialFollowCursor]);
|
|
79
110
|
const interactions = (0, react_1.useInteractions)([
|
|
80
111
|
hover,
|
|
81
112
|
focus,
|
|
@@ -83,6 +114,7 @@ function useTooltip({ isInitialOpen = false, placement = 'top', isOpen: controll
|
|
|
83
114
|
role,
|
|
84
115
|
click,
|
|
85
116
|
clientPoint,
|
|
117
|
+
initialCursorTracking,
|
|
86
118
|
]);
|
|
87
119
|
return (0, react_2.useMemo)(() => (Object.assign(Object.assign({ headerId: type === 'rich' ? headerId : undefined, isOpen,
|
|
88
120
|
isPortaled, setHeaderId: type === 'rich' ? setHeaderId : undefined, setOpen,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-tooltip.js","sourceRoot":"","sources":["../../../src/tooltip/use-tooltip.ts"],"names":[],"mappings":";;;AAgEA,gCAsGC;AAtKD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,8CAoB4B;AAC5B,iCAA4E;AAuB5E,SAAgB,UAAU,CAAC,EACzB,a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,uBAAe,EAAC;QACnC,KAAK;QACL,KAAK;QACL,OAAO;QACP,IAAI;QACJ,KAAK;QACL,WAAW;KACZ,CAAC,CAAC;IAEH,OAAO,IAAA,eAAO,EACZ,GAAG,EAAE,CAAC,+BACJ,QAAQ,EAAE,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,EAChD,MAAM;QACN,UAAU,EACV,WAAW,EAAE,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,EACtD,OAAO;QACP,IAAI,IACD,YAAY,GACZ,IAAI,EACP,EACF,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,CAAC,CAClE,CAAC;AACJ,CAAC;AAIY,QAAA,cAAc,GAAG,IAAA,qBAAa,EAAc,IAAI,CAAC,CAAC;AAExD,MAAM,iBAAiB,GAAG,GAAkC,EAAE;IACnE,MAAM,OAAO,GAAG,IAAA,kBAAU,EAAC,sBAAc,CAAC,CAAC;IAE3C,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;QACrB,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;IACvE,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AARW,QAAA,iBAAiB,qBAQ5B","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\nimport {\n autoUpdate,\n type AutoUpdateOptions,\n flip,\n offset,\n type Placement,\n type ReferenceType,\n safePolygon,\n shift,\n useClick,\n useClientPoint,\n useDismiss,\n useFloating,\n type UseFloatingOptions,\n type UseFloatingReturn,\n useFocus,\n useHover,\n useInteractions,\n type UseInteractionsReturn,\n useRole,\n} from '@floating-ui/react';\nimport { createContext, useContext, useId, useMemo, useState } from 'react';\n\nexport interface TooltipOptions {\n isInitialOpen?: boolean;\n placement?: Placement;\n isOpen?: boolean;\n onOpenChange?: UseFloatingOptions['onOpenChange'];\n type?: 'simple' | 'rich';\n isPortaled?: boolean;\n strategy?: 'fixed' | 'absolute';\n hoverDelay?: {\n open: number;\n close: number;\n };\n shouldCloseOnReferenceClick?: boolean;\n autoUpdateOptions?: AutoUpdateOptions;\n isDisabled?: boolean;\n // TODO v5: rename this prop to follow lint rule\n /** Whether the tooltip should follow the mouse cursor. Only applies to 'simple' tooltips with mouse hover. */\n // eslint-disable-next-line @typescript-eslint/naming-convention\n followCursor?: boolean;\n}\n\nexport function useTooltip({\n isInitialOpen = false,\n placement = 'top',\n isOpen: controlledOpen,\n onOpenChange: setControlledOpen,\n type = 'simple',\n isPortaled = true,\n strategy = 'absolute',\n hoverDelay = undefined,\n shouldCloseOnReferenceClick = false,\n autoUpdateOptions,\n isDisabled = false,\n followCursor = false,\n}: TooltipOptions = {}): {\n headerId?: string;\n setHeaderId?: (id: string | undefined) => void;\n isOpen: boolean;\n setOpen: (open: boolean) => void;\n type: 'simple' | 'rich';\n isPortaled: boolean;\n} & UseInteractionsReturn &\n UseFloatingReturn<ReferenceType> {\n const id = useId();\n const [headerId, setHeaderId] = useState<string | undefined>(id);\n const [isUncontrolledOpen, setIsUncontrolledOpen] = useState(isInitialOpen);\n const isOpen = controlledOpen ?? isUncontrolledOpen;\n const setOpen = setControlledOpen ?? setIsUncontrolledOpen;\n\n const data = useFloating({\n middleware: [\n offset(5),\n flip({\n crossAxis: placement.includes('-'),\n fallbackAxisSideDirection: 'start',\n padding: 5,\n }),\n shift({ padding: 5 }),\n ],\n onOpenChange: setOpen,\n open: isOpen,\n placement,\n strategy,\n whileElementsMounted(referenceEl, floatingEl, update) {\n const cleanup = autoUpdate(referenceEl, floatingEl, update, {\n ...autoUpdateOptions,\n });\n return cleanup;\n },\n });\n\n const context = data.context;\n\n const hover = useHover(context, {\n delay: hoverDelay,\n enabled: type === 'simple' && !isDisabled,\n handleClose: safePolygon(),\n move: false,\n });\n const click = useClick(context, {\n enabled: type === 'rich' && !isDisabled,\n });\n const focus = useFocus(context, {\n enabled: type === 'simple' && !isDisabled,\n visibleOnly: true,\n });\n const dismiss = useDismiss(context, {\n escapeKey: true,\n outsidePress: true,\n referencePress: shouldCloseOnReferenceClick,\n });\n const role = useRole(context, {\n role: type === 'simple' ? 'tooltip' : 'dialog',\n });\n const followAxis =\n placement.startsWith('left') || placement.startsWith('right') ? 'y' : 'x';\n const clientPoint = useClientPoint(context, {\n axis: followAxis,\n enabled: followCursor && type === 'simple' && !isDisabled,\n });\n\n const interactions = useInteractions([\n hover,\n focus,\n dismiss,\n role,\n click,\n clientPoint,\n ]);\n\n return useMemo(\n () => ({\n headerId: type === 'rich' ? headerId : undefined,\n isOpen,\n isPortaled,\n setHeaderId: type === 'rich' ? setHeaderId : undefined,\n setOpen,\n type,\n ...interactions,\n ...data,\n }),\n [headerId, isOpen, isPortaled, setOpen, type, interactions, data],\n );\n}\n\ntype ContextType = ReturnType<typeof useTooltip> | null;\n\nexport const TooltipContext = createContext<ContextType>(null);\n\nexport const useTooltipContext = (): ReturnType<typeof useTooltip> => {\n const context = useContext(TooltipContext);\n\n if (context === null) {\n throw new Error('Tooltip components must be wrapped in <Tooltip />');\n }\n\n return context;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"use-tooltip.js","sourceRoot":"","sources":["../../../src/tooltip/use-tooltip.ts"],"names":[],"mappings":";;;AA8EA,gCAkJC;AAhOD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,8CAqB4B;AA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QACtE,CAAC,CAAC;QACF,OAAO;YACL,SAAS,EAAE;gBACT,cAAc,EAAE,sBAAsB;gBACtC,aAAa,EAAE,sBAAsB;aACtC;SACF,CAAC;IACJ,CAAC,EAAE,CAAC,qBAAqB,CAAC,CAAC,CAAC;IAE5B,MAAM,YAAY,GAAG,IAAA,uBAAe,EAAC;QACnC,KAAK;QACL,KAAK;QACL,OAAO;QACP,IAAI;QACJ,KAAK;QACL,WAAW;QACX,qBAAqB;KACtB,CAAC,CAAC;IAEH,OAAO,IAAA,eAAO,EACZ,GAAG,EAAE,CAAC,+BACJ,QAAQ,EAAE,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,EAChD,MAAM;QACN,UAAU,EACV,WAAW,EAAE,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,EACtD,OAAO;QACP,IAAI,IACD,YAAY,GACZ,IAAI,EACP,EACF,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,CAAC,CAClE,CAAC;AACJ,CAAC;AAIY,QAAA,cAAc,GAAG,IAAA,qBAAa,EAAc,IAAI,CAAC,CAAC;AAExD,MAAM,iBAAiB,GAAG,GAAkC,EAAE;IACnE,MAAM,OAAO,GAAG,IAAA,kBAAU,EAAC,sBAAc,CAAC,CAAC;IAE3C,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;QACrB,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;IACvE,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AARW,QAAA,iBAAiB,qBAQ5B","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\nimport {\n autoUpdate,\n type AutoUpdateOptions,\n type ElementProps,\n flip,\n offset,\n type Placement,\n type ReferenceType,\n safePolygon,\n shift,\n useClick,\n useClientPoint,\n useDismiss,\n useFloating,\n type UseFloatingOptions,\n type UseFloatingReturn,\n useFocus,\n useHover,\n useInteractions,\n type UseInteractionsReturn,\n useRole,\n} from '@floating-ui/react';\nimport {\n createContext,\n type PointerEvent as ReactPointerEvent,\n useContext,\n useId,\n useMemo,\n useRef,\n useState,\n} from 'react';\n\nexport interface TooltipOptions {\n isInitialOpen?: boolean;\n placement?: Placement;\n isOpen?: boolean;\n onOpenChange?: UseFloatingOptions['onOpenChange'];\n type?: 'simple' | 'rich';\n isPortaled?: boolean;\n strategy?: 'fixed' | 'absolute';\n hoverDelay?: {\n open: number;\n close: number;\n };\n shouldCloseOnReferenceClick?: boolean;\n autoUpdateOptions?: AutoUpdateOptions;\n isDisabled?: boolean;\n // TODO v5: align followCursor with the Tippy.js convention: `true` should follow\n // the cursor continuously on both axes, with explicit 'horizontal' / 'vertical'\n // values for single-axis following (instead of deriving the axis from `placement`).\n /**\n * Whether the tooltip should be positioned at the mouse cursor. Only applies to 'simple' tooltips with mouse hover.\n * `true` follows the cursor continuously along one axis derived from `placement` (horizontal for top/bottom, vertical for left/right).\n * `'initial'` opens the tooltip at the cursor's position (both axes) and keeps it there, like the native `title` attribute; `placement` controls which side of that point the tooltip appears on.\n */\n followCursor?: boolean | 'initial';\n}\n\nexport function useTooltip({\n isInitialOpen = false,\n placement = 'top',\n isOpen: controlledOpen,\n onOpenChange: setControlledOpen,\n type = 'simple',\n isPortaled = true,\n strategy = 'absolute',\n hoverDelay = undefined,\n shouldCloseOnReferenceClick = false,\n autoUpdateOptions,\n isDisabled = false,\n followCursor = false,\n}: TooltipOptions = {}): {\n headerId?: string;\n setHeaderId?: (id: string | undefined) => void;\n isOpen: boolean;\n setOpen: (open: boolean) => void;\n type: 'simple' | 'rich';\n isPortaled: boolean;\n} & UseInteractionsReturn &\n UseFloatingReturn<ReferenceType> {\n const id = useId();\n const [headerId, setHeaderId] = useState<string | undefined>(id);\n const [isUncontrolledOpen, setIsUncontrolledOpen] = useState(isInitialOpen);\n const isOpen = controlledOpen ?? isUncontrolledOpen;\n const setOpen: NonNullable<UseFloatingOptions['onOpenChange']> =\n setControlledOpen ?? setIsUncontrolledOpen;\n\n // For followCursor='initial': the latest pointer position over the trigger,\n // and a snapshot of it frozen at the moment the tooltip opens.\n const pointerPositionRef = useRef<{ x: number; y: number } | null>(null);\n const [initialCursorPoint, setInitialCursorPoint] = useState<{\n x: number;\n y: number;\n } | null>(null);\n\n const data = useFloating({\n middleware: [\n offset(5),\n flip({\n crossAxis: placement.includes('-'),\n fallbackAxisSideDirection: 'start',\n padding: 5,\n }),\n shift({ padding: 5 }),\n ],\n onOpenChange(open, event, reason) {\n if (followCursor === 'initial') {\n // Only anchor to the cursor for pointer-driven opens; keyboard focus\n // opens fall back to positioning relative to the trigger element.\n const isPointerDrivenOpen = event !== undefined && 'clientX' in event;\n setInitialCursorPoint(\n open && isPointerDrivenOpen ? pointerPositionRef.current : null,\n );\n }\n setOpen(open, event, reason);\n },\n open: isOpen,\n placement,\n strategy,\n whileElementsMounted(referenceEl, floatingEl, update) {\n const cleanup = autoUpdate(referenceEl, floatingEl, update, {\n ...autoUpdateOptions,\n });\n return cleanup;\n },\n });\n\n const context = data.context;\n\n const hover = useHover(context, {\n delay: hoverDelay,\n enabled: type === 'simple' && !isDisabled,\n handleClose: safePolygon(),\n move: false,\n });\n const click = useClick(context, {\n enabled: type === 'rich' && !isDisabled,\n });\n const focus = useFocus(context, {\n enabled: type === 'simple' && !isDisabled,\n visibleOnly: true,\n });\n const dismiss = useDismiss(context, {\n escapeKey: true,\n outsidePress: true,\n referencePress: shouldCloseOnReferenceClick,\n });\n const role = useRole(context, {\n role: type === 'simple' ? 'tooltip' : 'dialog',\n });\n const followAxis =\n placement.startsWith('left') || placement.startsWith('right') ? 'y' : 'x';\n const isInitialFollowCursor = followCursor === 'initial';\n const clientPoint = useClientPoint(context, {\n // 'initial' anchors to the exact cursor point (both axes); `true` follows\n // continuously along the axis derived from `placement`.\n axis: isInitialFollowCursor ? 'both' : followAxis,\n enabled: followCursor !== false && type === 'simple' && !isDisabled,\n // Explicit coordinates lock the position: useClientPoint stops tracking\n // pointer movement when they are provided.\n ...(isInitialFollowCursor && {\n x: initialCursorPoint?.x ?? null,\n y: initialCursorPoint?.y ?? null,\n }),\n });\n\n const initialCursorTracking = useMemo<ElementProps>(() => {\n if (!isInitialFollowCursor) {\n return {};\n }\n const capturePointerPosition = (event: ReactPointerEvent) => {\n pointerPositionRef.current = { x: event.clientX, y: event.clientY };\n };\n return {\n reference: {\n onPointerEnter: capturePointerPosition,\n onPointerMove: capturePointerPosition,\n },\n };\n }, [isInitialFollowCursor]);\n\n const interactions = useInteractions([\n hover,\n focus,\n dismiss,\n role,\n click,\n clientPoint,\n initialCursorTracking,\n ]);\n\n return useMemo(\n () => ({\n headerId: type === 'rich' ? headerId : undefined,\n isOpen,\n isPortaled,\n setHeaderId: type === 'rich' ? setHeaderId : undefined,\n setOpen,\n type,\n ...interactions,\n ...data,\n }),\n [headerId, isOpen, isPortaled, setOpen, type, interactions, data],\n );\n}\n\ntype ContextType = ReturnType<typeof useTooltip> | null;\n\nexport const TooltipContext = createContext<ContextType>(null);\n\nexport const useTooltipContext = (): ReturnType<typeof useTooltip> => {\n const context = useContext(TooltipContext);\n\n if (context === null) {\n throw new Error('Tooltip components must be wrapped in <Tooltip />');\n }\n\n return context;\n};\n"]}
|
|
@@ -428,7 +428,7 @@ const Item = (_a) => {
|
|
|
428
428
|
},
|
|
429
429
|
tabIndex: -1,
|
|
430
430
|
}, children: _jsx(EllipsisHorizontalIconOutline, {}) }), _jsx(Menu, Object.assign({ isOpen: isMenuOpen, anchorRef: actionButtonRef, onClose: handleMenuClose }, actionMenuProps, { children: actionMenuItems }))] }))] }) })));
|
|
431
|
-
return (_jsxs(_Fragment, { children: [_jsx(ConditionalWrap, { shouldWrap: tooltipContent !== undefined && tooltipContent !== null, wrap: (children) => (_jsxs(Tooltip, Object.assign({ type: "simple", hoverDelay: { close: 0, open: 500 }, isDisabled: isMenuOpen, followCursor:
|
|
431
|
+
return (_jsxs(_Fragment, { children: [_jsx(ConditionalWrap, { shouldWrap: tooltipContent !== undefined && tooltipContent !== null, wrap: (children) => (_jsxs(Tooltip, Object.assign({ type: "simple", hoverDelay: { close: 0, open: 500 }, isDisabled: isMenuOpen, followCursor: "initial" }, tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.root, { children: [_jsx(Tooltip.Trigger, Object.assign({ hasButtonWrapper: true }, tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.trigger, { children: children })), _jsx(Tooltip.Content, Object.assign({}, tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.content, { children: tooltipContent }))] }))), children: itemElement }), hasChildren && (_jsx(TreeViewContext.Provider, { value: { focusedId, level: level + 1, selectionMode, setFocusedId }, children: _jsx("div", { role: "group", id: groupId, hidden: !isExpanded, style: { '--tree-level': level - 1 }, children: annotateTreeItems(children) }) }))] }));
|
|
432
432
|
};
|
|
433
433
|
/**
|
|
434
434
|
* A skeleton placeholder for tree items that are being loaded. Renders one or
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeView.js","sourceRoot":"","sources":["../../../../src/next/tree-view/TreeView.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,UAAU,MAAM,YAAY,CAAC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G,OAEmC,EADnC,SAAS,cANQ,uDAOrB,CADa;IAEZ,MAAM,EAAE,KAAK,EAAE,GAAG,UAAU,CAAC,eAAe,CAAC,CAAC;IAC9C,OAAO,CACL,4BACE,GAAG,EAAE,GAAG,iBACI,MAAM,EAClB,SAAS,EAAE,UAAU,CAAC,4BAA4B,EAAE,SAAS,CAAC,EAC9D,KAAK,EAAE,gBAAE,cAAc,EAAE,KAAK,GAAG,CAAC,IAAK,KAAK,CAAyB,IACjE,cAAc,EACd,SAAS,cAEZ,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CACtC,KAAC,QAAQ,IAAS,MAAM,EAAC,MAAM,EAAC,KAAK,EAAC,MAAM,IAA7B,CAAC,CAA+B,CAChD,CAAC,IACE,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nimport { useMergeRefs } from '@floating-ui/react';\nimport classNames from 'classnames';\nimport {\n Children,\n cloneElement,\n createContext,\n isValidElement,\n useCallback,\n useContext,\n useId,\n useRef,\n useState,\n} from 'react';\n\nimport { type CommonProps, type TooltipObjectProps } from '../../_common/types';\nimport { useSemicontrolledState } from '../../_common/use-semi-controlled-state';\nimport { Checkbox } from '../../checkbox';\nimport { CleanIconButton } from '../../clean-icon-button';\nimport { ConditionalWrap } from '../../conditional-wrap';\nimport { ChevronRightIconOutline } from '../../icons/generated/heroIcons/ChevronRightIconOutline';\nimport { EllipsisHorizontalIconOutline } from '../../icons/generated/heroIcons/EllipsisHorizontalIconOutline';\nimport { Menu } from '../../menu';\nimport { Skeleton } from '../../skeleton';\nimport { Tooltip } from '../../tooltip';\n\ntype SelectionMode = 'single' | 'multiple';\n\ntype TreeViewContextValue = {\n focusedId: string | null;\n level: number;\n selectionMode: SelectionMode;\n setFocusedId: (id: string | null) => void;\n};\n\nconst noop = () => undefined;\n\nconst TREE_EVENTS = {\n action: 'treeitem-action',\n collapse: 'treeitem-collapse',\n expand: 'treeitem-expand',\n select: 'treeitem-select',\n} as const;\n\nconst TreeViewContext = createContext<TreeViewContextValue>({\n focusedId: null,\n level: 1,\n selectionMode: 'single',\n setFocusedId: noop,\n});\n\nfunction getVisibleTreeItems(root: HTMLElement): HTMLElement[] {\n return Array.from(\n root.querySelectorAll<HTMLElement>(\n '[role=\"treeitem\"]:not([role=\"group\"][hidden] [role=\"treeitem\"])',\n ),\n ).filter((el) => {\n let parent = el.parentElement;\n while (parent && parent !== root) {\n if (parent.getAttribute('role') === 'group' && parent.hidden) {\n return false;\n }\n parent = parent.parentElement;\n }\n return true;\n });\n}\n\nfunction annotateTreeItems(children: React.ReactNode): React.ReactNode {\n const items = Children.toArray(children);\n const treeItemCount = items.filter(\n (child): child is React.ReactElement =>\n isValidElement(child) && child.type === Item,\n ).length;\n\n let posInSet = 0;\n return Children.map(children, (child) => {\n if (isValidElement(child) && child.type === Item) {\n posInSet++;\n return cloneElement(\n child as React.ReactElement<React.HTMLAttributes<HTMLElement>>,\n {\n 'aria-posinset': posInSet,\n 'aria-setsize': treeItemCount,\n },\n );\n }\n return child;\n });\n}\n\ntype RootProps = {\n /** The aria-label for the tree. Required for accessibility, unless using ariaLabelledby. Pass null to omit. */\n ariaLabel: string | null;\n /** The aria-labelledby for the tree. Pass a string of space-separated IDs of elements that label the tree. */\n ariaLabelledby?: string;\n /** The children of the tree. Should be TreeView.Item components or TreeView.SkeletonItem components only. */\n children?: React.ReactNode;\n /** Selection mode for the tree. Defaults to \"single\". */\n selectionMode?: SelectionMode;\n};\n\n/**\n * Root container for a tree view. Renders a `role=\"tree\"` element with full\n * keyboard navigation (arrow keys, Home/End, Enter/Space) following the\n * WAI-ARIA TreeView pattern.\n *\n * Direct children should be `TreeView.Item` or `TreeView.SkeletonItem`.\n *\n * @example\n * ```tsx\n * <TreeView ariaLabel=\"Files\">\n * <TreeView.Item title=\"README.md\" onSelectedChange={setSelected} isSelected={selected} />\n * </TreeView>\n * ```\n *\n * @alpha - this component is still in development and may change in the future. It might not have feature parity with the old tree view yet.\n */\nconst Root = ({\n children,\n selectionMode = 'single',\n ariaLabel,\n ariaLabelledby,\n className,\n style,\n htmlAttributes,\n ref,\n ...restProps\n}: CommonProps<'div', RootProps>) => {\n const treeRef = useRef<HTMLDivElement>(null);\n const mergedRef = useMergeRefs([treeRef, ref]);\n const [focusedId, setFocusedId] = useState<string | null>(null);\n\n const handleKeyDown = useCallback(\n (e: React.KeyboardEvent<HTMLDivElement>) => {\n const root = treeRef.current;\n if (!root) {\n return;\n }\n\n const items = getVisibleTreeItems(root);\n if (items.length === 0) {\n return;\n }\n\n const currentIndex = items.findIndex((el) => el.id === focusedId);\n let isHandled = true;\n\n switch (e.key) {\n case 'ArrowDown': {\n const nextIndex =\n currentIndex < items.length - 1 ? currentIndex + 1 : currentIndex;\n const nextItem = items[nextIndex];\n if (nextItem) {\n setFocusedId(nextItem.id);\n nextItem.focus();\n }\n break;\n }\n case 'ArrowUp': {\n const prevIndex = currentIndex > 0 ? currentIndex - 1 : 0;\n const prevItem = items[prevIndex];\n if (prevItem) {\n setFocusedId(prevItem.id);\n prevItem.focus();\n }\n break;\n }\n case 'ArrowRight': {\n const current = currentIndex >= 0 ? items[currentIndex] : null;\n if (!current) {\n break;\n }\n const isExpanded = current.getAttribute('aria-expanded');\n if (isExpanded === 'false') {\n current.dispatchEvent(new CustomEvent(TREE_EVENTS.expand));\n } else if (isExpanded === 'true') {\n const nextIndex = currentIndex + 1;\n if (nextIndex < items.length) {\n const nextItem = items[nextIndex];\n setFocusedId(nextItem.id);\n nextItem.focus();\n }\n }\n break;\n }\n case 'ArrowLeft': {\n const current = currentIndex >= 0 ? items[currentIndex] : null;\n if (!current) {\n break;\n }\n const isExpanded = current.getAttribute('aria-expanded');\n if (isExpanded === 'true') {\n current.dispatchEvent(new CustomEvent(TREE_EVENTS.collapse));\n } else {\n const parentGroup = current.closest('[role=\"group\"]');\n if (parentGroup?.id) {\n const parentItem = root.querySelector<HTMLElement>(\n `[aria-owns=\"${parentGroup.id}\"]`,\n );\n if (parentItem) {\n setFocusedId(parentItem.id);\n parentItem.focus();\n }\n }\n }\n break;\n }\n case 'Home': {\n const first = items[0];\n if (first) {\n setFocusedId(first.id);\n first.focus();\n }\n break;\n }\n case 'End': {\n const last = items[items.length - 1];\n if (last) {\n setFocusedId(last.id);\n last.focus();\n }\n break;\n }\n case 'Enter':\n case ' ': {\n const current = currentIndex >= 0 ? items[currentIndex] : null;\n if (current) {\n current.dispatchEvent(new CustomEvent(TREE_EVENTS.select));\n }\n break;\n }\n case 'F10': {\n if (e.shiftKey) {\n const current = currentIndex >= 0 ? items[currentIndex] : null;\n if (current) {\n current.dispatchEvent(new CustomEvent(TREE_EVENTS.action));\n }\n } else {\n isHandled = false;\n }\n break;\n }\n default:\n isHandled = false;\n }\n\n if (isHandled) {\n e.preventDefault();\n e.stopPropagation();\n }\n },\n [focusedId],\n );\n\n const handleFocus = useCallback(\n (e: React.FocusEvent<HTMLDivElement>) => {\n const root = treeRef.current;\n if (!root) {\n return;\n }\n\n if (e.target === root) {\n const items = getVisibleTreeItems(root);\n const alreadyFocused = focusedId\n ? items.find((el) => el.id === focusedId)\n : null;\n const target = alreadyFocused ?? items[0];\n if (target) {\n setFocusedId(target.id);\n target.focus();\n }\n }\n },\n [focusedId],\n );\n\n const classes = classNames(className, 'ndl-tree-view-new');\n\n return (\n <TreeViewContext.Provider\n value={{ focusedId, level: 1, selectionMode, setFocusedId }}\n >\n <div\n ref={mergedRef}\n role=\"tree\"\n aria-multiselectable={selectionMode === 'multiple' || undefined}\n tabIndex={0}\n className={classes}\n onKeyDown={handleKeyDown}\n onFocus={handleFocus}\n aria-label={ariaLabel ?? undefined}\n aria-labelledby={ariaLabelledby}\n style={style}\n {...htmlAttributes}\n {...restProps}\n >\n {annotateTreeItems(children)}\n </div>\n </TreeViewContext.Provider>\n );\n};\n\ntype ItemProps = {\n /** Nested TreeView.Item or TreeView.SkeletonItem elements rendered as sub-items in a collapsible group. */\n children?: React.ReactNode;\n /** The label content displayed in the item row. */\n title?: React.ReactNode;\n /** Default expansion for uncontrolled items */\n // TODO v5: fix boolean naming convention\n // eslint-disable-next-line @typescript-eslint/naming-convention\n defaultExpanded?: boolean;\n /** Whether the item has children. Decides if the item should render a chevron for expansion. Needed for lazy loading. */\n hasChildren?: boolean;\n /** Whether the item is disabled */\n isDisabled?: boolean;\n /** Whether the item is expanded. Makes the item controlled. */\n isExpanded?: boolean;\n /** Whether the item is in an indeterminate state. Only meaningful in multi-select mode for parent nodes. */\n isIndeterminate?: boolean;\n /** Whether the item is loading. Applies aria-busy=\"true\" to the item. */\n isLoading?: boolean;\n /** Whether the item is selected */\n isSelected?: boolean;\n /** Leading visual for the item. */\n leadingVisual?: React.ReactNode;\n /** Trailing content for the item. Shown after the children but before the action menu. */\n trailingContent?: React.ReactNode;\n /** ReactNode containing Menu.Item elements to render in an action menu. When provided, an action button is rendered. */\n actionMenuItems?: React.ReactNode;\n /** Props forwarded to the Menu sub-components (anchorRef, onClose). */\n actionMenuProps?: React.ComponentProps<typeof Menu>;\n /** Content rendered inside the tooltip. When provided, the item is wrapped in a Tooltip. */\n tooltipContent?: React.ReactNode;\n /** Props forwarded to the Tooltip sub-components (root, trigger, content). */\n tooltipProps?: TooltipObjectProps;\n /** Callback called when the item is expanded/collapsed. */\n onExpandedChange?: (isExpanded: boolean) => void;\n /** Callback called when the item is selected/deselected. */\n onSelectedChange?: (isSelected: boolean) => void;\n};\n\n/**\n * A single item within a `TreeView`. Renders a `role=\"treeitem\"` element that\n * supports selection, expansion, leading/trailing visuals, and an action menu.\n *\n * The `title` prop provides the item's label content. Nesting `TreeView.Item`\n * elements as `children` creates a hierarchical tree structure.\n *\n * Supports both controlled (`isExpanded`) and uncontrolled (`defaultExpanded`)\n * expansion, as well as lazy loading via `hasChildren` + `isLoading`.\n *\n * @example\n * ```tsx\n * <TreeView.Item\n * title=\"src\"\n * leadingVisual={<FolderIcon />}\n * isSelected={selected}\n * onSelectedChange={setSelected}\n * >\n * <TreeView.Item title=\"index.ts\" />\n * </TreeView.Item>\n * ```\n */\nconst Item = ({\n actionMenuItems,\n children,\n defaultExpanded = false,\n hasChildren: hasChildrenProp,\n isDisabled,\n isExpanded: isExpandedProp,\n isIndeterminate,\n isLoading,\n isSelected,\n leadingVisual,\n title,\n tooltipContent,\n tooltipProps,\n trailingContent,\n onExpandedChange,\n onSelectedChange,\n actionMenuProps,\n className,\n style,\n htmlAttributes,\n ref,\n ...restProps\n}: CommonProps<'div', ItemProps>) => {\n const generatedId = useId();\n const itemId = `ndl-treeitem-${generatedId}`;\n const titleId = `ndl-treeitem-title-${generatedId}`;\n const groupId = `ndl-treegroup-${generatedId}`;\n const itemRef = useRef<HTMLDivElement>(null);\n const actionButtonRef = useRef<HTMLButtonElement>(null);\n const didOpenViaKeyboard = useRef(false);\n const [isMenuOpen, setIsMenuOpen] = useState(false);\n const { focusedId, level, selectionMode, setFocusedId } =\n useContext(TreeViewContext);\n\n const isControlledExpansion = isExpandedProp !== undefined;\n const [isExpanded, setIsExpanded] = useSemicontrolledState({\n isControlled: isControlledExpansion,\n onChange: onExpandedChange,\n state: isExpandedProp ?? defaultExpanded,\n });\n\n const hasChildren = hasChildrenProp ?? Children.count(children) > 0;\n const isSelectable = onSelectedChange !== undefined;\n const isMultiple = selectionMode === 'multiple';\n\n const toggleExpanded = useCallback(() => {\n if (isDisabled) {\n return;\n }\n if (hasChildren) {\n setIsExpanded(!isExpanded);\n }\n }, [isDisabled, hasChildren, setIsExpanded, isExpanded]);\n\n const handleSelect = useCallback(() => {\n if (isDisabled) {\n return;\n }\n onSelectedChange?.(!isSelected);\n }, [isDisabled, isSelected, onSelectedChange]);\n\n const handleClick = useCallback(() => {\n if (isDisabled) {\n return;\n }\n setFocusedId(itemId);\n if (isSelectable) {\n handleSelect();\n } else {\n toggleExpanded();\n }\n }, [\n isDisabled,\n setFocusedId,\n itemId,\n isSelectable,\n handleSelect,\n toggleExpanded,\n ]);\n\n const handleChevronClick = useCallback(\n (e: React.MouseEvent) => {\n e.stopPropagation();\n if (isDisabled) {\n return;\n }\n setFocusedId(itemId);\n toggleExpanded();\n },\n [isDisabled, setFocusedId, itemId, toggleExpanded],\n );\n\n const handleMenuClose = useCallback(() => {\n setIsMenuOpen(false);\n if (didOpenViaKeyboard.current) {\n itemRef.current?.focus();\n didOpenViaKeyboard.current = false;\n }\n }, []);\n\n const handleCustomEvents = useCallback(\n (e: Event) => {\n if (e.type === TREE_EVENTS.expand) {\n e.stopPropagation();\n if (hasChildren && !isExpanded && !isDisabled) {\n setIsExpanded(true);\n }\n } else if (e.type === TREE_EVENTS.collapse) {\n e.stopPropagation();\n if (hasChildren && isExpanded && !isDisabled) {\n setIsExpanded(false);\n }\n } else if (e.type === TREE_EVENTS.select) {\n e.stopPropagation();\n if (isSelectable) {\n handleSelect();\n } else {\n toggleExpanded();\n }\n } else if (e.type === TREE_EVENTS.action) {\n e.stopPropagation();\n if (actionMenuItems && !isDisabled) {\n didOpenViaKeyboard.current = true;\n setIsMenuOpen(true);\n }\n }\n },\n [\n actionMenuItems,\n hasChildren,\n isExpanded,\n isDisabled,\n isSelectable,\n setIsExpanded,\n handleSelect,\n toggleExpanded,\n ],\n );\n\n const callbackRef = useCallback(\n (node: HTMLDivElement | null) => {\n const prev = itemRef.current;\n if (prev) {\n prev.removeEventListener(TREE_EVENTS.expand, handleCustomEvents);\n prev.removeEventListener(TREE_EVENTS.collapse, handleCustomEvents);\n prev.removeEventListener(TREE_EVENTS.select, handleCustomEvents);\n prev.removeEventListener(TREE_EVENTS.action, handleCustomEvents);\n }\n (itemRef as React.MutableRefObject<HTMLDivElement | null>).current = node;\n if (node) {\n node.addEventListener(TREE_EVENTS.expand, handleCustomEvents);\n node.addEventListener(TREE_EVENTS.collapse, handleCustomEvents);\n node.addEventListener(TREE_EVENTS.select, handleCustomEvents);\n node.addEventListener(TREE_EVENTS.action, handleCustomEvents);\n }\n },\n [handleCustomEvents],\n );\n\n const mergedRef = useMergeRefs([callbackRef, ref]);\n\n const isFocused = focusedId === itemId;\n\n const selectionAriaProps = (() => {\n if (!isSelectable) {\n return {};\n }\n if (isMultiple) {\n return {\n 'aria-checked': isIndeterminate\n ? ('mixed' as const)\n : (isSelected ?? false),\n };\n }\n return { 'aria-selected': isSelected ?? false };\n })();\n\n const itemElement = (\n // eslint-disable-next-line jsx-a11y/click-events-have-key-events -- keyboard handled on tree root; aria-selected/aria-checked applied via spread\n <div\n ref={mergedRef}\n id={itemId}\n // eslint-disable-next-line jsx-a11y/role-has-required-aria-props -- aria-selected/aria-checked applied conditionally via spread\n role=\"treeitem\"\n {...selectionAriaProps}\n aria-expanded={hasChildren ? isExpanded : undefined}\n aria-owns={hasChildren ? groupId : undefined}\n aria-disabled={isDisabled || undefined}\n aria-busy={isLoading || undefined}\n aria-keyshortcuts={actionMenuItems ? 'Shift+F10' : undefined}\n aria-labelledby={titleId}\n aria-level={level}\n tabIndex={isFocused ? 0 : -1}\n className={classNames('ndl-tree-view-new-item', className, {\n 'ndl-tree-view-new-item--disabled': isDisabled,\n 'ndl-tree-view-new-item--parent': hasChildren,\n 'ndl-tree-view-new-item--selected': isSelected && isSelectable,\n })}\n style={{ '--tree-level': level - 1, ...style } as React.CSSProperties}\n onClick={(e) => {\n e.stopPropagation();\n handleClick();\n }}\n {...htmlAttributes}\n {...restProps}\n >\n <div\n className={classNames('ndl-tree-view-new-item-content', {\n 'ndl-tree-view-new-item-content--parent': hasChildren,\n })}\n >\n {hasChildren && (\n // eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions -- keyboard handled on tree root\n <span\n className=\"ndl-tree-view-new-chevron\"\n aria-disabled={isDisabled}\n onClick={handleChevronClick}\n >\n <ChevronRightIconOutline\n className={classNames('ndl-tree-view-new-chevron-icon', {\n 'ndl-tree-view-new-chevron-icon--open': isExpanded,\n })}\n />\n </span>\n )}\n {leadingVisual && (\n <div className=\"ndl-tree-view-new-item-content-leading-visual\">\n {leadingVisual}\n </div>\n )}\n {isMultiple && isSelectable && (\n <div className=\"ndl-tree-view-new-checkbox\" inert>\n <Checkbox\n style={{ borderWidth: '1.5px' }}\n ariaLabel=\"Select\"\n isChecked={isSelected}\n isIndeterminate={isIndeterminate}\n isDisabled={isDisabled}\n onChange={noop}\n />\n </div>\n )}\n <div id={titleId} className=\"ndl-tree-view-new-item-content-title\">\n {title}\n </div>\n {trailingContent && (\n <div className=\"ndl-tree-view-new-item-content-trailing-content\">\n {trailingContent}\n </div>\n )}\n {actionMenuItems && (\n <div\n className={classNames('ndl-tree-view-new-action', {\n 'ndl-tree-view-new-action--visible': isMenuOpen,\n })}\n >\n <CleanIconButton\n ref={actionButtonRef}\n size=\"small\"\n description={null}\n isDisabled={isDisabled}\n style={{ height: '24px', width: '24px' }}\n htmlAttributes={{\n 'aria-expanded': isMenuOpen || undefined,\n 'aria-haspopup': 'menu',\n 'aria-label': 'Actions',\n onClick: (e: React.MouseEvent) => {\n e.stopPropagation();\n didOpenViaKeyboard.current = false;\n setIsMenuOpen((prev) => !prev);\n },\n tabIndex: -1,\n }}\n >\n <EllipsisHorizontalIconOutline />\n </CleanIconButton>\n <Menu\n isOpen={isMenuOpen}\n anchorRef={actionButtonRef}\n onClose={handleMenuClose}\n {...actionMenuProps}\n >\n {actionMenuItems}\n </Menu>\n </div>\n )}\n </div>\n </div>\n );\n\n return (\n <>\n <ConditionalWrap\n shouldWrap={tooltipContent !== undefined && tooltipContent !== null}\n wrap={(children) => (\n <Tooltip\n type=\"simple\"\n hoverDelay={{ close: 0, open: 500 }}\n isDisabled={isMenuOpen}\n followCursor={true}\n {...tooltipProps?.root}\n >\n <Tooltip.Trigger hasButtonWrapper {...tooltipProps?.trigger}>\n {children}\n </Tooltip.Trigger>\n <Tooltip.Content {...tooltipProps?.content}>\n {tooltipContent}\n </Tooltip.Content>\n </Tooltip>\n )}\n >\n {itemElement}\n </ConditionalWrap>\n {hasChildren && (\n <TreeViewContext.Provider\n value={{ focusedId, level: level + 1, selectionMode, setFocusedId }}\n >\n <div\n role=\"group\"\n id={groupId}\n hidden={!isExpanded}\n style={{ '--tree-level': level - 1 } as React.CSSProperties}\n >\n {annotateTreeItems(children)}\n </div>\n </TreeViewContext.Provider>\n )}\n </>\n );\n};\n\ntype SkeletonItemProps = {\n /** The number of rows to render. */\n rows?: number;\n};\n\n/**\n * A skeleton placeholder for tree items that are being loaded. Renders one or\n * more `Skeleton` rows at the current nesting depth. The element is\n * `aria-hidden` since it is purely a visual indicator and not interactive.\n *\n * Typically used inside a `TreeView.Item` that has `isLoading` set, to give\n * the user a visual hint that child items are being fetched.\n *\n * @example\n * ```tsx\n * <TreeView.Item title=\"Lazy folder\" hasChildren isLoading={isLoading} isExpanded>\n * {isLoading && <TreeView.SkeletonItem rows={3} />}\n * </TreeView.Item>\n * ```\n */\nconst SkeletonItem = ({\n rows = 1,\n className,\n style,\n htmlAttributes,\n ref,\n ...restProps\n}: CommonProps<'div', SkeletonItemProps>) => {\n const { level } = useContext(TreeViewContext);\n return (\n <div\n ref={ref}\n aria-hidden=\"true\"\n className={classNames('ndl-tree-view-new-skeleton', className)}\n style={{ '--tree-level': level - 1, ...style } as React.CSSProperties}\n {...htmlAttributes}\n {...restProps}\n >\n {Array.from({ length: rows }, (_, i) => (\n <Skeleton key={i} height=\"18px\" width=\"100%\" />\n ))}\n </div>\n );\n};\n\nconst TreeView = Object.assign(Root, { Item, SkeletonItem });\nexport { TreeView };\n"]}
|
|
1
|
+
{"version":3,"file":"TreeView.js","sourceRoot":"","sources":["../../../../src/next/tree-view/TreeView.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EACL,QAAQ,EACR,YAAY,EACZ,aAAa,EACb,cAAc,EACd,WAAW,EACX,UAAU,EACV,KAAK,EACL,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAC;AAGf,OAAO,EAAE,sBAAsB,EAAE,MAAM,yCAAyC,CAAC;AACjF,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,uBAAuB,EAAE,MAAM,yDAAyD,CAAC;AAClG,OAAO,EAAE,6BAA6B,EAAE,MAAM,+DAA+D,CAAC;AAC9G,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAWxC,MAAM,IAAI,GAAG,GAAG,EAAE,CAAC,SAAS,CAAC;AAE7B,MAAM,WAAW,GAAG;IAClB,MAAM,EAAE,iBAAiB;IACzB,QAAQ,EAAE,mBAAmB;IAC7B,MAAM,EAAE,iBAAiB;IACzB,MAAM,EAAE,iBAAiB;CACjB,CAAC;AAEX,MAAM,eAAe,GA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AAE,aAAa,EAAE,YAAY,EAAE,YAEnE,cACE,IAAI,EAAC,OAAO,EACZ,EAAE,EAAE,OAAO,EACX,MAAM,EAAE,CAAC,UAAU,EACnB,KAAK,EAAE,EAAE,cAAc,EAAE,KAAK,GAAG,CAAC,EAAyB,YAE1D,iBAAiB,CAAC,QAAQ,CAAC,GACxB,GACmB,CAC5B,IACA,CACJ,CAAC;AACJ,CAAC,CAAC;AAOF;;;;;;;;;;;;;;GAcG;AACH,MAAM,YAAY,GAAG,CAAC,EAOkB,EAAE,EAAE;QAPtB,EACpB,IAAI,GAAG,CAAC,EACR,SAAS,EACT,KAAK,EACL,cAAc,EACd,GAAG,OAEmC,EADnC,SAAS,cANQ,uDAOrB,CADa;IAEZ,MAAM,EAAE,KAAK,EAAE,GAAG,UAAU,CAAC,eAAe,CAAC,CAAC;IAC9C,OAAO,CACL,4BACE,GAAG,EAAE,GAAG,iBACI,MAAM,EAClB,SAAS,EAAE,UAAU,CAAC,4BAA4B,EAAE,SAAS,CAAC,EAC9D,KAAK,EAAE,gBAAE,cAAc,EAAE,KAAK,GAAG,CAAC,IAAK,KAAK,CAAyB,IACjE,cAAc,EACd,SAAS,cAEZ,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CACtC,KAAC,QAAQ,IAAS,MAAM,EAAC,MAAM,EAAC,KAAK,EAAC,MAAM,IAA7B,CAAC,CAA+B,CAChD,CAAC,IACE,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nimport { useMergeRefs } from '@floating-ui/react';\nimport classNames from 'classnames';\nimport {\n Children,\n cloneElement,\n createContext,\n isValidElement,\n useCallback,\n useContext,\n useId,\n useRef,\n useState,\n} from 'react';\n\nimport { type CommonProps, type TooltipObjectProps } from '../../_common/types';\nimport { useSemicontrolledState } from '../../_common/use-semi-controlled-state';\nimport { Checkbox } from '../../checkbox';\nimport { CleanIconButton } from '../../clean-icon-button';\nimport { ConditionalWrap } from '../../conditional-wrap';\nimport { ChevronRightIconOutline } from '../../icons/generated/heroIcons/ChevronRightIconOutline';\nimport { EllipsisHorizontalIconOutline } from '../../icons/generated/heroIcons/EllipsisHorizontalIconOutline';\nimport { Menu } from '../../menu';\nimport { Skeleton } from '../../skeleton';\nimport { Tooltip } from '../../tooltip';\n\ntype SelectionMode = 'single' | 'multiple';\n\ntype TreeViewContextValue = {\n focusedId: string | null;\n level: number;\n selectionMode: SelectionMode;\n setFocusedId: (id: string | null) => void;\n};\n\nconst noop = () => undefined;\n\nconst TREE_EVENTS = {\n action: 'treeitem-action',\n collapse: 'treeitem-collapse',\n expand: 'treeitem-expand',\n select: 'treeitem-select',\n} as const;\n\nconst TreeViewContext = createContext<TreeViewContextValue>({\n focusedId: null,\n level: 1,\n selectionMode: 'single',\n setFocusedId: noop,\n});\n\nfunction getVisibleTreeItems(root: HTMLElement): HTMLElement[] {\n return Array.from(\n root.querySelectorAll<HTMLElement>(\n '[role=\"treeitem\"]:not([role=\"group\"][hidden] [role=\"treeitem\"])',\n ),\n ).filter((el) => {\n let parent = el.parentElement;\n while (parent && parent !== root) {\n if (parent.getAttribute('role') === 'group' && parent.hidden) {\n return false;\n }\n parent = parent.parentElement;\n }\n return true;\n });\n}\n\nfunction annotateTreeItems(children: React.ReactNode): React.ReactNode {\n const items = Children.toArray(children);\n const treeItemCount = items.filter(\n (child): child is React.ReactElement =>\n isValidElement(child) && child.type === Item,\n ).length;\n\n let posInSet = 0;\n return Children.map(children, (child) => {\n if (isValidElement(child) && child.type === Item) {\n posInSet++;\n return cloneElement(\n child as React.ReactElement<React.HTMLAttributes<HTMLElement>>,\n {\n 'aria-posinset': posInSet,\n 'aria-setsize': treeItemCount,\n },\n );\n }\n return child;\n });\n}\n\ntype RootProps = {\n /** The aria-label for the tree. Required for accessibility, unless using ariaLabelledby. Pass null to omit. */\n ariaLabel: string | null;\n /** The aria-labelledby for the tree. Pass a string of space-separated IDs of elements that label the tree. */\n ariaLabelledby?: string;\n /** The children of the tree. Should be TreeView.Item components or TreeView.SkeletonItem components only. */\n children?: React.ReactNode;\n /** Selection mode for the tree. Defaults to \"single\". */\n selectionMode?: SelectionMode;\n};\n\n/**\n * Root container for a tree view. Renders a `role=\"tree\"` element with full\n * keyboard navigation (arrow keys, Home/End, Enter/Space) following the\n * WAI-ARIA TreeView pattern.\n *\n * Direct children should be `TreeView.Item` or `TreeView.SkeletonItem`.\n *\n * @example\n * ```tsx\n * <TreeView ariaLabel=\"Files\">\n * <TreeView.Item title=\"README.md\" onSelectedChange={setSelected} isSelected={selected} />\n * </TreeView>\n * ```\n *\n * @alpha - this component is still in development and may change in the future. It might not have feature parity with the old tree view yet.\n */\nconst Root = ({\n children,\n selectionMode = 'single',\n ariaLabel,\n ariaLabelledby,\n className,\n style,\n htmlAttributes,\n ref,\n ...restProps\n}: CommonProps<'div', RootProps>) => {\n const treeRef = useRef<HTMLDivElement>(null);\n const mergedRef = useMergeRefs([treeRef, ref]);\n const [focusedId, setFocusedId] = useState<string | null>(null);\n\n const handleKeyDown = useCallback(\n (e: React.KeyboardEvent<HTMLDivElement>) => {\n const root = treeRef.current;\n if (!root) {\n return;\n }\n\n const items = getVisibleTreeItems(root);\n if (items.length === 0) {\n return;\n }\n\n const currentIndex = items.findIndex((el) => el.id === focusedId);\n let isHandled = true;\n\n switch (e.key) {\n case 'ArrowDown': {\n const nextIndex =\n currentIndex < items.length - 1 ? currentIndex + 1 : currentIndex;\n const nextItem = items[nextIndex];\n if (nextItem) {\n setFocusedId(nextItem.id);\n nextItem.focus();\n }\n break;\n }\n case 'ArrowUp': {\n const prevIndex = currentIndex > 0 ? currentIndex - 1 : 0;\n const prevItem = items[prevIndex];\n if (prevItem) {\n setFocusedId(prevItem.id);\n prevItem.focus();\n }\n break;\n }\n case 'ArrowRight': {\n const current = currentIndex >= 0 ? items[currentIndex] : null;\n if (!current) {\n break;\n }\n const isExpanded = current.getAttribute('aria-expanded');\n if (isExpanded === 'false') {\n current.dispatchEvent(new CustomEvent(TREE_EVENTS.expand));\n } else if (isExpanded === 'true') {\n const nextIndex = currentIndex + 1;\n if (nextIndex < items.length) {\n const nextItem = items[nextIndex];\n setFocusedId(nextItem.id);\n nextItem.focus();\n }\n }\n break;\n }\n case 'ArrowLeft': {\n const current = currentIndex >= 0 ? items[currentIndex] : null;\n if (!current) {\n break;\n }\n const isExpanded = current.getAttribute('aria-expanded');\n if (isExpanded === 'true') {\n current.dispatchEvent(new CustomEvent(TREE_EVENTS.collapse));\n } else {\n const parentGroup = current.closest('[role=\"group\"]');\n if (parentGroup?.id) {\n const parentItem = root.querySelector<HTMLElement>(\n `[aria-owns=\"${parentGroup.id}\"]`,\n );\n if (parentItem) {\n setFocusedId(parentItem.id);\n parentItem.focus();\n }\n }\n }\n break;\n }\n case 'Home': {\n const first = items[0];\n if (first) {\n setFocusedId(first.id);\n first.focus();\n }\n break;\n }\n case 'End': {\n const last = items[items.length - 1];\n if (last) {\n setFocusedId(last.id);\n last.focus();\n }\n break;\n }\n case 'Enter':\n case ' ': {\n const current = currentIndex >= 0 ? items[currentIndex] : null;\n if (current) {\n current.dispatchEvent(new CustomEvent(TREE_EVENTS.select));\n }\n break;\n }\n case 'F10': {\n if (e.shiftKey) {\n const current = currentIndex >= 0 ? items[currentIndex] : null;\n if (current) {\n current.dispatchEvent(new CustomEvent(TREE_EVENTS.action));\n }\n } else {\n isHandled = false;\n }\n break;\n }\n default:\n isHandled = false;\n }\n\n if (isHandled) {\n e.preventDefault();\n e.stopPropagation();\n }\n },\n [focusedId],\n );\n\n const handleFocus = useCallback(\n (e: React.FocusEvent<HTMLDivElement>) => {\n const root = treeRef.current;\n if (!root) {\n return;\n }\n\n if (e.target === root) {\n const items = getVisibleTreeItems(root);\n const alreadyFocused = focusedId\n ? items.find((el) => el.id === focusedId)\n : null;\n const target = alreadyFocused ?? items[0];\n if (target) {\n setFocusedId(target.id);\n target.focus();\n }\n }\n },\n [focusedId],\n );\n\n const classes = classNames(className, 'ndl-tree-view-new');\n\n return (\n <TreeViewContext.Provider\n value={{ focusedId, level: 1, selectionMode, setFocusedId }}\n >\n <div\n ref={mergedRef}\n role=\"tree\"\n aria-multiselectable={selectionMode === 'multiple' || undefined}\n tabIndex={0}\n className={classes}\n onKeyDown={handleKeyDown}\n onFocus={handleFocus}\n aria-label={ariaLabel ?? undefined}\n aria-labelledby={ariaLabelledby}\n style={style}\n {...htmlAttributes}\n {...restProps}\n >\n {annotateTreeItems(children)}\n </div>\n </TreeViewContext.Provider>\n );\n};\n\ntype ItemProps = {\n /** Nested TreeView.Item or TreeView.SkeletonItem elements rendered as sub-items in a collapsible group. */\n children?: React.ReactNode;\n /** The label content displayed in the item row. */\n title?: React.ReactNode;\n /** Default expansion for uncontrolled items */\n // TODO v5: fix boolean naming convention\n // eslint-disable-next-line @typescript-eslint/naming-convention\n defaultExpanded?: boolean;\n /** Whether the item has children. Decides if the item should render a chevron for expansion. Needed for lazy loading. */\n hasChildren?: boolean;\n /** Whether the item is disabled */\n isDisabled?: boolean;\n /** Whether the item is expanded. Makes the item controlled. */\n isExpanded?: boolean;\n /** Whether the item is in an indeterminate state. Only meaningful in multi-select mode for parent nodes. */\n isIndeterminate?: boolean;\n /** Whether the item is loading. Applies aria-busy=\"true\" to the item. */\n isLoading?: boolean;\n /** Whether the item is selected */\n isSelected?: boolean;\n /** Leading visual for the item. */\n leadingVisual?: React.ReactNode;\n /** Trailing content for the item. Shown after the children but before the action menu. */\n trailingContent?: React.ReactNode;\n /** ReactNode containing Menu.Item elements to render in an action menu. When provided, an action button is rendered. */\n actionMenuItems?: React.ReactNode;\n /** Props forwarded to the Menu sub-components (anchorRef, onClose). */\n actionMenuProps?: React.ComponentProps<typeof Menu>;\n /** Content rendered inside the tooltip. When provided, the item is wrapped in a Tooltip. */\n tooltipContent?: React.ReactNode;\n /** Props forwarded to the Tooltip sub-components (root, trigger, content). */\n tooltipProps?: TooltipObjectProps;\n /** Callback called when the item is expanded/collapsed. */\n onExpandedChange?: (isExpanded: boolean) => void;\n /** Callback called when the item is selected/deselected. */\n onSelectedChange?: (isSelected: boolean) => void;\n};\n\n/**\n * A single item within a `TreeView`. Renders a `role=\"treeitem\"` element that\n * supports selection, expansion, leading/trailing visuals, and an action menu.\n *\n * The `title` prop provides the item's label content. Nesting `TreeView.Item`\n * elements as `children` creates a hierarchical tree structure.\n *\n * Supports both controlled (`isExpanded`) and uncontrolled (`defaultExpanded`)\n * expansion, as well as lazy loading via `hasChildren` + `isLoading`.\n *\n * @example\n * ```tsx\n * <TreeView.Item\n * title=\"src\"\n * leadingVisual={<FolderIcon />}\n * isSelected={selected}\n * onSelectedChange={setSelected}\n * >\n * <TreeView.Item title=\"index.ts\" />\n * </TreeView.Item>\n * ```\n */\nconst Item = ({\n actionMenuItems,\n children,\n defaultExpanded = false,\n hasChildren: hasChildrenProp,\n isDisabled,\n isExpanded: isExpandedProp,\n isIndeterminate,\n isLoading,\n isSelected,\n leadingVisual,\n title,\n tooltipContent,\n tooltipProps,\n trailingContent,\n onExpandedChange,\n onSelectedChange,\n actionMenuProps,\n className,\n style,\n htmlAttributes,\n ref,\n ...restProps\n}: CommonProps<'div', ItemProps>) => {\n const generatedId = useId();\n const itemId = `ndl-treeitem-${generatedId}`;\n const titleId = `ndl-treeitem-title-${generatedId}`;\n const groupId = `ndl-treegroup-${generatedId}`;\n const itemRef = useRef<HTMLDivElement>(null);\n const actionButtonRef = useRef<HTMLButtonElement>(null);\n const didOpenViaKeyboard = useRef(false);\n const [isMenuOpen, setIsMenuOpen] = useState(false);\n const { focusedId, level, selectionMode, setFocusedId } =\n useContext(TreeViewContext);\n\n const isControlledExpansion = isExpandedProp !== undefined;\n const [isExpanded, setIsExpanded] = useSemicontrolledState({\n isControlled: isControlledExpansion,\n onChange: onExpandedChange,\n state: isExpandedProp ?? defaultExpanded,\n });\n\n const hasChildren = hasChildrenProp ?? Children.count(children) > 0;\n const isSelectable = onSelectedChange !== undefined;\n const isMultiple = selectionMode === 'multiple';\n\n const toggleExpanded = useCallback(() => {\n if (isDisabled) {\n return;\n }\n if (hasChildren) {\n setIsExpanded(!isExpanded);\n }\n }, [isDisabled, hasChildren, setIsExpanded, isExpanded]);\n\n const handleSelect = useCallback(() => {\n if (isDisabled) {\n return;\n }\n onSelectedChange?.(!isSelected);\n }, [isDisabled, isSelected, onSelectedChange]);\n\n const handleClick = useCallback(() => {\n if (isDisabled) {\n return;\n }\n setFocusedId(itemId);\n if (isSelectable) {\n handleSelect();\n } else {\n toggleExpanded();\n }\n }, [\n isDisabled,\n setFocusedId,\n itemId,\n isSelectable,\n handleSelect,\n toggleExpanded,\n ]);\n\n const handleChevronClick = useCallback(\n (e: React.MouseEvent) => {\n e.stopPropagation();\n if (isDisabled) {\n return;\n }\n setFocusedId(itemId);\n toggleExpanded();\n },\n [isDisabled, setFocusedId, itemId, toggleExpanded],\n );\n\n const handleMenuClose = useCallback(() => {\n setIsMenuOpen(false);\n if (didOpenViaKeyboard.current) {\n itemRef.current?.focus();\n didOpenViaKeyboard.current = false;\n }\n }, []);\n\n const handleCustomEvents = useCallback(\n (e: Event) => {\n if (e.type === TREE_EVENTS.expand) {\n e.stopPropagation();\n if (hasChildren && !isExpanded && !isDisabled) {\n setIsExpanded(true);\n }\n } else if (e.type === TREE_EVENTS.collapse) {\n e.stopPropagation();\n if (hasChildren && isExpanded && !isDisabled) {\n setIsExpanded(false);\n }\n } else if (e.type === TREE_EVENTS.select) {\n e.stopPropagation();\n if (isSelectable) {\n handleSelect();\n } else {\n toggleExpanded();\n }\n } else if (e.type === TREE_EVENTS.action) {\n e.stopPropagation();\n if (actionMenuItems && !isDisabled) {\n didOpenViaKeyboard.current = true;\n setIsMenuOpen(true);\n }\n }\n },\n [\n actionMenuItems,\n hasChildren,\n isExpanded,\n isDisabled,\n isSelectable,\n setIsExpanded,\n handleSelect,\n toggleExpanded,\n ],\n );\n\n const callbackRef = useCallback(\n (node: HTMLDivElement | null) => {\n const prev = itemRef.current;\n if (prev) {\n prev.removeEventListener(TREE_EVENTS.expand, handleCustomEvents);\n prev.removeEventListener(TREE_EVENTS.collapse, handleCustomEvents);\n prev.removeEventListener(TREE_EVENTS.select, handleCustomEvents);\n prev.removeEventListener(TREE_EVENTS.action, handleCustomEvents);\n }\n (itemRef as React.MutableRefObject<HTMLDivElement | null>).current = node;\n if (node) {\n node.addEventListener(TREE_EVENTS.expand, handleCustomEvents);\n node.addEventListener(TREE_EVENTS.collapse, handleCustomEvents);\n node.addEventListener(TREE_EVENTS.select, handleCustomEvents);\n node.addEventListener(TREE_EVENTS.action, handleCustomEvents);\n }\n },\n [handleCustomEvents],\n );\n\n const mergedRef = useMergeRefs([callbackRef, ref]);\n\n const isFocused = focusedId === itemId;\n\n const selectionAriaProps = (() => {\n if (!isSelectable) {\n return {};\n }\n if (isMultiple) {\n return {\n 'aria-checked': isIndeterminate\n ? ('mixed' as const)\n : (isSelected ?? false),\n };\n }\n return { 'aria-selected': isSelected ?? false };\n })();\n\n const itemElement = (\n // eslint-disable-next-line jsx-a11y/click-events-have-key-events -- keyboard handled on tree root; aria-selected/aria-checked applied via spread\n <div\n ref={mergedRef}\n id={itemId}\n // eslint-disable-next-line jsx-a11y/role-has-required-aria-props -- aria-selected/aria-checked applied conditionally via spread\n role=\"treeitem\"\n {...selectionAriaProps}\n aria-expanded={hasChildren ? isExpanded : undefined}\n aria-owns={hasChildren ? groupId : undefined}\n aria-disabled={isDisabled || undefined}\n aria-busy={isLoading || undefined}\n aria-keyshortcuts={actionMenuItems ? 'Shift+F10' : undefined}\n aria-labelledby={titleId}\n aria-level={level}\n tabIndex={isFocused ? 0 : -1}\n className={classNames('ndl-tree-view-new-item', className, {\n 'ndl-tree-view-new-item--disabled': isDisabled,\n 'ndl-tree-view-new-item--parent': hasChildren,\n 'ndl-tree-view-new-item--selected': isSelected && isSelectable,\n })}\n style={{ '--tree-level': level - 1, ...style } as React.CSSProperties}\n onClick={(e) => {\n e.stopPropagation();\n handleClick();\n }}\n {...htmlAttributes}\n {...restProps}\n >\n <div\n className={classNames('ndl-tree-view-new-item-content', {\n 'ndl-tree-view-new-item-content--parent': hasChildren,\n })}\n >\n {hasChildren && (\n // eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions -- keyboard handled on tree root\n <span\n className=\"ndl-tree-view-new-chevron\"\n aria-disabled={isDisabled}\n onClick={handleChevronClick}\n >\n <ChevronRightIconOutline\n className={classNames('ndl-tree-view-new-chevron-icon', {\n 'ndl-tree-view-new-chevron-icon--open': isExpanded,\n })}\n />\n </span>\n )}\n {leadingVisual && (\n <div className=\"ndl-tree-view-new-item-content-leading-visual\">\n {leadingVisual}\n </div>\n )}\n {isMultiple && isSelectable && (\n <div className=\"ndl-tree-view-new-checkbox\" inert>\n <Checkbox\n style={{ borderWidth: '1.5px' }}\n ariaLabel=\"Select\"\n isChecked={isSelected}\n isIndeterminate={isIndeterminate}\n isDisabled={isDisabled}\n onChange={noop}\n />\n </div>\n )}\n <div id={titleId} className=\"ndl-tree-view-new-item-content-title\">\n {title}\n </div>\n {trailingContent && (\n <div className=\"ndl-tree-view-new-item-content-trailing-content\">\n {trailingContent}\n </div>\n )}\n {actionMenuItems && (\n <div\n className={classNames('ndl-tree-view-new-action', {\n 'ndl-tree-view-new-action--visible': isMenuOpen,\n })}\n >\n <CleanIconButton\n ref={actionButtonRef}\n size=\"small\"\n description={null}\n isDisabled={isDisabled}\n style={{ height: '24px', width: '24px' }}\n htmlAttributes={{\n 'aria-expanded': isMenuOpen || undefined,\n 'aria-haspopup': 'menu',\n 'aria-label': 'Actions',\n onClick: (e: React.MouseEvent) => {\n e.stopPropagation();\n didOpenViaKeyboard.current = false;\n setIsMenuOpen((prev) => !prev);\n },\n tabIndex: -1,\n }}\n >\n <EllipsisHorizontalIconOutline />\n </CleanIconButton>\n <Menu\n isOpen={isMenuOpen}\n anchorRef={actionButtonRef}\n onClose={handleMenuClose}\n {...actionMenuProps}\n >\n {actionMenuItems}\n </Menu>\n </div>\n )}\n </div>\n </div>\n );\n\n return (\n <>\n <ConditionalWrap\n shouldWrap={tooltipContent !== undefined && tooltipContent !== null}\n wrap={(children) => (\n <Tooltip\n type=\"simple\"\n hoverDelay={{ close: 0, open: 500 }}\n isDisabled={isMenuOpen}\n followCursor=\"initial\"\n {...tooltipProps?.root}\n >\n <Tooltip.Trigger hasButtonWrapper {...tooltipProps?.trigger}>\n {children}\n </Tooltip.Trigger>\n <Tooltip.Content {...tooltipProps?.content}>\n {tooltipContent}\n </Tooltip.Content>\n </Tooltip>\n )}\n >\n {itemElement}\n </ConditionalWrap>\n {hasChildren && (\n <TreeViewContext.Provider\n value={{ focusedId, level: level + 1, selectionMode, setFocusedId }}\n >\n <div\n role=\"group\"\n id={groupId}\n hidden={!isExpanded}\n style={{ '--tree-level': level - 1 } as React.CSSProperties}\n >\n {annotateTreeItems(children)}\n </div>\n </TreeViewContext.Provider>\n )}\n </>\n );\n};\n\ntype SkeletonItemProps = {\n /** The number of rows to render. */\n rows?: number;\n};\n\n/**\n * A skeleton placeholder for tree items that are being loaded. Renders one or\n * more `Skeleton` rows at the current nesting depth. The element is\n * `aria-hidden` since it is purely a visual indicator and not interactive.\n *\n * Typically used inside a `TreeView.Item` that has `isLoading` set, to give\n * the user a visual hint that child items are being fetched.\n *\n * @example\n * ```tsx\n * <TreeView.Item title=\"Lazy folder\" hasChildren isLoading={isLoading} isExpanded>\n * {isLoading && <TreeView.SkeletonItem rows={3} />}\n * </TreeView.Item>\n * ```\n */\nconst SkeletonItem = ({\n rows = 1,\n className,\n style,\n htmlAttributes,\n ref,\n ...restProps\n}: CommonProps<'div', SkeletonItemProps>) => {\n const { level } = useContext(TreeViewContext);\n return (\n <div\n ref={ref}\n aria-hidden=\"true\"\n className={classNames('ndl-tree-view-new-skeleton', className)}\n style={{ '--tree-level': level - 1, ...style } as React.CSSProperties}\n {...htmlAttributes}\n {...restProps}\n >\n {Array.from({ length: rows }, (_, i) => (\n <Skeleton key={i} height=\"18px\" width=\"100%\" />\n ))}\n </div>\n );\n};\n\nconst TreeView = Object.assign(Root, { Item, SkeletonItem });\nexport { TreeView };\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tooltip.js","sourceRoot":"","sources":["../../../src/tooltip/Tooltip.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAEL,oBAAoB,EACpB,cAAc,EAGd,YAAY,GACb,MAAM,oBAAoB,CAAC;AAC5B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGzC,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAE,UAAU,EAA2B,MAAM,eAAe,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAuC9E,MAAM,gBAAgB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K,EACL,cAAc,EACd,GAAG,OAEqC,EADrC,SAAS,cANG,2DAOhB,CADa;IAEZ,MAAM,OAAO,GAAG,iBAAiB,EAAE,CAAC;IACpC,MAAM,UAAU,GAAG,YAAY,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC,CAAC;IAEjE,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;QACpB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,OAAO,GAAG,UAAU,CAAC,qBAAqB,EAAE,SAAS,CAAC,CAAC;IAE7D,OAAO,CACL,4BACE,SAAS,EAAE,OAAO,EAClB,GAAG,EAAE,UAAU,EACf,KAAK,EAAE,KAAK,IACR,SAAS,EACT,cAAc,cAEjB,QAAQ,IACL,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,OAAO,CAAC,WAAW,GAAG,iBAAiB,CAAC;AAExC,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,gBAAgB,EAAE;IAC9C,OAAO,EAAE,OAAO;IAChB,IAAI,EAAE,WAAW;IACjB,OAAO,EAAE,cAAc;IACvB,MAAM,EAAE,aAAa;IACrB,OAAO,EAAE,cAAc;CACxB,CAAC,CAAC;AAEH,OAAO,EAAE,OAAO,EAAE,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\nimport {\n type AutoUpdateOptions,\n FloatingFocusManager,\n FloatingPortal,\n type Placement,\n type UseFloatingOptions,\n useMergeRefs,\n} from '@floating-ui/react';\nimport classNames from 'classnames';\nimport React, { useEffect } from 'react';\n\nimport { type CommonProps } from '../_common/types';\nimport { ConditionalWrap } from '../conditional-wrap';\nimport { useIsInsideDialog } from '../dialog/dialog-context';\nimport { useNeedleTheme } from '../theme';\nimport { Typography, type TypographyVariants } from '../typography';\nimport { TooltipContext, useTooltip, useTooltipContext } from './use-tooltip';\n\nexport type TooltipProps = {\n /** Content displayed inside the tooltip. Wraps `Tooltip.Trigger`, `Tooltip.Content`, and optional parts */\n children: React.ReactNode;\n /** Whether the tooltip is disabled */\n isDisabled?: boolean;\n /** Whether the tooltip should be open on first render */\n isInitialOpen?: boolean;\n /** Placement of the tooltip content relative to the trigger */\n placement?: Placement;\n /** Controls the open state . If omitted, the tooltip manages its own state */\n isOpen?: boolean;\n // TODO v5: deprecate this prop\n /**\n * Visual style of the tooltip content. `simple` renders plain text, `rich` renders a composable panel\n * @deprecated rich type will be removed in v5, use simple type instead.\n */\n type: 'simple' | 'rich';\n /** Whether the content is rendered in a portal. */\n isPortaled?: boolean;\n /** Callback fired when the open state changes, if omitted, the tooltip manages its own state using internal hooks */\n onOpenChange?: UseFloatingOptions['onOpenChange'];\n /** Positioning strategy of the tooltip. Defaults to `fixed` when inside a dialog, otherwise `absolute` */\n floatingStrategy?: 'absolute' | 'fixed';\n /** Hover open/close delays in milliseconds */\n hoverDelay?: {\n open: number;\n close: number;\n };\n /** Whether the tooltip should close when the reference element is clicked. Useful when the trigger moves after click. */\n shouldCloseOnReferenceClick?: boolean;\n autoUpdateOptions?: AutoUpdateOptions;\n /** Whether the tooltip should follow the mouse cursor. Only applies to 'simple' tooltips with mouse hover. */\n // TODO v5: rename this prop to follow lint rule\n // eslint-disable-next-line @typescript-eslint/naming-convention\n followCursor?: boolean;\n};\n\nconst TooltipComponent = ({\n children,\n isDisabled = false,\n type,\n isInitialOpen,\n placement,\n isOpen,\n onOpenChange,\n isPortaled: isPortaledProp,\n floatingStrategy: strategyProp,\n hoverDelay,\n shouldCloseOnReferenceClick,\n autoUpdateOptions,\n followCursor,\n}: TooltipProps) => {\n const isInsideDialog = useIsInsideDialog();\n const strategy = isInsideDialog ? 'fixed' : 'absolute';\n const isPortaled = !isInsideDialog;\n\n const tooltip = useTooltip({\n autoUpdateOptions,\n followCursor,\n hoverDelay,\n isDisabled,\n isInitialOpen,\n // if isDisabled is true tooltip will not open otherwise either controlled or uncontrolled depending on if isOpen is passed\n isOpen: isDisabled === true ? false : isOpen,\n isPortaled: isPortaledProp ?? isPortaled,\n onOpenChange,\n placement,\n shouldCloseOnReferenceClick,\n strategy: strategyProp ?? strategy,\n type,\n });\n\n return (\n <TooltipContext.Provider value={tooltip}>\n {children}\n </TooltipContext.Provider>\n );\n};\n\nTooltipComponent.displayName = 'Tooltip';\n\ntype TooltipTriggerProps = {\n /** Content displayed inside the trigger element */\n children: React.ReactNode;\n /** Whether the trigger element can be any element without an extra button wrapper. The child element will be cloned with the necessary trigger props and merged refs */\n hasButtonWrapper?: boolean;\n};\n\nconst TooltipTrigger = ({\n children,\n hasButtonWrapper = false,\n htmlAttributes,\n className,\n style,\n ref,\n ...restProps\n}: CommonProps<'button', TooltipTriggerProps>) => {\n const context = useTooltipContext();\n\n // Example from floating-ui\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n const childrenProps = (children as any).props;\n const mergedRefs = useMergeRefs([\n context.refs.setReference,\n ref,\n childrenProps?.ref,\n ]);\n\n const triggerClasses = classNames(\n {\n 'ndl-closed': !context.isOpen,\n 'ndl-open': context.isOpen,\n },\n 'ndl-tooltip-trigger',\n className,\n );\n\n // `hasButtonWrapper=true` allows the user to pass any element as the anchor\n if (hasButtonWrapper && React.isValidElement(children)) {\n const props: Record<string, unknown> = {\n className: triggerClasses,\n ...htmlAttributes,\n ...childrenProps,\n ref: mergedRefs,\n };\n\n return React.cloneElement(children, context.getReferenceProps(props));\n }\n\n return (\n <button\n type=\"button\"\n className={triggerClasses}\n style={style}\n ref={mergedRefs}\n {...context.getReferenceProps(htmlAttributes)}\n {...restProps}\n >\n {children}\n </button>\n );\n};\n\ntype TooltipContentProps = {\n /** Content displayed inside the tooltip */\n children: React.ReactNode;\n};\n\nconst TooltipContent = ({\n children,\n style,\n htmlAttributes,\n className,\n ref,\n ...restProps\n}: CommonProps<'div', TooltipContentProps>) => {\n const context = useTooltipContext();\n const mergedRef = useMergeRefs([context.refs.setFloating, ref]);\n const { themeClassName } = useNeedleTheme();\n\n const hasHeaderChild = React.useMemo(() => {\n if (context.type !== 'rich') {\n return false;\n }\n const childrenArray = React.Children.toArray(children);\n return childrenArray.some(\n (child) => React.isValidElement(child) && child.type === TooltipHeader,\n );\n }, [children, context.type]);\n\n if (!context.isOpen) {\n return null;\n }\n\n const classes = classNames('ndl-tooltip-content', themeClassName, className, {\n 'ndl-tooltip-content-rich': context.type === 'rich',\n 'ndl-tooltip-content-simple': context.type === 'simple',\n });\n\n if (context.type === 'simple') {\n return (\n <ConditionalWrap\n shouldWrap={context.isPortaled}\n wrap={(wrapChildren) => <FloatingPortal>{wrapChildren}</FloatingPortal>}\n >\n <div\n ref={mergedRef}\n className={classes}\n style={{\n ...context.floatingStyles,\n ...style,\n }}\n {...restProps}\n {...context.getFloatingProps(htmlAttributes)}\n >\n <Typography variant=\"body-medium\">{children}</Typography>\n </div>\n </ConditionalWrap>\n );\n }\n\n const ariaLabelledBy =\n htmlAttributes?.['aria-labelledby'] ??\n (hasHeaderChild ? context.headerId : undefined);\n\n if (htmlAttributes?.['aria-label'] === undefined && !ariaLabelledBy) {\n console.warn(\n 'The rich Tooltip is missing aria-label and Header. Please add one of them for accessibility.',\n );\n }\n\n return (\n <ConditionalWrap\n shouldWrap={context.isPortaled}\n wrap={(wrapChildren) => <FloatingPortal>{wrapChildren}</FloatingPortal>}\n >\n <FloatingFocusManager\n context={context.context}\n returnFocus={true}\n modal={false}\n initialFocus={0}\n closeOnFocusOut\n >\n <div\n ref={mergedRef}\n className={classes}\n style={{\n ...context.floatingStyles,\n ...style,\n }}\n {...restProps}\n {...context.getFloatingProps({\n ...htmlAttributes,\n 'aria-labelledby': ariaLabelledBy,\n })}\n >\n {children}\n </div>\n </FloatingFocusManager>\n </ConditionalWrap>\n );\n};\n\ntype TooltipHeaderProps = {\n /** Content displayed inside the header */\n children: React.ReactNode;\n /** @deprecated Use `typographyVariant` instead */\n passThroughProps?: Partial<React.ComponentPropsWithoutRef<typeof Typography>>;\n typographyVariant?: TypographyVariants;\n};\n\nconst TooltipHeader = ({\n children,\n passThroughProps,\n typographyVariant = 'subheading-medium',\n className,\n style,\n htmlAttributes,\n ref,\n ...restProps\n}: CommonProps<'span', TooltipHeaderProps>) => {\n const context = useTooltipContext();\n\n const classes = classNames('ndl-tooltip-header', className);\n\n useEffect(() => {\n if (Boolean(htmlAttributes?.id) === true) {\n context.setHeaderId?.(htmlAttributes?.id);\n }\n }, [context, htmlAttributes?.id]);\n\n if (!context.isOpen) {\n return null;\n }\n\n return (\n <Typography\n ref={ref}\n variant={typographyVariant}\n className={classes}\n style={style}\n htmlAttributes={{ ...htmlAttributes, id: context.headerId }}\n {...passThroughProps}\n {...restProps}\n >\n {children}\n </Typography>\n );\n};\n\nexport type TooltipBodyProps = {\n /** Content displayed inside the body */\n children: React.ReactNode;\n /** Additional props to pass to the Typography component */\n // TODO v5: Deprecate passThroughProps and use restProps instead\n passThroughProps?: Partial<React.ComponentPropsWithoutRef<typeof Typography>>;\n};\n\nconst TooltipBody = ({\n children,\n className,\n style,\n htmlAttributes,\n passThroughProps,\n ref,\n ...restProps\n}: CommonProps<'span', TooltipBodyProps>) => {\n const context = useTooltipContext();\n\n const classes = classNames('ndl-tooltip-body', className);\n if (!context.isOpen) {\n return null;\n }\n\n return (\n <Typography\n ref={ref}\n variant=\"body-medium\"\n className={classes}\n style={style}\n htmlAttributes={htmlAttributes}\n {...passThroughProps}\n {...restProps}\n >\n {children}\n </Typography>\n );\n};\n\ntype ToolTipActionsProps = {\n /** Content displayed inside the actions container */\n children: React.ReactNode;\n};\n\nconst Actions = ({\n children,\n className,\n style,\n htmlAttributes,\n ref,\n ...restProps\n}: CommonProps<'div', ToolTipActionsProps>) => {\n const context = useTooltipContext();\n const mergedRefs = useMergeRefs([context.refs.setFloating, ref]);\n\n if (!context.isOpen) {\n return null;\n }\n\n const classes = classNames('ndl-tooltip-actions', className);\n\n return (\n <div\n className={classes}\n ref={mergedRefs}\n style={style}\n {...restProps}\n {...htmlAttributes}\n >\n {children}\n </div>\n );\n};\n\nActions.displayName = 'Tooltip.Actions';\n\nconst Tooltip = Object.assign(TooltipComponent, {\n Actions: Actions,\n Body: TooltipBody,\n Content: TooltipContent,\n Header: TooltipHeader,\n Trigger: TooltipTrigger,\n});\n\nexport { Tooltip };\n"]}
|
|
1
|
+
{"version":3,"file":"Tooltip.js","sourceRoot":"","sources":["../../../src/tooltip/Tooltip.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAEL,oBAAoB,EACpB,cAAc,EAGd,YAAY,GACb,MAAM,oBAAoB,CAAC;AAC5B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGzC,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAE,UAAU,EAA2B,MAAM,eAAe,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AA4C9E,MAAM,gBAAgB,GAAG,CAAC,EACxB,QAAQ,EACR,UAAU,GAAG,KAAK,EAClB,IAAI,EACJ,aAAa,EACb,SAAS,EACT,MAAM,EACN,YAAY,EACZ,UAAU,EAAE,cAAc,EAC1B,gBAA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,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC,CAAC;IAEjE,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;QACpB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,OAAO,GAAG,UAAU,CAAC,qBAAqB,EAAE,SAAS,CAAC,CAAC;IAE7D,OAAO,CACL,4BACE,SAAS,EAAE,OAAO,EAClB,GAAG,EAAE,UAAU,EACf,KAAK,EAAE,KAAK,IACR,SAAS,EACT,cAAc,cAEjB,QAAQ,IACL,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,OAAO,CAAC,WAAW,GAAG,iBAAiB,CAAC;AAExC,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,gBAAgB,EAAE;IAC9C,OAAO,EAAE,OAAO;IAChB,IAAI,EAAE,WAAW;IACjB,OAAO,EAAE,cAAc;IACvB,MAAM,EAAE,aAAa;IACrB,OAAO,EAAE,cAAc;CACxB,CAAC,CAAC;AAEH,OAAO,EAAE,OAAO,EAAE,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\nimport {\n type AutoUpdateOptions,\n FloatingFocusManager,\n FloatingPortal,\n type Placement,\n type UseFloatingOptions,\n useMergeRefs,\n} from '@floating-ui/react';\nimport classNames from 'classnames';\nimport React, { useEffect } from 'react';\n\nimport { type CommonProps } from '../_common/types';\nimport { ConditionalWrap } from '../conditional-wrap';\nimport { useIsInsideDialog } from '../dialog/dialog-context';\nimport { useNeedleTheme } from '../theme';\nimport { Typography, type TypographyVariants } from '../typography';\nimport { TooltipContext, useTooltip, useTooltipContext } from './use-tooltip';\n\nexport type TooltipProps = {\n /** Content displayed inside the tooltip. Wraps `Tooltip.Trigger`, `Tooltip.Content`, and optional parts */\n children: React.ReactNode;\n /** Whether the tooltip is disabled */\n isDisabled?: boolean;\n /** Whether the tooltip should be open on first render */\n isInitialOpen?: boolean;\n /** Placement of the tooltip content relative to the trigger */\n placement?: Placement;\n /** Controls the open state . If omitted, the tooltip manages its own state */\n isOpen?: boolean;\n // TODO v5: deprecate this prop\n /**\n * Visual style of the tooltip content. `simple` renders plain text, `rich` renders a composable panel\n * @deprecated rich type will be removed in v5, use simple type instead.\n */\n type: 'simple' | 'rich';\n /** Whether the content is rendered in a portal. */\n isPortaled?: boolean;\n /** Callback fired when the open state changes, if omitted, the tooltip manages its own state using internal hooks */\n onOpenChange?: UseFloatingOptions['onOpenChange'];\n /** Positioning strategy of the tooltip. Defaults to `fixed` when inside a dialog, otherwise `absolute` */\n floatingStrategy?: 'absolute' | 'fixed';\n /** Hover open/close delays in milliseconds */\n hoverDelay?: {\n open: number;\n close: number;\n };\n /** Whether the tooltip should close when the reference element is clicked. Useful when the trigger moves after click. */\n shouldCloseOnReferenceClick?: boolean;\n autoUpdateOptions?: AutoUpdateOptions;\n // TODO v5: align followCursor with the Tippy.js convention: `true` should follow\n // the cursor continuously on both axes, with explicit 'horizontal' / 'vertical'\n // values for single-axis following (instead of deriving the axis from `placement`).\n /**\n * Whether the tooltip should be positioned at the mouse cursor. Only applies to 'simple' tooltips with mouse hover.\n * `true` follows the cursor continuously along one axis derived from `placement` (horizontal for top/bottom, vertical for left/right).\n * `'initial'` opens the tooltip at the cursor's position (both axes) and keeps it there, like the native `title` attribute; `placement` controls which side of that point the tooltip appears on.\n */\n followCursor?: boolean | 'initial';\n};\n\nconst TooltipComponent = ({\n children,\n isDisabled = false,\n type,\n isInitialOpen,\n placement,\n isOpen,\n onOpenChange,\n isPortaled: isPortaledProp,\n floatingStrategy: strategyProp,\n hoverDelay,\n shouldCloseOnReferenceClick,\n autoUpdateOptions,\n followCursor,\n}: TooltipProps) => {\n const isInsideDialog = useIsInsideDialog();\n const strategy = isInsideDialog ? 'fixed' : 'absolute';\n const isPortaled = !isInsideDialog;\n\n const tooltip = useTooltip({\n autoUpdateOptions,\n followCursor,\n hoverDelay,\n isDisabled,\n isInitialOpen,\n // if isDisabled is true tooltip will not open otherwise either controlled or uncontrolled depending on if isOpen is passed\n isOpen: isDisabled === true ? false : isOpen,\n isPortaled: isPortaledProp ?? isPortaled,\n onOpenChange,\n placement,\n shouldCloseOnReferenceClick,\n strategy: strategyProp ?? strategy,\n type,\n });\n\n return (\n <TooltipContext.Provider value={tooltip}>\n {children}\n </TooltipContext.Provider>\n );\n};\n\nTooltipComponent.displayName = 'Tooltip';\n\ntype TooltipTriggerProps = {\n /** Content displayed inside the trigger element */\n children: React.ReactNode;\n /** Whether the trigger element can be any element without an extra button wrapper. The child element will be cloned with the necessary trigger props and merged refs */\n hasButtonWrapper?: boolean;\n};\n\nconst TooltipTrigger = ({\n children,\n hasButtonWrapper = false,\n htmlAttributes,\n className,\n style,\n ref,\n ...restProps\n}: CommonProps<'button', TooltipTriggerProps>) => {\n const context = useTooltipContext();\n\n // Example from floating-ui\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n const childrenProps = (children as any).props;\n const mergedRefs = useMergeRefs([\n context.refs.setReference,\n ref,\n childrenProps?.ref,\n ]);\n\n const triggerClasses = classNames(\n {\n 'ndl-closed': !context.isOpen,\n 'ndl-open': context.isOpen,\n },\n 'ndl-tooltip-trigger',\n className,\n );\n\n // `hasButtonWrapper=true` allows the user to pass any element as the anchor\n if (hasButtonWrapper && React.isValidElement(children)) {\n const props: Record<string, unknown> = {\n className: triggerClasses,\n ...htmlAttributes,\n ...childrenProps,\n ref: mergedRefs,\n };\n\n return React.cloneElement(children, context.getReferenceProps(props));\n }\n\n return (\n <button\n type=\"button\"\n className={triggerClasses}\n style={style}\n ref={mergedRefs}\n {...context.getReferenceProps(htmlAttributes)}\n {...restProps}\n >\n {children}\n </button>\n );\n};\n\ntype TooltipContentProps = {\n /** Content displayed inside the tooltip */\n children: React.ReactNode;\n};\n\nconst TooltipContent = ({\n children,\n style,\n htmlAttributes,\n className,\n ref,\n ...restProps\n}: CommonProps<'div', TooltipContentProps>) => {\n const context = useTooltipContext();\n const mergedRef = useMergeRefs([context.refs.setFloating, ref]);\n const { themeClassName } = useNeedleTheme();\n\n const hasHeaderChild = React.useMemo(() => {\n if (context.type !== 'rich') {\n return false;\n }\n const childrenArray = React.Children.toArray(children);\n return childrenArray.some(\n (child) => React.isValidElement(child) && child.type === TooltipHeader,\n );\n }, [children, context.type]);\n\n if (!context.isOpen) {\n return null;\n }\n\n const classes = classNames('ndl-tooltip-content', themeClassName, className, {\n 'ndl-tooltip-content-rich': context.type === 'rich',\n 'ndl-tooltip-content-simple': context.type === 'simple',\n });\n\n if (context.type === 'simple') {\n return (\n <ConditionalWrap\n shouldWrap={context.isPortaled}\n wrap={(wrapChildren) => <FloatingPortal>{wrapChildren}</FloatingPortal>}\n >\n <div\n ref={mergedRef}\n className={classes}\n style={{\n ...context.floatingStyles,\n ...style,\n }}\n {...restProps}\n {...context.getFloatingProps(htmlAttributes)}\n >\n <Typography variant=\"body-medium\">{children}</Typography>\n </div>\n </ConditionalWrap>\n );\n }\n\n const ariaLabelledBy =\n htmlAttributes?.['aria-labelledby'] ??\n (hasHeaderChild ? context.headerId : undefined);\n\n if (htmlAttributes?.['aria-label'] === undefined && !ariaLabelledBy) {\n console.warn(\n 'The rich Tooltip is missing aria-label and Header. Please add one of them for accessibility.',\n );\n }\n\n return (\n <ConditionalWrap\n shouldWrap={context.isPortaled}\n wrap={(wrapChildren) => <FloatingPortal>{wrapChildren}</FloatingPortal>}\n >\n <FloatingFocusManager\n context={context.context}\n returnFocus={true}\n modal={false}\n initialFocus={0}\n closeOnFocusOut\n >\n <div\n ref={mergedRef}\n className={classes}\n style={{\n ...context.floatingStyles,\n ...style,\n }}\n {...restProps}\n {...context.getFloatingProps({\n ...htmlAttributes,\n 'aria-labelledby': ariaLabelledBy,\n })}\n >\n {children}\n </div>\n </FloatingFocusManager>\n </ConditionalWrap>\n );\n};\n\ntype TooltipHeaderProps = {\n /** Content displayed inside the header */\n children: React.ReactNode;\n /** @deprecated Use `typographyVariant` instead */\n passThroughProps?: Partial<React.ComponentPropsWithoutRef<typeof Typography>>;\n typographyVariant?: TypographyVariants;\n};\n\nconst TooltipHeader = ({\n children,\n passThroughProps,\n typographyVariant = 'subheading-medium',\n className,\n style,\n htmlAttributes,\n ref,\n ...restProps\n}: CommonProps<'span', TooltipHeaderProps>) => {\n const context = useTooltipContext();\n\n const classes = classNames('ndl-tooltip-header', className);\n\n useEffect(() => {\n if (Boolean(htmlAttributes?.id) === true) {\n context.setHeaderId?.(htmlAttributes?.id);\n }\n }, [context, htmlAttributes?.id]);\n\n if (!context.isOpen) {\n return null;\n }\n\n return (\n <Typography\n ref={ref}\n variant={typographyVariant}\n className={classes}\n style={style}\n htmlAttributes={{ ...htmlAttributes, id: context.headerId }}\n {...passThroughProps}\n {...restProps}\n >\n {children}\n </Typography>\n );\n};\n\nexport type TooltipBodyProps = {\n /** Content displayed inside the body */\n children: React.ReactNode;\n /** Additional props to pass to the Typography component */\n // TODO v5: Deprecate passThroughProps and use restProps instead\n passThroughProps?: Partial<React.ComponentPropsWithoutRef<typeof Typography>>;\n};\n\nconst TooltipBody = ({\n children,\n className,\n style,\n htmlAttributes,\n passThroughProps,\n ref,\n ...restProps\n}: CommonProps<'span', TooltipBodyProps>) => {\n const context = useTooltipContext();\n\n const classes = classNames('ndl-tooltip-body', className);\n if (!context.isOpen) {\n return null;\n }\n\n return (\n <Typography\n ref={ref}\n variant=\"body-medium\"\n className={classes}\n style={style}\n htmlAttributes={htmlAttributes}\n {...passThroughProps}\n {...restProps}\n >\n {children}\n </Typography>\n );\n};\n\ntype ToolTipActionsProps = {\n /** Content displayed inside the actions container */\n children: React.ReactNode;\n};\n\nconst Actions = ({\n children,\n className,\n style,\n htmlAttributes,\n ref,\n ...restProps\n}: CommonProps<'div', ToolTipActionsProps>) => {\n const context = useTooltipContext();\n const mergedRefs = useMergeRefs([context.refs.setFloating, ref]);\n\n if (!context.isOpen) {\n return null;\n }\n\n const classes = classNames('ndl-tooltip-actions', className);\n\n return (\n <div\n className={classes}\n ref={mergedRefs}\n style={style}\n {...restProps}\n {...htmlAttributes}\n >\n {children}\n </div>\n );\n};\n\nActions.displayName = 'Tooltip.Actions';\n\nconst Tooltip = Object.assign(TooltipComponent, {\n Actions: Actions,\n Body: TooltipBody,\n Content: TooltipContent,\n Header: TooltipHeader,\n Trigger: TooltipTrigger,\n});\n\nexport { Tooltip };\n"]}
|
|
@@ -33,7 +33,7 @@ const triggerStyle = {
|
|
|
33
33
|
width: '300px',
|
|
34
34
|
};
|
|
35
35
|
const Component = () => {
|
|
36
|
-
return (_jsxs("div", { style: { display: 'flex', gap: '24px' }, children: [_jsxs(Tooltip, { type: "simple", followCursor: true, placement: "bottom", children: [_jsx(Tooltip.Trigger, { children: _jsx("div", { style: triggerStyle, children: "
|
|
36
|
+
return (_jsxs("div", { style: { display: 'flex', gap: '24px' }, children: [_jsxs(Tooltip, { type: "simple", followCursor: true, placement: "bottom", hoverDelay: { close: 0, open: 500 }, children: [_jsx(Tooltip.Trigger, { children: _jsx("div", { style: triggerStyle, children: "followCursor with placement=\"bottom\": follows on the x-axis" }) }), _jsx(Tooltip.Content, { children: "Follows cursor along the x-axis" })] }), _jsxs(Tooltip, { type: "simple", followCursor: true, placement: "right", hoverDelay: { close: 0, open: 500 }, children: [_jsx(Tooltip.Trigger, { children: _jsx("div", { style: triggerStyle, children: "followCursor with placement=\"right\": follows on the y-axis" }) }), _jsx(Tooltip.Content, { children: "Follows cursor along the y-axis" })] }), _jsxs(Tooltip, { type: "simple", followCursor: "initial", placement: "bottom", hoverDelay: { close: 0, open: 500 }, children: [_jsx(Tooltip.Trigger, { children: _jsx("div", { style: triggerStyle, children: "followCursor=\"initial\": opens at the cursor point and stays there" }) }), _jsx(Tooltip.Content, { children: "Pinned at the cursor position it opened at" })] })] }));
|
|
37
37
|
};
|
|
38
38
|
export default Component;
|
|
39
39
|
//# sourceMappingURL=tooltip-follow-cursor.story.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tooltip-follow-cursor.story.js","sourceRoot":"","sources":["../../../../src/tooltip/stories/tooltip-follow-cursor.story.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,yCAAyC,CAAC;AAEjD,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C,MAAM,YAAY,GAAwB;IACxC,UAAU,EAAE,QAAQ;IACpB,eAAe,EAAE,oCAAoC;IACrD,YAAY,EAAE,KAAK;IACnB,KAAK,EAAE,yCAAyC;IAChD,OAAO,EAAE,MAAM;IACf,MAAM,EAAE,OAAO;IACf,cAAc,EAAE,QAAQ;IACxB,OAAO,EAAE,KAAK;IACd,KAAK,EAAE,OAAO;CACf,CAAC;AAEF,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,OAAO,CACL,eAAK,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,aAC1C,MAAC,OAAO,
|
|
1
|
+
{"version":3,"file":"tooltip-follow-cursor.story.js","sourceRoot":"","sources":["../../../../src/tooltip/stories/tooltip-follow-cursor.story.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,yCAAyC,CAAC;AAEjD,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C,MAAM,YAAY,GAAwB;IACxC,UAAU,EAAE,QAAQ;IACpB,eAAe,EAAE,oCAAoC;IACrD,YAAY,EAAE,KAAK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is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nimport '@neo4j-ndl/base/lib/neo4j-ds-styles.css';\n\nimport { Tooltip } from '@neo4j-ndl/react';\n\nconst triggerStyle: React.CSSProperties = {\n alignItems: 'center',\n backgroundColor: 'var(--theme-color-primary-bg-weak)',\n borderRadius: '4px',\n color: 'var(--theme-color-primary-text-inverse)',\n display: 'flex',\n height: '300px',\n justifyContent: 'center',\n padding: '8px',\n width: '300px',\n};\n\nconst Component = () => {\n return (\n <div style={{ display: 'flex', gap: '24px' }}>\n <Tooltip\n type=\"simple\"\n followCursor\n placement=\"bottom\"\n hoverDelay={{ close: 0, open: 500 }}\n >\n <Tooltip.Trigger>\n <div style={triggerStyle}>\n followCursor with placement="bottom": follows on the\n x-axis\n </div>\n </Tooltip.Trigger>\n <Tooltip.Content>Follows cursor along the x-axis</Tooltip.Content>\n </Tooltip>\n\n <Tooltip\n type=\"simple\"\n followCursor\n placement=\"right\"\n hoverDelay={{ close: 0, open: 500 }}\n >\n <Tooltip.Trigger>\n <div style={triggerStyle}>\n followCursor with placement="right": follows on the y-axis\n </div>\n </Tooltip.Trigger>\n <Tooltip.Content>Follows cursor along the y-axis</Tooltip.Content>\n </Tooltip>\n\n <Tooltip\n type=\"simple\"\n followCursor=\"initial\"\n placement=\"bottom\"\n hoverDelay={{ close: 0, open: 500 }}\n >\n <Tooltip.Trigger>\n <div style={triggerStyle}>\n followCursor="initial": opens at the cursor point and\n stays there\n </div>\n </Tooltip.Trigger>\n <Tooltip.Content>\n Pinned at the cursor position it opened at\n </Tooltip.Content>\n </Tooltip>\n </div>\n );\n};\n\nexport default Component;\n"]}
|
|
@@ -19,13 +19,18 @@
|
|
|
19
19
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
20
20
|
*/
|
|
21
21
|
import { autoUpdate, flip, offset, safePolygon, shift, useClick, useClientPoint, useDismiss, useFloating, useFocus, useHover, useInteractions, useRole, } from '@floating-ui/react';
|
|
22
|
-
import { createContext, useContext, useId, useMemo, useState } from 'react';
|
|
22
|
+
import { createContext, useContext, useId, useMemo, useRef, useState, } from 'react';
|
|
23
23
|
export function useTooltip({ isInitialOpen = false, placement = 'top', isOpen: controlledOpen, onOpenChange: setControlledOpen, type = 'simple', isPortaled = true, strategy = 'absolute', hoverDelay = undefined, shouldCloseOnReferenceClick = false, autoUpdateOptions, isDisabled = false, followCursor = false, } = {}) {
|
|
24
|
+
var _a, _b;
|
|
24
25
|
const id = useId();
|
|
25
26
|
const [headerId, setHeaderId] = useState(id);
|
|
26
27
|
const [isUncontrolledOpen, setIsUncontrolledOpen] = useState(isInitialOpen);
|
|
27
28
|
const isOpen = controlledOpen !== null && controlledOpen !== void 0 ? controlledOpen : isUncontrolledOpen;
|
|
28
29
|
const setOpen = setControlledOpen !== null && setControlledOpen !== void 0 ? setControlledOpen : setIsUncontrolledOpen;
|
|
30
|
+
// For followCursor='initial': the latest pointer position over the trigger,
|
|
31
|
+
// and a snapshot of it frozen at the moment the tooltip opens.
|
|
32
|
+
const pointerPositionRef = useRef(null);
|
|
33
|
+
const [initialCursorPoint, setInitialCursorPoint] = useState(null);
|
|
29
34
|
const data = useFloating({
|
|
30
35
|
middleware: [
|
|
31
36
|
offset(5),
|
|
@@ -36,7 +41,15 @@ export function useTooltip({ isInitialOpen = false, placement = 'top', isOpen: c
|
|
|
36
41
|
}),
|
|
37
42
|
shift({ padding: 5 }),
|
|
38
43
|
],
|
|
39
|
-
onOpenChange
|
|
44
|
+
onOpenChange(open, event, reason) {
|
|
45
|
+
if (followCursor === 'initial') {
|
|
46
|
+
// Only anchor to the cursor for pointer-driven opens; keyboard focus
|
|
47
|
+
// opens fall back to positioning relative to the trigger element.
|
|
48
|
+
const isPointerDrivenOpen = event !== undefined && 'clientX' in event;
|
|
49
|
+
setInitialCursorPoint(open && isPointerDrivenOpen ? pointerPositionRef.current : null);
|
|
50
|
+
}
|
|
51
|
+
setOpen(open, event, reason);
|
|
52
|
+
},
|
|
40
53
|
open: isOpen,
|
|
41
54
|
placement,
|
|
42
55
|
strategy,
|
|
@@ -68,10 +81,28 @@ export function useTooltip({ isInitialOpen = false, placement = 'top', isOpen: c
|
|
|
68
81
|
role: type === 'simple' ? 'tooltip' : 'dialog',
|
|
69
82
|
});
|
|
70
83
|
const followAxis = placement.startsWith('left') || placement.startsWith('right') ? 'y' : 'x';
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
84
|
+
const isInitialFollowCursor = followCursor === 'initial';
|
|
85
|
+
const clientPoint = useClientPoint(context, Object.assign({
|
|
86
|
+
// 'initial' anchors to the exact cursor point (both axes); `true` follows
|
|
87
|
+
// continuously along the axis derived from `placement`.
|
|
88
|
+
axis: isInitialFollowCursor ? 'both' : followAxis, enabled: followCursor !== false && type === 'simple' && !isDisabled }, (isInitialFollowCursor && {
|
|
89
|
+
x: (_a = initialCursorPoint === null || initialCursorPoint === void 0 ? void 0 : initialCursorPoint.x) !== null && _a !== void 0 ? _a : null,
|
|
90
|
+
y: (_b = initialCursorPoint === null || initialCursorPoint === void 0 ? void 0 : initialCursorPoint.y) !== null && _b !== void 0 ? _b : null,
|
|
91
|
+
})));
|
|
92
|
+
const initialCursorTracking = useMemo(() => {
|
|
93
|
+
if (!isInitialFollowCursor) {
|
|
94
|
+
return {};
|
|
95
|
+
}
|
|
96
|
+
const capturePointerPosition = (event) => {
|
|
97
|
+
pointerPositionRef.current = { x: event.clientX, y: event.clientY };
|
|
98
|
+
};
|
|
99
|
+
return {
|
|
100
|
+
reference: {
|
|
101
|
+
onPointerEnter: capturePointerPosition,
|
|
102
|
+
onPointerMove: capturePointerPosition,
|
|
103
|
+
},
|
|
104
|
+
};
|
|
105
|
+
}, [isInitialFollowCursor]);
|
|
75
106
|
const interactions = useInteractions([
|
|
76
107
|
hover,
|
|
77
108
|
focus,
|
|
@@ -79,6 +110,7 @@ export function useTooltip({ isInitialOpen = false, placement = 'top', isOpen: c
|
|
|
79
110
|
role,
|
|
80
111
|
click,
|
|
81
112
|
clientPoint,
|
|
113
|
+
initialCursorTracking,
|
|
82
114
|
]);
|
|
83
115
|
return useMemo(() => (Object.assign(Object.assign({ headerId: type === 'rich' ? headerId : undefined, isOpen,
|
|
84
116
|
isPortaled, setHeaderId: type === 'rich' ? setHeaderId : undefined, setOpen,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-tooltip.js","sourceRoot":"","sources":["../../../src/tooltip/use-tooltip.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EACL,UAAU,EAEV,IAAI,EACJ,MAAM,EAGN,WAAW,EACX,KAAK,EACL,QAAQ,EACR,cAAc,EACd,UAAU,EACV,WAAW,EAGX,QAAQ,EACR,QAAQ,EACR,eAAe,EAEf,OAAO,GACR,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAuB5E,MAAM,UAAU,UAAU,CAAC,EACzB,aAAa,GAAG,KAAK,EACrB,SAAS,GAAG,KAAK,EACjB,MAAM,EAAE,cAAc,EACtB,YAAY,EAAE,iBAAiB,EAC/B,IAAI,GAAG,QAAQ,EACf,UAAU,GAAG,IAAI,EACjB,QAAQ,GAAG,UAAU,EACrB,UAAU,GAAG,SAAS,EACtB,2BAA2B,GAAG,KAAK,EACnC,iBAAiB,EACjB,UAAU,GAAG,KAAK,EAClB,YAAY,GAAG,KAAK,MACF,EAAE;IASpB,MAAM,EAA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,EAAE,UAAU,EAAE,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,CAAC,CAClE,CAAC;AACJ,CAAC;AAID,MAAM,CAAC,MAAM,cAAc,GAAG,aAAa,CAAc,IAAI,CAAC,CAAC;AAE/D,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAkC,EAAE;IACnE,MAAM,OAAO,GAAG,UAAU,CAAC,cAAc,CAAC,CAAC;IAE3C,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;QACrB,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;IACvE,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\nimport {\n autoUpdate,\n type AutoUpdateOptions,\n flip,\n offset,\n type Placement,\n type ReferenceType,\n safePolygon,\n shift,\n useClick,\n useClientPoint,\n useDismiss,\n useFloating,\n type UseFloatingOptions,\n type UseFloatingReturn,\n useFocus,\n useHover,\n useInteractions,\n type UseInteractionsReturn,\n useRole,\n} from '@floating-ui/react';\nimport { createContext, useContext, useId, useMemo, useState } from 'react';\n\nexport interface TooltipOptions {\n isInitialOpen?: boolean;\n placement?: Placement;\n isOpen?: boolean;\n onOpenChange?: UseFloatingOptions['onOpenChange'];\n type?: 'simple' | 'rich';\n isPortaled?: boolean;\n strategy?: 'fixed' | 'absolute';\n hoverDelay?: {\n open: number;\n close: number;\n };\n shouldCloseOnReferenceClick?: boolean;\n autoUpdateOptions?: AutoUpdateOptions;\n isDisabled?: boolean;\n // TODO v5: rename this prop to follow lint rule\n /** Whether the tooltip should follow the mouse cursor. Only applies to 'simple' tooltips with mouse hover. */\n // eslint-disable-next-line @typescript-eslint/naming-convention\n followCursor?: boolean;\n}\n\nexport function useTooltip({\n isInitialOpen = false,\n placement = 'top',\n isOpen: controlledOpen,\n onOpenChange: setControlledOpen,\n type = 'simple',\n isPortaled = true,\n strategy = 'absolute',\n hoverDelay = undefined,\n shouldCloseOnReferenceClick = false,\n autoUpdateOptions,\n isDisabled = false,\n followCursor = false,\n}: TooltipOptions = {}): {\n headerId?: string;\n setHeaderId?: (id: string | undefined) => void;\n isOpen: boolean;\n setOpen: (open: boolean) => void;\n type: 'simple' | 'rich';\n isPortaled: boolean;\n} & UseInteractionsReturn &\n UseFloatingReturn<ReferenceType> {\n const id = useId();\n const [headerId, setHeaderId] = useState<string | undefined>(id);\n const [isUncontrolledOpen, setIsUncontrolledOpen] = useState(isInitialOpen);\n const isOpen = controlledOpen ?? isUncontrolledOpen;\n const setOpen = setControlledOpen ?? setIsUncontrolledOpen;\n\n const data = useFloating({\n middleware: [\n offset(5),\n flip({\n crossAxis: placement.includes('-'),\n fallbackAxisSideDirection: 'start',\n padding: 5,\n }),\n shift({ padding: 5 }),\n ],\n onOpenChange: setOpen,\n open: isOpen,\n placement,\n strategy,\n whileElementsMounted(referenceEl, floatingEl, update) {\n const cleanup = autoUpdate(referenceEl, floatingEl, update, {\n ...autoUpdateOptions,\n });\n return cleanup;\n },\n });\n\n const context = data.context;\n\n const hover = useHover(context, {\n delay: hoverDelay,\n enabled: type === 'simple' && !isDisabled,\n handleClose: safePolygon(),\n move: false,\n });\n const click = useClick(context, {\n enabled: type === 'rich' && !isDisabled,\n });\n const focus = useFocus(context, {\n enabled: type === 'simple' && !isDisabled,\n visibleOnly: true,\n });\n const dismiss = useDismiss(context, {\n escapeKey: true,\n outsidePress: true,\n referencePress: shouldCloseOnReferenceClick,\n });\n const role = useRole(context, {\n role: type === 'simple' ? 'tooltip' : 'dialog',\n });\n const followAxis =\n placement.startsWith('left') || placement.startsWith('right') ? 'y' : 'x';\n const clientPoint = useClientPoint(context, {\n axis: followAxis,\n enabled: followCursor && type === 'simple' && !isDisabled,\n });\n\n const interactions = useInteractions([\n hover,\n focus,\n dismiss,\n role,\n click,\n clientPoint,\n ]);\n\n return useMemo(\n () => ({\n headerId: type === 'rich' ? headerId : undefined,\n isOpen,\n isPortaled,\n setHeaderId: type === 'rich' ? setHeaderId : undefined,\n setOpen,\n type,\n ...interactions,\n ...data,\n }),\n [headerId, isOpen, isPortaled, setOpen, type, interactions, data],\n );\n}\n\ntype ContextType = ReturnType<typeof useTooltip> | null;\n\nexport const TooltipContext = createContext<ContextType>(null);\n\nexport const useTooltipContext = (): ReturnType<typeof useTooltip> => {\n const context = useContext(TooltipContext);\n\n if (context === null) {\n throw new Error('Tooltip components must be wrapped in <Tooltip />');\n }\n\n return context;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"use-tooltip.js","sourceRoot":"","sources":["../../../src/tooltip/use-tooltip.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EACL,UAAU,EAGV,IAAI,EACJ,MAAM,EAGN,WAAW,EACX,KAAK,EACL,QAAQ,EACR,cAAc,EACd,UAAU,EACV,WAAW,EAGX,QAAQ,EACR,QAAQ,EACR,eAAe,EAEf,OAAO,GACR,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,aAAa,EAEb,UAAU,EACV,KAAK,EACL,OAAO,EACP,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAC;AA4Bf,MAAM,UAAU,UAAU,CAAC,EACzB,aAAa,GAAG,KAAK,EACrB,SAAS,GAAG,KAAK,EACjB,MAAM,EAAE,cAAc,EACtB,YAAY,EAAE,iBAAiB,EAC/B,IAAI,GAAG,QAAQ,EACf,UAAU,GAAG,IAAI,EACjB,Q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AAO,CACZ,GAAG,EAAE,CAAC,+BACJ,QAAQ,EAAE,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,EAChD,MAAM;QACN,UAAU,EACV,WAAW,EAAE,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,EACtD,OAAO;QACP,IAAI,IACD,YAAY,GACZ,IAAI,EACP,EACF,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,CAAC,CAClE,CAAC;AACJ,CAAC;AAID,MAAM,CAAC,MAAM,cAAc,GAAG,aAAa,CAAc,IAAI,CAAC,CAAC;AAE/D,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAkC,EAAE;IACnE,MAAM,OAAO,GAAG,UAAU,CAAC,cAAc,CAAC,CAAC;IAE3C,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;QACrB,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;IACvE,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\nimport {\n autoUpdate,\n type AutoUpdateOptions,\n type ElementProps,\n flip,\n offset,\n type Placement,\n type ReferenceType,\n safePolygon,\n shift,\n useClick,\n useClientPoint,\n useDismiss,\n useFloating,\n type UseFloatingOptions,\n type UseFloatingReturn,\n useFocus,\n useHover,\n useInteractions,\n type UseInteractionsReturn,\n useRole,\n} from '@floating-ui/react';\nimport {\n createContext,\n type PointerEvent as ReactPointerEvent,\n useContext,\n useId,\n useMemo,\n useRef,\n useState,\n} from 'react';\n\nexport interface TooltipOptions {\n isInitialOpen?: boolean;\n placement?: Placement;\n isOpen?: boolean;\n onOpenChange?: UseFloatingOptions['onOpenChange'];\n type?: 'simple' | 'rich';\n isPortaled?: boolean;\n strategy?: 'fixed' | 'absolute';\n hoverDelay?: {\n open: number;\n close: number;\n };\n shouldCloseOnReferenceClick?: boolean;\n autoUpdateOptions?: AutoUpdateOptions;\n isDisabled?: boolean;\n // TODO v5: align followCursor with the Tippy.js convention: `true` should follow\n // the cursor continuously on both axes, with explicit 'horizontal' / 'vertical'\n // values for single-axis following (instead of deriving the axis from `placement`).\n /**\n * Whether the tooltip should be positioned at the mouse cursor. Only applies to 'simple' tooltips with mouse hover.\n * `true` follows the cursor continuously along one axis derived from `placement` (horizontal for top/bottom, vertical for left/right).\n * `'initial'` opens the tooltip at the cursor's position (both axes) and keeps it there, like the native `title` attribute; `placement` controls which side of that point the tooltip appears on.\n */\n followCursor?: boolean | 'initial';\n}\n\nexport function useTooltip({\n isInitialOpen = false,\n placement = 'top',\n isOpen: controlledOpen,\n onOpenChange: setControlledOpen,\n type = 'simple',\n isPortaled = true,\n strategy = 'absolute',\n hoverDelay = undefined,\n shouldCloseOnReferenceClick = false,\n autoUpdateOptions,\n isDisabled = false,\n followCursor = false,\n}: TooltipOptions = {}): {\n headerId?: string;\n setHeaderId?: (id: string | undefined) => void;\n isOpen: boolean;\n setOpen: (open: boolean) => void;\n type: 'simple' | 'rich';\n isPortaled: boolean;\n} & UseInteractionsReturn &\n UseFloatingReturn<ReferenceType> {\n const id = useId();\n const [headerId, setHeaderId] = useState<string | undefined>(id);\n const [isUncontrolledOpen, setIsUncontrolledOpen] = useState(isInitialOpen);\n const isOpen = controlledOpen ?? isUncontrolledOpen;\n const setOpen: NonNullable<UseFloatingOptions['onOpenChange']> =\n setControlledOpen ?? setIsUncontrolledOpen;\n\n // For followCursor='initial': the latest pointer position over the trigger,\n // and a snapshot of it frozen at the moment the tooltip opens.\n const pointerPositionRef = useRef<{ x: number; y: number } | null>(null);\n const [initialCursorPoint, setInitialCursorPoint] = useState<{\n x: number;\n y: number;\n } | null>(null);\n\n const data = useFloating({\n middleware: [\n offset(5),\n flip({\n crossAxis: placement.includes('-'),\n fallbackAxisSideDirection: 'start',\n padding: 5,\n }),\n shift({ padding: 5 }),\n ],\n onOpenChange(open, event, reason) {\n if (followCursor === 'initial') {\n // Only anchor to the cursor for pointer-driven opens; keyboard focus\n // opens fall back to positioning relative to the trigger element.\n const isPointerDrivenOpen = event !== undefined && 'clientX' in event;\n setInitialCursorPoint(\n open && isPointerDrivenOpen ? pointerPositionRef.current : null,\n );\n }\n setOpen(open, event, reason);\n },\n open: isOpen,\n placement,\n strategy,\n whileElementsMounted(referenceEl, floatingEl, update) {\n const cleanup = autoUpdate(referenceEl, floatingEl, update, {\n ...autoUpdateOptions,\n });\n return cleanup;\n },\n });\n\n const context = data.context;\n\n const hover = useHover(context, {\n delay: hoverDelay,\n enabled: type === 'simple' && !isDisabled,\n handleClose: safePolygon(),\n move: false,\n });\n const click = useClick(context, {\n enabled: type === 'rich' && !isDisabled,\n });\n const focus = useFocus(context, {\n enabled: type === 'simple' && !isDisabled,\n visibleOnly: true,\n });\n const dismiss = useDismiss(context, {\n escapeKey: true,\n outsidePress: true,\n referencePress: shouldCloseOnReferenceClick,\n });\n const role = useRole(context, {\n role: type === 'simple' ? 'tooltip' : 'dialog',\n });\n const followAxis =\n placement.startsWith('left') || placement.startsWith('right') ? 'y' : 'x';\n const isInitialFollowCursor = followCursor === 'initial';\n const clientPoint = useClientPoint(context, {\n // 'initial' anchors to the exact cursor point (both axes); `true` follows\n // continuously along the axis derived from `placement`.\n axis: isInitialFollowCursor ? 'both' : followAxis,\n enabled: followCursor !== false && type === 'simple' && !isDisabled,\n // Explicit coordinates lock the position: useClientPoint stops tracking\n // pointer movement when they are provided.\n ...(isInitialFollowCursor && {\n x: initialCursorPoint?.x ?? null,\n y: initialCursorPoint?.y ?? null,\n }),\n });\n\n const initialCursorTracking = useMemo<ElementProps>(() => {\n if (!isInitialFollowCursor) {\n return {};\n }\n const capturePointerPosition = (event: ReactPointerEvent) => {\n pointerPositionRef.current = { x: event.clientX, y: event.clientY };\n };\n return {\n reference: {\n onPointerEnter: capturePointerPosition,\n onPointerMove: capturePointerPosition,\n },\n };\n }, [isInitialFollowCursor]);\n\n const interactions = useInteractions([\n hover,\n focus,\n dismiss,\n role,\n click,\n clientPoint,\n initialCursorTracking,\n ]);\n\n return useMemo(\n () => ({\n headerId: type === 'rich' ? headerId : undefined,\n isOpen,\n isPortaled,\n setHeaderId: type === 'rich' ? setHeaderId : undefined,\n setOpen,\n type,\n ...interactions,\n ...data,\n }),\n [headerId, isOpen, isPortaled, setOpen, type, interactions, data],\n );\n}\n\ntype ContextType = ReturnType<typeof useTooltip> | null;\n\nexport const TooltipContext = createContext<ContextType>(null);\n\nexport const useTooltipContext = (): ReturnType<typeof useTooltip> => {\n const context = useContext(TooltipContext);\n\n if (context === null) {\n throw new Error('Tooltip components must be wrapped in <Tooltip />');\n }\n\n return context;\n};\n"]}
|
|
@@ -52,8 +52,12 @@ export type TooltipProps = {
|
|
|
52
52
|
/** Whether the tooltip should close when the reference element is clicked. Useful when the trigger moves after click. */
|
|
53
53
|
shouldCloseOnReferenceClick?: boolean;
|
|
54
54
|
autoUpdateOptions?: AutoUpdateOptions;
|
|
55
|
-
/**
|
|
56
|
-
|
|
55
|
+
/**
|
|
56
|
+
* Whether the tooltip should be positioned at the mouse cursor. Only applies to 'simple' tooltips with mouse hover.
|
|
57
|
+
* `true` follows the cursor continuously along one axis derived from `placement` (horizontal for top/bottom, vertical for left/right).
|
|
58
|
+
* `'initial'` opens the tooltip at the cursor's position (both axes) and keeps it there, like the native `title` attribute; `placement` controls which side of that point the tooltip appears on.
|
|
59
|
+
*/
|
|
60
|
+
followCursor?: boolean | 'initial';
|
|
57
61
|
};
|
|
58
62
|
type TooltipTriggerProps = {
|
|
59
63
|
/** Content displayed inside the trigger element */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tooltip.d.ts","sourceRoot":"","sources":["../../../src/tooltip/Tooltip.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EACL,KAAK,iBAAiB,EAGtB,KAAK,SAAS,EACd,KAAK,kBAAkB,EAExB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,KAAoB,MAAM,OAAO,CAAC;AAEzC,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAIpD,OAAO,EAAE,UAAU,EAAE,KAAK,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAGpE,MAAM,MAAM,YAAY,GAAG;IACzB,2GAA2G;IAC3G,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,sCAAsC;IACtC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,0DAA0D;IAC1D,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,+DAA+D;IAC/D,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,8EAA8E;IAC9E,MAAM,CAAC,EAAE,OAAO,CAAC;IAEjB;;;OAGG;IACH,IAAI,EAAE,QAAQ,GAAG,MAAM,CAAC;IACxB,oDAAoD;IACpD,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,qHAAqH;IACrH,YAAY,CAAC,EAAE,kBAAkB,CAAC,cAAc,CAAC,CAAC;IAClD,0GAA0G;IAC1G,gBAAgB,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC;IACxC,8CAA8C;IAC9C,UAAU,CAAC,EAAE;QACX,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;IACF,yHAAyH;IACzH,2BAA2B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-
{"version":3,"file":"tooltip-follow-cursor.story.d.ts","sourceRoot":"","sources":["../../../../src/tooltip/stories/tooltip-follow-cursor.story.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,yCAAyC,CAAC;AAgBjD,QAAA,MAAM,SAAS,+
|
|
1
|
+
{"version":3,"file":"tooltip-follow-cursor.story.d.ts","sourceRoot":"","sources":["../../../../src/tooltip/stories/tooltip-follow-cursor.story.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,yCAAyC,CAAC;AAgBjD,QAAA,MAAM,SAAS,+CAkDd,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -34,8 +34,12 @@ export interface TooltipOptions {
|
|
|
34
34
|
shouldCloseOnReferenceClick?: boolean;
|
|
35
35
|
autoUpdateOptions?: AutoUpdateOptions;
|
|
36
36
|
isDisabled?: boolean;
|
|
37
|
-
/**
|
|
38
|
-
|
|
37
|
+
/**
|
|
38
|
+
* Whether the tooltip should be positioned at the mouse cursor. Only applies to 'simple' tooltips with mouse hover.
|
|
39
|
+
* `true` follows the cursor continuously along one axis derived from `placement` (horizontal for top/bottom, vertical for left/right).
|
|
40
|
+
* `'initial'` opens the tooltip at the cursor's position (both axes) and keeps it there, like the native `title` attribute; `placement` controls which side of that point the tooltip appears on.
|
|
41
|
+
*/
|
|
42
|
+
followCursor?: boolean | 'initial';
|
|
39
43
|
}
|
|
40
44
|
export declare function useTooltip({ isInitialOpen, placement, isOpen: controlledOpen, onOpenChange: setControlledOpen, type, isPortaled, strategy, hoverDelay, shouldCloseOnReferenceClick, autoUpdateOptions, isDisabled, followCursor, }?: TooltipOptions): {
|
|
41
45
|
headerId?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-tooltip.d.ts","sourceRoot":"","sources":["../../../src/tooltip/use-tooltip.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmB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AE,MAAM,GAAG,SAAS,KAAK,IAAI,CAAC;IAC/C,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACjC,IAAI,EAAE,QAAQ,GAAG,MAAM,CAAC;IACxB,UAAU,EAAE,OAAO,CAAC;CACrB,GAAG,qBAAqB,GACvB,iBAAiB,CAAC,aAAa,CAAC,CA6HjC;AAED,KAAK,WAAW,GAAG,UAAU,CAAC,OAAO,UAAU,CAAC,GAAG,IAAI,CAAC;AAExD,eAAO,MAAM,cAAc,sCAAmC,CAAC;AAE/D,eAAO,MAAM,iBAAiB,QAAO,UAAU,CAAC,OAAO,UAAU,CAQhE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@neo4j-ndl/react",
|
|
3
|
-
"version": "4.18.
|
|
3
|
+
"version": "4.18.13",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"description": "React implementation of Neo4j Design System",
|
|
6
6
|
"keywords": [
|
|
@@ -399,7 +399,7 @@
|
|
|
399
399
|
"@tanstack/react-table": "8.21.3",
|
|
400
400
|
"react": ">=19.0.0",
|
|
401
401
|
"react-dom": ">=19.0.0",
|
|
402
|
-
"@neo4j-ndl/base": "^4.17.
|
|
402
|
+
"@neo4j-ndl/base": "^4.17.7"
|
|
403
403
|
},
|
|
404
404
|
"dependencies": {
|
|
405
405
|
"@dnd-kit/core": "6.3.1",
|
|
@@ -11,7 +11,7 @@ Import: `import { Tooltip } from '@neo4j-ndl/react'`
|
|
|
11
11
|
| `autoUpdateOptions` | `AutoUpdateOptions` | | | |
|
|
12
12
|
| `children` | `ReactNode` | ✅ | | Content displayed inside the tooltip. Wraps `Tooltip.Trigger`, `Tooltip.Content`, and optional parts |
|
|
13
13
|
| `floatingStrategy` | `'absolute' \| 'fixed'` | | | Positioning strategy of the tooltip. Defaults to `fixed` when inside a dialog, otherwise `absolute` |
|
|
14
|
-
| `followCursor` | `boolean` | | | Whether the tooltip should
|
|
14
|
+
| `followCursor` | `boolean \| "initial"` | | | Whether the tooltip should be positioned at the mouse cursor. Only applies to 'simple' tooltips with mouse hover. `true` follows the cursor continuously along one axis derived from `placement` (horizontal for top/bottom, vertical for left/right). `'initial'` opens the tooltip at the cursor's position (both axes) and keeps it there, like the native `title` attribute; `placement` controls which side of that point the tooltip appears on. |
|
|
15
15
|
| `hoverDelay` | `{ open: number; close: number; }` | | | Hover open/close delays in milliseconds |
|
|
16
16
|
| `isDisabled` | `boolean` | | `false` | Whether the tooltip is disabled |
|
|
17
17
|
| `isInitialOpen` | `boolean` | | | Whether the tooltip should be open on first render |
|
|
@@ -207,18 +207,50 @@ const triggerStyle: React.CSSProperties = {
|
|
|
207
207
|
const Component = () => {
|
|
208
208
|
return (
|
|
209
209
|
<div style={{ display: 'flex', gap: '24px' }}>
|
|
210
|
-
<Tooltip
|
|
210
|
+
<Tooltip
|
|
211
|
+
type="simple"
|
|
212
|
+
followCursor
|
|
213
|
+
placement="bottom"
|
|
214
|
+
hoverDelay={{ close: 0, open: 500 }}
|
|
215
|
+
>
|
|
211
216
|
<Tooltip.Trigger>
|
|
212
|
-
<div style={triggerStyle}>
|
|
217
|
+
<div style={triggerStyle}>
|
|
218
|
+
followCursor with placement="bottom": follows on the
|
|
219
|
+
x-axis
|
|
220
|
+
</div>
|
|
213
221
|
</Tooltip.Trigger>
|
|
214
|
-
<Tooltip.Content>Follows cursor along x-axis</Tooltip.Content>
|
|
222
|
+
<Tooltip.Content>Follows cursor along the x-axis</Tooltip.Content>
|
|
215
223
|
</Tooltip>
|
|
216
224
|
|
|
217
|
-
<Tooltip
|
|
225
|
+
<Tooltip
|
|
226
|
+
type="simple"
|
|
227
|
+
followCursor
|
|
228
|
+
placement="right"
|
|
229
|
+
hoverDelay={{ close: 0, open: 500 }}
|
|
230
|
+
>
|
|
218
231
|
<Tooltip.Trigger>
|
|
219
|
-
<div style={triggerStyle}>
|
|
232
|
+
<div style={triggerStyle}>
|
|
233
|
+
followCursor with placement="right": follows on the y-axis
|
|
234
|
+
</div>
|
|
220
235
|
</Tooltip.Trigger>
|
|
221
|
-
<Tooltip.Content>Follows cursor along y-axis</Tooltip.Content>
|
|
236
|
+
<Tooltip.Content>Follows cursor along the y-axis</Tooltip.Content>
|
|
237
|
+
</Tooltip>
|
|
238
|
+
|
|
239
|
+
<Tooltip
|
|
240
|
+
type="simple"
|
|
241
|
+
followCursor="initial"
|
|
242
|
+
placement="bottom"
|
|
243
|
+
hoverDelay={{ close: 0, open: 500 }}
|
|
244
|
+
>
|
|
245
|
+
<Tooltip.Trigger>
|
|
246
|
+
<div style={triggerStyle}>
|
|
247
|
+
followCursor="initial": opens at the cursor point and
|
|
248
|
+
stays there
|
|
249
|
+
</div>
|
|
250
|
+
</Tooltip.Trigger>
|
|
251
|
+
<Tooltip.Content>
|
|
252
|
+
Pinned at the cursor position it opened at
|
|
253
|
+
</Tooltip.Content>
|
|
222
254
|
</Tooltip>
|
|
223
255
|
</div>
|
|
224
256
|
);
|