Skip to content

Commit 470d876

Browse files
committed
fixed most circular deps warnings
1 parent 3953ae3 commit 470d876

15 files changed

+70
-65
lines changed

packages/react/src/components/Accordion/AccordionContent.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { HTMLAttributes } from 'react';
33
import { forwardRef, useContext } from 'react';
44

55
import { AnimateHeight } from '../../utilities/AnimateHeight';
6-
import { Paragraph } from '..';
6+
import { Paragraph } from '../Typography';
77

88
import { AccordionItemContext } from './AccordionItem';
99

packages/react/src/components/Accordion/AccordionHeading.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import cl from 'clsx/lite';
33
import type { ReactNode, MouseEventHandler, HTMLAttributes } from 'react';
44
import { forwardRef, useContext } from 'react';
55

6-
import { Paragraph, Heading } from '..';
6+
import { Paragraph, Heading } from '../Typography';
77

88
import { AccordionItemContext } from './AccordionItem';
99

packages/react/src/components/Alert/Alert.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
} from '@navikt/aksel-icons';
99
import cl from 'clsx/lite';
1010

11-
import { Paragraph } from '..';
11+
import { Paragraph } from '../Typography';
1212

1313
const icons: Record<
1414
Severity,

packages/react/src/components/HelpText/HelpText.tsx

+3-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import { useState } from 'react';
33
import cl from 'clsx/lite';
44
import type { Placement } from '@floating-ui/utils';
55

6-
import { Popover, Paragraph } from '../';
6+
import { Popover } from '../Popover';
7+
import { Paragraph } from '../Typography/Paragraph';
78
import type { PopoverRootProps } from '../Popover/PopoverRoot';
89
import type { PortalProps } from '../../types/Portal';
910

@@ -27,7 +28,7 @@ export type HelpTextProps = {
2728
} & PortalProps &
2829
ButtonHTMLAttributes<HTMLButtonElement>;
2930

30-
const HelpText = ({
31+
export const HelpText = ({
3132
title,
3233
placement = 'right',
3334
portal,
@@ -93,5 +94,3 @@ const HelpText = ({
9394
};
9495

9596
HelpText.displayName = 'HelpText';
96-
97-
export { HelpText };

packages/react/src/components/form/Combobox/Combobox.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ import { useDebounceCallback, omit } from '../../../utilities';
1212
import { Spinner } from '../../Spinner';
1313

1414
import type { Option } from './useCombobox';
15-
import useCombobox, { prefix, removePrefix } from './useCombobox';
15+
import { useCombobox } from './useCombobox';
16+
import { prefix, removePrefix } from './utilities';
1617
import ComboboxInput from './internal/ComboboxInput';
1718
import ComboboxLabel from './internal/ComboboxLabel';
1819
import ComboboxError from './internal/ComboboxError';

packages/react/src/components/form/Combobox/ComboboxContext.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import type { useFormField } from '../useFormField';
99

1010
import type { ComboboxProps } from './Combobox';
1111
import type { Option } from './useCombobox';
12-
import type useCombobox from './useCombobox';
12+
import type { useCombobox } from './useCombobox';
1313

1414
export type ComboboxContextType = {
1515
multiple: NonNullable<ComboboxProps['multiple']>;

packages/react/src/components/form/Combobox/Option/Option.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { ComboboxContext } from '../ComboboxContext';
88

99
import { SelectedIcon } from './SelectedIcon';
1010
import ComboboxOptionDescription from './Description';
11-
import useComboboxOption from './useComboboxOption';
11+
import { useComboboxOption } from './useComboboxOption';
1212

1313
export type ComboboxOptionProps = {
1414
/**

packages/react/src/components/form/Combobox/Option/useComboboxOption.tsx

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11
import { useContext, useEffect, useId, useMemo } from 'react';
2+
import type { Ref } from 'react';
23
import { useMergeRefs } from '@floating-ui/react';
34

45
import { ComboboxContext } from '../ComboboxContext';
56
import { useDebounceCallback } from '../../../../utilities';
67
import { useComboboxId, useComboboxIdDispatch } from '../ComboboxIdContext';
7-
import { prefix } from '../useCombobox';
8+
import { prefix } from '../utilities';
89

910
type UseComboboxOptionProps = {
1011
id?: string;
11-
ref: React.Ref<HTMLButtonElement>;
12+
ref: Ref<HTMLButtonElement>;
1213
value: string;
1314
};
1415

15-
export default function useComboboxOption({
16+
export const useComboboxOption = ({
1617
id,
1718
ref,
1819
value,
19-
}: UseComboboxOptionProps) {
20+
}: UseComboboxOptionProps) => {
2021
const generatedId = useId();
2122
const newId = id || generatedId;
2223

@@ -71,4 +72,4 @@ export default function useComboboxOption({
7172
active,
7273
onOptionClick: onOptionClickDebounced,
7374
};
74-
}
75+
};

packages/react/src/components/form/Combobox/internal/ComboboxInput.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ import { ChevronUpIcon, ChevronDownIcon } from '@navikt/aksel-icons';
55
import { useMergeRefs } from '@floating-ui/react';
66

77
import { ComboboxContext } from '../ComboboxContext';
8-
import { Box, Paragraph } from '../../../';
8+
import { Paragraph } from '../../../Typography';
9+
import { Box } from '../../../Box';
910
import { omit } from '../../../../utilities';
1011
import { useComboboxIdDispatch } from '../ComboboxIdContext';
1112
import type { ComboboxProps } from '../Combobox';
12-
import { prefix } from '../useCombobox';
13+
import { prefix } from '../utilities';
1314

1415
import ComboboxChips from './ComboboxChips';
1516
import ComboboxClearButton from './ComboboxClearButton';

packages/react/src/components/form/Combobox/internal/ComboboxNative.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { Option } from '../useCombobox';
22
import type { ComboboxProps } from '../Combobox';
3-
import { removePrefix } from '../useCombobox';
3+
import { removePrefix } from '../utilities';
44

55
type ComboboxNativeProps = {
66
selectedOptions: {

packages/react/src/components/form/Combobox/useCombobox.test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { renderHook } from '@testing-library/react';
22

33
import type { UseComboboxProps } from './useCombobox';
4-
import useCombobox from './useCombobox';
4+
import { useCombobox } from './useCombobox';
55

66
import { Combobox } from '.';
77

packages/react/src/components/form/Combobox/useCombobox.tsx

+7-43
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
1-
import {
2-
useMemo,
3-
Children,
4-
useState,
5-
isValidElement,
6-
useCallback,
7-
} from 'react';
1+
import { useMemo, Children, useState, useCallback } from 'react';
82
import type { ReactNode, ReactElement } from 'react';
93

10-
import { ComboboxOption } from './Option/Option';
11-
import { ComboboxCustom } from './Custom';
124
import type { ComboboxOptionProps } from './Option/Option';
135
import type { ComboboxProps } from './Combobox';
146
import type { ComboboxCustomProps } from './Custom';
7+
import {
8+
isComboboxOption,
9+
isInteractiveComboboxCustom,
10+
prefix,
11+
} from './utilities';
1512

1613
export type UseComboboxProps = {
1714
children: ReactNode;
@@ -30,40 +27,7 @@ export type Option = {
3027

3128
const isOption = (option: Option | undefined): option is Option => !!option;
3229

33-
export function isComboboxOption(
34-
child: ReactNode,
35-
): child is ReactElement<ComboboxOptionProps> {
36-
return isValidElement(child) && child.type === ComboboxOption;
37-
}
38-
39-
export function isComboboxCustom(
40-
child: ReactNode,
41-
): child is ReactElement<ComboboxCustomProps> {
42-
return isValidElement(child) && child.type === ComboboxCustom;
43-
}
44-
45-
export function isInteractiveComboboxCustom(
46-
child: ReactNode,
47-
): child is ReactElement<ComboboxCustomProps> {
48-
return isComboboxCustom(child) && child.props.interactive === true;
49-
}
50-
51-
const INTERNAL_OPTION_PREFIX = 'internal-option-';
52-
53-
/**
54-
* We use this function to prefix the value of the options so we can make sure numbers as strings are not parsed as numbers in objects
55-
* @param value
56-
* @returns
57-
*/
58-
export const prefix = (value?: string): string => {
59-
return INTERNAL_OPTION_PREFIX + value;
60-
};
61-
62-
export const removePrefix = (value: string): string => {
63-
return value.slice(INTERNAL_OPTION_PREFIX.length);
64-
};
65-
66-
export default function useCombobox({
30+
export function useCombobox({
6731
children,
6832
inputValue,
6933
multiple,

packages/react/src/components/form/Combobox/useComboboxKeyboard.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useDebounceCallback } from '../../../utilities';
22

3-
import type useCombobox from './useCombobox';
3+
import type { useCombobox } from './useCombobox';
44
import { useComboboxId } from './ComboboxIdContext';
55
import type { ComboboxContextType } from './ComboboxContext';
66

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import { isValidElement } from 'react';
2+
import type { ReactNode, ReactElement } from 'react';
3+
4+
import { ComboboxOption } from './Option/Option';
5+
import { ComboboxCustom } from './Custom';
6+
import type { ComboboxOptionProps } from './Option/Option';
7+
import type { ComboboxCustomProps } from './Custom';
8+
9+
export function isComboboxOption(
10+
child: ReactNode,
11+
): child is ReactElement<ComboboxOptionProps> {
12+
return isValidElement(child) && child.type === ComboboxOption;
13+
}
14+
15+
export function isComboboxCustom(
16+
child: ReactNode,
17+
): child is ReactElement<ComboboxCustomProps> {
18+
return isValidElement(child) && child.type === ComboboxCustom;
19+
}
20+
21+
export function isInteractiveComboboxCustom(
22+
child: ReactNode,
23+
): child is ReactElement<ComboboxCustomProps> {
24+
return isComboboxCustom(child) && child.props.interactive === true;
25+
}
26+
27+
const INTERNAL_OPTION_PREFIX = 'internal-option-';
28+
29+
/**
30+
* We use this function to prefix the value of the options so we can make sure numbers as strings are not parsed as numbers in objects
31+
* @param value
32+
* @returns
33+
*/
34+
export const prefix = (value?: string): string => {
35+
return INTERNAL_OPTION_PREFIX + value;
36+
};
37+
38+
export const removePrefix = (value: string): string => {
39+
return value.slice(INTERNAL_OPTION_PREFIX.length);
40+
};

packages/react/src/utilities/RovingFocus/RovingFocusItem.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ import { useMergeRefs } from '@floating-ui/react';
77
import { Slot } from '@radix-ui/react-slot';
88

99
import type { RovingFocusElement } from './RovingFocusRoot';
10-
11-
import { useRovingFocus } from '.';
10+
import { useRovingFocus } from './useRovingFocus';
1211

1312
type RovingFocusItemProps = {
1413
/** The value of the `RovingFocusItem` used to determine which item should have focus. */

0 commit comments

Comments
 (0)