rsuite 5.45.0 → 5.46.1

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 (60) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/DatePicker/styles/index.less +15 -0
  3. package/cjs/Calendar/MonthDropdown.js +1 -2
  4. package/cjs/Calendar/MonthDropdownItem.js +26 -13
  5. package/cjs/Calendar/Table.js +2 -1
  6. package/cjs/Calendar/TableCell.d.ts +14 -0
  7. package/cjs/Calendar/TableCell.js +72 -0
  8. package/cjs/Calendar/TableHeaderRow.js +3 -1
  9. package/cjs/Calendar/TableRow.d.ts +1 -0
  10. package/cjs/Calendar/TableRow.js +31 -49
  11. package/cjs/Calendar/useCalendarDate.d.ts +1 -1
  12. package/cjs/Calendar/utils.d.ts +7 -0
  13. package/cjs/Calendar/utils.js +15 -0
  14. package/cjs/Cascader/Cascader.js +13 -3
  15. package/cjs/DatePicker/DatePicker.js +145 -38
  16. package/cjs/InputPicker/InputPicker.js +7 -4
  17. package/cjs/Picker/PickerToggle.js +3 -0
  18. package/cjs/Picker/utils.js +21 -12
  19. package/cjs/RangeSlider/RangeSlider.js +14 -6
  20. package/cjs/Slider/Slider.js +7 -3
  21. package/cjs/Table/Table.d.ts +7 -7
  22. package/dist/rsuite-no-reset-rtl.css +110 -62
  23. package/dist/rsuite-no-reset-rtl.min.css +1 -1
  24. package/dist/rsuite-no-reset-rtl.min.css.map +1 -1
  25. package/dist/rsuite-no-reset.css +110 -62
  26. package/dist/rsuite-no-reset.min.css +1 -1
  27. package/dist/rsuite-no-reset.min.css.map +1 -1
  28. package/dist/rsuite-rtl.css +110 -62
  29. package/dist/rsuite-rtl.min.css +1 -1
  30. package/dist/rsuite-rtl.min.css.map +1 -1
  31. package/dist/rsuite.css +110 -62
  32. package/dist/rsuite.js +60 -17
  33. package/dist/rsuite.js.map +1 -1
  34. package/dist/rsuite.min.css +1 -1
  35. package/dist/rsuite.min.css.map +1 -1
  36. package/dist/rsuite.min.js +1 -1
  37. package/dist/rsuite.min.js.map +1 -1
  38. package/esm/Calendar/MonthDropdown.js +1 -2
  39. package/esm/Calendar/MonthDropdownItem.js +28 -15
  40. package/esm/Calendar/Table.js +2 -1
  41. package/esm/Calendar/TableCell.d.ts +14 -0
  42. package/esm/Calendar/TableCell.js +66 -0
  43. package/esm/Calendar/TableHeaderRow.js +3 -1
  44. package/esm/Calendar/TableRow.d.ts +1 -0
  45. package/esm/Calendar/TableRow.js +32 -50
  46. package/esm/Calendar/useCalendarDate.d.ts +1 -1
  47. package/esm/Calendar/utils.d.ts +7 -0
  48. package/esm/Calendar/utils.js +12 -0
  49. package/esm/Cascader/Cascader.js +13 -3
  50. package/esm/DatePicker/DatePicker.js +147 -40
  51. package/esm/InputPicker/InputPicker.js +7 -4
  52. package/esm/Picker/PickerToggle.js +3 -0
  53. package/esm/Picker/utils.js +21 -12
  54. package/esm/RangeSlider/RangeSlider.js +14 -6
  55. package/esm/Slider/Slider.js +7 -3
  56. package/esm/Table/Table.d.ts +7 -7
  57. package/package.json +2 -2
  58. package/styles/color-modes/dark.less +1 -41
  59. package/styles/color-modes/high-contrast.less +1 -36
  60. package/styles/color-modes/light.less +0 -46
@@ -6,6 +6,7 @@ import PropTypes from 'prop-types';
6
6
  import mapValues from 'lodash/mapValues';
7
7
  import pick from 'lodash/pick';
8
8
  import omit from 'lodash/omit';
9
+ import delay from 'lodash/delay';
9
10
  import debounce from 'lodash/debounce';
10
11
  import IconCalendar from '@rsuite/icons/legacy/Calendar';
11
12
  import IconClockO from '@rsuite/icons/legacy/ClockO';
@@ -15,10 +16,12 @@ import { isEveryDateInMonth } from '../Calendar/MonthDropdown';
15
16
  import Toolbar from './Toolbar';
16
17
  import Stack from '../Stack';
17
18
  import PredefinedRanges from './PredefinedRanges';
18
- import { composeFunctions, createChainedFunction, DateUtils, mergeRefs, useClassNames, useControlled, useCustom } from '../utils';
19
- import { PickerOverlay, pickerPropTypes, PickerToggle, PickerToggleTrigger, pickTriggerPropKeys, omitTriggerPropKeys, usePickerClassName, usePublicMethods, useToggleKeyDownEvent } from '../Picker';
19
+ import { composeFunctions, createChainedFunction, mergeRefs, useClassNames, useControlled, useCustom } from '../utils';
20
+ import { shouldRenderMonth, shouldRenderDate, shouldRenderTime, shouldOnlyRenderTime, setHours, getHours, addMonths, addDays, setMinutes, getMinutes, setSeconds, getSeconds, isValid, format, getDateMask, disabledTime, isMatch, calendarOnlyProps } from '../utils/dateUtils';
21
+ import { PickerOverlay, pickerPropTypes, PickerToggle, PickerToggleTrigger, pickTriggerPropKeys, omitTriggerPropKeys, usePickerClassName, usePublicMethods, useToggleKeyDownEvent, onMenuKeyDown } from '../Picker';
20
22
  import { OverlayCloseCause } from '../Overlay/OverlayTrigger';
21
23
  import { deprecatePropTypeNew } from '../utils/deprecatePropType';
24
+ import { getAriaLabel } from '../Calendar/utils';
22
25
  var DatePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
23
26
  var _props$as = props.as,
24
27
  Component = _props$as === void 0 ? 'div' : _props$as,
@@ -92,12 +95,17 @@ var DatePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
92
95
  calendarDate = _useCalendarDate.calendarDate,
93
96
  setCalendarDate = _useCalendarDate.setCalendarDate,
94
97
  resetCalendarDate = _useCalendarDate.resetCalendarDate;
95
- var _useState = useState(),
96
- inputState = _useState[0],
97
- setInputState = _useState[1];
98
- var _useState2 = useState(false),
99
- active = _useState2[0],
100
- setActive = _useState2[1];
98
+ var _useState = useState(false),
99
+ showMonthDropdown = _useState[0],
100
+ setShowMonthDropdown = _useState[1]; // Show only the calendar month panel. formatStr = 'yyyy-MM'
101
+ var onlyShowMonth = shouldRenderMonth(formatStr) && !shouldRenderDate(formatStr);
102
+ var showMonth = onlyShowMonth || showMonthDropdown;
103
+ var _useState2 = useState(),
104
+ inputState = _useState2[0],
105
+ setInputState = _useState2[1];
106
+ var _useState3 = useState(false),
107
+ active = _useState3[0],
108
+ setActive = _useState3[1];
101
109
  var triggerRef = useRef(null);
102
110
  var rootRef = useRef(null);
103
111
  var targetRef = useRef(null);
@@ -151,9 +159,9 @@ var DatePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
151
159
  * The callback triggered when PM/AM is switched.
152
160
  */
153
161
  var handleToggleMeridian = useCallback(function () {
154
- var hours = DateUtils.getHours(calendarDate);
162
+ var hours = getHours(calendarDate);
155
163
  var nextHours = hours >= 12 ? hours - 12 : hours + 12;
156
- var nextDate = DateUtils.setHours(calendarDate, nextHours);
164
+ var nextDate = setHours(calendarDate, nextHours);
157
165
  handleChangeTime(nextDate);
158
166
  }, [calendarDate, handleChangeTime]);
159
167
  var updateValue = useCallback(function (event, nextPageDate, closeOverlay) {
@@ -183,13 +191,57 @@ var DatePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
183
191
  onShortcutClick === null || onShortcutClick === void 0 ? void 0 : onShortcutClick(range, event);
184
192
  }, [handleDateChange, onShortcutClick, updateValue]);
185
193
 
194
+ /**
195
+ * Get the corresponding container based on date selection and month selection
196
+ */
197
+ var getOverlayContainer = useCallback(function () {
198
+ var _overlayRef$current;
199
+ return (_overlayRef$current = overlayRef.current) === null || _overlayRef$current === void 0 ? void 0 : _overlayRef$current.querySelector(showMonth ? '[role="menu"]' : '[role="grid"]');
200
+ }, [showMonth]);
201
+
202
+ /**
203
+ * Check whether the date is focusable
204
+ */
205
+ var checkFocusable = useCallback(function (date) {
206
+ var formatStr = showMonth ? locale.formattedMonthPattern : locale.formattedDayPattern;
207
+ var ariaLabel = getAriaLabel(date, formatStr, formatDate);
208
+ var container = getOverlayContainer();
209
+ var dateElement = container.querySelector("[aria-label=\"" + ariaLabel + "\"]");
210
+ if (dateElement !== null && dateElement !== void 0 && dateElement.hasAttribute('aria-disabled')) {
211
+ return false;
212
+ }
213
+ return true;
214
+ }, [formatDate, getOverlayContainer, locale, showMonth]);
215
+
216
+ /**
217
+ * Focus on the currently selected date element
218
+ */
219
+ var focusSelectedDate = useCallback(function () {
220
+ delay(function () {
221
+ var container = getOverlayContainer();
222
+ var selectedElement = container === null || container === void 0 ? void 0 : container.querySelector('[aria-selected="true"]');
223
+ selectedElement === null || selectedElement === void 0 ? void 0 : selectedElement.focus();
224
+ }, 1);
225
+ }, [getOverlayContainer]);
226
+
227
+ /**
228
+ * Focus on the input element
229
+ */
230
+ var focusTargetButton = useCallback(function () {
231
+ delay(function () {
232
+ var _targetRef$current, _targetRef$current$qu;
233
+ (_targetRef$current = targetRef.current) === null || _targetRef$current === void 0 ? void 0 : (_targetRef$current$qu = _targetRef$current.querySelector('input')) === null || _targetRef$current$qu === void 0 ? void 0 : _targetRef$current$qu.focus();
234
+ }, 100);
235
+ }, []);
236
+
186
237
  /**
187
238
  * The callback triggered after clicking the OK button.
188
239
  */
189
240
  var handleOK = useCallback(function (event) {
190
241
  updateValue(event);
191
242
  onOk === null || onOk === void 0 ? void 0 : onOk(calendarDate, event);
192
- }, [updateValue, onOk, calendarDate]);
243
+ focusTargetButton();
244
+ }, [updateValue, onOk, calendarDate, focusTargetButton]);
193
245
 
194
246
  /**
195
247
  * Callback after clicking the clear button.
@@ -198,6 +250,54 @@ var DatePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
198
250
  updateValue(event, null);
199
251
  resetCalendarDate(null);
200
252
  }, [resetCalendarDate, updateValue]);
253
+ var handlePickerToggleKeyDown = useCallback(function (event) {
254
+ var _event$target;
255
+ var tagName = (_event$target = event.target) === null || _event$target === void 0 ? void 0 : _event$target.tagName;
256
+ if (tagName === 'INPUT') {
257
+ if (event.key === 'ArrowDown') {
258
+ event.preventDefault();
259
+ focusSelectedDate();
260
+ } else if (event.key === 'Enter') {
261
+ var _triggerRef$current2, _triggerRef$current2$;
262
+ (_triggerRef$current2 = triggerRef.current) === null || _triggerRef$current2 === void 0 ? void 0 : (_triggerRef$current2$ = _triggerRef$current2.open) === null || _triggerRef$current2$ === void 0 ? void 0 : _triggerRef$current2$.call(_triggerRef$current2);
263
+ }
264
+ }
265
+ }, [focusSelectedDate]);
266
+ var handlePickerOverlayKeyDown = useCallback(function (event) {
267
+ var delta = 0;
268
+ var step = showMonth ? 6 : 7;
269
+ var changeDateFunc = showMonth ? addMonths : addDays;
270
+ onMenuKeyDown(event, {
271
+ down: function down() {
272
+ delta = step;
273
+ },
274
+ up: function up() {
275
+ delta = -step;
276
+ },
277
+ right: function right() {
278
+ delta = 1;
279
+ },
280
+ left: function left() {
281
+ delta = -1;
282
+ },
283
+ enter: function enter() {
284
+ handleOK(event);
285
+ }
286
+ });
287
+ var nextDate = changeDateFunc(calendarDate, delta);
288
+ if (checkFocusable(nextDate)) {
289
+ setCalendarDate(nextDate);
290
+ focusSelectedDate();
291
+ }
292
+ }, [showMonth, calendarDate, checkFocusable, handleOK, setCalendarDate, focusSelectedDate]);
293
+
294
+ /**
295
+ * The callback triggered after the month selection box is opened or closed.
296
+ */
297
+ var handleToggleMonthDropdown = useCallback(function (toggle) {
298
+ onToggleMonthDropdown === null || onToggleMonthDropdown === void 0 ? void 0 : onToggleMonthDropdown(toggle);
299
+ setShowMonthDropdown(toggle);
300
+ }, [onToggleMonthDropdown]);
201
301
 
202
302
  /**
203
303
  * Handle keyboard events.
@@ -205,8 +305,10 @@ var DatePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
205
305
  var onPickerKeyDown = useToggleKeyDownEvent(_extends({
206
306
  triggerRef: triggerRef,
207
307
  targetRef: targetRef,
308
+ overlayRef: overlayRef,
208
309
  active: active,
209
- onExit: handleClean
310
+ onExit: handleClean,
311
+ onKeyDown: handlePickerToggleKeyDown
210
312
  }, rest));
211
313
 
212
314
  /**
@@ -218,18 +320,18 @@ var DatePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
218
320
  }
219
321
  setCalendarDate(
220
322
  // Determine whether the current value contains time, if not, use calendarDate.
221
- DateUtils.shouldRenderTime(formatStr) ? nextValue : composeFunctions(function (d) {
222
- return DateUtils.setHours(d, DateUtils.getHours(calendarDate));
323
+ shouldRenderTime(formatStr) ? nextValue : composeFunctions(function (d) {
324
+ return setHours(d, getHours(calendarDate));
223
325
  }, function (d) {
224
- return DateUtils.setMinutes(d, DateUtils.getMinutes(calendarDate));
326
+ return setMinutes(d, getMinutes(calendarDate));
225
327
  }, function (d) {
226
- return DateUtils.setSeconds(d, DateUtils.getSeconds(calendarDate));
328
+ return setSeconds(d, getSeconds(calendarDate));
227
329
  })(nextValue));
228
330
  handleDateChange(nextValue);
229
331
  if (oneTap && updatableValue) {
230
332
  updateValue(event, nextValue);
231
333
  }
232
- }, [formatStr, handleDateChange, oneTap, calendarDate, setCalendarDate, updateValue]);
334
+ }, [setCalendarDate, formatStr, handleDateChange, oneTap, calendarDate, updateValue]);
233
335
 
234
336
  /**
235
337
  * A callback triggered when the date on the calendar changes.
@@ -237,13 +339,11 @@ var DatePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
237
339
  var handleChangeMonth = useCallback(function (nextPageDate, event) {
238
340
  setCalendarDate(nextPageDate);
239
341
  handleDateChange(nextPageDate);
240
-
241
- // Show only the calendar month panel. formatStr = 'yyyy-MM'
242
- var onlyShowMonth = DateUtils.shouldRenderMonth(formatStr) && !DateUtils.shouldRenderDate(formatStr);
342
+ focusSelectedDate();
243
343
  if (oneTap && onlyShowMonth) {
244
344
  updateValue(event, nextPageDate);
245
345
  }
246
- }, [formatStr, handleDateChange, oneTap, setCalendarDate, updateValue]);
346
+ }, [focusSelectedDate, handleDateChange, oneTap, onlyShowMonth, setCalendarDate, updateValue]);
247
347
  var isDateDisabled = useCallback(function (date) {
248
348
  if (typeof shouldDisableDate === 'function') {
249
349
  return shouldDisableDate(date);
@@ -262,7 +362,7 @@ var DatePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
262
362
 
263
363
  // isMatch('01/11/2020', 'MM/dd/yyyy') ==> true
264
364
  // isMatch('2020-11-01', 'MM/dd/yyyy') ==> false
265
- if (!DateUtils.isMatch(value, formatStr, {
365
+ if (!isMatch(value, formatStr, {
266
366
  locale: locale.dateLocale
267
367
  })) {
268
368
  setInputState('Error');
@@ -271,10 +371,10 @@ var DatePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
271
371
  var date = parseDate(value, formatStr);
272
372
 
273
373
  // If only the time is included in the characters, it will default to today.
274
- if (DateUtils.shouldOnlyRenderTime(formatStr)) {
275
- date = new Date(DateUtils.format(new Date(), 'yyyy-MM-dd') + " " + value);
374
+ if (shouldOnlyRenderTime(formatStr)) {
375
+ date = new Date(format(new Date(), 'yyyy-MM-dd') + " " + value);
276
376
  }
277
- if (!DateUtils.isValid(date)) {
377
+ if (!isValid(date)) {
278
378
  setInputState('Error');
279
379
  return;
280
380
  }
@@ -315,7 +415,7 @@ var DatePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
315
415
  var disabledToolbarHandle = useCallback(function (date) {
316
416
  var _DEPRECATED_disabledD;
317
417
  var allowDate = (_DEPRECATED_disabledD = DEPRECATED_disabledDate === null || DEPRECATED_disabledDate === void 0 ? void 0 : DEPRECATED_disabledDate(date)) !== null && _DEPRECATED_disabledD !== void 0 ? _DEPRECATED_disabledD : false;
318
- var allowTime = DateUtils.disabledTime(props, date);
418
+ var allowTime = disabledTime(props, date);
319
419
  return allowDate || allowTime;
320
420
  }, [DEPRECATED_disabledDate, props]);
321
421
 
@@ -326,13 +426,13 @@ var DatePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
326
426
  * - If format is month, disable ok button if all dates in the month of selected date are disabled
327
427
  */
328
428
  var isOKButtonDisabled = useCallback(function (selectedDate) {
329
- if (DateUtils.shouldRenderMonth(formatStr) && !DateUtils.shouldRenderDate(formatStr)) {
429
+ if (shouldRenderMonth(formatStr) && !shouldRenderDate(formatStr)) {
330
430
  return isEveryDateInMonth(selectedDate.getFullYear(), selectedDate.getMonth(), disabledToolbarHandle);
331
431
  }
332
432
  return disabledToolbarHandle(selectedDate);
333
433
  }, [disabledToolbarHandle, formatStr]);
334
434
  var calendarProps = useMemo(function () {
335
- return mapValues(pick(props, DateUtils.calendarOnlyProps), function (disabledOrHiddenTimeFunc) {
435
+ return mapValues(pick(props, calendarOnlyProps), function (disabledOrHiddenTimeFunc) {
336
436
  return function (next, date) {
337
437
  var _disabledOrHiddenTime;
338
438
  return (_disabledOrHiddenTime = disabledOrHiddenTimeFunc === null || disabledOrHiddenTimeFunc === void 0 ? void 0 : disabledOrHiddenTimeFunc(next, date)) !== null && _disabledOrHiddenTime !== void 0 ? _disabledOrHiddenTime : false;
@@ -355,15 +455,19 @@ var DatePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
355
455
  onMoveForward: handleMoveForward,
356
456
  onMoveBackward: handleMoveBackward,
357
457
  onSelect: handleSelect,
358
- onToggleMonthDropdown: onToggleMonthDropdown,
458
+ onToggleMonthDropdown: handleToggleMonthDropdown,
359
459
  onToggleTimeDropdown: onToggleTimeDropdown,
360
460
  onChangeMonth: handleChangeMonth,
361
461
  onChangeTime: handleChangeTime,
362
462
  onToggleMeridian: handleToggleMeridian
363
463
  }));
464
+
465
+ // The shortcut option on the left side of the calendar panel
364
466
  var sideRanges = (ranges === null || ranges === void 0 ? void 0 : ranges.filter(function (range) {
365
467
  return (range === null || range === void 0 ? void 0 : range.placement) === 'left';
366
468
  })) || [];
469
+
470
+ // The shortcut option on the bottom of the calendar panel
367
471
  var bottomRanges = (ranges === null || ranges === void 0 ? void 0 : ranges.filter(function (range) {
368
472
  return (range === null || range === void 0 ? void 0 : range.placement) === 'bottom' || (range === null || range === void 0 ? void 0 : range.placement) === undefined;
369
473
  })) || [];
@@ -381,7 +485,8 @@ var DatePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
381
485
  className: classes,
382
486
  ref: mergeRefs(overlayRef, speakerRef),
383
487
  style: styles,
384
- target: triggerRef
488
+ target: triggerRef,
489
+ onKeyDown: handlePickerOverlayKeyDown
385
490
  }, /*#__PURE__*/React.createElement(Stack, {
386
491
  alignItems: "flex-start"
387
492
  }, sideRanges.length > 0 && /*#__PURE__*/React.createElement(PredefinedRanges, {
@@ -422,20 +527,22 @@ var DatePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
422
527
  return (_renderValue = renderValue === null || renderValue === void 0 ? void 0 : renderValue(value, formatStr)) !== null && _renderValue !== void 0 ? _renderValue : formatDate(value, formatStr);
423
528
  }, [formatStr, formatDate, placeholder, renderValue, value]);
424
529
  var caretAs = useMemo(function () {
425
- return caretAsProp || (DateUtils.shouldOnlyRenderTime(formatStr) ? IconClockO : IconCalendar);
530
+ return caretAsProp || (shouldOnlyRenderTime(formatStr) ? IconClockO : IconCalendar);
426
531
  }, [caretAsProp, formatStr]);
532
+ var handleTriggerClose = useCallback(function (cause) {
533
+ // Unless overlay is closing on user clicking "OK" button,
534
+ // reset the selected date on calendar panel
535
+ if (cause !== OverlayCloseCause.ImperativeHandle) {
536
+ resetCalendarDate();
537
+ }
538
+ setShowMonthDropdown(false);
539
+ }, [resetCalendarDate]);
427
540
  return /*#__PURE__*/React.createElement(PickerToggleTrigger, {
428
541
  trigger: "active",
429
542
  pickerProps: pick(props, pickTriggerPropKeys),
430
543
  ref: triggerRef,
431
544
  placement: placement,
432
- onClose: function onClose(cause) {
433
- // Unless overlay is closing on user clicking "OK" button,
434
- // reset the selected date on calendar panel
435
- if (cause !== OverlayCloseCause.ImperativeHandle) {
436
- resetCalendarDate();
437
- }
438
- },
545
+ onClose: handleTriggerClose,
439
546
  onEntered: createChainedFunction(handleEntered, onEntered),
440
547
  onExited: createChainedFunction(handleExited, onExited),
441
548
  speaker: renderDropdownMenu
@@ -443,7 +550,7 @@ var DatePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
443
550
  className: merge(className, classes),
444
551
  style: style,
445
552
  ref: rootRef
446
- }, /*#__PURE__*/React.createElement(PickerToggle, _extends({}, omit(rest, [].concat(omitTriggerPropKeys, usedClassNamePropKeys, DateUtils.calendarOnlyProps)), {
553
+ }, /*#__PURE__*/React.createElement(PickerToggle, _extends({}, omit(rest, [].concat(omitTriggerPropKeys, usedClassNamePropKeys, calendarOnlyProps)), {
447
554
  className: prefix({
448
555
  error: inputState === 'Error'
449
556
  }),
@@ -453,7 +560,7 @@ var DatePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
453
560
  editable: editable,
454
561
  inputValue: value ? formatDate(value, formatStr) : '',
455
562
  inputPlaceholder: typeof placeholder === 'string' && placeholder ? placeholder : formatStr,
456
- inputMask: DateUtils.getDateMask(formatStr),
563
+ inputMask: getDateMask(formatStr),
457
564
  onInputChange: handleInputChange,
458
565
  onInputBlur: handleInputPressEnd,
459
566
  onInputPressEnter: handleInputPressEnd,
@@ -143,9 +143,12 @@ var InputPicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
143
143
  return multi ? clone(value) || [] : value;
144
144
  }, [multi, value]);
145
145
  var handleClose = useCallback(function () {
146
- var _triggerRef$current;
146
+ var _triggerRef$current, _targetRef$current, _targetRef$current$fo;
147
147
  triggerRef === null || triggerRef === void 0 ? void 0 : (_triggerRef$current = triggerRef.current) === null || _triggerRef$current === void 0 ? void 0 : _triggerRef$current.close();
148
- }, [triggerRef]);
148
+
149
+ // The focus is on the trigger button after closing
150
+ (_targetRef$current = targetRef.current) === null || _targetRef$current === void 0 ? void 0 : (_targetRef$current$fo = _targetRef$current.focus) === null || _targetRef$current$fo === void 0 ? void 0 : _targetRef$current$fo.call(_targetRef$current);
151
+ }, []);
149
152
 
150
153
  // Used to hover the focuse item when trigger `onKeydown`
151
154
  var _useFocusItemValue = useFocusItemValue(multi ? value === null || value === void 0 ? void 0 : value[0] : value, {
@@ -651,7 +654,7 @@ var InputPicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
651
654
  plaintext: plaintext,
652
655
  ref: targetRef,
653
656
  as: toggleAs,
654
- tabIndex: undefined,
657
+ tabIndex: tabIndex,
655
658
  onClean: handleClean,
656
659
  cleanable: cleanable && !disabled,
657
660
  hasValue: hasValue,
@@ -663,7 +666,7 @@ var InputPicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
663
666
  }), searching || multi && hasValue ? null : itemNode || placeholderNode), !(!multi && disabled) && /*#__PURE__*/React.createElement("div", {
664
667
  className: prefix(_templateObject5 || (_templateObject5 = _taggedTemplateLiteralLoose(["tag-wrapper"])))
665
668
  }, tagElements, displaySearchInput && /*#__PURE__*/React.createElement(InputSearch, _extends({}, inputProps, {
666
- tabIndex: tabIndex,
669
+ tabIndex: -1,
667
670
  readOnly: readOnly,
668
671
  onBlur: onBlur,
669
672
  onFocus: createChainedFunction(handleFocus, onFocus),
@@ -142,6 +142,8 @@ var PickerToggle = /*#__PURE__*/React.forwardRef(function (props, ref) {
142
142
  }, [editable, onInputPressEnter, onInputBackspace]);
143
143
  var renderInput = useCallback(function (ref, props) {
144
144
  return /*#__PURE__*/React.createElement("input", _extends({
145
+ type: "text",
146
+ autoComplete: "off",
145
147
  ref: mergeRefs(inputRef, ref),
146
148
  name: name,
147
149
  style: {
@@ -191,6 +193,7 @@ var PickerToggle = /*#__PURE__*/React.forwardRef(function (props, ref) {
191
193
  },
192
194
  "data-testid": "spinner"
193
195
  }) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(TextMask, {
196
+ keepCharPositions: true,
194
197
  mask: inputMask,
195
198
  value: Array.isArray(inputValue) ? inputValue.toString() : inputValue,
196
199
  onBlur: handleInputBlur,
@@ -182,6 +182,12 @@ export var useFocusItemValue = function useFocusItemValue(defaultFocusItemValue,
182
182
  var _useState3 = useState([]),
183
183
  keys = _useState3[0],
184
184
  setKeys = _useState3[1];
185
+ var focusCallback = useCallback(function (value, event) {
186
+ var menu = isFunction(target) ? target() : target;
187
+ var focusElement = menu === null || menu === void 0 ? void 0 : menu.querySelector("[data-key=\"" + value + "\"]");
188
+ focusElement === null || focusElement === void 0 ? void 0 : focusElement.focus();
189
+ callback === null || callback === void 0 ? void 0 : callback(value, event);
190
+ }, [callback, target]);
185
191
  var getScrollContainer = useCallback(function () {
186
192
  var menu = isFunction(target) ? target() : target;
187
193
 
@@ -267,11 +273,11 @@ export var useFocusItemValue = function useFocusItemValue(defaultFocusItemValue,
267
273
  var focusItem = items[nextIndex];
268
274
  if (!isUndefined(focusItem)) {
269
275
  setFocusItemValue(focusItem[valueKey]);
270
- callback === null || callback === void 0 ? void 0 : callback(focusItem[valueKey], event);
276
+ focusCallback(focusItem[valueKey], event);
271
277
  scrollListItem('bottom', focusItem[valueKey], willOverflow);
272
278
  }
273
279
  });
274
- }, [callback, findFocusItemIndex, scrollListItem, valueKey]);
280
+ }, [focusCallback, findFocusItemIndex, scrollListItem, valueKey]);
275
281
  var focusPrevMenuItem = useCallback(function (event) {
276
282
  findFocusItemIndex(function (items, index) {
277
283
  var willOverflow = index === 0;
@@ -279,11 +285,11 @@ export var useFocusItemValue = function useFocusItemValue(defaultFocusItemValue,
279
285
  var focusItem = items[nextIndex];
280
286
  if (!isUndefined(focusItem)) {
281
287
  setFocusItemValue(focusItem[valueKey]);
282
- callback === null || callback === void 0 ? void 0 : callback(focusItem[valueKey], event);
288
+ focusCallback(focusItem[valueKey], event);
283
289
  scrollListItem('top', focusItem[valueKey], willOverflow);
284
290
  }
285
291
  });
286
- }, [callback, findFocusItemIndex, scrollListItem, valueKey]);
292
+ }, [focusCallback, findFocusItemIndex, scrollListItem, valueKey]);
287
293
  var getSubMenuKeys = useCallback(function (nextLayer) {
288
294
  var menu = isFunction(target) ? target() : target;
289
295
  var subMenu = menu === null || menu === void 0 ? void 0 : menu.querySelector("[data-layer=\"" + nextLayer + "\"]");
@@ -303,9 +309,9 @@ export var useFocusItemValue = function useFocusItemValue(defaultFocusItemValue,
303
309
  setKeys(nextKeys);
304
310
  setLayer(nextLayer);
305
311
  setFocusItemValue(nextKeys[0]);
306
- callback === null || callback === void 0 ? void 0 : callback(nextKeys[0], event);
312
+ focusCallback(nextKeys[0], event);
307
313
  }
308
- }, [callback, getSubMenuKeys, layer]);
314
+ }, [focusCallback, getSubMenuKeys, layer]);
309
315
  var focusPrevLevelMenu = useCallback(function (event) {
310
316
  var nextLayer = layer - 1;
311
317
  var nextKeys = getSubMenuKeys(nextLayer);
@@ -319,10 +325,10 @@ export var useFocusItemValue = function useFocusItemValue(defaultFocusItemValue,
319
325
  var parentItemValue = (_getParent = getParent(focusItem)) === null || _getParent === void 0 ? void 0 : _getParent[valueKey];
320
326
  if (parentItemValue) {
321
327
  setFocusItemValue(parentItemValue);
322
- callback === null || callback === void 0 ? void 0 : callback(parentItemValue, event);
328
+ focusCallback(parentItemValue, event);
323
329
  }
324
330
  }
325
- }, [callback, data, focusItemValue, getParent, getSubMenuKeys, layer, valueKey]);
331
+ }, [focusCallback, data, focusItemValue, getParent, getSubMenuKeys, layer, valueKey]);
326
332
  var handleKeyDown = useCallback(function (event) {
327
333
  var _onMenuKeyDown;
328
334
  onMenuKeyDown(event, (_onMenuKeyDown = {
@@ -363,10 +369,13 @@ export var useToggleKeyDownEvent = function useToggleKeyDownEvent(props) {
363
369
  onMenuPressEnter = props.onMenuPressEnter,
364
370
  onMenuPressBackspace = props.onMenuPressBackspace;
365
371
  var handleClose = useCallback(function () {
366
- var _triggerRef$current, _triggerRef$current$c;
372
+ var _triggerRef$current, _triggerRef$current$c, _targetRef$current, _targetRef$current$fo;
367
373
  (_triggerRef$current = triggerRef.current) === null || _triggerRef$current === void 0 ? void 0 : (_triggerRef$current$c = _triggerRef$current.close) === null || _triggerRef$current$c === void 0 ? void 0 : _triggerRef$current$c.call(_triggerRef$current);
374
+
375
+ // The focus is on the trigger button after closing
376
+ (_targetRef$current = targetRef.current) === null || _targetRef$current === void 0 ? void 0 : (_targetRef$current$fo = _targetRef$current.focus) === null || _targetRef$current$fo === void 0 ? void 0 : _targetRef$current$fo.call(_targetRef$current);
368
377
  onClose === null || onClose === void 0 ? void 0 : onClose();
369
- }, [onClose, triggerRef]);
378
+ }, [onClose, targetRef, triggerRef]);
370
379
  var handleOpen = useCallback(function () {
371
380
  var _triggerRef$current2, _triggerRef$current2$;
372
381
  (_triggerRef$current2 = triggerRef.current) === null || _triggerRef$current2 === void 0 ? void 0 : (_triggerRef$current2$ = _triggerRef$current2.open) === null || _triggerRef$current2$ === void 0 ? void 0 : _triggerRef$current2$.call(_triggerRef$current2);
@@ -527,8 +536,8 @@ export function usePublicMethods(ref, parmas) {
527
536
  return (_overlayRef$current = overlayRef === null || overlayRef === void 0 ? void 0 : overlayRef.current) !== null && _overlayRef$current !== void 0 ? _overlayRef$current : null;
528
537
  },
529
538
  get target() {
530
- var _targetRef$current;
531
- return (_targetRef$current = targetRef === null || targetRef === void 0 ? void 0 : targetRef.current) !== null && _targetRef$current !== void 0 ? _targetRef$current : null;
539
+ var _targetRef$current2;
540
+ return (_targetRef$current2 = targetRef === null || targetRef === void 0 ? void 0 : targetRef.current) !== null && _targetRef$current2 !== void 0 ? _targetRef$current2 : null;
532
541
  },
533
542
  get list() {
534
543
  if (!(listRef !== null && listRef !== void 0 && listRef.current)) {
@@ -30,6 +30,7 @@ var RangeSlider = /*#__PURE__*/React.forwardRef(function (props, ref) {
30
30
  progress = _props$progress === void 0 ? true : _props$progress,
31
31
  vertical = props.vertical,
32
32
  disabled = props.disabled,
33
+ readOnly = props.readOnly,
33
34
  _props$classPrefix = props.classPrefix,
34
35
  classPrefix = _props$classPrefix === void 0 ? 'slider' : _props$classPrefix,
35
36
  _props$min = props.min,
@@ -49,7 +50,7 @@ var RangeSlider = /*#__PURE__*/React.forwardRef(function (props, ref) {
49
50
  renderMark = props.renderMark,
50
51
  onChange = props.onChange,
51
52
  onChangeCommitted = props.onChangeCommitted,
52
- rest = _objectWithoutPropertiesLoose(props, ["aria-label", "aria-labelledby", "aria-valuetext", "as", "barClassName", "className", "constraint", "defaultValue", "graduated", "progress", "vertical", "disabled", "classPrefix", "min", "max", "step", "value", "handleClassName", "handleStyle", "handleTitle", "tooltip", "getAriaValueText", "renderTooltip", "renderMark", "onChange", "onChangeCommitted"]);
53
+ rest = _objectWithoutPropertiesLoose(props, ["aria-label", "aria-labelledby", "aria-valuetext", "as", "barClassName", "className", "constraint", "defaultValue", "graduated", "progress", "vertical", "disabled", "readOnly", "classPrefix", "min", "max", "step", "value", "handleClassName", "handleStyle", "handleTitle", "tooltip", "getAriaValueText", "renderTooltip", "renderMark", "onChange", "onChangeCommitted"]);
53
54
  var barRef = useRef(null);
54
55
 
55
56
  // Define the parameter position of the handle
@@ -162,6 +163,9 @@ var RangeSlider = /*#__PURE__*/React.forwardRef(function (props, ref) {
162
163
  * Callback function that is fired when the mousemove is triggered
163
164
  */
164
165
  var handleDragMove = useEventCallback(function (event, dataset) {
166
+ if (disabled || readOnly) {
167
+ return;
168
+ }
165
169
  var nextValue = getNextValue(event, dataset);
166
170
  if (isRangeMatchingConstraint(nextValue)) {
167
171
  setValue(nextValue);
@@ -173,12 +177,15 @@ var RangeSlider = /*#__PURE__*/React.forwardRef(function (props, ref) {
173
177
  * Callback function that is fired when the mouseup is triggered
174
178
  */
175
179
  var handleChangeCommitted = useCallback(function (event, dataset) {
180
+ if (disabled || readOnly) {
181
+ return;
182
+ }
176
183
  var nextValue = getNextValue(event, dataset);
177
184
  if (isRangeMatchingConstraint(nextValue)) {
178
185
  setValue(nextValue);
179
186
  onChangeCommitted === null || onChangeCommitted === void 0 ? void 0 : onChangeCommitted(nextValue, event);
180
187
  }
181
- }, [getNextValue, onChangeCommitted, isRangeMatchingConstraint, setValue]);
188
+ }, [disabled, readOnly, getNextValue, isRangeMatchingConstraint, setValue, onChangeCommitted]);
182
189
  var handleKeyDown = useCallback(function (event) {
183
190
  var _event$target;
184
191
  var _event$target$dataset = (_event$target = event.target) === null || _event$target === void 0 ? void 0 : _event$target['dataset'],
@@ -219,8 +226,8 @@ var RangeSlider = /*#__PURE__*/React.forwardRef(function (props, ref) {
219
226
  onChange === null || onChange === void 0 ? void 0 : onChange(nextValue, event);
220
227
  }
221
228
  }, [max, min, onChange, rtl, isRangeMatchingConstraint, setValue, step, value]);
222
- var handleClick = useCallback(function (event) {
223
- if (disabled) {
229
+ var handleBarClick = useCallback(function (event) {
230
+ if (disabled || readOnly) {
224
231
  return;
225
232
  }
226
233
  var start = value[0],
@@ -239,8 +246,9 @@ var RangeSlider = /*#__PURE__*/React.forwardRef(function (props, ref) {
239
246
  if (isRangeMatchingConstraint(nextValue)) {
240
247
  setValue(nextValue);
241
248
  onChange === null || onChange === void 0 ? void 0 : onChange(nextValue, event);
249
+ onChangeCommitted === null || onChangeCommitted === void 0 ? void 0 : onChangeCommitted(nextValue, event);
242
250
  }
243
- }, [disabled, getValidValue, getValueByPosition, isRangeMatchingConstraint, onChange, setValue, value]);
251
+ }, [disabled, readOnly, getValidValue, getValueByPosition, isRangeMatchingConstraint, onChange, onChangeCommitted, setValue, value]);
244
252
  var handleProps = useMemo(function () {
245
253
  return [{
246
254
  value: value[0],
@@ -281,7 +289,7 @@ var RangeSlider = /*#__PURE__*/React.forwardRef(function (props, ref) {
281
289
  }), /*#__PURE__*/React.createElement("div", {
282
290
  className: merge(barClassName, prefix('bar')),
283
291
  ref: barRef,
284
- onClick: handleClick
292
+ onClick: handleBarClick
285
293
  }, progress && /*#__PURE__*/React.createElement(ProgressBar, {
286
294
  rtl: rtl,
287
295
  vertical: vertical,
@@ -83,9 +83,9 @@ var Slider = /*#__PURE__*/React.forwardRef(function (props, ref) {
83
83
  var classes = merge(className, withClassPrefix({
84
84
  vertical: vertical,
85
85
  disabled: disabled,
86
- readOnly: readOnly,
87
86
  graduated: graduated,
88
- 'with-mark': renderMark
87
+ 'with-mark': renderMark,
88
+ readonly: readOnly
89
89
  }));
90
90
  var max = useMemo(function () {
91
91
  return precisionMath(Math.floor((maxProp - min) / step) * step + min);
@@ -159,6 +159,10 @@ var Slider = /*#__PURE__*/React.forwardRef(function (props, ref) {
159
159
  var nextValue = getValidValue(getValueByPosition(event));
160
160
  onChangeCommitted === null || onChangeCommitted === void 0 ? void 0 : onChangeCommitted(nextValue, event);
161
161
  }, [disabled, getValidValue, getValueByPosition, onChangeCommitted, readOnly]);
162
+ var handleClickBar = useCallback(function (event) {
163
+ handleChangeValue(event);
164
+ handleChangeCommitted(event);
165
+ }, [handleChangeCommitted, handleChangeValue]);
162
166
  var handleKeyDown = useCallback(function (event) {
163
167
  var nextValue;
164
168
  var increaseKey = rtl ? 'ArrowLeft' : 'ArrowRight';
@@ -200,7 +204,7 @@ var Slider = /*#__PURE__*/React.forwardRef(function (props, ref) {
200
204
  }), /*#__PURE__*/React.createElement("div", {
201
205
  ref: barRef,
202
206
  className: merge(barClassName, prefix('bar')),
203
- onClick: handleChangeValue
207
+ onClick: handleClickBar
204
208
  }, progress && /*#__PURE__*/React.createElement(ProgressBar, {
205
209
  rtl: rtl,
206
210
  vertical: vertical,
@@ -1,15 +1,15 @@
1
1
  import React from 'react';
2
- import { Column, TableProps, RowDataType, TableInstance, CellProps as TableCellProps } from 'rsuite-table';
3
- export interface CellProps<T = any> extends Omit<TableCellProps, 'rowData' | 'dataKey'> {
2
+ import { Column, TableProps, RowDataType, TableInstance, CellProps as TableCellProps, RowKeyType } from 'rsuite-table';
3
+ export interface CellProps<Row extends RowDataType> extends Omit<TableCellProps<Row>, 'rowData' | 'dataKey'> {
4
4
  /** Data binding key, but also a sort of key */
5
- dataKey?: string | keyof T;
5
+ dataKey?: string | keyof Row;
6
6
  /** Row Data */
7
- rowData?: T;
7
+ rowData?: Row;
8
8
  }
9
- declare const _default: (<Row extends RowDataType<never>, Key>(props: TableProps<Row, Key> & React.RefAttributes<TableInstance<Row, Key>>) => React.ReactElement<any, string | React.JSXElementConstructor<any>>) & {
10
- Cell: React.ForwardRefExoticComponent<import("rsuite-table/lib/Cell").InnerCellProps & React.RefAttributes<HTMLDivElement>>;
9
+ declare const _default: (<Row extends RowDataType<any>, Key extends RowKeyType>(props: TableProps<Row, Key> & React.RefAttributes<TableInstance<Row, Key>>) => React.ReactElement<any, string | React.JSXElementConstructor<any>>) & {
10
+ Cell: <Row_1 extends RowDataType<any>, Key_1 extends RowKeyType>(props: import("rsuite-table/lib/Cell").InnerCellProps<Row_1, Key_1> & React.RefAttributes<HTMLDivElement>) => React.ReactElement<any, string | React.JSXElementConstructor<any>>;
11
11
  Column: typeof Column;
12
- HeaderCell: React.ForwardRefExoticComponent<import("rsuite-table").HeaderCellProps & React.RefAttributes<HTMLDivElement>>;
12
+ HeaderCell: <Row_2 extends RowDataType<any>, Key_2 extends RowKeyType>(props: import("rsuite-table").HeaderCellProps<Row_2, Key_2> & React.RefAttributes<HTMLDivElement>) => React.ReactElement<any, string | React.JSXElementConstructor<any>>;
13
13
  ColumnGroup: React.ForwardRefExoticComponent<import("rsuite-table").ColumnGroupProps & React.RefAttributes<HTMLDivElement>>;
14
14
  };
15
15
  export default _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rsuite",
3
- "version": "5.45.0",
3
+ "version": "5.46.1",
4
4
  "description": "A suite of react components",
5
5
  "main": "cjs/index.js",
6
6
  "module": "esm/index.js",
@@ -38,7 +38,7 @@
38
38
  "prop-types": "^15.8.1",
39
39
  "react-use-set": "^1.0.0",
40
40
  "react-window": "^1.8.8",
41
- "rsuite-table": "^5.17.0",
41
+ "rsuite-table": "^5.18.2",
42
42
  "schema-typed": "^2.1.3"
43
43
  },
44
44
  "peerDependencies": {