123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- "use strict";
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
- exports.__esModule = true;
- exports.createConnect = createConnect;
- exports["default"] = void 0;
- var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
- var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
- var _connectAdvanced = _interopRequireDefault(require("../components/connectAdvanced"));
- var _shallowEqual = _interopRequireDefault(require("../utils/shallowEqual"));
- var _mapDispatchToProps = _interopRequireDefault(require("./mapDispatchToProps"));
- var _mapStateToProps = _interopRequireDefault(require("./mapStateToProps"));
- var _mergeProps = _interopRequireDefault(require("./mergeProps"));
- var _selectorFactory = _interopRequireDefault(require("./selectorFactory"));
- var _excluded = ["pure", "areStatesEqual", "areOwnPropsEqual", "areStatePropsEqual", "areMergedPropsEqual"];
- function match(arg, factories, name) {
- for (var i = factories.length - 1; i >= 0; i--) {
- var result = factories[i](arg);
- if (result) return result;
- }
- return function (dispatch, options) {
- throw new Error("Invalid value of type " + typeof arg + " for " + name + " argument when connecting component " + options.wrappedComponentName + ".");
- };
- }
- function strictEqual(a, b) {
- return a === b;
- }
- function createConnect(_temp) {
- var _ref = _temp === void 0 ? {} : _temp,
- _ref$connectHOC = _ref.connectHOC,
- connectHOC = _ref$connectHOC === void 0 ? _connectAdvanced["default"] : _ref$connectHOC,
- _ref$mapStateToPropsF = _ref.mapStateToPropsFactories,
- mapStateToPropsFactories = _ref$mapStateToPropsF === void 0 ? _mapStateToProps["default"] : _ref$mapStateToPropsF,
- _ref$mapDispatchToPro = _ref.mapDispatchToPropsFactories,
- mapDispatchToPropsFactories = _ref$mapDispatchToPro === void 0 ? _mapDispatchToProps["default"] : _ref$mapDispatchToPro,
- _ref$mergePropsFactor = _ref.mergePropsFactories,
- mergePropsFactories = _ref$mergePropsFactor === void 0 ? _mergeProps["default"] : _ref$mergePropsFactor,
- _ref$selectorFactory = _ref.selectorFactory,
- selectorFactory = _ref$selectorFactory === void 0 ? _selectorFactory["default"] : _ref$selectorFactory;
- return function connect(mapStateToProps, mapDispatchToProps, mergeProps, _ref2) {
- if (_ref2 === void 0) {
- _ref2 = {};
- }
- var _ref3 = _ref2,
- _ref3$pure = _ref3.pure,
- pure = _ref3$pure === void 0 ? true : _ref3$pure,
- _ref3$areStatesEqual = _ref3.areStatesEqual,
- areStatesEqual = _ref3$areStatesEqual === void 0 ? strictEqual : _ref3$areStatesEqual,
- _ref3$areOwnPropsEqua = _ref3.areOwnPropsEqual,
- areOwnPropsEqual = _ref3$areOwnPropsEqua === void 0 ? _shallowEqual["default"] : _ref3$areOwnPropsEqua,
- _ref3$areStatePropsEq = _ref3.areStatePropsEqual,
- areStatePropsEqual = _ref3$areStatePropsEq === void 0 ? _shallowEqual["default"] : _ref3$areStatePropsEq,
- _ref3$areMergedPropsE = _ref3.areMergedPropsEqual,
- areMergedPropsEqual = _ref3$areMergedPropsE === void 0 ? _shallowEqual["default"] : _ref3$areMergedPropsE,
- extraOptions = (0, _objectWithoutPropertiesLoose2["default"])(_ref3, _excluded);
- var initMapStateToProps = match(mapStateToProps, mapStateToPropsFactories, 'mapStateToProps');
- var initMapDispatchToProps = match(mapDispatchToProps, mapDispatchToPropsFactories, 'mapDispatchToProps');
- var initMergeProps = match(mergeProps, mergePropsFactories, 'mergeProps');
- return connectHOC(selectorFactory, (0, _extends2["default"])({
-
- methodName: 'connect',
-
- getDisplayName: function getDisplayName(name) {
- return "Connect(" + name + ")";
- },
-
- shouldHandleStateChanges: Boolean(mapStateToProps),
-
- initMapStateToProps: initMapStateToProps,
- initMapDispatchToProps: initMapDispatchToProps,
- initMergeProps: initMergeProps,
- pure: pure,
- areStatesEqual: areStatesEqual,
- areOwnPropsEqual: areOwnPropsEqual,
- areStatePropsEqual: areStatePropsEqual,
- areMergedPropsEqual: areMergedPropsEqual
- }, extraOptions));
- };
- }
- var _default = createConnect();
- exports["default"] = _default;
|