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.
Files changed (211) hide show
  1. package/Button/styles/index.less +7 -1
  2. package/CHANGELOG.md +45 -0
  3. package/PanelGroup/styles/index.less +12 -12
  4. package/README.md +3 -45
  5. package/Sidenav/styles/index.less +4 -0
  6. package/Slider/styles/index.less +20 -14
  7. package/Toggle/styles/index.less +48 -27
  8. package/Toggle/styles/mixin.less +16 -14
  9. package/cjs/@types/common.d.ts +8 -2
  10. package/cjs/Affix/Affix.js +3 -3
  11. package/cjs/Animation/Collapse.js +9 -7
  12. package/cjs/Animation/Transition.js +4 -2
  13. package/cjs/AutoComplete/AutoComplete.d.ts +2 -2
  14. package/cjs/AutoComplete/AutoComplete.js +7 -4
  15. package/cjs/Calendar/TimeDropdown.js +5 -3
  16. package/cjs/Cascader/Cascader.d.ts +1 -1
  17. package/cjs/Cascader/DropdownMenu.js +6 -5
  18. package/cjs/CheckTreePicker/CheckTreeNode.d.ts +1 -1
  19. package/cjs/CheckTreePicker/CheckTreePicker.d.ts +1 -1
  20. package/cjs/CheckTreePicker/utils.d.ts +1 -1
  21. package/cjs/CheckTreePicker/utils.js +7 -6
  22. package/cjs/Checkbox/Checkbox.d.ts +3 -3
  23. package/cjs/CheckboxGroup/CheckboxGroup.js +2 -2
  24. package/cjs/CheckboxGroup/CheckboxGroupContext.d.ts +1 -1
  25. package/cjs/DOMHelper/index.d.ts +12 -27
  26. package/cjs/DOMHelper/index.js +4 -3
  27. package/cjs/DOMHelper/isElement.d.ts +2 -0
  28. package/cjs/DOMHelper/isElement.js +11 -0
  29. package/cjs/DatePicker/DatePicker.d.ts +3 -3
  30. package/cjs/DateRangePicker/Calendar.d.ts +1 -1
  31. package/cjs/DateRangePicker/DateRangePicker.d.ts +2 -2
  32. package/cjs/Disclosure/Disclosure.d.ts +1 -1
  33. package/cjs/Disclosure/DisclosureContext.d.ts +1 -1
  34. package/cjs/Dropdown/DropdownItem.d.ts +1 -1
  35. package/cjs/Dropdown/DropdownItem.js +16 -19
  36. package/cjs/Dropdown/DropdownMenu.d.ts +2 -2
  37. package/cjs/Dropdown/useRenderDropdownItem.d.ts +2 -0
  38. package/cjs/Dropdown/useRenderDropdownItem.js +26 -0
  39. package/cjs/Form/Form.d.ts +1 -1
  40. package/cjs/FormControl/FormControl.d.ts +9 -3
  41. package/cjs/Input/Input.d.ts +2 -1
  42. package/cjs/InputNumber/InputNumber.js +2 -2
  43. package/cjs/InputPicker/InputPicker.js +3 -3
  44. package/cjs/List/helper/useSortHelper.js +11 -6
  45. package/cjs/MaskedInput/MaskedInput.d.ts +5 -42
  46. package/cjs/MaskedInput/MaskedInput.js +9 -63
  47. package/cjs/MaskedInput/TextMask.d.ts +43 -0
  48. package/cjs/MaskedInput/TextMask.js +80 -0
  49. package/cjs/Menu/Menu.js +46 -34
  50. package/cjs/Menu/MenuItem.d.ts +1 -1
  51. package/cjs/Menu/MenuItem.js +16 -12
  52. package/cjs/Menu/Menubar.d.ts +1 -1
  53. package/cjs/Message/Message.js +13 -11
  54. package/cjs/Modal/Modal.js +5 -3
  55. package/cjs/Modal/utils.js +15 -14
  56. package/cjs/Notification/Notification.js +6 -3
  57. package/cjs/Overlay/Modal.js +14 -11
  58. package/cjs/Overlay/ModalManager.js +19 -7
  59. package/cjs/Overlay/OverlayTrigger.js +2 -2
  60. package/cjs/Overlay/Position.js +27 -17
  61. package/cjs/Overlay/positionUtils.js +16 -8
  62. package/cjs/Panel/Panel.d.ts +1 -1
  63. package/cjs/Picker/DropdownMenu.js +10 -6
  64. package/cjs/Picker/DropdownMenuCheckItem.d.ts +3 -3
  65. package/cjs/Picker/PickerOverlay.js +5 -3
  66. package/cjs/Picker/PickerToggle.d.ts +6 -0
  67. package/cjs/Picker/PickerToggle.js +16 -8
  68. package/cjs/Picker/SearchBar.d.ts +1 -1
  69. package/cjs/Picker/utils.d.ts +2 -2
  70. package/cjs/Radio/Radio.d.ts +1 -1
  71. package/cjs/RadioGroup/RadioGroup.d.ts +1 -1
  72. package/cjs/RadioGroup/RadioGroup.js +2 -2
  73. package/cjs/RangeSlider/RangeSlider.js +9 -5
  74. package/cjs/Rate/Character.js +2 -2
  75. package/cjs/Rate/Rate.js +3 -1
  76. package/cjs/Ripple/Ripple.js +6 -7
  77. package/cjs/Sidenav/SidenavDropdownItem.d.ts +1 -1
  78. package/cjs/Sidenav/SidenavDropdownItem.js +17 -10
  79. package/cjs/Sidenav/SidenavDropdownMenu.d.ts +1 -1
  80. package/cjs/Slider/Graduated.js +1 -1
  81. package/cjs/Slider/Handle.js +10 -5
  82. package/cjs/Slider/ProgressBar.js +1 -1
  83. package/cjs/Slider/Slider.js +9 -5
  84. package/cjs/Toggle/Toggle.d.ts +3 -6
  85. package/cjs/Toggle/Toggle.js +32 -27
  86. package/cjs/Tree/Tree.d.ts +3 -3
  87. package/cjs/TreePicker/TreeNode.d.ts +1 -1
  88. package/cjs/TreePicker/TreeNode.js +2 -2
  89. package/cjs/TreePicker/TreePicker.d.ts +1 -1
  90. package/cjs/Uploader/Uploader.d.ts +4 -4
  91. package/cjs/locales/fa_IR.js +8 -8
  92. package/cjs/utils/BrowserDetection.js +1 -1
  93. package/cjs/utils/index.d.ts +1 -0
  94. package/cjs/utils/index.js +7 -2
  95. package/cjs/utils/scrollTopAnimation.js +5 -5
  96. package/cjs/utils/treeUtils.d.ts +2 -2
  97. package/cjs/utils/useElementResize.d.ts +1 -1
  98. package/cjs/utils/useElementResize.js +11 -6
  99. package/cjs/utils/useEventListener.js +4 -2
  100. package/cjs/utils/useIsMounted.d.ts +2 -0
  101. package/cjs/utils/useIsMounted.js +22 -0
  102. package/cjs/utils/usePortal.js +2 -2
  103. package/cjs/utils/useRootClose.js +10 -10
  104. package/dist/rsuite-rtl.css +194 -119
  105. package/dist/rsuite-rtl.min.css +1 -1
  106. package/dist/rsuite-rtl.min.css.map +1 -1
  107. package/dist/rsuite.css +194 -119
  108. package/dist/rsuite.js +703 -504
  109. package/dist/rsuite.js.map +1 -1
  110. package/dist/rsuite.min.css +1 -1
  111. package/dist/rsuite.min.css.map +1 -1
  112. package/dist/rsuite.min.js +1 -1
  113. package/dist/rsuite.min.js.LICENSE.txt +9 -0
  114. package/dist/rsuite.min.js.map +1 -1
  115. package/esm/@types/common.d.ts +8 -2
  116. package/esm/Affix/Affix.js +1 -1
  117. package/esm/Animation/Collapse.js +2 -1
  118. package/esm/Animation/Transition.js +3 -2
  119. package/esm/AutoComplete/AutoComplete.d.ts +2 -2
  120. package/esm/AutoComplete/AutoComplete.js +8 -5
  121. package/esm/Calendar/TimeDropdown.js +2 -1
  122. package/esm/Cascader/Cascader.d.ts +1 -1
  123. package/esm/Cascader/DropdownMenu.js +4 -3
  124. package/esm/CheckTreePicker/CheckTreeNode.d.ts +1 -1
  125. package/esm/CheckTreePicker/CheckTreePicker.d.ts +1 -1
  126. package/esm/CheckTreePicker/utils.d.ts +1 -1
  127. package/esm/CheckTreePicker/utils.js +7 -6
  128. package/esm/Checkbox/Checkbox.d.ts +3 -3
  129. package/esm/CheckboxGroup/CheckboxGroup.js +2 -2
  130. package/esm/CheckboxGroup/CheckboxGroupContext.d.ts +1 -1
  131. package/esm/DOMHelper/index.d.ts +12 -27
  132. package/esm/DOMHelper/index.js +2 -3
  133. package/esm/DOMHelper/isElement.d.ts +2 -0
  134. package/esm/DOMHelper/isElement.js +5 -0
  135. package/esm/DatePicker/DatePicker.d.ts +3 -3
  136. package/esm/DateRangePicker/Calendar.d.ts +1 -1
  137. package/esm/DateRangePicker/DateRangePicker.d.ts +2 -2
  138. package/esm/Disclosure/Disclosure.d.ts +1 -1
  139. package/esm/Disclosure/DisclosureContext.d.ts +1 -1
  140. package/esm/Dropdown/DropdownItem.d.ts +1 -1
  141. package/esm/Dropdown/DropdownItem.js +15 -19
  142. package/esm/Dropdown/DropdownMenu.d.ts +2 -2
  143. package/esm/Dropdown/useRenderDropdownItem.d.ts +2 -0
  144. package/esm/Dropdown/useRenderDropdownItem.js +18 -0
  145. package/esm/Form/Form.d.ts +1 -1
  146. package/esm/FormControl/FormControl.d.ts +9 -3
  147. package/esm/Input/Input.d.ts +2 -1
  148. package/esm/InputNumber/InputNumber.js +2 -2
  149. package/esm/InputPicker/InputPicker.js +2 -2
  150. package/esm/List/helper/useSortHelper.js +8 -4
  151. package/esm/MaskedInput/MaskedInput.d.ts +5 -42
  152. package/esm/MaskedInput/MaskedInput.js +9 -63
  153. package/esm/MaskedInput/TextMask.d.ts +43 -0
  154. package/esm/MaskedInput/TextMask.js +67 -0
  155. package/esm/Menu/Menu.js +46 -36
  156. package/esm/Menu/MenuItem.d.ts +1 -1
  157. package/esm/Menu/MenuItem.js +16 -12
  158. package/esm/Menu/Menubar.d.ts +1 -1
  159. package/esm/Message/Message.js +15 -13
  160. package/esm/Modal/Modal.js +3 -2
  161. package/esm/Modal/utils.js +14 -12
  162. package/esm/Notification/Notification.js +7 -4
  163. package/esm/Overlay/Modal.js +11 -8
  164. package/esm/Overlay/ModalManager.js +6 -1
  165. package/esm/Overlay/OverlayTrigger.js +1 -1
  166. package/esm/Overlay/Position.js +20 -11
  167. package/esm/Overlay/positionUtils.js +5 -1
  168. package/esm/Panel/Panel.d.ts +1 -1
  169. package/esm/Picker/DropdownMenu.js +3 -1
  170. package/esm/Picker/DropdownMenuCheckItem.d.ts +3 -3
  171. package/esm/Picker/PickerOverlay.js +2 -1
  172. package/esm/Picker/PickerToggle.d.ts +6 -0
  173. package/esm/Picker/PickerToggle.js +15 -8
  174. package/esm/Picker/SearchBar.d.ts +1 -1
  175. package/esm/Picker/utils.d.ts +2 -2
  176. package/esm/Radio/Radio.d.ts +1 -1
  177. package/esm/RadioGroup/RadioGroup.d.ts +1 -1
  178. package/esm/RadioGroup/RadioGroup.js +2 -2
  179. package/esm/RangeSlider/RangeSlider.js +4 -2
  180. package/esm/Rate/Character.js +2 -2
  181. package/esm/Rate/Rate.js +2 -1
  182. package/esm/Ripple/Ripple.js +4 -3
  183. package/esm/Sidenav/SidenavDropdownItem.d.ts +1 -1
  184. package/esm/Sidenav/SidenavDropdownItem.js +16 -10
  185. package/esm/Sidenav/SidenavDropdownMenu.d.ts +1 -1
  186. package/esm/Slider/Graduated.js +1 -1
  187. package/esm/Slider/Handle.js +5 -2
  188. package/esm/Slider/ProgressBar.js +1 -1
  189. package/esm/Slider/Slider.js +4 -2
  190. package/esm/Toggle/Toggle.d.ts +3 -6
  191. package/esm/Toggle/Toggle.js +34 -29
  192. package/esm/Tree/Tree.d.ts +3 -3
  193. package/esm/TreePicker/TreeNode.d.ts +1 -1
  194. package/esm/TreePicker/TreeNode.js +1 -1
  195. package/esm/TreePicker/TreePicker.d.ts +1 -1
  196. package/esm/Uploader/Uploader.d.ts +4 -4
  197. package/esm/locales/fa_IR.js +8 -8
  198. package/esm/utils/BrowserDetection.js +1 -1
  199. package/esm/utils/index.d.ts +1 -0
  200. package/esm/utils/index.js +2 -1
  201. package/esm/utils/scrollTopAnimation.js +2 -2
  202. package/esm/utils/treeUtils.d.ts +2 -2
  203. package/esm/utils/useElementResize.d.ts +1 -1
  204. package/esm/utils/useElementResize.js +12 -5
  205. package/esm/utils/useEventListener.js +1 -1
  206. package/esm/utils/useIsMounted.d.ts +2 -0
  207. package/esm/utils/useIsMounted.js +16 -0
  208. package/esm/utils/usePortal.js +2 -2
  209. package/esm/utils/useRootClose.js +8 -6
  210. package/package.json +5 -5
  211. 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 { on } from 'dom-lib';
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 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 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, { 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
-
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 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'])));
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
- var menuFocus = useFocus(menuElementRef);
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
- menuFocus.grab();
58
- }, [dispatch, onToggleMenu, menuFocus]);
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
- onKeyDown: handleButtonKeydown
155
- };
156
- /**
157
- * Bind event of trigger,
158
- * not used in in the expanded state of '<Sidenav>'
159
- */
160
-
161
- if (openMenuOn !== null && openMenuOn !== void 0 && openMenuOn.includes('click')) {
162
- buttonEventHandlers.onClick = handleButtonClick;
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
- if (openMenuOn !== null && openMenuOn !== void 0 && openMenuOn.includes('contextmenu')) {
166
- buttonEventHandlers.onContextMenu = handleButtonContextMenu;
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-'); // Ref: https://www.w3.org/TR/wai-aria-practices-1.2/#wai-aria-roles-states-and-properties-14
171
-
172
- var buttonAriaAttributes = {
173
- role: 'button',
174
- 'aria-haspopup': 'menu',
175
- 'aria-expanded': open || undefined,
176
- // it's recommend to remove aria-expanded when menu is hidden
177
- 'aria-controls': menuId
178
- };
179
-
180
- var buttonProps = _extends({
181
- id: buttonId
182
- }, buttonAriaAttributes, buttonEventHandlers, {
183
- // render props
184
- open: open
185
- });
186
-
187
- var customMenuButton = renderMenuButton === null || renderMenuButton === void 0 ? void 0 : renderMenuButton(buttonProps, buttonElementRef);
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);
@@ -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<HTMLElement>) => void;
11
+ onActivate?: (event: React.SyntheticEvent) => void;
12
12
  }
13
13
  export interface MenuitemRenderProps {
14
14
  selected: boolean;
@@ -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
- dispatch({
36
- type: MenuActionTypes.MoveFocus,
37
- to: MoveFocusTo.Specific,
38
- id: menuitemRef.current.id
39
- });
40
- }, [dispatch]); // Gain/release focus on mouseenter/mouseleave in `menu`
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
- dispatch({
44
- type: MenuActionTypes.MoveFocus,
45
- to: MoveFocusTo.Specific,
46
- id: menuitemRef.current.id
47
- });
48
- }, [dispatch]);
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,
@@ -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<HTMLElement>) => void;
8
+ onActivateItem?: (event: React.SyntheticEvent) => void;
9
9
  }
10
10
  export default function Menubar({ vertical, children, onActivateItem }: MenubarProps): JSX.Element;
@@ -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; // Timed close message
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, {
@@ -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 = helper.on(dialogRef.current, helper.animation.events().end, function () {
101
+ transitionEndListener.current = on(dialogRef.current, getTransitionEnd(), function () {
101
102
  setShake(false);
102
103
  });
103
104
  }
@@ -1,6 +1,7 @@
1
1
  import { useState, useRef, useCallback, useEffect } from 'react';
2
- import bindElementResize, { unbind as unbindElementResize } from 'element-resize-event';
3
- import helper from '../DOMHelper';
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 ? helper.getHeight(headerDOM) + headerHeight : headerHeight;
28
- footerHeight = footerDOM ? helper.getHeight(footerDOM) + footerHeight : footerHeight;
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 = helper.getHeight(window) - excludeHeight;
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 = helper.on(window, 'resize', updateBodyStyles);
57
- bindElementResize(contentElement.current, updateBodyStyles);
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; // Timed close message
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
- setDisplay('hide');
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;