rsuite 5.13.0 → 5.15.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.
- package/Button/styles/index.less +1 -0
- package/CHANGELOG.md +45 -0
- package/Dropdown/styles/index.less +8 -3
- package/Grid/styles/index.less +42 -10
- package/Sidenav/styles/index.less +45 -11
- package/Table/styles/index.less +0 -2
- package/Tooltip/styles/index.less +4 -4
- package/cjs/@types/common.d.ts +6 -0
- package/cjs/Cascader/utils.d.ts +1 -1
- package/cjs/Col/Col.d.ts +25 -5
- package/cjs/Col/Col.js +9 -1
- package/cjs/CustomProvider/CustomProvider.d.ts +20 -7
- package/cjs/CustomProvider/CustomProvider.js +24 -3
- package/cjs/Dropdown/useRenderDropdownItem.d.ts +1 -1
- package/cjs/Form/Form.d.ts +8 -8
- package/cjs/Form/test/Form.test.d.ts +1 -0
- package/cjs/Form/test/Form.test.js +18 -0
- package/cjs/Modal/test/Modal.test.d.ts +1 -0
- package/cjs/Modal/test/Modal.test.js +14 -0
- package/cjs/Modal/utils.d.ts +1 -1
- package/cjs/Nav/NavDropdownMenu.d.ts +12 -1
- package/cjs/Nav/NavDropdownMenu.js +9 -3
- package/cjs/Nav/test/Nav.test.d.ts +1 -0
- package/cjs/Nav/test/Nav.test.js +17 -0
- package/cjs/Navbar/NavbarDropdownMenu.d.ts +12 -1
- package/cjs/Navbar/NavbarDropdownMenu.js +9 -3
- package/cjs/Overlay/Modal.d.ts +1 -4
- package/cjs/Overlay/Overlay.d.ts +3 -1
- package/cjs/Overlay/Overlay.js +6 -2
- package/cjs/Overlay/OverlayTrigger.d.ts +8 -4
- package/cjs/Overlay/OverlayTrigger.js +32 -4
- package/cjs/Overlay/Position.d.ts +3 -1
- package/cjs/Overlay/Position.js +12 -4
- package/cjs/Overlay/positionUtils.d.ts +11 -4
- package/cjs/Overlay/positionUtils.js +48 -2
- package/cjs/Panel/Panel.js +9 -6
- package/cjs/Picker/utils.d.ts +1 -1
- package/cjs/Popover/Popover.d.ts +2 -0
- package/cjs/Popover/Popover.js +6 -3
- package/cjs/Sidenav/SidenavDropdownToggle.js +2 -1
- package/cjs/Sidenav/SidenavItem.d.ts +4 -0
- package/cjs/Sidenav/SidenavItem.js +40 -31
- package/cjs/Sidenav/SidenavToggle.d.ts +5 -1
- package/cjs/Sidenav/SidenavToggle.js +25 -9
- package/cjs/Toggle/Toggle.d.ts +1 -1
- package/cjs/Tooltip/Tooltip.d.ts +3 -1
- package/cjs/Tooltip/Tooltip.js +8 -3
- package/cjs/Whisper/Whisper.d.ts +3 -5
- package/cjs/Whisper/Whisper.js +6 -1
- package/cjs/Whisper/test/Whisper.test.d.ts +1 -0
- package/cjs/Whisper/test/Whisper.test.js +23 -0
- package/cjs/index.d.ts +3 -3
- package/cjs/index.js +3 -2
- package/cjs/toaster/ToastContainer.d.ts +1 -0
- package/cjs/toaster/ToastContainer.js +4 -1
- package/cjs/toaster/index.d.ts +1 -0
- package/cjs/toaster/index.js +4 -1
- package/cjs/toaster/toaster.d.ts +0 -1
- package/cjs/toaster/useToaster.d.ts +12 -0
- package/cjs/toaster/useToaster.js +43 -0
- package/cjs/utils/constants.d.ts +1 -0
- package/cjs/utils/constants.js +3 -1
- package/cjs/utils/stringToObject.d.ts +1 -1
- package/cjs/utils/tplTransform.d.ts +1 -1
- package/cjs/utils/treeUtils.d.ts +3 -3
- package/cjs/utils/treeUtils.js +8 -10
- package/cjs/utils/useCustom.d.ts +1 -1
- package/cjs/utils/useCustom.js +5 -3
- package/cjs/utils/useFocus.d.ts +1 -1
- package/dist/rsuite-rtl.css +741 -71
- package/dist/rsuite-rtl.min.css +1 -1
- package/dist/rsuite-rtl.min.css.map +1 -1
- package/dist/rsuite.css +741 -71
- package/dist/rsuite.js +92 -103
- 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 +6 -0
- package/esm/Cascader/utils.d.ts +1 -1
- package/esm/Col/Col.d.ts +25 -5
- package/esm/Col/Col.js +10 -2
- package/esm/CustomProvider/CustomProvider.d.ts +20 -7
- package/esm/CustomProvider/CustomProvider.js +22 -3
- package/esm/Dropdown/useRenderDropdownItem.d.ts +1 -1
- package/esm/Form/Form.d.ts +8 -8
- package/esm/Form/test/Form.test.d.ts +1 -0
- package/esm/Form/test/Form.test.js +11 -0
- package/esm/Modal/test/Modal.test.d.ts +1 -0
- package/esm/Modal/test/Modal.test.js +9 -0
- package/esm/Modal/utils.d.ts +1 -1
- package/esm/Nav/NavDropdownMenu.d.ts +12 -1
- package/esm/Nav/NavDropdownMenu.js +8 -3
- package/esm/Nav/test/Nav.test.d.ts +1 -0
- package/esm/Nav/test/Nav.test.js +11 -0
- package/esm/Navbar/NavbarDropdownMenu.d.ts +12 -1
- package/esm/Navbar/NavbarDropdownMenu.js +8 -3
- package/esm/Overlay/Modal.d.ts +1 -4
- package/esm/Overlay/Overlay.d.ts +3 -1
- package/esm/Overlay/Overlay.js +6 -2
- package/esm/Overlay/OverlayTrigger.d.ts +8 -4
- package/esm/Overlay/OverlayTrigger.js +33 -5
- package/esm/Overlay/Position.d.ts +3 -1
- package/esm/Overlay/Position.js +12 -4
- package/esm/Overlay/positionUtils.d.ts +11 -4
- package/esm/Overlay/positionUtils.js +46 -2
- package/esm/Panel/Panel.js +9 -6
- package/esm/Picker/utils.d.ts +1 -1
- package/esm/Popover/Popover.d.ts +2 -0
- package/esm/Popover/Popover.js +6 -3
- package/esm/Sidenav/SidenavDropdownToggle.js +2 -1
- package/esm/Sidenav/SidenavItem.d.ts +4 -0
- package/esm/Sidenav/SidenavItem.js +38 -31
- package/esm/Sidenav/SidenavToggle.d.ts +5 -1
- package/esm/Sidenav/SidenavToggle.js +22 -9
- package/esm/Toggle/Toggle.d.ts +1 -1
- package/esm/Tooltip/Tooltip.d.ts +3 -1
- package/esm/Tooltip/Tooltip.js +8 -3
- package/esm/Whisper/Whisper.d.ts +3 -5
- package/esm/Whisper/Whisper.js +6 -1
- package/esm/Whisper/test/Whisper.test.d.ts +1 -0
- package/esm/Whisper/test/Whisper.test.js +16 -0
- package/esm/index.d.ts +3 -3
- package/esm/index.js +1 -1
- package/esm/toaster/ToastContainer.d.ts +1 -0
- package/esm/toaster/ToastContainer.js +1 -0
- package/esm/toaster/index.d.ts +1 -0
- package/esm/toaster/index.js +1 -0
- package/esm/toaster/toaster.d.ts +0 -1
- package/esm/toaster/useToaster.d.ts +12 -0
- package/esm/toaster/useToaster.js +34 -0
- package/esm/utils/constants.d.ts +1 -0
- package/esm/utils/constants.js +1 -0
- package/esm/utils/stringToObject.d.ts +1 -1
- package/esm/utils/tplTransform.d.ts +1 -1
- package/esm/utils/treeUtils.d.ts +3 -3
- package/esm/utils/treeUtils.js +8 -10
- package/esm/utils/useCustom.d.ts +1 -1
- package/esm/utils/useCustom.js +5 -3
- package/esm/utils/useFocus.d.ts +1 -1
- package/package.json +1 -1
- package/styles/color-modes/dark.less +223 -181
- package/styles/color-modes/high-contrast.less +221 -179
- package/styles/color-modes/light.less +47 -5
- package/styles/colors/dark.less +91 -91
- package/styles/colors/high-contrast.less +91 -91
- package/styles/variables.less +35 -12
- package/styles/color-modes/common.less +0 -44
package/cjs/Form/Form.d.ts
CHANGED
|
@@ -44,21 +44,21 @@ export interface FormProps<T = Record<string, any>, errorMsgType = any, E = {
|
|
|
44
44
|
export interface FormInstance<T = Record<string, any>, errorMsg = string, E = {
|
|
45
45
|
[P in keyof T]?: errorMsg;
|
|
46
46
|
}> {
|
|
47
|
-
root:
|
|
47
|
+
root: HTMLFormElement | null;
|
|
48
48
|
/** Verify form data */
|
|
49
|
-
check
|
|
49
|
+
check: (callback?: (formError: E) => void) => boolean;
|
|
50
50
|
/** Asynchronously check form data */
|
|
51
|
-
checkAsync
|
|
51
|
+
checkAsync: () => Promise<any>;
|
|
52
52
|
/** Check the data field */
|
|
53
|
-
checkForField
|
|
53
|
+
checkForField: (fieldName: keyof T, callback?: (checkResult: CheckResult<errorMsg>) => void) => boolean;
|
|
54
54
|
/** Asynchronous verification as a data field */
|
|
55
|
-
checkForFieldAsync
|
|
55
|
+
checkForFieldAsync: (fieldName: keyof T) => Promise<CheckResult>;
|
|
56
56
|
/** Clear all error messages */
|
|
57
|
-
cleanErrors
|
|
57
|
+
cleanErrors: (callback?: () => void) => void;
|
|
58
58
|
/** Clear the error message of the specified field */
|
|
59
|
-
cleanErrorForField
|
|
59
|
+
cleanErrorForField: (fieldName: keyof E, callback?: () => void) => void;
|
|
60
60
|
/** All error messages are reset, and an initial value can be set */
|
|
61
|
-
resetErrors
|
|
61
|
+
resetErrors: (formError: E, callback?: () => void) => void;
|
|
62
62
|
}
|
|
63
63
|
export interface FormComponent extends RsRefForwardingComponent<'form', FormProps & {
|
|
64
64
|
ref?: React.Ref<FormInstance>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
var _react = _interopRequireDefault(require("react"));
|
|
6
|
+
|
|
7
|
+
var _Form = _interopRequireDefault(require("../Form"));
|
|
8
|
+
|
|
9
|
+
var _formRef$current;
|
|
10
|
+
|
|
11
|
+
var formRef = /*#__PURE__*/_react.default.createRef();
|
|
12
|
+
|
|
13
|
+
/*#__PURE__*/
|
|
14
|
+
_react.default.createElement(_Form.default, {
|
|
15
|
+
ref: formRef
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
(_formRef$current = formRef.current) === null || _formRef$current === void 0 ? void 0 : _formRef$current.check();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
var _react = _interopRequireDefault(require("react"));
|
|
6
|
+
|
|
7
|
+
var _Modal = _interopRequireDefault(require("../Modal"));
|
|
8
|
+
|
|
9
|
+
/*#__PURE__*/
|
|
10
|
+
_react.default.createElement(_Modal.default, {
|
|
11
|
+
container: function container() {
|
|
12
|
+
return document.body;
|
|
13
|
+
}
|
|
14
|
+
});
|
package/cjs/Modal/utils.d.ts
CHANGED
|
@@ -3,4 +3,4 @@ export declare const useBodyStyles: (ref: React.RefObject<HTMLElement>, options:
|
|
|
3
3
|
overflow: boolean;
|
|
4
4
|
drawer: boolean;
|
|
5
5
|
prefix: (...classes: any) => string;
|
|
6
|
-
}) => [import("react").CSSProperties, (entering?: boolean
|
|
6
|
+
}) => [import("react").CSSProperties, (entering?: boolean) => void, () => void];
|
|
@@ -4,8 +4,19 @@ import { IconProps } from '@rsuite/icons/lib/Icon';
|
|
|
4
4
|
export interface NavDropdownMenuProps<T = any> extends StandardProps {
|
|
5
5
|
/** Define the title as a submenu */
|
|
6
6
|
title?: React.ReactNode;
|
|
7
|
-
/**
|
|
7
|
+
/**
|
|
8
|
+
* The submenu expands from the left and defaults to the right
|
|
9
|
+
* @deprecated Use openDirection="start" instead
|
|
10
|
+
*/
|
|
8
11
|
pullLeft?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Direction that the sub-menu open towards
|
|
14
|
+
* - start: towards the head of the reading direction (right by default, left in RTL)
|
|
15
|
+
* - end: towards the end of the reading direction (left by default, right in RTL)
|
|
16
|
+
*
|
|
17
|
+
* @default 'end'
|
|
18
|
+
*/
|
|
19
|
+
openDirection?: 'start' | 'end';
|
|
9
20
|
/**
|
|
10
21
|
* Only used for setting the default expand state when it's a submenu.
|
|
11
22
|
*/
|
|
@@ -33,6 +33,8 @@ var _useCustom2 = _interopRequireDefault(require("../utils/useCustom"));
|
|
|
33
33
|
|
|
34
34
|
var _NavContext = _interopRequireDefault(require("./NavContext"));
|
|
35
35
|
|
|
36
|
+
var _deprecatePropType = _interopRequireDefault(require("../utils/deprecatePropType"));
|
|
37
|
+
|
|
36
38
|
var _templateObject, _templateObject2;
|
|
37
39
|
|
|
38
40
|
/**
|
|
@@ -51,7 +53,9 @@ var NavDropdownMenu = /*#__PURE__*/_react.default.forwardRef(function (props, re
|
|
|
51
53
|
_props$classPrefix = props.classPrefix,
|
|
52
54
|
classPrefix = _props$classPrefix === void 0 ? 'dropdown-menu' : _props$classPrefix,
|
|
53
55
|
children = props.children,
|
|
54
|
-
|
|
56
|
+
_props$openDirection = props.openDirection,
|
|
57
|
+
openDirection = _props$openDirection === void 0 ? 'end' : _props$openDirection,
|
|
58
|
+
rest = (0, _objectWithoutPropertiesLoose2.default)(props, ["onToggle", "eventKey", "title", "classPrefix", "children", "openDirection"]);
|
|
55
59
|
|
|
56
60
|
var _useCustom = (0, _useCustom2.default)('DropdownMenu'),
|
|
57
61
|
rtl = _useCustom.rtl;
|
|
@@ -118,7 +122,8 @@ var NavDropdownMenu = /*#__PURE__*/_react.default.forwardRef(function (props, re
|
|
|
118
122
|
return /*#__PURE__*/_react.default.createElement("ul", (0, _extends2.default)({
|
|
119
123
|
ref: popupRef,
|
|
120
124
|
className: menuClassName,
|
|
121
|
-
hidden: !open
|
|
125
|
+
hidden: !open,
|
|
126
|
+
"data-direction": openDirection
|
|
122
127
|
}, popupProps, menuProps), children);
|
|
123
128
|
},
|
|
124
129
|
onToggleMenu: handleToggleSubmenu
|
|
@@ -144,7 +149,8 @@ NavDropdownMenu.propTypes = {
|
|
|
144
149
|
children: _propTypes.default.node,
|
|
145
150
|
icon: _propTypes.default.any,
|
|
146
151
|
classPrefix: _propTypes.default.string,
|
|
147
|
-
pullLeft: _propTypes.default.bool,
|
|
152
|
+
pullLeft: (0, _deprecatePropType.default)(_propTypes.default.bool, 'Use openDirection="start" instead.'),
|
|
153
|
+
openDirection: _propTypes.default.oneOf(['start', 'end']),
|
|
148
154
|
title: _propTypes.default.node,
|
|
149
155
|
open: _propTypes.default.bool,
|
|
150
156
|
eventKey: _propTypes.default.any,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
var _react = _interopRequireDefault(require("react"));
|
|
6
|
+
|
|
7
|
+
var _Navbar = _interopRequireDefault(require("../../Navbar"));
|
|
8
|
+
|
|
9
|
+
var _Nav = _interopRequireDefault(require("../Nav"));
|
|
10
|
+
|
|
11
|
+
/*#__PURE__*/
|
|
12
|
+
_react.default.createElement(_Navbar.default, null, /*#__PURE__*/_react.default.createElement(_Nav.default, null, /*#__PURE__*/_react.default.createElement(_Nav.default.Menu, {
|
|
13
|
+
title: "Menu"
|
|
14
|
+
}, /*#__PURE__*/_react.default.createElement(_Nav.default.Menu, {
|
|
15
|
+
title: "Submenu",
|
|
16
|
+
openDirection: "start"
|
|
17
|
+
}, /*#__PURE__*/_react.default.createElement(_Nav.default.Item, null, "Submenu item")))));
|
|
@@ -4,8 +4,19 @@ import { IconProps } from '@rsuite/icons/lib/Icon';
|
|
|
4
4
|
export interface NavbarDropdownMenuProps<T = any> extends StandardProps {
|
|
5
5
|
/** Define the title as a submenu */
|
|
6
6
|
title?: React.ReactNode;
|
|
7
|
-
/**
|
|
7
|
+
/**
|
|
8
|
+
* The submenu expands from the left and defaults to the right
|
|
9
|
+
* @deprecated Use openDirection="start" instead.
|
|
10
|
+
*/
|
|
8
11
|
pullLeft?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Direction that the sub-menu open towards
|
|
14
|
+
* - start: towards the head of the reading direction (right by default, left in RTL)
|
|
15
|
+
* - end: towards the end of the reading direction (left by default, right in RTL)
|
|
16
|
+
*
|
|
17
|
+
* @default 'end'
|
|
18
|
+
*/
|
|
19
|
+
openDirection?: 'start' | 'end';
|
|
9
20
|
/**
|
|
10
21
|
* Only used for setting the default expand state when it's a submenu.
|
|
11
22
|
*/
|
|
@@ -33,6 +33,8 @@ var _Disclosure = _interopRequireDefault(require("../Disclosure"));
|
|
|
33
33
|
|
|
34
34
|
var _NavContext = _interopRequireDefault(require("../Nav/NavContext"));
|
|
35
35
|
|
|
36
|
+
var _deprecatePropType = _interopRequireDefault(require("../utils/deprecatePropType"));
|
|
37
|
+
|
|
36
38
|
var _templateObject, _templateObject2;
|
|
37
39
|
|
|
38
40
|
/**
|
|
@@ -62,7 +64,9 @@ var NavbarDropdownMenu = /*#__PURE__*/_react.default.forwardRef(function (props,
|
|
|
62
64
|
_props$classPrefix = props.classPrefix,
|
|
63
65
|
classPrefix = _props$classPrefix === void 0 ? 'dropdown-menu' : _props$classPrefix,
|
|
64
66
|
children = props.children,
|
|
65
|
-
|
|
67
|
+
_props$openDirection = props.openDirection,
|
|
68
|
+
openDirection = _props$openDirection === void 0 ? 'end' : _props$openDirection,
|
|
69
|
+
rest = (0, _objectWithoutPropertiesLoose2.default)(props, ["onToggle", "eventKey", "title", "classPrefix", "children", "openDirection"]);
|
|
66
70
|
|
|
67
71
|
var _useCustom = (0, _useCustom2.default)('DropdownMenu'),
|
|
68
72
|
rtl = _useCustom.rtl;
|
|
@@ -129,7 +133,8 @@ var NavbarDropdownMenu = /*#__PURE__*/_react.default.forwardRef(function (props,
|
|
|
129
133
|
return /*#__PURE__*/_react.default.createElement("ul", (0, _extends2.default)({
|
|
130
134
|
ref: elementRef,
|
|
131
135
|
className: menuClassName,
|
|
132
|
-
hidden: !open
|
|
136
|
+
hidden: !open,
|
|
137
|
+
"data-direction": openDirection
|
|
133
138
|
}, menuProps), children);
|
|
134
139
|
}));
|
|
135
140
|
});
|
|
@@ -143,7 +148,8 @@ NavbarDropdownMenu.propTypes = {
|
|
|
143
148
|
children: _propTypes.default.node,
|
|
144
149
|
icon: _propTypes.default.any,
|
|
145
150
|
classPrefix: _propTypes.default.string,
|
|
146
|
-
pullLeft: _propTypes.default.bool,
|
|
151
|
+
pullLeft: (0, _deprecatePropType.default)(_propTypes.default.bool, 'Use openDirection="start" instead.'),
|
|
152
|
+
openDirection: _propTypes.default.oneOf(['start', 'end']),
|
|
147
153
|
title: _propTypes.default.node,
|
|
148
154
|
open: _propTypes.default.bool,
|
|
149
155
|
eventKey: _propTypes.default.any,
|
package/cjs/Overlay/Modal.d.ts
CHANGED
|
@@ -37,9 +37,6 @@ export interface BaseModalProps extends WithAsProps, AnimationEventProps {
|
|
|
37
37
|
onOpen?: () => void;
|
|
38
38
|
/** Called when Modal is closed */
|
|
39
39
|
onClose?: (event: React.SyntheticEvent) => void;
|
|
40
|
-
}
|
|
41
|
-
interface ModalProps extends BaseModalProps {
|
|
42
|
-
children: (props: any, ref: any) => React.ReactElement;
|
|
43
40
|
container?: HTMLElement | (() => HTMLElement);
|
|
44
41
|
containerClassName?: string;
|
|
45
42
|
backdropTransitionTimeout?: number;
|
|
@@ -48,7 +45,7 @@ interface ModalProps extends BaseModalProps {
|
|
|
48
45
|
onEsc?: React.KeyboardEventHandler;
|
|
49
46
|
onBackdropClick?: React.MouseEventHandler;
|
|
50
47
|
}
|
|
51
|
-
declare const Modal: RsRefForwardingComponent<'div',
|
|
48
|
+
declare const Modal: RsRefForwardingComponent<'div', BaseModalProps>;
|
|
52
49
|
export declare const modalPropTypes: {
|
|
53
50
|
as: PropTypes.Requireable<PropTypes.ReactComponentLike>;
|
|
54
51
|
className: PropTypes.Requireable<string>;
|
package/cjs/Overlay/Overlay.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import { TypeAttributes, AnimationEventProps } from '../@types/common';
|
|
3
|
+
import { TypeAttributes, AnimationEventProps, CursorPosition } from '../@types/common';
|
|
4
4
|
export interface OverlayProps extends AnimationEventProps {
|
|
5
5
|
container?: HTMLElement | (() => HTMLElement | null) | null;
|
|
6
6
|
children: React.ReactElement | ((props: any, ref: any) => React.ReactElement);
|
|
@@ -14,6 +14,8 @@ export interface OverlayProps extends AnimationEventProps {
|
|
|
14
14
|
transition?: React.ElementType;
|
|
15
15
|
triggerTarget?: React.RefObject<any>;
|
|
16
16
|
onClose?: React.ReactEventHandler;
|
|
17
|
+
followCursor?: boolean;
|
|
18
|
+
cursorPosition?: CursorPosition | null;
|
|
17
19
|
}
|
|
18
20
|
export declare const overlayPropTypes: {
|
|
19
21
|
container: PropTypes.Requireable<any>;
|
package/cjs/Overlay/Overlay.js
CHANGED
|
@@ -67,7 +67,9 @@ var Overlay = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
|
|
|
67
67
|
onExiting = props.onExiting,
|
|
68
68
|
onEnter = props.onEnter,
|
|
69
69
|
onEntering = props.onEntering,
|
|
70
|
-
onEntered = props.onEntered
|
|
70
|
+
onEntered = props.onEntered,
|
|
71
|
+
followCursor = props.followCursor,
|
|
72
|
+
cursorPosition = props.cursorPosition;
|
|
71
73
|
|
|
72
74
|
var _useState = (0, _react.useState)(!open),
|
|
73
75
|
exited = _useState[0],
|
|
@@ -101,7 +103,9 @@ var Overlay = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
|
|
|
101
103
|
containerPadding: containerPadding,
|
|
102
104
|
triggerTarget: triggerTarget,
|
|
103
105
|
placement: placement,
|
|
104
|
-
preventOverflow: preventOverflow
|
|
106
|
+
preventOverflow: preventOverflow,
|
|
107
|
+
followCursor: followCursor,
|
|
108
|
+
cursorPosition: cursorPosition
|
|
105
109
|
};
|
|
106
110
|
|
|
107
111
|
var renderChildWithPosition = function renderChildWithPosition(transitionProps, transitionRef) {
|
|
@@ -50,16 +50,20 @@ export interface OverlayTriggerProps extends StandardProps, AnimationEventProps
|
|
|
50
50
|
onMouseOut?: React.MouseEventHandler;
|
|
51
51
|
/** Mouse over callback function */
|
|
52
52
|
onMouseOver?: React.MouseEventHandler;
|
|
53
|
+
/** Mouse move callback function */
|
|
54
|
+
onMouseMove?: React.MouseEventHandler;
|
|
53
55
|
/** Callback fired when open component */
|
|
54
56
|
onOpen?: () => void;
|
|
55
57
|
/** Callback fired when close component */
|
|
56
58
|
onClose?: () => void;
|
|
59
|
+
/** Whether speaker to follow the cursor */
|
|
60
|
+
followCursor?: boolean;
|
|
57
61
|
}
|
|
58
62
|
export interface OverlayTriggerInstance {
|
|
59
|
-
root: HTMLElement;
|
|
63
|
+
root: HTMLElement | undefined;
|
|
60
64
|
updatePosition: () => void;
|
|
61
|
-
open: () => void;
|
|
62
|
-
close: () => void;
|
|
65
|
+
open: (delay?: number) => void;
|
|
66
|
+
close: (delay?: number) => void;
|
|
63
67
|
}
|
|
64
|
-
declare const OverlayTrigger: React.ForwardRefExoticComponent<OverlayTriggerProps & React.RefAttributes<
|
|
68
|
+
declare const OverlayTrigger: React.ForwardRefExoticComponent<OverlayTriggerProps & React.RefAttributes<OverlayTriggerInstance>>;
|
|
65
69
|
export default OverlayTrigger;
|
|
@@ -93,12 +93,15 @@ var OverlayTrigger = /*#__PURE__*/_react.default.forwardRef(function (props, ref
|
|
|
93
93
|
rootClose = _props$rootClose === void 0 ? true : _props$rootClose,
|
|
94
94
|
onClick = props.onClick,
|
|
95
95
|
onMouseOver = props.onMouseOver,
|
|
96
|
+
onMouseMove = props.onMouseMove,
|
|
96
97
|
onMouseOut = props.onMouseOut,
|
|
97
98
|
onContextMenu = props.onContextMenu,
|
|
98
99
|
onFocus = props.onFocus,
|
|
99
100
|
onBlur = props.onBlur,
|
|
100
101
|
onClose = props.onClose,
|
|
101
|
-
|
|
102
|
+
followCursor = props.followCursor,
|
|
103
|
+
onExited = props.onExited,
|
|
104
|
+
rest = (0, _objectWithoutPropertiesLoose2.default)(props, ["children", "container", "controlId", "defaultOpen", "trigger", "disabled", "readOnly", "plaintext", "open", "delay", "delayOpen", "delayClose", "enterable", "placement", "speaker", "rootClose", "onClick", "onMouseOver", "onMouseMove", "onMouseOut", "onContextMenu", "onFocus", "onBlur", "onClose", "followCursor", "onExited"]);
|
|
102
105
|
|
|
103
106
|
var _usePortal = (0, _utils.usePortal)({
|
|
104
107
|
container: container
|
|
@@ -110,7 +113,11 @@ var OverlayTrigger = /*#__PURE__*/_react.default.forwardRef(function (props, ref
|
|
|
110
113
|
|
|
111
114
|
var _useControlled = (0, _utils.useControlled)(openProp, defaultOpen),
|
|
112
115
|
open = _useControlled[0],
|
|
113
|
-
setOpen = _useControlled[1];
|
|
116
|
+
setOpen = _useControlled[1];
|
|
117
|
+
|
|
118
|
+
var _useState = (0, _react.useState)(null),
|
|
119
|
+
cursorPosition = _useState[0],
|
|
120
|
+
setCursorPosition = _useState[1]; // Delay the timer to close/open the overlay
|
|
114
121
|
// When the cursor moves from the trigger to the overlay, the overlay will be closed.
|
|
115
122
|
// In order to keep the overlay open, a timer is used to delay the closing.
|
|
116
123
|
|
|
@@ -158,6 +165,9 @@ var OverlayTrigger = /*#__PURE__*/_react.default.forwardRef(function (props, ref
|
|
|
158
165
|
|
|
159
166
|
setOpen(false);
|
|
160
167
|
}, [delayClose, setOpen]);
|
|
168
|
+
var handleExited = (0, _react.useCallback)(function () {
|
|
169
|
+
setCursorPosition(null);
|
|
170
|
+
}, []);
|
|
161
171
|
(0, _react.useImperativeHandle)(ref, function () {
|
|
162
172
|
return {
|
|
163
173
|
get root() {
|
|
@@ -255,6 +265,16 @@ var OverlayTrigger = /*#__PURE__*/_react.default.forwardRef(function (props, ref
|
|
|
255
265
|
handleCloseWhenLeave();
|
|
256
266
|
}
|
|
257
267
|
}, [handleCloseWhenLeave, trigger]);
|
|
268
|
+
var handledMoveOverlay = (0, _react.useCallback)(function (event) {
|
|
269
|
+
setCursorPosition(function () {
|
|
270
|
+
return {
|
|
271
|
+
top: event.pageY,
|
|
272
|
+
left: event.pageX,
|
|
273
|
+
clientTop: event.clientX,
|
|
274
|
+
clientLeft: event.clientY
|
|
275
|
+
};
|
|
276
|
+
});
|
|
277
|
+
}, [open]);
|
|
258
278
|
var preventDefault = (0, _react.useCallback)(function (event) {
|
|
259
279
|
event.preventDefault();
|
|
260
280
|
}, []);
|
|
@@ -264,7 +284,8 @@ var OverlayTrigger = /*#__PURE__*/_react.default.forwardRef(function (props, ref
|
|
|
264
284
|
onMouseOver: onMouseOver,
|
|
265
285
|
onMouseOut: onMouseOut,
|
|
266
286
|
onFocus: onFocus,
|
|
267
|
-
onBlur: onBlur
|
|
287
|
+
onBlur: onBlur,
|
|
288
|
+
onMouseMove: onMouseMove
|
|
268
289
|
};
|
|
269
290
|
|
|
270
291
|
if (!disabled && !readOnly && !plaintext) {
|
|
@@ -302,6 +323,10 @@ var OverlayTrigger = /*#__PURE__*/_react.default.forwardRef(function (props, ref
|
|
|
302
323
|
triggerEvents.onFocus = (0, _utils.createChainedFunction)(handleDelayedOpen, onFocus);
|
|
303
324
|
triggerEvents.onBlur = (0, _utils.createChainedFunction)(handleDelayedClose, onBlur);
|
|
304
325
|
}
|
|
326
|
+
|
|
327
|
+
if (trigger !== 'none') {
|
|
328
|
+
triggerEvents.onMouseMove = (0, _utils.createChainedFunction)(handledMoveOverlay, onMouseMove);
|
|
329
|
+
}
|
|
305
330
|
}
|
|
306
331
|
|
|
307
332
|
var renderOverlay = function renderOverlay() {
|
|
@@ -309,6 +334,7 @@ var OverlayTrigger = /*#__PURE__*/_react.default.forwardRef(function (props, ref
|
|
|
309
334
|
rootClose: rootClose,
|
|
310
335
|
triggerTarget: triggerRef,
|
|
311
336
|
onClose: trigger !== 'none' ? (0, _utils.createChainedFunction)(handleClose, onClose) : undefined,
|
|
337
|
+
onExited: (0, _utils.createChainedFunction)(followCursor ? handleExited : undefined, onExited),
|
|
312
338
|
placement: placement,
|
|
313
339
|
container: container,
|
|
314
340
|
open: open
|
|
@@ -326,7 +352,9 @@ var OverlayTrigger = /*#__PURE__*/_react.default.forwardRef(function (props, ref
|
|
|
326
352
|
|
|
327
353
|
return /*#__PURE__*/_react.default.createElement(_Overlay.default, (0, _extends2.default)({}, overlayProps, {
|
|
328
354
|
ref: overlayRef,
|
|
329
|
-
childrenProps: speakerProps
|
|
355
|
+
childrenProps: speakerProps,
|
|
356
|
+
followCursor: followCursor,
|
|
357
|
+
cursorPosition: cursorPosition
|
|
330
358
|
}), typeof speaker === 'function' ? function (props, ref) {
|
|
331
359
|
return speaker((0, _extends2.default)({}, props, {
|
|
332
360
|
onClose: handleClose
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { TypeAttributes } from '../@types/common';
|
|
2
|
+
import { CursorPosition, TypeAttributes } from '../@types/common';
|
|
3
3
|
export interface PositionChildProps {
|
|
4
4
|
className: string;
|
|
5
5
|
left?: number;
|
|
@@ -13,6 +13,8 @@ export interface PositionProps {
|
|
|
13
13
|
placement?: TypeAttributes.Placement;
|
|
14
14
|
preventOverflow?: boolean;
|
|
15
15
|
triggerTarget?: React.RefObject<any>;
|
|
16
|
+
followCursor?: boolean;
|
|
17
|
+
cursorPosition?: CursorPosition | null;
|
|
16
18
|
}
|
|
17
19
|
export interface PositionInstance {
|
|
18
20
|
updatePosition?: () => void;
|
package/cjs/Overlay/Position.js
CHANGED
|
@@ -41,7 +41,9 @@ var usePosition = function usePosition(props, ref) {
|
|
|
41
41
|
_props$containerPaddi = props.containerPadding,
|
|
42
42
|
containerPadding = _props$containerPaddi === void 0 ? 0 : _props$containerPaddi,
|
|
43
43
|
container = props.container,
|
|
44
|
-
triggerTarget = props.triggerTarget
|
|
44
|
+
triggerTarget = props.triggerTarget,
|
|
45
|
+
followCursor = props.followCursor,
|
|
46
|
+
cursorPosition = props.cursorPosition;
|
|
45
47
|
var containerRef = (0, _react.useRef)(null);
|
|
46
48
|
var lastTargetRef = (0, _react.useRef)(null);
|
|
47
49
|
var overlayResizeObserver = (0, _react.useRef)();
|
|
@@ -91,7 +93,7 @@ var usePosition = function usePosition(props, ref) {
|
|
|
91
93
|
|
|
92
94
|
var overlay = (0, _utils.getDOMNode)(ref.current);
|
|
93
95
|
var containerElement = (0, _getContainer.default)(typeof container === 'function' ? container() : container !== null && container !== void 0 ? container : null, (0, _ownerDocument.default)(ref.current).body);
|
|
94
|
-
var posi = utils.calcOverlayPosition(overlay, targetElement, containerElement);
|
|
96
|
+
var posi = utils.calcOverlayPosition(overlay, targetElement, containerElement, followCursor ? cursorPosition : undefined);
|
|
95
97
|
|
|
96
98
|
if (forceUpdateDOM && overlay) {
|
|
97
99
|
var _overlay$className, _overlay$className$ma;
|
|
@@ -113,7 +115,7 @@ var usePosition = function usePosition(props, ref) {
|
|
|
113
115
|
|
|
114
116
|
containerRef.current = containerElement;
|
|
115
117
|
lastTargetRef.current = targetElement;
|
|
116
|
-
}, [container, ref, triggerTarget, utils]);
|
|
118
|
+
}, [container, ref, triggerTarget, utils, followCursor, cursorPosition]);
|
|
117
119
|
(0, _react.useEffect)(function () {
|
|
118
120
|
updatePosition(false);
|
|
119
121
|
var overlay = (0, _utils.getDOMNode)(ref.current);
|
|
@@ -158,7 +160,9 @@ var usePosition = function usePosition(props, ref) {
|
|
|
158
160
|
|
|
159
161
|
var Position = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
|
|
160
162
|
var children = props.children,
|
|
161
|
-
className = props.className
|
|
163
|
+
className = props.className,
|
|
164
|
+
followCursor = props.followCursor,
|
|
165
|
+
cursorPosition = props.cursorPosition;
|
|
162
166
|
|
|
163
167
|
var childRef = _react.default.useRef(null);
|
|
164
168
|
|
|
@@ -180,6 +184,10 @@ var Position = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
|
|
|
180
184
|
updatePosition: updatePosition
|
|
181
185
|
};
|
|
182
186
|
});
|
|
187
|
+
(0, _react.useEffect)(function () {
|
|
188
|
+
if (!followCursor || !cursorPosition) return;
|
|
189
|
+
updatePosition();
|
|
190
|
+
}, [followCursor, cursorPosition, updatePosition]);
|
|
183
191
|
|
|
184
192
|
if (typeof children === 'function') {
|
|
185
193
|
var childProps = {
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import { TypeAttributes } from '../@types/common';
|
|
1
|
+
import { CursorPosition, TypeAttributes } from '../@types/common';
|
|
2
|
+
declare type Offset = {
|
|
3
|
+
top: number;
|
|
4
|
+
left: number;
|
|
5
|
+
width: number;
|
|
6
|
+
height: number;
|
|
7
|
+
};
|
|
2
8
|
export interface PositionType {
|
|
3
9
|
positionLeft?: number;
|
|
4
10
|
positionTop?: number;
|
|
@@ -24,13 +30,14 @@ export interface Dimensions {
|
|
|
24
30
|
scrollY: number;
|
|
25
31
|
}
|
|
26
32
|
declare const _default: (props: UtilProps) => {
|
|
27
|
-
getPosition(target:
|
|
33
|
+
getPosition(target: HTMLElement, container: HTMLElement): {
|
|
28
34
|
top: number;
|
|
29
35
|
left: number;
|
|
30
36
|
height: number;
|
|
31
37
|
width: number;
|
|
32
|
-
} | null;
|
|
38
|
+
} | DOMRect | null;
|
|
39
|
+
getCursorOffsetPosition(target: HTMLElement, container: HTMLElement, cursorPosition: CursorPosition): Offset;
|
|
33
40
|
calcAutoPlacement(targetOffset: any, container: any, overlay: any): any;
|
|
34
|
-
calcOverlayPosition(overlayNode:
|
|
41
|
+
calcOverlayPosition(overlayNode: HTMLElement, target: HTMLElement, container: HTMLElement, cursorPosition?: CursorPosition | null): PositionType;
|
|
35
42
|
};
|
|
36
43
|
export default _default;
|
|
@@ -21,6 +21,10 @@ var _scrollLeft = _interopRequireDefault(require("dom-lib/scrollLeft"));
|
|
|
21
21
|
|
|
22
22
|
var _getPosition2 = _interopRequireDefault(require("dom-lib/getPosition"));
|
|
23
23
|
|
|
24
|
+
var _getStyle = _interopRequireDefault(require("dom-lib/getStyle"));
|
|
25
|
+
|
|
26
|
+
var _nodeName = _interopRequireDefault(require("dom-lib/nodeName"));
|
|
27
|
+
|
|
24
28
|
var AutoPlacement = {
|
|
25
29
|
left: 'Start',
|
|
26
30
|
right: 'End',
|
|
@@ -146,6 +150,48 @@ var _default = function _default(props) {
|
|
|
146
150
|
var offset = container.tagName === 'BODY' ? (0, _getOffset.default)(target) : (0, _getPosition2.default)(target, container, false);
|
|
147
151
|
return offset;
|
|
148
152
|
},
|
|
153
|
+
getCursorOffsetPosition: function getCursorOffsetPosition(target, container, cursorPosition) {
|
|
154
|
+
var left = cursorPosition.left,
|
|
155
|
+
top = cursorPosition.top,
|
|
156
|
+
clientLeft = cursorPosition.clientLeft,
|
|
157
|
+
clientTop = cursorPosition.clientTop;
|
|
158
|
+
var offset = {
|
|
159
|
+
left: left,
|
|
160
|
+
top: top,
|
|
161
|
+
width: 10,
|
|
162
|
+
height: 10
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
if ((0, _getStyle.default)(target, 'position') === 'fixed') {
|
|
166
|
+
offset.left = clientLeft;
|
|
167
|
+
offset.top = clientTop;
|
|
168
|
+
return offset;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
if (container.tagName === 'BODY') {
|
|
172
|
+
return offset;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
var containerOffset = {
|
|
176
|
+
top: 0,
|
|
177
|
+
left: 0
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
if ((0, _nodeName.default)(container) !== 'html') {
|
|
181
|
+
var nextParentOffset = (0, _getOffset.default)(container);
|
|
182
|
+
|
|
183
|
+
if (nextParentOffset) {
|
|
184
|
+
containerOffset.top = nextParentOffset.top;
|
|
185
|
+
containerOffset.left = nextParentOffset.left;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
containerOffset.top += parseInt((0, _getStyle.default)(container, 'borderTopWidth'), 10) - (0, _scrollTop.default)(container) || 0;
|
|
190
|
+
containerOffset.left += parseInt((0, _getStyle.default)(container, 'borderLeftWidth'), 10) - (0, _scrollLeft.default)(container) || 0;
|
|
191
|
+
offset.left = left - containerOffset.left;
|
|
192
|
+
offset.top = top - containerOffset.top;
|
|
193
|
+
return offset;
|
|
194
|
+
},
|
|
149
195
|
calcAutoPlacement: function calcAutoPlacement(targetOffset, container, overlay) {
|
|
150
196
|
var _getContainerDimensio3 = getContainerDimensions(container),
|
|
151
197
|
width = _getContainerDimensio3.width,
|
|
@@ -210,8 +256,8 @@ var _default = function _default(props) {
|
|
|
210
256
|
return "" + direction.key + AutoPlacement[align.key];
|
|
211
257
|
},
|
|
212
258
|
// Calculate the position of the overlay
|
|
213
|
-
calcOverlayPosition: function calcOverlayPosition(overlayNode, target, container) {
|
|
214
|
-
var childOffset = this.getPosition(target, container);
|
|
259
|
+
calcOverlayPosition: function calcOverlayPosition(overlayNode, target, container, cursorPosition) {
|
|
260
|
+
var childOffset = cursorPosition ? this.getCursorOffsetPosition(target, container, cursorPosition) : this.getPosition(target, container);
|
|
215
261
|
|
|
216
262
|
var _ref2 = (0, _getOffset.default)(overlayNode),
|
|
217
263
|
overlayHeight = _ref2.height,
|
package/cjs/Panel/Panel.js
CHANGED
|
@@ -58,23 +58,26 @@ var Panel = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
|
|
|
58
58
|
prefix = _useClassNames.prefix,
|
|
59
59
|
withClassPrefix = _useClassNames.withClassPrefix;
|
|
60
60
|
|
|
61
|
-
var _useControlled = (0, _utils.useControlled)(expandedProp, defaultExpanded),
|
|
62
|
-
expandedState = _useControlled[0],
|
|
63
|
-
setExpanded = _useControlled[1];
|
|
64
|
-
|
|
65
61
|
var _ref = (0, _react.useContext)(_PanelGroup.PanelGroupContext) || {},
|
|
66
62
|
accordion = _ref.accordion,
|
|
67
63
|
activeKey = _ref.activeKey,
|
|
68
64
|
onGroupSelect = _ref.onGroupSelect;
|
|
69
65
|
|
|
66
|
+
var _useControlled = (0, _utils.useControlled)(expandedProp, defaultExpanded || typeof activeKey !== 'undefined' && activeKey === eventKey),
|
|
67
|
+
expandedState = _useControlled[0],
|
|
68
|
+
setExpanded = _useControlled[1];
|
|
69
|
+
|
|
70
70
|
var collapsible = collapsibleProp;
|
|
71
71
|
var headerRole = headerRoleProp;
|
|
72
72
|
var expanded = expandedState;
|
|
73
73
|
|
|
74
74
|
if (accordion) {
|
|
75
75
|
collapsible = true;
|
|
76
|
-
headerRole = 'button';
|
|
77
|
-
|
|
76
|
+
headerRole = 'button'; // Collapses all inactive panels.
|
|
77
|
+
|
|
78
|
+
if (typeof activeKey !== 'undefined' && activeKey !== eventKey) {
|
|
79
|
+
expanded = false;
|
|
80
|
+
}
|
|
78
81
|
}
|
|
79
82
|
|
|
80
83
|
var handleSelect = (0, _react.useCallback)(function (event) {
|
package/cjs/Picker/utils.d.ts
CHANGED
|
@@ -101,7 +101,7 @@ export declare function useSearch(props: SearchProps): {
|
|
|
101
101
|
filteredData: import("../CheckTreePicker/utils").TreeNodeType[];
|
|
102
102
|
updateFilteredData: (nextData: ItemDataType[]) => void;
|
|
103
103
|
setSearchKeyword: React.Dispatch<React.SetStateAction<string>>;
|
|
104
|
-
checkShouldDisplay: (item: ItemDataType, keyword?: string
|
|
104
|
+
checkShouldDisplay: (item: ItemDataType, keyword?: string) => boolean;
|
|
105
105
|
handleSearch: (searchKeyword: string, event: React.SyntheticEvent) => void;
|
|
106
106
|
};
|
|
107
107
|
interface PickerDependentParameters {
|
package/cjs/Popover/Popover.d.ts
CHANGED
|
@@ -7,6 +7,8 @@ export interface PopoverProps extends WithAsProps {
|
|
|
7
7
|
visible?: boolean;
|
|
8
8
|
/** The content full the container */
|
|
9
9
|
full?: boolean;
|
|
10
|
+
/** Whether show the arrow indicator */
|
|
11
|
+
arrow?: boolean;
|
|
10
12
|
}
|
|
11
13
|
declare const Popover: RsRefForwardingComponent<'div', PopoverProps>;
|
|
12
14
|
export default Popover;
|