jss-plugin-camel-case
Advanced tools
@@ -0,1 +1,2 @@ | ||
| /* eslint-disable no-var, prefer-template */ | ||
| var uppercasePattern = /[A-Z]/g; | ||
@@ -5,13 +6,15 @@ var msPattern = /^ms-/; | ||
| function hyphenateStyleName(string) { | ||
| return string in cache | ||
| ? cache[string] | ||
| : cache[string] = string | ||
| .replace(uppercasePattern, '-$&') | ||
| .toLowerCase() | ||
| .replace(msPattern, '-ms-'); | ||
| function toHyphenLower(match) { | ||
| return '-' + match.toLowerCase() | ||
| } | ||
| var hyphenateStyleName_1 = hyphenateStyleName; | ||
| function hyphenateStyleName(name) { | ||
| if (cache.hasOwnProperty(name)) { | ||
| return cache[name] | ||
| } | ||
| var hName = name.replace(uppercasePattern, toHyphenLower); | ||
| return (cache[name] = msPattern.test(hName) ? '-' + hName : hName) | ||
| } | ||
| /** | ||
@@ -28,3 +31,3 @@ * Convert camel cased property names to dash separated. | ||
| for (var prop in style) { | ||
| var key = prop.startsWith('--') ? prop : hyphenateStyleName_1(prop); | ||
| var key = prop.startsWith('--') ? prop : hyphenateStyleName(prop); | ||
| converted[key] = style[prop]; | ||
@@ -65,3 +68,3 @@ } | ||
| var hyphenatedProp = hyphenateStyleName_1(prop); // There was no camel case in place | ||
| var hyphenatedProp = hyphenateStyleName(prop); // There was no camel case in place | ||
@@ -68,0 +71,0 @@ if (prop === hyphenatedProp) return value; |
| (function (global, factory) { | ||
| typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : | ||
| typeof define === 'function' && define.amd ? define(['exports'], factory) : | ||
| (factory((global.jssPluginCamelCase = {}))); | ||
| }(this, (function (exports) { 'use strict'; | ||
| typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : | ||
| typeof define === 'function' && define.amd ? define(['exports'], factory) : | ||
| (global = global || self, factory(global.jssPluginCamelCase = {})); | ||
| }(this, function (exports) { 'use strict'; | ||
| var uppercasePattern = /[A-Z]/g; | ||
| var msPattern = /^ms-/; | ||
| var cache = {}; | ||
| /* eslint-disable no-var, prefer-template */ | ||
| var uppercasePattern = /[A-Z]/g; | ||
| var msPattern = /^ms-/; | ||
| var cache = {}; | ||
| function hyphenateStyleName(string) { | ||
| return string in cache | ||
| ? cache[string] | ||
| : cache[string] = string | ||
| .replace(uppercasePattern, '-$&') | ||
| .toLowerCase() | ||
| .replace(msPattern, '-ms-'); | ||
| function toHyphenLower(match) { | ||
| return '-' + match.toLowerCase() | ||
| } | ||
| function hyphenateStyleName(name) { | ||
| if (cache.hasOwnProperty(name)) { | ||
| return cache[name] | ||
| } | ||
| var hyphenateStyleName_1 = hyphenateStyleName; | ||
| var hName = name.replace(uppercasePattern, toHyphenLower); | ||
| return (cache[name] = msPattern.test(hName) ? '-' + hName : hName) | ||
| } | ||
| /** | ||
| * Convert camel cased property names to dash separated. | ||
| * | ||
| * @param {Object} style | ||
| * @return {Object} | ||
| */ | ||
| /** | ||
| * Convert camel cased property names to dash separated. | ||
| * | ||
| * @param {Object} style | ||
| * @return {Object} | ||
| */ | ||
| function convertCase(style) { | ||
| var converted = {}; | ||
| function convertCase(style) { | ||
| var converted = {}; | ||
| for (var prop in style) { | ||
| var key = prop.startsWith('--') ? prop : hyphenateStyleName_1(prop); | ||
| converted[key] = style[prop]; | ||
| } | ||
| for (var prop in style) { | ||
| var key = prop.startsWith('--') ? prop : hyphenateStyleName(prop); | ||
| converted[key] = style[prop]; | ||
| } | ||
| if (style.fallbacks) { | ||
| if (Array.isArray(style.fallbacks)) converted.fallbacks = style.fallbacks.map(convertCase);else converted.fallbacks = convertCase(style.fallbacks); | ||
| } | ||
| return converted; | ||
| if (style.fallbacks) { | ||
| if (Array.isArray(style.fallbacks)) converted.fallbacks = style.fallbacks.map(convertCase);else converted.fallbacks = convertCase(style.fallbacks); | ||
| } | ||
| /** | ||
| * Allow camel cased property names by converting them back to dasherized. | ||
| * | ||
| * @param {Rule} rule | ||
| */ | ||
| return converted; | ||
| } | ||
| /** | ||
| * Allow camel cased property names by converting them back to dasherized. | ||
| * | ||
| * @param {Rule} rule | ||
| */ | ||
| function camelCase() { | ||
| function onProcessStyle(style) { | ||
| if (Array.isArray(style)) { | ||
| // Handle rules like @font-face, which can have multiple styles in an array | ||
| for (var index = 0; index < style.length; index++) { | ||
| style[index] = convertCase(style[index]); | ||
| } | ||
| return style; | ||
| function camelCase() { | ||
| function onProcessStyle(style) { | ||
| if (Array.isArray(style)) { | ||
| // Handle rules like @font-face, which can have multiple styles in an array | ||
| for (var index = 0; index < style.length; index++) { | ||
| style[index] = convertCase(style[index]); | ||
| } | ||
| return convertCase(style); | ||
| return style; | ||
| } | ||
| function onChangeValue(value, prop, rule) { | ||
| if (prop.startsWith('--')) { | ||
| return value; | ||
| } | ||
| return convertCase(style); | ||
| } | ||
| var hyphenatedProp = hyphenateStyleName_1(prop); // There was no camel case in place | ||
| function onChangeValue(value, prop, rule) { | ||
| if (prop.startsWith('--')) { | ||
| return value; | ||
| } | ||
| if (prop === hyphenatedProp) return value; | ||
| rule.prop(hyphenatedProp, value); // Core will ignore that property value we set the proper one above. | ||
| var hyphenatedProp = hyphenateStyleName(prop); // There was no camel case in place | ||
| return null; | ||
| } | ||
| if (prop === hyphenatedProp) return value; | ||
| rule.prop(hyphenatedProp, value); // Core will ignore that property value we set the proper one above. | ||
| return { | ||
| onProcessStyle: onProcessStyle, | ||
| onChangeValue: onChangeValue | ||
| }; | ||
| return null; | ||
| } | ||
| exports.default = camelCase; | ||
| return { | ||
| onProcessStyle: onProcessStyle, | ||
| onChangeValue: onChangeValue | ||
| }; | ||
| } | ||
| Object.defineProperty(exports, '__esModule', { value: true }); | ||
| exports.default = camelCase; | ||
| }))); | ||
| Object.defineProperty(exports, '__esModule', { value: true }); | ||
| })); | ||
| //# sourceMappingURL=jss-plugin-camel-case.js.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"jss-plugin-camel-case.js","sources":["../../../node_modules/hyphenate-style-name/index.js","../src/index.js"],"sourcesContent":["'use strict';\n\nvar uppercasePattern = /[A-Z]/g;\nvar msPattern = /^ms-/;\nvar cache = {};\n\nfunction hyphenateStyleName(string) {\n return string in cache\n ? cache[string]\n : cache[string] = string\n .replace(uppercasePattern, '-$&')\n .toLowerCase()\n .replace(msPattern, '-ms-');\n}\n\nmodule.exports = hyphenateStyleName;\n","// @flow\nimport type {Plugin} from 'jss'\nimport hyphenate from 'hyphenate-style-name'\n\n/**\n * Convert camel cased property names to dash separated.\n *\n * @param {Object} style\n * @return {Object}\n */\nfunction convertCase(style) {\n const converted = {}\n\n for (const prop in style) {\n const key = prop.startsWith('--') ? prop : hyphenate(prop)\n\n converted[key] = style[prop]\n }\n\n if (style.fallbacks) {\n if (Array.isArray(style.fallbacks)) converted.fallbacks = style.fallbacks.map(convertCase)\n else converted.fallbacks = convertCase(style.fallbacks)\n }\n\n return converted\n}\n\n/**\n * Allow camel cased property names by converting them back to dasherized.\n *\n * @param {Rule} rule\n */\nexport default function camelCase(): Plugin {\n function onProcessStyle(style) {\n if (Array.isArray(style)) {\n // Handle rules like @font-face, which can have multiple styles in an array\n for (let index = 0; index < style.length; index++) {\n style[index] = convertCase(style[index])\n }\n return style\n }\n\n return convertCase(style)\n }\n\n function onChangeValue(value, prop, rule) {\n if (prop.startsWith('--')) {\n return value\n }\n\n const hyphenatedProp = hyphenate(prop)\n\n // There was no camel case in place\n if (prop === hyphenatedProp) return value\n\n rule.prop(hyphenatedProp, value)\n\n // Core will ignore that property value we set the proper one above.\n return null\n }\n\n return {onProcessStyle, onChangeValue}\n}\n"],"names":["convertCase","style","converted","prop","key","startsWith","hyphenate","fallbacks","Array","isArray","map","camelCase","onProcessStyle","index","length","onChangeValue","value","rule","hyphenatedProp"],"mappings":";;;;;;IAEA,IAAI,gBAAgB,GAAG,QAAQ,CAAC;IAChC,IAAI,SAAS,GAAG,MAAM,CAAC;IACvB,IAAI,KAAK,GAAG,EAAE,CAAC;;IAEf,SAAS,kBAAkB,CAAC,MAAM,EAAE;QAChC,OAAO,MAAM,IAAI,KAAK;UACpB,KAAK,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C,KAAD,CAAlB;IACD;;IAED,WAASc,aAAT,CAAuBC,KAAvB,EAA8Bb,IAA9B,EAAoCc,IAApC,EAA0C;IACxC,QAAId,IAAI,CAACE,UAAL,CAAgB,IAAhB,CAAJ,EAA2B;IACzB,aAAOW,KAAP;IACD;;IAED,QAAME,cAAc,GAAGZ,oBAAS,CAACH,IAAD,CAAhC,CALwC;;IAQxC,QAAIA,IAAI,KAAKe,cAAb,EAA6B,OAAOF,KAAP;IAE7BC,IAAAA,IAAI,CAACd,IAAL,CAAUe,cAAV,EAA0BF,KAA1B,EAVwC;;IAaxC,WAAO,IAAP;IACD;;IAED,SAAO;IAACJ,IAAAA,cAAc,EAAdA,cAAD;IAAiBG,IAAAA,aAAa,EAAbA;IAAjB,GAAP;IACD;;;;;;;;;;;;"} | ||
| {"version":3,"file":"jss-plugin-camel-case.js","sources":["../../../node_modules/hyphenate-style-name/index.js","../src/index.js"],"sourcesContent":["/* eslint-disable no-var, prefer-template */\nvar uppercasePattern = /[A-Z]/g\nvar msPattern = /^ms-/\nvar cache = {}\n\nfunction toHyphenLower(match) {\n return '-' + match.toLowerCase()\n}\n\nfunction hyphenateStyleName(name) {\n if (cache.hasOwnProperty(name)) {\n return cache[name]\n }\n\n var hName = name.replace(uppercasePattern, toHyphenLower)\n return (cache[name] = msPattern.test(hName) ? '-' + hName : hName)\n}\n\nexport default hyphenateStyleName\n","// @flow\nimport type {Plugin} from 'jss'\nimport hyphenate from 'hyphenate-style-name'\n\n/**\n * Convert camel cased property names to dash separated.\n *\n * @param {Object} style\n * @return {Object}\n */\nfunction convertCase(style) {\n const converted = {}\n\n for (const prop in style) {\n const key = prop.startsWith('--') ? prop : hyphenate(prop)\n\n converted[key] = style[prop]\n }\n\n if (style.fallbacks) {\n if (Array.isArray(style.fallbacks)) converted.fallbacks = style.fallbacks.map(convertCase)\n else converted.fallbacks = convertCase(style.fallbacks)\n }\n\n return converted\n}\n\n/**\n * Allow camel cased property names by converting them back to dasherized.\n *\n * @param {Rule} rule\n */\nexport default function camelCase(): Plugin {\n function onProcessStyle(style) {\n if (Array.isArray(style)) {\n // Handle rules like @font-face, which can have multiple styles in an array\n for (let index = 0; index < style.length; index++) {\n style[index] = convertCase(style[index])\n }\n return style\n }\n\n return convertCase(style)\n }\n\n function onChangeValue(value, prop, rule) {\n if (prop.startsWith('--')) {\n return value\n }\n\n const hyphenatedProp = hyphenate(prop)\n\n // There was no camel case in place\n if (prop === hyphenatedProp) return value\n\n rule.prop(hyphenatedProp, value)\n\n // Core will ignore that property value we set the proper one above.\n return null\n }\n\n return {onProcessStyle, onChangeValue}\n}\n"],"names":["convertCase","style","converted","prop","key","startsWith","hyphenate","fallbacks","Array","isArray","map","camelCase","onProcessStyle","index","length","onChangeValue","value","rule","hyphenatedProp"],"mappings":";;;;;;EAAA;EACA,IAAI,gBAAgB,GAAG,SAAQ;EAC/B,IAAI,SAAS,GAAG,OAAM;EACtB,IAAI,KAAK,GAAG,GAAE;;EAEd,SAAS,aAAa,CAAC,KAAK,EAAE;EAC9B,EAAE,OAAO,GAAG,GAAG,KAAK,CAAC,WAAW,EAAE;EAClC,CAAC;;EAED,SAAS,kBAAkB,CAAC,IAAI,EAAE;EAClC,EAAE,IAAI,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE;EAClC,IAAI,OAAO,KAAK,CAAC,IAAI,CAAC;EACtB,GAAG;;EAEH,EAAE,IAAI,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,gBAAgB,EAAE,aAAa,EAAC;EAC3D,EAAE,QAAQ,KAAK,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,GAAG,GAAG,KAAK,GAAG,KAAK,CAAC;EACpE,CAAC;;ECZD;;;;;;;EAMA,SAASA,WAAT,CAAqBC,KAArB,EAA4B;EAC1B,MAAMC,SAAS,GAAG,EAAlB;;EAEA,OAAK,IAAMC,IAAX,IAAmBF,KAAnB,EAA0B;EACxB,QAAMG,GAAG,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C,WAAO,IAAP;EACD;;EAED,SAAO;EAACJ,IAAAA,cAAc,EAAdA,cAAD;EAAiBG,IAAAA,aAAa,EAAbA;EAAjB,GAAP;EACD;;;;;;;;;;;;"} |
@@ -1,1 +0,1 @@ | ||
| !function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r(e.jssPluginCamelCase={})}(this,function(e){"use strict";var r=/[A-Z]/g,n=/^ms-/,t={};var a=function(e){return e in t?t[e]:t[e]=e.replace(r,"-$&").toLowerCase().replace(n,"-ms-")};function f(e){var r={};for(var n in e){r[n.startsWith("--")?n:a(n)]=e[n]}return e.fallbacks&&(Array.isArray(e.fallbacks)?r.fallbacks=e.fallbacks.map(f):r.fallbacks=f(e.fallbacks)),r}e.default=function(){return{onProcessStyle:function(e){if(Array.isArray(e)){for(var r=0;r<e.length;r++)e[r]=f(e[r]);return e}return f(e)},onChangeValue:function(e,r,n){if(r.startsWith("--"))return e;var t=a(r);return r===t?e:(n.prop(t,e),null)}}},Object.defineProperty(e,"__esModule",{value:!0})}); | ||
| !function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r((e=e||self).jssPluginCamelCase={})}(this,function(e){"use strict";var r=/[A-Z]/g,t=/^ms-/,n={};function a(e){return"-"+e.toLowerCase()}function f(e){if(n.hasOwnProperty(e))return n[e];var f=e.replace(r,a);return n[e]=t.test(f)?"-"+f:f}function s(e){var r={};for(var t in e){r[t.startsWith("--")?t:f(t)]=e[t]}return e.fallbacks&&(Array.isArray(e.fallbacks)?r.fallbacks=e.fallbacks.map(s):r.fallbacks=s(e.fallbacks)),r}e.default=function(){return{onProcessStyle:function(e){if(Array.isArray(e)){for(var r=0;r<e.length;r++)e[r]=s(e[r]);return e}return s(e)},onChangeValue:function(e,r,t){if(r.startsWith("--"))return e;var n=f(r);return r===n?e:(t.prop(n,e),null)}}},Object.defineProperty(e,"__esModule",{value:!0})}); |
+6
-6
| { | ||
| "name": "jss-plugin-camel-case", | ||
| "description": "JSS plugin that allows to write camel cased rule properties", | ||
| "version": "10.0.0-alpha.10", | ||
| "version": "10.0.0-alpha.11", | ||
| "license": "MIT", | ||
@@ -40,10 +40,10 @@ "homepage": "https://cssinjs.org/jss-camel-case", | ||
| "devDependencies": { | ||
| "jss-plugin-rule-value-function": "10.0.0-alpha.10" | ||
| "jss-plugin-rule-value-function": "10.0.0-alpha.11" | ||
| }, | ||
| "dependencies": { | ||
| "@babel/runtime": "^7.0.0", | ||
| "hyphenate-style-name": "^1.0.2", | ||
| "jss": "10.0.0-alpha.10" | ||
| "@babel/runtime": "^7.3.1", | ||
| "hyphenate-style-name": "^1.0.3", | ||
| "jss": "10.0.0-alpha.11" | ||
| }, | ||
| "gitHead": "953234ad4e69b2f3d00fb9d683fba24865d2c4dd" | ||
| "gitHead": "79343bda7df92609218aea1c9907297051cfc6ed" | ||
| } |
+1
-1
@@ -12,3 +12,3 @@ # jss-plugin-camel-case | ||
| See our website [jss-plugin-camel-case](https://cssinjs.org/jss-plugin-camel-case?v=v10.0.0-alpha.10) for more information. | ||
| See our website [jss-plugin-camel-case](https://cssinjs.org/jss-plugin-camel-case?v=v10.0.0-alpha.11) for more information. | ||
@@ -15,0 +15,0 @@ ## Install |
22183
1.74%468
0.86%+ Added
- Removed
Updated
Updated
Updated