<filename>node_modules/.cache/babel-loader/eba9fded7d103922ab3356def9f9c72f.json
{"ast":null,"code":"import PropTypes from 'prop-types';\nimport createConnector from '../core/createConnector';\nimport { getCurrentRefinementValue, hasMultipleIndices, getIndexId } from '../core/indexUtils';\nimport { shallowEqual, omit } from '../core/utils';\n/**\n * connectScrollTo connector provides the logic to build a widget that will\n * let the page scroll to a certain point.\n * @name connectScrollTo\n * @kind connector\n * @propType {string} [scrollOn=\"page\"] - Widget searchState key on which to listen for changes, default to the pagination widget.\n * @providedPropType {any} value - the current refinement applied to the widget listened by scrollTo\n * @providedPropType {boolean} hasNotChanged - indicates whether the refinement came from the scrollOn argument (for instance page by default)\n */\n\nexport default createConnector({\n  displayName: 'AlgoliaScrollTo',\n  propTypes: {\n    scrollOn: PropTypes.string\n  },\n  defaultProps: {\n    scrollOn: 'page'\n  },\n  getProvidedProps: function getProvidedProps(props, searchState) {\n    var id = props.scrollOn;\n    var value = getCurrentRefinementValue(props, searchState, {\n      ais: props.contextValue,\n      multiIndexContext: props.indexContextValue\n    }, id, null);\n\n    if (!this._prevSearchState) {\n      this._prevSearchState = {};\n    } // Get the subpart of the state that interest us\n\n\n    if (hasMultipleIndices({\n      ais: props.contextValue,\n      multiIndexContext: props.indexContextValue\n    })) {\n      searchState = searchState.indices ? searchState.indices[getIndexId({\n        ais: props.contextValue,\n        multiIndexContext: props.indexContextValue\n      })] : {};\n    } // if there is a change in the app that has been triggered by another element\n    // than \"props.scrollOn (id) or the Configure widget, we need to keep track of\n    // the search state to know if there's a change in the app that was not triggered\n    // by the props.scrollOn (id) or the Configure widget. This is useful when\n    // using ScrollTo in combination of Pagination. As pagination can be change\n    // by every widget, we want to scroll only if it cames from the pagination\n    // widget itself. We also remove the configure key from the search state to\n    // do this comparison because for now configure values are not present in the\n    // search state before a first refinement has been made and will false the results.\n    // See: https://github.com/algolia/react-instantsearch/issues/164\n\n\n    var cleanedSearchState = omit(searchState, ['configure', id]);\n    var hasNotChanged = shallowEqual(this._prevSearchState, cleanedSearchState);\n    this._prevSearchState = cleanedSearchState;\n    return {\n      value: value,\n      hasNotChanged: hasNotChanged\n    };\n  }\n});","map":null,"metadata":{},"sourceType":"module"}