@cloud-ru/uikit-product-fields-predefined 0.15.2 → 0.16.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 (36) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +1 -0
  3. package/dist/cjs/components/FieldAi/FieldAi.d.ts +5 -1
  4. package/dist/cjs/components/FieldAi/FieldAi.js +6 -2
  5. package/dist/cjs/components/FieldAi/components/AlertButton/AlertButton.d.ts +5 -0
  6. package/dist/cjs/components/FieldAi/components/AlertButton/AlertButton.js +12 -0
  7. package/dist/cjs/components/FieldAi/components/AlertButton/index.d.ts +1 -0
  8. package/dist/cjs/components/FieldAi/components/AlertButton/index.js +17 -0
  9. package/dist/cjs/components/FieldAi/components/AlertButton/styles.module.css +17 -0
  10. package/dist/cjs/components/FieldAi/styles.module.css +29 -2
  11. package/dist/cjs/components/FieldDescription/FieldDescription.d.ts +1 -1
  12. package/dist/cjs/components/FieldDescription/FieldDescriptionRHF.d.ts +1 -1
  13. package/dist/cjs/components/FieldName/FieldName.d.ts +1 -1
  14. package/dist/cjs/components/FieldName/FieldNameRHF.d.ts +1 -1
  15. package/dist/cjs/components/FieldPhone/FieldPhone.d.ts +2 -2
  16. package/dist/esm/components/FieldAi/FieldAi.d.ts +5 -1
  17. package/dist/esm/components/FieldAi/FieldAi.js +8 -4
  18. package/dist/esm/components/FieldAi/components/AlertButton/AlertButton.d.ts +5 -0
  19. package/dist/esm/components/FieldAi/components/AlertButton/AlertButton.js +6 -0
  20. package/dist/esm/components/FieldAi/components/AlertButton/index.d.ts +1 -0
  21. package/dist/esm/components/FieldAi/components/AlertButton/index.js +1 -0
  22. package/dist/esm/components/FieldAi/components/AlertButton/styles.module.css +17 -0
  23. package/dist/esm/components/FieldAi/styles.module.css +29 -2
  24. package/dist/esm/components/FieldDescription/FieldDescription.d.ts +1 -1
  25. package/dist/esm/components/FieldDescription/FieldDescriptionRHF.d.ts +1 -1
  26. package/dist/esm/components/FieldName/FieldName.d.ts +1 -1
  27. package/dist/esm/components/FieldName/FieldNameRHF.d.ts +1 -1
  28. package/dist/esm/components/FieldPhone/FieldPhone.d.ts +2 -2
  29. package/dist/tsconfig.cjs.tsbuildinfo +1 -1
  30. package/dist/tsconfig.esm.tsbuildinfo +1 -1
  31. package/package.json +3 -3
  32. package/src/components/FieldAi/FieldAi.tsx +28 -3
  33. package/src/components/FieldAi/components/AlertButton/AlertButton.tsx +16 -0
  34. package/src/components/FieldAi/components/AlertButton/index.ts +1 -0
  35. package/src/components/FieldAi/components/AlertButton/styles.module.scss +20 -0
  36. package/src/components/FieldAi/styles.module.scss +46 -7
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloud-ru/uikit-product-fields-predefined",
3
3
  "title": "Fields Predefined",
4
- "version": "0.15.2",
4
+ "version": "0.16.0",
5
5
  "sideEffects": [
6
6
  "*.css",
7
7
  "*.woff",
@@ -34,7 +34,7 @@
34
34
  "dependencies": {
35
35
  "@cloud-ru/uikit-product-icons": "16.1.1",
36
36
  "@cloud-ru/uikit-product-mobile-dropdown": "0.9.31",
37
- "@cloud-ru/uikit-product-mobile-fields": "0.12.3",
37
+ "@cloud-ru/uikit-product-mobile-fields": "0.12.4",
38
38
  "@cloud-ru/uikit-product-mobile-modal": "0.9.28",
39
39
  "@cloud-ru/uikit-product-mobile-tooltip": "0.5.4",
40
40
  "@cloud-ru/uikit-product-utils": "8.1.0",
@@ -61,5 +61,5 @@
61
61
  "react-hook-form": ">=7.51.0",
62
62
  "yup": ">=0.32.0"
63
63
  },
64
- "gitHead": "1a98d6d9bff32edcbb3f9b0be0a14dce3f2abe5d"
64
+ "gitHead": "f0d31e819998afe109833b200e61860543bcf54b"
65
65
  }
@@ -1,7 +1,7 @@
1
1
  import cn from 'classnames';
2
2
  import { forwardRef, KeyboardEventHandler, useEffect, useMemo, useRef, useState } from 'react';
3
3
 
4
- import { EyeClosedSVG, EyeSVG } from '@cloud-ru/uikit-product-icons';
4
+ import { EyeClosedSVG, EyeSVG, PasswordLockSVG } from '@cloud-ru/uikit-product-icons';
5
5
  import { useLocale } from '@cloud-ru/uikit-product-locale';
6
6
  import {
7
7
  AdaptiveFieldTextArea,
@@ -10,12 +10,15 @@ import {
10
10
  } from '@cloud-ru/uikit-product-mobile-fields';
11
11
  import { WithLayoutType } from '@cloud-ru/uikit-product-utils';
12
12
  import { ButtonFunction, ButtonOutline } from '@snack-uikit/button';
13
+ import { themeVars } from '@snack-uikit/figma-tokens';
13
14
  import { Tooltip } from '@snack-uikit/tooltip';
15
+ import { Typography } from '@snack-uikit/typography';
14
16
 
15
17
  import { FieldSubmitButton } from '../../helperComponents/FieldSubmitButton';
16
18
  import { TextAreaActionsFooter } from '../../helperComponents/TextAreaActionsFooter';
17
19
  import { isTouchDevice as isTouchDeviceHelper } from '../../helpers';
18
20
  import { AIDisclaimer } from '../AIDisclaimer/AIDisclaimer';
21
+ import { AlertButton } from './components/AlertButton';
19
22
  import { MobileFieldAi } from './components/MobileFieldAi';
20
23
  import { WithPasswordValidation } from './components/WithPasswordValidation';
21
24
  import styles from './styles.module.scss';
@@ -29,11 +32,25 @@ export type FieldAiProps = WithLayoutType<
29
32
  onSubmit(value: string): void;
30
33
  /** Действие при клике по кнопке сброса контекста */
31
34
  onResetContextClick?(): void;
35
+ /** Действие для отмены секьюрности поля */
36
+ onCancelSecure?(): void;
32
37
  }
33
38
  >;
34
39
 
35
40
  export const FieldAi = forwardRef<HTMLTextAreaElement, FieldAiProps>(
36
- ({ secure = false, onSubmit: handleSubmitProp, value, onResetContextClick, disabled, className, ...props }, ref) => {
41
+ (
42
+ {
43
+ secure = false,
44
+ onSubmit: handleSubmitProp,
45
+ value,
46
+ onResetContextClick,
47
+ onCancelSecure,
48
+ disabled,
49
+ className,
50
+ ...props
51
+ },
52
+ ref,
53
+ ) => {
37
54
  const { layoutType, validationState } = props;
38
55
  const { t } = useLocale('FieldsPredefined');
39
56
  const isTouchDevice = isTouchDeviceHelper(layoutType);
@@ -48,6 +65,7 @@ export const FieldAi = forwardRef<HTMLTextAreaElement, FieldAiProps>(
48
65
  const passwordValidation = useMemo(() => getValidationPassword(value), [value]);
49
66
  const isPasswordValid = isPasswordMode ? Object.values(passwordValidation).every(Boolean) : true;
50
67
  const showPasswordError = !isPasswordValid && secure && value;
68
+ const showPasswordAlert = Boolean(onCancelSecure) && secure === 'password';
51
69
 
52
70
  useEffect(
53
71
  () => () => {
@@ -113,7 +131,14 @@ export const FieldAi = forwardRef<HTMLTextAreaElement, FieldAiProps>(
113
131
  }
114
132
 
115
133
  return (
116
- <div className={cn(styles.wrapper, className)}>
134
+ <div className={cn(styles.wrapper, isPasswordMode && styles.passwordWrapper, className)}>
135
+ {showPasswordAlert && (
136
+ <div className={styles.alert}>
137
+ <PasswordLockSVG size={16} color={themeVars.sys.neutral.textSupport} />
138
+ <Typography.SansBodyS className={styles.alertText}>{t('FieldAi.secret.alert.text')}</Typography.SansBodyS>
139
+ <AlertButton label={t('FieldAi.secret.alert.button')} onClick={onCancelSecure} />
140
+ </div>
141
+ )}
117
142
  <WithPasswordValidation
118
143
  showValidation={isPasswordMode}
119
144
  passwordValidation={passwordValidation}
@@ -0,0 +1,16 @@
1
+ import { Typography } from '@snack-uikit/typography';
2
+
3
+ import styles from './styles.module.scss';
4
+
5
+ export type AlertButtonProps = {
6
+ label: string;
7
+ onClick?(): void;
8
+ };
9
+
10
+ export function AlertButton({ label, onClick }: AlertButtonProps) {
11
+ return (
12
+ <button onClick={onClick} className={styles.button}>
13
+ <Typography.SansLabelM className={styles.label}>{label}</Typography.SansLabelM>
14
+ </button>
15
+ );
16
+ }
@@ -0,0 +1 @@
1
+ export * from './AlertButton';
@@ -0,0 +1,20 @@
1
+ @use '@sbercloud/figma-tokens-cloud-platform/build/scss/styles-theme-variables' as stv;
2
+
3
+ .button {
4
+ outline: none;
5
+ border: none;
6
+ background-color: transparent;
7
+ cursor: pointer;
8
+ height: 16px;
9
+ display: flex;
10
+ align-items: center;
11
+ justify-content: center;
12
+ }
13
+
14
+ .label {
15
+ color: stv.$sys-blue-text-support;
16
+
17
+ &:hover {
18
+ color: stv.$sys-neutral-text-main;
19
+ }
20
+ }
@@ -1,9 +1,38 @@
1
+ /* stylelint-disable color-no-hex */
1
2
  @use '@sbercloud/figma-tokens-cloud-platform/build/scss/components/styles-tokens-fields' as ste;
3
+ @use '@sbercloud/figma-tokens-cloud-platform/build/scss/styles-theme-variables' as stv;
2
4
 
3
5
  .wrapper {
4
6
  display: flex;
5
7
  flex-direction: column;
6
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;
7
36
  }
8
37
 
9
38
  .secured {
@@ -34,18 +63,28 @@
34
63
 
35
64
  .submitButton {
36
65
  &:not([data-disabled]) {
37
- /* stylelint-disable-next-line color-no-hex */
38
- background: radial-gradient(92.53% 92.53% at 65.87% 21.69%, #7CB5F2 15%, #5FD7C2 45%, #26D07C 65%);
66
+ background: radial-gradient(92.53% 92.53% at 65.87% 21.69%, #7cb5f2 15%, #5fd7c2 45%, #26d07c 65%);
39
67
  }
40
68
  }
41
69
 
42
70
  .textarea {
43
- &> :first-child {
44
- &[data-validation=default]:not([data-readonly]):not([data-disable-focus]):focus-within:not([data-disabled]) {
71
+ & > :first-child {
72
+ &[data-validation='default']:not([data-readonly]):not([data-disable-focus]):focus-within:not([data-disabled]) {
45
73
  border-color: transparent;
46
- /* stylelint-disable-next-line color-no-hex */
47
- background: linear-gradient(var(--sys-neutral-background2-level), var(--sys-neutral-background2-level) 0) padding-box, radial-gradient(92.53% 92.53% at 65.87% 21.69%, #7CB5F2 8%, #78B9EC 17%, #70C6DD 28%, #64D8C7 38%, #5FD7C2 44%, #54D5B3 51%, #40D39C 58%, #26D07C 66%) border-box;
74
+ background:
75
+ linear-gradient(var(--sys-neutral-background2-level), var(--sys-neutral-background2-level) 0) padding-box,
76
+ radial-gradient(
77
+ 92.53% 92.53% at 65.87% 21.69%,
78
+ #7cb5f2 8%,
79
+ #78b9ec 17%,
80
+ #70c6dd 28%,
81
+ #64d8c7 38%,
82
+ #5fd7c2 44%,
83
+ #54d5b3 51%,
84
+ #40d39c 58%,
85
+ #26d07c 66%
86
+ )
87
+ border-box;
48
88
  }
49
89
  }
50
90
  }
51
-