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

@rc-component/notification

v2.0.8

Published

notification ui component for react

Readme

特性

  • useNotification 钩子返回 API 和 React 持有者元素。
  • 具有最大数量限制的顶部、底部、左侧和右侧展示位置。
  • 可关闭通知、持续计时器、进度显示、悬停暂停和堆叠布局。
  • 支持动画自定义、语义化 classNames / styles 、细节组件覆盖和 Provider 级类。
  • 通知配置、API、列表配置和进度属性的 TypeScript 定义。
  • 被 Ant Design 用作共享的 notification 基础能力。

安装

npm install @rc-component/notification

使用

import { useNotification } from '@rc-component/notification';

export default () => {
  const [api, holder] = useNotification();

  return (
    <>
      {holder}
      <button
        type="button"
        onClick={() => {
          api.open({
            key: 'welcome',
            title: 'Notification',
            description: 'This notice is rendered by @rc-component/notification.',
            closable: true,
          });
        }}
      >
        Open
      </button>
    </>
  );
};
import { NotificationProvider, useNotification } from '@rc-component/notification';

const Demo = () => {
  const [api, holder] = useNotification({
    placement: 'topRight',
    maxCount: 3,
    showProgress: true,
    pauseOnHover: true,
    stack: true,
  });

  return (
    <>
      {holder}
      <button type="button" onClick={() => api.open({ title: 'Queued' })}>
        Add
      </button>
    </>
  );
};

export default () => (
  <NotificationProvider classNames={{ notice: 'custom-notice' }}>
    <Demo />
  </NotificationProvider>
);

示例

运行本地 dumi 站点:

npm install
npm start

然后打开 http://localhost:8000

API

useNotification

const [api, holder] = useNotification(config);

| 参数 | 类型 | 默认值 | 说明 | | ------------------- | ------------------------------------------------------------ | --------------------- | -------------------------------------------------- | | className | (placement: Placement) => string | - | 每个放置容器的类名。 | | classNames | NotificationClassNames | - | 通知和列表槽的语义类名。 | | closable | boolean \| { closeIcon?: ReactNode; onClose?: () => void } | - | 打开通知的共享可关闭配置。 | | components | { progress?: ComponentType<NotificationProgressProps> } | - | 组件覆盖。 | | duration | number \| false \| null | 4.5 | 自动关闭延迟以秒为单位。使用 false0 禁用。 | | getContainer | () => HTMLElement \| ShadowRoot | () => document.body | 通知门户容器。 | | maxCount | number | - | 保留的最大通知数。最旧的通知被删除。 | | motion | CSSMotionProps \| (placement) => CSSMotionProps | - | 通知过渡动画配置。 | | pauseOnHover | boolean | true | 悬停时暂停自动关闭计时器。 | | placement | Placement | topRight | 打开通知的默认位置。 | | prefixCls | string | rc-notification | 类名前缀。 | | renderNotifications | (node, info) => ReactElement | - | 自定义呈现的通知树。 | | showProgress | boolean | false | 显示打开通知的自动关闭进度。 | | stack | boolean \| StackConfig | false | 启用堆叠通知布局。 | | style | (placement: Placement) => CSSProperties | - | 每个放置容器的内联样式。 | | styles | NotificationStyles | - | 通知和列表槽的语义样式。 | | onAllRemoved | () => void | - | 删除所有通知后触发。 |

NotificationAPI

| Method | 类型 | 说明 | | --------- | --------------------------------------------------- | ------------------ | | open | (config: Partial<NotificationListConfig>) => void | 打开或更新通知。 | | close | (key: React.Key) => void | 通过按键关闭通知。 | | destroy | () => void | 删除所有通知。 |

NotificationListConfig

| 参数 | 类型 | 默认值 | 说明 | | ------------ | ------------------------------------------------------------ | ---------- | ------------------------------------------- | | actions | ReactNode | - | 额外的动作内容。 | | className | string | - | 通知的类名。 | | classNames | NotificationClassNames | - | 通知槽的语义类名。 | | closable | boolean \| { closeIcon?: ReactNode; onClose?: () => void } | - | 是否可以关闭通知。 | | components | { progress?: ComponentType<NotificationProgressProps> } | - | 组件覆盖此通知。 | | description | ReactNode | - | 注意说明内容。 | | duration | number \| false \| null | 4.5 | 自动关闭延迟以秒为单位。 | | icon | ReactNode | - | 通知图标。 | | key | React.Key | - | 独特的通知键。使用相同的密钥打开会更新它。 | | offset | number | - | 堆叠定位使用的偏移量。 | | pauseOnHover | boolean | true | 悬停时暂停此通知。 | | placement | Placement | topRight | 通知位置。 | | props | HTMLAttributes<HTMLDivElement> & Record<string, any> | - | 额外的 props 传递到通知根。 | | role | string | - | ARIA 的作用为通知。 | | showProgress | boolean | false | 显示自动关闭进度。 | | style | CSSProperties | - | 通知的内联样式。 | | styles | NotificationStyles | - | 通知槽的语义样式。 | | title | ReactNode | - | 注意标题内容。 | | onClick | MouseEventHandler<HTMLDivElement> | - | 单击通知时触发。 | | onClose | () => void | - | 通知关闭时触发。更喜欢 closable.onClose。 | | onMouseEnter | MouseEventHandler<HTMLDivElement> | - | 当鼠标进入通知时触发。 | | onMouseLeave | MouseEventHandler<HTMLDivElement> | - | 当鼠标离开通知时触发。 |

Types

type Placement = 'top' | 'topLeft' | 'topRight' | 'bottom' | 'bottomLeft' | 'bottomRight';

interface StackConfig {
  threshold?: number;
  offset?: number;
}

本地开发

npm install
npm start
npm test
npm run tsc
npm run coverage
npm run compile
npm run build

dumi 站点默认运行在 http://localhost:8000

发布

npm run prepublishOnly

包构建完成后,发布流程由 @rc-component/np 通过 rc-np 命令处理。

许可证

@rc-component/notification 基于 MIT 许可证发布。