instantsearch.js 4.80.0 → 4.82.0
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/cjs/components/Answers/Answers.js +4 -4
- package/cjs/components/Breadcrumb/Breadcrumb.js +2 -2
- package/cjs/components/ClearRefinements/ClearRefinements.js +2 -2
- package/cjs/components/GeoSearchControls/GeoSearchControls.js +2 -2
- package/cjs/components/Highlight/Highlight.js +3 -3
- package/cjs/components/InfiniteHits/InfiniteHits.js +4 -4
- package/cjs/components/MenuSelect/MenuSelect.js +2 -2
- package/cjs/components/Pagination/Pagination.js +1 -1
- package/cjs/components/Panel/Panel.js +5 -5
- package/cjs/components/QueryRuleCustomData/QueryRuleCustomData.js +1 -1
- package/cjs/components/RangeInput/RangeInput.js +14 -14
- package/cjs/components/RefinementList/RefinementList.js +16 -16
- package/cjs/components/RefinementList/RefinementListItem.js +2 -2
- package/cjs/components/RelevantSort/RelevantSort.js +1 -1
- package/cjs/components/ReverseHighlight/ReverseHighlight.js +3 -3
- package/cjs/components/ReverseSnippet/ReverseSnippet.js +3 -3
- package/cjs/components/SearchBox/SearchBox.js +31 -19
- package/cjs/components/Slider/Pit.js +2 -2
- package/cjs/components/Slider/Rheostat.js +13 -13
- package/cjs/components/Slider/Slider.js +19 -19
- package/cjs/components/Snippet/Snippet.js +3 -3
- package/cjs/components/Stats/Stats.js +6 -6
- package/cjs/components/Template/Template.js +18 -18
- package/cjs/components/ToggleRefinement/ToggleRefinement.js +2 -2
- package/cjs/components/VoiceSearch/VoiceSearch.js +1 -1
- package/cjs/connectors/answers/connectAnswers.js +2 -2
- package/cjs/connectors/autocomplete/connectAutocomplete.js +2 -2
- package/cjs/connectors/breadcrumb/connectBreadcrumb.js +6 -6
- package/cjs/connectors/chat/connectChat.js +221 -0
- package/cjs/connectors/clear-refinements/connectClearRefinements.js +7 -7
- package/cjs/connectors/configure/connectConfigure.js +3 -3
- package/cjs/connectors/configure-related-items/connectConfigureRelatedItems.js +8 -8
- package/cjs/connectors/current-refinements/connectCurrentRefinements.js +7 -7
- package/cjs/connectors/dynamic-widgets/connectDynamicWidgets.js +2 -2
- package/cjs/connectors/frequently-bought-together/connectFrequentlyBoughtTogether.js +6 -3
- package/cjs/connectors/geo-search/connectGeoSearch.js +2 -2
- package/cjs/connectors/hierarchical-menu/connectHierarchicalMenu.js +28 -16
- package/cjs/connectors/hits/connectHits.js +2 -2
- package/cjs/connectors/hits/connectHitsWithInsights.js +1 -1
- package/cjs/connectors/hits-per-page/connectHitsPerPage.js +7 -7
- package/cjs/connectors/index.js +8 -1
- package/cjs/connectors/index.umd.js +239 -0
- package/cjs/connectors/infinite-hits/connectInfiniteHits.js +11 -11
- package/cjs/connectors/infinite-hits/connectInfiniteHitsWithInsights.js +1 -1
- package/cjs/connectors/looking-similar/connectLookingSimilar.js +3 -3
- package/cjs/connectors/menu/connectMenu.js +8 -8
- package/cjs/connectors/numeric-menu/connectNumericMenu.js +7 -7
- package/cjs/connectors/pagination/Paginator.js +5 -5
- package/cjs/connectors/pagination/connectPagination.js +3 -3
- package/cjs/connectors/powered-by/connectPoweredBy.js +2 -2
- package/cjs/connectors/query-rules/connectQueryRules.js +7 -7
- package/cjs/connectors/range/connectRange.js +22 -22
- package/cjs/connectors/rating-menu/connectRatingMenu.js +9 -9
- package/cjs/connectors/refinement-list/connectRefinementList.js +4 -4
- package/cjs/connectors/related-products/connectRelatedProducts.js +3 -3
- package/cjs/connectors/relevant-sort/connectRelevantSort.js +2 -2
- package/cjs/connectors/search-box/connectSearchBox.js +2 -2
- package/cjs/connectors/sort-by/connectSortBy.js +2 -2
- package/cjs/connectors/stats/connectStats.js +2 -2
- package/cjs/connectors/toggle-refinement/connectToggleRefinement.js +10 -10
- package/cjs/connectors/trending-items/connectTrendingItems.js +3 -3
- package/cjs/connectors/voice-search/connectVoiceSearch.js +3 -3
- package/cjs/helpers/components/Highlight.js +3 -3
- package/cjs/helpers/components/ReverseHighlight.js +5 -5
- package/cjs/helpers/components/ReverseSnippet.js +5 -5
- package/cjs/helpers/components/Snippet.js +3 -3
- package/cjs/helpers/index.js +2 -3
- package/cjs/index.js +4 -5
- package/cjs/lib/InstantSearch.js +13 -13
- package/cjs/lib/chat/chat.js +177 -0
- package/cjs/lib/chat/index.js +27 -0
- package/cjs/lib/createHelpers.js +2 -2
- package/cjs/lib/infiniteHitsCache/index.js +1 -1
- package/cjs/lib/infiniteHitsCache/sessionStorage.js +2 -2
- package/cjs/lib/insights/client.js +2 -2
- package/cjs/lib/insights/index.js +2 -3
- package/cjs/lib/routers/history.js +8 -8
- package/cjs/lib/routers/index.js +1 -1
- package/cjs/lib/server.js +2 -2
- package/cjs/lib/stateMappings/index.js +1 -1
- package/cjs/lib/stateMappings/simple.js +4 -4
- package/cjs/lib/stateMappings/singleIndex.js +4 -4
- package/cjs/lib/templating/prepareTemplateProps.js +7 -7
- package/cjs/lib/templating/renderTemplate.js +3 -3
- package/cjs/lib/useStickToBottom.js +20 -0
- package/cjs/lib/utils/checkIndexUiState.js +14 -14
- package/cjs/lib/utils/createSendEventForFacet.js +6 -6
- package/cjs/lib/utils/createSendEventForHits.js +6 -6
- package/cjs/lib/utils/escape-highlight.js +4 -4
- package/cjs/lib/utils/geo-search.js +4 -4
- package/cjs/lib/utils/hits-absolute-position.js +2 -2
- package/cjs/lib/utils/hits-query-id.js +2 -2
- package/cjs/lib/utils/hydrateRecommendCache.js +2 -2
- package/cjs/lib/utils/hydrateSearchClient.js +6 -6
- package/cjs/lib/utils/mergeSearchParameters.js +4 -4
- package/cjs/lib/utils/range.js +5 -5
- package/cjs/lib/utils/reverseHighlightedParts.js +2 -2
- package/cjs/lib/version.js +1 -1
- package/cjs/lib/voiceSearchHelper/index.js +2 -2
- package/cjs/middlewares/createInsightsMiddleware.js +13 -13
- package/cjs/middlewares/createRouterMiddleware.js +3 -3
- package/cjs/templates/carousel/carousel.js +34 -7
- package/cjs/widgets/analytics/analytics.js +2 -2
- package/cjs/widgets/answers/answers.js +3 -3
- package/cjs/widgets/autocomplete/autocomplete.js +281 -0
- package/cjs/widgets/breadcrumb/breadcrumb.js +3 -3
- package/cjs/widgets/chat/chat.js +612 -0
- package/cjs/widgets/clear-refinements/clear-refinements.js +3 -3
- package/cjs/widgets/configure/configure.js +3 -3
- package/cjs/widgets/configure-related-items/configure-related-items.js +3 -3
- package/cjs/widgets/current-refinements/current-refinements.js +3 -3
- package/cjs/widgets/dynamic-widgets/dynamic-widgets.js +5 -5
- package/cjs/widgets/frequently-bought-together/frequently-bought-together.js +8 -6
- package/cjs/widgets/geo-search/GeoSearchRenderer.js +7 -7
- package/cjs/widgets/geo-search/createHTMLMarker.js +12 -12
- package/cjs/widgets/geo-search/geo-search.js +5 -5
- package/cjs/widgets/hierarchical-menu/hierarchical-menu.js +3 -3
- package/cjs/widgets/hits/hits.js +7 -7
- package/cjs/widgets/hits-per-page/hits-per-page.js +3 -3
- package/cjs/widgets/index/index.js +18 -11
- package/cjs/widgets/index.js +17 -2
- package/cjs/widgets/index.umd.js +275 -0
- package/cjs/widgets/infinite-hits/infinite-hits.js +3 -3
- package/cjs/widgets/looking-similar/looking-similar.js +6 -6
- package/cjs/widgets/menu/menu.js +3 -3
- package/cjs/widgets/menu-select/menu-select.js +3 -3
- package/cjs/widgets/numeric-menu/numeric-menu.js +3 -3
- package/cjs/widgets/pagination/pagination.js +3 -3
- package/cjs/widgets/panel/panel.js +3 -3
- package/cjs/widgets/places/places.js +4 -4
- package/cjs/widgets/powered-by/powered-by.js +3 -3
- package/cjs/widgets/query-rule-context/query-rule-context.js +3 -3
- package/cjs/widgets/query-rule-custom-data/query-rule-custom-data.js +3 -3
- package/cjs/widgets/range-input/range-input.js +7 -7
- package/cjs/widgets/range-slider/range-slider.js +7 -7
- package/cjs/widgets/rating-menu/rating-menu.js +3 -3
- package/cjs/widgets/refinement-list/refinement-list.js +3 -3
- package/cjs/widgets/related-products/related-products.js +6 -6
- package/cjs/widgets/relevant-sort/relevant-sort.js +3 -3
- package/cjs/widgets/search-box/search-box.js +3 -3
- package/cjs/widgets/sort-by/sort-by.js +3 -3
- package/cjs/widgets/stats/stats.js +3 -3
- package/cjs/widgets/toggle-refinement/toggle-refinement.js +3 -3
- package/cjs/widgets/trending-items/trending-items.js +6 -6
- package/cjs/widgets/voice-search/voice-search.js +3 -3
- package/dist/instantsearch.development.d.ts +165 -14
- package/dist/instantsearch.development.js +1456 -680
- package/dist/instantsearch.development.js.map +1 -1
- package/dist/instantsearch.production.d.ts +165 -14
- package/dist/instantsearch.production.min.d.ts +165 -14
- package/dist/instantsearch.production.min.js +2 -2
- package/dist/instantsearch.production.min.js.map +1 -1
- package/es/components/Answers/Answers.js +3 -3
- package/es/components/Breadcrumb/Breadcrumb.js +1 -1
- package/es/components/ClearRefinements/ClearRefinements.js +1 -1
- package/es/components/GeoSearchControls/GeoSearchControls.js +1 -1
- package/es/components/Highlight/Highlight.js +3 -3
- package/es/components/InfiniteHits/InfiniteHits.js +3 -3
- package/es/components/MenuSelect/MenuSelect.js +1 -1
- package/es/components/Panel/Panel.js +4 -4
- package/es/components/RangeInput/RangeInput.js +13 -13
- package/es/components/RefinementList/RefinementList.js +15 -15
- package/es/components/RefinementList/RefinementListItem.js +1 -1
- package/es/components/ReverseHighlight/ReverseHighlight.js +3 -3
- package/es/components/ReverseSnippet/ReverseSnippet.js +3 -3
- package/es/components/SearchBox/SearchBox.d.ts +4 -0
- package/es/components/SearchBox/SearchBox.js +30 -18
- package/es/components/Slider/Pit.js +2 -2
- package/es/components/Slider/Rheostat.js +13 -13
- package/es/components/Slider/Slider.js +18 -18
- package/es/components/Snippet/Snippet.js +3 -3
- package/es/components/Stats/Stats.js +5 -5
- package/es/components/Template/Template.js +18 -18
- package/es/components/ToggleRefinement/ToggleRefinement.js +1 -1
- package/es/connectors/answers/connectAnswers.js +2 -2
- package/es/connectors/autocomplete/connectAutocomplete.js +2 -2
- package/es/connectors/breadcrumb/connectBreadcrumb.js +6 -6
- package/es/connectors/chat/connectChat.d.ts +433 -0
- package/es/connectors/chat/connectChat.js +215 -0
- package/es/connectors/clear-refinements/connectClearRefinements.js +7 -7
- package/es/connectors/configure/connectConfigure.js +2 -2
- package/es/connectors/configure-related-items/connectConfigureRelatedItems.js +7 -7
- package/es/connectors/current-refinements/connectCurrentRefinements.js +7 -7
- package/es/connectors/dynamic-widgets/connectDynamicWidgets.js +2 -2
- package/es/connectors/frequently-bought-together/connectFrequentlyBoughtTogether.d.ts +6 -0
- package/es/connectors/frequently-bought-together/connectFrequentlyBoughtTogether.js +6 -3
- package/es/connectors/geo-search/connectGeoSearch.d.ts +1 -0
- package/es/connectors/geo-search/connectGeoSearch.js +2 -2
- package/es/connectors/hierarchical-menu/connectHierarchicalMenu.js +28 -16
- package/es/connectors/hits/connectHits.d.ts +1 -0
- package/es/connectors/hits/connectHits.js +2 -2
- package/es/connectors/hits/connectHitsWithInsights.d.ts +1 -0
- package/es/connectors/hits-per-page/connectHitsPerPage.js +7 -7
- package/es/connectors/index.d.ts +1 -0
- package/es/connectors/index.js +2 -1
- package/es/connectors/index.umd.d.ts +39 -0
- package/es/connectors/index.umd.js +47 -0
- package/es/connectors/infinite-hits/connectInfiniteHits.d.ts +1 -0
- package/es/connectors/infinite-hits/connectInfiniteHits.js +11 -11
- package/es/connectors/infinite-hits/connectInfiniteHitsWithInsights.d.ts +1 -0
- package/es/connectors/looking-similar/connectLookingSimilar.d.ts +2 -0
- package/es/connectors/looking-similar/connectLookingSimilar.js +3 -3
- package/es/connectors/menu/connectMenu.js +8 -8
- package/es/connectors/numeric-menu/connectNumericMenu.js +7 -7
- package/es/connectors/pagination/Paginator.js +5 -5
- package/es/connectors/pagination/connectPagination.js +2 -2
- package/es/connectors/powered-by/connectPoweredBy.js +2 -2
- package/es/connectors/query-rules/connectQueryRules.js +7 -7
- package/es/connectors/range/connectRange.js +22 -22
- package/es/connectors/rating-menu/connectRatingMenu.js +9 -9
- package/es/connectors/refinement-list/connectRefinementList.js +4 -4
- package/es/connectors/related-products/connectRelatedProducts.d.ts +2 -0
- package/es/connectors/related-products/connectRelatedProducts.js +3 -3
- package/es/connectors/relevant-sort/connectRelevantSort.js +2 -2
- package/es/connectors/search-box/connectSearchBox.js +2 -2
- package/es/connectors/sort-by/connectSortBy.js +2 -2
- package/es/connectors/stats/connectStats.js +2 -2
- package/es/connectors/toggle-refinement/connectToggleRefinement.js +10 -10
- package/es/connectors/trending-items/connectTrendingItems.d.ts +2 -0
- package/es/connectors/trending-items/connectTrendingItems.js +3 -3
- package/es/connectors/voice-search/connectVoiceSearch.js +2 -2
- package/es/helpers/components/Highlight.js +3 -3
- package/es/helpers/components/ReverseHighlight.js +5 -5
- package/es/helpers/components/ReverseSnippet.js +5 -5
- package/es/helpers/components/Snippet.js +3 -3
- package/es/lib/InstantSearch.d.ts +1 -1
- package/es/lib/InstantSearch.js +12 -12
- package/es/lib/chat/chat.d.ts +40 -0
- package/es/lib/chat/chat.js +166 -0
- package/es/lib/chat/index.d.ts +7 -0
- package/es/lib/chat/index.js +5 -0
- package/es/lib/createHelpers.js +2 -2
- package/es/lib/infiniteHitsCache/sessionStorage.js +2 -2
- package/es/lib/insights/client.js +2 -2
- package/es/lib/routers/history.js +7 -7
- package/es/lib/server.js +2 -2
- package/es/lib/stateMappings/simple.js +4 -4
- package/es/lib/stateMappings/singleIndex.js +4 -4
- package/es/lib/templating/prepareTemplateProps.js +7 -7
- package/es/lib/templating/renderTemplate.js +2 -2
- package/es/lib/useStickToBottom.d.ts +1 -0
- package/es/lib/useStickToBottom.js +14 -0
- package/es/lib/utils/checkIndexUiState.js +14 -14
- package/es/lib/utils/createSendEventForFacet.js +6 -6
- package/es/lib/utils/createSendEventForHits.js +6 -6
- package/es/lib/utils/escape-highlight.js +4 -4
- package/es/lib/utils/geo-search.js +4 -4
- package/es/lib/utils/hits-absolute-position.js +2 -2
- package/es/lib/utils/hits-query-id.js +2 -2
- package/es/lib/utils/hydrateRecommendCache.js +2 -2
- package/es/lib/utils/hydrateSearchClient.js +6 -6
- package/es/lib/utils/mergeSearchParameters.js +4 -4
- package/es/lib/utils/range.js +5 -5
- package/es/lib/utils/reverseHighlightedParts.js +2 -2
- package/es/lib/version.d.ts +1 -1
- package/es/lib/version.js +1 -1
- package/es/lib/voiceSearchHelper/index.js +2 -2
- package/es/middlewares/createInsightsMiddleware.js +13 -13
- package/es/middlewares/createRouterMiddleware.js +2 -2
- package/es/templates/carousel/carousel.d.ts +10 -3
- package/es/templates/carousel/carousel.js +35 -8
- package/es/types/render-state.d.ts +2 -1
- package/es/types/templates.d.ts +1 -1
- package/es/types/widget.d.ts +10 -3
- package/es/widgets/analytics/analytics.js +2 -2
- package/es/widgets/answers/answers.js +2 -2
- package/es/widgets/autocomplete/autocomplete.d.ts +57 -0
- package/es/widgets/autocomplete/autocomplete.js +274 -0
- package/es/widgets/breadcrumb/breadcrumb.js +2 -2
- package/es/widgets/chat/chat.d.ts +559 -0
- package/es/widgets/chat/chat.js +594 -0
- package/es/widgets/clear-refinements/clear-refinements.js +2 -2
- package/es/widgets/configure/configure.js +2 -2
- package/es/widgets/configure-related-items/configure-related-items.js +2 -2
- package/es/widgets/current-refinements/current-refinements.js +2 -2
- package/es/widgets/dynamic-widgets/dynamic-widgets.js +4 -4
- package/es/widgets/frequently-bought-together/frequently-bought-together.d.ts +3 -1
- package/es/widgets/frequently-bought-together/frequently-bought-together.js +7 -5
- package/es/widgets/geo-search/GeoSearchRenderer.js +6 -6
- package/es/widgets/geo-search/createHTMLMarker.js +12 -12
- package/es/widgets/geo-search/geo-search.d.ts +1 -0
- package/es/widgets/geo-search/geo-search.js +4 -4
- package/es/widgets/hierarchical-menu/hierarchical-menu.js +2 -2
- package/es/widgets/hits/hits.d.ts +1 -0
- package/es/widgets/hits/hits.js +6 -6
- package/es/widgets/hits-per-page/hits-per-page.js +2 -2
- package/es/widgets/index/index.d.ts +1 -1
- package/es/widgets/index/index.js +17 -10
- package/es/widgets/index.d.ts +2 -0
- package/es/widgets/index.js +3 -1
- package/es/widgets/index.umd.d.ts +45 -0
- package/es/widgets/index.umd.js +52 -0
- package/es/widgets/infinite-hits/infinite-hits.d.ts +1 -0
- package/es/widgets/infinite-hits/infinite-hits.js +2 -2
- package/es/widgets/looking-similar/looking-similar.d.ts +3 -1
- package/es/widgets/looking-similar/looking-similar.js +5 -5
- package/es/widgets/menu/menu.js +2 -2
- package/es/widgets/menu-select/menu-select.js +2 -2
- package/es/widgets/numeric-menu/numeric-menu.js +2 -2
- package/es/widgets/pagination/pagination.js +2 -2
- package/es/widgets/panel/panel.js +2 -2
- package/es/widgets/places/places.js +4 -4
- package/es/widgets/powered-by/powered-by.js +2 -2
- package/es/widgets/query-rule-context/query-rule-context.js +2 -2
- package/es/widgets/query-rule-custom-data/query-rule-custom-data.js +2 -2
- package/es/widgets/range-input/range-input.js +6 -6
- package/es/widgets/range-slider/range-slider.js +6 -6
- package/es/widgets/rating-menu/rating-menu.js +2 -2
- package/es/widgets/refinement-list/refinement-list.js +2 -2
- package/es/widgets/related-products/related-products.d.ts +3 -1
- package/es/widgets/related-products/related-products.js +5 -5
- package/es/widgets/relevant-sort/relevant-sort.js +2 -2
- package/es/widgets/search-box/search-box.js +2 -2
- package/es/widgets/sort-by/sort-by.js +2 -2
- package/es/widgets/stats/stats.js +2 -2
- package/es/widgets/toggle-refinement/toggle-refinement.js +2 -2
- package/es/widgets/trending-items/trending-items.d.ts +3 -1
- package/es/widgets/trending-items/trending-items.js +5 -5
- package/es/widgets/voice-search/voice-search.js +2 -2
- package/package.json +11 -7
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
2
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
3
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
-
function _defineProperty(
|
|
5
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i :
|
|
4
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
6
6
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
7
|
import historyRouter from "../lib/routers/history.js";
|
|
8
8
|
import simpleStateMapping from "../lib/stateMappings/simple.js";
|
|
@@ -2,15 +2,22 @@
|
|
|
2
2
|
import { html } from 'htm/preact';
|
|
3
3
|
import { h } from 'preact';
|
|
4
4
|
import type { CarouselProps as CarouselUiProps, VNode } from 'instantsearch-ui-components';
|
|
5
|
-
type Template = (params: {
|
|
5
|
+
type Template<TData = Record<string, unknown>> = (params: {
|
|
6
6
|
html: typeof html;
|
|
7
|
-
}) => VNode | VNode[] | null;
|
|
7
|
+
} & TData) => VNode | VNode[] | null;
|
|
8
8
|
type CreateCarouselTemplateProps<TObject extends Record<string, unknown>> = {
|
|
9
9
|
templates?: Partial<{
|
|
10
10
|
previous: Exclude<Template, string>;
|
|
11
11
|
next: Exclude<Template, string>;
|
|
12
|
+
header: Exclude<Template<{
|
|
13
|
+
canScrollLeft: boolean;
|
|
14
|
+
canScrollRight: boolean;
|
|
15
|
+
scrollLeft: () => void;
|
|
16
|
+
scrollRight: () => void;
|
|
17
|
+
}>, string>;
|
|
12
18
|
}>;
|
|
13
19
|
cssClasses?: Partial<CarouselUiProps<TObject>['classNames']>;
|
|
20
|
+
showNavigation?: boolean;
|
|
14
21
|
};
|
|
15
22
|
type CarouselTemplateProps<TObject extends Record<string, unknown>> = Pick<CarouselUiProps<TObject>, 'items'> & {
|
|
16
23
|
templates: {
|
|
@@ -20,5 +27,5 @@ type CarouselTemplateProps<TObject extends Record<string, unknown>> = Pick<Carou
|
|
|
20
27
|
} & {
|
|
21
28
|
sendEvent?: CarouselUiProps<TObject>['sendEvent'];
|
|
22
29
|
};
|
|
23
|
-
export declare function carousel<TObject extends Record<string, unknown>>({ cssClasses, templates, }?: CreateCarouselTemplateProps<TObject>): ({ items, templates: widgetTemplates, cssClasses: widgetCssClasses, sendEvent, }: CarouselTemplateProps<TObject>) => h.JSX.Element;
|
|
30
|
+
export declare function carousel<TObject extends Record<string, unknown>>({ cssClasses, templates, showNavigation, }?: CreateCarouselTemplateProps<TObject>): ({ items, templates: widgetTemplates, cssClasses: widgetCssClasses, sendEvent, }: CarouselTemplateProps<TObject>) => h.JSX.Element;
|
|
24
31
|
export {};
|
|
@@ -1,24 +1,42 @@
|
|
|
1
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
2
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
3
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
-
function _defineProperty(
|
|
5
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i :
|
|
4
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
6
6
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
|
-
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (
|
|
7
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
8
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
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."); }
|
|
10
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
11
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
12
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
13
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
8
14
|
import { html } from 'htm/preact';
|
|
9
15
|
import { createCarouselComponent, cx, generateCarouselId } from 'instantsearch-ui-components';
|
|
10
16
|
import { Fragment, h } from 'preact';
|
|
11
|
-
import { useRef } from 'preact/hooks';
|
|
17
|
+
import { useRef, useState } from 'preact/hooks';
|
|
12
18
|
var Carousel = createCarouselComponent({
|
|
13
19
|
createElement: h,
|
|
14
20
|
Fragment: Fragment
|
|
15
21
|
});
|
|
16
22
|
function CarouselWithRefs(props) {
|
|
23
|
+
var _useState = useState(false),
|
|
24
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
25
|
+
canScrollLeft = _useState2[0],
|
|
26
|
+
setCanScrollLeft = _useState2[1];
|
|
27
|
+
var _useState3 = useState(true),
|
|
28
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
29
|
+
canScrollRight = _useState4[0],
|
|
30
|
+
setCanScrollRight = _useState4[1];
|
|
17
31
|
var carouselRefs = {
|
|
18
32
|
listRef: useRef(null),
|
|
19
33
|
nextButtonRef: useRef(null),
|
|
20
34
|
previousButtonRef: useRef(null),
|
|
21
|
-
carouselIdRef: useRef(generateCarouselId())
|
|
35
|
+
carouselIdRef: useRef(generateCarouselId()),
|
|
36
|
+
canScrollLeft: canScrollLeft,
|
|
37
|
+
canScrollRight: canScrollRight,
|
|
38
|
+
setCanScrollLeft: setCanScrollLeft,
|
|
39
|
+
setCanScrollRight: setCanScrollRight
|
|
22
40
|
};
|
|
23
41
|
return h(Carousel, _extends({}, carouselRefs, props));
|
|
24
42
|
}
|
|
@@ -26,7 +44,9 @@ export function carousel() {
|
|
|
26
44
|
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
27
45
|
cssClasses = _ref.cssClasses,
|
|
28
46
|
_ref$templates = _ref.templates,
|
|
29
|
-
templates = _ref$templates === void 0 ? {} : _ref$templates
|
|
47
|
+
templates = _ref$templates === void 0 ? {} : _ref$templates,
|
|
48
|
+
_ref$showNavigation = _ref.showNavigation,
|
|
49
|
+
showNavigation = _ref$showNavigation === void 0 ? true : _ref$showNavigation;
|
|
30
50
|
return function CarouselTemplate(_ref2) {
|
|
31
51
|
var items = _ref2.items,
|
|
32
52
|
widgetTemplates = _ref2.templates,
|
|
@@ -35,11 +55,17 @@ export function carousel() {
|
|
|
35
55
|
_ref2$sendEvent = _ref2.sendEvent,
|
|
36
56
|
sendEvent = _ref2$sendEvent === void 0 ? function () {} : _ref2$sendEvent;
|
|
37
57
|
var previous = templates.previous,
|
|
38
|
-
next = templates.next
|
|
58
|
+
next = templates.next,
|
|
59
|
+
header = templates.header;
|
|
39
60
|
return h(CarouselWithRefs, {
|
|
40
61
|
items: items,
|
|
41
62
|
sendEvent: sendEvent,
|
|
42
63
|
itemComponent: widgetTemplates.item,
|
|
64
|
+
headerComponent: header ? function (props) {
|
|
65
|
+
return header(_objectSpread({
|
|
66
|
+
html: html
|
|
67
|
+
}, props));
|
|
68
|
+
} : undefined,
|
|
43
69
|
previousIconComponent: previous ? function () {
|
|
44
70
|
return previous({
|
|
45
71
|
html: html
|
|
@@ -53,7 +79,8 @@ export function carousel() {
|
|
|
53
79
|
classNames: _objectSpread(_objectSpread({}, cssClasses), {
|
|
54
80
|
list: cx(cssClasses === null || cssClasses === void 0 ? void 0 : cssClasses.list, widgetCssClasses === null || widgetCssClasses === void 0 ? void 0 : widgetCssClasses.list),
|
|
55
81
|
item: cx(cssClasses === null || cssClasses === void 0 ? void 0 : cssClasses.item, widgetCssClasses === null || widgetCssClasses === void 0 ? void 0 : widgetCssClasses.item)
|
|
56
|
-
})
|
|
82
|
+
}),
|
|
83
|
+
showNavigation: showNavigation
|
|
57
84
|
});
|
|
58
85
|
};
|
|
59
86
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { AnswersWidgetDescription } from '../connectors/answers/connectAnswers';
|
|
2
2
|
import type { AutocompleteWidgetDescription } from '../connectors/autocomplete/connectAutocomplete';
|
|
3
3
|
import type { BreadcrumbWidgetDescription } from '../connectors/breadcrumb/connectBreadcrumb';
|
|
4
|
+
import type { ChatWidgetDescription } from '../connectors/chat/connectChat';
|
|
4
5
|
import type { ClearRefinementsWidgetDescription } from '../connectors/clear-refinements/connectClearRefinements';
|
|
5
6
|
import type { ConfigureWidgetDescription } from '../connectors/configure/connectConfigure';
|
|
6
7
|
import type { CurrentRefinementsWidgetDescription } from '../connectors/current-refinements/connectCurrentRefinements';
|
|
@@ -25,7 +26,7 @@ import type { ToggleRefinementWidgetDescription } from '../connectors/toggle-ref
|
|
|
25
26
|
import type { VoiceSearchWidgetDescription } from '../connectors/voice-search/connectVoiceSearch';
|
|
26
27
|
import type { AnalyticsWidgetDescription } from '../widgets/analytics/analytics';
|
|
27
28
|
import type { PlacesWidgetDescription } from '../widgets/places/places';
|
|
28
|
-
type ConnectorRenderStates = AnswersWidgetDescription['indexRenderState'] & AutocompleteWidgetDescription['indexRenderState'] & BreadcrumbWidgetDescription['indexRenderState'] & ClearRefinementsWidgetDescription['indexRenderState'] & ConfigureWidgetDescription['indexRenderState'] & CurrentRefinementsWidgetDescription['indexRenderState'] & GeoSearchWidgetDescription['indexRenderState'] & HierarchicalMenuWidgetDescription['indexRenderState'] & HitsWidgetDescription['indexRenderState'] & HitsPerPageWidgetDescription['indexRenderState'] & InfiniteHitsWidgetDescription['indexRenderState'] & MenuWidgetDescription['indexRenderState'] & NumericMenuWidgetDescription['indexRenderState'] & PaginationWidgetDescription['indexRenderState'] & PoweredByWidgetDescription['indexRenderState'] & QueryRulesWidgetDescription['indexRenderState'] & RangeWidgetDescription['indexRenderState'] & RatingMenuWidgetDescription['indexRenderState'] & RefinementListWidgetDescription['indexRenderState'] & RelevantSortWidgetDescription['indexRenderState'] & SearchBoxWidgetDescription['indexRenderState'] & SortByWidgetDescription['indexRenderState'] & StatsWidgetDescription['indexRenderState'] & ToggleRefinementWidgetDescription['indexRenderState'] & VoiceSearchWidgetDescription['indexRenderState'];
|
|
29
|
+
type ConnectorRenderStates = AnswersWidgetDescription['indexRenderState'] & AutocompleteWidgetDescription['indexRenderState'] & BreadcrumbWidgetDescription['indexRenderState'] & ChatWidgetDescription['indexRenderState'] & ClearRefinementsWidgetDescription['indexRenderState'] & ConfigureWidgetDescription['indexRenderState'] & CurrentRefinementsWidgetDescription['indexRenderState'] & GeoSearchWidgetDescription['indexRenderState'] & HierarchicalMenuWidgetDescription['indexRenderState'] & HitsWidgetDescription['indexRenderState'] & HitsPerPageWidgetDescription['indexRenderState'] & InfiniteHitsWidgetDescription['indexRenderState'] & MenuWidgetDescription['indexRenderState'] & NumericMenuWidgetDescription['indexRenderState'] & PaginationWidgetDescription['indexRenderState'] & PoweredByWidgetDescription['indexRenderState'] & QueryRulesWidgetDescription['indexRenderState'] & RangeWidgetDescription['indexRenderState'] & RatingMenuWidgetDescription['indexRenderState'] & RefinementListWidgetDescription['indexRenderState'] & RelevantSortWidgetDescription['indexRenderState'] & SearchBoxWidgetDescription['indexRenderState'] & SortByWidgetDescription['indexRenderState'] & StatsWidgetDescription['indexRenderState'] & ToggleRefinementWidgetDescription['indexRenderState'] & VoiceSearchWidgetDescription['indexRenderState'];
|
|
29
30
|
type WidgetRenderStates = AnalyticsWidgetDescription['indexRenderState'] & PlacesWidgetDescription['indexRenderState'];
|
|
30
31
|
export type IndexRenderState = Partial<ConnectorRenderStates & WidgetRenderStates>;
|
|
31
32
|
export type RenderState = {
|
package/es/types/templates.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ interface TemplateWithBindEventParams extends TemplateParams {
|
|
|
22
22
|
}
|
|
23
23
|
export type TemplateWithBindEvent<TTemplateData = void> = string | ((data: TTemplateData, params: TemplateWithBindEventParams) => VNode | VNode[] | string);
|
|
24
24
|
export type Templates = {
|
|
25
|
-
[key: string]: Template<any> | TemplateWithBindEvent<any> | undefined;
|
|
25
|
+
[key: string]: Template<any> | TemplateWithBindEvent<any> | Templates | undefined;
|
|
26
26
|
};
|
|
27
27
|
export type HoganHelpers<TKeys extends string = string> = Record<TKeys, (text: string, render: (value: string) => string) => string>;
|
|
28
28
|
export {};
|
package/es/types/widget.d.ts
CHANGED
|
@@ -43,8 +43,8 @@ export type DisposeOptions = {
|
|
|
43
43
|
recommendState: RecommendParameters;
|
|
44
44
|
parent: IndexWidget;
|
|
45
45
|
};
|
|
46
|
-
export type BuiltinTypes = 'ais.analytics' | 'ais.answers' | 'ais.autocomplete' | 'ais.breadcrumb' | 'ais.clearRefinements' | 'ais.configure' | 'ais.configureRelatedItems' | 'ais.currentRefinements' | 'ais.dynamicWidgets' | 'ais.frequentlyBoughtTogether' | 'ais.geoSearch' | 'ais.hierarchicalMenu' | 'ais.hits' | 'ais.hitsPerPage' | 'ais.index' | 'ais.infiniteHits' | 'ais.lookingSimilar' | 'ais.menu' | 'ais.numericMenu' | 'ais.pagination' | 'ais.places' | 'ais.poweredBy' | 'ais.queryRules' | 'ais.range' | 'ais.rangeSlider' | 'ais.rangeInput' | 'ais.ratingMenu' | 'ais.refinementList' | 'ais.relatedProducts' | 'ais.searchBox' | 'ais.relevantSort' | 'ais.sortBy' | 'ais.stats' | 'ais.toggleRefinement' | 'ais.trendingItems' | 'ais.voiceSearch';
|
|
47
|
-
export type BuiltinWidgetTypes = 'ais.analytics' | 'ais.answers' | 'ais.autocomplete' | 'ais.breadcrumb' | 'ais.clearRefinements' | 'ais.configure' | 'ais.configureRelatedItems' | 'ais.currentRefinements' | 'ais.dynamicWidgets' | 'ais.frequentlyBoughtTogether' | 'ais.geoSearch' | 'ais.hierarchicalMenu' | 'ais.hits' | 'ais.hitsPerPage' | 'ais.index' | 'ais.infiniteHits' | 'ais.lookingSimilar' | 'ais.menu' | 'ais.menuSelect' | 'ais.numericMenu' | 'ais.pagination' | 'ais.places' | 'ais.poweredBy' | 'ais.queryRuleCustomData' | 'ais.queryRuleContext' | 'ais.rangeInput' | 'ais.rangeSlider' | 'ais.ratingMenu' | 'ais.refinementList' | 'ais.relatedProducts' | 'ais.searchBox' | 'ais.relevantSort' | 'ais.sortBy' | 'ais.stats' | 'ais.toggleRefinement' | 'ais.trendingItems' | 'ais.voiceSearch';
|
|
46
|
+
export type BuiltinTypes = 'ais.analytics' | 'ais.answers' | 'ais.autocomplete' | 'ais.breadcrumb' | 'ais.clearRefinements' | 'ais.chat' | 'ais.configure' | 'ais.configureRelatedItems' | 'ais.currentRefinements' | 'ais.dynamicWidgets' | 'ais.frequentlyBoughtTogether' | 'ais.geoSearch' | 'ais.hierarchicalMenu' | 'ais.hits' | 'ais.hitsPerPage' | 'ais.index' | 'ais.infiniteHits' | 'ais.lookingSimilar' | 'ais.menu' | 'ais.numericMenu' | 'ais.pagination' | 'ais.places' | 'ais.poweredBy' | 'ais.queryRules' | 'ais.range' | 'ais.rangeSlider' | 'ais.rangeInput' | 'ais.ratingMenu' | 'ais.refinementList' | 'ais.relatedProducts' | 'ais.searchBox' | 'ais.relevantSort' | 'ais.sortBy' | 'ais.stats' | 'ais.toggleRefinement' | 'ais.trendingItems' | 'ais.voiceSearch';
|
|
47
|
+
export type BuiltinWidgetTypes = 'ais.analytics' | 'ais.answers' | 'ais.autocomplete' | 'ais.breadcrumb' | 'ais.chat' | 'ais.clearRefinements' | 'ais.configure' | 'ais.configureRelatedItems' | 'ais.currentRefinements' | 'ais.dynamicWidgets' | 'ais.frequentlyBoughtTogether' | 'ais.geoSearch' | 'ais.hierarchicalMenu' | 'ais.hits' | 'ais.hitsPerPage' | 'ais.index' | 'ais.infiniteHits' | 'ais.lookingSimilar' | 'ais.menu' | 'ais.menuSelect' | 'ais.numericMenu' | 'ais.pagination' | 'ais.places' | 'ais.poweredBy' | 'ais.queryRuleCustomData' | 'ais.queryRuleContext' | 'ais.rangeInput' | 'ais.rangeSlider' | 'ais.ratingMenu' | 'ais.refinementList' | 'ais.relatedProducts' | 'ais.searchBox' | 'ais.relevantSort' | 'ais.sortBy' | 'ais.stats' | 'ais.toggleRefinement' | 'ais.trendingItems' | 'ais.voiceSearch';
|
|
48
48
|
export type UnknownWidgetParams = NonNullable<object>;
|
|
49
49
|
export type WidgetParams = {
|
|
50
50
|
widgetParams?: UnknownWidgetParams;
|
|
@@ -74,6 +74,13 @@ type RecommendWidget<TWidgetDescription extends WidgetDescription & WidgetParams
|
|
|
74
74
|
getRenderState: (renderState: Expand<IndexRenderState & Partial<TWidgetDescription['indexRenderState']>>, renderOptions: InitOptions | RecommendRenderOptions) => IndexRenderState & TWidgetDescription['indexRenderState'];
|
|
75
75
|
getWidgetRenderState: (renderOptions: InitOptions | RecommendRenderOptions) => Expand<WidgetRenderState<TWidgetDescription['renderState'], TWidgetDescription['widgetParams']>>;
|
|
76
76
|
};
|
|
77
|
+
type Parent = {
|
|
78
|
+
/**
|
|
79
|
+
* This gets dynamically added by the `index` widget.
|
|
80
|
+
* If the widget has gone through `addWidget`, it will have a parent.
|
|
81
|
+
*/
|
|
82
|
+
parent?: IndexWidget;
|
|
83
|
+
};
|
|
77
84
|
type RequiredWidgetLifeCycle<TWidgetDescription extends WidgetDescription> = {
|
|
78
85
|
/**
|
|
79
86
|
* Identifier for connectors and widgets.
|
|
@@ -159,7 +166,7 @@ type RequiredRenderStateLifeCycle<TWidgetDescription extends WidgetDescription &
|
|
|
159
166
|
type RenderStateLifeCycle<TWidgetDescription extends WidgetDescription & WidgetParams> = TWidgetDescription extends RequiredKeys<WidgetDescription, 'renderState' | 'indexRenderState'> & WidgetParams ? RequiredRenderStateLifeCycle<TWidgetDescription> : Partial<RequiredRenderStateLifeCycle<TWidgetDescription>>;
|
|
160
167
|
export type Widget<TWidgetDescription extends WidgetDescription & WidgetParams = {
|
|
161
168
|
$$type: string;
|
|
162
|
-
}> = Expand<RequiredWidgetLifeCycle<TWidgetDescription> & WidgetType<TWidgetDescription> & UiStateLifeCycle<TWidgetDescription> & RenderStateLifeCycle<TWidgetDescription>> & (SearchWidget<TWidgetDescription> | RecommendWidget<TWidgetDescription>);
|
|
169
|
+
}> = Expand<Parent & RequiredWidgetLifeCycle<TWidgetDescription> & WidgetType<TWidgetDescription> & UiStateLifeCycle<TWidgetDescription> & RenderStateLifeCycle<TWidgetDescription>> & (SearchWidget<TWidgetDescription> | RecommendWidget<TWidgetDescription>);
|
|
163
170
|
export type { IndexWidget } from '../widgets';
|
|
164
171
|
export type TransformItemsMetadata = {
|
|
165
172
|
results: SearchResults | undefined | null;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
2
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
3
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
-
function _defineProperty(
|
|
5
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i :
|
|
4
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
6
6
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
7
|
import { createDocumentationMessageGenerator, warning } from "../../lib/utils/index.js";
|
|
8
8
|
var withUsage = createDocumentationMessageGenerator({
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
2
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
3
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
-
function _defineProperty(
|
|
5
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i :
|
|
4
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
6
6
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
7
|
import { cx } from 'instantsearch-ui-components';
|
|
8
8
|
import { h, render } from 'preact';
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
|
|
2
|
+
import type { AutocompleteConnectorParams, AutocompleteWidgetDescription } from '../../connectors/autocomplete/connectAutocomplete';
|
|
3
|
+
import type { BaseHit, IndexUiState, IndexWidget, Template, WidgetFactory } from '../../types';
|
|
4
|
+
import type { AutocompleteClassNames, AutocompleteIndexClassNames, AutocompleteIndexConfig } from 'instantsearch-ui-components';
|
|
5
|
+
export type AutocompleteCSSClasses = Partial<AutocompleteClassNames>;
|
|
6
|
+
export type AutocompleteTemplates<TItem extends BaseHit> = Partial<Record<string, TItem>>;
|
|
7
|
+
type IndexConfig<TItem extends BaseHit> = AutocompleteIndexConfig<TItem> & {
|
|
8
|
+
templates?: Partial<{
|
|
9
|
+
/**
|
|
10
|
+
* Template to use for the header, before the list of items.
|
|
11
|
+
*/
|
|
12
|
+
header: Template<{
|
|
13
|
+
items: TItem[];
|
|
14
|
+
}>;
|
|
15
|
+
/**
|
|
16
|
+
* Template to use for each result. This template will receive an object containing a single record.
|
|
17
|
+
*/
|
|
18
|
+
item: Template<{
|
|
19
|
+
item: TItem;
|
|
20
|
+
onSelect: () => void;
|
|
21
|
+
}>;
|
|
22
|
+
}>;
|
|
23
|
+
cssClasses?: Partial<AutocompleteIndexClassNames>;
|
|
24
|
+
};
|
|
25
|
+
type AutocompleteWidgetParams<TItem extends BaseHit> = {
|
|
26
|
+
/**
|
|
27
|
+
* CSS Selector or HTMLElement to insert the widget.
|
|
28
|
+
*/
|
|
29
|
+
container: string | HTMLElement;
|
|
30
|
+
/**
|
|
31
|
+
* Indices to use in the Autocomplete.
|
|
32
|
+
*/
|
|
33
|
+
indices?: Array<IndexConfig<TItem>>;
|
|
34
|
+
/**
|
|
35
|
+
* Index to use for retrieving and showing query suggestions.
|
|
36
|
+
*/
|
|
37
|
+
showSuggestions?: Partial<Pick<IndexConfig<{
|
|
38
|
+
query: string;
|
|
39
|
+
}>, 'indexName' | 'getURL' | 'templates' | 'cssClasses'>>;
|
|
40
|
+
getSearchPageURL?: (nextUiState: IndexUiState) => string;
|
|
41
|
+
onSelect?: AutocompleteIndexConfig<TItem>['onSelect'];
|
|
42
|
+
/**
|
|
43
|
+
* Templates to use for the widget.
|
|
44
|
+
*/
|
|
45
|
+
templates?: AutocompleteTemplates<TItem>;
|
|
46
|
+
/**
|
|
47
|
+
* CSS classes to add.
|
|
48
|
+
*/
|
|
49
|
+
cssClasses?: AutocompleteCSSClasses;
|
|
50
|
+
};
|
|
51
|
+
export type AutocompleteWidget<TItem extends BaseHit = BaseHit> = WidgetFactory<AutocompleteWidgetDescription & {
|
|
52
|
+
$$widgetType: 'ais.autocomplete';
|
|
53
|
+
}, AutocompleteConnectorParams, AutocompleteWidgetParams<TItem>>;
|
|
54
|
+
export declare function EXPERIMENTAL_autocomplete<TItem extends BaseHit = BaseHit>(widgetParams: AutocompleteWidgetParams<TItem> & AutocompleteConnectorParams): (IndexWidget<import("../../types").UiState> | import("../../types").Widget<import("../../connectors/search-box/connectSearchBox").SearchBoxWidgetDescription & {
|
|
55
|
+
widgetParams: import("../../connectors/search-box/connectSearchBox").SearchBoxConnectorParams & object;
|
|
56
|
+
}>)[];
|
|
57
|
+
export {};
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
var _excluded = ["instanceId", "containerNode"];
|
|
3
|
+
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
|
|
4
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
5
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
6
|
+
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
|
7
|
+
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
|
|
8
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
9
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
10
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
11
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
12
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
13
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
14
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
15
|
+
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
16
|
+
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
17
|
+
import { createAutocompleteComponent, createAutocompleteIndexComponent, createAutocompletePanelComponent, createAutocompletePropGetters, createAutocompleteSearchComponent, createAutocompleteSuggestionComponent, cx } from 'instantsearch-ui-components';
|
|
18
|
+
import { Fragment, h, render } from 'preact';
|
|
19
|
+
import { useEffect, useId, useMemo, useRef, useState } from 'preact/hooks';
|
|
20
|
+
import TemplateComponent from "../../components/Template/Template.js";
|
|
21
|
+
import { connectAutocomplete, connectSearchBox } from "../../connectors/index.umd.js";
|
|
22
|
+
import { component } from "../../lib/suit.js";
|
|
23
|
+
import { prepareTemplateProps } from "../../lib/templating/index.js";
|
|
24
|
+
import { createDocumentationMessageGenerator, getContainerNode, walkIndex } from "../../lib/utils/index.js";
|
|
25
|
+
import configure from "../configure/configure.js";
|
|
26
|
+
import index from "../index/index.js";
|
|
27
|
+
var autocompleteInstanceId = 0;
|
|
28
|
+
var withUsage = createDocumentationMessageGenerator({
|
|
29
|
+
name: 'autocomplete'
|
|
30
|
+
});
|
|
31
|
+
var suit = component('Autocomplete');
|
|
32
|
+
var Autocomplete = createAutocompleteComponent({
|
|
33
|
+
createElement: h,
|
|
34
|
+
Fragment: Fragment
|
|
35
|
+
});
|
|
36
|
+
var AutocompletePanel = createAutocompletePanelComponent({
|
|
37
|
+
createElement: h,
|
|
38
|
+
Fragment: Fragment
|
|
39
|
+
});
|
|
40
|
+
var AutocompleteIndex = createAutocompleteIndexComponent({
|
|
41
|
+
createElement: h,
|
|
42
|
+
Fragment: Fragment
|
|
43
|
+
});
|
|
44
|
+
var AutocompleteSuggestion = createAutocompleteSuggestionComponent({
|
|
45
|
+
createElement: h,
|
|
46
|
+
Fragment: Fragment
|
|
47
|
+
});
|
|
48
|
+
var AutocompleteSearchBox = createAutocompleteSearchComponent({
|
|
49
|
+
createElement: h,
|
|
50
|
+
Fragment: Fragment
|
|
51
|
+
});
|
|
52
|
+
var usePropGetters = createAutocompletePropGetters({
|
|
53
|
+
useEffect: useEffect,
|
|
54
|
+
useId: useId,
|
|
55
|
+
useMemo: useMemo,
|
|
56
|
+
useRef: useRef,
|
|
57
|
+
useState: useState
|
|
58
|
+
});
|
|
59
|
+
var createRenderer = function createRenderer(params) {
|
|
60
|
+
var instanceId = params.instanceId,
|
|
61
|
+
containerNode = params.containerNode,
|
|
62
|
+
rendererParams = _objectWithoutProperties(params, _excluded);
|
|
63
|
+
return function (connectorParams, isFirstRendering) {
|
|
64
|
+
if (isFirstRendering) {
|
|
65
|
+
var isolatedIndex = connectorParams.instantSearchInstance.mainIndex;
|
|
66
|
+
var targetIndex = connectorParams.instantSearchInstance.mainIndex;
|
|
67
|
+
walkIndex(targetIndex, function (childIndex) {
|
|
68
|
+
if (childIndex.getIndexId() === "ais-autocomplete-".concat(instanceId)) {
|
|
69
|
+
isolatedIndex = childIndex;
|
|
70
|
+
targetIndex = childIndex.parent;
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
rendererParams.renderState = {
|
|
74
|
+
indexTemplateProps: [],
|
|
75
|
+
isolatedIndex: isolatedIndex,
|
|
76
|
+
targetIndex: targetIndex
|
|
77
|
+
};
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
render(h(AutocompleteWrapper, _extends({}, rendererParams, connectorParams)), containerNode);
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
function AutocompleteWrapper(_ref) {
|
|
84
|
+
var _targetIndex$getWidge, _isolatedIndex$getHel;
|
|
85
|
+
var indicesConfig = _ref.indicesConfig,
|
|
86
|
+
indices = _ref.indices,
|
|
87
|
+
getSearchPageURL = _ref.getSearchPageURL,
|
|
88
|
+
userOnSelect = _ref.onSelect,
|
|
89
|
+
refine = _ref.refine,
|
|
90
|
+
cssClasses = _ref.cssClasses,
|
|
91
|
+
renderState = _ref.renderState,
|
|
92
|
+
instantSearchInstance = _ref.instantSearchInstance;
|
|
93
|
+
var isolatedIndex = renderState.isolatedIndex,
|
|
94
|
+
targetIndex = renderState.targetIndex;
|
|
95
|
+
var isSearchPage = (_targetIndex$getWidge = targetIndex === null || targetIndex === void 0 ? void 0 : targetIndex.getWidgets().some(function (_ref2) {
|
|
96
|
+
var $$type = _ref2.$$type;
|
|
97
|
+
return ['ais.hits', 'ais.infiniteHits'].includes($$type);
|
|
98
|
+
})) !== null && _targetIndex$getWidge !== void 0 ? _targetIndex$getWidge : false;
|
|
99
|
+
var onRefine = function onRefine(query) {
|
|
100
|
+
instantSearchInstance.setUiState(function (uiState) {
|
|
101
|
+
var _objectSpread2;
|
|
102
|
+
return _objectSpread(_objectSpread({}, uiState), {}, (_objectSpread2 = {}, _defineProperty(_objectSpread2, targetIndex.getIndexId(), _objectSpread(_objectSpread({}, uiState[targetIndex.getIndexId()]), {}, {
|
|
103
|
+
query: query
|
|
104
|
+
})), _defineProperty(_objectSpread2, isolatedIndex.getIndexId(), {
|
|
105
|
+
query: query
|
|
106
|
+
}), _objectSpread2));
|
|
107
|
+
});
|
|
108
|
+
};
|
|
109
|
+
var _usePropGetters = usePropGetters({
|
|
110
|
+
indices: indices,
|
|
111
|
+
indicesConfig: indicesConfig,
|
|
112
|
+
onRefine: onRefine,
|
|
113
|
+
onSelect: userOnSelect !== null && userOnSelect !== void 0 ? userOnSelect : function (_ref3) {
|
|
114
|
+
var query = _ref3.query,
|
|
115
|
+
setQuery = _ref3.setQuery,
|
|
116
|
+
url = _ref3.url;
|
|
117
|
+
if (url) {
|
|
118
|
+
window.location.href = url;
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
if (!isSearchPage && typeof getSearchPageURL !== 'undefined') {
|
|
122
|
+
var indexUiState = instantSearchInstance.getUiState()[targetIndex.getIndexId()];
|
|
123
|
+
window.location.href = getSearchPageURL(_objectSpread(_objectSpread({}, indexUiState), {}, {
|
|
124
|
+
query: query
|
|
125
|
+
}));
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
setQuery(query);
|
|
129
|
+
}
|
|
130
|
+
}),
|
|
131
|
+
getInputProps = _usePropGetters.getInputProps,
|
|
132
|
+
getItemProps = _usePropGetters.getItemProps,
|
|
133
|
+
getPanelProps = _usePropGetters.getPanelProps,
|
|
134
|
+
getRootProps = _usePropGetters.getRootProps;
|
|
135
|
+
var query = isolatedIndex === null || isolatedIndex === void 0 ? void 0 : (_isolatedIndex$getHel = isolatedIndex.getHelper()) === null || _isolatedIndex$getHel === void 0 ? void 0 : _isolatedIndex$getHel.state.query;
|
|
136
|
+
return h(Autocomplete, _extends({}, getRootProps(), {
|
|
137
|
+
classNames: cssClasses
|
|
138
|
+
}), h(AutocompleteSearchBox, {
|
|
139
|
+
query: query || '',
|
|
140
|
+
inputProps: _objectSpread(_objectSpread({}, getInputProps()), {}, {
|
|
141
|
+
// @ts-ignore - This clashes with some ambient React JSX declarations.
|
|
142
|
+
onInput: function onInput(evt) {
|
|
143
|
+
return refine(evt.currentTarget.value);
|
|
144
|
+
}
|
|
145
|
+
}),
|
|
146
|
+
onClear: function onClear() {
|
|
147
|
+
return onRefine('');
|
|
148
|
+
},
|
|
149
|
+
isSearchStalled: instantSearchInstance.status === 'stalled'
|
|
150
|
+
}), h(AutocompletePanel, getPanelProps(), indices.map(function (_ref4, i) {
|
|
151
|
+
var _indicesConfig$i$temp;
|
|
152
|
+
var indexId = _ref4.indexId,
|
|
153
|
+
hits = _ref4.hits;
|
|
154
|
+
if (!renderState.indexTemplateProps[i]) {
|
|
155
|
+
renderState.indexTemplateProps[i] = prepareTemplateProps({
|
|
156
|
+
defaultTemplates: {},
|
|
157
|
+
templatesConfig: instantSearchInstance.templatesConfig,
|
|
158
|
+
templates: indicesConfig[i].templates
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
var headerComponent = (_indicesConfig$i$temp = indicesConfig[i].templates) !== null && _indicesConfig$i$temp !== void 0 && _indicesConfig$i$temp.header ? function (_ref5) {
|
|
162
|
+
var items = _ref5.items;
|
|
163
|
+
return h(TemplateComponent, _extends({}, renderState.indexTemplateProps[i], {
|
|
164
|
+
templateKey: "header",
|
|
165
|
+
rootTagName: "fragment",
|
|
166
|
+
data: {
|
|
167
|
+
items: items
|
|
168
|
+
}
|
|
169
|
+
}));
|
|
170
|
+
} : undefined;
|
|
171
|
+
var itemComponent = function itemComponent(_ref6) {
|
|
172
|
+
var item = _ref6.item,
|
|
173
|
+
onSelect = _ref6.onSelect;
|
|
174
|
+
return h(TemplateComponent, _extends({}, renderState.indexTemplateProps[i], {
|
|
175
|
+
templateKey: "item",
|
|
176
|
+
rootTagName: "fragment",
|
|
177
|
+
data: {
|
|
178
|
+
item: item,
|
|
179
|
+
onSelect: onSelect
|
|
180
|
+
}
|
|
181
|
+
}));
|
|
182
|
+
};
|
|
183
|
+
return h(AutocompleteIndex, {
|
|
184
|
+
key: indexId,
|
|
185
|
+
HeaderComponent: headerComponent,
|
|
186
|
+
ItemComponent: itemComponent,
|
|
187
|
+
items: hits.map(function (item) {
|
|
188
|
+
return _objectSpread(_objectSpread({}, item), {}, {
|
|
189
|
+
__indexName: indexId
|
|
190
|
+
});
|
|
191
|
+
}),
|
|
192
|
+
getItemProps: getItemProps,
|
|
193
|
+
classNames: indicesConfig[i].cssClasses
|
|
194
|
+
});
|
|
195
|
+
})));
|
|
196
|
+
}
|
|
197
|
+
export function EXPERIMENTAL_autocomplete(widgetParams) {
|
|
198
|
+
var _ref7 = widgetParams || {},
|
|
199
|
+
container = _ref7.container,
|
|
200
|
+
escapeHTML = _ref7.escapeHTML,
|
|
201
|
+
_ref7$indices = _ref7.indices,
|
|
202
|
+
indices = _ref7$indices === void 0 ? [] : _ref7$indices,
|
|
203
|
+
showSuggestions = _ref7.showSuggestions,
|
|
204
|
+
getSearchPageURL = _ref7.getSearchPageURL,
|
|
205
|
+
onSelect = _ref7.onSelect,
|
|
206
|
+
_ref7$templates = _ref7.templates,
|
|
207
|
+
templates = _ref7$templates === void 0 ? {} : _ref7$templates,
|
|
208
|
+
_ref7$cssClasses = _ref7.cssClasses,
|
|
209
|
+
userCssClasses = _ref7$cssClasses === void 0 ? {} : _ref7$cssClasses;
|
|
210
|
+
if (!container) {
|
|
211
|
+
throw new Error(withUsage('The `container` option is required.'));
|
|
212
|
+
}
|
|
213
|
+
var containerNode = getContainerNode(container);
|
|
214
|
+
var cssClasses = {
|
|
215
|
+
root: cx(suit(), userCssClasses.root)
|
|
216
|
+
};
|
|
217
|
+
var indicesConfig = _toConsumableArray(indices);
|
|
218
|
+
if (showSuggestions !== null && showSuggestions !== void 0 && showSuggestions.indexName) {
|
|
219
|
+
var _showSuggestions$cssC, _showSuggestions$cssC2, _showSuggestions$cssC3, _showSuggestions$cssC4;
|
|
220
|
+
indicesConfig.unshift({
|
|
221
|
+
indexName: showSuggestions.indexName,
|
|
222
|
+
templates: _objectSpread({
|
|
223
|
+
// @ts-expect-error
|
|
224
|
+
item: AutocompleteSuggestion
|
|
225
|
+
}, showSuggestions.templates),
|
|
226
|
+
cssClasses: {
|
|
227
|
+
root: cx('ais-AutocompleteSuggestions', (_showSuggestions$cssC = showSuggestions.cssClasses) === null || _showSuggestions$cssC === void 0 ? void 0 : _showSuggestions$cssC.root),
|
|
228
|
+
list: cx('ais-AutocompleteSuggestionsList', (_showSuggestions$cssC2 = showSuggestions.cssClasses) === null || _showSuggestions$cssC2 === void 0 ? void 0 : _showSuggestions$cssC2.list),
|
|
229
|
+
header: cx('ais-AutocompleteSuggestionsHeader', (_showSuggestions$cssC3 = showSuggestions.cssClasses) === null || _showSuggestions$cssC3 === void 0 ? void 0 : _showSuggestions$cssC3.header),
|
|
230
|
+
item: cx('ais-AutocompleteSuggestionsItem', (_showSuggestions$cssC4 = showSuggestions.cssClasses) === null || _showSuggestions$cssC4 === void 0 ? void 0 : _showSuggestions$cssC4.item)
|
|
231
|
+
},
|
|
232
|
+
getQuery: function getQuery(item) {
|
|
233
|
+
return item.query;
|
|
234
|
+
},
|
|
235
|
+
getURL: showSuggestions.getURL
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
var instanceId = ++autocompleteInstanceId;
|
|
239
|
+
var specializedRenderer = createRenderer({
|
|
240
|
+
instanceId: instanceId,
|
|
241
|
+
containerNode: containerNode,
|
|
242
|
+
indicesConfig: indicesConfig,
|
|
243
|
+
getSearchPageURL: getSearchPageURL,
|
|
244
|
+
onSelect: onSelect,
|
|
245
|
+
cssClasses: cssClasses,
|
|
246
|
+
renderState: {
|
|
247
|
+
indexTemplateProps: [],
|
|
248
|
+
isolatedIndex: undefined,
|
|
249
|
+
targetIndex: undefined
|
|
250
|
+
},
|
|
251
|
+
templates: templates
|
|
252
|
+
});
|
|
253
|
+
var makeWidget = connectAutocomplete(specializedRenderer, function () {
|
|
254
|
+
return render(null, containerNode);
|
|
255
|
+
});
|
|
256
|
+
return [connectSearchBox(function () {
|
|
257
|
+
return null;
|
|
258
|
+
})({}), index({
|
|
259
|
+
indexId: "ais-autocomplete-".concat(instanceId),
|
|
260
|
+
EXPERIMENTAL_isolated: true
|
|
261
|
+
}).addWidgets([configure({
|
|
262
|
+
hitsPerPage: 5
|
|
263
|
+
})].concat(_toConsumableArray(indicesConfig.map(function (_ref8) {
|
|
264
|
+
var indexName = _ref8.indexName;
|
|
265
|
+
return index({
|
|
266
|
+
indexName: indexName,
|
|
267
|
+
indexId: indexName
|
|
268
|
+
}).addWidgets([configure({})]);
|
|
269
|
+
})), [_objectSpread(_objectSpread({}, makeWidget({
|
|
270
|
+
escapeHTML: escapeHTML
|
|
271
|
+
})), {}, {
|
|
272
|
+
$$widgetType: 'ais.autocomplete'
|
|
273
|
+
})]))];
|
|
274
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
2
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
3
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
-
function _defineProperty(
|
|
5
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i :
|
|
4
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
6
6
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
7
|
import { cx } from 'instantsearch-ui-components';
|
|
8
8
|
import { h, render } from 'preact';
|