@cloud-ru/uikit-product-fields-predefined 2.4.8-preview-5e39e65e.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (187) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +12 -326
  3. package/dist/cjs/components/index.d.ts +0 -2
  4. package/dist/cjs/components/index.js +0 -2
  5. package/dist/esm/components/index.d.ts +0 -2
  6. package/dist/esm/components/index.js +0 -2
  7. package/dist/tsconfig.cjs.tsbuildinfo +1 -1
  8. package/dist/tsconfig.esm.tsbuildinfo +1 -1
  9. package/package.json +3 -9
  10. package/src/components/index.ts +0 -2
  11. package/dist/cjs/components/FieldAi/FieldAi.d.ts +0 -24
  12. package/dist/cjs/components/FieldAi/FieldAi.js +0 -92
  13. package/dist/cjs/components/FieldAi/components/AlertButton/AlertButton.d.ts +0 -5
  14. package/dist/cjs/components/FieldAi/components/AlertButton/AlertButton.js +0 -12
  15. package/dist/cjs/components/FieldAi/components/AlertButton/index.d.ts +0 -1
  16. package/dist/cjs/components/FieldAi/components/AlertButton/index.js +0 -17
  17. package/dist/cjs/components/FieldAi/components/AlertButton/styles.module.css +0 -17
  18. package/dist/cjs/components/FieldAi/components/CheckItem/CheckItem.d.ts +0 -9
  19. package/dist/cjs/components/FieldAi/components/CheckItem/CheckItem.js +0 -28
  20. package/dist/cjs/components/FieldAi/components/CheckItem/index.d.ts +0 -1
  21. package/dist/cjs/components/FieldAi/components/CheckItem/index.js +0 -17
  22. package/dist/cjs/components/FieldAi/components/CheckItem/styles.module.css +0 -36
  23. package/dist/cjs/components/FieldAi/components/MobileFieldAi/MobileFieldAi.d.ts +0 -5
  24. package/dist/cjs/components/FieldAi/components/MobileFieldAi/MobileFieldAi.js +0 -31
  25. package/dist/cjs/components/FieldAi/components/MobileFieldAi/index.d.ts +0 -1
  26. package/dist/cjs/components/FieldAi/components/MobileFieldAi/index.js +0 -17
  27. package/dist/cjs/components/FieldAi/components/MobileFieldAi/styles.module.css +0 -78
  28. package/dist/cjs/components/FieldAi/components/PasswordValidation/PasswordValidation.d.ts +0 -7
  29. package/dist/cjs/components/FieldAi/components/PasswordValidation/PasswordValidation.js +0 -23
  30. package/dist/cjs/components/FieldAi/components/PasswordValidation/index.d.ts +0 -1
  31. package/dist/cjs/components/FieldAi/components/PasswordValidation/index.js +0 -17
  32. package/dist/cjs/components/FieldAi/components/PasswordValidation/styles.module.css +0 -36
  33. package/dist/cjs/components/FieldAi/components/TextArea/TextArea.d.ts +0 -39
  34. package/dist/cjs/components/FieldAi/components/TextArea/TextArea.js +0 -33
  35. package/dist/cjs/components/FieldAi/components/TextArea/index.d.ts +0 -1
  36. package/dist/cjs/components/FieldAi/components/TextArea/index.js +0 -17
  37. package/dist/cjs/components/FieldAi/components/TextArea/styles.module.css +0 -32
  38. package/dist/cjs/components/FieldAi/components/WithPasswordValidation/WithPasswordValidation.d.ts +0 -10
  39. package/dist/cjs/components/FieldAi/components/WithPasswordValidation/WithPasswordValidation.js +0 -23
  40. package/dist/cjs/components/FieldAi/components/WithPasswordValidation/index.d.ts +0 -1
  41. package/dist/cjs/components/FieldAi/components/WithPasswordValidation/index.js +0 -17
  42. package/dist/cjs/components/FieldAi/components/WithPasswordValidation/styles.module.css +0 -6
  43. package/dist/cjs/components/FieldAi/index.d.ts +0 -1
  44. package/dist/cjs/components/FieldAi/index.js +0 -17
  45. package/dist/cjs/components/FieldAi/styles.module.css +0 -61
  46. package/dist/cjs/components/FieldAi/utils.d.ts +0 -10
  47. package/dist/cjs/components/FieldAi/utils.js +0 -19
  48. package/dist/cjs/components/FieldCode/FieldCode.d.ts +0 -33
  49. package/dist/cjs/components/FieldCode/FieldCode.js +0 -48
  50. package/dist/cjs/components/FieldCode/components/Cell/Cell.d.ts +0 -5
  51. package/dist/cjs/components/FieldCode/components/Cell/Cell.js +0 -27
  52. package/dist/cjs/components/FieldCode/components/Cell/index.d.ts +0 -1
  53. package/dist/cjs/components/FieldCode/components/Cell/index.js +0 -17
  54. package/dist/cjs/components/FieldCode/components/Cell/styles.module.css +0 -3
  55. package/dist/cjs/components/FieldCode/components/ResendCode/ResendCode.d.ts +0 -8
  56. package/dist/cjs/components/FieldCode/components/ResendCode/ResendCode.js +0 -28
  57. package/dist/cjs/components/FieldCode/components/ResendCode/index.d.ts +0 -1
  58. package/dist/cjs/components/FieldCode/components/ResendCode/index.js +0 -17
  59. package/dist/cjs/components/FieldCode/components/ResendCode/utils.d.ts +0 -1
  60. package/dist/cjs/components/FieldCode/components/ResendCode/utils.js +0 -8
  61. package/dist/cjs/components/FieldCode/components/index.d.ts +0 -2
  62. package/dist/cjs/components/FieldCode/components/index.js +0 -18
  63. package/dist/cjs/components/FieldCode/constants.d.ts +0 -14
  64. package/dist/cjs/components/FieldCode/constants.js +0 -10
  65. package/dist/cjs/components/FieldCode/hooks/index.d.ts +0 -4
  66. package/dist/cjs/components/FieldCode/hooks/index.js +0 -20
  67. package/dist/cjs/components/FieldCode/hooks/useCodeInput.d.ts +0 -22
  68. package/dist/cjs/components/FieldCode/hooks/useCodeInput.js +0 -98
  69. package/dist/cjs/components/FieldCode/hooks/useFieldCodeValidate.d.ts +0 -8
  70. package/dist/cjs/components/FieldCode/hooks/useFieldCodeValidate.js +0 -24
  71. package/dist/cjs/components/FieldCode/hooks/useFieldHelpers.d.ts +0 -13
  72. package/dist/cjs/components/FieldCode/hooks/useFieldHelpers.js +0 -34
  73. package/dist/cjs/components/FieldCode/hooks/useFocusCell.d.ts +0 -5
  74. package/dist/cjs/components/FieldCode/hooks/useFocusCell.js +0 -22
  75. package/dist/cjs/components/FieldCode/index.d.ts +0 -2
  76. package/dist/cjs/components/FieldCode/index.js +0 -20
  77. package/dist/cjs/components/FieldCode/styles.module.css +0 -30
  78. package/dist/cjs/components/FieldCode/utils.d.ts +0 -6
  79. package/dist/cjs/components/FieldCode/utils.js +0 -21
  80. package/dist/esm/components/FieldAi/FieldAi.d.ts +0 -24
  81. package/dist/esm/components/FieldAi/FieldAi.js +0 -86
  82. package/dist/esm/components/FieldAi/components/AlertButton/AlertButton.d.ts +0 -5
  83. package/dist/esm/components/FieldAi/components/AlertButton/AlertButton.js +0 -6
  84. package/dist/esm/components/FieldAi/components/AlertButton/index.d.ts +0 -1
  85. package/dist/esm/components/FieldAi/components/AlertButton/index.js +0 -1
  86. package/dist/esm/components/FieldAi/components/AlertButton/styles.module.css +0 -17
  87. package/dist/esm/components/FieldAi/components/CheckItem/CheckItem.d.ts +0 -9
  88. package/dist/esm/components/FieldAi/components/CheckItem/CheckItem.js +0 -22
  89. package/dist/esm/components/FieldAi/components/CheckItem/index.d.ts +0 -1
  90. package/dist/esm/components/FieldAi/components/CheckItem/index.js +0 -1
  91. package/dist/esm/components/FieldAi/components/CheckItem/styles.module.css +0 -36
  92. package/dist/esm/components/FieldAi/components/MobileFieldAi/MobileFieldAi.d.ts +0 -5
  93. package/dist/esm/components/FieldAi/components/MobileFieldAi/MobileFieldAi.js +0 -25
  94. package/dist/esm/components/FieldAi/components/MobileFieldAi/index.d.ts +0 -1
  95. package/dist/esm/components/FieldAi/components/MobileFieldAi/index.js +0 -1
  96. package/dist/esm/components/FieldAi/components/MobileFieldAi/styles.module.css +0 -78
  97. package/dist/esm/components/FieldAi/components/PasswordValidation/PasswordValidation.d.ts +0 -7
  98. package/dist/esm/components/FieldAi/components/PasswordValidation/PasswordValidation.js +0 -17
  99. package/dist/esm/components/FieldAi/components/PasswordValidation/index.d.ts +0 -1
  100. package/dist/esm/components/FieldAi/components/PasswordValidation/index.js +0 -1
  101. package/dist/esm/components/FieldAi/components/PasswordValidation/styles.module.css +0 -36
  102. package/dist/esm/components/FieldAi/components/TextArea/TextArea.d.ts +0 -39
  103. package/dist/esm/components/FieldAi/components/TextArea/TextArea.js +0 -27
  104. package/dist/esm/components/FieldAi/components/TextArea/index.d.ts +0 -1
  105. package/dist/esm/components/FieldAi/components/TextArea/index.js +0 -1
  106. package/dist/esm/components/FieldAi/components/TextArea/styles.module.css +0 -32
  107. package/dist/esm/components/FieldAi/components/WithPasswordValidation/WithPasswordValidation.d.ts +0 -10
  108. package/dist/esm/components/FieldAi/components/WithPasswordValidation/WithPasswordValidation.js +0 -17
  109. package/dist/esm/components/FieldAi/components/WithPasswordValidation/index.d.ts +0 -1
  110. package/dist/esm/components/FieldAi/components/WithPasswordValidation/index.js +0 -1
  111. package/dist/esm/components/FieldAi/components/WithPasswordValidation/styles.module.css +0 -6
  112. package/dist/esm/components/FieldAi/index.d.ts +0 -1
  113. package/dist/esm/components/FieldAi/index.js +0 -1
  114. package/dist/esm/components/FieldAi/styles.module.css +0 -61
  115. package/dist/esm/components/FieldAi/utils.d.ts +0 -10
  116. package/dist/esm/components/FieldAi/utils.js +0 -15
  117. package/dist/esm/components/FieldCode/FieldCode.d.ts +0 -33
  118. package/dist/esm/components/FieldCode/FieldCode.js +0 -41
  119. package/dist/esm/components/FieldCode/components/Cell/Cell.d.ts +0 -5
  120. package/dist/esm/components/FieldCode/components/Cell/Cell.js +0 -21
  121. package/dist/esm/components/FieldCode/components/Cell/index.d.ts +0 -1
  122. package/dist/esm/components/FieldCode/components/Cell/index.js +0 -1
  123. package/dist/esm/components/FieldCode/components/Cell/styles.module.css +0 -3
  124. package/dist/esm/components/FieldCode/components/ResendCode/ResendCode.d.ts +0 -8
  125. package/dist/esm/components/FieldCode/components/ResendCode/ResendCode.js +0 -25
  126. package/dist/esm/components/FieldCode/components/ResendCode/index.d.ts +0 -1
  127. package/dist/esm/components/FieldCode/components/ResendCode/index.js +0 -1
  128. package/dist/esm/components/FieldCode/components/ResendCode/utils.d.ts +0 -1
  129. package/dist/esm/components/FieldCode/components/ResendCode/utils.js +0 -5
  130. package/dist/esm/components/FieldCode/components/index.d.ts +0 -2
  131. package/dist/esm/components/FieldCode/components/index.js +0 -2
  132. package/dist/esm/components/FieldCode/constants.d.ts +0 -14
  133. package/dist/esm/components/FieldCode/constants.js +0 -7
  134. package/dist/esm/components/FieldCode/hooks/index.d.ts +0 -4
  135. package/dist/esm/components/FieldCode/hooks/index.js +0 -4
  136. package/dist/esm/components/FieldCode/hooks/useCodeInput.d.ts +0 -22
  137. package/dist/esm/components/FieldCode/hooks/useCodeInput.js +0 -95
  138. package/dist/esm/components/FieldCode/hooks/useFieldCodeValidate.d.ts +0 -8
  139. package/dist/esm/components/FieldCode/hooks/useFieldCodeValidate.js +0 -21
  140. package/dist/esm/components/FieldCode/hooks/useFieldHelpers.d.ts +0 -13
  141. package/dist/esm/components/FieldCode/hooks/useFieldHelpers.js +0 -31
  142. package/dist/esm/components/FieldCode/hooks/useFocusCell.d.ts +0 -5
  143. package/dist/esm/components/FieldCode/hooks/useFocusCell.js +0 -19
  144. package/dist/esm/components/FieldCode/index.d.ts +0 -2
  145. package/dist/esm/components/FieldCode/index.js +0 -2
  146. package/dist/esm/components/FieldCode/styles.module.css +0 -30
  147. package/dist/esm/components/FieldCode/utils.d.ts +0 -6
  148. package/dist/esm/components/FieldCode/utils.js +0 -13
  149. package/src/components/FieldAi/FieldAi.tsx +0 -201
  150. package/src/components/FieldAi/components/AlertButton/AlertButton.tsx +0 -16
  151. package/src/components/FieldAi/components/AlertButton/index.ts +0 -1
  152. package/src/components/FieldAi/components/AlertButton/styles.module.scss +0 -20
  153. package/src/components/FieldAi/components/CheckItem/CheckItem.tsx +0 -45
  154. package/src/components/FieldAi/components/CheckItem/index.ts +0 -1
  155. package/src/components/FieldAi/components/CheckItem/styles.module.scss +0 -44
  156. package/src/components/FieldAi/components/MobileFieldAi/MobileFieldAi.tsx +0 -57
  157. package/src/components/FieldAi/components/MobileFieldAi/index.ts +0 -1
  158. package/src/components/FieldAi/components/MobileFieldAi/styles.module.scss +0 -90
  159. package/src/components/FieldAi/components/PasswordValidation/PasswordValidation.tsx +0 -85
  160. package/src/components/FieldAi/components/PasswordValidation/index.ts +0 -1
  161. package/src/components/FieldAi/components/PasswordValidation/styles.module.scss +0 -34
  162. package/src/components/FieldAi/components/TextArea/TextArea.tsx +0 -113
  163. package/src/components/FieldAi/components/TextArea/index.ts +0 -1
  164. package/src/components/FieldAi/components/TextArea/styles.module.scss +0 -35
  165. package/src/components/FieldAi/components/WithPasswordValidation/WithPasswordValidation.tsx +0 -63
  166. package/src/components/FieldAi/components/WithPasswordValidation/index.ts +0 -1
  167. package/src/components/FieldAi/components/WithPasswordValidation/styles.module.scss +0 -8
  168. package/src/components/FieldAi/index.ts +0 -1
  169. package/src/components/FieldAi/styles.module.scss +0 -85
  170. package/src/components/FieldAi/utils.ts +0 -27
  171. package/src/components/FieldCode/FieldCode.tsx +0 -125
  172. package/src/components/FieldCode/components/Cell/Cell.tsx +0 -32
  173. package/src/components/FieldCode/components/Cell/index.ts +0 -1
  174. package/src/components/FieldCode/components/Cell/styles.module.scss +0 -5
  175. package/src/components/FieldCode/components/ResendCode/ResendCode.tsx +0 -33
  176. package/src/components/FieldCode/components/ResendCode/index.ts +0 -1
  177. package/src/components/FieldCode/components/ResendCode/utils.ts +0 -5
  178. package/src/components/FieldCode/components/index.ts +0 -2
  179. package/src/components/FieldCode/constants.ts +0 -20
  180. package/src/components/FieldCode/hooks/index.ts +0 -4
  181. package/src/components/FieldCode/hooks/useCodeInput.ts +0 -147
  182. package/src/components/FieldCode/hooks/useFieldCodeValidate.ts +0 -35
  183. package/src/components/FieldCode/hooks/useFieldHelpers.ts +0 -52
  184. package/src/components/FieldCode/hooks/useFocusCell.ts +0 -29
  185. package/src/components/FieldCode/index.ts +0 -2
  186. package/src/components/FieldCode/styles.module.scss +0 -40
  187. package/src/components/FieldCode/utils.ts +0 -23
@@ -1,90 +0,0 @@
1
- @use '@cloud-ru/figma-tokens-cloud-platform/build/scss/components/styles-tokens-fields' as ste;
2
-
3
- $padding-right: (
4
- 's': ste.$fields-buttons-s,
5
- 'm': ste.$fields-buttons-m,
6
- 'l': ste.$fields-buttons-m,
7
- );
8
- $scroll-bar-heights: (
9
- 's': ste.$dimension-050m,
10
- 'm': calc(#{ste.$dimension-025m} + #{ste.$dimension-050m}),
11
- 'l': ste.$dimension-1m,
12
- );
13
- $sizes: 's', 'm', 'l';
14
-
15
- .scrollContainer {
16
- border-radius: 4px;
17
- padding: 6px 0;
18
-
19
- [data-overlayscrollbars-contents] {
20
- display: flex;
21
- }
22
- }
23
-
24
- .textarea {
25
- overflow: hidden;
26
- }
27
-
28
- .mobileInputWrapper {
29
- --max-rows: 1000;
30
- --min-rows: 3;
31
-
32
- display: flex;
33
- position: relative;
34
- gap: 8px;
35
-
36
- .scrollContainer {
37
- min-height: calc(var(--min-rows) * var(--row-height) + var(--horizontal-scroll-bar-height));
38
- max-height: calc(var(--max-rows) * var(--row-height) + var(--horizontal-scroll-bar-height));
39
- }
40
-
41
- .textarea {
42
- @include ste.composite-var(ste.$sans-body-l);
43
-
44
- padding-right: calc(42px + ste.simple-var(ste.$fields-scroll-bar-width, 'width'));
45
-
46
- &::placeholder {
47
- color: ste.simple-var(ste.$sys-neutral-text-disabled);
48
- }
49
- }
50
-
51
- @each $size in $sizes {
52
- &[data-size='#{$size}'] {
53
- --row-height: #{ste.simple-var(ste.$theme-variables, 'sans', 'body', $size, 'line-height')};
54
- --horizontal-scroll-bar-height: #{ste.simple-var($scroll-bar-heights, $size)};
55
- }
56
- }
57
- }
58
-
59
- .mobileSubmitButtonWrapper {
60
- width: 32px;
61
- height: 32px;
62
- display: flex;
63
- flex-shrink: 0;
64
- position: absolute;
65
- bottom: 0;
66
- right: 10px;
67
- }
68
-
69
- .mobileSubmitButton {
70
- /* stylelint-disable-next-line declaration-no-important */
71
- position: relative !important;
72
- /* stylelint-disable-next-line declaration-no-important */
73
- flex-shrink: 0 !important;
74
-
75
- &:not([data-disabled]) {
76
- /* stylelint-disable-next-line color-no-hex */
77
- background: radial-gradient(229.88% 112% at 37.5% 77.08%, #26D07C 19.86%, #5FD7C2 50.73%, #7CB5F2 89.88%);
78
- }
79
-
80
- &:after {
81
- content: '';
82
- display: flex;
83
- width: 48px;
84
- height: 48px;
85
- position: absolute;
86
- top: 50%;
87
- left: 50%;
88
- transform: translate(-50%, -50%);
89
- }
90
- }
@@ -1,85 +0,0 @@
1
- import { useMemo } from 'react';
2
-
3
- import { useLocale } from '@cloud-ru/uikit-product-locale';
4
- import { WithLayoutType } from '@cloud-ru/uikit-product-utils';
5
-
6
- import { isTouchDevice as isTouchDeviceHelper } from '../../../../helpers';
7
- import { ValidationPassword, ValidationPasswordKey } from '../../utils';
8
- import { CheckItem } from '../CheckItem';
9
- import styles from './styles.module.scss';
10
-
11
- export type WithPasswordTooltipProps = WithLayoutType<{
12
- passwordValidation: ValidationPassword;
13
- animatedKey?: ValidationPasswordKey | null;
14
- }>;
15
-
16
- export function PasswordValidation({ passwordValidation, layoutType, animatedKey }: WithPasswordTooltipProps) {
17
- const { t } = useLocale('FieldsPredefined');
18
-
19
- const allCriteriaMet = useMemo(() => Object.values(passwordValidation).every(item => item), [passwordValidation]);
20
- const isTouchDevice = isTouchDeviceHelper(layoutType);
21
-
22
- if (isTouchDevice) {
23
- if (allCriteriaMet) {
24
- return (
25
- <div className={styles.validationItemsContainer} data-layout-type={layoutType}>
26
- <CheckItem
27
- checked={true}
28
- label={t('FieldAi.secret.passwordTooltip.titleSuccess')}
29
- layoutType={layoutType}
30
- shouldHide={false}
31
- />
32
- </div>
33
- );
34
- }
35
- }
36
-
37
- return (
38
- <div className={styles.validationItemsContainer} data-layout-type={layoutType}>
39
- <div className={styles.validationList}>
40
- <CheckItem
41
- checked={passwordValidation.minLength}
42
- label={t('FieldAi.secret.passwordTooltip.minLength')}
43
- layoutType={layoutType}
44
- shouldHide={isTouchDevice}
45
- animated={animatedKey === 'minLength'}
46
- />
47
- <CheckItem
48
- checked={passwordValidation.onlyLatin}
49
- label={t('FieldAi.secret.passwordTooltip.onlyLatin')}
50
- layoutType={layoutType}
51
- shouldHide={isTouchDevice}
52
- animated={animatedKey === 'onlyLatin'}
53
- />
54
- <CheckItem
55
- checked={passwordValidation.hasLetterCases}
56
- label={t('FieldAi.secret.passwordTooltip.hasLetterCases')}
57
- layoutType={layoutType}
58
- shouldHide={isTouchDevice}
59
- animated={animatedKey === 'hasLetterCases'}
60
- />
61
- <CheckItem
62
- checked={passwordValidation.hasNumber}
63
- label={t('FieldAi.secret.passwordTooltip.hasNumber')}
64
- layoutType={layoutType}
65
- shouldHide={isTouchDevice}
66
- animated={animatedKey === 'hasNumber'}
67
- />
68
- <CheckItem
69
- checked={passwordValidation.hasSymbol}
70
- label={t('FieldAi.secret.passwordTooltip.hasSymbol')}
71
- layoutType={layoutType}
72
- shouldHide={isTouchDevice}
73
- animated={animatedKey === 'hasSymbol'}
74
- />
75
- <CheckItem
76
- checked={passwordValidation.noSpaces}
77
- label={t('FieldAi.secret.passwordTooltip.noSpaces')}
78
- layoutType={layoutType}
79
- shouldHide={isTouchDevice}
80
- animated={animatedKey === 'noSpaces'}
81
- />
82
- </div>
83
- </div>
84
- );
85
- }
@@ -1 +0,0 @@
1
- export * from './PasswordValidation';
@@ -1,34 +0,0 @@
1
- @use '@cloud-ru/figma-tokens-cloud-platform/build/scss/styles-theme-variables' as ste;
2
-
3
- .tooltipText {
4
- display: flex;
5
- flex-direction: column;
6
- }
7
-
8
- .validationList {
9
- display: flex;
10
- flex-direction: column;
11
- gap: 12px;
12
- }
13
-
14
- .validationItemsContainer {
15
- @include ste.composite-var(ste.$sans-body-m);
16
- color: ste.$sys-neutral-text-main;
17
-
18
- display: flex;
19
- flex-direction: column;
20
- gap: 12px;
21
-
22
- &[data-layout-type='mobile'],
23
- &[data-layout-type='tablet'] {
24
- gap: 8px;
25
- @include ste.composite-var(ste.$sans-body-s);
26
- padding: 8px 16px;
27
-
28
-
29
- .validationList {
30
- gap: 2px;
31
- }
32
- }
33
- }
34
-
@@ -1,113 +0,0 @@
1
- import cn from 'classnames';
2
- import {
3
- ChangeEvent,
4
- ChangeEventHandler,
5
- FocusEventHandler,
6
- forwardRef,
7
- KeyboardEventHandler,
8
- MouseEventHandler,
9
- RefAttributes,
10
- useState,
11
- } from 'react';
12
- import TextareaAutosize from 'react-textarea-autosize';
13
-
14
- import { InputPrivateProps } from '@snack-uikit/input-private';
15
- import { extractSupportProps, useLayoutEffect, WithSupportProps } from '@snack-uikit/utils';
16
-
17
- import styles from './styles.module.scss';
18
-
19
- export type TextAreaProps = RefAttributes<HTMLTextAreaElement> &
20
- WithSupportProps<{
21
- /** HTML-аттрибут name */
22
- name?: string;
23
- /** HTML-аттрибут value */
24
- value?: string;
25
- /** Колбек смены значения */
26
- onChange?(value: string, e: ChangeEvent<HTMLTextAreaElement>): void;
27
- /** HTML-аттрибут id */
28
- id?: string;
29
- className?: string;
30
- /** Плейсхолдер */
31
- placeholder?: string;
32
- /** Является ли поле доступным только на чтение */
33
- readonly?: boolean;
34
- /** Является ли поле деактивированным */
35
- disabled?: boolean;
36
- /** Включен ли автокомплит */
37
- autoComplete?: boolean;
38
- /** Максимальное кол-во символов */
39
- maxLength?: number;
40
- /** Колбек получения фокуса */
41
- onFocus?: FocusEventHandler<HTMLTextAreaElement>;
42
- /** Колбек потери фокуса */
43
- onBlur?: FocusEventHandler<HTMLTextAreaElement>;
44
- /** Колбек нажатия клавиши клавиатуры */
45
- onKeyDown?: KeyboardEventHandler<HTMLTextAreaElement>;
46
- /** HTML-аттрибут tab-index */
47
- tabIndex?: number;
48
- /** Минимальное кол-во строк, до которого размер поля может быть увеличен @default 3*/
49
- minRows?: number;
50
- /** Включение проверки орфографии @default true*/
51
- spellCheck?: boolean;
52
- /** Режим работы экранной клавиатуры */
53
- inputMode?: InputPrivateProps['inputMode'];
54
- }>;
55
-
56
- export const TextArea = forwardRef<HTMLTextAreaElement, TextAreaProps>(
57
- (
58
- {
59
- name,
60
- value = '',
61
- onChange,
62
- placeholder,
63
- id,
64
- className,
65
- disabled = false,
66
- readonly = false,
67
- autoComplete = false,
68
- maxLength,
69
- onFocus,
70
- onBlur,
71
- onKeyDown,
72
- tabIndex,
73
- minRows = 3,
74
- spellCheck,
75
- inputMode,
76
- ...rest
77
- },
78
- ref,
79
- ) => {
80
- // fix of height on the initial render
81
- // see https://github.com/Andarist/react-textarea-autosize/issues/337#issuecomment-1024980737
82
- const [, setIsRerendered] = useState(false);
83
- useLayoutEffect(() => setIsRerendered(true), []);
84
-
85
- const onChangeHandler: ChangeEventHandler<HTMLTextAreaElement> = e => onChange?.(e.target.value, e);
86
- const stopPropagation: MouseEventHandler<HTMLTextAreaElement> = e => e.stopPropagation();
87
-
88
- return (
89
- <TextareaAutosize
90
- id={id}
91
- name={name}
92
- value={value}
93
- ref={ref}
94
- className={cn(className, styles.textarea)}
95
- autoComplete={autoComplete ? 'on' : 'off'}
96
- placeholder={placeholder}
97
- disabled={disabled}
98
- readOnly={readonly}
99
- maxLength={maxLength}
100
- onChange={onChangeHandler}
101
- onClick={stopPropagation}
102
- onFocus={onFocus}
103
- onBlur={onBlur}
104
- onKeyDown={onKeyDown}
105
- tabIndex={tabIndex}
106
- minRows={minRows}
107
- spellCheck={spellCheck}
108
- inputMode={inputMode}
109
- {...extractSupportProps(rest)}
110
- />
111
- );
112
- },
113
- );
@@ -1 +0,0 @@
1
- export * from './TextArea';
@@ -1,35 +0,0 @@
1
- @use '@cloud-ru/figma-tokens-cloud-platform/build/scss/components/styles-tokens-element' as ste;
2
-
3
- .textarea {
4
- resize: none;
5
-
6
- box-sizing: border-box;
7
- width: 100%;
8
- max-width: 100%;
9
- margin: 0;
10
- padding: 0;
11
-
12
- color: ste.simple-var(ste.$sys-neutral-text-main);
13
-
14
- background-color: transparent;
15
- border: none;
16
- border-radius: 0;
17
- outline: 0;
18
-
19
- &::placeholder {
20
- color: ste.simple-var(ste.$sys-neutral-text-disabled);
21
- }
22
-
23
- &::-webkit-scrollbar {
24
- width: 0;
25
- max-width: 0;
26
- }
27
-
28
- &:read-only {
29
- color: ste.simple-var(ste.$sys-neutral-text-support);
30
- }
31
-
32
- &[disabled] {
33
- color: ste.simple-var(ste.$sys-neutral-text-disabled);
34
- }
35
- }
@@ -1,63 +0,0 @@
1
- import { ReactNode } from 'react';
2
-
3
- import { AdaptiveTooltip } from '@cloud-ru/uikit-product-mobile-tooltip';
4
- import { WithLayoutType } from '@cloud-ru/uikit-product-utils';
5
-
6
- import { isTouchDevice } from '../../../../helpers';
7
- import { ValidationPassword, ValidationPasswordKey } from '../../utils';
8
- import { PasswordValidation } from '../PasswordValidation';
9
- import styles from './styles.module.scss';
10
-
11
- export type WithPasswordTooltipProps = WithLayoutType<{
12
- showValidation?: boolean;
13
- children: ReactNode;
14
- passwordValidation: ValidationPassword;
15
- animatedKey?: ValidationPasswordKey | null;
16
- }>;
17
-
18
- export function WithPasswordValidation({
19
- showValidation,
20
- passwordValidation,
21
- layoutType,
22
- children,
23
- animatedKey,
24
- }: WithPasswordTooltipProps) {
25
- if (isTouchDevice(layoutType)) {
26
- if (showValidation) {
27
- return (
28
- <div className={styles.validationContainer}>
29
- <PasswordValidation
30
- passwordValidation={passwordValidation}
31
- layoutType={layoutType}
32
- animatedKey={animatedKey}
33
- />
34
-
35
- {children}
36
- </div>
37
- );
38
- }
39
-
40
- return children;
41
- }
42
-
43
- if (showValidation) {
44
- return (
45
- <AdaptiveTooltip
46
- placement={'left-end'}
47
- layoutType={layoutType}
48
- tip={
49
- <PasswordValidation
50
- passwordValidation={passwordValidation}
51
- layoutType={layoutType}
52
- animatedKey={animatedKey}
53
- />
54
- }
55
- offset={8}
56
- >
57
- {children}
58
- </AdaptiveTooltip>
59
- );
60
- }
61
-
62
- return children;
63
- }
@@ -1 +0,0 @@
1
- export * from './WithPasswordValidation';
@@ -1,8 +0,0 @@
1
- @use '@cloud-ru/figma-tokens-cloud-platform/build/scss/styles-theme-variables' as ste;
2
-
3
- .validationContainer {
4
- display: flex;
5
- flex-direction: column;
6
- gap: 8px;
7
- background-color: ste.$sys-neutral-background1-level;
8
- }
@@ -1 +0,0 @@
1
- export * from './FieldAi';
@@ -1,85 +0,0 @@
1
- /* stylelint-disable color-no-hex */
2
- @use '@cloud-ru/figma-tokens-cloud-platform/build/scss/components/styles-tokens-fields' as ste;
3
- @use '@cloud-ru/figma-tokens-cloud-platform/build/scss/styles-theme-variables' as stv;
4
-
5
- .wrapper {
6
- display: flex;
7
- flex-direction: column;
8
- gap: ste.$dimension-050m;
9
- position: relative;
10
- }
11
-
12
- .passwordWrapper {
13
- gap: 0;
14
- }
15
-
16
- .alert {
17
- display: flex;
18
- gap: 8px;
19
- padding: 4px 8px;
20
- border-radius: 8px 8px 0 0;
21
- border: 1px solid stv.$sys-blue-decor-activated;
22
- background-color: stv.$sys-blue-decor-default;
23
- box-sizing: border-box;
24
- height: 38px;
25
- position: absolute;
26
- left: 0;
27
- top: -26px;
28
- width: 100%;
29
- color: stv.$sys-neutral-text-main;
30
- }
31
-
32
- .alertText {
33
- flex: 1;
34
- min-width: 0;
35
- color: stv.$sys-neutral-text-main;
36
- }
37
-
38
- .secured {
39
- textarea {
40
- -webkit-text-security: disc;
41
- /* stylelint-disable-next-line property-no-unknown */
42
- text-security: disc;
43
- }
44
- }
45
-
46
- .mobileSubmitButton {
47
- /* stylelint-disable-next-line declaration-no-important */
48
- position: relative !important;
49
- /* stylelint-disable-next-line declaration-no-important */
50
- flex-shrink: 0 !important;
51
-
52
- &:after {
53
- content: '';
54
- display: flex;
55
- width: 48px;
56
- height: 48px;
57
- position: absolute;
58
- top: 50%;
59
- left: 50%;
60
- transform: translate(-50%, -50%);
61
- }
62
- }
63
-
64
- .submitButton {
65
- &:not([data-disabled]) {
66
- background: radial-gradient(229.88% 112% at 37.5% 77.08%, #26D07C 19.86%, #5FD7C2 50.73%, #7CB5F2 89.88%);
67
- }
68
- }
69
-
70
- .textarea {
71
- & > :first-child {
72
- &[data-validation='default']:not([data-readonly]):not([data-disable-focus]):focus-within:not([data-disabled]) {
73
- border-color: transparent;
74
- background:
75
- linear-gradient(var(--sys-neutral-background2-level), var(--sys-neutral-background2-level) 0) padding-box,
76
- radial-gradient(
77
- 57.79% 100% at 50% 0%,
78
- #7cb5f2 38%,
79
- #5fd7c2 79%,
80
- #26d07c 90%
81
- )
82
- border-box;
83
- }
84
- }
85
- }
@@ -1,27 +0,0 @@
1
- export type ValidationPassword = {
2
- onlyLatin: boolean;
3
- minLength: boolean;
4
- hasLetterCases: boolean;
5
- hasNumber: boolean;
6
- hasSymbol: boolean;
7
- noSpaces: boolean;
8
- };
9
-
10
- export type ValidationPasswordKey = keyof ValidationPassword;
11
-
12
- const MIN_PASSWORD_LENGTH = 8;
13
- const NUMBER_REGEX = /[0-9]/;
14
- const CAPITAL_REGEX = /\p{Lu}/u;
15
- const LOWER_REGEX = /\p{Ll}/u;
16
- const SYMBOLS_REGEX = /[\p{P}\p{S}]/u;
17
- const NO_SPACES = /^\S*$/u;
18
- const LATIN_REGEX = /^[a-zA-Z0-9\p{P}\p{S}]+$/u;
19
-
20
- export const getValidationPassword = (password: string = ''): ValidationPassword => ({
21
- onlyLatin: Boolean(password.match(LATIN_REGEX)),
22
- minLength: password.length >= MIN_PASSWORD_LENGTH,
23
- hasLetterCases: Boolean(password.match(CAPITAL_REGEX)) && Boolean(password.match(LOWER_REGEX)),
24
- hasNumber: Boolean(password.match(NUMBER_REGEX)),
25
- hasSymbol: Boolean(password.match(SYMBOLS_REGEX)),
26
- noSpaces: Boolean(password.match(NO_SPACES)),
27
- });
@@ -1,125 +0,0 @@
1
- import cn from 'classnames';
2
- import { forwardRef, useImperativeHandle } from 'react';
3
-
4
- import { FieldDecorator, FieldDecoratorProps } from '@snack-uikit/fields';
5
-
6
- import { Cell, ResendCode, type ResendCodeProps } from './components';
7
- import { FIELD_CODE_DEFAULT_FOCUS_EFFECTS, type FieldCodeFocusEffect } from './constants';
8
- import { useCodeInput, UseCodeInputParams, useFieldHelpers, useFocusCell } from './hooks';
9
- import styles from './styles.module.scss';
10
- import { getCellValidationState } from './utils';
11
-
12
- export type FieldCodeRef = {
13
- /** Перенести фокус на ячейку с индексом `index` */
14
- moveFocus: (index: number) => void;
15
- /** Убрать фокус со всех ячеек кода */
16
- blurFields: () => void;
17
- /** Сбросить значение кода */
18
- resetCode: () => void;
19
- };
20
-
21
- /** Собственные пропсы `FieldCode` */
22
- export type FieldCodeOwnProps = {
23
- /** CSS-класс компонента */
24
- className?: string;
25
- /** CSS-класс ячейки кода */
26
- cellClassName?: string;
27
- /** Позиции, после которых нужно вставить пробел (индексы символов, после которых будет пробел) */
28
- spacing?: number[];
29
- /** Подсветить пустые символы кода */
30
- showEmptyChars?: boolean;
31
- /** Компонент отправки нового кода */
32
- resendCode?: ResendCodeProps;
33
- /** Сценарии автофокуса; по умолчанию — первая ячейка при монтировании и после сброса (см. `FieldCodeFocusEffect`) */
34
- focusEffects?: readonly FieldCodeFocusEffect[];
35
- /** Сообщение при неверном коде, если не передан свой `error` */
36
- invalidCode?: string;
37
- };
38
-
39
- export type FieldCodeProps = FieldCodeOwnProps &
40
- Omit<UseCodeInputParams, 'moveFocus'> &
41
- Pick<FieldDecoratorProps, 'size' | 'disabled' | 'label' | 'error' | 'data-test-id'>;
42
-
43
- export const FieldCode = forwardRef<FieldCodeRef, FieldCodeProps>(function FieldCode(props, ref) {
44
- const {
45
- codeLength,
46
- className,
47
- cellClassName,
48
- value,
49
- onChange,
50
- spacing,
51
- onComplete,
52
- size,
53
- disabled,
54
- label,
55
- error,
56
- invalidCode,
57
- showEmptyChars,
58
- resendCode,
59
- focusEffects = FIELD_CODE_DEFAULT_FOCUS_EFFECTS,
60
- 'data-test-id': dataTestId,
61
- } = props;
62
-
63
- const { inputsRef, moveFocus, blurFields } = useFocusCell(codeLength);
64
- const { code, cellHandlers, onChangeCode } = useCodeInput({ value, onChange, codeLength, moveFocus, onComplete });
65
- const { resetCode } = useFieldHelpers({
66
- onChangeCode,
67
- focusEffects,
68
- moveFocus,
69
- showEmptyChars,
70
- code,
71
- codeLength,
72
- });
73
-
74
- useImperativeHandle(
75
- ref,
76
- () => ({
77
- moveFocus,
78
- blurFields,
79
- resetCode,
80
- }),
81
- [moveFocus, blurFields, resetCode],
82
- );
83
-
84
- const resolvedError = error ?? invalidCode;
85
-
86
- const resolvedDecoratorProps = {
87
- label,
88
- disabled,
89
- size,
90
- error: resolvedError,
91
- };
92
-
93
- return (
94
- <div className={cn(styles.fieldCode, className)} {...(dataTestId ? { 'data-test-id': dataTestId } : undefined)}>
95
- <FieldDecorator {...resolvedDecoratorProps}>
96
- <div className={styles.codeContainer} data-size={size}>
97
- {code.map((char, index) => (
98
- <Cell
99
- ref={inputRef => {
100
- if (inputRef) {
101
- inputsRef.current[index] = inputRef;
102
- }
103
- }}
104
- key={index}
105
- className={cn(spacing?.includes(index) && styles.cellSpacing, cellClassName)}
106
- size={size}
107
- value={char}
108
- disabled={disabled}
109
- autoComplete={index === 0 ? 'one-time-code' : undefined}
110
- onKeyDown={e => cellHandlers.onKeyDown(e, index)}
111
- onPaste={cellHandlers.onPaste}
112
- onChange={e => cellHandlers.onChange(e, index)}
113
- validationState={getCellValidationState(char, showEmptyChars, Boolean(resolvedError))}
114
- />
115
- ))}
116
- </div>
117
- </FieldDecorator>
118
-
119
- {resendCode ? <ResendCode {...resendCode} size={resendCode.size ?? size} /> : null}
120
- </div>
121
- );
122
- });
123
-
124
- export type { FieldCodeFocusEffect } from './constants';
125
- export { FIELD_CODE_DEFAULT_FOCUS_EFFECTS } from './constants';