0.1.2 • Published 3 years ago

@five-show/antd-prompt v0.1.2

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

antd-prompt

a simple prompt for ant design

Features

  • Prompt
  • FromModal

Requirement

  • react >= 16.8
  • antd >= 4.0

Install

npm

npm install @five-show/antd-prompt

yarn

yarn add @five-show/antd-prompt

Usage

import { Prompt } from "@five-show/antd-prompt";

component

<Prompt visible={visible} onOk={handleOk} onCancel={handleCancel} {...promptProps} />

function

const value = await Prompt.prompt({
  ...promptProps,
});
await handleOk(value);

or

await Prompt.prompt({
  ...promptProps,
  onOk: handleOk,
});

Example

git clone https://github.com/MorningK/antd-prompt.git
cd antd-prompt
npm install
cd example
npm install
npm run start

Props

propdescriptiontypedefault
visibleWhether the modal dialog is visible or notboolean
titleThe modal dialog's titleReactNode
cancelTextText of the Cancel buttonReactNode
onCancelSpecify a function that will be called when a user clicks mask, close button on top right or Cancel button() => void | Promise
okTextText of the OK buttonReactNode
okButtonPropsThe ok button propsButtonProps
onOkSpecify a function that will be called when a user clicks the OK button(value: T) => void | Promise
addonBeforeThe ReactNode add before FormReactNode
addonAfterThe ReactNode add after FormReactNode
modalPropsThe modal propsModalProps
formPropsThe form propsFromProps
nameThe name of Form.ItemNamePathinput
labelThe label text of Form.ItemReactNode
requiredThe initialValue of Form.Itembooleantrue
initialValueThe initialValue of Form.ItemT
formItemPropsThe props of Form.ItemFormItemProps
childrenThe children of Form.ItemReactNode<Input autoComplete="false" autoFocus allowClear />
export type FormModalProps<T = any> = {
  visible?: boolean;
  title?: React.ReactNode;
  cancelText?: React.ReactNode;
  onCancel?: () => void | Promise<any>;
  okText?: React.ReactNode;
  okButtonProps?: ButtonProps;
  onOk?: (values: T) => void | Promise<any>;
  addonBefore?: React.ReactNode;
  addonAfter?: React.ReactNode;
  children?: React.ReactNode;
  modalProps?: ModalProps;
  formProps?: FormProps;
};
export type PromptProp<T = any> = Omit<FormModalProps, 'onOk' | 'children'> & {
  onOk?: (value: T) => Promise<any>;
  name?: string;
  label?: string;
  required?: boolean;
  initialValue?: T;
  formItemProps?: FormItemProps;
  children?: React.ReactNode;
};
0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

4 years ago

0.0.1

4 years ago