@ringcentral/spring-ui 1.11.2 → 1.13.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 (241) hide show
  1. package/Accordion.js +90 -34
  2. package/AccordionHeader.js +72 -20
  3. package/Alert.js +120 -28
  4. package/Animation.js +2 -45
  5. package/Announcement.js +46 -35
  6. package/Autocomplete.js +1011 -580
  7. package/Avatar.js +134 -73
  8. package/AvatarGroup.js +50 -7
  9. package/Backdrop.js +45 -7
  10. package/Badge.js +77 -15
  11. package/Block.js +34 -12
  12. package/BlockHeader.js +55 -11
  13. package/BottomNavigation.js +181 -65
  14. package/BottomNavigationItem.js +93 -30
  15. package/Button.js +160 -24
  16. package/CallButton.js +53 -31
  17. package/Checkbox.js +88 -26
  18. package/Chip.js +126 -26
  19. package/CircularProgressIndicator.js +80 -8
  20. package/ClickAwayListener.js +4 -1
  21. package/ComponentsProps.js +1 -0
  22. package/DatePicker.js +611 -190
  23. package/DateUtilsContext.js +43 -25
  24. package/Dialer.js +576 -250
  25. package/Dialog.js +100 -45
  26. package/Divider.js +43 -7
  27. package/DragHandle.js +32 -6
  28. package/Drawer.js +117 -19
  29. package/Dropdown.js +154 -74
  30. package/EmptyState.js +63 -11
  31. package/FabButton.js +51 -17
  32. package/FocusTrap.js +109 -12
  33. package/FormField.js +106 -8
  34. package/FormLabel.js +81 -7
  35. package/Icon.js +1 -8
  36. package/IconButton.js +142 -26
  37. package/IconButtonGroup.js +35 -12
  38. package/InlineEditable.js +98 -44
  39. package/LinearProgressIndicator.js +73 -24
  40. package/Link.js +40 -11
  41. package/List.js +54 -9
  42. package/ListItem.js +152 -23
  43. package/ListItemText.js +44 -16
  44. package/ListNavigation.js +272 -20
  45. package/Menu.js +139 -23
  46. package/MenuActions.js +37 -12
  47. package/MenuDivider.js +34 -8
  48. package/MenuFooter.js +36 -12
  49. package/MenuHeader.js +54 -15
  50. package/MenuItem.js +402 -33
  51. package/MenuItemText.js +51 -8
  52. package/MenuList.js +87 -34
  53. package/Modal.js +345 -16
  54. package/NestedMenuContext.js +183 -11
  55. package/Option.js +32 -34
  56. package/Overlap.js +54 -7
  57. package/PageHeader.js +62 -24
  58. package/PickerTextField.js +156 -33
  59. package/Popover.js +262 -21
  60. package/Popper.js +130 -77
  61. package/PopperPaper.js +54 -8
  62. package/Portal.js +6 -1
  63. package/Radio.js +65 -21
  64. package/RadioGroup.js +56 -17
  65. package/Rating.js +223 -87
  66. package/Select.js +387 -41
  67. package/SingleFilter.js +148 -77
  68. package/Skeleton.js +68 -17
  69. package/Slider.js +168 -69
  70. package/Snackbar.js +122 -59
  71. package/SortableList.js +32 -12
  72. package/SortableListDndContext.js +69 -22
  73. package/SortableListItem.js +92 -47
  74. package/SortableVirtualizedList.js +52 -28
  75. package/SplitButton.js +124 -86
  76. package/Squircle.js +4 -7
  77. package/StatusIndicator.js +51 -9
  78. package/Step.js +63 -38
  79. package/StepButton.js +51 -23
  80. package/StepConnector.js +48 -8
  81. package/StepContent.js +68 -25
  82. package/StepIcon.js +90 -9
  83. package/StepLabel.js +90 -14
  84. package/Stepper.js +65 -23
  85. package/SubMenu.js +203 -99
  86. package/SwipeableDrawer.js +439 -194
  87. package/Switch.js +70 -23
  88. package/Tab.js +120 -57
  89. package/TabContext.js +59 -15
  90. package/TabPanel.js +40 -13
  91. package/Table.js +60 -17
  92. package/TableBody.js +42 -12
  93. package/TableCell.js +84 -50
  94. package/TableContainer.js +32 -10
  95. package/TableFooter.js +38 -10
  96. package/TableHead.js +49 -15
  97. package/TablePagination.js +153 -77
  98. package/TableRow.js +60 -21
  99. package/Tabs.js +593 -268
  100. package/Tag.js +51 -16
  101. package/Text.js +68 -37
  102. package/TextField.js +209 -29
  103. package/Textarea.js +51 -40
  104. package/TimePicker.js +490 -230
  105. package/Tooltip.js +48 -23
  106. package/Tray.js +237 -13
  107. package/TrayMenu.js +62 -41
  108. package/VirtualizedList.js +208 -109
  109. package/VirtualizedMenu.js +359 -29
  110. package/VisuallyHidden.js +29 -6
  111. package/chunks/1250.js +98 -0
  112. package/chunks/1294.js +126 -0
  113. package/chunks/2956.js +18 -0
  114. package/chunks/4476.js +460 -0
  115. package/chunks/4491.js +10 -0
  116. package/chunks/4535.js +364 -0
  117. package/chunks/5047.js +3 -0
  118. package/chunks/6335.js +24 -0
  119. package/chunks/7279.js +10 -0
  120. package/chunks/8011.js +8 -0
  121. package/chunks/8307.js +56 -0
  122. package/chunks/8467.js +8 -0
  123. package/chunks/8809.js +8 -0
  124. package/chunks/{RadioGroup.context.js → 9551.js} +12 -6
  125. package/chunks/987.js +8 -0
  126. package/index.css +2624 -2416
  127. package/index.js +245 -193
  128. package/internal/utils/index.d.ts +1 -0
  129. package/internal/utils/setRef.d.ts +2 -0
  130. package/package.json +8 -8
  131. package/src/Alert/Alert.type.d.ts +2 -1
  132. package/src/Animation/components/Fade/Fade.d.ts +4 -2
  133. package/src/Animation/components/Grow/Grow.d.ts +4 -2
  134. package/src/Animation/components/ShowHideEye/ShowHideEye.d.ts +1 -1
  135. package/src/Animation/components/SlideIn/SlideIn.d.ts +4 -2
  136. package/src/Animation/components/SlideIn/getSlideIn.d.ts +1 -1
  137. package/src/Animation/hooks/useMotionSafeTransition/useMotionSafeTransition.d.ts +2 -0
  138. package/src/Autocomplete/SuggestionList/SuggestionList.d.ts +1 -1
  139. package/src/Autocomplete/useAutocomplete.d.ts +18 -18
  140. package/src/Autocomplete/useAutocompleteTag.d.ts +18 -18
  141. package/src/Badge/Badge.d.ts +2 -1
  142. package/src/Button/Button.classes.d.ts +1 -1
  143. package/src/ComponentsProps.d.ts +111 -110
  144. package/src/DatePicker/DatePickerDataAttributes.d.ts +11 -0
  145. package/src/DatePicker/utils/DatePickerAriaLabelUtils.d.ts +2 -1
  146. package/src/DatePicker/utils/DatePickerUtils.d.ts +1 -1
  147. package/src/Dialer/DialDelete/DialDelete.d.ts +2 -2
  148. package/src/Dialer/DialPad/DialPad.d.ts +2 -2
  149. package/src/Dialer/Dialer.d.ts +4 -2
  150. package/src/Dropdown/Dropdown.type.d.ts +2 -2
  151. package/src/InlineEditable/InlineEditable.type.d.ts +2 -1
  152. package/src/ListNavigation/useListNavigation.d.ts +3 -3
  153. package/src/MenuActions/MenuActions.d.ts +2 -2
  154. package/src/MenuItem/MenuItem.type.d.ts +1 -0
  155. package/src/MenuItem/useMenuItem.d.ts +1 -1
  156. package/src/MenuItem/useVirtualizedMenuItem.d.ts +1 -1
  157. package/src/MenuList/MenuList.type.d.ts +1 -1
  158. package/src/MenuList/MenuListContext.d.ts +2 -3
  159. package/src/Modal/Modal.type.d.ts +1 -0
  160. package/src/NestedMenuContext/MenuOverlayGroupContext.d.ts +2 -2
  161. package/src/Popover/Popover.classes.d.ts +1 -1
  162. package/src/Popover/Popover.internal.d.ts +8 -0
  163. package/src/Popover/Popover.type.d.ts +1 -0
  164. package/src/Popper/Popper.type.d.ts +10 -7
  165. package/src/Rating/utils.d.ts +3 -2
  166. package/src/Select/Select.type.d.ts +7 -5
  167. package/src/Slider/Slider.d.ts +2 -2
  168. package/src/Slider/SliderThumb.d.ts +2 -1
  169. package/src/Squircle/Squircle.d.ts +1 -1
  170. package/src/StatusIndicator/StatusIndicator.d.ts +2 -1
  171. package/src/SubMenu/PopperMenu.type.d.ts +4 -1
  172. package/src/Table/Table.type.d.ts +3 -0
  173. package/src/Table/TableContext.d.ts +3 -0
  174. package/src/Table/TableRowContext.d.ts +7 -0
  175. package/src/Table/index.d.ts +1 -0
  176. package/src/TableCell/TableCell.classes.d.ts +1 -1
  177. package/src/TableFooter/TableFooter.classes.d.ts +1 -1
  178. package/src/TableFooter/TableFooter.type.d.ts +1 -0
  179. package/src/TableHead/TableHead.classes.d.ts +1 -1
  180. package/src/TableHead/TableHead.type.d.ts +1 -0
  181. package/src/TableRow/TableRow.type.d.ts +2 -0
  182. package/chunks/AccordionContext.js +0 -6
  183. package/chunks/Alert.js +0 -48
  184. package/chunks/AvatarGroup.js +0 -22
  185. package/chunks/Backdrop.js +0 -18
  186. package/chunks/Badge.js +0 -32
  187. package/chunks/BottomNavigationItem.js +0 -36
  188. package/chunks/Button.js +0 -88
  189. package/chunks/Chip.js +0 -73
  190. package/chunks/CircularProgressIndicator.js +0 -36
  191. package/chunks/Divider.js +0 -19
  192. package/chunks/DragHandle.js +0 -11
  193. package/chunks/Drawer.js +0 -32
  194. package/chunks/ExpandCollapseCaret.js +0 -24
  195. package/chunks/FormLabel.js +0 -27
  196. package/chunks/Icon.js +0 -25
  197. package/chunks/IconButtonLabel.js +0 -68
  198. package/chunks/List.js +0 -22
  199. package/chunks/ListItem.js +0 -83
  200. package/chunks/Menu.js +0 -61
  201. package/chunks/MenuDivider.js +0 -14
  202. package/chunks/MenuItemText.js +0 -17
  203. package/chunks/MenuList.js +0 -46
  204. package/chunks/Modal.js +0 -212
  205. package/chunks/Overlap.js +0 -25
  206. package/chunks/PickerTextField.js +0 -85
  207. package/chunks/Popover.js +0 -53
  208. package/chunks/PopperPaper.js +0 -15
  209. package/chunks/Select.js +0 -220
  210. package/chunks/ShowHideEye.js +0 -56
  211. package/chunks/SlideIn.js +0 -19
  212. package/chunks/SortableArrow.js +0 -73
  213. package/chunks/Squircle.js +0 -31
  214. package/chunks/StatusIndicator.js +0 -20
  215. package/chunks/StepConnector.js +0 -21
  216. package/chunks/StepIcon.js +0 -43
  217. package/chunks/StepLabel.js +0 -29
  218. package/chunks/StepperContext.js +0 -9
  219. package/chunks/TableContext.js +0 -6
  220. package/chunks/Tablelvl2Context.js +0 -6
  221. package/chunks/TabsContext.js +0 -6
  222. package/chunks/TextField.js +0 -110
  223. package/chunks/Tooltip.js +0 -217
  224. package/chunks/VirtualizedMenu.js +0 -164
  225. package/chunks/VisuallyHidden.js +0 -12
  226. package/chunks/getFade.js +0 -27
  227. package/chunks/getGrow.js +0 -70
  228. package/chunks/getSlideIn.js +0 -30
  229. package/chunks/hasContent.js +0 -3
  230. package/chunks/useAnimationFrame.js +0 -15
  231. package/chunks/useFocusTrapStack.js +0 -36
  232. package/chunks/useHelperTextId.js +0 -22
  233. package/chunks/useListNavigation.js +0 -199
  234. package/chunks/useMenuItemSelect.js +0 -273
  235. package/chunks/useMotionSafeTransition.js +0 -9
  236. package/chunks/useNestedMenuItem.js +0 -27
  237. package/chunks/useNestedParentMenu.js +0 -113
  238. package/chunks/usePrefersReducedMotion.js +0 -36
  239. package/chunks/useTooltipForceHide.js +0 -27
  240. package/chunks/useTrayNavigate.js +0 -150
  241. package/chunks/withTooltip.js +0 -15
package/DatePicker.js CHANGED
@@ -1,68 +1,93 @@
1
- import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
2
- import { useFocusVisible, useForkRef, combineProps, useOnlyOneFocusable, useKeyboardMoveFocus, usePrevious, useId, useEventCallback, useWindowContext, runKeyHandler, useControlled } from '@ringcentral/spring-base';
3
- import { createContext, useContext, forwardRef, useRef, useMemo, useLayoutEffect, createElement, useState, useCallback, useEffect } from 'react';
4
- import { B as Button } from './chunks/Button.js';
5
- import { C as CircularProgressIndicator } from './chunks/CircularProgressIndicator.js';
6
- import { useDateUtilsContext, DateUtilsProvider } from './DateUtilsContext.js';
7
- import { CaretLeftMd, CaretRightMd, CalendarMd } from '@ringcentral/spring-icon';
8
- import { E as ExpandCollapseCaret } from './chunks/ExpandCollapseCaret.js';
9
- import 'framer-motion';
10
- import { useThemeProps, useClassesWithMode } from '@ringcentral/spring-theme';
11
- import './chunks/Icon.js';
12
- import { I as IconButton } from './chunks/IconButtonLabel.js';
13
- import clsx from 'clsx';
14
- import dayjs from 'dayjs';
15
- import { P as PickerTextField } from './chunks/PickerTextField.js';
16
- import '@mui/base';
17
- import './chunks/Tooltip.js';
18
- import './chunks/usePrefersReducedMotion.js';
19
- import './chunks/getFade.js';
20
- import './Popper.js';
21
- import '@floating-ui/react-dom';
22
- import './chunks/Modal.js';
23
- import './chunks/useFocusTrapStack.js';
24
- import './chunks/Backdrop.js';
25
- import './chunks/PopperPaper.js';
26
- import './chunks/withTooltip.js';
27
- import '@date-io/dayjs';
28
- import './chunks/useMotionSafeTransition.js';
29
- import './chunks/Squircle.js';
30
- import './chunks/Popover.js';
31
- import './chunks/getGrow.js';
32
- import './chunks/useHelperTextId.js';
33
- import './chunks/TextField.js';
34
- import './chunks/ShowHideEye.js';
35
- import './chunks/VisuallyHidden.js';
36
-
37
- const DatePickerClassesContext = createContext(() => '');
38
- const useDatePickerClasses = () => useContext(DatePickerClassesContext);
39
-
40
- const HeaderAction = (props) => {
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import { combineProps, runKeyHandler, useControlled, useEventCallback, useFocusVisible, useForkRef, useId, useKeyboardMoveFocus, useOnlyOneFocusable, usePrevious } from "@ringcentral/spring-base";
3
+ import { createContext, createElement, forwardRef, useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
4
+ import { CalendarMd, CaretLeftMd, CaretRightMd } from "@ringcentral/spring-icon";
5
+ import clsx from "clsx";
6
+ import dayjs from "dayjs";
7
+ import { useClassesWithMode, useThemeProps } from "@ringcentral/spring-theme";
8
+ import "./chunks/4476.js";
9
+ import { DateUtilsProvider, useDateUtilsContext } from "./DateUtilsContext.js";
10
+ import { IconButton as IconButton_IconButton } from "./IconButton.js";
11
+ import { Button as Button_Button } from "./Button.js";
12
+ import { CircularProgressIndicator as CircularProgressIndicator_CircularProgressIndicator } from "./CircularProgressIndicator.js";
13
+ import { PickerTextField as PickerTextField_PickerTextField } from "./PickerTextField.js";
14
+ import { ExpandCollapseCaret as ExpandCollapseCaret_ExpandCollapseCaret } from "./chunks/1294.js";
15
+
16
+
17
+
18
+
19
+
20
+
21
+ const DatePickerClassesContext = createContext(()=>'');
22
+ const useDatePickerClasses = ()=>useContext(DatePickerClassesContext);
23
+
24
+
25
+ const DATE_PICKER_HEADER_DATA_ATTRIBUTES = {
26
+ previousMonth: 'data-sui-picker-previous-month',
27
+ nextMonth: 'data-sui-picker-next-month',
28
+ switchYearAction: 'data-sui-picker-switch-year-action'
29
+ };
30
+ const DATE_PICKER_HEADER_SELECTORS = {
31
+ previousMonth: `[${DATE_PICKER_HEADER_DATA_ATTRIBUTES.previousMonth}]`,
32
+ nextMonth: `[${DATE_PICKER_HEADER_DATA_ATTRIBUTES.nextMonth}]`,
33
+ switchYearAction: `[${DATE_PICKER_HEADER_DATA_ATTRIBUTES.switchYearAction}]`
34
+ };
35
+
36
+
37
+
38
+
39
+
40
+
41
+
42
+
43
+
44
+
45
+
46
+ const HeaderAction = (props)=>{
41
47
  const { className, disabled, ...rest } = props;
42
48
  const cls = useDatePickerClasses();
43
49
  const { focusVisible, focusVisibleRef, focusVisibleHandlers } = useFocusVisible();
44
- return (jsx("button", { className: clsx(className, cls('header-action', { focusVisible, disabled })), ref: focusVisibleRef, ...rest, ...focusVisibleHandlers }));
50
+ return /*#__PURE__*/ jsx("button", {
51
+ className: clsx(className, cls('header-action', {
52
+ focusVisible,
53
+ disabled
54
+ })),
55
+ ref: focusVisibleRef,
56
+ ...rest,
57
+ ...focusVisibleHandlers,
58
+ type: "button"
59
+ });
45
60
  };
46
61
 
62
+
63
+
64
+
65
+
66
+
47
67
  const defaultScreenReaderProps = {
48
- getMonthYearAriaLabel: (monthLabel, expanded) => `${monthLabel}${expanded ? ', year selection expanded' : ''}`,
49
- getSwitchMonthAriaLabel: (isNext, currentMonth) => `${isNext ? 'Next' : 'Previous'} month, currently viewing ${currentMonth}`,
50
- getBackToTodayAriaLabel: () => 'Go back to today',
51
- getLoadingAriaLabel: () => 'Loading dates',
52
- getDayAriaLabel: (day, selected) => `${day}${selected ? ', selected' : ''}`,
53
- getYearAriaLabel: (year, selected) => `${year}${selected ? ', selected' : ''}`,
68
+ getMonthYearAriaLabel: (monthLabel, expanded)=>`${monthLabel}${expanded ? ', year selection expanded' : ''}`,
69
+ getSwitchMonthAriaLabel: (isNext, currentMonth)=>`${isNext ? 'Next' : 'Previous'} month, currently viewing ${currentMonth}`,
70
+ getBackToTodayAriaLabel: ()=>'Go back to today',
71
+ getLoadingAriaLabel: ()=>'Loading dates',
72
+ getDayAriaLabel: (day, selected)=>`${day}${selected ? ', selected' : ''}`,
73
+ getYearAriaLabel: (year, selected)=>`${year}${selected ? ', selected' : ''}`
54
74
  };
55
- const ScreenReaderContext = createContext(defaultScreenReaderProps);
56
- const useScreenReaderContext = () => useContext(ScreenReaderContext);
57
- const ScreenReaderProvider = ({ screenReaderProps, children, }) => {
58
- return (jsx(ScreenReaderContext.Provider, { value: screenReaderProps || defaultScreenReaderProps, children: children }));
75
+ const ScreenReaderContext = /*#__PURE__*/ createContext(defaultScreenReaderProps);
76
+ const useScreenReaderContext = ()=>useContext(ScreenReaderContext);
77
+ const ScreenReaderProvider = ({ screenReaderProps, children })=>{
78
+ return /*#__PURE__*/ jsx(ScreenReaderContext.Provider, {
79
+ value: screenReaderProps || defaultScreenReaderProps,
80
+ children: children
81
+ });
59
82
  };
60
83
 
61
- const focusDayElement = () => {
62
- const elm = document.querySelector('[data-sui-picker-focused]');
63
- elm?.focus();
84
+
85
+ const focusDayElement = (root = document)=>{
86
+ const focusedDayElement = root?.querySelector('[data-sui-picker-focused]');
87
+ focusedDayElement?.focus();
88
+ return focusedDayElement;
64
89
  };
65
- const isSameYearAndMonth = ({ source, comparing }, utils) => {
90
+ const isSameYearAndMonth = ({ source, comparing }, utils)=>{
66
91
  if (!source || !comparing) {
67
92
  return false;
68
93
  }
@@ -72,7 +97,7 @@ const isSameYearAndMonth = ({ source, comparing }, utils) => {
72
97
  const comparingYear = utils.getYear(comparing);
73
98
  return thisMonth === comparingMonth && thisYear === comparingYear;
74
99
  };
75
- const invalidateDateInRange = (day, { dateRange: { min, max }, disableFuture, disablePast, now, }, utils) => {
100
+ const invalidateDateInRange = (day, { dateRange: { min, max }, disableFuture, disablePast, now }, utils)=>{
76
101
  if (disableFuture && utils.isAfterDay(day, now)) {
77
102
  return now;
78
103
  }
@@ -88,7 +113,7 @@ const invalidateDateInRange = (day, { dateRange: { min, max }, disableFuture, di
88
113
  return false;
89
114
  };
90
115
 
91
- const findClosestEnabledDate = ({ date, utils, minDate, maxDate, disableFuture, disablePast, shouldDisableDate, }) => {
116
+ const findClosestEnabledDate = ({ date, utils, minDate, maxDate, disableFuture, disablePast, shouldDisableDate })=>{
92
117
  const today = utils.startOfDay(utils.date());
93
118
  if (disablePast && utils.isBefore(minDate, today)) {
94
119
  minDate = today;
@@ -108,7 +133,7 @@ const findClosestEnabledDate = ({ date, utils, minDate, maxDate, disableFuture,
108
133
  }
109
134
  forward = null;
110
135
  }
111
- while (forward || backward) {
136
+ while(forward || backward){
112
137
  if (forward && utils.isAfter(forward, maxDate)) {
113
138
  forward = null;
114
139
  }
@@ -128,20 +153,34 @@ const findClosestEnabledDate = ({ date, utils, minDate, maxDate, disableFuture,
128
153
  backward = utils.addDays(backward, -1);
129
154
  }
130
155
  }
156
+ // fallback to today if no enabled days
131
157
  return utils.date();
132
158
  };
133
159
 
134
- const DatePickerHeader = (props) => {
135
- const { focusedDate, onMonthChange, disablePrevMonth = false, disableNextMonth = false, onViewChange, view, gridLabelId, } = props;
160
+
161
+
162
+
163
+
164
+
165
+
166
+
167
+
168
+
169
+
170
+
171
+
172
+
173
+ const DatePickerHeader = (props)=>{
174
+ const { focusedDate, onMonthChange, disablePrevMonth = false, disableNextMonth = false, onViewChange, view, gridLabelId } = props;
136
175
  const utils = useDateUtilsContext();
137
176
  const cls = useDatePickerClasses();
138
177
  const preMonth = utils.getPreviousMonth(focusedDate);
139
178
  const nextMonth = utils.getNextMonth(focusedDate);
140
179
  const monthLabel = utils.getCalendarHeaderText(focusedDate);
141
- const selectNextMonth = () => {
180
+ const selectNextMonth = ()=>{
142
181
  onMonthChange(nextMonth, 'left');
143
182
  };
144
- const selectPreviousMonth = () => {
183
+ const selectPreviousMonth = ()=>{
145
184
  onMonthChange(preMonth, 'right');
146
185
  };
147
186
  const isYearView = view === 'year';
@@ -150,11 +189,78 @@ const DatePickerHeader = (props) => {
150
189
  const monthYearAriaLabel = getMonthYearAriaLabel?.(`${monthLabel}`, isExpanded);
151
190
  const nextMonthAriaLabel = getSwitchMonthAriaLabel?.(true, utils.getMonthText(focusedDate));
152
191
  const previousMonthAriaLabel = getSwitchMonthAriaLabel?.(false, utils.getMonthText(focusedDate));
153
- return (jsx(Fragment, { children: jsxs("div", { className: cls('header'), children: [jsxs(HeaderAction, { onClick: onViewChange, "aria-label": monthYearAriaLabel, "aria-expanded": isExpanded, "data-sui-picker-switch-year-action": "", className: cls('switch-year-action'), children: [jsx("span", { id: gridLabelId, "aria-live": "polite", "aria-atomic": "true", children: monthLabel }), jsx(ExpandCollapseCaret, { className: cls('switch-year-action-caret'), size: "small", expanded: isExpanded })] }), !isYearView && (jsxs("div", { className: cls('switch-month-actions-group'), children: [jsx(IconButton, { shape: "squircle", variant: "contained", color: "secondary", size: "small", background: false, symbol: CaretLeftMd, className: cls('switch-month-action'), disabled: disablePrevMonth, onClick: selectPreviousMonth, "aria-label": previousMonthAriaLabel, "data-sui-picker-previous-month": "" }), jsx(IconButton, { shape: "squircle", variant: "contained", color: "secondary", size: "small", background: false, symbol: CaretRightMd, className: cls('switch-month-action'), disabled: disableNextMonth, onClick: selectNextMonth, "aria-label": nextMonthAriaLabel, "data-sui-picker-next-month": "" })] }))] }) }));
192
+ return /*#__PURE__*/ jsx(Fragment, {
193
+ children: /*#__PURE__*/ jsxs("div", {
194
+ className: cls('header'),
195
+ children: [
196
+ /*#__PURE__*/ jsxs(HeaderAction, {
197
+ onClick: onViewChange,
198
+ "aria-label": monthYearAriaLabel,
199
+ "aria-expanded": isExpanded,
200
+ [DATE_PICKER_HEADER_DATA_ATTRIBUTES.switchYearAction]: '',
201
+ className: cls('switch-year-action'),
202
+ children: [
203
+ /*#__PURE__*/ jsx("span", {
204
+ id: gridLabelId,
205
+ "aria-live": "polite",
206
+ "aria-atomic": "true",
207
+ children: monthLabel
208
+ }),
209
+ /*#__PURE__*/ jsx(ExpandCollapseCaret_ExpandCollapseCaret, {
210
+ className: cls('switch-year-action-caret'),
211
+ size: "small",
212
+ expanded: isExpanded
213
+ })
214
+ ]
215
+ }),
216
+ !isYearView && /*#__PURE__*/ jsxs("div", {
217
+ className: cls('switch-month-actions-group'),
218
+ children: [
219
+ /*#__PURE__*/ jsx(IconButton_IconButton, {
220
+ shape: "squircle",
221
+ variant: "contained",
222
+ color: "secondary",
223
+ size: "small",
224
+ background: false,
225
+ symbol: CaretLeftMd,
226
+ className: cls('switch-month-action'),
227
+ disabled: disablePrevMonth,
228
+ onClick: selectPreviousMonth,
229
+ "aria-label": previousMonthAriaLabel,
230
+ [DATE_PICKER_HEADER_DATA_ATTRIBUTES.previousMonth]: ''
231
+ }),
232
+ /*#__PURE__*/ jsx(IconButton_IconButton, {
233
+ shape: "squircle",
234
+ variant: "contained",
235
+ color: "secondary",
236
+ size: "small",
237
+ background: false,
238
+ symbol: CaretRightMd,
239
+ className: cls('switch-month-action'),
240
+ disabled: disableNextMonth,
241
+ onClick: selectNextMonth,
242
+ "aria-label": nextMonthAriaLabel,
243
+ [DATE_PICKER_HEADER_DATA_ATTRIBUTES.nextMonth]: ''
244
+ })
245
+ ]
246
+ })
247
+ ]
248
+ })
249
+ });
154
250
  };
155
251
  DatePickerHeader.displayName = 'RcDatePickerHeader';
156
252
 
157
- const Day = forwardRef((props, ref) => {
253
+
254
+
255
+
256
+
257
+
258
+
259
+
260
+
261
+
262
+
263
+ const Day = /*#__PURE__*/ forwardRef((props, ref)=>{
158
264
  const { onSelect, value, selected, disabled, focused, children, current, date, onFocus, onBlur, ...rest } = props;
159
265
  const { getDayAriaLabel } = useScreenReaderContext() ?? {};
160
266
  const cls = useDatePickerClasses();
@@ -162,95 +268,204 @@ const Day = forwardRef((props, ref) => {
162
268
  const utils = useDateUtilsContext();
163
269
  const handleRef = useForkRef(ref, focusVisibleRef);
164
270
  const dayLabel = `${utils.getDatePickerHeaderText(date)} ${utils.getYearText(date)}`;
165
- return (jsx("button", { onClick: () => onSelect(value), ref: handleRef, className: cls('date-button', 'day', {
271
+ return /*#__PURE__*/ jsx("button", {
272
+ onClick: ()=>onSelect(value),
273
+ ref: handleRef,
274
+ className: cls('date-button', 'day', {
166
275
  'current-date': current,
167
276
  selected,
168
277
  disabled,
169
- focusVisible,
170
- }), "data-sui-picker-focused": focused ? '' : undefined, "data-sui-picker-day": value, "aria-label": getDayAriaLabel?.(dayLabel, selected, {
278
+ focusVisible
279
+ }),
280
+ "data-sui-picker-focused": focused ? '' : undefined,
281
+ "data-sui-picker-day": value,
282
+ "aria-label": getDayAriaLabel?.(dayLabel, selected, {
171
283
  date,
172
284
  disabled,
173
285
  today: current,
174
- focused,
175
- }), ...rest, ...combineProps({ onBlur, onFocus }, focusVisibleHandlers), children: children }));
286
+ focused
287
+ }),
288
+ ...rest,
289
+ ...combineProps({
290
+ onBlur,
291
+ onFocus
292
+ }, focusVisibleHandlers),
293
+ type: "button",
294
+ children: children
295
+ });
176
296
  });
177
297
  Day.displayName = 'SuiDay';
178
298
 
179
- const Year = forwardRef((props, ref) => {
299
+
300
+
301
+
302
+
303
+
304
+
305
+
306
+
307
+
308
+
309
+
310
+
311
+ const Year = /*#__PURE__*/ forwardRef((props, ref)=>{
180
312
  const { onSelect, value, selected, disabled, children, current, onFocus, onBlur, date, ...rest } = props;
181
313
  const { getYearAriaLabel } = useScreenReaderContext() ?? {};
182
314
  const cls = useDatePickerClasses();
183
315
  const { focusVisible, focusVisibleHandlers, focusVisibleRef } = useFocusVisible();
184
316
  const handleRef = useForkRef(ref, focusVisibleRef);
185
- return (jsx("button", { onClick: () => onSelect(value), ref: handleRef, className: cls('date-button', 'year', {
317
+ return /*#__PURE__*/ jsx("button", {
318
+ onClick: ()=>onSelect(value),
319
+ ref: handleRef,
320
+ className: cls('date-button', 'year', {
186
321
  'current-date': current,
187
322
  selected,
188
323
  disabled,
189
- focusVisible,
190
- }), "data-sui-picker-year": value, "aria-label": getYearAriaLabel?.(value, selected), ...rest, ...combineProps({ onBlur, onFocus }, focusVisibleHandlers), children: children }));
324
+ focusVisible
325
+ }),
326
+ "data-sui-picker-year": value,
327
+ "aria-label": getYearAriaLabel?.(value, selected),
328
+ ...rest,
329
+ ...combineProps({
330
+ onBlur,
331
+ onFocus
332
+ }, focusVisibleHandlers),
333
+ type: "button",
334
+ children: children
335
+ });
191
336
  });
192
337
  Year.displayName = 'SuiYear';
193
338
 
194
- const Years = forwardRef((props, ref) => {
195
- const { date, onYearChange, minDate, maxDate, disablePast, disableFuture, now, } = props;
339
+
340
+
341
+
342
+
343
+
344
+
345
+
346
+
347
+ const Years = /*#__PURE__*/ forwardRef((props, ref)=>{
348
+ const { date, onYearChange, minDate, maxDate, disablePast, disableFuture, now } = props;
196
349
  const utils = useDateUtilsContext();
197
350
  const containerRef = useRef(null);
198
351
  const combineRef = useForkRef(containerRef, ref);
199
352
  const selectedYearRef = useRef(null);
200
353
  const currentYear = utils.getYearText(date || now);
201
- const years = useMemo(() => utils.getYearRange(minDate, maxDate), [maxDate, minDate, utils]);
354
+ const years = useMemo(()=>utils.getYearRange(minDate, maxDate), [
355
+ maxDate,
356
+ minDate,
357
+ utils
358
+ ]);
202
359
  const focusedIndexRef = useRef(0);
203
360
  const focusedYear = utils.getYearText(years[focusedIndexRef.current]);
204
361
  const { focusIndex, getItemProps } = useOnlyOneFocusable({
205
362
  focusedIndexRef,
206
- containerRef,
363
+ containerRef
207
364
  });
208
- const getOptionDisabled = (year) => Boolean((disablePast && utils.isBeforeYear(year, now)) ||
209
- (disableFuture && utils.isAfterYear(year, now)));
365
+ const getOptionDisabled = (year)=>Boolean(disablePast && utils.isBeforeYear(year, now) || disableFuture && utils.isAfterYear(year, now));
210
366
  const { onKeyFocusedIndexHandle: handleKeyDown } = useKeyboardMoveFocus({
211
367
  options: years,
212
368
  focusedIndexRef,
213
369
  columns: 4,
214
370
  infinite: 'order',
215
- onFocusedIndexChange: (event, toIndex) => {
371
+ onFocusedIndexChange: (event, toIndex)=>{
216
372
  focusIndex(toIndex);
217
373
  event?.preventDefault();
218
374
  },
219
- getOptionDisabled,
375
+ getOptionDisabled
220
376
  });
221
- useLayoutEffect(() => {
222
- const index = years.findIndex((x) => utils.getYearText(x) === currentYear);
377
+ useLayoutEffect(()=>{
378
+ const index = years.findIndex((x)=>utils.getYearText(x) === currentYear);
223
379
  focusIndex(index);
380
+ // oxlint-disable-next-line react-hooks/exhaustive-deps
224
381
  }, []);
225
382
  const cls = useDatePickerClasses();
226
- return (jsx("div", { role: "presentation", className: cls('years-panel'), ref: combineRef, onKeyDown: handleKeyDown, children: years.map((year, index) => {
383
+ return /*#__PURE__*/ jsx("div", {
384
+ role: "presentation",
385
+ className: cls('years-panel'),
386
+ ref: combineRef,
387
+ onKeyDown: handleKeyDown,
388
+ children: years.map((year, index)=>{
227
389
  const yearText = utils.getYearText(year);
228
390
  const selected = yearText === currentYear;
229
391
  const focused = yearText === focusedYear;
230
392
  const disabled = getOptionDisabled(year);
231
- return (createElement(Year, { ...getItemProps(index), current: utils.isSameYear(year, now), ref: focused ? selectedYearRef : undefined, key: utils.getYearText(year), selected: selected, date: year, value: yearText, onSelect: (year) => {
393
+ return /*#__PURE__*/ createElement(Year, {
394
+ ...getItemProps(index),
395
+ current: utils.isSameYear(year, now),
396
+ ref: focused ? selectedYearRef : undefined,
397
+ key: utils.getYearText(year),
398
+ selected: selected,
399
+ date: year,
400
+ value: yearText,
401
+ onSelect: (year)=>{
232
402
  const newDate = utils.setYear(date, Number(year));
233
403
  onYearChange(newDate);
234
- }, disabled: disabled }, utils.getYearText(year)));
235
- }) }));
404
+ },
405
+ disabled: disabled
406
+ }, utils.getYearText(year));
407
+ })
408
+ });
236
409
  });
237
410
  Years.displayName = 'SuiYears';
238
411
 
412
+
413
+
414
+
415
+
416
+
417
+
418
+
419
+
420
+
421
+
422
+
423
+
424
+
239
425
  const DATE_PICKER_CALENDAR_GRID_LABEL_ID_PREFIX = 'DatePickerCalendarGridLabel';
240
- const Calendar = forwardRef(({ onMonthChange, date, shouldDisableDate, dateRange, todayButtonText, loadingIndicator, disablePast, disableFuture, renderDay, onSelectDay, getInvalidateDateInRange, }, ref) => {
426
+ const getFallbackHeaderFocusTarget = (target)=>{
427
+ switch(target){
428
+ case 'previousMonth':
429
+ return 'nextMonth';
430
+ case 'nextMonth':
431
+ return 'previousMonth';
432
+ default:
433
+ return 'switchYearAction';
434
+ }
435
+ };
436
+ const getHeaderButton = (root, target)=>root?.querySelector(DATE_PICKER_HEADER_SELECTORS[target]) ?? null;
437
+ const getRestorableHeaderFocusElement = (root, target)=>{
438
+ const headerElement = getHeaderButton(root, target);
439
+ if (headerElement && !headerElement.disabled) {
440
+ return headerElement;
441
+ }
442
+ const fallbackElement = getHeaderButton(root, getFallbackHeaderFocusTarget(target));
443
+ if (fallbackElement && !fallbackElement.disabled) {
444
+ return fallbackElement;
445
+ }
446
+ return getHeaderButton(root, 'switchYearAction');
447
+ };
448
+ const Calendar = /*#__PURE__*/ forwardRef(({ onMonthChange, date, shouldDisableDate, dateRange, todayButtonText, loadingIndicator, disablePast, disableFuture, renderDay, onSelectDay, getInvalidateDateInRange }, ref)=>{
241
449
  const cls = useDatePickerClasses();
242
450
  const utils = useDateUtilsContext();
243
- const previousFocusDate = usePrevious(() => focusedDate);
244
- const previousView = usePrevious(() => view);
451
+ const previousFocusDate = usePrevious(()=>focusedDate);
245
452
  const weeks = useRef([]);
246
- const weekdayLabels = useMemo(() => utils.getWeekdayLabels(), [utils]);
247
- const { now, isTodayDisabled } = useMemo(() => {
453
+ const calendarRef = useRef(null);
454
+ const handleCalendarRef = useForkRef(calendarRef, ref);
455
+ const focusIntentRef = useRef('day');
456
+ const weekdayLabels = useMemo(()=>utils.getWeekdayLabels(), [
457
+ utils
458
+ ]);
459
+ const { now, isTodayDisabled } = useMemo(()=>{
248
460
  const nowDate = utils.date();
249
461
  return {
250
462
  now: nowDate,
251
- isTodayDisabled: shouldDisableDate(nowDate),
463
+ isTodayDisabled: shouldDisableDate(nowDate)
252
464
  };
253
- }, [shouldDisableDate, utils]);
465
+ }, [
466
+ shouldDisableDate,
467
+ utils
468
+ ]);
254
469
  const [focusedDate, setFocusedDate] = useState(date);
255
470
  const [view, setView] = useState('day');
256
471
  const [slideDirection, setSlideDirection] = useState('left');
@@ -258,170 +473,312 @@ const Calendar = forwardRef(({ onMonthChange, date, shouldDisableDate, dateRange
258
473
  const gridLabelId = useId(DATE_PICKER_CALENDAR_GRID_LABEL_ID_PREFIX, true);
259
474
  const { min, max } = dateRange;
260
475
  const currentMonthNumber = utils.getMonth(focusedDate);
261
- const sameMonthDate = previousFocusDate
262
- ? isSameYearAndMonth({ source: focusedDate, comparing: previousFocusDate }, utils)
263
- : false;
476
+ const sameMonthDate = previousFocusDate ? isSameYearAndMonth({
477
+ source: focusedDate,
478
+ comparing: previousFocusDate
479
+ }, utils) : false;
264
480
  if (!sameMonthDate) {
265
481
  weeks.current = utils.getWeekArray(focusedDate);
266
482
  }
267
- const viewChange = view !== previousView;
268
- const pushToLoadingQueue = () => {
269
- setLoadingQueue(loadingQueue + 1);
483
+ const pushToLoadingQueue = ()=>{
484
+ setLoadingQueue((queue)=>queue + 1);
270
485
  };
271
- const popFromLoadingQueue = () => {
272
- setLoadingQueue(loadingQueue <= 0 ? 0 : loadingQueue - 1);
486
+ const popFromLoadingQueue = ()=>{
487
+ setLoadingQueue((queue)=>queue <= 0 ? 0 : queue - 1);
273
488
  };
274
- const handleMonthChange = useEventCallback((newMonth, direction) => {
489
+ const handleMonthChange = useEventCallback((newMonth, direction, shouldFocusDay = false)=>{
490
+ if (shouldFocusDay) {
491
+ focusIntentRef.current = 'day';
492
+ } else {
493
+ focusIntentRef.current = direction === 'left' ? 'nextMonth' : 'previousMonth';
494
+ }
275
495
  setSlideDirection(direction);
276
496
  setFocusedDate(getInvalidateDateInRange(newMonth) || newMonth);
277
497
  if (onMonthChange) {
278
498
  const returnVal = onMonthChange(newMonth);
279
499
  if (returnVal) {
280
500
  pushToLoadingQueue();
281
- returnVal.then(() => {
501
+ returnVal.then(()=>{
282
502
  popFromLoadingQueue();
283
503
  });
284
504
  }
285
505
  }
286
506
  });
287
- const handleChangeView = useEventCallback(() => {
507
+ const handleChangeView = useEventCallback(()=>{
508
+ focusIntentRef.current = null;
288
509
  setView(view === 'day' ? 'year' : 'day');
289
510
  });
290
- const disableNextMonth = useMemo(() => {
511
+ const disableNextMonth = useMemo(()=>{
291
512
  const nextStartDay = utils.startOfMonth(utils.getNextMonth(focusedDate));
292
513
  return !!getInvalidateDateInRange(nextStartDay);
293
- }, [focusedDate, getInvalidateDateInRange, utils]);
294
- const disablePrevMonth = useMemo(() => {
514
+ }, [
515
+ focusedDate,
516
+ getInvalidateDateInRange,
517
+ utils
518
+ ]);
519
+ const disablePrevMonth = useMemo(()=>{
295
520
  const prevLatestDay = utils.endOfMonth(utils.getPreviousMonth(focusedDate));
296
521
  return !!getInvalidateDateInRange(prevLatestDay);
297
- }, [focusedDate, getInvalidateDateInRange, utils]);
298
- const handleKeyDown = (event) => {
299
- const moveDay = (value) => {
522
+ }, [
523
+ focusedDate,
524
+ getInvalidateDateInRange,
525
+ utils
526
+ ]);
527
+ const handleKeyDown = (event)=>{
528
+ const moveDay = (value)=>{
300
529
  const day = utils.addDays(focusedDate, value);
301
530
  if (day && !shouldDisableDate(day)) {
302
531
  const newMonthNumber = utils.getMonth(day);
303
532
  if (newMonthNumber !== currentMonthNumber) {
304
- return handleMonthChange(day, newMonthNumber > currentMonthNumber ? 'left' : 'right');
533
+ return handleMonthChange(day, newMonthNumber > currentMonthNumber ? 'left' : 'right', true);
305
534
  }
535
+ focusIntentRef.current = 'day';
306
536
  setFocusedDate(day);
307
537
  }
308
538
  };
309
- const goToDate = (day) => {
539
+ const goToDate = (day)=>{
540
+ focusIntentRef.current = 'day';
310
541
  setFocusedDate(getInvalidateDateInRange(day) || day);
311
542
  };
312
- const confirmDate = () => {
543
+ const confirmDate = ()=>{
313
544
  event.stopPropagation();
314
545
  onSelectDay(focusedDate);
315
546
  };
316
547
  runKeyHandler(event, {
317
- ArrowUp: () => moveDay(-7),
318
- ArrowDown: () => moveDay(7),
319
- ArrowLeft: () => moveDay(-1),
320
- ArrowRight: () => moveDay(1),
321
- Home: () => goToDate(utils.startOfMonth(focusedDate)),
322
- End: () => goToDate(utils.endOfMonth(focusedDate)),
548
+ ArrowUp: ()=>moveDay(-7),
549
+ ArrowDown: ()=>moveDay(7),
550
+ ArrowLeft: ()=>moveDay(-1),
551
+ ArrowRight: ()=>moveDay(1),
552
+ Home: ()=>goToDate(utils.startOfMonth(focusedDate)),
553
+ End: ()=>goToDate(utils.endOfMonth(focusedDate)),
323
554
  Enter: confirmDate,
324
- ' ': confirmDate,
555
+ ' ': confirmDate
325
556
  });
326
557
  };
327
558
  const { getBackToTodayAriaLabel, getLoadingAriaLabel } = useScreenReaderContext() ?? {};
328
559
  const backToTodayAriaLabel = getBackToTodayAriaLabel?.();
329
560
  const loadingAriaLabel = getLoadingAriaLabel?.();
330
- const renderDays = (week) => {
561
+ const renderDays = (week)=>{
331
562
  const selectedDate = date;
332
- return week.map((day) => {
563
+ return week.map((day)=>{
333
564
  const disabled = shouldDisableDate(day);
334
565
  const isDayInCurrentMonth = utils.getMonth(day) === currentMonthNumber;
335
566
  const dayText = utils.getDayText(day);
336
567
  const key = utils.formatByString(day, 'YYYY-MM-DD');
337
568
  const selected = utils.isSameDay(day, selectedDate);
338
569
  const focused = utils.isSameDay(focusedDate, day);
339
- const dayComponent = isDayInCurrentMonth ? (jsx(Day, { disabled: disabled, current: utils.isSameDay(day, now), selected: selected, tabIndex: focused ? 0 : -1, focused: focused, date: day, value: dayText, onSelect: () => {
570
+ const dayComponent = isDayInCurrentMonth ? /*#__PURE__*/ jsx(Day, {
571
+ disabled: disabled,
572
+ current: utils.isSameDay(day, now),
573
+ selected: selected,
574
+ tabIndex: focused ? 0 : -1,
575
+ focused: focused,
576
+ date: day,
577
+ value: dayText,
578
+ onSelect: ()=>{
340
579
  isDayInCurrentMonth && onSelectDay(day);
341
- }, children: dayText }, key)) : (jsx("div", { "aria-hidden": true }, key));
342
- const renderedDay = renderDay
343
- ? renderDay(day, focusedDate, isDayInCurrentMonth, dayComponent)
344
- : dayComponent;
345
- return (jsx("td", { className: cls('day-cell'), "aria-selected": selected && isDayInCurrentMonth ? true : undefined, children: renderedDay }, key));
580
+ },
581
+ children: dayText
582
+ }, key) : /*#__PURE__*/ jsx("div", {
583
+ "aria-hidden": true
584
+ }, key);
585
+ const renderedDay = renderDay ? renderDay(day, focusedDate, isDayInCurrentMonth, dayComponent) : dayComponent;
586
+ return /*#__PURE__*/ jsx("td", {
587
+ className: cls('day-cell'),
588
+ "aria-selected": selected && isDayInCurrentMonth ? true : undefined,
589
+ children: renderedDay
590
+ }, key);
346
591
  });
347
592
  };
348
- const renderBody = () => {
349
- const loadingElement = loadingIndicator ? (loadingIndicator) : (jsx("div", { className: cls('loading-container'), children: jsx(CircularProgressIndicator, { progressBarProps: {
350
- 'aria-label': loadingAriaLabel,
351
- } }) }));
352
- switch (view) {
593
+ const renderBody = ()=>{
594
+ const loadingElement = loadingIndicator ? loadingIndicator : /*#__PURE__*/ jsx("div", {
595
+ className: cls('loading-container'),
596
+ children: /*#__PURE__*/ jsx(CircularProgressIndicator_CircularProgressIndicator, {
597
+ progressBarProps: {
598
+ 'aria-label': loadingAriaLabel
599
+ }
600
+ })
601
+ });
602
+ switch(view){
353
603
  case 'day':
354
- return (jsxs(Fragment, { children: [jsx("div", { className: cls('days-panel'), children: jsxs("table", { className: cls('days-grid'), role: "grid", "aria-labelledby": gridLabelId, "aria-busy": loadingQueue > 0 ? true : undefined, onKeyDown: handleKeyDown, children: [jsx("thead", { children: jsx("tr", { className: cls('weekdays'), children: weekdayLabels.map(({ full, min }) => (jsx("th", { className: cls('weekday'), scope: "col", abbr: full, "aria-label": full, children: min }, full))) }) }), loadingQueue > 0 ? (jsx("tbody", { "data-sui-picker-loading": "", children: jsx("tr", { children: jsx("td", { colSpan: 7, children: loadingElement }) }) })) : (jsx("tbody", { children: weeks.current.map((week) => (jsx("tr", { className: cls('week'), children: renderDays(week) }, utils.formatByString(week[0], 'YYYY-MM-DD')))) }))] }) }), jsx("div", { children: jsx(Button, { className: cls('today-button'), variant: "outlined", size: "small", color: "secondary", onClick: () => {
604
+ return /*#__PURE__*/ jsxs(Fragment, {
605
+ children: [
606
+ /*#__PURE__*/ jsx("div", {
607
+ className: cls('days-panel'),
608
+ children: /*#__PURE__*/ jsxs("table", {
609
+ className: cls('days-grid'),
610
+ role: "grid",
611
+ "aria-labelledby": gridLabelId,
612
+ "aria-busy": loadingQueue > 0 ? true : undefined,
613
+ onKeyDown: handleKeyDown,
614
+ children: [
615
+ /*#__PURE__*/ jsx("thead", {
616
+ children: /*#__PURE__*/ jsx("tr", {
617
+ className: cls('weekdays'),
618
+ children: weekdayLabels.map(({ full, min })=>/*#__PURE__*/ jsx("th", {
619
+ className: cls('weekday'),
620
+ scope: "col",
621
+ abbr: full,
622
+ "aria-label": full,
623
+ children: min
624
+ }, full))
625
+ })
626
+ }),
627
+ loadingQueue > 0 ? /*#__PURE__*/ jsx("tbody", {
628
+ "data-sui-picker-loading": "",
629
+ children: /*#__PURE__*/ jsx("tr", {
630
+ children: /*#__PURE__*/ jsx("td", {
631
+ colSpan: 7,
632
+ children: loadingElement
633
+ })
634
+ })
635
+ }) : /*#__PURE__*/ jsx("tbody", {
636
+ children: weeks.current.map((week)=>/*#__PURE__*/ jsx("tr", {
637
+ className: cls('week'),
638
+ children: renderDays(week)
639
+ }, utils.formatByString(week[0], 'YYYY-MM-DD')))
640
+ })
641
+ ]
642
+ })
643
+ }),
644
+ /*#__PURE__*/ jsx("div", {
645
+ children: /*#__PURE__*/ jsx(Button_Button, {
646
+ className: cls('today-button'),
647
+ variant: "outlined",
648
+ size: "small",
649
+ color: "secondary",
650
+ onClick: ()=>{
355
651
  onSelectDay(now);
356
- }, disabled: isTodayDisabled, "aria-label": backToTodayAriaLabel, "data-sui-picker-today": "", children: todayButtonText }) })] }));
652
+ },
653
+ disabled: isTodayDisabled,
654
+ "aria-label": backToTodayAriaLabel,
655
+ "data-sui-picker-today": "",
656
+ children: todayButtonText
657
+ })
658
+ })
659
+ ]
660
+ });
357
661
  case 'year':
358
- return (jsx(Years, { date: focusedDate, minDate: min, maxDate: max, onYearChange: (day) => {
662
+ return /*#__PURE__*/ jsx(Years, {
663
+ date: focusedDate,
664
+ minDate: min,
665
+ maxDate: max,
666
+ onYearChange: (day)=>{
667
+ focusIntentRef.current = 'switchYearAction';
359
668
  setView('day');
360
669
  const validateDate = getInvalidateDateInRange(day) || day;
361
670
  setFocusedDate(validateDate);
362
- }, disablePast: disablePast, disableFuture: disableFuture, now: now }));
671
+ },
672
+ disablePast: disablePast,
673
+ disableFuture: disableFuture,
674
+ now: now
675
+ });
363
676
  default:
364
677
  return null;
365
678
  }
366
679
  };
367
- const { document } = useWindowContext();
368
- useLayoutEffect(() => {
369
- if (viewChange)
680
+ useLayoutEffect(()=>{
681
+ const focusIntent = focusIntentRef.current;
682
+ if (!focusIntent) {
683
+ return;
684
+ }
685
+ if (focusIntent !== 'day') {
686
+ const focusTarget = getRestorableHeaderFocusElement(calendarRef.current, focusIntent);
687
+ if (focusTarget) {
688
+ focusTarget.focus();
689
+ focusIntentRef.current = null;
690
+ }
370
691
  return;
371
- if (sameMonthDate) {
372
- focusDayElement();
692
+ }
693
+ if (loadingQueue > 0) {
373
694
  return;
374
695
  }
375
- const activeEl = document?.activeElement;
376
- if (activeEl &&
377
- !activeEl.hasAttribute('data-sui-picker-next-month') &&
378
- !activeEl.hasAttribute('data-sui-picker-previous-month')) {
379
- const timer = setTimeout(() => {
380
- focusDayElement();
381
- });
382
- return () => {
383
- clearTimeout(timer);
384
- };
696
+ if (focusDayElement(calendarRef.current)) {
697
+ focusIntentRef.current = null;
385
698
  }
386
- return undefined;
387
699
  });
388
- useLayoutEffect(() => {
389
- if (previousView && view === 'day' && viewChange) {
390
- focusDayElement();
391
- }
392
- }, [previousView, view, viewChange]);
393
- useLayoutEffect(() => {
394
- focusDayElement();
395
- }, []);
396
- return (jsxs("div", { className: cls('calendar'), ref: ref, children: [jsx(DatePickerHeader, { focusedDate: focusedDate, slideDirection: slideDirection, view: view, onMonthChange: handleMonthChange, onViewChange: handleChangeView, disablePrevMonth: disablePrevMonth, disableNextMonth: disableNextMonth, gridLabelId: gridLabelId }), renderBody()] }));
700
+ return /*#__PURE__*/ jsxs("div", {
701
+ className: cls('calendar'),
702
+ ref: handleCalendarRef,
703
+ children: [
704
+ /*#__PURE__*/ jsx(DatePickerHeader, {
705
+ focusedDate: focusedDate,
706
+ slideDirection: slideDirection,
707
+ view: view,
708
+ onMonthChange: handleMonthChange,
709
+ onViewChange: handleChangeView,
710
+ disablePrevMonth: disablePrevMonth,
711
+ disableNextMonth: disableNextMonth,
712
+ gridLabelId: gridLabelId
713
+ }),
714
+ renderBody()
715
+ ]
716
+ });
397
717
  });
398
718
  Calendar.displayName = 'RcCalendar';
399
719
 
400
- var DatePicker$1 = {"sui-date-picker-calendar":"sui-date-picker-calendar","sui-date-picker-header":"sui-date-picker-header","sui-date-picker-header-action":"sui-date-picker-header-action","sui-focus-visible":"sui-focus-visible","sui-disabled":"sui-disabled","sui-date-picker-switch-year-action":"sui-date-picker-switch-year-action","sui-date-picker-switch-year-action-caret":"sui-date-picker-switch-year-action-caret","sui-date-picker-switch-month-actions-group":"sui-date-picker-switch-month-actions-group","sui-date-picker-switch-month-action":"sui-date-picker-switch-month-action","sui-date-picker-date-button":"sui-date-picker-date-button","sui-selected":"sui-selected","sui-date-picker-current-date":"sui-date-picker-current-date","sui-date-picker-day":"sui-date-picker-day","sui-date-picker-year":"sui-date-picker-year","sui-date-picker-years-panel":"sui-date-picker-years-panel","sui-date-picker-days-panel":"sui-date-picker-days-panel","sui-date-picker-days-grid":"sui-date-picker-days-grid","sui-date-picker-week":"sui-date-picker-week","sui-date-picker-weekdays":"sui-date-picker-weekdays","sui-date-picker-day-cell":"sui-date-picker-day-cell","sui-date-picker-weekday":"sui-date-picker-weekday","sui-date-picker-loading-container":"sui-date-picker-loading-container","sui-date-picker-today-button":"sui-date-picker-today-button","sui-compact":"sui-compact"};
720
+
721
+
722
+
723
+
724
+
725
+
726
+
727
+ // extracted by css-extract-rspack-plugin
728
+ /* export default */ var DatePicker = ({"sui-date-picker-calendar":"sui-date-picker-calendar","sui-date-picker-header":"sui-date-picker-header","sui-date-picker-header-action":"sui-date-picker-header-action","sui-focus-visible":"sui-focus-visible","sui-disabled":"sui-disabled","sui-date-picker-switch-year-action":"sui-date-picker-switch-year-action","sui-date-picker-switch-year-action-caret":"sui-date-picker-switch-year-action-caret","sui-date-picker-switch-month-actions-group":"sui-date-picker-switch-month-actions-group","sui-date-picker-switch-month-action":"sui-date-picker-switch-month-action","sui-date-picker-date-button":"sui-date-picker-date-button","sui-selected":"sui-selected","sui-date-picker-current-date":"sui-date-picker-current-date","sui-date-picker-day":"sui-date-picker-day","sui-date-picker-year":"sui-date-picker-year","sui-date-picker-years-panel":"sui-date-picker-years-panel","sui-date-picker-days-panel":"sui-date-picker-days-panel","sui-date-picker-days-grid":"sui-date-picker-days-grid","sui-date-picker-week":"sui-date-picker-week","sui-date-picker-weekdays":"sui-date-picker-weekdays","sui-date-picker-day-cell":"sui-date-picker-day-cell","sui-date-picker-weekday":"sui-date-picker-weekday","sui-date-picker-loading-container":"sui-date-picker-loading-container","sui-date-picker-today-button":"sui-date-picker-today-button","sui-compact":"sui-compact"});
729
+
730
+
731
+
732
+
733
+
734
+
735
+
736
+
737
+
738
+
739
+
740
+
401
741
 
402
742
  const defaultMinDate = new Date('1900-01-01');
403
743
  const defaultMaxDate = new Date('2100-01-01');
404
744
  const DEFAULT_FORMAT = 'MM/DD/YYYY';
405
- const InnerDatePicker = (props) => {
745
+ const InnerDatePicker = (props)=>{
406
746
  const { innerRef, value, onChange, formatString = DEFAULT_FORMAT, todayButtonText = 'Today', min: minDate = null, max: maxDate = null, disableFuture, disablePast, loadingIndicator, onMonthChange, renderDay, disabled, shouldDisableDate: shouldDisableDateProp, onClose, onClear, classes, PopoverProps, screenReaderProps, clearBtn = true, label = 'Date', className, ...rest } = props;
407
- const cls = useClassesWithMode('date-picker', classes, className, ['calendar']);
747
+ const cls = useClassesWithMode('date-picker', classes, className, [
748
+ 'calendar'
749
+ ]);
408
750
  const utils = useDateUtilsContext();
409
751
  const [controlledValue, setControlledValue] = useControlled({
410
752
  controlled: value,
411
753
  default: null,
412
- name: 'DatePicker',
754
+ name: 'DatePicker'
413
755
  });
414
756
  const actionRef = useRef(null);
415
757
  const minDateValue = minDate?.valueOf() ?? defaultMinDate.valueOf();
416
758
  const maxDateValue = maxDate?.valueOf() ?? defaultMaxDate.valueOf();
417
- const dateRange = useMemo(() => ({
418
- min: dayjs(minDateValue),
419
- max: dayjs(maxDateValue),
420
- }), [minDateValue, maxDateValue]);
421
- const getInvalidateDateInRange = useCallback((day) => invalidateDateInRange(day, { dateRange, now: utils.date(), disableFuture, disablePast }, utils), [dateRange, disableFuture, disablePast, utils]);
422
- const shouldDisableDate = useCallback((day) => Boolean(getInvalidateDateInRange(day)) ||
423
- Boolean(shouldDisableDateProp?.(day)), [getInvalidateDateInRange, shouldDisableDateProp]);
424
- const getClosestEnabledDate = useCallback((currDate) => {
759
+ const dateRange = useMemo(()=>({
760
+ min: dayjs(minDateValue),
761
+ max: dayjs(maxDateValue)
762
+ }), [
763
+ minDateValue,
764
+ maxDateValue
765
+ ]);
766
+ const getInvalidateDateInRange = useCallback((day)=>invalidateDateInRange(day, {
767
+ dateRange,
768
+ now: utils.date(),
769
+ disableFuture,
770
+ disablePast
771
+ }, utils), [
772
+ dateRange,
773
+ disableFuture,
774
+ disablePast,
775
+ utils
776
+ ]);
777
+ const shouldDisableDate = useCallback((day)=>Boolean(getInvalidateDateInRange(day)) || Boolean(shouldDisableDateProp?.(day)), [
778
+ getInvalidateDateInRange,
779
+ shouldDisableDateProp
780
+ ]);
781
+ const getClosestEnabledDate = useCallback((currDate)=>{
425
782
  return findClosestEnabledDate({
426
783
  date: currDate,
427
784
  utils,
@@ -429,7 +786,7 @@ const InnerDatePicker = (props) => {
429
786
  maxDate: utils.date(dateRange.max),
430
787
  disablePast: Boolean(disablePast),
431
788
  disableFuture: Boolean(disableFuture),
432
- shouldDisableDate,
789
+ shouldDisableDate
433
790
  });
434
791
  }, [
435
792
  dateRange.max,
@@ -437,22 +794,32 @@ const InnerDatePicker = (props) => {
437
794
  disableFuture,
438
795
  disablePast,
439
796
  shouldDisableDate,
797
+ utils
798
+ ]);
799
+ const initialDate = useMemo(()=>getClosestEnabledDate(utils.date()), [
440
800
  utils,
801
+ getClosestEnabledDate
802
+ ]);
803
+ const dayjsValue = useMemo(()=>controlledValue ? dayjs(controlledValue) : null, [
804
+ controlledValue
441
805
  ]);
442
- const initialDate = useMemo(() => getClosestEnabledDate(utils.date()), [utils, getClosestEnabledDate]);
443
- const dayjsValue = useMemo(() => (controlledValue ? dayjs(controlledValue) : null), [controlledValue]);
444
806
  const nowDate = dayjsValue || initialDate;
445
- const textFiledValue = useMemo(() => (dayjsValue ? utils.formatByString(dayjsValue, formatString) : ''), [dayjsValue, utils, formatString]);
446
- const handleChange = (toDate, fromUserSelect) => {
807
+ const textFiledValue = useMemo(()=>dayjsValue ? utils.formatByString(dayjsValue, formatString) : '', [
808
+ dayjsValue,
809
+ utils,
810
+ formatString
811
+ ]);
812
+ const handleChange = (toDate, fromUserSelect)=>{
447
813
  actionRef.current?.close();
448
814
  setControlledValue(toDate);
449
815
  onChange?.(toDate, fromUserSelect);
450
816
  };
451
- const handleDaySelect = useEventCallback((day, fromUserSelect = true) => {
817
+ const handleDaySelect = useEventCallback((day, fromUserSelect = true)=>{
452
818
  const newDay = day ? utils.startOfDay(day).toDate() : null;
453
819
  handleChange(newDay, fromUserSelect);
454
820
  });
455
- useEffect(() => {
821
+ // Revalidate controlled values when disabled-date rules change.
822
+ useEffect(()=>{
456
823
  if (!dayjsValue || !shouldDisableDate(dayjsValue)) {
457
824
  return;
458
825
  }
@@ -465,20 +832,74 @@ const InnerDatePicker = (props) => {
465
832
  getClosestEnabledDate,
466
833
  handleDaySelect,
467
834
  shouldDisableDate,
468
- utils,
835
+ utils
469
836
  ]);
470
- return (jsx(DatePickerClassesContext.Provider, { value: cls, children: jsx(PickerTextField, { className: cls('root'), variant: "standard", label: label, ref: innerRef, action: actionRef, onClear: (e) => {
837
+ return /*#__PURE__*/ jsx(DatePickerClassesContext.Provider, {
838
+ value: cls,
839
+ children: /*#__PURE__*/ jsx(PickerTextField_PickerTextField, {
840
+ className: cls('root'),
841
+ variant: "standard",
842
+ label: label,
843
+ ref: innerRef,
844
+ action: actionRef,
845
+ onClear: (e)=>{
471
846
  onClear?.(e);
472
847
  handleChange(null);
473
- }, PopoverProps: PopoverProps, value: textFiledValue, disabled: disabled, endIconSymbol: CalendarMd, onClose: onClose, clearBtn: clearBtn, ...rest, children: jsx(ScreenReaderProvider, { screenReaderProps: screenReaderProps, children: jsx(Calendar, { date: nowDate, dateRange: dateRange, onSelectDay: handleDaySelect, disableFuture: disableFuture, disablePast: disablePast, loadingIndicator: loadingIndicator, onMonthChange: onMonthChange, renderDay: renderDay, shouldDisableDate: shouldDisableDate, getInvalidateDateInRange: getInvalidateDateInRange, todayButtonText: todayButtonText, formatString: formatString }) }) }) }));
848
+ },
849
+ PopoverProps: PopoverProps,
850
+ value: textFiledValue,
851
+ disabled: disabled,
852
+ endIconSymbol: CalendarMd,
853
+ onClose: onClose,
854
+ clearBtn: clearBtn,
855
+ ...rest,
856
+ children: /*#__PURE__*/ jsx(ScreenReaderProvider, {
857
+ screenReaderProps: screenReaderProps,
858
+ children: /*#__PURE__*/ jsx(Calendar, {
859
+ date: nowDate,
860
+ dateRange: dateRange,
861
+ onSelectDay: handleDaySelect,
862
+ disableFuture: disableFuture,
863
+ disablePast: disablePast,
864
+ loadingIndicator: loadingIndicator,
865
+ onMonthChange: onMonthChange,
866
+ renderDay: renderDay,
867
+ shouldDisableDate: shouldDisableDate,
868
+ getInvalidateDateInRange: getInvalidateDateInRange,
869
+ todayButtonText: todayButtonText,
870
+ formatString: formatString
871
+ })
872
+ })
873
+ })
874
+ });
474
875
  };
475
- const DatePicker = forwardRef((inProps, ref) => {
876
+ const DatePicker_DatePicker = /*#__PURE__*/ forwardRef((inProps, ref)=>{
476
877
  const { locale = 'en', ...rest } = useThemeProps({
477
878
  props: inProps,
478
- name: 'DatePicker',
879
+ name: 'DatePicker'
880
+ });
881
+ return /*#__PURE__*/ jsx(DateUtilsProvider, {
882
+ locale: locale,
883
+ children: /*#__PURE__*/ jsx(InnerDatePicker, {
884
+ innerRef: ref,
885
+ ...rest
886
+ })
479
887
  });
480
- return (jsx(DateUtilsProvider, { locale: locale, children: jsx(InnerDatePicker, { innerRef: ref, ...rest }) }));
481
888
  });
482
- DatePicker.displayName = 'SuiDatePicker';
889
+ DatePicker_DatePicker.displayName = 'SuiDatePicker';
890
+
891
+
892
+
893
+
894
+
895
+
896
+
897
+
898
+
899
+
900
+
901
+
902
+
903
+
483
904
 
484
- export { Calendar, DEFAULT_FORMAT, DatePicker, DatePickerClassesContext, DatePickerHeader, Day, HeaderAction, ScreenReaderContext, ScreenReaderProvider, Year, Years, DatePicker$1 as datePickerStyle, findClosestEnabledDate, focusDayElement, invalidateDateInRange, isSameYearAndMonth, useDatePickerClasses, useScreenReaderContext };
905
+ export { Calendar, DEFAULT_FORMAT, DatePicker as datePickerStyle, DatePickerClassesContext, DatePickerHeader, DatePicker_DatePicker as DatePicker, Day, HeaderAction, ScreenReaderContext, ScreenReaderProvider, Year, Years, findClosestEnabledDate, focusDayElement, invalidateDateInRange, isSameYearAndMonth, useDatePickerClasses, useScreenReaderContext };