rsuite 5.68.1 → 5.69.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 (75) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/Calendar/styles/index.css +1 -1
  3. package/Calendar/styles/index.less +1 -1
  4. package/DatePicker/styles/index.css +1 -1
  5. package/DateRangePicker/styles/index.css +1 -1
  6. package/cjs/Calendar/Calendar.d.ts +7 -2
  7. package/cjs/Calendar/Calendar.js +1 -1
  8. package/cjs/Calendar/CalendarContainer.d.ts +5 -0
  9. package/cjs/Calendar/CalendarContainer.js +15 -44
  10. package/cjs/Calendar/CalendarContext.d.ts +126 -2
  11. package/cjs/Calendar/CalendarContext.js +11 -3
  12. package/cjs/Calendar/CalendarHeader.js +3 -20
  13. package/cjs/Calendar/MonthDropdown.js +39 -29
  14. package/cjs/Calendar/TimeDropdown.js +0 -14
  15. package/cjs/Calendar/index.d.ts +1 -2
  16. package/cjs/CustomProvider/CustomProvider.d.ts +13 -16
  17. package/cjs/DateInput/hooks/useDateInputState.d.ts +0 -2
  18. package/cjs/DateInput/hooks/useDateInputState.js +4 -1
  19. package/cjs/DatePicker/DatePicker.d.ts +6 -1
  20. package/cjs/DatePicker/DatePicker.js +10 -8
  21. package/cjs/DateRangePicker/Calendar.d.ts +3 -3
  22. package/cjs/DateRangePicker/Calendar.js +1 -1
  23. package/cjs/DateRangePicker/DateRangePicker.d.ts +15 -3
  24. package/cjs/DateRangePicker/DateRangePicker.js +30 -25
  25. package/cjs/InputNumber/InputNumber.d.ts +9 -0
  26. package/cjs/InputNumber/InputNumber.js +28 -8
  27. package/cjs/internals/Windowing/List.d.ts +13 -3
  28. package/cjs/internals/Windowing/index.d.ts +1 -1
  29. package/cjs/internals/hooks/useCustom.js +25 -12
  30. package/cjs/useMediaQuery/useMediaQuery.js +12 -6
  31. package/dist/rsuite-no-reset-rtl.css +1 -1
  32. package/dist/rsuite-no-reset-rtl.min.css +1 -1
  33. package/dist/rsuite-no-reset-rtl.min.css.map +1 -1
  34. package/dist/rsuite-no-reset.css +1 -1
  35. package/dist/rsuite-no-reset.min.css +1 -1
  36. package/dist/rsuite-no-reset.min.css.map +1 -1
  37. package/dist/rsuite-rtl.css +1 -1
  38. package/dist/rsuite-rtl.min.css +1 -1
  39. package/dist/rsuite-rtl.min.css.map +1 -1
  40. package/dist/rsuite.css +1 -1
  41. package/dist/rsuite.js +16 -16
  42. package/dist/rsuite.min.css +1 -1
  43. package/dist/rsuite.min.css.map +1 -1
  44. package/dist/rsuite.min.js +1 -1
  45. package/dist/rsuite.min.js.map +1 -1
  46. package/esm/Calendar/Calendar.d.ts +7 -2
  47. package/esm/Calendar/Calendar.js +1 -1
  48. package/esm/Calendar/CalendarContainer.d.ts +5 -0
  49. package/esm/Calendar/CalendarContainer.js +15 -44
  50. package/esm/Calendar/CalendarContext.d.ts +126 -2
  51. package/esm/Calendar/CalendarContext.js +12 -3
  52. package/esm/Calendar/CalendarHeader.js +3 -20
  53. package/esm/Calendar/MonthDropdown.js +39 -29
  54. package/esm/Calendar/TimeDropdown.js +0 -14
  55. package/esm/Calendar/index.d.ts +1 -2
  56. package/esm/CustomProvider/CustomProvider.d.ts +13 -16
  57. package/esm/DateInput/hooks/useDateInputState.d.ts +0 -2
  58. package/esm/DateInput/hooks/useDateInputState.js +5 -2
  59. package/esm/DatePicker/DatePicker.d.ts +6 -1
  60. package/esm/DatePicker/DatePicker.js +10 -8
  61. package/esm/DateRangePicker/Calendar.d.ts +3 -3
  62. package/esm/DateRangePicker/Calendar.js +1 -1
  63. package/esm/DateRangePicker/DateRangePicker.d.ts +15 -3
  64. package/esm/DateRangePicker/DateRangePicker.js +19 -14
  65. package/esm/InputNumber/InputNumber.d.ts +9 -0
  66. package/esm/InputNumber/InputNumber.js +29 -9
  67. package/esm/internals/Windowing/List.d.ts +13 -3
  68. package/esm/internals/Windowing/index.d.ts +1 -1
  69. package/esm/internals/hooks/useCustom.js +25 -12
  70. package/esm/useMediaQuery/useMediaQuery.js +13 -7
  71. package/package.json +1 -1
  72. package/cjs/Calendar/types.d.ts +0 -28
  73. package/cjs/Calendar/types.js +0 -4
  74. package/esm/Calendar/types.d.ts +0 -28
  75. package/esm/Calendar/types.js +0 -2
@@ -1,7 +1,8 @@
1
1
  import React from 'react';
2
2
  import CalendarContainer from './CalendarContainer';
3
- import { CalendarLocale } from '../locales';
4
- import { RsRefForwardingComponent, WithAsProps } from '../internals/types';
3
+ import type { CalendarLocale } from '../locales';
4
+ import type { RsRefForwardingComponent, WithAsProps } from '../internals/types';
5
+ import type { MonthDropdownProps } from './CalendarContext';
5
6
  export interface CalendarProps extends WithAsProps {
6
7
  /**
7
8
  * Controlled value
@@ -38,6 +39,10 @@ export interface CalendarProps extends WithAsProps {
38
39
  * @default 0
39
40
  */
40
41
  weekStart?: 0 | 1 | 2 | 3 | 4 | 5 | 6;
42
+ /**
43
+ * The props for the Month Dropdown component.
44
+ */
45
+ monthDropdownProps?: MonthDropdownProps;
41
46
  /**
42
47
  * Callback fired before the value changed
43
48
  */
@@ -6,10 +6,10 @@ import React, { useCallback } from 'react';
6
6
  import PropTypes from 'prop-types';
7
7
  import isSameMonth from 'date-fns/isSameMonth';
8
8
  import CalendarContainer from "./CalendarContainer.js";
9
+ import useCalendarDate from "./useCalendarDate.js";
9
10
  import Button from "../Button/index.js";
10
11
  import { FormattedDate } from "../CustomProvider/index.js";
11
12
  import { useClassNames, useCustom } from "../internals/hooks/index.js";
12
- import useCalendarDate from "./useCalendarDate.js";
13
13
  /**
14
14
  * The Calendar component is used to select dates.
15
15
  * @see https://rsuitejs.com/components/calendar
@@ -2,6 +2,7 @@ import React, { HTMLAttributes } from 'react';
2
2
  import { CalendarHeaderProps } from './CalendarHeader';
3
3
  import { RsRefForwardingComponent, WithAsProps } from '../internals/types';
4
4
  import { CalendarLocale } from '../locales';
5
+ import { MonthDropdownProps } from './CalendarContext';
5
6
  import { CalendarState } from './useCalendarState';
6
7
  export interface CalendarProps extends WithAsProps, Omit<HTMLAttributes<HTMLDivElement>, 'onSelect' | 'onChange' | 'onMouseMove'>, CalendarHeaderProps {
7
8
  /**
@@ -91,6 +92,10 @@ export interface CalendarProps extends WithAsProps, Omit<HTMLAttributes<HTMLDivE
91
92
  * @see https://rsuitejs.com/guide/i18n/#calendar
92
93
  */
93
94
  locale: CalendarLocale;
95
+ /**
96
+ * The props for the Month Dropdown component.
97
+ */
98
+ monthDropdownProps?: MonthDropdownProps;
94
99
  /**
95
100
  * Callback after the date has changed
96
101
  */
@@ -1,9 +1,8 @@
1
1
  'use client';
2
2
  import _extends from "@babel/runtime/helpers/esm/extends";
3
3
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
4
- var _excluded = ["as", "className", "classPrefix", "dateRange", "disabledBackward", "defaultState", "disabledDate", "disabledForward", "format", "hoverRangeValue", "isoWeek", "weekStart", "targetId", "limitEndYear", "limitStartYear", "locale", "onChangeMonth", "onChangeTime", "onMouseMove", "onMoveBackward", "onMoveForward", "onSelect", "onToggleMeridian", "onToggleMonthDropdown", "onToggleTimeDropdown", "calendarDate", "cellClassName", "renderCell", "renderCellOnPicker", "renderTitle", "renderToolbar", "showMeridian", "showWeekNumbers", "inline"];
4
+ var _excluded = ["as", "className", "classPrefix", "calendarDate", "dateRange", "disabledBackward", "defaultState", "disabledForward", "format", "hoverRangeValue", "inline", "isoWeek", "weekStart", "targetId", "limitEndYear", "limitStartYear", "locale", "monthDropdownProps", "showMeridian", "showWeekNumbers", "cellClassName", "disabledDate", "onChangeMonth", "onChangeTime", "onMouseMove", "onMoveBackward", "onMoveForward", "onSelect", "onToggleMeridian", "onToggleMonthDropdown", "onToggleTimeDropdown", "renderCell", "renderCellOnPicker", "renderTitle", "renderToolbar"];
5
5
  import React, { useMemo } from 'react';
6
- import PropTypes from 'prop-types';
7
6
  import pick from 'lodash/pick';
8
7
  import MonthDropdown from "./MonthDropdown.js";
9
8
  import TimeDropdown from "./TimeDropdown.js";
@@ -20,13 +19,14 @@ var CalendarContainer = /*#__PURE__*/React.forwardRef(function (props, ref) {
20
19
  className = props.className,
21
20
  _props$classPrefix = props.classPrefix,
22
21
  classPrefix = _props$classPrefix === void 0 ? 'calendar' : _props$classPrefix,
22
+ calendarDateProp = props.calendarDate,
23
23
  dateRange = props.dateRange,
24
24
  disabledBackward = props.disabledBackward,
25
25
  defaultState = props.defaultState,
26
- disabledDate = props.disabledDate,
27
26
  disabledForward = props.disabledForward,
28
27
  format = props.format,
29
28
  hoverRangeValue = props.hoverRangeValue,
29
+ inline = props.inline,
30
30
  _props$isoWeek = props.isoWeek,
31
31
  isoWeek = _props$isoWeek === void 0 ? false : _props$isoWeek,
32
32
  _props$weekStart = props.weekStart,
@@ -35,6 +35,11 @@ var CalendarContainer = /*#__PURE__*/React.forwardRef(function (props, ref) {
35
35
  limitEndYear = props.limitEndYear,
36
36
  limitStartYear = props.limitStartYear,
37
37
  locale = props.locale,
38
+ monthDropdownProps = props.monthDropdownProps,
39
+ showMeridian = props.showMeridian,
40
+ showWeekNumbers = props.showWeekNumbers,
41
+ cellClassName = props.cellClassName,
42
+ disabledDate = props.disabledDate,
38
43
  onChangeMonth = props.onChangeMonth,
39
44
  onChangeTime = props.onChangeTime,
40
45
  onMouseMove = props.onMouseMove,
@@ -44,15 +49,10 @@ var CalendarContainer = /*#__PURE__*/React.forwardRef(function (props, ref) {
44
49
  onToggleMeridian = props.onToggleMeridian,
45
50
  onToggleMonthDropdown = props.onToggleMonthDropdown,
46
51
  onToggleTimeDropdown = props.onToggleTimeDropdown,
47
- calendarDateProp = props.calendarDate,
48
- cellClassName = props.cellClassName,
49
52
  renderCell = props.renderCell,
50
53
  renderCellOnPicker = props.renderCellOnPicker,
51
54
  renderTitle = props.renderTitle,
52
55
  renderToolbar = props.renderToolbar,
53
- showMeridian = props.showMeridian,
54
- showWeekNumbers = props.showWeekNumbers,
55
- inline = props.inline,
56
56
  rest = _objectWithoutPropertiesLoose(props, _excluded);
57
57
  var _useClassNames = useClassNames(classPrefix),
58
58
  withClassPrefix = _useClassNames.withClassPrefix,
@@ -125,23 +125,24 @@ var CalendarContainer = /*#__PURE__*/React.forwardRef(function (props, ref) {
125
125
  var contextValue = {
126
126
  date: calendarDate,
127
127
  dateRange: dateRange,
128
- disabledDate: isDateDisabled,
129
128
  format: format,
130
129
  hoverRangeValue: hoverRangeValue,
131
- inSameMonth: inSameThisMonthDate,
130
+ inline: inline,
132
131
  isoWeek: isoWeek,
133
132
  weekStart: weekStart,
134
133
  targetId: targetId,
135
134
  locale: locale,
135
+ showWeekNumbers: showWeekNumbers,
136
+ monthDropdownProps: monthDropdownProps,
137
+ cellClassName: cellClassName,
138
+ disabledDate: isDateDisabled,
139
+ inSameMonth: inSameThisMonthDate,
136
140
  onChangeMonth: handleChangeMonth,
137
141
  onChangeTime: onChangeTime,
138
142
  onMouseMove: onMouseMove,
139
143
  onSelect: onSelect,
140
- cellClassName: cellClassName,
141
144
  renderCell: renderCell,
142
- renderCellOnPicker: renderCellOnPicker,
143
- showWeekNumbers: showWeekNumbers,
144
- inline: inline
145
+ renderCellOnPicker: renderCellOnPicker
145
146
  };
146
147
  return /*#__PURE__*/React.createElement(CalendarProvider, {
147
148
  value: contextValue
@@ -180,34 +181,4 @@ var CalendarContainer = /*#__PURE__*/React.forwardRef(function (props, ref) {
180
181
  }, /*#__PURE__*/React.createElement(AngleUpIcon, null))));
181
182
  });
182
183
  CalendarContainer.displayName = 'CalendarContainer';
183
- CalendarContainer.propTypes = {
184
- className: PropTypes.string,
185
- classPrefix: PropTypes.string,
186
- disabledDate: PropTypes.func,
187
- disabledHours: PropTypes.func,
188
- disabledMinutes: PropTypes.func,
189
- disabledSeconds: PropTypes.func,
190
- format: PropTypes.string,
191
- hideHours: PropTypes.func,
192
- hideMinutes: PropTypes.func,
193
- hideSeconds: PropTypes.func,
194
- isoWeek: PropTypes.bool,
195
- limitEndYear: PropTypes.number,
196
- limitStartYear: PropTypes.number,
197
- locale: PropTypes.object,
198
- onChangeMonth: PropTypes.func,
199
- onChangeTime: PropTypes.func,
200
- onMoveBackward: PropTypes.func,
201
- onMoveForward: PropTypes.func,
202
- onSelect: PropTypes.func,
203
- onToggleMeridian: PropTypes.func,
204
- onToggleMonthDropdown: PropTypes.func,
205
- onToggleTimeDropdown: PropTypes.func,
206
- calendarDate: PropTypes.instanceOf(Date),
207
- renderCell: PropTypes.func,
208
- renderTitle: PropTypes.func,
209
- renderToolbar: PropTypes.func,
210
- showMeridian: PropTypes.bool,
211
- showWeekNumbers: PropTypes.bool
212
- };
213
184
  export default CalendarContainer;
@@ -1,6 +1,130 @@
1
1
  import React from 'react';
2
- import { CalendarContextValue } from './types';
2
+ import { CalendarLocale } from '../locales';
3
+ import { format } from '../internals/utils/date';
4
+ import type { FixedSizeListProps } from '../internals/Windowing';
5
+ /**
6
+ * Represents the inner context value for the Calendar component.
7
+ */
8
+ export interface CalendarInnerContextValue {
9
+ /**
10
+ * The current date of the calendar.
11
+ */
12
+ date: Date;
13
+ /**
14
+ * The date range selected in the calendar.
15
+ */
16
+ dateRange?: Date[];
17
+ /**
18
+ * The format used for displaying dates.
19
+ */
20
+ format?: string;
21
+ /**
22
+ * The hover range value in the calendar.
23
+ */
24
+ hoverRangeValue?: [Date, Date];
25
+ /**
26
+ * Indicates whether the calendar is inline or not.
27
+ */
28
+ inline?: boolean;
29
+ /**
30
+ * Indicates whether the ISO week numbers should be shown in the calendar.
31
+ */
32
+ isoWeek: boolean;
33
+ /**
34
+ * The start day of the week in the calendar.
35
+ * 0 - Sunday, 1 - Monday, 2 - Tuesday, 3 - Wednesday, 4 - Thursday, 5 - Friday, 6 - Saturday
36
+ */
37
+ weekStart: 0 | 1 | 2 | 3 | 4 | 5 | 6;
38
+ /**
39
+ * Indicates whether week numbers should be shown in the calendar.
40
+ */
41
+ showWeekNumbers?: boolean;
42
+ /**
43
+ * The target ID of the calendar.
44
+ */
45
+ targetId?: string;
46
+ /**
47
+ * The props for the Month Dropdown component.
48
+ */
49
+ monthDropdownProps?: MonthDropdownProps;
50
+ /**
51
+ * A function that determines if a date is disabled in the calendar.
52
+ * @param date - The date to check.
53
+ * @param selectRangeValue - The selected date range.
54
+ * @param type - The type of the calendar.
55
+ * @returns True if the date is disabled, false otherwise.
56
+ */
57
+ disabledDate?: (date: Date, selectRangeValue?: Date[], type?: string) => boolean;
58
+ /**
59
+ * A function that determines if a date is in the same month as the current date in the calendar.
60
+ * @param date - The date to check.
61
+ * @returns True if the date is in the same month, false otherwise.
62
+ */
63
+ inSameMonth?: (date: Date) => boolean;
64
+ /**
65
+ * A callback function that is called when the month is changed in the calendar.
66
+ * @param nextPageDate - The next page date.
67
+ * @param event - The mouse event.
68
+ */
69
+ onChangeMonth?: (nextPageDate: Date, event: React.MouseEvent) => void;
70
+ /**
71
+ * A callback function that is called when the time is changed in the calendar.
72
+ * @param nextPageTime - The next page time.
73
+ * @param event - The mouse event.
74
+ */
75
+ onChangeTime?: (nextPageTime: Date, event: React.MouseEvent) => void;
76
+ /**
77
+ * A callback function that is called when the mouse moves over a date in the calendar.
78
+ * @param date - The date.
79
+ */
80
+ onMouseMove?: (date: Date) => void;
81
+ /**
82
+ * A callback function that is called when a date is selected in the calendar.
83
+ * @param date - The selected date.
84
+ * @param event - The mouse event.
85
+ */
86
+ onSelect?: (date: Date, event: React.MouseEvent) => void;
87
+ /**
88
+ * A function that renders the cell content in the calendar.
89
+ * @param date - The date.
90
+ * @returns The rendered cell content.
91
+ */
92
+ renderCell?: (date: Date) => React.ReactNode;
93
+ /**
94
+ * A function that renders the cell content in the picker.
95
+ * @param date - The date.
96
+ * @returns The rendered cell content.
97
+ */
98
+ renderCellOnPicker?: (date: Date) => React.ReactNode;
99
+ /**
100
+ * A function that returns the class name for a cell in the calendar.
101
+ * @param date - The date.
102
+ * @returns The class name for the cell.
103
+ */
104
+ cellClassName?: (date: Date) => string | undefined;
105
+ }
106
+ /**
107
+ * Props for the MonthDropdown component.
108
+ */
109
+ export interface MonthDropdownProps extends Partial<FixedSizeListProps> {
110
+ /**
111
+ * The HTML element or React component to render as the root element of the MonthDropdown.
112
+ */
113
+ as?: React.ElementType;
114
+ /**
115
+ * The HTML element or React component to render as each item in the MonthDropdown.
116
+ */
117
+ itemAs?: React.ElementType;
118
+ /**
119
+ * The CSS class name to apply to each item in the MonthDropdown.
120
+ */
121
+ itemClassName?: string;
122
+ }
123
+ export interface CalendarContextValue extends CalendarInnerContextValue {
124
+ locale: CalendarLocale;
125
+ formatDate?: typeof format;
126
+ }
3
127
  declare const CalendarContext: React.Context<CalendarContextValue>;
4
- export default CalendarContext;
5
128
  export declare const CalendarProvider: React.Provider<CalendarContextValue>;
6
129
  export declare const useCalendarContext: () => CalendarContextValue;
130
+ export default CalendarContext;
@@ -1,8 +1,17 @@
1
1
  'use client';
2
2
  import React, { useContext } from 'react';
3
+
4
+ /**
5
+ * Represents the inner context value for the Calendar component.
6
+ */
7
+
8
+ /**
9
+ * Props for the MonthDropdown component.
10
+ */
11
+
3
12
  var CalendarContext = /*#__PURE__*/React.createContext({});
4
- export default CalendarContext;
5
13
  export var CalendarProvider = CalendarContext.Provider;
6
14
  export var useCalendarContext = function useCalendarContext() {
7
- return useContext(CalendarContext) || {};
8
- };
15
+ return useContext(CalendarContext);
16
+ };
17
+ export default CalendarContext;
@@ -3,7 +3,6 @@ import _extends from "@babel/runtime/helpers/esm/extends";
3
3
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
4
4
  var _excluded = ["as", "className", "classPrefix", "disabledBackward", "disabledForward", "showDate", "showMeridian", "showMonth", "showTime", "disabledTime", "onMoveBackward", "onMoveForward", "onToggleMeridian", "onToggleMonthDropdown", "onToggleTimeDropdown", "renderTitle", "renderToolbar"];
5
5
  import React, { useCallback } from 'react';
6
- import PropTypes from 'prop-types';
7
6
  import AngleLeftIcon from '@rsuite/icons/legacy/AngleLeft';
8
7
  import AngleRightIcon from '@rsuite/icons/legacy/AngleRight';
9
8
  import IconButton from "../IconButton/index.js";
@@ -39,7 +38,8 @@ var CalendarHeader = /*#__PURE__*/React.forwardRef(function (props, ref) {
39
38
  date = _useCalendarContext$d === void 0 ? new Date() : _useCalendarContext$d,
40
39
  format = _useCalendarContext.format,
41
40
  inline = _useCalendarContext.inline,
42
- disabledDate = _useCalendarContext.disabledDate;
41
+ disabledDate = _useCalendarContext.disabledDate,
42
+ targetId = _useCalendarContext.targetId;
43
43
  var _useDateRangePickerCo = useDateRangePickerContext(),
44
44
  isSelectedIdle = _useDateRangePickerCo.isSelectedIdle;
45
45
  var _useClassNames = useClassNames(classPrefix),
@@ -101,6 +101,7 @@ var CalendarHeader = /*#__PURE__*/React.forwardRef(function (props, ref) {
101
101
  icon: /*#__PURE__*/React.createElement(AngleLeftIcon, null)
102
102
  })), /*#__PURE__*/React.createElement(Button, _extends({}, btnProps, {
103
103
  "aria-label": "Select month",
104
+ id: targetId ? targetId + "-grid-label" : undefined,
104
105
  className: dateTitleClasses,
105
106
  onClick: onToggleMonthDropdown
106
107
  }), renderTitle()), /*#__PURE__*/React.createElement(IconButton, _extends({}, btnProps, {
@@ -141,22 +142,4 @@ var CalendarHeader = /*#__PURE__*/React.forwardRef(function (props, ref) {
141
142
  }))), renderToolbar === null || renderToolbar === void 0 ? void 0 : renderToolbar(date));
142
143
  });
143
144
  CalendarHeader.displayName = 'CalendarHeader';
144
- CalendarHeader.propTypes = {
145
- className: PropTypes.string,
146
- classPrefix: PropTypes.string,
147
- disabledBackward: PropTypes.bool,
148
- disabledForward: PropTypes.bool,
149
- disabledTime: PropTypes.func,
150
- onMoveBackward: PropTypes.func,
151
- onMoveForward: PropTypes.func,
152
- onToggleMeridian: PropTypes.func,
153
- onToggleMonthDropdown: PropTypes.func,
154
- onToggleTimeDropdown: PropTypes.func,
155
- renderTitle: PropTypes.func,
156
- renderToolbar: PropTypes.func,
157
- showDate: PropTypes.bool,
158
- showMeridian: PropTypes.bool,
159
- showMonth: PropTypes.bool,
160
- showTime: PropTypes.bool
161
- };
162
145
  export default CalendarHeader;
@@ -1,7 +1,8 @@
1
1
  'use client';
2
2
  import _extends from "@babel/runtime/helpers/esm/extends";
3
3
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
4
- var _excluded = ["as", "className", "classPrefix", "limitStartYear", "limitEndYear", "show", "height", "width", "disabledMonth"];
4
+ var _excluded = ["as", "className", "classPrefix", "limitStartYear", "limitEndYear", "show", "height", "width", "disabledMonth"],
5
+ _excluded2 = ["className", "itemClassName", "as", "itemAs"];
5
6
  import React, { useCallback, useMemo } from 'react';
6
7
  import { getDaysInMonth, getMonth, getYear } from "../internals/utils/date/index.js";
7
8
  import { AutoSizer, FixedSizeList } from "../internals/Windowing/index.js";
@@ -37,7 +38,8 @@ var MonthDropdown = /*#__PURE__*/React.forwardRef(function (props, ref) {
37
38
  var _useCalendarContext = useCalendarContext(),
38
39
  _useCalendarContext$d = _useCalendarContext.date,
39
40
  date = _useCalendarContext$d === void 0 ? new Date() : _useCalendarContext$d,
40
- targetId = _useCalendarContext.targetId;
41
+ targetId = _useCalendarContext.targetId,
42
+ monthDropdownProps = _useCalendarContext.monthDropdownProps;
41
43
  var _useClassNames = useClassNames(classPrefix),
42
44
  prefix = _useClassNames.prefix,
43
45
  merge = _useClassNames.merge,
@@ -54,9 +56,16 @@ var MonthDropdown = /*#__PURE__*/React.forwardRef(function (props, ref) {
54
56
  }
55
57
  return false;
56
58
  }, [disabledMonth]);
57
- var rowRenderer = useCallback(function (_ref) {
58
- var index = _ref.index,
59
- style = _ref.style;
59
+ var _ref = monthDropdownProps || {},
60
+ listClassName = _ref.className,
61
+ itemClassName = _ref.itemClassName,
62
+ List = _ref.as,
63
+ _ref$itemAs = _ref.itemAs,
64
+ Item = _ref$itemAs === void 0 ? 'div' : _ref$itemAs,
65
+ restListProps = _objectWithoutPropertiesLoose(_ref, _excluded2);
66
+ var rowRenderer = useCallback(function (_ref2) {
67
+ var index = _ref2.index,
68
+ style = _ref2.style;
60
69
  var selectedMonth = getMonth(date);
61
70
  var selectedYear = getYear(date);
62
71
  var year = startYear + index;
@@ -64,14 +73,13 @@ var MonthDropdown = /*#__PURE__*/React.forwardRef(function (props, ref) {
64
73
  var titleClassName = prefix('year', {
65
74
  'year-active': isSelectedYear
66
75
  });
67
- var rowClassName = merge(prefix('row'), {
68
- 'first-row': index === 0,
69
- 'last-row': index === rowCount - 1
70
- });
71
- return /*#__PURE__*/React.createElement("div", {
72
- className: rowClassName,
76
+ return /*#__PURE__*/React.createElement(Item, {
73
77
  role: "row",
74
78
  "aria-label": "" + year,
79
+ className: merge(itemClassName, prefix('row'), {
80
+ 'first-row': index === 0,
81
+ 'last-row': index === rowCount - 1
82
+ }),
75
83
  style: style
76
84
  }, /*#__PURE__*/React.createElement("div", {
77
85
  className: titleClassName,
@@ -87,40 +95,42 @@ var MonthDropdown = /*#__PURE__*/React.forwardRef(function (props, ref) {
87
95
  year: year
88
96
  });
89
97
  })));
90
- }, [date, isMonthDisabled, merge, prefix, rowCount, startYear]);
98
+ }, [Item, date, isMonthDisabled, merge, prefix, itemClassName, rowCount, startYear]);
91
99
  var classes = merge(className, withClassPrefix(), {
92
100
  show: show
93
101
  });
94
102
  var itemSize = 75;
95
103
  var initialItemIndex = getYear(date) - startYear;
96
104
  var initialScrollOffset = itemSize * initialItemIndex;
105
+ if (!show) {
106
+ return null;
107
+ }
97
108
  return /*#__PURE__*/React.createElement(Component, _extends({
109
+ ref: ref,
98
110
  role: "grid",
99
- "aria-label": "Select month",
100
111
  tabIndex: -1,
101
- id: targetId ? targetId + "-" + classPrefix : undefined
102
- }, rest, {
103
- ref: ref,
104
- className: classes
105
- }), /*#__PURE__*/React.createElement("div", {
106
- className: prefix('content')
107
- }, /*#__PURE__*/React.createElement("div", {
112
+ className: classes,
113
+ "aria-labelledby": targetId ? targetId + "-grid-label" : undefined,
114
+ id: targetId ? targetId + "-calendar-month-dropdown" : undefined,
115
+ "data-testid": "calendar-month-dropdown"
116
+ }, rest), /*#__PURE__*/React.createElement("div", {
108
117
  className: prefix('scroll')
109
- }, show && /*#__PURE__*/React.createElement(AutoSizer, {
118
+ }, /*#__PURE__*/React.createElement(AutoSizer, {
110
119
  defaultHeight: defaultHeight,
111
120
  defaultWidth: defaultWidth
112
- }, function (_ref2) {
113
- var height = _ref2.height,
114
- width = _ref2.width;
115
- return /*#__PURE__*/React.createElement(FixedSizeList, {
116
- className: prefix('row-wrapper'),
121
+ }, function (_ref3) {
122
+ var height = _ref3.height,
123
+ width = _ref3.width;
124
+ return /*#__PURE__*/React.createElement(FixedSizeList, _extends({
125
+ className: merge(prefix('row-wrapper'), listClassName),
117
126
  width: width || defaultWidth,
118
127
  height: height || defaultHeight,
119
128
  itemSize: itemSize,
120
129
  itemCount: rowCount,
121
- initialScrollOffset: initialScrollOffset
122
- }, rowRenderer);
123
- }))));
130
+ initialScrollOffset: initialScrollOffset,
131
+ innerElementType: List
132
+ }, restListProps), rowRenderer);
133
+ })));
124
134
  });
125
135
  MonthDropdown.displayName = 'MonthDropdown';
126
136
  export default MonthDropdown;
@@ -3,7 +3,6 @@ import _extends from "@babel/runtime/helpers/esm/extends";
3
3
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
4
4
  var _excluded = ["as", "className", "classPrefix", "show", "showMeridian"];
5
5
  import React, { useEffect, useRef } from 'react';
6
- import PropTypes from 'prop-types';
7
6
  import getPosition from 'dom-lib/getPosition';
8
7
  import scrollTop from 'dom-lib/scrollTop';
9
8
  import partial from 'lodash/partial';
@@ -190,17 +189,4 @@ var TimeDropdown = /*#__PURE__*/React.forwardRef(function (props, ref) {
190
189
  }, renderColumn('hours', time.hours), renderColumn('minutes', time.minutes), renderColumn('seconds', time.seconds))));
191
190
  });
192
191
  TimeDropdown.displayName = 'TimeDropdown';
193
- TimeDropdown.propTypes = {
194
- show: PropTypes.bool,
195
- showMeridian: PropTypes.bool,
196
- className: PropTypes.string,
197
- classPrefix: PropTypes.string,
198
- disabledDate: PropTypes.func,
199
- disabledHours: PropTypes.func,
200
- disabledMinutes: PropTypes.func,
201
- disabledSeconds: PropTypes.func,
202
- hideHours: PropTypes.func,
203
- hideMinutes: PropTypes.func,
204
- hideSeconds: PropTypes.func
205
- };
206
192
  export default TimeDropdown;
@@ -1,8 +1,7 @@
1
1
  import Calendar from './Calendar';
2
2
  import CalendarContainer from './CalendarContainer';
3
3
  import { CalendarState } from './useCalendarState';
4
- import CalendarContext from './CalendarContext';
5
- import { CalendarContextValue } from './types';
4
+ import CalendarContext, { CalendarContextValue } from './CalendarContext';
6
5
  export { CalendarContainer, CalendarContext, CalendarState };
7
6
  export type { CalendarContextValue };
8
7
  export type { CalendarProps } from './Calendar';
@@ -1,6 +1,14 @@
1
1
  import React from 'react';
2
+ import type { Locale as DateFnsLocale } from 'date-fns';
2
3
  import { Locale } from '../locales';
3
4
  import { ToastContainerInstance } from '../toaster/ToastContainer';
5
+ export interface FormatDateOptions {
6
+ locale?: DateFnsLocale;
7
+ weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6;
8
+ firstWeekContainsDate?: number;
9
+ useAdditionalWeekYearTokens?: boolean;
10
+ useAdditionalDayOfYearTokens?: boolean;
11
+ }
4
12
  export interface CustomValue<T = Locale> {
5
13
  /** Language configuration */
6
14
  locale: T;
@@ -19,7 +27,7 @@ export interface CustomValue<T = Locale> {
19
27
  * }
20
28
  *
21
29
  * */
22
- formatDate: (date: Date | number, format: string) => string;
30
+ formatDate: (date: Date | number, format: string, options?: FormatDateOptions) => string;
23
31
  /**
24
32
  * Return the date parsed from string using the given format string.
25
33
  *
@@ -33,7 +41,7 @@ export interface CustomValue<T = Locale> {
33
41
  * }
34
42
  *
35
43
  * */
36
- parseDate: (dateString: string, formatString: string) => Date;
44
+ parseDate: (dateString: string, formatString: string, referenceDate?: Date | number, options?: FormatDateOptions) => Date;
37
45
  /**
38
46
  * A Map of toast containers
39
47
  */
@@ -60,6 +68,7 @@ declare const CustomContext: React.Context<CustomProviderProps<{
60
68
  } | undefined;
61
69
  Plaintext?: {
62
70
  unfilled: string;
71
+ /** Support right-to-left */
63
72
  notSelected: string;
64
73
  notUploaded: string;
65
74
  } | undefined;
@@ -67,19 +76,7 @@ declare const CustomContext: React.Context<CustomProviderProps<{
67
76
  more: string;
68
77
  prev: string;
69
78
  next: string;
70
- first: string; /**
71
- * Return the date parsed from string using the given format string.
72
- *
73
- * Example:
74
- *
75
- * import parse from 'date-fns/parse';
76
- * import eo from 'date-fns/locale/eo'
77
- *
78
- * function parseDate(date, formatStr) {
79
- * return parse(date, formatStr, new Date(), { locale: eo });
80
- * }
81
- *
82
- * */
79
+ first: string;
83
80
  last: string;
84
81
  limit: string;
85
82
  total: string;
@@ -152,7 +149,7 @@ declare const CustomContext: React.Context<CustomProviderProps<{
152
149
  } | undefined;
153
150
  Uploader?: {
154
151
  inited: string;
155
- progress: string; /** If true, the ripple effect is disabled. Affected components include: Button, Nav.Item, Pagination. */
152
+ progress: string;
156
153
  error: string;
157
154
  complete: string;
158
155
  emptyFile: string;
@@ -1,8 +1,6 @@
1
- import { format } from '../../internals/utils/date';
2
1
  import type { Locale } from 'date-fns';
3
2
  interface DateInputState {
4
3
  formatStr: string;
5
- formatDate?: typeof format;
6
4
  locale: Locale;
7
5
  date?: Date | null;
8
6
  isControlledDate?: boolean;
@@ -1,13 +1,16 @@
1
1
  'use client';
2
2
  import { useCallback, useEffect } from 'react';
3
3
  import startCase from 'lodash/startCase';
4
- import { addDays, addMonths, addYears, addHours, addMinutes, addSeconds, format, isLastDayOfMonth, lastDayOfMonth, isValid } from "../../internals/utils/date/index.js";
4
+ import { addDays, addMonths, addYears, addHours, addMinutes, addSeconds, isLastDayOfMonth, lastDayOfMonth, isValid } from "../../internals/utils/date/index.js";
5
+ import { useCustom } from "../../internals/hooks/index.js";
5
6
  import { useDateField, patternMap } from "../DateField.js";
6
7
  export function useDateInputState(_ref) {
7
8
  var formatStr = _ref.formatStr,
8
9
  locale = _ref.locale,
9
10
  date = _ref.date,
10
11
  isControlledDate = _ref.isControlledDate;
12
+ var _useCustom = useCustom(),
13
+ formatDate = _useCustom.formatDate;
11
14
  var _useDateField = useDateField(formatStr, locale.localize, date),
12
15
  dateField = _useDateField.dateField,
13
16
  dispatch = _useDateField.dispatch,
@@ -88,7 +91,7 @@ export function useDateInputState(_ref) {
88
91
  };
89
92
  var toControlledDateString = function toControlledDateString() {
90
93
  if (date && isValid(date)) {
91
- return format(date, formatStr, {
94
+ return formatDate(date, formatStr, {
92
95
  locale: locale
93
96
  });
94
97
  }
@@ -1,8 +1,9 @@
1
1
  import React from 'react';
2
2
  import { RangeType } from './Toolbar';
3
- import { DatePickerLocale } from '../locales';
4
3
  import type { FormControlBaseProps, PickerBaseProps, RsRefForwardingComponent } from '../internals/types';
4
+ import type { DatePickerLocale } from '../locales';
5
5
  import type { DeprecatedProps } from './types';
6
+ import type { MonthDropdownProps } from '../Calendar/CalendarContext';
6
7
  export interface DatePickerProps extends PickerBaseProps<DatePickerLocale>, FormControlBaseProps<Date | null>, DeprecatedProps {
7
8
  /**
8
9
  * Custom caret component
@@ -77,6 +78,10 @@ export interface DatePickerProps extends PickerBaseProps<DatePickerLocale>, Form
77
78
  * Meridian format for 12-hour time
78
79
  */
79
80
  showMeridian?: boolean;
81
+ /**
82
+ * The props for the Month Dropdown component.
83
+ */
84
+ monthDropdownProps?: MonthDropdownProps;
80
85
  /**
81
86
  * Whether a date on the calendar view should be disabled
82
87
  *