{"name":"@rc-component/notification","version":"1.2.0","keywords":["react","react-component","react-notification","notification"],"license":"MIT","_id":"@rc-component/notification@1.2.0","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":"http://github.com/react-component/notification","bugs":{"url":"http://github.com/react-component/notification/issues"},"dist":{"shasum":"dd7c7d50f1d3217bfbc75bc46259e212096855c5","tarball":"http://registry-npm.ywwl.com/@rc-component/notification/download/@rc-component/notification-1.2.0.tgz","fileCount":37,"integrity":"sha512-OX3J+zVU7rvoJCikjrfW7qOUp7zlDeFBK2eA3SFbGSkDqo63Sl4Ss8A04kFP+fxHSxMDIS9jYVEZtU1FNCFuBA==","signatures":[{"sig":"MEUCIFf0QRvgkz5safbGxlVp0IaB6gkRc4VVubabBuGYJl2cAiEA5UIwYGMYJ9ICn6m/KX1H+6P8AUT/P31tyiYnBfwbuVo=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":74474,"size":13988,"noattachment":false,"key":"/@rc-component/notification/-/@rc-component/notification-1.2.0.tgz"},"main":"lib/index","module":"es/index","engines":{"node":">=8.x"},"gitHead":"477e95ff0509c98e339d9e9b599189df02279cad","scripts":{"lint":"eslint src/ docs/examples/ --ext .tsx,.ts,.jsx,.js","test":"vitest --watch=false","build":"dumi build","start":"dumi dev","compile":"father build && lessc assets/index.less assets/index.css","prepare":"husky install","coverage":"vitest run --coverage","now-build":"npm run build","test:watch":"vitest","docs:deploy":"gh-pages -d .doc","prepublishOnly":"npm run compile && rc-np"},"typings":"es/index.d.ts","_npmUser":{"name":"zombiej","email":"smith3816@gmail.com"},"repository":{"url":"git+ssh://git@github.com/react-component/notification.git","type":"git"},"_npmVersion":"10.9.2","description":"notification ui component for react","directories":{},"lint-staged":{"**/*.{js,jsx,tsx,ts,md,json}":["prettier --write","git add"]},"_nodeVersion":"22.15.1","dependencies":{"clsx":"^2.1.1","@rc-component/util":"^1.2.1","@rc-component/motion":"^1.1.4"},"_hasShrinkwrap":false,"devDependencies":{"dumi":"^2.1.0","less":"^4.2.0","husky":"^8.0.3","jsdom":"^24.0.0","react":"^18.0.0","eslint":"^7.8.1","father":"^4.0.0","vitest":"^0.34.2","gh-pages":"^3.1.0","prettier":"^3.0.2","react-dom":"^18.0.0","typescript":"^5.4.5","@types/node":"^24.5.2","lint-staged":"^14.0.1","@types/react":"^18.0.0","@umijs/fabric":"^2.0.0","@rc-component/np":"^1.0.3","@types/react-dom":"^18.0.0","@vitest/coverage-v8":"^0.34.2","@testing-library/react":"^15.0.7","@testing-library/jest-dom":"^6.0.0","@typescript-eslint/parser":"^5.59.7","@rc-component/father-plugin":"^2.0.4","@types/testing-library__jest-dom":"^6.0.0","@typescript-eslint/eslint-plugin":"^5.59.7"},"peerDependencies":{"react":">=16.9.0","react-dom":">=16.9.0"},"_npmOperationalInternal":{"tmp":"tmp/notification_1.2.0_1762140631347_0.37014417840859926","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":1762140631544,"_cnpm_publish_time":1762140631544,"dist-tags":{"latest":"2.1.1"}}