{"name":"@snackstack/core","version":"0.0.0-experimental-daf338c19","description":"To install the latest stable version with [npm](https://www.npmjs.com/get-npm), run the following command:","homepage":"https://github.com/snackstack/core#readme","license":"MIT","author":{"name":"Tobias Tengler","email":"contact.tobiastengler@gmail.com","url":"https://github.com/tobias-tengler"},"repository":{"type":"git","url":"git+https://github.com/snackstack/core.git"},"bugs":{"url":"https://github.com/snackstack/core/issues"},"keywords":["notifications","toast","snackbar","snackstack","react","reactjs","javascript","typescript"],"main":"dist/index.js","module":"dist/core.esm.js","typings":"dist/index.d.ts","engines":{"node":">=10"},"scripts":{"start":"tsdx watch","build":"tsdx build","test":"tsdx test --passWithNoTests","lint":"tsdx lint","size":"size-limit","analyze":"size-limit --why"},"dependencies":{"resize-observer-polyfill":"^1.5.1","use-sync-external-store":"^1.2.0"},"peerDependencies":{"react":"^16.8.0 || ^17.0.0 || ^18.0.0"},"devDependencies":{"@size-limit/preset-small-lib":"^7.0.8","@types/react":"^18.0.15","@types/use-sync-external-store":"^0.0.3","husky":"^8.0.1","react":"^18.2.0","size-limit":"^7.0.8","tsdx":"^0.14.1","tslib":"^2.4.0","typescript":"^4.7.4"},"husky":{"hooks":{"pre-commit":"tsdx lint"}},"size-limit":[{"path":"dist/core.cjs.production.min.js","limit":"10 KB"},{"path":"dist/core.esm.js","limit":"10 KB"}],"readmeFilename":"README.md","readme":"<h1 align=\"center\" style=\"font-size: 30px;\">@snackstack/core</h1>\n<p align=\"center\">Component / state management library agnostic way to manage notifications</a></p>\n\n<p align=\"center\">\n  <a href=\"https://www.npmjs.com/package/@snackstack/core\" alt=\"npm.js package link\">\n    <img src=\"https://img.shields.io/npm/v/@snackstack/core?color=F50057\" alt=\"Latest version published to npm.js\" />\n    <img src=\"https://img.shields.io/npm/dm/@snackstack/core?color=1976D2\" alt=\"npm downloads per month\" />\n    <img src=\"https://img.shields.io/npm/l/@snackstack/core?color=00C853\" alt=\"Project license\" />\n  </a>\n</p>\n\n## Installation\n\nTo install the latest stable version with [npm](https://www.npmjs.com/get-npm), run the following command:\n\n```\nnpm install @snackstack/core\n```\n\nOr if you're using [yarn](https://classic.yarnpkg.com/docs/install/):\n\n```\nyarn add @snackstack/core\n```\n\n## Setup\n\nOnce you have installed snackstack, import the `SnackProvider` and `SnackStack` component, as well as the `SnackManager` class.\n\nInstantiate a new instance of the `SnackManager` class and optionally pass an options object of type `SnackManagerOptions` to its constructor.\n\nNow that the manager is setup, wrap the `SnackProvider` around the parts of your application that should be able to manage and display notifications. The newly created `SnackManager` instance needs to be passed as value to the `manager` property on the provider.\n\nPlace the `SnackStack` component somewhere below the `SnackProvider` and specify a component used to render your notifications.\n\n```diff\nimport React from 'react';\nimport ReactDOM from 'react-dom/client';\n+ import { SnackProvider, SnackStack, SnackManager } from '@snackstack/core';\n\n+ const snackManager = new SnackManager({ maxSnacks: 7 });\n\nconst root = ReactDOM.createRoot(document.getElementById('root') as HTMLElement);\n\nroot.render(\n  <React.StrictMode>\n+   <SnackProvider manager={snackManager}>\n      <App />\n\n+     <SnackStack Component={MyNotification} />\n+   </SnackProvider>\n  </React.StrictMode>\n);\n\n+ const MyNotification = React.forwardRef<unknown, SnackProps>(({ message, offset }) => {\n+   return <div style={{ top: offset }}>{message}</div>;\n+ });\n```\n\nWhile this gives you full creative freedom to design your notification component, you might prefer a pre-built solution:\n\n- [@snackstack/mui](https://github.com/snackstack/mui): Adapter for [Material UI](https://mui.com)\n\n[Learn more about displaying notifications](https://snackstack.github.io/docs/guides/displaying-notifications)\n\n## Managing notifications\n\nOnce setup, notifications can be managed through the `SnackManager`. You can either use the instance you previously instantiated or the `useSnackManager` hook (works only in components rendered below the `SnackProvider`).\n\n```diff\n+ import { useSnackManager } from '@snackstack/core';\n\nfunction App() {\n+ const manager = useSnackManager();\n\n  const handleClick = () => {\n+   manager.enqueue('A notification');\n  };\n\n  return <button onClick={handleClick}>Show notification</button>;\n}\n```\n\n[Learn more about managing notifications](https://snackstack.github.io/docs/guides/managing-notifications)\n","licenseText":"MIT License\n\nCopyright (c) 2020 Tobias Tengler\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","_id":"@snackstack/core@0.0.0-experimental-daf338c19","dist":{"shasum":"a8cac28c1e674aa0278e32c2649645f35e16c1c5","integrity":"sha512-amU04qUVWVkXqVPl1suwJQ92gFJFkJnydlMoBeAlk+qKR4Ko7i5vsfX2wkQ8jep/jQc4b2z+B0cCK01jxGRO9A==","tarball":"https://registry.npmjs.org/@snackstack/core/-/core-0.0.0-experimental-daf338c19.tgz","fileCount":29,"unpackedSize":85348,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDXo5EnG+K6yBqqDfecPXtZa4sY+g0/pcFFE8qcgr2eGQIhAJwa3BpJAiLUpxtwrbglbtJAXApp0PwetL4wgpMV6zTm"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJizxb6ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmr/FQ/+JhFDs0PuUkNP6h34wc2LGSYnz3VAdlWNQX8X64lzdf5b7/Kf\r\ntMS7wJ/uvAOuCkNNNSIQh7gsNhrZ0qDkOu3g9lupBxRo8G9NHm8i8PJEK/m0\r\nL4SVatjixJeJkwrMCTFM9YTn5X9qwwSmVcYYBGE4/cp5OyodkSgw092mG8Uc\r\niCy2CUJNnnPP4yfr/FFDbNgVdwUoPnFIszhw0dgDq6mVIMOemu/3aBWpDGeO\r\nFBdmWSzM4l9V8plfsIEMSOFOkIX0gqkIjuFs5PhZjyFTa5Zx9Qzf+5XQdUCx\r\n9oQy4DLW5ZI5KA9+PbRsqlsaNQcCgUIfNrpCNoVs1rkq1d0+62Y3N6qJAjAq\r\ncNiXw6Vo/c5/nSlX9L4esnRQw4/0K1MUZNUTSlmdSaV6gAz9Kh3m++k0uPCT\r\nCSUKYZqdVggkTs4IPCKtkju0ptylN/Y0RWrknoPsmX1SKZ6bSqdEWOSyiolk\r\n+jXWP2VpHsec4bBlRK9C+Ooew5S9vpG+re4Py9K6KGYtEl6Dwm4tSzBm7g8v\r\nbd5erncbAe7py8QjspDTZamL6kCBQ31+PJ6zBCFWHhUeYH4sPGiQ3dI4fNUj\r\nsKVCDSHe+cD94Mdzh6ZSXB+GHFqh3BADCyWDwbiNT42n61xvVzuO1xupEfUM\r\nBPrTvCbwV807hoB2JbiSaso9+UxfDJ+NLPg=\r\n=9jlD\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"tobiastengler","email":"contact.tobiastengler@gmail.com"},"directories":{},"maintainers":[{"name":"tobiastengler","email":"contact.tobiastengler@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/core_0.0.0-experimental-daf338c19_1657739002214_0.043226940243996426"},"_hasShrinkwrap":false}