From 0f93b668c81289ed422ec9211a33f7f007f2f933 Mon Sep 17 00:00:00 2001 From: Tobias Barsnes Date: Tue, 10 Dec 2024 15:41:53 +0100 Subject: [PATCH] chore: flatten components folder (#2874) Flattens `form` and `loaders` folders --------- Co-authored-by: Michael Marszalek --- apps/storybook/.storybook/preview.tsx | 9 ++++++- .../react/src/components/Button/Button.tsx | 2 +- .../{form => }/Checkbox/Checkbox.mdx | 2 +- .../{form => }/Checkbox/Checkbox.stories.tsx | 3 +-- .../{form => }/Checkbox/Checkbox.test.tsx | 0 .../{form => }/Checkbox/Checkbox.tsx | 10 +++---- .../react/src/components/Checkbox/index.ts | 1 + packages/react/src/components/Chip/Chips.tsx | 2 +- .../{form => }/Combobox/Combobox.mdx | 0 .../{form => }/Combobox/Combobox.stories.tsx | 12 ++++----- .../{form => }/Combobox/Combobox.test.tsx | 0 .../{form => }/Combobox/Combobox.tsx | 12 ++++----- .../{form => }/Combobox/ComboboxContext.tsx | 2 +- .../{form => }/Combobox/ComboboxIdContext.tsx | 0 .../components/{form => }/Combobox/Custom.tsx | 4 +-- .../components/{form => }/Combobox/Empty.tsx | 2 +- .../Combobox/Option/Description.tsx | 0 .../{form => }/Combobox/Option/Option.tsx | 4 +-- .../Combobox/Option/SelectedIcon.tsx | 0 .../Combobox/Option/useComboboxOption.tsx | 2 +- .../{form => }/Combobox/data/data.ts | 0 .../components/{form => }/Combobox/index.ts | 0 .../Combobox/internal/ComboboxChips.tsx | 2 +- .../Combobox/internal/ComboboxClearButton.tsx | 0 .../Combobox/internal/ComboboxError.tsx | 4 +-- .../Combobox/internal/ComboboxInput.tsx | 4 +-- .../Combobox/internal/ComboboxLabel.tsx | 6 ++--- .../Combobox/internal/ComboboxNative.tsx | 0 .../{form => }/Combobox/useCombobox.test.tsx | 0 .../{form => }/Combobox/useCombobox.tsx | 0 .../Combobox/useComboboxKeyboard.tsx | 2 +- .../Combobox/useFloatingCombobox.tsx | 0 .../{form => }/Combobox/utilities.ts | 0 .../ErrorSummary/ErrorSummary.stories.tsx | 2 +- .../src/components/{form => }/Field/Field.mdx | 0 .../{form => }/Field/Field.stories.tsx | 4 +-- .../src/components/{form => }/Field/Field.tsx | 2 +- .../{form => }/Field/FieldAffix.tsx | 0 .../{form => }/Field/FieldCounter.tsx | 2 +- .../{form => }/Field/FieldDescription.tsx | 0 .../{form => }/Field/fieldObserver.test.tsx | 0 .../{form => }/Field/fieldObserver.ts | 0 .../src/components/{form => }/Field/index.ts | 0 .../{form => }/Fieldset/Fieldset.mdx | 0 .../{form => }/Fieldset/Fieldset.stories.tsx | 0 .../{form => }/Fieldset/Fieldset.test.tsx | 0 .../{form => }/Fieldset/Fieldset.tsx | 2 +- .../{form => }/Fieldset/FieldsetContext.ts | 2 +- .../Fieldset/FieldsetDescription.tsx | 2 +- .../{form => }/Fieldset/FieldsetLegend.tsx | 4 +-- .../components/{form => }/Fieldset/index.ts | 0 .../src/components/{form => }/Input/Input.mdx | 2 +- .../{form => }/Input/Input.stories.tsx | 2 +- .../{form => }/Input/Input.test.tsx | 0 .../src/components/{form => }/Input/Input.tsx | 6 ++--- .../src/components/{form => }/Input/index.ts | 0 .../src/components/{form => }/Radio/Radio.mdx | 2 +- .../{form => }/Radio/Radio.stories.tsx | 3 +-- .../{form => }/Radio/Radio.test.tsx | 0 .../src/components/{form => }/Radio/Radio.tsx | 10 +++---- packages/react/src/components/Radio/index.ts | 1 + .../components/{form => }/Search/Search.mdx | 0 .../{form => }/Search/Search.stories.tsx | 0 .../{form => }/Search/Search.test.tsx | 0 .../components/{form => }/Search/Search.tsx | 2 +- .../{form => }/Search/SearchButton.tsx | 4 +-- .../{form => }/Search/SearchClear.tsx | 2 +- .../{form => }/Search/SearchInput.tsx | 2 +- .../src/components/{form => }/Search/index.ts | 0 .../components/{form => }/Select/Select.mdx | 0 .../{form => }/Select/Select.stories.tsx | 0 .../{form => }/Select/Select.test.tsx | 0 .../components/{form => }/Select/Select.tsx | 4 +-- .../{form => }/Select/SelectOptgroup.tsx | 0 .../{form => }/Select/SelectOption.tsx | 0 .../src/components/{form => }/Select/index.ts | 0 .../{loaders => }/Skeleton/Skeleton.mdx | 0 .../Skeleton/Skeleton.stories.tsx | 0 .../{loaders => }/Skeleton/Skeleton.test.tsx | 0 .../{loaders => }/Skeleton/Skeleton.tsx | 9 ++++++- .../react/src/components/Skeleton/index.ts | 2 ++ .../{loaders => }/Spinner/Spinner.mdx | 0 .../{loaders => }/Spinner/Spinner.stories.tsx | 0 .../{loaders => }/Spinner/Spinner.test.tsx | 0 .../{loaders => }/Spinner/Spinner.tsx | 4 +-- .../components/{loaders => }/Spinner/index.ts | 0 .../components/{form => }/Switch/Switch.mdx | 0 .../{form => }/Switch/Switch.stories.tsx | 0 .../{form => }/Switch/Switch.test.tsx | 0 .../components/{form => }/Switch/Switch.tsx | 8 +++--- .../src/components/{form => }/Switch/index.ts | 0 .../src/components/Table/Table.stories.tsx | 3 ++- .../{form => }/Textarea/Textarea.mdx | 0 .../{form => }/Textarea/Textarea.stories.tsx | 0 .../{form => }/Textarea/Textarea.test.tsx | 0 .../{form => }/Textarea/Textarea.tsx | 2 +- .../components/{form => }/Textarea/index.ts | 0 .../{form => }/Textarea/useTextarea.ts | 4 +-- .../{form => }/Textfield/Textfield.mdx | 2 -- .../Textfield/Textfield.stories.tsx | 0 .../{form => }/Textfield/Textfield.test.tsx | 0 .../{form => }/Textfield/Textfield.tsx | 6 ++--- .../components/{form => }/Textfield/index.ts | 0 .../src/components/form/Checkbox/index.ts | 2 -- .../react/src/components/form/Radio/index.ts | 2 -- packages/react/src/components/index.ts | 26 +++++++++---------- .../src/components/loaders/Skeleton/index.ts | 11 -------- packages/react/src/utilities/hooks/index.ts | 7 ++++- .../hooks/useFormField}/useFormField.test.tsx | 4 +-- .../hooks/useFormField}/useFormField.ts | 4 +-- .../{ => usePrevious}/usePrevious.test.ts | 2 +- .../hooks/{ => usePrevious}/usePrevious.ts | 0 .../useRadioGroup/useRadioGroup.test.tsx | 9 +++---- .../loaders => stories}/Loaders.mdx | 4 +-- 114 files changed, 130 insertions(+), 126 deletions(-) rename packages/react/src/components/{form => }/Checkbox/Checkbox.mdx (98%) rename packages/react/src/components/{form => }/Checkbox/Checkbox.stories.tsx (98%) rename packages/react/src/components/{form => }/Checkbox/Checkbox.test.tsx (100%) rename packages/react/src/components/{form => }/Checkbox/Checkbox.tsx (84%) create mode 100644 packages/react/src/components/Checkbox/index.ts rename packages/react/src/components/{form => }/Combobox/Combobox.mdx (100%) rename packages/react/src/components/{form => }/Combobox/Combobox.stories.tsx (98%) rename packages/react/src/components/{form => }/Combobox/Combobox.test.tsx (100%) rename packages/react/src/components/{form => }/Combobox/Combobox.tsx (97%) rename packages/react/src/components/{form => }/Combobox/ComboboxContext.tsx (95%) rename packages/react/src/components/{form => }/Combobox/ComboboxIdContext.tsx (100%) rename packages/react/src/components/{form => }/Combobox/Custom.tsx (96%) rename packages/react/src/components/{form => }/Combobox/Empty.tsx (96%) rename packages/react/src/components/{form => }/Combobox/Option/Description.tsx (100%) rename packages/react/src/components/{form => }/Combobox/Option/Option.tsx (97%) rename packages/react/src/components/{form => }/Combobox/Option/SelectedIcon.tsx (100%) rename packages/react/src/components/{form => }/Combobox/Option/useComboboxOption.tsx (94%) rename packages/react/src/components/{form => }/Combobox/data/data.ts (100%) rename packages/react/src/components/{form => }/Combobox/index.ts (100%) rename packages/react/src/components/{form => }/Combobox/internal/ComboboxChips.tsx (97%) rename packages/react/src/components/{form => }/Combobox/internal/ComboboxClearButton.tsx (100%) rename packages/react/src/components/{form => }/Combobox/internal/ComboboxError.tsx (80%) rename packages/react/src/components/{form => }/Combobox/internal/ComboboxInput.tsx (98%) rename packages/react/src/components/{form => }/Combobox/internal/ComboboxLabel.tsx (89%) rename packages/react/src/components/{form => }/Combobox/internal/ComboboxNative.tsx (100%) rename packages/react/src/components/{form => }/Combobox/useCombobox.test.tsx (100%) rename packages/react/src/components/{form => }/Combobox/useCombobox.tsx (100%) rename packages/react/src/components/{form => }/Combobox/useComboboxKeyboard.tsx (98%) rename packages/react/src/components/{form => }/Combobox/useFloatingCombobox.tsx (100%) rename packages/react/src/components/{form => }/Combobox/utilities.ts (100%) rename packages/react/src/components/{form => }/Field/Field.mdx (100%) rename packages/react/src/components/{form => }/Field/Field.stories.tsx (97%) rename packages/react/src/components/{form => }/Field/Field.tsx (93%) rename packages/react/src/components/{form => }/Field/FieldAffix.tsx (100%) rename packages/react/src/components/{form => }/Field/FieldCounter.tsx (98%) rename packages/react/src/components/{form => }/Field/FieldDescription.tsx (100%) rename packages/react/src/components/{form => }/Field/fieldObserver.test.tsx (100%) rename packages/react/src/components/{form => }/Field/fieldObserver.ts (100%) rename packages/react/src/components/{form => }/Field/index.ts (100%) rename packages/react/src/components/{form => }/Fieldset/Fieldset.mdx (100%) rename packages/react/src/components/{form => }/Fieldset/Fieldset.stories.tsx (100%) rename packages/react/src/components/{form => }/Fieldset/Fieldset.test.tsx (100%) rename packages/react/src/components/{form => }/Fieldset/Fieldset.tsx (89%) rename packages/react/src/components/{form => }/Fieldset/FieldsetContext.ts (72%) rename packages/react/src/components/{form => }/Fieldset/FieldsetDescription.tsx (78%) rename packages/react/src/components/{form => }/Fieldset/FieldsetLegend.tsx (79%) rename packages/react/src/components/{form => }/Fieldset/index.ts (100%) rename packages/react/src/components/{form => }/Input/Input.mdx (97%) rename packages/react/src/components/{form => }/Input/Input.stories.tsx (99%) rename packages/react/src/components/{form => }/Input/Input.test.tsx (100%) rename packages/react/src/components/{form => }/Input/Input.tsx (91%) rename packages/react/src/components/{form => }/Input/index.ts (100%) rename packages/react/src/components/{form => }/Radio/Radio.mdx (98%) rename packages/react/src/components/{form => }/Radio/Radio.stories.tsx (97%) rename packages/react/src/components/{form => }/Radio/Radio.test.tsx (100%) rename packages/react/src/components/{form => }/Radio/Radio.tsx (83%) create mode 100644 packages/react/src/components/Radio/index.ts rename packages/react/src/components/{form => }/Search/Search.mdx (100%) rename packages/react/src/components/{form => }/Search/Search.stories.tsx (100%) rename packages/react/src/components/{form => }/Search/Search.test.tsx (100%) rename packages/react/src/components/{form => }/Search/Search.tsx (86%) rename packages/react/src/components/{form => }/Search/SearchButton.tsx (81%) rename packages/react/src/components/{form => }/Search/SearchClear.tsx (95%) rename packages/react/src/components/{form => }/Search/SearchInput.tsx (91%) rename packages/react/src/components/{form => }/Search/index.ts (100%) rename packages/react/src/components/{form => }/Select/Select.mdx (100%) rename packages/react/src/components/{form => }/Select/Select.stories.tsx (100%) rename packages/react/src/components/{form => }/Select/Select.test.tsx (100%) rename packages/react/src/components/{form => }/Select/Select.tsx (91%) rename packages/react/src/components/{form => }/Select/SelectOptgroup.tsx (100%) rename packages/react/src/components/{form => }/Select/SelectOption.tsx (100%) rename packages/react/src/components/{form => }/Select/index.ts (100%) rename packages/react/src/components/{loaders => }/Skeleton/Skeleton.mdx (100%) rename packages/react/src/components/{loaders => }/Skeleton/Skeleton.stories.tsx (100%) rename packages/react/src/components/{loaders => }/Skeleton/Skeleton.test.tsx (100%) rename packages/react/src/components/{loaders => }/Skeleton/Skeleton.tsx (84%) create mode 100644 packages/react/src/components/Skeleton/index.ts rename packages/react/src/components/{loaders => }/Spinner/Spinner.mdx (100%) rename packages/react/src/components/{loaders => }/Spinner/Spinner.stories.tsx (100%) rename packages/react/src/components/{loaders => }/Spinner/Spinner.test.tsx (100%) rename packages/react/src/components/{loaders => }/Spinner/Spinner.tsx (94%) rename packages/react/src/components/{loaders => }/Spinner/index.ts (100%) rename packages/react/src/components/{form => }/Switch/Switch.mdx (100%) rename packages/react/src/components/{form => }/Switch/Switch.stories.tsx (100%) rename packages/react/src/components/{form => }/Switch/Switch.test.tsx (100%) rename packages/react/src/components/{form => }/Switch/Switch.tsx (88%) rename packages/react/src/components/{form => }/Switch/index.ts (100%) rename packages/react/src/components/{form => }/Textarea/Textarea.mdx (100%) rename packages/react/src/components/{form => }/Textarea/Textarea.stories.tsx (100%) rename packages/react/src/components/{form => }/Textarea/Textarea.test.tsx (100%) rename packages/react/src/components/{form => }/Textarea/Textarea.tsx (91%) rename packages/react/src/components/{form => }/Textarea/index.ts (100%) rename packages/react/src/components/{form => }/Textarea/useTextarea.ts (87%) rename packages/react/src/components/{form => }/Textfield/Textfield.mdx (97%) rename packages/react/src/components/{form => }/Textfield/Textfield.stories.tsx (100%) rename packages/react/src/components/{form => }/Textfield/Textfield.test.tsx (100%) rename packages/react/src/components/{form => }/Textfield/Textfield.tsx (94%) rename packages/react/src/components/{form => }/Textfield/index.ts (100%) delete mode 100644 packages/react/src/components/form/Checkbox/index.ts delete mode 100644 packages/react/src/components/form/Radio/index.ts delete mode 100644 packages/react/src/components/loaders/Skeleton/index.ts rename packages/react/src/{components/form => utilities/hooks/useFormField}/useFormField.test.tsx (95%) rename packages/react/src/{components/form => utilities/hooks/useFormField}/useFormField.ts (94%) rename packages/react/src/utilities/hooks/{ => usePrevious}/usePrevious.test.ts (95%) rename packages/react/src/utilities/hooks/{ => usePrevious}/usePrevious.ts (100%) rename packages/react/{src/components/loaders => stories}/Loaders.mdx (91%) diff --git a/apps/storybook/.storybook/preview.tsx b/apps/storybook/.storybook/preview.tsx index 1b902a00d4..e61363c652 100644 --- a/apps/storybook/.storybook/preview.tsx +++ b/apps/storybook/.storybook/preview.tsx @@ -43,7 +43,14 @@ const getPath = (href: string | undefined): string => { const components = { p: (props: Props) => ( - + ), ol: (props: Props) => ( , diff --git a/packages/react/src/components/form/Checkbox/Checkbox.mdx b/packages/react/src/components/Checkbox/Checkbox.mdx similarity index 98% rename from packages/react/src/components/form/Checkbox/Checkbox.mdx rename to packages/react/src/components/Checkbox/Checkbox.mdx index d3822b4329..ac5d181150 100644 --- a/packages/react/src/components/form/Checkbox/Checkbox.mdx +++ b/packages/react/src/components/Checkbox/Checkbox.mdx @@ -2,7 +2,7 @@ import { Meta, Canvas, Controls, Primary, ArgTypes } from '@storybook/blocks'; import { Do, Dont, Stack, CssVariables } from '@doc-components'; import css from '@digdir/designsystemet-css/input.css?inline'; import * as CheckboxStories from './Checkbox.stories'; -import * as useCheckboxGroupStories from '../../../utilities/hooks/useCheckboxGroup/useCheckboxGroup.stories'; +import * as useCheckboxGroupStories from '../../utilities/hooks/useCheckboxGroup/useCheckboxGroup.stories'; diff --git a/packages/react/src/components/form/Checkbox/Checkbox.stories.tsx b/packages/react/src/components/Checkbox/Checkbox.stories.tsx similarity index 98% rename from packages/react/src/components/form/Checkbox/Checkbox.stories.tsx rename to packages/react/src/components/Checkbox/Checkbox.stories.tsx index b58257f7fd..f1e82fa65f 100644 --- a/packages/react/src/components/form/Checkbox/Checkbox.stories.tsx +++ b/packages/react/src/components/Checkbox/Checkbox.stories.tsx @@ -6,10 +6,9 @@ import { Fieldset, Paragraph, Table, - type UseCheckboxGroupProps, ValidationMessage, - useCheckboxGroup, } from '../..'; +import { type UseCheckboxGroupProps, useCheckboxGroup } from '../../utilities'; type Story = StoryObj; diff --git a/packages/react/src/components/form/Checkbox/Checkbox.test.tsx b/packages/react/src/components/Checkbox/Checkbox.test.tsx similarity index 100% rename from packages/react/src/components/form/Checkbox/Checkbox.test.tsx rename to packages/react/src/components/Checkbox/Checkbox.test.tsx diff --git a/packages/react/src/components/form/Checkbox/Checkbox.tsx b/packages/react/src/components/Checkbox/Checkbox.tsx similarity index 84% rename from packages/react/src/components/form/Checkbox/Checkbox.tsx rename to packages/react/src/components/Checkbox/Checkbox.tsx index c25c976fe0..64a7f39296 100644 --- a/packages/react/src/components/form/Checkbox/Checkbox.tsx +++ b/packages/react/src/components/Checkbox/Checkbox.tsx @@ -1,13 +1,13 @@ import type { ReactNode } from 'react'; import { forwardRef } from 'react'; -import type { Color } from '../../../colors'; -import type { DefaultProps, LabelRequired } from '../../../types'; -import type { MergeRight } from '../../../utilities'; -import { Label } from '../../Label'; -import { ValidationMessage } from '../../ValidationMessage'; +import type { Color } from '../../colors'; +import type { DefaultProps, LabelRequired } from '../../types'; +import type { MergeRight } from '../../utilities'; import { Field } from '../Field'; import { Input, type InputProps } from '../Input'; +import { Label } from '../Label'; +import { ValidationMessage } from '../ValidationMessage'; export type CheckboxProps = MergeRight< DefaultProps & Omit, diff --git a/packages/react/src/components/Checkbox/index.ts b/packages/react/src/components/Checkbox/index.ts new file mode 100644 index 0000000000..f5c939faf4 --- /dev/null +++ b/packages/react/src/components/Checkbox/index.ts @@ -0,0 +1 @@ +export * from './Checkbox'; diff --git a/packages/react/src/components/Chip/Chips.tsx b/packages/react/src/components/Chip/Chips.tsx index 8e45d892b9..109c56ac3c 100644 --- a/packages/react/src/components/Chip/Chips.tsx +++ b/packages/react/src/components/Chip/Chips.tsx @@ -5,7 +5,7 @@ import type { ButtonHTMLAttributes, InputHTMLAttributes } from 'react'; import type { Color } from '../../colors'; import type { DefaultProps } from '../../types'; import type { MergeRight } from '../../utilities'; -import { Input } from '../form/Input'; +import { Input } from '../Input'; type ChipBaseProps = { /** Specify which color palette to use. If left unspecified, the color is inherited from the nearest ancestor with data-color. diff --git a/packages/react/src/components/form/Combobox/Combobox.mdx b/packages/react/src/components/Combobox/Combobox.mdx similarity index 100% rename from packages/react/src/components/form/Combobox/Combobox.mdx rename to packages/react/src/components/Combobox/Combobox.mdx diff --git a/packages/react/src/components/form/Combobox/Combobox.stories.tsx b/packages/react/src/components/Combobox/Combobox.stories.tsx similarity index 98% rename from packages/react/src/components/form/Combobox/Combobox.stories.tsx rename to packages/react/src/components/Combobox/Combobox.stories.tsx index b8ca3f6887..7108d35a02 100644 --- a/packages/react/src/components/form/Combobox/Combobox.stories.tsx +++ b/packages/react/src/components/Combobox/Combobox.stories.tsx @@ -3,16 +3,16 @@ import { expect, userEvent, within } from '@storybook/test'; import { useState } from 'react'; import type { FormEvent } from 'react'; -import { Button } from '../../Button'; -import { Chip } from '../../Chip'; -import { Heading } from '../../Heading'; -import { Modal } from '../../Modal'; -import { Paragraph } from '../../Paragraph'; +import { Button } from '../Button'; +import { Chip } from '../Chip'; +import { Heading } from '../Heading'; +import { Modal } from '../Modal'; +import { Paragraph } from '../Paragraph'; import { Switch } from '../Switch'; import { data } from './data/data'; -import { Divider } from '../../Divider'; +import { Divider } from '../Divider'; import { Combobox } from './index'; export default { diff --git a/packages/react/src/components/form/Combobox/Combobox.test.tsx b/packages/react/src/components/Combobox/Combobox.test.tsx similarity index 100% rename from packages/react/src/components/form/Combobox/Combobox.test.tsx rename to packages/react/src/components/Combobox/Combobox.test.tsx diff --git a/packages/react/src/components/form/Combobox/Combobox.tsx b/packages/react/src/components/Combobox/Combobox.tsx similarity index 97% rename from packages/react/src/components/form/Combobox/Combobox.tsx rename to packages/react/src/components/Combobox/Combobox.tsx index f2ae7dec86..6abd39f901 100644 --- a/packages/react/src/components/form/Combobox/Combobox.tsx +++ b/packages/react/src/components/Combobox/Combobox.tsx @@ -4,11 +4,11 @@ import cl from 'clsx/lite'; import { forwardRef, useEffect, useRef, useState } from 'react'; import type { InputHTMLAttributes, ReactNode } from 'react'; -import type { PortalProps } from '../../../types'; -import { omit, useDebounceCallback } from '../../../utilities'; -import { Spinner } from '../../loaders/Spinner'; -import type { FormFieldProps } from '../useFormField'; -import { useFormField } from '../useFormField'; +import type { PortalProps } from '../../types'; +import { omit, useDebounceCallback } from '../../utilities'; +import type { FormFieldProps } from '../../utilities/hooks/useFormField/useFormField'; +import { useFormField } from '../../utilities/hooks/useFormField/useFormField'; +import { Spinner } from '../Spinner'; import { ComboboxContext } from './ComboboxContext'; import { ComboboxIdProvider } from './ComboboxIdContext'; @@ -53,7 +53,7 @@ export type ComboboxProps = { */ multiple?: boolean; /** - * Name of the value when used in a form + * Name of the value when used in a formPuse */ name?: string; /** diff --git a/packages/react/src/components/form/Combobox/ComboboxContext.tsx b/packages/react/src/components/Combobox/ComboboxContext.tsx similarity index 95% rename from packages/react/src/components/form/Combobox/ComboboxContext.tsx rename to packages/react/src/components/Combobox/ComboboxContext.tsx index 831e048f9e..e00477790d 100644 --- a/packages/react/src/components/form/Combobox/ComboboxContext.tsx +++ b/packages/react/src/components/Combobox/ComboboxContext.tsx @@ -6,7 +6,7 @@ import type { import { createContext } from 'react'; import type { Dispatch, Ref, RefObject, SetStateAction } from 'react'; -import type { useFormField } from '../useFormField'; +import type { useFormField } from '../../utilities/hooks/useFormField/useFormField'; import type { ComboboxProps } from './Combobox'; import type { Option, useCombobox } from './useCombobox'; diff --git a/packages/react/src/components/form/Combobox/ComboboxIdContext.tsx b/packages/react/src/components/Combobox/ComboboxIdContext.tsx similarity index 100% rename from packages/react/src/components/form/Combobox/ComboboxIdContext.tsx rename to packages/react/src/components/Combobox/ComboboxIdContext.tsx diff --git a/packages/react/src/components/form/Combobox/Custom.tsx b/packages/react/src/components/Combobox/Custom.tsx similarity index 96% rename from packages/react/src/components/form/Combobox/Custom.tsx rename to packages/react/src/components/Combobox/Custom.tsx index 73bb89a123..27a2d3aee4 100644 --- a/packages/react/src/components/form/Combobox/Custom.tsx +++ b/packages/react/src/components/Combobox/Custom.tsx @@ -4,8 +4,8 @@ import cl from 'clsx/lite'; import { forwardRef, useContext, useId, useMemo } from 'react'; import type { HTMLAttributes } from 'react'; -import { omit } from '../../../utilities'; -import { Label } from '../../Label'; +import { omit } from '../../utilities'; +import { Label } from '../Label'; import { ComboboxContext } from './ComboboxContext'; import { useComboboxId } from './ComboboxIdContext'; diff --git a/packages/react/src/components/form/Combobox/Empty.tsx b/packages/react/src/components/Combobox/Empty.tsx similarity index 96% rename from packages/react/src/components/form/Combobox/Empty.tsx rename to packages/react/src/components/Combobox/Empty.tsx index fcbcc0deec..d9b5743560 100644 --- a/packages/react/src/components/form/Combobox/Empty.tsx +++ b/packages/react/src/components/Combobox/Empty.tsx @@ -2,7 +2,7 @@ import cl from 'clsx/lite'; import { forwardRef, useContext } from 'react'; import type { HTMLAttributes } from 'react'; -import { Label } from '../../Label'; +import { Label } from '../Label'; import { ComboboxContext } from './ComboboxContext'; diff --git a/packages/react/src/components/form/Combobox/Option/Description.tsx b/packages/react/src/components/Combobox/Option/Description.tsx similarity index 100% rename from packages/react/src/components/form/Combobox/Option/Description.tsx rename to packages/react/src/components/Combobox/Option/Description.tsx diff --git a/packages/react/src/components/form/Combobox/Option/Option.tsx b/packages/react/src/components/Combobox/Option/Option.tsx similarity index 97% rename from packages/react/src/components/form/Combobox/Option/Option.tsx rename to packages/react/src/components/Combobox/Option/Option.tsx index 494facf347..f14bebfdb7 100644 --- a/packages/react/src/components/form/Combobox/Option/Option.tsx +++ b/packages/react/src/components/Combobox/Option/Option.tsx @@ -2,8 +2,8 @@ import cl from 'clsx/lite'; import { forwardRef, isValidElement, memo, useContext, useId } from 'react'; import type { ButtonHTMLAttributes, ReactElement, ReactNode } from 'react'; -import { omit } from '../../../../utilities/omit/omit'; -import { Label } from '../../../Label'; +import { omit } from '../../../utilities/omit/omit'; +import { Label } from '../../Label'; import { ComboboxContext } from '../ComboboxContext'; import ComboboxOptionDescription from './Description'; diff --git a/packages/react/src/components/form/Combobox/Option/SelectedIcon.tsx b/packages/react/src/components/Combobox/Option/SelectedIcon.tsx similarity index 100% rename from packages/react/src/components/form/Combobox/Option/SelectedIcon.tsx rename to packages/react/src/components/Combobox/Option/SelectedIcon.tsx diff --git a/packages/react/src/components/form/Combobox/Option/useComboboxOption.tsx b/packages/react/src/components/Combobox/Option/useComboboxOption.tsx similarity index 94% rename from packages/react/src/components/form/Combobox/Option/useComboboxOption.tsx rename to packages/react/src/components/Combobox/Option/useComboboxOption.tsx index 010670a1df..86d433dadb 100644 --- a/packages/react/src/components/form/Combobox/Option/useComboboxOption.tsx +++ b/packages/react/src/components/Combobox/Option/useComboboxOption.tsx @@ -2,7 +2,7 @@ import { useMergeRefs } from '@floating-ui/react'; import { useContext, useEffect, useId, useMemo } from 'react'; import type { Ref } from 'react'; -import { useDebounceCallback } from '../../../../utilities/hooks/useDebounceCallback/useDebounceCallback'; +import { useDebounceCallback } from '../../../utilities/hooks/useDebounceCallback/useDebounceCallback'; import { ComboboxContext } from '../ComboboxContext'; import { useComboboxId, useComboboxIdDispatch } from '../ComboboxIdContext'; import { prefix } from '../utilities'; diff --git a/packages/react/src/components/form/Combobox/data/data.ts b/packages/react/src/components/Combobox/data/data.ts similarity index 100% rename from packages/react/src/components/form/Combobox/data/data.ts rename to packages/react/src/components/Combobox/data/data.ts diff --git a/packages/react/src/components/form/Combobox/index.ts b/packages/react/src/components/Combobox/index.ts similarity index 100% rename from packages/react/src/components/form/Combobox/index.ts rename to packages/react/src/components/Combobox/index.ts diff --git a/packages/react/src/components/form/Combobox/internal/ComboboxChips.tsx b/packages/react/src/components/Combobox/internal/ComboboxChips.tsx similarity index 97% rename from packages/react/src/components/form/Combobox/internal/ComboboxChips.tsx rename to packages/react/src/components/Combobox/internal/ComboboxChips.tsx index 0e886accb7..0b96027bef 100644 --- a/packages/react/src/components/form/Combobox/internal/ComboboxChips.tsx +++ b/packages/react/src/components/Combobox/internal/ComboboxChips.tsx @@ -1,6 +1,6 @@ import { useContext } from 'react'; -import { ChipRemovable } from '../../../Chip'; +import { ChipRemovable } from '../../Chip'; import { ComboboxContext } from '../ComboboxContext'; const ComboboxChips = () => { diff --git a/packages/react/src/components/form/Combobox/internal/ComboboxClearButton.tsx b/packages/react/src/components/Combobox/internal/ComboboxClearButton.tsx similarity index 100% rename from packages/react/src/components/form/Combobox/internal/ComboboxClearButton.tsx rename to packages/react/src/components/Combobox/internal/ComboboxClearButton.tsx diff --git a/packages/react/src/components/form/Combobox/internal/ComboboxError.tsx b/packages/react/src/components/Combobox/internal/ComboboxError.tsx similarity index 80% rename from packages/react/src/components/form/Combobox/internal/ComboboxError.tsx rename to packages/react/src/components/Combobox/internal/ComboboxError.tsx index 3a182c5ae3..515af2b8de 100644 --- a/packages/react/src/components/form/Combobox/internal/ComboboxError.tsx +++ b/packages/react/src/components/Combobox/internal/ComboboxError.tsx @@ -1,5 +1,5 @@ -import { ValidationMessage } from '../../../ValidationMessage'; -import type { useFormField } from '../../useFormField'; +import type { useFormField } from '../../../utilities/hooks/useFormField/useFormField'; +import { ValidationMessage } from '../../ValidationMessage'; import type { ComboboxProps } from '../Combobox'; type ComboboxErrorProps = { diff --git a/packages/react/src/components/form/Combobox/internal/ComboboxInput.tsx b/packages/react/src/components/Combobox/internal/ComboboxInput.tsx similarity index 98% rename from packages/react/src/components/form/Combobox/internal/ComboboxInput.tsx rename to packages/react/src/components/Combobox/internal/ComboboxInput.tsx index 9c29fcbd5b..9174c7a332 100644 --- a/packages/react/src/components/form/Combobox/internal/ComboboxInput.tsx +++ b/packages/react/src/components/Combobox/internal/ComboboxInput.tsx @@ -9,8 +9,8 @@ import type { } from 'react'; import { useContext, useRef } from 'react'; -import { omit } from '../../../../utilities'; -import { Paragraph } from '../../../Paragraph'; +import { omit } from '../../../utilities'; +import { Paragraph } from '../../Paragraph'; import type { ComboboxProps } from '../Combobox'; import { ComboboxContext } from '../ComboboxContext'; import { useComboboxIdDispatch } from '../ComboboxIdContext'; diff --git a/packages/react/src/components/form/Combobox/internal/ComboboxLabel.tsx b/packages/react/src/components/Combobox/internal/ComboboxLabel.tsx similarity index 89% rename from packages/react/src/components/form/Combobox/internal/ComboboxLabel.tsx rename to packages/react/src/components/Combobox/internal/ComboboxLabel.tsx index b19ab3c814..8275c228bb 100644 --- a/packages/react/src/components/form/Combobox/internal/ComboboxLabel.tsx +++ b/packages/react/src/components/Combobox/internal/ComboboxLabel.tsx @@ -1,9 +1,9 @@ import { PadlockLockedFillIcon } from '@navikt/aksel-icons'; import cl from 'clsx/lite'; -import { Label } from '../../../Label'; -import { Paragraph } from '../../../Paragraph'; -import type { useFormField } from '../../useFormField'; +import type { useFormField } from '../../../utilities/hooks/useFormField/useFormField'; +import { Label } from '../../Label'; +import { Paragraph } from '../../Paragraph'; import type { ComboboxProps } from '../Combobox'; type ComboboxLabelProps = { diff --git a/packages/react/src/components/form/Combobox/internal/ComboboxNative.tsx b/packages/react/src/components/Combobox/internal/ComboboxNative.tsx similarity index 100% rename from packages/react/src/components/form/Combobox/internal/ComboboxNative.tsx rename to packages/react/src/components/Combobox/internal/ComboboxNative.tsx diff --git a/packages/react/src/components/form/Combobox/useCombobox.test.tsx b/packages/react/src/components/Combobox/useCombobox.test.tsx similarity index 100% rename from packages/react/src/components/form/Combobox/useCombobox.test.tsx rename to packages/react/src/components/Combobox/useCombobox.test.tsx diff --git a/packages/react/src/components/form/Combobox/useCombobox.tsx b/packages/react/src/components/Combobox/useCombobox.tsx similarity index 100% rename from packages/react/src/components/form/Combobox/useCombobox.tsx rename to packages/react/src/components/Combobox/useCombobox.tsx diff --git a/packages/react/src/components/form/Combobox/useComboboxKeyboard.tsx b/packages/react/src/components/Combobox/useComboboxKeyboard.tsx similarity index 98% rename from packages/react/src/components/form/Combobox/useComboboxKeyboard.tsx rename to packages/react/src/components/Combobox/useComboboxKeyboard.tsx index 262ca3a53d..9817c9a567 100644 --- a/packages/react/src/components/form/Combobox/useComboboxKeyboard.tsx +++ b/packages/react/src/components/Combobox/useComboboxKeyboard.tsx @@ -1,4 +1,4 @@ -import { useDebounceCallback } from '../../../utilities'; +import { useDebounceCallback } from '../../utilities'; import type { KeyboardEvent } from 'react'; import type { ComboboxContextType } from './ComboboxContext'; diff --git a/packages/react/src/components/form/Combobox/useFloatingCombobox.tsx b/packages/react/src/components/Combobox/useFloatingCombobox.tsx similarity index 100% rename from packages/react/src/components/form/Combobox/useFloatingCombobox.tsx rename to packages/react/src/components/Combobox/useFloatingCombobox.tsx diff --git a/packages/react/src/components/form/Combobox/utilities.ts b/packages/react/src/components/Combobox/utilities.ts similarity index 100% rename from packages/react/src/components/form/Combobox/utilities.ts rename to packages/react/src/components/Combobox/utilities.ts diff --git a/packages/react/src/components/ErrorSummary/ErrorSummary.stories.tsx b/packages/react/src/components/ErrorSummary/ErrorSummary.stories.tsx index 7e076bdc8a..9cb3c16035 100644 --- a/packages/react/src/components/ErrorSummary/ErrorSummary.stories.tsx +++ b/packages/react/src/components/ErrorSummary/ErrorSummary.stories.tsx @@ -3,7 +3,7 @@ import { expect, userEvent, within } from '@storybook/test'; import { useState } from 'react'; import { Button } from '../Button'; -import { Textfield } from '../form/Textfield'; +import { Textfield } from '../Textfield'; import { ErrorSummary } from './'; diff --git a/packages/react/src/components/form/Field/Field.mdx b/packages/react/src/components/Field/Field.mdx similarity index 100% rename from packages/react/src/components/form/Field/Field.mdx rename to packages/react/src/components/Field/Field.mdx diff --git a/packages/react/src/components/form/Field/Field.stories.tsx b/packages/react/src/components/Field/Field.stories.tsx similarity index 97% rename from packages/react/src/components/form/Field/Field.stories.tsx rename to packages/react/src/components/Field/Field.stories.tsx index a8008ff817..d5337d3f6c 100644 --- a/packages/react/src/components/form/Field/Field.stories.tsx +++ b/packages/react/src/components/Field/Field.stories.tsx @@ -1,13 +1,13 @@ import type { Meta, StoryFn } from '@storybook/react'; import { useEffect } from 'react'; -import { Label } from '../../Label'; +import { Label } from '../Label'; import { Field } from '.'; -import { ValidationMessage } from '../../ValidationMessage'; import { Input } from '../Input'; import { Select } from '../Select'; import { Textarea } from '../Textarea'; +import { ValidationMessage } from '../ValidationMessage'; type Story = StoryFn; diff --git a/packages/react/src/components/form/Field/Field.tsx b/packages/react/src/components/Field/Field.tsx similarity index 93% rename from packages/react/src/components/form/Field/Field.tsx rename to packages/react/src/components/Field/Field.tsx index e6c181d431..9f6dddd96e 100644 --- a/packages/react/src/components/form/Field/Field.tsx +++ b/packages/react/src/components/Field/Field.tsx @@ -2,7 +2,7 @@ import { useMergeRefs } from '@floating-ui/react'; import cl from 'clsx/lite'; import type { HTMLAttributes } from 'react'; import { forwardRef, useEffect, useRef } from 'react'; -import type { DefaultProps } from '../../../types'; +import type { DefaultProps } from '../../types'; import { fieldObserver } from './fieldObserver'; export type FieldProps = { diff --git a/packages/react/src/components/form/Field/FieldAffix.tsx b/packages/react/src/components/Field/FieldAffix.tsx similarity index 100% rename from packages/react/src/components/form/Field/FieldAffix.tsx rename to packages/react/src/components/Field/FieldAffix.tsx diff --git a/packages/react/src/components/form/Field/FieldCounter.tsx b/packages/react/src/components/Field/FieldCounter.tsx similarity index 98% rename from packages/react/src/components/form/Field/FieldCounter.tsx rename to packages/react/src/components/Field/FieldCounter.tsx index f6e46631d0..c7e355ca3a 100644 --- a/packages/react/src/components/form/Field/FieldCounter.tsx +++ b/packages/react/src/components/Field/FieldCounter.tsx @@ -2,7 +2,7 @@ import { forwardRef, useEffect, useRef, useState } from 'react'; import { ValidationMessage, type ValidationMessageProps, -} from '../../ValidationMessage'; +} from '../ValidationMessage'; export type FieldCounterProps = { /** Label template for when `maxCount` is exceeded diff --git a/packages/react/src/components/form/Field/FieldDescription.tsx b/packages/react/src/components/Field/FieldDescription.tsx similarity index 100% rename from packages/react/src/components/form/Field/FieldDescription.tsx rename to packages/react/src/components/Field/FieldDescription.tsx diff --git a/packages/react/src/components/form/Field/fieldObserver.test.tsx b/packages/react/src/components/Field/fieldObserver.test.tsx similarity index 100% rename from packages/react/src/components/form/Field/fieldObserver.test.tsx rename to packages/react/src/components/Field/fieldObserver.test.tsx diff --git a/packages/react/src/components/form/Field/fieldObserver.ts b/packages/react/src/components/Field/fieldObserver.ts similarity index 100% rename from packages/react/src/components/form/Field/fieldObserver.ts rename to packages/react/src/components/Field/fieldObserver.ts diff --git a/packages/react/src/components/form/Field/index.ts b/packages/react/src/components/Field/index.ts similarity index 100% rename from packages/react/src/components/form/Field/index.ts rename to packages/react/src/components/Field/index.ts diff --git a/packages/react/src/components/form/Fieldset/Fieldset.mdx b/packages/react/src/components/Fieldset/Fieldset.mdx similarity index 100% rename from packages/react/src/components/form/Fieldset/Fieldset.mdx rename to packages/react/src/components/Fieldset/Fieldset.mdx diff --git a/packages/react/src/components/form/Fieldset/Fieldset.stories.tsx b/packages/react/src/components/Fieldset/Fieldset.stories.tsx similarity index 100% rename from packages/react/src/components/form/Fieldset/Fieldset.stories.tsx rename to packages/react/src/components/Fieldset/Fieldset.stories.tsx diff --git a/packages/react/src/components/form/Fieldset/Fieldset.test.tsx b/packages/react/src/components/Fieldset/Fieldset.test.tsx similarity index 100% rename from packages/react/src/components/form/Fieldset/Fieldset.test.tsx rename to packages/react/src/components/Fieldset/Fieldset.test.tsx diff --git a/packages/react/src/components/form/Fieldset/Fieldset.tsx b/packages/react/src/components/Fieldset/Fieldset.tsx similarity index 89% rename from packages/react/src/components/form/Fieldset/Fieldset.tsx rename to packages/react/src/components/Fieldset/Fieldset.tsx index 690205a578..21cf8170a2 100644 --- a/packages/react/src/components/form/Fieldset/Fieldset.tsx +++ b/packages/react/src/components/Fieldset/Fieldset.tsx @@ -2,7 +2,7 @@ import cl from 'clsx/lite'; import type { FieldsetHTMLAttributes } from 'react'; import { forwardRef } from 'react'; -import type { DefaultProps } from '../../../types'; +import type { DefaultProps } from '../../types'; export type FieldsetProps = DefaultProps & FieldsetHTMLAttributes; diff --git a/packages/react/src/components/form/Fieldset/FieldsetContext.ts b/packages/react/src/components/Fieldset/FieldsetContext.ts similarity index 72% rename from packages/react/src/components/form/Fieldset/FieldsetContext.ts rename to packages/react/src/components/Fieldset/FieldsetContext.ts index dfaa8a7300..5d9d92f1ab 100644 --- a/packages/react/src/components/form/Fieldset/FieldsetContext.ts +++ b/packages/react/src/components/Fieldset/FieldsetContext.ts @@ -1,6 +1,6 @@ import { createContext } from 'react'; -import type { FormFieldProps } from '../useFormField'; +import type { FormFieldProps } from '../../utilities/hooks/useFormField/useFormField'; export type FieldsetContextType = Pick< FormFieldProps, diff --git a/packages/react/src/components/form/Fieldset/FieldsetDescription.tsx b/packages/react/src/components/Fieldset/FieldsetDescription.tsx similarity index 78% rename from packages/react/src/components/form/Fieldset/FieldsetDescription.tsx rename to packages/react/src/components/Fieldset/FieldsetDescription.tsx index 774103a6d9..e9dc7d5960 100644 --- a/packages/react/src/components/form/Fieldset/FieldsetDescription.tsx +++ b/packages/react/src/components/Fieldset/FieldsetDescription.tsx @@ -1,6 +1,6 @@ import { forwardRef } from 'react'; -import { Paragraph, type ParagraphProps } from '../../Paragraph/Paragraph'; +import { Paragraph, type ParagraphProps } from '../Paragraph/Paragraph'; export type FieldsetDescriptionProps = ParagraphProps; diff --git a/packages/react/src/components/form/Fieldset/FieldsetLegend.tsx b/packages/react/src/components/Fieldset/FieldsetLegend.tsx similarity index 79% rename from packages/react/src/components/form/Fieldset/FieldsetLegend.tsx rename to packages/react/src/components/Fieldset/FieldsetLegend.tsx index 968d87b500..52dac5da4b 100644 --- a/packages/react/src/components/form/Fieldset/FieldsetLegend.tsx +++ b/packages/react/src/components/Fieldset/FieldsetLegend.tsx @@ -1,7 +1,7 @@ import { type HTMLAttributes, forwardRef } from 'react'; -import type { DefaultProps } from '../../../types'; +import type { DefaultProps } from '../../types'; -import { Label } from '../../Label/Label'; +import { Label } from '../Label/Label'; export type FieldsetLegendProps = HTMLAttributes & DefaultProps; diff --git a/packages/react/src/components/form/Fieldset/index.ts b/packages/react/src/components/Fieldset/index.ts similarity index 100% rename from packages/react/src/components/form/Fieldset/index.ts rename to packages/react/src/components/Fieldset/index.ts diff --git a/packages/react/src/components/form/Input/Input.mdx b/packages/react/src/components/Input/Input.mdx similarity index 97% rename from packages/react/src/components/form/Input/Input.mdx rename to packages/react/src/components/Input/Input.mdx index 1e3828118e..e3ce11c6a9 100644 --- a/packages/react/src/components/form/Input/Input.mdx +++ b/packages/react/src/components/Input/Input.mdx @@ -1,7 +1,7 @@ import { Meta, Canvas, Controls, Primary } from '@storybook/blocks'; import { CssVariables } from '@doc-components'; import css from '@digdir/designsystemet-css/input.css?inline'; -import { Alert } from '../../Alert'; +import { Alert } from '../Alert'; import * as InputStories from './Input.stories'; diff --git a/packages/react/src/components/form/Input/Input.stories.tsx b/packages/react/src/components/Input/Input.stories.tsx similarity index 99% rename from packages/react/src/components/form/Input/Input.stories.tsx rename to packages/react/src/components/Input/Input.stories.tsx index 9714665555..66c3f07f6c 100644 --- a/packages/react/src/components/form/Input/Input.stories.tsx +++ b/packages/react/src/components/Input/Input.stories.tsx @@ -12,7 +12,7 @@ import { } from '../..'; import { Input } from '.'; -import type { Size } from '../../../types'; +import type { Size } from '../../types'; type Story = StoryObj; diff --git a/packages/react/src/components/form/Input/Input.test.tsx b/packages/react/src/components/Input/Input.test.tsx similarity index 100% rename from packages/react/src/components/form/Input/Input.test.tsx rename to packages/react/src/components/Input/Input.test.tsx diff --git a/packages/react/src/components/form/Input/Input.tsx b/packages/react/src/components/Input/Input.tsx similarity index 91% rename from packages/react/src/components/form/Input/Input.tsx rename to packages/react/src/components/Input/Input.tsx index c280c457aa..335ff034b5 100644 --- a/packages/react/src/components/form/Input/Input.tsx +++ b/packages/react/src/components/Input/Input.tsx @@ -1,9 +1,9 @@ import cl from 'clsx/lite'; import type { InputHTMLAttributes } from 'react'; import { forwardRef } from 'react'; -import type { Color } from '../../../colors'; -import type { DefaultProps } from '../../../types'; -import type { MergeRight } from '../../../utilities'; +import type { Color } from '../../colors'; +import type { DefaultProps } from '../../types'; +import type { MergeRight } from '../../utilities'; type InputAttr = InputHTMLAttributes; diff --git a/packages/react/src/components/form/Input/index.ts b/packages/react/src/components/Input/index.ts similarity index 100% rename from packages/react/src/components/form/Input/index.ts rename to packages/react/src/components/Input/index.ts diff --git a/packages/react/src/components/form/Radio/Radio.mdx b/packages/react/src/components/Radio/Radio.mdx similarity index 98% rename from packages/react/src/components/form/Radio/Radio.mdx rename to packages/react/src/components/Radio/Radio.mdx index 96380289ee..c8ef7103a3 100644 --- a/packages/react/src/components/form/Radio/Radio.mdx +++ b/packages/react/src/components/Radio/Radio.mdx @@ -2,7 +2,7 @@ import { Meta, Canvas, Controls, Primary, ArgTypes } from '@storybook/blocks'; import { CssVariables } from '@doc-components'; import css from '@digdir/designsystemet-css/input.css?inline'; import * as RadioStories from './Radio.stories'; -import * as useRadioGroupStories from '../../../utilities/hooks/useRadioGroup/useRadioGroup.stories'; +import * as useRadioGroupStories from '../../utilities/hooks/useRadioGroup/useRadioGroup.stories'; diff --git a/packages/react/src/components/form/Radio/Radio.stories.tsx b/packages/react/src/components/Radio/Radio.stories.tsx similarity index 97% rename from packages/react/src/components/form/Radio/Radio.stories.tsx rename to packages/react/src/components/Radio/Radio.stories.tsx index 1886938fc6..ca2abf6bd0 100644 --- a/packages/react/src/components/form/Radio/Radio.stories.tsx +++ b/packages/react/src/components/Radio/Radio.stories.tsx @@ -5,10 +5,9 @@ import { Fieldset, Paragraph, Radio, - type UseRadioGroupProps, ValidationMessage, - useRadioGroup, } from '../..'; +import { type UseRadioGroupProps, useRadioGroup } from '../../utilities'; export default { title: 'Komponenter/Radio', diff --git a/packages/react/src/components/form/Radio/Radio.test.tsx b/packages/react/src/components/Radio/Radio.test.tsx similarity index 100% rename from packages/react/src/components/form/Radio/Radio.test.tsx rename to packages/react/src/components/Radio/Radio.test.tsx diff --git a/packages/react/src/components/form/Radio/Radio.tsx b/packages/react/src/components/Radio/Radio.tsx similarity index 83% rename from packages/react/src/components/form/Radio/Radio.tsx rename to packages/react/src/components/Radio/Radio.tsx index d5522b645d..cb69ca0db4 100644 --- a/packages/react/src/components/form/Radio/Radio.tsx +++ b/packages/react/src/components/Radio/Radio.tsx @@ -1,13 +1,13 @@ import type { ReactNode } from 'react'; import { forwardRef } from 'react'; -import type { Color } from '../../../colors'; -import type { DefaultProps, LabelRequired } from '../../../types'; -import type { MergeRight } from '../../../utilities'; -import { Label } from '../../Label'; -import { ValidationMessage } from '../../ValidationMessage'; +import type { Color } from '../../colors'; +import type { DefaultProps, LabelRequired } from '../../types'; +import type { MergeRight } from '../../utilities'; import { Field } from '../Field'; import { Input, type InputProps } from '../Input'; +import { Label } from '../Label'; +import { ValidationMessage } from '../ValidationMessage'; export type RadioProps = MergeRight< DefaultProps & Omit, diff --git a/packages/react/src/components/Radio/index.ts b/packages/react/src/components/Radio/index.ts new file mode 100644 index 0000000000..bfbe6d09bf --- /dev/null +++ b/packages/react/src/components/Radio/index.ts @@ -0,0 +1 @@ +export * from './Radio'; diff --git a/packages/react/src/components/form/Search/Search.mdx b/packages/react/src/components/Search/Search.mdx similarity index 100% rename from packages/react/src/components/form/Search/Search.mdx rename to packages/react/src/components/Search/Search.mdx diff --git a/packages/react/src/components/form/Search/Search.stories.tsx b/packages/react/src/components/Search/Search.stories.tsx similarity index 100% rename from packages/react/src/components/form/Search/Search.stories.tsx rename to packages/react/src/components/Search/Search.stories.tsx diff --git a/packages/react/src/components/form/Search/Search.test.tsx b/packages/react/src/components/Search/Search.test.tsx similarity index 100% rename from packages/react/src/components/form/Search/Search.test.tsx rename to packages/react/src/components/Search/Search.test.tsx diff --git a/packages/react/src/components/form/Search/Search.tsx b/packages/react/src/components/Search/Search.tsx similarity index 86% rename from packages/react/src/components/form/Search/Search.tsx rename to packages/react/src/components/Search/Search.tsx index 8d9687f349..b669a222a6 100644 --- a/packages/react/src/components/form/Search/Search.tsx +++ b/packages/react/src/components/Search/Search.tsx @@ -1,7 +1,7 @@ import cl from 'clsx/lite'; import { forwardRef } from 'react'; -import type { DefaultProps } from '../../../types'; +import type { DefaultProps } from '../../types'; export type SearchProps = DefaultProps & React.HTMLAttributes; diff --git a/packages/react/src/components/form/Search/SearchButton.tsx b/packages/react/src/components/Search/SearchButton.tsx similarity index 81% rename from packages/react/src/components/form/Search/SearchButton.tsx rename to packages/react/src/components/Search/SearchButton.tsx index 5efba80b92..ed1390ddc7 100644 --- a/packages/react/src/components/form/Search/SearchButton.tsx +++ b/packages/react/src/components/Search/SearchButton.tsx @@ -1,7 +1,7 @@ import { forwardRef } from 'react'; -import type { MergeRight } from '../../../utilities'; -import { Button, type ButtonProps } from '../../Button'; +import type { MergeRight } from '../../utilities'; +import { Button, type ButtonProps } from '../Button'; export type SearchButtonProps = MergeRight< ButtonProps, diff --git a/packages/react/src/components/form/Search/SearchClear.tsx b/packages/react/src/components/Search/SearchClear.tsx similarity index 95% rename from packages/react/src/components/form/Search/SearchClear.tsx rename to packages/react/src/components/Search/SearchClear.tsx index 3e8facf63d..1383eaac89 100644 --- a/packages/react/src/components/form/Search/SearchClear.tsx +++ b/packages/react/src/components/Search/SearchClear.tsx @@ -1,5 +1,5 @@ import { forwardRef } from 'react'; -import { Button, type ButtonProps } from '../../Button'; +import { Button, type ButtonProps } from '../Button'; import { setReactInputValue } from '../Combobox/utilities'; /* We omit children since we render the icon with css */ diff --git a/packages/react/src/components/form/Search/SearchInput.tsx b/packages/react/src/components/Search/SearchInput.tsx similarity index 91% rename from packages/react/src/components/form/Search/SearchInput.tsx rename to packages/react/src/components/Search/SearchInput.tsx index 5c424bcd53..5062aa1146 100644 --- a/packages/react/src/components/form/Search/SearchInput.tsx +++ b/packages/react/src/components/Search/SearchInput.tsx @@ -1,5 +1,5 @@ import { forwardRef } from 'react'; -import type { DefaultProps } from '../../../types'; +import type { DefaultProps } from '../../types'; import { Input } from '../Input'; export type SearchInputProps = DefaultProps & diff --git a/packages/react/src/components/form/Search/index.ts b/packages/react/src/components/Search/index.ts similarity index 100% rename from packages/react/src/components/form/Search/index.ts rename to packages/react/src/components/Search/index.ts diff --git a/packages/react/src/components/form/Select/Select.mdx b/packages/react/src/components/Select/Select.mdx similarity index 100% rename from packages/react/src/components/form/Select/Select.mdx rename to packages/react/src/components/Select/Select.mdx diff --git a/packages/react/src/components/form/Select/Select.stories.tsx b/packages/react/src/components/Select/Select.stories.tsx similarity index 100% rename from packages/react/src/components/form/Select/Select.stories.tsx rename to packages/react/src/components/Select/Select.stories.tsx diff --git a/packages/react/src/components/form/Select/Select.test.tsx b/packages/react/src/components/Select/Select.test.tsx similarity index 100% rename from packages/react/src/components/form/Select/Select.test.tsx rename to packages/react/src/components/Select/Select.test.tsx diff --git a/packages/react/src/components/form/Select/Select.tsx b/packages/react/src/components/Select/Select.tsx similarity index 91% rename from packages/react/src/components/form/Select/Select.tsx rename to packages/react/src/components/Select/Select.tsx index 702f8b67dd..4d6c156c9a 100644 --- a/packages/react/src/components/form/Select/Select.tsx +++ b/packages/react/src/components/Select/Select.tsx @@ -1,8 +1,8 @@ import cl from 'clsx/lite'; import { forwardRef } from 'react'; import type { SelectHTMLAttributes } from 'react'; -import type { DefaultProps } from '../../../types'; -import type { MergeRight } from '../../../utilities'; +import type { DefaultProps } from '../../types'; +import type { MergeRight } from '../../utilities'; export type SelectProps = MergeRight< Omit & diff --git a/packages/react/src/components/form/Select/SelectOptgroup.tsx b/packages/react/src/components/Select/SelectOptgroup.tsx similarity index 100% rename from packages/react/src/components/form/Select/SelectOptgroup.tsx rename to packages/react/src/components/Select/SelectOptgroup.tsx diff --git a/packages/react/src/components/form/Select/SelectOption.tsx b/packages/react/src/components/Select/SelectOption.tsx similarity index 100% rename from packages/react/src/components/form/Select/SelectOption.tsx rename to packages/react/src/components/Select/SelectOption.tsx diff --git a/packages/react/src/components/form/Select/index.ts b/packages/react/src/components/Select/index.ts similarity index 100% rename from packages/react/src/components/form/Select/index.ts rename to packages/react/src/components/Select/index.ts diff --git a/packages/react/src/components/loaders/Skeleton/Skeleton.mdx b/packages/react/src/components/Skeleton/Skeleton.mdx similarity index 100% rename from packages/react/src/components/loaders/Skeleton/Skeleton.mdx rename to packages/react/src/components/Skeleton/Skeleton.mdx diff --git a/packages/react/src/components/loaders/Skeleton/Skeleton.stories.tsx b/packages/react/src/components/Skeleton/Skeleton.stories.tsx similarity index 100% rename from packages/react/src/components/loaders/Skeleton/Skeleton.stories.tsx rename to packages/react/src/components/Skeleton/Skeleton.stories.tsx diff --git a/packages/react/src/components/loaders/Skeleton/Skeleton.test.tsx b/packages/react/src/components/Skeleton/Skeleton.test.tsx similarity index 100% rename from packages/react/src/components/loaders/Skeleton/Skeleton.test.tsx rename to packages/react/src/components/Skeleton/Skeleton.test.tsx diff --git a/packages/react/src/components/loaders/Skeleton/Skeleton.tsx b/packages/react/src/components/Skeleton/Skeleton.tsx similarity index 84% rename from packages/react/src/components/loaders/Skeleton/Skeleton.tsx rename to packages/react/src/components/Skeleton/Skeleton.tsx index 4ce84d2d4f..4e5e0bc267 100644 --- a/packages/react/src/components/loaders/Skeleton/Skeleton.tsx +++ b/packages/react/src/components/Skeleton/Skeleton.tsx @@ -3,7 +3,7 @@ import { Slot } from '@radix-ui/react-slot'; import cl from 'clsx/lite'; import { type HTMLAttributes, forwardRef } from 'react'; -import { useSynchronizedAnimation } from '../../../utilities'; +import { useSynchronizedAnimation } from '../../utilities'; export type SkeletonProps = { /** @@ -26,6 +26,13 @@ export type SkeletonProps = { | { variant?: 'rectangle' | 'circle'; characters?: never } ); +/** + * Represent a draft of page while the content loads. Mix different skeleton components to create your layout. + * @example + * + * + * + */ export const Skeleton = forwardRef( function Skeleton( { diff --git a/packages/react/src/components/Skeleton/index.ts b/packages/react/src/components/Skeleton/index.ts new file mode 100644 index 0000000000..8391a3cbe1 --- /dev/null +++ b/packages/react/src/components/Skeleton/index.ts @@ -0,0 +1,2 @@ +export type { SkeletonProps } from './Skeleton'; +export { Skeleton } from './Skeleton'; diff --git a/packages/react/src/components/loaders/Spinner/Spinner.mdx b/packages/react/src/components/Spinner/Spinner.mdx similarity index 100% rename from packages/react/src/components/loaders/Spinner/Spinner.mdx rename to packages/react/src/components/Spinner/Spinner.mdx diff --git a/packages/react/src/components/loaders/Spinner/Spinner.stories.tsx b/packages/react/src/components/Spinner/Spinner.stories.tsx similarity index 100% rename from packages/react/src/components/loaders/Spinner/Spinner.stories.tsx rename to packages/react/src/components/Spinner/Spinner.stories.tsx diff --git a/packages/react/src/components/loaders/Spinner/Spinner.test.tsx b/packages/react/src/components/Spinner/Spinner.test.tsx similarity index 100% rename from packages/react/src/components/loaders/Spinner/Spinner.test.tsx rename to packages/react/src/components/Spinner/Spinner.test.tsx diff --git a/packages/react/src/components/loaders/Spinner/Spinner.tsx b/packages/react/src/components/Spinner/Spinner.tsx similarity index 94% rename from packages/react/src/components/loaders/Spinner/Spinner.tsx rename to packages/react/src/components/Spinner/Spinner.tsx index 7f10458745..f59a59a092 100644 --- a/packages/react/src/components/loaders/Spinner/Spinner.tsx +++ b/packages/react/src/components/Spinner/Spinner.tsx @@ -2,8 +2,8 @@ import { useMergeRefs } from '@floating-ui/react'; import cl from 'clsx/lite'; import { type ComponentPropsWithoutRef, forwardRef } from 'react'; -import type { Color } from '../../../colors'; -import { useSynchronizedAnimation } from '../../../utilities'; +import type { Color } from '../../colors'; +import { useSynchronizedAnimation } from '../../utilities'; export type SpinnerProps = { /** Accessibile label */ diff --git a/packages/react/src/components/loaders/Spinner/index.ts b/packages/react/src/components/Spinner/index.ts similarity index 100% rename from packages/react/src/components/loaders/Spinner/index.ts rename to packages/react/src/components/Spinner/index.ts diff --git a/packages/react/src/components/form/Switch/Switch.mdx b/packages/react/src/components/Switch/Switch.mdx similarity index 100% rename from packages/react/src/components/form/Switch/Switch.mdx rename to packages/react/src/components/Switch/Switch.mdx diff --git a/packages/react/src/components/form/Switch/Switch.stories.tsx b/packages/react/src/components/Switch/Switch.stories.tsx similarity index 100% rename from packages/react/src/components/form/Switch/Switch.stories.tsx rename to packages/react/src/components/Switch/Switch.stories.tsx diff --git a/packages/react/src/components/form/Switch/Switch.test.tsx b/packages/react/src/components/Switch/Switch.test.tsx similarity index 100% rename from packages/react/src/components/form/Switch/Switch.test.tsx rename to packages/react/src/components/Switch/Switch.test.tsx diff --git a/packages/react/src/components/form/Switch/Switch.tsx b/packages/react/src/components/Switch/Switch.tsx similarity index 88% rename from packages/react/src/components/form/Switch/Switch.tsx rename to packages/react/src/components/Switch/Switch.tsx index 2abe7e8700..3142c2c1e8 100644 --- a/packages/react/src/components/form/Switch/Switch.tsx +++ b/packages/react/src/components/Switch/Switch.tsx @@ -1,12 +1,12 @@ import type { InputHTMLAttributes, ReactNode } from 'react'; import { forwardRef } from 'react'; -import type { Color } from '../../../colors'; -import type { DefaultProps, LabelRequired } from '../../../types'; -import type { MergeRight } from '../../../utilities'; -import { Label } from '../../Label'; +import type { Color } from '../../colors'; +import type { DefaultProps, LabelRequired } from '../../types'; +import type { MergeRight } from '../../utilities'; import { Field, type FieldProps } from '../Field'; import { Input, type InputProps } from '../Input'; +import { Label } from '../Label'; export type SwitchProps = MergeRight< DefaultProps & Omit, 'size'>, diff --git a/packages/react/src/components/form/Switch/index.ts b/packages/react/src/components/Switch/index.ts similarity index 100% rename from packages/react/src/components/form/Switch/index.ts rename to packages/react/src/components/Switch/index.ts diff --git a/packages/react/src/components/Table/Table.stories.tsx b/packages/react/src/components/Table/Table.stories.tsx index 2c0c87acca..26f609a10f 100644 --- a/packages/react/src/components/Table/Table.stories.tsx +++ b/packages/react/src/components/Table/Table.stories.tsx @@ -3,7 +3,8 @@ import { useState } from 'react'; import type { TableHeaderCellProps } from '../..'; -import { Checkbox, Table, Textfield, useCheckboxGroup } from '../..'; +import { Checkbox, Table, Textfield } from '../..'; +import { useCheckboxGroup } from '../../utilities'; type Story = StoryFn; diff --git a/packages/react/src/components/form/Textarea/Textarea.mdx b/packages/react/src/components/Textarea/Textarea.mdx similarity index 100% rename from packages/react/src/components/form/Textarea/Textarea.mdx rename to packages/react/src/components/Textarea/Textarea.mdx diff --git a/packages/react/src/components/form/Textarea/Textarea.stories.tsx b/packages/react/src/components/Textarea/Textarea.stories.tsx similarity index 100% rename from packages/react/src/components/form/Textarea/Textarea.stories.tsx rename to packages/react/src/components/Textarea/Textarea.stories.tsx diff --git a/packages/react/src/components/form/Textarea/Textarea.test.tsx b/packages/react/src/components/Textarea/Textarea.test.tsx similarity index 100% rename from packages/react/src/components/form/Textarea/Textarea.test.tsx rename to packages/react/src/components/Textarea/Textarea.test.tsx diff --git a/packages/react/src/components/form/Textarea/Textarea.tsx b/packages/react/src/components/Textarea/Textarea.tsx similarity index 91% rename from packages/react/src/components/form/Textarea/Textarea.tsx rename to packages/react/src/components/Textarea/Textarea.tsx index 9c53e37df3..21b46f7863 100644 --- a/packages/react/src/components/form/Textarea/Textarea.tsx +++ b/packages/react/src/components/Textarea/Textarea.tsx @@ -1,7 +1,7 @@ import cl from 'clsx/lite'; import type { TextareaHTMLAttributes } from 'react'; import { forwardRef } from 'react'; -import type { DefaultProps } from '../../../types'; +import type { DefaultProps } from '../../types'; export type TextareaProps = TextareaHTMLAttributes & Omit; diff --git a/packages/react/src/components/form/Textarea/index.ts b/packages/react/src/components/Textarea/index.ts similarity index 100% rename from packages/react/src/components/form/Textarea/index.ts rename to packages/react/src/components/Textarea/index.ts diff --git a/packages/react/src/components/form/Textarea/useTextarea.ts b/packages/react/src/components/Textarea/useTextarea.ts similarity index 87% rename from packages/react/src/components/form/Textarea/useTextarea.ts rename to packages/react/src/components/Textarea/useTextarea.ts index 8dc629c3e9..8be0e2e03f 100644 --- a/packages/react/src/components/form/Textarea/useTextarea.ts +++ b/packages/react/src/components/Textarea/useTextarea.ts @@ -1,9 +1,9 @@ import type { TextareaHTMLAttributes } from 'react'; import { useContext } from 'react'; +import type { FormField } from '../../utilities/hooks/useFormField/useFormField'; +import { useFormField } from '../../utilities/hooks/useFormField/useFormField'; import { FieldsetContext } from '../Fieldset/FieldsetContext'; -import type { FormField } from '../useFormField'; -import { useFormField } from '../useFormField'; import type { TextareaProps } from './Textarea'; diff --git a/packages/react/src/components/form/Textfield/Textfield.mdx b/packages/react/src/components/Textfield/Textfield.mdx similarity index 97% rename from packages/react/src/components/form/Textfield/Textfield.mdx rename to packages/react/src/components/Textfield/Textfield.mdx index cbc7487978..a94730022b 100644 --- a/packages/react/src/components/form/Textfield/Textfield.mdx +++ b/packages/react/src/components/Textfield/Textfield.mdx @@ -1,6 +1,4 @@ import { Meta, Canvas, Controls, Primary } from '@storybook/blocks'; -import { CssVariables } from '@doc-components'; -import css from '@digdir/designsystemet-css/textfield.css?inline'; import * as TextfieldStories from './Textfield.stories'; diff --git a/packages/react/src/components/form/Textfield/Textfield.stories.tsx b/packages/react/src/components/Textfield/Textfield.stories.tsx similarity index 100% rename from packages/react/src/components/form/Textfield/Textfield.stories.tsx rename to packages/react/src/components/Textfield/Textfield.stories.tsx diff --git a/packages/react/src/components/form/Textfield/Textfield.test.tsx b/packages/react/src/components/Textfield/Textfield.test.tsx similarity index 100% rename from packages/react/src/components/form/Textfield/Textfield.test.tsx rename to packages/react/src/components/Textfield/Textfield.test.tsx diff --git a/packages/react/src/components/form/Textfield/Textfield.tsx b/packages/react/src/components/Textfield/Textfield.tsx similarity index 94% rename from packages/react/src/components/form/Textfield/Textfield.tsx rename to packages/react/src/components/Textfield/Textfield.tsx index c50d9521fe..ed5e9d2439 100644 --- a/packages/react/src/components/form/Textfield/Textfield.tsx +++ b/packages/react/src/components/Textfield/Textfield.tsx @@ -1,8 +1,6 @@ import { type ForwardedRef, type ReactNode, forwardRef } from 'react'; -import type { DefaultProps, LabelRequired } from '../../../types'; -import { Label } from '../../Label'; -import { ValidationMessage } from '../../ValidationMessage'; +import type { DefaultProps, LabelRequired } from '../../types'; import { Field, FieldAffix, @@ -11,7 +9,9 @@ import { FieldDescription, } from '../Field'; import { Input, type InputProps } from '../Input'; +import { Label } from '../Label'; import { Textarea, type TextareaProps } from '../Textarea'; +import { ValidationMessage } from '../ValidationMessage'; type InputProps_ = Omit< InputProps, diff --git a/packages/react/src/components/form/Textfield/index.ts b/packages/react/src/components/Textfield/index.ts similarity index 100% rename from packages/react/src/components/form/Textfield/index.ts rename to packages/react/src/components/Textfield/index.ts diff --git a/packages/react/src/components/form/Checkbox/index.ts b/packages/react/src/components/form/Checkbox/index.ts deleted file mode 100644 index 4c37578af3..0000000000 --- a/packages/react/src/components/form/Checkbox/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './Checkbox'; -export * from '../../../utilities/hooks/useCheckboxGroup/useCheckboxGroup'; diff --git a/packages/react/src/components/form/Radio/index.ts b/packages/react/src/components/form/Radio/index.ts deleted file mode 100644 index 34bf6811ac..0000000000 --- a/packages/react/src/components/form/Radio/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './Radio'; -export * from '../../../utilities/hooks/useRadioGroup/useRadioGroup'; diff --git a/packages/react/src/components/index.ts b/packages/react/src/components/index.ts index 1b785d6472..c26cbe4c1e 100644 --- a/packages/react/src/components/index.ts +++ b/packages/react/src/components/index.ts @@ -3,8 +3,8 @@ export * from './Button'; export * from './Badge'; export * from './Breadcrumbs'; export * from './HelpText'; -export * from './loaders/Spinner'; -export * from './loaders/Skeleton'; +export * from './Spinner'; +export * from './Skeleton'; export * from './Link'; export * from './List'; export * from './Label'; @@ -12,29 +12,29 @@ export * from './Heading'; export * from './Paragraph'; export * from './ValidationMessage'; export * from './Details'; -export * from './form/Select'; +export * from './Select'; export * from './Alert'; export * from './Tag'; export * from './Chip'; export * from './Pagination'; export * from './SkipLink'; export * from './Tooltip'; -export * from './form/Field'; -export * from './form/Checkbox'; -export * from './form/Radio'; -export * from './form/Fieldset'; -export * from './form/Switch'; -export * from './form/Textfield'; -export * from './form/Textarea'; -export * from './form/Input'; +export * from './Field'; +export * from './Checkbox'; +export * from './Radio'; +export * from './Fieldset'; +export * from './Switch'; +export * from './Textfield'; +export * from './Textarea'; +export * from './Input'; export * from './Tabs'; export * from './ToggleGroup'; export * from './Popover'; export * from './Divider'; export * from './Modal'; export * from './Dropdown'; -export * from './form/Search'; +export * from './Search'; export * from './Card'; -export * from './form/Combobox'; +export * from './Combobox'; export * from './Table'; export * from './ErrorSummary'; diff --git a/packages/react/src/components/loaders/Skeleton/index.ts b/packages/react/src/components/loaders/Skeleton/index.ts deleted file mode 100644 index b66e8d4677..0000000000 --- a/packages/react/src/components/loaders/Skeleton/index.ts +++ /dev/null @@ -1,11 +0,0 @@ -/** - * Represent a draft of page while the content loads. Mix different skeleton components to create your layout. - * @example - * - * - * - * - * - */ -export type { SkeletonProps } from './Skeleton'; -export { Skeleton } from './Skeleton'; diff --git a/packages/react/src/utilities/hooks/index.ts b/packages/react/src/utilities/hooks/index.ts index 1e50bd9603..4768d312a1 100644 --- a/packages/react/src/utilities/hooks/index.ts +++ b/packages/react/src/utilities/hooks/index.ts @@ -2,4 +2,9 @@ export { useDebounceCallback } from './useDebounceCallback/useDebounceCallback'; export { useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect/useIsomorphicLayoutEffect'; export { useMediaQuery } from './useMediaQuery/useMediaQuery'; export { useSynchronizedAnimation } from './useSynchronizedAnimation/useSynchronizedAnimation'; -export { usePrevious } from './usePrevious'; +export { usePrevious } from './usePrevious/usePrevious'; +export { useRadioGroup } from './useRadioGroup/useRadioGroup'; +export { useCheckboxGroup } from './useCheckboxGroup/useCheckboxGroup'; + +export type { UseRadioGroupProps } from './useRadioGroup/useRadioGroup'; +export type { UseCheckboxGroupProps } from './useCheckboxGroup/useCheckboxGroup'; diff --git a/packages/react/src/components/form/useFormField.test.tsx b/packages/react/src/utilities/hooks/useFormField/useFormField.test.tsx similarity index 95% rename from packages/react/src/components/form/useFormField.test.tsx rename to packages/react/src/utilities/hooks/useFormField/useFormField.test.tsx index fd5c86baf4..912bb7c4ec 100644 --- a/packages/react/src/components/form/useFormField.test.tsx +++ b/packages/react/src/utilities/hooks/useFormField/useFormField.test.tsx @@ -1,8 +1,8 @@ import { renderHook } from '@testing-library/react'; import type { ReactNode } from 'react'; -import type { FieldsetProps } from './Fieldset'; -import { Fieldset } from './Fieldset'; +import type { FieldsetProps } from '../../../components/Fieldset'; +import { Fieldset } from '../../../components/Fieldset'; import type { FormField } from './useFormField'; import { useFormField } from './useFormField'; diff --git a/packages/react/src/components/form/useFormField.ts b/packages/react/src/utilities/hooks/useFormField/useFormField.ts similarity index 94% rename from packages/react/src/components/form/useFormField.ts rename to packages/react/src/utilities/hooks/useFormField/useFormField.ts index b072c6d862..d84175d44c 100644 --- a/packages/react/src/components/form/useFormField.ts +++ b/packages/react/src/utilities/hooks/useFormField/useFormField.ts @@ -2,8 +2,8 @@ import cl from 'clsx/lite'; import { useContext, useId } from 'react'; import type { HTMLAttributes, InputHTMLAttributes, ReactNode } from 'react'; -import type { Size } from '../../types'; -import { FieldsetContext } from './Fieldset/FieldsetContext'; +import { FieldsetContext } from '../../../components/Fieldset/FieldsetContext'; +import type { Size } from '../../../types'; export type FormFieldProps = { /** Error message for form field */ diff --git a/packages/react/src/utilities/hooks/usePrevious.test.ts b/packages/react/src/utilities/hooks/usePrevious/usePrevious.test.ts similarity index 95% rename from packages/react/src/utilities/hooks/usePrevious.test.ts rename to packages/react/src/utilities/hooks/usePrevious/usePrevious.test.ts index fe65b33f95..a56c76f599 100644 --- a/packages/react/src/utilities/hooks/usePrevious.test.ts +++ b/packages/react/src/utilities/hooks/usePrevious/usePrevious.test.ts @@ -1,6 +1,6 @@ import { renderHook } from '@testing-library/react'; -import { usePrevious } from './'; +import { usePrevious } from '..'; const renderUsePrevious = () => renderHook(({ state }) => usePrevious(state), { initialProps: { state: 0 } }); diff --git a/packages/react/src/utilities/hooks/usePrevious.ts b/packages/react/src/utilities/hooks/usePrevious/usePrevious.ts similarity index 100% rename from packages/react/src/utilities/hooks/usePrevious.ts rename to packages/react/src/utilities/hooks/usePrevious/usePrevious.ts diff --git a/packages/react/src/utilities/hooks/useRadioGroup/useRadioGroup.test.tsx b/packages/react/src/utilities/hooks/useRadioGroup/useRadioGroup.test.tsx index a241b9f571..a29ff8f7aa 100644 --- a/packages/react/src/utilities/hooks/useRadioGroup/useRadioGroup.test.tsx +++ b/packages/react/src/utilities/hooks/useRadioGroup/useRadioGroup.test.tsx @@ -2,13 +2,12 @@ import { render, screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import { act } from 'react'; +import { Fieldset, Radio, ValidationMessage } from '../../../components'; import { - Fieldset, - Radio, - ValidationMessage, + type GetRadioProps, + type UseRadioGroupProps, useRadioGroup, -} from '../../../components'; -import type { GetRadioProps, UseRadioGroupProps } from './useRadioGroup'; +} from './useRadioGroup'; const RadioGroup = (args: UseRadioGroupProps) => { const { getRadioProps, validationMessageProps } = useRadioGroup(args); diff --git a/packages/react/src/components/loaders/Loaders.mdx b/packages/react/stories/Loaders.mdx similarity index 91% rename from packages/react/src/components/loaders/Loaders.mdx rename to packages/react/stories/Loaders.mdx index f3352336d9..8a755c0456 100644 --- a/packages/react/src/components/loaders/Loaders.mdx +++ b/packages/react/stories/Loaders.mdx @@ -2,8 +2,8 @@ import { Meta, Primary, Controls, Canvas } from '@storybook/blocks'; import { CssVariables } from '@doc-components'; import cssSpinner from '@digdir/designsystemet-css/spinner.css?inline'; import cssSkeleton from '@digdir/designsystemet-css/skeleton.css?inline'; -import * as SkeletonStories from './Skeleton/Skeleton.stories'; -import * as SpinnerStories from './Spinner/Spinner.stories'; +import * as SkeletonStories from '../src/components/Skeleton/Skeleton.stories'; +import * as SpinnerStories from '../src/components/Spinner/Spinner.stories';