|
|
|
@ -1,4 +1,5 @@
|
|
|
|
|
import * as React from 'react';
|
|
|
|
|
import { NoCompactStyle } from '../space/Compact';
|
|
|
|
|
import type { MenuProps } from './menu';
|
|
|
|
|
|
|
|
|
|
// Used for Dropdown only
|
|
|
|
@ -14,9 +15,10 @@ export interface OverrideContextProps {
|
|
|
|
|
const OverrideContext = React.createContext<OverrideContextProps | null>(null);
|
|
|
|
|
|
|
|
|
|
/** @internal Only used for Dropdown component. Do not use this in your production. */
|
|
|
|
|
export const OverrideProvider: React.FC<OverrideContextProps & { children: React.ReactNode }> = (
|
|
|
|
|
props,
|
|
|
|
|
) => {
|
|
|
|
|
export const OverrideProvider = React.forwardRef<
|
|
|
|
|
HTMLElement,
|
|
|
|
|
OverrideContextProps & { children: React.ReactNode }
|
|
|
|
|
>((props, ref) => {
|
|
|
|
|
const { children, ...restProps } = props;
|
|
|
|
|
const override = React.useContext(OverrideContext);
|
|
|
|
|
|
|
|
|
@ -32,8 +34,12 @@ export const OverrideProvider: React.FC<OverrideContextProps & { children: React
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return <OverrideContext.Provider value={context}>{children}</OverrideContext.Provider>;
|
|
|
|
|
};
|
|
|
|
|
return (
|
|
|
|
|
<OverrideContext.Provider value={context}>
|
|
|
|
|
<NoCompactStyle>{React.cloneElement(children as React.ReactElement, { ref })}</NoCompactStyle>
|
|
|
|
|
</OverrideContext.Provider>
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
/** @internal Only used for Dropdown component. Do not use this in your production. */
|
|
|
|
|
export default OverrideContext;
|
|
|
|
|