Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "feat: make dialog slot internal to be used for composition only",
"packageName": "@fluentui/react-drawer",
"email": "marcosvmmoura@gmail.com",
"dependentChangeType": "patch"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't forget to update in to feature

}
Original file line number Diff line number Diff line change
Expand Up @@ -131,19 +131,18 @@ export type DrawerInlineState = Required<ComponentState<DrawerInlineSlots> & Dra
export const DrawerOverlay: ForwardRefComponent<DrawerOverlayProps>;

// @public (undocumented)
export const drawerOverlayClassNames: Omit<SlotClassNames<DrawerOverlaySlots>, 'dialog'>;
export const drawerOverlayClassNames: SlotClassNames<DrawerOverlaySlots>;

// @public
export type DrawerOverlayProps = ComponentProps<DrawerOverlaySlots> & Pick<DialogProps, 'modalType' | 'onOpenChange' | 'inertTrapFocus' | 'defaultOpen'> & DrawerBaseProps;

// @public (undocumented)
// @public
export type DrawerOverlaySlots = DialogSurfaceSlots & {
root: Slot<DialogSurfaceProps>;
dialog?: Slot<DialogProps>;
};

// @public
export type DrawerOverlayState = Omit<ComponentState<DrawerOverlaySlots>, 'backdrop'> & Required<DrawerBaseState & {
export type DrawerOverlayState = Omit<ComponentState<DrawerOverlayInternalSlots>, 'backdrop'> & Required<DrawerBaseState & {
backdropMotion: MotionState<HTMLDivElement>;
}>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,24 @@ import type { MotionState } from '@fluentui/react-motion-preview';

import type { DrawerBaseProps, DrawerBaseState } from '../../shared/DrawerBase.types';

/**
* DrawerOverlay slots
*/
export type DrawerOverlaySlots = DialogSurfaceSlots & {
/**
* Slot for the root element.
*/
root: Slot<DialogSurfaceProps>;
};

/**
* DrawerOverlay internal slots for when using with composition API
*/
export type DrawerOverlayInternalSlots = DrawerOverlaySlots & {
/**
* Slot for the dialog component that wraps the drawer.
*/
dialog?: Slot<DialogProps>;
dialog: Slot<DialogProps>;
};

/**
Expand All @@ -23,7 +34,7 @@ export type DrawerOverlayProps = ComponentProps<DrawerOverlaySlots> &
/**
* State used in rendering DrawerOverlay
*/
export type DrawerOverlayState = Omit<ComponentState<DrawerOverlaySlots>, 'backdrop'> &
export type DrawerOverlayState = Omit<ComponentState<DrawerOverlayInternalSlots>, 'backdrop'> &
Required<
DrawerBaseState & {
backdropMotion: MotionState<HTMLDivElement>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/** @jsxImportSource @fluentui/react-jsx-runtime */
import { assertSlots } from '@fluentui/react-utilities';

import type { DrawerOverlayState, DrawerOverlaySlots } from './DrawerOverlay.types';
import type { DrawerOverlayState, DrawerOverlayInternalSlots } from './DrawerOverlay.types';

/**
* Render the final JSX of DrawerOverlay
Expand All @@ -12,7 +12,7 @@ export const renderDrawerOverlay_unstable = (state: DrawerOverlayState) => {
return null;
}

assertSlots<DrawerOverlaySlots>(state);
assertSlots<DrawerOverlayInternalSlots>(state);

return (
<state.dialog>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,23 @@ export const useDrawerOverlay_unstable = (
},
);

const dialog = slot.optional(props.dialog, {
elementType: Dialog,
renderByDefault: true,
defaultProps: {
const dialog = slot.always(
{
open: true,
defaultOpen,
onOpenChange,
inertTrapFocus,
modalType,
/*
* children is not needed here because we construct the children in the render function,
* but it's required by DialogProps
*/
children: null as unknown as JSX.Element,
},
{
elementType: Dialog,
},
});
);

return {
components: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
useDrawerDurationStyles,
} from '../../shared/useDrawerBaseStyles.styles';

export const drawerOverlayClassNames: Omit<SlotClassNames<DrawerOverlaySlots>, 'dialog'> = {
export const drawerOverlayClassNames: SlotClassNames<DrawerOverlaySlots> = {
root: 'fui-DrawerOverlay',
backdrop: 'fui-DrawerOverlay__backdrop',
};
Expand Down