Skip to content
Merged
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": "minor",
"comment": "adds Announce context",
"packageName": "@fluentui/react-shared-contexts",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@
import * as React_2 from 'react';
import type { Theme } from '@fluentui/react-theme';

// @internal (undocumented)
export type AnnounceContextValue_unstable = {
announce: (message: string, options?: AnnounceOptions) => void;
};

// @internal (undocumented)
export const AnnounceProvider_unstable: React_2.Provider<AnnounceContextValue_unstable | undefined>;

// @internal (undocumented)
export type BackgroundAppearanceContextValue = 'inverted' | undefined;

Expand Down Expand Up @@ -334,6 +342,11 @@ export type TooltipVisibilityContextValue_unstable = {
// @internal (undocumented)
export const TooltipVisibilityProvider_unstable: React_2.Provider<TooltipVisibilityContextValue_unstable>;

// Warning: (ae-incompatible-release-tags) The symbol "useAnnounce" is marked as @public, but its signature references "AnnounceContextValue_unstable" which is marked as @internal
//
// @public (undocumented)
export function useAnnounce_unstable(): AnnounceContextValue_unstable;

// Warning: (ae-incompatible-release-tags) The symbol "useBackgroundAppearance" is marked as @public, but its signature references "BackgroundAppearanceContextValue" which is marked as @internal
//
// @public (undocumented)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import * as React from 'react';

export type AnnounceOptions = {
alert?: boolean;
batchId?: string;
polite?: boolean;
priority?: number;
};

/**
* @internal
*/
export type AnnounceContextValue = {
announce: (message: string, options?: AnnounceOptions) => void;
};

/**
* @internal
*/
const AnnounceContext = React.createContext<AnnounceContextValue | undefined>(undefined);

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

export function useAnnounce(): AnnounceContextValue {
return React.useContext(AnnounceContext) ?? { announce: () => undefined };
}
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';
export type { AnnounceContextValue as AnnounceContextValue_unstable } from './AnnounceContext';