Skip to content

Commit

Permalink
chore: flatten components folder (#2874)
Browse files Browse the repository at this point in the history
Flattens `form` and `loaders` folders

---------

Co-authored-by: Michael Marszalek <[email protected]>
  • Loading branch information
Barsnes and mimarz authored Dec 10, 2024
1 parent 17e9a01 commit 0f93b66
Show file tree
Hide file tree
Showing 114 changed files with 130 additions and 126 deletions.
9 changes: 8 additions & 1 deletion apps/storybook/.storybook/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,14 @@ const getPath = (href: string | undefined): string => {

const components = {
p: (props: Props) => (
<Paragraph {...props} className='sb-unstyled' data-color-scheme='light' />
<Paragraph
{...props}
className='sb-unstyled'
data-color-scheme='light'
style={{
backgroundColor: 'transparent',
}}
/>
),
ol: (props: Props) => (
<List.Ordered
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/components/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { ButtonHTMLAttributes } from 'react';
import type { Color } from '../../colors';
import type { DefaultProps } from '../../types';
import type { MergeRight } from '../../utilities';
import { Spinner } from '../loaders/Spinner';
import { Spinner } from '../Spinner';

export type ButtonProps = MergeRight<
DefaultProps & ButtonHTMLAttributes<HTMLButtonElement>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

<Meta of={CheckboxStories} />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ import {
Fieldset,
Paragraph,
Table,
type UseCheckboxGroupProps,
ValidationMessage,
useCheckboxGroup,
} from '../..';
import { type UseCheckboxGroupProps, useCheckboxGroup } from '../../utilities';

type Story = StoryObj<typeof Checkbox>;

Expand Down
Original file line number Diff line number Diff line change
@@ -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<InputProps, 'type' | 'role' | 'size'>,
Expand Down
1 change: 1 addition & 0 deletions packages/react/src/components/Checkbox/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './Checkbox';
2 changes: 1 addition & 1 deletion packages/react/src/components/Chip/Chips.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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;
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useContext } from 'react';

import { ChipRemovable } from '../../../Chip';
import { ChipRemovable } from '../../Chip';
import { ComboboxContext } from '../ComboboxContext';

const ComboboxChips = () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -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 = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
Original file line number Diff line number Diff line change
@@ -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 = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useDebounceCallback } from '../../../utilities';
import { useDebounceCallback } from '../../utilities';

import type { KeyboardEvent } from 'react';
import type { ComboboxContextType } from './ComboboxContext';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 './';

Expand Down
Original file line number Diff line number Diff line change
@@ -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<typeof Field>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<HTMLFieldSetElement>;
Expand Down
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
Original file line number Diff line number Diff line change
@@ -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<HTMLLegendElement> &
DefaultProps;
Expand Down
Original file line number Diff line number Diff line change
@@ -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';

<Meta of={InputStories} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
} from '../..';

import { Input } from '.';
import type { Size } from '../../../types';
import type { Size } from '../../types';

type Story = StoryObj<typeof Input>;

Expand Down
Original file line number Diff line number Diff line change
@@ -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<HTMLInputElement>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

<Meta of={RadioStories} />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ import {
Fieldset,
Paragraph,
Radio,
type UseRadioGroupProps,
ValidationMessage,
useRadioGroup,
} from '../..';
import { type UseRadioGroupProps, useRadioGroup } from '../../utilities';

export default {
title: 'Komponenter/Radio',
Expand Down
Original file line number Diff line number Diff line change
@@ -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<InputProps, 'type' | 'role' | 'size'>,
Expand Down
1 change: 1 addition & 0 deletions packages/react/src/components/Radio/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './Radio';
Original file line number Diff line number Diff line change
@@ -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<HTMLDivElement>;

Expand Down
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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 */
Expand Down
Loading

0 comments on commit 0f93b66

Please sign in to comment.