npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@xme-react/dialog

v1.0.4

Published

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

Readme

弹出框 / Dialog

Dialog(弹出框)

| 参数 | 类型 | 备注 | | :-------- | --------:| :------: | | visible | Boolean | 是否显示 | | closable | Boolean | 是否有关闭按钮,默认true | | globalScroll | Boolean | 默认需要自己设置容器的高度,在容器内部滚动,设置为true后,当content的高度超出页面时,会全局滚动,默认false | | maskClosable | Boolean | 是否可以点击非内容区域关闭弹窗,默认true | | onClose | Function | 点击关闭的回调 |

Dialog.Modal(对话框)

参数

| 参数 | 类型 | 备注 | | :-------- | --------:| :------: | | visible | Boolean | 是否显示 | | closable | Boolean | 是否有关闭按钮,默认true | | globalScroll | Boolean | 默认需要自己设置容器的高度,在容器内部滚动,设置为true后,当content的高度超出页面时,会全局滚动,默认false | | maskClosable | Boolean | 是否可以点击非内容区域关闭弹窗,默认true | | confirmText | String | 确定按钮的文案,默认确定 | | cancelText | String | 取消按钮的文案,默认取消 | | title | String|ReactNode | 对话框的标题,如果为空,则不显示 | | content | String|ReactNode | 要展示的内容 | | footer | Boolean|String|ReactNode | 是否显示底部操作区域,默认true 可以传入ReactNode自定义底部 | | confirmLoading | Boolean | 点击确认按钮时,是否显示loading状态,默认false | | onConfirm | Function | 点击确定的回调 | | onCancel | Function | 点击取消的回调 | | onClose | Function | 点击关闭的回调 |

方法

| 方法 | 类型 | 备注 | | :-------- | --------:| :------: | | show | Function | 显示Modal,返回一个函数,调用此函数直接关闭Modal |

Dialog.Notification(通知提醒框)

| 参数 | 类型 | 备注 | | :-------- | --------:| :------: | | body必填 | String | 要显示的提醒框的内容 | | icon | String | 要显示的提醒框的icon,必须是一个icon的url地址 | | iconfont | String | 要显示的提醒框的icon,可以传入iconfont的class来显示,比如iconfont icon-close,优先级比icon高 | | title | String | 提醒框的title | | duration | Number | duration秒后消失,如果设置为0,则永久显示,默认4000 | | onClose | Function | 关闭时的回调 | | onClick | Function | 点击提醒框的回调 | | tag | String | 提醒框的唯一标示,如果传的tag与正在显示的提醒框一致,则会替换当前正在显示的提醒框的内容,duration重新计算 |

方法

| 方法 | 类型 | 备注 | | :-------- | --------:| :------: | | show | Function | 显示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)