diff --git a/packages/mui-base/src/Fieldset/Legend/FieldsetLegend.tsx b/packages/mui-base/src/Fieldset/Legend/FieldsetLegend.tsx index 3671ee60d1..5fbedd9654 100644 --- a/packages/mui-base/src/Fieldset/Legend/FieldsetLegend.tsx +++ b/packages/mui-base/src/Fieldset/Legend/FieldsetLegend.tsx @@ -1,10 +1,10 @@ 'use client'; import * as React from 'react'; import PropTypes from 'prop-types'; -import type { FieldsetLegendOwnerState, FieldsetLegendProps } from './FieldsetLegend.types'; import { useComponentRenderer } from '../../utils/useComponentRenderer'; import { useFieldsetLegend } from './useFieldsetLegend'; import { useFieldsetRootContext } from '../Root/FieldsetRootContext'; +import type { BaseUIComponentProps } from '../../utils/types'; /** * Renders an element that labels the fieldset. @@ -18,7 +18,7 @@ import { useFieldsetRootContext } from '../Root/FieldsetRootContext'; * - [FieldsetLegend API](https://base-ui.netlify.app/components/react-fieldset/#api-reference-FieldsetLegend) */ const FieldsetLegend = React.forwardRef(function FieldsetLegend( - props: FieldsetLegendProps, + props: FieldsetLegend.Props, forwardedRef: React.ForwardedRef, ) { const { render, className, id, ...otherProps } = props; @@ -27,7 +27,7 @@ const FieldsetLegend = React.forwardRef(function FieldsetLegend( const { disabled } = useFieldsetRootContext(); - const ownerState: FieldsetLegendOwnerState = React.useMemo( + const ownerState: FieldsetLegend.OwnerState = React.useMemo( () => ({ disabled: disabled ?? false, }), @@ -46,6 +46,14 @@ const FieldsetLegend = React.forwardRef(function FieldsetLegend( return renderElement(); }); +namespace FieldsetLegend { + export type OwnerState = { + disabled: boolean; + }; + + export interface Props extends BaseUIComponentProps<'span', OwnerState> {} +} + FieldsetLegend.propTypes /* remove-proptypes */ = { // ┌────────────────────────────── Warning ──────────────────────────────┐ // │ These PropTypes are generated from the TypeScript type definitions. │ diff --git a/packages/mui-base/src/Fieldset/Legend/FieldsetLegend.types.ts b/packages/mui-base/src/Fieldset/Legend/FieldsetLegend.types.ts deleted file mode 100644 index 1cb1ed5e18..0000000000 --- a/packages/mui-base/src/Fieldset/Legend/FieldsetLegend.types.ts +++ /dev/null @@ -1,8 +0,0 @@ -import type { BaseUIComponentProps } from '../../utils/types'; - -export type FieldsetLegendOwnerState = { - disabled: boolean; -}; - -export interface FieldsetLegendProps - extends BaseUIComponentProps<'span', FieldsetLegendOwnerState> {} diff --git a/packages/mui-base/src/Fieldset/Legend/useFieldsetLegend.ts b/packages/mui-base/src/Fieldset/Legend/useFieldsetLegend.ts index 37aefaa774..2d07e6032b 100644 --- a/packages/mui-base/src/Fieldset/Legend/useFieldsetLegend.ts +++ b/packages/mui-base/src/Fieldset/Legend/useFieldsetLegend.ts @@ -5,11 +5,7 @@ import { useId } from '../../utils/useId'; import { useEnhancedEffect } from '../../utils/useEnhancedEffect'; import { useFieldsetRootContext } from '../Root/FieldsetRootContext'; -interface UseFieldsetLegendParameters { - id?: string; -} - -export function useFieldsetLegend(params: UseFieldsetLegendParameters) { +export function useFieldsetLegend(params: useFieldsetLegend.Parameters) { const { id: idProp } = params; const { setLegendId } = useFieldsetRootContext(); @@ -38,3 +34,9 @@ export function useFieldsetLegend(params: UseFieldsetLegendParameters) { [getLegendProps], ); } + +export namespace useFieldsetLegend { + export interface Parameters { + id?: string; + } +} diff --git a/packages/mui-base/src/Fieldset/Root/FieldsetRoot.tsx b/packages/mui-base/src/Fieldset/Root/FieldsetRoot.tsx index ba657b9e3a..74a47b859b 100644 --- a/packages/mui-base/src/Fieldset/Root/FieldsetRoot.tsx +++ b/packages/mui-base/src/Fieldset/Root/FieldsetRoot.tsx @@ -1,10 +1,10 @@ 'use client'; import * as React from 'react'; import PropTypes from 'prop-types'; -import type { FieldsetRootOwnerState, FieldsetRootProps } from './FieldsetRoot.types'; import { useComponentRenderer } from '../../utils/useComponentRenderer'; -import { FieldsetRootContext, type FieldsetRootContextValue } from './FieldsetRootContext'; +import { FieldsetRootContext } from './FieldsetRootContext'; import { useFieldsetRoot } from './useFieldsetRoot'; +import type { BaseUIComponentProps } from '../../utils/types'; /** * The foundation for building custom-styled fieldsets. @@ -18,14 +18,14 @@ import { useFieldsetRoot } from './useFieldsetRoot'; * - [FieldsetRoot API](https://base-ui.netlify.app/components/react-fieldset/#api-reference-FieldsetRoot) */ const FieldsetRoot = React.forwardRef(function FieldsetRoot( - props: FieldsetRootProps, + props: FieldsetRoot.Props, forwardedRef: React.ForwardedRef, ) { const { render, className, disabled = false, ...otherProps } = props; const { legendId, setLegendId, getRootProps } = useFieldsetRoot(); - const ownerState: FieldsetRootOwnerState = React.useMemo( + const ownerState: FieldsetRoot.OwnerState = React.useMemo( () => ({ disabled, }), @@ -41,7 +41,7 @@ const FieldsetRoot = React.forwardRef(function FieldsetRoot( extraProps: otherProps, }); - const contextValue: FieldsetRootContextValue = React.useMemo( + const contextValue: FieldsetRootContext = React.useMemo( () => ({ legendId, setLegendId, @@ -57,6 +57,14 @@ const FieldsetRoot = React.forwardRef(function FieldsetRoot( ); }); +namespace FieldsetRoot { + export type OwnerState = { + disabled: boolean; + }; + + export interface Props extends BaseUIComponentProps<'fieldset', OwnerState> {} +} + FieldsetRoot.propTypes /* remove-proptypes */ = { // ┌────────────────────────────── Warning ──────────────────────────────┐ // │ These PropTypes are generated from the TypeScript type definitions. │ diff --git a/packages/mui-base/src/Fieldset/Root/FieldsetRoot.types.ts b/packages/mui-base/src/Fieldset/Root/FieldsetRoot.types.ts deleted file mode 100644 index 5405138555..0000000000 --- a/packages/mui-base/src/Fieldset/Root/FieldsetRoot.types.ts +++ /dev/null @@ -1,8 +0,0 @@ -import type { BaseUIComponentProps } from '../../utils/types'; - -export type FieldsetRootOwnerState = { - disabled: boolean; -}; - -export interface FieldsetRootProps - extends BaseUIComponentProps<'fieldset', FieldsetRootOwnerState> {} diff --git a/packages/mui-base/src/Fieldset/Root/FieldsetRootContext.ts b/packages/mui-base/src/Fieldset/Root/FieldsetRootContext.ts index 9692eae8b5..80dc08ea3c 100644 --- a/packages/mui-base/src/Fieldset/Root/FieldsetRootContext.ts +++ b/packages/mui-base/src/Fieldset/Root/FieldsetRootContext.ts @@ -1,13 +1,13 @@ 'use client'; import * as React from 'react'; -export interface FieldsetRootContextValue { +export interface FieldsetRootContext { legendId: string | undefined; setLegendId: React.Dispatch>; disabled: boolean | undefined; } -export const FieldsetRootContext = React.createContext({ +export const FieldsetRootContext = React.createContext({ legendId: undefined, setLegendId: () => {}, disabled: undefined, diff --git a/packages/mui-base/src/Fieldset/index.barrel.ts b/packages/mui-base/src/Fieldset/index.barrel.ts index bd5416640a..b5a4cbaf40 100644 --- a/packages/mui-base/src/Fieldset/index.barrel.ts +++ b/packages/mui-base/src/Fieldset/index.barrel.ts @@ -1,5 +1,2 @@ export * from './Root/FieldsetRoot'; export * from './Legend/FieldsetLegend'; - -export type * from './Root/FieldsetRoot.types'; -export type * from './Legend/FieldsetLegend.types'; diff --git a/packages/mui-base/src/Fieldset/index.ts b/packages/mui-base/src/Fieldset/index.ts index 9d2e949e67..ee2ae05cbc 100644 --- a/packages/mui-base/src/Fieldset/index.ts +++ b/packages/mui-base/src/Fieldset/index.ts @@ -1,11 +1,2 @@ export { FieldsetRoot as Root } from './Root/FieldsetRoot'; export { FieldsetLegend as Legend } from './Legend/FieldsetLegend'; - -export type { - FieldsetRootProps as RootProps, - FieldsetRootOwnerState as RootOwnerState, -} from './Root/FieldsetRoot.types'; -export type { - FieldsetLegendProps as LegendProps, - FieldsetLegendOwnerState as LegendOwnerState, -} from './Legend/FieldsetLegend.types';