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,38 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof";
|
|
4
|
-
|
|
3
|
+
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); }
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = void 0;
|
|
9
|
-
|
|
10
8
|
var _preact = require("preact");
|
|
11
|
-
|
|
12
9
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
13
|
-
|
|
14
|
-
function
|
|
15
|
-
|
|
16
|
-
function
|
|
17
|
-
|
|
18
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
19
|
-
|
|
20
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
21
|
-
|
|
10
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
11
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
12
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
13
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
22
14
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
23
|
-
|
|
24
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
25
|
-
|
|
15
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
26
16
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
27
|
-
|
|
28
|
-
function
|
|
29
|
-
|
|
30
|
-
function
|
|
31
|
-
|
|
32
|
-
function
|
|
33
|
-
|
|
34
|
-
function _extends() { _extends = Object.assign || 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); }
|
|
35
|
-
|
|
17
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
18
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
19
|
+
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; }
|
|
20
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
21
|
+
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
|
+
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); }
|
|
36
23
|
var KEYS = {
|
|
37
24
|
DOWN: 40,
|
|
38
25
|
END: 35,
|
|
@@ -46,61 +33,47 @@ var KEYS = {
|
|
|
46
33
|
};
|
|
47
34
|
var PERCENT_EMPTY = 0;
|
|
48
35
|
var PERCENT_FULL = 100;
|
|
49
|
-
|
|
50
36
|
function getPosition(value, min, max) {
|
|
51
37
|
return (value - min) / (max - min) * 100;
|
|
52
38
|
}
|
|
53
|
-
|
|
54
39
|
function getValue(pos, min, max) {
|
|
55
40
|
var decimal = pos / 100;
|
|
56
|
-
|
|
57
41
|
if (pos === 0) {
|
|
58
42
|
return min;
|
|
59
43
|
} else if (pos === 100) {
|
|
60
44
|
return max;
|
|
61
45
|
}
|
|
62
|
-
|
|
63
46
|
return Math.round((max - min) * decimal + min);
|
|
64
47
|
}
|
|
65
|
-
|
|
66
48
|
function getClassName(props) {
|
|
67
49
|
var orientation = props.orientation === 'vertical' ? 'rheostat-vertical' : 'rheostat-horizontal';
|
|
68
50
|
return ['rheostat', orientation].concat(props.className.split(' ')).join(' ');
|
|
69
51
|
}
|
|
70
|
-
|
|
71
52
|
function getHandleFor(ev) {
|
|
72
53
|
return Number(ev.currentTarget.getAttribute('data-handle-key'));
|
|
73
54
|
}
|
|
74
|
-
|
|
75
55
|
function killEvent(ev) {
|
|
76
56
|
ev.stopPropagation();
|
|
77
57
|
ev.preventDefault();
|
|
78
58
|
}
|
|
79
|
-
|
|
80
59
|
function Button(props) {
|
|
81
60
|
return (0, _preact.h)("button", _extends({}, props, {
|
|
82
61
|
type: "button"
|
|
83
62
|
}));
|
|
84
|
-
}
|
|
85
|
-
// maybe migrate to csstype later?
|
|
86
|
-
|
|
63
|
+
}
|
|
87
64
|
|
|
65
|
+
// Preact doesn't have builtin types for Style, JSX.HTMLAttributes['style'] is just object
|
|
66
|
+
// maybe migrate to csstype later?
|
|
88
67
|
var _ref6 = (0, _preact.h)("div", {
|
|
89
68
|
className: "rheostat-background"
|
|
90
69
|
});
|
|
91
|
-
|
|
92
70
|
var Rheostat = /*#__PURE__*/function (_Component) {
|
|
93
71
|
_inherits(Rheostat, _Component);
|
|
94
|
-
|
|
95
72
|
var _super = _createSuper(Rheostat);
|
|
96
|
-
|
|
97
73
|
function Rheostat(props) {
|
|
98
74
|
var _this;
|
|
99
|
-
|
|
100
75
|
_classCallCheck(this, Rheostat);
|
|
101
|
-
|
|
102
76
|
_this = _super.call(this, props);
|
|
103
|
-
|
|
104
77
|
_defineProperty(_assertThisInitialized(_this), "state", {
|
|
105
78
|
className: getClassName(_this.props),
|
|
106
79
|
// non-null thanks to defaultProps
|
|
@@ -114,9 +87,7 @@ var Rheostat = /*#__PURE__*/function (_Component) {
|
|
|
114
87
|
// non-null thanks to defaultProps
|
|
115
88
|
values: _this.props.values
|
|
116
89
|
});
|
|
117
|
-
|
|
118
90
|
_defineProperty(_assertThisInitialized(_this), "rheostat", (0, _preact.createRef)());
|
|
119
|
-
|
|
120
91
|
_this.getPublicState = _this.getPublicState.bind(_assertThisInitialized(_this));
|
|
121
92
|
_this.getSliderBoundingBox = _this.getSliderBoundingBox.bind(_assertThisInitialized(_this));
|
|
122
93
|
_this.getProgressStyle = _this.getProgressStyle.bind(_assertThisInitialized(_this));
|
|
@@ -145,34 +116,30 @@ var Rheostat = /*#__PURE__*/function (_Component) {
|
|
|
145
116
|
_this.updateNewValues = _this.updateNewValues.bind(_assertThisInitialized(_this));
|
|
146
117
|
return _this;
|
|
147
118
|
}
|
|
148
|
-
|
|
149
119
|
_createClass(Rheostat, [{
|
|
150
120
|
key: "componentWillReceiveProps",
|
|
151
121
|
value: function componentWillReceiveProps(nextProps) {
|
|
152
122
|
var _this$props = this.props,
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
123
|
+
className = _this$props.className,
|
|
124
|
+
disabled = _this$props.disabled,
|
|
125
|
+
min = _this$props.min,
|
|
126
|
+
max = _this$props.max,
|
|
127
|
+
orientation = _this$props.orientation;
|
|
158
128
|
var _this$state = this.state,
|
|
159
|
-
|
|
160
|
-
|
|
129
|
+
values = _this$state.values,
|
|
130
|
+
slidingIndex = _this$state.slidingIndex;
|
|
161
131
|
var minMaxChanged = nextProps.min !== min || nextProps.max !== max;
|
|
162
132
|
var valuesChanged = values.length !== nextProps.values.length || values.some(function (value, idx) {
|
|
163
133
|
return nextProps.values[idx] !== value;
|
|
164
134
|
});
|
|
165
135
|
var orientationChanged = nextProps.className !== className || nextProps.orientation !== orientation;
|
|
166
136
|
var willBeDisabled = nextProps.disabled && !disabled;
|
|
167
|
-
|
|
168
137
|
if (orientationChanged) {
|
|
169
138
|
this.setState({
|
|
170
139
|
className: getClassName(nextProps)
|
|
171
140
|
});
|
|
172
141
|
}
|
|
173
|
-
|
|
174
142
|
if (minMaxChanged || valuesChanged) this.updateNewValues(nextProps);
|
|
175
|
-
|
|
176
143
|
if (willBeDisabled && slidingIndex !== null) {
|
|
177
144
|
this.endSlide();
|
|
178
145
|
}
|
|
@@ -181,8 +148,8 @@ var Rheostat = /*#__PURE__*/function (_Component) {
|
|
|
181
148
|
key: "getPublicState",
|
|
182
149
|
value: function getPublicState() {
|
|
183
150
|
var _this$props2 = this.props,
|
|
184
|
-
|
|
185
|
-
|
|
151
|
+
min = _this$props2.min,
|
|
152
|
+
max = _this$props2.max;
|
|
186
153
|
var values = this.state.values;
|
|
187
154
|
return {
|
|
188
155
|
max: max,
|
|
@@ -208,7 +175,6 @@ var Rheostat = /*#__PURE__*/function (_Component) {
|
|
|
208
175
|
value: function getProgressStyle(idx) {
|
|
209
176
|
var handlePos = this.state.handlePos;
|
|
210
177
|
var value = handlePos[idx];
|
|
211
|
-
|
|
212
178
|
if (idx === 0) {
|
|
213
179
|
return this.props.orientation === 'vertical' ? {
|
|
214
180
|
height: "".concat(value, "%"),
|
|
@@ -218,7 +184,6 @@ var Rheostat = /*#__PURE__*/function (_Component) {
|
|
|
218
184
|
width: "".concat(value, "%")
|
|
219
185
|
};
|
|
220
186
|
}
|
|
221
|
-
|
|
222
187
|
var prevValue = handlePos[idx - 1];
|
|
223
188
|
var diffValue = value - prevValue;
|
|
224
189
|
return this.props.orientation === 'vertical' ? {
|
|
@@ -260,8 +225,8 @@ var Rheostat = /*#__PURE__*/function (_Component) {
|
|
|
260
225
|
value: function getSnapPosition(positionPercent) {
|
|
261
226
|
if (!this.props.snap) return positionPercent;
|
|
262
227
|
var _ref = this.props,
|
|
263
|
-
|
|
264
|
-
|
|
228
|
+
max = _ref.max,
|
|
229
|
+
min = _ref.min;
|
|
265
230
|
var value = getValue(positionPercent, min, max);
|
|
266
231
|
var snapValue = this.getClosestSnapPoint(value);
|
|
267
232
|
return getPosition(snapValue, min, max);
|
|
@@ -270,32 +235,27 @@ var Rheostat = /*#__PURE__*/function (_Component) {
|
|
|
270
235
|
key: "getNextPositionForKey",
|
|
271
236
|
value: function getNextPositionForKey(idx, keyCode) {
|
|
272
237
|
var _stepMultiplier;
|
|
273
|
-
|
|
274
238
|
var _this$state2 = this.state,
|
|
275
|
-
|
|
276
|
-
|
|
239
|
+
handlePos = _this$state2.handlePos,
|
|
240
|
+
values = _this$state2.values;
|
|
277
241
|
var _ref2 = this.props,
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
242
|
+
max = _ref2.max,
|
|
243
|
+
min = _ref2.min,
|
|
244
|
+
snapPoints = _ref2.snapPoints;
|
|
281
245
|
var shouldSnap = this.props.snap;
|
|
282
246
|
var proposedValue = values[idx];
|
|
283
247
|
var proposedPercentage = handlePos[idx];
|
|
284
248
|
var originalPercentage = proposedPercentage;
|
|
285
249
|
var stepValue = 1;
|
|
286
|
-
|
|
287
250
|
if (max >= 100) {
|
|
288
251
|
proposedPercentage = Math.round(proposedPercentage);
|
|
289
252
|
} else {
|
|
290
253
|
stepValue = 100 / (max - min);
|
|
291
254
|
}
|
|
292
|
-
|
|
293
255
|
var currentIndex = null;
|
|
294
|
-
|
|
295
256
|
if (shouldSnap) {
|
|
296
257
|
currentIndex = snapPoints.indexOf(this.getClosestSnapPoint(values[idx]));
|
|
297
258
|
}
|
|
298
|
-
|
|
299
259
|
var stepMultiplier = (_stepMultiplier = {}, _defineProperty(_stepMultiplier, KEYS.LEFT, function (v) {
|
|
300
260
|
return v * -1;
|
|
301
261
|
}), _defineProperty(_stepMultiplier, KEYS.RIGHT, function (v) {
|
|
@@ -309,38 +269,34 @@ var Rheostat = /*#__PURE__*/function (_Component) {
|
|
|
309
269
|
}), _defineProperty(_stepMultiplier, KEYS.PAGE_UP, function (v) {
|
|
310
270
|
return v > 1 ? v : v * 10;
|
|
311
271
|
}), _stepMultiplier);
|
|
312
|
-
|
|
313
272
|
if (Object.prototype.hasOwnProperty.call(stepMultiplier, keyCode)) {
|
|
314
273
|
proposedPercentage += stepMultiplier[keyCode](stepValue);
|
|
315
|
-
|
|
316
274
|
if (shouldSnap) {
|
|
317
|
-
if (!currentIndex) {
|
|
275
|
+
if (!currentIndex) {
|
|
276
|
+
// nothing happens
|
|
318
277
|
} else if (proposedPercentage > originalPercentage) {
|
|
319
278
|
// move cursor right unless overflow
|
|
320
279
|
if (currentIndex < snapPoints.length - 1) {
|
|
321
280
|
proposedValue = snapPoints[currentIndex + 1];
|
|
322
|
-
}
|
|
323
|
-
|
|
281
|
+
}
|
|
282
|
+
// move cursor left unless there is overflow
|
|
324
283
|
} else if (currentIndex > 0) {
|
|
325
284
|
proposedValue = snapPoints[currentIndex - 1];
|
|
326
285
|
}
|
|
327
286
|
}
|
|
328
287
|
} else if (keyCode === KEYS.HOME) {
|
|
329
288
|
proposedPercentage = PERCENT_EMPTY;
|
|
330
|
-
|
|
331
289
|
if (shouldSnap) {
|
|
332
290
|
proposedValue = snapPoints[0];
|
|
333
291
|
}
|
|
334
292
|
} else if (keyCode === KEYS.END) {
|
|
335
293
|
proposedPercentage = PERCENT_FULL;
|
|
336
|
-
|
|
337
294
|
if (shouldSnap) {
|
|
338
295
|
proposedValue = snapPoints[snapPoints.length - 1];
|
|
339
296
|
}
|
|
340
297
|
} else {
|
|
341
298
|
return null;
|
|
342
299
|
}
|
|
343
|
-
|
|
344
300
|
return shouldSnap ? getPosition(proposedValue, min, max) : proposedPercentage;
|
|
345
301
|
}
|
|
346
302
|
}, {
|
|
@@ -348,8 +304,8 @@ var Rheostat = /*#__PURE__*/function (_Component) {
|
|
|
348
304
|
value: function getNextState(idx, proposedPosition) {
|
|
349
305
|
var handlePos = this.state.handlePos;
|
|
350
306
|
var _ref3 = this.props,
|
|
351
|
-
|
|
352
|
-
|
|
307
|
+
max = _ref3.max,
|
|
308
|
+
min = _ref3.min;
|
|
353
309
|
var actualPosition = this.validatePosition(idx, proposedPosition);
|
|
354
310
|
var nextHandlePos = handlePos.map(function (pos, index) {
|
|
355
311
|
return index === idx ? actualPosition : pos;
|
|
@@ -415,12 +371,10 @@ var Rheostat = /*#__PURE__*/function (_Component) {
|
|
|
415
371
|
key: "handleTouchSlide",
|
|
416
372
|
value: function handleTouchSlide(ev) {
|
|
417
373
|
if (this.state.slidingIndex === null) return;
|
|
418
|
-
|
|
419
374
|
if (ev.changedTouches.length > 1) {
|
|
420
375
|
this.endSlide();
|
|
421
376
|
return;
|
|
422
377
|
}
|
|
423
|
-
|
|
424
378
|
var touch = ev.changedTouches[0];
|
|
425
379
|
this.handleSlide(touch.clientX, touch.clientY);
|
|
426
380
|
killEvent(ev);
|
|
@@ -429,11 +383,10 @@ var Rheostat = /*#__PURE__*/function (_Component) {
|
|
|
429
383
|
key: "handleSlide",
|
|
430
384
|
value: function handleSlide(x, y) {
|
|
431
385
|
var _this$state3 = this.state,
|
|
432
|
-
|
|
433
|
-
|
|
386
|
+
idx = _this$state3.slidingIndex,
|
|
387
|
+
sliderBox = _this$state3.sliderBox;
|
|
434
388
|
var positionPercent = this.props.orientation === 'vertical' ? (y - sliderBox.top) / sliderBox.height * PERCENT_FULL : (x - sliderBox.left) / sliderBox.width * PERCENT_FULL;
|
|
435
389
|
this.slideTo(idx, positionPercent);
|
|
436
|
-
|
|
437
390
|
if (this.canMove(idx, positionPercent)) {
|
|
438
391
|
// update mouse positions
|
|
439
392
|
this.setState({
|
|
@@ -449,7 +402,6 @@ var Rheostat = /*#__PURE__*/function (_Component) {
|
|
|
449
402
|
key: "endSlide",
|
|
450
403
|
value: function endSlide() {
|
|
451
404
|
var _this2 = this;
|
|
452
|
-
|
|
453
405
|
var idx = this.state.slidingIndex;
|
|
454
406
|
this.setState({
|
|
455
407
|
slidingIndex: null
|
|
@@ -459,7 +411,6 @@ var Rheostat = /*#__PURE__*/function (_Component) {
|
|
|
459
411
|
document.removeEventListener('touchmove', this.handleTouchSlide, false);
|
|
460
412
|
document.removeEventListener('mousemove', this.handleMouseSlide, false);
|
|
461
413
|
if (this.props.onSliderDragEnd) this.props.onSliderDragEnd();
|
|
462
|
-
|
|
463
414
|
if (this.props.snap) {
|
|
464
415
|
var positionPercent = this.getSnapPosition(this.state.handlePos[idx]);
|
|
465
416
|
this.slideTo(idx, positionPercent, function () {
|
|
@@ -473,19 +424,19 @@ var Rheostat = /*#__PURE__*/function (_Component) {
|
|
|
473
424
|
key: "handleClick",
|
|
474
425
|
value: function handleClick(ev) {
|
|
475
426
|
var _this3 = this;
|
|
476
|
-
|
|
477
427
|
if (ev.target.getAttribute('data-handle-key')) {
|
|
478
428
|
return;
|
|
479
|
-
}
|
|
480
|
-
// the position where you click in relativity.
|
|
481
|
-
|
|
429
|
+
}
|
|
482
430
|
|
|
431
|
+
// Calculate the position of the slider on the page so we can determine
|
|
432
|
+
// the position where you click in relativity.
|
|
483
433
|
var sliderBox = this.getSliderBoundingBox();
|
|
484
434
|
var positionDecimal = this.props.orientation === 'vertical' ? (ev.clientY - sliderBox.top) / sliderBox.height : (ev.clientX - sliderBox.left) / sliderBox.width;
|
|
485
435
|
var positionPercent = positionDecimal * PERCENT_FULL;
|
|
486
436
|
var handleId = this.getClosestHandle(positionPercent);
|
|
487
|
-
var validPositionPercent = this.getSnapPosition(positionPercent);
|
|
437
|
+
var validPositionPercent = this.getSnapPosition(positionPercent);
|
|
488
438
|
|
|
439
|
+
// Move the handle there
|
|
489
440
|
this.slideTo(handleId, validPositionPercent, function () {
|
|
490
441
|
return _this3.fireChangeEvent();
|
|
491
442
|
});
|
|
@@ -495,34 +446,30 @@ var Rheostat = /*#__PURE__*/function (_Component) {
|
|
|
495
446
|
key: "handleKeydown",
|
|
496
447
|
value: function handleKeydown(ev) {
|
|
497
448
|
var _this4 = this;
|
|
498
|
-
|
|
499
449
|
var idx = getHandleFor(ev);
|
|
500
|
-
|
|
501
450
|
if (ev.keyCode === KEYS.ESC) {
|
|
502
451
|
ev.currentTarget.blur();
|
|
503
452
|
return;
|
|
504
453
|
}
|
|
505
|
-
|
|
506
454
|
var proposedPercentage = this.getNextPositionForKey(idx, ev.keyCode);
|
|
507
455
|
if (proposedPercentage === null) return;
|
|
508
|
-
|
|
509
456
|
if (this.canMove(idx, proposedPercentage)) {
|
|
510
457
|
this.slideTo(idx, proposedPercentage, function () {
|
|
511
458
|
return _this4.fireChangeEvent();
|
|
512
459
|
});
|
|
513
460
|
if (this.props.onKeyPress) this.props.onKeyPress();
|
|
514
461
|
}
|
|
515
|
-
|
|
516
462
|
killEvent(ev);
|
|
517
|
-
}
|
|
518
|
-
// does not collide with other handles too much.
|
|
463
|
+
}
|
|
519
464
|
|
|
465
|
+
// Make sure the proposed position respects the bounds and
|
|
466
|
+
// does not collide with other handles too much.
|
|
520
467
|
}, {
|
|
521
468
|
key: "validatePosition",
|
|
522
469
|
value: function validatePosition(idx, proposedPosition) {
|
|
523
470
|
var _this$state4 = this.state,
|
|
524
|
-
|
|
525
|
-
|
|
471
|
+
handlePos = _this$state4.handlePos,
|
|
472
|
+
handleDimensions = _this$state4.handleDimensions;
|
|
526
473
|
return Math.max(Math.min(proposedPosition, handlePos[idx + 1] !== undefined ? handlePos[idx + 1] - handleDimensions : PERCENT_FULL // 100% is the highest value
|
|
527
474
|
), handlePos[idx - 1] !== undefined ? handlePos[idx - 1] + handleDimensions : PERCENT_EMPTY // 0% is the lowest value
|
|
528
475
|
);
|
|
@@ -531,16 +478,13 @@ var Rheostat = /*#__PURE__*/function (_Component) {
|
|
|
531
478
|
key: "validateValues",
|
|
532
479
|
value: function validateValues(proposedValues, props) {
|
|
533
480
|
var _ref4 = props || this.props,
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
481
|
+
max = _ref4.max,
|
|
482
|
+
min = _ref4.min;
|
|
537
483
|
return proposedValues.map(function (value, idx, values) {
|
|
538
484
|
var realValue = Math.max(Math.min(value, max), min);
|
|
539
|
-
|
|
540
485
|
if (values.length && realValue < values[idx - 1]) {
|
|
541
486
|
return values[idx - 1];
|
|
542
487
|
}
|
|
543
|
-
|
|
544
488
|
return realValue;
|
|
545
489
|
});
|
|
546
490
|
}
|
|
@@ -548,8 +492,8 @@ var Rheostat = /*#__PURE__*/function (_Component) {
|
|
|
548
492
|
key: "canMove",
|
|
549
493
|
value: function canMove(idx, proposedPosition) {
|
|
550
494
|
var _this$state5 = this.state,
|
|
551
|
-
|
|
552
|
-
|
|
495
|
+
handlePos = _this$state5.handlePos,
|
|
496
|
+
handleDimensions = _this$state5.handleDimensions;
|
|
553
497
|
if (proposedPosition < PERCENT_EMPTY) return false;
|
|
554
498
|
if (proposedPosition > PERCENT_FULL) return false;
|
|
555
499
|
var nextHandlePosition = handlePos[idx + 1] !== undefined ? handlePos[idx + 1] - handleDimensions : Infinity;
|
|
@@ -568,7 +512,6 @@ var Rheostat = /*#__PURE__*/function (_Component) {
|
|
|
568
512
|
key: "slideTo",
|
|
569
513
|
value: function slideTo(idx, proposedPosition, onAfterSet) {
|
|
570
514
|
var _this5 = this;
|
|
571
|
-
|
|
572
515
|
var nextState = this.getNextState(idx, proposedPosition);
|
|
573
516
|
this.setState(nextState, function () {
|
|
574
517
|
var onValuesUpdated = _this5.props.onValuesUpdated;
|
|
@@ -580,16 +523,15 @@ var Rheostat = /*#__PURE__*/function (_Component) {
|
|
|
580
523
|
key: "updateNewValues",
|
|
581
524
|
value: function updateNewValues(nextProps) {
|
|
582
525
|
var _this6 = this;
|
|
526
|
+
var slidingIndex = this.state.slidingIndex;
|
|
583
527
|
|
|
584
|
-
|
|
585
|
-
|
|
528
|
+
// Don't update while the slider is sliding
|
|
586
529
|
if (slidingIndex !== null) {
|
|
587
530
|
return;
|
|
588
531
|
}
|
|
589
|
-
|
|
590
532
|
var max = nextProps.max,
|
|
591
|
-
|
|
592
|
-
|
|
533
|
+
min = nextProps.min,
|
|
534
|
+
values = nextProps.values;
|
|
593
535
|
var nextValues = this.validateValues(values, nextProps);
|
|
594
536
|
this.setState({
|
|
595
537
|
handlePos: nextValues.map(function (value) {
|
|
@@ -604,22 +546,20 @@ var Rheostat = /*#__PURE__*/function (_Component) {
|
|
|
604
546
|
key: "render",
|
|
605
547
|
value: function render() {
|
|
606
548
|
var _this7 = this;
|
|
607
|
-
|
|
608
549
|
var _ref5 = this.props,
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
550
|
+
children = _ref5.children,
|
|
551
|
+
disabled = _ref5.disabled,
|
|
552
|
+
Handle = _ref5.handle,
|
|
553
|
+
max = _ref5.max,
|
|
554
|
+
min = _ref5.min,
|
|
555
|
+
orientation = _ref5.orientation,
|
|
556
|
+
PitComponent = _ref5.pitComponent,
|
|
557
|
+
pitPoints = _ref5.pitPoints,
|
|
558
|
+
ProgressBar = _ref5.progressBar; // all required thanks to defaultProps
|
|
619
559
|
var _this$state6 = this.state,
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
560
|
+
className = _this$state6.className,
|
|
561
|
+
handlePos = _this$state6.handlePos,
|
|
562
|
+
values = _this$state6.values;
|
|
623
563
|
return (0, _preact.h)("div", {
|
|
624
564
|
className: className,
|
|
625
565
|
ref: this.rheostat,
|
|
@@ -655,7 +595,6 @@ var Rheostat = /*#__PURE__*/function (_Component) {
|
|
|
655
595
|
if (idx === 0 && arr.length > 1) {
|
|
656
596
|
return null;
|
|
657
597
|
}
|
|
658
|
-
|
|
659
598
|
return (0, _preact.h)(ProgressBar, {
|
|
660
599
|
className: "rheostat-progress",
|
|
661
600
|
key: "progress-bar-".concat(idx),
|
|
@@ -677,10 +616,8 @@ var Rheostat = /*#__PURE__*/function (_Component) {
|
|
|
677
616
|
}), children);
|
|
678
617
|
}
|
|
679
618
|
}]);
|
|
680
|
-
|
|
681
619
|
return Rheostat;
|
|
682
620
|
}(_preact.Component);
|
|
683
|
-
|
|
684
621
|
_defineProperty(Rheostat, "defaultProps", {
|
|
685
622
|
className: '',
|
|
686
623
|
children: null,
|
|
@@ -703,6 +640,5 @@ _defineProperty(Rheostat, "defaultProps", {
|
|
|
703
640
|
snapPoints: [],
|
|
704
641
|
values: [PERCENT_EMPTY]
|
|
705
642
|
});
|
|
706
|
-
|
|
707
643
|
var _default = Rheostat;
|
|
708
644
|
exports.default = _default;
|