@salutejs/plasma-new-hope 0.327.0-canary.1973.15679545656.0 → 0.327.0-canary.1973.15733948288.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/cjs/components/CodeField/CodeField.js +10 -15
- package/cjs/components/CodeField/CodeField.js.map +1 -1
- package/cjs/components/CodeInput/CodeInput.js +12 -17
- package/cjs/components/CodeInput/CodeInput.js.map +1 -1
- package/cjs/components/CodeInput/CodeInput.tokens.js.map +1 -1
- package/cjs/components/CodeInput/utils/handleCodeError.js +2 -2
- package/cjs/components/CodeInput/utils/handleCodeError.js.map +1 -1
- package/cjs/components/CodeInput/utils/handleItemError.js +1 -1
- package/cjs/components/CodeInput/utils/handleItemError.js.map +1 -1
- package/cjs/components/CodeInput/variations/_size/base.js.map +1 -1
- package/cjs/hooks/useCodeHook.js +34 -0
- package/cjs/hooks/useCodeHook.js.map +1 -0
- package/cjs/index.js +6 -0
- package/cjs/index.js.map +1 -1
- package/cjs/utils/constants.js +12 -0
- package/cjs/utils/constants.js.map +1 -1
- package/cjs/utils/index.js.map +1 -1
- package/cjs/utils/initialValuesHelper.js.map +1 -0
- package/emotion/cjs/components/CodeField/CodeField.js +9 -15
- package/emotion/cjs/components/CodeInput/CodeInput.js +10 -16
- package/emotion/cjs/components/CodeInput/utils/handleCodeError.js +3 -3
- package/emotion/cjs/components/CodeInput/utils/handleItemError.js +1 -1
- package/emotion/cjs/components/CodeInput/utils/index.js +4 -4
- package/emotion/cjs/components/CodeInput/variations/_size/base.js +1 -1
- package/emotion/cjs/hooks/index.js +8 -1
- package/emotion/cjs/hooks/useCodeHook.js +32 -0
- package/emotion/cjs/utils/constants.js +8 -2
- package/emotion/cjs/utils/index.js +12 -0
- package/emotion/es/components/CodeField/CodeField.js +11 -16
- package/emotion/es/components/CodeInput/CodeInput.js +12 -17
- package/emotion/es/components/CodeInput/utils/handleCodeError.js +2 -2
- package/emotion/es/components/CodeInput/utils/handleItemError.js +1 -1
- package/emotion/es/components/CodeInput/utils/index.js +1 -1
- package/emotion/es/components/CodeInput/variations/_size/base.js +1 -1
- package/emotion/es/hooks/index.js +2 -1
- package/emotion/es/hooks/useCodeHook.js +26 -0
- package/emotion/es/utils/constants.js +7 -1
- package/emotion/es/utils/index.js +1 -0
- package/es/components/CodeField/CodeField.js +11 -16
- package/es/components/CodeField/CodeField.js.map +1 -1
- package/es/components/CodeInput/CodeInput.js +13 -18
- package/es/components/CodeInput/CodeInput.js.map +1 -1
- package/es/components/CodeInput/CodeInput.tokens.js.map +1 -1
- package/es/components/CodeInput/utils/handleCodeError.js +2 -2
- package/es/components/CodeInput/utils/handleCodeError.js.map +1 -1
- package/es/components/CodeInput/utils/handleItemError.js +1 -1
- package/es/components/CodeInput/utils/handleItemError.js.map +1 -1
- package/es/components/CodeInput/variations/_size/base.js.map +1 -1
- package/es/hooks/useCodeHook.js +30 -0
- package/es/hooks/useCodeHook.js.map +1 -0
- package/es/index.js +2 -0
- package/es/index.js.map +1 -1
- package/es/utils/constants.js +7 -1
- package/es/utils/constants.js.map +1 -1
- package/es/utils/index.js.map +1 -1
- package/es/utils/initialValuesHelper.js.map +1 -0
- package/package.json +2 -2
- package/styled-components/cjs/components/CodeField/CodeField.js +9 -15
- package/styled-components/cjs/components/CodeInput/CodeInput.js +10 -16
- package/styled-components/cjs/components/CodeInput/utils/handleCodeError.js +3 -3
- package/styled-components/cjs/components/CodeInput/utils/handleItemError.js +1 -1
- package/styled-components/cjs/components/CodeInput/utils/index.js +4 -4
- package/styled-components/cjs/hooks/index.js +8 -1
- package/styled-components/cjs/hooks/useCodeHook.js +32 -0
- package/styled-components/cjs/utils/constants.js +8 -2
- package/styled-components/cjs/utils/index.js +12 -0
- package/styled-components/es/components/CodeField/CodeField.js +11 -16
- package/styled-components/es/components/CodeInput/CodeInput.js +12 -17
- package/styled-components/es/components/CodeInput/utils/handleCodeError.js +2 -2
- package/styled-components/es/components/CodeInput/utils/handleItemError.js +1 -1
- package/styled-components/es/components/CodeInput/utils/index.js +1 -1
- package/styled-components/es/hooks/index.js +2 -1
- package/styled-components/es/hooks/useCodeHook.js +26 -0
- package/styled-components/es/utils/constants.js +7 -1
- package/styled-components/es/utils/index.js +1 -0
- package/types/components/CodeField/CodeField.d.ts.map +1 -1
- package/types/components/CodeInput/CodeInput.d.ts.map +1 -1
- package/types/components/CodeInput/CodeInput.tokens.d.ts +1 -0
- package/types/components/CodeInput/CodeInput.tokens.d.ts.map +1 -1
- package/types/components/CodeInput/utils/handleCodeError.d.ts.map +1 -1
- package/types/components/CodeInput/utils/handleItemError.d.ts.map +1 -1
- package/types/components/CodeInput/utils/index.d.ts +1 -1
- package/types/components/CodeInput/utils/index.d.ts.map +1 -1
- package/types/components/CodeInput/variations/_size/base.d.ts.map +1 -1
- package/types/hooks/index.d.ts +1 -0
- package/types/hooks/index.d.ts.map +1 -1
- package/types/hooks/useCodeHook.d.ts +13 -0
- package/types/hooks/useCodeHook.d.ts.map +1 -0
- package/types/utils/constants.d.ts +6 -0
- package/types/utils/constants.d.ts.map +1 -1
- package/types/utils/index.d.ts +1 -0
- package/types/utils/index.d.ts.map +1 -1
- package/types/utils/initialValuesHelper.d.ts.map +1 -0
- package/cjs/components/CodeInput/utils/constants.js +0 -14
- package/cjs/components/CodeInput/utils/constants.js.map +0 -1
- package/cjs/components/CodeInput/utils/initialValuesHelper.js.map +0 -1
- package/emotion/cjs/components/CodeInput/utils/constants.js +0 -12
- package/emotion/cjs/components/CodeInput/utils/types.js +0 -5
- package/emotion/es/components/CodeInput/utils/constants.js +0 -6
- package/emotion/es/components/CodeInput/utils/types.js +0 -1
- package/es/components/CodeInput/utils/constants.js +0 -7
- package/es/components/CodeInput/utils/constants.js.map +0 -1
- package/es/components/CodeInput/utils/initialValuesHelper.js.map +0 -1
- package/styled-components/cjs/components/CodeInput/utils/constants.js +0 -12
- package/styled-components/cjs/components/CodeInput/utils/types.js +0 -5
- package/styled-components/es/components/CodeInput/utils/constants.js +0 -6
- package/styled-components/es/components/CodeInput/utils/types.js +0 -1
- package/types/components/CodeInput/utils/constants.d.ts +0 -7
- package/types/components/CodeInput/utils/constants.d.ts.map +0 -1
- package/types/components/CodeInput/utils/initialValuesHelper.d.ts.map +0 -1
- package/types/components/CodeInput/utils/types.d.ts +0 -11
- package/types/components/CodeInput/utils/types.d.ts.map +0 -1
- /package/cjs/{components/CodeInput/utils → utils}/initialValuesHelper.js +0 -0
- /package/emotion/cjs/{components/CodeInput/utils → utils}/initialValuesHelper.js +0 -0
- /package/emotion/es/{components/CodeInput/utils → utils}/initialValuesHelper.js +0 -0
- /package/es/{components/CodeInput/utils → utils}/initialValuesHelper.js +0 -0
- /package/styled-components/cjs/{components/CodeInput/utils → utils}/initialValuesHelper.js +0 -0
- /package/styled-components/es/{components/CodeInput/utils → utils}/initialValuesHelper.js +0 -0
- /package/types/{components/CodeInput/utils → utils}/initialValuesHelper.d.ts +0 -0
@@ -202,21 +202,15 @@ var codeFieldRoot = exports.codeFieldRoot = function codeFieldRoot(Root) {
|
|
202
202
|
onFullCodeEnter(fullCode);
|
203
203
|
}
|
204
204
|
}, []);
|
205
|
-
(0,
|
206
|
-
inputRefs
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
}, [autoFocus]);
|
215
|
-
(0, _hooks.useDidMountEffect)(function () {
|
216
|
-
if (handleFullCodeEnter && originalValue.length === codeLength) {
|
217
|
-
handleFullCodeEnter(originalValue);
|
218
|
-
}
|
219
|
-
}, [originalValue, handleFullCodeEnter]);
|
205
|
+
(0, _hooks.useCodeHook)({
|
206
|
+
inputRefs: inputRefs,
|
207
|
+
codeLength: codeLength,
|
208
|
+
disabled: disabled,
|
209
|
+
autoFocus: autoFocus,
|
210
|
+
originalValue: originalValue,
|
211
|
+
getLastActiveIndex: getLastActiveIndex,
|
212
|
+
handleFullCodeEnter: handleFullCodeEnter
|
213
|
+
});
|
220
214
|
(0, _hooks.useDidMountEffect)(function () {
|
221
215
|
if (isError) {
|
222
216
|
(0, _utils2.handleCodeError)({
|
@@ -9,7 +9,7 @@ var _react = /*#__PURE__*/_interopRequireWildcard(/*#__PURE__*/require("react"))
|
|
9
9
|
var _classnames = /*#__PURE__*/_interopRequireDefault(/*#__PURE__*/require("classnames"));
|
10
10
|
var _hooks = /*#__PURE__*/require("../../hooks");
|
11
11
|
var _utils = /*#__PURE__*/require("../../utils");
|
12
|
-
var _constants = /*#__PURE__*/require("
|
12
|
+
var _constants = /*#__PURE__*/require("../../utils/constants");
|
13
13
|
var _utils2 = /*#__PURE__*/require("./utils");
|
14
14
|
var _CodeInput = /*#__PURE__*/require("./CodeInput.tokens");
|
15
15
|
var _CodeInput2 = /*#__PURE__*/require("./CodeInput.styles");
|
@@ -208,21 +208,15 @@ var codeInputRoot = exports.codeInputRoot = function codeInputRoot(Root) {
|
|
208
208
|
onFullCodeEnter(fullCode);
|
209
209
|
}
|
210
210
|
}, []);
|
211
|
-
(0,
|
212
|
-
inputRefs
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
}, [autoFocus]);
|
221
|
-
(0, _hooks.useDidMountEffect)(function () {
|
222
|
-
if (handleFullCodeEnter && originalValue.length === codeLength) {
|
223
|
-
handleFullCodeEnter(originalValue);
|
224
|
-
}
|
225
|
-
}, [originalValue, handleFullCodeEnter]);
|
211
|
+
(0, _hooks.useCodeHook)({
|
212
|
+
inputRefs: inputRefs,
|
213
|
+
codeLength: codeLength,
|
214
|
+
disabled: disabled,
|
215
|
+
autoFocus: autoFocus,
|
216
|
+
originalValue: originalValue,
|
217
|
+
getLastActiveIndex: getLastActiveIndex,
|
218
|
+
handleFullCodeEnter: handleFullCodeEnter
|
219
|
+
});
|
226
220
|
(0, _hooks.useDidMountEffect)(function () {
|
227
221
|
if (isError) {
|
228
222
|
(0, _utils2.handleCodeError)({
|
@@ -5,8 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
});
|
6
6
|
exports.handleCodeError = void 0;
|
7
7
|
var _CodeInput = /*#__PURE__*/require("../CodeInput.tokens");
|
8
|
-
var
|
9
|
-
var
|
8
|
+
var _utils = /*#__PURE__*/require("../../../utils");
|
9
|
+
var _constants = /*#__PURE__*/require("../../../utils/constants");
|
10
10
|
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
|
11
11
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
12
12
|
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
@@ -50,7 +50,7 @@ var handleCodeError = exports.handleCodeError = function handleCodeError(_ref) {
|
|
50
50
|
(_captionRef$current2 = captionRef.current) === null || _captionRef$current2 === void 0 || _captionRef$current2.classList.add(_CodeInput.classes.captionError);
|
51
51
|
setTimeout(function () {
|
52
52
|
var _inputRefs$current$, _inputContainerRef$cu2;
|
53
|
-
codeSetter((0,
|
53
|
+
codeSetter((0, _utils.getCodeValue)(codeLength, ''));
|
54
54
|
(_inputRefs$current$ = inputRefs.current[0]) === null || _inputRefs$current$ === void 0 || _inputRefs$current$.focus();
|
55
55
|
(_inputContainerRef$cu2 = inputContainerRef.current) === null || _inputContainerRef$cu2 === void 0 || _inputContainerRef$cu2.classList.remove(_CodeInput.classes.codeError, _CodeInput.classes.codeErrorAnimation, _CodeInput.classes.codeErrorFade);
|
56
56
|
}, _constants.ANIMATION_TIMEOUT);
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
});
|
6
6
|
exports.handleItemError = void 0;
|
7
7
|
var _CodeInput = /*#__PURE__*/require("../CodeInput.tokens");
|
8
|
-
var _constants = /*#__PURE__*/require("
|
8
|
+
var _constants = /*#__PURE__*/require("../../../utils/constants");
|
9
9
|
var handleItemError = exports.handleItemError = function handleItemError(_ref) {
|
10
10
|
var _inputContainerRef$cu;
|
11
11
|
var currentSymbol = _ref.currentSymbol,
|
@@ -6,19 +6,19 @@ Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
Object.defineProperty(exports, "getCodeValue", {
|
7
7
|
enumerable: true,
|
8
8
|
get: function get() {
|
9
|
-
return
|
9
|
+
return _utils.getCodeValue;
|
10
10
|
}
|
11
11
|
});
|
12
12
|
Object.defineProperty(exports, "getFieldPattern", {
|
13
13
|
enumerable: true,
|
14
14
|
get: function get() {
|
15
|
-
return
|
15
|
+
return _utils.getFieldPattern;
|
16
16
|
}
|
17
17
|
});
|
18
18
|
Object.defineProperty(exports, "getPlaceholderValue", {
|
19
19
|
enumerable: true,
|
20
20
|
get: function get() {
|
21
|
-
return
|
21
|
+
return _utils.getPlaceholderValue;
|
22
22
|
}
|
23
23
|
});
|
24
24
|
Object.defineProperty(exports, "handleCodeError", {
|
@@ -33,6 +33,6 @@ Object.defineProperty(exports, "handleItemError", {
|
|
33
33
|
return _handleItemError.handleItemError;
|
34
34
|
}
|
35
35
|
});
|
36
|
-
var
|
36
|
+
var _utils = /*#__PURE__*/require("../../../utils");
|
37
37
|
var _handleItemError = /*#__PURE__*/require("./handleItemError");
|
38
38
|
var _handleCodeError = /*#__PURE__*/require("./handleCodeError");
|
@@ -3,6 +3,12 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
+
Object.defineProperty(exports, "useCodeHook", {
|
7
|
+
enumerable: true,
|
8
|
+
get: function get() {
|
9
|
+
return _useCodeHook.useCodeHook;
|
10
|
+
}
|
11
|
+
});
|
6
12
|
Object.defineProperty(exports, "useDidMountEffect", {
|
7
13
|
enumerable: true,
|
8
14
|
get: function get() {
|
@@ -58,4 +64,5 @@ var _useForceUpdate = /*#__PURE__*/require("./useForceUpdate");
|
|
58
64
|
var _useDidMountEffect = /*#__PURE__*/require("./useDidMountEffect");
|
59
65
|
var _useDidMountLayoutEffect = /*#__PURE__*/require("./useDidMountLayoutEffect");
|
60
66
|
var _useOutsideClick = /*#__PURE__*/require("./useOutsideClick");
|
61
|
-
var _useIsomorphicLayoutEffect = /*#__PURE__*/require("./useIsomorphicLayoutEffect");
|
67
|
+
var _useIsomorphicLayoutEffect = /*#__PURE__*/require("./useIsomorphicLayoutEffect");
|
68
|
+
var _useCodeHook = /*#__PURE__*/require("./useCodeHook");
|
@@ -0,0 +1,32 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.useCodeHook = void 0;
|
7
|
+
var _react = /*#__PURE__*/require("react");
|
8
|
+
var _ = /*#__PURE__*/require(".");
|
9
|
+
var useCodeHook = exports.useCodeHook = function useCodeHook(_ref) {
|
10
|
+
var inputRefs = _ref.inputRefs,
|
11
|
+
codeLength = _ref.codeLength,
|
12
|
+
disabled = _ref.disabled,
|
13
|
+
autoFocus = _ref.autoFocus,
|
14
|
+
originalValue = _ref.originalValue,
|
15
|
+
getLastActiveIndex = _ref.getLastActiveIndex,
|
16
|
+
handleFullCodeEnter = _ref.handleFullCodeEnter;
|
17
|
+
(0, _react.useEffect)(function () {
|
18
|
+
inputRefs.current = inputRefs.current.slice(0, codeLength);
|
19
|
+
}, [codeLength]);
|
20
|
+
(0, _react.useEffect)(function () {
|
21
|
+
if (autoFocus && !disabled) {
|
22
|
+
var _inputRefs$current$la;
|
23
|
+
var lastActiveIndex = getLastActiveIndex();
|
24
|
+
(_inputRefs$current$la = inputRefs.current[lastActiveIndex]) === null || _inputRefs$current$la === void 0 || _inputRefs$current$la.focus();
|
25
|
+
}
|
26
|
+
}, [autoFocus]);
|
27
|
+
(0, _.useDidMountEffect)(function () {
|
28
|
+
if (handleFullCodeEnter && originalValue.length === codeLength) {
|
29
|
+
handleFullCodeEnter(originalValue);
|
30
|
+
}
|
31
|
+
}, [originalValue, handleFullCodeEnter]);
|
32
|
+
};
|
@@ -3,7 +3,7 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.screenGroupBreakpoints = exports.keyCodes = void 0;
|
6
|
+
exports.screenGroupBreakpoints = exports.keyCodes = exports.ONLY_DIGITS_PATTERN = exports.ONLY_DIGITS_AND_CHARS_PATTERN = exports.ONLY_CHARS_PATTERN = exports.FORBIDDEN_KEYS = exports.BACKSPACE_KEY = exports.ANIMATION_TIMEOUT = void 0;
|
7
7
|
var keyCodes = exports.keyCodes = {
|
8
8
|
PageUp: 33,
|
9
9
|
PageDown: 34,
|
@@ -21,4 +21,10 @@ var screenGroupBreakpoints = exports.screenGroupBreakpoints = {
|
|
21
21
|
small: '0',
|
22
22
|
medium: '35rem',
|
23
23
|
large: '60rem'
|
24
|
-
};
|
24
|
+
};
|
25
|
+
var ONLY_DIGITS_PATTERN = exports.ONLY_DIGITS_PATTERN = '^\\d+$';
|
26
|
+
var ONLY_CHARS_PATTERN = exports.ONLY_CHARS_PATTERN = '^[a-zA-Z]+$';
|
27
|
+
var ONLY_DIGITS_AND_CHARS_PATTERN = exports.ONLY_DIGITS_AND_CHARS_PATTERN = '^[a-zA-Z0-9]+$';
|
28
|
+
var FORBIDDEN_KEYS = exports.FORBIDDEN_KEYS = ['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown', 'Delete', 'Tab'];
|
29
|
+
var BACKSPACE_KEY = exports.BACKSPACE_KEY = 'Backspace';
|
30
|
+
var ANIMATION_TIMEOUT = exports.ANIMATION_TIMEOUT = 300;
|
@@ -131,6 +131,18 @@ Object.keys(_getPopoverPlacement).forEach(function (key) {
|
|
131
131
|
}
|
132
132
|
});
|
133
133
|
});
|
134
|
+
var _initialValuesHelper = /*#__PURE__*/require("./initialValuesHelper");
|
135
|
+
Object.keys(_initialValuesHelper).forEach(function (key) {
|
136
|
+
if (key === "default" || key === "__esModule") return;
|
137
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
138
|
+
if (key in exports && exports[key] === _initialValuesHelper[key]) return;
|
139
|
+
Object.defineProperty(exports, key, {
|
140
|
+
enumerable: true,
|
141
|
+
get: function get() {
|
142
|
+
return _initialValuesHelper[key];
|
143
|
+
}
|
144
|
+
});
|
145
|
+
});
|
134
146
|
var _noop = /*#__PURE__*/require("./noop");
|
135
147
|
var _getHeightAsNumber = /*#__PURE__*/require("./getHeightAsNumber");
|
136
148
|
var _createConditionalComponent = /*#__PURE__*/require("./createConditionalComponent");
|
@@ -17,10 +17,11 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
|
|
17
17
|
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
18
18
|
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
19
19
|
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
20
|
-
import React, { forwardRef, Fragment, useCallback,
|
20
|
+
import React, { forwardRef, Fragment, useCallback, useRef, useState } from 'react';
|
21
21
|
import cls from 'classnames';
|
22
22
|
import { useDidMountEffect } from "../../hooks";
|
23
23
|
import { getSizeValueFromProp } from "../../utils";
|
24
|
+
import { useCodeHook } from "../../hooks";
|
24
25
|
import { BACKSPACE_KEY, FORBIDDEN_KEYS, ONLY_DIGITS_PATTERN } from "./utils/constants";
|
25
26
|
import { getCodeValue, getFieldPattern, getPlaceholderValue, handleCodeError, handleItemError } from "./utils";
|
26
27
|
import { classes } from "./CodeField.tokens";
|
@@ -193,21 +194,15 @@ export var codeFieldRoot = function codeFieldRoot(Root) {
|
|
193
194
|
onFullCodeEnter(fullCode);
|
194
195
|
}
|
195
196
|
}, []);
|
196
|
-
|
197
|
-
inputRefs
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
}, [autoFocus]);
|
206
|
-
useDidMountEffect(function () {
|
207
|
-
if (handleFullCodeEnter && originalValue.length === codeLength) {
|
208
|
-
handleFullCodeEnter(originalValue);
|
209
|
-
}
|
210
|
-
}, [originalValue, handleFullCodeEnter]);
|
197
|
+
useCodeHook({
|
198
|
+
inputRefs: inputRefs,
|
199
|
+
codeLength: codeLength,
|
200
|
+
disabled: disabled,
|
201
|
+
autoFocus: autoFocus,
|
202
|
+
originalValue: originalValue,
|
203
|
+
getLastActiveIndex: getLastActiveIndex,
|
204
|
+
handleFullCodeEnter: handleFullCodeEnter
|
205
|
+
});
|
211
206
|
useDidMountEffect(function () {
|
212
207
|
if (isError) {
|
213
208
|
handleCodeError({
|
@@ -17,11 +17,12 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
|
|
17
17
|
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
18
18
|
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
19
19
|
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
20
|
-
import React, { forwardRef, Fragment, useCallback,
|
20
|
+
import React, { forwardRef, Fragment, useCallback, useRef, useState } from 'react';
|
21
21
|
import cls from 'classnames';
|
22
22
|
import { useDidMountEffect } from "../../hooks";
|
23
23
|
import { getSizeValueFromProp } from "../../utils";
|
24
|
-
import { BACKSPACE_KEY, FORBIDDEN_KEYS, ONLY_DIGITS_PATTERN } from "
|
24
|
+
import { BACKSPACE_KEY, FORBIDDEN_KEYS, ONLY_DIGITS_PATTERN } from "../../utils/constants";
|
25
|
+
import { useCodeHook } from "../../hooks";
|
25
26
|
import { getCodeValue, getFieldPattern, getPlaceholderValue, handleCodeError, handleItemError } from "./utils";
|
26
27
|
import { classes } from "./CodeInput.tokens";
|
27
28
|
import { base, CaptionWrapper, CodeGroup, CodeWrapper, ItemInput, Separator, ItemWrapper, ItemCircle } from "./CodeInput.styles";
|
@@ -199,21 +200,15 @@ export var codeInputRoot = function codeInputRoot(Root) {
|
|
199
200
|
onFullCodeEnter(fullCode);
|
200
201
|
}
|
201
202
|
}, []);
|
202
|
-
|
203
|
-
inputRefs
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
}, [autoFocus]);
|
212
|
-
useDidMountEffect(function () {
|
213
|
-
if (handleFullCodeEnter && originalValue.length === codeLength) {
|
214
|
-
handleFullCodeEnter(originalValue);
|
215
|
-
}
|
216
|
-
}, [originalValue, handleFullCodeEnter]);
|
203
|
+
useCodeHook({
|
204
|
+
inputRefs: inputRefs,
|
205
|
+
codeLength: codeLength,
|
206
|
+
disabled: disabled,
|
207
|
+
autoFocus: autoFocus,
|
208
|
+
originalValue: originalValue,
|
209
|
+
getLastActiveIndex: getLastActiveIndex,
|
210
|
+
handleFullCodeEnter: handleFullCodeEnter
|
211
|
+
});
|
217
212
|
useDidMountEffect(function () {
|
218
213
|
if (isError) {
|
219
214
|
handleCodeError({
|
@@ -5,8 +5,8 @@ function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Sym
|
|
5
5
|
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
|
6
6
|
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
7
7
|
import { classes } from "../CodeInput.tokens";
|
8
|
-
import {
|
9
|
-
import {
|
8
|
+
import { getCodeValue } from "../../../utils";
|
9
|
+
import { ANIMATION_TIMEOUT } from "../../../utils/constants";
|
10
10
|
export var handleCodeError = function handleCodeError(_ref) {
|
11
11
|
var _captionRef$current, _captionRef$current2;
|
12
12
|
var codeLength = _ref.codeLength,
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { classes } from "../CodeInput.tokens";
|
2
|
-
import { ANIMATION_TIMEOUT } from "
|
2
|
+
import { ANIMATION_TIMEOUT } from "../../../utils/constants";
|
3
3
|
export var handleItemError = function handleItemError(_ref) {
|
4
4
|
var _inputContainerRef$cu;
|
5
5
|
var currentSymbol = _ref.currentSymbol,
|
@@ -1,3 +1,3 @@
|
|
1
|
-
export { getFieldPattern, getPlaceholderValue, getCodeValue } from "
|
1
|
+
export { getFieldPattern, getPlaceholderValue, getCodeValue } from "../../../utils";
|
2
2
|
export { handleItemError } from "./handleItemError";
|
3
3
|
export { handleCodeError } from "./handleCodeError";
|
@@ -5,4 +5,5 @@ export { useForceUpdate } from "./useForceUpdate";
|
|
5
5
|
export { useDidMountEffect } from "./useDidMountEffect";
|
6
6
|
export { useDidMountLayoutEffect } from "./useDidMountLayoutEffect";
|
7
7
|
export { useOutsideClick } from "./useOutsideClick";
|
8
|
-
export { useIsomorphicLayoutEffect } from "./useIsomorphicLayoutEffect";
|
8
|
+
export { useIsomorphicLayoutEffect } from "./useIsomorphicLayoutEffect";
|
9
|
+
export { useCodeHook } from "./useCodeHook";
|
@@ -0,0 +1,26 @@
|
|
1
|
+
import { useEffect } from 'react';
|
2
|
+
import { useDidMountEffect } from '.';
|
3
|
+
export var useCodeHook = function useCodeHook(_ref) {
|
4
|
+
var inputRefs = _ref.inputRefs,
|
5
|
+
codeLength = _ref.codeLength,
|
6
|
+
disabled = _ref.disabled,
|
7
|
+
autoFocus = _ref.autoFocus,
|
8
|
+
originalValue = _ref.originalValue,
|
9
|
+
getLastActiveIndex = _ref.getLastActiveIndex,
|
10
|
+
handleFullCodeEnter = _ref.handleFullCodeEnter;
|
11
|
+
useEffect(function () {
|
12
|
+
inputRefs.current = inputRefs.current.slice(0, codeLength);
|
13
|
+
}, [codeLength]);
|
14
|
+
useEffect(function () {
|
15
|
+
if (autoFocus && !disabled) {
|
16
|
+
var _inputRefs$current$la;
|
17
|
+
var lastActiveIndex = getLastActiveIndex();
|
18
|
+
(_inputRefs$current$la = inputRefs.current[lastActiveIndex]) === null || _inputRefs$current$la === void 0 || _inputRefs$current$la.focus();
|
19
|
+
}
|
20
|
+
}, [autoFocus]);
|
21
|
+
useDidMountEffect(function () {
|
22
|
+
if (handleFullCodeEnter && originalValue.length === codeLength) {
|
23
|
+
handleFullCodeEnter(originalValue);
|
24
|
+
}
|
25
|
+
}, [originalValue, handleFullCodeEnter]);
|
26
|
+
};
|
@@ -15,4 +15,10 @@ export var screenGroupBreakpoints = {
|
|
15
15
|
small: '0',
|
16
16
|
medium: '35rem',
|
17
17
|
large: '60rem'
|
18
|
-
};
|
18
|
+
};
|
19
|
+
export var ONLY_DIGITS_PATTERN = '^\\d+$';
|
20
|
+
export var ONLY_CHARS_PATTERN = '^[a-zA-Z]+$';
|
21
|
+
export var ONLY_DIGITS_AND_CHARS_PATTERN = '^[a-zA-Z0-9]+$';
|
22
|
+
export var FORBIDDEN_KEYS = ['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown', 'Delete', 'Tab'];
|
23
|
+
export var BACKSPACE_KEY = 'Backspace';
|
24
|
+
export var ANIMATION_TIMEOUT = 300;
|
@@ -9,6 +9,7 @@ export { createEvent } from "./createEvent";
|
|
9
9
|
import * as _constants from "./constants";
|
10
10
|
export { _constants as constants };
|
11
11
|
export * from "./getPopoverPlacement";
|
12
|
+
export * from "./initialValuesHelper";
|
12
13
|
export { noop } from "./noop";
|
13
14
|
export { getHeightAsNumber } from "./getHeightAsNumber";
|
14
15
|
export { createConditionalComponent } from "./createConditionalComponent";
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"CodeField.d.ts","sourceRoot":"","sources":["../../../src/components/CodeField/CodeField.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
1
|
+
{"version":3,"file":"CodeField.d.ts","sourceRoot":"","sources":["../../../src/components/CodeField/CodeField.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8D,MAAM,OAAO,CAAC;AAGnF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAM7C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAUxD,eAAO,MAAM,aAAa,SAAU,SAAS,CAAC,cAAc,EAAE,cAAc,CAAC;;;;;;;;;;;;;;;;;;;sLAkRxE,CAAC;AAEN,eAAO,MAAM,eAAe;;;mBApRQ,SAAS,CAAC,cAAc,EAAE,cAAc,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6S5E,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"CodeInput.d.ts","sourceRoot":"","sources":["../../../src/components/CodeInput/CodeInput.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
1
|
+
{"version":3,"file":"CodeInput.d.ts","sourceRoot":"","sources":["../../../src/components/CodeInput/CodeInput.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8D,MAAM,OAAO,CAAC;AAGnF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAO7C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAiBxD,eAAO,MAAM,aAAa,SAAU,SAAS,CAAC,cAAc,EAAE,cAAc,CAAC;;;;;;;;;;;;;;;;;;;sLA4SxE,CAAC;AAEN,eAAO,MAAM,eAAe;;;mBA9SQ,SAAS,CAAC,cAAc,EAAE,cAAc,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmU5E,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"CodeInput.tokens.d.ts","sourceRoot":"","sources":["../../../src/components/CodeInput/CodeInput.tokens.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;CAqBnB,CAAC;AAEF,eAAO,MAAM,aAAa;;;;;CAKzB,CAAC;AAEF,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6DlB,CAAC"}
|
1
|
+
{"version":3,"file":"CodeInput.tokens.d.ts","sourceRoot":"","sources":["../../../src/components/CodeInput/CodeInput.tokens.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;CAqBnB,CAAC;AAEF,eAAO,MAAM,aAAa;;;;;CAKzB,CAAC;AAEF,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6DlB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,MAAM,OAAO,MAAM,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"handleCodeError.d.ts","sourceRoot":"","sources":["../../../../src/components/CodeInput/utils/handleCodeError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAEnE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;
|
1
|
+
{"version":3,"file":"handleCodeError.d.ts","sourceRoot":"","sources":["../../../../src/components/CodeInput/utils/handleCodeError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAEnE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAK5D,KAAK,mBAAmB,GAAG;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,WAAW,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC3B,iBAAiB,EAAE,gBAAgB,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;IAC3D,SAAS,EAAE,gBAAgB,CAAC,KAAK,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAAC,CAAC;IAC5D,UAAU,EAAE,gBAAgB,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;IACpD,OAAO,EAAE,QAAQ,CAAC,cAAc,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IACjD,UAAU,EAAE,CAAC,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,IAAI,CAAC;CAChD,CAAC;AAEF,eAAO,MAAM,eAAe,mHASzB,mBAAmB,SA8CrB,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"handleItemError.d.ts","sourceRoot":"","sources":["../../../../src/components/CodeInput/utils/handleItemError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAEzC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;
|
1
|
+
{"version":3,"file":"handleItemError.d.ts","sourceRoot":"","sources":["../../../../src/components/CodeInput/utils/handleItemError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAEzC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAI5D,KAAK,mBAAmB,GAAG;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACvB,SAAS,EAAE,gBAAgB,CAAC,KAAK,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAAC,CAAC;IAC5D,iBAAiB,EAAE,gBAAgB,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;IAC3D,UAAU,EAAE,CAAC,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,IAAI,CAAC;CAChD,CAAC;AAEF,eAAO,MAAM,eAAe,oGAQzB,mBAAmB,SA4BrB,CAAC"}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
export { getFieldPattern, getPlaceholderValue, getCodeValue } from '
|
1
|
+
export { getFieldPattern, getPlaceholderValue, getCodeValue } from '../../../utils';
|
2
2
|
export { handleItemError } from './handleItemError';
|
3
3
|
export { handleCodeError } from './handleCodeError';
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/CodeInput/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/CodeInput/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACpF,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../../../src/components/CodeInput/variations/_size/base.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../../../src/components/CodeInput/variations/_size/base.ts"],"names":[],"mappings":"AAqBA,eAAO,MAAM,IAAI,0CA2BhB,CAAC"}
|
package/types/hooks/index.d.ts
CHANGED
@@ -6,4 +6,5 @@ export { useDidMountEffect } from './useDidMountEffect';
|
|
6
6
|
export { useDidMountLayoutEffect } from './useDidMountLayoutEffect';
|
7
7
|
export { useOutsideClick } from './useOutsideClick';
|
8
8
|
export { useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect';
|
9
|
+
export { useCodeHook } from './useCodeHook';
|
9
10
|
//# sourceMappingURL=index.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC"}
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC"}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import { MutableRefObject } from 'react';
|
2
|
+
type useCodeHookTypes = {
|
3
|
+
codeLength: number;
|
4
|
+
inputRefs: MutableRefObject<Array<HTMLInputElement | null>>;
|
5
|
+
autoFocus?: boolean;
|
6
|
+
disabled?: boolean;
|
7
|
+
originalValue: string;
|
8
|
+
getLastActiveIndex: () => number;
|
9
|
+
handleFullCodeEnter: (fullCode: string) => void;
|
10
|
+
};
|
11
|
+
export declare const useCodeHook: ({ inputRefs, codeLength, disabled, autoFocus, originalValue, getLastActiveIndex, handleFullCodeEnter, }: useCodeHookTypes) => void;
|
12
|
+
export {};
|
13
|
+
//# sourceMappingURL=useCodeHook.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"useCodeHook.d.ts","sourceRoot":"","sources":["../../src/hooks/useCodeHook.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAa,MAAM,OAAO,CAAC;AAIpD,KAAK,gBAAgB,GAAG;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,gBAAgB,CAAC,KAAK,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAAC,CAAC;IAC5D,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,kBAAkB,EAAE,MAAM,MAAM,CAAC;IACjC,mBAAmB,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;CACnD,CAAC;AAEF,eAAO,MAAM,WAAW,4GAQrB,gBAAgB,SAkBlB,CAAC"}
|
@@ -16,4 +16,10 @@ export declare const screenGroupBreakpoints: {
|
|
16
16
|
medium: string;
|
17
17
|
large: string;
|
18
18
|
};
|
19
|
+
export declare const ONLY_DIGITS_PATTERN = "^\\d+$";
|
20
|
+
export declare const ONLY_CHARS_PATTERN = "^[a-zA-Z]+$";
|
21
|
+
export declare const ONLY_DIGITS_AND_CHARS_PATTERN = "^[a-zA-Z0-9]+$";
|
22
|
+
export declare const FORBIDDEN_KEYS: string[];
|
23
|
+
export declare const BACKSPACE_KEY = "Backspace";
|
24
|
+
export declare const ANIMATION_TIMEOUT = 300;
|
19
25
|
//# sourceMappingURL=constants.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/utils/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,QAAQ;;;;;;;;;;;;CAYpB,CAAC;AAEF,eAAO,MAAM,sBAAsB;;;;CAIlC,CAAC"}
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/utils/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,QAAQ;;;;;;;;;;;;CAYpB,CAAC;AAEF,eAAO,MAAM,sBAAsB;;;;CAIlC,CAAC;AAEF,eAAO,MAAM,mBAAmB,WAAW,CAAC;AAC5C,eAAO,MAAM,kBAAkB,gBAAgB,CAAC;AAChD,eAAO,MAAM,6BAA6B,mBAAmB,CAAC;AAE9D,eAAO,MAAM,cAAc,UAAuE,CAAC;AACnG,eAAO,MAAM,aAAa,cAAc,CAAC;AAEzC,eAAO,MAAM,iBAAiB,MAAM,CAAC"}
|
package/types/utils/index.d.ts
CHANGED
@@ -9,6 +9,7 @@ export { isEmpty } from './isEmpty';
|
|
9
9
|
export { createEvent } from './createEvent';
|
10
10
|
export * as constants from './constants';
|
11
11
|
export * from './getPopoverPlacement';
|
12
|
+
export * from './initialValuesHelper';
|
12
13
|
export { noop } from './noop';
|
13
14
|
export { getHeightAsNumber } from './getHeightAsNumber';
|
14
15
|
export { createConditionalComponent } from './createConditionalComponent';
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,KAAK,SAAS,MAAM,aAAa,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAE1E,eAAO,MAAM,EAAE,eAAgB,CAAC,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC,EAAE,WAAuD,CAAC;AAEvH,eAAO,MAAM,eAAe,MAAO,oBAAoB,WAAW,KAAK,CAAC,MAAM,GAAG,MAAM,GAAG,aAAa,CAAC,KAAG,MAQ1G,CAAC;AAEF,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC"}
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,KAAK,SAAS,MAAM,aAAa,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAE1E,eAAO,MAAM,EAAE,eAAgB,CAAC,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC,EAAE,WAAuD,CAAC;AAEvH,eAAO,MAAM,eAAe,MAAO,oBAAoB,WAAW,KAAK,CAAC,MAAM,GAAG,MAAM,GAAG,aAAa,CAAC,KAAG,MAQ1G,CAAC;AAEF,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"initialValuesHelper.d.ts","sourceRoot":"","sources":["../../src/utils/initialValuesHelper.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,mBAAoB,MAAM,GAAG,MAAM,kBAU9D,CAAC;AAEF,eAAO,MAAM,YAAY,eAAgB,MAAM,SAAS,MAAM,KAAG,KAAK,CAAC,MAAM,CAM5E,CAAC;AAEF,eAAO,MAAM,mBAAmB,eAAgB,MAAM,gBAAgB,MAAM,KAAG,IAAI,GAAG,MAAM,EAU3F,CAAC"}
|
@@ -1,14 +0,0 @@
|
|
1
|
-
'use strict';
|
2
|
-
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
4
|
-
|
5
|
-
var ONLY_DIGITS_PATTERN = '^\\d+$';
|
6
|
-
var FORBIDDEN_KEYS = ['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown', 'Delete', 'Tab'];
|
7
|
-
var BACKSPACE_KEY = 'Backspace';
|
8
|
-
var ANIMATION_TIMEOUT = 300;
|
9
|
-
|
10
|
-
exports.ANIMATION_TIMEOUT = ANIMATION_TIMEOUT;
|
11
|
-
exports.BACKSPACE_KEY = BACKSPACE_KEY;
|
12
|
-
exports.FORBIDDEN_KEYS = FORBIDDEN_KEYS;
|
13
|
-
exports.ONLY_DIGITS_PATTERN = ONLY_DIGITS_PATTERN;
|
14
|
-
//# sourceMappingURL=constants.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"constants.js","sources":["../../../../src/components/CodeInput/utils/constants.ts"],"sourcesContent":["export const ONLY_DIGITS_PATTERN = '^\\\\d+$';\nexport const ONLY_CHARS_PATTERN = '^[a-zA-Z]+$';\nexport const ONLY_DIGITS_AND_CHARS_PATTERN = '^[a-zA-Z0-9]+$';\n\nexport const FORBIDDEN_KEYS = ['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown', 'Delete', 'Tab'];\nexport const BACKSPACE_KEY = 'Backspace';\n\nexport const ANIMATION_TIMEOUT = 300;\n"],"names":["ONLY_DIGITS_PATTERN","FORBIDDEN_KEYS","BACKSPACE_KEY","ANIMATION_TIMEOUT"],"mappings":";;;;AAAO,IAAMA,mBAAmB,GAAG,SAAQ;AAI9BC,IAAAA,cAAc,GAAG,CAAC,WAAW,EAAE,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,QAAQ,EAAE,KAAK,EAAC;AAC3F,IAAMC,aAAa,GAAG,YAAW;AAEjC,IAAMC,iBAAiB,GAAG;;;;;;;"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"initialValuesHelper.js","sources":["../../../../src/components/CodeInput/utils/initialValuesHelper.ts"],"sourcesContent":["export const getFieldPattern = (allowedSymbols: RegExp | string) => {\n if (!allowedSymbols) {\n return null;\n }\n\n if (typeof allowedSymbols === 'string') {\n return new RegExp(allowedSymbols, 'g');\n }\n\n return allowedSymbols;\n};\n\nexport const getCodeValue = (codeLength: number, value: string): Array<string> => {\n if (!value.length) {\n return new Array(codeLength).fill('');\n }\n\n return value.slice(0, codeLength).split('');\n};\n\nexport const getPlaceholderValue = (codeLength: number, placeholder?: string): null | string[] => {\n if (!placeholder || typeof placeholder !== 'string') {\n return null;\n }\n\n if (placeholder.length === 1) {\n return Array(codeLength).fill(placeholder);\n }\n\n return placeholder.slice(0, codeLength).split('');\n};\n"],"names":["getFieldPattern","allowedSymbols","RegExp","getCodeValue","codeLength","value","length","Array","fill","slice","split","getPlaceholderValue","placeholder"],"mappings":";;;;IAAaA,eAAe,GAAG,SAAlBA,eAAeA,CAAIC,cAA+B,EAAK;EAChE,IAAI,CAACA,cAAc,EAAE;AACjB,IAAA,OAAO,IAAI,CAAA;AACf,GAAA;AAEA,EAAA,IAAI,OAAOA,cAAc,KAAK,QAAQ,EAAE;AACpC,IAAA,OAAO,IAAIC,MAAM,CAACD,cAAc,EAAE,GAAG,CAAC,CAAA;AAC1C,GAAA;AAEA,EAAA,OAAOA,cAAc,CAAA;AACzB,EAAC;AAEM,IAAME,YAAY,GAAG,SAAfA,YAAYA,CAAIC,UAAkB,EAAEC,KAAa,EAAoB;AAC9E,EAAA,IAAI,CAACA,KAAK,CAACC,MAAM,EAAE;IACf,OAAO,IAAIC,KAAK,CAACH,UAAU,CAAC,CAACI,IAAI,CAAC,EAAE,CAAC,CAAA;AACzC,GAAA;AAEA,EAAA,OAAOH,KAAK,CAACI,KAAK,CAAC,CAAC,EAAEL,UAAU,CAAC,CAACM,KAAK,CAAC,EAAE,CAAC,CAAA;AAC/C,EAAC;AAEM,IAAMC,mBAAmB,GAAG,SAAtBA,mBAAmBA,CAAIP,UAAkB,EAAEQ,WAAoB,EAAsB;AAC9F,EAAA,IAAI,CAACA,WAAW,IAAI,OAAOA,WAAW,KAAK,QAAQ,EAAE;AACjD,IAAA,OAAO,IAAI,CAAA;AACf,GAAA;AAEA,EAAA,IAAIA,WAAW,CAACN,MAAM,KAAK,CAAC,EAAE;IAC1B,OAAOC,KAAK,CAACH,UAAU,CAAC,CAACI,IAAI,CAACI,WAAW,CAAC,CAAA;AAC9C,GAAA;AAEA,EAAA,OAAOA,WAAW,CAACH,KAAK,CAAC,CAAC,EAAEL,UAAU,CAAC,CAACM,KAAK,CAAC,EAAE,CAAC,CAAA;AACrD;;;;;;"}
|
@@ -1,12 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.ONLY_DIGITS_PATTERN = exports.ONLY_DIGITS_AND_CHARS_PATTERN = exports.ONLY_CHARS_PATTERN = exports.FORBIDDEN_KEYS = exports.BACKSPACE_KEY = exports.ANIMATION_TIMEOUT = void 0;
|
7
|
-
var ONLY_DIGITS_PATTERN = exports.ONLY_DIGITS_PATTERN = '^\\d+$';
|
8
|
-
var ONLY_CHARS_PATTERN = exports.ONLY_CHARS_PATTERN = '^[a-zA-Z]+$';
|
9
|
-
var ONLY_DIGITS_AND_CHARS_PATTERN = exports.ONLY_DIGITS_AND_CHARS_PATTERN = '^[a-zA-Z0-9]+$';
|
10
|
-
var FORBIDDEN_KEYS = exports.FORBIDDEN_KEYS = ['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown', 'Delete', 'Tab'];
|
11
|
-
var BACKSPACE_KEY = exports.BACKSPACE_KEY = 'Backspace';
|
12
|
-
var ANIMATION_TIMEOUT = exports.ANIMATION_TIMEOUT = 300;
|
@@ -1,6 +0,0 @@
|
|
1
|
-
export var ONLY_DIGITS_PATTERN = '^\\d+$';
|
2
|
-
export var ONLY_CHARS_PATTERN = '^[a-zA-Z]+$';
|
3
|
-
export var ONLY_DIGITS_AND_CHARS_PATTERN = '^[a-zA-Z0-9]+$';
|
4
|
-
export var FORBIDDEN_KEYS = ['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown', 'Delete', 'Tab'];
|
5
|
-
export var BACKSPACE_KEY = 'Backspace';
|
6
|
-
export var ANIMATION_TIMEOUT = 300;
|
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|
@@ -1,7 +0,0 @@
|
|
1
|
-
var ONLY_DIGITS_PATTERN = '^\\d+$';
|
2
|
-
var FORBIDDEN_KEYS = ['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown', 'Delete', 'Tab'];
|
3
|
-
var BACKSPACE_KEY = 'Backspace';
|
4
|
-
var ANIMATION_TIMEOUT = 300;
|
5
|
-
|
6
|
-
export { ANIMATION_TIMEOUT, BACKSPACE_KEY, FORBIDDEN_KEYS, ONLY_DIGITS_PATTERN };
|
7
|
-
//# sourceMappingURL=constants.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"constants.js","sources":["../../../../src/components/CodeInput/utils/constants.ts"],"sourcesContent":["export const ONLY_DIGITS_PATTERN = '^\\\\d+$';\nexport const ONLY_CHARS_PATTERN = '^[a-zA-Z]+$';\nexport const ONLY_DIGITS_AND_CHARS_PATTERN = '^[a-zA-Z0-9]+$';\n\nexport const FORBIDDEN_KEYS = ['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown', 'Delete', 'Tab'];\nexport const BACKSPACE_KEY = 'Backspace';\n\nexport const ANIMATION_TIMEOUT = 300;\n"],"names":["ONLY_DIGITS_PATTERN","FORBIDDEN_KEYS","BACKSPACE_KEY","ANIMATION_TIMEOUT"],"mappings":"AAAO,IAAMA,mBAAmB,GAAG,SAAQ;AAI9BC,IAAAA,cAAc,GAAG,CAAC,WAAW,EAAE,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,QAAQ,EAAE,KAAK,EAAC;AAC3F,IAAMC,aAAa,GAAG,YAAW;AAEjC,IAAMC,iBAAiB,GAAG;;;;"}
|