@salutejs/plasma-new-hope 0.336.0-canary.2210.17488241312.0 → 0.336.0-canary.2210.17546691141.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.css +7 -7
- package/cjs/components/CodeField/CodeField.js +39 -27
- package/cjs/components/CodeField/CodeField.js.map +1 -1
- package/cjs/components/CodeField/CodeField.styles.js +1 -1
- package/cjs/components/CodeField/CodeField.styles.js.map +1 -1
- package/cjs/components/CodeField/{CodeField.styles_14p25hi.css → CodeField.styles_7tebk.css} +1 -1
- package/cjs/components/Pagination/Pagination.js +2 -1
- package/cjs/components/Pagination/Pagination.js.map +1 -1
- package/cjs/index.css +7 -7
- package/emotion/cjs/components/CodeField/CodeField.js +35 -22
- package/emotion/cjs/components/CodeField/CodeField.styles.js +13 -13
- package/emotion/cjs/components/Pagination/Pagination.js +1 -1
- package/emotion/cjs/examples/components/Combobox/Combobox.js +15 -0
- package/emotion/es/components/CodeField/CodeField.js +37 -23
- package/emotion/es/components/CodeField/CodeField.styles.js +13 -13
- package/emotion/es/components/Pagination/Pagination.js +1 -1
- package/es/components/CodeField/CodeField.css +7 -7
- package/es/components/CodeField/CodeField.js +40 -28
- package/es/components/CodeField/CodeField.js.map +1 -1
- package/es/components/CodeField/CodeField.styles.js +1 -1
- package/es/components/CodeField/CodeField.styles.js.map +1 -1
- package/es/components/CodeField/{CodeField.styles_14p25hi.css → CodeField.styles_7tebk.css} +1 -1
- package/es/components/Pagination/Pagination.js +2 -1
- package/es/components/Pagination/Pagination.js.map +1 -1
- package/es/index.css +7 -7
- package/package.json +2 -2
- package/styled-components/cjs/components/CodeField/CodeField.js +35 -22
- package/styled-components/cjs/components/CodeField/CodeField.styles.js +7 -7
- package/styled-components/cjs/components/Pagination/Pagination.js +1 -1
- package/styled-components/cjs/examples/components/Combobox/Combobox.js +15 -0
- package/styled-components/es/components/CodeField/CodeField.js +37 -23
- package/styled-components/es/components/CodeField/CodeField.styles.js +7 -7
- package/styled-components/es/components/Pagination/Pagination.js +1 -1
- package/types/components/CodeField/CodeField.d.ts.map +1 -1
- package/types/components/CodeField/CodeField.styles.d.ts.map +1 -1
- package/types/components/Pagination/Pagination.types.d.ts +75 -0
- package/types/components/Pagination/Pagination.types.d.ts.map +1 -1
- package/cjs/components/CodeField/hooks/useWebOTP.js +0 -107
- package/cjs/components/CodeField/hooks/useWebOTP.js.map +0 -1
- package/es/components/CodeField/hooks/useWebOTP.js +0 -103
- package/es/components/CodeField/hooks/useWebOTP.js.map +0 -1
@@ -29,7 +29,6 @@ var _base = require("./variations/_view/base");
|
|
29
29
|
var _base1 = require("./variations/_size/base");
|
30
30
|
var _base2 = require("./variations/_shape/base");
|
31
31
|
var _base3 = require("./variations/_disabled/base");
|
32
|
-
var _useWebOTP = require("./hooks/useWebOTP");
|
33
32
|
function _array_like_to_array(arr, len) {
|
34
33
|
if (len == null || len > arr.length) len = arr.length;
|
35
34
|
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
@@ -213,18 +212,20 @@ var codeFieldRoot = function(Root) {
|
|
213
212
|
"onChange",
|
214
213
|
"onFullCodeEnter"
|
215
214
|
]);
|
215
|
+
var _autocompleteRef_current;
|
216
216
|
var _useState = _sliced_to_array((0, _react.useState)((0, _utils1.getCodeValue)(codeLength, '')), 2), innerValue = _useState[0], setInnerValue = _useState[1];
|
217
|
-
var code =
|
217
|
+
var code = typeof outerValue === 'string' ? (0, _utils1.getCodeValue)(codeLength, outerValue) : innerValue;
|
218
218
|
var _useState1 = _sliced_to_array((0, _react.useState)(code.join('')), 2), originalValue = _useState1[0], setOriginalValue = _useState1[1];
|
219
|
-
|
219
|
+
// const [otpVal, setOtpVal] = useState<Credential | null>(null);
|
220
220
|
var inputRefs = (0, _react.useRef)([]);
|
221
221
|
var inputContainerRef = (0, _react.useRef)(null);
|
222
222
|
var captionRef = (0, _react.useRef)(null);
|
223
|
+
var autocompleteRef = (0, _react.useRef)(null);
|
223
224
|
var fieldPattern = (0, _utils1.getFieldPattern)(allowedSymbols);
|
224
225
|
var placeholderValue = (0, _utils1.getPlaceholderValue)(codeLength, placeholder);
|
225
226
|
var parts = codeLength === 6 ? 2 : 1;
|
226
227
|
var widthValue = width ? (0, _utils.getSizeValueFromProp)(width, 'rem') : undefined;
|
227
|
-
var isWebOTPEnabled = autoComplete === 'one-time-code' && !disabled &&
|
228
|
+
var isWebOTPEnabled = autoComplete === 'one-time-code' && !disabled && (0, _utils1.isWebOTPSupported)();
|
228
229
|
var getLastActiveIndex = function() {
|
229
230
|
if (code.length && code.length < codeLength) {
|
230
231
|
return code.length;
|
@@ -235,25 +236,25 @@ var codeFieldRoot = function(Root) {
|
|
235
236
|
return lastEmptyIndex >= 0 ? lastEmptyIndex : codeLength - 1;
|
236
237
|
};
|
237
238
|
var codeSetter = function(newCode) {
|
238
|
-
setInnerValue(newCode);
|
239
239
|
var originalCode = newCode.join('');
|
240
|
+
setInnerValue((0, _utils1.getCodeValue)(codeLength, originalCode));
|
240
241
|
setOriginalValue(originalCode);
|
241
242
|
if (onChange) {
|
242
243
|
onChange(originalCode);
|
243
244
|
}
|
244
|
-
|
245
|
-
|
246
|
-
|
245
|
+
// if (originalCode.length > 0) {
|
246
|
+
// stopWebOTPListener();
|
247
|
+
// }
|
247
248
|
};
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
})
|
249
|
+
// const { startWebOTPListener, stopWebOTPListener } = useWebOTP({
|
250
|
+
// codeString: originalValue,
|
251
|
+
// enableSMSAutoRead: autoComplete === 'one-time-code',
|
252
|
+
// disabled: Boolean(disabled),
|
253
|
+
// codeLength,
|
254
|
+
// codeSetter,
|
255
|
+
// onFullCodeEnter,
|
256
|
+
// setOtpVal,
|
257
|
+
// });
|
257
258
|
var handleClick = function() {
|
258
259
|
if (disabled) {
|
259
260
|
return;
|
@@ -311,6 +312,9 @@ var codeFieldRoot = function(Root) {
|
|
311
312
|
setIsError(false);
|
312
313
|
}
|
313
314
|
}
|
315
|
+
if (!symbol) {
|
316
|
+
return;
|
317
|
+
}
|
314
318
|
if (!fieldPattern) {
|
315
319
|
newCode[index] = symbol;
|
316
320
|
codeSetter(newCode);
|
@@ -320,9 +324,6 @@ var codeFieldRoot = function(Root) {
|
|
320
324
|
}
|
321
325
|
return;
|
322
326
|
}
|
323
|
-
if (!symbol) {
|
324
|
-
return;
|
325
|
-
}
|
326
327
|
if (fieldPattern.test(symbol)) {
|
327
328
|
newCode[index] = symbol.charAt(symbol.length - 1);
|
328
329
|
codeSetter(newCode);
|
@@ -367,7 +368,7 @@ var codeFieldRoot = function(Root) {
|
|
367
368
|
if (onFullCodeEnter) {
|
368
369
|
onFullCodeEnter(fullCode);
|
369
370
|
}
|
370
|
-
|
371
|
+
// startWebOTPListener();
|
371
372
|
}, []);
|
372
373
|
(0, _hooks1.useCodeHook)({
|
373
374
|
inputRefs: inputRefs,
|
@@ -394,6 +395,16 @@ var codeFieldRoot = function(Root) {
|
|
394
395
|
}, [
|
395
396
|
isError
|
396
397
|
]);
|
398
|
+
(0, _react.useEffect)(function() {
|
399
|
+
if (disabled || !autocompleteRef.current) {
|
400
|
+
return;
|
401
|
+
}
|
402
|
+
var autocompleteCode = autocompleteRef.current.value.split('');
|
403
|
+
codeSetter(autocompleteCode);
|
404
|
+
}, [
|
405
|
+
(_autocompleteRef_current = autocompleteRef.current) === null || _autocompleteRef_current === void 0 ? void 0 : _autocompleteRef_current.value,
|
406
|
+
disabled
|
407
|
+
]);
|
397
408
|
return /*#__PURE__*/ _react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/ _react.default.createElement(Root, _object_spread({
|
398
409
|
ref: ref,
|
399
410
|
view: view,
|
@@ -436,8 +447,10 @@ var codeFieldRoot = function(Root) {
|
|
436
447
|
captionAlign: captionAlign,
|
437
448
|
widthValue: widthValue
|
438
449
|
}, caption), isWebOTPEnabled && /*#__PURE__*/ _react.default.createElement(_CodeFieldstyles.HiddenInput, _object_spread({
|
450
|
+
ref: autocompleteRef,
|
451
|
+
autoComplete: autoComplete,
|
439
452
|
tabIndex: -1
|
440
|
-
}, rest)))
|
453
|
+
}, rest))));
|
441
454
|
});
|
442
455
|
};
|
443
456
|
var codeFieldConfig = {
|
@@ -80,32 +80,32 @@ var base = (0, _styledcomponents.css)([
|
|
80
80
|
], _CodeFieldtokens.classes.captionAlignLeft);
|
81
81
|
var CodeWrapper = _styledcomponents.default.div.withConfig({
|
82
82
|
displayName: "CodeField.styles__CodeWrapper",
|
83
|
-
componentId: "sc-
|
83
|
+
componentId: "sc-ae648a72-0"
|
84
84
|
})([
|
85
85
|
"display:flex;align-items:center;"
|
86
86
|
]);
|
87
87
|
var CodeGroup = _styledcomponents.default.div.withConfig({
|
88
88
|
displayName: "CodeField.styles__CodeGroup",
|
89
|
-
componentId: "sc-
|
89
|
+
componentId: "sc-ae648a72-1"
|
90
90
|
})([
|
91
91
|
"display:flex;align-items:center;"
|
92
92
|
]);
|
93
93
|
var Separator = _styledcomponents.default.div.withConfig({
|
94
94
|
displayName: "CodeField.styles__Separator",
|
95
|
-
componentId: "sc-
|
95
|
+
componentId: "sc-ae648a72-2"
|
96
96
|
})([
|
97
97
|
"width:var(",
|
98
98
|
");"
|
99
99
|
], _CodeFieldtokens.tokens.separatorWidth);
|
100
100
|
var ItemInput = _styledcomponents.default.input.withConfig({
|
101
101
|
displayName: "CodeField.styles__ItemInput",
|
102
|
-
componentId: "sc-
|
102
|
+
componentId: "sc-ae648a72-3"
|
103
103
|
})([
|
104
104
|
"box-sizing:border-box;appearance:none;border:0;padding:0;outline:none;pointer-events:none;text-align:center;"
|
105
105
|
]);
|
106
106
|
var CaptionWrapper = _styledcomponents.default.div.withConfig({
|
107
107
|
displayName: "CodeField.styles__CaptionWrapper",
|
108
|
-
componentId: "sc-
|
108
|
+
componentId: "sc-ae648a72-4"
|
109
109
|
})([
|
110
110
|
"text-align:",
|
111
111
|
";align-self:",
|
@@ -123,7 +123,7 @@ var CaptionWrapper = _styledcomponents.default.div.withConfig({
|
|
123
123
|
});
|
124
124
|
var HiddenInput = _styledcomponents.default.input.withConfig({
|
125
125
|
displayName: "CodeField.styles__HiddenInput",
|
126
|
-
componentId: "sc-
|
126
|
+
componentId: "sc-ae648a72-5"
|
127
127
|
})([
|
128
|
-
"
|
128
|
+
""
|
129
129
|
]);
|
@@ -170,7 +170,7 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
170
170
|
}
|
171
171
|
var paginationRoot = function(Root) {
|
172
172
|
return /*#__PURE__*/ (0, _react.forwardRef)(function(_param, ref) {
|
173
|
-
var outerValue = _param.value, defaultValue = _param.defaultValue, outerPerPage = _param.perPage, defaultPerPage = _param.defaultPerPage, _param_slots = _param.slots, slots = _param_slots === void 0 ? _utils1.defaultValues.slots : _param_slots, view = _param.view, viewCurrentPage = _param.viewCurrentPage, _param_type = _param.type, type = _param_type === void 0 ? _utils1.defaultValues.type : _param_type, size = _param.size, _param_pilled = _param.pilled, pilled = _param_pilled === void 0 ? _utils1.defaultValues.pilled : _param_pilled, _param_square = _param.square, square = _param_square === void 0 ? _utils1.defaultValues.square : _param_square, _param_disabledPages = _param.disabledPages, disabledPages = _param_disabledPages === void 0 ? _utils1.defaultValues.disabledPages : _param_disabledPages, _param_count = _param.count, count = _param_count === void 0 ? _utils1.defaultValues.value : _param_count, _param_hasQuickJump = _param.hasQuickJump, hasQuickJump = _param_hasQuickJump === void 0 ? _utils1.defaultValues.hasQuickJump : _param_hasQuickJump, _param_hasPerPage = _param.hasPerPage, hasPerPage = _param_hasPerPage === void 0 ? _utils1.defaultValues.hasPerPage : _param_hasPerPage, _param_perPageList = _param.perPageList, perPageList = _param_perPageList === void 0 ? _utils1.defaultValues.perPageList : _param_perPageList, _param_isCommonButtonStyles = _param.isCommonButtonStyles, isCommonButtonStyles = _param_isCommonButtonStyles === void 0 ? _utils1.defaultValues.isCommonButtonStyles : _param_isCommonButtonStyles, _param_placeholderQuickJump = _param.placeholderQuickJump, placeholderQuickJump = _param_placeholderQuickJump === void 0 ? _utils1.defaultValues.placeholderQuickJump : _param_placeholderQuickJump, _param_textQuickJump = _param.textQuickJump, textQuickJump = _param_textQuickJump === void 0 ? _utils1.defaultValues.textQuickJump : _param_textQuickJump, _param_textPerPage = _param.textPerPage, textPerPage = _param_textPerPage === void 0 ? _utils1.defaultValues.textPerPage : _param_textPerPage, leftContent = _param.leftContent, rightContent = _param.rightContent,
|
173
|
+
var outerValue = _param.value, defaultValue = _param.defaultValue, outerPerPage = _param.perPage, defaultPerPage = _param.defaultPerPage, _param_slots = _param.slots, slots = _param_slots === void 0 ? _utils1.defaultValues.slots : _param_slots, view = _param.view, viewCurrentPage = _param.viewCurrentPage, _param_type = _param.type, type = _param_type === void 0 ? _utils1.defaultValues.type : _param_type, size = _param.size, _param_pilled = _param.pilled, pilled = _param_pilled === void 0 ? _utils1.defaultValues.pilled : _param_pilled, _param_square = _param.square, square = _param_square === void 0 ? _utils1.defaultValues.square : _param_square, _param_disabledPages = _param.disabledPages, disabledPages = _param_disabledPages === void 0 ? _utils1.defaultValues.disabledPages : _param_disabledPages, _param_count = _param.count, count = _param_count === void 0 ? _utils1.defaultValues.value : _param_count, _param_hasQuickJump = _param.hasQuickJump, hasQuickJump = _param_hasQuickJump === void 0 ? _utils1.defaultValues.hasQuickJump : _param_hasQuickJump, _param_hasPerPage = _param.hasPerPage, hasPerPage = _param_hasPerPage === void 0 ? _utils1.defaultValues.hasPerPage : _param_hasPerPage, _param_perPageList = _param.perPageList, perPageList = _param_perPageList === void 0 ? _utils1.defaultValues.perPageList : _param_perPageList, _param_isCommonButtonStyles = _param.isCommonButtonStyles, isCommonButtonStyles = _param_isCommonButtonStyles === void 0 ? _utils1.defaultValues.isCommonButtonStyles : _param_isCommonButtonStyles, _param_placeholderQuickJump = _param.placeholderQuickJump, placeholderQuickJump = _param_placeholderQuickJump === void 0 ? _utils1.defaultValues.placeholderQuickJump : _param_placeholderQuickJump, _param_textQuickJump = _param.textQuickJump, textQuickJump = _param_textQuickJump === void 0 ? _utils1.defaultValues.textQuickJump : _param_textQuickJump, _param_textPerPage = _param.textPerPage, textPerPage = _param_textPerPage === void 0 ? _utils1.defaultValues.textPerPage : _param_textPerPage, leftContent = _param.leftContent, rightContent = _param.rightContent, _param_listWidth = _param.listWidth, listWidth = _param_listWidth === void 0 ? 'fit-content' : _param_listWidth, onChangePageValue = _param.onChangePageValue, onChangePerPageValue = _param.onChangePerPageValue, onChange = _param.onChange, rest = _object_without_properties(_param, [
|
174
174
|
"value",
|
175
175
|
"defaultValue",
|
176
176
|
"perPage",
|
@@ -1 +1,16 @@
|
|
1
1
|
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
3
|
+
value: true
|
4
|
+
});
|
5
|
+
Object.defineProperty(exports, "Combobox", {
|
6
|
+
enumerable: true,
|
7
|
+
get: function() {
|
8
|
+
return Combobox;
|
9
|
+
}
|
10
|
+
});
|
11
|
+
var _engines = require("../../../engines");
|
12
|
+
var _ = require("../../..");
|
13
|
+
var _Comboboxconfig = require("./Combobox.config");
|
14
|
+
var mergedConfig = (0, _engines.mergeConfig)(_.comboboxNewConfig, _Comboboxconfig.config);
|
15
|
+
var ComboboxComponent = (0, _engines.component)(mergedConfig);
|
16
|
+
var Combobox = ComboboxComponent;
|
@@ -111,7 +111,7 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
111
111
|
if (n === "Map" || n === "Set") return Array.from(n);
|
112
112
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
113
113
|
}
|
114
|
-
import React, { forwardRef, Fragment, useCallback, useRef, useState } from "react";
|
114
|
+
import React, { forwardRef, Fragment, useCallback, useEffect, useRef, useState } from "react";
|
115
115
|
import cls from "classnames";
|
116
116
|
import { useDidMountEffect } from "../../hooks";
|
117
117
|
import { getSizeValueFromProp } from "../../utils";
|
@@ -124,7 +124,7 @@ import { base as viewCSS } from "./variations/_view/base";
|
|
124
124
|
import { base as sizeCSS } from "./variations/_size/base";
|
125
125
|
import { base as shapeCSS } from "./variations/_shape/base";
|
126
126
|
import { base as disabledCSS } from "./variations/_disabled/base";
|
127
|
-
import { useWebOTP } from
|
127
|
+
// import { useWebOTP } from './hooks/useWebOTP';
|
128
128
|
export var codeFieldRoot = function(Root) {
|
129
129
|
return /*#__PURE__*/ forwardRef(function(_param, ref) {
|
130
130
|
var className = _param.className, outerValue = _param.value, placeholder = _param.placeholder, autoFocus = _param.autoFocus, _param_codeLength = _param.codeLength, codeLength = _param_codeLength === void 0 ? 6 : _param_codeLength, caption = _param.caption, _param_captionAlign = _param.captionAlign, captionAlign = _param_captionAlign === void 0 ? 'left' : _param_captionAlign, width = _param.width, _param_shape = _param.shape, shape = _param_shape === void 0 ? 'default' : _param_shape, view = _param.view, size = _param.size, disabled = _param.disabled, isError = _param.isError, _param_allowedSymbols = _param.allowedSymbols, allowedSymbols = _param_allowedSymbols === void 0 ? ONLY_DIGITS_PATTERN : _param_allowedSymbols, _param_itemErrorBehavior = _param.itemErrorBehavior, itemErrorBehavior = _param_itemErrorBehavior === void 0 ? 'remove-symbol' : _param_itemErrorBehavior, _param_codeErrorBehavior = _param.codeErrorBehavior, codeErrorBehavior = _param_codeErrorBehavior === void 0 ? 'remove-code' : _param_codeErrorBehavior, _param_autoComplete = _param.autoComplete, autoComplete = _param_autoComplete === void 0 ? 'one-time-code' : _param_autoComplete, setIsError = _param.setIsError, onChange = _param.onChange, onFullCodeEnter = _param.onFullCodeEnter, rest = _object_without_properties(_param, [
|
@@ -149,18 +149,20 @@ export var codeFieldRoot = function(Root) {
|
|
149
149
|
"onChange",
|
150
150
|
"onFullCodeEnter"
|
151
151
|
]);
|
152
|
+
var _autocompleteRef_current;
|
152
153
|
var _useState = _sliced_to_array(useState(getCodeValue(codeLength, '')), 2), innerValue = _useState[0], setInnerValue = _useState[1];
|
153
|
-
var code =
|
154
|
+
var code = typeof outerValue === 'string' ? getCodeValue(codeLength, outerValue) : innerValue;
|
154
155
|
var _useState1 = _sliced_to_array(useState(code.join('')), 2), originalValue = _useState1[0], setOriginalValue = _useState1[1];
|
155
|
-
|
156
|
+
// const [otpVal, setOtpVal] = useState<Credential | null>(null);
|
156
157
|
var inputRefs = useRef([]);
|
157
158
|
var inputContainerRef = useRef(null);
|
158
159
|
var captionRef = useRef(null);
|
160
|
+
var autocompleteRef = useRef(null);
|
159
161
|
var fieldPattern = getFieldPattern(allowedSymbols);
|
160
162
|
var placeholderValue = getPlaceholderValue(codeLength, placeholder);
|
161
163
|
var parts = codeLength === 6 ? 2 : 1;
|
162
164
|
var widthValue = width ? getSizeValueFromProp(width, 'rem') : undefined;
|
163
|
-
var isWebOTPEnabled = autoComplete === 'one-time-code' && !disabled &&
|
165
|
+
var isWebOTPEnabled = autoComplete === 'one-time-code' && !disabled && isWebOTPSupported();
|
164
166
|
var getLastActiveIndex = function() {
|
165
167
|
if (code.length && code.length < codeLength) {
|
166
168
|
return code.length;
|
@@ -171,25 +173,25 @@ export var codeFieldRoot = function(Root) {
|
|
171
173
|
return lastEmptyIndex >= 0 ? lastEmptyIndex : codeLength - 1;
|
172
174
|
};
|
173
175
|
var codeSetter = function(newCode) {
|
174
|
-
setInnerValue(newCode);
|
175
176
|
var originalCode = newCode.join('');
|
177
|
+
setInnerValue(getCodeValue(codeLength, originalCode));
|
176
178
|
setOriginalValue(originalCode);
|
177
179
|
if (onChange) {
|
178
180
|
onChange(originalCode);
|
179
181
|
}
|
180
|
-
|
181
|
-
|
182
|
-
|
182
|
+
// if (originalCode.length > 0) {
|
183
|
+
// stopWebOTPListener();
|
184
|
+
// }
|
183
185
|
};
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
})
|
186
|
+
// const { startWebOTPListener, stopWebOTPListener } = useWebOTP({
|
187
|
+
// codeString: originalValue,
|
188
|
+
// enableSMSAutoRead: autoComplete === 'one-time-code',
|
189
|
+
// disabled: Boolean(disabled),
|
190
|
+
// codeLength,
|
191
|
+
// codeSetter,
|
192
|
+
// onFullCodeEnter,
|
193
|
+
// setOtpVal,
|
194
|
+
// });
|
193
195
|
var handleClick = function() {
|
194
196
|
if (disabled) {
|
195
197
|
return;
|
@@ -247,6 +249,9 @@ export var codeFieldRoot = function(Root) {
|
|
247
249
|
setIsError(false);
|
248
250
|
}
|
249
251
|
}
|
252
|
+
if (!symbol) {
|
253
|
+
return;
|
254
|
+
}
|
250
255
|
if (!fieldPattern) {
|
251
256
|
newCode[index] = symbol;
|
252
257
|
codeSetter(newCode);
|
@@ -256,9 +261,6 @@ export var codeFieldRoot = function(Root) {
|
|
256
261
|
}
|
257
262
|
return;
|
258
263
|
}
|
259
|
-
if (!symbol) {
|
260
|
-
return;
|
261
|
-
}
|
262
264
|
if (fieldPattern.test(symbol)) {
|
263
265
|
newCode[index] = symbol.charAt(symbol.length - 1);
|
264
266
|
codeSetter(newCode);
|
@@ -303,7 +305,7 @@ export var codeFieldRoot = function(Root) {
|
|
303
305
|
if (onFullCodeEnter) {
|
304
306
|
onFullCodeEnter(fullCode);
|
305
307
|
}
|
306
|
-
|
308
|
+
// startWebOTPListener();
|
307
309
|
}, []);
|
308
310
|
useCodeHook({
|
309
311
|
inputRefs: inputRefs,
|
@@ -330,6 +332,16 @@ export var codeFieldRoot = function(Root) {
|
|
330
332
|
}, [
|
331
333
|
isError
|
332
334
|
]);
|
335
|
+
useEffect(function() {
|
336
|
+
if (disabled || !autocompleteRef.current) {
|
337
|
+
return;
|
338
|
+
}
|
339
|
+
var autocompleteCode = autocompleteRef.current.value.split('');
|
340
|
+
codeSetter(autocompleteCode);
|
341
|
+
}, [
|
342
|
+
(_autocompleteRef_current = autocompleteRef.current) === null || _autocompleteRef_current === void 0 ? void 0 : _autocompleteRef_current.value,
|
343
|
+
disabled
|
344
|
+
]);
|
333
345
|
return /*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement(Root, _object_spread({
|
334
346
|
ref: ref,
|
335
347
|
view: view,
|
@@ -372,8 +384,10 @@ export var codeFieldRoot = function(Root) {
|
|
372
384
|
captionAlign: captionAlign,
|
373
385
|
widthValue: widthValue
|
374
386
|
}, caption), isWebOTPEnabled && /*#__PURE__*/ React.createElement(HiddenInput, _object_spread({
|
387
|
+
ref: autocompleteRef,
|
388
|
+
autoComplete: autoComplete,
|
375
389
|
tabIndex: -1
|
376
|
-
}, rest)))
|
390
|
+
}, rest))));
|
377
391
|
});
|
378
392
|
};
|
379
393
|
export var codeFieldConfig = {
|
@@ -7,32 +7,32 @@ export var base = css([
|
|
7
7
|
], classes.captionAlignLeft);
|
8
8
|
export var CodeWrapper = styled.div.withConfig({
|
9
9
|
displayName: "CodeField.styles__CodeWrapper",
|
10
|
-
componentId: "sc-
|
10
|
+
componentId: "sc-ae648a72-0"
|
11
11
|
})([
|
12
12
|
"display:flex;align-items:center;"
|
13
13
|
]);
|
14
14
|
export var CodeGroup = styled.div.withConfig({
|
15
15
|
displayName: "CodeField.styles__CodeGroup",
|
16
|
-
componentId: "sc-
|
16
|
+
componentId: "sc-ae648a72-1"
|
17
17
|
})([
|
18
18
|
"display:flex;align-items:center;"
|
19
19
|
]);
|
20
20
|
export var Separator = styled.div.withConfig({
|
21
21
|
displayName: "CodeField.styles__Separator",
|
22
|
-
componentId: "sc-
|
22
|
+
componentId: "sc-ae648a72-2"
|
23
23
|
})([
|
24
24
|
"width:var(",
|
25
25
|
");"
|
26
26
|
], tokens.separatorWidth);
|
27
27
|
export var ItemInput = styled.input.withConfig({
|
28
28
|
displayName: "CodeField.styles__ItemInput",
|
29
|
-
componentId: "sc-
|
29
|
+
componentId: "sc-ae648a72-3"
|
30
30
|
})([
|
31
31
|
"box-sizing:border-box;appearance:none;border:0;padding:0;outline:none;pointer-events:none;text-align:center;"
|
32
32
|
]);
|
33
33
|
export var CaptionWrapper = styled.div.withConfig({
|
34
34
|
displayName: "CodeField.styles__CaptionWrapper",
|
35
|
-
componentId: "sc-
|
35
|
+
componentId: "sc-ae648a72-4"
|
36
36
|
})([
|
37
37
|
"text-align:",
|
38
38
|
";align-self:",
|
@@ -50,7 +50,7 @@ export var CaptionWrapper = styled.div.withConfig({
|
|
50
50
|
});
|
51
51
|
export var HiddenInput = styled.input.withConfig({
|
52
52
|
displayName: "CodeField.styles__HiddenInput",
|
53
|
-
componentId: "sc-
|
53
|
+
componentId: "sc-ae648a72-5"
|
54
54
|
})([
|
55
|
-
"
|
55
|
+
""
|
56
56
|
]);
|
@@ -111,7 +111,7 @@ import { PaginationQuickJumpToPage } from "./ui/PaginationQuickJumpToPage/Pagina
|
|
111
111
|
import { PaginationSelectPerPage } from "./ui/PaginationSelectPerPage/PaginationSelectPerPage";
|
112
112
|
export var paginationRoot = function(Root) {
|
113
113
|
return /*#__PURE__*/ forwardRef(function(_param, ref) {
|
114
|
-
var outerValue = _param.value, defaultValue = _param.defaultValue, outerPerPage = _param.perPage, defaultPerPage = _param.defaultPerPage, _param_slots = _param.slots, slots = _param_slots === void 0 ? defaultValues.slots : _param_slots, view = _param.view, viewCurrentPage = _param.viewCurrentPage, _param_type = _param.type, type = _param_type === void 0 ? defaultValues.type : _param_type, size = _param.size, _param_pilled = _param.pilled, pilled = _param_pilled === void 0 ? defaultValues.pilled : _param_pilled, _param_square = _param.square, square = _param_square === void 0 ? defaultValues.square : _param_square, _param_disabledPages = _param.disabledPages, disabledPages = _param_disabledPages === void 0 ? defaultValues.disabledPages : _param_disabledPages, _param_count = _param.count, count = _param_count === void 0 ? defaultValues.value : _param_count, _param_hasQuickJump = _param.hasQuickJump, hasQuickJump = _param_hasQuickJump === void 0 ? defaultValues.hasQuickJump : _param_hasQuickJump, _param_hasPerPage = _param.hasPerPage, hasPerPage = _param_hasPerPage === void 0 ? defaultValues.hasPerPage : _param_hasPerPage, _param_perPageList = _param.perPageList, perPageList = _param_perPageList === void 0 ? defaultValues.perPageList : _param_perPageList, _param_isCommonButtonStyles = _param.isCommonButtonStyles, isCommonButtonStyles = _param_isCommonButtonStyles === void 0 ? defaultValues.isCommonButtonStyles : _param_isCommonButtonStyles, _param_placeholderQuickJump = _param.placeholderQuickJump, placeholderQuickJump = _param_placeholderQuickJump === void 0 ? defaultValues.placeholderQuickJump : _param_placeholderQuickJump, _param_textQuickJump = _param.textQuickJump, textQuickJump = _param_textQuickJump === void 0 ? defaultValues.textQuickJump : _param_textQuickJump, _param_textPerPage = _param.textPerPage, textPerPage = _param_textPerPage === void 0 ? defaultValues.textPerPage : _param_textPerPage, leftContent = _param.leftContent, rightContent = _param.rightContent,
|
114
|
+
var outerValue = _param.value, defaultValue = _param.defaultValue, outerPerPage = _param.perPage, defaultPerPage = _param.defaultPerPage, _param_slots = _param.slots, slots = _param_slots === void 0 ? defaultValues.slots : _param_slots, view = _param.view, viewCurrentPage = _param.viewCurrentPage, _param_type = _param.type, type = _param_type === void 0 ? defaultValues.type : _param_type, size = _param.size, _param_pilled = _param.pilled, pilled = _param_pilled === void 0 ? defaultValues.pilled : _param_pilled, _param_square = _param.square, square = _param_square === void 0 ? defaultValues.square : _param_square, _param_disabledPages = _param.disabledPages, disabledPages = _param_disabledPages === void 0 ? defaultValues.disabledPages : _param_disabledPages, _param_count = _param.count, count = _param_count === void 0 ? defaultValues.value : _param_count, _param_hasQuickJump = _param.hasQuickJump, hasQuickJump = _param_hasQuickJump === void 0 ? defaultValues.hasQuickJump : _param_hasQuickJump, _param_hasPerPage = _param.hasPerPage, hasPerPage = _param_hasPerPage === void 0 ? defaultValues.hasPerPage : _param_hasPerPage, _param_perPageList = _param.perPageList, perPageList = _param_perPageList === void 0 ? defaultValues.perPageList : _param_perPageList, _param_isCommonButtonStyles = _param.isCommonButtonStyles, isCommonButtonStyles = _param_isCommonButtonStyles === void 0 ? defaultValues.isCommonButtonStyles : _param_isCommonButtonStyles, _param_placeholderQuickJump = _param.placeholderQuickJump, placeholderQuickJump = _param_placeholderQuickJump === void 0 ? defaultValues.placeholderQuickJump : _param_placeholderQuickJump, _param_textQuickJump = _param.textQuickJump, textQuickJump = _param_textQuickJump === void 0 ? defaultValues.textQuickJump : _param_textQuickJump, _param_textPerPage = _param.textPerPage, textPerPage = _param_textPerPage === void 0 ? defaultValues.textPerPage : _param_textPerPage, leftContent = _param.leftContent, rightContent = _param.rightContent, _param_listWidth = _param.listWidth, listWidth = _param_listWidth === void 0 ? 'fit-content' : _param_listWidth, onChangePageValue = _param.onChangePageValue, onChangePerPageValue = _param.onChangePerPageValue, onChange = _param.onChange, rest = _object_without_properties(_param, [
|
115
115
|
"value",
|
116
116
|
"defaultValue",
|
117
117
|
"perPage",
|
@@ -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,KAAyE,MAAM,OAAO,CAAC;AAG9F,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAM7C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAkBxD,eAAO,MAAM,aAAa,SAAU,SAAS,CAAC,cAAc,EAAE,cAAc,CAAC;;;;;;;;;;;;;;;;;;;sLAsUxE,CAAC;AAEN,eAAO,MAAM,eAAe;;;mBAxUQ,SAAS,CAAC,cAAc,EAAE,cAAc,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiW5E,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"CodeField.styles.d.ts","sourceRoot":"","sources":["../../../src/components/CodeField/CodeField.styles.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,IAAI,0CAUhB,CAAC;AAEF,eAAO,MAAM,WAAW,qKAGvB,CAAC;AAEF,eAAO,MAAM,SAAS,qKAGrB,CAAC;AAEF,eAAO,MAAM,SAAS,qKAErB,CAAC;AAEF,eAAO,MAAM,SAAS,8KAQrB,CAAC;AAEF,eAAO,MAAM,cAAc;kBAA8B,MAAM,GAAG,QAAQ;iBAAe,MAAM;EAK9F,CAAC;AAEF,eAAO,MAAM,WAAW,
|
1
|
+
{"version":3,"file":"CodeField.styles.d.ts","sourceRoot":"","sources":["../../../src/components/CodeField/CodeField.styles.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,IAAI,0CAUhB,CAAC;AAEF,eAAO,MAAM,WAAW,qKAGvB,CAAC;AAEF,eAAO,MAAM,SAAS,qKAGrB,CAAC;AAEF,eAAO,MAAM,SAAS,qKAErB,CAAC;AAEF,eAAO,MAAM,SAAS,8KAQrB,CAAC;AAEF,eAAO,MAAM,cAAc;kBAA8B,MAAM,GAAG,QAAQ;iBAAe,MAAM;EAK9F,CAAC;AAEF,eAAO,MAAM,WAAW,8KAAiB,CAAC"}
|
@@ -2,35 +2,110 @@ import type { CSSProperties, HTMLAttributes, ReactNode } from 'react';
|
|
2
2
|
import type { AsProps, NumericRange, CreateArrayWithLengthX } from '../../types';
|
3
3
|
export type PaginationTypes = 'compact' | 'default';
|
4
4
|
export type CustomPaginationProps = {
|
5
|
+
/**
|
6
|
+
* Вид
|
7
|
+
*/
|
5
8
|
view?: string;
|
9
|
+
/**
|
10
|
+
* Вид выбранной кнопки
|
11
|
+
*/
|
6
12
|
viewCurrentPage?: string;
|
13
|
+
/**
|
14
|
+
* Левый контент
|
15
|
+
*/
|
7
16
|
leftContent?: ReactNode;
|
17
|
+
/**
|
18
|
+
* Правый контент
|
19
|
+
*/
|
8
20
|
rightContent?: ReactNode;
|
21
|
+
/**
|
22
|
+
* Тип обычный или компактный
|
23
|
+
*/
|
9
24
|
type?: PaginationTypes;
|
25
|
+
/**
|
26
|
+
* Размер
|
27
|
+
*/
|
10
28
|
size?: string;
|
29
|
+
/**
|
30
|
+
* Количество страниц
|
31
|
+
*/
|
11
32
|
count?: number;
|
33
|
+
/**
|
34
|
+
* Выбранная страница
|
35
|
+
*/
|
12
36
|
value?: number;
|
37
|
+
/**
|
38
|
+
* Выбранная страница по умолчанию
|
39
|
+
*/
|
13
40
|
defaultValue?: number;
|
41
|
+
/**
|
42
|
+
* Выбор страницы через Input
|
43
|
+
*/
|
14
44
|
hasQuickJump?: boolean;
|
45
|
+
/**
|
46
|
+
* Выбор количества результатов на странице
|
47
|
+
*/
|
15
48
|
hasPerPage?: boolean;
|
49
|
+
/**
|
50
|
+
* Выбранное количество результатов на странице
|
51
|
+
*/
|
16
52
|
perPage?: number;
|
53
|
+
/**
|
54
|
+
* Выбранное количество результатов на странице по умолчанию
|
55
|
+
*/
|
17
56
|
defaultPerPage?: number;
|
57
|
+
/**
|
58
|
+
* Список результатов на странице
|
59
|
+
*/
|
18
60
|
perPageList?: number[];
|
61
|
+
/**
|
62
|
+
* Заблокированные страницы
|
63
|
+
*/
|
19
64
|
disabledPages?: string[];
|
65
|
+
/**
|
66
|
+
* Количество PageButtons
|
67
|
+
*/
|
20
68
|
slots?: NumericRange<CreateArrayWithLengthX<7>, 15>;
|
69
|
+
/**
|
70
|
+
* Скругление кнопки
|
71
|
+
*/
|
21
72
|
pilled?: boolean;
|
73
|
+
/**
|
74
|
+
* Равная ширина и высота кнопки
|
75
|
+
*/
|
22
76
|
square?: boolean;
|
77
|
+
/**
|
78
|
+
* Авто изменение стиля кнопок в ButtonGroup
|
79
|
+
*/
|
23
80
|
isCommonButtonStyles?: boolean;
|
81
|
+
/**
|
82
|
+
* Placeholder TextField'a для быстрого прыжка на страницу
|
83
|
+
*/
|
24
84
|
placeholderQuickJump?: string;
|
85
|
+
/**
|
86
|
+
* Текст для быстрого прыжка на страницу
|
87
|
+
*/
|
25
88
|
textQuickJump?: string;
|
89
|
+
/**
|
90
|
+
* Текст для выбора кол-ва результатов на странице
|
91
|
+
*/
|
26
92
|
textPerPage?: string;
|
27
93
|
/**
|
28
94
|
* Значение css width для выпадающего списка.
|
29
95
|
* @example width="200px"
|
30
96
|
*/
|
31
97
|
listWidth?: CSSProperties['width'];
|
98
|
+
/**
|
99
|
+
* Функция которая исполняeтся при изменении `page`, `perPage`
|
100
|
+
*/
|
32
101
|
onChange?: (page?: number, perPage?: number) => void;
|
102
|
+
/**
|
103
|
+
* @deprecated - использовать onChange
|
104
|
+
*/
|
33
105
|
onChangePageValue?: (page?: number) => void;
|
106
|
+
/**
|
107
|
+
* @deprecated - использовать onChange
|
108
|
+
*/
|
34
109
|
onChangePerPageValue?: (perPage?: number) => void;
|
35
110
|
};
|
36
111
|
export interface PaginationProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onChange' | 'defaultValue'>, AsProps, CustomPaginationProps {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Pagination.types.d.ts","sourceRoot":"","sources":["../../../src/components/Pagination/Pagination.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEtE,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAKjF,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG,SAAS,CAAC;AAEpD,MAAM,MAAM,qBAAqB,GAAG;
|
1
|
+
{"version":3,"file":"Pagination.types.d.ts","sourceRoot":"","sources":["../../../src/components/Pagination/Pagination.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEtE,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAKjF,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG,SAAS,CAAC;AAEpD,MAAM,MAAM,qBAAqB,GAAG;IAChC;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB;;OAEG;IACH,WAAW,CAAC,EAAE,SAAS,CAAC;IAExB;;OAEG;IACH,YAAY,CAAC,EAAE,SAAS,CAAC;IAEzB;;OAEG;IACH,IAAI,CAAC,EAAE,eAAe,CAAC;IAEvB;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IAEvB;;OAEG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IAEvB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IAEzB;;OAEG;IACH,KAAK,CAAC,EAAE,YAAY,CAAC,sBAAsB,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAEpD;;OAEG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IAEjB;;OAEG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IAEjB;;OAEG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAE/B;;OAEG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAE9B;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;;OAGG;IACH,SAAS,CAAC,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC;IAEnC;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACrD;;OAEG;IACH,iBAAiB,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5C;;OAEG;IACH,oBAAoB,CAAC,EAAE,CAAC,OAAO,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;CACrD,CAAC;AAEF,MAAM,WAAW,eACb,SAAQ,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,UAAU,GAAG,cAAc,CAAC,EACrE,OAAO,EACP,qBAAqB;CAAG"}
|
@@ -1,107 +0,0 @@
|
|
1
|
-
'use strict';
|
2
|
-
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
4
|
-
|
5
|
-
var _rollupPluginBabelHelpers = require('../../../_virtual/_rollupPluginBabelHelpers.js');
|
6
|
-
var React = require('react');
|
7
|
-
var isWebOTPSupported = require('../utils/isWebOTPSupported.js');
|
8
|
-
var initialValuesHelper = require('../utils/initialValuesHelper.js');
|
9
|
-
|
10
|
-
// Type guard function to check if credential is OTPCredential
|
11
|
-
var isOTPCredential = function isOTPCredential(credential) {
|
12
|
-
return credential !== null && 'code' in credential;
|
13
|
-
};
|
14
|
-
var useWebOTP = function useWebOTP(_ref) {
|
15
|
-
var codeString = _ref.codeString,
|
16
|
-
enableSMSAutoRead = _ref.enableSMSAutoRead,
|
17
|
-
disabled = _ref.disabled,
|
18
|
-
codeLength = _ref.codeLength,
|
19
|
-
codeSetter = _ref.codeSetter,
|
20
|
-
onFullCodeEnter = _ref.onFullCodeEnter,
|
21
|
-
setOtpVal = _ref.setOtpVal;
|
22
|
-
var abortControllerRef = React.useRef(null);
|
23
|
-
var startWebOTPListener = React.useCallback(/*#__PURE__*/_rollupPluginBabelHelpers.asyncToGenerator(/*#__PURE__*/_rollupPluginBabelHelpers.regeneratorRuntime().mark(function _callee() {
|
24
|
-
var otp, otpCode, newCode;
|
25
|
-
return _rollupPluginBabelHelpers.regeneratorRuntime().wrap(function _callee$(_context) {
|
26
|
-
while (1) switch (_context.prev = _context.next) {
|
27
|
-
case 0:
|
28
|
-
if (!(!enableSMSAutoRead || disabled || !isWebOTPSupported.isWebOTPSupported())) {
|
29
|
-
_context.next = 2;
|
30
|
-
break;
|
31
|
-
}
|
32
|
-
return _context.abrupt("return");
|
33
|
-
case 2:
|
34
|
-
if (abortControllerRef.current) {
|
35
|
-
abortControllerRef.current.abort();
|
36
|
-
}
|
37
|
-
abortControllerRef.current = new AbortController();
|
38
|
-
_context.prev = 4;
|
39
|
-
_context.next = 7;
|
40
|
-
return navigator.credentials.get({
|
41
|
-
otp: {
|
42
|
-
transport: ['sms']
|
43
|
-
},
|
44
|
-
signal: abortControllerRef.current.signal
|
45
|
-
});
|
46
|
-
case 7:
|
47
|
-
otp = _context.sent;
|
48
|
-
console.log('otp received', otp);
|
49
|
-
setOtpVal(otp);
|
50
|
-
|
51
|
-
// Type guard to check if it's an OTP credential
|
52
|
-
if (otp && isOTPCredential(otp) && otp.code) {
|
53
|
-
otpCode = otp.code; // Validate the OTP code length matches our expected length
|
54
|
-
if (otpCode.length === codeLength) {
|
55
|
-
newCode = initialValuesHelper.getCodeValue(codeLength, otpCode);
|
56
|
-
codeSetter(newCode);
|
57
|
-
|
58
|
-
// Trigger full code enter callback
|
59
|
-
if (onFullCodeEnter) {
|
60
|
-
onFullCodeEnter(otpCode);
|
61
|
-
}
|
62
|
-
}
|
63
|
-
}
|
64
|
-
_context.next = 16;
|
65
|
-
break;
|
66
|
-
case 13:
|
67
|
-
_context.prev = 13;
|
68
|
-
_context.t0 = _context["catch"](4);
|
69
|
-
if (_context.t0 instanceof DOMException) {
|
70
|
-
if (_context.t0.name !== 'AbortError' && _context.t0.name !== 'NotAllowedError') {
|
71
|
-
console.warn('Web OTP API error:', _context.t0);
|
72
|
-
}
|
73
|
-
} else if (_context.t0 instanceof Error) {
|
74
|
-
console.warn('Web OTP API error:', _context.t0);
|
75
|
-
} else {
|
76
|
-
console.warn('Unknown Web OTP API error:', _context.t0);
|
77
|
-
}
|
78
|
-
case 16:
|
79
|
-
case "end":
|
80
|
-
return _context.stop();
|
81
|
-
}
|
82
|
-
}, _callee, null, [[4, 13]]);
|
83
|
-
})), [enableSMSAutoRead, disabled, codeLength, onFullCodeEnter]);
|
84
|
-
var stopWebOTPListener = React.useCallback(function () {
|
85
|
-
if (abortControllerRef.current) {
|
86
|
-
abortControllerRef.current.abort();
|
87
|
-
abortControllerRef.current = null;
|
88
|
-
}
|
89
|
-
}, []);
|
90
|
-
React.useEffect(function () {
|
91
|
-
if (isWebOTPSupported.isWebOTPSupported() && codeString === '' && enableSMSAutoRead && !disabled) {
|
92
|
-
startWebOTPListener();
|
93
|
-
} else {
|
94
|
-
stopWebOTPListener();
|
95
|
-
}
|
96
|
-
return function () {
|
97
|
-
stopWebOTPListener();
|
98
|
-
};
|
99
|
-
}, [codeString, enableSMSAutoRead, disabled, startWebOTPListener, stopWebOTPListener]);
|
100
|
-
return {
|
101
|
-
startWebOTPListener: startWebOTPListener,
|
102
|
-
stopWebOTPListener: stopWebOTPListener
|
103
|
-
};
|
104
|
-
};
|
105
|
-
|
106
|
-
exports.useWebOTP = useWebOTP;
|
107
|
-
//# sourceMappingURL=useWebOTP.js.map
|