From 7058b690e82951e9d9a2be1f2a6853f70f1f824c Mon Sep 17 00:00:00 2001 From: Eirik Backer Date: Thu, 31 Oct 2024 15:52:36 +0100 Subject: [PATCH] fix(Select): use field (#2709) Part of #2311 --- .../src/components/form/Select/Select.mdx | 18 +++--- .../components/form/Select/Select.stories.tsx | 48 ++++---------- .../src/components/form/Select/Select.tsx | 4 +- .../react/src/components/form/Select/index.ts | 13 ++-- .../src/components/form/Select/useSelect.ts | 64 ------------------- 5 files changed, 30 insertions(+), 117 deletions(-) delete mode 100644 packages/react/src/components/form/Select/useSelect.ts diff --git a/packages/react/src/components/form/Select/Select.mdx b/packages/react/src/components/form/Select/Select.mdx index b56fe8f323..6109a6e38d 100644 --- a/packages/react/src/components/form/Select/Select.mdx +++ b/packages/react/src/components/form/Select/Select.mdx @@ -18,14 +18,16 @@ For eksempel er det ikke mulig å overstyre formateringen av alternativene. ## Bruk ```tsx -import { Select } from '@digdir/designsystemet-react'; - - -; +import { Select, Field } from '@digdir/designsystemet-react'; + + + + + ``` ## Eksempler diff --git a/packages/react/src/components/form/Select/Select.stories.tsx b/packages/react/src/components/form/Select/Select.stories.tsx index 301628f919..9edbd811e6 100644 --- a/packages/react/src/components/form/Select/Select.stories.tsx +++ b/packages/react/src/components/form/Select/Select.stories.tsx @@ -1,7 +1,6 @@ import type { Meta, StoryFn } from '@storybook/react'; -import { Label } from '../../Label'; -import { Select } from './'; +import { Field, Label, Select, ValidationMessage } from '../../'; export default { title: 'Komponenter/Select', @@ -9,24 +8,11 @@ export default { parameters: { layout: 'padded', }, - decorators: [ - (Story) => ( -
- -
- ), - ], } as Meta; export const Preview: StoryFn = (args) => ( - <> - + + - + ); Preview.args = { @@ -46,12 +32,11 @@ Preview.args = { 'data-size': 'md', disabled: false, readOnly: false, - id: 'my-select', }; export const Disabled: StoryFn = (args) => ( - <> - + + - + ); Disabled.args = { disabled: true, - id: 'my-select', }; export const WithError: StoryFn = (args) => ( - <> - + + - + Velg et fjell + ); WithError.args = { 'aria-invalid': true, - id: 'my-select', }; export const WithOptgroup: StoryFn = (args) => ( - <> - + + - + ); - -WithOptgroup.args = { - id: 'my-select', -}; diff --git a/packages/react/src/components/form/Select/Select.tsx b/packages/react/src/components/form/Select/Select.tsx index f4ec2454bf..004a9a482f 100644 --- a/packages/react/src/components/form/Select/Select.tsx +++ b/packages/react/src/components/form/Select/Select.tsx @@ -8,10 +8,10 @@ export type SelectProps = { * @default false */ readOnly?: boolean; - /** Defines the width of