algolia-experiences 1.8.16 → 1.8.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
|
|
2
2
|
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
|
|
3
|
-
|
|
3
|
+
|
|
4
4
|
- [`algolia-experiences`](#algolia-experiences)
|
|
5
5
|
- [Usage](#usage)
|
|
6
6
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! algolia-experiences 1.8.
|
|
1
|
+
/*! algolia-experiences 1.8.18 | © Algolia, Inc. and contributors; MIT License | https://github.com/algolia/instantsearch */
|
|
2
2
|
(function (factory) {
|
|
3
3
|
typeof define === 'function' && define.amd ? define(factory) :
|
|
4
4
|
factory();
|
|
@@ -4987,7 +4987,7 @@
|
|
|
4987
4987
|
function requireVersion() {
|
|
4988
4988
|
if (hasRequiredVersion) return version$1;
|
|
4989
4989
|
hasRequiredVersion = 1;
|
|
4990
|
-
version$1 = '3.29.
|
|
4990
|
+
version$1 = '3.29.3';
|
|
4991
4991
|
return version$1;
|
|
4992
4992
|
}
|
|
4993
4993
|
|
|
@@ -6886,7 +6886,7 @@
|
|
|
6886
6886
|
});
|
|
6887
6887
|
}
|
|
6888
6888
|
|
|
6889
|
-
var version = '4.
|
|
6889
|
+
var version = '4.109.0';
|
|
6890
6890
|
|
|
6891
6891
|
var ANONYMOUS_TOKEN_COOKIE_KEY = '_ALGOLIA';
|
|
6892
6892
|
function getCookie(name) {
|
|
@@ -7374,7 +7374,8 @@
|
|
|
7374
7374
|
helper.overrideStateWithoutTriggeringChangeEvent(_object_spread_props(_object_spread({}, helper.state), {
|
|
7375
7375
|
userToken: normalizedUserToken
|
|
7376
7376
|
}));
|
|
7377
|
-
if (existingToken && existingToken !==
|
|
7377
|
+
if (existingToken && existingToken !== normalizedUserToken) {
|
|
7378
|
+
helper._recommendCache = {};
|
|
7378
7379
|
instantSearchInstance.scheduleSearch();
|
|
7379
7380
|
}
|
|
7380
7381
|
}
|
|
@@ -7463,14 +7464,17 @@
|
|
|
7463
7464
|
} else if (event.insightsMethod) {
|
|
7464
7465
|
if (event.insightsMethod === 'viewedObjectIDs') {
|
|
7465
7466
|
var payload = event.payload;
|
|
7467
|
+
var getViewEventKey = function getViewEventKey(objectID) {
|
|
7468
|
+
return payload.queryID ? "".concat(payload.queryID, ":").concat(objectID) : objectID;
|
|
7469
|
+
};
|
|
7466
7470
|
var difference = payload.objectIDs.filter(function(objectID) {
|
|
7467
|
-
return !viewedObjectIDs.has(objectID);
|
|
7471
|
+
return !viewedObjectIDs.has(getViewEventKey(objectID));
|
|
7468
7472
|
});
|
|
7469
7473
|
if (difference.length === 0) {
|
|
7470
7474
|
return;
|
|
7471
7475
|
}
|
|
7472
7476
|
difference.forEach(function(objectID) {
|
|
7473
|
-
return viewedObjectIDs.add(objectID);
|
|
7477
|
+
return viewedObjectIDs.add(getViewEventKey(objectID));
|
|
7474
7478
|
});
|
|
7475
7479
|
payload.objectIDs = difference;
|
|
7476
7480
|
}
|
|
@@ -7578,10 +7582,10 @@
|
|
|
7578
7582
|
* and the ability to set credentials via extra parameters when sending events.
|
|
7579
7583
|
*/ function isModernInsightsClient(client) {
|
|
7580
7584
|
var _split_map = _sliced_to_array((client.version || '').split('.').map(Number), 2), major = _split_map[0], minor = _split_map[1];
|
|
7581
|
-
/*
|
|
7585
|
+
/* oxlint-disable instantsearch/naming-convention */ var v3 = major >= 3;
|
|
7582
7586
|
var v2_6 = major === 2 && minor >= 6;
|
|
7583
7587
|
var v1_10 = major === 1 && minor >= 10;
|
|
7584
|
-
/*
|
|
7588
|
+
/* oxlint-enable instantsearch/naming-convention */ return v3 || v2_6 || v1_10;
|
|
7585
7589
|
}
|
|
7586
7590
|
/**
|
|
7587
7591
|
* While `search-insights` supports both string and number user tokens,
|
|
@@ -9040,6 +9044,38 @@
|
|
|
9040
9044
|
return states;
|
|
9041
9045
|
}
|
|
9042
9046
|
|
|
9047
|
+
/**
|
|
9048
|
+
* Forwards the insights-related search parameters to every Recommend query.
|
|
9049
|
+
*
|
|
9050
|
+
* The insights middleware writes `userToken` and `clickAnalytics` on the main
|
|
9051
|
+
* helper's search state, which only feeds search queries: Recommend queries are
|
|
9052
|
+
* built from their own parameters and never read the search state. Without this,
|
|
9053
|
+
* recommendations can't be personalized, and their responses carry no `queryID`
|
|
9054
|
+
* for the connectors to attribute click and conversion events with.
|
|
9055
|
+
*
|
|
9056
|
+
* Parameters set on a widget win, so an explicit `queryParameters.userToken`
|
|
9057
|
+
* keeps overriding the middleware.
|
|
9058
|
+
*/ function addInsightsToRecommendParameters(recommendParameters, param) {
|
|
9059
|
+
var userToken = param.userToken, clickAnalytics = param.clickAnalytics;
|
|
9060
|
+
if (userToken === undefined && clickAnalytics === undefined) {
|
|
9061
|
+
return recommendParameters;
|
|
9062
|
+
}
|
|
9063
|
+
return new algoliasearchHelper.RecommendParameters({
|
|
9064
|
+
params: recommendParameters.params.map(function(params) {
|
|
9065
|
+
// v4 `TrendingFacetsQuery` doesn't include `queryParameters`, but the v5
|
|
9066
|
+
// API and the helper support them, like `connectTrendingFacets` does.
|
|
9067
|
+
var queryParameters = params.queryParameters;
|
|
9068
|
+
return _object_spread_props(_object_spread({}, params), {
|
|
9069
|
+
queryParameters: _object_spread({}, clickAnalytics === undefined ? {} : {
|
|
9070
|
+
clickAnalytics: clickAnalytics
|
|
9071
|
+
}, userToken === undefined ? {} : {
|
|
9072
|
+
userToken: userToken
|
|
9073
|
+
}, queryParameters)
|
|
9074
|
+
});
|
|
9075
|
+
})
|
|
9076
|
+
});
|
|
9077
|
+
}
|
|
9078
|
+
|
|
9043
9079
|
function createDocumentationLink(param) {
|
|
9044
9080
|
var name = param.name, _param_connector = param.connector, connector = _param_connector === void 0 ? false : _param_connector;
|
|
9045
9081
|
return [
|
|
@@ -9324,12 +9360,13 @@
|
|
|
9324
9360
|
instantSearchInstance._hasRecommendWidget = hasRecommendWidget;
|
|
9325
9361
|
}
|
|
9326
9362
|
var index = function index(widgetParams) {
|
|
9327
|
-
|
|
9363
|
+
var _widgetParams_EXPERIMENTAL_isolated;
|
|
9364
|
+
if (widgetParams === undefined || widgetParams.indexName === undefined && !widgetParams.isolated && !widgetParams.EXPERIMENTAL_isolated) {
|
|
9328
9365
|
throw new Error(withUsage$K('The `indexName` option is required.'));
|
|
9329
9366
|
}
|
|
9330
9367
|
// When isolated=true, we use an empty string as the default indexName.
|
|
9331
9368
|
// This is intentional: isolated indices do not require a real index name.
|
|
9332
|
-
var _widgetParams_indexName = widgetParams.indexName, indexName = _widgetParams_indexName === void 0 ? '' : _widgetParams_indexName, _widgetParams_indexId = widgetParams.indexId, indexId = _widgetParams_indexId === void 0 ? indexName : _widgetParams_indexId,
|
|
9369
|
+
var _widgetParams_indexName = widgetParams.indexName, indexName = _widgetParams_indexName === void 0 ? '' : _widgetParams_indexName, _widgetParams_indexId = widgetParams.indexId, indexId = _widgetParams_indexId === void 0 ? indexName : _widgetParams_indexId, _widgetParams_isolated = widgetParams.isolated, isolated = _widgetParams_isolated === void 0 ? (_widgetParams_EXPERIMENTAL_isolated = widgetParams.EXPERIMENTAL_isolated) !== null && _widgetParams_EXPERIMENTAL_isolated !== void 0 ? _widgetParams_EXPERIMENTAL_isolated : false : _widgetParams_isolated;
|
|
9333
9370
|
var localWidgets = [];
|
|
9334
9371
|
var localUiState = {};
|
|
9335
9372
|
var localInstantSearchInstance = null;
|
|
@@ -9617,7 +9654,7 @@
|
|
|
9617
9654
|
mainHelper.state
|
|
9618
9655
|
].concat(_to_consumable_array(resolveSearchParameters(_this))));
|
|
9619
9656
|
}, function() {
|
|
9620
|
-
return _this.getHelper().recommendState;
|
|
9657
|
+
return addInsightsToRecommendParameters(_this.getHelper().recommendState, mainHelper.state);
|
|
9621
9658
|
});
|
|
9622
9659
|
var indexInitialResults = (_instantSearchInstance__initialResults = instantSearchInstance._initialResults) === null || _instantSearchInstance__initialResults === void 0 ? void 0 : _instantSearchInstance__initialResults[this.getIndexId()];
|
|
9623
9660
|
if (indexInitialResults === null || indexInitialResults === void 0 ? void 0 : indexInitialResults.results) {
|
|
@@ -11410,6 +11447,22 @@
|
|
|
11410
11447
|
};
|
|
11411
11448
|
}
|
|
11412
11449
|
|
|
11450
|
+
function updateNavigationButtonsProps(param) {
|
|
11451
|
+
var listRef = param.listRef, nextButtonRef = param.nextButtonRef, previousButtonRef = param.previousButtonRef, setCanScrollLeft = param.setCanScrollLeft, setCanScrollRight = param.setCanScrollRight;
|
|
11452
|
+
if (!listRef.current) {
|
|
11453
|
+
return;
|
|
11454
|
+
}
|
|
11455
|
+
var isLeftHidden = listRef.current.scrollLeft <= 0;
|
|
11456
|
+
var isRightHidden = listRef.current.scrollLeft + listRef.current.clientWidth >= listRef.current.scrollWidth;
|
|
11457
|
+
setCanScrollLeft(!isLeftHidden);
|
|
11458
|
+
setCanScrollRight(!isRightHidden);
|
|
11459
|
+
if (previousButtonRef.current) {
|
|
11460
|
+
previousButtonRef.current.hidden = isLeftHidden;
|
|
11461
|
+
}
|
|
11462
|
+
if (nextButtonRef.current) {
|
|
11463
|
+
nextButtonRef.current.hidden = isRightHidden;
|
|
11464
|
+
}
|
|
11465
|
+
}
|
|
11413
11466
|
var lastCarouselId = 0;
|
|
11414
11467
|
function generateCarouselId() {
|
|
11415
11468
|
return "ais-Carousel-".concat(lastCarouselId++);
|
|
@@ -11443,7 +11496,7 @@
|
|
|
11443
11496
|
}));
|
|
11444
11497
|
}
|
|
11445
11498
|
function createCarouselComponent(param) {
|
|
11446
|
-
var createElement = param.createElement, Fragment = param.Fragment;
|
|
11499
|
+
var createElement = param.createElement, Fragment = param.Fragment, useEffect = param.useEffect, useRef = param.useRef;
|
|
11447
11500
|
return function Carousel(userProps) {
|
|
11448
11501
|
var listRef = userProps.listRef, nextButtonRef = userProps.nextButtonRef, previousButtonRef = userProps.previousButtonRef, carouselIdRef = userProps.carouselIdRef, canScrollLeft = userProps.canScrollLeft, canScrollRight = userProps.canScrollRight, setCanScrollLeft = userProps.setCanScrollLeft, setCanScrollRight = userProps.setCanScrollRight, _userProps_classNames = userProps.classNames, classNames = _userProps_classNames === void 0 ? {} : _userProps_classNames, tmp = userProps.itemComponent, ItemComponent = tmp === void 0 ? createDefaultItemComponent({
|
|
11449
11502
|
createElement: createElement,
|
|
@@ -11474,6 +11527,7 @@
|
|
|
11474
11527
|
previousButtonLabel: 'Previous',
|
|
11475
11528
|
previousButtonTitle: 'Previous'
|
|
11476
11529
|
}, userTranslations);
|
|
11530
|
+
var previousItemsLengthRef = useRef(items.length);
|
|
11477
11531
|
var cssClasses = {
|
|
11478
11532
|
root: cx('ais-Carousel', classNames.root),
|
|
11479
11533
|
list: cx('ais-Carousel-list', classNames.list),
|
|
@@ -11492,27 +11546,33 @@
|
|
|
11492
11546
|
listRef.current.scrollLeft += listRef.current.offsetWidth * 0.75;
|
|
11493
11547
|
}
|
|
11494
11548
|
}
|
|
11495
|
-
function
|
|
11496
|
-
if (
|
|
11497
|
-
|
|
11498
|
-
|
|
11499
|
-
|
|
11500
|
-
|
|
11501
|
-
|
|
11502
|
-
|
|
11503
|
-
|
|
11504
|
-
|
|
11505
|
-
}
|
|
11506
|
-
if (nextButtonRef.current) {
|
|
11507
|
-
nextButtonRef.current.hidden = isRightHidden;
|
|
11549
|
+
useEffect(function() {
|
|
11550
|
+
if (previousItemsLengthRef.current !== items.length) {
|
|
11551
|
+
updateNavigationButtonsProps({
|
|
11552
|
+
listRef: listRef,
|
|
11553
|
+
nextButtonRef: nextButtonRef,
|
|
11554
|
+
previousButtonRef: previousButtonRef,
|
|
11555
|
+
setCanScrollLeft: setCanScrollLeft,
|
|
11556
|
+
setCanScrollRight: setCanScrollRight
|
|
11557
|
+
});
|
|
11558
|
+
previousItemsLengthRef.current = items.length;
|
|
11508
11559
|
}
|
|
11509
|
-
}
|
|
11560
|
+
}, [
|
|
11561
|
+
items.length,
|
|
11562
|
+
listRef,
|
|
11563
|
+
nextButtonRef,
|
|
11564
|
+
previousButtonRef,
|
|
11565
|
+
setCanScrollLeft,
|
|
11566
|
+
setCanScrollRight
|
|
11567
|
+
]);
|
|
11510
11568
|
if (items.length === 0) {
|
|
11511
11569
|
return null;
|
|
11512
11570
|
}
|
|
11571
|
+
var itemOccurrences = new Map();
|
|
11513
11572
|
return /*#__PURE__*/ createElement("div", _object_spread_props(_object_spread({}, props), {
|
|
11514
11573
|
className: cx(cssClasses.root)
|
|
11515
11574
|
}), HeaderComponent && /*#__PURE__*/ createElement(HeaderComponent, {
|
|
11575
|
+
nbItems: items.length,
|
|
11516
11576
|
canScrollLeft: canScrollLeft,
|
|
11517
11577
|
canScrollRight: canScrollRight,
|
|
11518
11578
|
scrollLeft: scrollLeft,
|
|
@@ -11538,7 +11598,15 @@
|
|
|
11538
11598
|
"aria-roledescription": "carousel",
|
|
11539
11599
|
"aria-label": translations.listLabel,
|
|
11540
11600
|
"aria-live": "polite",
|
|
11541
|
-
onScroll:
|
|
11601
|
+
onScroll: function onScroll() {
|
|
11602
|
+
return updateNavigationButtonsProps({
|
|
11603
|
+
listRef: listRef,
|
|
11604
|
+
nextButtonRef: nextButtonRef,
|
|
11605
|
+
previousButtonRef: previousButtonRef,
|
|
11606
|
+
setCanScrollLeft: setCanScrollLeft,
|
|
11607
|
+
setCanScrollRight: setCanScrollRight
|
|
11608
|
+
});
|
|
11609
|
+
},
|
|
11542
11610
|
onKeyDown: function onKeyDown(event) {
|
|
11543
11611
|
if (event.key === 'ArrowLeft') {
|
|
11544
11612
|
event.preventDefault();
|
|
@@ -11549,8 +11617,14 @@
|
|
|
11549
11617
|
}
|
|
11550
11618
|
}
|
|
11551
11619
|
}, items.map(function(item, index) {
|
|
11620
|
+
var _itemOccurrences_get;
|
|
11621
|
+
var occurrence = (_itemOccurrences_get = itemOccurrences.get(item.objectID)) !== null && _itemOccurrences_get !== void 0 ? _itemOccurrences_get : 0;
|
|
11622
|
+
itemOccurrences.set(item.objectID, occurrence + 1);
|
|
11552
11623
|
return /*#__PURE__*/ createElement("li", {
|
|
11553
|
-
key:
|
|
11624
|
+
key: JSON.stringify([
|
|
11625
|
+
item.objectID,
|
|
11626
|
+
occurrence
|
|
11627
|
+
]),
|
|
11554
11628
|
className: cx(cssClasses.item),
|
|
11555
11629
|
"aria-roledescription": "slide",
|
|
11556
11630
|
"aria-label": "".concat(index + 1, " of ").concat(items.length),
|
|
@@ -11978,7 +12052,9 @@
|
|
|
11978
12052
|
|
|
11979
12053
|
var Carousel = createCarouselComponent({
|
|
11980
12054
|
createElement: h$1,
|
|
11981
|
-
Fragment: p$1
|
|
12055
|
+
Fragment: p$1,
|
|
12056
|
+
useEffect: s,
|
|
12057
|
+
useRef: A
|
|
11982
12058
|
});
|
|
11983
12059
|
function CarouselWithRefs(props) {
|
|
11984
12060
|
var _useState = _sliced_to_array(y(false), 2), canScrollLeft = _useState[0], setCanScrollLeft = _useState[1];
|
|
@@ -11997,28 +12073,31 @@
|
|
|
11997
12073
|
}
|
|
11998
12074
|
function carousel() {
|
|
11999
12075
|
var _ref = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, cssClasses = _ref.cssClasses, _ref_templates = _ref.templates, templates = _ref_templates === void 0 ? {} : _ref_templates, _ref_showNavigation = _ref.showNavigation, showNavigation = _ref_showNavigation === void 0 ? true : _ref_showNavigation;
|
|
12076
|
+
var previous = templates.previous, next = templates.next, header = templates.header;
|
|
12077
|
+
var HeaderComponent = header ? function(props) {
|
|
12078
|
+
return header(_object_spread({
|
|
12079
|
+
html: m$1
|
|
12080
|
+
}, props));
|
|
12081
|
+
} : undefined;
|
|
12082
|
+
var PreviousIconComponent = previous ? function() {
|
|
12083
|
+
return previous({
|
|
12084
|
+
html: m$1
|
|
12085
|
+
});
|
|
12086
|
+
} : undefined;
|
|
12087
|
+
var NextIconComponent = next ? function() {
|
|
12088
|
+
return next({
|
|
12089
|
+
html: m$1
|
|
12090
|
+
});
|
|
12091
|
+
} : undefined;
|
|
12000
12092
|
return function CarouselTemplate(param) {
|
|
12001
12093
|
var items = param.items, widgetTemplates = param.templates, tmp = param.cssClasses, widgetCssClasses = tmp === void 0 ? {} : tmp, _param_sendEvent = param.sendEvent, sendEvent = _param_sendEvent === void 0 ? function() {} : _param_sendEvent;
|
|
12002
|
-
var previous = templates.previous, next = templates.next, header = templates.header;
|
|
12003
12094
|
return /*#__PURE__*/ h$1(CarouselWithRefs, {
|
|
12004
12095
|
items: items,
|
|
12005
12096
|
sendEvent: sendEvent,
|
|
12006
12097
|
itemComponent: widgetTemplates.item,
|
|
12007
|
-
headerComponent:
|
|
12008
|
-
|
|
12009
|
-
|
|
12010
|
-
}, props));
|
|
12011
|
-
} : undefined,
|
|
12012
|
-
previousIconComponent: previous ? function() {
|
|
12013
|
-
return previous({
|
|
12014
|
-
html: m$1
|
|
12015
|
-
});
|
|
12016
|
-
} : undefined,
|
|
12017
|
-
nextIconComponent: next ? function() {
|
|
12018
|
-
return next({
|
|
12019
|
-
html: m$1
|
|
12020
|
-
});
|
|
12021
|
-
} : undefined,
|
|
12098
|
+
headerComponent: HeaderComponent,
|
|
12099
|
+
previousIconComponent: PreviousIconComponent,
|
|
12100
|
+
nextIconComponent: NextIconComponent,
|
|
12022
12101
|
classNames: _object_spread({}, cssClasses, {
|
|
12023
12102
|
list: cx(cssClasses === null || cssClasses === void 0 ? void 0 : cssClasses.list, widgetCssClasses === null || widgetCssClasses === void 0 ? void 0 : widgetCssClasses.list),
|
|
12024
12103
|
item: cx(cssClasses === null || cssClasses === void 0 ? void 0 : cssClasses.item, widgetCssClasses === null || widgetCssClasses === void 0 ? void 0 : widgetCssClasses.item)
|
|
@@ -13280,7 +13359,7 @@
|
|
|
13280
13359
|
// it is non-empty and the chat is not already processing a message.
|
|
13281
13360
|
// Returns true when a message was submitted, so callers can clear their input.
|
|
13282
13361
|
function openChat(chatRenderState) {
|
|
13283
|
-
var _ref = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, message = _ref.message, referer = _ref.referer;
|
|
13362
|
+
var _ref = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, message = _ref.message, referer = _ref.referer, turnContext = _ref.turnContext;
|
|
13284
13363
|
var _ref1;
|
|
13285
13364
|
var _chatRenderState_setOpen;
|
|
13286
13365
|
if (!chatRenderState) {
|
|
@@ -13296,9 +13375,13 @@
|
|
|
13296
13375
|
if (isChatBusy(chatRenderState) || !chatRenderState.sendMessage) {
|
|
13297
13376
|
return false;
|
|
13298
13377
|
}
|
|
13299
|
-
chatRenderState.sendMessage({
|
|
13378
|
+
chatRenderState.sendMessage(_object_spread({
|
|
13300
13379
|
text: trimmed
|
|
13301
|
-
},
|
|
13380
|
+
}, turnContext ? {
|
|
13381
|
+
metadata: {
|
|
13382
|
+
turnContext: turnContext
|
|
13383
|
+
}
|
|
13384
|
+
} : {}), referer ? {
|
|
13302
13385
|
headers: {
|
|
13303
13386
|
'x-algolia-referer': referer
|
|
13304
13387
|
}
|