UNPKG

@jswork/react-sms-send

Version:

Sms button for react.

96 lines (92 loc) 2.54 kB
import React, { Component, ReactNode, ElementType, HTMLAttributes } from 'react'; import { EventMittNamespace } from '@jswork/event-mitt'; type Status = 'init' | 'loading' | 'done'; type TemplateArgs = { status: Status; count?: number; }; type ReactSmsSendProps = { /** * The unique id for component. */ name?: string; /** * The extended className for component. * @default '' */ className?: string; /** * The children element. */ children?: ReactNode; /** * The element type to render as. */ as?: ElementType; /** * The props for the element type. */ asProps?: any; /** * If the as(button) component is disabled. */ disabled?: boolean; /** * The max count to resend. * @default 30 */ count?: number; /** * The min count to resend. * @default 0 */ min?: number; /** * The template function to render the content. * @param args */ template?: (args: TemplateArgs) => ReactNode; /** * The callback function when status change. * @param args */ onChange?: (args: TemplateArgs) => void; /** * The callback function when before send. * @returns boolean or Promise<boolean> */ onBeforeSend?: () => Promise<boolean> | boolean; } & Omit<HTMLAttributes<HTMLElement>, 'as' | 'children'>; type ReactSmsSendState = TemplateArgs; declare class ReactSmsSend extends Component<ReactSmsSendProps, ReactSmsSendState> { static displayName: string; static version: string; static event: EventMittNamespace.EventMitt; static events: string[]; static defaultProps: { name: string; as: string; count: number; min: number; onBeforeSend: () => boolean; }; private timer; private harmonyEvents; state: ReactSmsSendState; get isDisabled(): boolean | undefined; get template(): React.ReactNode; componentDidMount(): void; componentDidUpdate(prevProps: Readonly<ReactSmsSendProps>, prevState: Readonly<ReactSmsSendState>): void; componentWillUnmount(): void; handleClick: (e: any) => Promise<void>; reset: (callback?: () => void) => void; sending: () => void; resend: () => void; clear: () => void; render(): React.JSX.Element; } declare const useCommand: (inName?: string) => { reset: () => void; resend: () => void; }; export { type Status, type TemplateArgs, ReactSmsSend as default, useCommand };