@moda/om 20.4.0 → 21.0.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 (93) hide show
  1. package/dist/index.cjs.js +1433 -1504
  2. package/dist/index.cjs.js.map +1 -1
  3. package/dist/index.esm.js +1433 -1504
  4. package/dist/index.esm.js.map +1 -1
  5. package/dist/src/components/Checkbox/Checkbox.d.ts +1 -1
  6. package/dist/src/components/Field/Field.d.ts +1 -1
  7. package/dist/src/components/PasswordInput/PasswordInput.d.ts +1 -1
  8. package/dist/src/components/Popover/Popover.d.ts +1 -1
  9. package/dist/src/components/PromoBanner/PromoBanner.d.ts +1 -1
  10. package/dist/src/components/RadioButton/RadioButton.d.ts +1 -1
  11. package/dist/src/components/Select/useSelect.d.ts +3 -3
  12. package/dist/src/components/Tabs/Tab.d.ts +1 -1
  13. package/dist/src/components/Text/Text.d.ts +2 -2
  14. package/dist/src/hooks/useClickOutside.d.ts +1 -1
  15. package/dist/src/index.d.ts +1 -1
  16. package/dist/src/utilities/States/State.d.ts +6 -7
  17. package/dist/src/utilities/States/StateProps.d.ts +7 -0
  18. package/dist/src/utilities/States/States.d.ts +6 -7
  19. package/dist/src/utilities/States/Styles.d.ts +14 -0
  20. package/dist/src/utilities/States/index.d.ts +1 -0
  21. package/dist/src/utilities/index.d.ts +7 -0
  22. package/dist/src/utilities/isEmpty.d.ts +1 -0
  23. package/dist/src/utilities/isRenderProps.d.ts +5 -0
  24. package/dist/src/utilities/stringifyProps.d.ts +1 -0
  25. package/dist/src/utilities/truncate.d.ts +1 -0
  26. package/dist/styles.css +1 -1
  27. package/package.json +64 -61
  28. package/src/components/AspectRatioBox/AspectRatioBox.stories.tsx +1 -1
  29. package/src/components/Badge/Badge.stories.tsx +1 -1
  30. package/src/components/Breadcrumbs/Breadcrumbs.stories.tsx +1 -1
  31. package/src/components/Breadcrumbs/Breadcrumbs.tsx +2 -2
  32. package/src/components/Button/Button.stories.tsx +2 -2
  33. package/src/components/Checkbox/Checkbox.stories.tsx +1 -1
  34. package/src/components/Checkbox/Checkbox.tsx +1 -1
  35. package/src/components/Clickable/Clickable.stories.tsx +1 -1
  36. package/src/components/ColorSwatch/ColorSwatch.stories.tsx +1 -1
  37. package/src/components/ControlLink/ControlLink.stories.tsx +1 -1
  38. package/src/components/CreditCardNumberInput/CreditCardNumberInput.stories.tsx +1 -1
  39. package/src/components/CreditCardNumberInput/CreditCardNumberInput.test.tsx +3 -6
  40. package/src/components/CreditCardNumberInput/CreditCardNumberInput.tsx +5 -13
  41. package/src/components/DefinitionList/DefinitionList.stories.tsx +1 -1
  42. package/src/components/Divider/Divider.stories.tsx +1 -1
  43. package/src/components/Expandable/Expandable.stories.tsx +1 -1
  44. package/src/components/Field/Field.stories.tsx +1 -1
  45. package/src/components/Field/Field.tsx +1 -1
  46. package/src/components/Label/Label.stories.tsx +1 -1
  47. package/src/components/LoadingItemsLavenderBlue/LoadingItems.stories.tsx +1 -1
  48. package/src/components/LoadingItemsPinkGreen/LoadingItems.stories.tsx +1 -1
  49. package/src/components/LoadingShapes/LoadingShapes.stories.tsx +1 -1
  50. package/src/components/LoadingShapesLavenderBlue/LoadingShapesLavenderBlue.stories.tsx +1 -1
  51. package/src/components/LoadingShapesPinkGreen/LoadingShapesPinkGreen.stories.tsx +1 -1
  52. package/src/components/Overlay/Overlay.stories.tsx +1 -1
  53. package/src/components/PasswordInput/PasswordInput.stories.tsx +1 -1
  54. package/src/components/Popover/Popover.stories.tsx +1 -1
  55. package/src/components/Popover/Popover.tsx +1 -1
  56. package/src/components/PromoBanner/PromoBanner.stories.tsx +1 -1
  57. package/src/components/PromoBanner/PromoBanner.tsx +1 -1
  58. package/src/components/RadioButton/RadioButton.stories.tsx +1 -1
  59. package/src/components/RadioButton/RadioButton.tsx +1 -1
  60. package/src/components/SearchInput/SearchInput.stories.tsx +1 -1
  61. package/src/components/Select/Select.stories.tsx +2 -3
  62. package/src/components/Select/Select.test.tsx +5 -5
  63. package/src/components/SelectableButton/SelectableButton.stories.tsx +1 -1
  64. package/src/components/Shape/Shape.stories.tsx +1 -1
  65. package/src/components/Stack/Stack.stories.tsx +1 -1
  66. package/src/components/Tabs/Tab.tsx +1 -1
  67. package/src/components/Tabs/Tabs.stories.tsx +1 -1
  68. package/src/components/Tag/Tag.stories.tsx +1 -1
  69. package/src/components/Text/Text.stories.tsx +1 -1
  70. package/src/components/Text/Text.tsx +2 -2
  71. package/src/components/TextInput/TextInput.stories.tsx +1 -1
  72. package/src/components/Textarea/Textarea.stories.tsx +1 -1
  73. package/src/components/Toast/Toast.stories.tsx +1 -1
  74. package/src/components/VerticalDivider/VerticalDivider.stories.tsx +1 -1
  75. package/src/hooks/useClickOutside.ts +4 -1
  76. package/src/utilities/States/State.tsx +13 -13
  77. package/src/utilities/States/StateProps.tsx +28 -0
  78. package/src/utilities/States/States.tsx +9 -11
  79. package/src/utilities/States/Styles.tsx +43 -0
  80. package/src/utilities/States/index.ts +1 -0
  81. package/src/utilities/index.ts +7 -0
  82. package/src/utilities/isEmpty.ts +1 -0
  83. package/src/utilities/isRenderProps.ts +9 -0
  84. package/src/utilities/{States/stringifyProps.tsx → stringifyProps.ts} +2 -7
  85. package/src/utilities/truncate.ts +5 -0
  86. package/dist/src/utilities/States/StatesProps.d.ts +0 -8
  87. package/dist/src/utilities/States/isRenderProps.d.ts +0 -4
  88. package/dist/src/utilities/States/stringifyProps.d.ts +0 -1
  89. package/src/utilities/States/State.scss +0 -11
  90. package/src/utilities/States/States.scss +0 -5
  91. package/src/utilities/States/StatesProps.scss +0 -24
  92. package/src/utilities/States/StatesProps.tsx +0 -31
  93. package/src/utilities/States/isRenderProps.ts +0 -7
package/dist/index.cjs.js CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  var React = require('react');
4
4
  var reactRouterDom = require('react-router-dom');
5
- var require$$1 = require('react-dom');
5
+ var reactDom = require('react-dom');
6
6
 
7
7
  function _interopNamespaceDefault(e) {
8
8
  var n = Object.create(null);
@@ -945,11 +945,16 @@ function requireHelpers() {
945
945
  };
946
946
  return __assign.apply(this, arguments);
947
947
  };
948
+ var __importDefault = helpers && helpers.__importDefault || function (mod) {
949
+ return mod && mod.__esModule ? mod : {
950
+ "default": mod
951
+ };
952
+ };
948
953
  Object.defineProperty(exports, "__esModule", {
949
954
  value: true
950
955
  });
951
956
  exports.spacing = exports.colorInHex = exports.color = exports.remToUnitlessPx = exports.text = void 0;
952
- var color_string_1 = require$$0;
957
+ var color_string_1 = __importDefault(require$$0);
953
958
  var colors_1 = requireColors();
954
959
  var space_1 = requireSpace();
955
960
  var typography_1 = requireTypography();
@@ -1260,108 +1265,6 @@ var isRenderProps = function isRenderProps(children) {
1260
1265
  return typeof children === 'function';
1261
1266
  };
1262
1267
 
1263
- var classnames = {exports: {}};
1264
-
1265
- var hasRequiredClassnames;
1266
- function requireClassnames() {
1267
- if (hasRequiredClassnames) return classnames.exports;
1268
- hasRequiredClassnames = 1;
1269
- (function (module) {
1270
- /* global define */
1271
-
1272
- (function () {
1273
-
1274
- var hasOwn = {}.hasOwnProperty;
1275
- function classNames() {
1276
- var classes = '';
1277
- for (var i = 0; i < arguments.length; i++) {
1278
- var arg = arguments[i];
1279
- if (arg) {
1280
- classes = appendClass(classes, parseValue(arg));
1281
- }
1282
- }
1283
- return classes;
1284
- }
1285
- function parseValue(arg) {
1286
- if (typeof arg === 'string' || typeof arg === 'number') {
1287
- return arg;
1288
- }
1289
- if (_typeof$1(arg) !== 'object') {
1290
- return '';
1291
- }
1292
- if (Array.isArray(arg)) {
1293
- return classNames.apply(null, arg);
1294
- }
1295
- if (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes('[native code]')) {
1296
- return arg.toString();
1297
- }
1298
- var classes = '';
1299
- for (var key in arg) {
1300
- if (hasOwn.call(arg, key) && arg[key]) {
1301
- classes = appendClass(classes, key);
1302
- }
1303
- }
1304
- return classes;
1305
- }
1306
- function appendClass(value, newClass) {
1307
- if (!newClass) {
1308
- return value;
1309
- }
1310
- if (value) {
1311
- return value + ' ' + newClass;
1312
- }
1313
- return value + newClass;
1314
- }
1315
- if (module.exports) {
1316
- classNames["default"] = classNames;
1317
- module.exports = classNames;
1318
- } else {
1319
- window.classNames = classNames;
1320
- }
1321
- })();
1322
- })(classnames);
1323
- return classnames.exports;
1324
- }
1325
-
1326
- var classnamesExports = requireClassnames();
1327
- var classNames = /*@__PURE__*/getDefaultExportFromCjs(classnamesExports);
1328
-
1329
- var _excluded$G = ["className", "children", "space", "direction", "alignItems", "justifyContent", "style"];
1330
- var Stack = function Stack(_ref) {
1331
- var className = _ref.className,
1332
- children = _ref.children,
1333
- space = _ref.space,
1334
- _ref$direction = _ref.direction,
1335
- direction = _ref$direction === void 0 ? 'vertical' : _ref$direction,
1336
- alignItems = _ref.alignItems,
1337
- justifyContent = _ref.justifyContent,
1338
- style = _ref.style,
1339
- rest = _objectWithoutProperties(_ref, _excluded$G);
1340
- return /*#__PURE__*/React.createElement("div", _extends$1({
1341
- className: classNames("Stack Stack--".concat(direction, "-").concat(space), className),
1342
- style: _objectSpread2(_objectSpread2({}, style), {}, {
1343
- alignItems: alignItems,
1344
- justifyContent: justifyContent
1345
- })
1346
- }, rest), children);
1347
- };
1348
-
1349
- var omit$1 = function omit(obj) {
1350
- for (var _len = arguments.length, keys = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1351
- keys[_key - 1] = arguments[_key];
1352
- }
1353
- return Object.entries(obj).filter(function (_ref) {
1354
- var _ref2 = _slicedToArray(_ref, 1),
1355
- key = _ref2[0];
1356
- return !keys.includes(key);
1357
- }).reduce(function (obj, _ref3) {
1358
- var _ref4 = _slicedToArray(_ref3, 2),
1359
- key = _ref4[0],
1360
- val = _ref4[1];
1361
- return Object.assign(obj, _defineProperty$1({}, key, val));
1362
- }, {});
1363
- };
1364
-
1365
1268
  var truncate = function truncate(string) {
1366
1269
  var maxLength = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 25;
1367
1270
  if (!string) return null;
@@ -1369,7 +1272,6 @@ var truncate = function truncate(string) {
1369
1272
  return "".concat(string.substring(0, maxLength)).concat(ellipsis ? '...' : '');
1370
1273
  };
1371
1274
 
1372
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1373
1275
  var stringifyProps = function stringifyProps(props) {
1374
1276
  var stringifiedProps = Object.entries(props || {}).reduce(function (memo, _ref) {
1375
1277
  var _ref2 = _slicedToArray(_ref, 2),
@@ -1386,50 +1288,85 @@ var stringifyProps = function stringifyProps(props) {
1386
1288
  return stringifiedProps.trim();
1387
1289
  };
1388
1290
 
1389
- /* eslint-disable @typescript-eslint/no-explicit-any */
1390
-
1391
- /* eslint-enable @typescript-eslint/no-explicit-any */
1291
+ var omit$1 = function omit(obj) {
1292
+ for (var _len = arguments.length, keys = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1293
+ keys[_key - 1] = arguments[_key];
1294
+ }
1295
+ return Object.entries(obj).filter(function (_ref) {
1296
+ var _ref2 = _slicedToArray(_ref, 1),
1297
+ key = _ref2[0];
1298
+ return !keys.includes(key);
1299
+ }).reduce(function (obj, _ref3) {
1300
+ var _ref4 = _slicedToArray(_ref3, 2),
1301
+ key = _ref4[0],
1302
+ val = _ref4[1];
1303
+ return Object.assign(obj, _defineProperty$1({}, key, val));
1304
+ }, {});
1305
+ };
1392
1306
 
1393
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1394
1307
  var isEmpty = function isEmpty(obj) {
1395
1308
  return Object.entries(obj || {}).length === 0;
1396
1309
  };
1397
- var StatesProps = function StatesProps(_ref) {
1310
+
1311
+ var DEFAULT_STYLES = {
1312
+ state: {
1313
+ border: '1px dotted #ddd',
1314
+ padding: '0.5rem',
1315
+ marginBottom: '1rem'
1316
+ },
1317
+ stateProps: {
1318
+ display: 'block',
1319
+ marginTop: '0.5rem',
1320
+ paddingTop: '0.5rem',
1321
+ fontFamily: "source-code-pro, Menlo, Monaco, Consolas, 'Courier New', monospace",
1322
+ fontSize: '0.8125rem',
1323
+ color: '#999',
1324
+ borderTop: '1px dotted #ddd'
1325
+ },
1326
+ statePropsActive: {
1327
+ color: '#111',
1328
+ textDecoration: 'underline'
1329
+ }
1330
+ };
1331
+ var Styles = /*#__PURE__*/React.createContext(DEFAULT_STYLES);
1332
+ var useStyles = function useStyles() {
1333
+ return React.useContext(Styles);
1334
+ };
1335
+
1336
+ var StateProps = function StateProps(_ref) {
1398
1337
  var props = _ref.props,
1399
1338
  children = _ref.children;
1339
+ var styles = useStyles();
1400
1340
  var childrenProps = omit$1.apply(void 0, [children.props].concat(_toConsumableArray(Object.keys(props || {}))));
1401
- return /*#__PURE__*/React.createElement(Stack, {
1402
- className: "StatesProps",
1403
- space: 2,
1404
- direction: "horizontal"
1405
- }, /*#__PURE__*/React.createElement("span", null, children.type.displayName || children.type.name), !isEmpty(props) && /*#__PURE__*/React.createElement("strong", null, stringifyProps(props)), !isRenderProps(children) && !isEmpty(childrenProps) && /*#__PURE__*/React.createElement("span", null, stringifyProps(childrenProps)), /*#__PURE__*/React.createElement("span", null, " "));
1341
+ return /*#__PURE__*/React.createElement("div", {
1342
+ style: styles.stateProps
1343
+ }, '<', /*#__PURE__*/React.createElement("span", null, children.type.displayName || children.type.name), ' ', !isEmpty(props) && /*#__PURE__*/React.createElement("strong", {
1344
+ style: styles.statePropsActive
1345
+ }, stringifyProps(props)), ' ', !isRenderProps(children) && !isEmpty(childrenProps) && /*#__PURE__*/React.createElement("span", null, stringifyProps(childrenProps)), /*#__PURE__*/React.createElement("span", null, ' />'));
1406
1346
  };
1407
1347
 
1408
- var _excluded$F = ["props", "children"];
1348
+ var _excluded$G = ["props", "children"];
1409
1349
  var State = function State(_ref) {
1410
1350
  var props = _ref.props,
1411
1351
  children = _ref.children,
1412
- rest = _objectWithoutProperties(_ref, _excluded$F);
1352
+ rest = _objectWithoutProperties(_ref, _excluded$G);
1353
+ var styles = useStyles();
1413
1354
  var Specimen = isRenderProps(children) ? children(props) : /*#__PURE__*/React.cloneElement(children, props);
1414
1355
  var innerChildren = isRenderProps(children) ? children(props) : children;
1415
1356
  return /*#__PURE__*/React.createElement("div", _extends$1({
1416
- className: "State"
1417
- }, rest), Specimen, /*#__PURE__*/React.createElement("code", {
1418
- className: "State__props"
1419
- }, /*#__PURE__*/React.createElement(StatesProps, {
1357
+ style: styles.state
1358
+ }, rest), Specimen, /*#__PURE__*/React.createElement(StateProps, {
1420
1359
  props: props
1421
- }, innerChildren)));
1360
+ }, innerChildren));
1422
1361
  };
1423
1362
 
1424
- var _excluded$E = ["states", "children"];
1363
+ var _excluded$F = ["states", "children"];
1425
1364
  var States = function States(_ref) {
1426
1365
  var _ref$states = _ref.states,
1427
1366
  states = _ref$states === void 0 ? [{}] : _ref$states,
1428
1367
  children = _ref.children,
1429
- rest = _objectWithoutProperties(_ref, _excluded$E);
1430
- return /*#__PURE__*/React.createElement("div", {
1431
- className: "States"
1432
- }, states.map(function (props, index) {
1368
+ rest = _objectWithoutProperties(_ref, _excluded$F);
1369
+ return /*#__PURE__*/React.createElement(React.Fragment, null, states.map(function (props, index) {
1433
1370
  return /*#__PURE__*/React.createElement(State, _extends$1({
1434
1371
  key: index,
1435
1372
  props: props
@@ -1437,6 +1374,11 @@ var States = function States(_ref) {
1437
1374
  }));
1438
1375
  };
1439
1376
 
1377
+ var preventNavigation = function preventNavigation(event) {
1378
+ event.preventDefault();
1379
+ event.returnValue = '';
1380
+ };
1381
+
1440
1382
  /******************************************************************************
1441
1383
  Copyright (c) Microsoft Corporation.
1442
1384
 
@@ -5310,6 +5252,72 @@ var FocusOn = /*#__PURE__*/React__namespace.forwardRef(function (props, ref) {
5310
5252
  }));
5311
5253
  });
5312
5254
 
5255
+ var classnames = {exports: {}};
5256
+
5257
+ var hasRequiredClassnames;
5258
+ function requireClassnames() {
5259
+ if (hasRequiredClassnames) return classnames.exports;
5260
+ hasRequiredClassnames = 1;
5261
+ (function (module) {
5262
+ /* global define */
5263
+
5264
+ (function () {
5265
+
5266
+ var hasOwn = {}.hasOwnProperty;
5267
+ function classNames() {
5268
+ var classes = '';
5269
+ for (var i = 0; i < arguments.length; i++) {
5270
+ var arg = arguments[i];
5271
+ if (arg) {
5272
+ classes = appendClass(classes, parseValue(arg));
5273
+ }
5274
+ }
5275
+ return classes;
5276
+ }
5277
+ function parseValue(arg) {
5278
+ if (typeof arg === 'string' || typeof arg === 'number') {
5279
+ return arg;
5280
+ }
5281
+ if (_typeof$1(arg) !== 'object') {
5282
+ return '';
5283
+ }
5284
+ if (Array.isArray(arg)) {
5285
+ return classNames.apply(null, arg);
5286
+ }
5287
+ if (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes('[native code]')) {
5288
+ return arg.toString();
5289
+ }
5290
+ var classes = '';
5291
+ for (var key in arg) {
5292
+ if (hasOwn.call(arg, key) && arg[key]) {
5293
+ classes = appendClass(classes, key);
5294
+ }
5295
+ }
5296
+ return classes;
5297
+ }
5298
+ function appendClass(value, newClass) {
5299
+ if (!newClass) {
5300
+ return value;
5301
+ }
5302
+ if (value) {
5303
+ return value + ' ' + newClass;
5304
+ }
5305
+ return value + newClass;
5306
+ }
5307
+ if (module.exports) {
5308
+ classNames["default"] = classNames;
5309
+ module.exports = classNames;
5310
+ } else {
5311
+ window.classNames = classNames;
5312
+ }
5313
+ })();
5314
+ })(classnames);
5315
+ return classnames.exports;
5316
+ }
5317
+
5318
+ var classnamesExports = requireClassnames();
5319
+ var classNames = /*@__PURE__*/getDefaultExportFromCjs(classnamesExports);
5320
+
5313
5321
  var dist$3 = {};
5314
5322
 
5315
5323
  var scale = {};
@@ -5410,7 +5418,7 @@ function requireDist$3() {
5410
5418
 
5411
5419
  var distExports$3 = requireDist$3();
5412
5420
 
5413
- var _excluded$D = ["aspectWidth", "aspectHeight", "maxWidth", "maxHeight", "outlined", "children", "className"];
5421
+ var _excluded$E = ["aspectWidth", "aspectHeight", "maxWidth", "maxHeight", "outlined", "children", "className"];
5414
5422
  var DEFAULT_PRODUCT_ASPECT_WIDTH = 128;
5415
5423
  var DEFAULT_PRODUCT_ASPECT_HEIGHT = 205;
5416
5424
  var DEFAULT_PRODUCT_ASPECT_RATIO = DEFAULT_PRODUCT_ASPECT_HEIGHT / DEFAULT_PRODUCT_ASPECT_WIDTH;
@@ -5456,7 +5464,7 @@ var AspectRatioBox = /*#__PURE__*/React.forwardRef(function (_ref2, forwardedRef
5456
5464
  outlined = _ref2$outlined === void 0 ? false : _ref2$outlined,
5457
5465
  children = _ref2.children,
5458
5466
  className = _ref2.className,
5459
- rest = _objectWithoutProperties(_ref2, _excluded$D);
5467
+ rest = _objectWithoutProperties(_ref2, _excluded$E);
5460
5468
  var _scaleDimensions = scaleDimensions({
5461
5469
  width: aspectWidth,
5462
5470
  height: aspectHeight,
@@ -5484,22 +5492,22 @@ var AspectRatioBox = /*#__PURE__*/React.forwardRef(function (_ref2, forwardedRef
5484
5492
  });
5485
5493
  AspectRatioBox.displayName = 'AspectRatioBox';
5486
5494
 
5487
- var _excluded$C = ["className", "theme", "children"];
5495
+ var _excluded$D = ["className", "theme", "children"];
5488
5496
  var Badge = function Badge(_ref) {
5489
5497
  var className = _ref.className,
5490
5498
  theme = _ref.theme,
5491
5499
  children = _ref.children,
5492
- rest = _objectWithoutProperties(_ref, _excluded$C);
5500
+ rest = _objectWithoutProperties(_ref, _excluded$D);
5493
5501
  return /*#__PURE__*/React.createElement("span", _extends$1({
5494
5502
  className: classNames('Badge', theme && "Badge--".concat(theme), className)
5495
5503
  }, rest), children);
5496
5504
  };
5497
5505
 
5498
- var _excluded$B = ["children", "className"];
5506
+ var _excluded$C = ["children", "className"];
5499
5507
  var Breadcrumbs = function Breadcrumbs(_ref) {
5500
5508
  var children = _ref.children,
5501
5509
  className = _ref.className,
5502
- rest = _objectWithoutProperties(_ref, _excluded$B);
5510
+ rest = _objectWithoutProperties(_ref, _excluded$C);
5503
5511
  var position = 0;
5504
5512
  return /*#__PURE__*/React.createElement("ol", _extends$1({
5505
5513
  itemScope: true,
@@ -5517,7 +5525,7 @@ var Breadcrumbs = function Breadcrumbs(_ref) {
5517
5525
  }));
5518
5526
  };
5519
5527
 
5520
- var _excluded$A = ["className", "styleless", "disabled"];
5528
+ var _excluded$B = ["className", "styleless", "disabled"];
5521
5529
  var isLink = function isLink(props) {
5522
5530
  return 'to' in props;
5523
5531
  };
@@ -5532,7 +5540,7 @@ var Clickable = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
5532
5540
  _ref$styleless = _ref.styleless,
5533
5541
  styleless = _ref$styleless === void 0 ? false : _ref$styleless,
5534
5542
  disabled = _ref.disabled,
5535
- rest = _objectWithoutProperties(_ref, _excluded$A);
5543
+ rest = _objectWithoutProperties(_ref, _excluded$B);
5536
5544
  var props = _objectSpread2(_objectSpread2({}, rest), {}, {
5537
5545
  className: classNames({
5538
5546
  Clickable: !styleless,
@@ -5553,14 +5561,14 @@ var Clickable = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
5553
5561
  });
5554
5562
  Clickable.displayName = 'Clickable';
5555
5563
 
5556
- var _excluded$z = ["className", "disabled", "children", "underlined"];
5564
+ var _excluded$A = ["className", "disabled", "children", "underlined"];
5557
5565
  var ControlLink = function ControlLink(_ref) {
5558
5566
  var className = _ref.className,
5559
5567
  disabled = _ref.disabled,
5560
5568
  children = _ref.children,
5561
5569
  _ref$underlined = _ref.underlined,
5562
5570
  underlined = _ref$underlined === void 0 ? true : _ref$underlined,
5563
- rest = _objectWithoutProperties(_ref, _excluded$z);
5571
+ rest = _objectWithoutProperties(_ref, _excluded$A);
5564
5572
  return /*#__PURE__*/React.createElement(Clickable, _extends$1({}, rest, {
5565
5573
  className: classNames('ControlLink', {
5566
5574
  'ControlLink--underlined': underlined
@@ -5571,12 +5579,12 @@ var ControlLink = function ControlLink(_ref) {
5571
5579
  }), children);
5572
5580
  };
5573
5581
 
5574
- var _excluded$y = ["children", "position", "className"];
5582
+ var _excluded$z = ["children", "position", "className"];
5575
5583
  var Breadcrumb = function Breadcrumb(_ref) {
5576
5584
  var children = _ref.children,
5577
5585
  position = _ref.position,
5578
5586
  className = _ref.className,
5579
- rest = _objectWithoutProperties(_ref, _excluded$y);
5587
+ rest = _objectWithoutProperties(_ref, _excluded$z);
5580
5588
  return /*#__PURE__*/React.createElement("li", {
5581
5589
  className: classNames('Breadcrumb', className),
5582
5590
  itemProp: "itemListElement",
@@ -7300,11 +7308,11 @@ var useBreakpoint = function useBreakpoint(props) {
7300
7308
  };
7301
7309
  };
7302
7310
 
7303
- var _excluded$x = ["children", "className"];
7311
+ var _excluded$y = ["children", "className"];
7304
7312
  var Breakpoint = function Breakpoint(_ref) {
7305
7313
  var children = _ref.children,
7306
7314
  className = _ref.className,
7307
- rest = _objectWithoutProperties(_ref, _excluded$x);
7315
+ rest = _objectWithoutProperties(_ref, _excluded$y);
7308
7316
  var _discriminate = discriminate(rest),
7309
7317
  mode = _discriminate.mode,
7310
7318
  breakpoint = _discriminate.breakpoint;
@@ -7315,7 +7323,7 @@ var Breakpoint = function Breakpoint(_ref) {
7315
7323
  }, omit(['at', 'gt', 'lt'], rest)), children) : null;
7316
7324
  };
7317
7325
 
7318
- var _excluded$w = ["secondary", "tertiary", "elevated", "chip", "hover", "focus", "disabled", "className"];
7326
+ var _excluded$x = ["secondary", "tertiary", "elevated", "chip", "hover", "focus", "disabled", "className"];
7319
7327
  var Button = function Button(_ref) {
7320
7328
  var secondary = _ref.secondary,
7321
7329
  tertiary = _ref.tertiary,
@@ -7325,7 +7333,7 @@ var Button = function Button(_ref) {
7325
7333
  focus = _ref.focus,
7326
7334
  disabled = _ref.disabled,
7327
7335
  className = _ref.className,
7328
- rest = _objectWithoutProperties(_ref, _excluded$w);
7336
+ rest = _objectWithoutProperties(_ref, _excluded$x);
7329
7337
  return /*#__PURE__*/React.createElement(Clickable, _extends$1({
7330
7338
  className: classNames('Button', {
7331
7339
  'Button--chip': chip,
@@ -7449,7 +7457,7 @@ var Circle12 = function Circle12(_a) {
7449
7457
  };
7450
7458
  Circle12.displayName = 'Circle12';
7451
7459
 
7452
- var _excluded$v = ["className", "defaultChecked", "checked", "children", "value", "onChange", "disabled", "checkIcon", "dataTestId", "id"];
7460
+ var _excluded$w = ["className", "defaultChecked", "checked", "children", "value", "onChange", "disabled", "checkIcon", "dataTestId", "id"];
7453
7461
  var CHECKED_ITEM_PROPS = {
7454
7462
  className: 'Checkbox__check-mark',
7455
7463
  height: '85%',
@@ -7468,7 +7476,7 @@ var Checkbox = function Checkbox(_ref) {
7468
7476
  checkIcon = _ref$checkIcon === void 0 ? 'checkmark' : _ref$checkIcon,
7469
7477
  dataTestId = _ref.dataTestId,
7470
7478
  id = _ref.id,
7471
- rest = _objectWithoutProperties(_ref, _excluded$v);
7479
+ rest = _objectWithoutProperties(_ref, _excluded$w);
7472
7480
  var _useState = React.useState((_ref2 = checked !== null && checked !== void 0 ? checked : defaultChecked) !== null && _ref2 !== void 0 ? _ref2 : false),
7473
7481
  _useState2 = _slicedToArray(_useState, 2),
7474
7482
  isChecked = _useState2[0],
@@ -7560,7 +7568,7 @@ var SKU_COLORS = {
7560
7568
  yellow: '#ffca44'
7561
7569
  };
7562
7570
 
7563
- var _excluded$u = ["className", "size", "color", "backgroundUrl", "focus", "hover", "selected", "soldOut", "onSale", "onClick", "onMouseEnter", "disabled", "title"];
7571
+ var _excluded$v = ["className", "size", "color", "backgroundUrl", "focus", "hover", "selected", "soldOut", "onSale", "onClick", "onMouseEnter", "disabled", "title"];
7564
7572
  var ColorSwatch = function ColorSwatch(_ref) {
7565
7573
  var _SKU_COLORS;
7566
7574
  var className = _ref.className,
@@ -7576,7 +7584,7 @@ var ColorSwatch = function ColorSwatch(_ref) {
7576
7584
  onMouseEnter = _ref.onMouseEnter,
7577
7585
  disabled = _ref.disabled,
7578
7586
  title = _ref.title,
7579
- rest = _objectWithoutProperties(_ref, _excluded$u);
7587
+ rest = _objectWithoutProperties(_ref, _excluded$v);
7580
7588
  var handleClick = React.useCallback(function (_event) {
7581
7589
  onClick === null || onClick === void 0 || onClick(color, title);
7582
7590
  }, [color, title, onClick]);
@@ -7611,14 +7619,14 @@ var ColorSwatch = function ColorSwatch(_ref) {
7611
7619
  }));
7612
7620
  };
7613
7621
 
7614
- var _excluded$t = ["className", "children", "onClose", "shards", "autoFocus"];
7622
+ var _excluded$u = ["className", "children", "onClose", "shards", "autoFocus"];
7615
7623
  var Modal = function Modal(_ref) {
7616
7624
  var className = _ref.className,
7617
7625
  children = _ref.children,
7618
7626
  onClose = _ref.onClose,
7619
7627
  shards = _ref.shards,
7620
7628
  autoFocus = _ref.autoFocus,
7621
- rest = _objectWithoutProperties(_ref, _excluded$t);
7629
+ rest = _objectWithoutProperties(_ref, _excluded$u);
7622
7630
  return /*#__PURE__*/React.createElement("div", _extends$1({
7623
7631
  className: classNames('Modal', className)
7624
7632
  }, rest), /*#__PURE__*/React.createElement(FocusOn, {
@@ -7629,14 +7637,14 @@ var Modal = function Modal(_ref) {
7629
7637
  }, children));
7630
7638
  };
7631
7639
 
7632
- var _excluded$s = ["className", "children", "show"];
7640
+ var _excluded$t = ["className", "children", "show"];
7633
7641
  var UNMOUNT_DELAY_MS = 500;
7634
7642
  var Overlay = /*#__PURE__*/React.forwardRef(function (_ref, forwardedRef) {
7635
7643
  var className = _ref.className,
7636
7644
  children = _ref.children,
7637
7645
  _ref$show = _ref.show,
7638
7646
  show = _ref$show === void 0 ? true : _ref$show,
7639
- rest = _objectWithoutProperties(_ref, _excluded$s);
7647
+ rest = _objectWithoutProperties(_ref, _excluded$t);
7640
7648
  var _useState = React.useState(show),
7641
7649
  _useState2 = _slicedToArray(_useState, 2),
7642
7650
  open = _useState2[0],
@@ -7663,7 +7671,7 @@ var Overlay = /*#__PURE__*/React.forwardRef(function (_ref, forwardedRef) {
7663
7671
  });
7664
7672
  Overlay.displayName = 'Overlay';
7665
7673
 
7666
- var _excluded$r = ["children", "className", "contentClassName", "onClose", "overlayClassName", "show", "shards", "autoFocus"];
7674
+ var _excluded$s = ["children", "className", "contentClassName", "onClose", "overlayClassName", "show", "shards", "autoFocus"];
7667
7675
  var ModalOverlay = function ModalOverlay(_ref) {
7668
7676
  var children = _ref.children,
7669
7677
  className = _ref.className,
@@ -7674,7 +7682,7 @@ var ModalOverlay = function ModalOverlay(_ref) {
7674
7682
  show = _ref$show === void 0 ? true : _ref$show,
7675
7683
  shards = _ref.shards,
7676
7684
  autoFocus = _ref.autoFocus,
7677
- rest = _objectWithoutProperties(_ref, _excluded$r);
7685
+ rest = _objectWithoutProperties(_ref, _excluded$s);
7678
7686
  var element = React.useMemo(function () {
7679
7687
  return typeof document !== 'undefined' ? document.createElement('div') : null;
7680
7688
  }, []);
@@ -7687,7 +7695,7 @@ var ModalOverlay = function ModalOverlay(_ref) {
7687
7695
  };
7688
7696
  }, [element]);
7689
7697
  if (!element) return null;
7690
- return /*#__PURE__*/require$$1.createPortal(/*#__PURE__*/React.createElement(Overlay, _extends$1({
7698
+ return /*#__PURE__*/reactDom.createPortal(/*#__PURE__*/React.createElement(Overlay, _extends$1({
7691
7699
  className: classNames('ModalOverlay', overlayClassName),
7692
7700
  show: show
7693
7701
  }, rest), /*#__PURE__*/React.createElement(Modal, {
@@ -7700,6 +7708,26 @@ var ModalOverlay = function ModalOverlay(_ref) {
7700
7708
  }, children))), element);
7701
7709
  };
7702
7710
 
7711
+ var _excluded$r = ["className", "children", "space", "direction", "alignItems", "justifyContent", "style"];
7712
+ var Stack = function Stack(_ref) {
7713
+ var className = _ref.className,
7714
+ children = _ref.children,
7715
+ space = _ref.space,
7716
+ _ref$direction = _ref.direction,
7717
+ direction = _ref$direction === void 0 ? 'vertical' : _ref$direction,
7718
+ alignItems = _ref.alignItems,
7719
+ justifyContent = _ref.justifyContent,
7720
+ style = _ref.style,
7721
+ rest = _objectWithoutProperties(_ref, _excluded$r);
7722
+ return /*#__PURE__*/React.createElement("div", _extends$1({
7723
+ className: classNames("Stack Stack--".concat(direction, "-").concat(space), className),
7724
+ style: _objectSpread2(_objectSpread2({}, style), {}, {
7725
+ alignItems: alignItems,
7726
+ justifyContent: justifyContent
7727
+ })
7728
+ }, rest), children);
7729
+ };
7730
+
7703
7731
  var _excluded$q = ["as", "className", "treatment", "color", "family", "children", "style"];
7704
7732
  var Text = function Text(_ref) {
7705
7733
  var _ref$as = _ref.as,
@@ -7848,516 +7876,7 @@ var ExceedConstrain = function ExceedConstrain(_ref) {
7848
7876
 
7849
7877
  var reactInputMask = {exports: {}};
7850
7878
 
7851
- var reactInputMask_production_min;
7852
- var hasRequiredReactInputMask_production_min;
7853
- function requireReactInputMask_production_min() {
7854
- if (hasRequiredReactInputMask_production_min) return reactInputMask_production_min;
7855
- hasRequiredReactInputMask_production_min = 1;
7856
- function _interopDefault(e) {
7857
- return e && "object" == _typeof$1(e) && "default" in e ? e["default"] : e;
7858
- }
7859
- var React$1 = _interopDefault(React),
7860
- reactDom = require$$1;
7861
- function _defaults2(e, t) {
7862
- for (var n = Object.getOwnPropertyNames(t), a = 0; a < n.length; a++) {
7863
- var i = n[a],
7864
- r = Object.getOwnPropertyDescriptor(t, i);
7865
- r && r.configurable && e[i] === undefined && Object.defineProperty(e, i, r);
7866
- }
7867
- return e;
7868
- }
7869
- function _extends() {
7870
- return (_extends = Object.assign || function (e) {
7871
- for (var t = 1; t < arguments.length; t++) {
7872
- var n = arguments[t];
7873
- for (var a in n) Object.prototype.hasOwnProperty.call(n, a) && (e[a] = n[a]);
7874
- }
7875
- return e;
7876
- }).apply(this, arguments);
7877
- }
7878
- function _inheritsLoose(e, t) {
7879
- e.prototype = Object.create(t.prototype), _defaults2(e.prototype.constructor = e, t);
7880
- }
7881
- function _objectWithoutPropertiesLoose(e, t) {
7882
- if (null == e) return {};
7883
- var n,
7884
- a,
7885
- i = {},
7886
- r = Object.keys(e);
7887
- for (a = 0; a < r.length; a++) n = r[a], 0 <= t.indexOf(n) || (i[n] = e[n]);
7888
- return i;
7889
- }
7890
- function _assertThisInitialized(e) {
7891
- if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
7892
- return e;
7893
- }
7894
- var invariant = function invariant(e, t, n, a, i, r, o, s) {
7895
- if (!e) {
7896
- var l;
7897
- 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 {
7898
- var u = [n, a, i, r, o, s],
7899
- c = 0;
7900
- (l = new Error(t.replace(/%s/g, function () {
7901
- return u[c++];
7902
- }))).name = "Invariant Violation";
7903
- }
7904
- throw l.framesToPop = 1, l;
7905
- }
7906
- },
7907
- invariant_1 = invariant;
7908
- function setInputSelection(e, t, n) {
7909
- if ("selectionStart" in e && "selectionEnd" in e) e.selectionStart = t, e.selectionEnd = n;else {
7910
- var a = e.createTextRange();
7911
- a.collapse(true), a.moveStart("character", t), a.moveEnd("character", n - t), a.select();
7912
- }
7913
- }
7914
- function getInputSelection(e) {
7915
- var t = 0,
7916
- n = 0;
7917
- if ("selectionStart" in e && "selectionEnd" in e) t = e.selectionStart, n = e.selectionEnd;else {
7918
- var a = document.selection.createRange();
7919
- a.parentElement() === e && (t = -a.moveStart("character", -e.value.length), n = -a.moveEnd("character", -e.value.length));
7920
- }
7921
- return {
7922
- start: t,
7923
- end: n,
7924
- length: n - t
7925
- };
7926
- }
7927
- var defaultFormatChars = {
7928
- 9: "[0-9]",
7929
- a: "[A-Za-z]",
7930
- "*": "[A-Za-z0-9]"
7931
- },
7932
- defaultMaskChar = "_";
7933
- function parseMask(e, t, n) {
7934
- var a = "",
7935
- i = "",
7936
- r = null,
7937
- o = [];
7938
- if (t === undefined && (t = defaultMaskChar), null == n && (n = defaultFormatChars), !e || "string" != typeof e) return {
7939
- maskChar: t,
7940
- formatChars: n,
7941
- mask: null,
7942
- prefix: null,
7943
- lastEditablePosition: null,
7944
- permanents: []
7945
- };
7946
- var s = false;
7947
- return e.split("").forEach(function (e) {
7948
- s = !s && "\\" === e || (s || !n[e] ? (o.push(a.length), a.length === o.length - 1 && (i += e)) : r = a.length + 1, a += e, false);
7949
- }), {
7950
- maskChar: t,
7951
- formatChars: n,
7952
- prefix: i,
7953
- mask: a,
7954
- lastEditablePosition: r,
7955
- permanents: o
7956
- };
7957
- }
7958
- function isPermanentCharacter(e, t) {
7959
- return -1 !== e.permanents.indexOf(t);
7960
- }
7961
- function isAllowedCharacter(e, t, n) {
7962
- var a = e.mask,
7963
- i = e.formatChars;
7964
- if (!n) return false;
7965
- if (isPermanentCharacter(e, t)) return a[t] === n;
7966
- var r = i[a[t]];
7967
- return new RegExp(r).test(n);
7968
- }
7969
- function isEmpty(n, e) {
7970
- return e.split("").every(function (e, t) {
7971
- return isPermanentCharacter(n, t) || !isAllowedCharacter(n, t, e);
7972
- });
7973
- }
7974
- function getFilledLength(e, t) {
7975
- var n = e.maskChar,
7976
- a = e.prefix;
7977
- if (!n) {
7978
- for (; t.length > a.length && isPermanentCharacter(e, t.length - 1);) t = t.slice(0, t.length - 1);
7979
- return t.length;
7980
- }
7981
- for (var i = a.length, r = t.length; r >= a.length; r--) {
7982
- var o = t[r];
7983
- if (!isPermanentCharacter(e, r) && isAllowedCharacter(e, r, o)) {
7984
- i = r + 1;
7985
- break;
7986
- }
7987
- }
7988
- return i;
7989
- }
7990
- function isFilled(e, t) {
7991
- return getFilledLength(e, t) === e.mask.length;
7992
- }
7993
- function formatValue(e, t) {
7994
- var n = e.maskChar,
7995
- a = e.mask,
7996
- i = e.prefix;
7997
- if (!n) {
7998
- for ((t = insertString(e, "", t, 0)).length < i.length && (t = i); t.length < a.length && isPermanentCharacter(e, t.length);) t += a[t.length];
7999
- return t;
8000
- }
8001
- if (t) return insertString(e, formatValue(e, ""), t, 0);
8002
- for (var r = 0; r < a.length; r++) isPermanentCharacter(e, r) ? t += a[r] : t += n;
8003
- return t;
8004
- }
8005
- function clearRange(n, e, a, t) {
8006
- var i = a + t,
8007
- r = n.maskChar,
8008
- o = n.mask,
8009
- s = n.prefix,
8010
- l = e.split("");
8011
- if (r) return l.map(function (e, t) {
8012
- return t < a || i <= t ? e : isPermanentCharacter(n, t) ? o[t] : r;
8013
- }).join("");
8014
- for (var u = i; u < l.length; u++) isPermanentCharacter(n, u) && (l[u] = "");
8015
- return a = Math.max(s.length, a), l.splice(a, i - a), e = l.join(""), formatValue(n, e);
8016
- }
8017
- function insertString(r, o, e, s) {
8018
- var l = r.mask,
8019
- u = r.maskChar,
8020
- c = r.prefix,
8021
- t = e.split(""),
8022
- h = isFilled(r, o);
8023
- return !u && s > o.length && (o += l.slice(o.length, s)), t.every(function (e) {
8024
- for (; i = e, isPermanentCharacter(r, a = s) && i !== l[a];) {
8025
- if (s >= o.length && (o += l[s]), t = e, n = s, u && isPermanentCharacter(r, n) && t === u) return true;
8026
- if (++s >= l.length) return false;
8027
- }
8028
- var t, n, a, i;
8029
- 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);
8030
- }), o;
8031
- }
8032
- function getInsertStringLength(a, e, t, i) {
8033
- var r = a.mask,
8034
- o = a.maskChar,
8035
- n = t.split(""),
8036
- s = i;
8037
- return n.every(function (e) {
8038
- for (; n = e, isPermanentCharacter(a, t = i) && n !== r[t];) if (++i >= r.length) return false;
8039
- var t, n;
8040
- return (isAllowedCharacter(a, i, e) || e === o) && i++, i < r.length;
8041
- }), i - s;
8042
- }
8043
- function getLeftEditablePosition(e, t) {
8044
- for (var n = t; 0 <= n; --n) if (!isPermanentCharacter(e, n)) return n;
8045
- return null;
8046
- }
8047
- function getRightEditablePosition(e, t) {
8048
- for (var n = e.mask, a = t; a < n.length; ++a) if (!isPermanentCharacter(e, a)) return a;
8049
- return null;
8050
- }
8051
- function getStringValue(e) {
8052
- return e || 0 === e ? e + "" : "";
8053
- }
8054
- function processChange(e, t, n, a, i) {
8055
- var r = e.mask,
8056
- o = e.prefix,
8057
- s = e.lastEditablePosition,
8058
- l = t,
8059
- u = "",
8060
- c = 0,
8061
- h = 0,
8062
- f = Math.min(i.start, n.start);
8063
- 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) {
8064
- if (1 === h && !i.length) f = i.start === n.start ? getRightEditablePosition(e, n.start) : getLeftEditablePosition(e, n.start);
8065
- l = clearRange(e, l, f, h);
8066
- }
8067
- 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), {
8068
- value: l = formatValue(e, l),
8069
- enteredString: u,
8070
- selection: {
8071
- start: f,
8072
- end: f
8073
- }
8074
- };
8075
- }
8076
- function isWindowsPhoneBrowser() {
8077
- var e = new RegExp("windows", "i"),
8078
- t = new RegExp("phone", "i"),
8079
- n = navigator.userAgent;
8080
- return e.test(n) && t.test(n);
8081
- }
8082
- function isFunction(e) {
8083
- return "function" == typeof e;
8084
- }
8085
- function getRequestAnimationFrame() {
8086
- return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame;
8087
- }
8088
- function getCancelAnimationFrame() {
8089
- return window.cancelAnimationFrame || window.webkitCancelRequestAnimationFrame || window.webkitCancelAnimationFrame || window.mozCancelAnimationFrame;
8090
- }
8091
- function defer(e) {
8092
- return (!!getCancelAnimationFrame() ? getRequestAnimationFrame() : function () {
8093
- return setTimeout(e, 1e3 / 60);
8094
- })(e);
8095
- }
8096
- function cancelDefer(e) {
8097
- (getCancelAnimationFrame() || clearTimeout)(e);
8098
- }
8099
- var InputElement = function (c) {
8100
- function e(e) {
8101
- var f = c.call(this, e) || this;
8102
- f.focused = false, f.mounted = false, f.previousSelection = null, f.selectionDeferId = null, f.saveSelectionLoopDeferId = null, f.saveSelectionLoop = function () {
8103
- f.previousSelection = f.getSelection(), f.saveSelectionLoopDeferId = defer(f.saveSelectionLoop);
8104
- }, f.runSaveSelectionLoop = function () {
8105
- null === f.saveSelectionLoopDeferId && f.saveSelectionLoop();
8106
- }, f.stopSaveSelectionLoop = function () {
8107
- null !== f.saveSelectionLoopDeferId && (cancelDefer(f.saveSelectionLoopDeferId), f.saveSelectionLoopDeferId = null, f.previousSelection = null);
8108
- }, f.getInputDOMNode = function () {
8109
- if (!f.mounted) return null;
8110
- var e = reactDom.findDOMNode(_assertThisInitialized(_assertThisInitialized(f))),
8111
- t = "undefined" != typeof window && e instanceof window.Element;
8112
- if (e && !t) return null;
8113
- if ("INPUT" !== e.nodeName && (e = e.querySelector("input")), !e) throw new Error("react-input-mask: inputComponent doesn't contain input node");
8114
- return e;
8115
- }, f.getInputValue = function () {
8116
- var e = f.getInputDOMNode();
8117
- return e ? e.value : null;
8118
- }, f.setInputValue = function (e) {
8119
- var t = f.getInputDOMNode();
8120
- t && (f.value = e, t.value = e);
8121
- }, f.setCursorToEnd = function () {
8122
- var e = getFilledLength(f.maskOptions, f.value),
8123
- t = getRightEditablePosition(f.maskOptions, e);
8124
- null !== t && f.setCursorPosition(t);
8125
- }, f.setSelection = function (e, t, n) {
8126
- void 0 === n && (n = {});
8127
- var a = f.getInputDOMNode(),
8128
- i = f.isFocused();
8129
- a && i && (n.deferred || setInputSelection(a, e, t), null !== f.selectionDeferId && cancelDefer(f.selectionDeferId), f.selectionDeferId = defer(function () {
8130
- f.selectionDeferId = null, setInputSelection(a, e, t);
8131
- }), f.previousSelection = {
8132
- start: e,
8133
- end: t,
8134
- length: Math.abs(t - e)
8135
- });
8136
- }, f.getSelection = function () {
8137
- return getInputSelection(f.getInputDOMNode());
8138
- }, f.getCursorPosition = function () {
8139
- return f.getSelection().start;
8140
- }, f.setCursorPosition = function (e) {
8141
- f.setSelection(e, e);
8142
- }, f.isFocused = function () {
8143
- return f.focused;
8144
- }, f.getBeforeMaskedValueChangeConfig = function () {
8145
- var e = f.maskOptions,
8146
- t = e.mask,
8147
- n = e.maskChar,
8148
- a = e.permanents,
8149
- i = e.formatChars;
8150
- return {
8151
- mask: t,
8152
- maskChar: n,
8153
- permanents: a,
8154
- alwaysShowMask: !!f.props.alwaysShowMask,
8155
- formatChars: i
8156
- };
8157
- }, f.isInputAutofilled = function (e, t, n, a) {
8158
- var i = f.getInputDOMNode();
8159
- try {
8160
- if (i.matches(":-webkit-autofill")) return !0;
8161
- } catch (r) {}
8162
- return !f.focused || a.end < n.length && t.end === e.length;
8163
- }, f.onChange = function (e) {
8164
- var t = _assertThisInitialized(_assertThisInitialized(f)).beforePasteState,
8165
- n = _assertThisInitialized(_assertThisInitialized(f)).previousSelection,
8166
- a = f.props.beforeMaskedValueChange,
8167
- i = f.getInputValue(),
8168
- r = f.value,
8169
- o = f.getSelection();
8170
- f.isInputAutofilled(i, o, r, n) && (r = formatValue(f.maskOptions, ""), n = {
8171
- start: 0,
8172
- end: 0,
8173
- length: 0
8174
- }), t && (n = t.selection, r = t.value, o = {
8175
- start: n.start + i.length,
8176
- end: n.start + i.length,
8177
- length: 0
8178
- }, i = r.slice(0, n.start) + i + r.slice(n.end), f.beforePasteState = null);
8179
- var s = processChange(f.maskOptions, i, o, r, n),
8180
- l = s.enteredString,
8181
- u = s.selection,
8182
- c = s.value;
8183
- if (isFunction(a)) {
8184
- var h = a({
8185
- value: c,
8186
- selection: u
8187
- }, {
8188
- value: r,
8189
- selection: n
8190
- }, l, f.getBeforeMaskedValueChangeConfig());
8191
- c = h.value, u = h.selection;
8192
- }
8193
- f.setInputValue(c), isFunction(f.props.onChange) && f.props.onChange(e), f.isWindowsPhoneBrowser ? f.setSelection(u.start, u.end, {
8194
- deferred: true
8195
- }) : f.setSelection(u.start, u.end);
8196
- }, f.onFocus = function (e) {
8197
- var t = f.props.beforeMaskedValueChange,
8198
- n = f.maskOptions,
8199
- a = n.mask,
8200
- i = n.prefix;
8201
- if (f.focused = true, f.mounted = true, a) {
8202
- if (f.value) getFilledLength(f.maskOptions, f.value) < f.maskOptions.mask.length && f.setCursorToEnd();else {
8203
- var r = formatValue(f.maskOptions, i),
8204
- o = formatValue(f.maskOptions, r),
8205
- s = getFilledLength(f.maskOptions, o),
8206
- l = getRightEditablePosition(f.maskOptions, s),
8207
- u = {
8208
- start: l,
8209
- end: l
8210
- };
8211
- if (isFunction(t)) {
8212
- var c = t({
8213
- value: o,
8214
- selection: u
8215
- }, {
8216
- value: f.value,
8217
- selection: null
8218
- }, null, f.getBeforeMaskedValueChangeConfig());
8219
- o = c.value, u = c.selection;
8220
- }
8221
- var h = o !== f.getInputValue();
8222
- h && f.setInputValue(o), h && isFunction(f.props.onChange) && f.props.onChange(e), f.setSelection(u.start, u.end);
8223
- }
8224
- f.runSaveSelectionLoop();
8225
- }
8226
- isFunction(f.props.onFocus) && f.props.onFocus(e);
8227
- }, f.onBlur = function (e) {
8228
- var t = f.props.beforeMaskedValueChange,
8229
- n = f.maskOptions.mask;
8230
- if (f.stopSaveSelectionLoop(), f.focused = false, n && !f.props.alwaysShowMask && isEmpty(f.maskOptions, f.value)) {
8231
- var a = "";
8232
- if (isFunction(t)) a = t({
8233
- value: a,
8234
- selection: null
8235
- }, {
8236
- value: f.value,
8237
- selection: f.previousSelection
8238
- }, null, f.getBeforeMaskedValueChangeConfig()).value;
8239
- var i = a !== f.getInputValue();
8240
- i && f.setInputValue(a), i && isFunction(f.props.onChange) && f.props.onChange(e);
8241
- }
8242
- isFunction(f.props.onBlur) && f.props.onBlur(e);
8243
- }, f.onMouseDown = function (e) {
8244
- if (!f.focused && document.addEventListener) {
8245
- f.mouseDownX = e.clientX, f.mouseDownY = e.clientY, f.mouseDownTime = new Date().getTime();
8246
- var r = function r(e) {
8247
- if (document.removeEventListener("mouseup", r), f.focused) {
8248
- var t = Math.abs(e.clientX - f.mouseDownX),
8249
- n = Math.abs(e.clientY - f.mouseDownY),
8250
- a = Math.max(t, n),
8251
- i = new Date().getTime() - f.mouseDownTime;
8252
- (a <= 10 && i <= 200 || a <= 5 && i <= 300) && f.setCursorToEnd();
8253
- }
8254
- };
8255
- document.addEventListener("mouseup", r);
8256
- }
8257
- isFunction(f.props.onMouseDown) && f.props.onMouseDown(e);
8258
- }, f.onPaste = function (e) {
8259
- isFunction(f.props.onPaste) && f.props.onPaste(e), e.defaultPrevented || (f.beforePasteState = {
8260
- value: f.getInputValue(),
8261
- selection: f.getSelection()
8262
- }, f.setInputValue(""));
8263
- }, f.handleRef = function (e) {
8264
- null == f.props.children && isFunction(f.props.inputRef) && f.props.inputRef(e);
8265
- };
8266
- var t = e.mask,
8267
- n = e.maskChar,
8268
- a = e.formatChars,
8269
- i = e.alwaysShowMask,
8270
- r = e.beforeMaskedValueChange,
8271
- o = e.defaultValue,
8272
- s = e.value;
8273
- f.maskOptions = parseMask(t, n, a), null == o && (o = ""), null == s && (s = o);
8274
- var l = getStringValue(s);
8275
- if (f.maskOptions.mask && (i || l) && (l = formatValue(f.maskOptions, l), isFunction(r))) {
8276
- var u = e.value;
8277
- null == e.value && (u = o), l = r({
8278
- value: l,
8279
- selection: null
8280
- }, {
8281
- value: u = getStringValue(u),
8282
- selection: null
8283
- }, null, f.getBeforeMaskedValueChangeConfig()).value;
8284
- }
8285
- return f.value = l, f;
8286
- }
8287
- _inheritsLoose(e, c);
8288
- var t = e.prototype;
8289
- return t.componentDidMount = function () {
8290
- this.mounted = true, this.getInputDOMNode() && (this.isWindowsPhoneBrowser = isWindowsPhoneBrowser(), this.maskOptions.mask && this.getInputValue() !== this.value && this.setInputValue(this.value));
8291
- }, t.componentDidUpdate = function () {
8292
- var e = this.previousSelection,
8293
- t = this.props,
8294
- n = t.beforeMaskedValueChange,
8295
- a = t.alwaysShowMask,
8296
- i = t.mask,
8297
- r = t.maskChar,
8298
- o = t.formatChars,
8299
- s = this.maskOptions,
8300
- l = a || this.isFocused(),
8301
- u = null != this.props.value,
8302
- c = u ? getStringValue(this.props.value) : this.value,
8303
- h = e ? e.start : null;
8304
- if (this.maskOptions = parseMask(i, r, o), this.maskOptions.mask) {
8305
- !s.mask && this.isFocused() && this.runSaveSelectionLoop();
8306
- var f = this.maskOptions.mask && this.maskOptions.mask !== s.mask;
8307
- if (s.mask || u || (c = this.getInputValue()), (f || this.maskOptions.mask && (c || l)) && (c = formatValue(this.maskOptions, c)), f) {
8308
- var p = getFilledLength(this.maskOptions, c);
8309
- (null === h || p < h) && (h = isFilled(this.maskOptions, c) ? p : getRightEditablePosition(this.maskOptions, p));
8310
- }
8311
- !this.maskOptions.mask || !isEmpty(this.maskOptions, c) || l || u && this.props.value || (c = "");
8312
- var d = {
8313
- start: h,
8314
- end: h
8315
- };
8316
- if (isFunction(n)) {
8317
- var m = n({
8318
- value: c,
8319
- selection: d
8320
- }, {
8321
- value: this.value,
8322
- selection: this.previousSelection
8323
- }, null, this.getBeforeMaskedValueChangeConfig());
8324
- c = m.value, d = m.selection;
8325
- }
8326
- this.value = c;
8327
- var g = this.getInputValue() !== this.value;
8328
- g ? (this.setInputValue(this.value), this.forceUpdate()) : f && this.forceUpdate();
8329
- var v = false;
8330
- null != d.start && null != d.end && (v = !e || e.start !== d.start || e.end !== d.end), (v || g) && this.setSelection(d.start, d.end);
8331
- } else s.mask && (this.stopSaveSelectionLoop(), this.forceUpdate());
8332
- }, t.componentWillUnmount = function () {
8333
- this.mounted = false, null !== this.selectionDeferId && cancelDefer(this.selectionDeferId), this.stopSaveSelectionLoop();
8334
- }, t.render = function () {
8335
- var t,
8336
- e = this.props,
8337
- n = (e.mask, e.alwaysShowMask, e.maskChar, e.formatChars, e.inputRef, e.beforeMaskedValueChange, e.children),
8338
- a = _objectWithoutPropertiesLoose(e, ["mask", "alwaysShowMask", "maskChar", "formatChars", "inputRef", "beforeMaskedValueChange", "children"]);
8339
- if (n) {
8340
- isFunction(n) || invariant_1(false);
8341
- var i = ["onChange", "onPaste", "onMouseDown", "onFocus", "onBlur", "value", "disabled", "readOnly"],
8342
- r = _extends({}, a);
8343
- i.forEach(function (e) {
8344
- return delete r[e];
8345
- }), t = n(r), i.filter(function (e) {
8346
- return null != t.props[e] && t.props[e] !== a[e];
8347
- }).length && invariant_1(false);
8348
- } else t = React$1.createElement("input", _extends({
8349
- ref: this.handleRef
8350
- }, a));
8351
- var o = {
8352
- onFocus: this.onFocus,
8353
- onBlur: this.onBlur
8354
- };
8355
- 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);
8356
- }, e;
8357
- }(React$1.Component);
8358
- reactInputMask_production_min = InputElement;
8359
- return reactInputMask_production_min;
8360
- }
7879
+ var reactInputMask_production_min = {exports: {}};
8361
7880
 
8362
7881
  /**
8363
7882
  * Copyright (c) 2013-present, Facebook, Inc.
@@ -8469,31 +7988,527 @@ function requireWarning() {
8469
7988
  return warning_1;
8470
7989
  }
8471
7990
 
7991
+ var hasRequiredReactInputMask_production_min;
7992
+ function requireReactInputMask_production_min() {
7993
+ if (hasRequiredReactInputMask_production_min) return reactInputMask_production_min.exports;
7994
+ hasRequiredReactInputMask_production_min = 1;
7995
+ var e = React;
7996
+ var t = requireInvariant();
7997
+ function n() {
7998
+ return n = Object.assign ? Object.assign.bind() : function (e) {
7999
+ for (var t = 1; t < arguments.length; t++) {
8000
+ var n = arguments[t];
8001
+ for (var i in n) Object.prototype.hasOwnProperty.call(n, i) && (e[i] = n[i]);
8002
+ }
8003
+ return e;
8004
+ }, n.apply(this, arguments);
8005
+ }
8006
+ function i(e) {
8007
+ return requestAnimationFrame(e);
8008
+ }
8009
+ function r(e) {
8010
+ cancelAnimationFrame(e);
8011
+ }
8012
+ function a(e) {
8013
+ var t = e.ownerDocument;
8014
+ return t.hasFocus() && t.activeElement === e;
8015
+ }
8016
+ function l(e) {
8017
+ return null == e ? void 0 : e.ownerDocument;
8018
+ }
8019
+ function o(e) {
8020
+ var t = function (e) {
8021
+ var t;
8022
+ return null == (t = l(e)) ? void 0 : t.defaultView;
8023
+ }(e);
8024
+ return !!t && e instanceof t.HTMLElement;
8025
+ }
8026
+ function u(t) {
8027
+ return e.useCallback(function () {
8028
+ var e = t.current,
8029
+ n = "undefined" != typeof window && o(e);
8030
+ if (!e || !n) return null;
8031
+ if ("INPUT" !== e.nodeName && (e = e.querySelector("input")), !e) throw new Error("react-input-mask: inputComponent doesn't contain input node");
8032
+ return e;
8033
+ }, [t]);
8034
+ }
8035
+ function s(t, n) {
8036
+ var l,
8037
+ o,
8038
+ s,
8039
+ c,
8040
+ f = e.useRef({
8041
+ start: null,
8042
+ end: null
8043
+ }),
8044
+ h = u(t),
8045
+ g = e.useCallback(function () {
8046
+ return function (e) {
8047
+ var t = e.selectionStart,
8048
+ n = e.selectionEnd;
8049
+ return {
8050
+ start: t,
8051
+ end: n,
8052
+ length: n - t
8053
+ };
8054
+ }(h());
8055
+ }, [h]),
8056
+ v = e.useCallback(function () {
8057
+ return f.current;
8058
+ }, []),
8059
+ d = e.useCallback(function (e) {
8060
+ var t = h();
8061
+ t && a(t) && (!function (e, t, n) {
8062
+ void 0 === n && (n = t), e.setSelectionRange(t, n);
8063
+ }(t, e.start, e.end), f.current = g());
8064
+ }, [h, g]),
8065
+ m = e.useCallback(function () {
8066
+ f.current = g();
8067
+ }, [g]),
8068
+ p = (l = m, o = e.useRef(null), s = e.useCallback(function () {
8069
+ null === o.current && function e() {
8070
+ l(), o.current = i(e);
8071
+ }();
8072
+ }, [l]), c = e.useCallback(function () {
8073
+ r(o.current), o.current = null;
8074
+ }, []), e.useEffect(function () {
8075
+ o.current && (c(), s());
8076
+ }, [s, c]), e.useEffect(r, []), [s, c]),
8077
+ k = p[0],
8078
+ P = p[1];
8079
+ return e.useLayoutEffect(function () {
8080
+ if (n) {
8081
+ var e = h();
8082
+ return e.addEventListener("focus", k), e.addEventListener("blur", P), a(e) && k(), function () {
8083
+ e.removeEventListener("focus", k), e.removeEventListener("blur", P), P();
8084
+ };
8085
+ }
8086
+ }), {
8087
+ getSelection: g,
8088
+ getLastSelection: v,
8089
+ setSelection: d
8090
+ };
8091
+ }
8092
+ function c(t, n) {
8093
+ var i = e.useRef(),
8094
+ r = s(i, n),
8095
+ a = r.getSelection,
8096
+ l = r.getLastSelection,
8097
+ o = r.setSelection,
8098
+ c = function (t, n) {
8099
+ var i = u(t),
8100
+ r = e.useRef(n);
8101
+ return {
8102
+ getValue: e.useCallback(function () {
8103
+ return i().value;
8104
+ }, [i]),
8105
+ getLastValue: e.useCallback(function () {
8106
+ return r.current;
8107
+ }, []),
8108
+ setValue: e.useCallback(function (e) {
8109
+ r.current = e;
8110
+ var t = i();
8111
+ t && (t.value = e);
8112
+ }, [i])
8113
+ };
8114
+ }(i, t),
8115
+ f = c.getValue,
8116
+ h = c.getLastValue,
8117
+ g = c.setValue;
8118
+ return {
8119
+ inputRef: i,
8120
+ getInputState: function getInputState() {
8121
+ return {
8122
+ value: f(),
8123
+ selection: a()
8124
+ };
8125
+ },
8126
+ getLastInputState: function getLastInputState() {
8127
+ return {
8128
+ value: h(),
8129
+ selection: l()
8130
+ };
8131
+ },
8132
+ setInputState: function setInputState(e) {
8133
+ var t = e.value,
8134
+ n = e.selection;
8135
+ g(t), o(n);
8136
+ }
8137
+ };
8138
+ }
8139
+ requireWarning();
8140
+ var f = ["disabled", "onBlur", "onChange", "onFocus", "onMouseDown", "readOnly", "value"],
8141
+ h = {
8142
+ 9: /[0-9]/,
8143
+ a: /[A-Za-z]/,
8144
+ "*": /[A-Za-z0-9]/
8145
+ };
8146
+ var g = function g(e) {
8147
+ var t = this;
8148
+ this.isCharacterAllowedAtPosition = function (e, n) {
8149
+ var i = t.maskOptions.maskPlaceholder;
8150
+ return !!t.isCharacterFillingPosition(e, n) || !!i && i[n] === e;
8151
+ }, this.isCharacterFillingPosition = function (e, n) {
8152
+ var i = t.maskOptions.mask;
8153
+ if (!e || n >= i.length) return false;
8154
+ if (!t.isPositionEditable(n)) return i[n] === e;
8155
+ var r = i[n];
8156
+ return new RegExp(r).test(e);
8157
+ }, this.isPositionEditable = function (e) {
8158
+ var n = t.maskOptions,
8159
+ i = n.mask,
8160
+ r = n.permanents;
8161
+ return e < i.length && -1 === r.indexOf(e);
8162
+ }, this.isValueEmpty = function (e) {
8163
+ return e.split("").every(function (e, n) {
8164
+ return !t.isPositionEditable(n) || !t.isCharacterFillingPosition(e, n);
8165
+ });
8166
+ }, this.isValueFilled = function (e) {
8167
+ return t.getFilledLength(e) === t.maskOptions.lastEditablePosition + 1;
8168
+ }, this.getDefaultSelectionForValue = function (e) {
8169
+ var n = t.getFilledLength(e),
8170
+ i = t.getRightEditablePosition(n);
8171
+ return {
8172
+ start: i,
8173
+ end: i
8174
+ };
8175
+ }, this.getFilledLength = function (e) {
8176
+ return function (e, t) {
8177
+ for (var n = e.length - 1; n >= 0; n--) if (t(e[n], n)) return n;
8178
+ return -1;
8179
+ }(e.split(""), function (e, n) {
8180
+ return t.isPositionEditable(n) && t.isCharacterFillingPosition(e, n);
8181
+ }) + 1;
8182
+ }, this.getStringFillingLengthAtPosition = function (e, n) {
8183
+ return e.split("").reduce(function (e, n) {
8184
+ return t.insertCharacterAtPosition(e, n, e.length);
8185
+ }, function (e, t) {
8186
+ void 0 === t && (t = 1);
8187
+ for (var n = "", i = 0; i < t; i++) n += e;
8188
+ return n;
8189
+ }(" ", n)).length - n;
8190
+ }, this.getLeftEditablePosition = function (e) {
8191
+ for (var n = e; n >= 0; n--) if (t.isPositionEditable(n)) return n;
8192
+ return null;
8193
+ }, this.getRightEditablePosition = function (e) {
8194
+ for (var n = t.maskOptions.mask, i = e; i < n.length; i++) if (t.isPositionEditable(i)) return i;
8195
+ return null;
8196
+ }, this.formatValue = function (e) {
8197
+ var n = t.maskOptions,
8198
+ i = n.maskPlaceholder,
8199
+ r = n.mask;
8200
+ if (!i) {
8201
+ for (e = t.insertStringAtPosition("", e, 0); e.length < r.length && !t.isPositionEditable(e.length);) e += r[e.length];
8202
+ return e;
8203
+ }
8204
+ return t.insertStringAtPosition(i, e, 0);
8205
+ }, this.clearRange = function (e, n, i) {
8206
+ if (!i) return e;
8207
+ var r = n + i,
8208
+ a = t.maskOptions,
8209
+ l = a.maskPlaceholder,
8210
+ o = a.mask,
8211
+ u = e.split("").map(function (e, i) {
8212
+ var a = t.isPositionEditable(i);
8213
+ return !l && i >= r && !a ? "" : i < n || i >= r ? e : a ? l ? l[i] : "" : o[i];
8214
+ }).join("");
8215
+ return t.formatValue(u);
8216
+ }, this.insertCharacterAtPosition = function (e, n, i) {
8217
+ var r = t.maskOptions,
8218
+ a = r.mask,
8219
+ l = r.maskPlaceholder;
8220
+ if (i >= a.length) return e;
8221
+ var o = t.isCharacterAllowedAtPosition(n, i),
8222
+ u = t.isPositionEditable(i),
8223
+ s = t.getRightEditablePosition(i),
8224
+ c = l && s ? n === l[s] : null,
8225
+ f = e.slice(0, i);
8226
+ !o && u || (e = f + (o ? n : a[i]));
8227
+ return o || u || c || (e = t.insertCharacterAtPosition(e, n, i + 1)), e;
8228
+ }, this.insertStringAtPosition = function (e, n, i) {
8229
+ var r = t.maskOptions,
8230
+ a = r.mask,
8231
+ l = r.maskPlaceholder;
8232
+ if (!n || i >= a.length) return e;
8233
+ var o = n.split(""),
8234
+ u = t.isValueFilled(e) || !!l,
8235
+ s = e.slice(i);
8236
+ if (e = o.reduce(function (e, n) {
8237
+ return t.insertCharacterAtPosition(e, n, e.length);
8238
+ }, e.slice(0, i)), u) e += s.slice(e.length - i);else if (t.isValueFilled(e)) e += a.slice(e.length).join("");else {
8239
+ e = s.split("").filter(function (e, n) {
8240
+ return t.isPositionEditable(i + n);
8241
+ }).reduce(function (e, n) {
8242
+ var i = t.getRightEditablePosition(e.length);
8243
+ return null === i ? e : (t.isPositionEditable(e.length) || (e += a.slice(e.length, i).join("")), t.insertCharacterAtPosition(e, n, e.length));
8244
+ }, e);
8245
+ }
8246
+ return e;
8247
+ }, this.processChange = function (e, n) {
8248
+ var i = t.maskOptions,
8249
+ r = i.mask,
8250
+ a = i.prefix,
8251
+ l = i.lastEditablePosition,
8252
+ o = e.value,
8253
+ u = e.selection,
8254
+ s = n.value,
8255
+ c = n.selection,
8256
+ f = o,
8257
+ h = "",
8258
+ g = 0,
8259
+ v = 0,
8260
+ d = Math.min(c.start, u.start);
8261
+ if (u.end > c.start ? (h = f.slice(c.start, u.end), v = (g = t.getStringFillingLengthAtPosition(h, d)) ? c.length : 0) : f.length < s.length && (v = s.length - f.length), f = s, v) {
8262
+ if (1 === v && !c.length) d = c.start === u.start ? t.getRightEditablePosition(u.start) : t.getLeftEditablePosition(u.start);
8263
+ f = t.clearRange(f, d, v);
8264
+ }
8265
+ return f = t.insertStringAtPosition(f, h, d), (d += g) >= r.length ? d = r.length : d < a.length && !g ? d = a.length : d >= a.length && d < l && g && (d = t.getRightEditablePosition(d)), {
8266
+ value: f = t.formatValue(f),
8267
+ enteredString: h,
8268
+ selection: {
8269
+ start: d,
8270
+ end: d
8271
+ }
8272
+ };
8273
+ }, this.maskOptions = function (e) {
8274
+ var t = e.mask,
8275
+ n = e.maskPlaceholder,
8276
+ i = [];
8277
+ if (!t) return {
8278
+ maskPlaceholder: null,
8279
+ mask: null,
8280
+ prefix: null,
8281
+ lastEditablePosition: null,
8282
+ permanents: []
8283
+ };
8284
+ if ("string" == typeof t) {
8285
+ var r = false,
8286
+ a = "";
8287
+ t.split("").forEach(function (e) {
8288
+ r || "\\" !== e ? (!r && h[e] || i.push(a.length), a += e, r = false) : r = true;
8289
+ }), t = a.split("").map(function (e, t) {
8290
+ return -1 === i.indexOf(t) ? h[e] : e;
8291
+ });
8292
+ } else t.forEach(function (e, t) {
8293
+ "string" == typeof e && i.push(t);
8294
+ });
8295
+ n && (n = 1 === n.length ? t.map(function (e, t) {
8296
+ return -1 !== i.indexOf(t) ? e : n;
8297
+ }) : n.split(""), i.forEach(function (e) {
8298
+ n[e] = t[e];
8299
+ }), n = n.join(""));
8300
+ for (var l = i.filter(function (e, t) {
8301
+ return e === t;
8302
+ }).map(function (e) {
8303
+ return t[e];
8304
+ }).join(""), o = t.length - 1; -1 !== i.indexOf(o);) o--;
8305
+ return {
8306
+ maskPlaceholder: n,
8307
+ prefix: l,
8308
+ mask: t,
8309
+ lastEditablePosition: o,
8310
+ permanents: i
8311
+ };
8312
+ }(e);
8313
+ },
8314
+ v = ["alwaysShowMask", "children", "mask", "maskPlaceholder", "beforeMaskedStateChange"],
8315
+ d = e.forwardRef(function (r, o) {
8316
+ var s = r.alwaysShowMask,
8317
+ h = r.children,
8318
+ d = r.mask,
8319
+ m = r.maskPlaceholder,
8320
+ p = r.beforeMaskedStateChange,
8321
+ k = function (e, t) {
8322
+ if (null == e) return {};
8323
+ var n,
8324
+ i,
8325
+ r = {},
8326
+ a = Object.keys(e);
8327
+ for (i = 0; i < a.length; i++) n = a[i], t.indexOf(n) >= 0 || (r[n] = e[n]);
8328
+ return r;
8329
+ }(r, v);
8330
+ !function (e) {
8331
+ var n = e.mask,
8332
+ i = e.maskPlaceholder;
8333
+ n && i && 1 !== i.length && i.length !== n.length && t(false);
8334
+ }(r);
8335
+ var P,
8336
+ b,
8337
+ E = new g({
8338
+ mask: d,
8339
+ maskPlaceholder: m
8340
+ }),
8341
+ S = !!d,
8342
+ C = !k.disabled && !k.readOnly,
8343
+ w = null !== r.value && void 0 !== r.value,
8344
+ V = (P = S, b = e.useRef(), e.useEffect(function () {
8345
+ b.current = P;
8346
+ }), b.current),
8347
+ F = function (e) {
8348
+ return "" + e;
8349
+ }((w ? r.value : r.defaultValue) || ""),
8350
+ y = c(F, S),
8351
+ O = y.inputRef,
8352
+ L = y.getInputState,
8353
+ A = y.setInputState,
8354
+ R = y.getLastInputState,
8355
+ x = u(O);
8356
+ if (S && w) {
8357
+ var M = x(),
8358
+ D = M && a(M) || s || r.value ? E.formatValue(r.value) : r.value;
8359
+ p && (D = p({
8360
+ nextState: {
8361
+ value: D,
8362
+ selection: {
8363
+ start: null,
8364
+ end: null
8365
+ }
8366
+ }
8367
+ }).value), A(n({}, R(), {
8368
+ value: D
8369
+ }));
8370
+ }
8371
+ var j = R(),
8372
+ I = j.selection,
8373
+ q = j.value;
8374
+ e.useLayoutEffect(function () {
8375
+ if (S) {
8376
+ var e = x();
8377
+ if (e) {
8378
+ var t = a(e),
8379
+ i = I,
8380
+ r = L(),
8381
+ l = n({}, r);
8382
+ if (!w) {
8383
+ var o = r.value,
8384
+ u = E.formatValue(o),
8385
+ c = E.isValueEmpty(u);
8386
+ !c || t || s ? l.value = u : c && !t && (l.value = "");
8387
+ }
8388
+ t && !V ? l.selection = E.getDefaultSelectionForValue(l.value) : w && t && i && null !== i.start && null !== i.end && (l.selection = i), p && (l = p({
8389
+ currentState: r,
8390
+ nextState: l
8391
+ })), A(l);
8392
+ }
8393
+ }
8394
+ });
8395
+ var B = function B(e) {
8396
+ O.current = e, !function (e) {
8397
+ return "function" == typeof e;
8398
+ }(o) ? null !== o && "object" == _typeof$1(o) && (o.current = e) : o(e);
8399
+ },
8400
+ T = n({}, k, {
8401
+ onFocus: function onFocus(e) {
8402
+ O.current = e.target;
8403
+ var t = L().value;
8404
+ if (S && !E.isValueFilled(t)) {
8405
+ var n = E.formatValue(t),
8406
+ a = E.getDefaultSelectionForValue(n),
8407
+ l = {
8408
+ value: n,
8409
+ selection: a
8410
+ };
8411
+ p && (n = (l = p({
8412
+ currentState: L(),
8413
+ nextState: l
8414
+ })).value, a = l.selection), A(l), n !== t && r.onChange && r.onChange(e), i(function () {
8415
+ A(R());
8416
+ });
8417
+ }
8418
+ r.onFocus && r.onFocus(e);
8419
+ },
8420
+ onBlur: function onBlur(e) {
8421
+ var t = L().value,
8422
+ n = R().value;
8423
+ if (S && !s && E.isValueEmpty(n)) {
8424
+ var i = "",
8425
+ a = {
8426
+ value: i,
8427
+ selection: {
8428
+ start: null,
8429
+ end: null
8430
+ }
8431
+ };
8432
+ p && (i = (a = p({
8433
+ currentState: L(),
8434
+ nextState: a
8435
+ })).value), A(a), i !== t && r.onChange && r.onChange(e);
8436
+ }
8437
+ r.onBlur && r.onBlur(e);
8438
+ },
8439
+ onChange: S && C ? function (e) {
8440
+ var t = L(),
8441
+ n = R(),
8442
+ i = E.processChange(t, n);
8443
+ p && (i = p({
8444
+ currentState: t,
8445
+ previousState: n,
8446
+ nextState: i
8447
+ })), A(i), r.onChange && r.onChange(e);
8448
+ } : r.onChange,
8449
+ onMouseDown: S && C ? function (e) {
8450
+ var t = x();
8451
+ if (t) {
8452
+ var i = L().value,
8453
+ o = l(t);
8454
+ if (!a(t) && !E.isValueFilled(i)) {
8455
+ var u = e.clientX,
8456
+ s = e.clientY,
8457
+ c = new Date().getTime();
8458
+ o.addEventListener("mouseup", function e(i) {
8459
+ if (o.removeEventListener("mouseup", e), a(t)) {
8460
+ var r = Math.abs(i.clientX - u),
8461
+ l = Math.abs(i.clientY - s),
8462
+ f = Math.max(r, l),
8463
+ h = new Date().getTime() - c;
8464
+ if (f <= 10 && h <= 200 || f <= 5 && h <= 300) {
8465
+ var g = R(),
8466
+ v = n({}, g, {
8467
+ selection: E.getDefaultSelectionForValue(g.value)
8468
+ });
8469
+ A(v);
8470
+ }
8471
+ }
8472
+ });
8473
+ }
8474
+ r.onMouseDown && r.onMouseDown(e);
8475
+ }
8476
+ } : r.onMouseDown,
8477
+ value: S && w ? q : r.value
8478
+ });
8479
+ if (h) {
8480
+ !function (e, n) {
8481
+ f.filter(function (t) {
8482
+ return null != n.props[t] && n.props[t] !== e[t];
8483
+ }).length && t(false);
8484
+ }(r, h);
8485
+ var N = e.Children.only(h);
8486
+ return e.cloneElement(N, n({}, T, {
8487
+ ref: B
8488
+ }));
8489
+ }
8490
+ return e.createElement("input", n({
8491
+ ref: B
8492
+ }, T));
8493
+ });
8494
+ d.displayName = "InputMask", d.defaultProps = {
8495
+ alwaysShowMask: false,
8496
+ maskPlaceholder: "_"
8497
+ }, reactInputMask_production_min.exports = d;
8498
+ return reactInputMask_production_min.exports;
8499
+ }
8500
+
8472
8501
  var reactInputMask_development;
8473
8502
  var hasRequiredReactInputMask_development;
8474
8503
  function requireReactInputMask_development() {
8475
8504
  if (hasRequiredReactInputMask_development) return reactInputMask_development;
8476
8505
  hasRequiredReactInputMask_development = 1;
8477
- function _interopDefault(ex) {
8478
- return ex && _typeof$1(ex) === 'object' && 'default' in ex ? ex['default'] : ex;
8479
- }
8480
- var React$1 = _interopDefault(React);
8481
- var reactDom = require$$1;
8482
- var invariant = _interopDefault(requireInvariant());
8483
- var warning = _interopDefault(requireWarning());
8484
- function _defaults2(obj, defaults) {
8485
- var keys = Object.getOwnPropertyNames(defaults);
8486
- for (var i = 0; i < keys.length; i++) {
8487
- var key = keys[i];
8488
- var value = Object.getOwnPropertyDescriptor(defaults, key);
8489
- if (value && value.configurable && obj[key] === undefined) {
8490
- Object.defineProperty(obj, key, value);
8491
- }
8492
- }
8493
- return obj;
8494
- }
8506
+ var React$1 = React;
8507
+ var PropTypes = /*@__PURE__*/requirePropTypes();
8508
+ var invariant = requireInvariant();
8509
+ var warning = requireWarning();
8495
8510
  function _extends() {
8496
- _extends = Object.assign || function (target) {
8511
+ _extends = Object.assign ? Object.assign.bind() : function (target) {
8497
8512
  for (var i = 1; i < arguments.length; i++) {
8498
8513
  var source = arguments[i];
8499
8514
  for (var key in source) {
@@ -8506,11 +8521,6 @@ function requireReactInputMask_development() {
8506
8521
  };
8507
8522
  return _extends.apply(this, arguments);
8508
8523
  }
8509
- function _inheritsLoose(subClass, superClass) {
8510
- subClass.prototype = Object.create(superClass.prototype);
8511
- subClass.prototype.constructor = subClass;
8512
- _defaults2(subClass, superClass);
8513
- }
8514
8524
  function _objectWithoutPropertiesLoose(source, excluded) {
8515
8525
  if (source == null) return {};
8516
8526
  var target = {};
@@ -8523,895 +8533,825 @@ function requireReactInputMask_development() {
8523
8533
  }
8524
8534
  return target;
8525
8535
  }
8526
- function _assertThisInitialized(self) {
8527
- if (self === void 0) {
8528
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
8529
- }
8530
- return self;
8536
+ function defer(fn) {
8537
+ return requestAnimationFrame(fn);
8538
+ }
8539
+ function cancelDefer(deferId) {
8540
+ cancelAnimationFrame(deferId);
8531
8541
  }
8532
8542
  function setInputSelection(input, start, end) {
8533
- if ('selectionStart' in input && 'selectionEnd' in input) {
8534
- input.selectionStart = start;
8535
- input.selectionEnd = end;
8536
- } else {
8537
- var range = input.createTextRange();
8538
- range.collapse(true);
8539
- range.moveStart('character', start);
8540
- range.moveEnd('character', end - start);
8541
- range.select();
8543
+ if (end === undefined) {
8544
+ end = start;
8542
8545
  }
8546
+ input.setSelectionRange(start, end);
8543
8547
  }
8544
8548
  function getInputSelection(input) {
8545
- var start = 0;
8546
- var end = 0;
8547
- if ('selectionStart' in input && 'selectionEnd' in input) {
8548
- start = input.selectionStart;
8549
- end = input.selectionEnd;
8550
- } else {
8551
- var range = document.selection.createRange();
8552
- if (range.parentElement() === input) {
8553
- start = -range.moveStart('character', -input.value.length);
8554
- end = -range.moveEnd('character', -input.value.length);
8555
- }
8556
- }
8549
+ var start = input.selectionStart;
8550
+ var end = input.selectionEnd;
8557
8551
  return {
8558
8552
  start: start,
8559
8553
  end: end,
8560
8554
  length: end - start
8561
8555
  };
8562
8556
  }
8563
- var defaultFormatChars = {
8564
- '9': '[0-9]',
8565
- 'a': '[A-Za-z]',
8566
- '*': '[A-Za-z0-9]'
8567
- };
8568
- var defaultMaskChar = '_';
8569
- function parseMask(mask, maskChar, formatChars) {
8570
- var parsedMaskString = '';
8571
- var prefix = '';
8572
- var lastEditablePosition = null;
8573
- var permanents = [];
8574
- if (maskChar === undefined) {
8575
- maskChar = defaultMaskChar;
8576
- }
8577
- if (formatChars == null) {
8578
- formatChars = defaultFormatChars;
8579
- }
8580
- if (!mask || typeof mask !== 'string') {
8581
- return {
8582
- maskChar: maskChar,
8583
- formatChars: formatChars,
8584
- mask: null,
8585
- prefix: null,
8586
- lastEditablePosition: null,
8587
- permanents: []
8588
- };
8589
- }
8590
- var isPermanent = false;
8591
- mask.split('').forEach(function (character) {
8592
- if (!isPermanent && character === '\\') {
8593
- isPermanent = true;
8594
- } else {
8595
- if (isPermanent || !formatChars[character]) {
8596
- permanents.push(parsedMaskString.length);
8597
- if (parsedMaskString.length === permanents.length - 1) {
8598
- prefix += character;
8599
- }
8600
- } else {
8601
- lastEditablePosition = parsedMaskString.length + 1;
8602
- }
8603
- parsedMaskString += character;
8604
- isPermanent = false;
8605
- }
8606
- });
8607
- return {
8608
- maskChar: maskChar,
8609
- formatChars: formatChars,
8610
- prefix: prefix,
8611
- mask: parsedMaskString,
8612
- lastEditablePosition: lastEditablePosition,
8613
- permanents: permanents
8614
- };
8557
+ function isInputFocused(input) {
8558
+ var inputDocument = input.ownerDocument;
8559
+ return inputDocument.hasFocus() && inputDocument.activeElement === input;
8615
8560
  }
8616
8561
 
8617
- /* eslint no-use-before-define: ["error", { functions: false }] */
8618
- function isPermanentCharacter(maskOptions, pos) {
8619
- return maskOptions.permanents.indexOf(pos) !== -1;
8562
+ // Element's window may differ from the one within React instance
8563
+ // if element rendered within iframe.
8564
+ // See https://github.com/sanniassin/react-input-mask/issues/182
8565
+ function getElementDocument(element) {
8566
+ return element == null ? void 0 : element.ownerDocument;
8620
8567
  }
8621
- function isAllowedCharacter(maskOptions, pos, character) {
8622
- var mask = maskOptions.mask,
8623
- formatChars = maskOptions.formatChars;
8624
- if (!character) {
8625
- return false;
8626
- }
8627
- if (isPermanentCharacter(maskOptions, pos)) {
8628
- return mask[pos] === character;
8629
- }
8630
- var ruleChar = mask[pos];
8631
- var charRule = formatChars[ruleChar];
8632
- return new RegExp(charRule).test(character);
8568
+ function getElementWindow(element) {
8569
+ var _getElementDocument;
8570
+ return (_getElementDocument = getElementDocument(element)) == null ? void 0 : _getElementDocument.defaultView;
8633
8571
  }
8634
- function isEmpty(maskOptions, value) {
8635
- return value.split('').every(function (character, i) {
8636
- return isPermanentCharacter(maskOptions, i) || !isAllowedCharacter(maskOptions, i, character);
8637
- });
8572
+ function isDOMElement(element) {
8573
+ var elementWindow = getElementWindow(element);
8574
+ return !!elementWindow && element instanceof elementWindow.HTMLElement;
8638
8575
  }
8639
- function getFilledLength(maskOptions, value) {
8640
- var maskChar = maskOptions.maskChar,
8641
- prefix = maskOptions.prefix;
8642
- if (!maskChar) {
8643
- while (value.length > prefix.length && isPermanentCharacter(maskOptions, value.length - 1)) {
8644
- value = value.slice(0, value.length - 1);
8645
- }
8646
- return value.length;
8647
- }
8648
- var filledLength = prefix.length;
8649
- for (var i = value.length; i >= prefix.length; i--) {
8650
- var character = value[i];
8651
- var isEnteredCharacter = !isPermanentCharacter(maskOptions, i) && isAllowedCharacter(maskOptions, i, character);
8652
- if (isEnteredCharacter) {
8653
- filledLength = i + 1;
8654
- break;
8576
+ function isFunction(value) {
8577
+ return typeof value === "function";
8578
+ }
8579
+ function findLastIndex(array, predicate) {
8580
+ for (var i = array.length - 1; i >= 0; i--) {
8581
+ var x = array[i];
8582
+ if (predicate(x, i)) {
8583
+ return i;
8655
8584
  }
8656
8585
  }
8657
- return filledLength;
8586
+ return -1;
8658
8587
  }
8659
- function isFilled(maskOptions, value) {
8660
- return getFilledLength(maskOptions, value) === maskOptions.mask.length;
8661
- }
8662
- function formatValue(maskOptions, value) {
8663
- var maskChar = maskOptions.maskChar,
8664
- mask = maskOptions.mask,
8665
- prefix = maskOptions.prefix;
8666
- if (!maskChar) {
8667
- value = insertString(maskOptions, '', value, 0);
8668
- if (value.length < prefix.length) {
8669
- value = prefix;
8670
- }
8671
- while (value.length < mask.length && isPermanentCharacter(maskOptions, value.length)) {
8672
- value += mask[value.length];
8673
- }
8674
- return value;
8588
+ function repeat(string, n) {
8589
+ if (n === void 0) {
8590
+ n = 1;
8675
8591
  }
8676
- if (value) {
8677
- var emptyValue = formatValue(maskOptions, '');
8678
- return insertString(maskOptions, emptyValue, value, 0);
8592
+ var result = "";
8593
+ for (var i = 0; i < n; i++) {
8594
+ result += string;
8679
8595
  }
8680
- for (var i = 0; i < mask.length; i++) {
8681
- if (isPermanentCharacter(maskOptions, i)) {
8682
- value += mask[i];
8683
- } else {
8684
- value += maskChar;
8685
- }
8686
- }
8687
- return value;
8688
- }
8689
- function clearRange(maskOptions, value, start, len) {
8690
- var end = start + len;
8691
- var maskChar = maskOptions.maskChar,
8692
- mask = maskOptions.mask,
8693
- prefix = maskOptions.prefix;
8694
- var arrayValue = value.split('');
8695
- if (!maskChar) {
8696
- // remove any permanent chars after clear range, they will be added back by formatValue
8697
- for (var i = end; i < arrayValue.length; i++) {
8698
- if (isPermanentCharacter(maskOptions, i)) {
8699
- arrayValue[i] = '';
8700
- }
8596
+ return result;
8597
+ }
8598
+ function toString(value) {
8599
+ return "" + value;
8600
+ }
8601
+ function useInputElement(inputRef) {
8602
+ return React$1.useCallback(function () {
8603
+ var input = inputRef.current;
8604
+ var isDOMNode = typeof window !== "undefined" && isDOMElement(input);
8605
+
8606
+ // workaround for react-test-renderer
8607
+ // https://github.com/sanniassin/react-input-mask/issues/147
8608
+ if (!input || !isDOMNode) {
8609
+ return null;
8701
8610
  }
8702
- start = Math.max(prefix.length, start);
8703
- arrayValue.splice(start, end - start);
8704
- value = arrayValue.join('');
8705
- return formatValue(maskOptions, value);
8706
- }
8707
- return arrayValue.map(function (character, i) {
8708
- if (i < start || i >= end) {
8709
- return character;
8611
+ if (input.nodeName !== "INPUT") {
8612
+ input = input.querySelector("input");
8710
8613
  }
8711
- if (isPermanentCharacter(maskOptions, i)) {
8712
- return mask[i];
8614
+ if (!input) {
8615
+ throw new Error("react-input-mask: inputComponent doesn't contain input node");
8713
8616
  }
8714
- return maskChar;
8715
- }).join('');
8617
+ return input;
8618
+ }, [inputRef]);
8716
8619
  }
8717
- function insertString(maskOptions, value, insertStr, insertPosition) {
8718
- var mask = maskOptions.mask,
8719
- maskChar = maskOptions.maskChar,
8720
- prefix = maskOptions.prefix;
8721
- var arrayInsertStr = insertStr.split('');
8722
- var isInputFilled = isFilled(maskOptions, value);
8723
- var isUsablePosition = function isUsablePosition(pos, character) {
8724
- return !isPermanentCharacter(maskOptions, pos) || character === mask[pos];
8725
- };
8726
- var isUsableCharacter = function isUsableCharacter(character, pos) {
8727
- return !maskChar || !isPermanentCharacter(maskOptions, pos) || character !== maskChar;
8728
- };
8729
- if (!maskChar && insertPosition > value.length) {
8730
- value += mask.slice(value.length, insertPosition);
8731
- }
8732
- arrayInsertStr.every(function (insertCharacter) {
8733
- while (!isUsablePosition(insertPosition, insertCharacter)) {
8734
- if (insertPosition >= value.length) {
8735
- value += mask[insertPosition];
8736
- }
8737
- if (!isUsableCharacter(insertCharacter, insertPosition)) {
8738
- return true;
8739
- }
8740
- insertPosition++; // stop iteration if maximum value length reached
8741
-
8742
- if (insertPosition >= mask.length) {
8743
- return false;
8744
- }
8745
- }
8746
- var isAllowed = isAllowedCharacter(maskOptions, insertPosition, insertCharacter) || insertCharacter === maskChar;
8747
- if (!isAllowed) {
8748
- return true;
8620
+ function useDeferLoop(callback) {
8621
+ var deferIdRef = React$1.useRef(null);
8622
+ var runLoop = React$1.useCallback(function () {
8623
+ // If there are simulated focus events, runLoop could be
8624
+ // called multiple times without blur or re-render
8625
+ if (deferIdRef.current !== null) {
8626
+ return;
8749
8627
  }
8750
- if (insertPosition < value.length) {
8751
- if (maskChar || isInputFilled || insertPosition < prefix.length) {
8752
- value = value.slice(0, insertPosition) + insertCharacter + value.slice(insertPosition + 1);
8753
- } else {
8754
- value = value.slice(0, insertPosition) + insertCharacter + value.slice(insertPosition);
8755
- value = formatValue(maskOptions, value);
8756
- }
8757
- } else if (!maskChar) {
8758
- value += insertCharacter;
8628
+ function loop() {
8629
+ callback();
8630
+ deferIdRef.current = defer(loop);
8759
8631
  }
8760
- insertPosition++; // stop iteration if maximum value length reached
8761
-
8762
- return insertPosition < mask.length;
8632
+ loop();
8633
+ }, [callback]);
8634
+ var stopLoop = React$1.useCallback(function () {
8635
+ cancelDefer(deferIdRef.current);
8636
+ deferIdRef.current = null;
8637
+ }, []);
8638
+ React$1.useEffect(function () {
8639
+ if (deferIdRef.current) {
8640
+ stopLoop();
8641
+ runLoop();
8642
+ }
8643
+ }, [runLoop, stopLoop]);
8644
+ React$1.useEffect(cancelDefer, []);
8645
+ return [runLoop, stopLoop];
8646
+ }
8647
+ function useSelection(inputRef, isMasked) {
8648
+ var selectionRef = React$1.useRef({
8649
+ start: null,
8650
+ end: null
8763
8651
  });
8764
- return value;
8765
- }
8766
- function getInsertStringLength(maskOptions, value, insertStr, insertPosition) {
8767
- var mask = maskOptions.mask,
8768
- maskChar = maskOptions.maskChar;
8769
- var arrayInsertStr = insertStr.split('');
8770
- var initialInsertPosition = insertPosition;
8771
- var isUsablePosition = function isUsablePosition(pos, character) {
8772
- return !isPermanentCharacter(maskOptions, pos) || character === mask[pos];
8773
- };
8774
- arrayInsertStr.every(function (insertCharacter) {
8775
- while (!isUsablePosition(insertPosition, insertCharacter)) {
8776
- insertPosition++; // stop iteration if maximum value length reached
8652
+ var getInputElement = useInputElement(inputRef);
8653
+ var getSelection = React$1.useCallback(function () {
8654
+ var input = getInputElement();
8655
+ return getInputSelection(input);
8656
+ }, [getInputElement]);
8657
+ var getLastSelection = React$1.useCallback(function () {
8658
+ return selectionRef.current;
8659
+ }, []);
8660
+ var setSelection = React$1.useCallback(function (selection) {
8661
+ var input = getInputElement();
8777
8662
 
8778
- if (insertPosition >= mask.length) {
8779
- return false;
8780
- }
8663
+ // Don't change selection on unfocused input
8664
+ // because Safari sets focus on selection change (#154)
8665
+ if (!input || !isInputFocused(input)) {
8666
+ return;
8781
8667
  }
8782
- var isAllowed = isAllowedCharacter(maskOptions, insertPosition, insertCharacter) || insertCharacter === maskChar;
8783
- if (isAllowed) {
8784
- insertPosition++;
8785
- } // stop iteration if maximum value length reached
8786
-
8787
- return insertPosition < mask.length;
8788
- });
8789
- return insertPosition - initialInsertPosition;
8790
- }
8791
- function getLeftEditablePosition(maskOptions, pos) {
8792
- for (var i = pos; i >= 0; --i) {
8793
- if (!isPermanentCharacter(maskOptions, i)) {
8794
- return i;
8668
+ setInputSelection(input, selection.start, selection.end);
8669
+
8670
+ // Use actual selection in case the requested one was out of range
8671
+ selectionRef.current = getSelection();
8672
+ }, [getInputElement, getSelection]);
8673
+ var selectionLoop = React$1.useCallback(function () {
8674
+ selectionRef.current = getSelection();
8675
+ }, [getSelection]);
8676
+ var _useDeferLoop = useDeferLoop(selectionLoop),
8677
+ runSelectionLoop = _useDeferLoop[0],
8678
+ stopSelectionLoop = _useDeferLoop[1];
8679
+ React$1.useLayoutEffect(function () {
8680
+ if (!isMasked) {
8681
+ return;
8795
8682
  }
8796
- }
8797
- return null;
8798
- }
8799
- function getRightEditablePosition(maskOptions, pos) {
8800
- var mask = maskOptions.mask;
8801
- for (var i = pos; i < mask.length; ++i) {
8802
- if (!isPermanentCharacter(maskOptions, i)) {
8803
- return i;
8683
+ var input = getInputElement();
8684
+ input.addEventListener("focus", runSelectionLoop);
8685
+ input.addEventListener("blur", stopSelectionLoop);
8686
+ if (isInputFocused(input)) {
8687
+ runSelectionLoop();
8804
8688
  }
8805
- }
8806
- return null;
8689
+ return function () {
8690
+ input.removeEventListener("focus", runSelectionLoop);
8691
+ input.removeEventListener("blur", stopSelectionLoop);
8692
+ stopSelectionLoop();
8693
+ };
8694
+ });
8695
+ return {
8696
+ getSelection: getSelection,
8697
+ getLastSelection: getLastSelection,
8698
+ setSelection: setSelection
8699
+ };
8807
8700
  }
8808
- function getStringValue(value) {
8809
- return !value && value !== 0 ? '' : value + '';
8810
- }
8811
- function processChange(maskOptions, value, selection, previousValue, previousSelection) {
8812
- var mask = maskOptions.mask,
8813
- prefix = maskOptions.prefix,
8814
- lastEditablePosition = maskOptions.lastEditablePosition;
8815
- var newValue = value;
8816
- var enteredString = '';
8817
- var formattedEnteredStringLength = 0;
8818
- var removedLength = 0;
8819
- var cursorPosition = Math.min(previousSelection.start, selection.start);
8820
- if (selection.end > previousSelection.start) {
8821
- enteredString = newValue.slice(previousSelection.start, selection.end);
8822
- formattedEnteredStringLength = getInsertStringLength(maskOptions, previousValue, enteredString, cursorPosition);
8823
- if (!formattedEnteredStringLength) {
8824
- removedLength = 0;
8825
- } else {
8826
- removedLength = previousSelection.length;
8827
- }
8828
- } else if (newValue.length < previousValue.length) {
8829
- removedLength = previousValue.length - newValue.length;
8830
- }
8831
- newValue = previousValue;
8832
- if (removedLength) {
8833
- if (removedLength === 1 && !previousSelection.length) {
8834
- var deleteFromRight = previousSelection.start === selection.start;
8835
- cursorPosition = deleteFromRight ? getRightEditablePosition(maskOptions, selection.start) : getLeftEditablePosition(maskOptions, selection.start);
8701
+ function useValue(inputRef, initialValue) {
8702
+ var getInputElement = useInputElement(inputRef);
8703
+ var valueRef = React$1.useRef(initialValue);
8704
+ var getValue = React$1.useCallback(function () {
8705
+ var input = getInputElement();
8706
+ return input.value;
8707
+ }, [getInputElement]);
8708
+ var getLastValue = React$1.useCallback(function () {
8709
+ return valueRef.current;
8710
+ }, []);
8711
+ var setValue = React$1.useCallback(function (newValue) {
8712
+ valueRef.current = newValue;
8713
+ var input = getInputElement();
8714
+ if (input) {
8715
+ input.value = newValue;
8836
8716
  }
8837
- newValue = clearRange(maskOptions, newValue, cursorPosition, removedLength);
8717
+ }, [getInputElement]);
8718
+ return {
8719
+ getValue: getValue,
8720
+ getLastValue: getLastValue,
8721
+ setValue: setValue
8722
+ };
8723
+ }
8724
+ function useInputState(initialValue, isMasked) {
8725
+ var inputRef = React$1.useRef();
8726
+ var _useSelection = useSelection(inputRef, isMasked),
8727
+ getSelection = _useSelection.getSelection,
8728
+ getLastSelection = _useSelection.getLastSelection,
8729
+ setSelection = _useSelection.setSelection;
8730
+ var _useValue = useValue(inputRef, initialValue),
8731
+ getValue = _useValue.getValue,
8732
+ getLastValue = _useValue.getLastValue,
8733
+ setValue = _useValue.setValue;
8734
+ function getLastInputState() {
8735
+ return {
8736
+ value: getLastValue(),
8737
+ selection: getLastSelection()
8738
+ };
8838
8739
  }
8839
- newValue = insertString(maskOptions, newValue, enteredString, cursorPosition);
8840
- cursorPosition = cursorPosition + formattedEnteredStringLength;
8841
- if (cursorPosition >= mask.length) {
8842
- cursorPosition = mask.length;
8843
- } else if (cursorPosition < prefix.length && !formattedEnteredStringLength) {
8844
- cursorPosition = prefix.length;
8845
- } else if (cursorPosition >= prefix.length && cursorPosition < lastEditablePosition && formattedEnteredStringLength) {
8846
- cursorPosition = getRightEditablePosition(maskOptions, cursorPosition);
8740
+ function getInputState() {
8741
+ return {
8742
+ value: getValue(),
8743
+ selection: getSelection()
8744
+ };
8847
8745
  }
8848
- newValue = formatValue(maskOptions, newValue);
8849
- if (!enteredString) {
8850
- enteredString = null;
8746
+ function setInputState(_ref) {
8747
+ var value = _ref.value,
8748
+ selection = _ref.selection;
8749
+ setValue(value);
8750
+ setSelection(selection);
8851
8751
  }
8852
8752
  return {
8853
- value: newValue,
8854
- enteredString: enteredString,
8855
- selection: {
8856
- start: cursorPosition,
8857
- end: cursorPosition
8858
- }
8753
+ inputRef: inputRef,
8754
+ getInputState: getInputState,
8755
+ getLastInputState: getLastInputState,
8756
+ setInputState: setInputState
8859
8757
  };
8860
8758
  }
8861
- function isWindowsPhoneBrowser() {
8862
- var windows = new RegExp('windows', 'i');
8863
- var phone = new RegExp('phone', 'i');
8864
- var ua = navigator.userAgent;
8865
- return windows.test(ua) && phone.test(ua);
8759
+ function usePrevious(value) {
8760
+ var ref = React$1.useRef();
8761
+ React$1.useEffect(function () {
8762
+ ref.current = value;
8763
+ });
8764
+ return ref.current;
8866
8765
  }
8867
- function isFunction(value) {
8868
- return typeof value === 'function';
8766
+ var CONTROLLED_PROPS = ["disabled", "onBlur", "onChange", "onFocus", "onMouseDown", "readOnly", "value"];
8767
+ var defaultFormatChars = {
8768
+ 9: /[0-9]/,
8769
+ a: /[A-Za-z]/,
8770
+ "*": /[A-Za-z0-9]/
8771
+ };
8772
+ function validateMaxLength(props) {
8773
+ process.env.NODE_ENV !== "production" ? warning(!props.maxLength || !props.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;
8869
8774
  }
8870
- function getRequestAnimationFrame() {
8871
- return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame;
8775
+ function validateMaskPlaceholder(props) {
8776
+ var mask = props.mask,
8777
+ maskPlaceholder = props.maskPlaceholder;
8778
+ !(!mask || !maskPlaceholder || maskPlaceholder.length === 1 || maskPlaceholder.length === mask.length) ? process.env.NODE_ENV !== "production" ? invariant(false, "react-input-mask: maskPlaceholder should either be a single character or have the same length as the mask:\n" + ("mask: " + mask + "\n") + ("maskPlaceholder: " + maskPlaceholder)) : invariant(false) : void 0;
8872
8779
  }
8873
- function getCancelAnimationFrame() {
8874
- return window.cancelAnimationFrame || window.webkitCancelRequestAnimationFrame || window.webkitCancelAnimationFrame || window.mozCancelAnimationFrame;
8780
+ function validateChildren(props, inputElement) {
8781
+ var conflictProps = CONTROLLED_PROPS.filter(function (propId) {
8782
+ return inputElement.props[propId] != null && inputElement.props[propId] !== props[propId];
8783
+ });
8784
+ !!conflictProps.length ? process.env.NODE_ENV !== "production" ? invariant(false, "react-input-mask: the following props should be passed to the InputMask component, not to children: " + conflictProps.join(",")) : invariant(false) : void 0;
8875
8785
  }
8876
- function defer(fn) {
8877
- var hasCancelAnimationFrame = !!getCancelAnimationFrame();
8878
- var deferFn;
8879
- if (hasCancelAnimationFrame) {
8880
- deferFn = getRequestAnimationFrame();
8881
- } else {
8882
- deferFn = function deferFn() {
8883
- return setTimeout(fn, 1000 / 60);
8786
+ var parseMask = function parseMask(_ref) {
8787
+ var mask = _ref.mask,
8788
+ maskPlaceholder = _ref.maskPlaceholder;
8789
+ var permanents = [];
8790
+ if (!mask) {
8791
+ return {
8792
+ maskPlaceholder: null,
8793
+ mask: null,
8794
+ prefix: null,
8795
+ lastEditablePosition: null,
8796
+ permanents: []
8884
8797
  };
8885
8798
  }
8886
- return deferFn(fn);
8887
- }
8888
- function cancelDefer(deferId) {
8889
- var cancelFn = getCancelAnimationFrame() || clearTimeout;
8890
- cancelFn(deferId);
8891
- }
8892
- var InputElement = /*#__PURE__*/
8893
- function (_React$Component) {
8894
- _inheritsLoose(InputElement, _React$Component);
8895
- function InputElement(props) {
8896
- var _this;
8897
- _this = _React$Component.call(this, props) || this;
8898
- _this.focused = false;
8899
- _this.mounted = false;
8900
- _this.previousSelection = null;
8901
- _this.selectionDeferId = null;
8902
- _this.saveSelectionLoopDeferId = null;
8903
- _this.saveSelectionLoop = function () {
8904
- _this.previousSelection = _this.getSelection();
8905
- _this.saveSelectionLoopDeferId = defer(_this.saveSelectionLoop);
8906
- };
8907
- _this.runSaveSelectionLoop = function () {
8908
- if (_this.saveSelectionLoopDeferId === null) {
8909
- _this.saveSelectionLoop();
8910
- }
8911
- };
8912
- _this.stopSaveSelectionLoop = function () {
8913
- if (_this.saveSelectionLoopDeferId !== null) {
8914
- cancelDefer(_this.saveSelectionLoopDeferId);
8915
- _this.saveSelectionLoopDeferId = null;
8916
- _this.previousSelection = null;
8917
- }
8918
- };
8919
- _this.getInputDOMNode = function () {
8920
- if (!_this.mounted) {
8921
- return null;
8922
- }
8923
- var input = reactDom.findDOMNode(_assertThisInitialized(_assertThisInitialized(_this)));
8924
- var isDOMNode = typeof window !== 'undefined' && input instanceof window.Element; // workaround for react-test-renderer
8925
- // https://github.com/sanniassin/react-input-mask/issues/147
8926
-
8927
- if (input && !isDOMNode) {
8928
- return null;
8929
- }
8930
- if (input.nodeName !== 'INPUT') {
8931
- input = input.querySelector('input');
8932
- }
8933
- if (!input) {
8934
- throw new Error('react-input-mask: inputComponent doesn\'t contain input node');
8935
- }
8936
- return input;
8937
- };
8938
- _this.getInputValue = function () {
8939
- var input = _this.getInputDOMNode();
8940
- if (!input) {
8941
- return null;
8942
- }
8943
- return input.value;
8944
- };
8945
- _this.setInputValue = function (value) {
8946
- var input = _this.getInputDOMNode();
8947
- if (!input) {
8948
- return;
8949
- }
8950
- _this.value = value;
8951
- input.value = value;
8952
- };
8953
- _this.setCursorToEnd = function () {
8954
- var filledLength = getFilledLength(_this.maskOptions, _this.value);
8955
- var pos = getRightEditablePosition(_this.maskOptions, filledLength);
8956
- if (pos !== null) {
8957
- _this.setCursorPosition(pos);
8958
- }
8959
- };
8960
- _this.setSelection = function (start, end, options) {
8961
- if (options === void 0) {
8962
- options = {};
8799
+ if (typeof mask === "string") {
8800
+ var isPermanent = false;
8801
+ var parsedMaskString = "";
8802
+ mask.split("").forEach(function (character) {
8803
+ if (!isPermanent && character === "\\") {
8804
+ isPermanent = true;
8805
+ } else {
8806
+ if (isPermanent || !defaultFormatChars[character]) {
8807
+ permanents.push(parsedMaskString.length);
8808
+ }
8809
+ parsedMaskString += character;
8810
+ isPermanent = false;
8963
8811
  }
8964
- var input = _this.getInputDOMNode();
8965
- var isFocused = _this.isFocused(); // don't change selection on unfocused input
8966
- // because Safari sets focus on selection change (#154)
8967
-
8968
- if (!input || !isFocused) {
8969
- return;
8812
+ });
8813
+ mask = parsedMaskString.split("").map(function (character, index) {
8814
+ if (permanents.indexOf(index) === -1) {
8815
+ return defaultFormatChars[character];
8970
8816
  }
8971
- var _options = options,
8972
- deferred = _options.deferred;
8973
- if (!deferred) {
8974
- setInputSelection(input, start, end);
8817
+ return character;
8818
+ });
8819
+ } else {
8820
+ mask.forEach(function (character, index) {
8821
+ if (typeof character === "string") {
8822
+ permanents.push(index);
8975
8823
  }
8976
- if (_this.selectionDeferId !== null) {
8977
- cancelDefer(_this.selectionDeferId);
8978
- } // deferred selection update is required for pre-Lollipop Android browser,
8979
- // but for consistent behavior we do it for all browsers
8980
-
8981
- _this.selectionDeferId = defer(function () {
8982
- _this.selectionDeferId = null;
8983
- setInputSelection(input, start, end);
8984
- });
8985
- _this.previousSelection = {
8986
- start: start,
8987
- end: end,
8988
- length: Math.abs(end - start)
8989
- };
8990
- };
8991
- _this.getSelection = function () {
8992
- var input = _this.getInputDOMNode();
8993
- return getInputSelection(input);
8994
- };
8995
- _this.getCursorPosition = function () {
8996
- return _this.getSelection().start;
8997
- };
8998
- _this.setCursorPosition = function (pos) {
8999
- _this.setSelection(pos, pos);
9000
- };
9001
- _this.isFocused = function () {
9002
- return _this.focused;
9003
- };
9004
- _this.getBeforeMaskedValueChangeConfig = function () {
9005
- var _this$maskOptions = _this.maskOptions,
9006
- mask = _this$maskOptions.mask,
9007
- maskChar = _this$maskOptions.maskChar,
9008
- permanents = _this$maskOptions.permanents,
9009
- formatChars = _this$maskOptions.formatChars;
9010
- var alwaysShowMask = _this.props.alwaysShowMask;
9011
- return {
9012
- mask: mask,
9013
- maskChar: maskChar,
9014
- permanents: permanents,
9015
- alwaysShowMask: !!alwaysShowMask,
9016
- formatChars: formatChars
9017
- };
9018
- };
9019
- _this.isInputAutofilled = function (value, selection, previousValue, previousSelection) {
9020
- var input = _this.getInputDOMNode(); // only check for positive match because it will be false negative
9021
- // in case of autofill simulation in tests
9022
- //
9023
- // input.matches throws an exception if selector isn't supported
9024
-
9025
- try {
9026
- if (input.matches(':-webkit-autofill')) {
9027
- return true;
8824
+ });
8825
+ }
8826
+ if (maskPlaceholder) {
8827
+ if (maskPlaceholder.length === 1) {
8828
+ maskPlaceholder = mask.map(function (character, index) {
8829
+ if (permanents.indexOf(index) !== -1) {
8830
+ return character;
9028
8831
  }
9029
- } catch (e) {} // if input isn't focused then change event must have been triggered
9030
- // either by autofill or event simulation in tests
9031
-
9032
- if (!_this.focused) {
9033
- return true;
9034
- } // if cursor has moved to the end while previousSelection forbids it
9035
- // then it must be autofill
8832
+ return maskPlaceholder;
8833
+ });
8834
+ } else {
8835
+ maskPlaceholder = maskPlaceholder.split("");
8836
+ }
8837
+ permanents.forEach(function (position) {
8838
+ maskPlaceholder[position] = mask[position];
8839
+ });
8840
+ maskPlaceholder = maskPlaceholder.join("");
8841
+ }
8842
+ var prefix = permanents.filter(function (position, index) {
8843
+ return position === index;
8844
+ }).map(function (position) {
8845
+ return mask[position];
8846
+ }).join("");
8847
+ var lastEditablePosition = mask.length - 1;
8848
+ while (permanents.indexOf(lastEditablePosition) !== -1) {
8849
+ lastEditablePosition--;
8850
+ }
8851
+ return {
8852
+ maskPlaceholder: maskPlaceholder,
8853
+ prefix: prefix,
8854
+ mask: mask,
8855
+ lastEditablePosition: lastEditablePosition,
8856
+ permanents: permanents
8857
+ };
8858
+ };
9036
8859
 
9037
- return previousSelection.end < previousValue.length && selection.end === value.length;
9038
- };
9039
- _this.onChange = function (event) {
9040
- var _assertThisInitialize = _assertThisInitialized(_assertThisInitialized(_this)),
9041
- beforePasteState = _assertThisInitialize.beforePasteState;
9042
- var _assertThisInitialize2 = _assertThisInitialized(_assertThisInitialized(_this)),
9043
- previousSelection = _assertThisInitialize2.previousSelection;
9044
- var beforeMaskedValueChange = _this.props.beforeMaskedValueChange;
9045
- var value = _this.getInputValue();
9046
- var previousValue = _this.value;
9047
- var selection = _this.getSelection(); // autofill replaces entire value, ignore old one
9048
- // https://github.com/sanniassin/react-input-mask/issues/113
9049
-
9050
- if (_this.isInputAutofilled(value, selection, previousValue, previousSelection)) {
9051
- previousValue = formatValue(_this.maskOptions, '');
9052
- previousSelection = {
9053
- start: 0,
9054
- end: 0,
9055
- length: 0
9056
- };
9057
- } // set value and selection as if we haven't
9058
- // cleared input in onPaste handler
9059
-
9060
- if (beforePasteState) {
9061
- previousSelection = beforePasteState.selection;
9062
- previousValue = beforePasteState.value;
9063
- selection = {
9064
- start: previousSelection.start + value.length,
9065
- end: previousSelection.start + value.length,
9066
- length: 0
9067
- };
9068
- value = previousValue.slice(0, previousSelection.start) + value + previousValue.slice(previousSelection.end);
9069
- _this.beforePasteState = null;
9070
- }
9071
- var changedState = processChange(_this.maskOptions, value, selection, previousValue, previousSelection);
9072
- var enteredString = changedState.enteredString;
9073
- var newSelection = changedState.selection;
9074
- var newValue = changedState.value;
9075
- if (isFunction(beforeMaskedValueChange)) {
9076
- var modifiedValue = beforeMaskedValueChange({
9077
- value: newValue,
9078
- selection: newSelection
9079
- }, {
9080
- value: previousValue,
9081
- selection: previousSelection
9082
- }, enteredString, _this.getBeforeMaskedValueChangeConfig());
9083
- newValue = modifiedValue.value;
9084
- newSelection = modifiedValue.selection;
9085
- }
9086
- _this.setInputValue(newValue);
9087
- if (isFunction(_this.props.onChange)) {
9088
- _this.props.onChange(event);
9089
- }
9090
- if (_this.isWindowsPhoneBrowser) {
9091
- _this.setSelection(newSelection.start, newSelection.end, {
9092
- deferred: true
9093
- });
9094
- } else {
9095
- _this.setSelection(newSelection.start, newSelection.end);
9096
- }
8860
+ /* eslint no-use-before-define: ["error", { functions: false }] */
8861
+ var MaskUtils = function MaskUtils(options) {
8862
+ var _this = this;
8863
+ this.isCharacterAllowedAtPosition = function (character, position) {
8864
+ var maskPlaceholder = _this.maskOptions.maskPlaceholder;
8865
+ if (_this.isCharacterFillingPosition(character, position)) {
8866
+ return true;
8867
+ }
8868
+ if (!maskPlaceholder) {
8869
+ return false;
8870
+ }
8871
+ return maskPlaceholder[position] === character;
8872
+ };
8873
+ this.isCharacterFillingPosition = function (character, position) {
8874
+ var mask = _this.maskOptions.mask;
8875
+ if (!character || position >= mask.length) {
8876
+ return false;
8877
+ }
8878
+ if (!_this.isPositionEditable(position)) {
8879
+ return mask[position] === character;
8880
+ }
8881
+ var charRule = mask[position];
8882
+ return new RegExp(charRule).test(character);
8883
+ };
8884
+ this.isPositionEditable = function (position) {
8885
+ var _this$maskOptions = _this.maskOptions,
8886
+ mask = _this$maskOptions.mask,
8887
+ permanents = _this$maskOptions.permanents;
8888
+ return position < mask.length && permanents.indexOf(position) === -1;
8889
+ };
8890
+ this.isValueEmpty = function (value) {
8891
+ return value.split("").every(function (character, position) {
8892
+ return !_this.isPositionEditable(position) || !_this.isCharacterFillingPosition(character, position);
8893
+ });
8894
+ };
8895
+ this.isValueFilled = function (value) {
8896
+ return _this.getFilledLength(value) === _this.maskOptions.lastEditablePosition + 1;
8897
+ };
8898
+ this.getDefaultSelectionForValue = function (value) {
8899
+ var filledLength = _this.getFilledLength(value);
8900
+ var cursorPosition = _this.getRightEditablePosition(filledLength);
8901
+ return {
8902
+ start: cursorPosition,
8903
+ end: cursorPosition
9097
8904
  };
9098
- _this.onFocus = function (event) {
9099
- var beforeMaskedValueChange = _this.props.beforeMaskedValueChange;
9100
- var _this$maskOptions2 = _this.maskOptions,
9101
- mask = _this$maskOptions2.mask,
9102
- prefix = _this$maskOptions2.prefix;
9103
- _this.focused = true; // if autoFocus is set, onFocus triggers before componentDidMount
9104
-
9105
- _this.mounted = true;
9106
- if (mask) {
9107
- if (!_this.value) {
9108
- var emptyValue = formatValue(_this.maskOptions, prefix);
9109
- var newValue = formatValue(_this.maskOptions, emptyValue);
9110
- var filledLength = getFilledLength(_this.maskOptions, newValue);
9111
- var cursorPosition = getRightEditablePosition(_this.maskOptions, filledLength);
9112
- var newSelection = {
9113
- start: cursorPosition,
9114
- end: cursorPosition
9115
- };
9116
- if (isFunction(beforeMaskedValueChange)) {
9117
- var modifiedValue = beforeMaskedValueChange({
9118
- value: newValue,
9119
- selection: newSelection
9120
- }, {
9121
- value: _this.value,
9122
- selection: null
9123
- }, null, _this.getBeforeMaskedValueChangeConfig());
9124
- newValue = modifiedValue.value;
9125
- newSelection = modifiedValue.selection;
9126
- }
9127
- var isInputValueChanged = newValue !== _this.getInputValue();
9128
- if (isInputValueChanged) {
9129
- _this.setInputValue(newValue);
9130
- }
9131
- if (isInputValueChanged && isFunction(_this.props.onChange)) {
9132
- _this.props.onChange(event);
9133
- }
9134
- _this.setSelection(newSelection.start, newSelection.end);
9135
- } else if (getFilledLength(_this.maskOptions, _this.value) < _this.maskOptions.mask.length) {
9136
- _this.setCursorToEnd();
9137
- }
9138
- _this.runSaveSelectionLoop();
8905
+ };
8906
+ this.getFilledLength = function (value) {
8907
+ var characters = value.split("");
8908
+ var lastFilledIndex = findLastIndex(characters, function (character, position) {
8909
+ return _this.isPositionEditable(position) && _this.isCharacterFillingPosition(character, position);
8910
+ });
8911
+ return lastFilledIndex + 1;
8912
+ };
8913
+ this.getStringFillingLengthAtPosition = function (string, position) {
8914
+ var characters = string.split("");
8915
+ var insertedValue = characters.reduce(function (value, character) {
8916
+ return _this.insertCharacterAtPosition(value, character, value.length);
8917
+ }, repeat(" ", position));
8918
+ return insertedValue.length - position;
8919
+ };
8920
+ this.getLeftEditablePosition = function (position) {
8921
+ for (var i = position; i >= 0; i--) {
8922
+ if (_this.isPositionEditable(i)) {
8923
+ return i;
9139
8924
  }
9140
- if (isFunction(_this.props.onFocus)) {
9141
- _this.props.onFocus(event);
8925
+ }
8926
+ return null;
8927
+ };
8928
+ this.getRightEditablePosition = function (position) {
8929
+ var mask = _this.maskOptions.mask;
8930
+ for (var i = position; i < mask.length; i++) {
8931
+ if (_this.isPositionEditable(i)) {
8932
+ return i;
9142
8933
  }
9143
- };
9144
- _this.onBlur = function (event) {
9145
- var beforeMaskedValueChange = _this.props.beforeMaskedValueChange;
9146
- var mask = _this.maskOptions.mask;
9147
- _this.stopSaveSelectionLoop();
9148
- _this.focused = false;
9149
- if (mask && !_this.props.alwaysShowMask && isEmpty(_this.maskOptions, _this.value)) {
9150
- var newValue = '';
9151
- if (isFunction(beforeMaskedValueChange)) {
9152
- var modifiedValue = beforeMaskedValueChange({
9153
- value: newValue,
9154
- selection: null
9155
- }, {
9156
- value: _this.value,
9157
- selection: _this.previousSelection
9158
- }, null, _this.getBeforeMaskedValueChangeConfig());
9159
- newValue = modifiedValue.value;
9160
- }
9161
- var isInputValueChanged = newValue !== _this.getInputValue();
9162
- if (isInputValueChanged) {
9163
- _this.setInputValue(newValue);
8934
+ }
8935
+ return null;
8936
+ };
8937
+ this.formatValue = function (value) {
8938
+ var _this$maskOptions2 = _this.maskOptions,
8939
+ maskPlaceholder = _this$maskOptions2.maskPlaceholder,
8940
+ mask = _this$maskOptions2.mask;
8941
+ if (!maskPlaceholder) {
8942
+ value = _this.insertStringAtPosition("", value, 0);
8943
+ while (value.length < mask.length && !_this.isPositionEditable(value.length)) {
8944
+ value += mask[value.length];
8945
+ }
8946
+ return value;
8947
+ }
8948
+ return _this.insertStringAtPosition(maskPlaceholder, value, 0);
8949
+ };
8950
+ this.clearRange = function (value, start, len) {
8951
+ if (!len) {
8952
+ return value;
8953
+ }
8954
+ var end = start + len;
8955
+ var _this$maskOptions3 = _this.maskOptions,
8956
+ maskPlaceholder = _this$maskOptions3.maskPlaceholder,
8957
+ mask = _this$maskOptions3.mask;
8958
+ var clearedValue = value.split("").map(function (character, i) {
8959
+ var isEditable = _this.isPositionEditable(i);
8960
+ if (!maskPlaceholder && i >= end && !isEditable) {
8961
+ return "";
8962
+ }
8963
+ if (i < start || i >= end) {
8964
+ return character;
8965
+ }
8966
+ if (!isEditable) {
8967
+ return mask[i];
8968
+ }
8969
+ if (maskPlaceholder) {
8970
+ return maskPlaceholder[i];
8971
+ }
8972
+ return "";
8973
+ }).join("");
8974
+ return _this.formatValue(clearedValue);
8975
+ };
8976
+ this.insertCharacterAtPosition = function (value, character, position) {
8977
+ var _this$maskOptions4 = _this.maskOptions,
8978
+ mask = _this$maskOptions4.mask,
8979
+ maskPlaceholder = _this$maskOptions4.maskPlaceholder;
8980
+ if (position >= mask.length) {
8981
+ return value;
8982
+ }
8983
+ var isAllowed = _this.isCharacterAllowedAtPosition(character, position);
8984
+ var isEditable = _this.isPositionEditable(position);
8985
+ var nextEditablePosition = _this.getRightEditablePosition(position);
8986
+ var isNextPlaceholder = maskPlaceholder && nextEditablePosition ? character === maskPlaceholder[nextEditablePosition] : null;
8987
+ var valueBefore = value.slice(0, position);
8988
+ if (isAllowed || !isEditable) {
8989
+ var insertedCharacter = isAllowed ? character : mask[position];
8990
+ value = valueBefore + insertedCharacter;
8991
+ }
8992
+ if (!isAllowed && !isEditable && !isNextPlaceholder) {
8993
+ value = _this.insertCharacterAtPosition(value, character, position + 1);
8994
+ }
8995
+ return value;
8996
+ };
8997
+ this.insertStringAtPosition = function (value, string, position) {
8998
+ var _this$maskOptions5 = _this.maskOptions,
8999
+ mask = _this$maskOptions5.mask,
9000
+ maskPlaceholder = _this$maskOptions5.maskPlaceholder;
9001
+ if (!string || position >= mask.length) {
9002
+ return value;
9003
+ }
9004
+ var characters = string.split("");
9005
+ var isFixedLength = _this.isValueFilled(value) || !!maskPlaceholder;
9006
+ var valueAfter = value.slice(position);
9007
+ value = characters.reduce(function (value, character) {
9008
+ return _this.insertCharacterAtPosition(value, character, value.length);
9009
+ }, value.slice(0, position));
9010
+ if (isFixedLength) {
9011
+ value += valueAfter.slice(value.length - position);
9012
+ } else if (_this.isValueFilled(value)) {
9013
+ value += mask.slice(value.length).join("");
9014
+ } else {
9015
+ var editableCharactersAfter = valueAfter.split("").filter(function (character, i) {
9016
+ return _this.isPositionEditable(position + i);
9017
+ });
9018
+ value = editableCharactersAfter.reduce(function (value, character) {
9019
+ var nextEditablePosition = _this.getRightEditablePosition(value.length);
9020
+ if (nextEditablePosition === null) {
9021
+ return value;
9164
9022
  }
9165
- if (isInputValueChanged && isFunction(_this.props.onChange)) {
9166
- _this.props.onChange(event);
9023
+ if (!_this.isPositionEditable(value.length)) {
9024
+ value += mask.slice(value.length, nextEditablePosition).join("");
9167
9025
  }
9026
+ return _this.insertCharacterAtPosition(value, character, value.length);
9027
+ }, value);
9028
+ }
9029
+ return value;
9030
+ };
9031
+ this.processChange = function (currentState, previousState) {
9032
+ var _this$maskOptions6 = _this.maskOptions,
9033
+ mask = _this$maskOptions6.mask,
9034
+ prefix = _this$maskOptions6.prefix,
9035
+ lastEditablePosition = _this$maskOptions6.lastEditablePosition;
9036
+ var value = currentState.value,
9037
+ selection = currentState.selection;
9038
+ var previousValue = previousState.value;
9039
+ var previousSelection = previousState.selection;
9040
+ var newValue = value;
9041
+ var enteredString = "";
9042
+ var formattedEnteredStringLength = 0;
9043
+ var removedLength = 0;
9044
+ var cursorPosition = Math.min(previousSelection.start, selection.start);
9045
+ if (selection.end > previousSelection.start) {
9046
+ enteredString = newValue.slice(previousSelection.start, selection.end);
9047
+ formattedEnteredStringLength = _this.getStringFillingLengthAtPosition(enteredString, cursorPosition);
9048
+ if (!formattedEnteredStringLength) {
9049
+ removedLength = 0;
9050
+ } else {
9051
+ removedLength = previousSelection.length;
9168
9052
  }
9169
- if (isFunction(_this.props.onBlur)) {
9170
- _this.props.onBlur(event);
9171
- }
9172
- };
9173
- _this.onMouseDown = function (event) {
9174
- // tiny unintentional mouse movements can break cursor
9175
- // position on focus, so we have to restore it in that case
9176
- //
9177
- // https://github.com/sanniassin/react-input-mask/issues/108
9178
- if (!_this.focused && document.addEventListener) {
9179
- _this.mouseDownX = event.clientX;
9180
- _this.mouseDownY = event.clientY;
9181
- _this.mouseDownTime = new Date().getTime();
9182
- var mouseUpHandler = function mouseUpHandler(mouseUpEvent) {
9183
- document.removeEventListener('mouseup', mouseUpHandler);
9184
- if (!_this.focused) {
9185
- return;
9186
- }
9187
- var deltaX = Math.abs(mouseUpEvent.clientX - _this.mouseDownX);
9188
- var deltaY = Math.abs(mouseUpEvent.clientY - _this.mouseDownY);
9189
- var axisDelta = Math.max(deltaX, deltaY);
9190
- var timeDelta = new Date().getTime() - _this.mouseDownTime;
9191
- if (axisDelta <= 10 && timeDelta <= 200 || axisDelta <= 5 && timeDelta <= 300) {
9192
- _this.setCursorToEnd();
9193
- }
9194
- };
9195
- document.addEventListener('mouseup', mouseUpHandler);
9053
+ } else if (newValue.length < previousValue.length) {
9054
+ removedLength = previousValue.length - newValue.length;
9055
+ }
9056
+ newValue = previousValue;
9057
+ if (removedLength) {
9058
+ if (removedLength === 1 && !previousSelection.length) {
9059
+ var deleteFromRight = previousSelection.start === selection.start;
9060
+ cursorPosition = deleteFromRight ? _this.getRightEditablePosition(selection.start) : _this.getLeftEditablePosition(selection.start);
9196
9061
  }
9197
- if (isFunction(_this.props.onMouseDown)) {
9198
- _this.props.onMouseDown(event);
9062
+ newValue = _this.clearRange(newValue, cursorPosition, removedLength);
9063
+ }
9064
+ newValue = _this.insertStringAtPosition(newValue, enteredString, cursorPosition);
9065
+ cursorPosition += formattedEnteredStringLength;
9066
+ if (cursorPosition >= mask.length) {
9067
+ cursorPosition = mask.length;
9068
+ } else if (cursorPosition < prefix.length && !formattedEnteredStringLength) {
9069
+ cursorPosition = prefix.length;
9070
+ } else if (cursorPosition >= prefix.length && cursorPosition < lastEditablePosition && formattedEnteredStringLength) {
9071
+ cursorPosition = _this.getRightEditablePosition(cursorPosition);
9072
+ }
9073
+ newValue = _this.formatValue(newValue);
9074
+ return {
9075
+ value: newValue,
9076
+ enteredString: enteredString,
9077
+ selection: {
9078
+ start: cursorPosition,
9079
+ end: cursorPosition
9199
9080
  }
9200
9081
  };
9201
- _this.onPaste = function (event) {
9202
- if (isFunction(_this.props.onPaste)) {
9203
- _this.props.onPaste(event);
9204
- } // event.clipboardData might not work in Android browser
9205
- // cleaning input to get raw text inside onChange handler
9206
-
9207
- if (!event.defaultPrevented) {
9208
- _this.beforePasteState = {
9209
- value: _this.getInputValue(),
9210
- selection: _this.getSelection()
9211
- };
9212
- _this.setInputValue('');
9082
+ };
9083
+ this.maskOptions = parseMask(options);
9084
+ };
9085
+ var _excluded = ["alwaysShowMask", "children", "mask", "maskPlaceholder", "beforeMaskedStateChange"];
9086
+
9087
+ // eslint-disable-next-line prefer-arrow-callback
9088
+ var InputMask = /*#__PURE__*/React$1.forwardRef(function InputMask(props, forwardedRef) {
9089
+ var alwaysShowMask = props.alwaysShowMask,
9090
+ children = props.children,
9091
+ mask = props.mask,
9092
+ maskPlaceholder = props.maskPlaceholder,
9093
+ beforeMaskedStateChange = props.beforeMaskedStateChange,
9094
+ restProps = _objectWithoutPropertiesLoose(props, _excluded);
9095
+ validateMaxLength(props);
9096
+ validateMaskPlaceholder(props);
9097
+ var maskUtils = new MaskUtils({
9098
+ mask: mask,
9099
+ maskPlaceholder: maskPlaceholder
9100
+ });
9101
+ var isMasked = !!mask;
9102
+ var isEditable = !restProps.disabled && !restProps.readOnly;
9103
+ var isControlled = props.value !== null && props.value !== undefined;
9104
+ var previousIsMasked = usePrevious(isMasked);
9105
+ var initialValue = toString((isControlled ? props.value : props.defaultValue) || "");
9106
+ var _useInputState = useInputState(initialValue, isMasked),
9107
+ inputRef = _useInputState.inputRef,
9108
+ getInputState = _useInputState.getInputState,
9109
+ setInputState = _useInputState.setInputState,
9110
+ getLastInputState = _useInputState.getLastInputState;
9111
+ var getInputElement = useInputElement(inputRef);
9112
+ function onChange(event) {
9113
+ var currentState = getInputState();
9114
+ var previousState = getLastInputState();
9115
+ var newInputState = maskUtils.processChange(currentState, previousState);
9116
+ if (beforeMaskedStateChange) {
9117
+ newInputState = beforeMaskedStateChange({
9118
+ currentState: currentState,
9119
+ previousState: previousState,
9120
+ nextState: newInputState
9121
+ });
9122
+ }
9123
+ setInputState(newInputState);
9124
+ if (props.onChange) {
9125
+ props.onChange(event);
9126
+ }
9127
+ }
9128
+ function onFocus(event) {
9129
+ // If autoFocus property is set, focus event fires before the ref handler gets called
9130
+ inputRef.current = event.target;
9131
+ var currentValue = getInputState().value;
9132
+ if (isMasked && !maskUtils.isValueFilled(currentValue)) {
9133
+ var newValue = maskUtils.formatValue(currentValue);
9134
+ var newSelection = maskUtils.getDefaultSelectionForValue(newValue);
9135
+ var newInputState = {
9136
+ value: newValue,
9137
+ selection: newSelection
9138
+ };
9139
+ if (beforeMaskedStateChange) {
9140
+ newInputState = beforeMaskedStateChange({
9141
+ currentState: getInputState(),
9142
+ nextState: newInputState
9143
+ });
9144
+ newValue = newInputState.value;
9145
+ newSelection = newInputState.selection;
9213
9146
  }
9214
- };
9215
- _this.handleRef = function (ref) {
9216
- if (_this.props.children == null && isFunction(_this.props.inputRef)) {
9217
- _this.props.inputRef(ref);
9147
+ setInputState(newInputState);
9148
+ if (newValue !== currentValue && props.onChange) {
9149
+ props.onChange(event);
9218
9150
  }
9219
- };
9220
- var _mask = props.mask,
9221
- _maskChar = props.maskChar,
9222
- _formatChars = props.formatChars,
9223
- _alwaysShowMask = props.alwaysShowMask,
9224
- _beforeMaskedValueChange = props.beforeMaskedValueChange;
9225
- var defaultValue = props.defaultValue,
9226
- _value = props.value;
9227
- _this.maskOptions = parseMask(_mask, _maskChar, _formatChars);
9228
- if (defaultValue == null) {
9229
- defaultValue = '';
9230
- }
9231
- if (_value == null) {
9232
- _value = defaultValue;
9233
- }
9234
- var _newValue = getStringValue(_value);
9235
- if (_this.maskOptions.mask && (_alwaysShowMask || _newValue)) {
9236
- _newValue = formatValue(_this.maskOptions, _newValue);
9237
- if (isFunction(_beforeMaskedValueChange)) {
9238
- var oldValue = props.value;
9239
- if (props.value == null) {
9240
- oldValue = defaultValue;
9151
+
9152
+ // Chrome resets selection after focus event,
9153
+ // so we want to restore it later
9154
+ defer(function () {
9155
+ setInputState(getLastInputState());
9156
+ });
9157
+ }
9158
+ if (props.onFocus) {
9159
+ props.onFocus(event);
9160
+ }
9161
+ }
9162
+ function onBlur(event) {
9163
+ var currentValue = getInputState().value;
9164
+ var lastValue = getLastInputState().value;
9165
+ if (isMasked && !alwaysShowMask && maskUtils.isValueEmpty(lastValue)) {
9166
+ var newValue = "";
9167
+ var newInputState = {
9168
+ value: newValue,
9169
+ selection: {
9170
+ start: null,
9171
+ end: null
9241
9172
  }
9242
- oldValue = getStringValue(oldValue);
9243
- var modifiedValue = _beforeMaskedValueChange({
9244
- value: _newValue,
9245
- selection: null
9246
- }, {
9247
- value: oldValue,
9248
- selection: null
9249
- }, null, _this.getBeforeMaskedValueChangeConfig());
9250
- _newValue = modifiedValue.value;
9173
+ };
9174
+ if (beforeMaskedStateChange) {
9175
+ newInputState = beforeMaskedStateChange({
9176
+ currentState: getInputState(),
9177
+ nextState: newInputState
9178
+ });
9179
+ newValue = newInputState.value;
9180
+ }
9181
+ setInputState(newInputState);
9182
+ if (newValue !== currentValue && props.onChange) {
9183
+ props.onChange(event);
9251
9184
  }
9252
9185
  }
9253
- _this.value = _newValue;
9254
- return _this;
9186
+ if (props.onBlur) {
9187
+ props.onBlur(event);
9188
+ }
9255
9189
  }
9256
- var _proto = InputElement.prototype;
9257
- _proto.componentDidMount = function componentDidMount() {
9258
- this.mounted = true; // workaround for react-test-renderer
9259
- // https://github.com/sanniassin/react-input-mask/issues/147
9260
9190
 
9261
- if (!this.getInputDOMNode()) {
9262
- return;
9263
- }
9264
- this.isWindowsPhoneBrowser = isWindowsPhoneBrowser();
9265
- if (this.maskOptions.mask && this.getInputValue() !== this.value) {
9266
- this.setInputValue(this.value);
9267
- }
9268
- };
9269
- _proto.componentDidUpdate = function componentDidUpdate() {
9270
- var previousSelection = this.previousSelection;
9271
- var _this$props = this.props,
9272
- beforeMaskedValueChange = _this$props.beforeMaskedValueChange,
9273
- alwaysShowMask = _this$props.alwaysShowMask,
9274
- mask = _this$props.mask,
9275
- maskChar = _this$props.maskChar,
9276
- formatChars = _this$props.formatChars;
9277
- var previousMaskOptions = this.maskOptions;
9278
- var showEmpty = alwaysShowMask || this.isFocused();
9279
- var hasValue = this.props.value != null;
9280
- var newValue = hasValue ? getStringValue(this.props.value) : this.value;
9281
- var cursorPosition = previousSelection ? previousSelection.start : null;
9282
- this.maskOptions = parseMask(mask, maskChar, formatChars);
9283
- if (!this.maskOptions.mask) {
9284
- if (previousMaskOptions.mask) {
9285
- this.stopSaveSelectionLoop(); // render depends on this.maskOptions and this.value,
9286
- // call forceUpdate to keep it in sync
9287
-
9288
- this.forceUpdate();
9289
- }
9191
+ // Tiny unintentional mouse movements can break cursor
9192
+ // position on focus, so we have to restore it in that case
9193
+ //
9194
+ // https://github.com/sanniassin/react-input-mask/issues/108
9195
+ function onMouseDown(event) {
9196
+ var input = getInputElement();
9197
+ if (!input) {
9290
9198
  return;
9291
- } else if (!previousMaskOptions.mask && this.isFocused()) {
9292
- this.runSaveSelectionLoop();
9293
9199
  }
9294
- var isMaskChanged = this.maskOptions.mask && this.maskOptions.mask !== previousMaskOptions.mask;
9295
- if (!previousMaskOptions.mask && !hasValue) {
9296
- newValue = this.getInputValue();
9200
+ var _getInputState = getInputState(),
9201
+ value = _getInputState.value;
9202
+ var inputDocument = getElementDocument(input);
9203
+ if (!isInputFocused(input) && !maskUtils.isValueFilled(value)) {
9204
+ var mouseDownX = event.clientX;
9205
+ var mouseDownY = event.clientY;
9206
+ var mouseDownTime = new Date().getTime();
9207
+ var mouseUpHandler = function mouseUpHandler(mouseUpEvent) {
9208
+ inputDocument.removeEventListener("mouseup", mouseUpHandler);
9209
+ if (!isInputFocused(input)) {
9210
+ return;
9211
+ }
9212
+ var deltaX = Math.abs(mouseUpEvent.clientX - mouseDownX);
9213
+ var deltaY = Math.abs(mouseUpEvent.clientY - mouseDownY);
9214
+ var axisDelta = Math.max(deltaX, deltaY);
9215
+ var timeDelta = new Date().getTime() - mouseDownTime;
9216
+ if (axisDelta <= 10 && timeDelta <= 200 || axisDelta <= 5 && timeDelta <= 300) {
9217
+ var _lastState = getLastInputState();
9218
+ var newSelection = maskUtils.getDefaultSelectionForValue(_lastState.value);
9219
+ var newState = _extends({}, _lastState, {
9220
+ selection: newSelection
9221
+ });
9222
+ setInputState(newState);
9223
+ }
9224
+ };
9225
+ inputDocument.addEventListener("mouseup", mouseUpHandler);
9297
9226
  }
9298
- if (isMaskChanged || this.maskOptions.mask && (newValue || showEmpty)) {
9299
- newValue = formatValue(this.maskOptions, newValue);
9227
+ if (props.onMouseDown) {
9228
+ props.onMouseDown(event);
9300
9229
  }
9301
- if (isMaskChanged) {
9302
- var filledLength = getFilledLength(this.maskOptions, newValue);
9303
- if (cursorPosition === null || filledLength < cursorPosition) {
9304
- if (isFilled(this.maskOptions, newValue)) {
9305
- cursorPosition = filledLength;
9306
- } else {
9307
- cursorPosition = getRightEditablePosition(this.maskOptions, filledLength);
9230
+ }
9231
+
9232
+ // For controlled inputs we want to provide properly formatted
9233
+ // value prop
9234
+ if (isMasked && isControlled) {
9235
+ var input = getInputElement();
9236
+ var isFocused = input && isInputFocused(input);
9237
+ var newValue = isFocused || alwaysShowMask || props.value ? maskUtils.formatValue(props.value) : props.value;
9238
+ if (beforeMaskedStateChange) {
9239
+ newValue = beforeMaskedStateChange({
9240
+ nextState: {
9241
+ value: newValue,
9242
+ selection: {
9243
+ start: null,
9244
+ end: null
9245
+ }
9308
9246
  }
9309
- }
9310
- }
9311
- if (this.maskOptions.mask && isEmpty(this.maskOptions, newValue) && !showEmpty && (!hasValue || !this.props.value)) {
9312
- newValue = '';
9247
+ }).value;
9313
9248
  }
9314
- var newSelection = {
9315
- start: cursorPosition,
9316
- end: cursorPosition
9317
- };
9318
- if (isFunction(beforeMaskedValueChange)) {
9319
- var modifiedValue = beforeMaskedValueChange({
9320
- value: newValue,
9321
- selection: newSelection
9322
- }, {
9323
- value: this.value,
9324
- selection: this.previousSelection
9325
- }, null, this.getBeforeMaskedValueChangeConfig());
9326
- newValue = modifiedValue.value;
9327
- newSelection = modifiedValue.selection;
9328
- }
9329
- this.value = newValue;
9330
- var isValueChanged = this.getInputValue() !== this.value; // render depends on this.maskOptions and this.value,
9331
- // call forceUpdate to keep it in sync
9332
-
9333
- if (isValueChanged) {
9334
- this.setInputValue(this.value);
9335
- this.forceUpdate();
9336
- } else if (isMaskChanged) {
9337
- this.forceUpdate();
9338
- }
9339
- var isSelectionChanged = false;
9340
- if (newSelection.start != null && newSelection.end != null) {
9341
- isSelectionChanged = !previousSelection || previousSelection.start !== newSelection.start || previousSelection.end !== newSelection.end;
9342
- }
9343
- if (isSelectionChanged || isValueChanged) {
9344
- this.setSelection(newSelection.start, newSelection.end);
9249
+ setInputState(_extends({}, getLastInputState(), {
9250
+ value: newValue
9251
+ }));
9252
+ }
9253
+ var lastState = getLastInputState();
9254
+ var lastSelection = lastState.selection;
9255
+ var lastValue = lastState.value;
9256
+ React$1.useLayoutEffect(function () {
9257
+ if (!isMasked) {
9258
+ return;
9345
9259
  }
9346
- };
9347
- _proto.componentWillUnmount = function componentWillUnmount() {
9348
- this.mounted = false;
9349
- if (this.selectionDeferId !== null) {
9350
- cancelDefer(this.selectionDeferId);
9260
+ var input = getInputElement();
9261
+ if (!input) {
9262
+ return;
9351
9263
  }
9352
- this.stopSaveSelectionLoop();
9353
- };
9354
- _proto.render = function render() {
9355
- var _this$props2 = this.props,
9356
- mask = _this$props2.mask;
9357
- _this$props2.alwaysShowMask;
9358
- var maskChar = _this$props2.maskChar,
9359
- formatChars = _this$props2.formatChars,
9360
- inputRef = _this$props2.inputRef;
9361
- _this$props2.beforeMaskedValueChange;
9362
- var children = _this$props2.children,
9363
- restProps = _objectWithoutPropertiesLoose(_this$props2, ["mask", "alwaysShowMask", "maskChar", "formatChars", "inputRef", "beforeMaskedValueChange", "children"]);
9364
- var inputElement;
9365
- process.env.NODE_ENV !== "production" ? warning(
9366
- // parse mask to test against actual mask prop as this.maskOptions
9367
- // will be updated later in componentDidUpdate
9368
- !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;
9369
- if (children) {
9370
- !isFunction(children) ? process.env.NODE_ENV !== "production" ? invariant(false, 'react-input-mask: children must be a function') : invariant(false) : void 0;
9371
- var controlledProps = ['onChange', 'onPaste', 'onMouseDown', 'onFocus', 'onBlur', 'value', 'disabled', 'readOnly'];
9372
- var childrenProps = _extends({}, restProps);
9373
- controlledProps.forEach(function (propId) {
9374
- return delete childrenProps[propId];
9264
+ var isFocused = isInputFocused(input);
9265
+ var previousSelection = lastSelection;
9266
+ var currentState = getInputState();
9267
+ var newInputState = _extends({}, currentState);
9268
+
9269
+ // Update value for uncontrolled inputs to make sure
9270
+ // it's always in sync with mask props
9271
+ if (!isControlled) {
9272
+ var currentValue = currentState.value;
9273
+ var formattedValue = maskUtils.formatValue(currentValue);
9274
+ var isValueEmpty = maskUtils.isValueEmpty(formattedValue);
9275
+ var shouldFormatValue = !isValueEmpty || isFocused || alwaysShowMask;
9276
+ if (shouldFormatValue) {
9277
+ newInputState.value = formattedValue;
9278
+ } else if (isValueEmpty && !isFocused) {
9279
+ newInputState.value = "";
9280
+ }
9281
+ }
9282
+ if (isFocused && !previousIsMasked) {
9283
+ // Adjust selection if input got masked while being focused
9284
+ newInputState.selection = maskUtils.getDefaultSelectionForValue(newInputState.value);
9285
+ } else if (isControlled && isFocused && previousSelection) {
9286
+ // Restore cursor position if value has changed outside change event
9287
+ if (previousSelection.start !== null && previousSelection.end !== null) {
9288
+ newInputState.selection = previousSelection;
9289
+ }
9290
+ }
9291
+ if (beforeMaskedStateChange) {
9292
+ newInputState = beforeMaskedStateChange({
9293
+ currentState: currentState,
9294
+ nextState: newInputState
9375
9295
  });
9376
- inputElement = children(childrenProps);
9377
- var conflictProps = controlledProps.filter(function (propId) {
9378
- return inputElement.props[propId] != null && inputElement.props[propId] !== restProps[propId];
9379
- });
9380
- !!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;
9381
- 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;
9382
- } else {
9383
- inputElement = React$1.createElement("input", _extends({
9384
- ref: this.handleRef
9385
- }, restProps));
9386
9296
  }
9387
- var changedProps = {
9388
- onFocus: this.onFocus,
9389
- onBlur: this.onBlur
9390
- };
9391
- if (this.maskOptions.mask) {
9392
- if (!restProps.disabled && !restProps.readOnly) {
9393
- changedProps.onChange = this.onChange;
9394
- changedProps.onPaste = this.onPaste;
9395
- changedProps.onMouseDown = this.onMouseDown;
9396
- }
9397
- if (restProps.value != null) {
9398
- changedProps.value = this.value;
9399
- }
9297
+ setInputState(newInputState);
9298
+ });
9299
+ var refCallback = function refCallback(node) {
9300
+ inputRef.current = node;
9301
+
9302
+ // if a ref callback is passed to InputMask
9303
+ if (isFunction(forwardedRef)) {
9304
+ forwardedRef(node);
9305
+ } else if (forwardedRef !== null && _typeof$1(forwardedRef) === "object") {
9306
+ forwardedRef.current = node;
9400
9307
  }
9401
- inputElement = React$1.cloneElement(inputElement, changedProps);
9402
- return inputElement;
9403
9308
  };
9404
- return InputElement;
9405
- }(React$1.Component);
9406
- reactInputMask_development = InputElement;
9309
+ var inputProps = _extends({}, restProps, {
9310
+ onFocus: onFocus,
9311
+ onBlur: onBlur,
9312
+ onChange: isMasked && isEditable ? onChange : props.onChange,
9313
+ onMouseDown: isMasked && isEditable ? onMouseDown : props.onMouseDown,
9314
+ value: isMasked && isControlled ? lastValue : props.value
9315
+ });
9316
+ if (children) {
9317
+ validateChildren(props, children);
9318
+
9319
+ // {@link https://stackoverflow.com/q/63149840/327074}
9320
+ var onlyChild = React$1.Children.only(children);
9321
+ return /*#__PURE__*/React$1.cloneElement(onlyChild, _extends({}, inputProps, {
9322
+ ref: refCallback
9323
+ }));
9324
+ }
9325
+ return /*#__PURE__*/React$1.createElement("input", _extends({
9326
+ ref: refCallback
9327
+ }, inputProps));
9328
+ });
9329
+ InputMask.displayName = "InputMask";
9330
+ InputMask.defaultProps = {
9331
+ alwaysShowMask: false,
9332
+ maskPlaceholder: "_"
9333
+ };
9334
+ InputMask.propTypes = {
9335
+ alwaysShowMask: PropTypes.bool,
9336
+ beforeMaskedStateChange: PropTypes.func,
9337
+ children: PropTypes.element,
9338
+ mask: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.instanceOf(RegExp)]))]),
9339
+ maskPlaceholder: PropTypes.string,
9340
+ onFocus: PropTypes.func,
9341
+ onBlur: PropTypes.func,
9342
+ onChange: PropTypes.func,
9343
+ onMouseDown: PropTypes.func
9344
+ };
9345
+ reactInputMask_development = InputMask;
9407
9346
  return reactInputMask_development;
9408
9347
  }
9409
9348
 
9349
+ /* eslint-disable import/no-unresolved */
9410
9350
  var hasRequiredReactInputMask;
9411
9351
  function requireReactInputMask() {
9412
9352
  if (hasRequiredReactInputMask) return reactInputMask.exports;
9413
9353
  hasRequiredReactInputMask = 1;
9414
- if (process.env.NODE_ENV === 'production') {
9354
+ if (process.env.NODE_ENV === "production") {
9415
9355
  reactInputMask.exports = requireReactInputMask_production_min();
9416
9356
  } else {
9417
9357
  reactInputMask.exports = requireReactInputMask_development();
@@ -11179,15 +11119,9 @@ var CreditCardNumberInput = function CreditCardNumberInput(_ref) {
11179
11119
  setValue(event.target.value);
11180
11120
  onChange === null || onChange === void 0 || onChange(event.target.value);
11181
11121
  }, [setValue, onChange]);
11182
-
11183
- // 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
11184
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
11185
- var renderInputField = function renderInputField(inputProps) {
11186
- return /*#__PURE__*/React.createElement(CreditCardNumberInputField, _extends$1({}, rest, inputProps));
11187
- };
11188
11122
  return /*#__PURE__*/React.createElement(InputMask, {
11189
11123
  mask: mask,
11190
- maskChar: maskChar,
11124
+ maskPlaceholder: maskChar,
11191
11125
  alwaysShowMask: alwaysShowMask,
11192
11126
  disabled: disabled,
11193
11127
  readOnly: readOnly,
@@ -11196,7 +11130,7 @@ var CreditCardNumberInput = function CreditCardNumberInput(_ref) {
11196
11130
  onMouseDown: onMouseDown,
11197
11131
  onFocus: onFocus,
11198
11132
  onBlur: onBlur
11199
- }, renderInputField);
11133
+ }, /*#__PURE__*/React.createElement(CreditCardNumberInputField, rest));
11200
11134
  };
11201
11135
 
11202
11136
  var _excluded$e = ["term", "children", "className"];
@@ -12036,11 +11970,6 @@ var LoadingShapesLavenderBlue = function LoadingShapesLavenderBlue() {
12036
11970
  }));
12037
11971
  };
12038
11972
 
12039
- var preventNavigation = function preventNavigation(event) {
12040
- event.preventDefault();
12041
- event.returnValue = '';
12042
- };
12043
-
12044
11973
  var usePreventNavigation = function usePreventNavigation() {
12045
11974
  var enabled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
12046
11975
  React.useEffect(function () {