{"name":"@rc-component/notification","version":"2.0.9","keywords":["react","react-component","react-notification","notification"],"license":"MIT","_id":"@rc-component/notification@2.0.9","maintainers":[{"name":"zombiej","email":"smith3816@gmail.com"},{"name":"afc163","email":"afc163@gmail.com"},{"name":"madccc","email":"1075746765@qq.com"},{"name":"peachscript","email":"scdzwyxst@gmail.com"},{"name":"chenshuai2144","email":"wasd2144@hotmail.com"}],"homepage":"https://react-component.github.io/notification","bugs":{"url":"https://github.com/react-component/notification/issues"},"dist":{"shasum":"d47af1804824723f73964950b8fc589dc26ddd3f","tarball":"http://registry-npm.ywwl.com/@rc-component/notification/download/@rc-component/notification-2.0.9.tgz","fileCount":59,"integrity":"sha512-jQT5IVSWSHPTNFXQM2YQONPptjiKXZa4A4Kzwh2xkh3MkL31gRzyjb98N3QHBzLxsyGGJK1aNpn9j9aSO/O0dg==","signatures":[{"sig":"MEQCIB2pYvWekduePe4zDMV+DmVwW9plQSiuobaXmeZF8v59AiBdanc71TYVO/KUitNAytfpMlefA7Hs2CEgFCoOFi0dYQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"sig":"MEYCIQC5b3tWRf3pOZQ2KPEaqlpVsfz/ZdIQrsjHm27b6ZTjNAIhAMSKMjveKf11SIqBboddFfpiQ+bo7r0SlSZGDeYBO3GB","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":138549,"size":21749,"noattachment":false,"key":"/@rc-component/notification/-/@rc-component/notification-2.0.9.tgz"},"main":"lib/index","types":"./es/index.d.ts","module":"es/index","engines":{"node":">=8.x"},"gitHead":"7ef71d9757a0a2a7a7459edbcdce0e231851fd79","scripts":{"tsc":"tsc --noEmit","lint":"eslint src/ docs/examples/ --ext .tsx,.ts,.jsx,.js","test":"vitest --watch=false","build":"npm run docs:build","start":"dumi dev","compile":"father build && lessc assets/index.less assets/index.css","prepare":"husky","coverage":"vitest run --coverage","gh-pages":"cross-env GH_PAGES=1 npm run docs:build && npm run docs:deploy","prettier":"prettier --write --ignore-unknown .","docs:build":"dumi build","test:watch":"vitest","docs:deploy":"gh-pages -d docs-dist","prepublishOnly":"npm run compile && rc-np"},"_npmUser":{"name":"zombiej","email":"smith3816@gmail.com"},"repository":{"url":"git+https://github.com/react-component/notification.git","type":"git"},"_npmVersion":"11.19.1","description":"notification ui component for react","directories":{},"lint-staged":{"*":"prettier --write --ignore-unknown"},"_nodeVersion":"26.9.0","dependencies":{"clsx":"^2.1.1","@rc-component/util":"^1.13.0","@rc-component/motion":"^1.1.4"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"dumi":"^2.4.38","less":"^4.6.7","husky":"^9.1.7","jsdom":"^29.1.1","react":"^19.2.7","eslint":"^10.6.0","father":"^4.6.24","vitest":"^4.1.9","globals":"^17.7.0","gh-pages":"^6.3.0","prettier":"^3.9.4","cross-env":"^10.1.0","react-dom":"^19.2.7","@eslint/js":"^10.0.1","typescript":"^6.0.3","@types/node":"^26.0.1","lint-staged":"^17.0.8","@types/react":"^19.2.17","@eslint/compat":"^2.1.0","@rc-component/np":"^1.0.4","@types/react-dom":"^19.2.3","typescript-eslint":"^8.62.1","eslint-plugin-jest":"^29.15.4","@vitest/coverage-v8":"^4.1.9","eslint-plugin-react":"^7.37.5","@testing-library/dom":"^10.4.1","@testing-library/react":"^16.3.2","eslint-config-prettier":"^10.1.8","@csstools/css-tokenizer":"^4.0.0","@testing-library/jest-dom":"^6.9.1","eslint-plugin-react-hooks":"^7.1.1","@rc-component/father-plugin":"^2.2.0","@csstools/css-parser-algorithms":"^4.0.0"},"peerDependencies":{"react":">=18.0.0","react-dom":">=18.0.0"},"_npmOperationalInternal":{"tmp":"tmp/notification_2.0.9_1790665312308_0.872378738854495","host":"s3://npm-registry-packages-npm-production"},"readme":"<div align=\"center\">\n  <h1>@rc-component/notification</h1>\n  <p><sub><a href=\"https://ant.design\"><img alt=\"Ant Design\" height=\"14\" src=\"https://gw.alipayobjects.com/zos/rmsportal/KDpgvguMpGfqaHPjicRK.svg\" style=\"vertical-align: -0.125em;\" /></a> Ant Design 生态的一部分。</sub></p>\n  <p>🔔 React 通知组件，支持堆叠、位置、动画和全局调用。</p>\n\n  <p>\n    <a href=\"https://npmjs.org/package/@rc-component/notification\"><img alt=\"NPM version\" src=\"https://img.shields.io/npm/v/@rc-component/notification.svg?style=flat-square\"></a>\n    <a href=\"https://npmjs.org/package/@rc-component/notification\"><img alt=\"npm downloads\" src=\"https://img.shields.io/npm/dm/@rc-component/notification.svg?style=flat-square\"></a>\n    <a href=\"https://github.com/react-component/notification/actions/workflows/react-component-ci.yml\"><img alt=\"build status\" src=\"https://github.com/react-component/notification/actions/workflows/react-component-ci.yml/badge.svg\"></a>\n    <a href=\"https://app.codecov.io/gh/react-component/notification\"><img alt=\"Codecov\" src=\"https://img.shields.io/codecov/c/github/react-component/notification/master.svg?style=flat-square\"></a>\n    <a href=\"https://bundlephobia.com/package/@rc-component/notification\"><img alt=\"bundle size\" src=\"https://img.shields.io/bundlephobia/minzip/@rc-component/notification?style=flat-square\"></a>\n    <a href=\"https://github.com/umijs/dumi\"><img alt=\"dumi\" src=\"https://img.shields.io/badge/docs%20by-dumi-blue?style=flat-square\"></a>\n  </p>\n</div>\n\n<p align=\"center\"><a href=\"./README.md\">English</a> | 简体中文</p>\n\n## 特性\n\n- `useNotification` 钩子返回 API 和 React 持有者元素。\n- 具有最大数量限制的顶部、底部、左侧和右侧展示位置。\n- 可关闭通知、持续计时器、进度显示、悬停暂停和堆叠布局。\n- 支持动画自定义、语义化 `classNames` / `styles` 、细节组件覆盖和 Provider 级类。\n- 通知配置、API、列表配置和进度属性的 TypeScript 定义。\n- 被 Ant Design 用作共享的 notification 基础能力。\n\n## 安装\n\n```bash\nnpm install @rc-component/notification\n```\n\n## 使用\n\n```tsx | pure\nimport { useNotification } from '@rc-component/notification';\n\nexport default () => {\n  const [api, holder] = useNotification();\n\n  return (\n    <>\n      {holder}\n      <button\n        type=\"button\"\n        onClick={() => {\n          api.open({\n            key: 'welcome',\n            title: 'Notification',\n            description: 'This notice is rendered by @rc-component/notification.',\n            closable: true,\n          });\n        }}\n      >\n        Open\n      </button>\n    </>\n  );\n};\n```\n\n```tsx | pure\nimport { NotificationProvider, useNotification } from '@rc-component/notification';\n\nconst Demo = () => {\n  const [api, holder] = useNotification({\n    placement: 'topRight',\n    maxCount: 3,\n    showProgress: true,\n    pauseOnHover: true,\n    stack: true,\n  });\n\n  return (\n    <>\n      {holder}\n      <button type=\"button\" onClick={() => api.open({ title: 'Queued' })}>\n        Add\n      </button>\n    </>\n  );\n};\n\nexport default () => (\n  <NotificationProvider classNames={{ notice: 'custom-notice' }}>\n    <Demo />\n  </NotificationProvider>\n);\n```\n\n## 示例\n\n运行本地 dumi 站点：\n\n```bash\nnpm install\nnpm start\n```\n\n然后打开 `http://localhost:8000`。\n\n## API\n\n### useNotification\n\n```ts\nconst [api, holder] = useNotification(config);\n```\n\n| 参数                | 类型                                                         | 默认值                | 说明                                               |\n| ------------------- | ------------------------------------------------------------ | --------------------- | -------------------------------------------------- |\n| className           | `(placement: Placement) => string`                           | -                     | 每个放置容器的类名。                               |\n| classNames          | `NotificationClassNames`                                     | -                     | 通知和列表槽的语义类名。                           |\n| closable            | `boolean \\| { closeIcon?: ReactNode; onClose?: () => void }` | -                     | 打开通知的共享可关闭配置。                         |\n| components          | `{ progress?: ComponentType<NotificationProgressProps> }`    | -                     | 组件覆盖。                                         |\n| duration            | `number \\| false \\| null`                                    | `4.5`                 | 自动关闭延迟以秒为单位。使用 `false` 或 `0` 禁用。 |\n| getContainer        | `() => HTMLElement \\| ShadowRoot`                            | `() => document.body` | 通知门户容器。                                     |\n| maxCount            | `number`                                                     | -                     | 保留的最大通知数。最旧的通知被删除。               |\n| motion              | `CSSMotionProps \\| (placement) => CSSMotionProps`            | -                     | 通知过渡动画配置。                                 |\n| pauseOnHover        | `boolean`                                                    | `true`                | 悬停时暂停自动关闭计时器。                         |\n| placement           | `Placement`                                                  | `topRight`            | 打开通知的默认位置。                               |\n| prefixCls           | `string`                                                     | `rc-notification`     | 类名前缀。                                         |\n| renderNotifications | `(node, info) => ReactElement`                               | -                     | 自定义呈现的通知树。                               |\n| showProgress        | `boolean`                                                    | `false`               | 显示打开通知的自动关闭进度。                       |\n| stack               | `boolean \\| StackConfig`                                     | `false`               | 启用堆叠通知布局。                                 |\n| style               | `(placement: Placement) => CSSProperties`                    | -                     | 每个放置容器的内联样式。                           |\n| styles              | `NotificationStyles`                                         | -                     | 通知和列表槽的语义样式。                           |\n| onAllRemoved        | `() => void`                                                 | -                     | 删除所有通知后触发。                               |\n\n### NotificationAPI\n\n| Method    | 类型                                                | 说明               |\n| --------- | --------------------------------------------------- | ------------------ |\n| `open`    | `(config: Partial<NotificationListConfig>) => void` | 打开或更新通知。   |\n| `close`   | `(key: React.Key) => void`                          | 通过按键关闭通知。 |\n| `destroy` | `() => void`                                        | 删除所有通知。     |\n\n### NotificationListConfig\n\n| 参数         | 类型                                                         | 默认值     | 说明                                        |\n| ------------ | ------------------------------------------------------------ | ---------- | ------------------------------------------- |\n| actions      | `ReactNode`                                                  | -          | 额外的动作内容。                            |\n| className    | `string`                                                     | -          | 通知的类名。                                |\n| classNames   | `NotificationClassNames`                                     | -          | 通知槽的语义类名。                          |\n| closable     | `boolean \\| { closeIcon?: ReactNode; onClose?: () => void }` | -          | 是否可以关闭通知。                          |\n| components   | `{ progress?: ComponentType<NotificationProgressProps> }`    | -          | 组件覆盖此通知。                            |\n| description  | `ReactNode`                                                  | -          | 注意说明内容。                              |\n| duration     | `number \\| false \\| null`                                    | `4.5`      | 自动关闭延迟以秒为单位。                    |\n| icon         | `ReactNode`                                                  | -          | 通知图标。                                  |\n| key          | `React.Key`                                                  | -          | 独特的通知键。使用相同的密钥打开会更新它。  |\n| offset       | `number`                                                     | -          | 堆叠定位使用的偏移量。                      |\n| pauseOnHover | `boolean`                                                    | `true`     | 悬停时暂停此通知。                          |\n| placement    | `Placement`                                                  | `topRight` | 通知位置。                                  |\n| props        | `HTMLAttributes<HTMLDivElement> & Record<string, any>`       | -          | 额外的 props 传递到通知根。                 |\n| role         | `string`                                                     | -          | ARIA 的作用为通知。                         |\n| showProgress | `boolean`                                                    | `false`    | 显示自动关闭进度。                          |\n| style        | `CSSProperties`                                              | -          | 通知的内联样式。                            |\n| styles       | `NotificationStyles`                                         | -          | 通知槽的语义样式。                          |\n| title        | `ReactNode`                                                  | -          | 注意标题内容。                              |\n| onClick      | `MouseEventHandler<HTMLDivElement>`                          | -          | 单击通知时触发。                            |\n| onClose      | `() => void`                                                 | -          | 通知关闭时触发。更喜欢 `closable.onClose`。 |\n| onMouseEnter | `MouseEventHandler<HTMLDivElement>`                          | -          | 当鼠标进入通知时触发。                      |\n| onMouseLeave | `MouseEventHandler<HTMLDivElement>`                          | -          | 当鼠标离开通知时触发。                      |\n\n### Types\n\n```ts\ntype Placement = 'top' | 'topLeft' | 'topRight' | 'bottom' | 'bottomLeft' | 'bottomRight';\n\ninterface StackConfig {\n  threshold?: number;\n  offset?: number;\n}\n```\n\n## 本地开发\n\n```bash\nnpm install\nnpm start\nnpm test\nnpm run tsc\nnpm run coverage\nnpm run compile\nnpm run build\n```\n\ndumi 站点默认运行在 `http://localhost:8000`。\n\n## 发布\n\n```bash\nnpm run prepublishOnly\n```\n\n包构建完成后，发布流程由 `@rc-component/np` 通过 `rc-np` 命令处理。\n\n## 许可证\n\n@rc-component/notification 基于 [MIT](./LICENSE) 许可证发布。\n","publish_time":1790665312450,"_cnpm_publish_time":1790665312450,"dist-tags":{"latest":"2.1.1"}}