instantsearch.js 4.49.0 → 4.49.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/cjs/components/Answers/Answers.js +6 -16
- package/cjs/components/Breadcrumb/Breadcrumb.js +5 -12
- package/cjs/components/ClearRefinements/ClearRefinements.js +4 -11
- package/cjs/components/CurrentRefinements/CurrentRefinements.js +5 -12
- package/cjs/components/GeoSearchControls/GeoSearchButton.js +4 -6
- package/cjs/components/GeoSearchControls/GeoSearchControls.js +11 -20
- package/cjs/components/GeoSearchControls/GeoSearchToggle.js +4 -6
- package/cjs/components/Highlight/Highlight.js +3 -11
- package/cjs/components/Hits/Hits.js +8 -20
- package/cjs/components/InfiniteHits/InfiniteHits.js +13 -25
- package/cjs/components/InternalHighlight/InternalHighlight.js +0 -3
- package/cjs/components/MenuSelect/MenuSelect.js +9 -19
- package/cjs/components/Pagination/Pagination.js +10 -17
- package/cjs/components/Panel/Panel.js +7 -26
- package/cjs/components/PoweredBy/PoweredBy.js +4 -5
- package/cjs/components/QueryRuleCustomData/QueryRuleCustomData.js +2 -6
- package/cjs/components/RangeInput/RangeInput.js +16 -48
- package/cjs/components/RefinementList/RefinementList.js +19 -73
- package/cjs/components/RefinementList/RefinementListItem.js +8 -14
- package/cjs/components/RelevantSort/RelevantSort.js +4 -8
- package/cjs/components/ReverseHighlight/ReverseHighlight.js +3 -11
- package/cjs/components/ReverseSnippet/ReverseSnippet.js +3 -11
- package/cjs/components/SearchBox/SearchBox.js +25 -69
- package/cjs/components/Selector/Selector.js +3 -6
- package/cjs/components/Slider/Pit.js +3 -10
- package/cjs/components/Slider/Rheostat.js +63 -131
- package/cjs/components/Slider/Slider.js +28 -65
- package/cjs/components/Snippet/Snippet.js +3 -11
- package/cjs/components/Stats/Stats.js +7 -20
- package/cjs/components/Template/Template.js +8 -37
- package/cjs/components/ToggleRefinement/ToggleRefinement.js +4 -10
- package/cjs/components/VoiceSearch/VoiceSearch.js +8 -15
- package/cjs/connectors/answers/connectAnswers.js +21 -36
- package/cjs/connectors/autocomplete/connectAutocomplete.js +8 -25
- package/cjs/connectors/breadcrumb/connectBreadcrumb.js +17 -48
- package/cjs/connectors/clear-refinements/connectClearRefinements.js +27 -45
- package/cjs/connectors/configure/connectConfigure.js +6 -20
- package/cjs/connectors/configure-related-items/connectConfigureRelatedItems.js +11 -36
- package/cjs/connectors/current-refinements/connectCurrentRefinements.js +18 -57
- package/cjs/connectors/dynamic-widgets/connectDynamicWidgets.js +17 -37
- package/cjs/connectors/geo-search/connectGeoSearch.js +17 -47
- package/cjs/connectors/hierarchical-menu/connectHierarchicalMenu.js +38 -74
- package/cjs/connectors/hits/connectHits.js +10 -26
- package/cjs/connectors/hits/connectHitsWithInsights.js +0 -4
- package/cjs/connectors/hits-per-page/connectHitsPerPage.js +15 -38
- package/cjs/connectors/index.js +62 -96
- package/cjs/connectors/infinite-hits/connectInfiniteHits.js +26 -62
- package/cjs/connectors/infinite-hits/connectInfiniteHitsWithInsights.js +0 -4
- package/cjs/connectors/menu/connectMenu.js +28 -66
- package/cjs/connectors/numeric-menu/connectNumericMenu.js +24 -78
- package/cjs/connectors/pagination/Paginator.js +3 -20
- package/cjs/connectors/pagination/connectPagination.js +8 -25
- package/cjs/connectors/powered-by/connectPoweredBy.js +4 -13
- package/cjs/connectors/query-rules/connectQueryRules.js +32 -56
- package/cjs/connectors/range/connectRange.js +41 -101
- package/cjs/connectors/rating-menu/connectRatingMenu.js +23 -79
- package/cjs/connectors/refinement-list/connectRefinementList.js +37 -70
- package/cjs/connectors/relevant-sort/connectRelevantSort.js +4 -14
- package/cjs/connectors/search-box/connectSearchBox.js +7 -23
- package/cjs/connectors/sort-by/connectSortBy.js +11 -21
- package/cjs/connectors/stats/connectStats.js +4 -11
- package/cjs/connectors/toggle-refinement/connectToggleRefinement.js +29 -63
- package/cjs/connectors/voice-search/connectVoiceSearch.js +13 -35
- package/cjs/helpers/components/Highlight.js +4 -12
- package/cjs/helpers/components/ReverseHighlight.js +7 -19
- package/cjs/helpers/components/ReverseSnippet.js +7 -19
- package/cjs/helpers/components/Snippet.js +4 -12
- package/cjs/helpers/components/index.js +0 -8
- package/cjs/helpers/get-insights-anonymous-user-token.js +7 -12
- package/cjs/helpers/highlight.js +10 -16
- package/cjs/helpers/index.js +17 -31
- package/cjs/helpers/insights.js +5 -17
- package/cjs/helpers/reverseHighlight.js +10 -16
- package/cjs/helpers/reverseSnippet.js +10 -16
- package/cjs/helpers/snippet.js +10 -16
- package/cjs/index.js +3 -18
- package/cjs/lib/InstantSearch.js +79 -180
- package/cjs/lib/createHelpers.js +4 -11
- package/cjs/lib/formatNumber.js +0 -1
- package/cjs/lib/infiniteHitsCache/index.js +0 -2
- package/cjs/lib/infiniteHitsCache/sessionStorage.js +9 -18
- package/cjs/lib/insights/client.js +8 -34
- package/cjs/lib/insights/index.js +7 -13
- package/cjs/lib/insights/listener.js +4 -20
- package/cjs/lib/routers/history.js +63 -102
- package/cjs/lib/routers/index.js +0 -2
- package/cjs/lib/stateMappings/index.js +0 -3
- package/cjs/lib/stateMappings/simple.js +6 -13
- package/cjs/lib/stateMappings/singleIndex.js +1 -7
- package/cjs/lib/suit.js +2 -5
- package/cjs/lib/templating/index.js +0 -4
- package/cjs/lib/templating/prepareTemplateProps.js +8 -19
- package/cjs/lib/templating/renderTemplate.js +9 -24
- package/cjs/lib/utils/capitalize.js +0 -1
- package/cjs/lib/utils/checkIndexUiState.js +15 -43
- package/cjs/lib/utils/checkRendering.js +0 -2
- package/cjs/lib/utils/clearRefinements.js +2 -9
- package/cjs/lib/utils/concatHighlightedParts.js +1 -3
- package/cjs/lib/utils/createConcurrentSafePromise.js +0 -3
- package/cjs/lib/utils/createSendEventForFacet.js +7 -14
- package/cjs/lib/utils/createSendEventForHits.js +9 -33
- package/cjs/lib/utils/debounce.js +0 -3
- package/cjs/lib/utils/defer.js +0 -11
- package/cjs/lib/utils/detect-insights-client.js +0 -2
- package/cjs/lib/utils/documentation.js +2 -5
- package/cjs/lib/utils/escape-highlight.js +5 -22
- package/cjs/lib/utils/escape-html.js +9 -7
- package/cjs/lib/utils/escapeFacetValue.js +1 -5
- package/cjs/lib/utils/find.js +2 -5
- package/cjs/lib/utils/findIndex.js +0 -3
- package/cjs/lib/utils/geo-search.js +14 -34
- package/cjs/lib/utils/getAppIdAndApiKey.js +2 -3
- package/cjs/lib/utils/getContainerNode.js +0 -6
- package/cjs/lib/utils/getHighlightFromSiblings.js +0 -6
- package/cjs/lib/utils/getHighlightedParts.js +1 -4
- package/cjs/lib/utils/getObjectType.js +0 -1
- package/cjs/lib/utils/getPropertyByPath.js +0 -1
- package/cjs/lib/utils/getRefinements.js +13 -26
- package/cjs/lib/utils/getWidgetAttribute.js +0 -6
- package/cjs/lib/utils/hits-absolute-position.js +2 -6
- package/cjs/lib/utils/hits-query-id.js +2 -7
- package/cjs/lib/utils/index.js +0 -92
- package/cjs/lib/utils/isDomElement.js +0 -1
- package/cjs/lib/utils/isEqual.js +0 -8
- package/cjs/lib/utils/isFacetRefined.js +0 -1
- package/cjs/lib/utils/isFiniteNumber.js +0 -1
- package/cjs/lib/utils/isIndexWidget.js +0 -1
- package/cjs/lib/utils/isPlainObject.js +3 -11
- package/cjs/lib/utils/isSpecialClick.js +0 -1
- package/cjs/lib/utils/logger.js +3 -13
- package/cjs/lib/utils/mergeSearchParameters.js +16 -40
- package/cjs/lib/utils/noop.js +0 -1
- package/cjs/lib/utils/range.js +8 -14
- package/cjs/lib/utils/render-args.js +0 -2
- package/cjs/lib/utils/resolveSearchParameters.js +0 -3
- package/cjs/lib/utils/reverseHighlightedParts.js +2 -8
- package/cjs/lib/utils/safelyRunOnBrowser.js +7 -9
- package/cjs/lib/utils/serializer.js +1 -3
- package/cjs/lib/utils/setIndexHelperState.js +0 -5
- package/cjs/lib/utils/toArray.js +0 -1
- package/cjs/lib/utils/typedObject.js +0 -1
- package/cjs/lib/utils/uniq.js +0 -1
- package/cjs/lib/version.js +1 -1
- package/cjs/lib/voiceSearchHelper/index.js +8 -36
- package/cjs/middlewares/createInsightsMiddleware.js +15 -44
- package/cjs/middlewares/createMetadataMiddleware.js +4 -12
- package/cjs/middlewares/createRouterMiddleware.js +8 -19
- package/cjs/middlewares/index.js +0 -6
- package/cjs/types/algoliasearch.js +0 -2
- package/cjs/types/index.js +0 -28
- package/cjs/widgets/analytics/analytics.js +12 -47
- package/cjs/widgets/answers/answers.js +19 -39
- package/cjs/widgets/breadcrumb/breadcrumb.js +18 -38
- package/cjs/widgets/clear-refinements/clear-refinements.js +15 -35
- package/cjs/widgets/configure/configure.js +2 -10
- package/cjs/widgets/configure-related-items/configure-related-items.js +2 -10
- package/cjs/widgets/current-refinements/current-refinements.js +12 -30
- package/cjs/widgets/dynamic-widgets/dynamic-widgets.js +6 -25
- package/cjs/widgets/geo-search/GeoSearchRenderer.js +41 -68
- package/cjs/widgets/geo-search/createHTMLMarker.js +30 -60
- package/cjs/widgets/geo-search/defaultTemplates.js +0 -3
- package/cjs/widgets/geo-search/geo-search.js +27 -59
- package/cjs/widgets/hierarchical-menu/defaultTemplates.js +4 -7
- package/cjs/widgets/hierarchical-menu/hierarchical-menu.js +28 -47
- package/cjs/widgets/hits/hits.js +16 -37
- package/cjs/widgets/hits-per-page/hits-per-page.js +13 -31
- package/cjs/widgets/index/index.js +49 -95
- package/cjs/widgets/index.js +12 -50
- package/cjs/widgets/infinite-hits/infinite-hits.js +23 -44
- package/cjs/widgets/menu/defaultTemplates.js +3 -6
- package/cjs/widgets/menu/menu.js +23 -43
- package/cjs/widgets/menu-select/defaultTemplates.js +1 -3
- package/cjs/widgets/menu-select/menu-select.js +18 -38
- package/cjs/widgets/numeric-menu/defaultTemplates.js +3 -4
- package/cjs/widgets/numeric-menu/numeric-menu.js +17 -37
- package/cjs/widgets/pagination/pagination.js +32 -53
- package/cjs/widgets/panel/panel.js +20 -48
- package/cjs/widgets/places/places.js +16 -33
- package/cjs/widgets/powered-by/powered-by.js +10 -27
- package/cjs/widgets/query-rule-context/query-rule-context.js +2 -13
- package/cjs/widgets/query-rule-custom-data/query-rule-custom-data.js +14 -32
- package/cjs/widgets/range-input/range-input.js +23 -50
- package/cjs/widgets/range-slider/range-slider.js +28 -53
- package/cjs/widgets/rating-menu/defaultTemplates.js +8 -14
- package/cjs/widgets/rating-menu/rating-menu.js +17 -38
- package/cjs/widgets/refinement-list/defaultTemplates.js +5 -8
- package/cjs/widgets/refinement-list/refinement-list.js +39 -60
- package/cjs/widgets/relevant-sort/relevant-sort.js +10 -29
- package/cjs/widgets/search-box/defaultTemplates.js +0 -5
- package/cjs/widgets/search-box/search-box.js +31 -49
- package/cjs/widgets/sort-by/sort-by.js +11 -29
- package/cjs/widgets/stats/defaultTemplates.js +0 -1
- package/cjs/widgets/stats/stats.js +27 -57
- package/cjs/widgets/toggle-refinement/toggle-refinement.js +16 -36
- package/cjs/widgets/voice-search/defaultTemplates.js +4 -14
- package/cjs/widgets/voice-search/voice-search.js +17 -36
- package/dist/instantsearch.development.d.ts +8 -6
- package/dist/instantsearch.development.js +1725 -3087
- package/dist/instantsearch.development.js.map +1 -1
- package/dist/instantsearch.production.d.ts +8 -6
- package/dist/instantsearch.production.min.d.ts +8 -6
- package/dist/instantsearch.production.min.js +2 -2
- package/dist/instantsearch.production.min.js.map +1 -1
- package/es/components/Answers/Answers.js +6 -11
- package/es/components/Breadcrumb/Breadcrumb.js +5 -7
- package/es/components/ClearRefinements/ClearRefinements.js +4 -6
- package/es/components/CurrentRefinements/CurrentRefinements.js +7 -10
- package/es/components/GeoSearchControls/GeoSearchButton.js +6 -6
- package/es/components/GeoSearchControls/GeoSearchControls.js +11 -13
- package/es/components/GeoSearchControls/GeoSearchToggle.js +6 -6
- package/es/components/Highlight/Highlight.js +3 -7
- package/es/components/Hits/Hits.js +8 -15
- package/es/components/InfiniteHits/InfiniteHits.js +13 -20
- package/es/components/MenuSelect/MenuSelect.js +9 -13
- package/es/components/Pagination/Pagination.js +12 -15
- package/es/components/Panel/Panel.js +7 -20
- package/es/components/PoweredBy/PoweredBy.js +6 -5
- package/es/components/QueryRuleCustomData/QueryRuleCustomData.js +4 -4
- package/es/components/RangeInput/RangeInput.js +16 -43
- package/es/components/RefinementList/RefinementList.js +19 -64
- package/es/components/RefinementList/RefinementListItem.js +8 -10
- package/es/components/RelevantSort/RelevantSort.js +6 -6
- package/es/components/ReverseHighlight/ReverseHighlight.js +3 -7
- package/es/components/ReverseSnippet/ReverseSnippet.js +3 -7
- package/es/components/SearchBox/SearchBox.js +25 -63
- package/es/components/Selector/Selector.js +5 -5
- package/es/components/Slider/Pit.js +3 -7
- package/es/components/Slider/Rheostat.js +64 -129
- package/es/components/Slider/Slider.js +28 -58
- package/es/components/Snippet/Snippet.js +3 -7
- package/es/components/Stats/Stats.js +7 -15
- package/es/components/Template/Template.js +8 -32
- package/es/components/ToggleRefinement/ToggleRefinement.js +4 -6
- package/es/components/VoiceSearch/VoiceSearch.js +10 -13
- package/es/connectors/answers/connectAnswers.js +21 -35
- package/es/connectors/autocomplete/connectAutocomplete.js +8 -23
- package/es/connectors/breadcrumb/connectBreadcrumb.js +17 -46
- package/es/connectors/clear-refinements/connectClearRefinements.js +27 -43
- package/es/connectors/configure/connectConfigure.js +7 -16
- package/es/connectors/configure-related-items/connectConfigureRelatedItems.js +11 -31
- package/es/connectors/current-refinements/connectCurrentRefinements.js +18 -55
- package/es/connectors/dynamic-widgets/connectDynamicWidgets.js +17 -35
- package/es/connectors/geo-search/connectGeoSearch.js +17 -45
- package/es/connectors/hierarchical-menu/connectHierarchicalMenu.js +38 -72
- package/es/connectors/hits/connectHits.js +10 -24
- package/es/connectors/hits-per-page/connectHitsPerPage.js +15 -36
- package/es/connectors/index.d.ts +2 -1
- package/es/connectors/index.js +6 -3
- package/es/connectors/infinite-hits/connectInfiniteHits.js +26 -60
- package/es/connectors/menu/connectMenu.js +28 -64
- package/es/connectors/numeric-menu/connectNumericMenu.js +24 -76
- package/es/connectors/pagination/Paginator.js +3 -19
- package/es/connectors/pagination/connectPagination.js +8 -21
- package/es/connectors/powered-by/connectPoweredBy.js +4 -11
- package/es/connectors/query-rules/connectQueryRules.js +32 -54
- package/es/connectors/range/connectRange.js +41 -99
- package/es/connectors/rating-menu/connectRatingMenu.js +23 -77
- package/es/connectors/refinement-list/connectRefinementList.js +37 -68
- package/es/connectors/relevant-sort/connectRelevantSort.js +4 -13
- package/es/connectors/search-box/connectSearchBox.js +7 -21
- package/es/connectors/sort-by/connectSortBy.js +11 -19
- package/es/connectors/stats/connectStats.js +4 -9
- package/es/connectors/toggle-refinement/connectToggleRefinement.js +29 -61
- package/es/connectors/voice-search/connectVoiceSearch.js +13 -31
- package/es/helpers/components/Highlight.js +4 -8
- package/es/helpers/components/ReverseHighlight.js +7 -15
- package/es/helpers/components/ReverseSnippet.js +7 -15
- package/es/helpers/components/Snippet.js +4 -8
- package/es/helpers/get-insights-anonymous-user-token.js +5 -7
- package/es/helpers/highlight.js +9 -11
- package/es/helpers/insights.js +3 -10
- package/es/helpers/reverseHighlight.js +9 -11
- package/es/helpers/reverseSnippet.js +9 -11
- package/es/helpers/snippet.js +9 -11
- package/es/index.js +0 -2
- package/es/lib/InstantSearch.js +79 -170
- package/es/lib/createHelpers.js +4 -8
- package/es/lib/infiniteHitsCache/sessionStorage.js +9 -16
- package/es/lib/insights/client.js +8 -32
- package/es/lib/insights/listener.js +6 -18
- package/es/lib/routers/history.js +63 -99
- package/es/lib/stateMappings/simple.js +6 -12
- package/es/lib/stateMappings/singleIndex.js +1 -6
- package/es/lib/suit.js +2 -3
- package/es/lib/templating/prepareTemplateProps.js +8 -18
- package/es/lib/templating/renderTemplate.js +9 -20
- package/es/lib/utils/checkIndexUiState.js +18 -40
- package/es/lib/utils/clearRefinements.js +2 -8
- package/es/lib/utils/concatHighlightedParts.js +1 -1
- package/es/lib/utils/createConcurrentSafePromise.js +0 -2
- package/es/lib/utils/createSendEventForFacet.js +7 -12
- package/es/lib/utils/createSendEventForHits.js +8 -30
- package/es/lib/utils/debounce.js +0 -2
- package/es/lib/utils/defer.js +0 -10
- package/es/lib/utils/documentation.js +2 -3
- package/es/lib/utils/escape-highlight.js +3 -16
- package/es/lib/utils/escape-html.js +9 -5
- package/es/lib/utils/escapeFacetValue.js +0 -2
- package/es/lib/utils/find.js +2 -4
- package/es/lib/utils/findIndex.js +0 -2
- package/es/lib/utils/geo-search.js +14 -32
- package/es/lib/utils/getAppIdAndApiKey.js +2 -2
- package/es/lib/utils/getContainerNode.js +1 -5
- package/es/lib/utils/getHighlightFromSiblings.js +0 -3
- package/es/lib/utils/getHighlightedParts.js +1 -2
- package/es/lib/utils/getRefinements.js +13 -24
- package/es/lib/utils/getWidgetAttribute.js +0 -5
- package/es/lib/utils/hits-absolute-position.js +2 -5
- package/es/lib/utils/hits-query-id.js +2 -6
- package/es/lib/utils/isEqual.js +0 -7
- package/es/lib/utils/isPlainObject.js +3 -10
- package/es/lib/utils/logger.js +2 -12
- package/es/lib/utils/mergeSearchParameters.js +16 -37
- package/es/lib/utils/range.js +8 -13
- package/es/lib/utils/resolveSearchParameters.js +0 -2
- package/es/lib/utils/reverseHighlightedParts.js +2 -6
- package/es/lib/utils/safelyRunOnBrowser.js +7 -8
- package/es/lib/utils/setIndexHelperState.js +0 -2
- package/es/lib/version.d.ts +1 -1
- package/es/lib/version.js +1 -1
- package/es/lib/voiceSearchHelper/index.js +8 -35
- package/es/middlewares/createInsightsMiddleware.js +15 -41
- package/es/middlewares/createMetadataMiddleware.js +3 -9
- package/es/middlewares/createRouterMiddleware.js +8 -13
- package/es/types/index.js +9 -5
- package/es/widgets/analytics/analytics.js +12 -45
- package/es/widgets/answers/answers.js +19 -28
- package/es/widgets/breadcrumb/breadcrumb.js +18 -27
- package/es/widgets/clear-refinements/clear-refinements.js +15 -24
- package/es/widgets/configure/configure.js +3 -6
- package/es/widgets/configure-related-items/configure-related-items.js +2 -7
- package/es/widgets/current-refinements/current-refinements.js +12 -21
- package/es/widgets/dynamic-widgets/dynamic-widgets.js +6 -20
- package/es/widgets/geo-search/GeoSearchRenderer.js +41 -63
- package/es/widgets/geo-search/createHTMLMarker.js +30 -59
- package/es/widgets/geo-search/defaultTemplates.js +2 -2
- package/es/widgets/geo-search/geo-search.js +27 -49
- package/es/widgets/hierarchical-menu/defaultTemplates.js +5 -4
- package/es/widgets/hierarchical-menu/hierarchical-menu.js +28 -36
- package/es/widgets/hits/hits.js +16 -25
- package/es/widgets/hits-per-page/hits-per-page.js +13 -22
- package/es/widgets/index/index.js +49 -91
- package/es/widgets/index.d.ts +2 -1
- package/es/widgets/index.js +4 -3
- package/es/widgets/infinite-hits/infinite-hits.js +23 -32
- package/es/widgets/menu/defaultTemplates.js +4 -3
- package/es/widgets/menu/menu.js +23 -32
- package/es/widgets/menu-select/defaultTemplates.js +1 -1
- package/es/widgets/menu-select/menu-select.js +18 -27
- package/es/widgets/numeric-menu/defaultTemplates.js +4 -3
- package/es/widgets/numeric-menu/numeric-menu.js +17 -26
- package/es/widgets/pagination/pagination.js +32 -44
- package/es/widgets/panel/panel.js +20 -40
- package/es/widgets/places/places.js +16 -32
- package/es/widgets/powered-by/powered-by.js +10 -18
- package/es/widgets/query-rule-context/query-rule-context.js +2 -9
- package/es/widgets/query-rule-custom-data/query-rule-custom-data.js +13 -22
- package/es/widgets/range-input/range-input.js +23 -40
- package/es/widgets/range-slider/range-slider.js +28 -44
- package/es/widgets/rating-menu/defaultTemplates.js +9 -12
- package/es/widgets/rating-menu/rating-menu.js +17 -27
- package/es/widgets/refinement-list/defaultTemplates.js +6 -5
- package/es/widgets/refinement-list/refinement-list.js +39 -48
- package/es/widgets/relevant-sort/relevant-sort.js +10 -19
- package/es/widgets/search-box/defaultTemplates.js +1 -4
- package/es/widgets/search-box/search-box.js +31 -39
- package/es/widgets/sort-by/sort-by.js +11 -20
- package/es/widgets/stats/stats.js +26 -45
- package/es/widgets/toggle-refinement/toggle-refinement.js +16 -25
- package/es/widgets/voice-search/defaultTemplates.js +5 -13
- package/es/widgets/voice-search/voice-search.js +17 -26
- package/package.json +20 -119
- package/scripts/transforms/__testfixtures__/addWidget-to-addWidgets/imported.input.js +0 -1
- package/scripts/transforms/__testfixtures__/addWidget-to-addWidgets/imported.output.js +0 -1
- package/CHANGELOG.md +0 -3684
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* This implementation is taken from Lodash implementation.
|
|
3
3
|
* See: https://github.com/lodash/lodash/blob/4.17.11-npm/escape.js
|
|
4
4
|
*/
|
|
5
|
+
|
|
5
6
|
// Used to map characters to HTML entities.
|
|
6
7
|
var htmlEntities = {
|
|
7
8
|
'&': '&',
|
|
@@ -9,41 +10,44 @@ var htmlEntities = {
|
|
|
9
10
|
'>': '>',
|
|
10
11
|
'"': '"',
|
|
11
12
|
"'": '''
|
|
12
|
-
};
|
|
13
|
+
};
|
|
13
14
|
|
|
15
|
+
// Used to match HTML entities and HTML characters.
|
|
14
16
|
var regexUnescapedHtml = /[&<>"']/g;
|
|
15
17
|
var regexHasUnescapedHtml = RegExp(regexUnescapedHtml.source);
|
|
18
|
+
|
|
16
19
|
/**
|
|
17
20
|
* Converts the characters "&", "<", ">", '"', and "'" in `string` to their
|
|
18
21
|
* corresponding HTML entities.
|
|
19
22
|
*/
|
|
20
|
-
|
|
21
23
|
export function escape(value) {
|
|
22
24
|
return value && regexHasUnescapedHtml.test(value) ? value.replace(regexUnescapedHtml, function (character) {
|
|
23
25
|
return htmlEntities[character];
|
|
24
26
|
}) : value;
|
|
25
27
|
}
|
|
28
|
+
|
|
26
29
|
/**
|
|
27
30
|
* This implementation is taken from Lodash implementation.
|
|
28
31
|
* See: https://github.com/lodash/lodash/blob/4.17.11-npm/unescape.js
|
|
29
32
|
*/
|
|
30
|
-
// Used to map HTML entities to characters.
|
|
31
33
|
|
|
34
|
+
// Used to map HTML entities to characters.
|
|
32
35
|
var htmlCharacters = {
|
|
33
36
|
'&': '&',
|
|
34
37
|
'<': '<',
|
|
35
38
|
'>': '>',
|
|
36
39
|
'"': '"',
|
|
37
40
|
''': "'"
|
|
38
|
-
};
|
|
41
|
+
};
|
|
39
42
|
|
|
43
|
+
// Used to match HTML entities and HTML characters.
|
|
40
44
|
var regexEscapedHtml = /&(amp|quot|lt|gt|#39);/g;
|
|
41
45
|
var regexHasEscapedHtml = RegExp(regexEscapedHtml.source);
|
|
46
|
+
|
|
42
47
|
/**
|
|
43
48
|
* Converts the HTML entities "&", "<", ">", '"', and "'" in `string` to their
|
|
44
49
|
* characters.
|
|
45
50
|
*/
|
|
46
|
-
|
|
47
51
|
export function unescape(value) {
|
|
48
52
|
return value && regexHasEscapedHtml.test(value) ? value.replace(regexEscapedHtml, function (character) {
|
|
49
53
|
return htmlCharacters[character];
|
|
@@ -2,13 +2,11 @@ export function unescapeFacetValue(value) {
|
|
|
2
2
|
if (typeof value === 'string') {
|
|
3
3
|
return value.replace(/^\\-/, '-');
|
|
4
4
|
}
|
|
5
|
-
|
|
6
5
|
return value;
|
|
7
6
|
}
|
|
8
7
|
export function escapeFacetValue(value) {
|
|
9
8
|
if (typeof value === 'number' && value < 0 || typeof value === 'string') {
|
|
10
9
|
return String(value).replace(/^-/, '\\-');
|
|
11
10
|
}
|
|
12
|
-
|
|
13
11
|
return value;
|
|
14
12
|
}
|
package/es/lib/utils/find.js
CHANGED
|
@@ -6,14 +6,12 @@
|
|
|
6
6
|
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find
|
|
7
7
|
export function find(items, predicate) {
|
|
8
8
|
var value;
|
|
9
|
-
|
|
10
9
|
for (var i = 0; i < items.length; i++) {
|
|
11
|
-
value = items[i];
|
|
12
|
-
|
|
10
|
+
value = items[i];
|
|
11
|
+
// inlined for performance: if (Call(predicate, thisArg, [value, i, list])) {
|
|
13
12
|
if (predicate(value, i, items)) {
|
|
14
13
|
return value;
|
|
15
14
|
}
|
|
16
15
|
}
|
|
17
|
-
|
|
18
16
|
return undefined;
|
|
19
17
|
}
|
|
@@ -1,48 +1,36 @@
|
|
|
1
1
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
-
|
|
3
2
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
|
-
|
|
5
3
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
6
|
-
|
|
7
4
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
8
|
-
|
|
9
|
-
function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
10
|
-
|
|
5
|
+
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
11
6
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
12
|
-
|
|
13
7
|
var latLngRegExp = /^(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)$/;
|
|
14
8
|
export function aroundLatLngToPosition(value) {
|
|
15
|
-
var pattern = value.match(latLngRegExp);
|
|
16
|
-
// throw an error due to the wrong format. So throw an error should be safe.
|
|
9
|
+
var pattern = value.match(latLngRegExp);
|
|
17
10
|
|
|
11
|
+
// Since the value provided is the one send with the request, the API should
|
|
12
|
+
// throw an error due to the wrong format. So throw an error should be safe.
|
|
18
13
|
if (!pattern) {
|
|
19
14
|
throw new Error("Invalid value for \"aroundLatLng\" parameter: \"".concat(value, "\""));
|
|
20
15
|
}
|
|
21
|
-
|
|
22
16
|
return {
|
|
23
17
|
lat: parseFloat(pattern[1]),
|
|
24
18
|
lng: parseFloat(pattern[2])
|
|
25
19
|
};
|
|
26
20
|
}
|
|
27
|
-
|
|
28
21
|
function insideBoundingBoxArrayToBoundingBox(value) {
|
|
29
22
|
var _value = _slicedToArray(value, 1),
|
|
30
|
-
|
|
31
|
-
|
|
23
|
+
_value$ = _value[0];
|
|
32
24
|
_value$ = _value$ === void 0 ? [undefined, undefined, undefined, undefined] : _value$;
|
|
33
|
-
|
|
34
25
|
var _value$2 = _slicedToArray(_value$, 4),
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
26
|
+
neLat = _value$2[0],
|
|
27
|
+
neLng = _value$2[1],
|
|
28
|
+
swLat = _value$2[2],
|
|
29
|
+
swLng = _value$2[3]; // Since the value provided is the one send with the request, the API should
|
|
39
30
|
// throw an error due to the wrong format. So throw an error should be safe.
|
|
40
|
-
|
|
41
|
-
|
|
42
31
|
if (!neLat || !neLng || !swLat || !swLng) {
|
|
43
32
|
throw new Error("Invalid value for \"insideBoundingBox\" parameter: [".concat(value, "]"));
|
|
44
33
|
}
|
|
45
|
-
|
|
46
34
|
return {
|
|
47
35
|
northEast: {
|
|
48
36
|
lat: neLat,
|
|
@@ -54,21 +42,17 @@ function insideBoundingBoxArrayToBoundingBox(value) {
|
|
|
54
42
|
}
|
|
55
43
|
};
|
|
56
44
|
}
|
|
57
|
-
|
|
58
45
|
function insideBoundingBoxStringToBoundingBox(value) {
|
|
59
46
|
var _value$split$map = value.split(',').map(parseFloat),
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
47
|
+
_value$split$map2 = _slicedToArray(_value$split$map, 4),
|
|
48
|
+
neLat = _value$split$map2[0],
|
|
49
|
+
neLng = _value$split$map2[1],
|
|
50
|
+
swLat = _value$split$map2[2],
|
|
51
|
+
swLng = _value$split$map2[3]; // Since the value provided is the one send with the request, the API should
|
|
65
52
|
// throw an error due to the wrong format. So throw an error should be safe.
|
|
66
|
-
|
|
67
|
-
|
|
68
53
|
if (!neLat || !neLng || !swLat || !swLng) {
|
|
69
54
|
throw new Error("Invalid value for \"insideBoundingBox\" parameter: \"".concat(value, "\""));
|
|
70
55
|
}
|
|
71
|
-
|
|
72
56
|
return {
|
|
73
57
|
northEast: {
|
|
74
58
|
lat: neLat,
|
|
@@ -80,11 +64,9 @@ function insideBoundingBoxStringToBoundingBox(value) {
|
|
|
80
64
|
}
|
|
81
65
|
};
|
|
82
66
|
}
|
|
83
|
-
|
|
84
67
|
export function insideBoundingBoxToBoundingBox(value) {
|
|
85
68
|
if (Array.isArray(value)) {
|
|
86
69
|
return insideBoundingBoxArrayToBoundingBox(value);
|
|
87
70
|
}
|
|
88
|
-
|
|
89
71
|
return insideBoundingBoxStringToBoundingBox(value);
|
|
90
72
|
}
|
|
@@ -3,8 +3,8 @@ export function getAppIdAndApiKey(searchClient) {
|
|
|
3
3
|
if (searchClient.transporter) {
|
|
4
4
|
// searchClient v4
|
|
5
5
|
var _searchClient$transpo = searchClient.transporter,
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
headers = _searchClient$transpo.headers,
|
|
7
|
+
queryParameters = _searchClient$transpo.queryParameters;
|
|
8
8
|
var APP_ID = 'x-algolia-application-id';
|
|
9
9
|
var API_KEY = 'x-algolia-api-key';
|
|
10
10
|
var appId = headers[APP_ID] || queryParameters[APP_ID];
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { isDomElement } from "./isDomElement.js";
|
|
2
|
+
|
|
2
3
|
/**
|
|
3
4
|
* Return the container. If it's a string, it is considered a
|
|
4
5
|
* css selector and retrieves the first matching element. Otherwise
|
|
@@ -8,20 +9,15 @@ import { isDomElement } from "./isDomElement.js";
|
|
|
8
9
|
* @return {HTMLElement} Container node
|
|
9
10
|
* @throws Error when the type is not correct
|
|
10
11
|
*/
|
|
11
|
-
|
|
12
12
|
export function getContainerNode(selectorOrHTMLElement) {
|
|
13
13
|
var isSelectorString = typeof selectorOrHTMLElement === 'string';
|
|
14
14
|
var domElement = isSelectorString ? document.querySelector(selectorOrHTMLElement) : selectorOrHTMLElement;
|
|
15
|
-
|
|
16
15
|
if (!isDomElement(domElement)) {
|
|
17
16
|
var errorMessage = 'Container must be `string` or `HTMLElement`.';
|
|
18
|
-
|
|
19
17
|
if (isSelectorString) {
|
|
20
18
|
errorMessage += " Unable to find ".concat(selectorOrHTMLElement);
|
|
21
19
|
}
|
|
22
|
-
|
|
23
20
|
throw new Error(errorMessage);
|
|
24
21
|
}
|
|
25
|
-
|
|
26
22
|
return domElement;
|
|
27
23
|
}
|
|
@@ -2,14 +2,11 @@ import { unescape } from "./escape-html.js";
|
|
|
2
2
|
var hasAlphanumeric = new RegExp(/\w/i);
|
|
3
3
|
export function getHighlightFromSiblings(parts, i) {
|
|
4
4
|
var _parts, _parts2;
|
|
5
|
-
|
|
6
5
|
var current = parts[i];
|
|
7
6
|
var isNextHighlighted = ((_parts = parts[i + 1]) === null || _parts === void 0 ? void 0 : _parts.isHighlighted) || true;
|
|
8
7
|
var isPreviousHighlighted = ((_parts2 = parts[i - 1]) === null || _parts2 === void 0 ? void 0 : _parts2.isHighlighted) || true;
|
|
9
|
-
|
|
10
8
|
if (!hasAlphanumeric.test(unescape(current.value)) && isPreviousHighlighted === isNextHighlighted) {
|
|
11
9
|
return isPreviousHighlighted;
|
|
12
10
|
}
|
|
13
|
-
|
|
14
11
|
return current.isHighlighted;
|
|
15
12
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { TAG_REPLACEMENT } from "./escape-highlight.js";
|
|
2
2
|
export function getHighlightedParts(highlightedValue) {
|
|
3
3
|
var highlightPostTag = TAG_REPLACEMENT.highlightPostTag,
|
|
4
|
-
|
|
4
|
+
highlightPreTag = TAG_REPLACEMENT.highlightPreTag;
|
|
5
5
|
var splitByPreTag = highlightedValue.split(highlightPreTag);
|
|
6
6
|
var firstValue = splitByPreTag.shift();
|
|
7
7
|
var elements = !firstValue ? [] : [{
|
|
@@ -14,7 +14,6 @@ export function getHighlightedParts(highlightedValue) {
|
|
|
14
14
|
value: splitByPostTag[0],
|
|
15
15
|
isHighlighted: true
|
|
16
16
|
});
|
|
17
|
-
|
|
18
17
|
if (splitByPostTag[1] !== '') {
|
|
19
18
|
elements.push({
|
|
20
19
|
value: splitByPostTag[1],
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { find } from "./find.js";
|
|
2
2
|
import { unescapeFacetValue, escapeFacetValue } from "./escapeFacetValue.js";
|
|
3
|
-
|
|
4
3
|
function getRefinement(state, type, attribute, name) {
|
|
5
4
|
var resultsFacets = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : [];
|
|
6
5
|
var res = {
|
|
@@ -13,60 +12,51 @@ function getRefinement(state, type, attribute, name) {
|
|
|
13
12
|
return resultsFacet.name === attribute;
|
|
14
13
|
});
|
|
15
14
|
var count;
|
|
16
|
-
|
|
17
15
|
if (type === 'hierarchical') {
|
|
18
16
|
(function () {
|
|
19
17
|
var facetDeclaration = state.getHierarchicalFacetByName(attribute);
|
|
20
18
|
var nameParts = name.split(facetDeclaration.separator);
|
|
21
|
-
|
|
22
19
|
var getFacetRefinement = function getFacetRefinement(facetData) {
|
|
23
20
|
return function (refinementKey) {
|
|
24
21
|
return facetData[refinementKey];
|
|
25
22
|
};
|
|
26
23
|
};
|
|
27
|
-
|
|
28
24
|
var _loop = function _loop(i) {
|
|
29
25
|
facet = facet && facet.data && find(Object.keys(facet.data).map(getFacetRefinement(facet.data)), function (refinement) {
|
|
30
26
|
return refinement.name === nameParts[i];
|
|
31
27
|
});
|
|
32
28
|
};
|
|
33
|
-
|
|
34
29
|
for (var i = 0; facet !== undefined && i < nameParts.length; ++i) {
|
|
35
30
|
_loop(i);
|
|
36
31
|
}
|
|
37
|
-
|
|
38
32
|
count = facet && facet.count;
|
|
39
33
|
})();
|
|
40
34
|
} else {
|
|
41
35
|
count = facet && facet.data && facet.data[res.name];
|
|
42
36
|
}
|
|
43
|
-
|
|
44
37
|
if (count !== undefined) {
|
|
45
38
|
res.count = count;
|
|
46
39
|
}
|
|
47
|
-
|
|
48
40
|
if (facet && facet.exhaustive !== undefined) {
|
|
49
41
|
res.exhaustive = facet.exhaustive;
|
|
50
42
|
}
|
|
51
|
-
|
|
52
43
|
return res;
|
|
53
44
|
}
|
|
54
|
-
|
|
55
45
|
export function getRefinements(results, state) {
|
|
56
46
|
var includesQuery = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
57
47
|
var refinements = [];
|
|
58
48
|
var _state$facetsRefineme = state.facetsRefinements,
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
49
|
+
facetsRefinements = _state$facetsRefineme === void 0 ? {} : _state$facetsRefineme,
|
|
50
|
+
_state$facetsExcludes = state.facetsExcludes,
|
|
51
|
+
facetsExcludes = _state$facetsExcludes === void 0 ? {} : _state$facetsExcludes,
|
|
52
|
+
_state$disjunctiveFac = state.disjunctiveFacetsRefinements,
|
|
53
|
+
disjunctiveFacetsRefinements = _state$disjunctiveFac === void 0 ? {} : _state$disjunctiveFac,
|
|
54
|
+
_state$hierarchicalFa = state.hierarchicalFacetsRefinements,
|
|
55
|
+
hierarchicalFacetsRefinements = _state$hierarchicalFa === void 0 ? {} : _state$hierarchicalFa,
|
|
56
|
+
_state$numericRefinem = state.numericRefinements,
|
|
57
|
+
numericRefinements = _state$numericRefinem === void 0 ? {} : _state$numericRefinem,
|
|
58
|
+
_state$tagRefinements = state.tagRefinements,
|
|
59
|
+
tagRefinements = _state$tagRefinements === void 0 ? [] : _state$tagRefinements;
|
|
70
60
|
Object.keys(facetsRefinements).forEach(function (attribute) {
|
|
71
61
|
var refinementNames = facetsRefinements[attribute];
|
|
72
62
|
refinementNames.forEach(function (refinementName) {
|
|
@@ -87,7 +77,8 @@ export function getRefinements(results, state) {
|
|
|
87
77
|
Object.keys(disjunctiveFacetsRefinements).forEach(function (attribute) {
|
|
88
78
|
var refinementNames = disjunctiveFacetsRefinements[attribute];
|
|
89
79
|
refinementNames.forEach(function (refinementName) {
|
|
90
|
-
refinements.push(getRefinement(state, 'disjunctive', attribute,
|
|
80
|
+
refinements.push(getRefinement(state, 'disjunctive', attribute,
|
|
81
|
+
// We unescape any disjunctive refined values with `unescapeFacetValue` because
|
|
91
82
|
// they can be escaped on negative numeric values with `escapeFacetValue`.
|
|
92
83
|
unescapeFacetValue(refinementName), results.disjunctiveFacets));
|
|
93
84
|
});
|
|
@@ -122,7 +113,6 @@ export function getRefinements(results, state) {
|
|
|
122
113
|
name: refinementName
|
|
123
114
|
});
|
|
124
115
|
});
|
|
125
|
-
|
|
126
116
|
if (includesQuery && state.query && state.query.trim()) {
|
|
127
117
|
refinements.push({
|
|
128
118
|
attribute: 'query',
|
|
@@ -131,6 +121,5 @@ export function getRefinements(results, state) {
|
|
|
131
121
|
query: state.query
|
|
132
122
|
});
|
|
133
123
|
}
|
|
134
|
-
|
|
135
124
|
return refinements;
|
|
136
125
|
}
|
|
@@ -1,23 +1,18 @@
|
|
|
1
1
|
export function getWidgetAttribute(widget, initOptions) {
|
|
2
2
|
var _widget$getWidgetRend;
|
|
3
|
-
|
|
4
3
|
var renderState = (_widget$getWidgetRend = widget.getWidgetRenderState) === null || _widget$getWidgetRend === void 0 ? void 0 : _widget$getWidgetRend.call(widget, initOptions);
|
|
5
4
|
var attribute = null;
|
|
6
|
-
|
|
7
5
|
if (renderState && renderState.widgetParams) {
|
|
8
6
|
// casting as widgetParams is checked just before
|
|
9
7
|
var widgetParams = renderState.widgetParams;
|
|
10
|
-
|
|
11
8
|
if (widgetParams.attribute) {
|
|
12
9
|
attribute = widgetParams.attribute;
|
|
13
10
|
} else if (Array.isArray(widgetParams.attributes)) {
|
|
14
11
|
attribute = widgetParams.attributes[0];
|
|
15
12
|
}
|
|
16
13
|
}
|
|
17
|
-
|
|
18
14
|
if (typeof attribute !== 'string') {
|
|
19
15
|
throw new Error("Could not find the attribute of the widget:\n\n".concat(JSON.stringify(widget), "\n\nPlease check whether the widget's getWidgetRenderState returns widgetParams.attribute correctly."));
|
|
20
16
|
}
|
|
21
|
-
|
|
22
17
|
return attribute;
|
|
23
18
|
}
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
2
|
-
|
|
3
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
4
|
-
|
|
1
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
2
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
5
3
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
|
-
|
|
7
4
|
export function addAbsolutePosition(hits, page, hitsPerPage) {
|
|
8
5
|
return hits.map(function (hit, idx) {
|
|
9
6
|
return _objectSpread(_objectSpread({}, hit), {}, {
|
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
2
|
-
|
|
3
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
4
|
-
|
|
1
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
2
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
5
3
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
|
-
|
|
7
4
|
export function addQueryID(hits, queryID) {
|
|
8
5
|
if (!queryID) {
|
|
9
6
|
return hits;
|
|
10
7
|
}
|
|
11
|
-
|
|
12
8
|
return hits.map(function (hit) {
|
|
13
9
|
return _objectSpread(_objectSpread({}, hit), {}, {
|
|
14
10
|
__queryID: queryID
|
package/es/lib/utils/isEqual.js
CHANGED
|
@@ -1,31 +1,24 @@
|
|
|
1
1
|
function isPrimitive(obj) {
|
|
2
2
|
return obj !== Object(obj);
|
|
3
3
|
}
|
|
4
|
-
|
|
5
4
|
export function isEqual(first, second) {
|
|
6
5
|
if (first === second) {
|
|
7
6
|
return true;
|
|
8
7
|
}
|
|
9
|
-
|
|
10
8
|
if (isPrimitive(first) || isPrimitive(second) || typeof first === 'function' || typeof second === 'function') {
|
|
11
9
|
return first === second;
|
|
12
10
|
}
|
|
13
|
-
|
|
14
11
|
if (Object.keys(first).length !== Object.keys(second).length) {
|
|
15
12
|
return false;
|
|
16
13
|
}
|
|
17
|
-
|
|
18
14
|
for (var _i = 0, _Object$keys = Object.keys(first); _i < _Object$keys.length; _i++) {
|
|
19
15
|
var key = _Object$keys[_i];
|
|
20
|
-
|
|
21
16
|
if (!(key in second)) {
|
|
22
17
|
return false;
|
|
23
18
|
}
|
|
24
|
-
|
|
25
19
|
if (!isEqual(first[key], second[key])) {
|
|
26
20
|
return false;
|
|
27
21
|
}
|
|
28
22
|
}
|
|
29
|
-
|
|
30
23
|
return true;
|
|
31
24
|
}
|
|
@@ -1,42 +1,35 @@
|
|
|
1
|
-
function _typeof(obj) { "@babel/helpers - typeof";
|
|
2
|
-
|
|
1
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
3
2
|
/**
|
|
4
3
|
* This implementation is taken from Lodash implementation.
|
|
5
4
|
* See: https://github.com/lodash/lodash/blob/master/isPlainObject.js
|
|
6
5
|
*/
|
|
6
|
+
|
|
7
7
|
function getTag(value) {
|
|
8
8
|
if (value === null) {
|
|
9
9
|
return value === undefined ? '[object Undefined]' : '[object Null]';
|
|
10
10
|
}
|
|
11
|
-
|
|
12
11
|
return Object.prototype.toString.call(value);
|
|
13
12
|
}
|
|
14
|
-
|
|
15
13
|
function isObjectLike(value) {
|
|
16
14
|
return _typeof(value) === 'object' && value !== null;
|
|
17
15
|
}
|
|
16
|
+
|
|
18
17
|
/**
|
|
19
18
|
* Checks if `value` is a plain object.
|
|
20
19
|
*
|
|
21
20
|
* A plain object is an object created by the `Object`
|
|
22
21
|
* constructor or with a `[[Prototype]]` of `null`.
|
|
23
22
|
*/
|
|
24
|
-
|
|
25
|
-
|
|
26
23
|
export function isPlainObject(value) {
|
|
27
24
|
if (!isObjectLike(value) || getTag(value) !== '[object Object]') {
|
|
28
25
|
return false;
|
|
29
26
|
}
|
|
30
|
-
|
|
31
27
|
if (Object.getPrototypeOf(value) === null) {
|
|
32
28
|
return true;
|
|
33
29
|
}
|
|
34
|
-
|
|
35
30
|
var proto = value;
|
|
36
|
-
|
|
37
31
|
while (Object.getPrototypeOf(proto) !== null) {
|
|
38
32
|
proto = Object.getPrototypeOf(proto);
|
|
39
33
|
}
|
|
40
|
-
|
|
41
34
|
return Object.getPrototypeOf(value) === proto;
|
|
42
35
|
}
|
package/es/lib/utils/logger.js
CHANGED
|
@@ -1,31 +1,27 @@
|
|
|
1
1
|
import { noop } from "./noop.js";
|
|
2
|
-
|
|
3
2
|
/**
|
|
4
3
|
* Logs a warning when this function is called, in development environment only.
|
|
5
4
|
*/
|
|
6
5
|
var deprecate = function deprecate(fn, message) {
|
|
7
6
|
return fn;
|
|
8
7
|
};
|
|
8
|
+
|
|
9
9
|
/**
|
|
10
10
|
* Logs a warning
|
|
11
11
|
* This is used to log issues in development environment only.
|
|
12
12
|
*/
|
|
13
|
-
|
|
14
|
-
|
|
15
13
|
var warn = noop;
|
|
14
|
+
|
|
16
15
|
/**
|
|
17
16
|
* Logs a warning if the condition is not met.
|
|
18
17
|
* This is used to log issues in development environment only.
|
|
19
18
|
*/
|
|
20
|
-
|
|
21
19
|
var _warning = noop;
|
|
22
|
-
|
|
23
20
|
if (process.env.NODE_ENV === 'development') {
|
|
24
21
|
warn = function warn(message) {
|
|
25
22
|
// eslint-disable-next-line no-console
|
|
26
23
|
console.warn("[InstantSearch.js]: ".concat(message.trim()));
|
|
27
24
|
};
|
|
28
|
-
|
|
29
25
|
deprecate = function deprecate(fn, message) {
|
|
30
26
|
var hasAlreadyPrinted = false;
|
|
31
27
|
return function () {
|
|
@@ -33,25 +29,19 @@ if (process.env.NODE_ENV === 'development') {
|
|
|
33
29
|
hasAlreadyPrinted = true;
|
|
34
30
|
warn(message);
|
|
35
31
|
}
|
|
36
|
-
|
|
37
32
|
return fn.apply(void 0, arguments);
|
|
38
33
|
};
|
|
39
34
|
};
|
|
40
|
-
|
|
41
35
|
_warning = function warning(condition, message) {
|
|
42
36
|
if (condition) {
|
|
43
37
|
return;
|
|
44
38
|
}
|
|
45
|
-
|
|
46
39
|
var hasAlreadyPrinted = _warning.cache[message];
|
|
47
|
-
|
|
48
40
|
if (!hasAlreadyPrinted) {
|
|
49
41
|
_warning.cache[message] = true;
|
|
50
42
|
warn(message);
|
|
51
43
|
}
|
|
52
44
|
};
|
|
53
|
-
|
|
54
45
|
_warning.cache = {};
|
|
55
46
|
}
|
|
56
|
-
|
|
57
47
|
export { warn, deprecate, _warning as warning };
|