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 🙏

© 2024 – Pkg Stats / Ryan Hefner

zent-sweetalert

v1.1.0

Published

Zent快捷弹窗

Downloads

7

Readme

zent-sweetalert

React版的window.alertwindow.confirm.

如果你需要个性化的Dialog请直接使用Dialog,这个包的API不会提供个性化选项。

API

提示对话框

Sweetalert.alert(config: object): function

// 这个别名只为兼容老版本,不要使用!
Sweetalert.info(config) // alias to alert, deprecated!

| 参数 | 说明 | 类型 | 默认值 | 备选值 | |------|------|------|--------|--------| | content | 可选,弹窗中的内容 | node | | | | type | 可选,弹窗的类型,设置会在title左边显示一个小图标,不传不会显示图标 | string | undefined | 'info', 'success', 'error', 'warning' | | title | 可选,弹窗的标题 | node | '' | | | onConfirm | 可选,确认操作回调函数 | func | noop | | | confirmText | 可选,确认按钮文案 | string | '取消' | | | className | 可选,额外的className | string | '' | | | prefix | 可选, 默认className的前缀 | string | 'zent' | |

确认对话框

Sweetalert.confirm(config: object): function

| 参数 | 说明 | 类型 | 默认值 | 备选值 | |------|------|------|--------|--------| | content | 可选,弹窗中的内容 | node | | | | type | 可选,弹窗的类型,设置会在title左边显示一个小图标,不传不会显示图标 | string | undefined | 'info', 'success', 'error', 'warning' | | title | 可选,弹窗的标题 | node | '' | | | onCancel | 可选,取消操作回调函数 | func | 空函数 | | | onConfirm | 可选,确认操作回调函数 | func | 空函数 | | | cancelText | 可选,取消按钮文案 | string | '取消' | | | confirmText | 可选,确认按钮文案 | string | '确认' | | | className | 可选,额外的className | string | '' | | | prefix | 可选,默认className的前缀 | string | 'zent' | |

返回值

alertconfirm的返回值都是用来手动关闭对话框的函数。

关于onConfirm and onCancel

function(close?: func): Promise?

都接受一个可选的参数close,用来关闭对话框。可以返回一个Promise

根据函数参数及返回值的不同,分为几种情况:

  1. callback没传: 点了按钮后直接关闭。
  2. callback,但是callback函数无参数: 调用callback,如果返回值是个Promise,resolve后关闭,否则如果返回值不是false直接关闭,如果返回值是false对话框不关闭。
  3. callback,并且callback接受close参数: 调用callback并将close作为参数传给它,如果返回值是个Promise,resolve后关闭,否则不自动关闭,需要外部自己去调用close

如果返回值是Promise,对应的按钮会在Promise未完成前显示为loading状态。


新版UI规范建议

  • 弹窗包含取消操作的按钮时,右上角的叉号不应显示
  • 重要操作的按钮应该在左侧,而不是右侧