@salutejs/plasma-new-hope 0.194.0-canary.1562.11857238836.0 → 0.194.0-canary.1565.11870784206.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 (180) hide show
  1. package/cjs/components/Combobox/ComboboxNew/Combobox.js +1 -0
  2. package/cjs/components/Combobox/ComboboxNew/Combobox.js.map +1 -1
  3. package/cjs/components/Combobox/ComboboxNew/ui/Inner/ui/Item/Item.js +2 -1
  4. package/cjs/components/Combobox/ComboboxNew/ui/Inner/ui/Item/Item.js.map +1 -1
  5. package/cjs/components/Combobox/ComboboxOld/Combobox.css +4 -5
  6. package/cjs/components/Combobox/ComboboxOld/ui/ComboboxDivider/ComboboxDivider.css +4 -5
  7. package/cjs/components/Combobox/ComboboxOld/ui/ComboboxFooter/ComboboxFooter.css +4 -5
  8. package/cjs/components/Combobox/ComboboxOld/ui/ComboboxGroup/ComboboxGroup.css +4 -5
  9. package/cjs/components/Combobox/ComboboxOld/ui/ComboboxHeader/ComboboxHeader.css +4 -5
  10. package/cjs/components/Dropdown/Dropdown.css +4 -5
  11. package/cjs/components/Dropdown/Dropdown.js +2 -4
  12. package/cjs/components/Dropdown/Dropdown.js.map +1 -1
  13. package/cjs/components/Dropdown/ui/DropdownItem/DropdownItem.css +4 -5
  14. package/cjs/components/Dropdown/ui/DropdownItem/DropdownItem.js +2 -3
  15. package/cjs/components/Dropdown/ui/DropdownItem/DropdownItem.js.map +1 -1
  16. package/cjs/components/Dropdown/ui/DropdownItem/DropdownItem.styles.js +1 -7
  17. package/cjs/components/Dropdown/ui/DropdownItem/DropdownItem.styles.js.map +1 -1
  18. package/cjs/components/Dropdown/ui/DropdownItem/{DropdownItem.styles_14yih1y.css → DropdownItem.styles_1b439rx.css} +0 -1
  19. package/cjs/components/Select/Select.js +1 -0
  20. package/cjs/components/Select/Select.js.map +1 -1
  21. package/cjs/components/Select/ui/Inner/ui/Item/Item.js +2 -1
  22. package/cjs/components/Select/ui/Inner/ui/Item/Item.js.map +1 -1
  23. package/cjs/components/Select/ui/Target/ui/Textfield/Textfield.js +3 -18
  24. package/cjs/components/Select/ui/Target/ui/Textfield/Textfield.js.map +1 -1
  25. package/cjs/components/TextField/TextField.js +27 -3
  26. package/cjs/components/TextField/TextField.js.map +1 -1
  27. package/cjs/components/TextField/hooks/useValidation.js +273 -0
  28. package/cjs/components/TextField/hooks/useValidation.js.map +1 -0
  29. package/cjs/index.css +4 -5
  30. package/cjs/utils/constants.js +4 -0
  31. package/cjs/utils/constants.js.map +1 -1
  32. package/emotion/cjs/components/Combobox/ComboboxNew/Combobox.js +1 -0
  33. package/emotion/cjs/components/Combobox/ComboboxNew/ui/Inner/ui/Item/Item.js +2 -1
  34. package/emotion/cjs/components/Dropdown/Dropdown.js +2 -4
  35. package/emotion/cjs/components/Dropdown/ui/DropdownItem/DropdownItem.js +2 -3
  36. package/emotion/cjs/components/Dropdown/ui/DropdownItem/DropdownItem.styles.js +11 -15
  37. package/emotion/cjs/components/Select/Select.js +1 -0
  38. package/emotion/cjs/components/Select/ui/Inner/ui/Item/Item.js +2 -1
  39. package/emotion/cjs/components/Select/ui/Target/ui/Textfield/Textfield.js +3 -24
  40. package/emotion/cjs/components/TextField/TextField.js +27 -4
  41. package/emotion/cjs/components/TextField/TextField.template-doc.mdx +330 -0
  42. package/emotion/cjs/components/TextField/hooks/index.js +8 -1
  43. package/emotion/cjs/components/TextField/hooks/useValidation.js +276 -0
  44. package/emotion/cjs/examples/plasma_b2c/components/TextField/TextField.stories.tsx +253 -1
  45. package/emotion/cjs/examples/plasma_web/components/TextField/TextField.stories.tsx +252 -0
  46. package/emotion/cjs/utils/constants.js +4 -2
  47. package/emotion/es/components/Combobox/ComboboxNew/Combobox.js +1 -0
  48. package/emotion/es/components/Combobox/ComboboxNew/ui/Inner/ui/Item/Item.js +2 -1
  49. package/emotion/es/components/Dropdown/Dropdown.js +2 -4
  50. package/emotion/es/components/Dropdown/ui/DropdownItem/DropdownItem.js +3 -4
  51. package/emotion/es/components/Dropdown/ui/DropdownItem/DropdownItem.styles.js +11 -15
  52. package/emotion/es/components/Select/Select.js +1 -0
  53. package/emotion/es/components/Select/ui/Inner/ui/Item/Item.js +2 -1
  54. package/emotion/es/components/Select/ui/Target/ui/Textfield/Textfield.js +3 -24
  55. package/emotion/es/components/TextField/TextField.js +28 -5
  56. package/emotion/es/components/TextField/TextField.template-doc.mdx +330 -0
  57. package/emotion/es/components/TextField/hooks/index.js +2 -1
  58. package/emotion/es/components/TextField/hooks/useValidation.js +270 -0
  59. package/emotion/es/examples/plasma_b2c/components/TextField/TextField.stories.tsx +253 -1
  60. package/emotion/es/examples/plasma_web/components/TextField/TextField.stories.tsx +252 -0
  61. package/emotion/es/utils/constants.js +3 -1
  62. package/es/components/Combobox/ComboboxNew/Combobox.js +1 -0
  63. package/es/components/Combobox/ComboboxNew/Combobox.js.map +1 -1
  64. package/es/components/Combobox/ComboboxNew/ui/Inner/ui/Item/Item.js +2 -1
  65. package/es/components/Combobox/ComboboxNew/ui/Inner/ui/Item/Item.js.map +1 -1
  66. package/es/components/Combobox/ComboboxOld/Combobox.css +4 -5
  67. package/es/components/Combobox/ComboboxOld/ui/ComboboxDivider/ComboboxDivider.css +4 -5
  68. package/es/components/Combobox/ComboboxOld/ui/ComboboxFooter/ComboboxFooter.css +4 -5
  69. package/es/components/Combobox/ComboboxOld/ui/ComboboxGroup/ComboboxGroup.css +4 -5
  70. package/es/components/Combobox/ComboboxOld/ui/ComboboxHeader/ComboboxHeader.css +4 -5
  71. package/es/components/Dropdown/Dropdown.css +4 -5
  72. package/es/components/Dropdown/Dropdown.js +2 -4
  73. package/es/components/Dropdown/Dropdown.js.map +1 -1
  74. package/es/components/Dropdown/ui/DropdownItem/DropdownItem.css +4 -5
  75. package/es/components/Dropdown/ui/DropdownItem/DropdownItem.js +3 -4
  76. package/es/components/Dropdown/ui/DropdownItem/DropdownItem.js.map +1 -1
  77. package/es/components/Dropdown/ui/DropdownItem/DropdownItem.styles.js +2 -7
  78. package/es/components/Dropdown/ui/DropdownItem/DropdownItem.styles.js.map +1 -1
  79. package/es/components/Dropdown/ui/DropdownItem/{DropdownItem.styles_14yih1y.css → DropdownItem.styles_1b439rx.css} +0 -1
  80. package/es/components/Select/Select.js +1 -0
  81. package/es/components/Select/Select.js.map +1 -1
  82. package/es/components/Select/ui/Inner/ui/Item/Item.js +2 -1
  83. package/es/components/Select/ui/Inner/ui/Item/Item.js.map +1 -1
  84. package/es/components/Select/ui/Target/ui/Textfield/Textfield.js +4 -19
  85. package/es/components/Select/ui/Target/ui/Textfield/Textfield.js.map +1 -1
  86. package/es/components/TextField/TextField.js +27 -3
  87. package/es/components/TextField/TextField.js.map +1 -1
  88. package/es/components/TextField/hooks/useValidation.js +269 -0
  89. package/es/components/TextField/hooks/useValidation.js.map +1 -0
  90. package/es/index.css +4 -5
  91. package/es/utils/constants.js +3 -1
  92. package/es/utils/constants.js.map +1 -1
  93. package/package.json +2 -3
  94. package/styled-components/cjs/components/Combobox/ComboboxNew/Combobox.js +1 -0
  95. package/styled-components/cjs/components/Combobox/ComboboxNew/ui/Inner/ui/Item/Item.js +2 -1
  96. package/styled-components/cjs/components/Dropdown/Dropdown.js +2 -4
  97. package/styled-components/cjs/components/Dropdown/ui/DropdownItem/DropdownItem.js +2 -3
  98. package/styled-components/cjs/components/Dropdown/ui/DropdownItem/DropdownItem.styles.js +2 -5
  99. package/styled-components/cjs/components/Select/Select.js +1 -0
  100. package/styled-components/cjs/components/Select/ui/Inner/ui/Item/Item.js +2 -1
  101. package/styled-components/cjs/components/Select/ui/Target/ui/Textfield/Textfield.js +3 -24
  102. package/styled-components/cjs/components/TextField/TextField.js +26 -3
  103. package/styled-components/cjs/components/TextField/TextField.template-doc.mdx +330 -0
  104. package/styled-components/cjs/components/TextField/hooks/index.js +8 -1
  105. package/styled-components/cjs/components/TextField/hooks/useValidation.js +276 -0
  106. package/styled-components/cjs/examples/plasma_b2c/components/TextField/TextField.stories.tsx +253 -1
  107. package/styled-components/cjs/examples/plasma_web/components/TextField/TextField.stories.tsx +252 -0
  108. package/styled-components/cjs/utils/constants.js +4 -2
  109. package/styled-components/es/components/Combobox/ComboboxNew/Combobox.js +1 -0
  110. package/styled-components/es/components/Combobox/ComboboxNew/ui/Inner/ui/Item/Item.js +2 -1
  111. package/styled-components/es/components/Dropdown/Dropdown.js +2 -4
  112. package/styled-components/es/components/Dropdown/ui/DropdownItem/DropdownItem.js +3 -4
  113. package/styled-components/es/components/Dropdown/ui/DropdownItem/DropdownItem.styles.js +2 -5
  114. package/styled-components/es/components/Select/Select.js +1 -0
  115. package/styled-components/es/components/Select/ui/Inner/ui/Item/Item.js +2 -1
  116. package/styled-components/es/components/Select/ui/Target/ui/Textfield/Textfield.js +3 -24
  117. package/styled-components/es/components/TextField/TextField.js +27 -4
  118. package/styled-components/es/components/TextField/TextField.template-doc.mdx +330 -0
  119. package/styled-components/es/components/TextField/hooks/index.js +2 -1
  120. package/styled-components/es/components/TextField/hooks/useValidation.js +270 -0
  121. package/styled-components/es/examples/plasma_b2c/components/TextField/TextField.stories.tsx +253 -1
  122. package/styled-components/es/examples/plasma_web/components/TextField/TextField.stories.tsx +252 -0
  123. package/styled-components/es/utils/constants.js +3 -1
  124. package/types/components/Autocomplete/Autocomplete.types.d.ts +2 -2
  125. package/types/components/Autocomplete/Autocomplete.types.d.ts.map +1 -1
  126. package/types/components/Autocomplete/ui/TextField/TextField.styles.d.ts +1676 -92
  127. package/types/components/Autocomplete/ui/TextField/TextField.styles.d.ts.map +1 -1
  128. package/types/components/Combobox/ComboboxNew/Combobox.d.ts.map +1 -1
  129. package/types/components/Combobox/ComboboxNew/Combobox.types.d.ts +2 -1
  130. package/types/components/Combobox/ComboboxNew/Combobox.types.d.ts.map +1 -1
  131. package/types/components/Combobox/ComboboxNew/ui/Inner/ui/Item/Item.d.ts.map +1 -1
  132. package/types/components/Combobox/ComboboxNew/ui/Target/Target.styles.d.ts +1676 -92
  133. package/types/components/Combobox/ComboboxNew/ui/Target/Target.styles.d.ts.map +1 -1
  134. package/types/components/DatePicker/SingleDate/SingleDate.styles.d.ts +1676 -92
  135. package/types/components/DatePicker/SingleDate/SingleDate.styles.d.ts.map +1 -1
  136. package/types/components/Dropdown/Dropdown.d.ts +2 -50
  137. package/types/components/Dropdown/Dropdown.d.ts.map +1 -1
  138. package/types/components/Dropdown/Dropdown.types.d.ts +6 -11
  139. package/types/components/Dropdown/Dropdown.types.d.ts.map +1 -1
  140. package/types/components/Dropdown/index.d.ts +0 -1
  141. package/types/components/Dropdown/index.d.ts.map +1 -1
  142. package/types/components/Dropdown/ui/DropdownItem/DropdownItem.d.ts.map +1 -1
  143. package/types/components/Dropdown/ui/DropdownItem/DropdownItem.styles.d.ts +0 -1
  144. package/types/components/Dropdown/ui/DropdownItem/DropdownItem.styles.d.ts.map +1 -1
  145. package/types/components/Range/Range.styles.d.ts +1676 -92
  146. package/types/components/Range/Range.styles.d.ts.map +1 -1
  147. package/types/components/Select/Select.d.ts.map +1 -1
  148. package/types/components/Select/Select.types.d.ts +2 -1
  149. package/types/components/Select/Select.types.d.ts.map +1 -1
  150. package/types/components/Select/ui/Inner/ui/Item/Item.d.ts.map +1 -1
  151. package/types/components/Select/ui/Target/ui/Textfield/Textfield.d.ts.map +1 -1
  152. package/types/components/Select/ui/Target/ui/Textfield/Textfield.styles.d.ts +1676 -92
  153. package/types/components/Select/ui/Target/ui/Textfield/Textfield.styles.d.ts.map +1 -1
  154. package/types/components/Slider/components/Double/Double.styles.d.ts +1676 -92
  155. package/types/components/Slider/components/Double/Double.styles.d.ts.map +1 -1
  156. package/types/components/TextField/TextField.d.ts.map +1 -1
  157. package/types/components/TextField/TextField.types.d.ts +51 -1
  158. package/types/components/TextField/TextField.types.d.ts.map +1 -1
  159. package/types/components/TextField/hooks/index.d.ts +1 -0
  160. package/types/components/TextField/hooks/index.d.ts.map +1 -1
  161. package/types/components/TextField/hooks/useValidation.d.ts +7 -0
  162. package/types/components/TextField/hooks/useValidation.d.ts.map +1 -0
  163. package/types/examples/plasma_b2c/components/Autocomplete/Autocomplete.d.ts +64 -2
  164. package/types/examples/plasma_b2c/components/Autocomplete/Autocomplete.d.ts.map +1 -1
  165. package/types/examples/plasma_b2c/components/Dropdown/Dropdown.d.ts +1 -25
  166. package/types/examples/plasma_b2c/components/Dropdown/Dropdown.d.ts.map +1 -1
  167. package/types/examples/plasma_b2c/components/Mask/Mask.d.ts +2732 -92
  168. package/types/examples/plasma_b2c/components/Mask/Mask.d.ts.map +1 -1
  169. package/types/examples/plasma_b2c/components/TextField/TextField.d.ts +1676 -92
  170. package/types/examples/plasma_b2c/components/TextField/TextField.d.ts.map +1 -1
  171. package/types/examples/plasma_web/components/Autocomplete/Autocomplete.d.ts +64 -2
  172. package/types/examples/plasma_web/components/Autocomplete/Autocomplete.d.ts.map +1 -1
  173. package/types/examples/plasma_web/components/Dropdown/Dropdown.d.ts +1 -25
  174. package/types/examples/plasma_web/components/Dropdown/Dropdown.d.ts.map +1 -1
  175. package/types/examples/plasma_web/components/Mask/Mask.d.ts +2732 -92
  176. package/types/examples/plasma_web/components/Mask/Mask.d.ts.map +1 -1
  177. package/types/examples/plasma_web/components/TextField/TextField.d.ts +1676 -92
  178. package/types/examples/plasma_web/components/TextField/TextField.d.ts.map +1 -1
  179. package/types/utils/constants.d.ts +2 -0
  180. package/types/utils/constants.d.ts.map +1 -1
@@ -291,3 +291,255 @@ export const Chips: StoryObj<StoryPropsChips> = {
291
291
  },
292
292
  render: (args) => <StoryChips {...args} />,
293
293
  };
294
+
295
+ type StoryEmailValidationProps = StoryPropsDefault & {
296
+ minLengthValue?: number;
297
+ minLengthErrorMessage?: string;
298
+ maxLengthValue?: number;
299
+ maxLengthErrorMessage?: string;
300
+ minHostLengthValue?: number;
301
+ minHostLengthErrorMessage?: string;
302
+ maxHostLengthValue?: number;
303
+ maxHostLengthErrorMessage?: string;
304
+ minDomainLengthValue?: number;
305
+ minDomainLengthErrorMessage?: string;
306
+ maxDomainLengthValue?: number;
307
+ maxDomainLengthErrorMessage?: string;
308
+ minZoneLengthValue?: number;
309
+ minZoneLengthErrorMessage?: string;
310
+ maxZoneLengthValue?: number;
311
+ maxZoneLengthErrorMessage?: string;
312
+ whitelistDomainsValue?: string;
313
+ whitelistDomainsErrorMessage?: string;
314
+ blacklistDomainsValue?: string;
315
+ blacklistDomainsErrorMessage?: string;
316
+ };
317
+
318
+ const StoryEmailValidation = ({
319
+ minLengthValue,
320
+ minLengthErrorMessage,
321
+ maxLengthValue,
322
+ maxLengthErrorMessage,
323
+ minHostLengthValue,
324
+ minHostLengthErrorMessage,
325
+ maxHostLengthValue,
326
+ maxHostLengthErrorMessage,
327
+ minDomainLengthValue,
328
+ minDomainLengthErrorMessage,
329
+ maxDomainLengthValue,
330
+ maxDomainLengthErrorMessage,
331
+ minZoneLengthValue,
332
+ minZoneLengthErrorMessage,
333
+ maxZoneLengthValue,
334
+ maxZoneLengthErrorMessage,
335
+ whitelistDomainsValue,
336
+ whitelistDomainsErrorMessage,
337
+ blacklistDomainsValue,
338
+ blacklistDomainsErrorMessage,
339
+ ...rest
340
+ }: StoryEmailValidationProps) => {
341
+ const [error, setError] = useState('');
342
+
343
+ const validationOptions = {
344
+ minLength: {
345
+ value: minLengthValue || undefined,
346
+ errorMessage: minLengthErrorMessage || 'Почта слишком короткая',
347
+ },
348
+ maxLength: {
349
+ value: maxLengthValue || undefined,
350
+ errorMessage: maxLengthErrorMessage || 'Почта слишком длинная',
351
+ },
352
+ minHostLength: {
353
+ value: minHostLengthValue || undefined,
354
+ errorMessage: minHostLengthErrorMessage || 'Хост слишком короткий',
355
+ },
356
+ maxHostLength: {
357
+ value: maxHostLengthValue || undefined,
358
+ errorMessage: maxHostLengthErrorMessage || 'Хост слишком длинный',
359
+ },
360
+ minDomainLength: {
361
+ value: minDomainLengthValue || undefined,
362
+ errorMessage: minDomainLengthErrorMessage || 'Домен слишком короткий',
363
+ },
364
+ maxDomainLength: {
365
+ value: maxDomainLengthValue || undefined,
366
+ errorMessage: maxDomainLengthErrorMessage || 'Домен слишком длинный',
367
+ },
368
+ minZoneLength: {
369
+ value: minZoneLengthValue || undefined,
370
+ errorMessage: minZoneLengthErrorMessage || 'Доменная зона слишком короткая',
371
+ },
372
+ maxZoneLength: {
373
+ value: maxZoneLengthValue || undefined,
374
+ errorMessage: maxZoneLengthErrorMessage || 'Доменная зона слишком длинная',
375
+ },
376
+ whitelistDomains: {
377
+ value: whitelistDomainsValue?.split(',') || undefined,
378
+ errorMessage: whitelistDomainsErrorMessage || 'Домен не разрешен',
379
+ },
380
+ blacklistDomains: {
381
+ value: blacklistDomainsValue?.split(',') || undefined,
382
+ errorMessage: blacklistDomainsErrorMessage || 'Домен запрещен',
383
+ },
384
+ };
385
+
386
+ const handleOnChange = () => {
387
+ setError('');
388
+ };
389
+
390
+ const handleOnValidate = ({ errorMessage }: { errorMessage?: string }) => {
391
+ setError(errorMessage || '');
392
+ };
393
+
394
+ return (
395
+ <TextField
396
+ label="Валидация почты"
397
+ validationType="email"
398
+ options={validationOptions}
399
+ size="l"
400
+ view={error ? 'negative' : 'default'}
401
+ leftHelper={error || 'Валидация почты'}
402
+ onChange={handleOnChange}
403
+ onValidate={handleOnValidate}
404
+ {...rest}
405
+ />
406
+ );
407
+ };
408
+
409
+ export const EmailValidation: StoryObj<StoryEmailValidationProps> = {
410
+ argTypes: {
411
+ ...disableProps(['view', 'size', 'maxLength', 'required', 'requiredPlacement', 'optional']),
412
+ },
413
+ args: {
414
+ labelPlacement: 'outer',
415
+ placeholder: 'Заполните поле',
416
+ minLengthValue: 5,
417
+ minLengthErrorMessage: 'Почта слишком короткая',
418
+ maxLengthValue: 25,
419
+ maxLengthErrorMessage: 'Почта слишком длинная',
420
+ minHostLengthValue: 1,
421
+ minHostLengthErrorMessage: 'Хост слишком короткий',
422
+ maxHostLengthValue: 12,
423
+ maxHostLengthErrorMessage: 'Хост слишком длинный',
424
+ minDomainLengthValue: 1,
425
+ minDomainLengthErrorMessage: 'Домен слишком короткий',
426
+ maxDomainLengthValue: 6,
427
+ maxDomainLengthErrorMessage: 'Домен слишком длинный',
428
+ minZoneLengthValue: 1,
429
+ minZoneLengthErrorMessage: 'Доменная зона слишком короткая',
430
+ maxZoneLengthValue: 5,
431
+ maxZoneLengthErrorMessage: 'Доменная зона слишком длинная',
432
+ whitelistDomainsValue: 'gmail.com,yandex.ru,mail.ru,mail.com',
433
+ whitelistDomainsErrorMessage: 'Домен не разрешен',
434
+ blacklistDomainsValue: 'heh.org,hah.ha',
435
+ blacklistDomainsErrorMessage: 'Домен запрещен',
436
+ },
437
+ render: (args) => <StoryEmailValidation {...args} />,
438
+ };
439
+
440
+ type StoryPasswordValidationProps = StoryPropsDefault & {
441
+ minLengthValue?: number;
442
+ minLengthErrorMessage?: string;
443
+ maxLengthValue?: number;
444
+ maxLengthErrorMessage?: string;
445
+ includeUppercase?: boolean;
446
+ includeUppercaseErrorMessage?: string;
447
+ includeLowercase?: boolean;
448
+ includeLowercaseErrorMessage?: string;
449
+ includeDigits?: boolean;
450
+ includeDigitsErrorMessage?: string;
451
+ includeSpecialSymbols?: boolean;
452
+ includeSpecialSymbolsErrorMessage?: string;
453
+ };
454
+
455
+ const StoryPasswordValidation = ({
456
+ minLengthValue,
457
+ minLengthErrorMessage,
458
+ maxLengthValue,
459
+ maxLengthErrorMessage,
460
+ includeUppercase,
461
+ includeUppercaseErrorMessage,
462
+ includeLowercase,
463
+ includeLowercaseErrorMessage,
464
+ includeDigits,
465
+ includeDigitsErrorMessage,
466
+ includeSpecialSymbols,
467
+ includeSpecialSymbolsErrorMessage,
468
+ ...rest
469
+ }: StoryPasswordValidationProps) => {
470
+ const [error, setError] = useState('');
471
+
472
+ const validationOptions = {
473
+ minLength: {
474
+ value: minLengthValue || undefined,
475
+ errorMessage: minLengthErrorMessage || 'Пароль слишком короткий',
476
+ },
477
+ maxLength: {
478
+ value: maxLengthValue || undefined,
479
+ errorMessage: maxLengthErrorMessage || 'Пароль слишком длинный',
480
+ },
481
+ includeUppercase: {
482
+ value: includeUppercase,
483
+ errorMessage: includeUppercaseErrorMessage || 'Пароль должен содержать хотя бы одну заглавную букву',
484
+ },
485
+ includeLowercase: {
486
+ value: includeLowercase,
487
+ errorMessage: includeLowercaseErrorMessage || 'Пароль должен содержать хотя бы одну строчную букву',
488
+ },
489
+ includeDigits: {
490
+ value: includeDigits,
491
+ errorMessage: includeDigitsErrorMessage || 'Пароль должен содержать хотя бы одну цифру',
492
+ },
493
+ includeSpecialSymbols: {
494
+ value: includeSpecialSymbols,
495
+ errorMessage:
496
+ includeSpecialSymbolsErrorMessage || 'Пароль должен содержать хотя бы один специальный символ',
497
+ },
498
+ };
499
+
500
+ const handleOnChange = () => {
501
+ setError('');
502
+ };
503
+
504
+ const handleOnValidate = ({ errorMessage }: { errorMessage?: string }) => {
505
+ setError(errorMessage || '');
506
+ };
507
+
508
+ return (
509
+ <TextField
510
+ label="Валидация пароля"
511
+ validationType="password"
512
+ options={validationOptions}
513
+ size="l"
514
+ view={error ? 'negative' : 'default'}
515
+ leftHelper={error || 'Валидация пароля'}
516
+ onChange={handleOnChange}
517
+ onValidate={handleOnValidate}
518
+ {...rest}
519
+ />
520
+ );
521
+ };
522
+
523
+ export const PasswordValidation: StoryObj<StoryPasswordValidationProps> = {
524
+ argTypes: {
525
+ ...disableProps(['view', 'size', 'maxLength', 'required', 'requiredPlacement', 'optional']),
526
+ },
527
+ args: {
528
+ labelPlacement: 'outer',
529
+ placeholder: 'Заполните поле',
530
+ passwordHidden: false,
531
+ minLengthValue: 5,
532
+ minLengthErrorMessage: 'Пароль слишком короткий',
533
+ maxLengthValue: 25,
534
+ maxLengthErrorMessage: 'Пароль слишком длинный',
535
+ includeUppercase: true,
536
+ includeUppercaseErrorMessage: 'Пароль должен содержать хотя бы одну заглавную букву',
537
+ includeLowercase: true,
538
+ includeLowercaseErrorMessage: 'Пароль должен содержать хотя бы одну строчную букву',
539
+ includeDigits: true,
540
+ includeDigitsErrorMessage: 'Пароль должен содержать хотя бы одну цифру',
541
+ includeSpecialSymbols: true,
542
+ includeSpecialSymbolsErrorMessage: 'Пароль должен содержать хотя бы один специальный символ',
543
+ },
544
+ render: (args) => <StoryPasswordValidation {...args} />,
545
+ };
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.keyCodes = void 0;
6
+ exports.specialCharacters = exports.keyCodes = exports.emailPattern = void 0;
7
7
  var keyCodes = exports.keyCodes = {
8
8
  PageUp: 33,
9
9
  PageDown: 34,
@@ -16,4 +16,6 @@ var keyCodes = exports.keyCodes = {
16
16
  Enter: 13,
17
17
  Space: 32,
18
18
  Escape: 27
19
- };
19
+ };
20
+ var emailPattern = exports.emailPattern = /^[^\s@]+@([^\s@.,]+\.)+[^\s@.,]{2,}$/;
21
+ var specialCharacters = exports.specialCharacters = /[!@#$%^&*(),.?":{}|<>]/;
@@ -348,6 +348,7 @@ export var comboboxRoot = function comboboxRoot(Root) {
348
348
  handleItemClick: handleItemClick,
349
349
  variant: variant,
350
350
  renderItem: renderItem,
351
+ valueToItemMap: valueToItemMap,
351
352
  treeId: treeId
352
353
  }
353
354
  }, /*#__PURE__*/React.createElement(FloatingPopover, {
@@ -31,6 +31,7 @@ export var Item = function Item(_ref) {
31
31
  handleItemClick = _useContext.handleItemClick,
32
32
  variant = _useContext.variant,
33
33
  renderItem = _useContext.renderItem,
34
+ valueToItemMap = _useContext.valueToItemMap,
34
35
  treeId = _useContext.treeId;
35
36
  var disabledClassName = disabled ? classes.dropdownItemIsDisabled : undefined;
36
37
  var focusedClass = currentLevel === focusedPath.length - 1 && index === (focusedPath === null || focusedPath === void 0 ? void 0 : focusedPath[currentLevel]) ? classes.dropdownItemIsFocused : undefined;
@@ -84,7 +85,7 @@ export var Item = function Item(_ref) {
84
85
  }))), !multiple && checked.get(item.value) === 'done' && /*#__PURE__*/React.createElement(IconDone, {
85
86
  size: sizeToIconSize(size, variant),
86
87
  color: "inherit"
87
- })), renderItem ? /*#__PURE__*/React.createElement(StyledText, null, renderItem(item)) : /*#__PURE__*/React.createElement(StyledWrapper, null, /*#__PURE__*/React.createElement(StyledCell, {
88
+ })), renderItem ? /*#__PURE__*/React.createElement(StyledText, null, renderItem(valueToItemMap.get(value))) : /*#__PURE__*/React.createElement(StyledWrapper, null, /*#__PURE__*/React.createElement(StyledCell, {
88
89
  view: "default",
89
90
  size: "l",
90
91
  contentLeft: contentLeft,
@@ -1,4 +1,4 @@
1
- var _excluded = ["items", "children", "placement", "offset", "closeOnOverlayClick", "onToggle", "size", "view", "itemRole", "className", "listWidth", "listHeight", "listOverflow", "closeOnSelect", "onHover", "onItemSelect", "onItemClick", "trigger", "variant", "hasArrow", "alwaysOpened", "portal", "renderItem"];
1
+ var _excluded = ["items", "children", "placement", "offset", "closeOnOverlayClick", "onToggle", "size", "view", "itemRole", "className", "listWidth", "listHeight", "listOverflow", "closeOnSelect", "onHover", "onItemSelect", "onItemClick", "trigger", "variant", "hasArrow", "alwaysOpened", "portal"];
2
2
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
3
3
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
4
4
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
@@ -60,7 +60,6 @@ export var dropdownRoot = function dropdownRoot(Root) {
60
60
  _ref$alwaysOpened = _ref.alwaysOpened,
61
61
  alwaysOpened = _ref$alwaysOpened === void 0 ? false : _ref$alwaysOpened,
62
62
  portal = _ref.portal,
63
- renderItem = _ref.renderItem,
64
63
  rest = _objectWithoutProperties(_ref, _excluded);
65
64
  var _useReducer = useReducer(pathReducer, []),
66
65
  _useReducer2 = _slicedToArray(_useReducer, 2),
@@ -136,8 +135,7 @@ export var dropdownRoot = function dropdownRoot(Root) {
136
135
  onItemClick: onItemClick,
137
136
  onItemSelect: onItemSelect,
138
137
  hasArrow: hasArrow,
139
- treeId: treeId,
140
- renderItem: renderItem
138
+ treeId: treeId
141
139
  }
142
140
  }, /*#__PURE__*/React.createElement(FloatingPopover, {
143
141
  ref: floatingPopoverRef,
@@ -4,7 +4,7 @@ import { cx } from '../../../../utils';
4
4
  import { IconDisclosureRight } from '../../../_Icon';
5
5
  import { Context } from '../../Dropdown';
6
6
  import { getItemId } from '../../utils';
7
- import { Wrapper, DisclosureIconWrapper, Divider, CellWrapper, StyledCell, RenderItemWrapper } from './DropdownItem.styles';
7
+ import { Wrapper, DisclosureIconWrapper, Divider, CellWrapper, StyledCell } from './DropdownItem.styles';
8
8
  export var DropdownItem = function DropdownItem(_ref) {
9
9
  var item = _ref.item,
10
10
  path = _ref.path,
@@ -34,8 +34,7 @@ export var DropdownItem = function DropdownItem(_ref) {
34
34
  onItemSelect = _useContext.onItemSelect,
35
35
  onItemClick = _useContext.onItemClick,
36
36
  hasArrow = _useContext.hasArrow,
37
- treeId = _useContext.treeId,
38
- renderItem = _useContext.renderItem;
37
+ treeId = _useContext.treeId;
39
38
  var hasDescendants = Boolean(item.items);
40
39
  var disclosureIconSize = size === 'xs' ? 'xs' : 's';
41
40
  var isDisabledClassName = disabled || isDisabled ? classes.dropdownItemIsDisabled : undefined;
@@ -86,7 +85,7 @@ export var DropdownItem = function DropdownItem(_ref) {
86
85
  "aria-expanded": ariaExpanded,
87
86
  "aria-level": ariaLevel,
88
87
  "aria-label": ariaLabel
89
- }, renderItem ? /*#__PURE__*/React.createElement(RenderItemWrapper, null, renderItem(item)) : /*#__PURE__*/React.createElement(CellWrapper, null, /*#__PURE__*/React.createElement(StyledCell, {
88
+ }, /*#__PURE__*/React.createElement(CellWrapper, null, /*#__PURE__*/React.createElement(StyledCell, {
90
89
  contentLeft: contentLeft,
91
90
  contentRight: contentRight,
92
91
  alignContentLeft: "center",
@@ -1,6 +1,6 @@
1
1
  import styled from 'styled-components';
2
2
  import { classes, tokens, constants } from '../../Dropdown.tokens';
3
- import { addFocus, applyEllipsis } from '../../../../mixins';
3
+ import { addFocus } from '../../../../mixins';
4
4
  import { cellConfig, cellTokens } from '../../../Cell';
5
5
  import { component, mergeConfig } from '../../../../engines';
6
6
  var mergedCellConfig = /*#__PURE__*/mergeConfig(cellConfig);
@@ -35,7 +35,4 @@ export var Wrapper = /*#__PURE__*/styled.li.withConfig({
35
35
  outlineRadius: /*#__PURE__*/"var(".concat(tokens.itemBorderRadius, ")"),
36
36
  hasTransition: false,
37
37
  customFocusRules: /*#__PURE__*/"\n &.".concat(classes.dropdownItemIsFocused, ":before {\n outline: none;\n box-shadow: 0 0 0 0.0625rem var(").concat(constants.focusColor, ");\n }\n ")
38
- }));
39
- export var RenderItemWrapper = /*#__PURE__*/styled.div.withConfig({
40
- componentId: "plasma-new-hope__sc-hs0ek1-5"
41
- })(["", ";flex:1;"], /*#__PURE__*/applyEllipsis());
38
+ }));
@@ -272,6 +272,7 @@ export var selectRoot = function selectRoot(Root) {
272
272
  handleItemClick: handleItemClick,
273
273
  variant: variant,
274
274
  renderItem: renderItem,
275
+ valueToItemMap: valueToItemMap,
275
276
  treeId: treeId
276
277
  }
277
278
  }, /*#__PURE__*/React.createElement(FloatingPopover, {
@@ -32,6 +32,7 @@ export var Item = function Item(_ref) {
32
32
  handleItemClick = _useContext.handleItemClick,
33
33
  variant = _useContext.variant,
34
34
  renderItem = _useContext.renderItem,
35
+ valueToItemMap = _useContext.valueToItemMap,
35
36
  treeId = _useContext.treeId;
36
37
  var itemDisabled = Boolean(disabled || isDisabled);
37
38
  var disabledClassName = itemDisabled ? classes.dropdownItemIsDisabled : undefined;
@@ -86,7 +87,7 @@ export var Item = function Item(_ref) {
86
87
  }))), !multiselect && checked.get(item.value) === 'done' && /*#__PURE__*/React.createElement(IconDone, {
87
88
  size: sizeToIconSize(size, variant),
88
89
  color: "inherit"
89
- })), renderItem ? /*#__PURE__*/React.createElement(StyledText, null, renderItem(item)) : /*#__PURE__*/React.createElement(StyledWrapper, null, /*#__PURE__*/React.createElement(StyledCell, {
90
+ })), renderItem ? /*#__PURE__*/React.createElement(StyledText, null, renderItem(valueToItemMap.get(value))) : /*#__PURE__*/React.createElement(StyledWrapper, null, /*#__PURE__*/React.createElement(StyledCell, {
90
91
  contentLeft: contentLeft,
91
92
  contentRight: contentRight
92
93
  // TODO: #1548
@@ -1,10 +1,4 @@
1
1
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
3
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
5
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
6
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
7
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
8
2
  import React, { forwardRef } from 'react';
9
3
  import { sizeToIconSize, getItemId } from '../../../../utils';
10
4
  import { classes } from '../../../../Select.tokens';
@@ -53,24 +47,9 @@ export var Textfield = /*#__PURE__*/forwardRef(function (_ref, ref) {
53
47
 
54
48
  // Обработчик чипов
55
49
  var handleChipsChange = function handleChipsChange(chipLabels) {
56
- if (!Array.isArray(value)) return;
57
-
58
- // TODO: #1564
59
- // Из лейблов чипов получаем value у item и далее прокидываем его в onChange.
60
- if (renderValue && !isTargetAmount) {
61
- var resultValues = _toConsumableArray(value);
62
- value.forEach(function (_, index) {
63
- var labelAfterRenderValue = renderValue(labelToItemMap.get(valueToItemMap.get(value[index]).label));
64
- if (!chipLabels.includes(labelAfterRenderValue)) {
65
- resultValues.splice(index, 1);
66
- }
67
- });
68
- onChange(resultValues);
69
- } else {
70
- onChange(chipLabels.map(function (chipLabel) {
71
- return labelToItemMap.get(chipLabel).value;
72
- }));
73
- }
50
+ onChange(chipLabels.map(function (chipLabel) {
51
+ return labelToItemMap.get(chipLabel).value;
52
+ }));
74
53
  };
75
54
  return /*#__PURE__*/React.createElement(StyledTextField, _extends({
76
55
  ref: ref,
@@ -1,4 +1,4 @@
1
- var _excluded = ["id", "className", "style", "contentLeft", "contentRight", "label", "labelPlacement", "textBefore", "textAfter", "placeholder", "leftHelper", "enumerationType", "requiredPlacement", "titleCaption", "hintTrigger", "hintText", "hintView", "hintSize", "hintTargetIcon", "hintPlacement", "hintHasArrow", "hintOffset", "hintWidth", "hintContentLeft", "view", "size", "readOnly", "disabled", "required", "clear", "optional", "hasDivider", "value", "chips", "onChange", "onChangeChips", "onSearch", "onKeyDown"];
1
+ var _excluded = ["id", "className", "style", "contentLeft", "contentRight", "label", "labelPlacement", "textBefore", "textAfter", "placeholder", "leftHelper", "enumerationType", "requiredPlacement", "titleCaption", "hintTrigger", "hintText", "hintView", "hintSize", "hintTargetIcon", "hintPlacement", "hintHasArrow", "hintOffset", "hintWidth", "hintContentLeft", "view", "size", "readOnly", "disabled", "required", "clear", "optional", "hasDivider", "value", "chips", "validationType", "options", "passwordHidden", "onValidate", "onChange", "onBlur", "onChangeChips", "onSearch", "onKeyDown"];
2
2
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
3
3
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
4
4
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
@@ -24,7 +24,7 @@ import { base as hintSizeCSS } from './variations/_hint-size/base';
24
24
  import { Input, InputContainer, LeftHelper, Label, InputWrapper, InputLabelWrapper, StyledContentLeft, StyledContentRight, StyledChips, StyledTextBefore, StyledTextAfter, StyledIndicator, StyledOptionalText, InputPlaceholder, OuterLabelWrapper, TitleCaption, StyledHintWrapper, StyledIndicatorWrapper } from './TextField.styles';
25
25
  import { classes } from './TextField.tokens';
26
26
  import { TextFieldChip } from './ui';
27
- import { useKeyNavigation } from './hooks';
27
+ import { useKeyNavigation, useValidation } from './hooks';
28
28
  import { HintComponent } from './ui/Hint/Hint';
29
29
  var optionalText = 'optional';
30
30
  export var base = /*#__PURE__*/css(["display:block;"]);
@@ -77,7 +77,12 @@ export var textFieldRoot = function textFieldRoot(Root) {
77
77
  hasDivider = _ref.hasDivider,
78
78
  outerValue = _ref.value,
79
79
  values = _ref.chips,
80
+ validationType = _ref.validationType,
81
+ options = _ref.options,
82
+ passwordHidden = _ref.passwordHidden,
83
+ onValidate = _ref.onValidate,
80
84
  onChange = _ref.onChange,
85
+ onBlur = _ref.onBlur,
81
86
  onChangeChips = _ref.onChangeChips,
82
87
  onSearch = _ref.onSearch,
83
88
  onKeyDown = _ref.onKeyDown,
@@ -127,6 +132,7 @@ export var textFieldRoot = function textFieldRoot(Root) {
127
132
  var hasValueClass = hasValue ? classes.hasValue : undefined;
128
133
  var wrapperWithoutLeftContent = !contentLeft && isChipsVisible ? classes.hasEmptyContentLeft : undefined;
129
134
  var wrapperWithoutRightContent = !contentRight && isChipsVisible ? classes.hasEmptyContentRight : undefined;
135
+ var isPasswordHidden = validationType === 'password' && passwordHidden;
130
136
  var hintRef = useOutsideClick(function () {
131
137
  setIsHintVisible(false);
132
138
  });
@@ -169,6 +175,13 @@ export var textFieldRoot = function textFieldRoot(Root) {
169
175
  setChips(newChips);
170
176
  onChangeChips === null || onChangeChips === void 0 || onChangeChips(newValues);
171
177
  };
178
+ var _useValidation = useValidation({
179
+ validationType: validationType,
180
+ options: options,
181
+ onValidate: onValidate
182
+ }),
183
+ handleValidationBlur = _useValidation.handleValidationBlur,
184
+ handleValidationKeyDown = _useValidation.handleValidationKeyDown;
172
185
  var _useKeyNavigation = useKeyNavigation({
173
186
  controlledRefs: controlledRefs,
174
187
  disabled: disabled,
@@ -198,6 +211,12 @@ export var textFieldRoot = function textFieldRoot(Root) {
198
211
  });
199
212
  inputRef.current.focus();
200
213
  };
214
+ var handleInputBlur = function handleInputBlur(event) {
215
+ if (onBlur) {
216
+ onBlur(event);
217
+ }
218
+ handleValidationBlur(event);
219
+ };
201
220
  var getRef = function getRef(element, index) {
202
221
  if (element && chipsRefs !== null && chipsRefs !== void 0 && chipsRefs.current) {
203
222
  chipsRefs.current[index] = element;
@@ -205,6 +224,7 @@ export var textFieldRoot = function textFieldRoot(Root) {
205
224
  };
206
225
  var handleOnKeyDown = function handleOnKeyDown(event) {
207
226
  handleInputKeydown(event);
227
+ handleValidationKeyDown(event);
208
228
  if (onKeyDown) {
209
229
  onKeyDown(event);
210
230
  }
@@ -338,8 +358,11 @@ export var textFieldRoot = function textFieldRoot(Root) {
338
358
  readOnly: !disabled && readOnly,
339
359
  onInput: handleInput,
340
360
  onChange: handleChange,
341
- onKeyDown: handleOnKeyDown
342
- }, rest)), hasInnerLabel && /*#__PURE__*/React.createElement(Label, {
361
+ onKeyDown: handleOnKeyDown,
362
+ onBlur: handleInputBlur
363
+ }, rest, isPasswordHidden && {
364
+ type: 'password'
365
+ })), hasInnerLabel && /*#__PURE__*/React.createElement(Label, {
343
366
  id: labelId,
344
367
  htmlFor: innerId
345
368
  }, innerLabelValue, optionalTextNode), placeholderShown && !hasValue && /*#__PURE__*/React.createElement(InputPlaceholder, null, innerPlaceholderValue, hasPlaceholderOptional && optionalTextNode)), textAfter && /*#__PURE__*/React.createElement(StyledTextAfter, null, textAfter)), contentRight && /*#__PURE__*/React.createElement(StyledContentRight, null, contentRight)), leftHelper && /*#__PURE__*/React.createElement(LeftHelper, {