@hitachivantara/uikit-react-core 5.66.11 → 5.66.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (260) hide show
  1. package/dist/cjs/ActionsGeneric/ActionsGeneric.cjs +1 -2
  2. package/dist/cjs/AvatarGroup/AvatarGroup.cjs +1 -2
  3. package/dist/cjs/BaseDropdown/BaseDropdown.cjs +2 -4
  4. package/dist/cjs/Box/Box.cjs +13 -14
  5. package/dist/cjs/Button/Button.cjs +3 -6
  6. package/dist/cjs/Calendar/CalendarHeader/CalendarHeader.cjs +2 -4
  7. package/dist/cjs/Calendar/SingleCalendar/CalendarCell.cjs +1 -2
  8. package/dist/cjs/Calendar/SingleCalendar/SingleCalendar.cjs +4 -8
  9. package/dist/cjs/Calendar/utils.cjs +4 -8
  10. package/dist/cjs/Carousel/Carousel.cjs +3 -6
  11. package/dist/cjs/ColorPicker/Fields/Fields.cjs +4 -8
  12. package/dist/cjs/DatePicker/DatePicker.cjs +6 -12
  13. package/dist/cjs/Dialog/Dialog.cjs +2 -4
  14. package/dist/cjs/Drawer/Drawer.cjs +1 -2
  15. package/dist/cjs/DropDownMenu/DropDownMenu.cjs +2 -4
  16. package/dist/cjs/Dropdown/Dropdown.cjs +1 -2
  17. package/dist/cjs/Dropdown/List/List.cjs +2 -4
  18. package/dist/cjs/Dropdown/utils.cjs +1 -2
  19. package/dist/cjs/FileUploader/DropZone/DropZone.cjs +3 -6
  20. package/dist/cjs/FileUploader/FileList/FileList.cjs +1 -2
  21. package/dist/cjs/FilterGroup/FilterContent/FilterContent.cjs +2 -4
  22. package/dist/cjs/Focus/Focus.cjs +7 -14
  23. package/dist/cjs/Forms/FormElement/utils/FormUtils.cjs +6 -4
  24. package/dist/cjs/GlobalActions/GlobalActions.styles.cjs +1 -2
  25. package/dist/cjs/Grid/Grid.cjs +7 -4
  26. package/dist/cjs/Header/Navigation/useSelectionPath.cjs +1 -2
  27. package/dist/cjs/Input/Input.cjs +2 -4
  28. package/dist/cjs/Link/Link.cjs +1 -2
  29. package/dist/cjs/List/List.cjs +12 -15
  30. package/dist/cjs/List/utils.cjs +1 -2
  31. package/dist/cjs/ListContainer/ListContainer.cjs +1 -2
  32. package/dist/cjs/ListContainer/ListContext/ListContext.cjs +1 -2
  33. package/dist/cjs/ListContainer/ListItem/ListItem.cjs +3 -6
  34. package/dist/cjs/LoadingContainer/LoadingContainer.cjs +2 -1
  35. package/dist/cjs/Pagination/Select.cjs +1 -2
  36. package/dist/cjs/QueryBuilder/Rule/Attribute/Attribute.cjs +1 -2
  37. package/dist/cjs/QueryBuilder/Rule/Value/NumericValue/NumericValue.cjs +2 -2
  38. package/dist/cjs/QueryBuilder/utils/reducer.cjs +1 -2
  39. package/dist/cjs/ScrollTo/Horizontal/ScrollToHorizontal.cjs +2 -2
  40. package/dist/cjs/ScrollTo/Vertical/ScrollToVertical.cjs +2 -2
  41. package/dist/cjs/Select/Select.cjs +2 -2
  42. package/dist/cjs/Skeleton/Skeleton.cjs +1 -2
  43. package/dist/cjs/Slider/Slider.cjs +1 -2
  44. package/dist/cjs/Slider/SliderInput/SliderInput.cjs +1 -2
  45. package/dist/cjs/Slider/utils.cjs +4 -8
  46. package/dist/cjs/Stack/Stack.cjs +1 -2
  47. package/dist/cjs/Table/TableContext.cjs +1 -2
  48. package/dist/cjs/Table/TableSectionContext.cjs +1 -2
  49. package/dist/cjs/Table/hooks/useBulkActions.cjs +1 -2
  50. package/dist/cjs/Table/hooks/useRowExpand.cjs +5 -1
  51. package/dist/cjs/Table/utils/fallbacks.cjs +1 -2
  52. package/dist/cjs/Tag/Tag.cjs +2 -4
  53. package/dist/cjs/TagsInput/TagsInput.cjs +2 -3
  54. package/dist/cjs/TextArea/TextArea.cjs +1 -2
  55. package/dist/cjs/TimeAgo/TimeAgo.cjs +1 -2
  56. package/dist/cjs/TimeAgo/useTimeout.cjs +1 -2
  57. package/dist/cjs/TimePicker/Placeholder.cjs +3 -6
  58. package/dist/cjs/TimePicker/TimePicker.cjs +3 -6
  59. package/dist/cjs/TreeView/TreeItem/TreeItem.cjs +2 -1
  60. package/dist/cjs/TreeView/TreeItem/useHvTreeItem.cjs +3 -6
  61. package/dist/cjs/TreeView/internals/DescendantProvider.cjs +1 -2
  62. package/dist/cjs/TreeView/internals/hooks/plugins/useTreeViewExpansion.cjs +1 -2
  63. package/dist/cjs/TreeView/internals/hooks/plugins/useTreeViewFocus.cjs +1 -2
  64. package/dist/cjs/TreeView/internals/hooks/plugins/useTreeViewKeyboardNavigation.cjs +1 -2
  65. package/dist/cjs/TreeView/internals/hooks/plugins/useTreeViewNodes.cjs +1 -2
  66. package/dist/cjs/TreeView/internals/hooks/plugins/useTreeViewSelection.cjs +1 -2
  67. package/dist/cjs/TreeView/internals/hooks/useInstanceEventHandler.cjs +1 -2
  68. package/dist/cjs/TreeView/internals/hooks/useTreeView.cjs +1 -2
  69. package/dist/cjs/TreeView/internals/hooks/useTreeViewInstanceEvents.cjs +1 -2
  70. package/dist/cjs/TreeView/internals/hooks/useTreeViewModels.cjs +1 -2
  71. package/dist/cjs/Typography/utils.cjs +1 -2
  72. package/dist/cjs/VerticalNavigation/Header/Header.cjs +1 -2
  73. package/dist/cjs/VerticalNavigation/Navigation/Navigation.cjs +2 -4
  74. package/dist/cjs/VerticalNavigation/TreeView/TreeView.cjs +3 -6
  75. package/dist/cjs/VerticalNavigation/TreeView/TreeViewItem.cjs +4 -8
  76. package/dist/cjs/hooks/useForkRef.cjs +1 -2
  77. package/dist/cjs/hooks/useUniqueId.cjs +2 -4
  78. package/dist/cjs/providers/Provider.cjs +2 -4
  79. package/dist/cjs/utils/classes.cjs +6 -3
  80. package/dist/cjs/utils/deepMerge.cjs +2 -1
  81. package/dist/cjs/utils/helpers.cjs +1 -2
  82. package/dist/cjs/utils/theme.cjs +1 -2
  83. package/dist/cjs/utils/useSavedState.cjs +1 -2
  84. package/dist/esm/ActionsGeneric/ActionsGeneric.js +1 -2
  85. package/dist/esm/ActionsGeneric/ActionsGeneric.js.map +1 -1
  86. package/dist/esm/AvatarGroup/AvatarGroup.js +1 -2
  87. package/dist/esm/AvatarGroup/AvatarGroup.js.map +1 -1
  88. package/dist/esm/BaseDropdown/BaseDropdown.js +2 -4
  89. package/dist/esm/BaseDropdown/BaseDropdown.js.map +1 -1
  90. package/dist/esm/Box/Box.js +13 -14
  91. package/dist/esm/Box/Box.js.map +1 -1
  92. package/dist/esm/Button/Button.js +3 -6
  93. package/dist/esm/Button/Button.js.map +1 -1
  94. package/dist/esm/Button/Button.styles.js.map +1 -1
  95. package/dist/esm/Calendar/CalendarHeader/CalendarHeader.js +2 -4
  96. package/dist/esm/Calendar/CalendarHeader/CalendarHeader.js.map +1 -1
  97. package/dist/esm/Calendar/SingleCalendar/CalendarCell.js +1 -2
  98. package/dist/esm/Calendar/SingleCalendar/CalendarCell.js.map +1 -1
  99. package/dist/esm/Calendar/SingleCalendar/SingleCalendar.js +4 -8
  100. package/dist/esm/Calendar/SingleCalendar/SingleCalendar.js.map +1 -1
  101. package/dist/esm/Calendar/utils.js +4 -8
  102. package/dist/esm/Calendar/utils.js.map +1 -1
  103. package/dist/esm/Card/Card.js.map +1 -1
  104. package/dist/esm/Carousel/Carousel.js +3 -6
  105. package/dist/esm/Carousel/Carousel.js.map +1 -1
  106. package/dist/esm/ColorPicker/Fields/Fields.js +3 -6
  107. package/dist/esm/ColorPicker/Fields/Fields.js.map +1 -1
  108. package/dist/esm/DatePicker/DatePicker.js +6 -12
  109. package/dist/esm/DatePicker/DatePicker.js.map +1 -1
  110. package/dist/esm/Dialog/Dialog.js +2 -4
  111. package/dist/esm/Dialog/Dialog.js.map +1 -1
  112. package/dist/esm/Drawer/Drawer.js +1 -2
  113. package/dist/esm/Drawer/Drawer.js.map +1 -1
  114. package/dist/esm/DropDownMenu/DropDownMenu.js +2 -4
  115. package/dist/esm/DropDownMenu/DropDownMenu.js.map +1 -1
  116. package/dist/esm/Dropdown/Dropdown.js +1 -2
  117. package/dist/esm/Dropdown/Dropdown.js.map +1 -1
  118. package/dist/esm/Dropdown/List/List.js +2 -4
  119. package/dist/esm/Dropdown/List/List.js.map +1 -1
  120. package/dist/esm/Dropdown/utils.js +1 -2
  121. package/dist/esm/Dropdown/utils.js.map +1 -1
  122. package/dist/esm/FileUploader/DropZone/DropZone.js +3 -6
  123. package/dist/esm/FileUploader/DropZone/DropZone.js.map +1 -1
  124. package/dist/esm/FileUploader/FileList/FileList.js +1 -2
  125. package/dist/esm/FileUploader/FileList/FileList.js.map +1 -1
  126. package/dist/esm/FilterGroup/FilterContent/FilterContent.js +2 -4
  127. package/dist/esm/FilterGroup/FilterContent/FilterContent.js.map +1 -1
  128. package/dist/esm/Focus/Focus.js +7 -14
  129. package/dist/esm/Focus/Focus.js.map +1 -1
  130. package/dist/esm/Forms/FormElement/FormElement.js.map +1 -1
  131. package/dist/esm/Forms/FormElement/context/FormElementContext.js.map +1 -1
  132. package/dist/esm/Forms/FormElement/context/FormElementDescriptorsContext.js.map +1 -1
  133. package/dist/esm/Forms/FormElement/utils/FormUtils.js +6 -4
  134. package/dist/esm/Forms/FormElement/utils/FormUtils.js.map +1 -1
  135. package/dist/esm/GlobalActions/GlobalActions.styles.js +1 -2
  136. package/dist/esm/GlobalActions/GlobalActions.styles.js.map +1 -1
  137. package/dist/esm/Grid/Grid.js +7 -4
  138. package/dist/esm/Grid/Grid.js.map +1 -1
  139. package/dist/esm/Header/Navigation/useSelectionPath.js +1 -2
  140. package/dist/esm/Header/Navigation/useSelectionPath.js.map +1 -1
  141. package/dist/esm/Input/Input.js +2 -4
  142. package/dist/esm/Input/Input.js.map +1 -1
  143. package/dist/esm/Link/Link.js +1 -2
  144. package/dist/esm/Link/Link.js.map +1 -1
  145. package/dist/esm/List/List.js +12 -15
  146. package/dist/esm/List/List.js.map +1 -1
  147. package/dist/esm/List/utils.js +1 -2
  148. package/dist/esm/List/utils.js.map +1 -1
  149. package/dist/esm/ListContainer/ListContainer.js +4 -5
  150. package/dist/esm/ListContainer/ListContainer.js.map +1 -1
  151. package/dist/esm/ListContainer/ListContext/ListContext.js +1 -2
  152. package/dist/esm/ListContainer/ListContext/ListContext.js.map +1 -1
  153. package/dist/esm/ListContainer/ListItem/ListItem.js +5 -8
  154. package/dist/esm/ListContainer/ListItem/ListItem.js.map +1 -1
  155. package/dist/esm/Loading/Loading.js.map +1 -1
  156. package/dist/esm/LoadingContainer/LoadingContainer.js +2 -1
  157. package/dist/esm/LoadingContainer/LoadingContainer.js.map +1 -1
  158. package/dist/esm/MultiButton/MultiButton.js.map +1 -1
  159. package/dist/esm/Pagination/Select.js +1 -2
  160. package/dist/esm/Pagination/Select.js.map +1 -1
  161. package/dist/esm/QueryBuilder/Rule/Attribute/Attribute.js +1 -2
  162. package/dist/esm/QueryBuilder/Rule/Attribute/Attribute.js.map +1 -1
  163. package/dist/esm/QueryBuilder/Rule/Operator/Operator.js.map +1 -1
  164. package/dist/esm/QueryBuilder/Rule/Value/NumericValue/NumericValue.js +2 -2
  165. package/dist/esm/QueryBuilder/Rule/Value/NumericValue/NumericValue.js.map +1 -1
  166. package/dist/esm/QueryBuilder/utils/index.js.map +1 -1
  167. package/dist/esm/QueryBuilder/utils/reducer.js +1 -2
  168. package/dist/esm/QueryBuilder/utils/reducer.js.map +1 -1
  169. package/dist/esm/ScrollTo/Horizontal/ScrollToHorizontal.js +2 -2
  170. package/dist/esm/ScrollTo/Horizontal/ScrollToHorizontal.js.map +1 -1
  171. package/dist/esm/ScrollTo/Vertical/ScrollToVertical.js +2 -2
  172. package/dist/esm/ScrollTo/Vertical/ScrollToVertical.js.map +1 -1
  173. package/dist/esm/Section/Section.js.map +1 -1
  174. package/dist/esm/Select/Select.js +2 -2
  175. package/dist/esm/Select/Select.js.map +1 -1
  176. package/dist/esm/SimpleGrid/SimpleGrid.styles.js.map +1 -1
  177. package/dist/esm/Skeleton/Skeleton.js +1 -2
  178. package/dist/esm/Skeleton/Skeleton.js.map +1 -1
  179. package/dist/esm/Slider/Slider.js +1 -2
  180. package/dist/esm/Slider/Slider.js.map +1 -1
  181. package/dist/esm/Slider/SliderInput/SliderInput.js +1 -2
  182. package/dist/esm/Slider/SliderInput/SliderInput.js.map +1 -1
  183. package/dist/esm/Slider/utils.js +4 -8
  184. package/dist/esm/Slider/utils.js.map +1 -1
  185. package/dist/esm/Snackbar/Snackbar.js.map +1 -1
  186. package/dist/esm/Stack/Stack.js +1 -2
  187. package/dist/esm/Stack/Stack.js.map +1 -1
  188. package/dist/esm/Table/TableCell/TableCell.js.map +1 -1
  189. package/dist/esm/Table/TableContext.js +1 -2
  190. package/dist/esm/Table/TableContext.js.map +1 -1
  191. package/dist/esm/Table/TableHeader/TableHeader.js.map +1 -1
  192. package/dist/esm/Table/TableRow/TableRow.js.map +1 -1
  193. package/dist/esm/Table/TableSectionContext.js +1 -2
  194. package/dist/esm/Table/TableSectionContext.js.map +1 -1
  195. package/dist/esm/Table/hooks/useBulkActions.js +1 -2
  196. package/dist/esm/Table/hooks/useBulkActions.js.map +1 -1
  197. package/dist/esm/Table/hooks/useHeaderGroups.js.map +1 -1
  198. package/dist/esm/Table/hooks/usePagination.js.map +1 -1
  199. package/dist/esm/Table/hooks/useResizeColumns.js.map +1 -1
  200. package/dist/esm/Table/hooks/useRowExpand.js +5 -1
  201. package/dist/esm/Table/hooks/useRowExpand.js.map +1 -1
  202. package/dist/esm/Table/hooks/useRowSelection.js.map +1 -1
  203. package/dist/esm/Table/hooks/useSortBy.js.map +1 -1
  204. package/dist/esm/Table/hooks/useSticky.js.map +1 -1
  205. package/dist/esm/Table/hooks/useTableStyles.js.map +1 -1
  206. package/dist/esm/Table/utils/fallbacks.js +1 -2
  207. package/dist/esm/Table/utils/fallbacks.js.map +1 -1
  208. package/dist/esm/Tag/Tag.js +2 -4
  209. package/dist/esm/Tag/Tag.js.map +1 -1
  210. package/dist/esm/TagsInput/TagsInput.js +2 -3
  211. package/dist/esm/TagsInput/TagsInput.js.map +1 -1
  212. package/dist/esm/TextArea/TextArea.js +1 -2
  213. package/dist/esm/TextArea/TextArea.js.map +1 -1
  214. package/dist/esm/TimeAgo/TimeAgo.js +1 -2
  215. package/dist/esm/TimeAgo/TimeAgo.js.map +1 -1
  216. package/dist/esm/TimeAgo/useTimeout.js +1 -2
  217. package/dist/esm/TimeAgo/useTimeout.js.map +1 -1
  218. package/dist/esm/TimePicker/Placeholder.js +3 -6
  219. package/dist/esm/TimePicker/Placeholder.js.map +1 -1
  220. package/dist/esm/TimePicker/TimePicker.js +3 -6
  221. package/dist/esm/TimePicker/TimePicker.js.map +1 -1
  222. package/dist/esm/TreeView/TreeItem/TreeItem.js +2 -1
  223. package/dist/esm/TreeView/TreeItem/TreeItem.js.map +1 -1
  224. package/dist/esm/TreeView/TreeItem/useHvTreeItem.js +2 -4
  225. package/dist/esm/TreeView/TreeItem/useHvTreeItem.js.map +1 -1
  226. package/dist/esm/Typography/utils.js +1 -2
  227. package/dist/esm/Typography/utils.js.map +1 -1
  228. package/dist/esm/VerticalNavigation/Header/Header.js +1 -2
  229. package/dist/esm/VerticalNavigation/Header/Header.js.map +1 -1
  230. package/dist/esm/VerticalNavigation/Navigation/Navigation.js +2 -4
  231. package/dist/esm/VerticalNavigation/Navigation/Navigation.js.map +1 -1
  232. package/dist/esm/VerticalNavigation/NavigationSlider/utils/NavigationSlider.utils.js.map +1 -1
  233. package/dist/esm/VerticalNavigation/TreeView/TreeView.js +3 -6
  234. package/dist/esm/VerticalNavigation/TreeView/TreeView.js.map +1 -1
  235. package/dist/esm/VerticalNavigation/TreeView/TreeViewContext.js.map +1 -1
  236. package/dist/esm/VerticalNavigation/TreeView/TreeViewItem.js +4 -8
  237. package/dist/esm/VerticalNavigation/TreeView/TreeViewItem.js.map +1 -1
  238. package/dist/esm/VerticalNavigation/VerticalNavigation.js.map +1 -1
  239. package/dist/esm/VerticalNavigation/VerticalNavigationContext.js.map +1 -1
  240. package/dist/esm/hocs/withTooltip.js.map +1 -1
  241. package/dist/esm/hooks/useComputation.js.map +1 -1
  242. package/dist/esm/hooks/useCss.js.map +1 -1
  243. package/dist/esm/hooks/useForkRef.js.map +1 -1
  244. package/dist/esm/hooks/useUniqueId.js +1 -2
  245. package/dist/esm/hooks/useUniqueId.js.map +1 -1
  246. package/dist/esm/providers/Provider.js +2 -4
  247. package/dist/esm/providers/Provider.js.map +1 -1
  248. package/dist/esm/types/generic.js.map +1 -1
  249. package/dist/esm/utils/classes.js +6 -3
  250. package/dist/esm/utils/classes.js.map +1 -1
  251. package/dist/esm/utils/deepMerge.js +2 -1
  252. package/dist/esm/utils/deepMerge.js.map +1 -1
  253. package/dist/esm/utils/helpers.js +1 -2
  254. package/dist/esm/utils/helpers.js.map +1 -1
  255. package/dist/esm/utils/theme.js +1 -2
  256. package/dist/esm/utils/theme.js.map +1 -1
  257. package/dist/esm/utils/useSavedState.js +1 -2
  258. package/dist/esm/utils/useSavedState.js.map +1 -1
  259. package/dist/types/index.d.ts +268 -352
  260. package/package.json +4 -4
@@ -1 +1 @@
1
- {"version":3,"file":"TreeViewItem.js","sources":["../../../../src/VerticalNavigation/TreeView/TreeViewItem.tsx"],"sourcesContent":["import {\n forwardRef,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { DropDownXS, DropUpXS } from \"@hitachivantara/uikit-react-icons\";\n\nimport { useDefaultProps } from \"../../hooks/useDefaultProps\";\nimport { useForkRef } from \"../../hooks/useForkRef\";\nimport { HvOverflowTooltip } from \"../../OverflowTooltip\";\nimport { HvTooltip } from \"../../Tooltip\";\nimport {\n DescendantProvider,\n useDescendant,\n} from \"../../TreeView/internals/DescendantProvider\";\nimport { HvTypography } from \"../../Typography\";\nimport { ExtractNames } from \"../../utils/classes\";\nimport { setId } from \"../../utils/setId\";\nimport { VerticalNavigationContext } from \"../VerticalNavigationContext\";\nimport { IconWrapper } from \"./IconWrapper\";\nimport {\n TreeViewControlContext,\n TreeViewStateContext,\n} from \"./TreeViewContext\";\nimport { staticClasses, useClasses } from \"./TreeViewItem.styles\";\n\nexport { staticClasses as treeViewItemClasses };\n\nexport type HvVerticalNavigationTreeViewItemClasses = ExtractNames<\n typeof useClasses\n>;\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: classesProp,\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 } = useDefaultProps(\"HvVerticalNavigationTreeViewItem\", props);\n\n const { classes, cx } = useClasses(classesProp);\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<HTMLLIElement>();\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, hasAnyChildWithData } = useContext(\n VerticalNavigationContext,\n );\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 isOpen,\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 isOpen,\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, isOpen],\n );\n\n const renderedContent = useMemo(() => {\n const buttonLinkProps = {\n href,\n target,\n };\n\n const hasChildren = !!children;\n const showTooltip = !hasChildren && !isOpen && !disableTooltip;\n\n const isLink = href !== undefined && !disabled;\n\n return (\n <HvTooltip placement=\"right\" title={showTooltip && label}>\n <HvTypography\n id={setId(id, \"button\")}\n component={isLink ? \"a\" : \"div\"}\n {...(isLink ? buttonLinkProps : null)}\n ref={contentRef}\n className={cx(classes.content, {\n [classes.link]: isLink,\n [classes.minimized]: !isOpen,\n })}\n variant=\"body\"\n disabled={disabled}\n onClick={handleClick}\n onMouseDown={handleMouseDown}\n style={{\n paddingLeft:\n (useIcons || !isOpen ? 0 : 10) +\n level * (collapsible ? 16 : 10),\n }}\n role={isLink ? 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\":\n isOpen && expandable ? setId(id, \"group\") : undefined,\n \"aria-label\": payload?.label,\n })}\n >\n <IconWrapper\n icon={useIcons && icon}\n label={payload?.label}\n hasChildren={hasChildren}\n showAvatar={!icon && useIcons}\n isOpen={isOpen}\n hasAnyChildWithData={hasAnyChildWithData}\n style={{\n // @ts-ignore\n \"--icon-margin-left\": hasAnyChildWithData ? \"auto\" : \"unset\",\n }}\n className={classes.icon}\n />\n\n {isOpen && (\n <div\n className={cx(classes.label, {\n [classes.labelIcon]: useIcons,\n [classes.labelExpandable]: !!expandable,\n })}\n >\n <HvOverflowTooltip data={label} />\n </div>\n )}\n\n {isOpen && expandable && (expanded ? <DropUpXS /> : <DropDownXS />)}\n </HvTypography>\n </HvTooltip>\n );\n }, [\n href,\n target,\n children,\n isOpen,\n disableTooltip,\n disabled,\n label,\n id,\n cx,\n classes.content,\n classes.link,\n classes.minimized,\n classes.icon,\n classes.label,\n classes.labelIcon,\n classes.labelExpandable,\n handleClick,\n handleMouseDown,\n useIcons,\n level,\n collapsible,\n treeviewMode,\n handleFocus,\n selectable,\n expandable,\n handleKeyDown,\n selected,\n isChildSelected,\n nodeId,\n expanded,\n payload?.label,\n icon,\n hasAnyChildWithData,\n ]);\n\n const renderedChildren = useMemo(\n () =>\n children && (\n <ul\n id={setId(id, \"group\")}\n className={classes.group}\n role={treeviewMode ? \"group\" : undefined}\n >\n {children}\n </ul>\n ),\n [children, classes?.group, id, treeviewMode],\n );\n\n return (\n <li\n ref={handleRef}\n id={id ?? undefined}\n className={cx(\n classes.node,\n {\n [classes.disabled]: disabled,\n [classes.expandable]: expandable,\n [classes.collapsed]: expandable && !expanded,\n [classes.expanded]: expandable && expanded,\n [classes.selectable]: selectable && !disabled,\n [classes.unselectable]: !disabled && !selectable,\n [classes.selected]:\n (!disabled && selectable && selected) ||\n (!isOpen &&\n useIcons &&\n isChildSelected &&\n isChildSelected(nodeId)),\n [classes.unselected]: !disabled && selectable && !selected,\n [classes.focused]: focused,\n [classes.hide]: !isOpen && !useIcons,\n },\n className,\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 </li>\n );\n },\n);\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AA2GA,MAAM,mBAAmB,CAAC,OAAO,aAAa;AAC5C,MAAI,MAAM,YAAY,MAAM,WAAW,MAAM,WAAW,UAAU;AAEhE,UAAM,eAAe;AAAA,EACvB;AACF;AAEO,MAAM,mCAAmC;AAAA,EAC9C,CAAC,OAA8C,QAAQ;AAC/C,UAAA;AAAA,MACJ,IAAI;AAAA,MACJ;AAAA,MACA,SAAS;AAAA,MAET,UAAU,eAAe;AAAA,MAEzB,YAAY;AAAA,MAEZ;AAAA,MACA,OAAO;AAAA,MACP;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MAEA;AAAA,MACA;AAAA,MACA;AAAA,MAEA;AAAA,MAEA;AAAA,MAEA,GAAG;AAAA,IAAA,IACD,gBAAgB,oCAAoC,KAAK;AAE7D,UAAM,EAAE,SAAS,GAAG,IAAI,WAAW,WAAW;AAExC,UAAA,yBAAyB,WAAW,sBAAsB;AAC1D,UAAA,EAAE,YAAY,YAAY,WAAW,YAAY,gBAAgB,IACrE,WAAW,oBAAoB;AAE3B,UAAA;AAAA,MACJ;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;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OAAO,OAAO;AAAA,QACnC,GAAI,SAAS,cAAc;AAAA,UAC1B,MAAM;AAAA,UACN,iBAAiB;AAAA,UACjB,iBAAiB,aAAa,WAAW;AAAA,UACzC,iBAAiB,WAAW,OAAO;AAAA,QACrC;AAAA,QACC,GAAG;AAAA,QAEH,UAAA;AAAA,UAAA;AAAA,UACA,8BACE,oBAAmB,EAAA,IAAI,QAAQ,OAAO,QAAQ,GAC5C,UACH,iBAAA,CAAA;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAIR;AACF;"}
1
+ {"version":3,"file":"TreeViewItem.js","sources":["../../../../src/VerticalNavigation/TreeView/TreeViewItem.tsx"],"sourcesContent":["import {\n forwardRef,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { DropDownXS, DropUpXS } from \"@hitachivantara/uikit-react-icons\";\n\nimport { useDefaultProps } from \"../../hooks/useDefaultProps\";\nimport { useForkRef } from \"../../hooks/useForkRef\";\nimport { HvOverflowTooltip } from \"../../OverflowTooltip\";\nimport { HvTooltip } from \"../../Tooltip\";\nimport {\n DescendantProvider,\n useDescendant,\n} from \"../../TreeView/internals/DescendantProvider\";\nimport { HvTypography } from \"../../Typography\";\nimport { ExtractNames } from \"../../utils/classes\";\nimport { setId } from \"../../utils/setId\";\nimport { VerticalNavigationContext } from \"../VerticalNavigationContext\";\nimport { IconWrapper } from \"./IconWrapper\";\nimport {\n TreeViewControlContext,\n TreeViewStateContext,\n} from \"./TreeViewContext\";\nimport { staticClasses, useClasses } from \"./TreeViewItem.styles\";\n\nexport { staticClasses as treeViewItemClasses };\n\nexport type HvVerticalNavigationTreeViewItemClasses = ExtractNames<\n typeof useClasses\n>;\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: any, disabled: any) => {\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: classesProp,\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 } = useDefaultProps(\"HvVerticalNavigationTreeViewItem\", props);\n\n const { classes, cx } = useClasses(classesProp);\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<HTMLLIElement>();\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, hasAnyChildWithData } = useContext(\n VerticalNavigationContext,\n );\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: any) => {\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: any) => {\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 isOpen,\n ],\n );\n\n const handleSelection = useCallback(\n (event: any) => {\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: any) => {\n preventSelection(event, disabled);\n\n if (onMouseDown) {\n onMouseDown(event);\n }\n },\n [disabled, onMouseDown],\n );\n\n const handleClick = useCallback(\n (event: any) => {\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 isOpen,\n ],\n );\n\n const handleKeyDown = useCallback(\n (event: any) => {\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, isOpen],\n );\n\n const renderedContent = useMemo(() => {\n const buttonLinkProps = {\n href,\n target,\n };\n\n const hasChildren = !!children;\n const showTooltip = !hasChildren && !isOpen && !disableTooltip;\n\n const isLink = href !== undefined && !disabled;\n\n return (\n <HvTooltip placement=\"right\" title={showTooltip && label}>\n <HvTypography\n id={setId(id, \"button\")}\n component={isLink ? \"a\" : \"div\"}\n {...(isLink ? buttonLinkProps : null)}\n ref={contentRef}\n className={cx(classes.content, {\n [classes.link]: isLink,\n [classes.minimized]: !isOpen,\n })}\n variant=\"body\"\n disabled={disabled}\n onClick={handleClick}\n onMouseDown={handleMouseDown}\n style={{\n paddingLeft:\n (useIcons || !isOpen ? 0 : 10) +\n level * (collapsible ? 16 : 10),\n }}\n role={isLink ? 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\":\n isOpen && expandable ? setId(id, \"group\") : undefined,\n \"aria-label\": payload?.label,\n })}\n >\n <IconWrapper\n icon={useIcons && icon}\n label={payload?.label}\n hasChildren={hasChildren}\n showAvatar={!icon && useIcons}\n isOpen={isOpen}\n hasAnyChildWithData={hasAnyChildWithData}\n style={{\n // @ts-ignore\n \"--icon-margin-left\": hasAnyChildWithData ? \"auto\" : \"unset\",\n }}\n className={classes.icon}\n />\n\n {isOpen && (\n <div\n className={cx(classes.label, {\n [classes.labelIcon]: useIcons,\n [classes.labelExpandable]: !!expandable,\n })}\n >\n <HvOverflowTooltip data={label} />\n </div>\n )}\n\n {isOpen && expandable && (expanded ? <DropUpXS /> : <DropDownXS />)}\n </HvTypography>\n </HvTooltip>\n );\n }, [\n href,\n target,\n children,\n isOpen,\n disableTooltip,\n disabled,\n label,\n id,\n cx,\n classes.content,\n classes.link,\n classes.minimized,\n classes.icon,\n classes.label,\n classes.labelIcon,\n classes.labelExpandable,\n handleClick,\n handleMouseDown,\n useIcons,\n level,\n collapsible,\n treeviewMode,\n handleFocus,\n selectable,\n expandable,\n handleKeyDown,\n selected,\n isChildSelected,\n nodeId,\n expanded,\n payload?.label,\n icon,\n hasAnyChildWithData,\n ]);\n\n const renderedChildren = useMemo(\n () =>\n children && (\n <ul\n id={setId(id, \"group\")}\n className={classes.group}\n role={treeviewMode ? \"group\" : undefined}\n >\n {children}\n </ul>\n ),\n [children, classes?.group, id, treeviewMode],\n );\n\n return (\n <li\n ref={handleRef}\n id={id ?? undefined}\n className={cx(\n classes.node,\n {\n [classes.disabled]: disabled,\n [classes.expandable]: expandable,\n [classes.collapsed]: expandable && !expanded,\n [classes.expanded]: expandable && expanded,\n [classes.selectable]: selectable && !disabled,\n [classes.unselectable]: !disabled && !selectable,\n [classes.selected]:\n (!disabled && selectable && selected) ||\n (!isOpen &&\n useIcons &&\n isChildSelected &&\n isChildSelected(nodeId)),\n [classes.unselected]: !disabled && selectable && !selected,\n [classes.focused]: focused,\n [classes.hide]: !isOpen && !useIcons,\n },\n className,\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 </li>\n );\n },\n);\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AA2GA,MAAM,mBAAmB,CAAC,OAAY,aAAkB;AACtD,MAAI,MAAM,YAAY,MAAM,WAAW,MAAM,WAAW,UAAU;AAEhE,UAAM,eAAe;AAAA,EACvB;AACF;AAEO,MAAM,mCAAmC;AAAA,EAC9C,CAAC,OAA8C,QAAQ;AAC/C,UAAA;AAAA,MACJ,IAAI;AAAA,MACJ;AAAA,MACA,SAAS;AAAA,MAET,UAAU,eAAe;AAAA,MAEzB,YAAY;AAAA,MAEZ;AAAA,MACA,OAAO;AAAA,MACP;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MAEA;AAAA,MACA;AAAA,MACA;AAAA,MAEA;AAAA,MAEA;AAAA,MAEA,GAAG;AAAA,IAAA,IACD,gBAAgB,oCAAoC,KAAK;AAE7D,UAAM,EAAE,SAAS,GAAG,IAAI,WAAW,WAAW;AAExC,UAAA,yBAAyB,WAAW,sBAAsB;AAC1D,UAAA,EAAE,YAAY,YAAY,WAAW,YAAY,gBAAgB,IACrE,WAAW,oBAAoB;AAE3B,UAAA;AAAA,MACJ;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACE,IAAA;AAEJ,UAAM,eAAe,SAAS;AAE9B,QAAI,KAAoB;AAExB,QAAI,UAAU,MAAM;AACb,WAAA;AAAA,IAAA,WACI,UAAU,QAAQ;AACtB,WAAA,GAAG,MAAM,IAAI,MAAM;AAAA,IAC1B;AAEA,U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AQ,GAC5C,UACH,iBAAA,CAAA;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAIR;AACF;"}
@@ -1 +1 @@
1
- {"version":3,"file":"VerticalNavigation.js","sources":["../../../src/VerticalNavigation/VerticalNavigation.tsx"],"sourcesContent":["import { useCallback, useEffect, useMemo, useState } from \"react\";\n\nimport { useDefaultProps } from \"../hooks/useDefaultProps\";\nimport { HvBaseProps } from \"../types/generic\";\nimport { ExtractNames } from \"../utils/classes\";\nimport {\n fillDataWithParentId,\n getNavigationItemById,\n getParentItemById,\n} from \"./NavigationSlider/utils\";\nimport { hasChildNavigationItems } from \"./utils/VerticalNavigation.utils\";\nimport { staticClasses, useClasses } from \"./VerticalNavigation.styles\";\nimport {\n NavigationData,\n VerticalNavigationContext,\n} from \"./VerticalNavigationContext\";\n\nexport { staticClasses as verticalNavigationClasses };\n\nexport type HvVerticalNavigationClasses = ExtractNames<typeof useClasses>;\n\nexport type HvVerticalNavigationMode = \"icon\" | \"simple\";\n\nexport type HvVerticalNavigationPosition =\n | \"static\"\n | \"relative\"\n | \"fixed\"\n | \"absolute\";\n\nexport interface HvVerticalNavigationProps extends HvBaseProps<HTMLDivElement> {\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvVerticalNavigationClasses;\n /** Current State of the Vertical Navigation Collapse */\n open?: boolean;\n /**\n * Collapsed Mode for the Vertical Navigation, the default value is \"simple\".\n *\n * @deprecated - `useIcons` property should be used instead.\n */\n collapsedMode?: HvVerticalNavigationMode;\n /** Boolean to determine if treeview is in slider mode (for mobile navigation), the default value is false. */\n slider?: boolean;\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 = (props: HvVerticalNavigationProps) => {\n const {\n id,\n className,\n classes: classesProp,\n children,\n open = true,\n slider = false,\n useIcons = false,\n ...others\n } = useDefaultProps(\"HvVerticalNavigation\", props);\n const { classes, cx } = useClasses(classesProp);\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 = useCallback(() => {\n setParentItem(getParentItemById(withParentData, parentItem.id));\n }, [parentItem, setParentItem, withParentData]);\n\n const navigateToChildHandler = useCallback(\n (event, item) => {\n setParentItem(getNavigationItemById(withParentData, item.id));\n event.stopPropagation();\n },\n [setParentItem, withParentData],\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 parentData,\n parentSelected,\n ],\n );\n\n const content = (\n <VerticalNavigationContext.Provider value={value}>\n <div\n id={id}\n className={cx(\n classes.root,\n {\n [classes.collapsed]: !open,\n [classes.slider]: slider,\n [classes.childData]: hasAnyChildWithData,\n },\n className,\n )}\n {...others}\n >\n {children}\n </div>\n </VerticalNavigationContext.Provider>\n );\n\n return content;\n};\n"],"names":[],"mappings":";;;;;;;;AAmEa,MAAA,uBAAuB,CAAC,UAAqC;AAClE,QAAA;AAAA,IACJ;AAAA,IACA;AAAA,IACA,SAAS;AAAA,IACT;AAAA,IACA,OAAO;AAAA,IACP,SAAS;AAAA,IACT,WAAW;AAAA,IACX,GAAG;AAAA,EAAA,IACD,gBAAgB,wBAAwB,KAAK;AACjD,QAAM,EAAE,SAAS,GAAG,IAAI,WAAW,WAAW;AAE9C,QAAM,CAAC,YAAY,aAAa,IAAI,SAA2B,CAAE,CAAA;AAEjE,QAAM,CAAC,gBAAgB,iBAAiB,IAAI,SAAS;AAErD,QAAM,CAAC,aAAa,cAAc,IAAI,SAA6B;AAGnE,QAAM,iBAAiB;AAAA,IACrB,MAAM,qBAAqB,UAAU;AAAA,IACrC,CAAC,UAAU;AAAA,EAAA;AAGb,QAAM,oBAAoB;AAAA,IACxB,MAAM,kBAAkB,gBAAgB,cAAc;AAAA,IACtD,CAAC,gBAAgB,cAAc;AAAA,EAAA;AAGjC,QAAM,CAAC,YAAY,aAAa,IAAI,SAAS,iBAAiB;AAE9D,QAAM,sBAAsB;AAAA,IAC1B,MAAM,wBAAwB,UAAU;AAAA,IACxC,CAAC,UAAU;AAAA,EAAA;AAGb;AAAA,IACE,MAAM,eAAe,YAAY,KAAK;AAAA,IACtC,CAAC,YAAY,aAAa;AAAA,EAAA;AAGtB,QAAA,0BAA0B,YAAY,MAAM;AAChD,kBAAc,kBAAkB,gBAAgB,WAAW,EAAE,CAAC;AAAA,EAC7D,GAAA,CAAC,YAAY,eAAe,cAAc,CAAC;AAE9C,QAAM,yBAAyB;AAAA,IAC7B,CAAC,OAAO,SAAS;AACf,oBAAc,sBAAsB,gBAAgB,KAAK,EAAE,CAAC;AAC5D,YAAM,gBAAgB;AAAA,IACxB;AAAA,IACA,CAAC,eAAe,cAAc;AAAA,EAAA;AAGhC,QAAM,QAAQ;AAAA,IACZ,OAAO;AAAA,MACL,QAAQ;AAAA,MACR;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MAEA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MAEA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IAAA;AAAA,IAEF;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EAAA;AAGF,QAAM,UACJ,oBAAC,0BAA0B,UAA1B,EAAmC,OAClC,UAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC;AAAA,MACA,WAAW;AAAA,QACT,QAAQ;AAAA,QACR;AAAA,UACE,CAAC,QAAQ,SAAS,GAAG,CAAC;AAAA,UACtB,CAAC,QAAQ,MAAM,GAAG;AAAA,UAClB,CAAC,QAAQ,SAAS,GAAG;AAAA,QACvB;AAAA,QACA;AAAA,MACF;AAAA,MACC,GAAG;AAAA,MAEH;AAAA,IAAA;AAAA,EAEL,EAAA,CAAA;AAGK,SAAA;AACT;"}
1
+ {"version":3,"file":"VerticalNavigation.js","sources":["../../../src/VerticalNavigation/VerticalNavigation.tsx"],"sourcesContent":["import { useCallback, useEffect, useMemo, useState } from \"react\";\n\nimport { useDefaultProps } from \"../hooks/useDefaultProps\";\nimport { HvBaseProps } from \"../types/generic\";\nimport { ExtractNames } from \"../utils/classes\";\nimport {\n fillDataWithParentId,\n getNavigationItemById,\n getParentItemById,\n} from \"./NavigationSlider/utils\";\nimport { hasChildNavigationItems } from \"./utils/VerticalNavigation.utils\";\nimport { staticClasses, useClasses } from \"./VerticalNavigation.styles\";\nimport {\n NavigationData,\n VerticalNavigationContext,\n} from \"./VerticalNavigationContext\";\n\nexport { staticClasses as verticalNavigationClasses };\n\nexport type HvVerticalNavigationClasses = ExtractNames<typeof useClasses>;\n\nexport type HvVerticalNavigationMode = \"icon\" | \"simple\";\n\nexport type HvVerticalNavigationPosition =\n | \"static\"\n | \"relative\"\n | \"fixed\"\n | \"absolute\";\n\nexport interface HvVerticalNavigationProps extends HvBaseProps<HTMLDivElement> {\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvVerticalNavigationClasses;\n /** Current State of the Vertical Navigation Collapse */\n open?: boolean;\n /**\n * Collapsed Mode for the Vertical Navigation, the default value is \"simple\".\n *\n * @deprecated - `useIcons` property should be used instead.\n */\n collapsedMode?: HvVerticalNavigationMode;\n /** Boolean to determine if treeview is in slider mode (for mobile navigation), the default value is false. */\n slider?: boolean;\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 = (props: HvVerticalNavigationProps) => {\n const {\n id,\n className,\n classes: classesProp,\n children,\n open = true,\n slider = false,\n useIcons = false,\n ...others\n } = useDefaultProps(\"HvVerticalNavigation\", props);\n const { classes, cx } = useClasses(classesProp);\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 = useCallback(() => {\n setParentItem(getParentItemById(withParentData, parentItem.id));\n }, [parentItem, setParentItem, withParentData]);\n\n const navigateToChildHandler = useCallback(\n (event: any, item: any) => {\n setParentItem(getNavigationItemById(withParentData, item.id));\n event.stopPropagation();\n },\n [setParentItem, withParentData],\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 parentData,\n parentSelected,\n ],\n );\n\n const content = (\n <VerticalNavigationContext.Provider value={value}>\n <div\n id={id}\n className={cx(\n classes.root,\n {\n [classes.collapsed]: !open,\n [classes.slider]: slider,\n [classes.childData]: hasAnyChildWithData,\n },\n className,\n )}\n {...others}\n >\n {children}\n </div>\n </VerticalNavigationContext.Provider>\n );\n\n return content;\n};\n"],"names":[],"mappings":";;;;;;;;AAmEa,MAAA,uBAAuB,CAAC,UAAqC;AAClE,QAAA;AAAA,IACJ;AAAA,IACA;AAAA,IACA,SAAS;AAAA,IACT;AAAA,IACA,OAAO;AAAA,IACP,SAAS;AAAA,IACT,WAAW;AAAA,IACX,GAAG;AAAA,EAAA,IACD,gBAAgB,wBAAwB,KAAK;AACjD,QAAM,EAAE,SAAS,GAAG,IAAI,WAAW,WAAW;AAE9C,QAAM,CAAC,YAAY,aAAa,IAAI,SAA2B,CAAE,CAAA;AAEjE,QAAM,CAAC,gBAAgB,iBAAiB,IAAI,SAAS;AAErD,QAAM,CAAC,aAAa,cAAc,IAAI,SAA6B;AAGnE,QAAM,iBAAiB;AAAA,IACrB,MAAM,qBAAqB,UAAU;AAAA,IACrC,CAAC,UAAU;AAAA,EAAA;AAGb,QAAM,oBAAoB;AAAA,IACxB,MAAM,kBAAkB,gBAAgB,cAAc;AAAA,IACtD,CAAC,gBAAgB,cAAc;AAAA,EAAA;AAGjC,QAAM,CAAC,YAAY,aAAa,IAAI,SAAS,iBAAiB;AAE9D,QAAM,sBAAsB;AAAA,IAC1B,MAAM,wBAAwB,UAAU;AAAA,IACxC,CAAC,UAAU;AAAA,EAAA;AAGb;AAAA,IACE,MAAM,eAAe,YAAY,KAAK;AAAA,IACtC,CAAC,YAAY,aAAa;AAAA,EAAA;AAGtB,QAAA,0BAA0B,YAAY,MAAM;AAChD,kBAAc,kBAAkB,gBAAgB,WAAW,EAAE,CAAC;AAAA,EAC7D,GAAA,CAAC,YAAY,eAAe,cAAc,CAAC;AAE9C,QAAM,yBAAyB;AAAA,IAC7B,CAAC,OAAY,SAAc;AACzB,oBAAc,sBAAsB,gBAAgB,KAAK,EAAE,CAAC;AAC5D,YAAM,gBAAgB;AAAA,IACxB;AAAA,IACA,CAAC,eAAe,cAAc;AAAA,EAAA;AAGhC,QAAM,QAAQ;AAAA,IACZ,OAAO;AAAA,MACL,QAAQ;AAAA,MACR;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MAEA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MAEA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IAAA;AAAA,IAEF;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EAAA;AAGF,QAAM,UACJ,oBAAC,0BAA0B,UAA1B,EAAmC,OAClC,UAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC;AAAA,MACA,WAAW;AAAA,QACT,QAAQ;AAAA,QACR;AAAA,UACE,CAAC,QAAQ,SAAS,GAAG,CAAC;AAAA,UACtB,CAAC,QAAQ,MAAM,GAAG;AAAA,UAClB,CAAC,QAAQ,SAAS,GAAG;AAAA,QACvB;AAAA,QACA;AAAA,MACF;AAAA,MACC,GAAG;AAAA,MAEH;AAAA,IAAA;AAAA,EAEL,EAAA,CAAA;AAGK,SAAA;AACT;"}
@@ -1 +1 @@
1
- {"version":3,"file":"VerticalNavigationContext.js","sources":["../../../src/VerticalNavigation/VerticalNavigationContext.tsx"],"sourcesContent":["import { createContext } from \"react\";\n\nexport type NavigationData<T extends React.ElementType = \"a\"> =\n React.ComponentProps<T> &\n Record<string, any> & {\n /** The id to be applied to the root element. */\n id: string;\n /** The label to be rendered on the menu item. */\n label: string;\n /** The icon to be rendered. */\n icon?: React.ReactNode;\n /** The Data children subset. */\n data?: NavigationData<T>[];\n /** Whether the item is disabled and not interactive. */\n disabled?: boolean;\n /** Whether the item has a selected state. */\n selectable?: boolean;\n };\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":[],"mappings":";AAwCA,MAAM,4BAA4B;AAAA,EAChC;AAAA,IACE,QAAQ;AAAA,IACR,UAAU;AAAA,IACV,QAAQ;AAAA,EACV;AACF;"}
1
+ {"version":3,"file":"VerticalNavigationContext.js","sources":["../../../src/VerticalNavigation/VerticalNavigationContext.tsx"],"sourcesContent":["import { createContext } from \"react\";\n\nexport type NavigationData<T extends React.ElementType = \"a\"> =\n React.ComponentProps<T> &\n Record<string, any> & {\n /** The id to be applied to the root element. */\n id: string;\n /** The label to be rendered on the menu item. */\n label: string;\n /** The icon to be rendered. */\n icon?: React.ReactNode;\n /** The Data children subset. */\n data?: NavigationData<T>[];\n /** Whether the item is disabled and not interactive. */\n disabled?: boolean;\n /** Whether the item has a selected state. */\n selectable?: boolean;\n };\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?: any;\n setParentItem?: React.Dispatch<React.SetStateAction<any>>;\n withParentData?: any;\n navigateToChildHandler?: (event: any, item: any) => void;\n navigateToParentHandler?: () => void;\n\n parentData?: NavigationData[];\n setParentData?: React.Dispatch<React.SetStateAction<any>>;\n parentSelected?: any;\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":[],"mappings":";AAwCA,MAAM,4BAA4B;AAAA,EAChC;AAAA,IACE,QAAQ;AAAA,IACR,UAAU;AAAA,IACV,QAAQ;AAAA,EACV;AACF;"}
@@ -1 +1 @@
1
- {"version":3,"file":"withTooltip.js","sources":["../../../src/hocs/withTooltip.tsx"],"sourcesContent":["import { useState } from \"react\";\n\nimport { HvTooltip, HvTooltipPlacementType, HvTooltipProps } from \"../Tooltip\";\nimport { HvBaseProps } from \"../types/generic\";\n\nconst styles: { truncate: React.CSSProperties } = {\n truncate: {\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n whiteSpace: \"nowrap\",\n },\n};\n\nexport const withTooltip =\n (\n Component: React.FunctionComponent,\n // eslint-disable-next-line @typescript-eslint/default-param-last\n label = \"\",\n placement: HvTooltipPlacementType,\n hideTooltip?: (event: React.MouseEvent<HTMLDivElement>) => boolean,\n tooltipProps?: Partial<HvTooltipProps>,\n tooltipContainerProps?: HvBaseProps,\n ) =>\n (props) => {\n const [isHoverDisabled, setIsHoverDisabled] = useState<boolean | undefined>(\n false,\n );\n const [open, setOpen] = useState<boolean>(false);\n\n const handleMouseEnter = (event: React.MouseEvent<HTMLDivElement>) => {\n const isHidden = hideTooltip?.(event);\n setIsHoverDisabled(isHidden);\n setOpen(!isHidden);\n };\n\n const handleMouseLeave = () => {\n setIsHoverDisabled(false);\n setOpen(false);\n };\n\n return (\n <HvTooltip\n style={{ ...styles.truncate }}\n disableHoverListener={isHoverDisabled}\n disableFocusListener\n disableTouchListener\n title={label}\n open={open}\n placement={placement}\n {...tooltipProps}\n >\n <div\n {...tooltipContainerProps}\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleMouseLeave}\n >\n <Component {...props} />\n </div>\n </HvTooltip>\n );\n };\n"],"names":[],"mappings":";;;AAKA,MAAM,SAA4C;AAAA,EAChD,UAAU;AAAA,IACR,UAAU;AAAA,IACV,cAAc;AAAA,IACd,YAAY;AAAA,EACd;AACF;AAEa,MAAA,cACX,CACE,WAEA,QAAQ,IACR,WACA,aACA,cACA,0BAEF,CAAC,UAAU;AACH,QAAA,CAAC,iBAAiB,kBAAkB,IAAI;AAAA,IAC5C;AAAA,EAAA;AAEF,QAAM,CAAC,MAAM,OAAO,IAAI,SAAkB,KAAK;AAEzC,QAAA,mBAAmB,CAAC,UAA4C;AAC9D,UAAA,WAAW,cAAc,KAAK;AACpC,uBAAmB,QAAQ;AAC3B,YAAQ,CAAC,QAAQ;AAAA,EAAA;AAGnB,QAAM,mBAAmB,MAAM;AAC7B,uBAAmB,KAAK;AACxB,YAAQ,KAAK;AAAA,EAAA;AAIb,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,OAAO,EAAE,GAAG,OAAO,SAAS;AAAA,MAC5B,sBAAsB;AAAA,MACtB,sBAAoB;AAAA,MACpB,sBAAoB;AAAA,MACpB,OAAO;AAAA,MACP;AAAA,MACA;AAAA,MACC,GAAG;AAAA,MAEJ,UAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UACE,GAAG;AAAA,UACJ,cAAc;AAAA,UACd,cAAc;AAAA,UAEd,UAAA,oBAAC,WAAW,EAAA,GAAG,MAAO,CAAA;AAAA,QAAA;AAAA,MACxB;AAAA,IAAA;AAAA,EAAA;AAGN;"}
1
+ {"version":3,"file":"withTooltip.js","sources":["../../../src/hocs/withTooltip.tsx"],"sourcesContent":["import { useState } from \"react\";\n\nimport { HvTooltip, HvTooltipPlacementType, HvTooltipProps } from \"../Tooltip\";\nimport { HvBaseProps } from \"../types/generic\";\n\nconst styles: { truncate: React.CSSProperties } = {\n truncate: {\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n whiteSpace: \"nowrap\",\n },\n};\n\nexport const withTooltip =\n (\n Component: React.FunctionComponent,\n // eslint-disable-next-line @typescript-eslint/default-param-last\n label = \"\",\n placement: HvTooltipPlacementType,\n hideTooltip?: (event: React.MouseEvent<HTMLDivElement>) => boolean,\n tooltipProps?: Partial<HvTooltipProps>,\n tooltipContainerProps?: HvBaseProps,\n ) =>\n (props: any) => {\n const [isHoverDisabled, setIsHoverDisabled] = useState<boolean | undefined>(\n false,\n );\n const [open, setOpen] = useState<boolean>(false);\n\n const handleMouseEnter = (event: React.MouseEvent<HTMLDivElement>) => {\n const isHidden = hideTooltip?.(event);\n setIsHoverDisabled(isHidden);\n setOpen(!isHidden);\n };\n\n const handleMouseLeave = () => {\n setIsHoverDisabled(false);\n setOpen(false);\n };\n\n return (\n <HvTooltip\n style={{ ...styles.truncate }}\n disableHoverListener={isHoverDisabled}\n disableFocusListener\n disableTouchListener\n title={label}\n open={open}\n placement={placement}\n {...tooltipProps}\n >\n <div\n {...tooltipContainerProps}\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleMouseLeave}\n >\n <Component {...props} />\n </div>\n </HvTooltip>\n );\n };\n"],"names":[],"mappings":";;;AAKA,MAAM,SAA4C;AAAA,EAChD,UAAU;AAAA,IACR,UAAU;AAAA,IACV,cAAc;AAAA,IACd,YAAY;AAAA,EACd;AACF;AAEa,MAAA,cACX,CACE,WAEA,QAAQ,IACR,WACA,aACA,cACA,0BAEF,CAAC,UAAe;AACR,QAAA,CAAC,iBAAiB,kBAAkB,IAAI;AAAA,IAC5C;AAAA,EAAA;AAEF,QAAM,CAAC,MAAM,OAAO,IAAI,SAAkB,KAAK;AAEzC,QAAA,mBAAmB,CAAC,UAA4C;AAC9D,UAAA,WAAW,cAAc,KAAK;AACpC,uBAAmB,QAAQ;AAC3B,YAAQ,CAAC,QAAQ;AAAA,EAAA;AAGnB,QAAM,mBAAmB,MAAM;AAC7B,uBAAmB,KAAK;AACxB,YAAQ,KAAK;AAAA,EAAA;AAIb,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,OAAO,EAAE,GAAG,OAAO,SAAS;AAAA,MAC5B,sBAAsB;AAAA,MACtB,sBAAoB;AAAA,MACpB,sBAAoB;AAAA,MACpB,OAAO;AAAA,MACP;AAAA,MACA;AAAA,MACC,GAAG;AAAA,MAEJ,UAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UACE,GAAG;AAAA,UACJ,cAAc;AAAA,UACd,cAAc;AAAA,UAEd,UAAA,oBAAC,WAAW,EAAA,GAAG,MAAO,CAAA;AAAA,QAAA;AAAA,MACxB;AAAA,IAAA;AAAA,EAAA;AAGN;"}
@@ -1 +1 @@
1
- {"version":3,"file":"useComputation.js","sources":["../../../src/hooks/useComputation.ts"],"sourcesContent":["import { useRef, useState } from \"react\";\n\nexport const useComputation = (valueFn, valueFallback?) => {\n const computed = useRef<any>(null);\n const [value, setValue] = useState(valueFallback);\n\n const computeValue = () => {\n if (!computed.current) {\n setValue(valueFn?.());\n computed.current = true;\n }\n };\n\n return [value, computeValue];\n};\n"],"names":[],"mappings":";AAEa,MAAA,iBAAiB,CAAC,SAAS,kBAAmB;AACnD,QAAA,WAAW,OAAY,IAAI;AACjC,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAS,aAAa;AAEhD,QAAM,eAAe,MAAM;AACrB,QAAA,CAAC,SAAS,SAAS;AACrB,eAAS,WAAW;AACpB,eAAS,UAAU;AAAA,IACrB;AAAA,EAAA;AAGK,SAAA,CAAC,OAAO,YAAY;AAC7B;"}
1
+ {"version":3,"file":"useComputation.js","sources":["../../../src/hooks/useComputation.ts"],"sourcesContent":["import { useRef, useState } from \"react\";\n\nexport const useComputation = (valueFn: Function, valueFallback?: Function) => {\n const computed = useRef<any>(null);\n const [value, setValue] = useState(valueFallback);\n\n const computeValue = () => {\n if (!computed.current) {\n setValue(valueFn?.());\n computed.current = true;\n }\n };\n\n return [value, computeValue];\n};\n"],"names":[],"mappings":";AAEa,MAAA,iBAAiB,CAAC,SAAmB,kBAA6B;AACvE,QAAA,WAAW,OAAY,IAAI;AACjC,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAS,aAAa;AAEhD,QAAM,eAAe,MAAM;AACrB,QAAA,CAAC,SAAS,SAAS;AACrB,eAAS,WAAW;AACpB,eAAS,UAAU;AAAA,IACrB;AAAA,EAAA;AAGK,SAAA,CAAC,OAAO,YAAY;AAC7B;"}
@@ -1 +1 @@
1
- {"version":3,"file":"useCss.js","sources":["../../../src/hooks/useCss.ts"],"sourcesContent":["import { useMemo } from \"react\";\nimport { EmotionCache, css as emotionCss } from \"@emotion/css\";\nimport { RegisteredCache, serializeStyles } from \"@emotion/serialize\";\nimport { getRegisteredStyles, insertStyles } from \"@emotion/utils\";\nimport clsx from \"clsx\";\n\nimport { useEmotionCache } from \"./useEmotionCache\";\n\ntype CSS = typeof emotionCss;\n\nfunction getRef(args: any[]) {\n if (args.length !== 1) {\n return { args, ref: undefined };\n }\n\n const [arg] = args;\n\n if (!(arg instanceof Object)) {\n return { args, ref: undefined };\n }\n\n if (!(\"ref\" in arg)) {\n return { args, ref: undefined };\n }\n\n const { ref, ...argCopy } = arg;\n return { args: [argCopy], ref };\n}\n\nconst cssFactory = (() => {\n function merge(registered: RegisteredCache, css: CSS, className: string) {\n const registeredStyles: string[] = [];\n\n const rawClassName = getRegisteredStyles(\n registered,\n registeredStyles,\n className,\n );\n\n if (registeredStyles.length < 2) {\n return className;\n }\n\n return rawClassName + css(registeredStyles);\n }\n\n function innerCssFactory(cache: EmotionCache) {\n const css: CSS = (...styles: any) => {\n const { ref, args } = getRef(styles);\n const serialized = serializeStyles(args, cache.registered);\n insertStyles(cache, serialized, false);\n return `${cache.key}-${serialized.name}${\n ref === undefined ? \"\" : ` ${ref}`\n }`;\n };\n\n const cx = (...args: any) => merge(cache.registered, css, clsx(args));\n\n return { css, cx };\n }\n\n return innerCssFactory;\n})();\n\nexport function useCss() {\n const cache = useEmotionCache();\n return useMemo(() => cssFactory(cache), [cache]);\n}\n"],"names":[],"mappings":";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"react\";\nimport type { EmotionCache } from \"@emotion/cache\";\nimport { css as emotionCss } from \"@emotion/css\";\nimport { RegisteredCache, serializeStyles } from \"@emotion/serialize\";\nimport { getRegisteredStyles, insertStyles } from \"@emotion/utils\";\nimport clsx from \"clsx\";\n\nimport { useEmotionCache } from \"./useEmotionCache\";\n\ntype CSS = typeof emotionCss;\n\nfunction getRef(args: any[]) {\n if (args.length !== 1) {\n return { args, ref: undefined };\n }\n\n const [arg] = args;\n\n if (!(arg instanceof Object)) {\n return { args, ref: undefined };\n }\n\n if (!(\"ref\" in arg)) {\n return { args, ref: undefined };\n }\n\n const { ref, ...argCopy } = arg;\n return { args: [argCopy], ref };\n}\n\nconst cssFactory = (() => {\n function merge(registered: RegisteredCache, css: CSS, className: string) {\n const registeredStyles: string[] = [];\n\n const rawClassName = getRegisteredStyles(\n registered,\n registeredStyles,\n className,\n );\n\n if (registeredStyles.length < 2) {\n return className;\n }\n\n return rawClassName + css(registeredStyles);\n }\n\n function innerCssFactory(cache: EmotionCache) {\n const css: CSS = (...styles: any) => {\n const { ref, args } = getRef(styles);\n const serialized = serializeStyles(args, cache.registered);\n insertStyles(cache, serialized, false);\n return `${cache.key}-${serialized.name}${\n ref === undefined ? \"\" : ` ${ref}`\n }`;\n };\n\n const cx = (...args: any) => merge(cache.registered, css, clsx(args));\n\n return { css, cx };\n }\n\n return innerCssFactory;\n})();\n\nexport function useCss() {\n const cache = useEmotionCache();\n return useMemo(() => cssFactory(cache), [cache]);\n}\n"],"names":[],"mappings":";;;;;AAWA,SAAS,OAAO,MAAa;AACvB,MAAA,KAAK,WAAW,GAAG;AACd,WAAA,EAAE,MAAM,KAAK,OAAU;AAAA,EAChC;AAEM,QAAA,CAAC,GAAG,IAAI;AAEV,MAAA,EAAE,eAAe,SAAS;AACrB,WAAA,EAAE,MAAM,KAAK,OAAU;AAAA,EAChC;AAEI,MAAA,EAAE,SAAS,MAAM;AACZ,WAAA,EAAE,MAAM,KAAK,OAAU;AAAA,EAChC;AAEA,QAAM,EAAE,KAAK,GAAG,QAAA,IAAY;AAC5B,SAAO,EAAE,MAAM,CAAC,OAAO,GAAG,IAAI;AAChC;AAEA,MAAM,aAAoB,uBAAA;AACf,WAAA,MAAM,YAA6B,KAAU,WAAmB;AACvE,UAAM,mBAA6B,CAAA;AAEnC,UAAM,eAAe;AAAA,MACnB;AAAA,MACA;AAAA,MACA;AAAA,IAAA;AAGE,QAAA,iBAAiB,SAAS,GAAG;AACxB,aAAA;AAAA,IACT;AAEO,WAAA,eAAe,IAAI,gBAAgB;AAAA,EAC5C;AAEA,WAAS,gBAAgB,OAAqB;AACtC,UAAA,MAAW,IAAI,WAAgB;AACnC,YAAM,EAAE,KAAK,KAAK,IAAI,OAAO,MAAM;AACnC,YAAM,aAAa,gBAAgB,MAAM,MAAM,UAAU;AAC5C,mBAAA,OAAO,YAAY,KAAK;AACrC,aAAO,GAAG,MAAM,GAAG,IAAI,WAAW,IAAI,GACpC,QAAQ,SAAY,KAAK,IAAI,GAAG,EAClC;AAAA,IAAA;AAGI,UAAA,KAAK,IAAI,SAAc,MAAM,MAAM,YAAY,KAAK,KAAK,IAAI,CAAC;AAE7D,WAAA,EAAE,KAAK;EAChB;AAEO,SAAA;AACT;AAEO,SAAS,SAAS;AACvB,QAAM,QAAQ;AACd,SAAO,QAAQ,MAAM,WAAW,KAAK,GAAG,CAAC,KAAK,CAAC;AACjD;"}
@@ -1 +1 @@
1
- {"version":3,"file":"useForkRef.js","sources":["../../../src/hooks/useForkRef.ts"],"sourcesContent":["// copied from https://github.com/mui-org/material-ui/blob/03bd73be34424cb2cd17ac602def9ad2b9642de4/packages/material-ui-utils/src/useForkRef.js\nimport * as React from \"react\";\n\nconst setRef = (ref, value) => {\n if (typeof ref === \"function\") {\n ref(value);\n } else if (ref) {\n ref.current = value;\n }\n};\n\nexport const useForkRef = (refA, refB) => {\n /**\n * This will create a new function if the ref props change and are defined.\n * This means react will call the old forkRef with `null` and the new forkRef\n * with the ref. Cleanup naturally emerges from this behavior.\n */\n return React.useMemo(() => {\n if (refA == null && refB == null) {\n return null;\n }\n return (refValue) => {\n setRef(refA, refValue);\n setRef(refB, refValue);\n };\n }, [refA, refB]);\n};\n"],"names":[],"mappings":";AAGA,MAAM,SAAS,CAAC,KAAK,UAAU;AACzB,MAAA,OAAO,QAAQ,YAAY;AAC7B,QAAI,KAAK;AAAA,aACA,KAAK;AACd,QAAI,UAAU;AAAA,EAChB;AACF;AAEa,MAAA,aAAa,CAAC,MAAM,SAAS;AAMjC,SAAA,MAAM,QAAQ,MAAM;AACrB,QAAA,QAAQ,QAAQ,QAAQ,MAAM;AACzB,aAAA;AAAA,IACT;AACA,WAAO,CAAC,aAAa;AACnB,aAAO,MAAM,QAAQ;AACrB,aAAO,MAAM,QAAQ;AAAA,IAAA;AAAA,EACvB,GACC,CAAC,MAAM,IAAI,CAAC;AACjB;"}
1
+ {"version":3,"file":"useForkRef.js","sources":["../../../src/hooks/useForkRef.ts"],"sourcesContent":["// copied from https://github.com/mui-org/material-ui/blob/03bd73be34424cb2cd17ac602def9ad2b9642de4/packages/material-ui-utils/src/useForkRef.js\nimport * as React from \"react\";\n\nconst setRef = (ref: any, value: any) => {\n if (typeof ref === \"function\") {\n ref(value);\n } else if (ref) {\n ref.current = value;\n }\n};\n\nexport const useForkRef = (refA: any, refB: any) => {\n /**\n * This will create a new function if the ref props change and are defined.\n * This means react will call the old forkRef with `null` and the new forkRef\n * with the ref. Cleanup naturally emerges from this behavior.\n */\n return React.useMemo(() => {\n if (refA == null && refB == null) {\n return null;\n }\n return (refValue: any) => {\n setRef(refA, refValue);\n setRef(refB, refValue);\n };\n }, [refA, refB]);\n};\n"],"names":[],"mappings":";AAGA,MAAM,SAAS,CAAC,KAAU,UAAe;AACnC,MAAA,OAAO,QAAQ,YAAY;AAC7B,QAAI,KAAK;AAAA,aACA,KAAK;AACd,QAAI,UAAU;AAAA,EAChB;AACF;AAEa,MAAA,aAAa,CAAC,MAAW,SAAc;AAM3C,SAAA,MAAM,QAAQ,MAAM;AACrB,QAAA,QAAQ,QAAQ,QAAQ,MAAM;AACzB,aAAA;AAAA,IACT;AACA,WAAO,CAAC,aAAkB;AACxB,aAAO,MAAM,QAAQ;AACrB,aAAO,MAAM,QAAQ;AAAA,IAAA;AAAA,EACvB,GACC,CAAC,MAAM,IAAI,CAAC;AACjB;"}
@@ -4,8 +4,7 @@ let count = 0;
4
4
  const useUniqueId = (deterministicId, idPrefix) => {
5
5
  const [id, setId] = React.useState(useReactId());
6
6
  React.useLayoutEffect(() => {
7
- if (!deterministicId)
8
- setId((reactId) => reactId ?? String(count++));
7
+ if (!deterministicId) setId((reactId) => reactId ?? String(count++));
9
8
  }, [deterministicId, idPrefix]);
10
9
  return deterministicId || (idPrefix ? idPrefix + id : id ?? "");
11
10
  };
@@ -1 +1 @@
1
- {"version":3,"file":"useUniqueId.js","sources":["../../../src/hooks/useUniqueId.ts"],"sourcesContent":["import * as React from \"react\"; // this can be optimized when react 17 support is dropped\n\n/** Credit: https://github.com/radix-ui/primitives/blob/main/packages/react/id/src/id.tsx\n * Modified slightly to suit our purposes.\n */\n// We `toString()` to prevent bundlers from trying to `import { useId } from 'react';`\nconst useReactId = (React as any)[\"useId\".toString()] || (() => undefined);\nlet count = 0;\n\nexport const useUniqueId = (\n deterministicId?: string,\n /**\n * @deprecated\n * Users should pick between a fully deterministic or fully generated id\n * @example\n * useUniqueId(setId(idPrefix, deterministicId))\n * */\n idPrefix?: string,\n): string => {\n const [id, setId] = React.useState<string | undefined>(useReactId());\n\n React.useLayoutEffect(() => {\n // eslint-disable-next-line no-plusplus\n if (!deterministicId) setId((reactId) => reactId ?? String(count++));\n }, [deterministicId, idPrefix]);\n\n return deterministicId || (idPrefix ? idPrefix + id : id ?? \"\");\n};\n"],"names":[],"mappings":";AAMA,MAAM,aAAc,MAAc,QAAQ,SAAU,CAAA,MAAM,MAAM;AAChE,IAAI,QAAQ;AAEC,MAAA,cAAc,CACzB,iBAOA,aACW;AACX,QAAM,CAAC,IAAI,KAAK,IAAI,MAAM,SAA6B,YAAY;AAEnE,QAAM,gBAAgB,MAAM;AAE1B,QAAI,CAAC;AAAiB,YAAM,CAAC,YAAY,WAAW,OAAO,OAAO,CAAC;AAAA,EAAA,GAClE,CAAC,iBAAiB,QAAQ,CAAC;AAE9B,SAAO,oBAAoB,WAAW,WAAW,KAAK,MAAM;AAC9D;"}
1
+ {"version":3,"file":"useUniqueId.js","sources":["../../../src/hooks/useUniqueId.ts"],"sourcesContent":["import * as React from \"react\"; // this can be optimized when react 17 support is dropped\n\n/** Credit: https://github.com/radix-ui/primitives/blob/main/packages/react/id/src/id.tsx\n * Modified slightly to suit our purposes.\n */\n// We `toString()` to prevent bundlers from trying to `import { useId } from 'react';`\nconst useReactId = (React as any)[\"useId\".toString()] || (() => undefined);\nlet count = 0;\n\nexport const useUniqueId = (\n deterministicId?: string,\n /**\n * @deprecated\n * Users should pick between a fully deterministic or fully generated id\n * @example\n * useUniqueId(setId(idPrefix, deterministicId))\n * */\n idPrefix?: string,\n): string => {\n const [id, setId] = React.useState<string | undefined>(useReactId());\n\n React.useLayoutEffect(() => {\n // eslint-disable-next-line no-plusplus\n if (!deterministicId) setId((reactId) => reactId ?? String(count++));\n }, [deterministicId, idPrefix]);\n\n return deterministicId || (idPrefix ? idPrefix + id : (id ?? \"\"));\n};\n"],"names":[],"mappings":";AAMA,MAAM,aAAc,MAAc,QAAQ,SAAU,CAAA,MAAM,MAAM;AAChE,IAAI,QAAQ;AAEC,MAAA,cAAc,CACzB,iBAOA,aACW;AACX,QAAM,CAAC,IAAI,KAAK,IAAI,MAAM,SAA6B,YAAY;AAEnE,QAAM,gBAAgB,MAAM;AAEtB,QAAA,CAAC,gBAAuB,OAAA,CAAC,YAAY,WAAW,OAAO,OAAO,CAAC;AAAA,EAAA,GAClE,CAAC,iBAAiB,QAAQ,CAAC;AAE9B,SAAO,oBAAoB,WAAW,WAAW,KAAM,MAAM;AAC/D;"}
@@ -24,10 +24,8 @@ const HvProvider = ({
24
24
  const scopedRootId = `${scopedRootPrefix}-${generatedId}`;
25
25
  const themesList = processThemes(themes);
26
26
  const emotionCache = useMemo(() => {
27
- if (emotionCacheProp)
28
- return emotionCacheProp;
29
- if (classNameKey === defaultCacheKey)
30
- return defaultEmotionCache;
27
+ if (emotionCacheProp) return emotionCacheProp;
28
+ if (classNameKey === defaultCacheKey) return defaultEmotionCache;
31
29
  return createCache({ key: classNameKey, prepend: true });
32
30
  }, [classNameKey, emotionCacheProp]);
33
31
  return /* @__PURE__ */ jsxs(CacheProvider, { value: emotionCache, children: [
@@ -1 +1 @@
1
- {"version":3,"file":"Provider.js","sources":["../../../src/providers/Provider.tsx"],"sourcesContent":["import { useMemo } from \"react\";\nimport createCache, { EmotionCache } from \"@emotion/cache\";\nimport {\n CacheProvider,\n ClassNames,\n css as cssReact,\n Global,\n} from \"@emotion/react\";\nimport {\n CssBaseline,\n CssScopedBaseline,\n getThemesVars,\n HvThemeStructure,\n} from \"@hitachivantara/uikit-styles\";\n\nimport { useUniqueId } from \"../hooks/useUniqueId\";\nimport { HvTheme } from \"../types/theme\";\nimport { getElementById } from \"../utils/document\";\nimport { processThemes } from \"../utils/theme\";\nimport {\n defaultCacheKey,\n defaultEmotionCache,\n HvThemeProvider,\n} from \"./ThemeProvider\";\n\n// Provider props\nexport interface HvProviderProps {\n /**\n * Your component tree.\n */\n children?: React.ReactNode;\n /**\n * Id of your root element.\n */\n rootElementId?: string;\n /**\n * By default the baseline styles are applied globally, `global`, to the application for the UI Kit components to work properly.\n * If you need to scope the baseline styles to avoid styling conflicts, you can set this property to `scoped`.\n * To scope the baseline to your root, you need to add the `rootElementId` property.\n * If the `rootElementId` property is not set, the baseline will be scoped to a new container, `hv-uikit-scoped-root*`, created around your content.\n * If you are providing your own baseline styles, you can set this property to `none` to disable the baseline styles.\n */\n cssBaseline?: \"global\" | \"scoped\" | \"none\";\n /**\n * By default the theme styles are applied globally, `global`, to the application.\n * If you need to scope the theme styles to avoid styling conflicts, you can set this property to `scoped`.\n * To scope the theme to your root, you need to add the `rootElementId` property.\n * If the `rootElementId` property is not set, the theme will be scoped to a new container, `hv-uikit-scoped-root*`, created around your content.\n */\n cssTheme?: \"global\" | \"scoped\";\n /**\n * The string used to prefix the class names and uniquely identify them. The key can only contain lower case alphabetical characters.\n * This is useful to avoid class name collisions.\n *\n * If `emotionCache` is passed, this is value is ignored.\n *\n * @default \"hv\"\n */\n classNameKey?: string;\n /**\n * The emotion cache instance to use. If no value is provided, the default cache is used.\n */\n emotionCache?: EmotionCache;\n /**\n * List of themes to be used by UI Kit.\n * You can provide your own themes created with the `createTheme` utility and/or the default themes `ds3` and `ds5` provided by UI Kit.\n *\n * If no value is provided, the `ds5` theme will be used.\n */\n themes?: (HvTheme | HvThemeStructure)[];\n /**\n * The active theme. It must be one of the themes passed to `themes`.\n *\n * If no value is provided, the first theme from the `themes` list is used. If no `themes` list is provided, the `ds5` theme will be used.\n */\n theme?: string;\n /**\n * The active color mode. It must be one of the color modes of the active theme.\n *\n * If no value is provided, the first color mode defined in the active theme is used.\n * For the default themes `ds3` and `ds5`, the `dawn` color mode is the one used.\n */\n colorMode?: string;\n}\n\nconst scopedRootPrefix = \"hv-uikit-scoped-root\" as const;\n\n/**\n * Enables theming capabilities and makes cross-component theme properties available down the tree.\n */\nexport const HvProvider = ({\n children,\n rootElementId,\n cssBaseline = \"global\",\n cssTheme = \"global\",\n themes,\n theme,\n colorMode,\n emotionCache: emotionCacheProp,\n classNameKey = defaultCacheKey,\n}: HvProviderProps) => {\n const generatedId = useUniqueId();\n const scopedRootId = `${scopedRootPrefix}-${generatedId}`;\n\n // Themes\n const themesList = processThemes(themes);\n\n // Emotion cache\n // Moves UI Kit styles to the top of the <head> so they're loaded first\n // This enables users to override the UI Kit styles if necessary\n const emotionCache = useMemo(() => {\n if (emotionCacheProp) return emotionCacheProp;\n // reuse the default shared cache if `classNameKey` is the same\n if (classNameKey === defaultCacheKey) return defaultEmotionCache;\n\n return createCache({ key: classNameKey, prepend: true });\n }, [classNameKey, emotionCacheProp]);\n\n return (\n <CacheProvider value={emotionCache}>\n <Global\n styles={cssReact`\n ${\n cssBaseline === \"global\" && {\n [`@layer hv-uikit-baseline`]: {\n ...CssBaseline,\n },\n }\n }\n ${getThemesVars(themesList)}\n `}\n />\n <HvThemeProvider\n themes={themesList}\n theme={theme || themesList[0].name}\n emotionCache={emotionCache}\n colorMode={colorMode || Object.keys(themesList[0].colors.modes)[0]}\n themeRootId={\n cssTheme === \"scoped\" ? rootElementId || scopedRootId : undefined\n }\n >\n <ClassNames>\n {({ css }) => {\n if (cssBaseline === \"scoped\") {\n const rootElement = getElementById(rootElementId);\n\n if (rootElement) {\n rootElement.classList.add(\n css({\n [`@layer ${rootElementId}-baseline`]: {\n ...CssScopedBaseline,\n },\n }),\n );\n }\n }\n\n return (cssTheme === \"scoped\" || cssBaseline === \"scoped\") &&\n !rootElementId ? (\n <div\n id={scopedRootId}\n className={\n cssBaseline === \"scoped\"\n ? css({\n [`@layer ${rootElementId}-baseline`]: {\n ...CssScopedBaseline,\n },\n })\n : undefined\n }\n >\n {children}\n </div>\n ) : (\n children\n );\n }}\n </ClassNames>\n </HvThemeProvider>\n </CacheProvider>\n );\n};\n"],"names":["cssReact","css"],"mappings":";;;;;;;;;;AAqFA,MAAM,mBAAmB;AAKlB,MAAM,aAAa,CAAC;AAAA,EACzB;AAAA,EACA;AAAA,EACA,cAAc;AAAA,EACd,WAAW;AAAA,EACX;AAAA,EACA;AAAA,EACA;AAAA,EACA,cAAc;AAAA,EACd,eAAe;AACjB,MAAuB;AACrB,QAAM,cAAc;AACpB,QAAM,eAAe,GAAG,gBAAgB,IAAI,WAAW;AAGjD,QAAA,aAAa,cAAc,MAAM;AAKjC,QAAA,eAAe,QAAQ,MAAM;AAC7B,QAAA;AAAyB,aAAA;AAE7B,QAAI,iBAAiB;AAAwB,aAAA;AAE7C,WAAO,YAAY,EAAE,KAAK,cAAc,SAAS,MAAM;AAAA,EAAA,GACtD,C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"],"sourcesContent":["import { useMemo } from \"react\";\nimport createCache, { EmotionCache } from \"@emotion/cache\";\nimport {\n CacheProvider,\n ClassNames,\n css as cssReact,\n Global,\n} from \"@emotion/react\";\nimport {\n CssBaseline,\n CssScopedBaseline,\n getThemesVars,\n HvThemeStructure,\n} from \"@hitachivantara/uikit-styles\";\n\nimport { useUniqueId } from \"../hooks/useUniqueId\";\nimport { HvTheme } from \"../types/theme\";\nimport { getElementById } from \"../utils/document\";\nimport { processThemes } from \"../utils/theme\";\nimport {\n defaultCacheKey,\n defaultEmotionCache,\n HvThemeProvider,\n} from \"./ThemeProvider\";\n\n// Provider props\nexport interface HvProviderProps {\n /**\n * Your component tree.\n */\n children?: React.ReactNode;\n /**\n * Id of your root element.\n */\n rootElementId?: string;\n /**\n * By default the baseline styles are applied globally, `global`, to the application for the UI Kit components to work properly.\n * If you need to scope the baseline styles to avoid styling conflicts, you can set this property to `scoped`.\n * To scope the baseline to your root, you need to add the `rootElementId` property.\n * If the `rootElementId` property is not set, the baseline will be scoped to a new container, `hv-uikit-scoped-root*`, created around your content.\n * If you are providing your own baseline styles, you can set this property to `none` to disable the baseline styles.\n */\n cssBaseline?: \"global\" | \"scoped\" | \"none\";\n /**\n * By default the theme styles are applied globally, `global`, to the application.\n * If you need to scope the theme styles to avoid styling conflicts, you can set this property to `scoped`.\n * To scope the theme to your root, you need to add the `rootElementId` property.\n * If the `rootElementId` property is not set, the theme will be scoped to a new container, `hv-uikit-scoped-root*`, created around your content.\n */\n cssTheme?: \"global\" | \"scoped\";\n /**\n * The string used to prefix the class names and uniquely identify them. The key can only contain lower case alphabetical characters.\n * This is useful to avoid class name collisions.\n *\n * If `emotionCache` is passed, this is value is ignored.\n *\n * @default \"hv\"\n */\n classNameKey?: string;\n /**\n * The emotion cache instance to use. If no value is provided, the default cache is used.\n */\n emotionCache?: EmotionCache;\n /**\n * List of themes to be used by UI Kit.\n * You can provide your own themes created with the `createTheme` utility and/or the default themes `ds3` and `ds5` provided by UI Kit.\n *\n * If no value is provided, the `ds5` theme will be used.\n */\n themes?: (HvTheme | HvThemeStructure)[];\n /**\n * The active theme. It must be one of the themes passed to `themes`.\n *\n * If no value is provided, the first theme from the `themes` list is used. If no `themes` list is provided, the `ds5` theme will be used.\n */\n theme?: string;\n /**\n * The active color mode. It must be one of the color modes of the active theme.\n *\n * If no value is provided, the first color mode defined in the active theme is used.\n * For the default themes `ds3` and `ds5`, the `dawn` color mode is the one used.\n */\n colorMode?: string;\n}\n\nconst scopedRootPrefix = \"hv-uikit-scoped-root\" as const;\n\n/**\n * Enables theming capabilities and makes cross-component theme properties available down the tree.\n */\nexport const HvProvider = ({\n children,\n rootElementId,\n cssBaseline = \"global\",\n cssTheme = \"global\",\n themes,\n theme,\n colorMode,\n emotionCache: emotionCacheProp,\n classNameKey = defaultCacheKey,\n}: HvProviderProps) => {\n const generatedId = useUniqueId();\n const scopedRootId = `${scopedRootPrefix}-${generatedId}`;\n\n // Themes\n const themesList = processThemes(themes);\n\n // Emotion cache\n // Moves UI Kit styles to the top of the <head> so they're loaded first\n // This enables users to override the UI Kit styles if necessary\n const emotionCache = useMemo(() => {\n if (emotionCacheProp) return emotionCacheProp;\n // reuse the default shared cache if `classNameKey` is the same\n if (classNameKey === defaultCacheKey) return defaultEmotionCache;\n\n return createCache({ key: classNameKey, prepend: true });\n }, [classNameKey, emotionCacheProp]);\n\n return (\n <CacheProvider value={emotionCache}>\n <Global\n styles={cssReact`\n ${\n cssBaseline === \"global\" && {\n [`@layer hv-uikit-baseline`]: {\n ...CssBaseline,\n },\n }\n }\n ${getThemesVars(themesList)}\n `}\n />\n <HvThemeProvider\n themes={themesList}\n theme={theme || themesList[0].name}\n emotionCache={emotionCache}\n colorMode={colorMode || Object.keys(themesList[0].colors.modes)[0]}\n themeRootId={\n cssTheme === \"scoped\" ? rootElementId || scopedRootId : undefined\n }\n >\n <ClassNames>\n {({ css }) => {\n if (cssBaseline === \"scoped\") {\n const rootElement = getElementById(rootElementId);\n\n if (rootElement) {\n rootElement.classList.add(\n css({\n [`@layer ${rootElementId}-baseline`]: {\n ...CssScopedBaseline,\n },\n }),\n );\n }\n }\n\n return (cssTheme === \"scoped\" || cssBaseline === \"scoped\") &&\n !rootElementId ? (\n <div\n id={scopedRootId}\n className={\n cssBaseline === \"scoped\"\n ? css({\n [`@layer ${rootElementId}-baseline`]: {\n ...CssScopedBaseline,\n },\n })\n : undefined\n }\n >\n {children}\n </div>\n ) : (\n children\n );\n }}\n </ClassNames>\n </HvThemeProvider>\n </CacheProvider>\n );\n};\n"],"names":["cssReact","css"],"mappings":";;;;;;;;;;AAqFA,MAAM,mBAAmB;AAKlB,MAAM,aAAa,CAAC;AAAA,EACzB;AAAA,EACA;AAAA,EACA,cAAc;AAAA,EACd,WAAW;AAAA,EACX;AAAA,EACA;AAAA,EACA;AAAA,EACA,cAAc;AAAA,EACd,eAAe;AACjB,MAAuB;AACrB,QAAM,cAAc;AACpB,QAAM,eAAe,GAAG,gBAAgB,IAAI,WAAW;AAGjD,QAAA,aAAa,cAAc,MAAM;AAKjC,QAAA,eAAe,QAAQ,MAAM;AACjC,QAAI,iBAAyB,QAAA;AAEzB,QAAA,iBAAiB,gBAAwB,QAAA;AAE7C,WAAO,YAAY,EAAE,KAAK,cAAc,SAAS,MAAM;AAAA,EAAA,GACtD,CAAC,cAAc,gBAAgB,CAAC;AAGjC,SAAA,qBAAC,eAAc,EAAA,OAAO,cACpB,UAAA;AAAA,IAAA;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,QAAQA;AAAAA,YAEJ,gBAAgB,YAAY;AAAA,UAC1B,CAAC,0BAA0B,GAAG;AAAA,YAC5B,GAAG;AAAA,UACL;AAAA,QAAA,CAEJ;AAAA,YACE,cAAc,UAAU,CAAC;AAAA;AAAA,MAAA;AAAA,IAE/B;AAAA,IACA;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,QAAQ;AAAA,QACR,OAAO,SAAS,WAAW,CAAC,EAAE;AAAA,QAC9B;AAAA,QACA,WAAW,aAAa,OAAO,KAAK,WAAW,CAAC,EAAE,OAAO,KAAK,EAAE,CAAC;AAAA,QACjE,aACE,aAAa,WAAW,iBAAiB,eAAe;AAAA,QAG1D,UAAC,oBAAA,YAAA,EACE,UAAC,CAAA,EAAE,KAAAC,WAAU;AACZ,cAAI,gBAAgB,UAAU;AACtB,kBAAA,cAAc,eAAe,aAAa;AAEhD,gBAAI,aAAa;AACf,0BAAY,UAAU;AAAA,gBACpBA,KAAI;AAAA,kBACF,CAAC,UAAU,aAAa,WAAW,GAAG;AAAA,oBACpC,GAAG;AAAA,kBACL;AAAA,gBAAA,CACD;AAAA,cAAA;AAAA,YAEL;AAAA,UACF;AAEA,kBAAQ,aAAa,YAAY,gBAAgB,aAC/C,CAAC,gBACD;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,IAAI;AAAA,cACJ,WACE,gBAAgB,WACZA,KAAI;AAAA,gBACF,CAAC,UAAU,aAAa,WAAW,GAAG;AAAA,kBACpC,GAAG;AAAA,gBACL;AAAA,cACD,CAAA,IACD;AAAA,cAGL;AAAA,YAAA;AAAA,UAGH,IAAA;AAAA,QAAA,GAGN;AAAA,MAAA;AAAA,IACF;AAAA,EACF,EAAA,CAAA;AAEJ;"}
@@ -1 +1 @@
1
- {"version":3,"file":"generic.js","sources":["../../../src/types/generic.ts"],"sourcesContent":["import { forwardRef } from \"react\";\nimport type {\n HvExtraDeepProps,\n HvExtraProps,\n} from \"@hitachivantara/uikit-react-shared\";\n\nexport type { HvExtraProps, HvExtraDeepProps };\n\ntype AsProp<C extends React.ElementType> = {\n /** Custom element type to override the root component */\n component?: C;\n};\n\ntype PropsToOmit<C extends React.ElementType, P> = keyof (AsProp<C> & P);\n\n// Workaround to fix the use of Omit with ComponentPropsWithoutRef\n// Without this the event handlers return any instead of the type for the chosen element\ntype FixComponentProps<T> = T extends any ? T : never;\n\ntype PolymorphicComponent<\n C extends React.ElementType,\n Props = {},\n> = React.PropsWithChildren<Props & AsProp<C>> &\n FixComponentProps<\n Omit<React.ComponentPropsWithoutRef<C>, PropsToOmit<C, Props>>\n >;\n\nexport type PolymorphicRef<C extends React.ElementType> =\n React.ComponentPropsWithRef<C>[\"ref\"];\n\nexport type PolymorphicComponentRef<\n C extends React.ElementType,\n Props = {},\n> = PolymorphicComponent<C, Props> & { ref?: PolymorphicRef<C> };\n\n/** HV Base Props. Extends `React.HTMLAttributes` of an element `E`, and filters `K` keys. */\nexport type HvBaseProps<\n E extends HTMLElement = HTMLDivElement,\n K extends keyof React.HTMLAttributes<E> = never,\n> = Omit<React.HTMLAttributes<E>, K>;\n\n/** This type allows to do a deep partial by applying the Partial type to each key recursively */\nexport type DeepPartial<T> = T extends {}\n ? Partial<{\n [P in keyof T]: DeepPartial<T[P]>;\n }>\n : T;\n\n/** This type combines the HvExtraProps and DeepPartial types */\nexport type HvExtraDeepPartialProps<T> = Partial<{\n [P in keyof T]: DeepPartial<T[P]> & HvExtraProps;\n}> &\n HvExtraProps;\n\nexport type Arrayable<T> = T | T[];\n\n/** React.forwardRef with fixed type declarations */\nexport function fixedForwardRef<T, P = {}>(\n // TODO: change `React.ReactElement | null` to `React.ReactNode` in typescript@5\n render: (props: P, ref: React.Ref<T>) => React.ReactElement | null,\n): (props: P & React.RefAttributes<T>) => React.ReactElement | null {\n return forwardRef(render) as any;\n}\n\n// Source code from: https://github.com/piotrwitek/utility-types/blob/master/src/mapped-types.ts\n/**\n * Optional\n * @desc From `T` make a set of properties by key `K` become optional\n * @example\n * type Props = {\n * name: string;\n * age: number;\n * visible: boolean;\n * };\n *\n * // Expect: { name?: string; age?: number; visible?: boolean; }\n * type Props = Optional<Props>;\n *\n * // Expect: { name: string; age?: number; visible?: boolean; }\n * type Props = Optional<Props, 'age' | 'visible'>;\n */\nexport type HvOptional<T extends object, K extends keyof T = keyof T> = Omit<\n T,\n K\n> &\n Partial<Pick<T, K>>;\n"],"names":[],"mappings":";AAyDO,SAAS,gBAEd,QACkE;AAClE,SAAO,WAAW,MAAM;AAC1B;"}
1
+ {"version":3,"file":"generic.js","sources":["../../../src/types/generic.ts"],"sourcesContent":["import { forwardRef } from \"react\";\nimport type {\n HvExtraDeepProps,\n HvExtraProps,\n} from \"@hitachivantara/uikit-react-shared\";\n\nexport type { HvExtraProps, HvExtraDeepProps };\n\ntype AsProp<C extends React.ElementType> = {\n /** Custom element type to override the root component */\n component?: C;\n};\n\ntype PropsToOmit<C extends React.ElementType, P> = keyof (AsProp<C> & P);\n\n// Workaround to fix the use of Omit with ComponentPropsWithoutRef\n// Without this the event handlers return any instead of the type for the chosen element\ntype FixComponentProps<T> = T extends any ? T : never;\n\ntype PolymorphicComponent<\n C extends React.ElementType,\n Props = {},\n> = React.PropsWithChildren<Props & AsProp<C>> &\n FixComponentProps<\n Omit<React.ComponentPropsWithoutRef<C>, PropsToOmit<C, Props>>\n >;\n\nexport type PolymorphicRef<C extends React.ElementType> =\n React.ComponentPropsWithRef<C>[\"ref\"];\n\nexport type PolymorphicComponentRef<\n C extends React.ElementType,\n Props = {},\n> = PolymorphicComponent<C, Props> & { ref?: PolymorphicRef<C> };\n\n/** HV Base Props. Extends `React.HTMLAttributes` of an element `E`, and filters `K` keys. */\nexport type HvBaseProps<\n E extends HTMLElement = HTMLDivElement,\n K extends keyof React.HTMLAttributes<E> = never,\n> = Omit<React.HTMLAttributes<E>, K>;\n\n/** This type allows to do a deep partial by applying the Partial type to each key recursively */\nexport type DeepPartial<T> = T extends {}\n ? Partial<{\n [P in keyof T]: DeepPartial<T[P]>;\n }>\n : T;\n\n/** This type combines the HvExtraProps and DeepPartial types */\nexport type HvExtraDeepPartialProps<T> = Partial<{\n [P in keyof T]: DeepPartial<T[P]> & HvExtraProps;\n}> &\n HvExtraProps;\n\nexport type Arrayable<T> = T | T[];\n\n/** React.forwardRef with fixed type declarations */\nexport function fixedForwardRef<T, P = {}>(\n render: (props: P, ref: React.Ref<T>) => React.ReactNode,\n): (props: P & React.RefAttributes<T>) => React.ReactNode {\n return forwardRef(render) as any;\n}\n\n// Source code from: https://github.com/piotrwitek/utility-types/blob/master/src/mapped-types.ts\n/**\n * Optional\n * @desc From `T` make a set of properties by key `K` become optional\n * @example\n * type Props = {\n * name: string;\n * age: number;\n * visible: boolean;\n * };\n *\n * // Expect: { name?: string; age?: number; visible?: boolean; }\n * type Props = Optional<Props>;\n *\n * // Expect: { name: string; age?: number; visible?: boolean; }\n * type Props = Optional<Props, 'age' | 'visible'>;\n */\nexport type HvOptional<T extends object, K extends keyof T = keyof T> = Omit<\n T,\n K\n> &\n Partial<Pick<T, K>>;\n"],"names":[],"mappings":";AAyDO,SAAS,gBACd,QACwD;AACxD,SAAO,WAAW,MAAM;AAC1B;"}
@@ -20,8 +20,7 @@ const deepRenameKeys = (obj, mapFn) => {
20
20
  const replace$ = (stylesObj, name) => {
21
21
  return deepRenameKeys(stylesObj, (key) => {
22
22
  const matches = key.match(/\$\w+/g);
23
- if (!matches?.length)
24
- return key;
23
+ if (!matches?.length) return key;
25
24
  const newKey = matches.reduce(
26
25
  (acc, match) => acc.replace(match, `.${name}-${match.slice(1)}`),
27
26
  key
@@ -34,7 +33,11 @@ function createClasses(name, stylesObject) {
34
33
  const staticClasses = getClasses(Object.keys(styles), name);
35
34
  function useClasses(classesProp = {}, addStatic = true) {
36
35
  const { cx, css } = useCss();
37
- const mergeClasses = (key) => cx(addStatic && `${name}-${key}`, css(styles[key]), classesProp?.[key]);
36
+ const mergeClasses = (key) => cx(
37
+ addStatic && `${name}-${key}`,
38
+ css(styles[key]),
39
+ classesProp?.[key]
40
+ );
38
41
  const classes = Object.fromEntries(
39
42
  Object.keys(styles).map((key) => [key, mergeClasses(key)])
40
43
  );
@@ -1 +1 @@
1
- {"version":3,"file":"classes.js","sources":["../../../src/utils/classes.ts"],"sourcesContent":["import type { CSSInterpolation } from \"@emotion/serialize\";\n\nimport { useCss } from \"../hooks/useCss\";\n\nexport type ExtractNames<\n T extends (...args: any) => { classes: Record<string, any>; cx: any },\n> = Partial<ReturnType<T>[\"classes\"]>;\n\nexport const getClasses = <T extends string, N extends string>(\n keys: T[],\n name: N,\n) => {\n const classesObj: Record<string, string> = {};\n keys.forEach((key: string) => {\n classesObj[key] = `${name}-${key}`;\n });\n return classesObj as { [P in T]: `${N}-${P}` };\n};\n\nconst deepRenameKeys = <T extends object>(\n obj: T,\n mapFn: (key: string) => string,\n): T => {\n const result: any = {};\n for (const key in obj) {\n if (Object.hasOwn(obj, key)) {\n const newKey = mapFn(key);\n const value = obj[key];\n result[newKey] =\n typeof value === \"object\" ? deepRenameKeys(value as any, mapFn) : value;\n }\n }\n return result;\n};\n\n/** Given a `stylesObj`, replaces its keys' `$myClass` with `.{name}-myClass`. */\nexport const replace$ = <T extends object>(stylesObj: T, name: string): T => {\n return deepRenameKeys(stylesObj, (key) => {\n const matches = key.match(/\\$\\w+/g);\n if (!matches?.length) return key;\n const newKey = matches.reduce(\n (acc, match) => acc.replace(match, `.${name}-${match.slice(1)}`),\n key,\n );\n return newKey ?? key;\n });\n};\n\n/** Utility function to create classes for a component. */\nexport function createClasses<Name extends string, ClassName extends string>(\n /** Component name in PascalCase (ie. `HvTableCell`). */\n name: Name,\n stylesObject: Record<ClassName, CSSInterpolation>,\n) {\n const styles = replace$(stylesObject, name);\n\n const staticClasses = getClasses(Object.keys(styles) as ClassName[], name);\n\n /**\n * Hook that takes in a component's `classesProp` overrides, and returns the\n * concatenated static/internal/override `classes`, and the cached `cx` and `css` utilities.\n */\n function useClasses(\n classesProp: Partial<Record<ClassName, string>> = {},\n /** Whether to add the static classes. Disable when included by `classesProp` */\n addStatic = true,\n ) {\n const { cx, css } = useCss();\n\n const mergeClasses = (key: string) =>\n cx(addStatic && `${name}-${key}`, css(styles[key]), classesProp?.[key]);\n\n const classes = Object.fromEntries(\n Object.keys(styles).map((key) => [key, mergeClasses(key)]),\n ) as { [P in ClassName]: string };\n\n return { classes, css, cx };\n }\n\n return { useClasses, staticClasses };\n}\n"],"names":[],"mappings":";AAQa,MAAA,aAAa,CACxB,MACA,SAC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,WAAA,EAAE,SAAS,KAAK;EACzB;AAEO,SAAA,EAAE,YAAY;AACvB;"}
1
+ {"version":3,"file":"classes.js","sources":["../../../src/utils/classes.ts"],"sourcesContent":["import type { CSSInterpolation } from \"@emotion/serialize\";\n\nimport { useCss } from \"../hooks/useCss\";\n\nexport type ExtractNames<\n T extends (...args: any) => { classes: Record<string, any>; cx: any },\n> = Partial<ReturnType<T>[\"classes\"]>;\n\nexport const getClasses = <T extends string, N extends string>(\n keys: T[],\n name: N,\n) => {\n const classesObj: Record<string, string> = {};\n keys.forEach((key: string) => {\n classesObj[key] = `${name}-${key}`;\n });\n return classesObj as { [P in T]: `${N}-${P}` };\n};\n\nconst deepRenameKeys = <T extends object>(\n obj: T,\n mapFn: (key: string) => string,\n): T => {\n const result: any = {};\n for (const key in obj) {\n if (Object.hasOwn(obj, key)) {\n const newKey = mapFn(key);\n const value = obj[key];\n result[newKey] =\n typeof value === \"object\" ? deepRenameKeys(value as any, mapFn) : value;\n }\n }\n return result;\n};\n\n/** Given a `stylesObj`, replaces its keys' `$myClass` with `.{name}-myClass`. */\nexport const replace$ = <T extends object>(stylesObj: T, name: string): T => {\n return deepRenameKeys(stylesObj, (key) => {\n const matches = key.match(/\\$\\w+/g);\n if (!matches?.length) return key;\n const newKey = matches.reduce(\n (acc, match) => acc.replace(match, `.${name}-${match.slice(1)}`),\n key,\n );\n return newKey ?? key;\n });\n};\n\n/** Utility function to create classes for a component. */\nexport function createClasses<Name extends string, ClassName extends string>(\n /** Component name in PascalCase (ie. `HvTableCell`). */\n name: Name,\n stylesObject: Record<ClassName, CSSInterpolation>,\n) {\n const styles = replace$(stylesObject, name);\n\n const staticClasses = getClasses(Object.keys(styles) as ClassName[], name);\n\n /**\n * Hook that takes in a component's `classesProp` overrides, and returns the\n * concatenated static/internal/override `classes`, and the cached `cx` and `css` utilities.\n */\n function useClasses(\n classesProp: Partial<Record<ClassName, string>> = {},\n /** Whether to add the static classes. Disable when included by `classesProp` */\n addStatic = true,\n ) {\n const { cx, css } = useCss();\n\n const mergeClasses = (key: string) =>\n cx(\n addStatic && `${name}-${key}`,\n css(styles[key as keyof typeof styles]),\n classesProp?.[key as keyof typeof classesProp],\n );\n\n const classes = Object.fromEntries(\n Object.keys(styles).map((key) => [key, mergeClasses(key)]),\n ) as { [P in ClassName]: string };\n\n return { classes, css, cx };\n }\n\n return { useClasses, staticClasses };\n}\n"],"names":[],"mappings":";AAQa,MAAA,aAAa,CACxB,MACA,SACG;AACH,QAAM,aAAqC,CAAA;AACtC,OAAA,QAAQ,CAAC,QAAgB;AAC5B,eAAW,GAAG,IAAI,GAAG,IAAI,IAAI,GAAG;AAAA,EAAA,CACjC;AACM,SAAA;AACT;AAEA,MAAM,iBAAiB,CACrB,KACA,UACM;AACN,QAAM,SAAc,CAAA;AACpB,aAAW,OAAO,KAAK;AACrB,QAAI,OAAO,OAAO,KAAK,GAAG,GAAG;AACrB,YAAA,SAAS,MAAM,GAAG;AAClB,YAAA,QAAQ,IAAI,GAAG;AACd,aAAA,MAAM,IACX,OAAO,UAAU,WAAW,eAAe,OAAc,KAAK,IAAI;AAAA,IACtE;AAAA,EACF;AACO,SAAA;AACT;AAGa,MAAA,WAAW,CAAmB,WAAc,SAAoB;AACpE,SAAA,eAAe,WAAW,CAAC,QAAQ;AAClC,UAAA,UAAU,IAAI,MAAM,QAAQ;AAC9B,QAAA,CAAC,SAAS,OAAe,QAAA;AAC7B,UAAM,SAAS,QAAQ;AAAA,MACrB,CAAC,KAAK,UAAU,IAAI,QAAQ,OAAO,IAAI,IAAI,IAAI,MAAM,MAAM,CAAC,CAAC,EAAE;AAAA,MAC/D;AAAA,IAAA;AAEF,WAAO,UAAU;AAAA,EAAA,CAClB;AACH;AAGgB,SAAA,cAEd,MACA,cACA;AACM,QAAA,SAAS,SAAS,cAAc,IAAI;AAE1C,QAAM,gBAAgB,WAAW,OAAO,KAAK,MAAM,GAAkB,IAAI;AAMzE,WAAS,WACP,cAAkD,IAElD,YAAY,MACZ;AACA,UAAM,EAAE,IAAI,IAAI,IAAI,OAAO;AAErB,UAAA,eAAe,CAAC,QACpB;AAAA,MACE,aAAa,GAAG,IAAI,IAAI,GAAG;AAAA,MAC3B,IAAI,OAAO,GAA0B,CAAC;AAAA,MACtC,cAAc,GAA+B;AAAA,IAAA;AAGjD,UAAM,UAAU,OAAO;AAAA,MACrB,OAAO,KAAK,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,KAAK,aAAa,GAAG,CAAC,CAAC;AAAA,IAAA;AAGpD,WAAA,EAAE,SAAS,KAAK;EACzB;AAEO,SAAA,EAAE,YAAY;AACvB;"}
@@ -1,6 +1,7 @@
1
1
  const isObject = (val) => val && typeof val === "object" && !Array.isArray(val);
2
2
  function merge(target, source) {
3
- Object.keys(source || {}).forEach((key) => {
3
+ Object.keys(source || {}).forEach((keyProp) => {
4
+ const key = keyProp;
4
5
  if (isObject(target[key]) && isObject(source?.[key])) {
5
6
  merge(target[key], source?.[key]);
6
7
  } else {
@@ -1 +1 @@
1
- {"version":3,"file":"deepMerge.js","sources":["../../../src/utils/deepMerge.ts"],"sourcesContent":["import { DeepPartial } from \"../types/generic\";\n\nconst isObject = (val: any): val is Object =>\n val && typeof val === \"object\" && !Array.isArray(val);\n\nfunction merge<T>(target: T, source?: DeepPartial<T>) {\n Object.keys(source || {}).forEach((key) => {\n if (isObject(target[key]) && isObject(source?.[key])) {\n merge(target[key], source?.[key]);\n } else {\n target[key] = source?.[key];\n }\n });\n}\n\n/** Merges recursively all keys of source into target returning the resulting object. */\nexport function deepMerge<T>(target: T, source?: DeepPartial<T>): T {\n const result = structuredClone(target);\n merge(result, source);\n return result;\n}\n"],"names":[],"mappings":"AAEA,MAAM,WAAW,CAAC,QAChB,OAAO,OAAO,QAAQ,YAAY,CAAC,MAAM,QAAQ,GAAG;AAEtD,SAAS,MAAS,QAAW,QAAyB;AACpD,SAAO,KAAK,UAAU,CAAE,CAAA,EAAE,QAAQ,CAAC,QAAQ;AACrC,QAAA,SAAS,OAAO,GAAG,CAAC,KAAK,SAAS,SAAS,GAAG,CAAC,GAAG;AACpD,YAAM,OAAO,GAAG,GAAG,SAAS,GAAG,CAAC;AAAA,IAAA,OAC3B;AACE,aAAA,GAAG,IAAI,SAAS,GAAG;AAAA,IAC5B;AAAA,EAAA,CACD;AACH;AAGgB,SAAA,UAAa,QAAW,QAA4B;AAC5D,QAAA,SAAS,gBAAgB,MAAM;AACrC,QAAM,QAAQ,MAAM;AACb,SAAA;AACT;"}
1
+ {"version":3,"file":"deepMerge.js","sources":["../../../src/utils/deepMerge.ts"],"sourcesContent":["import { DeepPartial } from \"../types/generic\";\n\nconst isObject = (val: any): val is Object =>\n val && typeof val === \"object\" && !Array.isArray(val);\n\nfunction merge<T>(target: T, source?: DeepPartial<T>) {\n Object.keys(source || {}).forEach((keyProp) => {\n const key = keyProp as keyof typeof source;\n if (isObject(target[key]) && isObject(source?.[key])) {\n merge(target[key], source?.[key]);\n } else {\n (target as any)[key] = source?.[key];\n }\n });\n}\n\n/** Merges recursively all keys of source into target returning the resulting object. */\nexport function deepMerge<T>(target: T, source?: DeepPartial<T>): T {\n const result = structuredClone(target);\n merge(result, source);\n return result;\n}\n"],"names":[],"mappings":"AAEA,MAAM,WAAW,CAAC,QAChB,OAAO,OAAO,QAAQ,YAAY,CAAC,MAAM,QAAQ,GAAG;AAEtD,SAAS,MAAS,QAAW,QAAyB;AACpD,SAAO,KAAK,UAAU,CAAE,CAAA,EAAE,QAAQ,CAAC,YAAY;AAC7C,UAAM,MAAM;AACR,QAAA,SAAS,OAAO,GAAG,CAAC,KAAK,SAAS,SAAS,GAAG,CAAC,GAAG;AACpD,YAAM,OAAO,GAAG,GAAG,SAAS,GAAG,CAAC;AAAA,IAAA,OAC3B;AACJ,aAAe,GAAG,IAAI,SAAS,GAAG;AAAA,IACrC;AAAA,EAAA,CACD;AACH;AAGgB,SAAA,UAAa,QAAW,QAA4B;AAC5D,QAAA,SAAS,gBAAgB,MAAM;AACrC,QAAM,QAAQ,MAAM;AACb,SAAA;AACT;"}
@@ -16,8 +16,7 @@ function isEqual(obj1, obj2) {
16
16
  }
17
17
  const keys1 = Object.keys(obj1);
18
18
  const keys2 = Object.keys(obj2);
19
- if (keys1.length !== keys2.length)
20
- return false;
19
+ if (keys1.length !== keys2.length) return false;
21
20
  for (const key of keys1) {
22
21
  if (!isEqual(obj1[key], obj2[key]))
23
22
  return false;
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.js","sources":["../../../src/utils/helpers.ts"],"sourcesContent":["export const uniqueId = (prefix = \"\") => {\n return `${prefix}${Math.random().toString(36).slice(2, 9)}`;\n};\n\nexport const range = (length: number, start = 0) => {\n return Array.from({ length: length - start }, (_, i) => i + start);\n};\n\nexport const capitalize = (string = \"\") => {\n return string.charAt(0).toUpperCase() + string.slice(1).toLowerCase();\n};\n\nexport const clamp = (value: number, max = 100, min = 0) => {\n return Math.min(Math.max(value, min), max);\n};\n\nexport function isEqual(obj1: unknown, obj2: unknown) {\n if (!obj1 || !obj2 || typeof obj1 !== \"object\" || typeof obj2 !== \"object\") {\n return obj1 === obj2;\n }\n\n const keys1 = Object.keys(obj1);\n const keys2 = Object.keys(obj2);\n\n if (keys1.length !== keys2.length) return false;\n\n for (const key of keys1) {\n if (!isEqual(obj1[key], obj2[key])) return false;\n }\n\n return true;\n}\n"],"names":[],"mappings":"AAAa,MAAA,WAAW,CAAC,SAAS,OAAO;AACvC,SAAO,GAAG,MAAM,GAAG,KAAK,OAAO,EAAE,SAAS,EAAE,EAAE,MAAM,GAAG,CAAC,CAAC;AAC3D;AAEO,MAAM,QAAQ,CAAC,QAAgB,QAAQ,MAAM;AAC3C,SAAA,MAAM,KAAK,EAAE,QAAQ,SAAS,SAAS,CAAC,GAAG,MAAM,IAAI,KAAK;AACnE;AAEa,MAAA,aAAa,CAAC,SAAS,OAAO;AAClC,SAAA,OAAO,OAAO,CAAC,EAAE,YAAA,IAAgB,OAAO,MAAM,CAAC,EAAE;AAC1D;AAEO,MAAM,QAAQ,CAAC,OAAe,MAAM,KAAK,MAAM,MAAM;AAC1D,SAAO,KAAK,IAAI,KAAK,IAAI,OAAO,GAAG,GAAG,GAAG;AAC3C;AAEgB,SAAA,QAAQ,MAAe,MAAe;AAChD,MAAA,CAAC,QAAQ,CAAC,QAAQ,OAAO,SAAS,YAAY,OAAO,SAAS,UAAU;AAC1E,WAAO,SAAS;AAAA,EAClB;AAEM,QAAA,QAAQ,OAAO,KAAK,IAAI;AACxB,QAAA,QAAQ,OAAO,KAAK,IAAI;AAE1B,MAAA,MAAM,WAAW,MAAM;AAAe,WAAA;AAE1C,aAAW,OAAO,OAAO;AACvB,QAAI,CAAC,QAAQ,KAAK,GAAG,GAAG,KAAK,GAAG,CAAC;AAAU,aAAA;AAAA,EAC7C;AAEO,SAAA;AACT;"}
1
+ {"version":3,"file":"helpers.js","sources":["../../../src/utils/helpers.ts"],"sourcesContent":["export const uniqueId = (prefix = \"\") => {\n return `${prefix}${Math.random().toString(36).slice(2, 9)}`;\n};\n\nexport const range = (length: number, start = 0) => {\n return Array.from({ length: length - start }, (_, i) => i + start);\n};\n\nexport const capitalize = (string = \"\") => {\n return string.charAt(0).toUpperCase() + string.slice(1).toLowerCase();\n};\n\nexport const clamp = (value: number, max = 100, min = 0) => {\n return Math.min(Math.max(value, min), max);\n};\n\nexport function isEqual(obj1: unknown, obj2: unknown) {\n if (!obj1 || !obj2 || typeof obj1 !== \"object\" || typeof obj2 !== \"object\") {\n return obj1 === obj2;\n }\n\n const keys1 = Object.keys(obj1);\n const keys2 = Object.keys(obj2);\n\n if (keys1.length !== keys2.length) return false;\n\n for (const key of keys1) {\n if (\n !isEqual(obj1[key as keyof typeof obj1], obj2[key as keyof typeof obj2])\n )\n return false;\n }\n\n return true;\n}\n"],"names":[],"mappings":"AAAa,MAAA,WAAW,CAAC,SAAS,OAAO;AACvC,SAAO,GAAG,MAAM,GAAG,KAAK,OAAO,EAAE,SAAS,EAAE,EAAE,MAAM,GAAG,CAAC,CAAC;AAC3D;AAEO,MAAM,QAAQ,CAAC,QAAgB,QAAQ,MAAM;AAC3C,SAAA,MAAM,KAAK,EAAE,QAAQ,SAAS,SAAS,CAAC,GAAG,MAAM,IAAI,KAAK;AACnE;AAEa,MAAA,aAAa,CAAC,SAAS,OAAO;AAClC,SAAA,OAAO,OAAO,CAAC,EAAE,YAAA,IAAgB,OAAO,MAAM,CAAC,EAAE;AAC1D;AAEO,MAAM,QAAQ,CAAC,OAAe,MAAM,KAAK,MAAM,MAAM;AAC1D,SAAO,KAAK,IAAI,KAAK,IAAI,OAAO,GAAG,GAAG,GAAG;AAC3C;AAEgB,SAAA,QAAQ,MAAe,MAAe;AAChD,MAAA,CAAC,QAAQ,CAAC,QAAQ,OAAO,SAAS,YAAY,OAAO,SAAS,UAAU;AAC1E,WAAO,SAAS;AAAA,EAClB;AAEM,QAAA,QAAQ,OAAO,KAAK,IAAI;AACxB,QAAA,QAAQ,OAAO,KAAK,IAAI;AAE9B,MAAI,MAAM,WAAW,MAAM,OAAe,QAAA;AAE1C,aAAW,OAAO,OAAO;AACvB,QACE,CAAC,QAAQ,KAAK,GAAwB,GAAG,KAAK,GAAwB,CAAC;AAEhE,aAAA;AAAA,EACX;AAEO,SAAA;AACT;"}
@@ -77,8 +77,7 @@ const processThemes = (themesList) => {
77
77
  };
78
78
  const getVarValue = (cssVar, rootElementId) => {
79
79
  const root = getElementById(rootElementId || "hv-root");
80
- if (!root)
81
- return void 0;
80
+ if (!root) return void 0;
82
81
  return getComputedStyle(root).getPropertyValue(cssVar.replace("var(", "").replace(")", "")).trim();
83
82
  };
84
83
  export {
@@ -1 +1 @@
1
- {"version":3,"file":"theme.js","sources":["../../../src/utils/theme.ts"],"sourcesContent":["import {\n HvThemeColorModeStructure,\n HvThemeStructure,\n themes,\n} from \"@hitachivantara/uikit-styles\";\n\nimport { HvCreateThemeProps, HvTheme } from \"../types/theme\";\nimport { getContainerElement, getElementById } from \"./document\";\n\n/**\n * Sets the element attributes and style for a theme and color mode.\n */\nexport const setElementAttrs = (\n themeName: string,\n modeName: string,\n colorScheme: string,\n themeRootId?: string,\n) => {\n const element = getContainerElement(themeRootId);\n\n if (element) {\n element.setAttribute(`data-theme`, themeName);\n element.setAttribute(`data-color-mode`, modeName);\n\n // set default styles for child components to inherit\n element.classList.add(`uikit-root-element`);\n element.style.colorScheme = colorScheme;\n }\n};\n\n/**\n * Applies customizations to a theme.\n */\nconst applyThemeCustomizations = (obj: any, customizations: any) => {\n const isObject = (val: any) =>\n val && typeof val === \"object\" && !Array.isArray(val);\n\n // Customized theme\n const customizedTheme = { ...obj };\n\n // Add new values to the theme or replace values\n Object.keys(customizations).forEach((key) => {\n if (customizedTheme[key]) {\n if (isObject(customizedTheme[key]) && isObject(customizations[key])) {\n customizedTheme[key] = applyThemeCustomizations(\n customizedTheme[key],\n customizations[key],\n );\n } else if (typeof customizedTheme[key] === typeof customizations[key]) {\n customizedTheme[key] = customizations[key];\n }\n } else {\n customizedTheme[key] = customizations[key];\n }\n });\n\n return customizedTheme;\n};\n\n/**\n * Creates a customized theme based on the base theme and customizations given.\n * For the color modes, the colors that are not defined will be replaced by the values from the dawn mode of the base theme.\n */\nexport const createTheme = (\n props: HvCreateThemeProps,\n): HvTheme | HvThemeStructure => {\n const {\n name,\n base = \"ds5\",\n inheritColorModes = true,\n ...customizations\n } = props;\n\n // Apply customizations to the base theme\n const customizedTheme: HvTheme | HvThemeStructure = customizations\n ? (applyThemeCustomizations(themes[base], customizations) as HvTheme)\n : { ...themes[base] };\n\n // Set theme name\n customizedTheme.name = name.trim();\n // Set theme base\n customizedTheme.base = base;\n\n // Fill new color modes with missing colors\n if (customizations) {\n Object.keys(customizedTheme.colors.modes).forEach((mode) => {\n if (!themes[base].colors.modes[mode]) {\n customizedTheme.colors.modes[mode] = {\n ...themes[base].colors.modes.dawn,\n ...(customizedTheme.colors.modes[mode] as Partial<\n HvThemeColorModeStructure & { [key: string]: string }\n >),\n };\n }\n });\n }\n\n // If the flag `inheritColorModes` is false and customizations were given for the color modes,\n // we're removing any color modes that might have been inherited\n if (!inheritColorModes && customizations.colors?.modes) {\n Object.keys(customizedTheme.colors.modes).forEach((mode) => {\n if (!Object.keys(customizations.colors?.modes || {}).includes(mode)) {\n delete customizedTheme.colors.modes[mode];\n }\n });\n }\n\n // Created theme\n return customizedTheme;\n};\n\n/**\n * Process the themes provided to the HvProvider:\n * - Cleans themes with the same name\n * - Returns the default if the list is empty (ds5)\n */\nexport const processThemes = (\n themesList?: (HvTheme | HvThemeStructure)[],\n): (HvTheme | HvThemeStructure)[] => {\n if (themesList && Array.isArray(themesList) && themesList.length > 0) {\n const list: (HvTheme | HvThemeStructure)[] = [];\n\n themesList.forEach((thm) => {\n const i: number = list.findIndex(\n (t) => t.name.trim() === thm.name.trim(),\n );\n\n if (i !== -1) {\n list.splice(i, 1);\n list.push(thm);\n } else {\n list.push(thm);\n }\n });\n\n // Cleaned themes\n return list;\n }\n // DS5\n return [themes.ds5];\n};\n\nexport const getVarValue = (cssVar: string, rootElementId?: string) => {\n const root = getElementById(rootElementId || \"hv-root\");\n if (!root) return undefined;\n\n return getComputedStyle(root)\n .getPropertyValue(cssVar.replace(\"var(\", \"\").replace(\")\", \"\"))\n .trim();\n};\n"],"names":[],"mappings":";;AAYO,MAAM,kBAAkB,CAC7B,WACA,UACA,aACA,gBACG;AACG,QAAA,UAAU,oBAAoB,WAAW;AAE/C,MAAI,SAAS;AACH,YAAA,aAAa,cAAc,SAAS;AACpC,YAAA,aAAa,mBAAmB,QAAQ;AAGxC,YAAA,UAAU,IAAI,oBAAoB;AAC1C,YAAQ,MAAM,cAAc;AAAA,EAC9B;AACF;AAKA,MAAM,2BAA2B,CAAC,KAAU,mBAAwB;AAC5D,QAAA,WAAW,CAAC,QAChB,OAAO,OAAO,QAAQ,YAAY,CAAC,MAAM,QAAQ,GAAG;AAGhD,QAAA,kBAAkB,EAAE,GAAG;AAG7B,SAAO,KAAK,cAAc,EAAE,QAAQ,CAAC,QAAQ;AACv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AM,IAAI;AAAA,MAC1C;AAAA,IAAA,CACD;AAAA,EACH;AAGO,SAAA;AACT;AAOa,MAAA,gBAAgB,CAC3B,eACmC;AACnC,MAAI,cAAc,MAAM,QAAQ,UAAU,KAAK,WAAW,SAAS,GAAG;AACpE,UAAM,OAAuC,CAAA;AAElC,eAAA,QAAQ,CAAC,QAAQ;AAC1B,YAAM,IAAY,KAAK;AAAA,QACrB,CAAC,MAAM,EAAE,KAAK,WAAW,IAAI,KAAK,KAAK;AAAA,MAAA;AAGzC,UAAI,MAAM,IAAI;AACP,aAAA,OAAO,GAAG,CAAC;AAChB,aAAK,KAAK,GAAG;AAAA,MAAA,OACR;AACL,aAAK,KAAK,GAAG;AAAA,MACf;AAAA,IAAA,CACD;AAGM,WAAA;AAAA,EACT;AAEO,SAAA,CAAC,OAAO,GAAG;AACpB;AAEa,MAAA,cAAc,CAAC,QAAgB,kBAA2B;AAC/D,QAAA,OAAO,eAAe,iBAAiB,SAAS;AACtD,MAAI,CAAC;AAAa,WAAA;AAElB,SAAO,iBAAiB,IAAI,EACzB,iBAAiB,OAAO,QAAQ,QAAQ,EAAE,EAAE,QAAQ,KAAK,EAAE,CAAC,EAC5D,KAAK;AACV;"}
1
+ {"version":3,"file":"theme.js","sources":["../../../src/utils/theme.ts"],"sourcesContent":["import {\n HvThemeColorModeStructure,\n HvThemeStructure,\n themes,\n} from \"@hitachivantara/uikit-styles\";\n\nimport { HvCreateThemeProps, HvTheme } from \"../types/theme\";\nimport { getContainerElement, getElementById } from \"./document\";\n\n/**\n * Sets the element attributes and style for a theme and color mode.\n */\nexport const setElementAttrs = (\n themeName: string,\n modeName: string,\n colorScheme: string,\n themeRootId?: string,\n) => {\n const element = getContainerElement(themeRootId);\n\n if (element) {\n element.setAttribute(`data-theme`, themeName);\n element.setAttribute(`data-color-mode`, modeName);\n\n // set default styles for child components to inherit\n element.classList.add(`uikit-root-element`);\n element.style.colorScheme = colorScheme;\n }\n};\n\n/**\n * Applies customizations to a theme.\n */\nconst applyThemeCustomizations = (obj: any, customizations: any) => {\n const isObject = (val: any) =>\n val && typeof val === \"object\" && !Array.isArray(val);\n\n // Customized theme\n const customizedTheme = { ...obj };\n\n // Add new values to the theme or replace values\n Object.keys(customizations).forEach((key) => {\n if (customizedTheme[key]) {\n if (isObject(customizedTheme[key]) && isObject(customizations[key])) {\n customizedTheme[key] = applyThemeCustomizations(\n customizedTheme[key],\n customizations[key],\n );\n } else if (typeof customizedTheme[key] === typeof customizations[key]) {\n customizedTheme[key] = customizations[key];\n }\n } else {\n customizedTheme[key] = customizations[key];\n }\n });\n\n return customizedTheme;\n};\n\n/**\n * Creates a customized theme based on the base theme and customizations given.\n * For the color modes, the colors that are not defined will be replaced by the values from the dawn mode of the base theme.\n */\nexport const createTheme = (\n props: HvCreateThemeProps,\n): HvTheme | HvThemeStructure => {\n const {\n name,\n base = \"ds5\",\n inheritColorModes = true,\n ...customizations\n } = props;\n\n // Apply customizations to the base theme\n const customizedTheme: HvTheme | HvThemeStructure = customizations\n ? (applyThemeCustomizations(themes[base], customizations) as HvTheme)\n : { ...themes[base] };\n\n // Set theme name\n customizedTheme.name = name.trim();\n // Set theme base\n customizedTheme.base = base;\n\n // Fill new color modes with missing colors\n if (customizations) {\n Object.keys(customizedTheme.colors.modes).forEach((mode) => {\n // @ts-ignore\n if (!themes[base].colors.modes[mode]) {\n customizedTheme.colors.modes[mode] = {\n ...themes[base].colors.modes.dawn,\n ...(customizedTheme.colors.modes[mode] as Partial<\n HvThemeColorModeStructure & { [key: string]: string }\n >),\n };\n }\n });\n }\n\n // If the flag `inheritColorModes` is false and customizations were given for the color modes,\n // we're removing any color modes that might have been inherited\n if (!inheritColorModes && customizations.colors?.modes) {\n Object.keys(customizedTheme.colors.modes).forEach((mode) => {\n if (!Object.keys(customizations.colors?.modes || {}).includes(mode)) {\n delete customizedTheme.colors.modes[mode];\n }\n });\n }\n\n // Created theme\n return customizedTheme;\n};\n\n/**\n * Process the themes provided to the HvProvider:\n * - Cleans themes with the same name\n * - Returns the default if the list is empty (ds5)\n */\nexport const processThemes = (\n themesList?: (HvTheme | HvThemeStructure)[],\n): (HvTheme | HvThemeStructure)[] => {\n if (themesList && Array.isArray(themesList) && themesList.length > 0) {\n const list: (HvTheme | HvThemeStructure)[] = [];\n\n themesList.forEach((thm) => {\n const i: number = list.findIndex(\n (t) => t.name.trim() === thm.name.trim(),\n );\n\n if (i !== -1) {\n list.splice(i, 1);\n list.push(thm);\n } else {\n list.push(thm);\n }\n });\n\n // Cleaned themes\n return list;\n }\n // DS5\n return [themes.ds5];\n};\n\nexport const getVarValue = (cssVar: string, rootElementId?: string) => {\n const root = getElementById(rootElementId || \"hv-root\");\n if (!root) return undefined;\n\n return getComputedStyle(root)\n .getPropertyValue(cssVar.replace(\"var(\", \"\").replace(\")\", \"\"))\n .trim();\n};\n"],"names":[],"mappings":";;AAYO,MAAM,kBAAkB,CAC7B,WACA,UACA,aACA,gBACG;AACG,QAAA,UAAU,oBAAoB,WAAW;AAE/C,MAAI,SAAS;AACH,YAAA,aAAa,cAAc,SAAS;AACpC,YAAA,aAAa,mBAAmB,QAAQ;AAGxC,YAAA,UAAU,IAAI,oBAAoB;AAC1C,YAAQ,MAAM,cAAc;AAAA,EAC9B;AACF;AAKA,MAAM,2BAA2B,CAAC,KAAU,mBAAwB;AAC5D,QAAA,WAAW,CAAC,QAChB,OAAO,OAAO,QAAQ,YAAY,CAAC,MAAM,QAAQ,GAAG;AAGhD,QAAA,kBAAkB,EAAE,GAAG;AAG7B,SAAO,KAAK,cAAc,EAAE,QAAQ,CAAC,QAAQ;AACvC,QAAA,gBAAgB,GAAG,GAAG;AACpB,UAAA,SAAS,gBAAgB,GAAG,CAAC,KAAK,SAAS,eAAe,GAAG,CAAC,GAAG;AACnE,wBAAgB,GAAG,IAAI;AAAA,UACrB,gBAAgB,GAAG;AAAA,UACnB,eAAe,GAAG;AAAA,QAAA;AAAA,MACpB,WACS,OAAO,gBAAgB,GAAG,MAAM,OAAO,eAA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AAAA,QACrB,CAAC,MAAM,EAAE,KAAK,WAAW,IAAI,KAAK,KAAK;AAAA,MAAA;AAGzC,UAAI,MAAM,IAAI;AACP,aAAA,OAAO,GAAG,CAAC;AAChB,aAAK,KAAK,GAAG;AAAA,MAAA,OACR;AACL,aAAK,KAAK,GAAG;AAAA,MACf;AAAA,IAAA,CACD;AAGM,WAAA;AAAA,EACT;AAEO,SAAA,CAAC,OAAO,GAAG;AACpB;AAEa,MAAA,cAAc,CAAC,QAAgB,kBAA2B;AAC/D,QAAA,OAAO,eAAe,iBAAiB,SAAS;AAClD,MAAA,CAAC,KAAa,QAAA;AAElB,SAAO,iBAAiB,IAAI,EACzB,iBAAiB,OAAO,QAAQ,QAAQ,EAAE,EAAE,QAAQ,KAAK,EAAE,CAAC,EAC5D,KAAK;AACV;"}
@@ -7,8 +7,7 @@ function useSavedState(defaultState) {
7
7
  );
8
8
  const changeState = useCallback((value, save = false) => {
9
9
  setState(value);
10
- if (save)
11
- setSubmittedState(value);
10
+ if (save) setSubmittedState(value);
12
11
  }, []);
13
12
  const rollback = () => {
14
13
  setState(submittedState);
@@ -1 +1 @@
1
- {"version":3,"file":"useSavedState.js","sources":["../../../src/utils/useSavedState.ts"],"sourcesContent":["import { useCallback, useState } from \"react\";\n\nexport function useSavedState<T>(defaultState: T) {\n const [initialState] = useState<T>(defaultState);\n\n const [state, setState] = useState<T | undefined>(initialState);\n const [submittedState, setSubmittedState] = useState<T | undefined>(\n initialState,\n );\n\n const changeState = useCallback((value?: T, save = false) => {\n setState(value);\n if (save) setSubmittedState(value);\n }, []);\n\n const rollback = () => {\n setState(submittedState);\n };\n\n return [state, changeState, rollback, submittedState, initialState] as const;\n}\n"],"names":[],"mappings":";AAEO,SAAS,cAAiB,cAAiB;AAChD,QAAM,CAAC,YAAY,IAAI,SAAY,YAAY;AAE/C,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAwB,YAAY;AACxD,QAAA,CAAC,gBAAgB,iBAAiB,IAAI;AAAA,IAC1C;AAAA,EAAA;AAGF,QAAM,cAAc,YAAY,CAAC,OAAW,OAAO,UAAU;AAC3D,aAAS,KAAK;AACV,QAAA;AAAM,wBAAkB,KAAK;AAAA,EACnC,GAAG,CAAE,CAAA;AAEL,QAAM,WAAW,MAAM;AACrB,aAAS,cAAc;AAAA,EAAA;AAGzB,SAAO,CAAC,OAAO,aAAa,UAAU,gBAAgB,YAAY;AACpE;"}
1
+ {"version":3,"file":"useSavedState.js","sources":["../../../src/utils/useSavedState.ts"],"sourcesContent":["import { useCallback, useState } from \"react\";\n\nexport function useSavedState<T>(defaultState: T) {\n const [initialState] = useState<T>(defaultState);\n\n const [state, setState] = useState<T | undefined>(initialState);\n const [submittedState, setSubmittedState] = useState<T | undefined>(\n initialState,\n );\n\n const changeState = useCallback((value?: T, save = false) => {\n setState(value);\n if (save) setSubmittedState(value);\n }, []);\n\n const rollback = () => {\n setState(submittedState);\n };\n\n return [state, changeState, rollback, submittedState, initialState] as const;\n}\n"],"names":[],"mappings":";AAEO,SAAS,cAAiB,cAAiB;AAChD,QAAM,CAAC,YAAY,IAAI,SAAY,YAAY;AAE/C,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAwB,YAAY;AACxD,QAAA,CAAC,gBAAgB,iBAAiB,IAAI;AAAA,IAC1C;AAAA,EAAA;AAGF,QAAM,cAAc,YAAY,CAAC,OAAW,OAAO,UAAU;AAC3D,aAAS,KAAK;AACV,QAAA,wBAAwB,KAAK;AAAA,EACnC,GAAG,CAAE,CAAA;AAEL,QAAM,WAAW,MAAM;AACrB,aAAS,cAAc;AAAA,EAAA;AAGzB,SAAO,CAAC,OAAO,aAAa,UAAU,gBAAgB,YAAY;AACpE;"}