mealz-components 0.2.1 → 0.3.0-alpha.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/like-button/like-button.css +7 -0
- package/dist/like-button/like-button.js +638 -0
- package/dist/like-button/like-button.min.js +28 -0
- package/dist/like-button/like-button.umd.cjs +23 -0
- package/dist/mealz-components.js +171 -132
- package/dist/mealz-components.min.js +20 -20
- package/dist/mealz-components.umd.cjs +14 -14
- package/dist/recipe-card/recipe-card.css +92 -0
- package/dist/recipe-card/recipe-card.js +622 -0
- package/dist/recipe-card/recipe-card.min.js +28 -0
- package/dist/recipe-card/recipe-card.umd.cjs +23 -0
- package/dist/store-locator/store-locator.js +62 -76
- package/dist/store-locator/store-locator.min.js +20 -20
- package/dist/store-locator/store-locator.umd.cjs +13 -13
- package/dist/style.css +1 -0
- package/package.json +7 -2
|
@@ -3,51 +3,40 @@
|
|
|
3
3
|
* Copyright 2019 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
5
5
|
*/
|
|
6
|
-
const N=globalThis,
|
|
6
|
+
const N=globalThis,F=N.ShadowRoot&&(void 0===N.ShadyCSS||N.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,J=Symbol(),G=new WeakMap;let nt=class{constructor(t,e,s){if(this._$cssResult$=!0,s!==J)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const e=this.t;if(F&&void 0===t){const s=void 0!==e&&1===e.length;s&&(t=G.get(e)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),s&&G.set(e,t))}return t}toString(){return this.cssText}};const Z=F?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const s of t.cssRules)e+=s.cssText;return(t=>new nt("string"==typeof t?t:t+"",void 0,J))(e)})(t):t
|
|
7
7
|
/**
|
|
8
8
|
* @license
|
|
9
9
|
* Copyright 2017 Google LLC
|
|
10
10
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
11
|
-
*/,{is:
|
|
11
|
+
*/,{is:gt,defineProperty:ft,getOwnPropertyDescriptor:_t,getOwnPropertyNames:bt,getOwnPropertySymbols:$t,getPrototypeOf:yt}=Object,$=globalThis,K=$.trustedTypes,vt=K?K.emptyScript:"",B=$.reactiveElementPolyfillSupport,L=(t,e)=>t,I={toAttribute(t,e){switch(e){case Boolean:t=t?vt:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){let s=t;switch(e){case Boolean:s=null!==t;break;case Number:s=null===t?null:Number(t);break;case Object:case Array:try{s=JSON.parse(t)}catch{s=null}}return s}},W=(t,e)=>!gt(t,e),Y={attribute:!0,type:String,converter:I,reflect:!1,hasChanged:W};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),$.litPropertyMetadata??($.litPropertyMetadata=new WeakMap);class w extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??(this.l=[])).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,e=Y){if(e.state&&(e.attribute=!1),this._$Ei(),this.elementProperties.set(t,e),!e.noAccessor){const s=Symbol(),i=this.getPropertyDescriptor(t,s,e);void 0!==i&&ft(this.prototype,t,i)}}static getPropertyDescriptor(t,e,s){const{get:i,set:o}=_t(this.prototype,t)??{get(){return this[e]},set(t){this[e]=t}};return{get(){return null==i?void 0:i.call(this)},set(e){const n=null==i?void 0:i.call(this);o.call(this,e),this.requestUpdate(t,n,s)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??Y}static _$Ei(){if(this.hasOwnProperty(L("elementProperties")))return;const t=yt(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(L("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(L("properties"))){const t=this.properties,e=[...bt(t),...$t(t)];for(const s of e)this.createProperty(s,t[s])}const t=this[Symbol.metadata];if(null!==t){const e=litPropertyMetadata.get(t);if(void 0!==e)for(const[t,s]of e)this.elementProperties.set(t,s)}this._$Eh=new Map;for(const[t,e]of this.elementProperties){const s=this._$Eu(t,e);void 0!==s&&this._$Eh.set(s,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const s=new Set(t.flat(1/0).reverse());for(const t of s)e.unshift(Z(t))}else void 0!==t&&e.push(Z(t));return e}static _$Eu(t,e){const s=e.attribute;return!1===s?void 0:"string"==typeof s?s:"string"==typeof t?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){var t;this._$ES=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$E_(),this.requestUpdate(),null==(t=this.constructor.l)||t.forEach((t=>t(this)))}addController(t){var e;(this._$EO??(this._$EO=new Set)).add(t),void 0!==this.renderRoot&&this.isConnected&&(null==(e=t.hostConnected)||e.call(t))}removeController(t){var e;null==(e=this._$EO)||e.delete(t)}_$E_(){const t=new Map,e=this.constructor.elementProperties;for(const s of e.keys())this.hasOwnProperty(s)&&(t.set(s,this[s]),delete this[s]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return((t,e)=>{if(F)t.adoptedStyleSheets=e.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet));else for(const s of e){const e=document.createElement("style"),i=N.litNonce;void 0!==i&&e.setAttribute("nonce",i),e.textContent=s.cssText,t.appendChild(e)}})(t,this.constructor.elementStyles),t}connectedCallback(){var t;this.renderRoot??(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),null==(t=this._$EO)||t.forEach((t=>{var e;return null==(e=t.hostConnected)?void 0:e.call(t)}))}enableUpdating(t){}disconnectedCallback(){var t;null==(t=this._$EO)||t.forEach((t=>{var e;return null==(e=t.hostDisconnected)?void 0:e.call(t)}))}attributeChangedCallback(t,e,s){this._$AK(t,s)}_$EC(t,e){var s;const i=this.constructor.elementProperties.get(t),o=this.constructor._$Eu(t,i);if(void 0!==o&&!0===i.reflect){const n=(void 0!==(null==(s=i.converter)?void 0:s.toAttribute)?i.converter:I).toAttribute(e,i.type);this._$Em=t,null==n?this.removeAttribute(o):this.setAttribute(o,n),this._$Em=null}}_$AK(t,e){var s;const i=this.constructor,o=i._$Eh.get(t);if(void 0!==o&&this._$Em!==o){const t=i.getPropertyOptions(o),n="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==(null==(s=t.converter)?void 0:s.fromAttribute)?t.converter:I;this._$Em=o,this[o]=n.fromAttribute(e,t.type),this._$Em=null}}requestUpdate(t,e,s){if(void 0!==t){if(s??(s=this.constructor.getPropertyOptions(t)),!(s.hasChanged??W)(this[t],e))return;this.P(t,e,s)}!1===this.isUpdatePending&&(this._$ES=this._$ET())}P(t,e,s){this._$AL.has(t)||this._$AL.set(t,e),!0===s.reflect&&this._$Em!==t&&(this._$Ej??(this._$Ej=new Set)).add(t)}async _$ET(){this.isUpdatePending=!0;try{await this._$ES}catch(t){Promise.reject(t)}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var t;if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??(this.renderRoot=this.createRenderRoot()),this._$Ep){for(const[t,e]of this._$Ep)this[t]=e;this._$Ep=void 0}const t=this.constructor.elementProperties;if(t.size>0)for(const[e,s]of t)!0!==s.wrapped||this._$AL.has(e)||void 0===this[e]||this.P(e,this[e],s)}let e=!1;const s=this._$AL;try{e=this.shouldUpdate(s),e?(this.willUpdate(s),null==(t=this._$EO)||t.forEach((t=>{var e;return null==(e=t.hostUpdate)?void 0:e.call(t)})),this.update(s)):this._$EU()}catch(t){throw e=!1,this._$EU(),t}e&&this._$AE(s)}willUpdate(t){}_$AE(t){var e;null==(e=this._$EO)||e.forEach((t=>{var e;return null==(e=t.hostUpdated)?void 0:e.call(t)})),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EU(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Ej&&(this._$Ej=this._$Ej.forEach((t=>this._$EC(t,this[t])))),this._$EU()}updated(t){}firstUpdated(t){}}w.elementStyles=[],w.shadowRootOptions={mode:"open"},w[L("elementProperties")]=new Map,w[L("finalized")]=new Map,null==B||B({ReactiveElement:w}),($.reactiveElementVersions??($.reactiveElementVersions=[])).push("2.0.4");
|
|
12
12
|
/**
|
|
13
13
|
* @license
|
|
14
14
|
* Copyright 2017 Google LLC
|
|
15
15
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
16
16
|
*/
|
|
17
|
-
const
|
|
17
|
+
const k=globalThis,z=k.trustedTypes,Q=z?z.createPolicy("lit-html",{createHTML:t=>t}):void 0,b=`lit$${Math.random().toFixed(9).slice(2)}$`,at="?"+b,At=`<${at}>`,x=document,T=()=>x.createComment(""),M=t=>null===t||"object"!=typeof t&&"function"!=typeof t,lt=Array.isArray,D="[ \t\n\f\r]",P=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,X=/-->/g,tt=/>/g,v=RegExp(`>|${D}(?:([^\\s"'>=/]+)(${D}*=${D}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),et=/'/g,st=/"/g,dt=/^(?:script|style|textarea|title)$/i,u=(s=1,(t,...e)=>({_$litType$:s,strings:t,values:e})),E=Symbol.for("lit-noChange"),h=Symbol.for("lit-nothing"),it=new WeakMap,A=x.createTreeWalker(x,129);var s;function pt(t,e){if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==Q?Q.createHTML(e):e}class U{constructor({strings:t,_$litType$:e},s){let i;this.parts=[];let o=0,n=0;const r=t.length-1,l=this.parts,[a,d]=((t,e)=>{const s=t.length-1,i=[];let o,n=2===e?"<svg>":"",r=P;for(let e=0;e<s;e++){const s=t[e];let l,a,d=-1,h=0;for(;h<s.length&&(r.lastIndex=h,a=r.exec(s),null!==a);)h=r.lastIndex,r===P?"!--"===a[1]?r=X:void 0!==a[1]?r=tt:void 0!==a[2]?(dt.test(a[2])&&(o=RegExp("</"+a[2],"g")),r=v):void 0!==a[3]&&(r=v):r===v?">"===a[0]?(r=o??P,d=-1):void 0===a[1]?d=-2:(d=r.lastIndex-a[2].length,l=a[1],r=void 0===a[3]?v:'"'===a[3]?st:et):r===st||r===et?r=v:r===X||r===tt?r=P:(r=v,o=void 0);const p=r===v&&t[e+1].startsWith("/>")?" ":"";n+=r===P?s+At:d>=0?(i.push(l),s.slice(0,d)+"$lit$"+s.slice(d)+b+p):s+b+(-2===d?e:p)}return[pt(t,n+(t[s]||"<?>")+(2===e?"</svg>":"")),i]})(t,e);if(this.el=U.createElement(a,s),A.currentNode=this.el.content,2===e){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes)}for(;null!==(i=A.nextNode())&&l.length<r;){if(1===i.nodeType){if(i.hasAttributes())for(const t of i.getAttributeNames())if(t.endsWith("$lit$")){const e=d[n++],s=i.getAttribute(t).split(b),r=/([.?@])?(.*)/.exec(e);l.push({type:1,index:o,name:r[2],strings:s,ctor:"."===r[1]?Ct:"?"===r[1]?Pt:"@"===r[1]?Lt:H}),i.removeAttribute(t)}else t.startsWith(b)&&(l.push({type:6,index:o}),i.removeAttribute(t));if(dt.test(i.tagName)){const t=i.textContent.split(b),e=t.length-1;if(e>0){i.textContent=z?z.emptyScript:"";for(let s=0;s<e;s++)i.append(t[s],T()),A.nextNode(),l.push({type:2,index:++o});i.append(t[e],T())}}}else if(8===i.nodeType)if(i.data===at)l.push({type:2,index:o});else{let t=-1;for(;-1!==(t=i.data.indexOf(b,t+1));)l.push({type:7,index:o}),t+=b.length-1}o++}}static createElement(t,e){const s=x.createElement("template");return s.innerHTML=t,s}}function C(t,e,s=t,i){var o,n;if(e===E)return e;let r=void 0!==i?null==(o=s._$Co)?void 0:o[i]:s._$Cl;const l=M(e)?void 0:e._$litDirective$;return(null==r?void 0:r.constructor)!==l&&(null==(n=null==r?void 0:r._$AO)||n.call(r,!1),void 0===l?r=void 0:(r=new l(t),r._$AT(t,s,i)),void 0!==i?(s._$Co??(s._$Co=[]))[i]=r:s._$Cl=r),void 0!==r&&(e=C(t,r._$AS(t,e.values),r,i)),e}class Et{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:e},parts:s}=this._$AD,i=((null==t?void 0:t.creationScope)??x).importNode(e,!0);A.currentNode=i;let o=A.nextNode(),n=0,r=0,l=s[0];for(;void 0!==l;){if(n===l.index){let e;2===l.type?e=new R(o,o.nextSibling,this,t):1===l.type?e=new l.ctor(o,l.name,l.strings,this,t):6===l.type&&(e=new kt(o,this,t)),this._$AV.push(e),l=s[++r]}n!==(null==l?void 0:l.index)&&(o=A.nextNode(),n++)}return A.currentNode=x,i}p(t){let e=0;for(const s of this._$AV)void 0!==s&&(void 0!==s.strings?(s._$AI(t,s,e),e+=s.strings.length-2):s._$AI(t[e])),e++}}class R{get _$AU(){var t;return(null==(t=this._$AM)?void 0:t._$AU)??this._$Cv}constructor(t,e,s,i){this.type=2,this._$AH=h,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=s,this.options=i,this._$Cv=(null==i?void 0:i.isConnected)??!0}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return void 0!==e&&11===(null==t?void 0:t.nodeType)&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=C(this,t,e),M(t)?t===h||null==t||""===t?(this._$AH!==h&&this._$AR(),this._$AH=h):t!==this._$AH&&t!==E&&this._(t):void 0!==t._$litType$?this.$(t):void 0!==t.nodeType?this.T(t):(t=>lt(t)||"function"==typeof(null==t?void 0:t[Symbol.iterator]))(t)?this.k(t):this._(t)}S(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.S(t))}_(t){this._$AH!==h&&M(this._$AH)?this._$AA.nextSibling.data=t:this.T(x.createTextNode(t)),this._$AH=t}$(t){var e;const{values:s,_$litType$:i}=t,o="number"==typeof i?this._$AC(t):(void 0===i.el&&(i.el=U.createElement(pt(i.h,i.h[0]),this.options)),i);if((null==(e=this._$AH)?void 0:e._$AD)===o)this._$AH.p(s);else{const t=new Et(o,this),e=t.u(this.options);t.p(s),this.T(e),this._$AH=t}}_$AC(t){let e=it.get(t.strings);return void 0===e&&it.set(t.strings,e=new U(t)),e}k(t){lt(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let s,i=0;for(const o of t)i===e.length?e.push(s=new R(this.S(T()),this.S(T()),this,this.options)):s=e[i],s._$AI(o),i++;i<e.length&&(this._$AR(s&&s._$AB.nextSibling,i),e.length=i)}_$AR(t=this._$AA.nextSibling,e){var s;for(null==(s=this._$AP)||s.call(this,!1,!0,e);t&&t!==this._$AB;){const e=t.nextSibling;t.remove(),t=e}}setConnected(t){var e;void 0===this._$AM&&(this._$Cv=t,null==(e=this._$AP)||e.call(this,t))}}class H{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,s,i,o){this.type=1,this._$AH=h,this._$AN=void 0,this.element=t,this.name=e,this._$AM=i,this.options=o,s.length>2||""!==s[0]||""!==s[1]?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=h}_$AI(t,e=this,s,i){const o=this.strings;let n=!1;if(void 0===o)t=C(this,t,e,0),n=!M(t)||t!==this._$AH&&t!==E,n&&(this._$AH=t);else{const i=t;let r,l;for(t=o[0],r=0;r<o.length-1;r++)l=C(this,i[s+r],e,r),l===E&&(l=this._$AH[r]),n||(n=!M(l)||l!==this._$AH[r]),l===h?t=h:t!==h&&(t+=(l??"")+o[r+1]),this._$AH[r]=l}n&&!i&&this.j(t)}j(t){t===h?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}class Ct extends H{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===h?void 0:t}}class Pt extends H{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==h)}}class Lt extends H{constructor(t,e,s,i,o){super(t,e,s,i,o),this.type=5}_$AI(t,e=this){if((t=C(this,t,e,0)??h)===E)return;const s=this._$AH,i=t===h&&s!==h||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,o=t!==h&&(s===h||i);i&&this.element.removeEventListener(this.name,this,s),o&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var e;"function"==typeof this._$AH?this._$AH.call((null==(e=this.options)?void 0:e.host)??this.element,t):this._$AH.handleEvent(t)}}class kt{constructor(t,e,s){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=s}get _$AU(){return this._$AM._$AU}_$AI(t){C(this,t)}}const j=k.litHtmlPolyfillSupport;null==j||j(U,R),(k.litHtmlVersions??(k.litHtmlVersions=[])).push("3.1.3");
|
|
18
18
|
/**
|
|
19
19
|
* @license
|
|
20
20
|
* Copyright 2017 Google LLC
|
|
21
21
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
22
22
|
*/
|
|
23
|
-
class
|
|
23
|
+
class S extends w{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var t;const e=super.createRenderRoot();return(t=this.renderOptions).renderBefore??(t.renderBefore=e.firstChild),e}update(t){const e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=((t,e,s)=>{const i=(null==s?void 0:s.renderBefore)??e;let o=i._$litPart$;if(void 0===o){const t=(null==s?void 0:s.renderBefore)??null;i._$litPart$=o=new R(e.insertBefore(T(),t),t,void 0,s??{})}return o._$AI(t),o})(e,this.renderRoot,this.renderOptions)}connectedCallback(){var t;super.connectedCallback(),null==(t=this._$Do)||t.setConnected(!0)}disconnectedCallback(){var t;super.disconnectedCallback(),null==(t=this._$Do)||t.setConnected(!1)}render(){return E}}var ot;S._$litElement$=!0,S.finalized=!0,null==(ot=globalThis.litElementHydrateSupport)||ot.call(globalThis,{LitElement:S});const q=globalThis.litElementPolyfillSupport;null==q||q({LitElement:S}),(globalThis.litElementVersions??(globalThis.litElementVersions=[])).push("4.0.5");
|
|
24
24
|
/**
|
|
25
25
|
* @license
|
|
26
26
|
* Copyright 2017 Google LLC
|
|
27
27
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
28
28
|
*/
|
|
29
|
-
const
|
|
29
|
+
const ht=t=>(e,s)=>{void 0!==s?s.addInitializer((()=>{customElements.define(t,e)})):customElements.define(t,e)}
|
|
30
30
|
/**
|
|
31
31
|
* @license
|
|
32
32
|
* Copyright 2017 Google LLC
|
|
33
33
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
34
|
-
|
|
34
|
+
*/,Mt={attribute:!0,type:String,converter:I,reflect:!1,hasChanged:W},Ut=(t=Mt,e,s)=>{const{kind:i,metadata:o}=s;let n=globalThis.litPropertyMetadata.get(o);if(void 0===n&&globalThis.litPropertyMetadata.set(o,n=new Map),n.set(s.name,t),"accessor"===i){const{name:i}=s;return{set(s){const o=e.get.call(this);e.set.call(this,s),this.requestUpdate(i,o,t)},init(e){return void 0!==e&&this.P(i,void 0,t),e}}}if("setter"===i){const{name:i}=s;return function(s){const o=this[i];e.call(this,s),this.requestUpdate(i,o,t)}}throw Error("Unsupported decorator location: "+i)};function y(t){return(e,s)=>"object"==typeof s?Ut(t,e,s):((t,e,s)=>{const i=e.hasOwnProperty(s);return e.constructor.createProperty(s,i?{...t,wrapped:!0}:t),i?Object.getOwnPropertyDescriptor(e,s):void 0})(t,e,s)}
|
|
35
35
|
/**
|
|
36
36
|
* @license
|
|
37
37
|
* Copyright 2017 Google LLC
|
|
38
38
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
39
|
-
*/
|
|
40
|
-
/**
|
|
41
|
-
* @license
|
|
42
|
-
* Copyright 2017 Google LLC
|
|
43
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
44
|
-
*/
|
|
45
|
-
const it=(t,e,s)=>(s.configurable=!0,s.enumerable=!0,Reflect.decorate&&"object"!=typeof e&&Object.defineProperty(t,e,s),s)
|
|
46
|
-
/**
|
|
47
|
-
* @license
|
|
48
|
-
* Copyright 2017 Google LLC
|
|
49
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
50
|
-
*/;class Nt{get extId(){return this.attributes["ext-id"]}}var It=Object.defineProperty,Bt=Object.getOwnPropertyDescriptor,g=(t,e,s,i)=>{for(var o,n=i>1?void 0:i?Bt(e,s):e,r=t.length-1;r>=0;r--)(o=t[r])&&(n=(i?o(e,s,n):o(n))||n);return i&&n&&It(e,s,n),n};let m=class extends T{constructor(){var t,e,s,i,o,n;super(...arguments),this.selectedRadius=25,this.radiusOption=[10,25,50],this.getByAddress=null==(e=null==(t=window.miam)?void 0:t.pos)?void 0:e.getByAddress,this.getByCoordinates=null==(i=null==(s=window.miam)?void 0:s.pos)?void 0:i.getByCoordinates,this.getAffiliateSuppliers=null==(n=null==(o=window.miam)?void 0:o.supplier)?void 0:n.getAffiliateSuppliers,this._posList=[],this._markers=[],this._searchingPos=!1,this._searchSubmitted=!1,this._previousSearchMethod=()=>{},this._suppliers=[],this._selectedSuppliers=[],this._showPosList=!1}set geolocationCoordinates(t){var e,s;this._geolocationCoordinates=t,null!=(e=null==t?void 0:t.coords)&&e.latitude&&null!=(s=null==t?void 0:t.coords)&&s.longitude&&this.getPosByCoordinates()}get geolocationCoordinates(){return this._geolocationCoordinates}_nameOfStore(t){return`${t.supplier.attributes.name} - ${t.attributes.name}`}connectedCallback(){super.connectedCallback(),console.debug("[MealzComponents] loading store locator"),this.initLeaflet(),this.fetchSuppliers()}disconnectedCallback(){super.disconnectedCallback(),this._leafletCss.remove(),this._miamDs.remove(),this._leafletJs.remove()}render(){if(this.show)return this.posSelectionTemplate()}firstUpdated(){this.loadMap(),this.geolocationTimeout(),this.listenFormSubmit()}posSelectionTemplate(){return u`
|
|
39
|
+
*/class It{get extId(){return this.attributes["ext-id"]}}var zt=Object.defineProperty,Ht=Object.getOwnPropertyDescriptor,g=(t,e,s,i)=>{for(var o,n=i>1?void 0:i?Ht(e,s):e,r=t.length-1;r>=0;r--)(o=t[r])&&(n=(i?o(e,s,n):o(n))||n);return i&&n&&zt(e,s,n),n};let m=class extends S{constructor(){var t,e,s,i,o,n;super(...arguments),this.selectedRadius=25,this.radiusOption=[10,25,50],this.getByAddress=null==(e=null==(t=window.miam)?void 0:t.pos)?void 0:e.getByAddress,this.getByCoordinates=null==(i=null==(s=window.miam)?void 0:s.pos)?void 0:i.getByCoordinates,this.getAffiliateSuppliers=null==(n=null==(o=window.miam)?void 0:o.supplier)?void 0:n.getAffiliateSuppliers,this._posList=[],this._markers=[],this._searchingPos=!1,this._searchSubmitted=!1,this._previousSearchMethod=()=>{},this._suppliers=[],this._selectedSuppliers=[],this._showPosList=!1}set geolocationCoordinates(t){var e,s;this._geolocationCoordinates=t,null!=(e=null==t?void 0:t.coords)&&e.latitude&&null!=(s=null==t?void 0:t.coords)&&s.longitude&&this.getPosByCoordinates()}get geolocationCoordinates(){return this._geolocationCoordinates}_nameOfStore(t){return`${t.supplier.attributes.name} - ${t.attributes.name}`}connectedCallback(){super.connectedCallback(),console.debug("[MealzComponents] loading store locator"),this.initLeaflet(),this.fetchSuppliers()}disconnectedCallback(){super.disconnectedCallback(),this._leafletCss.remove(),this._miamDs.remove(),this._leafletJs.remove()}render(){if(this.show)return this.posSelectionTemplate()}firstUpdated(){this.loadMap(),this.geolocationTimeout(),this.listenFormSubmit()}posSelectionTemplate(){return u`
|
|
51
40
|
<div class="wrapper miam-ds-body">
|
|
52
41
|
<div class="pos-selection">
|
|
53
42
|
<div class="title">
|
|
@@ -120,7 +109,7 @@ const it=(t,e,s)=>(s.configurable=!0,s.enumerable=!0,Reflect.decorate&&"object"!
|
|
|
120
109
|
</div>
|
|
121
110
|
`))}
|
|
122
111
|
</div>
|
|
123
|
-
`}getButtonLabel(){if(this._showPosList)return"Voir la carte";const t=this._posList.length;return 1===t?"Voir le magasin":`Voir les ${t} magasins`}setAddress(t=!1){if(!this._addressInput.value||this._addressInput.value.length<3||this._searchingPos||!t&&this._prevAddress===this._addressInput.value+", France")return;const e=this.shadowRoot.getElementById("pos-list");e&&"none"===e.style.display&&this.togglePosList(!0),this._previousSearchMethod=this.setAddress,this._prevAddress=this._addressInput.value+", France",this._searchingPos=!0,this.requestUpdate(),this.getByAddress(this._prevAddress,this.selectedRadius,this._selectedSuppliers).subscribe((t=>{this.setPosList(t),this.setNewLocation(),this._searchingPos=!1,this._searchSubmitted=!0,this.requestUpdate()}))}setGeolocation(t=!1){const e=this.shadowRoot.getElementById("pos-list");e&&"none"===e.style.display&&this.togglePosList(!0),this._prevAddress="",this._previousSearchMethod=this.setGeolocation,this.getPosByCoordinates()}getPosByCoordinates(){this._searchingPos=!0,this.requestUpdate(),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.requestUpdate()}))}setPosList(t){this._posList=t.data.map((e=>{const s=Object.assign(new
|
|
112
|
+
`}getButtonLabel(){if(this._showPosList)return"Voir la carte";const t=this._posList.length;return 1===t?"Voir le magasin":`Voir les ${t} magasins`}setAddress(t=!1){if(!this._addressInput.value||this._addressInput.value.length<3||this._searchingPos||!t&&this._prevAddress===this._addressInput.value+", France")return;const e=this.shadowRoot.getElementById("pos-list");e&&"none"===e.style.display&&this.togglePosList(!0),this._previousSearchMethod=this.setAddress,this._prevAddress=this._addressInput.value+", France",this._searchingPos=!0,this.requestUpdate(),this.getByAddress(this._prevAddress,this.selectedRadius,this._selectedSuppliers).subscribe((t=>{this.setPosList(t),this.setNewLocation(),this._searchingPos=!1,this._searchSubmitted=!0,this.requestUpdate()}))}setGeolocation(t=!1){const e=this.shadowRoot.getElementById("pos-list");e&&"none"===e.style.display&&this.togglePosList(!0),this._prevAddress="",this._previousSearchMethod=this.setGeolocation,this.getPosByCoordinates()}getPosByCoordinates(){this._searchingPos=!0,this.requestUpdate(),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.requestUpdate()}))}setPosList(t){this._posList=t.data.map((e=>{const s=Object.assign(new It,e);return s.supplier=t.included.find((t=>t.id===s.relationships.supplier.data.id)),s}))}dispatchPos(t){const e={detail:{posId:t.id,posExtId:t.extId,supplierId:t.supplier.id,posName:this._nameOfStore(t)},bubbles:!0,composed:!0};console.debug("[MealzComponents] dispatchEvent posIdChange",e),this.dispatchEvent(new CustomEvent("posIdChange",e))}dispatchShow(t){const e={detail:{show:t},bubbles:!0,composed:!0};console.debug("[MealzComponents] dispatchEvent showChange",e),this.dispatchEvent(new CustomEvent("showChange",e))}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 e=50;console.debug("[Map] Checking for window.L");const s=setInterval((()=>{void 0!==window.L||0===e?(clearInterval(s),void 0!==window.L?(console.debug("[Map] window.L is defined"),t(!0)):(console.error("[Map] Failed to load Leaflet after",5e3,"ms"),t(!1))):e--}),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()}))}fetchSuppliers(){this.getAffiliateSuppliers().subscribe((t=>{this._suppliers=t.map((t=>({id:t.id,name:t.attributes.name}))),this.requestUpdate()}))}setNewLocation(){var t;const e=this.shadowRoot.getElementById("map");e&&(this._map?(this._markers.forEach((t=>{this._map.removeLayer(t)})),this._markers=[],this._map.panTo(this.getCoordinates())):this._map=null==(t=window.L)?void 0:t.map(e).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:`\n <div class="pos-item">\n <div class="top">\n <img class="pos-img" src="${t.supplier.attributes.logo}" alt="${t.supplier.attributes.name}"/>\n <div class="top-right">\n <div class="name">${this._nameOfStore(t)}</div>\n <div class="address">${t.attributes.address}</div>\n </div>\n </div>\n <div class="bottom">\n <button id="select" class="miam-ds-button primary select-pos-button">Sélectionner</button>\n </div>\n </div>\n `});this._markers[e].bindPopup(s).on("popupopen",(e=>{e.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){const e=this.shadowRoot.getElementById("pos-list"),s=this.shadowRoot.getElementById("mobile-buttons-wrapper");!e||!s||(t?(e.style.display="none",s.className="mobile-buttons-wrapper__see-list"):(e.style.display="flex",s.className="mobile-buttons-wrapper__see-map"),this._showPosList=!this._showPosList,this.requestUpdate())}geolocationTimeout(){setTimeout((()=>{void 0===this.geolocationCoordinates&&(this.geolocationCoordinates={})}),2e4)}listenFormSubmit(){this.shadowRoot.getElementById("store-locator-form").addEventListener("submit",(t=>{t.preventDefault(),this.setAddress()}))}};m.styles=[((t,...e)=>{const s=1===t.length?t[0]:e.reduce(((e,s,i)=>e+(t=>{if(!0===t._$cssResult$)return t.cssText;if("number"==typeof t)return t;throw Error("Value passed to 'css' function must be a 'css' function result: "+t+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(s)+t[i+1]),t[0]);return new nt(s,t,J)})`
|
|
124
113
|
:host {
|
|
125
114
|
display: block;
|
|
126
115
|
height: 100%;
|
|
@@ -437,4 +426,15 @@ const it=(t,e,s)=>(s.configurable=!0,s.enumerable=!0,Reflect.decorate&&"object"!
|
|
|
437
426
|
top: 0;
|
|
438
427
|
}
|
|
439
428
|
}
|
|
440
|
-
`],g([y({type:Boolean})],m.prototype,"show",2),g([y({type:Number})],m.prototype,"selectedRadius",2),g([y({type:Array})],m.prototype,"radiusOption",2),g([y({type:GeolocationPosition})],m.prototype,"geolocationCoordinates",1),g([y()],m.prototype,"getByAddress",2),g([y()],m.prototype,"getByCoordinates",2),g([y()],m.prototype,"getAffiliateSuppliers",2),g([function(t){return y({...t,state:!0,attribute:!1})}
|
|
429
|
+
`],g([y({type:Boolean})],m.prototype,"show",2),g([y({type:Number})],m.prototype,"selectedRadius",2),g([y({type:Array})],m.prototype,"radiusOption",2),g([y({type:GeolocationPosition})],m.prototype,"geolocationCoordinates",1),g([y()],m.prototype,"getByAddress",2),g([y()],m.prototype,"getByCoordinates",2),g([y()],m.prototype,"getAffiliateSuppliers",2),g([function(t){return y({...t,state:!0,attribute:!1})}
|
|
430
|
+
/**
|
|
431
|
+
* @license
|
|
432
|
+
* Copyright 2017 Google LLC
|
|
433
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
434
|
+
*/()],m.prototype,"_geolocationCoordinates",2),g([
|
|
435
|
+
/**
|
|
436
|
+
* @license
|
|
437
|
+
* Copyright 2017 Google LLC
|
|
438
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
439
|
+
*/
|
|
440
|
+
function(t,e){return(e,s,i)=>((t,e,s)=>(s.configurable=!0,s.enumerable=!0,Reflect.decorate&&"object"!=typeof e&&Object.defineProperty(t,e,s),s))(e,s,{get(){return(null==(e=this.renderRoot)?void 0:e.querySelector(t))??null;var e}})}("input")],m.prototype,"_addressInput",2),m=g([ht("mealz-store-locator")],m),window.customElements.get("mealz-store-locator")||window.customElements.define("mealz-store-locator",m);class Bt extends S{createRenderRoot(){return this}}let V=class extends Bt{constructor(){super(...arguments),this.liked=null,this.recipeLikeId="",this.requestHeaders=new Headers}connectedCallback(){super.connectedCallback(),console.debug("[MealzComponents] loading like button"),this.requestHeaders.append("Authorization","Bearer <your-token>"),this.requestHeaders.append("miam-origin","partners"),this.requestHeaders.append("Content-Type","application/vnd.api+json")}render(){this.button=this.querySelector(".mealz-like-button"),this.button&&(this.getInitialStatus(),this.recipeLikeId&&this.button.addEventListener("click",(()=>this.toggle())),console.log(this.button))}getInitialStatus(){var t;const e=null==(t=this.attributes["starting-data"])?void 0:t.value;if(console.log(e),!e)return;const{id:s,liked:i}=JSON.parse(e);this.recipeLikeId=s,this.liked=i,this.removeAttribute("starting-data")}async toggle(){var t,e;const s=JSON.stringify({data:{type:"recipe-likes",id:1,attributes:{"is-past":this.liked}}}),i=await fetch(`http://localhost:3000/api/v1/recipe-likes/${this.recipeLikeId}`,{headers:this.requestHeaders,method:"PATCH",body:s}).then((t=>t.json()));this.liked=!(null!=(e=null==(t=i.data)?void 0:t.attributes)&&e["is-past"]),this.updateDOM()}updateDOM(){this.button.querySelector(".mealz-like-button__icon").classList.toggle("fill",this.liked),this.button.querySelectorAll(".mealz-like-button__icon img").forEach((t=>t.classList.toggle("active")))}};V=((t,e,s,i)=>{for(var o,n=e,r=t.length-1;r>=0;r--)(o=t[r])&&(n=o(n)||n);return n})([ht("mealz-like-button")],V),window.customElements.get("mealz-like-button")||window.customElements.define("mealz-like-button",V);export{V as MealzLikeButton,m as MealzStoreLocator};
|
|
@@ -2,41 +2,41 @@
|
|
|
2
2
|
* @license
|
|
3
3
|
* Copyright 2019 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
5
|
-
*/var
|
|
5
|
+
*/var ht;const _=globalThis,H=_.ShadowRoot&&(_.ShadyCSS===void 0||_.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,D=Symbol(),W=new WeakMap;let G=class{constructor(t,e,s){if(this._$cssResult$=!0,s!==D)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const e=this.t;if(H&&t===void 0){const s=e!==void 0&&e.length===1;s&&(t=W.get(e)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),s&&W.set(e,t))}return t}toString(){return this.cssText}};const pt=o=>new G(typeof o=="string"?o:o+"",void 0,D),ct=(o,...t)=>{const e=o.length===1?o[0]:t.reduce((s,i,n)=>s+(r=>{if(r._$cssResult$===!0)return r.cssText;if(typeof r=="number")return r;throw Error("Value passed to 'css' function must be a 'css' function result: "+r+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(i)+o[n+1],o[0]);return new G(e,o,D)},ut=(o,t)=>{if(H)o.adoptedStyleSheets=t.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet);else for(const e of t){const s=document.createElement("style"),i=_.litNonce;i!==void 0&&s.setAttribute("nonce",i),s.textContent=e.cssText,o.appendChild(s)}},Z=H?o=>o:o=>o instanceof CSSStyleSheet?(t=>{let e="";for(const s of t.cssRules)e+=s.cssText;return pt(e)})(o):o;/**
|
|
6
6
|
* @license
|
|
7
7
|
* Copyright 2017 Google LLC
|
|
8
8
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
9
|
-
*/const{is:mt,defineProperty:gt,getOwnPropertyDescriptor:ft,getOwnPropertyNames:_t,getOwnPropertySymbols:$t
|
|
9
|
+
*/const{is:mt,defineProperty:gt,getOwnPropertyDescriptor:ft,getOwnPropertyNames:_t,getOwnPropertySymbols:bt,getPrototypeOf:$t}=Object,b=globalThis,K=b.trustedTypes,yt=K?K.emptyScript:"",j=b.reactiveElementPolyfillSupport,P=(o,t)=>o,R={toAttribute(o,t){switch(t){case Boolean:o=o?yt:null;break;case Object:case Array:o=o==null?o:JSON.stringify(o)}return o},fromAttribute(o,t){let e=o;switch(t){case Boolean:e=o!==null;break;case Number:e=o===null?null:Number(o);break;case Object:case Array:try{e=JSON.parse(o)}catch{e=null}}return e}},q=(o,t)=>!mt(o,t),Y={attribute:!0,type:String,converter:R,reflect:!1,hasChanged:q};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),b.litPropertyMetadata??(b.litPropertyMetadata=new WeakMap);class S extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??(this.l=[])).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,e=Y){if(e.state&&(e.attribute=!1),this._$Ei(),this.elementProperties.set(t,e),!e.noAccessor){const s=Symbol(),i=this.getPropertyDescriptor(t,s,e);i!==void 0&>(this.prototype,t,i)}}static getPropertyDescriptor(t,e,s){const{get:i,set:n}=ft(this.prototype,t)??{get(){return this[e]},set(r){this[e]=r}};return{get(){return i==null?void 0:i.call(this)},set(r){const l=i==null?void 0:i.call(this);n.call(this,r),this.requestUpdate(t,l,s)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??Y}static _$Ei(){if(this.hasOwnProperty(P("elementProperties")))return;const t=$t(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(P("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(P("properties"))){const e=this.properties,s=[..._t(e),...bt(e)];for(const i of s)this.createProperty(i,e[i])}const t=this[Symbol.metadata];if(t!==null){const e=litPropertyMetadata.get(t);if(e!==void 0)for(const[s,i]of e)this.elementProperties.set(s,i)}this._$Eh=new Map;for(const[e,s]of this.elementProperties){const i=this._$Eu(e,s);i!==void 0&&this._$Eh.set(i,e)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const s=new Set(t.flat(1/0).reverse());for(const i of s)e.unshift(Z(i))}else t!==void 0&&e.push(Z(t));return e}static _$Eu(t,e){const s=e.attribute;return s===!1?void 0:typeof s=="string"?s:typeof t=="string"?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){var t;this._$ES=new Promise(e=>this.enableUpdating=e),this._$AL=new Map,this._$E_(),this.requestUpdate(),(t=this.constructor.l)==null||t.forEach(e=>e(this))}addController(t){var e;(this._$EO??(this._$EO=new Set)).add(t),this.renderRoot!==void 0&&this.isConnected&&((e=t.hostConnected)==null||e.call(t))}removeController(t){var e;(e=this._$EO)==null||e.delete(t)}_$E_(){const t=new Map,e=this.constructor.elementProperties;for(const s of e.keys())this.hasOwnProperty(s)&&(t.set(s,this[s]),delete this[s]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return ut(t,this.constructor.elementStyles),t}connectedCallback(){var t;this.renderRoot??(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(t=this._$EO)==null||t.forEach(e=>{var s;return(s=e.hostConnected)==null?void 0:s.call(e)})}enableUpdating(t){}disconnectedCallback(){var t;(t=this._$EO)==null||t.forEach(e=>{var s;return(s=e.hostDisconnected)==null?void 0:s.call(e)})}attributeChangedCallback(t,e,s){this._$AK(t,s)}_$EC(t,e){var n;const s=this.constructor.elementProperties.get(t),i=this.constructor._$Eu(t,s);if(i!==void 0&&s.reflect===!0){const r=(((n=s.converter)==null?void 0:n.toAttribute)!==void 0?s.converter:R).toAttribute(e,s.type);this._$Em=t,r==null?this.removeAttribute(i):this.setAttribute(i,r),this._$Em=null}}_$AK(t,e){var n;const s=this.constructor,i=s._$Eh.get(t);if(i!==void 0&&this._$Em!==i){const r=s.getPropertyOptions(i),l=typeof r.converter=="function"?{fromAttribute:r.converter}:((n=r.converter)==null?void 0:n.fromAttribute)!==void 0?r.converter:R;this._$Em=i,this[i]=l.fromAttribute(e,r.type),this._$Em=null}}requestUpdate(t,e,s){if(t!==void 0){if(s??(s=this.constructor.getPropertyOptions(t)),!(s.hasChanged??q)(this[t],e))return;this.P(t,e,s)}this.isUpdatePending===!1&&(this._$ES=this._$ET())}P(t,e,s){this._$AL.has(t)||this._$AL.set(t,e),s.reflect===!0&&this._$Em!==t&&(this._$Ej??(this._$Ej=new Set)).add(t)}async _$ET(){this.isUpdatePending=!0;try{await this._$ES}catch(e){Promise.reject(e)}const t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var s;if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??(this.renderRoot=this.createRenderRoot()),this._$Ep){for(const[n,r]of this._$Ep)this[n]=r;this._$Ep=void 0}const i=this.constructor.elementProperties;if(i.size>0)for(const[n,r]of i)r.wrapped!==!0||this._$AL.has(n)||this[n]===void 0||this.P(n,this[n],r)}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),(s=this._$EO)==null||s.forEach(i=>{var n;return(n=i.hostUpdate)==null?void 0:n.call(i)}),this.update(e)):this._$EU()}catch(i){throw t=!1,this._$EU(),i}t&&this._$AE(e)}willUpdate(t){}_$AE(t){var e;(e=this._$EO)==null||e.forEach(s=>{var i;return(i=s.hostUpdated)==null?void 0:i.call(s)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EU(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Ej&&(this._$Ej=this._$Ej.forEach(e=>this._$EC(e,this[e]))),this._$EU()}updated(t){}firstUpdated(t){}}S.elementStyles=[],S.shadowRootOptions={mode:"open"},S[P("elementProperties")]=new Map,S[P("finalized")]=new Map,j==null||j({ReactiveElement:S}),(b.reactiveElementVersions??(b.reactiveElementVersions=[])).push("2.0.4");/**
|
|
10
10
|
* @license
|
|
11
11
|
* Copyright 2017 Google LLC
|
|
12
12
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
13
|
-
*/const
|
|
14
|
-
\f\r]`,
|
|
15
|
-
\f\r"'\`<>=]|("|')|))|$)`,"g"),ot=/'/g,nt=/"/g,rt=/^(?:script|style|textarea|title)$/i,wt=o=>(t,...e)=>({_$litType$:o,strings:t,values:e}),m=wt(1),E=Symbol.for("lit-noChange"),
|
|
13
|
+
*/const k=globalThis,N=k.trustedTypes,Q=N?N.createPolicy("lit-html",{createHTML:o=>o}):void 0,X="$lit$",$=`lit$${Math.random().toFixed(9).slice(2)}$`,tt="?"+$,vt=`<${tt}>`,A=document,M=()=>A.createComment(""),z=o=>o===null||typeof o!="object"&&typeof o!="function",et=Array.isArray,At=o=>et(o)||typeof(o==null?void 0:o[Symbol.iterator])=="function",V=`[
|
|
14
|
+
\f\r]`,T=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,st=/-->/g,it=/>/g,w=RegExp(`>|${V}(?:([^\\s"'>=/]+)(${V}*=${V}*(?:[^
|
|
15
|
+
\f\r"'\`<>=]|("|')|))|$)`,"g"),ot=/'/g,nt=/"/g,rt=/^(?:script|style|textarea|title)$/i,wt=o=>(t,...e)=>({_$litType$:o,strings:t,values:e}),m=wt(1),E=Symbol.for("lit-noChange"),p=Symbol.for("lit-nothing"),at=new WeakMap,x=A.createTreeWalker(A,129);function lt(o,t){if(!Array.isArray(o)||!o.hasOwnProperty("raw"))throw Error("invalid template strings array");return Q!==void 0?Q.createHTML(t):t}const xt=(o,t)=>{const e=o.length-1,s=[];let i,n=t===2?"<svg>":"",r=T;for(let l=0;l<e;l++){const a=o[l];let c,u,d=-1,f=0;for(;f<a.length&&(r.lastIndex=f,u=r.exec(a),u!==null);)f=r.lastIndex,r===T?u[1]==="!--"?r=st:u[1]!==void 0?r=it:u[2]!==void 0?(rt.test(u[2])&&(i=RegExp("</"+u[2],"g")),r=w):u[3]!==void 0&&(r=w):r===w?u[0]===">"?(r=i??T,d=-1):u[1]===void 0?d=-2:(d=r.lastIndex-u[2].length,c=u[1],r=u[3]===void 0?w:u[3]==='"'?nt:ot):r===nt||r===ot?r=w:r===st||r===it?r=T:(r=w,i=void 0);const v=r===w&&o[l+1].startsWith("/>")?" ":"";n+=r===T?a+vt:d>=0?(s.push(c),a.slice(0,d)+X+a.slice(d)+$+v):a+$+(d===-2?l:v)}return[lt(o,n+(o[e]||"<?>")+(t===2?"</svg>":"")),s]};class U{constructor({strings:t,_$litType$:e},s){let i;this.parts=[];let n=0,r=0;const l=t.length-1,a=this.parts,[c,u]=xt(t,e);if(this.el=U.createElement(c,s),x.currentNode=this.el.content,e===2){const d=this.el.content.firstChild;d.replaceWith(...d.childNodes)}for(;(i=x.nextNode())!==null&&a.length<l;){if(i.nodeType===1){if(i.hasAttributes())for(const d of i.getAttributeNames())if(d.endsWith(X)){const f=u[r++],v=i.getAttribute(d).split($),B=/([.?@])?(.*)/.exec(f);a.push({type:1,index:n,name:B[2],strings:v,ctor:B[1]==="."?Et:B[1]==="?"?Ct:B[1]==="@"?Lt:I}),i.removeAttribute(d)}else d.startsWith($)&&(a.push({type:6,index:n}),i.removeAttribute(d));if(rt.test(i.tagName)){const d=i.textContent.split($),f=d.length-1;if(f>0){i.textContent=N?N.emptyScript:"";for(let v=0;v<f;v++)i.append(d[v],M()),x.nextNode(),a.push({type:2,index:++n});i.append(d[f],M())}}}else if(i.nodeType===8)if(i.data===tt)a.push({type:2,index:n});else{let d=-1;for(;(d=i.data.indexOf($,d+1))!==-1;)a.push({type:7,index:n}),d+=$.length-1}n++}}static createElement(t,e){const s=A.createElement("template");return s.innerHTML=t,s}}function C(o,t,e=o,s){var r,l;if(t===E)return t;let i=s!==void 0?(r=e._$Co)==null?void 0:r[s]:e._$Cl;const n=z(t)?void 0:t._$litDirective$;return(i==null?void 0:i.constructor)!==n&&((l=i==null?void 0:i._$AO)==null||l.call(i,!1),n===void 0?i=void 0:(i=new n(o),i._$AT(o,e,s)),s!==void 0?(e._$Co??(e._$Co=[]))[s]=i:e._$Cl=i),i!==void 0&&(t=C(o,i._$AS(o,t.values),i,s)),t}class St{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:e},parts:s}=this._$AD,i=((t==null?void 0:t.creationScope)??A).importNode(e,!0);x.currentNode=i;let n=x.nextNode(),r=0,l=0,a=s[0];for(;a!==void 0;){if(r===a.index){let c;a.type===2?c=new O(n,n.nextSibling,this,t):a.type===1?c=new a.ctor(n,a.name,a.strings,this,t):a.type===6&&(c=new Pt(n,this,t)),this._$AV.push(c),a=s[++l]}r!==(a==null?void 0:a.index)&&(n=x.nextNode(),r++)}return x.currentNode=A,i}p(t){let e=0;for(const s of this._$AV)s!==void 0&&(s.strings!==void 0?(s._$AI(t,s,e),e+=s.strings.length-2):s._$AI(t[e])),e++}}class O{get _$AU(){var t;return((t=this._$AM)==null?void 0:t._$AU)??this._$Cv}constructor(t,e,s,i){this.type=2,this._$AH=p,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=s,this.options=i,this._$Cv=(i==null?void 0:i.isConnected)??!0}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return e!==void 0&&(t==null?void 0:t.nodeType)===11&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=C(this,t,e),z(t)?t===p||t==null||t===""?(this._$AH!==p&&this._$AR(),this._$AH=p):t!==this._$AH&&t!==E&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):At(t)?this.k(t):this._(t)}S(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.S(t))}_(t){this._$AH!==p&&z(this._$AH)?this._$AA.nextSibling.data=t:this.T(A.createTextNode(t)),this._$AH=t}$(t){var n;const{values:e,_$litType$:s}=t,i=typeof s=="number"?this._$AC(t):(s.el===void 0&&(s.el=U.createElement(lt(s.h,s.h[0]),this.options)),s);if(((n=this._$AH)==null?void 0:n._$AD)===i)this._$AH.p(e);else{const r=new St(i,this),l=r.u(this.options);r.p(e),this.T(l),this._$AH=r}}_$AC(t){let e=at.get(t.strings);return e===void 0&&at.set(t.strings,e=new U(t)),e}k(t){et(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let s,i=0;for(const n of t)i===e.length?e.push(s=new O(this.S(M()),this.S(M()),this,this.options)):s=e[i],s._$AI(n),i++;i<e.length&&(this._$AR(s&&s._$AB.nextSibling,i),e.length=i)}_$AR(t=this._$AA.nextSibling,e){var s;for((s=this._$AP)==null?void 0:s.call(this,!1,!0,e);t&&t!==this._$AB;){const i=t.nextSibling;t.remove(),t=i}}setConnected(t){var e;this._$AM===void 0&&(this._$Cv=t,(e=this._$AP)==null||e.call(this,t))}}class I{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,s,i,n){this.type=1,this._$AH=p,this._$AN=void 0,this.element=t,this.name=e,this._$AM=i,this.options=n,s.length>2||s[0]!==""||s[1]!==""?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=p}_$AI(t,e=this,s,i){const n=this.strings;let r=!1;if(n===void 0)t=C(this,t,e,0),r=!z(t)||t!==this._$AH&&t!==E,r&&(this._$AH=t);else{const l=t;let a,c;for(t=n[0],a=0;a<n.length-1;a++)c=C(this,l[s+a],e,a),c===E&&(c=this._$AH[a]),r||(r=!z(c)||c!==this._$AH[a]),c===p?t=p:t!==p&&(t+=(c??"")+n[a+1]),this._$AH[a]=c}r&&!i&&this.j(t)}j(t){t===p?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}class Et extends I{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===p?void 0:t}}class Ct extends I{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==p)}}class Lt extends I{constructor(t,e,s,i,n){super(t,e,s,i,n),this.type=5}_$AI(t,e=this){if((t=C(this,t,e,0)??p)===E)return;const s=this._$AH,i=t===p&&s!==p||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,n=t!==p&&(s===p||i);i&&this.element.removeEventListener(this.name,this,s),n&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var e;typeof this._$AH=="function"?this._$AH.call(((e=this.options)==null?void 0:e.host)??this.element,t):this._$AH.handleEvent(t)}}class Pt{constructor(t,e,s){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=s}get _$AU(){return this._$AM._$AU}_$AI(t){C(this,t)}}const F=k.litHtmlPolyfillSupport;F==null||F(U,O),(k.litHtmlVersions??(k.litHtmlVersions=[])).push("3.1.3");const kt=(o,t,e)=>{const s=(e==null?void 0:e.renderBefore)??t;let i=s._$litPart$;if(i===void 0){const n=(e==null?void 0:e.renderBefore)??null;s._$litPart$=i=new O(t.insertBefore(M(),n),n,void 0,e??{})}return i._$AI(o),i};/**
|
|
16
16
|
* @license
|
|
17
17
|
* Copyright 2017 Google LLC
|
|
18
18
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
19
|
-
*/class
|
|
19
|
+
*/class L extends S{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=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._$Do=kt(e,this.renderRoot,this.renderOptions)}connectedCallback(){var t;super.connectedCallback(),(t=this._$Do)==null||t.setConnected(!0)}disconnectedCallback(){var t;super.disconnectedCallback(),(t=this._$Do)==null||t.setConnected(!1)}render(){return E}}L._$litElement$=!0,L.finalized=!0,(ht=globalThis.litElementHydrateSupport)==null||ht.call(globalThis,{LitElement:L});const J=globalThis.litElementPolyfillSupport;J==null||J({LitElement:L}),(globalThis.litElementVersions??(globalThis.litElementVersions=[])).push("4.0.5");/**
|
|
20
20
|
* @license
|
|
21
21
|
* Copyright 2017 Google LLC
|
|
22
22
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
23
|
-
*/const
|
|
23
|
+
*/const dt=o=>(t,e)=>{e!==void 0?e.addInitializer(()=>{customElements.define(o,t)}):customElements.define(o,t)};/**
|
|
24
24
|
* @license
|
|
25
25
|
* Copyright 2017 Google LLC
|
|
26
26
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
27
|
-
*/const
|
|
27
|
+
*/const Mt={attribute:!0,type:String,converter:R,reflect:!1,hasChanged:q},zt=(o=Mt,t,e)=>{const{kind:s,metadata:i}=e;let n=globalThis.litPropertyMetadata.get(i);if(n===void 0&&globalThis.litPropertyMetadata.set(i,n=new Map),n.set(e.name,o),s==="accessor"){const{name:r}=e;return{set(l){const a=t.get.call(this);t.set.call(this,l),this.requestUpdate(r,a,o)},init(l){return l!==void 0&&this.P(r,void 0,o),l}}}if(s==="setter"){const{name:r}=e;return function(l){const a=this[r];t.call(this,l),this.requestUpdate(r,a,o)}}throw Error("Unsupported decorator location: "+s)};function y(o){return(t,e)=>typeof e=="object"?zt(o,t,e):((s,i,n)=>{const r=i.hasOwnProperty(n);return i.constructor.createProperty(n,r?{...s,wrapped:!0}:s),r?Object.getOwnPropertyDescriptor(i,n):void 0})(o,t,e)}/**
|
|
28
28
|
* @license
|
|
29
29
|
* Copyright 2017 Google LLC
|
|
30
30
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
31
|
-
*/function
|
|
31
|
+
*/function Tt(o){return y({...o,state:!0,attribute:!1})}/**
|
|
32
32
|
* @license
|
|
33
33
|
* Copyright 2017 Google LLC
|
|
34
34
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
35
|
-
*/const
|
|
35
|
+
*/const Ut=(o,t,e)=>(e.configurable=!0,e.enumerable=!0,Reflect.decorate&&typeof t!="object"&&Object.defineProperty(o,t,e),e);/**
|
|
36
36
|
* @license
|
|
37
37
|
* Copyright 2017 Google LLC
|
|
38
38
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
39
|
-
*/function
|
|
39
|
+
*/function Ot(o,t){return(e,s,i)=>{const n=r=>{var l;return((l=r.renderRoot)==null?void 0:l.querySelector(o))??null};return Ut(e,s,{get(){return n(this)}})}}class Rt{get extId(){return this.attributes["ext-id"]}}var Nt=Object.defineProperty,It=Object.getOwnPropertyDescriptor,g=(o,t,e,s)=>{for(var i=s>1?void 0:s?It(t,e):t,n=o.length-1,r;n>=0;n--)(r=o[n])&&(i=(s?r(t,e,i):r(i))||i);return s&&i&&Nt(t,e,i),i};h.MealzStoreLocator=class extends L{constructor(){var t,e,s,i,n,r;super(...arguments),this.selectedRadius=25,this.radiusOption=[10,25,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=(r=(n=window.miam)==null?void 0:n.supplier)==null?void 0:r.getAffiliateSuppliers,this._posList=[],this._markers=[],this._searchingPos=!1,this._searchSubmitted=!1,this._previousSearchMethod=()=>{},this._suppliers=[],this._selectedSuppliers=[],this._showPosList=!1}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.getPosByCoordinates()}get geolocationCoordinates(){return this._geolocationCoordinates}_nameOfStore(t){return`${t.supplier.attributes.name} - ${t.attributes.name}`}connectedCallback(){super.connectedCallback(),console.debug("[MealzComponents] loading store locator"),this.initLeaflet(),this.fetchSuppliers()}disconnectedCallback(){super.disconnectedCallback(),this._leafletCss.remove(),this._miamDs.remove(),this._leafletJs.remove()}render(){if(this.show)return this.posSelectionTemplate()}firstUpdated(){this.loadMap(),this.geolocationTimeout(),this.listenFormSubmit()}posSelectionTemplate(){return m`
|
|
40
40
|
<div class="wrapper miam-ds-body">
|
|
41
41
|
<div class="pos-selection">
|
|
42
42
|
<div class="title">
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
</div>
|
|
64
64
|
${this.posMapTemplate()}
|
|
65
65
|
</div>
|
|
66
|
-
`}geolocButtonTemplate(){var e,s,i,
|
|
66
|
+
`}geolocButtonTemplate(){var e,s,i,n;let t;if(this.geolocationCoordinates===void 0)t=m`<div class="miam-ds-loader"></div>`;else if((s=(e=this.geolocationCoordinates)==null?void 0:e.coords)!=null&&s.longitude&&((n=(i=this.geolocationCoordinates)==null?void 0:i.coords)!=null&&n.latitude))t=m`<img title="Votre position" class="geolocation-icon" src="https://storage.googleapis.com/assets.miam.tech/generic/icons/locate-primary.svg" alt="Geolocaliser"/>`;else return m``;return m`
|
|
67
67
|
<button type="button" ?disabled=${this.geolocationCoordinates===void 0} class="miam-ds-button square ghost locate-button" @click=${this.setGeolocation}>
|
|
68
68
|
${t}
|
|
69
69
|
</button>
|
|
@@ -109,7 +109,7 @@
|
|
|
109
109
|
</div>
|
|
110
110
|
`)}
|
|
111
111
|
</div>
|
|
112
|
-
`}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){if(!this._addressInput.value||this._addressInput.value.length<3||this._searchingPos||!t&&this._prevAddress===this._addressInput.value+", France")return;const e=this.shadowRoot.getElementById("pos-list");e&&e.style.display==="none"&&this.togglePosList(!0),this._previousSearchMethod=this.setAddress,this._prevAddress=this._addressInput.value+", France",this._searchingPos=!0,this.requestUpdate(),this.getByAddress(this._prevAddress,this.selectedRadius,this._selectedSuppliers).subscribe(s=>{this.setPosList(s),this.setNewLocation(),this._searchingPos=!1,this._searchSubmitted=!0,this.requestUpdate()})}setGeolocation(t=!1){const e=this.shadowRoot.getElementById("pos-list");e&&e.style.display==="none"&&this.togglePosList(!0),this._prevAddress="",this._previousSearchMethod=this.setGeolocation,this.getPosByCoordinates()}getPosByCoordinates(){this._searchingPos=!0,this.requestUpdate(),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.requestUpdate()})}setPosList(t){this._posList=t.data.map(e=>{const s=Object.assign(new
|
|
112
|
+
`}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){if(!this._addressInput.value||this._addressInput.value.length<3||this._searchingPos||!t&&this._prevAddress===this._addressInput.value+", France")return;const e=this.shadowRoot.getElementById("pos-list");e&&e.style.display==="none"&&this.togglePosList(!0),this._previousSearchMethod=this.setAddress,this._prevAddress=this._addressInput.value+", France",this._searchingPos=!0,this.requestUpdate(),this.getByAddress(this._prevAddress,this.selectedRadius,this._selectedSuppliers).subscribe(s=>{this.setPosList(s),this.setNewLocation(),this._searchingPos=!1,this._searchSubmitted=!0,this.requestUpdate()})}setGeolocation(t=!1){const e=this.shadowRoot.getElementById("pos-list");e&&e.style.display==="none"&&this.togglePosList(!0),this._prevAddress="",this._previousSearchMethod=this.setGeolocation,this.getPosByCoordinates()}getPosByCoordinates(){this._searchingPos=!0,this.requestUpdate(),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.requestUpdate()})}setPosList(t){this._posList=t.data.map(e=>{const s=Object.assign(new Rt,e);return s.supplier=t.included.find(i=>i.id===s.relationships.supplier.data.id),s})}dispatchPos(t){const e={detail:{posId:t.id,posExtId:t.extId,supplierId:t.supplier.id,posName:this._nameOfStore(t)},bubbles:!0,composed:!0};console.debug("[MealzComponents] dispatchEvent posIdChange",e),this.dispatchEvent(new CustomEvent("posIdChange",e))}dispatchShow(t){const e={detail:{show:t},bubbles:!0,composed:!0};console.debug("[MealzComponents] dispatchEvent showChange",e),this.dispatchEvent(new CustomEvent("showChange",e))}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 n=setInterval(()=>{window.L!==void 0||i===0?(clearInterval(n),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()})}fetchSuppliers(){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:`
|
|
113
113
|
<div class="pos-item">
|
|
114
114
|
<div class="top">
|
|
115
115
|
<img class="pos-img" src="${t.supplier.attributes.logo}" alt="${t.supplier.attributes.name}"/>
|
|
@@ -439,4 +439,4 @@
|
|
|
439
439
|
top: 0;
|
|
440
440
|
}
|
|
441
441
|
}
|
|
442
|
-
`],g([y({type:Boolean})],h.MealzStoreLocator.prototype,"show",2),g([y({type:Number})],h.MealzStoreLocator.prototype,"selectedRadius",2),g([y({type:Array})],h.MealzStoreLocator.prototype,"radiusOption",2),g([y({type:GeolocationPosition})],h.MealzStoreLocator.prototype,"geolocationCoordinates",1),g([y()],h.MealzStoreLocator.prototype,"getByAddress",2),g([y()],h.MealzStoreLocator.prototype,"getByCoordinates",2),g([y()],h.MealzStoreLocator.prototype,"getAffiliateSuppliers",2),g([
|
|
442
|
+
`],g([y({type:Boolean})],h.MealzStoreLocator.prototype,"show",2),g([y({type:Number})],h.MealzStoreLocator.prototype,"selectedRadius",2),g([y({type:Array})],h.MealzStoreLocator.prototype,"radiusOption",2),g([y({type:GeolocationPosition})],h.MealzStoreLocator.prototype,"geolocationCoordinates",1),g([y()],h.MealzStoreLocator.prototype,"getByAddress",2),g([y()],h.MealzStoreLocator.prototype,"getByCoordinates",2),g([y()],h.MealzStoreLocator.prototype,"getAffiliateSuppliers",2),g([Tt()],h.MealzStoreLocator.prototype,"_geolocationCoordinates",2),g([Ot("input")],h.MealzStoreLocator.prototype,"_addressInput",2),h.MealzStoreLocator=g([dt("mealz-store-locator")],h.MealzStoreLocator),window.customElements.get("mealz-store-locator")||window.customElements.define("mealz-store-locator",h.MealzStoreLocator);class Bt extends L{createRenderRoot(){return this}}var Ht=(o,t,e,s)=>{for(var i=t,n=o.length-1,r;n>=0;n--)(r=o[n])&&(i=r(i)||i);return i};h.MealzLikeButton=class extends Bt{constructor(){super(...arguments),this.liked=null,this.recipeLikeId="",this.requestHeaders=new Headers}connectedCallback(){super.connectedCallback(),console.debug("[MealzComponents] loading like button"),this.requestHeaders.append("Authorization","Bearer <your-token>"),this.requestHeaders.append("miam-origin","partners"),this.requestHeaders.append("Content-Type","application/vnd.api+json")}render(){this.button=this.querySelector(".mealz-like-button"),this.button&&(this.getInitialStatus(),this.recipeLikeId&&this.button.addEventListener("click",()=>this.toggle()),console.log(this.button))}getInitialStatus(){var i;const t=(i=this.attributes["starting-data"])==null?void 0:i.value;if(console.log(t),!t)return;const{id:e,liked:s}=JSON.parse(t);this.recipeLikeId=e,this.liked=s,this.removeAttribute("starting-data")}async toggle(){var s,i;const t=JSON.stringify({data:{type:"recipe-likes",id:1,attributes:{"is-past":this.liked}}}),e=await fetch(`http://localhost:3000/api/v1/recipe-likes/${this.recipeLikeId}`,{headers:this.requestHeaders,method:"PATCH",body:t}).then(n=>n.json());this.liked=!((i=(s=e.data)==null?void 0:s.attributes)!=null&&i["is-past"]),this.updateDOM()}updateDOM(){this.button.querySelector(".mealz-like-button__icon").classList.toggle("fill",this.liked),this.button.querySelectorAll(".mealz-like-button__icon img").forEach(t=>t.classList.toggle("active"))}},h.MealzLikeButton=Ht([dt("mealz-like-button")],h.MealzLikeButton),window.customElements.get("mealz-like-button")||window.customElements.define("mealz-like-button",h.MealzLikeButton),Object.defineProperty(h,Symbol.toStringTag,{value:"Module"})});
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
mealz-recipe-card {
|
|
2
|
+
position: relative;
|
|
3
|
+
display: flex;
|
|
4
|
+
width: var(--m-catalog-card-width, 308px);
|
|
5
|
+
height: 500px;
|
|
6
|
+
flex-direction: column;
|
|
7
|
+
align-items: flex-start;
|
|
8
|
+
flex-shrink: 0;
|
|
9
|
+
border-radius: 8px;
|
|
10
|
+
overflow: hidden;
|
|
11
|
+
cursor: pointer;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.miam-recipe-card__container {
|
|
15
|
+
display: flex;
|
|
16
|
+
flex-direction: column;
|
|
17
|
+
height: 100%;
|
|
18
|
+
width: 100%;
|
|
19
|
+
flex-shrink: 0;
|
|
20
|
+
align-self: stretch;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.miam-recipe-card__top {
|
|
24
|
+
position: relative;
|
|
25
|
+
flex: 1;
|
|
26
|
+
height: calc(100% - 72px);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.miam-recipe-card__picture {
|
|
30
|
+
width: 100%;
|
|
31
|
+
height: 100%;
|
|
32
|
+
overflow: hidden;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.miam-recipe-card__picture img {
|
|
36
|
+
display: block;
|
|
37
|
+
width: 100%;
|
|
38
|
+
height: 100%;
|
|
39
|
+
-o-object-fit: cover;
|
|
40
|
+
object-fit: cover;
|
|
41
|
+
transition: transform .2s;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.miam-recipe-card__content {
|
|
45
|
+
position: absolute;
|
|
46
|
+
width: 100%;
|
|
47
|
+
height: 100%;
|
|
48
|
+
top: 0;
|
|
49
|
+
left: 0;
|
|
50
|
+
display: flex;
|
|
51
|
+
flex-direction: column;
|
|
52
|
+
justify-content: space-between;
|
|
53
|
+
align-items: stretch;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.miam-recipe-card__content .miam-recipe-card__top-container {
|
|
57
|
+
display: flex;
|
|
58
|
+
flex-direction: row-reverse;
|
|
59
|
+
justify-content: space-between;
|
|
60
|
+
margin: 12px;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.miam-recipe-card__content .miam-recipe-card__picture__bottom {
|
|
64
|
+
width: 100%;
|
|
65
|
+
display: flex;
|
|
66
|
+
justify-content: space-between;
|
|
67
|
+
align-items: flex-end;
|
|
68
|
+
padding: 12px;
|
|
69
|
+
box-sizing: border-box;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.miam-recipe-card__content .miam-recipe-card__picture__bottom span {
|
|
73
|
+
font-family: Roboto Slab, sans-serif;
|
|
74
|
+
font-size: 16px;
|
|
75
|
+
font-weight: 900;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.miam-recipe-card__bottom {
|
|
79
|
+
display: flex;
|
|
80
|
+
width: 100%;
|
|
81
|
+
height: 72px;
|
|
82
|
+
flex-direction: column;
|
|
83
|
+
align-items: flex-start;
|
|
84
|
+
justify-content: center;
|
|
85
|
+
box-sizing: border-box;
|
|
86
|
+
padding: 12px;
|
|
87
|
+
border-radius: 0 0 8px 8px;
|
|
88
|
+
background-color: var(--miam-ds-color-neutral-white, #fff);
|
|
89
|
+
border-right: 1px solid var(--borders-default, #d9dde1);
|
|
90
|
+
border-bottom: 1px solid var(--borders-default, #d9dde1);
|
|
91
|
+
border-left: 1px solid var(--borders-default, #d9dde1)
|
|
92
|
+
}
|