rsuite 5.3.0 → 5.4.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 (106) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/Dropdown/styles/index.less +1 -0
  3. package/Nav/styles/index.less +1 -0
  4. package/Navbar/styles/index.less +7 -0
  5. package/Radio/styles/index.less +6 -0
  6. package/Stack/package.json +7 -0
  7. package/Stack/styles/index.less +5 -0
  8. package/TreePicker/styles/index.less +0 -14
  9. package/cjs/@types/common.d.ts +4 -4
  10. package/cjs/Cascader/utils.d.ts +7 -7
  11. package/cjs/CheckPicker/CheckPicker.d.ts +9 -4
  12. package/cjs/CheckPicker/test/CheckPicker.test.d.ts +1 -0
  13. package/cjs/CheckPicker/test/CheckPicker.test.js +76 -0
  14. package/cjs/CheckTree/index.js +2 -6
  15. package/cjs/DatePicker/DatePicker.js +2 -2
  16. package/cjs/DateRangePicker/DateRangePicker.js +6 -2
  17. package/cjs/Dropdown/DropdownToggle.js +8 -1
  18. package/cjs/MultiCascader/utils.d.ts +3 -3
  19. package/cjs/Nav/Nav.js +3 -0
  20. package/cjs/Nav/NavContext.d.ts +6 -0
  21. package/cjs/Nav/NavContext.js +1 -0
  22. package/cjs/Overlay/Modal.js +37 -25
  23. package/cjs/Overlay/Overlay.d.ts +1 -1
  24. package/cjs/Overlay/Overlay.js +7 -1
  25. package/cjs/Overlay/OverlayContext.d.ts +6 -0
  26. package/cjs/Overlay/OverlayContext.js +14 -0
  27. package/cjs/Overlay/OverlayTrigger.js +7 -1
  28. package/cjs/Overlay/Position.d.ts +1 -1
  29. package/cjs/Picker/propTypes.d.ts +3 -5
  30. package/cjs/Picker/propTypes.js +4 -3
  31. package/cjs/Picker/utils.d.ts +3 -3
  32. package/cjs/SelectPicker/SelectPicker.d.ts +12 -5
  33. package/cjs/SelectPicker/SelectPicker.js +4 -4
  34. package/cjs/SelectPicker/index.d.ts +1 -1
  35. package/cjs/SelectPicker/test/SelectPicker.test.d.ts +1 -0
  36. package/cjs/SelectPicker/test/SelectPicker.test.js +62 -0
  37. package/cjs/Stack/Stack.d.ts +26 -0
  38. package/cjs/Stack/Stack.js +86 -0
  39. package/cjs/Stack/index.d.ts +3 -0
  40. package/cjs/Stack/index.js +11 -0
  41. package/cjs/Steps/StepItem.js +2 -2
  42. package/cjs/Toggle/Toggle.js +2 -2
  43. package/cjs/Tree/Tree.d.ts +0 -1
  44. package/cjs/Tree/Tree.js +2 -6
  45. package/cjs/Tree/TreeContext.d.ts +0 -1
  46. package/cjs/TreePicker/TreeNode.js +1 -14
  47. package/cjs/TreePicker/TreePicker.js +3 -29
  48. package/cjs/index.d.ts +4 -2
  49. package/cjs/index.js +9 -5
  50. package/cjs/utils/treeUtils.d.ts +5 -5
  51. package/cjs/utils/usePortal.d.ts +1 -1
  52. package/dist/rsuite-rtl.css +20 -16
  53. package/dist/rsuite-rtl.min.css +1 -1
  54. package/dist/rsuite-rtl.min.css.map +1 -1
  55. package/dist/rsuite.css +20 -16
  56. package/dist/rsuite.js +51 -18
  57. package/dist/rsuite.js.map +1 -1
  58. package/dist/rsuite.min.css +1 -1
  59. package/dist/rsuite.min.css.map +1 -1
  60. package/dist/rsuite.min.js +1 -1
  61. package/dist/rsuite.min.js.map +1 -1
  62. package/esm/@types/common.d.ts +4 -4
  63. package/esm/Cascader/utils.d.ts +7 -7
  64. package/esm/CheckPicker/CheckPicker.d.ts +9 -4
  65. package/esm/CheckPicker/test/CheckPicker.test.d.ts +1 -0
  66. package/esm/CheckPicker/test/CheckPicker.test.js +64 -0
  67. package/esm/CheckTree/index.js +2 -4
  68. package/esm/DatePicker/DatePicker.js +2 -2
  69. package/esm/DateRangePicker/DateRangePicker.js +6 -2
  70. package/esm/Dropdown/DropdownToggle.js +7 -1
  71. package/esm/MultiCascader/utils.d.ts +3 -3
  72. package/esm/Nav/Nav.js +3 -0
  73. package/esm/Nav/NavContext.d.ts +6 -0
  74. package/esm/Nav/NavContext.js +1 -0
  75. package/esm/Overlay/Modal.js +37 -25
  76. package/esm/Overlay/Overlay.d.ts +1 -1
  77. package/esm/Overlay/Overlay.js +7 -2
  78. package/esm/Overlay/OverlayContext.d.ts +6 -0
  79. package/esm/Overlay/OverlayContext.js +4 -0
  80. package/esm/Overlay/OverlayTrigger.js +7 -2
  81. package/esm/Overlay/Position.d.ts +1 -1
  82. package/esm/Picker/propTypes.d.ts +3 -5
  83. package/esm/Picker/propTypes.js +4 -3
  84. package/esm/Picker/utils.d.ts +3 -3
  85. package/esm/SelectPicker/SelectPicker.d.ts +12 -5
  86. package/esm/SelectPicker/SelectPicker.js +4 -4
  87. package/esm/SelectPicker/index.d.ts +1 -1
  88. package/esm/SelectPicker/test/SelectPicker.test.d.ts +1 -0
  89. package/esm/SelectPicker/test/SelectPicker.test.js +52 -0
  90. package/esm/Stack/Stack.d.ts +26 -0
  91. package/esm/Stack/Stack.js +71 -0
  92. package/esm/Stack/index.d.ts +3 -0
  93. package/esm/Stack/index.js +2 -0
  94. package/esm/Steps/StepItem.js +2 -2
  95. package/esm/Toggle/Toggle.js +2 -2
  96. package/esm/Tree/Tree.d.ts +0 -1
  97. package/esm/Tree/Tree.js +2 -4
  98. package/esm/Tree/TreeContext.d.ts +0 -1
  99. package/esm/TreePicker/TreeNode.js +2 -14
  100. package/esm/TreePicker/TreePicker.js +3 -29
  101. package/esm/index.d.ts +4 -2
  102. package/esm/index.js +2 -1
  103. package/esm/utils/treeUtils.d.ts +5 -5
  104. package/esm/utils/usePortal.d.ts +1 -1
  105. package/package.json +1 -1
  106. package/styles/index.less +1 -0
@@ -134,12 +134,12 @@ export interface SVGIcon {
134
134
  viewBox: string;
135
135
  id: string;
136
136
  }
137
- export interface ItemDataType extends Record<string, any> {
137
+ export interface ItemDataType<T = number | string> extends Record<string, any> {
138
138
  label?: string | React.ReactNode;
139
- value?: string | number;
139
+ value?: T;
140
140
  groupBy?: string;
141
- parent?: ItemDataType;
142
- children?: ItemDataType[];
141
+ parent?: ItemDataType<T>;
142
+ children?: ItemDataType<T>[];
143
143
  loading?: boolean;
144
144
  }
145
145
  export interface Offset {
@@ -2,16 +2,16 @@
2
2
  import { CascaderProps } from './Cascader';
3
3
  import { ItemDataType } from '../@types/common';
4
4
  export declare function getColumnsAndPaths<T extends ItemDataType>(data: T[], value: any, options: any): {
5
- columns: ItemDataType[][];
5
+ columns: ItemDataType<string | number>[][];
6
6
  paths: T[];
7
7
  };
8
8
  export declare function usePaths(props: CascaderProps): {
9
9
  enforceUpdate: (nextValue: any, isAttachChildren?: boolean | undefined) => void;
10
- columnData: ItemDataType[][];
11
- valueToPaths: ItemDataType[];
12
- selectedPaths: ItemDataType[];
13
- setValueToPaths: import("react").Dispatch<import("react").SetStateAction<ItemDataType[]>>;
14
- setColumnData: import("react").Dispatch<import("react").SetStateAction<ItemDataType[][]>>;
15
- setSelectedPaths: import("react").Dispatch<import("react").SetStateAction<ItemDataType[]>>;
10
+ columnData: ItemDataType<string | number>[][];
11
+ valueToPaths: ItemDataType<string | number>[];
12
+ selectedPaths: ItemDataType<string | number>[];
13
+ setValueToPaths: import("react").Dispatch<import("react").SetStateAction<ItemDataType<string | number>[]>>;
14
+ setColumnData: import("react").Dispatch<import("react").SetStateAction<ItemDataType<string | number>[][]>>;
15
+ setSelectedPaths: import("react").Dispatch<import("react").SetStateAction<ItemDataType<string | number>[]>>;
16
16
  addColumn: (column: ItemDataType[], index: number) => void;
17
17
  };
@@ -1,13 +1,18 @@
1
+ import React from 'react';
1
2
  import { PickerLocale } from '../locales';
2
- import { PickerComponent } from '../Picker';
3
3
  import { ItemDataType, FormControlPickerProps } from '../@types/common';
4
- import { SelectProps } from '../SelectPicker';
4
+ import type { MultipleSelectProps } from '../SelectPicker';
5
5
  export declare type ValueType = (number | string)[];
6
- export interface CheckPickerProps<T = ValueType> extends FormControlPickerProps<T, PickerLocale, ItemDataType>, SelectProps<T> {
6
+ export interface CheckPickerProps<T> extends FormControlPickerProps<T[], PickerLocale, ItemDataType<T>>, MultipleSelectProps<T> {
7
7
  /** Top the selected option in the options */
8
8
  sticky?: boolean;
9
9
  /** A picker that can be counted */
10
10
  countable?: boolean;
11
11
  }
12
- declare const CheckPicker: PickerComponent<CheckPickerProps>;
12
+ export interface CheckPickerComponent {
13
+ <T>(props: CheckPickerProps<T>): JSX.Element | null;
14
+ displayName?: string;
15
+ propTypes?: React.WeakValidationMap<CheckPickerProps<any>>;
16
+ }
17
+ declare const CheckPicker: CheckPickerComponent;
13
18
  export default CheckPicker;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,64 @@
1
+ import React from 'react';
2
+ import { expectType } from 'ts-expect';
3
+ import CheckPicker from '../CheckPicker'; // Infer value and onChange types from data
4
+
5
+ var numberValuedData = [{
6
+ label: 'One',
7
+ value: 1
8
+ }];
9
+
10
+ /*#__PURE__*/
11
+ React.createElement(CheckPicker, {
12
+ data: numberValuedData,
13
+ value: [1]
14
+ }); // @ts-expect-error should not accept single value
15
+
16
+ /*#__PURE__*/
17
+ React.createElement(CheckPicker, {
18
+ data: numberValuedData,
19
+ value: 1
20
+ }); // @ts-expect-error should not accept string value
21
+
22
+ /*#__PURE__*/
23
+ React.createElement(CheckPicker, {
24
+ data: numberValuedData,
25
+ value: ['1']
26
+ });
27
+
28
+ /*#__PURE__*/
29
+ React.createElement(CheckPicker, {
30
+ data: numberValuedData,
31
+ onChange: function onChange(newValue) {
32
+ expectType(newValue);
33
+ }
34
+ });
35
+ var stringValuedData = [{
36
+ label: 'One',
37
+ value: 'One'
38
+ }];
39
+
40
+ /*#__PURE__*/
41
+ React.createElement(CheckPicker, {
42
+ data: stringValuedData,
43
+ value: ['1']
44
+ }); // @ts-expect-error should not accept single value
45
+
46
+ /*#__PURE__*/
47
+ React.createElement(CheckPicker, {
48
+ data: numberValuedData,
49
+ value: "1"
50
+ }); // @ts-expect-error should not accept number value
51
+
52
+ /*#__PURE__*/
53
+ React.createElement(CheckPicker, {
54
+ data: stringValuedData,
55
+ value: [1]
56
+ });
57
+
58
+ /*#__PURE__*/
59
+ React.createElement(CheckPicker, {
60
+ data: stringValuedData,
61
+ onChange: function onChange(newValue) {
62
+ expectType(newValue);
63
+ }
64
+ });
@@ -1,13 +1,11 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
- import React, { useRef } from 'react';
2
+ import React from 'react';
3
3
  import CheckTreePicker from '../CheckTreePicker';
4
4
  import TreeContext from '../Tree/TreeContext';
5
5
  var CheckTree = /*#__PURE__*/React.forwardRef(function (props, ref) {
6
- var dragNodeRef = useRef();
7
6
  return /*#__PURE__*/React.createElement(TreeContext.Provider, {
8
7
  value: {
9
- inline: true,
10
- dragNodeRef: dragNodeRef
8
+ inline: true
11
9
  }
12
10
  }, /*#__PURE__*/React.createElement(CheckTreePicker, _extends({
13
11
  ref: ref
@@ -408,7 +408,7 @@ var DatePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
408
408
 
409
409
  return (_renderValue = renderValue === null || renderValue === void 0 ? void 0 : renderValue(value, formatStr)) !== null && _renderValue !== void 0 ? _renderValue : formatDate(value, formatStr);
410
410
  }, [formatStr, formatDate, placeholder, renderValue, value]);
411
- var caretComponent = useMemo(function () {
411
+ var caretAs = useMemo(function () {
412
412
  return DateUtils.shouldOnlyTime(formatStr) ? IconClockO : IconCalendar;
413
413
  }, [formatStr]);
414
414
  return /*#__PURE__*/React.createElement(PickerToggleTrigger, {
@@ -444,7 +444,7 @@ var DatePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
444
444
  active: active,
445
445
  placement: placement,
446
446
  disabled: disabled,
447
- caretComponent: caretComponent
447
+ caretAs: caretAs
448
448
  }), renderDate())));
449
449
  });
450
450
  DatePicker.displayName = 'DatePicker';
@@ -268,6 +268,10 @@ var DateRangePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
268
268
  setHoverDateRange(nextHoverDateRange);
269
269
  }
270
270
  }, [getHoverRangeValue, hoverRange]);
271
+ /**
272
+ * Callback for selecting a date cell in the calendar grid
273
+ */
274
+
271
275
  var handleSelectDate = useCallback(function (date, event) {
272
276
  var nextSelectDates = hoverDateRange !== null && hoverDateRange !== void 0 ? hoverDateRange : [];
273
277
  var hoverRangeValue = getHoverRangeValue(date);
@@ -303,7 +307,7 @@ var DateRangePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
303
307
  nextSelectDates.reverse();
304
308
  }
305
309
 
306
- setHoverDateRange(nextSelectDates.length === 2 ? nextSelectDates : null);
310
+ setHoverDateRange(nextSelectDates.length === 2 ? nextSelectDates : [nextSelectDates[0], nextSelectDates[0]]);
307
311
  setSelectedDates(nextSelectDates);
308
312
  updateCalendarDate(nextSelectDates);
309
313
  onSelect === null || onSelect === void 0 ? void 0 : onSelect(date, event);
@@ -602,7 +606,7 @@ var DateRangePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
602
606
  hasValue: hasValue,
603
607
  active: isPickerToggleActive,
604
608
  placement: placement,
605
- caretComponent: IconCalendar,
609
+ caretAs: IconCalendar,
606
610
  disabled: disabled
607
611
  }), getDisplayString(value))));
608
612
  });
@@ -6,6 +6,7 @@ import Button from '../Button';
6
6
  import { useClassNames } from '../utils';
7
7
  import useToggleCaret from '../utils/useToggleCaret';
8
8
  import { SidenavContext } from '../Sidenav/Sidenav';
9
+ import NavContext from '../Nav/NavContext';
9
10
  var DropdownToggle = /*#__PURE__*/React.forwardRef(function (props, ref) {
10
11
  var _props$as = props.as,
11
12
  Component = _props$as === void 0 ? Button : _props$as,
@@ -22,6 +23,9 @@ var DropdownToggle = /*#__PURE__*/React.forwardRef(function (props, ref) {
22
23
 
23
24
  var sidenav = useContext(SidenavContext);
24
25
 
26
+ var _useContext = useContext(NavContext),
27
+ withinNav = _useContext.withinNav;
28
+
25
29
  var _useClassNames = useClassNames(classPrefix),
26
30
  prefix = _useClassNames.prefix,
27
31
  withClassPrefix = _useClassNames.withClassPrefix,
@@ -33,7 +37,9 @@ var DropdownToggle = /*#__PURE__*/React.forwardRef(function (props, ref) {
33
37
  var inSidenav = !!sidenav; // Caret icon is down by default, when Dropdown is used in Sidenav.
34
38
 
35
39
  var Caret = useToggleCaret(inSidenav ? 'bottomStart' : placement);
36
- var toggle = /*#__PURE__*/React.createElement(Component, _extends({}, rest, {
40
+ var toggle = /*#__PURE__*/React.createElement(Component, _extends({
41
+ appearance: withinNav ? 'subtle' : undefined
42
+ }, rest, {
37
43
  ref: ref,
38
44
  className: classes
39
45
  }), icon && /*#__PURE__*/React.cloneElement(icon, {
@@ -39,16 +39,16 @@ export declare const removeAllChildrenValue: <T>(value: T[], item: ItemType, ite
39
39
  */
40
40
  export declare function useFlattenData(data: ItemDataType[], itemKeys: ItemKeys): {
41
41
  addFlattenData: (children: ItemDataType[], parent: ItemDataType) => void;
42
- flattenData: ItemDataType[];
42
+ flattenData: ItemDataType<string | number>[];
43
43
  };
44
44
  /**
45
45
  * A hook for column data
46
46
  * @param flattenData
47
47
  */
48
48
  export declare function useColumnData(flattenData: ItemType[]): {
49
- columnData: ItemDataType[][];
49
+ columnData: ItemDataType<string | number>[][];
50
50
  addColumn: (column: ItemDataType[], index: number) => void;
51
- setColumnData: import("react").Dispatch<import("react").SetStateAction<ItemDataType[][]>>;
51
+ setColumnData: import("react").Dispatch<import("react").SetStateAction<ItemDataType<string | number>[][]>>;
52
52
  enforceUpdateColumnData: (nextData: ItemDataType[]) => void;
53
53
  };
54
54
  /**
package/esm/Nav/Nav.js CHANGED
@@ -59,6 +59,7 @@ var Nav = /*#__PURE__*/React.forwardRef(function (props, ref) {
59
59
  if (sidenav !== null && sidenav !== void 0 && sidenav.expanded) {
60
60
  return /*#__PURE__*/React.createElement(NavContext.Provider, {
61
61
  value: {
62
+ withinNav: true,
62
63
  activeKey: activeKey,
63
64
  onSelect: onSelectProp !== null && onSelectProp !== void 0 ? onSelectProp : onSelectFromSidenav
64
65
  }
@@ -73,6 +74,7 @@ var Nav = /*#__PURE__*/React.forwardRef(function (props, ref) {
73
74
  if (sidenav) {
74
75
  return /*#__PURE__*/React.createElement(NavContext.Provider, {
75
76
  value: {
77
+ withinNav: true,
76
78
  activeKey: activeKey,
77
79
  onSelect: onSelectProp !== null && onSelectProp !== void 0 ? onSelectProp : onSelectFromSidenav
78
80
  }
@@ -89,6 +91,7 @@ var Nav = /*#__PURE__*/React.forwardRef(function (props, ref) {
89
91
 
90
92
  return /*#__PURE__*/React.createElement(NavContext.Provider, {
91
93
  value: {
94
+ withinNav: true,
92
95
  activeKey: activeKey,
93
96
  onSelect: onSelectProp !== null && onSelectProp !== void 0 ? onSelectProp : onSelectFromSidenav
94
97
  }
@@ -1,5 +1,11 @@
1
1
  import React from 'react';
2
2
  export interface NavContextProps {
3
+ /**
4
+ * Whether component is rendered within a <Nav>
5
+ *
6
+ * FIXME: Bad design. Should use NavContextProps | null to determin whether within a <Nav>
7
+ */
8
+ withinNav: boolean;
3
9
  activeKey: string | null;
4
10
  onSelect?: (eventKey: string | undefined, event: React.SyntheticEvent) => void;
5
11
  }
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  import noop from 'lodash/noop';
3
3
  var NavContext = /*#__PURE__*/React.createContext({
4
+ withinNav: false,
4
5
  activeKey: null,
5
6
  onSelect: noop
6
7
  });
@@ -3,14 +3,14 @@ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWith
3
3
  import React, { useRef, useEffect, useState, useCallback } from 'react';
4
4
  import PropTypes from 'prop-types';
5
5
  import classNames from 'classnames';
6
- import canUseDOM from 'dom-lib/canUseDOM';
7
6
  import contains from 'dom-lib/contains';
8
7
  import getContainer from 'dom-lib/getContainer';
9
8
  import on from 'dom-lib/on';
10
9
  import ModalManager from './ModalManager';
11
10
  import Fade from '../Animation/Fade';
12
11
  import { animationPropTypes } from '../Animation/utils';
13
- import { mergeRefs, usePortal, createChainedFunction, useWillUnmount, KEY_VALUES } from '../utils';
12
+ import { mergeRefs, usePortal, createChainedFunction, useWillUnmount, useEventCallback, KEY_VALUES } from '../utils';
13
+ import OverlayContext from './OverlayContext';
14
14
  var manager;
15
15
 
16
16
  function getManager() {
@@ -103,12 +103,12 @@ var Modal = /*#__PURE__*/React.forwardRef(function (props, ref) {
103
103
 
104
104
  var mountModal = open || Transition && !exited;
105
105
  var lastFocus = useRef(null);
106
- var handleDocumentKeyDown = useCallback(function (event) {
106
+ var handleDocumentKeyDown = useEventCallback(function (event) {
107
107
  if (keyboard && event.key === KEY_VALUES.ESC && modal.isTopModal()) {
108
108
  onEsc === null || onEsc === void 0 ? void 0 : onEsc(event);
109
109
  onClose === null || onClose === void 0 ? void 0 : onClose(event);
110
110
  }
111
- }, [keyboard, modal, onEsc, onClose]);
111
+ });
112
112
  var restoreLastFocus = useCallback(function () {
113
113
  if (lastFocus.current) {
114
114
  var _lastFocus$current$fo, _lastFocus$current;
@@ -117,19 +117,29 @@ var Modal = /*#__PURE__*/React.forwardRef(function (props, ref) {
117
117
  lastFocus.current = null;
118
118
  }
119
119
  }, []);
120
- var handleEnforceFocus = useCallback(function () {
121
- if (!enforceFocus || !modal.isTopModal()) {
122
- return;
123
- }
120
+ /**
121
+ * Determines if the currently focused element is inside the dialog,
122
+ * and if not, returns the focus to the dialog.
123
+ *
124
+ */
124
125
 
126
+ var handleFocusDialog = useEventCallback(function (onBeforeFocusCallback) {
125
127
  var currentActiveElement = document.activeElement;
126
128
  var dialog = modal.dialog;
127
129
 
128
- if (dialog && dialog !== currentActiveElement && !contains(dialog, currentActiveElement)) {
130
+ if (dialog && currentActiveElement && !contains(dialog, currentActiveElement)) {
131
+ onBeforeFocusCallback === null || onBeforeFocusCallback === void 0 ? void 0 : onBeforeFocusCallback();
129
132
  dialog.focus();
130
133
  }
131
- }, [enforceFocus, modal]);
132
- var handleBackdropClick = useCallback(function (event) {
134
+ });
135
+ var handleEnforceFocus = useEventCallback(function () {
136
+ if (!enforceFocus || !modal.isTopModal()) {
137
+ return;
138
+ }
139
+
140
+ handleFocusDialog();
141
+ });
142
+ var handleBackdropClick = useEventCallback(function (event) {
133
143
  if (event.target !== event.currentTarget) {
134
144
  return;
135
145
  }
@@ -139,10 +149,10 @@ var Modal = /*#__PURE__*/React.forwardRef(function (props, ref) {
139
149
  if (backdrop === true) {
140
150
  onClose === null || onClose === void 0 ? void 0 : onClose(event);
141
151
  }
142
- }, [backdrop, onBackdropClick, onClose]);
152
+ });
143
153
  var documentKeyDownListener = useRef();
144
154
  var documentFocusListener = useRef();
145
- var handleOpen = useCallback(function () {
155
+ var handleOpen = useEventCallback(function () {
146
156
  var containerElement = getContainer(container, document.body);
147
157
  modal.add(containerElement, containerClassName);
148
158
 
@@ -154,19 +164,15 @@ var Modal = /*#__PURE__*/React.forwardRef(function (props, ref) {
154
164
  documentFocusListener.current = on(document, 'focus', handleEnforceFocus, true);
155
165
  }
156
166
 
157
- if (canUseDOM) {
158
- lastFocus.current = document.activeElement;
159
- }
160
-
161
167
  if (autoFocus) {
162
- var _modal$dialog;
163
-
164
- (_modal$dialog = modal.dialog) === null || _modal$dialog === void 0 ? void 0 : _modal$dialog.focus();
168
+ handleFocusDialog(function () {
169
+ lastFocus.current = document.activeElement;
170
+ });
165
171
  }
166
172
 
167
173
  onOpen === null || onOpen === void 0 ? void 0 : onOpen();
168
- }, [autoFocus, container, containerClassName, handleDocumentKeyDown, handleEnforceFocus, modal, onOpen]);
169
- var handleClose = useCallback(function () {
174
+ });
175
+ var handleClose = useEventCallback(function () {
170
176
  var _documentKeyDownListe, _documentFocusListene;
171
177
 
172
178
  modal.remove();
@@ -175,7 +181,7 @@ var Modal = /*#__PURE__*/React.forwardRef(function (props, ref) {
175
181
  (_documentFocusListene = documentFocusListener.current) === null || _documentFocusListene === void 0 ? void 0 : _documentFocusListene.off();
176
182
  documentFocusListener.current = null;
177
183
  restoreLastFocus();
178
- }, [modal, restoreLastFocus]);
184
+ });
179
185
  useEffect(function () {
180
186
  if (!open) {
181
187
  return;
@@ -244,12 +250,18 @@ var Modal = /*#__PURE__*/React.forwardRef(function (props, ref) {
244
250
  onEntering: onEntering,
245
251
  onEntered: onEntered
246
252
  }), children) : children;
247
- return /*#__PURE__*/React.createElement(Portal, null, /*#__PURE__*/React.createElement(Component, _extends({}, rest, {
253
+ return /*#__PURE__*/React.createElement(OverlayContext.Provider, {
254
+ value: {
255
+ overlayContainer: function overlayContainer() {
256
+ return modal.dialog;
257
+ }
258
+ }
259
+ }, /*#__PURE__*/React.createElement(Portal, null, /*#__PURE__*/React.createElement(Component, _extends({}, rest, {
248
260
  ref: mergeRefs(modal.setDialogRef, ref),
249
261
  style: style,
250
262
  className: className,
251
263
  tabIndex: -1
252
- }), backdrop && renderBackdrop(), dialogElement));
264
+ }), backdrop && renderBackdrop(), dialogElement)));
253
265
  });
254
266
  export var modalPropTypes = {
255
267
  as: PropTypes.elementType,
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import { TypeAttributes, AnimationEventProps } from '../@types/common';
4
4
  export interface OverlayProps extends AnimationEventProps {
5
- container?: HTMLElement | (() => HTMLElement);
5
+ container?: HTMLElement | (() => HTMLElement | null) | null;
6
6
  children: React.ReactElement | ((props: any, ref: any) => React.ReactElement);
7
7
  childrenProps?: React.HTMLAttributes<HTMLElement>;
8
8
  className?: string;
@@ -1,10 +1,11 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
- import React, { useState, useRef, useCallback } from 'react';
2
+ import React, { useState, useRef, useCallback, useContext } from 'react';
3
3
  import classNames from 'classnames';
4
4
  import PropTypes from 'prop-types';
5
5
  import Position from './Position';
6
6
  import { mergeRefs, useRootClose } from '../utils';
7
7
  import Fade from '../Animation/Fade';
8
+ import OverlayContext from './OverlayContext';
8
9
  export var overlayPropTypes = {
9
10
  container: PropTypes.any,
10
11
  children: PropTypes.any,
@@ -26,7 +27,11 @@ export var overlayPropTypes = {
26
27
  onExited: PropTypes.func
27
28
  };
28
29
  var Overlay = /*#__PURE__*/React.forwardRef(function (props, ref) {
29
- var container = props.container,
30
+ var _useContext = useContext(OverlayContext),
31
+ overlayContainer = _useContext.overlayContainer;
32
+
33
+ var _props$container = props.container,
34
+ container = _props$container === void 0 ? overlayContainer : _props$container,
30
35
  containerPadding = props.containerPadding,
31
36
  placement = props.placement,
32
37
  rootClose = props.rootClose,
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ export interface OverlayContextProps {
3
+ overlayContainer?: () => HTMLElement | null;
4
+ }
5
+ declare const OverlayContext: React.Context<OverlayContextProps>;
6
+ export default OverlayContext;
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ var OverlayContext = /*#__PURE__*/React.createContext({});
3
+ OverlayContext.displayName = 'OverlayContext';
4
+ export default OverlayContext;
@@ -1,13 +1,14 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
3
  import _isUndefined from "lodash/isUndefined";
4
- import React, { useRef, useEffect, useImperativeHandle, useCallback } from 'react';
4
+ import React, { useRef, useEffect, useImperativeHandle, useCallback, useContext } from 'react';
5
5
  import get from 'lodash/get';
6
6
  import isNil from 'lodash/isNil';
7
7
  import contains from 'dom-lib/contains';
8
8
  import Overlay from './Overlay';
9
9
  import { createChainedFunction, usePortal, useControlled } from '../utils';
10
10
  import isOneOf from '../utils/isOneOf';
11
+ import OverlayContext from './OverlayContext';
11
12
 
12
13
  function mergeEvents(events, props) {
13
14
  if (events === void 0) {
@@ -47,8 +48,12 @@ function onMouseEventHandler(handler, event, delay) {
47
48
 
48
49
  var defaultTrigger = ['hover', 'focus'];
49
50
  var OverlayTrigger = /*#__PURE__*/React.forwardRef(function (props, ref) {
51
+ var _useContext = useContext(OverlayContext),
52
+ overlayContainer = _useContext.overlayContainer;
53
+
50
54
  var children = props.children,
51
- container = props.container,
55
+ _props$container = props.container,
56
+ container = _props$container === void 0 ? overlayContainer : _props$container,
52
57
  controlId = props.controlId,
53
58
  defaultOpen = props.defaultOpen,
54
59
  _props$trigger = props.trigger,
@@ -8,7 +8,7 @@ export interface PositionChildProps {
8
8
  export interface PositionProps {
9
9
  children: (props: PositionChildProps, ref: any) => React.ReactElement;
10
10
  className?: string;
11
- container?: HTMLElement | (() => HTMLElement);
11
+ container?: HTMLElement | (() => HTMLElement | null) | null;
12
12
  containerPadding?: number;
13
13
  placement?: TypeAttributes.Placement;
14
14
  preventOverflow?: boolean;
@@ -9,7 +9,6 @@ export declare const pickerPropTypes: {
9
9
  containerPadding: PropTypes.Requireable<number>;
10
10
  container: PropTypes.Requireable<any>;
11
11
  disabled: PropTypes.Requireable<boolean>;
12
- toggleAs: PropTypes.Requireable<PropTypes.ReactComponentLike>;
13
12
  menuClassName: PropTypes.Requireable<string>;
14
13
  menuStyle: PropTypes.Requireable<object>;
15
14
  placeholder: PropTypes.Requireable<PropTypes.ReactNodeLike>;
@@ -26,7 +25,7 @@ export declare const pickerPropTypes: {
26
25
  onOpen: PropTypes.Requireable<(...args: any[]) => any>;
27
26
  onClose: PropTypes.Requireable<(...args: any[]) => any>;
28
27
  onClean: PropTypes.Requireable<(...args: any[]) => any>;
29
- listProps: PropTypes.Requireable<object>;
28
+ listProps: PropTypes.Requireable<any>;
30
29
  onEnter: PropTypes.Requireable<(...args: any[]) => any>;
31
30
  onEntering: PropTypes.Requireable<(...args: any[]) => any>;
32
31
  onEntered: PropTypes.Requireable<(...args: any[]) => any>;
@@ -35,7 +34,7 @@ export declare const pickerPropTypes: {
35
34
  onExited: PropTypes.Requireable<(...args: any[]) => any>;
36
35
  };
37
36
  export declare const listPickerPropTypes: {
38
- data: PropTypes.Requireable<any[]>;
37
+ data: PropTypes.Validator<any[]>;
39
38
  valueKey: PropTypes.Requireable<string>;
40
39
  labelKey: PropTypes.Requireable<string>;
41
40
  childrenKey: PropTypes.Requireable<string>;
@@ -52,7 +51,6 @@ export declare const listPickerPropTypes: {
52
51
  containerPadding: PropTypes.Requireable<number>;
53
52
  container: PropTypes.Requireable<any>;
54
53
  disabled: PropTypes.Requireable<boolean>;
55
- toggleAs: PropTypes.Requireable<PropTypes.ReactComponentLike>;
56
54
  menuClassName: PropTypes.Requireable<string>;
57
55
  menuStyle: PropTypes.Requireable<object>;
58
56
  placeholder: PropTypes.Requireable<PropTypes.ReactNodeLike>;
@@ -69,7 +67,7 @@ export declare const listPickerPropTypes: {
69
67
  onOpen: PropTypes.Requireable<(...args: any[]) => any>;
70
68
  onClose: PropTypes.Requireable<(...args: any[]) => any>;
71
69
  onClean: PropTypes.Requireable<(...args: any[]) => any>;
72
- listProps: PropTypes.Requireable<object>;
70
+ listProps: PropTypes.Requireable<any>;
73
71
  onEnter: PropTypes.Requireable<(...args: any[]) => any>;
74
72
  onEntering: PropTypes.Requireable<(...args: any[]) => any>;
75
73
  onEntered: PropTypes.Requireable<(...args: any[]) => any>;
@@ -12,7 +12,8 @@ export var pickerPropTypes = _extends({}, animationPropTypes, {
12
12
  containerPadding: PropTypes.number,
13
13
  container: PropTypes.oneOfType([PropTypes.any, PropTypes.func]),
14
14
  disabled: PropTypes.bool,
15
- toggleAs: PropTypes.elementType,
15
+ // PropTypes.elementType conflictin with React.ElementType
16
+ // toggleAs: PropTypes.elementType,
16
17
  menuClassName: PropTypes.string,
17
18
  menuStyle: PropTypes.object,
18
19
  placeholder: PropTypes.node,
@@ -30,10 +31,10 @@ export var pickerPropTypes = _extends({}, animationPropTypes, {
30
31
  onOpen: PropTypes.func,
31
32
  onClose: PropTypes.func,
32
33
  onClean: PropTypes.func,
33
- listProps: PropTypes.object
34
+ listProps: PropTypes.any
34
35
  });
35
36
  export var listPickerPropTypes = _extends({}, pickerPropTypes, {
36
- data: PropTypes.array,
37
+ data: PropTypes.array.isRequired,
37
38
  valueKey: PropTypes.string,
38
39
  labelKey: PropTypes.string,
39
40
  childrenKey: PropTypes.string,
@@ -56,13 +56,13 @@ interface FocusItemValueProps {
56
56
  * @param defaultFocusItemValue
57
57
  * @param props
58
58
  */
59
- export declare const useFocusItemValue: <T extends string | number>(defaultFocusItemValue: T | null | undefined, props: FocusItemValueProps) => {
59
+ export declare const useFocusItemValue: <T>(defaultFocusItemValue: T | null | undefined, props: FocusItemValueProps) => {
60
60
  focusItemValue: T | null | undefined;
61
61
  setFocusItemValue: React.Dispatch<React.SetStateAction<T | null | undefined>>;
62
62
  layer: number;
63
63
  setLayer: React.Dispatch<React.SetStateAction<number>>;
64
- keys: (string | undefined)[];
65
- setKeys: React.Dispatch<React.SetStateAction<(string | undefined)[]>>;
64
+ keys: any[];
65
+ setKeys: React.Dispatch<React.SetStateAction<any[]>>;
66
66
  onKeyDown: (event: any) => void;
67
67
  };
68
68
  interface ToggleKeyDownEventProps {
@@ -1,10 +1,8 @@
1
1
  import React from 'react';
2
2
  import { PickerLocale } from '../locales';
3
- import { PickerComponent } from '../Picker';
4
3
  import { FormControlPickerProps, ItemDataType } from '../@types/common';
5
4
  import { ListProps } from 'react-virtualized/dist/commonjs/List';
6
- export declare type ValueType = number | string;
7
- export interface SelectProps<T = ValueType> {
5
+ export interface SelectProps<T> {
8
6
  /** Set group condition key in data */
9
7
  groupBy?: string;
10
8
  /** Whether dispaly search input box */
@@ -37,7 +35,16 @@ export interface SelectProps<T = ValueType> {
37
35
  /** Called when clean */
38
36
  onClean?: (event: React.SyntheticEvent) => void;
39
37
  }
40
- export interface SelectPickerProps<T = ValueType> extends FormControlPickerProps<T, PickerLocale, ItemDataType>, SelectProps<T> {
38
+ export interface MultipleSelectProps<T> extends Omit<SelectProps<T>, 'renderValue'> {
39
+ /** Custom render selected items */
40
+ renderValue?: (value: T[], item: ItemDataType<T>[], selectedElement: React.ReactNode) => React.ReactNode;
41
+ }
42
+ export interface SelectPickerProps<T> extends FormControlPickerProps<T, PickerLocale, ItemDataType<T>>, SelectProps<T> {
43
+ }
44
+ export interface SelectPickerComponent {
45
+ <T>(props: SelectPickerProps<T>): JSX.Element | null;
46
+ displayName?: string;
47
+ propTypes?: React.WeakValidationMap<SelectPickerProps<any>>;
41
48
  }
42
- declare const SelectPicker: PickerComponent<SelectPickerProps>;
49
+ declare const SelectPicker: SelectPickerComponent;
43
50
  export default SelectPicker;