@hitachivantara/uikit-react-core 5.9.1 → 5.11.0

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 (117) hide show
  1. package/dist/cjs/components/ActionsGeneric/ActionsGeneric.cjs.map +1 -1
  2. package/dist/cjs/components/BaseInput/BaseInput.cjs +18 -1
  3. package/dist/cjs/components/BaseInput/BaseInput.cjs.map +1 -1
  4. package/dist/cjs/components/BreadCrumb/BreadCrumb.cjs +3 -3
  5. package/dist/cjs/components/BreadCrumb/BreadCrumb.cjs.map +1 -1
  6. package/dist/cjs/components/BreadCrumb/Page/Page.cjs +22 -12
  7. package/dist/cjs/components/BreadCrumb/Page/Page.cjs.map +1 -1
  8. package/dist/cjs/components/BreadCrumb/Page/Page.styles.cjs +19 -44
  9. package/dist/cjs/components/BreadCrumb/Page/Page.styles.cjs.map +1 -1
  10. package/dist/cjs/components/Calendar/CalendarHeader/CalendarHeader.styles.cjs +4 -8
  11. package/dist/cjs/components/Calendar/CalendarHeader/CalendarHeader.styles.cjs.map +1 -1
  12. package/dist/cjs/components/Calendar/SingleCalendar/CalendarCell.cjs +5 -17
  13. package/dist/cjs/components/Calendar/SingleCalendar/CalendarCell.cjs.map +1 -1
  14. package/dist/cjs/components/Calendar/utils.cjs +0 -8
  15. package/dist/cjs/components/Calendar/utils.cjs.map +1 -1
  16. package/dist/cjs/components/DropDownMenu/DropDownMenu.cjs +24 -29
  17. package/dist/cjs/components/DropDownMenu/DropDownMenu.cjs.map +1 -1
  18. package/dist/cjs/components/DropDownMenu/DropDownMenu.styles.cjs +27 -75
  19. package/dist/cjs/components/DropDownMenu/DropDownMenu.styles.cjs.map +1 -1
  20. package/dist/cjs/components/DropDownMenu/dropDownMenuClasses.cjs +1 -1
  21. package/dist/cjs/components/DropDownMenu/dropDownMenuClasses.cjs.map +1 -1
  22. package/dist/cjs/components/FileUploader/DropZone/DropZone.cjs +5 -4
  23. package/dist/cjs/components/FileUploader/DropZone/DropZone.cjs.map +1 -1
  24. package/dist/cjs/components/Pagination/Pagination.styles.cjs +10 -14
  25. package/dist/cjs/components/Pagination/Pagination.styles.cjs.map +1 -1
  26. package/dist/cjs/components/Table/TableCell/TableCell.cjs +4 -4
  27. package/dist/cjs/components/Table/TableCell/TableCell.cjs.map +1 -1
  28. package/dist/cjs/components/Table/TableCell/TableCell.styles.cjs +2 -14
  29. package/dist/cjs/components/Table/TableCell/TableCell.styles.cjs.map +1 -1
  30. package/dist/cjs/components/Table/TableRow/TableRow.cjs +6 -6
  31. package/dist/cjs/components/Table/TableRow/TableRow.cjs.map +1 -1
  32. package/dist/cjs/components/Table/utils/utils.cjs +0 -5
  33. package/dist/cjs/components/Table/utils/utils.cjs.map +1 -1
  34. package/dist/cjs/components/Tooltip/Tooltip.cjs.map +1 -1
  35. package/dist/cjs/components/Tooltip/Tooltip.styles.cjs +23 -37
  36. package/dist/cjs/components/Tooltip/Tooltip.styles.cjs.map +1 -1
  37. package/dist/cjs/components/VerticalNavigation/Actions/Actions.cjs +2 -2
  38. package/dist/cjs/components/VerticalNavigation/Actions/Actions.cjs.map +1 -1
  39. package/dist/cjs/components/VerticalNavigation/Header/Header.cjs +2 -2
  40. package/dist/cjs/components/VerticalNavigation/Header/Header.cjs.map +1 -1
  41. package/dist/cjs/components/VerticalNavigation/Navigation/Navigation.cjs +15 -8
  42. package/dist/cjs/components/VerticalNavigation/Navigation/Navigation.cjs.map +1 -1
  43. package/dist/cjs/components/VerticalNavigation/NavigationPopup/NavigationPopup.cjs +1 -0
  44. package/dist/cjs/components/VerticalNavigation/NavigationPopup/NavigationPopup.cjs.map +1 -1
  45. package/dist/cjs/components/VerticalNavigation/TreeView/TreeViewItem.cjs +5 -5
  46. package/dist/cjs/components/VerticalNavigation/TreeView/TreeViewItem.cjs.map +1 -1
  47. package/dist/cjs/components/VerticalNavigation/VerticalNavigation.cjs +7 -3
  48. package/dist/cjs/components/VerticalNavigation/VerticalNavigation.cjs.map +1 -1
  49. package/dist/cjs/components/VerticalNavigation/VerticalNavigationContext.cjs +1 -1
  50. package/dist/cjs/components/VerticalNavigation/VerticalNavigationContext.cjs.map +1 -1
  51. package/dist/cjs/hooks/useUniqueId.cjs +1 -1
  52. package/dist/cjs/hooks/useUniqueId.cjs.map +1 -1
  53. package/dist/cjs/index.cjs +2 -3
  54. package/dist/cjs/index.cjs.map +1 -1
  55. package/dist/cjs/utils/checkValidHexColorValue.cjs +9 -0
  56. package/dist/cjs/utils/checkValidHexColorValue.cjs.map +1 -0
  57. package/dist/esm/components/ActionsGeneric/ActionsGeneric.js.map +1 -1
  58. package/dist/esm/components/BaseInput/BaseInput.js +18 -1
  59. package/dist/esm/components/BaseInput/BaseInput.js.map +1 -1
  60. package/dist/esm/components/BreadCrumb/BreadCrumb.js +3 -3
  61. package/dist/esm/components/BreadCrumb/BreadCrumb.js.map +1 -1
  62. package/dist/esm/components/BreadCrumb/Page/Page.js +23 -13
  63. package/dist/esm/components/BreadCrumb/Page/Page.js.map +1 -1
  64. package/dist/esm/components/BreadCrumb/Page/Page.styles.js +19 -42
  65. package/dist/esm/components/BreadCrumb/Page/Page.styles.js.map +1 -1
  66. package/dist/esm/components/Calendar/CalendarHeader/CalendarHeader.styles.js +4 -8
  67. package/dist/esm/components/Calendar/CalendarHeader/CalendarHeader.styles.js.map +1 -1
  68. package/dist/esm/components/Calendar/SingleCalendar/CalendarCell.js +6 -18
  69. package/dist/esm/components/Calendar/SingleCalendar/CalendarCell.js.map +1 -1
  70. package/dist/esm/components/Calendar/utils.js +1 -9
  71. package/dist/esm/components/Calendar/utils.js.map +1 -1
  72. package/dist/esm/components/DropDownMenu/DropDownMenu.js +25 -30
  73. package/dist/esm/components/DropDownMenu/DropDownMenu.js.map +1 -1
  74. package/dist/esm/components/DropDownMenu/DropDownMenu.styles.js +27 -73
  75. package/dist/esm/components/DropDownMenu/DropDownMenu.styles.js.map +1 -1
  76. package/dist/esm/components/DropDownMenu/dropDownMenuClasses.js +1 -1
  77. package/dist/esm/components/DropDownMenu/dropDownMenuClasses.js.map +1 -1
  78. package/dist/esm/components/FileUploader/DropZone/DropZone.js +5 -4
  79. package/dist/esm/components/FileUploader/DropZone/DropZone.js.map +1 -1
  80. package/dist/esm/components/Pagination/Pagination.styles.js +10 -14
  81. package/dist/esm/components/Pagination/Pagination.styles.js.map +1 -1
  82. package/dist/esm/components/Table/TableCell/TableCell.js +2 -2
  83. package/dist/esm/components/Table/TableCell/TableCell.js.map +1 -1
  84. package/dist/esm/components/Table/TableCell/TableCell.styles.js +2 -14
  85. package/dist/esm/components/Table/TableCell/TableCell.styles.js.map +1 -1
  86. package/dist/esm/components/Table/TableRow/TableRow.js +2 -2
  87. package/dist/esm/components/Table/TableRow/TableRow.js.map +1 -1
  88. package/dist/esm/components/Table/utils/utils.js +0 -5
  89. package/dist/esm/components/Table/utils/utils.js.map +1 -1
  90. package/dist/esm/components/Tooltip/Tooltip.js.map +1 -1
  91. package/dist/esm/components/Tooltip/Tooltip.styles.js +24 -38
  92. package/dist/esm/components/Tooltip/Tooltip.styles.js.map +1 -1
  93. package/dist/esm/components/VerticalNavigation/Actions/Actions.js +2 -2
  94. package/dist/esm/components/VerticalNavigation/Actions/Actions.js.map +1 -1
  95. package/dist/esm/components/VerticalNavigation/Header/Header.js +2 -2
  96. package/dist/esm/components/VerticalNavigation/Header/Header.js.map +1 -1
  97. package/dist/esm/components/VerticalNavigation/Navigation/Navigation.js +15 -8
  98. package/dist/esm/components/VerticalNavigation/Navigation/Navigation.js.map +1 -1
  99. package/dist/esm/components/VerticalNavigation/NavigationPopup/NavigationPopup.js +1 -0
  100. package/dist/esm/components/VerticalNavigation/NavigationPopup/NavigationPopup.js.map +1 -1
  101. package/dist/esm/components/VerticalNavigation/TreeView/TreeViewItem.js +5 -5
  102. package/dist/esm/components/VerticalNavigation/TreeView/TreeViewItem.js.map +1 -1
  103. package/dist/esm/components/VerticalNavigation/VerticalNavigation.js +7 -3
  104. package/dist/esm/components/VerticalNavigation/VerticalNavigation.js.map +1 -1
  105. package/dist/esm/components/VerticalNavigation/VerticalNavigationContext.js +1 -1
  106. package/dist/esm/components/VerticalNavigation/VerticalNavigationContext.js.map +1 -1
  107. package/dist/esm/hooks/useUniqueId.js +2 -2
  108. package/dist/esm/hooks/useUniqueId.js.map +1 -1
  109. package/dist/esm/index.js +5 -6
  110. package/dist/esm/utils/checkValidHexColorValue.js +9 -0
  111. package/dist/esm/utils/checkValidHexColorValue.js.map +1 -0
  112. package/dist/types/index.d.ts +41 -45
  113. package/package.json +5 -5
  114. package/dist/cjs/hocs/withId.cjs +0 -31
  115. package/dist/cjs/hocs/withId.cjs.map +0 -1
  116. package/dist/esm/hocs/withId.js +0 -28
  117. package/dist/esm/hocs/withId.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"TreeViewItem.js","sources":["../../../../../src/components/VerticalNavigation/TreeView/TreeViewItem.tsx"],"sourcesContent":["import {\n forwardRef,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { clsx } from \"clsx\";\nimport { DropDownXS, DropUpXS } from \"@hitachivantara/uikit-react-icons\";\nimport { useForkRef } from \"@core/hooks\";\nimport { setId } from \"@core/utils\";\nimport treeViewItemClasses, {\n HvVerticalNavigationTreeViewItemClasses,\n} from \"./treeViewItemClasses\";\nimport { StyledContent, StyledGroup, StyledNode } from \"./TreeViewItem.styles\";\nimport { DescendantProvider, useDescendant } from \"./descendants\";\nimport {\n TreeViewControlContext,\n TreeViewStateContext,\n} from \"./TreeViewContext\";\nimport { VerticalNavigationContext } from \"..\";\nimport { IconWrapper } from \"./IconWrapper\";\n\nexport interface HvVerticalNavigationTreeViewItemProps {\n /**\n * Id to be applied to the root node.\n */\n id?: string;\n /**\n * Class names to be applied.\n */\n className?: string;\n /**\n * A Jss Object used to override or extend the styles applied to the Radio button.\n */\n classes?: HvVerticalNavigationTreeViewItemClasses;\n /**\n * Is the node disabled.\n */\n disabled?: boolean;\n /**\n * Can the node be selected.\n */\n selectable?: boolean;\n /**\n * The id of the node.\n */\n nodeId?: string;\n /**\n * The icon to display next to the node's label.\n */\n icon?: React.ReactNode;\n /**\n * The item label.\n */\n label?: React.ReactNode;\n /**\n * The url for the link.\n */\n href?: string;\n /**\n * The behavior when opening a link.\n */\n target?: string;\n /**\n * The node payload.\n */\n payload?: any;\n /**\n * @ignore\n */\n onClick?: any;\n /**\n * @ignore\n */\n onMouseDown?: any;\n /**\n * @ignore\n */\n onFocus?: any;\n /**\n * The content of the component.\n */\n children?: React.ReactNode;\n /**\n * @ignore\n */\n onMouseEnter?: any;\n /**\n * Disables the appearence of a tooltip on hovering an element ( Only applicable when the in collapsed mode)\n */\n disableTooltip?: boolean;\n}\n\nconst preventSelection = (event, disabled) => {\n if (event.shiftKey || event.ctrlKey || event.metaKey || disabled) {\n // Prevent text selection\n event.preventDefault();\n }\n};\n\nexport const HvVerticalNavigationTreeViewItem = forwardRef(\n (props: HvVerticalNavigationTreeViewItemProps, ref) => {\n const {\n id: idProp,\n className,\n classes,\n\n disabled: disabledProp = false,\n\n selectable: selectableProp,\n\n nodeId,\n icon = null,\n label,\n href,\n target,\n payload,\n\n onClick,\n onMouseDown,\n onFocus,\n\n children,\n\n disableTooltip,\n\n ...others\n } = props;\n\n const treeViewControlContext = useContext(TreeViewControlContext);\n const { isExpanded, isSelected, isFocused, isDisabled, isChildSelected } =\n useContext(TreeViewStateContext);\n\n const {\n treeId,\n mode,\n collapsible,\n toggleExpansion,\n multiSelect,\n selectNode,\n selectRange,\n disabledItemsFocusable,\n registerNode,\n unregisterNode,\n mapFirstChar,\n unMapFirstChar,\n focus,\n } = treeViewControlContext;\n\n const treeviewMode = mode === \"treeview\";\n\n let id: string | null = null;\n\n if (idProp != null) {\n id = idProp;\n } else if (treeId && nodeId) {\n id = `${treeId}-${nodeId}`;\n }\n\n const [treeitemElement, setTreeitemElement] = useState(null);\n const contentRef = useRef<HTMLDivElement>(null);\n const handleRef = useForkRef(setTreeitemElement, ref);\n\n const descendant = useMemo(\n () => ({\n element: treeitemElement,\n id: nodeId,\n }),\n [nodeId, treeitemElement]\n );\n\n const { isOpen, collapsedMode } = useContext(VerticalNavigationContext);\n\n const { index, parentId, level } = useDescendant(descendant);\n\n const expandable = collapsible && Array.isArray(children);\n const expanded = isExpanded ? isExpanded(nodeId) : false;\n const focused = isFocused ? isFocused(nodeId) : false;\n const selected = isSelected ? isSelected(nodeId) : false;\n const disabled = isDisabled ? isDisabled(nodeId) : false;\n\n const selectable =\n selectableProp != null\n ? selectableProp\n : !collapsible || !expandable || !isOpen;\n\n useEffect(() => {\n // On the first render a node's index will be -1. We want to wait for the real index.\n if (registerNode && unregisterNode && index !== -1) {\n registerNode({\n id: nodeId,\n idAttribute: id,\n index,\n parentId,\n selectable,\n expandable,\n disabled: disabledProp,\n onFocus,\n payload,\n });\n\n return () => {\n unregisterNode(nodeId);\n };\n }\n\n return undefined;\n }, [\n registerNode,\n unregisterNode,\n parentId,\n index,\n nodeId,\n expandable,\n disabledProp,\n id,\n selectable,\n onFocus,\n payload,\n ]);\n\n useEffect(() => {\n if (\n mapFirstChar &&\n unMapFirstChar &&\n label &&\n contentRef.current?.textContent\n ) {\n mapFirstChar(\n nodeId,\n contentRef.current?.textContent.substring(0, 1).toLowerCase()\n );\n\n return () => {\n unMapFirstChar(nodeId);\n };\n }\n return undefined;\n }, [mapFirstChar, unMapFirstChar, nodeId, label]);\n\n let ariaSelected;\n if (multiSelect) {\n ariaSelected = selected;\n } else if (selected) {\n /* single-selection trees unset aria-selected on un-selected items.\n *\n * If the tree does not support multiple selection, aria-selected\n * is set to true for the selected node and it is not present on any other node in the tree.\n * Source: https://www.w3.org/TR/wai-aria-practices/#TreeView\n */\n ariaSelected = true;\n }\n\n const handleFocus = useCallback(\n (event) => {\n // DOM focus stays on the tree which manages focus with aria-activedescendant\n if (event.target === event.currentTarget) {\n (event.target.ownerDocument || document)\n .getElementById(treeId)\n .focus({ preventScroll: true });\n }\n\n const unfocusable = !disabledItemsFocusable && disabled;\n if (\n !focused &&\n event.currentTarget === event.target &&\n !unfocusable &&\n focus\n ) {\n focus(event, nodeId);\n }\n },\n [disabled, disabledItemsFocusable, focus, focused, nodeId, treeId]\n );\n\n const handleExpansion = useCallback(\n (event) => {\n if (!disabled) {\n if (treeviewMode && !focused && focus) {\n focus(event, nodeId);\n }\n\n const multiple =\n multiSelect && (event.shiftKey || event.ctrlKey || event.metaKey);\n\n // If already expanded and trying to toggle selection don't close\n if (\n expandable &&\n isOpen &&\n !(multiple && isExpanded && isExpanded(nodeId))\n ) {\n if (toggleExpansion) toggleExpansion(event, nodeId);\n }\n }\n },\n [\n disabled,\n expandable,\n focus,\n focused,\n isExpanded,\n multiSelect,\n nodeId,\n toggleExpansion,\n treeviewMode,\n ]\n );\n\n const handleSelection = useCallback(\n (event) => {\n if (selectable && !disabled) {\n if (treeviewMode && !focused && focus) {\n focus(event, nodeId);\n }\n\n const multiple =\n multiSelect && (event.shiftKey || event.ctrlKey || event.metaKey);\n\n if (multiple) {\n if (event.shiftKey) {\n if (selectRange) return selectRange(event, { end: nodeId });\n } else if (selectNode) return selectNode(event, nodeId, true);\n } else if (selectNode) return selectNode(event, nodeId);\n } else {\n return false;\n }\n },\n [\n disabled,\n focus,\n focused,\n multiSelect,\n nodeId,\n selectNode,\n selectRange,\n selectable,\n treeviewMode,\n ]\n );\n\n const handleMouseDown = useCallback(\n (event) => {\n preventSelection(event, disabled);\n\n if (onMouseDown) {\n onMouseDown(event);\n }\n },\n [disabled, onMouseDown]\n );\n\n const handleClick = useCallback(\n (event) => {\n if (!disabled) {\n if (expandable && isOpen) {\n handleExpansion(event);\n }\n\n if (selectable) {\n handleSelection(event);\n }\n }\n\n if (onClick) {\n onClick(event);\n }\n },\n [\n disabled,\n expandable,\n handleExpansion,\n handleSelection,\n onClick,\n selectable,\n ]\n );\n\n const handleKeyDown = useCallback(\n (event) => {\n let isEventHandled = false;\n const { key } = event;\n\n if (\n event.altKey ||\n event.ctrlKey ||\n event.metaKey ||\n event.currentTarget !== event.target\n ) {\n return;\n }\n if (contentRef.current === event.currentTarget) {\n if (key === \"Enter\" || key === \" \") {\n if (expandable && isOpen) {\n isEventHandled = handleExpansion(event) as unknown as boolean;\n }\n\n if (selectable) {\n isEventHandled = handleSelection(event) as boolean;\n }\n }\n\n if (isEventHandled) {\n event.preventDefault();\n event.stopPropagation();\n }\n }\n },\n [expandable, handleExpansion, handleSelection, selectable]\n );\n\n const renderedContent = useMemo(\n () => (\n <StyledContent\n id={setId(id, \"button\")}\n component={href ? \"a\" : \"div\"}\n href={href}\n target={target}\n ref={contentRef}\n className={clsx(\n treeViewItemClasses.content,\n classes?.content,\n href != null && clsx(treeViewItemClasses.link, classes?.link),\n !isOpen && clsx(treeViewItemClasses.minimized, classes?.minimized)\n )}\n variant=\"body\"\n disabled={disabled}\n onClick={handleClick}\n onMouseDown={handleMouseDown}\n style={{\n paddingLeft:\n (expandable || icon != null || !isOpen ? 0 : 10) +\n level * (collapsible ? 32 : 10),\n }}\n role={href ? undefined : \"button\"}\n {...(treeviewMode\n ? {\n tabIndex: -1,\n onFocus: handleFocus,\n }\n : {\n tabIndex: selectable || expandable ? 0 : -1,\n onKeyDown: handleKeyDown,\n \"aria-current\":\n (selectable && selected) ||\n (!isOpen && isChildSelected?.(nodeId))\n ? href\n ? \"page\"\n : true\n : undefined,\n \"aria-expanded\": expandable ? expanded : undefined,\n \"aria-controls\": expandable ? setId(id, \"group\") : undefined,\n \"aria-label\": payload?.label,\n })}\n >\n {isOpen && expandable && (expanded ? <DropUpXS /> : <DropDownXS />)}\n\n <IconWrapper\n icon={icon}\n label={payload?.label}\n hasChildren={Boolean(children)}\n showAvatar={\n !icon && level === 0 && !isOpen && collapsedMode === \"icon\"\n }\n isOpen={isOpen}\n disableTooltip={disableTooltip}\n />\n\n {isOpen && label}\n </StyledContent>\n ),\n [\n id,\n href,\n target,\n classes?.content,\n treeViewItemClasses.content,\n classes?.link,\n treeViewItemClasses.link,\n classes?.minimized,\n treeViewItemClasses.minimized,\n disabled,\n handleClick,\n handleMouseDown,\n expandable,\n icon,\n level,\n collapsible,\n treeviewMode,\n handleFocus,\n selectable,\n handleKeyDown,\n selected,\n expanded,\n label,\n disableTooltip,\n ]\n );\n\n const renderedChildren = useMemo(\n () =>\n children && (\n <StyledGroup\n id={setId(id, \"group\")}\n className={clsx(treeViewItemClasses.group, classes?.group)}\n role={treeviewMode ? \"group\" : undefined}\n >\n {children}\n </StyledGroup>\n ),\n [children, treeViewItemClasses.group, classes?.group, id, treeviewMode]\n );\n\n return (\n <StyledNode\n ref={handleRef}\n id={id ?? undefined}\n className={clsx(\n treeViewItemClasses?.node,\n classes?.node,\n className,\n disabled && clsx(treeViewItemClasses.disabled, classes?.disabled),\n expandable &&\n clsx(treeViewItemClasses.expandable, classes?.expandable),\n expandable &&\n !expanded &&\n clsx(treeViewItemClasses.collapsed, classes?.collapsed),\n expandable &&\n expanded &&\n clsx(treeViewItemClasses.expanded, classes?.expanded),\n selectable &&\n !disabled &&\n clsx(treeViewItemClasses.selectable, classes?.selectable),\n !disabled &&\n !selectable &&\n clsx(treeViewItemClasses.unselectable, classes?.unselectable),\n !disabled &&\n selectable &&\n selected &&\n clsx(treeViewItemClasses.selected, classes?.selected),\n !disabled &&\n selectable &&\n !selected &&\n clsx(treeViewItemClasses.unselected, classes?.unselected),\n focused && clsx(treeViewItemClasses.focused, classes?.focused),\n !isOpen &&\n collapsedMode === \"simple\" &&\n clsx(treeViewItemClasses.hide, classes?.hide),\n !isOpen &&\n collapsedMode === \"icon\" &&\n isChildSelected &&\n isChildSelected(nodeId) &&\n clsx(treeViewItemClasses.selected, classes?.selected)\n )}\n data-hasicon={icon != null ? true : undefined}\n {...(mode === \"treeview\" && {\n role: \"treeitem\",\n \"aria-selected\": ariaSelected,\n \"aria-expanded\": expandable ? expanded : undefined,\n \"aria-disabled\": disabled ? true : undefined,\n })}\n {...others}\n >\n {renderedContent}\n {isOpen && (\n <DescendantProvider id={nodeId} level={level + 1}>\n {renderedChildren}\n </DescendantProvider>\n )}\n </StyledNode>\n );\n }\n);\n"],"names":["preventSelection","event","disabled","shiftKey","ctrlKey","metaKey","preventDefault","HvVerticalNavigationTreeViewItem","forwardRef","props","ref","id","idProp","className","classes","disabledProp","selectable","selectableProp","nodeId","icon","label","href","target","payload","onClick","onMouseDown","onFocus","children","disableTooltip","others","treeViewControlContext","useContext","TreeViewControlContext","isExpanded","isSelected","isFocused","isDisabled","isChildSelected","TreeViewStateContext","treeId","mode","collapsible","toggleExpansion","multiSelect","selectNode","selectRange","disabledItemsFocusable","registerNode","unregisterNode","mapFirstChar","unMapFirstChar","focus","treeviewMode","treeitemElement","setTreeitemElement","useState","contentRef","useRef","handleRef","useForkRef","descendant","useMemo","element","isOpen","collapsedMode","VerticalNavigationContext","index","parentId","level","useDescendant","expandable","Array","isArray","expanded","focused","selected","useEffect","idAttribute","undefined","current","textContent","substring","toLowerCase","ariaSelected","handleFocus","useCallback","currentTarget","ownerDocument","document","getElementById","preventScroll","unfocusable","handleExpansion","multiple","handleSelection","end","handleMouseDown","handleClick","handleKeyDown","isEventHandled","key","altKey","stopPropagation","renderedContent","_jsxs","StyledContent","setId","component","clsx","treeViewItemClasses","content","link","minimized","variant","style","paddingLeft","role","tabIndex","onKeyDown","DropUpXS","DropDownXS","IconWrapper","hasChildren","Boolean","showAvatar","renderedChildren","StyledGroup","group","StyledNode","node","collapsed","unselectable","unselected","hide","DescendantProvider"],"mappings":";;;;;;;;;;;;AAgGA,MAAMA,mBAAmBA,CAACC,OAAOC,aAAa;AAC5C,MAAID,MAAME,YAAYF,MAAMG,WAAWH,MAAMI,WAAWH,UAAU;AAEhED,UAAMK,eAAgB;AAAA,EACxB;AACF;AAEO,MAAMC,mCAAmCC,WAC9C,CAACC,OAA8CC,QAAQ;;AAC/C,QAAA;AAAA,IACJC,IAAIC;AAAAA,IACJC;AAAAA,IACAC;AAAAA,IAEAZ,UAAUa,eAAe;AAAA,IAEzBC,YAAYC;A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jI,YACCc,cACA2D,YACAiC,KAAKC,oBAAoBlC,UAAU7D,mCAAS6D,QAAQ,GACtD,CAACzE,YACCc,cACA,CAAC2D,YACDiC,KAAKC,oBAAoBuB,YAAYtH,mCAASsH,UAAU,GAC1D1D,WAAWkC,KAAKC,oBAAoBnC,SAAS5D,mCAAS4D,OAAO,GAC7D,CAACX,UACCC,kBAAkB,YAClB4C,KAAKC,oBAAoBwB,MAAMvH,mCAASuH,IAAI,GAC9C,CAACtE,UACCC,kBAAkB,UAClB3B,mBACAA,gBAAgBnB,MAAM,KACtB0F,KAAKC,oBAAoBlC,UAAU7D,mCAAS6D,QAAQ,CAAC;AAAA,IAEzD,gBAAcxD,QAAQ,OAAO,OAAO2D;AAAAA,IAAU,GACzCtC,SAAS,cAAc;AAAA,MAC1B4E,MAAM;AAAA,MACN,iBAAiBjC;AAAAA,MACjB,iBAAiBb,aAAaG,WAAWK;AAAAA,MACzC,iBAAiB5E,WAAW,OAAO4E;AAAAA,IACrC;AAAA,IAAC,GACGjD;AAAAA,IAAMF,WAET4E,iBACAxC,8BACEuE,oBAAkB;AAAA,MAAC3H,IAAIO;AAAAA,MAAQkD,OAAOA,QAAQ;AAAA,MAAEzC,UAC9CkG;AAAAA,IAAAA,CAEJ,CAAA;AAAA,EAAA,CACU;AAEjB,CAAC;"}
1
+ {"version":3,"file":"TreeViewItem.js","sources":["../../../../../src/components/VerticalNavigation/TreeView/TreeViewItem.tsx"],"sourcesContent":["import {\n forwardRef,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { clsx } from \"clsx\";\nimport { DropDownXS, DropUpXS } from \"@hitachivantara/uikit-react-icons\";\nimport { useForkRef } from \"@core/hooks\";\nimport { setId } from \"@core/utils\";\nimport treeViewItemClasses, {\n HvVerticalNavigationTreeViewItemClasses,\n} from \"./treeViewItemClasses\";\nimport { StyledContent, StyledGroup, StyledNode } from \"./TreeViewItem.styles\";\nimport { DescendantProvider, useDescendant } from \"./descendants\";\nimport {\n TreeViewControlContext,\n TreeViewStateContext,\n} from \"./TreeViewContext\";\nimport { VerticalNavigationContext } from \"..\";\nimport { IconWrapper } from \"./IconWrapper\";\n\nexport interface HvVerticalNavigationTreeViewItemProps {\n /**\n * Id to be applied to the root node.\n */\n id?: string;\n /**\n * Class names to be applied.\n */\n className?: string;\n /**\n * A Jss Object used to override or extend the styles applied to the Radio button.\n */\n classes?: HvVerticalNavigationTreeViewItemClasses;\n /**\n * Is the node disabled.\n */\n disabled?: boolean;\n /**\n * Can the node be selected.\n */\n selectable?: boolean;\n /**\n * The id of the node.\n */\n nodeId?: string;\n /**\n * The icon to display next to the node's label.\n */\n icon?: React.ReactNode;\n /**\n * The item label.\n */\n label?: React.ReactNode;\n /**\n * The url for the link.\n */\n href?: string;\n /**\n * The behavior when opening a link.\n */\n target?: string;\n /**\n * The node payload.\n */\n payload?: any;\n /**\n * @ignore\n */\n onClick?: any;\n /**\n * @ignore\n */\n onMouseDown?: any;\n /**\n * @ignore\n */\n onFocus?: any;\n /**\n * The content of the component.\n */\n children?: React.ReactNode;\n /**\n * @ignore\n */\n onMouseEnter?: any;\n /**\n * Disables the appearence of a tooltip on hovering an element ( Only applicable when the in collapsed mode)\n */\n disableTooltip?: boolean;\n}\n\nconst preventSelection = (event, disabled) => {\n if (event.shiftKey || event.ctrlKey || event.metaKey || disabled) {\n // Prevent text selection\n event.preventDefault();\n }\n};\n\nexport const HvVerticalNavigationTreeViewItem = forwardRef(\n (props: HvVerticalNavigationTreeViewItemProps, ref) => {\n const {\n id: idProp,\n className,\n classes,\n\n disabled: disabledProp = false,\n\n selectable: selectableProp,\n\n nodeId,\n icon = null,\n label,\n href,\n target,\n payload,\n\n onClick,\n onMouseDown,\n onFocus,\n\n children,\n\n disableTooltip,\n\n ...others\n } = props;\n\n const treeViewControlContext = useContext(TreeViewControlContext);\n const { isExpanded, isSelected, isFocused, isDisabled, isChildSelected } =\n useContext(TreeViewStateContext);\n\n const {\n treeId,\n mode,\n collapsible,\n toggleExpansion,\n multiSelect,\n selectNode,\n selectRange,\n disabledItemsFocusable,\n registerNode,\n unregisterNode,\n mapFirstChar,\n unMapFirstChar,\n focus,\n } = treeViewControlContext;\n\n const treeviewMode = mode === \"treeview\";\n\n let id: string | null = null;\n\n if (idProp != null) {\n id = idProp;\n } else if (treeId && nodeId) {\n id = `${treeId}-${nodeId}`;\n }\n\n const [treeitemElement, setTreeitemElement] = useState(null);\n const contentRef = useRef<HTMLDivElement>(null);\n const handleRef = useForkRef(setTreeitemElement, ref);\n\n const descendant = useMemo(\n () => ({\n element: treeitemElement,\n id: nodeId,\n }),\n [nodeId, treeitemElement]\n );\n\n const { isOpen, useIcons } = useContext(VerticalNavigationContext);\n\n const { index, parentId, level } = useDescendant(descendant);\n\n const expandable = collapsible && Array.isArray(children);\n const expanded = isExpanded ? isExpanded(nodeId) : false;\n const focused = isFocused ? isFocused(nodeId) : false;\n const selected = isSelected ? isSelected(nodeId) : false;\n const disabled = isDisabled ? isDisabled(nodeId) : false;\n\n const selectable =\n selectableProp != null\n ? selectableProp\n : !collapsible || !expandable || !isOpen;\n\n useEffect(() => {\n // On the first render a node's index will be -1. We want to wait for the real index.\n if (registerNode && unregisterNode && index !== -1) {\n registerNode({\n id: nodeId,\n idAttribute: id,\n index,\n parentId,\n selectable,\n expandable,\n disabled: disabledProp,\n onFocus,\n payload,\n });\n\n return () => {\n unregisterNode(nodeId);\n };\n }\n\n return undefined;\n }, [\n registerNode,\n unregisterNode,\n parentId,\n index,\n nodeId,\n expandable,\n disabledProp,\n id,\n selectable,\n onFocus,\n payload,\n ]);\n\n useEffect(() => {\n if (\n mapFirstChar &&\n unMapFirstChar &&\n label &&\n contentRef.current?.textContent\n ) {\n mapFirstChar(\n nodeId,\n contentRef.current?.textContent.substring(0, 1).toLowerCase()\n );\n\n return () => {\n unMapFirstChar(nodeId);\n };\n }\n return undefined;\n }, [mapFirstChar, unMapFirstChar, nodeId, label]);\n\n let ariaSelected;\n if (multiSelect) {\n ariaSelected = selected;\n } else if (selected) {\n /* single-selection trees unset aria-selected on un-selected items.\n *\n * If the tree does not support multiple selection, aria-selected\n * is set to true for the selected node and it is not present on any other node in the tree.\n * Source: https://www.w3.org/TR/wai-aria-practices/#TreeView\n */\n ariaSelected = true;\n }\n\n const handleFocus = useCallback(\n (event) => {\n // DOM focus stays on the tree which manages focus with aria-activedescendant\n if (event.target === event.currentTarget) {\n (event.target.ownerDocument || document)\n .getElementById(treeId)\n .focus({ preventScroll: true });\n }\n\n const unfocusable = !disabledItemsFocusable && disabled;\n if (\n !focused &&\n event.currentTarget === event.target &&\n !unfocusable &&\n focus\n ) {\n focus(event, nodeId);\n }\n },\n [disabled, disabledItemsFocusable, focus, focused, nodeId, treeId]\n );\n\n const handleExpansion = useCallback(\n (event) => {\n if (!disabled) {\n if (treeviewMode && !focused && focus) {\n focus(event, nodeId);\n }\n\n const multiple =\n multiSelect && (event.shiftKey || event.ctrlKey || event.metaKey);\n\n // If already expanded and trying to toggle selection don't close\n if (\n expandable &&\n isOpen &&\n !(multiple && isExpanded && isExpanded(nodeId))\n ) {\n if (toggleExpansion) toggleExpansion(event, nodeId);\n }\n }\n },\n [\n disabled,\n expandable,\n focus,\n focused,\n isExpanded,\n multiSelect,\n nodeId,\n toggleExpansion,\n treeviewMode,\n ]\n );\n\n const handleSelection = useCallback(\n (event) => {\n if (selectable && !disabled) {\n if (treeviewMode && !focused && focus) {\n focus(event, nodeId);\n }\n\n const multiple =\n multiSelect && (event.shiftKey || event.ctrlKey || event.metaKey);\n\n if (multiple) {\n if (event.shiftKey) {\n if (selectRange) return selectRange(event, { end: nodeId });\n } else if (selectNode) return selectNode(event, nodeId, true);\n } else if (selectNode) return selectNode(event, nodeId);\n } else {\n return false;\n }\n },\n [\n disabled,\n focus,\n focused,\n multiSelect,\n nodeId,\n selectNode,\n selectRange,\n selectable,\n treeviewMode,\n ]\n );\n\n const handleMouseDown = useCallback(\n (event) => {\n preventSelection(event, disabled);\n\n if (onMouseDown) {\n onMouseDown(event);\n }\n },\n [disabled, onMouseDown]\n );\n\n const handleClick = useCallback(\n (event) => {\n if (!disabled) {\n if (expandable && isOpen) {\n handleExpansion(event);\n }\n\n if (selectable) {\n handleSelection(event);\n }\n }\n\n if (onClick) {\n onClick(event);\n }\n },\n [\n disabled,\n expandable,\n handleExpansion,\n handleSelection,\n onClick,\n selectable,\n ]\n );\n\n const handleKeyDown = useCallback(\n (event) => {\n let isEventHandled = false;\n const { key } = event;\n\n if (\n event.altKey ||\n event.ctrlKey ||\n event.metaKey ||\n event.currentTarget !== event.target\n ) {\n return;\n }\n if (contentRef.current === event.currentTarget) {\n if (key === \"Enter\" || key === \" \") {\n if (expandable && isOpen) {\n isEventHandled = handleExpansion(event) as unknown as boolean;\n }\n\n if (selectable) {\n isEventHandled = handleSelection(event) as boolean;\n }\n }\n\n if (isEventHandled) {\n event.preventDefault();\n event.stopPropagation();\n }\n }\n },\n [expandable, handleExpansion, handleSelection, selectable]\n );\n\n const renderedContent = useMemo(\n () => (\n <StyledContent\n id={setId(id, \"button\")}\n component={href ? \"a\" : \"div\"}\n href={href}\n target={target}\n ref={contentRef}\n className={clsx(\n treeViewItemClasses.content,\n classes?.content,\n href != null && clsx(treeViewItemClasses.link, classes?.link),\n !isOpen && clsx(treeViewItemClasses.minimized, classes?.minimized)\n )}\n variant=\"body\"\n disabled={disabled}\n onClick={handleClick}\n onMouseDown={handleMouseDown}\n style={{\n paddingLeft:\n (expandable || useIcons || !isOpen ? 0 : 10) +\n level * (collapsible ? 32 : 10),\n }}\n role={href ? undefined : \"button\"}\n {...(treeviewMode\n ? {\n tabIndex: -1,\n onFocus: handleFocus,\n }\n : {\n tabIndex: selectable || expandable ? 0 : -1,\n onKeyDown: handleKeyDown,\n \"aria-current\":\n (selectable && selected) ||\n (!isOpen && isChildSelected?.(nodeId))\n ? href\n ? \"page\"\n : true\n : undefined,\n \"aria-expanded\": expandable ? expanded : undefined,\n \"aria-controls\": expandable ? setId(id, \"group\") : undefined,\n \"aria-label\": payload?.label,\n })}\n >\n {isOpen && expandable && (expanded ? <DropUpXS /> : <DropDownXS />)}\n\n <IconWrapper\n icon={useIcons && icon}\n label={payload?.label}\n hasChildren={Boolean(children)}\n showAvatar={!icon && useIcons}\n isOpen={isOpen}\n disableTooltip={disableTooltip}\n />\n\n {isOpen && label}\n </StyledContent>\n ),\n [\n id,\n href,\n target,\n classes?.content,\n treeViewItemClasses.content,\n classes?.link,\n treeViewItemClasses.link,\n classes?.minimized,\n treeViewItemClasses.minimized,\n disabled,\n handleClick,\n handleMouseDown,\n expandable,\n icon,\n level,\n collapsible,\n treeviewMode,\n handleFocus,\n selectable,\n handleKeyDown,\n selected,\n expanded,\n label,\n disableTooltip,\n ]\n );\n\n const renderedChildren = useMemo(\n () =>\n children && (\n <StyledGroup\n id={setId(id, \"group\")}\n className={clsx(treeViewItemClasses.group, classes?.group)}\n role={treeviewMode ? \"group\" : undefined}\n >\n {children}\n </StyledGroup>\n ),\n [children, treeViewItemClasses.group, classes?.group, id, treeviewMode]\n );\n\n return (\n <StyledNode\n ref={handleRef}\n id={id ?? undefined}\n className={clsx(\n treeViewItemClasses?.node,\n classes?.node,\n className,\n disabled && clsx(treeViewItemClasses.disabled, classes?.disabled),\n expandable &&\n clsx(treeViewItemClasses.expandable, classes?.expandable),\n expandable &&\n !expanded &&\n clsx(treeViewItemClasses.collapsed, classes?.collapsed),\n expandable &&\n expanded &&\n clsx(treeViewItemClasses.expanded, classes?.expanded),\n selectable &&\n !disabled &&\n clsx(treeViewItemClasses.selectable, classes?.selectable),\n !disabled &&\n !selectable &&\n clsx(treeViewItemClasses.unselectable, classes?.unselectable),\n !disabled &&\n selectable &&\n selected &&\n clsx(treeViewItemClasses.selected, classes?.selected),\n !disabled &&\n selectable &&\n !selected &&\n clsx(treeViewItemClasses.unselected, classes?.unselected),\n focused && clsx(treeViewItemClasses.focused, classes?.focused),\n !isOpen && !useIcons && clsx(treeViewItemClasses.hide, classes?.hide),\n !isOpen &&\n useIcons &&\n isChildSelected &&\n isChildSelected(nodeId) &&\n clsx(treeViewItemClasses.selected, classes?.selected)\n )}\n data-hasicon={icon != null ? true : undefined}\n {...(mode === \"treeview\" && {\n role: \"treeitem\",\n \"aria-selected\": ariaSelected,\n \"aria-expanded\": expandable ? expanded : undefined,\n \"aria-disabled\": disabled ? true : undefined,\n })}\n {...others}\n >\n {renderedContent}\n {isOpen && (\n <DescendantProvider id={nodeId} level={level + 1}>\n {renderedChildren}\n </DescendantProvider>\n )}\n </StyledNode>\n );\n }\n);\n"],"names":["preventSelection","event","disabled","shiftKey","ctrlKey","metaKey","preventDefault","HvVerticalNavigationTreeViewItem","forwardRef","props","ref","id","idProp","className","classes","disabledProp","selectable","selectableProp","nodeId","icon","label","href","target","payload","onClick","onMouseDown","onFocus","children","disableTooltip","others","treeViewControlContext","useContext","TreeViewControlContext","isExpanded","isSelected","isFocused","isDisabled","isChildSelected","TreeViewStateContext","treeId","mode","collapsible","toggleExpansion","multiSelect","selectNode","selectRange","disabledItemsFocusable","registerNode","unregisterNode","mapFirstChar","unMapFirstChar","focus","treeviewMode","treeitemElement","setTreeitemElement","useState","contentRef","useRef","handleRef","useForkRef","descendant","useMemo","element","isOpen","useIcons","VerticalNavigationContext","index","parentId","level","useDescendant","expandable","Array","isArray","expanded","focused","selected","useEffect","idAttribute","undefined","current","textContent","substring","toLowerCase","ariaSelected","handleFocus","useCallback","currentTarget","ownerDocument","document","getElementById","preventScroll","unfocusable","handleExpansion","multiple","handleSelection","end","handleMouseDown","handleClick","handleKeyDown","isEventHandled","key","altKey","stopPropagation","renderedContent","_jsxs","StyledContent","setId","component","clsx","treeViewItemClasses","content","link","minimized","variant","style","paddingLeft","role","tabIndex","onKeyDown","DropUpXS","DropDownXS","IconWrapper","hasChildren","Boolean","showAvatar","renderedChildren","StyledGroup","group","StyledNode","node","collapsed","unselectable","unselected","hide","DescendantProvider"],"mappings":";;;;;;;;;;;;AAgGA,MAAMA,mBAAmBA,CAAC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KC,oBAAoBqB,WAAWpH,mCAASoH,SAAS,GACxD5D,cACEG,YACAmC,KAAKC,oBAAoBpC,UAAU3D,mCAAS2D,QAAQ,GACtDzD,cACE,CAACd,YACD0G,KAAKC,oBAAoB7F,YAAYF,mCAASE,UAAU,GAC1D,CAACd,YACC,CAACc,cACD4F,KAAKC,oBAAoBsB,cAAcrH,mCAASqH,YAAY,GAC9D,CAACjI,YACCc,cACA2D,YACAiC,KAAKC,oBAAoBlC,UAAU7D,mCAAS6D,QAAQ,GACtD,CAACzE,YACCc,cACA,CAAC2D,YACDiC,KAAKC,oBAAoBuB,YAAYtH,mCAASsH,UAAU,GAC1D1D,WAAWkC,KAAKC,oBAAoBnC,SAAS5D,mCAAS4D,OAAO,GAC7D,CAACX,UAAU,CAACC,YAAY4C,KAAKC,oBAAoBwB,MAAMvH,mCAASuH,IAAI,GACpE,CAACtE,UACCC,YACA3B,mBACAA,gBAAgBnB,MAAM,KACtB0F,KAAKC,oBAAoBlC,UAAU7D,mCAAS6D,QAAQ,CAAC;AAAA,IAEzD,gBAAcxD,QAAQ,OAAO,OAAO2D;AAAAA,IAAU,GACzCtC,SAAS,cAAc;AAAA,MAC1B4E,MAAM;AAAA,MACN,iBAAiBjC;AAAAA,MACjB,iBAAiBb,aAAaG,WAAWK;AAAAA,MACzC,iBAAiB5E,WAAW,OAAO4E;AAAAA,IACrC;AAAA,IAAC,GACGjD;AAAAA,IAAMF,WAET4E,iBACAxC,8BACEuE,oBAAkB;AAAA,MAAC3H,IAAIO;AAAAA,MAAQkD,OAAOA,QAAQ;AAAA,MAAEzC,UAC9CkG;AAAAA,IAAAA,CAEJ,CAAA;AAAA,EAAA,CACU;AAEjB,CAAC;"}
@@ -12,10 +12,13 @@ const HvVerticalNavigation = ({
12
12
  classes,
13
13
  children,
14
14
  open = true,
15
- collapsedMode = "simple",
16
15
  slider = false,
16
+ useIcons = false,
17
17
  ...others
18
18
  }) => {
19
+ if (others.collapsedMode) {
20
+ console.warn("`collaspedMode` is deprecated. Please use 'useIcons'.");
21
+ }
19
22
  const [parentData, setParentData] = useState([]);
20
23
  const [parentSelected, setParentSelected] = useState();
21
24
  const [headerTitle, setHeaderTitle] = useState();
@@ -33,11 +36,12 @@ const HvVerticalNavigation = ({
33
36
  };
34
37
  const value = useMemo(() => ({
35
38
  isOpen: open,
36
- collapsedMode,
39
+ useIcons,
37
40
  slider,
38
41
  headerTitle,
39
42
  setHeaderTitle,
40
43
  parentItem,
44
+ setParentItem,
41
45
  withParentData,
42
46
  navigateToChildHandler,
43
47
  navigateToParentHandler,
@@ -46,7 +50,7 @@ const HvVerticalNavigation = ({
46
50
  parentSelected,
47
51
  setParentSelected,
48
52
  hasAnyChildWithData
49
- }), [open, collapsedMode, slider, headerTitle, setHeaderTitle, parentItem, withParentData, navigateToChildHandler, navigateToParentHandler, hasAnyChildWithData]);
53
+ }), [open, useIcons, slider, headerTitle, setHeaderTitle, parentItem, setParentItem, withParentData, navigateToChildHandler, navigateToParentHandler, hasAnyChildWithData]);
50
54
  const content = /* @__PURE__ */ jsx(VerticalNavigationContext.Provider, {
51
55
  value,
52
56
  children: /* @__PURE__ */ jsx(StyledRoot, {
@@ -1 +1 @@
1
- {"version":3,"file":"VerticalNavigation.js","sources":["../../../../src/components/VerticalNavigation/VerticalNavigation.tsx"],"sourcesContent":["import { clsx } from \"clsx\";\nimport { useEffect, useMemo, useState } from \"react\";\nimport { StyledRoot } from \"./VerticalNavigation.styles\";\nimport verticalNavigationClasses, {\n HvVerticalNavigationClasses,\n} from \"./verticalNavigationClasses\";\nimport { NavigationData, VerticalNavigationContext } from \".\";\nimport {\n fillDataWithParentId,\n getNavigationItemById,\n getParentItemById,\n} from \"./NavigationSlider/utils\";\nimport { hasChildNavigationItems } from \"./utils/VerticalNavigation.utils\";\n\nexport interface HvVerticalNavigationProps {\n /**\n * Id to be applied to the root node.\n */\n id?: string;\n /**\n * Class names to be applied.\n */\n className?: string;\n /**\n * A Jss Object used to override or extend the styles applied to the component.\n */\n classes?: HvVerticalNavigationClasses;\n /**\n * Current State of the Vertical Navigation Collapse\n */\n open?: boolean;\n /**\n * Collpased Mode for the Vertical Navigation, the default value is \"simple\".\n */\n collapsedMode?: HvVerticalNavigationMode;\n /**\n * Boolean to determine if treeview is in slider mode (for mobile navigation), the default value is false.\n */\n slider?: boolean;\n /**\n * The content inside the actions container.\n */\n children?: React.ReactNode;\n}\n\n/**\n * Navigation enables users to move through an app to complete tasks.\n *\n * It is recommended to use vertical navigation when your application requires global navigation that is displayed on the left.\n * While vertical navigation menus generally consume more space than their horizontal counterparts, they have become more popular as desktop monitors move to wide-screen formats.\n *\n * Although both the hierarchically organized data and the visual style resemble a treeview-like structure, the [Treeview Design Pattern](https://w3c.github.io/aria-practices/#TreeView)\n * isn't necessarily the most appropriate.\n *\n * The tree role provides complex functionality that is not needed for typical site navigation, and changes the most common keyboard navigation using TAB.\n *\n * The [Disclosure Design Pattern](https://w3c.github.io/aria-practices/#disclosure) is more suited for typical site navigation, with expandable groups of links.\n * However it can be tedious to TAB through all navigation items to reach the actions panel.\n *\n * Both modes are available via the `mode` property and each app should choose the most appropriate.\n */\nexport const HvVerticalNavigation = ({\n id,\n className,\n classes,\n\n children,\n\n open = true,\n\n collapsedMode = \"simple\",\n\n slider = false,\n\n ...others\n}: HvVerticalNavigationProps) => {\n const [parentData, setParentData] = useState<NavigationData[]>([]);\n\n const [parentSelected, setParentSelected] = useState();\n\n const [headerTitle, setHeaderTitle] = useState<string | undefined>();\n\n // navigationSlider\n const withParentData = useMemo(\n () => fillDataWithParentId(parentData),\n [parentData]\n );\n\n const initialParentItem = useMemo(\n () => getParentItemById(withParentData, parentSelected),\n [withParentData, parentSelected]\n );\n\n const [parentItem, setParentItem] = useState(initialParentItem);\n\n const hasAnyChildWithData = useMemo(\n () => hasChildNavigationItems(parentData),\n [parentData]\n );\n\n useEffect(\n () => setHeaderTitle(parentItem?.label),\n [parentItem, setParentItem]\n );\n\n const navigateToParentHandler = () => {\n setParentItem(getParentItemById(withParentData, parentItem.id));\n };\n\n const navigateToChildHandler = (event, item) => {\n setParentItem(getNavigationItemById(withParentData, item.id));\n event.stopPropagation();\n };\n\n const value = useMemo(\n () => ({\n isOpen: open,\n collapsedMode,\n slider,\n headerTitle,\n setHeaderTitle,\n\n parentItem,\n withParentData,\n navigateToChildHandler,\n navigateToParentHandler,\n\n parentData,\n setParentData,\n parentSelected,\n setParentSelected,\n hasAnyChildWithData,\n }),\n [\n open,\n collapsedMode,\n slider,\n headerTitle,\n setHeaderTitle,\n parentItem,\n withParentData,\n navigateToChildHandler,\n navigateToParentHandler,\n hasAnyChildWithData,\n ]\n );\n\n const content = (\n <VerticalNavigationContext.Provider value={value}>\n <StyledRoot\n id={id}\n className={clsx(\n className,\n verticalNavigationClasses.root,\n classes?.root,\n !open && verticalNavigationClasses.collapsed,\n slider && verticalNavigationClasses.slider,\n classes?.collapsed\n )}\n hasAnyChildWithData={hasAnyChildWithData}\n {...others}\n >\n {children}\n </StyledRoot>\n </VerticalNavigationContext.Provider>\n );\n\n return content;\n};\n\nexport type HvVerticalNavigationMode = \"icon\" | \"simple\";\n\nexport type HvVerticalNavigationPosition =\n | \"static\"\n | \"relative\"\n | \"fixed\"\n | \"absolute\";\n"],"names":["HvVerticalNavigation","id","className","classes","children","open","collapsedMode","slider","others","parentData","setParentData","useState","parentSelected","setParentSelected","headerTitle","setHeaderTitle","withParentData","useMemo","fillDataWithParentId","initialParentItem","getParentItemById","parentItem","setParentItem","hasAnyChildWithData","hasChildNavigationItems","label","navigateToParentHandler","navigateToChildHandler","event","item","getNavigationItemById","stopPropagation","value","isOpen","content","VerticalNavigationContext","Provider","StyledRoot","clsx","verticalNavigationClasses","root","collapsed"],"mappings":";;;;;;;;AA6DO,MAAMA,uBAAuBA,CAAC;AAAA,EACnCC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EAEAC;AAAAA,EAEAC,OAAO;AAAA,EAEPC,gBAAgB;AAAA,EAEhBC,SAAS;AAAA,EAET,GAA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TpC;AAAAA,MACAC,WAAWoC,KACTpC,WACAqC,0BAA0BC,MAC1BrC,mCAASqC,MACT,CAACnC,QAAQkC,0BAA0BE,WACnClC,UAAUgC,0BAA0BhC,QACpCJ,mCAASsC,SAAS;AAAA,MAEpBlB;AAAAA,MAAyC,GACrCf;AAAAA,MAAMJ;AAAAA,IAAAA,CAED;AAAA,EAAA,CAGd;AAEM8B,SAAAA;AACT;"}
1
+ {"version":3,"file":"VerticalNavigation.js","sources":["../../../../src/components/VerticalNavigation/VerticalNavigation.tsx"],"sourcesContent":["import { clsx } from \"clsx\";\nimport { useEffect, useMemo, useState } from \"react\";\nimport { StyledRoot } from \"./VerticalNavigation.styles\";\nimport verticalNavigationClasses, {\n HvVerticalNavigationClasses,\n} from \"./verticalNavigationClasses\";\nimport { NavigationData, VerticalNavigationContext } from \".\";\nimport {\n fillDataWithParentId,\n getNavigationItemById,\n getParentItemById,\n} from \"./NavigationSlider/utils\";\nimport { hasChildNavigationItems } from \"./utils/VerticalNavigation.utils\";\n\nexport interface HvVerticalNavigationProps {\n /**\n * Id to be applied to the root node.\n */\n id?: string;\n /**\n * Class names to be applied.\n */\n className?: string;\n /**\n * A Jss Object used to override or extend the styles applied to the component.\n */\n classes?: HvVerticalNavigationClasses;\n /**\n * Current State of the Vertical Navigation Collapse\n */\n open?: boolean;\n /**\n * Collpased Mode for the Vertical Navigation, the default value is \"simple\".\n *\n * @deprecated - `useIcons` property should be used instead.\n */\n collapsedMode?: HvVerticalNavigationMode;\n /**\n * Boolean to determine if treeview is in slider mode (for mobile navigation), the default value is false.\n */\n slider?: boolean;\n /**\n * The content inside the actions container.\n */\n children?: React.ReactNode;\n /**\n * Boolean to determine if icons should be displayed in the navigation menu.\n * When `true` a icon will always be displayed, if no icon is provided the first letter of the label will be\n * displayed inside an Avatar component.\n * When `false` no icons will be shown, even if an icon is provided.\n */\n useIcons?: boolean;\n}\n\n/**\n * Navigation enables users to move through an app to complete tasks.\n *\n * It is recommended to use vertical navigation when your application requires global navigation that is displayed on the left.\n * While vertical navigation menus generally consume more space than their horizontal counterparts, they have become more popular as desktop monitors move to wide-screen formats.\n *\n * Although both the hierarchically organized data and the visual style resemble a treeview-like structure, the [Treeview Design Pattern](https://w3c.github.io/aria-practices/#TreeView)\n * isn't necessarily the most appropriate.\n *\n * The tree role provides complex functionality that is not needed for typical site navigation, and changes the most common keyboard navigation using TAB.\n *\n * The [Disclosure Design Pattern](https://w3c.github.io/aria-practices/#disclosure) is more suited for typical site navigation, with expandable groups of links.\n * However it can be tedious to TAB through all navigation items to reach the actions panel.\n *\n * Both modes are available via the `mode` property and each app should choose the most appropriate.\n */\nexport const HvVerticalNavigation = ({\n id,\n className,\n classes,\n\n children,\n\n open = true,\n\n slider = false,\n\n useIcons = false,\n\n ...others\n}: HvVerticalNavigationProps) => {\n if (others.collapsedMode) {\n console.warn(\"`collaspedMode` is deprecated. Please use 'useIcons'.\");\n }\n const [parentData, setParentData] = useState<NavigationData[]>([]);\n\n const [parentSelected, setParentSelected] = useState();\n\n const [headerTitle, setHeaderTitle] = useState<string | undefined>();\n\n // navigationSlider\n const withParentData = useMemo(\n () => fillDataWithParentId(parentData),\n [parentData]\n );\n\n const initialParentItem = useMemo(\n () => getParentItemById(withParentData, parentSelected),\n [withParentData, parentSelected]\n );\n\n const [parentItem, setParentItem] = useState(initialParentItem);\n\n const hasAnyChildWithData = useMemo(\n () => hasChildNavigationItems(parentData),\n [parentData]\n );\n\n useEffect(\n () => setHeaderTitle(parentItem?.label),\n [parentItem, setParentItem]\n );\n\n const navigateToParentHandler = () => {\n setParentItem(getParentItemById(withParentData, parentItem.id));\n };\n\n const navigateToChildHandler = (event, item) => {\n setParentItem(getNavigationItemById(withParentData, item.id));\n event.stopPropagation();\n };\n\n const value = useMemo(\n () => ({\n isOpen: open,\n useIcons,\n slider,\n headerTitle,\n setHeaderTitle,\n\n parentItem,\n setParentItem,\n withParentData,\n navigateToChildHandler,\n navigateToParentHandler,\n\n parentData,\n setParentData,\n parentSelected,\n setParentSelected,\n hasAnyChildWithData,\n }),\n [\n open,\n useIcons,\n slider,\n headerTitle,\n setHeaderTitle,\n parentItem,\n setParentItem,\n withParentData,\n navigateToChildHandler,\n navigateToParentHandler,\n hasAnyChildWithData,\n ]\n );\n\n const content = (\n <VerticalNavigationContext.Provider value={value}>\n <StyledRoot\n id={id}\n className={clsx(\n className,\n verticalNavigationClasses.root,\n classes?.root,\n !open && verticalNavigationClasses.collapsed,\n slider && verticalNavigationClasses.slider,\n classes?.collapsed\n )}\n hasAnyChildWithData={hasAnyChildWithData}\n {...others}\n >\n {children}\n </StyledRoot>\n </VerticalNavigationContext.Provider>\n );\n\n return content;\n};\n\nexport type HvVerticalNavigationMode = \"icon\" | \"simple\";\n\nexport type HvVerticalNavigationPosition =\n | \"static\"\n | \"relative\"\n | \"fixed\"\n | \"absolute\";\n"],"names":["HvVerticalNavigation","id","className","classes","children","open","slider","useIcons","others","collapsedMode","console","warn","parentData","setParentData","useState","parentSelected","setParentSelected","headerTitle","setHeaderTitle","withParentData","useMemo","fillDataWithParentId","initialParentItem","getParentItemById","parentItem","setParentItem","hasAnyChildWithData","hasChildNavigationItems","label","navigateToParentHandler","navigateToChildHandler","event","item","getNavigationItemById","stopPropagation","value","isOpen","content","VerticalNavigationContext","Provider","StyledRoot","clsx","verticalNavigationClasses","root","collapsed"],"mappings":";;;;;;;;AAsEO,MAAMA,uBAAuBA,CAAC;AAAA,EACnCC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EAEAC;AAAAA,EAEAC,OAAO;AAAA,EAEPC,SAAS;AAAA,EAETC,WAAW;AAAA,EAEX,GAAGC;AACsB,MAAM;AAC/B,MAAIA,OAAOC,eAAe;AACxBC,YAAQC,KAAK,uDAAuD;AAAA,EACtE;AACA,QAAM,CAACC,YAAYC,aAAa,IAAIC,SAA2B,CAAE,CAAA;AAEjE,QAAM,CAACC,gBAAgBC,iBAAiB,IAAIF,SAAU;AAEtD,QAAM,CAACG,aAAaC,cAAc,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yC,SAAS;AAAA,MAEpBlB;AAAAA,MAAyC,GACrClB;AAAAA,MAAMJ;AAAAA,IAAAA,CAED;AAAA,EAAA,CAGd;AAEMiC,SAAAA;AACT;"}
@@ -1,7 +1,7 @@
1
1
  import { createContext } from "react";
2
2
  const VerticalNavigationContext = createContext({
3
3
  isOpen: true,
4
- collapsedMode: "simple",
4
+ useIcons: false,
5
5
  slider: false
6
6
  });
7
7
  export {
@@ -1 +1 @@
1
- {"version":3,"file":"VerticalNavigationContext.js","sources":["../../../../src/components/VerticalNavigation/VerticalNavigationContext.tsx"],"sourcesContent":["import { createContext } from \"react\";\nimport { NavigationData, HvVerticalNavigationMode } from \".\";\n\ninterface VerticalNavigationContextValue {\n isOpen: boolean;\n collapsedMode: HvVerticalNavigationMode;\n slider?: boolean;\n headerTitle?: string;\n setHeaderTitle?: React.Dispatch<React.SetStateAction<string | undefined>>;\n\n parentItem?;\n withParentData?;\n navigateToChildHandler?: (event, item) => void;\n navigateToParentHandler?: () => void;\n\n parentData?: NavigationData[];\n setParentData?: React.Dispatch<React.SetStateAction<any>>;\n parentSelected?;\n setParentSelected?: React.Dispatch<React.SetStateAction<any>>;\n\n hasAnyChildWithData?: boolean;\n}\n\nconst VerticalNavigationContext = createContext<VerticalNavigationContextValue>(\n {\n isOpen: true,\n collapsedMode: \"simple\",\n slider: false,\n }\n);\n\nexport { VerticalNavigationContext };\n"],"names":["VerticalNavigationContext","createContext","isOpen","collapsedMode","slider"],"mappings":";AAuBA,MAAMA,4BAA4BC,cAChC;AAAA,EACEC,QAAQ;AAAA,EACRC,eAAe;AAAA,EACfC,QAAQ;AACV,CAAC;"}
1
+ {"version":3,"file":"VerticalNavigationContext.js","sources":["../../../../src/components/VerticalNavigation/VerticalNavigationContext.tsx"],"sourcesContent":["import { createContext } from \"react\";\nimport { NavigationData } from \".\";\n\ninterface VerticalNavigationContextValue {\n isOpen: boolean;\n useIcons: boolean;\n slider?: boolean;\n headerTitle?: string;\n setHeaderTitle?: React.Dispatch<React.SetStateAction<string | undefined>>;\n\n parentItem?;\n setParentItem?: React.Dispatch<React.SetStateAction<any>>;\n withParentData?;\n navigateToChildHandler?: (event, item) => void;\n navigateToParentHandler?: () => void;\n\n parentData?: NavigationData[];\n setParentData?: React.Dispatch<React.SetStateAction<any>>;\n parentSelected?;\n setParentSelected?: React.Dispatch<React.SetStateAction<any>>;\n\n hasAnyChildWithData?: boolean;\n}\n\nconst VerticalNavigationContext = createContext<VerticalNavigationContextValue>(\n {\n isOpen: true,\n useIcons: false,\n slider: false,\n }\n);\n\nexport { VerticalNavigationContext };\n"],"names":["VerticalNavigationContext","createContext","isOpen","useIcons","slider"],"mappings":";AAwBA,MAAMA,4BAA4BC,cAChC;AAAA,EACEC,QAAQ;AAAA,EACRC,UAAU;AAAA,EACVC,QAAQ;AACV,CAAC;"}
@@ -1,6 +1,6 @@
1
- import { useState } from "react";
1
+ import { useMemo } from "react";
2
2
  import uniqueId from "lodash/uniqueId";
3
- const useUniqueId = (id, idPrefix) => useState(id || uniqueId(idPrefix))[0];
3
+ const useUniqueId = (id, idPrefix) => useMemo(() => id || uniqueId(idPrefix), [id, idPrefix]);
4
4
  export {
5
5
  useUniqueId as default
6
6
  };
@@ -1 +1 @@
1
- {"version":3,"file":"useUniqueId.js","sources":["../../../src/hooks/useUniqueId.ts"],"sourcesContent":["import { useState } from \"react\";\nimport uniqueId from \"lodash/uniqueId\";\n\nexport default (id, idPrefix) => useState(id || uniqueId(idPrefix))[0];\n"],"names":["id","idPrefix","useState","uniqueId"],"mappings":";;AAGA,MAAA,cAAe,CAACA,IAAIC,aAAaC,SAASF,MAAMG,SAASF,QAAQ,CAAC,EAAE,CAAC;"}
1
+ {"version":3,"file":"useUniqueId.js","sources":["../../../src/hooks/useUniqueId.ts"],"sourcesContent":["import { useMemo } from \"react\";\nimport uniqueId from \"lodash/uniqueId\";\n\nexport default (id?: string, idPrefix?: string) =>\n useMemo(() => id || uniqueId(idPrefix), [id, idPrefix]);\n"],"names":["id","idPrefix","useMemo","uniqueId"],"mappings":";;AAGA,MAAe,cAAA,CAACA,IAAaC,aAC3BC,QAAQ,MAAMF,MAAMG,SAASF,QAAQ,GAAG,CAACD,IAAIC,QAAQ,CAAC;"}
package/dist/esm/index.js CHANGED
@@ -197,7 +197,7 @@ import { default as default102 } from "./components/Table/renderers/DropdownColu
197
197
  import { default as default103, normalizeProgressBar } from "./components/Table/renderers/ProgressColumnCell/ProgressColumnCell.js";
198
198
  import { default as default104 } from "./components/Table/renderers/SwitchColumnCell/SwitchColumnCell.js";
199
199
  import { hvNodeFallback, hvNumberFallback, hvStringFallback } from "./components/Table/utils/fallbacks.js";
200
- import { checkValidHexColorValue, getBorderStyles } from "./components/Table/utils/utils.js";
200
+ import { getBorderStyles } from "./components/Table/utils/utils.js";
201
201
  import { default as default105 } from "./components/Login/loginClasses.js";
202
202
  import { HvLogin } from "./components/Login/Login.js";
203
203
  import { default as default106 } from "./components/Controls/controlClasses.js";
@@ -269,6 +269,7 @@ import { default as default132 } from "./utils/hexToRgbA.js";
269
269
  import { default as default133 } from "./utils/browser.js";
270
270
  import { default as default134 } from "./utils/multiSelectionEventHandler.js";
271
271
  import { default as default135 } from "./utils/getComponentName.js";
272
+ import { default as default136 } from "./utils/checkValidHexColorValue.js";
272
273
  import { outlineStyles } from "./utils/focusUtils.js";
273
274
  import { keyboardCodes } from "./utils/keyboardUtils/keyboardCodes.js";
274
275
  import { getKeyCodeFromEvent, isKeycode, isKeypress } from "./utils/keyboardUtils/keyCheck.js";
@@ -279,8 +280,7 @@ import { getClasses } from "./utils/classes.js";
279
280
  import { getFirstAndLastFocus, getFocusableList, getPrevNextFocus } from "./utils/focusableElementFinder.js";
280
281
  import { wrapperTooltip } from "./utils/wrapperTooltip.js";
281
282
  import { useSavedState } from "./utils/useSavedState.js";
282
- import { default as default136 } from "./hocs/withTooltip.js";
283
- import { default as default137 } from "./hocs/withId.js";
283
+ import { default as default137 } from "./hocs/withTooltip.js";
284
284
  export {
285
285
  CellWithCheckBox,
286
286
  CellWithExpandButton,
@@ -450,7 +450,7 @@ export {
450
450
  default11 as charCounterClasses,
451
451
  default59 as checkBoxClasses,
452
452
  default65 as checkBoxGroupClasses,
453
- checkValidHexColorValue,
453
+ default136 as checkValidHexColorValue,
454
454
  default128 as colorPickerClasses,
455
455
  default30 as containerClasses,
456
456
  default106 as controlsClasses,
@@ -612,8 +612,7 @@ export {
612
612
  default115 as verticalNavigationTreeClasses,
613
613
  default122 as verticalScrollListItemClasses,
614
614
  default16 as warningTextClasses,
615
- default137 as withId,
616
- default136 as withTooltip,
615
+ default137 as withTooltip,
617
616
  wrapperTooltip
618
617
  };
619
618
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,9 @@
1
+ const checkValidHexColorValue = (value) => {
2
+ const reg = /^#([0-9a-f]{3}){1,2}$/i;
3
+ return value ? reg.test(value) : false;
4
+ };
5
+ const checkValidHexColorValue$1 = checkValidHexColorValue;
6
+ export {
7
+ checkValidHexColorValue$1 as default
8
+ };
9
+ //# sourceMappingURL=checkValidHexColorValue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checkValidHexColorValue.js","sources":["../../../src/utils/checkValidHexColorValue.ts"],"sourcesContent":["const checkValidHexColorValue = (value?: string): boolean => {\n const reg = /^#([0-9a-f]{3}){1,2}$/i;\n return value ? reg.test(value) : false;\n};\n\nexport default checkValidHexColorValue;\n"],"names":["checkValidHexColorValue","value","reg","test"],"mappings":"AAAA,MAAMA,0BAA0BA,CAACC,UAA4B;AAC3D,QAAMC,MAAM;AACZ,SAAOD,QAAQC,IAAIC,KAAKF,KAAK,IAAI;AACnC;AAEA,MAAA,4BAAeD;"}
@@ -85,7 +85,6 @@ import { theme } from '@hitachivantara/uikit-styles';
85
85
  import { themes } from '@hitachivantara/uikit-styles';
86
86
  import type { ThHTMLAttributes } from 'react';
87
87
  import { TooltipProps } from '@mui/material';
88
- import { TransitionProps } from '@mui/material/transitions';
89
88
  import { UseColumnOrderInstanceProps } from 'react-table';
90
89
  import { UseColumnOrderState } from 'react-table';
91
90
  import { useEffect } from 'react';
@@ -137,8 +136,8 @@ declare type Accessor<D extends object> = (originalRow: D, index: number, sub: {
137
136
  }) => CellValue;
138
137
 
139
138
  export declare const accordionClasses: {
140
- label: "HvAccordion-label";
141
139
  hidden: "HvAccordion-hidden";
140
+ label: "HvAccordion-label";
142
141
  container: "HvAccordion-container";
143
142
  disabled: "HvAccordion-disabled";
144
143
  root: "HvAccordion-root";
@@ -275,10 +274,10 @@ export declare const baseCheckBoxClasses: {
275
274
  };
276
275
 
277
276
  export declare const baseDropdownClasses: {
278
- header: "HvBaseDropdown-header";
279
277
  placeholder: "HvBaseDropdown-placeholder";
280
278
  arrow: "HvBaseDropdown-arrow";
281
279
  anchor: "HvBaseDropdown-anchor";
280
+ header: "HvBaseDropdown-header";
282
281
  container: "HvBaseDropdown-container";
283
282
  root: "HvBaseDropdown-root";
284
283
  rootDisabled: "HvBaseDropdown-rootDisabled";
@@ -336,8 +335,8 @@ export declare const baseSwitchClasses: {
336
335
  };
337
336
 
338
337
  export declare const breadCrumbClasses: {
339
- a: "HvBreadCrumb-a";
340
338
  link: "HvBreadCrumb-link";
339
+ a: "HvBreadCrumb-a";
341
340
  root: "HvBreadCrumb-root";
342
341
  orderedList: "HvBreadCrumb-orderedList";
343
342
  currentPage: "HvBreadCrumb-currentPage";
@@ -435,8 +434,8 @@ export declare const cardMediaClasses: {
435
434
  };
436
435
 
437
436
  export declare const carouselClasses: {
438
- main: "HvCarousel-main";
439
437
  title: "HvCarousel-title";
438
+ main: "HvCarousel-main";
440
439
  dot: "HvCarousel-dot";
441
440
  controls: "HvCarousel-controls";
442
441
  xs: "HvCarousel-xs";
@@ -638,9 +637,9 @@ export declare const dotPaginationClasses: {
638
637
  };
639
638
 
640
639
  export declare const dropdownClasses: {
641
- label: "HvDropdown-label";
642
640
  placeholder: "HvDropdown-placeholder";
643
641
  arrow: "HvDropdown-arrow";
642
+ label: "HvDropdown-label";
644
643
  error: "HvDropdown-error";
645
644
  dropdown: "HvDropdown-dropdown";
646
645
  root: "HvDropdown-root";
@@ -660,6 +659,7 @@ export declare const dropDownMenuClasses: {
660
659
  root: "HvDropDownMenu-root";
661
660
  baseContainer: "HvDropDownMenu-baseContainer";
662
661
  iconSelected: "HvDropDownMenu-iconSelected";
662
+ menuListRoot: "HvDropDownMenu-menuListRoot";
663
663
  menuList: "HvDropDownMenu-menuList";
664
664
  };
665
665
 
@@ -1896,7 +1896,7 @@ export declare interface HvBreadCrumbClasses {
1896
1896
  a?: string;
1897
1897
  }
1898
1898
 
1899
- export declare interface HvBreadCrumbPathElement {
1899
+ export declare interface HvBreadCrumbPathElement extends Record<string, any> {
1900
1900
  label: string;
1901
1901
  path: string;
1902
1902
  }
@@ -1911,7 +1911,7 @@ export declare interface HvBreadCrumbProps extends HvBaseProps<HTMLDivElement, "
1911
1911
  /** The component used for the link node. Either a string to use a DOM element or a component. */
1912
1912
  component?: React.ElementType;
1913
1913
  /** Function passed to the component. If defined the component prop is used as the link node. */
1914
- onClick?: (event: MouseEventHandler<HTMLAnchorElement>, data: any) => void | undefined;
1914
+ onClick?: (event: MouseEvent_2<HTMLElement>, data: any) => void;
1915
1915
  /** Props passed down to the DropDownMenu sub-menu component. */
1916
1916
  dropDownMenuProps?: HvDropDownMenuProps;
1917
1917
  /** A Jss Object used to override or extend the styles applied to the component. */
@@ -3253,10 +3253,10 @@ declare interface HvDropdownListProps {
3253
3253
  virtualized?: boolean;
3254
3254
  }
3255
3255
 
3256
- export declare const HvDropDownMenu: {
3257
- ({ id, ...others }: WithIdProps): JSX_2.Element;
3258
- Naked: any;
3259
- };
3256
+ /**
3257
+ * A drop-down menu is a graphical control element, similar to a list box, that allows the user to choose a value from a list.
3258
+ */
3259
+ export declare const HvDropDownMenu: ({ id: idProp, classes, className, icon, placement, dataList, disablePortal, onToggle, onClick, keepOpened, disabled, expanded, defaultExpanded, category, ...others }: HvDropDownMenuProps) => JSX_2.Element;
3260
3260
 
3261
3261
  export declare interface HvDropDownMenuClasses {
3262
3262
  /** Styles applied to the root. */
@@ -3269,6 +3269,8 @@ export declare interface HvDropDownMenuClasses {
3269
3269
  icon?: string;
3270
3270
  /** Styles applied to the icon when selected. */
3271
3271
  iconSelected?: string;
3272
+ /** Styles applied to the list root. */
3273
+ menuListRoot?: string;
3272
3274
  /** Styles applied to the list. */
3273
3275
  menuList?: string;
3274
3276
  }
@@ -7219,6 +7221,7 @@ export declare interface HvToggleButtonProps extends HvBaseProps<HTMLButtonEleme
7219
7221
 
7220
7222
  /**
7221
7223
  * Tooltips display informative text when users hover over, focus on, or tap an element.
7224
+ * Accessibility-wise, the tooltip automatically labels the `children` content.
7222
7225
  */
7223
7226
  export declare const HvTooltip: ForwardRefExoticComponent<Omit<HvTooltipProps, "ref"> & RefAttributes<unknown>>;
7224
7227
 
@@ -7247,9 +7250,9 @@ export declare interface HvTooltipClasses {
7247
7250
  valueWrapper?: string;
7248
7251
  }
7249
7252
 
7250
- export declare type HvTooltipPlacementType = "bottom-end" | "bottom-start" | "bottom" | "left-end" | "left-start" | "left" | "right-end" | "right-start" | "right" | "top-end" | "top-start" | "top";
7253
+ export declare type HvTooltipPlacementType = TooltipProps["placement"];
7251
7254
 
7252
- export declare interface HvTooltipProps extends Omit<TooltipProps, "classes" | "title"> {
7255
+ export declare interface HvTooltipProps extends Omit<TooltipProps, "classes"> {
7253
7256
  /**
7254
7257
  * Class names to be applied.
7255
7258
  */
@@ -7271,20 +7274,12 @@ export declare interface HvTooltipProps extends Omit<TooltipProps, "classes" | "
7271
7274
  * This property won't impact the enter touch delay (enterTouchDelay).
7272
7275
  */
7273
7276
  enterDelay?: number;
7274
- /**
7275
- * Tooltip title. Zero-length titles string are never displayed.
7276
- */
7277
- title?: string | ReactElement;
7278
- /**
7279
- * The component used for the transition
7280
- */
7281
- TransitionComponent?: React.JSXElementConstructor<TransitionProps & {
7282
- children: React.ReactElement<any, any>;
7283
- }>;
7284
- /**
7285
- * Properties applied to the Transition element.
7286
- */
7287
- TransitionProps?: TransitionProps;
7277
+ /** @inheritdoc */
7278
+ title: TooltipProps["title"];
7279
+ /** @inheritdoc */
7280
+ TransitionComponent?: TooltipProps["TransitionComponent"];
7281
+ /** @inheritdoc */
7282
+ TransitionProps?: TooltipProps["TransitionProps"];
7288
7283
  /**
7289
7284
  * Defines if should use a single or multiline tooltip.
7290
7285
  */
@@ -7406,7 +7401,7 @@ export declare interface HvValidationMessages {
7406
7401
  *
7407
7402
  * Both modes are available via the `mode` property and each app should choose the most appropriate.
7408
7403
  */
7409
- export declare const HvVerticalNavigation: ({ id, className, classes, children, open, collapsedMode, slider, ...others }: HvVerticalNavigationProps) => JSX_2.Element;
7404
+ export declare const HvVerticalNavigation: ({ id, className, classes, children, open, slider, useIcons, ...others }: HvVerticalNavigationProps) => JSX_2.Element;
7410
7405
 
7411
7406
  export declare const HvVerticalNavigationAction: ({ className, classes, id, label, icon, onClick, ...others }: HvVerticalNavigationActionProps) => JSX_2.Element;
7412
7407
 
@@ -7546,7 +7541,9 @@ export declare interface HvVerticalNavigationProps {
7546
7541
  */
7547
7542
  open?: boolean;
7548
7543
  /**
7549
- * Collpased Mode for the Vertical Navigation, the default value is "simple".
7544
+ * Collpased Mode for the Vertical Navigation, the default value is "simple".
7545
+ *
7546
+ * @deprecated - `useIcons` property should be used instead.
7550
7547
  */
7551
7548
  collapsedMode?: HvVerticalNavigationMode;
7552
7549
  /**
@@ -7557,6 +7554,13 @@ export declare interface HvVerticalNavigationProps {
7557
7554
  * The content inside the actions container.
7558
7555
  */
7559
7556
  children?: React.ReactNode;
7557
+ /**
7558
+ * Boolean to determine if icons should be displayed in the navigation menu.
7559
+ * When `true` a icon will always be displayed, if no icon is provided the first letter of the label will be
7560
+ * displayed inside an Avatar component.
7561
+ * When `false` no icons will be shown, even if an icon is provided.
7562
+ */
7563
+ useIcons?: boolean;
7560
7564
  }
7561
7565
 
7562
7566
  export declare const HvVerticalNavigationSlider: ({ id, classes, data, selected, onNavigateToTarget, onNavigateToChild, }: HvVerticalNavigationSliderProps) => JSX_2.Element;
@@ -8153,9 +8157,9 @@ export declare const listItemClasses: {
8153
8157
  };
8154
8158
 
8155
8159
  export declare const loadingClasses: {
8156
- label: "HvLoading-label";
8157
- small: "HvLoading-small";
8158
8160
  hidden: "HvLoading-hidden";
8161
+ small: "HvLoading-small";
8162
+ label: "HvLoading-label";
8159
8163
  overlay: "HvLoading-overlay";
8160
8164
  blur: "HvLoading-blur";
8161
8165
  root: "HvLoading-root";
@@ -8937,9 +8941,9 @@ export declare const treeViewClasses: {
8937
8941
  };
8938
8942
 
8939
8943
  export declare const treeViewItemClasses: {
8940
- link: "HvVerticalNavigationTreeViewItem-link";
8941
8944
  content: "HvVerticalNavigationTreeViewItem-content";
8942
8945
  unselectable: "HvVerticalNavigationTreeViewItem-unselectable";
8946
+ link: "HvVerticalNavigationTreeViewItem-link";
8943
8947
  group: "HvVerticalNavigationTreeViewItem-group";
8944
8948
  hide: "HvVerticalNavigationTreeViewItem-hide";
8945
8949
  expanded: "HvVerticalNavigationTreeViewItem-expanded";
@@ -8955,9 +8959,9 @@ export declare const treeViewItemClasses: {
8955
8959
  };
8956
8960
 
8957
8961
  export declare const typographyClasses: {
8962
+ link: "HvTypography-link";
8958
8963
  body: "HvTypography-body";
8959
8964
  label: "HvTypography-label";
8960
- link: "HvTypography-link";
8961
8965
  display: "HvTypography-display";
8962
8966
  noWrap: "HvTypography-noWrap";
8963
8967
  title1: "HvTypography-title1";
@@ -9297,7 +9301,7 @@ export declare type UseTableStylesProps = (<D extends object = Record<string, un
9297
9301
 
9298
9302
  export declare const useTheme: () => HvThemeContextValue;
9299
9303
 
9300
- export declare const useUniqueId: (id: any, idPrefix: any) => any;
9304
+ export declare const useUniqueId: (id?: string, idPrefix?: string) => string;
9301
9305
 
9302
9306
  export declare const useWidth: () => string;
9303
9307
 
@@ -9313,11 +9317,12 @@ export declare const VerticalNavigationContext: Context<VerticalNavigationContex
9313
9317
 
9314
9318
  declare interface VerticalNavigationContextValue {
9315
9319
  isOpen: boolean;
9316
- collapsedMode: HvVerticalNavigationMode;
9320
+ useIcons: boolean;
9317
9321
  slider?: boolean;
9318
9322
  headerTitle?: string;
9319
9323
  setHeaderTitle?: React.Dispatch<React.SetStateAction<string | undefined>>;
9320
9324
  parentItem?: any;
9325
+ setParentItem?: React.Dispatch<React.SetStateAction<any>>;
9321
9326
  withParentData?: any;
9322
9327
  navigateToChildHandler?: (event: any, item: any) => void;
9323
9328
  navigateToParentHandler?: () => void;
@@ -9366,15 +9371,6 @@ export declare const warningTextClasses: {
9366
9371
  topBorder: "HvWarningText-topBorder";
9367
9372
  };
9368
9373
 
9369
- export declare const withId: (Component: any) => {
9370
- ({ id, ...others }: WithIdProps): JSX_2.Element;
9371
- Naked: any;
9372
- };
9373
-
9374
- declare interface WithIdProps extends HvExtraProps {
9375
- id?: string;
9376
- }
9377
-
9378
9374
  export declare const withTooltip: (Component: React.FunctionComponent, label: string | undefined, placement: HvTooltipPlacementType, hideTooltip?: ((event: React.MouseEvent<HTMLDivElement>) => boolean) | undefined, tooltipProps?: HvTooltipProps, tooltipContainerProps?: HvBaseProps) => (props: any) => JSX_2.Element;
9379
9375
 
9380
9376
  export declare const wrapperTooltip: (hasTooltips: any, Component: any, label: any) => ((props: any) => JSX_2.Element) | (() => any);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hitachivantara/uikit-react-core",
3
- "version": "5.9.1",
3
+ "version": "5.11.0",
4
4
  "private": false,
5
5
  "author": "Hitachi Vantara UI Kit Team",
6
6
  "description": "Core React components for the NEXT Design System.",
@@ -30,9 +30,9 @@
30
30
  },
31
31
  "dependencies": {
32
32
  "@emotion/cache": "^11.10.5",
33
- "@hitachivantara/uikit-react-icons": "^5.1.9",
34
- "@hitachivantara/uikit-react-shared": "^5.0.13",
35
- "@hitachivantara/uikit-styles": "^5.7.1",
33
+ "@hitachivantara/uikit-react-icons": "^5.1.10",
34
+ "@hitachivantara/uikit-react-shared": "^5.0.14",
35
+ "@hitachivantara/uikit-styles": "^5.8.0",
36
36
  "@popperjs/core": "^2.11.6",
37
37
  "@types/react-table": "^7.7.14",
38
38
  "attr-accept": "^2.2.2",
@@ -58,7 +58,7 @@
58
58
  "access": "public",
59
59
  "directory": "package"
60
60
  },
61
- "gitHead": "d4eeebdbe4d08fbdc650a55910d415747dcb5531",
61
+ "gitHead": "f089170f43c957eb52d3d482b996f262c93a91c1",
62
62
  "main": "dist/cjs/index.cjs",
63
63
  "exports": {
64
64
  ".": {
@@ -1,31 +0,0 @@
1
- "use strict";
2
- Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
- const React = require("react");
4
- const hoistNonReactStatics = require("hoist-non-react-statics");
5
- const uniqueId = require("lodash/uniqueId");
6
- const jsxRuntime = require("@emotion/react/jsx-runtime");
7
- const getComponentName = require("../utils/getComponentName.cjs");
8
- const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
9
- const hoistNonReactStatics__default = /* @__PURE__ */ _interopDefault(hoistNonReactStatics);
10
- const uniqueId__default = /* @__PURE__ */ _interopDefault(uniqueId);
11
- const pascalToKebab = (string = "") => string.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
12
- const withId = (Component) => {
13
- const WithId = ({
14
- id,
15
- ...others
16
- }) => {
17
- const [internalId] = React.useState(id || uniqueId__default.default(`${pascalToKebab(getComponentName.default(Component))}-`));
18
- return /* @__PURE__ */ jsxRuntime.jsx(Component, {
19
- id: internalId,
20
- ...others
21
- });
22
- };
23
- hoistNonReactStatics__default.default(WithId, Component);
24
- if (process.env.NODE_ENV !== "production") {
25
- WithId.Naked = Component;
26
- }
27
- return WithId;
28
- };
29
- const withId$1 = withId;
30
- exports.default = withId$1;
31
- //# sourceMappingURL=withId.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"withId.cjs","sources":["../../../src/hocs/withId.tsx"],"sourcesContent":["import { useState } from \"react\";\nimport hoistNonReactStatics from \"hoist-non-react-statics\";\nimport uniqueId from \"lodash/uniqueId\";\nimport { HvExtraProps } from \"@core/types\";\nimport { getComponentName } from \"@core/utils\";\n\nconst pascalToKebab = (string = \"\") =>\n string.replace(/([a-z0-9])([A-Z])/g, \"$1-$2\").toLowerCase();\n\nexport interface WithIdProps extends HvExtraProps {\n id?: string;\n}\n\nconst withId = (Component) => {\n const WithId = ({ id, ...others }: WithIdProps) => {\n const [internalId] = useState(\n id || uniqueId(`${pascalToKebab(getComponentName(Component))}-`)\n );\n\n return <Component id={internalId} {...others} />;\n };\n\n // https://reactjs.org/docs/higher-order-components.html#static-methods-must-be-copied-over\n hoistNonReactStatics(WithId, Component);\n\n if (process.env.NODE_ENV !== \"production\") {\n WithId.Naked = Component;\n }\n\n return WithId;\n};\n\nexport default withId;\n"],"names":["pascalToKebab","string","replace","toLowerCase","withId","Component","WithId","id","others","internalId","useState","uniqueId","getComponentName","hoistNonReactStatics","process","env","NODE_ENV","Naked"],"mappings":";;;;;;;;;;AAMA,MAAMA,gBAAgBA,CAACC,SAAS,OAC9BA,OAAOC,QAAQ,sBAAsB,OAAO,EAAEC;AAMhD,MAAMC,SAAUC,CAAc,cAAA;AAC5B,QAAMC,SAASA,CAAC;AAAA,IAAEC;AAAAA,IAAI,GAAGC;AAAAA,EAAAA,MAA0B;AACjD,UAAM,CAACC,UAAU,IAAIC,eACnBH,MAAMI,kBAAAA,QAAU,GAAEX,cAAcY,iBAAiBP,QAAAA,SAAS,CAAC,IAAI,CAAC;AAGlE,0CAAQA,WAAS;AAAA,MAACE,IAAIE;AAAAA,MAAW,GAAKD;AAAAA,IAAAA,CAAU;AAAA,EAAA;AAIlDK,wCAAqBP,QAAQD,SAAS;AAElCS,MAAAA,QAAQC,IAAIC,aAAa,cAAc;AACzCV,WAAOW,QAAQZ;AAAAA,EACjB;AAEOC,SAAAA;AACT;AAEA,MAAA,WAAeF;;"}