From a4e6143011e4f40e6a70950400066781a00cf2da Mon Sep 17 00:00:00 2001 From: mariktar <100trk@gmail.com> Date: Wed, 18 Sep 2024 13:33:52 +0300 Subject: [PATCH 01/21] chore(react-components): rename Select --- .../__snapshots__/select.test.tsx.snap | 0 .../src/NativeSelect/index.ts | 1 + .../native_select.stories.tsx} | 10 ++--- .../native_select.test.tsx} | 14 +++--- .../native_select.tsx} | 44 ++++++++++--------- packages/react-components/src/Select/index.ts | 1 - packages/react-components/src/index.ts | 2 +- 7 files changed, 37 insertions(+), 35 deletions(-) rename packages/react-components/src/{Select => NativeSelect}/__snapshots__/select.test.tsx.snap (100%) create mode 100644 packages/react-components/src/NativeSelect/index.ts rename packages/react-components/src/{Select/select.stories.tsx => NativeSelect/native_select.stories.tsx} (76%) rename packages/react-components/src/{Select/select.test.tsx => NativeSelect/native_select.test.tsx} (64%) rename packages/react-components/src/{Select/select.tsx => NativeSelect/native_select.tsx} (86%) delete mode 100644 packages/react-components/src/Select/index.ts diff --git a/packages/react-components/src/Select/__snapshots__/select.test.tsx.snap b/packages/react-components/src/NativeSelect/__snapshots__/select.test.tsx.snap similarity index 100% rename from packages/react-components/src/Select/__snapshots__/select.test.tsx.snap rename to packages/react-components/src/NativeSelect/__snapshots__/select.test.tsx.snap diff --git a/packages/react-components/src/NativeSelect/index.ts b/packages/react-components/src/NativeSelect/index.ts new file mode 100644 index 00000000..f5715a12 --- /dev/null +++ b/packages/react-components/src/NativeSelect/index.ts @@ -0,0 +1 @@ +export { NativeSelect } from './native_select'; diff --git a/packages/react-components/src/Select/select.stories.tsx b/packages/react-components/src/NativeSelect/native_select.stories.tsx similarity index 76% rename from packages/react-components/src/Select/select.stories.tsx rename to packages/react-components/src/NativeSelect/native_select.stories.tsx index 32fdf174..1910a9a7 100644 --- a/packages/react-components/src/Select/select.stories.tsx +++ b/packages/react-components/src/NativeSelect/native_select.stories.tsx @@ -1,9 +1,9 @@ import type { Meta, StoryObj } from '@storybook/react'; -import { Select } from './index'; +import { NativeSelect } from './index'; -const meta: Meta = { - title: 'Components/Select', - component: Select, +const meta: Meta = { + title: 'Components/NativeSelect', + component: NativeSelect, args: { options: [ { @@ -34,6 +34,6 @@ const meta: Meta = { export default meta; -type Story = StoryObj; +type Story = StoryObj; export const Playground: Story = {}; diff --git a/packages/react-components/src/Select/select.test.tsx b/packages/react-components/src/NativeSelect/native_select.test.tsx similarity index 64% rename from packages/react-components/src/Select/select.test.tsx rename to packages/react-components/src/NativeSelect/native_select.test.tsx index cf5f019e..63248010 100644 --- a/packages/react-components/src/Select/select.test.tsx +++ b/packages/react-components/src/NativeSelect/native_select.test.tsx @@ -1,16 +1,16 @@ import React from 'react'; import { renderWithWrapper as render } from '../test-utils'; -import { Select } from './index'; +import { NativeSelect } from './index'; -describe(', + , ); expect(asFragment()).toMatchSnapshot(); @@ -18,14 +18,14 @@ describe(', + , ); expect(asFragment()).toMatchSnapshot(); }); describe('sizes', () => { - const sizes: Array['size']> = [ + const sizes: Array['size']> = [ 'small', 'medium', 'large', @@ -34,7 +34,7 @@ describe(', + , ); expect(asFragment()).toMatchSnapshot(); diff --git a/packages/react-components/src/Select/select.tsx b/packages/react-components/src/NativeSelect/native_select.tsx similarity index 86% rename from packages/react-components/src/Select/select.tsx rename to packages/react-components/src/NativeSelect/native_select.tsx index e024dfb3..eef2312a 100644 --- a/packages/react-components/src/Select/select.tsx +++ b/packages/react-components/src/NativeSelect/native_select.tsx @@ -6,7 +6,7 @@ import { ArrowDropDownIcon } from '../icons'; /** * Types. */ -type SelectOwnProps = { +type NativeSelectOwnProps = { options: { value: string; label: string; @@ -78,9 +78,9 @@ type SelectOwnProps = { onChange?: React.ChangeEventHandler; }; -type SelectProps = SelectOwnProps & Omit, 'onChange'>; -type SelectRootProps = React.HTMLAttributes & { - selectSize?: SelectOwnProps['size'] +type NativeSelectProps = NativeSelectOwnProps & Omit, 'onChange'>; +type NativeSelectRootProps = React.HTMLAttributes & { + selectSize?: NativeSelectOwnProps['size'] }; /** * @@ -89,7 +89,7 @@ type SelectRootProps = React.HTMLAttributes & { /** * Styles. */ -const SelectRoot = styled('select')( +const NativeSelectRoot = styled('select')( (props) => ({ fontFamily: 'inherit', outline: 'none', @@ -170,20 +170,22 @@ const SelectRoot = styled('select')( }, ); -const SelectLabel = styled('label')({ +const NativeSelectLabel = styled('label')({ marginBottom: '2px', display: 'inline-block', }); -const SelectErrorMessage = styled(Typography)({ +const NativeSelectErrorMessage = styled(Typography)({ marginTop: '2px', }); -const SelectContainer = styled('div')({ +const NativeSelectContainer = styled('div')({ position: 'relative', }); -const SelectArrowIcon = styled(ArrowDropDownIcon)>((props) => ({ +const NativeSelectArrowIcon = styled( + ArrowDropDownIcon, +)>((props) => ({ position: 'absolute', right: '0px', top: 'calc(50% - 12px)', @@ -198,7 +200,7 @@ const SelectArrowIcon = styled(ArrowDropDownIcon)((props, ref) => { +export const NativeSelect = React.forwardRef((props, ref) => { const { options, size, @@ -225,7 +227,7 @@ export const Select = React.forwardRef((props, ref) {...other} > {label && ( - ((props, ref) > {label} - + )} - - + ((props, ref) {option.label} ))} - - + - + {error && errorText && ( - {errorText} - + )} ); }); -Select.displayName = 'Select'; +NativeSelect.displayName = 'NativeSelect'; -Select.defaultProps = { +NativeSelect.defaultProps = { disabled: false, size: 'medium', }; diff --git a/packages/react-components/src/Select/index.ts b/packages/react-components/src/Select/index.ts deleted file mode 100644 index de9bdf23..00000000 --- a/packages/react-components/src/Select/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { Select } from './select'; diff --git a/packages/react-components/src/index.ts b/packages/react-components/src/index.ts index 149c15f5..f290cf83 100644 --- a/packages/react-components/src/index.ts +++ b/packages/react-components/src/index.ts @@ -20,7 +20,7 @@ export * from './Popper'; export * from './Popover'; export * from './Portal'; export * from './Radio'; -export * from './Select'; +export * from './NativeSelect'; export * from './Skeleton'; export * from './Autocomplete'; export * from './Slide'; From 8a50c4a50d485767ce4019b430b10df1eca4e69d Mon Sep 17 00:00:00 2001 From: mariktar <100trk@gmail.com> Date: Wed, 18 Sep 2024 13:38:20 +0300 Subject: [PATCH 02/21] chore(react-components): rename Autocomplete --- .../src/Autocomplete/index.ts | 1 - .../__snapshots__/autocomplete.test.tsx.snap | 0 packages/react-components/src/Select/index.ts | 1 + .../select.stories.tsx} | 10 +- .../select.test.tsx} | 20 +-- .../autocomplete.tsx => Select/select.tsx} | 116 +++++++++--------- packages/react-components/src/index.ts | 2 +- 7 files changed, 75 insertions(+), 75 deletions(-) delete mode 100644 packages/react-components/src/Autocomplete/index.ts rename packages/react-components/src/{Autocomplete => Select}/__snapshots__/autocomplete.test.tsx.snap (100%) create mode 100644 packages/react-components/src/Select/index.ts rename packages/react-components/src/{Autocomplete/autocomplete.stories.tsx => Select/select.stories.tsx} (96%) rename packages/react-components/src/{Autocomplete/autocomplete.test.tsx => Select/select.test.tsx} (86%) rename packages/react-components/src/{Autocomplete/autocomplete.tsx => Select/select.tsx} (84%) diff --git a/packages/react-components/src/Autocomplete/index.ts b/packages/react-components/src/Autocomplete/index.ts deleted file mode 100644 index 7020b66f..00000000 --- a/packages/react-components/src/Autocomplete/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { Autocomplete } from './autocomplete'; diff --git a/packages/react-components/src/Autocomplete/__snapshots__/autocomplete.test.tsx.snap b/packages/react-components/src/Select/__snapshots__/autocomplete.test.tsx.snap similarity index 100% rename from packages/react-components/src/Autocomplete/__snapshots__/autocomplete.test.tsx.snap rename to packages/react-components/src/Select/__snapshots__/autocomplete.test.tsx.snap diff --git a/packages/react-components/src/Select/index.ts b/packages/react-components/src/Select/index.ts new file mode 100644 index 00000000..de9bdf23 --- /dev/null +++ b/packages/react-components/src/Select/index.ts @@ -0,0 +1 @@ +export { Select } from './select'; diff --git a/packages/react-components/src/Autocomplete/autocomplete.stories.tsx b/packages/react-components/src/Select/select.stories.tsx similarity index 96% rename from packages/react-components/src/Autocomplete/autocomplete.stories.tsx rename to packages/react-components/src/Select/select.stories.tsx index 1a7f233f..420d62da 100644 --- a/packages/react-components/src/Autocomplete/autocomplete.stories.tsx +++ b/packages/react-components/src/Select/select.stories.tsx @@ -1,5 +1,5 @@ import type { Meta, StoryObj } from '@storybook/react'; -import { Autocomplete } from './index'; +import { Select } from './index'; const top100Films = [ { title: 'The Shawshank Redemption', year: 1994 }, @@ -104,10 +104,10 @@ const top100Films = [ { title: 'Monty Python and the Holy Grail', year: 1975 }, ]; -const meta: Meta = { - title: 'Components/Autocomplete', +const meta: Meta = { + title: 'Components/Select', // @ts-ignore - component: Autocomplete, + component: Select, args: { options: top100Films, placeholder: 'Select a movie', @@ -126,6 +126,6 @@ const meta: Meta = { export default meta; -type Story = StoryObj; +type Story = StoryObj; export const Playground: Story = {}; diff --git a/packages/react-components/src/Autocomplete/autocomplete.test.tsx b/packages/react-components/src/Select/select.test.tsx similarity index 86% rename from packages/react-components/src/Autocomplete/autocomplete.test.tsx rename to packages/react-components/src/Select/select.test.tsx index 70a5f7a3..f5b473d9 100644 --- a/packages/react-components/src/Autocomplete/autocomplete.test.tsx +++ b/packages/react-components/src/Select/select.test.tsx @@ -1,13 +1,13 @@ import React from 'react'; import { renderWithWrapper as render, screen, fireEvent } from '../test-utils'; -import { Autocomplete } from './index'; +import { Select } from './index'; -describe('', () => { +describe(' + + + +`; + +exports[` should pass error 1`] = ` +.emotion-0 { + margin: 0; + color: var(--pv-color-black); + font-weight: var(--pv-text-b3-weight); + font-size: var(--pv-text-b3-size); + line-height: var(--pv-text-b3-height); + letter-spacing: var(--pv-text-b3-spacing); + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; + outline: none; + box-sizing: border-box; + width: 100%; + border-radius: 4px; + padding: 0 calc(var(--pv-size-base-2) + 24px) 0 var(--pv-size-base-2); + background-color: var(--pv-color-gray-1); + border-style: solid; + border-width: 1px; + -webkit-transition: background-color 200ms,color 200ms,border-color 200ms; + transition: background-color 200ms,color 200ms,border-color 200ms; + -webkit-appearance: none; + -moz-appearance: none; + -ms-appearance: none; + appearance: none; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; + text-align: left; + cursor: pointer; + font-family: inherit; + height: var(--pv-size-base-7); + position: relative; + border-color: var(--pv-color-gray-8); +} + +.emotion-0:hover { + background-color: var(--pv-color-gray-3); + border-color: var(--pv-color-gray-7); +} + +.emotion-0:disabled { + cursor: not-allowed; + background-color: var(--pv-color-gray-1); + border-color: var(--pv-color-gray-5); + color: var(--pv-color-gray-7); +} + +.emotion-0:not(:disabled) { + color: var(--pv-color-black); +} + +.emotion-0:not(:disabled)[aria-placeholder] { + color: var(--pv-color-gray-9); +} + +.emotion-0:not(:disabled)[aria-invalid] { + background-color: var(--pv-color-wrong-tint-5); + border-color: var(--pv-color-wrong-tint-3); +} + +.emotion-0:not(:disabled):focus-visible { + background-color: var(--pv-color-secondary-tint-5); + border-color: var(--pv-color-secondary-tint-3); +} + +.emotion-1 { + position: absolute; + right: 0px; + top: calc(50% - 12px); + margin: 0px var(--pv-size-base); + color: var(--pv-color-gray-10); +} + +.emotion-1[aria-disabled="true"] { + color: inherit; +} + +.emotion-2 { + bottom: 0; + left: 0; + height: 100%; + position: absolute; + opacity: 0; + pointer-events: none; + width: 100%; + box-sizing: border-box; +} + +.emotion-3 { + margin: 0; + color: var(--pv-color-wrong); + font-weight: var(--pv-text-c2-weight); + font-size: var(--pv-text-c2-size); + line-height: var(--pv-text-c2-height); + letter-spacing: var(--pv-text-c2-spacing); + margin-top: 2px; +} + +.emotion-4 { + position: fixed; + z-index: 1300; + top: 0; + bottom: 0; + right: 0; + left: 0; +} + +.emotion-5 { + background: var(--pv-color-black); + z-index: -1; + position: fixed; + right: 0; + bottom: 0; + top: 0; + left: 0; + -webkit-tap-highlight-color: transparent; + background-color: transparent; +} + +.emotion-6 { + outline: 0; + max-width: calc(100% - 32px); + min-width: 16px; + max-height: calc(100% - 32px); + min-height: 16px; + border-radius: 4px; + box-shadow: var(--pv-shadow-light-low); + background-color: var(--pv-color-white); + min-width: 240px; +} + +.emotion-7 { + border-color: var(--pv-color-gray-3); + border-style: solid; + border-width: 0px 0px 1px 0px; +} + +.emotion-8 { + padding: var(--pv-size-base-3) var(--pv-size-base-3) var(--pv-size-base-2); +} + +.emotion-9 { + margin: 0; + color: var(--pv-color-black); + font-weight: var(--pv-text-b3-weight); + font-size: var(--pv-text-b3-size); + line-height: var(--pv-text-b3-height); + letter-spacing: var(--pv-text-b3-spacing); + font-family: inherit; + outline: none; + box-sizing: border-box; + width: 100%; + border-radius: 4px; + padding: 0 var(--pv-size-base-2); + background-color: var(--pv-color-gray-1); + border-style: solid; + border-width: 1px; + -webkit-transition: background-color 200ms,color 200ms,border-color 200ms; + transition: background-color 200ms,color 200ms,border-color 200ms; + display: -webkit-inline-box; + display: -webkit-inline-flex; + display: -ms-inline-flexbox; + display: inline-flex; + -webkit-appearance: none; + -moz-appearance: none; + -ms-appearance: none; + appearance: none; + height: var(--pv-size-base-7); + color: var(--pv-color-black); + border-color: var(--pv-color-gray-8); +} + +.emotion-9::-webkit-input-placeholder { + color: var(--pv-color-gray-9); +} + +.emotion-9::-moz-placeholder { + color: var(--pv-color-gray-9); +} + +.emotion-9:-ms-input-placeholder { + color: var(--pv-color-gray-9); +} + +.emotion-9::placeholder { + color: var(--pv-color-gray-9); +} + +.emotion-9:hover { + background-color: var(--pv-color-gray-3); + border-color: var(--pv-color-gray-7); +} + +.emotion-9:disabled { + cursor: not-allowed; + background-color: var(--pv-color-gray-1); + border-color: var(--pv-color-gray-5); + color: var(--pv-color-gray-7); +} + +.emotion-9:not(:disabled)[aria-invalid] { + background-color: var(--pv-color-wrong-tint-5); + border-color: var(--pv-color-wrong-tint-3); +} + +.emotion-9:not(:disabled):focus-visible { + background-color: var(--pv-color-secondary-tint-5); + border-color: var(--pv-color-secondary-tint-3); +} + +.emotion-10 { + padding: var(--pv-size-base-3) var(--pv-size-base-2); +} + +.emotion-11 { + margin: 0; + color: var(--pv-color-gray-10); + font-weight: var(--pv-text-b2-weight); + font-size: var(--pv-text-b2-size); + line-height: var(--pv-text-b2-height); + letter-spacing: var(--pv-text-b2-spacing); +} + + +
+
+ +

+ Error text +

+
+
+