rsuite 5.44.0 → 5.46.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 (81) hide show
  1. package/Button/styles/index.less +1 -1
  2. package/CHANGELOG.md +25 -0
  3. package/DatePicker/styles/index.less +15 -0
  4. package/Drawer/styles/index.less +1 -1
  5. package/Modal/styles/index.less +24 -2
  6. package/cjs/Calendar/MonthDropdown.js +1 -2
  7. package/cjs/Calendar/MonthDropdownItem.js +26 -13
  8. package/cjs/Calendar/TableCell.d.ts +14 -0
  9. package/cjs/Calendar/TableCell.js +72 -0
  10. package/cjs/Calendar/TableHeaderRow.js +3 -1
  11. package/cjs/Calendar/TableRow.js +22 -46
  12. package/cjs/Calendar/useCalendarDate.d.ts +1 -1
  13. package/cjs/Calendar/utils.d.ts +7 -0
  14. package/cjs/Calendar/utils.js +15 -0
  15. package/cjs/Cascader/Cascader.js +13 -3
  16. package/cjs/DatePicker/DatePicker.js +145 -38
  17. package/cjs/Drawer/Drawer.d.ts +2 -0
  18. package/cjs/Drawer/Drawer.js +16 -5
  19. package/cjs/Drawer/DrawerContext.d.ts +9 -0
  20. package/cjs/Drawer/DrawerContext.js +10 -0
  21. package/cjs/FormControl/FormControl.js +1 -1
  22. package/cjs/InputPicker/InputPicker.js +7 -4
  23. package/cjs/Modal/Modal.d.ts +2 -4
  24. package/cjs/Modal/Modal.js +24 -13
  25. package/cjs/Modal/ModalBody.js +14 -8
  26. package/cjs/Modal/ModalContext.d.ts +1 -3
  27. package/cjs/Modal/ModalHeader.js +9 -6
  28. package/cjs/Modal/index.d.ts +1 -0
  29. package/cjs/Modal/utils.d.ts +4 -1
  30. package/cjs/Modal/utils.js +9 -4
  31. package/cjs/Picker/PickerToggle.js +3 -0
  32. package/cjs/Picker/utils.js +21 -12
  33. package/cjs/Table/Table.d.ts +7 -7
  34. package/dist/rsuite-no-reset-rtl.css +141 -64
  35. package/dist/rsuite-no-reset-rtl.min.css +1 -1
  36. package/dist/rsuite-no-reset-rtl.min.css.map +1 -1
  37. package/dist/rsuite-no-reset.css +141 -64
  38. package/dist/rsuite-no-reset.min.css +1 -1
  39. package/dist/rsuite-no-reset.min.css.map +1 -1
  40. package/dist/rsuite-rtl.css +141 -64
  41. package/dist/rsuite-rtl.min.css +1 -1
  42. package/dist/rsuite-rtl.min.css.map +1 -1
  43. package/dist/rsuite.css +141 -64
  44. package/dist/rsuite.js +73 -19
  45. package/dist/rsuite.js.map +1 -1
  46. package/dist/rsuite.min.css +1 -1
  47. package/dist/rsuite.min.css.map +1 -1
  48. package/dist/rsuite.min.js +1 -1
  49. package/dist/rsuite.min.js.map +1 -1
  50. package/esm/Calendar/MonthDropdown.js +1 -2
  51. package/esm/Calendar/MonthDropdownItem.js +28 -15
  52. package/esm/Calendar/TableCell.d.ts +14 -0
  53. package/esm/Calendar/TableCell.js +66 -0
  54. package/esm/Calendar/TableHeaderRow.js +3 -1
  55. package/esm/Calendar/TableRow.js +23 -47
  56. package/esm/Calendar/useCalendarDate.d.ts +1 -1
  57. package/esm/Calendar/utils.d.ts +7 -0
  58. package/esm/Calendar/utils.js +12 -0
  59. package/esm/Cascader/Cascader.js +13 -3
  60. package/esm/DatePicker/DatePicker.js +147 -40
  61. package/esm/Drawer/Drawer.d.ts +2 -0
  62. package/esm/Drawer/Drawer.js +15 -5
  63. package/esm/Drawer/DrawerContext.d.ts +9 -0
  64. package/esm/Drawer/DrawerContext.js +4 -0
  65. package/esm/FormControl/FormControl.js +1 -1
  66. package/esm/InputPicker/InputPicker.js +7 -4
  67. package/esm/Modal/Modal.d.ts +2 -4
  68. package/esm/Modal/Modal.js +25 -14
  69. package/esm/Modal/ModalBody.js +14 -8
  70. package/esm/Modal/ModalContext.d.ts +1 -3
  71. package/esm/Modal/ModalHeader.js +9 -6
  72. package/esm/Modal/index.d.ts +1 -0
  73. package/esm/Modal/utils.d.ts +4 -1
  74. package/esm/Modal/utils.js +9 -4
  75. package/esm/Picker/PickerToggle.js +3 -0
  76. package/esm/Picker/utils.js +21 -12
  77. package/esm/Table/Table.d.ts +7 -7
  78. package/package.json +2 -2
  79. package/styles/color-modes/dark.less +0 -40
  80. package/styles/color-modes/high-contrast.less +0 -35
  81. package/styles/color-modes/light.less +0 -46
@@ -5,8 +5,6 @@ export interface ModalContextProps {
5
5
  /** Pass the close event callback to the header close button. */
6
6
  onModalClose?: (event: React.MouseEvent<Element, MouseEvent>) => void;
7
7
  /** Pass the latest style to body. */
8
- getBodyStyles?: () => React.CSSProperties;
9
- /** Whether this Modal is a Drawer */
10
- isDrawer: boolean;
8
+ getBodyStyles?: () => React.CSSProperties | null;
11
9
  }
12
10
  export declare const ModalContext: React.Context<ModalContextProps | null>;
@@ -14,7 +14,9 @@ var _ModalContext = require("./ModalContext");
14
14
  var _CloseButton = _interopRequireDefault(require("../CloseButton"));
15
15
  var _Close = _interopRequireDefault(require("@rsuite/icons/Close"));
16
16
  var _IconButton = _interopRequireDefault(require("../IconButton"));
17
+ var _DrawerContext = _interopRequireDefault(require("../Drawer/DrawerContext"));
17
18
  var ModalHeader = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
19
+ var _useContext, _useContext2;
18
20
  var _props$as = props.as,
19
21
  Component = _props$as === void 0 ? 'div' : _props$as,
20
22
  _props$classPrefix = props.classPrefix,
@@ -30,16 +32,17 @@ var ModalHeader = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
30
32
  withClassPrefix = _useClassNames.withClassPrefix,
31
33
  prefix = _useClassNames.prefix;
32
34
  var classes = merge(className, withClassPrefix());
33
- var context = (0, _react.useContext)(_ModalContext.ModalContext);
34
- var buttonElement = !(context !== null && context !== void 0 && context.isDrawer) ? /*#__PURE__*/_react.default.createElement(_CloseButton.default, {
35
- className: prefix('close'),
36
- onClick: (0, _utils.createChainedFunction)(onClose, context === null || context === void 0 ? void 0 : context.onModalClose)
37
- }) : /*#__PURE__*/_react.default.createElement(_IconButton.default, {
35
+ var onModalClose = (_useContext = (0, _react.useContext)(_ModalContext.ModalContext)) === null || _useContext === void 0 ? void 0 : _useContext.onModalClose;
36
+ var isDrawer = (_useContext2 = (0, _react.useContext)(_DrawerContext.default)) === null || _useContext2 === void 0 ? void 0 : _useContext2.isDrawer;
37
+ var buttonElement = isDrawer ? /*#__PURE__*/_react.default.createElement(_IconButton.default, {
38
38
  icon: /*#__PURE__*/_react.default.createElement(_Close.default, null),
39
39
  appearance: "subtle",
40
40
  size: "sm",
41
41
  className: prefix('close'),
42
- onClick: (0, _utils.createChainedFunction)(onClose, context === null || context === void 0 ? void 0 : context.onModalClose)
42
+ onClick: (0, _utils.createChainedFunction)(onClose, onModalClose)
43
+ }) : /*#__PURE__*/_react.default.createElement(_CloseButton.default, {
44
+ className: prefix('close'),
45
+ onClick: (0, _utils.createChainedFunction)(onClose, onModalClose)
43
46
  });
44
47
  return /*#__PURE__*/_react.default.createElement(Component, (0, _extends2.default)({}, rest, {
45
48
  ref: ref,
@@ -5,4 +5,5 @@ export type { ModalDialogProps } from './ModalDialog';
5
5
  export type { ModalFooterProps } from './ModalFooter';
6
6
  export type { ModalHeaderProps } from './ModalHeader';
7
7
  export type { ModalTitleProps } from './ModalTitle';
8
+ export type { ModalSize } from './utils';
8
9
  export default Modal;
@@ -1,6 +1,9 @@
1
1
  /// <reference types="react" />
2
+ import { TypeAttributes } from '../@types/common';
3
+ export declare type ModalSize = TypeAttributes.Size | 'full' | number | string;
2
4
  export declare const useBodyStyles: (ref: React.RefObject<HTMLElement>, options: {
3
5
  overflow: boolean;
4
6
  drawer: boolean;
7
+ size?: ModalSize | undefined;
5
8
  prefix: (...classes: any) => string;
6
- }) => [import("react").CSSProperties, (entering?: boolean) => void, () => void];
9
+ }) => [import("react").CSSProperties | null, (entering?: boolean) => void, () => void];
@@ -14,7 +14,8 @@ var useBodyStyles = function useBodyStyles(ref, options) {
14
14
  setBodyStyles = _useState[1];
15
15
  var overflow = options.overflow,
16
16
  drawer = options.drawer,
17
- prefix = options.prefix;
17
+ prefix = options.prefix,
18
+ size = options.size;
18
19
  var windowResizeListener = (0, _react.useRef)();
19
20
  var contentElement = (0, _react.useRef)(null);
20
21
  var contentElementResizeObserver = (0, _react.useRef)();
@@ -51,7 +52,11 @@ var useBodyStyles = function useBodyStyles(ref, options) {
51
52
  contentElementResizeObserver.current = null;
52
53
  }, []);
53
54
  var onChangeBodyStyles = (0, _react.useCallback)(function (entering) {
54
- if (overflow && !drawer && ref.current) {
55
+ if (drawer || size === 'full') {
56
+ setBodyStyles(null);
57
+ return;
58
+ }
59
+ if (overflow && ref.current) {
55
60
  updateBodyStyles(undefined, entering);
56
61
  contentElement.current = ref.current.querySelector("." + prefix('content'));
57
62
  if (!windowResizeListener.current) {
@@ -64,11 +69,11 @@ var useBodyStyles = function useBodyStyles(ref, options) {
64
69
  contentElementResizeObserver.current.observe(contentElement.current);
65
70
  }
66
71
  }
67
- }, [drawer, overflow, prefix, ref, updateBodyStyles]);
72
+ }, [drawer, overflow, prefix, ref, size, updateBodyStyles]);
68
73
  (0, _react.useEffect)(function () {
69
74
  return onDestroyEvents;
70
75
  // eslint-disable-next-line react-hooks/exhaustive-deps
71
76
  }, []);
72
- return [overflow ? bodyStyles : {}, onChangeBodyStyles, onDestroyEvents];
77
+ return [overflow ? bodyStyles : null, onChangeBodyStyles, onDestroyEvents];
73
78
  };
74
79
  exports.useBodyStyles = useBodyStyles;
@@ -148,6 +148,8 @@ var PickerToggle = /*#__PURE__*/_react.default.forwardRef(function (props, ref)
148
148
  }, [editable, onInputPressEnter, onInputBackspace]);
149
149
  var renderInput = (0, _react.useCallback)(function (ref, props) {
150
150
  return /*#__PURE__*/_react.default.createElement("input", (0, _extends2.default)({
151
+ type: "text",
152
+ autoComplete: "off",
151
153
  ref: (0, _utils.mergeRefs)(inputRef, ref),
152
154
  name: name,
153
155
  style: {
@@ -197,6 +199,7 @@ var PickerToggle = /*#__PURE__*/_react.default.forwardRef(function (props, ref)
197
199
  },
198
200
  "data-testid": "spinner"
199
201
  }) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_TextMask.default, {
202
+ keepCharPositions: true,
200
203
  mask: inputMask,
201
204
  value: Array.isArray(inputValue) ? inputValue.toString() : inputValue,
202
205
  onBlur: handleInputBlur,
@@ -194,6 +194,12 @@ var useFocusItemValue = function useFocusItemValue(defaultFocusItemValue, props)
194
194
  var _useState3 = (0, _react.useState)([]),
195
195
  keys = _useState3[0],
196
196
  setKeys = _useState3[1];
197
+ var focusCallback = (0, _react.useCallback)(function (value, event) {
198
+ var menu = (0, _isFunction.default)(target) ? target() : target;
199
+ var focusElement = menu === null || menu === void 0 ? void 0 : menu.querySelector("[data-key=\"" + value + "\"]");
200
+ focusElement === null || focusElement === void 0 ? void 0 : focusElement.focus();
201
+ callback === null || callback === void 0 ? void 0 : callback(value, event);
202
+ }, [callback, target]);
197
203
  var getScrollContainer = (0, _react.useCallback)(function () {
198
204
  var menu = (0, _isFunction.default)(target) ? target() : target;
199
205
 
@@ -279,11 +285,11 @@ var useFocusItemValue = function useFocusItemValue(defaultFocusItemValue, props)
279
285
  var focusItem = items[nextIndex];
280
286
  if (!(0, _isUndefined.default)(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('bottom', focusItem[valueKey], willOverflow);
284
290
  }
285
291
  });
286
- }, [callback, findFocusItemIndex, scrollListItem, valueKey]);
292
+ }, [focusCallback, findFocusItemIndex, scrollListItem, valueKey]);
287
293
  var focusPrevMenuItem = (0, _react.useCallback)(function (event) {
288
294
  findFocusItemIndex(function (items, index) {
289
295
  var willOverflow = index === 0;
@@ -291,11 +297,11 @@ var useFocusItemValue = function useFocusItemValue(defaultFocusItemValue, props)
291
297
  var focusItem = items[nextIndex];
292
298
  if (!(0, _isUndefined.default)(focusItem)) {
293
299
  setFocusItemValue(focusItem[valueKey]);
294
- callback === null || callback === void 0 ? void 0 : callback(focusItem[valueKey], event);
300
+ focusCallback(focusItem[valueKey], event);
295
301
  scrollListItem('top', focusItem[valueKey], willOverflow);
296
302
  }
297
303
  });
298
- }, [callback, findFocusItemIndex, scrollListItem, valueKey]);
304
+ }, [focusCallback, findFocusItemIndex, scrollListItem, valueKey]);
299
305
  var getSubMenuKeys = (0, _react.useCallback)(function (nextLayer) {
300
306
  var menu = (0, _isFunction.default)(target) ? target() : target;
301
307
  var subMenu = menu === null || menu === void 0 ? void 0 : menu.querySelector("[data-layer=\"" + nextLayer + "\"]");
@@ -315,9 +321,9 @@ var useFocusItemValue = function useFocusItemValue(defaultFocusItemValue, props)
315
321
  setKeys(nextKeys);
316
322
  setLayer(nextLayer);
317
323
  setFocusItemValue(nextKeys[0]);
318
- callback === null || callback === void 0 ? void 0 : callback(nextKeys[0], event);
324
+ focusCallback(nextKeys[0], event);
319
325
  }
320
- }, [callback, getSubMenuKeys, layer]);
326
+ }, [focusCallback, getSubMenuKeys, layer]);
321
327
  var focusPrevLevelMenu = (0, _react.useCallback)(function (event) {
322
328
  var nextLayer = layer - 1;
323
329
  var nextKeys = getSubMenuKeys(nextLayer);
@@ -331,10 +337,10 @@ var useFocusItemValue = function useFocusItemValue(defaultFocusItemValue, props)
331
337
  var parentItemValue = (_getParent = getParent(focusItem)) === null || _getParent === void 0 ? void 0 : _getParent[valueKey];
332
338
  if (parentItemValue) {
333
339
  setFocusItemValue(parentItemValue);
334
- callback === null || callback === void 0 ? void 0 : callback(parentItemValue, event);
340
+ focusCallback(parentItemValue, event);
335
341
  }
336
342
  }
337
- }, [callback, data, focusItemValue, getParent, getSubMenuKeys, layer, valueKey]);
343
+ }, [focusCallback, data, focusItemValue, getParent, getSubMenuKeys, layer, valueKey]);
338
344
  var handleKeyDown = (0, _react.useCallback)(function (event) {
339
345
  var _onMenuKeyDown;
340
346
  onMenuKeyDown(event, (_onMenuKeyDown = {
@@ -376,10 +382,13 @@ var useToggleKeyDownEvent = function useToggleKeyDownEvent(props) {
376
382
  onMenuPressEnter = props.onMenuPressEnter,
377
383
  onMenuPressBackspace = props.onMenuPressBackspace;
378
384
  var handleClose = (0, _react.useCallback)(function () {
379
- var _triggerRef$current, _triggerRef$current$c;
385
+ var _triggerRef$current, _triggerRef$current$c, _targetRef$current, _targetRef$current$fo;
380
386
  (_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);
387
+
388
+ // The focus is on the trigger button after closing
389
+ (_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);
381
390
  onClose === null || onClose === void 0 ? void 0 : onClose();
382
- }, [onClose, triggerRef]);
391
+ }, [onClose, targetRef, triggerRef]);
383
392
  var handleOpen = (0, _react.useCallback)(function () {
384
393
  var _triggerRef$current2, _triggerRef$current2$;
385
394
  (_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);
@@ -541,8 +550,8 @@ function usePublicMethods(ref, parmas) {
541
550
  return (_overlayRef$current = overlayRef === null || overlayRef === void 0 ? void 0 : overlayRef.current) !== null && _overlayRef$current !== void 0 ? _overlayRef$current : null;
542
551
  },
543
552
  get target() {
544
- var _targetRef$current;
545
- return (_targetRef$current = targetRef === null || targetRef === void 0 ? void 0 : targetRef.current) !== null && _targetRef$current !== void 0 ? _targetRef$current : null;
553
+ var _targetRef$current2;
554
+ return (_targetRef$current2 = targetRef === null || targetRef === void 0 ? void 0 : targetRef.current) !== null && _targetRef$current2 !== void 0 ? _targetRef$current2 : null;
546
555
  },
547
556
  get list() {
548
557
  if (!(listRef !== null && listRef !== void 0 && listRef.current)) {
@@ -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<never>, 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<never>, 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<never>, 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;