@iconify/react
Advanced tools
Comparing version 2.0.0-beta.0 to 2.0.0-beta.1
@@ -322,5 +322,7 @@ 'use strict'; | ||
var transformations = []; | ||
var rotation = customisations.rotate; | ||
if (customisations.hFlip) { | ||
if (customisations.vFlip) { | ||
var hFlip = customisations.hFlip !== icon.hFlip; | ||
var vFlip = customisations.vFlip !== icon.vFlip; | ||
var rotation = customisations.rotate + icon.rotate; | ||
if (hFlip) { | ||
if (vFlip) { | ||
rotation += 2; | ||
@@ -339,3 +341,3 @@ } | ||
} | ||
else if (customisations.vFlip) { | ||
else if (vFlip) { | ||
// Vertical flip | ||
@@ -342,0 +344,0 @@ transformations.push('translate(' + (0 - box.left) + ' ' + (box.height + box.top) + ')'); |
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react");function t(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function i(e,t){return e(t={exports:{}},t.exports),t.exports}var r=i((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.merge=function(e,t,i){for(var r=Object.create(null),n=[e,t,i],a=0;a<3;a++){var o=n[a];if("object"==typeof o&&o)for(var l in o)r[l]=o[l]}return r}}));t(r);var n=r.merge,a=i((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.defaults=Object.freeze({inline:!1,width:null,height:null,hAlign:"center",vAlign:"middle",slice:!1,hFlip:!1,vFlip:!1,rotate:0}),t.fullCustomisations=function(e){return r.merge(t.defaults,e)}}));t(a);var o=a.defaults,l=(a.fullCustomisations,i((function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var i=/[\s,]+/;t.flipFromString=function(e,t){t.split(i).forEach((function(t){switch(t.trim()){case"horizontal":e.hFlip=!0;break;case"vertical":e.vFlip=!0}}))},t.alignmentFromString=function(e,t){t.split(i).forEach((function(t){var i=t.trim();switch(i){case"left":case"center":case"right":e.hAlign=i;break;case"top":case"middle":case"bottom":e.vAlign=i;break;case"slice":e.slice=!0;break;case"meet":e.slice=!1}}))}})));t(l);var c=l.flipFromString,s=l.alignmentFromString,u=i((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.rotateFromString=function(e){var t=e.replace(/^-?[0-9.]*/,"");function i(e){for(;e<0;)e+=4;return e%4}if(""===t){var r=parseInt(e);return isNaN(r)?0:i(r)}if(t!==e){var n=0;switch(t){case"%":n=25;break;case"deg":n=90}if(n){var a=parseFloat(e.slice(0,e.length-t.length));return isNaN(a)?0:(a/=n)%1==0?i(a):0}}return 0}}));t(u);var f=u.rotateFromString,h=i((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.iconDefaults=Object.freeze({body:"",left:0,top:0,width:16,height:16,rotate:0,vFlip:!1,hFlip:!1}),t.fullIcon=function(e){return r.merge(t.iconDefaults,e)}}));t(h);h.iconDefaults;var d=h.fullIcon,p=i((function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var i=/(-?[0-9.]*[0-9]+[0-9.]*)/g,r=/^-?[0-9.]*[0-9]+[0-9.]*$/g;t.calcSize=function(e,t,n){if(1===t)return e;if(n=void 0===n?100:n,"number"==typeof e)return Math.ceil(e*t*n)/n;if("string"!=typeof e)return e;var a=e.split(i);if(null===a||!a.length)return e;for(var o=[],l=a.shift(),c=r.test(l);;){if(c){var s=parseFloat(l);isNaN(s)?o.push(l):o.push(Math.ceil(s*t*n)/n)}else o.push(l);if(void 0===(l=a.shift()))return o.join("");c=!c}}}));t(p);p.calcSize;var g=i((function(e,t){function i(e){var t="";switch(e.hAlign){case"left":t+="xMin";break;case"right":t+="xMax";break;default:t+="xMid"}switch(e.vAlign){case"top":t+="YMin";break;case"bottom":t+="YMax";break;default:t+="YMid"}return t+=e.slice?" slice":" meet"}Object.defineProperty(t,"__esModule",{value:!0}),t.iconToSVG=function(e,t){var r,n,a,o={left:e.left,top:e.top,width:e.width,height:e.height},l=[],c=t.rotate;switch(t.hFlip?t.vFlip?c+=2:(l.push("translate("+(o.width+o.left)+" "+(0-o.top)+")"),l.push("scale(-1 1)"),o.top=o.left=0):t.vFlip&&(l.push("translate("+(0-o.left)+" "+(o.height+o.top)+")"),l.push("scale(1 -1)"),o.top=o.left=0),c%=4){case 1:r=o.height/2+o.top,l.unshift("rotate(90 "+r+" "+r+")");break;case 2:l.unshift("rotate(180 "+(o.width/2+o.left)+" "+(o.height/2+o.top)+")");break;case 3:r=o.width/2+o.left,l.unshift("rotate(-90 "+r+" "+r+")")}c%2==1&&(0===o.left&&0===o.top||(r=o.left,o.left=o.top,o.top=r),o.width!==o.height&&(r=o.width,o.width=o.height,o.height=r)),null===t.width&&null===t.height?(a="1em",n=p.calcSize(a,o.width/o.height)):null!==t.width&&null!==t.height?(n=t.width,a=t.height):null!==t.height?(a=t.height,n=p.calcSize(a,o.width/o.height)):(n=t.width,a=p.calcSize(n,o.height/o.width)),"auto"===n&&(n=o.width),"auto"===a&&(a=o.height),n="string"==typeof n?n:n+"",a="string"==typeof a?a:a+"";var s=e.body;l.length&&(s='<g transform="'+l.join(" ")+'">'+s+"</g>");var u={attributes:{width:n,height:a,preserveAspectRatio:i(t),viewBox:o.left+" "+o.top+" "+o.width+" "+o.height},body:s};return t.inline&&(u.inline=!0),u}}));t(g);var v=g.iconToSVG,b=i((function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var i=/\sid="(\S+)"/g,r="IconifyId-"+Date.now().toString(16)+"-"+(16777216*Math.random()|0).toString(16)+"-",n=0;function a(e,t,i){for(var r=0;-1!==(r=i.indexOf(e,r));)i=i.slice(0,r)+t+i.slice(r+e.length),r+=t.length;return i}t.replaceIDs=function(e,t){void 0===t&&(t=r);for(var o,l=[];o=i.exec(e);)l.push(o[1]);return l.length?(l.forEach((function(i){var r="function"==typeof t?t():t+n++;e=a('="'+i+'"','="'+r+'"',e),e=a('="#'+i+'"','="#'+r+'"',e),e=a("(#"+i+")","(#"+r+")",e)})),e):e}}));t(b);var w=b.replaceIDs,m={xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":!0,focusable:!1,role:"img",style:{}},y=n(o,{inline:!0}),_=Object.create(null),M=function(t,i){var r="string"==typeof t.icon?_[t.icon]:d(t.icon);if(!r)return null;var a=n(i,t),o=n(m),l="object"==typeof t.style?t.style:{};for(var u in o.style=l,t){var h=t[u];switch(u){case"icon":case"style":break;case"flip":c(a,h);break;case"align":s(a,h);break;case"color":l.color=h;break;case"rotate":"number"!=typeof h?a[u]=f(h):o[u]=h;break;case"ariaHidden":case"aria-hidden":!0!==h&&"true"!==h&&delete o["aria-hidden"];break;default:void 0===i[u]&&(o[u]=h)}}var p=v(r,a);for(var g in o.dangerouslySetInnerHTML={__html:w(p.body)},p.attributes)o[g]=p.attributes[g];return p.inline&&void 0===l.verticalAlign&&(l.verticalAlign="-0.125em"),e.createElement("svg",o)};exports.Icon=function(e){return M(e,o)},exports.InlineIcon=function(e){return M(e,y)},exports.addIcon=function(e,t){_[e]=d(t)}; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react");function t(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function i(e,t){return e(t={exports:{}},t.exports),t.exports}var r=i((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.merge=function(e,t,i){for(var r=Object.create(null),n=[e,t,i],a=0;a<3;a++){var o=n[a];if("object"==typeof o&&o)for(var l in o)r[l]=o[l]}return r}}));t(r);var n=r.merge,a=i((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.defaults=Object.freeze({inline:!1,width:null,height:null,hAlign:"center",vAlign:"middle",slice:!1,hFlip:!1,vFlip:!1,rotate:0}),t.fullCustomisations=function(e){return r.merge(t.defaults,e)}}));t(a);var o=a.defaults,l=(a.fullCustomisations,i((function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var i=/[\s,]+/;t.flipFromString=function(e,t){t.split(i).forEach((function(t){switch(t.trim()){case"horizontal":e.hFlip=!0;break;case"vertical":e.vFlip=!0}}))},t.alignmentFromString=function(e,t){t.split(i).forEach((function(t){var i=t.trim();switch(i){case"left":case"center":case"right":e.hAlign=i;break;case"top":case"middle":case"bottom":e.vAlign=i;break;case"slice":e.slice=!0;break;case"meet":e.slice=!1}}))}})));t(l);var c=l.flipFromString,s=l.alignmentFromString,u=i((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.rotateFromString=function(e){var t=e.replace(/^-?[0-9.]*/,"");function i(e){for(;e<0;)e+=4;return e%4}if(""===t){var r=parseInt(e);return isNaN(r)?0:i(r)}if(t!==e){var n=0;switch(t){case"%":n=25;break;case"deg":n=90}if(n){var a=parseFloat(e.slice(0,e.length-t.length));return isNaN(a)?0:(a/=n)%1==0?i(a):0}}return 0}}));t(u);var f=u.rotateFromString,h=i((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.iconDefaults=Object.freeze({body:"",left:0,top:0,width:16,height:16,rotate:0,vFlip:!1,hFlip:!1}),t.fullIcon=function(e){return r.merge(t.iconDefaults,e)}}));t(h);h.iconDefaults;var d=h.fullIcon,p=i((function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var i=/(-?[0-9.]*[0-9]+[0-9.]*)/g,r=/^-?[0-9.]*[0-9]+[0-9.]*$/g;t.calcSize=function(e,t,n){if(1===t)return e;if(n=void 0===n?100:n,"number"==typeof e)return Math.ceil(e*t*n)/n;if("string"!=typeof e)return e;var a=e.split(i);if(null===a||!a.length)return e;for(var o=[],l=a.shift(),c=r.test(l);;){if(c){var s=parseFloat(l);isNaN(s)?o.push(l):o.push(Math.ceil(s*t*n)/n)}else o.push(l);if(void 0===(l=a.shift()))return o.join("");c=!c}}}));t(p);p.calcSize;var g=i((function(e,t){function i(e){var t="";switch(e.hAlign){case"left":t+="xMin";break;case"right":t+="xMax";break;default:t+="xMid"}switch(e.vAlign){case"top":t+="YMin";break;case"bottom":t+="YMax";break;default:t+="YMid"}return t+=e.slice?" slice":" meet"}Object.defineProperty(t,"__esModule",{value:!0}),t.iconToSVG=function(e,t){var r,n,a,o={left:e.left,top:e.top,width:e.width,height:e.height},l=[],c=t.hFlip!==e.hFlip,s=t.vFlip!==e.vFlip,u=t.rotate+e.rotate;switch(c?s?u+=2:(l.push("translate("+(o.width+o.left)+" "+(0-o.top)+")"),l.push("scale(-1 1)"),o.top=o.left=0):s&&(l.push("translate("+(0-o.left)+" "+(o.height+o.top)+")"),l.push("scale(1 -1)"),o.top=o.left=0),u%=4){case 1:r=o.height/2+o.top,l.unshift("rotate(90 "+r+" "+r+")");break;case 2:l.unshift("rotate(180 "+(o.width/2+o.left)+" "+(o.height/2+o.top)+")");break;case 3:r=o.width/2+o.left,l.unshift("rotate(-90 "+r+" "+r+")")}u%2==1&&(0===o.left&&0===o.top||(r=o.left,o.left=o.top,o.top=r),o.width!==o.height&&(r=o.width,o.width=o.height,o.height=r)),null===t.width&&null===t.height?(a="1em",n=p.calcSize(a,o.width/o.height)):null!==t.width&&null!==t.height?(n=t.width,a=t.height):null!==t.height?(a=t.height,n=p.calcSize(a,o.width/o.height)):(n=t.width,a=p.calcSize(n,o.height/o.width)),"auto"===n&&(n=o.width),"auto"===a&&(a=o.height),n="string"==typeof n?n:n+"",a="string"==typeof a?a:a+"";var f=e.body;l.length&&(f='<g transform="'+l.join(" ")+'">'+f+"</g>");var h={attributes:{width:n,height:a,preserveAspectRatio:i(t),viewBox:o.left+" "+o.top+" "+o.width+" "+o.height},body:f};return t.inline&&(h.inline=!0),h}}));t(g);var v=g.iconToSVG,b=i((function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var i=/\sid="(\S+)"/g,r="IconifyId-"+Date.now().toString(16)+"-"+(16777216*Math.random()|0).toString(16)+"-",n=0;function a(e,t,i){for(var r=0;-1!==(r=i.indexOf(e,r));)i=i.slice(0,r)+t+i.slice(r+e.length),r+=t.length;return i}t.replaceIDs=function(e,t){void 0===t&&(t=r);for(var o,l=[];o=i.exec(e);)l.push(o[1]);return l.length?(l.forEach((function(i){var r="function"==typeof t?t():t+n++;e=a('="'+i+'"','="'+r+'"',e),e=a('="#'+i+'"','="#'+r+'"',e),e=a("(#"+i+")","(#"+r+")",e)})),e):e}}));t(b);var w=b.replaceIDs,m={xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":!0,focusable:!1,role:"img",style:{}},y=n(o,{inline:!0}),_=Object.create(null),M=function(t,i){var r="string"==typeof t.icon?_[t.icon]:d(t.icon);if(!r)return null;var a=n(i,t),o=n(m),l="object"==typeof t.style?t.style:{};for(var u in o.style=l,t){var h=t[u];switch(u){case"icon":case"style":break;case"flip":c(a,h);break;case"align":s(a,h);break;case"color":l.color=h;break;case"rotate":"number"!=typeof h?a[u]=f(h):o[u]=h;break;case"ariaHidden":case"aria-hidden":!0!==h&&"true"!==h&&delete o["aria-hidden"];break;default:void 0===i[u]&&(o[u]=h)}}var p=v(r,a);for(var g in o.dangerouslySetInnerHTML={__html:w(p.body)},p.attributes)o[g]=p.attributes[g];return p.inline&&void 0===l.verticalAlign&&(l.verticalAlign="-0.125em"),e.createElement("svg",o)};exports.Icon=function(e){return M(e,o)},exports.InlineIcon=function(e){return M(e,y)},exports.addIcon=function(e,t){_[e]=d(t)}; |
@@ -318,5 +318,7 @@ import { createElement } from 'react'; | ||
var transformations = []; | ||
var rotation = customisations.rotate; | ||
if (customisations.hFlip) { | ||
if (customisations.vFlip) { | ||
var hFlip = customisations.hFlip !== icon.hFlip; | ||
var vFlip = customisations.vFlip !== icon.vFlip; | ||
var rotation = customisations.rotate + icon.rotate; | ||
if (hFlip) { | ||
if (vFlip) { | ||
rotation += 2; | ||
@@ -335,3 +337,3 @@ } | ||
} | ||
else if (customisations.vFlip) { | ||
else if (vFlip) { | ||
// Vertical flip | ||
@@ -338,0 +340,0 @@ transformations.push('translate(' + (0 - box.left) + ' ' + (box.height + box.top) + ')'); |
@@ -5,3 +5,3 @@ { | ||
"author": "Vjacheslav Trushkin", | ||
"version": "2.0.0-beta.0", | ||
"version": "2.0.0-beta.1", | ||
"license": "MIT", | ||
@@ -8,0 +8,0 @@ "bugs": "https://github.com/iconify/iconify/issues", |
@@ -91,3 +91,3 @@ # Iconify for React | ||
`icon` property is mandatory. It tells component what icon to render. If the property value is invalid, the component will render an empty icon. Value can be a string containing the icon name (icon must be registered before use by calling `addIcon`, see instructions above) or an object containing the icon data. | ||
`icon` property is mandatory. It tells component what icon to render. If the property value is invalid, the component will render an empty icon. The value can be a string containing the icon name (icon must be registered before use by calling `addIcon`, see instructions above) or an object containing the icon data. | ||
@@ -94,0 +94,0 @@ The icon component has the following optional properties: |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
65477
1504
0