UNPKG

@wordpress/notices

Version:
8 lines (7 loc) 1.8 kB
{ "version": 3, "sources": ["../../../src/components/snackbar-notices/index.tsx"], "sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { SnackbarList } from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as noticesStore } from '../../store';\n\n// Last three notices. Slices from the tail end of the list.\nconst MAX_VISIBLE_NOTICES = -3;\n\ntype SnackbarNoticesProps = {\n\tclassName?: string;\n\tcontext?: string;\n};\n\nexport default function SnackbarNotices( {\n\tclassName,\n\tcontext,\n}: SnackbarNoticesProps ) {\n\tconst notices = useSelect(\n\t\t( select ) => select( noticesStore ).getNotices( context ),\n\t\t[ context ]\n\t);\n\tconst { removeNotice } = useDispatch( noticesStore );\n\tconst snackbarNotices = notices\n\t\t.filter( ( { type } ) => type === 'snackbar' )\n\t\t.slice( MAX_VISIBLE_NOTICES );\n\n\treturn (\n\t\t<SnackbarList\n\t\t\tnotices={ snackbarNotices }\n\t\t\tclassName={ clsx( 'components-notices__snackbar', className ) }\n\t\t\tonRemove={ ( id ) => removeNotice( id, context ) }\n\t\t/>\n\t);\n}\n"], "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAKjB,wBAA6B;AAC7B,kBAAuC;AAKvC,mBAAsC;AAwBpC;AArBF,IAAM,sBAAsB;AAOb,SAAR,gBAAkC;AAAA,EACxC;AAAA,EACA;AACD,GAA0B;AACzB,QAAM,cAAU;AAAA,IACf,CAAE,WAAY,OAAQ,aAAAA,KAAa,EAAE,WAAY,OAAQ;AAAA,IACzD,CAAE,OAAQ;AAAA,EACX;AACA,QAAM,EAAE,aAAa,QAAI,yBAAa,aAAAA,KAAa;AACnD,QAAM,kBAAkB,QACtB,OAAQ,CAAE,EAAE,KAAK,MAAO,SAAS,UAAW,EAC5C,MAAO,mBAAoB;AAE7B,SACC;AAAA,IAAC;AAAA;AAAA,MACA,SAAU;AAAA,MACV,eAAY,YAAAC,SAAM,gCAAgC,SAAU;AAAA,MAC5D,UAAW,CAAE,OAAQ,aAAc,IAAI,OAAQ;AAAA;AAAA,EAChD;AAEF;", "names": ["noticesStore", "clsx"] }