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
|
@@ -3,22 +3,19 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.escapeHits = escapeHits;
|
|
7
|
-
exports.escapeFacets = escapeFacets;
|
|
8
6
|
exports.TAG_REPLACEMENT = exports.TAG_PLACEHOLDER = void 0;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var _isPlainObject = require("./isPlainObject
|
|
13
|
-
|
|
14
|
-
function
|
|
15
|
-
|
|
16
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
17
|
-
|
|
18
|
-
function
|
|
19
|
-
|
|
20
|
-
function
|
|
21
|
-
|
|
7
|
+
exports.escapeFacets = escapeFacets;
|
|
8
|
+
exports.escapeHits = escapeHits;
|
|
9
|
+
var _escapeHtml = require("./escape-html");
|
|
10
|
+
var _isPlainObject = require("./isPlainObject");
|
|
11
|
+
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); }
|
|
12
|
+
function _objectDestructuringEmpty(obj) { if (obj == null) throw new TypeError("Cannot destructure " + obj); }
|
|
13
|
+
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); }
|
|
14
|
+
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; }
|
|
15
|
+
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; }
|
|
16
|
+
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; }
|
|
17
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
18
|
+
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); }
|
|
22
19
|
var TAG_PLACEHOLDER = {
|
|
23
20
|
highlightPreTag: '__ais-highlight__',
|
|
24
21
|
highlightPostTag: '__/ais-highlight__'
|
|
@@ -29,50 +26,40 @@ var TAG_REPLACEMENT = {
|
|
|
29
26
|
highlightPostTag: '</mark>'
|
|
30
27
|
};
|
|
31
28
|
exports.TAG_REPLACEMENT = TAG_REPLACEMENT;
|
|
32
|
-
|
|
33
29
|
function replaceTagsAndEscape(value) {
|
|
34
30
|
return (0, _escapeHtml.escape)(value).replace(new RegExp(TAG_PLACEHOLDER.highlightPreTag, 'g'), TAG_REPLACEMENT.highlightPreTag).replace(new RegExp(TAG_PLACEHOLDER.highlightPostTag, 'g'), TAG_REPLACEMENT.highlightPostTag);
|
|
35
31
|
}
|
|
36
|
-
|
|
37
32
|
function recursiveEscape(input) {
|
|
38
33
|
if ((0, _isPlainObject.isPlainObject)(input) && typeof input.value !== 'string') {
|
|
39
34
|
return Object.keys(input).reduce(function (acc, key) {
|
|
40
35
|
return _objectSpread(_objectSpread({}, acc), {}, _defineProperty({}, key, recursiveEscape(input[key])));
|
|
41
36
|
}, {});
|
|
42
37
|
}
|
|
43
|
-
|
|
44
38
|
if (Array.isArray(input)) {
|
|
45
39
|
return input.map(recursiveEscape);
|
|
46
40
|
}
|
|
47
|
-
|
|
48
41
|
return _objectSpread(_objectSpread({}, input), {}, {
|
|
49
42
|
value: replaceTagsAndEscape(input.value)
|
|
50
43
|
});
|
|
51
44
|
}
|
|
52
|
-
|
|
53
45
|
function escapeHits(hits) {
|
|
54
46
|
if (hits.__escaped === undefined) {
|
|
55
47
|
// We don't override the value on hit because it will mutate the raw results
|
|
56
48
|
// instead we make a shallow copy and we assign the escaped values on it.
|
|
57
49
|
hits = hits.map(function (_ref) {
|
|
58
|
-
var hit = _extends({}, _ref);
|
|
59
|
-
|
|
50
|
+
var hit = _extends({}, (_objectDestructuringEmpty(_ref), _ref));
|
|
60
51
|
if (hit._highlightResult) {
|
|
61
52
|
hit._highlightResult = recursiveEscape(hit._highlightResult);
|
|
62
53
|
}
|
|
63
|
-
|
|
64
54
|
if (hit._snippetResult) {
|
|
65
55
|
hit._snippetResult = recursiveEscape(hit._snippetResult);
|
|
66
56
|
}
|
|
67
|
-
|
|
68
57
|
return hit;
|
|
69
58
|
});
|
|
70
59
|
hits.__escaped = true;
|
|
71
60
|
}
|
|
72
|
-
|
|
73
61
|
return hits;
|
|
74
62
|
}
|
|
75
|
-
|
|
76
63
|
function escapeFacets(facetHits) {
|
|
77
64
|
return facetHits.map(function (h) {
|
|
78
65
|
return _objectSpread(_objectSpread({}, h), {}, {
|
|
@@ -5,11 +5,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.escape = escape;
|
|
7
7
|
exports.unescape = unescape;
|
|
8
|
-
|
|
9
8
|
/**
|
|
10
9
|
* This implementation is taken from Lodash implementation.
|
|
11
10
|
* See: https://github.com/lodash/lodash/blob/4.17.11-npm/escape.js
|
|
12
11
|
*/
|
|
12
|
+
|
|
13
13
|
// Used to map characters to HTML entities.
|
|
14
14
|
var htmlEntities = {
|
|
15
15
|
'&': '&',
|
|
@@ -17,42 +17,44 @@ var htmlEntities = {
|
|
|
17
17
|
'>': '>',
|
|
18
18
|
'"': '"',
|
|
19
19
|
"'": '''
|
|
20
|
-
};
|
|
20
|
+
};
|
|
21
21
|
|
|
22
|
+
// Used to match HTML entities and HTML characters.
|
|
22
23
|
var regexUnescapedHtml = /[&<>"']/g;
|
|
23
24
|
var regexHasUnescapedHtml = RegExp(regexUnescapedHtml.source);
|
|
25
|
+
|
|
24
26
|
/**
|
|
25
27
|
* Converts the characters "&", "<", ">", '"', and "'" in `string` to their
|
|
26
28
|
* corresponding HTML entities.
|
|
27
29
|
*/
|
|
28
|
-
|
|
29
30
|
function escape(value) {
|
|
30
31
|
return value && regexHasUnescapedHtml.test(value) ? value.replace(regexUnescapedHtml, function (character) {
|
|
31
32
|
return htmlEntities[character];
|
|
32
33
|
}) : value;
|
|
33
34
|
}
|
|
35
|
+
|
|
34
36
|
/**
|
|
35
37
|
* This implementation is taken from Lodash implementation.
|
|
36
38
|
* See: https://github.com/lodash/lodash/blob/4.17.11-npm/unescape.js
|
|
37
39
|
*/
|
|
38
|
-
// Used to map HTML entities to characters.
|
|
39
|
-
|
|
40
40
|
|
|
41
|
+
// Used to map HTML entities to characters.
|
|
41
42
|
var htmlCharacters = {
|
|
42
43
|
'&': '&',
|
|
43
44
|
'<': '<',
|
|
44
45
|
'>': '>',
|
|
45
46
|
'"': '"',
|
|
46
47
|
''': "'"
|
|
47
|
-
};
|
|
48
|
+
};
|
|
48
49
|
|
|
50
|
+
// Used to match HTML entities and HTML characters.
|
|
49
51
|
var regexEscapedHtml = /&(amp|quot|lt|gt|#39);/g;
|
|
50
52
|
var regexHasEscapedHtml = RegExp(regexEscapedHtml.source);
|
|
53
|
+
|
|
51
54
|
/**
|
|
52
55
|
* Converts the HTML entities "&", "<", ">", '"', and "'" in `string` to their
|
|
53
56
|
* characters.
|
|
54
57
|
*/
|
|
55
|
-
|
|
56
58
|
function unescape(value) {
|
|
57
59
|
return value && regexHasEscapedHtml.test(value) ? value.replace(regexEscapedHtml, function (character) {
|
|
58
60
|
return htmlCharacters[character];
|
|
@@ -3,21 +3,17 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.unescapeFacetValue = unescapeFacetValue;
|
|
7
6
|
exports.escapeFacetValue = escapeFacetValue;
|
|
8
|
-
|
|
7
|
+
exports.unescapeFacetValue = unescapeFacetValue;
|
|
9
8
|
function unescapeFacetValue(value) {
|
|
10
9
|
if (typeof value === 'string') {
|
|
11
10
|
return value.replace(/^\\-/, '-');
|
|
12
11
|
}
|
|
13
|
-
|
|
14
12
|
return value;
|
|
15
13
|
}
|
|
16
|
-
|
|
17
14
|
function escapeFacetValue(value) {
|
|
18
15
|
if (typeof value === 'number' && value < 0 || typeof value === 'string') {
|
|
19
16
|
return String(value).replace(/^-/, '\\-');
|
|
20
17
|
}
|
|
21
|
-
|
|
22
18
|
return value;
|
|
23
19
|
}
|
package/cjs/lib/utils/find.js
CHANGED
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.find = find;
|
|
7
|
-
|
|
8
7
|
// We aren't using the native `Array.prototype.find` because the refactor away from Lodash is not
|
|
9
8
|
// published as a major version.
|
|
10
9
|
// Relying on the `find` polyfill on user-land, which before was only required for niche use-cases,
|
|
@@ -13,14 +12,12 @@ exports.find = find;
|
|
|
13
12
|
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find
|
|
14
13
|
function find(items, predicate) {
|
|
15
14
|
var value;
|
|
16
|
-
|
|
17
15
|
for (var i = 0; i < items.length; i++) {
|
|
18
|
-
value = items[i];
|
|
19
|
-
|
|
16
|
+
value = items[i];
|
|
17
|
+
// inlined for performance: if (Call(predicate, thisArg, [value, i, list])) {
|
|
20
18
|
if (predicate(value, i, items)) {
|
|
21
19
|
return value;
|
|
22
20
|
}
|
|
23
21
|
}
|
|
24
|
-
|
|
25
22
|
return undefined;
|
|
26
23
|
}
|
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.findIndex = findIndex;
|
|
7
|
-
|
|
8
7
|
// We aren't using the native `Array.prototype.findIndex` because the refactor away from Lodash is not
|
|
9
8
|
// published as a major version.
|
|
10
9
|
// Relying on the `findIndex` polyfill on user-land, which before was only required for niche use-cases,
|
|
@@ -15,12 +14,10 @@ function findIndex(array, comparator) {
|
|
|
15
14
|
if (!Array.isArray(array)) {
|
|
16
15
|
return -1;
|
|
17
16
|
}
|
|
18
|
-
|
|
19
17
|
for (var i = 0; i < array.length; i++) {
|
|
20
18
|
if (comparator(array[i])) {
|
|
21
19
|
return i;
|
|
22
20
|
}
|
|
23
21
|
}
|
|
24
|
-
|
|
25
22
|
return -1;
|
|
26
23
|
}
|
|
@@ -5,53 +5,41 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.aroundLatLngToPosition = aroundLatLngToPosition;
|
|
7
7
|
exports.insideBoundingBoxToBoundingBox = insideBoundingBoxToBoundingBox;
|
|
8
|
-
|
|
9
8
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
10
|
-
|
|
11
9
|
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."); }
|
|
12
|
-
|
|
13
10
|
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); }
|
|
14
|
-
|
|
15
|
-
function
|
|
16
|
-
|
|
17
|
-
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; }
|
|
18
|
-
|
|
11
|
+
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; }
|
|
12
|
+
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
19
13
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
20
|
-
|
|
21
14
|
var latLngRegExp = /^(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)$/;
|
|
22
|
-
|
|
23
15
|
function aroundLatLngToPosition(value) {
|
|
24
|
-
var pattern = value.match(latLngRegExp);
|
|
25
|
-
// throw an error due to the wrong format. So throw an error should be safe.
|
|
16
|
+
var pattern = value.match(latLngRegExp);
|
|
26
17
|
|
|
18
|
+
// Since the value provided is the one send with the request, the API should
|
|
19
|
+
// throw an error due to the wrong format. So throw an error should be safe.
|
|
27
20
|
if (!pattern) {
|
|
28
21
|
throw new Error("Invalid value for \"aroundLatLng\" parameter: \"".concat(value, "\""));
|
|
29
22
|
}
|
|
30
|
-
|
|
31
23
|
return {
|
|
32
24
|
lat: parseFloat(pattern[1]),
|
|
33
25
|
lng: parseFloat(pattern[2])
|
|
34
26
|
};
|
|
35
27
|
}
|
|
36
|
-
|
|
37
28
|
function insideBoundingBoxArrayToBoundingBox(value) {
|
|
38
29
|
var _value = _slicedToArray(value, 1),
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
30
|
+
_value$ = _value[0],
|
|
31
|
+
_value$2 = _value$ === void 0 ? [undefined, undefined, undefined, undefined] : _value$,
|
|
32
|
+
_value$3 = _slicedToArray(_value$2, 4),
|
|
33
|
+
neLat = _value$3[0],
|
|
34
|
+
neLng = _value$3[1],
|
|
35
|
+
swLat = _value$3[2],
|
|
36
|
+
swLng = _value$3[3];
|
|
37
|
+
|
|
38
|
+
// Since the value provided is the one send with the request, the API should
|
|
48
39
|
// throw an error due to the wrong format. So throw an error should be safe.
|
|
49
|
-
|
|
50
|
-
|
|
51
40
|
if (!neLat || !neLng || !swLat || !swLng) {
|
|
52
41
|
throw new Error("Invalid value for \"insideBoundingBox\" parameter: [".concat(value, "]"));
|
|
53
42
|
}
|
|
54
|
-
|
|
55
43
|
return {
|
|
56
44
|
northEast: {
|
|
57
45
|
lat: neLat,
|
|
@@ -63,21 +51,19 @@ function insideBoundingBoxArrayToBoundingBox(value) {
|
|
|
63
51
|
}
|
|
64
52
|
};
|
|
65
53
|
}
|
|
66
|
-
|
|
67
54
|
function insideBoundingBoxStringToBoundingBox(value) {
|
|
68
55
|
var _value$split$map = value.split(',').map(parseFloat),
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
// throw an error due to the wrong format. So throw an error should be safe.
|
|
75
|
-
|
|
56
|
+
_value$split$map2 = _slicedToArray(_value$split$map, 4),
|
|
57
|
+
neLat = _value$split$map2[0],
|
|
58
|
+
neLng = _value$split$map2[1],
|
|
59
|
+
swLat = _value$split$map2[2],
|
|
60
|
+
swLng = _value$split$map2[3];
|
|
76
61
|
|
|
62
|
+
// Since the value provided is the one send with the request, the API should
|
|
63
|
+
// throw an error due to the wrong format. So throw an error should be safe.
|
|
77
64
|
if (!neLat || !neLng || !swLat || !swLng) {
|
|
78
65
|
throw new Error("Invalid value for \"insideBoundingBox\" parameter: \"".concat(value, "\""));
|
|
79
66
|
}
|
|
80
|
-
|
|
81
67
|
return {
|
|
82
68
|
northEast: {
|
|
83
69
|
lat: neLat,
|
|
@@ -89,11 +75,9 @@ function insideBoundingBoxStringToBoundingBox(value) {
|
|
|
89
75
|
}
|
|
90
76
|
};
|
|
91
77
|
}
|
|
92
|
-
|
|
93
78
|
function insideBoundingBoxToBoundingBox(value) {
|
|
94
79
|
if (Array.isArray(value)) {
|
|
95
80
|
return insideBoundingBoxArrayToBoundingBox(value);
|
|
96
81
|
}
|
|
97
|
-
|
|
98
82
|
return insideBoundingBoxStringToBoundingBox(value);
|
|
99
83
|
}
|
|
@@ -4,14 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.getAppIdAndApiKey = getAppIdAndApiKey;
|
|
7
|
-
|
|
8
7
|
// typed as any, since it accepts the _real_ js clients, not the interface we otherwise expect
|
|
9
8
|
function getAppIdAndApiKey(searchClient) {
|
|
10
9
|
if (searchClient.transporter) {
|
|
11
10
|
// searchClient v4
|
|
12
11
|
var _searchClient$transpo = searchClient.transporter,
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
headers = _searchClient$transpo.headers,
|
|
13
|
+
queryParameters = _searchClient$transpo.queryParameters;
|
|
15
14
|
var APP_ID = 'x-algolia-application-id';
|
|
16
15
|
var API_KEY = 'x-algolia-api-key';
|
|
17
16
|
var appId = headers[APP_ID] || queryParameters[APP_ID];
|
|
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.getContainerNode = getContainerNode;
|
|
7
|
-
|
|
8
|
-
var _isDomElement = require("./isDomElement.js");
|
|
9
|
-
|
|
7
|
+
var _isDomElement = require("./isDomElement");
|
|
10
8
|
/**
|
|
11
9
|
* Return the container. If it's a string, it is considered a
|
|
12
10
|
* css selector and retrieves the first matching element. Otherwise
|
|
@@ -19,16 +17,12 @@ var _isDomElement = require("./isDomElement.js");
|
|
|
19
17
|
function getContainerNode(selectorOrHTMLElement) {
|
|
20
18
|
var isSelectorString = typeof selectorOrHTMLElement === 'string';
|
|
21
19
|
var domElement = isSelectorString ? document.querySelector(selectorOrHTMLElement) : selectorOrHTMLElement;
|
|
22
|
-
|
|
23
20
|
if (!(0, _isDomElement.isDomElement)(domElement)) {
|
|
24
21
|
var errorMessage = 'Container must be `string` or `HTMLElement`.';
|
|
25
|
-
|
|
26
22
|
if (isSelectorString) {
|
|
27
23
|
errorMessage += " Unable to find ".concat(selectorOrHTMLElement);
|
|
28
24
|
}
|
|
29
|
-
|
|
30
25
|
throw new Error(errorMessage);
|
|
31
26
|
}
|
|
32
|
-
|
|
33
27
|
return domElement;
|
|
34
28
|
}
|
|
@@ -4,21 +4,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.getHighlightFromSiblings = getHighlightFromSiblings;
|
|
7
|
-
|
|
8
|
-
var _escapeHtml = require("./escape-html.js");
|
|
9
|
-
|
|
7
|
+
var _escapeHtml = require("./escape-html");
|
|
10
8
|
var hasAlphanumeric = new RegExp(/\w/i);
|
|
11
|
-
|
|
12
9
|
function getHighlightFromSiblings(parts, i) {
|
|
13
10
|
var _parts, _parts2;
|
|
14
|
-
|
|
15
11
|
var current = parts[i];
|
|
16
12
|
var isNextHighlighted = ((_parts = parts[i + 1]) === null || _parts === void 0 ? void 0 : _parts.isHighlighted) || true;
|
|
17
13
|
var isPreviousHighlighted = ((_parts2 = parts[i - 1]) === null || _parts2 === void 0 ? void 0 : _parts2.isHighlighted) || true;
|
|
18
|
-
|
|
19
14
|
if (!hasAlphanumeric.test((0, _escapeHtml.unescape)(current.value)) && isPreviousHighlighted === isNextHighlighted) {
|
|
20
15
|
return isPreviousHighlighted;
|
|
21
16
|
}
|
|
22
|
-
|
|
23
17
|
return current.isHighlighted;
|
|
24
18
|
}
|
|
@@ -4,12 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.getHighlightedParts = getHighlightedParts;
|
|
7
|
-
|
|
8
|
-
var _escapeHighlight = require("./escape-highlight.js");
|
|
9
|
-
|
|
7
|
+
var _escapeHighlight = require("./escape-highlight");
|
|
10
8
|
function getHighlightedParts(highlightedValue) {
|
|
11
9
|
var highlightPostTag = _escapeHighlight.TAG_REPLACEMENT.highlightPostTag,
|
|
12
|
-
|
|
10
|
+
highlightPreTag = _escapeHighlight.TAG_REPLACEMENT.highlightPreTag;
|
|
13
11
|
var splitByPreTag = highlightedValue.split(highlightPreTag);
|
|
14
12
|
var firstValue = splitByPreTag.shift();
|
|
15
13
|
var elements = !firstValue ? [] : [{
|
|
@@ -22,7 +20,6 @@ function getHighlightedParts(highlightedValue) {
|
|
|
22
20
|
value: splitByPostTag[0],
|
|
23
21
|
isHighlighted: true
|
|
24
22
|
});
|
|
25
|
-
|
|
26
23
|
if (splitByPostTag[1] !== '') {
|
|
27
24
|
elements.push({
|
|
28
25
|
value: splitByPostTag[1],
|
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.getPropertyByPath = getPropertyByPath;
|
|
7
|
-
|
|
8
7
|
function getPropertyByPath(object, path) {
|
|
9
8
|
var parts = Array.isArray(path) ? path : path.split('.');
|
|
10
9
|
return parts.reduce(function (current, key) {
|
|
@@ -4,11 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.getRefinements = getRefinements;
|
|
7
|
-
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
var _escapeFacetValue = require("./escapeFacetValue.js");
|
|
11
|
-
|
|
7
|
+
var _find = require("./find");
|
|
8
|
+
var _escapeFacetValue = require("./escapeFacetValue");
|
|
12
9
|
function getRefinement(state, type, attribute, name) {
|
|
13
10
|
var resultsFacets = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : [];
|
|
14
11
|
var res = {
|
|
@@ -21,60 +18,49 @@ function getRefinement(state, type, attribute, name) {
|
|
|
21
18
|
return resultsFacet.name === attribute;
|
|
22
19
|
});
|
|
23
20
|
var count;
|
|
24
|
-
|
|
25
21
|
if (type === 'hierarchical') {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
return function (refinementKey) {
|
|
32
|
-
return facetData[refinementKey];
|
|
33
|
-
};
|
|
22
|
+
var facetDeclaration = state.getHierarchicalFacetByName(attribute);
|
|
23
|
+
var nameParts = name.split(facetDeclaration.separator);
|
|
24
|
+
var getFacetRefinement = function getFacetRefinement(facetData) {
|
|
25
|
+
return function (refinementKey) {
|
|
26
|
+
return facetData[refinementKey];
|
|
34
27
|
};
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
count = facet && facet.count;
|
|
47
|
-
})();
|
|
28
|
+
};
|
|
29
|
+
var _loop = function _loop(i) {
|
|
30
|
+
facet = facet && facet.data && (0, _find.find)(Object.keys(facet.data).map(getFacetRefinement(facet.data)), function (refinement) {
|
|
31
|
+
return refinement.name === nameParts[i];
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
for (var i = 0; facet !== undefined && i < nameParts.length; ++i) {
|
|
35
|
+
_loop(i);
|
|
36
|
+
}
|
|
37
|
+
count = facet && facet.count;
|
|
48
38
|
} else {
|
|
49
39
|
count = facet && facet.data && facet.data[res.name];
|
|
50
40
|
}
|
|
51
|
-
|
|
52
41
|
if (count !== undefined) {
|
|
53
42
|
res.count = count;
|
|
54
43
|
}
|
|
55
|
-
|
|
56
44
|
if (facet && facet.exhaustive !== undefined) {
|
|
57
45
|
res.exhaustive = facet.exhaustive;
|
|
58
46
|
}
|
|
59
|
-
|
|
60
47
|
return res;
|
|
61
48
|
}
|
|
62
|
-
|
|
63
49
|
function getRefinements(results, state) {
|
|
64
50
|
var includesQuery = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
65
51
|
var refinements = [];
|
|
66
52
|
var _state$facetsRefineme = state.facetsRefinements,
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
53
|
+
facetsRefinements = _state$facetsRefineme === void 0 ? {} : _state$facetsRefineme,
|
|
54
|
+
_state$facetsExcludes = state.facetsExcludes,
|
|
55
|
+
facetsExcludes = _state$facetsExcludes === void 0 ? {} : _state$facetsExcludes,
|
|
56
|
+
_state$disjunctiveFac = state.disjunctiveFacetsRefinements,
|
|
57
|
+
disjunctiveFacetsRefinements = _state$disjunctiveFac === void 0 ? {} : _state$disjunctiveFac,
|
|
58
|
+
_state$hierarchicalFa = state.hierarchicalFacetsRefinements,
|
|
59
|
+
hierarchicalFacetsRefinements = _state$hierarchicalFa === void 0 ? {} : _state$hierarchicalFa,
|
|
60
|
+
_state$numericRefinem = state.numericRefinements,
|
|
61
|
+
numericRefinements = _state$numericRefinem === void 0 ? {} : _state$numericRefinem,
|
|
62
|
+
_state$tagRefinements = state.tagRefinements,
|
|
63
|
+
tagRefinements = _state$tagRefinements === void 0 ? [] : _state$tagRefinements;
|
|
78
64
|
Object.keys(facetsRefinements).forEach(function (attribute) {
|
|
79
65
|
var refinementNames = facetsRefinements[attribute];
|
|
80
66
|
refinementNames.forEach(function (refinementName) {
|
|
@@ -95,7 +81,8 @@ function getRefinements(results, state) {
|
|
|
95
81
|
Object.keys(disjunctiveFacetsRefinements).forEach(function (attribute) {
|
|
96
82
|
var refinementNames = disjunctiveFacetsRefinements[attribute];
|
|
97
83
|
refinementNames.forEach(function (refinementName) {
|
|
98
|
-
refinements.push(getRefinement(state, 'disjunctive', attribute,
|
|
84
|
+
refinements.push(getRefinement(state, 'disjunctive', attribute,
|
|
85
|
+
// We unescape any disjunctive refined values with `unescapeFacetValue` because
|
|
99
86
|
// they can be escaped on negative numeric values with `escapeFacetValue`.
|
|
100
87
|
(0, _escapeFacetValue.unescapeFacetValue)(refinementName), results.disjunctiveFacets));
|
|
101
88
|
});
|
|
@@ -130,7 +117,6 @@ function getRefinements(results, state) {
|
|
|
130
117
|
name: refinementName
|
|
131
118
|
});
|
|
132
119
|
});
|
|
133
|
-
|
|
134
120
|
if (includesQuery && state.query && state.query.trim()) {
|
|
135
121
|
refinements.push({
|
|
136
122
|
attribute: 'query',
|
|
@@ -139,6 +125,5 @@ function getRefinements(results, state) {
|
|
|
139
125
|
query: state.query
|
|
140
126
|
});
|
|
141
127
|
}
|
|
142
|
-
|
|
143
128
|
return refinements;
|
|
144
129
|
}
|
|
@@ -4,27 +4,21 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.getWidgetAttribute = getWidgetAttribute;
|
|
7
|
-
|
|
8
7
|
function getWidgetAttribute(widget, initOptions) {
|
|
9
8
|
var _widget$getWidgetRend;
|
|
10
|
-
|
|
11
9
|
var renderState = (_widget$getWidgetRend = widget.getWidgetRenderState) === null || _widget$getWidgetRend === void 0 ? void 0 : _widget$getWidgetRend.call(widget, initOptions);
|
|
12
10
|
var attribute = null;
|
|
13
|
-
|
|
14
11
|
if (renderState && renderState.widgetParams) {
|
|
15
12
|
// casting as widgetParams is checked just before
|
|
16
13
|
var widgetParams = renderState.widgetParams;
|
|
17
|
-
|
|
18
14
|
if (widgetParams.attribute) {
|
|
19
15
|
attribute = widgetParams.attribute;
|
|
20
16
|
} else if (Array.isArray(widgetParams.attributes)) {
|
|
21
17
|
attribute = widgetParams.attributes[0];
|
|
22
18
|
}
|
|
23
19
|
}
|
|
24
|
-
|
|
25
20
|
if (typeof attribute !== 'string') {
|
|
26
21
|
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."));
|
|
27
22
|
}
|
|
28
|
-
|
|
29
23
|
return attribute;
|
|
30
24
|
}
|
|
@@ -4,13 +4,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.addAbsolutePosition = addAbsolutePosition;
|
|
7
|
-
|
|
8
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
9
|
-
|
|
10
|
-
function
|
|
11
|
-
|
|
12
|
-
function
|
|
13
|
-
|
|
7
|
+
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); }
|
|
8
|
+
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; }
|
|
9
|
+
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; }
|
|
10
|
+
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; }
|
|
11
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
12
|
+
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); }
|
|
14
13
|
function addAbsolutePosition(hits, page, hitsPerPage) {
|
|
15
14
|
return hits.map(function (hit, idx) {
|
|
16
15
|
return _objectSpread(_objectSpread({}, hit), {}, {
|