forked from mui/base-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[core] Make context definitions consistent (mui#735)
- Loading branch information
1 parent
7445aad
commit 8c52af4
Showing
71 changed files
with
368 additions
and
226 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 0 additions & 22 deletions
22
packages/mui-base/src/Collapsible/Root/CollapsibleContext.tsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
packages/mui-base/src/Collapsible/Root/CollapsibleRootContext.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
'use client'; | ||
import * as React from 'react'; | ||
import type { CollapsibleRoot } from './CollapsibleRoot'; | ||
import type { useCollapsibleRoot } from './useCollapsibleRoot'; | ||
|
||
export interface CollapsibleRootContext extends useCollapsibleRoot.ReturnValue { | ||
ownerState: CollapsibleRoot.OwnerState; | ||
} | ||
|
||
export const CollapsibleRootContext = React.createContext<CollapsibleRootContext | undefined>( | ||
undefined, | ||
); | ||
|
||
if (process.env.NODE_ENV !== 'production') { | ||
CollapsibleRootContext.displayName = 'CollapsibleRootContext'; | ||
} | ||
|
||
export function useCollapsibleContext() { | ||
const context = React.useContext(CollapsibleRootContext); | ||
if (context === undefined) { | ||
throw new Error( | ||
'Base UI: CollapsibleRootContext is missing. Collapsible parts must be placed within <Collapsible.Root>.', | ||
); | ||
} | ||
|
||
return context; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 17 additions & 10 deletions
27
packages/mui-base/src/Composite/Root/CompositeRootContext.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,26 @@ | ||
'use client'; | ||
import * as React from 'react'; | ||
|
||
export const CompositeRootContext = React.createContext<CompositeRootContext.Value | null>(null); | ||
export interface CompositeRootContext { | ||
activeIndex: number; | ||
onActiveIndexChange: (index: number) => void; | ||
} | ||
|
||
export const CompositeRootContext = React.createContext<CompositeRootContext | undefined>( | ||
undefined, | ||
); | ||
|
||
if (process.env.NODE_ENV !== 'production') { | ||
CompositeRootContext.displayName = 'CompositeRootContext'; | ||
} | ||
|
||
export function useCompositeRootContext() { | ||
const context = React.useContext(CompositeRootContext); | ||
if (context === null) { | ||
throw new Error('<Composite.Item> must be used within <Composite.Root>'); | ||
if (context === undefined) { | ||
throw new Error( | ||
'Base UI: CompositeRootContext is missing. Composite parts must be placed within <Composite.Root>.', | ||
); | ||
} | ||
return context; | ||
} | ||
|
||
export namespace CompositeRootContext { | ||
export interface Value { | ||
activeIndex: number; | ||
onActiveIndexChange: (index: number) => void; | ||
} | ||
return context; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.