UNPKG

1.08 kBJavaScriptView Raw
1'use strict';
2
3Object.defineProperty(exports, '__esModule', { value: true });
4
5require('./unsupportedIterableToArray-8a00e599.js');
6var toConsumableArray = require('./toConsumableArray-7f36359f.js');
7
8// Forward some props of an instance to a child element.
9//
10// Usage example:
11//
12// <Child {...forwardProps(this, ['name', 'style'])}>
13//
14function forwardProps(instance, names) {
15 return names.reduce(function (props, name) {
16 if (instance.props[name]) {
17 props[name] = instance.props[name];
18 }
19
20 return props;
21 }, {});
22} // Forward the props useful to extend the styles of the main child of a
23// component, using either styled() or the style attribute. Additionnal names
24// can be passed as a second parameter.
25
26function stylingProps(instance) {
27 var names = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
28 return forwardProps(instance, ['style', 'className'].concat(toConsumableArray._toConsumableArray(names)));
29}
30
31exports.forwardProps = forwardProps;
32exports.stylingProps = stylingProps;
33//# sourceMappingURL=components.js.map