import * as React from "react"; export type IProps = {} export type IModal = { readonly names: ModalNames readonly type: ModalType readonly btnDirection: ModalBtnDirection readonly btnType: ModalBtnType /** * 初始化 */ readonly init: (params: ModalInitParams[]) => void /** * 是否打开 */ readonly has: () => boolean /** * alert 弹出框 */ readonly alert: (content: string | React.ReactNode, params?: ModalParams) => void /** * confirm 弹出框 */ readonly confirm: (content: string | React.ReactNode, params?: ModalParams) => void /** * password 弹出框 */ readonly password: (params?: ModalPasswordParams) => void /** * 显示 */ readonly show: (name: ModalNamesData, params?: ModalParams) => void /** * 隐藏 */ readonly hide: (callback?: () => void) => void /** * 是否是确定 */ readonly isSure: (params: ModalBtnParams) => boolean /** * 是否是取消 */ readonly isCancel: (params: ModalBtnParams) => boolean /** * 是否是其他 */ readonly isOther: (params: ModalBtnParams) => boolean } /** * 初始化参数 */ export type ModalInitParams = { // 展示形式 type: ModalTypeData name: ModalNamesData btnDirection?: ModalBtnDirectionData btnList?: ModalBtnParams[] // 间隙(仅在 type = bottom 有用) space?: number } export type ModalParams = { type?: ModalTypeData callback?: (params: ModalBtnResultParams) => void title?: string | React.ReactNode content?: string | React.ReactNode btn?: ModalBtnParams[] } export type ModalPasswordParams = ModalParams & { password: string hasTouchID?: boolean touchIDTips?: string touchIDHref?: string } /** * 按钮返回数据 */ export type ModalBtnResultParams = { // 按钮类型 readonly type: ModalBtnTypeData // 类型名称 readonly name: ModalNamesData // 有正确的密码 hasCorrPassword?: boolean } /** * emitter 传递参数 */ export type ModalEmitterParams = { display: boolean type: ModalTypeData // 间隙(仅在 type = bottom 有用) space?: number title?: string | React.ReactNode content?: string | React.ReactNode btn?: string | React.ReactNode } /** * 按钮参数 */ export type ModalBtnParams = { type: ModalBtnTypeData text?: string callback?: (res: ModalBtnResultParams) => void } /** * 展示形式 */ export type ModalType = { // 默认 readonly default: 'default' // 底部 readonly bottom: 'bottom' } export type ModalTypeData = 'default' | 'bottom'; /** * modal 类型名称 */ export type ModalNames = { readonly alert: 'alert' readonly confirm: 'confirm' readonly password: 'password' // 其他自定义 readonly other: 'other' } export type ModalNamesData = 'alert' | 'confirm' | 'password' | 'other'; /** * 按钮方向 */ export type ModalBtnDirection = { readonly row: 'row' readonly col: 'col' } export type ModalBtnDirectionData = 'row' | 'col' /** * 按钮类型 */ export type ModalBtnType = { readonly sure: 'sure' readonly cancel: 'cancel' readonly other: 'other' } export type ModalBtnTypeData = 'sure' | 'cancel' | 'other'