rsuite 5.20.0 → 5.21.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/CHANGELOG.md +10 -0
- package/CheckTreePicker/styles/index.less +0 -25
- package/Picker/styles/index.less +0 -10
- package/Picker/styles/mixin.less +0 -5
- package/README.md +4 -2
- package/TreePicker/styles/index.less +0 -19
- package/Windowing/package.json +7 -0
- package/cjs/Calendar/MonthDropdown.d.ts +1 -0
- package/cjs/Calendar/MonthDropdown.js +27 -40
- package/cjs/Cascader/Cascader.d.ts +2 -2
- package/cjs/Cascader/DropdownMenu.js +5 -2
- package/cjs/CheckPicker/CheckPicker.d.ts +2 -2
- package/cjs/CheckPicker/CheckPicker.js +4 -1
- package/cjs/CheckTreePicker/CheckTreePicker.js +37 -39
- package/cjs/CustomProvider/CustomProvider.d.ts +1 -108
- package/cjs/CustomProvider/CustomProvider.js +2 -5
- package/cjs/CustomProvider/index.d.ts +2 -2
- package/cjs/CustomProvider/index.js +0 -1
- package/cjs/DateRangePicker/DateRangePicker.js +5 -5
- package/cjs/Disclosure/Disclosure.d.ts +2 -2
- package/cjs/Disclosure/Disclosure.js +6 -6
- package/cjs/InputPicker/InputPicker.js +4 -1
- package/cjs/Modal/ModalBody.js +18 -17
- package/cjs/MultiCascader/DropdownMenu.js +5 -2
- package/cjs/Navbar/NavbarDropdownMenu.js +16 -10
- package/cjs/Overlay/OverlayTrigger.d.ts +2 -2
- package/cjs/Picker/DropdownMenu.d.ts +2 -1
- package/cjs/Picker/DropdownMenu.js +38 -34
- package/cjs/Picker/PickerOverlay.d.ts +2 -2
- package/cjs/Picker/PickerToggle.js +4 -1
- package/cjs/Picker/PickerToggleTrigger.d.ts +2 -2
- package/cjs/Picker/PickerToggleTrigger.js +11 -10
- package/cjs/Picker/index.d.ts +3 -3
- package/cjs/Picker/types.d.ts +7 -5
- package/cjs/Picker/utils.d.ts +11 -12
- package/cjs/Picker/utils.js +4 -0
- package/cjs/SelectPicker/SelectPicker.d.ts +4 -5
- package/cjs/SelectPicker/SelectPicker.js +4 -1
- package/cjs/Tree/Tree.d.ts +2 -5
- package/cjs/TreePicker/TreePicker.js +35 -37
- package/cjs/TreePicker/test/TreePicker.test.js +14 -0
- package/cjs/Whisper/Whisper.d.ts +3 -3
- package/cjs/Whisper/Whisper.js +11 -10
- package/cjs/Windowing/AutoSizer.d.ts +25 -0
- package/cjs/Windowing/AutoSizer.js +103 -0
- package/cjs/Windowing/List.d.ts +45 -0
- package/cjs/Windowing/List.js +72 -0
- package/cjs/Windowing/index.d.ts +5 -0
- package/cjs/Windowing/index.js +19 -0
- package/cjs/index.d.ts +1 -0
- package/cjs/toaster/ToastContainer.d.ts +2 -1
- package/cjs/toaster/ToastContainer.js +27 -26
- package/cjs/toaster/toaster.d.ts +1 -1
- package/cjs/toaster/toaster.js +43 -13
- package/cjs/toaster/useToaster.d.ts +1 -1
- package/cjs/utils/index.d.ts +1 -0
- package/cjs/utils/index.js +6 -1
- package/cjs/utils/render.d.ts +3 -0
- package/cjs/utils/render.js +49 -0
- package/cjs/utils/treeUtils.d.ts +2 -2
- package/cjs/utils/useUniqueId.js +10 -2
- package/dist/rsuite-rtl.css +0 -67
- package/dist/rsuite-rtl.min.css +1 -1
- package/dist/rsuite-rtl.min.css.map +1 -1
- package/dist/rsuite.css +0 -67
- package/dist/rsuite.js +104 -363
- 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.LICENSE.txt +2 -0
- package/dist/rsuite.min.js.map +1 -1
- package/esm/Calendar/MonthDropdown.d.ts +1 -0
- package/esm/Calendar/MonthDropdown.js +26 -41
- package/esm/Cascader/Cascader.d.ts +2 -2
- package/esm/Cascader/DropdownMenu.js +5 -2
- package/esm/CheckPicker/CheckPicker.d.ts +2 -2
- package/esm/CheckPicker/CheckPicker.js +4 -1
- package/esm/CheckTreePicker/CheckTreePicker.js +37 -38
- package/esm/CustomProvider/CustomProvider.d.ts +1 -108
- package/esm/CustomProvider/CustomProvider.js +2 -4
- package/esm/CustomProvider/index.d.ts +2 -2
- package/esm/CustomProvider/index.js +2 -2
- package/esm/DateRangePicker/DateRangePicker.js +5 -5
- package/esm/Disclosure/Disclosure.d.ts +2 -2
- package/esm/Disclosure/Disclosure.js +6 -6
- package/esm/InputPicker/InputPicker.js +4 -1
- package/esm/Modal/ModalBody.js +16 -17
- package/esm/MultiCascader/DropdownMenu.js +5 -2
- package/esm/Navbar/NavbarDropdownMenu.js +14 -8
- package/esm/Overlay/OverlayTrigger.d.ts +2 -2
- package/esm/Picker/DropdownMenu.d.ts +2 -1
- package/esm/Picker/DropdownMenu.js +38 -36
- package/esm/Picker/PickerOverlay.d.ts +2 -2
- package/esm/Picker/PickerToggle.js +4 -1
- package/esm/Picker/PickerToggleTrigger.d.ts +2 -2
- package/esm/Picker/PickerToggleTrigger.js +10 -11
- package/esm/Picker/index.d.ts +3 -3
- package/esm/Picker/types.d.ts +7 -5
- package/esm/Picker/utils.d.ts +11 -12
- package/esm/Picker/utils.js +4 -0
- package/esm/SelectPicker/SelectPicker.d.ts +4 -5
- package/esm/SelectPicker/SelectPicker.js +4 -1
- package/esm/Tree/Tree.d.ts +2 -5
- package/esm/TreePicker/TreePicker.js +34 -35
- package/esm/TreePicker/test/TreePicker.test.js +14 -0
- package/esm/Whisper/Whisper.d.ts +3 -3
- package/esm/Whisper/Whisper.js +10 -11
- package/esm/Windowing/AutoSizer.d.ts +25 -0
- package/esm/Windowing/AutoSizer.js +88 -0
- package/esm/Windowing/List.d.ts +45 -0
- package/esm/Windowing/List.js +58 -0
- package/esm/Windowing/index.d.ts +5 -0
- package/esm/Windowing/index.js +3 -0
- package/esm/index.d.ts +1 -0
- package/esm/toaster/ToastContainer.d.ts +2 -1
- package/esm/toaster/ToastContainer.js +28 -26
- package/esm/toaster/toaster.d.ts +1 -1
- package/esm/toaster/toaster.js +41 -13
- package/esm/toaster/useToaster.d.ts +1 -1
- package/esm/utils/index.d.ts +1 -0
- package/esm/utils/index.js +1 -0
- package/esm/utils/render.d.ts +3 -0
- package/esm/utils/render.js +37 -0
- package/esm/utils/treeUtils.d.ts +2 -2
- package/esm/utils/useUniqueId.js +7 -2
- package/package.json +3 -3
- package/styles/mixins/listbox.less +0 -5
- package/cjs/Picker/VirtualizedList.d.ts +0 -37
- package/cjs/Picker/VirtualizedList.js +0 -15
- package/esm/Picker/VirtualizedList.d.ts +0 -37
- package/esm/Picker/VirtualizedList.js +0 -4
package/esm/Whisper/Whisper.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { OverlayTriggerHandle } from '../Overlay/OverlayTrigger';
|
|
3
3
|
import { OverlayTriggerProps } from '../Overlay/OverlayTrigger';
|
|
4
4
|
export declare type WhisperProps = OverlayTriggerProps;
|
|
5
|
-
export declare type WhisperInstance =
|
|
6
|
-
declare const Whisper: React.ForwardRefExoticComponent<OverlayTriggerProps & React.RefAttributes<
|
|
5
|
+
export declare type WhisperInstance = OverlayTriggerHandle;
|
|
6
|
+
declare const Whisper: React.ForwardRefExoticComponent<OverlayTriggerProps & React.RefAttributes<OverlayTriggerHandle>>;
|
|
7
7
|
export default Whisper;
|
package/esm/Whisper/Whisper.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
import React from 'react';
|
|
3
|
+
import React, { useContext } from 'react';
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
5
|
import OverlayTrigger from '../Overlay/OverlayTrigger';
|
|
6
6
|
import { createChainedFunction, placementPolyfill, PLACEMENT } from '../utils';
|
|
7
|
-
import {
|
|
7
|
+
import { CustomContext } from '../CustomProvider';
|
|
8
8
|
var Whisper = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
9
9
|
var onOpen = props.onOpen,
|
|
10
10
|
onClose = props.onClose,
|
|
@@ -15,15 +15,14 @@ var Whisper = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
15
15
|
preventOverflow = props.preventOverflow,
|
|
16
16
|
rest = _objectWithoutPropertiesLoose(props, ["onOpen", "onClose", "onEntered", "onExited", "placement", "preventOverflow"]);
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
});
|
|
18
|
+
var context = useContext(CustomContext);
|
|
19
|
+
return /*#__PURE__*/React.createElement(OverlayTrigger, _extends({}, rest, {
|
|
20
|
+
ref: ref,
|
|
21
|
+
preventOverflow: preventOverflow,
|
|
22
|
+
placement: placementPolyfill(placement, context === null || context === void 0 ? void 0 : context.rtl),
|
|
23
|
+
onEntered: createChainedFunction(onOpen, onEntered),
|
|
24
|
+
onExited: createChainedFunction(onClose, onExited)
|
|
25
|
+
}));
|
|
27
26
|
});
|
|
28
27
|
Whisper.displayName = 'Whisper';
|
|
29
28
|
Whisper.propTypes = {
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface Size {
|
|
3
|
+
height: number;
|
|
4
|
+
width: number;
|
|
5
|
+
}
|
|
6
|
+
export interface AutoSizerProps {
|
|
7
|
+
/** Function responsible for rendering children. */
|
|
8
|
+
children: (size: Size) => React.ReactNode;
|
|
9
|
+
/** Optional custom CSS class name to attach to root AutoSizer element. */
|
|
10
|
+
className?: string | undefined;
|
|
11
|
+
/** Default height to use for initial render; useful for SSR */
|
|
12
|
+
defaultHeight?: number | undefined;
|
|
13
|
+
/** Default width to use for initial render; useful for SSR */
|
|
14
|
+
defaultWidth?: number | undefined;
|
|
15
|
+
/** Disable dynamic :height property */
|
|
16
|
+
disableHeight?: boolean | undefined;
|
|
17
|
+
/** Disable dynamic :width property */
|
|
18
|
+
disableWidth?: boolean | undefined;
|
|
19
|
+
/** Optional inline style */
|
|
20
|
+
style?: React.CSSProperties | undefined;
|
|
21
|
+
/** Callback to be invoked on-resize */
|
|
22
|
+
onResize?: ((size: Size) => void) | undefined;
|
|
23
|
+
}
|
|
24
|
+
declare const AutoSizer: React.ForwardRefExoticComponent<AutoSizerProps & React.RefAttributes<HTMLDivElement>>;
|
|
25
|
+
export default AutoSizer;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
+
import React, { useState, useRef } from 'react';
|
|
4
|
+
import { useCallback } from 'react';
|
|
5
|
+
import getStyle from 'dom-lib/getStyle';
|
|
6
|
+
import { mergeRefs, useElementResize, useMount } from '../utils';
|
|
7
|
+
var AutoSizer = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
8
|
+
var children = props.children,
|
|
9
|
+
className = props.className,
|
|
10
|
+
disableHeight = props.disableHeight,
|
|
11
|
+
disableWidth = props.disableWidth,
|
|
12
|
+
defaultHeight = props.defaultHeight,
|
|
13
|
+
defaultWidth = props.defaultWidth,
|
|
14
|
+
style = props.style,
|
|
15
|
+
onResize = props.onResize,
|
|
16
|
+
rest = _objectWithoutPropertiesLoose(props, ["children", "className", "disableHeight", "disableWidth", "defaultHeight", "defaultWidth", "style", "onResize"]);
|
|
17
|
+
|
|
18
|
+
var _useState = useState(defaultHeight || 0),
|
|
19
|
+
height = _useState[0],
|
|
20
|
+
setHeight = _useState[1];
|
|
21
|
+
|
|
22
|
+
var _useState2 = useState(defaultWidth || 0),
|
|
23
|
+
width = _useState2[0],
|
|
24
|
+
setWidth = _useState2[1];
|
|
25
|
+
|
|
26
|
+
var rootRef = useRef(null);
|
|
27
|
+
var getParentNode = useCallback(function () {
|
|
28
|
+
var _rootRef$current;
|
|
29
|
+
|
|
30
|
+
if ((_rootRef$current = rootRef.current) !== null && _rootRef$current !== void 0 && _rootRef$current.parentNode && rootRef.current.parentNode.ownerDocument && rootRef.current.parentNode.ownerDocument.defaultView && rootRef.current.parentNode instanceof rootRef.current.parentNode.ownerDocument.defaultView.HTMLElement) {
|
|
31
|
+
return rootRef.current.parentNode;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return null;
|
|
35
|
+
}, []);
|
|
36
|
+
var handleResize = useCallback(function () {
|
|
37
|
+
var parentNode = getParentNode();
|
|
38
|
+
|
|
39
|
+
if (parentNode) {
|
|
40
|
+
var offsetHeight = parentNode.offsetHeight || 0;
|
|
41
|
+
var offsetWidth = parentNode.offsetWidth || 0;
|
|
42
|
+
|
|
43
|
+
var _style = getStyle(parentNode);
|
|
44
|
+
|
|
45
|
+
var paddingLeft = parseInt(_style.paddingLeft, 10) || 0;
|
|
46
|
+
var paddingRight = parseInt(_style.paddingRight, 10) || 0;
|
|
47
|
+
var paddingTop = parseInt(_style.paddingTop, 10) || 0;
|
|
48
|
+
var paddingBottom = parseInt(_style.paddingBottom, 10) || 0;
|
|
49
|
+
var newHeight = offsetHeight - paddingTop - paddingBottom;
|
|
50
|
+
var newWidth = offsetWidth - paddingLeft - paddingRight;
|
|
51
|
+
|
|
52
|
+
if (!disableHeight && height !== newHeight || !disableWidth && width !== newWidth) {
|
|
53
|
+
setHeight(offsetHeight - paddingTop - paddingBottom);
|
|
54
|
+
setWidth(offsetWidth - paddingLeft - paddingRight);
|
|
55
|
+
onResize === null || onResize === void 0 ? void 0 : onResize({
|
|
56
|
+
height: offsetHeight,
|
|
57
|
+
width: offsetWidth
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}, [disableHeight, disableWidth, getParentNode, height, onResize, width]);
|
|
62
|
+
useMount(handleResize);
|
|
63
|
+
useElementResize(getParentNode(), handleResize);
|
|
64
|
+
var outerStyle = {
|
|
65
|
+
overflow: 'visible'
|
|
66
|
+
};
|
|
67
|
+
var childParams = {
|
|
68
|
+
width: 0,
|
|
69
|
+
height: 0
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
if (!disableHeight) {
|
|
73
|
+
outerStyle.height = 0;
|
|
74
|
+
childParams.height = height;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (!disableWidth) {
|
|
78
|
+
outerStyle.width = 0;
|
|
79
|
+
childParams.width = width;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return /*#__PURE__*/React.createElement("div", _extends({
|
|
83
|
+
className: className,
|
|
84
|
+
ref: mergeRefs(rootRef, ref),
|
|
85
|
+
style: _extends({}, outerStyle, style)
|
|
86
|
+
}, rest), children(childParams));
|
|
87
|
+
});
|
|
88
|
+
export default AutoSizer;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { VariableSizeList, ListItemKeySelector, ListOnScrollProps, ListOnItemsRenderedProps } from 'react-window';
|
|
2
|
+
import { WithAsProps, RsRefForwardingComponent } from '../@types/common';
|
|
3
|
+
export interface ListProps<T = any> extends WithAsProps {
|
|
4
|
+
/**
|
|
5
|
+
* @deprecated use itemSize instead
|
|
6
|
+
* Either a fixed row height (number) or a function that returns the height of a row given its index: ({ index: number }): number
|
|
7
|
+
*/
|
|
8
|
+
rowHeight?: number | (({ index: number }: {
|
|
9
|
+
index: any;
|
|
10
|
+
}) => number);
|
|
11
|
+
/**
|
|
12
|
+
* Size of a item in the direction being windowed.
|
|
13
|
+
*/
|
|
14
|
+
itemSize: number | ((index: number) => number);
|
|
15
|
+
/**
|
|
16
|
+
* Scroll offset for initial render.
|
|
17
|
+
*/
|
|
18
|
+
initialScrollOffset?: number;
|
|
19
|
+
/**
|
|
20
|
+
* By default, lists will use an item's index as its key. This is okay if:
|
|
21
|
+
*
|
|
22
|
+
* - Your collections of items is never sorted or modified
|
|
23
|
+
* - Your item renderer is not stateful and does not extend PureComponent
|
|
24
|
+
*
|
|
25
|
+
* If your list does not satisfy the above constraints, use the itemKey property to specify your own keys for items
|
|
26
|
+
*/
|
|
27
|
+
itemKey?: ListItemKeySelector<T>;
|
|
28
|
+
/**
|
|
29
|
+
* Called when the items rendered by the list change.
|
|
30
|
+
*/
|
|
31
|
+
onItemsRendered?: (props: ListOnItemsRenderedProps) => void;
|
|
32
|
+
/**
|
|
33
|
+
* Called when the list scroll positions changes, as a result of user scrolling or scroll-to method calls.
|
|
34
|
+
*/
|
|
35
|
+
onScroll?: (props: ListOnScrollProps) => void;
|
|
36
|
+
}
|
|
37
|
+
export interface ListHandle extends Partial<VariableSizeList> {
|
|
38
|
+
/**
|
|
39
|
+
* @deprecated use scrollToItem instead
|
|
40
|
+
* Ensure row is visible. This method can be used to safely scroll back to a cell that a user has scrolled away from even if it was previously scrolled to.
|
|
41
|
+
*/
|
|
42
|
+
scrollToRow?: (index: number) => void;
|
|
43
|
+
}
|
|
44
|
+
declare const List: RsRefForwardingComponent<'div', ListProps>;
|
|
45
|
+
export default List;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
+
import React, { useRef, useImperativeHandle, useCallback } from 'react';
|
|
4
|
+
import { VariableSizeList } from 'react-window';
|
|
5
|
+
import { useCustom } from '../utils';
|
|
6
|
+
var List = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
7
|
+
var rowHeight = props.rowHeight,
|
|
8
|
+
_props$as = props.as,
|
|
9
|
+
Component = _props$as === void 0 ? VariableSizeList : _props$as,
|
|
10
|
+
rest = _objectWithoutPropertiesLoose(props, ["rowHeight", "as"]);
|
|
11
|
+
|
|
12
|
+
var listRef = useRef(null);
|
|
13
|
+
|
|
14
|
+
var _useCustom = useCustom(),
|
|
15
|
+
rtl = _useCustom.rtl;
|
|
16
|
+
|
|
17
|
+
useImperativeHandle(ref, function () {
|
|
18
|
+
return {
|
|
19
|
+
resetAfterIndex: function resetAfterIndex(index, shouldForceUpdate) {
|
|
20
|
+
var _listRef$current, _listRef$current$rese;
|
|
21
|
+
|
|
22
|
+
(_listRef$current = listRef.current) === null || _listRef$current === void 0 ? void 0 : (_listRef$current$rese = _listRef$current.resetAfterIndex) === null || _listRef$current$rese === void 0 ? void 0 : _listRef$current$rese.call(_listRef$current, index, shouldForceUpdate);
|
|
23
|
+
},
|
|
24
|
+
scrollTo: function scrollTo(scrollOffset) {
|
|
25
|
+
var _listRef$current2, _listRef$current2$scr;
|
|
26
|
+
|
|
27
|
+
(_listRef$current2 = listRef.current) === null || _listRef$current2 === void 0 ? void 0 : (_listRef$current2$scr = _listRef$current2.scrollTo) === null || _listRef$current2$scr === void 0 ? void 0 : _listRef$current2$scr.call(_listRef$current2, scrollOffset);
|
|
28
|
+
},
|
|
29
|
+
scrollToItem: function scrollToItem(index, align) {
|
|
30
|
+
var _listRef$current3, _listRef$current3$scr;
|
|
31
|
+
|
|
32
|
+
(_listRef$current3 = listRef.current) === null || _listRef$current3 === void 0 ? void 0 : (_listRef$current3$scr = _listRef$current3.scrollToItem) === null || _listRef$current3$scr === void 0 ? void 0 : _listRef$current3$scr.call(_listRef$current3, index, align);
|
|
33
|
+
},
|
|
34
|
+
scrollToRow: function scrollToRow(index) {
|
|
35
|
+
var _listRef$current4, _listRef$current4$scr;
|
|
36
|
+
|
|
37
|
+
(_listRef$current4 = listRef.current) === null || _listRef$current4 === void 0 ? void 0 : (_listRef$current4$scr = _listRef$current4.scrollToItem) === null || _listRef$current4$scr === void 0 ? void 0 : _listRef$current4$scr.call(_listRef$current4, index);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
});
|
|
41
|
+
var setRowHeight = useCallback(function (index) {
|
|
42
|
+
return typeof rowHeight === 'function' ? rowHeight({
|
|
43
|
+
index: index
|
|
44
|
+
}) : rowHeight || 0;
|
|
45
|
+
}, [rowHeight]);
|
|
46
|
+
|
|
47
|
+
var compatibleProps = _extends({}, rest);
|
|
48
|
+
|
|
49
|
+
if (rowHeight) {
|
|
50
|
+
compatibleProps.itemSize = Component === VariableSizeList ? setRowHeight : rowHeight;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return /*#__PURE__*/React.createElement(Component, _extends({
|
|
54
|
+
ref: listRef,
|
|
55
|
+
direction: rtl ? 'rtl' : 'ltr'
|
|
56
|
+
}, compatibleProps));
|
|
57
|
+
});
|
|
58
|
+
export default List;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { default as AutoSizer } from './AutoSizer';
|
|
2
|
+
export { default as List } from './List';
|
|
3
|
+
export { FixedSizeList, VariableSizeList } from 'react-window';
|
|
4
|
+
export type { ListChildComponentProps } from 'react-window';
|
|
5
|
+
export type { ListProps, ListHandle } from './List';
|
package/esm/index.d.ts
CHANGED
|
@@ -155,3 +155,4 @@ export type { AffixProps } from './Affix';
|
|
|
155
155
|
export { default as CustomProvider } from './CustomProvider';
|
|
156
156
|
export type { CustomProviderProps } from './CustomProvider';
|
|
157
157
|
export type { Locale, CalendarLocale, PlaintextLocale, PaginationLocale, TableLocale, DatePickerLocale, DateRangePickerLocale, PickerLocale, InputPickerLocale, UploaderLocale, BreadcrumbLocale, ToggleLocale } from './locales';
|
|
158
|
+
export type { PickerHandle } from './Picker';
|
|
@@ -7,6 +7,7 @@ export interface ToastContainerProps extends WithAsProps {
|
|
|
7
7
|
placement?: PlacementType;
|
|
8
8
|
/** Set the message to appear in the specified container */
|
|
9
9
|
container?: HTMLElement | (() => HTMLElement);
|
|
10
|
+
callback?: (ref: React.RefObject<ToastContainerInstance>) => void;
|
|
10
11
|
}
|
|
11
12
|
export interface ToastContainerInstance {
|
|
12
13
|
root: HTMLElement;
|
|
@@ -19,7 +20,7 @@ export interface NodeProps extends WithAsProps {
|
|
|
19
20
|
onClose?: (event?: React.MouseEvent<HTMLDivElement>) => void;
|
|
20
21
|
}
|
|
21
22
|
interface ToastContainerComponent extends RsRefForwardingComponent<'div', ToastContainerProps> {
|
|
22
|
-
getInstance: (props: ToastContainerProps) => [React.RefObject<ToastContainerInstance>, () => void]
|
|
23
|
+
getInstance: (props: ToastContainerProps) => Promise<[React.RefObject<ToastContainerInstance>, () => void]>;
|
|
23
24
|
}
|
|
24
25
|
declare const ToastContainer: ToastContainerComponent;
|
|
25
26
|
export default ToastContainer;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
2
2
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
3
|
import React, { useState, useImperativeHandle, useRef, useCallback } from 'react';
|
|
4
|
-
import { render, unmountComponentAtNode } from 'react-dom';
|
|
5
4
|
import PropTypes from 'prop-types';
|
|
6
5
|
import kebabCase from 'lodash/kebabCase';
|
|
7
6
|
import Transition from '../Animation/Transition';
|
|
8
|
-
import { useClassNames, guid, createChainedFunction } from '../utils';
|
|
7
|
+
import { useClassNames, guid, createChainedFunction, render } from '../utils';
|
|
9
8
|
export var toastPlacements = ['topCenter', 'bottomCenter', 'topStart', 'topEnd', 'bottomStart', 'bottomEnd'];
|
|
10
9
|
|
|
11
10
|
var useMessages = function useMessages() {
|
|
@@ -22,13 +21,15 @@ var useMessages = function useMessages() {
|
|
|
22
21
|
}, [messages]);
|
|
23
22
|
var push = useCallback(function (message) {
|
|
24
23
|
var key = guid();
|
|
25
|
-
setMessages(
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
24
|
+
setMessages(function (prevMessages) {
|
|
25
|
+
return [].concat(prevMessages, [{
|
|
26
|
+
key: key,
|
|
27
|
+
visible: true,
|
|
28
|
+
node: message
|
|
29
|
+
}]);
|
|
30
|
+
});
|
|
30
31
|
return key;
|
|
31
|
-
}, [
|
|
32
|
+
}, []);
|
|
32
33
|
var clear = useCallback(function () {
|
|
33
34
|
// Set all existing messages to be invisible.
|
|
34
35
|
setMessages(messages.map(function (msg) {
|
|
@@ -76,7 +77,8 @@ var ToastContainer = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
76
77
|
classPrefix = _props$classPrefix === void 0 ? 'toast-container' : _props$classPrefix,
|
|
77
78
|
_props$placement = props.placement,
|
|
78
79
|
placement = _props$placement === void 0 ? 'topCenter' : _props$placement,
|
|
79
|
-
|
|
80
|
+
callback = props.callback,
|
|
81
|
+
rest = _objectWithoutPropertiesLoose(props, ["as", "className", "classPrefix", "placement", "callback"]);
|
|
80
82
|
|
|
81
83
|
var _useClassNames = useClassNames(classPrefix),
|
|
82
84
|
withClassPrefix = _useClassNames.withClassPrefix,
|
|
@@ -125,7 +127,10 @@ var ToastContainer = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
125
127
|
});
|
|
126
128
|
});
|
|
127
129
|
return /*#__PURE__*/React.createElement(Component, _extends({}, rest, {
|
|
128
|
-
ref:
|
|
130
|
+
ref: function ref(selfRef) {
|
|
131
|
+
rootRef.current = selfRef;
|
|
132
|
+
callback === null || callback === void 0 ? void 0 : callback(selfRef);
|
|
133
|
+
},
|
|
129
134
|
className: classes
|
|
130
135
|
}), elements);
|
|
131
136
|
});
|
|
@@ -135,22 +140,18 @@ ToastContainer.getInstance = function (props) {
|
|
|
135
140
|
rest = _objectWithoutPropertiesLoose(props, ["container"]);
|
|
136
141
|
|
|
137
142
|
var containerRef = /*#__PURE__*/React.createRef();
|
|
138
|
-
var
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
parentElement.appendChild(mountElement);
|
|
144
|
-
|
|
145
|
-
function destroy() {
|
|
146
|
-
unmountComponentAtNode(mountElement);
|
|
147
|
-
parentElement.removeChild(mountElement);
|
|
148
|
-
}
|
|
143
|
+
var containerElement = (typeof container === 'function' ? container() : container) || document.body;
|
|
144
|
+
return new Promise(function (resolve) {
|
|
145
|
+
var renderCallback = function renderCallback() {
|
|
146
|
+
resolve([containerRef, unmount]);
|
|
147
|
+
};
|
|
149
148
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
149
|
+
var _render = render( /*#__PURE__*/React.createElement(ToastContainer, _extends({}, rest, {
|
|
150
|
+
ref: containerRef,
|
|
151
|
+
callback: renderCallback
|
|
152
|
+
})), containerElement),
|
|
153
|
+
unmount = _render.unmount;
|
|
154
|
+
});
|
|
154
155
|
};
|
|
155
156
|
|
|
156
157
|
ToastContainer.displayName = 'ToastContainer';
|
|
@@ -158,6 +159,7 @@ ToastContainer.propTypes = {
|
|
|
158
159
|
className: PropTypes.string,
|
|
159
160
|
classPrefix: PropTypes.string,
|
|
160
161
|
placement: PropTypes.elementType,
|
|
161
|
-
container: PropTypes.oneOfType([PropTypes.node, PropTypes.func])
|
|
162
|
+
container: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
|
|
163
|
+
callback: PropTypes.func
|
|
162
164
|
};
|
|
163
165
|
export default ToastContainer;
|
package/esm/toaster/toaster.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export interface Toaster {
|
|
|
7
7
|
* @param message
|
|
8
8
|
* @param options
|
|
9
9
|
*/
|
|
10
|
-
push(message: React.ReactNode, options?: ToastContainerProps): string | undefined
|
|
10
|
+
push(message: React.ReactNode, options?: ToastContainerProps): string | undefined | Promise<string | undefined>;
|
|
11
11
|
/**
|
|
12
12
|
* Remove a message by key
|
|
13
13
|
* @param key
|
package/esm/toaster/toaster.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
2
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
1
3
|
import ToastContainer from './ToastContainer';
|
|
2
4
|
var defaultContainerId = 'default';
|
|
3
5
|
var containers = new Map();
|
|
@@ -7,12 +9,8 @@ var containers = new Map();
|
|
|
7
9
|
* @param options
|
|
8
10
|
*/
|
|
9
11
|
|
|
10
|
-
function createContainer(
|
|
11
|
-
|
|
12
|
-
container = _ToastContainer$getIn[0];
|
|
13
|
-
|
|
14
|
-
containers.set(containerId || defaultContainerId, container);
|
|
15
|
-
return container;
|
|
12
|
+
function createContainer(_x, _x2) {
|
|
13
|
+
return _createContainer.apply(this, arguments);
|
|
16
14
|
}
|
|
17
15
|
/**
|
|
18
16
|
* Get the container by ID. Use default ID when ID is not available.
|
|
@@ -20,6 +18,33 @@ function createContainer(containerId, props) {
|
|
|
20
18
|
*/
|
|
21
19
|
|
|
22
20
|
|
|
21
|
+
function _createContainer() {
|
|
22
|
+
_createContainer = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(containerId, props) {
|
|
23
|
+
var _yield$ToastContainer, container;
|
|
24
|
+
|
|
25
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
26
|
+
while (1) {
|
|
27
|
+
switch (_context.prev = _context.next) {
|
|
28
|
+
case 0:
|
|
29
|
+
_context.next = 2;
|
|
30
|
+
return ToastContainer.getInstance(props);
|
|
31
|
+
|
|
32
|
+
case 2:
|
|
33
|
+
_yield$ToastContainer = _context.sent;
|
|
34
|
+
container = _yield$ToastContainer[0];
|
|
35
|
+
containers.set(containerId || defaultContainerId, container);
|
|
36
|
+
return _context.abrupt("return", container);
|
|
37
|
+
|
|
38
|
+
case 6:
|
|
39
|
+
case "end":
|
|
40
|
+
return _context.stop();
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}, _callee);
|
|
44
|
+
}));
|
|
45
|
+
return _createContainer.apply(this, arguments);
|
|
46
|
+
}
|
|
47
|
+
|
|
23
48
|
function getContainer(containerId) {
|
|
24
49
|
if (containers.size == 0) {
|
|
25
50
|
return null;
|
|
@@ -33,21 +58,24 @@ var toaster = function toaster(message) {
|
|
|
33
58
|
};
|
|
34
59
|
|
|
35
60
|
toaster.push = function (message, options) {
|
|
36
|
-
var
|
|
61
|
+
var _options;
|
|
37
62
|
|
|
38
63
|
if (options === void 0) {
|
|
39
64
|
options = {};
|
|
40
65
|
}
|
|
41
66
|
|
|
42
|
-
var
|
|
67
|
+
var containerId = (_options = options) === null || _options === void 0 ? void 0 : _options.placement;
|
|
68
|
+
var container = getContainer(containerId);
|
|
43
69
|
|
|
44
|
-
if (
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
container = createContainer((_options$placement = options.placement) !== null && _options$placement !== void 0 ? _options$placement : '', options);
|
|
70
|
+
if (container !== null && container !== void 0 && container.current) {
|
|
71
|
+
return container.current.push(message);
|
|
48
72
|
}
|
|
49
73
|
|
|
50
|
-
return (
|
|
74
|
+
return createContainer(containerId !== null && containerId !== void 0 ? containerId : '', options).then(function (ref) {
|
|
75
|
+
var _ref$current;
|
|
76
|
+
|
|
77
|
+
return (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.push(message);
|
|
78
|
+
});
|
|
51
79
|
};
|
|
52
80
|
|
|
53
81
|
toaster.remove = function (key) {
|
|
@@ -5,7 +5,7 @@ import { ToastContainerProps } from './ToastContainer';
|
|
|
5
5
|
* @returns toaster { push, remove, clear }
|
|
6
6
|
*/
|
|
7
7
|
declare const useToaster: () => {
|
|
8
|
-
push: (message: React.ReactNode, options?: ToastContainerProps) => string | undefined;
|
|
8
|
+
push: (message: React.ReactNode, options?: ToastContainerProps) => string | Promise<string | undefined> | undefined;
|
|
9
9
|
remove: (key: string) => void;
|
|
10
10
|
clear: () => void;
|
|
11
11
|
};
|
package/esm/utils/index.d.ts
CHANGED
|
@@ -23,6 +23,7 @@ export { default as composeFunctions } from './composeFunctions';
|
|
|
23
23
|
export { default as reactToString } from './reactToString';
|
|
24
24
|
export { default as scrollTopAnimation } from './scrollTopAnimation';
|
|
25
25
|
export { default as appendTooltip } from './appendTooltip';
|
|
26
|
+
export { default as render } from './render';
|
|
26
27
|
/** Hooks **/
|
|
27
28
|
export { default as useClassNames } from './useClassNames';
|
|
28
29
|
export { default as useEventListener } from './useEventListener';
|
package/esm/utils/index.js
CHANGED
|
@@ -25,6 +25,7 @@ export { default as composeFunctions } from './composeFunctions';
|
|
|
25
25
|
export { default as reactToString } from './reactToString';
|
|
26
26
|
export { default as scrollTopAnimation } from './scrollTopAnimation';
|
|
27
27
|
export { default as appendTooltip } from './appendTooltip';
|
|
28
|
+
export { default as render } from './render';
|
|
28
29
|
/** Hooks **/
|
|
29
30
|
|
|
30
31
|
export { default as useClassNames } from './useClassNames';
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import * as ReactDOM from 'react-dom';
|
|
3
|
+
var majorVersion = parseInt(React.version);
|
|
4
|
+
var SuperposedReactDOM = ReactDOM;
|
|
5
|
+
|
|
6
|
+
function render(element, container) {
|
|
7
|
+
var mountElement = document.createElement('div');
|
|
8
|
+
mountElement.className = 'rs-mount-element';
|
|
9
|
+
var containerElement = container || document.body; // Add the detached element to the root
|
|
10
|
+
|
|
11
|
+
containerElement.appendChild(mountElement);
|
|
12
|
+
|
|
13
|
+
if (majorVersion >= 18) {
|
|
14
|
+
/**
|
|
15
|
+
* ignore react 18 warnings
|
|
16
|
+
* Warning: You are importing createRoot from "react-dom" which is not supported. You should instead import it from "react-dom/client".
|
|
17
|
+
*/
|
|
18
|
+
ReactDOM['__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED'].usingClientEntryPoint = true;
|
|
19
|
+
var createRoot = SuperposedReactDOM.createRoot;
|
|
20
|
+
var root = containerElement.__root || createRoot(mountElement, {
|
|
21
|
+
identifierPrefix: 'rs-root-'
|
|
22
|
+
});
|
|
23
|
+
root.render(element);
|
|
24
|
+
containerElement.__root = root;
|
|
25
|
+
return root;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
SuperposedReactDOM.render(element, mountElement);
|
|
29
|
+
return {
|
|
30
|
+
unmount: function unmount() {
|
|
31
|
+
SuperposedReactDOM.unmountComponentAtNode(mountElement);
|
|
32
|
+
containerElement.removeChild(mountElement);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export default render;
|
package/esm/utils/treeUtils.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { TREE_NODE_DROP_POSITION } from '../utils';
|
|
|
4
4
|
import { CheckTreePickerProps } from '../CheckTreePicker/CheckTreePicker';
|
|
5
5
|
import { ItemDataType } from '../@types/common';
|
|
6
6
|
import { TreePickerProps } from '../TreePicker/TreePicker';
|
|
7
|
-
import {
|
|
7
|
+
import { ListHandle } from '../Windowing';
|
|
8
8
|
declare type PartialTreeProps = Partial<TreePickerProps | CheckTreePickerProps>;
|
|
9
9
|
/**
|
|
10
10
|
* according node parentNode expand state decide node whether to show
|
|
@@ -236,7 +236,7 @@ export interface FocusToTreeNodeProps {
|
|
|
236
236
|
activeNode: any;
|
|
237
237
|
virtualized: boolean;
|
|
238
238
|
container: HTMLElement | null;
|
|
239
|
-
list:
|
|
239
|
+
list: ListHandle;
|
|
240
240
|
formattedNodes: TreeNodeType[];
|
|
241
241
|
}
|
|
242
242
|
/**
|
package/esm/utils/useUniqueId.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as React from 'react';
|
|
2
2
|
import uniqueId from 'lodash/uniqueId';
|
|
3
|
+
var reactUseId = React['useId' + ''];
|
|
3
4
|
/**
|
|
4
5
|
* Used for generating unique ID for DOM elements
|
|
5
6
|
*
|
|
@@ -7,7 +8,11 @@ import uniqueId from 'lodash/uniqueId';
|
|
|
7
8
|
*/
|
|
8
9
|
|
|
9
10
|
export default function useUniqueId(prefix, idProp) {
|
|
10
|
-
var idRef = useRef();
|
|
11
|
+
var idRef = React.useRef();
|
|
12
|
+
|
|
13
|
+
if (reactUseId !== undefined) {
|
|
14
|
+
return idProp !== null && idProp !== void 0 ? idProp : "" + prefix + reactUseId();
|
|
15
|
+
}
|
|
11
16
|
|
|
12
17
|
if (!idRef.current) {
|
|
13
18
|
idRef.current = uniqueId(prefix);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rsuite",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.21.0",
|
|
4
4
|
"description": "A suite of react components",
|
|
5
5
|
"main": "cjs/index.js",
|
|
6
6
|
"module": "esm/index.js",
|
|
@@ -30,13 +30,13 @@
|
|
|
30
30
|
"@types/chai": "^4.3.3",
|
|
31
31
|
"@types/lodash": "^4.14.184",
|
|
32
32
|
"@types/prop-types": "^15.7.5",
|
|
33
|
-
"@types/react-
|
|
33
|
+
"@types/react-window": "^1.8.5",
|
|
34
34
|
"classnames": "^2.3.1",
|
|
35
35
|
"date-fns": "^2.29.3",
|
|
36
36
|
"dom-lib": "^3.1.3",
|
|
37
37
|
"lodash": "^4.17.11",
|
|
38
38
|
"prop-types": "^15.8.1",
|
|
39
|
-
"react-
|
|
39
|
+
"react-window": "^1.8.7",
|
|
40
40
|
"rsuite-table": "^5.7.2",
|
|
41
41
|
"schema-typed": "^2.0.3"
|
|
42
42
|
},
|