jss-plugin-expand
Advanced tools
Comparing version 10.0.0-alpha.12 to 10.0.0-alpha.13
@@ -213,2 +213,3 @@ /** | ||
/* eslint-disable no-use-before-define */ | ||
/** | ||
@@ -222,3 +223,2 @@ * Map values by given prop. | ||
*/ | ||
function mapValuesByProp(value, prop, rule) { | ||
@@ -231,8 +231,2 @@ return value.map(function (item) { | ||
* Convert array to nested array, if needed | ||
* | ||
* @param {Array} array of values | ||
* @param {String} original property | ||
* @param {Object} sheme, for converting arrays in strings | ||
* @param {Object} original rule | ||
* @return {String} converted string | ||
*/ | ||
@@ -254,9 +248,2 @@ | ||
* Convert object to array. | ||
* | ||
* @param {Object} object of values | ||
* @param {String} original property | ||
* @param {Object} original rule | ||
* @param {Boolean} is fallback prop | ||
* @param {Boolean} object is inside array | ||
* @return {String} converted string | ||
*/ | ||
@@ -297,8 +284,2 @@ | ||
* Convert custom properties values to styles adding them to rule directly | ||
* | ||
* @param {Object} object of values | ||
* @param {Object} original rule | ||
* @param {String} property, that contain partial custom properties | ||
* @param {Boolean} is fallback prop | ||
* @return {Object} value without custom properties, that was already added to rule | ||
*/ | ||
@@ -327,7 +308,2 @@ | ||
* Detect if a style needs to be converted. | ||
* | ||
* @param {Object} style | ||
* @param {Object} rule | ||
* @param {Boolean} is fallback prop | ||
* @return {Object} convertedStyle | ||
*/ | ||
@@ -344,5 +320,3 @@ | ||
if (prop === 'fallbacks') { | ||
// $FlowFixMe: Flow has problems with knowing that the fallback prop actually exists | ||
for (var index = 0; index < style.fallbacks.length; index++) { | ||
// $FlowFixMe: Flow has problems with knowing that the fallback prop actually exists | ||
style.fallbacks[index] = styleDetector(style.fallbacks[index], rule, true); | ||
@@ -360,3 +334,2 @@ } | ||
if (prop === 'fallbacks') { | ||
// $FlowFixMe: Flow has problems with knowing that the fallback prop actually exists | ||
style.fallbacks = styleDetector(style.fallbacks, rule, true); | ||
@@ -377,5 +350,2 @@ continue; | ||
* Adds possibility to write expanded styles. | ||
* | ||
* @param {Rule} rule | ||
* @api public | ||
*/ | ||
@@ -382,0 +352,0 @@ |
@@ -217,2 +217,3 @@ 'use strict'; | ||
/* eslint-disable no-use-before-define */ | ||
/** | ||
@@ -226,3 +227,2 @@ * Map values by given prop. | ||
*/ | ||
function mapValuesByProp(value, prop, rule) { | ||
@@ -235,8 +235,2 @@ return value.map(function (item) { | ||
* Convert array to nested array, if needed | ||
* | ||
* @param {Array} array of values | ||
* @param {String} original property | ||
* @param {Object} sheme, for converting arrays in strings | ||
* @param {Object} original rule | ||
* @return {String} converted string | ||
*/ | ||
@@ -258,9 +252,2 @@ | ||
* Convert object to array. | ||
* | ||
* @param {Object} object of values | ||
* @param {String} original property | ||
* @param {Object} original rule | ||
* @param {Boolean} is fallback prop | ||
* @param {Boolean} object is inside array | ||
* @return {String} converted string | ||
*/ | ||
@@ -301,8 +288,2 @@ | ||
* Convert custom properties values to styles adding them to rule directly | ||
* | ||
* @param {Object} object of values | ||
* @param {Object} original rule | ||
* @param {String} property, that contain partial custom properties | ||
* @param {Boolean} is fallback prop | ||
* @return {Object} value without custom properties, that was already added to rule | ||
*/ | ||
@@ -331,7 +312,2 @@ | ||
* Detect if a style needs to be converted. | ||
* | ||
* @param {Object} style | ||
* @param {Object} rule | ||
* @param {Boolean} is fallback prop | ||
* @return {Object} convertedStyle | ||
*/ | ||
@@ -348,5 +324,3 @@ | ||
if (prop === 'fallbacks') { | ||
// $FlowFixMe: Flow has problems with knowing that the fallback prop actually exists | ||
for (var index = 0; index < style.fallbacks.length; index++) { | ||
// $FlowFixMe: Flow has problems with knowing that the fallback prop actually exists | ||
style.fallbacks[index] = styleDetector(style.fallbacks[index], rule, true); | ||
@@ -364,3 +338,2 @@ } | ||
if (prop === 'fallbacks') { | ||
// $FlowFixMe: Flow has problems with knowing that the fallback prop actually exists | ||
style.fallbacks = styleDetector(style.fallbacks, rule, true); | ||
@@ -381,5 +354,2 @@ continue; | ||
* Adds possibility to write expanded styles. | ||
* | ||
* @param {Rule} rule | ||
* @api public | ||
*/ | ||
@@ -386,0 +356,0 @@ |
@@ -213,2 +213,3 @@ /** | ||
/* eslint-disable no-use-before-define */ | ||
/** | ||
@@ -222,3 +223,2 @@ * Map values by given prop. | ||
*/ | ||
function mapValuesByProp(value, prop, rule) { | ||
@@ -231,8 +231,2 @@ return value.map(function (item) { | ||
* Convert array to nested array, if needed | ||
* | ||
* @param {Array} array of values | ||
* @param {String} original property | ||
* @param {Object} sheme, for converting arrays in strings | ||
* @param {Object} original rule | ||
* @return {String} converted string | ||
*/ | ||
@@ -254,9 +248,2 @@ | ||
* Convert object to array. | ||
* | ||
* @param {Object} object of values | ||
* @param {String} original property | ||
* @param {Object} original rule | ||
* @param {Boolean} is fallback prop | ||
* @param {Boolean} object is inside array | ||
* @return {String} converted string | ||
*/ | ||
@@ -297,8 +284,2 @@ | ||
* Convert custom properties values to styles adding them to rule directly | ||
* | ||
* @param {Object} object of values | ||
* @param {Object} original rule | ||
* @param {String} property, that contain partial custom properties | ||
* @param {Boolean} is fallback prop | ||
* @return {Object} value without custom properties, that was already added to rule | ||
*/ | ||
@@ -327,7 +308,2 @@ | ||
* Detect if a style needs to be converted. | ||
* | ||
* @param {Object} style | ||
* @param {Object} rule | ||
* @param {Boolean} is fallback prop | ||
* @return {Object} convertedStyle | ||
*/ | ||
@@ -344,5 +320,3 @@ | ||
if (prop === 'fallbacks') { | ||
// $FlowFixMe: Flow has problems with knowing that the fallback prop actually exists | ||
for (var index = 0; index < style.fallbacks.length; index++) { | ||
// $FlowFixMe: Flow has problems with knowing that the fallback prop actually exists | ||
style.fallbacks[index] = styleDetector(style.fallbacks[index], rule, true); | ||
@@ -360,3 +334,2 @@ } | ||
if (prop === 'fallbacks') { | ||
// $FlowFixMe: Flow has problems with knowing that the fallback prop actually exists | ||
style.fallbacks = styleDetector(style.fallbacks, rule, true); | ||
@@ -377,5 +350,2 @@ continue; | ||
* Adds possibility to write expanded styles. | ||
* | ||
* @param {Rule} rule | ||
* @api public | ||
*/ | ||
@@ -382,0 +352,0 @@ |
@@ -219,2 +219,3 @@ (function (global, factory) { | ||
/* eslint-disable no-use-before-define */ | ||
/** | ||
@@ -228,3 +229,2 @@ * Map values by given prop. | ||
*/ | ||
function mapValuesByProp(value, prop, rule) { | ||
@@ -237,8 +237,2 @@ return value.map(function (item) { | ||
* Convert array to nested array, if needed | ||
* | ||
* @param {Array} array of values | ||
* @param {String} original property | ||
* @param {Object} sheme, for converting arrays in strings | ||
* @param {Object} original rule | ||
* @return {String} converted string | ||
*/ | ||
@@ -260,9 +254,2 @@ | ||
* Convert object to array. | ||
* | ||
* @param {Object} object of values | ||
* @param {String} original property | ||
* @param {Object} original rule | ||
* @param {Boolean} is fallback prop | ||
* @param {Boolean} object is inside array | ||
* @return {String} converted string | ||
*/ | ||
@@ -303,8 +290,2 @@ | ||
* Convert custom properties values to styles adding them to rule directly | ||
* | ||
* @param {Object} object of values | ||
* @param {Object} original rule | ||
* @param {String} property, that contain partial custom properties | ||
* @param {Boolean} is fallback prop | ||
* @return {Object} value without custom properties, that was already added to rule | ||
*/ | ||
@@ -333,7 +314,2 @@ | ||
* Detect if a style needs to be converted. | ||
* | ||
* @param {Object} style | ||
* @param {Object} rule | ||
* @param {Boolean} is fallback prop | ||
* @return {Object} convertedStyle | ||
*/ | ||
@@ -350,5 +326,3 @@ | ||
if (prop === 'fallbacks') { | ||
// $FlowFixMe: Flow has problems with knowing that the fallback prop actually exists | ||
for (var index = 0; index < style.fallbacks.length; index++) { | ||
// $FlowFixMe: Flow has problems with knowing that the fallback prop actually exists | ||
style.fallbacks[index] = styleDetector(style.fallbacks[index], rule, true); | ||
@@ -366,3 +340,2 @@ } | ||
if (prop === 'fallbacks') { | ||
// $FlowFixMe: Flow has problems with knowing that the fallback prop actually exists | ||
style.fallbacks = styleDetector(style.fallbacks, rule, true); | ||
@@ -383,5 +356,2 @@ continue; | ||
* Adds possibility to write expanded styles. | ||
* | ||
* @param {Rule} rule | ||
* @api public | ||
*/ | ||
@@ -388,0 +358,0 @@ |
{ | ||
"name": "jss-plugin-expand", | ||
"description": "JSS plugin that gives you a better syntax than CSS.", | ||
"version": "10.0.0-alpha.12", | ||
"version": "10.0.0-alpha.13", | ||
"license": "MIT", | ||
@@ -40,9 +40,9 @@ "homepage": "https://cssinjs.org/jss-expand", | ||
"devDependencies": { | ||
"jss-plugin-rule-value-observable": "10.0.0-alpha.12" | ||
"jss-plugin-rule-value-observable": "10.0.0-alpha.13" | ||
}, | ||
"dependencies": { | ||
"@babel/runtime": "^7.3.1", | ||
"jss": "10.0.0-alpha.12" | ||
"jss": "10.0.0-alpha.13" | ||
}, | ||
"gitHead": "e6bf06abb8440633e1a0b332632d6d382522e20e" | ||
"gitHead": "37f000839b1970298782bf85f929c828060ffe3a" | ||
} |
@@ -12,3 +12,3 @@ # jss-plugin-expand | ||
See our website [jss-plugin-expand](https://cssinjs.org/jss-plugin-expand?v=v10.0.0-alpha.12) for more information. | ||
See our website [jss-plugin-expand](https://cssinjs.org/jss-plugin-expand?v=v10.0.0-alpha.13) for more information. | ||
@@ -15,0 +15,0 @@ ## Install |
// @flow | ||
/* eslint-disable no-use-before-define */ | ||
import type {Plugin, StyleRule} from 'jss' | ||
import type {Plugin, StyleRule, JssStyle} from 'jss' | ||
import {propArray, propArrayInObj, propObj, customPropObj} from './props' | ||
// TODO needs proper types for all supported formats | ||
type JssValue = Object | ||
/** | ||
@@ -14,3 +17,3 @@ * Map values by given prop. | ||
*/ | ||
function mapValuesByProp(value, prop, rule: StyleRule) { | ||
function mapValuesByProp(value: JssValue, prop: string, rule: StyleRule) { | ||
return value.map(item => objectToArray(item, prop, rule, false, true)) | ||
@@ -21,10 +24,4 @@ } | ||
* Convert array to nested array, if needed | ||
* | ||
* @param {Array} array of values | ||
* @param {String} original property | ||
* @param {Object} sheme, for converting arrays in strings | ||
* @param {Object} original rule | ||
* @return {String} converted string | ||
*/ | ||
function processArray(value, prop, scheme, rule: StyleRule) { | ||
function processArray(value: JssValue, prop: string, scheme: typeof propArray, rule: StyleRule) { | ||
if (scheme[prop] == null) return value | ||
@@ -42,11 +39,10 @@ if (value.length === 0) return [] | ||
* Convert object to array. | ||
* | ||
* @param {Object} object of values | ||
* @param {String} original property | ||
* @param {Object} original rule | ||
* @param {Boolean} is fallback prop | ||
* @param {Boolean} object is inside array | ||
* @return {String} converted string | ||
*/ | ||
function objectToArray(value, prop, rule: StyleRule, isFallback, isInArray) { | ||
function objectToArray( | ||
value: JssValue, | ||
prop: string, | ||
rule: StyleRule, | ||
isFallback?: boolean, | ||
isInArray?: boolean | ||
) { | ||
if (!(propObj[prop] || customPropObj[prop])) return [] | ||
@@ -87,10 +83,9 @@ | ||
* Convert custom properties values to styles adding them to rule directly | ||
* | ||
* @param {Object} object of values | ||
* @param {Object} original rule | ||
* @param {String} property, that contain partial custom properties | ||
* @param {Boolean} is fallback prop | ||
* @return {Object} value without custom properties, that was already added to rule | ||
*/ | ||
function customPropsToStyle(value, rule: StyleRule, customProps, isFallback) { | ||
function customPropsToStyle( | ||
value: JssValue, | ||
rule: StyleRule, | ||
customProps: {[string]: string}, | ||
isFallback?: boolean | ||
) { | ||
for (const prop in customProps) { | ||
@@ -121,9 +116,4 @@ const propName = customProps[prop] | ||
* Detect if a style needs to be converted. | ||
* | ||
* @param {Object} style | ||
* @param {Object} rule | ||
* @param {Boolean} is fallback prop | ||
* @return {Object} convertedStyle | ||
*/ | ||
function styleDetector(style, rule: StyleRule, isFallback) { | ||
function styleDetector(style: JssStyle, rule: StyleRule, isFallback?: boolean): JssStyle { | ||
for (const prop in style) { | ||
@@ -136,5 +126,3 @@ const value = style[prop] | ||
if (prop === 'fallbacks') { | ||
// $FlowFixMe: Flow has problems with knowing that the fallback prop actually exists | ||
for (let index = 0; index < style.fallbacks.length; index++) { | ||
// $FlowFixMe: Flow has problems with knowing that the fallback prop actually exists | ||
style.fallbacks[index] = styleDetector(style.fallbacks[index], rule, true) | ||
@@ -151,3 +139,2 @@ } | ||
if (prop === 'fallbacks') { | ||
// $FlowFixMe: Flow has problems with knowing that the fallback prop actually exists | ||
style.fallbacks = styleDetector(style.fallbacks, rule, true) | ||
@@ -171,5 +158,2 @@ continue | ||
* Adds possibility to write expanded styles. | ||
* | ||
* @param {Rule} rule | ||
* @api public | ||
*/ | ||
@@ -176,0 +160,0 @@ export default function jssExpand(): Plugin { |
Sorry, the diff of this file is not supported yet
82300
1998
+ Addedjss@10.0.0-alpha.13(transitive)
- Removedjss@10.0.0-alpha.12(transitive)
Updatedjss@10.0.0-alpha.13