UNPKG

@wordpress/components

Version:
8 lines (7 loc) 2.31 kB
{ "version": 3, "sources": ["../../src/notice/list.tsx"], "sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * Internal dependencies\n */\nimport Notice from '.';\nimport { createElement as _createElement } from \"react\";\nimport { jsxs as _jsxs } from \"react/jsx-runtime\";\nconst noop = () => {};\n\n/**\n * `NoticeList` is a component used to render a collection of notices.\n *\n *```jsx\n * import { Notice, NoticeList } from `@wordpress/components`;\n *\n * const MyNoticeList = () => {\n *\tconst [ notices, setNotices ] = useState( [\n *\t\t{\n *\t\t\tid: 'second-notice',\n *\t\t\tcontent: 'second notice content',\n *\t\t},\n *\t\t{\n *\t\t\tid: 'fist-notice',\n *\t\t\tcontent: 'first notice content',\n *\t\t},\n *\t] );\n *\n *\tconst removeNotice = ( id ) => {\n *\t\tsetNotices( notices.filter( ( notice ) => notice.id !== id ) );\n *\t};\n *\n *\treturn <NoticeList notices={ notices } onRemove={ removeNotice } />;\n *};\n *```\n */\nfunction NoticeList({\n notices,\n onRemove = noop,\n className,\n children\n}) {\n const removeNotice = id => () => onRemove(id);\n className = clsx('components-notice-list', className);\n return /*#__PURE__*/_jsxs(\"div\", {\n className: className,\n children: [children, [...notices].reverse().map(notice => {\n const {\n content,\n ...restNotice\n } = notice;\n return /*#__PURE__*/_createElement(Notice, {\n ...restNotice,\n key: notice.id,\n onRemove: removeNotice(notice.id)\n }, notice.content);\n })]\n });\n}\nexport default NoticeList;"], "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAKjB,eAAmB;AACnB,mBAAgD;AAChD,yBAA8B;AAC9B,IAAM,OAAO,MAAM;AAAC;AA4BpB,SAAS,WAAW;AAAA,EAClB;AAAA,EACA,WAAW;AAAA,EACX;AAAA,EACA;AACF,GAAG;AACD,QAAM,eAAe,QAAM,MAAM,SAAS,EAAE;AAC5C,kBAAY,YAAAA,SAAK,0BAA0B,SAAS;AACpD,SAAoB,uCAAAC,MAAM,OAAO;AAAA,IAC/B;AAAA,IACA,UAAU,CAAC,UAAU,CAAC,GAAG,OAAO,EAAE,QAAQ,EAAE,IAAI,YAAU;AACxD,YAAM;AAAA,QACJ;AAAA,QACA,GAAG;AAAA,MACL,IAAI;AACJ,aAAoB,iCAAAC,eAAe,SAAAC,SAAQ;AAAA,QACzC,GAAG;AAAA,QACH,KAAK,OAAO;AAAA,QACZ,UAAU,aAAa,OAAO,EAAE;AAAA,MAClC,GAAG,OAAO,OAAO;AAAA,IACnB,CAAC,CAAC;AAAA,EACJ,CAAC;AACH;AACA,IAAO,eAAQ;", "names": ["clsx", "_jsxs", "_createElement", "Notice"] }