@cloud-ru/uikit-product-fields-predefined 0.14.0 → 0.15.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 (29) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/README.md +239 -3
  3. package/dist/cjs/components/FieldAi/FieldAi.js +26 -4
  4. package/dist/cjs/components/FieldAi/components/CheckItem/CheckItem.d.ts +2 -1
  5. package/dist/cjs/components/FieldAi/components/CheckItem/CheckItem.js +2 -2
  6. package/dist/cjs/components/FieldAi/components/CheckItem/styles.module.css +14 -0
  7. package/dist/cjs/components/FieldAi/components/PasswordValidation/PasswordValidation.d.ts +3 -2
  8. package/dist/cjs/components/FieldAi/components/PasswordValidation/PasswordValidation.js +2 -2
  9. package/dist/cjs/components/FieldAi/components/WithPasswordValidation/WithPasswordValidation.d.ts +3 -2
  10. package/dist/cjs/components/FieldAi/components/WithPasswordValidation/WithPasswordValidation.js +3 -3
  11. package/dist/cjs/components/FieldAi/utils.d.ts +1 -0
  12. package/dist/esm/components/FieldAi/FieldAi.js +27 -5
  13. package/dist/esm/components/FieldAi/components/CheckItem/CheckItem.d.ts +2 -1
  14. package/dist/esm/components/FieldAi/components/CheckItem/CheckItem.js +2 -2
  15. package/dist/esm/components/FieldAi/components/CheckItem/styles.module.css +14 -0
  16. package/dist/esm/components/FieldAi/components/PasswordValidation/PasswordValidation.d.ts +3 -2
  17. package/dist/esm/components/FieldAi/components/PasswordValidation/PasswordValidation.js +2 -2
  18. package/dist/esm/components/FieldAi/components/WithPasswordValidation/WithPasswordValidation.d.ts +3 -2
  19. package/dist/esm/components/FieldAi/components/WithPasswordValidation/WithPasswordValidation.js +3 -3
  20. package/dist/esm/components/FieldAi/utils.d.ts +1 -0
  21. package/dist/tsconfig.cjs.tsbuildinfo +1 -1
  22. package/dist/tsconfig.esm.tsbuildinfo +1 -1
  23. package/package.json +8 -8
  24. package/src/components/FieldAi/FieldAi.tsx +36 -5
  25. package/src/components/FieldAi/components/CheckItem/CheckItem.tsx +3 -2
  26. package/src/components/FieldAi/components/CheckItem/styles.module.scss +16 -0
  27. package/src/components/FieldAi/components/PasswordValidation/PasswordValidation.tsx +9 -2
  28. package/src/components/FieldAi/components/WithPasswordValidation/WithPasswordValidation.tsx +15 -3
  29. package/src/components/FieldAi/utils.ts +2 -0
@@ -4,7 +4,7 @@ import { CheckSVG } from '@cloud-ru/uikit-product-icons';
4
4
  import { Typography } from '@snack-uikit/typography';
5
5
  import styles from './styles.module.css';
6
6
  const CHECKED_ITEM_DISAPPEAR_TIMEOUT = 500;
7
- export function CheckItem({ label, checked, layoutType, shouldHide = false }) {
7
+ export function CheckItem({ label, checked, layoutType, shouldHide = false, animated = false }) {
8
8
  const [visible, setVisible] = useState(checked);
9
9
  useEffect(() => {
10
10
  if (checked) {
@@ -18,5 +18,5 @@ export function CheckItem({ label, checked, layoutType, shouldHide = false }) {
18
18
  if (shouldHide && !visible) {
19
19
  return null;
20
20
  }
21
- return (_jsxs("div", { className: styles.checkItem, "data-layout-type": layoutType, children: [_jsx(CheckSVG, { size: 20, className: styles.icon, "data-checked": checked }), _jsx(Typography.SansBodyM, { className: styles.label, "data-checked": checked, children: label })] }));
21
+ return (_jsxs("div", { className: styles.checkItem, "data-layout-type": layoutType, "data-animated": animated, children: [_jsx(CheckSVG, { size: 20, className: styles.icon, "data-checked": checked }), _jsx(Typography.SansBodyM, { className: styles.label, "data-checked": checked, children: label })] }));
22
22
  }
@@ -1,3 +1,14 @@
1
+ @keyframes shake{
2
+ 0%, 100%{
3
+ transform:translateX(0);
4
+ }
5
+ 10%, 30%, 50%, 70%, 90%{
6
+ transform:translateX(-4px);
7
+ }
8
+ 20%, 40%, 60%, 80%{
9
+ transform:translateX(4px);
10
+ }
11
+ }
1
12
  .checkItem{
2
13
  display:inline-flex;
3
14
  gap:10px;
@@ -5,6 +16,9 @@
5
16
  .checkItem[data-layout-type=mobile], .checkItem[data-layout-type=tablet]{
6
17
  gap:8px;
7
18
  }
19
+ .checkItem[data-animated=true]{
20
+ animation:shake 0.5s ease-in-out;
21
+ }
8
22
 
9
23
  .icon{
10
24
  flex-shrink:0;
@@ -1,6 +1,7 @@
1
1
  import { WithLayoutType } from '@cloud-ru/uikit-product-utils';
2
- import { ValidationPassword } from '../../utils';
2
+ import { ValidationPassword, ValidationPasswordKey } from '../../utils';
3
3
  export type WithPasswordTooltipProps = WithLayoutType<{
4
4
  passwordValidation: ValidationPassword;
5
+ animatedKey?: ValidationPasswordKey | null;
5
6
  }>;
6
- export declare function PasswordValidation({ passwordValidation, layoutType }: WithPasswordTooltipProps): import("react/jsx-runtime").JSX.Element;
7
+ export declare function PasswordValidation({ passwordValidation, layoutType, animatedKey }: WithPasswordTooltipProps): import("react/jsx-runtime").JSX.Element;
@@ -4,7 +4,7 @@ import { useLocale } from '@cloud-ru/uikit-product-locale';
4
4
  import { isTouchDevice as isTouchDeviceHelper } from '../../../../helpers';
5
5
  import { CheckItem } from '../CheckItem';
6
6
  import styles from './styles.module.css';
7
- export function PasswordValidation({ passwordValidation, layoutType }) {
7
+ export function PasswordValidation({ passwordValidation, layoutType, animatedKey }) {
8
8
  const { t } = useLocale('FieldsPredefined');
9
9
  const allCriteriaMet = useMemo(() => Object.values(passwordValidation).every(item => item), [passwordValidation]);
10
10
  const isTouchDevice = isTouchDeviceHelper(layoutType);
@@ -13,5 +13,5 @@ export function PasswordValidation({ passwordValidation, layoutType }) {
13
13
  return (_jsx("div", { className: styles.validationItemsContainer, "data-layout-type": layoutType, children: _jsx(CheckItem, { checked: true, label: t('FieldAi.secret.passwordTooltip.titleSuccess'), layoutType: layoutType, shouldHide: false }) }));
14
14
  }
15
15
  }
16
- return (_jsx("div", { className: styles.validationItemsContainer, "data-layout-type": layoutType, children: _jsxs("div", { className: styles.validationList, children: [_jsx(CheckItem, { checked: passwordValidation.minLength, label: t('FieldAi.secret.passwordTooltip.minLength'), layoutType: layoutType, shouldHide: isTouchDevice }), _jsx(CheckItem, { checked: passwordValidation.onlyLatin, label: t('FieldAi.secret.passwordTooltip.onlyLatin'), layoutType: layoutType, shouldHide: isTouchDevice }), _jsx(CheckItem, { checked: passwordValidation.hasLetterCases, label: t('FieldAi.secret.passwordTooltip.hasLetterCases'), layoutType: layoutType, shouldHide: isTouchDevice }), _jsx(CheckItem, { checked: passwordValidation.hasNumber, label: t('FieldAi.secret.passwordTooltip.hasNumber'), layoutType: layoutType, shouldHide: isTouchDevice }), _jsx(CheckItem, { checked: passwordValidation.hasSymbol, label: t('FieldAi.secret.passwordTooltip.hasSymbol'), layoutType: layoutType, shouldHide: isTouchDevice }), _jsx(CheckItem, { checked: passwordValidation.noSpaces, label: t('FieldAi.secret.passwordTooltip.noSpaces'), layoutType: layoutType, shouldHide: isTouchDevice })] }) }));
16
+ return (_jsx("div", { className: styles.validationItemsContainer, "data-layout-type": layoutType, children: _jsxs("div", { className: styles.validationList, children: [_jsx(CheckItem, { checked: passwordValidation.minLength, label: t('FieldAi.secret.passwordTooltip.minLength'), layoutType: layoutType, shouldHide: isTouchDevice, animated: animatedKey === 'minLength' }), _jsx(CheckItem, { checked: passwordValidation.onlyLatin, label: t('FieldAi.secret.passwordTooltip.onlyLatin'), layoutType: layoutType, shouldHide: isTouchDevice, animated: animatedKey === 'onlyLatin' }), _jsx(CheckItem, { checked: passwordValidation.hasLetterCases, label: t('FieldAi.secret.passwordTooltip.hasLetterCases'), layoutType: layoutType, shouldHide: isTouchDevice, animated: animatedKey === 'hasLetterCases' }), _jsx(CheckItem, { checked: passwordValidation.hasNumber, label: t('FieldAi.secret.passwordTooltip.hasNumber'), layoutType: layoutType, shouldHide: isTouchDevice, animated: animatedKey === 'hasNumber' }), _jsx(CheckItem, { checked: passwordValidation.hasSymbol, label: t('FieldAi.secret.passwordTooltip.hasSymbol'), layoutType: layoutType, shouldHide: isTouchDevice, animated: animatedKey === 'hasSymbol' }), _jsx(CheckItem, { checked: passwordValidation.noSpaces, label: t('FieldAi.secret.passwordTooltip.noSpaces'), layoutType: layoutType, shouldHide: isTouchDevice, animated: animatedKey === 'noSpaces' })] }) }));
17
17
  }
@@ -1,9 +1,10 @@
1
1
  import { ReactNode } from 'react';
2
2
  import { WithLayoutType } from '@cloud-ru/uikit-product-utils';
3
- import { ValidationPassword } from '../../utils';
3
+ import { ValidationPassword, ValidationPasswordKey } from '../../utils';
4
4
  export type WithPasswordTooltipProps = WithLayoutType<{
5
5
  showValidation?: boolean;
6
6
  children: ReactNode;
7
7
  passwordValidation: ValidationPassword;
8
+ animatedKey?: ValidationPasswordKey | null;
8
9
  }>;
9
- export declare function WithPasswordValidation({ showValidation, passwordValidation, layoutType, children, }: WithPasswordTooltipProps): string | number | boolean | import("react/jsx-runtime").JSX.Element | Iterable<ReactNode> | null | undefined;
10
+ export declare function WithPasswordValidation({ showValidation, passwordValidation, layoutType, children, animatedKey, }: WithPasswordTooltipProps): string | number | boolean | import("react/jsx-runtime").JSX.Element | Iterable<ReactNode> | null | undefined;
@@ -3,15 +3,15 @@ import { AdaptiveTooltip } from '@cloud-ru/uikit-product-mobile-tooltip';
3
3
  import { isTouchDevice } from '../../../../helpers';
4
4
  import { PasswordValidation } from '../PasswordValidation';
5
5
  import styles from './styles.module.css';
6
- export function WithPasswordValidation({ showValidation, passwordValidation, layoutType, children, }) {
6
+ export function WithPasswordValidation({ showValidation, passwordValidation, layoutType, children, animatedKey, }) {
7
7
  if (isTouchDevice(layoutType)) {
8
8
  if (showValidation) {
9
- return (_jsxs("div", { className: styles.validationContainer, children: [_jsx(PasswordValidation, { passwordValidation: passwordValidation, layoutType: layoutType }), children] }));
9
+ return (_jsxs("div", { className: styles.validationContainer, children: [_jsx(PasswordValidation, { passwordValidation: passwordValidation, layoutType: layoutType, animatedKey: animatedKey }), children] }));
10
10
  }
11
11
  return children;
12
12
  }
13
13
  if (showValidation) {
14
- return (_jsx(AdaptiveTooltip, { placement: 'left-end', layoutType: layoutType, tip: _jsx(PasswordValidation, { passwordValidation: passwordValidation, layoutType: layoutType }), offset: 8, children: children }));
14
+ return (_jsx(AdaptiveTooltip, { placement: 'left-end', layoutType: layoutType, tip: _jsx(PasswordValidation, { passwordValidation: passwordValidation, layoutType: layoutType, animatedKey: animatedKey }), offset: 8, children: children }));
15
15
  }
16
16
  return children;
17
17
  }
@@ -6,4 +6,5 @@ export type ValidationPassword = {
6
6
  hasSymbol: boolean;
7
7
  noSpaces: boolean;
8
8
  };
9
+ export type ValidationPasswordKey = keyof ValidationPassword;
9
10
  export declare const getValidationPassword: (password?: string) => ValidationPassword;