rsuite 5.28.2 → 5.29.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 (42) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/cjs/Affix/Affix.d.ts +5 -3
  3. package/cjs/Affix/Affix.js +33 -11
  4. package/cjs/AutoComplete/AutoComplete.d.ts +2 -0
  5. package/cjs/DatePicker/DatePicker.d.ts +34 -3
  6. package/cjs/DatePicker/DatePicker.js +38 -16
  7. package/cjs/DateRangePicker/DateRangePicker.d.ts +9 -1
  8. package/cjs/DateRangePicker/DateRangePicker.js +16 -6
  9. package/cjs/FormControl/FormControl.js +1 -1
  10. package/cjs/Overlay/Modal.js +5 -5
  11. package/cjs/Overlay/OverlayTrigger.js +3 -2
  12. package/cjs/Table/Table.d.ts +8 -18
  13. package/cjs/Table/Table.js +8 -7
  14. package/cjs/Table/index.d.ts +2 -2
  15. package/cjs/utils/dateUtils.d.ts +1 -0
  16. package/cjs/utils/dateUtils.js +10 -3
  17. package/cjs/utils/deprecatePropType.d.ts +5 -0
  18. package/cjs/utils/deprecatePropType.js +5 -0
  19. package/cjs/utils/usePortal.js +9 -12
  20. package/dist/rsuite.js +765 -734
  21. package/dist/rsuite.js.map +1 -1
  22. package/dist/rsuite.min.js +1 -1
  23. package/dist/rsuite.min.js.map +1 -1
  24. package/esm/Affix/Affix.d.ts +5 -3
  25. package/esm/Affix/Affix.js +32 -11
  26. package/esm/AutoComplete/AutoComplete.d.ts +2 -0
  27. package/esm/DatePicker/DatePicker.d.ts +34 -3
  28. package/esm/DatePicker/DatePicker.js +37 -16
  29. package/esm/DateRangePicker/DateRangePicker.d.ts +9 -1
  30. package/esm/DateRangePicker/DateRangePicker.js +15 -6
  31. package/esm/FormControl/FormControl.js +1 -1
  32. package/esm/Overlay/Modal.js +5 -4
  33. package/esm/Overlay/OverlayTrigger.js +3 -2
  34. package/esm/Table/Table.d.ts +8 -18
  35. package/esm/Table/Table.js +9 -9
  36. package/esm/Table/index.d.ts +2 -2
  37. package/esm/utils/dateUtils.d.ts +1 -0
  38. package/esm/utils/dateUtils.js +10 -3
  39. package/esm/utils/deprecatePropType.d.ts +5 -0
  40. package/esm/utils/deprecatePropType.js +5 -0
  41. package/esm/utils/usePortal.js +10 -13
  42. package/package.json +3 -3
@@ -1,11 +1,13 @@
1
- import { RsRefForwardingComponent, WithAsProps } from '../@types/common';
1
+ import { Offset, RsRefForwardingComponent, WithAsProps } from '../@types/common';
2
2
  export interface AffixProps extends WithAsProps {
3
+ /** Specify the container. */
4
+ container?: HTMLElement | (() => HTMLElement);
3
5
  /** Distance from top */
4
6
  top?: number;
5
7
  /** Callback after the state changes. */
6
8
  onChange?: (fixed?: boolean) => void;
7
- /** Specify the container. */
8
- container?: HTMLElement | (() => HTMLElement);
9
+ /** Callback after the offset changes. */
10
+ onOffsetChange?: (offset?: Offset) => void;
9
11
  }
10
12
  declare const Affix: RsRefForwardingComponent<'div', AffixProps>;
11
13
  export default Affix;
@@ -2,20 +2,33 @@ import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
3
  import React, { useCallback, useEffect, useRef, useState } from 'react';
4
4
  import PropTypes from 'prop-types';
5
+ import debounce from 'lodash/debounce';
5
6
  import getOffset from 'dom-lib/getOffset';
6
7
  import { mergeRefs, useClassNames, useElementResize, useEventListener, useMount } from '../utils';
7
8
 
8
9
  /**
9
10
  * Get the layout size and offset of the mount element
10
11
  */
11
- function useOffset(mountRef) {
12
+ function useOffset(mountRef, onOffsetChange) {
12
13
  var _useState = useState(null),
13
14
  offset = _useState[0],
14
15
  setOffset = _useState[1];
15
16
 
16
17
  var updateOffset = useCallback(function () {
17
- setOffset(getOffset(mountRef.current));
18
- }, [mountRef]); // Update after the element size changes
18
+ if (!mountRef.current) {
19
+ return;
20
+ }
21
+
22
+ var newOffset = getOffset(mountRef.current);
23
+
24
+ if ((newOffset === null || newOffset === void 0 ? void 0 : newOffset.height) !== (offset === null || offset === void 0 ? void 0 : offset.height) || (newOffset === null || newOffset === void 0 ? void 0 : newOffset.width) !== (offset === null || offset === void 0 ? void 0 : offset.width) || (newOffset === null || newOffset === void 0 ? void 0 : newOffset.top) !== (offset === null || offset === void 0 ? void 0 : offset.top) || (newOffset === null || newOffset === void 0 ? void 0 : newOffset.left) !== (offset === null || offset === void 0 ? void 0 : offset.left)) {
25
+ setOffset(newOffset);
26
+
27
+ if (offset !== null && newOffset !== null) {
28
+ onOffsetChange === null || onOffsetChange === void 0 ? void 0 : onOffsetChange(newOffset);
29
+ }
30
+ }
31
+ }, [mountRef, offset, onOffsetChange]); // Update after the element size changes
19
32
 
20
33
  useElementResize(function () {
21
34
  return mountRef.current;
@@ -23,7 +36,9 @@ function useOffset(mountRef) {
23
36
 
24
37
  useMount(updateOffset); // Update after window size changes
25
38
 
26
- useEventListener(window, 'resize', updateOffset, false);
39
+ useEventListener(window, 'resize', updateOffset, false); // Update after window scroll
40
+
41
+ useEventListener(window, 'scroll', debounce(updateOffset, 100), false);
27
42
  return offset;
28
43
  }
29
44
  /**
@@ -66,7 +81,7 @@ function useFixed(offset, containerOffset, props) {
66
81
 
67
82
  var scrollY = window.scrollY || window.pageYOffset; // When the scroll distance exceeds the element's top value, it is fixed.
68
83
 
69
- var nextFixed = scrollY - (Number(offset.top) - Number(top)) >= 0; // If the current element is specified in the container,
84
+ var nextFixed = scrollY - (Number(offset === null || offset === void 0 ? void 0 : offset.top) - Number(top)) >= 0; // If the current element is specified in the container,
70
85
  // add to determine whether the current container is in the window range.
71
86
 
72
87
  if (containerOffset) {
@@ -77,7 +92,7 @@ function useFixed(offset, containerOffset, props) {
77
92
  setFixed(nextFixed);
78
93
  onChange === null || onChange === void 0 ? void 0 : onChange(nextFixed);
79
94
  }
80
- }, [fixed, offset, containerOffset, onChange, top]); // Add scroll event to window
95
+ }, [offset, top, containerOffset, fixed, onChange]); // Add scroll event to window
81
96
 
82
97
  useEventListener(window, 'scroll', handleScroll, false);
83
98
  return fixed;
@@ -96,10 +111,11 @@ var Affix = /*#__PURE__*/React.forwardRef(function (props, ref) {
96
111
  _props$top = props.top,
97
112
  top = _props$top === void 0 ? 0 : _props$top,
98
113
  onChange = props.onChange,
99
- rest = _objectWithoutPropertiesLoose(props, ["as", "classPrefix", "className", "children", "container", "top", "onChange"]);
114
+ onOffsetChange = props.onOffsetChange,
115
+ rest = _objectWithoutPropertiesLoose(props, ["as", "classPrefix", "className", "children", "container", "top", "onChange", "onOffsetChange"]);
100
116
 
101
117
  var mountRef = useRef(null);
102
- var offset = useOffset(mountRef);
118
+ var offset = useOffset(mountRef, onOffsetChange);
103
119
  var containerOffset = useContainerOffset(container);
104
120
  var fixed = useFixed(offset, containerOffset, {
105
121
  top: top,
@@ -111,14 +127,19 @@ var Affix = /*#__PURE__*/React.forwardRef(function (props, ref) {
111
127
  merge = _useClassNames.merge;
112
128
 
113
129
  var classes = merge(className, (_merge = {}, _merge[withClassPrefix()] = fixed, _merge));
130
+
131
+ var _ref = offset || {},
132
+ width = _ref.width,
133
+ height = _ref.height;
134
+
114
135
  var placeholderStyles = fixed ? {
115
- width: offset === null || offset === void 0 ? void 0 : offset.width,
116
- height: offset === null || offset === void 0 ? void 0 : offset.height
136
+ width: width,
137
+ height: height
117
138
  } : undefined;
118
139
  var fixedStyles = {
119
140
  position: 'fixed',
120
141
  top: top,
121
- width: offset === null || offset === void 0 ? void 0 : offset.width,
142
+ width: width,
122
143
  zIndex: 10
123
144
  };
124
145
  var affixStyles = fixed ? fixedStyles : undefined;
@@ -17,6 +17,8 @@ export interface AutoCompleteProps<T = ValueType> extends WithAsProps, FormContr
17
17
  placeholder?: string;
18
18
  /** The width of the menu will automatically follow the width of the input box */
19
19
  menuAutoWidth?: boolean;
20
+ /** AutoComplete Content */
21
+ autoComplete?: string;
20
22
  /** Custom filter function to determine whether the item will be displayed */
21
23
  filterBy?: (value: string, item: ItemDataType) => boolean;
22
24
  /** Called when a option is selected */
@@ -33,14 +33,45 @@ export interface DatePickerProps extends PickerBaseProps<DatePickerLocale>, Form
33
33
  * Whether to disable a date on the calendar view
34
34
  *
35
35
  * @returns date should be disabled (not selectable)
36
+ * @deprecated Use {@link shouldDisableDate} instead
36
37
  */
37
38
  disabledDate?: (date?: Date) => boolean;
38
- /** Disabled hours */
39
+ /**
40
+ * Disabled hours
41
+ *
42
+ * @deprecated Use {@link shouldDisableHour} instead
43
+ */
39
44
  disabledHours?: (hour: number, date: Date) => boolean;
40
- /** Disabled minutes */
45
+ /**
46
+ * Disabled minutes
47
+ *
48
+ * @deprecated Use {@link shouldDisableMinute} instead
49
+ */
41
50
  disabledMinutes?: (minute: number, date: Date) => boolean;
42
- /** Disabled seconds */
51
+ /**
52
+ * Disabled seconds
53
+ *
54
+ * @deprecated Use {@link shouldDisableSecond} instead
55
+ */
43
56
  disabledSeconds?: (second: number, date: Date) => boolean;
57
+ /**
58
+ * Whether a date on the calendar view should be disabled
59
+ *
60
+ * @returns date should be disabled (not selectable)
61
+ */
62
+ shouldDisableDate?: (date: Date) => boolean;
63
+ /**
64
+ * Disabled hours
65
+ */
66
+ shouldDisableHour?: (hour: number, date: Date) => boolean;
67
+ /**
68
+ * Disabled minutes
69
+ */
70
+ shouldDisableMinute?: (minute: number, date: Date) => boolean;
71
+ /**
72
+ * Disabled seconds
73
+ */
74
+ shouldDisableSecond?: (second: number, date: Date) => boolean;
44
75
  /** Hidden hours */
45
76
  hideHours?: (hour: number, date: Date) => boolean;
46
77
  /** Hidden minutes */
@@ -16,6 +16,7 @@ import PredefinedRanges from './PredefinedRanges';
16
16
  import { composeFunctions, createChainedFunction, DateUtils, mergeRefs, useClassNames, useControlled, useCustom } from '../utils';
17
17
  import { PickerOverlay, pickerPropTypes, PickerToggle, PickerToggleTrigger, pickTriggerPropKeys, omitTriggerPropKeys, usePickerClassName, usePublicMethods, useToggleKeyDownEvent } from '../Picker';
18
18
  import { OverlayCloseCause } from '../Overlay/OverlayTrigger';
19
+ import { deprecatePropTypeNew } from '../utils/deprecatePropType';
19
20
  var DatePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
20
21
  var _props$as = props.as,
21
22
  Component = _props$as === void 0 ? 'div' : _props$as,
@@ -50,7 +51,14 @@ var DatePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
50
51
  style = props.style,
51
52
  toggleAs = props.toggleAs,
52
53
  caretAsProp = props.caretAs,
53
- disabledDateProp = props.disabledDate,
54
+ DEPRECATED_disabledDate = props.disabledDate,
55
+ DEPRECATED_disabledHours = props.disabledHours,
56
+ DEPRECATED_disabledMinutes = props.disabledMinutes,
57
+ DEPRECATED_disabledSeconds = props.disabledSeconds,
58
+ shouldDisableDate = props.shouldDisableDate,
59
+ shouldDisableHour = props.shouldDisableHour,
60
+ shouldDisableMinute = props.shouldDisableMinute,
61
+ shouldDisableSecond = props.shouldDisableSecond,
54
62
  renderValue = props.renderValue,
55
63
  onChange = props.onChange,
56
64
  onChangeCalendarDate = props.onChangeCalendarDate,
@@ -65,7 +73,7 @@ var DatePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
65
73
  onSelect = props.onSelect,
66
74
  onToggleMonthDropdown = props.onToggleMonthDropdown,
67
75
  onToggleTimeDropdown = props.onToggleTimeDropdown,
68
- rest = _objectWithoutPropertiesLoose(props, ["as", "className", "classPrefix", "calendarDefaultDate", "cleanable", "editable", "defaultValue", "disabled", "format", "isoWeek", "limitEndYear", "locale", "menuClassName", "appearance", "placement", "oneTap", "placeholder", "ranges", "value", "showMeridian", "showWeekNumbers", "style", "toggleAs", "caretAs", "disabledDate", "renderValue", "onChange", "onChangeCalendarDate", "onClean", "onClose", "onEntered", "onExited", "onNextMonth", "onOk", "onOpen", "onPrevMonth", "onSelect", "onToggleMonthDropdown", "onToggleTimeDropdown"]);
76
+ rest = _objectWithoutPropertiesLoose(props, ["as", "className", "classPrefix", "calendarDefaultDate", "cleanable", "editable", "defaultValue", "disabled", "format", "isoWeek", "limitEndYear", "locale", "menuClassName", "appearance", "placement", "oneTap", "placeholder", "ranges", "value", "showMeridian", "showWeekNumbers", "style", "toggleAs", "caretAs", "disabledDate", "disabledHours", "disabledMinutes", "disabledSeconds", "shouldDisableDate", "shouldDisableHour", "shouldDisableMinute", "shouldDisableSecond", "renderValue", "onChange", "onChangeCalendarDate", "onClean", "onClose", "onEntered", "onExited", "onNextMonth", "onOk", "onOpen", "onPrevMonth", "onSelect", "onToggleMonthDropdown", "onToggleTimeDropdown"]);
69
77
 
70
78
  var _useCustom = useCustom('DatePicker', overrideLocale),
71
79
  locale = _useCustom.locale,
@@ -241,11 +249,17 @@ var DatePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
241
249
  updateValue(event, nextPageDate);
242
250
  }
243
251
  }, [formatStr, handleDateChange, oneTap, setCalendarDate, updateValue]);
244
- var disabledDate = useCallback(function (date) {
245
- var _disabledDateProp;
252
+ var isDateDisabled = useCallback(function (date) {
253
+ if (typeof shouldDisableDate === 'function') {
254
+ return shouldDisableDate(date);
255
+ }
256
+
257
+ if (typeof DEPRECATED_disabledDate === 'function') {
258
+ return DEPRECATED_disabledDate(date);
259
+ }
246
260
 
247
- return (_disabledDateProp = disabledDateProp === null || disabledDateProp === void 0 ? void 0 : disabledDateProp(date)) !== null && _disabledDateProp !== void 0 ? _disabledDateProp : false;
248
- }, [disabledDateProp]);
261
+ return false;
262
+ }, [DEPRECATED_disabledDate, shouldDisableDate]);
249
263
  /**
250
264
  * Callback after the input box value is changed.
251
265
  */
@@ -272,13 +286,13 @@ var DatePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
272
286
  return;
273
287
  }
274
288
 
275
- if (disabledDate(date)) {
289
+ if (isDateDisabled(date)) {
276
290
  setInputState('Error');
277
291
  return;
278
292
  }
279
293
 
280
294
  handleSelect(date, event, false);
281
- }, [formatStr, locale, parseDate, disabledDate, handleSelect]);
295
+ }, [formatStr, locale, parseDate, isDateDisabled, handleSelect]);
282
296
  /**
283
297
  * The callback after the enter key is triggered on the input
284
298
  */
@@ -300,12 +314,12 @@ var DatePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
300
314
  }, [onClose]); // Check whether the time is within the time range of the shortcut option in the toolbar.
301
315
 
302
316
  var disabledToolbarHandle = useCallback(function (date) {
303
- var _disabledDateProp2;
317
+ var _DEPRECATED_disabledD;
304
318
 
305
- var allowDate = (_disabledDateProp2 = disabledDateProp === null || disabledDateProp === void 0 ? void 0 : disabledDateProp(date)) !== null && _disabledDateProp2 !== void 0 ? _disabledDateProp2 : false;
319
+ var allowDate = (_DEPRECATED_disabledD = DEPRECATED_disabledDate === null || DEPRECATED_disabledDate === void 0 ? void 0 : DEPRECATED_disabledDate(date)) !== null && _DEPRECATED_disabledD !== void 0 ? _DEPRECATED_disabledD : false;
306
320
  var allowTime = DateUtils.disabledTime(props, date);
307
321
  return allowDate || allowTime;
308
- }, [disabledDateProp, props]);
322
+ }, [DEPRECATED_disabledDate, props]);
309
323
  /**
310
324
  * Whether "OK" button is disabled
311
325
  *
@@ -336,7 +350,10 @@ var DatePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
336
350
  locale: locale,
337
351
  showWeekNumbers: showWeekNumbers,
338
352
  showMeridian: showMeridian,
339
- disabledDate: disabledDate,
353
+ disabledDate: isDateDisabled,
354
+ disabledHours: shouldDisableHour !== null && shouldDisableHour !== void 0 ? shouldDisableHour : DEPRECATED_disabledHours,
355
+ disabledMinutes: shouldDisableMinute !== null && shouldDisableMinute !== void 0 ? shouldDisableMinute : DEPRECATED_disabledMinutes,
356
+ disabledSeconds: shouldDisableSecond !== null && shouldDisableSecond !== void 0 ? shouldDisableSecond : DEPRECATED_disabledSeconds,
340
357
  limitEndYear: limitEndYear,
341
358
  format: formatStr,
342
359
  isoWeek: isoWeek,
@@ -468,10 +485,14 @@ DatePicker.displayName = 'DatePicker';
468
485
  DatePicker.propTypes = _extends({}, pickerPropTypes, {
469
486
  calendarDefaultDate: PropTypes.instanceOf(Date),
470
487
  defaultValue: PropTypes.instanceOf(Date),
471
- disabledDate: PropTypes.func,
472
- disabledHours: PropTypes.func,
473
- disabledMinutes: PropTypes.func,
474
- disabledSeconds: PropTypes.func,
488
+ disabledDate: deprecatePropTypeNew(PropTypes.func, 'Use "shouldDisableDate" property instead.'),
489
+ disabledHours: deprecatePropTypeNew(PropTypes.func, 'Use "shouldDisableHour" property instead.'),
490
+ disabledMinutes: deprecatePropTypeNew(PropTypes.func, 'Use "shouldDisableMinute" property instead.'),
491
+ disabledSeconds: deprecatePropTypeNew(PropTypes.func, 'Use "shouldDisableSecond" property instead.'),
492
+ shouldDisableDate: PropTypes.func,
493
+ shouldDisableHour: PropTypes.func,
494
+ shouldDisableMinute: PropTypes.func,
495
+ shouldDisableSecond: PropTypes.func,
475
496
  format: PropTypes.string,
476
497
  hideHours: PropTypes.func,
477
498
  hideMinutes: PropTypes.func,
@@ -27,8 +27,16 @@ export interface DateRangePickerProps extends PickerBaseProps, FormControlBasePr
27
27
  defaultCalendarValue?: DateRange;
28
28
  /** The character that separates two dates */
29
29
  character?: string;
30
- /** Disabled date */
30
+ /**
31
+ * Disabled date
32
+ *
33
+ * @deprecated Use {@link shouldDisableDate} instead
34
+ */
31
35
  disabledDate?: DisabledDateFunction;
36
+ /**
37
+ * Whether a date cell is disabled
38
+ */
39
+ shouldDisableDate?: DisabledDateFunction;
32
40
  /** Called when the option is selected */
33
41
  onSelect?: (date: Date, event?: React.SyntheticEvent) => void;
34
42
  /** Called after clicking the OK button */
@@ -17,6 +17,7 @@ import { addMonths, compareAsc, isSameMonth, startOfDay, endOfDay, shouldRenderT
17
17
  import Calendar from './Calendar';
18
18
  import * as disabledDateUtils from './disabledDateUtils';
19
19
  import { getSafeCalendarDate, getMonthHoverRange, getWeekHoverRange, isSameRange } from './utils';
20
+ import { deprecatePropTypeNew } from '../utils/deprecatePropType';
20
21
  var DateRangePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
21
22
  var _ref, _ref2, _merge;
22
23
 
@@ -36,7 +37,8 @@ var DateRangePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
36
37
  defaultCalendarValue = props.defaultCalendarValue,
37
38
  defaultValue = props.defaultValue,
38
39
  disabled = props.disabled,
39
- disabledDateProp = props.disabledDate,
40
+ DEPRECATED_disabledDateProp = props.disabledDate,
41
+ shouldDisableDate = props.shouldDisableDate,
40
42
  _props$format = props.format,
41
43
  formatStr = _props$format === void 0 ? 'yyyy-MM-dd' : _props$format,
42
44
  hoverRange = props.hoverRange,
@@ -72,7 +74,7 @@ var DateRangePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
72
74
  onOpen = props.onOpen,
73
75
  onSelect = props.onSelect,
74
76
  renderTitle = props.renderTitle,
75
- rest = _objectWithoutPropertiesLoose(props, ["as", "classPrefix", "className", "appearance", "editable", "cleanable", "character", "defaultCalendarValue", "defaultValue", "disabled", "disabledDate", "format", "hoverRange", "isoWeek", "limitEndYear", "locale", "menuClassName", "menuStyle", "oneTap", "placeholder", "placement", "ranges", "renderValue", "showOneCalendar", "showWeekNumbers", "showMeridian", "style", "toggleAs", "caretAs", "value", "onChange", "onClean", "onClose", "onEnter", "onEntered", "onExited", "onOk", "onOpen", "onSelect", "renderTitle"]);
77
+ rest = _objectWithoutPropertiesLoose(props, ["as", "classPrefix", "className", "appearance", "editable", "cleanable", "character", "defaultCalendarValue", "defaultValue", "disabled", "disabledDate", "shouldDisableDate", "format", "hoverRange", "isoWeek", "limitEndYear", "locale", "menuClassName", "menuStyle", "oneTap", "placeholder", "placement", "ranges", "renderValue", "showOneCalendar", "showWeekNumbers", "showMeridian", "style", "toggleAs", "caretAs", "value", "onChange", "onClean", "onClose", "onEnter", "onEntered", "onExited", "onOk", "onOpen", "onSelect", "renderTitle"]);
76
78
 
77
79
  var _useClassNames = useClassNames(classPrefix),
78
80
  merge = _useClassNames.merge,
@@ -536,10 +538,16 @@ var DateRangePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
536
538
  onClose === null || onClose === void 0 ? void 0 : onClose();
537
539
  }, [onClose]);
538
540
  var isDateDisabled = useCallback(function (date, selectDate, selectedDone, target) {
539
- var _disabledDateProp;
541
+ if (typeof shouldDisableDate === 'function') {
542
+ return shouldDisableDate(date, selectDate, selectedDone, target);
543
+ }
544
+
545
+ if (typeof DEPRECATED_disabledDateProp === 'function') {
546
+ return DEPRECATED_disabledDateProp(date, selectDate, selectedDone, target);
547
+ }
540
548
 
541
- return (_disabledDateProp = disabledDateProp === null || disabledDateProp === void 0 ? void 0 : disabledDateProp(date, selectDate, selectedDone, target)) !== null && _disabledDateProp !== void 0 ? _disabledDateProp : false;
542
- }, [disabledDateProp]);
549
+ return false;
550
+ }, [DEPRECATED_disabledDateProp, shouldDisableDate]);
543
551
  var disabledByBetween = useCallback(function (start, end, type) {
544
552
  // If the date is between the start and the end
545
553
  // the button is disabled
@@ -733,7 +741,8 @@ DateRangePicker.propTypes = _extends({}, pickerPropTypes, {
733
741
  limitEndYear: PropTypes.number,
734
742
  onChange: PropTypes.func,
735
743
  onOk: PropTypes.func,
736
- disabledDate: PropTypes.func,
744
+ disabledDate: deprecatePropTypeNew(PropTypes.func, 'Use "shouldDisableDate" property instead.'),
745
+ shouldDisableDate: PropTypes.func,
737
746
  onSelect: PropTypes.func,
738
747
  showWeekNumbers: PropTypes.bool,
739
748
  showMeridian: PropTypes.bool,
@@ -164,7 +164,7 @@ var FormControl = /*#__PURE__*/React.forwardRef(function (props, ref) {
164
164
  "aria-describedby": ariaDescribedby,
165
165
  "aria-invalid": fieldHasError || undefined,
166
166
  "aria-errormessage": ariaErrormessage
167
- }, rest, accepterProps, {
167
+ }, accepterProps, rest, {
168
168
  readOnly: readOnly,
169
169
  plaintext: plaintext,
170
170
  disabled: disabled,
@@ -4,7 +4,6 @@ import React, { useRef, useEffect, useState, useCallback, useMemo } from 'react'
4
4
  import PropTypes from 'prop-types';
5
5
  import classNames from 'classnames';
6
6
  import contains from 'dom-lib/contains';
7
- import getContainer from 'dom-lib/getContainer';
8
7
  import on from 'dom-lib/on';
9
8
  import ModalManager from './ModalManager';
10
9
  import Fade from '../Animation/Fade';
@@ -90,7 +89,8 @@ var Modal = /*#__PURE__*/React.forwardRef(function (props, ref) {
90
89
  var _usePortal = usePortal({
91
90
  container: container
92
91
  }),
93
- Portal = _usePortal.Portal;
92
+ Portal = _usePortal.Portal,
93
+ containerElement = _usePortal.target;
94
94
 
95
95
  var modal = useModalManager();
96
96
 
@@ -141,8 +141,9 @@ var Modal = /*#__PURE__*/React.forwardRef(function (props, ref) {
141
141
  var documentKeyDownListener = useRef();
142
142
  var documentFocusListener = useRef();
143
143
  var handleOpen = useEventCallback(function () {
144
- var containerElement = getContainer(container, document.body);
145
- modal.add(containerElement, containerClassName);
144
+ if (containerElement) {
145
+ modal.add(containerElement, containerClassName);
146
+ }
146
147
 
147
148
  if (!documentKeyDownListener.current) {
148
149
  documentKeyDownListener.current = on(document, 'keydown', handleDocumentKeyDown);
@@ -98,7 +98,8 @@ var OverlayTrigger = /*#__PURE__*/React.forwardRef(function (props, ref) {
98
98
  var _usePortal = usePortal({
99
99
  container: container
100
100
  }),
101
- Portal = _usePortal.Portal;
101
+ Portal = _usePortal.Portal,
102
+ containerElement = _usePortal.target;
102
103
 
103
104
  var triggerRef = useRef();
104
105
  var overlayRef = useRef();
@@ -345,7 +346,7 @@ var OverlayTrigger = /*#__PURE__*/React.forwardRef(function (props, ref) {
345
346
  }) : undefined,
346
347
  onExited: createChainedFunction(followCursor ? handleExited : undefined, onExited),
347
348
  placement: placement,
348
- container: container,
349
+ container: containerElement,
349
350
  open: open
350
351
  });
351
352
 
@@ -1,25 +1,15 @@
1
1
  import React from 'react';
2
- import { Column, Cell, HeaderCell, ColumnGroup, TableProps } from 'rsuite-table';
3
- import { StandardProps, RsRefForwardingComponent } from '../@types/common';
4
- export interface TableInstance extends React.Component<TableProps> {
5
- scrollTop: (top: number) => void;
6
- scrollLeft: (left: number) => void;
7
- }
8
- export interface CellProps<T = any> extends StandardProps {
2
+ import { Column, TableProps, RowDataType, TableInstance, CellProps as TableCellProps } from 'rsuite-table';
3
+ export interface CellProps<T = any> extends Omit<TableCellProps, 'rowData' | 'dataKey'> {
9
4
  /** Data binding key, but also a sort of key */
10
5
  dataKey?: string | keyof T;
11
- /** Row Number */
12
- rowIndex?: number;
13
6
  /** Row Data */
14
7
  rowData?: T;
15
8
  }
16
- interface TableComponent extends RsRefForwardingComponent<'div', TableProps & {
17
- ref?: React.Ref<TableInstance>;
18
- }> {
9
+ declare const _default: (<Row extends RowDataType, 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>>;
19
11
  Column: typeof Column;
20
- Cell: typeof Cell;
21
- HeaderCell: typeof HeaderCell;
22
- ColumnGroup: typeof ColumnGroup;
23
- }
24
- declare const Table: TableComponent;
25
- export default Table;
12
+ HeaderCell: React.ForwardRefExoticComponent<import("rsuite-table").HeaderCellProps & React.RefAttributes<HTMLDivElement>>;
13
+ ColumnGroup: React.ForwardRefExoticComponent<import("rsuite-table").ColumnGroupProps & React.RefAttributes<HTMLDivElement>>;
14
+ };
15
+ export default _default;
@@ -1,9 +1,9 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
3
  import React from 'react';
4
- import { Table as RsTable, Column, Cell, HeaderCell, ColumnGroup } from 'rsuite-table';
4
+ import { Table, Column, Cell, HeaderCell, ColumnGroup } from 'rsuite-table';
5
5
  import { useCustom } from '../utils';
6
- var Table = /*#__PURE__*/React.forwardRef(function (props, ref) {
6
+ var CustomTable = /*#__PURE__*/React.forwardRef(function (props, ref) {
7
7
  var localeProp = props.locale,
8
8
  _props$loadAnimation = props.loadAnimation,
9
9
  loadAnimation = _props$loadAnimation === void 0 ? true : _props$loadAnimation,
@@ -13,16 +13,16 @@ var Table = /*#__PURE__*/React.forwardRef(function (props, ref) {
13
13
  locale = _useCustom.locale,
14
14
  rtl = _useCustom.rtl;
15
15
 
16
- return /*#__PURE__*/React.createElement(RsTable, _extends({}, rest, {
16
+ return /*#__PURE__*/React.createElement(Table, _extends({}, rest, {
17
17
  rtl: rtl,
18
18
  ref: ref,
19
19
  locale: locale,
20
20
  loadAnimation: loadAnimation
21
21
  }));
22
22
  });
23
- Table.Cell = Cell;
24
- Table.Column = Column;
25
- Table.HeaderCell = HeaderCell;
26
- Table.ColumnGroup = ColumnGroup;
27
- Table.displayName = 'Table';
28
- export default Table;
23
+ export default Object.assign(CustomTable, {
24
+ Cell: Cell,
25
+ Column: Column,
26
+ HeaderCell: HeaderCell,
27
+ ColumnGroup: ColumnGroup
28
+ });
@@ -1,4 +1,4 @@
1
1
  import Table from './Table';
2
- export type { TableProps, ColumnProps, ColumnGroupProps, TableLocaleType } from 'rsuite-table';
3
- export type { TableInstance, CellProps } from './Table';
2
+ export type { TableProps, ColumnProps, ColumnGroupProps, HeaderCellProps, SortType, RowDataType, RowKeyType, TableLocaleType, TableSizeChangeEventName, TableInstance } from 'rsuite-table';
3
+ export type { CellProps } from './Table';
4
4
  export default Table;
@@ -41,6 +41,7 @@ export declare type CalendarOnlyPropsType = 'disabledHours' | 'disabledMinutes'
41
41
  export declare const calendarOnlyProps: CalendarOnlyPropsType[];
42
42
  /**
43
43
  * Verify that the time is valid.
44
+ *
44
45
  * @param props
45
46
  * @param date
46
47
  */
@@ -57,15 +57,21 @@ function validTime(calendarProps, date) {
57
57
 
58
58
  return Object.keys(calendarProps).some(function (key) {
59
59
  if (/(Hours)/.test(key)) {
60
- return calendarProps[key](getHours(date), date);
60
+ var _calendarProps$key, _calendarProps$key2;
61
+
62
+ return (_calendarProps$key = (_calendarProps$key2 = calendarProps[key]) === null || _calendarProps$key2 === void 0 ? void 0 : _calendarProps$key2.call(calendarProps, getHours(date), date)) !== null && _calendarProps$key !== void 0 ? _calendarProps$key : true;
61
63
  }
62
64
 
63
65
  if (/(Minutes)/.test(key)) {
64
- return calendarProps[key](getMinutes(date), date);
66
+ var _calendarProps$key3, _calendarProps$key4;
67
+
68
+ return (_calendarProps$key3 = (_calendarProps$key4 = calendarProps[key]) === null || _calendarProps$key4 === void 0 ? void 0 : _calendarProps$key4.call(calendarProps, getMinutes(date), date)) !== null && _calendarProps$key3 !== void 0 ? _calendarProps$key3 : true;
65
69
  }
66
70
 
67
71
  if (/(Seconds)/.test(key)) {
68
- return calendarProps[key](getSeconds(date), date);
72
+ var _calendarProps$key5, _calendarProps$key6;
73
+
74
+ return (_calendarProps$key5 = (_calendarProps$key6 = calendarProps[key]) === null || _calendarProps$key6 === void 0 ? void 0 : _calendarProps$key6.call(calendarProps, getSeconds(date), date)) !== null && _calendarProps$key5 !== void 0 ? _calendarProps$key5 : true;
69
75
  }
70
76
 
71
77
  return false;
@@ -73,6 +79,7 @@ function validTime(calendarProps, date) {
73
79
  }
74
80
  /**
75
81
  * Verify that the time is valid.
82
+ *
76
83
  * @param props
77
84
  * @param date
78
85
  */
@@ -7,5 +7,10 @@ import * as PropTypes from 'prop-types';
7
7
  export default function deprecatePropType<T extends PropTypes.Validator<any>>(propType: T, explanation?: string): typeof propType;
8
8
  /**
9
9
  * Prints deprecation message when user uses a deprecated prop
10
+ *
11
+ * @example
12
+ *
13
+ * deprecatePropTypeNew(PropTypes.bool, 'Use Dropdown.Separator component instead.')
14
+ *
10
15
  */
11
16
  export declare function deprecatePropTypeNew<T extends PropTypes.Validator<any>>(propType: T, explanation?: string): typeof propType;
@@ -23,6 +23,11 @@ export default function deprecatePropType(propType, explanation) {
23
23
  }
24
24
  /**
25
25
  * Prints deprecation message when user uses a deprecated prop
26
+ *
27
+ * @example
28
+ *
29
+ * deprecatePropTypeNew(PropTypes.bool, 'Use Dropdown.Separator component instead.')
30
+ *
26
31
  */
27
32
 
28
33
  export function deprecatePropTypeNew(propType, explanation) {
@@ -1,5 +1,5 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
- import React, { useRef, useEffect, useState, useCallback } from 'react';
2
+ import React, { useEffect, useState, useCallback, useMemo } from 'react';
3
3
  import { createPortal } from 'react-dom';
4
4
  import canUseDOM from 'dom-lib/canUseDOM';
5
5
  var MountedPortal = /*#__PURE__*/React.memo(function (_ref) {
@@ -30,24 +30,21 @@ function usePortal(props) {
30
30
  container = _props.container,
31
31
  _props$waitMount = _props.waitMount,
32
32
  waitMount = _props$waitMount === void 0 ? false : _props$waitMount;
33
- var rootElemRef = useRef(canUseDOM ? document.body : null);
34
- useEffect(function () {
35
- var containerElement = typeof container === 'function' ? container() : container; // Parent is either a new root or the existing dom element
36
-
37
- var parentElement = containerElement || document.body;
38
- rootElemRef.current = parentElement;
39
- }, [rootElemRef, container]);
33
+ var containerElement = typeof container === 'function' ? container() : container;
34
+ var rootElement = useMemo(function () {
35
+ return canUseDOM ? containerElement || document.body : null;
36
+ }, [containerElement]);
40
37
  var Portal = useCallback(function (_ref2) {
41
38
  var children = _ref2.children;
42
- return rootElemRef.current != null ? /*#__PURE__*/createPortal(children, rootElemRef.current) : null;
43
- }, []);
39
+ return rootElement != null ? /*#__PURE__*/createPortal(children, rootElement) : null;
40
+ }, [rootElement]);
44
41
  var WaitMountPortal = useCallback(function (props) {
45
42
  return /*#__PURE__*/React.createElement(MountedPortal, _extends({
46
- container: rootElemRef.current
43
+ container: rootElement
47
44
  }, props));
48
- }, []);
45
+ }, [rootElement]);
49
46
  return {
50
- target: rootElemRef.current,
47
+ target: rootElement,
51
48
  Portal: waitMount ? WaitMountPortal : Portal
52
49
  };
53
50
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rsuite",
3
- "version": "5.28.2",
3
+ "version": "5.29.0",
4
4
  "description": "A suite of react components",
5
5
  "main": "cjs/index.js",
6
6
  "module": "esm/index.js",
@@ -37,8 +37,8 @@
37
37
  "lodash": "^4.17.11",
38
38
  "prop-types": "^15.8.1",
39
39
  "react-window": "^1.8.8",
40
- "rsuite-table": "^5.9.0",
41
- "schema-typed": "^2.1.0"
40
+ "rsuite-table": "^5.10.1",
41
+ "schema-typed": "^2.1.2"
42
42
  },
43
43
  "peerDependencies": {
44
44
  "react": ">=16.8.0",