rsuite 5.3.0 → 5.4.3
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.
- package/Button/styles/index.less +1 -5
- package/CHANGELOG.md +53 -0
- package/Drawer/styles/index.less +3 -0
- package/Dropdown/styles/index.less +5 -3
- package/Dropdown/styles/mixin.less +0 -2
- package/Modal/styles/index.less +23 -22
- package/Nav/styles/index.less +1 -0
- package/Navbar/styles/index.less +27 -8
- package/Radio/styles/index.less +6 -0
- package/Sidenav/styles/index.less +8 -2
- package/Stack/package.json +7 -0
- package/Stack/styles/index.less +5 -0
- package/TreePicker/styles/index.less +0 -14
- package/cjs/@types/common.d.ts +4 -4
- package/cjs/Affix/Affix.js +3 -1
- package/cjs/AvatarGroup/AvatarGroup.js +9 -4
- package/cjs/ButtonGroup/ButtonGroup.js +9 -4
- package/cjs/Calendar/Calendar.js +21 -20
- package/cjs/Calendar/Header.js +1 -3
- package/cjs/Calendar/Table.js +1 -1
- package/cjs/Calendar/TableRow.js +12 -7
- package/cjs/Calendar/View.js +9 -5
- package/cjs/Cascader/utils.d.ts +7 -7
- package/cjs/CheckPicker/CheckPicker.d.ts +12 -4
- package/cjs/CheckPicker/test/CheckPicker.test.d.ts +1 -0
- package/cjs/CheckPicker/test/CheckPicker.test.js +84 -0
- package/cjs/CheckTree/index.js +6 -5
- package/cjs/Container/Container.js +6 -3
- package/cjs/DatePicker/DatePicker.js +4 -2
- package/cjs/DateRangePicker/DateRangePicker.js +9 -5
- package/cjs/Disclosure/Disclosure.d.ts +8 -5
- package/cjs/Disclosure/Disclosure.js +51 -11
- package/cjs/Disclosure/DisclosureButton.d.ts +2 -2
- package/cjs/Disclosure/DisclosureContext.d.ts +6 -1
- package/cjs/Dropdown/Dropdown.js +1 -1
- package/cjs/Dropdown/DropdownItem.js +9 -10
- package/cjs/Dropdown/DropdownMenu.js +81 -23
- package/cjs/Dropdown/DropdownToggle.js +8 -1
- package/cjs/FormGroup/FormGroup.js +9 -4
- package/cjs/Menu/MenuItem.js +1 -1
- package/cjs/Modal/Modal.js +34 -22
- package/cjs/MultiCascader/utils.d.ts +3 -3
- package/cjs/Nav/Nav.js +10 -12
- package/cjs/Nav/NavContext.d.ts +6 -0
- package/cjs/Nav/NavContext.js +1 -0
- package/cjs/Navbar/index.d.ts +1 -0
- package/cjs/Navbar/index.js +4 -3
- package/cjs/Overlay/Modal.js +43 -45
- package/cjs/Overlay/Overlay.d.ts +1 -1
- package/cjs/Overlay/Overlay.js +7 -1
- package/cjs/Overlay/OverlayContext.d.ts +6 -0
- package/cjs/Overlay/OverlayContext.js +14 -0
- package/cjs/Overlay/OverlayTrigger.js +7 -1
- package/cjs/Overlay/Position.d.ts +1 -1
- package/cjs/PanelGroup/PanelGroup.js +8 -5
- package/cjs/Picker/propTypes.d.ts +3 -5
- package/cjs/Picker/propTypes.js +4 -3
- package/cjs/Picker/utils.d.ts +3 -3
- package/cjs/SelectPicker/SelectPicker.d.ts +16 -6
- package/cjs/SelectPicker/SelectPicker.js +4 -4
- package/cjs/SelectPicker/index.d.ts +1 -1
- package/cjs/SelectPicker/test/SelectPicker.test.d.ts +1 -0
- package/cjs/SelectPicker/test/SelectPicker.test.js +70 -0
- package/cjs/Stack/Stack.d.ts +26 -0
- package/cjs/Stack/Stack.js +86 -0
- package/cjs/Stack/index.d.ts +3 -0
- package/cjs/Stack/index.js +11 -0
- package/cjs/Steps/StepItem.js +2 -2
- package/cjs/Toggle/Toggle.js +4 -3
- package/cjs/Tree/Tree.d.ts +0 -1
- package/cjs/Tree/Tree.js +6 -5
- package/cjs/Tree/TreeContext.d.ts +0 -1
- package/cjs/TreePicker/TreeNode.js +1 -14
- package/cjs/TreePicker/TreePicker.js +3 -29
- package/cjs/index.d.ts +4 -2
- package/cjs/index.js +9 -5
- package/cjs/utils/index.d.ts +1 -0
- package/cjs/utils/index.js +7 -2
- package/cjs/utils/treeUtils.d.ts +5 -5
- package/cjs/utils/useMount.d.ts +2 -0
- package/cjs/utils/useMount.js +19 -0
- package/cjs/utils/usePortal.d.ts +1 -1
- package/dist/rsuite-rtl.css +351 -188
- package/dist/rsuite-rtl.min.css +1 -1
- package/dist/rsuite-rtl.min.css.map +1 -1
- package/dist/rsuite.css +351 -188
- package/dist/rsuite.js +94 -39
- package/dist/rsuite.js.map +1 -1
- package/dist/rsuite.min.css +1 -1
- package/dist/rsuite.min.css.map +1 -1
- package/dist/rsuite.min.js +1 -1
- package/dist/rsuite.min.js.map +1 -1
- package/esm/@types/common.d.ts +4 -4
- package/esm/Affix/Affix.js +4 -2
- package/esm/AvatarGroup/AvatarGroup.js +7 -4
- package/esm/ButtonGroup/ButtonGroup.js +7 -4
- package/esm/Calendar/Calendar.js +22 -21
- package/esm/Calendar/Header.js +1 -3
- package/esm/Calendar/Table.js +1 -1
- package/esm/Calendar/TableRow.js +13 -8
- package/esm/Calendar/View.js +10 -6
- package/esm/Cascader/utils.d.ts +7 -7
- package/esm/CheckPicker/CheckPicker.d.ts +12 -4
- package/esm/CheckPicker/test/CheckPicker.test.d.ts +1 -0
- package/esm/CheckPicker/test/CheckPicker.test.js +71 -0
- package/esm/CheckTree/index.js +7 -6
- package/esm/Container/Container.js +7 -4
- package/esm/DatePicker/DatePicker.js +4 -2
- package/esm/DateRangePicker/DateRangePicker.js +9 -5
- package/esm/Disclosure/Disclosure.d.ts +8 -5
- package/esm/Disclosure/Disclosure.js +52 -13
- package/esm/Disclosure/DisclosureButton.d.ts +2 -2
- package/esm/Disclosure/DisclosureContext.d.ts +6 -1
- package/esm/Dropdown/Dropdown.js +1 -1
- package/esm/Dropdown/DropdownItem.js +9 -9
- package/esm/Dropdown/DropdownMenu.js +82 -24
- package/esm/Dropdown/DropdownToggle.js +7 -1
- package/esm/FormGroup/FormGroup.js +7 -4
- package/esm/Menu/MenuItem.js +1 -1
- package/esm/Modal/Modal.js +36 -24
- package/esm/MultiCascader/utils.d.ts +3 -3
- package/esm/Nav/Nav.js +11 -13
- package/esm/Nav/NavContext.d.ts +6 -0
- package/esm/Nav/NavContext.js +1 -0
- package/esm/Navbar/index.d.ts +1 -0
- package/esm/Navbar/index.js +1 -0
- package/esm/Overlay/Modal.js +44 -46
- package/esm/Overlay/Overlay.d.ts +1 -1
- package/esm/Overlay/Overlay.js +7 -2
- package/esm/Overlay/OverlayContext.d.ts +6 -0
- package/esm/Overlay/OverlayContext.js +4 -0
- package/esm/Overlay/OverlayTrigger.js +7 -2
- package/esm/Overlay/Position.d.ts +1 -1
- package/esm/PanelGroup/PanelGroup.js +9 -6
- package/esm/Picker/propTypes.d.ts +3 -5
- package/esm/Picker/propTypes.js +4 -3
- package/esm/Picker/utils.d.ts +3 -3
- package/esm/SelectPicker/SelectPicker.d.ts +16 -6
- package/esm/SelectPicker/SelectPicker.js +4 -4
- package/esm/SelectPicker/index.d.ts +1 -1
- package/esm/SelectPicker/test/SelectPicker.test.d.ts +1 -0
- package/esm/SelectPicker/test/SelectPicker.test.js +59 -0
- package/esm/Stack/Stack.d.ts +26 -0
- package/esm/Stack/Stack.js +71 -0
- package/esm/Stack/index.d.ts +3 -0
- package/esm/Stack/index.js +2 -0
- package/esm/Steps/StepItem.js +2 -2
- package/esm/Toggle/Toggle.js +4 -3
- package/esm/Tree/Tree.d.ts +0 -1
- package/esm/Tree/Tree.js +7 -6
- package/esm/Tree/TreeContext.d.ts +0 -1
- package/esm/TreePicker/TreeNode.js +2 -14
- package/esm/TreePicker/TreePicker.js +3 -29
- package/esm/index.d.ts +4 -2
- package/esm/index.js +2 -1
- package/esm/utils/index.d.ts +1 -0
- package/esm/utils/index.js +2 -1
- package/esm/utils/treeUtils.d.ts +5 -5
- package/esm/utils/useMount.d.ts +2 -0
- package/esm/utils/useMount.js +13 -0
- package/esm/utils/usePortal.d.ts +1 -1
- package/package.json +2 -2
- package/styles/color-modes/dark.less +1 -0
- package/styles/color-modes/high-contrast.less +1 -0
- package/styles/color-modes/light.less +1 -0
- package/styles/index.less +1 -0
- package/styles/mixins/utilities.less +17 -5
package/esm/Overlay/Modal.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
import React, { useRef, useEffect, useState, useCallback } from 'react';
|
|
3
|
+
import React, { useRef, useEffect, useState, useCallback, useMemo } 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() {
|
|
@@ -72,7 +72,6 @@ var Modal = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
72
72
|
open = props.open,
|
|
73
73
|
_props$autoFocus = props.autoFocus,
|
|
74
74
|
autoFocus = _props$autoFocus === void 0 ? true : _props$autoFocus,
|
|
75
|
-
onBackdropClick = props.onBackdropClick,
|
|
76
75
|
onEsc = props.onEsc,
|
|
77
76
|
onExit = props.onExit,
|
|
78
77
|
onExiting = props.onExiting,
|
|
@@ -82,7 +81,7 @@ var Modal = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
82
81
|
onEntered = props.onEntered,
|
|
83
82
|
onClose = props.onClose,
|
|
84
83
|
onOpen = props.onOpen,
|
|
85
|
-
rest = _objectWithoutPropertiesLoose(props, ["as", "children", "transition", "dialogTransitionTimeout", "style", "className", "container", "animationProps", "containerClassName", "keyboard", "enforceFocus", "backdrop", "backdropTransitionTimeout", "backdropStyle", "backdropClassName", "open", "autoFocus", "
|
|
84
|
+
rest = _objectWithoutPropertiesLoose(props, ["as", "children", "transition", "dialogTransitionTimeout", "style", "className", "container", "animationProps", "containerClassName", "keyboard", "enforceFocus", "backdrop", "backdropTransitionTimeout", "backdropStyle", "backdropClassName", "open", "autoFocus", "onEsc", "onExit", "onExiting", "onExited", "onEnter", "onEntering", "onEntered", "onClose", "onOpen"]);
|
|
86
85
|
|
|
87
86
|
var _useState = useState(!open),
|
|
88
87
|
exited = _useState[0],
|
|
@@ -103,12 +102,12 @@ var Modal = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
103
102
|
|
|
104
103
|
var mountModal = open || Transition && !exited;
|
|
105
104
|
var lastFocus = useRef(null);
|
|
106
|
-
var handleDocumentKeyDown =
|
|
105
|
+
var handleDocumentKeyDown = useEventCallback(function (event) {
|
|
107
106
|
if (keyboard && event.key === KEY_VALUES.ESC && modal.isTopModal()) {
|
|
108
107
|
onEsc === null || onEsc === void 0 ? void 0 : onEsc(event);
|
|
109
108
|
onClose === null || onClose === void 0 ? void 0 : onClose(event);
|
|
110
109
|
}
|
|
111
|
-
}
|
|
110
|
+
});
|
|
112
111
|
var restoreLastFocus = useCallback(function () {
|
|
113
112
|
if (lastFocus.current) {
|
|
114
113
|
var _lastFocus$current$fo, _lastFocus$current;
|
|
@@ -117,32 +116,31 @@ var Modal = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
117
116
|
lastFocus.current = null;
|
|
118
117
|
}
|
|
119
118
|
}, []);
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
119
|
+
/**
|
|
120
|
+
* Determines if the currently focused element is inside the dialog,
|
|
121
|
+
* and if not, returns the focus to the dialog.
|
|
122
|
+
*
|
|
123
|
+
*/
|
|
124
124
|
|
|
125
|
+
var handleFocusDialog = useEventCallback(function (onBeforeFocusCallback) {
|
|
125
126
|
var currentActiveElement = document.activeElement;
|
|
126
127
|
var dialog = modal.dialog;
|
|
127
128
|
|
|
128
|
-
if (dialog &&
|
|
129
|
+
if (dialog && currentActiveElement && !contains(dialog, currentActiveElement)) {
|
|
130
|
+
onBeforeFocusCallback === null || onBeforeFocusCallback === void 0 ? void 0 : onBeforeFocusCallback();
|
|
129
131
|
dialog.focus();
|
|
130
132
|
}
|
|
131
|
-
}
|
|
132
|
-
var
|
|
133
|
-
if (
|
|
133
|
+
});
|
|
134
|
+
var handleEnforceFocus = useEventCallback(function () {
|
|
135
|
+
if (!enforceFocus || !modal.isTopModal()) {
|
|
134
136
|
return;
|
|
135
137
|
}
|
|
136
138
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
if (backdrop === true) {
|
|
140
|
-
onClose === null || onClose === void 0 ? void 0 : onClose(event);
|
|
141
|
-
}
|
|
142
|
-
}, [backdrop, onBackdropClick, onClose]);
|
|
139
|
+
handleFocusDialog();
|
|
140
|
+
});
|
|
143
141
|
var documentKeyDownListener = useRef();
|
|
144
142
|
var documentFocusListener = useRef();
|
|
145
|
-
var handleOpen =
|
|
143
|
+
var handleOpen = useEventCallback(function () {
|
|
146
144
|
var containerElement = getContainer(container, document.body);
|
|
147
145
|
modal.add(containerElement, containerClassName);
|
|
148
146
|
|
|
@@ -154,19 +152,15 @@ var Modal = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
154
152
|
documentFocusListener.current = on(document, 'focus', handleEnforceFocus, true);
|
|
155
153
|
}
|
|
156
154
|
|
|
157
|
-
if (canUseDOM) {
|
|
158
|
-
lastFocus.current = document.activeElement;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
155
|
if (autoFocus) {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
156
|
+
handleFocusDialog(function () {
|
|
157
|
+
lastFocus.current = document.activeElement;
|
|
158
|
+
});
|
|
165
159
|
}
|
|
166
160
|
|
|
167
161
|
onOpen === null || onOpen === void 0 ? void 0 : onOpen();
|
|
168
|
-
}
|
|
169
|
-
var handleClose =
|
|
162
|
+
});
|
|
163
|
+
var handleClose = useEventCallback(function () {
|
|
170
164
|
var _documentKeyDownListe, _documentFocusListene;
|
|
171
165
|
|
|
172
166
|
modal.remove();
|
|
@@ -175,7 +169,7 @@ var Modal = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
175
169
|
(_documentFocusListene = documentFocusListener.current) === null || _documentFocusListene === void 0 ? void 0 : _documentFocusListene.off();
|
|
176
170
|
documentFocusListener.current = null;
|
|
177
171
|
restoreLastFocus();
|
|
178
|
-
}
|
|
172
|
+
});
|
|
179
173
|
useEffect(function () {
|
|
180
174
|
if (!open) {
|
|
181
175
|
return;
|
|
@@ -196,17 +190,19 @@ var Modal = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
196
190
|
var handleExited = useCallback(function () {
|
|
197
191
|
setExited(true);
|
|
198
192
|
}, []);
|
|
193
|
+
var contextValue = useMemo(function () {
|
|
194
|
+
return {
|
|
195
|
+
overlayContainer: function overlayContainer() {
|
|
196
|
+
return modal.dialog;
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
}, [modal.dialog]);
|
|
199
200
|
|
|
200
201
|
if (!mountModal) {
|
|
201
202
|
return null;
|
|
202
203
|
}
|
|
203
204
|
|
|
204
205
|
var renderBackdrop = function renderBackdrop() {
|
|
205
|
-
var backdropPorps = {
|
|
206
|
-
style: backdropStyle,
|
|
207
|
-
onClick: handleBackdropClick
|
|
208
|
-
};
|
|
209
|
-
|
|
210
206
|
if (Transition) {
|
|
211
207
|
return /*#__PURE__*/React.createElement(Fade, {
|
|
212
208
|
transitionAppear: true,
|
|
@@ -218,18 +214,19 @@ var Modal = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
218
214
|
|
|
219
215
|
return /*#__PURE__*/React.createElement("div", _extends({
|
|
220
216
|
"aria-hidden": true
|
|
221
|
-
}, rest,
|
|
217
|
+
}, rest, {
|
|
218
|
+
style: backdropStyle,
|
|
222
219
|
ref: mergeRefs(modal.setBackdropRef, ref),
|
|
223
220
|
className: classNames(backdropClassName, className)
|
|
224
221
|
}));
|
|
225
222
|
});
|
|
226
223
|
}
|
|
227
224
|
|
|
228
|
-
return /*#__PURE__*/React.createElement("div",
|
|
229
|
-
"aria-hidden": true
|
|
230
|
-
|
|
225
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
226
|
+
"aria-hidden": true,
|
|
227
|
+
style: backdropStyle,
|
|
231
228
|
className: backdropClassName
|
|
232
|
-
})
|
|
229
|
+
});
|
|
233
230
|
};
|
|
234
231
|
|
|
235
232
|
var dialogElement = Transition ? /*#__PURE__*/React.createElement(Transition, _extends({}, animationProps, {
|
|
@@ -244,12 +241,14 @@ var Modal = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
244
241
|
onEntering: onEntering,
|
|
245
242
|
onEntered: onEntered
|
|
246
243
|
}), children) : children;
|
|
247
|
-
return /*#__PURE__*/React.createElement(
|
|
244
|
+
return /*#__PURE__*/React.createElement(OverlayContext.Provider, {
|
|
245
|
+
value: contextValue
|
|
246
|
+
}, /*#__PURE__*/React.createElement(Portal, null, backdrop && renderBackdrop(), /*#__PURE__*/React.createElement(Component, _extends({}, rest, {
|
|
248
247
|
ref: mergeRefs(modal.setDialogRef, ref),
|
|
249
248
|
style: style,
|
|
250
249
|
className: className,
|
|
251
250
|
tabIndex: -1
|
|
252
|
-
}),
|
|
251
|
+
}), dialogElement)));
|
|
253
252
|
});
|
|
254
253
|
export var modalPropTypes = {
|
|
255
254
|
as: PropTypes.elementType,
|
|
@@ -274,7 +273,6 @@ Modal.propTypes = _extends({}, animationPropTypes, modalPropTypes, {
|
|
|
274
273
|
dialogTransitionTimeout: PropTypes.number,
|
|
275
274
|
backdropTransitionTimeout: PropTypes.number,
|
|
276
275
|
transition: PropTypes.any,
|
|
277
|
-
onEsc: PropTypes.func
|
|
278
|
-
onBackdropClick: PropTypes.func
|
|
276
|
+
onEsc: PropTypes.func
|
|
279
277
|
});
|
|
280
278
|
export default Modal;
|
package/esm/Overlay/Overlay.d.ts
CHANGED
|
@@ -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;
|
package/esm/Overlay/Overlay.js
CHANGED
|
@@ -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
|
|
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,
|
|
@@ -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;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
import React, { useCallback } from 'react';
|
|
3
|
+
import React, { useCallback, useMemo } from 'react';
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
5
|
import { useClassNames, useControlled } from '../utils';
|
|
6
6
|
export var PanelGroupContext = /*#__PURE__*/React.createContext({});
|
|
@@ -34,16 +34,19 @@ var PanelGroup = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
34
34
|
setActiveKey(activeKey);
|
|
35
35
|
onSelect === null || onSelect === void 0 ? void 0 : onSelect(activeKey, event);
|
|
36
36
|
}, [onSelect, setActiveKey]);
|
|
37
|
+
var contextValue = useMemo(function () {
|
|
38
|
+
return {
|
|
39
|
+
accordion: accordion,
|
|
40
|
+
activeKey: activeKey,
|
|
41
|
+
onGroupSelect: handleSelect
|
|
42
|
+
};
|
|
43
|
+
}, [accordion, activeKey, handleSelect]);
|
|
37
44
|
return /*#__PURE__*/React.createElement(Component, _extends({}, rest, {
|
|
38
45
|
ref: ref,
|
|
39
46
|
role: accordion ? 'tablist' : undefined,
|
|
40
47
|
className: classes
|
|
41
48
|
}), /*#__PURE__*/React.createElement(PanelGroupContext.Provider, {
|
|
42
|
-
value:
|
|
43
|
-
accordion: accordion,
|
|
44
|
-
activeKey: activeKey,
|
|
45
|
-
onGroupSelect: handleSelect
|
|
46
|
-
}
|
|
49
|
+
value: contextValue
|
|
47
50
|
}, children));
|
|
48
51
|
});
|
|
49
52
|
PanelGroup.displayName = 'PanelGroup';
|
|
@@ -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<
|
|
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.
|
|
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<
|
|
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>;
|
package/esm/Picker/propTypes.js
CHANGED
|
@@ -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
|
-
|
|
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.
|
|
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,
|
package/esm/Picker/utils.d.ts
CHANGED
|
@@ -56,13 +56,13 @@ interface FocusItemValueProps {
|
|
|
56
56
|
* @param defaultFocusItemValue
|
|
57
57
|
* @param props
|
|
58
58
|
*/
|
|
59
|
-
export declare const useFocusItemValue: <T
|
|
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:
|
|
65
|
-
setKeys: React.Dispatch<React.SetStateAction<
|
|
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,9 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { Ref } from 'react';
|
|
2
2
|
import { PickerLocale } from '../locales';
|
|
3
|
-
import {
|
|
3
|
+
import { PickerInstance } from '../Picker';
|
|
4
4
|
import { FormControlPickerProps, ItemDataType } from '../@types/common';
|
|
5
5
|
import { ListProps } from 'react-virtualized/dist/commonjs/List';
|
|
6
|
-
export
|
|
7
|
-
export interface SelectProps<T = ValueType> {
|
|
6
|
+
export interface SelectProps<T> {
|
|
8
7
|
/** Set group condition key in data */
|
|
9
8
|
groupBy?: string;
|
|
10
9
|
/** Whether dispaly search input box */
|
|
@@ -37,7 +36,18 @@ export interface SelectProps<T = ValueType> {
|
|
|
37
36
|
/** Called when clean */
|
|
38
37
|
onClean?: (event: React.SyntheticEvent) => void;
|
|
39
38
|
}
|
|
40
|
-
export interface
|
|
39
|
+
export interface MultipleSelectProps<T> extends Omit<SelectProps<T>, 'renderValue'> {
|
|
40
|
+
/** Custom render selected items */
|
|
41
|
+
renderValue?: (value: T[], item: ItemDataType<T>[], selectedElement: React.ReactNode) => React.ReactNode;
|
|
42
|
+
}
|
|
43
|
+
export interface SelectPickerProps<T> extends FormControlPickerProps<T, PickerLocale, ItemDataType<T>>, SelectProps<T> {
|
|
44
|
+
}
|
|
45
|
+
export interface SelectPickerComponent {
|
|
46
|
+
<T>(props: SelectPickerProps<T> & {
|
|
47
|
+
ref?: Ref<PickerInstance>;
|
|
48
|
+
}): JSX.Element | null;
|
|
49
|
+
displayName?: string;
|
|
50
|
+
propTypes?: React.WeakValidationMap<SelectPickerProps<any>>;
|
|
41
51
|
}
|
|
42
|
-
declare const SelectPicker:
|
|
52
|
+
declare const SelectPicker: SelectPickerComponent;
|
|
43
53
|
export default SelectPicker;
|
|
@@ -78,9 +78,9 @@ var SelectPicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
78
78
|
var _useCustom = useCustom('Picker', overrideLocale),
|
|
79
79
|
locale = _useCustom.locale;
|
|
80
80
|
|
|
81
|
-
var
|
|
82
|
-
value =
|
|
83
|
-
setValue =
|
|
81
|
+
var _ref = useControlled(valueProp, defaultValue),
|
|
82
|
+
value = _ref[0],
|
|
83
|
+
setValue = _ref[1]; // Used to hover the focus item when trigger `onKeydown`
|
|
84
84
|
|
|
85
85
|
|
|
86
86
|
var _useFocusItemValue = useFocusItemValue(value, {
|
|
@@ -309,7 +309,7 @@ var SelectPicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
309
309
|
disabled: disabled,
|
|
310
310
|
cleanable: cleanable && !disabled,
|
|
311
311
|
hasValue: hasValue,
|
|
312
|
-
inputValue: value,
|
|
312
|
+
inputValue: value !== null && value !== void 0 ? value : '',
|
|
313
313
|
active: active,
|
|
314
314
|
placement: placement
|
|
315
315
|
}), selectedElement || (locale === null || locale === void 0 ? void 0 : locale.placeholder))));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { expectType } from 'ts-expect';
|
|
3
|
+
import SelectPicker from '../SelectPicker'; // Infer value and onChange types from data
|
|
4
|
+
|
|
5
|
+
var numberValuedData = [{
|
|
6
|
+
label: 'One',
|
|
7
|
+
value: 1
|
|
8
|
+
}];
|
|
9
|
+
|
|
10
|
+
/*#__PURE__*/
|
|
11
|
+
React.createElement(SelectPicker, {
|
|
12
|
+
data: numberValuedData,
|
|
13
|
+
value: 1
|
|
14
|
+
}); // @ts-expect-error should not accept string value
|
|
15
|
+
|
|
16
|
+
/*#__PURE__*/
|
|
17
|
+
React.createElement(SelectPicker, {
|
|
18
|
+
data: numberValuedData,
|
|
19
|
+
value: "1"
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
/*#__PURE__*/
|
|
23
|
+
React.createElement(SelectPicker, {
|
|
24
|
+
data: numberValuedData,
|
|
25
|
+
onChange: function onChange(newValue) {
|
|
26
|
+
expectType(newValue);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
var stringValuedData = [{
|
|
30
|
+
label: 'One',
|
|
31
|
+
value: 'One'
|
|
32
|
+
}];
|
|
33
|
+
|
|
34
|
+
/*#__PURE__*/
|
|
35
|
+
React.createElement(SelectPicker, {
|
|
36
|
+
data: stringValuedData,
|
|
37
|
+
value: "1"
|
|
38
|
+
}); // @ts-expect-error should not accept number value
|
|
39
|
+
|
|
40
|
+
/*#__PURE__*/
|
|
41
|
+
React.createElement(SelectPicker, {
|
|
42
|
+
data: stringValuedData,
|
|
43
|
+
value: 1
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
/*#__PURE__*/
|
|
47
|
+
React.createElement(SelectPicker, {
|
|
48
|
+
data: stringValuedData,
|
|
49
|
+
onChange: function onChange(newValue) {
|
|
50
|
+
expectType(newValue);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
var pickerRef = /*#__PURE__*/React.createRef();
|
|
54
|
+
|
|
55
|
+
/*#__PURE__*/
|
|
56
|
+
React.createElement(SelectPicker, {
|
|
57
|
+
ref: pickerRef,
|
|
58
|
+
data: []
|
|
59
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { WithAsProps } from '../@types/common';
|
|
3
|
+
export interface StackProps extends WithAsProps {
|
|
4
|
+
/**
|
|
5
|
+
* The direction of the children in the stack.
|
|
6
|
+
*/
|
|
7
|
+
direction?: 'row' | 'row-reverse' | 'column' | 'column-reverse';
|
|
8
|
+
/**
|
|
9
|
+
* Define the alignment of the children in the stack on the cross axis
|
|
10
|
+
*/
|
|
11
|
+
alignItems?: 'flex-start' | 'center' | 'flex-end' | 'stretch' | 'baseline';
|
|
12
|
+
/**
|
|
13
|
+
* Define the alignment of the children in the stack on the inline axis
|
|
14
|
+
*/
|
|
15
|
+
justifyContent?: 'flex-start' | 'center' | 'flex-end' | 'space-between' | 'space-around';
|
|
16
|
+
/** Define the spacing between immediate children */
|
|
17
|
+
spacing?: number | string | (number | string)[];
|
|
18
|
+
/** Add an element between each child */
|
|
19
|
+
divider?: React.ReactNode;
|
|
20
|
+
/**
|
|
21
|
+
* Define whether the children in the stack are forced onto one line or can wrap onto multiple lines
|
|
22
|
+
*/
|
|
23
|
+
wrap?: boolean;
|
|
24
|
+
}
|
|
25
|
+
declare const Stack: React.ForwardRefExoticComponent<StackProps & React.RefAttributes<HTMLDivElement>>;
|
|
26
|
+
export default Stack;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import PropTypes from 'prop-types';
|
|
5
|
+
import { useClassNames, useCustom, isIE } from '../utils';
|
|
6
|
+
var Stack = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
7
|
+
var _itemStyles;
|
|
8
|
+
|
|
9
|
+
var _props$as = props.as,
|
|
10
|
+
Component = _props$as === void 0 ? 'div' : _props$as,
|
|
11
|
+
_props$alignItems = props.alignItems,
|
|
12
|
+
alignItems = _props$alignItems === void 0 ? 'center' : _props$alignItems,
|
|
13
|
+
_props$classPrefix = props.classPrefix,
|
|
14
|
+
classPrefix = _props$classPrefix === void 0 ? 'stack' : _props$classPrefix,
|
|
15
|
+
className = props.className,
|
|
16
|
+
children = props.children,
|
|
17
|
+
direction = props.direction,
|
|
18
|
+
justifyContent = props.justifyContent,
|
|
19
|
+
spacing = props.spacing,
|
|
20
|
+
divider = props.divider,
|
|
21
|
+
style = props.style,
|
|
22
|
+
wrap = props.wrap,
|
|
23
|
+
rest = _objectWithoutPropertiesLoose(props, ["as", "alignItems", "classPrefix", "className", "children", "direction", "justifyContent", "spacing", "divider", "style", "wrap"]);
|
|
24
|
+
|
|
25
|
+
var _useCustom = useCustom('Stack'),
|
|
26
|
+
rtl = _useCustom.rtl;
|
|
27
|
+
|
|
28
|
+
var _useClassNames = useClassNames(classPrefix),
|
|
29
|
+
withClassPrefix = _useClassNames.withClassPrefix,
|
|
30
|
+
merge = _useClassNames.merge,
|
|
31
|
+
prefix = _useClassNames.prefix;
|
|
32
|
+
|
|
33
|
+
var classes = merge(className, withClassPrefix());
|
|
34
|
+
var isSupportGridGap = !isIE();
|
|
35
|
+
var count = React.Children.count(children);
|
|
36
|
+
var gridGap = Array.isArray(spacing) ? spacing : [spacing, 0];
|
|
37
|
+
var itemStyles = (_itemStyles = {}, _itemStyles[rtl ? 'marginLeft' : 'marginRight'] = gridGap[0], _itemStyles.marginBottom = gridGap[1], _itemStyles);
|
|
38
|
+
|
|
39
|
+
var styles = _extends({
|
|
40
|
+
alignItems: alignItems,
|
|
41
|
+
justifyContent: justifyContent,
|
|
42
|
+
flexDirection: direction,
|
|
43
|
+
flexWrap: wrap ? 'wrap' : undefined,
|
|
44
|
+
gap: isSupportGridGap ? spacing : undefined
|
|
45
|
+
}, style);
|
|
46
|
+
|
|
47
|
+
return /*#__PURE__*/React.createElement(Component, _extends({}, rest, {
|
|
48
|
+
ref: ref,
|
|
49
|
+
className: classes,
|
|
50
|
+
style: styles
|
|
51
|
+
}), React.Children.map(children, function (child, index) {
|
|
52
|
+
var childNode = /*#__PURE__*/React.createElement("div", {
|
|
53
|
+
className: prefix('item'),
|
|
54
|
+
style: !isSupportGridGap ? itemStyles : undefined
|
|
55
|
+
}, child);
|
|
56
|
+
return [childNode, index < count - 1 ? divider : null];
|
|
57
|
+
}));
|
|
58
|
+
});
|
|
59
|
+
Stack.displayName = 'Stack';
|
|
60
|
+
Stack.propTypes = {
|
|
61
|
+
className: PropTypes.string,
|
|
62
|
+
children: PropTypes.node,
|
|
63
|
+
classPrefix: PropTypes.string,
|
|
64
|
+
direction: PropTypes.oneOf(['row', 'row-reverse', 'column', 'column-reverse']),
|
|
65
|
+
alignItems: PropTypes.oneOf(['flex-start', 'center', 'flex-end', 'stretch', 'baseline']),
|
|
66
|
+
justifyContent: PropTypes.oneOf(['flex-start', 'center', 'flex-end', 'space-between', 'space-around']),
|
|
67
|
+
spacing: PropTypes.oneOfType([PropTypes.number, PropTypes.string, PropTypes.array]),
|
|
68
|
+
divider: PropTypes.node,
|
|
69
|
+
wrap: PropTypes.bool
|
|
70
|
+
};
|
|
71
|
+
export default Stack;
|