@moda/om 18.3.2 → 18.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/dist/index.cjs.js +1866 -1745
  2. package/dist/index.cjs.js.map +1 -1
  3. package/dist/index.esm.js +1867 -1747
  4. package/dist/index.esm.js.map +1 -1
  5. package/dist/src/__mocks__/Icon.d.ts +2 -2
  6. package/dist/src/components/AspectRatioBox/AspectRatioBox.stories.d.ts +2 -2
  7. package/dist/src/components/Badge/Badge.stories.d.ts +3 -3
  8. package/dist/src/components/Breadcrumbs/Breadcrumbs.stories.d.ts +3 -3
  9. package/dist/src/components/Breakpoint/Breakpoint.stories.d.ts +4 -4
  10. package/dist/src/components/Button/Button.stories.d.ts +13 -13
  11. package/dist/src/components/Checkbox/Checkbox.stories.d.ts +7 -7
  12. package/dist/src/components/Clickable/Clickable.stories.d.ts +4 -4
  13. package/dist/src/components/ColorSwatch/ColorSwatch.stories.d.ts +6 -6
  14. package/dist/src/components/Constrain/Constrain.stories.d.ts +5 -5
  15. package/dist/src/components/Constrain/ExceedConstrain.stories.d.ts +4 -4
  16. package/dist/src/components/ControlLink/ControlLink.stories.d.ts +3 -3
  17. package/dist/src/components/CreditCardNumberInput/CreditCardNumberInput.stories.d.ts +2 -2
  18. package/dist/src/components/DefinitionList/DefinitionList.stories.d.ts +2 -2
  19. package/dist/src/components/Divider/Divider.stories.d.ts +5 -5
  20. package/dist/src/components/Expandable/Expandable.stories.d.ts +6 -6
  21. package/dist/src/components/Field/Field.stories.d.ts +4 -4
  22. package/dist/src/components/Label/Label.stories.d.ts +2 -2
  23. package/dist/src/components/Loading/Loading.stories.d.ts +2 -2
  24. package/dist/src/components/LoadingBalls/LoadingBalls.stories.d.ts +2 -2
  25. package/dist/src/components/LoadingShapes/LoadingShapes.d.ts +2 -2
  26. package/dist/src/components/LoadingShapes/LoadingShapes.stories.d.ts +2 -2
  27. package/dist/src/components/Modal/Modal.stories.d.ts +3 -3
  28. package/dist/src/components/ModalOverlay/ModalOverlay.stories.d.ts +2 -2
  29. package/dist/src/components/NavigationPreventer/NavigationPreventer.d.ts +7 -0
  30. package/dist/src/components/NavigationPreventer/index.d.ts +1 -0
  31. package/dist/src/components/NavigationPreventer/usePreventNavigation.d.ts +1 -0
  32. package/dist/src/components/Overlay/Overlay.stories.d.ts +2 -2
  33. package/dist/src/components/Paginator/Paginator.stories.d.ts +2 -2
  34. package/dist/src/components/PasswordInput/PasswordInput.stories.d.ts +2 -2
  35. package/dist/src/components/Popover/Popover.stories.d.ts +2 -2
  36. package/dist/src/components/PromoBanner/PromoBanner.stories.d.ts +3 -3
  37. package/dist/src/components/RadioButton/RadioButton.stories.d.ts +3 -3
  38. package/dist/src/components/SearchInput/SearchInput.stories.d.ts +3 -3
  39. package/dist/src/components/Select/Select.stories.d.ts +10 -10
  40. package/dist/src/components/SelectableButton/SelectableButton.stories.d.ts +4 -4
  41. package/dist/src/components/Shape/Shape.stories.d.ts +2 -2
  42. package/dist/src/components/SlidingPane/SlidingPane.stories.d.ts +2 -2
  43. package/dist/src/components/Stack/Stack.stories.d.ts +5 -5
  44. package/dist/src/components/Tabs/Tabs.stories.d.ts +3 -3
  45. package/dist/src/components/Tag/Tag.stories.d.ts +2 -2
  46. package/dist/src/components/Text/Text.stories.d.ts +5 -5
  47. package/dist/src/components/TextInput/TextInput.stories.d.ts +2 -2
  48. package/dist/src/components/Textarea/Textarea.stories.d.ts +2 -2
  49. package/dist/src/components/Toast/Toast.stories.d.ts +2 -2
  50. package/dist/src/components/VerticalDivider/VerticalDivider.stories.d.ts +3 -3
  51. package/dist/src/components/index.d.ts +1 -0
  52. package/dist/src/index.d.ts +4 -0
  53. package/dist/src/mixins/font-smoothing/font-smoothing.stories.d.ts +2 -2
  54. package/dist/src/mixins/overflow-scroll/overflow-scroll.stories.d.ts +3 -3
  55. package/dist/src/mixins/stack/stack.stories.d.ts +3 -3
  56. package/dist/src/mixins/thin-underline/thin-underline.stories.d.ts +2 -2
  57. package/dist/src/mixins/visually-hidden/visually-hidden.stories.d.ts +2 -2
  58. package/dist/src/utilities/preventNavigation.d.ts +1 -0
  59. package/dist/styles.css +1 -1
  60. package/dist/test/setupTests.d.ts +0 -1
  61. package/package.json +13 -13
  62. package/src/components/Expandable/Expandable.stories.tsx +1 -1
  63. package/src/components/ModalOverlay/ModalOverlay.test.tsx +2 -2
  64. package/src/components/NavigationPreventer/NavigationPreventer.tsx +17 -0
  65. package/src/components/NavigationPreventer/index.ts +1 -0
  66. package/src/components/NavigationPreventer/usePreventNavigation.ts +12 -0
  67. package/src/components/index.ts +1 -0
  68. package/src/hooks/useBreakpoint.ts +2 -2
  69. package/src/utilities/preventNavigation.ts +4 -0
package/dist/index.cjs.js CHANGED
@@ -340,6 +340,8 @@ colors.colors = {
340
340
  "money-good": "rgb(4, 108, 0)",
341
341
  "fuchsia": "rgb(196, 76, 176)",
342
342
  "dark-fuchsia": "rgb(180, 60, 160)",
343
+ "teal": "rgb(0, 111, 98)",
344
+ "ivory": "rgb(242, 233, 219)",
343
345
  "klein-blue": "rgb(38, 48, 120)",
344
346
  "brick": "rgb(147, 58, 32)",
345
347
  "goldenrod": "rgb(186, 145, 46)",
@@ -360,7 +362,9 @@ colors.colors = {
360
362
  "mint": "rgb(227, 251, 226)",
361
363
  "money-good": "rgb(4, 108, 0)",
362
364
  "fuchsia": "rgb(196, 76, 176)",
363
- "dark-fuchsia": "rgb(180, 60, 160)"
365
+ "dark-fuchsia": "rgb(180, 60, 160)",
366
+ "teal": "rgb(0, 111, 98)",
367
+ "ivory": "rgb(242, 233, 219)"
364
368
  },
365
369
  "global": {
366
370
  "klein-blue": "rgb(38, 48, 120)",
@@ -953,7 +957,7 @@ var colorStringExports = colorString.exports;
953
957
  return [topY, rightX, bottom, left].reduce(function (acc, value) {
954
958
  var _a;
955
959
  if (value === undefined) return acc;
956
- return [acc, (_a = space_1.space.scale[value]) !== null && _a !== void 0 ? _a : value].join(' ');
960
+ return [acc, (_a = space_1.space.scale[Number(value)]) !== null && _a !== void 0 ? _a : value].join(' ');
957
961
  }, '');
958
962
  };
959
963
  exports.spacing = spacing;
@@ -1015,62 +1019,62 @@ var colorStringExports = colorString.exports;
1015
1019
  __exportStar(helpers, exports);
1016
1020
  })(dist$4);
1017
1021
 
1018
- function _iterableToArrayLimit(arr, i) {
1019
- var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"];
1020
- if (null != _i) {
1021
- var _s,
1022
- _e,
1023
- _x,
1024
- _r,
1025
- _arr = [],
1026
- _n = !0,
1027
- _d = !1;
1022
+ function _iterableToArrayLimit(r, l) {
1023
+ var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
1024
+ if (null != t) {
1025
+ var e,
1026
+ n,
1027
+ i,
1028
+ u,
1029
+ a = [],
1030
+ f = !0,
1031
+ o = !1;
1028
1032
  try {
1029
- if (_x = (_i = _i.call(arr)).next, 0 === i) {
1030
- if (Object(_i) !== _i) return;
1031
- _n = !1;
1032
- } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0);
1033
- } catch (err) {
1034
- _d = !0, _e = err;
1033
+ if (i = (t = t.call(r)).next, 0 === l) {
1034
+ if (Object(t) !== t) return;
1035
+ f = !1;
1036
+ } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
1037
+ } catch (r) {
1038
+ o = !0, n = r;
1035
1039
  } finally {
1036
1040
  try {
1037
- if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return;
1041
+ if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
1038
1042
  } finally {
1039
- if (_d) throw _e;
1043
+ if (o) throw n;
1040
1044
  }
1041
1045
  }
1042
- return _arr;
1046
+ return a;
1043
1047
  }
1044
1048
  }
1045
- function ownKeys(object, enumerableOnly) {
1046
- var keys = Object.keys(object);
1049
+ function ownKeys(e, r) {
1050
+ var t = Object.keys(e);
1047
1051
  if (Object.getOwnPropertySymbols) {
1048
- var symbols = Object.getOwnPropertySymbols(object);
1049
- enumerableOnly && (symbols = symbols.filter(function (sym) {
1050
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
1051
- })), keys.push.apply(keys, symbols);
1052
+ var o = Object.getOwnPropertySymbols(e);
1053
+ r && (o = o.filter(function (r) {
1054
+ return Object.getOwnPropertyDescriptor(e, r).enumerable;
1055
+ })), t.push.apply(t, o);
1052
1056
  }
1053
- return keys;
1057
+ return t;
1054
1058
  }
1055
- function _objectSpread2(target) {
1056
- for (var i = 1; i < arguments.length; i++) {
1057
- var source = null != arguments[i] ? arguments[i] : {};
1058
- i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
1059
- _defineProperty$1(target, key, source[key]);
1060
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
1061
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
1059
+ function _objectSpread2(e) {
1060
+ for (var r = 1; r < arguments.length; r++) {
1061
+ var t = null != arguments[r] ? arguments[r] : {};
1062
+ r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
1063
+ _defineProperty$1(e, r, t[r]);
1064
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
1065
+ Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
1062
1066
  });
1063
1067
  }
1064
- return target;
1068
+ return e;
1065
1069
  }
1066
- function _typeof$1(obj) {
1070
+ function _typeof$1(o) {
1067
1071
  "@babel/helpers - typeof";
1068
1072
 
1069
- return _typeof$1 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
1070
- return typeof obj;
1071
- } : function (obj) {
1072
- return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
1073
- }, _typeof$1(obj);
1073
+ return _typeof$1 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
1074
+ return typeof o;
1075
+ } : function (o) {
1076
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
1077
+ }, _typeof$1(o);
1074
1078
  }
1075
1079
  function _defineProperty$1(obj, key, value) {
1076
1080
  key = _toPropertyKey$1(key);
@@ -1344,7 +1348,9 @@ var stringifyProps = function stringifyProps(props) {
1344
1348
 
1345
1349
  /* eslint-disable @typescript-eslint/no-explicit-any */
1346
1350
 
1347
- /* eslint-enable @typescript-eslint/no-explicit-any */ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1351
+ /* eslint-enable @typescript-eslint/no-explicit-any */
1352
+
1353
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1348
1354
  var isEmpty = function isEmpty(obj) {
1349
1355
  return Object.entries(obj || {}).length === 0;
1350
1356
  };
@@ -1662,11 +1668,12 @@ var RemoveScroll = /*#__PURE__*/React__namespace.forwardRef(function (props, par
1662
1668
  allowPinchZoom = props.allowPinchZoom,
1663
1669
  _b = props.as,
1664
1670
  Container = _b === void 0 ? 'div' : _b,
1665
- rest = __rest$a(props, ["forwardProps", "children", "className", "removeScrollBar", "enabled", "shards", "sideCar", "noIsolation", "inert", "allowPinchZoom", "as"]);
1671
+ gapMode = props.gapMode,
1672
+ rest = __rest$a(props, ["forwardProps", "children", "className", "removeScrollBar", "enabled", "shards", "sideCar", "noIsolation", "inert", "allowPinchZoom", "as", "gapMode"]);
1666
1673
  var SideCar = sideCar;
1667
1674
  var containerRef = useMergeRefs([ref, parentRef]);
1668
1675
  var containerProps = _assign(_assign({}, rest), callbacks);
1669
- return /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, null, enabled && /*#__PURE__*/React__namespace.createElement(SideCar, {
1676
+ return /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, null, enabled && ( /*#__PURE__*/React__namespace.createElement(SideCar, {
1670
1677
  sideCar: effectCar$1,
1671
1678
  removeScrollBar: removeScrollBar,
1672
1679
  shards: shards,
@@ -1674,13 +1681,14 @@ var RemoveScroll = /*#__PURE__*/React__namespace.forwardRef(function (props, par
1674
1681
  inert: inert,
1675
1682
  setCallbacks: setCallbacks,
1676
1683
  allowPinchZoom: !!allowPinchZoom,
1677
- lockRef: ref
1678
- }), forwardProps ? /*#__PURE__*/React__namespace.cloneElement(React__namespace.Children.only(children), _assign(_assign({}, containerProps), {
1684
+ lockRef: ref,
1685
+ gapMode: gapMode
1686
+ })), forwardProps ? ( /*#__PURE__*/React__namespace.cloneElement(React__namespace.Children.only(children), _assign(_assign({}, containerProps), {
1679
1687
  ref: containerRef
1680
- })) : /*#__PURE__*/React__namespace.createElement(Container, _assign({}, containerProps, {
1688
+ }))) : ( /*#__PURE__*/React__namespace.createElement(Container, _assign({}, containerProps, {
1681
1689
  className: className,
1682
1690
  ref: containerRef
1683
- }), children));
1691
+ }), children)));
1684
1692
  });
1685
1693
  RemoveScroll.defaultProps = {
1686
1694
  enabled: true,
@@ -1709,123 +1717,84 @@ function _extends() {
1709
1717
 
1710
1718
  var propTypes = {exports: {}};
1711
1719
 
1712
- var reactIs = {exports: {}};
1713
-
1714
- var reactIs_production_min = {};
1720
+ /**
1721
+ * Copyright (c) 2013-present, Facebook, Inc.
1722
+ *
1723
+ * This source code is licensed under the MIT license found in the
1724
+ * LICENSE file in the root directory of this source tree.
1725
+ */
1726
+ var ReactPropTypesSecret_1;
1727
+ var hasRequiredReactPropTypesSecret;
1728
+ function requireReactPropTypesSecret() {
1729
+ if (hasRequiredReactPropTypesSecret) return ReactPropTypesSecret_1;
1730
+ hasRequiredReactPropTypesSecret = 1;
1731
+ var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
1732
+ ReactPropTypesSecret_1 = ReactPropTypesSecret;
1733
+ return ReactPropTypesSecret_1;
1734
+ }
1715
1735
 
1716
- var hasRequiredReactIs_production_min;
1717
- function requireReactIs_production_min() {
1718
- if (hasRequiredReactIs_production_min) return reactIs_production_min;
1719
- hasRequiredReactIs_production_min = 1;
1720
- var b = "function" === typeof Symbol && Symbol["for"],
1721
- c = b ? Symbol["for"]("react.element") : 60103,
1722
- d = b ? Symbol["for"]("react.portal") : 60106,
1723
- e = b ? Symbol["for"]("react.fragment") : 60107,
1724
- f = b ? Symbol["for"]("react.strict_mode") : 60108,
1725
- g = b ? Symbol["for"]("react.profiler") : 60114,
1726
- h = b ? Symbol["for"]("react.provider") : 60109,
1727
- k = b ? Symbol["for"]("react.context") : 60110,
1728
- l = b ? Symbol["for"]("react.async_mode") : 60111,
1729
- m = b ? Symbol["for"]("react.concurrent_mode") : 60111,
1730
- n = b ? Symbol["for"]("react.forward_ref") : 60112,
1731
- p = b ? Symbol["for"]("react.suspense") : 60113,
1732
- q = b ? Symbol["for"]("react.suspense_list") : 60120,
1733
- r = b ? Symbol["for"]("react.memo") : 60115,
1734
- t = b ? Symbol["for"]("react.lazy") : 60116,
1735
- v = b ? Symbol["for"]("react.block") : 60121,
1736
- w = b ? Symbol["for"]("react.fundamental") : 60117,
1737
- x = b ? Symbol["for"]("react.responder") : 60118,
1738
- y = b ? Symbol["for"]("react.scope") : 60119;
1739
- function z(a) {
1740
- if ("object" === _typeof$1(a) && null !== a) {
1741
- var u = a.$$typeof;
1742
- switch (u) {
1743
- case c:
1744
- switch (a = a.type, a) {
1745
- case l:
1746
- case m:
1747
- case e:
1748
- case g:
1749
- case f:
1750
- case p:
1751
- return a;
1752
- default:
1753
- switch (a = a && a.$$typeof, a) {
1754
- case k:
1755
- case n:
1756
- case t:
1757
- case r:
1758
- case h:
1759
- return a;
1760
- default:
1761
- return u;
1762
- }
1763
- }
1764
- case d:
1765
- return u;
1736
+ /**
1737
+ * Copyright (c) 2013-present, Facebook, Inc.
1738
+ *
1739
+ * This source code is licensed under the MIT license found in the
1740
+ * LICENSE file in the root directory of this source tree.
1741
+ */
1742
+ var factoryWithThrowingShims;
1743
+ var hasRequiredFactoryWithThrowingShims;
1744
+ function requireFactoryWithThrowingShims() {
1745
+ if (hasRequiredFactoryWithThrowingShims) return factoryWithThrowingShims;
1746
+ hasRequiredFactoryWithThrowingShims = 1;
1747
+ var ReactPropTypesSecret = requireReactPropTypesSecret();
1748
+ function emptyFunction() {}
1749
+ function emptyFunctionWithReset() {}
1750
+ emptyFunctionWithReset.resetWarningCache = emptyFunction;
1751
+ factoryWithThrowingShims = function factoryWithThrowingShims() {
1752
+ function shim(props, propName, componentName, location, propFullName, secret) {
1753
+ if (secret === ReactPropTypesSecret) {
1754
+ // It is still safe when called from React.
1755
+ return;
1766
1756
  }
1757
+ var err = new Error('Calling PropTypes validators directly is not supported by the `prop-types` package. ' + 'Use PropTypes.checkPropTypes() to call them. ' + 'Read more at http://fb.me/use-check-prop-types');
1758
+ err.name = 'Invariant Violation';
1759
+ throw err;
1767
1760
  }
1768
- }
1769
- function A(a) {
1770
- return z(a) === m;
1771
- }
1772
- reactIs_production_min.AsyncMode = l;
1773
- reactIs_production_min.ConcurrentMode = m;
1774
- reactIs_production_min.ContextConsumer = k;
1775
- reactIs_production_min.ContextProvider = h;
1776
- reactIs_production_min.Element = c;
1777
- reactIs_production_min.ForwardRef = n;
1778
- reactIs_production_min.Fragment = e;
1779
- reactIs_production_min.Lazy = t;
1780
- reactIs_production_min.Memo = r;
1781
- reactIs_production_min.Portal = d;
1782
- reactIs_production_min.Profiler = g;
1783
- reactIs_production_min.StrictMode = f;
1784
- reactIs_production_min.Suspense = p;
1785
- reactIs_production_min.isAsyncMode = function (a) {
1786
- return A(a) || z(a) === l;
1787
- };
1788
- reactIs_production_min.isConcurrentMode = A;
1789
- reactIs_production_min.isContextConsumer = function (a) {
1790
- return z(a) === k;
1791
- };
1792
- reactIs_production_min.isContextProvider = function (a) {
1793
- return z(a) === h;
1794
- };
1795
- reactIs_production_min.isElement = function (a) {
1796
- return "object" === _typeof$1(a) && null !== a && a.$$typeof === c;
1797
- };
1798
- reactIs_production_min.isForwardRef = function (a) {
1799
- return z(a) === n;
1800
- };
1801
- reactIs_production_min.isFragment = function (a) {
1802
- return z(a) === e;
1803
- };
1804
- reactIs_production_min.isLazy = function (a) {
1805
- return z(a) === t;
1806
- };
1807
- reactIs_production_min.isMemo = function (a) {
1808
- return z(a) === r;
1809
- };
1810
- reactIs_production_min.isPortal = function (a) {
1811
- return z(a) === d;
1812
- };
1813
- reactIs_production_min.isProfiler = function (a) {
1814
- return z(a) === g;
1815
- };
1816
- reactIs_production_min.isStrictMode = function (a) {
1817
- return z(a) === f;
1818
- };
1819
- reactIs_production_min.isSuspense = function (a) {
1820
- return z(a) === p;
1821
- };
1822
- reactIs_production_min.isValidElementType = function (a) {
1823
- return "string" === typeof a || "function" === typeof a || a === e || a === m || a === g || a === f || a === p || a === q || "object" === _typeof$1(a) && null !== a && (a.$$typeof === t || a.$$typeof === r || a.$$typeof === h || a.$$typeof === k || a.$$typeof === n || a.$$typeof === w || a.$$typeof === x || a.$$typeof === y || a.$$typeof === v);
1761
+ shim.isRequired = shim;
1762
+ function getShim() {
1763
+ return shim;
1764
+ }
1765
+ // Important!
1766
+ // Keep this list in sync with production version in `./factoryWithTypeCheckers.js`.
1767
+ var ReactPropTypes = {
1768
+ array: shim,
1769
+ bigint: shim,
1770
+ bool: shim,
1771
+ func: shim,
1772
+ number: shim,
1773
+ object: shim,
1774
+ string: shim,
1775
+ symbol: shim,
1776
+ any: shim,
1777
+ arrayOf: getShim,
1778
+ element: shim,
1779
+ elementType: shim,
1780
+ instanceOf: getShim,
1781
+ node: shim,
1782
+ objectOf: getShim,
1783
+ oneOf: getShim,
1784
+ oneOfType: getShim,
1785
+ shape: getShim,
1786
+ exact: getShim,
1787
+ checkPropTypes: emptyFunctionWithReset,
1788
+ resetWarningCache: emptyFunction
1789
+ };
1790
+ ReactPropTypes.PropTypes = ReactPropTypes;
1791
+ return ReactPropTypes;
1824
1792
  };
1825
- reactIs_production_min.typeOf = z;
1826
- return reactIs_production_min;
1793
+ return factoryWithThrowingShims;
1827
1794
  }
1828
1795
 
1796
+ var reactIs = {exports: {}};
1797
+
1829
1798
  var reactIs_development = {};
1830
1799
 
1831
1800
  var hasRequiredReactIs_development;
@@ -1991,68 +1960,183 @@ function requireReactIs_development() {
1991
1960
  return reactIs_development;
1992
1961
  }
1993
1962
 
1994
- var hasRequiredReactIs;
1995
- function requireReactIs() {
1996
- if (hasRequiredReactIs) return reactIs.exports;
1997
- hasRequiredReactIs = 1;
1998
- if (process.env.NODE_ENV === 'production') {
1999
- reactIs.exports = requireReactIs_production_min();
2000
- } else {
2001
- reactIs.exports = requireReactIs_development();
2002
- }
2003
- return reactIs.exports;
2004
- }
2005
-
2006
- /*
2007
- object-assign
2008
- (c) Sindre Sorhus
2009
- @license MIT
2010
- */
2011
- var objectAssign;
2012
- var hasRequiredObjectAssign;
2013
- function requireObjectAssign() {
2014
- if (hasRequiredObjectAssign) return objectAssign;
2015
- hasRequiredObjectAssign = 1;
2016
- /* eslint-disable no-unused-vars */
2017
- var getOwnPropertySymbols = Object.getOwnPropertySymbols;
2018
- var hasOwnProperty = Object.prototype.hasOwnProperty;
2019
- var propIsEnumerable = Object.prototype.propertyIsEnumerable;
2020
- function toObject(val) {
2021
- if (val === null || val === undefined) {
2022
- throw new TypeError('Object.assign cannot be called with null or undefined');
2023
- }
2024
- return Object(val);
2025
- }
2026
- function shouldUseNative() {
2027
- try {
2028
- if (!Object.assign) {
2029
- return false;
2030
- }
2031
-
2032
- // Detect buggy property enumeration order in older V8 versions.
2033
-
2034
- // https://bugs.chromium.org/p/v8/issues/detail?id=4118
2035
- var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
2036
- test1[5] = 'de';
2037
- if (Object.getOwnPropertyNames(test1)[0] === '5') {
2038
- return false;
2039
- }
2040
-
2041
- // https://bugs.chromium.org/p/v8/issues/detail?id=3056
2042
- var test2 = {};
2043
- for (var i = 0; i < 10; i++) {
2044
- test2['_' + String.fromCharCode(i)] = i;
2045
- }
2046
- var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
2047
- return test2[n];
2048
- });
2049
- if (order2.join('') !== '0123456789') {
2050
- return false;
2051
- }
1963
+ var reactIs_production_min = {};
2052
1964
 
2053
- // https://bugs.chromium.org/p/v8/issues/detail?id=3056
2054
- var test3 = {};
2055
- 'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
1965
+ var hasRequiredReactIs_production_min;
1966
+ function requireReactIs_production_min() {
1967
+ if (hasRequiredReactIs_production_min) return reactIs_production_min;
1968
+ hasRequiredReactIs_production_min = 1;
1969
+ var b = "function" === typeof Symbol && Symbol["for"],
1970
+ c = b ? Symbol["for"]("react.element") : 60103,
1971
+ d = b ? Symbol["for"]("react.portal") : 60106,
1972
+ e = b ? Symbol["for"]("react.fragment") : 60107,
1973
+ f = b ? Symbol["for"]("react.strict_mode") : 60108,
1974
+ g = b ? Symbol["for"]("react.profiler") : 60114,
1975
+ h = b ? Symbol["for"]("react.provider") : 60109,
1976
+ k = b ? Symbol["for"]("react.context") : 60110,
1977
+ l = b ? Symbol["for"]("react.async_mode") : 60111,
1978
+ m = b ? Symbol["for"]("react.concurrent_mode") : 60111,
1979
+ n = b ? Symbol["for"]("react.forward_ref") : 60112,
1980
+ p = b ? Symbol["for"]("react.suspense") : 60113,
1981
+ q = b ? Symbol["for"]("react.suspense_list") : 60120,
1982
+ r = b ? Symbol["for"]("react.memo") : 60115,
1983
+ t = b ? Symbol["for"]("react.lazy") : 60116,
1984
+ v = b ? Symbol["for"]("react.block") : 60121,
1985
+ w = b ? Symbol["for"]("react.fundamental") : 60117,
1986
+ x = b ? Symbol["for"]("react.responder") : 60118,
1987
+ y = b ? Symbol["for"]("react.scope") : 60119;
1988
+ function z(a) {
1989
+ if ("object" === _typeof$1(a) && null !== a) {
1990
+ var u = a.$$typeof;
1991
+ switch (u) {
1992
+ case c:
1993
+ switch (a = a.type, a) {
1994
+ case l:
1995
+ case m:
1996
+ case e:
1997
+ case g:
1998
+ case f:
1999
+ case p:
2000
+ return a;
2001
+ default:
2002
+ switch (a = a && a.$$typeof, a) {
2003
+ case k:
2004
+ case n:
2005
+ case t:
2006
+ case r:
2007
+ case h:
2008
+ return a;
2009
+ default:
2010
+ return u;
2011
+ }
2012
+ }
2013
+ case d:
2014
+ return u;
2015
+ }
2016
+ }
2017
+ }
2018
+ function A(a) {
2019
+ return z(a) === m;
2020
+ }
2021
+ reactIs_production_min.AsyncMode = l;
2022
+ reactIs_production_min.ConcurrentMode = m;
2023
+ reactIs_production_min.ContextConsumer = k;
2024
+ reactIs_production_min.ContextProvider = h;
2025
+ reactIs_production_min.Element = c;
2026
+ reactIs_production_min.ForwardRef = n;
2027
+ reactIs_production_min.Fragment = e;
2028
+ reactIs_production_min.Lazy = t;
2029
+ reactIs_production_min.Memo = r;
2030
+ reactIs_production_min.Portal = d;
2031
+ reactIs_production_min.Profiler = g;
2032
+ reactIs_production_min.StrictMode = f;
2033
+ reactIs_production_min.Suspense = p;
2034
+ reactIs_production_min.isAsyncMode = function (a) {
2035
+ return A(a) || z(a) === l;
2036
+ };
2037
+ reactIs_production_min.isConcurrentMode = A;
2038
+ reactIs_production_min.isContextConsumer = function (a) {
2039
+ return z(a) === k;
2040
+ };
2041
+ reactIs_production_min.isContextProvider = function (a) {
2042
+ return z(a) === h;
2043
+ };
2044
+ reactIs_production_min.isElement = function (a) {
2045
+ return "object" === _typeof$1(a) && null !== a && a.$$typeof === c;
2046
+ };
2047
+ reactIs_production_min.isForwardRef = function (a) {
2048
+ return z(a) === n;
2049
+ };
2050
+ reactIs_production_min.isFragment = function (a) {
2051
+ return z(a) === e;
2052
+ };
2053
+ reactIs_production_min.isLazy = function (a) {
2054
+ return z(a) === t;
2055
+ };
2056
+ reactIs_production_min.isMemo = function (a) {
2057
+ return z(a) === r;
2058
+ };
2059
+ reactIs_production_min.isPortal = function (a) {
2060
+ return z(a) === d;
2061
+ };
2062
+ reactIs_production_min.isProfiler = function (a) {
2063
+ return z(a) === g;
2064
+ };
2065
+ reactIs_production_min.isStrictMode = function (a) {
2066
+ return z(a) === f;
2067
+ };
2068
+ reactIs_production_min.isSuspense = function (a) {
2069
+ return z(a) === p;
2070
+ };
2071
+ reactIs_production_min.isValidElementType = function (a) {
2072
+ return "string" === typeof a || "function" === typeof a || a === e || a === m || a === g || a === f || a === p || a === q || "object" === _typeof$1(a) && null !== a && (a.$$typeof === t || a.$$typeof === r || a.$$typeof === h || a.$$typeof === k || a.$$typeof === n || a.$$typeof === w || a.$$typeof === x || a.$$typeof === y || a.$$typeof === v);
2073
+ };
2074
+ reactIs_production_min.typeOf = z;
2075
+ return reactIs_production_min;
2076
+ }
2077
+
2078
+ var hasRequiredReactIs;
2079
+ function requireReactIs() {
2080
+ if (hasRequiredReactIs) return reactIs.exports;
2081
+ hasRequiredReactIs = 1;
2082
+ if (process.env.NODE_ENV === 'production') {
2083
+ reactIs.exports = requireReactIs_production_min();
2084
+ } else {
2085
+ reactIs.exports = requireReactIs_development();
2086
+ }
2087
+ return reactIs.exports;
2088
+ }
2089
+
2090
+ /*
2091
+ object-assign
2092
+ (c) Sindre Sorhus
2093
+ @license MIT
2094
+ */
2095
+ var objectAssign;
2096
+ var hasRequiredObjectAssign;
2097
+ function requireObjectAssign() {
2098
+ if (hasRequiredObjectAssign) return objectAssign;
2099
+ hasRequiredObjectAssign = 1;
2100
+ /* eslint-disable no-unused-vars */
2101
+ var getOwnPropertySymbols = Object.getOwnPropertySymbols;
2102
+ var hasOwnProperty = Object.prototype.hasOwnProperty;
2103
+ var propIsEnumerable = Object.prototype.propertyIsEnumerable;
2104
+ function toObject(val) {
2105
+ if (val === null || val === undefined) {
2106
+ throw new TypeError('Object.assign cannot be called with null or undefined');
2107
+ }
2108
+ return Object(val);
2109
+ }
2110
+ function shouldUseNative() {
2111
+ try {
2112
+ if (!Object.assign) {
2113
+ return false;
2114
+ }
2115
+
2116
+ // Detect buggy property enumeration order in older V8 versions.
2117
+
2118
+ // https://bugs.chromium.org/p/v8/issues/detail?id=4118
2119
+ var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
2120
+ test1[5] = 'de';
2121
+ if (Object.getOwnPropertyNames(test1)[0] === '5') {
2122
+ return false;
2123
+ }
2124
+
2125
+ // https://bugs.chromium.org/p/v8/issues/detail?id=3056
2126
+ var test2 = {};
2127
+ for (var i = 0; i < 10; i++) {
2128
+ test2['_' + String.fromCharCode(i)] = i;
2129
+ }
2130
+ var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
2131
+ return test2[n];
2132
+ });
2133
+ if (order2.join('') !== '0123456789') {
2134
+ return false;
2135
+ }
2136
+
2137
+ // https://bugs.chromium.org/p/v8/issues/detail?id=3056
2138
+ var test3 = {};
2139
+ 'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
2056
2140
  test3[letter] = letter;
2057
2141
  });
2058
2142
  if (Object.keys(Object.assign({}, test3)).join('') !== 'abcdefghijklmnopqrst') {
@@ -2089,22 +2173,6 @@ function requireObjectAssign() {
2089
2173
  return objectAssign;
2090
2174
  }
2091
2175
 
2092
- /**
2093
- * Copyright (c) 2013-present, Facebook, Inc.
2094
- *
2095
- * This source code is licensed under the MIT license found in the
2096
- * LICENSE file in the root directory of this source tree.
2097
- */
2098
- var ReactPropTypesSecret_1;
2099
- var hasRequiredReactPropTypesSecret;
2100
- function requireReactPropTypesSecret() {
2101
- if (hasRequiredReactPropTypesSecret) return ReactPropTypesSecret_1;
2102
- hasRequiredReactPropTypesSecret = 1;
2103
- var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
2104
- ReactPropTypesSecret_1 = ReactPropTypesSecret;
2105
- return ReactPropTypesSecret_1;
2106
- }
2107
-
2108
2176
  var has;
2109
2177
  var hasRequiredHas;
2110
2178
  function requireHas() {
@@ -2745,66 +2813,6 @@ function requireFactoryWithTypeCheckers() {
2745
2813
  return factoryWithTypeCheckers;
2746
2814
  }
2747
2815
 
2748
- /**
2749
- * Copyright (c) 2013-present, Facebook, Inc.
2750
- *
2751
- * This source code is licensed under the MIT license found in the
2752
- * LICENSE file in the root directory of this source tree.
2753
- */
2754
- var factoryWithThrowingShims;
2755
- var hasRequiredFactoryWithThrowingShims;
2756
- function requireFactoryWithThrowingShims() {
2757
- if (hasRequiredFactoryWithThrowingShims) return factoryWithThrowingShims;
2758
- hasRequiredFactoryWithThrowingShims = 1;
2759
- var ReactPropTypesSecret = requireReactPropTypesSecret();
2760
- function emptyFunction() {}
2761
- function emptyFunctionWithReset() {}
2762
- emptyFunctionWithReset.resetWarningCache = emptyFunction;
2763
- factoryWithThrowingShims = function factoryWithThrowingShims() {
2764
- function shim(props, propName, componentName, location, propFullName, secret) {
2765
- if (secret === ReactPropTypesSecret) {
2766
- // It is still safe when called from React.
2767
- return;
2768
- }
2769
- var err = new Error('Calling PropTypes validators directly is not supported by the `prop-types` package. ' + 'Use PropTypes.checkPropTypes() to call them. ' + 'Read more at http://fb.me/use-check-prop-types');
2770
- err.name = 'Invariant Violation';
2771
- throw err;
2772
- }
2773
- shim.isRequired = shim;
2774
- function getShim() {
2775
- return shim;
2776
- }
2777
- // Important!
2778
- // Keep this list in sync with production version in `./factoryWithTypeCheckers.js`.
2779
- var ReactPropTypes = {
2780
- array: shim,
2781
- bigint: shim,
2782
- bool: shim,
2783
- func: shim,
2784
- number: shim,
2785
- object: shim,
2786
- string: shim,
2787
- symbol: shim,
2788
- any: shim,
2789
- arrayOf: getShim,
2790
- element: shim,
2791
- elementType: shim,
2792
- instanceOf: getShim,
2793
- node: shim,
2794
- objectOf: getShim,
2795
- oneOf: getShim,
2796
- oneOfType: getShim,
2797
- shape: getShim,
2798
- exact: getShim,
2799
- checkPropTypes: emptyFunctionWithReset,
2800
- resetWarningCache: emptyFunction
2801
- };
2802
- ReactPropTypes.PropTypes = ReactPropTypes;
2803
- return ReactPropTypes;
2804
- };
2805
- return factoryWithThrowingShims;
2806
- }
2807
-
2808
2816
  /**
2809
2817
  * Copyright (c) 2013-present, Facebook, Inc.
2810
2818
  *
@@ -2983,7 +2991,7 @@ var FocusLock = /*#__PURE__*/React__namespace.forwardRef(function FocusLockUI(pr
2983
2991
  var hasLeadingGuards = noFocusGuards !== true;
2984
2992
  var hasTailingGuards = hasLeadingGuards && noFocusGuards !== 'tail';
2985
2993
  var mergedRef = useMergeRefs([parentRef, setObserveNode]);
2986
- return /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, null, hasLeadingGuards && [/*#__PURE__*/
2994
+ return /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, null, hasLeadingGuards && [
2987
2995
  // nearest focus guard
2988
2996
  React__namespace.createElement("div", {
2989
2997
  key: "guard-first",
@@ -3080,6 +3088,9 @@ function deferAction(action) {
3080
3088
  var effectCar = createSidecarMedium();
3081
3089
  var focusHiddenMarker = 'data-focus-on-hidden';
3082
3090
 
3091
+ var PREVENT_SCROLL = {
3092
+ preventScroll: true
3093
+ };
3083
3094
  var FocusOn$1 = /*#__PURE__*/React__namespace.forwardRef(function (props, parentRef) {
3084
3095
  var _a = React__namespace.useState(false),
3085
3096
  lockProps = _a[0],
@@ -3087,6 +3098,7 @@ var FocusOn$1 = /*#__PURE__*/React__namespace.forwardRef(function (props, parent
3087
3098
  var children = props.children,
3088
3099
  autoFocus = props.autoFocus,
3089
3100
  shards = props.shards,
3101
+ crossFrame = props.crossFrame,
3090
3102
  _b = props.enabled,
3091
3103
  enabled = _b === void 0 ? true : _b,
3092
3104
  _c = props.scrollLock,
@@ -3104,7 +3116,7 @@ var FocusOn$1 = /*#__PURE__*/React__namespace.forwardRef(function (props, parent
3104
3116
  style = props.style,
3105
3117
  as = props.as,
3106
3118
  gapMode = props.gapMode,
3107
- rest = __rest$a(props, ["children", "autoFocus", "shards", "enabled", "scrollLock", "focusLock", "returnFocus", "inert", "allowPinchZoom", "sideCar", "className", "shouldIgnore", "preventScrollOnFocus", "style", "as", "gapMode"]);
3119
+ rest = __rest$a(props, ["children", "autoFocus", "shards", "crossFrame", "enabled", "scrollLock", "focusLock", "returnFocus", "inert", "allowPinchZoom", "sideCar", "className", "shouldIgnore", "preventScrollOnFocus", "style", "as", "gapMode"]);
3108
3120
  var SideCar = sideCar;
3109
3121
  var onActivation = lockProps.onActivation,
3110
3122
  onDeactivation = lockProps.onDeactivation,
@@ -3126,20 +3138,19 @@ var FocusOn$1 = /*#__PURE__*/React__namespace.forwardRef(function (props, parent
3126
3138
  returnFocus: returnFocus,
3127
3139
  autoFocus: autoFocus,
3128
3140
  shards: shards,
3141
+ crossFrame: crossFrame,
3129
3142
  onActivation: onActivation,
3130
3143
  onDeactivation: onDeactivation,
3131
3144
  className: className,
3132
3145
  whiteList: shouldIgnore,
3133
3146
  lockProps: appliedLockProps,
3134
- focusOptions: preventScrollOnFocus ? {
3135
- preventScroll: true
3136
- } : undefined,
3147
+ focusOptions: preventScrollOnFocus ? PREVENT_SCROLL : undefined,
3137
3148
  as: RemoveScroll
3138
- }, children), enabled && /*#__PURE__*/React__namespace.createElement(SideCar, _assign({}, rest, {
3149
+ }, children), enabled && ( /*#__PURE__*/React__namespace.createElement(SideCar, _assign({}, rest, {
3139
3150
  sideCar: effectCar,
3140
3151
  setLockProps: setLockProps,
3141
3152
  shards: shards
3142
- })));
3153
+ }))));
3143
3154
  });
3144
3155
 
3145
3156
  function _setPrototypeOf(o, p) {
@@ -3269,6 +3280,9 @@ var toArray = function toArray(a) {
3269
3280
  var asArray = function asArray(a) {
3270
3281
  return Array.isArray(a) ? a : [a];
3271
3282
  };
3283
+ var getFirst = function getFirst(a) {
3284
+ return Array.isArray(a) ? a[0] : a;
3285
+ };
3272
3286
 
3273
3287
  var isElementHidden = function isElementHidden(node) {
3274
3288
  // we can measure only "elements"
@@ -3383,16 +3397,28 @@ var tabbables = ['button:enabled', 'select:enabled', 'textarea:enabled', 'input:
3383
3397
  var queryTabbables = tabbables.join(',');
3384
3398
  var queryGuardTabbables = "".concat(queryTabbables, ", [data-focus-guard]");
3385
3399
  var getFocusablesWithShadowDom = function getFocusablesWithShadowDom(parent, withGuards) {
3386
- var _a;
3387
- return toArray(((_a = parent.shadowRoot) === null || _a === void 0 ? void 0 : _a.children) || parent.children).reduce(function (acc, child) {
3400
+ return toArray((parent.shadowRoot || parent).children).reduce(function (acc, child) {
3388
3401
  return acc.concat(child.matches(withGuards ? queryGuardTabbables : queryTabbables) ? [child] : [], getFocusablesWithShadowDom(child));
3389
3402
  }, []);
3390
3403
  };
3404
+ var getFocusablesWithIFrame = function getFocusablesWithIFrame(parent, withGuards) {
3405
+ var _a;
3406
+ // contentDocument of iframe will be null if current origin cannot access it
3407
+ if (parent instanceof HTMLIFrameElement && ((_a = parent.contentDocument) === null || _a === void 0 ? void 0 : _a.body)) {
3408
+ return getFocusables([parent.contentDocument.body], withGuards);
3409
+ }
3410
+ return [parent];
3411
+ };
3391
3412
  var getFocusables = function getFocusables(parents, withGuards) {
3392
3413
  return parents.reduce(function (acc, parent) {
3414
+ var _a;
3415
+ var focusableWithShadowDom = getFocusablesWithShadowDom(parent, withGuards);
3416
+ var focusableWithIframes = (_a = []).concat.apply(_a, focusableWithShadowDom.map(function (node) {
3417
+ return getFocusablesWithIFrame(node, withGuards);
3418
+ }));
3393
3419
  return acc.concat(
3394
3420
  // add all tabbables inside and within shadow DOMs in DOM order
3395
- getFocusablesWithShadowDom(parent, withGuards),
3421
+ focusableWithIframes,
3396
3422
  // add if node is tabbable itself
3397
3423
  parent.parentNode ? toArray(parent.parentNode.querySelectorAll(queryTabbables)).filter(function (node) {
3398
3424
  return node === parent;
@@ -3465,6 +3491,14 @@ var contains$1 = function contains(scope, element) {
3465
3491
  return true;
3466
3492
  }
3467
3493
  return toArray(scope.children).some(function (child) {
3494
+ var _a;
3495
+ if (child instanceof HTMLIFrameElement) {
3496
+ var iframeBody = (_a = child.contentDocument) === null || _a === void 0 ? void 0 : _a.body;
3497
+ if (iframeBody) {
3498
+ return contains(iframeBody, element);
3499
+ }
3500
+ return false;
3501
+ }
3468
3502
  return contains(child, element);
3469
3503
  });
3470
3504
  }
@@ -3493,7 +3527,6 @@ var filterNested = function filterNested(nodes) {
3493
3527
  /* eslint-enable */
3494
3528
  }
3495
3529
  }
3496
-
3497
3530
  return nodes.filter(function (_, index) {
3498
3531
  return !contained.has(index);
3499
3532
  });
@@ -3520,34 +3553,51 @@ var getAllAffectedNodes = function getAllAffectedNodes(node) {
3520
3553
  }, []);
3521
3554
  };
3522
3555
 
3523
- var getNestedShadowActiveElement = function getNestedShadowActiveElement(shadowRoot) {
3524
- return shadowRoot.activeElement ? shadowRoot.activeElement.shadowRoot ? getNestedShadowActiveElement(shadowRoot.activeElement.shadowRoot) : shadowRoot.activeElement : undefined;
3556
+ var safeProbe = function safeProbe(cb) {
3557
+ try {
3558
+ return cb();
3559
+ } catch (e) {
3560
+ return undefined;
3561
+ }
3525
3562
  };
3563
+
3526
3564
  /**
3527
3565
  * returns active element from document or from nested shadowdoms
3528
3566
  */
3529
- var getActiveElement = function getActiveElement() {
3530
- return document.activeElement ? document.activeElement.shadowRoot ? getNestedShadowActiveElement(document.activeElement.shadowRoot) : document.activeElement : undefined; // eslint-disable-next-line @typescript-eslint/no-explicit-any
3567
+ var getActiveElement = function getActiveElement(inDocument) {
3568
+ if (inDocument === void 0) {
3569
+ inDocument = document;
3570
+ }
3571
+ if (!inDocument || !inDocument.activeElement) {
3572
+ return undefined;
3573
+ }
3574
+ var activeElement = inDocument.activeElement;
3575
+ return activeElement.shadowRoot ? getActiveElement(activeElement.shadowRoot) : activeElement instanceof HTMLIFrameElement && safeProbe(function () {
3576
+ return activeElement.contentWindow.document;
3577
+ }) ? getActiveElement(activeElement.contentWindow.document) : activeElement;
3531
3578
  };
3532
3579
 
3533
- var focusInFrame = function focusInFrame(frame) {
3534
- return frame === document.activeElement;
3580
+ var focusInFrame = function focusInFrame(frame, activeElement) {
3581
+ return frame === activeElement;
3535
3582
  };
3536
- var focusInsideIframe = function focusInsideIframe(topNode) {
3583
+ var focusInsideIframe = function focusInsideIframe(topNode, activeElement) {
3537
3584
  return Boolean(toArray(topNode.querySelectorAll('iframe')).some(function (node) {
3538
- return focusInFrame(node);
3585
+ return focusInFrame(node, activeElement);
3539
3586
  }));
3540
3587
  };
3541
3588
  /**
3542
3589
  * @returns {Boolean} true, if the current focus is inside given node or nodes
3543
3590
  */
3544
- var focusInside = function focusInside(topNode) {
3545
- var activeElement = document && getActiveElement();
3591
+ var focusInside = function focusInside(topNode, activeElement) {
3592
+ // const activeElement = document && getActiveElement();
3593
+ if (activeElement === void 0) {
3594
+ activeElement = getActiveElement(getFirst(topNode).ownerDocument);
3595
+ }
3546
3596
  if (!activeElement || activeElement.dataset && activeElement.dataset.focusGuard) {
3547
3597
  return false;
3548
3598
  }
3549
3599
  return getAllAffectedNodes(topNode).some(function (node) {
3550
- return contains$1(node, activeElement) || focusInsideIframe(node);
3600
+ return contains$1(node, activeElement) || focusInsideIframe(node, activeElement);
3551
3601
  });
3552
3602
  };
3553
3603
 
@@ -3556,13 +3606,16 @@ var focusInside = function focusInside(topNode) {
3556
3606
  * ie contained inside a node focus-lock shall ignore
3557
3607
  * @returns {boolean} focus is currently is in "allow" area
3558
3608
  */
3559
- var focusIsHidden = function focusIsHidden() {
3560
- var activeElement = document && getActiveElement();
3609
+ var focusIsHidden = function focusIsHidden(inDocument) {
3610
+ if (inDocument === void 0) {
3611
+ inDocument = document;
3612
+ }
3613
+ var activeElement = getActiveElement(inDocument);
3561
3614
  if (!activeElement) {
3562
3615
  return false;
3563
3616
  }
3564
3617
  // this does not support setting FOCUS_ALLOW within shadow dom
3565
- return toArray(document.querySelectorAll("[".concat(FOCUS_ALLOW, "]"))).some(function (node) {
3618
+ return toArray(inDocument.querySelectorAll("[".concat(FOCUS_ALLOW, "]"))).some(function (node) {
3566
3619
  return contains$1(node, activeElement);
3567
3620
  });
3568
3621
  };
@@ -3780,7 +3833,7 @@ var reorderNodes = function reorderNodes(srcNodes, dstNodes) {
3780
3833
  * @param lastNode
3781
3834
  */
3782
3835
  var getFocusMerge = function getFocusMerge(topNode, lastNode) {
3783
- var activeElement = document && getActiveElement();
3836
+ var activeElement = getActiveElement(asArray(topNode).length > 0 ? document : getFirst(topNode).ownerDocument);
3784
3837
  var entries = getAllAffectedNodes(topNode).filter(isNotAGuard);
3785
3838
  var commonParent = getTopCommonParent(activeElement || topNode, topNode, entries);
3786
3839
  var visibilityCache = new Map();
@@ -3806,9 +3859,15 @@ var getFocusMerge = function getFocusMerge(topNode, lastNode) {
3806
3859
  });
3807
3860
  var newId = newFocus(innerNodes, outerNodes, activeElement, lastNode);
3808
3861
  if (newId === NEW_FOCUS) {
3809
- return {
3810
- node: pickAutofocus(anyFocusable, innerNodes, allParentAutofocusables(entries, visibilityCache))
3811
- };
3862
+ var focusNode = pickAutofocus(anyFocusable, innerNodes, allParentAutofocusables(entries, visibilityCache));
3863
+ if (focusNode) {
3864
+ return {
3865
+ node: focusNode
3866
+ };
3867
+ } else {
3868
+ console.warn('focus-lock: cannot find any node to move focus into');
3869
+ return undefined;
3870
+ }
3812
3871
  }
3813
3872
  if (newId === undefined) {
3814
3873
  return newId;
@@ -4315,6 +4374,7 @@ var elementCouldBeHScrolled = function elementCouldBeHScrolled(node) {
4315
4374
  return elementCanBeScrolled(node, 'overflowX');
4316
4375
  };
4317
4376
  var locationCouldBeScrolled = function locationCouldBeScrolled(axis, node) {
4377
+ var ownerDocument = node.ownerDocument;
4318
4378
  var current = node;
4319
4379
  do {
4320
4380
  // Skip over shadow root
@@ -4331,7 +4391,7 @@ var locationCouldBeScrolled = function locationCouldBeScrolled(axis, node) {
4331
4391
  }
4332
4392
  }
4333
4393
  current = current.parentNode;
4334
- } while (current && current !== document.body);
4394
+ } while (current && current !== ownerDocument.body);
4335
4395
  return false;
4336
4396
  };
4337
4397
  var getVScrollVariables = function getVScrollVariables(_a) {
@@ -4418,9 +4478,7 @@ function RemoveScrollSideCar(props) {
4418
4478
  var touchStartRef = React__namespace.useRef([0, 0]);
4419
4479
  var activeAxis = React__namespace.useRef();
4420
4480
  var id = React__namespace.useState(idCounter++)[0];
4421
- var Style = React__namespace.useState(function () {
4422
- return styleSingleton();
4423
- })[0];
4481
+ var Style = React__namespace.useState(styleSingleton)[0];
4424
4482
  var lastProps = React__namespace.useRef(props);
4425
4483
  React__namespace.useEffect(function () {
4426
4484
  lastProps.current = props;
@@ -4467,7 +4525,6 @@ function RemoveScrollSideCar(props) {
4467
4525
  canBeScrolledInMainDirection = locationCouldBeScrolled(moveDirection, target);
4468
4526
  // other axis might be not scrollable
4469
4527
  }
4470
-
4471
4528
  if (!canBeScrolledInMainDirection) {
4472
4529
  return false;
4473
4530
  }
@@ -4558,7 +4615,7 @@ function RemoveScrollSideCar(props) {
4558
4615
  return /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, null, inert ? /*#__PURE__*/React__namespace.createElement(Style, {
4559
4616
  styles: generateStyle(id)
4560
4617
  }) : null, removeScrollBar ? /*#__PURE__*/React__namespace.createElement(RemoveScrollBar, {
4561
- gapMode: "margin"
4618
+ gapMode: props.gapMode
4562
4619
  }) : null);
4563
4620
  }
4564
4621
 
@@ -5233,6 +5290,7 @@ function _curryN(length, received, fn) {
5233
5290
  var argsIdx = 0;
5234
5291
  var left = length;
5235
5292
  var combinedIdx = 0;
5293
+ var hasPlaceholder = false;
5236
5294
  while (combinedIdx < received.length || argsIdx < arguments.length) {
5237
5295
  var result;
5238
5296
  if (combinedIdx < received.length && (!_isPlaceholder(received[combinedIdx]) || argsIdx >= arguments.length)) {
@@ -5244,10 +5302,12 @@ function _curryN(length, received, fn) {
5244
5302
  combined[combinedIdx] = result;
5245
5303
  if (!_isPlaceholder(result)) {
5246
5304
  left -= 1;
5305
+ } else {
5306
+ hasPlaceholder = true;
5247
5307
  }
5248
5308
  combinedIdx += 1;
5249
5309
  }
5250
- return left <= 0 ? fn.apply(this, combined) : _arity(left, _curryN(length, combined, fn));
5310
+ return !hasPlaceholder && left <= 0 ? fn.apply(this, combined) : _arity(Math.max(0, left), _curryN(length, combined, fn));
5251
5311
  };
5252
5312
  }
5253
5313
 
@@ -5301,6 +5361,7 @@ _curry2(function curryN(length, fn) {
5301
5361
  }
5302
5362
  return _arity(length, _curryN(length, [], fn));
5303
5363
  });
5364
+ var curryN$1 = curryN;
5304
5365
 
5305
5366
  /**
5306
5367
  * Optimized internal three-arity curry function.
@@ -5459,15 +5520,16 @@ function _objectIs(a, b) {
5459
5520
  }
5460
5521
  var _objectIs$1 = typeof Object.is === 'function' ? Object.is : _objectIs;
5461
5522
 
5462
- var toString$1 = Object.prototype.toString;
5523
+ var toString$2 = Object.prototype.toString;
5463
5524
  var _isArguments = /*#__PURE__*/
5464
5525
  function () {
5465
- return toString$1.call(arguments) === '[object Arguments]' ? function _isArguments(x) {
5466
- return toString$1.call(x) === '[object Arguments]';
5526
+ return toString$2.call(arguments) === '[object Arguments]' ? function _isArguments(x) {
5527
+ return toString$2.call(x) === '[object Arguments]';
5467
5528
  } : function _isArguments(x) {
5468
5529
  return _has('callee', x);
5469
5530
  };
5470
5531
  }();
5532
+ var _isArguments$1 = _isArguments;
5471
5533
 
5472
5534
  var hasEnumBug = ! /*#__PURE__*/
5473
5535
  {
@@ -5519,7 +5581,7 @@ _curry1(function keys(obj) {
5519
5581
  }
5520
5582
  var prop, nIdx;
5521
5583
  var ks = [];
5522
- var checkArgsLength = hasArgsEnumBug && _isArguments(obj);
5584
+ var checkArgsLength = hasArgsEnumBug && _isArguments$1(obj);
5523
5585
  for (prop in obj) {
5524
5586
  if (_has(prop, obj) && (!checkArgsLength || prop !== 'length')) {
5525
5587
  ks[ks.length] = prop;
@@ -5537,6 +5599,7 @@ _curry1(function keys(obj) {
5537
5599
  }
5538
5600
  return ks;
5539
5601
  });
5602
+ var keys$1 = keys;
5540
5603
 
5541
5604
  /**
5542
5605
  * Gives a single-word string description of the (native) type of a value,
@@ -5561,6 +5624,7 @@ _curry1(function keys(obj) {
5561
5624
  * R.type([]); //=> "Array"
5562
5625
  * R.type(/[A-z]/); //=> "RegExp"
5563
5626
  * R.type(() => {}); //=> "Function"
5627
+ * R.type(async () => {}); //=> "AsyncFunction"
5564
5628
  * R.type(undefined); //=> "Undefined"
5565
5629
  */
5566
5630
 
@@ -5568,6 +5632,7 @@ var type = /*#__PURE__*/
5568
5632
  _curry1(function type(val) {
5569
5633
  return val === null ? 'Null' : val === undefined ? 'Undefined' : Object.prototype.toString.call(val).slice(8, -1);
5570
5634
  });
5635
+ var type$1 = type;
5571
5636
 
5572
5637
  /**
5573
5638
  * private _uniqContentEquals function.
@@ -5595,8 +5660,8 @@ function _equals(a, b, stackA, stackB) {
5595
5660
  if (_objectIs$1(a, b)) {
5596
5661
  return true;
5597
5662
  }
5598
- var typeA = type(a);
5599
- if (typeA !== type(b)) {
5663
+ var typeA = type$1(a);
5664
+ if (typeA !== type$1(b)) {
5600
5665
  return false;
5601
5666
  }
5602
5667
  if (typeof a['fantasy-land/equals'] === 'function' || typeof b['fantasy-land/equals'] === 'function') {
@@ -5675,8 +5740,8 @@ function _equals(a, b, stackA, stackB) {
5675
5740
  // Values of other types are only equal if identical.
5676
5741
  return false;
5677
5742
  }
5678
- var keysA = keys(a);
5679
- if (keysA.length !== keys(b).length) {
5743
+ var keysA = keys$1(a);
5744
+ if (keysA.length !== keys$1(b).length) {
5680
5745
  return false;
5681
5746
  }
5682
5747
  var extendedStackA = stackA.concat([a]);
@@ -5722,6 +5787,7 @@ var equals = /*#__PURE__*/
5722
5787
  _curry2(function equals(a, b) {
5723
5788
  return _equals(a, b, [], []);
5724
5789
  });
5790
+ var equals$1 = equals;
5725
5791
 
5726
5792
  function _indexOf(list, a, idx) {
5727
5793
  var inf, item; // Array.prototype.indexOf doesn't exist below IE9
@@ -5769,7 +5835,7 @@ function _indexOf(list, a, idx) {
5769
5835
  } // anything else not covered above, defer to R.equals
5770
5836
 
5771
5837
  while (idx < list.length) {
5772
- if (equals(list[idx], a)) {
5838
+ if (equals$1(list[idx], a)) {
5773
5839
  return idx;
5774
5840
  }
5775
5841
  idx += 1;
@@ -5809,6 +5875,7 @@ var _toISOString = typeof Date.prototype.toISOString === 'function' ? function _
5809
5875
  } : function _toISOString(d) {
5810
5876
  return d.getUTCFullYear() + '-' + pad(d.getUTCMonth() + 1) + '-' + pad(d.getUTCDate()) + 'T' + pad(d.getUTCHours()) + ':' + pad(d.getUTCMinutes()) + ':' + pad(d.getUTCSeconds()) + '.' + (d.getUTCMilliseconds() / 1000).toFixed(3).slice(2, 5) + 'Z';
5811
5877
  };
5878
+ var _toISOString$1 = _toISOString;
5812
5879
 
5813
5880
  function _complement(f) {
5814
5881
  return function () {
@@ -5899,10 +5966,11 @@ _dispatchable(['fantasy-land/filter', 'filter'], _xfilter, function (pred, filte
5899
5966
  acc[key] = filterable[key];
5900
5967
  }
5901
5968
  return acc;
5902
- }, {}, keys(filterable)) :
5969
+ }, {}, keys$1(filterable)) :
5903
5970
  // else
5904
5971
  _filter(pred, filterable);
5905
5972
  }));
5973
+ var filter$1 = filter;
5906
5974
 
5907
5975
  /**
5908
5976
  * The complement of [`filter`](#filter).
@@ -5931,8 +5999,9 @@ _dispatchable(['fantasy-land/filter', 'filter'], _xfilter, function (pred, filte
5931
5999
 
5932
6000
  var reject = /*#__PURE__*/
5933
6001
  _curry2(function reject(pred, filterable) {
5934
- return filter(_complement(pred), filterable);
6002
+ return filter$1(_complement(pred), filterable);
5935
6003
  });
6004
+ var reject$1 = reject;
5936
6005
 
5937
6006
  function _toString(x, seen) {
5938
6007
  var recur = function recur(y) {
@@ -5949,13 +6018,13 @@ function _toString(x, seen) {
5949
6018
  case '[object Arguments]':
5950
6019
  return '(function() { return arguments; }(' + _map(recur, x).join(', ') + '))';
5951
6020
  case '[object Array]':
5952
- return '[' + _map(recur, x).concat(mapPairs(x, reject(function (k) {
6021
+ return '[' + _map(recur, x).concat(mapPairs(x, reject$1(function (k) {
5953
6022
  return /^\d+$/.test(k);
5954
- }, keys(x)))).join(', ') + ']';
6023
+ }, keys$1(x)))).join(', ') + ']';
5955
6024
  case '[object Boolean]':
5956
6025
  return _typeof$1(x) === 'object' ? 'new Boolean(' + recur(x.valueOf()) + ')' : x.toString();
5957
6026
  case '[object Date]':
5958
- return 'new Date(' + (isNaN(x.valueOf()) ? recur(NaN) : _quote(_toISOString(x))) + ')';
6027
+ return 'new Date(' + (isNaN(x.valueOf()) ? recur(NaN) : _quote(_toISOString$1(x))) + ')';
5959
6028
  case '[object Map]':
5960
6029
  return 'new Map(' + recur(Array.from(x)) + ')';
5961
6030
  case '[object Null]':
@@ -5975,7 +6044,7 @@ function _toString(x, seen) {
5975
6044
  return repr;
5976
6045
  }
5977
6046
  }
5978
- return '{' + mapPairs(x, keys(x)).join(', ') + '}';
6047
+ return '{' + mapPairs(x, keys$1(x)).join(', ') + '}';
5979
6048
  }
5980
6049
  }
5981
6050
 
@@ -6020,6 +6089,7 @@ var toString = /*#__PURE__*/
6020
6089
  _curry1(function toString(val) {
6021
6090
  return _toString(val, []);
6022
6091
  });
6092
+ var toString$1 = toString;
6023
6093
 
6024
6094
  /**
6025
6095
  * Returns the larger of its two arguments.
@@ -6058,13 +6128,14 @@ _curry2(function max(a, b) {
6058
6128
  if (maxByType !== undefined) {
6059
6129
  return maxByType === _typeof$1(a) ? a : b;
6060
6130
  }
6061
- var stringA = toString(a);
6062
- var maxByStringValue = safeMax(stringA, toString(b));
6131
+ var stringA = toString$1(a);
6132
+ var maxByStringValue = safeMax(stringA, toString$1(b));
6063
6133
  if (maxByStringValue !== undefined) {
6064
6134
  return maxByStringValue === stringA ? a : b;
6065
6135
  }
6066
6136
  return b;
6067
6137
  });
6138
+ var max$1 = max;
6068
6139
 
6069
6140
  var XMap = /*#__PURE__*/
6070
6141
  function () {
@@ -6084,6 +6155,7 @@ var _xmap = function _xmap(f) {
6084
6155
  return new XMap(f, xf);
6085
6156
  };
6086
6157
  };
6158
+ var _xmap$1 = _xmap;
6087
6159
 
6088
6160
  /**
6089
6161
  * Takes a function and
@@ -6123,21 +6195,22 @@ var _xmap = function _xmap(f) {
6123
6195
 
6124
6196
  var map = /*#__PURE__*/
6125
6197
  _curry2( /*#__PURE__*/
6126
- _dispatchable(['fantasy-land/map', 'map'], _xmap, function map(fn, functor) {
6198
+ _dispatchable(['fantasy-land/map', 'map'], _xmap$1, function map(fn, functor) {
6127
6199
  switch (Object.prototype.toString.call(functor)) {
6128
6200
  case '[object Function]':
6129
- return curryN(functor.length, function () {
6201
+ return curryN$1(functor.length, function () {
6130
6202
  return fn.call(this, functor.apply(this, arguments));
6131
6203
  });
6132
6204
  case '[object Object]':
6133
6205
  return _arrayReduce(function (acc, key) {
6134
6206
  acc[key] = fn(functor[key]);
6135
6207
  return acc;
6136
- }, {}, keys(functor));
6208
+ }, {}, keys$1(functor));
6137
6209
  default:
6138
6210
  return _map(fn, functor);
6139
6211
  }
6140
6212
  }));
6213
+ var map$1 = map;
6141
6214
 
6142
6215
  function _isString(x) {
6143
6216
  return Object.prototype.toString.call(x) === '[object String]';
@@ -6184,11 +6257,12 @@ _curry1(function isArrayLike(x) {
6184
6257
  }
6185
6258
  return false;
6186
6259
  });
6260
+ var _isArrayLike$1 = _isArrayLike;
6187
6261
 
6188
6262
  var symIterator = typeof Symbol !== 'undefined' ? Symbol.iterator : '@@iterator';
6189
6263
  function _createReduce(arrayReduce, methodReduce, iterableReduce) {
6190
6264
  return function _reduce(xf, acc, list) {
6191
- if (_isArrayLike(list)) {
6265
+ if (_isArrayLike$1(list)) {
6192
6266
  return arrayReduce(xf, acc, list);
6193
6267
  }
6194
6268
  if (list == null) {
@@ -6253,6 +6327,7 @@ _curry2(function bind(fn, thisObj) {
6253
6327
  return fn.apply(thisObj, arguments);
6254
6328
  });
6255
6329
  });
6330
+ var bind$1 = bind;
6256
6331
 
6257
6332
  function _xIterableReduce(xf, acc, iter) {
6258
6333
  var step = iter.next();
@@ -6267,10 +6342,11 @@ function _xIterableReduce(xf, acc, iter) {
6267
6342
  return xf['@@transducer/result'](acc);
6268
6343
  }
6269
6344
  function _xMethodReduce(xf, acc, obj, methodName) {
6270
- return xf['@@transducer/result'](obj[methodName](bind(xf['@@transducer/step'], xf), acc));
6345
+ return xf['@@transducer/result'](obj[methodName](bind$1(xf['@@transducer/step'], xf), acc));
6271
6346
  }
6272
6347
  var _xReduce = /*#__PURE__*/
6273
6348
  _createReduce(_xArrayReduce, _xMethodReduce, _xIterableReduce);
6349
+ var _xReduce$1 = _xReduce;
6274
6350
 
6275
6351
  var XWrap = /*#__PURE__*/
6276
6352
  function () {
@@ -6347,8 +6423,9 @@ function _xwrap(fn) {
6347
6423
 
6348
6424
  var reduce = /*#__PURE__*/
6349
6425
  _curry3(function (xf, acc, list) {
6350
- return _xReduce(typeof xf === 'function' ? _xwrap(xf) : xf, acc, list);
6426
+ return _xReduce$1(typeof xf === 'function' ? _xwrap(xf) : xf, acc, list);
6351
6427
  });
6428
+ var reduce$1 = reduce;
6352
6429
 
6353
6430
  function _identity(x) {
6354
6431
  return x;
@@ -6376,6 +6453,7 @@ function _identity(x) {
6376
6453
 
6377
6454
  var identity = /*#__PURE__*/
6378
6455
  _curry1(_identity);
6456
+ var identity$1 = identity;
6379
6457
 
6380
6458
  /**
6381
6459
  * Returns a function, `fn`, which encapsulates `if/else, if/else, ...` logic.
@@ -6411,7 +6489,7 @@ _curry1(_identity);
6411
6489
 
6412
6490
  var cond = /*#__PURE__*/
6413
6491
  _curry1(function cond(pairs) {
6414
- var arity = reduce(max, 0, map(function (pair) {
6492
+ var arity = reduce$1(max$1, 0, map$1(function (pair) {
6415
6493
  return pair[0].length;
6416
6494
  }, pairs));
6417
6495
  return _arity(arity, function () {
@@ -6591,12 +6669,14 @@ function hasOrAdd(item, shouldAdd, set) {
6591
6669
  }
6592
6670
  } // A simple Set type that honours R.equals semantics
6593
6671
 
6672
+ var _Set$1 = _Set;
6673
+
6594
6674
  var XUniqBy = /*#__PURE__*/
6595
6675
  function () {
6596
6676
  function XUniqBy(f, xf) {
6597
6677
  this.xf = xf;
6598
6678
  this.f = f;
6599
- this.set = new _Set();
6679
+ this.set = new _Set$1();
6600
6680
  }
6601
6681
  XUniqBy.prototype['@@transducer/init'] = _xfBase.init;
6602
6682
  XUniqBy.prototype['@@transducer/result'] = _xfBase.result;
@@ -6635,7 +6715,7 @@ function _xuniqBy(f) {
6635
6715
  var uniqBy = /*#__PURE__*/
6636
6716
  _curry2( /*#__PURE__*/
6637
6717
  _dispatchable([], _xuniqBy, function (fn, list) {
6638
- var set = new _Set();
6718
+ var set = new _Set$1();
6639
6719
  var result = [];
6640
6720
  var idx = 0;
6641
6721
  var appliedItem, item;
@@ -6670,7 +6750,7 @@ var uniqBy$1 = uniqBy;
6670
6750
  */
6671
6751
 
6672
6752
  var uniq = /*#__PURE__*/
6673
- uniqBy$1(identity);
6753
+ uniqBy$1(identity$1);
6674
6754
  var uniq$1 = uniq;
6675
6755
 
6676
6756
  function _isNumber(x) {
@@ -7183,239 +7263,513 @@ var ExceedConstrain = function ExceedConstrain(_ref) {
7183
7263
 
7184
7264
  var reactInputMask = {exports: {}};
7185
7265
 
7186
- var reactInputMask_production_min;
7187
- var hasRequiredReactInputMask_production_min;
7188
- function requireReactInputMask_production_min() {
7189
- if (hasRequiredReactInputMask_production_min) return reactInputMask_production_min;
7190
- hasRequiredReactInputMask_production_min = 1;
7191
- function _interopDefault(e) {
7192
- return e && "object" == _typeof$1(e) && "default" in e ? e["default"] : e;
7193
- }
7194
- var React$1 = _interopDefault(React),
7195
- reactDom = require$$1;
7196
- function _defaults2(e, t) {
7197
- for (var n = Object.getOwnPropertyNames(t), a = 0; a < n.length; a++) {
7198
- var i = n[a],
7199
- r = Object.getOwnPropertyDescriptor(t, i);
7200
- r && r.configurable && e[i] === undefined && Object.defineProperty(e, i, r);
7266
+ /**
7267
+ * Copyright (c) 2013-present, Facebook, Inc.
7268
+ *
7269
+ * This source code is licensed under the MIT license found in the
7270
+ * LICENSE file in the root directory of this source tree.
7271
+ */
7272
+ var invariant_1;
7273
+ var hasRequiredInvariant;
7274
+ function requireInvariant() {
7275
+ if (hasRequiredInvariant) return invariant_1;
7276
+ hasRequiredInvariant = 1;
7277
+
7278
+ /**
7279
+ * Use invariant() to assert state which your program assumes to be true.
7280
+ *
7281
+ * Provide sprintf-style format (only %s is supported) and arguments
7282
+ * to provide information about what broke and what you were
7283
+ * expecting.
7284
+ *
7285
+ * The invariant message will be stripped in production, but the invariant
7286
+ * will remain to ensure logic does not differ in production.
7287
+ */
7288
+
7289
+ var NODE_ENV = process.env.NODE_ENV;
7290
+ var invariant = function invariant(condition, format, a, b, c, d, e, f) {
7291
+ if (NODE_ENV !== 'production') {
7292
+ if (format === undefined) {
7293
+ throw new Error('invariant requires an error message argument');
7294
+ }
7201
7295
  }
7202
- return e;
7203
- }
7204
- function _extends() {
7205
- return (_extends = Object.assign || function (e) {
7206
- for (var t = 1; t < arguments.length; t++) {
7207
- var n = arguments[t];
7208
- for (var a in n) Object.prototype.hasOwnProperty.call(n, a) && (e[a] = n[a]);
7296
+ if (!condition) {
7297
+ var error;
7298
+ if (format === undefined) {
7299
+ error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.');
7300
+ } else {
7301
+ var args = [a, b, c, d, e, f];
7302
+ var argIndex = 0;
7303
+ error = new Error(format.replace(/%s/g, function () {
7304
+ return args[argIndex++];
7305
+ }));
7306
+ error.name = 'Invariant Violation';
7209
7307
  }
7210
- return e;
7211
- }).apply(this, arguments);
7212
- }
7213
- function _inheritsLoose(e, t) {
7214
- e.prototype = Object.create(t.prototype), _defaults2(e.prototype.constructor = e, t);
7308
+ error.framesToPop = 1; // we don't care about invariant's own frame
7309
+ throw error;
7310
+ }
7311
+ };
7312
+ invariant_1 = invariant;
7313
+ return invariant_1;
7314
+ }
7315
+
7316
+ /**
7317
+ * Copyright (c) 2014-present, Facebook, Inc.
7318
+ *
7319
+ * This source code is licensed under the MIT license found in the
7320
+ * LICENSE file in the root directory of this source tree.
7321
+ */
7322
+ var warning_1;
7323
+ var hasRequiredWarning;
7324
+ function requireWarning() {
7325
+ if (hasRequiredWarning) return warning_1;
7326
+ hasRequiredWarning = 1;
7327
+
7328
+ /**
7329
+ * Similar to invariant but only logs a warning if the condition is not met.
7330
+ * This can be used to log issues in development environments in critical
7331
+ * paths. Removing the logging code for production environments will keep the
7332
+ * same logic and follow the same code paths.
7333
+ */
7334
+
7335
+ var __DEV__ = process.env.NODE_ENV !== 'production';
7336
+ var warning = function warning() {};
7337
+ if (__DEV__) {
7338
+ var printWarning = function printWarning(format, args) {
7339
+ var len = arguments.length;
7340
+ args = new Array(len > 1 ? len - 1 : 0);
7341
+ for (var key = 1; key < len; key++) {
7342
+ args[key - 1] = arguments[key];
7343
+ }
7344
+ var argIndex = 0;
7345
+ var message = 'Warning: ' + format.replace(/%s/g, function () {
7346
+ return args[argIndex++];
7347
+ });
7348
+ if (typeof console !== 'undefined') {
7349
+ console.error(message);
7350
+ }
7351
+ try {
7352
+ // --- Welcome to debugging React ---
7353
+ // This error was thrown as a convenience so that you can use this stack
7354
+ // to find the callsite that caused this warning to fire.
7355
+ throw new Error(message);
7356
+ } catch (x) {}
7357
+ };
7358
+ warning = function warning(condition, format, args) {
7359
+ var len = arguments.length;
7360
+ args = new Array(len > 2 ? len - 2 : 0);
7361
+ for (var key = 2; key < len; key++) {
7362
+ args[key - 2] = arguments[key];
7363
+ }
7364
+ if (format === undefined) {
7365
+ throw new Error('`warning(condition, format, ...args)` requires a warning ' + 'message argument');
7366
+ }
7367
+ if (!condition) {
7368
+ printWarning.apply(null, [format].concat(args));
7369
+ }
7370
+ };
7215
7371
  }
7216
- function _objectWithoutPropertiesLoose(e, t) {
7217
- if (null == e) return {};
7218
- var n,
7219
- a,
7220
- i = {},
7221
- r = Object.keys(e);
7222
- for (a = 0; a < r.length; a++) n = r[a], 0 <= t.indexOf(n) || (i[n] = e[n]);
7223
- return i;
7372
+ warning_1 = warning;
7373
+ return warning_1;
7374
+ }
7375
+
7376
+ var reactInputMask_development;
7377
+ var hasRequiredReactInputMask_development;
7378
+ function requireReactInputMask_development() {
7379
+ if (hasRequiredReactInputMask_development) return reactInputMask_development;
7380
+ hasRequiredReactInputMask_development = 1;
7381
+ function _interopDefault(ex) {
7382
+ return ex && _typeof$1(ex) === 'object' && 'default' in ex ? ex['default'] : ex;
7224
7383
  }
7225
- function _assertThisInitialized(e) {
7226
- if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
7227
- return e;
7384
+ var React$1 = _interopDefault(React);
7385
+ var reactDom = require$$1;
7386
+ var invariant = _interopDefault(requireInvariant());
7387
+ var warning = _interopDefault(requireWarning());
7388
+ function _defaults2(obj, defaults) {
7389
+ var keys = Object.getOwnPropertyNames(defaults);
7390
+ for (var i = 0; i < keys.length; i++) {
7391
+ var key = keys[i];
7392
+ var value = Object.getOwnPropertyDescriptor(defaults, key);
7393
+ if (value && value.configurable && obj[key] === undefined) {
7394
+ Object.defineProperty(obj, key, value);
7395
+ }
7396
+ }
7397
+ return obj;
7228
7398
  }
7229
- var invariant = function invariant(e, t, n, a, i, r, o, s) {
7230
- if (!e) {
7231
- var l;
7232
- if (t === undefined) l = new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else {
7233
- var u = [n, a, i, r, o, s],
7234
- c = 0;
7235
- (l = new Error(t.replace(/%s/g, function () {
7236
- return u[c++];
7237
- }))).name = "Invariant Violation";
7399
+ function _extends() {
7400
+ _extends = Object.assign || function (target) {
7401
+ for (var i = 1; i < arguments.length; i++) {
7402
+ var source = arguments[i];
7403
+ for (var key in source) {
7404
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
7405
+ target[key] = source[key];
7406
+ }
7238
7407
  }
7239
- throw l.framesToPop = 1, l;
7240
7408
  }
7241
- },
7242
- invariant_1 = invariant;
7243
- function setInputSelection(e, t, n) {
7244
- if ("selectionStart" in e && "selectionEnd" in e) e.selectionStart = t, e.selectionEnd = n;else {
7245
- var a = e.createTextRange();
7246
- a.collapse(!0), a.moveStart("character", t), a.moveEnd("character", n - t), a.select();
7409
+ return target;
7410
+ };
7411
+ return _extends.apply(this, arguments);
7412
+ }
7413
+ function _inheritsLoose(subClass, superClass) {
7414
+ subClass.prototype = Object.create(superClass.prototype);
7415
+ subClass.prototype.constructor = subClass;
7416
+ _defaults2(subClass, superClass);
7417
+ }
7418
+ function _objectWithoutPropertiesLoose(source, excluded) {
7419
+ if (source == null) return {};
7420
+ var target = {};
7421
+ var sourceKeys = Object.keys(source);
7422
+ var key, i;
7423
+ for (i = 0; i < sourceKeys.length; i++) {
7424
+ key = sourceKeys[i];
7425
+ if (excluded.indexOf(key) >= 0) continue;
7426
+ target[key] = source[key];
7247
7427
  }
7428
+ return target;
7248
7429
  }
7249
- function getInputSelection(e) {
7250
- var t = 0,
7251
- n = 0;
7252
- if ("selectionStart" in e && "selectionEnd" in e) t = e.selectionStart, n = e.selectionEnd;else {
7253
- var a = document.selection.createRange();
7254
- a.parentElement() === e && (t = -a.moveStart("character", -e.value.length), n = -a.moveEnd("character", -e.value.length));
7430
+ function _assertThisInitialized(self) {
7431
+ if (self === void 0) {
7432
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
7255
7433
  }
7256
- return {
7257
- start: t,
7258
- end: n,
7259
- length: n - t
7260
- };
7434
+ return self;
7261
7435
  }
7262
- var defaultFormatChars = {
7263
- 9: "[0-9]",
7264
- a: "[A-Za-z]",
7265
- "*": "[A-Za-z0-9]"
7266
- },
7267
- defaultMaskChar = "_";
7268
- function parseMask(e, t, n) {
7269
- var a = "",
7270
- i = "",
7271
- r = null,
7272
- o = [];
7273
- if (t === undefined && (t = defaultMaskChar), null == n && (n = defaultFormatChars), !e || "string" != typeof e) return {
7274
- maskChar: t,
7275
- formatChars: n,
7276
- mask: null,
7277
- prefix: null,
7278
- lastEditablePosition: null,
7279
- permanents: []
7436
+ function setInputSelection(input, start, end) {
7437
+ if ('selectionStart' in input && 'selectionEnd' in input) {
7438
+ input.selectionStart = start;
7439
+ input.selectionEnd = end;
7440
+ } else {
7441
+ var range = input.createTextRange();
7442
+ range.collapse(true);
7443
+ range.moveStart('character', start);
7444
+ range.moveEnd('character', end - start);
7445
+ range.select();
7446
+ }
7447
+ }
7448
+ function getInputSelection(input) {
7449
+ var start = 0;
7450
+ var end = 0;
7451
+ if ('selectionStart' in input && 'selectionEnd' in input) {
7452
+ start = input.selectionStart;
7453
+ end = input.selectionEnd;
7454
+ } else {
7455
+ var range = document.selection.createRange();
7456
+ if (range.parentElement() === input) {
7457
+ start = -range.moveStart('character', -input.value.length);
7458
+ end = -range.moveEnd('character', -input.value.length);
7459
+ }
7460
+ }
7461
+ return {
7462
+ start: start,
7463
+ end: end,
7464
+ length: end - start
7280
7465
  };
7281
- var s = !1;
7282
- return e.split("").forEach(function (e) {
7283
- s = !s && "\\" === e || (s || !n[e] ? (o.push(a.length), a.length === o.length - 1 && (i += e)) : r = a.length + 1, a += e, !1);
7284
- }), {
7285
- maskChar: t,
7286
- formatChars: n,
7287
- prefix: i,
7288
- mask: a,
7289
- lastEditablePosition: r,
7290
- permanents: o
7466
+ }
7467
+ var defaultFormatChars = {
7468
+ '9': '[0-9]',
7469
+ 'a': '[A-Za-z]',
7470
+ '*': '[A-Za-z0-9]'
7471
+ };
7472
+ var defaultMaskChar = '_';
7473
+ function parseMask(mask, maskChar, formatChars) {
7474
+ var parsedMaskString = '';
7475
+ var prefix = '';
7476
+ var lastEditablePosition = null;
7477
+ var permanents = [];
7478
+ if (maskChar === undefined) {
7479
+ maskChar = defaultMaskChar;
7480
+ }
7481
+ if (formatChars == null) {
7482
+ formatChars = defaultFormatChars;
7483
+ }
7484
+ if (!mask || typeof mask !== 'string') {
7485
+ return {
7486
+ maskChar: maskChar,
7487
+ formatChars: formatChars,
7488
+ mask: null,
7489
+ prefix: null,
7490
+ lastEditablePosition: null,
7491
+ permanents: []
7492
+ };
7493
+ }
7494
+ var isPermanent = false;
7495
+ mask.split('').forEach(function (character) {
7496
+ if (!isPermanent && character === '\\') {
7497
+ isPermanent = true;
7498
+ } else {
7499
+ if (isPermanent || !formatChars[character]) {
7500
+ permanents.push(parsedMaskString.length);
7501
+ if (parsedMaskString.length === permanents.length - 1) {
7502
+ prefix += character;
7503
+ }
7504
+ } else {
7505
+ lastEditablePosition = parsedMaskString.length + 1;
7506
+ }
7507
+ parsedMaskString += character;
7508
+ isPermanent = false;
7509
+ }
7510
+ });
7511
+ return {
7512
+ maskChar: maskChar,
7513
+ formatChars: formatChars,
7514
+ prefix: prefix,
7515
+ mask: parsedMaskString,
7516
+ lastEditablePosition: lastEditablePosition,
7517
+ permanents: permanents
7291
7518
  };
7292
7519
  }
7293
- function isPermanentCharacter(e, t) {
7294
- return -1 !== e.permanents.indexOf(t);
7520
+
7521
+ /* eslint no-use-before-define: ["error", { functions: false }] */
7522
+ function isPermanentCharacter(maskOptions, pos) {
7523
+ return maskOptions.permanents.indexOf(pos) !== -1;
7295
7524
  }
7296
- function isAllowedCharacter(e, t, n) {
7297
- var a = e.mask,
7298
- i = e.formatChars;
7299
- if (!n) return !1;
7300
- if (isPermanentCharacter(e, t)) return a[t] === n;
7301
- var r = i[a[t]];
7302
- return new RegExp(r).test(n);
7525
+ function isAllowedCharacter(maskOptions, pos, character) {
7526
+ var mask = maskOptions.mask,
7527
+ formatChars = maskOptions.formatChars;
7528
+ if (!character) {
7529
+ return false;
7530
+ }
7531
+ if (isPermanentCharacter(maskOptions, pos)) {
7532
+ return mask[pos] === character;
7533
+ }
7534
+ var ruleChar = mask[pos];
7535
+ var charRule = formatChars[ruleChar];
7536
+ return new RegExp(charRule).test(character);
7303
7537
  }
7304
- function isEmpty(n, e) {
7305
- return e.split("").every(function (e, t) {
7306
- return isPermanentCharacter(n, t) || !isAllowedCharacter(n, t, e);
7538
+ function isEmpty(maskOptions, value) {
7539
+ return value.split('').every(function (character, i) {
7540
+ return isPermanentCharacter(maskOptions, i) || !isAllowedCharacter(maskOptions, i, character);
7307
7541
  });
7308
7542
  }
7309
- function getFilledLength(e, t) {
7310
- var n = e.maskChar,
7311
- a = e.prefix;
7312
- if (!n) {
7313
- for (; t.length > a.length && isPermanentCharacter(e, t.length - 1);) t = t.slice(0, t.length - 1);
7314
- return t.length;
7543
+ function getFilledLength(maskOptions, value) {
7544
+ var maskChar = maskOptions.maskChar,
7545
+ prefix = maskOptions.prefix;
7546
+ if (!maskChar) {
7547
+ while (value.length > prefix.length && isPermanentCharacter(maskOptions, value.length - 1)) {
7548
+ value = value.slice(0, value.length - 1);
7549
+ }
7550
+ return value.length;
7315
7551
  }
7316
- for (var i = a.length, r = t.length; r >= a.length; r--) {
7317
- var o = t[r];
7318
- if (!isPermanentCharacter(e, r) && isAllowedCharacter(e, r, o)) {
7319
- i = r + 1;
7552
+ var filledLength = prefix.length;
7553
+ for (var i = value.length; i >= prefix.length; i--) {
7554
+ var character = value[i];
7555
+ var isEnteredCharacter = !isPermanentCharacter(maskOptions, i) && isAllowedCharacter(maskOptions, i, character);
7556
+ if (isEnteredCharacter) {
7557
+ filledLength = i + 1;
7320
7558
  break;
7321
7559
  }
7322
7560
  }
7323
- return i;
7561
+ return filledLength;
7324
7562
  }
7325
- function isFilled(e, t) {
7326
- return getFilledLength(e, t) === e.mask.length;
7563
+ function isFilled(maskOptions, value) {
7564
+ return getFilledLength(maskOptions, value) === maskOptions.mask.length;
7327
7565
  }
7328
- function formatValue(e, t) {
7329
- var n = e.maskChar,
7330
- a = e.mask,
7331
- i = e.prefix;
7332
- if (!n) {
7333
- for ((t = insertString(e, "", t, 0)).length < i.length && (t = i); t.length < a.length && isPermanentCharacter(e, t.length);) t += a[t.length];
7334
- return t;
7566
+ function formatValue(maskOptions, value) {
7567
+ var maskChar = maskOptions.maskChar,
7568
+ mask = maskOptions.mask,
7569
+ prefix = maskOptions.prefix;
7570
+ if (!maskChar) {
7571
+ value = insertString(maskOptions, '', value, 0);
7572
+ if (value.length < prefix.length) {
7573
+ value = prefix;
7574
+ }
7575
+ while (value.length < mask.length && isPermanentCharacter(maskOptions, value.length)) {
7576
+ value += mask[value.length];
7577
+ }
7578
+ return value;
7335
7579
  }
7336
- if (t) return insertString(e, formatValue(e, ""), t, 0);
7337
- for (var r = 0; r < a.length; r++) isPermanentCharacter(e, r) ? t += a[r] : t += n;
7338
- return t;
7339
- }
7340
- function clearRange(n, e, a, t) {
7341
- var i = a + t,
7342
- r = n.maskChar,
7343
- o = n.mask,
7344
- s = n.prefix,
7345
- l = e.split("");
7346
- if (r) return l.map(function (e, t) {
7347
- return t < a || i <= t ? e : isPermanentCharacter(n, t) ? o[t] : r;
7348
- }).join("");
7349
- for (var u = i; u < l.length; u++) isPermanentCharacter(n, u) && (l[u] = "");
7350
- return a = Math.max(s.length, a), l.splice(a, i - a), e = l.join(""), formatValue(n, e);
7580
+ if (value) {
7581
+ var emptyValue = formatValue(maskOptions, '');
7582
+ return insertString(maskOptions, emptyValue, value, 0);
7583
+ }
7584
+ for (var i = 0; i < mask.length; i++) {
7585
+ if (isPermanentCharacter(maskOptions, i)) {
7586
+ value += mask[i];
7587
+ } else {
7588
+ value += maskChar;
7589
+ }
7590
+ }
7591
+ return value;
7351
7592
  }
7352
- function insertString(r, o, e, s) {
7353
- var l = r.mask,
7354
- u = r.maskChar,
7355
- c = r.prefix,
7356
- t = e.split(""),
7357
- h = isFilled(r, o);
7358
- return !u && s > o.length && (o += l.slice(o.length, s)), t.every(function (e) {
7359
- for (; i = e, isPermanentCharacter(r, a = s) && i !== l[a];) {
7360
- if (s >= o.length && (o += l[s]), t = e, n = s, u && isPermanentCharacter(r, n) && t === u) return !0;
7361
- if (++s >= l.length) return !1;
7593
+ function clearRange(maskOptions, value, start, len) {
7594
+ var end = start + len;
7595
+ var maskChar = maskOptions.maskChar,
7596
+ mask = maskOptions.mask,
7597
+ prefix = maskOptions.prefix;
7598
+ var arrayValue = value.split('');
7599
+ if (!maskChar) {
7600
+ // remove any permanent chars after clear range, they will be added back by formatValue
7601
+ for (var i = end; i < arrayValue.length; i++) {
7602
+ if (isPermanentCharacter(maskOptions, i)) {
7603
+ arrayValue[i] = '';
7604
+ }
7362
7605
  }
7363
- var t, n, a, i;
7364
- return !isAllowedCharacter(r, s, e) && e !== u || (s < o.length ? o = u || h || s < c.length ? o.slice(0, s) + e + o.slice(s + 1) : (o = o.slice(0, s) + e + o.slice(s), formatValue(r, o)) : u || (o += e), ++s < l.length);
7365
- }), o;
7606
+ start = Math.max(prefix.length, start);
7607
+ arrayValue.splice(start, end - start);
7608
+ value = arrayValue.join('');
7609
+ return formatValue(maskOptions, value);
7610
+ }
7611
+ return arrayValue.map(function (character, i) {
7612
+ if (i < start || i >= end) {
7613
+ return character;
7614
+ }
7615
+ if (isPermanentCharacter(maskOptions, i)) {
7616
+ return mask[i];
7617
+ }
7618
+ return maskChar;
7619
+ }).join('');
7366
7620
  }
7367
- function getInsertStringLength(a, e, t, i) {
7368
- var r = a.mask,
7369
- o = a.maskChar,
7370
- n = t.split(""),
7371
- s = i;
7372
- return n.every(function (e) {
7373
- for (; n = e, isPermanentCharacter(a, t = i) && n !== r[t];) if (++i >= r.length) return !1;
7374
- var t, n;
7375
- return (isAllowedCharacter(a, i, e) || e === o) && i++, i < r.length;
7376
- }), i - s;
7621
+ function insertString(maskOptions, value, insertStr, insertPosition) {
7622
+ var mask = maskOptions.mask,
7623
+ maskChar = maskOptions.maskChar,
7624
+ prefix = maskOptions.prefix;
7625
+ var arrayInsertStr = insertStr.split('');
7626
+ var isInputFilled = isFilled(maskOptions, value);
7627
+ var isUsablePosition = function isUsablePosition(pos, character) {
7628
+ return !isPermanentCharacter(maskOptions, pos) || character === mask[pos];
7629
+ };
7630
+ var isUsableCharacter = function isUsableCharacter(character, pos) {
7631
+ return !maskChar || !isPermanentCharacter(maskOptions, pos) || character !== maskChar;
7632
+ };
7633
+ if (!maskChar && insertPosition > value.length) {
7634
+ value += mask.slice(value.length, insertPosition);
7635
+ }
7636
+ arrayInsertStr.every(function (insertCharacter) {
7637
+ while (!isUsablePosition(insertPosition, insertCharacter)) {
7638
+ if (insertPosition >= value.length) {
7639
+ value += mask[insertPosition];
7640
+ }
7641
+ if (!isUsableCharacter(insertCharacter, insertPosition)) {
7642
+ return true;
7643
+ }
7644
+ insertPosition++; // stop iteration if maximum value length reached
7645
+
7646
+ if (insertPosition >= mask.length) {
7647
+ return false;
7648
+ }
7649
+ }
7650
+ var isAllowed = isAllowedCharacter(maskOptions, insertPosition, insertCharacter) || insertCharacter === maskChar;
7651
+ if (!isAllowed) {
7652
+ return true;
7653
+ }
7654
+ if (insertPosition < value.length) {
7655
+ if (maskChar || isInputFilled || insertPosition < prefix.length) {
7656
+ value = value.slice(0, insertPosition) + insertCharacter + value.slice(insertPosition + 1);
7657
+ } else {
7658
+ value = value.slice(0, insertPosition) + insertCharacter + value.slice(insertPosition);
7659
+ value = formatValue(maskOptions, value);
7660
+ }
7661
+ } else if (!maskChar) {
7662
+ value += insertCharacter;
7663
+ }
7664
+ insertPosition++; // stop iteration if maximum value length reached
7665
+
7666
+ return insertPosition < mask.length;
7667
+ });
7668
+ return value;
7377
7669
  }
7378
- function getLeftEditablePosition(e, t) {
7379
- for (var n = t; 0 <= n; --n) if (!isPermanentCharacter(e, n)) return n;
7670
+ function getInsertStringLength(maskOptions, value, insertStr, insertPosition) {
7671
+ var mask = maskOptions.mask,
7672
+ maskChar = maskOptions.maskChar;
7673
+ var arrayInsertStr = insertStr.split('');
7674
+ var initialInsertPosition = insertPosition;
7675
+ var isUsablePosition = function isUsablePosition(pos, character) {
7676
+ return !isPermanentCharacter(maskOptions, pos) || character === mask[pos];
7677
+ };
7678
+ arrayInsertStr.every(function (insertCharacter) {
7679
+ while (!isUsablePosition(insertPosition, insertCharacter)) {
7680
+ insertPosition++; // stop iteration if maximum value length reached
7681
+
7682
+ if (insertPosition >= mask.length) {
7683
+ return false;
7684
+ }
7685
+ }
7686
+ var isAllowed = isAllowedCharacter(maskOptions, insertPosition, insertCharacter) || insertCharacter === maskChar;
7687
+ if (isAllowed) {
7688
+ insertPosition++;
7689
+ } // stop iteration if maximum value length reached
7690
+
7691
+ return insertPosition < mask.length;
7692
+ });
7693
+ return insertPosition - initialInsertPosition;
7694
+ }
7695
+ function getLeftEditablePosition(maskOptions, pos) {
7696
+ for (var i = pos; i >= 0; --i) {
7697
+ if (!isPermanentCharacter(maskOptions, i)) {
7698
+ return i;
7699
+ }
7700
+ }
7380
7701
  return null;
7381
7702
  }
7382
- function getRightEditablePosition(e, t) {
7383
- for (var n = e.mask, a = t; a < n.length; ++a) if (!isPermanentCharacter(e, a)) return a;
7703
+ function getRightEditablePosition(maskOptions, pos) {
7704
+ var mask = maskOptions.mask;
7705
+ for (var i = pos; i < mask.length; ++i) {
7706
+ if (!isPermanentCharacter(maskOptions, i)) {
7707
+ return i;
7708
+ }
7709
+ }
7384
7710
  return null;
7385
7711
  }
7386
- function getStringValue(e) {
7387
- return e || 0 === e ? e + "" : "";
7712
+ function getStringValue(value) {
7713
+ return !value && value !== 0 ? '' : value + '';
7388
7714
  }
7389
- function processChange(e, t, n, a, i) {
7390
- var r = e.mask,
7391
- o = e.prefix,
7392
- s = e.lastEditablePosition,
7393
- l = t,
7394
- u = "",
7395
- c = 0,
7396
- h = 0,
7397
- f = Math.min(i.start, n.start);
7398
- if (n.end > i.start ? h = (c = getInsertStringLength(e, a, u = l.slice(i.start, n.end), f)) ? i.length : 0 : l.length < a.length && (h = a.length - l.length), l = a, h) {
7399
- if (1 === h && !i.length) f = i.start === n.start ? getRightEditablePosition(e, n.start) : getLeftEditablePosition(e, n.start);
7400
- l = clearRange(e, l, f, h);
7715
+ function processChange(maskOptions, value, selection, previousValue, previousSelection) {
7716
+ var mask = maskOptions.mask,
7717
+ prefix = maskOptions.prefix,
7718
+ lastEditablePosition = maskOptions.lastEditablePosition;
7719
+ var newValue = value;
7720
+ var enteredString = '';
7721
+ var formattedEnteredStringLength = 0;
7722
+ var removedLength = 0;
7723
+ var cursorPosition = Math.min(previousSelection.start, selection.start);
7724
+ if (selection.end > previousSelection.start) {
7725
+ enteredString = newValue.slice(previousSelection.start, selection.end);
7726
+ formattedEnteredStringLength = getInsertStringLength(maskOptions, previousValue, enteredString, cursorPosition);
7727
+ if (!formattedEnteredStringLength) {
7728
+ removedLength = 0;
7729
+ } else {
7730
+ removedLength = previousSelection.length;
7731
+ }
7732
+ } else if (newValue.length < previousValue.length) {
7733
+ removedLength = previousValue.length - newValue.length;
7401
7734
  }
7402
- return l = insertString(e, l, u, f), (f += c) >= r.length ? f = r.length : f < o.length && !c ? f = o.length : f >= o.length && f < s && c && (f = getRightEditablePosition(e, f)), u || (u = null), {
7403
- value: l = formatValue(e, l),
7404
- enteredString: u,
7735
+ newValue = previousValue;
7736
+ if (removedLength) {
7737
+ if (removedLength === 1 && !previousSelection.length) {
7738
+ var deleteFromRight = previousSelection.start === selection.start;
7739
+ cursorPosition = deleteFromRight ? getRightEditablePosition(maskOptions, selection.start) : getLeftEditablePosition(maskOptions, selection.start);
7740
+ }
7741
+ newValue = clearRange(maskOptions, newValue, cursorPosition, removedLength);
7742
+ }
7743
+ newValue = insertString(maskOptions, newValue, enteredString, cursorPosition);
7744
+ cursorPosition = cursorPosition + formattedEnteredStringLength;
7745
+ if (cursorPosition >= mask.length) {
7746
+ cursorPosition = mask.length;
7747
+ } else if (cursorPosition < prefix.length && !formattedEnteredStringLength) {
7748
+ cursorPosition = prefix.length;
7749
+ } else if (cursorPosition >= prefix.length && cursorPosition < lastEditablePosition && formattedEnteredStringLength) {
7750
+ cursorPosition = getRightEditablePosition(maskOptions, cursorPosition);
7751
+ }
7752
+ newValue = formatValue(maskOptions, newValue);
7753
+ if (!enteredString) {
7754
+ enteredString = null;
7755
+ }
7756
+ return {
7757
+ value: newValue,
7758
+ enteredString: enteredString,
7405
7759
  selection: {
7406
- start: f,
7407
- end: f
7760
+ start: cursorPosition,
7761
+ end: cursorPosition
7408
7762
  }
7409
7763
  };
7410
7764
  }
7411
7765
  function isWindowsPhoneBrowser() {
7412
- var e = new RegExp("windows", "i"),
7413
- t = new RegExp("phone", "i"),
7414
- n = navigator.userAgent;
7415
- return e.test(n) && t.test(n);
7766
+ var windows = new RegExp('windows', 'i');
7767
+ var phone = new RegExp('phone', 'i');
7768
+ var ua = navigator.userAgent;
7769
+ return windows.test(ua) && phone.test(ua);
7416
7770
  }
7417
- function isFunction(e) {
7418
- return "function" == typeof e;
7771
+ function isFunction(value) {
7772
+ return typeof value === 'function';
7419
7773
  }
7420
7774
  function getRequestAnimationFrame() {
7421
7775
  return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame;
@@ -7423,985 +7777,200 @@ function requireReactInputMask_production_min() {
7423
7777
  function getCancelAnimationFrame() {
7424
7778
  return window.cancelAnimationFrame || window.webkitCancelRequestAnimationFrame || window.webkitCancelAnimationFrame || window.mozCancelAnimationFrame;
7425
7779
  }
7426
- function defer(e) {
7427
- return (!!getCancelAnimationFrame() ? getRequestAnimationFrame() : function () {
7428
- return setTimeout(e, 1e3 / 60);
7429
- })(e);
7780
+ function defer(fn) {
7781
+ var hasCancelAnimationFrame = !!getCancelAnimationFrame();
7782
+ var deferFn;
7783
+ if (hasCancelAnimationFrame) {
7784
+ deferFn = getRequestAnimationFrame();
7785
+ } else {
7786
+ deferFn = function deferFn() {
7787
+ return setTimeout(fn, 1000 / 60);
7788
+ };
7789
+ }
7790
+ return deferFn(fn);
7430
7791
  }
7431
- function cancelDefer(e) {
7432
- (getCancelAnimationFrame() || clearTimeout)(e);
7792
+ function cancelDefer(deferId) {
7793
+ var cancelFn = getCancelAnimationFrame() || clearTimeout;
7794
+ cancelFn(deferId);
7433
7795
  }
7434
- var InputElement = function (c) {
7435
- function e(e) {
7436
- var f = c.call(this, e) || this;
7437
- f.focused = !1, f.mounted = !1, f.previousSelection = null, f.selectionDeferId = null, f.saveSelectionLoopDeferId = null, f.saveSelectionLoop = function () {
7438
- f.previousSelection = f.getSelection(), f.saveSelectionLoopDeferId = defer(f.saveSelectionLoop);
7439
- }, f.runSaveSelectionLoop = function () {
7440
- null === f.saveSelectionLoopDeferId && f.saveSelectionLoop();
7441
- }, f.stopSaveSelectionLoop = function () {
7442
- null !== f.saveSelectionLoopDeferId && (cancelDefer(f.saveSelectionLoopDeferId), f.saveSelectionLoopDeferId = null, f.previousSelection = null);
7443
- }, f.getInputDOMNode = function () {
7444
- if (!f.mounted) return null;
7445
- var e = reactDom.findDOMNode(_assertThisInitialized(_assertThisInitialized(f))),
7446
- t = "undefined" != typeof window && e instanceof window.Element;
7447
- if (e && !t) return null;
7448
- if ("INPUT" !== e.nodeName && (e = e.querySelector("input")), !e) throw new Error("react-input-mask: inputComponent doesn't contain input node");
7449
- return e;
7450
- }, f.getInputValue = function () {
7451
- var e = f.getInputDOMNode();
7452
- return e ? e.value : null;
7453
- }, f.setInputValue = function (e) {
7454
- var t = f.getInputDOMNode();
7455
- t && (f.value = e, t.value = e);
7456
- }, f.setCursorToEnd = function () {
7457
- var e = getFilledLength(f.maskOptions, f.value),
7458
- t = getRightEditablePosition(f.maskOptions, e);
7459
- null !== t && f.setCursorPosition(t);
7460
- }, f.setSelection = function (e, t, n) {
7461
- void 0 === n && (n = {});
7462
- var a = f.getInputDOMNode(),
7463
- i = f.isFocused();
7464
- a && i && (n.deferred || setInputSelection(a, e, t), null !== f.selectionDeferId && cancelDefer(f.selectionDeferId), f.selectionDeferId = defer(function () {
7465
- f.selectionDeferId = null, setInputSelection(a, e, t);
7466
- }), f.previousSelection = {
7467
- start: e,
7468
- end: t,
7469
- length: Math.abs(t - e)
7470
- });
7471
- }, f.getSelection = function () {
7472
- return getInputSelection(f.getInputDOMNode());
7473
- }, f.getCursorPosition = function () {
7474
- return f.getSelection().start;
7475
- }, f.setCursorPosition = function (e) {
7476
- f.setSelection(e, e);
7477
- }, f.isFocused = function () {
7478
- return f.focused;
7479
- }, f.getBeforeMaskedValueChangeConfig = function () {
7480
- var e = f.maskOptions,
7481
- t = e.mask,
7482
- n = e.maskChar,
7483
- a = e.permanents,
7484
- i = e.formatChars;
7485
- return {
7486
- mask: t,
7487
- maskChar: n,
7488
- permanents: a,
7489
- alwaysShowMask: !!f.props.alwaysShowMask,
7490
- formatChars: i
7491
- };
7492
- }, f.isInputAutofilled = function (e, t, n, a) {
7493
- var i = f.getInputDOMNode();
7494
- try {
7495
- if (i.matches(":-webkit-autofill")) return !0;
7496
- } catch (r) {}
7497
- return !f.focused || a.end < n.length && t.end === e.length;
7498
- }, f.onChange = function (e) {
7499
- var t = _assertThisInitialized(_assertThisInitialized(f)).beforePasteState,
7500
- n = _assertThisInitialized(_assertThisInitialized(f)).previousSelection,
7501
- a = f.props.beforeMaskedValueChange,
7502
- i = f.getInputValue(),
7503
- r = f.value,
7504
- o = f.getSelection();
7505
- f.isInputAutofilled(i, o, r, n) && (r = formatValue(f.maskOptions, ""), n = {
7506
- start: 0,
7507
- end: 0,
7508
- length: 0
7509
- }), t && (n = t.selection, r = t.value, o = {
7510
- start: n.start + i.length,
7511
- end: n.start + i.length,
7512
- length: 0
7513
- }, i = r.slice(0, n.start) + i + r.slice(n.end), f.beforePasteState = null);
7514
- var s = processChange(f.maskOptions, i, o, r, n),
7515
- l = s.enteredString,
7516
- u = s.selection,
7517
- c = s.value;
7518
- if (isFunction(a)) {
7519
- var h = a({
7520
- value: c,
7521
- selection: u
7522
- }, {
7523
- value: r,
7524
- selection: n
7525
- }, l, f.getBeforeMaskedValueChangeConfig());
7526
- c = h.value, u = h.selection;
7796
+ var InputElement = /*#__PURE__*/
7797
+ function (_React$Component) {
7798
+ _inheritsLoose(InputElement, _React$Component);
7799
+ function InputElement(props) {
7800
+ var _this;
7801
+ _this = _React$Component.call(this, props) || this;
7802
+ _this.focused = false;
7803
+ _this.mounted = false;
7804
+ _this.previousSelection = null;
7805
+ _this.selectionDeferId = null;
7806
+ _this.saveSelectionLoopDeferId = null;
7807
+ _this.saveSelectionLoop = function () {
7808
+ _this.previousSelection = _this.getSelection();
7809
+ _this.saveSelectionLoopDeferId = defer(_this.saveSelectionLoop);
7810
+ };
7811
+ _this.runSaveSelectionLoop = function () {
7812
+ if (_this.saveSelectionLoopDeferId === null) {
7813
+ _this.saveSelectionLoop();
7527
7814
  }
7528
- f.setInputValue(c), isFunction(f.props.onChange) && f.props.onChange(e), f.isWindowsPhoneBrowser ? f.setSelection(u.start, u.end, {
7529
- deferred: !0
7530
- }) : f.setSelection(u.start, u.end);
7531
- }, f.onFocus = function (e) {
7532
- var t = f.props.beforeMaskedValueChange,
7533
- n = f.maskOptions,
7534
- a = n.mask,
7535
- i = n.prefix;
7536
- if (f.focused = !0, f.mounted = !0, a) {
7537
- if (f.value) getFilledLength(f.maskOptions, f.value) < f.maskOptions.mask.length && f.setCursorToEnd();else {
7538
- var r = formatValue(f.maskOptions, i),
7539
- o = formatValue(f.maskOptions, r),
7540
- s = getFilledLength(f.maskOptions, o),
7541
- l = getRightEditablePosition(f.maskOptions, s),
7542
- u = {
7543
- start: l,
7544
- end: l
7545
- };
7546
- if (isFunction(t)) {
7547
- var c = t({
7548
- value: o,
7549
- selection: u
7550
- }, {
7551
- value: f.value,
7552
- selection: null
7553
- }, null, f.getBeforeMaskedValueChangeConfig());
7554
- o = c.value, u = c.selection;
7555
- }
7556
- var h = o !== f.getInputValue();
7557
- h && f.setInputValue(o), h && isFunction(f.props.onChange) && f.props.onChange(e), f.setSelection(u.start, u.end);
7558
- }
7559
- f.runSaveSelectionLoop();
7815
+ };
7816
+ _this.stopSaveSelectionLoop = function () {
7817
+ if (_this.saveSelectionLoopDeferId !== null) {
7818
+ cancelDefer(_this.saveSelectionLoopDeferId);
7819
+ _this.saveSelectionLoopDeferId = null;
7820
+ _this.previousSelection = null;
7560
7821
  }
7561
- isFunction(f.props.onFocus) && f.props.onFocus(e);
7562
- }, f.onBlur = function (e) {
7563
- var t = f.props.beforeMaskedValueChange,
7564
- n = f.maskOptions.mask;
7565
- if (f.stopSaveSelectionLoop(), f.focused = !1, n && !f.props.alwaysShowMask && isEmpty(f.maskOptions, f.value)) {
7566
- var a = "";
7567
- if (isFunction(t)) a = t({
7568
- value: a,
7569
- selection: null
7570
- }, {
7571
- value: f.value,
7572
- selection: f.previousSelection
7573
- }, null, f.getBeforeMaskedValueChangeConfig()).value;
7574
- var i = a !== f.getInputValue();
7575
- i && f.setInputValue(a), i && isFunction(f.props.onChange) && f.props.onChange(e);
7822
+ };
7823
+ _this.getInputDOMNode = function () {
7824
+ if (!_this.mounted) {
7825
+ return null;
7576
7826
  }
7577
- isFunction(f.props.onBlur) && f.props.onBlur(e);
7578
- }, f.onMouseDown = function (e) {
7579
- if (!f.focused && document.addEventListener) {
7580
- f.mouseDownX = e.clientX, f.mouseDownY = e.clientY, f.mouseDownTime = new Date().getTime();
7581
- var r = function r(e) {
7582
- if (document.removeEventListener("mouseup", r), f.focused) {
7583
- var t = Math.abs(e.clientX - f.mouseDownX),
7584
- n = Math.abs(e.clientY - f.mouseDownY),
7585
- a = Math.max(t, n),
7586
- i = new Date().getTime() - f.mouseDownTime;
7587
- (a <= 10 && i <= 200 || a <= 5 && i <= 300) && f.setCursorToEnd();
7588
- }
7589
- };
7590
- document.addEventListener("mouseup", r);
7827
+ var input = reactDom.findDOMNode(_assertThisInitialized(_assertThisInitialized(_this)));
7828
+ var isDOMNode = typeof window !== 'undefined' && input instanceof window.Element; // workaround for react-test-renderer
7829
+ // https://github.com/sanniassin/react-input-mask/issues/147
7830
+
7831
+ if (input && !isDOMNode) {
7832
+ return null;
7591
7833
  }
7592
- isFunction(f.props.onMouseDown) && f.props.onMouseDown(e);
7593
- }, f.onPaste = function (e) {
7594
- isFunction(f.props.onPaste) && f.props.onPaste(e), e.defaultPrevented || (f.beforePasteState = {
7595
- value: f.getInputValue(),
7596
- selection: f.getSelection()
7597
- }, f.setInputValue(""));
7598
- }, f.handleRef = function (e) {
7599
- null == f.props.children && isFunction(f.props.inputRef) && f.props.inputRef(e);
7834
+ if (input.nodeName !== 'INPUT') {
7835
+ input = input.querySelector('input');
7836
+ }
7837
+ if (!input) {
7838
+ throw new Error('react-input-mask: inputComponent doesn\'t contain input node');
7839
+ }
7840
+ return input;
7600
7841
  };
7601
- var t = e.mask,
7602
- n = e.maskChar,
7603
- a = e.formatChars,
7604
- i = e.alwaysShowMask,
7605
- r = e.beforeMaskedValueChange,
7606
- o = e.defaultValue,
7607
- s = e.value;
7608
- f.maskOptions = parseMask(t, n, a), null == o && (o = ""), null == s && (s = o);
7609
- var l = getStringValue(s);
7610
- if (f.maskOptions.mask && (i || l) && (l = formatValue(f.maskOptions, l), isFunction(r))) {
7611
- var u = e.value;
7612
- null == e.value && (u = o), l = r({
7613
- value: l,
7614
- selection: null
7615
- }, {
7616
- value: u = getStringValue(u),
7617
- selection: null
7618
- }, null, f.getBeforeMaskedValueChangeConfig()).value;
7619
- }
7620
- return f.value = l, f;
7621
- }
7622
- _inheritsLoose(e, c);
7623
- var t = e.prototype;
7624
- return t.componentDidMount = function () {
7625
- this.mounted = !0, this.getInputDOMNode() && (this.isWindowsPhoneBrowser = isWindowsPhoneBrowser(), this.maskOptions.mask && this.getInputValue() !== this.value && this.setInputValue(this.value));
7626
- }, t.componentDidUpdate = function () {
7627
- var e = this.previousSelection,
7628
- t = this.props,
7629
- n = t.beforeMaskedValueChange,
7630
- a = t.alwaysShowMask,
7631
- i = t.mask,
7632
- r = t.maskChar,
7633
- o = t.formatChars,
7634
- s = this.maskOptions,
7635
- l = a || this.isFocused(),
7636
- u = null != this.props.value,
7637
- c = u ? getStringValue(this.props.value) : this.value,
7638
- h = e ? e.start : null;
7639
- if (this.maskOptions = parseMask(i, r, o), this.maskOptions.mask) {
7640
- !s.mask && this.isFocused() && this.runSaveSelectionLoop();
7641
- var f = this.maskOptions.mask && this.maskOptions.mask !== s.mask;
7642
- if (s.mask || u || (c = this.getInputValue()), (f || this.maskOptions.mask && (c || l)) && (c = formatValue(this.maskOptions, c)), f) {
7643
- var p = getFilledLength(this.maskOptions, c);
7644
- (null === h || p < h) && (h = isFilled(this.maskOptions, c) ? p : getRightEditablePosition(this.maskOptions, p));
7842
+ _this.getInputValue = function () {
7843
+ var input = _this.getInputDOMNode();
7844
+ if (!input) {
7845
+ return null;
7645
7846
  }
7646
- !this.maskOptions.mask || !isEmpty(this.maskOptions, c) || l || u && this.props.value || (c = "");
7647
- var d = {
7648
- start: h,
7649
- end: h
7650
- };
7651
- if (isFunction(n)) {
7652
- var m = n({
7653
- value: c,
7654
- selection: d
7655
- }, {
7656
- value: this.value,
7657
- selection: this.previousSelection
7658
- }, null, this.getBeforeMaskedValueChangeConfig());
7659
- c = m.value, d = m.selection;
7847
+ return input.value;
7848
+ };
7849
+ _this.setInputValue = function (value) {
7850
+ var input = _this.getInputDOMNode();
7851
+ if (!input) {
7852
+ return;
7660
7853
  }
7661
- this.value = c;
7662
- var g = this.getInputValue() !== this.value;
7663
- g ? (this.setInputValue(this.value), this.forceUpdate()) : f && this.forceUpdate();
7664
- var v = !1;
7665
- null != d.start && null != d.end && (v = !e || e.start !== d.start || e.end !== d.end), (v || g) && this.setSelection(d.start, d.end);
7666
- } else s.mask && (this.stopSaveSelectionLoop(), this.forceUpdate());
7667
- }, t.componentWillUnmount = function () {
7668
- this.mounted = !1, null !== this.selectionDeferId && cancelDefer(this.selectionDeferId), this.stopSaveSelectionLoop();
7669
- }, t.render = function () {
7670
- var t,
7671
- e = this.props,
7672
- n = (e.mask, e.alwaysShowMask, e.maskChar, e.formatChars, e.inputRef, e.beforeMaskedValueChange, e.children),
7673
- a = _objectWithoutPropertiesLoose(e, ["mask", "alwaysShowMask", "maskChar", "formatChars", "inputRef", "beforeMaskedValueChange", "children"]);
7674
- if (n) {
7675
- isFunction(n) || invariant_1(!1);
7676
- var i = ["onChange", "onPaste", "onMouseDown", "onFocus", "onBlur", "value", "disabled", "readOnly"],
7677
- r = _extends({}, a);
7678
- i.forEach(function (e) {
7679
- return delete r[e];
7680
- }), t = n(r), i.filter(function (e) {
7681
- return null != t.props[e] && t.props[e] !== a[e];
7682
- }).length && invariant_1(!1);
7683
- } else t = React$1.createElement("input", _extends({
7684
- ref: this.handleRef
7685
- }, a));
7686
- var o = {
7687
- onFocus: this.onFocus,
7688
- onBlur: this.onBlur
7854
+ _this.value = value;
7855
+ input.value = value;
7689
7856
  };
7690
- return this.maskOptions.mask && (a.disabled || a.readOnly || (o.onChange = this.onChange, o.onPaste = this.onPaste, o.onMouseDown = this.onMouseDown), null != a.value && (o.value = this.value)), t = React$1.cloneElement(t, o);
7691
- }, e;
7692
- }(React$1.Component);
7693
- reactInputMask_production_min = InputElement;
7694
- return reactInputMask_production_min;
7695
- }
7696
-
7697
- /**
7698
- * Copyright (c) 2013-present, Facebook, Inc.
7699
- *
7700
- * This source code is licensed under the MIT license found in the
7701
- * LICENSE file in the root directory of this source tree.
7702
- */
7703
- var invariant_1;
7704
- var hasRequiredInvariant;
7705
- function requireInvariant() {
7706
- if (hasRequiredInvariant) return invariant_1;
7707
- hasRequiredInvariant = 1;
7857
+ _this.setCursorToEnd = function () {
7858
+ var filledLength = getFilledLength(_this.maskOptions, _this.value);
7859
+ var pos = getRightEditablePosition(_this.maskOptions, filledLength);
7860
+ if (pos !== null) {
7861
+ _this.setCursorPosition(pos);
7862
+ }
7863
+ };
7864
+ _this.setSelection = function (start, end, options) {
7865
+ if (options === void 0) {
7866
+ options = {};
7867
+ }
7868
+ var input = _this.getInputDOMNode();
7869
+ var isFocused = _this.isFocused(); // don't change selection on unfocused input
7870
+ // because Safari sets focus on selection change (#154)
7708
7871
 
7709
- /**
7710
- * Use invariant() to assert state which your program assumes to be true.
7711
- *
7712
- * Provide sprintf-style format (only %s is supported) and arguments
7713
- * to provide information about what broke and what you were
7714
- * expecting.
7715
- *
7716
- * The invariant message will be stripped in production, but the invariant
7717
- * will remain to ensure logic does not differ in production.
7718
- */
7872
+ if (!input || !isFocused) {
7873
+ return;
7874
+ }
7875
+ var _options = options,
7876
+ deferred = _options.deferred;
7877
+ if (!deferred) {
7878
+ setInputSelection(input, start, end);
7879
+ }
7880
+ if (_this.selectionDeferId !== null) {
7881
+ cancelDefer(_this.selectionDeferId);
7882
+ } // deferred selection update is required for pre-Lollipop Android browser,
7883
+ // but for consistent behavior we do it for all browsers
7719
7884
 
7720
- var NODE_ENV = process.env.NODE_ENV;
7721
- var invariant = function invariant(condition, format, a, b, c, d, e, f) {
7722
- if (NODE_ENV !== 'production') {
7723
- if (format === undefined) {
7724
- throw new Error('invariant requires an error message argument');
7725
- }
7726
- }
7727
- if (!condition) {
7728
- var error;
7729
- if (format === undefined) {
7730
- error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.');
7731
- } else {
7732
- var args = [a, b, c, d, e, f];
7733
- var argIndex = 0;
7734
- error = new Error(format.replace(/%s/g, function () {
7735
- return args[argIndex++];
7736
- }));
7737
- error.name = 'Invariant Violation';
7738
- }
7739
- error.framesToPop = 1; // we don't care about invariant's own frame
7740
- throw error;
7741
- }
7742
- };
7743
- invariant_1 = invariant;
7744
- return invariant_1;
7745
- }
7885
+ _this.selectionDeferId = defer(function () {
7886
+ _this.selectionDeferId = null;
7887
+ setInputSelection(input, start, end);
7888
+ });
7889
+ _this.previousSelection = {
7890
+ start: start,
7891
+ end: end,
7892
+ length: Math.abs(end - start)
7893
+ };
7894
+ };
7895
+ _this.getSelection = function () {
7896
+ var input = _this.getInputDOMNode();
7897
+ return getInputSelection(input);
7898
+ };
7899
+ _this.getCursorPosition = function () {
7900
+ return _this.getSelection().start;
7901
+ };
7902
+ _this.setCursorPosition = function (pos) {
7903
+ _this.setSelection(pos, pos);
7904
+ };
7905
+ _this.isFocused = function () {
7906
+ return _this.focused;
7907
+ };
7908
+ _this.getBeforeMaskedValueChangeConfig = function () {
7909
+ var _this$maskOptions = _this.maskOptions,
7910
+ mask = _this$maskOptions.mask,
7911
+ maskChar = _this$maskOptions.maskChar,
7912
+ permanents = _this$maskOptions.permanents,
7913
+ formatChars = _this$maskOptions.formatChars;
7914
+ var alwaysShowMask = _this.props.alwaysShowMask;
7915
+ return {
7916
+ mask: mask,
7917
+ maskChar: maskChar,
7918
+ permanents: permanents,
7919
+ alwaysShowMask: !!alwaysShowMask,
7920
+ formatChars: formatChars
7921
+ };
7922
+ };
7923
+ _this.isInputAutofilled = function (value, selection, previousValue, previousSelection) {
7924
+ var input = _this.getInputDOMNode(); // only check for positive match because it will be false negative
7925
+ // in case of autofill simulation in tests
7926
+ //
7927
+ // input.matches throws an exception if selector isn't supported
7746
7928
 
7747
- /**
7748
- * Copyright (c) 2014-present, Facebook, Inc.
7749
- *
7750
- * This source code is licensed under the MIT license found in the
7751
- * LICENSE file in the root directory of this source tree.
7752
- */
7753
- var warning_1;
7754
- var hasRequiredWarning;
7755
- function requireWarning() {
7756
- if (hasRequiredWarning) return warning_1;
7757
- hasRequiredWarning = 1;
7929
+ try {
7930
+ if (input.matches(':-webkit-autofill')) {
7931
+ return true;
7932
+ }
7933
+ } catch (e) {} // if input isn't focused then change event must have been triggered
7934
+ // either by autofill or event simulation in tests
7758
7935
 
7759
- /**
7760
- * Similar to invariant but only logs a warning if the condition is not met.
7761
- * This can be used to log issues in development environments in critical
7762
- * paths. Removing the logging code for production environments will keep the
7763
- * same logic and follow the same code paths.
7764
- */
7936
+ if (!_this.focused) {
7937
+ return true;
7938
+ } // if cursor has moved to the end while previousSelection forbids it
7939
+ // then it must be autofill
7765
7940
 
7766
- var __DEV__ = process.env.NODE_ENV !== 'production';
7767
- var warning = function warning() {};
7768
- if (__DEV__) {
7769
- var printWarning = function printWarning(format, args) {
7770
- var len = arguments.length;
7771
- args = new Array(len > 1 ? len - 1 : 0);
7772
- for (var key = 1; key < len; key++) {
7773
- args[key - 1] = arguments[key];
7774
- }
7775
- var argIndex = 0;
7776
- var message = 'Warning: ' + format.replace(/%s/g, function () {
7777
- return args[argIndex++];
7778
- });
7779
- if (typeof console !== 'undefined') {
7780
- console.error(message);
7781
- }
7782
- try {
7783
- // --- Welcome to debugging React ---
7784
- // This error was thrown as a convenience so that you can use this stack
7785
- // to find the callsite that caused this warning to fire.
7786
- throw new Error(message);
7787
- } catch (x) {}
7788
- };
7789
- warning = function warning(condition, format, args) {
7790
- var len = arguments.length;
7791
- args = new Array(len > 2 ? len - 2 : 0);
7792
- for (var key = 2; key < len; key++) {
7793
- args[key - 2] = arguments[key];
7794
- }
7795
- if (format === undefined) {
7796
- throw new Error('`warning(condition, format, ...args)` requires a warning ' + 'message argument');
7797
- }
7798
- if (!condition) {
7799
- printWarning.apply(null, [format].concat(args));
7800
- }
7801
- };
7802
- }
7803
- warning_1 = warning;
7804
- return warning_1;
7805
- }
7941
+ return previousSelection.end < previousValue.length && selection.end === value.length;
7942
+ };
7943
+ _this.onChange = function (event) {
7944
+ var _assertThisInitialize = _assertThisInitialized(_assertThisInitialized(_this)),
7945
+ beforePasteState = _assertThisInitialize.beforePasteState;
7946
+ var _assertThisInitialize2 = _assertThisInitialized(_assertThisInitialized(_this)),
7947
+ previousSelection = _assertThisInitialize2.previousSelection;
7948
+ var beforeMaskedValueChange = _this.props.beforeMaskedValueChange;
7949
+ var value = _this.getInputValue();
7950
+ var previousValue = _this.value;
7951
+ var selection = _this.getSelection(); // autofill replaces entire value, ignore old one
7952
+ // https://github.com/sanniassin/react-input-mask/issues/113
7806
7953
 
7807
- var reactInputMask_development;
7808
- var hasRequiredReactInputMask_development;
7809
- function requireReactInputMask_development() {
7810
- if (hasRequiredReactInputMask_development) return reactInputMask_development;
7811
- hasRequiredReactInputMask_development = 1;
7812
- function _interopDefault(ex) {
7813
- return ex && _typeof$1(ex) === 'object' && 'default' in ex ? ex['default'] : ex;
7814
- }
7815
- var React$1 = _interopDefault(React);
7816
- var reactDom = require$$1;
7817
- var invariant = _interopDefault(requireInvariant());
7818
- var warning = _interopDefault(requireWarning());
7819
- function _defaults2(obj, defaults) {
7820
- var keys = Object.getOwnPropertyNames(defaults);
7821
- for (var i = 0; i < keys.length; i++) {
7822
- var key = keys[i];
7823
- var value = Object.getOwnPropertyDescriptor(defaults, key);
7824
- if (value && value.configurable && obj[key] === undefined) {
7825
- Object.defineProperty(obj, key, value);
7826
- }
7827
- }
7828
- return obj;
7829
- }
7830
- function _extends() {
7831
- _extends = Object.assign || function (target) {
7832
- for (var i = 1; i < arguments.length; i++) {
7833
- var source = arguments[i];
7834
- for (var key in source) {
7835
- if (Object.prototype.hasOwnProperty.call(source, key)) {
7836
- target[key] = source[key];
7837
- }
7838
- }
7839
- }
7840
- return target;
7841
- };
7842
- return _extends.apply(this, arguments);
7843
- }
7844
- function _inheritsLoose(subClass, superClass) {
7845
- subClass.prototype = Object.create(superClass.prototype);
7846
- subClass.prototype.constructor = subClass;
7847
- _defaults2(subClass, superClass);
7848
- }
7849
- function _objectWithoutPropertiesLoose(source, excluded) {
7850
- if (source == null) return {};
7851
- var target = {};
7852
- var sourceKeys = Object.keys(source);
7853
- var key, i;
7854
- for (i = 0; i < sourceKeys.length; i++) {
7855
- key = sourceKeys[i];
7856
- if (excluded.indexOf(key) >= 0) continue;
7857
- target[key] = source[key];
7858
- }
7859
- return target;
7860
- }
7861
- function _assertThisInitialized(self) {
7862
- if (self === void 0) {
7863
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
7864
- }
7865
- return self;
7866
- }
7867
- function setInputSelection(input, start, end) {
7868
- if ('selectionStart' in input && 'selectionEnd' in input) {
7869
- input.selectionStart = start;
7870
- input.selectionEnd = end;
7871
- } else {
7872
- var range = input.createTextRange();
7873
- range.collapse(true);
7874
- range.moveStart('character', start);
7875
- range.moveEnd('character', end - start);
7876
- range.select();
7877
- }
7878
- }
7879
- function getInputSelection(input) {
7880
- var start = 0;
7881
- var end = 0;
7882
- if ('selectionStart' in input && 'selectionEnd' in input) {
7883
- start = input.selectionStart;
7884
- end = input.selectionEnd;
7885
- } else {
7886
- var range = document.selection.createRange();
7887
- if (range.parentElement() === input) {
7888
- start = -range.moveStart('character', -input.value.length);
7889
- end = -range.moveEnd('character', -input.value.length);
7890
- }
7891
- }
7892
- return {
7893
- start: start,
7894
- end: end,
7895
- length: end - start
7896
- };
7897
- }
7898
- var defaultFormatChars = {
7899
- '9': '[0-9]',
7900
- 'a': '[A-Za-z]',
7901
- '*': '[A-Za-z0-9]'
7902
- };
7903
- var defaultMaskChar = '_';
7904
- function parseMask(mask, maskChar, formatChars) {
7905
- var parsedMaskString = '';
7906
- var prefix = '';
7907
- var lastEditablePosition = null;
7908
- var permanents = [];
7909
- if (maskChar === undefined) {
7910
- maskChar = defaultMaskChar;
7911
- }
7912
- if (formatChars == null) {
7913
- formatChars = defaultFormatChars;
7914
- }
7915
- if (!mask || typeof mask !== 'string') {
7916
- return {
7917
- maskChar: maskChar,
7918
- formatChars: formatChars,
7919
- mask: null,
7920
- prefix: null,
7921
- lastEditablePosition: null,
7922
- permanents: []
7923
- };
7924
- }
7925
- var isPermanent = false;
7926
- mask.split('').forEach(function (character) {
7927
- if (!isPermanent && character === '\\') {
7928
- isPermanent = true;
7929
- } else {
7930
- if (isPermanent || !formatChars[character]) {
7931
- permanents.push(parsedMaskString.length);
7932
- if (parsedMaskString.length === permanents.length - 1) {
7933
- prefix += character;
7934
- }
7935
- } else {
7936
- lastEditablePosition = parsedMaskString.length + 1;
7937
- }
7938
- parsedMaskString += character;
7939
- isPermanent = false;
7940
- }
7941
- });
7942
- return {
7943
- maskChar: maskChar,
7944
- formatChars: formatChars,
7945
- prefix: prefix,
7946
- mask: parsedMaskString,
7947
- lastEditablePosition: lastEditablePosition,
7948
- permanents: permanents
7949
- };
7950
- }
7951
-
7952
- /* eslint no-use-before-define: ["error", { functions: false }] */
7953
- function isPermanentCharacter(maskOptions, pos) {
7954
- return maskOptions.permanents.indexOf(pos) !== -1;
7955
- }
7956
- function isAllowedCharacter(maskOptions, pos, character) {
7957
- var mask = maskOptions.mask,
7958
- formatChars = maskOptions.formatChars;
7959
- if (!character) {
7960
- return false;
7961
- }
7962
- if (isPermanentCharacter(maskOptions, pos)) {
7963
- return mask[pos] === character;
7964
- }
7965
- var ruleChar = mask[pos];
7966
- var charRule = formatChars[ruleChar];
7967
- return new RegExp(charRule).test(character);
7968
- }
7969
- function isEmpty(maskOptions, value) {
7970
- return value.split('').every(function (character, i) {
7971
- return isPermanentCharacter(maskOptions, i) || !isAllowedCharacter(maskOptions, i, character);
7972
- });
7973
- }
7974
- function getFilledLength(maskOptions, value) {
7975
- var maskChar = maskOptions.maskChar,
7976
- prefix = maskOptions.prefix;
7977
- if (!maskChar) {
7978
- while (value.length > prefix.length && isPermanentCharacter(maskOptions, value.length - 1)) {
7979
- value = value.slice(0, value.length - 1);
7980
- }
7981
- return value.length;
7982
- }
7983
- var filledLength = prefix.length;
7984
- for (var i = value.length; i >= prefix.length; i--) {
7985
- var character = value[i];
7986
- var isEnteredCharacter = !isPermanentCharacter(maskOptions, i) && isAllowedCharacter(maskOptions, i, character);
7987
- if (isEnteredCharacter) {
7988
- filledLength = i + 1;
7989
- break;
7990
- }
7991
- }
7992
- return filledLength;
7993
- }
7994
- function isFilled(maskOptions, value) {
7995
- return getFilledLength(maskOptions, value) === maskOptions.mask.length;
7996
- }
7997
- function formatValue(maskOptions, value) {
7998
- var maskChar = maskOptions.maskChar,
7999
- mask = maskOptions.mask,
8000
- prefix = maskOptions.prefix;
8001
- if (!maskChar) {
8002
- value = insertString(maskOptions, '', value, 0);
8003
- if (value.length < prefix.length) {
8004
- value = prefix;
8005
- }
8006
- while (value.length < mask.length && isPermanentCharacter(maskOptions, value.length)) {
8007
- value += mask[value.length];
8008
- }
8009
- return value;
8010
- }
8011
- if (value) {
8012
- var emptyValue = formatValue(maskOptions, '');
8013
- return insertString(maskOptions, emptyValue, value, 0);
8014
- }
8015
- for (var i = 0; i < mask.length; i++) {
8016
- if (isPermanentCharacter(maskOptions, i)) {
8017
- value += mask[i];
8018
- } else {
8019
- value += maskChar;
8020
- }
8021
- }
8022
- return value;
8023
- }
8024
- function clearRange(maskOptions, value, start, len) {
8025
- var end = start + len;
8026
- var maskChar = maskOptions.maskChar,
8027
- mask = maskOptions.mask,
8028
- prefix = maskOptions.prefix;
8029
- var arrayValue = value.split('');
8030
- if (!maskChar) {
8031
- // remove any permanent chars after clear range, they will be added back by formatValue
8032
- for (var i = end; i < arrayValue.length; i++) {
8033
- if (isPermanentCharacter(maskOptions, i)) {
8034
- arrayValue[i] = '';
8035
- }
8036
- }
8037
- start = Math.max(prefix.length, start);
8038
- arrayValue.splice(start, end - start);
8039
- value = arrayValue.join('');
8040
- return formatValue(maskOptions, value);
8041
- }
8042
- return arrayValue.map(function (character, i) {
8043
- if (i < start || i >= end) {
8044
- return character;
8045
- }
8046
- if (isPermanentCharacter(maskOptions, i)) {
8047
- return mask[i];
8048
- }
8049
- return maskChar;
8050
- }).join('');
8051
- }
8052
- function insertString(maskOptions, value, insertStr, insertPosition) {
8053
- var mask = maskOptions.mask,
8054
- maskChar = maskOptions.maskChar,
8055
- prefix = maskOptions.prefix;
8056
- var arrayInsertStr = insertStr.split('');
8057
- var isInputFilled = isFilled(maskOptions, value);
8058
- var isUsablePosition = function isUsablePosition(pos, character) {
8059
- return !isPermanentCharacter(maskOptions, pos) || character === mask[pos];
8060
- };
8061
- var isUsableCharacter = function isUsableCharacter(character, pos) {
8062
- return !maskChar || !isPermanentCharacter(maskOptions, pos) || character !== maskChar;
8063
- };
8064
- if (!maskChar && insertPosition > value.length) {
8065
- value += mask.slice(value.length, insertPosition);
8066
- }
8067
- arrayInsertStr.every(function (insertCharacter) {
8068
- while (!isUsablePosition(insertPosition, insertCharacter)) {
8069
- if (insertPosition >= value.length) {
8070
- value += mask[insertPosition];
8071
- }
8072
- if (!isUsableCharacter(insertCharacter, insertPosition)) {
8073
- return true;
8074
- }
8075
- insertPosition++; // stop iteration if maximum value length reached
8076
-
8077
- if (insertPosition >= mask.length) {
8078
- return false;
8079
- }
8080
- }
8081
- var isAllowed = isAllowedCharacter(maskOptions, insertPosition, insertCharacter) || insertCharacter === maskChar;
8082
- if (!isAllowed) {
8083
- return true;
8084
- }
8085
- if (insertPosition < value.length) {
8086
- if (maskChar || isInputFilled || insertPosition < prefix.length) {
8087
- value = value.slice(0, insertPosition) + insertCharacter + value.slice(insertPosition + 1);
8088
- } else {
8089
- value = value.slice(0, insertPosition) + insertCharacter + value.slice(insertPosition);
8090
- value = formatValue(maskOptions, value);
8091
- }
8092
- } else if (!maskChar) {
8093
- value += insertCharacter;
8094
- }
8095
- insertPosition++; // stop iteration if maximum value length reached
8096
-
8097
- return insertPosition < mask.length;
8098
- });
8099
- return value;
8100
- }
8101
- function getInsertStringLength(maskOptions, value, insertStr, insertPosition) {
8102
- var mask = maskOptions.mask,
8103
- maskChar = maskOptions.maskChar;
8104
- var arrayInsertStr = insertStr.split('');
8105
- var initialInsertPosition = insertPosition;
8106
- var isUsablePosition = function isUsablePosition(pos, character) {
8107
- return !isPermanentCharacter(maskOptions, pos) || character === mask[pos];
8108
- };
8109
- arrayInsertStr.every(function (insertCharacter) {
8110
- while (!isUsablePosition(insertPosition, insertCharacter)) {
8111
- insertPosition++; // stop iteration if maximum value length reached
8112
-
8113
- if (insertPosition >= mask.length) {
8114
- return false;
8115
- }
8116
- }
8117
- var isAllowed = isAllowedCharacter(maskOptions, insertPosition, insertCharacter) || insertCharacter === maskChar;
8118
- if (isAllowed) {
8119
- insertPosition++;
8120
- } // stop iteration if maximum value length reached
8121
-
8122
- return insertPosition < mask.length;
8123
- });
8124
- return insertPosition - initialInsertPosition;
8125
- }
8126
- function getLeftEditablePosition(maskOptions, pos) {
8127
- for (var i = pos; i >= 0; --i) {
8128
- if (!isPermanentCharacter(maskOptions, i)) {
8129
- return i;
8130
- }
8131
- }
8132
- return null;
8133
- }
8134
- function getRightEditablePosition(maskOptions, pos) {
8135
- var mask = maskOptions.mask;
8136
- for (var i = pos; i < mask.length; ++i) {
8137
- if (!isPermanentCharacter(maskOptions, i)) {
8138
- return i;
8139
- }
8140
- }
8141
- return null;
8142
- }
8143
- function getStringValue(value) {
8144
- return !value && value !== 0 ? '' : value + '';
8145
- }
8146
- function processChange(maskOptions, value, selection, previousValue, previousSelection) {
8147
- var mask = maskOptions.mask,
8148
- prefix = maskOptions.prefix,
8149
- lastEditablePosition = maskOptions.lastEditablePosition;
8150
- var newValue = value;
8151
- var enteredString = '';
8152
- var formattedEnteredStringLength = 0;
8153
- var removedLength = 0;
8154
- var cursorPosition = Math.min(previousSelection.start, selection.start);
8155
- if (selection.end > previousSelection.start) {
8156
- enteredString = newValue.slice(previousSelection.start, selection.end);
8157
- formattedEnteredStringLength = getInsertStringLength(maskOptions, previousValue, enteredString, cursorPosition);
8158
- if (!formattedEnteredStringLength) {
8159
- removedLength = 0;
8160
- } else {
8161
- removedLength = previousSelection.length;
8162
- }
8163
- } else if (newValue.length < previousValue.length) {
8164
- removedLength = previousValue.length - newValue.length;
8165
- }
8166
- newValue = previousValue;
8167
- if (removedLength) {
8168
- if (removedLength === 1 && !previousSelection.length) {
8169
- var deleteFromRight = previousSelection.start === selection.start;
8170
- cursorPosition = deleteFromRight ? getRightEditablePosition(maskOptions, selection.start) : getLeftEditablePosition(maskOptions, selection.start);
8171
- }
8172
- newValue = clearRange(maskOptions, newValue, cursorPosition, removedLength);
8173
- }
8174
- newValue = insertString(maskOptions, newValue, enteredString, cursorPosition);
8175
- cursorPosition = cursorPosition + formattedEnteredStringLength;
8176
- if (cursorPosition >= mask.length) {
8177
- cursorPosition = mask.length;
8178
- } else if (cursorPosition < prefix.length && !formattedEnteredStringLength) {
8179
- cursorPosition = prefix.length;
8180
- } else if (cursorPosition >= prefix.length && cursorPosition < lastEditablePosition && formattedEnteredStringLength) {
8181
- cursorPosition = getRightEditablePosition(maskOptions, cursorPosition);
8182
- }
8183
- newValue = formatValue(maskOptions, newValue);
8184
- if (!enteredString) {
8185
- enteredString = null;
8186
- }
8187
- return {
8188
- value: newValue,
8189
- enteredString: enteredString,
8190
- selection: {
8191
- start: cursorPosition,
8192
- end: cursorPosition
8193
- }
8194
- };
8195
- }
8196
- function isWindowsPhoneBrowser() {
8197
- var windows = new RegExp('windows', 'i');
8198
- var phone = new RegExp('phone', 'i');
8199
- var ua = navigator.userAgent;
8200
- return windows.test(ua) && phone.test(ua);
8201
- }
8202
- function isFunction(value) {
8203
- return typeof value === 'function';
8204
- }
8205
- function getRequestAnimationFrame() {
8206
- return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame;
8207
- }
8208
- function getCancelAnimationFrame() {
8209
- return window.cancelAnimationFrame || window.webkitCancelRequestAnimationFrame || window.webkitCancelAnimationFrame || window.mozCancelAnimationFrame;
8210
- }
8211
- function defer(fn) {
8212
- var hasCancelAnimationFrame = !!getCancelAnimationFrame();
8213
- var deferFn;
8214
- if (hasCancelAnimationFrame) {
8215
- deferFn = getRequestAnimationFrame();
8216
- } else {
8217
- deferFn = function deferFn() {
8218
- return setTimeout(fn, 1000 / 60);
8219
- };
8220
- }
8221
- return deferFn(fn);
8222
- }
8223
- function cancelDefer(deferId) {
8224
- var cancelFn = getCancelAnimationFrame() || clearTimeout;
8225
- cancelFn(deferId);
8226
- }
8227
- var InputElement = /*#__PURE__*/
8228
- function (_React$Component) {
8229
- _inheritsLoose(InputElement, _React$Component);
8230
- function InputElement(props) {
8231
- var _this;
8232
- _this = _React$Component.call(this, props) || this;
8233
- _this.focused = false;
8234
- _this.mounted = false;
8235
- _this.previousSelection = null;
8236
- _this.selectionDeferId = null;
8237
- _this.saveSelectionLoopDeferId = null;
8238
- _this.saveSelectionLoop = function () {
8239
- _this.previousSelection = _this.getSelection();
8240
- _this.saveSelectionLoopDeferId = defer(_this.saveSelectionLoop);
8241
- };
8242
- _this.runSaveSelectionLoop = function () {
8243
- if (_this.saveSelectionLoopDeferId === null) {
8244
- _this.saveSelectionLoop();
8245
- }
8246
- };
8247
- _this.stopSaveSelectionLoop = function () {
8248
- if (_this.saveSelectionLoopDeferId !== null) {
8249
- cancelDefer(_this.saveSelectionLoopDeferId);
8250
- _this.saveSelectionLoopDeferId = null;
8251
- _this.previousSelection = null;
8252
- }
8253
- };
8254
- _this.getInputDOMNode = function () {
8255
- if (!_this.mounted) {
8256
- return null;
8257
- }
8258
- var input = reactDom.findDOMNode(_assertThisInitialized(_assertThisInitialized(_this)));
8259
- var isDOMNode = typeof window !== 'undefined' && input instanceof window.Element; // workaround for react-test-renderer
8260
- // https://github.com/sanniassin/react-input-mask/issues/147
8261
-
8262
- if (input && !isDOMNode) {
8263
- return null;
8264
- }
8265
- if (input.nodeName !== 'INPUT') {
8266
- input = input.querySelector('input');
8267
- }
8268
- if (!input) {
8269
- throw new Error('react-input-mask: inputComponent doesn\'t contain input node');
8270
- }
8271
- return input;
8272
- };
8273
- _this.getInputValue = function () {
8274
- var input = _this.getInputDOMNode();
8275
- if (!input) {
8276
- return null;
8277
- }
8278
- return input.value;
8279
- };
8280
- _this.setInputValue = function (value) {
8281
- var input = _this.getInputDOMNode();
8282
- if (!input) {
8283
- return;
8284
- }
8285
- _this.value = value;
8286
- input.value = value;
8287
- };
8288
- _this.setCursorToEnd = function () {
8289
- var filledLength = getFilledLength(_this.maskOptions, _this.value);
8290
- var pos = getRightEditablePosition(_this.maskOptions, filledLength);
8291
- if (pos !== null) {
8292
- _this.setCursorPosition(pos);
8293
- }
8294
- };
8295
- _this.setSelection = function (start, end, options) {
8296
- if (options === void 0) {
8297
- options = {};
8298
- }
8299
- var input = _this.getInputDOMNode();
8300
- var isFocused = _this.isFocused(); // don't change selection on unfocused input
8301
- // because Safari sets focus on selection change (#154)
8302
-
8303
- if (!input || !isFocused) {
8304
- return;
8305
- }
8306
- var _options = options,
8307
- deferred = _options.deferred;
8308
- if (!deferred) {
8309
- setInputSelection(input, start, end);
8310
- }
8311
- if (_this.selectionDeferId !== null) {
8312
- cancelDefer(_this.selectionDeferId);
8313
- } // deferred selection update is required for pre-Lollipop Android browser,
8314
- // but for consistent behavior we do it for all browsers
8315
-
8316
- _this.selectionDeferId = defer(function () {
8317
- _this.selectionDeferId = null;
8318
- setInputSelection(input, start, end);
8319
- });
8320
- _this.previousSelection = {
8321
- start: start,
8322
- end: end,
8323
- length: Math.abs(end - start)
8324
- };
8325
- };
8326
- _this.getSelection = function () {
8327
- var input = _this.getInputDOMNode();
8328
- return getInputSelection(input);
8329
- };
8330
- _this.getCursorPosition = function () {
8331
- return _this.getSelection().start;
8332
- };
8333
- _this.setCursorPosition = function (pos) {
8334
- _this.setSelection(pos, pos);
8335
- };
8336
- _this.isFocused = function () {
8337
- return _this.focused;
8338
- };
8339
- _this.getBeforeMaskedValueChangeConfig = function () {
8340
- var _this$maskOptions = _this.maskOptions,
8341
- mask = _this$maskOptions.mask,
8342
- maskChar = _this$maskOptions.maskChar,
8343
- permanents = _this$maskOptions.permanents,
8344
- formatChars = _this$maskOptions.formatChars;
8345
- var alwaysShowMask = _this.props.alwaysShowMask;
8346
- return {
8347
- mask: mask,
8348
- maskChar: maskChar,
8349
- permanents: permanents,
8350
- alwaysShowMask: !!alwaysShowMask,
8351
- formatChars: formatChars
8352
- };
8353
- };
8354
- _this.isInputAutofilled = function (value, selection, previousValue, previousSelection) {
8355
- var input = _this.getInputDOMNode(); // only check for positive match because it will be false negative
8356
- // in case of autofill simulation in tests
8357
- //
8358
- // input.matches throws an exception if selector isn't supported
8359
-
8360
- try {
8361
- if (input.matches(':-webkit-autofill')) {
8362
- return true;
8363
- }
8364
- } catch (e) {} // if input isn't focused then change event must have been triggered
8365
- // either by autofill or event simulation in tests
8366
-
8367
- if (!_this.focused) {
8368
- return true;
8369
- } // if cursor has moved to the end while previousSelection forbids it
8370
- // then it must be autofill
8371
-
8372
- return previousSelection.end < previousValue.length && selection.end === value.length;
8373
- };
8374
- _this.onChange = function (event) {
8375
- var _assertThisInitialize = _assertThisInitialized(_assertThisInitialized(_this)),
8376
- beforePasteState = _assertThisInitialize.beforePasteState;
8377
- var _assertThisInitialize2 = _assertThisInitialized(_assertThisInitialized(_this)),
8378
- previousSelection = _assertThisInitialize2.previousSelection;
8379
- var beforeMaskedValueChange = _this.props.beforeMaskedValueChange;
8380
- var value = _this.getInputValue();
8381
- var previousValue = _this.value;
8382
- var selection = _this.getSelection(); // autofill replaces entire value, ignore old one
8383
- // https://github.com/sanniassin/react-input-mask/issues/113
8384
-
8385
- if (_this.isInputAutofilled(value, selection, previousValue, previousSelection)) {
8386
- previousValue = formatValue(_this.maskOptions, '');
8387
- previousSelection = {
8388
- start: 0,
8389
- end: 0,
8390
- length: 0
8391
- };
8392
- } // set value and selection as if we haven't
8393
- // cleared input in onPaste handler
8394
-
8395
- if (beforePasteState) {
8396
- previousSelection = beforePasteState.selection;
8397
- previousValue = beforePasteState.value;
8398
- selection = {
8399
- start: previousSelection.start + value.length,
8400
- end: previousSelection.start + value.length,
8401
- length: 0
8402
- };
8403
- value = previousValue.slice(0, previousSelection.start) + value + previousValue.slice(previousSelection.end);
8404
- _this.beforePasteState = null;
7954
+ if (_this.isInputAutofilled(value, selection, previousValue, previousSelection)) {
7955
+ previousValue = formatValue(_this.maskOptions, '');
7956
+ previousSelection = {
7957
+ start: 0,
7958
+ end: 0,
7959
+ length: 0
7960
+ };
7961
+ } // set value and selection as if we haven't
7962
+ // cleared input in onPaste handler
7963
+
7964
+ if (beforePasteState) {
7965
+ previousSelection = beforePasteState.selection;
7966
+ previousValue = beforePasteState.value;
7967
+ selection = {
7968
+ start: previousSelection.start + value.length,
7969
+ end: previousSelection.start + value.length,
7970
+ length: 0
7971
+ };
7972
+ value = previousValue.slice(0, previousSelection.start) + value + previousValue.slice(previousSelection.end);
7973
+ _this.beforePasteState = null;
8405
7974
  }
8406
7975
  var changedState = processChange(_this.maskOptions, value, selection, previousValue, previousSelection);
8407
7976
  var enteredString = changedState.enteredString;
@@ -8539,207 +8108,718 @@ function requireReactInputMask_development() {
8539
8108
  } // event.clipboardData might not work in Android browser
8540
8109
  // cleaning input to get raw text inside onChange handler
8541
8110
 
8542
- if (!event.defaultPrevented) {
8543
- _this.beforePasteState = {
8544
- value: _this.getInputValue(),
8545
- selection: _this.getSelection()
8546
- };
8547
- _this.setInputValue('');
8548
- }
8111
+ if (!event.defaultPrevented) {
8112
+ _this.beforePasteState = {
8113
+ value: _this.getInputValue(),
8114
+ selection: _this.getSelection()
8115
+ };
8116
+ _this.setInputValue('');
8117
+ }
8118
+ };
8119
+ _this.handleRef = function (ref) {
8120
+ if (_this.props.children == null && isFunction(_this.props.inputRef)) {
8121
+ _this.props.inputRef(ref);
8122
+ }
8123
+ };
8124
+ var _mask = props.mask,
8125
+ _maskChar = props.maskChar,
8126
+ _formatChars = props.formatChars,
8127
+ _alwaysShowMask = props.alwaysShowMask,
8128
+ _beforeMaskedValueChange = props.beforeMaskedValueChange;
8129
+ var defaultValue = props.defaultValue,
8130
+ _value = props.value;
8131
+ _this.maskOptions = parseMask(_mask, _maskChar, _formatChars);
8132
+ if (defaultValue == null) {
8133
+ defaultValue = '';
8134
+ }
8135
+ if (_value == null) {
8136
+ _value = defaultValue;
8137
+ }
8138
+ var _newValue = getStringValue(_value);
8139
+ if (_this.maskOptions.mask && (_alwaysShowMask || _newValue)) {
8140
+ _newValue = formatValue(_this.maskOptions, _newValue);
8141
+ if (isFunction(_beforeMaskedValueChange)) {
8142
+ var oldValue = props.value;
8143
+ if (props.value == null) {
8144
+ oldValue = defaultValue;
8145
+ }
8146
+ oldValue = getStringValue(oldValue);
8147
+ var modifiedValue = _beforeMaskedValueChange({
8148
+ value: _newValue,
8149
+ selection: null
8150
+ }, {
8151
+ value: oldValue,
8152
+ selection: null
8153
+ }, null, _this.getBeforeMaskedValueChangeConfig());
8154
+ _newValue = modifiedValue.value;
8155
+ }
8156
+ }
8157
+ _this.value = _newValue;
8158
+ return _this;
8159
+ }
8160
+ var _proto = InputElement.prototype;
8161
+ _proto.componentDidMount = function componentDidMount() {
8162
+ this.mounted = true; // workaround for react-test-renderer
8163
+ // https://github.com/sanniassin/react-input-mask/issues/147
8164
+
8165
+ if (!this.getInputDOMNode()) {
8166
+ return;
8167
+ }
8168
+ this.isWindowsPhoneBrowser = isWindowsPhoneBrowser();
8169
+ if (this.maskOptions.mask && this.getInputValue() !== this.value) {
8170
+ this.setInputValue(this.value);
8171
+ }
8172
+ };
8173
+ _proto.componentDidUpdate = function componentDidUpdate() {
8174
+ var previousSelection = this.previousSelection;
8175
+ var _this$props = this.props,
8176
+ beforeMaskedValueChange = _this$props.beforeMaskedValueChange,
8177
+ alwaysShowMask = _this$props.alwaysShowMask,
8178
+ mask = _this$props.mask,
8179
+ maskChar = _this$props.maskChar,
8180
+ formatChars = _this$props.formatChars;
8181
+ var previousMaskOptions = this.maskOptions;
8182
+ var showEmpty = alwaysShowMask || this.isFocused();
8183
+ var hasValue = this.props.value != null;
8184
+ var newValue = hasValue ? getStringValue(this.props.value) : this.value;
8185
+ var cursorPosition = previousSelection ? previousSelection.start : null;
8186
+ this.maskOptions = parseMask(mask, maskChar, formatChars);
8187
+ if (!this.maskOptions.mask) {
8188
+ if (previousMaskOptions.mask) {
8189
+ this.stopSaveSelectionLoop(); // render depends on this.maskOptions and this.value,
8190
+ // call forceUpdate to keep it in sync
8191
+
8192
+ this.forceUpdate();
8193
+ }
8194
+ return;
8195
+ } else if (!previousMaskOptions.mask && this.isFocused()) {
8196
+ this.runSaveSelectionLoop();
8197
+ }
8198
+ var isMaskChanged = this.maskOptions.mask && this.maskOptions.mask !== previousMaskOptions.mask;
8199
+ if (!previousMaskOptions.mask && !hasValue) {
8200
+ newValue = this.getInputValue();
8201
+ }
8202
+ if (isMaskChanged || this.maskOptions.mask && (newValue || showEmpty)) {
8203
+ newValue = formatValue(this.maskOptions, newValue);
8204
+ }
8205
+ if (isMaskChanged) {
8206
+ var filledLength = getFilledLength(this.maskOptions, newValue);
8207
+ if (cursorPosition === null || filledLength < cursorPosition) {
8208
+ if (isFilled(this.maskOptions, newValue)) {
8209
+ cursorPosition = filledLength;
8210
+ } else {
8211
+ cursorPosition = getRightEditablePosition(this.maskOptions, filledLength);
8212
+ }
8213
+ }
8214
+ }
8215
+ if (this.maskOptions.mask && isEmpty(this.maskOptions, newValue) && !showEmpty && (!hasValue || !this.props.value)) {
8216
+ newValue = '';
8217
+ }
8218
+ var newSelection = {
8219
+ start: cursorPosition,
8220
+ end: cursorPosition
8221
+ };
8222
+ if (isFunction(beforeMaskedValueChange)) {
8223
+ var modifiedValue = beforeMaskedValueChange({
8224
+ value: newValue,
8225
+ selection: newSelection
8226
+ }, {
8227
+ value: this.value,
8228
+ selection: this.previousSelection
8229
+ }, null, this.getBeforeMaskedValueChangeConfig());
8230
+ newValue = modifiedValue.value;
8231
+ newSelection = modifiedValue.selection;
8232
+ }
8233
+ this.value = newValue;
8234
+ var isValueChanged = this.getInputValue() !== this.value; // render depends on this.maskOptions and this.value,
8235
+ // call forceUpdate to keep it in sync
8236
+
8237
+ if (isValueChanged) {
8238
+ this.setInputValue(this.value);
8239
+ this.forceUpdate();
8240
+ } else if (isMaskChanged) {
8241
+ this.forceUpdate();
8242
+ }
8243
+ var isSelectionChanged = false;
8244
+ if (newSelection.start != null && newSelection.end != null) {
8245
+ isSelectionChanged = !previousSelection || previousSelection.start !== newSelection.start || previousSelection.end !== newSelection.end;
8246
+ }
8247
+ if (isSelectionChanged || isValueChanged) {
8248
+ this.setSelection(newSelection.start, newSelection.end);
8249
+ }
8250
+ };
8251
+ _proto.componentWillUnmount = function componentWillUnmount() {
8252
+ this.mounted = false;
8253
+ if (this.selectionDeferId !== null) {
8254
+ cancelDefer(this.selectionDeferId);
8255
+ }
8256
+ this.stopSaveSelectionLoop();
8257
+ };
8258
+ _proto.render = function render() {
8259
+ var _this$props2 = this.props,
8260
+ mask = _this$props2.mask;
8261
+ _this$props2.alwaysShowMask;
8262
+ var maskChar = _this$props2.maskChar,
8263
+ formatChars = _this$props2.formatChars,
8264
+ inputRef = _this$props2.inputRef;
8265
+ _this$props2.beforeMaskedValueChange;
8266
+ var children = _this$props2.children,
8267
+ restProps = _objectWithoutPropertiesLoose(_this$props2, ["mask", "alwaysShowMask", "maskChar", "formatChars", "inputRef", "beforeMaskedValueChange", "children"]);
8268
+ var inputElement;
8269
+ process.env.NODE_ENV !== "production" ? warning(
8270
+ // parse mask to test against actual mask prop as this.maskOptions
8271
+ // will be updated later in componentDidUpdate
8272
+ !restProps.maxLength || !parseMask(mask, maskChar, formatChars).mask, 'react-input-mask: maxLength property shouldn\'t be passed to the masked input. It breaks masking and unnecessary because length is limited by the mask length.') : void 0;
8273
+ if (children) {
8274
+ !isFunction(children) ? process.env.NODE_ENV !== "production" ? invariant(false, 'react-input-mask: children must be a function') : invariant(false) : void 0;
8275
+ var controlledProps = ['onChange', 'onPaste', 'onMouseDown', 'onFocus', 'onBlur', 'value', 'disabled', 'readOnly'];
8276
+ var childrenProps = _extends({}, restProps);
8277
+ controlledProps.forEach(function (propId) {
8278
+ return delete childrenProps[propId];
8279
+ });
8280
+ inputElement = children(childrenProps);
8281
+ var conflictProps = controlledProps.filter(function (propId) {
8282
+ return inputElement.props[propId] != null && inputElement.props[propId] !== restProps[propId];
8283
+ });
8284
+ !!conflictProps.length ? process.env.NODE_ENV !== "production" ? invariant(false, "react-input-mask: the following props should be passed to the react-input-mask's component and should not be altered in children's function: " + conflictProps.join(', ')) : invariant(false) : void 0;
8285
+ process.env.NODE_ENV !== "production" ? warning(!inputRef, 'react-input-mask: inputRef is ignored when children is passed, attach ref to the children instead') : void 0;
8286
+ } else {
8287
+ inputElement = React$1.createElement("input", _extends({
8288
+ ref: this.handleRef
8289
+ }, restProps));
8290
+ }
8291
+ var changedProps = {
8292
+ onFocus: this.onFocus,
8293
+ onBlur: this.onBlur
8549
8294
  };
8550
- _this.handleRef = function (ref) {
8551
- if (_this.props.children == null && isFunction(_this.props.inputRef)) {
8552
- _this.props.inputRef(ref);
8295
+ if (this.maskOptions.mask) {
8296
+ if (!restProps.disabled && !restProps.readOnly) {
8297
+ changedProps.onChange = this.onChange;
8298
+ changedProps.onPaste = this.onPaste;
8299
+ changedProps.onMouseDown = this.onMouseDown;
8300
+ }
8301
+ if (restProps.value != null) {
8302
+ changedProps.value = this.value;
8553
8303
  }
8554
- };
8555
- var _mask = props.mask,
8556
- _maskChar = props.maskChar,
8557
- _formatChars = props.formatChars,
8558
- _alwaysShowMask = props.alwaysShowMask,
8559
- _beforeMaskedValueChange = props.beforeMaskedValueChange;
8560
- var defaultValue = props.defaultValue,
8561
- _value = props.value;
8562
- _this.maskOptions = parseMask(_mask, _maskChar, _formatChars);
8563
- if (defaultValue == null) {
8564
- defaultValue = '';
8565
8304
  }
8566
- if (_value == null) {
8567
- _value = defaultValue;
8305
+ inputElement = React$1.cloneElement(inputElement, changedProps);
8306
+ return inputElement;
8307
+ };
8308
+ return InputElement;
8309
+ }(React$1.Component);
8310
+ reactInputMask_development = InputElement;
8311
+ return reactInputMask_development;
8312
+ }
8313
+
8314
+ var reactInputMask_production_min;
8315
+ var hasRequiredReactInputMask_production_min;
8316
+ function requireReactInputMask_production_min() {
8317
+ if (hasRequiredReactInputMask_production_min) return reactInputMask_production_min;
8318
+ hasRequiredReactInputMask_production_min = 1;
8319
+ function _interopDefault(e) {
8320
+ return e && "object" == _typeof$1(e) && "default" in e ? e["default"] : e;
8321
+ }
8322
+ var React$1 = _interopDefault(React),
8323
+ reactDom = require$$1;
8324
+ function _defaults2(e, t) {
8325
+ for (var n = Object.getOwnPropertyNames(t), a = 0; a < n.length; a++) {
8326
+ var i = n[a],
8327
+ r = Object.getOwnPropertyDescriptor(t, i);
8328
+ r && r.configurable && e[i] === undefined && Object.defineProperty(e, i, r);
8329
+ }
8330
+ return e;
8331
+ }
8332
+ function _extends() {
8333
+ return (_extends = Object.assign || function (e) {
8334
+ for (var t = 1; t < arguments.length; t++) {
8335
+ var n = arguments[t];
8336
+ for (var a in n) Object.prototype.hasOwnProperty.call(n, a) && (e[a] = n[a]);
8568
8337
  }
8569
- var _newValue = getStringValue(_value);
8570
- if (_this.maskOptions.mask && (_alwaysShowMask || _newValue)) {
8571
- _newValue = formatValue(_this.maskOptions, _newValue);
8572
- if (isFunction(_beforeMaskedValueChange)) {
8573
- var oldValue = props.value;
8574
- if (props.value == null) {
8575
- oldValue = defaultValue;
8576
- }
8577
- oldValue = getStringValue(oldValue);
8578
- var modifiedValue = _beforeMaskedValueChange({
8579
- value: _newValue,
8580
- selection: null
8581
- }, {
8582
- value: oldValue,
8583
- selection: null
8584
- }, null, _this.getBeforeMaskedValueChangeConfig());
8585
- _newValue = modifiedValue.value;
8338
+ return e;
8339
+ }).apply(this, arguments);
8340
+ }
8341
+ function _inheritsLoose(e, t) {
8342
+ e.prototype = Object.create(t.prototype), _defaults2(e.prototype.constructor = e, t);
8343
+ }
8344
+ function _objectWithoutPropertiesLoose(e, t) {
8345
+ if (null == e) return {};
8346
+ var n,
8347
+ a,
8348
+ i = {},
8349
+ r = Object.keys(e);
8350
+ for (a = 0; a < r.length; a++) n = r[a], 0 <= t.indexOf(n) || (i[n] = e[n]);
8351
+ return i;
8352
+ }
8353
+ function _assertThisInitialized(e) {
8354
+ if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
8355
+ return e;
8356
+ }
8357
+ var invariant = function invariant(e, t, n, a, i, r, o, s) {
8358
+ if (!e) {
8359
+ var l;
8360
+ if (t === undefined) l = new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else {
8361
+ var u = [n, a, i, r, o, s],
8362
+ c = 0;
8363
+ (l = new Error(t.replace(/%s/g, function () {
8364
+ return u[c++];
8365
+ }))).name = "Invariant Violation";
8586
8366
  }
8367
+ throw l.framesToPop = 1, l;
8368
+ }
8369
+ },
8370
+ invariant_1 = invariant;
8371
+ function setInputSelection(e, t, n) {
8372
+ if ("selectionStart" in e && "selectionEnd" in e) e.selectionStart = t, e.selectionEnd = n;else {
8373
+ var a = e.createTextRange();
8374
+ a.collapse(!0), a.moveStart("character", t), a.moveEnd("character", n - t), a.select();
8375
+ }
8376
+ }
8377
+ function getInputSelection(e) {
8378
+ var t = 0,
8379
+ n = 0;
8380
+ if ("selectionStart" in e && "selectionEnd" in e) t = e.selectionStart, n = e.selectionEnd;else {
8381
+ var a = document.selection.createRange();
8382
+ a.parentElement() === e && (t = -a.moveStart("character", -e.value.length), n = -a.moveEnd("character", -e.value.length));
8383
+ }
8384
+ return {
8385
+ start: t,
8386
+ end: n,
8387
+ length: n - t
8388
+ };
8389
+ }
8390
+ var defaultFormatChars = {
8391
+ 9: "[0-9]",
8392
+ a: "[A-Za-z]",
8393
+ "*": "[A-Za-z0-9]"
8394
+ },
8395
+ defaultMaskChar = "_";
8396
+ function parseMask(e, t, n) {
8397
+ var a = "",
8398
+ i = "",
8399
+ r = null,
8400
+ o = [];
8401
+ if (t === undefined && (t = defaultMaskChar), null == n && (n = defaultFormatChars), !e || "string" != typeof e) return {
8402
+ maskChar: t,
8403
+ formatChars: n,
8404
+ mask: null,
8405
+ prefix: null,
8406
+ lastEditablePosition: null,
8407
+ permanents: []
8408
+ };
8409
+ var s = !1;
8410
+ return e.split("").forEach(function (e) {
8411
+ s = !s && "\\" === e || (s || !n[e] ? (o.push(a.length), a.length === o.length - 1 && (i += e)) : r = a.length + 1, a += e, !1);
8412
+ }), {
8413
+ maskChar: t,
8414
+ formatChars: n,
8415
+ prefix: i,
8416
+ mask: a,
8417
+ lastEditablePosition: r,
8418
+ permanents: o
8419
+ };
8420
+ }
8421
+ function isPermanentCharacter(e, t) {
8422
+ return -1 !== e.permanents.indexOf(t);
8423
+ }
8424
+ function isAllowedCharacter(e, t, n) {
8425
+ var a = e.mask,
8426
+ i = e.formatChars;
8427
+ if (!n) return !1;
8428
+ if (isPermanentCharacter(e, t)) return a[t] === n;
8429
+ var r = i[a[t]];
8430
+ return new RegExp(r).test(n);
8431
+ }
8432
+ function isEmpty(n, e) {
8433
+ return e.split("").every(function (e, t) {
8434
+ return isPermanentCharacter(n, t) || !isAllowedCharacter(n, t, e);
8435
+ });
8436
+ }
8437
+ function getFilledLength(e, t) {
8438
+ var n = e.maskChar,
8439
+ a = e.prefix;
8440
+ if (!n) {
8441
+ for (; t.length > a.length && isPermanentCharacter(e, t.length - 1);) t = t.slice(0, t.length - 1);
8442
+ return t.length;
8443
+ }
8444
+ for (var i = a.length, r = t.length; r >= a.length; r--) {
8445
+ var o = t[r];
8446
+ if (!isPermanentCharacter(e, r) && isAllowedCharacter(e, r, o)) {
8447
+ i = r + 1;
8448
+ break;
8587
8449
  }
8588
- _this.value = _newValue;
8589
- return _this;
8590
8450
  }
8591
- var _proto = InputElement.prototype;
8592
- _proto.componentDidMount = function componentDidMount() {
8593
- this.mounted = true; // workaround for react-test-renderer
8594
- // https://github.com/sanniassin/react-input-mask/issues/147
8595
-
8596
- if (!this.getInputDOMNode()) {
8597
- return;
8451
+ return i;
8452
+ }
8453
+ function isFilled(e, t) {
8454
+ return getFilledLength(e, t) === e.mask.length;
8455
+ }
8456
+ function formatValue(e, t) {
8457
+ var n = e.maskChar,
8458
+ a = e.mask,
8459
+ i = e.prefix;
8460
+ if (!n) {
8461
+ for ((t = insertString(e, "", t, 0)).length < i.length && (t = i); t.length < a.length && isPermanentCharacter(e, t.length);) t += a[t.length];
8462
+ return t;
8463
+ }
8464
+ if (t) return insertString(e, formatValue(e, ""), t, 0);
8465
+ for (var r = 0; r < a.length; r++) isPermanentCharacter(e, r) ? t += a[r] : t += n;
8466
+ return t;
8467
+ }
8468
+ function clearRange(n, e, a, t) {
8469
+ var i = a + t,
8470
+ r = n.maskChar,
8471
+ o = n.mask,
8472
+ s = n.prefix,
8473
+ l = e.split("");
8474
+ if (r) return l.map(function (e, t) {
8475
+ return t < a || i <= t ? e : isPermanentCharacter(n, t) ? o[t] : r;
8476
+ }).join("");
8477
+ for (var u = i; u < l.length; u++) isPermanentCharacter(n, u) && (l[u] = "");
8478
+ return a = Math.max(s.length, a), l.splice(a, i - a), e = l.join(""), formatValue(n, e);
8479
+ }
8480
+ function insertString(r, o, e, s) {
8481
+ var l = r.mask,
8482
+ u = r.maskChar,
8483
+ c = r.prefix,
8484
+ t = e.split(""),
8485
+ h = isFilled(r, o);
8486
+ return !u && s > o.length && (o += l.slice(o.length, s)), t.every(function (e) {
8487
+ for (; i = e, isPermanentCharacter(r, a = s) && i !== l[a];) {
8488
+ if (s >= o.length && (o += l[s]), t = e, n = s, u && isPermanentCharacter(r, n) && t === u) return !0;
8489
+ if (++s >= l.length) return !1;
8598
8490
  }
8599
- this.isWindowsPhoneBrowser = isWindowsPhoneBrowser();
8600
- if (this.maskOptions.mask && this.getInputValue() !== this.value) {
8601
- this.setInputValue(this.value);
8491
+ var t, n, a, i;
8492
+ return !isAllowedCharacter(r, s, e) && e !== u || (s < o.length ? o = u || h || s < c.length ? o.slice(0, s) + e + o.slice(s + 1) : (o = o.slice(0, s) + e + o.slice(s), formatValue(r, o)) : u || (o += e), ++s < l.length);
8493
+ }), o;
8494
+ }
8495
+ function getInsertStringLength(a, e, t, i) {
8496
+ var r = a.mask,
8497
+ o = a.maskChar,
8498
+ n = t.split(""),
8499
+ s = i;
8500
+ return n.every(function (e) {
8501
+ for (; n = e, isPermanentCharacter(a, t = i) && n !== r[t];) if (++i >= r.length) return !1;
8502
+ var t, n;
8503
+ return (isAllowedCharacter(a, i, e) || e === o) && i++, i < r.length;
8504
+ }), i - s;
8505
+ }
8506
+ function getLeftEditablePosition(e, t) {
8507
+ for (var n = t; 0 <= n; --n) if (!isPermanentCharacter(e, n)) return n;
8508
+ return null;
8509
+ }
8510
+ function getRightEditablePosition(e, t) {
8511
+ for (var n = e.mask, a = t; a < n.length; ++a) if (!isPermanentCharacter(e, a)) return a;
8512
+ return null;
8513
+ }
8514
+ function getStringValue(e) {
8515
+ return e || 0 === e ? e + "" : "";
8516
+ }
8517
+ function processChange(e, t, n, a, i) {
8518
+ var r = e.mask,
8519
+ o = e.prefix,
8520
+ s = e.lastEditablePosition,
8521
+ l = t,
8522
+ u = "",
8523
+ c = 0,
8524
+ h = 0,
8525
+ f = Math.min(i.start, n.start);
8526
+ if (n.end > i.start ? h = (c = getInsertStringLength(e, a, u = l.slice(i.start, n.end), f)) ? i.length : 0 : l.length < a.length && (h = a.length - l.length), l = a, h) {
8527
+ if (1 === h && !i.length) f = i.start === n.start ? getRightEditablePosition(e, n.start) : getLeftEditablePosition(e, n.start);
8528
+ l = clearRange(e, l, f, h);
8529
+ }
8530
+ return l = insertString(e, l, u, f), (f += c) >= r.length ? f = r.length : f < o.length && !c ? f = o.length : f >= o.length && f < s && c && (f = getRightEditablePosition(e, f)), u || (u = null), {
8531
+ value: l = formatValue(e, l),
8532
+ enteredString: u,
8533
+ selection: {
8534
+ start: f,
8535
+ end: f
8602
8536
  }
8603
8537
  };
8604
- _proto.componentDidUpdate = function componentDidUpdate() {
8605
- var previousSelection = this.previousSelection;
8606
- var _this$props = this.props,
8607
- beforeMaskedValueChange = _this$props.beforeMaskedValueChange,
8608
- alwaysShowMask = _this$props.alwaysShowMask,
8609
- mask = _this$props.mask,
8610
- maskChar = _this$props.maskChar,
8611
- formatChars = _this$props.formatChars;
8612
- var previousMaskOptions = this.maskOptions;
8613
- var showEmpty = alwaysShowMask || this.isFocused();
8614
- var hasValue = this.props.value != null;
8615
- var newValue = hasValue ? getStringValue(this.props.value) : this.value;
8616
- var cursorPosition = previousSelection ? previousSelection.start : null;
8617
- this.maskOptions = parseMask(mask, maskChar, formatChars);
8618
- if (!this.maskOptions.mask) {
8619
- if (previousMaskOptions.mask) {
8620
- this.stopSaveSelectionLoop(); // render depends on this.maskOptions and this.value,
8621
- // call forceUpdate to keep it in sync
8622
-
8623
- this.forceUpdate();
8538
+ }
8539
+ function isWindowsPhoneBrowser() {
8540
+ var e = new RegExp("windows", "i"),
8541
+ t = new RegExp("phone", "i"),
8542
+ n = navigator.userAgent;
8543
+ return e.test(n) && t.test(n);
8544
+ }
8545
+ function isFunction(e) {
8546
+ return "function" == typeof e;
8547
+ }
8548
+ function getRequestAnimationFrame() {
8549
+ return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame;
8550
+ }
8551
+ function getCancelAnimationFrame() {
8552
+ return window.cancelAnimationFrame || window.webkitCancelRequestAnimationFrame || window.webkitCancelAnimationFrame || window.mozCancelAnimationFrame;
8553
+ }
8554
+ function defer(e) {
8555
+ return (!!getCancelAnimationFrame() ? getRequestAnimationFrame() : function () {
8556
+ return setTimeout(e, 1e3 / 60);
8557
+ })(e);
8558
+ }
8559
+ function cancelDefer(e) {
8560
+ (getCancelAnimationFrame() || clearTimeout)(e);
8561
+ }
8562
+ var InputElement = function (c) {
8563
+ function e(e) {
8564
+ var f = c.call(this, e) || this;
8565
+ f.focused = !1, f.mounted = !1, f.previousSelection = null, f.selectionDeferId = null, f.saveSelectionLoopDeferId = null, f.saveSelectionLoop = function () {
8566
+ f.previousSelection = f.getSelection(), f.saveSelectionLoopDeferId = defer(f.saveSelectionLoop);
8567
+ }, f.runSaveSelectionLoop = function () {
8568
+ null === f.saveSelectionLoopDeferId && f.saveSelectionLoop();
8569
+ }, f.stopSaveSelectionLoop = function () {
8570
+ null !== f.saveSelectionLoopDeferId && (cancelDefer(f.saveSelectionLoopDeferId), f.saveSelectionLoopDeferId = null, f.previousSelection = null);
8571
+ }, f.getInputDOMNode = function () {
8572
+ if (!f.mounted) return null;
8573
+ var e = reactDom.findDOMNode(_assertThisInitialized(_assertThisInitialized(f))),
8574
+ t = "undefined" != typeof window && e instanceof window.Element;
8575
+ if (e && !t) return null;
8576
+ if ("INPUT" !== e.nodeName && (e = e.querySelector("input")), !e) throw new Error("react-input-mask: inputComponent doesn't contain input node");
8577
+ return e;
8578
+ }, f.getInputValue = function () {
8579
+ var e = f.getInputDOMNode();
8580
+ return e ? e.value : null;
8581
+ }, f.setInputValue = function (e) {
8582
+ var t = f.getInputDOMNode();
8583
+ t && (f.value = e, t.value = e);
8584
+ }, f.setCursorToEnd = function () {
8585
+ var e = getFilledLength(f.maskOptions, f.value),
8586
+ t = getRightEditablePosition(f.maskOptions, e);
8587
+ null !== t && f.setCursorPosition(t);
8588
+ }, f.setSelection = function (e, t, n) {
8589
+ void 0 === n && (n = {});
8590
+ var a = f.getInputDOMNode(),
8591
+ i = f.isFocused();
8592
+ a && i && (n.deferred || setInputSelection(a, e, t), null !== f.selectionDeferId && cancelDefer(f.selectionDeferId), f.selectionDeferId = defer(function () {
8593
+ f.selectionDeferId = null, setInputSelection(a, e, t);
8594
+ }), f.previousSelection = {
8595
+ start: e,
8596
+ end: t,
8597
+ length: Math.abs(t - e)
8598
+ });
8599
+ }, f.getSelection = function () {
8600
+ return getInputSelection(f.getInputDOMNode());
8601
+ }, f.getCursorPosition = function () {
8602
+ return f.getSelection().start;
8603
+ }, f.setCursorPosition = function (e) {
8604
+ f.setSelection(e, e);
8605
+ }, f.isFocused = function () {
8606
+ return f.focused;
8607
+ }, f.getBeforeMaskedValueChangeConfig = function () {
8608
+ var e = f.maskOptions,
8609
+ t = e.mask,
8610
+ n = e.maskChar,
8611
+ a = e.permanents,
8612
+ i = e.formatChars;
8613
+ return {
8614
+ mask: t,
8615
+ maskChar: n,
8616
+ permanents: a,
8617
+ alwaysShowMask: !!f.props.alwaysShowMask,
8618
+ formatChars: i
8619
+ };
8620
+ }, f.isInputAutofilled = function (e, t, n, a) {
8621
+ var i = f.getInputDOMNode();
8622
+ try {
8623
+ if (i.matches(":-webkit-autofill")) return !0;
8624
+ } catch (r) {}
8625
+ return !f.focused || a.end < n.length && t.end === e.length;
8626
+ }, f.onChange = function (e) {
8627
+ var t = _assertThisInitialized(_assertThisInitialized(f)).beforePasteState,
8628
+ n = _assertThisInitialized(_assertThisInitialized(f)).previousSelection,
8629
+ a = f.props.beforeMaskedValueChange,
8630
+ i = f.getInputValue(),
8631
+ r = f.value,
8632
+ o = f.getSelection();
8633
+ f.isInputAutofilled(i, o, r, n) && (r = formatValue(f.maskOptions, ""), n = {
8634
+ start: 0,
8635
+ end: 0,
8636
+ length: 0
8637
+ }), t && (n = t.selection, r = t.value, o = {
8638
+ start: n.start + i.length,
8639
+ end: n.start + i.length,
8640
+ length: 0
8641
+ }, i = r.slice(0, n.start) + i + r.slice(n.end), f.beforePasteState = null);
8642
+ var s = processChange(f.maskOptions, i, o, r, n),
8643
+ l = s.enteredString,
8644
+ u = s.selection,
8645
+ c = s.value;
8646
+ if (isFunction(a)) {
8647
+ var h = a({
8648
+ value: c,
8649
+ selection: u
8650
+ }, {
8651
+ value: r,
8652
+ selection: n
8653
+ }, l, f.getBeforeMaskedValueChangeConfig());
8654
+ c = h.value, u = h.selection;
8624
8655
  }
8625
- return;
8626
- } else if (!previousMaskOptions.mask && this.isFocused()) {
8627
- this.runSaveSelectionLoop();
8628
- }
8629
- var isMaskChanged = this.maskOptions.mask && this.maskOptions.mask !== previousMaskOptions.mask;
8630
- if (!previousMaskOptions.mask && !hasValue) {
8631
- newValue = this.getInputValue();
8632
- }
8633
- if (isMaskChanged || this.maskOptions.mask && (newValue || showEmpty)) {
8634
- newValue = formatValue(this.maskOptions, newValue);
8635
- }
8636
- if (isMaskChanged) {
8637
- var filledLength = getFilledLength(this.maskOptions, newValue);
8638
- if (cursorPosition === null || filledLength < cursorPosition) {
8639
- if (isFilled(this.maskOptions, newValue)) {
8640
- cursorPosition = filledLength;
8641
- } else {
8642
- cursorPosition = getRightEditablePosition(this.maskOptions, filledLength);
8656
+ f.setInputValue(c), isFunction(f.props.onChange) && f.props.onChange(e), f.isWindowsPhoneBrowser ? f.setSelection(u.start, u.end, {
8657
+ deferred: !0
8658
+ }) : f.setSelection(u.start, u.end);
8659
+ }, f.onFocus = function (e) {
8660
+ var t = f.props.beforeMaskedValueChange,
8661
+ n = f.maskOptions,
8662
+ a = n.mask,
8663
+ i = n.prefix;
8664
+ if (f.focused = !0, f.mounted = !0, a) {
8665
+ if (f.value) getFilledLength(f.maskOptions, f.value) < f.maskOptions.mask.length && f.setCursorToEnd();else {
8666
+ var r = formatValue(f.maskOptions, i),
8667
+ o = formatValue(f.maskOptions, r),
8668
+ s = getFilledLength(f.maskOptions, o),
8669
+ l = getRightEditablePosition(f.maskOptions, s),
8670
+ u = {
8671
+ start: l,
8672
+ end: l
8673
+ };
8674
+ if (isFunction(t)) {
8675
+ var c = t({
8676
+ value: o,
8677
+ selection: u
8678
+ }, {
8679
+ value: f.value,
8680
+ selection: null
8681
+ }, null, f.getBeforeMaskedValueChangeConfig());
8682
+ o = c.value, u = c.selection;
8683
+ }
8684
+ var h = o !== f.getInputValue();
8685
+ h && f.setInputValue(o), h && isFunction(f.props.onChange) && f.props.onChange(e), f.setSelection(u.start, u.end);
8643
8686
  }
8687
+ f.runSaveSelectionLoop();
8644
8688
  }
8645
- }
8646
- if (this.maskOptions.mask && isEmpty(this.maskOptions, newValue) && !showEmpty && (!hasValue || !this.props.value)) {
8647
- newValue = '';
8648
- }
8649
- var newSelection = {
8650
- start: cursorPosition,
8651
- end: cursorPosition
8689
+ isFunction(f.props.onFocus) && f.props.onFocus(e);
8690
+ }, f.onBlur = function (e) {
8691
+ var t = f.props.beforeMaskedValueChange,
8692
+ n = f.maskOptions.mask;
8693
+ if (f.stopSaveSelectionLoop(), f.focused = !1, n && !f.props.alwaysShowMask && isEmpty(f.maskOptions, f.value)) {
8694
+ var a = "";
8695
+ if (isFunction(t)) a = t({
8696
+ value: a,
8697
+ selection: null
8698
+ }, {
8699
+ value: f.value,
8700
+ selection: f.previousSelection
8701
+ }, null, f.getBeforeMaskedValueChangeConfig()).value;
8702
+ var i = a !== f.getInputValue();
8703
+ i && f.setInputValue(a), i && isFunction(f.props.onChange) && f.props.onChange(e);
8704
+ }
8705
+ isFunction(f.props.onBlur) && f.props.onBlur(e);
8706
+ }, f.onMouseDown = function (e) {
8707
+ if (!f.focused && document.addEventListener) {
8708
+ f.mouseDownX = e.clientX, f.mouseDownY = e.clientY, f.mouseDownTime = new Date().getTime();
8709
+ var r = function r(e) {
8710
+ if (document.removeEventListener("mouseup", r), f.focused) {
8711
+ var t = Math.abs(e.clientX - f.mouseDownX),
8712
+ n = Math.abs(e.clientY - f.mouseDownY),
8713
+ a = Math.max(t, n),
8714
+ i = new Date().getTime() - f.mouseDownTime;
8715
+ (a <= 10 && i <= 200 || a <= 5 && i <= 300) && f.setCursorToEnd();
8716
+ }
8717
+ };
8718
+ document.addEventListener("mouseup", r);
8719
+ }
8720
+ isFunction(f.props.onMouseDown) && f.props.onMouseDown(e);
8721
+ }, f.onPaste = function (e) {
8722
+ isFunction(f.props.onPaste) && f.props.onPaste(e), e.defaultPrevented || (f.beforePasteState = {
8723
+ value: f.getInputValue(),
8724
+ selection: f.getSelection()
8725
+ }, f.setInputValue(""));
8726
+ }, f.handleRef = function (e) {
8727
+ null == f.props.children && isFunction(f.props.inputRef) && f.props.inputRef(e);
8652
8728
  };
8653
- if (isFunction(beforeMaskedValueChange)) {
8654
- var modifiedValue = beforeMaskedValueChange({
8655
- value: newValue,
8656
- selection: newSelection
8729
+ var t = e.mask,
8730
+ n = e.maskChar,
8731
+ a = e.formatChars,
8732
+ i = e.alwaysShowMask,
8733
+ r = e.beforeMaskedValueChange,
8734
+ o = e.defaultValue,
8735
+ s = e.value;
8736
+ f.maskOptions = parseMask(t, n, a), null == o && (o = ""), null == s && (s = o);
8737
+ var l = getStringValue(s);
8738
+ if (f.maskOptions.mask && (i || l) && (l = formatValue(f.maskOptions, l), isFunction(r))) {
8739
+ var u = e.value;
8740
+ null == e.value && (u = o), l = r({
8741
+ value: l,
8742
+ selection: null
8657
8743
  }, {
8658
- value: this.value,
8659
- selection: this.previousSelection
8660
- }, null, this.getBeforeMaskedValueChangeConfig());
8661
- newValue = modifiedValue.value;
8662
- newSelection = modifiedValue.selection;
8663
- }
8664
- this.value = newValue;
8665
- var isValueChanged = this.getInputValue() !== this.value; // render depends on this.maskOptions and this.value,
8666
- // call forceUpdate to keep it in sync
8667
-
8668
- if (isValueChanged) {
8669
- this.setInputValue(this.value);
8670
- this.forceUpdate();
8671
- } else if (isMaskChanged) {
8672
- this.forceUpdate();
8673
- }
8674
- var isSelectionChanged = false;
8675
- if (newSelection.start != null && newSelection.end != null) {
8676
- isSelectionChanged = !previousSelection || previousSelection.start !== newSelection.start || previousSelection.end !== newSelection.end;
8677
- }
8678
- if (isSelectionChanged || isValueChanged) {
8679
- this.setSelection(newSelection.start, newSelection.end);
8680
- }
8681
- };
8682
- _proto.componentWillUnmount = function componentWillUnmount() {
8683
- this.mounted = false;
8684
- if (this.selectionDeferId !== null) {
8685
- cancelDefer(this.selectionDeferId);
8686
- }
8687
- this.stopSaveSelectionLoop();
8688
- };
8689
- _proto.render = function render() {
8690
- var _this$props2 = this.props,
8691
- mask = _this$props2.mask;
8692
- _this$props2.alwaysShowMask;
8693
- var maskChar = _this$props2.maskChar,
8694
- formatChars = _this$props2.formatChars,
8695
- inputRef = _this$props2.inputRef;
8696
- _this$props2.beforeMaskedValueChange;
8697
- var children = _this$props2.children,
8698
- restProps = _objectWithoutPropertiesLoose(_this$props2, ["mask", "alwaysShowMask", "maskChar", "formatChars", "inputRef", "beforeMaskedValueChange", "children"]);
8699
- var inputElement;
8700
- process.env.NODE_ENV !== "production" ? warning(
8701
- // parse mask to test against actual mask prop as this.maskOptions
8702
- // will be updated later in componentDidUpdate
8703
- !restProps.maxLength || !parseMask(mask, maskChar, formatChars).mask, 'react-input-mask: maxLength property shouldn\'t be passed to the masked input. It breaks masking and unnecessary because length is limited by the mask length.') : void 0;
8704
- if (children) {
8705
- !isFunction(children) ? process.env.NODE_ENV !== "production" ? invariant(false, 'react-input-mask: children must be a function') : invariant(false) : void 0;
8706
- var controlledProps = ['onChange', 'onPaste', 'onMouseDown', 'onFocus', 'onBlur', 'value', 'disabled', 'readOnly'];
8707
- var childrenProps = _extends({}, restProps);
8708
- controlledProps.forEach(function (propId) {
8709
- return delete childrenProps[propId];
8710
- });
8711
- inputElement = children(childrenProps);
8712
- var conflictProps = controlledProps.filter(function (propId) {
8713
- return inputElement.props[propId] != null && inputElement.props[propId] !== restProps[propId];
8714
- });
8715
- !!conflictProps.length ? process.env.NODE_ENV !== "production" ? invariant(false, "react-input-mask: the following props should be passed to the react-input-mask's component and should not be altered in children's function: " + conflictProps.join(', ')) : invariant(false) : void 0;
8716
- process.env.NODE_ENV !== "production" ? warning(!inputRef, 'react-input-mask: inputRef is ignored when children is passed, attach ref to the children instead') : void 0;
8717
- } else {
8718
- inputElement = React$1.createElement("input", _extends({
8719
- ref: this.handleRef
8720
- }, restProps));
8744
+ value: u = getStringValue(u),
8745
+ selection: null
8746
+ }, null, f.getBeforeMaskedValueChangeConfig()).value;
8721
8747
  }
8722
- var changedProps = {
8748
+ return f.value = l, f;
8749
+ }
8750
+ _inheritsLoose(e, c);
8751
+ var t = e.prototype;
8752
+ return t.componentDidMount = function () {
8753
+ this.mounted = !0, this.getInputDOMNode() && (this.isWindowsPhoneBrowser = isWindowsPhoneBrowser(), this.maskOptions.mask && this.getInputValue() !== this.value && this.setInputValue(this.value));
8754
+ }, t.componentDidUpdate = function () {
8755
+ var e = this.previousSelection,
8756
+ t = this.props,
8757
+ n = t.beforeMaskedValueChange,
8758
+ a = t.alwaysShowMask,
8759
+ i = t.mask,
8760
+ r = t.maskChar,
8761
+ o = t.formatChars,
8762
+ s = this.maskOptions,
8763
+ l = a || this.isFocused(),
8764
+ u = null != this.props.value,
8765
+ c = u ? getStringValue(this.props.value) : this.value,
8766
+ h = e ? e.start : null;
8767
+ if (this.maskOptions = parseMask(i, r, o), this.maskOptions.mask) {
8768
+ !s.mask && this.isFocused() && this.runSaveSelectionLoop();
8769
+ var f = this.maskOptions.mask && this.maskOptions.mask !== s.mask;
8770
+ if (s.mask || u || (c = this.getInputValue()), (f || this.maskOptions.mask && (c || l)) && (c = formatValue(this.maskOptions, c)), f) {
8771
+ var p = getFilledLength(this.maskOptions, c);
8772
+ (null === h || p < h) && (h = isFilled(this.maskOptions, c) ? p : getRightEditablePosition(this.maskOptions, p));
8773
+ }
8774
+ !this.maskOptions.mask || !isEmpty(this.maskOptions, c) || l || u && this.props.value || (c = "");
8775
+ var d = {
8776
+ start: h,
8777
+ end: h
8778
+ };
8779
+ if (isFunction(n)) {
8780
+ var m = n({
8781
+ value: c,
8782
+ selection: d
8783
+ }, {
8784
+ value: this.value,
8785
+ selection: this.previousSelection
8786
+ }, null, this.getBeforeMaskedValueChangeConfig());
8787
+ c = m.value, d = m.selection;
8788
+ }
8789
+ this.value = c;
8790
+ var g = this.getInputValue() !== this.value;
8791
+ g ? (this.setInputValue(this.value), this.forceUpdate()) : f && this.forceUpdate();
8792
+ var v = !1;
8793
+ null != d.start && null != d.end && (v = !e || e.start !== d.start || e.end !== d.end), (v || g) && this.setSelection(d.start, d.end);
8794
+ } else s.mask && (this.stopSaveSelectionLoop(), this.forceUpdate());
8795
+ }, t.componentWillUnmount = function () {
8796
+ this.mounted = !1, null !== this.selectionDeferId && cancelDefer(this.selectionDeferId), this.stopSaveSelectionLoop();
8797
+ }, t.render = function () {
8798
+ var t,
8799
+ e = this.props,
8800
+ n = (e.mask, e.alwaysShowMask, e.maskChar, e.formatChars, e.inputRef, e.beforeMaskedValueChange, e.children),
8801
+ a = _objectWithoutPropertiesLoose(e, ["mask", "alwaysShowMask", "maskChar", "formatChars", "inputRef", "beforeMaskedValueChange", "children"]);
8802
+ if (n) {
8803
+ isFunction(n) || invariant_1(!1);
8804
+ var i = ["onChange", "onPaste", "onMouseDown", "onFocus", "onBlur", "value", "disabled", "readOnly"],
8805
+ r = _extends({}, a);
8806
+ i.forEach(function (e) {
8807
+ return delete r[e];
8808
+ }), t = n(r), i.filter(function (e) {
8809
+ return null != t.props[e] && t.props[e] !== a[e];
8810
+ }).length && invariant_1(!1);
8811
+ } else t = React$1.createElement("input", _extends({
8812
+ ref: this.handleRef
8813
+ }, a));
8814
+ var o = {
8723
8815
  onFocus: this.onFocus,
8724
8816
  onBlur: this.onBlur
8725
8817
  };
8726
- if (this.maskOptions.mask) {
8727
- if (!restProps.disabled && !restProps.readOnly) {
8728
- changedProps.onChange = this.onChange;
8729
- changedProps.onPaste = this.onPaste;
8730
- changedProps.onMouseDown = this.onMouseDown;
8731
- }
8732
- if (restProps.value != null) {
8733
- changedProps.value = this.value;
8734
- }
8735
- }
8736
- inputElement = React$1.cloneElement(inputElement, changedProps);
8737
- return inputElement;
8738
- };
8739
- return InputElement;
8818
+ return this.maskOptions.mask && (a.disabled || a.readOnly || (o.onChange = this.onChange, o.onPaste = this.onPaste, o.onMouseDown = this.onMouseDown), null != a.value && (o.value = this.value)), t = React$1.cloneElement(t, o);
8819
+ }, e;
8740
8820
  }(React$1.Component);
8741
- reactInputMask_development = InputElement;
8742
- return reactInputMask_development;
8821
+ reactInputMask_production_min = InputElement;
8822
+ return reactInputMask_production_min;
8743
8823
  }
8744
8824
 
8745
8825
  if (process.env.NODE_ENV === 'production') {
@@ -8820,7 +8900,7 @@ var cardTypes$1 = {
8820
8900
  unionpay: {
8821
8901
  niceType: "UnionPay",
8822
8902
  type: "unionpay",
8823
- patterns: [620, [624, 626], [62100, 62182], [62184, 62187], [62185, 62197], [62200, 62205], [622010, 622999], 622018, [622019, 622999], [62207, 62209], [622126, 622925], [623, 626], 6270, 6272, 6276, [627700, 627779], [627781, 627799], [6282, 6289], 6291, 6292, 810, [8110, 8131], [8132, 8151], [8152, 8163], [8164, 8171]],
8903
+ patterns: [620, [62100, 62182], [62184, 62187], [62185, 62197], [62200, 62205], [622010, 622999], 622018, [62207, 62209], [623, 626], 6270, 6272, 6276, [627700, 627779], [627781, 627799], [6282, 6289], 6291, 6292, 810, [8110, 8131], [8132, 8151], [8152, 8163], [8164, 8171]],
8824
8904
  gaps: [4, 8, 12],
8825
8905
  lengths: [14, 15, 16, 17, 18, 19],
8826
8906
  code: {
@@ -8941,10 +9021,10 @@ function addMatchingCardsToResults(cardNumber, cardConfiguration, results) {
8941
9021
  var i, patternLength;
8942
9022
  for (i = 0; i < cardConfiguration.patterns.length; i++) {
8943
9023
  var pattern = cardConfiguration.patterns[i];
8944
- if (!matches_1.matches(cardNumber, pattern)) {
9024
+ if (!(0, matches_1.matches)(cardNumber, pattern)) {
8945
9025
  continue;
8946
9026
  }
8947
- var clonedCardConfiguration = clone_1$1.clone(cardConfiguration);
9027
+ var clonedCardConfiguration = (0, clone_1$1.clone)(cardConfiguration);
8948
9028
  if (Array.isArray(pattern)) {
8949
9029
  patternLength = String(pattern[0]).length;
8950
9030
  } else {
@@ -9038,13 +9118,13 @@ var cardNames = {
9038
9118
  HIPERCARD: "hipercard"
9039
9119
  };
9040
9120
  var ORIGINAL_TEST_ORDER = [cardNames.VISA, cardNames.MASTERCARD, cardNames.AMERICAN_EXPRESS, cardNames.DINERS_CLUB, cardNames.DISCOVER, cardNames.JCB, cardNames.UNIONPAY, cardNames.MAESTRO, cardNames.ELO, cardNames.MIR, cardNames.HIPER, cardNames.HIPERCARD];
9041
- var testOrder = clone_1.clone(ORIGINAL_TEST_ORDER);
9121
+ var testOrder = (0, clone_1.clone)(ORIGINAL_TEST_ORDER);
9042
9122
  function findType(cardType) {
9043
9123
  return customCards[cardType] || cardTypes[cardType];
9044
9124
  }
9045
9125
  function getAllCardTypes() {
9046
9126
  return testOrder.map(function (cardType) {
9047
- return clone_1.clone(findType(cardType));
9127
+ return (0, clone_1.clone)(findType(cardType));
9048
9128
  });
9049
9129
  }
9050
9130
  function getCardPosition(name, ignoreErrorForNotExisting) {
@@ -9059,7 +9139,7 @@ function getCardPosition(name, ignoreErrorForNotExisting) {
9059
9139
  }
9060
9140
  function creditCardType(cardNumber) {
9061
9141
  var results = [];
9062
- if (!is_valid_input_type_1.isValidInputType(cardNumber)) {
9142
+ if (!(0, is_valid_input_type_1.isValidInputType)(cardNumber)) {
9063
9143
  return results;
9064
9144
  }
9065
9145
  if (cardNumber.length === 0) {
@@ -9067,16 +9147,16 @@ function creditCardType(cardNumber) {
9067
9147
  }
9068
9148
  testOrder.forEach(function (cardType) {
9069
9149
  var cardConfiguration = findType(cardType);
9070
- add_matching_cards_to_results_1.addMatchingCardsToResults(cardNumber, cardConfiguration, results);
9150
+ (0, add_matching_cards_to_results_1.addMatchingCardsToResults)(cardNumber, cardConfiguration, results);
9071
9151
  });
9072
- var bestMatch = find_best_match_1.findBestMatch(results);
9152
+ var bestMatch = (0, find_best_match_1.findBestMatch)(results);
9073
9153
  if (bestMatch) {
9074
9154
  return [bestMatch];
9075
9155
  }
9076
9156
  return results;
9077
9157
  }
9078
9158
  creditCardType.getTypeInfo = function (cardType) {
9079
- return clone_1.clone(findType(cardType));
9159
+ return (0, clone_1.clone)(findType(cardType));
9080
9160
  };
9081
9161
  creditCardType.removeCard = function (name) {
9082
9162
  var position = getCardPosition(name);
@@ -9092,12 +9172,12 @@ creditCardType.addCard = function (config) {
9092
9172
  creditCardType.updateCard = function (cardType, updates) {
9093
9173
  var originalObject = customCards[cardType] || cardTypes[cardType];
9094
9174
  if (!originalObject) {
9095
- throw new Error("\"" + cardType + "\" is not a recognized type. Use `addCard` instead.'");
9175
+ throw new Error("\"".concat(cardType, "\" is not a recognized type. Use `addCard` instead.'"));
9096
9176
  }
9097
9177
  if (updates.type && originalObject.type !== updates.type) {
9098
9178
  throw new Error("Cannot overwrite type parameter.");
9099
9179
  }
9100
- var clonedCard = clone_1.clone(originalObject);
9180
+ var clonedCard = (0, clone_1.clone)(originalObject);
9101
9181
  clonedCard = __assign$8(__assign$8({}, clonedCard), updates);
9102
9182
  customCards[clonedCard.type] = clonedCard;
9103
9183
  };
@@ -9107,7 +9187,7 @@ creditCardType.changeOrder = function (name, position) {
9107
9187
  testOrder.splice(position, 0, name);
9108
9188
  };
9109
9189
  creditCardType.resetModifications = function () {
9110
- testOrder = clone_1.clone(ORIGINAL_TEST_ORDER);
9190
+ testOrder = (0, clone_1.clone)(ORIGINAL_TEST_ORDER);
9111
9191
  customCards = {};
9112
9192
  };
9113
9193
  creditCardType.types = cardNames;
@@ -9189,8 +9269,8 @@ var TextInput = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
9189
9269
  "aria-label": label || placeholder,
9190
9270
  ref: ref,
9191
9271
  onChange: function onChange(event) {
9192
- _onChange === null || _onChange === void 0 ? void 0 : _onChange(event.target.value);
9193
- onChangeEvent === null || onChangeEvent === void 0 ? void 0 : onChangeEvent(event);
9272
+ _onChange === null || _onChange === void 0 || _onChange(event.target.value);
9273
+ onChangeEvent === null || onChangeEvent === void 0 || onChangeEvent(event);
9194
9274
  }
9195
9275
  }, rest));
9196
9276
  });
@@ -9648,12 +9728,12 @@ var SearchInput = function SearchInput(_ref) {
9648
9728
  var handleClear = React.useCallback(function () {
9649
9729
  var _ref$current;
9650
9730
  setValue(DEFAULT_INPUT_VALUE);
9651
- onChange === null || onChange === void 0 ? void 0 : onChange(DEFAULT_INPUT_VALUE);
9652
- onClear === null || onClear === void 0 ? void 0 : onClear();
9653
- (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.focus();
9731
+ onChange === null || onChange === void 0 || onChange(DEFAULT_INPUT_VALUE);
9732
+ onClear === null || onClear === void 0 || onClear();
9733
+ (_ref$current = ref.current) === null || _ref$current === void 0 || _ref$current.focus();
9654
9734
  }, [onClear, onChange]);
9655
9735
  var handleChange = React.useCallback(function (value) {
9656
- onChange === null || onChange === void 0 ? void 0 : onChange(value);
9736
+ onChange === null || onChange === void 0 || onChange(value);
9657
9737
  setValue(value);
9658
9738
  }, [onChange, setValue]);
9659
9739
  React.useEffect(function () {
@@ -9675,16 +9755,16 @@ var SearchInput = function SearchInput(_ref) {
9675
9755
  }, /*#__PURE__*/React.createElement(Exit20, null)));
9676
9756
  };
9677
9757
 
9678
- var t$1 = function t(_t) {
9758
+ var t = function t(_t) {
9679
9759
  return "object" == _typeof$1(_t) && null != _t && 1 === _t.nodeType;
9680
9760
  },
9681
- e = function e(t, _e) {
9761
+ e$1 = function e(t, _e) {
9682
9762
  return (!_e || "hidden" !== t) && "visible" !== t && "clip" !== t;
9683
9763
  },
9684
9764
  n = function n(t, _n) {
9685
9765
  if (t.clientHeight < t.scrollHeight || t.clientWidth < t.scrollWidth) {
9686
9766
  var _l = getComputedStyle(t, null);
9687
- return e(_l.overflowY, _n) || e(_l.overflowX, _n) || function (t) {
9767
+ return e$1(_l.overflowY, _n) || e$1(_l.overflowX, _n) || function (t) {
9688
9768
  var e = function (t) {
9689
9769
  if (!t.ownerDocument || !t.ownerDocument.defaultView) return null;
9690
9770
  try {
@@ -9716,11 +9796,11 @@ var t$1 = function t(_t) {
9716
9796
  m = "function" == typeof a ? a : function (t) {
9717
9797
  return t !== a;
9718
9798
  };
9719
- if (!t$1(e)) throw new TypeError("Invalid target");
9799
+ if (!t(e)) throw new TypeError("Invalid target");
9720
9800
  var p = document.scrollingElement || document.documentElement,
9721
9801
  w = [],
9722
9802
  W = e;
9723
- for (; t$1(W) && m(W);) {
9803
+ for (; t(W) && m(W);) {
9724
9804
  if (W = i(W), W === p) {
9725
9805
  w.push(W);
9726
9806
  break;
@@ -9778,42 +9858,53 @@ var t$1 = function t(_t) {
9778
9858
  return k;
9779
9859
  };
9780
9860
 
9781
- var o = function o(e) {
9782
- return !1 === e ? {
9861
+ var o = function o(t) {
9862
+ return !1 === t ? {
9783
9863
  block: "end",
9784
9864
  inline: "nearest"
9785
- } : function (e) {
9786
- return e === Object(e) && 0 !== Object.keys(e).length;
9787
- }(e) ? e : {
9865
+ } : function (t) {
9866
+ return t === Object(t) && 0 !== Object.keys(t).length;
9867
+ }(t) ? t : {
9788
9868
  block: "start",
9789
9869
  inline: "nearest"
9790
9870
  };
9791
9871
  };
9792
- function t(t, n) {
9793
- if (!t.isConnected || !function (e) {
9794
- var o = e;
9872
+ function e(e, r) {
9873
+ if (!e.isConnected || !function (t) {
9874
+ var o = t;
9795
9875
  for (; o && o.parentNode;) {
9796
9876
  if (o.parentNode === document) return !0;
9797
9877
  o = o.parentNode instanceof ShadowRoot ? o.parentNode.host : o.parentNode;
9798
9878
  }
9799
9879
  return !1;
9800
- }(t)) return;
9801
- if (function (e) {
9802
- return "object" == _typeof$1(e) && "function" == typeof e.behavior;
9803
- }(n)) return n.behavior(o$1(t, n));
9804
- var r = "boolean" == typeof n || null == n ? void 0 : n.behavior;
9805
- var _iterator = _createForOfIteratorHelper(o$1(t, o(n))),
9880
+ }(e)) return;
9881
+ var n = function (t) {
9882
+ var o = window.getComputedStyle(t);
9883
+ return {
9884
+ top: parseFloat(o.scrollMarginTop) || 0,
9885
+ right: parseFloat(o.scrollMarginRight) || 0,
9886
+ bottom: parseFloat(o.scrollMarginBottom) || 0,
9887
+ left: parseFloat(o.scrollMarginLeft) || 0
9888
+ };
9889
+ }(e);
9890
+ if (function (t) {
9891
+ return "object" == _typeof$1(t) && "function" == typeof t.behavior;
9892
+ }(r)) return r.behavior(o$1(e, r));
9893
+ var l = "boolean" == typeof r || null == r ? void 0 : r.behavior;
9894
+ var _iterator = _createForOfIteratorHelper(o$1(e, o(r))),
9806
9895
  _step;
9807
9896
  try {
9808
9897
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
9809
9898
  var _step$value = _step.value,
9810
- i = _step$value.el,
9811
- a = _step$value.top,
9812
- l = _step$value.left;
9813
- i.scroll({
9814
- top: a,
9815
- left: l,
9816
- behavior: r
9899
+ a = _step$value.el,
9900
+ i = _step$value.top,
9901
+ s = _step$value.left;
9902
+ var _t = i - n.top + n.bottom,
9903
+ _o = s - n.left + n.right;
9904
+ a.scroll({
9905
+ top: _t,
9906
+ left: _o,
9907
+ behavior: l
9817
9908
  });
9818
9909
  }
9819
9910
  } catch (err) {
@@ -9837,7 +9928,7 @@ var SelectOption = function SelectOption(_ref) {
9837
9928
  }, [onClick, option]);
9838
9929
  React.useEffect(function () {
9839
9930
  if (active && ref.current) {
9840
- t(ref.current, {
9931
+ e(ref.current, {
9841
9932
  scrollMode: 'if-needed',
9842
9933
  block: 'nearest'
9843
9934
  });
@@ -10078,7 +10169,7 @@ var Select = function Select(_ref) {
10078
10169
  value: autoSelect ? option.value : value !== null && value !== void 0 ? value : option.value
10079
10170
  }
10080
10171
  });
10081
- onChange === null || onChange === void 0 ? void 0 : onChange(option.value);
10172
+ onChange === null || onChange === void 0 || onChange(option.value);
10082
10173
  }, [autoSelect, value, dispatch, onChange]);
10083
10174
  var handleFocus = React.useCallback(function (option) {
10084
10175
  return dispatch({
@@ -10412,7 +10503,7 @@ var CreditCardNumberInput = function CreditCardNumberInput(_ref) {
10412
10503
  }, [propsValue, value, setValue]);
10413
10504
  var handleChange = React.useCallback(function (event) {
10414
10505
  setValue(event.target.value);
10415
- onChange === null || onChange === void 0 ? void 0 : onChange(event.target.value);
10506
+ onChange === null || onChange === void 0 || onChange(event.target.value);
10416
10507
  }, [setValue, onChange]);
10417
10508
 
10418
10509
  // TODO: get rid of the any, the types of react-input-mask are incorrect here, it should expect a function as a child, but it expects a ReactNode
@@ -10475,7 +10566,7 @@ var Expandable = function Expandable(_ref) {
10475
10566
  setExpanded(function (expanded) {
10476
10567
  return !expanded;
10477
10568
  });
10478
- onToggle === null || onToggle === void 0 ? void 0 : onToggle();
10569
+ onToggle === null || onToggle === void 0 || onToggle();
10479
10570
  }, [onToggle]);
10480
10571
  return /*#__PURE__*/React.createElement("div", _extends$1({
10481
10572
  className: classNames('Expandable', "Expandable--".concat(background, "-background"), {
@@ -10907,7 +10998,7 @@ var ModalOverlay = function ModalOverlay(_ref) {
10907
10998
  document.body.appendChild(element);
10908
10999
  return function () {
10909
11000
  var _element$parentElemen;
10910
- element === null || element === void 0 ? void 0 : (_element$parentElemen = element.parentElement) === null || _element$parentElemen === void 0 ? void 0 : _element$parentElemen.removeChild(element);
11001
+ element === null || element === void 0 || (_element$parentElemen = element.parentElement) === null || _element$parentElemen === void 0 || _element$parentElemen.removeChild(element);
10911
11002
  };
10912
11003
  }, [element]);
10913
11004
  if (!element) return null;
@@ -10924,6 +11015,35 @@ var ModalOverlay = function ModalOverlay(_ref) {
10924
11015
  }, children))), element);
10925
11016
  };
10926
11017
 
11018
+ var preventNavigation = function preventNavigation(event) {
11019
+ event.preventDefault();
11020
+ event.returnValue = '';
11021
+ };
11022
+
11023
+ var usePreventNavigation = function usePreventNavigation() {
11024
+ var enabled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
11025
+ React.useEffect(function () {
11026
+ if (enabled) {
11027
+ window.addEventListener('beforeunload', preventNavigation);
11028
+ return function () {
11029
+ return window.removeEventListener('beforeunload', preventNavigation);
11030
+ };
11031
+ }
11032
+ }, [enabled]);
11033
+ };
11034
+
11035
+ var NavigationPreventer = function NavigationPreventer(_ref) {
11036
+ var _ref$enabled = _ref.enabled,
11037
+ enabled = _ref$enabled === void 0 ? false : _ref$enabled,
11038
+ _ref$message = _ref.message,
11039
+ message = _ref$message === void 0 ? 'Changes that you made may not be saved.' : _ref$message;
11040
+ usePreventNavigation(enabled);
11041
+ return /*#__PURE__*/React.createElement(reactRouterDom.Prompt, {
11042
+ when: enabled,
11043
+ message: message
11044
+ });
11045
+ };
11046
+
10927
11047
  var __assign$1 = undefined && undefined.__assign || function () {
10928
11048
  __assign$1 = Object.assign || function (t) {
10929
11049
  for (var s, i = 1, n = arguments.length; i < n; i++) {
@@ -11608,6 +11728,7 @@ exports.Mirror = Mirror;
11608
11728
  exports.Modal = Modal;
11609
11729
  exports.ModalOverlay = ModalOverlay;
11610
11730
  exports.MultiSelect = MultiSelect;
11731
+ exports.NavigationPreventer = NavigationPreventer;
11611
11732
  exports.NoLineDivider = NoLineDivider;
11612
11733
  exports.Oval = Oval;
11613
11734
  exports.Overlay = Overlay;