rsuite 5.48.1 → 5.49.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 (138) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/Cascader/styles/index.less +1 -0
  3. package/DatePicker/styles/index.less +18 -11
  4. package/DateRangeInput/package.json +7 -0
  5. package/DateRangePicker/styles/index.less +10 -0
  6. package/InputGroup/styles/index.less +1 -0
  7. package/Picker/styles/index.less +20 -0
  8. package/README.md +32 -22
  9. package/Sidenav/styles/index.less +2 -0
  10. package/cjs/Calendar/CalendarContainer.d.ts +2 -0
  11. package/cjs/Calendar/CalendarContainer.js +11 -4
  12. package/cjs/Calendar/CalendarHeader.js +2 -0
  13. package/cjs/Calendar/MonthDropdown.js +7 -2
  14. package/cjs/Calendar/MonthDropdownItem.js +2 -2
  15. package/cjs/Calendar/Table.js +6 -1
  16. package/cjs/Calendar/TimeDropdown.js +17 -10
  17. package/cjs/Calendar/types.d.ts +1 -0
  18. package/cjs/CustomProvider/CustomProvider.d.ts +13 -0
  19. package/cjs/CustomProvider/CustomProvider.js +2 -2
  20. package/cjs/DateInput/DateField.d.ts +9 -31
  21. package/cjs/DateInput/DateField.js +61 -12
  22. package/cjs/DateInput/DateInput.d.ts +7 -2
  23. package/cjs/DateInput/DateInput.js +74 -92
  24. package/cjs/DateInput/index.d.ts +4 -0
  25. package/cjs/DateInput/index.js +19 -1
  26. package/cjs/DateInput/useDateInputState.d.ts +7 -31
  27. package/cjs/DateInput/useDateInputState.js +39 -15
  28. package/cjs/DateInput/useIsFocused.d.ts +7 -0
  29. package/cjs/DateInput/useIsFocused.js +28 -0
  30. package/cjs/DateInput/useKeyboardInputEvent.d.ts +10 -0
  31. package/cjs/DateInput/useKeyboardInputEvent.js +44 -0
  32. package/cjs/DateInput/utils.d.ts +23 -1
  33. package/cjs/DateInput/utils.js +155 -51
  34. package/cjs/DatePicker/DatePicker.d.ts +20 -7
  35. package/cjs/DatePicker/DatePicker.js +210 -241
  36. package/cjs/DatePicker/PickerIndicator.d.ts +10 -0
  37. package/cjs/DatePicker/PickerIndicator.js +48 -0
  38. package/cjs/DatePicker/PickerLabel.d.ts +9 -0
  39. package/cjs/DatePicker/PickerLabel.js +23 -0
  40. package/cjs/DatePicker/Toolbar.js +3 -21
  41. package/cjs/DatePicker/utils.d.ts +5 -1
  42. package/cjs/DatePicker/utils.js +17 -1
  43. package/cjs/DateRangeInput/DateRangeInput.d.ts +29 -0
  44. package/cjs/DateRangeInput/DateRangeInput.js +244 -0
  45. package/cjs/DateRangeInput/index.d.ts +3 -0
  46. package/cjs/DateRangeInput/index.js +9 -0
  47. package/cjs/DateRangeInput/utils.d.ts +61 -0
  48. package/cjs/DateRangeInput/utils.js +146 -0
  49. package/cjs/DateRangePicker/DateRangePicker.js +12 -2
  50. package/cjs/Input/Input.d.ts +11 -0
  51. package/cjs/Input/Input.js +11 -8
  52. package/cjs/Overlay/OverlayTrigger.d.ts +3 -0
  53. package/cjs/Overlay/OverlayTrigger.js +5 -0
  54. package/cjs/Picker/usePickerRef.d.ts +17 -0
  55. package/cjs/Picker/usePickerRef.js +82 -0
  56. package/cjs/index.d.ts +2 -0
  57. package/cjs/index.js +3 -1
  58. package/cjs/locales/index.d.ts +2 -2
  59. package/cjs/utils/index.d.ts +2 -0
  60. package/cjs/utils/index.js +8 -2
  61. package/cjs/utils/useCustom.js +1 -1
  62. package/cjs/utils/useIsomorphicLayoutEffect.d.ts +3 -0
  63. package/cjs/utils/useIsomorphicLayoutEffect.js +9 -0
  64. package/dist/rsuite-no-reset-rtl.css +51 -141
  65. package/dist/rsuite-no-reset-rtl.min.css +1 -1
  66. package/dist/rsuite-no-reset-rtl.min.css.map +1 -1
  67. package/dist/rsuite-no-reset.css +51 -141
  68. package/dist/rsuite-no-reset.min.css +1 -1
  69. package/dist/rsuite-no-reset.min.css.map +1 -1
  70. package/dist/rsuite-rtl.css +51 -9
  71. package/dist/rsuite-rtl.min.css +1 -1
  72. package/dist/rsuite-rtl.min.css.map +1 -1
  73. package/dist/rsuite.css +51 -9
  74. package/dist/rsuite.js +4800 -246
  75. package/dist/rsuite.js.map +1 -1
  76. package/dist/rsuite.min.css +1 -1
  77. package/dist/rsuite.min.css.map +1 -1
  78. package/dist/rsuite.min.js +1 -1
  79. package/dist/rsuite.min.js.map +1 -1
  80. package/esm/Calendar/CalendarContainer.d.ts +2 -0
  81. package/esm/Calendar/CalendarContainer.js +12 -5
  82. package/esm/Calendar/CalendarHeader.js +2 -0
  83. package/esm/Calendar/MonthDropdown.js +7 -2
  84. package/esm/Calendar/MonthDropdownItem.js +2 -2
  85. package/esm/Calendar/Table.js +6 -1
  86. package/esm/Calendar/TimeDropdown.js +17 -10
  87. package/esm/Calendar/types.d.ts +1 -0
  88. package/esm/CustomProvider/CustomProvider.d.ts +13 -0
  89. package/esm/CustomProvider/CustomProvider.js +3 -3
  90. package/esm/DateInput/DateField.d.ts +9 -31
  91. package/esm/DateInput/DateField.js +61 -12
  92. package/esm/DateInput/DateInput.d.ts +7 -2
  93. package/esm/DateInput/DateInput.js +77 -95
  94. package/esm/DateInput/index.d.ts +4 -0
  95. package/esm/DateInput/index.js +4 -0
  96. package/esm/DateInput/useDateInputState.d.ts +7 -31
  97. package/esm/DateInput/useDateInputState.js +41 -18
  98. package/esm/DateInput/useIsFocused.d.ts +7 -0
  99. package/esm/DateInput/useIsFocused.js +22 -0
  100. package/esm/DateInput/useKeyboardInputEvent.d.ts +10 -0
  101. package/esm/DateInput/useKeyboardInputEvent.js +38 -0
  102. package/esm/DateInput/utils.d.ts +23 -1
  103. package/esm/DateInput/utils.js +150 -51
  104. package/esm/DatePicker/DatePicker.d.ts +20 -7
  105. package/esm/DatePicker/DatePicker.js +213 -244
  106. package/esm/DatePicker/PickerIndicator.d.ts +10 -0
  107. package/esm/DatePicker/PickerIndicator.js +42 -0
  108. package/esm/DatePicker/PickerLabel.d.ts +9 -0
  109. package/esm/DatePicker/PickerLabel.js +17 -0
  110. package/esm/DatePicker/Toolbar.js +3 -21
  111. package/esm/DatePicker/utils.d.ts +5 -1
  112. package/esm/DatePicker/utils.js +16 -1
  113. package/esm/DateRangeInput/DateRangeInput.d.ts +29 -0
  114. package/esm/DateRangeInput/DateRangeInput.js +237 -0
  115. package/esm/DateRangeInput/index.d.ts +3 -0
  116. package/esm/DateRangeInput/index.js +3 -0
  117. package/esm/DateRangeInput/utils.d.ts +61 -0
  118. package/esm/DateRangeInput/utils.js +137 -0
  119. package/esm/DateRangePicker/DateRangePicker.js +12 -2
  120. package/esm/Input/Input.d.ts +11 -0
  121. package/esm/Input/Input.js +12 -9
  122. package/esm/Overlay/OverlayTrigger.d.ts +3 -0
  123. package/esm/Overlay/OverlayTrigger.js +5 -0
  124. package/esm/Picker/usePickerRef.d.ts +17 -0
  125. package/esm/Picker/usePickerRef.js +77 -0
  126. package/esm/index.d.ts +2 -0
  127. package/esm/index.js +1 -0
  128. package/esm/locales/index.d.ts +2 -2
  129. package/esm/utils/index.d.ts +2 -0
  130. package/esm/utils/index.js +3 -1
  131. package/esm/utils/useCustom.js +2 -2
  132. package/esm/utils/useIsomorphicLayoutEffect.d.ts +3 -0
  133. package/esm/utils/useIsomorphicLayoutEffect.js +4 -0
  134. package/package.json +1 -1
  135. package/styles/color-modes/dark.less +1 -0
  136. package/styles/color-modes/high-contrast.less +1 -0
  137. package/styles/color-modes/light.less +1 -0
  138. package/styles/normalize.less +230 -231
@@ -0,0 +1,28 @@
1
+ 'use client';
2
+ "use strict";
3
+
4
+ exports.__esModule = true;
5
+ exports.useIsFocused = useIsFocused;
6
+ exports.default = void 0;
7
+ var _react = require("react");
8
+ function useIsFocused(_ref) {
9
+ var onFocusProp = _ref.onFocus,
10
+ onBlurProp = _ref.onBlur;
11
+ var _useState = (0, _react.useState)(false),
12
+ isFocused = _useState[0],
13
+ setIsFocused = _useState[1];
14
+ var onFocus = (0, _react.useCallback)(function (event) {
15
+ setIsFocused(true);
16
+ onFocusProp === null || onFocusProp === void 0 ? void 0 : onFocusProp(event);
17
+ }, [onFocusProp]);
18
+ var onBlur = (0, _react.useCallback)(function (event) {
19
+ setIsFocused(false);
20
+ onBlurProp === null || onBlurProp === void 0 ? void 0 : onBlurProp(event);
21
+ }, [onBlurProp]);
22
+ return [isFocused, {
23
+ onFocus: onFocus,
24
+ onBlur: onBlur
25
+ }];
26
+ }
27
+ var _default = useIsFocused;
28
+ exports.default = _default;
@@ -0,0 +1,10 @@
1
+ /// <reference types="react" />
2
+ interface KeyboardEventOptions {
3
+ onSegmentChange?: (kevent: React.KeyboardEvent<HTMLInputElement>) => void;
4
+ onSegmentValueChange?: (event: React.KeyboardEvent<HTMLInputElement>) => void;
5
+ onSegmentValueChangeWithNumericKeys?: (event: React.KeyboardEvent<HTMLInputElement>) => void;
6
+ onSegmentValueRemove?: (event: React.KeyboardEvent<HTMLInputElement>) => void;
7
+ onKeyDown?: (event: React.KeyboardEvent<HTMLInputElement>) => void;
8
+ }
9
+ export declare function useKeyboardInputEvent({ onSegmentChange, onSegmentValueChange, onSegmentValueChangeWithNumericKeys, onSegmentValueRemove, onKeyDown }: KeyboardEventOptions): (event: React.KeyboardEvent<HTMLInputElement>) => void;
10
+ export default useKeyboardInputEvent;
@@ -0,0 +1,44 @@
1
+ 'use client';
2
+ "use strict";
3
+
4
+ exports.__esModule = true;
5
+ exports.useKeyboardInputEvent = useKeyboardInputEvent;
6
+ exports.default = void 0;
7
+ function useKeyboardInputEvent(_ref) {
8
+ var onSegmentChange = _ref.onSegmentChange,
9
+ onSegmentValueChange = _ref.onSegmentValueChange,
10
+ onSegmentValueChangeWithNumericKeys = _ref.onSegmentValueChangeWithNumericKeys,
11
+ onSegmentValueRemove = _ref.onSegmentValueRemove,
12
+ onKeyDown = _ref.onKeyDown;
13
+ return function (event) {
14
+ var _key$match, _key$match2;
15
+ var key = event.key;
16
+ switch (key) {
17
+ case 'ArrowRight':
18
+ case 'ArrowLeft':
19
+ onSegmentChange === null || onSegmentChange === void 0 ? void 0 : onSegmentChange(event);
20
+ event.preventDefault();
21
+ break;
22
+ case 'ArrowUp':
23
+ case 'ArrowDown':
24
+ onSegmentValueChange === null || onSegmentValueChange === void 0 ? void 0 : onSegmentValueChange(event);
25
+ event.preventDefault();
26
+ break;
27
+ case 'Backspace':
28
+ onSegmentValueRemove === null || onSegmentValueRemove === void 0 ? void 0 : onSegmentValueRemove(event);
29
+ event.preventDefault();
30
+ break;
31
+ case (_key$match = key.match(/\d/)) === null || _key$match === void 0 ? void 0 : _key$match.input:
32
+ // Allow numeric keys to be entered
33
+ onSegmentValueChangeWithNumericKeys === null || onSegmentValueChangeWithNumericKeys === void 0 ? void 0 : onSegmentValueChangeWithNumericKeys(event);
34
+ event.preventDefault();
35
+ case (_key$match2 = key.match(/[a-z]/)) === null || _key$match2 === void 0 ? void 0 : _key$match2[0]:
36
+ // Prevent letters from being entered
37
+ event.preventDefault();
38
+ break;
39
+ }
40
+ onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(event);
41
+ };
42
+ }
43
+ var _default = useKeyboardInputEvent;
44
+ exports.default = _default;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { type Locale } from 'date-fns';
2
3
  interface SelectedStateOptions {
3
4
  /**
@@ -24,13 +25,32 @@ interface SelectedStateOptions {
24
25
  * The offset of the value, which is used to calculate the month.
25
26
  * This value will be changed when pressing the up and down arrow keys.
26
27
  */
27
- valueOffset?: number;
28
+ valueOffset?: number | null;
28
29
  /**
29
30
  * The date is rendered in string format according to format
30
31
  */
31
32
  dateString: string;
32
33
  }
33
34
  export declare function getPatternGroups(format: string, pattern: string): string;
35
+ interface SelectIndexGapOptions {
36
+ pattern: string;
37
+ formatStr: string;
38
+ valueOffset: number | null;
39
+ selectedMonth: number | null;
40
+ localize: Locale['localize'];
41
+ }
42
+ export declare function getSelectIndexGap(options: SelectIndexGapOptions): number;
43
+ interface DatePatternOptions {
44
+ selectionIndex: number;
45
+ positionOffset?: number;
46
+ formatStr: string;
47
+ dateString: string;
48
+ valueOffset: number | null;
49
+ selectedMonth: number | null;
50
+ localize: Locale['localize'];
51
+ }
52
+ export declare function getDatePattern(options: DatePatternOptions): string;
53
+ export declare function isCursorAfterMonth(cursorIndex: number, formatStr: string): boolean;
34
54
  export declare function getInputSelectedState(options: SelectedStateOptions): {
35
55
  selectionStart: number;
36
56
  selectionEnd: number;
@@ -38,4 +58,6 @@ export declare function getInputSelectedState(options: SelectedStateOptions): {
38
58
  };
39
59
  export declare function validateDateTime(type: string, value: number): boolean;
40
60
  export declare function modifyDate(date: Date, type: string, value: number): Date;
61
+ export declare function isFieldFullValue(formatStr: string, value: number, pattern: string): boolean;
62
+ export declare function useInputSelection(input: React.RefObject<any>): (selectionStart: number, selectionEnd: number) => void;
41
63
  export {};
@@ -4,15 +4,99 @@
4
4
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
5
5
  exports.__esModule = true;
6
6
  exports.getPatternGroups = getPatternGroups;
7
+ exports.getSelectIndexGap = getSelectIndexGap;
8
+ exports.getDatePattern = getDatePattern;
9
+ exports.isCursorAfterMonth = isCursorAfterMonth;
7
10
  exports.getInputSelectedState = getInputSelectedState;
8
11
  exports.validateDateTime = validateDateTime;
9
12
  exports.modifyDate = modifyDate;
13
+ exports.isFieldFullValue = isFieldFullValue;
14
+ exports.useInputSelection = useInputSelection;
10
15
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
11
16
  var _dateUtils = require("../utils/dateUtils");
17
+ var _utils = require("../utils");
12
18
  function getPatternGroups(format, pattern) {
13
19
  var _format$match;
14
20
  return ((_format$match = format.match(new RegExp("(" + pattern + ")+"))) === null || _format$match === void 0 ? void 0 : _format$match[0]) || '';
15
21
  }
22
+ function getSelectIndexGap(options) {
23
+ var pattern = options.pattern,
24
+ formatStr = options.formatStr,
25
+ valueOffset = options.valueOffset,
26
+ selectedMonth = options.selectedMonth,
27
+ localize = options.localize;
28
+ var gap = 0;
29
+ var monthIsAbbreviated = formatStr.includes('MMM');
30
+ var monthIsFull = formatStr.includes('MMMM');
31
+
32
+ // If the month is abbreviated or full, the gap needs to be adjusted.
33
+ if (monthIsAbbreviated || monthIsFull) {
34
+ var isSelectedMonth = pattern === 'M';
35
+
36
+ // If the selected is the month, and the valueOffset is null,
37
+ // it means that the delete key is pressed, and the default pattern is displayed, and the gap is 0 at this time.
38
+ if (isSelectedMonth && valueOffset === null) {
39
+ return 0;
40
+ }
41
+
42
+ // If the month is null and the valueOffset is 0, the month will not be updated, and the gap is 0 at this time.
43
+ if (selectedMonth === null && valueOffset === 0) {
44
+ return 0;
45
+ }
46
+ var month = selectedMonth ? selectedMonth + (isSelectedMonth ? valueOffset || 0 : 0) : 1;
47
+ if (month > 12) {
48
+ month = 1;
49
+ } else if (month === 0) {
50
+ month = 12;
51
+ }
52
+ var monthStr = localize === null || localize === void 0 ? void 0 : localize.month(month - 1, {
53
+ width: monthIsFull ? 'wide' : 'abbreviated'
54
+ });
55
+ gap = monthStr.length - (monthIsFull ? 4 : 3);
56
+ }
57
+ return gap;
58
+ }
59
+ function getDatePattern(options) {
60
+ var selectionIndex = options.selectionIndex,
61
+ _options$positionOffs = options.positionOffset,
62
+ positionOffset = _options$positionOffs === void 0 ? -1 : _options$positionOffs,
63
+ formatStr = options.formatStr,
64
+ dateString = options.dateString,
65
+ valueOffset = options.valueOffset,
66
+ selectedMonth = options.selectedMonth,
67
+ localize = options.localize;
68
+ var pattern = formatStr.charAt(selectionIndex || 0);
69
+ if (selectionIndex < 0 || selectionIndex > dateString.length - 1) {
70
+ pattern = formatStr.trim().charAt(0);
71
+ return pattern;
72
+ }
73
+ var gap = 0;
74
+ if (isCursorAfterMonth(selectionIndex, formatStr)) {
75
+ gap = getSelectIndexGap({
76
+ pattern: pattern,
77
+ formatStr: formatStr,
78
+ valueOffset: valueOffset,
79
+ selectedMonth: selectedMonth,
80
+ localize: localize
81
+ });
82
+ }
83
+ pattern = formatStr.charAt(selectionIndex - gap);
84
+
85
+ // If the pattern is not a letter, then get the pattern from the previous or next letter.
86
+ if (!pattern.match(/[y|d|M|H|h|m|s|a]/)) {
87
+ var nextIndex = selectionIndex + positionOffset;
88
+ pattern = getDatePattern((0, _extends2.default)({}, options, {
89
+ selectionIndex: nextIndex
90
+ }));
91
+ }
92
+ return pattern;
93
+ }
94
+
95
+ // Determine whether the cursor is after the month.
96
+ // If the currently operated field is after the month, the selected field needs to be moved backward.
97
+ function isCursorAfterMonth(cursorIndex, formatStr) {
98
+ return cursorIndex > formatStr.indexOf('M');
99
+ }
16
100
  function getInputSelectedState(options) {
17
101
  var input = options.input,
18
102
  direction = options.direction,
@@ -22,74 +106,61 @@ function getInputSelectedState(options) {
22
106
  dateString = options.dateString,
23
107
  _options$valueOffset = options.valueOffset,
24
108
  valueOffset = _options$valueOffset === void 0 ? 0 : _options$valueOffset;
25
- var getSelectIndexGap = function getSelectIndexGap(pattern) {
26
- var gap = 0;
27
- var monthIsAbbreviated = formatStr.includes('MMM');
28
- var monthIsFull = formatStr.includes('MMMM');
29
-
30
- // If the month is abbreviated or full, the gap needs to be adjusted.
31
- if (monthIsAbbreviated || monthIsFull) {
32
- var isSelected = pattern === 'M';
33
- if (selectedMonth === null && valueOffset === 0) {
34
- return gap;
35
- }
36
- var month = selectedMonth ? selectedMonth + (isSelected ? valueOffset : 0) : 1;
37
- if (month > 12) {
38
- month = 1;
39
- } else if (month === 0) {
40
- month = 12;
41
- }
42
- var monthStr = localize === null || localize === void 0 ? void 0 : localize.month(month - 1, {
43
- width: monthIsFull ? 'wide' : 'abbreviated'
44
- });
45
- gap = monthStr.length - (monthIsFull ? 4 : 3);
46
- }
47
- return gap;
48
- };
49
- var getDatePattern = function getDatePattern(selectionIndex, positionOffset) {
50
- if (positionOffset === void 0) {
51
- positionOffset = -1;
52
- }
53
- var pattern = formatStr.charAt((input === null || input === void 0 ? void 0 : input.selectionStart) || 0);
54
- if (selectionIndex < 0 || selectionIndex > dateString.length - 1) {
55
- pattern = formatStr.trim().charAt(0);
56
- return pattern;
57
- }
58
- var gap = getSelectIndexGap(pattern);
59
- pattern = formatStr.charAt(selectionIndex - gap);
60
-
61
- // If the pattern is not a letter, then get the pattern from the previous or next letter.
62
- if (!pattern.match(/[y|d|M|H|h|m|s|a]/)) {
63
- var nextIndex = selectionIndex + positionOffset;
64
- pattern = getDatePattern(nextIndex, positionOffset);
65
- }
66
- return pattern;
67
- };
68
109
  var getPatternSelectedIndexes = function getPatternSelectedIndexes(pattern) {
69
110
  var selectionStart = formatStr.indexOf(pattern);
70
111
  var selectionEnd = formatStr.lastIndexOf(pattern) + 1;
71
- var gap = getSelectIndexGap(pattern);
72
- if (pattern === 'M') {
112
+ var gap = getSelectIndexGap({
113
+ pattern: pattern,
114
+ formatStr: formatStr,
115
+ valueOffset: valueOffset,
116
+ selectedMonth: selectedMonth,
117
+ localize: localize
118
+ });
119
+ var isSelectedMonth = pattern === 'M';
120
+ var isNullMonth = selectedMonth === null && !(isSelectedMonth && valueOffset !== 0);
121
+
122
+ // If the month is null and the valueOffset is 0, the month will not be updated, and the gap is 0 at this time.
123
+ if (isNullMonth) {
124
+ return {
125
+ selectionStart: selectionStart,
126
+ selectionEnd: selectionEnd
127
+ };
128
+ }
129
+ if (isSelectedMonth) {
73
130
  return {
74
131
  selectionStart: selectionStart,
75
132
  selectionEnd: selectionEnd + gap
76
133
  };
77
134
  }
135
+ if (isCursorAfterMonth(selectionStart, formatStr)) {
136
+ return {
137
+ selectionStart: selectionStart + gap,
138
+ selectionEnd: selectionEnd + gap
139
+ };
140
+ }
78
141
  return {
79
- selectionStart: selectionStart + gap,
80
- selectionEnd: selectionEnd + gap
142
+ selectionStart: selectionStart,
143
+ selectionEnd: selectionEnd
81
144
  };
82
145
  };
83
146
  if (typeof input.selectionEnd === 'number' && typeof input.selectionStart === 'number') {
84
- var index = input.selectionStart;
147
+ var selectionIndex = input.selectionStart;
85
148
  var positionOffset = -1;
86
149
  if (direction === 'left') {
87
- index = input.selectionStart - 1;
150
+ selectionIndex = input.selectionStart - 1;
88
151
  } else if (direction === 'right') {
89
- index = input.selectionEnd + 1;
152
+ selectionIndex = input.selectionEnd + 1;
90
153
  positionOffset = 1;
91
154
  }
92
- var datePattern = getDatePattern(index, positionOffset);
155
+ var datePattern = getDatePattern({
156
+ selectionIndex: selectionIndex,
157
+ positionOffset: positionOffset,
158
+ formatStr: formatStr,
159
+ dateString: dateString,
160
+ valueOffset: valueOffset,
161
+ selectedMonth: selectedMonth,
162
+ localize: localize
163
+ });
93
164
  var indexes = getPatternSelectedIndexes(datePattern);
94
165
  return (0, _extends2.default)({
95
166
  selectedPattern: datePattern
@@ -156,4 +227,37 @@ function modifyDate(date, type, value) {
156
227
  return (0, _dateUtils.setSeconds)(date, value);
157
228
  }
158
229
  return date;
230
+ }
231
+ function isFieldFullValue(formatStr, value, pattern) {
232
+ var patternGroup = getPatternGroups(formatStr, pattern);
233
+ if (value.toString().length === patternGroup.length) {
234
+ return true;
235
+ }
236
+ switch (pattern) {
237
+ case 'M':
238
+ return parseInt(value + "0") > 12;
239
+ case 'd':
240
+ return parseInt(value + "0") > 31;
241
+ case 'H':
242
+ return parseInt(value + "0") > 23;
243
+ case 'h':
244
+ return parseInt(value + "0") > 12;
245
+ case 'm':
246
+ case 's':
247
+ return parseInt(value + "0") > 59;
248
+ default:
249
+ return false;
250
+ }
251
+ }
252
+ var isTestEnvironment = undefined === 'test';
253
+ function useInputSelection(input) {
254
+ return function setSelectionRange(selectionStart, selectionEnd) {
255
+ if (isTestEnvironment) {
256
+ (0, _utils.safeSetSelection)(input.current, selectionStart, selectionEnd);
257
+ return;
258
+ }
259
+ requestAnimationFrame(function () {
260
+ (0, _utils.safeSetSelection)(input.current, selectionStart, selectionEnd);
261
+ });
262
+ };
159
263
  }
@@ -1,14 +1,15 @@
1
1
  import React from 'react';
2
2
  import { RangeType } from './Toolbar';
3
3
  import { DatePickerLocale } from '../locales';
4
- import { PickerToggleProps } from '../Picker';
5
4
  import { FormControlBaseProps, PickerBaseProps, RsRefForwardingComponent } from '../@types/common';
6
5
  export type { RangeType } from './Toolbar';
7
- export interface DatePickerProps extends PickerBaseProps<DatePickerLocale>, FormControlBaseProps<Date | null>, Pick<PickerToggleProps, 'caretAs' | 'readOnly' | 'plaintext' | 'loading'> {
8
- /** Predefined date Ranges */
9
- ranges?: RangeType<Date>[];
6
+ export interface DatePickerProps extends PickerBaseProps<DatePickerLocale>, FormControlBaseProps<Date | null> {
7
+ /** Custom caret component */
8
+ caretAs?: React.ElementType | null;
10
9
  /** Calendar panel default presentation date and time */
11
10
  calendarDefaultDate?: Date;
11
+ /** Whether disabled the component */
12
+ disabled?: boolean;
12
13
  /** Rendered as an input, the date can be entered via the keyboard */
13
14
  editable?: boolean;
14
15
  /** Format date */
@@ -21,16 +22,26 @@ export interface DatePickerProps extends PickerBaseProps<DatePickerLocale>, Form
21
22
  inline?: boolean;
22
23
  /** ISO 8601 standard, each calendar week begins on Monday and Sunday on the seventh day */
23
24
  isoWeek?: boolean;
25
+ /** A label displayed at the beginning of toggle button */
26
+ label?: React.ReactNode;
24
27
  /** Set the upper limit of the available year relative to the current selection date */
25
28
  limitEndYear?: number;
26
29
  /** Set the lower limit of the available year relative to the current selection date */
27
30
  limitStartYear?: number;
31
+ /** Whether to display a loading state indicator */
32
+ loading?: boolean;
33
+ /** one tap to select */
34
+ oneTap?: boolean;
35
+ /** Whether plaintext the component */
36
+ plaintext?: boolean;
37
+ /** Whether read only the component */
38
+ readOnly?: boolean;
39
+ /** Predefined date Ranges */
40
+ ranges?: RangeType<Date>[];
28
41
  /** Whether to show week numbers */
29
42
  showWeekNumbers?: boolean;
30
43
  /** Meridian format */
31
44
  showMeridian?: boolean;
32
- /** one tap to select */
33
- oneTap?: boolean;
34
45
  /**
35
46
  * Whether to disable a date on the calendar view
36
47
  *
@@ -98,7 +109,9 @@ export interface DatePickerProps extends PickerBaseProps<DatePickerLocale>, Form
98
109
  onShortcutClick?: (range: RangeType<Date>, event: React.MouseEvent) => void;
99
110
  /** Called when clean */
100
111
  onClean?: (event: React.MouseEvent) => void;
101
- /** Custom render value */
112
+ /**
113
+ * @deprecated
114
+ */
102
115
  renderValue?: (value: Date, format: string) => string;
103
116
  }
104
117
  /**