@ringcentral/spring-ui 1.12.0 → 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 (213) hide show
  1. package/Accordion.js +90 -34
  2. package/AccordionHeader.js +71 -21
  3. package/Alert.js +120 -28
  4. package/Animation.js +2 -46
  5. package/Announcement.js +46 -35
  6. package/Autocomplete.js +1011 -583
  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 +57 -15
  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 -192
  23. package/DateUtilsContext.js +43 -25
  24. package/Dialer.js +564 -253
  25. package/Dialog.js +99 -45
  26. package/Divider.js +43 -7
  27. package/DragHandle.js +32 -6
  28. package/Drawer.js +117 -19
  29. package/Dropdown.js +154 -77
  30. package/EmptyState.js +65 -15
  31. package/FabButton.js +51 -17
  32. package/FocusTrap.js +109 -12
  33. package/FormField.js +108 -12
  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 -17
  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 -16
  50. package/MenuItem.js +402 -35
  51. package/MenuItemText.js +51 -9
  52. package/MenuList.js +87 -36
  53. package/Modal.js +345 -16
  54. package/NestedMenuContext.js +183 -11
  55. package/Option.js +32 -36
  56. package/Overlap.js +54 -7
  57. package/PageHeader.js +62 -24
  58. package/PickerTextField.js +156 -35
  59. package/Popover.js +262 -21
  60. package/Popper.js +112 -62
  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 -44
  67. package/SingleFilter.js +148 -79
  68. package/Skeleton.js +68 -17
  69. package/Slider.js +167 -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 +44 -20
  75. package/SplitButton.js +124 -89
  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 +67 -24
  82. package/StepIcon.js +90 -9
  83. package/StepLabel.js +90 -14
  84. package/Stepper.js +65 -23
  85. package/SubMenu.js +203 -101
  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 -79
  98. package/TableRow.js +60 -21
  99. package/Tabs.js +592 -271
  100. package/Tag.js +51 -16
  101. package/Text.js +68 -37
  102. package/TextField.js +209 -31
  103. package/Textarea.js +51 -42
  104. package/TimePicker.js +490 -232
  105. package/Tooltip.js +48 -23
  106. package/Tray.js +237 -13
  107. package/TrayMenu.js +62 -43
  108. package/VirtualizedList.js +205 -107
  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 +2436 -2261
  127. package/index.js +245 -195
  128. package/internal/utils/setRef.d.ts +2 -1
  129. package/package.json +4 -4
  130. package/src/Animation/hooks/useMotionSafeTransition/useMotionSafeTransition.d.ts +2 -0
  131. package/src/Autocomplete/SuggestionList/SuggestionList.d.ts +1 -1
  132. package/src/Button/Button.classes.d.ts +1 -1
  133. package/src/ComponentsProps.d.ts +111 -110
  134. package/src/DatePicker/DatePickerDataAttributes.d.ts +11 -0
  135. package/src/DatePicker/utils/DatePickerUtils.d.ts +1 -1
  136. package/src/MenuItem/MenuItem.type.d.ts +1 -0
  137. package/src/MenuList/MenuListContext.d.ts +2 -3
  138. package/src/Modal/Modal.type.d.ts +1 -0
  139. package/src/Popover/Popover.classes.d.ts +1 -1
  140. package/src/Popover/Popover.internal.d.ts +8 -0
  141. package/src/Popover/Popover.type.d.ts +1 -0
  142. package/src/Select/Select.type.d.ts +6 -4
  143. package/src/Table/Table.type.d.ts +3 -0
  144. package/src/Table/TableContext.d.ts +3 -0
  145. package/src/Table/TableRowContext.d.ts +7 -0
  146. package/src/Table/index.d.ts +1 -0
  147. package/src/TableCell/TableCell.classes.d.ts +1 -1
  148. package/src/TableFooter/TableFooter.classes.d.ts +1 -1
  149. package/src/TableFooter/TableFooter.type.d.ts +1 -0
  150. package/src/TableHead/TableHead.classes.d.ts +1 -1
  151. package/src/TableHead/TableHead.type.d.ts +1 -0
  152. package/src/TableRow/TableRow.type.d.ts +2 -0
  153. package/chunks/AccordionContext.js +0 -6
  154. package/chunks/Alert.js +0 -48
  155. package/chunks/AvatarGroup.js +0 -22
  156. package/chunks/Backdrop.js +0 -18
  157. package/chunks/Badge.js +0 -32
  158. package/chunks/BottomNavigationItem.js +0 -36
  159. package/chunks/Button.js +0 -88
  160. package/chunks/Chip.js +0 -73
  161. package/chunks/CircularProgressIndicator.js +0 -36
  162. package/chunks/Divider.js +0 -19
  163. package/chunks/DragHandle.js +0 -11
  164. package/chunks/Drawer.js +0 -33
  165. package/chunks/ExpandCollapseCaret.js +0 -24
  166. package/chunks/FormLabel.js +0 -27
  167. package/chunks/Icon.js +0 -25
  168. package/chunks/IconButtonLabel.js +0 -68
  169. package/chunks/List.js +0 -22
  170. package/chunks/ListItem.js +0 -83
  171. package/chunks/Menu.js +0 -61
  172. package/chunks/MenuDivider.js +0 -14
  173. package/chunks/MenuItemText.js +0 -18
  174. package/chunks/MenuList.js +0 -47
  175. package/chunks/Modal.js +0 -211
  176. package/chunks/Overlap.js +0 -25
  177. package/chunks/PickerTextField.js +0 -85
  178. package/chunks/Popover.js +0 -61
  179. package/chunks/PopperPaper.js +0 -15
  180. package/chunks/Select.js +0 -225
  181. package/chunks/ShowHideEye.js +0 -56
  182. package/chunks/SlideIn.js +0 -20
  183. package/chunks/SortableArrow.js +0 -73
  184. package/chunks/Squircle.js +0 -31
  185. package/chunks/StatusIndicator.js +0 -20
  186. package/chunks/StepConnector.js +0 -21
  187. package/chunks/StepIcon.js +0 -43
  188. package/chunks/StepLabel.js +0 -29
  189. package/chunks/StepperContext.js +0 -9
  190. package/chunks/TableContext.js +0 -6
  191. package/chunks/Tablelvl2Context.js +0 -6
  192. package/chunks/TabsContext.js +0 -6
  193. package/chunks/TextField.js +0 -110
  194. package/chunks/Tooltip.js +0 -217
  195. package/chunks/VirtualizedMenu.js +0 -162
  196. package/chunks/VisuallyHidden.js +0 -12
  197. package/chunks/composeEventHandlers.js +0 -10
  198. package/chunks/getFade.js +0 -27
  199. package/chunks/getGrow.js +0 -70
  200. package/chunks/getSlideIn.js +0 -30
  201. package/chunks/hasContent.js +0 -3
  202. package/chunks/useAnimationFrame.js +0 -15
  203. package/chunks/useFocusTrapStack.js +0 -38
  204. package/chunks/useHelperTextId.js +0 -24
  205. package/chunks/useListNavigation.js +0 -199
  206. package/chunks/useMenuItemSelect.js +0 -282
  207. package/chunks/useMotionSafeTransition.js +0 -9
  208. package/chunks/useNestedMenuItem.js +0 -27
  209. package/chunks/useNestedParentMenu.js +0 -113
  210. package/chunks/usePrefersReducedMotion.js +0 -36
  211. package/chunks/useTooltipForceHide.js +0 -27
  212. package/chunks/useTrayNavigate.js +0 -150
  213. package/chunks/withTooltip.js +0 -15
package/DatePicker.js CHANGED
@@ -1,70 +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/hasContent.js';
34
- import '@mui/utils';
35
- import './chunks/TextField.js';
36
- import './chunks/ShowHideEye.js';
37
- import './chunks/VisuallyHidden.js';
38
-
39
- const DatePickerClassesContext = createContext(() => '');
40
- const useDatePickerClasses = () => useContext(DatePickerClassesContext);
41
-
42
- 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)=>{
43
47
  const { className, disabled, ...rest } = props;
44
48
  const cls = useDatePickerClasses();
45
49
  const { focusVisible, focusVisibleRef, focusVisibleHandlers } = useFocusVisible();
46
- return (jsx("button", { className: clsx(className, cls('header-action', { focusVisible, disabled })), ref: focusVisibleRef, ...rest, ...focusVisibleHandlers, type: "button" }));
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
+ });
47
60
  };
48
61
 
62
+
63
+
64
+
65
+
66
+
49
67
  const defaultScreenReaderProps = {
50
- getMonthYearAriaLabel: (monthLabel, expanded) => `${monthLabel}${expanded ? ', year selection expanded' : ''}`,
51
- getSwitchMonthAriaLabel: (isNext, currentMonth) => `${isNext ? 'Next' : 'Previous'} month, currently viewing ${currentMonth}`,
52
- getBackToTodayAriaLabel: () => 'Go back to today',
53
- getLoadingAriaLabel: () => 'Loading dates',
54
- getDayAriaLabel: (day, selected) => `${day}${selected ? ', selected' : ''}`,
55
- 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' : ''}`
56
74
  };
57
- const ScreenReaderContext = createContext(defaultScreenReaderProps);
58
- const useScreenReaderContext = () => useContext(ScreenReaderContext);
59
- const ScreenReaderProvider = ({ screenReaderProps, children, }) => {
60
- 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
+ });
61
82
  };
62
83
 
63
- const focusDayElement = () => {
64
- const elm = document.querySelector('[data-sui-picker-focused]');
65
- elm?.focus();
84
+
85
+ const focusDayElement = (root = document)=>{
86
+ const focusedDayElement = root?.querySelector('[data-sui-picker-focused]');
87
+ focusedDayElement?.focus();
88
+ return focusedDayElement;
66
89
  };
67
- const isSameYearAndMonth = ({ source, comparing }, utils) => {
90
+ const isSameYearAndMonth = ({ source, comparing }, utils)=>{
68
91
  if (!source || !comparing) {
69
92
  return false;
70
93
  }
@@ -74,7 +97,7 @@ const isSameYearAndMonth = ({ source, comparing }, utils) => {
74
97
  const comparingYear = utils.getYear(comparing);
75
98
  return thisMonth === comparingMonth && thisYear === comparingYear;
76
99
  };
77
- const invalidateDateInRange = (day, { dateRange: { min, max }, disableFuture, disablePast, now, }, utils) => {
100
+ const invalidateDateInRange = (day, { dateRange: { min, max }, disableFuture, disablePast, now }, utils)=>{
78
101
  if (disableFuture && utils.isAfterDay(day, now)) {
79
102
  return now;
80
103
  }
@@ -90,7 +113,7 @@ const invalidateDateInRange = (day, { dateRange: { min, max }, disableFuture, di
90
113
  return false;
91
114
  };
92
115
 
93
- const findClosestEnabledDate = ({ date, utils, minDate, maxDate, disableFuture, disablePast, shouldDisableDate, }) => {
116
+ const findClosestEnabledDate = ({ date, utils, minDate, maxDate, disableFuture, disablePast, shouldDisableDate })=>{
94
117
  const today = utils.startOfDay(utils.date());
95
118
  if (disablePast && utils.isBefore(minDate, today)) {
96
119
  minDate = today;
@@ -110,7 +133,7 @@ const findClosestEnabledDate = ({ date, utils, minDate, maxDate, disableFuture,
110
133
  }
111
134
  forward = null;
112
135
  }
113
- while (forward || backward) {
136
+ while(forward || backward){
114
137
  if (forward && utils.isAfter(forward, maxDate)) {
115
138
  forward = null;
116
139
  }
@@ -130,20 +153,34 @@ const findClosestEnabledDate = ({ date, utils, minDate, maxDate, disableFuture,
130
153
  backward = utils.addDays(backward, -1);
131
154
  }
132
155
  }
156
+ // fallback to today if no enabled days
133
157
  return utils.date();
134
158
  };
135
159
 
136
- const DatePickerHeader = (props) => {
137
- 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;
138
175
  const utils = useDateUtilsContext();
139
176
  const cls = useDatePickerClasses();
140
177
  const preMonth = utils.getPreviousMonth(focusedDate);
141
178
  const nextMonth = utils.getNextMonth(focusedDate);
142
179
  const monthLabel = utils.getCalendarHeaderText(focusedDate);
143
- const selectNextMonth = () => {
180
+ const selectNextMonth = ()=>{
144
181
  onMonthChange(nextMonth, 'left');
145
182
  };
146
- const selectPreviousMonth = () => {
183
+ const selectPreviousMonth = ()=>{
147
184
  onMonthChange(preMonth, 'right');
148
185
  };
149
186
  const isYearView = view === 'year';
@@ -152,11 +189,78 @@ const DatePickerHeader = (props) => {
152
189
  const monthYearAriaLabel = getMonthYearAriaLabel?.(`${monthLabel}`, isExpanded);
153
190
  const nextMonthAriaLabel = getSwitchMonthAriaLabel?.(true, utils.getMonthText(focusedDate));
154
191
  const previousMonthAriaLabel = getSwitchMonthAriaLabel?.(false, utils.getMonthText(focusedDate));
155
- 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
+ });
156
250
  };
157
251
  DatePickerHeader.displayName = 'RcDatePickerHeader';
158
252
 
159
- const Day = forwardRef((props, ref) => {
253
+
254
+
255
+
256
+
257
+
258
+
259
+
260
+
261
+
262
+
263
+ const Day = /*#__PURE__*/ forwardRef((props, ref)=>{
160
264
  const { onSelect, value, selected, disabled, focused, children, current, date, onFocus, onBlur, ...rest } = props;
161
265
  const { getDayAriaLabel } = useScreenReaderContext() ?? {};
162
266
  const cls = useDatePickerClasses();
@@ -164,95 +268,204 @@ const Day = forwardRef((props, ref) => {
164
268
  const utils = useDateUtilsContext();
165
269
  const handleRef = useForkRef(ref, focusVisibleRef);
166
270
  const dayLabel = `${utils.getDatePickerHeaderText(date)} ${utils.getYearText(date)}`;
167
- 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', {
168
275
  'current-date': current,
169
276
  selected,
170
277
  disabled,
171
- focusVisible,
172
- }), "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, {
173
283
  date,
174
284
  disabled,
175
285
  today: current,
176
- focused,
177
- }), ...rest, ...combineProps({ onBlur, onFocus }, focusVisibleHandlers), type: "button", children: children }));
286
+ focused
287
+ }),
288
+ ...rest,
289
+ ...combineProps({
290
+ onBlur,
291
+ onFocus
292
+ }, focusVisibleHandlers),
293
+ type: "button",
294
+ children: children
295
+ });
178
296
  });
179
297
  Day.displayName = 'SuiDay';
180
298
 
181
- const Year = forwardRef((props, ref) => {
299
+
300
+
301
+
302
+
303
+
304
+
305
+
306
+
307
+
308
+
309
+
310
+
311
+ const Year = /*#__PURE__*/ forwardRef((props, ref)=>{
182
312
  const { onSelect, value, selected, disabled, children, current, onFocus, onBlur, date, ...rest } = props;
183
313
  const { getYearAriaLabel } = useScreenReaderContext() ?? {};
184
314
  const cls = useDatePickerClasses();
185
315
  const { focusVisible, focusVisibleHandlers, focusVisibleRef } = useFocusVisible();
186
316
  const handleRef = useForkRef(ref, focusVisibleRef);
187
- 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', {
188
321
  'current-date': current,
189
322
  selected,
190
323
  disabled,
191
- focusVisible,
192
- }), "data-sui-picker-year": value, "aria-label": getYearAriaLabel?.(value, selected), ...rest, ...combineProps({ onBlur, onFocus }, focusVisibleHandlers), type: "button", 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
+ });
193
336
  });
194
337
  Year.displayName = 'SuiYear';
195
338
 
196
- const Years = forwardRef((props, ref) => {
197
- 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;
198
349
  const utils = useDateUtilsContext();
199
350
  const containerRef = useRef(null);
200
351
  const combineRef = useForkRef(containerRef, ref);
201
352
  const selectedYearRef = useRef(null);
202
353
  const currentYear = utils.getYearText(date || now);
203
- 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
+ ]);
204
359
  const focusedIndexRef = useRef(0);
205
360
  const focusedYear = utils.getYearText(years[focusedIndexRef.current]);
206
361
  const { focusIndex, getItemProps } = useOnlyOneFocusable({
207
362
  focusedIndexRef,
208
- containerRef,
363
+ containerRef
209
364
  });
210
- const getOptionDisabled = (year) => Boolean((disablePast && utils.isBeforeYear(year, now)) ||
211
- (disableFuture && utils.isAfterYear(year, now)));
365
+ const getOptionDisabled = (year)=>Boolean(disablePast && utils.isBeforeYear(year, now) || disableFuture && utils.isAfterYear(year, now));
212
366
  const { onKeyFocusedIndexHandle: handleKeyDown } = useKeyboardMoveFocus({
213
367
  options: years,
214
368
  focusedIndexRef,
215
369
  columns: 4,
216
370
  infinite: 'order',
217
- onFocusedIndexChange: (event, toIndex) => {
371
+ onFocusedIndexChange: (event, toIndex)=>{
218
372
  focusIndex(toIndex);
219
373
  event?.preventDefault();
220
374
  },
221
- getOptionDisabled,
375
+ getOptionDisabled
222
376
  });
223
- useLayoutEffect(() => {
224
- const index = years.findIndex((x) => utils.getYearText(x) === currentYear);
377
+ useLayoutEffect(()=>{
378
+ const index = years.findIndex((x)=>utils.getYearText(x) === currentYear);
225
379
  focusIndex(index);
380
+ // oxlint-disable-next-line react-hooks/exhaustive-deps
226
381
  }, []);
227
382
  const cls = useDatePickerClasses();
228
- 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)=>{
229
389
  const yearText = utils.getYearText(year);
230
390
  const selected = yearText === currentYear;
231
391
  const focused = yearText === focusedYear;
232
392
  const disabled = getOptionDisabled(year);
233
- 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)=>{
234
402
  const newDate = utils.setYear(date, Number(year));
235
403
  onYearChange(newDate);
236
- }, disabled: disabled }, utils.getYearText(year)));
237
- }) }));
404
+ },
405
+ disabled: disabled
406
+ }, utils.getYearText(year));
407
+ })
408
+ });
238
409
  });
239
410
  Years.displayName = 'SuiYears';
240
411
 
412
+
413
+
414
+
415
+
416
+
417
+
418
+
419
+
420
+
421
+
422
+
423
+
424
+
241
425
  const DATE_PICKER_CALENDAR_GRID_LABEL_ID_PREFIX = 'DatePickerCalendarGridLabel';
242
- 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)=>{
243
449
  const cls = useDatePickerClasses();
244
450
  const utils = useDateUtilsContext();
245
- const previousFocusDate = usePrevious(() => focusedDate);
246
- const previousView = usePrevious(() => view);
451
+ const previousFocusDate = usePrevious(()=>focusedDate);
247
452
  const weeks = useRef([]);
248
- const weekdayLabels = useMemo(() => utils.getWeekdayLabels(), [utils]);
249
- 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(()=>{
250
460
  const nowDate = utils.date();
251
461
  return {
252
462
  now: nowDate,
253
- isTodayDisabled: shouldDisableDate(nowDate),
463
+ isTodayDisabled: shouldDisableDate(nowDate)
254
464
  };
255
- }, [shouldDisableDate, utils]);
465
+ }, [
466
+ shouldDisableDate,
467
+ utils
468
+ ]);
256
469
  const [focusedDate, setFocusedDate] = useState(date);
257
470
  const [view, setView] = useState('day');
258
471
  const [slideDirection, setSlideDirection] = useState('left');
@@ -260,170 +473,312 @@ const Calendar = forwardRef(({ onMonthChange, date, shouldDisableDate, dateRange
260
473
  const gridLabelId = useId(DATE_PICKER_CALENDAR_GRID_LABEL_ID_PREFIX, true);
261
474
  const { min, max } = dateRange;
262
475
  const currentMonthNumber = utils.getMonth(focusedDate);
263
- const sameMonthDate = previousFocusDate
264
- ? isSameYearAndMonth({ source: focusedDate, comparing: previousFocusDate }, utils)
265
- : false;
476
+ const sameMonthDate = previousFocusDate ? isSameYearAndMonth({
477
+ source: focusedDate,
478
+ comparing: previousFocusDate
479
+ }, utils) : false;
266
480
  if (!sameMonthDate) {
267
481
  weeks.current = utils.getWeekArray(focusedDate);
268
482
  }
269
- const viewChange = view !== previousView;
270
- const pushToLoadingQueue = () => {
271
- setLoadingQueue(loadingQueue + 1);
483
+ const pushToLoadingQueue = ()=>{
484
+ setLoadingQueue((queue)=>queue + 1);
272
485
  };
273
- const popFromLoadingQueue = () => {
274
- setLoadingQueue(loadingQueue <= 0 ? 0 : loadingQueue - 1);
486
+ const popFromLoadingQueue = ()=>{
487
+ setLoadingQueue((queue)=>queue <= 0 ? 0 : queue - 1);
275
488
  };
276
- 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
+ }
277
495
  setSlideDirection(direction);
278
496
  setFocusedDate(getInvalidateDateInRange(newMonth) || newMonth);
279
497
  if (onMonthChange) {
280
498
  const returnVal = onMonthChange(newMonth);
281
499
  if (returnVal) {
282
500
  pushToLoadingQueue();
283
- returnVal.then(() => {
501
+ returnVal.then(()=>{
284
502
  popFromLoadingQueue();
285
503
  });
286
504
  }
287
505
  }
288
506
  });
289
- const handleChangeView = useEventCallback(() => {
507
+ const handleChangeView = useEventCallback(()=>{
508
+ focusIntentRef.current = null;
290
509
  setView(view === 'day' ? 'year' : 'day');
291
510
  });
292
- const disableNextMonth = useMemo(() => {
511
+ const disableNextMonth = useMemo(()=>{
293
512
  const nextStartDay = utils.startOfMonth(utils.getNextMonth(focusedDate));
294
513
  return !!getInvalidateDateInRange(nextStartDay);
295
- }, [focusedDate, getInvalidateDateInRange, utils]);
296
- const disablePrevMonth = useMemo(() => {
514
+ }, [
515
+ focusedDate,
516
+ getInvalidateDateInRange,
517
+ utils
518
+ ]);
519
+ const disablePrevMonth = useMemo(()=>{
297
520
  const prevLatestDay = utils.endOfMonth(utils.getPreviousMonth(focusedDate));
298
521
  return !!getInvalidateDateInRange(prevLatestDay);
299
- }, [focusedDate, getInvalidateDateInRange, utils]);
300
- const handleKeyDown = (event) => {
301
- const moveDay = (value) => {
522
+ }, [
523
+ focusedDate,
524
+ getInvalidateDateInRange,
525
+ utils
526
+ ]);
527
+ const handleKeyDown = (event)=>{
528
+ const moveDay = (value)=>{
302
529
  const day = utils.addDays(focusedDate, value);
303
530
  if (day && !shouldDisableDate(day)) {
304
531
  const newMonthNumber = utils.getMonth(day);
305
532
  if (newMonthNumber !== currentMonthNumber) {
306
- return handleMonthChange(day, newMonthNumber > currentMonthNumber ? 'left' : 'right');
533
+ return handleMonthChange(day, newMonthNumber > currentMonthNumber ? 'left' : 'right', true);
307
534
  }
535
+ focusIntentRef.current = 'day';
308
536
  setFocusedDate(day);
309
537
  }
310
538
  };
311
- const goToDate = (day) => {
539
+ const goToDate = (day)=>{
540
+ focusIntentRef.current = 'day';
312
541
  setFocusedDate(getInvalidateDateInRange(day) || day);
313
542
  };
314
- const confirmDate = () => {
543
+ const confirmDate = ()=>{
315
544
  event.stopPropagation();
316
545
  onSelectDay(focusedDate);
317
546
  };
318
547
  runKeyHandler(event, {
319
- ArrowUp: () => moveDay(-7),
320
- ArrowDown: () => moveDay(7),
321
- ArrowLeft: () => moveDay(-1),
322
- ArrowRight: () => moveDay(1),
323
- Home: () => goToDate(utils.startOfMonth(focusedDate)),
324
- 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)),
325
554
  Enter: confirmDate,
326
- ' ': confirmDate,
555
+ ' ': confirmDate
327
556
  });
328
557
  };
329
558
  const { getBackToTodayAriaLabel, getLoadingAriaLabel } = useScreenReaderContext() ?? {};
330
559
  const backToTodayAriaLabel = getBackToTodayAriaLabel?.();
331
560
  const loadingAriaLabel = getLoadingAriaLabel?.();
332
- const renderDays = (week) => {
561
+ const renderDays = (week)=>{
333
562
  const selectedDate = date;
334
- return week.map((day) => {
563
+ return week.map((day)=>{
335
564
  const disabled = shouldDisableDate(day);
336
565
  const isDayInCurrentMonth = utils.getMonth(day) === currentMonthNumber;
337
566
  const dayText = utils.getDayText(day);
338
567
  const key = utils.formatByString(day, 'YYYY-MM-DD');
339
568
  const selected = utils.isSameDay(day, selectedDate);
340
569
  const focused = utils.isSameDay(focusedDate, day);
341
- 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: ()=>{
342
579
  isDayInCurrentMonth && onSelectDay(day);
343
- }, children: dayText }, key)) : (jsx("div", { "aria-hidden": true }, key));
344
- const renderedDay = renderDay
345
- ? renderDay(day, focusedDate, isDayInCurrentMonth, dayComponent)
346
- : dayComponent;
347
- 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);
348
591
  });
349
592
  };
350
- const renderBody = () => {
351
- const loadingElement = loadingIndicator ? (loadingIndicator) : (jsx("div", { className: cls('loading-container'), children: jsx(CircularProgressIndicator, { progressBarProps: {
352
- 'aria-label': loadingAriaLabel,
353
- } }) }));
354
- 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){
355
603
  case 'day':
356
- 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: ()=>{
357
651
  onSelectDay(now);
358
- }, 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
+ });
359
661
  case 'year':
360
- 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';
361
668
  setView('day');
362
669
  const validateDate = getInvalidateDateInRange(day) || day;
363
670
  setFocusedDate(validateDate);
364
- }, disablePast: disablePast, disableFuture: disableFuture, now: now }));
671
+ },
672
+ disablePast: disablePast,
673
+ disableFuture: disableFuture,
674
+ now: now
675
+ });
365
676
  default:
366
677
  return null;
367
678
  }
368
679
  };
369
- const { document } = useWindowContext();
370
- useLayoutEffect(() => {
371
- 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
+ }
372
691
  return;
373
- if (sameMonthDate) {
374
- focusDayElement();
692
+ }
693
+ if (loadingQueue > 0) {
375
694
  return;
376
695
  }
377
- const activeEl = document?.activeElement;
378
- if (activeEl &&
379
- !activeEl.hasAttribute('data-sui-picker-next-month') &&
380
- !activeEl.hasAttribute('data-sui-picker-previous-month')) {
381
- const timer = setTimeout(() => {
382
- focusDayElement();
383
- });
384
- return () => {
385
- clearTimeout(timer);
386
- };
696
+ if (focusDayElement(calendarRef.current)) {
697
+ focusIntentRef.current = null;
387
698
  }
388
- return undefined;
389
699
  });
390
- useLayoutEffect(() => {
391
- if (previousView && view === 'day' && viewChange) {
392
- focusDayElement();
393
- }
394
- }, [previousView, view, viewChange]);
395
- useLayoutEffect(() => {
396
- focusDayElement();
397
- }, []);
398
- 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
+ });
399
717
  });
400
718
  Calendar.displayName = 'RcCalendar';
401
719
 
402
- 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
+
403
741
 
404
742
  const defaultMinDate = new Date('1900-01-01');
405
743
  const defaultMaxDate = new Date('2100-01-01');
406
744
  const DEFAULT_FORMAT = 'MM/DD/YYYY';
407
- const InnerDatePicker = (props) => {
745
+ const InnerDatePicker = (props)=>{
408
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;
409
- const cls = useClassesWithMode('date-picker', classes, className, ['calendar']);
747
+ const cls = useClassesWithMode('date-picker', classes, className, [
748
+ 'calendar'
749
+ ]);
410
750
  const utils = useDateUtilsContext();
411
751
  const [controlledValue, setControlledValue] = useControlled({
412
752
  controlled: value,
413
753
  default: null,
414
- name: 'DatePicker',
754
+ name: 'DatePicker'
415
755
  });
416
756
  const actionRef = useRef(null);
417
757
  const minDateValue = minDate?.valueOf() ?? defaultMinDate.valueOf();
418
758
  const maxDateValue = maxDate?.valueOf() ?? defaultMaxDate.valueOf();
419
- const dateRange = useMemo(() => ({
420
- min: dayjs(minDateValue),
421
- max: dayjs(maxDateValue),
422
- }), [minDateValue, maxDateValue]);
423
- const getInvalidateDateInRange = useCallback((day) => invalidateDateInRange(day, { dateRange, now: utils.date(), disableFuture, disablePast }, utils), [dateRange, disableFuture, disablePast, utils]);
424
- const shouldDisableDate = useCallback((day) => Boolean(getInvalidateDateInRange(day)) ||
425
- Boolean(shouldDisableDateProp?.(day)), [getInvalidateDateInRange, shouldDisableDateProp]);
426
- 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)=>{
427
782
  return findClosestEnabledDate({
428
783
  date: currDate,
429
784
  utils,
@@ -431,7 +786,7 @@ const InnerDatePicker = (props) => {
431
786
  maxDate: utils.date(dateRange.max),
432
787
  disablePast: Boolean(disablePast),
433
788
  disableFuture: Boolean(disableFuture),
434
- shouldDisableDate,
789
+ shouldDisableDate
435
790
  });
436
791
  }, [
437
792
  dateRange.max,
@@ -439,22 +794,32 @@ const InnerDatePicker = (props) => {
439
794
  disableFuture,
440
795
  disablePast,
441
796
  shouldDisableDate,
797
+ utils
798
+ ]);
799
+ const initialDate = useMemo(()=>getClosestEnabledDate(utils.date()), [
442
800
  utils,
801
+ getClosestEnabledDate
802
+ ]);
803
+ const dayjsValue = useMemo(()=>controlledValue ? dayjs(controlledValue) : null, [
804
+ controlledValue
443
805
  ]);
444
- const initialDate = useMemo(() => getClosestEnabledDate(utils.date()), [utils, getClosestEnabledDate]);
445
- const dayjsValue = useMemo(() => (controlledValue ? dayjs(controlledValue) : null), [controlledValue]);
446
806
  const nowDate = dayjsValue || initialDate;
447
- const textFiledValue = useMemo(() => (dayjsValue ? utils.formatByString(dayjsValue, formatString) : ''), [dayjsValue, utils, formatString]);
448
- 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)=>{
449
813
  actionRef.current?.close();
450
814
  setControlledValue(toDate);
451
815
  onChange?.(toDate, fromUserSelect);
452
816
  };
453
- const handleDaySelect = useEventCallback((day, fromUserSelect = true) => {
817
+ const handleDaySelect = useEventCallback((day, fromUserSelect = true)=>{
454
818
  const newDay = day ? utils.startOfDay(day).toDate() : null;
455
819
  handleChange(newDay, fromUserSelect);
456
820
  });
457
- useEffect(() => {
821
+ // Revalidate controlled values when disabled-date rules change.
822
+ useEffect(()=>{
458
823
  if (!dayjsValue || !shouldDisableDate(dayjsValue)) {
459
824
  return;
460
825
  }
@@ -467,20 +832,74 @@ const InnerDatePicker = (props) => {
467
832
  getClosestEnabledDate,
468
833
  handleDaySelect,
469
834
  shouldDisableDate,
470
- utils,
835
+ utils
471
836
  ]);
472
- 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)=>{
473
846
  onClear?.(e);
474
847
  handleChange(null);
475
- }, 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
+ });
476
875
  };
477
- const DatePicker = forwardRef((inProps, ref) => {
876
+ const DatePicker_DatePicker = /*#__PURE__*/ forwardRef((inProps, ref)=>{
478
877
  const { locale = 'en', ...rest } = useThemeProps({
479
878
  props: inProps,
480
- 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
+ })
481
887
  });
482
- return (jsx(DateUtilsProvider, { locale: locale, children: jsx(InnerDatePicker, { innerRef: ref, ...rest }) }));
483
888
  });
484
- DatePicker.displayName = 'SuiDatePicker';
889
+ DatePicker_DatePicker.displayName = 'SuiDatePicker';
890
+
891
+
892
+
893
+
894
+
895
+
896
+
897
+
898
+
899
+
900
+
901
+
902
+
903
+
485
904
 
486
- 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 };