rsuite 5.1.0 → 5.2.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 +7 -1
- package/CHANGELOG.md +45 -0
- package/PanelGroup/styles/index.less +12 -12
- package/README.md +3 -45
- package/Sidenav/styles/index.less +4 -0
- package/Slider/styles/index.less +20 -14
- package/Toggle/styles/index.less +48 -27
- package/Toggle/styles/mixin.less +16 -14
- package/cjs/@types/common.d.ts +8 -2
- package/cjs/Affix/Affix.js +3 -3
- package/cjs/Animation/Collapse.js +9 -7
- package/cjs/Animation/Transition.js +4 -2
- package/cjs/AutoComplete/AutoComplete.d.ts +2 -2
- package/cjs/AutoComplete/AutoComplete.js +7 -4
- package/cjs/Calendar/TimeDropdown.js +5 -3
- package/cjs/Cascader/Cascader.d.ts +1 -1
- package/cjs/Cascader/DropdownMenu.js +6 -5
- package/cjs/CheckTreePicker/CheckTreeNode.d.ts +1 -1
- package/cjs/CheckTreePicker/CheckTreePicker.d.ts +1 -1
- package/cjs/CheckTreePicker/utils.d.ts +1 -1
- package/cjs/CheckTreePicker/utils.js +7 -6
- package/cjs/Checkbox/Checkbox.d.ts +3 -3
- package/cjs/CheckboxGroup/CheckboxGroup.js +2 -2
- package/cjs/CheckboxGroup/CheckboxGroupContext.d.ts +1 -1
- package/cjs/DOMHelper/index.d.ts +12 -27
- package/cjs/DOMHelper/index.js +4 -3
- package/cjs/DOMHelper/isElement.d.ts +2 -0
- package/cjs/DOMHelper/isElement.js +11 -0
- package/cjs/DatePicker/DatePicker.d.ts +3 -3
- package/cjs/DateRangePicker/Calendar.d.ts +1 -1
- package/cjs/DateRangePicker/DateRangePicker.d.ts +2 -2
- package/cjs/Disclosure/Disclosure.d.ts +1 -1
- package/cjs/Disclosure/DisclosureContext.d.ts +1 -1
- package/cjs/Dropdown/DropdownItem.d.ts +1 -1
- package/cjs/Dropdown/DropdownItem.js +16 -19
- package/cjs/Dropdown/DropdownMenu.d.ts +2 -2
- package/cjs/Dropdown/useRenderDropdownItem.d.ts +2 -0
- package/cjs/Dropdown/useRenderDropdownItem.js +26 -0
- package/cjs/Form/Form.d.ts +1 -1
- package/cjs/FormControl/FormControl.d.ts +9 -3
- package/cjs/Input/Input.d.ts +2 -1
- package/cjs/InputNumber/InputNumber.js +2 -2
- package/cjs/InputPicker/InputPicker.js +3 -3
- package/cjs/List/helper/useSortHelper.js +11 -6
- package/cjs/MaskedInput/MaskedInput.d.ts +5 -42
- package/cjs/MaskedInput/MaskedInput.js +9 -63
- package/cjs/MaskedInput/TextMask.d.ts +43 -0
- package/cjs/MaskedInput/TextMask.js +80 -0
- package/cjs/Menu/Menu.js +46 -34
- package/cjs/Menu/MenuItem.d.ts +1 -1
- package/cjs/Menu/MenuItem.js +16 -12
- package/cjs/Menu/Menubar.d.ts +1 -1
- package/cjs/Message/Message.js +13 -11
- package/cjs/Modal/Modal.js +5 -3
- package/cjs/Modal/utils.js +15 -14
- package/cjs/Notification/Notification.js +6 -3
- package/cjs/Overlay/Modal.js +14 -11
- package/cjs/Overlay/ModalManager.js +19 -7
- package/cjs/Overlay/OverlayTrigger.js +2 -2
- package/cjs/Overlay/Position.js +27 -17
- package/cjs/Overlay/positionUtils.js +16 -8
- package/cjs/Panel/Panel.d.ts +1 -1
- package/cjs/Picker/DropdownMenu.js +10 -6
- package/cjs/Picker/DropdownMenuCheckItem.d.ts +3 -3
- package/cjs/Picker/PickerOverlay.js +5 -3
- package/cjs/Picker/PickerToggle.d.ts +6 -0
- package/cjs/Picker/PickerToggle.js +16 -8
- package/cjs/Picker/SearchBar.d.ts +1 -1
- package/cjs/Picker/utils.d.ts +2 -2
- package/cjs/Radio/Radio.d.ts +1 -1
- package/cjs/RadioGroup/RadioGroup.d.ts +1 -1
- package/cjs/RadioGroup/RadioGroup.js +2 -2
- package/cjs/RangeSlider/RangeSlider.js +9 -5
- package/cjs/Rate/Character.js +2 -2
- package/cjs/Rate/Rate.js +3 -1
- package/cjs/Ripple/Ripple.js +6 -7
- package/cjs/Sidenav/SidenavDropdownItem.d.ts +1 -1
- package/cjs/Sidenav/SidenavDropdownItem.js +17 -10
- package/cjs/Sidenav/SidenavDropdownMenu.d.ts +1 -1
- package/cjs/Slider/Graduated.js +1 -1
- package/cjs/Slider/Handle.js +10 -5
- package/cjs/Slider/ProgressBar.js +1 -1
- package/cjs/Slider/Slider.js +9 -5
- package/cjs/Toggle/Toggle.d.ts +3 -6
- package/cjs/Toggle/Toggle.js +32 -27
- package/cjs/Tree/Tree.d.ts +3 -3
- package/cjs/TreePicker/TreeNode.d.ts +1 -1
- package/cjs/TreePicker/TreeNode.js +2 -2
- package/cjs/TreePicker/TreePicker.d.ts +1 -1
- package/cjs/Uploader/Uploader.d.ts +4 -4
- package/cjs/locales/fa_IR.js +8 -8
- package/cjs/utils/BrowserDetection.js +1 -1
- package/cjs/utils/index.d.ts +1 -0
- package/cjs/utils/index.js +7 -2
- package/cjs/utils/scrollTopAnimation.js +5 -5
- package/cjs/utils/treeUtils.d.ts +2 -2
- package/cjs/utils/useElementResize.d.ts +1 -1
- package/cjs/utils/useElementResize.js +11 -6
- package/cjs/utils/useEventListener.js +4 -2
- package/cjs/utils/useIsMounted.d.ts +2 -0
- package/cjs/utils/useIsMounted.js +22 -0
- package/cjs/utils/usePortal.js +2 -2
- package/cjs/utils/useRootClose.js +10 -10
- package/dist/rsuite-rtl.css +194 -119
- package/dist/rsuite-rtl.min.css +1 -1
- package/dist/rsuite-rtl.min.css.map +1 -1
- package/dist/rsuite.css +194 -119
- package/dist/rsuite.js +703 -504
- 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 +9 -0
- package/dist/rsuite.min.js.map +1 -1
- package/esm/@types/common.d.ts +8 -2
- package/esm/Affix/Affix.js +1 -1
- package/esm/Animation/Collapse.js +2 -1
- package/esm/Animation/Transition.js +3 -2
- package/esm/AutoComplete/AutoComplete.d.ts +2 -2
- package/esm/AutoComplete/AutoComplete.js +8 -5
- package/esm/Calendar/TimeDropdown.js +2 -1
- package/esm/Cascader/Cascader.d.ts +1 -1
- package/esm/Cascader/DropdownMenu.js +4 -3
- package/esm/CheckTreePicker/CheckTreeNode.d.ts +1 -1
- package/esm/CheckTreePicker/CheckTreePicker.d.ts +1 -1
- package/esm/CheckTreePicker/utils.d.ts +1 -1
- package/esm/CheckTreePicker/utils.js +7 -6
- package/esm/Checkbox/Checkbox.d.ts +3 -3
- package/esm/CheckboxGroup/CheckboxGroup.js +2 -2
- package/esm/CheckboxGroup/CheckboxGroupContext.d.ts +1 -1
- package/esm/DOMHelper/index.d.ts +12 -27
- package/esm/DOMHelper/index.js +2 -3
- package/esm/DOMHelper/isElement.d.ts +2 -0
- package/esm/DOMHelper/isElement.js +5 -0
- package/esm/DatePicker/DatePicker.d.ts +3 -3
- package/esm/DateRangePicker/Calendar.d.ts +1 -1
- package/esm/DateRangePicker/DateRangePicker.d.ts +2 -2
- package/esm/Disclosure/Disclosure.d.ts +1 -1
- package/esm/Disclosure/DisclosureContext.d.ts +1 -1
- package/esm/Dropdown/DropdownItem.d.ts +1 -1
- package/esm/Dropdown/DropdownItem.js +15 -19
- package/esm/Dropdown/DropdownMenu.d.ts +2 -2
- package/esm/Dropdown/useRenderDropdownItem.d.ts +2 -0
- package/esm/Dropdown/useRenderDropdownItem.js +18 -0
- package/esm/Form/Form.d.ts +1 -1
- package/esm/FormControl/FormControl.d.ts +9 -3
- package/esm/Input/Input.d.ts +2 -1
- package/esm/InputNumber/InputNumber.js +2 -2
- package/esm/InputPicker/InputPicker.js +2 -2
- package/esm/List/helper/useSortHelper.js +8 -4
- package/esm/MaskedInput/MaskedInput.d.ts +5 -42
- package/esm/MaskedInput/MaskedInput.js +9 -63
- package/esm/MaskedInput/TextMask.d.ts +43 -0
- package/esm/MaskedInput/TextMask.js +67 -0
- package/esm/Menu/Menu.js +46 -36
- package/esm/Menu/MenuItem.d.ts +1 -1
- package/esm/Menu/MenuItem.js +16 -12
- package/esm/Menu/Menubar.d.ts +1 -1
- package/esm/Message/Message.js +15 -13
- package/esm/Modal/Modal.js +3 -2
- package/esm/Modal/utils.js +14 -12
- package/esm/Notification/Notification.js +7 -4
- package/esm/Overlay/Modal.js +11 -8
- package/esm/Overlay/ModalManager.js +6 -1
- package/esm/Overlay/OverlayTrigger.js +1 -1
- package/esm/Overlay/Position.js +20 -11
- package/esm/Overlay/positionUtils.js +5 -1
- package/esm/Panel/Panel.d.ts +1 -1
- package/esm/Picker/DropdownMenu.js +3 -1
- package/esm/Picker/DropdownMenuCheckItem.d.ts +3 -3
- package/esm/Picker/PickerOverlay.js +2 -1
- package/esm/Picker/PickerToggle.d.ts +6 -0
- package/esm/Picker/PickerToggle.js +15 -8
- package/esm/Picker/SearchBar.d.ts +1 -1
- package/esm/Picker/utils.d.ts +2 -2
- package/esm/Radio/Radio.d.ts +1 -1
- package/esm/RadioGroup/RadioGroup.d.ts +1 -1
- package/esm/RadioGroup/RadioGroup.js +2 -2
- package/esm/RangeSlider/RangeSlider.js +4 -2
- package/esm/Rate/Character.js +2 -2
- package/esm/Rate/Rate.js +2 -1
- package/esm/Ripple/Ripple.js +4 -3
- package/esm/Sidenav/SidenavDropdownItem.d.ts +1 -1
- package/esm/Sidenav/SidenavDropdownItem.js +16 -10
- package/esm/Sidenav/SidenavDropdownMenu.d.ts +1 -1
- package/esm/Slider/Graduated.js +1 -1
- package/esm/Slider/Handle.js +5 -2
- package/esm/Slider/ProgressBar.js +1 -1
- package/esm/Slider/Slider.js +4 -2
- package/esm/Toggle/Toggle.d.ts +3 -6
- package/esm/Toggle/Toggle.js +34 -29
- package/esm/Tree/Tree.d.ts +3 -3
- package/esm/TreePicker/TreeNode.d.ts +1 -1
- package/esm/TreePicker/TreeNode.js +1 -1
- package/esm/TreePicker/TreePicker.d.ts +1 -1
- package/esm/Uploader/Uploader.d.ts +4 -4
- package/esm/locales/fa_IR.js +8 -8
- package/esm/utils/BrowserDetection.js +1 -1
- package/esm/utils/index.d.ts +1 -0
- package/esm/utils/index.js +2 -1
- package/esm/utils/scrollTopAnimation.js +2 -2
- package/esm/utils/treeUtils.d.ts +2 -2
- package/esm/utils/useElementResize.d.ts +1 -1
- package/esm/utils/useElementResize.js +12 -5
- package/esm/utils/useEventListener.js +1 -1
- package/esm/utils/useIsMounted.d.ts +2 -0
- package/esm/utils/useIsMounted.js +16 -0
- package/esm/utils/usePortal.js +2 -2
- package/esm/utils/useRootClose.js +8 -6
- package/package.json +5 -5
- package/styles/plugins/palette.js +10 -1
|
@@ -4,10 +4,11 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
4
4
|
|
|
5
5
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
6
6
|
|
|
7
|
-
import
|
|
7
|
+
import on from 'dom-lib/on';
|
|
8
8
|
import { useCallback, useRef, useState } from 'react';
|
|
9
9
|
import AutoScroller from './AutoScroller';
|
|
10
10
|
import { closestNode, getEdgeOffset, getScrollingParent, isContainInteractiveElement, setInlineStyles, setTransitionDuration, setTranslate3d } from './utils';
|
|
11
|
+
import { useIsMounted } from '../../utils';
|
|
11
12
|
import useManager from './useManager';
|
|
12
13
|
|
|
13
14
|
var useSortHelper = function useSortHelper(config) {
|
|
@@ -30,14 +31,16 @@ var useSortHelper = function useSortHelper(config) {
|
|
|
30
31
|
listItemRegister = _useManager.listItemRegister,
|
|
31
32
|
getManagedItem = _useManager.getManagedItem,
|
|
32
33
|
getOrderedItems = _useManager.getOrderedItems;
|
|
34
|
+
|
|
35
|
+
var isMounted = useIsMounted();
|
|
33
36
|
/**
|
|
34
37
|
* start dragging
|
|
35
38
|
* */
|
|
36
39
|
|
|
37
|
-
|
|
38
40
|
var handlePress = useCallback(function (mouseDownEvent, targetNode, curManagedItem) {
|
|
39
41
|
var _activeNodeHelper;
|
|
40
42
|
|
|
43
|
+
if (!isMounted()) return;
|
|
41
44
|
var listItemBaseClassName = targetNode.classList[0]; // get list item base className
|
|
42
45
|
|
|
43
46
|
var helperElementClass = listItemBaseClassName + "-helper";
|
|
@@ -217,7 +220,8 @@ var useSortHelper = function useSortHelper(config) {
|
|
|
217
220
|
setTimeout(function () {
|
|
218
221
|
var _activeNodeHelper2, _activeNodeHelper2$pa;
|
|
219
222
|
|
|
220
|
-
// Remove the helper from the DOM
|
|
223
|
+
if (!isMounted()) return; // Remove the helper from the DOM
|
|
224
|
+
|
|
221
225
|
(_activeNodeHelper2 = activeNodeHelper) === null || _activeNodeHelper2 === void 0 ? void 0 : (_activeNodeHelper2$pa = _activeNodeHelper2.parentNode) === null || _activeNodeHelper2$pa === void 0 ? void 0 : _activeNodeHelper2$pa.removeChild(activeNodeHelper);
|
|
222
226
|
activeNodeHelper = null; // Remove redundant styles
|
|
223
227
|
|
|
@@ -260,7 +264,7 @@ var useSortHelper = function useSortHelper(config) {
|
|
|
260
264
|
oldIndex: activeNodeOldIndex,
|
|
261
265
|
newIndex: activeNodeNextIndex
|
|
262
266
|
}, mouseDownEvent.nativeEvent);
|
|
263
|
-
}, [autoScroll, getOrderedItems, onSort, onSortEnd, onSortMove, onSortStart, transitionDuration]);
|
|
267
|
+
}, [autoScroll, getOrderedItems, isMounted, onSort, onSortEnd, onSortMove, onSortStart, transitionDuration]);
|
|
264
268
|
/**
|
|
265
269
|
* Determine whether to start dragging
|
|
266
270
|
* */
|
|
@@ -1,43 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
interface TextMaskProps {
|
|
7
|
-
/**
|
|
8
|
-
* `guide` is a boolean that tells the component whether to be in guide or no guide mode.
|
|
9
|
-
*/
|
|
10
|
-
guide?: boolean;
|
|
11
|
-
/**
|
|
12
|
-
* `mask` is an array or a function that defines how the user input is going to be masked.
|
|
13
|
-
*/
|
|
14
|
-
mask?: MaskType | MaskFunctionType | boolean;
|
|
15
|
-
/**
|
|
16
|
-
* `showMask` is a boolean that tells the Text Mask component to display the mask as a placeholder
|
|
17
|
-
* in place of the regular placeholder when the input element value is empty.
|
|
18
|
-
*/
|
|
19
|
-
showMask?: boolean;
|
|
20
|
-
/** The placeholder character represents the fillable spot in the mask. The default placeholder character is underscore, _. */
|
|
21
|
-
placeholderChar?: string;
|
|
22
|
-
/** `keepCharPositions` changes the general behavior of the Text Mask component. */
|
|
23
|
-
keepCharPositions?: boolean;
|
|
24
|
-
/** You can provide a `pipe` function that will give you the opportunity to modify the conformed value before it is displayed on the screen. */
|
|
25
|
-
pipe?: (conformedValue: string, config: ConfigType) => string;
|
|
26
|
-
}
|
|
27
|
-
export declare type MaskedInputProps = TextMaskProps & React.HTMLAttributes<HTMLInputElement> & {
|
|
28
|
-
/** Custom rendering DOM */
|
|
29
|
-
render?: (ref: React.Ref<HTMLInputElement>, props: React.HTMLAttributes<HTMLInputElement>) => any;
|
|
30
|
-
onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
31
|
-
value?: string | number;
|
|
32
|
-
readOnly?: boolean;
|
|
33
|
-
disabled?: boolean;
|
|
34
|
-
};
|
|
35
|
-
declare const MaskedInput: React.ForwardRefExoticComponent<TextMaskProps & React.HTMLAttributes<HTMLInputElement> & {
|
|
36
|
-
/** Custom rendering DOM */
|
|
37
|
-
render?: (ref: React.Ref<HTMLInputElement>, props: React.HTMLAttributes<HTMLInputElement>) => any;
|
|
38
|
-
onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
39
|
-
value?: string | number;
|
|
40
|
-
readOnly?: boolean;
|
|
41
|
-
disabled?: boolean;
|
|
42
|
-
} & React.RefAttributes<HTMLInputElement>>;
|
|
1
|
+
import { InputProps } from '../Input';
|
|
2
|
+
import type { TextMaskProps } from './TextMask';
|
|
3
|
+
import { RsRefForwardingComponent } from '../@types/common';
|
|
4
|
+
export declare type MaskedInputProps = Omit<TextMaskProps, 'onChange'> & Omit<InputProps, 'type'>;
|
|
5
|
+
declare const MaskedInput: RsRefForwardingComponent<'input', MaskedInputProps>;
|
|
43
6
|
export default MaskedInput;
|
|
@@ -1,67 +1,13 @@
|
|
|
1
|
-
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
2
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
-
import React
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import createTextMaskInputElement from './createTextMaskInputElement';
|
|
7
|
-
import { mergeRefs } from '../utils';
|
|
8
|
-
/**
|
|
9
|
-
* https://github.com/text-mask/text-mask/blob/master/componentDocumentation.md#guide
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
var defaultRender = function defaultRender(ref, props) {
|
|
13
|
-
return /*#__PURE__*/React.createElement("input", _extends({
|
|
14
|
-
ref: ref
|
|
15
|
-
}, props));
|
|
16
|
-
};
|
|
17
|
-
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import TextMask from './TextMask';
|
|
4
|
+
import Input from '../Input';
|
|
18
5
|
var MaskedInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
19
|
-
var
|
|
20
|
-
_props$
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
pipe = props.pipe,
|
|
26
|
-
_props$render = props.render,
|
|
27
|
-
render = _props$render === void 0 ? defaultRender : _props$render,
|
|
28
|
-
onChange = props.onChange,
|
|
29
|
-
rest = _objectWithoutPropertiesLoose(props, ["mask", "guide", "placeholderChar", "value", "showMask", "pipe", "render", "onChange"]);
|
|
30
|
-
|
|
31
|
-
var inputRef = useRef(null);
|
|
32
|
-
var textMaskInputElement = useRef();
|
|
33
|
-
var initTextMask = useCallback(function () {
|
|
34
|
-
var _textMaskInputElement;
|
|
35
|
-
|
|
36
|
-
textMaskInputElement.current = createTextMaskInputElement(_extends({
|
|
37
|
-
inputElement: inputRef.current
|
|
38
|
-
}, props));
|
|
39
|
-
(_textMaskInputElement = textMaskInputElement.current) === null || _textMaskInputElement === void 0 ? void 0 : _textMaskInputElement.update(value);
|
|
40
|
-
}, [props, value]);
|
|
41
|
-
var handleChange = useCallback(function (event) {
|
|
42
|
-
var _textMaskInputElement2;
|
|
43
|
-
|
|
44
|
-
(_textMaskInputElement2 = textMaskInputElement.current) === null || _textMaskInputElement2 === void 0 ? void 0 : _textMaskInputElement2.update();
|
|
45
|
-
onChange === null || onChange === void 0 ? void 0 : onChange(event);
|
|
46
|
-
}, [onChange]);
|
|
47
|
-
useEffect(function () {
|
|
48
|
-
initTextMask();
|
|
49
|
-
}, [guide, placeholderChar, showMask, pipe, mask, value, initTextMask]);
|
|
50
|
-
return render(mergeRefs(inputRef, ref), _extends({
|
|
51
|
-
onChange: handleChange,
|
|
52
|
-
defaultValue: value
|
|
53
|
-
}, omit(rest, ['keepCharPositions'])));
|
|
6
|
+
var _props$as = props.as,
|
|
7
|
+
inputAs = _props$as === void 0 ? TextMask : _props$as;
|
|
8
|
+
return /*#__PURE__*/React.createElement(Input, _extends({}, props, {
|
|
9
|
+
as: inputAs,
|
|
10
|
+
ref: ref
|
|
11
|
+
}));
|
|
54
12
|
});
|
|
55
|
-
MaskedInput.displayName = 'MaskedInput';
|
|
56
|
-
MaskedInput.propTypes = {
|
|
57
|
-
render: PropTypes.func,
|
|
58
|
-
onChange: PropTypes.func,
|
|
59
|
-
mask: PropTypes.oneOfType([PropTypes.array, PropTypes.func, PropTypes.bool]).isRequired,
|
|
60
|
-
guide: PropTypes.bool,
|
|
61
|
-
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
62
|
-
pipe: PropTypes.func,
|
|
63
|
-
placeholderChar: PropTypes.string,
|
|
64
|
-
keepCharPositions: PropTypes.bool,
|
|
65
|
-
showMask: PropTypes.bool
|
|
66
|
-
};
|
|
67
13
|
export default MaskedInput;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { MaskType, MaskFunctionType, ConfigType } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* https://github.com/text-mask/text-mask/blob/master/componentDocumentation.md#guide
|
|
5
|
+
*/
|
|
6
|
+
interface TextMaskBaseProps {
|
|
7
|
+
/**
|
|
8
|
+
* `guide` is a boolean that tells the component whether to be in guide or no guide mode.
|
|
9
|
+
*/
|
|
10
|
+
guide?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* `mask` is an array or a function that defines how the user input is going to be masked.
|
|
13
|
+
*/
|
|
14
|
+
mask?: MaskType | MaskFunctionType | boolean;
|
|
15
|
+
/**
|
|
16
|
+
* `showMask` is a boolean that tells the Text Mask component to display the mask as a placeholder
|
|
17
|
+
* in place of the regular placeholder when the input element value is empty.
|
|
18
|
+
*/
|
|
19
|
+
showMask?: boolean;
|
|
20
|
+
/** The placeholder character represents the fillable spot in the mask. The default placeholder character is underscore, _. */
|
|
21
|
+
placeholderChar?: string;
|
|
22
|
+
/** `keepCharPositions` changes the general behavior of the Text Mask component. */
|
|
23
|
+
keepCharPositions?: boolean;
|
|
24
|
+
/** You can provide a `pipe` function that will give you the opportunity to modify the conformed value before it is displayed on the screen. */
|
|
25
|
+
pipe?: (conformedValue: string, config: ConfigType) => string;
|
|
26
|
+
}
|
|
27
|
+
export declare type TextMaskProps = TextMaskBaseProps & React.HTMLAttributes<HTMLInputElement> & {
|
|
28
|
+
/** Custom rendering DOM */
|
|
29
|
+
render?: (ref: React.Ref<HTMLInputElement>, props: React.HTMLAttributes<HTMLInputElement>) => any;
|
|
30
|
+
onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
31
|
+
value?: string | number;
|
|
32
|
+
readOnly?: boolean;
|
|
33
|
+
disabled?: boolean;
|
|
34
|
+
};
|
|
35
|
+
declare const TextMask: React.ForwardRefExoticComponent<TextMaskBaseProps & React.HTMLAttributes<HTMLInputElement> & {
|
|
36
|
+
/** Custom rendering DOM */
|
|
37
|
+
render?: (ref: React.Ref<HTMLInputElement>, props: React.HTMLAttributes<HTMLInputElement>) => any;
|
|
38
|
+
onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
39
|
+
value?: string | number;
|
|
40
|
+
readOnly?: boolean;
|
|
41
|
+
disabled?: boolean;
|
|
42
|
+
} & React.RefAttributes<HTMLInputElement>>;
|
|
43
|
+
export default TextMask;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
2
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
+
import React, { useCallback, useEffect, useRef } from 'react';
|
|
4
|
+
import omit from 'lodash/omit';
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
6
|
+
import createTextMaskInputElement from './createTextMaskInputElement';
|
|
7
|
+
import { mergeRefs } from '../utils';
|
|
8
|
+
/**
|
|
9
|
+
* https://github.com/text-mask/text-mask/blob/master/componentDocumentation.md#guide
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
var defaultRender = function defaultRender(ref, props) {
|
|
13
|
+
return /*#__PURE__*/React.createElement("input", _extends({
|
|
14
|
+
ref: ref
|
|
15
|
+
}, props));
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
var TextMask = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
19
|
+
var mask = props.mask,
|
|
20
|
+
_props$guide = props.guide,
|
|
21
|
+
guide = _props$guide === void 0 ? true : _props$guide,
|
|
22
|
+
placeholderChar = props.placeholderChar,
|
|
23
|
+
value = props.value,
|
|
24
|
+
showMask = props.showMask,
|
|
25
|
+
pipe = props.pipe,
|
|
26
|
+
_props$render = props.render,
|
|
27
|
+
render = _props$render === void 0 ? defaultRender : _props$render,
|
|
28
|
+
onChange = props.onChange,
|
|
29
|
+
rest = _objectWithoutPropertiesLoose(props, ["mask", "guide", "placeholderChar", "value", "showMask", "pipe", "render", "onChange"]);
|
|
30
|
+
|
|
31
|
+
var inputRef = useRef(null);
|
|
32
|
+
var textMaskInputElement = useRef();
|
|
33
|
+
var initTextMask = useCallback(function () {
|
|
34
|
+
var _textMaskInputElement;
|
|
35
|
+
|
|
36
|
+
textMaskInputElement.current = createTextMaskInputElement(_extends({
|
|
37
|
+
inputElement: inputRef.current
|
|
38
|
+
}, props));
|
|
39
|
+
(_textMaskInputElement = textMaskInputElement.current) === null || _textMaskInputElement === void 0 ? void 0 : _textMaskInputElement.update(value);
|
|
40
|
+
}, [props, value]);
|
|
41
|
+
var handleChange = useCallback(function (event) {
|
|
42
|
+
var _textMaskInputElement2;
|
|
43
|
+
|
|
44
|
+
(_textMaskInputElement2 = textMaskInputElement.current) === null || _textMaskInputElement2 === void 0 ? void 0 : _textMaskInputElement2.update();
|
|
45
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(event);
|
|
46
|
+
}, [onChange]);
|
|
47
|
+
useEffect(function () {
|
|
48
|
+
initTextMask();
|
|
49
|
+
}, [guide, placeholderChar, showMask, pipe, mask, value, initTextMask]);
|
|
50
|
+
return render(mergeRefs(inputRef, ref), _extends({
|
|
51
|
+
onChange: handleChange,
|
|
52
|
+
defaultValue: value
|
|
53
|
+
}, omit(rest, ['keepCharPositions'])));
|
|
54
|
+
});
|
|
55
|
+
TextMask.displayName = 'TextMask';
|
|
56
|
+
TextMask.propTypes = {
|
|
57
|
+
render: PropTypes.func,
|
|
58
|
+
onChange: PropTypes.func,
|
|
59
|
+
mask: PropTypes.oneOfType([PropTypes.array, PropTypes.func, PropTypes.bool]).isRequired,
|
|
60
|
+
guide: PropTypes.bool,
|
|
61
|
+
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
62
|
+
pipe: PropTypes.func,
|
|
63
|
+
placeholderChar: PropTypes.string,
|
|
64
|
+
keepCharPositions: PropTypes.bool,
|
|
65
|
+
showMask: PropTypes.bool
|
|
66
|
+
};
|
|
67
|
+
export default TextMask;
|
package/esm/Menu/Menu.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
-
import React, { useCallback, useContext, useRef } from 'react';
|
|
2
|
+
import React, { useCallback, useContext, useRef, useMemo } from 'react';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import MenuContext, { MenuActionTypes, MoveFocusTo } from './MenuContext';
|
|
5
5
|
import { KEY_VALUES, useCustom } from '../utils';
|
|
@@ -40,7 +40,10 @@ function Menu(props) {
|
|
|
40
40
|
rtl = _useCustom.rtl;
|
|
41
41
|
|
|
42
42
|
var activeItem = (_items$activeItemInde = items[activeItemIndex]) === null || _items$activeItemInde === void 0 ? void 0 : _items$activeItemInde.element;
|
|
43
|
-
|
|
43
|
+
|
|
44
|
+
var _useFocus = useFocus(menuElementRef),
|
|
45
|
+
grabFocus = _useFocus.grab;
|
|
46
|
+
|
|
44
47
|
var openMenu = useCallback(function (event) {
|
|
45
48
|
dispatch({
|
|
46
49
|
type: MenuActionTypes.OpenMenu
|
|
@@ -54,8 +57,8 @@ function Menu(props) {
|
|
|
54
57
|
}
|
|
55
58
|
|
|
56
59
|
onToggleMenu === null || onToggleMenu === void 0 ? void 0 : onToggleMenu(true, event);
|
|
57
|
-
|
|
58
|
-
}, [dispatch, onToggleMenu,
|
|
60
|
+
grabFocus();
|
|
61
|
+
}, [dispatch, onToggleMenu, grabFocus]);
|
|
59
62
|
var closeMenu = useCallback(function (event, returnFocusToButton) {
|
|
60
63
|
if (returnFocusToButton === void 0) {
|
|
61
64
|
returnFocusToButton = true;
|
|
@@ -150,41 +153,48 @@ function Menu(props) {
|
|
|
150
153
|
if (disabled) return;
|
|
151
154
|
openMenu(event);
|
|
152
155
|
}, [open, disabled, openMenu]);
|
|
153
|
-
var buttonEventHandlers = {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
156
|
+
var buttonEventHandlers = useMemo(function () {
|
|
157
|
+
var buttonEventHandlers = {
|
|
158
|
+
onKeyDown: handleButtonKeydown
|
|
159
|
+
};
|
|
160
|
+
/**
|
|
161
|
+
* Bind event of trigger,
|
|
162
|
+
* not used in in the expanded state of '<Sidenav>'
|
|
163
|
+
*/
|
|
164
|
+
|
|
165
|
+
if (openMenuOn !== null && openMenuOn !== void 0 && openMenuOn.includes('click')) {
|
|
166
|
+
buttonEventHandlers.onClick = handleButtonClick;
|
|
167
|
+
}
|
|
164
168
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
169
|
+
if (openMenuOn !== null && openMenuOn !== void 0 && openMenuOn.includes('contextmenu')) {
|
|
170
|
+
buttonEventHandlers.onContextMenu = handleButtonContextMenu;
|
|
171
|
+
}
|
|
168
172
|
|
|
173
|
+
return buttonEventHandlers;
|
|
174
|
+
}, [openMenuOn, handleButtonKeydown, handleButtonClick, handleButtonContextMenu]);
|
|
169
175
|
var buttonId = useUniqueId('menubutton-');
|
|
170
|
-
var menuId = useUniqueId('menu-');
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
176
|
+
var menuId = useUniqueId('menu-');
|
|
177
|
+
var buttonAriaAttributes = useMemo(function () {
|
|
178
|
+
// Ref: https://www.w3.org/TR/wai-aria-practices-1.2/#wai-aria-roles-states-and-properties-14
|
|
179
|
+
return {
|
|
180
|
+
role: 'button',
|
|
181
|
+
'aria-haspopup': 'menu',
|
|
182
|
+
'aria-expanded': open || undefined,
|
|
183
|
+
// it's recommend to remove aria-expanded when menu is hidden
|
|
184
|
+
'aria-controls': menuId
|
|
185
|
+
};
|
|
186
|
+
}, [open, menuId]);
|
|
187
|
+
var buttonProps = useMemo(function () {
|
|
188
|
+
return _extends({
|
|
189
|
+
id: buttonId
|
|
190
|
+
}, buttonAriaAttributes, buttonEventHandlers, {
|
|
191
|
+
// render props
|
|
192
|
+
open: open
|
|
193
|
+
});
|
|
194
|
+
}, [buttonId, buttonAriaAttributes, buttonEventHandlers, open]);
|
|
195
|
+
var customMenuButton = useMemo(function () {
|
|
196
|
+
return renderMenuButton === null || renderMenuButton === void 0 ? void 0 : renderMenuButton(buttonProps, buttonElementRef);
|
|
197
|
+
}, [renderMenuButton, buttonProps, buttonElementRef]);
|
|
188
198
|
var buttonElement = customMenuButton !== null && customMenuButton !== void 0 ? customMenuButton : /*#__PURE__*/React.createElement("button", _extends({
|
|
189
199
|
ref: buttonElementRef
|
|
190
200
|
}, buttonProps), menuButtonText);
|
package/esm/Menu/MenuItem.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export interface MenuItemProps {
|
|
|
8
8
|
/** Render prop */
|
|
9
9
|
children: (menuitem: React.LiHTMLAttributes<HTMLLIElement> & MenuitemRenderProps, ref: React.Ref<HTMLLIElement>) => React.ReactElement;
|
|
10
10
|
/** Callback when menuitem is being activated */
|
|
11
|
-
onActivate?: (event: React.SyntheticEvent
|
|
11
|
+
onActivate?: (event: React.SyntheticEvent) => void;
|
|
12
12
|
}
|
|
13
13
|
export interface MenuitemRenderProps {
|
|
14
14
|
selected: boolean;
|
package/esm/Menu/MenuItem.js
CHANGED
|
@@ -32,20 +32,24 @@ function MenuItem(props) {
|
|
|
32
32
|
}, [disabled, onActivate]); // Gain/release focus on mousedown in `menubar`
|
|
33
33
|
|
|
34
34
|
var handleMouseDown = useCallback(function () {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
35
|
+
if (!hasFocus) {
|
|
36
|
+
dispatch({
|
|
37
|
+
type: MenuActionTypes.MoveFocus,
|
|
38
|
+
to: MoveFocusTo.Specific,
|
|
39
|
+
id: menuitemRef.current.id
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}, [hasFocus, dispatch]); // Gain/release focus on mouseenter/mouseleave in `menu`
|
|
41
43
|
|
|
42
44
|
var handleMouseMove = useCallback(function () {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
if (!hasFocus) {
|
|
46
|
+
dispatch({
|
|
47
|
+
type: MenuActionTypes.MoveFocus,
|
|
48
|
+
to: MoveFocusTo.Specific,
|
|
49
|
+
id: menuitemRef.current.id
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}, [hasFocus, dispatch]);
|
|
49
53
|
var handleMouseLeave = useCallback(function () {
|
|
50
54
|
dispatch({
|
|
51
55
|
type: MenuActionTypes.MoveFocus,
|
package/esm/Menu/Menubar.d.ts
CHANGED
|
@@ -5,6 +5,6 @@ export interface MenubarProps {
|
|
|
5
5
|
/** Render prop */
|
|
6
6
|
children: (menubar: React.HTMLAttributes<HTMLUListElement>, ref: React.Ref<HTMLUListElement>) => React.ReactElement;
|
|
7
7
|
/** Callback triggered when an item is being activated */
|
|
8
|
-
onActivateItem?: (event: React.SyntheticEvent
|
|
8
|
+
onActivateItem?: (event: React.SyntheticEvent) => void;
|
|
9
9
|
}
|
|
10
10
|
export default function Menubar({ vertical, children, onActivateItem }: MenubarProps): JSX.Element;
|
package/esm/Message/Message.js
CHANGED
|
@@ -4,9 +4,9 @@ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWith
|
|
|
4
4
|
|
|
5
5
|
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5;
|
|
6
6
|
|
|
7
|
-
import React, { useState } from 'react';
|
|
7
|
+
import React, { useState, useCallback } from 'react';
|
|
8
8
|
import PropTypes from 'prop-types';
|
|
9
|
-
import { useClassNames, useTimeout, MESSAGE_STATUS_ICONS, STATUS } from '../utils';
|
|
9
|
+
import { useClassNames, useTimeout, MESSAGE_STATUS_ICONS, STATUS, useIsMounted } from '../utils';
|
|
10
10
|
import CloseButton from '../CloseButton';
|
|
11
11
|
var Message = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
12
12
|
var _withClassPrefix;
|
|
@@ -35,12 +35,24 @@ var Message = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
35
35
|
var _useClassNames = useClassNames(classPrefix),
|
|
36
36
|
withClassPrefix = _useClassNames.withClassPrefix,
|
|
37
37
|
merge = _useClassNames.merge,
|
|
38
|
-
prefix = _useClassNames.prefix;
|
|
38
|
+
prefix = _useClassNames.prefix;
|
|
39
39
|
|
|
40
|
+
var isMounted = useIsMounted(); // Timed close message
|
|
40
41
|
|
|
41
42
|
var _useTimeout = useTimeout(onClose, duration, duration > 0),
|
|
42
43
|
clear = _useTimeout.clear;
|
|
43
44
|
|
|
45
|
+
var handleClose = useCallback(function (event) {
|
|
46
|
+
setDisplay('hiding');
|
|
47
|
+
onClose === null || onClose === void 0 ? void 0 : onClose(event);
|
|
48
|
+
clear();
|
|
49
|
+
setTimeout(function () {
|
|
50
|
+
if (isMounted()) {
|
|
51
|
+
setDisplay('hide');
|
|
52
|
+
}
|
|
53
|
+
}, 1000);
|
|
54
|
+
}, [clear, isMounted, onClose]);
|
|
55
|
+
|
|
44
56
|
if (display === 'hide') {
|
|
45
57
|
return null;
|
|
46
58
|
}
|
|
@@ -48,16 +60,6 @@ var Message = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
48
60
|
var classes = merge(className, withClassPrefix(type, display, (_withClassPrefix = {
|
|
49
61
|
full: full
|
|
50
62
|
}, _withClassPrefix['has-title'] = header, _withClassPrefix['has-icon'] = showIcon, _withClassPrefix)));
|
|
51
|
-
|
|
52
|
-
var handleClose = function handleClose(event) {
|
|
53
|
-
setDisplay('hiding');
|
|
54
|
-
onClose === null || onClose === void 0 ? void 0 : onClose(event);
|
|
55
|
-
clear();
|
|
56
|
-
setTimeout(function () {
|
|
57
|
-
setDisplay('hide');
|
|
58
|
-
}, 1000);
|
|
59
|
-
};
|
|
60
|
-
|
|
61
63
|
return /*#__PURE__*/React.createElement(Component, _extends({
|
|
62
64
|
role: "alert"
|
|
63
65
|
}, rest, {
|
package/esm/Modal/Modal.js
CHANGED
|
@@ -7,6 +7,8 @@ var _templateObject, _templateObject2;
|
|
|
7
7
|
import React, { useRef, useMemo, useState, useEffect, useCallback } from 'react';
|
|
8
8
|
import PropTypes from 'prop-types';
|
|
9
9
|
import pick from 'lodash/pick';
|
|
10
|
+
import on from 'dom-lib/on';
|
|
11
|
+
import getTransitionEnd from 'dom-lib/getTransitionEnd';
|
|
10
12
|
import BaseModal, { modalPropTypes } from '../Overlay/Modal';
|
|
11
13
|
import Bounce from '../Animation/Bounce';
|
|
12
14
|
import { useClassNames, mergeRefs, SIZE } from '../utils';
|
|
@@ -16,7 +18,6 @@ import ModalBody from './ModalBody';
|
|
|
16
18
|
import ModalHeader from './ModalHeader';
|
|
17
19
|
import ModalTitle from './ModalTitle';
|
|
18
20
|
import ModalFooter from './ModalFooter';
|
|
19
|
-
import helper from '../DOMHelper';
|
|
20
21
|
import { useBodyStyles } from './utils';
|
|
21
22
|
import useUniqueId from '../utils/useUniqueId';
|
|
22
23
|
var Modal = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
@@ -97,7 +98,7 @@ var Modal = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
97
98
|
// When the value of `backdrop` is `static`, a jitter animation will be added to the dialog when clicked.
|
|
98
99
|
if (backdrop === 'static') {
|
|
99
100
|
setShake(true);
|
|
100
|
-
transitionEndListener.current =
|
|
101
|
+
transitionEndListener.current = on(dialogRef.current, getTransitionEnd(), function () {
|
|
101
102
|
setShake(false);
|
|
102
103
|
});
|
|
103
104
|
}
|
package/esm/Modal/utils.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useState, useRef, useCallback, useEffect } from 'react';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
2
|
+
import getHeight from 'dom-lib/getHeight';
|
|
3
|
+
import on from 'dom-lib/on';
|
|
4
|
+
import { ResizeObserver } from '@juggle/resize-observer';
|
|
4
5
|
export var useBodyStyles = function useBodyStyles(ref, options) {
|
|
5
6
|
var _useState = useState({}),
|
|
6
7
|
bodyStyles = _useState[0],
|
|
@@ -11,6 +12,7 @@ export var useBodyStyles = function useBodyStyles(ref, options) {
|
|
|
11
12
|
prefix = options.prefix;
|
|
12
13
|
var windowResizeListener = useRef();
|
|
13
14
|
var contentElement = useRef();
|
|
15
|
+
var contentElementResizeObserver = useRef();
|
|
14
16
|
var updateBodyStyles = useCallback(function (_event, entering) {
|
|
15
17
|
var dialog = ref.current;
|
|
16
18
|
var scrollHeight = dialog ? dialog.scrollHeight : 0;
|
|
@@ -24,14 +26,14 @@ export var useBodyStyles = function useBodyStyles(ref, options) {
|
|
|
24
26
|
var footerHeight = 46;
|
|
25
27
|
var headerDOM = dialog.querySelector("." + prefix('header'));
|
|
26
28
|
var footerDOM = dialog.querySelector("." + prefix('footer'));
|
|
27
|
-
headerHeight = headerDOM ?
|
|
28
|
-
footerHeight = footerDOM ?
|
|
29
|
+
headerHeight = headerDOM ? getHeight(headerDOM) + headerHeight : headerHeight;
|
|
30
|
+
footerHeight = footerDOM ? getHeight(footerDOM) + footerHeight : footerHeight;
|
|
29
31
|
/**
|
|
30
32
|
* Header height + Footer height + Dialog margin
|
|
31
33
|
*/
|
|
32
34
|
|
|
33
35
|
var excludeHeight = headerHeight + footerHeight + (entering ? 70 : 60);
|
|
34
|
-
var bodyHeight =
|
|
36
|
+
var bodyHeight = getHeight(window) - excludeHeight;
|
|
35
37
|
var maxHeight = scrollHeight >= bodyHeight ? bodyHeight : scrollHeight;
|
|
36
38
|
styles.maxHeight = maxHeight;
|
|
37
39
|
}
|
|
@@ -39,13 +41,10 @@ export var useBodyStyles = function useBodyStyles(ref, options) {
|
|
|
39
41
|
setBodyStyles(styles);
|
|
40
42
|
}, [prefix, ref]);
|
|
41
43
|
var onDestroyEvents = useCallback(function () {
|
|
42
|
-
var _windowResizeListener, _windowResizeListener2;
|
|
44
|
+
var _windowResizeListener, _windowResizeListener2, _contentElementResize;
|
|
43
45
|
|
|
44
46
|
(_windowResizeListener = windowResizeListener.current) === null || _windowResizeListener === void 0 ? void 0 : (_windowResizeListener2 = _windowResizeListener.off) === null || _windowResizeListener2 === void 0 ? void 0 : _windowResizeListener2.call(_windowResizeListener);
|
|
45
|
-
|
|
46
|
-
if (contentElement.current) {
|
|
47
|
-
unbindElementResize(contentElement.current);
|
|
48
|
-
}
|
|
47
|
+
(_contentElementResize = contentElementResizeObserver.current) === null || _contentElementResize === void 0 ? void 0 : _contentElementResize.disconnect();
|
|
49
48
|
}, []);
|
|
50
49
|
var onChangeBodyStyles = useCallback(function (entering) {
|
|
51
50
|
if (overflow && !drawer) {
|
|
@@ -53,8 +52,11 @@ export var useBodyStyles = function useBodyStyles(ref, options) {
|
|
|
53
52
|
|
|
54
53
|
updateBodyStyles(null, entering);
|
|
55
54
|
contentElement.current = (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.querySelector("." + prefix('content'));
|
|
56
|
-
windowResizeListener.current =
|
|
57
|
-
|
|
55
|
+
windowResizeListener.current = on(window, 'resize', updateBodyStyles);
|
|
56
|
+
contentElementResizeObserver.current = new ResizeObserver(function () {
|
|
57
|
+
return updateBodyStyles();
|
|
58
|
+
});
|
|
59
|
+
contentElementResizeObserver.current.observe(contentElement.current);
|
|
58
60
|
}
|
|
59
61
|
}, [drawer, overflow, prefix, ref, updateBodyStyles]);
|
|
60
62
|
useEffect(function () {
|
|
@@ -6,7 +6,7 @@ var _templateObject, _templateObject2;
|
|
|
6
6
|
|
|
7
7
|
import React, { useCallback, useState } from 'react';
|
|
8
8
|
import PropTypes from 'prop-types';
|
|
9
|
-
import { useClassNames, useTimeout, MESSAGE_STATUS_ICONS } from '../utils';
|
|
9
|
+
import { useClassNames, useTimeout, MESSAGE_STATUS_ICONS, useIsMounted } from '../utils';
|
|
10
10
|
import CloseButton from '../CloseButton';
|
|
11
11
|
var Notification = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
12
12
|
var _props$as = props.as,
|
|
@@ -30,8 +30,9 @@ var Notification = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
30
30
|
var _useClassNames = useClassNames(classPrefix),
|
|
31
31
|
withClassPrefix = _useClassNames.withClassPrefix,
|
|
32
32
|
merge = _useClassNames.merge,
|
|
33
|
-
prefix = _useClassNames.prefix;
|
|
33
|
+
prefix = _useClassNames.prefix;
|
|
34
34
|
|
|
35
|
+
var isMounted = useIsMounted(); // Timed close message
|
|
35
36
|
|
|
36
37
|
var _useTimeout = useTimeout(onClose, duration, duration > 0),
|
|
37
38
|
clear = _useTimeout.clear; // Click to trigger to close the message
|
|
@@ -42,9 +43,11 @@ var Notification = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
42
43
|
onClose === null || onClose === void 0 ? void 0 : onClose(event);
|
|
43
44
|
clear();
|
|
44
45
|
setTimeout(function () {
|
|
45
|
-
|
|
46
|
+
if (isMounted()) {
|
|
47
|
+
setDisplay('hide');
|
|
48
|
+
}
|
|
46
49
|
}, 1000);
|
|
47
|
-
}, [onClose, clear]);
|
|
50
|
+
}, [onClose, clear, isMounted]);
|
|
48
51
|
var renderHeader = useCallback(function () {
|
|
49
52
|
if (!header) {
|
|
50
53
|
return null;
|