onno-react
Advanced tools
Comparing version 0.3.0 to 0.4.0
@@ -136,2 +136,45 @@ "use strict" | ||
function filter(options) { | ||
const { propsKeys, renderers, reducer, initial } = options | ||
const keys = [] | ||
if (isArray(propsKeys)) { | ||
push.apply(keys, propsKeys) | ||
} | ||
if (isArray(renderers)) { | ||
const filterSet = compose({ name: "filter", renderers }) | ||
push.apply(keys, filterSet.options.propsKeys) | ||
} | ||
const filterProps = (props) => { | ||
return keys.reduce((acc, key) => { | ||
return reducer(acc, key, props) | ||
}, initial(props)) | ||
} | ||
return filterProps | ||
} | ||
function omit(options) { | ||
const propsKeys = options.propsKeys || ["theme"] | ||
if (!propsKeys.includes("theme")) propsKeys.push("theme") | ||
return filter({ | ||
propsKeys, | ||
renderers: options.renderers, | ||
initial: (props) => Object.assign({}, props), | ||
reducer: (acc, key) => { | ||
delete acc[key] | ||
return acc | ||
} | ||
}) | ||
} | ||
function pick(options) { | ||
return filter({ | ||
propsKeys: options.propsKeys, | ||
renderers: options.renderers, | ||
initial: () => ({}), | ||
reducer: (acc, key, props) => { | ||
const value = props[key] | ||
if (!isNil(value)) acc[key] = value | ||
return acc | ||
} | ||
}) | ||
} | ||
function render(keys, value) { | ||
@@ -221,20 +264,2 @@ if (isNil(value) || !isArray(keys) || !keys.length) return null | ||
function omit(options) { | ||
const { propsKeys, renderers } = options | ||
const keys = ["theme"] | ||
if (isArray(propsKeys)) { | ||
push.apply(keys, propsKeys) | ||
} | ||
if (isArray(renderers)) { | ||
const omitSet = compose({ name: "omit", renderers }) | ||
push.apply(keys, omitSet.options.propsKeys) | ||
} | ||
const omitProps = (props) => { | ||
const filteredProps = Object.assign({}, props) | ||
keys.forEach((key) => delete filteredProps[key]) | ||
return filteredProps | ||
} | ||
return omitProps | ||
} | ||
const alignContent = style({ | ||
@@ -940,2 +965,3 @@ propsKeys: ["alignContent", "alc"] | ||
exports.extend = extend | ||
exports.filter = filter | ||
exports.flex = flex | ||
@@ -1036,2 +1062,3 @@ exports.flexBasis = flexBasis | ||
exports.perspectiveOrigin = perspectiveOrigin | ||
exports.pick = pick | ||
exports.placeContent = placeContent | ||
@@ -1038,0 +1065,0 @@ exports.placeItems = placeItems |
@@ -132,2 +132,45 @@ import { oneOfType, number, string, objectOf, arrayOf } from "prop-types" | ||
function filter(options) { | ||
const { propsKeys, renderers, reducer, initial } = options | ||
const keys = [] | ||
if (isArray(propsKeys)) { | ||
push.apply(keys, propsKeys) | ||
} | ||
if (isArray(renderers)) { | ||
const filterSet = compose({ name: "filter", renderers }) | ||
push.apply(keys, filterSet.options.propsKeys) | ||
} | ||
const filterProps = (props) => { | ||
return keys.reduce((acc, key) => { | ||
return reducer(acc, key, props) | ||
}, initial(props)) | ||
} | ||
return filterProps | ||
} | ||
function omit(options) { | ||
const propsKeys = options.propsKeys || ["theme"] | ||
if (!propsKeys.includes("theme")) propsKeys.push("theme") | ||
return filter({ | ||
propsKeys, | ||
renderers: options.renderers, | ||
initial: (props) => Object.assign({}, props), | ||
reducer: (acc, key) => { | ||
delete acc[key] | ||
return acc | ||
} | ||
}) | ||
} | ||
function pick(options) { | ||
return filter({ | ||
propsKeys: options.propsKeys, | ||
renderers: options.renderers, | ||
initial: () => ({}), | ||
reducer: (acc, key, props) => { | ||
const value = props[key] | ||
if (!isNil(value)) acc[key] = value | ||
return acc | ||
} | ||
}) | ||
} | ||
function render(keys, value) { | ||
@@ -217,20 +260,2 @@ if (isNil(value) || !isArray(keys) || !keys.length) return null | ||
function omit(options) { | ||
const { propsKeys, renderers } = options | ||
const keys = ["theme"] | ||
if (isArray(propsKeys)) { | ||
push.apply(keys, propsKeys) | ||
} | ||
if (isArray(renderers)) { | ||
const omitSet = compose({ name: "omit", renderers }) | ||
push.apply(keys, omitSet.options.propsKeys) | ||
} | ||
const omitProps = (props) => { | ||
const filteredProps = Object.assign({}, props) | ||
keys.forEach((key) => delete filteredProps[key]) | ||
return filteredProps | ||
} | ||
return omitProps | ||
} | ||
const alignContent = style({ | ||
@@ -934,2 +959,3 @@ propsKeys: ["alignContent", "alc"] | ||
extend, | ||
filter, | ||
flex, | ||
@@ -1030,2 +1056,3 @@ flexBasis, | ||
perspectiveOrigin, | ||
pick, | ||
placeContent, | ||
@@ -1032,0 +1059,0 @@ placeItems, |
{ | ||
"name": "onno-react", | ||
"license": "MIT", | ||
"version": "0.3.0", | ||
"version": "0.4.0", | ||
"homepage": "https://onnojs.com", | ||
@@ -30,6 +30,6 @@ "description": "Onno propTypes for React", | ||
"@types/prop-types": "15.7.1", | ||
"onno": "0.3.0", | ||
"onno": "0.4.0", | ||
"prop-types": "15.7.2" | ||
}, | ||
"gitHead": "1c74f1e86f46ecb35474fcce93c55fe6f595abe3" | ||
"gitHead": "29c8a0cb54ab74ad59cf4e2284f72fe97ef4d526" | ||
} |
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
58177
2150
+ Addedonno@0.4.0(transitive)
- Removedonno@0.3.0(transitive)
Updatedonno@0.4.0