mealz-components 2.8.3 → 2.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- function c(){const e=document.getElementById("__mealz-basket-preview-config__"),a=new URL(globalThis.location.href),l=(e==null?void 0:e.dataset.title)??a.searchParams.get("title")??"Mes repas",s=e==null?void 0:e.dataset.showTabSelector;let t;if(s===void 0){const o=a.searchParams.get("show_tab_selector");t=o!=="false"&&o!=="0"}else t=s!=="false";const r=document.querySelector("mealz-drawer-view-swapper");r&&r.displayBasketDrawer$.next({title:l,showTabSelector:t})}c();
1
+ import{w as e,a as s}from"../../assets/mealz-sdk-CQtAGQGQ.js";async function o(){const a=new URL(globalThis.location.href).searchParams.get("myMeals")==="products"?1:0;await e(),s.basket.openPreview("",a)}o();
@@ -1,29 +1,29 @@
1
- import"../drawer/drawer.min.js";import"../store-locator-drawer/store-locator-drawer.min.js";import{N as h,D as d,k as r,B as p}from"../assets/no-shadow-element-DZc32M1D.js";import{n as y}from"../assets/property-CrS1c6lI.js";import{m as t,w as g,i as k}from"../assets/mealz-sdk-CQtAGQGQ.js";import"../recipe-details/recipe-details.min.js";import"../store-locator/store-locator.min.js";import"../planner/planner-catalog/planner-catalog.min.js";import"../replace-item/replace-item.min.js";import"../replace-item-planner/replace-item-planner.min.js";import"../history-drawer/history-drawer.min.js";import{G as S,g as P}from"../supplier-selector/supplier-selector.min.js";import{o as R,l as z}from"../catalog/basket-preview/basket-preview.min.js";import"../preferences/preferences.min.js";import{m as b}from"../assets/merge-rdVI6Z3B.js";import{m as c}from"../assets/map-DdvZijlE.js";import{E as _}from"../assets/empty--gMS1asf.js";import"../assets/unsafe-html-DTarpZaV.js";import"../assets/skipWhile-BrGaejAE.js";import"../assets/OperatorSubscriber-BF1r9b3N.js";import"../assets/switchMap-C79NTzdm.js";import"../assets/innerFrom-BZ8nxpLv.js";import"../assets/filter-Dq4X88HC.js";import"../recipe-pricing/recipe-pricing.min.js";import"../assets/viewport-listener-073Dyp25.js";import"../assets/debounceTime-D6W3esj0.js";import"../assets/async-Buq9Zuro.js";import"../assets/take-B0yyxfMB.js";import"../assets/price-Bfy_G-uC.js";import"../assets/singleton-COF3iBbF.js";import"../assets/capitalize-DUAqYmp4.js";import"../counter/counter.min.js";import"../assets/product-card-CcfAgVi3.js";import"../price/price.min.js";import"../assets/promotion-badge-BusnHgIb.js";import"../assets/guestObserver-CSQi-6i9.js";import"../assets/delay-CUcLbxeL.js";import"../assets/mergeMap-CObP_yRz.js";import"../assets/executeSchedule-CEDvgTzM.js";import"../assets/timer-CGijW-Af.js";import"../assets/isScheduler-B3orCs5Q.js";import"../assets/isDate-BwHtzZM4.js";import"../assets/accordion-Ds4UMuL5.js";import"../store-indicator/store-indicator.min.js";import"../assets/state-1qy1JPQz.js";import"../assets/query-BApjzB0v.js";import"../last-order-badge/last-order-badge.min.js";import"../order-again/order-again.min.js";import"../like-button/like-button.min.js";import"../last-order-modal/last-order-modal.min.js";import"../planner/planner-onboarding/planner-onboarding.min.js";import"../onboarding/onboarding.min.js";import"../onboarding/events.min.js";import"../onboarding/analytics/onboarding-analytics.min.js";import"../assets/responsive-C7Qf71r3.js";import"../planner/helpers/planner-onboarding-storage.min.js";import"../assets/tap-D0fB7oij.js";import"../assets/combineLatest-CRVESsJM.js";import"../assets/from-BxJrdzJs.js";import"../assets/mapOneOrManyArgs-BpqqmasF.js";import"../assets/args-DPeCFqiB.js";import"../catalog/catalog-load-more.min.js";import"../assets/http-B0u4sOhM.js";import"../replace-item/replace-item-card/replace-item-card.min.js";import"../assets/price-utils-BRFZa-3D.js";import"../assets/distinctUntilChanged-FtASLz6t.js";import"../replace-item-planner/replace-item-card-planner/replace-item-card-planner.min.js";import"../assets/of-R1iMbYYX.js";import"../slider-tabs/slider-tabs.min.js";import"../modal/modal.min.js";import"../assets/mergeAll-BJfNWPb7.js";var C=Object.defineProperty,D=(l,e,i,o)=>{for(var s=void 0,a=l.length-1,n;a>=0;a--)(n=l[a])&&(s=n(e,i,s)||s);return s&&C(e,i,s),s};class f extends h{constructor(){super(),this.styleURL=new URL("./recipe-details/sponsor-block/sponsor-block.css",this.getBaseURL())}render(){var w,v,$;if(!this.sponsorBlock)return d;const{pictureUrl:e,content:i,backgroundColor:o="#FFFFFF",fontSize:s=16,fontColor:a="#000000"}=this.sponsorBlock,n=($=(v=(w=this.sponsorBlock.relationships)==null?void 0:w["sponsor-block-type"])==null?void 0:v.data)==null?void 0:$.name;if(!n)return r``;const m=n.toLowerCase(),u=`background-color: ${o}; font-size: ${s}px; color: ${a};`;switch(n){case"TEXT":case"SMALL_TEXT":case"TITLE":case"SMALL_TITLE":return r`
2
- <div class="sponsor-text-blocks sponsor-${m}-block" style="background-color: ${o};">
3
- <span class="sponsor-${m}-block__text" style="font-size: ${n.includes("TITLE")?32:16}px; color: ${a};">
1
+ import"../drawer/drawer.min.js";import"../store-locator-drawer/store-locator-drawer.min.js";import{N as h,D as d,k as r,B as c}from"../assets/no-shadow-element-DZc32M1D.js";import{n as y}from"../assets/property-CrS1c6lI.js";import{m as s,w as V,i as k}from"../assets/mealz-sdk-CQtAGQGQ.js";import"../recipe-details/recipe-details.min.js";import"../store-locator/store-locator.min.js";import"../planner/planner-catalog/planner-catalog.min.js";import"../replace-item/replace-item.min.js";import"../replace-item-planner/replace-item-planner.min.js";import"../history-drawer/history-drawer.min.js";import{G as P,g}from"../supplier-selector/supplier-selector.min.js";import{o as R,l as z}from"../catalog/basket-preview/basket-preview.min.js";import"../preferences/preferences.min.js";import{m as b}from"../assets/merge-rdVI6Z3B.js";import{m as n}from"../assets/map-DdvZijlE.js";import{E as _}from"../assets/empty--gMS1asf.js";import"../assets/unsafe-html-DTarpZaV.js";import"../assets/skipWhile-BrGaejAE.js";import"../assets/OperatorSubscriber-BF1r9b3N.js";import"../assets/switchMap-C79NTzdm.js";import"../assets/innerFrom-BZ8nxpLv.js";import"../assets/filter-Dq4X88HC.js";import"../recipe-pricing/recipe-pricing.min.js";import"../assets/viewport-listener-073Dyp25.js";import"../assets/debounceTime-D6W3esj0.js";import"../assets/async-Buq9Zuro.js";import"../assets/take-B0yyxfMB.js";import"../assets/price-Bfy_G-uC.js";import"../assets/singleton-COF3iBbF.js";import"../assets/capitalize-DUAqYmp4.js";import"../counter/counter.min.js";import"../assets/product-card-CcfAgVi3.js";import"../price/price.min.js";import"../assets/promotion-badge-BusnHgIb.js";import"../assets/guestObserver-CSQi-6i9.js";import"../assets/delay-CUcLbxeL.js";import"../assets/mergeMap-CObP_yRz.js";import"../assets/executeSchedule-CEDvgTzM.js";import"../assets/timer-CGijW-Af.js";import"../assets/isScheduler-B3orCs5Q.js";import"../assets/isDate-BwHtzZM4.js";import"../assets/accordion-Ds4UMuL5.js";import"../store-indicator/store-indicator.min.js";import"../assets/state-1qy1JPQz.js";import"../assets/query-BApjzB0v.js";import"../last-order-badge/last-order-badge.min.js";import"../order-again/order-again.min.js";import"../like-button/like-button.min.js";import"../last-order-modal/last-order-modal.min.js";import"../planner/planner-onboarding/planner-onboarding.min.js";import"../onboarding/onboarding.min.js";import"../onboarding/events.min.js";import"../onboarding/analytics/onboarding-analytics.min.js";import"../assets/responsive-C7Qf71r3.js";import"../planner/helpers/planner-onboarding-storage.min.js";import"../assets/tap-D0fB7oij.js";import"../assets/combineLatest-CRVESsJM.js";import"../assets/from-BxJrdzJs.js";import"../assets/mapOneOrManyArgs-BpqqmasF.js";import"../assets/args-DPeCFqiB.js";import"../catalog/catalog-load-more.min.js";import"../assets/http-B0u4sOhM.js";import"../replace-item/replace-item-card/replace-item-card.min.js";import"../assets/price-utils-BRFZa-3D.js";import"../assets/distinctUntilChanged-FtASLz6t.js";import"../replace-item-planner/replace-item-card-planner/replace-item-card-planner.min.js";import"../assets/of-R1iMbYYX.js";import"../slider-tabs/slider-tabs.min.js";import"../modal/modal.min.js";import"../assets/mergeAll-BJfNWPb7.js";var C=Object.defineProperty,D=(l,e,i,o)=>{for(var t=void 0,a=l.length-1,p;a>=0;a--)(p=l[a])&&(t=p(e,i,t)||t);return t&&C(e,i,t),t};class S extends h{constructor(){super(),this.styleURL=new URL("./recipe-details/sponsor-block/sponsor-block.css",this.getBaseURL())}render(){var w,v,$;if(!this.sponsorBlock)return d;const{pictureUrl:e,content:i,backgroundColor:o="#FFFFFF",fontSize:t=16,fontColor:a="#000000"}=this.sponsorBlock,p=($=(v=(w=this.sponsorBlock.relationships)==null?void 0:w["sponsor-block-type"])==null?void 0:v.data)==null?void 0:$.name;if(!p)return r``;const u=p.toLowerCase(),m=`background-color: ${o}; font-size: ${t}px; color: ${a};`;switch(p){case"TEXT":case"SMALL_TEXT":case"TITLE":case"SMALL_TITLE":return r`
2
+ <div class="sponsor-text-blocks sponsor-${u}-block" style="background-color: ${o};">
3
+ <span class="sponsor-${u}-block__text" style="font-size: ${p.includes("TITLE")?32:16}px; color: ${a};">
4
4
  ${i}
5
5
  </span>
6
6
  </div>`;case"LOGO":case"PICTURE":case"SMALL_PICTURE":return r`
7
- <div class="sponsor-${m}-block" style="background-color: ${o};">
8
- <img class="sponsor-${m}-block__picture sponsor-img" src="${e}" />
7
+ <div class="sponsor-${u}-block" style="background-color: ${o};">
8
+ <img class="sponsor-${u}-block__picture sponsor-img" src="${e}" />
9
9
  </div>`;case"IMAGE_WITH_TEXT":return r`
10
10
  <div class="sponsor-image-with-text-block" style="background-image: url(${e});">
11
- <span class="sponsor-image-with-text-block__text" style="${u}">
11
+ <span class="sponsor-image-with-text-block__text" style="${m}">
12
12
  ${i}
13
13
  </span>
14
14
  </div>`;case"IMAGE_AND_TEXT":return r`
15
15
  <div class="sponsor-image-and-text-block">
16
16
  <img class="sponsor-image-and-text-block__image" src="${e}">
17
- <span class="sponsor-image-and-text-block__text" style="${u}">
17
+ <span class="sponsor-image-and-text-block__text" style="${m}">
18
18
  ${i}
19
19
  </span>
20
20
  </div>`;case"TEXT_AND_IMAGE":return r`
21
21
  <div class="sponsor-text-and-image-block">
22
- <span class="sponsor-text-and-image-block__text" style="${u}">
22
+ <span class="sponsor-text-and-image-block__text" style="${m}">
23
23
  ${i}
24
24
  </span>
25
25
  <img class="sponsor-text-and-image-block__image" src="${e}">
26
- </div>`;default:return d}}}D([y()],f.prototype,"sponsorBlock");customElements.get("mealz-sponsor-block")||customElements.define("mealz-sponsor-storytelling",f);class E extends h{constructor(){super(),this.sponsorBlocks=[],this.subscriptions=[],this.styleURL=new URL("./recipe-details/recipe-addon/recipe-addon.css",this.getBaseURL())}connectedCallback(){super.connectedCallback(),this.listenToCloseEvent(),this.subscriptions.push(t.recipes.displayedRecipe$.subscribe(e=>{e&&(this.recipe=e.recipe,this.getSponsorBlocks())}))}disconnectedCallback(){super.disconnectedCallback(),this.subscriptions.forEach(e=>e.unsubscribe())}getSponsorBlocks(){var i,o,s;const e=(s=(o=(i=this.recipe)==null?void 0:i.relationships)==null?void 0:o.sponsors)==null?void 0:s.data[0];e&&this.subscriptions.push(t.sponsor.getSponsorBlocks(e.id).subscribe(a=>{a&&(this.sponsorBlocks=a,this.requestUpdate())}))}render(){var e;return r`
26
+ </div>`;default:return d}}}D([y()],S.prototype,"sponsorBlock");customElements.get("mealz-sponsor-block")||customElements.define("mealz-sponsor-storytelling",S);class B extends h{constructor(){super(),this.sponsorBlocks=[],this.subscriptions=[],this.styleURL=new URL("./recipe-details/recipe-addon/recipe-addon.css",this.getBaseURL())}connectedCallback(){super.connectedCallback(),this.listenToCloseEvent(),this.subscriptions.push(s.recipes.displayedRecipe$.subscribe(e=>{e&&(this.recipe=e.recipe,this.getSponsorBlocks())}))}disconnectedCallback(){super.disconnectedCallback(),this.subscriptions.forEach(e=>e.unsubscribe())}getSponsorBlocks(){var i,o,t;const e=(t=(o=(i=this.recipe)==null?void 0:i.relationships)==null?void 0:o.sponsors)==null?void 0:t.data[0];e&&this.subscriptions.push(s.sponsor.getSponsorBlocks(e.id).subscribe(a=>{a&&(this.sponsorBlocks=a,this.requestUpdate())}))}render(){var e;return r`
27
27
  <div class="mealz-recipe-addon">
28
28
  <div class="mealz-recipe-addon__header">
29
29
  <button class="mealz-recipe-addon__header-back-button mealz-ds-button ghost" @click="${this.closeRecipeAddon}">
@@ -46,8 +46,8 @@ import"../drawer/drawer.min.js";import"../store-locator-drawer/store-locator-dra
46
46
  ${this.sponsorBlocks.map(o=>r`
47
47
  <mealz-sponsor-block .sponsorBlock=${o}></mealz-sponsor-block>
48
48
  `)}
49
- `}listenToCloseEvent(){document.querySelector("mealz-drawer").addEventListener("drawerClosed",()=>{this.closeRecipeAddon()})}closeRecipeAddon(){const e=document.querySelector("mealz-drawer-view-swapper");e&&e.displayRecipeAddon$.next(!1)}}customElements.get("mealz-recipe-addon")||customElements.define("mealz-recipe-addon",E);var A=Object.defineProperty,B=(l,e,i,o)=>{for(var s=void 0,a=l.length-1,n;a>=0;a--)(n=l[a])&&(s=n(e,i,s)||s);return s&&A(e,i,s),s};class V extends h{constructor(){super(),this.displayBasketPreview=!1,this.displayProductAddition=!1,this.displayReplaceProduct=!1,this.displayPreferences$=new p(!1),this.displayStoreLocator$=new p(!1),this.displaySupplierSelector$=new p(!1),this.displayRecipeAddon$=new p(!1),this.displayPlannerCatalog$=new p(!1),this.displayHistoryDrawer$=new p(null),this.displayBasketDrawer$=new p(null),this.currentView$=new p(void 0),this.activeViewNames$=new p([]),this.subscriptions=[],this.recipePartnerLabel=S,this.viewHistory=[],this.scrollPositions=new Map,this.viewSelector=[{isSupplierSelectorVisible:()=>this.displaySupplierSelector$.value},{isStoreLocatorVisible:()=>this.displayStoreLocator$.value},{isRecipeAddonVisible:()=>this.displayRecipeAddon$.value},{isReplaceItemVisible:()=>!!this.displayReplaceItem},{isReplaceItemPlannerVisible:()=>!!this.displayReplaceItemPlanner},{isRecipeDetailsVisible:()=>!!this.displayedRecipeDetails},{isBasketPreviewVisible:()=>this.displayBasketPreview},{isProductAdditionVisible:()=>this.displayProductAddition},{isReplaceProductVisible:()=>this.displayReplaceProduct},{isPlannerCatalogVisible:()=>this.displayPlannerCatalog$.value},{isHistoryDrawerVisible:()=>!!this.displayHistoryDrawer$.value},{isBasketDrawerVisible:()=>!!this.displayBasketDrawer$.value},{isPreferencesVisible:()=>this.displayPreferences$.value}],this.styleURL=new URL("./drawer-view-swapper/drawer-view-swapper.css",this.getBaseURL()),R(),z(this.currentView$)}connectedCallback(){super.connectedCallback(),this.waitForSDKAndSetup()}waitForSDKAndSetup(){try{g().then(()=>{this.setupSubscriptions()})}catch(e){console.error("Error waiting for MealzInternal SDK:",e)}}setupSubscriptions(){this.subscriptions.push(b(t.pos.currentPos().pipe(c(e=>{this.pos=e,this.noSupplier=t.supplier.isNoSupplier()})),t.supplier.noSupplier$??_,t.recipes.displayedRecipe$.pipe(c(e=>{this.displayedRecipeDetails=e,this.noSupplier&&!this.pos&&e&&t.noSupplier.displaySupplierSelector$.next(!0)})),t.noSupplier.displaySupplierSelector$.pipe(c(e=>{this.displaySupplierSelector$.next(e)})),b(t.replaceItem.basketEntryToReplace$.pipe(c(e=>e||{displayReplaceItem:void 0})),t.replaceItem.replaceProductFromPreviewOpen$.pipe(c(e=>e?{basketEntry:e}:{displayReplaceItem:void 0})),t.replaceItem.additionModalOpen$.pipe(c(e=>e?{addProductMode:!0}:{displayReplaceItem:void 0}))).pipe(c(e=>{this.displayReplaceItem="displayReplaceItem"in e?void 0:e})),t.basket.basketPreviewState$.pipe(c(({isOpen:e})=>this.displayBasketPreview=e)),t.planner.itemToReplace$.pipe(c(e=>this.displayReplaceItemPlanner=e)),this.displayRecipeAddon$,this.displayStoreLocator$,this.displayPlannerCatalog$,this.displayHistoryDrawer$,this.displayBasketDrawer$,this.displayPreferences$).subscribe(()=>{this.recipePartnerLabel=P(),this.updateActiveViews(),this.findView(),this.requestUpdate()}))}disconnectedCallback(){super.disconnectedCallback(),this.subscriptions.forEach(e=>e.unsubscribe())}findView(){const e=this.getNextViewName();e!==this.currentView$.value?(this.saveCurrentScrollPosition(),this.currentView$.next(e),this.requestUpdate(),e?this.restoreScrollPosition(e):this.resetScrollPositions()):this.currentView$.next(e)}getDrawerContentContainer(){return this.querySelector(".mealz-drawer__content-container")}getNextViewName(){return this.computeActiveViewNames()[0]}computeActiveViewNames(){const e=[];for(const i of this.viewSelector){const[o,s]=Object.entries(i)[0];s()&&e.push(o)}return e}getActiveViewNames(){return[...this.activeViewNames$.value]}updateActiveViews(){const e=this.computeActiveViewNames(),i=this.activeViewNames$.value;(e.length!==i.length||e.some((s,a)=>s!==i[a]))&&(this.activeViewNames$.next(e),this.dispatchEvent(new CustomEvent("mealz-active-views-changed",{detail:{activeViews:e},bubbles:!0,composed:!0})))}saveCurrentScrollPosition(){if(this.currentView$.value){const e=this.getDrawerContentContainer();e&&this.scrollPositions.set(this.currentView$.value,e.scrollTop)}}restoreScrollPosition(e){requestAnimationFrame(()=>{const i=this.getDrawerContentContainer();i&&this.scrollPositions.has(e)&&(i.scrollTop=this.scrollPositions.get(e)??0)})}resetScrollPositions(){this.scrollPositions.clear()}addToHistory(e){this.viewHistory[this.viewHistory.length-1]!==e&&this.viewHistory.push(e)}render(){return r`
50
- <div class="mealz-drawer-view-swapper">${this.drawerIsOpen()?this.displayDrawer():d}</div>`}drawerIsOpen(){return this.currentView$.value!==void 0}closeDrawer(){this.displayStoreLocator$.next(!1),this.displayPlannerCatalog$.next(!1),this.displayPreferences$.next(!1),this.displayBasketDrawer$.next(null),k()&&(t.recipes.displayedRecipe$.next(null),t.basket.basketPreviewState$.next({isOpen:!1}),t.noSupplier&&t.noSupplier.displaySupplierSelector$&&t.noSupplier.displaySupplierSelector$.next(!1),t.productAddition&&typeof t.productAddition.close=="function"&&t.productAddition.close())}displayDrawer(){return this.drawerIsOpen()?r`
49
+ `}listenToCloseEvent(){document.querySelector("mealz-drawer").addEventListener("drawerClosed",()=>{this.closeRecipeAddon()})}closeRecipeAddon(){const e=document.querySelector("mealz-drawer-view-swapper");e&&e.displayRecipeAddon$.next(!1)}}customElements.get("mealz-recipe-addon")||customElements.define("mealz-recipe-addon",B);var E=Object.defineProperty,A=(l,e,i,o)=>{for(var t=void 0,a=l.length-1,p;a>=0;a--)(p=l[a])&&(t=p(e,i,t)||t);return t&&E(e,i,t),t};class f extends h{constructor(){super(),this.displayBasketPreview=!1,this.displayProductAddition=!1,this.displayReplaceProduct=!1,this.displayPreferences$=new c(!1),this.displayStoreLocator$=new c(!1),this.displaySupplierSelector$=new c(!1),this.displayRecipeAddon$=new c(!1),this.displayPlannerCatalog$=new c(!1),this.displayHistoryDrawer$=new c(null),this.displayBasketDrawer$=new c(null),this.currentView$=new c(void 0),this.activeViewNames$=new c([]),this.subscriptions=[],this.recipePartnerLabel=P,this.viewHistory=[],this.scrollPositions=new Map,this.viewSelector=[{isSupplierSelectorVisible:()=>this.displaySupplierSelector$.value},{isStoreLocatorVisible:()=>this.displayStoreLocator$.value},{isRecipeAddonVisible:()=>this.displayRecipeAddon$.value},{isReplaceItemVisible:()=>!!this.displayReplaceItem},{isReplaceItemPlannerVisible:()=>!!this.displayReplaceItemPlanner},{isRecipeDetailsVisible:()=>!!this.displayedRecipeDetails},{isBasketPreviewVisible:()=>this.displayBasketPreview},{isProductAdditionVisible:()=>this.displayProductAddition},{isReplaceProductVisible:()=>this.displayReplaceProduct},{isPlannerCatalogVisible:()=>this.displayPlannerCatalog$.value},{isHistoryDrawerVisible:()=>!!this.displayHistoryDrawer$.value},{isBasketDrawerVisible:()=>!!this.displayBasketDrawer$.value},{isPreferencesVisible:()=>this.displayPreferences$.value}],this.styleURL=new URL("./drawer-view-swapper/drawer-view-swapper.css",this.getBaseURL()),R(),z(this.currentView$)}connectedCallback(){super.connectedCallback(),this.waitForSDKAndSetup()}waitForSDKAndSetup(){try{V().then(()=>{this.setupSubscriptions()})}catch(e){console.error("Error waiting for MealzInternal SDK:",e)}}setupSubscriptions(){this.subscriptions.push(b(s.pos.currentPos().pipe(n(e=>{this.pos=e,this.noSupplier=s.supplier.isNoSupplier(),this.openSupplierSelectorWhenBasketPreviewNeedsPos()})),(s.supplier.noSupplier$??_).pipe(n(e=>{this.noSupplier=e,this.openSupplierSelectorWhenBasketPreviewNeedsPos()})),s.recipes.displayedRecipe$.pipe(n(e=>{this.displayedRecipeDetails=e,this.noSupplier&&!this.pos&&e&&s.noSupplier.displaySupplierSelector$.next(!0)})),s.noSupplier.displaySupplierSelector$.pipe(n(e=>{this.displaySupplierSelector$.next(e)})),b(s.replaceItem.basketEntryToReplace$.pipe(n(e=>e||{displayReplaceItem:void 0})),s.replaceItem.replaceProductFromPreviewOpen$.pipe(n(e=>e?{basketEntry:e}:{displayReplaceItem:void 0})),s.replaceItem.additionModalOpen$.pipe(n(e=>e?{addProductMode:!0}:{displayReplaceItem:void 0}))).pipe(n(e=>{this.displayReplaceItem="displayReplaceItem"in e?void 0:e})),s.basket.basketPreviewState$.pipe(n(({isOpen:e})=>{this.displayBasketPreview=e,this.openSupplierSelectorWhenBasketPreviewNeedsPos()})),s.planner.itemToReplace$.pipe(n(e=>this.displayReplaceItemPlanner=e)),this.displayRecipeAddon$,this.displayStoreLocator$,this.displayPlannerCatalog$,this.displayHistoryDrawer$,this.displayBasketDrawer$,this.displayPreferences$).subscribe(()=>{this.recipePartnerLabel=g(),this.updateActiveViews(),this.findView(),this.requestUpdate()}))}openSupplierSelectorWhenBasketPreviewNeedsPos(){var e;this.displayBasketPreview&&this.noSupplier&&!this.pos&&((e=s.noSupplier)!=null&&e.displaySupplierSelector$)&&s.noSupplier.displaySupplierSelector$.next(!0)}disconnectedCallback(){super.disconnectedCallback(),this.subscriptions.forEach(e=>e.unsubscribe())}findView(){const e=this.getNextViewName();e!==this.currentView$.value?(this.saveCurrentScrollPosition(),this.currentView$.next(e),this.requestUpdate(),e?this.restoreScrollPosition(e):this.resetScrollPositions()):this.currentView$.next(e)}getDrawerContentContainer(){return this.querySelector(".mealz-drawer__content-container")}getNextViewName(){return this.computeActiveViewNames()[0]}computeActiveViewNames(){const e=[];for(const i of this.viewSelector){const[o,t]=Object.entries(i)[0];t()&&e.push(o)}return e}getActiveViewNames(){return[...this.activeViewNames$.value]}updateActiveViews(){const e=this.computeActiveViewNames(),i=this.activeViewNames$.value;(e.length!==i.length||e.some((t,a)=>t!==i[a]))&&(this.activeViewNames$.next(e),this.dispatchEvent(new CustomEvent("mealz-active-views-changed",{detail:{activeViews:e},bubbles:!0,composed:!0})))}saveCurrentScrollPosition(){if(this.currentView$.value){const e=this.getDrawerContentContainer();e&&this.scrollPositions.set(this.currentView$.value,e.scrollTop)}}restoreScrollPosition(e){requestAnimationFrame(()=>{const i=this.getDrawerContentContainer();i&&this.scrollPositions.has(e)&&(i.scrollTop=this.scrollPositions.get(e)??0)})}resetScrollPositions(){this.scrollPositions.clear()}addToHistory(e){this.viewHistory[this.viewHistory.length-1]!==e&&this.viewHistory.push(e)}render(){return r`
50
+ <div class="mealz-drawer-view-swapper">${this.drawerIsOpen()?this.displayDrawer():d}</div>`}drawerIsOpen(){return this.currentView$.value!==void 0}closeDrawer(){this.displayStoreLocator$.next(!1),this.displayPlannerCatalog$.next(!1),this.displayPreferences$.next(!1),this.displayBasketDrawer$.next(null),k()&&(s.recipes.displayedRecipe$.next(null),s.basket.basketPreviewState$.next({isOpen:!1}),s.noSupplier&&s.noSupplier.displaySupplierSelector$&&s.noSupplier.displaySupplierSelector$.next(!1),s.productAddition&&typeof s.productAddition.close=="function"&&s.productAddition.close())}displayDrawer(){return this.drawerIsOpen()?r`
51
51
  <mealz-drawer @drawerClosed=${this.closeDrawer}
52
52
  .titleSlot=
53
53
  ${this.currentView$.value==="isSupplierSelectorVisible"?r`<span>Mes courses avec ${this.recipePartnerLabel}</span>`:this.currentView$.value==="isBasketPreviewVisible"?r`<span>Mes repas</span>`:this.currentView$.value==="isHistoryDrawerVisible"?r`<span>Commande du ${this.displayHistoryDrawer$.value.orderDate}</span>`:this.currentView$.value==="isBasketDrawerVisible"?r`<span>${this.displayBasketDrawer$.value.title}</span>`:this.currentView$.value==="isPlannerCatalogVisible"?r`<span>Ajouter une recette</span>`:d}
@@ -94,4 +94,4 @@ import"../drawer/drawer.min.js";import"../store-locator-drawer/store-locator-dra
94
94
  </mealz-history-drawer>
95
95
  `}
96
96
  </mealz-drawer>
97
- `:r``}}B([y({type:Boolean})],V.prototype,"displayBasketPreview");customElements.get("mealz-drawer-view-swapper")||customElements.define("mealz-drawer-view-swapper",V);if(!document.querySelector("mealz-drawer-view-swapper")){const l=document.createElement("mealz-drawer-view-swapper");document.body.appendChild(l)}
97
+ `:r``}}A([y({type:Boolean})],f.prototype,"displayBasketPreview");customElements.get("mealz-drawer-view-swapper")||customElements.define("mealz-drawer-view-swapper",f);if(!document.querySelector("mealz-drawer-view-swapper")){const l=document.createElement("mealz-drawer-view-swapper");document.body.appendChild(l)}
@@ -11,4 +11,4 @@ import"../store-locator/store-locator.min.js";import{N as l,D as c,k as p}from".
11
11
  <span class="mealz-store-indicator__swap-pos-label mealz-ds-text size-s weight-l">Changer</span>
12
12
  </button>
13
13
  </div>
14
- `:c}setCurrentPosLabel(){this.subscriptions.push(o.pos.currentPos().subscribe(e=>{e?this.currentPosLabel=e.relationships.supplier.data.attributes.name+" - "+e.attributes.name:this.currentPosLabel=" - ",this.requestUpdate()}))}openDrawer(){const e=document.querySelector("mealz-drawer-view-swapper");e&&(e.displayStoreLocator$.next(!0),this.sendLocatorDisplayEvent())}sendLocatorDisplayEvent(){o.analytics.sendEvent("locator.display",this.analyticsPath,{})}}u([d({type:String})],n.prototype,"analyticsPath");customElements.get("mealz-store-indicator")||customElements.define("mealz-store-indicator",n);
14
+ `:c}setCurrentPosLabel(){this.subscriptions.push(o.pos.currentPos().subscribe(e=>{e?this.currentPosLabel=e.relationships.supplier.data.attributes.name+" - "+e.attributes.name:this.currentPosLabel="Aucun magasin sélectionné",this.requestUpdate()}))}openDrawer(){const e=document.querySelector("mealz-drawer-view-swapper");e&&(e.displayStoreLocator$.next(!0),this.sendLocatorDisplayEvent())}sendLocatorDisplayEvent(){o.analytics.sendEvent("locator.display",this.analyticsPath,{})}}u([d({type:String})],n.prototype,"analyticsPath");customElements.get("mealz-store-indicator")||customElements.define("mealz-store-indicator",n);
@@ -1,9 +1,9 @@
1
- import{N as p,k as a}from"../assets/no-shadow-element-DZc32M1D.js";import{g as o,w as c}from"../assets/mealz-sdk-CQtAGQGQ.js";import{f as u}from"../assets/filter-Dq4X88HC.js";import"../assets/OperatorSubscriber-BF1r9b3N.js";const n="SITE DE REÇETTES NON RECONNU";function d(i){if(i==null||typeof i!="string")return n;const e=i.trim().toLowerCase();return e==="marmiton"?"Marmiton":e==="cuisineaz"?"CuisineAZ":e==="cuisineactuelle"?"Cuisine Actuelle":n}function m(){var i;try{const e=o(),s=(i=e==null?void 0:e.supplier)==null?void 0:i.getToken;if(typeof s!="function")return null;const t=s();if(!t||typeof t!="string")return null;const r=JSON.parse(atob(t)),l=r==null?void 0:r.origin;return typeof l=="string"&&l.length>0?l:null}catch{return null}}function g(){return d(m())}class h extends p{constructor(){super(),this.onboardingSteps=[{title:"Choisissez une recette",image:"https://storage.googleapis.com/assets.miam.tech/generic/images/9.1/onboardingRecipe.png"},{title:"Sélectionnez votre magasin",image:"https://storage.googleapis.com/assets.miam.tech/generic/images/9.1/onboardingDrive.png"},{title:"Commandez vos ingrédients",image:"https://storage.googleapis.com/assets.miam.tech/generic/images/9.1/onboardingIngredients.png"}],this.subscriptions=[],this.supplierList=[],this.recipePartnerLabel=n,this.analyticsPath="/supplier-selector",this.styleURL=new URL("./supplier-selector/supplier-selector.css",this.getBaseURL())}connectedCallback(){super.connectedCallback(),c().then(()=>{var t;this.syncRecipePartnerLabel();const e=o(),s=(t=e==null?void 0:e.supplier)==null?void 0:t.noSupplier$;s&&typeof s.subscribe=="function"&&this.subscriptions.push(s.subscribe(()=>{this.syncRecipePartnerLabel(),this.requestUpdate()})),this.loadAvailableSuppliers()}).catch(e=>{console.warn("[MealzSupplierSelector] MealzInternal SDK not available, suppliers will not be loaded.",e)}),this.listenToDrawerViewSwapper(),this.listenToCloseEvent()}disconnectedCallback(){super.disconnectedCallback(),this.subscriptions.forEach(e=>e.unsubscribe())}syncRecipePartnerLabel(){this.recipePartnerLabel=g()}loadAvailableSuppliers(){var r;const e=window.mealz,s=(r=e==null?void 0:e.supplier)==null?void 0:r.getAffiliateSuppliers;if(!s){console.warn("[MealzSupplierSelector] mealz.supplier.getAffiliateSuppliers is not available.");return}const t=s();if(!t||typeof t.subscribe!="function"){console.warn("[MealzSupplierSelector] getAffiliateSuppliers did not return a subscribable observable.");return}this.subscriptions.push(t.subscribe(l=>{this.supplierList=l,this.requestUpdate()}))}selectSupplier(e){localStorage.setItem("_miam/selectedSupplierId",e.id),this.sendSelectSupplierEvent(e);const s=this.closest("mealz-drawer-view-swapper"),t=document.querySelector("mealz-store-locator");s&&(s.displayStoreLocator$.next(!0),window.mealzInternal.noSupplier.displaySupplierSelector$.next(!1),t&&(t.show=!0))}listenToDrawerViewSwapper(){const e=document.querySelector("mealz-drawer-view-swapper");e&&this.subscriptions.push(e.displaySupplierSelector$.pipe(u(s=>s)).subscribe(()=>{this.syncRecipePartnerLabel(),this.pageview()}))}listenToCloseEvent(){const e=document.querySelector("mealz-drawer");e&&e.addEventListener("drawerClosed",()=>{this.sendCloseEvent()})}render(){return a`
1
+ import{N as c,k as l}from"../assets/no-shadow-element-DZc32M1D.js";import{g as o,w as u}from"../assets/mealz-sdk-CQtAGQGQ.js";import{f as d}from"../assets/filter-Dq4X88HC.js";import"../assets/OperatorSubscriber-BF1r9b3N.js";const n="SITE DE REÇETTES NON RECONNU";function m(i){if(i==null||typeof i!="string")return n;const e=i.trim().toLowerCase();return e==="marmiton"?"Marmiton":e==="cuisineaz"?"CuisineAZ":e==="cuisineactuelle"?"Cuisine Actuelle":n}const g="coursesu";function p(){var i;try{const e=o(),t=(i=e==null?void 0:e.supplier)==null?void 0:i.getToken;if(typeof t!="function")return null;const s=t();if(!s||typeof s!="string")return null;const r=JSON.parse(atob(s)),a=r==null?void 0:r.origin;return typeof a=="string"&&a.length>0?a:null}catch{return null}}function h(){return m(p())}function b(i,e){return(e==null?void 0:e.trim().toLowerCase())!=="cuisineaz"?i:i.filter(t=>t.attributes.name.trim().toLowerCase()===g)}class S extends c{constructor(){super(),this.onboardingSteps=[{title:"Choisissez une recette",image:"https://storage.googleapis.com/assets.miam.tech/generic/images/9.1/onboardingRecipe.png"},{title:"Sélectionnez votre magasin",image:"https://storage.googleapis.com/assets.miam.tech/generic/images/9.1/onboardingDrive.png"},{title:"Commandez vos ingrédients",image:"https://storage.googleapis.com/assets.miam.tech/generic/images/9.1/onboardingIngredients.png"}],this.subscriptions=[],this.supplierList=[],this.recipePartnerLabel=n,this.analyticsPath="/supplier-selector",this.styleURL=new URL("./supplier-selector/supplier-selector.css",this.getBaseURL())}connectedCallback(){super.connectedCallback(),u().then(()=>{var s;this.syncRecipePartnerLabel();const e=o(),t=(s=e==null?void 0:e.supplier)==null?void 0:s.noSupplier$;t&&typeof t.subscribe=="function"&&this.subscriptions.push(t.subscribe(()=>{this.syncRecipePartnerLabel(),this.requestUpdate()})),this.loadAvailableSuppliers()}).catch(e=>{console.warn("[MealzSupplierSelector] MealzInternal SDK not available, suppliers will not be loaded.",e)}),this.listenToDrawerViewSwapper(),this.listenToCloseEvent()}disconnectedCallback(){super.disconnectedCallback(),this.subscriptions.forEach(e=>e.unsubscribe())}syncRecipePartnerLabel(){this.recipePartnerLabel=h()}loadAvailableSuppliers(){var r;const e=window.mealz,t=(r=e==null?void 0:e.supplier)==null?void 0:r.getAffiliateSuppliers;if(!t){console.warn("[MealzSupplierSelector] mealz.supplier.getAffiliateSuppliers is not available.");return}const s=t();if(!s||typeof s.subscribe!="function"){console.warn("[MealzSupplierSelector] getAffiliateSuppliers did not return a subscribable observable.");return}this.subscriptions.push(s.subscribe(a=>{this.supplierList=a,this.requestUpdate()}))}selectSupplier(e){localStorage.setItem("_miam/selectedSupplierId",e.id),this.sendSelectSupplierEvent(e);const t=this.closest("mealz-drawer-view-swapper"),s=document.querySelector("mealz-store-locator");t&&(t.displayStoreLocator$.next(!0),window.mealzInternal.noSupplier.displaySupplierSelector$.next(!1),s&&(s.show=!0))}listenToDrawerViewSwapper(){const e=document.querySelector("mealz-drawer-view-swapper");e&&this.subscriptions.push(e.displaySupplierSelector$.pipe(d(t=>t)).subscribe(()=>{this.syncRecipePartnerLabel(),this.pageview()}))}listenToCloseEvent(){const e=document.querySelector("mealz-drawer");e&&e.addEventListener("drawerClosed",()=>{this.sendCloseEvent()})}render(){return l`
2
2
  <div class="mealz-supplier-selector">
3
3
  ${this.renderOnboarding()}
4
4
  ${this.renderSuppliers()}
5
5
  </div>
6
- `}renderOnboarding(){return a`
6
+ `}renderOnboarding(){return l`
7
7
  <div class="mealz-supplier-selector__onboarding-container">
8
8
  <h3 class="mealz-supplier-selector__onboarding-title mealz-ds-text weight-xl">
9
9
  ✨ Nouveau ! Faites vos courses en un clic avec ${this.recipePartnerLabel}.
@@ -13,11 +13,11 @@ import{N as p,k as a}from"../assets/no-shadow-element-DZc32M1D.js";import{g as o
13
13
  Vos ingrédients sont ajoutés automatiquement dans votre panier, prêt à être commandés.
14
14
  </span>
15
15
  <div class="mealz-supplier-selector__onboarding-steps">
16
- ${this.onboardingSteps.map((e,s)=>a`
16
+ ${this.onboardingSteps.map((e,t)=>l`
17
17
  <div class="mealz-supplier-selector__card">
18
18
  <div class="mealz-supplier-selector__instructions">
19
19
  <div class="mealz-supplier-selector__step-counter">
20
- <span class="mealz-ds-text weight-l">${s+1}</span>
20
+ <span class="mealz-ds-text weight-l">${t+1}</span>
21
21
  </div>
22
22
  <span class="mealz-supplier-selector__onboarding-step-text mealz-ds-text weight-xl">${e.title}</span>
23
23
  </div>
@@ -27,27 +27,27 @@ import{N as p,k as a}from"../assets/no-shadow-element-DZc32M1D.js";import{g as o
27
27
  `)}
28
28
  </div>
29
29
  </div>
30
- `}renderSuppliers(){return a`
30
+ `}getVisibleSuppliers(){return b(this.supplierList,p())}renderSuppliers(){return l`
31
31
  <div class="mealz-supplier-selector__suppliers-container">
32
32
  <h3 class="mealz-supplier-selector__onboarding-title mealz-ds-text weight-xl">
33
33
  Pour commencer, sélectionnez votre enseigne.
34
34
  </h3>
35
35
  <div class="mealz-supplier-selector__supplier-list">
36
- ${this.supplierList.map(e=>a`
37
- <button class="mealz-supplier-selector__supplier-button-card"
36
+ ${this.getVisibleSuppliers().map(e=>l`
37
+ <button class="mealz-supplier-selector__supplier-button-card ${e.attributes.name.toLowerCase()}-card"
38
38
  @click="${()=>this.selectSupplier(e)}">
39
39
  <img
40
40
  class="mealz-supplier-selector__supplier-bg"
41
41
  src="https://storage.googleapis.com/assets.miam.tech/generic/images/9.1/retailer-bg-${e.id}.png"
42
- alt="${e.name} background"
42
+ alt="${e.attributes.name} background"
43
43
  aria-hidden="true">
44
44
  <img
45
45
  class="mealz-supplier-selector__supplier-logo"
46
46
  src="https://storage.googleapis.com/assets.miam.tech/generic/images/9.1/retailer-${e.id}.svg"
47
- alt="${e.name}"
47
+ alt="${e.attributes.name}"
48
48
  aria-hidden="true">
49
49
  </button>
50
50
  `)}
51
51
  </div>
52
52
  </div>
53
- `}pageview(){window.mealzInternal.analytics.sendEvent("pageview",this.analyticsPath,{})}sendSelectSupplierEvent(e){window.mealzInternal.analytics.sendEvent("supplier-selector.select",this.analyticsPath,{supplier_id:e.id})}sendCloseEvent(){window.mealzInternal.analytics.sendEvent("supplier-selector.close",this.analyticsPath,{})}}customElements.get("mealz-supplier-selector")||customElements.define("mealz-supplier-selector",h);export{n as G,g};
53
+ `}pageview(){window.mealzInternal.analytics.sendEvent("pageview",this.analyticsPath,{})}sendSelectSupplierEvent(e){window.mealzInternal.analytics.sendEvent("supplier-selector.select",this.analyticsPath,{supplier_id:e.id})}sendCloseEvent(){window.mealzInternal.analytics.sendEvent("supplier-selector.close",this.analyticsPath,{})}}customElements.get("mealz-supplier-selector")||customElements.define("mealz-supplier-selector",S);export{n as G,h as g};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mealz-components",
3
3
  "type": "module",
4
- "version": "2.8.3",
4
+ "version": "2.9.0",
5
5
  "main": "./dist/mealz-components.js",
6
6
  "module": "./dist/mealz-components.js",
7
7
  "scripts": {