diff --git a/src/components/controls/PasswordInput/PasswordInput.scss b/src/components/controls/PasswordInput/PasswordInput.scss index c73982dee2..9e8f8c231b 100644 --- a/src/components/controls/PasswordInput/PasswordInput.scss +++ b/src/components/controls/PasswordInput/PasswordInput.scss @@ -10,11 +10,6 @@ $block: '.#{variables.$ns}password-input'; } } - &__additional-end-content { - display: flex; - align-items: center; - } - &__copy-button { margin-inline-end: 4px; } diff --git a/src/components/controls/PasswordInput/PasswordInput.tsx b/src/components/controls/PasswordInput/PasswordInput.tsx index da058cba29..a235672964 100644 --- a/src/components/controls/PasswordInput/PasswordInput.tsx +++ b/src/components/controls/PasswordInput/PasswordInput.tsx @@ -1,3 +1,5 @@ +'use client'; + import React from 'react'; import {Eye, EyeSlash} from '@gravity-ui/icons'; @@ -17,17 +19,16 @@ import './PasswordInput.scss'; const b = block('password-input'); -export type PasswordInputProps = Required> & - Omit & { - /** Show copy button */ - showCopyButton?: boolean; - /** Show reveal button */ - showRevealButton?: boolean; - /** Disable the tooltip for the copy button. The tooltip will not be displayed */ - hasCopyTooltip?: boolean; - /** Disable the tooltip for the reveal button. The tooltip will not be displayed */ - hasRevealTooltip?: boolean; - }; +export type PasswordInputProps = Omit & { + /** Show copy button */ + showCopyButton?: boolean; + /** Show reveal button */ + showRevealButton?: boolean; + /** Disable the tooltip for the copy button. The tooltip will not be displayed */ + hasCopyTooltip?: boolean; + /** Disable the tooltip for the reveal button. The tooltip will not be displayed */ + hasRevealTooltip?: boolean; +}; export const PasswordInput = (props: PasswordInputProps) => { const { @@ -57,7 +58,7 @@ export const PasswordInput = (props: PasswordInputProps) => { const {actionButtonSize, iconSize} = getActionButtonSizeAndIconSize(size); return ( -
+ {endContent || rightContent} {value && showCopyButton ? ( { ) : null} -
+ ); }, [ showRevealButton, diff --git a/src/components/controls/PasswordInput/README.md b/src/components/controls/PasswordInput/README.md index 6ae1371e1f..fcb5fce594 100644 --- a/src/components/controls/PasswordInput/README.md +++ b/src/components/controls/PasswordInput/README.md @@ -38,8 +38,6 @@ LANDING_BLOCK--> `TextInput` [properties](https://github.com/gravity-ui/uikit/blob/main/src/components/controls/TextInput/README.md#properties), with some exceptions and additions: -- `value` is required property; -- `onUpdate` is required property; - `type` is omitted; | Name | Description | Type | Default | diff --git a/src/components/controls/PasswordInput/__snapshots__/PasswordInput.visual.test.tsx-snapshots/PasswordInputStories-render-story-Default-dark-chromium-linux.png b/src/components/controls/PasswordInput/__snapshots__/PasswordInput.visual.test.tsx-snapshots/PasswordInput-render-story-Default-dark-chromium-linux.png similarity index 100% rename from src/components/controls/PasswordInput/__snapshots__/PasswordInput.visual.test.tsx-snapshots/PasswordInputStories-render-story-Default-dark-chromium-linux.png rename to src/components/controls/PasswordInput/__snapshots__/PasswordInput.visual.test.tsx-snapshots/PasswordInput-render-story-Default-dark-chromium-linux.png diff --git a/src/components/controls/PasswordInput/__snapshots__/PasswordInput.visual.test.tsx-snapshots/PasswordInputStories-render-story-Default-dark-webkit-linux.png b/src/components/controls/PasswordInput/__snapshots__/PasswordInput.visual.test.tsx-snapshots/PasswordInput-render-story-Default-dark-webkit-linux.png similarity index 100% rename from src/components/controls/PasswordInput/__snapshots__/PasswordInput.visual.test.tsx-snapshots/PasswordInputStories-render-story-Default-dark-webkit-linux.png rename to src/components/controls/PasswordInput/__snapshots__/PasswordInput.visual.test.tsx-snapshots/PasswordInput-render-story-Default-dark-webkit-linux.png diff --git a/src/components/controls/PasswordInput/__snapshots__/PasswordInput.visual.test.tsx-snapshots/PasswordInputStories-render-story-Default-light-chromium-linux.png b/src/components/controls/PasswordInput/__snapshots__/PasswordInput.visual.test.tsx-snapshots/PasswordInput-render-story-Default-light-chromium-linux.png similarity index 100% rename from src/components/controls/PasswordInput/__snapshots__/PasswordInput.visual.test.tsx-snapshots/PasswordInputStories-render-story-Default-light-chromium-linux.png rename to src/components/controls/PasswordInput/__snapshots__/PasswordInput.visual.test.tsx-snapshots/PasswordInput-render-story-Default-light-chromium-linux.png diff --git a/src/components/controls/PasswordInput/__snapshots__/PasswordInput.visual.test.tsx-snapshots/PasswordInputStories-render-story-Default-light-webkit-linux.png b/src/components/controls/PasswordInput/__snapshots__/PasswordInput.visual.test.tsx-snapshots/PasswordInput-render-story-Default-light-webkit-linux.png similarity index 100% rename from src/components/controls/PasswordInput/__snapshots__/PasswordInput.visual.test.tsx-snapshots/PasswordInputStories-render-story-Default-light-webkit-linux.png rename to src/components/controls/PasswordInput/__snapshots__/PasswordInput.visual.test.tsx-snapshots/PasswordInput-render-story-Default-light-webkit-linux.png diff --git a/src/components/controls/PasswordInput/__stories__/PasswordInput.stories.tsx b/src/components/controls/PasswordInput/__stories__/PasswordInput.stories.tsx index 8ac43c72ce..8ae6798ac1 100644 --- a/src/components/controls/PasswordInput/__stories__/PasswordInput.stories.tsx +++ b/src/components/controls/PasswordInput/__stories__/PasswordInput.stories.tsx @@ -3,15 +3,10 @@ import React from 'react'; import type {Meta, StoryFn} from '@storybook/react'; import {Button} from '../../../Button'; -import {Flex} from '../../../layout/Flex/Flex'; -import {cn} from '../../../utils/cn'; +import {Flex, spacing} from '../../../layout'; import type {PasswordInputProps} from '../PasswordInput'; import {PasswordInput} from '../PasswordInput'; -import './PasswordInputStories.scss'; - -const b = cn('password-input-stories'); - export default { title: 'Components/Inputs/PasswordInput', component: PasswordInput, @@ -52,9 +47,9 @@ const WithGenerateRandomValueTemplate: StoryFn = (args) => { return ( - + + + ); }; diff --git a/src/components/controls/PasswordInput/__stories__/PasswordInputStories.scss b/src/components/controls/PasswordInput/__stories__/PasswordInputStories.scss deleted file mode 100644 index 2ce1a88bd9..0000000000 --- a/src/components/controls/PasswordInput/__stories__/PasswordInputStories.scss +++ /dev/null @@ -1,5 +0,0 @@ -.password-input-stories { - &__button-generate-random-value { - margin-inline-start: 8px; - } -} diff --git a/src/components/controls/PasswordInput/__tests__/PasswordInput.visual.test.tsx b/src/components/controls/PasswordInput/__tests__/PasswordInput.visual.test.tsx index d82ef4a7b2..f6ab293e36 100644 --- a/src/components/controls/PasswordInput/__tests__/PasswordInput.visual.test.tsx +++ b/src/components/controls/PasswordInput/__tests__/PasswordInput.visual.test.tsx @@ -4,7 +4,7 @@ import {test} from '~playwright/core'; import {PasswordInputStories} from './helpersPlaywright'; -test.describe('PasswordInputStories', () => { +test.describe('PasswordInput', () => { test('render story: ', async ({mount, expectScreenshot}) => { await mount(); diff --git a/src/components/controls/PasswordInput/i18n/index.ts b/src/components/controls/PasswordInput/i18n/index.ts index 0e6a11a6f5..00314f8ae5 100644 --- a/src/components/controls/PasswordInput/i18n/index.ts +++ b/src/components/controls/PasswordInput/i18n/index.ts @@ -3,6 +3,6 @@ import {addComponentKeysets} from '../../../utils/addComponentKeysets'; import en from './en.json'; import ru from './ru.json'; -const COMPONENT = 'passwordInput'; +const COMPONENT = 'PasswordInput'; export const i18n = addComponentKeysets({en, ru}, COMPONENT);