@yamada-ui/react
Version:
React UI components of the Yamada, by the Yamada, for the Yamada built with React and Emotion
77 lines (76 loc) • 2.32 kB
TypeScript
import { SimpleDirection, SnacksConfig } from "../../core/system/index.types.js";
import "../../core/index.js";
import { AlertDescriptionProps, AlertIconProps, AlertLoadingProps, AlertRootProps, AlertTitleProps } from "../alert/alert.js";
import { SnackCloseButtonProps, SnackContentProps } from "./snacks.js";
import "../../index.js";
import { ReactNode } from "react";
//#region src/components/snacks/use-snacks.d.ts
interface Snack extends Omit<UseSnacksOptions, "direction" | "limit" | "startIndex"> {
id: string;
onClose: () => void;
onCloseComplete?: () => void;
}
interface SnackMethodsOptions extends Partial<Omit<Snack, "onClose">> {}
interface UseSnacksOptions extends Omit<AlertRootProps, "direction" | "title">, Pick<AlertLoadingProps, "loadingScheme">, SnacksConfig {
/**
* The description of the snack.
*/
description?: ReactNode;
/**
* The title of the snack.
*/
title?: ReactNode;
/**
* If `true`, the snack will have an icon.
*
* @default true
*/
withIcon?: boolean;
/**
* Props for the snack close button.
*/
closeButtonProps?: SnackCloseButtonProps;
/**
* Props for the snack content component.
*/
contentProps?: SnackContentProps;
/**
* Props for the alert description component.
*/
descriptionProps?: AlertDescriptionProps;
/**
* Props for the alert icon component.
*/
iconProps?: AlertIconProps;
/**
* Props for the alert loading component.
*/
loadingProps?: AlertLoadingProps;
/**
* Props for the alert title component.
*/
titleProps?: AlertTitleProps;
}
/**
* `useSnacks` is a custom hook for controlling notifications used in forms and the like.
*
* @see https://yamada-ui.com/docs/hooks/use-snacks
*/
declare const useSnacks: (options?: UseSnacksOptions) => {
snack: {
(options?: SnackMethodsOptions): string;
update(id: number | string, options: Omit<SnackMethodsOptions, "id">): void;
closeAll(): void;
close(id: number | string): void;
isActive(id: number | string): boolean;
};
snacks: {
direction: SimpleDirection | undefined;
items: Snack[];
startIndex: number | undefined;
};
};
type UseSnacksReturn = ReturnType<typeof useSnacks>;
//#endregion
export { UseSnacksOptions, UseSnacksReturn, useSnacks };
//# sourceMappingURL=use-snacks.d.ts.map