Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More

@algolia/recommend-react

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@algolia/recommend-react - npm Package Compare versions

Comparing version 1.2.0 to 1.3.0

@@ -1,1 +0,1 @@

export declare const version = "1.2.0";
export declare const version = "1.3.0";

@@ -1,1 +0,1 @@

export var version = '1.2.0';
export var version = '1.3.0';

@@ -1,3 +0,3 @@

/*! @algolia/recommend-react 1.2.0 | MIT License | © Algolia, Inc. and contributors | https://github.com/algolia/recommend */
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["@algolia/recommend-react"]={},e.React)}(this,(function(e,t){"use strict";function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n=r(t);function a(){return(a=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function o(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function c(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return t.filter(Boolean).join(" ")}function i(e){var t=e.createElement;return function(e){return 0===e.recommendations.length&&"idle"===e.status?t(e.Fallback,null):t("section",{className:c("auc-Recommend",e.classNames.root)},t(e.Header,{classNames:e.classNames,recommendations:e.recommendations,translations:e.translations}),t(e.View,null))}}function s(e){var t=e.createElement;return function(e){return e.translations.title?t("h3",{className:c("auc-Recommend-title",e.classNames.title)},e.translations.title):null}}function m(e){var t=e.createElement;return function(e){return t("div",{className:c("auc-Recommend-container",e.classNames.container)},t("ol",{className:c("auc-Recommend-list",e.classNames.list)},e.items.map((function(r){return t("li",{key:r.objectID,className:c("auc-Recommend-item",e.classNames.item)},t(e.itemComponent,{item:r}))}))))}}function u(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function l(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function f(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function d(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function b(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function p(e,t){if(e){if("string"==typeof e)return b(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?b(e,t):void 0}}function y(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,a,o=[],c=!0,i=!1;try{for(r=r.call(e);!(c=(n=r.next()).done)&&(o.push(n.value),!t||o.length!==t);c=!0);}catch(e){i=!0,a=e}finally{try{c||null==r.return||r.return()}finally{if(i)throw a}}return o}}(e,t)||p(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function O(e){return function(e){if(Array.isArray(e))return b(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||p(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function g(e){var t,r,n,a=e.hits,o=e.maxRecommendations;return(t=function(e,t){return(e._score||0)>(t._score||0)?-1:1},r=a,n=O(r),n.sort(t),n).slice(0,o&&o>0?o:void 0)}function h(e,t){return O(new Map(t.map((function(t){return[t[e],t]}))).values())}var j="1.2.0";function v(e){t.useEffect((function(){e.recommendClient.addAlgoliaAgent("recommend-react","1.2.0")}),[e.recommendClient])}var P=Object.prototype.hasOwnProperty;function w(e,t){var r,n;if(e===t)return!0;if(e&&t&&(r=e.constructor)===t.constructor){if(r===Date)return e.getTime()===t.getTime();if(r===RegExp)return e.toString()===t.toString();if(r===Array){if((n=e.length)===t.length)for(;n--&&w(e[n],t[n]););return-1===n}if(!r||"object"==typeof e){for(r in n=0,e){if(P.call(e,r)&&++n&&!P.call(t,r))return!1;if(!(r in t)||!w(e[r],t[r]))return!1}return Object.keys(t).length===n}}return e!=e&&t!=t}function E(e){var r=y(t.useState((function(){return e})),2),n=r[0],a=r[1];return t.useEffect((function(){!1===w(n,e)&&a(e)}),[e]),n}function N(e){var r=t.useRef(void 0),n=y(t.useState(e),2),a=n[0],o=n[1];return t.useEffect((function(){"stalled"!==a&&r.current&&clearTimeout(r.current),"loading"===a&&(r.current=setTimeout((function(){o("stalled")}),300))}),[a]),{status:a,setStatus:o}}function D(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function x(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?D(Object(r),!0).forEach((function(t){o(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):D(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function R(e){var r=e.indexName,n=e.maxRecommendations,a=e.objectIDs,o=e.queryParameters,c=e.recommendClient,i=e.threshold,s=e.transformItems,m=y(t.useState({recommendations:[]}),2),u=m[0],l=m[1],f=N("loading"),d=f.status,b=f.setStatus,p=E(a),O=E(s),P=E(o);return v({recommendClient:c}),t.useEffect((function(){b("loading"),function(e){var t=e.objectIDs,r=e.recommendClient,n=e.transformItems,a=void 0===n?function(e){return e}:n,o=e.indexName,c=e.maxRecommendations,i=e.queryParameters,s=e.threshold,m=t.map((function(e){return{indexName:o,maxRecommendations:c,objectID:e,queryParameters:i,threshold:s}}));return r.addAlgoliaAgent("recommend-core",j),r.getFrequentlyBoughtTogether(m).then((function(e){return g({maxRecommendations:c,hits:h("objectID",e.results.map((function(e){return e.hits})).flat())})})).then((function(e){return{recommendations:a(e)}}))}({indexName:r,maxRecommendations:n,objectIDs:p,queryParameters:P,recommendClient:c,threshold:i,transformItems:O}).then((function(e){l(e),b("idle")}))}),[r,n,p,P,c,b,i,O]),x(x({},u),{},{status:d})}var C,S,I,k=(C={createElement:t.createElement,Fragment:t.Fragment},S=C.createElement,I=C.Fragment,function(e){var t,r,n,c,l,f=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?u(Object(r),!0).forEach((function(t){o(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):u(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}({title:"Frequently bought together",sliderLabel:"Frequently bought together products"},e.translations),d=null!==(t=e.classNames)&&void 0!==t?t:{},b=null!==(r=e.children)&&void 0!==r?r:i({createElement:S,Fragment:I}),p=null!==(n=e.fallbackComponent)&&void 0!==n?n:function(){return null},y=null!==(c=e.headerComponent)&&void 0!==c?c:s({createElement:S,Fragment:I}),O=null!==(l=e.view)&&void 0!==l?l:m({createElement:S,Fragment:I});return b({classNames:d,Fallback:p,Header:y,recommendations:e.items,status:e.status,translations:f,View:function(t){return S(O,a({classNames:d,itemComponent:e.itemComponent,items:e.items,translations:f},t))}})});function F(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function q(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?F(Object(r),!0).forEach((function(t){o(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):F(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function A(e){var r=e.fallbackParameters,n=e.indexName,a=e.maxRecommendations,o=e.objectIDs,c=e.queryParameters,i=e.recommendClient,s=e.threshold,m=e.transformItems,u=y(t.useState({recommendations:[]}),2),l=u[0],f=u[1],d=N("loading"),b=d.status,p=d.setStatus,O=E(o),P=E(m),w=E(c),D=E(r);return v({recommendClient:i}),t.useEffect((function(){p("loading"),function(e){var t=e.objectIDs,r=e.recommendClient,n=e.transformItems,a=void 0===n?function(e){return e}:n,o=e.fallbackParameters,c=e.indexName,i=e.maxRecommendations,s=e.queryParameters,m=e.threshold,u=t.map((function(e){return{fallbackParameters:o,indexName:c,maxRecommendations:i,objectID:e,queryParameters:s,threshold:m}}));return r.addAlgoliaAgent("recommend-core",j),r.getRelatedProducts(u).then((function(e){return g({maxRecommendations:i,hits:h("objectID",e.results.map((function(e){return e.hits})).flat())})})).then((function(e){return{recommendations:a(e)}}))}({fallbackParameters:D,indexName:n,maxRecommendations:a,objectIDs:O,queryParameters:w,recommendClient:i,threshold:s,transformItems:P}).then((function(e){f(e),p("idle")}))}),[D,n,a,O,w,i,p,s,P]),q(q({},l),{},{status:b})}var T=function(e){var t=e.createElement,r=e.Fragment;return function(e){var n,c,u,f,d,b=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?l(Object(r),!0).forEach((function(t){o(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):l(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}({title:"Related products",sliderLabel:"Related products"},e.translations),p=null!==(n=e.classNames)&&void 0!==n?n:{},y=null!==(c=e.children)&&void 0!==c?c:i({createElement:t,Fragment:r}),O=null!==(u=e.fallbackComponent)&&void 0!==u?u:function(){return null},g=null!==(f=e.headerComponent)&&void 0!==f?f:s({createElement:t,Fragment:r}),h=null!==(d=e.view)&&void 0!==d?d:m({createElement:t,Fragment:r});return y({classNames:p,Fallback:O,Header:g,recommendations:e.items,status:e.status,translations:b,View:function(r){return t(h,a({classNames:p,itemComponent:e.itemComponent,items:e.items,translations:b},r))}})}}({createElement:t.createElement,Fragment:t.Fragment});function V(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function H(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?V(Object(r),!0).forEach((function(t){o(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):V(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function B(e){var r=e.fallbackParameters,n=e.indexName,a=e.maxRecommendations,o=e.queryParameters,c=e.recommendClient,i=e.threshold,s=e.transformItems,m=e.facetName,u=y(t.useState({recommendations:[]}),2),l=u[0],f=u[1],d=N("loading"),b=d.status,p=d.setStatus,O=E(s),h=E(o),P=E(r);return v({recommendClient:c}),t.useEffect((function(){p("loading"),function(e){var t=e.recommendClient,r=e.transformItems,n=void 0===r?function(e){return e}:r,a=e.fallbackParameters,o=e.indexName,c=e.maxRecommendations,i=e.queryParameters,s=e.threshold,m=e.facetName,u={fallbackParameters:a,indexName:o,maxRecommendations:c,queryParameters:i,threshold:s,facetName:m};return t.addAlgoliaAgent("recommend-core",j),t.getTrendingFacets([u]).then((function(e){return g({maxRecommendations:c,hits:e.results.map((function(e){return e.hits})).flat()})})).then((function(e){return{recommendations:n(e)}}))}({recommendClient:c,transformItems:O,fallbackParameters:P,indexName:n,maxRecommendations:a,queryParameters:h,threshold:i,facetName:m}).then((function(e){f(e),p("idle")}))}),[P,n,a,h,c,p,i,O,m]),H(H({},l),{},{status:b})}var L=function(e){var t=e.createElement,r=e.Fragment;return function(e){var n,m,u,l,d,b=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?f(Object(r),!0).forEach((function(t){o(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):f(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}({title:"Trending facets",sliderLabel:"Trending facets"},e.translations),p=null!==(n=e.classNames)&&void 0!==n?n:{},y=null!==(m=e.children)&&void 0!==m?m:i({createElement:t,Fragment:r}),O=null!==(u=e.fallbackComponent)&&void 0!==u?u:function(){return null},g=null!==(l=e.headerComponent)&&void 0!==l?l:s({createElement:t,Fragment:r}),h=null!==(d=e.view)&&void 0!==d?d:function(e){var t=e.createElement;return function(e){return t("div",{className:c("auc-Recommend-container",e.classNames.container)},t("ol",{className:c("auc-Recommend-list",e.classNames.list)},e.items.map((function(r){return t("li",{key:r.facetValue,className:c("auc-Recommend-item",e.classNames.item)},t(e.itemComponent,{item:r}))}))))}}({createElement:t,Fragment:r});return y({classNames:p,Fallback:O,Header:g,recommendations:e.items,status:e.status,translations:b,View:function(r){return t(h,a({classNames:p,itemComponent:e.itemComponent,items:e.items,translations:b},r))}})}}({createElement:t.createElement,Fragment:t.Fragment});function _(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function M(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?_(Object(r),!0).forEach((function(t){o(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):_(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function U(e){var r=e.fallbackParameters,n=e.indexName,a=e.maxRecommendations,o=e.queryParameters,c=e.recommendClient,i=e.threshold,s=e.transformItems,m=e.facetName,u=e.facetValue,l=y(t.useState({recommendations:[]}),2),f=l[0],d=l[1],b=N("loading"),p=b.status,O=b.setStatus,P=E(s),w=E(o),D=E(r);return v({recommendClient:c}),t.useEffect((function(){O("loading"),function(e){var t=e.recommendClient,r=e.transformItems,n=void 0===r?function(e){return e}:r,a=e.fallbackParameters,o=e.indexName,c=e.maxRecommendations,i=e.queryParameters,s=e.threshold,m=e.facetName,u=e.facetValue,l={fallbackParameters:a,indexName:o,maxRecommendations:c,queryParameters:i,threshold:s,facetName:m,facetValue:u};return t.addAlgoliaAgent("recommend-core",j),t.getTrendingItems([l]).then((function(e){return g({maxRecommendations:c,hits:h("objectID",e.results.map((function(e){return e.hits})).flat())})})).then((function(e){return{recommendations:n(e)}}))}({recommendClient:c,transformItems:P,fallbackParameters:D,indexName:n,maxRecommendations:a,queryParameters:w,threshold:i,facetName:m,facetValue:u}).then((function(e){d(e),O("idle")}))}),[D,n,a,w,c,O,i,P,m,u]),M(M({},f),{},{status:p})}var $=function(e){var t=e.createElement,r=e.Fragment;return function(e){var n,c,u,l,f,b=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?d(Object(r),!0).forEach((function(t){o(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):d(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}({title:"Trending items",sliderLabel:"Trending items"},e.translations),p=null!==(n=e.classNames)&&void 0!==n?n:{},y=null!==(c=e.children)&&void 0!==c?c:i({createElement:t,Fragment:r}),O=null!==(u=e.fallbackComponent)&&void 0!==u?u:function(){return null},g=null!==(l=e.headerComponent)&&void 0!==l?l:s({createElement:t,Fragment:r}),h=null!==(f=e.view)&&void 0!==f?f:m({createElement:t,Fragment:r});return y({classNames:p,Fallback:O,Header:g,recommendations:e.items,status:e.status,translations:b,View:function(r){return t(h,a({classNames:p,itemComponent:e.itemComponent,items:e.items,translations:b},r))}})}}({createElement:t.createElement,Fragment:t.Fragment});function z(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function G(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?z(Object(r),!0).forEach((function(t){o(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):z(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}e.FrequentlyBoughtTogether=function(e){var t=R(e),r=t.recommendations,o=t.status;return n.default.createElement(k,a({},e,{items:r,status:o}))},e.RelatedProducts=function(e){var t=A(e),r=t.recommendations,o=t.status;return n.default.createElement(T,a({},e,{items:r,status:o}))},e.TrendingFacets=function(e){var t=B(e),r=t.recommendations,o=t.status;return n.default.createElement(L,a({},e,{items:r,status:o}))},e.TrendingItems=function(e){var t=U(e),r=t.recommendations,o=t.status;return n.default.createElement($,a({},e,{items:r,status:o}))},e.useFrequentlyBoughtTogether=R,e.useRecommendations=function(e){var r=e.fallbackParameters,n=e.indexName,a=e.maxRecommendations,o=e.model,c=e.objectIDs,i=e.queryParameters,s=e.recommendClient,m=e.threshold,u=e.transformItems,l=y(t.useState({recommendations:[]}),2),f=l[0],d=l[1],b=N("loading"),p=b.status,O=b.setStatus,P=E(c),w=E(u),D=E(i),x=E(r);return v({recommendClient:s}),t.useEffect((function(){O("loading"),function(e){var t=e.objectIDs,r=e.recommendClient,n=e.transformItems,a=void 0===n?function(e){return e}:n,o=e.fallbackParameters,c=e.indexName,i=e.maxRecommendations,s=e.model,m=e.queryParameters,u=e.threshold,l=t.map((function(e){return{fallbackParameters:o,indexName:c,maxRecommendations:i,model:s,objectID:e,queryParameters:m,threshold:u}}));return r.addAlgoliaAgent("recommend-core",j),r.getRecommendations(l).then((function(e){return g({maxRecommendations:i,hits:h("objectID",e.results.map((function(e){return e.hits})).flat())})})).then((function(e){return{recommendations:a(e)}}))}({fallbackParameters:x,indexName:n,maxRecommendations:a,model:o,objectIDs:P,queryParameters:D,recommendClient:s,threshold:m,transformItems:w}).then((function(e){d(e),O("idle")}))}),[x,n,a,o,P,D,s,O,m,w]),G(G({},f),{},{status:p})},e.useRelatedProducts=A,Object.defineProperty(e,"__esModule",{value:!0})}));
/*! @algolia/recommend-react 1.3.0 | MIT License | © Algolia, Inc. and contributors | https://github.com/algolia/recommend */
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["@algolia/recommend-react"]={},e.React)}(this,(function(e,t){"use strict";function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n=r(t);function a(){return(a=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function o(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function c(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return t.filter(Boolean).join(" ")}function i(e){var t=e.createElement;return function(e){return 0===e.recommendations.length&&"idle"===e.status?t(e.Fallback,null):t("section",{className:c("auc-Recommend",e.classNames.root)},t(e.Header,{classNames:e.classNames,recommendations:e.recommendations,translations:e.translations}),t(e.View,null))}}function s(e){var t=e.createElement;return function(e){return e.translations.title?t("h3",{className:c("auc-Recommend-title",e.classNames.title)},e.translations.title):null}}function m(e){var t=e.createElement;return function(e){return t("div",{className:c("auc-Recommend-container",e.classNames.container)},t("ol",{className:c("auc-Recommend-list",e.classNames.list)},e.items.map((function(r){return t("li",{key:r.objectID,className:c("auc-Recommend-item",e.classNames.item)},t(e.itemComponent,{item:r}))}))))}}function u(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function l(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function f(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function d(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function b(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function p(e,t){if(e){if("string"==typeof e)return b(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?b(e,t):void 0}}function y(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,a,o=[],c=!0,i=!1;try{for(r=r.call(e);!(c=(n=r.next()).done)&&(o.push(n.value),!t||o.length!==t);c=!0);}catch(e){i=!0,a=e}finally{try{c||null==r.return||r.return()}finally{if(i)throw a}}return o}}(e,t)||p(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function O(e){return function(e){if(Array.isArray(e))return b(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||p(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function g(e){var t,r,n,a=e.hits,o=e.maxRecommendations;return(t=function(e,t){return(e._score||0)>(t._score||0)?-1:1},r=a,n=O(r),n.sort(t),n).slice(0,o&&o>0?o:void 0)}function h(e,t){return O(new Map(t.map((function(t){return[t[e],t]}))).values())}var j="1.3.0";function v(e){t.useEffect((function(){e.recommendClient.addAlgoliaAgent("recommend-react","1.3.0")}),[e.recommendClient])}var P=Object.prototype.hasOwnProperty;function w(e,t){var r,n;if(e===t)return!0;if(e&&t&&(r=e.constructor)===t.constructor){if(r===Date)return e.getTime()===t.getTime();if(r===RegExp)return e.toString()===t.toString();if(r===Array){if((n=e.length)===t.length)for(;n--&&w(e[n],t[n]););return-1===n}if(!r||"object"==typeof e){for(r in n=0,e){if(P.call(e,r)&&++n&&!P.call(t,r))return!1;if(!(r in t)||!w(e[r],t[r]))return!1}return Object.keys(t).length===n}}return e!=e&&t!=t}function E(e){var r=y(t.useState((function(){return e})),2),n=r[0],a=r[1];return t.useEffect((function(){!1===w(n,e)&&a(e)}),[e]),n}function N(e){var r=t.useRef(void 0),n=y(t.useState(e),2),a=n[0],o=n[1];return t.useEffect((function(){"stalled"!==a&&r.current&&clearTimeout(r.current),"loading"===a&&(r.current=setTimeout((function(){o("stalled")}),300))}),[a]),{status:a,setStatus:o}}function D(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function x(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?D(Object(r),!0).forEach((function(t){o(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):D(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function R(e){var r=e.indexName,n=e.maxRecommendations,a=e.objectIDs,o=e.queryParameters,c=e.recommendClient,i=e.threshold,s=e.transformItems,m=y(t.useState({recommendations:[]}),2),u=m[0],l=m[1],f=N("loading"),d=f.status,b=f.setStatus,p=E(a),O=E(s),P=E(o);return v({recommendClient:c}),t.useEffect((function(){b("loading"),function(e){var t=e.objectIDs,r=e.recommendClient,n=e.transformItems,a=void 0===n?function(e){return e}:n,o=e.indexName,c=e.maxRecommendations,i=e.queryParameters,s=e.threshold,m=t.map((function(e){return{indexName:o,maxRecommendations:c,objectID:e,queryParameters:i,threshold:s}}));return r.addAlgoliaAgent("recommend-core",j),r.getFrequentlyBoughtTogether(m).then((function(e){return g({maxRecommendations:c,hits:h("objectID",e.results.map((function(e){return e.hits})).flat())})})).then((function(e){return{recommendations:a(e)}}))}({indexName:r,maxRecommendations:n,objectIDs:p,queryParameters:P,recommendClient:c,threshold:i,transformItems:O}).then((function(e){l(e),b("idle")}))}),[r,n,p,P,c,b,i,O]),x(x({},u),{},{status:d})}var C,S,I,k=(C={createElement:t.createElement,Fragment:t.Fragment},S=C.createElement,I=C.Fragment,function(e){var t,r,n,c,l,f=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?u(Object(r),!0).forEach((function(t){o(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):u(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}({title:"Frequently bought together",sliderLabel:"Frequently bought together products"},e.translations),d=null!==(t=e.classNames)&&void 0!==t?t:{},b=null!==(r=e.children)&&void 0!==r?r:i({createElement:S,Fragment:I}),p=null!==(n=e.fallbackComponent)&&void 0!==n?n:function(){return null},y=null!==(c=e.headerComponent)&&void 0!==c?c:s({createElement:S,Fragment:I}),O=null!==(l=e.view)&&void 0!==l?l:m({createElement:S,Fragment:I});return b({classNames:d,Fallback:p,Header:y,recommendations:e.items,status:e.status,translations:f,View:function(t){return S(O,a({classNames:d,itemComponent:e.itemComponent,items:e.items,translations:f},t))}})});function F(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function q(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?F(Object(r),!0).forEach((function(t){o(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):F(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function A(e){var r=e.fallbackParameters,n=e.indexName,a=e.maxRecommendations,o=e.objectIDs,c=e.queryParameters,i=e.recommendClient,s=e.threshold,m=e.transformItems,u=y(t.useState({recommendations:[]}),2),l=u[0],f=u[1],d=N("loading"),b=d.status,p=d.setStatus,O=E(o),P=E(m),w=E(c),D=E(r);return v({recommendClient:i}),t.useEffect((function(){p("loading"),function(e){var t=e.objectIDs,r=e.recommendClient,n=e.transformItems,a=void 0===n?function(e){return e}:n,o=e.fallbackParameters,c=e.indexName,i=e.maxRecommendations,s=e.queryParameters,m=e.threshold,u=t.map((function(e){return{fallbackParameters:o,indexName:c,maxRecommendations:i,objectID:e,queryParameters:s,threshold:m}}));return r.addAlgoliaAgent("recommend-core",j),r.getRelatedProducts(u).then((function(e){return g({maxRecommendations:i,hits:h("objectID",e.results.map((function(e){return e.hits})).flat())})})).then((function(e){return{recommendations:a(e)}}))}({fallbackParameters:D,indexName:n,maxRecommendations:a,objectIDs:O,queryParameters:w,recommendClient:i,threshold:s,transformItems:P}).then((function(e){f(e),p("idle")}))}),[D,n,a,O,w,i,p,s,P]),q(q({},l),{},{status:b})}var T=function(e){var t=e.createElement,r=e.Fragment;return function(e){var n,c,u,f,d,b=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?l(Object(r),!0).forEach((function(t){o(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):l(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}({title:"Related products",sliderLabel:"Related products"},e.translations),p=null!==(n=e.classNames)&&void 0!==n?n:{},y=null!==(c=e.children)&&void 0!==c?c:i({createElement:t,Fragment:r}),O=null!==(u=e.fallbackComponent)&&void 0!==u?u:function(){return null},g=null!==(f=e.headerComponent)&&void 0!==f?f:s({createElement:t,Fragment:r}),h=null!==(d=e.view)&&void 0!==d?d:m({createElement:t,Fragment:r});return y({classNames:p,Fallback:O,Header:g,recommendations:e.items,status:e.status,translations:b,View:function(r){return t(h,a({classNames:p,itemComponent:e.itemComponent,items:e.items,translations:b},r))}})}}({createElement:t.createElement,Fragment:t.Fragment});function V(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function H(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?V(Object(r),!0).forEach((function(t){o(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):V(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function B(e){var r=e.fallbackParameters,n=e.indexName,a=e.maxRecommendations,o=e.queryParameters,c=e.recommendClient,i=e.threshold,s=e.transformItems,m=e.facetName,u=y(t.useState({recommendations:[]}),2),l=u[0],f=u[1],d=N("loading"),b=d.status,p=d.setStatus,O=E(s),h=E(o),P=E(r);return v({recommendClient:c}),t.useEffect((function(){p("loading"),function(e){var t=e.recommendClient,r=e.transformItems,n=void 0===r?function(e){return e}:r,a=e.fallbackParameters,o=e.indexName,c=e.maxRecommendations,i=e.queryParameters,s=e.threshold,m=e.facetName,u={fallbackParameters:a,indexName:o,maxRecommendations:c,queryParameters:i,threshold:s,facetName:m};return t.addAlgoliaAgent("recommend-core",j),t.getTrendingFacets([u]).then((function(e){return g({maxRecommendations:c,hits:e.results.map((function(e){return e.hits})).flat()})})).then((function(e){return{recommendations:n(e)}}))}({recommendClient:c,transformItems:O,fallbackParameters:P,indexName:n,maxRecommendations:a,queryParameters:h,threshold:i,facetName:m}).then((function(e){f(e),p("idle")}))}),[P,n,a,h,c,p,i,O,m]),H(H({},l),{},{status:b})}var L=function(e){var t=e.createElement,r=e.Fragment;return function(e){var n,m,u,l,d,b=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?f(Object(r),!0).forEach((function(t){o(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):f(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}({title:"Trending facets",sliderLabel:"Trending facets"},e.translations),p=null!==(n=e.classNames)&&void 0!==n?n:{},y=null!==(m=e.children)&&void 0!==m?m:i({createElement:t,Fragment:r}),O=null!==(u=e.fallbackComponent)&&void 0!==u?u:function(){return null},g=null!==(l=e.headerComponent)&&void 0!==l?l:s({createElement:t,Fragment:r}),h=null!==(d=e.view)&&void 0!==d?d:function(e){var t=e.createElement;return function(e){return t("div",{className:c("auc-Recommend-container",e.classNames.container)},t("ol",{className:c("auc-Recommend-list",e.classNames.list)},e.items.map((function(r){return t("li",{key:r.facetValue,className:c("auc-Recommend-item",e.classNames.item)},t(e.itemComponent,{item:r}))}))))}}({createElement:t,Fragment:r});return y({classNames:p,Fallback:O,Header:g,recommendations:e.items,status:e.status,translations:b,View:function(r){return t(h,a({classNames:p,itemComponent:e.itemComponent,items:e.items,translations:b},r))}})}}({createElement:t.createElement,Fragment:t.Fragment});function _(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function M(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?_(Object(r),!0).forEach((function(t){o(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):_(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function U(e){var r=e.fallbackParameters,n=e.indexName,a=e.maxRecommendations,o=e.queryParameters,c=e.recommendClient,i=e.threshold,s=e.transformItems,m=e.facetName,u=e.facetValue,l=y(t.useState({recommendations:[]}),2),f=l[0],d=l[1],b=N("loading"),p=b.status,O=b.setStatus,P=E(s),w=E(o),D=E(r);return v({recommendClient:c}),t.useEffect((function(){O("loading"),function(e){var t=e.recommendClient,r=e.transformItems,n=void 0===r?function(e){return e}:r,a=e.fallbackParameters,o=e.indexName,c=e.maxRecommendations,i=e.queryParameters,s=e.threshold,m=e.facetName,u=e.facetValue,l={fallbackParameters:a,indexName:o,maxRecommendations:c,queryParameters:i,threshold:s,facetName:m,facetValue:u};return t.addAlgoliaAgent("recommend-core",j),t.getTrendingItems([l]).then((function(e){return g({maxRecommendations:c,hits:h("objectID",e.results.map((function(e){return e.hits})).flat())})})).then((function(e){return{recommendations:n(e)}}))}({recommendClient:c,transformItems:P,fallbackParameters:D,indexName:n,maxRecommendations:a,queryParameters:w,threshold:i,facetName:m,facetValue:u}).then((function(e){d(e),O("idle")}))}),[D,n,a,w,c,O,i,P,m,u]),M(M({},f),{},{status:p})}var $=function(e){var t=e.createElement,r=e.Fragment;return function(e){var n,c,u,l,f,b=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?d(Object(r),!0).forEach((function(t){o(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):d(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}({title:"Trending items",sliderLabel:"Trending items"},e.translations),p=null!==(n=e.classNames)&&void 0!==n?n:{},y=null!==(c=e.children)&&void 0!==c?c:i({createElement:t,Fragment:r}),O=null!==(u=e.fallbackComponent)&&void 0!==u?u:function(){return null},g=null!==(l=e.headerComponent)&&void 0!==l?l:s({createElement:t,Fragment:r}),h=null!==(f=e.view)&&void 0!==f?f:m({createElement:t,Fragment:r});return y({classNames:p,Fallback:O,Header:g,recommendations:e.items,status:e.status,translations:b,View:function(r){return t(h,a({classNames:p,itemComponent:e.itemComponent,items:e.items,translations:b},r))}})}}({createElement:t.createElement,Fragment:t.Fragment});function z(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function G(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?z(Object(r),!0).forEach((function(t){o(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):z(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}e.FrequentlyBoughtTogether=function(e){var t=R(e),r=t.recommendations,o=t.status;return n.default.createElement(k,a({},e,{items:r,status:o}))},e.RelatedProducts=function(e){var t=A(e),r=t.recommendations,o=t.status;return n.default.createElement(T,a({},e,{items:r,status:o}))},e.TrendingFacets=function(e){var t=B(e),r=t.recommendations,o=t.status;return n.default.createElement(L,a({},e,{items:r,status:o}))},e.TrendingItems=function(e){var t=U(e),r=t.recommendations,o=t.status;return n.default.createElement($,a({},e,{items:r,status:o}))},e.useFrequentlyBoughtTogether=R,e.useRecommendations=function(e){var r=e.fallbackParameters,n=e.indexName,a=e.maxRecommendations,o=e.model,c=e.objectIDs,i=e.queryParameters,s=e.recommendClient,m=e.threshold,u=e.transformItems,l=y(t.useState({recommendations:[]}),2),f=l[0],d=l[1],b=N("loading"),p=b.status,O=b.setStatus,P=E(c),w=E(u),D=E(i),x=E(r);return v({recommendClient:s}),t.useEffect((function(){O("loading"),function(e){var t=e.objectIDs,r=e.recommendClient,n=e.transformItems,a=void 0===n?function(e){return e}:n,o=e.fallbackParameters,c=e.indexName,i=e.maxRecommendations,s=e.model,m=e.queryParameters,u=e.threshold,l=t.map((function(e){return{fallbackParameters:o,indexName:c,maxRecommendations:i,model:s,objectID:e,queryParameters:m,threshold:u}}));return r.addAlgoliaAgent("recommend-core",j),r.getRecommendations(l).then((function(e){return g({maxRecommendations:i,hits:h("objectID",e.results.map((function(e){return e.hits})).flat())})})).then((function(e){return{recommendations:a(e)}}))}({fallbackParameters:x,indexName:n,maxRecommendations:a,model:o,objectIDs:P,queryParameters:D,recommendClient:s,threshold:m,transformItems:w}).then((function(e){d(e),O("idle")}))}),[x,n,a,o,P,D,s,O,m,w]),G(G({},f),{},{status:p})},e.useRelatedProducts=A,Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=index.js.map
{
"name": "@algolia/recommend-react",
"description": "Horizontal slider UI component.",
"version": "1.2.0",
"version": "1.3.0",
"license": "MIT",

@@ -32,4 +32,4 @@ "homepage": "https://github.com/algolia/recommend",

"dependencies": {
"@algolia/recommend-core": "1.2.0",
"@algolia/recommend-vdom": "1.2.0",
"@algolia/recommend-core": "1.3.0",
"@algolia/recommend-vdom": "1.3.0",
"dequal": "^2.0.0"

@@ -36,0 +36,0 @@ },

Sorry, the diff of this file is not supported yet