diff --git a/CHANGELOG.md b/CHANGELOG.md index bb7912268f..3fd8ded130 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,83 @@ # Versions +## v1.0.0-alpha.3 + +_Oct 7, 2024_ + +A big thanks to the 7 contributors who made this release possible. Here are some highlights ✨: + +- ⭐ We added several new components: CheckboxGroup, RadioGroup, Form, Separator +- ⭐ Menu has new parts: CheckboxItem, RadioItem, and Group + +### `@base_ui/react@1.0.0-alpha.3` + +- [AlertDialog] Move types to namespaces (#591) @michaldudak +- [Checkbox] Modernize implementation (#594) @atomiks +- [CheckboxGroup] Implement components and hooks (#458) @atomiks +- [Collapsible] Add Collapsible components and hooks (#481) @mj12albert +- [Dialog] Move types to namespaces (#697) @michaldudak +- [Dialog][Collapsible] Fix style prop merging (#641) @michaldudak +- [Form] Create new `Form` component (#589) @atomiks +- [Menu] CheckboxItem component (#533) @michaldudak +- [Menu] Do not select an item when space is pressed during typeahead (#542) @michaldudak +- [Menu] Fix custom anchor positioning (#609) @michaldudak +- [Menu] Group and Separator components (#535) @michaldudak +- [Menu] Increase test timeout (#592) @michaldudak +- [Menu] RadioItem component (#534) @michaldudak +- [Menu] Remove the unused prop (#647) @michaldudak +- [Menu] Remove wrong default value from docs (#549) @sai6855 +- [Menu][Popover][PreviewCard][Tooltip] Add default value as `clippingAncestors` to collisionBoundary prop (#580) @sai6855 +- [NumberField] Modernize implementation (#590) @atomiks +- [Popover] Modernize implementation (#607) @atomiks +- [PreviewCard] Modernize implementation (#626) @atomiks +- [RadioGroup] Create new `RadioGroup` component (#487) @atomiks +- [Slider] Fix Home / End regression (#526) @sai6855 +- [Tooltip] Modernize implementation (#606) @atomiks +- [useButton] Modernize implementation (#643) @michaldudak +- [useScrollLock] Avoid scrollbar layout shift issues (#604) @atomiks + +### Docs + +- [docs] Fix 301 redirections in docs @oliviertassinari +- [docs] Make the readme specific to @base_ui/react (#633) @michaldudak +- [docs] Copy vale-action.yml from main repo @oliviertassinari +- [docs] Fix 301 to chromium (#636) @oliviertassinari +- [docs] Avoid dead links in demos (#610) @oliviertassinari +- [docs] Fix rel attribute on edit GitHub links (#614) @oliviertassinari +- [docs] Fix pnpm docs:link-check script (#552) @oliviertassinari +- [docs] Fix Stack Overflow issue canned response @oliviertassinari +- [docs] Fix outdated link to support page @oliviertassinari +- [docs] Clarify contribution guide references @oliviertassinari + +### Core + +- [code-infra] Remove custom playwright installation steps (#646) @Janpot +- [core] Fix 301 link to Next.js and git diff @oliviertassinari +- [core] Fix package.json repository rule @oliviertassinari +- [core] MUI X repository moved to a new location @oliviertassinari +- [core] React 19 compatibility (#605) @michaldudak +- [core] Reference `ownerDocument` (#660) @atomiks +- [core] Remove 'use client' from index files (#331) @michaldudak +- [core] Remove /.yarn (#596) @oliviertassinari +- [core] Remove Material UI dependency (#585) @michaldudak +- [core] Remove the legacy components from the repo (#584) @michaldudak +- [core] Rename positionStrategy to positionMethod (#704) @michaldudak +- [docs-infra] Fix double // (#613) @oliviertassinari +- [docs-infra] Strengthen CSP (#595) @oliviertassinari +- [infra] Adds reusable workflow for closing message on issues (#598) @michelengelen +- [infra] Adds reusable workflow for issue cleanup (#597) @michelengelen +- [infra] Fix line break in Stack Overflow message @oliviertassinari +- [test] Fix tests on Safari (#546) @michaldudak +- [test] Fix the test_types_next CI job (#703) @michaldudak +- [test] Improve visual screenshot canva (#708) +- [test] Point Istanbul to correct URL (#657) @sai6855 +- [test] Run Browserstack tests on master only (#578) @michaldudak +- [test] Use `waitFor` instead of fixed timeout in tests (#632) @michaldudak +- [website] Improve utm_source strategy @oliviertassinari +- [website] Modernize the Base UI website (#538) @michaldudak + +All contributors of this release in alphabetical order: @atomiks, @Janpot, @michaldudak, @michelengelen, @mj12albert, @oliviertassinari, @sai6855 + ## v1.0.0-alpha.2 _Aug 19, 2024_ diff --git a/docs/data/api/switch-root.json b/docs/data/api/switch-root.json index b63432c278..ab1c15cd36 100644 --- a/docs/data/api/switch-root.json +++ b/docs/data/api/switch-root.json @@ -4,7 +4,6 @@ "className": { "type": { "name": "union", "description": "func
| string" } }, "defaultChecked": { "type": { "name": "bool" } }, "disabled": { "type": { "name": "bool" }, "default": "false" }, - "id": { "type": { "name": "string" } }, "inputRef": { "type": { "name": "custom", "description": "ref" } }, "name": { "type": { "name": "string" } }, "onCheckedChange": { diff --git a/docs/data/components/switch/UnstyledSwitchIntroduction/css-modules/index.js b/docs/data/components/switch/UnstyledSwitchIntroduction/css-modules/index.js index ca04551ec5..d48f24dbea 100644 --- a/docs/data/components/switch/UnstyledSwitchIntroduction/css-modules/index.js +++ b/docs/data/components/switch/UnstyledSwitchIntroduction/css-modules/index.js @@ -1,148 +1,39 @@ 'use client'; import * as React from 'react'; import * as Switch from '@base_ui/react/Switch'; -import { useTheme } from '@mui/system'; +import classes from './styles.module.css'; export default function UnstyledSwitchIntroduction() { return (
- + - + - + - + -
); } - -const cyan = { - 50: '#E9F8FC', - 100: '#BDEBF4', - 200: '#99D8E5', - 300: '#66BACC', - 400: '#1F94AD', - 500: '#0D5463', - 600: '#094855', - 700: '#063C47', - 800: '#043039', - 900: '#022127', -}; - -const grey = { - 50: '#F3F6F9', - 100: '#E5EAF2', - 200: '#DAE2ED', - 300: '#C7D0DD', - 400: '#B0B8C4', - 500: '#9DA8B7', - 600: '#6B7A90', - 700: '#434D5B', - 800: '#303740', - 900: '#1C2025', -}; - -function useIsDarkMode() { - const theme = useTheme(); - return theme.palette.mode === 'dark'; -} - -function Styles() { - // Replace this with your app logic for determining dark modes - const isDarkMode = useIsDarkMode(); - - return ( - - ); -} diff --git a/docs/data/components/switch/UnstyledSwitchIntroduction/css-modules/index.tsx b/docs/data/components/switch/UnstyledSwitchIntroduction/css-modules/index.tsx index ca04551ec5..d48f24dbea 100644 --- a/docs/data/components/switch/UnstyledSwitchIntroduction/css-modules/index.tsx +++ b/docs/data/components/switch/UnstyledSwitchIntroduction/css-modules/index.tsx @@ -1,148 +1,39 @@ 'use client'; import * as React from 'react'; import * as Switch from '@base_ui/react/Switch'; -import { useTheme } from '@mui/system'; +import classes from './styles.module.css'; export default function UnstyledSwitchIntroduction() { return (
- + - + - + - + -
); } - -const cyan = { - 50: '#E9F8FC', - 100: '#BDEBF4', - 200: '#99D8E5', - 300: '#66BACC', - 400: '#1F94AD', - 500: '#0D5463', - 600: '#094855', - 700: '#063C47', - 800: '#043039', - 900: '#022127', -}; - -const grey = { - 50: '#F3F6F9', - 100: '#E5EAF2', - 200: '#DAE2ED', - 300: '#C7D0DD', - 400: '#B0B8C4', - 500: '#9DA8B7', - 600: '#6B7A90', - 700: '#434D5B', - 800: '#303740', - 900: '#1C2025', -}; - -function useIsDarkMode() { - const theme = useTheme(); - return theme.palette.mode === 'dark'; -} - -function Styles() { - // Replace this with your app logic for determining dark modes - const isDarkMode = useIsDarkMode(); - - return ( - - ); -} diff --git a/docs/data/components/switch/UnstyledSwitchIntroduction/css-modules/styles.module.css b/docs/data/components/switch/UnstyledSwitchIntroduction/css-modules/styles.module.css new file mode 100644 index 0000000000..d0b25a5991 --- /dev/null +++ b/docs/data/components/switch/UnstyledSwitchIntroduction/css-modules/styles.module.css @@ -0,0 +1,80 @@ +.root { + width: 38px; + height: 24px; + margin: 10px; + padding: 0; + box-sizing: border-box; + background: var(--gray-50); + border: 1px solid var(--gray-200); + border-radius: 24px; + display: inline-block; + transition-property: all; + transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); + transition-duration: 120ms; + box-shadow: inset 0px 1px 1px rgba(0, 0, 0, 0.05); + + :global(.dark) & { + background: var(--gray-900); + border-color: var(--gray-800); + box-shadow: inset 0px 1px 1px rgba(0, 0, 0, 0.5); + } + + &[data-disabled] { + opacity: 0.4; + cursor: not-allowed; + } + + &:hover:not([data-disabled]) { + background: var(--gray-100); + border-color: var(--gray-300); + + :global(.dark) & { + background: var(--gray-800); + border-color: var(--gray-600); + } + } + + &:focus-visible { + box-shadow: 0 0 0 3px var(--cyan-200); + + :global(.dark) & { + box-shadow: 0 0 0 3px var(--cyan-700); + } + } + + &[data-state='checked'] { + border: none; + background: var(--cyan-500); + } + + &[data-state='checked']:not([data-disabled]):hover { + background: var(--cyan-700); + } +} + +.thumb { + box-sizing: border-box; + border: 1px solid var(--gray-200); + display: block; + width: 16px; + height: 16px; + left: 4px; + border-radius: 16px; + background-color: #fff; + position: relative; + transition-property: all; + transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); + transition-duration: 120ms; + box-shadow: 0px 1px 2px rgba(0, 0, 0, 0.1); + + :global(.dark) & { + border-color: var(--gray-800); + box-shadow: 0px 1px 2px rgba(0, 0, 0, 0.25); + } +} + +.thumb[data-state='checked'] { + left: 18px; + background-color: #fff; + box-shadow: 0px 1px 2px rgba(0, 0, 0, 0.3); +} diff --git a/docs/data/components/switch/UnstyledSwitchIntroduction/tailwind/index.tsx b/docs/data/components/switch/UnstyledSwitchIntroduction/tailwind/index.tsx index f7443c9756..d3c6a6a13f 100644 --- a/docs/data/components/switch/UnstyledSwitchIntroduction/tailwind/index.tsx +++ b/docs/data/components/switch/UnstyledSwitchIntroduction/tailwind/index.tsx @@ -30,9 +30,9 @@ export default function UnstyledSwitchIntroduction() { ); } -const Switch = React.forwardRef( +const Switch = React.forwardRef( function Switch({ className: classNameProp = '', ...props }, ref) { - const className = ({ checked }: BaseSwitch.OwnerState) => + const className = ({ checked }: BaseSwitch.Root.OwnerState) => `group relative inline-block w-[38px] h-[24px] m-2.5 p-0 transition rounded-full border border-solid outline-none border-slate-300 dark:border-gray-700 focus-visible:shadow-outline-switch @@ -48,7 +48,7 @@ const Thumb = React.forwardRef< HTMLSpanElement, React.HTMLAttributes >(function Thumb({ className: classNameProp = '', ...props }, ref) { - const className = ({ checked }: BaseSwitch.OwnerState) => + const className = ({ checked }: BaseSwitch.Root.OwnerState) => `block w-4 h-4 rounded-2xl border border-solid outline-none border-slate-300 dark:border-gray-700 transition shadow-[0_1px_2px_rgb(0_0_0_/_0.1)] dark:shadow-[0_1px_2px_rgb(0_0_0_/_0.25)] relative transition-all diff --git a/docs/data/components/tabs/UnstyledTabsIntroduction/tailwind/index.tsx b/docs/data/components/tabs/UnstyledTabsIntroduction/tailwind/index.tsx index 4eb2e98f54..92957ad454 100644 --- a/docs/data/components/tabs/UnstyledTabsIntroduction/tailwind/index.tsx +++ b/docs/data/components/tabs/UnstyledTabsIntroduction/tailwind/index.tsx @@ -29,7 +29,7 @@ export default function UnstyledTabsIntroduction() { ); } -const TabsList = React.forwardRef((props, ref) => { +const TabsList = React.forwardRef((props, ref) => { const { className, ...other } = props; return ( ((props, ref) = ); }); -const Tab = React.forwardRef((props, ref) => { +const Tab = React.forwardRef((props, ref) => { const { className, ...other } = props; return ( ((props, ref) => { ); }); -const TabPanel = React.forwardRef((props, ref) => { +const TabPanel = React.forwardRef((props, ref) => { const { className, ...other } = props; return ( true, the component is disabled and can't be interacted with." }, - "id": { "description": "The id of the switch element." }, "inputRef": { "description": "Ref to the underlying input element." }, "name": { "description": "Name of the underlying input element." }, "onCheckedChange": { diff --git a/docs/src/blocks/PackageManagerSnippet/PackageManagerSnippetRoot.tsx b/docs/src/blocks/PackageManagerSnippet/PackageManagerSnippetRoot.tsx index eae7177cd5..a9d8e6c234 100644 --- a/docs/src/blocks/PackageManagerSnippet/PackageManagerSnippetRoot.tsx +++ b/docs/src/blocks/PackageManagerSnippet/PackageManagerSnippetRoot.tsx @@ -44,7 +44,7 @@ export namespace PackageManagerSnippetRoot { export type Props = { children: React.ReactNode; options: Array<{ value: string; label: string }>; - renderTab?: Tabs.TabProps['render']; - renderTabsList?: Tabs.ListProps['render']; + renderTab?: Tabs.Tab.Props['render']; + renderTabsList?: Tabs.List.Props['render']; }; } diff --git a/package.json b/package.json index 7fdca89621..d25331dc22 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@base_ui/monorepo", - "version": "1.0.0-alpha.2", + "version": "1.0.0-alpha.3", "private": true, "scripts": { "preinstall": "npx only-allow pnpm", diff --git a/packages/mui-base/package.json b/packages/mui-base/package.json index e922305204..e936c416a3 100644 --- a/packages/mui-base/package.json +++ b/packages/mui-base/package.json @@ -1,6 +1,6 @@ { "name": "@base_ui/react", - "version": "1.0.0-alpha.2", + "version": "1.0.0-alpha.3", "private": false, "author": "MUI Team", "description": "Base UI is a library of headless ('unstyled') React components and low-level hooks. You gain complete control over your app's CSS and accessibility features.", 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'; diff --git a/packages/mui-base/src/Switch/Root/SwitchContext.ts b/packages/mui-base/src/Switch/Root/SwitchContext.ts deleted file mode 100644 index c2366b6127..0000000000 --- a/packages/mui-base/src/Switch/Root/SwitchContext.ts +++ /dev/null @@ -1,5 +0,0 @@ -'use client'; -import * as React from 'react'; -import { type SwitchOwnerState } from './SwitchRoot.types'; - -export const SwitchContext = React.createContext(null); diff --git a/packages/mui-base/src/Switch/Root/SwitchRoot.tsx b/packages/mui-base/src/Switch/Root/SwitchRoot.tsx index f467e55059..40831d0b5d 100644 --- a/packages/mui-base/src/Switch/Root/SwitchRoot.tsx +++ b/packages/mui-base/src/Switch/Root/SwitchRoot.tsx @@ -3,17 +3,12 @@ import * as React from 'react'; import PropTypes from 'prop-types'; import refType from '@mui/utils/refType'; import { useSwitchRoot } from './useSwitchRoot'; -import { SwitchContext } from './SwitchContext'; -import type { SwitchRootProps, SwitchOwnerState } from './SwitchRoot.types'; -import { resolveClassName } from '../../utils/resolveClassName'; -import { useSwitchStyleHooks } from './useSwitchStyleHooks'; -import { evaluateRenderProp } from '../../utils/evaluateRenderProp'; -import { useRenderPropForkRef } from '../../utils/useRenderPropForkRef'; +import { SwitchRootContext } from './SwitchRootContext'; +import { styleHookMapping } from '../styleHooks'; +import { useComponentRenderer } from '../../utils/useComponentRenderer'; +import type { FieldRoot } from '../../Field/Root/FieldRoot'; import { useFieldRootContext } from '../../Field/Root/FieldRootContext'; - -function defaultRender(props: React.ComponentPropsWithRef<'button'>) { - return