@hitachivantara/uikit-react-core 6.8.1 → 6.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (441) hide show
  1. package/dist/Accordion/Accordion.js +69 -80
  2. package/dist/Accordion/Accordion.styles.js +21 -16
  3. package/dist/ActionBar/ActionBar.js +18 -17
  4. package/dist/ActionBar/ActionBar.styles.js +12 -15
  5. package/dist/ActionsGeneric/ActionsGeneric.js +72 -98
  6. package/dist/ActionsGeneric/ActionsGeneric.styles.js +17 -14
  7. package/dist/AppSwitcher/Action/Action.js +96 -111
  8. package/dist/AppSwitcher/Action/Action.styles.js +44 -48
  9. package/dist/AppSwitcher/AppSwitcher.js +70 -98
  10. package/dist/AppSwitcher/AppSwitcher.styles.js +50 -53
  11. package/dist/Avatar/Avatar.js +66 -111
  12. package/dist/Avatar/Avatar.styles.js +62 -52
  13. package/dist/AvatarGroup/AvatarGroup.js +49 -78
  14. package/dist/AvatarGroup/AvatarGroup.styles.js +40 -60
  15. package/dist/AvatarGroup/AvatarGroupContext.js +13 -16
  16. package/dist/Badge/Badge.js +40 -47
  17. package/dist/Badge/Badge.styles.js +50 -44
  18. package/dist/Banner/Banner.js +51 -83
  19. package/dist/Banner/Banner.styles.js +13 -22
  20. package/dist/Banner/BannerContent/BannerContent.js +35 -56
  21. package/dist/Banner/BannerContent/BannerContent.styles.js +31 -36
  22. package/dist/BaseCheckBox/BaseCheckBox.js +71 -88
  23. package/dist/BaseCheckBox/BaseCheckBox.styles.js +24 -31
  24. package/dist/BaseCheckBox/CheckBoxIcon.js +57 -73
  25. package/dist/BaseDropdown/BaseDropdown.js +147 -189
  26. package/dist/BaseDropdown/BaseDropdown.styles.js +72 -84
  27. package/dist/BaseDropdown/BaseDropdownPanel.js +69 -86
  28. package/dist/BaseDropdown/utils.js +77 -76
  29. package/dist/BaseInput/BaseInput.js +53 -89
  30. package/dist/BaseInput/BaseInput.styles.js +85 -105
  31. package/dist/BaseInput/validations.js +72 -69
  32. package/dist/BaseRadio/BaseRadio.js +61 -85
  33. package/dist/BaseRadio/BaseRadio.styles.js +26 -31
  34. package/dist/BaseRadio/RadioIcon.js +43 -48
  35. package/dist/BaseSwitch/BaseSwitch.js +70 -108
  36. package/dist/BaseSwitch/BaseSwitch.styles.js +94 -113
  37. package/dist/BreadCrumb/BreadCrumb.js +84 -106
  38. package/dist/BreadCrumb/BreadCrumb.styles.js +20 -17
  39. package/dist/BreadCrumb/Page/Page.js +24 -34
  40. package/dist/BreadCrumb/Page/Page.styles.js +20 -25
  41. package/dist/BreadCrumb/PathElement/PathElement.js +17 -17
  42. package/dist/BreadCrumb/PathElement/PathElement.styles.js +9 -7
  43. package/dist/BreadCrumb/utils.js +19 -27
  44. package/dist/BulkActions/BulkActions.js +57 -96
  45. package/dist/BulkActions/BulkActions.styles.js +37 -45
  46. package/dist/Button/Button.js +67 -95
  47. package/dist/Button/Button.styles.js +107 -124
  48. package/dist/ButtonBase/ButtonBase.js +32 -51
  49. package/dist/ButtonBase/ButtonBase.styles.js +21 -30
  50. package/dist/Calendar/Calendar.js +73 -101
  51. package/dist/Calendar/Calendar.styles.js +14 -32
  52. package/dist/Calendar/CalendarHeader/CalendarHeader.js +91 -118
  53. package/dist/Calendar/CalendarHeader/CalendarHeader.styles.js +11 -16
  54. package/dist/Calendar/CalendarNavigation/ComposedNavigation/ComposedNavigation.js +36 -50
  55. package/dist/Calendar/CalendarNavigation/ComposedNavigation/ComposedNavigation.styles.js +12 -18
  56. package/dist/Calendar/CalendarNavigation/MonthSelector/MonthSelector.js +23 -43
  57. package/dist/Calendar/CalendarNavigation/MonthSelector/MonthSelector.styles.js +21 -24
  58. package/dist/Calendar/CalendarNavigation/Navigation/Navigation.js +43 -59
  59. package/dist/Calendar/CalendarNavigation/Navigation/Navigation.styles.js +21 -24
  60. package/dist/Calendar/SingleCalendar/CalendarCell.js +60 -84
  61. package/dist/Calendar/SingleCalendar/CalendarCell.styles.js +39 -56
  62. package/dist/Calendar/SingleCalendar/SingleCalendar.js +121 -154
  63. package/dist/Calendar/SingleCalendar/SingleCalendar.styles.js +53 -68
  64. package/dist/Calendar/model.js +45 -62
  65. package/dist/Calendar/utils.js +233 -128
  66. package/dist/Card/Card.js +35 -53
  67. package/dist/Card/Card.styles.js +37 -50
  68. package/dist/Card/Content/Content.js +15 -27
  69. package/dist/Card/Content/Content.styles.js +5 -10
  70. package/dist/Card/Header/Header.js +22 -35
  71. package/dist/Card/Header/Header.styles.js +22 -25
  72. package/dist/Card/Media/Media.js +16 -26
  73. package/dist/Card/Media/Media.styles.js +6 -7
  74. package/dist/Carousel/Carousel.js +179 -207
  75. package/dist/Carousel/Carousel.styles.js +141 -166
  76. package/dist/Carousel/CarouselControls.js +48 -62
  77. package/dist/Carousel/CarouselSlide/CarouselSlide.js +19 -25
  78. package/dist/Carousel/CarouselSlide/CarouselSlide.styles.js +10 -11
  79. package/dist/Carousel/CarouselThumbnails.js +29 -36
  80. package/dist/CheckBox/CheckBox.js +112 -182
  81. package/dist/CheckBox/CheckBox.styles.js +48 -57
  82. package/dist/CheckBoxGroup/CheckBoxGroup.js +154 -245
  83. package/dist/CheckBoxGroup/CheckBoxGroup.styles.js +29 -35
  84. package/dist/ColorPicker/ColorPicker.js +146 -222
  85. package/dist/ColorPicker/ColorPicker.styles.js +40 -45
  86. package/dist/ColorPicker/Picker/Fields.js +125 -141
  87. package/dist/ColorPicker/Picker/Picker.js +51 -50
  88. package/dist/ColorPicker/Picker/Picker.styles.js +42 -42
  89. package/dist/ColorPicker/PresetColors/PresetColors.js +25 -28
  90. package/dist/ColorPicker/PresetColors/PresetColors.styles.js +17 -17
  91. package/dist/ColorPicker/SavedColors/SavedColors.js +37 -41
  92. package/dist/ColorPicker/SavedColors/SavedColors.styles.js +27 -29
  93. package/dist/ColorPicker/Swatch.js +22 -37
  94. package/dist/Container/Container.js +37 -58
  95. package/dist/Container/Container.styles.js +12 -13
  96. package/dist/Controls/Controls.js +50 -74
  97. package/dist/Controls/Controls.styles.js +16 -13
  98. package/dist/Controls/LeftControl/LeftControl.js +25 -38
  99. package/dist/Controls/LeftControl/LeftControl.styles.js +7 -7
  100. package/dist/Controls/RightControl/RightControl.js +31 -46
  101. package/dist/Controls/RightControl/RightControl.styles.js +9 -7
  102. package/dist/Controls/context/ControlsContext.js +5 -6
  103. package/dist/DatePicker/DatePicker.js +286 -339
  104. package/dist/DatePicker/DatePicker.styles.js +25 -40
  105. package/dist/DatePicker/useVisibleDate.js +142 -126
  106. package/dist/DatePicker/utils.js +17 -26
  107. package/dist/Dialog/Actions/Actions.js +19 -29
  108. package/dist/Dialog/Actions/Actions.styles.js +20 -20
  109. package/dist/Dialog/Content/Content.js +29 -46
  110. package/dist/Dialog/Content/Content.styles.js +14 -15
  111. package/dist/Dialog/Dialog.js +49 -69
  112. package/dist/Dialog/Dialog.styles.js +33 -46
  113. package/dist/Dialog/Title/Title.js +20 -42
  114. package/dist/Dialog/Title/Title.styles.js +14 -16
  115. package/dist/Dialog/context.js +5 -6
  116. package/dist/DotPagination/DotPagination.js +44 -59
  117. package/dist/DotPagination/DotPagination.styles.js +44 -47
  118. package/dist/Drawer/Drawer.js +37 -64
  119. package/dist/Drawer/Drawer.styles.js +18 -21
  120. package/dist/DropDownMenu/DropDownMenu.js +88 -124
  121. package/dist/DropDownMenu/DropDownMenu.styles.js +12 -21
  122. package/dist/Dropdown/Dropdown.js +221 -310
  123. package/dist/Dropdown/Dropdown.styles.js +39 -48
  124. package/dist/Dropdown/List/List.js +194 -176
  125. package/dist/Dropdown/List/List.styles.js +23 -24
  126. package/dist/Dropdown/utils.js +15 -16
  127. package/dist/DropdownButton/DropdownButton.js +42 -46
  128. package/dist/DropdownButton/DropdownButton.styles.js +37 -47
  129. package/dist/EmptyState/EmptyState.js +48 -61
  130. package/dist/EmptyState/EmptyState.styles.js +31 -31
  131. package/dist/FileUploader/DropZone/DropZone.js +141 -179
  132. package/dist/FileUploader/DropZone/DropZone.styles.js +55 -68
  133. package/dist/FileUploader/File/File.js +85 -75
  134. package/dist/FileUploader/File/File.styles.js +55 -60
  135. package/dist/FileUploader/FileList/FileList.js +19 -28
  136. package/dist/FileUploader/FileList/FileList.styles.js +15 -16
  137. package/dist/FileUploader/FileUploader.js +35 -55
  138. package/dist/FileUploader/FileUploader.styles.js +4 -7
  139. package/dist/FileUploader/Preview/Preview.js +37 -52
  140. package/dist/FileUploader/Preview/Preview.styles.js +22 -28
  141. package/dist/FileUploader/utils.js +24 -11
  142. package/dist/FilterGroup/Counter/Counter.js +31 -43
  143. package/dist/FilterGroup/Counter/Counter.styles.js +12 -15
  144. package/dist/FilterGroup/FilterContent/FilterContent.js +138 -177
  145. package/dist/FilterGroup/FilterContent/FilterContent.styles.js +46 -53
  146. package/dist/FilterGroup/FilterContent/HeaderButton.js +77 -100
  147. package/dist/FilterGroup/FilterGroup.js +87 -136
  148. package/dist/FilterGroup/FilterGroup.styles.js +9 -10
  149. package/dist/FilterGroup/FilterGroupContext.js +68 -73
  150. package/dist/FilterGroup/LeftPanel/LeftPanel.js +28 -31
  151. package/dist/FilterGroup/LeftPanel/LeftPanel.styles.js +6 -11
  152. package/dist/FilterGroup/RightPanel/RightPanel.js +118 -151
  153. package/dist/FilterGroup/RightPanel/RightPanel.styles.js +17 -27
  154. package/dist/Focus/Focus.js +248 -344
  155. package/dist/Focus/Focus.styles.js +28 -39
  156. package/dist/Focus/utils.js +14 -20
  157. package/dist/Footer/Footer.js +36 -38
  158. package/dist/Footer/Footer.styles.js +40 -43
  159. package/dist/FormElement/Adornment/Adornment.js +38 -49
  160. package/dist/FormElement/Adornment/Adornment.styles.js +14 -15
  161. package/dist/FormElement/CharCounter/CharCounter.js +51 -73
  162. package/dist/FormElement/CharCounter/CharCounter.styles.js +12 -10
  163. package/dist/FormElement/FormElement.js +53 -31
  164. package/dist/FormElement/FormElement.styles.js +4 -7
  165. package/dist/FormElement/InfoMessage/InfoMessage.js +26 -41
  166. package/dist/FormElement/InfoMessage/InfoMessage.styles.js +11 -9
  167. package/dist/FormElement/Label/Label.js +33 -56
  168. package/dist/FormElement/Label/Label.styles.js +11 -9
  169. package/dist/FormElement/LabelContainer.js +46 -55
  170. package/dist/FormElement/Suggestions/Suggestions.js +46 -71
  171. package/dist/FormElement/Suggestions/Suggestions.styles.js +9 -16
  172. package/dist/FormElement/WarningText/WarningText.js +41 -62
  173. package/dist/FormElement/WarningText/WarningText.styles.js +25 -28
  174. package/dist/FormElement/context.js +6 -10
  175. package/dist/FormElement/utils.js +54 -58
  176. package/dist/GlobalActions/GlobalActions.js +53 -59
  177. package/dist/GlobalActions/GlobalActions.styles.js +67 -76
  178. package/dist/Grid/Grid.js +82 -112
  179. package/dist/Grid/Grid.styles.js +37 -38
  180. package/dist/Header/Actions/Actions.js +15 -17
  181. package/dist/Header/Actions/Actions.styles.js +12 -15
  182. package/dist/Header/Brand/Brand.js +27 -23
  183. package/dist/Header/Brand/Brand.styles.js +16 -14
  184. package/dist/Header/Header.js +22 -31
  185. package/dist/Header/Header.styles.js +32 -30
  186. package/dist/Header/Navigation/MenuBar/Bar.js +23 -36
  187. package/dist/Header/Navigation/MenuBar/Bar.styles.js +54 -61
  188. package/dist/Header/Navigation/MenuBar/MenuBar.js +20 -26
  189. package/dist/Header/Navigation/MenuItem/MenuItem.js +104 -120
  190. package/dist/Header/Navigation/MenuItem/MenuItem.styles.js +48 -63
  191. package/dist/Header/Navigation/Navigation.js +32 -37
  192. package/dist/Header/Navigation/Navigation.styles.js +11 -17
  193. package/dist/Header/Navigation/useSelectionPath.js +17 -20
  194. package/dist/Header/Navigation/utils/FocusContext.js +23 -20
  195. package/dist/Header/Navigation/utils/SelectionContext.js +4 -4
  196. package/dist/IconButton/IconButton.js +25 -32
  197. package/dist/IconContainer/IconContainer.js +55 -76
  198. package/dist/InlineEditor/InlineEditor.js +105 -131
  199. package/dist/InlineEditor/InlineEditor.styles.js +44 -53
  200. package/dist/Input/Input.js +385 -461
  201. package/dist/Input/Input.styles.js +34 -47
  202. package/dist/Input/icons.js +16 -21
  203. package/dist/Input/utils.js +8 -11
  204. package/dist/List/List.js +196 -247
  205. package/dist/List/List.styles.js +44 -49
  206. package/dist/List/useSelectableList.js +11 -8
  207. package/dist/List/utils.js +24 -33
  208. package/dist/ListContainer/ListContainer.js +52 -65
  209. package/dist/ListContainer/ListContainer.styles.js +7 -10
  210. package/dist/ListContainer/ListContext/ListContext.js +4 -4
  211. package/dist/ListContainer/ListItem/ListItem.js +79 -117
  212. package/dist/ListContainer/ListItem/ListItem.styles.js +57 -78
  213. package/dist/Loading/Loading.js +31 -46
  214. package/dist/Loading/Loading.styles.js +41 -48
  215. package/dist/LoadingContainer/LoadingContainer.js +34 -40
  216. package/dist/LoadingContainer/LoadingContainer.styles.js +17 -18
  217. package/dist/Login/Login.js +22 -29
  218. package/dist/Login/Login.styles.js +20 -21
  219. package/dist/MultiButton/MultiButton.js +41 -59
  220. package/dist/MultiButton/MultiButton.styles.js +117 -137
  221. package/dist/NumberInput/NumberInput.js +51 -50
  222. package/dist/NumberInput/NumberInput.styles.js +5 -10
  223. package/dist/OverflowTooltip/OverflowTooltip.js +55 -75
  224. package/dist/OverflowTooltip/OverflowTooltip.styles.js +19 -23
  225. package/dist/Pagination/Pagination.js +176 -164
  226. package/dist/Pagination/Pagination.styles.js +86 -90
  227. package/dist/Pagination/Select.js +51 -60
  228. package/dist/Pagination/Select.styles.js +13 -19
  229. package/dist/Panel/Panel.js +19 -20
  230. package/dist/Panel/Panel.styles.js +12 -15
  231. package/dist/ProgressBar/ProgressBar.js +40 -53
  232. package/dist/ProgressBar/ProgressBar.styles.js +28 -40
  233. package/dist/QueryBuilder/ConfirmationDialog.js +35 -28
  234. package/dist/QueryBuilder/Context.js +308 -322
  235. package/dist/QueryBuilder/QueryBuilder.js +108 -137
  236. package/dist/QueryBuilder/QueryBuilder.styles.js +117 -108
  237. package/dist/QueryBuilder/Rule/Attribute.js +56 -62
  238. package/dist/QueryBuilder/Rule/Operator.js +53 -57
  239. package/dist/QueryBuilder/Rule/Rule.js +70 -96
  240. package/dist/QueryBuilder/Rule/Rule.styles.js +49 -54
  241. package/dist/QueryBuilder/RuleGroup.js +160 -206
  242. package/dist/QueryBuilder/Value/BooleanValue.js +38 -37
  243. package/dist/QueryBuilder/Value/DateTimeValue.js +233 -299
  244. package/dist/QueryBuilder/Value/EmptyValue.js +14 -14
  245. package/dist/QueryBuilder/Value/NumericValue.js +152 -204
  246. package/dist/QueryBuilder/Value/TextValue.js +38 -54
  247. package/dist/QueryBuilder/Value/Value.js +42 -67
  248. package/dist/QueryBuilder/types.js +4 -4
  249. package/dist/QueryBuilder/utils/index.js +40 -74
  250. package/dist/QueryBuilder/utils/reducer.js +86 -92
  251. package/dist/Radio/Radio.js +96 -145
  252. package/dist/Radio/Radio.styles.js +47 -55
  253. package/dist/RadioGroup/RadioGroup.js +98 -159
  254. package/dist/RadioGroup/RadioGroup.styles.js +28 -34
  255. package/dist/ScrollToHorizontal/HorizontalScrollListItem/HorizontalScrollListItem.js +34 -51
  256. package/dist/ScrollToHorizontal/HorizontalScrollListItem/HorizontalScrollListItem.styles.js +39 -48
  257. package/dist/ScrollToHorizontal/ScrollToHorizontal.js +56 -91
  258. package/dist/ScrollToHorizontal/ScrollToHorizontal.styles.js +28 -32
  259. package/dist/ScrollToVertical/ScrollToVertical.js +45 -77
  260. package/dist/ScrollToVertical/ScrollToVertical.styles.js +31 -38
  261. package/dist/ScrollToVertical/VerticalScrollListItem/VerticalScrollListItem.js +30 -39
  262. package/dist/ScrollToVertical/VerticalScrollListItem/VerticalScrollListItem.styles.js +44 -51
  263. package/dist/SearchInput/SearchInput.js +27 -25
  264. package/dist/SearchInput/SearchInput.styles.js +6 -7
  265. package/dist/Section/Section.js +69 -104
  266. package/dist/Section/Section.styles.js +53 -57
  267. package/dist/Select/Option.js +29 -46
  268. package/dist/Select/OptionGroup.js +18 -30
  269. package/dist/Select/Select.js +163 -219
  270. package/dist/Select/Select.styles.js +26 -32
  271. package/dist/SelectionList/SelectionList.js +162 -216
  272. package/dist/SelectionList/SelectionList.styles.js +36 -36
  273. package/dist/SimpleGrid/SimpleGrid.js +16 -27
  274. package/dist/SimpleGrid/SimpleGrid.styles.js +28 -39
  275. package/dist/Skeleton/Skeleton.js +26 -44
  276. package/dist/Skeleton/Skeleton.styles.js +43 -66
  277. package/dist/Slider/Slider.js +316 -431
  278. package/dist/Slider/Slider.styles.js +183 -216
  279. package/dist/Slider/SliderInput/SliderInput.js +38 -57
  280. package/dist/Slider/SliderInput/SliderInput.styles.js +13 -14
  281. package/dist/Slider/base.js +221 -243
  282. package/dist/Slider/utils.js +247 -233
  283. package/dist/Snackbar/Snackbar.js +59 -88
  284. package/dist/Snackbar/Snackbar.styles.js +25 -42
  285. package/dist/Snackbar/SnackbarContent/SnackbarContent.js +31 -50
  286. package/dist/Snackbar/SnackbarContent/SnackbarContent.styles.js +27 -30
  287. package/dist/SnackbarProvider/SnackbarProvider.js +73 -105
  288. package/dist/SnackbarProvider/SnackbarProvider.styles.js +20 -26
  289. package/dist/Stack/Stack.js +74 -84
  290. package/dist/Stack/Stack.styles.js +14 -33
  291. package/dist/StatusIcon/StatusIcon.js +78 -102
  292. package/dist/StatusIcon/StatusIcon.styles.js +42 -52
  293. package/dist/Switch/Switch.js +91 -138
  294. package/dist/Switch/Switch.styles.js +49 -60
  295. package/dist/Table/Table.js +62 -66
  296. package/dist/Table/Table.styles.js +23 -28
  297. package/dist/Table/TableBody/TableBody.js +45 -56
  298. package/dist/Table/TableBody/TableBody.styles.js +8 -7
  299. package/dist/Table/TableCell/TableCell.js +37 -66
  300. package/dist/Table/TableCell/TableCell.styles.js +125 -162
  301. package/dist/Table/TableContainer/TableContainer.js +18 -28
  302. package/dist/Table/TableContainer/TableContainer.styles.js +8 -12
  303. package/dist/Table/TableContext.js +4 -4
  304. package/dist/Table/TableHead/TableHead.js +27 -39
  305. package/dist/Table/TableHead/TableHead.styles.js +10 -7
  306. package/dist/Table/TableHeader/TableHeader.js +73 -124
  307. package/dist/Table/TableHeader/TableHeader.styles.js +135 -150
  308. package/dist/Table/TableHeader/utils.js +11 -15
  309. package/dist/Table/TableRow/TableRow.js +32 -51
  310. package/dist/Table/TableRow/TableRow.styles.js +64 -84
  311. package/dist/Table/TableSection/TableSection.js +21 -20
  312. package/dist/Table/TableSection/TableSection.styles.js +63 -96
  313. package/dist/Table/TableSectionContext.js +4 -4
  314. package/dist/Table/hooks/useHvBulkActions.js +54 -89
  315. package/dist/Table/hooks/useHvFilters.js +4 -4
  316. package/dist/Table/hooks/useHvGlobalFilter.js +4 -4
  317. package/dist/Table/hooks/useHvHeaderGroups.js +73 -82
  318. package/dist/Table/hooks/useHvPagination.js +31 -51
  319. package/dist/Table/hooks/useHvResizeColumns.js +25 -31
  320. package/dist/Table/hooks/useHvRowExpand.js +54 -69
  321. package/dist/Table/hooks/useHvRowSelection.js +294 -420
  322. package/dist/Table/hooks/useHvRowState.js +4 -4
  323. package/dist/Table/hooks/useHvSortBy.js +23 -30
  324. package/dist/Table/hooks/useHvSticky.js +114 -154
  325. package/dist/Table/hooks/useHvTable.js +40 -64
  326. package/dist/Table/hooks/useHvTableStyles.js +51 -82
  327. package/dist/Table/renderers/DateColumnCell.js +12 -13
  328. package/dist/Table/renderers/DefaultCell.js +13 -20
  329. package/dist/Table/renderers/DropdownColumnCell.js +4 -4
  330. package/dist/Table/renderers/ProgressColumnCell.js +43 -47
  331. package/dist/Table/renderers/SwitchColumnCell.js +37 -50
  332. package/dist/Table/renderers/renderers.js +146 -183
  333. package/dist/Tabs/Tab/Tab.js +21 -31
  334. package/dist/Tabs/Tab/Tab.styles.js +44 -54
  335. package/dist/Tabs/Tabs.js +23 -28
  336. package/dist/Tabs/Tabs.styles.js +9 -14
  337. package/dist/Tag/Tag.js +86 -129
  338. package/dist/Tag/Tag.styles.js +63 -88
  339. package/dist/TagsInput/TagsInput.js +349 -417
  340. package/dist/TagsInput/TagsInput.styles.js +77 -90
  341. package/dist/TextArea/TextArea.js +207 -274
  342. package/dist/TextArea/TextArea.styles.js +25 -20
  343. package/dist/TimeAgo/TimeAgo.js +24 -30
  344. package/dist/TimeAgo/TimeAgo.styles.js +4 -7
  345. package/dist/TimeAgo/formatUtils.js +57 -65
  346. package/dist/TimeAgo/useTimeAgo.js +18 -18
  347. package/dist/TimeAgo/useTimeout.js +14 -14
  348. package/dist/TimePicker/Placeholder.js +46 -52
  349. package/dist/TimePicker/TimePicker.js +164 -214
  350. package/dist/TimePicker/TimePicker.styles.js +30 -39
  351. package/dist/TimePicker/Unit/Unit.js +63 -49
  352. package/dist/TimePicker/Unit/Unit.styles.js +41 -46
  353. package/dist/ToggleButton/ToggleButton.js +25 -34
  354. package/dist/Tooltip/Tooltip.js +41 -51
  355. package/dist/Tooltip/Tooltip.styles.js +25 -26
  356. package/dist/TreeView/TreeItem/DefaultContent.js +51 -72
  357. package/dist/TreeView/TreeItem/TreeItem.js +102 -140
  358. package/dist/TreeView/TreeItem/TreeItem.styles.js +56 -70
  359. package/dist/TreeView/TreeItem/useHvTreeItem.js +38 -53
  360. package/dist/TreeView/TreeView.js +65 -62
  361. package/dist/TreeView/TreeView.styles.js +11 -13
  362. package/dist/TreeView/internals/DescendantProvider.js +120 -120
  363. package/dist/TreeView/internals/TreeViewProvider.js +32 -26
  364. package/dist/TreeView/internals/corePlugins.js +8 -4
  365. package/dist/TreeView/internals/hooks/plugins/defaultPlugins.js +10 -10
  366. package/dist/TreeView/internals/hooks/plugins/useTreeViewContextValueBuilder.js +20 -22
  367. package/dist/TreeView/internals/hooks/plugins/useTreeViewExpansion.js +39 -61
  368. package/dist/TreeView/internals/hooks/plugins/useTreeViewFocus.js +56 -80
  369. package/dist/TreeView/internals/hooks/plugins/useTreeViewKeyboardNavigation.js +149 -211
  370. package/dist/TreeView/internals/hooks/plugins/useTreeViewNodes.js +42 -68
  371. package/dist/TreeView/internals/hooks/plugins/useTreeViewSelection.js +162 -195
  372. package/dist/TreeView/internals/hooks/useInstanceEventHandler.js +52 -74
  373. package/dist/TreeView/internals/hooks/useTreeView.js +54 -69
  374. package/dist/TreeView/internals/hooks/useTreeViewInstanceEvents.js +28 -33
  375. package/dist/TreeView/internals/hooks/useTreeViewModels.js +34 -43
  376. package/dist/TreeView/internals/hooks/utils.js +28 -42
  377. package/dist/TreeView/internals/utils/EventManager.js +49 -58
  378. package/dist/TreeView/internals/utils/FinalizationRegistryBasedCleanupTracking.js +14 -18
  379. package/dist/TreeView/internals/utils/TimerBasedCleanupTracking.js +33 -37
  380. package/dist/TreeView/internals/utils/publishTreeViewEvent.js +5 -5
  381. package/dist/Typography/Typography.js +34 -51
  382. package/dist/Typography/Typography.styles.js +20 -23
  383. package/dist/VerticalNavigation/Actions/Action.js +23 -42
  384. package/dist/VerticalNavigation/Actions/Action.styles.js +21 -28
  385. package/dist/VerticalNavigation/Actions/Actions.js +15 -31
  386. package/dist/VerticalNavigation/Actions/Actions.styles.js +13 -19
  387. package/dist/VerticalNavigation/Header/Header.js +51 -91
  388. package/dist/VerticalNavigation/Header/Header.styles.js +22 -32
  389. package/dist/VerticalNavigation/Navigation/Navigation.js +183 -267
  390. package/dist/VerticalNavigation/Navigation/Navigation.styles.js +14 -24
  391. package/dist/VerticalNavigation/NavigationPopup/NavigationPopup.styles.js +9 -17
  392. package/dist/VerticalNavigation/NavigationPopup/NavigationPopupContainer.js +30 -32
  393. package/dist/VerticalNavigation/NavigationSlider/NavigationSlider.js +45 -63
  394. package/dist/VerticalNavigation/NavigationSlider/NavigationSlider.styles.js +23 -33
  395. package/dist/VerticalNavigation/NavigationSlider/utils.js +56 -39
  396. package/dist/VerticalNavigation/TreeView/TreeView.js +515 -664
  397. package/dist/VerticalNavigation/TreeView/TreeView.styles.js +10 -16
  398. package/dist/VerticalNavigation/TreeView/TreeViewContext.js +5 -6
  399. package/dist/VerticalNavigation/TreeView/TreeViewItem.js +319 -414
  400. package/dist/VerticalNavigation/TreeView/TreeViewItem.styles.js +91 -143
  401. package/dist/VerticalNavigation/VerticalNavigation.js +70 -97
  402. package/dist/VerticalNavigation/VerticalNavigation.styles.js +31 -45
  403. package/dist/VerticalNavigation/VerticalNavigationContext.js +8 -10
  404. package/dist/hooks/useClickOutside.js +21 -23
  405. package/dist/hooks/useComputation.js +13 -13
  406. package/dist/hooks/useControlled.js +10 -17
  407. package/dist/hooks/useEnhancedEffect.js +5 -5
  408. package/dist/hooks/useExpandable.js +24 -31
  409. package/dist/hooks/useFocus.js +31 -34
  410. package/dist/hooks/useForkRef.js +19 -19
  411. package/dist/hooks/useImageLoaded.js +26 -26
  412. package/dist/hooks/useIsMounted.js +13 -13
  413. package/dist/hooks/useLabels.js +7 -7
  414. package/dist/hooks/useScrollTo.js +101 -130
  415. package/dist/hooks/useUniqueId.js +6 -6
  416. package/dist/hooks/useWidth.js +10 -13
  417. package/dist/icons.js +77 -88
  418. package/dist/index.d.ts +8 -8
  419. package/dist/index.js +226 -554
  420. package/dist/providers/Provider.js +44 -75
  421. package/dist/providers/ThemeProvider.js +79 -71
  422. package/dist/providers/utils.js +40 -47
  423. package/dist/themes/index.js +6 -5
  424. package/dist/themes/next.js +132 -271
  425. package/dist/themes/pentaho.js +832 -1173
  426. package/dist/types/generic.js +5 -4
  427. package/dist/utils/Callout.js +123 -171
  428. package/dist/utils/CounterLabel.js +14 -15
  429. package/dist/utils/deepMerge.js +13 -15
  430. package/dist/utils/document.js +8 -8
  431. package/dist/utils/focusUtils.js +6 -7
  432. package/dist/utils/focusableElementFinder.js +23 -26
  433. package/dist/utils/helpers.js +15 -23
  434. package/dist/utils/iconVariant.js +15 -12
  435. package/dist/utils/keyboardUtils.js +28 -28
  436. package/dist/utils/multiSelectionEventHandler.js +37 -52
  437. package/dist/utils/scroll.js +50 -76
  438. package/dist/utils/setId.js +4 -4
  439. package/dist/utils/theme.js +11 -8
  440. package/dist/utils/useSavedState.js +19 -16
  441. package/package.json +5 -5
@@ -1,471 +1,395 @@
1
- import { jsx, jsxs } from "react/jsx-runtime";
2
- import { useRef, useState, useMemo, useCallback, useEffect } from "react";
3
- import { useForkRef } from "@mui/material/utils";
4
- import { useDefaultProps, useTheme } from "@hitachivantara/uikit-react-utils";
5
- import { DEFAULT_ERROR_MESSAGES, validateInput, computeValidationState, computeValidationMessage, hasBuiltInValidations } from "../BaseInput/validations.js";
6
- import { HvLabelContainer } from "../FormElement/LabelContainer.js";
7
- import { HvSuggestions } from "../FormElement/Suggestions/Suggestions.js";
8
- import { useControlled } from "../hooks/useControlled.js";
9
- import { useIsMounted } from "../hooks/useIsMounted.js";
10
- import { useLabels } from "../hooks/useLabels.js";
11
- import { useUniqueId } from "../hooks/useUniqueId.js";
12
- import { HvIcon } from "../icons.js";
13
1
  import { fixedForwardRef } from "../types/generic.js";
14
2
  import { isKey } from "../utils/keyboardUtils.js";
15
3
  import { setId } from "../utils/setId.js";
16
- import { EyeIcon } from "./icons.js";
17
- import { useClasses } from "./Input.styles.js";
18
- import { staticClasses } from "./Input.styles.js";
19
- import { changeInputValue } from "./utils.js";
20
4
  import { HvAdornment } from "../FormElement/Adornment/Adornment.js";
21
- import { HvTooltip } from "../Tooltip/Tooltip.js";
22
- import { isValid, isInvalid } from "../FormElement/utils.js";
5
+ import { useUniqueId } from "../hooks/useUniqueId.js";
6
+ import { isInvalid, isValid } from "../FormElement/utils.js";
23
7
  import { HvFormElement } from "../FormElement/FormElement.js";
24
- import { HvBaseInput } from "../BaseInput/BaseInput.js";
25
- import { HvWarningText } from "../FormElement/WarningText/WarningText.js";
26
8
  import { HvInfoMessage } from "../FormElement/InfoMessage/InfoMessage.js";
27
- const DEFAULT_LABELS = {
28
- /** The label of the clear button. */
29
- clearButtonLabel: "Clear the text",
30
- /** The tooltip of the reveal password button when the password is hidden. */
31
- revealPasswordButtonClickToShowTooltip: "Click to show password.",
32
- /** The tooltip of the reveal password button when the password is revealed. */
33
- revealPasswordButtonClickToHideTooltip: "Click to hide password.",
34
- /** The label of the search button. */
35
- searchButtonLabel: "Search"
9
+ import { HvIcon } from "../icons.js";
10
+ import { HvWarningText } from "../FormElement/WarningText/WarningText.js";
11
+ import { useControlled as useControlled$1 } from "../hooks/useControlled.js";
12
+ import { HvLabelContainer } from "../FormElement/LabelContainer.js";
13
+ import { HvSuggestions } from "../FormElement/Suggestions/Suggestions.js";
14
+ import { HvBaseInput } from "../BaseInput/BaseInput.js";
15
+ import { useLabels } from "../hooks/useLabels.js";
16
+ import { HvTooltip } from "../Tooltip/Tooltip.js";
17
+ import { DEFAULT_ERROR_MESSAGES, computeValidationMessage, computeValidationState, hasBuiltInValidations, validateInput } from "../BaseInput/validations.js";
18
+ import { useIsMounted } from "../hooks/useIsMounted.js";
19
+ import { EyeIcon } from "./icons.js";
20
+ import { useClasses } from "./Input.styles.js";
21
+ import { changeInputValue } from "./utils.js";
22
+ import { useDefaultProps, useTheme } from "@hitachivantara/uikit-react-utils";
23
+ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
24
+ import { jsx, jsxs } from "react/jsx-runtime";
25
+ import { useForkRef } from "@mui/material/utils";
26
+ //#region src/Input/Input.tsx
27
+ var DEFAULT_LABELS = {
28
+ /** The label of the clear button. */
29
+ clearButtonLabel: "Clear the text",
30
+ /** The tooltip of the reveal password button when the password is hidden. */
31
+ revealPasswordButtonClickToShowTooltip: "Click to show password.",
32
+ /** The tooltip of the reveal password button when the password is revealed. */
33
+ revealPasswordButtonClickToHideTooltip: "Click to hide password.",
34
+ /** The label of the search button. */
35
+ searchButtonLabel: "Search"
36
36
  };
37
37
  function eventTargetIsInsideContainer(container, event) {
38
- return !!container?.contains(event.relatedTarget);
38
+ return !!container?.contains(event.relatedTarget);
39
39
  }
40
- const HvInput = fixedForwardRef(function HvInput2(props, ref) {
41
- const {
42
- classes: classesProp,
43
- className,
44
- id,
45
- name,
46
- value: valueProp,
47
- defaultValue,
48
- required,
49
- readOnly,
50
- disabled,
51
- enablePortal,
52
- suggestOnFocus,
53
- label,
54
- description: descriptionProp,
55
- "aria-label": ariaLabel,
56
- "aria-labelledby": ariaLabelledBy,
57
- "aria-describedby": ariaDescribedBy,
58
- onChange,
59
- onEnter,
60
- status,
61
- statusMessage,
62
- infoMessage: infoMessageProp,
63
- "aria-errormessage": ariaErrorMessage,
64
- type = "text",
65
- placeholder,
66
- autoFocus,
67
- labels: labelsProp,
68
- validationMessages,
69
- disableClear,
70
- disableRevealPassword,
71
- disableSearchButton,
72
- endAdornment,
73
- maxCharQuantity,
74
- minCharQuantity,
75
- validation,
76
- showValidationIcon,
77
- suggestionListCallback,
78
- inputRef: inputRefProp,
79
- onBlur,
80
- onFocus,
81
- onKeyDown,
82
- inputProps = {},
83
- ...others
84
- } = useDefaultProps("HvInput", props);
85
- const { classes, cx } = useClasses(classesProp);
86
- const labels = useLabels(DEFAULT_LABELS, labelsProp);
87
- const elementId = useUniqueId(id);
88
- const { activeTheme } = useTheme();
89
- const inputRef = useRef(null);
90
- const forkedRef = useForkRef(ref, inputRef, inputRefProp);
91
- const suggestionsRef = useRef(null);
92
- const [description, infoMessage] = activeTheme?.name === "pentahoPlus" ? [infoMessageProp, descriptionProp] : [descriptionProp, infoMessageProp];
93
- const [focused, setFocused] = useState(false);
94
- const isDirty = useRef(false);
95
- const isEmptyValue = !inputRef.current?.value;
96
- const [validationState, setValidationState] = useControlled(
97
- status,
98
- "standBy"
99
- );
100
- const [validationMessage, setValidationMessage] = useControlled(
101
- statusMessage,
102
- ""
103
- );
104
- const errorMessages = useMemo(
105
- () => ({ ...DEFAULT_ERROR_MESSAGES, ...validationMessages }),
106
- // eslint-disable-next-line react-hooks/exhaustive-deps
107
- [
108
- validationMessages?.error,
109
- validationMessages?.requiredError,
110
- validationMessages?.minCharError,
111
- validationMessages?.maxCharError,
112
- validationMessages?.typeMismatchError
113
- ]
114
- );
115
- const performValidation = useCallback(() => {
116
- const inputValidity = validateInput(
117
- inputRef.current,
118
- required,
119
- minCharQuantity,
120
- maxCharQuantity,
121
- validation
122
- );
123
- setValidationState(computeValidationState(inputValidity, isEmptyValue));
124
- setValidationMessage(
125
- computeValidationMessage(inputValidity, errorMessages) || ""
126
- );
127
- return inputValidity;
128
- }, [
129
- errorMessages,
130
- isEmptyValue,
131
- maxCharQuantity,
132
- minCharQuantity,
133
- required,
134
- setValidationMessage,
135
- setValidationState,
136
- validation
137
- ]);
138
- const canShowError = ariaErrorMessage == null && (status !== void 0 && statusMessage !== void 0 || status === void 0 && hasBuiltInValidations(
139
- required,
140
- type,
141
- minCharQuantity,
142
- maxCharQuantity,
143
- validation,
144
- inputProps
145
- ));
146
- const isStateInvalid = isInvalid(validationState);
147
- const willShowError = canShowError && isStateInvalid;
148
- const canShowInfo = !!infoMessage && !willShowError;
149
- const [revealPassword, setRevealPassword] = useState(false);
150
- const realType = useMemo(() => {
151
- if (type === "password") {
152
- return revealPassword ? "text" : "password";
153
- }
154
- if (["search", "number", "email"].includes(type)) return type;
155
- return "text";
156
- }, [revealPassword, type]);
157
- const [suggestionValues, setSuggestionValues] = useState(null);
158
- const canShowSuggestions = suggestionListCallback != null;
159
- const hasSuggestions = !!suggestionValues;
160
- const hasLabel = label != null;
161
- const focusInput = () => {
162
- inputRef.current?.focus();
163
- };
164
- const isMounted = useIsMounted();
165
- const suggestionClearHandler = () => {
166
- if (isMounted.current) {
167
- setSuggestionValues(null);
168
- }
169
- };
170
- const suggestionHandler = (val) => {
171
- const suggestionsArray = suggestionListCallback?.(val);
172
- if (suggestionsArray?.[0]?.label) {
173
- setSuggestionValues(suggestionsArray);
174
- } else {
175
- suggestionClearHandler();
176
- }
177
- };
178
- const suggestionSelectedHandler = (event, item) => {
179
- const newValue = item.value || item.label;
180
- changeInputValue(inputRef.current, newValue);
181
- focusInput();
182
- suggestionClearHandler();
183
- if (type === "search") {
184
- onEnter?.(event, newValue);
185
- }
186
- };
187
- const onChangeHandler = (event, newValue) => {
188
- isDirty.current = true;
189
- onChange?.(event, newValue);
190
- if (canShowSuggestions) {
191
- suggestionHandler(newValue);
192
- }
193
- };
194
- const onInputBlurHandler = (event) => {
195
- if (eventTargetIsInsideContainer(suggestionsRef.current, event)) return;
196
- setFocused(false);
197
- const inputValidity = performValidation();
198
- onBlur?.(event, event.target?.value, inputValidity);
199
- };
200
- const onFocusHandler = (event) => {
201
- setFocused(true);
202
- setValidationState("standBy");
203
- onFocus?.(event, event.target.value);
204
- };
205
- const getSuggestions = (li) => {
206
- const listEl = document.getElementById(
207
- setId(elementId, "suggestions-list") || ""
208
- );
209
- return li != null ? listEl?.getElementsByTagName("li")?.[li] : listEl;
210
- };
211
- const onSuggestionKeyDown = (event) => {
212
- if (isKey(event, "Esc")) {
213
- suggestionClearHandler();
214
- focusInput();
215
- } else if (isKey(event, "Tab")) {
216
- suggestionClearHandler();
217
- }
218
- };
219
- const onKeyDownHandler = (event) => {
220
- const { value } = event.currentTarget;
221
- if (isKey(event, "ArrowDown") && hasSuggestions) {
222
- const li = getSuggestions(0);
223
- li?.focus();
224
- } else if (isKey(event, "Enter")) {
225
- onEnter?.(event, value);
226
- }
227
- onKeyDown?.(event, value);
228
- };
229
- const onContainerBlurHandler = (event) => {
230
- if (event.relatedTarget) {
231
- setTimeout(() => {
232
- const list = getSuggestions(null);
233
- if (!list?.contains(document.activeElement)) suggestionClearHandler();
234
- }, 10);
235
- }
236
- };
237
- const showClear = !disabled && !readOnly && !disableClear && !isEmptyValue && (!onEnter || type !== "search" || disableSearchButton || validationState !== "standBy");
238
- const showSearchIcon = type === "search" && !disableSearchButton;
239
- const showRevealPasswordButton = type === "password" && !disableRevealPassword;
240
- const handleClear = useCallback(
241
- (event) => {
242
- setValidationState("standBy");
243
- changeInputValue(inputRef.current, "");
244
- if (canShowSuggestions && suggestOnFocus) event.stopPropagation();
245
- else {
246
- setTimeout(focusInput);
247
- }
248
- },
249
- [canShowSuggestions, setValidationState, suggestOnFocus]
250
- );
251
- const clearButton = useMemo(() => {
252
- if (!showClear) {
253
- return null;
254
- }
255
- return /* @__PURE__ */ jsx(
256
- HvAdornment,
257
- {
258
- className: cx(classes.adornmentButton, {
259
- [classes.iconClear]: !showSearchIcon
260
- }),
261
- onClick: handleClear,
262
- "aria-label": labels?.clearButtonLabel,
263
- "aria-controls": setId(elementId, "input"),
264
- icon: /* @__PURE__ */ jsx(HvIcon, { compact: true, name: "Close", size: "xs" })
265
- }
266
- );
267
- }, [
268
- showClear,
269
- classes.adornmentButton,
270
- classes.iconClear,
271
- showSearchIcon,
272
- handleClear,
273
- labels?.clearButtonLabel,
274
- elementId,
275
- cx
276
- ]);
277
- const searchButton = useMemo(() => {
278
- const reallyShowIt = showSearchIcon && (isEmptyValue || onEnter && validationState === "standBy");
279
- if (!reallyShowIt) return null;
280
- return /* @__PURE__ */ jsx(
281
- HvAdornment,
282
- {
283
- className: classes.adornmentButton,
284
- onClick: onEnter && ((evt) => onEnter?.(evt, inputRef.current?.value ?? "")),
285
- icon: /* @__PURE__ */ jsx(HvIcon, { compact: true, name: "Search", title: labels.searchButtonLabel })
286
- }
287
- );
288
- }, [
289
- showSearchIcon,
290
- isEmptyValue,
291
- onEnter,
292
- validationState,
293
- classes.adornmentButton,
294
- labels.searchButtonLabel
295
- ]);
296
- const revealPasswordButton = useMemo(() => {
297
- if (!showRevealPasswordButton) return null;
298
- return /* @__PURE__ */ jsx(
299
- HvTooltip,
300
- {
301
- title: revealPassword ? labels?.revealPasswordButtonClickToHideTooltip : labels?.revealPasswordButtonClickToShowTooltip,
302
- children: /* @__PURE__ */ jsx(
303
- HvAdornment,
304
- {
305
- className: classes.adornmentButton,
306
- onClick: () => setRevealPassword((s) => !s),
307
- "aria-controls": setId(elementId, "input"),
308
- icon: /* @__PURE__ */ jsx(EyeIcon, { selected: revealPassword }),
309
- tabIndex: 0,
310
- ...{ selected: revealPassword }
311
- }
312
- )
313
- }
314
- );
315
- }, [
316
- showRevealPasswordButton,
317
- revealPassword,
318
- labels?.revealPasswordButtonClickToHideTooltip,
319
- labels?.revealPasswordButtonClickToShowTooltip,
320
- classes.adornmentButton,
321
- elementId
322
- ]);
323
- const validationIcon = useMemo(() => {
324
- if (!showValidationIcon) return null;
325
- if (!isValid(validationState)) return null;
326
- return /* @__PURE__ */ jsx(HvIcon, { name: "Success", color: "positive", className: classes.icon });
327
- }, [showValidationIcon, validationState, classes.icon]);
328
- const adornments = useMemo(() => {
329
- if (!clearButton && !revealPasswordButton && !searchButton && !validationIcon && !endAdornment)
330
- return null;
331
- return /* @__PURE__ */ jsxs("div", { className: classes.adornmentsBox, children: [
332
- clearButton,
333
- revealPasswordButton,
334
- searchButton,
335
- validationIcon || endAdornment
336
- ] });
337
- }, [
338
- classes.adornmentsBox,
339
- clearButton,
340
- endAdornment,
341
- revealPasswordButton,
342
- searchButton,
343
- validationIcon
344
- ]);
345
- useEffect(() => {
346
- if (focused || !isDirty.current && isEmptyValue) {
347
- return;
348
- }
349
- performValidation();
350
- }, [focused, isEmptyValue, performValidation]);
351
- const errorMessageId = isStateInvalid ? canShowError ? setId(elementId, "error") : ariaErrorMessage : void 0;
352
- return /* @__PURE__ */ jsxs(
353
- HvFormElement,
354
- {
355
- id,
356
- name,
357
- status: validationState,
358
- disabled,
359
- required,
360
- readOnly,
361
- className: cx(
362
- classes.root,
363
- {
364
- [classes.hasSuggestions]: hasSuggestions
365
- },
366
- className
367
- ),
368
- onBlur: onContainerBlurHandler,
369
- children: [
370
- /* @__PURE__ */ jsx(
371
- HvLabelContainer,
372
- {
373
- label,
374
- description,
375
- inputId: setId(elementId, "input"),
376
- labelId: setId(elementId, "label"),
377
- descriptionId: setId(elementId, "description"),
378
- classes: {
379
- root: classes.labelContainer,
380
- label: classes.label,
381
- description: classes.description
382
- }
383
- }
384
- ),
385
- /* @__PURE__ */ jsx(
386
- HvBaseInput,
387
- {
388
- id: hasLabel || showClear || showRevealPasswordButton ? setId(elementId, "input") : setId(id, "input"),
389
- name,
390
- value: valueProp,
391
- defaultValue,
392
- required,
393
- readOnly,
394
- disabled,
395
- onChange: onChangeHandler,
396
- autoFocus,
397
- onKeyDown: onKeyDownHandler,
398
- onBlur: onInputBlurHandler,
399
- onFocus: onFocusHandler,
400
- placeholder,
401
- type: realType,
402
- classes: {
403
- input: classes.input,
404
- root: classes.inputRoot,
405
- focused: classes.inputRootFocused,
406
- disabled: classes.inputRootDisabled,
407
- multiline: classes.inputRootMultiline
408
- },
409
- invalid: isStateInvalid,
410
- inputProps: {
411
- "aria-label": ariaLabel,
412
- "aria-labelledby": ariaLabelledBy,
413
- "aria-invalid": isStateInvalid ? true : void 0,
414
- "aria-errormessage": errorMessageId,
415
- "aria-describedby": ariaDescribedBy != null ? ariaDescribedBy : description ? setId(elementId, "description") : void 0,
416
- "aria-controls": canShowSuggestions ? setId(elementId, "suggestions") : void 0,
417
- // prevent browsers auto-fill/suggestions when we have our own
418
- autoComplete: canShowSuggestions ? "off" : void 0,
419
- onFocus: (event) => {
420
- inputProps.onFocus?.(event);
421
- if (canShowSuggestions && suggestOnFocus) {
422
- suggestionHandler(event.currentTarget.value);
423
- }
424
- },
425
- onClick: (event) => {
426
- inputProps.onClick?.(event);
427
- if (canShowSuggestions && suggestOnFocus) event.stopPropagation();
428
- },
429
- ...inputProps
430
- },
431
- ref: forkedRef,
432
- endAdornment: adornments,
433
- ...others
434
- }
435
- ),
436
- canShowSuggestions && /* @__PURE__ */ jsx(
437
- HvSuggestions,
438
- {
439
- id: setId(elementId, "suggestions"),
440
- classes: {
441
- root: classes.suggestionsContainer,
442
- list: classes.suggestionList
443
- },
444
- open: hasSuggestions,
445
- anchorEl: inputRef.current?.parentElement,
446
- onClose: suggestionClearHandler,
447
- onKeyDown: onSuggestionKeyDown,
448
- onSuggestionSelected: suggestionSelectedHandler,
449
- suggestionValues,
450
- enablePortal,
451
- popperProps: { ref: suggestionsRef }
452
- }
453
- ),
454
- canShowError && /* @__PURE__ */ jsx(
455
- HvWarningText,
456
- {
457
- id: setId(elementId, "error"),
458
- disableBorder: true,
459
- className: classes.error,
460
- children: validationMessage
461
- }
462
- ),
463
- canShowInfo && /* @__PURE__ */ jsx(HvInfoMessage, { disableGutter: true, variant: "caption1", children: infoMessage })
464
- ]
465
- }
466
- );
40
+ /**
41
+ The Input is a UI control that allows users to enter and edit text, typically used for collecting user-provided information.
42
+ */
43
+ var HvInput = fixedForwardRef(function HvInput(props, ref) {
44
+ const { classes: classesProp, className, id, name, value: valueProp, defaultValue, required, readOnly, disabled, enablePortal, suggestOnFocus, label, description: descriptionProp, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, onChange, onEnter, status, statusMessage, infoMessage: infoMessageProp, "aria-errormessage": ariaErrorMessage, type = "text", placeholder, autoFocus, labels: labelsProp, validationMessages, disableClear, disableRevealPassword, disableSearchButton, endAdornment, maxCharQuantity, minCharQuantity, validation, showValidationIcon, suggestionListCallback, inputRef: inputRefProp, onBlur, onFocus, onKeyDown, inputProps = {}, ...others } = useDefaultProps("HvInput", props);
45
+ const { classes, cx } = useClasses(classesProp);
46
+ const labels = useLabels(DEFAULT_LABELS, labelsProp);
47
+ const elementId = useUniqueId(id);
48
+ const { activeTheme } = useTheme();
49
+ const inputRef = useRef(null);
50
+ const forkedRef = useForkRef(ref, inputRef, inputRefProp);
51
+ const suggestionsRef = useRef(null);
52
+ const [description, infoMessage] = activeTheme?.name === "pentahoPlus" ? [infoMessageProp, descriptionProp] : [descriptionProp, infoMessageProp];
53
+ const [focused, setFocused] = useState(false);
54
+ const isDirty = useRef(false);
55
+ const isEmptyValue = !inputRef.current?.value;
56
+ const [validationState, setValidationState] = useControlled$1(status, "standBy");
57
+ const [validationMessage, setValidationMessage] = useControlled$1(statusMessage, "");
58
+ const errorMessages = useMemo(() => ({
59
+ ...DEFAULT_ERROR_MESSAGES,
60
+ ...validationMessages
61
+ }), [
62
+ validationMessages?.error,
63
+ validationMessages?.requiredError,
64
+ validationMessages?.minCharError,
65
+ validationMessages?.maxCharError,
66
+ validationMessages?.typeMismatchError
67
+ ]);
68
+ const performValidation = useCallback(() => {
69
+ const inputValidity = validateInput(inputRef.current, required, minCharQuantity, maxCharQuantity, validation);
70
+ setValidationState(computeValidationState(inputValidity, isEmptyValue));
71
+ setValidationMessage(computeValidationMessage(inputValidity, errorMessages) || "");
72
+ return inputValidity;
73
+ }, [
74
+ errorMessages,
75
+ isEmptyValue,
76
+ maxCharQuantity,
77
+ minCharQuantity,
78
+ required,
79
+ setValidationMessage,
80
+ setValidationState,
81
+ validation
82
+ ]);
83
+ const canShowError = ariaErrorMessage == null && (status !== void 0 && statusMessage !== void 0 || status === void 0 && hasBuiltInValidations(required, type, minCharQuantity, maxCharQuantity, validation, inputProps));
84
+ const isStateInvalid = isInvalid(validationState);
85
+ const canShowInfo = !!infoMessage && !(canShowError && isStateInvalid);
86
+ const [revealPassword, setRevealPassword] = useState(false);
87
+ const realType = useMemo(() => {
88
+ if (type === "password") return revealPassword ? "text" : "password";
89
+ if ([
90
+ "search",
91
+ "number",
92
+ "email"
93
+ ].includes(type)) return type;
94
+ return "text";
95
+ }, [revealPassword, type]);
96
+ const [suggestionValues, setSuggestionValues] = useState(null);
97
+ const canShowSuggestions = suggestionListCallback != null;
98
+ const hasSuggestions = !!suggestionValues;
99
+ const hasLabel = label != null;
100
+ /**
101
+ * Looks for the node that represent the input inside the material tree and focus it.
102
+ */
103
+ const focusInput = () => {
104
+ inputRef.current?.focus();
105
+ };
106
+ const isMounted = useIsMounted();
107
+ /**
108
+ * Clears the suggestion array.
109
+ */
110
+ const suggestionClearHandler = () => {
111
+ if (isMounted.current) setSuggestionValues(null);
112
+ };
113
+ /**
114
+ * Fills of the suggestion array.
115
+ */
116
+ const suggestionHandler = (val) => {
117
+ const suggestionsArray = suggestionListCallback?.(val);
118
+ if (suggestionsArray?.[0]?.label) setSuggestionValues(suggestionsArray);
119
+ else suggestionClearHandler();
120
+ };
121
+ /**
122
+ * Executes the user callback adds the selection to the state and clears the suggestions.
123
+ */
124
+ const suggestionSelectedHandler = (event, item) => {
125
+ const newValue = item.value || item.label;
126
+ changeInputValue(inputRef.current, newValue);
127
+ focusInput();
128
+ suggestionClearHandler();
129
+ if (type === "search") onEnter?.(event, newValue);
130
+ };
131
+ const onChangeHandler = (event, newValue) => {
132
+ isDirty.current = true;
133
+ onChange?.(event, newValue);
134
+ if (canShowSuggestions) suggestionHandler(newValue);
135
+ };
136
+ /**
137
+ * Validates the input updating the state and modifying the info text, also executes
138
+ * the user provided onBlur passing the current validation status and value.
139
+ */
140
+ const onInputBlurHandler = (event) => {
141
+ if (eventTargetIsInsideContainer(suggestionsRef.current, event)) return;
142
+ setFocused(false);
143
+ const inputValidity = performValidation();
144
+ onBlur?.(event, event.target?.value, inputValidity);
145
+ };
146
+ /**
147
+ * Updates the state putting again the value from the state because the input value is
148
+ * not automatically manage, it also executes the onFocus function from the user passing the value
149
+ */
150
+ const onFocusHandler = (event) => {
151
+ setFocused(true);
152
+ setValidationState("standBy");
153
+ onFocus?.(event, event.target.value);
154
+ };
155
+ const getSuggestions = (li) => {
156
+ const listEl = document.getElementById(setId(elementId, "suggestions-list") || "");
157
+ return li != null ? listEl?.getElementsByTagName("li")?.[li] : listEl;
158
+ };
159
+ const onSuggestionKeyDown = (event) => {
160
+ if (isKey(event, "Esc")) {
161
+ suggestionClearHandler();
162
+ focusInput();
163
+ } else if (isKey(event, "Tab")) suggestionClearHandler();
164
+ };
165
+ /** Focus the suggestion list when the arrow down is pressed. */
166
+ const onKeyDownHandler = (event) => {
167
+ const { value } = event.currentTarget;
168
+ if (isKey(event, "ArrowDown") && hasSuggestions) getSuggestions(0)?.focus();
169
+ else if (isKey(event, "Enter")) onEnter?.(event, value);
170
+ onKeyDown?.(event, value);
171
+ };
172
+ /** Clears the suggestion list on blur. */
173
+ const onContainerBlurHandler = (event) => {
174
+ if (event.relatedTarget) setTimeout(() => {
175
+ if (!getSuggestions(null)?.contains(document.activeElement)) suggestionClearHandler();
176
+ }, 10);
177
+ };
178
+ const showClear = !disabled && !readOnly && !disableClear && !isEmptyValue && (!onEnter || type !== "search" || disableSearchButton || validationState !== "standBy");
179
+ const showSearchIcon = type === "search" && !disableSearchButton;
180
+ const showRevealPasswordButton = type === "password" && !disableRevealPassword;
181
+ /**
182
+ * Clears the input value from the state and refocus the input.
183
+ */
184
+ const handleClear = useCallback((event) => {
185
+ setValidationState("standBy");
186
+ changeInputValue(inputRef.current, "");
187
+ if (canShowSuggestions && suggestOnFocus) event.stopPropagation();
188
+ else setTimeout(focusInput);
189
+ }, [
190
+ canShowSuggestions,
191
+ setValidationState,
192
+ suggestOnFocus
193
+ ]);
194
+ const clearButton = useMemo(() => {
195
+ if (!showClear) return null;
196
+ return /* @__PURE__ */ jsx(HvAdornment, {
197
+ className: cx(classes.adornmentButton, { [classes.iconClear]: !showSearchIcon }),
198
+ onClick: handleClear,
199
+ "aria-label": labels?.clearButtonLabel,
200
+ "aria-controls": setId(elementId, "input"),
201
+ icon: /* @__PURE__ */ jsx(HvIcon, {
202
+ compact: true,
203
+ name: "Close",
204
+ size: "xs"
205
+ })
206
+ });
207
+ }, [
208
+ showClear,
209
+ classes.adornmentButton,
210
+ classes.iconClear,
211
+ showSearchIcon,
212
+ handleClear,
213
+ labels?.clearButtonLabel,
214
+ elementId,
215
+ cx
216
+ ]);
217
+ const searchButton = useMemo(() => {
218
+ if (!(showSearchIcon && (isEmptyValue || onEnter && validationState === "standBy"))) return null;
219
+ return /* @__PURE__ */ jsx(HvAdornment, {
220
+ className: classes.adornmentButton,
221
+ onClick: onEnter && ((evt) => onEnter?.(evt, inputRef.current?.value ?? "")),
222
+ icon: /* @__PURE__ */ jsx(HvIcon, {
223
+ compact: true,
224
+ name: "Search",
225
+ title: labels.searchButtonLabel
226
+ })
227
+ });
228
+ }, [
229
+ showSearchIcon,
230
+ isEmptyValue,
231
+ onEnter,
232
+ validationState,
233
+ classes.adornmentButton,
234
+ labels.searchButtonLabel
235
+ ]);
236
+ const revealPasswordButton = useMemo(() => {
237
+ if (!showRevealPasswordButton) return null;
238
+ return /* @__PURE__ */ jsx(HvTooltip, {
239
+ title: revealPassword ? labels?.revealPasswordButtonClickToHideTooltip : labels?.revealPasswordButtonClickToShowTooltip,
240
+ children: /* @__PURE__ */ jsx(HvAdornment, {
241
+ className: classes.adornmentButton,
242
+ onClick: () => setRevealPassword((s) => !s),
243
+ "aria-controls": setId(elementId, "input"),
244
+ icon: /* @__PURE__ */ jsx(EyeIcon, { selected: revealPassword }),
245
+ tabIndex: 0,
246
+ selected: revealPassword
247
+ })
248
+ });
249
+ }, [
250
+ showRevealPasswordButton,
251
+ revealPassword,
252
+ labels?.revealPasswordButtonClickToHideTooltip,
253
+ labels?.revealPasswordButtonClickToShowTooltip,
254
+ classes.adornmentButton,
255
+ elementId
256
+ ]);
257
+ const validationIcon = useMemo(() => {
258
+ if (!showValidationIcon) return null;
259
+ if (!isValid(validationState)) return null;
260
+ return /* @__PURE__ */ jsx(HvIcon, {
261
+ name: "Success",
262
+ color: "positive",
263
+ className: classes.icon
264
+ });
265
+ }, [
266
+ showValidationIcon,
267
+ validationState,
268
+ classes.icon
269
+ ]);
270
+ const adornments = useMemo(() => {
271
+ if (!clearButton && !revealPasswordButton && !searchButton && !validationIcon && !endAdornment) return null;
272
+ return /* @__PURE__ */ jsxs("div", {
273
+ className: classes.adornmentsBox,
274
+ children: [
275
+ clearButton,
276
+ revealPasswordButton,
277
+ searchButton,
278
+ validationIcon || endAdornment
279
+ ]
280
+ });
281
+ }, [
282
+ classes.adornmentsBox,
283
+ clearButton,
284
+ endAdornment,
285
+ revealPasswordButton,
286
+ searchButton,
287
+ validationIcon
288
+ ]);
289
+ useEffect(() => {
290
+ if (focused || !isDirty.current && isEmptyValue) return;
291
+ performValidation();
292
+ }, [
293
+ focused,
294
+ isEmptyValue,
295
+ performValidation
296
+ ]);
297
+ const errorMessageId = isStateInvalid ? canShowError ? setId(elementId, "error") : ariaErrorMessage : void 0;
298
+ return /* @__PURE__ */ jsxs(HvFormElement, {
299
+ id,
300
+ name,
301
+ status: validationState,
302
+ disabled,
303
+ required,
304
+ readOnly,
305
+ className: cx(classes.root, { [classes.hasSuggestions]: hasSuggestions }, className),
306
+ onBlur: onContainerBlurHandler,
307
+ children: [
308
+ /* @__PURE__ */ jsx(HvLabelContainer, {
309
+ label,
310
+ description,
311
+ inputId: setId(elementId, "input"),
312
+ labelId: setId(elementId, "label"),
313
+ descriptionId: setId(elementId, "description"),
314
+ classes: {
315
+ root: classes.labelContainer,
316
+ label: classes.label,
317
+ description: classes.description
318
+ }
319
+ }),
320
+ /* @__PURE__ */ jsx(HvBaseInput, {
321
+ id: hasLabel || showClear || showRevealPasswordButton ? setId(elementId, "input") : setId(id, "input"),
322
+ name,
323
+ value: valueProp,
324
+ defaultValue,
325
+ required,
326
+ readOnly,
327
+ disabled,
328
+ onChange: onChangeHandler,
329
+ autoFocus,
330
+ onKeyDown: onKeyDownHandler,
331
+ onBlur: onInputBlurHandler,
332
+ onFocus: onFocusHandler,
333
+ placeholder,
334
+ type: realType,
335
+ classes: {
336
+ input: classes.input,
337
+ root: classes.inputRoot,
338
+ focused: classes.inputRootFocused,
339
+ disabled: classes.inputRootDisabled,
340
+ multiline: classes.inputRootMultiline
341
+ },
342
+ invalid: isStateInvalid,
343
+ inputProps: {
344
+ "aria-label": ariaLabel,
345
+ "aria-labelledby": ariaLabelledBy,
346
+ "aria-invalid": isStateInvalid ? true : void 0,
347
+ "aria-errormessage": errorMessageId,
348
+ "aria-describedby": ariaDescribedBy != null ? ariaDescribedBy : description ? setId(elementId, "description") : void 0,
349
+ "aria-controls": canShowSuggestions ? setId(elementId, "suggestions") : void 0,
350
+ autoComplete: canShowSuggestions ? "off" : void 0,
351
+ onFocus: (event) => {
352
+ inputProps.onFocus?.(event);
353
+ if (canShowSuggestions && suggestOnFocus) suggestionHandler(event.currentTarget.value);
354
+ },
355
+ onClick: (event) => {
356
+ inputProps.onClick?.(event);
357
+ if (canShowSuggestions && suggestOnFocus) event.stopPropagation();
358
+ },
359
+ ...inputProps
360
+ },
361
+ ref: forkedRef,
362
+ endAdornment: adornments,
363
+ ...others
364
+ }),
365
+ canShowSuggestions && /* @__PURE__ */ jsx(HvSuggestions, {
366
+ id: setId(elementId, "suggestions"),
367
+ classes: {
368
+ root: classes.suggestionsContainer,
369
+ list: classes.suggestionList
370
+ },
371
+ open: hasSuggestions,
372
+ anchorEl: inputRef.current?.parentElement,
373
+ onClose: suggestionClearHandler,
374
+ onKeyDown: onSuggestionKeyDown,
375
+ onSuggestionSelected: suggestionSelectedHandler,
376
+ suggestionValues,
377
+ enablePortal,
378
+ popperProps: { ref: suggestionsRef }
379
+ }),
380
+ canShowError && /* @__PURE__ */ jsx(HvWarningText, {
381
+ id: setId(elementId, "error"),
382
+ disableBorder: true,
383
+ className: classes.error,
384
+ children: validationMessage
385
+ }),
386
+ canShowInfo && /* @__PURE__ */ jsx(HvInfoMessage, {
387
+ disableGutter: true,
388
+ variant: "caption1",
389
+ children: infoMessage
390
+ })
391
+ ]
392
+ });
467
393
  });
468
- export {
469
- HvInput,
470
- staticClasses as inputClasses
471
- };
394
+ //#endregion
395
+ export { HvInput };