@neo4j-ndl/react 5.7.0 → 6.0.0-alpha.0.d77a467

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.
Files changed (93) hide show
  1. package/lib/cjs/accordion/Accordion.js +2 -2
  2. package/lib/cjs/accordion/Accordion.js.map +1 -1
  3. package/lib/cjs/ai/preview/Preview.js +1 -1
  4. package/lib/cjs/ai/preview/Preview.js.map +1 -1
  5. package/lib/cjs/ai/reasoning/Reasoning.js +2 -2
  6. package/lib/cjs/ai/reasoning/Reasoning.js.map +1 -1
  7. package/lib/cjs/ai/thinking/Thinking.js +2 -2
  8. package/lib/cjs/ai/thinking/Thinking.js.map +1 -1
  9. package/lib/cjs/avatar/Avatar.js +1 -1
  10. package/lib/cjs/avatar/Avatar.js.map +1 -1
  11. package/lib/cjs/banner/Banner.js +1 -1
  12. package/lib/cjs/banner/Banner.js.map +1 -1
  13. package/lib/cjs/data-grid/Components.js +1 -1
  14. package/lib/cjs/data-grid/Components.js.map +1 -1
  15. package/lib/cjs/date-picker/DatePicker.js +2 -2
  16. package/lib/cjs/date-picker/DatePicker.js.map +1 -1
  17. package/lib/cjs/dialog/Dialog.js +1 -1
  18. package/lib/cjs/dialog/Dialog.js.map +1 -1
  19. package/lib/cjs/drawer/Drawer.js +1 -1
  20. package/lib/cjs/drawer/Drawer.js.map +1 -1
  21. package/lib/cjs/dropzone/Dropzone.js +2 -2
  22. package/lib/cjs/dropzone/Dropzone.js.map +1 -1
  23. package/lib/cjs/inline-edit/InlineEdit.js +1 -1
  24. package/lib/cjs/inline-edit/InlineEdit.js.map +1 -1
  25. package/lib/cjs/inline-edit/utils.js +2 -4
  26. package/lib/cjs/inline-edit/utils.js.map +1 -1
  27. package/lib/cjs/side-navigation/SideNavigation.js +2 -2
  28. package/lib/cjs/side-navigation/SideNavigation.js.map +1 -1
  29. package/lib/cjs/spotlight/Spotlight.js +1 -1
  30. package/lib/cjs/spotlight/Spotlight.js.map +1 -1
  31. package/lib/cjs/tabs/Tabs.js +1 -1
  32. package/lib/cjs/tabs/Tabs.js.map +1 -1
  33. package/lib/cjs/tooltip/Tooltip.js +1 -1
  34. package/lib/cjs/tooltip/Tooltip.js.map +1 -1
  35. package/lib/cjs/tree-view/TreeViewTextItem.js +1 -1
  36. package/lib/cjs/tree-view/TreeViewTextItem.js.map +1 -1
  37. package/lib/esm/accordion/Accordion.mjs +2 -2
  38. package/lib/esm/accordion/Accordion.mjs.map +1 -1
  39. package/lib/esm/ai/preview/Preview.mjs +1 -1
  40. package/lib/esm/ai/preview/Preview.mjs.map +1 -1
  41. package/lib/esm/ai/reasoning/Reasoning.mjs +2 -2
  42. package/lib/esm/ai/reasoning/Reasoning.mjs.map +1 -1
  43. package/lib/esm/ai/thinking/Thinking.mjs +2 -2
  44. package/lib/esm/ai/thinking/Thinking.mjs.map +1 -1
  45. package/lib/esm/avatar/Avatar.mjs +1 -1
  46. package/lib/esm/avatar/Avatar.mjs.map +1 -1
  47. package/lib/esm/banner/Banner.mjs +1 -1
  48. package/lib/esm/banner/Banner.mjs.map +1 -1
  49. package/lib/esm/data-grid/Components.mjs +1 -1
  50. package/lib/esm/data-grid/Components.mjs.map +1 -1
  51. package/lib/esm/date-picker/DatePicker.mjs +2 -2
  52. package/lib/esm/date-picker/DatePicker.mjs.map +1 -1
  53. package/lib/esm/dialog/Dialog.mjs +1 -1
  54. package/lib/esm/dialog/Dialog.mjs.map +1 -1
  55. package/lib/esm/drawer/Drawer.mjs +1 -1
  56. package/lib/esm/drawer/Drawer.mjs.map +1 -1
  57. package/lib/esm/dropzone/Dropzone.mjs +2 -2
  58. package/lib/esm/dropzone/Dropzone.mjs.map +1 -1
  59. package/lib/esm/inline-edit/InlineEdit.mjs +1 -1
  60. package/lib/esm/inline-edit/InlineEdit.mjs.map +1 -1
  61. package/lib/esm/inline-edit/utils.mjs +2 -4
  62. package/lib/esm/inline-edit/utils.mjs.map +1 -1
  63. package/lib/esm/side-navigation/SideNavigation.mjs +2 -2
  64. package/lib/esm/side-navigation/SideNavigation.mjs.map +1 -1
  65. package/lib/esm/spotlight/Spotlight.mjs +1 -1
  66. package/lib/esm/spotlight/Spotlight.mjs.map +1 -1
  67. package/lib/esm/tabs/Tabs.mjs +1 -1
  68. package/lib/esm/tabs/Tabs.mjs.map +1 -1
  69. package/lib/esm/tooltip/Tooltip.mjs +1 -1
  70. package/lib/esm/tooltip/Tooltip.mjs.map +1 -1
  71. package/lib/esm/tree-view/TreeViewTextItem.mjs +1 -1
  72. package/lib/esm/tree-view/TreeViewTextItem.mjs.map +1 -1
  73. package/lib/types/ai/thinking/Thinking.d.ts.map +1 -1
  74. package/lib/types/inline-edit/InlineEdit.d.ts +1 -1
  75. package/lib/types/inline-edit/utils.d.ts.map +1 -1
  76. package/package.json +4 -3
  77. package/skills/ndl-react/SKILL.md +2 -2
  78. package/skills/ndl-react/components/accordion.md +3 -3
  79. package/skills/ndl-react/components/clean-icon-button.md +5 -5
  80. package/skills/ndl-react/components/date-picker.md +2 -2
  81. package/skills/ndl-react/components/dropzone.md +2 -2
  82. package/skills/ndl-react/components/icon-button.md +5 -5
  83. package/skills/ndl-react/components/inline-edit.md +1 -1
  84. package/skills/ndl-react/components/radio.md +1 -1
  85. package/skills/ndl-react/components/select-icon-button.md +6 -6
  86. package/skills/ndl-react/components/side-navigation.md +4 -4
  87. package/skills/ndl-react/components/skeleton.md +3 -3
  88. package/skills/ndl-react/components/status-indicator.md +5 -5
  89. package/skills/ndl-react/components/tabs.md +4 -4
  90. package/skills/ndl-react/components/timezone-picker.md +1 -1
  91. package/skills/ndl-react/components/tooltip.md +1 -1
  92. package/skills/ndl-react/components/typography.md +2 -2
  93. package/skills/ndl-react/references/styling.md +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"Spotlight.js","names":["createContext","useContext","classNames","Typography","StatusLabel","useId","useState","useRef","useSpotlightContext","React","useSpotlight","placementTranslation","useMergeRefs","useNeedleTheme","FloatingPortal","FloatingFocusManager","FloatingOverlay"],"sources":["../../../src/spotlight/Spotlight.tsx"],"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 FloatingFocusManager,\n FloatingOverlay,\n FloatingPortal,\n useMergeRefs,\n} from '@floating-ui/react';\nimport classNames from 'classnames';\nimport React, {\n createContext,\n useContext,\n useEffect,\n useId,\n useRef,\n useState,\n} from 'react';\n\nimport {\n type CommonProps,\n type PolymorphicCommonProps,\n} from '../_common/types';\nimport { placementTranslation, type Popover } from '../popover';\nimport { StatusLabel } from '../status-label';\nimport { useNeedleTheme } from '../theme';\nimport { Typography } from '../typography';\nimport { useSpotlightContext } from './SpotlightProvider';\n\n// Local instance context to pass stable ARIA ids to subcomponents\ntype SpotlightInstanceContextType = {\n headerId?: string;\n descriptionId?: string;\n setHeaderId?: (id: string | undefined) => void;\n setDescriptionId?: (id: string | undefined) => void;\n};\n\nconst SpotlightInstanceContext =\n createContext<SpotlightInstanceContextType | null>(null);\n\nconst useSpotlightInstance = (): SpotlightInstanceContextType => {\n const ctx = useContext(SpotlightInstanceContext);\n if (ctx === null) {\n throw new Error(\n 'Spotlight subcomponents must be used within <Spotlight />',\n );\n }\n return ctx;\n};\nimport { useSpotlight } from './use-spotlight';\n\ntype SpotlightHeaderProps = {\n /** The spotlight header content */\n children?: React.ReactNode;\n};\n\nconst SpotlightHeader = <T extends React.ElementType = 'div'>({\n children,\n className,\n as,\n style,\n htmlAttributes,\n ref,\n ...restProps\n}: PolymorphicCommonProps<T, SpotlightHeaderProps>) => {\n const classes = classNames('ndl-spotlight-header', className);\n const { headerId, setHeaderId } = useSpotlightInstance();\n const Component: React.ElementType = as ?? 'div';\n\n useEffect(() => {\n if (Boolean(htmlAttributes?.id) === true) {\n setHeaderId?.(htmlAttributes?.id);\n }\n }, [setHeaderId, htmlAttributes?.id]);\n\n return (\n <Typography\n as={Component}\n className={classes}\n ref={ref}\n style={style}\n variant=\"title-4\"\n {...restProps}\n htmlAttributes={{ ...htmlAttributes, id: headerId }}\n >\n {children}\n </Typography>\n );\n};\n\nSpotlightHeader.displayName = 'Spotlight.Header';\n\ntype SpotlightBodyProps = {\n /** The spotlight body content */\n children?: React.ReactNode;\n};\n\nconst SpotlightBody = <T extends React.ElementType = 'div'>({\n children,\n className,\n as,\n style,\n htmlAttributes,\n ref,\n ...restProps\n}: PolymorphicCommonProps<T, SpotlightBodyProps>) => {\n const classes = classNames('ndl-spotlight-body', className);\n const { descriptionId, setDescriptionId } = useSpotlightInstance();\n const Component: React.ElementType = as ?? 'div';\n\n useEffect(() => {\n if (Boolean(htmlAttributes?.id) === true) {\n setDescriptionId?.(htmlAttributes?.id);\n }\n }, [setDescriptionId, htmlAttributes?.id]);\n\n return (\n <Typography\n as={Component}\n className={classes}\n ref={ref}\n style={style}\n variant=\"body-medium\"\n {...restProps}\n htmlAttributes={{ ...htmlAttributes, id: descriptionId }}\n >\n {children}\n </Typography>\n );\n};\n\nSpotlightBody.displayName = 'Spotlight.Body';\n\ntype SpotlightLabelProps = Omit<\n React.ComponentProps<typeof StatusLabel>,\n 'color' | 'fill'\n>;\n\nconst SpotlightLabel = <T extends React.ElementType = 'div'>({\n className,\n children,\n hasIcon,\n as,\n style,\n htmlAttributes,\n ref,\n ...restProps\n}: PolymorphicCommonProps<T, SpotlightLabelProps>) => {\n useSpotlightContext();\n const classes = classNames('ndl-spotlight-label', className);\n\n return (\n <StatusLabel\n fill=\"semi-filled\"\n variant=\"discovery\"\n hasIcon={hasIcon}\n ref={ref}\n as={as}\n className={classes}\n style={style}\n {...restProps}\n {...htmlAttributes}\n >\n {children}\n </StatusLabel>\n );\n};\n\nSpotlightLabel.displayName = 'Spotlight.Label';\n\ntype SpotlightImageProps = {\n /** A string that represents the URL of the image */\n src: string;\n /** A string that represents the alt text of the image */\n alt: string;\n};\n\nconst SpotlightImage = ({\n src,\n alt,\n className,\n style,\n htmlAttributes,\n ref,\n ...restProps\n}: CommonProps<'img', SpotlightImageProps>) => {\n useSpotlightContext();\n const classes = classNames(\n 'ndl-spotlight-image ndl-typography-body-medium',\n className,\n );\n\n return (\n <img\n src={src}\n alt={alt}\n ref={ref}\n className={classes}\n style={style}\n {...restProps}\n {...htmlAttributes}\n />\n );\n};\n\nSpotlightImage.displayName = 'Spotlight.Image';\n\ntype SpotlightIconWrapperProps = {\n /** Content displayed in the icon wrapper */\n children?: React.ReactNode;\n};\n\nconst SpotlightIconWrapper = <T extends React.ElementType = 'div'>({\n children,\n className,\n as,\n style,\n htmlAttributes,\n ref,\n ...restProps\n}: PolymorphicCommonProps<T, SpotlightIconWrapperProps>) => {\n useSpotlightContext();\n const classes = classNames('ndl-spotlight-icon-wrapper', className);\n const Component = as ?? 'div';\n\n return (\n <Component\n ref={ref}\n className={classes}\n style={style}\n {...restProps}\n {...htmlAttributes}\n >\n {children}\n </Component>\n );\n};\n\nSpotlightIconWrapper.displayName = 'Spotlight.IconWrapper';\n\nexport type SpotlightCloseAction = 'clickOutside' | 'escapeKeyDown';\n\nexport type SpotlightProps = {\n /** The id of the `SpotlightTarget` that this `Spotlight` should be rendered next to */\n target: string;\n /** The actions to be displayed in the Spotlight. Should only be TextButton or OutlinedButton components. */\n actions?: React.ReactNode;\n /** A ReactNode that can be put in the left corner of the Spotlight (left of action buttons). It should be used to display the current step if you have a multi-step tour */\n beforeActions?: React.ReactNode;\n /** A callback function that is called if the Spotlight is closed by either clicking outside the Spotlight, or by pressing the Escape key. The function has one argument: action (string that can be either \"clickOutside\" or \"escapeKeyDown\") */\n onClose?: (action: SpotlightCloseAction) => void;\n /** Callback function called when the spotlight is opened */\n onOpen?: () => void;\n /** Children should be Spotlight subcomponents */\n children?: React.ReactNode;\n} & Pick<\n React.ComponentProps<typeof Popover>,\n 'placement' | 'initialFocus' | 'shouldCloseOnClickOutside'\n>;\n\nconst SpotlightComponent = ({\n target,\n beforeActions,\n actions,\n initialFocus,\n onClose,\n placement,\n children,\n className,\n style,\n htmlAttributes,\n shouldCloseOnClickOutside = false,\n onOpen,\n ref,\n ...restProps\n}: CommonProps<'div', SpotlightProps>) => {\n const generatedHeaderId = useId();\n const generatedDescriptionId = useId();\n const [targetElement, setTargetElement] = useState<HTMLElement | null>(null);\n const actionsRef = useRef<HTMLDivElement | null>(null);\n\n const {\n hasOverlay,\n isActiveSpotlight,\n isOpen,\n registeredTargets,\n setActiveSpotlight,\n setIsOpen,\n } = useSpotlightContext();\n\n const [headerId, setHeaderId] = useState<string | undefined>(\n generatedHeaderId,\n );\n const [descriptionId, setDescriptionId] = useState<string | undefined>(\n generatedDescriptionId,\n );\n\n // Determine if a Header child exists\n const hasHeaderChild = React.useMemo(() => {\n const childrenArray = React.Children.toArray(children);\n return childrenArray.some(\n (child) => React.isValidElement(child) && child.type === SpotlightHeader,\n );\n }, [children]);\n\n // Source ARIA from htmlAttributes\n const ariaLabel = htmlAttributes?.['aria-label'];\n const ariaLabelledBy =\n htmlAttributes?.['aria-labelledby'] ??\n (hasHeaderChild ? headerId : undefined);\n const ariaDescribedBy = htmlAttributes?.['aria-describedby'] ?? descriptionId;\n\n if (ariaLabel === undefined && !ariaLabelledBy) {\n console.warn(\n 'The Spotlight is missing aria-label and Header. Please add one of them for accessibility.',\n );\n }\n\n const onOpenChange = (isOpen: boolean, event?: Event) => {\n if (!isOpen) {\n if (event instanceof PointerEvent) {\n onClose?.('clickOutside');\n } else if (event instanceof KeyboardEvent) {\n onClose?.('escapeKeyDown');\n }\n setActiveSpotlight(null);\n setIsOpen(false);\n }\n };\n\n const spotlight = useSpotlight({\n anchorElement: targetElement,\n initialFocus,\n isOpen: isActiveSpotlight(target) && isOpen && !!targetElement,\n onOpenChange,\n placement: placement ? placementTranslation[placement] : undefined,\n shouldCloseOnClickOutside,\n });\n\n const mergedRef = useMergeRefs([spotlight.refs.setFloating, ref]);\n\n const { themeClassName } = useNeedleTheme();\n const classes = classNames('ndl-spotlight', themeClassName, className);\n\n useEffect(() => {\n setTargetElement(registeredTargets[target]?.current);\n }, [target, registeredTargets]);\n\n useEffect(() => {\n if (isOpen && isActiveSpotlight(target)) {\n onOpen?.();\n }\n }, [isOpen, onOpen, isActiveSpotlight, target]);\n\n const findInitialFocus = () => {\n if (spotlight.initialFocus !== undefined) {\n return spotlight.initialFocus;\n }\n if (!actionsRef.current) {\n return undefined;\n }\n const focusableEls = actionsRef.current.querySelectorAll(\n 'button, [href], input, select, textarea, [tabindex]:not([tabindex=\"-1\"])',\n );\n return focusableEls.length - 1;\n };\n\n if (!spotlight.context.open) {\n return null;\n }\n\n return (\n <FloatingPortal>\n <FloatingFocusManager\n context={spotlight.context}\n modal={true}\n initialFocus={findInitialFocus()}\n >\n <SpotlightInstanceContext.Provider\n value={{\n descriptionId,\n headerId,\n setDescriptionId,\n setHeaderId,\n }}\n >\n {hasOverlay === true && (\n <FloatingOverlay\n className=\"ndl-spotlight-overlay ndl-spotlight-overlay-top\"\n onPointerDown={(event) => {\n event.stopPropagation();\n event.preventDefault();\n }}\n onTouchStart={(event) => {\n event.stopPropagation();\n event.preventDefault();\n }}\n />\n )}\n <div\n ref={mergedRef}\n className={classes}\n style={{\n ...spotlight.floatingStyles,\n ...spotlight.transitionStyles,\n ...style,\n }}\n {...spotlight.getFloatingProps({\n ...htmlAttributes,\n 'aria-describedby': ariaDescribedBy,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-modal': 'true',\n })}\n {...restProps}\n >\n <div>{children}</div>\n {(Boolean(beforeActions) || Boolean(actions)) && (\n <div className=\"ndl-spotlight-footer\">\n <Typography variant=\"body-medium\">{beforeActions}</Typography>\n {Boolean(actions) && (\n <div className=\"ndl-spotlight-actions\" ref={actionsRef}>\n {actions}\n </div>\n )}\n </div>\n )}\n </div>\n </SpotlightInstanceContext.Provider>\n </FloatingFocusManager>\n </FloatingPortal>\n );\n};\n\nSpotlightComponent.displayName = 'Spotlight';\n\nconst Spotlight = Object.assign(SpotlightComponent, {\n Body: SpotlightBody,\n Header: SpotlightHeader,\n IconWrapper: SpotlightIconWrapper,\n Image: SpotlightImage,\n Label: SpotlightLabel,\n});\n\nexport { Spotlight };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0EE;CACA;CACA;CACA;CACA;CACA;;;CAoCA;CACA;CACA;CACA;CACA;CACA;;;CAoCA;CACA;CACA;CACA;CACA;CACA;CACA;;;CAiCA;CACA;CACA;CACA;CACA;CACA;;;CA8BA;CACA;CACA;CACA;CACA;CACA;;;CA2CA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;;AA5OF,MAAM,4BAAA,GACJA,MAAAA,cAAAA,CAAmD,IAAI;AAEzD,MAAM,6BAA2D;CAC/D,MAAM,OAAA,GAAMC,MAAAA,WAAAA,CAAW,wBAAwB;CAC/C,IAAI,QAAQ,MACV,MAAM,IAAI,MACR,2DACF;CAEF,OAAO;AACT;AAQA,MAAM,mBAAwD,SAQP;CARO,IAAA,EAC5D,UACA,WACA,IACA,OACA,gBACA,QAAA,MACG,YAAA,gCAAA,QAAA,MAAA,SAAA;CAEH,MAAM,WAAA,GAAUC,WAAAA,QAAAA,CAAW,wBAAwB,SAAS;CAC5D,MAAM,EAAE,UAAU,gBAAgB,qBAAqB;CACvD,MAAM,YAA+B,OAAA,QAAA,OAAA,KAAA,IAAA,KAAM;CAE3C,CAAA,GAAA,MAAA,UAAA,OAAgB;EACd,IAAI,QAAA,mBAAA,QAAA,mBAAA,KAAA,IAAA,KAAA,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Ae,UAAA;IAA0B,CAAA,GAC5D,QAAQ,OAAO,KACd,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;KAAK,WAAU;KAAwB,KAAK;KACzC,UAAA;IACE,CAAA,CAEJ;GAEJ,CAAA,CAAA,EAAA,CAAA,CAAA,CAC4B;;CACf,CAAA,EACR,CAAA;AAEpB;AAEA,mBAAmB,cAAc;AAEjC,MAAM,YAAY,OAAO,OAAO,oBAAoB;CAClD,MAAM;CACN,QAAQ;CACR,aAAa;CACb,OAAO;CACP,OAAO;AACT,CAAC"}
1
+ {"version":3,"file":"Spotlight.js","names":["createContext","useContext","classNames","Typography","StatusLabel","useId","useState","useRef","useSpotlightContext","React","useSpotlight","placementTranslation","useMergeRefs","useNeedleTheme","FloatingPortal","FloatingFocusManager","FloatingOverlay"],"sources":["../../../src/spotlight/Spotlight.tsx"],"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 FloatingFocusManager,\n FloatingOverlay,\n FloatingPortal,\n useMergeRefs,\n} from '@floating-ui/react';\nimport classNames from 'classnames';\nimport React, {\n createContext,\n useContext,\n useEffect,\n useId,\n useRef,\n useState,\n} from 'react';\n\nimport {\n type CommonProps,\n type PolymorphicCommonProps,\n} from '../_common/types';\nimport { placementTranslation, type Popover } from '../popover';\nimport { StatusLabel } from '../status-label';\nimport { useNeedleTheme } from '../theme';\nimport { Typography } from '../typography';\nimport { useSpotlightContext } from './SpotlightProvider';\n\n// Local instance context to pass stable ARIA ids to subcomponents\ntype SpotlightInstanceContextType = {\n headerId?: string;\n descriptionId?: string;\n setHeaderId?: (id: string | undefined) => void;\n setDescriptionId?: (id: string | undefined) => void;\n};\n\nconst SpotlightInstanceContext =\n createContext<SpotlightInstanceContextType | null>(null);\n\nconst useSpotlightInstance = (): SpotlightInstanceContextType => {\n const ctx = useContext(SpotlightInstanceContext);\n if (ctx === null) {\n throw new Error(\n 'Spotlight subcomponents must be used within <Spotlight />',\n );\n }\n return ctx;\n};\nimport { useSpotlight } from './use-spotlight';\n\ntype SpotlightHeaderProps = {\n /** The spotlight header content */\n children?: React.ReactNode;\n};\n\nconst SpotlightHeader = <T extends React.ElementType = 'div'>({\n children,\n className,\n as,\n style,\n htmlAttributes,\n ref,\n ...restProps\n}: PolymorphicCommonProps<T, SpotlightHeaderProps>) => {\n const classes = classNames('ndl-spotlight-header', className);\n const { headerId, setHeaderId } = useSpotlightInstance();\n const Component: React.ElementType = as ?? 'div';\n\n useEffect(() => {\n if (Boolean(htmlAttributes?.id) === true) {\n setHeaderId?.(htmlAttributes?.id);\n }\n }, [setHeaderId, htmlAttributes?.id]);\n\n return (\n <Typography\n as={Component}\n className={classes}\n ref={ref}\n style={style}\n variant=\"title-3\"\n {...restProps}\n htmlAttributes={{ ...htmlAttributes, id: headerId }}\n >\n {children}\n </Typography>\n );\n};\n\nSpotlightHeader.displayName = 'Spotlight.Header';\n\ntype SpotlightBodyProps = {\n /** The spotlight body content */\n children?: React.ReactNode;\n};\n\nconst SpotlightBody = <T extends React.ElementType = 'div'>({\n children,\n className,\n as,\n style,\n htmlAttributes,\n ref,\n ...restProps\n}: PolymorphicCommonProps<T, SpotlightBodyProps>) => {\n const classes = classNames('ndl-spotlight-body', className);\n const { descriptionId, setDescriptionId } = useSpotlightInstance();\n const Component: React.ElementType = as ?? 'div';\n\n useEffect(() => {\n if (Boolean(htmlAttributes?.id) === true) {\n setDescriptionId?.(htmlAttributes?.id);\n }\n }, [setDescriptionId, htmlAttributes?.id]);\n\n return (\n <Typography\n as={Component}\n className={classes}\n ref={ref}\n style={style}\n variant=\"body-medium\"\n {...restProps}\n htmlAttributes={{ ...htmlAttributes, id: descriptionId }}\n >\n {children}\n </Typography>\n );\n};\n\nSpotlightBody.displayName = 'Spotlight.Body';\n\ntype SpotlightLabelProps = Omit<\n React.ComponentProps<typeof StatusLabel>,\n 'color' | 'fill'\n>;\n\nconst SpotlightLabel = <T extends React.ElementType = 'div'>({\n className,\n children,\n hasIcon,\n as,\n style,\n htmlAttributes,\n ref,\n ...restProps\n}: PolymorphicCommonProps<T, SpotlightLabelProps>) => {\n useSpotlightContext();\n const classes = classNames('ndl-spotlight-label', className);\n\n return (\n <StatusLabel\n fill=\"semi-filled\"\n variant=\"discovery\"\n hasIcon={hasIcon}\n ref={ref}\n as={as}\n className={classes}\n style={style}\n {...restProps}\n {...htmlAttributes}\n >\n {children}\n </StatusLabel>\n );\n};\n\nSpotlightLabel.displayName = 'Spotlight.Label';\n\ntype SpotlightImageProps = {\n /** A string that represents the URL of the image */\n src: string;\n /** A string that represents the alt text of the image */\n alt: string;\n};\n\nconst SpotlightImage = ({\n src,\n alt,\n className,\n style,\n htmlAttributes,\n ref,\n ...restProps\n}: CommonProps<'img', SpotlightImageProps>) => {\n useSpotlightContext();\n const classes = classNames(\n 'ndl-spotlight-image ndl-typography-body-medium',\n className,\n );\n\n return (\n <img\n src={src}\n alt={alt}\n ref={ref}\n className={classes}\n style={style}\n {...restProps}\n {...htmlAttributes}\n />\n );\n};\n\nSpotlightImage.displayName = 'Spotlight.Image';\n\ntype SpotlightIconWrapperProps = {\n /** Content displayed in the icon wrapper */\n children?: React.ReactNode;\n};\n\nconst SpotlightIconWrapper = <T extends React.ElementType = 'div'>({\n children,\n className,\n as,\n style,\n htmlAttributes,\n ref,\n ...restProps\n}: PolymorphicCommonProps<T, SpotlightIconWrapperProps>) => {\n useSpotlightContext();\n const classes = classNames('ndl-spotlight-icon-wrapper', className);\n const Component = as ?? 'div';\n\n return (\n <Component\n ref={ref}\n className={classes}\n style={style}\n {...restProps}\n {...htmlAttributes}\n >\n {children}\n </Component>\n );\n};\n\nSpotlightIconWrapper.displayName = 'Spotlight.IconWrapper';\n\nexport type SpotlightCloseAction = 'clickOutside' | 'escapeKeyDown';\n\nexport type SpotlightProps = {\n /** The id of the `SpotlightTarget` that this `Spotlight` should be rendered next to */\n target: string;\n /** The actions to be displayed in the Spotlight. Should only be TextButton or OutlinedButton components. */\n actions?: React.ReactNode;\n /** A ReactNode that can be put in the left corner of the Spotlight (left of action buttons). It should be used to display the current step if you have a multi-step tour */\n beforeActions?: React.ReactNode;\n /** A callback function that is called if the Spotlight is closed by either clicking outside the Spotlight, or by pressing the Escape key. The function has one argument: action (string that can be either \"clickOutside\" or \"escapeKeyDown\") */\n onClose?: (action: SpotlightCloseAction) => void;\n /** Callback function called when the spotlight is opened */\n onOpen?: () => void;\n /** Children should be Spotlight subcomponents */\n children?: React.ReactNode;\n} & Pick<\n React.ComponentProps<typeof Popover>,\n 'placement' | 'initialFocus' | 'shouldCloseOnClickOutside'\n>;\n\nconst SpotlightComponent = ({\n target,\n beforeActions,\n actions,\n initialFocus,\n onClose,\n placement,\n children,\n className,\n style,\n htmlAttributes,\n shouldCloseOnClickOutside = false,\n onOpen,\n ref,\n ...restProps\n}: CommonProps<'div', SpotlightProps>) => {\n const generatedHeaderId = useId();\n const generatedDescriptionId = useId();\n const [targetElement, setTargetElement] = useState<HTMLElement | null>(null);\n const actionsRef = useRef<HTMLDivElement | null>(null);\n\n const {\n hasOverlay,\n isActiveSpotlight,\n isOpen,\n registeredTargets,\n setActiveSpotlight,\n setIsOpen,\n } = useSpotlightContext();\n\n const [headerId, setHeaderId] = useState<string | undefined>(\n generatedHeaderId,\n );\n const [descriptionId, setDescriptionId] = useState<string | undefined>(\n generatedDescriptionId,\n );\n\n // Determine if a Header child exists\n const hasHeaderChild = React.useMemo(() => {\n const childrenArray = React.Children.toArray(children);\n return childrenArray.some(\n (child) => React.isValidElement(child) && child.type === SpotlightHeader,\n );\n }, [children]);\n\n // Source ARIA from htmlAttributes\n const ariaLabel = htmlAttributes?.['aria-label'];\n const ariaLabelledBy =\n htmlAttributes?.['aria-labelledby'] ??\n (hasHeaderChild ? headerId : undefined);\n const ariaDescribedBy = htmlAttributes?.['aria-describedby'] ?? descriptionId;\n\n if (ariaLabel === undefined && !ariaLabelledBy) {\n console.warn(\n 'The Spotlight is missing aria-label and Header. Please add one of them for accessibility.',\n );\n }\n\n const onOpenChange = (isOpen: boolean, event?: Event) => {\n if (!isOpen) {\n if (event instanceof PointerEvent) {\n onClose?.('clickOutside');\n } else if (event instanceof KeyboardEvent) {\n onClose?.('escapeKeyDown');\n }\n setActiveSpotlight(null);\n setIsOpen(false);\n }\n };\n\n const spotlight = useSpotlight({\n anchorElement: targetElement,\n initialFocus,\n isOpen: isActiveSpotlight(target) && isOpen && !!targetElement,\n onOpenChange,\n placement: placement ? placementTranslation[placement] : undefined,\n shouldCloseOnClickOutside,\n });\n\n const mergedRef = useMergeRefs([spotlight.refs.setFloating, ref]);\n\n const { themeClassName } = useNeedleTheme();\n const classes = classNames('ndl-spotlight', themeClassName, className);\n\n useEffect(() => {\n setTargetElement(registeredTargets[target]?.current);\n }, [target, registeredTargets]);\n\n useEffect(() => {\n if (isOpen && isActiveSpotlight(target)) {\n onOpen?.();\n }\n }, [isOpen, onOpen, isActiveSpotlight, target]);\n\n const findInitialFocus = () => {\n if (spotlight.initialFocus !== undefined) {\n return spotlight.initialFocus;\n }\n if (!actionsRef.current) {\n return undefined;\n }\n const focusableEls = actionsRef.current.querySelectorAll(\n 'button, [href], input, select, textarea, [tabindex]:not([tabindex=\"-1\"])',\n );\n return focusableEls.length - 1;\n };\n\n if (!spotlight.context.open) {\n return null;\n }\n\n return (\n <FloatingPortal>\n <FloatingFocusManager\n context={spotlight.context}\n modal={true}\n initialFocus={findInitialFocus()}\n >\n <SpotlightInstanceContext.Provider\n value={{\n descriptionId,\n headerId,\n setDescriptionId,\n setHeaderId,\n }}\n >\n {hasOverlay === true && (\n <FloatingOverlay\n className=\"ndl-spotlight-overlay ndl-spotlight-overlay-top\"\n onPointerDown={(event) => {\n event.stopPropagation();\n event.preventDefault();\n }}\n onTouchStart={(event) => {\n event.stopPropagation();\n event.preventDefault();\n }}\n />\n )}\n <div\n ref={mergedRef}\n className={classes}\n style={{\n ...spotlight.floatingStyles,\n ...spotlight.transitionStyles,\n ...style,\n }}\n {...spotlight.getFloatingProps({\n ...htmlAttributes,\n 'aria-describedby': ariaDescribedBy,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-modal': 'true',\n })}\n {...restProps}\n >\n <div>{children}</div>\n {(Boolean(beforeActions) || Boolean(actions)) && (\n <div className=\"ndl-spotlight-footer\">\n <Typography variant=\"body-medium\">{beforeActions}</Typography>\n {Boolean(actions) && (\n <div className=\"ndl-spotlight-actions\" ref={actionsRef}>\n {actions}\n </div>\n )}\n </div>\n )}\n </div>\n </SpotlightInstanceContext.Provider>\n </FloatingFocusManager>\n </FloatingPortal>\n );\n};\n\nSpotlightComponent.displayName = 'Spotlight';\n\nconst Spotlight = Object.assign(SpotlightComponent, {\n Body: SpotlightBody,\n Header: SpotlightHeader,\n IconWrapper: SpotlightIconWrapper,\n Image: SpotlightImage,\n Label: SpotlightLabel,\n});\n\nexport { Spotlight };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0EE;CACA;CACA;CACA;CACA;CACA;;;CAoCA;CACA;CACA;CACA;CACA;CACA;;;CAoCA;CACA;CACA;CACA;CACA;CACA;CACA;;;CAiCA;CACA;CACA;CACA;CACA;CACA;;;CA8BA;CACA;CACA;CACA;CACA;CACA;;;CA2CA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;;AA5OF,MAAM,4BAAA,GACJA,MAAAA,cAAAA,CAAmD,IAAI;AAEzD,MAAM,6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,CAAA,GACK,UAAU,cAAA,GACV,UAAU,gBAAA,GACV,KACL;GACI,GAAA,UAAU,iBAAA,sBAAA,QAAA,sBAAA,QAAA,CAAA,GACT,cAAA,GAAA,CAAA,GAAA;IACH,oBAAoB;IACpB,cAAc;IACd,mBAAmB;IACnB,cAAc;GAChB,CAAA,CAAC,CAAA,GACG,SAAA,GAAA,CAAA,GAAA,EAAA,UAfN,CAiBE,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD,EAAM,SAAc,CAAA,IAClB,QAAQ,aAAa,KAAK,QAAQ,OAAO,MACzC,iBAAA,GAAA,kBAAA,KAAA,CAAC,OAAD;IAAK,WAAU;IAAf,UAAA,CACE,iBAAA,GAAA,kBAAA,IAAA,CAACb,8BAAAA,YAAD;KAAY,SAAQ;KAAe,UAAA;IAA0B,CAAA,GAC5D,QAAQ,OAAO,KACd,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;KAAK,WAAU;KAAwB,KAAK;KACzC,UAAA;IACE,CAAA,CAEJ;GAEJ,CAAA,CAAA,EAAA,CAAA,CAAA,CAC4B;;CACf,CAAA,EACR,CAAA;AAEpB;AAEA,mBAAmB,cAAc;AAEjC,MAAM,YAAY,OAAO,OAAO,oBAAoB;CAClD,MAAM;CACN,QAAQ;CACR,aAAa;CACb,OAAO;CACP,OAAO;AACT,CAAC"}
@@ -310,7 +310,7 @@ const TabBadge = (_ref4) => {
310
310
  const classes = (0, classnames.default)("ndl-tab-badge", className);
311
311
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_typography_Typography.Typography, require_objectSpread2.default(require_objectSpread2.default({
312
312
  ref,
313
- variant: "subheading-small",
313
+ variant: "subheading-medium",
314
314
  className: classes,
315
315
  style,
316
316
  htmlAttributes
@@ -1 +1 @@
1
- {"version":3,"file":"Tabs.js","names":["ArrowLeftCircleIconOutline","ArrowRightCircleIconOutline","classNames","React","useContext","useRef","useMergeRefs","useState","useTabsScrollOverflow","useCallback","Tooltip","Typography"],"sources":["../../../src/tabs/Tabs.tsx"],"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 { useMergeRefs } from '@floating-ui/react';\nimport classNames from 'classnames';\nimport React, {\n useCallback,\n useContext,\n useEffect,\n useRef,\n useState,\n} from 'react';\n\nimport {\n type CommonProps,\n type PolymorphicCommonProps,\n type TooltipObjectProps,\n} from '../_common/types';\nimport { ArrowLeftCircleIconOutline } from '../icons/generated/heroIcons/ArrowLeftCircleIconOutline';\nimport { ArrowRightCircleIconOutline } from '../icons/generated/heroIcons/ArrowRightCircleIconOutline';\nimport { Tooltip } from '../tooltip';\nimport { Typography } from '../typography';\nimport { useTabsScrollOverflow } from './use-tabs-scroll-overflow';\n\n// Reusable scroll button component\nconst ScrollButton = ({\n direction,\n isVisible,\n onClick,\n onBackground,\n}: {\n direction: 'left' | 'right';\n isVisible: boolean;\n onClick: () => void;\n onBackground: React.ComponentProps<typeof TabsComponent>['onBackground'];\n}) => {\n const Icon =\n direction === 'left'\n ? ArrowLeftCircleIconOutline\n : ArrowRightCircleIconOutline;\n const positionClass =\n direction === 'left' ? 'ndl-scroll-left-item' : 'ndl-scroll-right-item';\n\n return (\n <div\n className={classNames('ndl-scroll-item', positionClass, {\n 'ndl-scroll-item-hidden': !isVisible,\n 'ndl-scroll-item-on-background-default': onBackground === 'default',\n 'ndl-scroll-item-on-background-weak': onBackground === 'weak',\n })}\n >\n <button\n type=\"button\"\n tabIndex={-1}\n className=\"ndl-scroll-icon-wrapper\"\n onClick={onClick}\n aria-hidden=\"true\"\n >\n <Icon className=\"ndl-scroll-icon\" />\n </button>\n </div>\n );\n};\n\ntype TabId = string;\ntype Size = 'small' | 'large';\ntype Fill = 'underline' | 'filled';\n\ntype BaseTabsProps<T extends TabId> = {\n /** The currently active tabId */\n value: T;\n /** Callback function triggered when a new tab is selected */\n onChange: (event: T) => void;\n /** The content dislayed in the tabs */\n children: React.ReactNode | string;\n /** The fill type of the tabs */\n fill?: Fill;\n /** The size of the tabs */\n size?: Size;\n /** What background the Tabs is placed on. This affects the gradient background of the scroll navigation buttons. */\n onBackground?: 'weak' | 'default';\n};\n\ntype TabsContextType<T extends TabId> = Required<\n Pick<BaseTabsProps<T>, 'fill' | 'size' | 'onChange' | 'value'>\n> & {\n registerTab: (tabId: T, ref: React.RefObject<HTMLElement | null>) => void;\n unregisterTab: (tabId: T) => void;\n scrollTabIntoView: (tabId: T) => void;\n firstTabId: T | null;\n isValuePresent: boolean;\n};\n\n// oxlint-disable-next-line @typescript-eslint/no-explicit-any\nconst TabsContext = React.createContext<TabsContextType<any> | null>(null);\n\nconst useTabsContext = () => {\n const context = useContext(TabsContext);\n\n if (context === null) {\n throw new Error('Tab used without context');\n }\n\n return context;\n};\n\nconst getTabPanelId = (tabId: TabId) => `tabpanel-${tabId}`;\n\nconst getGeneralTabClasses = (size: Size, fill: Fill) => {\n return {\n 'ndl-filled-tab': fill === 'filled',\n 'ndl-large': size === 'large',\n 'ndl-small': size === 'small',\n 'ndl-underline-tab': fill === 'underline',\n };\n};\n\nconst TabsComponent = <U extends TabId, T extends React.ElementType = 'div'>({\n children,\n size = 'large',\n fill = 'underline',\n onChange,\n value,\n onBackground = 'weak',\n className,\n style,\n as,\n htmlAttributes,\n ref,\n ...restProps\n}: PolymorphicCommonProps<T, BaseTabsProps<U>>) => {\n const tabRefs = useRef<Map<U, React.RefObject<HTMLElement | null>>>(\n new Map(),\n );\n const containerRef = useRef<HTMLElement>(null);\n const scrollContainerRef = useRef<HTMLDivElement>(null);\n const mergedRef = useMergeRefs([containerRef, ref]);\n const [firstTabId, setFirstTabId] = useState<U | null>(null);\n const [isValuePresent, setIsValuePresent] = useState(false);\n const valueRef = useRef(value);\n\n // Use the custom hook for scroll overflow behavior\n const { scrollState, scrollToNextItem, checkOverflow } =\n useTabsScrollOverflow(scrollContainerRef);\n\n useEffect(() => {\n valueRef.current = value;\n setIsValuePresent(tabRefs.current.has(value));\n }, [value]);\n\n const registerTab = useCallback(\n (tabId: U, tabRef: React.RefObject<HTMLElement | null>) => {\n tabRefs.current.set(tabId, tabRef);\n const first = tabRefs.current.keys().next().value ?? null;\n setFirstTabId((prev) => (prev === first ? prev : first));\n\n if (tabId === valueRef.current) {\n setIsValuePresent(true);\n }\n },\n [],\n );\n\n const unregisterTab = useCallback((tabId: U) => {\n tabRefs.current.delete(tabId);\n const first = tabRefs.current.keys().next().value ?? null;\n setFirstTabId((prev) => (prev === first ? prev : first));\n\n if (tabId === valueRef.current) {\n setIsValuePresent(false);\n }\n }, []);\n\n // Check overflow when children change\n useEffect(() => {\n checkOverflow();\n }, [checkOverflow, children]);\n\n const scrollTabIntoView = useCallback((tabId: U) => {\n const tabRef = tabRefs.current.get(tabId);\n const scrollContainer = scrollContainerRef.current;\n\n if (tabRef?.current && scrollContainer) {\n const tabRect = tabRef.current.getBoundingClientRect();\n const containerRect = scrollContainer.getBoundingClientRect();\n const containerCenter = containerRect.left + containerRect.width / 2;\n\n const targetScrollLeft =\n scrollContainer.scrollLeft +\n (tabRect.left - containerCenter + tabRect.width / 2);\n\n scrollContainer.scrollTo({\n behavior: 'smooth',\n left: targetScrollLeft,\n });\n }\n }, []);\n\n const handleKeyDown = useCallback(\n (event: React.KeyboardEvent) => {\n if (event.key !== 'ArrowLeft' && event.key !== 'ArrowRight') {\n return;\n }\n\n event.preventDefault();\n\n const tabIds = Array.from(tabRefs.current.keys());\n const focusedElement = document.activeElement;\n\n // Find the currently focused tab\n let currentIndex = -1;\n for (let index = 0; index < tabIds.length; index++) {\n const tabRef = tabRefs.current.get(tabIds[index]);\n if (tabRef?.current === focusedElement) {\n currentIndex = index;\n break;\n }\n }\n\n // If no tab is focused, focus the active tab. Or the first tab if the active tab is not present.\n if (currentIndex === -1) {\n const activeTabRef = tabRefs.current.get(value);\n if (activeTabRef?.current) {\n activeTabRef.current.focus();\n } else if (!isValuePresent && firstTabId !== null) {\n const firstTabRef = tabRefs.current.get(firstTabId);\n if (firstTabRef?.current) {\n firstTabRef.current.focus();\n }\n }\n return;\n }\n\n let nextIndex: number;\n\n if (event.key === 'ArrowRight') {\n nextIndex = currentIndex === tabIds.length - 1 ? 0 : currentIndex + 1;\n } else {\n nextIndex = currentIndex === 0 ? tabIds.length - 1 : currentIndex - 1;\n }\n\n const nextTabId = tabIds[nextIndex];\n const nextTabRef = tabRefs.current.get(nextTabId);\n\n if (nextTabRef?.current) {\n nextTabRef.current.focus();\n scrollTabIntoView(nextTabId);\n }\n },\n [value, scrollTabIntoView, firstTabId, isValuePresent],\n );\n\n const classes = classNames(\n 'ndl-tabs',\n getGeneralTabClasses(size, fill),\n className,\n );\n\n const Component: React.ElementType = as ?? 'div';\n\n return (\n <Component\n className={classes}\n style={style}\n role=\"tablist\"\n aria-orientation=\"horizontal\"\n onKeyDown={handleKeyDown}\n ref={mergedRef}\n {...restProps}\n {...htmlAttributes}\n >\n <ScrollButton\n direction=\"left\"\n isVisible={scrollState.isLeftVisible}\n onClick={() => scrollToNextItem('left')}\n onBackground={onBackground}\n />\n <ScrollButton\n direction=\"right\"\n isVisible={scrollState.isRightVisible}\n onClick={() => scrollToNextItem('right')}\n onBackground={onBackground}\n />\n <TabsContext.Provider\n value={{\n fill,\n firstTabId,\n isValuePresent,\n onChange,\n registerTab,\n scrollTabIntoView,\n size,\n unregisterTab,\n value,\n }}\n >\n <div className=\"ndl-tabs-container\" ref={scrollContainerRef}>\n {children}\n </div>\n </TabsContext.Provider>\n </Component>\n );\n};\n\nTabsComponent.displayName = 'Tabs';\n\n/**\n * @remarks\n * When the `description` prop is set, hovering over the tab will show a tooltip with the text provided in the `description` prop. `tooltipProps` can be used to customize the tooltip appearance. The `TooltipObjectProps` type is defined as: `{ root?: Partial<React.ComponentProps<typeof Tooltip>>; trigger?: Partial<React.ComponentProps<typeof Tooltip.Trigger>>; content?: Partial<React.ComponentProps<typeof Tooltip.Content>>; }`, see the Tooltip component for more details.\n */\ntype TabProps<T extends TabId> = {\n /** The id of the tab */\n id: T;\n /** The content of the tab */\n children: React.ReactNode | string;\n /** A string that will be shown as a tooltip when hovering over the button it also acts as an aria-label- {@link https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-label} */\n description?: string;\n /** Props for the tooltip component. */\n tooltipProps?: TooltipObjectProps;\n /** Trailing content that will be rendered after the tab content. Badges belong here. */\n trailingContent?: React.ReactNode;\n /** Additional class name */\n className?: string;\n /** Whether the tab is disabled */\n isDisabled?: boolean;\n};\n\nconst TabsTab = <\n U extends TabId = TabId,\n T extends React.ElementType = 'button',\n>({\n children,\n id: tabId,\n isDisabled = false,\n className,\n description,\n tooltipProps,\n style,\n as,\n htmlAttributes,\n ref,\n trailingContent,\n ...restProps\n}: PolymorphicCommonProps<T, TabProps<U>>) => {\n const {\n size,\n fill,\n value,\n onChange,\n registerTab,\n unregisterTab,\n scrollTabIntoView,\n firstTabId,\n isValuePresent,\n } = useTabsContext();\n const internalRef = useRef<HTMLElement>(null);\n\n // Create a merged ref that handles both ref objects and ref functions\n const mergedRef = useMergeRefs([\n internalRef as React.RefObject<HTMLElement>,\n ref as React.RefObject<HTMLElement>,\n ]);\n\n // Register/unregister tab for keyboard navigation\n useEffect(() => {\n registerTab(tabId, internalRef);\n\n return () => {\n unregisterTab(tabId);\n };\n }, [tabId, registerTab, unregisterTab]);\n\n const baseClasses = classNames({\n ...getGeneralTabClasses(size, fill),\n 'ndl-disabled': isDisabled,\n 'ndl-selected': value === tabId,\n });\n\n const Component: React.ElementType = as ?? 'button';\n\n const classes = classNames('ndl-tab', baseClasses, className);\n\n // Only the active tab should be in the tab sequence initially\n // Other tabs can be focused via arrow keys but are not in tab sequence\n const tabIndex =\n value === tabId || (!isValuePresent && tabId === firstTabId) ? 0 : -1;\n\n return (\n <Tooltip\n type=\"simple\"\n {...tooltipProps?.root}\n isDisabled={description === undefined}\n >\n <Tooltip.Trigger {...tooltipProps?.trigger} hasButtonWrapper>\n <Component\n className={classes}\n style={style}\n onClick={() => {\n if (!isDisabled) {\n onChange(tabId);\n scrollTabIntoView(tabId);\n }\n }}\n role=\"tab\"\n id={tabId}\n aria-disabled={isDisabled}\n aria-label={description}\n aria-selected={value === tabId}\n aria-controls={getTabPanelId(tabId)}\n tabIndex={tabIndex}\n ref={mergedRef}\n {...restProps}\n {...htmlAttributes}\n >\n <span className=\"ndl-tab-content\">{children}</span>\n {trailingContent}\n {fill === 'underline' && <span className=\"ndl-tab-underline\" />}\n </Component>\n </Tooltip.Trigger>\n <Tooltip.Content {...tooltipProps?.content}>\n {description}\n </Tooltip.Content>\n </Tooltip>\n );\n};\n\nTabsTab.displayName = 'Tabs.Tab';\n\ntype TabPanelProps = {\n /** The content displayed in the tab panel */\n children: React.ReactNode;\n /** The currently selected tabId. The tab is visible if the value is equal to the tabId */\n value: TabId;\n /** The id of the tab panel */\n tabId: TabId;\n /** Additional class name */\n className?: string;\n};\n\nconst TabsTabPanel = <T extends React.ElementType = 'div'>({\n as,\n children,\n value,\n tabId,\n style,\n className,\n htmlAttributes,\n ref,\n ...restProps\n}: PolymorphicCommonProps<T, TabPanelProps>) => {\n const Component: React.ElementType = as ?? 'div';\n\n return (\n <>\n {value === tabId ? (\n <Component\n role=\"tabpanel\"\n id={getTabPanelId(tabId)}\n aria-labelledby={tabId}\n style={style}\n className={classNames(className)}\n ref={ref}\n {...restProps}\n {...htmlAttributes}\n >\n {children}\n </Component>\n ) : null}\n </>\n );\n};\n\nTabsTabPanel.displayName = 'Tabs.TabPanel';\n\ntype TabBadgeProps = {\n /** The content of the badge */\n children: React.ReactNode;\n};\n\nconst TabBadge = ({\n children,\n ref,\n htmlAttributes,\n style,\n className,\n ...restProps\n}: CommonProps<'span', TabBadgeProps>) => {\n const classes = classNames('ndl-tab-badge', className);\n return (\n <Typography\n ref={ref}\n variant=\"subheading-small\"\n className={classes}\n style={style}\n htmlAttributes={htmlAttributes}\n {...restProps}\n >\n {children}\n </Typography>\n );\n};\n\nconst Tabs = Object.assign(TabsComponent, {\n Badge: TabBadge,\n Tab: TabsTab,\n TabPanel: TabsTabPanel,\n});\n\nexport { Tabs };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuIE;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;;;CA2MA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;;;CAmGA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;;;CAiCA;CACA;CACA;CACA;CACA;;AA3cF,MAAM,gBAAgB,EACpB,WACA,WACA,SACA,mBAMI;CACJ,MAAM,OACJ,cAAc,SACVA,6DAAAA,6BACAC,8DAAAA;CAIN,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;EACE,YAAA,GAAWC,WAAAA,QAAAA,CAAW,mBAJxB,cAAc,SAAS,yBAAyB,yBAIU;GACtD,0BAA0B,CAAC;GAC3B,yCAAyC,iBAAiB;GAC1D,sCAAsC,iBAAiB;EACzD,CAAC;EAED,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAAC,UAAD;GACE,MAAK;GACL,UAAU;GACV,WAAU;GACD;GACT,eAAY;GAEZ,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAAC,MAAD,EAAM,WAAU,kBAAmB,CAAA;EAC7B,CAAA;CACL,CAAA;AAET;AAgCA,MAAM,cAAcC,MAAAA,QAAM,cAA2C,IAAI;AAEzE,MAAM,uBAAuB;CAC3B,MAAM,WAAA,GAAUC,MAAAA,WAAAA,CAAW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A,iBAAA,QAAA,iBAAA,KAAA,IAAA,KAAA,IAAY,aAAc,OAAA,GAAA,CAAA,GAAA,EAAA,UAChC,YAAA,CACc,CAAA,CACV;;AAEb;AAEA,QAAQ,cAAc;AAatB,MAAM,gBAAqD,UAUX;CAVW,IAAA,EACzD,IACA,UACA,OACA,OACA,OACA,WACA,gBACA,QAAA,OACG,YAAA,gCAAA,QAAA,OAAA,UAAA;CAIH,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAA,kBAAA,UAAA,EAAA,UACG,UAAU,QACT,iBAAA,GAAA,kBAAA,IAAA,CAL+B,OAAA,QAAA,OAAA,KAAA,IAAA,KAAM,OAAA,sBAAA,QAAA,sBAAA,QAAA,sBAAA,QAAA;EAMnC,MAAK;EACL,IAAI,cAAc,KAAK;EACvB,mBAAiB;EACV;EACP,YAAA,GAAWR,WAAAA,QAAAA,CAAW,SAAS;EAC1B;CACD,GAAA,SAAA,GACA,cAAA,GAAA,CAAA,GAAA,EAEH,SAAA,CACQ,CAAA,IACT,KACJ,CAAA;AAEN;AAEA,aAAa,cAAc;AAO3B,MAAM,YAAY,UAOwB;CAPxB,IAAA,EAChB,UACA,KACA,gBACA,OACA,cAAA,OACG,YAAA,gCAAA,QAAA,OAAA,UAAA;CAEH,MAAM,WAAA,GAAUA,WAAAA,QAAAA,CAAW,iBAAiB,SAAS;CACrD,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACS,8BAAAA,YAAAA,sBAAAA,QAAAA,sBAAAA,QAAAA;EACM;EACL,SAAQ;EACR,WAAW;EACJ;EACS;CACZ,GAAA,SAAA,GAAA,CAAA,GAAA,EAEH,SAAA,CACS,CAAA;AAEhB;AAEA,MAAM,OAAO,OAAO,OAAO,eAAe;CACxC,OAAO;CACP,KAAK;CACL,UAAU;AACZ,CAAC"}
1
+ {"version":3,"file":"Tabs.js","names":["ArrowLeftCircleIconOutline","ArrowRightCircleIconOutline","classNames","React","useContext","useRef","useMergeRefs","useState","useTabsScrollOverflow","useCallback","Tooltip","Typography"],"sources":["../../../src/tabs/Tabs.tsx"],"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 { useMergeRefs } from '@floating-ui/react';\nimport classNames from 'classnames';\nimport React, {\n useCallback,\n useContext,\n useEffect,\n useRef,\n useState,\n} from 'react';\n\nimport {\n type CommonProps,\n type PolymorphicCommonProps,\n type TooltipObjectProps,\n} from '../_common/types';\nimport { ArrowLeftCircleIconOutline } from '../icons/generated/heroIcons/ArrowLeftCircleIconOutline';\nimport { ArrowRightCircleIconOutline } from '../icons/generated/heroIcons/ArrowRightCircleIconOutline';\nimport { Tooltip } from '../tooltip';\nimport { Typography } from '../typography';\nimport { useTabsScrollOverflow } from './use-tabs-scroll-overflow';\n\n// Reusable scroll button component\nconst ScrollButton = ({\n direction,\n isVisible,\n onClick,\n onBackground,\n}: {\n direction: 'left' | 'right';\n isVisible: boolean;\n onClick: () => void;\n onBackground: React.ComponentProps<typeof TabsComponent>['onBackground'];\n}) => {\n const Icon =\n direction === 'left'\n ? ArrowLeftCircleIconOutline\n : ArrowRightCircleIconOutline;\n const positionClass =\n direction === 'left' ? 'ndl-scroll-left-item' : 'ndl-scroll-right-item';\n\n return (\n <div\n className={classNames('ndl-scroll-item', positionClass, {\n 'ndl-scroll-item-hidden': !isVisible,\n 'ndl-scroll-item-on-background-default': onBackground === 'default',\n 'ndl-scroll-item-on-background-weak': onBackground === 'weak',\n })}\n >\n <button\n type=\"button\"\n tabIndex={-1}\n className=\"ndl-scroll-icon-wrapper\"\n onClick={onClick}\n aria-hidden=\"true\"\n >\n <Icon className=\"ndl-scroll-icon\" />\n </button>\n </div>\n );\n};\n\ntype TabId = string;\ntype Size = 'small' | 'large';\ntype Fill = 'underline' | 'filled';\n\ntype BaseTabsProps<T extends TabId> = {\n /** The currently active tabId */\n value: T;\n /** Callback function triggered when a new tab is selected */\n onChange: (event: T) => void;\n /** The content dislayed in the tabs */\n children: React.ReactNode | string;\n /** The fill type of the tabs */\n fill?: Fill;\n /** The size of the tabs */\n size?: Size;\n /** What background the Tabs is placed on. This affects the gradient background of the scroll navigation buttons. */\n onBackground?: 'weak' | 'default';\n};\n\ntype TabsContextType<T extends TabId> = Required<\n Pick<BaseTabsProps<T>, 'fill' | 'size' | 'onChange' | 'value'>\n> & {\n registerTab: (tabId: T, ref: React.RefObject<HTMLElement | null>) => void;\n unregisterTab: (tabId: T) => void;\n scrollTabIntoView: (tabId: T) => void;\n firstTabId: T | null;\n isValuePresent: boolean;\n};\n\n// oxlint-disable-next-line @typescript-eslint/no-explicit-any\nconst TabsContext = React.createContext<TabsContextType<any> | null>(null);\n\nconst useTabsContext = () => {\n const context = useContext(TabsContext);\n\n if (context === null) {\n throw new Error('Tab used without context');\n }\n\n return context;\n};\n\nconst getTabPanelId = (tabId: TabId) => `tabpanel-${tabId}`;\n\nconst getGeneralTabClasses = (size: Size, fill: Fill) => {\n return {\n 'ndl-filled-tab': fill === 'filled',\n 'ndl-large': size === 'large',\n 'ndl-small': size === 'small',\n 'ndl-underline-tab': fill === 'underline',\n };\n};\n\nconst TabsComponent = <U extends TabId, T extends React.ElementType = 'div'>({\n children,\n size = 'large',\n fill = 'underline',\n onChange,\n value,\n onBackground = 'weak',\n className,\n style,\n as,\n htmlAttributes,\n ref,\n ...restProps\n}: PolymorphicCommonProps<T, BaseTabsProps<U>>) => {\n const tabRefs = useRef<Map<U, React.RefObject<HTMLElement | null>>>(\n new Map(),\n );\n const containerRef = useRef<HTMLElement>(null);\n const scrollContainerRef = useRef<HTMLDivElement>(null);\n const mergedRef = useMergeRefs([containerRef, ref]);\n const [firstTabId, setFirstTabId] = useState<U | null>(null);\n const [isValuePresent, setIsValuePresent] = useState(false);\n const valueRef = useRef(value);\n\n // Use the custom hook for scroll overflow behavior\n const { scrollState, scrollToNextItem, checkOverflow } =\n useTabsScrollOverflow(scrollContainerRef);\n\n useEffect(() => {\n valueRef.current = value;\n setIsValuePresent(tabRefs.current.has(value));\n }, [value]);\n\n const registerTab = useCallback(\n (tabId: U, tabRef: React.RefObject<HTMLElement | null>) => {\n tabRefs.current.set(tabId, tabRef);\n const first = tabRefs.current.keys().next().value ?? null;\n setFirstTabId((prev) => (prev === first ? prev : first));\n\n if (tabId === valueRef.current) {\n setIsValuePresent(true);\n }\n },\n [],\n );\n\n const unregisterTab = useCallback((tabId: U) => {\n tabRefs.current.delete(tabId);\n const first = tabRefs.current.keys().next().value ?? null;\n setFirstTabId((prev) => (prev === first ? prev : first));\n\n if (tabId === valueRef.current) {\n setIsValuePresent(false);\n }\n }, []);\n\n // Check overflow when children change\n useEffect(() => {\n checkOverflow();\n }, [checkOverflow, children]);\n\n const scrollTabIntoView = useCallback((tabId: U) => {\n const tabRef = tabRefs.current.get(tabId);\n const scrollContainer = scrollContainerRef.current;\n\n if (tabRef?.current && scrollContainer) {\n const tabRect = tabRef.current.getBoundingClientRect();\n const containerRect = scrollContainer.getBoundingClientRect();\n const containerCenter = containerRect.left + containerRect.width / 2;\n\n const targetScrollLeft =\n scrollContainer.scrollLeft +\n (tabRect.left - containerCenter + tabRect.width / 2);\n\n scrollContainer.scrollTo({\n behavior: 'smooth',\n left: targetScrollLeft,\n });\n }\n }, []);\n\n const handleKeyDown = useCallback(\n (event: React.KeyboardEvent) => {\n if (event.key !== 'ArrowLeft' && event.key !== 'ArrowRight') {\n return;\n }\n\n event.preventDefault();\n\n const tabIds = Array.from(tabRefs.current.keys());\n const focusedElement = document.activeElement;\n\n // Find the currently focused tab\n let currentIndex = -1;\n for (let index = 0; index < tabIds.length; index++) {\n const tabRef = tabRefs.current.get(tabIds[index]);\n if (tabRef?.current === focusedElement) {\n currentIndex = index;\n break;\n }\n }\n\n // If no tab is focused, focus the active tab. Or the first tab if the active tab is not present.\n if (currentIndex === -1) {\n const activeTabRef = tabRefs.current.get(value);\n if (activeTabRef?.current) {\n activeTabRef.current.focus();\n } else if (!isValuePresent && firstTabId !== null) {\n const firstTabRef = tabRefs.current.get(firstTabId);\n if (firstTabRef?.current) {\n firstTabRef.current.focus();\n }\n }\n return;\n }\n\n let nextIndex: number;\n\n if (event.key === 'ArrowRight') {\n nextIndex = currentIndex === tabIds.length - 1 ? 0 : currentIndex + 1;\n } else {\n nextIndex = currentIndex === 0 ? tabIds.length - 1 : currentIndex - 1;\n }\n\n const nextTabId = tabIds[nextIndex];\n const nextTabRef = tabRefs.current.get(nextTabId);\n\n if (nextTabRef?.current) {\n nextTabRef.current.focus();\n scrollTabIntoView(nextTabId);\n }\n },\n [value, scrollTabIntoView, firstTabId, isValuePresent],\n );\n\n const classes = classNames(\n 'ndl-tabs',\n getGeneralTabClasses(size, fill),\n className,\n );\n\n const Component: React.ElementType = as ?? 'div';\n\n return (\n <Component\n className={classes}\n style={style}\n role=\"tablist\"\n aria-orientation=\"horizontal\"\n onKeyDown={handleKeyDown}\n ref={mergedRef}\n {...restProps}\n {...htmlAttributes}\n >\n <ScrollButton\n direction=\"left\"\n isVisible={scrollState.isLeftVisible}\n onClick={() => scrollToNextItem('left')}\n onBackground={onBackground}\n />\n <ScrollButton\n direction=\"right\"\n isVisible={scrollState.isRightVisible}\n onClick={() => scrollToNextItem('right')}\n onBackground={onBackground}\n />\n <TabsContext.Provider\n value={{\n fill,\n firstTabId,\n isValuePresent,\n onChange,\n registerTab,\n scrollTabIntoView,\n size,\n unregisterTab,\n value,\n }}\n >\n <div className=\"ndl-tabs-container\" ref={scrollContainerRef}>\n {children}\n </div>\n </TabsContext.Provider>\n </Component>\n );\n};\n\nTabsComponent.displayName = 'Tabs';\n\n/**\n * @remarks\n * When the `description` prop is set, hovering over the tab will show a tooltip with the text provided in the `description` prop. `tooltipProps` can be used to customize the tooltip appearance. The `TooltipObjectProps` type is defined as: `{ root?: Partial<React.ComponentProps<typeof Tooltip>>; trigger?: Partial<React.ComponentProps<typeof Tooltip.Trigger>>; content?: Partial<React.ComponentProps<typeof Tooltip.Content>>; }`, see the Tooltip component for more details.\n */\ntype TabProps<T extends TabId> = {\n /** The id of the tab */\n id: T;\n /** The content of the tab */\n children: React.ReactNode | string;\n /** A string that will be shown as a tooltip when hovering over the button it also acts as an aria-label- {@link https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-label} */\n description?: string;\n /** Props for the tooltip component. */\n tooltipProps?: TooltipObjectProps;\n /** Trailing content that will be rendered after the tab content. Badges belong here. */\n trailingContent?: React.ReactNode;\n /** Additional class name */\n className?: string;\n /** Whether the tab is disabled */\n isDisabled?: boolean;\n};\n\nconst TabsTab = <\n U extends TabId = TabId,\n T extends React.ElementType = 'button',\n>({\n children,\n id: tabId,\n isDisabled = false,\n className,\n description,\n tooltipProps,\n style,\n as,\n htmlAttributes,\n ref,\n trailingContent,\n ...restProps\n}: PolymorphicCommonProps<T, TabProps<U>>) => {\n const {\n size,\n fill,\n value,\n onChange,\n registerTab,\n unregisterTab,\n scrollTabIntoView,\n firstTabId,\n isValuePresent,\n } = useTabsContext();\n const internalRef = useRef<HTMLElement>(null);\n\n // Create a merged ref that handles both ref objects and ref functions\n const mergedRef = useMergeRefs([\n internalRef as React.RefObject<HTMLElement>,\n ref as React.RefObject<HTMLElement>,\n ]);\n\n // Register/unregister tab for keyboard navigation\n useEffect(() => {\n registerTab(tabId, internalRef);\n\n return () => {\n unregisterTab(tabId);\n };\n }, [tabId, registerTab, unregisterTab]);\n\n const baseClasses = classNames({\n ...getGeneralTabClasses(size, fill),\n 'ndl-disabled': isDisabled,\n 'ndl-selected': value === tabId,\n });\n\n const Component: React.ElementType = as ?? 'button';\n\n const classes = classNames('ndl-tab', baseClasses, className);\n\n // Only the active tab should be in the tab sequence initially\n // Other tabs can be focused via arrow keys but are not in tab sequence\n const tabIndex =\n value === tabId || (!isValuePresent && tabId === firstTabId) ? 0 : -1;\n\n return (\n <Tooltip\n type=\"simple\"\n {...tooltipProps?.root}\n isDisabled={description === undefined}\n >\n <Tooltip.Trigger {...tooltipProps?.trigger} hasButtonWrapper>\n <Component\n className={classes}\n style={style}\n onClick={() => {\n if (!isDisabled) {\n onChange(tabId);\n scrollTabIntoView(tabId);\n }\n }}\n role=\"tab\"\n id={tabId}\n aria-disabled={isDisabled}\n aria-label={description}\n aria-selected={value === tabId}\n aria-controls={getTabPanelId(tabId)}\n tabIndex={tabIndex}\n ref={mergedRef}\n {...restProps}\n {...htmlAttributes}\n >\n <span className=\"ndl-tab-content\">{children}</span>\n {trailingContent}\n {fill === 'underline' && <span className=\"ndl-tab-underline\" />}\n </Component>\n </Tooltip.Trigger>\n <Tooltip.Content {...tooltipProps?.content}>\n {description}\n </Tooltip.Content>\n </Tooltip>\n );\n};\n\nTabsTab.displayName = 'Tabs.Tab';\n\ntype TabPanelProps = {\n /** The content displayed in the tab panel */\n children: React.ReactNode;\n /** The currently selected tabId. The tab is visible if the value is equal to the tabId */\n value: TabId;\n /** The id of the tab panel */\n tabId: TabId;\n /** Additional class name */\n className?: string;\n};\n\nconst TabsTabPanel = <T extends React.ElementType = 'div'>({\n as,\n children,\n value,\n tabId,\n style,\n className,\n htmlAttributes,\n ref,\n ...restProps\n}: PolymorphicCommonProps<T, TabPanelProps>) => {\n const Component: React.ElementType = as ?? 'div';\n\n return (\n <>\n {value === tabId ? (\n <Component\n role=\"tabpanel\"\n id={getTabPanelId(tabId)}\n aria-labelledby={tabId}\n style={style}\n className={classNames(className)}\n ref={ref}\n {...restProps}\n {...htmlAttributes}\n >\n {children}\n </Component>\n ) : null}\n </>\n );\n};\n\nTabsTabPanel.displayName = 'Tabs.TabPanel';\n\ntype TabBadgeProps = {\n /** The content of the badge */\n children: React.ReactNode;\n};\n\nconst TabBadge = ({\n children,\n ref,\n htmlAttributes,\n style,\n className,\n ...restProps\n}: CommonProps<'span', TabBadgeProps>) => {\n const classes = classNames('ndl-tab-badge', className);\n return (\n <Typography\n ref={ref}\n variant=\"subheading-medium\"\n className={classes}\n style={style}\n htmlAttributes={htmlAttributes}\n {...restProps}\n >\n {children}\n </Typography>\n );\n};\n\nconst Tabs = Object.assign(TabsComponent, {\n Badge: TabBadge,\n Tab: TabsTab,\n TabPanel: TabsTabPanel,\n});\n\nexport { Tabs };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuIE;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;;;CA2MA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;;;CAmGA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;;;CAiCA;CACA;CACA;CACA;CACA;;AA3cF,MAAM,gBAAgB,EACpB,WACA,WACA,SACA,mBAMI;CACJ,MAAM,OACJ,cAAc,SACVA,6DAAAA,6BACAC,8DAAAA;CAIN,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;EACE,YAAA,GAAWC,WAAAA,QAAAA,CAAW,mBAJxB,cAAc,SAAS,yBAAyB,yBAIU;GACtD,0BAA0B,CAAC;GAC3B,yCAAyC,iBAAiB;GAC1D,sCAAsC,iBAAiB;EACzD,CAAC;EAED,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAAC,UAAD;GACE,MAAK;GACL,UAAU;GACV,WAAU;GACD;GACT,eAAY;GAEZ,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAAC,MAAD,EAAM,WAAU,kBAAmB,CAAA;EAC7B,CAAA;CACL,CAAA;AAET;AAgCA,MAAM,cAAcC,MAAAA,QAAM,cAA2C,IAAI;AAEzE,MAAM,uBAAuB;CAC3B,MAAM,WAAA,GAAUC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AAA,QAAA,CAAA,GAAA,iBAAA,QAAA,iBAAA,KAAA,IAAA,KAAA,IAAY,aAAc,OAAA,GAAA,CAAA,GAAA,EAAA,UAChC,YAAA,CACc,CAAA,CACV;;AAEb;AAEA,QAAQ,cAAc;AAatB,MAAM,gBAAqD,UAUX;CAVW,IAAA,EACzD,IACA,UACA,OACA,OACA,OACA,WACA,gBACA,QAAA,OACG,YAAA,gCAAA,QAAA,OAAA,UAAA;CAIH,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAA,kBAAA,UAAA,EAAA,UACG,UAAU,QACT,iBAAA,GAAA,kBAAA,IAAA,CAL+B,OAAA,QAAA,OAAA,KAAA,IAAA,KAAM,OAAA,sBAAA,QAAA,sBAAA,QAAA,sBAAA,QAAA;EAMnC,MAAK;EACL,IAAI,cAAc,KAAK;EACvB,mBAAiB;EACV;EACP,YAAA,GAAWR,WAAAA,QAAAA,CAAW,SAAS;EAC1B;CACD,GAAA,SAAA,GACA,cAAA,GAAA,CAAA,GAAA,EAEH,SAAA,CACQ,CAAA,IACT,KACJ,CAAA;AAEN;AAEA,aAAa,cAAc;AAO3B,MAAM,YAAY,UAOwB;CAPxB,IAAA,EAChB,UACA,KACA,gBACA,OACA,cAAA,OACG,YAAA,gCAAA,QAAA,OAAA,UAAA;CAEH,MAAM,WAAA,GAAUA,WAAAA,QAAAA,CAAW,iBAAiB,SAAS;CACrD,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACS,8BAAAA,YAAAA,sBAAAA,QAAAA,sBAAAA,QAAAA;EACM;EACL,SAAQ;EACR,WAAW;EACJ;EACS;CACZ,GAAA,SAAA,GAAA,CAAA,GAAA,EAEH,SAAA,CACS,CAAA;AAEhB;AAEA,MAAM,OAAO,OAAO,OAAO,eAAe;CACxC,OAAO;CACP,KAAK;CACL,UAAU;AACZ,CAAC"}
@@ -170,7 +170,7 @@ const TooltipContent = (_ref2) => {
170
170
  });
171
171
  };
172
172
  const TooltipHeader = (_ref3) => {
173
- let { children, passThroughProps, typographyVariant = "subheading-medium", className, style, htmlAttributes, ref } = _ref3, restProps = require_objectWithoutProperties.default(_ref3, _excluded3);
173
+ let { children, passThroughProps, typographyVariant = "subheading-large", className, style, htmlAttributes, ref } = _ref3, restProps = require_objectWithoutProperties.default(_ref3, _excluded3);
174
174
  const context = require_tooltip_use_tooltip.useTooltipContext();
175
175
  const classes = (0, classnames.default)("ndl-tooltip-header", className);
176
176
  (0, react.useEffect)(() => {
@@ -1 +1 @@
1
- {"version":3,"file":"Tooltip.js","names":["useIsInsideDialog","useTooltip","TooltipContext","useTooltipContext","useMergeRefs","classNames","React","useNeedleTheme","ConditionalWrap","FloatingPortal","Typography","FloatingFocusManager"],"sources":["../../../src/tooltip/Tooltip.tsx"],"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 /**\n * Visual style of the tooltip content. `simple` renders plain text, `rich` renders a composable panel\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 /**\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 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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+HE;CACA;CACA;CACA;CACA;CACA;;;CAuDA;CACA;CACA;CACA;CACA;;;CAmGA;CACA;CACA;CACA;CACA;CACA;CACA;;;CAwCA;CACA;CACA;CACA;CACA;CACA;;;CA+BA;CACA;CACA;CACA;CACA;;AA7SF,MAAM,oBAAoB,EACxB,UACA,aAAa,OACb,MACA,eACA,WACA,QACA,cACA,YAAY,gBACZ,kBAAkB,cAClB,YACA,6BACA,mBACA,mBACkB;CAClB,MAAM,iBAAiBA,8BAAAA,kBAAkB;CAIzC,MAAM,UAAUC,4BAAAA,WAAW;EACzB;EACA;EACA;EACA;EACA;EAEA,QAAQ,eAAe,OAAO,QAAQ;EACtC,YAAY,mBAAA,QAAA,mBAAA,KAAA,IAAA,iBAAkB,CAVZ;EAWlB;EACA;EACA;EACA,UAAU,iBAAA,QAAA,iBAAA,KAAA,IAAA,eAfK,iBAAiB,UAAU;EAgB1C;CACF,CAAC;CAED,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACC,4BAAAA,eAAe,UAAhB;EAAyB,OAAO;EAC7B;CACsB,CAAA;AAE7B;AAEA,iBAAiB,cAAc;AAS/B,MAAM,kBAAkB,SAQ0B;CAR1B,IAAA,EACtB,UACA,mBAAmB,OACnB,gBACA,WACA,OACA,QAAA,MACG,YAAA,gCAAA,QAAA,MAAA,SAAA;CAEH,MAAM,UAAUC,4BAAAA,kBAAkB;CAIlC,MAAM,gBAAiB,SAAiB;CACxC,MAAM,cAAA,GAAaC,mBAAAA,aAAAA,CAAa;EAC9B,QAAQ,KAAK;EACb;EACA,kBAAA,QAAA,kBAAA,KAAA,IAAA,KAAA,IAAA,cAAe;CACjB,CAAC;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ergeRefs","classNames","React","useNeedleTheme","ConditionalWrap","FloatingPortal","Typography","FloatingFocusManager"],"sources":["../../../src/tooltip/Tooltip.tsx"],"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 /**\n * Visual style of the tooltip content. `simple` renders plain text, `rich` renders a composable panel\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 /**\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-large',\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 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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+HE;CACA;CACA;CACA;CACA;CACA;;;CAuDA;CACA;CACA;CACA;CACA;;;CAmGA;CACA;CACA;CACA;CACA;CACA;CACA;;;CAwCA;CACA;CACA;CACA;CACA;CACA;;;CA+BA;CACA;CACA;CACA;CACA;;A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A,QAAAA,sBAAAA,QAAAA,sBAAAA,QAAAA;EACM;EACL,SAAQ;EACR,WAAW;EACJ;EACS;CACZ,GAAA,gBAAA,GACA,SAAA,GAAA,CAAA,GAAA,EAEH,SAAA,CACS,CAAA;AAEhB;AAOA,MAAM,WAAW,UAO8B;CAP9B,IAAA,EACf,UACA,WACA,OACA,gBACA,QAAA,OACG,YAAA,gCAAA,QAAA,OAAA,UAAA;CAEH,MAAM,UAAUP,4BAAAA,kBAAkB;CAClC,MAAM,cAAA,GAAaC,mBAAAA,aAAAA,CAAa,CAAC,QAAQ,KAAK,aAAa,GAAG,CAAC;CAE/D,IAAI,CAAC,QAAQ,QACX,OAAO;CAGT,MAAM,WAAA,GAAUC,WAAAA,QAAAA,CAAW,uBAAuB,SAAS;CAE3D,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAA,sBAAA,QAAA,sBAAA,QAAA,sBAAA,QAAA;EACC,WAAW;EACX,KAAK;EACE;CACH,GAAA,SAAA,GACA,cAAA,GAAA,CAAA,GAAA,EAEH,SAAA,CACE,CAAA;AAET;AAEA,QAAQ,cAAc;AAEtB,MAAM,UAAU,OAAO,OAAO,kBAAkB;CACrC;CACT,MAAM;CACN,SAAS;CACT,QAAQ;CACR,SAAS;AACX,CAAC"}
@@ -189,7 +189,7 @@ const TreeViewTextItem = (_ref) => {
189
189
  children
190
190
  }),
191
191
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_typography_Typography.Typography, {
192
- variant: item.canHaveSubItems ? "subheading-small" : "body-medium",
192
+ variant: item.canHaveSubItems ? "subheading-medium" : "body-medium",
193
193
  htmlAttributes: { style: {
194
194
  overflow: "hidden",
195
195
  textOverflow: "ellipsis",
@@ -1 +1 @@
1
- {"version":3,"file":"TreeViewTextItem.js","names":["TreeItemWrapper","ChevronRightIconOutline","ChevronDownIconOutline","Skeleton","Checkbox","ConditionalWrap","Typography","CleanIconButton"],"sources":["../../../src/tree-view/TreeViewTextItem.tsx"],"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 type React from 'react';\n\nimport { Checkbox } from '../checkbox';\nimport { CleanIconButton } from '../clean-icon-button';\nimport { ConditionalWrap } from '../conditional-wrap';\nimport { ChevronDownIconOutline } from '../icons/generated/heroIcons/ChevronDownIconOutline';\nimport { ChevronRightIconOutline } from '../icons/generated/heroIcons/ChevronRightIconOutline';\nimport { Skeleton } from '../skeleton';\nimport { Typography } from '../typography';\nimport {\n type FlattenedTreeItem,\n type TextItemData,\n type TreeItemComponentProps,\n} from './tree-view-types';\nimport { TreeItemWrapper } from './TreeItemWrapper';\n\n/**\n * checks if any parent is checked\n * @param item - Tree item\n * @param items - Flattened tree items\n * @returns\n */\nconst parentIsCheckedRecursively = (\n item: FlattenedTreeItem<TextItemData>,\n items: FlattenedTreeItem<TextItemData>[],\n): boolean => {\n const parent = items.find((parentItem) => parentItem.id === item.parentId);\n if (parent) {\n if (parent.isSelected) {\n return true;\n }\n return parentIsCheckedRecursively(parent, items);\n }\n return false;\n};\n\n/**\n * checks if any children are checked\n * @param item - Tree item\n * @param items - Flattened tree items\n * @returns\n */\nconst childrenCheckedRecursively = (\n item: FlattenedTreeItem<TextItemData>,\n items: FlattenedTreeItem<TextItemData>[],\n): boolean => {\n const children = items.filter((childItem) => childItem.parentId === item.id);\n if (children.length === 0) {\n return false;\n }\n return children.some(\n (childItem) =>\n childItem.isSelected || childrenCheckedRecursively(childItem, items),\n );\n};\n\nexport const TreeViewTextItem = <T extends TextItemData>({\n depth,\n shouldDisableInteraction,\n shouldDisableSorting,\n isGhost,\n indentationWidth,\n isIndicator,\n isCollapsed,\n onCollapse,\n item,\n parent,\n isOver,\n isOverParent,\n setNodeRef,\n setActivatorNodeRef,\n dragHandleProps,\n style,\n trails,\n onItemsChanged,\n items,\n tabIndex,\n ref,\n ...restProps\n}: TreeItemComponentProps<T> & { ref?: React.Ref<HTMLElement> }) => {\n const isAnyParentChecked = parentIsCheckedRecursively(item, items);\n const isAnyChildChecked = childrenCheckedRecursively(item, items);\n\n const isIndeterminate =\n isAnyChildChecked === true &&\n isAnyParentChecked === false &&\n item.isSelected === false\n ? true\n : false;\n\n return (\n <TreeItemWrapper\n depth={depth}\n shouldDisableInteraction={shouldDisableInteraction}\n shouldDisableSorting={shouldDisableSorting}\n isGhost={isGhost}\n indentationWidth={indentationWidth}\n isIndicator={isIndicator}\n isCollapsed={isCollapsed}\n onCollapse={onCollapse}\n item={item}\n parent={parent}\n isOver={isOver}\n isOverParent={isOverParent}\n setNodeRef={setNodeRef}\n setActivatorNodeRef={setActivatorNodeRef}\n dragHandleProps={dragHandleProps}\n style={style}\n trails={trails}\n // oxlint-disable-next-line @typescript-eslint/no-empty-function\n onItemsChanged={() => {}}\n ref={ref}\n items={items}\n tabIndex={tabIndex}\n {...restProps}\n >\n {item.canHaveSubItems && onCollapse && (\n <button\n type=\"button\"\n className=\"ndl-tree-view-collapse-button\"\n onClick={() => onCollapse()}\n aria-label={item.isCollapsed ? 'Expand' : 'Collapse'}\n aria-expanded={item.isCollapsed ? 'false' : 'true'}\n /**\n * Tab index is set to -1 to prevent the item from being focused when the tree is navigated with tab\n * since we use the arrow keys instead\n */\n tabIndex={tabIndex}\n >\n {item.isCollapsed && <ChevronRightIconOutline className=\"ndl-icon\" />}\n {!item.isCollapsed && <ChevronDownIconOutline className=\"ndl-icon\" />}\n </button>\n )}\n {item.isSelected !== undefined && (\n <Skeleton\n onBackground=\"weak\"\n shape=\"rectangular\"\n {...item.skeletonProps}\n isLoading={item.isSkeletonLoading}\n >\n <Checkbox\n isIndeterminate={isIndeterminate}\n isChecked={item.isSelected}\n ariaLabel={item.data.text}\n htmlAttributes={{\n tabIndex,\n }}\n onChange={(event) => {\n const newItems = items.map((treeItem) => {\n if (treeItem.id === item.id) {\n return {\n ...treeItem,\n isSelected: event.target.checked,\n };\n }\n return treeItem;\n });\n\n // Uncheck parents if a child is unchecked\n if (!event.target.checked) {\n let parentId = item.parentId;\n while (parentId !== null) {\n const parent = newItems.find(\n (newItem) => newItem.id === parentId,\n );\n if (parent) {\n newItems.forEach((newItem) => {\n if (newItem.id === parent.id) {\n newItem.isSelected = false;\n }\n });\n parentId = parent.parentId;\n } else {\n parentId = null;\n }\n }\n }\n // Check children if a parent is checked\n if (item.canHaveSubItems) {\n const childIdsToUncheck = items\n .filter((childItem) => childItem.parentId === item.id)\n .map((childItem) => childItem.id);\n while (childIdsToUncheck.length > 0) {\n const childId = childIdsToUncheck.pop();\n const child = items.find(\n (childItem) => childItem.id === childId,\n );\n if (child) {\n newItems.forEach((newItem) => {\n if (newItem.id === child.id) {\n newItem.isSelected = event.target.checked;\n }\n });\n newItems\n .filter((childItem) => childItem.parentId === child.id)\n .forEach((childItem) => {\n childIdsToUncheck.push(childItem.id);\n });\n }\n }\n }\n onItemsChanged(newItems, { item, reason: 'selected' });\n }}\n aria-label={item.data.text}\n />\n </Skeleton>\n )}\n\n <Skeleton\n onBackground=\"weak\"\n shape=\"rectangular\"\n height=\"20px\"\n {...item.skeletonProps}\n isLoading={item.isSkeletonLoading}\n >\n <ConditionalWrap\n shouldWrap={item.data.onTextClick !== undefined}\n wrap={(children) => (\n <button\n type=\"button\"\n onClick={item.data.onTextClick}\n className=\"ndl-tree-view-text-clickable\"\n tabIndex={tabIndex}\n >\n {children}\n </button>\n )}\n >\n <Typography\n variant={item.canHaveSubItems ? 'subheading-small' : 'body-medium'}\n htmlAttributes={{\n style: {\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n },\n }}\n >\n {item.data.text}\n </Typography>\n </ConditionalWrap>\n </Skeleton>\n <div className=\"ndl-tree-view-actions\">\n {item.data.actions &&\n item.data.actions.map((action, index) => {\n return (\n <CleanIconButton\n key={index}\n className=\"ndl-tree-view-action\"\n size=\"small\"\n {...action.buttonProps}\n htmlAttributes={{\n tabIndex,\n ...action.buttonProps.htmlAttributes,\n }}\n >\n {action.icon}\n </CleanIconButton>\n );\n })}\n </div>\n </TreeItemWrapper>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;CA6EE;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAvDF,MAAM,8BACJ,MACA,UACY;CACZ,MAAM,SAAS,MAAM,MAAM,eAAe,WAAW,OAAO,KAAK,QAAQ;CACzE,IAAI,QAAQ;EACV,IAAI,OAAO,YACT,OAAO;EAET,OAAO,2BAA2B,QAAQ,KAAK;CACjD;CACA,OAAO;AACT;;;;;;;AAQA,MAAM,8BACJ,MACA,UACY;CACZ,MAAM,WAAW,MAAM,QAAQ,cAAc,UAAU,aAAa,KAAK,EAAE;CAC3E,IAAI,SAAS,WAAW,GACtB,OAAO;CAET,OAAO,SAAS,MACb,cACC,UAAU,cAAc,2BAA2B,WAAW,KAAK,CACvE;AACF;AAEA,MAAa,oBAA4C,SAuBW;CAvBX,IAAA,EACvD,OACA,0BACA,sBACA,SACA,kBACA,aACA,aACA,YACA,MACA,QACA,QACA,cACA,YACA,qBACA,iBACA,OACA,QACA,gBACA,OACA,UACA,QAAA,MACG,YAAA,gCAAA,QAAA,MAAA,SAAA;CAEH,MAAM,qBAAqB,2BAA2B,MAAM,KAAK;CAGjE,MAAM,kBAFoB,2BAA2B,MAAM,KAGzC,MAAM,QACtB,uBAAuB,SACvB,KAAK,eAAe,QAChB,OAC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ET;IACK,CAAA;IAGV,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAACC,8BAAAA,YAAD;KACE,SAAS,KAAK,kBAAkB,qBAAqB;KACrD,gBAAgB,EACd,OAAO;MACL,UAAU;MACV,cAAc;MACd,YAAY;KACd,EACF;KAEC,UAAA,KAAK,KAAK;IACD,CAAA;GACG,CAAA;EACT,CAAA,CAAA;EACV,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;GAAK,WAAU;GACZ,UAAA,KAAK,KAAK,WACT,KAAK,KAAK,QAAQ,KAAK,QAAQ,UAAU;IACvC,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACC,0CAAAA,iBAAAA,sBAAAA,QAAAA,sBAAAA,QAAAA;KAEC,WAAU;KACV,MAAK;IACD,GAAA,OAAO,WAAA,GAAA,CAAA,GAAA;KACX,gBAAA,sBAAA,QAAA,EACE,SAAA,GACG,OAAO,YAAY,cACxB;KAEC,UAAA,OAAO;IACO,CAAA,GAVV,KAUU;GAErB,CAAC;EACA,CAAA;CACU,EAAA,CAAA,CAAA;AAErB"}
1
+ {"version":3,"file":"TreeViewTextItem.js","names":["TreeItemWrapper","ChevronRightIconOutline","ChevronDownIconOutline","Skeleton","Checkbox","ConditionalWrap","Typography","CleanIconButton"],"sources":["../../../src/tree-view/TreeViewTextItem.tsx"],"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 type React from 'react';\n\nimport { Checkbox } from '../checkbox';\nimport { CleanIconButton } from '../clean-icon-button';\nimport { ConditionalWrap } from '../conditional-wrap';\nimport { ChevronDownIconOutline } from '../icons/generated/heroIcons/ChevronDownIconOutline';\nimport { ChevronRightIconOutline } from '../icons/generated/heroIcons/ChevronRightIconOutline';\nimport { Skeleton } from '../skeleton';\nimport { Typography } from '../typography';\nimport {\n type FlattenedTreeItem,\n type TextItemData,\n type TreeItemComponentProps,\n} from './tree-view-types';\nimport { TreeItemWrapper } from './TreeItemWrapper';\n\n/**\n * checks if any parent is checked\n * @param item - Tree item\n * @param items - Flattened tree items\n * @returns\n */\nconst parentIsCheckedRecursively = (\n item: FlattenedTreeItem<TextItemData>,\n items: FlattenedTreeItem<TextItemData>[],\n): boolean => {\n const parent = items.find((parentItem) => parentItem.id === item.parentId);\n if (parent) {\n if (parent.isSelected) {\n return true;\n }\n return parentIsCheckedRecursively(parent, items);\n }\n return false;\n};\n\n/**\n * checks if any children are checked\n * @param item - Tree item\n * @param items - Flattened tree items\n * @returns\n */\nconst childrenCheckedRecursively = (\n item: FlattenedTreeItem<TextItemData>,\n items: FlattenedTreeItem<TextItemData>[],\n): boolean => {\n const children = items.filter((childItem) => childItem.parentId === item.id);\n if (children.length === 0) {\n return false;\n }\n return children.some(\n (childItem) =>\n childItem.isSelected || childrenCheckedRecursively(childItem, items),\n );\n};\n\nexport const TreeViewTextItem = <T extends TextItemData>({\n depth,\n shouldDisableInteraction,\n shouldDisableSorting,\n isGhost,\n indentationWidth,\n isIndicator,\n isCollapsed,\n onCollapse,\n item,\n parent,\n isOver,\n isOverParent,\n setNodeRef,\n setActivatorNodeRef,\n dragHandleProps,\n style,\n trails,\n onItemsChanged,\n items,\n tabIndex,\n ref,\n ...restProps\n}: TreeItemComponentProps<T> & { ref?: React.Ref<HTMLElement> }) => {\n const isAnyParentChecked = parentIsCheckedRecursively(item, items);\n const isAnyChildChecked = childrenCheckedRecursively(item, items);\n\n const isIndeterminate =\n isAnyChildChecked === true &&\n isAnyParentChecked === false &&\n item.isSelected === false\n ? true\n : false;\n\n return (\n <TreeItemWrapper\n depth={depth}\n shouldDisableInteraction={shouldDisableInteraction}\n shouldDisableSorting={shouldDisableSorting}\n isGhost={isGhost}\n indentationWidth={indentationWidth}\n isIndicator={isIndicator}\n isCollapsed={isCollapsed}\n onCollapse={onCollapse}\n item={item}\n parent={parent}\n isOver={isOver}\n isOverParent={isOverParent}\n setNodeRef={setNodeRef}\n setActivatorNodeRef={setActivatorNodeRef}\n dragHandleProps={dragHandleProps}\n style={style}\n trails={trails}\n // oxlint-disable-next-line @typescript-eslint/no-empty-function\n onItemsChanged={() => {}}\n ref={ref}\n items={items}\n tabIndex={tabIndex}\n {...restProps}\n >\n {item.canHaveSubItems && onCollapse && (\n <button\n type=\"button\"\n className=\"ndl-tree-view-collapse-button\"\n onClick={() => onCollapse()}\n aria-label={item.isCollapsed ? 'Expand' : 'Collapse'}\n aria-expanded={item.isCollapsed ? 'false' : 'true'}\n /**\n * Tab index is set to -1 to prevent the item from being focused when the tree is navigated with tab\n * since we use the arrow keys instead\n */\n tabIndex={tabIndex}\n >\n {item.isCollapsed && <ChevronRightIconOutline className=\"ndl-icon\" />}\n {!item.isCollapsed && <ChevronDownIconOutline className=\"ndl-icon\" />}\n </button>\n )}\n {item.isSelected !== undefined && (\n <Skeleton\n onBackground=\"weak\"\n shape=\"rectangular\"\n {...item.skeletonProps}\n isLoading={item.isSkeletonLoading}\n >\n <Checkbox\n isIndeterminate={isIndeterminate}\n isChecked={item.isSelected}\n ariaLabel={item.data.text}\n htmlAttributes={{\n tabIndex,\n }}\n onChange={(event) => {\n const newItems = items.map((treeItem) => {\n if (treeItem.id === item.id) {\n return {\n ...treeItem,\n isSelected: event.target.checked,\n };\n }\n return treeItem;\n });\n\n // Uncheck parents if a child is unchecked\n if (!event.target.checked) {\n let parentId = item.parentId;\n while (parentId !== null) {\n const parent = newItems.find(\n (newItem) => newItem.id === parentId,\n );\n if (parent) {\n newItems.forEach((newItem) => {\n if (newItem.id === parent.id) {\n newItem.isSelected = false;\n }\n });\n parentId = parent.parentId;\n } else {\n parentId = null;\n }\n }\n }\n // Check children if a parent is checked\n if (item.canHaveSubItems) {\n const childIdsToUncheck = items\n .filter((childItem) => childItem.parentId === item.id)\n .map((childItem) => childItem.id);\n while (childIdsToUncheck.length > 0) {\n const childId = childIdsToUncheck.pop();\n const child = items.find(\n (childItem) => childItem.id === childId,\n );\n if (child) {\n newItems.forEach((newItem) => {\n if (newItem.id === child.id) {\n newItem.isSelected = event.target.checked;\n }\n });\n newItems\n .filter((childItem) => childItem.parentId === child.id)\n .forEach((childItem) => {\n childIdsToUncheck.push(childItem.id);\n });\n }\n }\n }\n onItemsChanged(newItems, { item, reason: 'selected' });\n }}\n aria-label={item.data.text}\n />\n </Skeleton>\n )}\n\n <Skeleton\n onBackground=\"weak\"\n shape=\"rectangular\"\n height=\"20px\"\n {...item.skeletonProps}\n isLoading={item.isSkeletonLoading}\n >\n <ConditionalWrap\n shouldWrap={item.data.onTextClick !== undefined}\n wrap={(children) => (\n <button\n type=\"button\"\n onClick={item.data.onTextClick}\n className=\"ndl-tree-view-text-clickable\"\n tabIndex={tabIndex}\n >\n {children}\n </button>\n )}\n >\n <Typography\n variant={item.canHaveSubItems ? 'subheading-medium' : 'body-medium'}\n htmlAttributes={{\n style: {\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n },\n }}\n >\n {item.data.text}\n </Typography>\n </ConditionalWrap>\n </Skeleton>\n <div className=\"ndl-tree-view-actions\">\n {item.data.actions &&\n item.data.actions.map((action, index) => {\n return (\n <CleanIconButton\n key={index}\n className=\"ndl-tree-view-action\"\n size=\"small\"\n {...action.buttonProps}\n htmlAttributes={{\n tabIndex,\n ...action.buttonProps.htmlAttributes,\n }}\n >\n {action.icon}\n </CleanIconButton>\n );\n })}\n </div>\n </TreeItemWrapper>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;CA6EE;CACA;CACA;CACA;CACA;CAC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AAAA,iBAAAA,sBAAAA,QAAAA,sBAAAA,QAAAA;KAEC,WAAU;KACV,MAAK;IACD,GAAA,OAAO,WAAA,GAAA,CAAA,GAAA;KACX,gBAAA,sBAAA,QAAA,EACE,SAAA,GACG,OAAO,YAAY,cACxB;KAEC,UAAA,OAAO;IACO,CAAA,GAVV,KAUU;GAErB,CAAC;EACA,CAAA;CACU,EAAA,CAAA,CAAA;AAErB"}
@@ -100,7 +100,7 @@ const AccordionComponent = function AccordionComponent(_ref) {
100
100
  }) }));
101
101
  };
102
102
  const createItemId = (type, id) => `ndl-accordionitem${type}id-${id}`;
103
- const BaseAccordionItem = ({ itemId, children, title, className = "", arrowPosition = "leading", isDisabled = false, onExpandedChange, htmlAttributes, style, as, titleTypographyVariant = "subheading-medium", hasDivider = true, trailingContent, headingLevel = 2 }) => {
103
+ const BaseAccordionItem = ({ itemId, children, title, className = "", arrowPosition = "leading", isDisabled = false, onExpandedChange, htmlAttributes, style, as, titleTypographyVariant = "subheading-large", hasDivider = true, trailingContent, headingLevel = 2 }) => {
104
104
  const contentRef = useRef(null);
105
105
  const innerContentRef = useRef(null);
106
106
  const itemElementId = createItemId("item", itemId);
@@ -213,7 +213,7 @@ const BaseAccordionItem = ({ itemId, children, title, className = "", arrowPosit
213
213
  * @remarks
214
214
  * Where `T` is of the type `string | number | undefined`.
215
215
  *
216
- * `TypographyVariants` is of the type `'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'subheading-large' | 'subheading-medium' | 'subheading-small' | 'body-large' | 'body-medium' | 'body-small' | 'code' | 'label'`.
216
+ * `TypographyVariants` is of the type `'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'subheading-large' | 'subheading-medium' | 'subheading-small' | 'body-large' | 'body-medium' | 'body-small' | 'code'`.
217
217
  */
218
218
  const AccordionItem = (_ref3) => {
219
219
  let { className } = _ref3, restProps = _objectWithoutProperties(_ref3, _excluded3);
@@ -1 +1 @@
1
- {"version":3,"file":"Accordion.mjs","names":[],"sources":["../../../src/accordion/Accordion.tsx"],"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 classNames from 'classnames';\nimport type React from 'react';\nimport { useCallback, useImperativeHandle, useRef } from 'react';\n\nimport { type PolymorphicCommonProps } from '../_common/types';\nimport { findUntil } from '../_common/utils';\nimport { Divider } from '../divider';\nimport { ChevronDownIconOutline } from '../icons/generated/heroIcons/ChevronDownIconOutline';\nimport { Typography } from '../typography';\nimport { AccordionContext, useAccordionContext } from './accordion-context';\nimport {\n type AccordionItemId,\n type AccordionItemProps,\n type AccordionProps,\n type ClassicItemProps,\n type IsMultiple,\n type IsNotMultiple,\n} from './accordion-types';\n\nenum AccordionSelector {\n Item = '.ndl-accordion-item',\n ItemNotDisabled = '.ndl-accordion-item:not(.ndl-accordion-item-disabled)',\n}\n\nconst getAccordionItem = (\n accordionElement: Element,\n selector: string,\n direction: 'next' | 'prev' = 'next',\n): Element | null => {\n const itemParent = accordionElement.closest(AccordionSelector.Item);\n if (!itemParent) {\n return null;\n }\n\n return findUntil(direction, itemParent, selector);\n};\n\nconst AccordionComponent = function AccordionComponent<\n T extends AccordionItemId,\n U extends React.ElementType = 'div',\n>({\n children,\n as,\n isMultiple,\n onChange,\n className,\n style,\n htmlAttributes,\n ref,\n ...restProps\n}: PolymorphicCommonProps<U, AccordionProps<T>>) {\n const accordionRef = useRef<U>(null);\n\n useImperativeHandle(ref, () => accordionRef.current!);\n\n const Component: React.ElementType = as || 'div';\n\n // The following function includes code needed to be\n // able to navigate with the arrow keys (not tab).\n const handleKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {\n const accordionElement = accordionRef.current;\n if (!accordionElement) {\n return;\n }\n const activeElement = document.activeElement as HTMLElement;\n if (event.key === 'ArrowDown') {\n event.preventDefault();\n event.stopPropagation();\n const newFocusedElement = getAccordionItem(\n activeElement,\n AccordionSelector.ItemNotDisabled,\n 'next',\n );\n const newHeader = newFocusedElement?.firstElementChild;\n\n if (newHeader && newHeader instanceof HTMLElement) {\n focusAccordionItem(newHeader as HTMLElement);\n }\n } else if (event.key === 'ArrowUp') {\n event.preventDefault();\n event.stopPropagation();\n const newFocusedElement = getAccordionItem(\n activeElement,\n AccordionSelector.ItemNotDisabled,\n 'prev',\n );\n const newHeader = newFocusedElement?.firstElementChild;\n\n if (newHeader && newHeader instanceof HTMLElement) {\n focusAccordionItem(newHeader as HTMLElement);\n }\n } else if (event.key === ' ' || event.key === 'Enter') {\n event.preventDefault();\n event.stopPropagation();\n activeElement.click();\n }\n };\n\n const focusAccordionItem = (accordionHtmlElement: HTMLElement) => {\n const accordionButton = accordionHtmlElement\n .getElementsByClassName('ndl-accordion-item-header-button')\n .item(0);\n\n if (accordionButton !== null && accordionButton instanceof HTMLElement) {\n accordionButton.focus();\n }\n };\n\n const classes = classNames('ndl-accordion', className);\n\n // Destructure and omit keys from DOM spread\n const { expandedItemIds, expandedItemId, ...restAccordionProps } =\n restProps as Record<string, unknown> as {\n expandedItemIds?: T[];\n expandedItemId?: T | null;\n [key: string]: unknown;\n };\n\n const contextValue = isMultiple\n ? ({\n expandedItemIds,\n isMultiple,\n onChange,\n } as IsMultiple<T>)\n : ({\n expandedItemId,\n isMultiple,\n onChange,\n } as IsNotMultiple<T>);\n\n return (\n <Component\n className={classes}\n style={style}\n ref={accordionRef}\n onKeyDown={handleKeyDown}\n role=\"presentation\"\n {...restAccordionProps}\n {...htmlAttributes}\n >\n <AccordionContext.Provider value={contextValue}>\n {children}\n </AccordionContext.Provider>\n </Component>\n );\n};\n\nconst createItemId = (type: string, id: AccordionItemId) =>\n `ndl-accordionitem${type}id-${id}`;\n\nconst BaseAccordionItem = <\n T extends AccordionItemId,\n U extends React.ElementType = 'div',\n>({\n itemId,\n children,\n title,\n className = '',\n arrowPosition = 'leading',\n isDisabled = false,\n onExpandedChange,\n htmlAttributes,\n style,\n as,\n titleTypographyVariant = 'subheading-medium',\n hasDivider = true,\n trailingContent,\n headingLevel = 2,\n}: PolymorphicCommonProps<U, AccordionItemProps<T>>) => {\n const contentRef = useRef<HTMLDivElement>(null);\n const innerContentRef = useRef<HTMLDivElement>(null);\n const itemElementId = createItemId('item', itemId);\n const headerElementId = createItemId('header', itemId);\n const buttonElementId = createItemId('button', itemId);\n const panelElementId = createItemId('panel', itemId);\n const Component: React.ElementType = as || 'div';\n\n const context = useAccordionContext();\n const { isMultiple } = context;\n\n const isExpanded = isMultiple\n ? context.expandedItemIds.includes(itemId)\n : context.expandedItemId === itemId;\n\n const handleOnClick = useCallback(() => {\n if (isDisabled) {\n return;\n }\n\n // Custom callback to call.\n if (onExpandedChange !== undefined) {\n onExpandedChange(!isExpanded);\n }\n\n if (isMultiple) {\n const { expandedItemIds, onChange }: IsMultiple<T> = context;\n // Multiple expanded.\n if (isExpanded) {\n // Remove from list.\n const newArray: T[] = expandedItemIds.filter(\n (activeId) => activeId !== itemId,\n );\n onChange(newArray);\n } else if (!isExpanded) {\n // Add to list.\n const newArray = [...expandedItemIds];\n newArray.push(itemId);\n onChange(newArray);\n }\n } else {\n const { onChange }: IsNotMultiple<T> = context;\n // Single expanded.\n if (isExpanded) {\n // Set null.\n onChange(null);\n } else if (!isExpanded) {\n // Set to id.\n onChange(itemId);\n }\n }\n\n // The W3 WAI-ARIA states that focus can only happen on the header not the header button.\n document.activeElement?.parentElement?.focus();\n }, [isExpanded, isMultiple, isDisabled, itemId, onExpandedChange, context]);\n\n const classes = classNames('ndl-accordion-item', className, {\n 'ndl-accordion-item-disabled': isDisabled,\n 'ndl-accordion-item-expanded': isExpanded,\n });\n\n const headerClasses = classNames('ndl-accordion-item-header', {\n 'ndl-accordion-item-header-disabled': isDisabled,\n });\n\n const iconClasses = classNames('ndl-accordion-item-header-icon-wrapper', {\n 'ndl-accordion-item-header-icon-wrapper-leading':\n arrowPosition === 'leading',\n });\n\n const buttonClasses = classNames('ndl-accordion-item-header-button', {\n 'ndl-accordion-item-header-button-disabled': isDisabled,\n });\n\n const titleClasses = classNames('ndl-accordion-item-header-button-title', {\n 'ndl-accordion-item-header-button-title': isDisabled,\n 'ndl-accordion-item-header-button-title-leading':\n arrowPosition === 'leading',\n });\n\n const contentClasses = classNames('ndl-accordion-item-content', {\n 'ndl-accordion-item-content-expanded': isExpanded,\n 'ndl-accordion-item-content-leading': arrowPosition === 'leading',\n });\n\n return (\n <Component\n className={classes}\n style={style}\n id={itemElementId}\n {...htmlAttributes}\n >\n <div className={headerClasses} id={headerElementId}>\n <Typography\n as={`h${headingLevel}`}\n variant={titleTypographyVariant}\n className=\"ndl-accordion-item-heading\"\n >\n <button\n type=\"button\"\n id={buttonElementId}\n onClick={handleOnClick}\n className={buttonClasses}\n aria-expanded={isExpanded}\n aria-disabled={isDisabled}\n aria-controls={panelElementId}\n disabled={isDisabled}\n >\n <span className={iconClasses}>\n <span className={titleClasses}>{title}</span>\n\n <ChevronDownIconOutline\n className={classNames('ndl-accordion-item-header-icon', {\n 'ndl-expanded': isExpanded,\n })}\n />\n </span>\n </button>\n </Typography>\n {trailingContent && (\n <Typography as=\"div\" variant=\"body-medium\">\n {trailingContent}\n </Typography>\n )}\n </div>\n\n <div\n id={panelElementId}\n ref={contentRef}\n className={contentClasses}\n aria-hidden={!isExpanded}\n aria-labelledby={buttonElementId}\n role=\"region\"\n >\n {/* The <div> element has a child <button> element that allows keyboard interaction */}\n {/* eslint-disable-next-line jsx-a11y/no-static-element-interactions */}\n <div\n ref={innerContentRef}\n className=\"ndl-accordion-item-content-inner\"\n onKeyDown={(event) => event.stopPropagation()}\n >\n <Typography\n variant=\"body-medium\"\n className=\"ndl-accordion-item-content-text\"\n as=\"div\"\n >\n {children}\n </Typography>\n </div>\n </div>\n {hasDivider && <Divider />}\n </Component>\n );\n};\n\n/**\n * @remarks\n * Where `T` is of the type `string | number | undefined`.\n *\n * `TypographyVariants` is of the type `'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'subheading-large' | 'subheading-medium' | 'subheading-small' | 'body-large' | 'body-medium' | 'body-small' | 'code' | 'label'`.\n */\nconst AccordionItem = <\n T extends AccordionItemId,\n U extends React.ElementType = 'div',\n>({\n className,\n ...restProps\n}: PolymorphicCommonProps<U, ClassicItemProps<T>>) => {\n const classes = classNames('ndl-accordion-item-classic', className);\n\n return <BaseAccordionItem {...restProps} className={classes} />;\n};\nAccordionItem.displayName = 'Accordion.Item';\n\n/**\n * @remarks\n * Where `T` is of the type `string | number | undefined`.\n */\ntype CleanItemProps<T extends AccordionItemId> = Omit<\n AccordionItemProps<T>,\n 'hasDivider'\n>;\n\nconst CleanItem = <\n T extends AccordionItemId,\n U extends React.ElementType = 'div',\n>({\n className,\n ...restProps\n}: PolymorphicCommonProps<U, CleanItemProps<T>>) => {\n const classes = classNames('ndl-accordion-item-clean', className);\n\n return (\n <BaseAccordionItem {...restProps} className={classes} hasDivider={false} />\n );\n};\n\nCleanItem.displayName = 'Accordion.CleanItem';\n\nconst Accordion = Object.assign(AccordionComponent, {\n CleanItem: CleanItem,\n Item: AccordionItem,\n});\n\nexport { Accordion };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6DE;CACA;CACA;CACA;CACA;CACA;CACA;CACA;;AA+DQ,MAAA,aAAA,CAAA,mBAAiB,gBAAA;AA+NzB,MAAA,aAAA,CAAA,WAAA;AAsBA,MAAA,aAAA,CAAA,WAAA;AA5UF,MAAM,oBACJ,kBACA,UACA,YAA6B,WACV;CACnB,MAAM,aAAa,iBAAiB,Q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AgB,WAClB,CAAC,EACF,CAAA,CACG;;IACA,CAAA;GACE,CAAA,GACX,mBACC,oBAAC,YAAD;IAAY,IAAG;IAAM,SAAQ;IAC1B,UAAA;GACS,CAAA,CAEX;;EAEL,oBAAC,OAAD;GACE,IAAI;GACJ,KAAK;GACL,WAAW;GACX,eAAa,CAAC;GACd,mBAAiB;GACjB,MAAK;GAIL,UAAA,oBAAC,OAAD;IACE,KAAK;IACL,WAAU;IACV,YAAY,UAAU,MAAM,gBAAgB;IAE5C,UAAA,oBAAC,YAAD;KACE,SAAQ;KACR,WAAU;KACV,IAAG;KAEF;IACS,CAAA;GACT,CAAA;EACF,CAAA;EACJ,cAAc,oBAAC,SAAD,CAAU,CAAA;CAChB,EAAA,CAAA,CAAA;AAEf;;;;;;;AAQA,MAAM,iBAGJ,UAGoD;CAHpD,IAAA,EACA,cAAA,OACG,YAAA,yBAAA,OAAA,UAAA;CAEH,MAAM,UAAU,WAAW,8BAA8B,SAAS;CAElE,OAAO,oBAAC,mBAAA,eAAA,eAAA,CAAA,GAAsB,SAAA,GAAA,CAAA,GAAA,EAAW,WAAW,QAAA,CAAU,CAAA;AAChE;AACA,cAAc,cAAc;AAW5B,MAAM,aAGJ,UAGkD;CAHlD,IAAA,EACA,cAAA,OACG,YAAA,yBAAA,OAAA,UAAA;CAEH,MAAM,UAAU,WAAW,4BAA4B,SAAS;CAEhE,OACE,oBAAC,mBAAA,eAAA,eAAA,CAAA,GAAsB,SAAA,GAAA,CAAA,GAAA;EAAW,WAAW;EAAS,YAAY;CAAQ,CAAA,CAAA;AAE9E;AAEA,UAAU,cAAc;AAExB,MAAM,YAAY,OAAO,OAAO,oBAAoB;CACvC;CACX,MAAM;AACR,CAAC"}
1
+ {"version":3,"file":"Accordion.mjs","names":[],"sources":["../../../src/accordion/Accordion.tsx"],"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 classNames from 'classnames';\nimport type React from 'react';\nimport { useCallback, useImperativeHandle, useRef } from 'react';\n\nimport { type PolymorphicCommonProps } from '../_common/types';\nimport { findUntil } from '../_common/utils';\nimport { Divider } from '../divider';\nimport { ChevronDownIconOutline } from '../icons/generated/heroIcons/ChevronDownIconOutline';\nimport { Typography } from '../typography';\nimport { AccordionContext, useAccordionContext } from './accordion-context';\nimport {\n type AccordionItemId,\n type AccordionItemProps,\n type AccordionProps,\n type ClassicItemProps,\n type IsMultiple,\n type IsNotMultiple,\n} from './accordion-types';\n\nenum AccordionSelector {\n Item = '.ndl-accordion-item',\n ItemNotDisabled = '.ndl-accordion-item:not(.ndl-accordion-item-disabled)',\n}\n\nconst getAccordionItem = (\n accordionElement: Element,\n selector: string,\n direction: 'next' | 'prev' = 'next',\n): Element | null => {\n const itemParent = accordionElement.closest(AccordionSelector.Item);\n if (!itemParent) {\n return null;\n }\n\n return findUntil(direction, itemParent, selector);\n};\n\nconst AccordionComponent = function AccordionComponent<\n T extends AccordionItemId,\n U extends React.ElementType = 'div',\n>({\n children,\n as,\n isMultiple,\n onChange,\n className,\n style,\n htmlAttributes,\n ref,\n ...restProps\n}: PolymorphicCommonProps<U, AccordionProps<T>>) {\n const accordionRef = useRef<U>(null);\n\n useImperativeHandle(ref, () => accordionRef.current!);\n\n const Component: React.ElementType = as || 'div';\n\n // The following function includes code needed to be\n // able to navigate with the arrow keys (not tab).\n const handleKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {\n const accordionElement = accordionRef.current;\n if (!accordionElement) {\n return;\n }\n const activeElement = document.activeElement as HTMLElement;\n if (event.key === 'ArrowDown') {\n event.preventDefault();\n event.stopPropagation();\n const newFocusedElement = getAccordionItem(\n activeElement,\n AccordionSelector.ItemNotDisabled,\n 'next',\n );\n const newHeader = newFocusedElement?.firstElementChild;\n\n if (newHeader && newHeader instanceof HTMLElement) {\n focusAccordionItem(newHeader as HTMLElement);\n }\n } else if (event.key === 'ArrowUp') {\n event.preventDefault();\n event.stopPropagation();\n const newFocusedElement = getAccordionItem(\n activeElement,\n AccordionSelector.ItemNotDisabled,\n 'prev',\n );\n const newHeader = newFocusedElement?.firstElementChild;\n\n if (newHeader && newHeader instanceof HTMLElement) {\n focusAccordionItem(newHeader as HTMLElement);\n }\n } else if (event.key === ' ' || event.key === 'Enter') {\n event.preventDefault();\n event.stopPropagation();\n activeElement.click();\n }\n };\n\n const focusAccordionItem = (accordionHtmlElement: HTMLElement) => {\n const accordionButton = accordionHtmlElement\n .getElementsByClassName('ndl-accordion-item-header-button')\n .item(0);\n\n if (accordionButton !== null && accordionButton instanceof HTMLElement) {\n accordionButton.focus();\n }\n };\n\n const classes = classNames('ndl-accordion', className);\n\n // Destructure and omit keys from DOM spread\n const { expandedItemIds, expandedItemId, ...restAccordionProps } =\n restProps as Record<string, unknown> as {\n expandedItemIds?: T[];\n expandedItemId?: T | null;\n [key: string]: unknown;\n };\n\n const contextValue = isMultiple\n ? ({\n expandedItemIds,\n isMultiple,\n onChange,\n } as IsMultiple<T>)\n : ({\n expandedItemId,\n isMultiple,\n onChange,\n } as IsNotMultiple<T>);\n\n return (\n <Component\n className={classes}\n style={style}\n ref={accordionRef}\n onKeyDown={handleKeyDown}\n role=\"presentation\"\n {...restAccordionProps}\n {...htmlAttributes}\n >\n <AccordionContext.Provider value={contextValue}>\n {children}\n </AccordionContext.Provider>\n </Component>\n );\n};\n\nconst createItemId = (type: string, id: AccordionItemId) =>\n `ndl-accordionitem${type}id-${id}`;\n\nconst BaseAccordionItem = <\n T extends AccordionItemId,\n U extends React.ElementType = 'div',\n>({\n itemId,\n children,\n title,\n className = '',\n arrowPosition = 'leading',\n isDisabled = false,\n onExpandedChange,\n htmlAttributes,\n style,\n as,\n titleTypographyVariant = 'subheading-large',\n hasDivider = true,\n trailingContent,\n headingLevel = 2,\n}: PolymorphicCommonProps<U, AccordionItemProps<T>>) => {\n const contentRef = useRef<HTMLDivElement>(null);\n const innerContentRef = useRef<HTMLDivElement>(null);\n const itemElementId = createItemId('item', itemId);\n const headerElementId = createItemId('header', itemId);\n const buttonElementId = createItemId('button', itemId);\n const panelElementId = createItemId('panel', itemId);\n const Component: React.ElementType = as || 'div';\n\n const context = useAccordionContext();\n const { isMultiple } = context;\n\n const isExpanded = isMultiple\n ? context.expandedItemIds.includes(itemId)\n : context.expandedItemId === itemId;\n\n const handleOnClick = useCallback(() => {\n if (isDisabled) {\n return;\n }\n\n // Custom callback to call.\n if (onExpandedChange !== undefined) {\n onExpandedChange(!isExpanded);\n }\n\n if (isMultiple) {\n const { expandedItemIds, onChange }: IsMultiple<T> = context;\n // Multiple expanded.\n if (isExpanded) {\n // Remove from list.\n const newArray: T[] = expandedItemIds.filter(\n (activeId) => activeId !== itemId,\n );\n onChange(newArray);\n } else if (!isExpanded) {\n // Add to list.\n const newArray = [...expandedItemIds];\n newArray.push(itemId);\n onChange(newArray);\n }\n } else {\n const { onChange }: IsNotMultiple<T> = context;\n // Single expanded.\n if (isExpanded) {\n // Set null.\n onChange(null);\n } else if (!isExpanded) {\n // Set to id.\n onChange(itemId);\n }\n }\n\n // The W3 WAI-ARIA states that focus can only happen on the header not the header button.\n document.activeElement?.parentElement?.focus();\n }, [isExpanded, isMultiple, isDisabled, itemId, onExpandedChange, context]);\n\n const classes = classNames('ndl-accordion-item', className, {\n 'ndl-accordion-item-disabled': isDisabled,\n 'ndl-accordion-item-expanded': isExpanded,\n });\n\n const headerClasses = classNames('ndl-accordion-item-header', {\n 'ndl-accordion-item-header-disabled': isDisabled,\n });\n\n const iconClasses = classNames('ndl-accordion-item-header-icon-wrapper', {\n 'ndl-accordion-item-header-icon-wrapper-leading':\n arrowPosition === 'leading',\n });\n\n const buttonClasses = classNames('ndl-accordion-item-header-button', {\n 'ndl-accordion-item-header-button-disabled': isDisabled,\n });\n\n const titleClasses = classNames('ndl-accordion-item-header-button-title', {\n 'ndl-accordion-item-header-button-title': isDisabled,\n 'ndl-accordion-item-header-button-title-leading':\n arrowPosition === 'leading',\n });\n\n const contentClasses = classNames('ndl-accordion-item-content', {\n 'ndl-accordion-item-content-expanded': isExpanded,\n 'ndl-accordion-item-content-leading': arrowPosition === 'leading',\n });\n\n return (\n <Component\n className={classes}\n style={style}\n id={itemElementId}\n {...htmlAttributes}\n >\n <div className={headerClasses} id={headerElementId}>\n <Typography\n as={`h${headingLevel}`}\n variant={titleTypographyVariant}\n className=\"ndl-accordion-item-heading\"\n >\n <button\n type=\"button\"\n id={buttonElementId}\n onClick={handleOnClick}\n className={buttonClasses}\n aria-expanded={isExpanded}\n aria-disabled={isDisabled}\n aria-controls={panelElementId}\n disabled={isDisabled}\n >\n <span className={iconClasses}>\n <span className={titleClasses}>{title}</span>\n\n <ChevronDownIconOutline\n className={classNames('ndl-accordion-item-header-icon', {\n 'ndl-expanded': isExpanded,\n })}\n />\n </span>\n </button>\n </Typography>\n {trailingContent && (\n <Typography as=\"div\" variant=\"body-medium\">\n {trailingContent}\n </Typography>\n )}\n </div>\n\n <div\n id={panelElementId}\n ref={contentRef}\n className={contentClasses}\n aria-hidden={!isExpanded}\n aria-labelledby={buttonElementId}\n role=\"region\"\n >\n {/* The <div> element has a child <button> element that allows keyboard interaction */}\n {/* eslint-disable-next-line jsx-a11y/no-static-element-interactions */}\n <div\n ref={innerContentRef}\n className=\"ndl-accordion-item-content-inner\"\n onKeyDown={(event) => event.stopPropagation()}\n >\n <Typography\n variant=\"body-medium\"\n className=\"ndl-accordion-item-content-text\"\n as=\"div\"\n >\n {children}\n </Typography>\n </div>\n </div>\n {hasDivider && <Divider />}\n </Component>\n );\n};\n\n/**\n * @remarks\n * Where `T` is of the type `string | number | undefined`.\n *\n * `TypographyVariants` is of the type `'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'subheading-large' | 'subheading-medium' | 'subheading-small' | 'body-large' | 'body-medium' | 'body-small' | 'code'`.\n */\nconst AccordionItem = <\n T extends AccordionItemId,\n U extends React.ElementType = 'div',\n>({\n className,\n ...restProps\n}: PolymorphicCommonProps<U, ClassicItemProps<T>>) => {\n const classes = classNames('ndl-accordion-item-classic', className);\n\n return <BaseAccordionItem {...restProps} className={classes} />;\n};\nAccordionItem.displayName = 'Accordion.Item';\n\n/**\n * @remarks\n * Where `T` is of the type `string | number | undefined`.\n */\ntype CleanItemProps<T extends AccordionItemId> = Omit<\n AccordionItemProps<T>,\n 'hasDivider'\n>;\n\nconst CleanItem = <\n T extends AccordionItemId,\n U extends React.ElementType = 'div',\n>({\n className,\n ...restProps\n}: PolymorphicCommonProps<U, CleanItemProps<T>>) => {\n const classes = classNames('ndl-accordion-item-clean', className);\n\n return (\n <BaseAccordionItem {...restProps} className={classes} hasDivider={false} />\n );\n};\n\nCleanItem.displayName = 'Accordion.CleanItem';\n\nconst Accordion = Object.assign(AccordionComponent, {\n CleanItem: CleanItem,\n Item: AccordionItem,\n});\n\nexport { Accordion };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6DE;CACA;CACA;CACA;CACA;CACA;CACA;CACA;;AA+DQ,MAAA,aAAA,CAAA,mBAAiB,gBAAA;AA+NzB,MAAA,aAAA,CAAA,WAAA;AAsBA,MAAA,aAAA,CAAA,WAAA;AA5UF,MAAM,oBACJ,kBACA,UACA,YAA6B,WACV;CACnB,MAAM,aAAa,iBAAiB,QAAA,qBAA8B;CAClE,IAAI,CAAC,YACH,OAAO;CAGT,OAAO,UAAU,WAAW,YAAY,QAAQ;AAClD;AAEA,MAAM,qBAAqB,SAAS,mBAGlC,MAU+C;CAV/C,IAAA,EACA,UACA,I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AD;GACE,IAAI;GACJ,KAAK;GACL,WAAW;GACX,eAAa,CAAC;GACd,mBAAiB;GACjB,MAAK;GAIL,UAAA,oBAAC,OAAD;IACE,KAAK;IACL,WAAU;IACV,YAAY,UAAU,MAAM,gBAAgB;IAE5C,UAAA,oBAAC,YAAD;KACE,SAAQ;KACR,WAAU;KACV,IAAG;KAEF;IACS,CAAA;GACT,CAAA;EACF,CAAA;EACJ,cAAc,oBAAC,SAAD,CAAU,CAAA;CAChB,EAAA,CAAA,CAAA;AAEf;;;;;;;AAQA,MAAM,iBAGJ,UAGoD;CAHpD,IAAA,EACA,cAAA,OACG,YAAA,yBAAA,OAAA,UAAA;CAEH,MAAM,UAAU,WAAW,8BAA8B,SAAS;CAElE,OAAO,oBAAC,mBAAA,eAAA,eAAA,CAAA,GAAsB,SAAA,GAAA,CAAA,GAAA,EAAW,WAAW,QAAA,CAAU,CAAA;AAChE;AACA,cAAc,cAAc;AAW5B,MAAM,aAGJ,UAGkD;CAHlD,IAAA,EACA,cAAA,OACG,YAAA,yBAAA,OAAA,UAAA;CAEH,MAAM,UAAU,WAAW,4BAA4B,SAAS;CAEhE,OACE,oBAAC,mBAAA,eAAA,eAAA,CAAA,GAAsB,SAAA,GAAA,CAAA,GAAA;EAAW,WAAW;EAAS,YAAY;CAAQ,CAAA,CAAA;AAE9E;AAEA,UAAU,cAAc;AAExB,MAAM,YAAY,OAAO,OAAO,oBAAoB;CACvC;CACX,MAAM;AACR,CAAC"}
@@ -117,7 +117,7 @@ const PreviewConfirmation = (_ref3) => {
117
117
  style
118
118
  }, restProps), htmlAttributes), {}, { children: [!(isFooter && status !== "pending") && /* @__PURE__ */ jsx(Typography, {
119
119
  as: "div",
120
- variant: isFooter ? "subheading-small" : "body-medium",
120
+ variant: isFooter ? "subheading-medium" : "body-medium",
121
121
  className: "ndl-ai-preview-confirmation-content",
122
122
  children
123
123
  }), /* @__PURE__ */ jsxs(Typography, {