instantsearch.js 4.49.1 → 4.49.3
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 +14 -8
- package/cjs/components/Answers/Answers.js +11 -18
- package/cjs/components/Breadcrumb/Breadcrumb.js +6 -13
- package/cjs/components/ClearRefinements/ClearRefinements.js +5 -12
- package/cjs/components/CurrentRefinements/CurrentRefinements.js +8 -16
- package/cjs/components/GeoSearchControls/GeoSearchButton.js +4 -7
- package/cjs/components/GeoSearchControls/GeoSearchControls.js +14 -23
- package/cjs/components/GeoSearchControls/GeoSearchToggle.js +4 -7
- package/cjs/components/Highlight/Highlight.js +5 -12
- package/cjs/components/Hits/Hits.js +13 -22
- package/cjs/components/InfiniteHits/InfiniteHits.js +18 -27
- package/cjs/components/InternalHighlight/InternalHighlight.js +0 -3
- package/cjs/components/MenuSelect/MenuSelect.js +12 -22
- package/cjs/components/Pagination/Pagination.js +12 -20
- package/cjs/components/Panel/Panel.js +9 -28
- package/cjs/components/PoweredBy/PoweredBy.js +4 -6
- package/cjs/components/QueryRuleCustomData/QueryRuleCustomData.js +3 -8
- package/cjs/components/RangeInput/RangeInput.js +21 -51
- package/cjs/components/RefinementList/RefinementList.js +30 -81
- package/cjs/components/RefinementList/RefinementListItem.js +9 -15
- package/cjs/components/RelevantSort/RelevantSort.js +5 -10
- package/cjs/components/ReverseHighlight/ReverseHighlight.js +5 -12
- package/cjs/components/ReverseSnippet/ReverseSnippet.js +5 -12
- package/cjs/components/SearchBox/SearchBox.js +35 -77
- package/cjs/components/Selector/Selector.js +3 -7
- package/cjs/components/Slider/Pit.js +7 -11
- package/cjs/components/Slider/Rheostat.js +69 -133
- package/cjs/components/Slider/Slider.js +39 -72
- package/cjs/components/Snippet/Snippet.js +5 -12
- package/cjs/components/Stats/Stats.js +13 -22
- package/cjs/components/Template/Template.js +17 -44
- package/cjs/components/ToggleRefinement/ToggleRefinement.js +5 -11
- package/cjs/components/VoiceSearch/VoiceSearch.js +9 -17
- package/cjs/connectors/answers/connectAnswers.js +36 -46
- package/cjs/connectors/autocomplete/connectAutocomplete.js +21 -35
- package/cjs/connectors/breadcrumb/connectBreadcrumb.js +27 -55
- package/cjs/connectors/clear-refinements/connectClearRefinements.js +41 -56
- package/cjs/connectors/configure/connectConfigure.js +17 -28
- package/cjs/connectors/configure-related-items/connectConfigureRelatedItems.js +21 -43
- package/cjs/connectors/current-refinements/connectCurrentRefinements.js +29 -65
- package/cjs/connectors/dynamic-widgets/connectDynamicWidgets.js +27 -45
- package/cjs/connectors/geo-search/connectGeoSearch.js +32 -59
- package/cjs/connectors/hierarchical-menu/connectHierarchicalMenu.js +50 -82
- package/cjs/connectors/hits/connectHits.js +25 -38
- package/cjs/connectors/hits/connectHitsWithInsights.js +3 -7
- package/cjs/connectors/hits-per-page/connectHitsPerPage.js +26 -46
- package/cjs/connectors/index.js +92 -126
- package/cjs/connectors/infinite-hits/connectInfiniteHits.js +43 -75
- package/cjs/connectors/infinite-hits/connectInfiniteHitsWithInsights.js +3 -7
- package/cjs/connectors/menu/connectMenu.js +39 -73
- package/cjs/connectors/numeric-menu/connectNumericMenu.js +37 -86
- package/cjs/connectors/pagination/Paginator.js +11 -25
- package/cjs/connectors/pagination/connectPagination.js +17 -31
- package/cjs/connectors/powered-by/connectPoweredBy.js +13 -19
- package/cjs/connectors/query-rules/connectQueryRules.js +44 -65
- package/cjs/connectors/range/connectRange.js +72 -129
- package/cjs/connectors/rating-menu/connectRatingMenu.js +34 -87
- package/cjs/connectors/refinement-list/connectRefinementList.js +51 -79
- package/cjs/connectors/relevant-sort/connectRelevantSort.js +11 -18
- package/cjs/connectors/search-box/connectSearchBox.js +15 -28
- package/cjs/connectors/sort-by/connectSortBy.js +21 -28
- package/cjs/connectors/stats/connectStats.js +12 -16
- package/cjs/connectors/toggle-refinement/connectToggleRefinement.js +44 -75
- package/cjs/connectors/voice-search/connectVoiceSearch.js +22 -41
- package/cjs/helpers/components/Highlight.js +11 -18
- package/cjs/helpers/components/ReverseHighlight.js +19 -26
- package/cjs/helpers/components/ReverseSnippet.js +19 -26
- package/cjs/helpers/components/Snippet.js +11 -18
- package/cjs/helpers/components/index.js +4 -12
- package/cjs/helpers/get-insights-anonymous-user-token.js +6 -17
- package/cjs/helpers/highlight.js +15 -19
- package/cjs/helpers/index.js +23 -37
- package/cjs/helpers/insights.js +9 -21
- package/cjs/helpers/reverseHighlight.js +16 -20
- package/cjs/helpers/reverseSnippet.js +16 -20
- package/cjs/helpers/snippet.js +15 -19
- package/cjs/index.js +12 -27
- package/cjs/lib/InstantSearch.js +108 -207
- package/cjs/lib/createHelpers.js +15 -19
- package/cjs/lib/formatNumber.js +0 -1
- package/cjs/lib/infiniteHitsCache/index.js +1 -3
- package/cjs/lib/infiniteHitsCache/sessionStorage.js +14 -22
- package/cjs/lib/insights/client.js +17 -40
- package/cjs/lib/insights/index.js +9 -15
- package/cjs/lib/insights/listener.js +7 -24
- package/cjs/lib/routers/history.js +75 -117
- package/cjs/lib/routers/index.js +1 -3
- package/cjs/lib/stateMappings/index.js +2 -5
- package/cjs/lib/stateMappings/simple.js +11 -14
- package/cjs/lib/stateMappings/singleIndex.js +6 -8
- package/cjs/lib/suit.js +2 -5
- package/cjs/lib/templating/index.js +2 -6
- package/cjs/lib/templating/prepareTemplateProps.js +14 -22
- package/cjs/lib/templating/renderTemplate.js +17 -30
- package/cjs/lib/utils/capitalize.js +0 -1
- package/cjs/lib/utils/checkIndexUiState.js +19 -47
- package/cjs/lib/utils/checkRendering.js +1 -3
- package/cjs/lib/utils/clearRefinements.js +2 -9
- package/cjs/lib/utils/concatHighlightedParts.js +2 -4
- package/cjs/lib/utils/createConcurrentSafePromise.js +0 -3
- package/cjs/lib/utils/createSendEventForFacet.js +8 -15
- package/cjs/lib/utils/createSendEventForHits.js +10 -34
- package/cjs/lib/utils/debounce.js +0 -3
- package/cjs/lib/utils/defer.js +0 -11
- package/cjs/lib/utils/detect-insights-client.js +1 -3
- package/cjs/lib/utils/documentation.js +2 -5
- package/cjs/lib/utils/escape-highlight.js +13 -26
- 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 +21 -37
- package/cjs/lib/utils/getAppIdAndApiKey.js +2 -3
- package/cjs/lib/utils/getContainerNode.js +1 -7
- package/cjs/lib/utils/getHighlightFromSiblings.js +1 -7
- package/cjs/lib/utils/getHighlightedParts.js +2 -5
- package/cjs/lib/utils/getObjectType.js +0 -1
- package/cjs/lib/utils/getPropertyByPath.js +0 -1
- package/cjs/lib/utils/getRefinements.js +30 -45
- package/cjs/lib/utils/getWidgetAttribute.js +0 -6
- package/cjs/lib/utils/hits-absolute-position.js +6 -7
- package/cjs/lib/utils/hits-query-id.js +6 -8
- package/cjs/lib/utils/index.js +46 -138
- package/cjs/lib/utils/isDomElement.js +0 -1
- package/cjs/lib/utils/isEqual.js +2 -7
- 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 +6 -16
- package/cjs/lib/utils/mergeSearchParameters.js +23 -43
- package/cjs/lib/utils/noop.js +0 -1
- package/cjs/lib/utils/range.js +9 -15
- package/cjs/lib/utils/render-args.js +0 -2
- package/cjs/lib/utils/resolveSearchParameters.js +0 -3
- package/cjs/lib/utils/reverseHighlightedParts.js +7 -10
- package/cjs/lib/utils/safelyRunOnBrowser.js +7 -9
- package/cjs/lib/utils/serializer.js +1 -3
- package/cjs/lib/utils/setIndexHelperState.js +2 -7
- 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 +12 -37
- package/cjs/middlewares/createInsightsMiddleware.js +30 -54
- package/cjs/middlewares/createMetadataMiddleware.js +7 -15
- package/cjs/middlewares/createRouterMiddleware.js +16 -24
- package/cjs/middlewares/index.js +3 -9
- package/cjs/types/algoliasearch.js +0 -2
- package/cjs/types/index.js +14 -42
- package/cjs/widgets/analytics/analytics.js +22 -48
- package/cjs/widgets/answers/answers.js +32 -49
- package/cjs/widgets/breadcrumb/breadcrumb.js +31 -48
- package/cjs/widgets/clear-refinements/clear-refinements.js +28 -45
- package/cjs/widgets/configure/configure.js +9 -14
- package/cjs/widgets/configure-related-items/configure-related-items.js +9 -14
- package/cjs/widgets/current-refinements/current-refinements.js +22 -37
- package/cjs/widgets/dynamic-widgets/dynamic-widgets.js +17 -32
- package/cjs/widgets/geo-search/GeoSearchRenderer.js +50 -72
- package/cjs/widgets/geo-search/createHTMLMarker.js +34 -62
- package/cjs/widgets/geo-search/defaultTemplates.js +0 -3
- package/cjs/widgets/geo-search/geo-search.js +44 -70
- package/cjs/widgets/hierarchical-menu/defaultTemplates.js +5 -9
- package/cjs/widgets/hierarchical-menu/hierarchical-menu.js +41 -57
- package/cjs/widgets/hits/hits.js +32 -50
- package/cjs/widgets/hits-per-page/hits-per-page.js +24 -39
- package/cjs/widgets/index/index.js +71 -113
- package/cjs/widgets/index.js +47 -85
- package/cjs/widgets/infinite-hits/infinite-hits.js +39 -57
- package/cjs/widgets/menu/defaultTemplates.js +4 -8
- package/cjs/widgets/menu/menu.js +36 -53
- package/cjs/widgets/menu-select/defaultTemplates.js +2 -4
- package/cjs/widgets/menu-select/menu-select.js +31 -48
- package/cjs/widgets/numeric-menu/defaultTemplates.js +3 -5
- package/cjs/widgets/numeric-menu/numeric-menu.js +30 -47
- package/cjs/widgets/pagination/pagination.js +43 -61
- package/cjs/widgets/panel/panel.js +31 -56
- package/cjs/widgets/places/places.js +22 -34
- package/cjs/widgets/powered-by/powered-by.js +20 -34
- package/cjs/widgets/query-rule-context/query-rule-context.js +10 -18
- package/cjs/widgets/query-rule-custom-data/query-rule-custom-data.js +24 -39
- package/cjs/widgets/range-input/range-input.js +36 -60
- package/cjs/widgets/range-slider/range-slider.js +39 -61
- package/cjs/widgets/rating-menu/defaultTemplates.js +9 -16
- package/cjs/widgets/rating-menu/rating-menu.js +30 -48
- package/cjs/widgets/refinement-list/defaultTemplates.js +6 -10
- package/cjs/widgets/refinement-list/refinement-list.js +54 -72
- package/cjs/widgets/relevant-sort/relevant-sort.js +21 -37
- package/cjs/widgets/search-box/defaultTemplates.js +0 -5
- package/cjs/widgets/search-box/search-box.js +42 -57
- package/cjs/widgets/sort-by/sort-by.js +21 -36
- package/cjs/widgets/stats/defaultTemplates.js +1 -2
- package/cjs/widgets/stats/stats.js +40 -67
- package/cjs/widgets/toggle-refinement/toggle-refinement.js +29 -46
- package/cjs/widgets/voice-search/defaultTemplates.js +4 -14
- package/cjs/widgets/voice-search/voice-search.js +28 -44
- package/dist/instantsearch.development.d.ts +9 -6
- package/dist/instantsearch.development.js +1840 -3142
- package/dist/instantsearch.development.js.map +1 -1
- package/dist/instantsearch.production.d.ts +9 -6
- package/dist/instantsearch.production.min.d.ts +9 -6
- package/dist/instantsearch.production.min.js +2 -2
- package/dist/instantsearch.production.min.js.map +1 -1
- package/es/components/Answers/Answers.js +10 -13
- package/es/components/Breadcrumb/Breadcrumb.js +5 -8
- package/es/components/ClearRefinements/ClearRefinements.js +4 -7
- package/es/components/CurrentRefinements/CurrentRefinements.js +5 -10
- package/es/components/GeoSearchControls/GeoSearchButton.js +4 -6
- package/es/components/GeoSearchControls/GeoSearchControls.js +11 -14
- package/es/components/GeoSearchControls/GeoSearchToggle.js +4 -6
- package/es/components/Highlight/Highlight.js +4 -7
- package/es/components/Hits/Hits.js +12 -17
- package/es/components/InfiniteHits/InfiniteHits.js +17 -22
- package/es/components/MenuSelect/MenuSelect.js +9 -14
- package/es/components/Pagination/Pagination.js +10 -15
- package/es/components/Panel/Panel.js +8 -22
- package/es/components/PoweredBy/PoweredBy.js +4 -5
- package/es/components/QueryRuleCustomData/QueryRuleCustomData.js +2 -4
- package/es/components/RangeInput/RangeInput.js +20 -46
- package/es/components/RefinementList/RefinementList.js +24 -67
- package/es/components/RefinementList/RefinementListItem.js +8 -11
- package/es/components/RelevantSort/RelevantSort.js +4 -6
- package/es/components/ReverseHighlight/ReverseHighlight.js +4 -7
- package/es/components/ReverseSnippet/ReverseSnippet.js +4 -7
- package/es/components/SearchBox/SearchBox.js +29 -66
- package/es/components/Selector/Selector.js +3 -5
- package/es/components/Slider/Pit.js +7 -9
- package/es/components/Slider/Rheostat.js +70 -133
- package/es/components/Slider/Slider.js +34 -61
- package/es/components/Snippet/Snippet.js +4 -7
- package/es/components/Stats/Stats.js +12 -17
- package/es/components/Template/Template.js +12 -35
- package/es/components/ToggleRefinement/ToggleRefinement.js +4 -7
- package/es/components/VoiceSearch/VoiceSearch.js +8 -13
- package/es/connectors/answers/connectAnswers.js +27 -36
- package/es/connectors/autocomplete/connectAutocomplete.js +12 -24
- package/es/connectors/breadcrumb/connectBreadcrumb.js +22 -48
- package/es/connectors/clear-refinements/connectClearRefinements.js +32 -45
- package/es/connectors/configure/connectConfigure.js +11 -17
- package/es/connectors/configure-related-items/connectConfigureRelatedItems.js +16 -33
- package/es/connectors/current-refinements/connectCurrentRefinements.js +23 -57
- package/es/connectors/dynamic-widgets/connectDynamicWidgets.js +20 -36
- package/es/connectors/geo-search/connectGeoSearch.js +21 -46
- package/es/connectors/hierarchical-menu/connectHierarchicalMenu.js +44 -74
- package/es/connectors/hits/connectHits.js +14 -25
- package/es/connectors/hits-per-page/connectHitsPerPage.js +20 -38
- package/es/connectors/index.d.ts +2 -1
- package/es/connectors/index.js +6 -3
- package/es/connectors/infinite-hits/connectInfiniteHits.js +32 -62
- package/es/connectors/menu/connectMenu.js +34 -66
- package/es/connectors/numeric-menu/connectNumericMenu.js +31 -78
- package/es/connectors/pagination/Paginator.js +8 -21
- package/es/connectors/pagination/connectPagination.js +12 -22
- package/es/connectors/powered-by/connectPoweredBy.js +8 -12
- package/es/connectors/query-rules/connectQueryRules.js +37 -56
- package/es/connectors/range/connectRange.js +46 -101
- package/es/connectors/rating-menu/connectRatingMenu.js +28 -79
- package/es/connectors/refinement-list/connectRefinementList.js +43 -69
- package/es/connectors/relevant-sort/connectRelevantSort.js +8 -14
- package/es/connectors/search-box/connectSearchBox.js +11 -22
- package/es/connectors/sort-by/connectSortBy.js +15 -20
- package/es/connectors/stats/connectStats.js +8 -10
- package/es/connectors/toggle-refinement/connectToggleRefinement.js +33 -62
- package/es/connectors/toggle-refinement/types.js +1 -0
- package/es/connectors/voice-search/connectVoiceSearch.js +17 -32
- package/es/helpers/components/Highlight.js +5 -8
- package/es/helpers/components/ReverseHighlight.js +13 -16
- package/es/helpers/components/ReverseSnippet.js +13 -16
- package/es/helpers/components/Snippet.js +5 -8
- package/es/helpers/get-insights-anonymous-user-token.js +2 -10
- package/es/helpers/highlight.js +10 -10
- package/es/helpers/insights.js +3 -10
- package/es/helpers/reverseHighlight.js +10 -10
- package/es/helpers/reverseSnippet.js +10 -10
- package/es/helpers/snippet.js +10 -10
- package/es/index.js +0 -2
- package/es/lib/InstantSearch.js +83 -172
- package/es/lib/createHelpers.js +8 -9
- package/es/lib/infiniteHitsCache/sessionStorage.js +10 -16
- package/es/lib/insights/client.js +12 -33
- package/es/lib/insights/listener.js +4 -18
- package/es/lib/routers/history.js +69 -108
- package/es/lib/stateMappings/simple.js +11 -13
- package/es/lib/stateMappings/singleIndex.js +6 -7
- package/es/lib/suit.js +2 -3
- package/es/lib/templating/prepareTemplateProps.js +13 -20
- package/es/lib/templating/renderTemplate.js +12 -21
- package/es/lib/utils/checkIndexUiState.js +19 -41
- 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 +9 -18
- 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 +21 -35
- 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 +28 -41
- package/es/lib/utils/getWidgetAttribute.js +0 -5
- package/es/lib/utils/hits-absolute-position.js +6 -6
- package/es/lib/utils/hits-query-id.js +6 -7
- package/es/lib/utils/isEqual.js +2 -6
- package/es/lib/utils/isPlainObject.js +3 -10
- package/es/lib/utils/logger.js +4 -14
- package/es/lib/utils/mergeSearchParameters.js +21 -38
- package/es/lib/utils/range.js +9 -14
- package/es/lib/utils/resolveSearchParameters.js +0 -2
- package/es/lib/utils/reverseHighlightedParts.js +6 -7
- 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 +12 -36
- package/es/lib/voiceSearchHelper/types.js +1 -0
- package/es/middlewares/createInsightsMiddleware.js +21 -42
- package/es/middlewares/createMetadataMiddleware.js +3 -9
- package/es/middlewares/createRouterMiddleware.js +12 -14
- package/es/types/algoliasearch.js +1 -0
- package/es/types/component.js +1 -0
- package/es/types/connector.js +1 -0
- package/es/types/index.js +9 -5
- package/es/types/insights.js +1 -0
- package/es/types/instantsearch.js +1 -0
- package/es/types/middleware.js +1 -0
- package/es/types/render-state.js +1 -0
- package/es/types/results.js +1 -0
- package/es/types/router.js +1 -0
- package/es/types/templates.js +1 -0
- package/es/types/ui-state.js +1 -0
- package/es/types/utils.js +1 -0
- package/es/types/widget-factory.js +1 -0
- package/es/types/widget.js +1 -0
- package/es/widgets/analytics/analytics.js +19 -43
- package/es/widgets/answers/answers.js +23 -30
- package/es/widgets/breadcrumb/breadcrumb.js +22 -29
- package/es/widgets/clear-refinements/clear-refinements.js +19 -26
- package/es/widgets/configure/configure.js +7 -7
- package/es/widgets/configure-related-items/configure-related-items.js +6 -8
- package/es/widgets/current-refinements/current-refinements.js +16 -23
- package/es/widgets/dynamic-widgets/dynamic-widgets.js +11 -21
- package/es/widgets/geo-search/GeoSearchRenderer.d.js +1 -0
- package/es/widgets/geo-search/GeoSearchRenderer.js +47 -65
- package/es/widgets/geo-search/createHTMLMarker.d.ts +1 -0
- package/es/widgets/geo-search/createHTMLMarker.js +34 -61
- package/es/widgets/geo-search/defaultTemplates.js +0 -2
- package/es/widgets/geo-search/geo-search.d.ts +1 -0
- package/es/widgets/geo-search/geo-search.js +34 -50
- package/es/widgets/hierarchical-menu/defaultTemplates.js +4 -4
- package/es/widgets/hierarchical-menu/hierarchical-menu.js +32 -38
- package/es/widgets/hits/hits.js +20 -27
- package/es/widgets/hits-per-page/hits-per-page.js +17 -24
- package/es/widgets/index/index.js +55 -93
- package/es/widgets/index.d.ts +2 -1
- package/es/widgets/index.js +4 -3
- package/es/widgets/infinite-hits/infinite-hits.js +27 -34
- package/es/widgets/menu/defaultTemplates.js +3 -3
- package/es/widgets/menu/menu.js +27 -34
- package/es/widgets/menu-select/defaultTemplates.js +1 -1
- package/es/widgets/menu-select/menu-select.js +22 -29
- package/es/widgets/numeric-menu/defaultTemplates.js +3 -3
- package/es/widgets/numeric-menu/numeric-menu.js +21 -28
- package/es/widgets/pagination/pagination.js +36 -46
- package/es/widgets/panel/panel.js +24 -42
- package/es/widgets/places/places.js +22 -33
- package/es/widgets/powered-by/powered-by.js +14 -20
- package/es/widgets/query-rule-context/query-rule-context.js +6 -10
- package/es/widgets/query-rule-custom-data/query-rule-custom-data.js +17 -24
- package/es/widgets/range-input/range-input.js +28 -43
- package/es/widgets/range-slider/range-slider.js +33 -47
- package/es/widgets/rating-menu/defaultTemplates.js +8 -12
- package/es/widgets/rating-menu/rating-menu.js +21 -29
- package/es/widgets/refinement-list/defaultTemplates.js +5 -5
- package/es/widgets/refinement-list/refinement-list.js +43 -50
- package/es/widgets/relevant-sort/relevant-sort.js +14 -21
- package/es/widgets/search-box/defaultTemplates.js +0 -4
- package/es/widgets/search-box/search-box.js +35 -41
- package/es/widgets/sort-by/sort-by.js +15 -22
- package/es/widgets/stats/stats.js +30 -47
- package/es/widgets/toggle-refinement/toggle-refinement.js +20 -27
- package/es/widgets/voice-search/defaultTemplates.js +4 -13
- package/es/widgets/voice-search/voice-search.js +21 -28
- 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/scripts/transforms/__tests__/addWidget-to-addWidgets.test.js +1 -0
- package/CHANGELOG.md +0 -3693
|
@@ -1,43 +1,38 @@
|
|
|
1
|
-
function
|
|
2
|
-
|
|
3
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
4
|
-
|
|
5
|
-
function
|
|
6
|
-
|
|
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); }
|
|
2
|
+
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; }
|
|
3
|
+
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; }
|
|
4
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
6
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
7
7
|
import { checkRendering, escapeFacetValue, createDocumentationMessageGenerator, find, noop, toArray } from "../../lib/utils/index.js";
|
|
8
8
|
var withUsage = createDocumentationMessageGenerator({
|
|
9
9
|
name: 'toggle-refinement',
|
|
10
10
|
connector: true
|
|
11
11
|
});
|
|
12
12
|
var $$type = 'ais.toggleRefinement';
|
|
13
|
-
|
|
14
13
|
var createSendEvent = function createSendEvent(_ref) {
|
|
15
14
|
var instantSearchInstance = _ref.instantSearchInstance,
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
helper = _ref.helper,
|
|
16
|
+
attribute = _ref.attribute,
|
|
17
|
+
on = _ref.on;
|
|
20
18
|
var sendEventForToggle = function sendEventForToggle() {
|
|
21
19
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
22
20
|
args[_key] = arguments[_key];
|
|
23
21
|
}
|
|
24
|
-
|
|
25
22
|
if (args.length === 1) {
|
|
26
23
|
instantSearchInstance.sendEventToInsights(args[0]);
|
|
27
24
|
return;
|
|
28
25
|
}
|
|
29
|
-
|
|
30
26
|
var eventType = args[0],
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
27
|
+
isRefined = args[1],
|
|
28
|
+
_args$ = args[2],
|
|
29
|
+
eventName = _args$ === void 0 ? 'Filter Applied' : _args$;
|
|
35
30
|
if (eventType !== 'click' || on === undefined) {
|
|
36
31
|
return;
|
|
37
|
-
}
|
|
38
|
-
// not when it gets removed
|
|
39
|
-
|
|
32
|
+
}
|
|
40
33
|
|
|
34
|
+
// only send an event when the refinement gets applied,
|
|
35
|
+
// not when it gets removed
|
|
41
36
|
if (!isRefined) {
|
|
42
37
|
instantSearchInstance.sendEventToInsights({
|
|
43
38
|
insightsMethod: 'clickedFilters',
|
|
@@ -54,10 +49,8 @@ var createSendEvent = function createSendEvent(_ref) {
|
|
|
54
49
|
});
|
|
55
50
|
}
|
|
56
51
|
};
|
|
57
|
-
|
|
58
52
|
return sendEventForToggle;
|
|
59
53
|
};
|
|
60
|
-
|
|
61
54
|
/**
|
|
62
55
|
* **Toggle** connector provides the logic to build a custom widget that will provide
|
|
63
56
|
* an on/off filtering feature based on an attribute value or values.
|
|
@@ -71,38 +64,32 @@ var connectToggleRefinement = function connectToggleRefinement(renderFn) {
|
|
|
71
64
|
checkRendering(renderFn, withUsage());
|
|
72
65
|
return function (widgetParams) {
|
|
73
66
|
var _ref2 = widgetParams || {},
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
67
|
+
attribute = _ref2.attribute,
|
|
68
|
+
_ref2$on = _ref2.on,
|
|
69
|
+
userOn = _ref2$on === void 0 ? true : _ref2$on,
|
|
70
|
+
userOff = _ref2.off;
|
|
79
71
|
if (!attribute) {
|
|
80
72
|
throw new Error(withUsage('The `attribute` option is required.'));
|
|
81
73
|
}
|
|
82
|
-
|
|
83
|
-
|
|
74
|
+
var hasAnOffValue = userOff !== undefined;
|
|
75
|
+
// even though facet values can be numbers and boolean,
|
|
84
76
|
// the helper methods only accept string in the type
|
|
85
|
-
|
|
86
77
|
var on = toArray(userOn).map(escapeFacetValue);
|
|
87
78
|
var off = hasAnOffValue ? toArray(userOff).map(escapeFacetValue) : undefined;
|
|
88
79
|
var sendEvent;
|
|
89
|
-
|
|
90
80
|
var toggleRefinementFactory = function toggleRefinementFactory(helper) {
|
|
91
81
|
return function () {
|
|
92
82
|
var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
83
|
+
isRefined: false
|
|
84
|
+
},
|
|
85
|
+
isRefined = _ref3.isRefined;
|
|
97
86
|
if (!isRefined) {
|
|
98
87
|
sendEvent('click', isRefined);
|
|
99
|
-
|
|
100
88
|
if (hasAnOffValue) {
|
|
101
89
|
off.forEach(function (v) {
|
|
102
90
|
return helper.removeDisjunctiveFacetRefinement(attribute, v);
|
|
103
91
|
});
|
|
104
92
|
}
|
|
105
|
-
|
|
106
93
|
on.forEach(function (v) {
|
|
107
94
|
return helper.addDisjunctiveFacetRefinement(attribute, v);
|
|
108
95
|
});
|
|
@@ -110,40 +97,33 @@ var connectToggleRefinement = function connectToggleRefinement(renderFn) {
|
|
|
110
97
|
on.forEach(function (v) {
|
|
111
98
|
return helper.removeDisjunctiveFacetRefinement(attribute, v);
|
|
112
99
|
});
|
|
113
|
-
|
|
114
100
|
if (hasAnOffValue) {
|
|
115
101
|
off.forEach(function (v) {
|
|
116
102
|
return helper.addDisjunctiveFacetRefinement(attribute, v);
|
|
117
103
|
});
|
|
118
104
|
}
|
|
119
105
|
}
|
|
120
|
-
|
|
121
106
|
helper.search();
|
|
122
107
|
};
|
|
123
108
|
};
|
|
124
|
-
|
|
125
109
|
var connectorState = {
|
|
126
110
|
createURLFactory: function createURLFactory(isRefined, _ref4) {
|
|
127
111
|
var state = _ref4.state,
|
|
128
|
-
|
|
112
|
+
createURL = _ref4.createURL;
|
|
129
113
|
return function () {
|
|
130
114
|
state = state.resetPage();
|
|
131
115
|
var valuesToRemove = isRefined ? on : off;
|
|
132
|
-
|
|
133
116
|
if (valuesToRemove) {
|
|
134
117
|
valuesToRemove.forEach(function (v) {
|
|
135
118
|
state = state.removeDisjunctiveFacetRefinement(attribute, v);
|
|
136
119
|
});
|
|
137
120
|
}
|
|
138
|
-
|
|
139
121
|
var valuesToAdd = isRefined ? off : on;
|
|
140
|
-
|
|
141
122
|
if (valuesToAdd) {
|
|
142
123
|
valuesToAdd.forEach(function (v) {
|
|
143
124
|
state = state.addDisjunctiveFacetRefinement(attribute, v);
|
|
144
125
|
});
|
|
145
126
|
}
|
|
146
|
-
|
|
147
127
|
return createURL(state);
|
|
148
128
|
};
|
|
149
129
|
}
|
|
@@ -174,10 +154,10 @@ var connectToggleRefinement = function connectToggleRefinement(renderFn) {
|
|
|
174
154
|
},
|
|
175
155
|
getWidgetRenderState: function getWidgetRenderState(_ref6) {
|
|
176
156
|
var state = _ref6.state,
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
157
|
+
helper = _ref6.helper,
|
|
158
|
+
results = _ref6.results,
|
|
159
|
+
createURL = _ref6.createURL,
|
|
160
|
+
instantSearchInstance = _ref6.instantSearchInstance;
|
|
181
161
|
var isRefined = results ? on.every(function (v) {
|
|
182
162
|
return state.isDisjunctiveFacetRefined(attribute, v);
|
|
183
163
|
}) : on.every(function (v) {
|
|
@@ -191,7 +171,6 @@ var connectToggleRefinement = function connectToggleRefinement(renderFn) {
|
|
|
191
171
|
isRefined: hasAnOffValue && !isRefined,
|
|
192
172
|
count: 0
|
|
193
173
|
};
|
|
194
|
-
|
|
195
174
|
if (results) {
|
|
196
175
|
var offValue = toArray(off || false);
|
|
197
176
|
var allFacetValues = results.getFacetValues(attribute, {}) || [];
|
|
@@ -231,7 +210,6 @@ var connectToggleRefinement = function connectToggleRefinement(renderFn) {
|
|
|
231
210
|
}, 0)
|
|
232
211
|
};
|
|
233
212
|
}
|
|
234
|
-
|
|
235
213
|
if (!sendEvent) {
|
|
236
214
|
sendEvent = createSendEvent({
|
|
237
215
|
instantSearchInstance: instantSearchInstance,
|
|
@@ -240,7 +218,6 @@ var connectToggleRefinement = function connectToggleRefinement(renderFn) {
|
|
|
240
218
|
helper: helper
|
|
241
219
|
});
|
|
242
220
|
}
|
|
243
|
-
|
|
244
221
|
var nextRefinement = isRefined ? offFacetValue : onFacetValue;
|
|
245
222
|
return {
|
|
246
223
|
value: {
|
|
@@ -265,11 +242,9 @@ var connectToggleRefinement = function connectToggleRefinement(renderFn) {
|
|
|
265
242
|
var isRefined = on && on.every(function (v) {
|
|
266
243
|
return searchParameters.isDisjunctiveFacetRefined(attribute, v);
|
|
267
244
|
});
|
|
268
|
-
|
|
269
245
|
if (!isRefined) {
|
|
270
246
|
return uiState;
|
|
271
247
|
}
|
|
272
|
-
|
|
273
248
|
return _objectSpread(_objectSpread({}, uiState), {}, {
|
|
274
249
|
toggle: _objectSpread(_objectSpread({}, uiState.toggle), {}, _defineProperty({}, attribute, isRefined))
|
|
275
250
|
});
|
|
@@ -278,29 +253,26 @@ var connectToggleRefinement = function connectToggleRefinement(renderFn) {
|
|
|
278
253
|
var uiState = _ref11.uiState;
|
|
279
254
|
var withFacetConfiguration = searchParameters.clearRefinements(attribute).addDisjunctiveFacet(attribute);
|
|
280
255
|
var isRefined = Boolean(uiState.toggle && uiState.toggle[attribute]);
|
|
281
|
-
|
|
282
256
|
if (isRefined) {
|
|
283
257
|
if (on) {
|
|
284
258
|
on.forEach(function (v) {
|
|
285
259
|
withFacetConfiguration = withFacetConfiguration.addDisjunctiveFacetRefinement(attribute, v);
|
|
286
260
|
});
|
|
287
261
|
}
|
|
288
|
-
|
|
289
262
|
return withFacetConfiguration;
|
|
290
|
-
}
|
|
291
|
-
|
|
263
|
+
}
|
|
292
264
|
|
|
265
|
+
// It's not refined with an `off` value
|
|
293
266
|
if (hasAnOffValue) {
|
|
294
267
|
if (off) {
|
|
295
268
|
off.forEach(function (v) {
|
|
296
269
|
withFacetConfiguration = withFacetConfiguration.addDisjunctiveFacetRefinement(attribute, v);
|
|
297
270
|
});
|
|
298
271
|
}
|
|
299
|
-
|
|
300
272
|
return withFacetConfiguration;
|
|
301
|
-
}
|
|
302
|
-
|
|
273
|
+
}
|
|
303
274
|
|
|
275
|
+
// It's not refined without an `off` value
|
|
304
276
|
return withFacetConfiguration.setQueryParameters({
|
|
305
277
|
disjunctiveFacetsRefinements: _objectSpread(_objectSpread({}, searchParameters.disjunctiveFacetsRefinements), {}, _defineProperty({}, attribute, []))
|
|
306
278
|
});
|
|
@@ -308,5 +280,4 @@ var connectToggleRefinement = function connectToggleRefinement(renderFn) {
|
|
|
308
280
|
};
|
|
309
281
|
};
|
|
310
282
|
};
|
|
311
|
-
|
|
312
283
|
export default connectToggleRefinement;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,26 +1,25 @@
|
|
|
1
|
-
function
|
|
2
|
-
|
|
3
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
4
|
-
|
|
5
|
-
function
|
|
6
|
-
|
|
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); }
|
|
2
|
+
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; }
|
|
3
|
+
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; }
|
|
4
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
6
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
7
7
|
import { checkRendering, createDocumentationMessageGenerator, noop } from "../../lib/utils/index.js";
|
|
8
8
|
import builtInCreateVoiceSearchHelper from "../../lib/voiceSearchHelper/index.js";
|
|
9
9
|
var withUsage = createDocumentationMessageGenerator({
|
|
10
10
|
name: 'voice-search',
|
|
11
11
|
connector: true
|
|
12
12
|
});
|
|
13
|
-
|
|
14
13
|
var connectVoiceSearch = function connectVoiceSearch(renderFn) {
|
|
15
14
|
var unmountFn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop;
|
|
16
15
|
checkRendering(renderFn, withUsage());
|
|
17
16
|
return function (widgetParams) {
|
|
18
17
|
var _widgetParams$searchA = widgetParams.searchAsYouSpeak,
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
searchAsYouSpeak = _widgetParams$searchA === void 0 ? false : _widgetParams$searchA,
|
|
19
|
+
language = widgetParams.language,
|
|
20
|
+
additionalQueryParameters = widgetParams.additionalQueryParameters,
|
|
21
|
+
_widgetParams$createV = widgetParams.createVoiceSearchHelper,
|
|
22
|
+
createVoiceSearchHelper = _widgetParams$createV === void 0 ? builtInCreateVoiceSearchHelper : _widgetParams$createV;
|
|
24
23
|
return {
|
|
25
24
|
$$type: 'ais.voiceSearch',
|
|
26
25
|
init: function init(initOptions) {
|
|
@@ -42,16 +41,13 @@ var connectVoiceSearch = function connectVoiceSearch(renderFn) {
|
|
|
42
41
|
},
|
|
43
42
|
getWidgetRenderState: function getWidgetRenderState(renderOptions) {
|
|
44
43
|
var _this = this;
|
|
45
|
-
|
|
46
44
|
var helper = renderOptions.helper,
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
instantSearchInstance = renderOptions.instantSearchInstance;
|
|
49
46
|
if (!this._refine) {
|
|
50
47
|
this._refine = function (query) {
|
|
51
48
|
if (query !== helper.state.query) {
|
|
52
49
|
var queryLanguages = language ? [language.split('-')[0]] : undefined;
|
|
53
50
|
helper.setQueryParameter('queryLanguages', queryLanguages);
|
|
54
|
-
|
|
55
51
|
if (typeof additionalQueryParameters === 'function') {
|
|
56
52
|
helper.setState(helper.state.setQueryParameters(_objectSpread({
|
|
57
53
|
ignorePlurals: true,
|
|
@@ -62,12 +58,10 @@ var connectVoiceSearch = function connectVoiceSearch(renderFn) {
|
|
|
62
58
|
query: query
|
|
63
59
|
}))));
|
|
64
60
|
}
|
|
65
|
-
|
|
66
61
|
helper.setQuery(query).search();
|
|
67
62
|
}
|
|
68
63
|
};
|
|
69
64
|
}
|
|
70
|
-
|
|
71
65
|
if (!this._voiceSearchHelper) {
|
|
72
66
|
this._voiceSearchHelper = createVoiceSearchHelper({
|
|
73
67
|
searchAsYouSpeak: searchAsYouSpeak,
|
|
@@ -82,13 +76,12 @@ var connectVoiceSearch = function connectVoiceSearch(renderFn) {
|
|
|
82
76
|
}
|
|
83
77
|
});
|
|
84
78
|
}
|
|
85
|
-
|
|
86
79
|
var _voiceSearchHelper = this._voiceSearchHelper,
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
80
|
+
isBrowserSupported = _voiceSearchHelper.isBrowserSupported,
|
|
81
|
+
isListening = _voiceSearchHelper.isListening,
|
|
82
|
+
startListening = _voiceSearchHelper.startListening,
|
|
83
|
+
stopListening = _voiceSearchHelper.stopListening,
|
|
84
|
+
getState = _voiceSearchHelper.getState;
|
|
92
85
|
return {
|
|
93
86
|
isBrowserSupported: isBrowserSupported(),
|
|
94
87
|
isListening: isListening(),
|
|
@@ -96,7 +89,6 @@ var connectVoiceSearch = function connectVoiceSearch(renderFn) {
|
|
|
96
89
|
if (!isBrowserSupported()) {
|
|
97
90
|
return;
|
|
98
91
|
}
|
|
99
|
-
|
|
100
92
|
if (isListening()) {
|
|
101
93
|
stopListening();
|
|
102
94
|
} else {
|
|
@@ -109,12 +101,9 @@ var connectVoiceSearch = function connectVoiceSearch(renderFn) {
|
|
|
109
101
|
},
|
|
110
102
|
dispose: function dispose(_ref) {
|
|
111
103
|
var state = _ref.state;
|
|
112
|
-
|
|
113
104
|
this._voiceSearchHelper.dispose();
|
|
114
|
-
|
|
115
105
|
unmountFn();
|
|
116
106
|
var newState = state;
|
|
117
|
-
|
|
118
107
|
if (typeof additionalQueryParameters === 'function') {
|
|
119
108
|
var additional = additionalQueryParameters({
|
|
120
109
|
query: ''
|
|
@@ -132,17 +121,14 @@ var connectVoiceSearch = function connectVoiceSearch(renderFn) {
|
|
|
132
121
|
optionalWords: undefined
|
|
133
122
|
}, toReset));
|
|
134
123
|
}
|
|
135
|
-
|
|
136
124
|
return newState.setQueryParameter('query', undefined);
|
|
137
125
|
},
|
|
138
126
|
getWidgetUiState: function getWidgetUiState(uiState, _ref2) {
|
|
139
127
|
var searchParameters = _ref2.searchParameters;
|
|
140
128
|
var query = searchParameters.query || '';
|
|
141
|
-
|
|
142
129
|
if (!query) {
|
|
143
130
|
return uiState;
|
|
144
131
|
}
|
|
145
|
-
|
|
146
132
|
return _objectSpread(_objectSpread({}, uiState), {}, {
|
|
147
133
|
query: query
|
|
148
134
|
});
|
|
@@ -154,5 +140,4 @@ var connectVoiceSearch = function connectVoiceSearch(renderFn) {
|
|
|
154
140
|
};
|
|
155
141
|
};
|
|
156
142
|
};
|
|
157
|
-
|
|
158
143
|
export default connectVoiceSearch;
|
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
var _excluded = ["hit", "attribute", "cssClasses"];
|
|
2
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
3
3
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
4
|
-
|
|
5
4
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
6
|
-
|
|
7
5
|
import { h } from 'preact';
|
|
8
6
|
import { Highlight as HighlightUiComponent } from "../../components/Highlight/Highlight.js";
|
|
9
7
|
import { getPropertyByPath, unescape, toArray, warning, getHighlightedParts } from "../../lib/utils/index.js";
|
|
10
8
|
export function Highlight(_ref) {
|
|
11
9
|
var hit = _ref.hit,
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
attribute = _ref.attribute,
|
|
11
|
+
cssClasses = _ref.cssClasses,
|
|
12
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
16
13
|
var property = getPropertyByPath(hit._highlightResult, attribute) || [];
|
|
17
14
|
var properties = toArray(property);
|
|
18
15
|
process.env.NODE_ENV === 'development' ? warning(Boolean(properties.length), "Could not enable highlight for \"".concat(attribute.toString(), "\", will display an empty string.\nPlease check whether this attribute exists and is either searchable or specified in `attributesToHighlight`.\n\nSee: https://alg.li/highlighting\n")) : void 0;
|
|
@@ -1,24 +1,22 @@
|
|
|
1
|
-
function
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
function
|
|
6
|
-
|
|
7
|
-
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; }
|
|
8
|
-
|
|
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); }
|
|
2
|
+
var _excluded = ["hit", "attribute", "cssClasses"],
|
|
3
|
+
_excluded2 = ["isHighlighted"];
|
|
4
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
5
|
+
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; }
|
|
6
|
+
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; }
|
|
7
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
8
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
9
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
9
10
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
10
|
-
|
|
11
11
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
12
|
-
|
|
13
12
|
import { h } from 'preact';
|
|
14
13
|
import { ReverseHighlight as ReverseHighlightUiComponent } from "../../components/ReverseHighlight/ReverseHighlight.js";
|
|
15
14
|
import { getPropertyByPath, unescape, toArray, warning, getHighlightedParts } from "../../lib/utils/index.js";
|
|
16
15
|
export function ReverseHighlight(_ref) {
|
|
17
16
|
var hit = _ref.hit,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
attribute = _ref.attribute,
|
|
18
|
+
cssClasses = _ref.cssClasses,
|
|
19
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
22
20
|
var property = getPropertyByPath(hit._highlightResult, attribute) || [];
|
|
23
21
|
var properties = toArray(property);
|
|
24
22
|
process.env.NODE_ENV === 'development' ? warning(Boolean(properties.length), "Could not enable highlight for \"".concat(attribute.toString(), "\", will display an empty string.\nPlease check whether this attribute exists and is either searchable or specified in `attributesToHighlight`.\n\nSee: https://alg.li/highlighting\n")) : void 0;
|
|
@@ -26,8 +24,7 @@ export function ReverseHighlight(_ref) {
|
|
|
26
24
|
var value = _ref2.value;
|
|
27
25
|
return getHighlightedParts(unescape(value || '')).map(function (_ref3) {
|
|
28
26
|
var isHighlighted = _ref3.isHighlighted,
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
rest = _objectWithoutProperties(_ref3, _excluded2);
|
|
31
28
|
return _objectSpread(_objectSpread({}, rest), {}, {
|
|
32
29
|
isHighlighted: !isHighlighted
|
|
33
30
|
});
|
|
@@ -1,24 +1,22 @@
|
|
|
1
|
-
function
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
function
|
|
6
|
-
|
|
7
|
-
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; }
|
|
8
|
-
|
|
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); }
|
|
2
|
+
var _excluded = ["hit", "attribute", "cssClasses"],
|
|
3
|
+
_excluded2 = ["isHighlighted"];
|
|
4
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
5
|
+
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; }
|
|
6
|
+
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; }
|
|
7
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
8
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
9
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
9
10
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
10
|
-
|
|
11
11
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
12
|
-
|
|
13
12
|
import { h } from 'preact';
|
|
14
13
|
import { ReverseSnippet as ReverseSnippetUiComponent } from "../../components/ReverseSnippet/ReverseSnippet.js";
|
|
15
14
|
import { getPropertyByPath, unescape, toArray, warning, getHighlightedParts } from "../../lib/utils/index.js";
|
|
16
15
|
export function ReverseSnippet(_ref) {
|
|
17
16
|
var hit = _ref.hit,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
attribute = _ref.attribute,
|
|
18
|
+
cssClasses = _ref.cssClasses,
|
|
19
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
22
20
|
var property = getPropertyByPath(hit._snippetResult, attribute) || [];
|
|
23
21
|
var properties = toArray(property);
|
|
24
22
|
process.env.NODE_ENV === 'development' ? warning(Boolean(properties.length), "Could not enable snippet for \"".concat(attribute.toString(), "\", will display an empty string.\nPlease check whether this attribute exists and is specified in `attributesToSnippet`.\n\nSee: https://alg.li/highlighting\n")) : void 0;
|
|
@@ -26,8 +24,7 @@ export function ReverseSnippet(_ref) {
|
|
|
26
24
|
var value = _ref2.value;
|
|
27
25
|
return getHighlightedParts(unescape(value || '')).map(function (_ref3) {
|
|
28
26
|
var isHighlighted = _ref3.isHighlighted,
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
rest = _objectWithoutProperties(_ref3, _excluded2);
|
|
31
28
|
return _objectSpread(_objectSpread({}, rest), {}, {
|
|
32
29
|
isHighlighted: !isHighlighted
|
|
33
30
|
});
|
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
var _excluded = ["hit", "attribute", "cssClasses"];
|
|
2
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
3
3
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
4
|
-
|
|
5
4
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
6
|
-
|
|
7
5
|
import { h } from 'preact';
|
|
8
6
|
import { Snippet as SnippetUiComponent } from "../../components/Snippet/Snippet.js";
|
|
9
7
|
import { getPropertyByPath, unescape, toArray, warning, getHighlightedParts } from "../../lib/utils/index.js";
|
|
10
8
|
export function Snippet(_ref) {
|
|
11
9
|
var hit = _ref.hit,
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
attribute = _ref.attribute,
|
|
11
|
+
cssClasses = _ref.cssClasses,
|
|
12
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
16
13
|
var property = getPropertyByPath(hit._snippetResult, attribute) || [];
|
|
17
14
|
var properties = toArray(property);
|
|
18
15
|
process.env.NODE_ENV === 'development' ? warning(Boolean(properties.length), "Could not enable snippet for \"".concat(attribute.toString(), "\", will display an empty string.\nPlease check whether this attribute exists and is specified in `attributesToSnippet`.\n\nSee: https://alg.li/highlighting\n")) : void 0;
|
|
@@ -1,38 +1,30 @@
|
|
|
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
|
import { warning } from "../lib/utils/index.js";
|
|
4
3
|
export var ANONYMOUS_TOKEN_COOKIE_KEY = '_ALGOLIA';
|
|
5
|
-
|
|
6
4
|
function getCookie(name) {
|
|
7
5
|
if ((typeof document === "undefined" ? "undefined" : _typeof(document)) !== 'object' || typeof document.cookie !== 'string') {
|
|
8
6
|
return undefined;
|
|
9
7
|
}
|
|
10
|
-
|
|
11
8
|
var prefix = "".concat(name, "=");
|
|
12
9
|
var cookies = document.cookie.split(';');
|
|
13
|
-
|
|
14
10
|
for (var i = 0; i < cookies.length; i++) {
|
|
15
11
|
var cookie = cookies[i];
|
|
16
|
-
|
|
17
12
|
while (cookie.charAt(0) === ' ') {
|
|
18
13
|
cookie = cookie.substring(1);
|
|
19
14
|
}
|
|
20
|
-
|
|
21
15
|
if (cookie.indexOf(prefix) === 0) {
|
|
22
16
|
return cookie.substring(prefix.length, cookie.length);
|
|
23
17
|
}
|
|
24
18
|
}
|
|
25
|
-
|
|
26
19
|
return undefined;
|
|
27
20
|
}
|
|
28
|
-
|
|
29
21
|
export function getInsightsAnonymousUserTokenInternal() {
|
|
30
22
|
return getCookie(ANONYMOUS_TOKEN_COOKIE_KEY);
|
|
31
23
|
}
|
|
24
|
+
|
|
32
25
|
/**
|
|
33
26
|
* @deprecated This function will be still supported in 4.x releases, but not further. It is replaced by the `insights` middleware. For more information, visit https://www.algolia.com/doc/guides/getting-insights-and-analytics/search-analytics/click-through-and-conversions/how-to/send-click-and-conversion-events-with-instantsearch/js/
|
|
34
27
|
*/
|
|
35
|
-
|
|
36
28
|
export default function getInsightsAnonymousUserToken() {
|
|
37
29
|
process.env.NODE_ENV === 'development' ? warning(false, "`getInsightsAnonymousUserToken` function has been deprecated. It is still supported in 4.x releases, but not further. It is replaced by the `insights` middleware.\n\nFor more information, visit https://www.algolia.com/doc/guides/getting-insights-and-analytics/search-analytics/click-through-and-conversions/how-to/send-click-and-conversion-events-with-instantsearch/js/") : void 0;
|
|
38
30
|
return getInsightsAnonymousUserTokenInternal();
|
package/es/helpers/highlight.js
CHANGED
|
@@ -3,20 +3,20 @@ import { getPropertyByPath, TAG_REPLACEMENT, warning } from "../lib/utils/index.
|
|
|
3
3
|
var suit = component('Highlight');
|
|
4
4
|
export default function highlight(_ref) {
|
|
5
5
|
var attribute = _ref.attribute,
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
var highlightAttributeResult = getPropertyByPath(hit._highlightResult, attribute);
|
|
6
|
+
_ref$highlightedTagNa = _ref.highlightedTagName,
|
|
7
|
+
highlightedTagName = _ref$highlightedTagNa === void 0 ? 'mark' : _ref$highlightedTagNa,
|
|
8
|
+
hit = _ref.hit,
|
|
9
|
+
_ref$cssClasses = _ref.cssClasses,
|
|
10
|
+
cssClasses = _ref$cssClasses === void 0 ? {} : _ref$cssClasses;
|
|
11
|
+
var highlightAttributeResult = getPropertyByPath(hit._highlightResult, attribute);
|
|
12
12
|
|
|
13
|
+
// @MAJOR fallback to attribute value if highlight is not found
|
|
13
14
|
process.env.NODE_ENV === 'development' ? warning(highlightAttributeResult, "Could not enable highlight for \"".concat(attribute, "\", will display an empty string.\nPlease check whether this attribute exists and is either searchable or specified in `attributesToHighlight`.\n\nSee: https://alg.li/highlighting\n")) : void 0;
|
|
14
|
-
|
|
15
15
|
var _ref2 = highlightAttributeResult || {},
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
_ref2$value = _ref2.value,
|
|
17
|
+
attributeValue = _ref2$value === void 0 ? '' : _ref2$value;
|
|
19
18
|
|
|
19
|
+
// cx is not used, since it would be bundled as a dependency for Vue & Angular
|
|
20
20
|
var className = suit({
|
|
21
21
|
descendantName: 'highlighted'
|
|
22
22
|
}) + (cssClasses.highlighted ? " ".concat(cssClasses.highlighted) : '');
|