rsuite 5.67.0 → 5.68.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 (77) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/Nav/styles/index.css +68 -0
  3. package/Nav/styles/index.less +37 -0
  4. package/Tabs/styles/index.css +68 -3
  5. package/Tabs/styles/index.less +0 -4
  6. package/cjs/CheckTree/utils.d.ts +1 -1
  7. package/cjs/CheckTree/utils.js +1 -1
  8. package/cjs/DateInput/DateInput.js +18 -2
  9. package/cjs/DateInput/hooks/useDateInputState.d.ts +1 -0
  10. package/cjs/DateInput/hooks/useDateInputState.js +10 -9
  11. package/cjs/DateInput/hooks/useKeyboardInputEvent.js +5 -0
  12. package/cjs/DateRangeInput/DateRangeInput.js +24 -2
  13. package/cjs/Form/Form.js +4 -10
  14. package/cjs/Form/FormContext.d.ts +2 -4
  15. package/cjs/Form/hooks/useFormValidate.d.ts +2 -2
  16. package/cjs/Form/hooks/useFormValidate.js +99 -35
  17. package/cjs/FormControl/FormControl.js +6 -22
  18. package/cjs/Nav/AdaptiveNavItem.d.ts +1 -1
  19. package/cjs/Nav/Nav.d.ts +28 -9
  20. package/cjs/Nav/Nav.js +1 -1
  21. package/cjs/Nav/NavContext.d.ts +2 -2
  22. package/cjs/Nav/NavItem.d.ts +1 -1
  23. package/cjs/Navbar/NavbarItem.d.ts +1 -1
  24. package/cjs/Sidenav/Sidenav.d.ts +3 -3
  25. package/cjs/Tabs/Tabs.d.ts +20 -17
  26. package/cjs/Tabs/Tabs.js +5 -1
  27. package/cjs/internals/Overlay/OverlayTrigger.d.ts +2 -2
  28. package/cjs/internals/Overlay/OverlayTrigger.js +17 -8
  29. package/cjs/internals/utils/BrowserDetection.js +6 -0
  30. package/cjs/internals/utils/ReactChildren.d.ts +6 -0
  31. package/cjs/internals/utils/ReactChildren.js +1 -0
  32. package/dist/rsuite-no-reset-rtl.css +65 -3
  33. package/dist/rsuite-no-reset-rtl.min.css +1 -1
  34. package/dist/rsuite-no-reset-rtl.min.css.map +1 -1
  35. package/dist/rsuite-no-reset.css +65 -3
  36. package/dist/rsuite-no-reset.min.css +1 -1
  37. package/dist/rsuite-no-reset.min.css.map +1 -1
  38. package/dist/rsuite-rtl.css +65 -3
  39. package/dist/rsuite-rtl.min.css +1 -1
  40. package/dist/rsuite-rtl.min.css.map +1 -1
  41. package/dist/rsuite.css +65 -3
  42. package/dist/rsuite.js +13 -13
  43. package/dist/rsuite.min.css +1 -1
  44. package/dist/rsuite.min.css.map +1 -1
  45. package/dist/rsuite.min.js +1 -1
  46. package/dist/rsuite.min.js.map +1 -1
  47. package/esm/CheckTree/utils.d.ts +1 -1
  48. package/esm/CheckTree/utils.js +1 -1
  49. package/esm/DateInput/DateInput.js +18 -2
  50. package/esm/DateInput/hooks/useDateInputState.d.ts +1 -0
  51. package/esm/DateInput/hooks/useDateInputState.js +11 -10
  52. package/esm/DateInput/hooks/useKeyboardInputEvent.js +5 -0
  53. package/esm/DateRangeInput/DateRangeInput.js +24 -2
  54. package/esm/Form/Form.js +4 -10
  55. package/esm/Form/FormContext.d.ts +2 -4
  56. package/esm/Form/hooks/useFormValidate.d.ts +2 -2
  57. package/esm/Form/hooks/useFormValidate.js +98 -34
  58. package/esm/FormControl/FormControl.js +6 -22
  59. package/esm/Nav/AdaptiveNavItem.d.ts +1 -1
  60. package/esm/Nav/Nav.d.ts +28 -9
  61. package/esm/Nav/Nav.js +1 -1
  62. package/esm/Nav/NavContext.d.ts +2 -2
  63. package/esm/Nav/NavItem.d.ts +1 -1
  64. package/esm/Navbar/NavbarItem.d.ts +1 -1
  65. package/esm/Sidenav/Sidenav.d.ts +3 -3
  66. package/esm/Tabs/Tabs.d.ts +20 -17
  67. package/esm/Tabs/Tabs.js +6 -1
  68. package/esm/internals/Overlay/OverlayTrigger.d.ts +2 -2
  69. package/esm/internals/Overlay/OverlayTrigger.js +18 -9
  70. package/esm/internals/utils/BrowserDetection.js +6 -0
  71. package/esm/internals/utils/ReactChildren.d.ts +6 -0
  72. package/esm/internals/utils/ReactChildren.js +1 -1
  73. package/package.json +1 -1
  74. package/styles/color-modes/dark.less +7 -0
  75. package/styles/color-modes/high-contrast.less +7 -0
  76. package/styles/color-modes/light.less +8 -0
  77. package/styles/plugins/palette.js +34 -6
@@ -4,12 +4,15 @@
4
4
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
5
5
  exports.__esModule = true;
6
6
  exports.default = useFormValidate;
7
- var _extends5 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
7
+ var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
8
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
8
9
  var _react = require("react");
9
10
  var _omit = _interopRequireDefault(require("lodash/omit"));
10
11
  var _set = _interopRequireDefault(require("lodash/set"));
11
12
  var _hooks = require("../../internals/hooks");
12
13
  var _utils = require("../../FormControl/utils");
14
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
15
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
13
16
  function useFormValidate(formError, props) {
14
17
  var formValue = props.formValue,
15
18
  getCombinedModel = props.getCombinedModel,
@@ -19,6 +22,9 @@ function useFormValidate(formError, props) {
19
22
  var _useControlled = (0, _hooks.useControlled)(formError, {}),
20
23
  realFormError = _useControlled[0],
21
24
  setFormError = _useControlled[1];
25
+ var checkOptions = {
26
+ nestedObject: nestedField
27
+ };
22
28
  var realFormErrorRef = (0, _react.useRef)(realFormError);
23
29
  realFormErrorRef.current = realFormError;
24
30
 
@@ -32,7 +38,7 @@ function useFormValidate(formError, props) {
32
38
  var errorCount = 0;
33
39
  var model = getCombinedModel();
34
40
  Object.keys(model.getSchemaSpec()).forEach(function (key) {
35
- var checkResult = model.checkForField(key, formValue || {});
41
+ var checkResult = model.checkForField(key, formValue || {}, checkOptions);
36
42
  if (checkResult.hasError === true) {
37
43
  errorCount += 1;
38
44
  formError[key] = (checkResult === null || checkResult === void 0 ? void 0 : checkResult.errorMessage) || checkResult;
@@ -47,24 +53,56 @@ function useFormValidate(formError, props) {
47
53
  }
48
54
  return true;
49
55
  });
50
-
56
+ var checkFieldForNextValue = (0, _hooks.useEventCallback)(function (fieldName, nextValue, callback) {
57
+ var model = getCombinedModel();
58
+ var resultOfCurrentField = model.checkForField(fieldName, nextValue, checkOptions);
59
+ var nextFormError = (0, _extends2.default)({}, formError);
60
+ /**
61
+ * when using proxy of schema-typed, we need to use getCheckResult to get all errors,
62
+ * but if nestedField is used, it is impossible to distinguish whether the nested object has an error here,
63
+ * so nestedField does not support proxy here
64
+ */
65
+ if (nestedField) {
66
+ nextFormError = (0, _set.default)(nextFormError, (0, _utils.nameToPath)(fieldName), resultOfCurrentField);
67
+ setFormError(nextFormError);
68
+ onCheck === null || onCheck === void 0 ? void 0 : onCheck(nextFormError);
69
+ callback === null || callback === void 0 ? void 0 : callback(resultOfCurrentField);
70
+ if (resultOfCurrentField.hasError) {
71
+ onError === null || onError === void 0 ? void 0 : onError(nextFormError);
72
+ }
73
+ return !resultOfCurrentField.hasError;
74
+ } else {
75
+ var allResults = model.getCheckResult();
76
+ var hasError = false;
77
+ Object.keys(allResults).forEach(function (key) {
78
+ var currentResult = allResults[key];
79
+ if (currentResult.hasError) {
80
+ nextFormError[key] = currentResult.errorMessage || currentResult;
81
+ hasError = true;
82
+ } else {
83
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
84
+ var _nextFormError = nextFormError,
85
+ _ = _nextFormError[key],
86
+ rest = (0, _objectWithoutPropertiesLoose2.default)(_nextFormError, [key].map(_toPropertyKey));
87
+ nextFormError = rest;
88
+ }
89
+ });
90
+ setFormError(nextFormError);
91
+ onCheck === null || onCheck === void 0 ? void 0 : onCheck(nextFormError);
92
+ callback === null || callback === void 0 ? void 0 : callback(resultOfCurrentField);
93
+ if (hasError) {
94
+ onError === null || onError === void 0 ? void 0 : onError(nextFormError);
95
+ }
96
+ return !hasError;
97
+ }
98
+ });
51
99
  /**
52
100
  * Check the data field
53
101
  * @param fieldName
54
102
  * @param callback
55
103
  */
56
104
  var checkForField = (0, _hooks.useEventCallback)(function (fieldName, callback) {
57
- var _extends2;
58
- var model = getCombinedModel();
59
- var checkResult = model.checkForField(fieldName, formValue || {});
60
- var nextFormError = (0, _extends5.default)({}, formError, (_extends2 = {}, _extends2[fieldName] = (checkResult === null || checkResult === void 0 ? void 0 : checkResult.errorMessage) || checkResult, _extends2));
61
- setFormError(nextFormError);
62
- onCheck === null || onCheck === void 0 ? void 0 : onCheck(nextFormError);
63
- callback === null || callback === void 0 ? void 0 : callback(checkResult);
64
- if (checkResult.hasError) {
65
- onError === null || onError === void 0 ? void 0 : onError(nextFormError);
66
- }
67
- return !checkResult.hasError;
105
+ return checkFieldForNextValue(fieldName, formValue || {}, callback);
68
106
  });
69
107
 
70
108
  /**
@@ -76,7 +114,7 @@ function useFormValidate(formError, props) {
76
114
  var model = getCombinedModel();
77
115
  Object.keys(model.getSchemaSpec()).forEach(function (key) {
78
116
  keys.push(key);
79
- promises.push(model.checkForFieldAsync(key, formValue || {}));
117
+ promises.push(model.checkForFieldAsync(key, formValue || {}, checkOptions));
80
118
  });
81
119
  return Promise.all(promises).then(function (values) {
82
120
  var formError = {};
@@ -98,23 +136,56 @@ function useFormValidate(formError, props) {
98
136
  };
99
137
  });
100
138
  });
139
+ var checkFieldAsyncForNextValue = (0, _hooks.useEventCallback)(function (fieldName, nextValue) {
140
+ var model = getCombinedModel();
141
+ return model.checkForFieldAsync(fieldName, nextValue, checkOptions).then(function (resultOfCurrentField) {
142
+ var nextFormError = (0, _extends2.default)({}, formError);
143
+ /**
144
+ * when using proxy of schema-typed, we need to use getCheckResult to get all errors,
145
+ * but if nestedField is used, it is impossible to distinguish whether the nested object has an error here,
146
+ * so nestedField does not support proxy here
147
+ */
148
+
149
+ if (nestedField) {
150
+ nextFormError = (0, _set.default)(nextFormError, (0, _utils.nameToPath)(fieldName), resultOfCurrentField);
151
+ onCheck === null || onCheck === void 0 ? void 0 : onCheck(nextFormError);
152
+ setFormError(nextFormError);
153
+ if (resultOfCurrentField.hasError) {
154
+ onError === null || onError === void 0 ? void 0 : onError(nextFormError);
155
+ }
156
+ return resultOfCurrentField;
157
+ } else {
158
+ var allResults = model.getCheckResult();
159
+ var hasError = false;
160
+ Object.keys(allResults).forEach(function (key) {
161
+ var currentResult = allResults[key];
162
+ if (currentResult.hasError) {
163
+ nextFormError[key] = currentResult.errorMessage || currentResult;
164
+ hasError = true;
165
+ } else {
166
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
167
+ var _nextFormError2 = nextFormError,
168
+ _ = _nextFormError2[key],
169
+ rest = (0, _objectWithoutPropertiesLoose2.default)(_nextFormError2, [key].map(_toPropertyKey));
170
+ nextFormError = rest;
171
+ }
172
+ });
173
+ setFormError(nextFormError);
174
+ onCheck === null || onCheck === void 0 ? void 0 : onCheck(nextFormError);
175
+ if (hasError) {
176
+ onError === null || onError === void 0 ? void 0 : onError(nextFormError);
177
+ }
178
+ return resultOfCurrentField;
179
+ }
180
+ });
181
+ });
101
182
 
102
183
  /**
103
184
  * Asynchronously check form fields and return Promise
104
185
  * @param fieldName
105
186
  */
106
187
  var checkForFieldAsync = (0, _hooks.useEventCallback)(function (fieldName) {
107
- var model = getCombinedModel();
108
- return model.checkForFieldAsync(fieldName, formValue || {}).then(function (checkResult) {
109
- var _extends3;
110
- var nextFormError = (0, _extends5.default)({}, formError, (_extends3 = {}, _extends3[fieldName] = checkResult.errorMessage, _extends3));
111
- onCheck === null || onCheck === void 0 ? void 0 : onCheck(nextFormError);
112
- setFormError(nextFormError);
113
- if (checkResult.hasError) {
114
- onError === null || onError === void 0 ? void 0 : onError(nextFormError);
115
- }
116
- return checkResult;
117
- });
188
+ return checkFieldAsyncForNextValue(fieldName, formValue || {});
118
189
  });
119
190
  var onRemoveError = (0, _react.useCallback)(function (name) {
120
191
  /**
@@ -127,14 +198,6 @@ function useFormValidate(formError, props) {
127
198
  onCheck === null || onCheck === void 0 ? void 0 : onCheck(formError);
128
199
  return formError;
129
200
  }, [nestedField, onCheck, setFormError]);
130
- var setFieldError = (0, _react.useCallback)(function (fieldName, checkResult) {
131
- var _extends4;
132
- var nextFormError = nestedField ? (0, _set.default)((0, _extends5.default)({}, formError), (0, _utils.nameToPath)(fieldName), checkResult) : (0, _extends5.default)({}, formError, (_extends4 = {}, _extends4[fieldName] = checkResult, _extends4));
133
- setFormError(nextFormError);
134
- onError === null || onError === void 0 ? void 0 : onError(nextFormError);
135
- onCheck === null || onCheck === void 0 ? void 0 : onCheck(nextFormError);
136
- return nextFormError;
137
- }, [formError, nestedField, onCheck, onError, setFormError]);
138
201
  var cleanErrors = (0, _hooks.useEventCallback)(function () {
139
202
  setFormError({});
140
203
  });
@@ -151,12 +214,13 @@ function useFormValidate(formError, props) {
151
214
  formError: realFormError,
152
215
  check: check,
153
216
  checkForField: checkForField,
217
+ checkFieldForNextValue: checkFieldForNextValue,
154
218
  checkAsync: checkAsync,
155
219
  checkForFieldAsync: checkForFieldAsync,
220
+ checkFieldAsyncForNextValue: checkFieldAsyncForNextValue,
156
221
  cleanErrors: cleanErrors,
157
222
  resetErrors: resetErrors,
158
223
  cleanErrorForField: cleanErrorForField,
159
- setFieldError: setFieldError,
160
224
  onRemoveError: onRemoveError
161
225
  };
162
226
  }
@@ -42,10 +42,9 @@ var FormControl = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
42
42
  removeFieldValue = _useContext.removeFieldValue,
43
43
  removeFieldError = _useContext.removeFieldError,
44
44
  onFieldChange = _useContext.onFieldChange,
45
- onFieldError = _useContext.onFieldError,
46
- onFieldSuccess = _useContext.onFieldSuccess,
47
- getCombinedModel = _useContext.getCombinedModel,
48
- contextCheckTrigger = _useContext.checkTrigger;
45
+ contextCheckTrigger = _useContext.checkTrigger,
46
+ checkFieldForNextValue = _useContext.checkFieldForNextValue,
47
+ checkFieldAsyncForNextValue = _useContext.checkFieldAsyncForNextValue;
49
48
  var _props$as = props.as,
50
49
  Component = _props$as === void 0 ? 'div' : _props$as,
51
50
  _props$accepter = props.accepter,
@@ -120,27 +119,12 @@ var FormControl = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
120
119
  onBlur === null || onBlur === void 0 ? void 0 : onBlur(event);
121
120
  });
122
121
  var handleFieldCheck = (0, _hooks.useEventCallback)(function (value) {
123
- var callbackEvents = function callbackEvents(checkResult) {
124
- if (checkResult.hasError) {
125
- var _errorMessage = checkResult.errorMessage;
126
- var _fieldError = nestedField ? checkResult : _errorMessage || checkResult;
127
- onFieldError === null || onFieldError === void 0 ? void 0 : onFieldError(name, _fieldError);
128
- } else {
129
- onFieldSuccess === null || onFieldSuccess === void 0 ? void 0 : onFieldSuccess(name);
130
- }
131
- return checkResult;
132
- };
133
122
  var nextFormValue = setFieldValue(name, value);
134
- var model = getCombinedModel();
135
- var checkOptions = {
136
- nestedObject: nestedField
137
- };
138
123
  if (checkAsync) {
139
- return model === null || model === void 0 ? void 0 : model.checkForFieldAsync(name, nextFormValue, checkOptions).then(function (checkResult) {
140
- return callbackEvents(checkResult);
141
- });
124
+ checkFieldAsyncForNextValue(name, nextFormValue);
125
+ } else {
126
+ checkFieldForNextValue(name, nextFormValue);
142
127
  }
143
- return Promise.resolve(callbackEvents(model === null || model === void 0 ? void 0 : model.checkForField(name, nextFormValue, checkOptions)));
144
128
  });
145
129
  var fieldHasError = Boolean(fieldError);
146
130
 
@@ -5,5 +5,5 @@ import { NavItemProps } from './NavItem';
5
5
  * When used as direct child of <Nav>, render the NavItem
6
6
  * When used within a <Nav.Menu>, render the NavDropdownItem
7
7
  */
8
- declare const AdaptiveNavItem: React.ForwardRefExoticComponent<NavItemProps<string> & React.RefAttributes<any>>;
8
+ declare const AdaptiveNavItem: React.ForwardRefExoticComponent<NavItemProps<string | number> & React.RefAttributes<any>>;
9
9
  export default AdaptiveNavItem;
package/cjs/Nav/Nav.d.ts CHANGED
@@ -4,21 +4,40 @@ import { WithAsProps, RsRefForwardingComponent } from '../internals/types';
4
4
  import NavDropdown from './NavDropdown';
5
5
  import NavMenu from './NavMenu';
6
6
  export interface NavProps<T = any> extends WithAsProps, Omit<React.HTMLAttributes<HTMLElement>, 'onSelect'> {
7
- /** sets appearance */
8
- appearance?: 'default' | 'subtle' | 'tabs';
9
- /** Reverse Direction of tabs/subtle */
7
+ /**
8
+ * The appearance style of the Nav component.
9
+ *
10
+ * @default 'default'
11
+ * @version 'pills' is supported in version 5.68.0
12
+ */
13
+ appearance?: 'default' | 'subtle' | 'tabs' | 'pills';
14
+ /**
15
+ * Whether the Nav component is reversed.
16
+ */
10
17
  reversed?: boolean;
11
- /** Justified navigation */
18
+ /**
19
+ * Whether the Nav component is justified.
20
+ */
12
21
  justified?: boolean;
13
- /** Vertical navigation */
22
+ /**
23
+ * Whether the Nav component is vertical.
24
+ */
14
25
  vertical?: boolean;
15
- /** appears on the right. */
26
+ /**
27
+ * Whether the Nav component is pulled to the right.
28
+ */
16
29
  pullRight?: boolean;
17
- /** Active key, corresponding to eventkey in <Nav.item>. */
30
+ /**
31
+ * The active key of the Nav component.
32
+ */
18
33
  activeKey?: T;
19
- /** Default active key, corresponding to eventkey in <Nav.item>. */
34
+ /**
35
+ * The default active key of the Nav component.
36
+ */
20
37
  defaultActiveKey?: T;
21
- /** Callback function triggered after selection */
38
+ /**
39
+ * Event handler for selecting a Nav item.
40
+ */
22
41
  onSelect?: (eventKey: T | undefined, event: React.SyntheticEvent) => void;
23
42
  }
24
43
  interface NavComponent extends RsRefForwardingComponent<'div', NavProps> {
package/cjs/Nav/Nav.js CHANGED
@@ -124,7 +124,7 @@ Nav.propTypes = {
124
124
  classPrefix: _propTypes.default.string,
125
125
  className: _propTypes.default.string,
126
126
  children: _propTypes.default.node,
127
- appearance: (0, _propTypes2.oneOf)(['default', 'subtle', 'tabs']),
127
+ appearance: (0, _propTypes2.oneOf)(['default', 'subtle', 'tabs', 'pills']),
128
128
  // Reverse Direction of tabs/subtle
129
129
  reversed: _propTypes.default.bool,
130
130
  justified: _propTypes.default.bool,
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  export interface NavContextProps {
3
- activeKey: string | undefined;
4
- onSelect?: (eventKey: string | undefined, event: React.SyntheticEvent) => void;
3
+ activeKey: string | number | undefined;
4
+ onSelect?: (eventKey: string | number | undefined, event: React.SyntheticEvent) => void;
5
5
  }
6
6
  declare const NavContext: React.Context<NavContextProps | null>;
7
7
  export default NavContext;
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { RsRefForwardingComponent, WithAsProps } from '../internals/types';
3
3
  import { IconProps } from '@rsuite/icons/lib/Icon';
4
- export interface NavItemProps<T = string> extends WithAsProps, Omit<React.HTMLAttributes<HTMLElement>, 'onSelect'> {
4
+ export interface NavItemProps<T = string | number> extends WithAsProps, Omit<React.HTMLAttributes<HTMLElement>, 'onSelect'> {
5
5
  /** Activation status */
6
6
  active?: boolean;
7
7
  /** Disabled status */
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { IconProps } from '@rsuite/icons/lib/Icon';
3
3
  import { RsRefForwardingComponent, WithAsProps } from '../internals/types';
4
- export interface NavbarItemProps<T = string> extends WithAsProps, Omit<React.HTMLAttributes<HTMLElement>, 'onSelect'> {
4
+ export interface NavbarItemProps<T = string | number> extends WithAsProps, Omit<React.HTMLAttributes<HTMLElement>, 'onSelect'> {
5
5
  /** Activation status */
6
6
  active?: boolean;
7
7
  /** Disabled status */
@@ -3,7 +3,7 @@ import SidenavBody from './SidenavBody';
3
3
  import SidenavHeader from './SidenavHeader';
4
4
  import SidenavToggle from './SidenavToggle';
5
5
  import { WithAsProps, RsRefForwardingComponent } from '../internals/types';
6
- export interface SidenavProps<T = string> extends WithAsProps {
6
+ export interface SidenavProps<T = string | number> extends WithAsProps {
7
7
  /** Whether to expand the Sidenav */
8
8
  expanded?: boolean;
9
9
  /** Menu style */
@@ -25,8 +25,8 @@ export interface SidenavProps<T = string> extends WithAsProps {
25
25
  */
26
26
  onSelect?: (eventKey: T | undefined, event: React.SyntheticEvent) => void;
27
27
  }
28
- export declare const SidenavContext: React.Context<SidenavContextType<string> | null>;
29
- export interface SidenavContextType<T = string> {
28
+ export declare const SidenavContext: React.Context<SidenavContextType<string | number> | null>;
29
+ export interface SidenavContextType<T = string | number> {
30
30
  openKeys: T[];
31
31
  /**
32
32
  * @deprecated Use activeKey from NavContext instead
@@ -1,41 +1,44 @@
1
1
  import React from 'react';
2
2
  import { WithAsProps, RsRefForwardingComponent } from '../internals/types';
3
3
  import Tab from './Tab';
4
+ /**
5
+ * Props for the Tabs component.
6
+ */
4
7
  export interface TabsProps extends WithAsProps {
5
8
  /**
6
- * The tabs appearance style.
9
+ * The appearance of the tabs.
10
+ * @default 'tabs'
11
+ * @version 'pills' is supported in version 5.68.0
7
12
  */
8
- appearance?: 'tabs' | 'subtle';
13
+ appearance?: 'tabs' | 'subtle' | 'pills';
9
14
  /**
10
- * Mark the Tab with a matching `eventKey` as active.
15
+ * The key of the active tab.
11
16
  */
12
- activeKey?: string;
17
+ activeKey?: string | number;
13
18
  /**
14
- * The default active tabKey.
19
+ * The default key of the active tab.
15
20
  */
16
- defaultActiveKey?: string;
21
+ defaultActiveKey?: string | number;
17
22
  /**
18
- * Reversed display.
19
- * @default false
23
+ * Whether to reverse the order of the tabs.
20
24
  */
21
25
  reversed?: boolean;
22
26
  /**
23
- * Vertical display.
24
- * @default false
27
+ * Whether to display the tabs vertically.
25
28
  */
26
29
  vertical?: boolean;
27
30
  /**
28
- * The HTML id attribute, which should be unique.
29
- * @default use generated id
31
+ * The ID of the tabs.
32
+ * @default A unique ID is automatically generated.
30
33
  */
31
34
  id?: string;
32
35
  /**
33
- * Callback fired when a Tab is selected.
34
- * @param eventKey
35
- * @param event
36
- * @returns
36
+ * Callback function that is called when a tab is selected.
37
+ *
38
+ * @param eventKey - The key of the selected tab.
39
+ * @param event - The event object.
37
40
  */
38
- onSelect?: (eventKey: string | undefined, event: React.SyntheticEvent) => void;
41
+ onSelect?: (eventKey: string | number | undefined, event: React.SyntheticEvent) => void;
39
42
  }
40
43
  interface TabsComponent extends RsRefForwardingComponent<'div', TabsProps> {
41
44
  Tab: typeof Tab;
package/cjs/Tabs/Tabs.js CHANGED
@@ -16,6 +16,10 @@ var _Tab = _interopRequireDefault(require("./Tab"));
16
16
  var _TabPanel = _interopRequireDefault(require("./TabPanel"));
17
17
  var _templateObject;
18
18
  var _excluded = ["as", "classPrefix", "appearance", "className", "children", "activeKey", "defaultActiveKey", "id", "reversed", "vertical", "onSelect"];
19
+ /**
20
+ * Props for the Tabs component.
21
+ */
22
+
19
23
  function getFocusableTabs(tablist) {
20
24
  var tabs = tablist === null || tablist === void 0 ? void 0 : tablist.querySelectorAll('[role=tab]');
21
25
  return Array.from(tabs).filter(function (tab) {
@@ -208,7 +212,7 @@ var Tabs = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
208
212
  Tabs.Tab = _Tab.default;
209
213
  Tabs.displayName = 'Tabs';
210
214
  Tabs.propTypes = {
211
- appearance: _propTypes.default.oneOf(['tabs', 'subtle']),
215
+ appearance: _propTypes.default.oneOf(['tabs', 'subtle', 'pills']),
212
216
  activeKey: _propTypes.default.any,
213
217
  defaultActiveKey: _propTypes.default.any,
214
218
  reversed: _propTypes.default.bool,
@@ -31,7 +31,7 @@ export interface OverlayTriggerProps extends Omit<StandardProps, 'children'>, An
31
31
  /** Whether mouse is allowed to enter the floating layer of popover, whose default value is false. */
32
32
  enterable?: boolean;
33
33
  /** For the monitored component, the event will be bound to this component. */
34
- children: React.ReactElement | ((props: any, ref: any) => React.ReactElement);
34
+ children: React.ReactNode | ((props: any, ref: any) => React.ReactElement);
35
35
  /** Whether to allow clicking document to close the overlay */
36
36
  rootClose?: boolean;
37
37
  /** Once disabled, the event cannot be triggered. */
@@ -73,7 +73,7 @@ export declare enum OverlayCloseCause {
73
73
  ImperativeHandle = 1
74
74
  }
75
75
  export interface OverlayTriggerHandle {
76
- root: HTMLElement | undefined;
76
+ root?: HTMLElement | null;
77
77
  updatePosition: () => void;
78
78
  open: (delay?: number) => void;
79
79
  close: (delay?: number) => void;
@@ -14,6 +14,7 @@ var _contains = _interopRequireDefault(require("dom-lib/contains"));
14
14
  var _Overlay = _interopRequireDefault(require("./Overlay"));
15
15
  var _hooks = require("../hooks");
16
16
  var _utils = require("../utils");
17
+ var _ReactChildren = require("../utils/ReactChildren");
17
18
  var _OverlayContext = _interopRequireDefault(require("./OverlayContext"));
18
19
  var _excluded = ["children", "container", "controlId", "defaultOpen", "trigger", "disabled", "followCursor", "readOnly", "plaintext", "open", "delay", "delayOpen", "delayClose", "enterable", "placement", "speaker", "rootClose", "onClick", "onMouseOver", "onMouseMove", "onMouseOut", "onContextMenu", "onFocus", "onBlur", "onOpen", "onClose", "onExited"];
19
20
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
@@ -104,7 +105,7 @@ var OverlayTrigger = /*#__PURE__*/_react.default.forwardRef(function (props, ref
104
105
  }),
105
106
  Portal = _usePortal.Portal,
106
107
  containerElement = _usePortal.target;
107
- var triggerRef = (0, _react.useRef)();
108
+ var triggerRef = (0, _react.useRef)(null);
108
109
  var overlayRef = (0, _react.useRef)();
109
110
  var _useControlled = (0, _hooks.useControlled)(openProp, defaultOpen),
110
111
  open = _useControlled[0],
@@ -367,13 +368,21 @@ var OverlayTrigger = /*#__PURE__*/_react.default.forwardRef(function (props, ref
367
368
  }), ref);
368
369
  } : speaker);
369
370
  };
370
- if (typeof children === 'object' && children.type === _react.default.Fragment || typeof children === 'string') {
371
- console.error('[rsuite] The OverlayTrigger component does not accept strings or Fragments as child.');
372
- }
373
- return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, typeof children === 'function' ? children(triggerEvents, triggerRef) : /*#__PURE__*/_react.default.cloneElement(children, (0, _extends2.default)({
374
- ref: triggerRef,
375
- 'aria-describedby': controlId
376
- }, mergeEvents(triggerEvents, children.props))), /*#__PURE__*/_react.default.createElement(Portal, null, renderOverlay()));
371
+ var triggerElement = (0, _react.useMemo)(function () {
372
+ if (typeof children === 'function') {
373
+ return children(triggerEvents, triggerRef);
374
+ } else if ((0, _ReactChildren.isFragment)(children) || ! /*#__PURE__*/(0, _react.isValidElement)(children)) {
375
+ return /*#__PURE__*/_react.default.createElement("span", (0, _extends2.default)({
376
+ ref: triggerRef,
377
+ "aria-describedby": controlId
378
+ }, triggerEvents), children);
379
+ }
380
+ return /*#__PURE__*/(0, _react.cloneElement)(children, (0, _extends2.default)({
381
+ ref: triggerRef,
382
+ 'aria-describedby': controlId
383
+ }, mergeEvents(triggerEvents, children.props)));
384
+ }, [children, controlId, triggerEvents]);
385
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, triggerElement, /*#__PURE__*/_react.default.createElement(Portal, null, renderOverlay()));
377
386
  });
378
387
  OverlayTrigger.displayName = 'OverlayTrigger';
379
388
  var _default = exports.default = OverlayTrigger;
@@ -45,6 +45,12 @@ var getSafariVersion = exports.getSafariVersion = function getSafariVersion() {
45
45
  * @see https://caniuse.com/flexbox-gap
46
46
  */
47
47
  var isSupportFlexGap = exports.isSupportFlexGap = function isSupportFlexGap() {
48
+ // Check if the browser supports the `gap` property
49
+ if (typeof CSS !== 'undefined' && typeof CSS.supports !== 'undefined') {
50
+ return CSS.supports('(gap: 1px)');
51
+ }
52
+
53
+ // IE does not support flex-gap
48
54
  if (isIE()) {
49
55
  return false;
50
56
  }
@@ -1,4 +1,10 @@
1
1
  import React from 'react';
2
+ /**
3
+ * Checks if the given children is a React fragment.
4
+ * @param children - The children to check.
5
+ * @returns True if the children is a React fragment, false otherwise.
6
+ */
7
+ export declare function isFragment(children: React.ReactNode): boolean;
2
8
  /**
3
9
  * Finds the first child that satisfies the given condition.
4
10
  * @param children - The children to search.
@@ -7,6 +7,7 @@ exports.ReactChildren = void 0;
7
7
  exports.count = count;
8
8
  exports.default = void 0;
9
9
  exports.find = find;
10
+ exports.isFragment = isFragment;
10
11
  exports.map = map;
11
12
  exports.mapCloneElement = mapCloneElement;
12
13
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));