instantsearch.js 4.79.2 → 4.81.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/Template/Template.js +1 -1
- package/cjs/connectors/chat/connectChat.js +200 -0
- package/cjs/connectors/index.js +7 -0
- package/cjs/connectors/index.umd.js +239 -0
- package/cjs/index.js +2 -2
- package/cjs/lib/InstantSearch.js +2 -10
- package/cjs/lib/chat/chat.js +177 -0
- package/cjs/lib/chat/index.js +27 -0
- package/cjs/lib/useStickToBottom.js +20 -0
- package/cjs/lib/version.js +1 -1
- package/cjs/templates/carousel/carousel.js +31 -4
- package/cjs/widgets/chat/chat.js +615 -0
- package/cjs/widgets/index/index.js +78 -24
- package/cjs/widgets/index.js +7 -0
- package/cjs/widgets/index.umd.js +267 -0
- package/dist/instantsearch.development.d.ts +123 -15
- package/dist/instantsearch.development.js +186 -91
- package/dist/instantsearch.development.js.map +1 -1
- package/dist/instantsearch.production.d.ts +123 -15
- package/dist/instantsearch.production.min.d.ts +123 -15
- package/dist/instantsearch.production.min.js +2 -2
- package/dist/instantsearch.production.min.js.map +1 -1
- package/es/components/Template/Template.js +1 -1
- package/es/connectors/chat/connectChat.d.ts +413 -0
- package/es/connectors/chat/connectChat.js +194 -0
- package/es/connectors/frequently-bought-together/connectFrequentlyBoughtTogether.d.ts +2 -0
- package/es/connectors/geo-search/connectGeoSearch.d.ts +1 -0
- package/es/connectors/hits/connectHits.d.ts +1 -0
- package/es/connectors/hits/connectHitsWithInsights.d.ts +1 -0
- 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/connectInfiniteHitsWithInsights.d.ts +1 -0
- package/es/connectors/looking-similar/connectLookingSimilar.d.ts +2 -0
- package/es/connectors/related-products/connectRelatedProducts.d.ts +2 -0
- package/es/connectors/trending-items/connectTrendingItems.d.ts +2 -0
- package/es/lib/InstantSearch.d.ts +2 -2
- package/es/lib/InstantSearch.js +2 -10
- 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/useStickToBottom.d.ts +1 -0
- package/es/lib/useStickToBottom.js +14 -0
- package/es/lib/version.d.ts +1 -1
- package/es/lib/version.js +1 -1
- package/es/templates/carousel/carousel.d.ts +10 -3
- package/es/templates/carousel/carousel.js +32 -5
- package/es/types/render-state.d.ts +2 -1
- package/es/types/templates.d.ts +1 -1
- package/es/types/widget.d.ts +2 -2
- package/es/widgets/chat/chat.d.ts +555 -0
- package/es/widgets/chat/chat.js +597 -0
- package/es/widgets/frequently-bought-together/frequently-bought-together.d.ts +3 -1
- package/es/widgets/geo-search/geo-search.d.ts +1 -0
- package/es/widgets/hits/hits.d.ts +1 -0
- package/es/widgets/index/index.d.ts +46 -2
- package/es/widgets/index/index.js +78 -24
- package/es/widgets/index.d.ts +1 -0
- package/es/widgets/index.js +2 -1
- package/es/widgets/index.umd.d.ts +44 -0
- package/es/widgets/index.umd.js +51 -0
- package/es/widgets/infinite-hits/infinite-hits.d.ts +1 -0
- package/es/widgets/looking-similar/looking-similar.d.ts +3 -1
- package/es/widgets/related-products/related-products.d.ts +3 -1
- package/es/widgets/trending-items/trending-items.d.ts +3 -1
- package/package.json +11 -7
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! InstantSearch.js 4.
|
|
1
|
+
/*! InstantSearch.js 4.81.0 | © Algolia, Inc. and contributors; MIT License | https://github.com/algolia/instantsearch */
|
|
2
2
|
(function (global, factory) {
|
|
3
3
|
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
|
4
4
|
typeof define === 'function' && define.amd ? define(factory) :
|
|
@@ -13827,6 +13827,9 @@
|
|
|
13827
13827
|
|
|
13828
13828
|
/** @deprecated use connectDynamicWidgets */
|
|
13829
13829
|
var EXPERIMENTAL_connectDynamicWidgets = deprecate(connectDynamicWidgets, 'use connectDynamicWidgets');
|
|
13830
|
+
var connectChat = function connectChat() {
|
|
13831
|
+
throw new Error("\"connectChat\" is not available from the UMD build.\n\nPlease use InstantSearch.js with a packaging system:\nhttps://www.algolia.com/doc/guides/building-search-ui/installation/js/#with-a-packaging-system");
|
|
13832
|
+
};
|
|
13830
13833
|
|
|
13831
13834
|
var connectors = /*#__PURE__*/Object.freeze({
|
|
13832
13835
|
__proto__: null,
|
|
@@ -13834,6 +13837,7 @@
|
|
|
13834
13837
|
EXPERIMENTAL_connectConfigureRelatedItems: EXPERIMENTAL_connectConfigureRelatedItems,
|
|
13835
13838
|
EXPERIMENTAL_connectDynamicWidgets: EXPERIMENTAL_connectDynamicWidgets,
|
|
13836
13839
|
connectDynamicWidgets: connectDynamicWidgets,
|
|
13840
|
+
connectChat: connectChat,
|
|
13837
13841
|
connectClearRefinements: connectClearRefinements,
|
|
13838
13842
|
connectCurrentRefinements: connectCurrentRefinements,
|
|
13839
13843
|
connectHierarchicalMenu: connectHierarchicalMenu,
|
|
@@ -15857,12 +15861,18 @@
|
|
|
15857
15861
|
}, []);
|
|
15858
15862
|
}
|
|
15859
15863
|
var index = function index(widgetParams) {
|
|
15860
|
-
if (widgetParams === undefined || widgetParams.indexName === undefined) {
|
|
15864
|
+
if (widgetParams === undefined || widgetParams.indexName === undefined && !widgetParams.EXPERIMENTAL_isolated) {
|
|
15861
15865
|
throw new Error(withUsage$u('The `indexName` option is required.'));
|
|
15862
15866
|
}
|
|
15863
|
-
|
|
15867
|
+
|
|
15868
|
+
// When isolated=true, we use an empty string as the default indexName.
|
|
15869
|
+
// This is intentional: isolated indices do not require a real index name.
|
|
15870
|
+
var _widgetParams$indexNa = widgetParams.indexName,
|
|
15871
|
+
indexName = _widgetParams$indexNa === void 0 ? '' : _widgetParams$indexNa,
|
|
15864
15872
|
_widgetParams$indexId = widgetParams.indexId,
|
|
15865
|
-
indexId = _widgetParams$indexId === void 0 ? indexName : _widgetParams$indexId
|
|
15873
|
+
indexId = _widgetParams$indexId === void 0 ? indexName : _widgetParams$indexId,
|
|
15874
|
+
_widgetParams$EXPERIM = widgetParams.EXPERIMENTAL_isolated,
|
|
15875
|
+
isolated = _widgetParams$EXPERIM === void 0 ? false : _widgetParams$EXPERIM;
|
|
15866
15876
|
var localWidgets = [];
|
|
15867
15877
|
var localUiState = {};
|
|
15868
15878
|
var localInstantSearchInstance = null;
|
|
@@ -15875,6 +15885,7 @@
|
|
|
15875
15885
|
return {
|
|
15876
15886
|
$$type: 'ais.index',
|
|
15877
15887
|
$$widgetType: 'ais.index',
|
|
15888
|
+
_isolated: isolated,
|
|
15878
15889
|
getIndexName: function getIndexName() {
|
|
15879
15890
|
return indexName;
|
|
15880
15891
|
},
|
|
@@ -15926,7 +15937,7 @@
|
|
|
15926
15937
|
return resolveScopedResultsFromWidgets(widgetSiblings);
|
|
15927
15938
|
},
|
|
15928
15939
|
getParent: function getParent() {
|
|
15929
|
-
return localParent;
|
|
15940
|
+
return isolated ? null : localParent;
|
|
15930
15941
|
},
|
|
15931
15942
|
createURL: function createURL(nextState) {
|
|
15932
15943
|
if (typeof nextState === 'function') {
|
|
@@ -15945,12 +15956,15 @@
|
|
|
15945
15956
|
if (!Array.isArray(widgets)) {
|
|
15946
15957
|
throw new Error(withUsage$u('The `addWidgets` method expects an array of widgets.'));
|
|
15947
15958
|
}
|
|
15948
|
-
|
|
15959
|
+
var flatWidgets = widgets.reduce(function (acc, w) {
|
|
15960
|
+
return acc.concat(Array.isArray(w) ? w : [w]);
|
|
15961
|
+
}, []);
|
|
15962
|
+
if (flatWidgets.some(function (widget) {
|
|
15949
15963
|
return typeof widget.init !== 'function' && typeof widget.render !== 'function';
|
|
15950
15964
|
})) {
|
|
15951
15965
|
throw new Error(withUsage$u('The widget definition expects a `render` and/or an `init` method.'));
|
|
15952
15966
|
}
|
|
15953
|
-
|
|
15967
|
+
flatWidgets.forEach(function (widget) {
|
|
15954
15968
|
if (isIndexWidget(widget)) {
|
|
15955
15969
|
return;
|
|
15956
15970
|
}
|
|
@@ -15965,8 +15979,8 @@
|
|
|
15965
15979
|
}
|
|
15966
15980
|
addWidgetId(widget);
|
|
15967
15981
|
});
|
|
15968
|
-
localWidgets = localWidgets.concat(
|
|
15969
|
-
if (localInstantSearchInstance && Boolean(
|
|
15982
|
+
localWidgets = localWidgets.concat(flatWidgets);
|
|
15983
|
+
if (localInstantSearchInstance && Boolean(flatWidgets.length)) {
|
|
15970
15984
|
privateHelperSetState(helper, {
|
|
15971
15985
|
state: getLocalWidgetsSearchParameters(localWidgets, {
|
|
15972
15986
|
uiState: localUiState,
|
|
@@ -15982,7 +15996,7 @@
|
|
|
15982
15996
|
// We compute the render state before calling `init` in a separate loop
|
|
15983
15997
|
// to construct the whole render state object that is then passed to
|
|
15984
15998
|
// `init`.
|
|
15985
|
-
|
|
15999
|
+
flatWidgets.forEach(function (widget) {
|
|
15986
16000
|
if (widget.getRenderState) {
|
|
15987
16001
|
var renderState = widget.getRenderState(localInstantSearchInstance.renderState[_this.getIndexId()] || {}, createInitArgs(localInstantSearchInstance, _this, localInstantSearchInstance._initialUiState));
|
|
15988
16002
|
storeRenderState({
|
|
@@ -15992,12 +16006,17 @@
|
|
|
15992
16006
|
});
|
|
15993
16007
|
}
|
|
15994
16008
|
});
|
|
15995
|
-
|
|
16009
|
+
flatWidgets.forEach(function (widget) {
|
|
15996
16010
|
if (widget.init) {
|
|
15997
16011
|
widget.init(createInitArgs(localInstantSearchInstance, _this, localInstantSearchInstance._initialUiState));
|
|
15998
16012
|
}
|
|
15999
16013
|
});
|
|
16000
|
-
|
|
16014
|
+
if (isolated) {
|
|
16015
|
+
var _helper2;
|
|
16016
|
+
(_helper2 = helper) === null || _helper2 === void 0 ? void 0 : _helper2.search();
|
|
16017
|
+
} else {
|
|
16018
|
+
localInstantSearchInstance.scheduleSearch();
|
|
16019
|
+
}
|
|
16001
16020
|
}
|
|
16002
16021
|
return this;
|
|
16003
16022
|
},
|
|
@@ -16006,13 +16025,16 @@
|
|
|
16006
16025
|
if (!Array.isArray(widgets)) {
|
|
16007
16026
|
throw new Error(withUsage$u('The `removeWidgets` method expects an array of widgets.'));
|
|
16008
16027
|
}
|
|
16009
|
-
|
|
16028
|
+
var flatWidgets = widgets.reduce(function (acc, w) {
|
|
16029
|
+
return acc.concat(Array.isArray(w) ? w : [w]);
|
|
16030
|
+
}, []);
|
|
16031
|
+
if (flatWidgets.some(function (widget) {
|
|
16010
16032
|
return typeof widget.dispose !== 'function';
|
|
16011
16033
|
})) {
|
|
16012
16034
|
throw new Error(withUsage$u('The widget definition expects a `dispose` method.'));
|
|
16013
16035
|
}
|
|
16014
16036
|
localWidgets = localWidgets.filter(function (widget) {
|
|
16015
|
-
return
|
|
16037
|
+
return flatWidgets.indexOf(widget) === -1;
|
|
16016
16038
|
});
|
|
16017
16039
|
localWidgets.forEach(function (widget) {
|
|
16018
16040
|
if (isIndexWidget(widget)) {
|
|
@@ -16028,8 +16050,8 @@
|
|
|
16028
16050
|
hasSearchWidget = true;
|
|
16029
16051
|
}
|
|
16030
16052
|
});
|
|
16031
|
-
if (localInstantSearchInstance && Boolean(
|
|
16032
|
-
var
|
|
16053
|
+
if (localInstantSearchInstance && Boolean(flatWidgets.length)) {
|
|
16054
|
+
var _flatWidgets$reduce = flatWidgets.reduce(function (states, widget) {
|
|
16033
16055
|
// the `dispose` method exists at this point we already assert it
|
|
16034
16056
|
var next = widget.dispose({
|
|
16035
16057
|
helper: helper,
|
|
@@ -16047,8 +16069,8 @@
|
|
|
16047
16069
|
cleanedSearchState: helper.state,
|
|
16048
16070
|
cleanedRecommendState: helper.recommendState
|
|
16049
16071
|
}),
|
|
16050
|
-
cleanedSearchState =
|
|
16051
|
-
cleanedRecommendState =
|
|
16072
|
+
cleanedSearchState = _flatWidgets$reduce.cleanedSearchState,
|
|
16073
|
+
cleanedRecommendState = _flatWidgets$reduce.cleanedRecommendState;
|
|
16052
16074
|
var newState = localInstantSearchInstance.future.preserveSharedStateOnUnmount ? getLocalWidgetsSearchParameters(localWidgets, {
|
|
16053
16075
|
uiState: localUiState,
|
|
16054
16076
|
initialSearchParameters: new algoliasearchHelper_1.SearchParameters({
|
|
@@ -16068,7 +16090,12 @@
|
|
|
16068
16090
|
helper.setState(newState);
|
|
16069
16091
|
helper.recommendState = cleanedRecommendState;
|
|
16070
16092
|
if (localWidgets.length) {
|
|
16071
|
-
|
|
16093
|
+
if (isolated) {
|
|
16094
|
+
var _helper3;
|
|
16095
|
+
(_helper3 = helper) === null || _helper3 === void 0 ? void 0 : _helper3.search();
|
|
16096
|
+
} else {
|
|
16097
|
+
localInstantSearchInstance.scheduleSearch();
|
|
16098
|
+
}
|
|
16072
16099
|
}
|
|
16073
16100
|
}
|
|
16074
16101
|
return this;
|
|
@@ -16106,13 +16133,20 @@
|
|
|
16106
16133
|
// This Helper is only used for state management we do not care about the
|
|
16107
16134
|
// `searchClient`. Only the "main" Helper created at the `InstantSearch`
|
|
16108
16135
|
// level is aware of the client.
|
|
16109
|
-
helper = algoliasearchHelper_1(
|
|
16136
|
+
helper = algoliasearchHelper_1(mainHelper.getClient(), parameters.index, parameters);
|
|
16110
16137
|
helper.recommendState = recommendParameters;
|
|
16111
16138
|
|
|
16112
16139
|
// We forward the call to `search` to the "main" instance of the Helper
|
|
16113
16140
|
// which is responsible for managing the queries (it's the only one that is
|
|
16114
16141
|
// aware of the `searchClient`).
|
|
16115
16142
|
helper.search = function () {
|
|
16143
|
+
if (isolated) {
|
|
16144
|
+
instantSearchInstance.status = 'loading';
|
|
16145
|
+
_this3.render({
|
|
16146
|
+
instantSearchInstance: instantSearchInstance
|
|
16147
|
+
});
|
|
16148
|
+
return instantSearchInstance.compositionID ? helper.searchWithComposition() : helper.searchOnlyWithDerivedHelpers();
|
|
16149
|
+
}
|
|
16116
16150
|
if (instantSearchInstance.onStateChange) {
|
|
16117
16151
|
instantSearchInstance.onStateChange({
|
|
16118
16152
|
uiState: instantSearchInstance.mainIndex.getWidgetUiState({}),
|
|
@@ -16136,7 +16170,9 @@
|
|
|
16136
16170
|
var state = helper.state.setQueryParameters(userState);
|
|
16137
16171
|
return mainHelper.searchForFacetValues(facetName, facetValue, maxFacetHits, state);
|
|
16138
16172
|
};
|
|
16139
|
-
|
|
16173
|
+
var isolatedHelper = indexName ? helper : algoliasearchHelper_1({}, '__empty_index__', {});
|
|
16174
|
+
var derivingHelper = isolated ? isolatedHelper : nearestIsolatedHelper(parent, mainHelper);
|
|
16175
|
+
derivedHelper = derivingHelper.derive(function () {
|
|
16140
16176
|
return mergeSearchParameters.apply(void 0, [mainHelper.state].concat(_toConsumableArray(resolveSearchParameters(_this3))));
|
|
16141
16177
|
}, function () {
|
|
16142
16178
|
return _this3.getHelper().recommendState;
|
|
@@ -16278,7 +16314,11 @@
|
|
|
16278
16314
|
|
|
16279
16315
|
// We only render index widgets if there are no results.
|
|
16280
16316
|
// This makes sure `render` is never called with `results` being `null`.
|
|
16281
|
-
|
|
16317
|
+
// If it's an isolated index without an index name, we render all widgets,
|
|
16318
|
+
// as there are no results to display for the isolated index itself.
|
|
16319
|
+
var widgetsToRender = this.getResults() || (_derivedHelper2 = derivedHelper) !== null && _derivedHelper2 !== void 0 && _derivedHelper2.lastRecommendResults || isolated && !indexName ? localWidgets : localWidgets.filter(function (widget) {
|
|
16320
|
+
return widget.shouldRender;
|
|
16321
|
+
});
|
|
16282
16322
|
widgetsToRender = widgetsToRender.filter(function (widget) {
|
|
16283
16323
|
if (!widget.shouldRender) {
|
|
16284
16324
|
return true;
|
|
@@ -16312,7 +16352,7 @@
|
|
|
16312
16352
|
},
|
|
16313
16353
|
dispose: function dispose() {
|
|
16314
16354
|
var _this5 = this,
|
|
16315
|
-
|
|
16355
|
+
_helper4,
|
|
16316
16356
|
_derivedHelper3;
|
|
16317
16357
|
localWidgets.forEach(function (widget) {
|
|
16318
16358
|
if (widget.dispose && helper) {
|
|
@@ -16332,13 +16372,15 @@
|
|
|
16332
16372
|
});
|
|
16333
16373
|
localInstantSearchInstance = null;
|
|
16334
16374
|
localParent = null;
|
|
16335
|
-
(
|
|
16375
|
+
(_helper4 = helper) === null || _helper4 === void 0 ? void 0 : _helper4.removeAllListeners();
|
|
16336
16376
|
helper = null;
|
|
16337
16377
|
(_derivedHelper3 = derivedHelper) === null || _derivedHelper3 === void 0 ? void 0 : _derivedHelper3.detach();
|
|
16338
16378
|
derivedHelper = null;
|
|
16339
16379
|
},
|
|
16340
16380
|
getWidgetUiState: function getWidgetUiState(uiState) {
|
|
16341
|
-
return localWidgets.filter(isIndexWidget).
|
|
16381
|
+
return localWidgets.filter(isIndexWidget).filter(function (w) {
|
|
16382
|
+
return !w._isolated;
|
|
16383
|
+
}).reduce(function (previousUiState, innerIndex) {
|
|
16342
16384
|
return innerIndex.getWidgetUiState(previousUiState);
|
|
16343
16385
|
}, _objectSpread2(_objectSpread2({}, uiState), {}, _defineProperty({}, indexId, _objectSpread2(_objectSpread2({}, uiState[indexId]), localUiState))));
|
|
16344
16386
|
},
|
|
@@ -16353,6 +16395,9 @@
|
|
|
16353
16395
|
initialSearchParameters: searchParameters
|
|
16354
16396
|
});
|
|
16355
16397
|
},
|
|
16398
|
+
shouldRender: function shouldRender() {
|
|
16399
|
+
return true;
|
|
16400
|
+
},
|
|
16356
16401
|
refreshUiState: function refreshUiState() {
|
|
16357
16402
|
localUiState = getLocalWidgetsUiState(localWidgets, {
|
|
16358
16403
|
searchParameters: this.getHelper().state,
|
|
@@ -16375,6 +16420,19 @@
|
|
|
16375
16420
|
instantSearchInstance.renderState = _objectSpread2(_objectSpread2({}, instantSearchInstance.renderState), {}, _defineProperty({}, parentIndexName, _objectSpread2(_objectSpread2({}, instantSearchInstance.renderState[parentIndexName]), renderState)));
|
|
16376
16421
|
}
|
|
16377
16422
|
|
|
16423
|
+
/**
|
|
16424
|
+
* Walk up the parent chain to find the closest isolated index, or fall back to mainHelper
|
|
16425
|
+
*/
|
|
16426
|
+
function nearestIsolatedHelper(current, mainHelper) {
|
|
16427
|
+
while (current) {
|
|
16428
|
+
if (current._isolated) {
|
|
16429
|
+
return current.getHelper();
|
|
16430
|
+
}
|
|
16431
|
+
current = current.getParent();
|
|
16432
|
+
}
|
|
16433
|
+
return mainHelper;
|
|
16434
|
+
}
|
|
16435
|
+
|
|
16378
16436
|
function formatNumber(value, numberLocale) {
|
|
16379
16437
|
return value.toLocaleString(numberLocale);
|
|
16380
16438
|
}
|
|
@@ -16440,7 +16498,7 @@
|
|
|
16440
16498
|
};
|
|
16441
16499
|
}
|
|
16442
16500
|
|
|
16443
|
-
var version$1 = '4.
|
|
16501
|
+
var version$1 = '4.81.0';
|
|
16444
16502
|
|
|
16445
16503
|
var withUsage$v = createDocumentationMessageGenerator({
|
|
16446
16504
|
name: 'instantsearch'
|
|
@@ -16741,12 +16799,9 @@
|
|
|
16741
16799
|
if (!Array.isArray(widgets)) {
|
|
16742
16800
|
throw new Error(withUsage$v('The `addWidgets` method expects an array of widgets. Please use `addWidget`.'));
|
|
16743
16801
|
}
|
|
16744
|
-
if (widgets.some(function (
|
|
16745
|
-
return
|
|
16802
|
+
if (this.compositionID && widgets.some(function (w) {
|
|
16803
|
+
return !Array.isArray(w) && isIndexWidget(w) && !w._isolated;
|
|
16746
16804
|
})) {
|
|
16747
|
-
throw new Error(withUsage$v('The widget definition expects a `render` and/or an `init` method.'));
|
|
16748
|
-
}
|
|
16749
|
-
if (this.compositionID && widgets.some(isIndexWidget)) {
|
|
16750
16805
|
throw new Error(withUsage$v('The `index` widget cannot be used with a composition-based InstantSearch implementation.'));
|
|
16751
16806
|
}
|
|
16752
16807
|
this.mainIndex.addWidgets(widgets);
|
|
@@ -16779,11 +16834,6 @@
|
|
|
16779
16834
|
if (!Array.isArray(widgets)) {
|
|
16780
16835
|
throw new Error(withUsage$v('The `removeWidgets` method expects an array of widgets. Please use `removeWidget`.'));
|
|
16781
16836
|
}
|
|
16782
|
-
if (widgets.some(function (widget) {
|
|
16783
|
-
return typeof widget.dispose !== 'function';
|
|
16784
|
-
})) {
|
|
16785
|
-
throw new Error(withUsage$v('The widget definition expects a `dispose` method.'));
|
|
16786
|
-
}
|
|
16787
16837
|
this.mainIndex.removeWidgets(widgets);
|
|
16788
16838
|
return this;
|
|
16789
16839
|
}
|
|
@@ -17142,6 +17192,50 @@
|
|
|
17142
17192
|
|
|
17143
17193
|
var _extends$1 = unwrapExports(_extends_1);
|
|
17144
17194
|
|
|
17195
|
+
var objectWithoutPropertiesLoose = createCommonjsModule(function (module) {
|
|
17196
|
+
function _objectWithoutPropertiesLoose(r, e) {
|
|
17197
|
+
if (null == r) return {};
|
|
17198
|
+
var t = {};
|
|
17199
|
+
for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
|
|
17200
|
+
if (-1 !== e.indexOf(n)) continue;
|
|
17201
|
+
t[n] = r[n];
|
|
17202
|
+
}
|
|
17203
|
+
return t;
|
|
17204
|
+
}
|
|
17205
|
+
module.exports = _objectWithoutPropertiesLoose, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
17206
|
+
});
|
|
17207
|
+
|
|
17208
|
+
unwrapExports(objectWithoutPropertiesLoose);
|
|
17209
|
+
|
|
17210
|
+
var objectWithoutProperties = createCommonjsModule(function (module) {
|
|
17211
|
+
function _objectWithoutProperties(e, t) {
|
|
17212
|
+
if (null == e) return {};
|
|
17213
|
+
var o,
|
|
17214
|
+
r,
|
|
17215
|
+
i = objectWithoutPropertiesLoose(e, t);
|
|
17216
|
+
if (Object.getOwnPropertySymbols) {
|
|
17217
|
+
var n = Object.getOwnPropertySymbols(e);
|
|
17218
|
+
for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
|
|
17219
|
+
}
|
|
17220
|
+
return i;
|
|
17221
|
+
}
|
|
17222
|
+
module.exports = _objectWithoutProperties, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
17223
|
+
});
|
|
17224
|
+
|
|
17225
|
+
var _objectWithoutProperties$1 = unwrapExports(objectWithoutProperties);
|
|
17226
|
+
|
|
17227
|
+
function cx() {
|
|
17228
|
+
for (var _len = arguments.length, classNames = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
17229
|
+
classNames[_key] = arguments[_key];
|
|
17230
|
+
}
|
|
17231
|
+
return classNames.reduce(function (acc, className) {
|
|
17232
|
+
if (Array.isArray(className)) {
|
|
17233
|
+
return acc.concat(className);
|
|
17234
|
+
}
|
|
17235
|
+
return acc.concat([className]);
|
|
17236
|
+
}, []).filter(Boolean).join(' ');
|
|
17237
|
+
}
|
|
17238
|
+
|
|
17145
17239
|
var _typeof_1 = createCommonjsModule(function (module) {
|
|
17146
17240
|
function _typeof(o) {
|
|
17147
17241
|
"@babel/helpers - typeof";
|
|
@@ -17200,50 +17294,6 @@
|
|
|
17200
17294
|
|
|
17201
17295
|
var _defineProperty$1 = unwrapExports(defineProperty);
|
|
17202
17296
|
|
|
17203
|
-
var objectWithoutPropertiesLoose = createCommonjsModule(function (module) {
|
|
17204
|
-
function _objectWithoutPropertiesLoose(r, e) {
|
|
17205
|
-
if (null == r) return {};
|
|
17206
|
-
var t = {};
|
|
17207
|
-
for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
|
|
17208
|
-
if (-1 !== e.indexOf(n)) continue;
|
|
17209
|
-
t[n] = r[n];
|
|
17210
|
-
}
|
|
17211
|
-
return t;
|
|
17212
|
-
}
|
|
17213
|
-
module.exports = _objectWithoutPropertiesLoose, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
17214
|
-
});
|
|
17215
|
-
|
|
17216
|
-
unwrapExports(objectWithoutPropertiesLoose);
|
|
17217
|
-
|
|
17218
|
-
var objectWithoutProperties = createCommonjsModule(function (module) {
|
|
17219
|
-
function _objectWithoutProperties(e, t) {
|
|
17220
|
-
if (null == e) return {};
|
|
17221
|
-
var o,
|
|
17222
|
-
r,
|
|
17223
|
-
i = objectWithoutPropertiesLoose(e, t);
|
|
17224
|
-
if (Object.getOwnPropertySymbols) {
|
|
17225
|
-
var n = Object.getOwnPropertySymbols(e);
|
|
17226
|
-
for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
|
|
17227
|
-
}
|
|
17228
|
-
return i;
|
|
17229
|
-
}
|
|
17230
|
-
module.exports = _objectWithoutProperties, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
17231
|
-
});
|
|
17232
|
-
|
|
17233
|
-
var _objectWithoutProperties$1 = unwrapExports(objectWithoutProperties);
|
|
17234
|
-
|
|
17235
|
-
function cx() {
|
|
17236
|
-
for (var _len = arguments.length, classNames = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
17237
|
-
classNames[_key] = arguments[_key];
|
|
17238
|
-
}
|
|
17239
|
-
return classNames.reduce(function (acc, className) {
|
|
17240
|
-
if (Array.isArray(className)) {
|
|
17241
|
-
return acc.concat(className);
|
|
17242
|
-
}
|
|
17243
|
-
return acc.concat([className]);
|
|
17244
|
-
}, []).filter(Boolean).join(' ');
|
|
17245
|
-
}
|
|
17246
|
-
|
|
17247
17297
|
function createDefaultEmptyComponent(_ref) {
|
|
17248
17298
|
var createElement = _ref.createElement,
|
|
17249
17299
|
Fragment = _ref.Fragment;
|
|
@@ -17309,7 +17359,7 @@
|
|
|
17309
17359
|
};
|
|
17310
17360
|
}
|
|
17311
17361
|
|
|
17312
|
-
var _excluded$9 = ["listRef", "nextButtonRef", "previousButtonRef", "carouselIdRef", "classNames", "itemComponent", "previousIconComponent", "nextIconComponent", "items", "translations", "sendEvent"];
|
|
17362
|
+
var _excluded$9 = ["listRef", "nextButtonRef", "previousButtonRef", "carouselIdRef", "canScrollLeft", "canScrollRight", "setCanScrollLeft", "setCanScrollRight", "classNames", "itemComponent", "previousIconComponent", "nextIconComponent", "headerComponent", "showNavigation", "items", "translations", "sendEvent"];
|
|
17313
17363
|
function ownKeys$1(e, r) {
|
|
17314
17364
|
var t = Object.keys(e);
|
|
17315
17365
|
if (Object.getOwnPropertySymbols) {
|
|
@@ -17371,6 +17421,10 @@
|
|
|
17371
17421
|
nextButtonRef = userProps.nextButtonRef,
|
|
17372
17422
|
previousButtonRef = userProps.previousButtonRef,
|
|
17373
17423
|
carouselIdRef = userProps.carouselIdRef,
|
|
17424
|
+
canScrollLeft = userProps.canScrollLeft,
|
|
17425
|
+
canScrollRight = userProps.canScrollRight,
|
|
17426
|
+
setCanScrollLeft = userProps.setCanScrollLeft,
|
|
17427
|
+
setCanScrollRight = userProps.setCanScrollRight,
|
|
17374
17428
|
_userProps$classNames = userProps.classNames,
|
|
17375
17429
|
classNames = _userProps$classNames === void 0 ? {} : _userProps$classNames,
|
|
17376
17430
|
_userProps$itemCompon = userProps.itemComponent,
|
|
@@ -17382,6 +17436,9 @@
|
|
|
17382
17436
|
PreviousIconComponent = _userProps$previousIc === void 0 ? PreviousIconDefaultComponent : _userProps$previousIc,
|
|
17383
17437
|
_userProps$nextIconCo = userProps.nextIconComponent,
|
|
17384
17438
|
NextIconComponent = _userProps$nextIconCo === void 0 ? NextIconDefaultComponent : _userProps$nextIconCo,
|
|
17439
|
+
HeaderComponent = userProps.headerComponent,
|
|
17440
|
+
_userProps$showNaviga = userProps.showNavigation,
|
|
17441
|
+
showNavigation = _userProps$showNaviga === void 0 ? true : _userProps$showNaviga,
|
|
17385
17442
|
items = userProps.items,
|
|
17386
17443
|
userTranslations = userProps.translations,
|
|
17387
17444
|
sendEvent = userProps.sendEvent,
|
|
@@ -17412,18 +17469,31 @@
|
|
|
17412
17469
|
}
|
|
17413
17470
|
}
|
|
17414
17471
|
function updateNavigationButtonsProps() {
|
|
17415
|
-
if (!listRef.current
|
|
17472
|
+
if (!listRef.current) {
|
|
17416
17473
|
return;
|
|
17417
17474
|
}
|
|
17418
|
-
|
|
17419
|
-
|
|
17475
|
+
var isLeftHidden = listRef.current.scrollLeft <= 0;
|
|
17476
|
+
var isRightHidden = listRef.current.scrollLeft + listRef.current.clientWidth >= listRef.current.scrollWidth;
|
|
17477
|
+
setCanScrollLeft(!isLeftHidden);
|
|
17478
|
+
setCanScrollRight(!isRightHidden);
|
|
17479
|
+
if (previousButtonRef.current) {
|
|
17480
|
+
previousButtonRef.current.hidden = isLeftHidden;
|
|
17481
|
+
}
|
|
17482
|
+
if (nextButtonRef.current) {
|
|
17483
|
+
nextButtonRef.current.hidden = isRightHidden;
|
|
17484
|
+
}
|
|
17420
17485
|
}
|
|
17421
17486
|
if (items.length === 0) {
|
|
17422
17487
|
return null;
|
|
17423
17488
|
}
|
|
17424
17489
|
return createElement("div", _extends$1({}, props, {
|
|
17425
17490
|
className: cx(cssClasses.root)
|
|
17426
|
-
}), createElement(
|
|
17491
|
+
}), HeaderComponent && createElement(HeaderComponent, {
|
|
17492
|
+
canScrollLeft: canScrollLeft,
|
|
17493
|
+
canScrollRight: canScrollRight,
|
|
17494
|
+
scrollLeft: scrollLeft,
|
|
17495
|
+
scrollRight: scrollRight
|
|
17496
|
+
}), showNavigation && createElement("button", {
|
|
17427
17497
|
ref: previousButtonRef,
|
|
17428
17498
|
title: translations.previousButtonTitle,
|
|
17429
17499
|
"aria-label": translations.previousButtonLabel,
|
|
@@ -17470,7 +17540,7 @@
|
|
|
17470
17540
|
item: item,
|
|
17471
17541
|
sendEvent: sendEvent
|
|
17472
17542
|
}));
|
|
17473
|
-
})), createElement("button", {
|
|
17543
|
+
})), showNavigation && createElement("button", {
|
|
17474
17544
|
ref: nextButtonRef,
|
|
17475
17545
|
title: translations.nextButtonTitle,
|
|
17476
17546
|
"aria-label": translations.nextButtonLabel,
|
|
@@ -17961,11 +18031,23 @@
|
|
|
17961
18031
|
Fragment: p
|
|
17962
18032
|
});
|
|
17963
18033
|
function CarouselWithRefs(props) {
|
|
18034
|
+
var _useState = y$1(false),
|
|
18035
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
18036
|
+
canScrollLeft = _useState2[0],
|
|
18037
|
+
setCanScrollLeft = _useState2[1];
|
|
18038
|
+
var _useState3 = y$1(true),
|
|
18039
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
18040
|
+
canScrollRight = _useState4[0],
|
|
18041
|
+
setCanScrollRight = _useState4[1];
|
|
17964
18042
|
var carouselRefs = {
|
|
17965
18043
|
listRef: A$1(null),
|
|
17966
18044
|
nextButtonRef: A$1(null),
|
|
17967
18045
|
previousButtonRef: A$1(null),
|
|
17968
|
-
carouselIdRef: A$1(generateCarouselId())
|
|
18046
|
+
carouselIdRef: A$1(generateCarouselId()),
|
|
18047
|
+
canScrollLeft: canScrollLeft,
|
|
18048
|
+
canScrollRight: canScrollRight,
|
|
18049
|
+
setCanScrollLeft: setCanScrollLeft,
|
|
18050
|
+
setCanScrollRight: setCanScrollRight
|
|
17969
18051
|
};
|
|
17970
18052
|
return h(Carousel, _extends({}, carouselRefs, props));
|
|
17971
18053
|
}
|
|
@@ -17973,7 +18055,9 @@
|
|
|
17973
18055
|
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
17974
18056
|
cssClasses = _ref.cssClasses,
|
|
17975
18057
|
_ref$templates = _ref.templates,
|
|
17976
|
-
templates = _ref$templates === void 0 ? {} : _ref$templates
|
|
18058
|
+
templates = _ref$templates === void 0 ? {} : _ref$templates,
|
|
18059
|
+
_ref$showNavigation = _ref.showNavigation,
|
|
18060
|
+
showNavigation = _ref$showNavigation === void 0 ? true : _ref$showNavigation;
|
|
17977
18061
|
return function CarouselTemplate(_ref2) {
|
|
17978
18062
|
var items = _ref2.items,
|
|
17979
18063
|
widgetTemplates = _ref2.templates,
|
|
@@ -17982,11 +18066,17 @@
|
|
|
17982
18066
|
_ref2$sendEvent = _ref2.sendEvent,
|
|
17983
18067
|
sendEvent = _ref2$sendEvent === void 0 ? function () {} : _ref2$sendEvent;
|
|
17984
18068
|
var previous = templates.previous,
|
|
17985
|
-
next = templates.next
|
|
18069
|
+
next = templates.next,
|
|
18070
|
+
header = templates.header;
|
|
17986
18071
|
return h(CarouselWithRefs, {
|
|
17987
18072
|
items: items,
|
|
17988
18073
|
sendEvent: sendEvent,
|
|
17989
18074
|
itemComponent: widgetTemplates.item,
|
|
18075
|
+
headerComponent: header ? function (props) {
|
|
18076
|
+
return header(_objectSpread2({
|
|
18077
|
+
html: m$1
|
|
18078
|
+
}, props));
|
|
18079
|
+
} : undefined,
|
|
17990
18080
|
previousIconComponent: previous ? function () {
|
|
17991
18081
|
return previous({
|
|
17992
18082
|
html: m$1
|
|
@@ -18000,7 +18090,8 @@
|
|
|
18000
18090
|
classNames: _objectSpread2(_objectSpread2({}, cssClasses), {
|
|
18001
18091
|
list: cx(cssClasses === null || cssClasses === void 0 ? void 0 : cssClasses.list, widgetCssClasses === null || widgetCssClasses === void 0 ? void 0 : widgetCssClasses.list),
|
|
18002
18092
|
item: cx(cssClasses === null || cssClasses === void 0 ? void 0 : cssClasses.item, widgetCssClasses === null || widgetCssClasses === void 0 ? void 0 : widgetCssClasses.item)
|
|
18003
|
-
})
|
|
18093
|
+
}),
|
|
18094
|
+
showNavigation: showNavigation
|
|
18004
18095
|
});
|
|
18005
18096
|
};
|
|
18006
18097
|
}
|
|
@@ -19068,7 +19159,7 @@
|
|
|
19068
19159
|
});
|
|
19069
19160
|
// if there is one TextNode first and one TextNode last, the
|
|
19070
19161
|
// last one's nodeValue will be assigned to the first.
|
|
19071
|
-
if (this.nodes[0].nodeValue) {
|
|
19162
|
+
if (this.nodes[0] && this.nodes[0].nodeValue) {
|
|
19072
19163
|
this.nodes[0].nodeValue = '';
|
|
19073
19164
|
}
|
|
19074
19165
|
}
|
|
@@ -25508,6 +25599,9 @@
|
|
|
25508
25599
|
|
|
25509
25600
|
/** @deprecated use dynamicWidgets */
|
|
25510
25601
|
var EXPERIMENTAL_dynamicWidgets = deprecate(dynamicWidgets, 'use dynamicWidgets');
|
|
25602
|
+
var chat = function chat() {
|
|
25603
|
+
throw new Error("\"chat\" is not available from the UMD build.\n\nPlease use InstantSearch.js with a packaging system:\nhttps://www.algolia.com/doc/guides/building-search-ui/installation/js/#with-a-packaging-system");
|
|
25604
|
+
};
|
|
25511
25605
|
|
|
25512
25606
|
var widgets = /*#__PURE__*/Object.freeze({
|
|
25513
25607
|
__proto__: null,
|
|
@@ -25515,6 +25609,7 @@
|
|
|
25515
25609
|
EXPERIMENTAL_configureRelatedItems: EXPERIMENTAL_configureRelatedItems,
|
|
25516
25610
|
EXPERIMENTAL_dynamicWidgets: EXPERIMENTAL_dynamicWidgets,
|
|
25517
25611
|
dynamicWidgets: dynamicWidgets,
|
|
25612
|
+
chat: chat,
|
|
25518
25613
|
analytics: analytics,
|
|
25519
25614
|
breadcrumb: breadcrumb,
|
|
25520
25615
|
clearRefinements: clearRefinements$1,
|