@spark-ui/components
Version:
Spark (Leboncoin design system) components.
159 lines (147 loc) • 6.43 kB
TypeScript
import { QueuedToast, ToastState, ToastOptions } from '@react-stately/toast';
import { ReactNode, ComponentPropsWithRef, PropsWithChildren, ReactElement, Ref } from 'react';
import * as react_jsx_runtime from 'react/jsx-runtime';
import * as class_variance_authority_types from 'class-variance-authority/types';
import { VariantProps } from 'class-variance-authority';
import { AriaToastRegionProps } from '@react-aria/toast';
import { ButtonProps } from '../button/index.js';
import { IconButtonProps } from '../icon-button/index.js';
import { IconProps } from '../icon/index.js';
declare const snackbarItemVariant: (props?: ({
design?: "filled" | "tinted" | null | undefined;
intent?: "main" | "success" | "alert" | "error" | "info" | "neutral" | "basic" | "support" | "accent" | "inverse" | null | undefined;
} & class_variance_authority_types.ClassProp) | undefined) => string;
declare const snackbarItemVariantContent: (props?: ({
actionOnNewline?: boolean | null | undefined;
} & class_variance_authority_types.ClassProp) | undefined) => string;
type SnackbarItemVariantProps = VariantProps<typeof snackbarItemVariant>;
type SnackbarItemVariantContentProps = VariantProps<typeof snackbarItemVariantContent>;
interface SnackbarItemValue extends SnackbarItemVariantProps {
/**
* Icon that will be prepended before snackbar message
*/
icon?: ReactNode;
message: ReactNode;
/**
* If `true` snackbar will display a close button
* @default false
*/
isClosable?: boolean;
/**
* A label for the action button within the toast.
*/
actionLabel?: string;
/**
* Handler that is called when the action button is pressed.
*/
onAction?: () => void;
/**
* If `true` the action button will be displayed on a new line.
* @default false
*/
actionOnNewline?: boolean;
}
interface SnackbarItemProps extends ComponentPropsWithRef<'div'>, SnackbarItemVariantProps, SnackbarItemVariantContentProps {
/**
* Defines a string value that labels the current element.
*/
'aria-label'?: string;
/**
* Identifies the element (or elements) that labels the current element.
*/
'aria-labelledby'?: string;
/**
* Identifies the element (or elements) that describes the object.
*/
'aria-describedby'?: string;
/**
* Identifies the element (or elements) that provide a detailed, extended description for the object.
*/
'aria-details'?: string;
}
declare const SnackbarItem: {
({ "aria-label": ariaLabel, "aria-labelledby": ariaLabelledby, "aria-describedby": ariaDescribedby, "aria-details": ariaDetails, design: designProp, intent: intentProp, actionOnNewline: actionOnNewlineProp, className, children, ref: forwardedRef, ...rest }: PropsWithChildren<SnackbarItemProps>): react_jsx_runtime.JSX.Element;
displayName: string;
};
interface SnackbarItemState<T = SnackbarItemValue> {
toast: QueuedToast<T>;
state: ToastState<T>;
}
declare const snackbarRegionVariant: (props?: ({
position?: "top" | "top-right" | "top-left" | "bottom" | "bottom-right" | "bottom-left" | null | undefined;
} & class_variance_authority_types.ClassProp) | undefined) => string;
type SnackbarRegionVariantProps = VariantProps<typeof snackbarRegionVariant>;
interface SnackbarRegionProps extends ComponentPropsWithRef<'div'>, AriaToastRegionProps, SnackbarRegionVariantProps, Pick<SnackbarItemState, 'state'> {
/**
* An accessibility label for the snackbar region.
* @default 'Notifications'
*/
'aria-label'?: string;
/**
* Identifies the element (or elements) that labels the current element.
*/
'aria-labelledby'?: string;
/**
* Identifies the element (or elements) that describes the object.
*/
'aria-describedby'?: string;
/**
* Identifies the element (or elements) that provide a detailed, extended description for the object.
*/
'aria-details'?: string;
/**
* The component/template used to display each snackbar from the queue
* @default 'Snackbar.Item'
*/
children?: ReactElement<SnackbarItemProps, typeof SnackbarItem>;
}
declare const clearSnackbarQueue: () => void;
type SnackbarProps = Omit<SnackbarRegionProps, 'state'> & {
ref?: Ref<HTMLDivElement>;
};
declare const Snackbar$1: {
({ ref: forwardedRef, ...props }: SnackbarProps): ReactElement | null;
displayName: string;
};
interface AddSnackbarArgs extends SnackbarItemValue, Omit<ToastOptions, 'timeout'> {
/**
* Handler that is called when the snackbar is closed, either by the user
* or after a timeout.
*/
onClose?: () => void;
/**
* A timeout to automatically close the snackbar after, in milliseconds.
* @default 5000
*/
timeout?: number | null;
/**
* The priority of the snackbar relative to other snackbars. Larger numbers indicate higher priority.
*/
priority?: number;
}
declare const addSnackbar: ({ onClose, timeout, priority, ...content }: AddSnackbarArgs) => void;
type SnackbarItemActionProps = Omit<ButtonProps, 'size' | 'shape' | 'intent'> & SnackbarItemVariantProps & {
ref?: Ref<HTMLButtonElement>;
};
declare const SnackbarItemAction: {
({ design: designProp, intent: intentProp, onClick, children, className, ref, ...rest }: SnackbarItemActionProps): react_jsx_runtime.JSX.Element;
displayName: string;
};
interface SnackbarItemCloseProps extends Omit<ComponentPropsWithRef<'button'>, 'aria-label' | 'disabled'>, Pick<IconButtonProps, 'aria-label'>, SnackbarItemVariantProps {
}
declare const SnackbarItemClose: {
({ design: designProp, intent: intentProp, "aria-label": ariaLabel, onClick, className, ref, ...rest }: SnackbarItemCloseProps): react_jsx_runtime.JSX.Element;
displayName: string;
};
type SnackbarItemIconProps = IconProps;
declare const SnackbarItemIcon: {
({ children, className, ...rest }: SnackbarItemIconProps): ReactElement;
displayName: string;
};
declare const Snackbar: typeof Snackbar$1 & {
Item: typeof SnackbarItem;
ItemAction: typeof SnackbarItemAction;
ItemClose: typeof SnackbarItemClose;
ItemIcon: typeof SnackbarItemIcon;
};
export { type AddSnackbarArgs, Snackbar, type SnackbarItemActionProps, type SnackbarItemCloseProps, type SnackbarItemIconProps, type SnackbarItemProps, type SnackbarProps, addSnackbar, clearSnackbarQueue };