{"_id":"@caesium/hook-notifications","_rev":"5-f2ee5276dd0e7f746d50a55540f6df8c","name":"@caesium/hook-notifications","dist-tags":{"latest":"0.1.1"},"versions":{"0.0.0":{"name":"@caesium/hook-notifications","version":"0.0.0","description":"Notifications System for React","main":"lib/hook-notifications.js","scripts":{"test":"jest","prepublishOnly":"tsc"},"keywords":["React","Notifications"],"author":{"name":"Adam Laycock","email":"adam@arcath.net"},"license":"MIT","devDependencies":{"@testing-library/jest-dom":"^5.11.4","@testing-library/react":"^11.0.4","@types/react":"^16.9.49","@types/uuid":"^8.3.0","jest":"^26.4.2","react":"^16.13.1","react-dom":"^16.13.1","ts-jest":"^26.4.0","typescript":"^4.0.3"},"dependencies":{"uuid":"^8.3.0"},"gitHead":"63eaf3cecc4e91f685bd3169c4890e36ccdc99e0","_id":"@caesium/hook-notifications@0.0.0","_nodeVersion":"14.0.0","_npmVersion":"6.14.4","dist":{"integrity":"sha512-KHs76tD9v5GzrzobDGwEfFHXUM4WHLpq3y8HzAGIi5Oe/eF1LoE77wbEkFOGXqoSPOnRHuxX0lzgPzms+X4yhA==","shasum":"33d623f8822edb312ea36205f7c541592f24ebc7","tarball":"https://registry.npmjs.org/@caesium/hook-notifications/-/hook-notifications-0.0.0.tgz","fileCount":7,"unpackedSize":8216,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfbQY2CRA9TVsSAnZWagAA6IYP/RbIhXUbBw+wZnrdZiJU\nC7Rngj8RJXhSdq9GqbSL5LcdhAw/ddM77U5E3Sq+E4eczPbsGRKRAht1Tn0R\nH7Xtr5kPsFMMEhZTonhQkGwD3eWcg9iiVql8rL0g2RBZzknG3QQN2HNZfUUw\nGTK3OOQ5Jgx+0qgHZRMr+jSVwPWrx3CGCJnxKaTYQa6RMmC/pkb5eLEGE2h8\n35tl0Nai3dLijtkI77D8A+yKj2taqw/rK06d9gLP+tFqG0+zg6uPze//WF/k\nXPDnnWmvBQeSxcw/z8AC+wkKq1OvXPE6cxfPCzOP9bxZtJeEOkapEWkdkq2n\n8zJvudXmdOzd2eYTtcsUK/DvsxcRvlZXbWxA4LG67AteGlX30TqxVmlXKq93\nC5C3cs0syyBrnitf0IUaVL0aveYXvVYxdbeop3SPXKJVIfZyiqtMCd8Pm8kT\n0blUEdjWBBR4F0j4OJVtm5kHh+JVgH4iRiKj2YeI9lGViFqdfimlbXU3xlrr\nw7X1jcstLQ82JmtaZJmgDgF9iSAQPfvlKL8hGFX0zYCpwkmyzrFegZvJpe5i\neHy7B/u5+EirjiLKzkVsnaPXTxBEO2ybwhZwNJ0RYw9jJEvzADzOhC7pr/vP\nXZKxcb4FIgMlT7Wx2QEUmhLpCMFG8TQwpGG82ANVESlzcerYE0DGviJkyLrx\ny0Hf\r\n=Pjom\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBju+EsQf1OozDEpkwQkjAaortwtY4lx/bs5ZIPjEcr7AiEA6INciQ4yZ6gk49gLnawBv8YMdXTIIMzoPWXSlx7C1WE="}]},"maintainers":[{"name":"arcath","email":"adam@arcath.net"}],"_npmUser":{"name":"arcath","email":"adam@arcath.net"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/hook-notifications_0.0.0_1600980534222_0.13979538205057374"},"_hasShrinkwrap":false},"0.1.0":{"name":"@caesium/hook-notifications","version":"0.1.0","description":"Notifications System for React","main":"lib/hook-notifications.js","scripts":{"test":"jest","prepublishOnly":"tsc"},"keywords":["React","Notifications"],"author":{"name":"Adam Laycock","email":"adam@arcath.net"},"license":"MIT","devDependencies":{"@testing-library/jest-dom":"^5.11.4","@testing-library/react":"^11.0.4","@types/react":"^16.9.49","@types/uuid":"^8.3.0","jest":"^26.4.2","react":"^16.13.1","react-dom":"^16.13.1","ts-jest":"^26.4.0","typescript":"^4.0.3"},"dependencies":{"uuid":"^8.3.0"},"gitHead":"ac2d92ffbe021319d9e10ae9d4adc6994964efaf","_id":"@caesium/hook-notifications@0.1.0","_nodeVersion":"14.0.0","_npmVersion":"6.14.4","dist":{"integrity":"sha512-Yaaok3yvnyFZf2iPbdGwFgLONCHzVCOEA0AhCUcKuNSuFO4gGZKfrntCFDscPMsxV3mrMn33ZKgh3vEfuCxqbw==","shasum":"e6ffbeb88912cc14c2491da37009c715bace2d67","tarball":"https://registry.npmjs.org/@caesium/hook-notifications/-/hook-notifications-0.1.0.tgz","fileCount":18,"unpackedSize":66732,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfbQgBCRA9TVsSAnZWagAAYWQQAJfkGJMhVSJlp6g3fh0Q\nWajYkAKHDJNR8FyQDWkoeOjF6rSPPTwTR0fnTo1evFoOJUqnUhjoWNGh5hhL\nY+z5lXpQ06Ca4laMrxwj6+L9f3nvg7mAns+o/2GX2hD+92PxdREN9KdquutC\nnrXazncNniqXYAgOofbzNjOz7oMfT0v/jOjcmEeRsPMOYzkBmyqhvPqyiHJI\nS7JD08i3sRYv1NtfVLTZSV4ubFVSGa8DO6DroNKG5IBOXFcgn0hZOfjeEqtq\nfndUH8SE7ZWSWaszU+VcMMzOIJaHLrxXNfh7WvGfYGoXoSdW0/WM4266yzvV\n0VueNeLk+mWENDwNbdzQTFRVFMFXyHJ3ivTigZzVEk585/xwqjFPDjwtFJhO\nkJVSh/TK1uyibYe2+aHK4lpx5m7qWoSb7cEGaDqJU6mUCjkVFQr0wad4exIl\nJxwuaqDG+8pT0E3zjM+5BhDF8YjiOkE6SRsycZ5PgXP9QqmwI5C8VXUxd1SF\n3TameyU/w5I76mWgVtDA5QcADj3/y/rZ/SOWRtnrZBo1Cps+AzSr+CjBgbjN\nDRJiALmlfYCNYylrirQA1/GewNm+2A7elsvFqrvlCwPYhCwZe8efvdUu5pXK\nFXAEVxcMbFtwEDRiaOuw1BC/3qSamNbr3nsmFPDME2vA8FOghd+kqqUrqbBp\n2+bc\r\n=FFxA\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCrBIEh7ZMRbJxTm0kWf1SjSonrqOe7vgRTxE0kBdQSZwIhAKIKW/oIkRFANS11CRDuZiIKn8qlAlUP9P1yJyqKVLJJ"}]},"maintainers":[{"name":"arcath","email":"adam@arcath.net"}],"_npmUser":{"name":"arcath","email":"adam@arcath.net"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/hook-notifications_0.1.0_1600980992835_0.5497805496573944"},"_hasShrinkwrap":false},"0.1.1":{"name":"@caesium/hook-notifications","version":"0.1.1","description":"Notifications System for React","main":"lib/hook-notifications.js","scripts":{"test":"jest","prepublishOnly":"tsc"},"keywords":["React","Notifications"],"author":{"name":"Adam Laycock","email":"adam@arcath.net"},"license":"MIT","devDependencies":{"@testing-library/jest-dom":"^5.11.4","@testing-library/react":"^11.0.4","@types/react":"^16.9.49","@types/uuid":"^8.3.0","jest":"^26.4.2","react":"^16.13.1","react-dom":"^16.13.1","ts-jest":"^26.4.0","typescript":"^4.0.3"},"dependencies":{"uuid":"^8.3.0"},"gitHead":"9d80ac3a9bde127187042cde3bdf9b37a32e3e0a","_id":"@caesium/hook-notifications@0.1.1","_nodeVersion":"14.0.0","_npmVersion":"6.14.4","dist":{"integrity":"sha512-EJjZxRmwjluo3oSUHu5zmBv+As65g9nzZvRCRQP6Ll9z7jyr6P6jaV5oYyPRDALeSVHJ6SbU0ys+0XYvV4rSww==","shasum":"980634dc7e40a645c6e059734907a77b0107a211","tarball":"https://registry.npmjs.org/@caesium/hook-notifications/-/hook-notifications-0.1.1.tgz","fileCount":18,"unpackedSize":66732,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfctfACRA9TVsSAnZWagAAyAAP/jGLC5u61GDmBkFWIx2T\nnZGTWmgkIXklKaVc9mQUX08LVqD2Z1YSGTaUp+OZtiGe3BBn/EMihjAEaeF9\nbgrfScNYRa4copSAArgRP9UyxoXZx8Xj5IxcZHrimrrsFuHEzUv9BOcMesKb\nWuLi2BLzIMplKo0ITSYYO6R4c9zB69YE0cmqGGxC7lK3vqXJmjSbtvaE6A9S\nQSbSLcOwqg35OcMTL7XBaajKjx5OqddrZfDwC5tORhXsJaYU2LSfLRe2hvO9\noFAbkjczF5NCFLfVVu+1sXUOie2cq1YkYqZIRFLZk65wlwbb6FJtRYCBzpSA\nKlBeTq3B4SGeNhUwOu2VikUqEusSGnYKgBRJJF7i2qI762DYb2e3TloeG2Md\nOKNyGY9ZvwhIqaja4d2ATMnMOscIiSmeqiH8maNymY+JdzRc9Zrp/O952a10\nVDbYhppvhw62I60tCETxahA1Ennytcbx9lAnOgglBAgI/AURVXjGRmh1YoCv\nWhVOEd+LyoeFk/aC3JvIKuQKveduxAUS752FWEwU99Nu9GmJltBKofBXSaXs\ni41t5Y2Z44L8yxRkxnLbt6R6ZiKEHrZywKafw4BEPbu5saEhFvf0vYk3CJEa\nFxbGc0VDmABQMKCk0jg0biagEPqvogvprMs4UgGApOf0hwKXx64nlQ2GqryX\nYH2Y\r\n=QtcT\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICKmoEk7hnh+ED6NItzkxsATEy3XnoEEeWSi0+pjYpX2AiEA8do6flCgMuI7WWluY+fkZ1v2qZg2bSWBjsxXBZJWkzI="}]},"maintainers":[{"name":"arcath","email":"adam@arcath.net"}],"_npmUser":{"name":"arcath","email":"adam@arcath.net"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/hook-notifications_0.1.1_1601361856223_0.4109682340875478"},"_hasShrinkwrap":false}},"time":{"created":"2020-09-24T20:48:54.004Z","0.0.0":"2020-09-24T20:48:54.329Z","modified":"2022-04-04T21:30:11.121Z","0.1.0":"2020-09-24T20:56:32.973Z","0.0.1":"2020-09-29T06:40:29.228Z","0.1.1":"2020-09-29T06:44:16.365Z"},"maintainers":[{"name":"arcath","email":"adam@arcath.net"}],"description":"Notifications System for React","keywords":["React","Notifications"],"author":{"name":"Adam Laycock","email":"adam@arcath.net"},"license":"MIT","readme":"# Notifications Hook\r\n\r\n## Install\r\n\r\n```\r\nnpm install --save @caesium/hook-notifications\r\n```\r\n\r\n## Usage\r\n\r\nThere are 3 exported properties that are needed at a minimum `useNotify`, `useNotifications` and `Notifications`.\r\n\r\nAt the top level of your app add `Notifications` as a wrapper around everything. e.g.\r\n\r\n```tsx\r\nimport React from 'react'\r\nimport {Notifications} from '@caesium/hook-notifications'\r\n\r\nexport const App: React.FC = ({children}) => {\r\n  return <Notifications>\r\n    {children}\r\n  </Notifications>\r\n}\r\n```\r\n\r\nIn your notifications component use `useNotifications` to get a list of notifications and the `removeNotification` function to remove them.\r\n\r\n```tsx\r\nimport React from 'react'\r\nimport {useNotifications} from '@caesium/hook-notifications'\r\n\r\nexport const NotificationsComponent: React.FC = () => {\r\n  const {notifications, removeNotification} = useNotifications()\r\n\r\n  return <div>\r\n    {notifications.map((notification) => {\r\n      return <div key={notification.uuid} onClick={() => {\r\n        removeNotification(notification.uuid)\r\n      }}>\r\n        <h6>{notification.title}</h6>\r\n        <p>{notification.message}</p>\r\n      </div>\r\n    })}\r\n  </div>\r\n}\r\n```\r\n\r\nFrom any component that needs to create a notification you use `useNotify` to get the `notify` function.\r\n\r\n```tsx\r\nimport React from 'react'\r\nimport {useNotify} from '@caesium/hook-notifications'\r\n\r\nexport const ButtonPresser: React.FC = () => {\r\n  const {notify} = useNotify()\r\n\r\n  return <div>\r\n    <button onClick={() => {\r\n      notify({\r\n        title: 'Foo',\r\n        message: 'bar'\r\n      })\r\n    }}>Notify Me</button>\r\n  </div>\r\n}\r\n```\r\n\r\nYou can change the type of the notifications by re-exporting the two hooks from another file in your code.\r\n\r\n```ts\r\nimport {useNotify as notify, UseNotifyFunction, useNotifications as notifications, UseNotificationsFunction} from './hook-notifications'\r\n\r\ninterface NewNotification{\r\n  title: string\r\n  message: string\r\n  icon: string\r\n}\r\n\r\ninterface Notification extends NewNotification{\r\n  uuid: string\r\n}\r\n\r\nexport const useNotify: UseNotifyFunction<NewNotification> = () => {\r\n  return notify()\r\n}\r\n\r\nexport const useNotifications: UseNotificationsFunction<Notification> = () => {\r\n  return (notifications() as any)\r\n}\r\n```","readmeFilename":"readme.md"}