css-styled
Advanced tools
Comparing version 0.2.2 to 0.2.3
@@ -7,3 +7,3 @@ /* | ||
repository: git+https://github.com/daybrush/css-styled.git | ||
version: 0.2.2 | ||
version: 0.2.3 | ||
*/ | ||
@@ -10,0 +10,0 @@ 'use strict'; |
@@ -7,3 +7,3 @@ /* | ||
repository: git+https://github.com/daybrush/css-styled.git | ||
version: 0.2.2 | ||
version: 0.2.3 | ||
*/ | ||
@@ -10,0 +10,0 @@ import { splitComma } from '@daybrush/utils'; |
@@ -7,3 +7,3 @@ /* | ||
repository: git+https://github.com/daybrush/css-styled.git | ||
version: 0.2.2 | ||
version: 0.2.3 | ||
*/ | ||
@@ -38,4 +38,73 @@ (function (global, factory) { | ||
repository: https://github.com/daybrush/utils | ||
@version 0.10.1 | ||
@version 1.0.0 | ||
*/ | ||
var OPEN_CLOSED_CHARACTER = ["\"", "'", "\\\"", "\\'"]; | ||
function findClosed(closedCharacter, texts, index, length) { | ||
for (var i = index; i < length; ++i) { | ||
var character = texts[i].trim(); | ||
if (character === closedCharacter) { | ||
return i; | ||
} | ||
var nextIndex = i; | ||
if (character === "(") { | ||
nextIndex = findClosed(")", texts, i + 1, length); | ||
} else if (OPEN_CLOSED_CHARACTER.indexOf(character) > -1) { | ||
nextIndex = findClosed(character, texts, i + 1, length); | ||
} | ||
if (nextIndex === -1) { | ||
break; | ||
} | ||
i = nextIndex; | ||
} | ||
return -1; | ||
} | ||
function splitText(text, separator) { | ||
var regexText = "(\\s*" + (separator || ",") + "\\s*|\\(|\\)|\"|'|\\\\\"|\\\\'|\\s+)"; | ||
var regex = new RegExp(regexText, "g"); | ||
var texts = text.split(regex).filter(Boolean); | ||
var length = texts.length; | ||
var values = []; | ||
var tempValues = []; | ||
for (var i = 0; i < length; ++i) { | ||
var character = texts[i].trim(); | ||
var nextIndex = i; | ||
if (character === "(") { | ||
nextIndex = findClosed(")", texts, i + 1, length); | ||
} else if (character === ")") { | ||
throw new Error("invalid format"); | ||
} else if (OPEN_CLOSED_CHARACTER.indexOf(character) > -1) { | ||
nextIndex = findClosed(character, texts, i + 1, length); | ||
} else if (character === separator) { | ||
if (tempValues.length) { | ||
values.push(tempValues.join("")); | ||
tempValues = []; | ||
} | ||
continue; | ||
} | ||
if (nextIndex === -1) { | ||
nextIndex = length - 1; | ||
} | ||
tempValues.push(texts.slice(i, nextIndex + 1).join("")); | ||
i = nextIndex; | ||
} | ||
if (tempValues.length) { | ||
values.push(tempValues.join("")); | ||
} | ||
return values; | ||
} | ||
/** | ||
@@ -58,6 +127,3 @@ * divide text by comma. | ||
// "[^"]*"|'[^']*' | ||
var matches = text.match(/("[^"]*"|'[^']*'|[^,\s()]*\((?:[^()]*|\([^()]*\))*\)[^,\s()]*|[^,])+/g); | ||
return matches ? matches.map(function (str) { | ||
return str.trim(); | ||
}) : []; | ||
return splitText(text, ","); | ||
} | ||
@@ -64,0 +130,0 @@ |
@@ -7,5 +7,5 @@ /* | ||
repository: git+https://github.com/daybrush/css-styled.git | ||
version: 0.2.2 | ||
version: 0.2.3 | ||
*/ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).styled=t()}(this,function(){"use strict";var e=function(e){for(var t=5381,n=e.length;n;)t=33*t^e.charCodeAt(--n);return t>>>0};function a(o,e,t,n){var r=document.createElement("style");r.setAttribute("type","text/css"),r.setAttribute("data-styled-id",o),t.nonce&&r.setAttribute("nonce",t.nonce);var i=e;return t.original||(i=e.replace(/([^}{]*){/gm,function(e,t){return((n=t.match(/("[^"]*"|'[^']*'|[^,\s()]*\((?:[^()]*|\([^()]*\))*\)[^,\s()]*|[^,])+/g))?n.map(function(e){return e.trim()}):[]).map(function(e){return-1<e.indexOf(":global")?e.replace(/\:global/g,""):-1<e.indexOf(":host")?""+e.replace(/\:host/g,"."+o):"."+o+" "+e}).join(", ")+"{";var n})),r.innerHTML=i,(n||document.head||document.body).appendChild(r),r}return function(i){var u,d="rCS"+e(i).toString(36),c=0;return{className:d,inject:function(e,t){void 0===t&&(t={});var n,o=function(e){if(e&&e.getRootNode){var t=e.getRootNode();if(11===t.nodeType)return t}}(e),r=0===c;return(o||r)&&(n=a(d,i,t,o)),r&&(u=n),o||++c,{destroy:function(){o?(e.removeChild(n),n=null):(0<c&&--c,0===c&&u&&(u.parentNode.removeChild(u),u=null))}}}}}}); | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e=e||self).styled=n()}(this,function(){"use strict";var e=function(e){for(var n=5381,t=e.length;t;)n=33*n^e.charCodeAt(--t);return n>>>0},d=['"',"'",'\\"',"\\'"];function c(e,n,t,r){for(var o=t;o<r;++o){var i=n[o].trim();if(i===e)return o;var u=o;if("("===i?u=c(")",n,o+1,r):-1<d.indexOf(i)&&(u=c(i,n,o+1,r)),-1===u)break;o=u}return-1}function a(e){return function(e,n){for(var t=new RegExp("(\\s*"+(n||",")+"\\s*|\\(|\\)|\"|'|\\\\\"|\\\\'|\\s+)","g"),r=e.split(t).filter(Boolean),o=r.length,i=[],u=[],f=0;f<o;++f){var l=r[f].trim(),a=f;if("("===l)a=c(")",r,f+1,o);else{if(")"===l)throw new Error("invalid format");if(-1<d.indexOf(l))a=c(l,r,f+1,o);else if(l===n){u.length&&(i.push(u.join("")),u=[]);continue}}-1===a&&(a=o-1),u.push(r.slice(f,a+1).join("")),f=a}return u.length&&i.push(u.join("")),i}(e,",")}return function(i){var u,f="rCS"+e(i).toString(36),l=0;return{className:f,inject:function(e,n){void 0===n&&(n={});var t,r=function(e){if(e&&e.getRootNode){var n=e.getRootNode();if(11===n.nodeType)return n}}(e),o=0===l;return(r||o)&&(t=function(t,e,n,r){var o=document.createElement("style");o.setAttribute("type","text/css"),o.setAttribute("data-styled-id",t),n.nonce&&o.setAttribute("nonce",n.nonce);var i=e;return n.original||(i=e.replace(/([^}{]*){/gm,function(e,n){return a(n).map(function(e){return-1<e.indexOf(":global")?e.replace(/\:global/g,""):-1<e.indexOf(":host")?""+e.replace(/\:host/g,"."+t):"."+t+" "+e}).join(", ")+"{"})),o.innerHTML=i,(r||document.head||document.body).appendChild(o),o}(f,i,n,r)),o&&(u=t),r||++l,{destroy:function(){r?(e.removeChild(t),t=null):(0<l&&--l,0===l&&u&&(u.parentNode.removeChild(u),u=null))}}}}}}); | ||
//# sourceMappingURL=styled.min.js.map |
{ | ||
"name": "css-styled", | ||
"version": "0.2.2", | ||
"version": "0.2.3", | ||
"description": "This component is a lightweight, simple line style component.", | ||
@@ -14,5 +14,5 @@ "main": "./dist/styled.cjs.js", | ||
"doc": "rm -rf ./doc && jsdoc -c jsdoc.json", | ||
"prerelease": "npm run build && prerelease --dirs=dist,doc", | ||
"release": "npm run build && npm run doc && release --dirs=dist,doc", | ||
"release:init": "npm run build && npm run doc && release -i --dirs=dist,doc", | ||
"prerelease": "npm run build && prerelease --dirs=dist", | ||
"release": "npm run build && release --dirs=dist", | ||
"release:init": "npm run build && release -i --dirs=dist", | ||
"packages": "pvu --path=packages --update=react-css-styled" | ||
@@ -31,3 +31,3 @@ }, | ||
"dependencies": { | ||
"@daybrush/utils": "^0.10.1", | ||
"@daybrush/utils": "^1.0.0", | ||
"string-hash": "^1.1.3" | ||
@@ -46,4 +46,4 @@ }, | ||
"peerDependencies": { | ||
"@daybrush/utils": ">=0.10.1" | ||
"@daybrush/utils": ">=1.0.0" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
48717
658
+ Added@daybrush/utils@1.13.0(transitive)
- Removed@daybrush/utils@0.10.5(transitive)
Updated@daybrush/utils@^1.0.0