import { type CSSProperties, type PropsWithChildren, type ReactNode } from "react"; import type { IconNames, tokens } from "@jobber/design"; import { type ButtonProps } from "../Button"; import { type ButtonDismissProps } from "../ButtonDismiss"; import type { IconProps } from "../Icon"; export type BannerType = "notice" | "success" | "warning" | "error"; type TokensType = keyof typeof tokens; type Prefixes = TokensType extends `${infer Prefix}-${string}` ? Prefix : never; type ExtractTokens = Extract; type Tokenize = ExtractTokens extends `${T}-${infer Value}` ? Value : never; type Colors = Tokenize<"color">; export interface BannerProps { readonly children: ReactNode; /** * Sets the status-based theme of the Banner */ readonly type: BannerType; /** * Accepts props for Button. Default action uses a 'subtle' Button */ readonly primaryAction?: ButtonProps; /** * Set to false to hide the dismiss button * @default true */ readonly dismissible?: boolean; /** * Use to override the default status Icon */ readonly icon?: IconNames; /** * Callback to be called when the Banner is dismissed. */ onDismiss?(): void; /** * When provided, Banner's visibility is controlled by this value * @default undefined */ readonly controlledVisiblity?: boolean; } export interface BannerProviderProps extends PropsWithChildren { /** * Sets the status-based theme of the Banner. */ readonly type: BannerType; /** * When provided, Banner's visibility is controlled by this value. */ readonly visible?: boolean; /** * Callback to be called when the Banner is dismissed. */ readonly onDismiss?: () => void; /** * Icon to be used for the Banner. * If you want to remove the icon, set to false. * @default */ readonly icon?: React.ReactNode; /** * Dismiss button to be used for the Banner. * If you want to remove the dismiss button, set to false. * @default */ readonly dismissButton?: React.ReactNode; /** * **Use at your own risk:** Custom class names for specific elements. This should only be used as a * **last resort**. Using this may result in unexpected side effects. * More information in the [Customizing components Guide](https://atlantis.getjobber.com/guides/customizing-components). */ readonly UNSAFE_className?: { readonly container?: string; }; /** * **Use at your own risk:** Custom style for specific elements. This should only be used as a * **last resort**. Using this may result in unexpected side effects. * More information in the [Customizing components Guide](https://atlantis.getjobber.com/guides/customizing-components). */ readonly UNSAFE_style?: { readonly container?: CSSProperties; }; } export interface BannerContentProps extends PropsWithChildren { /** * **Use at your own risk:** Custom class names for specific elements. This should only be used as a * **last resort**. Using this may result in unexpected side effects. * More information in the [Customizing components Guide](https://atlantis.getjobber.com/guides/customizing-components). */ readonly UNSAFE_className?: { readonly container?: string; }; /** * **Use at your own risk:** Custom style for specific elements. This should only be used as a * **last resort**. Using this may result in unexpected side effects. * More information in the [Customizing components Guide](https://atlantis.getjobber.com/guides/customizing-components). */ readonly UNSAFE_style?: { readonly container?: CSSProperties; }; } export interface BannerDismissButtonProps { readonly onClick?: ButtonDismissProps["onClick"]; readonly ariaLabel?: ButtonDismissProps["ariaLabel"]; /** * **Use at your own risk:** Custom class names for specific elements. This should only be used as a * **last resort**. Using this may result in unexpected side effects. * More information in the [Customizing components Guide](https://atlantis.getjobber.com/guides/customizing-components). */ readonly UNSAFE_className?: { readonly container?: string; }; /** * **Use at your own risk:** Custom style for specific elements. This should only be used as a * **last resort**. Using this may result in unexpected side effects. * More information in the [Customizing components Guide](https://atlantis.getjobber.com/guides/customizing-components). */ readonly UNSAFE_style?: { readonly container?: CSSProperties; }; } export interface BannerIconProps extends Partial> { /** * Sets the background color of the icon. */ readonly backgroundColor?: Colors; /** * **Use at your own risk:** Custom class names for specific elements. This should only be used as a * **last resort**. Using this may result in unexpected side effects. * More information in the [Customizing components Guide](https://atlantis.getjobber.com/guides/customizing-components). */ readonly UNSAFE_className?: { readonly container?: string; readonly icon?: IconProps["UNSAFE_className"]; }; /** * **Use at your own risk:** Custom style for specific elements. This should only be used as a * **last resort**. Using this may result in unexpected side effects. * More information in the [Customizing components Guide](https://atlantis.getjobber.com/guides/customizing-components). */ readonly UNSAFE_style?: { readonly container?: CSSProperties; readonly icon?: IconProps["UNSAFE_style"]; }; } export interface BannerActionProps extends Omit { /** * **Use at your own risk:** Custom class names for specific elements. This should only be used as a * **last resort**. Using this may result in unexpected side effects. * More information in the [Customizing components Guide](https://atlantis.getjobber.com/guides/customizing-components). */ readonly UNSAFE_className?: { readonly container?: string; readonly button?: ButtonProps["UNSAFE_className"]; }; /** * **Use at your own risk:** Custom style for specific elements. This should only be used as a * **last resort**. Using this may result in unexpected side effects. * More information in the [Customizing components Guide](https://atlantis.getjobber.com/guides/customizing-components). */ readonly UNSAFE_style?: { readonly container?: CSSProperties; readonly button?: ButtonProps["UNSAFE_style"]; }; } export {};