@itwin/itwinui-react 3.0.4 → 3.0.6

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 (500) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/cjs/core/Alert/Alert.js +46 -106
  3. package/cjs/core/Avatar/Avatar.js +21 -58
  4. package/cjs/core/AvatarGroup/AvatarGroup.js +26 -64
  5. package/cjs/core/Backdrop/Backdrop.js +8 -16
  6. package/cjs/core/Badge/Badge.js +22 -39
  7. package/cjs/core/Breadcrumbs/Breadcrumbs.js +61 -138
  8. package/cjs/core/ButtonGroup/ButtonGroup.js +32 -68
  9. package/cjs/core/Buttons/Button.js +11 -57
  10. package/cjs/core/Buttons/DropdownButton.js +15 -49
  11. package/cjs/core/Buttons/IconButton.js +13 -53
  12. package/cjs/core/Buttons/IdeasButton.js +8 -20
  13. package/cjs/core/Buttons/SplitButton.js +43 -103
  14. package/cjs/core/Carousel/Carousel.js +54 -78
  15. package/cjs/core/Carousel/CarouselContext.js +4 -4
  16. package/cjs/core/Carousel/CarouselDot.js +12 -23
  17. package/cjs/core/Carousel/CarouselDotsList.js +92 -153
  18. package/cjs/core/Carousel/CarouselNavigation.js +41 -84
  19. package/cjs/core/Carousel/CarouselSlide.js +26 -49
  20. package/cjs/core/Carousel/CarouselSlider.js +47 -66
  21. package/cjs/core/Checkbox/Checkbox.js +32 -88
  22. package/cjs/core/ColorPicker/ColorBuilder.js +174 -292
  23. package/cjs/core/ColorPicker/ColorInputPanel.js +246 -411
  24. package/cjs/core/ColorPicker/ColorPalette.js +23 -47
  25. package/cjs/core/ColorPicker/ColorPicker.js +53 -87
  26. package/cjs/core/ColorPicker/ColorPickerContext.js +9 -11
  27. package/cjs/core/ColorPicker/ColorSwatch.js +15 -40
  28. package/cjs/core/ComboBox/ComboBox.js +280 -402
  29. package/cjs/core/ComboBox/ComboBoxEndIcon.js +12 -28
  30. package/cjs/core/ComboBox/ComboBoxInput.js +131 -207
  31. package/cjs/core/ComboBox/ComboBoxInputContainer.js +12 -35
  32. package/cjs/core/ComboBox/ComboBoxMenu.js +43 -87
  33. package/cjs/core/ComboBox/ComboBoxMenuItem.js +21 -73
  34. package/cjs/core/ComboBox/ComboBoxMultipleContainer.js +7 -13
  35. package/cjs/core/ComboBox/helpers.js +43 -47
  36. package/cjs/core/DatePicker/DatePicker.js +333 -569
  37. package/cjs/core/Dialog/Dialog.js +36 -65
  38. package/cjs/core/Dialog/DialogBackdrop.js +27 -47
  39. package/cjs/core/Dialog/DialogButtonBar.js +3 -3
  40. package/cjs/core/Dialog/DialogContent.js +18 -26
  41. package/cjs/core/Dialog/DialogContext.js +5 -5
  42. package/cjs/core/Dialog/DialogDragContext.js +8 -8
  43. package/cjs/core/Dialog/DialogMain.js +137 -183
  44. package/cjs/core/Dialog/DialogTitleBar.js +20 -67
  45. package/cjs/core/Dialog/DialogTitleBarTitle.js +3 -3
  46. package/cjs/core/Divider/Divider.js +8 -14
  47. package/cjs/core/DropdownMenu/DropdownMenu.js +46 -80
  48. package/cjs/core/ExpandableBlock/ExpandableBlock.js +101 -206
  49. package/cjs/core/Fieldset/Fieldset.js +14 -25
  50. package/cjs/core/FileUpload/FileEmptyCard.js +17 -43
  51. package/cjs/core/FileUpload/FileUpload.js +42 -88
  52. package/cjs/core/FileUpload/FileUploadCard.js +84 -169
  53. package/cjs/core/FileUpload/FileUploadTemplate.js +16 -51
  54. package/cjs/core/Flex/Flex.js +77 -93
  55. package/cjs/core/Footer/Footer.js +64 -103
  56. package/cjs/core/Footer/FooterItem.js +3 -3
  57. package/cjs/core/Footer/FooterList.js +3 -3
  58. package/cjs/core/Footer/FooterSeparator.js +5 -8
  59. package/cjs/core/Header/Header.js +22 -67
  60. package/cjs/core/Header/HeaderBasicButton.js +13 -24
  61. package/cjs/core/Header/HeaderBreadcrumbs.js +14 -38
  62. package/cjs/core/Header/HeaderButton.js +22 -76
  63. package/cjs/core/Header/HeaderDropdownButton.js +20 -48
  64. package/cjs/core/Header/HeaderLogo.js +11 -42
  65. package/cjs/core/Header/HeaderSplitButton.js +21 -66
  66. package/cjs/core/Icon/Icon.js +18 -32
  67. package/cjs/core/InformationPanel/InformationPanel.js +42 -77
  68. package/cjs/core/InformationPanel/InformationPanelBody.js +4 -6
  69. package/cjs/core/InformationPanel/InformationPanelContent.js +8 -20
  70. package/cjs/core/InformationPanel/InformationPanelHeader.js +14 -34
  71. package/cjs/core/InformationPanel/InformationPanelWrapper.js +4 -6
  72. package/cjs/core/Input/Input.js +10 -18
  73. package/cjs/core/InputGrid/InputGrid.js +8 -17
  74. package/cjs/core/InputGroup/InputGroup.js +25 -72
  75. package/cjs/core/InputWithDecorations/InputWithDecorations.js +23 -51
  76. package/cjs/core/Label/Label.js +11 -32
  77. package/cjs/core/LabeledInput/LabeledInput.js +20 -70
  78. package/cjs/core/LabeledSelect/LabeledSelect.js +28 -77
  79. package/cjs/core/LabeledTextarea/LabeledTextarea.js +7 -13
  80. package/cjs/core/LinkAction/LinkAction.js +3 -3
  81. package/cjs/core/List/List.js +3 -3
  82. package/cjs/core/List/ListItem.js +35 -55
  83. package/cjs/core/Menu/Menu.js +53 -66
  84. package/cjs/core/Menu/MenuDivider.js +4 -4
  85. package/cjs/core/Menu/MenuExtraContent.js +4 -4
  86. package/cjs/core/Menu/MenuItem.js +92 -168
  87. package/cjs/core/Menu/MenuItemSkeleton.js +19 -54
  88. package/cjs/core/Modal/Modal.js +11 -38
  89. package/cjs/core/Modal/ModalButtonBar.js +4 -7
  90. package/cjs/core/Modal/ModalContent.js +3 -3
  91. package/cjs/core/NonIdealState/ErrorPage.js +131 -187
  92. package/cjs/core/NonIdealState/NonIdealState.js +12 -77
  93. package/cjs/core/NotificationMarker/NotificationMarker.js +8 -29
  94. package/cjs/core/Overlay/Overlay.d.ts +20 -24
  95. package/cjs/core/Overlay/Overlay.js +50 -64
  96. package/cjs/core/Popover/Popover.js +87 -157
  97. package/cjs/core/ProgressIndicators/ProgressLinear.js +11 -49
  98. package/cjs/core/ProgressIndicators/ProgressRadial.js +19 -51
  99. package/cjs/core/Radio/Radio.js +12 -54
  100. package/cjs/core/RadioTiles/RadioTile.js +14 -80
  101. package/cjs/core/RadioTiles/RadioTileGroup.js +9 -16
  102. package/cjs/core/SearchBox/SearchBox.js +104 -221
  103. package/cjs/core/Select/Select.js +141 -276
  104. package/cjs/core/Select/SelectTag.js +9 -21
  105. package/cjs/core/Select/SelectTagContainer.js +14 -30
  106. package/cjs/core/SideNavigation/SideNavigation.js +29 -138
  107. package/cjs/core/SideNavigation/SidenavButton.js +8 -30
  108. package/cjs/core/SideNavigation/SidenavSubmenu.js +9 -23
  109. package/cjs/core/SideNavigation/SidenavSubmenuHeader.js +10 -29
  110. package/cjs/core/SkipToContentLink/SkipToContentLink.js +8 -20
  111. package/cjs/core/Slider/Slider.js +195 -376
  112. package/cjs/core/Slider/Thumb.js +57 -108
  113. package/cjs/core/Slider/Track.js +55 -83
  114. package/cjs/core/StatusMessage/StatusMessage.js +12 -34
  115. package/cjs/core/Stepper/Stepper.js +21 -80
  116. package/cjs/core/Stepper/StepperStep.js +36 -109
  117. package/cjs/core/Stepper/WorkflowDiagram.js +15 -38
  118. package/cjs/core/Stepper/WorkflowDiagramStep.js +11 -39
  119. package/cjs/core/Surface/Surface.js +54 -94
  120. package/cjs/core/Table/SubRowExpander.js +15 -37
  121. package/cjs/core/Table/Table.js +419 -763
  122. package/cjs/core/Table/TableCell.js +63 -113
  123. package/cjs/core/Table/TablePaginator.js +136 -312
  124. package/cjs/core/Table/TableRowMemoized.js +64 -137
  125. package/cjs/core/Table/actionHandlers/expandHandler.js +12 -12
  126. package/cjs/core/Table/actionHandlers/filterHandler.js +17 -25
  127. package/cjs/core/Table/actionHandlers/index.js +14 -56
  128. package/cjs/core/Table/actionHandlers/resizeHandler.js +13 -13
  129. package/cjs/core/Table/actionHandlers/selectHandler.js +98 -128
  130. package/cjs/core/Table/cells/DefaultCell.js +13 -48
  131. package/cjs/core/Table/cells/EditableCell.js +46 -75
  132. package/cjs/core/Table/cells/index.js +6 -16
  133. package/cjs/core/Table/columns/actionColumn.js +67 -97
  134. package/cjs/core/Table/columns/expanderColumn.js +32 -46
  135. package/cjs/core/Table/columns/index.js +11 -41
  136. package/cjs/core/Table/columns/selectionColumn.js +29 -57
  137. package/cjs/core/Table/filters/BaseFilter.js +13 -24
  138. package/cjs/core/Table/filters/DateRangeFilter/DatePickerInput.js +52 -120
  139. package/cjs/core/Table/filters/DateRangeFilter/DateRangeFilter.js +60 -120
  140. package/cjs/core/Table/filters/FilterButtonBar.js +16 -39
  141. package/cjs/core/Table/filters/FilterToggle.js +26 -62
  142. package/cjs/core/Table/filters/NumberRangeFilter/NumberRangeFilter.js +36 -58
  143. package/cjs/core/Table/filters/TextFilter/TextFilter.js +28 -40
  144. package/cjs/core/Table/filters/customFilterFunctions.js +14 -16
  145. package/cjs/core/Table/filters/defaultFilterFunctions.js +81 -86
  146. package/cjs/core/Table/filters/index.js +11 -35
  147. package/cjs/core/Table/filters/tableFilters.js +32 -44
  148. package/cjs/core/Table/filters/types.js +2 -2
  149. package/cjs/core/Table/hooks/index.js +19 -67
  150. package/cjs/core/Table/hooks/useColumnDragAndDrop.js +86 -101
  151. package/cjs/core/Table/hooks/useExpanderCell.js +25 -33
  152. package/cjs/core/Table/hooks/useResizeColumns.js +290 -362
  153. package/cjs/core/Table/hooks/useScrollToRow.js +38 -46
  154. package/cjs/core/Table/hooks/useSelectionCell.js +10 -17
  155. package/cjs/core/Table/hooks/useStickyColumns.js +62 -64
  156. package/cjs/core/Table/hooks/useSubRowFiltering.js +88 -95
  157. package/cjs/core/Table/hooks/useSubRowSelection.js +31 -32
  158. package/cjs/core/Table/index.js +18 -78
  159. package/cjs/core/Table/utils.js +40 -42
  160. package/cjs/core/Tabs/Tabs.js +232 -417
  161. package/cjs/core/Tag/Tag.js +15 -42
  162. package/cjs/core/Tag/TagContainer.js +11 -23
  163. package/cjs/core/Textarea/Textarea.js +6 -11
  164. package/cjs/core/ThemeProvider/ThemeContext.js +4 -4
  165. package/cjs/core/ThemeProvider/ThemeProvider.js +52 -105
  166. package/cjs/core/Tile/Tile.js +230 -410
  167. package/cjs/core/TimePicker/TimePicker.js +234 -458
  168. package/cjs/core/Toast/Toast.js +107 -204
  169. package/cjs/core/Toast/Toaster.js +77 -102
  170. package/cjs/core/ToggleSwitch/ToggleSwitch.js +23 -66
  171. package/cjs/core/Tooltip/Tooltip.js +91 -137
  172. package/cjs/core/TransferList/TransferList.js +103 -177
  173. package/cjs/core/Tree/Tree.js +129 -204
  174. package/cjs/core/Tree/TreeContext.js +9 -9
  175. package/cjs/core/Tree/TreeNode.js +104 -207
  176. package/cjs/core/Tree/TreeNodeExpander.js +12 -26
  177. package/cjs/core/Typography/Anchor.js +3 -3
  178. package/cjs/core/Typography/Blockquote.js +10 -18
  179. package/cjs/core/Typography/Code.js +3 -3
  180. package/cjs/core/Typography/Kbd.js +21 -30
  181. package/cjs/core/Typography/Text.js +13 -26
  182. package/cjs/core/VisuallyHidden/VisuallyHidden.js +8 -14
  183. package/cjs/core/utils/color/ColorValue.js +453 -535
  184. package/cjs/core/utils/color/index.js +4 -4
  185. package/cjs/core/utils/components/AutoclearingHiddenLiveRegion.js +13 -20
  186. package/cjs/core/utils/components/Box.js +3 -3
  187. package/cjs/core/utils/components/ButtonBase.js +20 -38
  188. package/cjs/core/utils/components/FocusTrap.js +38 -47
  189. package/cjs/core/utils/components/InputContainer.js +19 -58
  190. package/cjs/core/utils/components/InputFlexContainer.js +8 -24
  191. package/cjs/core/utils/components/MiddleTextTruncation.js +22 -32
  192. package/cjs/core/utils/components/Portal.js +20 -22
  193. package/cjs/core/utils/components/Resizer.js +196 -253
  194. package/cjs/core/utils/components/VirtualScroll.js +223 -304
  195. package/cjs/core/utils/components/WithCSSTransition.js +32 -49
  196. package/cjs/core/utils/components/index.js +14 -14
  197. package/cjs/core/utils/functions/colors.js +22 -25
  198. package/cjs/core/utils/functions/date.js +10 -10
  199. package/cjs/core/utils/functions/dev.js +14 -13
  200. package/cjs/core/utils/functions/dom.d.ts +2 -1
  201. package/cjs/core/utils/functions/dom.js +22 -25
  202. package/cjs/core/utils/functions/focusable.js +17 -26
  203. package/cjs/core/utils/functions/import.js +23 -46
  204. package/cjs/core/utils/functions/index.js +13 -13
  205. package/cjs/core/utils/functions/numbers.d.ts +7 -0
  206. package/cjs/core/utils/functions/numbers.js +21 -10
  207. package/cjs/core/utils/functions/polymorphic.js +30 -43
  208. package/cjs/core/utils/functions/react.js +24 -26
  209. package/cjs/core/utils/functions/supports.js +4 -5
  210. package/cjs/core/utils/hooks/index.js +17 -17
  211. package/cjs/core/utils/hooks/useContainerWidth.js +19 -26
  212. package/cjs/core/utils/hooks/useControlledState.js +12 -21
  213. package/cjs/core/utils/hooks/useDragAndDrop.js +87 -110
  214. package/cjs/core/utils/hooks/useEventListener.js +22 -22
  215. package/cjs/core/utils/hooks/useGlobals.js +27 -33
  216. package/cjs/core/utils/hooks/useId.js +8 -10
  217. package/cjs/core/utils/hooks/useIntersection.js +24 -30
  218. package/cjs/core/utils/hooks/useIsClient.js +9 -9
  219. package/cjs/core/utils/hooks/useIsomorphicLayoutEffect.js +5 -6
  220. package/cjs/core/utils/hooks/useLatestRef.js +9 -9
  221. package/cjs/core/utils/hooks/useMediaQuery.js +31 -31
  222. package/cjs/core/utils/hooks/useMergedRefs.js +16 -15
  223. package/cjs/core/utils/hooks/useOverflow.js +57 -70
  224. package/cjs/core/utils/hooks/useResizeObserver.js +17 -22
  225. package/cjs/core/utils/hooks/useSafeContext.js +9 -9
  226. package/cjs/core/utils/icons/StatusIconMap.js +12 -28
  227. package/cjs/core/utils/icons/Svg.js +3 -3
  228. package/cjs/core/utils/icons/SvgCalendar.js +7 -12
  229. package/cjs/core/utils/icons/SvgCaretDownSmall.js +7 -12
  230. package/cjs/core/utils/icons/SvgCaretRightSmall.js +7 -12
  231. package/cjs/core/utils/icons/SvgCaretUpSmall.js +7 -12
  232. package/cjs/core/utils/icons/SvgCheckmark.js +7 -10
  233. package/cjs/core/utils/icons/SvgCheckmarkSmall.js +7 -12
  234. package/cjs/core/utils/icons/SvgChevronLeft.js +7 -12
  235. package/cjs/core/utils/icons/SvgChevronLeftDouble.js +7 -12
  236. package/cjs/core/utils/icons/SvgChevronRight.js +7 -12
  237. package/cjs/core/utils/icons/SvgChevronRightDouble.js +7 -12
  238. package/cjs/core/utils/icons/SvgClose.js +7 -12
  239. package/cjs/core/utils/icons/SvgCloseSmall.js +7 -12
  240. package/cjs/core/utils/icons/SvgColumnManager.js +7 -12
  241. package/cjs/core/utils/icons/SvgDocument.js +7 -10
  242. package/cjs/core/utils/icons/SvgFilter.js +7 -10
  243. package/cjs/core/utils/icons/SvgFilterHollow.js +7 -12
  244. package/cjs/core/utils/icons/SvgImportantSmall.js +7 -12
  245. package/cjs/core/utils/icons/SvgInfoCircular.js +7 -12
  246. package/cjs/core/utils/icons/SvgMore.js +7 -12
  247. package/cjs/core/utils/icons/SvgMoreVertical.js +7 -12
  248. package/cjs/core/utils/icons/SvgNew.js +7 -12
  249. package/cjs/core/utils/icons/SvgSearch.js +7 -12
  250. package/cjs/core/utils/icons/SvgSmileyHappy.js +7 -12
  251. package/cjs/core/utils/icons/SvgSortDown.js +7 -12
  252. package/cjs/core/utils/icons/SvgSortUp.js +7 -12
  253. package/cjs/core/utils/icons/SvgStatusError.js +7 -12
  254. package/cjs/core/utils/icons/SvgStatusSuccess.js +7 -12
  255. package/cjs/core/utils/icons/SvgStatusWarning.js +7 -12
  256. package/cjs/core/utils/icons/SvgSwap.js +7 -12
  257. package/cjs/core/utils/icons/SvgUpload.js +7 -12
  258. package/cjs/core/utils/icons/index.js +34 -34
  259. package/cjs/core/utils/index.js +10 -10
  260. package/cjs/core/utils/props.js +2 -2
  261. package/cjs/core/utils/types.js +2 -2
  262. package/cjs/index.js +229 -949
  263. package/cjs/react-table/react-table.js +2 -2
  264. package/cjs/styles.js +412 -425
  265. package/esm/core/Alert/Alert.js +39 -106
  266. package/esm/core/Avatar/Avatar.js +14 -42
  267. package/esm/core/AvatarGroup/AvatarGroup.js +20 -58
  268. package/esm/core/Backdrop/Backdrop.js +2 -10
  269. package/esm/core/Badge/Badge.js +16 -31
  270. package/esm/core/Breadcrumbs/Breadcrumbs.js +55 -135
  271. package/esm/core/ButtonGroup/ButtonGroup.js +25 -61
  272. package/esm/core/Buttons/Button.js +5 -45
  273. package/esm/core/Buttons/DropdownButton.js +7 -37
  274. package/esm/core/Buttons/IconButton.js +5 -40
  275. package/esm/core/Buttons/IdeasButton.js +2 -12
  276. package/esm/core/Buttons/SplitButton.js +34 -101
  277. package/esm/core/Carousel/Carousel.js +43 -72
  278. package/esm/core/Carousel/CarouselDot.js +6 -17
  279. package/esm/core/Carousel/CarouselDotsList.js +85 -147
  280. package/esm/core/Carousel/CarouselNavigation.js +32 -68
  281. package/esm/core/Carousel/CarouselSlide.js +19 -41
  282. package/esm/core/Carousel/CarouselSlider.js +41 -65
  283. package/esm/core/Checkbox/Checkbox.js +25 -78
  284. package/esm/core/ColorPicker/ColorBuilder.js +167 -280
  285. package/esm/core/ColorPicker/ColorInputPanel.js +237 -395
  286. package/esm/core/ColorPicker/ColorPalette.js +14 -35
  287. package/esm/core/ColorPicker/ColorPicker.js +46 -79
  288. package/esm/core/ColorPicker/ColorPickerContext.js +5 -7
  289. package/esm/core/ColorPicker/ColorSwatch.js +7 -24
  290. package/esm/core/ComboBox/ComboBox.js +267 -396
  291. package/esm/core/ComboBox/ComboBoxEndIcon.js +5 -18
  292. package/esm/core/ComboBox/ComboBoxInput.js +125 -197
  293. package/esm/core/ComboBox/ComboBoxInputContainer.js +5 -20
  294. package/esm/core/ComboBox/ComboBoxMenu.js +37 -77
  295. package/esm/core/ComboBox/ComboBoxMenuItem.js +14 -61
  296. package/esm/core/ComboBox/ComboBoxMultipleContainer.js +2 -6
  297. package/esm/core/ComboBox/helpers.js +38 -38
  298. package/esm/core/DatePicker/DatePicker.js +326 -555
  299. package/esm/core/Dialog/Dialog.js +24 -53
  300. package/esm/core/Dialog/DialogBackdrop.js +19 -39
  301. package/esm/core/Dialog/DialogContent.js +12 -20
  302. package/esm/core/Dialog/DialogContext.js +1 -1
  303. package/esm/core/Dialog/DialogDragContext.js +4 -4
  304. package/esm/core/Dialog/DialogMain.js +128 -177
  305. package/esm/core/Dialog/DialogTitleBar.js +10 -45
  306. package/esm/core/Divider/Divider.js +2 -8
  307. package/esm/core/DropdownMenu/DropdownMenu.js +40 -75
  308. package/esm/core/ExpandableBlock/ExpandableBlock.js +92 -193
  309. package/esm/core/Fieldset/Fieldset.js +8 -19
  310. package/esm/core/FileUpload/FileEmptyCard.js +8 -19
  311. package/esm/core/FileUpload/FileUpload.js +36 -72
  312. package/esm/core/FileUpload/FileUploadCard.js +76 -153
  313. package/esm/core/FileUpload/FileUploadTemplate.js +9 -37
  314. package/esm/core/Flex/Flex.js +71 -87
  315. package/esm/core/Footer/Footer.js +55 -86
  316. package/esm/core/Footer/FooterSeparator.js +1 -1
  317. package/esm/core/Header/Header.js +14 -55
  318. package/esm/core/Header/HeaderBasicButton.js +7 -15
  319. package/esm/core/Header/HeaderBreadcrumbs.js +8 -32
  320. package/esm/core/Header/HeaderButton.js +14 -62
  321. package/esm/core/Header/HeaderDropdownButton.js +13 -42
  322. package/esm/core/Header/HeaderLogo.js +5 -36
  323. package/esm/core/Header/HeaderSplitButton.js +14 -61
  324. package/esm/core/Icon/Icon.js +12 -26
  325. package/esm/core/InformationPanel/InformationPanel.js +36 -71
  326. package/esm/core/InformationPanel/InformationPanelContent.js +3 -17
  327. package/esm/core/InformationPanel/InformationPanelHeader.js +8 -32
  328. package/esm/core/InformationPanel/InformationPanelWrapper.js +1 -3
  329. package/esm/core/Input/Input.js +4 -12
  330. package/esm/core/InputGrid/InputGrid.js +2 -11
  331. package/esm/core/InputGroup/InputGroup.js +16 -57
  332. package/esm/core/InputWithDecorations/InputWithDecorations.js +11 -42
  333. package/esm/core/Label/Label.js +5 -26
  334. package/esm/core/LabeledInput/LabeledInput.js +10 -63
  335. package/esm/core/LabeledSelect/LabeledSelect.js +18 -67
  336. package/esm/core/LabeledTextarea/LabeledTextarea.js +2 -8
  337. package/esm/core/List/ListItem.js +28 -46
  338. package/esm/core/Menu/Menu.js +48 -64
  339. package/esm/core/Menu/MenuDivider.js +1 -1
  340. package/esm/core/Menu/MenuExtraContent.js +1 -1
  341. package/esm/core/Menu/MenuItem.js +84 -164
  342. package/esm/core/Menu/MenuItemSkeleton.js +12 -43
  343. package/esm/core/Modal/Modal.js +6 -33
  344. package/esm/core/NonIdealState/ErrorPage.js +123 -173
  345. package/esm/core/NonIdealState/NonIdealState.js +6 -65
  346. package/esm/core/NotificationMarker/NotificationMarker.js +2 -20
  347. package/esm/core/Overlay/Overlay.d.ts +20 -24
  348. package/esm/core/Overlay/Overlay.js +45 -55
  349. package/esm/core/Popover/Popover.js +80 -172
  350. package/esm/core/ProgressIndicators/ProgressLinear.js +5 -40
  351. package/esm/core/ProgressIndicators/ProgressRadial.js +14 -40
  352. package/esm/core/Radio/Radio.js +6 -45
  353. package/esm/core/RadioTiles/RadioTile.js +8 -62
  354. package/esm/core/RadioTiles/RadioTileGroup.js +3 -10
  355. package/esm/core/SearchBox/SearchBox.js +97 -214
  356. package/esm/core/Select/Select.js +130 -265
  357. package/esm/core/Select/SelectTag.js +3 -15
  358. package/esm/core/Select/SelectTagContainer.js +7 -20
  359. package/esm/core/SideNavigation/SideNavigation.js +21 -118
  360. package/esm/core/SideNavigation/SidenavButton.js +2 -24
  361. package/esm/core/SideNavigation/SidenavSubmenu.js +3 -14
  362. package/esm/core/SideNavigation/SidenavSubmenuHeader.js +4 -20
  363. package/esm/core/SkipToContentLink/SkipToContentLink.js +2 -11
  364. package/esm/core/Slider/Slider.js +187 -340
  365. package/esm/core/Slider/Thumb.js +50 -97
  366. package/esm/core/Slider/Track.js +49 -74
  367. package/esm/core/StatusMessage/StatusMessage.js +5 -23
  368. package/esm/core/Stepper/Stepper.js +14 -70
  369. package/esm/core/Stepper/StepperStep.js +29 -92
  370. package/esm/core/Stepper/WorkflowDiagram.js +8 -21
  371. package/esm/core/Stepper/WorkflowDiagramStep.js +4 -22
  372. package/esm/core/Surface/Surface.js +48 -84
  373. package/esm/core/Table/SubRowExpander.js +9 -31
  374. package/esm/core/Table/Table.js +408 -763
  375. package/esm/core/Table/TableCell.js +53 -87
  376. package/esm/core/Table/TablePaginator.js +125 -306
  377. package/esm/core/Table/TableRowMemoized.js +58 -129
  378. package/esm/core/Table/actionHandlers/expandHandler.js +10 -10
  379. package/esm/core/Table/actionHandlers/filterHandler.js +15 -23
  380. package/esm/core/Table/actionHandlers/index.js +1 -5
  381. package/esm/core/Table/actionHandlers/resizeHandler.js +11 -11
  382. package/esm/core/Table/actionHandlers/selectHandler.js +95 -122
  383. package/esm/core/Table/cells/DefaultCell.js +7 -42
  384. package/esm/core/Table/cells/EditableCell.js +41 -70
  385. package/esm/core/Table/columns/actionColumn.js +55 -85
  386. package/esm/core/Table/columns/expanderColumn.js +25 -39
  387. package/esm/core/Table/columns/selectionColumn.js +23 -51
  388. package/esm/core/Table/filters/BaseFilter.js +7 -15
  389. package/esm/core/Table/filters/DateRangeFilter/DatePickerInput.js +42 -107
  390. package/esm/core/Table/filters/DateRangeFilter/DateRangeFilter.js +52 -110
  391. package/esm/core/Table/filters/FilterButtonBar.js +9 -28
  392. package/esm/core/Table/filters/FilterToggle.js +18 -51
  393. package/esm/core/Table/filters/NumberRangeFilter/NumberRangeFilter.js +28 -50
  394. package/esm/core/Table/filters/TextFilter/TextFilter.js +20 -32
  395. package/esm/core/Table/filters/customFilterFunctions.js +12 -14
  396. package/esm/core/Table/filters/defaultFilterFunctions.js +79 -84
  397. package/esm/core/Table/filters/tableFilters.js +25 -34
  398. package/esm/core/Table/hooks/useColumnDragAndDrop.js +81 -88
  399. package/esm/core/Table/hooks/useExpanderCell.js +20 -26
  400. package/esm/core/Table/hooks/useResizeColumns.js +287 -353
  401. package/esm/core/Table/hooks/useScrollToRow.js +34 -42
  402. package/esm/core/Table/hooks/useSelectionCell.js +6 -10
  403. package/esm/core/Table/hooks/useStickyColumns.js +59 -61
  404. package/esm/core/Table/hooks/useSubRowFiltering.js +83 -90
  405. package/esm/core/Table/hooks/useSubRowSelection.js +27 -28
  406. package/esm/core/Table/index.js +1 -5
  407. package/esm/core/Table/utils.js +38 -40
  408. package/esm/core/Tabs/Tabs.js +226 -401
  409. package/esm/core/Tag/Tag.js +8 -35
  410. package/esm/core/Tag/TagContainer.js +5 -17
  411. package/esm/core/Textarea/Textarea.js +1 -6
  412. package/esm/core/ThemeProvider/ThemeProvider.js +44 -101
  413. package/esm/core/Tile/Tile.js +218 -386
  414. package/esm/core/TimePicker/TimePicker.js +228 -448
  415. package/esm/core/Toast/Toast.js +99 -193
  416. package/esm/core/Toast/Toaster.js +69 -82
  417. package/esm/core/ToggleSwitch/ToggleSwitch.js +17 -60
  418. package/esm/core/Tooltip/Tooltip.js +86 -151
  419. package/esm/core/TransferList/TransferList.js +93 -157
  420. package/esm/core/Tree/Tree.js +122 -196
  421. package/esm/core/Tree/TreeContext.js +5 -5
  422. package/esm/core/Tree/TreeNode.js +96 -195
  423. package/esm/core/Tree/TreeNodeExpander.js +5 -16
  424. package/esm/core/Typography/Blockquote.js +4 -12
  425. package/esm/core/Typography/Kbd.js +15 -24
  426. package/esm/core/Typography/Text.js +7 -20
  427. package/esm/core/VisuallyHidden/VisuallyHidden.js +2 -8
  428. package/esm/core/utils/color/ColorValue.js +449 -524
  429. package/esm/core/utils/components/AutoclearingHiddenLiveRegion.js +7 -11
  430. package/esm/core/utils/components/ButtonBase.js +13 -31
  431. package/esm/core/utils/components/FocusTrap.js +32 -41
  432. package/esm/core/utils/components/InputContainer.js +11 -50
  433. package/esm/core/utils/components/InputFlexContainer.js +2 -15
  434. package/esm/core/utils/components/MiddleTextTruncation.js +17 -27
  435. package/esm/core/utils/components/Portal.js +12 -12
  436. package/esm/core/utils/components/Resizer.js +192 -250
  437. package/esm/core/utils/components/VirtualScroll.js +218 -297
  438. package/esm/core/utils/components/WithCSSTransition.js +26 -43
  439. package/esm/core/utils/functions/colors.js +19 -19
  440. package/esm/core/utils/functions/date.js +8 -8
  441. package/esm/core/utils/functions/dev.js +12 -11
  442. package/esm/core/utils/functions/dom.d.ts +2 -1
  443. package/esm/core/utils/functions/dom.js +18 -18
  444. package/esm/core/utils/functions/focusable.js +15 -24
  445. package/esm/core/utils/functions/import.js +2 -4
  446. package/esm/core/utils/functions/numbers.d.ts +7 -0
  447. package/esm/core/utils/functions/numbers.js +17 -7
  448. package/esm/core/utils/functions/polymorphic.js +23 -32
  449. package/esm/core/utils/functions/react.js +19 -21
  450. package/esm/core/utils/functions/supports.js +1 -2
  451. package/esm/core/utils/hooks/useContainerWidth.js +13 -16
  452. package/esm/core/utils/hooks/useControlledState.js +8 -17
  453. package/esm/core/utils/hooks/useDragAndDrop.js +81 -100
  454. package/esm/core/utils/hooks/useEventListener.js +18 -18
  455. package/esm/core/utils/hooks/useGlobals.js +21 -27
  456. package/esm/core/utils/hooks/useId.js +3 -4
  457. package/esm/core/utils/hooks/useIntersection.js +19 -25
  458. package/esm/core/utils/hooks/useIsClient.js +5 -5
  459. package/esm/core/utils/hooks/useIsomorphicLayoutEffect.js +1 -2
  460. package/esm/core/utils/hooks/useLatestRef.js +5 -5
  461. package/esm/core/utils/hooks/useMediaQuery.js +25 -23
  462. package/esm/core/utils/hooks/useMergedRefs.js +12 -11
  463. package/esm/core/utils/hooks/useOverflow.js +51 -63
  464. package/esm/core/utils/hooks/useResizeObserver.js +12 -17
  465. package/esm/core/utils/hooks/useSafeContext.js +5 -5
  466. package/esm/core/utils/icons/StatusIconMap.js +4 -8
  467. package/esm/core/utils/icons/SvgCalendar.js +2 -7
  468. package/esm/core/utils/icons/SvgCaretDownSmall.js +2 -7
  469. package/esm/core/utils/icons/SvgCaretRightSmall.js +2 -7
  470. package/esm/core/utils/icons/SvgCaretUpSmall.js +2 -7
  471. package/esm/core/utils/icons/SvgCheckmark.js +2 -5
  472. package/esm/core/utils/icons/SvgCheckmarkSmall.js +2 -7
  473. package/esm/core/utils/icons/SvgChevronLeft.js +2 -7
  474. package/esm/core/utils/icons/SvgChevronLeftDouble.js +2 -7
  475. package/esm/core/utils/icons/SvgChevronRight.js +2 -7
  476. package/esm/core/utils/icons/SvgChevronRightDouble.js +2 -7
  477. package/esm/core/utils/icons/SvgClose.js +2 -7
  478. package/esm/core/utils/icons/SvgCloseSmall.js +2 -7
  479. package/esm/core/utils/icons/SvgColumnManager.js +2 -7
  480. package/esm/core/utils/icons/SvgDocument.js +2 -5
  481. package/esm/core/utils/icons/SvgFilter.js +2 -5
  482. package/esm/core/utils/icons/SvgFilterHollow.js +2 -7
  483. package/esm/core/utils/icons/SvgImportantSmall.js +2 -7
  484. package/esm/core/utils/icons/SvgInfoCircular.js +2 -7
  485. package/esm/core/utils/icons/SvgMore.js +2 -7
  486. package/esm/core/utils/icons/SvgMoreVertical.js +2 -7
  487. package/esm/core/utils/icons/SvgNew.js +2 -7
  488. package/esm/core/utils/icons/SvgSearch.js +2 -7
  489. package/esm/core/utils/icons/SvgSmileyHappy.js +2 -7
  490. package/esm/core/utils/icons/SvgSortDown.js +2 -7
  491. package/esm/core/utils/icons/SvgSortUp.js +2 -7
  492. package/esm/core/utils/icons/SvgStatusError.js +2 -7
  493. package/esm/core/utils/icons/SvgStatusSuccess.js +2 -7
  494. package/esm/core/utils/icons/SvgStatusWarning.js +2 -7
  495. package/esm/core/utils/icons/SvgSwap.js +2 -7
  496. package/esm/core/utils/icons/SvgUpload.js +2 -7
  497. package/esm/index.js +3 -21
  498. package/esm/styles.js +414 -425
  499. package/package.json +2 -2
  500. package/styles.css +6 -6
@@ -1,114 +1,112 @@
1
- 'use strict';
2
- Object.defineProperty(exports, '__esModule', { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DatePicker = exports.generateLocalizedStrings = void 0;
4
- const tslib_1 = require('tslib');
4
+ const tslib_1 = require("tslib");
5
5
  /*---------------------------------------------------------------------------------------------
6
6
  * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
7
7
  * See LICENSE.md in the project root for license terms and full copyright notice.
8
8
  *--------------------------------------------------------------------------------------------*/
9
- const classnames_1 = tslib_1.__importDefault(require('classnames'));
10
- const React = tslib_1.__importStar(require('react'));
11
- const index_js_1 = require('../utils/index.js');
12
- const IconButton_js_1 = require('../Buttons/IconButton.js');
13
- const TimePicker_js_1 = require('../TimePicker/TimePicker.js');
9
+ const classnames_1 = tslib_1.__importDefault(require("classnames"));
10
+ const React = tslib_1.__importStar(require("react"));
11
+ const index_js_1 = require("../utils/index.js");
12
+ const IconButton_js_1 = require("../Buttons/IconButton.js");
13
+ const TimePicker_js_1 = require("../TimePicker/TimePicker.js");
14
14
  const isSameDay = (a, b) => {
15
- return (
16
- a &&
17
- b &&
18
- a.getFullYear() === b.getFullYear() &&
19
- a.getMonth() === b.getMonth() &&
20
- a.getDate() === b.getDate()
21
- );
15
+ return (a &&
16
+ b &&
17
+ a.getFullYear() === b.getFullYear() &&
18
+ a.getMonth() === b.getMonth() &&
19
+ a.getDate() === b.getDate());
22
20
  };
23
21
  const isInDateRange = (date, startDate, endDate) => {
24
- if (!date || !startDate || !endDate) {
25
- return false;
26
- }
27
- const minDate = new Date(startDate);
28
- const maxDate = new Date(endDate);
29
- const testDate = new Date(date);
30
- testDate && testDate.setHours(0, 0, 0, 0);
31
- minDate && minDate.setHours(0, 0, 0, 0);
32
- maxDate && maxDate.setHours(0, 0, 0, 0);
33
- return testDate > minDate && testDate < maxDate;
22
+ if (!date || !startDate || !endDate) {
23
+ return false;
24
+ }
25
+ const minDate = new Date(startDate);
26
+ const maxDate = new Date(endDate);
27
+ const testDate = new Date(date);
28
+ testDate && testDate.setHours(0, 0, 0, 0);
29
+ minDate && minDate.setHours(0, 0, 0, 0);
30
+ maxDate && maxDate.setHours(0, 0, 0, 0);
31
+ return testDate > minDate && testDate < maxDate;
34
32
  };
35
33
  // Type guard for multiple did not work
36
34
  const isSingleOnChange = (onChange, enableRangeSelect) => {
37
- return !enableRangeSelect;
35
+ return !enableRangeSelect;
38
36
  };
39
37
  const defaultMonths = [
40
- 'January',
41
- 'February',
42
- 'March',
43
- 'April',
44
- 'May',
45
- 'June',
46
- 'July',
47
- 'August',
48
- 'September',
49
- 'October',
50
- 'November',
51
- 'December',
38
+ 'January',
39
+ 'February',
40
+ 'March',
41
+ 'April',
42
+ 'May',
43
+ 'June',
44
+ 'July',
45
+ 'August',
46
+ 'September',
47
+ 'October',
48
+ 'November',
49
+ 'December',
52
50
  ];
53
51
  const defaultShortDays = ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'];
54
52
  const defaultLongDays = [
55
- 'Sunday',
56
- 'Monday',
57
- 'Tuesday',
58
- 'Wednesday',
59
- 'Thursday',
60
- 'Friday',
61
- 'Saturday',
53
+ 'Sunday',
54
+ 'Monday',
55
+ 'Tuesday',
56
+ 'Wednesday',
57
+ 'Thursday',
58
+ 'Friday',
59
+ 'Saturday',
62
60
  ];
63
61
  /**
64
62
  * Generate localized months and days strings using `Intl.DateTimeFormat` for passed locale to use in DatePicker component.
65
63
  * If locale is not passed, browser locale will be used.
66
64
  */
67
65
  const generateLocalizedStrings = (locale) => {
68
- const shortWeekDayFormatter = new Intl.DateTimeFormat(locale, {
69
- weekday: 'short',
70
- });
71
- const longWeekDayFormatter = new Intl.DateTimeFormat(locale, {
72
- weekday: 'long',
73
- });
74
- const monthFormatter = new Intl.DateTimeFormat(locale, { month: 'long' });
75
- const months = [
76
- monthFormatter.format(new Date(2020, 0, 1)),
77
- monthFormatter.format(new Date(2020, 1, 1)),
78
- monthFormatter.format(new Date(2020, 2, 1)),
79
- monthFormatter.format(new Date(2020, 3, 1)),
80
- monthFormatter.format(new Date(2020, 4, 1)),
81
- monthFormatter.format(new Date(2020, 5, 1)),
82
- monthFormatter.format(new Date(2020, 6, 1)),
83
- monthFormatter.format(new Date(2020, 7, 1)),
84
- monthFormatter.format(new Date(2020, 8, 1)),
85
- monthFormatter.format(new Date(2020, 9, 1)),
86
- monthFormatter.format(new Date(2020, 10, 1)),
87
- monthFormatter.format(new Date(2020, 11, 1)),
88
- ];
89
- const days = [
90
- longWeekDayFormatter.format(new Date(2020, 10, 1)),
91
- longWeekDayFormatter.format(new Date(2020, 10, 2)),
92
- longWeekDayFormatter.format(new Date(2020, 10, 3)),
93
- longWeekDayFormatter.format(new Date(2020, 10, 4)),
94
- longWeekDayFormatter.format(new Date(2020, 10, 5)),
95
- longWeekDayFormatter.format(new Date(2020, 10, 6)),
96
- longWeekDayFormatter.format(new Date(2020, 10, 7)),
97
- ];
98
- const shortDays = [
99
- shortWeekDayFormatter.format(new Date(2020, 10, 1)).slice(0, 2),
100
- shortWeekDayFormatter.format(new Date(2020, 10, 2)).slice(0, 2),
101
- shortWeekDayFormatter.format(new Date(2020, 10, 3)).slice(0, 2),
102
- shortWeekDayFormatter.format(new Date(2020, 10, 4)).slice(0, 2),
103
- shortWeekDayFormatter.format(new Date(2020, 10, 5)).slice(0, 2),
104
- shortWeekDayFormatter.format(new Date(2020, 10, 6)).slice(0, 2),
105
- shortWeekDayFormatter.format(new Date(2020, 10, 7)).slice(0, 2),
106
- ];
107
- return {
108
- months,
109
- shortDays,
110
- days,
111
- };
66
+ const shortWeekDayFormatter = new Intl.DateTimeFormat(locale, {
67
+ weekday: 'short',
68
+ });
69
+ const longWeekDayFormatter = new Intl.DateTimeFormat(locale, {
70
+ weekday: 'long',
71
+ });
72
+ const monthFormatter = new Intl.DateTimeFormat(locale, { month: 'long' });
73
+ const months = [
74
+ monthFormatter.format(new Date(2020, 0, 1)),
75
+ monthFormatter.format(new Date(2020, 1, 1)),
76
+ monthFormatter.format(new Date(2020, 2, 1)),
77
+ monthFormatter.format(new Date(2020, 3, 1)),
78
+ monthFormatter.format(new Date(2020, 4, 1)),
79
+ monthFormatter.format(new Date(2020, 5, 1)),
80
+ monthFormatter.format(new Date(2020, 6, 1)),
81
+ monthFormatter.format(new Date(2020, 7, 1)),
82
+ monthFormatter.format(new Date(2020, 8, 1)),
83
+ monthFormatter.format(new Date(2020, 9, 1)),
84
+ monthFormatter.format(new Date(2020, 10, 1)),
85
+ monthFormatter.format(new Date(2020, 11, 1)),
86
+ ];
87
+ const days = [
88
+ longWeekDayFormatter.format(new Date(2020, 10, 1)),
89
+ longWeekDayFormatter.format(new Date(2020, 10, 2)),
90
+ longWeekDayFormatter.format(new Date(2020, 10, 3)),
91
+ longWeekDayFormatter.format(new Date(2020, 10, 4)),
92
+ longWeekDayFormatter.format(new Date(2020, 10, 5)),
93
+ longWeekDayFormatter.format(new Date(2020, 10, 6)),
94
+ longWeekDayFormatter.format(new Date(2020, 10, 7)),
95
+ ];
96
+ const shortDays = [
97
+ shortWeekDayFormatter.format(new Date(2020, 10, 1)).slice(0, 2),
98
+ shortWeekDayFormatter.format(new Date(2020, 10, 2)).slice(0, 2),
99
+ shortWeekDayFormatter.format(new Date(2020, 10, 3)).slice(0, 2),
100
+ shortWeekDayFormatter.format(new Date(2020, 10, 4)).slice(0, 2),
101
+ shortWeekDayFormatter.format(new Date(2020, 10, 5)).slice(0, 2),
102
+ shortWeekDayFormatter.format(new Date(2020, 10, 6)).slice(0, 2),
103
+ shortWeekDayFormatter.format(new Date(2020, 10, 7)).slice(0, 2),
104
+ ];
105
+ return {
106
+ months,
107
+ shortDays,
108
+ days,
109
+ };
112
110
  };
113
111
  exports.generateLocalizedStrings = generateLocalizedStrings;
114
112
  /**
@@ -117,490 +115,256 @@ exports.generateLocalizedStrings = generateLocalizedStrings;
117
115
  * <DatePicker date={new Date()} onChange={(e) => console.log('New date value: ' + e)} />
118
116
  */
119
117
  exports.DatePicker = React.forwardRef((props, forwardedRef) => {
120
- const {
121
- date,
122
- onChange,
123
- localizedNames,
124
- className,
125
- setFocus = false,
126
- showTime = false,
127
- use12Hours = false,
128
- precision,
129
- hourStep,
130
- minuteStep,
131
- secondStep,
132
- useCombinedRenderer,
133
- combinedRenderer,
134
- hourRenderer,
135
- minuteRenderer,
136
- secondRenderer,
137
- meridiemRenderer,
138
- showYearSelection = false,
139
- enableRangeSelect = false,
140
- startDate,
141
- endDate,
142
- monthYearProps,
143
- calendarProps,
144
- monthProps,
145
- weekDayProps,
146
- dayProps,
147
- weekProps,
148
- isDateDisabled,
149
- applyBackground = true,
150
- ...rest
151
- } = props;
152
- const monthNames = localizedNames?.months ?? defaultMonths;
153
- const shortDays = localizedNames?.shortDays ?? defaultShortDays;
154
- const longDays = localizedNames?.days ?? defaultLongDays;
155
- const [selectedDay, setSelectedDay] = React.useState(date);
156
- const [selectedStartDay, setSelectedStartDay] = React.useState(startDate);
157
- const [selectedEndDay, setSelectedEndDay] = React.useState(endDate);
158
- const [focusedDay, setFocusedDay] = React.useState(
159
- selectedStartDay ?? selectedDay ?? new Date(),
160
- );
161
- const [displayedMonthIndex, setDisplayedMonthIndex] = React.useState(
162
- selectedStartDay?.getMonth() ??
163
- selectedDay?.getMonth() ??
164
- new Date().getMonth(),
165
- );
166
- const [displayedYear, setDisplayedYear] = React.useState(
167
- selectedStartDay?.getFullYear() ??
168
- selectedDay?.getFullYear() ??
169
- new Date().getFullYear(),
170
- );
171
- // boolean that toggles between the user picking the start date and end date for date range
172
- const [isSelectingStartDate, setIsSelectingStartDate] = React.useState(true);
173
- // Used to focus days only when days are changed
174
- // e.g. without this, when changing months day would be focused
175
- const needFocus = React.useRef(setFocus);
176
- React.useEffect(() => {
177
- if (needFocus.current) {
178
- needFocus.current = false;
179
- }
180
- });
181
- const setMonthAndYear = React.useCallback((newMonth, newYear) => {
182
- setDisplayedMonthIndex(newMonth);
183
- setDisplayedYear(newYear);
184
- }, []);
185
- React.useEffect(() => {
186
- const currentDate = new Date();
187
- setSelectedDay(date);
188
- setSelectedStartDay(startDate);
189
- setSelectedEndDay(endDate);
190
- if (!enableRangeSelect) {
191
- setFocusedDay(date ?? currentDate);
192
- }
193
- setMonthAndYear(
194
- startDate?.getMonth() ?? date?.getMonth() ?? currentDate.getMonth(),
195
- startDate?.getFullYear() ??
196
- date?.getFullYear() ??
197
- currentDate.getFullYear(),
198
- );
199
- }, [date, setMonthAndYear, startDate, endDate, enableRangeSelect]);
200
- const days = React.useMemo(() => {
201
- let offsetToFirst = new Date(
202
- displayedYear,
203
- displayedMonthIndex,
204
- 1,
205
- ).getDay();
206
- // if its sunday, show one week before
207
- if (0 === offsetToFirst) {
208
- offsetToFirst = 7;
209
- }
210
- const daysInMonth = [];
211
- // generate 6 weeks of dates
212
- for (let i = 1; i <= 42; i++) {
213
- const adjustedDay = i - offsetToFirst;
214
- daysInMonth.push(
215
- new Date(displayedYear, displayedMonthIndex, adjustedDay),
216
- );
217
- }
218
- return daysInMonth;
219
- }, [displayedMonthIndex, displayedYear]);
220
- const weeks = React.useMemo(() => {
221
- const weeksInMonth = [];
222
- const weekCount = Math.ceil(days.length / 7);
223
- for (let i = 0; i < weekCount; i++) {
224
- weeksInMonth.push(days.slice(i * 7, (i + 1) * 7));
225
- }
226
- return weeksInMonth;
227
- }, [days]);
228
- const getNewFocusedDate = (newYear, newMonth) => {
229
- const currentDate = selectedStartDay ?? selectedDay ?? new Date();
230
- const newDate = new Date(
231
- newYear,
232
- newMonth,
233
- currentDate.getDate(),
234
- currentDate.getHours(),
235
- currentDate.getMinutes(),
236
- currentDate.getSeconds(),
237
- );
238
- return newDate;
239
- };
240
- const handleMoveToPreviousYear = () => {
241
- const newYear = displayedYear - 1;
242
- setMonthAndYear(displayedMonthIndex, newYear);
243
- setFocusedDay(getNewFocusedDate(newYear, displayedMonthIndex));
244
- };
245
- const handleMoveToNextYear = () => {
246
- const newYear = displayedYear + 1;
247
- setMonthAndYear(displayedMonthIndex, newYear);
248
- setFocusedDay(getNewFocusedDate(newYear, displayedMonthIndex));
249
- };
250
- const handleMoveToPreviousMonth = () => {
251
- const newMonth = displayedMonthIndex !== 0 ? displayedMonthIndex - 1 : 11;
252
- const newYear =
253
- displayedMonthIndex !== 0 ? displayedYear : displayedYear - 1;
254
- setMonthAndYear(newMonth, newYear);
255
- setFocusedDay(getNewFocusedDate(newYear, newMonth));
256
- };
257
- const handleMoveToNextMonth = () => {
258
- const newMonth = displayedMonthIndex !== 11 ? displayedMonthIndex + 1 : 0;
259
- const newYear =
260
- displayedMonthIndex !== 11 ? displayedYear : displayedYear + 1;
261
- setMonthAndYear(newMonth, newYear);
262
- setFocusedDay(getNewFocusedDate(newYear, newMonth));
263
- };
264
- const onDayClick = (day) => {
265
- // single date selection
266
- if (!enableRangeSelect) {
267
- if (day.getMonth() !== selectedDay?.getMonth()) {
268
- setMonthAndYear(day.getMonth(), day.getFullYear());
269
- }
270
- const currentDate = selectedDay ?? new Date();
271
- const newDate = new Date(
272
- day.getFullYear(),
273
- day.getMonth(),
274
- day.getDate(),
275
- currentDate.getHours(),
276
- currentDate.getMinutes(),
277
- currentDate.getSeconds(),
278
- );
279
- setSelectedDay(newDate);
280
- setFocusedDay(newDate);
281
- isSingleOnChange(onChange, enableRangeSelect) && onChange?.(newDate);
282
- }
283
- // start date selection (date range only)
284
- else if (isSelectingStartDate) {
285
- if (day.getMonth() !== selectedStartDay?.getMonth()) {
286
- setMonthAndYear(day.getMonth(), day.getFullYear());
287
- }
288
- const currentStartDate = selectedStartDay ?? new Date();
289
- const newStartDate = new Date(
290
- day.getFullYear(),
291
- day.getMonth(),
292
- day.getDate(),
293
- currentStartDate.getHours(),
294
- currentStartDate.getMinutes(),
295
- currentStartDate.getSeconds(),
296
- );
297
- setSelectedStartDay(newStartDate);
298
- setFocusedDay(newStartDate);
299
- // if the start date is after the end date or the end date is undefined, reset the end date
300
- if (!(0, index_js_1.isBefore)(newStartDate, selectedEndDay)) {
301
- setSelectedEndDay(newStartDate);
302
- onChange?.(newStartDate, newStartDate);
303
- } else {
304
- selectedEndDay && onChange?.(newStartDate, selectedEndDay);
305
- }
306
- setIsSelectingStartDate(false);
307
- }
308
- // end date selection (date range only)
309
- else {
310
- if (day.getMonth() !== selectedEndDay?.getMonth()) {
311
- setMonthAndYear(day.getMonth(), day.getFullYear());
312
- }
313
- const currentEndDate = selectedEndDay ?? new Date();
314
- const newEndDate = new Date(
315
- day.getFullYear(),
316
- day.getMonth(),
317
- day.getDate(),
318
- currentEndDate.getHours(),
319
- currentEndDate.getMinutes(),
320
- currentEndDate.getSeconds(),
321
- );
322
- setFocusedDay(newEndDate);
323
- // if the end date is before the start date, move back the start date and still have user select end date
324
- if (!(0, index_js_1.isBefore)(newEndDate, selectedStartDay)) {
325
- setSelectedEndDay(newEndDate);
326
- selectedStartDay && onChange?.(selectedStartDay, newEndDate);
327
- setIsSelectingStartDate(true);
328
- } else {
329
- setSelectedStartDay(newEndDate);
330
- selectedEndDay && onChange?.(newEndDate, selectedEndDay);
331
- }
332
- }
333
- };
334
- const handleCalendarKeyDown = (event) => {
335
- if (event.altKey) {
336
- return;
337
- }
338
- if (!focusedDay) {
339
- return;
340
- }
341
- const adjustedFocusedDay = new Date(focusedDay);
342
- switch (event.key) {
343
- case 'ArrowDown':
344
- adjustedFocusedDay.setDate(focusedDay.getDate() + 7);
345
- if (adjustedFocusedDay.getMonth() !== displayedMonthIndex) {
346
- handleMoveToNextMonth();
118
+ const { date, onChange, localizedNames, className, setFocus = false, showTime = false, use12Hours = false, precision, hourStep, minuteStep, secondStep, useCombinedRenderer, combinedRenderer, hourRenderer, minuteRenderer, secondRenderer, meridiemRenderer, showYearSelection = false, enableRangeSelect = false, startDate, endDate, monthYearProps, calendarProps, monthProps, weekDayProps, dayProps, weekProps, isDateDisabled, applyBackground = true, ...rest } = props;
119
+ const monthNames = localizedNames?.months ?? defaultMonths;
120
+ const shortDays = localizedNames?.shortDays ?? defaultShortDays;
121
+ const longDays = localizedNames?.days ?? defaultLongDays;
122
+ const [selectedDay, setSelectedDay] = React.useState(date);
123
+ const [selectedStartDay, setSelectedStartDay] = React.useState(startDate);
124
+ const [selectedEndDay, setSelectedEndDay] = React.useState(endDate);
125
+ const [focusedDay, setFocusedDay] = React.useState(selectedStartDay ?? selectedDay ?? new Date());
126
+ const [displayedMonthIndex, setDisplayedMonthIndex] = React.useState(selectedStartDay?.getMonth() ??
127
+ selectedDay?.getMonth() ??
128
+ new Date().getMonth());
129
+ const [displayedYear, setDisplayedYear] = React.useState(selectedStartDay?.getFullYear() ??
130
+ selectedDay?.getFullYear() ??
131
+ new Date().getFullYear());
132
+ // boolean that toggles between the user picking the start date and end date for date range
133
+ const [isSelectingStartDate, setIsSelectingStartDate] = React.useState(true);
134
+ // Used to focus days only when days are changed
135
+ // e.g. without this, when changing months day would be focused
136
+ const needFocus = React.useRef(setFocus);
137
+ React.useEffect(() => {
138
+ if (needFocus.current) {
139
+ needFocus.current = false;
347
140
  }
348
- setFocusedDay(adjustedFocusedDay);
349
- needFocus.current = true;
350
- event.preventDefault();
351
- break;
352
- case 'ArrowUp':
353
- adjustedFocusedDay.setDate(focusedDay.getDate() - 7);
354
- if (adjustedFocusedDay.getMonth() !== displayedMonthIndex) {
355
- handleMoveToPreviousMonth();
141
+ });
142
+ const setMonthAndYear = React.useCallback((newMonth, newYear) => {
143
+ setDisplayedMonthIndex(newMonth);
144
+ setDisplayedYear(newYear);
145
+ }, []);
146
+ React.useEffect(() => {
147
+ const currentDate = new Date();
148
+ setSelectedDay(date);
149
+ setSelectedStartDay(startDate);
150
+ setSelectedEndDay(endDate);
151
+ if (!enableRangeSelect) {
152
+ setFocusedDay(date ?? currentDate);
356
153
  }
357
- setFocusedDay(adjustedFocusedDay);
358
- needFocus.current = true;
359
- event.preventDefault();
360
- break;
361
- case 'ArrowLeft':
362
- adjustedFocusedDay.setDate(focusedDay.getDate() - 1);
363
- if (adjustedFocusedDay.getMonth() !== displayedMonthIndex) {
364
- handleMoveToPreviousMonth();
154
+ setMonthAndYear(startDate?.getMonth() ?? date?.getMonth() ?? currentDate.getMonth(), startDate?.getFullYear() ??
155
+ date?.getFullYear() ??
156
+ currentDate.getFullYear());
157
+ }, [date, setMonthAndYear, startDate, endDate, enableRangeSelect]);
158
+ const days = React.useMemo(() => {
159
+ let offsetToFirst = new Date(displayedYear, displayedMonthIndex, 1).getDay();
160
+ // if its sunday, show one week before
161
+ if (0 === offsetToFirst) {
162
+ offsetToFirst = 7;
365
163
  }
366
- setFocusedDay(adjustedFocusedDay);
367
- needFocus.current = true;
368
- event.preventDefault();
369
- break;
370
- case 'ArrowRight':
371
- adjustedFocusedDay.setDate(focusedDay.getDate() + 1);
372
- if (adjustedFocusedDay.getMonth() !== displayedMonthIndex) {
373
- handleMoveToNextMonth();
164
+ const daysInMonth = [];
165
+ // generate 6 weeks of dates
166
+ for (let i = 1; i <= 42; i++) {
167
+ const adjustedDay = i - offsetToFirst;
168
+ daysInMonth.push(new Date(displayedYear, displayedMonthIndex, adjustedDay));
374
169
  }
375
- setFocusedDay(adjustedFocusedDay);
376
- needFocus.current = true;
377
- event.preventDefault();
378
- break;
379
- case 'Enter':
380
- case ' ':
381
- case 'Spacebar':
382
- if (!isDateDisabled?.(focusedDay)) {
383
- onDayClick(focusedDay);
170
+ return daysInMonth;
171
+ }, [displayedMonthIndex, displayedYear]);
172
+ const weeks = React.useMemo(() => {
173
+ const weeksInMonth = [];
174
+ const weekCount = Math.ceil(days.length / 7);
175
+ for (let i = 0; i < weekCount; i++) {
176
+ weeksInMonth.push(days.slice(i * 7, (i + 1) * 7));
384
177
  }
385
- event.preventDefault();
386
- break;
387
- }
388
- };
389
- const getDayClass = (day) => {
390
- if (day.getMonth() !== displayedMonthIndex) {
391
- return 'iui-calendar-day-outside-month';
392
- }
393
- let dayClass = 'iui-calendar-day';
394
- const isSelectedDay =
395
- isSameDay(day, selectedDay) ||
396
- (isSameDay(day, selectedStartDay) && isSameDay(day, selectedEndDay));
397
- if (isSelectedDay) {
398
- dayClass += '-selected';
399
- } else if (isSameDay(day, selectedStartDay)) {
400
- dayClass += '-range-start';
401
- } else if (isSameDay(day, selectedEndDay)) {
402
- dayClass += '-range-end';
403
- }
404
- // adds range class to dates between start and end date
405
- if (
406
- selectedStartDay &&
407
- selectedEndDay &&
408
- isInDateRange(day, selectedStartDay, selectedEndDay)
409
- ) {
410
- dayClass += '-range';
411
- }
412
- if (isSameDay(day, new Date())) {
413
- dayClass += '-today';
414
- }
415
- return dayClass;
416
- };
417
- const dateTableId = (0, index_js_1.useId)();
418
- return React.createElement(
419
- index_js_1.Box,
420
- {
421
- className: (0, classnames_1.default)(
422
- 'iui-date-picker',
423
- { 'iui-popover-surface': applyBackground },
424
- className,
425
- ),
426
- ref: forwardedRef,
427
- ...rest,
428
- },
429
- React.createElement(
430
- 'div',
431
- null,
432
- React.createElement(
433
- index_js_1.Box,
434
- {
435
- as: 'div',
436
- ...monthYearProps,
437
- className: (0, classnames_1.default)(
438
- 'iui-calendar-month-year',
439
- monthYearProps?.className,
440
- ),
441
- },
442
- showYearSelection &&
443
- React.createElement(
444
- IconButton_js_1.IconButton,
445
- {
446
- styleType: 'borderless',
447
- onClick: handleMoveToPreviousYear,
448
- 'aria-label': 'Previous year',
449
- size: 'small',
450
- },
451
- React.createElement(index_js_1.SvgChevronLeftDouble, null),
452
- ),
453
- React.createElement(
454
- IconButton_js_1.IconButton,
455
- {
456
- styleType: 'borderless',
457
- onClick: handleMoveToPreviousMonth,
458
- 'aria-label': 'Previous month',
459
- size: 'small',
460
- },
461
- React.createElement(index_js_1.SvgChevronLeft, null),
462
- ),
463
- React.createElement(
464
- 'span',
465
- { 'aria-live': 'polite' },
466
- React.createElement(
467
- index_js_1.Box,
468
- {
469
- as: 'span',
470
- id: dateTableId,
471
- title: monthNames[displayedMonthIndex],
472
- ...monthProps,
473
- className: (0, classnames_1.default)(
474
- 'iui-calendar-month',
475
- monthProps?.className,
476
- ),
477
- },
478
- monthNames[displayedMonthIndex],
479
- ),
480
- '\u00A0',
481
- displayedYear,
482
- ),
483
- React.createElement(
484
- IconButton_js_1.IconButton,
485
- {
486
- styleType: 'borderless',
487
- onClick: handleMoveToNextMonth,
488
- 'aria-label': 'Next month',
489
- size: 'small',
490
- },
491
- React.createElement(index_js_1.SvgChevronRight, null),
492
- ),
493
- showYearSelection &&
494
- React.createElement(
495
- IconButton_js_1.IconButton,
496
- {
497
- styleType: 'borderless',
498
- onClick: handleMoveToNextYear,
499
- 'aria-label': 'Next year',
500
- size: 'small',
501
- },
502
- React.createElement(index_js_1.SvgChevronRightDouble, null),
503
- ),
504
- ),
505
- React.createElement(
506
- index_js_1.Box,
507
- {
508
- as: 'div',
509
- ...weekDayProps,
510
- className: (0, classnames_1.default)(
511
- 'iui-calendar-weekdays',
512
- weekDayProps?.className,
513
- ),
514
- },
515
- shortDays.map((day, index) =>
516
- React.createElement('div', { key: day, title: longDays[index] }, day),
517
- ),
518
- ),
519
- React.createElement(
520
- 'div',
521
- {
522
- onKeyDown: handleCalendarKeyDown,
523
- role: 'listbox',
524
- 'aria-labelledby': dateTableId,
525
- ...calendarProps,
526
- },
527
- weeks.map((weekDays, weekIndex) => {
528
- return React.createElement(
529
- index_js_1.Box,
530
- {
531
- as: 'div',
532
- key: `week-${displayedMonthIndex}-${weekIndex}`,
533
- ...weekProps,
534
- className: (0, classnames_1.default)(
535
- 'iui-calendar-week',
536
- weekProps?.className,
537
- ),
538
- },
539
- weekDays.map((weekDay, dayIndex) => {
540
- const dateValue = weekDay.getDate();
541
- const isDisabled = isDateDisabled?.(weekDay);
542
- return React.createElement(
543
- index_js_1.Box,
544
- {
545
- as: 'div',
546
- key: `day-${displayedMonthIndex}-${dayIndex}`,
547
- onClick: () => !isDisabled && onDayClick(weekDay),
548
- role: 'option',
549
- tabIndex: isSameDay(weekDay, focusedDay) ? 0 : -1,
550
- 'aria-disabled': isDisabled ? 'true' : undefined,
551
- ref: (element) =>
552
- isSameDay(weekDay, focusedDay) &&
553
- needFocus.current &&
554
- element?.focus(),
555
- ...dayProps,
556
- className: (0, classnames_1.default)(
557
- getDayClass(weekDay),
558
- dayProps?.className,
559
- ),
560
- },
561
- dateValue,
562
- );
563
- }),
564
- );
565
- }),
566
- ),
567
- ),
568
- showTime &&
569
- React.createElement(TimePicker_js_1.TimePicker, {
570
- date: selectedStartDay ?? selectedDay,
571
- use12Hours: use12Hours,
572
- precision: precision,
573
- hourStep: hourStep,
574
- minuteStep: minuteStep,
575
- secondStep: secondStep,
576
- useCombinedRenderer: useCombinedRenderer,
577
- combinedRenderer: combinedRenderer,
578
- hourRenderer: hourRenderer,
579
- minuteRenderer: minuteRenderer,
580
- secondRenderer: secondRenderer,
581
- meridiemRenderer: meridiemRenderer,
582
- onChange: (date) =>
583
- isSingleOnChange(onChange, enableRangeSelect)
584
- ? onChange?.(date)
585
- : onChange?.(
586
- new Date(
587
- selectedStartDay?.getFullYear() ?? date.getFullYear(),
588
- selectedStartDay?.getMonth() ?? date.getMonth(),
589
- selectedStartDay?.getDate() ?? date.getDate(),
590
- date.getHours(),
591
- date.getMinutes(),
592
- date.getSeconds(),
593
- ),
594
- new Date(
595
- selectedEndDay?.getFullYear() ?? date.getFullYear(),
596
- selectedEndDay?.getMonth() ?? date.getMonth(),
597
- selectedEndDay?.getDate() ?? date.getDate(),
598
- date.getHours(),
599
- date.getMinutes(),
600
- date.getSeconds(),
601
- ),
602
- ),
603
- }),
604
- );
178
+ return weeksInMonth;
179
+ }, [days]);
180
+ const getNewFocusedDate = (newYear, newMonth) => {
181
+ const currentDate = selectedStartDay ?? selectedDay ?? new Date();
182
+ const newDate = new Date(newYear, newMonth, currentDate.getDate(), currentDate.getHours(), currentDate.getMinutes(), currentDate.getSeconds());
183
+ return newDate;
184
+ };
185
+ const handleMoveToPreviousYear = () => {
186
+ const newYear = displayedYear - 1;
187
+ setMonthAndYear(displayedMonthIndex, newYear);
188
+ setFocusedDay(getNewFocusedDate(newYear, displayedMonthIndex));
189
+ };
190
+ const handleMoveToNextYear = () => {
191
+ const newYear = displayedYear + 1;
192
+ setMonthAndYear(displayedMonthIndex, newYear);
193
+ setFocusedDay(getNewFocusedDate(newYear, displayedMonthIndex));
194
+ };
195
+ const handleMoveToPreviousMonth = () => {
196
+ const newMonth = displayedMonthIndex !== 0 ? displayedMonthIndex - 1 : 11;
197
+ const newYear = displayedMonthIndex !== 0 ? displayedYear : displayedYear - 1;
198
+ setMonthAndYear(newMonth, newYear);
199
+ setFocusedDay(getNewFocusedDate(newYear, newMonth));
200
+ };
201
+ const handleMoveToNextMonth = () => {
202
+ const newMonth = displayedMonthIndex !== 11 ? displayedMonthIndex + 1 : 0;
203
+ const newYear = displayedMonthIndex !== 11 ? displayedYear : displayedYear + 1;
204
+ setMonthAndYear(newMonth, newYear);
205
+ setFocusedDay(getNewFocusedDate(newYear, newMonth));
206
+ };
207
+ const onDayClick = (day) => {
208
+ // single date selection
209
+ if (!enableRangeSelect) {
210
+ if (day.getMonth() !== selectedDay?.getMonth()) {
211
+ setMonthAndYear(day.getMonth(), day.getFullYear());
212
+ }
213
+ const currentDate = selectedDay ?? new Date();
214
+ const newDate = new Date(day.getFullYear(), day.getMonth(), day.getDate(), currentDate.getHours(), currentDate.getMinutes(), currentDate.getSeconds());
215
+ setSelectedDay(newDate);
216
+ setFocusedDay(newDate);
217
+ isSingleOnChange(onChange, enableRangeSelect) && onChange?.(newDate);
218
+ }
219
+ // start date selection (date range only)
220
+ else if (isSelectingStartDate) {
221
+ if (day.getMonth() !== selectedStartDay?.getMonth()) {
222
+ setMonthAndYear(day.getMonth(), day.getFullYear());
223
+ }
224
+ const currentStartDate = selectedStartDay ?? new Date();
225
+ const newStartDate = new Date(day.getFullYear(), day.getMonth(), day.getDate(), currentStartDate.getHours(), currentStartDate.getMinutes(), currentStartDate.getSeconds());
226
+ setSelectedStartDay(newStartDate);
227
+ setFocusedDay(newStartDate);
228
+ // if the start date is after the end date or the end date is undefined, reset the end date
229
+ if (!(0, index_js_1.isBefore)(newStartDate, selectedEndDay)) {
230
+ setSelectedEndDay(newStartDate);
231
+ onChange?.(newStartDate, newStartDate);
232
+ }
233
+ else {
234
+ selectedEndDay && onChange?.(newStartDate, selectedEndDay);
235
+ }
236
+ setIsSelectingStartDate(false);
237
+ }
238
+ // end date selection (date range only)
239
+ else {
240
+ if (day.getMonth() !== selectedEndDay?.getMonth()) {
241
+ setMonthAndYear(day.getMonth(), day.getFullYear());
242
+ }
243
+ const currentEndDate = selectedEndDay ?? new Date();
244
+ const newEndDate = new Date(day.getFullYear(), day.getMonth(), day.getDate(), currentEndDate.getHours(), currentEndDate.getMinutes(), currentEndDate.getSeconds());
245
+ setFocusedDay(newEndDate);
246
+ // if the end date is before the start date, move back the start date and still have user select end date
247
+ if (!(0, index_js_1.isBefore)(newEndDate, selectedStartDay)) {
248
+ setSelectedEndDay(newEndDate);
249
+ selectedStartDay && onChange?.(selectedStartDay, newEndDate);
250
+ setIsSelectingStartDate(true);
251
+ }
252
+ else {
253
+ setSelectedStartDay(newEndDate);
254
+ selectedEndDay && onChange?.(newEndDate, selectedEndDay);
255
+ }
256
+ }
257
+ };
258
+ const handleCalendarKeyDown = (event) => {
259
+ if (event.altKey) {
260
+ return;
261
+ }
262
+ if (!focusedDay) {
263
+ return;
264
+ }
265
+ const adjustedFocusedDay = new Date(focusedDay);
266
+ switch (event.key) {
267
+ case 'ArrowDown':
268
+ adjustedFocusedDay.setDate(focusedDay.getDate() + 7);
269
+ if (adjustedFocusedDay.getMonth() !== displayedMonthIndex) {
270
+ handleMoveToNextMonth();
271
+ }
272
+ setFocusedDay(adjustedFocusedDay);
273
+ needFocus.current = true;
274
+ event.preventDefault();
275
+ break;
276
+ case 'ArrowUp':
277
+ adjustedFocusedDay.setDate(focusedDay.getDate() - 7);
278
+ if (adjustedFocusedDay.getMonth() !== displayedMonthIndex) {
279
+ handleMoveToPreviousMonth();
280
+ }
281
+ setFocusedDay(adjustedFocusedDay);
282
+ needFocus.current = true;
283
+ event.preventDefault();
284
+ break;
285
+ case 'ArrowLeft':
286
+ adjustedFocusedDay.setDate(focusedDay.getDate() - 1);
287
+ if (adjustedFocusedDay.getMonth() !== displayedMonthIndex) {
288
+ handleMoveToPreviousMonth();
289
+ }
290
+ setFocusedDay(adjustedFocusedDay);
291
+ needFocus.current = true;
292
+ event.preventDefault();
293
+ break;
294
+ case 'ArrowRight':
295
+ adjustedFocusedDay.setDate(focusedDay.getDate() + 1);
296
+ if (adjustedFocusedDay.getMonth() !== displayedMonthIndex) {
297
+ handleMoveToNextMonth();
298
+ }
299
+ setFocusedDay(adjustedFocusedDay);
300
+ needFocus.current = true;
301
+ event.preventDefault();
302
+ break;
303
+ case 'Enter':
304
+ case ' ':
305
+ case 'Spacebar':
306
+ if (!isDateDisabled?.(focusedDay)) {
307
+ onDayClick(focusedDay);
308
+ }
309
+ event.preventDefault();
310
+ break;
311
+ }
312
+ };
313
+ const getDayClass = (day) => {
314
+ if (day.getMonth() !== displayedMonthIndex) {
315
+ return 'iui-calendar-day-outside-month';
316
+ }
317
+ let dayClass = 'iui-calendar-day';
318
+ const isSelectedDay = isSameDay(day, selectedDay) ||
319
+ (isSameDay(day, selectedStartDay) && isSameDay(day, selectedEndDay));
320
+ if (isSelectedDay) {
321
+ dayClass += '-selected';
322
+ }
323
+ else if (isSameDay(day, selectedStartDay)) {
324
+ dayClass += '-range-start';
325
+ }
326
+ else if (isSameDay(day, selectedEndDay)) {
327
+ dayClass += '-range-end';
328
+ }
329
+ // adds range class to dates between start and end date
330
+ if (selectedStartDay &&
331
+ selectedEndDay &&
332
+ isInDateRange(day, selectedStartDay, selectedEndDay)) {
333
+ dayClass += '-range';
334
+ }
335
+ if (isSameDay(day, new Date())) {
336
+ dayClass += '-today';
337
+ }
338
+ return dayClass;
339
+ };
340
+ const dateTableId = (0, index_js_1.useId)();
341
+ return (React.createElement(index_js_1.Box, { className: (0, classnames_1.default)('iui-date-picker', { 'iui-popover-surface': applyBackground }, className), ref: forwardedRef, ...rest },
342
+ React.createElement("div", null,
343
+ React.createElement(index_js_1.Box, { as: 'div', ...monthYearProps, className: (0, classnames_1.default)('iui-calendar-month-year', monthYearProps?.className) },
344
+ showYearSelection && (React.createElement(IconButton_js_1.IconButton, { styleType: 'borderless', onClick: handleMoveToPreviousYear, "aria-label": 'Previous year', size: 'small' },
345
+ React.createElement(index_js_1.SvgChevronLeftDouble, null))),
346
+ React.createElement(IconButton_js_1.IconButton, { styleType: 'borderless', onClick: handleMoveToPreviousMonth, "aria-label": 'Previous month', size: 'small' },
347
+ React.createElement(index_js_1.SvgChevronLeft, null)),
348
+ React.createElement("span", { "aria-live": 'polite' },
349
+ React.createElement(index_js_1.Box, { as: 'span', id: dateTableId, title: monthNames[displayedMonthIndex], ...monthProps, className: (0, classnames_1.default)('iui-calendar-month', monthProps?.className) }, monthNames[displayedMonthIndex]),
350
+ "\u00A0",
351
+ displayedYear),
352
+ React.createElement(IconButton_js_1.IconButton, { styleType: 'borderless', onClick: handleMoveToNextMonth, "aria-label": 'Next month', size: 'small' },
353
+ React.createElement(index_js_1.SvgChevronRight, null)),
354
+ showYearSelection && (React.createElement(IconButton_js_1.IconButton, { styleType: 'borderless', onClick: handleMoveToNextYear, "aria-label": 'Next year', size: 'small' },
355
+ React.createElement(index_js_1.SvgChevronRightDouble, null)))),
356
+ React.createElement(index_js_1.Box, { as: 'div', ...weekDayProps, className: (0, classnames_1.default)('iui-calendar-weekdays', weekDayProps?.className) }, shortDays.map((day, index) => (React.createElement("div", { key: day, title: longDays[index] }, day)))),
357
+ React.createElement("div", { onKeyDown: handleCalendarKeyDown, role: 'listbox', "aria-labelledby": dateTableId, ...calendarProps }, weeks.map((weekDays, weekIndex) => {
358
+ return (React.createElement(index_js_1.Box, { as: 'div', key: `week-${displayedMonthIndex}-${weekIndex}`, ...weekProps, className: (0, classnames_1.default)('iui-calendar-week', weekProps?.className) }, weekDays.map((weekDay, dayIndex) => {
359
+ const dateValue = weekDay.getDate();
360
+ const isDisabled = isDateDisabled?.(weekDay);
361
+ return (React.createElement(index_js_1.Box, { as: 'div', key: `day-${displayedMonthIndex}-${dayIndex}`, onClick: () => !isDisabled && onDayClick(weekDay), role: 'option', tabIndex: isSameDay(weekDay, focusedDay) ? 0 : -1, "aria-disabled": isDisabled ? 'true' : undefined, ref: (element) => isSameDay(weekDay, focusedDay) &&
362
+ needFocus.current &&
363
+ element?.focus(), ...dayProps, className: (0, classnames_1.default)(getDayClass(weekDay), dayProps?.className) }, dateValue));
364
+ })));
365
+ }))),
366
+ showTime && (React.createElement(TimePicker_js_1.TimePicker, { date: selectedStartDay ?? selectedDay, use12Hours: use12Hours, precision: precision, hourStep: hourStep, minuteStep: minuteStep, secondStep: secondStep, useCombinedRenderer: useCombinedRenderer, combinedRenderer: combinedRenderer, hourRenderer: hourRenderer, minuteRenderer: minuteRenderer, secondRenderer: secondRenderer, meridiemRenderer: meridiemRenderer, onChange: (date) => isSingleOnChange(onChange, enableRangeSelect)
367
+ ? onChange?.(date)
368
+ : onChange?.(new Date(selectedStartDay?.getFullYear() ?? date.getFullYear(), selectedStartDay?.getMonth() ?? date.getMonth(), selectedStartDay?.getDate() ?? date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds()), new Date(selectedEndDay?.getFullYear() ?? date.getFullYear(), selectedEndDay?.getMonth() ?? date.getMonth(), selectedEndDay?.getDate() ?? date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds())) }))));
605
369
  });
606
370
  exports.default = exports.DatePicker;