Skip to content

Commit 27569e3

Browse files
authored
ci: address circular dependency warnings (#20395)
* ci: address circular dependency warnings * refactor: update NumberInput subcomponents
1 parent d31346c commit 27569e3

File tree

8 files changed

+16
-33
lines changed

8 files changed

+16
-33
lines changed

packages/react/src/components/ListBox/ListBox.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import {
2020
ListBoxTypePropType,
2121
type ListBoxSize,
2222
type ListBoxType,
23-
} from '.';
23+
} from './ListBoxPropTypes';
2424
import { usePrefix } from '../../internal/usePrefix';
2525
import { FormContext } from '../FluidForm';
2626

packages/react/src/components/NumberInput/NumberInput.tsx

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import React, {
1616
useMemo,
1717
useRef,
1818
useState,
19-
type FC,
2019
type MouseEvent,
2120
type ReactNode,
2221
} from 'react';
@@ -1016,13 +1015,14 @@ NumberInput.propTypes = {
10161015
warnText: PropTypes.node,
10171016
};
10181017

1019-
export interface Label {
1018+
interface LabelProps {
10201019
disabled?: boolean;
10211020
hideLabel?: boolean;
10221021
id?: string;
10231022
label?: ReactNode;
10241023
}
1025-
const Label: FC<Label> = ({ disabled, id, hideLabel, label }) => {
1024+
1025+
const Label = ({ disabled, id, hideLabel, label }: LabelProps) => {
10261026
const prefix = usePrefix();
10271027
const className = cx({
10281028
[`${prefix}--label`]: true,
@@ -1040,19 +1040,13 @@ const Label: FC<Label> = ({ disabled, id, hideLabel, label }) => {
10401040
return null;
10411041
};
10421042

1043-
Label.propTypes = {
1044-
disabled: PropTypes.bool,
1045-
hideLabel: PropTypes.bool,
1046-
id: PropTypes.string,
1047-
label: PropTypes.node,
1048-
};
1049-
1050-
export interface HelperTextProps {
1043+
interface HelperTextProps {
10511044
id?: string;
10521045
description?: ReactNode;
10531046
disabled?: boolean;
10541047
}
1055-
function HelperText({ disabled, description, id }: HelperTextProps) {
1048+
1049+
const HelperText = ({ disabled, description, id }: HelperTextProps) => {
10561050
const prefix = usePrefix();
10571051
const className = cx(`${prefix}--form__helper-text`, {
10581052
[`${prefix}--form__helper-text--disabled`]: disabled,
@@ -1066,12 +1060,6 @@ function HelperText({ disabled, description, id }: HelperTextProps) {
10661060
);
10671061
}
10681062
return null;
1069-
}
1070-
1071-
HelperText.propTypes = {
1072-
description: PropTypes.node,
1073-
disabled: PropTypes.bool,
1074-
id: PropTypes.string,
10751063
};
10761064

10771065
/**

packages/react/src/components/RadioButtonGroup/RadioButtonGroup.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import React, {
1616
} from 'react';
1717
import classNames from 'classnames';
1818
import type { RadioButtonProps } from '../RadioButton';
19-
import { Legend } from '../Text';
19+
import { Legend } from '../Text/createTextComponent';
2020
import { usePrefix } from '../../internal/usePrefix';
2121
import { WarningFilled, WarningAltFilled } from '@carbon/icons-react';
2222
import { deprecate } from '../../prop-types/deprecate';

packages/react/src/components/Text/Text.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {
1818
PolymorphicComponentPropWithRef,
1919
PolymorphicRef,
2020
} from '../../internal/PolymorphicProps';
21-
import { TextDirectionContext, type TextDir } from '.';
21+
import { TextDirectionContext, type TextDir } from './TextDirectionContext';
2222

2323
export interface TextBaseProps {
2424
dir?: TextDir;

packages/react/src/components/Text/TextDirection.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
type GetTextDirection,
1313
type TextDir,
1414
type TextDirectionContextType,
15-
} from '.';
15+
} from './TextDirectionContext';
1616

1717
export interface TextDirectionProps {
1818
children: ReactNode;

packages/react/src/components/Text/createTextComponent.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,15 @@
66
*/
77

88
import React, { type ElementType } from 'react';
9-
import { Text, TextProps } from '.';
9+
import { Text, TextProps } from './Text';
1010

1111
/**
1212
* Create a text component wrapper for a given text node type. Useful for
1313
* returning a `Text` component for a text node like a `<label>`.
1414
* @param {string} element
1515
* @param {string} displayName
1616
*/
17-
export const createTextComponent = (
18-
element: ElementType,
19-
displayName: string
20-
) => {
17+
const createTextComponent = (element: ElementType, displayName: string) => {
2118
const TextWrapper = (props: TextProps<ElementType>) => {
2219
return <Text as={element} {...props} />;
2320
};
@@ -28,3 +25,5 @@ export const createTextComponent = (
2825

2926
return TextWrapper;
3027
};
28+
29+
export const Legend = createTextComponent('legend', 'Legend');

packages/react/src/components/Text/index.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,6 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8-
import { createTextComponent } from './createTextComponent';
9-
108
export * from './Text';
119
export * from './TextDirection';
1210
export * from './TextDirectionContext';
13-
14-
export const Label = createTextComponent('label', 'Label');
15-
export const Legend = createTextComponent('legend', 'Legend');

packages/react/src/components/UIShell/Switcher.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ import { usePrefix } from '../../internal/usePrefix';
1919
import { useMergedRefs } from '../../internal/useMergedRefs';
2020
import PropTypes from 'prop-types';
2121
import { AriaLabelPropType } from '../../prop-types/AriaPropTypes';
22-
import { SwitcherDivider, SwitcherItem } from '.';
22+
import SwitcherItem from './SwitcherItem';
23+
import SwitcherDivider from './SwitcherDivider';
2324

2425
export interface BaseSwitcherProps {
2526
/**

0 commit comments

Comments
 (0)