mealz-components 0.7.0 → 0.7.1
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/{lit-element-BKlYWoBt.js → lit-element-S5SYC_ST.js} +1 -1
- package/dist/assets/no-shadow-element-CB4i9vr8.js +1 -0
- package/dist/catalog/catalog-breadcrumb/catalog-breadcrumb.min.js +1 -1
- 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-home/catalog-home.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/like-button/like-button.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-pricing/recipe-pricing.min.js +1 -1
- package/dist/store-locator/store-locator.min.js +49 -9
- package/package.json +1 -1
- package/dist/assets/no-shadow-element-BdZPYRaG.js +0 -1
|
@@ -20,4 +20,4 @@
|
|
|
20
20
|
* @license
|
|
21
21
|
* Copyright 2017 Google LLC
|
|
22
22
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
23
|
-
*/class H extends y{constructor(){super(...arguments),this.renderOptions={host:this},this.o=void 0}createRenderRoot(){var e;const t=super.createRenderRoot();return(e=this.renderOptions).renderBefore??(e.renderBefore=t.firstChild),t}update(t){const e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this.o=bt(e,this.renderRoot,this.renderOptions)}connectedCallback(){var t;super.connectedCallback(),(t=this.o)==null||t.setConnected(!0)}disconnectedCallback(){var t;super.disconnectedCallback(),(t=this.o)==null||t.setConnected(!1)}render(){return v}}var X;H._$litElement$=!0,H.finalized=!0,(X=globalThis.litElementHydrateSupport)==null||X.call(globalThis,{LitElement:H});const L=globalThis.litElementPolyfillSupport;L==null||L({LitElement:H});(globalThis.litElementVersions??(globalThis.litElementVersions=[])).push("4.1.0");export{et as f,H as h,Ct as i,Ut as k,wt as t,I as u};
|
|
23
|
+
*/class H extends y{constructor(){super(...arguments),this.renderOptions={host:this},this.o=void 0}createRenderRoot(){var e;const t=super.createRenderRoot();return(e=this.renderOptions).renderBefore??(e.renderBefore=t.firstChild),t}update(t){const e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this.o=bt(e,this.renderRoot,this.renderOptions)}connectedCallback(){var t;super.connectedCallback(),(t=this.o)==null||t.setConnected(!0)}disconnectedCallback(){var t;super.disconnectedCallback(),(t=this.o)==null||t.setConnected(!1)}render(){return v}}var X;H._$litElement$=!0,H.finalized=!0,(X=globalThis.litElementHydrateSupport)==null||X.call(globalThis,{LitElement:H});const L=globalThis.litElementPolyfillSupport;L==null||L({LitElement:H});(globalThis.litElementVersions??(globalThis.litElementVersions=[])).push("4.1.0");export{d as D,et as f,H as h,Ct as i,Ut as k,wt as t,I as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{h as e}from"./lit-element-S5SYC_ST.js";class r extends e{createRenderRoot(){return this}}export{r as N};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as s}from"../../assets/lit-element-
|
|
1
|
+
import{t as s}from"../../assets/lit-element-S5SYC_ST.js";import{N as n}from"../../assets/no-shadow-element-CB4i9vr8.js";var b=Object.defineProperty,p=Object.getOwnPropertyDescriptor,u=(o,a,l,r)=>{for(var e=r>1?void 0:r?p(a,l):a,t=o.length-1,c;t>=0;t--)(c=o[t])&&(e=(r?c(a,l,e):c(e))||e);return r&&e&&b(a,l,e),e};let m=class extends n{connectedCallback(){super.connectedCallback()}render(){}};m=u([s("mealz-catalog-breadcrumb")],m);customElements.get("mealz-catalog-breadcrumb")||customElements.define("mealz-catalog-breadcrumb",m);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as k}from"../../assets/lit-element-
|
|
1
|
+
import{t as k}from"../../assets/lit-element-S5SYC_ST.js";import{N as D}from"../../assets/no-shadow-element-CB4i9vr8.js";import{_ as M,S as O,a as H,b as C,c as P,d as y,i as w,f as h,m as V,o as S,g as j,h as q,O as x,j as N}from"../../assets/mapOneOrManyArgs-BtDjRPOr.js";var U={now:function(){return Date.now()},delegate:void 0},F=function(e){M(n,e);function n(t,i){return e.call(this)||this}return n.prototype.schedule=function(t,i){return this},n}(O),_={setInterval:function(e,n){for(var t=[],i=2;i<arguments.length;i++)t[i-2]=arguments[i];return setInterval.apply(void 0,H([e,n],C(t)))},clearInterval:function(e){var n=_.delegate;return((n==null?void 0:n.clearInterval)||clearInterval)(e)},delegate:void 0},$=function(e){M(n,e);function n(t,i){var r=e.call(this,t,i)||this;return r.scheduler=t,r.work=i,r.pending=!1,r}return n.prototype.schedule=function(t,i){var r;if(i===void 0&&(i=0),this.closed)return this;this.state=t;var s=this.id,a=this.scheduler;return s!=null&&(this.id=this.recycleAsyncId(a,s,i)),this.pending=!0,this.delay=i,this.id=(r=this.id)!==null&&r!==void 0?r:this.requestAsyncId(a,this.id,i),this},n.prototype.requestAsyncId=function(t,i,r){return r===void 0&&(r=0),_.setInterval(t.flush.bind(t,this),r)},n.prototype.recycleAsyncId=function(t,i,r){if(r===void 0&&(r=0),r!=null&&this.delay===r&&this.pending===!1)return i;i!=null&&_.clearInterval(i)},n.prototype.execute=function(t,i){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var r=this._execute(t,i);if(r)return r;this.pending===!1&&this.id!=null&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},n.prototype._execute=function(t,i){var r=!1,s;try{this.work(t)}catch(a){r=!0,s=a||new Error("Scheduled action threw falsy error")}if(r)return this.unsubscribe(),s},n.prototype.unsubscribe=function(){if(!this.closed){var t=this,i=t.id,r=t.scheduler,s=r.actions;this.work=this.state=this.scheduler=null,this.pending=!1,P(s,this),i!=null&&(this.id=this.recycleAsyncId(r,i,null)),this.delay=null,e.prototype.unsubscribe.call(this)}},n}(F),R=function(){function e(n,t){t===void 0&&(t=e.now),this.schedulerActionCtor=n,this.now=t}return e.prototype.schedule=function(n,t,i){return t===void 0&&(t=0),new this.schedulerActionCtor(this,n).schedule(i,t)},e.now=U.now,e}(),J=function(e){M(n,e);function n(t,i){i===void 0&&(i=R.now);var r=e.call(this,t,i)||this;return r.actions=[],r._active=!1,r}return n.prototype.flush=function(t){var i=this.actions;if(this._active){i.push(t);return}var r;this._active=!0;do if(r=t.execute(t.state,t.delay))break;while(t=i.shift());if(this._active=!1,r){for(;t=i.shift();)t.unsubscribe();throw r}},n}(R),z=new J($),B=z;function G(e){return e instanceof Date&&!isNaN(e)}function Q(e,n,t,i,r,s,a,u){var l=[],o=0,f=0,c=!1,p=function(){c&&!l.length&&!o&&n.complete()},b=function(v){return o<i?m(v):l.push(v)},m=function(v){o++;var g=!1;w(t(v,f++)).subscribe(y(n,function(d){n.next(d)},function(){g=!0},void 0,function(){if(g)try{o--;for(var d=function(){var I=l.shift();a||m(I)};l.length&&o<i;)d();p()}catch(I){n.error(I)}}))};return e.subscribe(y(n,b,function(){c=!0,p()})),function(){}}function T(e,n,t){return t===void 0&&(t=1/0),h(n)?T(function(i,r){return V(function(s,a){return n(i,s,r,a)})(w(e(i,r)))},t):(typeof n=="number"&&(t=n),S(function(i,r){return Q(i,r,e,t)}))}var Y=["addListener","removeListener"],K=["addEventListener","removeEventListener"],W=["on","off"];function L(e,n,t,i){if(h(t)&&(i=t,t=void 0),i)return L(e,n,t).pipe(j(i));var r=C(ee(e)?K.map(function(u){return function(l){return e[u](n,l,t)}}):X(e)?Y.map(A(e,n)):Z(e)?W.map(A(e,n)):[],2),s=r[0],a=r[1];if(!s&&q(e))return T(function(u){return L(u,n,t)})(w(e));if(!s)throw new TypeError("Invalid event target");return new x(function(u){var l=function(){for(var o=[],f=0;f<arguments.length;f++)o[f]=arguments[f];return u.next(1<o.length?o:o[0])};return s(l),function(){return a(l)}})}function A(e,n){return function(t){return function(i){return e[t](n,i)}}}function X(e){return h(e.addListener)&&h(e.removeListener)}function Z(e){return h(e.on)&&h(e.off)}function ee(e){return h(e.addEventListener)&&h(e.removeEventListener)}function te(e,n,t){t===void 0&&(t=B);var i=-1;return n!=null&&(N(n)?t=n:i=n),new x(function(r){var s=G(e)?+e-t.now():e;s<0&&(s=0);var a=0;return t.schedule(function(){r.closed||(r.next(a++),0<=i?this.schedule(void 0,i):r.complete())},s)})}function ne(e,n){return S(function(t,i){var r=n??{},s=r.leading,a=s===void 0?!0:s,u=r.trailing,l=u===void 0?!1:u,o=!1,f=null,c=null,p=!1,b=function(){c==null||c.unsubscribe(),c=null,l&&(g(),p&&i.complete())},m=function(){c=null,p&&i.complete()},v=function(d){return c=w(e(d)).subscribe(y(i,b,m))},g=function(){if(o){o=!1;var d=f;f=null,i.next(d),!p&&v(d)}};t.subscribe(y(i,function(d){o=!0,f=d,!(c&&!c.closed)&&(a?g():v(d))},function(){p=!0,!(l&&o&&c&&!c.closed)&&i.complete()}))})}function ie(e,n,t){n===void 0&&(n=z);var i=te(e,n);return ne(function(){return i},t)}var re=Object.defineProperty,se=Object.getOwnPropertyDescriptor,ae=(e,n,t,i)=>{for(var r=i>1?void 0:i?se(n,t):n,s=e.length-1,a;s>=0;s--)(a=e[s])&&(r=(i?a(n,t,r):a(r))||r);return i&&r&&re(n,t,r),r};const oe=300;let E=class extends D{constructor(){super(...arguments),this.batchSize=10,this.page=2,this.ssrURL="",this.packageId="",this.posId="",this.loadingMoreRecipes=!1,this.noMoreData=!1,this.subscriptions=[]}connectedCallback(){super.connectedCallback()}disconnectedCallback(){super.disconnectedCallback(),this.subscriptions.forEach(e=>e.unsubscribe())}render(){var u;const e=(u=this.attributes["starting-data"])==null?void 0:u.value;if(!e||(this.recipeCardListHTML=this.querySelector(".mealz-catalog__list"),!this.recipeCardListHTML))return;const{batchSize:n,packageId:t,posId:i,ssrURL:r,displayRecipeVariant:s}=JSON.parse(e);Object.assign(this,{batchSize:n,packageId:t,posId:i,ssrURL:r,displayRecipeVariant:s});const a=L(window,"scroll");this.subscriptions.push(a.pipe(ie(100)).subscribe(()=>{!this.noMoreData&&!this.loadingMoreRecipes&&window.innerHeight+Math.round(window.scrollY)+oe>=document.body.offsetHeight&&this.getMoreRecipeCards()}))}buildHeaders(){return{authorization:`user_id ${localStorage.getItem("_miam/userId")}`,"language-id":window.mealzInternal.user.getLanguage(),"supplier-token":window.mealzInternal.supplier.getToken()}}async getMoreRecipeCards(){this.loadingMoreRecipes=!0;const e=new URLSearchParams;e.append("category_id",this.packageId),e.append("display_recipe_variant",this.displayRecipeVariant),e.append("size",this.batchSize.toString()),e.append("page",this.page.toString()),this.posId&&e.append("store_id",this.posId);const n=await fetch(this.ssrURL+"?"+e,{method:"GET",headers:this.buildHeaders()});this.appendRecipesToList(await n.text())}appendRecipesToList(e){this.checkIfMoreRecipes(e),this.recipeCardListHTML.insertAdjacentHTML("beforeend",e),this.loadingMoreRecipes=!1,this.page++}checkIfMoreRecipes(e){const n=e.match(/<mealz-recipe-card(?=\s|>)/gi);(n?n.length:0)<this.batchSize&&(this.noMoreData=!0)}};E=ae([k("mealz-catalog-category")],E);customElements.get("mealz-catalog-category")||customElements.define("mealz-catalog-category",E);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as c}from"../../assets/lit-element-
|
|
1
|
+
import{t as c}from"../../assets/lit-element-S5SYC_ST.js";import{N as n}from"../../assets/no-shadow-element-CB4i9vr8.js";var d=Object.defineProperty,g=Object.getOwnPropertyDescriptor,u=(e,t,a,o)=>{for(var s=o>1?void 0:o?g(t,a):t,i=e.length-1,r;i>=0;i--)(r=e[i])&&(s=(o?r(t,a,s):r(s))||s);return o&&s&&d(t,a,s),s};let l=class extends n{constructor(){super(...arguments),this.subscriptions=[]}connectedCallback(){super.connectedCallback()}disconnectedCallback(){super.disconnectedCallback(),this.subscriptions.forEach(e=>e.unsubscribe())}render(){this.favorites=this.querySelector(".mealz-catalog-favorites__list"),this.favorites&&this.subscriptions.push(window.mealzInternal.user.isAuthenticated().subscribe(e=>{this.isLogged=e,this.updateDOM()}))}updateDOM(){const e=this.favorites.querySelector(".mealz-catalog-favorites__list__loader"),t=this.favorites.querySelector(".mealz-catalog-favorites__list__not-logged"),a=this.favorites.querySelector(".mealz-catalog-favorites__list__logged");!e||!t||!a||(e.classList.add("hidden"),t.classList.toggle("hidden",this.isLogged),a.classList.toggle("hidden",!this.isLogged))}};l=u([c("mealz-catalog-favorites")],l);customElements.get("mealz-catalog-favorites")||customElements.define("mealz-catalog-favorites",l);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as s}from"../../assets/lit-element-
|
|
1
|
+
import{t as s}from"../../assets/lit-element-S5SYC_ST.js";import{N as n}from"../../assets/no-shadow-element-CB4i9vr8.js";var p=Object.defineProperty,f=Object.getOwnPropertyDescriptor,v=(c,a,o,l)=>{for(var e=l>1?void 0:l?f(a,o):a,t=c.length-1,m;t>=0;t--)(m=c[t])&&(e=(l?m(a,o,e):m(e))||e);return l&&e&&p(a,o,e),e};let r=class extends n{connectedCallback(){super.connectedCallback()}render(){}};r=v([s("mealz-catalog-home")],r);customElements.get("mealz-catalog-home")||customElements.define("mealz-catalog-home",r);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as n}from"../../assets/lit-element-
|
|
1
|
+
import{t as n}from"../../assets/lit-element-S5SYC_ST.js";import{N as c}from"../../assets/no-shadow-element-CB4i9vr8.js";var h=Object.defineProperty,u=Object.getOwnPropertyDescriptor,p=(e,t,o,s)=>{for(var r=s>1?void 0:s?u(t,o):t,i=e.length-1,a;i>=0;i--)(a=e[i])&&(r=(s?a(t,o,r):a(r))||r);return s&&r&&h(t,o,r),r};let l=class extends c{constructor(){super(...arguments),this.subscriptions=[],this.supplierHeaderHeight=0}connectedCallback(){super.connectedCallback(),this.subscriptions.push(window.mealzInternal.getStickyHeaderHeight().subscribe(e=>{this.supplierHeaderHeight=e}))}disconnectedCallback(){super.disconnectedCallback(),this.subscriptions.forEach(e=>e.unsubscribe()),this.toolbarObserver.unobserve(this.anchorElement)}render(){this.findElementsInDocument(),this.addEveryEventListeners()}firstUpdated(){this.setStickyObserver()}setStickyObserver(){var t;if(this.toolbar=document.querySelector(".mealz-catalog-toolbar"),this.anchorElement=document.querySelector(".mealz-catalog-toolbar__anchor"),!this.anchorElement||!this.toolbar)return;const e={rootMargin:`-${this.supplierHeaderHeight}px 0px 0px 0px`,threshold:1};(t=this.toolbarObserver)==null||t.unobserve(this),setTimeout(()=>this.setStickyToolbarStyle(),50),this.toolbarObserver=new IntersectionObserver(()=>{this.setStickyToolbarStyle()},e),this.toolbarObserver.observe(this.anchorElement)}setStickyToolbarStyle(){const t=this.anchorElement.getBoundingClientRect().top<this.supplierHeaderHeight;this.anchorElement.style.height=t?this.toolbar.clientHeight+"px":"0px",this.toolbar.classList.toggle("sticking",t),this.toolbar.style.top=this.supplierHeaderHeight+"px",this.updateDOM(t)}findElementsInDocument(){this.filterButton=this.querySelector(".mealz-catalog-toolbar__controls__filter"),this.preferencesButton=this.querySelector(".mealz-catalog-toolbar__controls__preferences"),this.favoritesButton=this.querySelector(".mealz-catalog-toolbar__controls__favorites"),this.searchButton=this.querySelector(".mealz-catalog-toolbar__searchbar-button"),this.searchInput=this.querySelector(".mealz-catalog-toolbar__searchbar-input"),this.backButton=this.querySelector(".mealz-recipe-toolbar__return-button")}addEveryEventListeners(){var e,t,o;(e=this.filterButton)==null||e.addEventListener("click",s=>{s.stopPropagation(),this.openFilter()}),(t=this.preferencesButton)==null||t.addEventListener("click",s=>{s.stopPropagation(),this.openPreferences()}),(o=this.searchInput)==null||o.addEventListener("keypress",s=>{s.key==="Enter"&&this.searchButton.click()})}updateDOM(e){var t,o,s,r;e?(this.favoritesButton.classList.remove("full"),this.preferencesButton.classList.remove("full"),this.favoritesButton.classList.add("ghost","square"),this.preferencesButton.classList.add("ghost","square"),(r=(s=this.backButton)==null?void 0:s.classList)==null||r.remove("hidden")):(this.favoritesButton.classList.remove("ghost","square"),this.preferencesButton.classList.remove("ghost","square"),this.favoritesButton.classList.add("full"),this.preferencesButton.classList.add("full"),(o=(t=this.backButton)==null?void 0:t.classList)==null||o.add("hidden"))}openFilter(){console.log("OPEN FILTER")}openPreferences(){console.log("OPEN PREFERENCES")}};l=p([n("mealz-catalog-toolbar")],l);customElements.get("mealz-catalog-toolbar")||customElements.define("mealz-catalog-toolbar",l);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as a}from"../../assets/lit-element-
|
|
1
|
+
import{t as a}from"../../assets/lit-element-S5SYC_ST.js";import{N as l}from"../../assets/no-shadow-element-CB4i9vr8.js";var c=Object.defineProperty,m=Object.getOwnPropertyDescriptor,b=(t,e,i,n)=>{for(var s=n>1?void 0:n?m(e,i):e,o=t.length-1,r;o>=0;o--)(r=t[o])&&(s=(n?r(e,i,s):r(s))||s);return n&&s&&c(e,i,s),s};let u=class extends l{constructor(){super(...arguments),this.subscriptions=[]}connectedCallback(){super.connectedCallback(),this.subscriptions.push(window.mealz.basket.recipeCount().subscribe(t=>{this.recipesCount=t,this.updateDOM()}))}disconnectedCallback(){super.disconnectedCallback(),this.subscriptions.forEach(t=>t.unsubscribe())}render(){this.button=this.querySelector(".mealz-my-meals-button"),this.button&&this.button.addEventListener("click",t=>{t.stopPropagation(),this.toggle()})}toggle(){window.mealz.basket.openPreview()}updateDOM(){var e;if(!this.button)return;this.recipesCount?this.button.classList.remove("hidden"):this.button.classList.add("hidden");const t=(e=this.button.querySelector(".mealz-my-meals-button__text"))==null?void 0:e.firstElementChild;t&&(t.innerHTML=`${this.recipesCount||0}`)}};u=b([a("mealz-my-meals-button")],u);customElements.get("mealz-my-meals-button")||customElements.define("mealz-my-meals-button",u);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as c}from"../assets/lit-element-
|
|
1
|
+
import{t as c}from"../assets/lit-element-S5SYC_ST.js";import{N as o}from"../assets/no-shadow-element-CB4i9vr8.js";var u=Object.defineProperty,d=Object.getOwnPropertyDescriptor,p=(e,i,r,s)=>{for(var t=s>1?void 0:s?d(i,r):i,l=e.length-1,n;l>=0;l--)(n=e[l])&&(t=(s?n(i,r,t):n(t))||t);return s&&t&&u(i,r,t),t};let a=class extends o{constructor(){super(...arguments),this.liked=null,this.recipeLikeId="",this.recipeId="",this.subscriptions=[]}connectedCallback(){super.connectedCallback()}disconnectedCallback(){super.disconnectedCallback(),this.subscriptions.forEach(e=>e.unsubscribe())}render(){this.button=this.querySelector(".mealz-like-button"),this.button&&(this.getInitialStatus(),this.button.addEventListener("click",e=>{e.stopPropagation(),this.toggle()}),this.subscriptions.push(window.mealzInternal.recipes.recipeLikeUpdated().subscribe(({id:e,isPast:i})=>{e===this.recipeId&&(this.liked=!i,this.updateDOM())})))}getInitialStatus(){var t;const e=(t=this.attributes["starting-data"])==null?void 0:t.value;if(!e)return;const{id:i,recipeId:r,liked:s}=JSON.parse(e);this.recipeLikeId=i,this.recipeId=r,this.liked=s!==void 0?s:!1,this.removeAttribute("starting-data")}async toggle(){window.mealzInternal.recipes.updateRecipeLike(this.recipeLikeId,this.recipeId,this.liked)}updateDOM(){this.button.querySelector(".mealz-like-button__icon").classList.toggle("fill",this.liked),this.button.querySelectorAll(".mealz-like-button__icon img").forEach(e=>e.classList.toggle("active"))}};a=p([c("mealz-like-button")],a);customElements.get("mealz-like-button")||customElements.define("mealz-like-button",a);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as p}from"../assets/lit-element-
|
|
1
|
+
import{t as p}from"../assets/lit-element-S5SYC_ST.js";import{N as d}from"../assets/no-shadow-element-CB4i9vr8.js";var h=Object.defineProperty,o=Object.getOwnPropertyDescriptor,l=(e,t,s,r)=>{for(var i=r>1?void 0:r?o(t,s):t,c=e.length-1,a;c>=0;c--)(a=e[c])&&(i=(r?a(t,s,i):a(i))||i);return r&&i&&h(t,s,i),i};let n=class extends d{constructor(){super(...arguments),this.subscriptions=[]}connectedCallback(){super.connectedCallback(),this.listenInView(),this.subscriptions.push(window.mealzInternal.recipes.guestsUpdated().subscribe(async({recipeId:e,guests:t})=>{this.updatedRecipeId=e,this.updatedGuests=t,this.updateDOM()}))}disconnectedCallback(){var e;super.disconnectedCallback(),this.subscriptions.forEach(t=>t.unsubscribe()),(e=this.inViewObserver)==null||e.unobserve(this)}render(){this.recipeCardTop=this.querySelector(".mealz-recipe-card__top"),this.recipeCardCta=this.querySelector(".mealz-recipe-card__cta"),!(!this.recipeCardTop||!this.recipeCardCta)&&(this.getInitialStatus(),this.recipeCardTop.addEventListener("click",()=>this.recipeCardTopClick()),this.recipeCardCta.addEventListener("click",()=>this.recipeCardCtaClick()))}listenInView(){const e={threshold:0};this.inViewObserver=new IntersectionObserver(t=>this.handleIntersection(t),e),this.inViewObserver.observe(this)}handleIntersection(e){e.forEach(t=>{var s;t.isIntersecting&&(this.recipePricing=this.querySelector("mealz-recipe-pricing"),this.recipePricing&&((s=this.recipePricing)==null||s.fetchPrice(this.posId,"DEFAULT",this.guests),this.inViewObserver.unobserve(this)))})}getInitialStatus(){var i;const e=(i=this.attributes["starting-data"])==null?void 0:i.value;if(!e)return;const{id:t,guests:s,posId:r}=JSON.parse(e);this.posId=r,this.recipeId=t,this.guests=s,this.removeAttribute("starting-data")}recipeCardTopClick(){window.mealzInternal.recipes.openDetails(this.recipeId,this.guests)}recipeCardCtaClick(){window.mealzInternal.recipes.openDetails(this.recipeId,this.guests)}updateDOM(){if(this.recipeId!==this.updatedRecipeId)return;const e=this.querySelector(".mealz-recipe-card__counter span");e&&(this.guests=this.updatedGuests,e.innerHTML=this.guests.toString())}};n=l([p("mealz-recipe-card")],n);customElements.get("mealz-recipe-card")||customElements.define("mealz-recipe-card",n);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as l}from"../assets/lit-element-
|
|
1
|
+
import{t as l}from"../assets/lit-element-S5SYC_ST.js";import{N as p}from"../assets/no-shadow-element-CB4i9vr8.js";var d=Object.defineProperty,o=Object.getOwnPropertyDescriptor,u=(e,s,i,a)=>{for(var t=a>1?void 0:a?o(s,i):s,r=e.length-1,c;r>=0;r--)(c=e[r])&&(t=(a?c(s,i,t):c(t))||t);return a&&t&&d(s,i,t),t};let n=class extends p{constructor(){super(...arguments),this.subscriptions=[]}async connectedCallback(){super.connectedCallback(),this.getInitialStatus()}disconnectedCallback(){super.disconnectedCallback(),this.subscriptions.forEach(e=>e.unsubscribe())}render(){this.recipeCta=this.querySelector(".mealz-recipe-card-cta"),this.recipeCta&&this.subscriptions.push(window.mealzInternal.basket.recipePricesInBasket$().subscribe(e=>{this.updateDOM(e.map(s=>s.id).includes(this.recipeId))}))}getInitialStatus(){var e;this.recipeId=(e=this.attributes["starting-data"])==null?void 0:e.value}updateDOM(e){e?(this.recipeCta.classList.replace("primary","secondary"),this.recipeCta.classList.add("in-basket")):(this.recipeCta.classList.replace("secondary","primary"),this.recipeCta.classList.remove("in-basket"))}};n=u([l("mealz-recipe-card-cta")],n);customElements.get("mealz-recipe-card-cta")||customElements.define("mealz-recipe-card-cta",n);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as z}from"../assets/lit-element-
|
|
1
|
+
import{t as z}from"../assets/lit-element-S5SYC_ST.js";import{N as D}from"../assets/no-shadow-element-CB4i9vr8.js";import{k as F,_ as v,l as f,E as w,S as R,c as V,O as l,n as q,f as O,j as M,o as d,d as b,e as u,i as y,p as N,r as U,q as B,h as J,s as T,t as W,u as $,v as G,w as H,g as K,x as P}from"../assets/mapOneOrManyArgs-BtDjRPOr.js";var Y=F(function(t){return function(){t(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),I=function(t){v(n,t);function n(){var r=t.call(this)||this;return r.closed=!1,r.currentObservers=null,r.observers=[],r.isStopped=!1,r.hasError=!1,r.thrownError=null,r}return n.prototype.lift=function(r){var e=new S(this,this);return e.operator=r,e},n.prototype._throwIfClosed=function(){if(this.closed)throw new Y},n.prototype.next=function(r){var e=this;f(function(){var i,o;if(e._throwIfClosed(),!e.isStopped){e.currentObservers||(e.currentObservers=Array.from(e.observers));try{for(var s=q(e.currentObservers),a=s.next();!a.done;a=s.next()){var c=a.value;c.next(r)}}catch(p){i={error:p}}finally{try{a&&!a.done&&(o=s.return)&&o.call(s)}finally{if(i)throw i.error}}}})},n.prototype.error=function(r){var e=this;f(function(){if(e._throwIfClosed(),!e.isStopped){e.hasError=e.isStopped=!0,e.thrownError=r;for(var i=e.observers;i.length;)i.shift().error(r)}})},n.prototype.complete=function(){var r=this;f(function(){if(r._throwIfClosed(),!r.isStopped){r.isStopped=!0;for(var e=r.observers;e.length;)e.shift().complete()}})},n.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(n.prototype,"observed",{get:function(){var r;return((r=this.observers)===null||r===void 0?void 0:r.length)>0},enumerable:!1,configurable:!0}),n.prototype._trySubscribe=function(r){return this._throwIfClosed(),t.prototype._trySubscribe.call(this,r)},n.prototype._subscribe=function(r){return this._throwIfClosed(),this._checkFinalizedStatuses(r),this._innerSubscribe(r)},n.prototype._innerSubscribe=function(r){var e=this,i=this,o=i.hasError,s=i.isStopped,a=i.observers;return o||s?w:(this.currentObservers=null,a.push(r),new R(function(){e.currentObservers=null,V(a,r)}))},n.prototype._checkFinalizedStatuses=function(r){var e=this,i=e.hasError,o=e.thrownError,s=e.isStopped;i?r.error(o):s&&r.complete()},n.prototype.asObservable=function(){var r=new l;return r.source=this,r},n.create=function(r,e){return new S(r,e)},n}(l),S=function(t){v(n,t);function n(r,e){var i=t.call(this)||this;return i.destination=r,i.source=e,i}return n.prototype.next=function(r){var e,i;(i=(e=this.destination)===null||e===void 0?void 0:e.next)===null||i===void 0||i.call(e,r)},n.prototype.error=function(r){var e,i;(i=(e=this.destination)===null||e===void 0?void 0:e.error)===null||i===void 0||i.call(e,r)},n.prototype.complete=function(){var r,e;(e=(r=this.destination)===null||r===void 0?void 0:r.complete)===null||e===void 0||e.call(r)},n.prototype._subscribe=function(r){var e,i;return(i=(e=this.source)===null||e===void 0?void 0:e.subscribe(r))!==null&&i!==void 0?i:w},n}(I),Q=function(t){v(n,t);function n(r){var e=t.call(this)||this;return e._value=r,e}return Object.defineProperty(n.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),n.prototype._subscribe=function(r){var e=t.prototype._subscribe.call(this,r);return!e.closed&&r.next(this._value),e},n.prototype.getValue=function(){var r=this,e=r.hasError,i=r.thrownError,o=r._value;if(e)throw i;return this._throwIfClosed(),o},n.prototype.next=function(r){t.prototype.next.call(this,this._value=r)},n}(I);function E(t){return t[t.length-1]}function X(t){return O(E(t))?t.pop():void 0}function Z(t){return M(E(t))?t.pop():void 0}function x(t,n){return n===void 0&&(n=0),d(function(r,e){r.subscribe(b(e,function(i){return u(e,t,function(){return e.next(i)},n)},function(){return u(e,t,function(){return e.complete()},n)},function(i){return u(e,t,function(){return e.error(i)},n)}))})}function j(t,n){return n===void 0&&(n=0),d(function(r,e){e.add(t.schedule(function(){return r.subscribe(e)},n))})}function ee(t,n){return y(t).pipe(j(n),x(n))}function re(t,n){return y(t).pipe(j(n),x(n))}function te(t,n){return new l(function(r){var e=0;return n.schedule(function(){e===t.length?r.complete():(r.next(t[e++]),r.closed||this.schedule())})})}function ne(t,n){return new l(function(r){var e;return u(r,n,function(){e=t[N](),u(r,n,function(){var i,o,s;try{i=e.next(),o=i.value,s=i.done}catch(a){r.error(a);return}s?r.complete():r.next(o)},0,!0)}),function(){return O(e==null?void 0:e.return)&&e.return()}})}function C(t,n){if(!t)throw new Error("Iterable cannot be null");return new l(function(r){u(r,n,function(){var e=t[Symbol.asyncIterator]();u(r,n,function(){e.next().then(function(i){i.done?r.complete():r.next(i.value)})},0,!0)})})}function ie(t,n){return C(U(t),n)}function oe(t,n){if(t!=null){if(B(t))return ee(t,n);if(J(t))return te(t,n);if(T(t))return re(t,n);if(W(t))return C(t,n);if($(t))return ne(t,n);if(G(t))return ie(t,n)}throw H(t)}function k(t,n){return n?oe(t,n):y(t)}var se=Array.isArray,ae=Object.getPrototypeOf,ce=Object.prototype,ue=Object.keys;function le(t){if(t.length===1){var n=t[0];if(se(n))return{args:n,keys:null};if(pe(n)){var r=ue(n);return{args:r.map(function(e){return n[e]}),keys:r}}}return{args:t,keys:null}}function pe(t){return t&&typeof t=="object"&&ae(t)===ce}function fe(t,n){return t.reduce(function(r,e,i){return r[e]=n[i],r},{})}function he(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var r=Z(t),e=X(t),i=le(t),o=i.args,s=i.keys;if(o.length===0)return k([],r);var a=new l(ve(o,r,s?function(c){return fe(s,c)}:P));return e?a.pipe(K(e)):a}function ve(t,n,r){return r===void 0&&(r=P),function(e){_(n,function(){for(var i=t.length,o=new Array(i),s=i,a=i,c=function(m){_(n,function(){var A=k(t[m],n),g=!1;A.subscribe(b(e,function(L){o[m]=L,g||(g=!0,a--),a||e.next(r(o.slice()))},function(){--s||e.complete()}))},e)},p=0;p<i;p++)c(p)},e)}}function _(t,n,r){t?u(r,t,n):n()}function de(t){return d(function(n,r){var e=!1,i=0;n.subscribe(b(r,function(o){return(e||(e=!t(o,i++)))&&r.next(o)}))})}var be=Object.defineProperty,ye=Object.getOwnPropertyDescriptor,me=(t,n,r,e)=>{for(var i=e>1?void 0:e?ye(n,r):n,o=t.length-1,s;o>=0;o--)(s=t[o])&&(i=(e?s(n,r,i):s(i))||i);return e&&i&&be(n,r,i),i};let h=class extends D{constructor(){super(...arguments),this.formattedPrice="",this.rendered=new Q(!1),this.subscriptions=[]}connectedCallback(){super.connectedCallback(),this.subscriptions.push(window.mealzInternal.recipes.guestsUpdated().subscribe(t=>{t.recipeId===this.recipeId&&(this.serves=t.guests)}),he([this.rendered,window.mealzInternal.basket.recipePricesInBasket$()]).pipe(de(([t,n])=>!t||!n)).subscribe(([t,n])=>{this.recipePricingValue=n.find(e=>e.id===this.recipeId);const r=this.recipePricingValue?(this.recipePricingValue.price/this.serves).toString():this.pricePerServe;this.applyCurrencyDisplay(r),this.showPrice()}))}disconnectedCallback(){super.disconnectedCallback(),this.subscriptions.forEach(t=>t.unsubscribe())}fetchPrice(t,n,r){var s,a;let e=(s=this.recipePricing)==null?void 0:s.querySelector(".mealz-recipe-pricing__wrapper");const i=(a=this.attributes["starting-data"])==null?void 0:a.value;if(!i){e==null||e.classList.replace("active","hidden");return}JSON.parse(i).pricePerServe===null&&(e==null||e.classList.replace("active","hidden"),this.subscriptions.push(window.mealzInternal.recipes.fetchPricing(this.recipeId,t,n,r).subscribe(c=>{c!=null&&c.price_per_serve&&(e==null||e.classList.replace("hidden","active"),this.applyCurrencyDisplay(c.price_per_serve))})))}render(){this.recipePricing=this.querySelector(".mealz-recipe-pricing"),this.recipePricing&&(this.rendered.next(!0),this.getInitialStatus())}getInitialStatus(){var i;const t=(i=this.attributes["starting-data"])==null?void 0:i.value;if(!t)return;const{recipeId:n,pricePerServe:r,serves:e}=JSON.parse(t);this.recipeId=n,this.pricePerServe=(r==null?void 0:r.toString())??null,this.serves=e,this.applyCurrencyDisplay(this.pricePerServe)}applyCurrencyDisplay(t){let n=parseFloat(t);this.formattedPrice=n.toLocaleString("fr-FR",{minimumFractionDigits:2,maximumFractionDigits:2}),this.updateDOM()}showPrice(){var r,e;let t=(r=this.recipePricing)==null?void 0:r.querySelector(".mealz-recipe-pricing__loading"),n=(e=this.recipePricing)==null?void 0:e.querySelector(".mealz-recipe-pricing__wrapper");t&&t.classList.contains("active")&&(t.classList.replace("active","hidden"),n.classList.replace("hidden","active"))}updateDOM(){var n;const t=(n=this.recipePricing)==null?void 0:n.querySelector(".mealz-recipe-pricing__wrapper__price");t&&(t.innerHTML=this.formattedPrice+" €")}};h=me([z("mealz-recipe-pricing")],h);customElements.get("mealz-recipe-pricing")||customElements.define("mealz-recipe-pricing",h);
|
|
@@ -1,27 +1,33 @@
|
|
|
1
|
-
import{u,f as
|
|
1
|
+
import{u as m,f as g,i as b,h as f,k as n,D as u,t as x}from"../assets/lit-element-S5SYC_ST.js";/**
|
|
2
2
|
* @license
|
|
3
3
|
* Copyright 2017 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
5
|
-
*/const _={attribute:!0,type:String,converter:
|
|
5
|
+
*/const _={attribute:!0,type:String,converter:m,reflect:!1,hasChanged:g},v=(t=_,e,s)=>{const{kind:i,metadata:o}=s;let a=globalThis.litPropertyMetadata.get(o);if(a===void 0&&globalThis.litPropertyMetadata.set(o,a=new Map),a.set(s.name,t),i==="accessor"){const{name:r}=s;return{set(p){const h=e.get.call(this);e.set.call(this,p),this.requestUpdate(r,h,t)},init(p){return p!==void 0&&this.P(r,void 0,t),p}}}if(i==="setter"){const{name:r}=s;return function(p){const h=this[r];e.call(this,p),this.requestUpdate(r,h,t)}}throw Error("Unsupported decorator location: "+i)};function c(t){return(e,s)=>typeof s=="object"?v(t,e,s):((i,o,a)=>{const r=o.hasOwnProperty(a);return o.constructor.createProperty(a,r?{...i,wrapped:!0}:i),r?Object.getOwnPropertyDescriptor(o,a):void 0})(t,e,s)}/**
|
|
6
6
|
* @license
|
|
7
7
|
* Copyright 2017 Google LLC
|
|
8
8
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
9
|
-
*/function
|
|
9
|
+
*/function w(t){return c({...t,state:!0,attribute:!1})}/**
|
|
10
10
|
* @license
|
|
11
11
|
* Copyright 2017 Google LLC
|
|
12
12
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
13
|
-
*/const
|
|
13
|
+
*/const y=(t,e,s)=>(s.configurable=!0,s.enumerable=!0,Reflect.decorate&&typeof e!="object"&&Object.defineProperty(t,e,s),s);/**
|
|
14
14
|
* @license
|
|
15
15
|
* Copyright 2017 Google LLC
|
|
16
16
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
17
|
-
*/function
|
|
17
|
+
*/function S(t,e){return(s,i,o)=>{const a=r=>{var p;return((p=r.renderRoot)==null?void 0:p.querySelector(t))??null};return y(s,i,{get(){return a(this)}})}}class C{get extId(){return this.attributes["ext-id"]}}var L=Object.defineProperty,E=Object.getOwnPropertyDescriptor,d=(t,e,s,i)=>{for(var o=i>1?void 0:i?E(e,s):e,a=t.length-1,r;a>=0;a--)(r=t[a])&&(o=(i?r(e,s,o):r(o))||o);return i&&o&&L(e,s,o),o};let l=class extends f{constructor(){var t,e,s,i,o,a;super(...arguments),this.selectedRadius=50,this.getByAddress=(e=(t=window.miam)==null?void 0:t.pos)==null?void 0:e.getByAddress,this.getByCoordinates=(i=(s=window.miam)==null?void 0:s.pos)==null?void 0:i.getByCoordinates,this.getAffiliateSuppliers=(a=(o=window.miam)==null?void 0:o.supplier)==null?void 0:a.getAffiliateSuppliers,this.isMobile=!1,this._posList=[],this._markers=[],this._searchingPos=!1,this._searchSubmitted=!1,this._previousSearchMethod=()=>{},this._suppliers=[],this._selectedSuppliers=[],this._showPosList=!1,this._posSelected=!1,this.subscriptions=[]}set geolocationCoordinates(t){var e,s;this._geolocationCoordinates=t,(e=t==null?void 0:t.coords)!=null&&e.latitude&&((s=t==null?void 0:t.coords)!=null&&s.longitude)&&this.setGeolocation()}get geolocationCoordinates(){return this._geolocationCoordinates}_nameOfStore(t){return`${t.supplier.attributes.name} - ${t.attributes.name}`}connectedCallback(){super.connectedCallback(),this.initLeaflet(),this.fetchSuppliers(),this.initEvents(),this.checkMobile(),window.addEventListener("resize",this.checkMobile.bind(this))}disconnectedCallback(){this.subscriptions.forEach(t=>t.unsubscribe()),super.disconnectedCallback(),this._leafletCss.remove(),this._miamDs.remove(),this._leafletJs.remove()}render(){if(this.show)return this.posSelectionTemplate()}firstUpdated(){this._posSelected=!1,this.loadMap(),this.geolocationTimeout(),this.listenFormSubmit()}checkMobile(){this.isMobile=window.innerWidth<=768}posSelectionTemplate(){return n`
|
|
18
|
+
<button @click=${()=>this.dispatchShow(!1)} class="miam-ds-button primary close-button">
|
|
19
|
+
<img src="https://storage.googleapis.com/assets.miam.tech/generic/icons/Cross.svg"
|
|
20
|
+
alt="modal close button"/>
|
|
21
|
+
</button>
|
|
18
22
|
<div class="wrapper miam-ds-body">
|
|
19
23
|
<div class="pos-selection">
|
|
24
|
+
${this.isMobile?u:this.infoBoxTemplate()}
|
|
20
25
|
<div class="title">
|
|
21
26
|
<button @click=${()=>this.dispatchShow(!1)}><</button>
|
|
22
27
|
<span>Sélectionner un magasin</span>
|
|
23
28
|
</div>
|
|
24
29
|
<form id="store-locator-form">
|
|
30
|
+
${this.isMobile?this.infoBoxTemplate():u}
|
|
25
31
|
<div class="address-input-container">
|
|
26
32
|
${this.geolocButtonTemplate()}
|
|
27
33
|
<input required class="address-input" type="text" name="address"
|
|
@@ -38,11 +44,17 @@ import{u,f as m,i as g,h as b,k as n,t as f}from"../assets/lit-element-BKlYWoBt.
|
|
|
38
44
|
class="miam-ds-button primary hide-pos-button">
|
|
39
45
|
${this.getButtonLabel()}
|
|
40
46
|
</button>
|
|
41
|
-
</div>`:
|
|
47
|
+
</div>`:u}
|
|
42
48
|
</div>
|
|
43
49
|
</div>
|
|
44
50
|
${this.posMapTemplate()}
|
|
45
51
|
</div>
|
|
52
|
+
`}infoBoxTemplate(){return n`
|
|
53
|
+
<div class="info-box">
|
|
54
|
+
<span class="miam-ds-text size-s weight-l">Dernière étape pour pouvoir commander des recettes !</span>
|
|
55
|
+
<img src="https://storage.googleapis.com/assets.miam.tech/generic/icons/Infos_Primary.svg" alt="Info icon"
|
|
56
|
+
@click=${()=>this.openNoSupplierOnboarding()}/>
|
|
57
|
+
</div>
|
|
46
58
|
`}geolocButtonTemplate(){var e,s,i,o;let t;if(this.geolocationCoordinates===void 0)t=n`
|
|
47
59
|
<div class="miam-ds-loader"></div>`;else if((s=(e=this.geolocationCoordinates)==null?void 0:e.coords)!=null&&s.longitude&&((o=(i=this.geolocationCoordinates)==null?void 0:i.coords)!=null&&o.latitude))t=n`<img title="Votre position" class="geolocation-icon"
|
|
48
60
|
src="https://storage.googleapis.com/assets.miam.tech/generic/icons/locate-primary.svg"
|
|
@@ -93,7 +105,7 @@ import{u,f as m,i as g,h as b,k as n,t as f}from"../assets/lit-element-BKlYWoBt.
|
|
|
93
105
|
</div>
|
|
94
106
|
`)}
|
|
95
107
|
</div>
|
|
96
|
-
`}getButtonLabel(){if(this._showPosList)return"Voir la carte";const t=this._posList.length;return t===1?"Voir le magasin":`Voir les ${t} magasins`}setAddress(t=!1){!this._addressInput.value||this._addressInput.value.length<3||this._searchingPos||!t&&this._prevAddress===this._addressInput.value+", France"||(this.shadowRoot.getElementById("pos-list"),this._previousSearchMethod=this.setAddress,this._prevAddress=this._addressInput.value+", France",this._searchingPos=!0,this.requestUpdate(),this.subscriptions.push(this.getByAddress(this._prevAddress,this.selectedRadius,this._selectedSuppliers).subscribe(e=>{this.setPosList(e),this.setNewLocation(),this.dispatchSearch(this._prevAddress,e.data.length),this._searchingPos=!1,this._searchSubmitted=!0,this.togglePosList(!1),this.requestUpdate()})))}setGeolocation(t=!1){this._prevAddress="",this._previousSearchMethod=this.setGeolocation,this.getPosByCoordinates()}getPosByCoordinates(){this._searchingPos=!0,this.requestUpdate(),this.subscriptions.push(this.getByCoordinates(this.geolocationCoordinates.coords.latitude,this.geolocationCoordinates.coords.longitude,this.selectedRadius,this._selectedSuppliers).subscribe(t=>{this._addressInput.value="",this.setPosList(t),this._searchingPos=!1,this.setNewLocation(),this._searchSubmitted=!0,this.togglePosList(!1),this.requestUpdate()}))}setPosList(t){this._posList=t.data.map(e=>{const s=Object.assign(new
|
|
108
|
+
`}getButtonLabel(){if(this._showPosList)return"Voir la carte";const t=this._posList.length;return t===1?"Voir le magasin":`Voir les ${t} magasins`}setAddress(t=!1){!this._addressInput.value||this._addressInput.value.length<3||this._searchingPos||!t&&this._prevAddress===this._addressInput.value+", France"||(this.shadowRoot.getElementById("pos-list"),this._previousSearchMethod=this.setAddress,this._prevAddress=this._addressInput.value+", France",this._searchingPos=!0,this.requestUpdate(),this.subscriptions.push(this.getByAddress(this._prevAddress,this.selectedRadius,this._selectedSuppliers).subscribe(e=>{this.setPosList(e),this.setNewLocation(),this.dispatchSearch(this._prevAddress,e.data.length),this._searchingPos=!1,this._searchSubmitted=!0,this.togglePosList(!1),this.requestUpdate()})))}setGeolocation(t=!1){this._prevAddress="",this._previousSearchMethod=this.setGeolocation,this.getPosByCoordinates()}getPosByCoordinates(){this._searchingPos=!0,this.requestUpdate(),this.subscriptions.push(this.getByCoordinates(this.geolocationCoordinates.coords.latitude,this.geolocationCoordinates.coords.longitude,this.selectedRadius,this._selectedSuppliers).subscribe(t=>{this._addressInput.value="",this.setPosList(t),this._searchingPos=!1,this.setNewLocation(),this._searchSubmitted=!0,this.togglePosList(!1),this.requestUpdate()}))}setPosList(t){this._posList=t.data.map(e=>{const s=Object.assign(new C,e);return s.supplier=t.included.find(i=>i.id===s.relationships.supplier.data.id),s}).sort((e,s)=>e.attributes.name.includes("onoprix")?-1:s.attributes.name.includes("onoprix")?1:0)}dispatchPos(t){this._posSelected=!0,this.requestUpdate();const e={detail:{posId:t.id,posExtId:t.extId,supplierId:t.supplier.id,supplierName:t.supplier.attributes.name,posName:this._nameOfStore(t)},bubbles:!0,composed:!0};this.dispatchEvent(new CustomEvent("posIdChange",e))}dispatchShow(t){const e={detail:{show:t},bubbles:!0,composed:!0};this.dispatchEvent(new CustomEvent("showChange",e))}dispatchSearch(t,e){const s={detail:{searchTerm:t,storesFoundCount:e},bubbles:!0,composed:!0};console.debug("[MealzComponents] dispatchEvent searchChange",s),this.dispatchEvent(new CustomEvent("searchChange",s))}initLeaflet(){this._leafletCss=document.createElement("link"),this._leafletCss.setAttribute("rel","stylesheet"),this._leafletCss.setAttribute("href","https://unpkg.com/leaflet@1.9.4/dist/leaflet.css"),this._leafletCss.setAttribute("integrity","sha256-p4NxAoJBhIIN+hmNHrzRCf9tD/miZyoHS5obTRR9BMY="),this._leafletCss.setAttribute("crossorigin",""),this._leafletJs=document.createElement("script"),this._leafletJs.setAttribute("src","https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"),this._leafletJs.setAttribute("integrity","sha256-20nQCchB9co0qIjJZRGuk2/Z9VM+kNiyxNV1lvTlZBo="),this._leafletJs.setAttribute("crossorigin",""),this._miamDs=document.createElement("link"),this._miamDs.setAttribute("rel","stylesheet"),this._miamDs.setAttribute("href","https://unpkg.com/miam-ds@1.2.4/miam-ds.min.css"),this.shadowRoot.appendChild(this._miamDs),this.shadowRoot.appendChild(this._leafletCss),document.head.appendChild(this._leafletJs)}waitForLeaflet(t){let i=50;console.debug("[Map] Checking for window.L");const o=setInterval(()=>{window.L!==void 0||i===0?(clearInterval(o),window.L!==void 0?(console.debug("[Map] window.L is defined"),t(!0)):(console.error("[Map] Failed to load Leaflet after",50*100,"ms"),t(!1))):i--},100)}initMap(){this._map&&(this._map.off(),this._map.remove()),this.setNewLocation(),window.L.tileLayer("https://cartodb-basemaps-{s}.global.ssl.fastly.net/light_all/{z}/{x}/{y}.png",{maxZoom:19,attribution:"Map tiles by Carto, under CC BY 3.0. Data by OpenStreetMap, under ODbL."}).addTo(this._map)}loadMap(){this.waitForLeaflet(t=>{t&&this.initMap()})}initEvents(){this._filterEvent=new CustomEvent("filterChange",{detail:{supplierName:""},bubbles:!0,composed:!0})}fetchSuppliers(){this.subscriptions.push(this.getAffiliateSuppliers().subscribe(t=>{this._suppliers=t.map(e=>({id:e.id,name:e.attributes.name})),this.requestUpdate()}))}setNewLocation(){var e;const t=this.shadowRoot.getElementById("map");t&&(this._map?(this._markers.forEach(s=>{this._map.removeLayer(s)}),this._markers=[],this._map.panTo(this.getCoordinates())):this._map=(e=window.L)==null?void 0:e.map(t).setView(this.getCoordinates(),13),this.addMarkers())}getCoordinates(){return this._posList.length<1?[48.866667,2.333333]:[this._posList[0].attributes.latitude,this._posList[0].attributes.longitude]}addMarkers(){this._posList.length>0&&this._posList.forEach((t,e)=>{this._markers.push(window.L.marker([t.attributes.latitude,t.attributes.longitude],{icon:this.buildIcon(t.supplier)}).addTo(this._map));let s=window.L.popup({content:`
|
|
97
109
|
<div class="pos-item">
|
|
98
110
|
<div class="top">
|
|
99
111
|
<img class="pos-img" src="${t.supplier.attributes.logo}" alt="${t.supplier.attributes.name}"/>
|
|
@@ -106,17 +118,41 @@ import{u,f as m,i as g,h as b,k as n,t as f}from"../assets/lit-element-BKlYWoBt.
|
|
|
106
118
|
<button id="select" class="miam-ds-button primary select-pos-button">Sélectionner</button>
|
|
107
119
|
</div>
|
|
108
120
|
</div>
|
|
109
|
-
`});this._markers[e].bindPopup(s).on("popupopen",i=>{i.target.getPopup().getElement().querySelector("#select").addEventListener("click",()=>{this.dispatchPos(t)})})})}buildIcon(t){return window.L.icon({iconUrl:t.attributes.logo||"https://cdn-icons-png.flaticon.com/512/3515/3515146.png",shadowUrl:"https://storage.googleapis.com/assets.miam.tech/mealz-components/store-locator/marker.svg",iconSize:[32,32],shadowSize:[44,53],iconAnchor:[16,45],shadowAnchor:[22,45],popupAnchor:[0,-55]})}togglePosList(t){this._showPosList=!t;const e=this.shadowRoot.getElementById("pos-list"),s={bubbles:!0,composed:!0};e&&(t?(e.style.display="none",this.dispatchEvent(new CustomEvent("mapSelected",s))):(e.style.display="flex",this.dispatchEvent(new CustomEvent("listSelected",s))),this.requestUpdate())}geolocationTimeout(){setTimeout(()=>{this.geolocationCoordinates===void 0&&(this.geolocationCoordinates={})},2e4)}listenFormSubmit(){this.shadowRoot.getElementById("store-locator-form").addEventListener("submit",e=>{e.preventDefault(),this.setAddress()})}};l.styles=[
|
|
121
|
+
`});this._markers[e].bindPopup(s).on("popupopen",i=>{i.target.getPopup().getElement().querySelector("#select").addEventListener("click",()=>{this.dispatchPos(t)})})})}buildIcon(t){return window.L.icon({iconUrl:t.attributes.logo||"https://cdn-icons-png.flaticon.com/512/3515/3515146.png",shadowUrl:"https://storage.googleapis.com/assets.miam.tech/mealz-components/store-locator/marker.svg",iconSize:[32,32],shadowSize:[44,53],iconAnchor:[16,45],shadowAnchor:[22,45],popupAnchor:[0,-55]})}togglePosList(t){this._showPosList=!t;const e=this.shadowRoot.getElementById("pos-list"),s={bubbles:!0,composed:!0};e&&(t?(e.style.display="none",this.dispatchEvent(new CustomEvent("mapSelected",s))):(e.style.display="flex",this.dispatchEvent(new CustomEvent("listSelected",s))),this.requestUpdate())}geolocationTimeout(){setTimeout(()=>{this.geolocationCoordinates===void 0&&(this.geolocationCoordinates={})},2e4)}listenFormSubmit(){this.shadowRoot.getElementById("store-locator-form").addEventListener("submit",e=>{e.preventDefault(),this.setAddress()})}openNoSupplierOnboarding(){var t;(t=window.miam)==null||t.pos.openNoSupplierOnboarding()}};l.styles=[b`
|
|
110
122
|
:host {
|
|
111
123
|
display: block;
|
|
112
124
|
height: 100%;
|
|
113
125
|
}
|
|
126
|
+
|
|
127
|
+
.close-button {
|
|
128
|
+
display: block;
|
|
129
|
+
position: absolute;
|
|
130
|
+
z-index: 2;
|
|
131
|
+
right: 12px;
|
|
132
|
+
top: 12px;
|
|
133
|
+
height: 40px;
|
|
134
|
+
width: 40px;
|
|
135
|
+
padding: 8px;
|
|
136
|
+
}
|
|
114
137
|
|
|
115
138
|
.wrapper {
|
|
116
139
|
height: 100%;
|
|
117
140
|
display: flex;
|
|
118
141
|
}
|
|
119
142
|
|
|
143
|
+
.info-box {
|
|
144
|
+
display: flex;
|
|
145
|
+
justify-content: space-between;
|
|
146
|
+
padding: 8px 12px;
|
|
147
|
+
border-radius: 8px;
|
|
148
|
+
background-color: var(--miam-color-primary-100, #E4EAEC);
|
|
149
|
+
|
|
150
|
+
span {
|
|
151
|
+
color: var(--miam-ds-color-primary, #24748F);
|
|
152
|
+
margin-right: 4px;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
120
156
|
.pos-selection {
|
|
121
157
|
display: flex;
|
|
122
158
|
width: 320px;
|
|
@@ -297,6 +333,10 @@ import{u,f as m,i as g,h as b,k as n,t as f}from"../assets/lit-element-BKlYWoBt.
|
|
|
297
333
|
}
|
|
298
334
|
|
|
299
335
|
@media(max-width: 768px) {
|
|
336
|
+
.close-button {
|
|
337
|
+
display: none;
|
|
338
|
+
}
|
|
339
|
+
|
|
300
340
|
.wrapper {
|
|
301
341
|
position: absolute;
|
|
302
342
|
flex-direction: column;
|
|
@@ -413,4 +453,4 @@ import{u,f as m,i as g,h as b,k as n,t as f}from"../assets/lit-element-BKlYWoBt.
|
|
|
413
453
|
top: 0;
|
|
414
454
|
}
|
|
415
455
|
}
|
|
416
|
-
`];d([c({type:Boolean})],l.prototype,"show",2);d([c({type:Number})],l.prototype,"selectedRadius",2);d([c({type:GeolocationPosition})],l.prototype,"geolocationCoordinates",1);d([c()],l.prototype,"getByAddress",2);d([c()],l.prototype,"getByCoordinates",2);d([c()],l.prototype,"getAffiliateSuppliers",2);d([
|
|
456
|
+
`];d([c({type:Boolean})],l.prototype,"show",2);d([c({type:Number})],l.prototype,"selectedRadius",2);d([c({type:GeolocationPosition})],l.prototype,"geolocationCoordinates",1);d([c()],l.prototype,"getByAddress",2);d([c()],l.prototype,"getByCoordinates",2);d([c()],l.prototype,"getAffiliateSuppliers",2);d([w()],l.prototype,"isMobile",2);d([S("input")],l.prototype,"_addressInput",2);l=d([x("mealz-store-locator")],l);customElements.get("mealz-store-locator")||customElements.define("mealz-store-locator",l);
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{h as e}from"./lit-element-BKlYWoBt.js";class r extends e{createRenderRoot(){return this}}export{r as N};
|