Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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": "minor",
"comment": "adds Announce context",
"packageName": "@fluentui/react-shared-contexts",
"email": "eysjiang@gmail.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import * as React from 'react';

export type AnnounceOptions = {
alert?: boolean;
priority?: number;
batchId?: string;
Comment thread
emmayjiang marked this conversation as resolved.
};

/**
* @internal
*/
export type AnnounceContextValue = (message: string, options: AnnounceOptions) => void;
Comment thread
emmayjiang marked this conversation as resolved.
Outdated

/**
* @internal
*/
export const AnnounceContext = React.createContext<AnnounceContextValue | undefined>(undefined);
Comment thread
emmayjiang marked this conversation as resolved.
Outdated

/**
* @internal
*/
export const AnnounceProvider = AnnounceContext.Provider;

export function useAnnounce(): AnnounceContextValue {
Comment thread
smhigley marked this conversation as resolved.
return React.useContext(AnnounceContext) ?? (() => null);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './AnnounceContext';
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,6 @@ export { BackgroundAppearanceProvider, useBackgroundAppearance } from './Backgro
export type { BackgroundAppearanceContextValue } from './BackgroundAppearanceContext';

export { PortalMountNodeProvider, usePortalMountNode } from './PortalMountNodeContext';

export { AnnounceProvider as AnnounceProvider_unstable, useAnnounce as useAnnounce_unstable } from './AnnounceContext';
Comment thread
emmayjiang marked this conversation as resolved.
export type { AnnounceContextValue as AnnounceContextValue_unstable } from './AnnounceContext';