Socket
Socket
Sign inDemoInstall

babel-plugin-tailwind-components

Package Overview
Dependencies
49
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.5.6 to 0.5.7

2

dist/index.js

@@ -1,2 +0,2 @@

var e={"bg-bottom":{backgroundPosition:"bottom"},"bg-center":{backgroundPosition:"center"},"bg-left":{backgroundPosition:"left"},"bg-left-bottom":{backgroundPosition:"left bottom"},"bg-left-top":{backgroundPosition:"left top"},"bg-right":{backgroundPosition:"right"},"bg-right-bottom":{backgroundPosition:"right bottom"},"bg-right-top":{backgroundPosition:"right-top"},"bg-top":{backgroundPosition:"top"},"bg-repeat":{backgroundRepeat:"repeat"},"bg-no-repeat":{backgroundRepeat:"no-repeat"},"bg-repeat-x":{backgroundRepeat:"repeat-x"},"bg-repeat-y":{backgroundRepeat:"repeat-y"},"bg-fixed":{backgroundAttachment:"fixed"},"bg-local":{backgroundAttachment:"local"},"bg-scroll":{backgroundAttachment:"scroll"},"border-solid":{borderStyle:"solid"},"border-dashed":{borderStyle:"dashed"},"border-dotted":{borderStyle:"dotted"},"border-none":{borderStyle:"none"},block:{display:"block"},"inline-block":{display:"inline-block"},inline:{display:"inline"},table:{display:"table"},"table-row":{display:"table-row"},"table-cell":{display:"table-cell"},hidden:{display:"none"},flex:{display:"flex"},"inline-flex":{display:"inline-flex"},"flex-row":{flexDirection:"row"},"flex-row-reverse":{flexDirection:"row-reverse"},"flex-col":{flexDirection:"column"},"flex-col-reverse":{flexDirection:"column-reverse"},"flex-no-wrap":{flexWrap:"nowrap"},"flex-wrap":{flexWrap:"wrap"},"flex-wrap-reverse":{flexWrap:"wrap-reverse"},"justify-start":{justifyContent:"flex-start"},"justify-center":{justifyContent:"center"},"justify-end":{justifyContent:"flex-end"},"justify-between":{justifyContent:"space-between"},"justify-around":{justifyContent:"space-around"},"items-stretch":{alignItems:"flex-stretch"},"items-start":{alignItems:"flex-start"},"items-center":{alignItems:"center"},"items-end":{alignItems:"flex-end"},"items-baseline":{alignItems:"baseline"},"content-start":{alignContent:"flex-start"},"content-center":{alignContent:"center"},"content-end":{alignContent:"flex-end"},"content-between":{alignContent:"space-between"},"content-around":{alignContent:"space-around"},"self-auto":{alignSelf:"auto"},"self-start":{alignSelf:"flex-start"},"self-center":{alignSelf:"center"},"self-end":{alignSelf:"flex-end"},"self-stretch":{alignSelf:"stretch"},"flex-initial":{flex:"initial"},"flex-1":{flex:1},"flex-auto":{flex:"auto"},"flex-none":{flex:"none"},"flex-grow":{flexGrow:1},"flex-shrink":{flexShrink:1},"flex-no-grow":{flexGrow:0},"flex-no-shrink":{flexShrink:0},"float-right":{float:"right"},"float-left":{float:"left"},"float-none":{float:"none"},clearfix:{"::after":{content:'""',display:"table",clear:"both"}},"appearance-none":{appearance:"none"},"cursor-auto":{cursor:"auto"},"cursor-default":{cursor:"default"},"cursor-pointer":{cursor:"pointer"},"cursor-wait":{cursor:"wait"},"cursor-move":{cursor:"move"},"cursor-not-allowed":{cursor:"not-allowed"},"resize-none":{resize:"none"},resize:{resize:"both"},"resize-y":{resize:"vertical"},"resize-x":{resize:"horizontal"},"pointer-events-none":{pointerEvents:"none"},"pointer-events-auto":{pointerEvents:"auto"},"select-none":{userSelect:"none"},"select-text":{userSelect:"text"},"list-reset":{listStyle:"none",padding:0},"overflow-auto":{overflow:"auto"},"overflow-hidden":{overflow:"hidden"},"overflow-visible":{overflow:"visible"},"overflow-scroll":{overflow:"scroll"},"overflow-x-auto":{overflowX:"auto"},"overflow-y-auto":{overflowY:"auto"},"overflow-x-hidden":{overflowX:"hidden"},"overflow-y-hidden":{overflowY:"hidden"},"overflow-x-visible":{overflowX:"visible"},"overflow-y-visible":{overflowY:"visible"},"overflow-x-scroll":{overflowX:"scroll"},"overflow-y-scroll":{overflowY:"scroll"},"scrolling-touch":{webkitOverflowScrolling:"touch"},"scrolling-auto":{webkitOverflowScrolling:"auto"},static:{position:"static"},fixed:{position:"fixed"},absolute:{position:"absolute"},relative:{position:"relative"},sticky:{position:"sticky"},"pin-t":{top:0},"pin-r":{right:0},"pin-b":{bottom:0},"pin-l":{left:0},"pin-y":{top:0,bottom:0},"pin-x":{right:0,left:0},pin:{top:0,right:0,bottom:0,left:0},"pin-none":{top:"auto",right:"auto",bottom:"auto",left:"auto"},"text-left":{textAlign:"left"},"text-center":{textAlign:"center"},"text-right":{textAlign:"right"},"text-justify":{textAlign:"justify"},italic:{fontStyle:"italic"},roman:{fontStyle:"normal"},uppercase:{textTransform:"uppercase"},lowercase:{textTransform:"lowercase"},capitalize:{textTransform:"capitalize"},"normal-case":{textTransform:"none"},underline:{textDecoration:"underline"},"line-through":{textDecoration:"line-through"},"no-underline":{textDecoration:"none"},antialiased:{webkitFontSmoothing:"antialiased",mozOsxFontSmoothing:"grayscale"},"subpixel-antialiased":{webkitFontSmoothing:"auto",mozOsxFontSmoothing:"auto"},"whitespace-normal":{whiteSpace:"normal"},"whitespace-no-wrap":{whiteSpace:"nowrap"},"whitespace-pre":{whiteSpace:"pre"},"whitespace-pre-line":{whiteSpace:"pre-line"},"whitespace-pre-wrap":{whiteSpace:"pre-wrap"},"break-words":{wordWrap:"break-word"},"break-normal":{wordWrap:"normal"},truncate:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},"align-baseline":{verticalAlign:"baseline"},"align-top":{verticalAlign:"top"},"align-middle":{verticalAlign:"middle"},"align-bottom":{verticalAlign:"bottom"},"align-text-top":{verticalAlign:"text-top"},"align-text-bottom":{verticalAlign:"text-bottom"},visible:{visibility:"visible"},invisible:{visibility:"hidden"},"border-collapse":{borderCollapse:"collapse"},"border-separate":{borderCollapse:"separate"},"table-auto":{tableLayout:"auto"},"table-fixed":{tableLayout:"fixed"},"outline-none":{outline:0}},t={bg:[{prop:"backgroundColor",config:"backgroundColors"},{prop:"backgroundSize",config:"backgroundSize"}],"border-t":{prop:"borderTopWidth",config:"borderWidths"},"border-b":{prop:"borderBottomWidth",config:"borderWidths"},"border-l":{prop:"borderLeftWidth",config:"borderWidths"},"border-r":{prop:"borderRightWidth",config:"borderWidths"},border:[{prop:"borderColor",config:"borderColors"},{prop:"borderWidth",config:"borderWidths"}],"rounded-t":{prop:"borderTopRadius",config:"borderRadius"},"rounded-r":{prop:"borderRightRadius",config:"borderRadius"},"rounded-b":{prop:"borderBottomRadius",config:"borderRadius"},"rounded-l":{prop:"borderLeftRadius",config:"borderRadius"},"rounded-tl":{prop:"borderTopLeftRadius",config:"borderRadius"},"rounded-tr":{prop:"borderTopRightRadius",config:"borderRadius"},"rounded-br":{prop:"borderBottomRightRadius",config:"borderRadius"},"rounded-bl":{prop:"borderBottomLeftRadius",config:"borderRadius"},rounded:{prop:"borderRadius",config:"borderRadius"},opacity:{prop:"opacity",config:"opacity"},shadow:{prop:"boxShadow",config:"shadows"},w:{prop:"width",config:"width"},"min-w":{prop:"minWidth",config:"minWidth"},"max-w":{prop:"maxWidth",config:"maxWidth"},h:{prop:"height",config:"height"},"min-h":{prop:"minHeight",config:"minHeight"},"max-h":{prop:"maxHeight",config:"maxHeight"},pt:{prop:"paddingTop",config:"padding"},pr:{prop:"paddingRight",config:"padding"},pb:{prop:"paddingBottom",config:"padding"},pl:{prop:"paddingLeft",config:"padding"},px:{prop:["paddingLeft","paddingRight"],config:"padding"},py:{prop:["paddingTop","paddingBottom"],config:"padding"},p:{prop:"padding",config:"padding"},mt:{prop:"marginTop",config:"margin"},mr:{prop:"marginRight",config:"margin"},mb:{prop:"marginBottom",config:"margin"},ml:{prop:"marginLeft",config:"margin"},mx:{prop:["marginLeft","marginRight"],config:"margin"},my:{prop:["marginTop","marginBottom"],config:"margin"},m:{prop:"margin",config:"margin"},"-mt":{prop:"marginTop",config:"negativeMargin",pre:'"-"+'},"-mr":{prop:"marginRight",config:"negativeMargin",pre:'"-"+'},"-mb":{prop:"marginBottom",config:"negativeMargin",pre:'"-"+'},"-ml":{prop:"marginLeft",config:"negativeMargin",pre:'"-"+'},"-mx":{prop:["marginLeft","marginRight"],config:"negativeMargin",pre:'"-"+'},"-my":{prop:["marginTop","marginBottom"],config:"negativeMargin",pre:'"-"+'},"-m":{prop:"margin",config:"negativeMargin",pre:'"-"+'},fill:{prop:"fill",config:"svgFill"},stroke:{prop:"stroke",config:"svgStroke"},font:[{prop:"fontWeight",config:"fontWeights"},{prop:"fontFamily",config:"fonts",preDev:"(",postDev:" || []).map(x => '\"' + x + '\"').join(', ')",format:function(e){return e.map(function(e){return'"'+e+'"'}).join(", ")}}],text:[{prop:"color",config:"textColors"},{prop:"fontSize",config:"textSizes"}],leading:{prop:"lineHeight",config:"leading"},tracking:{prop:"letterSpacing",config:"tracking"},z:{prop:"zIndex",config:"zIndex"}};function r(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var o=require("@babel/parser"),n=require("@babel/generator").default;function i(i){var c,g,u=i.path,b=i.t,m=i.configPath,h="production"===process.env.NODE_ENV,v=!h,x="StringLiteral"===u.node.type?"object":i.outputFormat;if(!x||"auto"===x){var w=u.findParent(function(e){return e.isJSXElement()});x=w&&"style"===w.node.openingElement.name.name?"string":"object"}var y,k,S,j=("StringLiteral"===u.node.type?u.node.value:u.node.quasi.quasis[0].value.cooked).match(/\S+/g)||[],R=u.find(function(e){return e.isProgram()});"production"===process.env.NODE_ENV?y=require(m):(k=R.scope.generateUidIdentifier("tailwind"),R.unshiftContainer("body",b.importDeclaration([b.importDefaultSpecifier(k)],b.stringLiteral(m)))),"StringLiteral"===u.node.type&&(S=R.scope.generateUidIdentifier("css"),R.unshiftContainer("body",b.importDeclaration([b.importSpecifier(S,b.identifier("css"))],b.stringLiteral("emotion"))));var W=j.reduce(function(o,n,i){for(var s,u,b=[];null!==s;)(s=n.match(/^([a-z-_]+):/i))&&(n=n.substr(s[0].length),b.push(s[1]));if(b=b.map(function(e){return"hover"===e||"focus"===e||"active"===e?":"+e:h?"@media (min-width: "+y.screens[e]+")":"`@media (min-width: ${"+k.name+'.screens["'+e+'"]})`'}),e[n])return b.length?(f(o,b,p(d(o,b,{}),e[n])),o):p(o,e[n]);if(Object.keys(t).some(function(e){if(n.startsWith(e+"-")||n===e)return u=e,!0}),u){var m,w=n.substr(u.length+1);if(""===w&&(w="default"),Array.isArray(t[u])){var S=t[u].map(function(e){var t=l(e,v),r=t.pre,o=t.post;if(!h||void 0!==y[e.config][w]){var n=e.format?e.format:function(e){return e};return h?((c={})[e.prop]=r||o?r+n(y[e.config][w])+o:n(y[e.config][w]),c):"string"===x?"['"+a(e.prop)+"', "+r+k.name+"."+e.config+'["'+w+'"]'+o+"]":"{"+e.prop+":"+r+k.name+"."+e.config+'["'+w+'"]'+o+"}"}});h?m=S.filter(function(e){return void 0!==e})[0]:"string"===x?(S="["+S.join(",")+"].filter(x => typeof x[1] !== 'undefined' && x[1] !== '')[0].join(':')",(m={})["__spread__"+i]=S):(S="["+S.join(",")+'].filter(x => typeof x[Object.keys(x)[0]] !== "undefined" && x[Object.keys(x)[0]] !== "")[0]',(m={})["__spread__"+i]=S)}else{m=Array.isArray(t[u].prop)?t[u].prop:[t[u].prop];var j=l(t[u],v),R=j.pre,W=j.post,L=t[u].format?t[u].format:function(e){return e};m=m.reduce(function(e,o){return function(e){for(var t=arguments,o=1;o<arguments.length;o++){var n=null!=t[o]?t[o]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(t){r(e,t,n[t])})}return e}({},e,((g={})[o]=h?R+L(y[t[u].config][w])+W:"$"+R+k.name+"."+t[u].config+'["'+w+'"]'+W,g))},{})}return b.length?(f(o,b,p(d(o,b,{}),m)),o):p(o,m)}return o},{}),L=s(W,b);if("string"===x){var E=function e(t,r){void 0===r&&(r=!1);var o=r?"/**/":"";return Object.keys(t).reduce(function(r,n){var i=t[n];if(n.startsWith("__spread__"))return r+"${"+i+"};"+o;if("string"==typeof i)return"$"===i[0]&&(i="${"+i.substr(1)+"}"),r+a(n)+":"+i+";"+o;i=e(i);var l=":"===n[0]?"&"+n:n;return l="`"===l[0]?l.substr(1,l.length-2):l,r+a(l)+"{"+i+"};"+o},"")}(W,v),O=u.parentPath;if(O.isTemplateLiteral()){var P=O.get("expressions").indexOf(u),z=O.get("quasis")[P],A=O.get("quasis")[P+1];A.node.value.raw=z.node.value.raw+E+A.node.value.raw,A.node.value.cooked=z.node.value.cooked+E+A.node.value.cooked,z.remove(),u.remove();var C=o.parseExpression(n(O.node).code);O.replaceWith(C)}else{u.replaceWith(o.parseExpression("`"+E+"`"))}}else u.replaceWith("StringLiteral"===u.node.type?b.callExpression(S,[L]):L)}function a(e){return e.replace(/[A-Z]/g,"-$&").toLowerCase().replace(/^(ms|o|moz|webkit)-/,"-$1-")}function l(e,t){var r="",o="";return t&&e.preDev?r=e.preDev:e.pre&&(r=e.pre),t&&e.postDev?o=e.postDev:e.post&&(o=e.post),{pre:r,post:o}}function p(e,t){return Object.assign({},e,t)}function s(e,t){if(null===e)return t.nullLiteral();switch(typeof e){case"function":var r=o.parse(e.toString(),{allowReturnOutsideFunction:!0,allowSuperOutsideMethod:!0});return traverse.removeProperties(r);case"number":return t.numericLiteral(e);case"string":return e.startsWith("$")?o.parseExpression(e.substr(1)):t.stringLiteral(e);case"boolean":return t.booleanLiteral(e);case"undefined":return t.unaryExpression("void",t.numericLiteral(0),!0);default:if(Array.isArray(e))return t.arrayExpression(e.map(function(e){return s(e,t)}));try{return t.objectExpression(c(e,t,"spreadElement"))}catch(r){return t.objectExpression(c(e,t,"spreadProperty"))}}}function c(e,t,r){return Object.keys(e).filter(function(t){return void 0!==e[t]}).map(function(n){if(n.startsWith("__spread__"))return t[r](o.parseExpression(e[n]));var i=n.startsWith("`"),a=i?o.parseExpression(n):t.stringLiteral(n);return t.objectProperty(a,s(e[n],t),i)})}function f(e,t,r){t.split&&(t=t.split("."));for(var o,n=0,i=t.length,a=e;n<i;++n)o=a[t[n]],a=a[t[n]]=n===i-1?r:null==o?{}:o}function d(e,t,r,o){for(o=0,t=t.split?t.split("."):t;e&&o<t.length;)e=e[t[o++]];return void 0===e||o<t.length?r:e}var g=require("path");module.exports=function(e){var t=e.types,r=t.cloneNode||t.cloneDeep;return{visitor:{TaggedTemplateExpression:function(e,r){"tw"===e.node.tag.name&&i({path:e,configPath:g.resolve(r.file.opts.sourceRoot||".",r.opts.config||"./tailwind.js"),t:t,outputFormat:r.opts.format})},JSXAttribute:function(e,o){if("tw"===e.node.name.name){var n=g.resolve(o.file.opts.sourceRoot||".",o.opts.config||"./tailwind.js");"StringLiteral"===e.node.value.type&&e.get("value").replaceWith(t.jSXExpressionContainer(r(e.node.value))),e.traverse({ArrayExpression:function(e){var o=e.findParent(function(e){return e.isProgram()}),n=o.scope.generateUidIdentifier("cx");o.unshiftContainer("body",t.importDeclaration([t.importSpecifier(n,n)],t.stringLiteral("emotion"))),e.replaceWith(t.callExpression(r(n),e.get("elements").map(function(e){return r(e.node)}))),e.skip()}}),e.traverse({StringLiteral:function(e){i({path:e,configPath:n,t:t,outputFormat:o.opts.format}),e.skip()}})}}}}};
var e={"bg-bottom":{backgroundPosition:"bottom"},"bg-center":{backgroundPosition:"center"},"bg-left":{backgroundPosition:"left"},"bg-left-bottom":{backgroundPosition:"left bottom"},"bg-left-top":{backgroundPosition:"left top"},"bg-right":{backgroundPosition:"right"},"bg-right-bottom":{backgroundPosition:"right bottom"},"bg-right-top":{backgroundPosition:"right-top"},"bg-top":{backgroundPosition:"top"},"bg-repeat":{backgroundRepeat:"repeat"},"bg-no-repeat":{backgroundRepeat:"no-repeat"},"bg-repeat-x":{backgroundRepeat:"repeat-x"},"bg-repeat-y":{backgroundRepeat:"repeat-y"},"bg-fixed":{backgroundAttachment:"fixed"},"bg-local":{backgroundAttachment:"local"},"bg-scroll":{backgroundAttachment:"scroll"},"border-solid":{borderStyle:"solid"},"border-dashed":{borderStyle:"dashed"},"border-dotted":{borderStyle:"dotted"},"border-none":{borderStyle:"none"},block:{display:"block"},"inline-block":{display:"inline-block"},inline:{display:"inline"},table:{display:"table"},"table-row":{display:"table-row"},"table-cell":{display:"table-cell"},hidden:{display:"none"},flex:{display:"flex"},"inline-flex":{display:"inline-flex"},"flex-row":{flexDirection:"row"},"flex-row-reverse":{flexDirection:"row-reverse"},"flex-col":{flexDirection:"column"},"flex-col-reverse":{flexDirection:"column-reverse"},"flex-no-wrap":{flexWrap:"nowrap"},"flex-wrap":{flexWrap:"wrap"},"flex-wrap-reverse":{flexWrap:"wrap-reverse"},"justify-start":{justifyContent:"flex-start"},"justify-center":{justifyContent:"center"},"justify-end":{justifyContent:"flex-end"},"justify-between":{justifyContent:"space-between"},"justify-around":{justifyContent:"space-around"},"items-stretch":{alignItems:"flex-stretch"},"items-start":{alignItems:"flex-start"},"items-center":{alignItems:"center"},"items-end":{alignItems:"flex-end"},"items-baseline":{alignItems:"baseline"},"content-start":{alignContent:"flex-start"},"content-center":{alignContent:"center"},"content-end":{alignContent:"flex-end"},"content-between":{alignContent:"space-between"},"content-around":{alignContent:"space-around"},"self-auto":{alignSelf:"auto"},"self-start":{alignSelf:"flex-start"},"self-center":{alignSelf:"center"},"self-end":{alignSelf:"flex-end"},"self-stretch":{alignSelf:"stretch"},"flex-initial":{flex:"initial"},"flex-1":{flex:1},"flex-auto":{flex:"auto"},"flex-none":{flex:"none"},"flex-grow":{flexGrow:1},"flex-shrink":{flexShrink:1},"flex-no-grow":{flexGrow:0},"flex-no-shrink":{flexShrink:0},"float-right":{float:"right"},"float-left":{float:"left"},"float-none":{float:"none"},clearfix:{"::after":{content:'""',display:"table",clear:"both"}},"appearance-none":{appearance:"none"},"cursor-auto":{cursor:"auto"},"cursor-default":{cursor:"default"},"cursor-pointer":{cursor:"pointer"},"cursor-wait":{cursor:"wait"},"cursor-move":{cursor:"move"},"cursor-not-allowed":{cursor:"not-allowed"},"resize-none":{resize:"none"},resize:{resize:"both"},"resize-y":{resize:"vertical"},"resize-x":{resize:"horizontal"},"pointer-events-none":{pointerEvents:"none"},"pointer-events-auto":{pointerEvents:"auto"},"select-none":{userSelect:"none"},"select-text":{userSelect:"text"},"list-reset":{listStyle:"none",padding:0},"overflow-auto":{overflow:"auto"},"overflow-hidden":{overflow:"hidden"},"overflow-visible":{overflow:"visible"},"overflow-scroll":{overflow:"scroll"},"overflow-x-auto":{overflowX:"auto"},"overflow-y-auto":{overflowY:"auto"},"overflow-x-hidden":{overflowX:"hidden"},"overflow-y-hidden":{overflowY:"hidden"},"overflow-x-visible":{overflowX:"visible"},"overflow-y-visible":{overflowY:"visible"},"overflow-x-scroll":{overflowX:"scroll"},"overflow-y-scroll":{overflowY:"scroll"},"scrolling-touch":{webkitOverflowScrolling:"touch"},"scrolling-auto":{webkitOverflowScrolling:"auto"},static:{position:"static"},fixed:{position:"fixed"},absolute:{position:"absolute"},relative:{position:"relative"},sticky:{position:"sticky"},"pin-t":{top:0},"pin-r":{right:0},"pin-b":{bottom:0},"pin-l":{left:0},"pin-y":{top:0,bottom:0},"pin-x":{right:0,left:0},pin:{top:0,right:0,bottom:0,left:0},"pin-none":{top:"auto",right:"auto",bottom:"auto",left:"auto"},"text-left":{textAlign:"left"},"text-center":{textAlign:"center"},"text-right":{textAlign:"right"},"text-justify":{textAlign:"justify"},italic:{fontStyle:"italic"},roman:{fontStyle:"normal"},uppercase:{textTransform:"uppercase"},lowercase:{textTransform:"lowercase"},capitalize:{textTransform:"capitalize"},"normal-case":{textTransform:"none"},underline:{textDecoration:"underline"},"line-through":{textDecoration:"line-through"},"no-underline":{textDecoration:"none"},antialiased:{webkitFontSmoothing:"antialiased",mozOsxFontSmoothing:"grayscale"},"subpixel-antialiased":{webkitFontSmoothing:"auto",mozOsxFontSmoothing:"auto"},"whitespace-normal":{whiteSpace:"normal"},"whitespace-no-wrap":{whiteSpace:"nowrap"},"whitespace-pre":{whiteSpace:"pre"},"whitespace-pre-line":{whiteSpace:"pre-line"},"whitespace-pre-wrap":{whiteSpace:"pre-wrap"},"break-words":{wordWrap:"break-word"},"break-normal":{wordWrap:"normal"},truncate:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},"align-baseline":{verticalAlign:"baseline"},"align-top":{verticalAlign:"top"},"align-middle":{verticalAlign:"middle"},"align-bottom":{verticalAlign:"bottom"},"align-text-top":{verticalAlign:"text-top"},"align-text-bottom":{verticalAlign:"text-bottom"},visible:{visibility:"visible"},invisible:{visibility:"hidden"},"border-collapse":{borderCollapse:"collapse"},"border-separate":{borderCollapse:"separate"},"table-auto":{tableLayout:"auto"},"table-fixed":{tableLayout:"fixed"},"outline-none":{outline:0}},t={bg:[{prop:"backgroundColor",config:"backgroundColors"},{prop:"backgroundSize",config:"backgroundSize"}],"border-t":{prop:"borderTopWidth",config:"borderWidths"},"border-b":{prop:"borderBottomWidth",config:"borderWidths"},"border-l":{prop:"borderLeftWidth",config:"borderWidths"},"border-r":{prop:"borderRightWidth",config:"borderWidths"},border:[{prop:"borderColor",config:"borderColors"},{prop:"borderWidth",config:"borderWidths"}],"rounded-t":{prop:"borderTopRadius",config:"borderRadius"},"rounded-r":{prop:"borderRightRadius",config:"borderRadius"},"rounded-b":{prop:"borderBottomRadius",config:"borderRadius"},"rounded-l":{prop:"borderLeftRadius",config:"borderRadius"},"rounded-tl":{prop:"borderTopLeftRadius",config:"borderRadius"},"rounded-tr":{prop:"borderTopRightRadius",config:"borderRadius"},"rounded-br":{prop:"borderBottomRightRadius",config:"borderRadius"},"rounded-bl":{prop:"borderBottomLeftRadius",config:"borderRadius"},rounded:{prop:"borderRadius",config:"borderRadius"},opacity:{prop:"opacity",config:"opacity"},shadow:{prop:"boxShadow",config:"shadows"},w:{prop:"width",config:"width"},"min-w":{prop:"minWidth",config:"minWidth"},"max-w":{prop:"maxWidth",config:"maxWidth"},h:{prop:"height",config:"height"},"min-h":{prop:"minHeight",config:"minHeight"},"max-h":{prop:"maxHeight",config:"maxHeight"},pt:{prop:"paddingTop",config:"padding"},pr:{prop:"paddingRight",config:"padding"},pb:{prop:"paddingBottom",config:"padding"},pl:{prop:"paddingLeft",config:"padding"},px:{prop:["paddingLeft","paddingRight"],config:"padding"},py:{prop:["paddingTop","paddingBottom"],config:"padding"},p:{prop:"padding",config:"padding"},mt:{prop:"marginTop",config:"margin"},mr:{prop:"marginRight",config:"margin"},mb:{prop:"marginBottom",config:"margin"},ml:{prop:"marginLeft",config:"margin"},mx:{prop:["marginLeft","marginRight"],config:"margin"},my:{prop:["marginTop","marginBottom"],config:"margin"},m:{prop:"margin",config:"margin"},"-mt":{prop:"marginTop",config:"negativeMargin",pre:'"-"+'},"-mr":{prop:"marginRight",config:"negativeMargin",pre:'"-"+'},"-mb":{prop:"marginBottom",config:"negativeMargin",pre:'"-"+'},"-ml":{prop:"marginLeft",config:"negativeMargin",pre:'"-"+'},"-mx":{prop:["marginLeft","marginRight"],config:"negativeMargin",pre:'"-"+'},"-my":{prop:["marginTop","marginBottom"],config:"negativeMargin",pre:'"-"+'},"-m":{prop:"margin",config:"negativeMargin",pre:'"-"+'},fill:{prop:"fill",config:"svgFill"},stroke:{prop:"stroke",config:"svgStroke"},font:[{prop:"fontWeight",config:"fontWeights"},{prop:"fontFamily",config:"fonts",preDev:"(",postDev:" || []).map(x => '\"' + x + '\"').join(', ')",format:function(e){return e.map(function(e){return'"'+e+'"'}).join(", ")}}],text:[{prop:"color",config:"textColors"},{prop:"fontSize",config:"textSizes"}],leading:{prop:"lineHeight",config:"leading"},tracking:{prop:"letterSpacing",config:"tracking"},z:{prop:"zIndex",config:"zIndex"}};function r(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var o=require("@babel/parser"),n=require("@babel/generator").default;function i(i){var c,g,u=i.path,b=i.t,m=i.configPath,h="production"===process.env.NODE_ENV,v=!h,x="StringLiteral"===u.node.type?"object":i.outputFormat;if(!x||"auto"===x){var w=u.findParent(function(e){return e.isJSXElement()});x=w&&"style"===w.node.openingElement.name.name?"string":"object"}var y,k,S,j=("StringLiteral"===u.node.type?u.node.value:u.node.quasi.quasis[0].value.cooked).match(/\S+/g)||[],R=u.find(function(e){return e.isProgram()});"production"===process.env.NODE_ENV?y=require(m):(k=R.scope.generateUidIdentifier("tailwind"),R.unshiftContainer("body",b.importDeclaration([b.importDefaultSpecifier(k)],b.stringLiteral(m)))),"StringLiteral"===u.node.type&&(S=R.scope.generateUidIdentifier("css"),R.unshiftContainer("body",b.importDeclaration([b.importSpecifier(S,b.identifier("css"))],b.stringLiteral("emotion"))));var W=j.reduce(function(o,n,i){for(var s,u,b=[];null!==s;)(s=n.match(/^([a-z-_]+):/i))&&(n=n.substr(s[0].length),b.push(s[1]));if(b=b.map(function(e){return"hover"===e||"focus"===e||"active"===e?":"+e:h?"@media (min-width: "+y.screens[e]+")":"`@media (min-width: ${"+k.name+'.screens["'+e+'"]})`'}),e[n])return b.length?(f(o,b,p(d(o,b,{}),e[n])),o):p(o,e[n]);if(Object.keys(t).some(function(e){if(n.startsWith(e+"-")||n===e)return u=e,!0}),u){var m,w=n.substr(u.length+1);if(""===w&&(w="default"),Array.isArray(t[u])){var S=t[u].map(function(e){var t=l(e,v),r=t.pre,o=t.post;if(!h||void 0!==y[e.config][w]){var n=e.format?e.format:function(e){return e};return h?((c={})[e.prop]=r||o?r+n(y[e.config][w])+o:n(y[e.config][w]),c):"string"===x?"['"+a(e.prop)+"', "+r+k.name+"."+e.config+'["'+w+'"]'+o+"]":"{"+e.prop+":"+r+k.name+"."+e.config+'["'+w+'"]'+o+"}"}});h?m=S.filter(function(e){return void 0!==e})[0]:"string"===x?(S="["+S.join(",")+"].filter(x => typeof x[1] !== 'undefined' && x[1] !== '')[0].join(':')",(m={})["__spread__"+i]=S):(S="["+S.join(",")+'].filter(x => typeof x[Object.keys(x)[0]] !== "undefined" && x[Object.keys(x)[0]] !== "")[0]',(m={})["__spread__"+i]=S)}else{m=Array.isArray(t[u].prop)?t[u].prop:[t[u].prop];var j=l(t[u],v),R=j.pre,W=j.post,L=t[u].format?t[u].format:function(e){return e};m=m.reduce(function(e,o){return function(e){for(var t=arguments,o=1;o<arguments.length;o++){var n=null!=t[o]?t[o]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(t){r(e,t,n[t])})}return e}({},e,((g={})[o]=h?R+L(y[t[u].config][w])+W:"$"+R+k.name+"."+t[u].config+'["'+w+'"]'+W,g))},{})}return b.length?(f(o,b,p(d(o,b,{}),m)),o):p(o,m)}return o},{}),L=s(W,b);if("string"===x){var E=function e(t,r){void 0===r&&(r=!1);var o=r?"/**/":"";return Object.keys(t).reduce(function(r,n){var i=t[n];if(n.startsWith("__spread__"))return r+"${"+i+"};"+o;if("string"==typeof i)return"$"===i[0]&&(i="${"+i.substr(1)+"}"),r+a(n)+":"+i+";"+o;i=e(i);var l=":"===n[0]?"&"+n:n;return l="`"===l[0]?l.substr(1,l.length-2):l,r+a(l)+"{"+i+"};"+o},"")}(W,v),O=u.parentPath;if(O.isTemplateLiteral()){var P=O.get("expressions").indexOf(u),z=O.get("quasis")[P],A=O.get("quasis")[P+1];A.node.value.raw=z.node.value.raw+E+A.node.value.raw,A.node.value.cooked=z.node.value.cooked+E+A.node.value.cooked,z.remove(),u.remove();var C=o.parseExpression(n(O.node).code);O.replaceWith(C)}else{u.replaceWith(o.parseExpression("`"+E+"`"))}}else u.replaceWith("StringLiteral"===u.node.type?b.callExpression(S,[L]):L)}function a(e){return e.replace(/[A-Z]/g,"-$&").toLowerCase().replace(/^(ms|o|moz|webkit)-/,"-$1-")}function l(e,t){var r="",o="";return t&&e.preDev?r=e.preDev:e.pre&&(r=e.pre),t&&e.postDev?o=e.postDev:e.post&&(o=e.post),{pre:r,post:o}}function p(e,t){return Object.assign({},e,t)}function s(e,t){if(null===e)return t.nullLiteral();switch(typeof e){case"function":var r=o.parse(e.toString(),{allowReturnOutsideFunction:!0,allowSuperOutsideMethod:!0});return traverse.removeProperties(r);case"number":return t.numericLiteral(e);case"string":return e.startsWith("$")?o.parseExpression(e.substr(1)):t.stringLiteral(e);case"boolean":return t.booleanLiteral(e);case"undefined":return t.unaryExpression("void",t.numericLiteral(0),!0);default:if(Array.isArray(e))return t.arrayExpression(e.map(function(e){return s(e,t)}));try{return t.objectExpression(c(e,t,"spreadElement"))}catch(r){return t.objectExpression(c(e,t,"spreadProperty"))}}}function c(e,t,r){return Object.keys(e).filter(function(t){return void 0!==e[t]}).map(function(n){if(n.startsWith("__spread__"))return t[r](o.parseExpression(e[n]));var i=n.startsWith("`"),a=i?o.parseExpression(n):t.stringLiteral(n);return t.objectProperty(a,s(e[n],t),i)})}function f(e,t,r){t.split&&(t=t.split("."));for(var o,n=0,i=t.length,a=e;n<i;++n)o=a[t[n]],a=a[t[n]]=n===i-1?r:null==o?{}:o}function d(e,t,r,o){for(o=0,t=t.split?t.split("."):t;e&&o<t.length;)e=e[t[o++]];return void 0===e||o<t.length?r:e}var g=require("path");module.exports=function(e){var t=e.types,r=t.cloneNode||t.cloneDeep;return{visitor:{TaggedTemplateExpression:function(e,r){"tw"===e.node.tag.name&&i({path:e,configPath:g.resolve(r.file.opts.sourceRoot||".",r.opts.config||"./tailwind.js"),t:t,outputFormat:r.opts.format})},JSXAttribute:function(e,o){if("tw"===e.node.name.name){var n=g.resolve(o.file.opts.sourceRoot||".",o.opts.config||"./tailwind.js");"StringLiteral"===e.node.value.type&&e.get("value").replaceWith(t.jSXExpressionContainer(r(e.node.value))),e.traverse({ArrayExpression:function(e){var o=e.findParent(function(e){return e.isProgram()}),n=o.scope.generateUidIdentifier("cx");o.unshiftContainer("body",t.importDeclaration([t.importSpecifier(n,t.identifier("cx"))],t.stringLiteral("emotion"))),e.replaceWith(t.callExpression(r(n),e.get("elements").map(function(e){return r(e.node)}))),e.skip()}}),e.traverse({StringLiteral:function(e){i({path:e,configPath:n,t:t,outputFormat:o.opts.format}),e.skip()}})}}}}};
//# sourceMappingURL=index.js.map
{
"name": "babel-plugin-tailwind-components",
"version": "0.5.6",
"version": "0.5.7",
"description": "Use Tailwind with any CSS-in-JS library",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc