New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@xme-react/dialog

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@xme-react/dialog

弹窗层(包含提醒框,对话框)

latest
npmnpm
Version
1.0.4
Version published
Maintainers
1
Created
Source

弹出框 / Dialog

Dialog(弹出框)

参数类型备注
visibleBoolean是否显示
closableBoolean是否有关闭按钮,默认true
globalScrollBoolean默认需要自己设置容器的高度,在容器内部滚动,设置为true后,当content的高度超出页面时,会全局滚动,默认false
maskClosableBoolean是否可以点击非内容区域关闭弹窗,默认true
onCloseFunction点击关闭的回调

Dialog.Modal(对话框)

参数
参数类型备注
visibleBoolean是否显示
closableBoolean是否有关闭按钮,默认true
globalScrollBoolean默认需要自己设置容器的高度,在容器内部滚动,设置为true后,当content的高度超出页面时,会全局滚动,默认false
maskClosableBoolean是否可以点击非内容区域关闭弹窗,默认true
confirmTextString确定按钮的文案,默认确定
cancelTextString取消按钮的文案,默认取消
titleStringReactNode
contentStringReactNode
footerBooleanString
confirmLoadingBoolean点击确认按钮时,是否显示loading状态,默认false
onConfirmFunction点击确定的回调
onCancelFunction点击取消的回调
onCloseFunction点击关闭的回调
方法
方法类型备注
showFunction显示Modal,返回一个函数,调用此函数直接关闭Modal

Dialog.Notification(通知提醒框)

参数类型备注
body必填String要显示的提醒框的内容
iconString要显示的提醒框的icon,必须是一个icon的url地址
iconfontString要显示的提醒框的icon,可以传入iconfont的class来显示,比如iconfont icon-close,优先级比icon
titleString提醒框的title
durationNumberduration秒后消失,如果设置为0,则永久显示,默认4000
onCloseFunction关闭时的回调
onClickFunction点击提醒框的回调
tagString提醒框的唯一标示,如果传的tag与正在显示的提醒框一致,则会替换当前正在显示的提醒框的内容,duration重新计算
方法
方法类型备注
showFunction显示Notification,返回一个对象,包含close方法,可以调用close函数手动关闭提醒框
import React, {Component} from 'react'
import ReactDOM from 'react-dom'
import Button from '@xm/Button'
import {Modal, Notification} from '@xm/Dialog'
import styles from './components/index.scss'

let i = 0

class App extends Component {
  constructor (props) {
    super(props)

    this.state = {
      visible: false
    }

    this.modalButtonClickHandler = this.modalButtonClickHandler.bind(this)
    this.firstModalConfirmHandler = this.firstModalConfirmHandler.bind(this)
    this.firstModalCancelHandler = this.firstModalCancelHandler.bind(this)
    this.showAnotherModalByFunction = this.showAnotherModalByFunction.bind(this)

    this.notificationButtonClickHandler = this.notificationButtonClickHandler.bind(this)
  }

  showAnotherModalByFunction () {
    const close = Modal.show({
      style: {
        top: '200px',
        width: '600px'
      },
      title: '另一个modal',
      closable: true,
      // maskClosable: true,
      globalScroll: true,
      content: <div style={{height: '1000px'}}>另一个Modal的内容</div>,
      footer: true,
      confirmText: '关闭第一个Modal',
      cancelText: '关闭',
      onConfirm: () => {
        this.firstModalCancelHandler()
      },
      onCancel: () => {
        close()
      }
    })
  }

  modalButtonClickHandler () {
    this.setState({
      visible: true
    })
  }

  firstModalConfirmHandler () {
    this.showAnotherModalByFunction()
  }

  firstModalCancelHandler () {
    this.setState({
      visible: false
    })
  }

  notificationButtonClickHandler () {
    const n = Notification.show({
      title: `title${i++}`,
      body: `body${i++}`,
      duration: 3000,
      tag: Math.floor(Math.random() * 10),
      iconfont: `${styles.iconfont} ${styles['icon-close']}`,
      icon: 'https://gss2.bdstatic.com/-fo3dSag_xI4khGkpoWK1HF6hhy/baike/whfpf%3D72%2C72%2C0/sign=489ae0bbdb09b3deebeab728aa825bb3/2cf5e0fe9925bc3142b4464b54df8db1ca137073.jpg',
      onClose: (data) => {
        console.log(data)
      },
      onClick: (data) => {
        console.log(data)
      }
    })

  }

  render () {
    const {visible} = this.state

    return (<div>
      <Button onClick={this.modalButtonClickHandler}>显示Modal</Button>
      <Button
        onClick={this.notificationButtonClickHandler}>显示Notification</Button>
      <Modal visible={visible} title="标题" footer closable maskClosable
             confirmText="打开一个新的Modal" onClose={this.firstModalCancelHandler}
             onConfirm={this.firstModalConfirmHandler}
             onCancel={this.firstModalCancelHandler}>
        <div>这是内容</div>
      </Modal>
    </div>)
  }
}

ReactDOM.render(<App />, document.body)

FAQs

Package last updated on 21 Mar 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts