@salutejs/plasma-new-hope 0.325.0 → 0.326.0-canary.1973.15343275842.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (177) hide show
  1. package/cjs/components/CodeInput/CodeInput.css +14 -0
  2. package/cjs/components/CodeInput/CodeInput.js +292 -0
  3. package/cjs/components/CodeInput/CodeInput.js.map +1 -0
  4. package/cjs/components/CodeInput/CodeInput.styles.js +78 -0
  5. package/cjs/components/CodeInput/CodeInput.styles.js.map +1 -0
  6. package/cjs/components/CodeInput/CodeInput.styles_29ush3.css +8 -0
  7. package/cjs/components/CodeInput/CodeInput.tokens.js +72 -0
  8. package/cjs/components/CodeInput/CodeInput.tokens.js.map +1 -0
  9. package/cjs/components/CodeInput/utils/constants.js +14 -0
  10. package/cjs/components/CodeInput/utils/constants.js.map +1 -0
  11. package/cjs/components/CodeInput/utils/handleCodeError.js +55 -0
  12. package/cjs/components/CodeInput/utils/handleCodeError.js.map +1 -0
  13. package/cjs/components/CodeInput/utils/handleItemError.js +53 -0
  14. package/cjs/components/CodeInput/utils/handleItemError.js.map +1 -0
  15. package/cjs/components/CodeInput/utils/initialValuesHelper.js +33 -0
  16. package/cjs/components/CodeInput/utils/initialValuesHelper.js.map +1 -0
  17. package/cjs/components/CodeInput/variations/_disabled/base.js +9 -0
  18. package/cjs/components/CodeInput/variations/_disabled/base.js.map +1 -0
  19. package/cjs/components/CodeInput/variations/_disabled/base_vkh53h.css +1 -0
  20. package/cjs/components/CodeInput/variations/_size/base.js +9 -0
  21. package/cjs/components/CodeInput/variations/_size/base.js.map +1 -0
  22. package/cjs/components/CodeInput/variations/_size/base_fhdb3l.css +1 -0
  23. package/cjs/components/CodeInput/variations/_view/base.js +9 -0
  24. package/cjs/components/CodeInput/variations/_view/base.js.map +1 -0
  25. package/cjs/components/CodeInput/variations/_view/base_lzwhmf.css +1 -0
  26. package/cjs/index.css +15 -0
  27. package/cjs/index.js +6 -0
  28. package/cjs/index.js.map +1 -1
  29. package/emotion/cjs/components/CodeInput/CodeInput.js +301 -0
  30. package/emotion/cjs/components/CodeInput/CodeInput.styles.js +76 -0
  31. package/emotion/cjs/components/CodeInput/CodeInput.tokens.js +70 -0
  32. package/emotion/cjs/components/CodeInput/CodeInput.types.js +5 -0
  33. package/emotion/cjs/components/CodeInput/index.js +31 -0
  34. package/emotion/cjs/components/CodeInput/utils/constants.js +12 -0
  35. package/emotion/cjs/components/CodeInput/utils/handleCodeError.js +58 -0
  36. package/emotion/cjs/components/CodeInput/utils/handleItemError.js +56 -0
  37. package/emotion/cjs/components/CodeInput/utils/index.js +38 -0
  38. package/emotion/cjs/components/CodeInput/utils/initialValuesHelper.js +30 -0
  39. package/emotion/cjs/components/CodeInput/variations/_disabled/base.js +9 -0
  40. package/emotion/cjs/components/CodeInput/variations/_disabled/tokens.json +4 -0
  41. package/emotion/cjs/components/CodeInput/variations/_size/base.js +10 -0
  42. package/emotion/cjs/components/CodeInput/variations/_size/tokens.json +19 -0
  43. package/emotion/cjs/components/CodeInput/variations/_view/base.js +10 -0
  44. package/emotion/cjs/components/CodeInput/variations/_view/tokens.json +1 -0
  45. package/emotion/cjs/examples/plasma_b2c/components/CodeInput/CodeInput.config.js +27 -0
  46. package/emotion/cjs/examples/plasma_b2c/components/CodeInput/CodeInput.js +11 -0
  47. package/emotion/cjs/examples/plasma_b2c/components/CodeInput/CodeInput.stories.tsx +107 -0
  48. package/emotion/cjs/examples/plasma_web/components/CodeInput/CodeInput.config.js +27 -0
  49. package/emotion/cjs/examples/plasma_web/components/CodeInput/CodeInput.js +11 -0
  50. package/emotion/cjs/examples/plasma_web/components/CodeInput/CodeInput.stories.tsx +107 -0
  51. package/emotion/cjs/index.js +11 -0
  52. package/emotion/es/components/CodeInput/CodeInput.js +292 -0
  53. package/emotion/es/components/CodeInput/CodeInput.styles.js +69 -0
  54. package/emotion/es/components/CodeInput/CodeInput.tokens.js +64 -0
  55. package/emotion/es/components/CodeInput/CodeInput.types.js +1 -0
  56. package/emotion/es/components/CodeInput/index.js +2 -0
  57. package/emotion/es/components/CodeInput/utils/constants.js +6 -0
  58. package/emotion/es/components/CodeInput/utils/handleCodeError.js +52 -0
  59. package/emotion/es/components/CodeInput/utils/handleItemError.js +50 -0
  60. package/emotion/es/components/CodeInput/utils/index.js +3 -0
  61. package/emotion/es/components/CodeInput/utils/initialValuesHelper.js +24 -0
  62. package/emotion/es/components/CodeInput/variations/_disabled/base.js +3 -0
  63. package/emotion/es/components/CodeInput/variations/_disabled/tokens.json +4 -0
  64. package/emotion/es/components/CodeInput/variations/_size/base.js +4 -0
  65. package/emotion/es/components/CodeInput/variations/_size/tokens.json +19 -0
  66. package/emotion/es/components/CodeInput/variations/_view/base.js +4 -0
  67. package/emotion/es/components/CodeInput/variations/_view/tokens.json +1 -0
  68. package/emotion/es/examples/plasma_b2c/components/CodeInput/CodeInput.config.js +21 -0
  69. package/emotion/es/examples/plasma_b2c/components/CodeInput/CodeInput.js +5 -0
  70. package/emotion/es/examples/plasma_b2c/components/CodeInput/CodeInput.stories.tsx +107 -0
  71. package/emotion/es/examples/plasma_web/components/CodeInput/CodeInput.config.js +21 -0
  72. package/emotion/es/examples/plasma_web/components/CodeInput/CodeInput.js +5 -0
  73. package/emotion/es/examples/plasma_web/components/CodeInput/CodeInput.stories.tsx +107 -0
  74. package/emotion/es/index.js +1 -0
  75. package/es/components/CodeInput/CodeInput.css +14 -0
  76. package/es/components/CodeInput/CodeInput.js +282 -0
  77. package/es/components/CodeInput/CodeInput.js.map +1 -0
  78. package/es/components/CodeInput/CodeInput.styles.js +67 -0
  79. package/es/components/CodeInput/CodeInput.styles.js.map +1 -0
  80. package/es/components/CodeInput/CodeInput.styles_29ush3.css +8 -0
  81. package/es/components/CodeInput/CodeInput.tokens.js +67 -0
  82. package/es/components/CodeInput/CodeInput.tokens.js.map +1 -0
  83. package/es/components/CodeInput/utils/constants.js +7 -0
  84. package/es/components/CodeInput/utils/constants.js.map +1 -0
  85. package/es/components/CodeInput/utils/handleCodeError.js +51 -0
  86. package/es/components/CodeInput/utils/handleCodeError.js.map +1 -0
  87. package/es/components/CodeInput/utils/handleItemError.js +49 -0
  88. package/es/components/CodeInput/utils/handleItemError.js.map +1 -0
  89. package/es/components/CodeInput/utils/initialValuesHelper.js +27 -0
  90. package/es/components/CodeInput/utils/initialValuesHelper.js.map +1 -0
  91. package/es/components/CodeInput/variations/_disabled/base.js +5 -0
  92. package/es/components/CodeInput/variations/_disabled/base.js.map +1 -0
  93. package/es/components/CodeInput/variations/_disabled/base_vkh53h.css +1 -0
  94. package/es/components/CodeInput/variations/_size/base.js +5 -0
  95. package/es/components/CodeInput/variations/_size/base.js.map +1 -0
  96. package/es/components/CodeInput/variations/_size/base_fhdb3l.css +1 -0
  97. package/es/components/CodeInput/variations/_view/base.js +5 -0
  98. package/es/components/CodeInput/variations/_view/base.js.map +1 -0
  99. package/es/components/CodeInput/variations/_view/base_lzwhmf.css +1 -0
  100. package/es/index.css +15 -0
  101. package/es/index.js +2 -0
  102. package/es/index.js.map +1 -1
  103. package/package.json +2 -2
  104. package/styled-components/cjs/components/CodeInput/CodeInput.js +301 -0
  105. package/styled-components/cjs/components/CodeInput/CodeInput.styles.js +47 -0
  106. package/styled-components/cjs/components/CodeInput/CodeInput.tokens.js +70 -0
  107. package/styled-components/cjs/components/CodeInput/CodeInput.types.js +5 -0
  108. package/styled-components/cjs/components/CodeInput/index.js +31 -0
  109. package/styled-components/cjs/components/CodeInput/utils/constants.js +12 -0
  110. package/styled-components/cjs/components/CodeInput/utils/handleCodeError.js +58 -0
  111. package/styled-components/cjs/components/CodeInput/utils/handleItemError.js +56 -0
  112. package/styled-components/cjs/components/CodeInput/utils/index.js +38 -0
  113. package/styled-components/cjs/components/CodeInput/utils/initialValuesHelper.js +30 -0
  114. package/styled-components/cjs/components/CodeInput/variations/_disabled/base.js +9 -0
  115. package/styled-components/cjs/components/CodeInput/variations/_disabled/tokens.json +4 -0
  116. package/styled-components/cjs/components/CodeInput/variations/_size/base.js +10 -0
  117. package/styled-components/cjs/components/CodeInput/variations/_size/tokens.json +19 -0
  118. package/styled-components/cjs/components/CodeInput/variations/_view/base.js +10 -0
  119. package/styled-components/cjs/components/CodeInput/variations/_view/tokens.json +1 -0
  120. package/styled-components/cjs/examples/plasma_b2c/components/CodeInput/CodeInput.config.js +27 -0
  121. package/styled-components/cjs/examples/plasma_b2c/components/CodeInput/CodeInput.js +11 -0
  122. package/styled-components/cjs/examples/plasma_b2c/components/CodeInput/CodeInput.stories.tsx +107 -0
  123. package/styled-components/cjs/examples/plasma_web/components/CodeInput/CodeInput.config.js +27 -0
  124. package/styled-components/cjs/examples/plasma_web/components/CodeInput/CodeInput.js +11 -0
  125. package/styled-components/cjs/examples/plasma_web/components/CodeInput/CodeInput.stories.tsx +107 -0
  126. package/styled-components/cjs/index.js +11 -0
  127. package/styled-components/es/components/CodeInput/CodeInput.js +292 -0
  128. package/styled-components/es/components/CodeInput/CodeInput.styles.js +39 -0
  129. package/styled-components/es/components/CodeInput/CodeInput.tokens.js +64 -0
  130. package/styled-components/es/components/CodeInput/CodeInput.types.js +1 -0
  131. package/styled-components/es/components/CodeInput/index.js +2 -0
  132. package/styled-components/es/components/CodeInput/utils/constants.js +6 -0
  133. package/styled-components/es/components/CodeInput/utils/handleCodeError.js +52 -0
  134. package/styled-components/es/components/CodeInput/utils/handleItemError.js +50 -0
  135. package/styled-components/es/components/CodeInput/utils/index.js +3 -0
  136. package/styled-components/es/components/CodeInput/utils/initialValuesHelper.js +24 -0
  137. package/styled-components/es/components/CodeInput/variations/_disabled/base.js +3 -0
  138. package/styled-components/es/components/CodeInput/variations/_disabled/tokens.json +4 -0
  139. package/styled-components/es/components/CodeInput/variations/_size/base.js +4 -0
  140. package/styled-components/es/components/CodeInput/variations/_size/tokens.json +19 -0
  141. package/styled-components/es/components/CodeInput/variations/_view/base.js +4 -0
  142. package/styled-components/es/components/CodeInput/variations/_view/tokens.json +1 -0
  143. package/styled-components/es/examples/plasma_b2c/components/CodeInput/CodeInput.config.js +21 -0
  144. package/styled-components/es/examples/plasma_b2c/components/CodeInput/CodeInput.js +5 -0
  145. package/styled-components/es/examples/plasma_b2c/components/CodeInput/CodeInput.stories.tsx +107 -0
  146. package/styled-components/es/examples/plasma_web/components/CodeInput/CodeInput.config.js +21 -0
  147. package/styled-components/es/examples/plasma_web/components/CodeInput/CodeInput.js +5 -0
  148. package/styled-components/es/examples/plasma_web/components/CodeInput/CodeInput.stories.tsx +107 -0
  149. package/styled-components/es/index.js +1 -0
  150. package/types/components/CodeInput/CodeInput.d.ts +67 -0
  151. package/types/components/CodeInput/CodeInput.d.ts.map +1 -0
  152. package/types/components/CodeInput/CodeInput.styles.d.ts +17 -0
  153. package/types/components/CodeInput/CodeInput.styles.d.ts.map +1 -0
  154. package/types/components/CodeInput/CodeInput.tokens.d.ts +65 -0
  155. package/types/components/CodeInput/CodeInput.tokens.d.ts.map +1 -0
  156. package/types/components/CodeInput/CodeInput.types.d.ts +96 -0
  157. package/types/components/CodeInput/CodeInput.types.d.ts.map +1 -0
  158. package/types/components/CodeInput/index.d.ts +3 -0
  159. package/types/components/CodeInput/index.d.ts.map +1 -0
  160. package/types/components/CodeInput/utils/constants.d.ts +7 -0
  161. package/types/components/CodeInput/utils/constants.d.ts.map +1 -0
  162. package/types/components/CodeInput/utils/handleCodeError.d.ts +15 -0
  163. package/types/components/CodeInput/utils/handleCodeError.d.ts.map +1 -0
  164. package/types/components/CodeInput/utils/handleItemError.d.ts +14 -0
  165. package/types/components/CodeInput/utils/handleItemError.d.ts.map +1 -0
  166. package/types/components/CodeInput/utils/index.d.ts +4 -0
  167. package/types/components/CodeInput/utils/index.d.ts.map +1 -0
  168. package/types/components/CodeInput/utils/initialValuesHelper.d.ts +4 -0
  169. package/types/components/CodeInput/utils/initialValuesHelper.d.ts.map +1 -0
  170. package/types/components/CodeInput/variations/_disabled/base.d.ts +2 -0
  171. package/types/components/CodeInput/variations/_disabled/base.d.ts.map +1 -0
  172. package/types/components/CodeInput/variations/_size/base.d.ts +2 -0
  173. package/types/components/CodeInput/variations/_size/base.d.ts.map +1 -0
  174. package/types/components/CodeInput/variations/_view/base.d.ts +2 -0
  175. package/types/components/CodeInput/variations/_view/base.d.ts.map +1 -0
  176. package/types/index.d.ts +1 -0
  177. package/types/index.d.ts.map +1 -1
@@ -0,0 +1,282 @@
1
+ import { objectWithoutProperties as _objectWithoutProperties, slicedToArray as _slicedToArray, extends as _extends, defineProperty as _defineProperty, toConsumableArray as _toConsumableArray } from '../../_virtual/_rollupPluginBabelHelpers.js';
2
+ import React, { forwardRef, useState, useRef, useCallback, useEffect, Fragment } from 'react';
3
+ import cls from 'classnames';
4
+ import { FORBIDDEN_KEYS, BACKSPACE_KEY, ONLY_DIGITS_PATTERN } from './utils/constants.js';
5
+ import { classes } from './CodeInput.tokens.js';
6
+ import { CodeWrapper, CodeGroup, ItemWrapper, ItemInput, ItemCircle, Separator, CaptionWrapper, base } from './CodeInput.styles.js';
7
+ import { base as base$1 } from './variations/_view/base.js';
8
+ import { base as base$2 } from './variations/_size/base.js';
9
+ import { base as base$3 } from './variations/_disabled/base.js';
10
+ import { getCodeValue, getPlaceholderValue, getFieldPattern } from './utils/initialValuesHelper.js';
11
+ import { useDidMountEffect } from '../../hooks/useDidMountEffect.js';
12
+ import { handleCodeError } from './utils/handleCodeError.js';
13
+ import { getSizeValueFromProp } from '../../utils/getSizeValueFromProp.js';
14
+ import { handleItemError } from './utils/handleItemError.js';
15
+
16
+ var _Separator;
17
+ var _excluded = ["className", "value", "placeholder", "autoFocus", "codeLength", "caption", "captionAlign", "width", "view", "size", "screen", "hidden", "disabled", "isError", "allowedSymbols", "itemErrorBehavior", "codeErrorBehavior", "autoComplete", "setIsError", "onChange", "onFullCodeEnter"];
18
+ var codeInputRoot = function codeInputRoot(Root) {
19
+ return /*#__PURE__*/forwardRef(function (_ref, ref) {
20
+ var className = _ref.className,
21
+ outerValue = _ref.value,
22
+ placeholder = _ref.placeholder,
23
+ autoFocus = _ref.autoFocus,
24
+ _ref$codeLength = _ref.codeLength,
25
+ codeLength = _ref$codeLength === void 0 ? 6 : _ref$codeLength,
26
+ caption = _ref.caption,
27
+ _ref$captionAlign = _ref.captionAlign,
28
+ captionAlign = _ref$captionAlign === void 0 ? 'left' : _ref$captionAlign,
29
+ width = _ref.width,
30
+ view = _ref.view,
31
+ size = _ref.size,
32
+ _ref$screen = _ref.screen,
33
+ screen = _ref$screen === void 0 ? 'medium' : _ref$screen,
34
+ hidden = _ref.hidden,
35
+ disabled = _ref.disabled,
36
+ isError = _ref.isError,
37
+ _ref$allowedSymbols = _ref.allowedSymbols,
38
+ allowedSymbols = _ref$allowedSymbols === void 0 ? ONLY_DIGITS_PATTERN : _ref$allowedSymbols,
39
+ _ref$itemErrorBehavio = _ref.itemErrorBehavior,
40
+ itemErrorBehavior = _ref$itemErrorBehavio === void 0 ? 'remove-symbol' : _ref$itemErrorBehavio,
41
+ _ref$codeErrorBehavio = _ref.codeErrorBehavior,
42
+ codeErrorBehavior = _ref$codeErrorBehavio === void 0 ? 'remove-code' : _ref$codeErrorBehavio,
43
+ _ref$autoComplete = _ref.autoComplete,
44
+ autoComplete = _ref$autoComplete === void 0 ? 'one-time-code' : _ref$autoComplete,
45
+ setIsError = _ref.setIsError,
46
+ onChange = _ref.onChange,
47
+ onFullCodeEnter = _ref.onFullCodeEnter,
48
+ rest = _objectWithoutProperties(_ref, _excluded);
49
+ var _useState = useState(getCodeValue(codeLength, outerValue || '')),
50
+ _useState2 = _slicedToArray(_useState, 2),
51
+ code = _useState2[0],
52
+ setCode = _useState2[1];
53
+ var _useState3 = useState(code.join('')),
54
+ _useState4 = _slicedToArray(_useState3, 2),
55
+ originalValue = _useState4[0],
56
+ setOriginalValue = _useState4[1];
57
+ var inputRefs = useRef([]);
58
+ var inputContainerRef = useRef(null);
59
+ var captionRef = useRef(null);
60
+ var fieldPattern = getFieldPattern(allowedSymbols);
61
+ var placeholderValue = getPlaceholderValue(codeLength, placeholder);
62
+ var parts = codeLength === 6 ? 2 : 1;
63
+ var screenClass = classes["".concat(screen, "Screen")];
64
+ var widthValue = width ? getSizeValueFromProp(width, 'rem') : undefined;
65
+ var getLastActiveIndex = function getLastActiveIndex() {
66
+ if (code.length && code.length < codeLength) {
67
+ return code.length;
68
+ }
69
+ var lastEmptyIndex = code.findIndex(function (digit) {
70
+ return digit === '';
71
+ });
72
+ return lastEmptyIndex >= 0 ? lastEmptyIndex : codeLength - 1;
73
+ };
74
+ var handleClick = function handleClick() {
75
+ if (disabled) {
76
+ return;
77
+ }
78
+ var lastActiveIndex = getLastActiveIndex();
79
+ if (inputRefs.current[lastActiveIndex]) {
80
+ inputRefs.current[lastActiveIndex].focus();
81
+ }
82
+ };
83
+ var handleOnKeyDown = function handleOnKeyDown(event, index) {
84
+ if (disabled) {
85
+ return;
86
+ }
87
+ var key = event.key;
88
+ if (FORBIDDEN_KEYS.includes(key)) {
89
+ event.preventDefault();
90
+ return;
91
+ }
92
+ if (key === BACKSPACE_KEY) {
93
+ if (index > 0 && code[index] === '') {
94
+ var _inputRefs$current;
95
+ (_inputRefs$current = inputRefs.current[index - 1]) === null || _inputRefs$current === void 0 || _inputRefs$current.focus();
96
+ }
97
+ }
98
+ };
99
+ var codeSetter = function codeSetter(newCode) {
100
+ setCode(newCode);
101
+ setOriginalValue(newCode.join(''));
102
+ if (onChange) {
103
+ onChange(newCode.join(''));
104
+ }
105
+ };
106
+ var handleChange = function handleChange(event, index) {
107
+ var _inputRefs$current$in;
108
+ if (disabled) {
109
+ return;
110
+ }
111
+ var rawSymbol = event.currentTarget.value;
112
+ var symbol = rawSymbol.charAt(rawSymbol.length - 1);
113
+ var newCode = _toConsumableArray(code);
114
+ (_inputRefs$current$in = inputRefs.current[index]) === null || _inputRefs$current$in === void 0 || _inputRefs$current$in.classList.remove(classes.itemError);
115
+ if (isError) {
116
+ var _captionRef$current;
117
+ (_captionRef$current = captionRef.current) === null || _captionRef$current === void 0 || _captionRef$current.classList.remove(classes.captionError);
118
+ if (codeErrorBehavior === 'keep') {
119
+ var _inputContainerRef$cu;
120
+ (_inputContainerRef$cu = inputContainerRef.current) === null || _inputContainerRef$cu === void 0 || _inputContainerRef$cu.classList.remove(classes.codeError, classes.codeErrorAnimation);
121
+ }
122
+ if (setIsError) {
123
+ setIsError(false);
124
+ }
125
+ }
126
+ if (!fieldPattern) {
127
+ newCode[index] = symbol;
128
+ codeSetter(newCode);
129
+ if (symbol && index < codeLength - 1) {
130
+ var _inputRefs$current2;
131
+ (_inputRefs$current2 = inputRefs.current[index + 1]) === null || _inputRefs$current2 === void 0 || _inputRefs$current2.focus();
132
+ }
133
+ return;
134
+ }
135
+ if (!symbol) {
136
+ newCode[index] = '';
137
+ codeSetter(newCode);
138
+ return;
139
+ }
140
+ if (fieldPattern.test(symbol)) {
141
+ newCode[index] = symbol.charAt(symbol.length - 1);
142
+ codeSetter(newCode);
143
+ if (index < codeLength - 1) {
144
+ var _inputRefs$current3;
145
+ (_inputRefs$current3 = inputRefs.current[index + 1]) === null || _inputRefs$current3 === void 0 || _inputRefs$current3.focus();
146
+ }
147
+ } else {
148
+ newCode[index] = symbol.charAt(symbol.length - 1);
149
+ handleItemError({
150
+ currentSymbol: symbol,
151
+ itemErrorBehavior: itemErrorBehavior,
152
+ index: index,
153
+ newCode: newCode,
154
+ inputRefs: inputRefs,
155
+ setCode: setCode,
156
+ codeSetter: codeSetter
157
+ });
158
+ }
159
+ };
160
+ var handlePaste = function handlePaste(event) {
161
+ var _inputRefs$current$ac;
162
+ if (disabled) {
163
+ return;
164
+ }
165
+ event.preventDefault();
166
+ var rawData = event.clipboardData.getData('text/plain');
167
+ var pastedData = (fieldPattern ? rawData.split('').map(function (symb) {
168
+ var _symb$match;
169
+ return ((_symb$match = symb.match(fieldPattern)) === null || _symb$match === void 0 ? void 0 : _symb$match[0]) || '';
170
+ }).filter(Boolean) || [] : rawData.split('')).slice(0, codeLength);
171
+ var activeIndex = Math.min(pastedData.length, codeLength - 1);
172
+ (_inputRefs$current$ac = inputRefs.current[activeIndex]) === null || _inputRefs$current$ac === void 0 || _inputRefs$current$ac.focus();
173
+ codeSetter(pastedData);
174
+ };
175
+ var handleFullCodeEnter = useCallback(function (fullCode) {
176
+ if (onFullCodeEnter) {
177
+ onFullCodeEnter(fullCode);
178
+ }
179
+ }, []);
180
+ useEffect(function () {
181
+ inputRefs.current = inputRefs.current.slice(0, codeLength);
182
+ }, [codeLength]);
183
+ useEffect(function () {
184
+ if (autoFocus && !disabled) {
185
+ var _inputRefs$current$la;
186
+ var lastActiveIndex = getLastActiveIndex();
187
+ (_inputRefs$current$la = inputRefs.current[lastActiveIndex]) === null || _inputRefs$current$la === void 0 || _inputRefs$current$la.focus();
188
+ }
189
+ }, [autoFocus]);
190
+ useDidMountEffect(function () {
191
+ if (handleFullCodeEnter && originalValue.length === codeLength) {
192
+ handleFullCodeEnter(originalValue);
193
+ }
194
+ }, [originalValue, handleFullCodeEnter]);
195
+ useDidMountEffect(function () {
196
+ if (isError) {
197
+ handleCodeError({
198
+ codeLength: codeLength,
199
+ codeErrorBehavior: codeErrorBehavior,
200
+ currentCode: code,
201
+ inputRefs: inputRefs,
202
+ inputContainerRef: inputContainerRef,
203
+ captionRef: captionRef,
204
+ setCode: setCode,
205
+ codeSetter: codeSetter
206
+ });
207
+ }
208
+ }, [isError]);
209
+ return /*#__PURE__*/React.createElement(Root, _extends({
210
+ ref: ref,
211
+ view: view,
212
+ size: size,
213
+ disabled: disabled,
214
+ screen: screen,
215
+ onClick: handleClick,
216
+ className: cls(className, _defineProperty({}, classes.captionAlignLeft, captionAlign === 'left'))
217
+ }, rest), /*#__PURE__*/React.createElement(CodeWrapper, {
218
+ ref: inputContainerRef
219
+ }, _toConsumableArray(Array(parts)).map(function (_, partIndex) {
220
+ return /*#__PURE__*/React.createElement(Fragment, {
221
+ key: partIndex
222
+ }, /*#__PURE__*/React.createElement(CodeGroup, {
223
+ role: "group"
224
+ }, _toConsumableArray(Array(codeLength / parts)).map(function (_, i) {
225
+ var inputCorrectIndex = i + codeLength / parts * partIndex;
226
+ return /*#__PURE__*/React.createElement(ItemWrapper, {
227
+ key: partIndex + i + partIndex * i,
228
+ className: screenClass
229
+ }, /*#__PURE__*/React.createElement(ItemInput, _extends({
230
+ ref: function ref(element) {
231
+ inputRefs.current[inputCorrectIndex] = element;
232
+ },
233
+ className: cls(_defineProperty({}, classes.hoverEnabled, inputCorrectIndex >= originalValue.length)),
234
+ hide: hidden,
235
+ value: code[inputCorrectIndex] || '',
236
+ autoComplete: autoComplete,
237
+ onChange: function onChange(e) {
238
+ handleChange(e, inputCorrectIndex);
239
+ },
240
+ onKeyDown: function onKeyDown(e) {
241
+ handleOnKeyDown(e, inputCorrectIndex);
242
+ },
243
+ onPaste: handlePaste,
244
+ tabIndex: originalValue.length === inputCorrectIndex ? 0 : -1
245
+ }, placeholderValue && {
246
+ placeholder: placeholderValue[inputCorrectIndex]
247
+ })), (!code[inputCorrectIndex] || !!code[inputCorrectIndex] && hidden) && /*#__PURE__*/React.createElement(ItemCircle, {
248
+ className: !!code[inputCorrectIndex] && hidden ? classes.itemCirlceFilled : ''
249
+ }));
250
+ })), partIndex !== parts - 1 && (_Separator || (_Separator = /*#__PURE__*/React.createElement(Separator, null))));
251
+ })), caption && /*#__PURE__*/React.createElement(CaptionWrapper, {
252
+ ref: captionRef,
253
+ captionAlign: captionAlign,
254
+ widthValue: widthValue
255
+ }, caption));
256
+ });
257
+ };
258
+ var codeInputConfig = {
259
+ name: 'CodeInput',
260
+ tag: 'div',
261
+ layout: codeInputRoot,
262
+ base: base,
263
+ variations: {
264
+ view: {
265
+ css: base$1
266
+ },
267
+ size: {
268
+ css: base$2
269
+ },
270
+ disabled: {
271
+ css: base$3,
272
+ attrs: true
273
+ }
274
+ },
275
+ defaults: {
276
+ size: 'm',
277
+ view: 'default'
278
+ }
279
+ };
280
+
281
+ export { codeInputConfig, codeInputRoot };
282
+ //# sourceMappingURL=CodeInput.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CodeInput.js","sources":["../../../src/components/CodeInput/CodeInput.tsx"],"sourcesContent":["import React, { forwardRef, Fragment, useCallback, useEffect, useRef, useState } from 'react';\nimport cls from 'classnames';\nimport type { ChangeEvent, KeyboardEvent, ClipboardEvent } from 'react';\nimport type { RootProps } from 'src/engines';\nimport { useDidMountEffect } from 'src/hooks';\nimport { getSizeValueFromProp } from 'src/utils';\n\nimport type { CodeInputProps } from './CodeInput.types';\nimport { BACKSPACE_KEY, FORBIDDEN_KEYS, ONLY_DIGITS_PATTERN } from './utils/constants';\nimport { getCodeValue, getFieldPattern, getPlaceholderValue, handleCodeError, handleItemError } from './utils';\nimport { classes } from './CodeInput.tokens';\nimport {\n base,\n CaptionWrapper,\n CodeGroup,\n CodeWrapper,\n ItemInput,\n Separator,\n ItemWrapper,\n ItemCircle,\n} from './CodeInput.styles';\nimport { base as viewCSS } from './variations/_view/base';\nimport { base as sizeCSS } from './variations/_size/base';\nimport { base as disabledCSS } from './variations/_disabled/base';\n\nexport const codeInputRoot = (Root: RootProps<HTMLDivElement, CodeInputProps>) =>\n forwardRef<HTMLInputElement, CodeInputProps>(\n (\n {\n className,\n value: outerValue,\n placeholder,\n autoFocus,\n codeLength = 6,\n caption,\n captionAlign = 'left',\n width,\n view,\n size,\n screen = 'medium',\n hidden,\n disabled,\n isError,\n allowedSymbols = ONLY_DIGITS_PATTERN,\n itemErrorBehavior = 'remove-symbol',\n codeErrorBehavior = 'remove-code',\n autoComplete = 'one-time-code',\n setIsError,\n onChange,\n onFullCodeEnter,\n ...rest\n },\n ref,\n ) => {\n const [code, setCode] = useState<Array<string>>(getCodeValue(codeLength, outerValue || ''));\n const [originalValue, setOriginalValue] = useState<string>(code.join(''));\n\n const inputRefs = useRef<Array<HTMLInputElement>>([]);\n const inputContainerRef = useRef<HTMLDivElement | null>(null);\n const captionRef = useRef<HTMLDivElement | null>(null);\n\n const fieldPattern = getFieldPattern(allowedSymbols);\n const placeholderValue = getPlaceholderValue(codeLength, placeholder);\n const parts = codeLength === 6 ? 2 : 1;\n\n const screenClass = classes[`${screen}Screen`];\n\n const widthValue = width ? getSizeValueFromProp(width, 'rem') : undefined;\n\n const getLastActiveIndex = () => {\n if (code.length && code.length < codeLength) {\n return code.length;\n }\n\n const lastEmptyIndex = code.findIndex((digit) => digit === '');\n return lastEmptyIndex >= 0 ? lastEmptyIndex : codeLength - 1;\n };\n\n const handleClick = () => {\n if (disabled) {\n return;\n }\n\n const lastActiveIndex = getLastActiveIndex();\n\n if (inputRefs.current[lastActiveIndex]) {\n inputRefs.current[lastActiveIndex].focus();\n }\n };\n\n const handleOnKeyDown = (event: KeyboardEvent<HTMLInputElement>, index: number) => {\n if (disabled) {\n return;\n }\n\n const { key } = event;\n if (FORBIDDEN_KEYS.includes(key)) {\n event.preventDefault();\n\n return;\n }\n\n if (key === BACKSPACE_KEY) {\n if (index > 0 && code[index] === '') {\n inputRefs.current[index - 1]?.focus();\n }\n }\n };\n\n const codeSetter = (newCode: Array<string>) => {\n setCode(newCode);\n setOriginalValue(newCode.join(''));\n\n if (onChange) {\n onChange(newCode.join(''));\n }\n };\n\n const handleChange = (event: ChangeEvent<HTMLInputElement>, index: number) => {\n if (disabled) {\n return;\n }\n\n const rawSymbol = event.currentTarget.value;\n const symbol = rawSymbol.charAt(rawSymbol.length - 1);\n const newCode = [...code];\n\n inputRefs.current[index]?.classList.remove(classes.itemError);\n if (isError) {\n captionRef.current?.classList.remove(classes.captionError);\n\n if (codeErrorBehavior === 'keep') {\n inputContainerRef.current?.classList.remove(classes.codeError, classes.codeErrorAnimation);\n }\n\n if (setIsError) {\n setIsError(false);\n }\n }\n\n if (!fieldPattern) {\n newCode[index] = symbol;\n codeSetter(newCode);\n\n if (symbol && index < codeLength - 1) {\n inputRefs.current[index + 1]?.focus();\n }\n\n return;\n }\n\n if (!symbol) {\n newCode[index] = '';\n codeSetter(newCode);\n\n return;\n }\n\n if (fieldPattern.test(symbol)) {\n newCode[index] = symbol.charAt(symbol.length - 1);\n codeSetter(newCode);\n\n if (index < codeLength - 1) {\n inputRefs.current[index + 1]?.focus();\n }\n } else {\n newCode[index] = symbol.charAt(symbol.length - 1);\n\n handleItemError({\n currentSymbol: symbol,\n itemErrorBehavior,\n index,\n newCode,\n inputRefs,\n setCode,\n codeSetter,\n });\n }\n };\n\n const handlePaste = (event: ClipboardEvent<HTMLInputElement>) => {\n if (disabled) {\n return;\n }\n\n event.preventDefault();\n\n const rawData = event.clipboardData.getData('text/plain');\n\n const pastedData = (fieldPattern\n ? rawData\n .split('')\n .map((symb) => symb.match(fieldPattern)?.[0] || '')\n .filter(Boolean) || []\n : rawData.split('')\n ).slice(0, codeLength);\n\n const activeIndex = Math.min(pastedData.length, codeLength - 1);\n inputRefs.current[activeIndex]?.focus();\n\n codeSetter(pastedData);\n };\n\n const handleFullCodeEnter = useCallback((fullCode: string) => {\n if (onFullCodeEnter) {\n onFullCodeEnter(fullCode);\n }\n }, []);\n\n useEffect(() => {\n inputRefs.current = inputRefs.current.slice(0, codeLength);\n }, [codeLength]);\n\n useEffect(() => {\n if (autoFocus && !disabled) {\n const lastActiveIndex = getLastActiveIndex();\n\n inputRefs.current[lastActiveIndex]?.focus();\n }\n }, [autoFocus]);\n\n useDidMountEffect(() => {\n if (handleFullCodeEnter && originalValue.length === codeLength) {\n handleFullCodeEnter(originalValue);\n }\n }, [originalValue, handleFullCodeEnter]);\n\n useDidMountEffect(() => {\n if (isError) {\n handleCodeError({\n codeLength,\n codeErrorBehavior,\n currentCode: code,\n inputRefs,\n inputContainerRef,\n captionRef,\n setCode,\n codeSetter,\n });\n }\n }, [isError]);\n\n return (\n <Root\n ref={ref}\n view={view}\n size={size}\n disabled={disabled}\n screen={screen}\n onClick={handleClick}\n className={cls(className, {\n [classes.captionAlignLeft]: captionAlign === 'left',\n })}\n {...rest}\n >\n <CodeWrapper ref={inputContainerRef}>\n {[...Array(parts)].map((_, partIndex) => (\n <Fragment key={partIndex}>\n <CodeGroup role=\"group\">\n {[...Array(codeLength / parts)].map((_, i) => {\n const inputCorrectIndex = i + (codeLength / parts) * partIndex;\n\n return (\n <ItemWrapper key={partIndex + i + partIndex * i} className={screenClass}>\n <ItemInput\n ref={(element: HTMLInputElement) => {\n inputRefs.current[inputCorrectIndex] = element;\n }}\n className={cls({\n [classes.hoverEnabled]:\n inputCorrectIndex >= originalValue.length,\n })}\n hide={hidden}\n value={code[inputCorrectIndex] || ''}\n autoComplete={autoComplete}\n onChange={(e: ChangeEvent<HTMLInputElement>) => {\n handleChange(e, inputCorrectIndex);\n }}\n onKeyDown={(e: KeyboardEvent<HTMLInputElement>) => {\n handleOnKeyDown(e, inputCorrectIndex);\n }}\n onPaste={handlePaste}\n tabIndex={originalValue.length === inputCorrectIndex ? 0 : -1}\n {...(placeholderValue && {\n placeholder: placeholderValue[inputCorrectIndex],\n })}\n />\n {(!code[inputCorrectIndex] ||\n (!!code[inputCorrectIndex] && hidden)) && (\n <ItemCircle\n className={\n !!code[inputCorrectIndex] && hidden\n ? classes.itemCirlceFilled\n : ''\n }\n />\n )}\n </ItemWrapper>\n );\n })}\n </CodeGroup>\n {partIndex !== parts - 1 && <Separator />}\n </Fragment>\n ))}\n </CodeWrapper>\n {caption && (\n <CaptionWrapper ref={captionRef} captionAlign={captionAlign} widthValue={widthValue}>\n {caption}\n </CaptionWrapper>\n )}\n </Root>\n );\n },\n );\n\nexport const codeInputConfig = {\n name: 'CodeInput',\n tag: 'div',\n layout: codeInputRoot,\n base,\n variations: {\n view: {\n css: viewCSS,\n },\n size: {\n css: sizeCSS,\n },\n disabled: {\n css: disabledCSS,\n attrs: true,\n },\n },\n defaults: {\n size: 'm',\n view: 'default',\n },\n};\n"],"names":["codeInputRoot","Root","forwardRef","_ref","ref","className","outerValue","value","placeholder","autoFocus","_ref$codeLength","codeLength","caption","_ref$captionAlign","captionAlign","width","view","size","_ref$screen","screen","hidden","disabled","isError","_ref$allowedSymbols","allowedSymbols","ONLY_DIGITS_PATTERN","_ref$itemErrorBehavio","itemErrorBehavior","_ref$codeErrorBehavio","codeErrorBehavior","_ref$autoComplete","autoComplete","setIsError","onChange","onFullCodeEnter","rest","_objectWithoutProperties","_excluded","_useState","useState","getCodeValue","_useState2","_slicedToArray","code","setCode","_useState3","join","_useState4","originalValue","setOriginalValue","inputRefs","useRef","inputContainerRef","captionRef","fieldPattern","getFieldPattern","placeholderValue","getPlaceholderValue","parts","screenClass","classes","concat","widthValue","getSizeValueFromProp","undefined","getLastActiveIndex","length","lastEmptyIndex","findIndex","digit","handleClick","lastActiveIndex","current","focus","handleOnKeyDown","event","index","key","FORBIDDEN_KEYS","includes","preventDefault","BACKSPACE_KEY","_inputRefs$current","codeSetter","newCode","handleChange","_inputRefs$current$in","rawSymbol","currentTarget","symbol","charAt","_toConsumableArray","classList","remove","itemError","_captionRef$current","captionError","_inputContainerRef$cu","codeError","codeErrorAnimation","_inputRefs$current2","test","_inputRefs$current3","handleItemError","currentSymbol","handlePaste","_inputRefs$current$ac","rawData","clipboardData","getData","pastedData","split","map","symb","_symb$match","match","filter","Boolean","slice","activeIndex","Math","min","handleFullCodeEnter","useCallback","fullCode","useEffect","_inputRefs$current$la","useDidMountEffect","handleCodeError","currentCode","React","createElement","_extends","onClick","cls","_defineProperty","captionAlignLeft","CodeWrapper","Array","_","partIndex","Fragment","CodeGroup","role","i","inputCorrectIndex","ItemWrapper","ItemInput","element","hoverEnabled","hide","e","onKeyDown","onPaste","tabIndex","ItemCircle","itemCirlceFilled","_Separator","Separator","CaptionWrapper","codeInputConfig","name","tag","layout","base","variations","css","viewCSS","sizeCSS","disabledCSS","attrs","defaults"],"mappings":";;;;;;;;;;;;;;;;;IAyBaA,aAAa,GAAG,SAAhBA,aAAaA,CAAIC,IAA+C,EAAA;AAAA,EAAA,oBACzEC,UAAU,CACN,UAAAC,IAAA,EAyBIC,GAAG,EACF;AAAA,IAAA,IAxBGC,SAAS,GAAAF,IAAA,CAATE,SAAS;MACFC,UAAU,GAAAH,IAAA,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nC,CAAC,CAAA;KACd,CACQ,CAAC,EACblJ,OAAO,iBACJsH,KAAA,CAAAC,aAAA,CAAC4B,cAAc,EAAA;AAAC3J,MAAAA,GAAG,EAAEiD,UAAW;AAACvC,MAAAA,YAAY,EAAEA,YAAa;AAACgD,MAAAA,UAAU,EAAEA,UAAAA;KACpElD,EAAAA,OACW,CAElB,CAAC,CAAA;AAEf,GACJ,CAAC,CAAA;AAAA,EAAA;AAEE,IAAMoJ,eAAe,GAAG;AAC3BC,EAAAA,IAAI,EAAE,WAAW;AACjBC,EAAAA,GAAG,EAAE,KAAK;AACVC,EAAAA,MAAM,EAAEnK,aAAa;AACrBoK,EAAAA,IAAI,EAAJA,IAAI;AACJC,EAAAA,UAAU,EAAE;AACRrJ,IAAAA,IAAI,EAAE;AACFsJ,MAAAA,GAAG,EAAEC,MAAAA;KACR;AACDtJ,IAAAA,IAAI,EAAE;AACFqJ,MAAAA,GAAG,EAAEE,MAAAA;KACR;AACDnJ,IAAAA,QAAQ,EAAE;AACNiJ,MAAAA,GAAG,EAAEG,MAAW;AAChBC,MAAAA,KAAK,EAAE,IAAA;AACX,KAAA;GACH;AACDC,EAAAA,QAAQ,EAAE;AACN1J,IAAAA,IAAI,EAAE,GAAG;AACTD,IAAAA,IAAI,EAAE,SAAA;AACV,GAAA;AACJ;;;;"}
@@ -0,0 +1,67 @@
1
+ import './CodeInput.styles_29ush3.css';
2
+ import { styled } from '@linaria/react';
3
+
4
+ var base = "b1y2r9rw";
5
+ var CodeWrapper = /*#__PURE__*/styled('div')({
6
+ name: "CodeWrapper",
7
+ "class": "c1fux591",
8
+ propsAsIs: false
9
+ });
10
+ var CodeGroup = /*#__PURE__*/styled('div')({
11
+ name: "CodeGroup",
12
+ "class": "cuja080",
13
+ propsAsIs: false
14
+ });
15
+ var Separator = /*#__PURE__*/styled('div')({
16
+ name: "Separator",
17
+ "class": "s175xqem",
18
+ propsAsIs: false
19
+ });
20
+ var _exp3 = function _exp3() {
21
+ return function (_ref) {
22
+ var hide = _ref.hide;
23
+ return hide ? '0' : '1';
24
+ };
25
+ };
26
+ var ItemInput = /*#__PURE__*/styled('input')({
27
+ name: "ItemInput",
28
+ "class": "i16menav",
29
+ propsAsIs: false,
30
+ vars: {
31
+ "i16menav-0": [/*#__PURE__*/_exp3()]
32
+ }
33
+ });
34
+ var ItemWrapper = /*#__PURE__*/styled('div')({
35
+ name: "ItemWrapper",
36
+ "class": "iuawgdb",
37
+ propsAsIs: false
38
+ });
39
+ var ItemCircle = /*#__PURE__*/styled('div')({
40
+ name: "ItemCircle",
41
+ "class": "i1tn2nm3",
42
+ propsAsIs: false
43
+ });
44
+ var _exp13 = function _exp13() {
45
+ return function (_ref2) {
46
+ var captionAlign = _ref2.captionAlign;
47
+ return captionAlign;
48
+ };
49
+ };
50
+ var _exp14 = function _exp14() {
51
+ return function (_ref3) {
52
+ var widthValue = _ref3.widthValue;
53
+ return widthValue || 'auto';
54
+ };
55
+ };
56
+ var CaptionWrapper = /*#__PURE__*/styled('div')({
57
+ name: "CaptionWrapper",
58
+ "class": "c19x1gm7",
59
+ propsAsIs: false,
60
+ vars: {
61
+ "c19x1gm7-0": [/*#__PURE__*/_exp13()],
62
+ "c19x1gm7-1": [/*#__PURE__*/_exp14()]
63
+ }
64
+ });
65
+
66
+ export { CaptionWrapper, CodeGroup, CodeWrapper, ItemCircle, ItemInput, ItemWrapper, Separator, base };
67
+ //# sourceMappingURL=CodeInput.styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CodeInput.styles.js","sources":["../../../src/components/CodeInput/CodeInput.styles.ts"],"sourcesContent":["import { css } from '@linaria/core';\nimport { styled } from '@linaria/react';\n\nimport { classes, tokens } from './CodeInput.tokens';\n\nexport const base = css`\n display: flex;\n flex-direction: column;\n justify-content: center;\n width: min-content;\n align-items: center;\n\n &.${classes.captionAlignLeft} {\n align-items: start;\n }\n`;\n\nexport const CodeWrapper = styled.div`\n display: flex;\n align-items: center;\n`;\n\nexport const CodeGroup = styled.div`\n display: flex;\n align-items: center;\n`;\n\nexport const Separator = styled.div`\n width: var(${tokens.separatorWidth});\n`;\n\nexport const ItemInput = styled.input<{ hide?: boolean }>`\n box-sizing: border-box;\n appearance: none;\n border: 0;\n padding: 0;\n outline: none;\n pointer-events: none;\n text-align: center;\n caret-color: transparent;\n caret: none;\n opacity: ${({ hide }) => (hide ? '0' : '1')};\n`;\n\nexport const ItemWrapper = styled.div`\n position: relative;\n`;\n\nexport const ItemCircle = styled.div<{ filled?: boolean }>`\n position: absolute;\n top: calc(50% - calc(var(${tokens.codeItemCircleSize}) / 2));\n left: calc(50% - calc(var(${tokens.codeItemCircleSize}) / 2));\n width: var(${tokens.codeItemCircleSize});\n height: var(${tokens.codeItemCircleSize});\n box-sizing: border-box;\n border: var(${tokens.codeItemCircleBorderWidth}) solid var(${tokens.codeColor});\n border-radius: 100%;\n background-color: 'transparent';\n\n &.${classes.itemCirlceFilled} {\n background-color: var(${tokens.codeColor});\n }\n`;\n\nexport const CaptionWrapper = styled.div<{ captionAlign: 'left' | 'center'; widthValue?: string }>`\n text-align: ${({ captionAlign }) => captionAlign};\n align-self: ${({ captionAlign }) => captionAlign};\n width: ${({ widthValue }) => widthValue || 'auto'};\n white-space: pre-line;\n`;\n"],"names":["base","CodeWrapper","styled","name","class","propsAsIs","CodeGroup","Separator","_exp3","_ref","hide","ItemInput","vars","ItemWrapper","ItemCircle","_exp13","_ref2","captionAlign","_exp14","_ref3","widthValue","CaptionWrapper"],"mappings":";;AAKO,IAAMA,IAAI,GAUhB,WAAA;AAEM,IAAMC,WAAW,gBAAGC,MAAM,CAAA,KAAA,CAAA,CAAA;AAAAC,EAAAA,IAAA,EAAA,aAAA;AAAAC,EAAAA,OAAAA,EAAA,UAAA;AAAAC,EAAAA,SAAA,EAAA,KAAA;AAAA,CAGhC,EAAA;AAEM,IAAMC,SAAS,gBAAGJ,MAAM,CAAA,KAAA,CAAA,CAAA;AAAAC,EAAAA,IAAA,EAAA,WAAA;AAAAC,E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A,GAAAA,KAAAA,CAAAA,YAAAA,CAAAA;AAAAA,IAAAA,OAAmBA,YAAY,CAAA;AAAA,GAAA,CAAA;AAAA,CAAA,CAAA;AAAA,IAAAC,MAAA,GAjElCA,SAiEkCA,MAAAA,GAAA;AAAA,EAAA,OACvC,UAAAC,KAAA,EAAA;AAAA,IAAA,IAAGC,UAAAA,GAAAA,KAAAA,CAAAA,UAAAA,CAAAA;IAAAA,OAAiBA,UAAU,IAAI,MAAM,CAAA;AAAA,GAAA,CAAA;AAAA,CAAA,CAAA;AAH9C,IAAMC,cAAc,gBAAGnB,MAAM,CAAA,KAAA,CAAA,CAAA;AAAAC,EAAAA,IAAA,EAAA,gBAAA;AAAAC,EAAAA,OAAAA,EAAA,UAAA;AAAAC,EAAAA,SAAA,EAAA,KAAA;AAAAO,EAAAA,IAAA,EAAA;AAAA,IAAA,YAAA,EAAA,cAElBG,MAAkC,EAAA,CAAA;AAAA,IAAA,YAAA,EAAA,cACvCG,MAAwC,EAAA,CAAA;AAAA,GAAA;AAAA,CAEpD;;;;"}
@@ -0,0 +1,8 @@
1
+ .b1y2r9rw{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;width:-webkit-min-content;width:-moz-min-content;width:min-content;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;}.b1y2r9rw.codeinput-caption-align-left{-webkit-align-items:start;-webkit-box-align:start;-ms-flex-align:start;align-items:start;}
2
+ .c1fux591{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;}
3
+ .cuja080{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;}
4
+ .s175xqem{width:var(--plasma-codeinput-separator-width);}
5
+ .i16menav{box-sizing:border-box;-webkit-appearance:none;-moz-appearance:none;appearance:none;border:0;padding:0;outline:none;pointer-events:none;text-align:center;caret-color:transparent;caret:none;opacity:var(--i16menav-0);}
6
+ .iuawgdb{position:relative;}
7
+ .i1tn2nm3{position:absolute;top:calc(50% - calc(var(--plasma-codeinput-item-circle-size) / 2));left:calc(50% - calc(var(--plasma-codeinput-item-circle-size) / 2));width:var(--plasma-codeinput-item-circle-size);height:var(--plasma-codeinput-item-circle-size);box-sizing:border-box;border:var(--plasma-codeinput-item-circle-border-width) solid var(--plasma-codeinput-code-color);border-radius:100%;background-color:'transparent';}.i1tn2nm3.codeinput-item-circle-filled{background-color:var(--plasma-codeinput-code-color);}
8
+ .c19x1gm7{text-align:var(--c19x1gm7-0);-webkit-align-self:var(--c19x1gm7-0);-ms-flex-item-align:var(--c19x1gm7-0);align-self:var(--c19x1gm7-0);width:var(--c19x1gm7-1);white-space:pre-line;}
@@ -0,0 +1,67 @@
1
+ var classes = {
2
+ itemError: 'codeinput-item-error',
3
+ itemErrorAnimation: 'codeinput-item-error-animation',
4
+ itemErrorFade: 'codeinput-item-error-fade',
5
+ itemCirlceFilled: 'codeinput-item-circle-filled',
6
+ captionError: 'codeinput-caption-error',
7
+ codeError: 'codeinput-code-error',
8
+ codeErrorAnimation: 'codeinput-code-error-animation',
9
+ codeErrorFade: 'codeinput-code-error-fade',
10
+ captionAlignLeft: 'codeinput-caption-align-left',
11
+ hoverEnabled: 'codeinput-item-hover-enabled',
12
+ segmented: 'codeinput-shape-segmented',
13
+ "default": 'codeinput-shape-default',
14
+ largeScreen: 'codeinput-large-screen',
15
+ mediumScreen: 'codeinput-medium-screen',
16
+ smallScreen: 'codeinput-small-screen',
17
+ disabled: 'codeinput-disabled'
18
+ };
19
+ var tokens = {
20
+ captionGap: '--plasma-codeinput-caption-gap',
21
+ codeItemsGap: '--plasma-codeinput-code-item-gap',
22
+ separatorWidth: '--plasma-codeinput-separator-width',
23
+ codeItemLargeWidth: '--plasma-codeinput-item-large-width',
24
+ codeItemLargeHeight: '--plasma-codeinput-item-large-height',
25
+ codeItemMediumWidth: '--plasma-codeinput-item-medium-width',
26
+ codeItemMediumHeight: '--plasma-codeinput-item-medium-height',
27
+ codeItemSmallWidth: '--plasma-codeinput-item-small-width',
28
+ codeItemSmallHeight: '--plasma-codeinput-item-small-height',
29
+ codeItemCircleSize: '--plasma-codeinput-item-circle-size',
30
+ codeItemCircleBorderWidth: '--plasma-codeinput-item-circle-border-width',
31
+ fontStyle: '--plasma-codeinput-font-style',
32
+ fontFamily: '--plasma-codeinput-font-family',
33
+ fontWeight: '--plasma-codeinput-font-weight',
34
+ letterSpacing: '--plasma-codeinput-letter-spacing',
35
+ largeScreenFontSize: '--plasma-codeinput-large-screen-font-size',
36
+ largeScreenLineHeight: '--plasma-codeinput-large-screen-line-height',
37
+ mediumScreenFontSize: '--plasma-codeinput-medium-screen-font-size',
38
+ mediumScreenLineHeight: '--plasma-codeinput-medium-screen-line-height',
39
+ smallScreenFontSize: '--plasma-codeinput-small-screen-font-size',
40
+ smallScreenLineHeight: '--plasma-codeinput-small-screen-line-height',
41
+ captionFontFamily: '--plasma-codeinput-caption-font-family',
42
+ captionFontSize: '--plasma-codeinput-caption-font-style',
43
+ captionFontStyle: '--plasma-codeinput-caption-font-size',
44
+ captionFontWeight: '--plasma-codeinput-caption-font-weight',
45
+ captionLetterSpacing: '--plasma-codeinput-caption-letter-spacing',
46
+ captionLineHeight: '--plasma-codeinput-caption-line-height',
47
+ borderRadius: '--plasma-codeinput-code-item-border-radius',
48
+ borderRadiusSegmented: '--plasma-codeinput-code-item-border-radius-segmented',
49
+ segmentedSideBorderRadius: '--plasma-codeinput-code-item-segmented-side-border-radius',
50
+ captionColor: '--plasma-codeinput-caption-color',
51
+ captionColorError: '--plasma-codeinput-caption-color-error',
52
+ codeColor: '--plasma-codeinput-code-color',
53
+ codeColorError: '--plasma-codeinput-code-color-error',
54
+ backgroundColor: '--plasma-codeinput-background-color',
55
+ backgroundColorHover: '--plasma-codeinput-background-color-hover',
56
+ backgroundColorFocus: '--plasma-codeinput-background-color-focus',
57
+ backgroundErrorColor: '--plasma-codeinput-background-error-color',
58
+ borderWidth: '--plasma-codeinput-border-width',
59
+ borderColor: '--plasma-codeinput-border-color',
60
+ borderColorHover: '--plasma-codeinput-border-color-hover',
61
+ borderColorFocus: '--plasma-codeinput-border-color-focus',
62
+ borderErrorColor: '--plasma-codeinput-border-error-color',
63
+ disabledOpacity: '--plasma-codeinput-disabled-opacity'
64
+ };
65
+
66
+ export { classes, tokens };
67
+ //# sourceMappingURL=CodeInput.tokens.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CodeInput.tokens.js","sources":["../../../src/components/CodeInput/CodeInput.tokens.ts"],"sourcesContent":["export const classes = {\n itemError: 'codeinput-item-error',\n itemErrorAnimation: 'codeinput-item-error-animation',\n itemErrorFade: 'codeinput-item-error-fade',\n itemCirlceFilled: 'codeinput-item-circle-filled',\n captionError: 'codeinput-caption-error',\n codeError: 'codeinput-code-error',\n codeErrorAnimation: 'codeinput-code-error-animation',\n codeErrorFade: 'codeinput-code-error-fade',\n\n captionAlignLeft: 'codeinput-caption-align-left',\n\n hoverEnabled: 'codeinput-item-hover-enabled',\n\n segmented: 'codeinput-shape-segmented',\n default: 'codeinput-shape-default',\n\n largeScreen: 'codeinput-large-screen',\n mediumScreen: 'codeinput-medium-screen',\n smallScreen: 'codeinput-small-screen',\n\n disabled: 'codeinput-disabled',\n};\n\nexport const tokens = {\n captionGap: '--plasma-codeinput-caption-gap',\n codeItemsGap: '--plasma-codeinput-code-item-gap',\n\n separatorWidth: '--plasma-codeinput-separator-width',\n\n codeItemLargeWidth: '--plasma-codeinput-item-large-width',\n codeItemLargeHeight: '--plasma-codeinput-item-large-height',\n\n codeItemMediumWidth: '--plasma-codeinput-item-medium-width',\n codeItemMediumHeight: '--plasma-codeinput-item-medium-height',\n\n codeItemSmallWidth: '--plasma-codeinput-item-small-width',\n codeItemSmallHeight: '--plasma-codeinput-item-small-height',\n\n codeItemCircleSize: '--plasma-codeinput-item-circle-size',\n codeItemCircleBorderWidth: '--plasma-codeinput-item-circle-border-width',\n\n fontStyle: '--plasma-codeinput-font-style',\n fontFamily: '--plasma-codeinput-font-family',\n fontWeight: '--plasma-codeinput-font-weight',\n letterSpacing: '--plasma-codeinput-letter-spacing',\n\n largeScreenFontSize: '--plasma-codeinput-large-screen-font-size',\n largeScreenLineHeight: '--plasma-codeinput-large-screen-line-height',\n\n mediumScreenFontSize: '--plasma-codeinput-medium-screen-font-size',\n mediumScreenLineHeight: '--plasma-codeinput-medium-screen-line-height',\n\n smallScreenFontSize: '--plasma-codeinput-small-screen-font-size',\n smallScreenLineHeight: '--plasma-codeinput-small-screen-line-height',\n\n captionFontFamily: '--plasma-codeinput-caption-font-family',\n captionFontSize: '--plasma-codeinput-caption-font-style',\n captionFontStyle: '--plasma-codeinput-caption-font-size',\n captionFontWeight: '--plasma-codeinput-caption-font-weight',\n captionLetterSpacing: '--plasma-codeinput-caption-letter-spacing',\n captionLineHeight: '--plasma-codeinput-caption-line-height',\n\n borderRadius: '--plasma-codeinput-code-item-border-radius',\n borderRadiusSegmented: '--plasma-codeinput-code-item-border-radius-segmented',\n segmentedSideBorderRadius: '--plasma-codeinput-code-item-segmented-side-border-radius',\n\n captionColor: '--plasma-codeinput-caption-color',\n captionColorError: '--plasma-codeinput-caption-color-error',\n\n codeColor: '--plasma-codeinput-code-color',\n codeColorError: '--plasma-codeinput-code-color-error',\n\n backgroundColor: '--plasma-codeinput-background-color',\n backgroundColorHover: '--plasma-codeinput-background-color-hover',\n backgroundColorFocus: '--plasma-codeinput-background-color-focus',\n backgroundErrorColor: '--plasma-codeinput-background-error-color',\n\n borderWidth: '--plasma-codeinput-border-width',\n borderColor: '--plasma-codeinput-border-color',\n borderColorHover: '--plasma-codeinput-border-color-hover',\n borderColorFocus: '--plasma-codeinput-border-color-focus',\n borderErrorColor: '--plasma-codeinput-border-error-color',\n\n disabledOpacity: '--plasma-codeinput-disabled-opacity',\n};\n"],"names":["classes","itemError","itemErrorAnimation","itemErrorFade","itemCirlceFilled","captionError","codeError","codeErrorAnimation","codeErrorFade","captionAlignLeft","hoverEnabled","segmented","largeScreen","mediumScreen","smallScreen","disabled","tokens","captionGap","codeItemsGap","separatorWidth","codeItemLargeWidth","codeItemLargeHeight","codeItemMediumWidth","codeItemMediumHeight","codeItemSmallWidth","codeItemSmallHeight","codeItemCircleSize","codeItemCircleBorderWidth","fontStyle","fontFamily","fontWeight","letterSpacing","largeScreenFontSize","largeScreenLineHeight","mediumScreenFontSize","mediumScreenLineHeight","smallScreenFontSize","smallScreenLineHeight","captionFontFamily","captionFontSize","captionFontStyle","captionFontWeight","captionLetterSpacing","captionLineHeight","borderRadius","borderRadiusSegmented","segmentedSideBorderRadius","captionColor","captionColorError","codeColor","codeColorError","backgroundColor","backgroundColorHover","backgroundColorFocus","backgroundErrorColor","borderWidth","borderColor","borderColorHover","borderColorFocus","borderErrorColor","disabledOpacity"],"mappings":"AAAO,IAAMA,OAAO,GAAG;AACnBC,EAAAA,SAAS,EAAE,sBAAsB;AACjCC,EAAAA,kBAAkB,EAAE,gCAAgC;AACpDC,EAAAA,aAAa,EAAE,2BAA2B;AAC1CC,EAAAA,gBAAgB,EAAE,8BAA8B;AAChDC,EAAAA,YAAY,EAAE,yBAAyB;AACvCC,EAAAA,SAAS,EAAE,sBAAsB;AACjCC,EAAAA,kBAAkB,EAAE,gCAAgC;AACpDC,EAAAA,aAAa,EAAE,2BAA2B;AAE1CC,EAAAA,gBAAgB,EAAE,8BAA8B;AAEhDC,EAAAA,YAAY,EAAE,8BAA8B;AAE5CC,EAAAA,SAAS,EAAE,2BAA2B;AACtC,EAAA,SAAA,EAAS,yBAAyB;AAElCC,EAAAA,WAAW,EAAE,wBAAwB;AACrCC,EAAAA,YAAY,EAAE,yBAAyB;AACvCC,EAAAA,WAAW,EAAE,wBAAwB;AAErCC,EAAAA,QAAQ,EAAE,oBA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AAE3DC,EAAAA,SAAS,EAAE,+BAA+B;AAC1CC,EAAAA,cAAc,EAAE,qCAAqC;AAErDC,EAAAA,eAAe,EAAE,qCAAqC;AACtDC,EAAAA,oBAAoB,EAAE,2CAA2C;AACjEC,EAAAA,oBAAoB,EAAE,2CAA2C;AACjEC,EAAAA,oBAAoB,EAAE,2CAA2C;AAEjEC,EAAAA,WAAW,EAAE,iCAAiC;AAC9CC,EAAAA,WAAW,EAAE,iCAAiC;AAC9CC,EAAAA,gBAAgB,EAAE,uCAAuC;AACzDC,EAAAA,gBAAgB,EAAE,uCAAuC;AACzDC,EAAAA,gBAAgB,EAAE,uCAAuC;AAEzDC,EAAAA,eAAe,EAAE,qCAAA;AACrB;;;;"}
@@ -0,0 +1,7 @@
1
+ var ONLY_DIGITS_PATTERN = '^\\d+$';
2
+ var FORBIDDEN_KEYS = ['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown', 'Delete'];
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
@@ -0,0 +1 @@
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'];\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,EAAC;AACpF,IAAMC,aAAa,GAAG,YAAW;AAEjC,IAAMC,iBAAiB,GAAG;;;;"}
@@ -0,0 +1,51 @@
1
+ import { toConsumableArray as _toConsumableArray } from '../../../_virtual/_rollupPluginBabelHelpers.js';
2
+ import { classes } from '../CodeInput.tokens.js';
3
+ import { ANIMATION_TIMEOUT } from './constants.js';
4
+ import { getCodeValue } from './initialValuesHelper.js';
5
+
6
+ var handleCodeError = function handleCodeError(_ref) {
7
+ var _captionRef$current, _captionRef$current2;
8
+ var codeLength = _ref.codeLength,
9
+ codeErrorBehavior = _ref.codeErrorBehavior,
10
+ currentCode = _ref.currentCode,
11
+ inputRefs = _ref.inputRefs,
12
+ inputContainerRef = _ref.inputContainerRef,
13
+ captionRef = _ref.captionRef,
14
+ setCode = _ref.setCode,
15
+ codeSetter = _ref.codeSetter;
16
+ if (!inputContainerRef.current) {
17
+ return;
18
+ }
19
+ switch (codeErrorBehavior) {
20
+ case 'keep':
21
+ inputContainerRef.current.classList.add(classes.codeError, classes.codeErrorAnimation);
22
+ (_captionRef$current = captionRef.current) === null || _captionRef$current === void 0 || _captionRef$current.classList.add(classes.captionError);
23
+ setTimeout(function () {
24
+ var _inputContainerRef$cu;
25
+ var newCode = _toConsumableArray(currentCode);
26
+ newCode.pop();
27
+ codeSetter(newCode);
28
+ setCode(currentCode);
29
+ (_inputContainerRef$cu = inputContainerRef.current) === null || _inputContainerRef$cu === void 0 || _inputContainerRef$cu.classList.remove(classes.codeErrorAnimation);
30
+ setTimeout(function () {
31
+ var _inputRefs$current, _inputRefs$current2;
32
+ (_inputRefs$current = inputRefs.current[inputRefs.current.length - 1]) === null || _inputRefs$current === void 0 || _inputRefs$current.setSelectionRange(0, 1);
33
+ (_inputRefs$current2 = inputRefs.current[inputRefs.current.length - 1]) === null || _inputRefs$current2 === void 0 || _inputRefs$current2.focus();
34
+ }, 0);
35
+ }, ANIMATION_TIMEOUT);
36
+ break;
37
+ case 'remove-code':
38
+ default:
39
+ inputContainerRef.current.classList.add(classes.codeError, classes.codeErrorAnimation, classes.codeErrorFade);
40
+ (_captionRef$current2 = captionRef.current) === null || _captionRef$current2 === void 0 || _captionRef$current2.classList.add(classes.captionError);
41
+ setTimeout(function () {
42
+ var _inputRefs$current$, _inputContainerRef$cu2;
43
+ codeSetter(getCodeValue(codeLength, ''));
44
+ (_inputRefs$current$ = inputRefs.current[0]) === null || _inputRefs$current$ === void 0 || _inputRefs$current$.focus();
45
+ (_inputContainerRef$cu2 = inputContainerRef.current) === null || _inputContainerRef$cu2 === void 0 || _inputContainerRef$cu2.classList.remove(classes.codeError, classes.codeErrorAnimation, classes.codeErrorFade);
46
+ }, ANIMATION_TIMEOUT);
47
+ }
48
+ };
49
+
50
+ export { handleCodeError };
51
+ //# sourceMappingURL=handleCodeError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handleCodeError.js","sources":["../../../../src/components/CodeInput/utils/handleCodeError.ts"],"sourcesContent":["import { Dispatch, MutableRefObject, SetStateAction } from 'react';\n\nimport type { CodeErrorBehavior } from '../CodeInput.types';\nimport { classes } from '../CodeInput.tokens';\n\nimport { ANIMATION_TIMEOUT } from './constants';\nimport { getCodeValue } from './initialValuesHelper';\n\ntype ValidateSymbolsArgs = {\n codeLength: number;\n codeErrorBehavior: CodeErrorBehavior;\n currentCode: Array<string>;\n inputContainerRef: MutableRefObject<HTMLDivElement | null>;\n inputRefs: MutableRefObject<Array<HTMLInputElement | null>>;\n captionRef: MutableRefObject<HTMLDivElement | null>;\n setCode: Dispatch<SetStateAction<Array<string>>>;\n codeSetter: (newCode: Array<string>) => void;\n};\n\nexport const handleCodeError = ({\n codeLength,\n codeErrorBehavior,\n currentCode,\n inputRefs,\n inputContainerRef,\n captionRef,\n setCode,\n codeSetter,\n}: ValidateSymbolsArgs) => {\n if (!inputContainerRef.current) {\n return;\n }\n\n switch (codeErrorBehavior) {\n case 'keep':\n inputContainerRef.current.classList.add(classes.codeError, classes.codeErrorAnimation);\n captionRef.current?.classList.add(classes.captionError);\n\n setTimeout(() => {\n const newCode = [...currentCode];\n\n newCode.pop();\n codeSetter(newCode);\n setCode(currentCode);\n\n inputContainerRef.current?.classList.remove(classes.codeErrorAnimation);\n\n setTimeout(() => {\n inputRefs.current[inputRefs.current.length - 1]?.setSelectionRange(0, 1);\n inputRefs.current[inputRefs.current.length - 1]?.focus();\n }, 0);\n }, ANIMATION_TIMEOUT);\n\n break;\n case 'remove-code':\n default:\n inputContainerRef.current.classList.add(\n classes.codeError,\n classes.codeErrorAnimation,\n classes.codeErrorFade,\n );\n captionRef.current?.classList.add(classes.captionError);\n\n setTimeout(() => {\n codeSetter(getCodeValue(codeLength, ''));\n\n inputRefs.current[0]?.focus();\n inputContainerRef.current?.classList.remove(\n classes.codeError,\n classes.codeErrorAnimation,\n classes.codeErrorFade,\n );\n }, ANIMATION_TIMEOUT);\n }\n};\n"],"names":["handleCodeError","_ref","_captionRef$current","_captionRef$current2","codeLength","codeErrorBehavior","currentCode","inputRefs","inputContainerRef","captionRef","setCode","codeSetter","current","classList","add","classes","codeError","codeErrorAnimation","captionError","setTimeout","_inputContainerRef$cu","newCode","_toConsumableArray","pop","remove","_inputRefs$current","_inputRefs$current2","length","setSelectionRange","focus","ANIMATION_TIMEOUT","codeErrorFade","_inputRefs$current$","_inputContainerRef$cu2","getCodeValue"],"mappings":";;;;;IAmBaA,eAAe,GAAG,SAAlBA,eAAeA,CAAAC,IAAA,EASD;EAAA,IAAAC,mBAAA,EAAAC,oBAAA,CAAA;AAAA,EAAA,IARvBC,UAAU,GAAAH,IAAA,CAAVG,UAAU;IACVC,iBAAiB,GAAAJ,IAAA,CAAjBI,iBAAiB;IACjBC,WAAW,GAAAL,IAAA,CAAXK,WAAW;IACXC,SAAS,GAAAN,IAAA,CAATM,SAAS;IACTC,iBAAiB,GAAAP,IAAA,CAAjBO,iBAA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