Skip to content

Commit

Permalink
fix: export utilities (#2961)
Browse files Browse the repository at this point in the history
Moves `useFormField` to `/Combobox` to keep up to what we do with utils
only used by it.

Removes unused `useTextarea`
  • Loading branch information
Barsnes authored Jan 8, 2025
1 parent f242e53 commit 2e955f4
Show file tree
Hide file tree
Showing 11 changed files with 15 additions and 70 deletions.
5 changes: 5 additions & 0 deletions .changeset/old-jeans-ring.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@digdir/designsystemet-react": patch
---

Export all utilities
4 changes: 2 additions & 2 deletions packages/react/src/components/Combobox/Combobox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import cl from 'clsx/lite';
import { forwardRef, useEffect, useRef, useState } from 'react';
import type { InputHTMLAttributes, ReactNode } from 'react';
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 type { FormFieldProps } from './useFormField/useFormField';
import { useFormField } from './useFormField/useFormField';

import { ComboboxContext } from './ComboboxContext';
import { ComboboxIdProvider } from './ComboboxIdContext';
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/components/Combobox/ComboboxContext.tsx
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 '../../utilities/hooks/useFormField/useFormField';
import type { useFormField } from './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
@@ -1,6 +1,6 @@
import type { useFormField } from '../../../utilities/hooks/useFormField/useFormField';
import { ValidationMessage } from '../../ValidationMessage';
import type { ComboboxProps } from '../Combobox';
import type { useFormField } from '../useFormField/useFormField';

type ComboboxErrorProps = {
size: ComboboxProps['size'];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { PadlockLockedFillIcon } from '@navikt/aksel-icons';
import cl from 'clsx/lite';

import type { useFormField } from '../../../utilities/hooks/useFormField/useFormField';
import { Label } from '../../Label';
import { Paragraph } from '../../Paragraph';
import type { ComboboxProps } from '../Combobox';
import type { useFormField } from '../useFormField/useFormField';

type ComboboxLabelProps = {
label?: ComboboxProps['label'];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createContext } from 'react';

import type { FormFieldProps } from '../../utilities/hooks/useFormField/useFormField';
import type { FormFieldProps } from './useFormField';

export type FieldsetContextType = Pick<
FormFieldProps,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import cl from 'clsx/lite';
import { useContext, useId } from 'react';
import type { HTMLAttributes, InputHTMLAttributes, ReactNode } from 'react';

import { FieldsetContext } from '../../../components/Fieldset/FieldsetContext';
import type { Size } from '../../../types';
import { FieldsetContext } from './FieldsetContext';

export type FormFieldProps = {
/** Error message for form field */
Expand Down
51 changes: 0 additions & 51 deletions packages/react/src/components/Textarea/useTextarea.ts

This file was deleted.

11 changes: 1 addition & 10 deletions packages/react/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
export * from './components';
export {
useSynchronizedAnimation,
useIsomorphicLayoutEffect,
RovingFocusRoot,
useRovingFocus,
RovingFocusItem,
getNextFocusableValue,
getPrevFocusableValue,
omit,
} from './utilities';
export * from './utilities';
export type { Size } from './types';
4 changes: 2 additions & 2 deletions packages/react/src/utilities/hooks/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
export { useCheckboxGroup } from './useCheckboxGroup/useCheckboxGroup';
export { useDebounceCallback } from './useDebounceCallback/useDebounceCallback';
export { useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect/useIsomorphicLayoutEffect';
export { useMediaQuery } from './useMediaQuery/useMediaQuery';
export { useSynchronizedAnimation } from './useSynchronizedAnimation/useSynchronizedAnimation';
export { usePrevious } from './usePrevious/usePrevious';
export { useRadioGroup } from './useRadioGroup/useRadioGroup';
export { useCheckboxGroup } from './useCheckboxGroup/useCheckboxGroup';
export { useSynchronizedAnimation } from './useSynchronizedAnimation/useSynchronizedAnimation';

export type { UseRadioGroupProps } from './useRadioGroup/useRadioGroup';
export type { UseCheckboxGroupProps } from './useCheckboxGroup/useCheckboxGroup';

0 comments on commit 2e955f4

Please sign in to comment.