(_ref, Component)
| 6741 | }; |
| 6742 | |
| 6743 | function $mapContextToProps(_ref, Component) { |
| 6744 | var maybeArrayOfConsumers = _ref.consumers, |
| 6745 | mapToProps = _ref.mapToProps, |
| 6746 | displayName = _ref.displayName, |
| 6747 | _ref$forwardRefAs = _ref.forwardRefAs, |
| 6748 | forwardRefAs = _ref$forwardRefAs === void 0 ? 'ref' : _ref$forwardRefAs; |
| 6749 | var consumers = maybeArrayOfConsumers; |
| 6750 | |
| 6751 | if (!Array.isArray(maybeArrayOfConsumers)) { |
| 6752 | consumers = [maybeArrayOfConsumers]; |
| 6753 | } |
| 6754 | |
| 6755 | var SingleConsumer = ensureConsumer(consumers[0]); |
| 6756 | |
| 6757 | function singleRender(props, ref) { |
| 6758 | var _extends2; |
| 6759 | |
| 6760 | var propsWithRef = _extends((_extends2 = {}, _extends2[forwardRefAs] = ref, _extends2), props); |
| 6761 | |
| 6762 | return _react.default.createElement(SingleConsumer, null, function (value) { |
| 6763 | return _react.default.createElement(Component, _extends({}, propsWithRef, mapToProps(value, props))); |
| 6764 | }); |
| 6765 | } |
| 6766 | |
| 6767 | function multiRender(props, ref) { |
| 6768 | var _extends3; |
| 6769 | |
| 6770 | var propsWithRef = _extends((_extends3 = {}, _extends3[forwardRefAs] = ref, _extends3), props); |
| 6771 | |
| 6772 | return consumers.reduceRight(function (inner, Context) { |
| 6773 | return function () { |
| 6774 | for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { |
| 6775 | args[_key] = arguments[_key]; |
| 6776 | } |
| 6777 | |
| 6778 | var Consumer = ensureConsumer(Context); |
| 6779 | return _react.default.createElement(Consumer, null, function (value) { |
| 6780 | return inner.apply(void 0, args.concat([value])); |
| 6781 | }); |
| 6782 | }; |
| 6783 | }, function () { |
| 6784 | for (var _len2 = arguments.length, contexts = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { |
| 6785 | contexts[_key2] = arguments[_key2]; |
| 6786 | } |
| 6787 | |
| 6788 | return _react.default.createElement(Component, _extends({}, propsWithRef, mapToProps.apply(void 0, contexts.concat([props])))); |
| 6789 | })(); |
| 6790 | } |
| 6791 | |
| 6792 | var contextTransform = consumers.length === 1 ? singleRender : multiRender; |
| 6793 | return (0, _forwardRef.default)(contextTransform, { |
| 6794 | displayName: displayName || getDisplayName(Component) |
| 6795 | }); |
| 6796 | } |
| 6797 | |
| 6798 | function mapContextToProps(maybeOpts, mapToProps, Component) { |
| 6799 | if (arguments.length === 2) return $mapContextToProps(maybeOpts, mapToProps); |
no test coverage detected
searching dependent graphs…