Skip to content
Draft
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
7 changes: 7 additions & 0 deletions change/@fluentui-react-drawer-base-hooks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🕵🏾‍♀️ visual changes to review in the Visual Change Report

vr-tests-react-components/Charts-DonutChart 2 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests-react-components/Charts-DonutChart.Dynamic.default.chromium.png 5581 Changed
vr-tests-react-components/Charts-DonutChart.Dynamic - Dark Mode.default.chromium.png 7530 Changed
vr-tests-react-components/Menu Converged - submenuIndicator slotted content 2 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests-react-components/Menu Converged - submenuIndicator slotted content.default - RTL.submenus open.chromium.png 404 Changed
vr-tests-react-components/Menu Converged - submenuIndicator slotted content.default.submenus open.chromium.png 413 Changed
vr-tests-react-components/Positioning 2 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests-react-components/Positioning.Positioning end.updated 2 times.chromium.png 623 Changed
vr-tests-react-components/Positioning.Positioning end.chromium.png 54 Changed
vr-tests-react-components/TagPicker 2 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests-react-components/TagPicker.disabled - RTL.disabled input hover.chromium.png 635 Changed
vr-tests-react-components/TagPicker.disabled.disabled input hover.chromium.png 677 Changed

There were 2 duplicate changes discarded. Check the build logs for more information.

"type": "minor",
"comment": "feat(react-drawer): add useOverlayDrawerBase_unstable and useInlineDrawerBase_unstable hooks",
"packageName": "@fluentui/react-drawer",
"email": "dmytrokirpa@microsoft.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "minor",
"comment": "feat(react-message-bar): add useMessageBarBase_unstable hook",
"packageName": "@fluentui/react-message-bar",
"email": "dmytrokirpa@microsoft.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import type { ComponentState } from '@fluentui/react-utilities';
import type { DialogProps } from '@fluentui/react-dialog';
import type { DialogSurfaceProps } from '@fluentui/react-dialog';
import type { DialogSurfaceSlots } from '@fluentui/react-dialog';
import type { DistributiveOmit } from '@fluentui/react-utilities';
import type { ForwardRefComponent } from '@fluentui/react-utilities';
import type { JSXElement } from '@fluentui/react-utilities';
import type { PresenceDirection } from '@fluentui/react-motion';
Expand Down Expand Up @@ -135,6 +136,15 @@ export type DrawerState = ComponentState<DrawerSlots>;
// @public
export const InlineDrawer: ForwardRefComponent<InlineDrawerProps>;

// @public
export type InlineDrawerBaseProps = ComponentProps<Omit<InlineDrawerSlots, 'surfaceMotion'>> & Omit<DrawerBaseProps, 'size' | 'position'>;

// @public
export type InlineDrawerBaseState = ComponentState<Omit<InlineDrawerSlots, 'surfaceMotion'>> & {
open: boolean;
unmountOnClose: boolean;
};

// @public (undocumented)
export const inlineDrawerClassNames: SlotClassNames<Omit<InlineDrawerSlots, 'surfaceMotion'>>;

Expand All @@ -150,13 +160,21 @@ export type InlineDrawerSlots = {
};

// @public
export type InlineDrawerState = Required<ComponentState<NonNullable<InlineDrawerSlots>> & DrawerBaseState & Pick<InlineDrawerProps, 'separator'> & {
export type InlineDrawerState = ComponentState<InlineDrawerSlots> & Required<DrawerBaseState & Pick<InlineDrawerProps, 'separator'>> & {
animationDirection: PresenceDirection;
}>;
open: boolean;
unmountOnClose: boolean;
};

// @public
export const OverlayDrawer: ForwardRefComponent<OverlayDrawerProps>;

// @public
export type OverlayDrawerBaseProps = DistributiveOmit<OverlayDrawerProps, 'size' | 'position'>;

// @public
export type OverlayDrawerBaseState = DistributiveOmit<OverlayDrawerState, 'size' | 'position' | 'motion'>;

// @public (undocumented)
export const overlayDrawerClassNames: SlotClassNames<Omit<OverlayDrawerSurfaceSlots, 'backdropMotion'>>;

Expand Down Expand Up @@ -199,7 +217,7 @@ export const renderDrawerHeaderTitle_unstable: (state: DrawerHeaderTitleState) =
export const renderInlineDrawer_unstable: (state: InlineDrawerState, contextValue: DrawerContextValue) => JSXElement;

// @public
export const renderOverlayDrawer_unstable: (state: OverlayDrawerState, contextValue: DrawerContextValue) => JSXElement;
export const renderOverlayDrawer_unstable: (state: OverlayDrawerBaseState, contextValue: DrawerContextValue) => JSXElement;

// @public
export const useDrawer_unstable: (props: DrawerProps, ref: React_2.Ref<HTMLElement>) => DrawerState;
Expand Down Expand Up @@ -246,12 +264,18 @@ export const useDrawerStyles_unstable: (state: DrawerState) => DrawerState;
// @public
export const useInlineDrawer_unstable: (props: InlineDrawerProps, ref: React_2.Ref<HTMLElement>) => InlineDrawerState;

// @public
export const useInlineDrawerBase_unstable: (props: InlineDrawerBaseProps, ref: React_2.Ref<HTMLElement>) => InlineDrawerBaseState;

// @public
export const useInlineDrawerStyles_unstable: (state: InlineDrawerState) => InlineDrawerState;

// @public
export const useOverlayDrawer_unstable: (props: OverlayDrawerProps, ref: React_2.Ref<HTMLElement>) => OverlayDrawerState;

// @public
export const useOverlayDrawerBase_unstable: (props: OverlayDrawerBaseProps, ref: React_2.Ref<HTMLElement>) => OverlayDrawerBaseState;

// @public
export const useOverlayDrawerStyles_unstable: (state: OverlayDrawerState) => OverlayDrawerState;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export type {
InlineDrawerBaseProps,
InlineDrawerBaseState,
InlineDrawerProps,
InlineDrawerSlots,
InlineDrawerState,
Expand All @@ -10,4 +12,5 @@ export {
renderInlineDrawer_unstable,
useInlineDrawerStyles_unstable,
useInlineDrawer_unstable,
useInlineDrawerBase_unstable,
} from './components/InlineDrawer/index';
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export type {
OverlayDrawerBaseProps,
OverlayDrawerBaseState,
OverlayDrawerInternalSlots,
OverlayDrawerProps,
OverlayDrawerSlots,
Expand All @@ -10,4 +12,5 @@ export {
renderOverlayDrawer_unstable,
useOverlayDrawerStyles_unstable,
useOverlayDrawer_unstable,
useOverlayDrawerBase_unstable,
} from './components/OverlayDrawer/index';
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,25 @@ export type InlineDrawerProps = ComponentProps<InlineDrawerSlots> &
/**
* State used in rendering InlineDrawer
*/
export type InlineDrawerState = Required<
ComponentState<NonNullable<InlineDrawerSlots>> &
DrawerBaseState &
Pick<InlineDrawerProps, 'separator'> & {
animationDirection: PresenceDirection;
}
>;
export type InlineDrawerState = ComponentState<InlineDrawerSlots> &
Required<DrawerBaseState & Pick<InlineDrawerProps, 'separator'>> & {
animationDirection: PresenceDirection;
open: boolean;
unmountOnClose: boolean;
};

/**
* InlineDrawer props without design-specific props (`size`, `position`, `separator`, and `surfaceMotion`).
* Use with `useInlineDrawerBase_unstable` to build custom-styled InlineDrawer variants.
*/
export type InlineDrawerBaseProps = ComponentProps<Omit<InlineDrawerSlots, 'surfaceMotion'>> &
Omit<DrawerBaseProps, 'size' | 'position'>;

/**
* InlineDrawer state without design-specific state fields (no `size`, `position`, `separator`,
* `surfaceMotion`, `animationDirection`, or deprecated `motion`).
*/
export type InlineDrawerBaseState = ComponentState<Omit<InlineDrawerSlots, 'surfaceMotion'>> & {
open: boolean;
unmountOnClose: boolean;
};
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
export { InlineDrawer } from './InlineDrawer';
export type {
InlineDrawerBaseProps,
InlineDrawerBaseState,
InlineDrawerProps,
InlineDrawerSlots,
InlineDrawerState,
SurfaceMotionSlotProps,
} from './InlineDrawer.types';
export { renderInlineDrawer_unstable } from './renderInlineDrawer';
export { useInlineDrawer_unstable } from './useInlineDrawer';
export { useInlineDrawer_unstable, useInlineDrawerBase_unstable } from './useInlineDrawer';
export { inlineDrawerClassNames, useInlineDrawerStyles_unstable } from './useInlineDrawerStyles.styles';
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,13 @@ export const renderInlineDrawer_unstable = (state: InlineDrawerState, contextVal

return (
<DrawerProvider value={contextValue}>
<state.surfaceMotion>
{state.surfaceMotion ? (
<state.surfaceMotion>
<state.root />
</state.surfaceMotion>
) : (
<state.root />
</state.surfaceMotion>
)}
</DrawerProvider>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@ import { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts

import { type DrawerMotionParams, InlineDrawerMotion } from '../../shared/drawerMotions';
import { useDrawerDefaultProps } from '../../shared/useDrawerDefaultProps';
import type { InlineDrawerProps, InlineDrawerState, SurfaceMotionSlotProps } from './InlineDrawer.types';
import type {
InlineDrawerBaseProps,
InlineDrawerBaseState,
InlineDrawerProps,
InlineDrawerState,
SurfaceMotionSlotProps,
} from './InlineDrawer.types';

const STATIC_MOTION = {
active: true,
Expand All @@ -16,6 +22,40 @@ const STATIC_MOTION = {
type: 'idle' as const,
};

/**
* Create the base state required to render InlineDrawer without design-specific props.
*
* The returned state can be composed with `useInlineDrawer_unstable` or used directly
* to build custom-styled InlineDrawer variants.
*
* @param props - props from this instance of InlineDrawer (without size, position, separator, surfaceMotion)
* @param ref - reference to root HTMLElement of InlineDrawer
*/
export const useInlineDrawerBase_unstable = (
props: InlineDrawerBaseProps,
ref: React.Ref<HTMLElement>,
): InlineDrawerBaseState => {
const { open = false, unmountOnClose = true } = props;

return {
components: {
root: 'div',
},

root: slot.always(
getIntrinsicElementProps('div', {
...props,
ref,
'aria-hidden': !unmountOnClose && !open ? true : undefined,
}),
{ elementType: 'div' },
),

open,
unmountOnClose,
};
};

/**
* Create the state required to render InlineDrawer.
*
Expand All @@ -27,11 +67,14 @@ const STATIC_MOTION = {
*/
export const useInlineDrawer_unstable = (props: InlineDrawerProps, ref: React.Ref<HTMLElement>): InlineDrawerState => {
const { size, position, open, unmountOnClose } = useDrawerDefaultProps(props);
const { separator = false, surfaceMotion } = props;
const { separator = false, surfaceMotion, ...baseProps } = props;
const { dir } = useFluent();
const [animationDirection, setAnimationDirection] = React.useState<PresenceDirection>(open ? 'enter' : 'exit');

const state = useInlineDrawerBase_unstable(baseProps as InlineDrawerBaseProps, ref);

return {
...state,
components: {
root: 'div',
// casting from internal type that has required properties
Expand All @@ -40,21 +83,13 @@ export const useInlineDrawer_unstable = (props: InlineDrawerProps, ref: React.Re
surfaceMotion: InlineDrawerMotion as unknown as React.FC<SurfaceMotionSlotProps>,
},

root: slot.always(
getIntrinsicElementProps('div', {
...props,
ref,
'aria-hidden': !unmountOnClose && !open ? true : undefined,
}),
{ elementType: 'div' },
),

open,
unmountOnClose,
position,
size,
separator,
unmountOnClose,
animationDirection,

surfaceMotion: presenceMotionSlot<DrawerMotionParams>(surfaceMotion, {
elementType: InlineDrawerMotion,
defaultProps: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { DialogProps } from '@fluentui/react-dialog';
import type { PresenceMotionSlotProps } from '@fluentui/react-motion';
import type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';
import type { ComponentProps, ComponentState, DistributiveOmit, Slot } from '@fluentui/react-utilities';

import type { DrawerMotionParams, OverlayDrawerSurfaceMotionParams } from '../../shared/drawerMotions';
import type { DrawerBaseProps, DrawerBaseState } from '../../shared/DrawerBase.types';
Expand Down Expand Up @@ -57,3 +57,14 @@ export type OverlayDrawerState = ComponentState<OverlayDrawerInternalSlots> &
Pick<OverlayDrawerProps, 'mountNode' | 'unmountOnClose'> & {
hasMountNodeElement: boolean;
};

/**
* OverlayDrawer props without design-specific props (`size` and `position`).
* Use with `useOverlayDrawerBase_unstable` to build custom-styled OverlayDrawer variants.
*/
export type OverlayDrawerBaseProps = DistributiveOmit<OverlayDrawerProps, 'size' | 'position'>;

/**
* OverlayDrawer state without design-specific state fields (`size`, `position`, and deprecated `motion`).
*/
export type OverlayDrawerBaseState = DistributiveOmit<OverlayDrawerState, 'size' | 'position' | 'motion'>;
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
export { OverlayDrawer } from './OverlayDrawer';
export type {
OverlayDrawerBaseProps,
OverlayDrawerBaseState,
OverlayDrawerInternalSlots,
OverlayDrawerProps,
OverlayDrawerSlots,
OverlayDrawerState,
} from './OverlayDrawer.types';
export { renderOverlayDrawer_unstable } from './renderOverlayDrawer';
export { useOverlayDrawer_unstable } from './useOverlayDrawer';
export { useOverlayDrawer_unstable, useOverlayDrawerBase_unstable } from './useOverlayDrawer';
export { overlayDrawerClassNames, useOverlayDrawerStyles_unstable } from './useOverlayDrawerStyles.styles';
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import type { JSXElement } from '@fluentui/react-utilities';
import { DrawerContextValue, DrawerProvider } from '../../contexts/drawerContext';
import { DialogBackdropProvider } from '@fluentui/react-dialog';

import type { OverlayDrawerState, OverlayDrawerInternalSlots } from './OverlayDrawer.types';
import type { OverlayDrawerBaseState, OverlayDrawerInternalSlots } from './OverlayDrawer.types';

/**
* Render the final JSX of OverlayDrawer
*/
export const renderOverlayDrawer_unstable = (
state: OverlayDrawerState,
state: OverlayDrawerBaseState,
contextValue: DrawerContextValue,
): JSXElement => {
assertSlots<OverlayDrawerInternalSlots>(state);
Expand Down
Loading
Loading