mealz-components 1.2.4 → 1.2.6
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
.mealz-catalog-favorites .
|
|
1
|
+
.mealz-catalog-favorites .hidden{display:none}.mealz-catalog-favorites .mealz-catalog-toolbar:not(.sticking){flex-direction:row;gap:0px}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as
|
|
1
|
+
import{t as u}from"../../assets/custom-element-BhZVzxrc.js";import"../../assets/lit-element-4gw3YGga.js";import{C as p}from"../catalog-load-more.min.js";import{h as g}from"../../assets/session-handler-BPS5vj92.js";import{o as h,c as m}from"../../assets/OperatorSubscriber-BPZabEAm.js";import"../../assets/no-shadow-element-CaVIVF-o.js";import"../../assets/mapOneOrManyArgs-2FiDGdaS.js";import"../../assets/async-B_IhBgzg.js";function f(e,t){return h(function(i,a){var s=0;i.subscribe(m(a,function(r){return e.call(t,r,s++)&&a.next(r)}))})}function v(e){return f(function(t,i){return e<=i})}var _=Object.defineProperty,b=Object.getOwnPropertyDescriptor,L=(e,t,i,a)=>{for(var s=a>1?void 0:a?b(t,i):t,r=e.length-1,o;r>=0;r--)(o=e[r])&&(s=(a?o(t,i,s):o(s))||s);return a&&s&&_(t,i,s),s};let n=class extends p{constructor(){super(...arguments),this.retryCount=0,this.maxRetries=30}connectedCallback(){super.connectedCallback(),this.subscriptions.push(window.mealzInternal.user.isAuthenticated().pipe(v(1)).subscribe(e=>{this.isLogged=e,this.updateDOM()}),this.handleLikedRecipe())}disconnectedCallback(){super.disconnectedCallback()}render(){var c;const e=(c=this.attributes["starting-data"])==null?void 0:c.value;if(!e||(this.favorites=this.querySelector(".mealz-catalog-favorites__list"),!this.favorites))return;const t=this.querySelector(".mealz-catalog__list");if(!t)return;const{pageSize:i,storeId:a,loadMoreURL:s,displayRecipeVariant:r,search:o,sessionId:l,path:d}=JSON.parse(e);g(l),this.analyticsPath=d,this.sendPageViewEvent(),this.loadMoreRecipesOnScroll({displayRecipeVariant:r,loadMoreURL:s,sessionId:l,pageSize:i,storeId:a,packageId:null,search:o,listHTML:t}),this.removeAttribute("starting-data")}updateDOM(){const e=this.querySelector(".mealz-catalog-favorites__list__not-logged"),t=this.querySelector(".mealz-catalog-favorites__list__logged");!e||!t||(e.classList.toggle("hidden",this.isLogged),t.classList.toggle("hidden",!this.isLogged))}sendPageViewEvent(){window.mealzInternal?(window.mealzInternal.analytics.sendEvent("pageview",this.analyticsPath,{}),this.retryCount=0):this.retryCount<this.maxRetries&&(this.retryCount++,setTimeout(()=>this.sendPageViewEvent(),10))}handleLikedRecipe(){return window.mealzInternal.recipes.recipeLikeUpdated().subscribe(({id:e,isPast:t})=>{const i=document.getElementById("mealz-recipe-card-"+e);i&&i.classList.toggle("hidden",t),this.requestUpdate()})}};n=L([u("mealz-catalog-favorites")],n);customElements.get("mealz-catalog-favorites")||customElements.define("mealz-catalog-favorites",n);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
:root{--m-history-order-width: var(--miam-history-order-width, var(--miam-catalog-card-width, 308px))}mealz-catalog-history .
|
|
1
|
+
:root{--m-history-order-width: var(--miam-history-order-width, var(--miam-catalog-card-width, 308px))}mealz-catalog-history .hidden{display:none}mealz-catalog-history .mealz-catalog__list,mealz-catalog-history .mealz-catalog__content .mealz-catalog__list{grid-template-columns:repeat(auto-fill,var(--m-history-order-width, 308px))}@media (min-width: 375px) and (max-width: 712px){mealz-catalog-history .mealz-catalog__list{grid-template-columns:repeat(auto-fill,var(--m-history-order-width, 308px))}}mealz-catalog-history .mealz-catalog-toolbar:not(.sticking){flex-direction:row;gap:0px}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{N as
|
|
1
|
+
import{N as k}from"../assets/no-shadow-element-CaVIVF-o.js";import{c as E,i as h,o as b,_ as x,O as _}from"../assets/OperatorSubscriber-BPZabEAm.js";import{i as L,m as I,a as T,b as D,c as H}from"../assets/mapOneOrManyArgs-2FiDGdaS.js";import{a as z,b as O}from"../assets/async-B_IhBgzg.js";import"../assets/lit-element-4gw3YGga.js";function A(i){return i instanceof Date&&!isNaN(i)}function S(i,e,t,n,o,l,u,c){var d=[],s=0,a=0,r=!1,f=function(){r&&!d.length&&!s&&e.complete()},w=function(p){return s<n?g(p):d.push(p)},g=function(p){s++;var v=!1;L(t(p,a++)).subscribe(E(e,function(m){e.next(m)},function(){v=!0},void 0,function(){if(v)try{s--;for(var m=function(){var y=d.shift();u||g(y)};d.length&&s<n;)m();f()}catch(y){e.error(y)}}))};return i.subscribe(E(e,w,function(){r=!0,f()})),function(){}}function R(i,e,t){return t===void 0&&(t=1/0),h(e)?R(function(n,o){return I(function(l,u){return e(n,l,o,u)})(L(i(n,o)))},t):(typeof e=="number"&&(t=e),b(function(n,o){return S(n,o,i,t)}))}var N=["addListener","removeListener"],$=["addEventListener","removeEventListener"],q=["on","off"];function M(i,e,t,n){if(h(t)&&(n=t,t=void 0),n)return M(i,e,t).pipe(T(n));var o=x(V(i)?$.map(function(c){return function(d){return i[c](e,d,t)}}):B(i)?N.map(C(i,e)):F(i)?q.map(C(i,e)):[],2),l=o[0],u=o[1];if(!l&&D(i))return R(function(c){return M(c,e,t)})(L(i));if(!l)throw new TypeError("Invalid event target");return new _(function(c){var d=function(){for(var s=[],a=0;a<arguments.length;a++)s[a]=arguments[a];return c.next(1<s.length?s:s[0])};return l(d),function(){return u(d)}})}function C(i,e){return function(t){return function(n){return i[t](e,n)}}}function B(i){return h(i.addListener)&&h(i.removeListener)}function F(i){return h(i.on)&&h(i.off)}function V(i){return h(i.addEventListener)&&h(i.removeEventListener)}function j(i,e,t){t===void 0&&(t=z);var n=-1;return e!=null&&(H(e)?t=e:n=e),new _(function(o){var l=A(i)?+i-t.now():i;l<0&&(l=0);var u=0;return t.schedule(function(){o.closed||(o.next(u++),0<=n?this.schedule(void 0,n):o.complete())},l)})}function G(i,e){return b(function(t,n){var o=e??{},l=o.leading,u=l===void 0?!0:l,c=o.trailing,d=c===void 0?!1:c,s=!1,a=null,r=null,f=!1,w=function(){r==null||r.unsubscribe(),r=null,d&&(v(),f&&n.complete())},g=function(){r=null,f&&n.complete()},p=function(m){return r=L(i(m)).subscribe(E(n,w,g))},v=function(){if(s){s=!1;var m=a;a=null,n.next(m),!f&&p(m)}};t.subscribe(E(n,function(m){s=!0,a=m,!(r&&!r.closed)&&(u?v():p(m))},function(){f=!0,!(d&&s&&r&&!r.closed)&&n.complete()}))})}function J(i,e,t){e===void 0&&(e=O);var n=j(i,e);return G(function(){return n},t)}const P=300;class Z extends k{constructor(){super(...arguments),this.noMoreData=!1,this.isLoading=!1,this.page=2,this.loaderElement=null,this.subscriptions=[]}connectedCallback(){super.connectedCallback(),this.createLoader()}disconnectedCallback(){super.disconnectedCallback(),this.subscriptions.forEach(e=>e.unsubscribe()),this.removeLoader()}loadMoreRecipesOnScroll({displayRecipeVariant:e,loadMoreURL:t,sessionId:n,pageSize:o,storeId:l,packageId:u,search:c,listHTML:d,promotions:s=!1}){const a=M(window,"scroll");this.subscriptions.push(a.pipe(J(100)).subscribe(()=>{const r=this.getBoundingClientRect(),f=r.bottom>0&&r.bottom<=window.innerHeight+P;!this.noMoreData&&!this.isLoading&&f&&this.getMoreRecipes({loadMoreURL:t,sessionId:n,pageSize:o,storeId:l,displayRecipeVariant:e,packageId:u,search:c,promotions:s,listHTML:d})}))}buildHeaders(e){const t={"language-id":window.mealzInternal.user.getLanguage(),"supplier-token":window.mealzInternal.supplier.getToken(),"session-id":e},n=localStorage.getItem("_miam/userId");return n?t.authorization=`user_id ${n}`:t["authless-id"]=localStorage.getItem("_miam/authlessId"),t}async getMoreRecipes({loadMoreURL:e,sessionId:t,pageSize:n,storeId:o,displayRecipeVariant:l,packageId:u,search:c,promotions:d,listHTML:s}){if(this.checkIfMoreRecipes(s.innerHTML,n),this.noMoreData||this.isLoading)return;this.isLoading=!0,this.toggleLoader(!0);const a=new URLSearchParams;a.append("size",n.toString()),a.append("page",this.page.toString()),l&&a.append("display_recipe_variant",l),u&&a.append("category_id",u),o&&a.append("store_id",o),c&&a.append("search",c),d&&a.append("promotions",d);try{const r=await fetch(e+"?"+a,{method:"GET",headers:this.buildHeaders(t)});if(!r.ok)throw new Error(`Load more request failed with status: ${r.status}`);const f=await r.text();this.appendRecipesToList(f,s,n)}catch(r){console.error(r),this.isLoading=!1}}appendRecipesToList(e,t,n){this.checkIfMoreRecipes(e,n),t.insertAdjacentHTML("beforeend",e),this.isLoading=!1,this.toggleLoader(!1),this.page++}checkIfMoreRecipes(e,t){const n=e.match(/<mealz-recipe-card(?=\s|>)/gi)||e.match(/<mealz-history-order(?=\s|>)/gi);(n?n.length:0)<t&&(this.noMoreData=!0)}createLoader(){const e=this.querySelector(".mealz-catalog__content");!this.loaderElement&&e&&(this.loaderElement=document.createElement("div"),this.loaderElement.className="miam-ds-loader",this.loaderElement.style.display="none",e.appendChild(this.loaderElement))}removeLoader(){this.loaderElement&&this.loaderElement.parentElement&&(this.loaderElement.parentElement.removeChild(this.loaderElement),this.loaderElement=null)}toggleLoader(e){this.loaderElement&&(this.loaderElement.style.display=e?"block":"none")}}export{Z as C};
|