fela-bindings
Advanced tools
Comparing version 1.2.0 to 1.3.0
@@ -13,3 +13,4 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
import reduce from 'lodash/reduce'; | ||
import objectReduce from 'fast-loops/lib/objectReduce'; | ||
import { combineMultiRules } from 'fela-tools'; | ||
@@ -37,12 +38,28 @@ import generateDisplayName from './generateDisplayName'; | ||
var _props = this.props, | ||
extend = _props.extend, | ||
_felaTheme = _props._felaTheme, | ||
otherProps = _objectWithoutProperties(_props, ['_felaTheme']); | ||
_felaRules = _props._felaRules, | ||
otherProps = _objectWithoutProperties(_props, ['extend', '_felaTheme', '_felaRules']); | ||
var preparedRules = typeof rules === 'function' ? rules(this.props) : rules; | ||
var allRules = [rules]; | ||
if (_felaRules) { | ||
allRules.push(_felaRules); | ||
} | ||
if (extend) { | ||
allRules.push(extend); | ||
} | ||
var styles = reduce(preparedRules, function (styleMap, rule, name) { | ||
var preparedRule = typeof rule !== 'function' ? function () { | ||
return rule; | ||
} : rule; | ||
styleMap[name] = renderer.renderRule(preparedRule, _extends({}, otherProps, { | ||
var combinedRules = combineMultiRules.apply(undefined, allRules); | ||
var preparedRules = combinedRules(_extends({}, otherProps, { | ||
theme: _felaTheme | ||
}), renderer); | ||
if (component._isFelaComponent) { | ||
return createElement(component, _extends({ | ||
_felaRules: combinedRules | ||
}, otherProps)); | ||
} | ||
var styles = objectReduce(preparedRules, function (styleMap, rule, name) { | ||
styleMap[name] = renderer.renderRule(rule, _extends({}, otherProps, { | ||
theme: _felaTheme | ||
@@ -55,3 +72,4 @@ })); | ||
return createElement(component, _extends({}, otherProps, { | ||
styles: styles | ||
styles: styles, | ||
rules: combinedRules | ||
})); | ||
@@ -65,2 +83,3 @@ } | ||
EnhancedComponent.displayName = generateDisplayName(component); | ||
EnhancedComponent._isFelaComponent = true; | ||
@@ -67,0 +86,0 @@ |
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
import forEach from 'lodash/forEach'; | ||
import arrayEach from 'fast-loops/lib/arrayEach'; | ||
@@ -30,3 +30,3 @@ export default function createTheme() { | ||
forEach(theme.listeners, function (listener) { | ||
arrayEach(theme.listeners, function (listener) { | ||
return listener(properties); | ||
@@ -33,0 +33,0 @@ }); |
@@ -1,5 +0,5 @@ | ||
import reduce from 'lodash/reduce'; | ||
import arrayReduce from 'fast-loops/lib/arrayReduce'; | ||
export default function extractPassThroughProps(passThrough, ruleProps) { | ||
return reduce(passThrough, function (output, property) { | ||
return arrayReduce(passThrough, function (output, property) { | ||
if (ruleProps.hasOwnProperty(property)) { | ||
@@ -6,0 +6,0 @@ output[property] = ruleProps[property]; |
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
import forEach from 'lodash/forEach'; | ||
import arrayEach from 'fast-loops/lib/arrayEach'; | ||
@@ -27,3 +27,3 @@ var basicStatics = { | ||
forEach(statics, function (property) { | ||
arrayEach(statics, function (property) { | ||
if (!target.hasOwnProperty(property) && !blockedStatics[property]) { | ||
@@ -38,3 +38,3 @@ try { | ||
forEach(mergableStatics, function (property) { | ||
arrayEach(mergableStatics, function (property) { | ||
if (source[property]) { | ||
@@ -41,0 +41,0 @@ var targetStatics = target[property] || {}; |
@@ -10,6 +10,6 @@ var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
import { render, rehydrate } from 'fela-dom'; | ||
import forEach from 'lodash/forEach'; | ||
import objectEach from 'fast-loops/lib/objectEach'; | ||
function hasDOM(renderer) { | ||
return !renderer.isNativeRenderer && typeof window !== 'undefined'; | ||
return !renderer.isNativeRenderer && typeof window !== 'undefined' && window.document && window.document.createElement; | ||
} | ||
@@ -57,3 +57,3 @@ | ||
if (statics) { | ||
forEach(statics, function (value, key) { | ||
objectEach(statics, function (value, key) { | ||
Provider[key] = value; | ||
@@ -60,0 +60,0 @@ }); |
@@ -1,16 +0,4 @@ | ||
var warnDeprecated = false; | ||
export default function resolvePassThrough(passThrough, ruleProps) { | ||
if (typeof passThrough === 'function') { | ||
var resolved = passThrough(ruleProps); | ||
if (!Array.isArray(resolved)) { | ||
if (process.env.NODE_ENV !== 'production' && !warnDeprecated) { | ||
console.warn('Using a function that returns an object of props as `createComponent` `passThroughProps`-parameter is deprecated. It will be removed soon. Instead return an array of prop names. e.g. `props => Object.keys(props)` See https://github.com/rofrischmann/fela/blob/master/packages/react-fela/docs/createComponent.md#functional-passthroughprops'); | ||
} | ||
return Object.keys(resolved); | ||
} | ||
return resolved; | ||
return passThrough(ruleProps); | ||
} | ||
@@ -17,0 +5,0 @@ |
@@ -1,5 +0,5 @@ | ||
import reduce from 'lodash/reduce'; | ||
import objectReduce from 'fast-loops/lib/objectReduce'; | ||
export default function resolveUsedProps(props, src) { | ||
return reduce(src, function (output, value, prop) { | ||
return objectReduce(src, function (output, value, prop) { | ||
if (props.indexOf(prop) === -1 && prop !== 'innerRef' && prop !== 'is') { | ||
@@ -6,0 +6,0 @@ output.push(prop); |
@@ -11,4 +11,4 @@ var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
import isEqual from 'lodash/isEqual'; | ||
import forEach from 'lodash/forEach'; | ||
import shallowEqual from 'shallow-equal/objects'; | ||
import objectEach from 'fast-loops/lib/objectEach'; | ||
@@ -35,3 +35,3 @@ import createTheme from './createTheme'; | ||
value: function componentWillReceiveProps(nextProps) { | ||
if (!isEqual(this.props.theme, nextProps.theme)) { | ||
if (!shallowEqual(this.props.theme, nextProps.theme)) { | ||
this.theme.update(nextProps.theme); | ||
@@ -56,3 +56,3 @@ } | ||
if (statics) { | ||
forEach(statics, function (value, key) { | ||
objectEach(statics, function (value, key) { | ||
ThemeProvider[key] = value; | ||
@@ -59,0 +59,0 @@ }); |
@@ -13,6 +13,8 @@ 'use strict'; | ||
var _reduce = require('lodash/reduce'); | ||
var _objectReduce = require('fast-loops/lib/objectReduce'); | ||
var _reduce2 = _interopRequireDefault(_reduce); | ||
var _objectReduce2 = _interopRequireDefault(_objectReduce); | ||
var _felaTools = require('fela-tools'); | ||
var _generateDisplayName = require('./generateDisplayName'); | ||
@@ -54,12 +56,28 @@ | ||
var _props = this.props, | ||
extend = _props.extend, | ||
_felaTheme = _props._felaTheme, | ||
otherProps = _objectWithoutProperties(_props, ['_felaTheme']); | ||
_felaRules = _props._felaRules, | ||
otherProps = _objectWithoutProperties(_props, ['extend', '_felaTheme', '_felaRules']); | ||
var preparedRules = typeof rules === 'function' ? rules(this.props) : rules; | ||
var allRules = [rules]; | ||
if (_felaRules) { | ||
allRules.push(_felaRules); | ||
} | ||
if (extend) { | ||
allRules.push(extend); | ||
} | ||
var styles = (0, _reduce2.default)(preparedRules, function (styleMap, rule, name) { | ||
var preparedRule = typeof rule !== 'function' ? function () { | ||
return rule; | ||
} : rule; | ||
styleMap[name] = renderer.renderRule(preparedRule, _extends({}, otherProps, { | ||
var combinedRules = _felaTools.combineMultiRules.apply(undefined, allRules); | ||
var preparedRules = combinedRules(_extends({}, otherProps, { | ||
theme: _felaTheme | ||
}), renderer); | ||
if (component._isFelaComponent) { | ||
return createElement(component, _extends({ | ||
_felaRules: combinedRules | ||
}, otherProps)); | ||
} | ||
var styles = (0, _objectReduce2.default)(preparedRules, function (styleMap, rule, name) { | ||
styleMap[name] = renderer.renderRule(rule, _extends({}, otherProps, { | ||
theme: _felaTheme | ||
@@ -72,3 +90,4 @@ })); | ||
return createElement(component, _extends({}, otherProps, { | ||
styles: styles | ||
styles: styles, | ||
rules: combinedRules | ||
})); | ||
@@ -82,2 +101,3 @@ } | ||
EnhancedComponent.displayName = (0, _generateDisplayName2.default)(component); | ||
EnhancedComponent._isFelaComponent = true; | ||
@@ -84,0 +104,0 @@ |
@@ -11,5 +11,5 @@ 'use strict'; | ||
var _forEach = require('lodash/forEach'); | ||
var _arrayEach = require('fast-loops/lib/arrayEach'); | ||
var _forEach2 = _interopRequireDefault(_forEach); | ||
var _arrayEach2 = _interopRequireDefault(_arrayEach); | ||
@@ -43,3 +43,3 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
(0, _forEach2.default)(theme.listeners, function (listener) { | ||
(0, _arrayEach2.default)(theme.listeners, function (listener) { | ||
return listener(properties); | ||
@@ -46,0 +46,0 @@ }); |
@@ -8,5 +8,5 @@ 'use strict'; | ||
var _reduce = require('lodash/reduce'); | ||
var _arrayReduce = require('fast-loops/lib/arrayReduce'); | ||
var _reduce2 = _interopRequireDefault(_reduce); | ||
var _arrayReduce2 = _interopRequireDefault(_arrayReduce); | ||
@@ -16,3 +16,3 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function extractPassThroughProps(passThrough, ruleProps) { | ||
return (0, _reduce2.default)(passThrough, function (output, property) { | ||
return (0, _arrayReduce2.default)(passThrough, function (output, property) { | ||
if (ruleProps.hasOwnProperty(property)) { | ||
@@ -19,0 +19,0 @@ output[property] = ruleProps[property]; |
@@ -11,5 +11,5 @@ 'use strict'; | ||
var _forEach = require('lodash/forEach'); | ||
var _arrayEach = require('fast-loops/lib/arrayEach'); | ||
var _forEach2 = _interopRequireDefault(_forEach); | ||
var _arrayEach2 = _interopRequireDefault(_arrayEach); | ||
@@ -40,3 +40,3 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
(0, _forEach2.default)(statics, function (property) { | ||
(0, _arrayEach2.default)(statics, function (property) { | ||
if (!target.hasOwnProperty(property) && !blockedStatics[property]) { | ||
@@ -51,3 +51,3 @@ try { | ||
(0, _forEach2.default)(mergableStatics, function (property) { | ||
(0, _arrayEach2.default)(mergableStatics, function (property) { | ||
if (source[property]) { | ||
@@ -54,0 +54,0 @@ var targetStatics = target[property] || {}; |
@@ -13,5 +13,5 @@ 'use strict'; | ||
var _forEach = require('lodash/forEach'); | ||
var _objectEach = require('fast-loops/lib/objectEach'); | ||
var _forEach2 = _interopRequireDefault(_forEach); | ||
var _objectEach2 = _interopRequireDefault(_objectEach); | ||
@@ -27,3 +27,3 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function hasDOM(renderer) { | ||
return !renderer.isNativeRenderer && typeof window !== 'undefined'; | ||
return !renderer.isNativeRenderer && typeof window !== 'undefined' && window.document && window.document.createElement; | ||
} | ||
@@ -71,3 +71,3 @@ | ||
if (statics) { | ||
(0, _forEach2.default)(statics, function (value, key) { | ||
(0, _objectEach2.default)(statics, function (value, key) { | ||
Provider[key] = value; | ||
@@ -74,0 +74,0 @@ }); |
@@ -7,17 +7,5 @@ 'use strict'; | ||
exports.default = resolvePassThrough; | ||
var warnDeprecated = false; | ||
function resolvePassThrough(passThrough, ruleProps) { | ||
if (typeof passThrough === 'function') { | ||
var resolved = passThrough(ruleProps); | ||
if (!Array.isArray(resolved)) { | ||
if (process.env.NODE_ENV !== 'production' && !warnDeprecated) { | ||
console.warn('Using a function that returns an object of props as `createComponent` `passThroughProps`-parameter is deprecated. It will be removed soon. Instead return an array of prop names. e.g. `props => Object.keys(props)` See https://github.com/rofrischmann/fela/blob/master/packages/react-fela/docs/createComponent.md#functional-passthroughprops'); | ||
} | ||
return Object.keys(resolved); | ||
} | ||
return resolved; | ||
return passThrough(ruleProps); | ||
} | ||
@@ -24,0 +12,0 @@ |
@@ -8,5 +8,5 @@ 'use strict'; | ||
var _reduce = require('lodash/reduce'); | ||
var _objectReduce = require('fast-loops/lib/objectReduce'); | ||
var _reduce2 = _interopRequireDefault(_reduce); | ||
var _objectReduce2 = _interopRequireDefault(_objectReduce); | ||
@@ -16,3 +16,3 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function resolveUsedProps(props, src) { | ||
return (0, _reduce2.default)(src, function (output, value, prop) { | ||
return (0, _objectReduce2.default)(src, function (output, value, prop) { | ||
if (props.indexOf(prop) === -1 && prop !== 'innerRef' && prop !== 'is') { | ||
@@ -19,0 +19,0 @@ output.push(prop); |
@@ -11,9 +11,9 @@ 'use strict'; | ||
var _isEqual = require('lodash/isEqual'); | ||
var _objects = require('shallow-equal/objects'); | ||
var _isEqual2 = _interopRequireDefault(_isEqual); | ||
var _objects2 = _interopRequireDefault(_objects); | ||
var _forEach = require('lodash/forEach'); | ||
var _objectEach = require('fast-loops/lib/objectEach'); | ||
var _forEach2 = _interopRequireDefault(_forEach); | ||
var _objectEach2 = _interopRequireDefault(_objectEach); | ||
@@ -53,3 +53,3 @@ var _createTheme = require('./createTheme'); | ||
value: function componentWillReceiveProps(nextProps) { | ||
if (!(0, _isEqual2.default)(this.props.theme, nextProps.theme)) { | ||
if (!(0, _objects2.default)(this.props.theme, nextProps.theme)) { | ||
this.theme.update(nextProps.theme); | ||
@@ -74,3 +74,3 @@ } | ||
if (statics) { | ||
(0, _forEach2.default)(statics, function (value, key) { | ||
(0, _objectEach2.default)(statics, function (value, key) { | ||
ThemeProvider[key] = value; | ||
@@ -77,0 +77,0 @@ }); |
{ | ||
"name": "fela-bindings", | ||
"version": "1.2.0", | ||
"version": "1.3.0", | ||
"description": "Abstract binding factories for Fela", | ||
@@ -25,10 +25,11 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"fela-dom": "^7.0.0", | ||
"lodash": "^4.17.4" | ||
"fast-loops": "^1.0.0", | ||
"fela-dom": "^7.0.1", | ||
"fela-tools": "^5.1.0", | ||
"shallow-equal": "^1.0.0" | ||
}, | ||
"devDependencies": { | ||
"fela": "^6.1.0", | ||
"fela-monolithic": "^5.0.14", | ||
"fela-tools": "^5.0.14" | ||
"fela": "^6.1.1", | ||
"fela-monolithic": "^5.0.15" | ||
} | ||
} |
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
58207
2
1036
4
+ Addedfast-loops@^1.0.0
+ Addedfela-tools@^5.1.0
+ Addedshallow-equal@^1.0.0
+ Addedcsstype@2.6.21(transitive)
+ Addedfela@6.2.4(transitive)
+ Addedfela-tools@5.2.3(transitive)
+ Addedshallow-equal@1.2.1(transitive)
- Removedlodash@^4.17.4
- Removedlodash@4.17.21(transitive)
Updatedfela-dom@^7.0.1