@salutejs/plasma-new-hope 0.374.0-dev.0 → 0.374.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/css/cjs/components/CodeField/CodeField.css +1 -1
- package/dist/css/cjs/components/CodeField/CodeField.js +39 -15
- package/dist/css/cjs/components/CodeField/utils/handleCodeError.js +10 -2
- package/dist/css/cjs/components/CodeField/utils/handleItemError.js +7 -13
- package/dist/css/cjs/components/CodeField/variations/_view/base.js +1 -1
- package/dist/css/cjs/components/CodeField/variations/_view/{base_1irs5gi.css → base_1x8fxav.css} +1 -1
- package/dist/css/cjs/index.css +1 -1
- package/dist/css/es/components/CodeField/CodeField.css +1 -1
- package/dist/css/es/components/CodeField/CodeField.js +39 -15
- package/dist/css/es/components/CodeField/utils/handleCodeError.js +10 -2
- package/dist/css/es/components/CodeField/utils/handleItemError.js +7 -13
- package/dist/css/es/components/CodeField/variations/_view/base.js +1 -1
- package/dist/css/es/components/CodeField/variations/_view/{base_1irs5gi.css → base_1x8fxav.css} +1 -1
- package/dist/css/es/index.css +1 -1
- package/dist/emotion/cjs/components/CodeField/CodeField.js +35 -15
- package/dist/emotion/cjs/components/CodeField/utils/handleCodeError.js +8 -2
- package/dist/emotion/cjs/components/CodeField/utils/handleItemError.js +5 -9
- package/dist/emotion/cjs/components/CodeField/variations/_view/base.js +1 -1
- package/dist/emotion/es/components/CodeField/CodeField.js +35 -15
- package/dist/emotion/es/components/CodeField/utils/handleCodeError.js +8 -2
- package/dist/emotion/es/components/CodeField/utils/handleItemError.js +5 -9
- package/dist/emotion/es/components/CodeField/variations/_view/base.js +1 -1
- package/dist/styled-components/cjs/components/CodeField/CodeField.js +35 -15
- package/dist/styled-components/cjs/components/CodeField/utils/handleCodeError.js +8 -2
- package/dist/styled-components/cjs/components/CodeField/utils/handleItemError.js +5 -9
- package/dist/styled-components/cjs/components/CodeField/variations/_view/base.js +2 -2
- package/dist/styled-components/es/components/CodeField/CodeField.js +35 -15
- package/dist/styled-components/es/components/CodeField/utils/handleCodeError.js +8 -2
- package/dist/styled-components/es/components/CodeField/utils/handleItemError.js +5 -9
- package/dist/styled-components/es/components/CodeField/variations/_view/base.js +2 -2
- package/package.json +5 -5
- package/types/components/CodeField/CodeField.d.ts.map +1 -1
- package/types/components/CodeField/utils/handleCodeError.d.ts +3 -1
- package/types/components/CodeField/utils/handleCodeError.d.ts.map +1 -1
- package/types/components/CodeField/utils/handleItemError.d.ts +3 -2
- package/types/components/CodeField/utils/handleItemError.d.ts.map +1 -1
|
@@ -81,11 +81,13 @@ const codeFieldRoot = (Root)=>/*#__PURE__*/ (0, _react.forwardRef)(({ id, classN
|
|
|
81
81
|
const [innerOriginalValue, setInnerOriginalValue] = (0, _react.useState)(code.join(''));
|
|
82
82
|
const [activeIndex, setActiveIndex] = (0, _react.useState)(null);
|
|
83
83
|
const [selectedIndex, setSelectedIndex] = (0, _react.useState)(null);
|
|
84
|
-
const
|
|
84
|
+
const [animatedItemErrorIndex, setAnimatedItemErrorIndex] = (0, _react.useState)(null);
|
|
85
|
+
const [activeErrorAnimations, setActiveErrorAnimations] = (0, _react.useState)(0);
|
|
85
86
|
const nativeInputRef = (0, _react.useRef)(null);
|
|
86
87
|
const inputContainerRef = (0, _react.useRef)(null);
|
|
87
88
|
const captionRef = (0, _react.useRef)(null);
|
|
88
89
|
const onFullCodeEnterRef = (0, _react.useRef)(onFullCodeEnter);
|
|
90
|
+
const activeErrorAnimationsRef = (0, _react.useRef)(0);
|
|
89
91
|
const inputForkRef = (0, _hooks.useForkRef)(nativeInputRef, ref);
|
|
90
92
|
/**
|
|
91
93
|
* Храним актуальный пользовательский колбэк в ref, чтобы изменение ссылки на него
|
|
@@ -98,6 +100,15 @@ const codeFieldRoot = (Root)=>/*#__PURE__*/ (0, _react.forwardRef)(({ id, classN
|
|
|
98
100
|
const parts = codeLength === 6 ? 2 : 1;
|
|
99
101
|
const codeValue = code.join('');
|
|
100
102
|
const widthValue = width ? (0, _utils.getSizeValueFromProp)(width, 'rem') : undefined;
|
|
103
|
+
const isErrorAnimationPlaying = activeErrorAnimations > 0;
|
|
104
|
+
const startErrorAnimation = ()=>{
|
|
105
|
+
activeErrorAnimationsRef.current += 1;
|
|
106
|
+
setActiveErrorAnimations(activeErrorAnimationsRef.current);
|
|
107
|
+
};
|
|
108
|
+
const finishErrorAnimation = ()=>{
|
|
109
|
+
activeErrorAnimationsRef.current = Math.max(0, activeErrorAnimationsRef.current - 1);
|
|
110
|
+
setActiveErrorAnimations(activeErrorAnimationsRef.current);
|
|
111
|
+
};
|
|
101
112
|
const codeSetter = (newCode)=>{
|
|
102
113
|
const originalCode = newCode.join('').slice(0, codeLength);
|
|
103
114
|
setInnerValue((0, _utils1.getCodeValue)(codeLength, originalCode));
|
|
@@ -121,9 +132,6 @@ const codeFieldRoot = (Root)=>/*#__PURE__*/ (0, _react.forwardRef)(({ id, classN
|
|
|
121
132
|
const controlledOriginalValue = codeValue.split('').every(isSymbolAllowed) ? codeValue : '';
|
|
122
133
|
const originalValue = typeof outerValue === 'string' ? controlledOriginalValue : innerOriginalValue;
|
|
123
134
|
const clearErrorState = ()=>{
|
|
124
|
-
itemRefs.current.forEach((item)=>{
|
|
125
|
-
item?.classList.remove(_CodeFieldtokens.classes.itemError, _CodeFieldtokens.classes.itemErrorFade, _CodeFieldtokens.classes.itemErrorAnimation);
|
|
126
|
-
});
|
|
127
135
|
if (!isError) {
|
|
128
136
|
return;
|
|
129
137
|
}
|
|
@@ -166,7 +174,7 @@ const codeFieldRoot = (Root)=>/*#__PURE__*/ (0, _react.forwardRef)(({ id, classN
|
|
|
166
174
|
selectLastActiveItem();
|
|
167
175
|
};
|
|
168
176
|
const handleChange = (event)=>{
|
|
169
|
-
if (disabled) {
|
|
177
|
+
if (disabled || activeErrorAnimationsRef.current > 0) {
|
|
170
178
|
return;
|
|
171
179
|
}
|
|
172
180
|
const rawValue = event.currentTarget.value.slice(0, codeLength);
|
|
@@ -184,17 +192,24 @@ const codeFieldRoot = (Root)=>/*#__PURE__*/ (0, _react.forwardRef)(({ id, classN
|
|
|
184
192
|
itemErrorBehavior,
|
|
185
193
|
index: invalidIndex,
|
|
186
194
|
newCode,
|
|
187
|
-
itemRefs,
|
|
188
195
|
inputRef: nativeInputRef,
|
|
189
196
|
setInnerValue,
|
|
190
197
|
setActiveIndex,
|
|
191
198
|
setSelectedIndex,
|
|
192
199
|
codeSetter,
|
|
193
|
-
onChange
|
|
200
|
+
onChange,
|
|
201
|
+
onAnimationStart: (index)=>{
|
|
202
|
+
startErrorAnimation();
|
|
203
|
+
setAnimatedItemErrorIndex(index);
|
|
204
|
+
},
|
|
205
|
+
onAnimationEnd: ()=>{
|
|
206
|
+
finishErrorAnimation();
|
|
207
|
+
setAnimatedItemErrorIndex(null);
|
|
208
|
+
}
|
|
194
209
|
});
|
|
195
210
|
};
|
|
196
211
|
const handleKeyDown = (event)=>{
|
|
197
|
-
if (!disabled && _constants.FORBIDDEN_KEYS.includes(event.key)) {
|
|
212
|
+
if (activeErrorAnimationsRef.current > 0 || !disabled && _constants.FORBIDDEN_KEYS.includes(event.key)) {
|
|
198
213
|
event.preventDefault();
|
|
199
214
|
}
|
|
200
215
|
if (onKeyDown) {
|
|
@@ -206,6 +221,9 @@ const codeFieldRoot = (Root)=>/*#__PURE__*/ (0, _react.forwardRef)(({ id, classN
|
|
|
206
221
|
return;
|
|
207
222
|
}
|
|
208
223
|
event.preventDefault();
|
|
224
|
+
if (activeErrorAnimationsRef.current > 0) {
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
209
227
|
const rawData = event.clipboardData.getData('text/plain');
|
|
210
228
|
const pastedData = rawData.split('').filter(isSymbolAllowed).slice(0, codeLength);
|
|
211
229
|
const selectionStart = event.currentTarget.selectionStart ?? 0;
|
|
@@ -222,9 +240,8 @@ const codeFieldRoot = (Root)=>/*#__PURE__*/ (0, _react.forwardRef)(({ id, classN
|
|
|
222
240
|
}, 0);
|
|
223
241
|
};
|
|
224
242
|
/**
|
|
225
|
-
* Нормализуем внутреннее
|
|
243
|
+
* Нормализуем внутреннее значение, если количество ячеек динамически изменилось.
|
|
226
244
|
*/ (0, _react.useEffect)(()=>{
|
|
227
|
-
itemRefs.current = itemRefs.current.slice(0, codeLength);
|
|
228
245
|
setInnerValue((currentCode)=>(0, _utils1.getCodeValue)(codeLength, currentCode.join('')));
|
|
229
246
|
setInnerOriginalValue((currentCode)=>currentCode.slice(0, codeLength));
|
|
230
247
|
}, [
|
|
@@ -267,7 +284,9 @@ const codeFieldRoot = (Root)=>/*#__PURE__*/ (0, _react.forwardRef)(({ id, classN
|
|
|
267
284
|
setInnerValue,
|
|
268
285
|
setActiveIndex,
|
|
269
286
|
setSelectedIndex,
|
|
270
|
-
codeSetter
|
|
287
|
+
codeSetter,
|
|
288
|
+
onAnimationStart: startErrorAnimation,
|
|
289
|
+
onAnimationEnd: finishErrorAnimation
|
|
271
290
|
});
|
|
272
291
|
}
|
|
273
292
|
}, [
|
|
@@ -299,15 +318,15 @@ const codeFieldRoot = (Root)=>/*#__PURE__*/ (0, _react.forwardRef)(({ id, classN
|
|
|
299
318
|
].map((_item, i)=>{
|
|
300
319
|
const inputCorrectIndex = i + codeLength / parts * partIndex;
|
|
301
320
|
const itemValue = code[inputCorrectIndex] || '';
|
|
321
|
+
const isAnimatedItemError = animatedItemErrorIndex === inputCorrectIndex;
|
|
302
322
|
return /*#__PURE__*/ _react.default.createElement(_CodeFieldstyles.ItemInput, {
|
|
303
323
|
key: inputCorrectIndex,
|
|
304
|
-
ref: (element)=>{
|
|
305
|
-
itemRefs.current[inputCorrectIndex] = element;
|
|
306
|
-
},
|
|
307
324
|
className: (0, _classnames.default)({
|
|
308
325
|
[_CodeFieldtokens.classes.segmented]: shape === 'segmented',
|
|
309
326
|
[_CodeFieldtokens.classes.itemFocused]: activeIndex === inputCorrectIndex,
|
|
310
|
-
[_CodeFieldtokens.classes.itemError]: itemErrorBehavior === 'keep' && Boolean(itemValue) && !isSymbolAllowed(itemValue),
|
|
327
|
+
[_CodeFieldtokens.classes.itemError]: isAnimatedItemError || itemErrorBehavior === 'keep' && Boolean(itemValue) && !isSymbolAllowed(itemValue),
|
|
328
|
+
[_CodeFieldtokens.classes.itemErrorAnimation]: isAnimatedItemError,
|
|
329
|
+
[_CodeFieldtokens.classes.itemErrorFade]: isAnimatedItemError && itemErrorBehavior === 'remove-symbol',
|
|
311
330
|
[_CodeFieldtokens.classes.hoverEnabled]: !disabled && inputCorrectIndex >= originalValue.length
|
|
312
331
|
}),
|
|
313
332
|
"data-code-field-item": ""
|
|
@@ -341,6 +360,7 @@ const codeFieldRoot = (Root)=>/*#__PURE__*/ (0, _react.forwardRef)(({ id, classN
|
|
|
341
360
|
form: form,
|
|
342
361
|
required: required,
|
|
343
362
|
disabled: disabled,
|
|
363
|
+
readOnly: isErrorAnimationPlaying,
|
|
344
364
|
"aria-label": ariaLabel,
|
|
345
365
|
"aria-describedby": ariaDescribedBy,
|
|
346
366
|
"aria-labelledby": ariaLabelledBy,
|
|
@@ -11,7 +11,7 @@ Object.defineProperty(exports, "handleCodeError", {
|
|
|
11
11
|
const _CodeFieldtokens = require("../CodeField.tokens");
|
|
12
12
|
const _constants = require("./constants");
|
|
13
13
|
const _initialValuesHelper = require("./initialValuesHelper");
|
|
14
|
-
const handleCodeError = ({ codeLength, codeErrorBehavior, currentCode, inputRef, inputContainerRef, captionRef, setInnerValue, setActiveIndex, setSelectedIndex, codeSetter })=>{
|
|
14
|
+
const handleCodeError = ({ codeLength, codeErrorBehavior, currentCode, inputRef, inputContainerRef, captionRef, setInnerValue, setActiveIndex, setSelectedIndex, codeSetter, onAnimationStart, onAnimationEnd })=>{
|
|
15
15
|
if (!inputContainerRef.current) {
|
|
16
16
|
return;
|
|
17
17
|
}
|
|
@@ -27,6 +27,7 @@ const handleCodeError = ({ codeLength, codeErrorBehavior, currentCode, inputRef,
|
|
|
27
27
|
};
|
|
28
28
|
switch(codeErrorBehavior){
|
|
29
29
|
case 'keep':
|
|
30
|
+
onAnimationStart();
|
|
30
31
|
inputContainerRef.current.classList.add(_CodeFieldtokens.classes.codeError, _CodeFieldtokens.classes.codeErrorAnimation);
|
|
31
32
|
captionRef.current?.classList.add(_CodeFieldtokens.classes.captionError);
|
|
32
33
|
setTimeout(()=>{
|
|
@@ -37,6 +38,7 @@ const handleCodeError = ({ codeLength, codeErrorBehavior, currentCode, inputRef,
|
|
|
37
38
|
codeSetter(newCode);
|
|
38
39
|
setInnerValue(currentCode);
|
|
39
40
|
inputContainerRef.current?.classList.remove(_CodeFieldtokens.classes.codeErrorAnimation);
|
|
41
|
+
onAnimationEnd();
|
|
40
42
|
setTimeout(()=>{
|
|
41
43
|
selectItem(codeLength - 1, codeLength);
|
|
42
44
|
}, 0);
|
|
@@ -44,12 +46,16 @@ const handleCodeError = ({ codeLength, codeErrorBehavior, currentCode, inputRef,
|
|
|
44
46
|
break;
|
|
45
47
|
case 'remove-code':
|
|
46
48
|
default:
|
|
49
|
+
onAnimationStart();
|
|
47
50
|
inputContainerRef.current.classList.add(_CodeFieldtokens.classes.codeError, _CodeFieldtokens.classes.codeErrorAnimation, _CodeFieldtokens.classes.codeErrorFade);
|
|
48
51
|
captionRef.current?.classList.add(_CodeFieldtokens.classes.captionError);
|
|
49
52
|
setTimeout(()=>{
|
|
50
53
|
codeSetter((0, _initialValuesHelper.getCodeValue)(codeLength, ''));
|
|
51
|
-
selectItem(0, 0);
|
|
52
54
|
inputContainerRef.current?.classList.remove(_CodeFieldtokens.classes.codeError, _CodeFieldtokens.classes.codeErrorAnimation, _CodeFieldtokens.classes.codeErrorFade);
|
|
55
|
+
onAnimationEnd();
|
|
56
|
+
setTimeout(()=>{
|
|
57
|
+
selectItem(0, 0);
|
|
58
|
+
}, 0);
|
|
53
59
|
}, _constants.ANIMATION_TIMEOUT);
|
|
54
60
|
}
|
|
55
61
|
};
|
|
@@ -8,12 +8,8 @@ Object.defineProperty(exports, "handleItemError", {
|
|
|
8
8
|
return handleItemError;
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
|
-
const _CodeFieldtokens = require("../CodeField.tokens");
|
|
12
11
|
const _constants = require("./constants");
|
|
13
|
-
const handleItemError = ({ itemErrorBehavior, index, newCode,
|
|
14
|
-
if (!itemRefs.current[index]) {
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
12
|
+
const handleItemError = ({ itemErrorBehavior, index, newCode, inputRef, setInnerValue, setActiveIndex, setSelectedIndex, codeSetter, onChange, onAnimationStart, onAnimationEnd })=>{
|
|
17
13
|
const selectItem = (selectionEnd)=>{
|
|
18
14
|
const input = inputRef.current;
|
|
19
15
|
if (!input) {
|
|
@@ -26,13 +22,13 @@ const handleItemError = ({ itemErrorBehavior, index, newCode, itemRefs, inputRef
|
|
|
26
22
|
};
|
|
27
23
|
switch(itemErrorBehavior){
|
|
28
24
|
case 'keep':
|
|
25
|
+
onAnimationStart(index);
|
|
29
26
|
setInnerValue(newCode);
|
|
30
27
|
if (onChange) {
|
|
31
28
|
onChange(newCode.join(''));
|
|
32
29
|
}
|
|
33
|
-
itemRefs.current[index]?.classList.add(_CodeFieldtokens.classes.itemError, _CodeFieldtokens.classes.itemErrorAnimation);
|
|
34
30
|
setTimeout(()=>{
|
|
35
|
-
|
|
31
|
+
onAnimationEnd();
|
|
36
32
|
setTimeout(()=>selectItem(index + 1), 0);
|
|
37
33
|
}, _constants.ANIMATION_TIMEOUT);
|
|
38
34
|
break;
|
|
@@ -43,18 +39,18 @@ const handleItemError = ({ itemErrorBehavior, index, newCode, itemRefs, inputRef
|
|
|
43
39
|
break;
|
|
44
40
|
case 'remove-symbol':
|
|
45
41
|
default:
|
|
42
|
+
onAnimationStart(index);
|
|
46
43
|
setInnerValue(newCode);
|
|
47
44
|
if (onChange) {
|
|
48
45
|
onChange(newCode.join(''));
|
|
49
46
|
}
|
|
50
|
-
itemRefs.current[index]?.classList.add(_CodeFieldtokens.classes.itemError, _CodeFieldtokens.classes.itemErrorFade, _CodeFieldtokens.classes.itemErrorAnimation);
|
|
51
47
|
setTimeout(()=>{
|
|
52
48
|
const updatedCode = [
|
|
53
49
|
...newCode
|
|
54
50
|
];
|
|
55
51
|
updatedCode.splice(index, 1);
|
|
56
52
|
codeSetter(updatedCode);
|
|
57
|
-
|
|
53
|
+
onAnimationEnd();
|
|
58
54
|
setTimeout(()=>selectItem(index), 0);
|
|
59
55
|
}, _constants.ANIMATION_TIMEOUT);
|
|
60
56
|
}
|
|
@@ -54,6 +54,6 @@ const base = (0, _styledcomponents.css)([
|
|
|
54
54
|
`);box-shadow:inset 0 0 0 var(`,
|
|
55
55
|
`) var(`,
|
|
56
56
|
`);&.`,
|
|
57
|
-
`{animation:shakingError 0.3s forwards
|
|
57
|
+
`{animation:shakingError 0.3s forwards,fadeError 0.3s forwards;}}@keyframes shakingError{14%{transform:translateX(-0.125rem);}28%{transform:translateX(0.125rem);}42%{transform:translateX(-0.125rem);}57%{transform:translateX(0.125rem);}71%{transform:translateX(-0.125rem);}85%{transform:translateX(0.125rem);}100%{transform:translateX(-0.125rem);}}@keyframes fadeError{50%{color:var(`,
|
|
58
58
|
`);}100%{color:transparent;}}`
|
|
59
|
-
], _CodeFieldstyles.CaptionWrapper, _CodeFieldtokens.tokens.captionColor, _CodeFieldtokens.classes.captionError, _CodeFieldtokens.tokens.captionColorError, _CodeFieldstyles.ItemInput, _CodeFieldtokens.tokens.codeColor, _CodeFieldtokens.tokens.caretColor, _CodeFieldtokens.tokens.backgroundColor, _CodeFieldtokens.tokens.borderWidth, _CodeFieldtokens.tokens.borderColor, _CodeFieldstyles.ItemValue, _CodeFieldtokens.classes.itemSelected, _CodeFieldtokens.classes.hoverEnabled, _CodeFieldtokens.tokens.backgroundColorHover, _CodeFieldtokens.tokens.borderWidth, _CodeFieldtokens.tokens.borderColorHover, _CodeFieldtokens.classes.itemFocused, _CodeFieldtokens.classes.itemError, _CodeFieldtokens.tokens.backgroundColorFocus, _CodeFieldtokens.tokens.borderWidth, _CodeFieldtokens.tokens.borderColorFocus, _CodeFieldtokens.classes.codeErrorAnimation, _CodeFieldtokens.classes.codeError, _CodeFieldstyles.ItemInput, _CodeFieldtokens.tokens.codeColorError, _CodeFieldtokens.tokens.backgroundErrorColor, _CodeFieldtokens.tokens.borderWidth, _CodeFieldtokens.tokens.borderErrorColor, _CodeFieldstyles.ItemInput, _CodeFieldtokens.tokens.backgroundErrorColor, _CodeFieldtokens.tokens.borderWidth, _CodeFieldtokens.tokens.borderErrorColor, _CodeFieldtokens.classes.codeErrorFade, _CodeFieldstyles.ItemInput, _CodeFieldtokens.classes.itemErrorAnimation, _CodeFieldtokens.classes.itemError, _CodeFieldtokens.classes.itemError, _CodeFieldtokens.tokens.codeColorError, _CodeFieldtokens.tokens.backgroundErrorColor, _CodeFieldtokens.tokens.borderWidth, _CodeFieldtokens.tokens.borderErrorColor, _CodeFieldtokens.classes.
|
|
59
|
+
], _CodeFieldstyles.CaptionWrapper, _CodeFieldtokens.tokens.captionColor, _CodeFieldtokens.classes.captionError, _CodeFieldtokens.tokens.captionColorError, _CodeFieldstyles.ItemInput, _CodeFieldtokens.tokens.codeColor, _CodeFieldtokens.tokens.caretColor, _CodeFieldtokens.tokens.backgroundColor, _CodeFieldtokens.tokens.borderWidth, _CodeFieldtokens.tokens.borderColor, _CodeFieldstyles.ItemValue, _CodeFieldtokens.classes.itemSelected, _CodeFieldtokens.classes.hoverEnabled, _CodeFieldtokens.tokens.backgroundColorHover, _CodeFieldtokens.tokens.borderWidth, _CodeFieldtokens.tokens.borderColorHover, _CodeFieldtokens.classes.itemFocused, _CodeFieldtokens.classes.itemError, _CodeFieldtokens.tokens.backgroundColorFocus, _CodeFieldtokens.tokens.borderWidth, _CodeFieldtokens.tokens.borderColorFocus, _CodeFieldtokens.classes.codeErrorAnimation, _CodeFieldtokens.classes.codeError, _CodeFieldstyles.ItemInput, _CodeFieldtokens.tokens.codeColorError, _CodeFieldtokens.tokens.backgroundErrorColor, _CodeFieldtokens.tokens.borderWidth, _CodeFieldtokens.tokens.borderErrorColor, _CodeFieldstyles.ItemInput, _CodeFieldtokens.tokens.backgroundErrorColor, _CodeFieldtokens.tokens.borderWidth, _CodeFieldtokens.tokens.borderErrorColor, _CodeFieldtokens.classes.codeErrorFade, _CodeFieldstyles.ItemInput, _CodeFieldtokens.classes.itemErrorAnimation, _CodeFieldtokens.classes.itemError, _CodeFieldtokens.classes.itemError, _CodeFieldtokens.tokens.codeColorError, _CodeFieldtokens.tokens.backgroundErrorColor, _CodeFieldtokens.tokens.borderWidth, _CodeFieldtokens.tokens.borderErrorColor, _CodeFieldtokens.classes.itemErrorFade, _CodeFieldtokens.tokens.codeColorError);
|
|
@@ -17,11 +17,13 @@ export const codeFieldRoot = (Root)=>/*#__PURE__*/ forwardRef(({ id, className,
|
|
|
17
17
|
const [innerOriginalValue, setInnerOriginalValue] = useState(code.join(''));
|
|
18
18
|
const [activeIndex, setActiveIndex] = useState(null);
|
|
19
19
|
const [selectedIndex, setSelectedIndex] = useState(null);
|
|
20
|
-
const
|
|
20
|
+
const [animatedItemErrorIndex, setAnimatedItemErrorIndex] = useState(null);
|
|
21
|
+
const [activeErrorAnimations, setActiveErrorAnimations] = useState(0);
|
|
21
22
|
const nativeInputRef = useRef(null);
|
|
22
23
|
const inputContainerRef = useRef(null);
|
|
23
24
|
const captionRef = useRef(null);
|
|
24
25
|
const onFullCodeEnterRef = useRef(onFullCodeEnter);
|
|
26
|
+
const activeErrorAnimationsRef = useRef(0);
|
|
25
27
|
const inputForkRef = useForkRef(nativeInputRef, ref);
|
|
26
28
|
/**
|
|
27
29
|
* Храним актуальный пользовательский колбэк в ref, чтобы изменение ссылки на него
|
|
@@ -34,6 +36,15 @@ export const codeFieldRoot = (Root)=>/*#__PURE__*/ forwardRef(({ id, className,
|
|
|
34
36
|
const parts = codeLength === 6 ? 2 : 1;
|
|
35
37
|
const codeValue = code.join('');
|
|
36
38
|
const widthValue = width ? getSizeValueFromProp(width, 'rem') : undefined;
|
|
39
|
+
const isErrorAnimationPlaying = activeErrorAnimations > 0;
|
|
40
|
+
const startErrorAnimation = ()=>{
|
|
41
|
+
activeErrorAnimationsRef.current += 1;
|
|
42
|
+
setActiveErrorAnimations(activeErrorAnimationsRef.current);
|
|
43
|
+
};
|
|
44
|
+
const finishErrorAnimation = ()=>{
|
|
45
|
+
activeErrorAnimationsRef.current = Math.max(0, activeErrorAnimationsRef.current - 1);
|
|
46
|
+
setActiveErrorAnimations(activeErrorAnimationsRef.current);
|
|
47
|
+
};
|
|
37
48
|
const codeSetter = (newCode)=>{
|
|
38
49
|
const originalCode = newCode.join('').slice(0, codeLength);
|
|
39
50
|
setInnerValue(getCodeValue(codeLength, originalCode));
|
|
@@ -57,9 +68,6 @@ export const codeFieldRoot = (Root)=>/*#__PURE__*/ forwardRef(({ id, className,
|
|
|
57
68
|
const controlledOriginalValue = codeValue.split('').every(isSymbolAllowed) ? codeValue : '';
|
|
58
69
|
const originalValue = typeof outerValue === 'string' ? controlledOriginalValue : innerOriginalValue;
|
|
59
70
|
const clearErrorState = ()=>{
|
|
60
|
-
itemRefs.current.forEach((item)=>{
|
|
61
|
-
item?.classList.remove(classes.itemError, classes.itemErrorFade, classes.itemErrorAnimation);
|
|
62
|
-
});
|
|
63
71
|
if (!isError) {
|
|
64
72
|
return;
|
|
65
73
|
}
|
|
@@ -102,7 +110,7 @@ export const codeFieldRoot = (Root)=>/*#__PURE__*/ forwardRef(({ id, className,
|
|
|
102
110
|
selectLastActiveItem();
|
|
103
111
|
};
|
|
104
112
|
const handleChange = (event)=>{
|
|
105
|
-
if (disabled) {
|
|
113
|
+
if (disabled || activeErrorAnimationsRef.current > 0) {
|
|
106
114
|
return;
|
|
107
115
|
}
|
|
108
116
|
const rawValue = event.currentTarget.value.slice(0, codeLength);
|
|
@@ -120,17 +128,24 @@ export const codeFieldRoot = (Root)=>/*#__PURE__*/ forwardRef(({ id, className,
|
|
|
120
128
|
itemErrorBehavior,
|
|
121
129
|
index: invalidIndex,
|
|
122
130
|
newCode,
|
|
123
|
-
itemRefs,
|
|
124
131
|
inputRef: nativeInputRef,
|
|
125
132
|
setInnerValue,
|
|
126
133
|
setActiveIndex,
|
|
127
134
|
setSelectedIndex,
|
|
128
135
|
codeSetter,
|
|
129
|
-
onChange
|
|
136
|
+
onChange,
|
|
137
|
+
onAnimationStart: (index)=>{
|
|
138
|
+
startErrorAnimation();
|
|
139
|
+
setAnimatedItemErrorIndex(index);
|
|
140
|
+
},
|
|
141
|
+
onAnimationEnd: ()=>{
|
|
142
|
+
finishErrorAnimation();
|
|
143
|
+
setAnimatedItemErrorIndex(null);
|
|
144
|
+
}
|
|
130
145
|
});
|
|
131
146
|
};
|
|
132
147
|
const handleKeyDown = (event)=>{
|
|
133
|
-
if (!disabled && FORBIDDEN_KEYS.includes(event.key)) {
|
|
148
|
+
if (activeErrorAnimationsRef.current > 0 || !disabled && FORBIDDEN_KEYS.includes(event.key)) {
|
|
134
149
|
event.preventDefault();
|
|
135
150
|
}
|
|
136
151
|
if (onKeyDown) {
|
|
@@ -142,6 +157,9 @@ export const codeFieldRoot = (Root)=>/*#__PURE__*/ forwardRef(({ id, className,
|
|
|
142
157
|
return;
|
|
143
158
|
}
|
|
144
159
|
event.preventDefault();
|
|
160
|
+
if (activeErrorAnimationsRef.current > 0) {
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
145
163
|
const rawData = event.clipboardData.getData('text/plain');
|
|
146
164
|
const pastedData = rawData.split('').filter(isSymbolAllowed).slice(0, codeLength);
|
|
147
165
|
const selectionStart = event.currentTarget.selectionStart ?? 0;
|
|
@@ -158,9 +176,8 @@ export const codeFieldRoot = (Root)=>/*#__PURE__*/ forwardRef(({ id, className,
|
|
|
158
176
|
}, 0);
|
|
159
177
|
};
|
|
160
178
|
/**
|
|
161
|
-
* Нормализуем внутреннее
|
|
179
|
+
* Нормализуем внутреннее значение, если количество ячеек динамически изменилось.
|
|
162
180
|
*/ useEffect(()=>{
|
|
163
|
-
itemRefs.current = itemRefs.current.slice(0, codeLength);
|
|
164
181
|
setInnerValue((currentCode)=>getCodeValue(codeLength, currentCode.join('')));
|
|
165
182
|
setInnerOriginalValue((currentCode)=>currentCode.slice(0, codeLength));
|
|
166
183
|
}, [
|
|
@@ -203,7 +220,9 @@ export const codeFieldRoot = (Root)=>/*#__PURE__*/ forwardRef(({ id, className,
|
|
|
203
220
|
setInnerValue,
|
|
204
221
|
setActiveIndex,
|
|
205
222
|
setSelectedIndex,
|
|
206
|
-
codeSetter
|
|
223
|
+
codeSetter,
|
|
224
|
+
onAnimationStart: startErrorAnimation,
|
|
225
|
+
onAnimationEnd: finishErrorAnimation
|
|
207
226
|
});
|
|
208
227
|
}
|
|
209
228
|
}, [
|
|
@@ -235,15 +254,15 @@ export const codeFieldRoot = (Root)=>/*#__PURE__*/ forwardRef(({ id, className,
|
|
|
235
254
|
].map((_item, i)=>{
|
|
236
255
|
const inputCorrectIndex = i + codeLength / parts * partIndex;
|
|
237
256
|
const itemValue = code[inputCorrectIndex] || '';
|
|
257
|
+
const isAnimatedItemError = animatedItemErrorIndex === inputCorrectIndex;
|
|
238
258
|
return /*#__PURE__*/ React.createElement(ItemInput, {
|
|
239
259
|
key: inputCorrectIndex,
|
|
240
|
-
ref: (element)=>{
|
|
241
|
-
itemRefs.current[inputCorrectIndex] = element;
|
|
242
|
-
},
|
|
243
260
|
className: cls({
|
|
244
261
|
[classes.segmented]: shape === 'segmented',
|
|
245
262
|
[classes.itemFocused]: activeIndex === inputCorrectIndex,
|
|
246
|
-
[classes.itemError]: itemErrorBehavior === 'keep' && Boolean(itemValue) && !isSymbolAllowed(itemValue),
|
|
263
|
+
[classes.itemError]: isAnimatedItemError || itemErrorBehavior === 'keep' && Boolean(itemValue) && !isSymbolAllowed(itemValue),
|
|
264
|
+
[classes.itemErrorAnimation]: isAnimatedItemError,
|
|
265
|
+
[classes.itemErrorFade]: isAnimatedItemError && itemErrorBehavior === 'remove-symbol',
|
|
247
266
|
[classes.hoverEnabled]: !disabled && inputCorrectIndex >= originalValue.length
|
|
248
267
|
}),
|
|
249
268
|
"data-code-field-item": ""
|
|
@@ -277,6 +296,7 @@ export const codeFieldRoot = (Root)=>/*#__PURE__*/ forwardRef(({ id, className,
|
|
|
277
296
|
form: form,
|
|
278
297
|
required: required,
|
|
279
298
|
disabled: disabled,
|
|
299
|
+
readOnly: isErrorAnimationPlaying,
|
|
280
300
|
"aria-label": ariaLabel,
|
|
281
301
|
"aria-describedby": ariaDescribedBy,
|
|
282
302
|
"aria-labelledby": ariaLabelledBy,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { classes } from "../CodeField.tokens";
|
|
2
2
|
import { ANIMATION_TIMEOUT } from "./constants";
|
|
3
3
|
import { getCodeValue } from "./initialValuesHelper";
|
|
4
|
-
export const handleCodeError = ({ codeLength, codeErrorBehavior, currentCode, inputRef, inputContainerRef, captionRef, setInnerValue, setActiveIndex, setSelectedIndex, codeSetter })=>{
|
|
4
|
+
export const handleCodeError = ({ codeLength, codeErrorBehavior, currentCode, inputRef, inputContainerRef, captionRef, setInnerValue, setActiveIndex, setSelectedIndex, codeSetter, onAnimationStart, onAnimationEnd })=>{
|
|
5
5
|
if (!inputContainerRef.current) {
|
|
6
6
|
return;
|
|
7
7
|
}
|
|
@@ -17,6 +17,7 @@ export const handleCodeError = ({ codeLength, codeErrorBehavior, currentCode, in
|
|
|
17
17
|
};
|
|
18
18
|
switch(codeErrorBehavior){
|
|
19
19
|
case 'keep':
|
|
20
|
+
onAnimationStart();
|
|
20
21
|
inputContainerRef.current.classList.add(classes.codeError, classes.codeErrorAnimation);
|
|
21
22
|
captionRef.current?.classList.add(classes.captionError);
|
|
22
23
|
setTimeout(()=>{
|
|
@@ -27,6 +28,7 @@ export const handleCodeError = ({ codeLength, codeErrorBehavior, currentCode, in
|
|
|
27
28
|
codeSetter(newCode);
|
|
28
29
|
setInnerValue(currentCode);
|
|
29
30
|
inputContainerRef.current?.classList.remove(classes.codeErrorAnimation);
|
|
31
|
+
onAnimationEnd();
|
|
30
32
|
setTimeout(()=>{
|
|
31
33
|
selectItem(codeLength - 1, codeLength);
|
|
32
34
|
}, 0);
|
|
@@ -34,12 +36,16 @@ export const handleCodeError = ({ codeLength, codeErrorBehavior, currentCode, in
|
|
|
34
36
|
break;
|
|
35
37
|
case 'remove-code':
|
|
36
38
|
default:
|
|
39
|
+
onAnimationStart();
|
|
37
40
|
inputContainerRef.current.classList.add(classes.codeError, classes.codeErrorAnimation, classes.codeErrorFade);
|
|
38
41
|
captionRef.current?.classList.add(classes.captionError);
|
|
39
42
|
setTimeout(()=>{
|
|
40
43
|
codeSetter(getCodeValue(codeLength, ''));
|
|
41
|
-
selectItem(0, 0);
|
|
42
44
|
inputContainerRef.current?.classList.remove(classes.codeError, classes.codeErrorAnimation, classes.codeErrorFade);
|
|
45
|
+
onAnimationEnd();
|
|
46
|
+
setTimeout(()=>{
|
|
47
|
+
selectItem(0, 0);
|
|
48
|
+
}, 0);
|
|
43
49
|
}, ANIMATION_TIMEOUT);
|
|
44
50
|
}
|
|
45
51
|
};
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
import { classes } from "../CodeField.tokens";
|
|
2
1
|
import { ANIMATION_TIMEOUT } from "./constants";
|
|
3
|
-
export const handleItemError = ({ itemErrorBehavior, index, newCode,
|
|
4
|
-
if (!itemRefs.current[index]) {
|
|
5
|
-
return;
|
|
6
|
-
}
|
|
2
|
+
export const handleItemError = ({ itemErrorBehavior, index, newCode, inputRef, setInnerValue, setActiveIndex, setSelectedIndex, codeSetter, onChange, onAnimationStart, onAnimationEnd })=>{
|
|
7
3
|
const selectItem = (selectionEnd)=>{
|
|
8
4
|
const input = inputRef.current;
|
|
9
5
|
if (!input) {
|
|
@@ -16,13 +12,13 @@ export const handleItemError = ({ itemErrorBehavior, index, newCode, itemRefs, i
|
|
|
16
12
|
};
|
|
17
13
|
switch(itemErrorBehavior){
|
|
18
14
|
case 'keep':
|
|
15
|
+
onAnimationStart(index);
|
|
19
16
|
setInnerValue(newCode);
|
|
20
17
|
if (onChange) {
|
|
21
18
|
onChange(newCode.join(''));
|
|
22
19
|
}
|
|
23
|
-
itemRefs.current[index]?.classList.add(classes.itemError, classes.itemErrorAnimation);
|
|
24
20
|
setTimeout(()=>{
|
|
25
|
-
|
|
21
|
+
onAnimationEnd();
|
|
26
22
|
setTimeout(()=>selectItem(index + 1), 0);
|
|
27
23
|
}, ANIMATION_TIMEOUT);
|
|
28
24
|
break;
|
|
@@ -33,18 +29,18 @@ export const handleItemError = ({ itemErrorBehavior, index, newCode, itemRefs, i
|
|
|
33
29
|
break;
|
|
34
30
|
case 'remove-symbol':
|
|
35
31
|
default:
|
|
32
|
+
onAnimationStart(index);
|
|
36
33
|
setInnerValue(newCode);
|
|
37
34
|
if (onChange) {
|
|
38
35
|
onChange(newCode.join(''));
|
|
39
36
|
}
|
|
40
|
-
itemRefs.current[index]?.classList.add(classes.itemError, classes.itemErrorFade, classes.itemErrorAnimation);
|
|
41
37
|
setTimeout(()=>{
|
|
42
38
|
const updatedCode = [
|
|
43
39
|
...newCode
|
|
44
40
|
];
|
|
45
41
|
updatedCode.splice(index, 1);
|
|
46
42
|
codeSetter(updatedCode);
|
|
47
|
-
|
|
43
|
+
onAnimationEnd();
|
|
48
44
|
setTimeout(()=>selectItem(index), 0);
|
|
49
45
|
}, ANIMATION_TIMEOUT);
|
|
50
46
|
}
|
|
@@ -44,6 +44,6 @@ export const base = css([
|
|
|
44
44
|
`);box-shadow:inset 0 0 0 var(`,
|
|
45
45
|
`) var(`,
|
|
46
46
|
`);&.`,
|
|
47
|
-
`{animation:shakingError 0.3s forwards
|
|
47
|
+
`{animation:shakingError 0.3s forwards,fadeError 0.3s forwards;}}@keyframes shakingError{14%{transform:translateX(-0.125rem);}28%{transform:translateX(0.125rem);}42%{transform:translateX(-0.125rem);}57%{transform:translateX(0.125rem);}71%{transform:translateX(-0.125rem);}85%{transform:translateX(0.125rem);}100%{transform:translateX(-0.125rem);}}@keyframes fadeError{50%{color:var(`,
|
|
48
48
|
`);}100%{color:transparent;}}`
|
|
49
|
-
], CaptionWrapper, tokens.captionColor, classes.captionError, tokens.captionColorError, ItemInput, tokens.codeColor, tokens.caretColor, tokens.backgroundColor, tokens.borderWidth, tokens.borderColor, ItemValue, classes.itemSelected, classes.hoverEnabled, tokens.backgroundColorHover, tokens.borderWidth, tokens.borderColorHover, classes.itemFocused, classes.itemError, tokens.backgroundColorFocus, tokens.borderWidth, tokens.borderColorFocus, classes.codeErrorAnimation, classes.codeError, ItemInput, tokens.codeColorError, tokens.backgroundErrorColor, tokens.borderWidth, tokens.borderErrorColor, ItemInput, tokens.backgroundErrorColor, tokens.borderWidth, tokens.borderErrorColor, classes.codeErrorFade, ItemInput, classes.itemErrorAnimation, classes.itemError, classes.itemError, tokens.codeColorError, tokens.backgroundErrorColor, tokens.borderWidth, tokens.borderErrorColor, classes.
|
|
49
|
+
], CaptionWrapper, tokens.captionColor, classes.captionError, tokens.captionColorError, ItemInput, tokens.codeColor, tokens.caretColor, tokens.backgroundColor, tokens.borderWidth, tokens.borderColor, ItemValue, classes.itemSelected, classes.hoverEnabled, tokens.backgroundColorHover, tokens.borderWidth, tokens.borderColorHover, classes.itemFocused, classes.itemError, tokens.backgroundColorFocus, tokens.borderWidth, tokens.borderColorFocus, classes.codeErrorAnimation, classes.codeError, ItemInput, tokens.codeColorError, tokens.backgroundErrorColor, tokens.borderWidth, tokens.borderErrorColor, ItemInput, tokens.backgroundErrorColor, tokens.borderWidth, tokens.borderErrorColor, classes.codeErrorFade, ItemInput, classes.itemErrorAnimation, classes.itemError, classes.itemError, tokens.codeColorError, tokens.backgroundErrorColor, tokens.borderWidth, tokens.borderErrorColor, classes.itemErrorFade, tokens.codeColorError);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salutejs/plasma-new-hope",
|
|
3
|
-
"version": "0.374.0
|
|
3
|
+
"version": "0.374.0",
|
|
4
4
|
"description": "Salute Design System blueprint",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -90,9 +90,9 @@
|
|
|
90
90
|
"@rollup/plugin-babel": "^6.0.4",
|
|
91
91
|
"@rollup/plugin-commonjs": "^25.0.4",
|
|
92
92
|
"@rollup/plugin-node-resolve": "^15.1.0",
|
|
93
|
-
"@salutejs/plasma-cy-utils": "0.167.0
|
|
94
|
-
"@salutejs/plasma-sb-utils": "0.238.0
|
|
95
|
-
"@salutejs/plasma-themes": "0.59.0
|
|
93
|
+
"@salutejs/plasma-cy-utils": "0.167.0",
|
|
94
|
+
"@salutejs/plasma-sb-utils": "0.238.0",
|
|
95
|
+
"@salutejs/plasma-themes": "0.59.0",
|
|
96
96
|
"@types/lodash": "^4.14.191",
|
|
97
97
|
"@types/lodash.chunk": "4.2.9",
|
|
98
98
|
"@types/lodash.throttle": "4.1.6",
|
|
@@ -145,5 +145,5 @@
|
|
|
145
145
|
"sideEffects": [
|
|
146
146
|
"*.css"
|
|
147
147
|
],
|
|
148
|
-
"gitHead": "
|
|
148
|
+
"gitHead": "7232ffe7284cf605a4c4d39f14dda710efcc33e2"
|
|
149
149
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CodeField.d.ts","sourceRoot":"","sources":["../../../src/components/CodeField/CodeField.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkF,MAAM,OAAO,CAAC;AAGvG,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAI7C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAsBxD,eAAO,MAAM,aAAa,SAAU,SAAS,CAAC,cAAc,EAAE,cAAc,CAAC;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"CodeField.d.ts","sourceRoot":"","sources":["../../../src/components/CodeField/CodeField.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkF,MAAM,OAAO,CAAC;AAGvG,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAI7C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAsBxD,eAAO,MAAM,aAAa,SAAU,SAAS,CAAC,cAAc,EAAE,cAAc,CAAC;;;;;;;;;;;;;;;;;;;;yIAyaxE,CAAC;AAEN,eAAO,MAAM,eAAe;;;mBA3aQ,SAAS,CAAC,cAAc,EAAE,cAAc,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoc5E,CAAC"}
|
|
@@ -11,7 +11,9 @@ type ValidateSymbolsArgs = {
|
|
|
11
11
|
setActiveIndex: Dispatch<SetStateAction<number | null>>;
|
|
12
12
|
setSelectedIndex: Dispatch<SetStateAction<number | null>>;
|
|
13
13
|
codeSetter: (newCode: Array<string>) => void;
|
|
14
|
+
onAnimationStart: () => void;
|
|
15
|
+
onAnimationEnd: () => void;
|
|
14
16
|
};
|
|
15
|
-
export declare const handleCodeError: ({ codeLength, codeErrorBehavior, currentCode, inputRef, inputContainerRef, captionRef, setInnerValue, setActiveIndex, setSelectedIndex, codeSetter, }: ValidateSymbolsArgs) => void;
|
|
17
|
+
export declare const handleCodeError: ({ codeLength, codeErrorBehavior, currentCode, inputRef, inputContainerRef, captionRef, setInnerValue, setActiveIndex, setSelectedIndex, codeSetter, onAnimationStart, onAnimationEnd, }: ValidateSymbolsArgs) => void;
|
|
16
18
|
export {};
|
|
17
19
|
//# sourceMappingURL=handleCodeError.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handleCodeError.d.ts","sourceRoot":"","sources":["../../../../src/components/CodeField/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;AAM5D,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,QAAQ,EAAE,gBAAgB,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAAC;IACpD,UAAU,EAAE,gBAAgB,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;IACpD,aAAa,EAAE,QAAQ,CAAC,cAAc,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IACvD,cAAc,EAAE,QAAQ,CAAC,cAAc,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC;IACxD,gBAAgB,EAAE,QAAQ,CAAC,cAAc,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC;IAC1D,UAAU,EAAE,CAAC,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"handleCodeError.d.ts","sourceRoot":"","sources":["../../../../src/components/CodeField/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;AAM5D,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,QAAQ,EAAE,gBAAgB,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAAC;IACpD,UAAU,EAAE,gBAAgB,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;IACpD,aAAa,EAAE,QAAQ,CAAC,cAAc,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IACvD,cAAc,EAAE,QAAQ,CAAC,cAAc,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC;IACxD,gBAAgB,EAAE,QAAQ,CAAC,cAAc,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC;IAC1D,UAAU,EAAE,CAAC,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,IAAI,CAAC;IAC7C,gBAAgB,EAAE,MAAM,IAAI,CAAC;IAC7B,cAAc,EAAE,MAAM,IAAI,CAAC;CAC9B,CAAC;AAEF,eAAO,MAAM,eAAe,4LAazB,mBAAmB,SAiErB,CAAC"}
|
|
@@ -4,14 +4,15 @@ type ValidateSymbolsArgs = {
|
|
|
4
4
|
itemErrorBehavior: ItemErrorBehavior;
|
|
5
5
|
index: number;
|
|
6
6
|
newCode: Array<string>;
|
|
7
|
-
itemRefs: MutableRefObject<Array<HTMLDivElement | null>>;
|
|
8
7
|
inputRef: MutableRefObject<HTMLInputElement | null>;
|
|
9
8
|
setInnerValue: Dispatch<SetStateAction<Array<string>>>;
|
|
10
9
|
setActiveIndex: Dispatch<SetStateAction<number | null>>;
|
|
11
10
|
setSelectedIndex: Dispatch<SetStateAction<number | null>>;
|
|
12
11
|
codeSetter: (newCode: Array<string>) => void;
|
|
13
12
|
onChange?: (value: string) => void;
|
|
13
|
+
onAnimationStart: (index: number) => void;
|
|
14
|
+
onAnimationEnd: () => void;
|
|
14
15
|
};
|
|
15
|
-
export declare const handleItemError: ({ itemErrorBehavior, index, newCode,
|
|
16
|
+
export declare const handleItemError: ({ itemErrorBehavior, index, newCode, inputRef, setInnerValue, setActiveIndex, setSelectedIndex, codeSetter, onChange, onAnimationStart, onAnimationEnd, }: ValidateSymbolsArgs) => void;
|
|
16
17
|
export {};
|
|
17
18
|
//# sourceMappingURL=handleItemError.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handleItemError.d.ts","sourceRoot":"","sources":["../../../../src/components/CodeField/utils/handleItemError.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":"handleItemError.d.ts","sourceRoot":"","sources":["../../../../src/components/CodeField/utils/handleItemError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAEnE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAI5D,KAAK,mBAAmB,GAAG;IACvB,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACvB,QAAQ,EAAE,gBAAgB,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAAC;IACpD,aAAa,EAAE,QAAQ,CAAC,cAAc,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IACvD,cAAc,EAAE,QAAQ,CAAC,cAAc,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC;IACxD,gBAAgB,EAAE,QAAQ,CAAC,cAAc,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC;IAC1D,UAAU,EAAE,CAAC,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,IAAI,CAAC;IAC7C,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,gBAAgB,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1C,cAAc,EAAE,MAAM,IAAI,CAAC;CAC9B,CAAC;AAEF,eAAO,MAAM,eAAe,8JAYzB,mBAAmB,SAmDrB,CAAC"}
|