rsuite 5.2.1 → 5.2.2
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 +6 -0
- package/CHANGELOG.md +12 -0
- package/PanelGroup/styles/index.less +12 -12
- package/cjs/Dropdown/DropdownItem.js +2 -1
- 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/Modal/utils.js +9 -10
- package/cjs/Overlay/Position.js +7 -4
- package/cjs/Picker/PickerToggle.js +2 -2
- package/cjs/utils/useElementResize.d.ts +1 -1
- package/cjs/utils/useElementResize.js +7 -5
- package/dist/rsuite-rtl.css +45 -3
- package/dist/rsuite-rtl.min.css +1 -1
- package/dist/rsuite-rtl.min.css.map +1 -1
- package/dist/rsuite.css +45 -3
- package/dist/rsuite.js +311 -354
- 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/Dropdown/DropdownItem.js +2 -1
- 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/Modal/utils.js +8 -7
- package/esm/Overlay/Position.js +6 -3
- package/esm/Picker/PickerToggle.js +2 -2
- package/esm/utils/useElementResize.d.ts +1 -1
- package/esm/utils/useElementResize.js +8 -4
- package/package.json +3 -3
|
@@ -108,7 +108,8 @@ var DropdownItem = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
108
108
|
if (panel) {
|
|
109
109
|
return renderDropdownItem(_extends({
|
|
110
110
|
ref: ref,
|
|
111
|
-
className: merge(prefix('panel'), className)
|
|
111
|
+
className: merge(prefix('panel'), className),
|
|
112
|
+
children: children
|
|
112
113
|
}, restProps));
|
|
113
114
|
}
|
|
114
115
|
|
|
@@ -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/Modal/utils.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useState, useRef, useCallback, useEffect } from 'react';
|
|
2
|
-
import bindElementResize, { unbind as unbindElementResize } from 'element-resize-event';
|
|
3
2
|
import getHeight from 'dom-lib/getHeight';
|
|
4
3
|
import on from 'dom-lib/on';
|
|
4
|
+
import { ResizeObserver } from '@juggle/resize-observer';
|
|
5
5
|
export var useBodyStyles = function useBodyStyles(ref, options) {
|
|
6
6
|
var _useState = useState({}),
|
|
7
7
|
bodyStyles = _useState[0],
|
|
@@ -12,6 +12,7 @@ export var useBodyStyles = function useBodyStyles(ref, options) {
|
|
|
12
12
|
prefix = options.prefix;
|
|
13
13
|
var windowResizeListener = useRef();
|
|
14
14
|
var contentElement = useRef();
|
|
15
|
+
var contentElementResizeObserver = useRef();
|
|
15
16
|
var updateBodyStyles = useCallback(function (_event, entering) {
|
|
16
17
|
var dialog = ref.current;
|
|
17
18
|
var scrollHeight = dialog ? dialog.scrollHeight : 0;
|
|
@@ -40,13 +41,10 @@ export var useBodyStyles = function useBodyStyles(ref, options) {
|
|
|
40
41
|
setBodyStyles(styles);
|
|
41
42
|
}, [prefix, ref]);
|
|
42
43
|
var onDestroyEvents = useCallback(function () {
|
|
43
|
-
var _windowResizeListener, _windowResizeListener2;
|
|
44
|
+
var _windowResizeListener, _windowResizeListener2, _contentElementResize;
|
|
44
45
|
|
|
45
46
|
(_windowResizeListener = windowResizeListener.current) === null || _windowResizeListener === void 0 ? void 0 : (_windowResizeListener2 = _windowResizeListener.off) === null || _windowResizeListener2 === void 0 ? void 0 : _windowResizeListener2.call(_windowResizeListener);
|
|
46
|
-
|
|
47
|
-
if (contentElement.current) {
|
|
48
|
-
unbindElementResize(contentElement.current);
|
|
49
|
-
}
|
|
47
|
+
(_contentElementResize = contentElementResizeObserver.current) === null || _contentElementResize === void 0 ? void 0 : _contentElementResize.disconnect();
|
|
50
48
|
}, []);
|
|
51
49
|
var onChangeBodyStyles = useCallback(function (entering) {
|
|
52
50
|
if (overflow && !drawer) {
|
|
@@ -55,7 +53,10 @@ export var useBodyStyles = function useBodyStyles(ref, options) {
|
|
|
55
53
|
updateBodyStyles(null, entering);
|
|
56
54
|
contentElement.current = (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.querySelector("." + prefix('content'));
|
|
57
55
|
windowResizeListener.current = on(window, 'resize', updateBodyStyles);
|
|
58
|
-
|
|
56
|
+
contentElementResizeObserver.current = new ResizeObserver(function () {
|
|
57
|
+
return updateBodyStyles();
|
|
58
|
+
});
|
|
59
|
+
contentElementResizeObserver.current.observe(contentElement.current);
|
|
59
60
|
}
|
|
60
61
|
}, [drawer, overflow, prefix, ref, updateBodyStyles]);
|
|
61
62
|
useEffect(function () {
|
package/esm/Overlay/Position.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import React, { useState, useEffect, useRef, useMemo, useCallback, useImperativeHandle } from 'react';
|
|
2
|
-
import bindElementResize from 'element-resize-event';
|
|
3
2
|
import PropTypes from 'prop-types';
|
|
4
3
|
import classNames from 'classnames';
|
|
5
4
|
import getContainer from 'dom-lib/getContainer';
|
|
@@ -8,6 +7,7 @@ import removeClass from 'dom-lib/removeClass';
|
|
|
8
7
|
import on from 'dom-lib/on';
|
|
9
8
|
import addClass from 'dom-lib/addClass';
|
|
10
9
|
import addStyle from 'dom-lib/addStyle';
|
|
10
|
+
import { ResizeObserver } from '@juggle/resize-observer';
|
|
11
11
|
import isElement from '../DOMHelper/isElement';
|
|
12
12
|
import positionUtils from './positionUtils';
|
|
13
13
|
import { getDOMNode } from '../utils';
|
|
@@ -23,6 +23,7 @@ var usePosition = function usePosition(props, ref) {
|
|
|
23
23
|
triggerTarget = props.triggerTarget;
|
|
24
24
|
var containerRef = useRef();
|
|
25
25
|
var lastTargetRef = useRef();
|
|
26
|
+
var overlayResizeObserver = useRef();
|
|
26
27
|
var defaultPosition = {
|
|
27
28
|
positionLeft: 0,
|
|
28
29
|
positionTop: 0,
|
|
@@ -109,17 +110,19 @@ var usePosition = function usePosition(props, ref) {
|
|
|
109
110
|
|
|
110
111
|
if (overlay) {
|
|
111
112
|
// Update the position when the size of the overlay changes
|
|
112
|
-
|
|
113
|
+
overlayResizeObserver.current = new ResizeObserver(function () {
|
|
113
114
|
return updatePosition(true, true);
|
|
114
115
|
});
|
|
116
|
+
overlayResizeObserver.current.observe(overlay);
|
|
115
117
|
}
|
|
116
118
|
|
|
117
119
|
return function () {
|
|
118
|
-
var _containerScrollListe;
|
|
120
|
+
var _containerScrollListe, _overlayResizeObserve;
|
|
119
121
|
|
|
120
122
|
lastTargetRef.current = null;
|
|
121
123
|
(_containerScrollListe = containerScrollListener) === null || _containerScrollListe === void 0 ? void 0 : _containerScrollListe.off();
|
|
122
124
|
resizeListener === null || resizeListener === void 0 ? void 0 : resizeListener.off();
|
|
125
|
+
(_overlayResizeObserve = overlayResizeObserver.current) === null || _overlayResizeObserve === void 0 ? void 0 : _overlayResizeObserve.disconnect();
|
|
123
126
|
};
|
|
124
127
|
}, [preventOverflow, ref, updatePosition]);
|
|
125
128
|
useUpdateEffect(function () {
|
|
@@ -12,7 +12,7 @@ import CloseButton from '../CloseButton';
|
|
|
12
12
|
import { useClassNames, KEY_VALUES, mergeRefs } from '../utils';
|
|
13
13
|
import Plaintext from '../Plaintext';
|
|
14
14
|
import useToggleCaret from '../utils/useToggleCaret';
|
|
15
|
-
import
|
|
15
|
+
import TextMask from '../MaskedInput/TextMask';
|
|
16
16
|
import deprecatePropType from '../utils/deprecatePropType';
|
|
17
17
|
var defaultInputMask = [];
|
|
18
18
|
var PickerToggle = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
@@ -146,7 +146,7 @@ var PickerToggle = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
146
146
|
onFocus: !disabled ? handleFocus : null // The debounce is set to 200 to solve the flicker caused by the switch between input and div.
|
|
147
147
|
,
|
|
148
148
|
onBlur: !disabled ? debounce(handleBlur, 200) : null
|
|
149
|
-
}), /*#__PURE__*/React.createElement(
|
|
149
|
+
}), /*#__PURE__*/React.createElement(TextMask, {
|
|
150
150
|
mask: inputMask,
|
|
151
151
|
value: Array.isArray(inputValue) ? inputValue.toString() : inputValue,
|
|
152
152
|
onBlur: handleInputBlur,
|
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
* @param eventTarget The target to listen for events on
|
|
6
6
|
* @param listener An event handler
|
|
7
7
|
*/
|
|
8
|
-
export default function useElementResize(eventTarget:
|
|
8
|
+
export default function useElementResize(eventTarget: Element | (() => Element), listener: ResizeObserverCallback): void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { useEffect } from 'react';
|
|
2
|
-
import
|
|
1
|
+
import { useEffect, useRef } from 'react';
|
|
2
|
+
import { ResizeObserver } from '@juggle/resize-observer';
|
|
3
3
|
/**
|
|
4
4
|
* Attach the event handler directly to the specified DOM element,
|
|
5
5
|
* and it will be triggered when the size of the DOM element is changed.
|
|
@@ -9,11 +9,15 @@ import bindElementResize, { unbind } from 'element-resize-event';
|
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
export default function useElementResize(eventTarget, listener) {
|
|
12
|
+
var resizeObserver = useRef();
|
|
12
13
|
useEffect(function () {
|
|
13
14
|
var target = typeof eventTarget === 'function' ? eventTarget() : eventTarget;
|
|
14
|
-
|
|
15
|
+
resizeObserver.current = new ResizeObserver(listener);
|
|
16
|
+
resizeObserver.current.observe(target);
|
|
15
17
|
return function () {
|
|
16
|
-
|
|
18
|
+
var _resizeObserver$curre;
|
|
19
|
+
|
|
20
|
+
(_resizeObserver$curre = resizeObserver.current) === null || _resizeObserver$curre === void 0 ? void 0 : _resizeObserver$curre.disconnect();
|
|
17
21
|
};
|
|
18
22
|
}, [eventTarget, listener]);
|
|
19
23
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rsuite",
|
|
3
|
-
"version": "5.2.
|
|
3
|
+
"version": "5.2.2",
|
|
4
4
|
"description": "A suite of react components",
|
|
5
5
|
"main": "cjs/index.js",
|
|
6
6
|
"module": "esm/index.js",
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@babel/runtime": "^7.8.4",
|
|
28
|
+
"@juggle/resize-observer": "^3.3.1",
|
|
28
29
|
"@rsuite/icons": "^1.0.2",
|
|
29
30
|
"@types/chai": "^4.2.18",
|
|
30
31
|
"@types/lodash": "^4.14.134",
|
|
@@ -33,11 +34,10 @@
|
|
|
33
34
|
"classnames": "^2.3.1",
|
|
34
35
|
"date-fns": "^2.13.0",
|
|
35
36
|
"dom-lib": "^3.0.0",
|
|
36
|
-
"element-resize-event": "^3.0.6",
|
|
37
37
|
"lodash": "^4.17.11",
|
|
38
38
|
"prop-types": "^15.7.2",
|
|
39
39
|
"react-virtualized": "^9.22.3",
|
|
40
|
-
"rsuite-table": "^5.0
|
|
40
|
+
"rsuite-table": "^5.2.0",
|
|
41
41
|
"schema-typed": "^2.0.2"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|