@cloud-ru/uikit-product-fields-predefined 0.13.3 → 0.13.4

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 (224) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/cjs/components/AIDisclaimer/AIDisclaimer.d.ts +4 -0
  3. package/dist/cjs/components/AIDisclaimer/AIDisclaimer.js +13 -0
  4. package/dist/cjs/components/AIDisclaimer/index.d.ts +1 -0
  5. package/dist/cjs/components/AIDisclaimer/index.js +17 -0
  6. package/dist/cjs/components/AIDisclaimer/styles.module.css +21 -0
  7. package/dist/cjs/components/FieldAi/FieldAi.d.ts +20 -0
  8. package/dist/cjs/components/FieldAi/FieldAi.js +66 -0
  9. package/dist/cjs/components/FieldAi/components/CheckItem/CheckItem.d.ts +8 -0
  10. package/dist/cjs/components/FieldAi/components/CheckItem/CheckItem.js +28 -0
  11. package/dist/cjs/components/FieldAi/components/CheckItem/index.d.ts +1 -0
  12. package/dist/cjs/components/FieldAi/components/CheckItem/index.js +17 -0
  13. package/dist/cjs/components/FieldAi/components/CheckItem/styles.module.css +22 -0
  14. package/dist/cjs/components/FieldAi/components/MobileFieldAi/MobileFieldAi.d.ts +5 -0
  15. package/dist/cjs/components/FieldAi/components/MobileFieldAi/MobileFieldAi.js +31 -0
  16. package/dist/cjs/components/FieldAi/components/MobileFieldAi/index.d.ts +1 -0
  17. package/dist/cjs/components/FieldAi/components/MobileFieldAi/index.js +17 -0
  18. package/dist/cjs/components/FieldAi/components/MobileFieldAi/styles.module.css +87 -0
  19. package/dist/cjs/components/FieldAi/components/PasswordValidation/PasswordValidation.d.ts +6 -0
  20. package/dist/cjs/components/FieldAi/components/PasswordValidation/PasswordValidation.js +23 -0
  21. package/dist/cjs/components/FieldAi/components/PasswordValidation/index.d.ts +1 -0
  22. package/dist/cjs/components/FieldAi/components/PasswordValidation/index.js +17 -0
  23. package/dist/cjs/components/FieldAi/components/PasswordValidation/styles.module.css +35 -0
  24. package/dist/cjs/components/FieldAi/components/TextArea/TextArea.d.ts +39 -0
  25. package/dist/cjs/components/FieldAi/components/TextArea/TextArea.js +33 -0
  26. package/dist/cjs/components/FieldAi/components/TextArea/index.d.ts +1 -0
  27. package/dist/cjs/components/FieldAi/components/TextArea/index.js +17 -0
  28. package/dist/cjs/components/FieldAi/components/TextArea/styles.module.css +32 -0
  29. package/dist/cjs/components/FieldAi/components/WithPasswordValidation/WithPasswordValidation.d.ts +9 -0
  30. package/dist/cjs/components/FieldAi/components/WithPasswordValidation/WithPasswordValidation.js +23 -0
  31. package/dist/cjs/components/FieldAi/components/WithPasswordValidation/index.d.ts +1 -0
  32. package/dist/cjs/components/FieldAi/components/WithPasswordValidation/index.js +17 -0
  33. package/dist/cjs/components/FieldAi/components/WithPasswordValidation/styles.module.css +5 -0
  34. package/dist/cjs/components/FieldAi/index.d.ts +1 -0
  35. package/dist/cjs/components/FieldAi/index.js +17 -0
  36. package/dist/cjs/components/FieldAi/styles.module.css +25 -0
  37. package/dist/cjs/components/FieldAi/utils.d.ts +9 -0
  38. package/dist/cjs/components/FieldAi/utils.js +19 -0
  39. package/dist/cjs/components/FieldChat/FieldChat.d.ts +15 -0
  40. package/dist/cjs/components/FieldChat/FieldChat.js +55 -0
  41. package/dist/cjs/components/FieldChat/components/Attachments/Attachments.d.ts +6 -0
  42. package/dist/cjs/components/FieldChat/components/Attachments/Attachments.js +20 -0
  43. package/dist/cjs/components/FieldChat/components/Attachments/index.d.ts +1 -0
  44. package/dist/cjs/components/FieldChat/components/Attachments/index.js +17 -0
  45. package/dist/cjs/components/FieldChat/components/Attachments/styles.module.css +9 -0
  46. package/dist/cjs/components/FieldChat/index.d.ts +1 -0
  47. package/dist/cjs/components/FieldChat/index.js +17 -0
  48. package/dist/cjs/components/FieldChat/styles.module.css +12 -0
  49. package/dist/cjs/components/FieldPhone/FieldPhone.d.ts +25 -0
  50. package/dist/cjs/components/FieldPhone/FieldPhone.js +131 -0
  51. package/dist/cjs/components/FieldPhone/__tests__/constants.d.ts +5 -0
  52. package/dist/cjs/components/FieldPhone/__tests__/constants.js +29 -0
  53. package/dist/cjs/components/FieldPhone/__tests__/formatPhoneNumber.spec.d.ts +1 -0
  54. package/dist/cjs/components/FieldPhone/__tests__/formatPhoneNumber.spec.js +14 -0
  55. package/dist/cjs/components/FieldPhone/__tests__/matchMedia.d.ts +1 -0
  56. package/dist/cjs/components/FieldPhone/__tests__/matchMedia.js +16 -0
  57. package/dist/cjs/components/FieldPhone/constants.d.ts +1 -0
  58. package/dist/cjs/components/FieldPhone/constants.js +4 -0
  59. package/dist/cjs/components/FieldPhone/countries.d.ts +3500 -0
  60. package/dist/cjs/components/FieldPhone/countries.js +1442 -0
  61. package/dist/cjs/components/FieldPhone/hooks/index.d.ts +2 -0
  62. package/dist/cjs/components/FieldPhone/hooks/index.js +18 -0
  63. package/dist/cjs/components/FieldPhone/hooks/useCountries.d.ts +2 -0
  64. package/dist/cjs/components/FieldPhone/hooks/useCountries.js +36 -0
  65. package/dist/cjs/components/FieldPhone/hooks/useMapCountryToOptions.d.ts +2 -0
  66. package/dist/cjs/components/FieldPhone/hooks/useMapCountryToOptions.js +19 -0
  67. package/dist/cjs/components/FieldPhone/index.d.ts +5 -0
  68. package/dist/cjs/components/FieldPhone/index.js +23 -0
  69. package/dist/cjs/components/FieldPhone/styles.module.css +3 -0
  70. package/dist/cjs/components/FieldPhone/types.d.ts +31 -0
  71. package/dist/cjs/components/FieldPhone/types.js +2 -0
  72. package/dist/cjs/components/FieldPhone/utils.d.ts +7 -0
  73. package/dist/cjs/components/FieldPhone/utils.js +57 -0
  74. package/dist/cjs/components/SelectCreate/SelectCreate.d.ts +21 -0
  75. package/dist/cjs/components/SelectCreate/SelectCreate.js +66 -0
  76. package/dist/cjs/components/SelectCreate/SelectFooter/SelectFooter.d.ts +7 -0
  77. package/dist/cjs/components/SelectCreate/SelectFooter/SelectFooter.js +16 -0
  78. package/dist/cjs/components/SelectCreate/SelectFooter/index.d.ts +1 -0
  79. package/dist/cjs/components/SelectCreate/SelectFooter/index.js +17 -0
  80. package/dist/cjs/components/SelectCreate/SelectFooter/styles.module.css +6 -0
  81. package/dist/cjs/components/SelectCreate/index.d.ts +1 -0
  82. package/dist/cjs/components/SelectCreate/index.js +17 -0
  83. package/dist/cjs/components/SelectCreate/types.d.ts +28 -0
  84. package/dist/cjs/components/SelectCreate/types.js +2 -0
  85. package/dist/cjs/components/SelectCreate/useSelectDataStates.d.ts +10 -0
  86. package/dist/cjs/components/SelectCreate/useSelectDataStates.js +26 -0
  87. package/dist/cjs/components/index.d.ts +5 -0
  88. package/dist/cjs/components/index.js +21 -0
  89. package/dist/cjs/helperComponents/FieldSubmitButton/FieldSubmitButton.d.ts +9 -0
  90. package/dist/cjs/helperComponents/FieldSubmitButton/FieldSubmitButton.js +15 -0
  91. package/dist/cjs/helperComponents/FieldSubmitButton/index.d.ts +1 -0
  92. package/dist/cjs/helperComponents/FieldSubmitButton/index.js +17 -0
  93. package/dist/cjs/helperComponents/TextAreaActionsFooter/TextAreaActionsFooter.d.ts +7 -0
  94. package/dist/cjs/helperComponents/TextAreaActionsFooter/TextAreaActionsFooter.js +12 -0
  95. package/dist/cjs/helperComponents/TextAreaActionsFooter/index.d.ts +1 -0
  96. package/dist/cjs/helperComponents/TextAreaActionsFooter/index.js +17 -0
  97. package/dist/cjs/helperComponents/TextAreaActionsFooter/styles.module.css +21 -0
  98. package/dist/cjs/helpers/capitalize.d.ts +1 -0
  99. package/dist/cjs/helpers/capitalize.js +6 -0
  100. package/dist/cjs/helpers/getSymbolsRangeFromMask.d.ts +8 -0
  101. package/dist/cjs/helpers/getSymbolsRangeFromMask.js +17 -0
  102. package/dist/cjs/helpers/index.d.ts +3 -0
  103. package/dist/cjs/helpers/index.js +19 -0
  104. package/dist/cjs/helpers/isTouchDevice.d.ts +2 -0
  105. package/dist/cjs/helpers/isTouchDevice.js +6 -0
  106. package/dist/cjs/hooks/index.d.ts +1 -0
  107. package/dist/cjs/hooks/index.js +17 -0
  108. package/dist/cjs/hooks/useOpen.d.ts +5 -0
  109. package/dist/cjs/hooks/useOpen.js +18 -0
  110. package/dist/cjs/index.d.ts +3 -0
  111. package/dist/cjs/index.js +22 -0
  112. package/dist/esm/components/AIDisclaimer/AIDisclaimer.d.ts +4 -0
  113. package/dist/esm/components/AIDisclaimer/AIDisclaimer.js +7 -0
  114. package/dist/esm/components/AIDisclaimer/index.d.ts +1 -0
  115. package/dist/esm/components/AIDisclaimer/index.js +1 -0
  116. package/dist/esm/components/AIDisclaimer/styles.module.css +21 -0
  117. package/dist/esm/components/FieldAi/FieldAi.d.ts +20 -0
  118. package/dist/esm/components/FieldAi/FieldAi.js +60 -0
  119. package/dist/esm/components/FieldAi/components/CheckItem/CheckItem.d.ts +8 -0
  120. package/dist/esm/components/FieldAi/components/CheckItem/CheckItem.js +22 -0
  121. package/dist/esm/components/FieldAi/components/CheckItem/index.d.ts +1 -0
  122. package/dist/esm/components/FieldAi/components/CheckItem/index.js +1 -0
  123. package/dist/esm/components/FieldAi/components/CheckItem/styles.module.css +22 -0
  124. package/dist/esm/components/FieldAi/components/MobileFieldAi/MobileFieldAi.d.ts +5 -0
  125. package/dist/esm/components/FieldAi/components/MobileFieldAi/MobileFieldAi.js +25 -0
  126. package/dist/esm/components/FieldAi/components/MobileFieldAi/index.d.ts +1 -0
  127. package/dist/esm/components/FieldAi/components/MobileFieldAi/index.js +1 -0
  128. package/dist/esm/components/FieldAi/components/MobileFieldAi/styles.module.css +87 -0
  129. package/dist/esm/components/FieldAi/components/PasswordValidation/PasswordValidation.d.ts +6 -0
  130. package/dist/esm/components/FieldAi/components/PasswordValidation/PasswordValidation.js +17 -0
  131. package/dist/esm/components/FieldAi/components/PasswordValidation/index.d.ts +1 -0
  132. package/dist/esm/components/FieldAi/components/PasswordValidation/index.js +1 -0
  133. package/dist/esm/components/FieldAi/components/PasswordValidation/styles.module.css +35 -0
  134. package/dist/esm/components/FieldAi/components/TextArea/TextArea.d.ts +39 -0
  135. package/dist/esm/components/FieldAi/components/TextArea/TextArea.js +27 -0
  136. package/dist/esm/components/FieldAi/components/TextArea/index.d.ts +1 -0
  137. package/dist/esm/components/FieldAi/components/TextArea/index.js +1 -0
  138. package/dist/esm/components/FieldAi/components/TextArea/styles.module.css +32 -0
  139. package/dist/esm/components/FieldAi/components/WithPasswordValidation/WithPasswordValidation.d.ts +9 -0
  140. package/dist/esm/components/FieldAi/components/WithPasswordValidation/WithPasswordValidation.js +17 -0
  141. package/dist/esm/components/FieldAi/components/WithPasswordValidation/index.d.ts +1 -0
  142. package/dist/esm/components/FieldAi/components/WithPasswordValidation/index.js +1 -0
  143. package/dist/esm/components/FieldAi/components/WithPasswordValidation/styles.module.css +5 -0
  144. package/dist/esm/components/FieldAi/index.d.ts +1 -0
  145. package/dist/esm/components/FieldAi/index.js +1 -0
  146. package/dist/esm/components/FieldAi/styles.module.css +25 -0
  147. package/dist/esm/components/FieldAi/utils.d.ts +9 -0
  148. package/dist/esm/components/FieldAi/utils.js +15 -0
  149. package/dist/esm/components/FieldChat/FieldChat.d.ts +15 -0
  150. package/dist/esm/components/FieldChat/FieldChat.js +49 -0
  151. package/dist/esm/components/FieldChat/components/Attachments/Attachments.d.ts +6 -0
  152. package/dist/esm/components/FieldChat/components/Attachments/Attachments.js +14 -0
  153. package/dist/esm/components/FieldChat/components/Attachments/index.d.ts +1 -0
  154. package/dist/esm/components/FieldChat/components/Attachments/index.js +1 -0
  155. package/dist/esm/components/FieldChat/components/Attachments/styles.module.css +9 -0
  156. package/dist/esm/components/FieldChat/index.d.ts +1 -0
  157. package/dist/esm/components/FieldChat/index.js +1 -0
  158. package/dist/esm/components/FieldChat/styles.module.css +12 -0
  159. package/dist/esm/components/FieldPhone/FieldPhone.d.ts +25 -0
  160. package/dist/esm/components/FieldPhone/FieldPhone.js +125 -0
  161. package/dist/esm/components/FieldPhone/__tests__/constants.d.ts +5 -0
  162. package/dist/esm/components/FieldPhone/__tests__/constants.js +26 -0
  163. package/dist/esm/components/FieldPhone/__tests__/formatPhoneNumber.spec.d.ts +1 -0
  164. package/dist/esm/components/FieldPhone/__tests__/formatPhoneNumber.spec.js +12 -0
  165. package/dist/esm/components/FieldPhone/__tests__/matchMedia.d.ts +1 -0
  166. package/dist/esm/components/FieldPhone/__tests__/matchMedia.js +14 -0
  167. package/dist/esm/components/FieldPhone/constants.d.ts +1 -0
  168. package/dist/esm/components/FieldPhone/constants.js +1 -0
  169. package/dist/esm/components/FieldPhone/countries.d.ts +3500 -0
  170. package/dist/esm/components/FieldPhone/countries.js +1436 -0
  171. package/dist/esm/components/FieldPhone/hooks/index.d.ts +2 -0
  172. package/dist/esm/components/FieldPhone/hooks/index.js +2 -0
  173. package/dist/esm/components/FieldPhone/hooks/useCountries.d.ts +2 -0
  174. package/dist/esm/components/FieldPhone/hooks/useCountries.js +33 -0
  175. package/dist/esm/components/FieldPhone/hooks/useMapCountryToOptions.d.ts +2 -0
  176. package/dist/esm/components/FieldPhone/hooks/useMapCountryToOptions.js +16 -0
  177. package/dist/esm/components/FieldPhone/index.d.ts +5 -0
  178. package/dist/esm/components/FieldPhone/index.js +4 -0
  179. package/dist/esm/components/FieldPhone/styles.module.css +3 -0
  180. package/dist/esm/components/FieldPhone/types.d.ts +31 -0
  181. package/dist/esm/components/FieldPhone/types.js +1 -0
  182. package/dist/esm/components/FieldPhone/utils.d.ts +7 -0
  183. package/dist/esm/components/FieldPhone/utils.js +51 -0
  184. package/dist/esm/components/SelectCreate/SelectCreate.d.ts +21 -0
  185. package/dist/esm/components/SelectCreate/SelectCreate.js +63 -0
  186. package/dist/esm/components/SelectCreate/SelectFooter/SelectFooter.d.ts +7 -0
  187. package/dist/esm/components/SelectCreate/SelectFooter/SelectFooter.js +10 -0
  188. package/dist/esm/components/SelectCreate/SelectFooter/index.d.ts +1 -0
  189. package/dist/esm/components/SelectCreate/SelectFooter/index.js +1 -0
  190. package/dist/esm/components/SelectCreate/SelectFooter/styles.module.css +6 -0
  191. package/dist/esm/components/SelectCreate/index.d.ts +1 -0
  192. package/dist/esm/components/SelectCreate/index.js +1 -0
  193. package/dist/esm/components/SelectCreate/types.d.ts +28 -0
  194. package/dist/esm/components/SelectCreate/types.js +1 -0
  195. package/dist/esm/components/SelectCreate/useSelectDataStates.d.ts +10 -0
  196. package/dist/esm/components/SelectCreate/useSelectDataStates.js +23 -0
  197. package/dist/esm/components/index.d.ts +5 -0
  198. package/dist/esm/components/index.js +5 -0
  199. package/dist/esm/helperComponents/FieldSubmitButton/FieldSubmitButton.d.ts +9 -0
  200. package/dist/esm/helperComponents/FieldSubmitButton/FieldSubmitButton.js +12 -0
  201. package/dist/esm/helperComponents/FieldSubmitButton/index.d.ts +1 -0
  202. package/dist/esm/helperComponents/FieldSubmitButton/index.js +1 -0
  203. package/dist/esm/helperComponents/TextAreaActionsFooter/TextAreaActionsFooter.d.ts +7 -0
  204. package/dist/esm/helperComponents/TextAreaActionsFooter/TextAreaActionsFooter.js +6 -0
  205. package/dist/esm/helperComponents/TextAreaActionsFooter/index.d.ts +1 -0
  206. package/dist/esm/helperComponents/TextAreaActionsFooter/index.js +1 -0
  207. package/dist/esm/helperComponents/TextAreaActionsFooter/styles.module.css +21 -0
  208. package/dist/esm/helpers/capitalize.d.ts +1 -0
  209. package/dist/esm/helpers/capitalize.js +3 -0
  210. package/dist/esm/helpers/getSymbolsRangeFromMask.d.ts +8 -0
  211. package/dist/esm/helpers/getSymbolsRangeFromMask.js +14 -0
  212. package/dist/esm/helpers/index.d.ts +3 -0
  213. package/dist/esm/helpers/index.js +3 -0
  214. package/dist/esm/helpers/isTouchDevice.d.ts +2 -0
  215. package/dist/esm/helpers/isTouchDevice.js +3 -0
  216. package/dist/esm/hooks/index.d.ts +1 -0
  217. package/dist/esm/hooks/index.js +1 -0
  218. package/dist/esm/hooks/useOpen.d.ts +5 -0
  219. package/dist/esm/hooks/useOpen.js +15 -0
  220. package/dist/esm/index.d.ts +3 -0
  221. package/dist/esm/index.js +3 -0
  222. package/dist/tsconfig.cjs.tsbuildinfo +1 -0
  223. package/dist/tsconfig.esm.tsbuildinfo +1 -0
  224. package/package.json +9 -8
@@ -0,0 +1,32 @@
1
+ .textarea{
2
+ resize:none;
3
+ box-sizing:border-box;
4
+ width:100%;
5
+ max-width:100%;
6
+ margin:0;
7
+ padding:0;
8
+ color:var(--sys-neutral-text-main, #41424e);
9
+ background-color:transparent;
10
+ border:none;
11
+ border-radius:0;
12
+ outline:0;
13
+ }
14
+ .textarea::-moz-placeholder{
15
+ color:var(--sys-neutral-text-disabled, #aaaebd);
16
+ }
17
+ .textarea::placeholder{
18
+ color:var(--sys-neutral-text-disabled, #aaaebd);
19
+ }
20
+ .textarea::-webkit-scrollbar{
21
+ width:0;
22
+ max-width:0;
23
+ }
24
+ .textarea:-moz-read-only{
25
+ color:var(--sys-neutral-text-support, #6d707f);
26
+ }
27
+ .textarea:read-only{
28
+ color:var(--sys-neutral-text-support, #6d707f);
29
+ }
30
+ .textarea[disabled]{
31
+ color:var(--sys-neutral-text-disabled, #aaaebd);
32
+ }
@@ -0,0 +1,9 @@
1
+ import { ReactNode } from 'react';
2
+ import { WithLayoutType } from '@sbercloud/uikit-product-utils';
3
+ import { ValidationPassword } from '../../utils';
4
+ export type WithPasswordTooltipProps = WithLayoutType<{
5
+ showValidation?: boolean;
6
+ children: ReactNode;
7
+ passwordValidation: ValidationPassword;
8
+ }>;
9
+ export declare function WithPasswordValidation({ showValidation, passwordValidation, layoutType, children, }: WithPasswordTooltipProps): string | number | boolean | import("react/jsx-runtime").JSX.Element | Iterable<ReactNode> | null | undefined;
@@ -0,0 +1,17 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { AdaptiveTooltip } from '@sbercloud/uikit-product-mobile-tooltip';
3
+ import { isTouchDevice } from '../../../../helpers';
4
+ import { PasswordValidation } from '../PasswordValidation';
5
+ import styles from './styles.module.css';
6
+ export function WithPasswordValidation({ showValidation, passwordValidation, layoutType, children, }) {
7
+ if (isTouchDevice(layoutType)) {
8
+ if (showValidation) {
9
+ return (_jsxs("div", { className: styles.validationContainer, children: [_jsx(PasswordValidation, { passwordValidation: passwordValidation, layoutType: layoutType }), children] }));
10
+ }
11
+ return children;
12
+ }
13
+ if (showValidation) {
14
+ return (_jsx(AdaptiveTooltip, { placement: 'left-end', layoutType: layoutType, tip: _jsx(PasswordValidation, { passwordValidation: passwordValidation, layoutType: layoutType }), offset: 8, children: children }));
15
+ }
16
+ return children;
17
+ }
@@ -0,0 +1 @@
1
+ export * from './WithPasswordValidation';
@@ -0,0 +1 @@
1
+ export * from './WithPasswordValidation';
@@ -0,0 +1,5 @@
1
+ .validationContainer{
2
+ display:flex;
3
+ flex-direction:column;
4
+ gap:8px;
5
+ }
@@ -0,0 +1 @@
1
+ export * from './FieldAi';
@@ -0,0 +1 @@
1
+ export * from './FieldAi';
@@ -0,0 +1,25 @@
1
+ .wrapper{
2
+ display:flex;
3
+ flex-direction:column;
4
+ gap:var(--dimension-050m, 4px);
5
+ }
6
+
7
+ .secured textarea{
8
+ -webkit-text-security:disc;
9
+ text-security:disc;
10
+ }
11
+
12
+ .mobileSubmitButton{
13
+ position:relative !important;
14
+ flex-shrink:0 !important;
15
+ }
16
+ .mobileSubmitButton:after{
17
+ content:"";
18
+ display:flex;
19
+ width:48px;
20
+ height:48px;
21
+ position:absolute;
22
+ top:50%;
23
+ left:50%;
24
+ transform:translate(-50%, -50%);
25
+ }
@@ -0,0 +1,9 @@
1
+ export type ValidationPassword = {
2
+ onlyLatin: boolean;
3
+ minLength: boolean;
4
+ hasLetterCases: boolean;
5
+ hasNumber: boolean;
6
+ hasSymbol: boolean;
7
+ noSpaces: boolean;
8
+ };
9
+ export declare const getValidationPassword: (password?: string) => ValidationPassword;
@@ -0,0 +1,15 @@
1
+ const MIN_PASSWORD_LENGTH = 8;
2
+ const NUMBER_REGEX = /[0-9]/;
3
+ const CAPITAL_REGEX = /\p{Lu}/u;
4
+ const LOWER_REGEX = /\p{Ll}/u;
5
+ const SYMBOLS_REGEX = /[\p{P}\p{S}]/u;
6
+ const NO_SPACES = /^\S*$/u;
7
+ const LATIN_REGEX = /^[a-zA-Z0-9\p{P}\p{S}]+$/u;
8
+ export const getValidationPassword = (password = '') => ({
9
+ onlyLatin: Boolean(password.match(LATIN_REGEX)),
10
+ minLength: password.length >= MIN_PASSWORD_LENGTH,
11
+ hasLetterCases: Boolean(password.match(CAPITAL_REGEX)) && Boolean(password.match(LOWER_REGEX)),
12
+ hasNumber: Boolean(password.match(NUMBER_REGEX)),
13
+ hasSymbol: Boolean(password.match(SYMBOLS_REGEX)),
14
+ noSpaces: Boolean(password.match(NO_SPACES)),
15
+ });
@@ -0,0 +1,15 @@
1
+ import { FieldTextAreaProps } from '@sbercloud/uikit-product-mobile-fields';
2
+ import { WithLayoutType } from '@sbercloud/uikit-product-utils';
3
+ import { AttachmentSquareProps } from '@snack-uikit/attachment';
4
+ import { FileUploadProps } from '@snack-uikit/drop-zone';
5
+ export type FieldChatProps = WithLayoutType<Omit<FieldTextAreaProps, 'placeholder' | 'hint' | 'labelTooltip' | 'label' | 'required' | 'size' | 'spellCheck' | 'footer'> & {
6
+ /** Колбек действия при отправке */
7
+ handleSubmit(value: string): void;
8
+ attachment?: Pick<FileUploadProps, 'onFilesUpload' | 'accept'> & {
9
+ /** Список загруженных файлов */
10
+ files?: File[];
11
+ /** Колбек действия при удалении прикрепленного файла */
12
+ onFileDelete: AttachmentSquareProps['onDelete'];
13
+ };
14
+ }>;
15
+ export declare function FieldChat({ handleSubmit: handleSubmitProp, value, layoutType, attachment, ...props }: FieldChatProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,49 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
13
+ import { useMemo } from 'react';
14
+ import { AttachmentSVG } from '@sbercloud/uikit-product-icons';
15
+ import { useLocale } from '@sbercloud/uikit-product-locale';
16
+ import { AdaptiveFieldTextArea } from '@sbercloud/uikit-product-mobile-fields';
17
+ import { ButtonFunction } from '@snack-uikit/button';
18
+ import { FileUpload } from '@snack-uikit/drop-zone';
19
+ import { Tooltip } from '@snack-uikit/tooltip';
20
+ import { FieldSubmitButton } from '../../helperComponents/FieldSubmitButton';
21
+ import { TextAreaActionsFooter } from '../../helperComponents/TextAreaActionsFooter';
22
+ import { Attachments } from './components/Attachments';
23
+ import styles from './styles.module.css';
24
+ export function FieldChat(_a) {
25
+ var { handleSubmit: handleSubmitProp, value, layoutType, attachment } = _a, props = __rest(_a, ["handleSubmit", "value", "layoutType", "attachment"]);
26
+ const { t } = useLocale('FieldsPredefined');
27
+ const isMobile = layoutType === 'mobile';
28
+ const files = useMemo(() => {
29
+ var _a, _b;
30
+ return (_b = (_a = attachment === null || attachment === void 0 ? void 0 : attachment.files) === null || _a === void 0 ? void 0 : _a.map(file => ({
31
+ file,
32
+ onDelete: attachment === null || attachment === void 0 ? void 0 : attachment.onFileDelete,
33
+ }))) !== null && _b !== void 0 ? _b : [];
34
+ }, [attachment === null || attachment === void 0 ? void 0 : attachment.files, attachment === null || attachment === void 0 ? void 0 : attachment.onFileDelete]);
35
+ const isValueValid = (typeof value === 'string' && value.trim().length > 0) || files.length > 0;
36
+ const handleSubmit = () => {
37
+ if (isValueValid) {
38
+ handleSubmitProp(value !== null && value !== void 0 ? value : '');
39
+ }
40
+ };
41
+ const handleKeyDown = e => {
42
+ if (e.key === 'Enter' && !e.shiftKey) {
43
+ e.preventDefault();
44
+ handleSubmit();
45
+ return;
46
+ }
47
+ };
48
+ return (_jsxs("div", { className: styles.fieldChat, "data-layout-type": layoutType, children: [isMobile && _jsx(Attachments, { files: files, isMobile: isMobile }), _jsx(AdaptiveFieldTextArea, Object.assign({}, props, { layoutType: layoutType, size: isMobile ? 'l' : 'm', minRows: 1, maxRows: 4, placeholder: t('FieldChat.placeholder'), onKeyDown: handleKeyDown, footer: _jsx(TextAreaActionsFooter, { right: _jsxs(_Fragment, { children: [attachment && (_jsx(Tooltip, { tip: t('FieldChat.attachFileTooltip'), hoverDelayOpen: 600, triggerClassName: styles.uploadTooltip, children: _jsx(FileUpload, { mode: 'multiple', onFilesUpload: attachment.onFilesUpload, accept: attachment.accept, children: _jsx(ButtonFunction, { size: isMobile ? 's' : 'xs', icon: _jsx(AttachmentSVG, {}) }) }) })), _jsx(FieldSubmitButton, { active: isValueValid, handleClick: handleSubmit, size: isMobile ? 's' : 'xs' })] }) }) })), !isMobile && _jsx(Attachments, { files: files })] }));
49
+ }
@@ -0,0 +1,6 @@
1
+ import { AttachmentSquareProps } from '@snack-uikit/attachment';
2
+ export type AttachmentsProps = {
3
+ files: AttachmentSquareProps[];
4
+ isMobile?: boolean;
5
+ };
6
+ export declare function Attachments({ files, isMobile }: AttachmentsProps): import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1,14 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Attachment, AttachmentSquare } from '@snack-uikit/attachment';
3
+ import { Scroll } from '@snack-uikit/scroll';
4
+ import styles from './styles.module.css';
5
+ export function Attachments({ files, isMobile }) {
6
+ if (!files.length) {
7
+ return null;
8
+ }
9
+ const AttachmentComponent = isMobile ? Attachment : AttachmentSquare;
10
+ return (_jsx(Scroll, { children: _jsx("div", { className: styles.attachments, children: files.map((file, index) => {
11
+ var _a;
12
+ return (_jsx(AttachmentComponent, Object.assign({ size: 's' }, file, { className: isMobile ? styles.attachment : undefined }), ((_a = file.file) === null || _a === void 0 ? void 0 : _a.name) || index));
13
+ }) }) }));
14
+ }
@@ -0,0 +1 @@
1
+ export * from './Attachments';
@@ -0,0 +1 @@
1
+ export * from './Attachments';
@@ -0,0 +1,9 @@
1
+ .attachments{
2
+ display:flex;
3
+ gap:8px;
4
+ padding:1px 0;
5
+ }
6
+
7
+ .attachment{
8
+ min-width:256px;
9
+ }
@@ -0,0 +1 @@
1
+ export * from './FieldChat';
@@ -0,0 +1 @@
1
+ export * from './FieldChat';
@@ -0,0 +1,12 @@
1
+ .fieldChat{
2
+ display:flex;
3
+ flex-direction:column;
4
+ gap:11px;
5
+ }
6
+ .fieldChat[data-layout-type=mobile]{
7
+ gap:7px;
8
+ }
9
+
10
+ .uploadTooltip{
11
+ display:flex;
12
+ }
@@ -0,0 +1,25 @@
1
+ import { FieldTextProps } from '@sbercloud/uikit-product-mobile-fields';
2
+ import { WithLayoutType } from '@sbercloud/uikit-product-utils';
3
+ import { CountrySettings, FieldPhoneOptionsProps } from './types';
4
+ export type FieldPhoneProps = WithLayoutType<Omit<FieldTextProps, 'prefix' | 'prefixIcon' | 'postfix' | 'placeholder' | 'autocomplete' | 'decoratorRef' | 'allowMoreThanMaxLength' | 'onKeyDown' | 'button' | 'maxLength' | 'inputMode'> & {
5
+ /** Включить скролл для основной части списка стран */
6
+ scrollList?: boolean;
7
+ onChange?(value: string): void;
8
+ searchPlaceholder?: string;
9
+ onChangeCountry?(country: FieldPhoneOptionsProps): void;
10
+ } & {
11
+ /** options — объект конфигурации для изменения стандартного списка стран */
12
+ options?: CountrySettings;
13
+ }>;
14
+ export declare const FieldPhone: import("react").ForwardRefExoticComponent<Omit<FieldTextProps, "onKeyDown" | "maxLength" | "placeholder" | "inputMode" | "prefix" | "prefixIcon" | "postfix" | "autocomplete" | "decoratorRef" | "allowMoreThanMaxLength" | "button"> & {
15
+ /** Включить скролл для основной части списка стран */
16
+ scrollList?: boolean;
17
+ onChange?(value: string): void;
18
+ searchPlaceholder?: string;
19
+ onChangeCountry?(country: FieldPhoneOptionsProps): void;
20
+ } & {
21
+ /** options — объект конфигурации для изменения стандартного списка стран */
22
+ options?: CountrySettings;
23
+ } & {
24
+ layoutType: import("@sbercloud/uikit-product-utils").LayoutType;
25
+ } & import("react").RefAttributes<HTMLInputElement>>;
@@ -0,0 +1,125 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ import cn from 'classnames';
14
+ import mergeRefs from 'merge-refs';
15
+ import { forwardRef, useEffect, useMemo, useRef, useState } from 'react';
16
+ import { useIMask } from 'react-imask';
17
+ import { AdaptiveDroplist } from '@sbercloud/uikit-product-mobile-dropdown';
18
+ import { AdaptiveFieldText } from '@sbercloud/uikit-product-mobile-fields';
19
+ import { useValueControl } from '@snack-uikit/utils';
20
+ import { PLACEHOLDER_CHAR } from './constants';
21
+ import { useCountries } from './hooks';
22
+ import styles from './styles.module.css';
23
+ import { detectCountryByPhone } from './utils';
24
+ export const FieldPhone = forwardRef((_a, ref) => {
25
+ var { value: valueProp, onChangeCountry, onChange: onChangeProp, showClearButton = true, searchPlaceholder, onPaste, className, scrollList, options: optionsProp } = _a, rest = __rest(_a, ["value", "onChangeCountry", "onChange", "showClearButton", "searchPlaceholder", "onPaste", "className", "scrollList", "options"]);
26
+ const [open, setOpen] = useState(false);
27
+ const localRef = useRef(null);
28
+ const options = useCountries(optionsProp);
29
+ const isOnlyOneCountryAvailable = options.length === 1;
30
+ const [country, setCountry] = useValueControl({
31
+ defaultValue: options[0],
32
+ onChange: onChangeCountry,
33
+ });
34
+ const [dropdownSearch, setDropDownSearch] = useState('');
35
+ const items = useMemo(() => {
36
+ if (dropdownSearch.length) {
37
+ return options.filter(opt => [opt.content.option, opt.content.caption].some(val => String(val).toLowerCase().includes(dropdownSearch.toLowerCase())));
38
+ }
39
+ return options;
40
+ }, [options, dropdownSearch]);
41
+ const maskOptions = useMemo(() => ({
42
+ mask: country === null || country === void 0 ? void 0 : country.mask,
43
+ lazy: false,
44
+ placeholderChar: PLACEHOLDER_CHAR,
45
+ definitions: {
46
+ X: /[0-9]/,
47
+ },
48
+ }), [country === null || country === void 0 ? void 0 : country.mask]);
49
+ const { ref: iMaskRef, value: iMaskValue, setValue, unmaskedValue, } = useIMask(maskOptions, {
50
+ onAccept: (_, maskRef) => {
51
+ const unmasked = maskRef.unmaskedValue;
52
+ const requiredSymbols = country === null || country === void 0 ? void 0 : country.mask.replace(/[\D]/g, '');
53
+ const value = unmasked.length ? `${country === null || country === void 0 ? void 0 : country.content.caption}${requiredSymbols}${unmasked}` : '';
54
+ if (value !== valueProp) {
55
+ onChangeProp === null || onChangeProp === void 0 ? void 0 : onChangeProp(value);
56
+ }
57
+ },
58
+ });
59
+ useEffect(() => {
60
+ var _a;
61
+ const requiredSymbols = country === null || country === void 0 ? void 0 : country.mask.replace(/[\D]/g, '');
62
+ const normalizedValue = valueProp === null || valueProp === void 0 ? void 0 : valueProp.replace(((_a = country === null || country === void 0 ? void 0 : country.content.caption) !== null && _a !== void 0 ? _a : '') + requiredSymbols, '');
63
+ if (normalizedValue !== undefined && normalizedValue !== unmaskedValue) {
64
+ setValue(normalizedValue);
65
+ }
66
+ // need to trigger update only on valueProp change
67
+ // eslint-disable-next-line react-hooks/exhaustive-deps
68
+ }, [valueProp]);
69
+ const updateMaskView = (value) => {
70
+ var _a;
71
+ setValue((_a = value === null || value === void 0 ? void 0 : value.replaceAll(/\w/g, ' ')) !== null && _a !== void 0 ? _a : '');
72
+ };
73
+ const handlePaste = e => {
74
+ var _a, _b;
75
+ e.preventDefault();
76
+ const text = ((_a = e.clipboardData) === null || _a === void 0 ? void 0 : _a.getData('text')) || '';
77
+ const newCountry = detectCountryByPhone(text, options);
78
+ const isCountryChanged = newCountry && newCountry.id !== (country === null || country === void 0 ? void 0 : country.id);
79
+ const currentCountry = isCountryChanged ? newCountry : country;
80
+ const prefixNumber = ((_b = currentCountry === null || currentCountry === void 0 ? void 0 : currentCountry.content.caption) !== null && _b !== void 0 ? _b : '').replace('+', '');
81
+ const prefixNumberWithOptionalPlus = RegExp(`^(\\+?${prefixNumber})`);
82
+ const valueWithoutPrefix = text.replace(prefixNumberWithOptionalPlus, '');
83
+ // костыль, чтобы всегда срабатывала маска
84
+ const newValue = `+${valueWithoutPrefix}`;
85
+ if (isCountryChanged) {
86
+ setCountry(newCountry);
87
+ updateMaskView(newCountry.mask);
88
+ setTimeout(() => setValue(newValue), 0);
89
+ }
90
+ else {
91
+ setValue(newValue);
92
+ }
93
+ onPaste === null || onPaste === void 0 ? void 0 : onPaste(e);
94
+ };
95
+ const handleChangeSelection = (selectedOption) => {
96
+ if (selectedOption && selectedOption !== (country === null || country === void 0 ? void 0 : country.content.option)) {
97
+ const selectedCountry = options.find(opt => opt.id === selectedOption);
98
+ updateMaskView(selectedCountry === null || selectedCountry === void 0 ? void 0 : selectedCountry.mask);
99
+ setCountry(selectedCountry);
100
+ }
101
+ setTimeout(() => { var _a; return (_a = localRef.current) === null || _a === void 0 ? void 0 : _a.focus(); }, 500);
102
+ };
103
+ const handleChange = (value) => {
104
+ var _a;
105
+ // needed only to clear value by clicking on clear button
106
+ if (unmaskedValue && !value) {
107
+ updateMaskView(country === null || country === void 0 ? void 0 : country.mask);
108
+ (_a = localRef.current) === null || _a === void 0 ? void 0 : _a.focus();
109
+ }
110
+ };
111
+ const showClear = showClearButton && Boolean(unmaskedValue);
112
+ return (_jsx(AdaptiveFieldText, Object.assign({}, rest, { inputMode: 'tel', "data-test-id": 'field-phone', type: 'tel', ref: mergeRefs(ref, localRef, iMaskRef), className: cn(className, styles.fieldPhone), "data-empty": !unmaskedValue || undefined, value: iMaskValue, onChange: handleChange, onPaste: handlePaste, showClearButton: showClear, prefix: country === null || country === void 0 ? void 0 : country.content.caption, button: isOnlyOneCountryAvailable
113
+ ? undefined
114
+ : {
115
+ variant: 'before',
116
+ hasArrow: true,
117
+ arrowOpen: open,
118
+ wrapper: button => (_jsx("div", { role: 'presentation', onClick: e => e.stopPropagation(), children: _jsx(AdaptiveDroplist, { onOpenChange: setOpen, closeDroplistOnItemClick: true, layoutType: rest.layoutType, items: items, selection: { mode: 'single', onChange: handleChangeSelection, value: country === null || country === void 0 ? void 0 : country.id }, scroll: scrollList, search: {
119
+ value: dropdownSearch,
120
+ onChange: setDropDownSearch,
121
+ placeholder: searchPlaceholder,
122
+ }, children: button }) })),
123
+ content: country === null || country === void 0 ? void 0 : country.beforeContent,
124
+ } })));
125
+ });
@@ -0,0 +1,5 @@
1
+ export declare const phoneFormatCases: {
2
+ country: string;
3
+ input: string;
4
+ expected: string;
5
+ }[];
@@ -0,0 +1,26 @@
1
+ export const phoneFormatCases = [
2
+ { country: 'Russia', input: '+79878887879', expected: '+7 987 888-78-79' },
3
+ { country: 'Russia', input: '+7987****875', expected: '+7 987 ***-*8-75' },
4
+ { country: 'Belarus', input: '+375129876543', expected: '+375 12 987-65-43' },
5
+ { country: 'Kazakhstan', input: '+79878887879', expected: '+7 987 888-78-79' },
6
+ { country: 'Armenia', input: '+37412987654', expected: '+374 12 987-654' },
7
+ { country: 'Kyrgyzstan', input: '+996987888777', expected: '+996 987 888-777' },
8
+ { country: 'Georgia', input: '+995987888777', expected: '+995 987 88-87-77' },
9
+ { country: 'Brazil', input: '+5512345678901', expected: '+55 12 34567-8901' },
10
+ { country: 'India', input: '+911234567890', expected: '+91 12345-67890' },
11
+ { country: 'UnitedArabEmirates', input: '+971123456789', expected: '+971 12 345-6789' },
12
+ { country: 'SaudiArabia', input: '+966123456789', expected: '+966 1 2345-6789' },
13
+ { country: 'SouthAfrica', input: '+27123456789', expected: '+27 12 345-6789' },
14
+ { country: 'Egypt', input: '+201234567890', expected: '+20 12 3456-7890' },
15
+ { country: 'Iran', input: '+981234567890', expected: '+98 123 456-7890' },
16
+ { country: 'Ethiopia', input: '+251123456789', expected: '+251 12 345-6789' },
17
+ { country: 'Romania', input: '+40123456789', expected: '+40 12 345-6789' },
18
+ { country: 'Serbia', input: '+381123456789', expected: '+381 12 345-6789' },
19
+ { country: 'Netherlands', input: '+31123456789', expected: '+31 12 345-6789' },
20
+ { country: 'Azerbaijan', input: '+994123456789', expected: '+994 12 345-67-89' },
21
+ { country: 'Syria', input: '+963123456789', expected: '+963 12 345-6789' },
22
+ { country: 'Cyprus', input: '+35712345678', expected: '+357 12 345678' },
23
+ { country: 'Uzbekistan', input: '+998123456789', expected: '+998 12 345-67-89' },
24
+ { country: 'Tajikistan', input: '+992123456789', expected: '+992 12 345-6789' },
25
+ { country: 'Moldova', input: '+37312345678', expected: '+373 1234 5678' },
26
+ ];
@@ -0,0 +1 @@
1
+ import './matchMedia';
@@ -0,0 +1,12 @@
1
+ import './matchMedia';
2
+ import { describe, expect, it } from 'vitest';
3
+ import { ALL_COUNTRY_CODES } from '../countries';
4
+ import { formatPhoneNumber } from '../utils';
5
+ import { phoneFormatCases } from './constants';
6
+ describe('Checking the mask overlay for each number', () => {
7
+ phoneFormatCases.forEach(({ country, input, expected }) => {
8
+ it(`should format the number correctly for ${country}`, () => {
9
+ expect(formatPhoneNumber(input, ALL_COUNTRY_CODES)).toBe(expected);
10
+ });
11
+ });
12
+ });
@@ -0,0 +1,14 @@
1
+ import { vi } from 'vitest';
2
+ Object.defineProperty(window, 'matchMedia', {
3
+ writable: true,
4
+ value: vi.fn().mockImplementation(query => ({
5
+ matches: false,
6
+ media: query,
7
+ onchange: null,
8
+ addListener: vi.fn(),
9
+ removeListener: vi.fn(),
10
+ addEventListener: vi.fn(),
11
+ removeEventListener: vi.fn(),
12
+ dispatchEvent: vi.fn(),
13
+ })),
14
+ });
@@ -0,0 +1 @@
1
+ export declare const PLACEHOLDER_CHAR = "_";
@@ -0,0 +1 @@
1
+ export const PLACEHOLDER_CHAR = '_';