instantsearch.js 4.58.0 → 4.59.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/README.md +1 -1
- package/cjs/components/Pagination/Pagination.js +4 -4
- package/cjs/components/RefinementList/RefinementList.js +2 -1
- package/cjs/components/SearchBox/SearchBox.js +5 -2
- package/cjs/components/Selector/Selector.js +4 -2
- package/cjs/components/Slider/Slider.js +3 -1
- package/cjs/lib/InstantSearch.js +26 -5
- package/cjs/lib/utils/createSendEventForFacet.js +12 -5
- package/cjs/lib/utils/createSendEventForHits.js +12 -6
- package/cjs/lib/version.js +1 -1
- package/cjs/middlewares/createInsightsMiddleware.js +15 -4
- package/cjs/widgets/sort-by/sort-by.js +2 -1
- package/dist/instantsearch.development.d.ts +4 -3
- package/dist/instantsearch.development.js +78 -34
- package/dist/instantsearch.development.js.map +1 -1
- package/dist/instantsearch.production.d.ts +4 -3
- package/dist/instantsearch.production.min.d.ts +4 -3
- package/dist/instantsearch.production.min.js +2 -2
- package/dist/instantsearch.production.min.js.map +1 -1
- package/es/components/Pagination/Pagination.js +4 -4
- package/es/components/RefinementList/RefinementList.js +2 -1
- package/es/components/SearchBox/SearchBox.d.ts +3 -0
- package/es/components/SearchBox/SearchBox.js +5 -2
- package/es/components/Selector/Selector.d.ts +2 -1
- package/es/components/Selector/Selector.js +4 -2
- package/es/components/Slider/Slider.js +3 -1
- package/es/lib/InstantSearch.d.ts +1 -0
- package/es/lib/InstantSearch.js +26 -5
- package/es/lib/utils/createSendEventForFacet.d.ts +1 -1
- package/es/lib/utils/createSendEventForFacet.js +12 -5
- package/es/lib/utils/createSendEventForHits.d.ts +2 -2
- package/es/lib/utils/createSendEventForHits.js +12 -6
- package/es/lib/version.d.ts +1 -1
- package/es/lib/version.js +1 -1
- package/es/middlewares/createInsightsMiddleware.js +15 -4
- package/es/widgets/sort-by/sort-by.js +2 -1
- package/package.json +6 -6
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! InstantSearch.js 4.
|
|
1
|
+
/*! InstantSearch.js 4.59.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) :
|
|
@@ -752,7 +752,9 @@
|
|
|
752
752
|
}
|
|
753
753
|
var facetValue = args[1],
|
|
754
754
|
_args$ = args[2],
|
|
755
|
-
eventName = _args$ === void 0 ? 'Filter Applied' : _args
|
|
755
|
+
eventName = _args$ === void 0 ? 'Filter Applied' : _args$,
|
|
756
|
+
_args$2 = args[3],
|
|
757
|
+
additionalData = _args$2 === void 0 ? {} : _args$2;
|
|
756
758
|
var _args$0$split = args[0].split(':'),
|
|
757
759
|
_args$0$split2 = _slicedToArray(_args$0$split, 2),
|
|
758
760
|
eventType = _args$0$split2[0],
|
|
@@ -760,7 +762,7 @@
|
|
|
760
762
|
var attribute = typeof attr === 'string' ? attr : attr(facetValue);
|
|
761
763
|
if (args.length === 1 && _typeof(args[0]) === 'object') {
|
|
762
764
|
instantSearchInstance.sendEventToInsights(args[0]);
|
|
763
|
-
} else if (eventType === 'click' &&
|
|
765
|
+
} else if (eventType === 'click' && args.length >= 2 && args.length <= 4) {
|
|
764
766
|
if (!isFacetRefined(helper, attribute, facetValue)) {
|
|
765
767
|
// send event only when the facet is being checked "ON"
|
|
766
768
|
instantSearchInstance.sendEventToInsights({
|
|
@@ -768,16 +770,16 @@
|
|
|
768
770
|
widgetType: widgetType,
|
|
769
771
|
eventType: eventType,
|
|
770
772
|
eventModifier: eventModifier,
|
|
771
|
-
payload: {
|
|
773
|
+
payload: _objectSpread2({
|
|
772
774
|
eventName: eventName,
|
|
773
775
|
index: helper.getIndex(),
|
|
774
776
|
filters: ["".concat(attribute, ":").concat(facetValue)]
|
|
775
|
-
},
|
|
777
|
+
}, additionalData),
|
|
776
778
|
attribute: attribute
|
|
777
779
|
});
|
|
778
780
|
}
|
|
779
781
|
} else {
|
|
780
|
-
throw new Error("You need to pass two arguments like:\n sendEvent('click', facetValue);\n\nIf you want to send a custom payload, you can pass one object: sendEvent(customPayload);\n");
|
|
782
|
+
throw new Error("You need to pass between two and four arguments like:\n sendEvent('click', facetValue, eventName?, additionalData?);\n\nIf you want to send a custom payload, you can pass one object: sendEvent(customPayload);\n");
|
|
781
783
|
}
|
|
782
784
|
};
|
|
783
785
|
return sendEventForFacet;
|
|
@@ -814,6 +816,7 @@
|
|
|
814
816
|
eventModifier = _args$0$split2[1];
|
|
815
817
|
var hits = args[1];
|
|
816
818
|
var eventName = args[2];
|
|
819
|
+
var additionalData = args[3] || {};
|
|
817
820
|
if (!hits) {
|
|
818
821
|
{
|
|
819
822
|
throw new Error("You need to pass hit or hits as the second argument like:\n ".concat(methodName, "(eventType, hit);\n "));
|
|
@@ -849,11 +852,11 @@
|
|
|
849
852
|
insightsMethod: 'viewedObjectIDs',
|
|
850
853
|
widgetType: widgetType,
|
|
851
854
|
eventType: eventType,
|
|
852
|
-
payload: {
|
|
855
|
+
payload: _objectSpread2({
|
|
853
856
|
eventName: eventName || 'Hits Viewed',
|
|
854
857
|
index: index,
|
|
855
858
|
objectIDs: objectIDsByChunk[i]
|
|
856
|
-
},
|
|
859
|
+
}, additionalData),
|
|
857
860
|
hits: batch,
|
|
858
861
|
eventModifier: eventModifier
|
|
859
862
|
};
|
|
@@ -864,13 +867,13 @@
|
|
|
864
867
|
insightsMethod: 'clickedObjectIDsAfterSearch',
|
|
865
868
|
widgetType: widgetType,
|
|
866
869
|
eventType: eventType,
|
|
867
|
-
payload: {
|
|
870
|
+
payload: _objectSpread2({
|
|
868
871
|
eventName: eventName || 'Hit Clicked',
|
|
869
872
|
index: index,
|
|
870
873
|
queryID: queryID,
|
|
871
874
|
objectIDs: objectIDsByChunk[i],
|
|
872
875
|
positions: positionsByChunk[i]
|
|
873
|
-
},
|
|
876
|
+
}, additionalData),
|
|
874
877
|
hits: batch,
|
|
875
878
|
eventModifier: eventModifier
|
|
876
879
|
};
|
|
@@ -881,12 +884,12 @@
|
|
|
881
884
|
insightsMethod: 'convertedObjectIDsAfterSearch',
|
|
882
885
|
widgetType: widgetType,
|
|
883
886
|
eventType: eventType,
|
|
884
|
-
payload: {
|
|
887
|
+
payload: _objectSpread2({
|
|
885
888
|
eventName: eventName || 'Hit Converted',
|
|
886
889
|
index: index,
|
|
887
890
|
queryID: queryID,
|
|
888
891
|
objectIDs: objectIDsByChunk[i]
|
|
889
|
-
},
|
|
892
|
+
}, additionalData),
|
|
890
893
|
hits: batch,
|
|
891
894
|
eventModifier: eventModifier
|
|
892
895
|
};
|
|
@@ -9911,7 +9914,7 @@
|
|
|
9911
9914
|
|
|
9912
9915
|
var SearchResults_1 = SearchResults;
|
|
9913
9916
|
|
|
9914
|
-
var version = '3.
|
|
9917
|
+
var version = '3.15.0';
|
|
9915
9918
|
|
|
9916
9919
|
var escapeFacetValue$4 = escapeFacetValue_1.escapeFacetValue;
|
|
9917
9920
|
|
|
@@ -12554,7 +12557,9 @@
|
|
|
12554
12557
|
insightsInitParams = props.insightsInitParams,
|
|
12555
12558
|
onEvent = props.onEvent,
|
|
12556
12559
|
_props$$$internal = props.$$internal,
|
|
12557
|
-
$$internal = _props$$$internal === void 0 ? false : _props$$$internal
|
|
12560
|
+
$$internal = _props$$$internal === void 0 ? false : _props$$$internal,
|
|
12561
|
+
_props$$$automatic = props.$$automatic,
|
|
12562
|
+
$$automatic = _props$$$automatic === void 0 ? false : _props$$$automatic;
|
|
12558
12563
|
var potentialInsightsClient = _insightsClient;
|
|
12559
12564
|
if (!_insightsClient && _insightsClient !== null) {
|
|
12560
12565
|
safelyRunOnBrowser(function (_ref) {
|
|
@@ -12645,6 +12650,7 @@
|
|
|
12645
12650
|
return {
|
|
12646
12651
|
$$type: 'ais.insights',
|
|
12647
12652
|
$$internal: $$internal,
|
|
12653
|
+
$$automatic: $$automatic,
|
|
12648
12654
|
onStateChange: function onStateChange() {},
|
|
12649
12655
|
subscribe: function subscribe() {
|
|
12650
12656
|
if (!insightsClient.shouldAddScript) return;
|
|
@@ -12670,9 +12676,14 @@
|
|
|
12670
12676
|
userToken: helper.state.userToken,
|
|
12671
12677
|
clickAnalytics: helper.state.clickAnalytics
|
|
12672
12678
|
};
|
|
12673
|
-
|
|
12674
|
-
|
|
12675
|
-
|
|
12679
|
+
|
|
12680
|
+
// We don't want to force clickAnalytics when the insights is enabled from the search response.
|
|
12681
|
+
// This means we don't enable insights for indices that don't opt in
|
|
12682
|
+
if (!$$automatic) {
|
|
12683
|
+
helper.overrideStateWithoutTriggeringChangeEvent(_objectSpread2(_objectSpread2({}, helper.state), {}, {
|
|
12684
|
+
clickAnalytics: true
|
|
12685
|
+
}));
|
|
12686
|
+
}
|
|
12676
12687
|
if (!$$internal) {
|
|
12677
12688
|
instantSearchInstance.scheduleSearch();
|
|
12678
12689
|
}
|
|
@@ -12739,6 +12750,9 @@
|
|
|
12739
12750
|
} else if (event.insightsMethod) {
|
|
12740
12751
|
// Source is used to differentiate events sent by instantsearch from those sent manually.
|
|
12741
12752
|
event.payload.algoliaSource = ['instantsearch'];
|
|
12753
|
+
if ($$automatic) {
|
|
12754
|
+
event.payload.algoliaSource.push('instantsearch-automatic');
|
|
12755
|
+
}
|
|
12742
12756
|
if (event.eventModifier === 'internal') {
|
|
12743
12757
|
event.payload.algoliaSource.push('instantsearch-internal');
|
|
12744
12758
|
}
|
|
@@ -14626,7 +14640,7 @@
|
|
|
14626
14640
|
};
|
|
14627
14641
|
}
|
|
14628
14642
|
|
|
14629
|
-
var version$1 = '4.
|
|
14643
|
+
var version$1 = '4.59.0';
|
|
14630
14644
|
|
|
14631
14645
|
var withUsage$r = createDocumentationMessageGenerator({
|
|
14632
14646
|
name: 'instantsearch'
|
|
@@ -14678,6 +14692,7 @@
|
|
|
14678
14692
|
_defineProperty(_assertThisInitialized(_this), "_createURL", void 0);
|
|
14679
14693
|
_defineProperty(_assertThisInitialized(_this), "_searchFunction", void 0);
|
|
14680
14694
|
_defineProperty(_assertThisInitialized(_this), "_mainHelperSearch", void 0);
|
|
14695
|
+
_defineProperty(_assertThisInitialized(_this), "_insights", void 0);
|
|
14681
14696
|
_defineProperty(_assertThisInitialized(_this), "middleware", []);
|
|
14682
14697
|
_defineProperty(_assertThisInitialized(_this), "sendEventToInsights", void 0);
|
|
14683
14698
|
/**
|
|
@@ -14728,7 +14743,7 @@
|
|
|
14728
14743
|
_options$routing = options.routing,
|
|
14729
14744
|
routing = _options$routing === void 0 ? null : _options$routing,
|
|
14730
14745
|
_options$insights = options.insights,
|
|
14731
|
-
insights = _options$insights === void 0 ?
|
|
14746
|
+
insights = _options$insights === void 0 ? undefined : _options$insights,
|
|
14732
14747
|
searchFunction = options.searchFunction,
|
|
14733
14748
|
_options$stalledSearc = options.stalledSearchDelay,
|
|
14734
14749
|
stalledSearchDelay = _options$stalledSearc === void 0 ? 200 : _options$stalledSearc,
|
|
@@ -14784,6 +14799,7 @@
|
|
|
14784
14799
|
_this._createURL = defaultCreateURL;
|
|
14785
14800
|
_this._initialUiState = initialUiState;
|
|
14786
14801
|
_this._initialResults = null;
|
|
14802
|
+
_this._insights = insights;
|
|
14787
14803
|
if (searchFunction) {
|
|
14788
14804
|
_warning(false, "The `searchFunction` option is deprecated. Use `onStateChange` instead.") ;
|
|
14789
14805
|
_this._searchFunction = searchFunction;
|
|
@@ -14795,8 +14811,9 @@
|
|
|
14795
14811
|
_this.use(createRouterMiddleware(routerOptions));
|
|
14796
14812
|
}
|
|
14797
14813
|
|
|
14798
|
-
// This is the default middleware,
|
|
14799
|
-
//
|
|
14814
|
+
// This is the default Insights middleware,
|
|
14815
|
+
// added when `insights` is set to true by the user.
|
|
14816
|
+
// Any user-provided middleware will be added later and override this one.
|
|
14800
14817
|
if (insights) {
|
|
14801
14818
|
var insightsOptions = typeof insights === 'boolean' ? {} : insights;
|
|
14802
14819
|
insightsOptions.$$internal = true;
|
|
@@ -15088,6 +15105,24 @@
|
|
|
15088
15105
|
var instance = _ref6.instance;
|
|
15089
15106
|
instance.started();
|
|
15090
15107
|
});
|
|
15108
|
+
|
|
15109
|
+
// This is the automatic Insights middleware,
|
|
15110
|
+
// added when `insights` is unset and the initial results possess `queryID`.
|
|
15111
|
+
// Any user-provided middleware will be added later and override this one.
|
|
15112
|
+
if (typeof this._insights === 'undefined') {
|
|
15113
|
+
mainHelper.derivedHelpers[0].once('result', function () {
|
|
15114
|
+
var hasAutomaticInsights = _this3.mainIndex.getScopedResults().some(function (_ref7) {
|
|
15115
|
+
var results = _ref7.results;
|
|
15116
|
+
return results === null || results === void 0 ? void 0 : results._automaticInsights;
|
|
15117
|
+
});
|
|
15118
|
+
if (hasAutomaticInsights) {
|
|
15119
|
+
_this3.use(createInsightsMiddleware({
|
|
15120
|
+
$$internal: true,
|
|
15121
|
+
$$automatic: true
|
|
15122
|
+
}));
|
|
15123
|
+
}
|
|
15124
|
+
});
|
|
15125
|
+
}
|
|
15091
15126
|
}
|
|
15092
15127
|
|
|
15093
15128
|
/**
|
|
@@ -15117,8 +15152,8 @@
|
|
|
15117
15152
|
(_this$mainHelper2 = this.mainHelper) === null || _this$mainHelper2 === void 0 ? void 0 : _this$mainHelper2.removeAllListeners();
|
|
15118
15153
|
this.mainHelper = null;
|
|
15119
15154
|
this.helper = null;
|
|
15120
|
-
this.middleware.forEach(function (
|
|
15121
|
-
var instance =
|
|
15155
|
+
this.middleware.forEach(function (_ref8) {
|
|
15156
|
+
var instance = _ref8.instance;
|
|
15122
15157
|
instance.unsubscribe();
|
|
15123
15158
|
});
|
|
15124
15159
|
}
|
|
@@ -17756,6 +17791,7 @@
|
|
|
17756
17791
|
searchAsYouType: true,
|
|
17757
17792
|
isSearchStalled: false,
|
|
17758
17793
|
disabled: false,
|
|
17794
|
+
ariaLabel: 'Search',
|
|
17759
17795
|
onChange: noop,
|
|
17760
17796
|
onSubmit: noop,
|
|
17761
17797
|
onReset: noop,
|
|
@@ -17872,7 +17908,8 @@
|
|
|
17872
17908
|
showReset = _this$props4.showReset,
|
|
17873
17909
|
showLoadingIndicator = _this$props4.showLoadingIndicator,
|
|
17874
17910
|
templates = _this$props4.templates,
|
|
17875
|
-
isSearchStalled = _this$props4.isSearchStalled
|
|
17911
|
+
isSearchStalled = _this$props4.isSearchStalled,
|
|
17912
|
+
ariaLabel = _this$props4.ariaLabel;
|
|
17876
17913
|
return h("div", {
|
|
17877
17914
|
className: cssClasses.root
|
|
17878
17915
|
}, h("form", {
|
|
@@ -17899,7 +17936,8 @@
|
|
|
17899
17936
|
maxLength: 512,
|
|
17900
17937
|
onInput: this.onInput,
|
|
17901
17938
|
onBlur: this.onBlur,
|
|
17902
|
-
onFocus: this.onFocus
|
|
17939
|
+
onFocus: this.onFocus,
|
|
17940
|
+
"aria-label": ariaLabel
|
|
17903
17941
|
}), h(Template, {
|
|
17904
17942
|
templateKey: "submit",
|
|
17905
17943
|
rootTagName: "button",
|
|
@@ -18148,7 +18186,8 @@
|
|
|
18148
18186
|
// This sets the search box to a controlled state because
|
|
18149
18187
|
// we don't rely on the `refine` prop but on `onChange`.
|
|
18150
18188
|
,
|
|
18151
|
-
searchAsYouType: false
|
|
18189
|
+
searchAsYouType: false,
|
|
18190
|
+
ariaLabel: "Search for filters"
|
|
18152
18191
|
}));
|
|
18153
18192
|
var facetValues = this.props.facetValues && this.props.facetValues.length > 0 && h("ul", {
|
|
18154
18193
|
className: this.props.cssClasses.list
|
|
@@ -18517,13 +18556,15 @@
|
|
|
18517
18556
|
var currentValue = _ref.currentValue,
|
|
18518
18557
|
options = _ref.options,
|
|
18519
18558
|
cssClasses = _ref.cssClasses,
|
|
18520
|
-
setValue = _ref.setValue
|
|
18559
|
+
setValue = _ref.setValue,
|
|
18560
|
+
ariaLabel = _ref.ariaLabel;
|
|
18521
18561
|
return h("select", {
|
|
18522
18562
|
className: cx(cssClasses.select),
|
|
18523
18563
|
onChange: function onChange(event) {
|
|
18524
18564
|
return setValue(event.target.value);
|
|
18525
18565
|
},
|
|
18526
|
-
value: "".concat(currentValue)
|
|
18566
|
+
value: "".concat(currentValue),
|
|
18567
|
+
"aria-label": ariaLabel
|
|
18527
18568
|
}, options.map(function (option) {
|
|
18528
18569
|
return h("option", {
|
|
18529
18570
|
className: cx(cssClasses.option),
|
|
@@ -19183,7 +19224,7 @@
|
|
|
19183
19224
|
}, h("ul", {
|
|
19184
19225
|
className: props.cssClasses.list
|
|
19185
19226
|
}, props.showFirst && h(PaginationLink, {
|
|
19186
|
-
ariaLabel: "First",
|
|
19227
|
+
ariaLabel: "First Page",
|
|
19187
19228
|
className: props.cssClasses.firstPageItem,
|
|
19188
19229
|
isDisabled: props.isFirstPage,
|
|
19189
19230
|
templates: props.templates,
|
|
@@ -19193,7 +19234,7 @@
|
|
|
19193
19234
|
cssClasses: props.cssClasses,
|
|
19194
19235
|
createClickHandler: createClickHandler
|
|
19195
19236
|
}), props.showPrevious && h(PaginationLink, {
|
|
19196
|
-
ariaLabel: "Previous",
|
|
19237
|
+
ariaLabel: "Previous Page",
|
|
19197
19238
|
className: props.cssClasses.previousPageItem,
|
|
19198
19239
|
isDisabled: props.isFirstPage,
|
|
19199
19240
|
templates: props.templates,
|
|
@@ -19216,7 +19257,7 @@
|
|
|
19216
19257
|
createClickHandler: createClickHandler
|
|
19217
19258
|
});
|
|
19218
19259
|
}), props.showNext && h(PaginationLink, {
|
|
19219
|
-
ariaLabel: "Next",
|
|
19260
|
+
ariaLabel: "Next Page",
|
|
19220
19261
|
className: props.cssClasses.nextPageItem,
|
|
19221
19262
|
isDisabled: props.isLastPage,
|
|
19222
19263
|
templates: props.templates,
|
|
@@ -19226,7 +19267,7 @@
|
|
|
19226
19267
|
cssClasses: props.cssClasses,
|
|
19227
19268
|
createClickHandler: createClickHandler
|
|
19228
19269
|
}), props.showLast && h(PaginationLink, {
|
|
19229
|
-
ariaLabel: "Last",
|
|
19270
|
+
ariaLabel: "Last Page, Page ".concat(props.nbPages),
|
|
19230
19271
|
className: props.cssClasses.lastPageItem,
|
|
19231
19272
|
isDisabled: props.isLastPage,
|
|
19232
19273
|
templates: props.templates,
|
|
@@ -20723,8 +20764,10 @@
|
|
|
20723
20764
|
parseFloat(props['aria-valuenow']) * 100) / 100;
|
|
20724
20765
|
var value = _typeof(tooltips) === 'object' && tooltips.format ? tooltips.format(roundedValue) : roundedValue;
|
|
20725
20766
|
var className = cx(props.className, props['data-handle-key'] === 0 && 'rheostat-handle-lower', props['data-handle-key'] === 1 && 'rheostat-handle-upper');
|
|
20767
|
+
var ariaLabel = props['data-handle-key'] === 0 ? 'Minimum Filter Handle' : 'Maximum Filter Handle';
|
|
20726
20768
|
return h("div", _extends({}, props, {
|
|
20727
|
-
className: className
|
|
20769
|
+
className: className,
|
|
20770
|
+
"aria-label": ariaLabel
|
|
20728
20771
|
}), tooltips && h("div", {
|
|
20729
20772
|
className: "rheostat-tooltip"
|
|
20730
20773
|
}, value));
|
|
@@ -21646,7 +21689,8 @@
|
|
|
21646
21689
|
cssClasses: cssClasses,
|
|
21647
21690
|
currentValue: currentRefinement,
|
|
21648
21691
|
options: options,
|
|
21649
|
-
setValue: refine
|
|
21692
|
+
setValue: refine,
|
|
21693
|
+
ariaLabel: "Sort results by"
|
|
21650
21694
|
})), containerNode);
|
|
21651
21695
|
};
|
|
21652
21696
|
};
|