UNPKG

@wordpress/components

Version:
8 lines (7 loc) 2.58 kB
{ "version": 3, "sources": ["../../src/icon/index.tsx"], "sourcesContent": ["/**\n * External dependencies\n */\n\n/**\n * WordPress dependencies\n */\nimport { cloneElement, createElement, isValidElement } from '@wordpress/element';\nimport { SVG } from '@wordpress/primitives';\n\n/**\n * Internal dependencies\n */\nimport Dashicon from '../dashicon';\nimport { jsx as _jsx } from \"react/jsx-runtime\";\n/**\n * Renders a raw icon without any initial styling or wrappers.\n *\n * ```jsx\n * import { wordpress } from '@wordpress/icons';\n *\n * <Icon icon={ wordpress } />\n * ```\n */\nfunction Icon({\n icon = null,\n size = 'string' === typeof icon ? 20 : 24,\n ...additionalProps\n}) {\n if ('string' === typeof icon) {\n return /*#__PURE__*/_jsx(Dashicon, {\n icon: icon,\n size: size,\n ...additionalProps\n });\n }\n if (isValidElement(icon) && Dashicon === icon.type) {\n return cloneElement(icon, {\n ...additionalProps\n });\n }\n if ('function' === typeof icon) {\n return createElement(icon, {\n size,\n ...additionalProps\n });\n }\n if (icon && (icon.type === 'svg' || icon.type === SVG)) {\n const appliedProps = {\n ...icon.props,\n width: size,\n height: size,\n ...additionalProps\n };\n return /*#__PURE__*/_jsx(SVG, {\n ...appliedProps\n });\n }\n if (isValidElement(icon)) {\n return cloneElement(icon, {\n // @ts-ignore Just forwarding the size prop along\n size,\n width: size,\n height: size,\n ...additionalProps\n });\n }\n return icon;\n}\nexport default Icon;"], "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOA,qBAA4D;AAC5D,wBAAoB;AAKpB,sBAAqB;AACrB,yBAA4B;AAU5B,SAAS,KAAK;AAAA,EACZ,OAAO;AAAA,EACP,OAAO,aAAa,OAAO,OAAO,KAAK;AAAA,EACvC,GAAG;AACL,GAAG;AACD,MAAI,aAAa,OAAO,MAAM;AAC5B,WAAoB,uCAAAA,KAAK,gBAAAC,SAAU;AAAA,MACjC;AAAA,MACA;AAAA,MACA,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AACA,UAAI,+BAAe,IAAI,KAAK,gBAAAA,YAAa,KAAK,MAAM;AAClD,eAAO,6BAAa,MAAM;AAAA,MACxB,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AACA,MAAI,eAAe,OAAO,MAAM;AAC9B,eAAO,8BAAc,MAAM;AAAA,MACzB;AAAA,MACA,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AACA,MAAI,SAAS,KAAK,SAAS,SAAS,KAAK,SAAS,wBAAM;AACtD,UAAM,eAAe;AAAA,MACnB,GAAG,KAAK;AAAA,MACR,OAAO;AAAA,MACP,QAAQ;AAAA,MACR,GAAG;AAAA,IACL;AACA,WAAoB,uCAAAD,KAAK,uBAAK;AAAA,MAC5B,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AACA,UAAI,+BAAe,IAAI,GAAG;AACxB,eAAO,6BAAa,MAAM;AAAA;AAAA,MAExB;AAAA,MACA,OAAO;AAAA,MACP,QAAQ;AAAA,MACR,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AACA,SAAO;AACT;AACA,IAAO,eAAQ;", "names": ["_jsx", "Dashicon"] }