Skip to content

Commit c2e0790

Browse files
committed
refactor: update imports to use type-only imports for React in form components
- Replaced standard React imports with type-only imports across multiple form components for improved type safety and clarity. - Ensured consistency in the usage of functional components with TypeScript interfaces.
1 parent 9d8b33c commit c2e0790

12 files changed

Lines changed: 43 additions & 32 deletions

packages/medusa-forms/src/controlled/ControlledCurrencyInput.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type * as React from 'react';
12
import {
23
Controller,
34
type ControllerProps,

packages/medusa-forms/src/controlled/ControlledSelect.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type * as React from 'react';
12
import {
23
Controller,
34
type ControllerProps,

packages/medusa-forms/src/controlled/ControlledTextArea.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type * as React from 'react';
12
import {
23
Controller,
34
type ControllerProps,

packages/medusa-forms/src/ui/ColorInput.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type * as React from 'react';
12
import { Input } from './Input';
23

34
interface ColorInputProps {

packages/medusa-forms/src/ui/CurrencyInput.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
import { CurrencyInput as MedusaCurrencyInput } from '@medusajs/ui';
2-
import { type FC } from 'react';
2+
import type * as React from 'react';
3+
import type { FC } from 'react';
34
import { FieldWrapper } from './FieldWrapper';
45
import type { BasicFieldProps, MedusaCurrencyInputProps } from './types';
56

6-
export type Props = MedusaCurrencyInputProps & BasicFieldProps & {
7-
ref?: React.Ref<HTMLInputElement>;
8-
};
7+
export type Props = MedusaCurrencyInputProps &
8+
BasicFieldProps & {
9+
ref?: React.Ref<HTMLInputElement>;
10+
};
911

1012
const Wrapper = FieldWrapper<Props>;
1113

1214
export const CurrencyInput: FC<Props> = ({ ref, ...props }) => (
1315
<Wrapper {...props}>{(inputProps) => <MedusaCurrencyInput {...inputProps} ref={ref} />}</Wrapper>
1416
);
15-

packages/medusa-forms/src/ui/DatePicker.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
import { DatePicker } from '@medusajs/ui';
2-
import { type FC } from 'react';
2+
import type * as React from 'react';
3+
import type { FC } from 'react';
34
import { FieldWrapper } from './FieldWrapper';
45
import type { BasicFieldProps, DatePickerProps } from './types';
56

6-
export type Props = DatePickerProps & BasicFieldProps & {
7-
ref?: React.Ref<HTMLInputElement>;
8-
};
7+
export type Props = DatePickerProps &
8+
BasicFieldProps & {
9+
ref?: React.Ref<HTMLInputElement>;
10+
};
911

1012
const Wrapper = FieldWrapper<Props>;
1113

1214
export const DatePickerInput: FC<Props> = ({ ref, ...props }) => {
1315
return <Wrapper {...props}>{(inputProps) => <DatePicker {...{ ...inputProps, ref }} />}</Wrapper>;
1416
};
15-

packages/medusa-forms/src/ui/FieldCheckbox.tsx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Checkbox as MedusaCheckbox } from '@medusajs/ui';
22
import clsx from 'clsx';
3+
import type * as React from 'react';
34
import { FieldWrapper } from './FieldWrapper';
45
import { Label } from './Label';
56
import type { BasicFieldProps } from './types';
@@ -11,16 +12,16 @@ export type FieldCheckboxProps = BasicFieldProps & {
1112
ref?: React.Ref<HTMLButtonElement>;
1213
};
1314

14-
export const FieldCheckbox: React.FC<FieldCheckboxProps> = ({
15-
label,
16-
labelClassName,
17-
labelTooltip,
18-
wrapperClassName,
19-
errorClassName,
20-
formErrors,
21-
onChange,
15+
export const FieldCheckbox: React.FC<FieldCheckboxProps> = ({
16+
label,
17+
labelClassName,
18+
labelTooltip,
19+
wrapperClassName,
20+
errorClassName,
21+
formErrors,
22+
onChange,
2223
ref,
23-
...props
24+
...props
2425
}) => {
2526
return (
2627
<FieldWrapper<FieldCheckboxProps>
@@ -57,4 +58,3 @@ export const FieldCheckbox: React.FC<FieldCheckboxProps> = ({
5758
</FieldWrapper>
5859
);
5960
};
60-

packages/medusa-forms/src/ui/FieldGroup.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import clsx from 'clsx';
2+
import type * as React from 'react';
23

34
export const FieldGroup = ({ className, children }: { className?: string; children: React.ReactNode }) => {
45
return <div className={clsx('flex flex-col gap-y-small', className)}>{children}</div>;

packages/medusa-forms/src/ui/Input.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
import { Input as MedusaInput } from '@medusajs/ui';
2+
import type * as React from 'react';
23
import { FieldWrapper } from './FieldWrapper';
34
import type { BasicFieldProps, MedusaInputProps } from './types';
45

5-
export type Props = MedusaInputProps & BasicFieldProps & {
6-
ref?: React.Ref<HTMLInputElement>;
7-
};
6+
export type Props = MedusaInputProps &
7+
BasicFieldProps & {
8+
ref?: React.Ref<HTMLInputElement>;
9+
};
810

911
const Wrapper = FieldWrapper<Props>;
1012

1113
export const Input: React.FC<Props> = ({ ref, ...props }) => (
1214
<Wrapper {...props}>{(inputProps) => <MedusaInput {...inputProps} ref={ref} />}</Wrapper>
1315
);
14-

packages/medusa-forms/src/ui/Label.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { InformationCircle } from '@medusajs/icons';
22
import { Label as MedusaLabel, Tooltip } from '@medusajs/ui';
33
import clsx from 'clsx';
4+
import type * as React from 'react';
45

56
interface Props {
67
htmlFor?: string;

0 commit comments

Comments
 (0)