Skip to content

Commit

Permalink
chore: resolve circular dependencies (#2478)
Browse files Browse the repository at this point in the history
  • Loading branch information
Barsnes authored Sep 20, 2024
1 parent 44582c8 commit f89091d
Show file tree
Hide file tree
Showing 12 changed files with 21 additions and 28 deletions.
3 changes: 2 additions & 1 deletion packages/react/src/components/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { Slot, Slottable } from '@radix-ui/react-slot';
import cl from 'clsx/lite';
import { forwardRef } from 'react';
import type { ButtonHTMLAttributes } from 'react';
import { Paragraph, Spinner } from '../';
import { Paragraph } from '../Typography';
import { Spinner } from '../loaders/Spinner';

export type ButtonProps = {
/**
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/components/Dropdown/DropdownItem.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { forwardRef, useContext } from 'react';

import type { ButtonProps } from '../Button';
import { Button } from '../Button';
import { Button } from '../Button/Button';

import { DropdownCtx } from './Dropdown';

Expand Down
3 changes: 1 addition & 2 deletions packages/react/src/components/Modal/ModalHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { XMarkIcon } from '@navikt/aksel-icons';
import { Slot } from '@radix-ui/react-slot';
import cl from 'clsx/lite';
import type { HTMLAttributes } from 'react';
import { forwardRef, useContext } from 'react';

import { Button } from '../Button';
import { Button } from '../Button/Button';
import { Heading, Paragraph } from '../Typography';

import { ModalContext } from './ModalRoot';
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/components/Modal/ModalTrigger.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Slot } from '@radix-ui/react-slot';
import { forwardRef, useContext } from 'react';
import type { ComponentPropsWithRef } from 'react';

import { Button } from '../Button';
import { Button } from '../Button/Button';

import { ModalContext } from './ModalRoot';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { forwardRef, useContext } from 'react';

import type { ButtonProps } from '../Button';
import { Button } from '../Button';
import { Button } from '../Button/Button';

import { PaginationContext } from './PaginationRoot';

Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/components/Popover/PopoverTrigger.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Slot } from '@radix-ui/react-slot';
import { forwardRef, useContext } from 'react';
import type { ComponentPropsWithRef } from 'react';
import { Button } from '../Button';
import { Button } from '../Button/Button';
import { Context } from './PopoverContext';

export type PopoverTriggerProps = ComponentPropsWithRef<typeof Button>;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import cl from 'clsx/lite';
import { forwardRef } from 'react';

import { RovingFocusItem } from '../../utilities/RovingFocus/RovingFocusItem';
import { Button, type ButtonProps } from '../Button';
import { Button, type ButtonProps } from '../Button/Button';

import { useToggleGroupItem } from './useToggleGroupitem';

Expand Down
12 changes: 9 additions & 3 deletions packages/react/src/components/form/Combobox/Option/Option.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import cl from 'clsx/lite';
import { forwardRef, memo, useContext, useId } from 'react';
import type { ButtonHTMLAttributes } from 'react';
import { forwardRef, isValidElement, memo, useContext, useId } from 'react';
import type { ButtonHTMLAttributes, ReactElement, ReactNode } from 'react';

import { omit } from '../../../../utilities';
import { omit } from '../../../../utilities/omit/omit';
import { Label } from '../../../Typography';
import { ComboboxContext } from '../ComboboxContext';

Expand Down Expand Up @@ -95,3 +95,9 @@ const ComboboxOption = memo(
ComboboxOption.displayName = 'ComboboxOption';

export { ComboboxOption };

export function isComboboxOption(
child: ReactNode,
): child is ReactElement<ComboboxOptionProps> {
return isValidElement(child) && child.type === ComboboxOption;
}
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';
import { useDebounceCallback } from '../../../../utilities/hooks/useDebounceCallback/useDebounceCallback';
import { ComboboxContext } from '../ComboboxContext';
import { useComboboxId, useComboboxIdDispatch } from '../ComboboxIdContext';
import { prefix } from '../utilities';
Expand Down
8 changes: 2 additions & 6 deletions packages/react/src/components/form/Combobox/useCombobox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,8 @@ import type { ReactElement, ReactNode } from 'react';

import type { ComboboxProps } from './Combobox';
import type { ComboboxCustomProps } from './Custom';
import type { ComboboxOptionProps } from './Option/Option';
import {
isComboboxOption,
isInteractiveComboboxCustom,
prefix,
} from './utilities';
import { type ComboboxOptionProps, isComboboxOption } from './Option/Option';
import { isInteractiveComboboxCustom, prefix } from './utilities';

export type UseComboboxProps = {
children: ReactNode;
Expand Down
8 changes: 0 additions & 8 deletions packages/react/src/components/form/Combobox/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,6 @@ import type { ReactElement, ReactNode } from 'react';

import { ComboboxCustom } from './Custom';
import type { ComboboxCustomProps } from './Custom';
import { ComboboxOption } from './Option/Option';
import type { ComboboxOptionProps } from './Option/Option';

export function isComboboxOption(
child: ReactNode,
): child is ReactElement<ComboboxOptionProps> {
return isValidElement(child) && child.type === ComboboxOption;
}

export function isComboboxCustom(
child: ReactNode,
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/components/form/Search/Search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { ChangeEvent, InputHTMLAttributes, ReactNode } from 'react';
import { forwardRef, useCallback, useRef, useState } from 'react';

import { omit } from '../../../utilities';
import { Button } from '../../Button';
import { Button } from '../../Button/Button';
import { Label, Paragraph } from '../../Typography';
import type { FormFieldProps } from '../useFormField';

Expand Down

0 comments on commit f89091d

Please sign in to comment.