mirror of
https://github.com/idanoo/GoScrobble.git
synced 2024-11-24 09:25:15 +00:00
1 line
4.1 KiB
Plaintext
1 line
4.1 KiB
Plaintext
{"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.indexOf('--') === 0 ? 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.indexOf('--') === 0) {\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","indexOf","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;AACd;EACA,SAAS,aAAa,CAAC,KAAK,EAAE;EAC9B,EAAE,OAAO,GAAG,GAAG,KAAK,CAAC,WAAW,EAAE;EAClC,CAAC;AACD;EACA,SAAS,kBAAkB,CAAC,IAAI,EAAE;EAClC,EAAE,IAAI,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE;EAClC,IAAI,OAAO,KAAK,CAAC,IAAI,CAAC;EACtB,GAAG;AACH;EACA,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;;ECZA;;;;;;;EAMA,SAASA,WAAT,CAAqBC,KAArB,EAA4B;EAC1B,MAAMC,SAAS,GAAG,EAAlB;;EAEA,OAAK,IAAMC,IAAX,IAAmBF,KAAnB,EAA0B;EACxB,QAAMG,GAAG,GAAGD,IAAI,CAACE,OAAL,CAAa,IAAb,MAAuB,CAAvB,GAA2BF,IAA3B,GAAkCG,kBAAS,CAACH,IAAD,CAAvD;EAEAD,IAAAA,SAAS,CAACE,GAAD,CAAT,GAAiBH,KAAK,CAACE,IAAD,CAAtB;EACD;;EAED,MAAIF,KAAK,CAACM,SAAV,EAAqB;EACnB,QAAIC,KAAK,CAACC,OAAN,CAAcR,KAAK,CAACM,SAApB,CAAJ,EAAoCL,SAAS,CAACK,SAAV,GAAsBN,KAAK,CAACM,SAAN,CAAgBG,GAAhB,CAAoBV,WAApB,CAAtB,CAApC,KACKE,SAAS,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