From 9801d334b9cb6c8bdc30d982020f447a1185f744 Mon Sep 17 00:00:00 2001 From: Valerii Sidorenko Date: Wed, 11 Sep 2024 14:33:08 +0200 Subject: [PATCH] feat(Select): pass aria attributes to render functions (#1841) --- .../Select/__stories__/Select.stories.tsx | 7 +-- .../Select/__stories__/SelectShowcase.tsx | 34 +++++++---- .../SelectControl/SelectControl.tsx | 47 +++++++++------ .../components/SelectFilter/SelectFilter.scss | 6 +- .../components/SelectFilter/SelectFilter.tsx | 31 +++++++--- src/components/Select/i18n/en.json | 3 +- src/components/Select/i18n/ru.json | 3 +- src/components/Select/types.ts | 58 +++++++++++++++---- 8 files changed, 132 insertions(+), 57 deletions(-) diff --git a/src/components/Select/__stories__/Select.stories.tsx b/src/components/Select/__stories__/Select.stories.tsx index 92feca1f36..2a2588623e 100644 --- a/src/components/Select/__stories__/Select.stories.tsx +++ b/src/components/Select/__stories__/Select.stories.tsx @@ -3,14 +3,13 @@ import React from 'react'; import type {Meta, StoryObj} from '@storybook/react'; import {Select} from '..'; -import type {SelectProps} from '..'; import {Button} from '../../Button'; import {SelectPopupWidthShowcase} from './SelectPopupWidthShowcase'; import {SelectShowcase} from './SelectShowcase'; import {UseSelectOptionsShowcase} from './UseSelectOptionsShowcase'; -const meta: Meta = { +const meta: Meta = { title: 'Components/Inputs/Select', component: Select, parameters: { @@ -31,7 +30,7 @@ const meta: Meta = { export default meta; -type Story = StoryObj; +type Story = StoryObj; export const Default = { render: (args) => ( @@ -45,7 +44,7 @@ export const Default = { } satisfies Story; export const Showcase = { - render: (args: SelectProps) => , + render: (args) => , args: { view: 'normal', size: 'm', diff --git a/src/components/Select/__stories__/SelectShowcase.tsx b/src/components/Select/__stories__/SelectShowcase.tsx index 36f7f25d91..2ce69cb6d0 100644 --- a/src/components/Select/__stories__/SelectShowcase.tsx +++ b/src/components/Select/__stories__/SelectShowcase.tsx @@ -120,14 +120,18 @@ export const SelectShowcase = (props: SelectProps) => { const [matchCase, setMatchCase] = React.useState(false); const [matchWholeWord, setMatchWholeWord] = React.useState(false); - const renderFilter: SelectProps['renderFilter'] = ({value, ref, onChange, onKeyDown}) => { + const renderFilter: SelectProps['renderFilter'] = ({ + ref, + style, + inputProps: {value, onChange, onKeyDown, ...controlProps}, + }) => { return ( -
+
@@ -281,20 +285,26 @@ export const SelectShowcase = (props: SelectProps) => { selectProps={{ ...props, className: b('user-control'), - renderControl: ({onClick, onKeyDown, ref, renderClear, disabled}) => { + renderControl: ({ + ref, + renderClear, + triggerProps: {onClick, disabled, id, ...extraProps}, + }) => { return (