@neo4j-ndl/react 5.6.4 → 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 (118) 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/icons/index.js +1 -1
  24. package/lib/cjs/index.js +4 -2
  25. package/lib/cjs/index.js.map +1 -1
  26. package/lib/cjs/inline-edit/InlineEdit.js +1 -1
  27. package/lib/cjs/inline-edit/InlineEdit.js.map +1 -1
  28. package/lib/cjs/inline-edit/utils.js +2 -4
  29. package/lib/cjs/inline-edit/utils.js.map +1 -1
  30. package/lib/cjs/search-field/SearchField.js +94 -0
  31. package/lib/cjs/search-field/SearchField.js.map +1 -0
  32. package/lib/cjs/search-field/index.js +30 -0
  33. package/lib/cjs/search-field/index.js.map +1 -0
  34. package/lib/cjs/side-navigation/SideNavigation.js +2 -2
  35. package/lib/cjs/side-navigation/SideNavigation.js.map +1 -1
  36. package/lib/cjs/spotlight/Spotlight.js +1 -1
  37. package/lib/cjs/spotlight/Spotlight.js.map +1 -1
  38. package/lib/cjs/tabs/Tabs.js +1 -1
  39. package/lib/cjs/tabs/Tabs.js.map +1 -1
  40. package/lib/cjs/text-input/TextInput.js +1 -1
  41. package/lib/cjs/text-input/TextInput.js.map +1 -1
  42. package/lib/cjs/tooltip/Tooltip.js +1 -1
  43. package/lib/cjs/tooltip/Tooltip.js.map +1 -1
  44. package/lib/cjs/tree-view/TreeViewTextItem.js +1 -1
  45. package/lib/cjs/tree-view/TreeViewTextItem.js.map +1 -1
  46. package/lib/esm/accordion/Accordion.mjs +2 -2
  47. package/lib/esm/accordion/Accordion.mjs.map +1 -1
  48. package/lib/esm/ai/preview/Preview.mjs +1 -1
  49. package/lib/esm/ai/preview/Preview.mjs.map +1 -1
  50. package/lib/esm/ai/reasoning/Reasoning.mjs +2 -2
  51. package/lib/esm/ai/reasoning/Reasoning.mjs.map +1 -1
  52. package/lib/esm/ai/thinking/Thinking.mjs +2 -2
  53. package/lib/esm/ai/thinking/Thinking.mjs.map +1 -1
  54. package/lib/esm/avatar/Avatar.mjs +1 -1
  55. package/lib/esm/avatar/Avatar.mjs.map +1 -1
  56. package/lib/esm/banner/Banner.mjs +1 -1
  57. package/lib/esm/banner/Banner.mjs.map +1 -1
  58. package/lib/esm/data-grid/Components.mjs +1 -1
  59. package/lib/esm/data-grid/Components.mjs.map +1 -1
  60. package/lib/esm/date-picker/DatePicker.mjs +2 -2
  61. package/lib/esm/date-picker/DatePicker.mjs.map +1 -1
  62. package/lib/esm/dialog/Dialog.mjs +1 -1
  63. package/lib/esm/dialog/Dialog.mjs.map +1 -1
  64. package/lib/esm/drawer/Drawer.mjs +1 -1
  65. package/lib/esm/drawer/Drawer.mjs.map +1 -1
  66. package/lib/esm/dropzone/Dropzone.mjs +2 -2
  67. package/lib/esm/dropzone/Dropzone.mjs.map +1 -1
  68. package/lib/esm/icons/index.mjs +1 -1
  69. package/lib/esm/index.mjs +4 -3
  70. package/lib/esm/index.mjs.map +1 -1
  71. package/lib/esm/inline-edit/InlineEdit.mjs +1 -1
  72. package/lib/esm/inline-edit/InlineEdit.mjs.map +1 -1
  73. package/lib/esm/inline-edit/utils.mjs +2 -4
  74. package/lib/esm/inline-edit/utils.mjs.map +1 -1
  75. package/lib/esm/search-field/SearchField.mjs +89 -0
  76. package/lib/esm/search-field/SearchField.mjs.map +1 -0
  77. package/lib/esm/search-field/index.mjs +24 -0
  78. package/lib/esm/search-field/index.mjs.map +1 -0
  79. package/lib/esm/side-navigation/SideNavigation.mjs +2 -2
  80. package/lib/esm/side-navigation/SideNavigation.mjs.map +1 -1
  81. package/lib/esm/spotlight/Spotlight.mjs +1 -1
  82. package/lib/esm/spotlight/Spotlight.mjs.map +1 -1
  83. package/lib/esm/tabs/Tabs.mjs +1 -1
  84. package/lib/esm/tabs/Tabs.mjs.map +1 -1
  85. package/lib/esm/text-input/TextInput.mjs +1 -1
  86. package/lib/esm/text-input/TextInput.mjs.map +1 -1
  87. package/lib/esm/tooltip/Tooltip.mjs +1 -1
  88. package/lib/esm/tooltip/Tooltip.mjs.map +1 -1
  89. package/lib/esm/tree-view/TreeViewTextItem.mjs +1 -1
  90. package/lib/esm/tree-view/TreeViewTextItem.mjs.map +1 -1
  91. package/lib/types/ai/thinking/Thinking.d.ts.map +1 -1
  92. package/lib/types/index.d.ts +1 -0
  93. package/lib/types/index.d.ts.map +1 -1
  94. package/lib/types/inline-edit/InlineEdit.d.ts +1 -1
  95. package/lib/types/inline-edit/utils.d.ts.map +1 -1
  96. package/lib/types/search-field/SearchField.d.ts +52 -0
  97. package/lib/types/search-field/SearchField.d.ts.map +1 -0
  98. package/lib/types/search-field/index.d.ts +22 -0
  99. package/lib/types/search-field/index.d.ts.map +1 -0
  100. package/package.json +9 -3
  101. package/skills/ndl-react/SKILL.md +3 -2
  102. package/skills/ndl-react/components/accordion.md +3 -3
  103. package/skills/ndl-react/components/clean-icon-button.md +5 -5
  104. package/skills/ndl-react/components/date-picker.md +2 -2
  105. package/skills/ndl-react/components/dropzone.md +2 -2
  106. package/skills/ndl-react/components/icon-button.md +5 -5
  107. package/skills/ndl-react/components/inline-edit.md +1 -1
  108. package/skills/ndl-react/components/radio.md +1 -1
  109. package/skills/ndl-react/components/search-field.md +254 -0
  110. package/skills/ndl-react/components/select-icon-button.md +6 -6
  111. package/skills/ndl-react/components/side-navigation.md +4 -4
  112. package/skills/ndl-react/components/skeleton.md +3 -3
  113. package/skills/ndl-react/components/status-indicator.md +5 -5
  114. package/skills/ndl-react/components/tabs.md +4 -4
  115. package/skills/ndl-react/components/timezone-picker.md +1 -1
  116. package/skills/ndl-react/components/tooltip.md +1 -1
  117. package/skills/ndl-react/components/typography.md +2 -2
  118. package/skills/ndl-react/references/styling.md +1 -1
@@ -470,7 +470,7 @@ const CategoryHeader = (_ref5) => {
470
470
  const classes = (0, classnames.default)("ndl-side-nav-category-header", className, { "ndl-side-nav-category-header-expanded": isExpanded || isHovered });
471
471
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_typography_Typography.Typography, require_objectSpread2.default(require_objectSpread2.default({
472
472
  ref,
473
- variant: "label",
473
+ variant: "title-4",
474
474
  as: "li",
475
475
  className: classes,
476
476
  htmlAttributes: require_objectSpread2.default(require_objectSpread2.default({}, htmlAttributes), {}, { role: "separator" }),
@@ -507,7 +507,7 @@ const ItemBadge = (_ref6) => {
507
507
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_typography_Typography.Typography, require_objectSpread2.default(require_objectSpread2.default({
508
508
  as: "span",
509
509
  className: badgeClasses,
510
- variant: "subheading-small",
510
+ variant: "subheading-medium",
511
511
  htmlAttributes: require_objectSpread2.default({ "aria-label": `${number} notifications of type ${type}` }, htmlAttributes),
512
512
  style,
513
513
  ref
@@ -1 +1 @@
1
- {"version":3,"file":"SideNavigation.js","names":["useState","useRef","classNames","useMergeRefs","tokens","SideNavContext","Composite","useSideNavContext","useSideNavCategoryContext","useListItem","CompositeItem","ConditionalWrap","Tooltip","IconIndicatorWrapper","Typography","useId","useFloating","offset","flip","shift","autoUpdate","useDismiss","useHover","safePolygon","useFocus","useListNavigation","useInteractions","useTransitionStyles","SideNavCategoryContext","ChevronRightIconOutline","FloatingList","FloatingPortal","FloatingFocusManager","Divider","CleanIconButton","PinIcon"],"sources":["../../../src/side-navigation/SideNavigation.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 */\n\nimport {\n autoUpdate,\n Composite,\n CompositeItem,\n flip,\n FloatingFocusManager,\n FloatingList,\n FloatingPortal,\n offset,\n safePolygon,\n shift,\n useDismiss,\n useFloating,\n useFocus,\n useHover,\n useInteractions,\n useListItem,\n useListNavigation,\n useMergeRefs,\n useTransitionStyles,\n} from '@floating-ui/react';\nimport { tokens } from '@neo4j-ndl/base';\nimport classNames from 'classnames';\nimport type React from 'react';\nimport { useEffect, useId, useRef, useState } from 'react';\n\nimport { IconIndicatorWrapper } from '../_common/IconIndicatorWrapper';\nimport {\n type CommonProps,\n type PolymorphicCommonProps,\n} from '../_common/types';\nimport { CleanIconButton } from '../clean-icon-button';\nimport { ConditionalWrap } from '../conditional-wrap';\nimport { Divider } from '../divider';\nimport PinIcon from '../icons/generated/custom/Pin';\nimport { ChevronRightIconOutline } from '../icons/generated/heroIcons/ChevronRightIconOutline';\nimport { Tooltip } from '../tooltip';\nimport { Typography } from '../typography';\nimport {\n SideNavCategoryContext,\n SideNavContext,\n useSideNavCategoryContext,\n useSideNavContext,\n} from './side-navigation-context';\nimport {\n type CategoryHeaderProps,\n type CategoryItemProps,\n type ItemBadgeProps,\n type NavItemProps,\n type SideNavListItemProps,\n type SideNavProps,\n} from './side-navigation-types';\n\n/**\n * SideNav\n */\nconst SideNavComponent = ({\n children,\n className,\n style,\n htmlAttributes,\n isExpanded = false,\n shouldOverlayOnInteraction = true,\n ariaLabel,\n onPinButtonClick,\n expandedWidth,\n ref,\n ...restProps\n}: CommonProps<'div', SideNavProps>) => {\n const [isHovered, setIsHovered] = useState(false);\n const [hasFocusVisible, setHasFocusVisible] = useState(false);\n const [isCollapseTransitioning, setIsCollapseTransitioning] = useState(false);\n const collapseTransitionTimeoutRef = useRef<ReturnType<\n typeof setTimeout\n > | null>(null);\n\n const rootRef = useRef<HTMLDivElement>(null);\n\n const isFloatingExpanded =\n shouldOverlayOnInteraction && (!isHovered ? hasFocusVisible : true);\n\n const classes = classNames('ndl-side-nav', 'ndl-side-nav-root', className, {\n 'ndl-side-nav-collapsed':\n isExpanded !== true && shouldOverlayOnInteraction !== true,\n 'ndl-side-nav-expanded': isExpanded,\n });\n\n const innerClasses = classNames('ndl-side-nav-inner', {\n 'ndl-side-nav-collapsing': isCollapseTransitioning,\n 'ndl-side-nav-hover': isFloatingExpanded === true && isExpanded !== true,\n });\n\n const customStyle = {\n ...style,\n ...(Boolean(expandedWidth) && {\n '--side-nav-width-expanded':\n typeof expandedWidth === 'string'\n ? expandedWidth\n : `${expandedWidth}px`,\n }),\n };\n\n const mergedRef = useMergeRefs([ref, rootRef]);\n\n const collapseTransitionDuration = Number.parseInt(\n tokens.motion.duration.quick,\n 10,\n );\n\n useEffect(() => {\n return () => {\n if (collapseTransitionTimeoutRef.current !== null) {\n clearTimeout(collapseTransitionTimeoutRef.current);\n collapseTransitionTimeoutRef.current = null;\n }\n };\n }, []);\n\n return (\n <SideNavContext.Provider\n value={{\n isExpanded,\n isHovered: isFloatingExpanded, // needs refactoring\n onPinButtonClick,\n shouldOverlayOnInteraction,\n }}\n >\n <div\n className={classes}\n ref={mergedRef}\n style={customStyle}\n onMouseEnter={() => {\n if (collapseTransitionTimeoutRef.current !== null) {\n clearTimeout(collapseTransitionTimeoutRef.current);\n collapseTransitionTimeoutRef.current = null;\n }\n setIsCollapseTransitioning(false);\n setIsHovered(true);\n }}\n onMouseLeave={() => {\n const shouldDelayZIndexRemoval =\n shouldOverlayOnInteraction &&\n !isExpanded &&\n (isHovered || hasFocusVisible);\n setIsHovered(false);\n if (shouldDelayZIndexRemoval) {\n if (collapseTransitionTimeoutRef.current !== null) {\n clearTimeout(collapseTransitionTimeoutRef.current);\n }\n setIsCollapseTransitioning(true);\n collapseTransitionTimeoutRef.current = setTimeout(() => {\n collapseTransitionTimeoutRef.current = null;\n setIsCollapseTransitioning(false);\n }, collapseTransitionDuration);\n }\n }}\n onFocusCapture={() => {\n // Delay slightly to let Composite's focus management settle\n requestAnimationFrame(() => {\n const activeElement = document.activeElement;\n // Check if focus is inside and visible (using :focus-visible on the active element)\n if (\n activeElement instanceof HTMLElement &&\n rootRef.current !== null &&\n rootRef.current.contains(activeElement) &&\n activeElement.matches(':focus-visible')\n ) {\n // Update state after another frame to let focus fully settle\n // This updates the context for consumers without disrupting focus\n requestAnimationFrame(() => {\n setHasFocusVisible(true);\n });\n }\n });\n }}\n onBlurCapture={() => {\n // Small delay to check if focus moved to another element inside\n requestAnimationFrame(() => {\n const activeElement = document.activeElement;\n const isInsideNav =\n activeElement instanceof HTMLElement &&\n rootRef.current !== null &&\n rootRef.current.contains(activeElement);\n // Check if focus is in a portaled floating menu\n const isInsideFloatingMenu =\n activeElement instanceof HTMLElement &&\n activeElement.closest('.ndl-side-nav-popover') !== null;\n\n if (\n (isInsideNav || isInsideFloatingMenu) &&\n activeElement instanceof HTMLElement &&\n activeElement.matches(':focus-visible')\n ) {\n // Focus stayed inside with focus-visible\n setHasFocusVisible(true);\n } else {\n // Focus left - collapse\n setHasFocusVisible(false);\n }\n });\n }}\n {...restProps}\n {...htmlAttributes}\n >\n <div className={innerClasses}>\n {/* Both the nav landmark and the Menubar get the same label following the\n WAI-ARIA pattern for Menubar:\n https://www.w3.org/WAI/ARIA/apg/patterns/menubar/examples/menubar-navigation */}\n <nav className=\"ndl-side-nav-nav\" aria-label={ariaLabel}>\n <Composite\n render={<ul />}\n aria-label={ariaLabel}\n role=\"menubar\"\n orientation=\"vertical\"\n aria-orientation=\"vertical\"\n className=\"ndl-side-nav-list\"\n loop={true}\n >\n {children}\n </Composite>\n </nav>\n {shouldOverlayOnInteraction === true && (\n <div className=\"ndl-side-nav-footer\">\n <PinButton />\n </div>\n )}\n </div>\n </div>\n </SideNavContext.Provider>\n );\n};\n\n/**\n * SideNavListItem\n */\nconst SideNavListItem = ({\n children,\n className,\n style,\n htmlAttributes,\n ref,\n ...restProps\n}: CommonProps<'li', SideNavListItemProps>) => {\n const classes = classNames('ndl-side-nav-list-item', className, {});\n\n return (\n <li\n role=\"none\"\n className={classes}\n style={style}\n ref={ref}\n {...restProps}\n {...htmlAttributes}\n >\n <SelectedIndicator />\n {children}\n </li>\n );\n};\n\n/**\n * NavItem\n */\nconst NavItem = <T extends React.ElementType = 'button'>({\n icon,\n label,\n trailingElement,\n isActive,\n className,\n style,\n htmlAttributes,\n as,\n badge,\n ref,\n ...restProps\n}: PolymorphicCommonProps<T, NavItemProps>) => {\n const { isExpanded, isHovered, shouldOverlayOnInteraction } =\n useSideNavContext();\n const categoryContext = useSideNavCategoryContext();\n const isInCategory = categoryContext !== null;\n\n const item = useListItem();\n const mergedRef = useMergeRefs([item.ref, ref]);\n\n const isActiveIndex = item.index === categoryContext?.activeIndex;\n\n const Component: React.ElementType = as ?? 'button';\n const classes = classNames('ndl-side-nav-nav-item', className, {\n 'ndl-active': isActive === true,\n });\n\n const Wrapper = isInCategory ? Component : CompositeItem;\n const componentProps = {\n className: classes,\n ref: mergedRef,\n role: 'menuitem',\n style: style,\n ...(isInCategory && {\n ...categoryContext?.getItemProps(),\n tabIndex: isActiveIndex ? 0 : -1,\n }),\n ...restProps,\n ...htmlAttributes,\n };\n const wrapperProps = isInCategory\n ? componentProps\n : {\n render: <Component {...componentProps} />,\n };\n\n return (\n <ConditionalWrap\n shouldWrap={\n isExpanded === false &&\n !shouldOverlayOnInteraction &&\n !isInCategory &&\n Boolean(label)\n }\n wrap={(children) => (\n <Tooltip\n type=\"simple\"\n placement=\"right\"\n hoverDelay={{ close: 0, open: shouldOverlayOnInteraction ? 100 : 0 }}\n >\n <Tooltip.Trigger hasButtonWrapper={true}>{children}</Tooltip.Trigger>\n <Tooltip.Content>{label}</Tooltip.Content>\n </Tooltip>\n )}\n >\n <Wrapper {...wrapperProps}>\n <div className=\"ndl-side-nav-item-inner\">\n {Boolean(icon) && (\n <div className=\"ndl-side-nav-item-leading-element\">\n <ConditionalWrap\n shouldWrap={Boolean(badge) && !isHovered && !isExpanded}\n wrap={(children) => (\n <IconIndicatorWrapper type={badge?.type ?? 'info'}>\n {children}\n </IconIndicatorWrapper>\n )}\n >\n {icon}\n </ConditionalWrap>\n </div>\n )}\n {Boolean(label) && (\n <Typography\n variant=\"body-medium\"\n as=\"div\"\n className=\"ndl-side-nav-item-label\"\n >\n {label}\n </Typography>\n )}\n {(Boolean(trailingElement) || Boolean(badge)) && (\n <div className=\"ndl-side-nav-item-trailing-element\">\n {trailingElement}\n {badge !== undefined && (\n <ItemBadge type={badge.type} number={badge.number} />\n )}\n </div>\n )}\n </div>\n </Wrapper>\n </ConditionalWrap>\n );\n};\n\n/**\n * CategoryItem\n */\nconst CategoryItem = ({\n children,\n icon,\n label,\n isActive,\n className,\n style,\n htmlAttributes,\n badge,\n isMenuOpen = false,\n ref,\n ...restProps\n}: CommonProps<'button', CategoryItemProps>) => {\n const floatingId = useId();\n const { isExpanded, isHovered, shouldOverlayOnInteraction } =\n useSideNavContext();\n const anchorRef = useRef<HTMLLIElement>(null);\n const [isOpen, setIsOpen] = useState(false);\n const [activeIndex, setActiveIndex] = useState<number | null>(null);\n const [isTooltipOpen, setIsTooltipOpen] = useState(false);\n const elementsRef = useRef<\n Array<HTMLButtonElement | HTMLAnchorElement | null>\n >([]);\n\n const classes = classNames('ndl-side-nav-category-item', className, {\n 'ndl-active': isActive === true,\n });\n\n // Floating UI setup\n const { refs, context } = useFloating({\n elements: {\n reference: anchorRef.current,\n },\n middleware: [\n offset(5),\n flip({ crossAxis: true, fallbackAxisSideDirection: 'end', padding: 5 }),\n shift({ padding: 5 }),\n ],\n onOpenChange: setIsOpen,\n open: isOpen || isMenuOpen,\n placement: 'right-start',\n strategy: 'fixed',\n whileElementsMounted: autoUpdate,\n });\n\n const dismiss = useDismiss(context, {\n referencePress: false,\n });\n const hover = useHover(context, {\n delay: { close: 130, open: 130 },\n handleClose: safePolygon({\n blockPointerEvents: false,\n requireIntent: false,\n }),\n });\n const focus = useFocus(context);\n const listNavigation = useListNavigation(context, {\n activeIndex: activeIndex,\n focusItemOnHover: false,\n focusItemOnOpen: false,\n listRef: elementsRef,\n loop: true,\n nested: true,\n onNavigate: setActiveIndex,\n openOnArrowKeyDown: false,\n });\n\n // Separate interactions: reference (no listNavigation), floating (with listNavigation)\n const refInteractions = useInteractions([dismiss, hover, focus]);\n const floatInteractions = useInteractions([dismiss, hover, listNavigation]);\n const { styles: transitionStyles } = useTransitionStyles(context, {\n duration: Number.parseInt(tokens.motion.duration.quick) ?? 0,\n });\n\n // Reset activeIndex when menu closes\n useEffect(() => {\n if (!context.open) {\n setActiveIndex(null);\n }\n }, [context.open]);\n\n const mergedRef = useMergeRefs([refs.setReference, ref]);\n\n return (\n <SideNavCategoryContext.Provider\n value={{\n activeIndex,\n getItemProps: floatInteractions.getItemProps,\n }}\n >\n <ConditionalWrap\n shouldWrap={\n isExpanded === false && !shouldOverlayOnInteraction && Boolean(label)\n }\n wrap={(children) => (\n <Tooltip\n type=\"simple\"\n placement=\"top\"\n hoverDelay={{\n close: 0,\n open: shouldOverlayOnInteraction ? 100 : 0,\n }}\n isOpen={isTooltipOpen}\n onOpenChange={setIsTooltipOpen}\n >\n <Tooltip.Trigger hasButtonWrapper={true}>\n {children}\n </Tooltip.Trigger>\n <Tooltip.Content className=\"ndl-side-nav ndl-side-nav-category-menu-tooltip-content\">\n {label}\n </Tooltip.Content>\n </Tooltip>\n )}\n >\n <CompositeItem\n render={\n <button\n type=\"button\"\n {...refInteractions.getReferenceProps({\n className: classes,\n ref: mergedRef,\n style,\n ...restProps,\n ...htmlAttributes,\n })}\n // {...restProps}\n // {...htmlAttributes}\n role=\"menuitem\"\n aria-haspopup=\"menu\"\n aria-expanded={context.open}\n aria-controls={floatingId}\n onFocus={(event) => {\n // Only show tooltip on focus-visible (keyboard navigation)\n if (\n event.target instanceof HTMLElement &&\n event.target.matches(':focus-visible')\n ) {\n setIsTooltipOpen(true);\n }\n // Call original handler if exists\n const originalOnFocus = refInteractions.getReferenceProps({})\n .onFocus as\n | ((event: React.FocusEvent<HTMLButtonElement>) => void)\n | undefined;\n originalOnFocus?.(event);\n }}\n onBlur={(event) => {\n setIsTooltipOpen(false);\n // Call original handler if exists\n const originalOnBlur = refInteractions.getReferenceProps({})\n .onBlur as\n | ((event: React.FocusEvent<HTMLButtonElement>) => void)\n | undefined;\n originalOnBlur?.(event);\n }}\n onKeyDown={(event) => {\n if (event.key === 'ArrowRight') {\n // open and move focus into submenu\n setIsOpen(true);\n setActiveIndex(0);\n // Defer focusing first item (if needed) to next tick\n requestAnimationFrame(() => {\n const el = elementsRef.current[0];\n el?.focus();\n });\n event.preventDefault();\n }\n // ArrowDown/ArrowUp: let Composite handle top-level roving focus.\n }}\n />\n }\n >\n <div className=\"ndl-side-nav-item-inner\">\n {Boolean(icon) && (\n <div className=\"ndl-side-nav-item-leading-element\">\n <ConditionalWrap\n shouldWrap={Boolean(badge) && !isHovered && !isExpanded}\n wrap={(children) => (\n <IconIndicatorWrapper type={badge?.type ?? 'info'}>\n {children}\n </IconIndicatorWrapper>\n )}\n >\n {icon}\n </ConditionalWrap>\n </div>\n )}\n {Boolean(label) && (\n <Typography\n variant=\"body-medium\"\n as=\"div\"\n className=\"ndl-side-nav-item-label\"\n >\n {label}\n </Typography>\n )}\n <div className=\"ndl-side-nav-item-trailing-element\">\n {badge && <ItemBadge type={badge.type} number={badge.number} />}\n <ChevronRightIconOutline className=\"ndl-side-nav-item-chevron\" />\n </div>\n </div>\n {context.open && (\n <FloatingList elementsRef={elementsRef}>\n <FloatingPortal>\n <FloatingFocusManager\n context={context}\n modal={false}\n initialFocus={-1}\n returnFocus={true}\n closeOnFocusOut={true}\n guards={true}\n >\n <ul\n id={floatingId}\n ref={refs.setFloating}\n className=\"ndl-side-nav ndl-side-nav-popover ndl-side-nav-popover-list\"\n style={{\n ...context.floatingStyles,\n ...transitionStyles,\n }}\n {...floatInteractions.getFloatingProps()}\n role=\"menu\"\n >\n {children}\n </ul>\n </FloatingFocusManager>\n </FloatingPortal>\n </FloatingList>\n )}\n </CompositeItem>\n </ConditionalWrap>\n </SideNavCategoryContext.Provider>\n );\n};\n\n/**\n * CategoryHeader\n */\nconst CategoryHeader = ({\n children,\n className,\n ref,\n style,\n htmlAttributes,\n ...restProps\n}: CommonProps<'li', CategoryHeaderProps>) => {\n const { isExpanded, isHovered } = useSideNavContext();\n\n const classes = classNames('ndl-side-nav-category-header', className, {\n 'ndl-side-nav-category-header-expanded': isExpanded || isHovered,\n });\n\n return (\n <Typography\n ref={ref}\n variant=\"label\"\n as=\"li\"\n className={classes}\n htmlAttributes={{\n ...htmlAttributes,\n role: 'separator',\n }}\n style={style}\n {...restProps}\n >\n {isExpanded || isHovered ? children : <Divider />}\n </Typography>\n );\n};\n\n/**\n * SelectedIndicator\n */\nconst SelectedIndicator = () => {\n return <div className=\"ndl-side-nav-selected-indicator\" />;\n};\n\n/**\n * SideNavDivider\n */\nconst SideNavDivider = () => {\n return (\n <Divider\n orientation=\"horizontal\"\n className=\"ndl-side-nav-divider\"\n as=\"li\"\n />\n );\n};\n\n/**\n * ItemBadge\n */\nconst ItemBadge = ({\n number,\n type,\n ref,\n htmlAttributes,\n style,\n className,\n ...restProps\n}: CommonProps<'span', ItemBadgeProps>) => {\n useSideNavContext();\n\n const badgeClasses = classNames('ndl-side-nav-item-badge', className, {\n 'ndl-danger': type === 'danger',\n 'ndl-info': type === 'info',\n 'ndl-warning': type === 'warning',\n });\n\n return (\n <Typography\n as=\"span\"\n className={badgeClasses}\n variant=\"subheading-small\"\n htmlAttributes={{\n 'aria-label': `${number} notifications of type ${type}`,\n ...htmlAttributes,\n }}\n style={style}\n ref={ref}\n {...restProps}\n >\n {number}\n </Typography>\n );\n};\n\n/**\n * PinButton\n */\nconst PinButton = () => {\n const { isExpanded, shouldOverlayOnInteraction, onPinButtonClick } =\n useSideNavContext();\n\n const classes = classNames('ndl-side-nav-pin-button');\n\n if (!shouldOverlayOnInteraction) {\n return null;\n }\n\n return (\n <CleanIconButton\n onClick={onPinButtonClick}\n className={classes}\n description=\"Pin\"\n size=\"medium\"\n isActive={isExpanded}\n tooltipProps={{\n root: {\n autoUpdateOptions: {\n animationFrame: true,\n },\n placement: 'right',\n },\n }}\n >\n <PinIcon />\n </CleanIconButton>\n );\n};\n\nconst SideNavigation = Object.assign(SideNavComponent, {\n CategoryHeader: CategoryHeader,\n CategoryItem: CategoryItem,\n Divider: SideNavDivider,\n ItemBadge: ItemBadge,\n ListItem: SideNavListItem,\n NavItem,\n});\n\nexport { SideNavigation };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8EE;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;;;CA0KA;CACA;CACA;CACA;CACA;;;CAwBA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;;;CAmGA;CACA;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,QAAAA,CAAW,2BAA2B,WAAW;EACpE,cAAc,SAAS;EACvB,YAAY,SAAS;EACrB,eAAe,SAAS;CAC1B,CAAC;CAED,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACY,8BAAAA,YAAAA,sBAAAA,QAAAA,sBAAAA,QAAAA;EACC,IAAG;EACH,WAAW;EACX,SAAQ;EACR,gBAAA,sBAAA,QAAA,EACE,cAAc,GAAG,OAAO,yBAAyB,OAAA,GAC9C,cACL;EACO;EACF;CACD,GAAA,SAAA,GAAA,CAAA,GAAA,EAAA,UAEH,OAAA,CACS,CAAA;AAEhB;;;;AAKA,MAAM,kBAAkB;CACtB,MAAM,EAAE,YAAY,4BAA4B,qBAC9CP,gDAAAA,kBAAkB;CAEpB,MAAM,WAAA,GAAUL,WAAAA,QAAAA,CAAW,yBAAyB;CAEpD,IAAI,CAAC,4BACH,OAAO;CAGT,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACgC,0CAAAA,iBAAD;EACE,SAAS;EACT,WAAW;EACX,aAAY;EACZ,MAAK;EACL,UAAU;EACV,cAAc,EACZ,MAAM;GACJ,mBAAmB,EACjB,gBAAgB,KAClB;GACA,WAAW;EACb,EACF;EAEA,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAACC,mCAAAA,SAAD,CAAU,CAAA;CACK,CAAA;AAErB;AAEA,MAAM,iBAAiB,OAAO,OAAO,kBAAkB;CACrC;CACF;CACd,SAAS;CACE;CACX,UAAU;CACV;AACF,CAAC"}
1
+ {"version":3,"file":"SideNavigation.js","names":["useState","useRef","classNames","useMergeRefs","tokens","SideNavContext","Composite","useSideNavContext","useSideNavCategoryContext","useListItem","CompositeItem","ConditionalWrap","Tooltip","IconIndicatorWrapper","Typography","useId","useFloating","offset","flip","shift","autoUpdate","useDismiss","useHover","safePolygon","useFocus","useListNavigation","useInteractions","useTransitionStyles","SideNavCategoryContext","ChevronRightIconOutline","FloatingList","FloatingPortal","FloatingFocusManager","Divider","CleanIconButton","PinIcon"],"sources":["../../../src/side-navigation/SideNavigation.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 */\n\nimport {\n autoUpdate,\n Composite,\n CompositeItem,\n flip,\n FloatingFocusManager,\n FloatingList,\n FloatingPortal,\n offset,\n safePolygon,\n shift,\n useDismiss,\n useFloating,\n useFocus,\n useHover,\n useInteractions,\n useListItem,\n useListNavigation,\n useMergeRefs,\n useTransitionStyles,\n} from '@floating-ui/react';\nimport { tokens } from '@neo4j-ndl/base';\nimport classNames from 'classnames';\nimport type React from 'react';\nimport { useEffect, useId, useRef, useState } from 'react';\n\nimport { IconIndicatorWrapper } from '../_common/IconIndicatorWrapper';\nimport {\n type CommonProps,\n type PolymorphicCommonProps,\n} from '../_common/types';\nimport { CleanIconButton } from '../clean-icon-button';\nimport { ConditionalWrap } from '../conditional-wrap';\nimport { Divider } from '../divider';\nimport PinIcon from '../icons/generated/custom/Pin';\nimport { ChevronRightIconOutline } from '../icons/generated/heroIcons/ChevronRightIconOutline';\nimport { Tooltip } from '../tooltip';\nimport { Typography } from '../typography';\nimport {\n SideNavCategoryContext,\n SideNavContext,\n useSideNavCategoryContext,\n useSideNavContext,\n} from './side-navigation-context';\nimport {\n type CategoryHeaderProps,\n type CategoryItemProps,\n type ItemBadgeProps,\n type NavItemProps,\n type SideNavListItemProps,\n type SideNavProps,\n} from './side-navigation-types';\n\n/**\n * SideNav\n */\nconst SideNavComponent = ({\n children,\n className,\n style,\n htmlAttributes,\n isExpanded = false,\n shouldOverlayOnInteraction = true,\n ariaLabel,\n onPinButtonClick,\n expandedWidth,\n ref,\n ...restProps\n}: CommonProps<'div', SideNavProps>) => {\n const [isHovered, setIsHovered] = useState(false);\n const [hasFocusVisible, setHasFocusVisible] = useState(false);\n const [isCollapseTransitioning, setIsCollapseTransitioning] = useState(false);\n const collapseTransitionTimeoutRef = useRef<ReturnType<\n typeof setTimeout\n > | null>(null);\n\n const rootRef = useRef<HTMLDivElement>(null);\n\n const isFloatingExpanded =\n shouldOverlayOnInteraction && (!isHovered ? hasFocusVisible : true);\n\n const classes = classNames('ndl-side-nav', 'ndl-side-nav-root', className, {\n 'ndl-side-nav-collapsed':\n isExpanded !== true && shouldOverlayOnInteraction !== true,\n 'ndl-side-nav-expanded': isExpanded,\n });\n\n const innerClasses = classNames('ndl-side-nav-inner', {\n 'ndl-side-nav-collapsing': isCollapseTransitioning,\n 'ndl-side-nav-hover': isFloatingExpanded === true && isExpanded !== true,\n });\n\n const customStyle = {\n ...style,\n ...(Boolean(expandedWidth) && {\n '--side-nav-width-expanded':\n typeof expandedWidth === 'string'\n ? expandedWidth\n : `${expandedWidth}px`,\n }),\n };\n\n const mergedRef = useMergeRefs([ref, rootRef]);\n\n const collapseTransitionDuration = Number.parseInt(\n tokens.motion.duration.quick,\n 10,\n );\n\n useEffect(() => {\n return () => {\n if (collapseTransitionTimeoutRef.current !== null) {\n clearTimeout(collapseTransitionTimeoutRef.current);\n collapseTransitionTimeoutRef.current = null;\n }\n };\n }, []);\n\n return (\n <SideNavContext.Provider\n value={{\n isExpanded,\n isHovered: isFloatingExpanded, // needs refactoring\n onPinButtonClick,\n shouldOverlayOnInteraction,\n }}\n >\n <div\n className={classes}\n ref={mergedRef}\n style={customStyle}\n onMouseEnter={() => {\n if (collapseTransitionTimeoutRef.current !== null) {\n clearTimeout(collapseTransitionTimeoutRef.current);\n collapseTransitionTimeoutRef.current = null;\n }\n setIsCollapseTransitioning(false);\n setIsHovered(true);\n }}\n onMouseLeave={() => {\n const shouldDelayZIndexRemoval =\n shouldOverlayOnInteraction &&\n !isExpanded &&\n (isHovered || hasFocusVisible);\n setIsHovered(false);\n if (shouldDelayZIndexRemoval) {\n if (collapseTransitionTimeoutRef.current !== null) {\n clearTimeout(collapseTransitionTimeoutRef.current);\n }\n setIsCollapseTransitioning(true);\n collapseTransitionTimeoutRef.current = setTimeout(() => {\n collapseTransitionTimeoutRef.current = null;\n setIsCollapseTransitioning(false);\n }, collapseTransitionDuration);\n }\n }}\n onFocusCapture={() => {\n // Delay slightly to let Composite's focus management settle\n requestAnimationFrame(() => {\n const activeElement = document.activeElement;\n // Check if focus is inside and visible (using :focus-visible on the active element)\n if (\n activeElement instanceof HTMLElement &&\n rootRef.current !== null &&\n rootRef.current.contains(activeElement) &&\n activeElement.matches(':focus-visible')\n ) {\n // Update state after another frame to let focus fully settle\n // This updates the context for consumers without disrupting focus\n requestAnimationFrame(() => {\n setHasFocusVisible(true);\n });\n }\n });\n }}\n onBlurCapture={() => {\n // Small delay to check if focus moved to another element inside\n requestAnimationFrame(() => {\n const activeElement = document.activeElement;\n const isInsideNav =\n activeElement instanceof HTMLElement &&\n rootRef.current !== null &&\n rootRef.current.contains(activeElement);\n // Check if focus is in a portaled floating menu\n const isInsideFloatingMenu =\n activeElement instanceof HTMLElement &&\n activeElement.closest('.ndl-side-nav-popover') !== null;\n\n if (\n (isInsideNav || isInsideFloatingMenu) &&\n activeElement instanceof HTMLElement &&\n activeElement.matches(':focus-visible')\n ) {\n // Focus stayed inside with focus-visible\n setHasFocusVisible(true);\n } else {\n // Focus left - collapse\n setHasFocusVisible(false);\n }\n });\n }}\n {...restProps}\n {...htmlAttributes}\n >\n <div className={innerClasses}>\n {/* Both the nav landmark and the Menubar get the same label following the\n WAI-ARIA pattern for Menubar:\n https://www.w3.org/WAI/ARIA/apg/patterns/menubar/examples/menubar-navigation */}\n <nav className=\"ndl-side-nav-nav\" aria-label={ariaLabel}>\n <Composite\n render={<ul />}\n aria-label={ariaLabel}\n role=\"menubar\"\n orientation=\"vertical\"\n aria-orientation=\"vertical\"\n className=\"ndl-side-nav-list\"\n loop={true}\n >\n {children}\n </Composite>\n </nav>\n {shouldOverlayOnInteraction === true && (\n <div className=\"ndl-side-nav-footer\">\n <PinButton />\n </div>\n )}\n </div>\n </div>\n </SideNavContext.Provider>\n );\n};\n\n/**\n * SideNavListItem\n */\nconst SideNavListItem = ({\n children,\n className,\n style,\n htmlAttributes,\n ref,\n ...restProps\n}: CommonProps<'li', SideNavListItemProps>) => {\n const classes = classNames('ndl-side-nav-list-item', className, {});\n\n return (\n <li\n role=\"none\"\n className={classes}\n style={style}\n ref={ref}\n {...restProps}\n {...htmlAttributes}\n >\n <SelectedIndicator />\n {children}\n </li>\n );\n};\n\n/**\n * NavItem\n */\nconst NavItem = <T extends React.ElementType = 'button'>({\n icon,\n label,\n trailingElement,\n isActive,\n className,\n style,\n htmlAttributes,\n as,\n badge,\n ref,\n ...restProps\n}: PolymorphicCommonProps<T, NavItemProps>) => {\n const { isExpanded, isHovered, shouldOverlayOnInteraction } =\n useSideNavContext();\n const categoryContext = useSideNavCategoryContext();\n const isInCategory = categoryContext !== null;\n\n const item = useListItem();\n const mergedRef = useMergeRefs([item.ref, ref]);\n\n const isActiveIndex = item.index === categoryContext?.activeIndex;\n\n const Component: React.ElementType = as ?? 'button';\n const classes = classNames('ndl-side-nav-nav-item', className, {\n 'ndl-active': isActive === true,\n });\n\n const Wrapper = isInCategory ? Component : CompositeItem;\n const componentProps = {\n className: classes,\n ref: mergedRef,\n role: 'menuitem',\n style: style,\n ...(isInCategory && {\n ...categoryContext?.getItemProps(),\n tabIndex: isActiveIndex ? 0 : -1,\n }),\n ...restProps,\n ...htmlAttributes,\n };\n const wrapperProps = isInCategory\n ? componentProps\n : {\n render: <Component {...componentProps} />,\n };\n\n return (\n <ConditionalWrap\n shouldWrap={\n isExpanded === false &&\n !shouldOverlayOnInteraction &&\n !isInCategory &&\n Boolean(label)\n }\n wrap={(children) => (\n <Tooltip\n type=\"simple\"\n placement=\"right\"\n hoverDelay={{ close: 0, open: shouldOverlayOnInteraction ? 100 : 0 }}\n >\n <Tooltip.Trigger hasButtonWrapper={true}>{children}</Tooltip.Trigger>\n <Tooltip.Content>{label}</Tooltip.Content>\n </Tooltip>\n )}\n >\n <Wrapper {...wrapperProps}>\n <div className=\"ndl-side-nav-item-inner\">\n {Boolean(icon) && (\n <div className=\"ndl-side-nav-item-leading-element\">\n <ConditionalWrap\n shouldWrap={Boolean(badge) && !isHovered && !isExpanded}\n wrap={(children) => (\n <IconIndicatorWrapper type={badge?.type ?? 'info'}>\n {children}\n </IconIndicatorWrapper>\n )}\n >\n {icon}\n </ConditionalWrap>\n </div>\n )}\n {Boolean(label) && (\n <Typography\n variant=\"body-medium\"\n as=\"div\"\n className=\"ndl-side-nav-item-label\"\n >\n {label}\n </Typography>\n )}\n {(Boolean(trailingElement) || Boolean(badge)) && (\n <div className=\"ndl-side-nav-item-trailing-element\">\n {trailingElement}\n {badge !== undefined && (\n <ItemBadge type={badge.type} number={badge.number} />\n )}\n </div>\n )}\n </div>\n </Wrapper>\n </ConditionalWrap>\n );\n};\n\n/**\n * CategoryItem\n */\nconst CategoryItem = ({\n children,\n icon,\n label,\n isActive,\n className,\n style,\n htmlAttributes,\n badge,\n isMenuOpen = false,\n ref,\n ...restProps\n}: CommonProps<'button', CategoryItemProps>) => {\n const floatingId = useId();\n const { isExpanded, isHovered, shouldOverlayOnInteraction } =\n useSideNavContext();\n const anchorRef = useRef<HTMLLIElement>(null);\n const [isOpen, setIsOpen] = useState(false);\n const [activeIndex, setActiveIndex] = useState<number | null>(null);\n const [isTooltipOpen, setIsTooltipOpen] = useState(false);\n const elementsRef = useRef<\n Array<HTMLButtonElement | HTMLAnchorElement | null>\n >([]);\n\n const classes = classNames('ndl-side-nav-category-item', className, {\n 'ndl-active': isActive === true,\n });\n\n // Floating UI setup\n const { refs, context } = useFloating({\n elements: {\n reference: anchorRef.current,\n },\n middleware: [\n offset(5),\n flip({ crossAxis: true, fallbackAxisSideDirection: 'end', padding: 5 }),\n shift({ padding: 5 }),\n ],\n onOpenChange: setIsOpen,\n open: isOpen || isMenuOpen,\n placement: 'right-start',\n strategy: 'fixed',\n whileElementsMounted: autoUpdate,\n });\n\n const dismiss = useDismiss(context, {\n referencePress: false,\n });\n const hover = useHover(context, {\n delay: { close: 130, open: 130 },\n handleClose: safePolygon({\n blockPointerEvents: false,\n requireIntent: false,\n }),\n });\n const focus = useFocus(context);\n const listNavigation = useListNavigation(context, {\n activeIndex: activeIndex,\n focusItemOnHover: false,\n focusItemOnOpen: false,\n listRef: elementsRef,\n loop: true,\n nested: true,\n onNavigate: setActiveIndex,\n openOnArrowKeyDown: false,\n });\n\n // Separate interactions: reference (no listNavigation), floating (with listNavigation)\n const refInteractions = useInteractions([dismiss, hover, focus]);\n const floatInteractions = useInteractions([dismiss, hover, listNavigation]);\n const { styles: transitionStyles } = useTransitionStyles(context, {\n duration: Number.parseInt(tokens.motion.duration.quick) ?? 0,\n });\n\n // Reset activeIndex when menu closes\n useEffect(() => {\n if (!context.open) {\n setActiveIndex(null);\n }\n }, [context.open]);\n\n const mergedRef = useMergeRefs([refs.setReference, ref]);\n\n return (\n <SideNavCategoryContext.Provider\n value={{\n activeIndex,\n getItemProps: floatInteractions.getItemProps,\n }}\n >\n <ConditionalWrap\n shouldWrap={\n isExpanded === false && !shouldOverlayOnInteraction && Boolean(label)\n }\n wrap={(children) => (\n <Tooltip\n type=\"simple\"\n placement=\"top\"\n hoverDelay={{\n close: 0,\n open: shouldOverlayOnInteraction ? 100 : 0,\n }}\n isOpen={isTooltipOpen}\n onOpenChange={setIsTooltipOpen}\n >\n <Tooltip.Trigger hasButtonWrapper={true}>\n {children}\n </Tooltip.Trigger>\n <Tooltip.Content className=\"ndl-side-nav ndl-side-nav-category-menu-tooltip-content\">\n {label}\n </Tooltip.Content>\n </Tooltip>\n )}\n >\n <CompositeItem\n render={\n <button\n type=\"button\"\n {...refInteractions.getReferenceProps({\n className: classes,\n ref: mergedRef,\n style,\n ...restProps,\n ...htmlAttributes,\n })}\n // {...restProps}\n // {...htmlAttributes}\n role=\"menuitem\"\n aria-haspopup=\"menu\"\n aria-expanded={context.open}\n aria-controls={floatingId}\n onFocus={(event) => {\n // Only show tooltip on focus-visible (keyboard navigation)\n if (\n event.target instanceof HTMLElement &&\n event.target.matches(':focus-visible')\n ) {\n setIsTooltipOpen(true);\n }\n // Call original handler if exists\n const originalOnFocus = refInteractions.getReferenceProps({})\n .onFocus as\n | ((event: React.FocusEvent<HTMLButtonElement>) => void)\n | undefined;\n originalOnFocus?.(event);\n }}\n onBlur={(event) => {\n setIsTooltipOpen(false);\n // Call original handler if exists\n const originalOnBlur = refInteractions.getReferenceProps({})\n .onBlur as\n | ((event: React.FocusEvent<HTMLButtonElement>) => void)\n | undefined;\n originalOnBlur?.(event);\n }}\n onKeyDown={(event) => {\n if (event.key === 'ArrowRight') {\n // open and move focus into submenu\n setIsOpen(true);\n setActiveIndex(0);\n // Defer focusing first item (if needed) to next tick\n requestAnimationFrame(() => {\n const el = elementsRef.current[0];\n el?.focus();\n });\n event.preventDefault();\n }\n // ArrowDown/ArrowUp: let Composite handle top-level roving focus.\n }}\n />\n }\n >\n <div className=\"ndl-side-nav-item-inner\">\n {Boolean(icon) && (\n <div className=\"ndl-side-nav-item-leading-element\">\n <ConditionalWrap\n shouldWrap={Boolean(badge) && !isHovered && !isExpanded}\n wrap={(children) => (\n <IconIndicatorWrapper type={badge?.type ?? 'info'}>\n {children}\n </IconIndicatorWrapper>\n )}\n >\n {icon}\n </ConditionalWrap>\n </div>\n )}\n {Boolean(label) && (\n <Typography\n variant=\"body-medium\"\n as=\"div\"\n className=\"ndl-side-nav-item-label\"\n >\n {label}\n </Typography>\n )}\n <div className=\"ndl-side-nav-item-trailing-element\">\n {badge && <ItemBadge type={badge.type} number={badge.number} />}\n <ChevronRightIconOutline className=\"ndl-side-nav-item-chevron\" />\n </div>\n </div>\n {context.open && (\n <FloatingList elementsRef={elementsRef}>\n <FloatingPortal>\n <FloatingFocusManager\n context={context}\n modal={false}\n initialFocus={-1}\n returnFocus={true}\n closeOnFocusOut={true}\n guards={true}\n >\n <ul\n id={floatingId}\n ref={refs.setFloating}\n className=\"ndl-side-nav ndl-side-nav-popover ndl-side-nav-popover-list\"\n style={{\n ...context.floatingStyles,\n ...transitionStyles,\n }}\n {...floatInteractions.getFloatingProps()}\n role=\"menu\"\n >\n {children}\n </ul>\n </FloatingFocusManager>\n </FloatingPortal>\n </FloatingList>\n )}\n </CompositeItem>\n </ConditionalWrap>\n </SideNavCategoryContext.Provider>\n );\n};\n\n/**\n * CategoryHeader\n */\nconst CategoryHeader = ({\n children,\n className,\n ref,\n style,\n htmlAttributes,\n ...restProps\n}: CommonProps<'li', CategoryHeaderProps>) => {\n const { isExpanded, isHovered } = useSideNavContext();\n\n const classes = classNames('ndl-side-nav-category-header', className, {\n 'ndl-side-nav-category-header-expanded': isExpanded || isHovered,\n });\n\n return (\n <Typography\n ref={ref}\n variant=\"title-4\"\n as=\"li\"\n className={classes}\n htmlAttributes={{\n ...htmlAttributes,\n role: 'separator',\n }}\n style={style}\n {...restProps}\n >\n {isExpanded || isHovered ? children : <Divider />}\n </Typography>\n );\n};\n\n/**\n * SelectedIndicator\n */\nconst SelectedIndicator = () => {\n return <div className=\"ndl-side-nav-selected-indicator\" />;\n};\n\n/**\n * SideNavDivider\n */\nconst SideNavDivider = () => {\n return (\n <Divider\n orientation=\"horizontal\"\n className=\"ndl-side-nav-divider\"\n as=\"li\"\n />\n );\n};\n\n/**\n * ItemBadge\n */\nconst ItemBadge = ({\n number,\n type,\n ref,\n htmlAttributes,\n style,\n className,\n ...restProps\n}: CommonProps<'span', ItemBadgeProps>) => {\n useSideNavContext();\n\n const badgeClasses = classNames('ndl-side-nav-item-badge', className, {\n 'ndl-danger': type === 'danger',\n 'ndl-info': type === 'info',\n 'ndl-warning': type === 'warning',\n });\n\n return (\n <Typography\n as=\"span\"\n className={badgeClasses}\n variant=\"subheading-medium\"\n htmlAttributes={{\n 'aria-label': `${number} notifications of type ${type}`,\n ...htmlAttributes,\n }}\n style={style}\n ref={ref}\n {...restProps}\n >\n {number}\n </Typography>\n );\n};\n\n/**\n * PinButton\n */\nconst PinButton = () => {\n const { isExpanded, shouldOverlayOnInteraction, onPinButtonClick } =\n useSideNavContext();\n\n const classes = classNames('ndl-side-nav-pin-button');\n\n if (!shouldOverlayOnInteraction) {\n return null;\n }\n\n return (\n <CleanIconButton\n onClick={onPinButtonClick}\n className={classes}\n description=\"Pin\"\n size=\"medium\"\n isActive={isExpanded}\n tooltipProps={{\n root: {\n autoUpdateOptions: {\n animationFrame: true,\n },\n placement: 'right',\n },\n }}\n >\n <PinIcon />\n </CleanIconButton>\n );\n};\n\nconst SideNavigation = Object.assign(SideNavComponent, {\n CategoryHeader: CategoryHeader,\n CategoryItem: CategoryItem,\n Divider: SideNavDivider,\n ItemBadge: ItemBadge,\n ListItem: SideNavListItem,\n NavItem,\n});\n\nexport { SideNavigation };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8EE;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;;;CA0KA;CACA;CACA;CACA;CACA;;;CAwBA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;;;CAmGA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;;;CAqOA;CACA;CACA;CACA;CACA;;;CAmDA;CACA;CACA;CACA;CACA;CACA;;;;;AAtmBF,MAAM,oBAAoB,SAYc;CAZd,IAAA,EACxB,UACA,WACA,OACA,gBACA,aAAa,OACb,6BAA6B,MAC7B,WACA,kBACA,eACA,QAAA,MACG,YAAA,gCAAA,QAAA,MAAA,SAAA;CAEH,MAAM,CAAC,WAAW,iBAAA,GAAgBA,MAAAA,SAAAA,CAAS,KAAK;CAChD,MAAM,CAAC,iBAAiB,uB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AA,CACS,CAAA;AAEhB;;;;AAKA,MAAM,kBAAkB;CACtB,MAAM,EAAE,YAAY,4BAA4B,qBAC9CP,gDAAAA,kBAAkB;CAEpB,MAAM,WAAA,GAAUL,WAAAA,QAAAA,CAAW,yBAAyB;CAEpD,IAAI,CAAC,4BACH,OAAO;CAGT,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACgC,0CAAAA,iBAAD;EACE,SAAS;EACT,WAAW;EACX,aAAY;EACZ,MAAK;EACL,UAAU;EACV,cAAc,EACZ,MAAM;GACJ,mBAAmB,EACjB,gBAAgB,KAClB;GACA,WAAW;EACb,EACF;EAEA,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAACC,mCAAAA,SAAD,CAAU,CAAA;CACK,CAAA;AAErB;AAEA,MAAM,iBAAiB,OAAO,OAAO,kBAAkB;CACrC;CACF;CACd,SAAS;CACE;CACX,UAAU;CACV;AACF,CAAC"}
@@ -114,7 +114,7 @@ const SpotlightHeader = (_ref) => {
114
114
  className: classes,
115
115
  ref,
116
116
  style,
117
- variant: "title-4"
117
+ variant: "title-3"
118
118
  }, restProps), {}, {
119
119
  htmlAttributes: require_objectSpread2.default(require_objectSpread2.default({}, htmlAttributes), {}, { id: headerId }),
120
120
  children
@@ -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,IAAQ,eAAgB,EAAE,MAAM,MAClC,gBAAA,QAAA,gBAAA,KAAA,KAAA,YAAA,mBAAA,QAAA,mBAAA,KAAA,IAAA,KAAA,IAAc,eAAgB,EAAE;CAEpC,GAAG,CAAC,aAAA,mBAAA,QAAA,mBAAA,KAAA,IAAA,KAAA,IAAa,eAAgB,EAAE,CAAC;CAEpC,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACC,8BAAAA,YAAAA,sBAAAA,QAAAA,sBAAAA,QA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,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,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;CAC5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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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AAA,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(Tab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BAAA,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"}
@@ -82,7 +82,7 @@ const TextInput = (_ref) => {
82
82
  state: value !== null && value !== void 0 ? value : ""
83
83
  });
84
84
  const hintId = (0, react.useId)();
85
- const canClear = isClearable && isDisabled !== true;
85
+ const canClear = isClearable && isDisabled !== true && isReadOnly !== true;
86
86
  const shouldRenderHint = canClear || isLoading;
87
87
  const { field, controlProps } = require__common_form_control_use_form_field.useFormField({
88
88
  errorText,
@@ -1 +1 @@
1
- {"version":3,"file":"TextInput.js","names":["useSemiControlledInput","useId","useFormField","classNames","customLabelAndNoAriaLabelWarningMessage","FormFieldLabel","Skeleton","LoadingSpinner","XMarkIconOutline","FormFieldMessage"],"sources":["../../../src/text-input/TextInput.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 */\n\nimport classNames from 'classnames';\nimport {\n type InputHTMLAttributes,\n type ReactElement,\n type ReactNode,\n useId,\n useMemo,\n} from 'react';\n\nimport {\n FormFieldLabel,\n FormFieldMessage,\n useFormField,\n} from '../_common/form-control';\nimport { customLabelAndNoAriaLabelWarningMessage } from '../_common/messages';\nimport { type CommonProps, type TooltipObjectProps } from '../_common/types';\nimport { useSemiControlledInput } from '../_common/use-semi-controlled-input';\nimport { needleWarningMessage } from '../_common/utils';\nimport { XMarkIconOutline } from '../icons/generated/heroIcons/XMarkIconOutline';\nimport { LoadingSpinner } from '../loading-spinner';\nimport { Skeleton } from '../skeleton';\n\n/**\n * @remarks\n * When `moreInformationText` is provided, a tooltip is rendered next to the label, and the `tooltipProps` prop is used to configure the tooltip. 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 *\n * @remarks\n * When `isSkeletonLoading` is true, the input is rendered as a loading skeleton and the `skeletonProps` prop is used to configure the skeleton. For more information, see the Skeleton documentation.\n */\ntype TextInputProps = {\n /** Assistive text displayed below the input */\n helpText?: string | ReactNode;\n\n /** Error message displayed below the input. When provided, it overrides `helpText` and shows an error icon */\n errorText?: string | ReactNode;\n\n /** Leading element rendered inside the input */\n leadingElement?: ReactElement;\n\n /** Trailing element rendered inside the input */\n trailingElement?: ReactElement;\n\n /** Size of the input */\n size?: 'small' | 'medium' | 'large';\n\n /** Whether the input is read-only */\n isReadOnly?: boolean;\n\n /**\n * Whether to display the Required/Optional label next to the field label.\n * Shows Required if isRequired is true, otherwise shows Optional.\n * @default false\n */\n // TODO: inconsistent naming. The same switch is `hasRequiredIndicator` on\n // Combobox and on the internal form control this maps onto, and `isOptional`\n // on TextArea. The name also needs the disable below, which a name using one\n // of the allowed boolean prefixes would not.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n showRequiredOrOptionalLabel?: boolean;\n\n /** Whether the input is disabled */\n isDisabled?: boolean;\n\n /** Whether the input is required */\n isRequired?: boolean;\n\n /** The current value of the input */\n value?: React.ComponentPropsWithoutRef<'input'>['value'];\n\n /** Placeholder text displayed when the input is empty */\n placeholder?: React.ComponentPropsWithoutRef<'input'>['placeholder'];\n\n /** Callback function triggered when the input value changes */\n onChange?: React.ComponentPropsWithoutRef<'input'>['onChange'];\n\n /** Whether the input should take the full available width */\n isFluid?: boolean;\n\n /** Text displayed in the information tooltip shown next to the label */\n moreInformationText?: React.ReactNode;\n\n // TODO v5: inconsistent naming. Every form control names itself differently:\n // the label is optional here and a design with no room for it reaches for\n // htmlAttributes['aria-label'], TextArea, Select, Checkbox, Radio and Switch\n // expose an `ariaLabel` prop instead, and Combobox requires the label and\n // clips it with `hasVisuallyHiddenLabel`.\n /** The label displayed above the input */\n label?: string | React.ReactNode;\n\n /** Props for the Tooltip component used by the information icon */\n tooltipProps?: TooltipObjectProps;\n\n /** Whether to render skeletons instead of content */\n isSkeletonLoading?: boolean;\n\n /** Additional props forwarded to the underlying Skeleton components */\n skeletonProps?: React.ComponentProps<typeof Skeleton>;\n\n /** Whether to show the clear button */\n isClearable?: boolean;\n\n /** Whether to show the loading spinner */\n isLoading?: boolean;\n};\n\n/**\n *\n *\n * TextInput Component\n *\n *\n */\n\nexport const TextInput = ({\n label,\n isFluid,\n errorText,\n helpText,\n leadingElement,\n trailingElement,\n showRequiredOrOptionalLabel = false,\n moreInformationText,\n size = 'medium',\n placeholder,\n value,\n tooltipProps,\n htmlAttributes,\n isDisabled,\n isReadOnly,\n isRequired,\n onChange,\n isClearable = false,\n className,\n style,\n isSkeletonLoading = false,\n isLoading = false,\n skeletonProps,\n ref,\n ...restProps\n}: CommonProps<'input', TextInputProps>) => {\n const [currentValue, handleChange] = useSemiControlledInput({\n inputType: 'text',\n isControlled: value !== undefined,\n onChange,\n state: value ?? '',\n });\n const hintId = useId();\n const canClear = isClearable && isDisabled !== true;\n const shouldRenderHint = canClear || isLoading;\n const { field, controlProps } = useFormField({\n errorText,\n // The clear/loading hint describes the input alongside the message.\n extraDescribedByIds: [shouldRenderHint && hintId],\n hasRequiredIndicator: showRequiredOrOptionalLabel,\n helpText,\n isRequired,\n label,\n });\n\n const containerWrappingClasses = classNames(`ndl-text-input`, className, {\n 'ndl-disabled': isDisabled,\n 'ndl-has-error': errorText,\n 'ndl-has-icon': leadingElement || trailingElement || errorText,\n 'ndl-has-leading-icon': leadingElement,\n 'ndl-has-trailing-icon': trailingElement || errorText,\n 'ndl-large': size === 'large',\n 'ndl-medium': size === 'medium',\n 'ndl-read-only': isReadOnly,\n 'ndl-small': size === 'small',\n });\n\n const hasEmptyLabelValue =\n label === undefined || label === null || label === '';\n\n const labelWrappingClasses = classNames('ndl-text-input-label', {\n 'ndl-fluid': isFluid,\n });\n\n const combinedHtmlInputAttributes: InputHTMLAttributes<HTMLInputElement> = {\n ...htmlAttributes,\n className: classNames('ndl-input', htmlAttributes?.className),\n };\n const ariaLabel = combinedHtmlInputAttributes['aria-label'];\n const isCustomLabel = Boolean(label) && typeof label !== 'string';\n const hasCustomLabelAndNoAriaLabel =\n isCustomLabel && (ariaLabel === undefined || ariaLabel === '');\n\n const handleInputKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {\n if (canClear && event.key === 'Escape' && Boolean(currentValue)) {\n event.preventDefault();\n event.stopPropagation();\n handleChange?.({\n target: { value: '' },\n } as React.ChangeEvent<HTMLInputElement>);\n }\n htmlAttributes?.onKeyDown?.(event);\n };\n\n useMemo(() => {\n if (!label && !ariaLabel) {\n needleWarningMessage(\n 'A TextInput without a label does not have an aria label, be sure to include an aria label for screen readers. Link: https://dequeuniversity.com/rules/axe/4.2/label?application=axeAPI',\n );\n }\n\n if (hasCustomLabelAndNoAriaLabel) {\n needleWarningMessage(customLabelAndNoAriaLabelWarningMessage);\n }\n }, [label, ariaLabel, hasCustomLabelAndNoAriaLabel]);\n\n return (\n <div className={containerWrappingClasses} style={style}>\n {/* We enable implicit label wrapping */}\n {/* Source: https://dequeuniversity.com/rules/axe/4.2/label?application=axeAPI */}\n <label className={labelWrappingClasses}>\n {!hasEmptyLabelValue && (\n <FormFieldLabel\n field={field}\n size={size}\n association=\"implicit\"\n moreInformationText={moreInformationText}\n tooltipProps={tooltipProps}\n wrap={(row) => (\n <Skeleton\n onBackground=\"weak\"\n shape=\"rectangular\"\n {...skeletonProps}\n isLoading={isSkeletonLoading}\n >\n {row}\n </Skeleton>\n )}\n />\n )}\n <Skeleton\n onBackground=\"weak\"\n shape=\"rectangular\"\n {...skeletonProps}\n isLoading={isSkeletonLoading}\n >\n <div className=\"ndl-input-wrapper\">\n {(leadingElement || (isLoading && !trailingElement)) && (\n <div className=\"ndl-element-leading ndl-element\">\n {isLoading ? (\n <LoadingSpinner\n size={size === 'large' ? 'medium' : 'small'}\n className={\n size === 'large'\n ? 'ndl-medium-spinner'\n : 'ndl-small-spinner'\n }\n />\n ) : (\n leadingElement\n )}\n </div>\n )}\n <div\n className={classNames('ndl-input-container', {\n 'ndl-clearable': isClearable,\n })}\n >\n <input\n ref={ref}\n readOnly={isReadOnly}\n disabled={isDisabled}\n required={isRequired}\n value={currentValue}\n placeholder={placeholder}\n type=\"text\"\n onChange={handleChange}\n {...controlProps}\n {...combinedHtmlInputAttributes}\n onKeyDown={handleInputKeyDown}\n {...restProps}\n />\n {shouldRenderHint && (\n <span\n id={hintId}\n className=\"ndl-text-input-hint\"\n aria-hidden={true}\n >\n {isLoading && 'Loading '}\n {canClear && 'Press Escape to clear input.'}\n </span>\n )}\n {canClear && Boolean(currentValue) && (\n <div className=\"ndl-element-clear ndl-element\">\n <button\n tabIndex={-1}\n aria-hidden={true}\n type=\"button\"\n title=\"Clear input (Esc)\"\n onClick={() => {\n handleChange?.({\n target: { value: '' },\n } as React.ChangeEvent<HTMLInputElement>);\n }}\n >\n <XMarkIconOutline />\n </button>\n </div>\n )}\n </div>\n {trailingElement && (\n <div className=\"ndl-element-trailing ndl-element\">\n {isLoading && !leadingElement ? (\n <LoadingSpinner\n size={size === 'large' ? 'medium' : 'small'}\n className={\n size === 'large'\n ? 'ndl-medium-spinner'\n : 'ndl-small-spinner'\n }\n />\n ) : (\n trailingElement\n )}\n </div>\n )}\n </div>\n </Skeleton>\n </label>\n\n <FormFieldMessage\n field={field}\n size={size}\n wrap={(content) => (\n <Skeleton\n onBackground=\"weak\"\n shape=\"rectangular\"\n {...skeletonProps}\n isLoading={isSkeletonLoading}\n >\n {content}\n </Skeleton>\n )}\n />\n </div>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuIE;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;;;;;;;;;AAxBF,MAAa,aAAa,SA0BkB;CA1BlB,IAAA,EACxB,OACA,SACA,WACA,UACA,gBACA,iBACA,8BAA8B,OAC9B,qBACA,OAAO,UACP,aACA,OACA,cACA,gBACA,YACA,YACA,YACA,UACA,cAAc,OACd,WACA,OACA,oBAAoB,OACpB,YAAY,OACZ,eACA,QAAA,MACG,YAAA,gCAAA,QAAA,MAAA,SAAA;CAEH,MAAM,CAAC,cAAc,gBAAgBA,0CAAA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A,GAAA,kBAAA,IAAA,CAACH,0BAAAA,UAAAA,sBAAAA,QAAAA,sBAAAA,QAAAA;IACC,cAAa;IACb,OAAM;GACF,GAAA,aAAA,GAAA,CAAA,GAAA;IACJ,WAAW;IAEV,UAAA;GACO,CAAA,CAAA;EAEb,CAAA,CACE;;AAET"}
1
+ {"version":3,"file":"TextInput.js","names":["useSemiControlledInput","useId","useFormField","classNames","customLabelAndNoAriaLabelWarningMessage","FormFieldLabel","Skeleton","LoadingSpinner","XMarkIconOutline","FormFieldMessage"],"sources":["../../../src/text-input/TextInput.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 */\n\nimport classNames from 'classnames';\nimport {\n type InputHTMLAttributes,\n type ReactElement,\n type ReactNode,\n useId,\n useMemo,\n} from 'react';\n\nimport {\n FormFieldLabel,\n FormFieldMessage,\n useFormField,\n} from '../_common/form-control';\nimport { customLabelAndNoAriaLabelWarningMessage } from '../_common/messages';\nimport { type CommonProps, type TooltipObjectProps } from '../_common/types';\nimport { useSemiControlledInput } from '../_common/use-semi-controlled-input';\nimport { needleWarningMessage } from '../_common/utils';\nimport { XMarkIconOutline } from '../icons/generated/heroIcons/XMarkIconOutline';\nimport { LoadingSpinner } from '../loading-spinner';\nimport { Skeleton } from '../skeleton';\n\n/**\n * @remarks\n * When `moreInformationText` is provided, a tooltip is rendered next to the label, and the `tooltipProps` prop is used to configure the tooltip. 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 *\n * @remarks\n * When `isSkeletonLoading` is true, the input is rendered as a loading skeleton and the `skeletonProps` prop is used to configure the skeleton. For more information, see the Skeleton documentation.\n */\ntype TextInputProps = {\n /** Assistive text displayed below the input */\n helpText?: string | ReactNode;\n\n /** Error message displayed below the input. When provided, it overrides `helpText` and shows an error icon */\n errorText?: string | ReactNode;\n\n /** Leading element rendered inside the input */\n leadingElement?: ReactElement;\n\n /** Trailing element rendered inside the input */\n trailingElement?: ReactElement;\n\n /** Size of the input */\n size?: 'small' | 'medium' | 'large';\n\n /** Whether the input is read-only */\n isReadOnly?: boolean;\n\n /**\n * Whether to display the Required/Optional label next to the field label.\n * Shows Required if isRequired is true, otherwise shows Optional.\n * @default false\n */\n // TODO: inconsistent naming. The same switch is `hasRequiredIndicator` on\n // Combobox and on the internal form control this maps onto, and `isOptional`\n // on TextArea. The name also needs the disable below, which a name using one\n // of the allowed boolean prefixes would not.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n showRequiredOrOptionalLabel?: boolean;\n\n /** Whether the input is disabled */\n isDisabled?: boolean;\n\n /** Whether the input is required */\n isRequired?: boolean;\n\n /** The current value of the input */\n value?: React.ComponentPropsWithoutRef<'input'>['value'];\n\n /** Placeholder text displayed when the input is empty */\n placeholder?: React.ComponentPropsWithoutRef<'input'>['placeholder'];\n\n /** Callback function triggered when the input value changes */\n onChange?: React.ComponentPropsWithoutRef<'input'>['onChange'];\n\n /** Whether the input should take the full available width */\n isFluid?: boolean;\n\n /** Text displayed in the information tooltip shown next to the label */\n moreInformationText?: React.ReactNode;\n\n // TODO v5: inconsistent naming. Every form control names itself differently:\n // the label is optional here and a design with no room for it reaches for\n // htmlAttributes['aria-label'], TextArea, Select, Checkbox, Radio and Switch\n // expose an `ariaLabel` prop instead, and Combobox requires the label and\n // clips it with `hasVisuallyHiddenLabel`.\n /** The label displayed above the input */\n label?: string | React.ReactNode;\n\n /** Props for the Tooltip component used by the information icon */\n tooltipProps?: TooltipObjectProps;\n\n /** Whether to render skeletons instead of content */\n isSkeletonLoading?: boolean;\n\n /** Additional props forwarded to the underlying Skeleton components */\n skeletonProps?: React.ComponentProps<typeof Skeleton>;\n\n /** Whether to show the clear button */\n isClearable?: boolean;\n\n /** Whether to show the loading spinner */\n isLoading?: boolean;\n};\n\n/**\n *\n *\n * TextInput Component\n *\n *\n */\n\nexport const TextInput = ({\n label,\n isFluid,\n errorText,\n helpText,\n leadingElement,\n trailingElement,\n showRequiredOrOptionalLabel = false,\n moreInformationText,\n size = 'medium',\n placeholder,\n value,\n tooltipProps,\n htmlAttributes,\n isDisabled,\n isReadOnly,\n isRequired,\n onChange,\n isClearable = false,\n className,\n style,\n isSkeletonLoading = false,\n isLoading = false,\n skeletonProps,\n ref,\n ...restProps\n}: CommonProps<'input', TextInputProps>) => {\n const [currentValue, handleChange] = useSemiControlledInput({\n inputType: 'text',\n isControlled: value !== undefined,\n onChange,\n state: value ?? '',\n });\n const hintId = useId();\n const canClear = isClearable && isDisabled !== true && isReadOnly !== true;\n const shouldRenderHint = canClear || isLoading;\n const { field, controlProps } = useFormField({\n errorText,\n // The clear/loading hint describes the input alongside the message.\n extraDescribedByIds: [shouldRenderHint && hintId],\n hasRequiredIndicator: showRequiredOrOptionalLabel,\n helpText,\n isRequired,\n label,\n });\n\n const containerWrappingClasses = classNames(`ndl-text-input`, className, {\n 'ndl-disabled': isDisabled,\n 'ndl-has-error': errorText,\n 'ndl-has-icon': leadingElement || trailingElement || errorText,\n 'ndl-has-leading-icon': leadingElement,\n 'ndl-has-trailing-icon': trailingElement || errorText,\n 'ndl-large': size === 'large',\n 'ndl-medium': size === 'medium',\n 'ndl-read-only': isReadOnly,\n 'ndl-small': size === 'small',\n });\n\n const hasEmptyLabelValue =\n label === undefined || label === null || label === '';\n\n const labelWrappingClasses = classNames('ndl-text-input-label', {\n 'ndl-fluid': isFluid,\n });\n\n const combinedHtmlInputAttributes: InputHTMLAttributes<HTMLInputElement> = {\n ...htmlAttributes,\n className: classNames('ndl-input', htmlAttributes?.className),\n };\n const ariaLabel = combinedHtmlInputAttributes['aria-label'];\n const isCustomLabel = Boolean(label) && typeof label !== 'string';\n const hasCustomLabelAndNoAriaLabel =\n isCustomLabel && (ariaLabel === undefined || ariaLabel === '');\n\n const handleInputKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {\n if (canClear && event.key === 'Escape' && Boolean(currentValue)) {\n event.preventDefault();\n event.stopPropagation();\n handleChange?.({\n target: { value: '' },\n } as React.ChangeEvent<HTMLInputElement>);\n }\n htmlAttributes?.onKeyDown?.(event);\n };\n\n useMemo(() => {\n if (!label && !ariaLabel) {\n needleWarningMessage(\n 'A TextInput without a label does not have an aria label, be sure to include an aria label for screen readers. Link: https://dequeuniversity.com/rules/axe/4.2/label?application=axeAPI',\n );\n }\n\n if (hasCustomLabelAndNoAriaLabel) {\n needleWarningMessage(customLabelAndNoAriaLabelWarningMessage);\n }\n }, [label, ariaLabel, hasCustomLabelAndNoAriaLabel]);\n\n return (\n <div className={containerWrappingClasses} style={style}>\n {/* We enable implicit label wrapping */}\n {/* Source: https://dequeuniversity.com/rules/axe/4.2/label?application=axeAPI */}\n <label className={labelWrappingClasses}>\n {!hasEmptyLabelValue && (\n <FormFieldLabel\n field={field}\n size={size}\n association=\"implicit\"\n moreInformationText={moreInformationText}\n tooltipProps={tooltipProps}\n wrap={(row) => (\n <Skeleton\n onBackground=\"weak\"\n shape=\"rectangular\"\n {...skeletonProps}\n isLoading={isSkeletonLoading}\n >\n {row}\n </Skeleton>\n )}\n />\n )}\n <Skeleton\n onBackground=\"weak\"\n shape=\"rectangular\"\n {...skeletonProps}\n isLoading={isSkeletonLoading}\n >\n <div className=\"ndl-input-wrapper\">\n {(leadingElement || (isLoading && !trailingElement)) && (\n <div className=\"ndl-element-leading ndl-element\">\n {isLoading ? (\n <LoadingSpinner\n size={size === 'large' ? 'medium' : 'small'}\n className={\n size === 'large'\n ? 'ndl-medium-spinner'\n : 'ndl-small-spinner'\n }\n />\n ) : (\n leadingElement\n )}\n </div>\n )}\n <div\n className={classNames('ndl-input-container', {\n 'ndl-clearable': isClearable,\n })}\n >\n <input\n ref={ref}\n readOnly={isReadOnly}\n disabled={isDisabled}\n required={isRequired}\n value={currentValue}\n placeholder={placeholder}\n type=\"text\"\n onChange={handleChange}\n {...controlProps}\n {...combinedHtmlInputAttributes}\n onKeyDown={handleInputKeyDown}\n {...restProps}\n />\n {shouldRenderHint && (\n <span\n id={hintId}\n className=\"ndl-text-input-hint\"\n aria-hidden={true}\n >\n {isLoading && 'Loading '}\n {canClear && 'Press Escape to clear input.'}\n </span>\n )}\n {canClear && Boolean(currentValue) && (\n <div className=\"ndl-element-clear ndl-element\">\n <button\n tabIndex={-1}\n aria-hidden={true}\n type=\"button\"\n title=\"Clear input (Esc)\"\n onClick={() => {\n handleChange?.({\n target: { value: '' },\n } as React.ChangeEvent<HTMLInputElement>);\n }}\n >\n <XMarkIconOutline />\n </button>\n </div>\n )}\n </div>\n {trailingElement && (\n <div className=\"ndl-element-trailing ndl-element\">\n {isLoading && !leadingElement ? (\n <LoadingSpinner\n size={size === 'large' ? 'medium' : 'small'}\n className={\n size === 'large'\n ? 'ndl-medium-spinner'\n : 'ndl-small-spinner'\n }\n />\n ) : (\n trailingElement\n )}\n </div>\n )}\n </div>\n </Skeleton>\n </label>\n\n <FormFieldMessage\n field={field}\n size={size}\n wrap={(content) => (\n <Skeleton\n onBackground=\"weak\"\n shape=\"rectangular\"\n {...skeletonProps}\n isLoading={isSkeletonLoading}\n >\n {content}\n </Skeleton>\n )}\n />\n </div>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuIE;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;C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;MACJ,mBACC,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;OAAK,WAAU;OACZ,UAAA,aAAa,CAAC,iBACb,iBAAA,GAAA,kBAAA,IAAA,CAACD,uCAAAA,gBAAD;QACE,MAAM,SAAS,UAAU,WAAW;QACpC,WACE,SAAS,UACL,uBACA;OAEP,CAAA,IAED;MAEC,CAAA;KAEJ;;GACG,CAAA,CAAA,CACL;EAEP,CAAA,GAAA,iBAAA,GAAA,kBAAA,IAAA,CAACE,8CAAAA,kBAAD;GACS;GACD;GACN,OAAO,YACL,iBAAA,GAAA,kBAAA,IAAA,CAACH,0BAAAA,UAAAA,sBAAAA,QAAAA,sBAAAA,QAAAA;IACC,cAAa;IACb,OAAM;GACF,GAAA,aAAA,GAAA,CAAA,GAAA;IACJ,WAAW;IAEV,UAAA;GACO,CAAA,CAAA;EAEb,CAAA,CACE;;AAET"}
@@ -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)(() => {