mealz-components 2.6.0 → 2.6.2
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/dist/assets/accordion-BGFgJnk1.js +19 -0
- package/dist/assets/product-card-wIoU7Z_5.js +189 -0
- package/dist/assets/promotion-badge-CDaL7Tqv.js +12 -0
- package/dist/basket-transfer-modal/basket-transfer-modal.min.js +5 -5
- package/dist/catalog/basket-preview/basket-preview.min.js +14 -14
- package/dist/catalog/catalog-category/catalog-category.min.js +1 -1
- package/dist/catalog/catalog-favorites/catalog-favorites.min.js +1 -1
- package/dist/catalog/catalog-history/catalog-history.min.js +1 -1
- package/dist/catalog/catalog-home/catalog-home.min.js +1 -1
- package/dist/catalog/catalog-home-header/catalog-home-header.min.js +1 -1
- package/dist/catalog/catalog-list/catalog-list.min.js +1 -1
- package/dist/catalog/catalog-tabs/catalog-tabs.min.js +1 -1
- package/dist/catalog/catalog-toolbar/catalog-toolbar.min.js +1 -1
- package/dist/catalog/my-meals-button/my-meals-button.min.js +1 -1
- package/dist/counter/counter.min.js +2 -2
- package/dist/drawer/drawer.min.js +5 -5
- package/dist/drawer-view-swapper/drawer-view-swapper.min.js +23 -23
- package/dist/history-drawer/history-drawer.min.js +1 -1
- package/dist/history-order/history-order.min.js +1 -1
- package/dist/history-order-expanded/history-order-expanded.min.js +1 -1
- package/dist/last-order-badge/last-order-badge.min.js +2 -2
- package/dist/last-order-modal/last-order-modal.min.js +4 -4
- package/dist/like-button/like-button.min.js +1 -1
- package/dist/modal/modal.min.js +4 -4
- package/dist/no-supplier-add-to-cart-cta/no-supplier-add-to-cart-cta.min.js +2 -2
- package/dist/onboarding/onboarding.min.js +4 -4
- package/dist/order-again/order-again.min.js +2 -2
- package/dist/planner/helpers/get-planner-onboarding-modal-config.min.js +1 -1
- package/dist/planner/helpers/init-planner-onboarding-modal.min.js +1 -1
- package/dist/planner/helpers/open-onboarding-modal.min.js +1 -1
- package/dist/planner/helpers/planner-onboarding-storage.min.js +1 -0
- package/dist/planner/planner-abandon-modal/planner-abandon-modal.min.js +2 -2
- package/dist/planner/planner-budget-edit-modal/planner-budget-edit-modal.min.js +2 -2
- package/dist/planner/planner-budget-gauge/planner-budget-gauge.min.js +1 -1
- package/dist/planner/planner-catalog/planner-catalog.min.js +2 -2
- package/dist/planner/planner-current-menu/planner-current-menu.css +1 -1
- package/dist/planner/planner-current-menu/planner-current-menu.min.js +1 -1
- package/dist/planner/planner-current-menu-modal/planner-current-menu-modal.min.js +2 -2
- package/dist/planner/planner-form/planner-form.min.js +7 -7
- package/dist/planner/planner-menu-option/planner-menu-option.min.js +1 -1
- package/dist/planner/planner-onboarding/planner-onboarding.min.js +1 -1
- package/dist/planner/planner-onboarding-modal/planner-onboarding-modal.min.js +6 -6
- package/dist/planner/planner-open-catalog-modal/planner-open-catalog-modal.min.js +2 -2
- package/dist/planner/planner-quick-menu/planner-quick-menu.min.js +1 -1
- package/dist/planner/planner-recipe-card/planner-recipe-card.min.js +1 -1
- package/dist/planner/planner-recipe-list/planner-recipe-list.min.js +1 -1
- package/dist/planner/planner-recipe-suggestion/planner-recipe-suggestion.min.js +1 -1
- package/dist/planner/planner-welcome-modal/planner-welcome-modal.min.js +3 -3
- package/dist/planner/to-basket-loader/to-basket-loader.min.js +5 -5
- package/dist/planner-entry/planner-entry.min.js +1 -1
- package/dist/preferences/preferences.min.js +4 -4
- package/dist/price/price.min.js +3 -3
- package/dist/products-to-basket-cta/products-to-basket-cta.min.js +1 -1
- package/dist/recipe-card/recipe-card.min.js +1 -1
- package/dist/recipe-card-cta/recipe-card-cta.min.js +1 -1
- package/dist/recipe-details/recipe-details.min.js +111 -111
- package/dist/recipe-pricing/recipe-pricing.min.js +1 -1
- package/dist/recipe-to-basket/recipe-to-basket.min.js +1 -1
- package/dist/replace-item/replace-item-card/replace-item-card.min.js +11 -11
- package/dist/replace-item/replace-item.min.js +13 -13
- package/dist/replace-item-planner/replace-item-card-planner/replace-item-card-planner.min.js +4 -4
- package/dist/replace-item-planner/replace-item-planner.min.js +13 -13
- package/dist/select/select.min.js +6 -6
- package/dist/slider-tabs/slider-tabs.min.js +3 -3
- package/dist/store-indicator/store-indicator.min.js +2 -2
- package/dist/store-locator/store-locator.min.js +2 -2
- package/dist/store-locator-drawer/store-locator-drawer.min.js +2 -2
- package/dist/supplier-selector/supplier-selector.min.js +6 -6
- package/package.json +1 -1
- package/dist/assets/accordion-sjJSL32r.js +0 -19
- package/dist/assets/custom-element-BhZVzxrc.js +0 -5
- package/dist/assets/product-card-TLfT6URx.js +0 -189
- package/dist/assets/promotion-badge-B-er7bV2.js +0 -12
- package/dist/planner/planner-dashboard/planner-dashboard.css +0 -1
- package/dist/planner/planner-dashboard/planner-dashboard.min.js +0 -1
- package/dist/planner-banner/planner-banner.css +0 -1
- package/dist/planner-card-link/planner-card-link.css +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{N as
|
|
1
|
+
import{N as o}from"../../assets/no-shadow-element-D62BBu0I.js";import{b as d}from"../../assets/http-Bepz6wA4.js";import{m as p}from"../../assets/mealz-sdk-E_fNZM-c.js";import{i as h}from"../../assets/responsive-C7Qf71r3.js";import{t as u}from"../../assets/take-CpvJwza7.js";import"../../assets/empty-qrpgDBbc.js";import"../../assets/OperatorSubscriber-DfCnFunn.js";class m extends o{constructor(){super(...arguments),this.menuRecipeCount=0,this.recipeCardURL="",this.storeId="",this.sessionId="",this.recipesIdInBasket=[],this.syncPlaceholdersRafId=null,this.onWindowResize=()=>this.scheduleSyncPlaceholders(),this.defaultMinRows=2}get selectors(){return{addToMenuCard:".mealz-planner-recipe-list__add-to-menu",recipeCardsContainer:".mealz-planner-recipe-list__in-menu",gridContainer:".mealz-planner-recipe-list__grid",headerCount:".mealz-planner-recipe-list__count",headerMealsLabel:".mealz-planner-recipe-list__meals-label",suggestionsButton:".mealz-planner-recipe-list__suggestions-button"}}connectedCallback(){super.connectedCallback(),this.initSelectors(),this.getRecipesInBasket(),this.addEventListeners(),this.setupResponsivePlaceholders(),this.scheduleSyncPlaceholders()}disconnectedCallback(){var e;super.disconnectedCallback(),window.removeEventListener("resize",this.onWindowResize),(e=this.resizeObserver)==null||e.disconnect(),this.resizeObserver=void 0,this.syncPlaceholdersRafId!==null&&(cancelAnimationFrame(this.syncPlaceholdersRafId),this.syncPlaceholdersRafId=null)}render(){const e=this.getAttribute("starting-data");e&&(Object.assign(this,JSON.parse(e)),this.removeAttribute("starting-data"),this.menuRecipeCount=this.querySelectorAll("mealz-planner-recipe-card").length,this.scheduleSyncPlaceholders(),this.syncHeader())}addEventListeners(){this.addClickListener("addToMenuCard",()=>{this.openCatalogDrawer()}),this.addClickListener("suggestionsButton",()=>{const e=document.querySelector("mealz-planner-current-menu");if(typeof(e==null?void 0:e.showSuggestions)=="function"){e.showSuggestions();return}})}openCatalogDrawer(){const e=document.querySelector("mealz-planner-current-menu");e==null||e.openCatalogDrawer()}async addRecipeCardToList(e){var a;const t=new URLSearchParams;t.append("recipe_id",e),t.append("recipe_index",this.menuRecipeCount.toString()),this.storeId&&t.append("store_id",this.storeId);const n=await(await fetch(this.recipeCardURL+"?"+t.toString(),{method:"GET",headers:d(this.sessionId)})).text(),i=(a=this.elements)==null?void 0:a.recipeCardsContainer;if(i){if(i.insertAdjacentHTML("afterbegin",n),this.recipesIdInBasket.includes(e)){const r=i.firstElementChild;r&&this.addInBasketOverlay(r)}if(!h(document)){const r=i.firstElementChild;if(r){const c=r.querySelector(".mealz-planner-recipe-card__picture img");c&&(c.classList.add("mealz-planner-recipe-card__image-animate"),c.addEventListener("animationend",()=>{c.classList.remove("mealz-planner-recipe-card__image-animate")},{once:!0}))}}this.menuRecipeCount++,this.updateRemainingRecipeIndexes(),this.syncPlaceholders(),this.syncHeader()}}removeRecipeCardFromList(e){var i,a;const t=(i=this.elements)==null?void 0:i.recipeCardsContainer,s=(a=t==null?void 0:t.children)==null?void 0:a[e];if(!s)return;s.classList.add("mealz-planner-recipe-card__fadeout");const n=setTimeout(()=>{this.cleanupRecipeCard(s)},200);s.addEventListener("animationend",()=>{clearTimeout(n),this.cleanupRecipeCard(s)},{once:!0})}cleanupRecipeCard(e){e.parentNode&&(e.remove(),this.menuRecipeCount--,this.updateRemainingRecipeIndexes(),this.syncPlaceholders(),this.syncHeader())}updateRemainingRecipeIndexes(){(document.querySelectorAll("mealz-planner-recipe-card")||[]).forEach((t,s)=>{t.updateRecipeIndex(s)})}getRecipesInBasket(){var t;const e=p.basket;(t=e==null?void 0:e.recipePricesInBasket$)==null||t.call(e).pipe(u(1)).subscribe(s=>{this.recipesIdInBasket=s.map(n=>n.id)})}addInBasketOverlay(e){const t=e.querySelector(".mealz-planner-recipe-card__in-basket");t==null||t.classList.remove("hidden")}setupResponsivePlaceholders(){const{gridContainer:e}=this.elements,t=e??this.querySelector(".mealz-planner-recipe-list__grid");t&&(window.addEventListener("resize",this.onWindowResize,{passive:!0}),typeof ResizeObserver<"u"&&(this.resizeObserver=new ResizeObserver(()=>{this.scheduleSyncPlaceholders()}),this.resizeObserver.observe(t)))}scheduleSyncPlaceholders(){this.syncPlaceholdersRafId!==null&&cancelAnimationFrame(this.syncPlaceholdersRafId),this.syncPlaceholdersRafId=requestAnimationFrame(()=>{this.syncPlaceholdersRafId=null,this.syncPlaceholders()})}getMinRows(){const e=this.getAttribute("min-rows"),t=e?Number.parseInt(e,10):NaN,s=Number.isFinite(t)?t:this.defaultMinRows;return Math.max(1,s)}getColumnsCount(e){const t=e.querySelector(".mealz-planner-recipe-list__add-to-menu, mealz-planner-recipe-card, .mealz-planner-recipe-list__placeholder");if(!t)return 1;const s=e.clientWidth,n=t.getBoundingClientRect();if(s<=0||n.width<=0)return 1;const i=getComputedStyle(t),a=Number.parseFloat(i.marginLeft||"0")||0,r=n.width+a;return r<=0?1:Math.max(1,Math.floor((s+a)/r))}syncPlaceholders(){const{gridContainer:e}=this.elements,t=e??this.querySelector(".mealz-planner-recipe-list__grid");if(!t)return;const s=this.getColumnsCount(t),n=this.getMinRows(),i=s*n,a=this.menuRecipeCount??this.querySelectorAll("mealz-planner-recipe-card").length,r=Math.max(0,i-1-a),c=Array.from(t.querySelectorAll(".mealz-planner-recipe-list__placeholder"));for(;c.length>r;){const l=c.pop();l==null||l.remove()}for(;c.length<r;){const l=document.createElement("div");l.className="mealz-planner-recipe-list__placeholder",l.setAttribute("aria-hidden","true"),t.appendChild(l),c.push(l)}}syncHeader(){const{headerCount:e,headerMealsLabel:t}=this.elements;if(e&&(e.textContent=String(this.menuRecipeCount??0)),t){const s=t.getAttribute("data-meal-singular")||"",n=t.getAttribute("data-meal-plural")||"";s&&n&&(t.textContent=this.menuRecipeCount===1?s:n)}}}customElements.get("mealz-planner-recipe-list")||customElements.define("mealz-planner-recipe-list",m);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{N as h,n as m,a as f}from"../../assets/no-shadow-element-D62BBu0I.js";import{t as _}from"../../assets/custom-element-BhZVzxrc.js";import{m as p}from"../../assets/mealz-sdk-E_fNZM-c.js";import{d as S}from"../../assets/debounceTime-Cf_7YmIn.js";import{E as c}from"../../assets/empty-qrpgDBbc.js";import{t as u}from"../../assets/take-CpvJwza7.js";import{t as d}from"../../assets/tap-BN_fPb40.js";import{o as x}from"../../assets/of-DtJFltSl.js";import"../../assets/async-C5Kj_SqM.js";import"../../assets/OperatorSubscriber-DfCnFunn.js";import"../../assets/args-DAL2bHut.js";import"../../assets/isScheduler-CqHuyMwD.js";import"../../assets/from-D8c5akO7.js";import"../../assets/innerFrom-DePszgj9.js";import"../../assets/executeSchedule-CEDvgTzM.js";class R{constructor(){this.attributes={title:"","ext-id":"","ext-link":"",description:"","number-of-guests":"","preparation-time":"","preheating-time":"","cooking-time":"","resting-time":"","media-url":"",source:"","informational-page-html":"","filigrane-logo-url":"","informational-sentence":"","order-history":"",difficulty:1,cost:1,suggested:!1,popularity:0,"video-id":"",promoted:!1,discounted:!1,editable:!1,position:-1},this.ttl=3600,this.finalTimer=this.attributes["preparation-time"]+this.attributes["preheating-time"]+this.attributes["cooking-time"]+this.attributes["resting-time"]}get title(){return this.attributes.title}get promoted(){return this.attributes.promoted}get discounted(){return this.attributes.discounted}get guests(){return this.attributes["number-of-guests"]}set guests(t){this.attributes["number-of-guests"]=t}get filigraneLogoUrl(){return this.attributes["filigrane-logo-url"]?this.attributes["filigrane-logo-url"]:null}get sponsorName(){return this.relationships.sponsors.length>0?this.relationships.sponsors[0].attributes.name:null}get sponsorLogoUrl(){var t,s;return this.relationships.sponsors.data.length>0?(s=(t=this.relationships.sponsors.data[0])==null?void 0:t.attributes)==null?void 0:s["logo-url"]:null}get informationalSentence(){return this.attributes["informational-sentence"]}get costLabel(){switch(this.attributes.cost){case 1:return"faible";case 2:return"moyen";case 3:return"élevé";default:return"moyen"}}get orderHistory(){return this.attributes["order-history"]}get preparationTime(){}get cookingTime(){}get restingTime(){}get difficulty(){return this.attributes.difficulty}set difficulty(t){this.attributes.difficulty=t}set discounted(t){this.attributes.discounted=t}}var b=Object.getOwnPropertyDescriptor,z=(e,t,s,i)=>{for(var a=i>1?void 0:i?b(t,s):t,o=e.length-1,n;o>=0;o--)(n=e[o])&&(a=n(a)||a);return a};let l=class extends h{constructor(){super(...arguments),this.recipeId="",this.guests=0,this.menuRecipes=[],this.suggestedRecipes=[],this.nextSuggestion=null,this.swapRecipeCount=0,this.swapRecipeClick$=new m,this.analyticsPath="/meals-planner/current",this.preferencesSubscription=new f,this.lastShownRecipeId=null,this.isAnimating=!1,this.prefersReducedMotion=!1,this.hasUserInteracted=!1,this.isLoadingNextSuggestion=!1,this.pendingPreferencesRefresh=!1}get selectors(){return{currentCard:".mealz-planner-recipe-suggestion:not(.mealz-planner-recipe-suggestion__next)",title:".mealz-planner-recipe-suggestion:not(.mealz-planner-recipe-suggestion__next) .mealz-planner-current-menu__recipe-title",swapButton:".mealz-planner-recipe-suggestion:not(.mealz-planner-recipe-suggestion__next) .mealz-planner-recipe-suggestion__actions-swap-button",addButton:".mealz-planner-recipe-suggestion:not(.mealz-planner-recipe-suggestion__next) .mealz-planner-recipe-suggestion__actions-add-button",seeRecipe:".mealz-planner-recipe-suggestion:not(.mealz-planner-recipe-suggestion__next) .mealz-planner-recipe-suggestion__see-recipe",addAndSwapButtons:".mealz-planner-recipe-suggestion:not(.mealz-planner-recipe-suggestion__next) .mealz-planner-recipe-suggestion__actions-add-and-swap",pictureContainer:".mealz-planner-recipe-suggestion:not(.mealz-planner-recipe-suggestion__next) .mealz-planner-recipe-suggestion__picture",picture:".mealz-planner-recipe-suggestion:not(.mealz-planner-recipe-suggestion__next) .mealz-planner-recipe-suggestion__picture img",promotion:".mealz-planner-recipe-suggestion:not(.mealz-planner-recipe-suggestion__next) .mealz-planner-recipe-suggestion__recipe-badges-promotion",sponsor:".mealz-planner-recipe-suggestion:not(.mealz-planner-recipe-suggestion__next) .mealz-planner-recipe-suggestion__recipe-sponsor",sponsorImg:".mealz-planner-recipe-suggestion:not(.mealz-planner-recipe-suggestion__next) .mealz-planner-recipe-suggestion__recipe-sponsor img",nextSuggestionCard:".mealz-planner-recipe-suggestion__next",nextSuggestionPicture:".mealz-planner-recipe-suggestion__next .mealz-planner-recipe-suggestion__picture img",nextSuggestionTitle:".mealz-planner-recipe-suggestion__next .mealz-planner-current-menu__recipe-title",nextPromotion:".mealz-planner-recipe-suggestion__next .mealz-planner-recipe-suggestion__recipe-badges-promotion",nextSponsor:".mealz-planner-recipe-suggestion__next .mealz-planner-recipe-suggestion__recipe-sponsor",nextSponsorImg:".mealz-planner-recipe-suggestion__next .mealz-planner-recipe-suggestion__recipe-sponsor img"}}connectedCallback(){super.connectedCallback(),this.initSelectors(),this.addEventListeners(),this.swapRecipeClick$.pipe(S(300)).subscribe(()=>this.swapRecipe()),this.subscribeToPreferencesChanges(),this.prefersReducedMotion=window.matchMedia("(prefers-reduced-motion: reduce)").matches}disconnectedCallback(){super.disconnectedCallback(),this.swapRecipeClick$.complete(),this.preferencesSubscription.unsubscribe()}firstUpdated(){const e=this.getAttribute("starting-data");e&&(Object.assign(this,JSON.parse(e)),this.nextSuggestion=this.suggestedRecipes[1]||null,this.updateDisplayedRecipe(),this.updateNextSuggestionUI(),this.recipeId&&this.suggestionShownEvent(),this.removeAttribute("starting-data"))}addEventListeners(){this.addEventListener("click",e=>{if(this.isAnimating){e.preventDefault(),e.stopPropagation();return}const t=e.target;if(t.closest(".mealz-planner-recipe-suggestion__actions-swap-button")){this.swapRecipeClick$.next();return}const s=t.closest(".mealz-planner-recipe-suggestion__actions-add-button");if(s&&!s.classList.contains("loading")){this.addRecipe();return}if(t.closest(".mealz-planner-current-menu__recipe-title")||t.closest(".mealz-planner-recipe-suggestion__see-recipe")||t.closest(".mealz-planner-recipe-suggestion__picture")){this.openRecipeDetails();return}})}updateDisplayedRecipe(){const{title:e,addAndSwapButtons:t,picture:s,promotion:i,sponsor:a,sponsorImg:o}=this.elements;if(!s||!e||!i||!a||!o||!t)return;const n=this.suggestedRecipes[0];if(!n)return;const r=new R;Object.assign(r,n),this.recipeId=n.id,this.setupImageHandlers(s,r,e,t,i,a,o)}setupImageHandlers(e,t,s,i,a,o,n){let r=null;const g=()=>{r&&(clearTimeout(r),r=null),this.updateRecipeUI(e,s,i,t,a,o,n)};e.classList.add("loading"),e.onload=g,e.onerror=g,t.attributes["media-url"]?(e.src=t.attributes["media-url"],r=window.setTimeout(g,1e3)):g()}updateRecipeUI(e,t,s,i,a,o,n){e.classList.remove("loading"),o.classList.toggle("hidden",!i.sponsorLogoUrl),n&&(n.src=i.sponsorLogoUrl?i.sponsorLogoUrl:""),a.classList.toggle("hidden",!i.discounted),t.textContent=i.attributes.title||"";const r=this.menuRecipes.some(g=>g.id===i.id);s.classList.toggle("hidden",r)}updateNextSuggestionUI(){return new Promise(e=>{const{nextSuggestionCard:t,nextSuggestionPicture:s,nextSuggestionTitle:i,nextPromotion:a,nextSponsor:o,nextSponsorImg:n}=this.elements;if(!this.nextSuggestion){t&&t.classList.add("hidden"),e();return}if(t&&t.classList.remove("hidden"),!s||!i){e();return}const r=s,g=i;if(g.textContent=this.nextSuggestion.attributes.title||"",o.classList.toggle("hidden",!this.nextSuggestion.sponsorLogoUrl),n&&(n.src=this.nextSuggestion.sponsorLogoUrl?this.nextSuggestion.sponsorLogoUrl:""),a.classList.toggle("hidden",!this.nextSuggestion.discounted),this.nextSuggestion.attributes["media-url"]){if(r.classList.add("loading"),r.complete&&r.src===this.nextSuggestion.attributes["media-url"]){r.classList.remove("loading"),e();return}r.onload=()=>{r.classList.remove("loading"),e()},r.onerror=()=>{r.classList.remove("loading"),e()},r.src=this.nextSuggestion.attributes["media-url"]}else e()})}async waitForNextSuggestionReady(){for(;this.isLoadingNextSuggestion;)await new Promise(e=>setTimeout(e,50));this.nextSuggestion&&await this.updateNextSuggestionUI()}runSuggestionTransition(e,t){if(this.isAnimating)return;const s=this.querySelector(".mealz-planner-recipe-suggestion:not(.mealz-planner-recipe-suggestion__next)"),i=this.querySelector(".mealz-planner-recipe-suggestion__next");if(!s||!i){t();return}if(this.prefersReducedMotion){t(),this.initSelectors();return}this.isAnimating=!0;const a=e==="add"?"mealz-planner-recipe-suggestion__exit-add":"mealz-planner-recipe-suggestion__exit-pass";s.classList.add(a),i.classList.add("mealz-planner-recipe-suggestion__promote"),setTimeout(()=>{(async()=>{s.style.display="none",s.classList.remove(a),s.classList.add("mealz-planner-recipe-suggestion__next"),i.classList.remove("mealz-planner-recipe-suggestion__promote","mealz-planner-recipe-suggestion__next"),this.initSelectors(),t(),await this.waitForNextSuggestionReady();const n=this.querySelector(".mealz-planner-recipe-suggestion__next");n?(n.classList.add("mealz-planner-recipe-suggestion__reveal"),n.style.display="flex",setTimeout(()=>{n.classList.remove("mealz-planner-recipe-suggestion__reveal"),this.isAnimating=!1,this.pendingPreferencesRefresh&&!this.isLoadingNextSuggestion&&(this.pendingPreferencesRefresh=!1,this.getNewSuggestedRecipes({replace:!0}))},200)):(this.isAnimating=!1,this.pendingPreferencesRefresh&&!this.isLoadingNextSuggestion&&(this.pendingPreferencesRefresh=!1,this.getNewSuggestedRecipes({replace:!0})))})()},300)}addRecipe(){this.addRecipeUsingSuggestionFlow$().subscribe()}addRecipeFromDetails$(e){return typeof e=="number"&&(this.guests=e),this.addRecipeUsingSuggestionFlow$()}addRecipeUsingSuggestionFlow$(){if(this.isAnimating)return c;this.toggleLoadingButton(!0);const e=document.querySelector("mealz-planner-current-menu");return e?(this.rejectCurrentRecipeIfNeeded(),e.addRecipe(this.recipeId,this.guests,"ai_suggestion","meals-planner-dashboard").pipe(u(1),d({next:()=>{this.runSuggestionTransition("add",()=>{this.addAndSelectNewSuggestion(),this.toggleLoadingButton(!1)})},error:()=>{this.toggleLoadingButton(!1)}}))):(this.toggleLoadingButton(!1),c)}toggleLoadingButton(e){this.querySelectorAll(".mealz-planner-recipe-suggestion .mealz-planner-recipe-suggestion__actions-add-button").forEach(s=>{s.classList.toggle("loading",e)})}addAndSelectNewSuggestion(e){if(e){this.menuRecipes.push(e),this.updateNextSuggestion(!0),this.updateDisplayedRecipe(),this.updateNextSuggestionUI(),this.requestUpdate();return}this.suggestedRecipes.length===0||!this.suggestedRecipes[0]||(this.menuRecipes.push(this.suggestedRecipes[0]),this.suggestedRecipes.shift(),this.updateNextSuggestion(!0),this.updateDisplayedRecipe(),this.updateNextSuggestionUI(),this.suggestionShownEvent(),this.requestUpdate())}removeRecipe(e){const t=e||this.recipeId,s=document.querySelector("mealz-planner-current-menu");return!s||!t?x():s.removeRecipe(t).pipe(u(1),d(()=>{const i=this.menuRecipes.findIndex(a=>a.id===t);i!==-1&&(this.menuRecipes.splice(i,1),this.recipeId===t&&(this.updateDisplayedRecipe(),this.requestUpdate()))}))}swapRecipe(){this.isAnimating||(this.rejectCurrentRecipeIfNeeded(),this.recipeSwappedEvent(),this.swapRecipeCount++,!sessionStorage.getItem("_miam/selectFromCatalogSuggestion")&&this.swapRecipeCount>3&&(sessionStorage.setItem("_miam/selectFromCatalogSuggestion","true"),this.openCatalogModal()),this.runSuggestionTransition("pass",()=>{this.suggestedRecipes.shift(),this.updateNextSuggestion(!0),this.updateDisplayedRecipe(),this.updateNextSuggestionUI(),this.suggestionShownEvent()}))}rejectCurrentRecipeIfNeeded(){const e=this.suggestedRecipes[0];(!this.hasUserInteracted||this.suggestedRecipes.length===1)&&(e!=null&&e.id)&&p.planner.rejectRecipe(e.id).pipe(u(1)).subscribe(),this.hasUserInteracted||(this.hasUserInteracted=!0)}updateNextSuggestion(e=!1){var t;this.suggestedRecipes.length>1?(this.nextSuggestion=this.suggestedRecipes[1],e&&((t=this.nextSuggestion)!=null&&t.id)&&p.planner.rejectRecipe(this.nextSuggestion.id).pipe(u(1)).subscribe()):(this.nextSuggestion=null,this.getNewSuggestedRecipes())}getNewSuggestedRecipes(e){const t=(e==null?void 0:e.replace)===!0;this.isLoadingNextSuggestion=!0,p.planner.getSuggestedRecipes().pipe(u(1)).subscribe(s=>{t?(this.suggestedRecipes=[...s],this.hasUserInteracted=!1,this.nextSuggestion=this.suggestedRecipes[1]||null):(this.suggestedRecipes=[...this.suggestedRecipes,...s],this.hasUserInteracted=!1,this.updateNextSuggestion()),this.updateDisplayedRecipe(),this.updateNextSuggestionUI().then(()=>{this.isLoadingNextSuggestion=!1,this.pendingPreferencesRefresh&&!this.isAnimating&&(this.pendingPreferencesRefresh=!1,this.getNewSuggestedRecipes({replace:!0}))}).catch(()=>{this.isLoadingNextSuggestion=!1,this.pendingPreferencesRefresh&&!this.isAnimating&&(this.pendingPreferencesRefresh=!1,this.getNewSuggestedRecipes({replace:!0}))}),this.suggestionShownEvent()})}openCatalogModal(){const e=document.querySelector("mealz-planner-current-menu");this.promptCatalogEvent(),e==null||e.openCatalogModal()}openRecipeDetails(){p.recipes.openDetails(this.recipeId,this.guests,0,"",!0)}subscribeToPreferencesChanges(){this.preferencesSubscription.add(p.preferences.preferencesChanged$().subscribe(()=>{if(this.isAnimating||this.isLoadingNextSuggestion){this.pendingPreferencesRefresh=!0;return}this.getNewSuggestedRecipes({replace:!0})}))}recipeSwappedEvent(){p.analytics.sendEvent("planner.recipe.swap",this.analyticsPath,{recipe_id:this.recipeId})}promptCatalogEvent(){p.analytics.sendEvent("planner.recipe.catalog-prompt",this.analyticsPath,{})}suggestionShownEvent(){this.recipeId&&this.recipeId!==this.lastShownRecipeId&&(p.analytics.sendEvent("planner.suggestion.show",this.analyticsPath,{recipe_id:this.recipeId}),this.lastShownRecipeId=this.recipeId)}};l=z([_("mealz-planner-recipe-suggestion")],l);customElements.get("mealz-planner-recipe-suggestion")||customElements.define("mealz-planner-recipe-suggestion",l);
|
|
1
|
+
import{N as h,n as m,a as f}from"../../assets/no-shadow-element-D62BBu0I.js";import{m as p}from"../../assets/mealz-sdk-E_fNZM-c.js";import{d as _}from"../../assets/debounceTime-Cf_7YmIn.js";import{E as l}from"../../assets/empty-qrpgDBbc.js";import{t as u}from"../../assets/take-CpvJwza7.js";import{t as c}from"../../assets/tap-BN_fPb40.js";import{o as S}from"../../assets/of-DtJFltSl.js";import"../../assets/async-C5Kj_SqM.js";import"../../assets/OperatorSubscriber-DfCnFunn.js";import"../../assets/args-DAL2bHut.js";import"../../assets/isScheduler-CqHuyMwD.js";import"../../assets/from-D8c5akO7.js";import"../../assets/innerFrom-DePszgj9.js";import"../../assets/executeSchedule-CEDvgTzM.js";class x{constructor(){this.attributes={title:"","ext-id":"","ext-link":"",description:"","number-of-guests":"","preparation-time":"","preheating-time":"","cooking-time":"","resting-time":"","media-url":"",source:"","informational-page-html":"","filigrane-logo-url":"","informational-sentence":"","order-history":"",difficulty:1,cost:1,suggested:!1,popularity:0,"video-id":"",promoted:!1,discounted:!1,editable:!1,position:-1},this.ttl=3600,this.finalTimer=this.attributes["preparation-time"]+this.attributes["preheating-time"]+this.attributes["cooking-time"]+this.attributes["resting-time"]}get title(){return this.attributes.title}get promoted(){return this.attributes.promoted}get discounted(){return this.attributes.discounted}get guests(){return this.attributes["number-of-guests"]}set guests(e){this.attributes["number-of-guests"]=e}get filigraneLogoUrl(){return this.attributes["filigrane-logo-url"]?this.attributes["filigrane-logo-url"]:null}get sponsorName(){return this.relationships.sponsors.length>0?this.relationships.sponsors[0].attributes.name:null}get sponsorLogoUrl(){var e,t;return this.relationships.sponsors.data.length>0?(t=(e=this.relationships.sponsors.data[0])==null?void 0:e.attributes)==null?void 0:t["logo-url"]:null}get informationalSentence(){return this.attributes["informational-sentence"]}get costLabel(){switch(this.attributes.cost){case 1:return"faible";case 2:return"moyen";case 3:return"élevé";default:return"moyen"}}get orderHistory(){return this.attributes["order-history"]}get preparationTime(){}get cookingTime(){}get restingTime(){}get difficulty(){return this.attributes.difficulty}set difficulty(e){this.attributes.difficulty=e}set discounted(e){this.attributes.discounted=e}}class R extends h{constructor(){super(...arguments),this.recipeId="",this.guests=0,this.menuRecipes=[],this.suggestedRecipes=[],this.nextSuggestion=null,this.swapRecipeCount=0,this.swapRecipeClick$=new m,this.analyticsPath="/meals-planner/current",this.preferencesSubscription=new f,this.lastShownRecipeId=null,this.isAnimating=!1,this.prefersReducedMotion=!1,this.hasUserInteracted=!1,this.isLoadingNextSuggestion=!1,this.pendingPreferencesRefresh=!1}get selectors(){return{currentCard:".mealz-planner-recipe-suggestion:not(.mealz-planner-recipe-suggestion__next)",title:".mealz-planner-recipe-suggestion:not(.mealz-planner-recipe-suggestion__next) .mealz-planner-current-menu__recipe-title",swapButton:".mealz-planner-recipe-suggestion:not(.mealz-planner-recipe-suggestion__next) .mealz-planner-recipe-suggestion__actions-swap-button",addButton:".mealz-planner-recipe-suggestion:not(.mealz-planner-recipe-suggestion__next) .mealz-planner-recipe-suggestion__actions-add-button",seeRecipe:".mealz-planner-recipe-suggestion:not(.mealz-planner-recipe-suggestion__next) .mealz-planner-recipe-suggestion__see-recipe",addAndSwapButtons:".mealz-planner-recipe-suggestion:not(.mealz-planner-recipe-suggestion__next) .mealz-planner-recipe-suggestion__actions-add-and-swap",pictureContainer:".mealz-planner-recipe-suggestion:not(.mealz-planner-recipe-suggestion__next) .mealz-planner-recipe-suggestion__picture",picture:".mealz-planner-recipe-suggestion:not(.mealz-planner-recipe-suggestion__next) .mealz-planner-recipe-suggestion__picture img",promotion:".mealz-planner-recipe-suggestion:not(.mealz-planner-recipe-suggestion__next) .mealz-planner-recipe-suggestion__recipe-badges-promotion",sponsor:".mealz-planner-recipe-suggestion:not(.mealz-planner-recipe-suggestion__next) .mealz-planner-recipe-suggestion__recipe-sponsor",sponsorImg:".mealz-planner-recipe-suggestion:not(.mealz-planner-recipe-suggestion__next) .mealz-planner-recipe-suggestion__recipe-sponsor img",nextSuggestionCard:".mealz-planner-recipe-suggestion__next",nextSuggestionPicture:".mealz-planner-recipe-suggestion__next .mealz-planner-recipe-suggestion__picture img",nextSuggestionTitle:".mealz-planner-recipe-suggestion__next .mealz-planner-current-menu__recipe-title",nextPromotion:".mealz-planner-recipe-suggestion__next .mealz-planner-recipe-suggestion__recipe-badges-promotion",nextSponsor:".mealz-planner-recipe-suggestion__next .mealz-planner-recipe-suggestion__recipe-sponsor",nextSponsorImg:".mealz-planner-recipe-suggestion__next .mealz-planner-recipe-suggestion__recipe-sponsor img"}}connectedCallback(){super.connectedCallback(),this.initSelectors(),this.addEventListeners(),this.swapRecipeClick$.pipe(_(300)).subscribe(()=>this.swapRecipe()),this.subscribeToPreferencesChanges(),this.prefersReducedMotion=window.matchMedia("(prefers-reduced-motion: reduce)").matches}disconnectedCallback(){super.disconnectedCallback(),this.swapRecipeClick$.complete(),this.preferencesSubscription.unsubscribe()}firstUpdated(){const e=this.getAttribute("starting-data");e&&(Object.assign(this,JSON.parse(e)),this.nextSuggestion=this.suggestedRecipes[1]||null,this.updateDisplayedRecipe(),this.updateNextSuggestionUI(),this.recipeId&&this.suggestionShownEvent(),this.removeAttribute("starting-data"))}addEventListeners(){this.addEventListener("click",e=>{if(this.isAnimating){e.preventDefault(),e.stopPropagation();return}const t=e.target;if(t.closest(".mealz-planner-recipe-suggestion__actions-swap-button")){this.swapRecipeClick$.next();return}const s=t.closest(".mealz-planner-recipe-suggestion__actions-add-button");if(s&&!s.classList.contains("loading")){this.addRecipe();return}if(t.closest(".mealz-planner-current-menu__recipe-title")||t.closest(".mealz-planner-recipe-suggestion__see-recipe")||t.closest(".mealz-planner-recipe-suggestion__picture")){this.openRecipeDetails();return}})}updateDisplayedRecipe(){const{title:e,addAndSwapButtons:t,picture:s,promotion:i,sponsor:a,sponsorImg:o}=this.elements;if(!s||!e||!i||!a||!o||!t)return;const r=this.suggestedRecipes[0];if(!r)return;const n=new x;Object.assign(n,r),this.recipeId=r.id,this.setupImageHandlers(s,n,e,t,i,a,o)}setupImageHandlers(e,t,s,i,a,o,r){let n=null;const g=()=>{n&&(clearTimeout(n),n=null),this.updateRecipeUI(e,s,i,t,a,o,r)};e.classList.add("loading"),e.onload=g,e.onerror=g,t.attributes["media-url"]?(e.src=t.attributes["media-url"],n=window.setTimeout(g,1e3)):g()}updateRecipeUI(e,t,s,i,a,o,r){e.classList.remove("loading"),o.classList.toggle("hidden",!i.sponsorLogoUrl),r&&(r.src=i.sponsorLogoUrl?i.sponsorLogoUrl:""),a.classList.toggle("hidden",!i.discounted),t.textContent=i.attributes.title||"";const n=this.menuRecipes.some(g=>g.id===i.id);s.classList.toggle("hidden",n)}updateNextSuggestionUI(){return new Promise(e=>{const{nextSuggestionCard:t,nextSuggestionPicture:s,nextSuggestionTitle:i,nextPromotion:a,nextSponsor:o,nextSponsorImg:r}=this.elements;if(!this.nextSuggestion){t&&t.classList.add("hidden"),e();return}if(t&&t.classList.remove("hidden"),!s||!i){e();return}const n=s,g=i;if(g.textContent=this.nextSuggestion.attributes.title||"",o.classList.toggle("hidden",!this.nextSuggestion.sponsorLogoUrl),r&&(r.src=this.nextSuggestion.sponsorLogoUrl?this.nextSuggestion.sponsorLogoUrl:""),a.classList.toggle("hidden",!this.nextSuggestion.discounted),this.nextSuggestion.attributes["media-url"]){if(n.classList.add("loading"),n.complete&&n.src===this.nextSuggestion.attributes["media-url"]){n.classList.remove("loading"),e();return}n.onload=()=>{n.classList.remove("loading"),e()},n.onerror=()=>{n.classList.remove("loading"),e()},n.src=this.nextSuggestion.attributes["media-url"]}else e()})}async waitForNextSuggestionReady(){for(;this.isLoadingNextSuggestion;)await new Promise(e=>setTimeout(e,50));this.nextSuggestion&&await this.updateNextSuggestionUI()}runSuggestionTransition(e,t){if(this.isAnimating)return;const s=this.querySelector(".mealz-planner-recipe-suggestion:not(.mealz-planner-recipe-suggestion__next)"),i=this.querySelector(".mealz-planner-recipe-suggestion__next");if(!s||!i){t();return}if(this.prefersReducedMotion){t(),this.initSelectors();return}this.isAnimating=!0;const a=e==="add"?"mealz-planner-recipe-suggestion__exit-add":"mealz-planner-recipe-suggestion__exit-pass";s.classList.add(a),i.classList.add("mealz-planner-recipe-suggestion__promote"),setTimeout(()=>{(async()=>{s.style.display="none",s.classList.remove(a),s.classList.add("mealz-planner-recipe-suggestion__next"),i.classList.remove("mealz-planner-recipe-suggestion__promote","mealz-planner-recipe-suggestion__next"),this.initSelectors(),t(),await this.waitForNextSuggestionReady();const r=this.querySelector(".mealz-planner-recipe-suggestion__next");r?(r.classList.add("mealz-planner-recipe-suggestion__reveal"),r.style.display="flex",setTimeout(()=>{r.classList.remove("mealz-planner-recipe-suggestion__reveal"),this.isAnimating=!1,this.pendingPreferencesRefresh&&!this.isLoadingNextSuggestion&&(this.pendingPreferencesRefresh=!1,this.getNewSuggestedRecipes({replace:!0}))},200)):(this.isAnimating=!1,this.pendingPreferencesRefresh&&!this.isLoadingNextSuggestion&&(this.pendingPreferencesRefresh=!1,this.getNewSuggestedRecipes({replace:!0})))})()},300)}addRecipe(){this.addRecipeUsingSuggestionFlow$().subscribe()}addRecipeFromDetails$(e){return typeof e=="number"&&(this.guests=e),this.addRecipeUsingSuggestionFlow$()}addRecipeUsingSuggestionFlow$(){if(this.isAnimating)return l;this.toggleLoadingButton(!0);const e=document.querySelector("mealz-planner-current-menu");return e?(this.rejectCurrentRecipeIfNeeded(),e.addRecipe(this.recipeId,this.guests,"ai_suggestion","meals-planner-dashboard").pipe(u(1),c({next:()=>{this.runSuggestionTransition("add",()=>{this.addAndSelectNewSuggestion(),this.toggleLoadingButton(!1)})},error:()=>{this.toggleLoadingButton(!1)}}))):(this.toggleLoadingButton(!1),l)}toggleLoadingButton(e){this.querySelectorAll(".mealz-planner-recipe-suggestion .mealz-planner-recipe-suggestion__actions-add-button").forEach(s=>{s.classList.toggle("loading",e)})}addAndSelectNewSuggestion(e){if(e){this.menuRecipes.push(e),this.updateNextSuggestion(!0),this.updateDisplayedRecipe(),this.updateNextSuggestionUI(),this.requestUpdate();return}this.suggestedRecipes.length===0||!this.suggestedRecipes[0]||(this.menuRecipes.push(this.suggestedRecipes[0]),this.suggestedRecipes.shift(),this.updateNextSuggestion(!0),this.updateDisplayedRecipe(),this.updateNextSuggestionUI(),this.suggestionShownEvent(),this.requestUpdate())}removeRecipe(e){const t=e||this.recipeId,s=document.querySelector("mealz-planner-current-menu");return!s||!t?S():s.removeRecipe(t).pipe(u(1),c(()=>{const i=this.menuRecipes.findIndex(a=>a.id===t);i!==-1&&(this.menuRecipes.splice(i,1),this.recipeId===t&&(this.updateDisplayedRecipe(),this.requestUpdate()))}))}swapRecipe(){this.isAnimating||(this.rejectCurrentRecipeIfNeeded(),this.recipeSwappedEvent(),this.swapRecipeCount++,!sessionStorage.getItem("_miam/selectFromCatalogSuggestion")&&this.swapRecipeCount>3&&(sessionStorage.setItem("_miam/selectFromCatalogSuggestion","true"),this.openCatalogModal()),this.runSuggestionTransition("pass",()=>{this.suggestedRecipes.shift(),this.updateNextSuggestion(!0),this.updateDisplayedRecipe(),this.updateNextSuggestionUI(),this.suggestionShownEvent()}))}rejectCurrentRecipeIfNeeded(){const e=this.suggestedRecipes[0];(!this.hasUserInteracted||this.suggestedRecipes.length===1)&&(e!=null&&e.id)&&p.planner.rejectRecipe(e.id).pipe(u(1)).subscribe(),this.hasUserInteracted||(this.hasUserInteracted=!0)}updateNextSuggestion(e=!1){var t;this.suggestedRecipes.length>1?(this.nextSuggestion=this.suggestedRecipes[1],e&&((t=this.nextSuggestion)!=null&&t.id)&&p.planner.rejectRecipe(this.nextSuggestion.id).pipe(u(1)).subscribe()):(this.nextSuggestion=null,this.getNewSuggestedRecipes())}getNewSuggestedRecipes(e){const t=(e==null?void 0:e.replace)===!0;this.isLoadingNextSuggestion=!0,p.planner.getSuggestedRecipes().pipe(u(1)).subscribe(s=>{t?(this.suggestedRecipes=[...s],this.hasUserInteracted=!1,this.nextSuggestion=this.suggestedRecipes[1]||null):(this.suggestedRecipes=[...this.suggestedRecipes,...s],this.hasUserInteracted=!1,this.updateNextSuggestion()),this.updateDisplayedRecipe(),this.updateNextSuggestionUI().then(()=>{this.isLoadingNextSuggestion=!1,this.pendingPreferencesRefresh&&!this.isAnimating&&(this.pendingPreferencesRefresh=!1,this.getNewSuggestedRecipes({replace:!0}))}).catch(()=>{this.isLoadingNextSuggestion=!1,this.pendingPreferencesRefresh&&!this.isAnimating&&(this.pendingPreferencesRefresh=!1,this.getNewSuggestedRecipes({replace:!0}))}),this.suggestionShownEvent()})}openCatalogModal(){const e=document.querySelector("mealz-planner-current-menu");this.promptCatalogEvent(),e==null||e.openCatalogModal()}openRecipeDetails(){p.recipes.openDetails(this.recipeId,this.guests,0,"",!0)}subscribeToPreferencesChanges(){this.preferencesSubscription.add(p.preferences.preferencesChanged$().subscribe(()=>{if(this.isAnimating||this.isLoadingNextSuggestion){this.pendingPreferencesRefresh=!0;return}this.getNewSuggestedRecipes({replace:!0})}))}recipeSwappedEvent(){p.analytics.sendEvent("planner.recipe.swap",this.analyticsPath,{recipe_id:this.recipeId})}promptCatalogEvent(){p.analytics.sendEvent("planner.recipe.catalog-prompt",this.analyticsPath,{})}suggestionShownEvent(){this.recipeId&&this.recipeId!==this.lastShownRecipeId&&(p.analytics.sendEvent("planner.suggestion.show",this.analyticsPath,{recipe_id:this.recipeId}),this.lastShownRecipeId=this.recipeId)}}customElements.get("mealz-planner-recipe-suggestion")||customElements.define("mealz-planner-recipe-suggestion",R);
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import{N as
|
|
1
|
+
import{N as m,k as i}from"../../assets/no-shadow-element-D62BBu0I.js";import{M as d}from"../../modal/modal.min.js";import{n as p}from"../../assets/property-CoRN-Ln2.js";import{M as u}from"../../onboarding/events.min.js";import{b as c,j as h,k as v}from"../../onboarding/analytics/onboarding-analytics.min.js";import{a as r,d as b,m as g}from"../helpers/planner-onboarding-storage.min.js";import"../../assets/mealz-sdk-E_fNZM-c.js";import"../../assets/unsafe-html-DWUMaK1p.js";var M=Object.defineProperty,f=(t,e,n,z)=>{for(var s=void 0,o=t.length-1,a;o>=0;o--)(a=t[o])&&(s=a(e,n,s)||s);return s&&M(e,n,s),s};class l extends m{constructor(){super(),this.isCustomMenu=!1,this.analyticsPath="/meals-planner/onboarding",this.styleURL=new URL("./planner/planner-welcome-modal/planner-welcome-modal.css",this.getBaseURL())}displayPlannerWelcomeModal(){if(r())return;const e=new d;document.body.appendChild(this);const n=this.isCustomMenu?"Bienvenue dans votre premier menu personnalisé":"Bienvenue dans votre première sélection du moment";e.disableMobileBottomSheet=!0,e.titleSlot=i`<span>${n}</span>`,e.contentSlot=this.renderModal(),this.appendChild(e),c(this.isCustomMenu?"personal":"suggestion","welcome"),e.addEventListener(u,()=>{this.skipOnboarding(!1)})}skipOnboarding(e=!1){h(this.isCustomMenu?"personal":"suggestion"),e&&(b(),g());const n=new CustomEvent("onboarding-skipped");this.dispatchEvent(n),this.remove()}startOnboardingTour(){if(r()){this.remove();return}v(this.isCustomMenu?"personal":"suggestion");const e=new CustomEvent("openOnboarding",{detail:{isCustomMenu:this.isCustomMenu}});this.dispatchEvent(e),this.remove()}renderModal(){const e=this.isCustomMenu?"Découvrez comment composer facilement votre menu selon vos envies.":"Découvrez le menu de la semaine que nous avons composé pour vous.";return i`
|
|
2
2
|
<div class="mealz-planner-welcome-modal__content">
|
|
3
3
|
<div class="mealz-planner-welcome-modal__description mealz-ds-text size-m">
|
|
4
4
|
<span>${e}</span>
|
|
5
5
|
</div>
|
|
6
6
|
<div class="mealz-planner-welcome-modal__button-container">
|
|
7
|
-
<button @click=${()=>this.
|
|
7
|
+
<button @click=${()=>this.skipOnboarding(!0)}
|
|
8
8
|
class="mealz-ds-button ghost mealz-planner-welcome-modal__refuse-button">
|
|
9
9
|
<span class="mealz-ds-text size-s weight-xl">Passer le guide</span>
|
|
10
10
|
</button>
|
|
@@ -14,4 +14,4 @@ import{N as d,k as r}from"../../assets/no-shadow-element-D62BBu0I.js";import{M a
|
|
|
14
14
|
</button>
|
|
15
15
|
</div>
|
|
16
16
|
</div>
|
|
17
|
-
`}}
|
|
17
|
+
`}}f([p({type:Boolean})],l.prototype,"isCustomMenu");customElements.get("mealz-planner-welcome-modal")||customElements.define("mealz-planner-welcome-modal",l);export{l as M};
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import{N as
|
|
1
|
+
import{N as p,k as o}from"../../assets/no-shadow-element-D62BBu0I.js";import{n as m}from"../../assets/property-CoRN-Ln2.js";import{r}from"../../assets/state-DDIoBQp5.js";import"../../assets/mealz-sdk-E_fNZM-c.js";var h=Object.defineProperty,i=(d,e,t,c)=>{for(var s=void 0,l=d.length-1,n;l>=0;l--)(n=d[l])&&(s=n(e,t,s)||s);return s&&h(e,t,s),s};class a extends p{constructor(){super(),this.recipeImgs=[],this.currentStep=0,this.displayedRecipes=[],this.isComplete=!1,this.backgroundImages=[],this.activeBackgroundIndex=0,this.preloadedImages=new Map,this.styleURL=new URL("./planner/to-basket-loader/to-basket-loader.css",this.getBaseURL())}connectedCallback(){super.connectedCallback(),this.scrollIntoView({behavior:"smooth",block:"center"}),this.preloadImages().then(()=>{this.startAnimation()})}async preloadImages(){if(!this.recipeImgs||this.recipeImgs.length===0)return Promise.resolve();const e=this.recipeImgs.map(t=>new Promise(c=>{const s=new Image;s.onload=()=>{this.preloadedImages.set(t,s),c()},s.onerror=()=>{c()},s.src=t}));return Promise.all(e).then(()=>{this.backgroundImages=[null,null]})}startAnimation(){this.displayedRecipes=[],this.recipeImgs.length>0&&(this.backgroundImages[0]=this.recipeImgs[0],this.activeBackgroundIndex=0);const e=()=>{if(this.currentStep<this.recipeImgs.length){const t=this.recipeImgs[this.currentStep];this.displayedRecipes=[...this.displayedRecipes,t],this.updateBackgroundImage(t),this.currentStep++,setTimeout(()=>{e()},1200)}else this.isComplete=!0,setTimeout(()=>{this.emitLoaderComplete()},1500)};setTimeout(()=>{e()},500)}updateBackgroundImage(e){const t=(this.activeBackgroundIndex+1)%2;this.backgroundImages[t]=e,this.activeBackgroundIndex=t,this.requestUpdate()}emitLoaderComplete(){this.dispatchEvent(new CustomEvent("basketComplete",{bubbles:!0,composed:!0}))}render(){return o`
|
|
2
2
|
<div class="mealz-to-basket-loader ${this.isComplete?"complete":""}">
|
|
3
|
-
${this.backgroundImages.map((e,t)=>e?
|
|
3
|
+
${this.backgroundImages.map((e,t)=>e?o`
|
|
4
4
|
<div class="mealz-to-basket-loader__background ${t===this.activeBackgroundIndex?"active":""}"
|
|
5
5
|
style="background-image: url('${e}')"></div>
|
|
6
6
|
`:"")}
|
|
7
7
|
<div class="mealz-to-basket-loader__container">
|
|
8
8
|
<div class="mealz-to-basket-loader__recipes">
|
|
9
|
-
${this.displayedRecipes.map(e=>
|
|
9
|
+
${this.displayedRecipes.map(e=>o`
|
|
10
10
|
<div class="mealz-to-basket-loader__recipe-item">
|
|
11
11
|
<div class="mealz-to-basket-loader__recipe-image">
|
|
12
|
-
${e?
|
|
12
|
+
${e?o`<img src="${e}" alt="Recipe">`:o`
|
|
13
13
|
<div class="mealz-to-basket-loader__recipe-placeholder"></div>`}
|
|
14
14
|
</div>
|
|
15
15
|
</div>
|
|
@@ -17,4 +17,4 @@ import{N as n,k as c}from"../../assets/no-shadow-element-D62BBu0I.js";import{t a
|
|
|
17
17
|
</div>
|
|
18
18
|
</div>
|
|
19
19
|
</div>
|
|
20
|
-
`}}
|
|
20
|
+
`}}i([m({type:Array})],a.prototype,"recipeImgs");i([r()],a.prototype,"currentStep");i([r()],a.prototype,"displayedRecipes");i([r()],a.prototype,"isComplete");i([r()],a.prototype,"backgroundImages");i([r()],a.prototype,"activeBackgroundIndex");i([r()],a.prototype,"preloadedImages");customElements.get("mealz-to-basket-loader")||customElements.define("mealz-to-basket-loader",a);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{N as
|
|
1
|
+
import{N as n}from"../assets/no-shadow-element-D62BBu0I.js";import{o as i}from"../planner/helpers/open-onboarding-modal.min.js";import{m as u}from"../assets/mealz-sdk-E_fNZM-c.js";import"../planner/planner-onboarding-modal/planner-onboarding-modal.min.js";import"../assets/state-DDIoBQp5.js";import"../assets/property-CoRN-Ln2.js";import"../onboarding/analytics/onboarding-analytics.min.js";import"../onboarding/events.min.js";import"../planner/helpers/get-planner-onboarding-modal-config.min.js";import"../modal/modal.min.js";import"../assets/unsafe-html-DWUMaK1p.js";import"../planner/helpers/planner-onboarding-storage.min.js";class a extends n{constructor(){super(...arguments),this.minGuests=1,this.maxGuests=12,this.currentGuests=4,this.menuId=null,this.subscriptions=[]}get selectors(){return{stepperMinus:".mealz-planner-entry__stepper-button--minus",stepperPlus:".mealz-planner-entry__stepper-button--plus",stepperNumber:".mealz-planner-entry__stepper-number",helpLink:".mealz-planner-entry__help-link"}}connectedCallback(){super.connectedCallback(),this.initSelectors(),this.initStartingData(),this.initGuests(),this.addEventListeners(),this.updateStepperButtons()}disconnectedCallback(){super.disconnectedCallback(),this.subscriptions.forEach(t=>t.unsubscribe()),this.subscriptions=[]}initStartingData(){const t=this.getAttribute("starting-data");if(t){try{const{menuId:e}=JSON.parse(t);e&&(this.menuId=e)}catch(e){console.error("Failed to parse starting-data:",e);return}this.removeAttribute("starting-data")}}initGuests(){const t=localStorage.getItem("_mealz/planner/guests");if(t){const e=parseInt(t,10);!isNaN(e)&&e>=this.minGuests&&e<=this.maxGuests&&(this.currentGuests=e)}else{const e=this.querySelector(this.selectors.stepperNumber);if(e){const r=e.getAttribute("data-guests");if(r){const s=parseInt(r,10);!isNaN(s)&&s>=this.minGuests&&s<=this.maxGuests&&(this.currentGuests=s)}}if(this.currentGuests===4){const r=localStorage.getItem("_miam/preferences/guests");if(r){const s=parseInt(r,10);!isNaN(s)&&s>=this.minGuests&&s<=this.maxGuests&&(this.currentGuests=s)}}}this.updateGuestsDisplay()}addEventListeners(){this.addClickListener("stepperMinus",()=>this.decrementGuests()),this.addClickListener("stepperPlus",()=>this.incrementGuests()),this.querySelectorAll(this.selectors.helpLink).forEach(e=>{e.addEventListener("click",r=>{r.preventDefault(),this.openOnboarding()})})}decrementGuests(){this.currentGuests>this.minGuests&&(this.currentGuests--,this.updateGuests())}incrementGuests(){this.currentGuests<this.maxGuests&&(this.currentGuests++,this.updateGuests())}updateGuests(){if(localStorage.setItem("_mealz/planner/guests",this.currentGuests.toString()),this.updateGuestsDisplay(),this.updateStepperButtons(),this.menuId){const t={guests:this.currentGuests};this.subscriptions.push(u.planner.updateMenu(this.menuId,{attributes:{...t}}).subscribe())}this.dispatchEvent(new CustomEvent("plannerGuestsChanged",{detail:{guests:this.currentGuests},bubbles:!0,composed:!0}))}updateGuestsDisplay(){const t=this.querySelector(this.selectors.stepperNumber);t&&(t.textContent=this.currentGuests.toString(),t.setAttribute("data-guests",this.currentGuests.toString()))}updateStepperButtons(){const t=this.querySelector(this.selectors.stepperMinus),e=this.querySelector(this.selectors.stepperPlus);t&&(t.disabled=this.currentGuests<=this.minGuests),e&&(e.disabled=this.currentGuests>=this.maxGuests)}openOnboarding(){i("dashboard")}}customElements.get("mealz-planner-entry")||customElements.define("mealz-planner-entry",a);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import"../assets/accordion-
|
|
1
|
+
import"../assets/accordion-BGFgJnk1.js";import{N as f,B as z,a as y,k as a}from"../assets/no-shadow-element-D62BBu0I.js";import{r as p}from"../assets/state-DDIoBQp5.js";import{m as t}from"../assets/mealz-sdk-E_fNZM-c.js";import{d as w}from"../assets/debounceTime-Cf_7YmIn.js";import{d as k}from"../assets/distinctUntilChanged-kXqVrZ5h.js";import{s as T}from"../assets/switchMap-BAdE9Uzw.js";import{n as h}from"../assets/property-CoRN-Ln2.js";import{f as $}from"../assets/filter-q99GWcpD.js";import"../assets/async-C5Kj_SqM.js";import"../assets/OperatorSubscriber-DfCnFunn.js";import"../assets/innerFrom-DePszgj9.js";var S=Object.defineProperty,_=(l,e,s,c)=>{for(var i=void 0,r=l.length-1,n;r>=0;r--)(n=l[r])&&(i=n(e,s,i)||i);return i&&S(e,s,i),i};class g extends f{constructor(){super(),this.suggestedTags=[],this.notFound=!1,this.searchQuery=new z(""),this.subscription=new y,this.styleURL=new URL("./preferences/preferences-search/preferences-search.css",this.getBaseURL())}connectedCallback(){super.connectedCallback(),this.listenOnSearchChange()}disconnectedCallback(){super.disconnectedCallback(),this.subscription.unsubscribe()}searchInputUpdate(e){this.searchQuery.next(e.target.value)}listenOnSearchChange(){this.subscription.add(this.searchQuery.pipe(w(250),k(),T(e=>e.length>0?t.tags.autocomplete(e):[])).subscribe(e=>{var s,c;this.suggestedTags=(s=e==null?void 0:e.data)==null?void 0:s.filter(i=>i.attributes["tag-type-id"]==="ingredient_category"||i.attributes["tag-type-id"]==="ingredientsdefinition"),this.notFound=((c=this.suggestedTags)==null?void 0:c.length)===0,this.requestUpdate()}))}addTag(e){t.preferences.newTagFromSearch(e),this.dispatchEvent(new CustomEvent("backAndReload"))}render(){return a`
|
|
2
2
|
<div class="mealz-preferences-search">
|
|
3
3
|
<div class="mealz-preferences-search__searchbar-container">
|
|
4
4
|
<div class="mealz-preferences-search__searchbar mealz-ds-searchbar">
|
|
@@ -33,7 +33,7 @@ import"../assets/accordion-sjJSL32r.js";import{N as _,B as z,a as y,k as a}from"
|
|
|
33
33
|
`)}
|
|
34
34
|
`}
|
|
35
35
|
</div>
|
|
36
|
-
`}}
|
|
36
|
+
`}}_([p()],g.prototype,"suggestedTags");_([p()],g.prototype,"notFound");customElements.get("mealz-preferences-search")||customElements.define("mealz-preferences-search",g);class m{constructor(){this.attributes={"tag-type-id":"",name:"","icon-url":"","picture-url":""}}get tagType(){return this.attributes["tag-type-id"]}get name(){return this.attributes.name}}var x=Object.defineProperty,o=(l,e,s,c)=>{for(var i=void 0,r=l.length-1,n;r>=0;r--)(n=l[r])&&(i=n(e,s,i)||i);return i&&x(e,s,i),i};class d extends f{constructor(){super(),this.isOpen=!1,this.diets=[],this.ingredients=[],this.equipments=[],this.displayType="defaultView",this.analyticsPath="/preferences",this.openedModalSubscriptions=[],this.subscriptions=[],this.forcedIngredients=[{id:"ingredient_category_lgumes",name:"Légume"},{id:"ingredient_category_viandes-blanches",name:"Viande blanche"},{id:"ingredient_category_fromage",name:"Fromage"},{id:"ingredient_category_poissons",name:"Poisson"},{id:"ingredient_category_fruits",name:"Fruit"},{id:"ingredientsdefinition_coriandre",name:"Coriandre"},{id:"ingredientsdefinition_brocoli",name:"Brocoli"},{id:"ingredientsdefinition_oeuf",name:"Oeuf"},{id:"ingredient_category_alcool",name:"Alcool"}],this.drawerViewSwapper=document.querySelector("mealz-drawer-view-swapper")}connectedCallback(){super.connectedCallback(),this.initSubscriptions()}disconnectedCallback(){super.disconnectedCallback(),this.openedModalSubscriptions.forEach(e=>e.unsubscribe()),this.subscriptions.forEach(e=>e.unsubscribe())}initSubscriptions(){this.subscriptions.push(this.drawerViewSwapper.displayPreferences$.subscribe(e=>{this.isOpen=e,e?(this.fetchTags(),this.pageview()):this.openedModalSubscriptions.forEach(s=>s.unsubscribe()),this.requestUpdate()}),t.supplier.currentSupplier().pipe($(e=>!!e)).subscribe(e=>{this.supplierId=e.id,this.fetchTags(),this.requestUpdate()}))}defaultViewHeader(){return a`
|
|
37
37
|
<button class="mealz-ds-button ghost square mealz-preferences__back-button" @click=${this.close}>
|
|
38
38
|
<img class="mealz-preferences__back-image" alt="go back"
|
|
39
39
|
src="https://storage.googleapis.com/assets.miam.tech/generic/icons/arrow-right.svg">
|
|
@@ -51,7 +51,7 @@ import"../assets/accordion-sjJSL32r.js";import{N as _,B as z,a as y,k as a}from"
|
|
|
51
51
|
<span class="mealz-ds-text mealz-preferences__guest-label">Nombre de personnes</span>
|
|
52
52
|
<mealz-counter
|
|
53
53
|
class="mealz-preferences__guest-counter"
|
|
54
|
-
.value=${
|
|
54
|
+
.value=${t.preferences.guests$.value}
|
|
55
55
|
@valueChange=${this.updateGuests}
|
|
56
56
|
>
|
|
57
57
|
</mealz-counter>
|
|
@@ -156,4 +156,4 @@ import"../assets/accordion-sjJSL32r.js";import{N as _,B as z,a as y,k as a}from"
|
|
|
156
156
|
></mealz-preferences-search>
|
|
157
157
|
`}
|
|
158
158
|
</div>
|
|
159
|
-
`:a``}close(){this.sendCloseEvent(),this.drawerViewSwapper.displayPreferences$.next(!1),
|
|
159
|
+
`:a``}close(){this.sendCloseEvent(),this.drawerViewSwapper.displayPreferences$.next(!1),t.preferences.resetTagsActions()}pageview(){t.analytics.sendEvent("pageview",this.analyticsPath,{})}sendCloseEvent(){t.analytics.sendEvent("preferences.close",this.analyticsPath,{})}createTagSubscription(e,s){this.openedModalSubscriptions.push(t.tags.all({remotefilter:{tag_type:e,for_supplier:this.supplierId}}).subscribe(c=>{this[`${e}s`]=c.data.map(i=>({tag:i,checked:t.preferences.tagShouldBeChecked(i,s),without:e!=="diet"})),this.requestUpdate()}))}fetchTags(){this.supplierId&&(this.createTagSubscription("diet",!1),this.createTagSubscription("equipment",!0),this.initIngredientTags())}reset(){t.preferences.resetPreferences(),t.preferences.sendCacheRequest("remove","preferences").subscribe(),this.fetchTags()}initIngredientTags(){this.ingredients=[],this.forcedIngredients.forEach(e=>{const s=new m;s.id=e.id,s.attributes.name=e.name,this.ingredients.push({tag:s,checked:t.preferences.tagShouldBeChecked(s,!0),without:!0})}),this.getAdditionalIngredients()}getAdditionalIngredients(){(t.preferences.preferencesInStorage()||{without:[]}).without.filter(r=>r.id.includes("ingredient_category_")||r.id.includes("ingredientsdefinition_")||r.id.includes("meal_type_")).forEach(r=>{if(this.forcedIngredients.findIndex(n=>n.id===r.id)===-1){const n=new m;n.id=r.id,n.attributes={"tag-type-id":"",name:r.name,"icon-url":"","picture-url":""},t.preferences.tagShouldBeChecked(n,!0)&&this.ingredients.push({tag:n,checked:!0,without:!0})}});const c=["ingredient_category_","ingredientsdefinition_","meal_type_"],i=t.preferences.tagsToAdd.filter(r=>{const n=r.tag.id,b=c.some(u=>n.includes(u)),v=!this.ingredients.some(u=>u.tag.id===n);return b&&v});this.ingredients.push(...i),this.updateFiltersInCache()}toggleTag(e){e.checked=!e.checked,e.tag.attributes["tag-type-id"]==="equipment"!==e.checked?t.preferences.addTag(e):(t.preferences.removeTag(e),this.isAdditionalIngredient(e)&&this.ingredients.splice(this.ingredients.findIndex(s=>s.tag.id===e.tag.id),1)),this.requestUpdate()}isAdditionalIngredient(e){return this.forcedIngredients.findIndex(s=>s.id===e.tag.id)===-1&&(e.tag.id.includes("ingredient_category_")||e.tag.id.includes("ingredientsdefinition_"))}updateAndBack(){t.preferences.updatePreferences(),this.updateFiltersInCache(!0)}goToDefaultView(){this.displayType="defaultView",this.requestUpdate()}goToSearchView(){this.displayType="searchView",this.requestUpdate()}updateFiltersInCache(e=!1){const s=t.preferences.addPreferencesToRemoteFilters(this.filters,!0),c={exclude_tags:s.exclude_tags,include_tags:s.include_tags,...t.preferences.guests$.value!==4&&{guests:t.preferences.guests$.value}};(Object.keys(c).length>0?t.preferences.sendCacheRequest("set","preferences",c):t.preferences.sendCacheRequest("remove","preferences")).subscribe(()=>{e&&(t.preferences.preferencesChanged(),this.close())})}updateGuests(e){t.preferences.guests$.next(e.detail.value),this.requestUpdate()}}o([h({type:Object})],d.prototype,"filters");o([h({type:Boolean})],d.prototype,"isOpen");o([p()],d.prototype,"diets");o([p()],d.prototype,"ingredients");o([p()],d.prototype,"equipments");o([p()],d.prototype,"displayType");o([h({type:String})],d.prototype,"analyticsPath");customElements.get("mealz-preferences")||customElements.define("mealz-preferences",d);
|
package/dist/price/price.min.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import{N as
|
|
1
|
+
import{N as n,k as p,D as d}from"../assets/no-shadow-element-D62BBu0I.js";import{n as o}from"../assets/property-CoRN-Ln2.js";import{P as m}from"../assets/price-D6RVRYHJ.js";import"../assets/mealz-sdk-E_fNZM-c.js";import"../assets/singleton-COF3iBbF.js";var u=Object.defineProperty,l=(i,t,e,h)=>{for(var r=void 0,c=i.length-1,a;c>=0;c--)(a=i[c])&&(r=a(t,e,r)||r);return r&&u(t,e,r),r};class s extends n{constructor(){super(),this.priceService=m.getInstance(),this.styleURL=new URL("./price/price.css",this.getBaseURL())}connectedCallback(){super.connectedCallback(),this.applyStartingDataFromAttribute(),this.priceService.initFormatter()}renderOldPrice(){return p`
|
|
2
2
|
<div class="mealz-price__previous mealz-ds-text weight-l size-xs">
|
|
3
3
|
${this.priceService.priceTemplate(this.oldPrice)}
|
|
4
4
|
</div>
|
|
5
|
-
`}render(){return
|
|
5
|
+
`}render(){return p`
|
|
6
6
|
<div class="mealz-price">
|
|
7
7
|
${this.oldPrice?this.renderOldPrice():d}
|
|
8
8
|
<div class="mealz-price__current">
|
|
9
9
|
${this.priceService.priceTemplate(this.price)}
|
|
10
10
|
</div>
|
|
11
11
|
</div>
|
|
12
|
-
`}applyStartingDataFromAttribute(){const t=this.getAttribute("starting-data");if(t){try{const e=JSON.parse(t);typeof e.price=="number"&&(this.price=e.price),typeof e.oldPrice=="number"&&(this.oldPrice=e.oldPrice)}catch{}this.removeAttribute("starting-data")}}}
|
|
12
|
+
`}applyStartingDataFromAttribute(){const t=this.getAttribute("starting-data");if(t){try{const e=JSON.parse(t);typeof e.price=="number"&&(this.price=e.price),typeof e.oldPrice=="number"&&(this.oldPrice=e.oldPrice)}catch{}this.removeAttribute("starting-data")}}}l([o({type:Number})],s.prototype,"price");l([o({type:Number})],s.prototype,"oldPrice");customElements.get("mealz-price")||customElements.define("mealz-price",s);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{n as c}from"../assets/property-CoRN-Ln2.js";import{N as b}from"../assets/no-shadow-element-D62BBu0I.js";import{m as n}from"../assets/mealz-sdk-E_fNZM-c.js";import{P as S}from"../assets/price-D6RVRYHJ.js";import{c as f}from"../assets/combineLatest-Capvy1jI.js";import"../assets/singleton-COF3iBbF.js";import"../assets/from-D8c5akO7.js";import"../assets/innerFrom-DePszgj9.js";import"../assets/executeSchedule-CEDvgTzM.js";import"../assets/OperatorSubscriber-DfCnFunn.js";import"../assets/mapOneOrManyArgs-CHGhEDCk.js";import"../assets/map-DT-7dkaR.js";import"../assets/args-DAL2bHut.js";import"../assets/isScheduler-CqHuyMwD.js";var k=Object.defineProperty,l=(d,t,e,i)=>{for(var s=void 0,a=d.length-1,r;a>=0;a--)(r=d[a])&&(s=r(t,e,s)||s);return s&&k(t,e,s),s};class o extends b{constructor(){super(),this.recipeId="",this.guests=0,this.analyticsPath="",this.subscriptions=[],this.remainingBasketEntries=[],this.allIngredientsToBasketLoading=!1,this.ingredientToBasketLoading=!1,this.remainingPrice=0,this.priceService=S.getInstance(),this.hasLiveData=!1,this.initialSSRCount=null,this.initialSSRPrice=null,this.styleURL=new URL("./products-to-basket-cta/products-to-basket-cta.css",this.getBaseURL())}get selectors(){return{addButton:"button.mealz-products-to-basket-cta",addButtonText:".mealz-products-to-basket__add-to-basket-cta__text",addButtonTextMain:".mealz-products-to-basket__add-to-basket-cta__text > span",loader:".mealz-ds-loader",remainingPriceValue:".mealz-products-to-basket__add-to-basket-remaining-price > span"}}connectedCallback(){super.connectedCallback(),this.applyStartingDataFromAttribute(),this.analyticsPath=this.analyticsPath||`/recipes/${this.recipeId}/shopping`,this.priceService.initFormatter(),this.initSelectors("addButton","addButtonText","addButtonTextMain","loader","remainingPriceValue"),this.addClickListener("addButton",()=>this.addAllIngredients()),this.initialSSRCount=this.readSSRCount(),this.initialSSRPrice=this.readSSRPrice(),this.subscribeToRecipeBasketStreams()}subscribeToRecipeBasketStreams(){this.subscriptions.push(f([n.recipes.remainingBasketEntries$,n.recipes.recipePrice$,n.recipes.allIngredientsToBasketLoading$,n.recipes.ingredientToBasketLoading$]).subscribe(t=>this.handleRecipeBasketStreamsUpdate(t)))}handleRecipeBasketStreamsUpdate(t){const[e,i,s,a]=t,r=e||[],u=i&&typeof i.remaining=="number"?i.remaining:0,h=!!s,p=!!a,m=r.length===0&&(Number(u)||0)===0&&!h&&!p,g=this.initialSSRCount!=null&&this.initialSSRCount>0||this.initialSSRPrice!=null&&this.initialSSRPrice>0;!this.hasLiveData&&m&&g||(this.remainingBasketEntries=r,this.remainingPrice=u,this.allIngredientsToBasketLoading=h,this.ingredientToBasketLoading=p,this.hasLiveData=!0,this.updateUI())}disconnectedCallback(){super.disconnectedCallback();for(const t of this.subscriptions)t.unsubscribe()}addAllIngredients(){this.recipeId&&(n.recipes.addAllIngredientsToBasket({originPath:this.analyticsPath,props:{}}),this.sendAddAllEvent())}sendAddAllEvent(){n.analytics.sendEvent("entry.add-all",this.analyticsPath,{recipe_id:this.recipeId,entry_count:this.remainingBasketEntries.length})}updateUI(){const t=this.isLoading();if(!this.hasLiveData){this.updateButtonState(this.getEl(this.elements.addButton),t);return}const e=this.remainingBasketEntries.length,i=this.getNumericRemainingPrice();this.updateButtonState(this.getEl(this.elements.addButton),t),this.updateTextVisibility(this.getEl(this.elements.addButtonText),t),this.updateMainText(this.getEl(this.elements.addButtonTextMain),e),this.updateLoaderVisibility(this.getEl(this.elements.loader),t),this.updateRemainingPrice(this.getEl(this.elements.remainingPriceValue),i)}getEl(t){return t instanceof HTMLElement?t:null}isLoading(){return this.allIngredientsToBasketLoading||this.ingredientToBasketLoading}getNumericRemainingPrice(){return Math.max(0,Number(this.remainingPrice)||0)}updateButtonState(t,e){if(t){if(!this.recipeId||e){t.setAttribute("disabled","true"),t.classList.add("disabled");return}t.removeAttribute("disabled"),t.classList.remove("disabled")}}updateTextVisibility(t,e){t&&t.classList.toggle("hidden",e)}updateMainText(t,e){t&&(e>1?t.textContent=`Ajouter ${e} produits`:e===1?t.textContent="Ajouter 1 produit":t.textContent="Ajouter")}updateLoaderVisibility(t,e){t&&t.classList.toggle("hidden",!e)}updateRemainingPrice(t,e){if(!t)return;const i=t.parentElement;try{t.textContent=this.priceService.formatPrice(e),i&&i.classList.toggle("hidden",e<=0)}catch(s){console.warn("products-to-basket-cta: price format error",s),t.textContent=""+this.remainingPrice,i&&i.classList.toggle("hidden",!(Number(this.remainingPrice)>0))}}readSSRCount(){const t=this.elements.addButtonTextMain,i=((t==null?void 0:t.textContent)||"").match(/Ajouter\s+(\d+)/i);if(i&&i[1]){const s=Number(i[1]);return Number.isFinite(s)?s:null}return null}readSSRPrice(){const t=this.elements.remainingPriceValue,i=((t==null?void 0:t.textContent)||"").replace(/[^0-9,.-]/g,"").replace(",","."),s=Number(i);return Number.isFinite(s)?s:null}applyStartingDataFromAttribute(){const t=this.getAttribute("starting-data");if(t){try{const e=JSON.parse(t);e&&typeof e.recipeId=="string"&&(this.recipeId=e.recipeId),typeof e.guests=="number"&&(this.guests=e.guests)}catch(e){console.warn("mealz-products-to-basket-cta: invalid starting-data payload",e)}this.removeAttribute("starting-data")}}}l([c({type:String})],o.prototype,"recipeId");l([c({type:Number})],o.prototype,"guests");l([c({type:String})],o.prototype,"analyticsPath");customElements.get("mealz-products-to-basket-cta")||customElements.define("mealz-products-to-basket-cta",o);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{N as S}from"../assets/no-shadow-element-D62BBu0I.js";import{V as
|
|
1
|
+
import{N as S}from"../assets/no-shadow-element-D62BBu0I.js";import{V as g}from"../assets/viewport-listener-DsRHfwo4.js";import{h as f}from"../assets/session-handler-BZFnRy_K.js";import{w as I,m as c}from"../assets/mealz-sdk-E_fNZM-c.js";import{f as u}from"../assets/filter-q99GWcpD.js";import{s as w}from"../assets/switchMap-BAdE9Uzw.js";import{c as y}from"../assets/combineLatest-Capvy1jI.js";import{t as d}from"../assets/take-CpvJwza7.js";import"../assets/debounceTime-Cf_7YmIn.js";import"../assets/async-C5Kj_SqM.js";import"../assets/OperatorSubscriber-DfCnFunn.js";import"../assets/innerFrom-DePszgj9.js";import"../assets/from-D8c5akO7.js";import"../assets/executeSchedule-CEDvgTzM.js";import"../assets/mapOneOrManyArgs-CHGhEDCk.js";import"../assets/map-DT-7dkaR.js";import"../assets/args-DAL2bHut.js";import"../assets/isScheduler-CqHuyMwD.js";import"../assets/empty-qrpgDBbc.js";class n{constructor(){this.trackedRecipes=new Map,this.hasScrolled=!1,this.scrollListener=null,this.cleanupInterval=null,this.MAX_RECIPES=1e3,this.CLEANUP_INTERVAL=300*1e3,this.handlePageUnload=()=>{this.destroy()},this.setupScrollListener(),this.startAutoCleanup(),this.setupPageUnloadListener()}static getInstance(){return n.instance||(n.instance=new n),n.instance}trackRecipeShow(e,t,s){const i=Date.now(),r=!this.trackedRecipes.get(e),o=this.hasScrolled;!r&&!o||(this.trackedRecipes.size>=this.MAX_RECIPES&&this.cleanOldRecipes(),this.trackedRecipes.set(e,i),window.mealzInternal.analytics.sendEvent("recipe.show",t,{recipe_id:e,category_id:s}))}cleanOldRecipes(){const t=Date.now()-3600*1e3;for(const[s,i]of this.trackedRecipes.entries())i<t&&this.trackedRecipes.delete(s)}clearAllRecipes(){this.trackedRecipes.clear()}destroy(){this.scrollListener&&(window.removeEventListener("scroll",this.scrollListener),this.scrollListener=null),window.removeEventListener("beforeunload",this.handlePageUnload),this.cleanupInterval&&(clearInterval(this.cleanupInterval),this.cleanupInterval=null),this.trackedRecipes.clear(),this.hasScrolled=!1,n.instance=null}setupScrollListener(){let e;this.scrollListener=()=>{this.hasScrolled=!0,clearTimeout(e),e=window.setTimeout(()=>{this.hasScrolled=!1},2e3)},window.addEventListener("scroll",this.scrollListener)}startAutoCleanup(){this.cleanupInterval=window.setInterval(()=>{this.cleanOldRecipes()},this.CLEANUP_INTERVAL)}setupPageUnloadListener(){window.addEventListener("beforeunload",this.handlePageUnload)}}class b extends S{constructor(){super(...arguments),this.subscriptions=[]}connectedCallback(){super.connectedCallback(),this.getInitialStatus(),this.listenInView(),I().then(()=>{this.setupSubscriptions()}).catch(e=>{console.warn("Failed to initialize SDK subscriptions:",e)})}setupSubscriptions(){this.subscriptions.push(c.basket.recipePricesInBasket$().subscribe(e=>{if(!e)return;const t=e.find(s=>s.id===this.recipeId);e.length>0&&t&&parseFloat(t.price)>0?(this.guests=c.basket.guestsForRecipe(t.id),this.updatedRecipeId=t.id,this.updateDOM()):this.render()}),this.setupPlannerMenuSubscription(),this.setupGuestUpdatesSubscription())}setupPlannerMenuSubscription(){return c.planner.menuPrice$.pipe(u(()=>this.planner&&!!this.recipeId),w(()=>y([c.planner.isRecipeInMenu$(this.recipeId).pipe(d(1))])),u(([e,t])=>e&&typeof t=="number"&&t>0)).subscribe(([e,t])=>{this.guests=t,this.updateGuestDisplay()})}setupGuestUpdatesSubscription(){return c.recipes.guestsUpdated().subscribe(e=>{e.recipeId===this.recipeId&&(this.guests=e.guests,this.updatedRecipeId=this.recipeId,this.updateDOM())})}disconnectedCallback(){var t;super.disconnectedCallback(),this.subscriptions.forEach(s=>s.unsubscribe()),(t=this.analyticsViewportObserver)==null||t.disconnect(),n.getInstance().cleanOldRecipes()}render(){this.recipeCardTop=this.querySelector(".mealz-recipe-card__top"),this.recipeCardCta=this.querySelector(".mealz-recipe-card__cta"),this.recipeCardTop&&(this.getInitialStatus(),this.recipeCardTop.addEventListener("click",()=>this.openDetails()),this.recipeCardCta&&this.recipeCardCta.addEventListener("click",()=>this.recipeCardCtaClick()))}listenInView(){this.analyticsViewportObserver=new g(this,()=>{this.sendAnalyticsShow()},{threshold:.8,debounce:1e3})}getInitialStatus(){var p;const e=(p=this.attributes["starting-data"])==null?void 0:p.value;if(!e)return;const{id:t,guests:s,path:i,categoryId:a,initialTabIndex:r,planner:o,sessionId:l,recipe:m}=JSON.parse(e);if(this.recipeId=t,this.analyticsPath=i,this.categoryId=a,this.guests=s,this.initialTabIndex=r,this.planner=o,this.recipe=m,f(l),!this.guests){this.guests=this.getGuests();const h=this.querySelector(".mealz-recipe-card__counter p");h&&(h.innerHTML=this.guests.toString())}this.removeAttribute("starting-data"),this.updateDOM()}openDetails(){c.recipes.openDetails(this.recipeId,this.guests,this.initialTabIndex,this.analyticsPath,this.planner,this.categoryId)}recipeCardCtaClick(){this.planner?this.handleCTAClickForPlanner():this.openDetails()}getGuests(){const e=localStorage.getItem("_miam/preferences/guests");if(e){const t=+e;if(!isNaN(t)&&t>0&&t<=30)return t}return 4}handleCTAClickForPlanner(){const e=this.querySelector("mealz-recipe-card-cta");if(!e)return;const t=e.querySelector(".mealz-recipe-card-cta__loader");if(t&&!t.classList.contains("hidden"))return;const s=e.getStatus();s==="add"?(this.showAddingToMenuState(e),this.addRecipeToMenu()):s==="in-menu"&&(this.showRemovingFromMenuState(e),this.removeRecipeFromMenu())}addRecipeToMenu(){var i,a;const e=document.querySelector("mealz-planner-recipe-suggestion"),t=(e==null?void 0:e.guests)||this.guests;this.guests=t,e&&(e.recipeId=this.recipeId);const s=document.querySelector("mealz-planner-current-menu");if(!s){const r=(a=(i=c.recipes)==null?void 0:i.productsPlannerByCategory$)==null?void 0:a.value,o=(r==null?void 0:r.toPickProducts)||[];c.planner.addRecipeToMenu(this.recipeId,t,!!c.pos.currentPos().value,o).pipe(d(1)).subscribe(()=>{this.removeRecipeCardLoader("add");const l=document.querySelector("mealz-planner-recipe-list");l==null||l.addRecipeCardToList(this.recipeId)});return}s.addRecipe(this.recipeId,t).subscribe(()=>{this.removeRecipeCardLoader("add"),e==null||e.addAndSelectNewSuggestion(this.recipe)})}removeRecipeFromMenu(){const e=document.querySelector("mealz-planner-recipe-suggestion");if(!e){c.planner.removeRecipeFromMenu(this.recipeId).pipe(d(1)).subscribe(()=>this.removeRecipeCardLoader("remove"));return}e.removeRecipe(this.recipeId).subscribe(()=>this.removeRecipeCardLoader("remove"))}showRemovingFromMenuState(e){const t=this.querySelector(".mealz-recipe-card-cta__loader"),s=e.querySelector("img.in-menu");t==null||t.classList.remove("hidden"),s==null||s.classList.add("hidden")}removeRecipeCardLoader(e){const t=this.querySelector("mealz-recipe-card-cta");if(!t)return;const s=this.querySelector(".mealz-recipe-card-cta"),i=this.querySelector(".mealz-recipe-card-cta__loader"),a=t.querySelector("img.add"),r=t.querySelector("img.in-menu");e==="add"?(i==null||i.classList.add("hidden"),s==null||s.classList.replace("primary","secondary"),r==null||r.classList.remove("hidden"),t.updateStatus("in-menu")):(i==null||i.classList.add("hidden"),s==null||s.classList.replace("secondary","primary"),a==null||a.classList.remove("hidden"),t.updateStatus("add"))}showAddingToMenuState(e){const t=this.querySelector(".mealz-recipe-card-cta__loader"),s=e.querySelector("img.add"),i=e.querySelector("img.in-menu");t==null||t.classList.remove("hidden"),s==null||s.classList.add("hidden"),i==null||i.classList.add("hidden")}updateDOM(){if(this.recipeId!==this.updatedRecipeId)return;const e=this.querySelector(".mealz-recipe-card__counter p");e&&(e.innerHTML=this.guests.toString())}updateGuestDisplay(){const e=this.querySelector(".mealz-recipe-card__counter p");e&&this.guests&&(e.innerHTML=this.guests.toString())}sendAnalyticsShow(){n.getInstance().trackRecipeShow(this.recipeId,this.analyticsPath,this.categoryId)}}customElements.get("mealz-recipe-card")||customElements.define("mealz-recipe-card",b);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{v as
|
|
1
|
+
import{v as F,O as H,N as P}from"../assets/no-shadow-element-D62BBu0I.js";import{w as D,m as o}from"../assets/mealz-sdk-E_fNZM-c.js";import{m as d}from"../assets/map-DT-7dkaR.js";import{d as p}from"../assets/distinctUntilChanged-kXqVrZ5h.js";import{m as q}from"../assets/mergeAll-DpEYIxY3.js";import{p as O}from"../assets/args-DAL2bHut.js";import{f as V}from"../assets/from-D8c5akO7.js";import{o as k,c as C}from"../assets/OperatorSubscriber-DfCnFunn.js";import{c as A}from"../assets/combineLatest-Capvy1jI.js";import{f as B}from"../assets/firstValueFrom-Bcbk1SUg.js";import{t as h}from"../assets/take-CpvJwza7.js";import{f as N}from"../assets/filter-q99GWcpD.js";import{s as E}from"../assets/skipWhile-Beza3ws3.js";import{a as U}from"../assets/async-C5Kj_SqM.js";import{i as x}from"../assets/isDate-BwHtzZM4.js";import{i as f}from"../assets/innerFrom-DePszgj9.js";import{e as W}from"../assets/executeSchedule-CEDvgTzM.js";import{s as _}from"../assets/switchMap-BAdE9Uzw.js";import{o as J}from"../assets/of-DtJFltSl.js";import"../assets/mergeMap-D2yctTHQ.js";import"../assets/isScheduler-CqHuyMwD.js";import"../assets/mapOneOrManyArgs-CHGhEDCk.js";import"../assets/empty-qrpgDBbc.js";var K=F(function(s){return function(t){t===void 0&&(t=null),s(this),this.message="Timeout has occurred",this.name="TimeoutError",this.info=t}});function w(s,e){var t=x(s)?{first:s}:typeof s=="number"?{each:s}:s,i=t.first,a=t.each,n=t.with,r=n===void 0?j:n,c=t.scheduler,I=c===void 0?U:c,y=t.meta,T=y===void 0?null:y;if(i==null&&a==null)throw new TypeError("No timeout provided.");return k(function(z,u){var L,l,g=null,b=0,S=function(v){l=W(u,I,function(){try{L.unsubscribe(),f(r({meta:T,lastValue:g,seen:b})).subscribe(u)}catch(M){u.error(M)}},v)};L=z.subscribe(C(u,function(v){l==null||l.unsubscribe(),b++,u.next(g=v),a>0&&S(a)},void 0,void 0,function(){l!=null&&l.closed||l==null||l.unsubscribe(),g=null})),!b&&S(i!=null?typeof i=="number"?i:+i-I.now():a)})}function j(s){throw new K(s)}function G(){return q(1)}function $(){for(var s=[],e=0;e<arguments.length;e++)s[e]=arguments[e];return G()(V(s,O(s)))}var Q=Array.isArray;function X(s){return s.length===1&&Q(s[0])?s[0]:s}function Y(){for(var s=[],e=0;e<arguments.length;e++)s[e]=arguments[e];return s=X(s),s.length===1?f(s[0]):new H(Z(s))}function Z(s){return function(e){for(var t=[],i=function(n){t.push(f(s[n]).subscribe(C(e,function(r){if(t){for(var c=0;c<t.length;c++)c!==n&&t[c].unsubscribe();t=null}e.next(r)})))},a=0;t&&!e.closed&&a<s.length;a++)i(a)}}function R(s){return k(function(e,t){var i=null,a=!1,n;i=e.subscribe(C(t,void 0,void 0,function(r){n=f(s(r,R(s)(e))),i?(i.unsubscribe(),i=null,n.subscribe(t)):a=!0})),a&&(i.unsubscribe(),i=null,n.subscribe(t))})}function m(){for(var s=[],e=0;e<arguments.length;e++)s[e]=arguments[e];var t=O(s);return k(function(i,a){(t?$(s,i,t):$(s,i)).subscribe(a)})}class ee extends P{constructor(){super(),this.subscriptions=[],this.clickHandler=()=>{},this.recipeId="",this.status="add",this.planner=!1,this.recipeCta=null,this.guests=4,this.standalone=!1,this.inBasket=!1,this.toBasketOnClick=!1,this.analyticsPath="",this.addAllIngredientsLoading=!1,this.styleURL=new URL("./recipe-card-cta/recipe-card-cta.css",this.getBaseURL())}connectedCallback(){super.connectedCallback(),this.getInitialStatus(),D().then(()=>{this.setupClickHandler(),this.setupSubscriptions()}).catch(e=>{console.warn("Failed to initialize SDK subscriptions:",e)})}setupSubscriptions(){const e=o.basket.recipePricesInBasket$().pipe(d(t=>t.some(i=>i.id===this.recipeId)),p(),m(!1));this.subscriptions.push(A([o.planner.isRecipeInMenu$(this.recipeId).pipe(m(!1),p()),e]).pipe(d(([t,i])=>this.planner?i?"in-basket":t?"in-menu":"add":i?"in-basket":"add"),p()).subscribe(t=>this.updateStatus(t)))}disconnectedCallback(){super.disconnectedCallback(),this.subscriptions.forEach(e=>e.unsubscribe()),this.removeClickHandler()}render(){this.recipeCta=this.querySelector(".mealz-recipe-card-cta"),this.recipeCta&&this.updateStatus(this.status)}getInitialStatus(){const e=this.attributes.getNamedItem("starting-data"),t=(e==null?void 0:e.value)||"{}",i=JSON.parse(t);if(i){if(i.recipeId)this.recipeId=i.recipeId,this.guests=i.guests||4,this.standalone=!0,this.inBasket=i.inBasket||!1,this.planner=i.planner||!1,this.status=i.status||"add",this.toBasketOnClick=i.toBasketOnClick||!1,this.analyticsPath=`/recipes/${this.recipeId}/shopping`,this.updateDOM(this.inBasket);else{const a=e==null?void 0:e.value;this.recipeId=a||"",this.standalone=!1,this.analyticsPath=this.recipeId?`/recipes/${this.recipeId}/shopping`:"";const n=this.classList.contains("in-basket");this.updateDOM(n)}if(this.removeAttribute("starting-data"),this.planner)this.updateStatus(this.status);else{const a=this.classList.contains("in-basket");this.updateStatus(a?"in-basket":"add")}}}setupClickHandler(){this.standalone&&(this.recipeCta=this.querySelector(".mealz-recipe-card-cta"),this.recipeCta&&(this.clickHandler=()=>{if(!this.planner)if(this.toBasketOnClick){if(this.addAllIngredientsLoading)return;this.addAllIngredientsFromRecipeToBasket()}else o.recipes.openDetails(this.recipeId,this.guests,0,"/recipes")},this.recipeCta.addEventListener("click",this.clickHandler)))}removeClickHandler(){this.recipeCta&&this.clickHandler&&this.recipeCta.removeEventListener("click",this.clickHandler)}updateStatus(e){this.recipeCta&&(this.recipeCta.classList.remove("hidden"),this.status=e,this.recipeCta.classList.remove("in-basket","in-menu","add"),this.recipeCta.classList.add(this.status),this.recipeCta.classList.toggle("primary",this.status==="add"),this.recipeCta.classList.toggle("secondary",this.status!=="add"),this.updateButtonState(),this.updateImages())}updateButtonState(){this.recipeCta&&(this.addAllIngredientsLoading||this.planner&&this.status==="in-basket"?(this.recipeCta.setAttribute("disabled","true"),this.recipeCta.classList.add("disabled")):(this.recipeCta.removeAttribute("disabled"),this.recipeCta.classList.remove("disabled")))}async addAllIngredientsFromRecipeToBasket(){if(this.recipeId){this.setLoadingState(!0);try{const e=o.recipes.loadAndSetupRecipe(this.recipeId,this.guests);e&&typeof e.pipe=="function"&&await B(e.pipe(h(1))),o.recipes.addAllIngredientsToBasket({originPath:this.analyticsPath,props:{}}),await this.waitForAddAllIngredientsToComplete()&&this.sendAddAllEvent()}catch(e){console.warn("mealz-recipe-card-cta: add-all-to-basket failed",e)}finally{this.setLoadingState(!1)}}}setLoadingState(e){if(this.addAllIngredientsLoading=e,!this.recipeCta)return;this.recipeCta.classList.toggle("loading",e),this.updateButtonState();const t=this.recipeCta.querySelector(".mealz-recipe-card-cta__loader");t&&t.classList.toggle("hidden",!e),this.recipeCta.querySelectorAll("img").forEach(a=>a.classList.toggle("hidden",e)),e||this.updateImages()}async waitForAddAllIngredientsToComplete(){const e=o.recipes.allIngredientsToBasketLoading$,t=o.basket.recipePricesInBasket$().pipe(d(r=>r.some(c=>c.id===this.recipeId)),p(),m(!1)),i=o.planner.isRecipeInMenu$(this.recipeId).pipe(m(!1),p()),a=A([i,t]).pipe(d(([r,c])=>c||this.planner&&r),N(r=>r),h(1),d(()=>!1)),n=e.pipe(E(r=>!r),h(1),w({first:15e3}),_(()=>e.pipe(E(r=>r),h(1),w({first:3e4}))),d(()=>!0),R(()=>J(!1)),h(1));return B(Y(n,a))}getRemainingEntriesCount(){const t=o.recipes.remainingBasketEntries$.value;return Array.isArray(t)?t.length:0}sendAddAllEvent(){o.analytics.sendEvent("entry.add-all",this.analyticsPath,{recipe_id:this.recipeId,entry_count:this.getRemainingEntriesCount()})}updateImages(){if(!this.recipeCta)return;this.recipeCta.querySelectorAll("img").forEach(t=>{t.classList.contains(this.status)?t.classList.remove("hidden"):t.classList.add("hidden")})}getStatus(){return this.status}updateDOM(e){const t=this.querySelector(".mealz-recipe-card-cta");t&&(t.classList.remove("hidden"),e?(t.classList.replace("primary","secondary"),t.classList.add("in-basket")):(t.classList.replace("secondary","primary"),t.classList.remove("in-basket")))}}customElements.get("mealz-recipe-card-cta")||customElements.define("mealz-recipe-card-cta",ee);
|