@veracity/vui
Version:
Veracity UI is a React component library crafted for use within Veracity applications and pages. Based on Styled Components and @xstyled.
84 lines (83 loc) • 4.67 kB
TypeScript
import { ThemingProps } from "../theme/types.js";
import "../theme/index.js";
import { IconProp, IconProps } from "../icon/icon.types.js";
import "../icon/index.js";
import { BoxProps } from "../box/box.types.js";
import "../box/index.js";
import { AriaAttributes, AriaRole, JSX, ReactNode } from "react";
//#region src/notification/notification.types.d.ts
type NotificationProps = Omit<BoxProps, 'size' | 'variant'> & Omit<ThemingProps<'Notification'>, 'variant'> & {
/** Socket displaying a button on the right. */
action?: ReactNode;
/** Vertical alignment of icon and dismiss button. Use `'center'` for single-line notifications. Manual override for the inferred layout. */
align?: 'top' | 'center';
/**
* ARIA live-region politeness. Auto-mapped from `intent` when omitted:
* info/success → `'polite'`, warning/danger → `'assertive'`. Forced to `'polite'` when `isLoading` is true.
*/
ariaLive?: AriaAttributes['aria-live'];
/** Available theme colors for this component. @deprecated */
colorScheme?: 'blue' | 'green' | 'red' | 'yellow';
/** Socket displaying an icon on the left. Set to `''` to suppress auto-injected icons. @deprecated Icons are now auto-injected based on `intent`. */
icon?: IconProp | JSX.Element | '';
/** Semantic colour intent — drives variant colour and auto-injects the matching icon. */
intent?: NotificationIntent;
/** When true, shows a loading spinner icon and suppresses intent-based icon injection. Forces `role="status"` / `aria-live="polite"` and defaults `intent` to `'info'` when not specified. */
isLoading?: boolean;
/** Callback function for the dismiss button. Only used when showDismissButton is true. */
onClose?: () => void;
/**
* ARIA role override. Auto-mapped from `intent` when omitted:
* info/success → `'status'`, warning/danger → `'alert'`. Forced to `'status'` when `isLoading` is true.
*/
role?: AriaRole;
/** Controls dismiss button visibility. When true, shows the button. Provide onClose for custom handler or use default. */
showDismissButton?: boolean;
/** Modifies Notification style and content based on the given status. @deprecated Use `variant` + `intent` instead. */
status?: NotificationStatus;
/** Object definition of styles and content for each status. @deprecated Use `variant` + `intent` instead. */
statusMapping?: NotificationStatusMapping;
/** Socket displaying text in the middle. */
text?: ReactNode;
/** Socket displaying title in the middle. */
title?: ReactNode;
/** The notification display style, or a legacy compound variant string. */
variant?: NotificationVariantHierarchy | NotificationVariantLegacy | (string & {});
/** @deprecated Use `align` instead. `'flex-start'` maps to `'top'`. */
verticalAlign?: 'center' | 'flex-start';
};
/** Semantic colour intents for the two-prop API. */
type NotificationIntent = 'info' | 'success' | 'danger' | 'warning';
/** Display style hierarchy for the two-prop API. */
type NotificationVariantHierarchy = 'inline' | 'banner';
/**
* Inferred layout based on content composition:
* - `'button-down'` when an `action` socket is present
* - `'multiline'` when both `title` and `text` are present (and no action)
* - `'one-line'` otherwise
*
* Layout is inference-only — there is no `layout` prop. Use `align` to override visual alignment.
*/
type NotificationLayout = 'one-line' | 'multiline' | 'button-down';
/**
* Legacy compound variant strings — kept for backward compatibility.
* Prefer `variant` + `intent` instead.
* @deprecated
*/
type NotificationVariantLegacy = 'subtleBlue' | 'subtleRed' | 'subtleYellow' | 'subtleGreen' | 'bannerBlue' | 'bannerRed' | 'bannerYellow' | 'bannerGreen';
/**
* @deprecated Use `NotificationVariantHierarchy | NotificationVariantLegacy` instead.
* Kept as a convenience alias.
*/
type NotificationVariant = NotificationVariantHierarchy | NotificationVariantLegacy;
type NotificationStatus = 'danger' | 'error' | 'info' | 'loading' | 'success' | 'warning' | 'bannerDanger' | 'bannerError' | 'bannerInfo' | 'bannerLoading' | 'bannerSuccess' | 'bannerWarning';
type NotificationStatusEntry = {
iconProps: IconProps;
intent?: NotificationIntent;
isLoading?: boolean;
variant?: NotificationVariantHierarchy | NotificationVariantLegacy;
};
type NotificationStatusMapping = Record<string, NotificationStatusEntry>;
//#endregion
export { NotificationIntent, NotificationLayout, NotificationProps, NotificationStatus, NotificationStatusEntry, NotificationStatusMapping, NotificationVariant, NotificationVariantHierarchy, NotificationVariantLegacy };
//# sourceMappingURL=notification.types.d.ts.map