diff --git a/packages/frontend-plugin-api/report.api.md b/packages/frontend-plugin-api/report.api.md index 647533b3b2..fdcbd161d9 100644 --- a/packages/frontend-plugin-api/report.api.md +++ b/packages/frontend-plugin-api/report.api.md @@ -1937,12 +1937,26 @@ export const swappableComponentsApiRef: ApiRef_2; // @public export type ToastApi = { - post(toast: ToastMessage): string; + post(toast: ToastApiMessage): string; close(key: string): void; - toast$(): Observable; + toast$(): Observable; close$(): Observable; }; +// @public +export type ToastApiMessage = { + title: ReactNode; + description?: ReactNode; + status?: 'neutral' | 'info' | 'success' | 'warning' | 'danger'; + links?: ToastLink[]; + timeout?: number; +}; + +// @public +export type ToastApiMessageWithKey = ToastApiMessage & { + key: string; +}; + // @public export const toastApiRef: ApiRef; @@ -1952,20 +1966,6 @@ export type ToastLink = { href: string; }; -// @public -export type ToastMessage = { - title: ReactNode; - description?: ReactNode; - status?: 'neutral' | 'info' | 'success' | 'warning' | 'danger'; - links?: ToastLink[]; - timeout?: number; -}; - -// @public -export type ToastMessageWithKey = ToastMessage & { - key: string; -}; - // @public (undocumented) export type TranslationApi = { getTranslation< diff --git a/packages/frontend-plugin-api/src/apis/definitions/AlertApi.ts b/packages/frontend-plugin-api/src/apis/definitions/AlertApi.ts index dbb05d642f..6f90f9d56f 100644 --- a/packages/frontend-plugin-api/src/apis/definitions/AlertApi.ts +++ b/packages/frontend-plugin-api/src/apis/definitions/AlertApi.ts @@ -21,7 +21,7 @@ import { Observable } from '@backstage/types'; * Message handled by the {@link AlertApi}. * * @public - * @deprecated Use {@link ToastMessage} from {@link ToastApi} instead. AlertApi will be removed in a future release. + * @deprecated Use {@link ToastApiMessage} from {@link ToastApi} instead. AlertApi will be removed in a future release. * * Migration guide: * - `message` becomes `title` diff --git a/packages/frontend-plugin-api/src/apis/definitions/ToastApi.ts b/packages/frontend-plugin-api/src/apis/definitions/ToastApi.ts index 761a62e83f..cccd6cde00 100644 --- a/packages/frontend-plugin-api/src/apis/definitions/ToastApi.ts +++ b/packages/frontend-plugin-api/src/apis/definitions/ToastApi.ts @@ -35,7 +35,7 @@ export type ToastLink = { * * @public */ -export type ToastMessage = { +export type ToastApiMessage = { /** Title of the toast (required) */ title: ReactNode; /** Optional description text */ @@ -53,7 +53,7 @@ export type ToastMessage = { * * @public */ -export type ToastMessageWithKey = ToastMessage & { +export type ToastApiMessageWithKey = ToastApiMessage & { /** Unique key for the toast, used for programmatic dismiss */ key: string; }; @@ -96,7 +96,7 @@ export type ToastApi = { * @param toast - The toast message to display * @returns A unique key that can be used to programmatically dismiss the toast */ - post(toast: ToastMessage): string; + post(toast: ToastApiMessage): string; /** * Programmatically close/dismiss a toast by its key. @@ -108,7 +108,7 @@ export type ToastApi = { /** * Observe toasts posted by other parts of the application. */ - toast$(): Observable; + toast$(): Observable; /** * Observe close events for programmatic toast dismissal. diff --git a/plugins/app/package.json b/plugins/app/package.json index e9d0b63697..44b3ff62c7 100644 --- a/plugins/app/package.json +++ b/plugins/app/package.json @@ -20,9 +20,7 @@ "directory": "plugins/app" }, "license": "Apache-2.0", - "sideEffects": [ - "*.css" - ], + "sideEffects": false, "exports": { ".": "./src/index.ts", "./alpha": "./src/alpha/index.ts", diff --git a/plugins/app/report.api.md b/plugins/app/report.api.md index 0e50b40e19..e294a54f30 100644 --- a/plugins/app/report.api.md +++ b/plugins/app/report.api.md @@ -1020,14 +1020,6 @@ const appPlugin: OverridableFrontendPlugin< >; export default appPlugin; -// @public -export interface ToastContent { - description?: ReactNode; - links?: ToastLink[]; - status?: 'neutral' | 'info' | 'success' | 'warning' | 'danger'; - title: ReactNode; -} - // @public export function ToastDisplay(props: ToastDisplayProps): JSX_3.Element; @@ -1041,11 +1033,5 @@ export interface ToastDisplayProps { transientTimeoutMs?: number; } -// @public -export interface ToastLink { - href: string; - label: string; -} - // (No @packageDocumentation comment for this package) ``` diff --git a/plugins/app/src/apis/ToastApiForwarder.ts b/plugins/app/src/apis/ToastApiForwarder.ts index afae550c5a..800dcad038 100644 --- a/plugins/app/src/apis/ToastApiForwarder.ts +++ b/plugins/app/src/apis/ToastApiForwarder.ts @@ -16,8 +16,8 @@ import { ToastApi, - ToastMessage, - ToastMessageWithKey, + ToastApiMessage, + ToastApiMessageWithKey, } from '@backstage/frontend-plugin-api'; import { Observable } from '@backstage/types'; import ObservableImpl from 'zen-observable'; @@ -85,15 +85,15 @@ class PublishSubject { * @internal */ export class ToastApiForwarder implements ToastApi { - private readonly subject = new PublishSubject(); + private readonly subject = new PublishSubject(); private readonly closeSubject = new PublishSubject(); - private readonly recentToasts: ToastMessageWithKey[] = []; + private readonly recentToasts: ToastApiMessageWithKey[] = []; private readonly closedKeys = new Set(); private readonly maxBufferSize = 10; - post(toast: ToastMessage): string { + post(toast: ToastApiMessage): string { const key = generateToastKey(); - const toastWithKey: ToastMessageWithKey = { ...toast, key }; + const toastWithKey: ToastApiMessageWithKey = { ...toast, key }; this.recentToasts.push(toastWithKey); if (this.recentToasts.length > this.maxBufferSize) { @@ -121,7 +121,7 @@ export class ToastApiForwarder implements ToastApi { } } - toast$(): Observable { + toast$(): Observable { // Filter out any toasts that were closed to handle race conditions const activeToasts = this.recentToasts.filter( t => !this.closedKeys.has(t.key), diff --git a/plugins/app/src/components/Toast/index.ts b/plugins/app/src/components/Toast/index.ts index eb6d7574a8..279bc3b8cc 100644 --- a/plugins/app/src/components/Toast/index.ts +++ b/plugins/app/src/components/Toast/index.ts @@ -16,9 +16,9 @@ // Public exports export { ToastDisplay } from './ToastDisplay'; -export type { ToastContent, ToastLink, ToastDisplayProps } from './types'; +export type { ToastDisplayProps } from './types'; // Internal exports (used within the plugin only) export { ToastContainer } from './ToastContainer'; export { toastQueue } from './ToastQueue'; -export type { ToastContainerProps } from './types'; +export type { ToastContent, ToastLink, ToastContainerProps } from './types'; diff --git a/plugins/app/src/components/Toast/types.ts b/plugins/app/src/components/Toast/types.ts index 8cc6968423..9eb2148af3 100644 --- a/plugins/app/src/components/Toast/types.ts +++ b/plugins/app/src/components/Toast/types.ts @@ -19,7 +19,7 @@ import type { ToastQueue, ToastState, QueuedToast } from 'react-stately'; /** * Link item for toast notifications - * @public + * @internal */ export interface ToastLink { /** Display text for the link */ @@ -30,7 +30,7 @@ export interface ToastLink { /** * Content for a toast notification - * @public + * @internal */ export interface ToastContent { /** Title of the toast (required) */ @@ -72,7 +72,7 @@ export interface ToastProps { /** * Props for the ToastContainer component - * @public + * @internal */ export interface ToastContainerProps { /** Toast queue instance */ diff --git a/plugins/app/src/index.ts b/plugins/app/src/index.ts index 230e82ddd3..ac1df118e3 100644 --- a/plugins/app/src/index.ts +++ b/plugins/app/src/index.ts @@ -18,8 +18,4 @@ export { appPlugin as default } from './plugin'; // Toast components for alert display export { ToastDisplay } from './components/Toast'; -export type { - ToastContent, - ToastLink, - ToastDisplayProps, -} from './components/Toast'; +export type { ToastDisplayProps } from './components/Toast';