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