instantsearch.js 4.54.0 → 4.55.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/Hits/Hits.js +16 -7
- package/cjs/components/InfiniteHits/InfiniteHits.js +13 -2
- package/cjs/components/Pagination/Pagination.js +35 -17
- package/cjs/components/Template/Template.js +6 -3
- package/cjs/connectors/autocomplete/connectAutocomplete.js +1 -1
- package/cjs/connectors/geo-search/connectGeoSearch.js +1 -1
- package/cjs/connectors/hierarchical-menu/connectHierarchicalMenu.js +1 -1
- package/cjs/connectors/hits/connectHits.js +1 -1
- package/cjs/connectors/infinite-hits/connectInfiniteHits.js +39 -31
- package/cjs/connectors/menu/connectMenu.js +1 -1
- package/cjs/connectors/numeric-menu/connectNumericMenu.js +1 -1
- package/cjs/connectors/rating-menu/connectRatingMenu.js +7 -3
- package/cjs/connectors/refinement-list/connectRefinementList.js +1 -1
- package/cjs/connectors/toggle-refinement/connectToggleRefinement.js +14 -4
- package/cjs/helpers/highlight.js +5 -0
- package/cjs/helpers/insights.js +3 -4
- package/cjs/helpers/reverseHighlight.js +5 -0
- package/cjs/helpers/reverseSnippet.js +5 -0
- package/cjs/helpers/snippet.js +5 -0
- package/cjs/lib/InstantSearch.js +18 -2
- package/cjs/lib/insights/listener.js +43 -36
- package/cjs/lib/routers/history.js +1 -0
- package/cjs/lib/server.js +60 -0
- package/cjs/lib/stateMappings/simple.js +1 -0
- package/cjs/lib/stateMappings/singleIndex.js +1 -0
- package/cjs/lib/utils/createSendEventForFacet.js +12 -2
- package/cjs/lib/utils/createSendEventForHits.js +34 -11
- package/cjs/lib/utils/index.js +11 -0
- package/cjs/lib/utils/walkIndex.js +18 -0
- package/cjs/lib/version.js +1 -1
- package/cjs/middlewares/createInsightsMiddleware.js +135 -33
- package/cjs/middlewares/createMetadataMiddleware.js +17 -5
- package/cjs/middlewares/createRouterMiddleware.js +5 -1
- package/cjs/widgets/hits/hits.js +1 -2
- package/cjs/widgets/infinite-hits/infinite-hits.js +1 -2
- package/cjs/widgets/pagination/pagination.js +51 -39
- package/cjs/widgets/panel/panel.js +0 -2
- package/dist/instantsearch.development.d.ts +94 -12
- package/dist/instantsearch.development.js +543 -312
- package/dist/instantsearch.development.js.map +1 -1
- package/dist/instantsearch.production.d.ts +94 -12
- package/dist/instantsearch.production.min.d.ts +94 -12
- package/dist/instantsearch.production.min.js +2 -2
- package/dist/instantsearch.production.min.js.map +1 -1
- package/es/components/Hits/Hits.d.ts +5 -5
- package/es/components/Hits/Hits.js +15 -5
- package/es/components/InfiniteHits/InfiniteHits.d.ts +3 -2
- package/es/components/InfiniteHits/InfiniteHits.js +13 -2
- package/es/components/Pagination/Pagination.js +34 -17
- package/es/components/Panel/Panel.d.ts +1 -1
- package/es/components/Template/Template.js +6 -3
- package/es/connectors/autocomplete/connectAutocomplete.js +1 -1
- package/es/connectors/geo-search/connectGeoSearch.js +1 -1
- package/es/connectors/hierarchical-menu/connectHierarchicalMenu.js +1 -1
- package/es/connectors/hits/connectHits.js +1 -1
- package/es/connectors/infinite-hits/connectInfiniteHits.js +39 -31
- package/es/connectors/menu/connectMenu.js +1 -1
- package/es/connectors/numeric-menu/connectNumericMenu.js +1 -1
- package/es/connectors/rating-menu/connectRatingMenu.js +7 -3
- package/es/connectors/refinement-list/connectRefinementList.js +1 -1
- package/es/connectors/toggle-refinement/connectToggleRefinement.js +13 -3
- package/es/helpers/highlight.d.ts +3 -0
- package/es/helpers/highlight.js +5 -0
- package/es/helpers/insights.d.ts +2 -1
- package/es/helpers/insights.js +3 -3
- package/es/helpers/reverseHighlight.d.ts +3 -0
- package/es/helpers/reverseHighlight.js +5 -0
- package/es/helpers/reverseSnippet.d.ts +3 -0
- package/es/helpers/reverseSnippet.js +5 -0
- package/es/helpers/snippet.d.ts +3 -0
- package/es/helpers/snippet.js +5 -0
- package/es/lib/InstantSearch.d.ts +11 -1
- package/es/lib/InstantSearch.js +18 -2
- package/es/lib/insights/listener.d.ts +10 -6
- package/es/lib/insights/listener.js +42 -36
- package/es/lib/routers/history.d.ts +1 -0
- package/es/lib/routers/history.js +1 -0
- package/es/lib/server.d.ts +10 -0
- package/es/lib/server.js +53 -0
- package/es/lib/stateMappings/simple.js +1 -0
- package/es/lib/stateMappings/singleIndex.js +1 -0
- package/es/lib/utils/createSendEventForFacet.js +12 -2
- package/es/lib/utils/createSendEventForHits.d.ts +8 -0
- package/es/lib/utils/createSendEventForHits.js +33 -11
- package/es/lib/utils/index.d.ts +1 -0
- package/es/lib/utils/index.js +1 -0
- package/es/lib/utils/walkIndex.d.ts +5 -0
- package/es/lib/utils/walkIndex.js +12 -0
- package/es/lib/version.d.ts +1 -1
- package/es/lib/version.js +1 -1
- package/es/middlewares/createInsightsMiddleware.d.ts +12 -12
- package/es/middlewares/createInsightsMiddleware.js +136 -34
- package/es/middlewares/createMetadataMiddleware.d.ts +3 -1
- package/es/middlewares/createMetadataMiddleware.js +17 -5
- package/es/middlewares/createRouterMiddleware.js +5 -1
- package/es/types/insights.d.ts +19 -1
- package/es/types/middleware.d.ts +16 -0
- package/es/types/router.d.ts +8 -0
- package/es/widgets/hits/hits.js +2 -3
- package/es/widgets/infinite-hits/infinite-hits.js +2 -3
- package/es/widgets/pagination/pagination.d.ts +12 -5
- package/es/widgets/pagination/pagination.js +51 -39
- package/es/widgets/panel/panel.js +0 -2
- package/package.json +6 -6
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! InstantSearch.js 4.
|
|
1
|
+
/*! InstantSearch.js 4.55.0 | © Algolia, Inc. and contributors; MIT License | https://github.com/algolia/instantsearch.js */
|
|
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) :
|
|
@@ -748,10 +748,13 @@
|
|
|
748
748
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
749
749
|
args[_key] = arguments[_key];
|
|
750
750
|
}
|
|
751
|
-
var
|
|
752
|
-
facetValue = args[1],
|
|
751
|
+
var facetValue = args[1],
|
|
753
752
|
_args$ = args[2],
|
|
754
753
|
eventName = _args$ === void 0 ? 'Filter Applied' : _args$;
|
|
754
|
+
var _args$0$split = args[0].split(':'),
|
|
755
|
+
_args$0$split2 = _slicedToArray(_args$0$split, 2),
|
|
756
|
+
eventType = _args$0$split2[0],
|
|
757
|
+
eventModifier = _args$0$split2[1];
|
|
755
758
|
var attribute = typeof attr === 'string' ? attr : attr(facetValue);
|
|
756
759
|
if (args.length === 1 && _typeof(args[0]) === 'object') {
|
|
757
760
|
instantSearchInstance.sendEventToInsights(args[0]);
|
|
@@ -762,6 +765,7 @@
|
|
|
762
765
|
insightsMethod: 'clickedFilters',
|
|
763
766
|
widgetType: widgetType,
|
|
764
767
|
eventType: eventType,
|
|
768
|
+
eventModifier: eventModifier,
|
|
765
769
|
payload: {
|
|
766
770
|
eventName: eventName,
|
|
767
771
|
index: helper.getIndex(),
|
|
@@ -792,7 +796,7 @@
|
|
|
792
796
|
}
|
|
793
797
|
return chunks;
|
|
794
798
|
}
|
|
795
|
-
|
|
799
|
+
function _buildEventPayloadsForHits(_ref) {
|
|
796
800
|
var index = _ref.index,
|
|
797
801
|
widgetType = _ref.widgetType,
|
|
798
802
|
methodName = _ref.methodName,
|
|
@@ -802,7 +806,10 @@
|
|
|
802
806
|
if (args.length === 1 && _typeof(args[0]) === 'object') {
|
|
803
807
|
return [args[0]];
|
|
804
808
|
}
|
|
805
|
-
var
|
|
809
|
+
var _args$0$split = args[0].split(':'),
|
|
810
|
+
_args$0$split2 = _slicedToArray(_args$0$split, 2),
|
|
811
|
+
eventType = _args$0$split2[0],
|
|
812
|
+
eventModifier = _args$0$split2[1];
|
|
806
813
|
var hits = args[1];
|
|
807
814
|
var eventName = args[2];
|
|
808
815
|
if (!hits) {
|
|
@@ -845,7 +852,8 @@
|
|
|
845
852
|
index: index,
|
|
846
853
|
objectIDs: objectIDsByChunk[i]
|
|
847
854
|
},
|
|
848
|
-
hits: batch
|
|
855
|
+
hits: batch,
|
|
856
|
+
eventModifier: eventModifier
|
|
849
857
|
};
|
|
850
858
|
});
|
|
851
859
|
} else if (eventType === 'click') {
|
|
@@ -855,13 +863,14 @@
|
|
|
855
863
|
widgetType: widgetType,
|
|
856
864
|
eventType: eventType,
|
|
857
865
|
payload: {
|
|
858
|
-
eventName: eventName,
|
|
866
|
+
eventName: eventName || 'Hit Clicked',
|
|
859
867
|
index: index,
|
|
860
868
|
queryID: queryID,
|
|
861
869
|
objectIDs: objectIDsByChunk[i],
|
|
862
870
|
positions: positionsByChunk[i]
|
|
863
871
|
},
|
|
864
|
-
hits: batch
|
|
872
|
+
hits: batch,
|
|
873
|
+
eventModifier: eventModifier
|
|
865
874
|
};
|
|
866
875
|
});
|
|
867
876
|
} else if (eventType === 'conversion') {
|
|
@@ -871,27 +880,30 @@
|
|
|
871
880
|
widgetType: widgetType,
|
|
872
881
|
eventType: eventType,
|
|
873
882
|
payload: {
|
|
874
|
-
eventName: eventName,
|
|
883
|
+
eventName: eventName || 'Hit Converted',
|
|
875
884
|
index: index,
|
|
876
885
|
queryID: queryID,
|
|
877
886
|
objectIDs: objectIDsByChunk[i]
|
|
878
887
|
},
|
|
879
|
-
hits: batch
|
|
888
|
+
hits: batch,
|
|
889
|
+
eventModifier: eventModifier
|
|
880
890
|
};
|
|
881
891
|
});
|
|
882
892
|
} else {
|
|
883
893
|
throw new Error("eventType(\"".concat(eventType, "\") is not supported.\n If you want to send a custom payload, you can pass one object: ").concat(methodName, "(customPayload);\n "));
|
|
884
894
|
}
|
|
885
|
-
}
|
|
895
|
+
}
|
|
886
896
|
function createSendEventForHits(_ref2) {
|
|
887
897
|
var instantSearchInstance = _ref2.instantSearchInstance,
|
|
888
898
|
index = _ref2.index,
|
|
889
899
|
widgetType = _ref2.widgetType;
|
|
900
|
+
var sentEvents = {};
|
|
901
|
+
var timer = undefined;
|
|
890
902
|
var sendEventForHits = function sendEventForHits() {
|
|
891
903
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
892
904
|
args[_key] = arguments[_key];
|
|
893
905
|
}
|
|
894
|
-
var payloads =
|
|
906
|
+
var payloads = _buildEventPayloadsForHits({
|
|
895
907
|
widgetType: widgetType,
|
|
896
908
|
index: index,
|
|
897
909
|
methodName: 'sendEvent',
|
|
@@ -899,8 +911,16 @@
|
|
|
899
911
|
instantSearchInstance: instantSearchInstance
|
|
900
912
|
});
|
|
901
913
|
payloads.forEach(function (payload) {
|
|
902
|
-
|
|
914
|
+
if (payload.eventType === 'click' && payload.eventModifier === 'internal' && sentEvents[payload.eventType]) {
|
|
915
|
+
return;
|
|
916
|
+
}
|
|
917
|
+
sentEvents[payload.eventType] = true;
|
|
918
|
+
instantSearchInstance.sendEventToInsights(payload);
|
|
903
919
|
});
|
|
920
|
+
clearTimeout(timer);
|
|
921
|
+
timer = setTimeout(function () {
|
|
922
|
+
sentEvents = {};
|
|
923
|
+
}, 0);
|
|
904
924
|
};
|
|
905
925
|
return sendEventForHits;
|
|
906
926
|
}
|
|
@@ -912,7 +932,7 @@
|
|
|
912
932
|
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
913
933
|
args[_key2] = arguments[_key2];
|
|
914
934
|
}
|
|
915
|
-
var payloads =
|
|
935
|
+
var payloads = _buildEventPayloadsForHits({
|
|
916
936
|
widgetType: widgetType,
|
|
917
937
|
index: index,
|
|
918
938
|
methodName: 'bindEvent',
|
|
@@ -2384,7 +2404,7 @@
|
|
|
2384
2404
|
}
|
|
2385
2405
|
if (!_refine) {
|
|
2386
2406
|
_refine = function _refine(facetValue) {
|
|
2387
|
-
sendEvent('click', facetValue);
|
|
2407
|
+
sendEvent('click:internal', facetValue);
|
|
2388
2408
|
helper.toggleFacetRefinement(hierarchicalFacetName, facetValue).search();
|
|
2389
2409
|
};
|
|
2390
2410
|
}
|
|
@@ -2490,7 +2510,7 @@
|
|
|
2490
2510
|
renderFn(_objectSpread2(_objectSpread2({}, renderState), {}, {
|
|
2491
2511
|
instantSearchInstance: renderOptions.instantSearchInstance
|
|
2492
2512
|
}), false);
|
|
2493
|
-
renderState.sendEvent('view', renderState.hits);
|
|
2513
|
+
renderState.sendEvent('view:internal', renderState.hits);
|
|
2494
2514
|
},
|
|
2495
2515
|
getRenderState: function getRenderState(renderState, renderOptions) {
|
|
2496
2516
|
return _objectSpread2(_objectSpread2({}, renderState), {}, {
|
|
@@ -2667,6 +2687,7 @@
|
|
|
2667
2687
|
|
|
2668
2688
|
var n,l,u,t,o,r,f={},e=[],c=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i;function s(n,l){for(var u in l)n[u]=l[u];return n}function a(n){var l=n.parentNode;l&&l.removeChild(n);}function h(l,u,i){var t,o,r,f={};for(r in u)"key"==r?t=u[r]:"ref"==r?o=u[r]:f[r]=u[r];if(arguments.length>2&&(f.children=arguments.length>3?n.call(arguments,2):i),"function"==typeof l&&null!=l.defaultProps)for(r in l.defaultProps)void 0===f[r]&&(f[r]=l.defaultProps[r]);return v(l,f,t,o,null)}function v(n,i,t,o,r){var f={type:n,props:i,key:t,ref:o,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,__h:null,constructor:void 0,__v:null==r?++u:r};return null==r&&null!=l.vnode&&l.vnode(f),f}function y(){return {current:null}}function p(n){return n.children}function d(n,l){this.props=n,this.context=l;}function _(n,l){if(null==l)return n.__?_(n.__,n.__.__k.indexOf(n)+1):null;for(var u;l<n.__k.length;l++)if(null!=(u=n.__k[l])&&null!=u.__e)return u.__e;return "function"==typeof n.type?_(n):null}function k(n){var l,u;if(null!=(n=n.__)&&null!=n.__c){for(n.__e=n.__c.base=null,l=0;l<n.__k.length;l++)if(null!=(u=n.__k[l])&&null!=u.__e){n.__e=n.__c.base=u.__e;break}return k(n)}}function b(n){(!n.__d&&(n.__d=!0)&&t.push(n)&&!g.__r++||o!==l.debounceRendering)&&((o=l.debounceRendering)||setTimeout)(g);}function g(){for(var n;g.__r=t.length;)n=t.sort(function(n,l){return n.__v.__b-l.__v.__b}),t=[],n.some(function(n){var l,u,i,t,o,r;n.__d&&(o=(t=(l=n).__v).__e,(r=l.__P)&&(u=[],(i=s({},t)).__v=t.__v+1,j(r,t,i,l.__n,void 0!==r.ownerSVGElement,null!=t.__h?[o]:null,u,null==o?_(t):o,t.__h),z(u,t),t.__e!=o&&k(t)));});}function w(n,l,u,i,t,o,r,c,s,a){var h,y,d,k,b,g,w,x=i&&i.__k||e,C=x.length;for(u.__k=[],h=0;h<l.length;h++)if(null!=(k=u.__k[h]=null==(k=l[h])||"boolean"==typeof k?null:"string"==typeof k||"number"==typeof k||"bigint"==typeof k?v(null,k,null,null,k):Array.isArray(k)?v(p,{children:k},null,null,null):k.__b>0?v(k.type,k.props,k.key,k.ref?k.ref:null,k.__v):k)){if(k.__=u,k.__b=u.__b+1,null===(d=x[h])||d&&k.key==d.key&&k.type===d.type)x[h]=void 0;else for(y=0;y<C;y++){if((d=x[y])&&k.key==d.key&&k.type===d.type){x[y]=void 0;break}d=null;}j(n,k,d=d||f,t,o,r,c,s,a),b=k.__e,(y=k.ref)&&d.ref!=y&&(w||(w=[]),d.ref&&w.push(d.ref,null,k),w.push(y,k.__c||b,k)),null!=b?(null==g&&(g=b),"function"==typeof k.type&&k.__k===d.__k?k.__d=s=m(k,s,n):s=A(n,k,d,x,b,s),"function"==typeof u.type&&(u.__d=s)):s&&d.__e==s&&s.parentNode!=n&&(s=_(d));}for(u.__e=g,h=C;h--;)null!=x[h]&&("function"==typeof u.type&&null!=x[h].__e&&x[h].__e==u.__d&&(u.__d=_(i,h+1)),N(x[h],x[h]));if(w)for(h=0;h<w.length;h++)M(w[h],w[++h],w[++h]);}function m(n,l,u){for(var i,t=n.__k,o=0;t&&o<t.length;o++)(i=t[o])&&(i.__=n,l="function"==typeof i.type?m(i,l,u):A(u,i,i,t,i.__e,l));return l}function A(n,l,u,i,t,o){var r,f,e;if(void 0!==l.__d)r=l.__d,l.__d=void 0;else if(null==u||t!=o||null==t.parentNode)n:if(null==o||o.parentNode!==n)n.appendChild(t),r=null;else{for(f=o,e=0;(f=f.nextSibling)&&e<i.length;e+=2)if(f==t)break n;n.insertBefore(t,o),r=o;}return void 0!==r?r:t.nextSibling}function C(n,l,u,i,t){var o;for(o in u)"children"===o||"key"===o||o in l||H(n,o,null,u[o],i);for(o in l)t&&"function"!=typeof l[o]||"children"===o||"key"===o||"value"===o||"checked"===o||u[o]===l[o]||H(n,o,l[o],u[o],i);}function $(n,l,u){"-"===l[0]?n.setProperty(l,u):n[l]=null==u?"":"number"!=typeof u||c.test(l)?u:u+"px";}function H(n,l,u,i,t){var o;n:if("style"===l)if("string"==typeof u)n.style.cssText=u;else{if("string"==typeof i&&(n.style.cssText=i=""),i)for(l in i)u&&l in u||$(n.style,l,"");if(u)for(l in u)i&&u[l]===i[l]||$(n.style,l,u[l]);}else if("o"===l[0]&&"n"===l[1])o=l!==(l=l.replace(/Capture$/,"")),l=l.toLowerCase()in n?l.toLowerCase().slice(2):l.slice(2),n.l||(n.l={}),n.l[l+o]=u,u?i||n.addEventListener(l,o?T:I,o):n.removeEventListener(l,o?T:I,o);else if("dangerouslySetInnerHTML"!==l){if(t)l=l.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if("href"!==l&&"list"!==l&&"form"!==l&&"tabIndex"!==l&&"download"!==l&&l in n)try{n[l]=null==u?"":u;break n}catch(n){}"function"==typeof u||(null!=u&&(!1!==u||"a"===l[0]&&"r"===l[1])?n.setAttribute(l,u):n.removeAttribute(l));}}function I(n){this.l[n.type+!1](l.event?l.event(n):n);}function T(n){this.l[n.type+!0](l.event?l.event(n):n);}function j(n,u,i,t,o,r,f,e,c){var a,h,v,y,_,k,b,g,m,x,A,C,$,H=u.type;if(void 0!==u.constructor)return null;null!=i.__h&&(c=i.__h,e=u.__e=i.__e,u.__h=null,r=[e]),(a=l.__b)&&a(u);try{n:if("function"==typeof H){if(g=u.props,m=(a=H.contextType)&&t[a.__c],x=a?m?m.props.value:a.__:t,i.__c?b=(h=u.__c=i.__c).__=h.__E:("prototype"in H&&H.prototype.render?u.__c=h=new H(g,x):(u.__c=h=new d(g,x),h.constructor=H,h.render=O),m&&m.sub(h),h.props=g,h.state||(h.state={}),h.context=x,h.__n=t,v=h.__d=!0,h.__h=[]),null==h.__s&&(h.__s=h.state),null!=H.getDerivedStateFromProps&&(h.__s==h.state&&(h.__s=s({},h.__s)),s(h.__s,H.getDerivedStateFromProps(g,h.__s))),y=h.props,_=h.state,v)null==H.getDerivedStateFromProps&&null!=h.componentWillMount&&h.componentWillMount(),null!=h.componentDidMount&&h.__h.push(h.componentDidMount);else{if(null==H.getDerivedStateFromProps&&g!==y&&null!=h.componentWillReceiveProps&&h.componentWillReceiveProps(g,x),!h.__e&&null!=h.shouldComponentUpdate&&!1===h.shouldComponentUpdate(g,h.__s,x)||u.__v===i.__v){h.props=g,h.state=h.__s,u.__v!==i.__v&&(h.__d=!1),h.__v=u,u.__e=i.__e,u.__k=i.__k,u.__k.forEach(function(n){n&&(n.__=u);}),h.__h.length&&f.push(h);break n}null!=h.componentWillUpdate&&h.componentWillUpdate(g,h.__s,x),null!=h.componentDidUpdate&&h.__h.push(function(){h.componentDidUpdate(y,_,k);});}if(h.context=x,h.props=g,h.__v=u,h.__P=n,A=l.__r,C=0,"prototype"in H&&H.prototype.render)h.state=h.__s,h.__d=!1,A&&A(u),a=h.render(h.props,h.state,h.context);else do{h.__d=!1,A&&A(u),a=h.render(h.props,h.state,h.context),h.state=h.__s;}while(h.__d&&++C<25);h.state=h.__s,null!=h.getChildContext&&(t=s(s({},t),h.getChildContext())),v||null==h.getSnapshotBeforeUpdate||(k=h.getSnapshotBeforeUpdate(y,_)),$=null!=a&&a.type===p&&null==a.key?a.props.children:a,w(n,Array.isArray($)?$:[$],u,i,t,o,r,f,e,c),h.base=u.__e,u.__h=null,h.__h.length&&f.push(h),b&&(h.__E=h.__=null),h.__e=!1;}else null==r&&u.__v===i.__v?(u.__k=i.__k,u.__e=i.__e):u.__e=L(i.__e,u,i,t,o,r,f,c);(a=l.diffed)&&a(u);}catch(n){u.__v=null,(c||null!=r)&&(u.__e=e,u.__h=!!c,r[r.indexOf(e)]=null),l.__e(n,u,i);}}function z(n,u){l.__c&&l.__c(u,n),n.some(function(u){try{n=u.__h,u.__h=[],n.some(function(n){n.call(u);});}catch(n){l.__e(n,u.__v);}});}function L(l,u,i,t,o,r,e,c){var s,h,v,y=i.props,p=u.props,d=u.type,k=0;if("svg"===d&&(o=!0),null!=r)for(;k<r.length;k++)if((s=r[k])&&"setAttribute"in s==!!d&&(d?s.localName===d:3===s.nodeType)){l=s,r[k]=null;break}if(null==l){if(null===d)return document.createTextNode(p);l=o?document.createElementNS("http://www.w3.org/2000/svg",d):document.createElement(d,p.is&&p),r=null,c=!1;}if(null===d)y===p||c&&l.data===p||(l.data=p);else{if(r=r&&n.call(l.childNodes),h=(y=i.props||f).dangerouslySetInnerHTML,v=p.dangerouslySetInnerHTML,!c){if(null!=r)for(y={},k=0;k<l.attributes.length;k++)y[l.attributes[k].name]=l.attributes[k].value;(v||h)&&(v&&(h&&v.__html==h.__html||v.__html===l.innerHTML)||(l.innerHTML=v&&v.__html||""));}if(C(l,p,y,o,c),v)u.__k=[];else if(k=u.props.children,w(l,Array.isArray(k)?k:[k],u,i,t,o&&"foreignObject"!==d,r,e,r?r[0]:i.__k&&_(i,0),c),null!=r)for(k=r.length;k--;)null!=r[k]&&a(r[k]);c||("value"in p&&void 0!==(k=p.value)&&(k!==l.value||"progress"===d&&!k||"option"===d&&k!==y.value)&&H(l,"value",k,y.value,!1),"checked"in p&&void 0!==(k=p.checked)&&k!==l.checked&&H(l,"checked",k,y.checked,!1));}return l}function M(n,u,i){try{"function"==typeof n?n(u):n.current=u;}catch(n){l.__e(n,i);}}function N(n,u,i){var t,o;if(l.unmount&&l.unmount(n),(t=n.ref)&&(t.current&&t.current!==n.__e||M(t,null,u)),null!=(t=n.__c)){if(t.componentWillUnmount)try{t.componentWillUnmount();}catch(n){l.__e(n,u);}t.base=t.__P=null,n.__c=void 0;}if(t=n.__k)for(o=0;o<t.length;o++)t[o]&&N(t[o],u,"function"!=typeof n.type);i||null==n.__e||a(n.__e),n.__=n.__e=n.__d=void 0;}function O(n,l,u){return this.constructor(n,u)}function P(u,i,t){var o,r,e;l.__&&l.__(u,i),r=(o="function"==typeof t)?null:t&&t.__k||i.__k,e=[],j(i,u=(!o&&t||i).__k=h(p,null,[u]),r||f,f,void 0!==i.ownerSVGElement,!o&&t?[t]:r?null:i.firstChild?n.call(i.childNodes):null,e,!o&&t?t:r?r.__e:i.firstChild,o),z(e,u);}n=e.slice,l={__e:function(n,l,u,i){for(var t,o,r;l=l.__;)if((t=l.__c)&&!t.__)try{if((o=t.constructor)&&null!=o.getDerivedStateFromError&&(t.setState(o.getDerivedStateFromError(n)),r=t.__d),null!=t.componentDidCatch&&(t.componentDidCatch(n,i||{}),r=t.__d),r)return t.__E=t}catch(l){n=l;}throw n}},u=0,d.prototype.setState=function(n,l){var u;u=null!=this.__s&&this.__s!==this.state?this.__s:this.__s=s({},this.state),"function"==typeof n&&(n=n(s({},u),this.props)),n&&s(u,n),null!=n&&this.__v&&(l&&this.__h.push(l),b(this));},d.prototype.forceUpdate=function(n){this.__v&&(this.__e=!0,n&&this.__h.push(n),b(this));},d.prototype.render=p,t=[],g.__r=0,r=0;
|
|
2669
2689
|
|
|
2690
|
+
/** @deprecated use bindEvent instead */
|
|
2670
2691
|
function readDataAttributes(domElement) {
|
|
2671
2692
|
var method = domElement.getAttribute('data-insights-method');
|
|
2672
2693
|
var serializedPayload = domElement.getAttribute('data-insights-payload');
|
|
@@ -2683,9 +2704,8 @@
|
|
|
2683
2704
|
throw new Error('The insights helper was unable to parse `data-insights-payload`.');
|
|
2684
2705
|
}
|
|
2685
2706
|
}
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
}
|
|
2707
|
+
|
|
2708
|
+
/** @deprecated use bindEvent instead */
|
|
2689
2709
|
function writeDataAttributes(_ref) {
|
|
2690
2710
|
var method = _ref.method,
|
|
2691
2711
|
payload = _ref.payload;
|
|
@@ -2712,7 +2732,34 @@
|
|
|
2712
2732
|
});
|
|
2713
2733
|
}
|
|
2714
2734
|
|
|
2715
|
-
var
|
|
2735
|
+
var createInsightsEventHandler = function createInsightsEventHandler(_ref) {
|
|
2736
|
+
var insights = _ref.insights,
|
|
2737
|
+
sendEvent = _ref.sendEvent;
|
|
2738
|
+
return function (event) {
|
|
2739
|
+
// new way, e.g. bindEvent("click", hit, "Hit clicked")
|
|
2740
|
+
var insightsThroughSendEvent = findInsightsTarget(event.target, event.currentTarget, function (element) {
|
|
2741
|
+
return element.hasAttribute('data-insights-event');
|
|
2742
|
+
});
|
|
2743
|
+
if (insightsThroughSendEvent) {
|
|
2744
|
+
var payload = parseInsightsEvent(insightsThroughSendEvent);
|
|
2745
|
+
payload.forEach(function (single) {
|
|
2746
|
+
return sendEvent(single);
|
|
2747
|
+
});
|
|
2748
|
+
}
|
|
2749
|
+
|
|
2750
|
+
// old way, e.g. instantsearch.insights("clickedObjectIDsAfterSearch", { .. })
|
|
2751
|
+
var insightsThroughFunction = findInsightsTarget(event.target, event.currentTarget, function (element) {
|
|
2752
|
+
return element.hasAttribute('data-insights-method') && element.hasAttribute('data-insights-payload');
|
|
2753
|
+
});
|
|
2754
|
+
if (insightsThroughFunction) {
|
|
2755
|
+
var _readDataAttributes = readDataAttributes(insightsThroughFunction),
|
|
2756
|
+
method = _readDataAttributes.method,
|
|
2757
|
+
_payload = _readDataAttributes.payload;
|
|
2758
|
+
insights(method, _payload);
|
|
2759
|
+
}
|
|
2760
|
+
};
|
|
2761
|
+
};
|
|
2762
|
+
function findInsightsTarget(startElement, endElement, validator) {
|
|
2716
2763
|
var element = startElement;
|
|
2717
2764
|
while (element && !validator(element)) {
|
|
2718
2765
|
if (element === endElement) {
|
|
@@ -2721,8 +2768,8 @@
|
|
|
2721
2768
|
element = element.parentElement;
|
|
2722
2769
|
}
|
|
2723
2770
|
return element;
|
|
2724
|
-
}
|
|
2725
|
-
|
|
2771
|
+
}
|
|
2772
|
+
function parseInsightsEvent(element) {
|
|
2726
2773
|
var serializedPayload = element.getAttribute('data-insights-event');
|
|
2727
2774
|
if (typeof serializedPayload !== 'string') {
|
|
2728
2775
|
throw new Error('The insights middleware expects `data-insights-event` to be a base64-encoded JSON string.');
|
|
@@ -2732,40 +2779,7 @@
|
|
|
2732
2779
|
} catch (error) {
|
|
2733
2780
|
throw new Error('The insights middleware was unable to parse `data-insights-event`.');
|
|
2734
2781
|
}
|
|
2735
|
-
}
|
|
2736
|
-
var insightsListener = function insightsListener(BaseComponent) {
|
|
2737
|
-
function WithInsightsListener(props) {
|
|
2738
|
-
var handleClick = function handleClick(event) {
|
|
2739
|
-
if (props.sendEvent) {
|
|
2740
|
-
// new way with insights middleware
|
|
2741
|
-
var targetWithEvent = findInsightsTarget(event.target, event.currentTarget, function (element) {
|
|
2742
|
-
return element.hasAttribute('data-insights-event');
|
|
2743
|
-
});
|
|
2744
|
-
if (targetWithEvent) {
|
|
2745
|
-
var payload = parseInsightsEvent(targetWithEvent);
|
|
2746
|
-
payload.forEach(function (single) {
|
|
2747
|
-
return props.sendEvent(single);
|
|
2748
|
-
});
|
|
2749
|
-
}
|
|
2750
|
-
}
|
|
2751
|
-
|
|
2752
|
-
// old way, e.g. instantsearch.insights("clickedObjectIDsAfterSearch", { .. })
|
|
2753
|
-
var insightsTarget = findInsightsTarget(event.target, event.currentTarget, function (element) {
|
|
2754
|
-
return hasDataAttributes(element);
|
|
2755
|
-
});
|
|
2756
|
-
if (insightsTarget) {
|
|
2757
|
-
var _readDataAttributes = readDataAttributes(insightsTarget),
|
|
2758
|
-
method = _readDataAttributes.method,
|
|
2759
|
-
_payload = _readDataAttributes.payload;
|
|
2760
|
-
props.insights(method, _payload);
|
|
2761
|
-
}
|
|
2762
|
-
};
|
|
2763
|
-
return h("div", {
|
|
2764
|
-
onClick: handleClick
|
|
2765
|
-
}, h(BaseComponent, props));
|
|
2766
|
-
}
|
|
2767
|
-
return WithInsightsListener;
|
|
2768
|
-
};
|
|
2782
|
+
}
|
|
2769
2783
|
|
|
2770
2784
|
var connectHitsWithInsights = withInsights(connectHits);
|
|
2771
2785
|
|
|
@@ -2897,7 +2911,8 @@
|
|
|
2897
2911
|
};
|
|
2898
2912
|
};
|
|
2899
2913
|
|
|
2900
|
-
var _excluded$2 = ["page"]
|
|
2914
|
+
var _excluded$2 = ["page"],
|
|
2915
|
+
_excluded2 = ["clickAnalytics", "userToken"];
|
|
2901
2916
|
var withUsage$7 = createDocumentationMessageGenerator({
|
|
2902
2917
|
name: 'infinite-hits',
|
|
2903
2918
|
connector: true
|
|
@@ -2908,17 +2923,24 @@
|
|
|
2908
2923
|
rest = _objectWithoutProperties(_ref, _excluded$2);
|
|
2909
2924
|
return rest;
|
|
2910
2925
|
}
|
|
2926
|
+
function normalizeState(state) {
|
|
2927
|
+
var _ref2 = state || {},
|
|
2928
|
+
clickAnalytics = _ref2.clickAnalytics,
|
|
2929
|
+
userToken = _ref2.userToken,
|
|
2930
|
+
rest = _objectWithoutProperties(_ref2, _excluded2);
|
|
2931
|
+
return rest;
|
|
2932
|
+
}
|
|
2911
2933
|
function getInMemoryCache() {
|
|
2912
2934
|
var cachedHits = null;
|
|
2913
2935
|
var cachedState = null;
|
|
2914
2936
|
return {
|
|
2915
|
-
read: function read(
|
|
2916
|
-
var state =
|
|
2937
|
+
read: function read(_ref3) {
|
|
2938
|
+
var state = _ref3.state;
|
|
2917
2939
|
return isEqual(cachedState, getStateWithoutPage(state)) ? cachedHits : null;
|
|
2918
2940
|
},
|
|
2919
|
-
write: function write(
|
|
2920
|
-
var state =
|
|
2921
|
-
hits =
|
|
2941
|
+
write: function write(_ref4) {
|
|
2942
|
+
var state = _ref4.state,
|
|
2943
|
+
hits = _ref4.hits;
|
|
2922
2944
|
cachedState = getStateWithoutPage(state);
|
|
2923
2945
|
cachedHits = hits;
|
|
2924
2946
|
}
|
|
@@ -2938,15 +2960,15 @@
|
|
|
2938
2960
|
// @TODO: this should be a generic, but a Connector can not yet be generic itself
|
|
2939
2961
|
|
|
2940
2962
|
return function (widgetParams) {
|
|
2941
|
-
var
|
|
2942
|
-
|
|
2943
|
-
escapeHTML =
|
|
2944
|
-
|
|
2945
|
-
transformItems =
|
|
2963
|
+
var _ref5 = widgetParams || {},
|
|
2964
|
+
_ref5$escapeHTML = _ref5.escapeHTML,
|
|
2965
|
+
escapeHTML = _ref5$escapeHTML === void 0 ? true : _ref5$escapeHTML,
|
|
2966
|
+
_ref5$transformItems = _ref5.transformItems,
|
|
2967
|
+
transformItems = _ref5$transformItems === void 0 ? function (items) {
|
|
2946
2968
|
return items;
|
|
2947
|
-
} :
|
|
2948
|
-
|
|
2949
|
-
cache =
|
|
2969
|
+
} : _ref5$transformItems,
|
|
2970
|
+
_ref5$cache = _ref5.cache,
|
|
2971
|
+
cache = _ref5$cache === void 0 ? getInMemoryCache() : _ref5$cache;
|
|
2950
2972
|
var showPrevious;
|
|
2951
2973
|
var showMore;
|
|
2952
2974
|
var sendEvent;
|
|
@@ -2977,7 +2999,7 @@
|
|
|
2977
2999
|
// avoid updating the browser URL when the user displays the previous page.
|
|
2978
3000
|
helper.overrideStateWithoutTriggeringChangeEvent(_objectSpread2(_objectSpread2({}, helper.state), {}, {
|
|
2979
3001
|
page: getFirstReceivedPage(helper.state, cache.read({
|
|
2980
|
-
state: helper.state
|
|
3002
|
+
state: normalizeState(helper.state)
|
|
2981
3003
|
}) || {}) - 1
|
|
2982
3004
|
})).searchWithoutTriggeringOnStateChange();
|
|
2983
3005
|
};
|
|
@@ -2985,7 +3007,7 @@
|
|
|
2985
3007
|
var getShowMore = function getShowMore(helper) {
|
|
2986
3008
|
return function () {
|
|
2987
3009
|
helper.setPage(getLastReceivedPage(helper.state, cache.read({
|
|
2988
|
-
state: helper.state
|
|
3010
|
+
state: normalizeState(helper.state)
|
|
2989
3011
|
}) || {}) + 1).search();
|
|
2990
3012
|
};
|
|
2991
3013
|
};
|
|
@@ -3002,19 +3024,19 @@
|
|
|
3002
3024
|
renderFn(_objectSpread2(_objectSpread2({}, widgetRenderState), {}, {
|
|
3003
3025
|
instantSearchInstance: instantSearchInstance
|
|
3004
3026
|
}), false);
|
|
3005
|
-
sendEvent('view', widgetRenderState.currentPageHits);
|
|
3027
|
+
sendEvent('view:internal', widgetRenderState.currentPageHits);
|
|
3006
3028
|
},
|
|
3007
3029
|
getRenderState: function getRenderState(renderState, renderOptions) {
|
|
3008
3030
|
return _objectSpread2(_objectSpread2({}, renderState), {}, {
|
|
3009
3031
|
infiniteHits: this.getWidgetRenderState(renderOptions)
|
|
3010
3032
|
});
|
|
3011
3033
|
},
|
|
3012
|
-
getWidgetRenderState: function getWidgetRenderState(
|
|
3013
|
-
var results =
|
|
3014
|
-
helper =
|
|
3015
|
-
parent =
|
|
3016
|
-
existingState =
|
|
3017
|
-
instantSearchInstance =
|
|
3034
|
+
getWidgetRenderState: function getWidgetRenderState(_ref6) {
|
|
3035
|
+
var results = _ref6.results,
|
|
3036
|
+
helper = _ref6.helper,
|
|
3037
|
+
parent = _ref6.parent,
|
|
3038
|
+
existingState = _ref6.state,
|
|
3039
|
+
instantSearchInstance = _ref6.instantSearchInstance;
|
|
3018
3040
|
var isFirstPage;
|
|
3019
3041
|
var currentPageHits = [];
|
|
3020
3042
|
/**
|
|
@@ -3024,7 +3046,7 @@
|
|
|
3024
3046
|
*/
|
|
3025
3047
|
var state = parent.getPreviousState() || existingState;
|
|
3026
3048
|
var cachedHits = cache.read({
|
|
3027
|
-
state: state
|
|
3049
|
+
state: normalizeState(state)
|
|
3028
3050
|
}) || {};
|
|
3029
3051
|
if (!results) {
|
|
3030
3052
|
showPrevious = getShowPrevious(helper);
|
|
@@ -3054,7 +3076,7 @@
|
|
|
3054
3076
|
if (cachedHits[_page] === undefined && !results.__isArtificial && instantSearchInstance.status === 'idle') {
|
|
3055
3077
|
cachedHits[_page] = transformedHits;
|
|
3056
3078
|
cache.write({
|
|
3057
|
-
state: state,
|
|
3079
|
+
state: normalizeState(state),
|
|
3058
3080
|
hits: cachedHits
|
|
3059
3081
|
});
|
|
3060
3082
|
}
|
|
@@ -3076,8 +3098,8 @@
|
|
|
3076
3098
|
widgetParams: widgetParams
|
|
3077
3099
|
};
|
|
3078
3100
|
},
|
|
3079
|
-
dispose: function dispose(
|
|
3080
|
-
var state =
|
|
3101
|
+
dispose: function dispose(_ref7) {
|
|
3102
|
+
var state = _ref7.state;
|
|
3081
3103
|
unmountFn();
|
|
3082
3104
|
var stateWithoutPage = state.setQueryParameter('page', undefined);
|
|
3083
3105
|
if (!escapeHTML) {
|
|
@@ -3087,8 +3109,8 @@
|
|
|
3087
3109
|
return _objectSpread2(_objectSpread2({}, acc), {}, _defineProperty({}, key, undefined));
|
|
3088
3110
|
}, {}));
|
|
3089
3111
|
},
|
|
3090
|
-
getWidgetUiState: function getWidgetUiState(uiState,
|
|
3091
|
-
var searchParameters =
|
|
3112
|
+
getWidgetUiState: function getWidgetUiState(uiState, _ref8) {
|
|
3113
|
+
var searchParameters = _ref8.searchParameters;
|
|
3092
3114
|
var page = searchParameters.page || 0;
|
|
3093
3115
|
if (!page) {
|
|
3094
3116
|
// return without adding `page` to uiState
|
|
@@ -3101,8 +3123,8 @@
|
|
|
3101
3123
|
page: page + 1
|
|
3102
3124
|
});
|
|
3103
3125
|
},
|
|
3104
|
-
getWidgetSearchParameters: function getWidgetSearchParameters(searchParameters,
|
|
3105
|
-
var uiState =
|
|
3126
|
+
getWidgetSearchParameters: function getWidgetSearchParameters(searchParameters, _ref9) {
|
|
3127
|
+
var uiState = _ref9.uiState;
|
|
3106
3128
|
var widgetSearchParameters = searchParameters;
|
|
3107
3129
|
if (escapeHTML) {
|
|
3108
3130
|
widgetSearchParameters = searchParameters.setQueryParameters(TAG_PLACEHOLDER);
|
|
@@ -3227,7 +3249,7 @@
|
|
|
3227
3249
|
var _helper$getHierarchic = helper.getHierarchicalFacetBreadcrumb(attribute),
|
|
3228
3250
|
_helper$getHierarchic2 = _slicedToArray(_helper$getHierarchic, 1),
|
|
3229
3251
|
refinedItem = _helper$getHierarchic2[0];
|
|
3230
|
-
sendEvent('click', facetValue ? facetValue : refinedItem);
|
|
3252
|
+
sendEvent('click:internal', facetValue ? facetValue : refinedItem);
|
|
3231
3253
|
helper.toggleFacetRefinement(attribute, facetValue ? facetValue : refinedItem).search();
|
|
3232
3254
|
};
|
|
3233
3255
|
}
|
|
@@ -3428,7 +3450,7 @@
|
|
|
3428
3450
|
if (!connectorState.refine) {
|
|
3429
3451
|
connectorState.refine = function (facetValue) {
|
|
3430
3452
|
var refinedState = getRefinedState(helper.state, attribute, facetValue);
|
|
3431
|
-
connectorState.sendEvent('click', facetValue);
|
|
3453
|
+
connectorState.sendEvent('click:internal', facetValue);
|
|
3432
3454
|
helper.setState(refinedState).search();
|
|
3433
3455
|
};
|
|
3434
3456
|
}
|
|
@@ -3992,7 +4014,7 @@
|
|
|
3992
4014
|
};
|
|
3993
4015
|
|
|
3994
4016
|
var _excluded$4 = ["name", "escapedValue"],
|
|
3995
|
-
_excluded2 = ["escapedValue", "value"];
|
|
4017
|
+
_excluded2$1 = ["escapedValue", "value"];
|
|
3996
4018
|
var withUsage$c = createDocumentationMessageGenerator({
|
|
3997
4019
|
name: 'refinement-list',
|
|
3998
4020
|
connector: true
|
|
@@ -4101,7 +4123,7 @@
|
|
|
4101
4123
|
var normalizedFacetValues = transformItems(facetValues.map(function (_ref3) {
|
|
4102
4124
|
var escapedValue = _ref3.escapedValue,
|
|
4103
4125
|
value = _ref3.value,
|
|
4104
|
-
item = _objectWithoutProperties(_ref3, _excluded2);
|
|
4126
|
+
item = _objectWithoutProperties(_ref3, _excluded2$1);
|
|
4105
4127
|
return _objectSpread2(_objectSpread2({}, item), {}, {
|
|
4106
4128
|
value: escapedValue,
|
|
4107
4129
|
label: value
|
|
@@ -4156,7 +4178,7 @@
|
|
|
4156
4178
|
widgetType: this.$$type
|
|
4157
4179
|
});
|
|
4158
4180
|
triggerRefine = function triggerRefine(facetValue) {
|
|
4159
|
-
sendEvent('click', facetValue);
|
|
4181
|
+
sendEvent('click:internal', facetValue);
|
|
4160
4182
|
helper.toggleFacetRefinement(attribute, facetValue).search();
|
|
4161
4183
|
};
|
|
4162
4184
|
searchForFacetValues = createSearchForFacetValues(helper, this);
|
|
@@ -4459,10 +4481,13 @@
|
|
|
4459
4481
|
instantSearchInstance.sendEventToInsights(args[0]);
|
|
4460
4482
|
return;
|
|
4461
4483
|
}
|
|
4462
|
-
var
|
|
4463
|
-
facetValue = args[1],
|
|
4484
|
+
var facetValue = args[1],
|
|
4464
4485
|
_args$ = args[2],
|
|
4465
4486
|
eventName = _args$ === void 0 ? 'Filter Applied' : _args$;
|
|
4487
|
+
var _args$0$split = args[0].split(':'),
|
|
4488
|
+
_args$0$split2 = _slicedToArray(_args$0$split, 2),
|
|
4489
|
+
eventType = _args$0$split2[0],
|
|
4490
|
+
eventModifier = _args$0$split2[1];
|
|
4466
4491
|
if (eventType !== 'click') {
|
|
4467
4492
|
return;
|
|
4468
4493
|
}
|
|
@@ -4472,6 +4497,7 @@
|
|
|
4472
4497
|
insightsMethod: 'clickedFilters',
|
|
4473
4498
|
widgetType: $$type$2,
|
|
4474
4499
|
eventType: eventType,
|
|
4500
|
+
eventModifier: eventModifier,
|
|
4475
4501
|
payload: {
|
|
4476
4502
|
eventName: eventName,
|
|
4477
4503
|
index: helper.getIndex(),
|
|
@@ -4547,7 +4573,7 @@
|
|
|
4547
4573
|
return emptyState;
|
|
4548
4574
|
}
|
|
4549
4575
|
var toggleRefinement = function toggleRefinement(helper, facetValue) {
|
|
4550
|
-
sendEvent('click', facetValue);
|
|
4576
|
+
sendEvent('click:internal', facetValue);
|
|
4551
4577
|
helper.setState(getRefinedState(helper.state, facetValue)).search();
|
|
4552
4578
|
};
|
|
4553
4579
|
var connectorState = {
|
|
@@ -4776,10 +4802,13 @@
|
|
|
4776
4802
|
instantSearchInstance.sendEventToInsights(args[0]);
|
|
4777
4803
|
return;
|
|
4778
4804
|
}
|
|
4779
|
-
var
|
|
4780
|
-
isRefined = args[1],
|
|
4805
|
+
var isRefined = args[1],
|
|
4781
4806
|
_args$ = args[2],
|
|
4782
4807
|
eventName = _args$ === void 0 ? 'Filter Applied' : _args$;
|
|
4808
|
+
var _args$0$split = args[0].split(':'),
|
|
4809
|
+
_args$0$split2 = _slicedToArray(_args$0$split, 2),
|
|
4810
|
+
eventType = _args$0$split2[0],
|
|
4811
|
+
eventModifier = _args$0$split2[1];
|
|
4783
4812
|
if (eventType !== 'click' || on === undefined) {
|
|
4784
4813
|
return;
|
|
4785
4814
|
}
|
|
@@ -4791,6 +4820,7 @@
|
|
|
4791
4820
|
insightsMethod: 'clickedFilters',
|
|
4792
4821
|
widgetType: $$type$3,
|
|
4793
4822
|
eventType: eventType,
|
|
4823
|
+
eventModifier: eventModifier,
|
|
4794
4824
|
payload: {
|
|
4795
4825
|
eventName: eventName,
|
|
4796
4826
|
index: helper.getIndex(),
|
|
@@ -4837,7 +4867,7 @@
|
|
|
4837
4867
|
},
|
|
4838
4868
|
isRefined = _ref3.isRefined;
|
|
4839
4869
|
if (!isRefined) {
|
|
4840
|
-
sendEvent('click', isRefined);
|
|
4870
|
+
sendEvent('click:internal', isRefined);
|
|
4841
4871
|
if (hasAnOffValue) {
|
|
4842
4872
|
off.forEach(function (v) {
|
|
4843
4873
|
return helper.removeDisjunctiveFacetRefinement(attribute, v);
|
|
@@ -5298,7 +5328,7 @@
|
|
|
5298
5328
|
widgetState.internalToggleRefineOnMapMove = createInternalToggleRefinementOnMapMove(renderArgs, this.render.bind(this));
|
|
5299
5329
|
widgetState.internalSetMapMoveSinceLastRefine = createInternalSetMapMoveSinceLastRefine(renderArgs, this.render.bind(this));
|
|
5300
5330
|
var widgetRenderState = this.getWidgetRenderState(renderArgs);
|
|
5301
|
-
sendEvent('view', widgetRenderState.items);
|
|
5331
|
+
sendEvent('view:internal', widgetRenderState.items);
|
|
5302
5332
|
renderFn(_objectSpread2(_objectSpread2({}, widgetRenderState), {}, {
|
|
5303
5333
|
instantSearchInstance: instantSearchInstance
|
|
5304
5334
|
}), isFirstRendering);
|
|
@@ -11109,7 +11139,7 @@
|
|
|
11109
11139
|
renderState.indices.forEach(function (_ref3) {
|
|
11110
11140
|
var sendEvent = _ref3.sendEvent,
|
|
11111
11141
|
hits = _ref3.hits;
|
|
11112
|
-
sendEvent('view', hits);
|
|
11142
|
+
sendEvent('view:internal', hits);
|
|
11113
11143
|
});
|
|
11114
11144
|
renderFn(_objectSpread2(_objectSpread2({}, renderState), {}, {
|
|
11115
11145
|
instantSearchInstance: instantSearchInstance
|
|
@@ -11707,6 +11737,10 @@
|
|
|
11707
11737
|
};
|
|
11708
11738
|
|
|
11709
11739
|
var suit = component('Highlight');
|
|
11740
|
+
|
|
11741
|
+
/**
|
|
11742
|
+
* @deprecated use html tagged templates and the Highlight component instead
|
|
11743
|
+
*/
|
|
11710
11744
|
function highlight(_ref) {
|
|
11711
11745
|
var attribute = _ref.attribute,
|
|
11712
11746
|
_ref$highlightedTagNa = _ref.highlightedTagName,
|
|
@@ -11714,6 +11748,7 @@
|
|
|
11714
11748
|
hit = _ref.hit,
|
|
11715
11749
|
_ref$cssClasses = _ref.cssClasses,
|
|
11716
11750
|
cssClasses = _ref$cssClasses === void 0 ? {} : _ref$cssClasses;
|
|
11751
|
+
_warning(false, "`instantsearch.highlight` function has been deprecated. It is still supported in 4.x releases, but not further. It is replaced by the `Highlight` component.\n\nFor more information, visit https://www.algolia.com/doc/guides/building-search-ui/upgrade-guides/js/?client=html+tagged+templates#upgrade-templates") ;
|
|
11717
11752
|
var highlightAttributeResult = getPropertyByPath(hit._highlightResult, attribute);
|
|
11718
11753
|
|
|
11719
11754
|
// @MAJOR fallback to attribute value if highlight is not found
|
|
@@ -11730,6 +11765,10 @@
|
|
|
11730
11765
|
}
|
|
11731
11766
|
|
|
11732
11767
|
var suit$1 = component('ReverseHighlight');
|
|
11768
|
+
|
|
11769
|
+
/**
|
|
11770
|
+
* @deprecated use html tagged templates and the ReverseHighlight component instead
|
|
11771
|
+
*/
|
|
11733
11772
|
function reverseHighlight(_ref) {
|
|
11734
11773
|
var attribute = _ref.attribute,
|
|
11735
11774
|
_ref$highlightedTagNa = _ref.highlightedTagName,
|
|
@@ -11737,6 +11776,7 @@
|
|
|
11737
11776
|
hit = _ref.hit,
|
|
11738
11777
|
_ref$cssClasses = _ref.cssClasses,
|
|
11739
11778
|
cssClasses = _ref$cssClasses === void 0 ? {} : _ref$cssClasses;
|
|
11779
|
+
_warning(false, "`instantsearch.reverseHighlight` function has been deprecated. It is still supported in 4.x releases, but not further. It is replaced by the `ReverseHighlight` component.\n\nFor more information, visit https://www.algolia.com/doc/guides/building-search-ui/upgrade-guides/js/?client=html+tagged+templates#upgrade-templates") ;
|
|
11740
11780
|
var highlightAttributeResult = getPropertyByPath(hit._highlightResult, attribute);
|
|
11741
11781
|
|
|
11742
11782
|
// @MAJOR fallback to attribute value if highlight is not found
|
|
@@ -11754,6 +11794,10 @@
|
|
|
11754
11794
|
}
|
|
11755
11795
|
|
|
11756
11796
|
var suit$2 = component('Snippet');
|
|
11797
|
+
|
|
11798
|
+
/**
|
|
11799
|
+
* @deprecated use html tagged templates and the Snippet component instead
|
|
11800
|
+
*/
|
|
11757
11801
|
function snippet(_ref) {
|
|
11758
11802
|
var attribute = _ref.attribute,
|
|
11759
11803
|
_ref$highlightedTagNa = _ref.highlightedTagName,
|
|
@@ -11761,6 +11805,7 @@
|
|
|
11761
11805
|
hit = _ref.hit,
|
|
11762
11806
|
_ref$cssClasses = _ref.cssClasses,
|
|
11763
11807
|
cssClasses = _ref$cssClasses === void 0 ? {} : _ref$cssClasses;
|
|
11808
|
+
_warning(false, "`instantsearch.snippet` function has been deprecated. It is still supported in 4.x releases, but not further. It is replaced by the `Snippet` component.\n\nFor more information, visit https://www.algolia.com/doc/guides/building-search-ui/upgrade-guides/js/?client=html+tagged+templates#upgrade-templates") ;
|
|
11764
11809
|
var snippetAttributeResult = getPropertyByPath(hit._snippetResult, attribute);
|
|
11765
11810
|
|
|
11766
11811
|
// @MAJOR fallback to attribute value if snippet is not found
|
|
@@ -11777,6 +11822,10 @@
|
|
|
11777
11822
|
}
|
|
11778
11823
|
|
|
11779
11824
|
var suit$3 = component('ReverseSnippet');
|
|
11825
|
+
|
|
11826
|
+
/**
|
|
11827
|
+
* @deprecated use html tagged templates and the ReverseSnippet component instead
|
|
11828
|
+
*/
|
|
11780
11829
|
function reverseSnippet(_ref) {
|
|
11781
11830
|
var attribute = _ref.attribute,
|
|
11782
11831
|
_ref$highlightedTagNa = _ref.highlightedTagName,
|
|
@@ -11784,6 +11833,7 @@
|
|
|
11784
11833
|
hit = _ref.hit,
|
|
11785
11834
|
_ref$cssClasses = _ref.cssClasses,
|
|
11786
11835
|
cssClasses = _ref$cssClasses === void 0 ? {} : _ref$cssClasses;
|
|
11836
|
+
_warning(false, "`instantsearch.reverseSnippet` function has been deprecated. It is still supported in 4.x releases, but not further. It is replaced by the `ReverseSnippet` component.\n\nFor more information, visit https://www.algolia.com/doc/guides/building-search-ui/upgrade-guides/js/?client=html+tagged+templates#upgrade-templates") ;
|
|
11787
11837
|
var snippetAttributeResult = getPropertyByPath(hit._snippetResult, attribute);
|
|
11788
11838
|
|
|
11789
11839
|
// @MAJOR fallback to attribute value if snippet is not found
|
|
@@ -11879,7 +11929,231 @@
|
|
|
11879
11929
|
};
|
|
11880
11930
|
}
|
|
11881
11931
|
|
|
11882
|
-
|
|
11932
|
+
var ALGOLIA_INSIGHTS_VERSION = '2.6.0';
|
|
11933
|
+
var ALGOLIA_INSIGHTS_SRC = "https://cdn.jsdelivr.net/npm/search-insights@".concat(ALGOLIA_INSIGHTS_VERSION, "/dist/search-insights.min.js");
|
|
11934
|
+
function createInsightsMiddleware() {
|
|
11935
|
+
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
11936
|
+
var _insightsClient = props.insightsClient,
|
|
11937
|
+
insightsInitParams = props.insightsInitParams,
|
|
11938
|
+
onEvent = props.onEvent,
|
|
11939
|
+
_props$$$internal = props.$$internal,
|
|
11940
|
+
$$internal = _props$$$internal === void 0 ? false : _props$$$internal;
|
|
11941
|
+
var potentialInsightsClient = _insightsClient;
|
|
11942
|
+
if (!_insightsClient && _insightsClient !== null) {
|
|
11943
|
+
safelyRunOnBrowser(function (_ref) {
|
|
11944
|
+
var window = _ref.window;
|
|
11945
|
+
var pointer = window.AlgoliaAnalyticsObject || 'aa';
|
|
11946
|
+
if (typeof pointer === 'string') {
|
|
11947
|
+
potentialInsightsClient = window[pointer];
|
|
11948
|
+
}
|
|
11949
|
+
if (!potentialInsightsClient) {
|
|
11950
|
+
window.AlgoliaAnalyticsObject = pointer;
|
|
11951
|
+
if (!window[pointer]) {
|
|
11952
|
+
window[pointer] = function () {
|
|
11953
|
+
if (!window[pointer].queue) {
|
|
11954
|
+
window[pointer].queue = [];
|
|
11955
|
+
}
|
|
11956
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
11957
|
+
args[_key] = arguments[_key];
|
|
11958
|
+
}
|
|
11959
|
+
window[pointer].queue.push(args);
|
|
11960
|
+
};
|
|
11961
|
+
window[pointer].version = ALGOLIA_INSIGHTS_VERSION;
|
|
11962
|
+
window[pointer].shouldAddScript = true;
|
|
11963
|
+
}
|
|
11964
|
+
potentialInsightsClient = window[pointer];
|
|
11965
|
+
}
|
|
11966
|
+
});
|
|
11967
|
+
}
|
|
11968
|
+
// if still no insightsClient was found, we use a noop
|
|
11969
|
+
var insightsClient = potentialInsightsClient || noop;
|
|
11970
|
+
return function (_ref2) {
|
|
11971
|
+
var instantSearchInstance = _ref2.instantSearchInstance;
|
|
11972
|
+
// remove existing default insights middleware
|
|
11973
|
+
// user-provided insights middleware takes precedence
|
|
11974
|
+
var existingInsightsMiddlewares = instantSearchInstance.middleware.filter(function (m) {
|
|
11975
|
+
return m.instance.$$type === 'ais.insights' && m.instance.$$internal;
|
|
11976
|
+
}).map(function (m) {
|
|
11977
|
+
return m.creator;
|
|
11978
|
+
});
|
|
11979
|
+
instantSearchInstance.unuse.apply(instantSearchInstance, _toConsumableArray(existingInsightsMiddlewares));
|
|
11980
|
+
var _getAppIdAndApiKey = getAppIdAndApiKey(instantSearchInstance.client),
|
|
11981
|
+
_getAppIdAndApiKey2 = _slicedToArray(_getAppIdAndApiKey, 2),
|
|
11982
|
+
appId = _getAppIdAndApiKey2[0],
|
|
11983
|
+
apiKey = _getAppIdAndApiKey2[1];
|
|
11984
|
+
|
|
11985
|
+
// search-insights.js also throws an error so dev-only clarification is sufficient
|
|
11986
|
+
_warning(Boolean(appId && apiKey), 'could not extract Algolia credentials from searchClient in insights middleware.') ;
|
|
11987
|
+
var queuedUserToken = undefined;
|
|
11988
|
+
var userTokenBeforeInit = undefined;
|
|
11989
|
+
if (Array.isArray(insightsClient.queue)) {
|
|
11990
|
+
// Context: The umd build of search-insights is asynchronously loaded by the snippet.
|
|
11991
|
+
//
|
|
11992
|
+
// When user calls `aa('setUserToken', 'my-user-token')` before `search-insights` is loaded,
|
|
11993
|
+
// ['setUserToken', 'my-user-token'] gets stored in `aa.queue`.
|
|
11994
|
+
// Whenever `search-insights` is finally loaded, it will process the queue.
|
|
11995
|
+
//
|
|
11996
|
+
// But here's the reason why we handle it here:
|
|
11997
|
+
// At this point, even though `search-insights` is not loaded yet,
|
|
11998
|
+
// we still want to read the token from the queue.
|
|
11999
|
+
// Otherwise, the first search call will be fired without the token.
|
|
12000
|
+
var _ref3 = find(insightsClient.queue.slice().reverse(), function (_ref5) {
|
|
12001
|
+
var _ref6 = _slicedToArray(_ref5, 1),
|
|
12002
|
+
method = _ref6[0];
|
|
12003
|
+
return method === 'setUserToken';
|
|
12004
|
+
}) || [];
|
|
12005
|
+
var _ref4 = _slicedToArray(_ref3, 2);
|
|
12006
|
+
queuedUserToken = _ref4[1];
|
|
12007
|
+
}
|
|
12008
|
+
insightsClient('getUserToken', null, function (_error, userToken) {
|
|
12009
|
+
// If user has called `aa('setUserToken', 'my-user-token')` before creating
|
|
12010
|
+
// the `insights` middleware, we store them temporarily and
|
|
12011
|
+
// set it later on.
|
|
12012
|
+
//
|
|
12013
|
+
// Otherwise, the `init` call might override it with anonymous user token.
|
|
12014
|
+
userTokenBeforeInit = userToken;
|
|
12015
|
+
});
|
|
12016
|
+
|
|
12017
|
+
// Only `init` if the `insightsInitParams` option is passed or
|
|
12018
|
+
// if the `insightsClient` version doesn't supports optional `init` calling.
|
|
12019
|
+
if (insightsInitParams || !isModernInsightsClient(insightsClient)) {
|
|
12020
|
+
insightsClient('init', _objectSpread2({
|
|
12021
|
+
appId: appId,
|
|
12022
|
+
apiKey: apiKey,
|
|
12023
|
+
partial: true
|
|
12024
|
+
}, insightsInitParams));
|
|
12025
|
+
}
|
|
12026
|
+
var initialParameters;
|
|
12027
|
+
var helper;
|
|
12028
|
+
return {
|
|
12029
|
+
$$type: 'ais.insights',
|
|
12030
|
+
$$internal: $$internal,
|
|
12031
|
+
onStateChange: function onStateChange() {},
|
|
12032
|
+
subscribe: function subscribe() {
|
|
12033
|
+
if (!insightsClient.shouldAddScript) return;
|
|
12034
|
+
var errorMessage = '[insights middleware]: could not load search-insights.js. Please load it manually following https://alg.li/insights-init';
|
|
12035
|
+
try {
|
|
12036
|
+
var script = document.createElement('script');
|
|
12037
|
+
script.async = true;
|
|
12038
|
+
script.src = ALGOLIA_INSIGHTS_SRC;
|
|
12039
|
+
script.onerror = function () {
|
|
12040
|
+
instantSearchInstance.emit('error', new Error(errorMessage));
|
|
12041
|
+
};
|
|
12042
|
+
document.body.appendChild(script);
|
|
12043
|
+
insightsClient.shouldAddScript = false;
|
|
12044
|
+
} catch (cause) {
|
|
12045
|
+
insightsClient.shouldAddScript = false;
|
|
12046
|
+
instantSearchInstance.emit('error', new Error(errorMessage));
|
|
12047
|
+
}
|
|
12048
|
+
},
|
|
12049
|
+
started: function started() {
|
|
12050
|
+
insightsClient('addAlgoliaAgent', 'insights-middleware');
|
|
12051
|
+
helper = instantSearchInstance.helper;
|
|
12052
|
+
initialParameters = {
|
|
12053
|
+
userToken: helper.state.userToken,
|
|
12054
|
+
clickAnalytics: helper.state.clickAnalytics
|
|
12055
|
+
};
|
|
12056
|
+
helper.overrideStateWithoutTriggeringChangeEvent(_objectSpread2(_objectSpread2({}, helper.state), {}, {
|
|
12057
|
+
clickAnalytics: true
|
|
12058
|
+
}));
|
|
12059
|
+
if (!$$internal) {
|
|
12060
|
+
instantSearchInstance.scheduleSearch();
|
|
12061
|
+
}
|
|
12062
|
+
var setUserTokenToSearch = function setUserTokenToSearch(userToken) {
|
|
12063
|
+
if (!userToken) {
|
|
12064
|
+
return;
|
|
12065
|
+
}
|
|
12066
|
+
var existingToken = helper.state.userToken;
|
|
12067
|
+
helper.overrideStateWithoutTriggeringChangeEvent(_objectSpread2(_objectSpread2({}, helper.state), {}, {
|
|
12068
|
+
userToken: userToken
|
|
12069
|
+
}));
|
|
12070
|
+
if (existingToken && existingToken !== userToken) {
|
|
12071
|
+
instantSearchInstance.scheduleSearch();
|
|
12072
|
+
}
|
|
12073
|
+
};
|
|
12074
|
+
var anonymousUserToken = getInsightsAnonymousUserTokenInternal();
|
|
12075
|
+
if (anonymousUserToken) {
|
|
12076
|
+
// When `aa('init', { ... })` is called, it creates an anonymous user token in cookie.
|
|
12077
|
+
// We can set it as userToken.
|
|
12078
|
+
setUserTokenToSearch(anonymousUserToken);
|
|
12079
|
+
}
|
|
12080
|
+
|
|
12081
|
+
// We consider the `userToken` coming from a `init` call to have a higher
|
|
12082
|
+
// importance than the one coming from the queue.
|
|
12083
|
+
if (userTokenBeforeInit) {
|
|
12084
|
+
setUserTokenToSearch(userTokenBeforeInit);
|
|
12085
|
+
insightsClient('setUserToken', userTokenBeforeInit);
|
|
12086
|
+
} else if (queuedUserToken) {
|
|
12087
|
+
setUserTokenToSearch(queuedUserToken);
|
|
12088
|
+
insightsClient('setUserToken', queuedUserToken);
|
|
12089
|
+
}
|
|
12090
|
+
|
|
12091
|
+
// This updates userToken which is set explicitly by `aa('setUserToken', userToken)`
|
|
12092
|
+
insightsClient('onUserTokenChange', setUserTokenToSearch, {
|
|
12093
|
+
immediate: true
|
|
12094
|
+
});
|
|
12095
|
+
var insightsClientWithLocalCredentials = insightsClient;
|
|
12096
|
+
if (isModernInsightsClient(insightsClient)) {
|
|
12097
|
+
insightsClientWithLocalCredentials = function insightsClientWithLocalCredentials(method, payload) {
|
|
12098
|
+
var extraParams = {
|
|
12099
|
+
headers: {
|
|
12100
|
+
'X-Algolia-Application-Id': appId,
|
|
12101
|
+
'X-Algolia-API-Key': apiKey
|
|
12102
|
+
}
|
|
12103
|
+
};
|
|
12104
|
+
|
|
12105
|
+
// @ts-ignore we are calling this only when we know that the client actually is correct
|
|
12106
|
+
return insightsClient(method, payload, extraParams);
|
|
12107
|
+
};
|
|
12108
|
+
}
|
|
12109
|
+
instantSearchInstance.sendEventToInsights = function (event) {
|
|
12110
|
+
if (onEvent) {
|
|
12111
|
+
onEvent(event, insightsClientWithLocalCredentials);
|
|
12112
|
+
} else if (event.insightsMethod) {
|
|
12113
|
+
// Source is used to differentiate events sent by instantsearch from those sent manually.
|
|
12114
|
+
event.payload.algoliaSource = ['instantsearch'];
|
|
12115
|
+
if (event.eventModifier === 'internal') {
|
|
12116
|
+
event.payload.algoliaSource.push('instantsearch-internal');
|
|
12117
|
+
}
|
|
12118
|
+
insightsClientWithLocalCredentials(event.insightsMethod, event.payload);
|
|
12119
|
+
_warning(Boolean(helper.state.userToken), "\nCannot send event to Algolia Insights because `userToken` is not set.\n\nSee documentation: https://www.algolia.com/doc/guides/building-search-ui/going-further/send-insights-events/js/#setting-the-usertoken\n") ;
|
|
12120
|
+
} else {
|
|
12121
|
+
_warning(false, 'Cannot send event to Algolia Insights because `insightsMethod` option is missing.') ;
|
|
12122
|
+
}
|
|
12123
|
+
};
|
|
12124
|
+
},
|
|
12125
|
+
unsubscribe: function unsubscribe() {
|
|
12126
|
+
insightsClient('onUserTokenChange', undefined);
|
|
12127
|
+
instantSearchInstance.sendEventToInsights = noop;
|
|
12128
|
+
if (helper && initialParameters) {
|
|
12129
|
+
helper.overrideStateWithoutTriggeringChangeEvent(_objectSpread2(_objectSpread2({}, helper.state), initialParameters));
|
|
12130
|
+
instantSearchInstance.scheduleSearch();
|
|
12131
|
+
}
|
|
12132
|
+
}
|
|
12133
|
+
};
|
|
12134
|
+
};
|
|
12135
|
+
}
|
|
12136
|
+
|
|
12137
|
+
/**
|
|
12138
|
+
* Determines if a given insights `client` supports the optional call to `init`
|
|
12139
|
+
* and the ability to set credentials via extra parameters when sending events.
|
|
12140
|
+
*/
|
|
12141
|
+
function isModernInsightsClient(client) {
|
|
12142
|
+
var _split$map = (client.version || '').split('.').map(Number),
|
|
12143
|
+
_split$map2 = _slicedToArray(_split$map, 2),
|
|
12144
|
+
major = _split$map2[0],
|
|
12145
|
+
minor = _split$map2[1];
|
|
12146
|
+
|
|
12147
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
12148
|
+
var v3 = major >= 3;
|
|
12149
|
+
var v2_6 = major === 2 && minor >= 6;
|
|
12150
|
+
var v1_10 = major === 1 && minor >= 10;
|
|
12151
|
+
/* eslint-enable @typescript-eslint/naming-convention */
|
|
12152
|
+
|
|
12153
|
+
return v3 || v2_6 || v1_10;
|
|
12154
|
+
}
|
|
12155
|
+
|
|
12156
|
+
function extractWidgetPayload(widgets, instantSearchInstance, payload) {
|
|
11883
12157
|
var initOptions = createInitArgs(instantSearchInstance, instantSearchInstance.mainIndex, instantSearchInstance._initialUiState);
|
|
11884
12158
|
widgets.forEach(function (widget) {
|
|
11885
12159
|
var widgetParams = {};
|
|
@@ -11901,7 +12175,7 @@
|
|
|
11901
12175
|
params: params
|
|
11902
12176
|
});
|
|
11903
12177
|
if (widget.$$type === 'ais.index') {
|
|
11904
|
-
|
|
12178
|
+
extractWidgetPayload(widget.getWidgets(), instantSearchInstance, payload);
|
|
11905
12179
|
}
|
|
11906
12180
|
});
|
|
11907
12181
|
}
|
|
@@ -11925,8 +12199,11 @@
|
|
|
11925
12199
|
* - connector name
|
|
11926
12200
|
*/
|
|
11927
12201
|
function createMetadataMiddleware() {
|
|
11928
|
-
|
|
11929
|
-
|
|
12202
|
+
var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
12203
|
+
_ref2$$$internal = _ref2.$$internal,
|
|
12204
|
+
$$internal = _ref2$$$internal === void 0 ? false : _ref2$$$internal;
|
|
12205
|
+
return function (_ref3) {
|
|
12206
|
+
var instantSearchInstance = _ref3.instantSearchInstance;
|
|
11930
12207
|
var payload = {
|
|
11931
12208
|
widgets: []
|
|
11932
12209
|
};
|
|
@@ -11934,13 +12211,22 @@
|
|
|
11934
12211
|
var refNode = document.querySelector('head');
|
|
11935
12212
|
payloadContainer.name = 'instantsearch:widgets';
|
|
11936
12213
|
return {
|
|
12214
|
+
$$type: 'ais.metadata',
|
|
12215
|
+
$$internal: $$internal,
|
|
11937
12216
|
onStateChange: function onStateChange() {},
|
|
11938
12217
|
subscribe: function subscribe() {
|
|
11939
12218
|
// using setTimeout here to delay extraction until widgets have been added in a tick (e.g. Vue)
|
|
11940
12219
|
setTimeout(function () {
|
|
11941
12220
|
var client = instantSearchInstance.client;
|
|
11942
12221
|
payload.ua = client.transporter && client.transporter.userAgent ? client.transporter.userAgent.value : client._ua;
|
|
11943
|
-
|
|
12222
|
+
extractWidgetPayload(instantSearchInstance.mainIndex.getWidgets(), instantSearchInstance, payload);
|
|
12223
|
+
instantSearchInstance.middleware.forEach(function (middleware) {
|
|
12224
|
+
return payload.widgets.push({
|
|
12225
|
+
middleware: true,
|
|
12226
|
+
type: middleware.instance.$$type,
|
|
12227
|
+
internal: middleware.instance.$$internal
|
|
12228
|
+
});
|
|
12229
|
+
});
|
|
11944
12230
|
payloadContainer.content = JSON.stringify(payload);
|
|
11945
12231
|
refNode.appendChild(payloadContainer);
|
|
11946
12232
|
}, 0);
|
|
@@ -12792,6 +13078,7 @@
|
|
|
12792
13078
|
dispose = _ref.dispose,
|
|
12793
13079
|
push = _ref.push;
|
|
12794
13080
|
_classCallCheck(this, BrowserHistory);
|
|
13081
|
+
_defineProperty(this, "$$type", 'ais.browser');
|
|
12795
13082
|
_defineProperty(this, "windowTitle", void 0);
|
|
12796
13083
|
_defineProperty(this, "writeDelay", void 0);
|
|
12797
13084
|
_defineProperty(this, "_createURL", void 0);
|
|
@@ -13044,6 +13331,7 @@
|
|
|
13044
13331
|
// which excludes "configure" as this function does.
|
|
13045
13332
|
function simpleStateMapping() {
|
|
13046
13333
|
return {
|
|
13334
|
+
$$type: 'ais.simple',
|
|
13047
13335
|
stateToRoute: function stateToRoute(uiState) {
|
|
13048
13336
|
return Object.keys(uiState).reduce(function (state, indexId) {
|
|
13049
13337
|
return _objectSpread2(_objectSpread2({}, state), {}, _defineProperty({}, indexId, getIndexStateWithoutConfigure(uiState[indexId])));
|
|
@@ -13063,7 +13351,9 @@
|
|
|
13063
13351
|
var _props$router = props.router,
|
|
13064
13352
|
router = _props$router === void 0 ? historyRouter() : _props$router,
|
|
13065
13353
|
_props$stateMapping = props.stateMapping,
|
|
13066
|
-
stateMapping = _props$stateMapping === void 0 ? simpleStateMapping() : _props$stateMapping
|
|
13354
|
+
stateMapping = _props$stateMapping === void 0 ? simpleStateMapping() : _props$stateMapping,
|
|
13355
|
+
_props$$$internal = props.$$internal,
|
|
13356
|
+
$$internal = _props$$$internal === void 0 ? false : _props$$$internal;
|
|
13067
13357
|
return function (_ref) {
|
|
13068
13358
|
var instantSearchInstance = _ref.instantSearchInstance;
|
|
13069
13359
|
function topLevelCreateURL(nextState) {
|
|
@@ -13080,6 +13370,8 @@
|
|
|
13080
13370
|
var lastRouteState = undefined;
|
|
13081
13371
|
var initialUiState = instantSearchInstance._initialUiState;
|
|
13082
13372
|
return {
|
|
13373
|
+
$$type: "ais.router({router:".concat(router.$$type || '__unknown__', ", stateMapping:").concat(stateMapping.$$type || '__unknown__', "})"),
|
|
13374
|
+
$$internal: $$internal,
|
|
13083
13375
|
onStateChange: function onStateChange(_ref2) {
|
|
13084
13376
|
var uiState = _ref2.uiState;
|
|
13085
13377
|
var routeState = stateMapping.stateToRoute(uiState);
|
|
@@ -13640,7 +13932,7 @@
|
|
|
13640
13932
|
};
|
|
13641
13933
|
}
|
|
13642
13934
|
|
|
13643
|
-
var version$1 = '4.
|
|
13935
|
+
var version$1 = '4.55.0';
|
|
13644
13936
|
|
|
13645
13937
|
var withUsage$r = createDocumentationMessageGenerator({
|
|
13646
13938
|
name: 'instantsearch'
|
|
@@ -13725,6 +14017,8 @@
|
|
|
13725
14017
|
initialUiState = _options$initialUiSta === void 0 ? {} : _options$initialUiSta,
|
|
13726
14018
|
_options$routing = options.routing,
|
|
13727
14019
|
routing = _options$routing === void 0 ? null : _options$routing,
|
|
14020
|
+
_options$insights = options.insights,
|
|
14021
|
+
insights = _options$insights === void 0 ? false : _options$insights,
|
|
13728
14022
|
searchFunction = options.searchFunction,
|
|
13729
14023
|
_options$stalledSearc = options.stalledSearchDelay,
|
|
13730
14024
|
stalledSearchDelay = _options$stalledSearc === void 0 ? 200 : _options$stalledSearc,
|
|
@@ -13780,11 +14074,22 @@
|
|
|
13780
14074
|
}
|
|
13781
14075
|
_this.sendEventToInsights = noop;
|
|
13782
14076
|
if (routing) {
|
|
13783
|
-
var routerOptions = typeof routing === 'boolean' ?
|
|
14077
|
+
var routerOptions = typeof routing === 'boolean' ? {} : routing;
|
|
14078
|
+
routerOptions.$$internal = true;
|
|
13784
14079
|
_this.use(createRouterMiddleware(routerOptions));
|
|
13785
14080
|
}
|
|
14081
|
+
|
|
14082
|
+
// This is the default middleware,
|
|
14083
|
+
// any user-provided middleware will be added later and override this one.
|
|
14084
|
+
if (insights) {
|
|
14085
|
+
var insightsOptions = typeof insights === 'boolean' ? {} : insights;
|
|
14086
|
+
insightsOptions.$$internal = true;
|
|
14087
|
+
_this.use(createInsightsMiddleware(insightsOptions));
|
|
14088
|
+
}
|
|
13786
14089
|
if (isMetadataEnabled()) {
|
|
13787
|
-
_this.use(createMetadataMiddleware(
|
|
14090
|
+
_this.use(createMetadataMiddleware({
|
|
14091
|
+
$$internal: true
|
|
14092
|
+
}));
|
|
13788
14093
|
}
|
|
13789
14094
|
return _this;
|
|
13790
14095
|
}
|
|
@@ -13820,6 +14125,8 @@
|
|
|
13820
14125
|
}
|
|
13821
14126
|
var newMiddlewareList = middleware.map(function (fn) {
|
|
13822
14127
|
var newMiddleware = _objectSpread2({
|
|
14128
|
+
$$type: '__unknown__',
|
|
14129
|
+
$$internal: false,
|
|
13823
14130
|
subscribe: noop,
|
|
13824
14131
|
started: noop,
|
|
13825
14132
|
unsubscribe: noop,
|
|
@@ -14197,6 +14504,7 @@
|
|
|
14197
14504
|
}
|
|
14198
14505
|
function singleIndexStateMapping(indexName) {
|
|
14199
14506
|
return {
|
|
14507
|
+
$$type: 'ais.singleIndex',
|
|
14200
14508
|
stateToRoute: function stateToRoute(uiState) {
|
|
14201
14509
|
return getIndexStateWithoutConfigure$1(uiState[indexName] || {});
|
|
14202
14510
|
},
|
|
@@ -14215,130 +14523,6 @@
|
|
|
14215
14523
|
singleIndex: singleIndexStateMapping
|
|
14216
14524
|
});
|
|
14217
14525
|
|
|
14218
|
-
function createInsightsMiddleware(props) {
|
|
14219
|
-
var _ref = props || {},
|
|
14220
|
-
_insightsClient = _ref.insightsClient,
|
|
14221
|
-
insightsInitParams = _ref.insightsInitParams,
|
|
14222
|
-
onEvent = _ref.onEvent;
|
|
14223
|
-
if (_insightsClient !== null && !_insightsClient) {
|
|
14224
|
-
{
|
|
14225
|
-
throw new Error("The `insightsClient` option is required if you want userToken to be automatically set in search calls. If you don't want this behaviour, set it to `null`.");
|
|
14226
|
-
}
|
|
14227
|
-
}
|
|
14228
|
-
var hasInsightsClient = Boolean(_insightsClient);
|
|
14229
|
-
var insightsClient = _insightsClient === null ? noop : _insightsClient;
|
|
14230
|
-
return function (_ref2) {
|
|
14231
|
-
var instantSearchInstance = _ref2.instantSearchInstance;
|
|
14232
|
-
var _getAppIdAndApiKey = getAppIdAndApiKey(instantSearchInstance.client),
|
|
14233
|
-
_getAppIdAndApiKey2 = _slicedToArray(_getAppIdAndApiKey, 2),
|
|
14234
|
-
appId = _getAppIdAndApiKey2[0],
|
|
14235
|
-
apiKey = _getAppIdAndApiKey2[1];
|
|
14236
|
-
|
|
14237
|
-
// search-insights.js also throws an error so dev-only clarification is sufficient
|
|
14238
|
-
if ( !(appId && apiKey)) {
|
|
14239
|
-
throw new Error('[insights middleware]: could not extract Algolia credentials from searchClient');
|
|
14240
|
-
}
|
|
14241
|
-
var queuedUserToken = undefined;
|
|
14242
|
-
var userTokenBeforeInit = undefined;
|
|
14243
|
-
if (Array.isArray(insightsClient.queue)) {
|
|
14244
|
-
// Context: The umd build of search-insights is asynchronously loaded by the snippet.
|
|
14245
|
-
//
|
|
14246
|
-
// When user calls `aa('setUserToken', 'my-user-token')` before `search-insights` is loaded,
|
|
14247
|
-
// ['setUserToken', 'my-user-token'] gets stored in `aa.queue`.
|
|
14248
|
-
// Whenever `search-insights` is finally loaded, it will process the queue.
|
|
14249
|
-
//
|
|
14250
|
-
// But here's the reason why we handle it here:
|
|
14251
|
-
// At this point, even though `search-insights` is not loaded yet,
|
|
14252
|
-
// we still want to read the token from the queue.
|
|
14253
|
-
// Otherwise, the first search call will be fired without the token.
|
|
14254
|
-
var _ref3 = find(insightsClient.queue.slice().reverse(), function (_ref5) {
|
|
14255
|
-
var _ref6 = _slicedToArray(_ref5, 1),
|
|
14256
|
-
method = _ref6[0];
|
|
14257
|
-
return method === 'setUserToken';
|
|
14258
|
-
}) || [];
|
|
14259
|
-
var _ref4 = _slicedToArray(_ref3, 2);
|
|
14260
|
-
queuedUserToken = _ref4[1];
|
|
14261
|
-
}
|
|
14262
|
-
insightsClient('getUserToken', null, function (_error, userToken) {
|
|
14263
|
-
// If user has called `aa('setUserToken', 'my-user-token')` before creating
|
|
14264
|
-
// the `insights` middleware, we store them temporarily and
|
|
14265
|
-
// set it later on.
|
|
14266
|
-
//
|
|
14267
|
-
// Otherwise, the `init` call might override it with anonymous user token.
|
|
14268
|
-
userTokenBeforeInit = userToken;
|
|
14269
|
-
});
|
|
14270
|
-
insightsClient('init', _objectSpread2({
|
|
14271
|
-
appId: appId,
|
|
14272
|
-
apiKey: apiKey
|
|
14273
|
-
}, insightsInitParams));
|
|
14274
|
-
var initialParameters;
|
|
14275
|
-
var helper;
|
|
14276
|
-
return {
|
|
14277
|
-
onStateChange: function onStateChange() {},
|
|
14278
|
-
subscribe: function subscribe() {},
|
|
14279
|
-
started: function started() {
|
|
14280
|
-
insightsClient('addAlgoliaAgent', 'insights-middleware');
|
|
14281
|
-
helper = instantSearchInstance.helper;
|
|
14282
|
-
initialParameters = {
|
|
14283
|
-
userToken: helper.state.userToken,
|
|
14284
|
-
clickAnalytics: helper.state.clickAnalytics
|
|
14285
|
-
};
|
|
14286
|
-
helper.overrideStateWithoutTriggeringChangeEvent(_objectSpread2(_objectSpread2({}, helper.state), {}, {
|
|
14287
|
-
clickAnalytics: true
|
|
14288
|
-
}));
|
|
14289
|
-
instantSearchInstance.scheduleSearch();
|
|
14290
|
-
var setUserTokenToSearch = function setUserTokenToSearch(userToken) {
|
|
14291
|
-
helper.overrideStateWithoutTriggeringChangeEvent(_objectSpread2(_objectSpread2({}, helper.state), {}, {
|
|
14292
|
-
userToken: userToken
|
|
14293
|
-
}));
|
|
14294
|
-
instantSearchInstance.scheduleSearch();
|
|
14295
|
-
};
|
|
14296
|
-
var anonymousUserToken = getInsightsAnonymousUserTokenInternal();
|
|
14297
|
-
if (hasInsightsClient && anonymousUserToken) {
|
|
14298
|
-
// When `aa('init', { ... })` is called, it creates an anonymous user token in cookie.
|
|
14299
|
-
// We can set it as userToken.
|
|
14300
|
-
setUserTokenToSearch(anonymousUserToken);
|
|
14301
|
-
}
|
|
14302
|
-
|
|
14303
|
-
// We consider the `userToken` coming from a `init` call to have a higher
|
|
14304
|
-
// importance than the one coming from the queue.
|
|
14305
|
-
if (userTokenBeforeInit) {
|
|
14306
|
-
insightsClient('setUserToken', userTokenBeforeInit);
|
|
14307
|
-
} else if (queuedUserToken) {
|
|
14308
|
-
insightsClient('setUserToken', queuedUserToken);
|
|
14309
|
-
}
|
|
14310
|
-
|
|
14311
|
-
// This updates userToken which is set explicitly by `aa('setUserToken', userToken)`
|
|
14312
|
-
insightsClient('onUserTokenChange', setUserTokenToSearch, {
|
|
14313
|
-
immediate: true
|
|
14314
|
-
});
|
|
14315
|
-
instantSearchInstance.sendEventToInsights = function (event) {
|
|
14316
|
-
if (onEvent) {
|
|
14317
|
-
onEvent(event, _insightsClient);
|
|
14318
|
-
} else if (event.insightsMethod) {
|
|
14319
|
-
var hasUserToken = Boolean(helper.state.userToken);
|
|
14320
|
-
if (hasUserToken) {
|
|
14321
|
-
insightsClient(event.insightsMethod, event.payload);
|
|
14322
|
-
} else {
|
|
14323
|
-
_warning(false, "\nCannot send event to Algolia Insights because `userToken` is not set.\n\nSee documentation: https://www.algolia.com/doc/guides/building-search-ui/going-further/send-insights-events/js/#setting-the-usertoken\n") ;
|
|
14324
|
-
}
|
|
14325
|
-
} else {
|
|
14326
|
-
_warning(false, 'Cannot send event to Algolia Insights because `insightsMethod` option is missing.') ;
|
|
14327
|
-
}
|
|
14328
|
-
};
|
|
14329
|
-
},
|
|
14330
|
-
unsubscribe: function unsubscribe() {
|
|
14331
|
-
insightsClient('onUserTokenChange', undefined);
|
|
14332
|
-
instantSearchInstance.sendEventToInsights = noop;
|
|
14333
|
-
if (helper && initialParameters) {
|
|
14334
|
-
helper.setState(_objectSpread2(_objectSpread2({}, helper.state), initialParameters));
|
|
14335
|
-
instantSearchInstance.scheduleSearch();
|
|
14336
|
-
}
|
|
14337
|
-
}
|
|
14338
|
-
};
|
|
14339
|
-
};
|
|
14340
|
-
}
|
|
14341
|
-
|
|
14342
14526
|
|
|
14343
14527
|
|
|
14344
14528
|
var middlewares = /*#__PURE__*/Object.freeze({
|
|
@@ -15355,7 +15539,7 @@
|
|
|
15355
15539
|
}
|
|
15356
15540
|
|
|
15357
15541
|
var _excluded$d = ["hit", "attribute", "cssClasses"],
|
|
15358
|
-
_excluded2$
|
|
15542
|
+
_excluded2$2 = ["isHighlighted"];
|
|
15359
15543
|
function ReverseHighlight$1(_ref) {
|
|
15360
15544
|
var hit = _ref.hit,
|
|
15361
15545
|
attribute = _ref.attribute,
|
|
@@ -15368,7 +15552,7 @@
|
|
|
15368
15552
|
var value = _ref2.value;
|
|
15369
15553
|
return getHighlightedParts(unescape$1(value || '')).map(function (_ref3) {
|
|
15370
15554
|
var isHighlighted = _ref3.isHighlighted,
|
|
15371
|
-
rest = _objectWithoutProperties(_ref3, _excluded2$
|
|
15555
|
+
rest = _objectWithoutProperties(_ref3, _excluded2$2);
|
|
15372
15556
|
return _objectSpread2(_objectSpread2({}, rest), {}, {
|
|
15373
15557
|
isHighlighted: !isHighlighted
|
|
15374
15558
|
});
|
|
@@ -15396,7 +15580,7 @@
|
|
|
15396
15580
|
}
|
|
15397
15581
|
|
|
15398
15582
|
var _excluded$f = ["hit", "attribute", "cssClasses"],
|
|
15399
|
-
_excluded2$
|
|
15583
|
+
_excluded2$3 = ["isHighlighted"];
|
|
15400
15584
|
function ReverseSnippet$1(_ref) {
|
|
15401
15585
|
var hit = _ref.hit,
|
|
15402
15586
|
attribute = _ref.attribute,
|
|
@@ -15409,7 +15593,7 @@
|
|
|
15409
15593
|
var value = _ref2.value;
|
|
15410
15594
|
return getHighlightedParts(unescape$1(value || '')).map(function (_ref3) {
|
|
15411
15595
|
var isHighlighted = _ref3.isHighlighted,
|
|
15412
|
-
rest = _objectWithoutProperties(_ref3, _excluded2$
|
|
15596
|
+
rest = _objectWithoutProperties(_ref3, _excluded2$3);
|
|
15413
15597
|
return _objectSpread2(_objectSpread2({}, rest), {}, {
|
|
15414
15598
|
isHighlighted: !isHighlighted
|
|
15415
15599
|
});
|
|
@@ -15535,9 +15719,12 @@
|
|
|
15535
15719
|
key: "render",
|
|
15536
15720
|
value: function render() {
|
|
15537
15721
|
var _this = this;
|
|
15538
|
-
|
|
15539
|
-
|
|
15540
|
-
|
|
15722
|
+
{
|
|
15723
|
+
var nonFunctionTemplates = Object.keys(this.props.templates).filter(function (key) {
|
|
15724
|
+
return typeof _this.props.templates[key] !== 'function';
|
|
15725
|
+
});
|
|
15726
|
+
_warning(nonFunctionTemplates.length === 0, "Hogan.js and string-based templates are deprecated and will not be supported in InstantSearch.js 5.x.\n\nYou can replace them with function-form templates and use either the provided `html` function or JSX templates.\n\nString-based templates: ".concat(nonFunctionTemplates.join(', '), ".\n\nSee: https://www.algolia.com/doc/guides/building-search-ui/upgrade-guides/js/#upgrade-templates")) ;
|
|
15727
|
+
}
|
|
15541
15728
|
var RootTagName = this.props.rootTagName;
|
|
15542
15729
|
var useCustomCompileOptions = this.props.useCustomCompileOptions[this.props.templateKey];
|
|
15543
15730
|
var compileOptions = useCustomCompileOptions ? this.props.templatesConfig.compileOptions : {};
|
|
@@ -16696,7 +16883,7 @@
|
|
|
16696
16883
|
};
|
|
16697
16884
|
|
|
16698
16885
|
var _excluded$j = ["initialZoom", "initialPosition", "templates", "cssClasses", "builtInMarker", "customHTMLMarker", "enableRefine", "enableClearMapRefinement", "enableRefineControl", "container", "googleReference"],
|
|
16699
|
-
_excluded2$
|
|
16886
|
+
_excluded2$4 = ["item"],
|
|
16700
16887
|
_excluded3 = ["item"];
|
|
16701
16888
|
var withUsage$y = createDocumentationMessageGenerator({
|
|
16702
16889
|
name: 'geo-search'
|
|
@@ -16798,7 +16985,7 @@
|
|
|
16798
16985
|
var customHTMLMarker = isCustomHTMLMarker && _objectSpread2(_objectSpread2({}, defaultCustomHTMLMarker), userCustomHTMLMarker);
|
|
16799
16986
|
var createBuiltInMarker = function createBuiltInMarker(_ref2) {
|
|
16800
16987
|
var item = _ref2.item,
|
|
16801
|
-
rest = _objectWithoutProperties(_ref2, _excluded2$
|
|
16988
|
+
rest = _objectWithoutProperties(_ref2, _excluded2$4);
|
|
16802
16989
|
return new googleReference.maps.Marker(_objectSpread2(_objectSpread2(_objectSpread2({}, builtInMarker.createOptions(item)), rest), {}, {
|
|
16803
16990
|
// @ts-expect-error @types/googlemaps doesn't document this
|
|
16804
16991
|
__id: item.objectID,
|
|
@@ -17471,18 +17658,24 @@
|
|
|
17471
17658
|
});
|
|
17472
17659
|
};
|
|
17473
17660
|
|
|
17474
|
-
|
|
17661
|
+
function Hits(_ref) {
|
|
17475
17662
|
var results = _ref.results,
|
|
17476
17663
|
hits = _ref.hits,
|
|
17664
|
+
insights = _ref.insights,
|
|
17477
17665
|
bindEvent = _ref.bindEvent,
|
|
17478
17666
|
sendEvent = _ref.sendEvent,
|
|
17479
17667
|
cssClasses = _ref.cssClasses,
|
|
17480
17668
|
templateProps = _ref.templateProps;
|
|
17669
|
+
var handleInsightsClick = createInsightsEventHandler({
|
|
17670
|
+
insights: insights,
|
|
17671
|
+
sendEvent: sendEvent
|
|
17672
|
+
});
|
|
17481
17673
|
if (results.hits.length === 0) {
|
|
17482
17674
|
return h(Template, _extends({}, templateProps, {
|
|
17483
17675
|
templateKey: "empty",
|
|
17484
17676
|
rootProps: {
|
|
17485
|
-
className: cx(cssClasses.root, cssClasses.emptyRoot)
|
|
17677
|
+
className: cx(cssClasses.root, cssClasses.emptyRoot),
|
|
17678
|
+
onClick: handleInsightsClick
|
|
17486
17679
|
},
|
|
17487
17680
|
data: results
|
|
17488
17681
|
}));
|
|
@@ -17496,7 +17689,11 @@
|
|
|
17496
17689
|
templateKey: "item",
|
|
17497
17690
|
rootTagName: "li",
|
|
17498
17691
|
rootProps: {
|
|
17499
|
-
className: cssClasses.item
|
|
17692
|
+
className: cssClasses.item,
|
|
17693
|
+
onClick: function onClick(event) {
|
|
17694
|
+
handleInsightsClick(event);
|
|
17695
|
+
sendEvent('click:internal', hit, 'Hit Clicked');
|
|
17696
|
+
}
|
|
17500
17697
|
},
|
|
17501
17698
|
key: hit.objectID,
|
|
17502
17699
|
data: _objectSpread2(_objectSpread2({}, hit), {}, {
|
|
@@ -17509,7 +17706,7 @@
|
|
|
17509
17706
|
sendEvent: sendEvent
|
|
17510
17707
|
}));
|
|
17511
17708
|
})));
|
|
17512
|
-
}
|
|
17709
|
+
}
|
|
17513
17710
|
|
|
17514
17711
|
var defaultTemplates$5 = {
|
|
17515
17712
|
empty: function empty() {
|
|
@@ -17524,7 +17721,6 @@
|
|
|
17524
17721
|
name: 'hits'
|
|
17525
17722
|
});
|
|
17526
17723
|
var suit$b = component('Hits');
|
|
17527
|
-
var HitsWithInsightsListener = insightsListener(Hits);
|
|
17528
17724
|
var renderer$6 = function renderer(_ref) {
|
|
17529
17725
|
var renderState = _ref.renderState,
|
|
17530
17726
|
cssClasses = _ref.cssClasses,
|
|
@@ -17545,7 +17741,7 @@
|
|
|
17545
17741
|
});
|
|
17546
17742
|
return;
|
|
17547
17743
|
}
|
|
17548
|
-
P(h(
|
|
17744
|
+
P(h(Hits, {
|
|
17549
17745
|
cssClasses: cssClasses,
|
|
17550
17746
|
hits: receivedHits,
|
|
17551
17747
|
results: results,
|
|
@@ -17682,6 +17878,7 @@
|
|
|
17682
17878
|
var InfiniteHits = function InfiniteHits(_ref) {
|
|
17683
17879
|
var results = _ref.results,
|
|
17684
17880
|
hits = _ref.hits,
|
|
17881
|
+
insights = _ref.insights,
|
|
17685
17882
|
bindEvent = _ref.bindEvent,
|
|
17686
17883
|
sendEvent = _ref.sendEvent,
|
|
17687
17884
|
hasShowPrevious = _ref.hasShowPrevious,
|
|
@@ -17691,11 +17888,16 @@
|
|
|
17691
17888
|
isLastPage = _ref.isLastPage,
|
|
17692
17889
|
cssClasses = _ref.cssClasses,
|
|
17693
17890
|
templateProps = _ref.templateProps;
|
|
17891
|
+
var handleInsightsClick = createInsightsEventHandler({
|
|
17892
|
+
insights: insights,
|
|
17893
|
+
sendEvent: sendEvent
|
|
17894
|
+
});
|
|
17694
17895
|
if (results.hits.length === 0) {
|
|
17695
17896
|
return h(Template, _extends({}, templateProps, {
|
|
17696
17897
|
templateKey: "empty",
|
|
17697
17898
|
rootProps: {
|
|
17698
|
-
className: cx(cssClasses.root, cssClasses.emptyRoot)
|
|
17899
|
+
className: cx(cssClasses.root, cssClasses.emptyRoot),
|
|
17900
|
+
onClick: handleInsightsClick
|
|
17699
17901
|
},
|
|
17700
17902
|
data: results
|
|
17701
17903
|
}));
|
|
@@ -17717,7 +17919,11 @@
|
|
|
17717
17919
|
templateKey: "item",
|
|
17718
17920
|
rootTagName: "li",
|
|
17719
17921
|
rootProps: {
|
|
17720
|
-
className: cssClasses.item
|
|
17922
|
+
className: cssClasses.item,
|
|
17923
|
+
onClick: function onClick(event) {
|
|
17924
|
+
handleInsightsClick(event);
|
|
17925
|
+
sendEvent('click:internal', hit, 'Hit Clicked');
|
|
17926
|
+
}
|
|
17721
17927
|
},
|
|
17722
17928
|
key: hit.objectID,
|
|
17723
17929
|
data: _objectSpread2(_objectSpread2({}, hit), {}, {
|
|
@@ -17759,7 +17965,6 @@
|
|
|
17759
17965
|
name: 'infinite-hits'
|
|
17760
17966
|
});
|
|
17761
17967
|
var suit$d = component('InfiniteHits');
|
|
17762
|
-
var InfiniteHitsWithInsightsListener = insightsListener(InfiniteHits);
|
|
17763
17968
|
var renderer$8 = function renderer(_ref) {
|
|
17764
17969
|
var containerNode = _ref.containerNode,
|
|
17765
17970
|
cssClasses = _ref.cssClasses,
|
|
@@ -17785,7 +17990,7 @@
|
|
|
17785
17990
|
});
|
|
17786
17991
|
return;
|
|
17787
17992
|
}
|
|
17788
|
-
P(h(
|
|
17993
|
+
P(h(InfiniteHits, {
|
|
17789
17994
|
cssClasses: cssClasses,
|
|
17790
17995
|
hits: hits,
|
|
17791
17996
|
results: results,
|
|
@@ -18256,7 +18461,8 @@
|
|
|
18256
18461
|
ariaLabel: "First",
|
|
18257
18462
|
className: props.cssClasses.firstPageItem,
|
|
18258
18463
|
isDisabled: props.isFirstPage,
|
|
18259
|
-
|
|
18464
|
+
templates: props.templates,
|
|
18465
|
+
templateKey: "first",
|
|
18260
18466
|
pageNumber: 0,
|
|
18261
18467
|
createURL: props.createURL,
|
|
18262
18468
|
cssClasses: props.cssClasses,
|
|
@@ -18265,7 +18471,8 @@
|
|
|
18265
18471
|
ariaLabel: "Previous",
|
|
18266
18472
|
className: props.cssClasses.previousPageItem,
|
|
18267
18473
|
isDisabled: props.isFirstPage,
|
|
18268
|
-
|
|
18474
|
+
templates: props.templates,
|
|
18475
|
+
templateKey: "previous",
|
|
18269
18476
|
pageNumber: props.currentPage - 1,
|
|
18270
18477
|
createURL: props.createURL,
|
|
18271
18478
|
cssClasses: props.cssClasses,
|
|
@@ -18276,7 +18483,8 @@
|
|
|
18276
18483
|
ariaLabel: "Page ".concat(pageNumber + 1),
|
|
18277
18484
|
className: props.cssClasses.pageItem,
|
|
18278
18485
|
isSelected: pageNumber === props.currentPage,
|
|
18279
|
-
|
|
18486
|
+
templates: props.templates,
|
|
18487
|
+
templateKey: "page",
|
|
18280
18488
|
pageNumber: pageNumber,
|
|
18281
18489
|
createURL: props.createURL,
|
|
18282
18490
|
cssClasses: props.cssClasses,
|
|
@@ -18286,7 +18494,8 @@
|
|
|
18286
18494
|
ariaLabel: "Next",
|
|
18287
18495
|
className: props.cssClasses.nextPageItem,
|
|
18288
18496
|
isDisabled: props.isLastPage,
|
|
18289
|
-
|
|
18497
|
+
templates: props.templates,
|
|
18498
|
+
templateKey: "next",
|
|
18290
18499
|
pageNumber: props.currentPage + 1,
|
|
18291
18500
|
createURL: props.createURL,
|
|
18292
18501
|
cssClasses: props.cssClasses,
|
|
@@ -18295,7 +18504,8 @@
|
|
|
18295
18504
|
ariaLabel: "Last",
|
|
18296
18505
|
className: props.cssClasses.lastPageItem,
|
|
18297
18506
|
isDisabled: props.isLastPage,
|
|
18298
|
-
|
|
18507
|
+
templates: props.templates,
|
|
18508
|
+
templateKey: "last",
|
|
18299
18509
|
pageNumber: props.nbPages - 1,
|
|
18300
18510
|
createURL: props.createURL,
|
|
18301
18511
|
cssClasses: props.cssClasses,
|
|
@@ -18303,7 +18513,8 @@
|
|
|
18303
18513
|
})));
|
|
18304
18514
|
}
|
|
18305
18515
|
function PaginationLink(_ref) {
|
|
18306
|
-
var
|
|
18516
|
+
var templates = _ref.templates,
|
|
18517
|
+
templateKey = _ref.templateKey,
|
|
18307
18518
|
ariaLabel = _ref.ariaLabel,
|
|
18308
18519
|
pageNumber = _ref.pageNumber,
|
|
18309
18520
|
className = _ref.className,
|
|
@@ -18316,18 +18527,28 @@
|
|
|
18316
18527
|
createClickHandler = _ref.createClickHandler;
|
|
18317
18528
|
return h("li", {
|
|
18318
18529
|
className: cx(cssClasses.item, className, isDisabled && cssClasses.disabledItem, isSelected && cssClasses.selectedItem)
|
|
18319
|
-
}, isDisabled ? h(
|
|
18320
|
-
|
|
18321
|
-
|
|
18322
|
-
|
|
18530
|
+
}, isDisabled ? h(Template, {
|
|
18531
|
+
rootTagName: "span",
|
|
18532
|
+
rootProps: {
|
|
18533
|
+
className: cssClasses.link
|
|
18534
|
+
},
|
|
18535
|
+
templateKey: templateKey,
|
|
18536
|
+
templates: templates,
|
|
18537
|
+
data: {
|
|
18538
|
+
page: pageNumber + 1
|
|
18323
18539
|
}
|
|
18324
|
-
}) : h(
|
|
18325
|
-
|
|
18326
|
-
|
|
18327
|
-
|
|
18328
|
-
|
|
18329
|
-
|
|
18330
|
-
|
|
18540
|
+
}) : h(Template, {
|
|
18541
|
+
rootTagName: "a",
|
|
18542
|
+
rootProps: {
|
|
18543
|
+
className: cssClasses.link,
|
|
18544
|
+
'aria-label': ariaLabel,
|
|
18545
|
+
href: createURL(pageNumber),
|
|
18546
|
+
onClick: createClickHandler(pageNumber)
|
|
18547
|
+
},
|
|
18548
|
+
templateKey: templateKey,
|
|
18549
|
+
templates: templates,
|
|
18550
|
+
data: {
|
|
18551
|
+
page: pageNumber + 1
|
|
18331
18552
|
}
|
|
18332
18553
|
}));
|
|
18333
18554
|
}
|
|
@@ -18337,28 +18558,40 @@
|
|
|
18337
18558
|
name: 'pagination'
|
|
18338
18559
|
});
|
|
18339
18560
|
var defaultTemplates$a = {
|
|
18340
|
-
previous:
|
|
18341
|
-
|
|
18342
|
-
|
|
18343
|
-
|
|
18561
|
+
previous: function previous() {
|
|
18562
|
+
return '‹';
|
|
18563
|
+
},
|
|
18564
|
+
next: function next() {
|
|
18565
|
+
return '›';
|
|
18566
|
+
},
|
|
18567
|
+
page: function page(_ref) {
|
|
18568
|
+
var _page = _ref.page;
|
|
18569
|
+
return "".concat(_page);
|
|
18570
|
+
},
|
|
18571
|
+
first: function first() {
|
|
18572
|
+
return '«';
|
|
18573
|
+
},
|
|
18574
|
+
last: function last() {
|
|
18575
|
+
return '»';
|
|
18576
|
+
}
|
|
18344
18577
|
};
|
|
18345
|
-
var renderer$c = function renderer(
|
|
18346
|
-
var containerNode =
|
|
18347
|
-
cssClasses =
|
|
18348
|
-
templates =
|
|
18349
|
-
showFirst =
|
|
18350
|
-
showLast =
|
|
18351
|
-
showPrevious =
|
|
18352
|
-
showNext =
|
|
18353
|
-
scrollToNode =
|
|
18354
|
-
return function (
|
|
18355
|
-
var createURL =
|
|
18356
|
-
currentRefinement =
|
|
18357
|
-
nbPages =
|
|
18358
|
-
pages =
|
|
18359
|
-
isFirstPage =
|
|
18360
|
-
isLastPage =
|
|
18361
|
-
refine =
|
|
18578
|
+
var renderer$c = function renderer(_ref2) {
|
|
18579
|
+
var containerNode = _ref2.containerNode,
|
|
18580
|
+
cssClasses = _ref2.cssClasses,
|
|
18581
|
+
templates = _ref2.templates,
|
|
18582
|
+
showFirst = _ref2.showFirst,
|
|
18583
|
+
showLast = _ref2.showLast,
|
|
18584
|
+
showPrevious = _ref2.showPrevious,
|
|
18585
|
+
showNext = _ref2.showNext,
|
|
18586
|
+
scrollToNode = _ref2.scrollToNode;
|
|
18587
|
+
return function (_ref3, isFirstRendering) {
|
|
18588
|
+
var createURL = _ref3.createURL,
|
|
18589
|
+
currentRefinement = _ref3.currentRefinement,
|
|
18590
|
+
nbPages = _ref3.nbPages,
|
|
18591
|
+
pages = _ref3.pages,
|
|
18592
|
+
isFirstPage = _ref3.isFirstPage,
|
|
18593
|
+
isLastPage = _ref3.isLastPage,
|
|
18594
|
+
refine = _ref3.refine;
|
|
18362
18595
|
if (isFirstRendering) return;
|
|
18363
18596
|
var setCurrentPage = function setCurrentPage(pageNumber) {
|
|
18364
18597
|
refine(pageNumber);
|
|
@@ -18384,24 +18617,24 @@
|
|
|
18384
18617
|
};
|
|
18385
18618
|
};
|
|
18386
18619
|
var pagination = function pagination(widgetParams) {
|
|
18387
|
-
var
|
|
18388
|
-
container =
|
|
18389
|
-
|
|
18390
|
-
userTemplates =
|
|
18391
|
-
|
|
18392
|
-
userCssClasses =
|
|
18393
|
-
totalPages =
|
|
18394
|
-
padding =
|
|
18395
|
-
|
|
18396
|
-
showFirst =
|
|
18397
|
-
|
|
18398
|
-
showLast =
|
|
18399
|
-
|
|
18400
|
-
showPrevious =
|
|
18401
|
-
|
|
18402
|
-
showNext =
|
|
18403
|
-
|
|
18404
|
-
userScrollTo =
|
|
18620
|
+
var _ref4 = widgetParams || {},
|
|
18621
|
+
container = _ref4.container,
|
|
18622
|
+
_ref4$templates = _ref4.templates,
|
|
18623
|
+
userTemplates = _ref4$templates === void 0 ? {} : _ref4$templates,
|
|
18624
|
+
_ref4$cssClasses = _ref4.cssClasses,
|
|
18625
|
+
userCssClasses = _ref4$cssClasses === void 0 ? {} : _ref4$cssClasses,
|
|
18626
|
+
totalPages = _ref4.totalPages,
|
|
18627
|
+
padding = _ref4.padding,
|
|
18628
|
+
_ref4$showFirst = _ref4.showFirst,
|
|
18629
|
+
showFirst = _ref4$showFirst === void 0 ? true : _ref4$showFirst,
|
|
18630
|
+
_ref4$showLast = _ref4.showLast,
|
|
18631
|
+
showLast = _ref4$showLast === void 0 ? true : _ref4$showLast,
|
|
18632
|
+
_ref4$showPrevious = _ref4.showPrevious,
|
|
18633
|
+
showPrevious = _ref4$showPrevious === void 0 ? true : _ref4$showPrevious,
|
|
18634
|
+
_ref4$showNext = _ref4.showNext,
|
|
18635
|
+
showNext = _ref4$showNext === void 0 ? true : _ref4$showNext,
|
|
18636
|
+
_ref4$scrollTo = _ref4.scrollTo,
|
|
18637
|
+
userScrollTo = _ref4$scrollTo === void 0 ? 'body' : _ref4$scrollTo;
|
|
18405
18638
|
if (!container) {
|
|
18406
18639
|
throw new Error(withUsage$G('The `container` option is required.'));
|
|
18407
18640
|
}
|
|
@@ -18619,8 +18852,6 @@
|
|
|
18619
18852
|
}
|
|
18620
18853
|
var containerNode = getContainerNode(widgetParams.container);
|
|
18621
18854
|
var defaultTemplates = {
|
|
18622
|
-
header: '',
|
|
18623
|
-
footer: '',
|
|
18624
18855
|
collapseButtonText: function collapseButtonText(_ref4) {
|
|
18625
18856
|
var isCollapsed = _ref4.collapsed;
|
|
18626
18857
|
return "<svg\n class=\"".concat(cssClasses.collapseIcon, "\"\n style=\"width: 1em; height: 1em;\"\n viewBox=\"0 0 500 500\"\n >\n <path d=\"").concat(isCollapsed ? 'M100 250l300-150v300z' : 'M250 400l150-300H100z', "\" fill=\"currentColor\" />\n </svg>");
|
|
@@ -18692,7 +18923,7 @@
|
|
|
18692
18923
|
};
|
|
18693
18924
|
|
|
18694
18925
|
var _excluded$l = ["placesReference", "defaultPosition"],
|
|
18695
|
-
_excluded2$
|
|
18926
|
+
_excluded2$5 = ["places"];
|
|
18696
18927
|
/* Places.js is an optional dependency, no error should be reported if the package is missing */
|
|
18697
18928
|
/** @ts-ignore */
|
|
18698
18929
|
|
|
@@ -18748,7 +18979,7 @@
|
|
|
18748
18979
|
var hasPositionSet = position !== defaultPosition.join(',');
|
|
18749
18980
|
if (!hasPositionSet && !state.query) {
|
|
18750
18981
|
var places = uiState.places,
|
|
18751
|
-
uiStateWithoutPlaces = _objectWithoutProperties(uiState, _excluded2$
|
|
18982
|
+
uiStateWithoutPlaces = _objectWithoutProperties(uiState, _excluded2$5);
|
|
18752
18983
|
return uiStateWithoutPlaces;
|
|
18753
18984
|
}
|
|
18754
18985
|
return _objectSpread2(_objectSpread2({}, uiState), {}, {
|