mealz-components 0.2.1 → 0.3.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/mealz-components.js +172 -119
- package/dist/mealz-components.min.js +10 -10
- package/dist/mealz-components.umd.cjs +15 -15
- package/dist/style.css +1 -0
- package/package.json +5 -1
package/dist/mealz-components.js
CHANGED
|
@@ -3,19 +3,19 @@
|
|
|
3
3
|
* Copyright 2019 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
5
5
|
*/
|
|
6
|
-
const N = globalThis,
|
|
7
|
-
let
|
|
6
|
+
const N = globalThis, F = N.ShadowRoot && (N.ShadyCSS === void 0 || N.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype, J = Symbol(), G = /* @__PURE__ */ new WeakMap();
|
|
7
|
+
let rt = class {
|
|
8
8
|
constructor(t, e, i) {
|
|
9
|
-
if (this._$cssResult$ = !0, i !==
|
|
9
|
+
if (this._$cssResult$ = !0, i !== J)
|
|
10
10
|
throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");
|
|
11
11
|
this.cssText = t, this.t = e;
|
|
12
12
|
}
|
|
13
13
|
get styleSheet() {
|
|
14
14
|
let t = this.o;
|
|
15
15
|
const e = this.t;
|
|
16
|
-
if (
|
|
16
|
+
if (F && t === void 0) {
|
|
17
17
|
const i = e !== void 0 && e.length === 1;
|
|
18
|
-
i && (t =
|
|
18
|
+
i && (t = G.get(e)), t === void 0 && ((this.o = t = new CSSStyleSheet()).replaceSync(this.cssText), i && G.set(e, t));
|
|
19
19
|
}
|
|
20
20
|
return t;
|
|
21
21
|
}
|
|
@@ -23,7 +23,7 @@ let nt = class {
|
|
|
23
23
|
return this.cssText;
|
|
24
24
|
}
|
|
25
25
|
};
|
|
26
|
-
const
|
|
26
|
+
const ut = (s) => new rt(typeof s == "string" ? s : s + "", void 0, J), mt = (s, ...t) => {
|
|
27
27
|
const e = s.length === 1 ? s[0] : t.reduce((i, o, r) => i + ((n) => {
|
|
28
28
|
if (n._$cssResult$ === !0)
|
|
29
29
|
return n.cssText;
|
|
@@ -31,30 +31,30 @@ const dt = (s) => new nt(typeof s == "string" ? s : s + "", void 0, F), ct = (s,
|
|
|
31
31
|
return n;
|
|
32
32
|
throw Error("Value passed to 'css' function must be a 'css' function result: " + n + ". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.");
|
|
33
33
|
})(o) + s[r + 1], s[0]);
|
|
34
|
-
return new
|
|
35
|
-
},
|
|
36
|
-
if (
|
|
34
|
+
return new rt(e, s, J);
|
|
35
|
+
}, gt = (s, t) => {
|
|
36
|
+
if (F)
|
|
37
37
|
s.adoptedStyleSheets = t.map((e) => e instanceof CSSStyleSheet ? e : e.styleSheet);
|
|
38
38
|
else
|
|
39
39
|
for (const e of t) {
|
|
40
40
|
const i = document.createElement("style"), o = N.litNonce;
|
|
41
41
|
o !== void 0 && i.setAttribute("nonce", o), i.textContent = e.cssText, s.appendChild(i);
|
|
42
42
|
}
|
|
43
|
-
},
|
|
43
|
+
}, Z = F ? (s) => s : (s) => s instanceof CSSStyleSheet ? ((t) => {
|
|
44
44
|
let e = "";
|
|
45
45
|
for (const i of t.cssRules)
|
|
46
46
|
e += i.cssText;
|
|
47
|
-
return
|
|
47
|
+
return ut(e);
|
|
48
48
|
})(s) : s;
|
|
49
49
|
/**
|
|
50
50
|
* @license
|
|
51
51
|
* Copyright 2017 Google LLC
|
|
52
52
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
53
53
|
*/
|
|
54
|
-
const { is:
|
|
54
|
+
const { is: ft, defineProperty: _t, getOwnPropertyDescriptor: bt, getOwnPropertyNames: $t, getOwnPropertySymbols: yt, getPrototypeOf: vt } = Object, $ = globalThis, K = $.trustedTypes, wt = K ? K.emptyScript : "", B = $.reactiveElementPolyfillSupport, L = (s, t) => s, I = { toAttribute(s, t) {
|
|
55
55
|
switch (t) {
|
|
56
56
|
case Boolean:
|
|
57
|
-
s = s ?
|
|
57
|
+
s = s ? wt : null;
|
|
58
58
|
break;
|
|
59
59
|
case Object:
|
|
60
60
|
case Array:
|
|
@@ -79,23 +79,23 @@ const { is: mt, defineProperty: gt, getOwnPropertyDescriptor: ft, getOwnProperty
|
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
return e;
|
|
82
|
-
} },
|
|
83
|
-
Symbol.metadata ?? (Symbol.metadata = Symbol("metadata")),
|
|
84
|
-
class
|
|
82
|
+
} }, W = (s, t) => !ft(s, t), Y = { attribute: !0, type: String, converter: I, reflect: !1, hasChanged: W };
|
|
83
|
+
Symbol.metadata ?? (Symbol.metadata = Symbol("metadata")), $.litPropertyMetadata ?? ($.litPropertyMetadata = /* @__PURE__ */ new WeakMap());
|
|
84
|
+
class x extends HTMLElement {
|
|
85
85
|
static addInitializer(t) {
|
|
86
86
|
this._$Ei(), (this.l ?? (this.l = [])).push(t);
|
|
87
87
|
}
|
|
88
88
|
static get observedAttributes() {
|
|
89
89
|
return this.finalize(), this._$Eh && [...this._$Eh.keys()];
|
|
90
90
|
}
|
|
91
|
-
static createProperty(t, e =
|
|
91
|
+
static createProperty(t, e = Y) {
|
|
92
92
|
if (e.state && (e.attribute = !1), this._$Ei(), this.elementProperties.set(t, e), !e.noAccessor) {
|
|
93
93
|
const i = Symbol(), o = this.getPropertyDescriptor(t, i, e);
|
|
94
|
-
o !== void 0 &&
|
|
94
|
+
o !== void 0 && _t(this.prototype, t, o);
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
97
|
static getPropertyDescriptor(t, e, i) {
|
|
98
|
-
const { get: o, set: r } =
|
|
98
|
+
const { get: o, set: r } = bt(this.prototype, t) ?? { get() {
|
|
99
99
|
return this[e];
|
|
100
100
|
}, set(n) {
|
|
101
101
|
this[e] = n;
|
|
@@ -108,19 +108,19 @@ class w extends HTMLElement {
|
|
|
108
108
|
}, configurable: !0, enumerable: !0 };
|
|
109
109
|
}
|
|
110
110
|
static getPropertyOptions(t) {
|
|
111
|
-
return this.elementProperties.get(t) ??
|
|
111
|
+
return this.elementProperties.get(t) ?? Y;
|
|
112
112
|
}
|
|
113
113
|
static _$Ei() {
|
|
114
|
-
if (this.hasOwnProperty(
|
|
114
|
+
if (this.hasOwnProperty(L("elementProperties")))
|
|
115
115
|
return;
|
|
116
|
-
const t =
|
|
116
|
+
const t = vt(this);
|
|
117
117
|
t.finalize(), t.l !== void 0 && (this.l = [...t.l]), this.elementProperties = new Map(t.elementProperties);
|
|
118
118
|
}
|
|
119
119
|
static finalize() {
|
|
120
|
-
if (this.hasOwnProperty(
|
|
120
|
+
if (this.hasOwnProperty(L("finalized")))
|
|
121
121
|
return;
|
|
122
|
-
if (this.finalized = !0, this._$Ei(), this.hasOwnProperty(
|
|
123
|
-
const e = this.properties, i = [
|
|
122
|
+
if (this.finalized = !0, this._$Ei(), this.hasOwnProperty(L("properties"))) {
|
|
123
|
+
const e = this.properties, i = [...$t(e), ...yt(e)];
|
|
124
124
|
for (const o of i)
|
|
125
125
|
this.createProperty(o, e[o]);
|
|
126
126
|
}
|
|
@@ -143,9 +143,9 @@ class w extends HTMLElement {
|
|
|
143
143
|
if (Array.isArray(t)) {
|
|
144
144
|
const i = new Set(t.flat(1 / 0).reverse());
|
|
145
145
|
for (const o of i)
|
|
146
|
-
e.unshift(
|
|
146
|
+
e.unshift(Z(o));
|
|
147
147
|
} else
|
|
148
|
-
t !== void 0 && e.push(
|
|
148
|
+
t !== void 0 && e.push(Z(t));
|
|
149
149
|
return e;
|
|
150
150
|
}
|
|
151
151
|
static _$Eu(t, e) {
|
|
@@ -175,7 +175,7 @@ class w extends HTMLElement {
|
|
|
175
175
|
}
|
|
176
176
|
createRenderRoot() {
|
|
177
177
|
const t = this.shadowRoot ?? this.attachShadow(this.constructor.shadowRootOptions);
|
|
178
|
-
return
|
|
178
|
+
return gt(t, this.constructor.elementStyles), t;
|
|
179
179
|
}
|
|
180
180
|
connectedCallback() {
|
|
181
181
|
var t;
|
|
@@ -214,7 +214,7 @@ class w extends HTMLElement {
|
|
|
214
214
|
}
|
|
215
215
|
requestUpdate(t, e, i) {
|
|
216
216
|
if (t !== void 0) {
|
|
217
|
-
if (i ?? (i = this.constructor.getPropertyOptions(t)), !(i.hasChanged ??
|
|
217
|
+
if (i ?? (i = this.constructor.getPropertyOptions(t)), !(i.hasChanged ?? W)(this[t], e))
|
|
218
218
|
return;
|
|
219
219
|
this.P(t, e, i);
|
|
220
220
|
}
|
|
@@ -292,68 +292,68 @@ class w extends HTMLElement {
|
|
|
292
292
|
firstUpdated(t) {
|
|
293
293
|
}
|
|
294
294
|
}
|
|
295
|
-
|
|
295
|
+
x.elementStyles = [], x.shadowRootOptions = { mode: "open" }, x[L("elementProperties")] = /* @__PURE__ */ new Map(), x[L("finalized")] = /* @__PURE__ */ new Map(), B == null || B({ ReactiveElement: x }), ($.reactiveElementVersions ?? ($.reactiveElementVersions = [])).push("2.0.4");
|
|
296
296
|
/**
|
|
297
297
|
* @license
|
|
298
298
|
* Copyright 2017 Google LLC
|
|
299
299
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
300
300
|
*/
|
|
301
|
-
const
|
|
302
|
-
\f\r]`,
|
|
303
|
-
\f\r"'\`<>=]|("|')|))|$)`, "g"),
|
|
301
|
+
const k = globalThis, z = k.trustedTypes, Q = z ? z.createPolicy("lit-html", { createHTML: (s) => s }) : void 0, at = "$lit$", b = `lit$${(Math.random() + "").slice(9)}$`, lt = "?" + b, At = `<${lt}>`, A = document, T = () => A.createComment(""), M = (s) => s === null || typeof s != "object" && typeof s != "function", pt = Array.isArray, xt = (s) => pt(s) || typeof (s == null ? void 0 : s[Symbol.iterator]) == "function", D = `[
|
|
302
|
+
\f\r]`, P = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, X = /-->/g, tt = />/g, v = RegExp(`>|${D}(?:([^\\s"'>=/]+)(${D}*=${D}*(?:[^
|
|
303
|
+
\f\r"'\`<>=]|("|')|))|$)`, "g"), et = /'/g, st = /"/g, dt = /^(?:script|style|textarea|title)$/i, St = (s) => (t, ...e) => ({ _$litType$: s, strings: t, values: e }), u = St(1), E = Symbol.for("lit-noChange"), h = Symbol.for("lit-nothing"), it = /* @__PURE__ */ new WeakMap(), w = A.createTreeWalker(A, 129);
|
|
304
304
|
function ht(s, t) {
|
|
305
305
|
if (!Array.isArray(s) || !s.hasOwnProperty("raw"))
|
|
306
306
|
throw Error("invalid template strings array");
|
|
307
|
-
return
|
|
307
|
+
return Q !== void 0 ? Q.createHTML(t) : t;
|
|
308
308
|
}
|
|
309
|
-
const
|
|
309
|
+
const Et = (s, t) => {
|
|
310
310
|
const e = s.length - 1, i = [];
|
|
311
|
-
let o, r = t === 2 ? "<svg>" : "", n =
|
|
311
|
+
let o, r = t === 2 ? "<svg>" : "", n = P;
|
|
312
312
|
for (let l = 0; l < e; l++) {
|
|
313
313
|
const a = s[l];
|
|
314
|
-
let
|
|
314
|
+
let d, c, p = -1, f = 0;
|
|
315
315
|
for (; f < a.length && (n.lastIndex = f, c = n.exec(a), c !== null); )
|
|
316
|
-
f = n.lastIndex, n ===
|
|
316
|
+
f = n.lastIndex, n === P ? c[1] === "!--" ? n = X : c[1] !== void 0 ? n = tt : c[2] !== void 0 ? (dt.test(c[2]) && (o = RegExp("</" + c[2], "g")), n = v) : c[3] !== void 0 && (n = v) : n === v ? c[0] === ">" ? (n = o ?? P, p = -1) : c[1] === void 0 ? p = -2 : (p = n.lastIndex - c[2].length, d = c[1], n = c[3] === void 0 ? v : c[3] === '"' ? st : et) : n === st || n === et ? n = v : n === X || n === tt ? n = P : (n = v, o = void 0);
|
|
317
317
|
const _ = n === v && s[l + 1].startsWith("/>") ? " " : "";
|
|
318
|
-
r += n ===
|
|
318
|
+
r += n === P ? a + At : p >= 0 ? (i.push(d), a.slice(0, p) + at + a.slice(p) + b + _) : a + b + (p === -2 ? l : _);
|
|
319
319
|
}
|
|
320
320
|
return [ht(s, r + (s[e] || "<?>") + (t === 2 ? "</svg>" : "")), i];
|
|
321
321
|
};
|
|
322
|
-
class
|
|
322
|
+
class O {
|
|
323
323
|
constructor({ strings: t, _$litType$: e }, i) {
|
|
324
324
|
let o;
|
|
325
325
|
this.parts = [];
|
|
326
326
|
let r = 0, n = 0;
|
|
327
|
-
const l = t.length - 1, a = this.parts, [
|
|
328
|
-
if (this.el =
|
|
327
|
+
const l = t.length - 1, a = this.parts, [d, c] = Et(t, e);
|
|
328
|
+
if (this.el = O.createElement(d, i), w.currentNode = this.el.content, e === 2) {
|
|
329
329
|
const p = this.el.content.firstChild;
|
|
330
330
|
p.replaceWith(...p.childNodes);
|
|
331
331
|
}
|
|
332
|
-
for (; (o =
|
|
332
|
+
for (; (o = w.nextNode()) !== null && a.length < l; ) {
|
|
333
333
|
if (o.nodeType === 1) {
|
|
334
334
|
if (o.hasAttributes())
|
|
335
335
|
for (const p of o.getAttributeNames())
|
|
336
|
-
if (p.endsWith(
|
|
337
|
-
const f = c[n++], _ = o.getAttribute(p).split(
|
|
338
|
-
a.push({ type: 1, index: r, name:
|
|
336
|
+
if (p.endsWith(at)) {
|
|
337
|
+
const f = c[n++], _ = o.getAttribute(p).split(b), R = /([.?@])?(.*)/.exec(f);
|
|
338
|
+
a.push({ type: 1, index: r, name: R[2], strings: _, ctor: R[1] === "." ? Pt : R[1] === "?" ? Lt : R[1] === "@" ? kt : H }), o.removeAttribute(p);
|
|
339
339
|
} else
|
|
340
|
-
p.startsWith(
|
|
341
|
-
if (
|
|
342
|
-
const p = o.textContent.split(
|
|
340
|
+
p.startsWith(b) && (a.push({ type: 6, index: r }), o.removeAttribute(p));
|
|
341
|
+
if (dt.test(o.tagName)) {
|
|
342
|
+
const p = o.textContent.split(b), f = p.length - 1;
|
|
343
343
|
if (f > 0) {
|
|
344
|
-
o.textContent =
|
|
344
|
+
o.textContent = z ? z.emptyScript : "";
|
|
345
345
|
for (let _ = 0; _ < f; _++)
|
|
346
|
-
o.append(p[_],
|
|
347
|
-
o.append(p[f],
|
|
346
|
+
o.append(p[_], T()), w.nextNode(), a.push({ type: 2, index: ++r });
|
|
347
|
+
o.append(p[f], T());
|
|
348
348
|
}
|
|
349
349
|
}
|
|
350
350
|
} else if (o.nodeType === 8)
|
|
351
|
-
if (o.data ===
|
|
351
|
+
if (o.data === lt)
|
|
352
352
|
a.push({ type: 2, index: r });
|
|
353
353
|
else {
|
|
354
354
|
let p = -1;
|
|
355
|
-
for (; (p = o.data.indexOf(
|
|
356
|
-
a.push({ type: 7, index: r }), p +=
|
|
355
|
+
for (; (p = o.data.indexOf(b, p + 1)) !== -1; )
|
|
356
|
+
a.push({ type: 7, index: r }), p += b.length - 1;
|
|
357
357
|
}
|
|
358
358
|
r++;
|
|
359
359
|
}
|
|
@@ -363,15 +363,15 @@ class R {
|
|
|
363
363
|
return i.innerHTML = t, i;
|
|
364
364
|
}
|
|
365
365
|
}
|
|
366
|
-
function
|
|
366
|
+
function C(s, t, e = s, i) {
|
|
367
367
|
var n, l;
|
|
368
|
-
if (t ===
|
|
368
|
+
if (t === E)
|
|
369
369
|
return t;
|
|
370
370
|
let o = i !== void 0 ? (n = e._$Co) == null ? void 0 : n[i] : e._$Cl;
|
|
371
371
|
const r = M(t) ? void 0 : t._$litDirective$;
|
|
372
|
-
return (o == null ? void 0 : o.constructor) !== r && ((l = o == null ? void 0 : o._$AO) == null || l.call(o, !1), r === void 0 ? o = void 0 : (o = new r(s), o._$AT(s, e, i)), i !== void 0 ? (e._$Co ?? (e._$Co = []))[i] = o : e._$Cl = o), o !== void 0 && (t =
|
|
372
|
+
return (o == null ? void 0 : o.constructor) !== r && ((l = o == null ? void 0 : o._$AO) == null || l.call(o, !1), r === void 0 ? o = void 0 : (o = new r(s), o._$AT(s, e, i)), i !== void 0 ? (e._$Co ?? (e._$Co = []))[i] = o : e._$Cl = o), o !== void 0 && (t = C(s, o._$AS(s, t.values), o, i)), t;
|
|
373
373
|
}
|
|
374
|
-
class
|
|
374
|
+
class Ct {
|
|
375
375
|
constructor(t, e) {
|
|
376
376
|
this._$AV = [], this._$AN = void 0, this._$AD = t, this._$AM = e;
|
|
377
377
|
}
|
|
@@ -383,16 +383,16 @@ class St {
|
|
|
383
383
|
}
|
|
384
384
|
u(t) {
|
|
385
385
|
const { el: { content: e }, parts: i } = this._$AD, o = ((t == null ? void 0 : t.creationScope) ?? A).importNode(e, !0);
|
|
386
|
-
|
|
387
|
-
let r =
|
|
386
|
+
w.currentNode = o;
|
|
387
|
+
let r = w.nextNode(), n = 0, l = 0, a = i[0];
|
|
388
388
|
for (; a !== void 0; ) {
|
|
389
389
|
if (n === a.index) {
|
|
390
|
-
let
|
|
391
|
-
a.type === 2 ?
|
|
390
|
+
let d;
|
|
391
|
+
a.type === 2 ? d = new U(r, r.nextSibling, this, t) : a.type === 1 ? d = new a.ctor(r, a.name, a.strings, this, t) : a.type === 6 && (d = new Tt(r, this, t)), this._$AV.push(d), a = i[++l];
|
|
392
392
|
}
|
|
393
|
-
n !== (a == null ? void 0 : a.index) && (r =
|
|
393
|
+
n !== (a == null ? void 0 : a.index) && (r = w.nextNode(), n++);
|
|
394
394
|
}
|
|
395
|
-
return
|
|
395
|
+
return w.currentNode = A, o;
|
|
396
396
|
}
|
|
397
397
|
p(t) {
|
|
398
398
|
let e = 0;
|
|
@@ -400,13 +400,13 @@ class St {
|
|
|
400
400
|
i !== void 0 && (i.strings !== void 0 ? (i._$AI(t, i, e), e += i.strings.length - 2) : i._$AI(t[e])), e++;
|
|
401
401
|
}
|
|
402
402
|
}
|
|
403
|
-
class
|
|
403
|
+
class U {
|
|
404
404
|
get _$AU() {
|
|
405
405
|
var t;
|
|
406
406
|
return ((t = this._$AM) == null ? void 0 : t._$AU) ?? this._$Cv;
|
|
407
407
|
}
|
|
408
408
|
constructor(t, e, i, o) {
|
|
409
|
-
this.type = 2, this._$AH =
|
|
409
|
+
this.type = 2, this._$AH = h, this._$AN = void 0, this._$AA = t, this._$AB = e, this._$AM = i, this.options = o, this._$Cv = (o == null ? void 0 : o.isConnected) ?? !0;
|
|
410
410
|
}
|
|
411
411
|
get parentNode() {
|
|
412
412
|
let t = this._$AA.parentNode;
|
|
@@ -420,7 +420,7 @@ class k {
|
|
|
420
420
|
return this._$AB;
|
|
421
421
|
}
|
|
422
422
|
_$AI(t, e = this) {
|
|
423
|
-
t =
|
|
423
|
+
t = C(this, t, e), M(t) ? t === h || t == null || t === "" ? (this._$AH !== h && this._$AR(), this._$AH = h) : t !== this._$AH && t !== E && this._(t) : t._$litType$ !== void 0 ? this.$(t) : t.nodeType !== void 0 ? this.T(t) : xt(t) ? this.k(t) : this._(t);
|
|
424
424
|
}
|
|
425
425
|
S(t) {
|
|
426
426
|
return this._$AA.parentNode.insertBefore(t, this._$AB);
|
|
@@ -429,28 +429,28 @@ class k {
|
|
|
429
429
|
this._$AH !== t && (this._$AR(), this._$AH = this.S(t));
|
|
430
430
|
}
|
|
431
431
|
_(t) {
|
|
432
|
-
this._$AH !==
|
|
432
|
+
this._$AH !== h && M(this._$AH) ? this._$AA.nextSibling.data = t : this.T(A.createTextNode(t)), this._$AH = t;
|
|
433
433
|
}
|
|
434
434
|
$(t) {
|
|
435
435
|
var r;
|
|
436
|
-
const { values: e, _$litType$: i } = t, o = typeof i == "number" ? this._$AC(t) : (i.el === void 0 && (i.el =
|
|
436
|
+
const { values: e, _$litType$: i } = t, o = typeof i == "number" ? this._$AC(t) : (i.el === void 0 && (i.el = O.createElement(ht(i.h, i.h[0]), this.options)), i);
|
|
437
437
|
if (((r = this._$AH) == null ? void 0 : r._$AD) === o)
|
|
438
438
|
this._$AH.p(e);
|
|
439
439
|
else {
|
|
440
|
-
const n = new
|
|
440
|
+
const n = new Ct(o, this), l = n.u(this.options);
|
|
441
441
|
n.p(e), this.T(l), this._$AH = n;
|
|
442
442
|
}
|
|
443
443
|
}
|
|
444
444
|
_$AC(t) {
|
|
445
|
-
let e =
|
|
446
|
-
return e === void 0 &&
|
|
445
|
+
let e = it.get(t.strings);
|
|
446
|
+
return e === void 0 && it.set(t.strings, e = new O(t)), e;
|
|
447
447
|
}
|
|
448
448
|
k(t) {
|
|
449
|
-
|
|
449
|
+
pt(this._$AH) || (this._$AH = [], this._$AR());
|
|
450
450
|
const e = this._$AH;
|
|
451
451
|
let i, o = 0;
|
|
452
452
|
for (const r of t)
|
|
453
|
-
o === e.length ? e.push(i = new
|
|
453
|
+
o === e.length ? e.push(i = new U(this.S(T()), this.S(T()), this, this.options)) : i = e[o], i._$AI(r), o++;
|
|
454
454
|
o < e.length && (this._$AR(i && i._$AB.nextSibling, o), e.length = o);
|
|
455
455
|
}
|
|
456
456
|
_$AR(t = this._$AA.nextSibling, e) {
|
|
@@ -473,49 +473,49 @@ class H {
|
|
|
473
473
|
return this._$AM._$AU;
|
|
474
474
|
}
|
|
475
475
|
constructor(t, e, i, o, r) {
|
|
476
|
-
this.type = 1, this._$AH =
|
|
476
|
+
this.type = 1, this._$AH = h, this._$AN = void 0, this.element = t, this.name = e, this._$AM = o, this.options = r, i.length > 2 || i[0] !== "" || i[1] !== "" ? (this._$AH = Array(i.length - 1).fill(new String()), this.strings = i) : this._$AH = h;
|
|
477
477
|
}
|
|
478
478
|
_$AI(t, e = this, i, o) {
|
|
479
479
|
const r = this.strings;
|
|
480
480
|
let n = !1;
|
|
481
481
|
if (r === void 0)
|
|
482
|
-
t =
|
|
482
|
+
t = C(this, t, e, 0), n = !M(t) || t !== this._$AH && t !== E, n && (this._$AH = t);
|
|
483
483
|
else {
|
|
484
484
|
const l = t;
|
|
485
|
-
let a,
|
|
485
|
+
let a, d;
|
|
486
486
|
for (t = r[0], a = 0; a < r.length - 1; a++)
|
|
487
|
-
|
|
487
|
+
d = C(this, l[i + a], e, a), d === E && (d = this._$AH[a]), n || (n = !M(d) || d !== this._$AH[a]), d === h ? t = h : t !== h && (t += (d ?? "") + r[a + 1]), this._$AH[a] = d;
|
|
488
488
|
}
|
|
489
489
|
n && !o && this.j(t);
|
|
490
490
|
}
|
|
491
491
|
j(t) {
|
|
492
|
-
t ===
|
|
492
|
+
t === h ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, t ?? "");
|
|
493
493
|
}
|
|
494
494
|
}
|
|
495
|
-
class
|
|
495
|
+
class Pt extends H {
|
|
496
496
|
constructor() {
|
|
497
497
|
super(...arguments), this.type = 3;
|
|
498
498
|
}
|
|
499
499
|
j(t) {
|
|
500
|
-
this.element[this.name] = t ===
|
|
500
|
+
this.element[this.name] = t === h ? void 0 : t;
|
|
501
501
|
}
|
|
502
502
|
}
|
|
503
|
-
class
|
|
503
|
+
class Lt extends H {
|
|
504
504
|
constructor() {
|
|
505
505
|
super(...arguments), this.type = 4;
|
|
506
506
|
}
|
|
507
507
|
j(t) {
|
|
508
|
-
this.element.toggleAttribute(this.name, !!t && t !==
|
|
508
|
+
this.element.toggleAttribute(this.name, !!t && t !== h);
|
|
509
509
|
}
|
|
510
510
|
}
|
|
511
|
-
class
|
|
511
|
+
class kt extends H {
|
|
512
512
|
constructor(t, e, i, o, r) {
|
|
513
513
|
super(t, e, i, o, r), this.type = 5;
|
|
514
514
|
}
|
|
515
515
|
_$AI(t, e = this) {
|
|
516
|
-
if ((t =
|
|
516
|
+
if ((t = C(this, t, e, 0) ?? h) === E)
|
|
517
517
|
return;
|
|
518
|
-
const i = this._$AH, o = t ===
|
|
518
|
+
const i = this._$AH, o = t === h && i !== h || t.capture !== i.capture || t.once !== i.once || t.passive !== i.passive, r = t !== h && (i === h || o);
|
|
519
519
|
o && this.element.removeEventListener(this.name, this, i), r && this.element.addEventListener(this.name, this, t), this._$AH = t;
|
|
520
520
|
}
|
|
521
521
|
handleEvent(t) {
|
|
@@ -523,7 +523,7 @@ class Pt extends H {
|
|
|
523
523
|
typeof this._$AH == "function" ? this._$AH.call(((e = this.options) == null ? void 0 : e.host) ?? this.element, t) : this._$AH.handleEvent(t);
|
|
524
524
|
}
|
|
525
525
|
}
|
|
526
|
-
class
|
|
526
|
+
class Tt {
|
|
527
527
|
constructor(t, e, i) {
|
|
528
528
|
this.element = t, this.type = 6, this._$AN = void 0, this._$AM = e, this.options = i;
|
|
529
529
|
}
|
|
@@ -531,17 +531,17 @@ class Lt {
|
|
|
531
531
|
return this._$AM._$AU;
|
|
532
532
|
}
|
|
533
533
|
_$AI(t) {
|
|
534
|
-
|
|
534
|
+
C(this, t);
|
|
535
535
|
}
|
|
536
536
|
}
|
|
537
|
-
const j =
|
|
538
|
-
j == null || j(
|
|
539
|
-
const
|
|
537
|
+
const j = k.litHtmlPolyfillSupport;
|
|
538
|
+
j == null || j(O, U), (k.litHtmlVersions ?? (k.litHtmlVersions = [])).push("3.1.2");
|
|
539
|
+
const Mt = (s, t, e) => {
|
|
540
540
|
const i = (e == null ? void 0 : e.renderBefore) ?? t;
|
|
541
541
|
let o = i._$litPart$;
|
|
542
542
|
if (o === void 0) {
|
|
543
543
|
const r = (e == null ? void 0 : e.renderBefore) ?? null;
|
|
544
|
-
i._$litPart$ = o = new
|
|
544
|
+
i._$litPart$ = o = new U(t.insertBefore(T(), r), r, void 0, e ?? {});
|
|
545
545
|
}
|
|
546
546
|
return o._$AI(s), o;
|
|
547
547
|
};
|
|
@@ -550,7 +550,7 @@ const Tt = (s, t, e) => {
|
|
|
550
550
|
* Copyright 2017 Google LLC
|
|
551
551
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
552
552
|
*/
|
|
553
|
-
class
|
|
553
|
+
class S extends x {
|
|
554
554
|
constructor() {
|
|
555
555
|
super(...arguments), this.renderOptions = { host: this }, this._$Do = void 0;
|
|
556
556
|
}
|
|
@@ -561,7 +561,7 @@ class T extends w {
|
|
|
561
561
|
}
|
|
562
562
|
update(t) {
|
|
563
563
|
const e = this.render();
|
|
564
|
-
this.hasUpdated || (this.renderOptions.isConnected = this.isConnected), super.update(t), this._$Do =
|
|
564
|
+
this.hasUpdated || (this.renderOptions.isConnected = this.isConnected), super.update(t), this._$Do = Mt(e, this.renderRoot, this.renderOptions);
|
|
565
565
|
}
|
|
566
566
|
connectedCallback() {
|
|
567
567
|
var t;
|
|
@@ -572,20 +572,20 @@ class T extends w {
|
|
|
572
572
|
super.disconnectedCallback(), (t = this._$Do) == null || t.setConnected(!1);
|
|
573
573
|
}
|
|
574
574
|
render() {
|
|
575
|
-
return
|
|
575
|
+
return E;
|
|
576
576
|
}
|
|
577
577
|
}
|
|
578
|
-
var
|
|
579
|
-
|
|
578
|
+
var nt;
|
|
579
|
+
S._$litElement$ = !0, S.finalized = !0, (nt = globalThis.litElementHydrateSupport) == null || nt.call(globalThis, { LitElement: S });
|
|
580
580
|
const q = globalThis.litElementPolyfillSupport;
|
|
581
|
-
q == null || q({ LitElement:
|
|
581
|
+
q == null || q({ LitElement: S });
|
|
582
582
|
(globalThis.litElementVersions ?? (globalThis.litElementVersions = [])).push("4.0.4");
|
|
583
583
|
/**
|
|
584
584
|
* @license
|
|
585
585
|
* Copyright 2017 Google LLC
|
|
586
586
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
587
587
|
*/
|
|
588
|
-
const
|
|
588
|
+
const ct = (s) => (t, e) => {
|
|
589
589
|
e !== void 0 ? e.addInitializer(() => {
|
|
590
590
|
customElements.define(s, t);
|
|
591
591
|
}) : customElements.define(s, t);
|
|
@@ -595,7 +595,7 @@ const Ut = (s) => (t, e) => {
|
|
|
595
595
|
* Copyright 2017 Google LLC
|
|
596
596
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
597
597
|
*/
|
|
598
|
-
const
|
|
598
|
+
const Ot = { attribute: !0, type: String, converter: I, reflect: !1, hasChanged: W }, Ut = (s = Ot, t, e) => {
|
|
599
599
|
const { kind: i, metadata: o } = e;
|
|
600
600
|
let r = globalThis.litPropertyMetadata.get(o);
|
|
601
601
|
if (r === void 0 && globalThis.litPropertyMetadata.set(o, r = /* @__PURE__ */ new Map()), r.set(e.name, s), i === "accessor") {
|
|
@@ -617,7 +617,7 @@ const Mt = { attribute: !0, type: String, converter: I, reflect: !1, hasChanged:
|
|
|
617
617
|
throw Error("Unsupported decorator location: " + i);
|
|
618
618
|
};
|
|
619
619
|
function y(s) {
|
|
620
|
-
return (t, e) => typeof e == "object" ?
|
|
620
|
+
return (t, e) => typeof e == "object" ? Ut(s, t, e) : ((i, o, r) => {
|
|
621
621
|
const n = o.hasOwnProperty(r);
|
|
622
622
|
return o.constructor.createProperty(r, n ? { ...i, wrapped: !0 } : i), n ? Object.getOwnPropertyDescriptor(o, r) : void 0;
|
|
623
623
|
})(s, t, e);
|
|
@@ -627,7 +627,7 @@ function y(s) {
|
|
|
627
627
|
* Copyright 2017 Google LLC
|
|
628
628
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
629
629
|
*/
|
|
630
|
-
function
|
|
630
|
+
function Rt(s) {
|
|
631
631
|
return y({ ...s, state: !0, attribute: !1 });
|
|
632
632
|
}
|
|
633
633
|
/**
|
|
@@ -635,13 +635,13 @@ function kt(s) {
|
|
|
635
635
|
* Copyright 2017 Google LLC
|
|
636
636
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
637
637
|
*/
|
|
638
|
-
const
|
|
638
|
+
const ot = (s, t, e) => (e.configurable = !0, e.enumerable = !0, Reflect.decorate && typeof t != "object" && Object.defineProperty(s, t, e), e);
|
|
639
639
|
/**
|
|
640
640
|
* @license
|
|
641
641
|
* Copyright 2017 Google LLC
|
|
642
642
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
643
643
|
*/
|
|
644
|
-
function
|
|
644
|
+
function Nt(s, t) {
|
|
645
645
|
return (e, i, o) => {
|
|
646
646
|
const r = (n) => {
|
|
647
647
|
var l;
|
|
@@ -652,31 +652,31 @@ function Ot(s, t) {
|
|
|
652
652
|
const a = Symbol();
|
|
653
653
|
return { get() {
|
|
654
654
|
return this[a];
|
|
655
|
-
}, set(
|
|
656
|
-
this[a] =
|
|
655
|
+
}, set(d) {
|
|
656
|
+
this[a] = d;
|
|
657
657
|
} };
|
|
658
658
|
})();
|
|
659
|
-
return
|
|
659
|
+
return ot(e, i, { get() {
|
|
660
660
|
let a = n.call(this);
|
|
661
661
|
return a === void 0 && (a = r(this), (a !== null || this.hasUpdated) && l.call(this, a)), a;
|
|
662
662
|
} });
|
|
663
663
|
}
|
|
664
|
-
return
|
|
664
|
+
return ot(e, i, { get() {
|
|
665
665
|
return r(this);
|
|
666
666
|
} });
|
|
667
667
|
};
|
|
668
668
|
}
|
|
669
|
-
class
|
|
669
|
+
class It {
|
|
670
670
|
get extId() {
|
|
671
671
|
return this.attributes["ext-id"];
|
|
672
672
|
}
|
|
673
673
|
}
|
|
674
|
-
var
|
|
675
|
-
for (var o = i > 1 ? void 0 : i ?
|
|
674
|
+
var zt = Object.defineProperty, Ht = Object.getOwnPropertyDescriptor, g = (s, t, e, i) => {
|
|
675
|
+
for (var o = i > 1 ? void 0 : i ? Ht(t, e) : t, r = s.length - 1, n; r >= 0; r--)
|
|
676
676
|
(n = s[r]) && (o = (i ? n(t, e, o) : n(o)) || o);
|
|
677
|
-
return i && o &&
|
|
677
|
+
return i && o && zt(t, e, o), o;
|
|
678
678
|
};
|
|
679
|
-
let m = class extends
|
|
679
|
+
let m = class extends S {
|
|
680
680
|
constructor() {
|
|
681
681
|
var s, t, e, i, o, r;
|
|
682
682
|
super(...arguments), this.selectedRadius = 25, this.radiusOption = [10, 25, 50], this.getByAddress = (t = (s = window.miam) == null ? void 0 : s.pos) == null ? void 0 : t.getByAddress, this.getByCoordinates = (i = (e = window.miam) == null ? void 0 : e.pos) == null ? void 0 : i.getByCoordinates, this.getAffiliateSuppliers = (r = (o = window.miam) == null ? void 0 : o.supplier) == null ? void 0 : r.getAffiliateSuppliers, this._posList = [], this._markers = [], this._searchingPos = !1, this._searchSubmitted = !1, this._previousSearchMethod = () => {
|
|
@@ -843,7 +843,7 @@ let m = class extends T {
|
|
|
843
843
|
}
|
|
844
844
|
setPosList(s) {
|
|
845
845
|
this._posList = s.data.map((t) => {
|
|
846
|
-
const e = Object.assign(new
|
|
846
|
+
const e = Object.assign(new It(), t);
|
|
847
847
|
return e.supplier = s.included.find((i) => i.id === e.relationships.supplier.data.id), e;
|
|
848
848
|
});
|
|
849
849
|
}
|
|
@@ -964,7 +964,7 @@ let m = class extends T {
|
|
|
964
964
|
}
|
|
965
965
|
};
|
|
966
966
|
m.styles = [
|
|
967
|
-
|
|
967
|
+
mt`
|
|
968
968
|
:host {
|
|
969
969
|
display: block;
|
|
970
970
|
height: 100%;
|
|
@@ -1305,15 +1305,68 @@ g([
|
|
|
1305
1305
|
y()
|
|
1306
1306
|
], m.prototype, "getAffiliateSuppliers", 2);
|
|
1307
1307
|
g([
|
|
1308
|
-
|
|
1308
|
+
Rt()
|
|
1309
1309
|
], m.prototype, "_geolocationCoordinates", 2);
|
|
1310
1310
|
g([
|
|
1311
|
-
|
|
1311
|
+
Nt("input")
|
|
1312
1312
|
], m.prototype, "_addressInput", 2);
|
|
1313
1313
|
m = g([
|
|
1314
|
-
|
|
1314
|
+
ct("mealz-store-locator")
|
|
1315
1315
|
], m);
|
|
1316
1316
|
window.customElements.get("mealz-store-locator") || window.customElements.define("mealz-store-locator", m);
|
|
1317
|
+
class Bt extends S {
|
|
1318
|
+
createRenderRoot() {
|
|
1319
|
+
return this;
|
|
1320
|
+
}
|
|
1321
|
+
}
|
|
1322
|
+
var Dt = Object.defineProperty, jt = Object.getOwnPropertyDescriptor, qt = (s, t, e, i) => {
|
|
1323
|
+
for (var o = i > 1 ? void 0 : i ? jt(t, e) : t, r = s.length - 1, n; r >= 0; r--)
|
|
1324
|
+
(n = s[r]) && (o = (i ? n(t, e, o) : n(o)) || o);
|
|
1325
|
+
return i && o && Dt(t, e, o), o;
|
|
1326
|
+
};
|
|
1327
|
+
let V = class extends Bt {
|
|
1328
|
+
constructor() {
|
|
1329
|
+
super(...arguments), this.liked = null, this.recipeLikeId = "", this.requestHeaders = new Headers();
|
|
1330
|
+
}
|
|
1331
|
+
connectedCallback() {
|
|
1332
|
+
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");
|
|
1333
|
+
}
|
|
1334
|
+
render() {
|
|
1335
|
+
this.button = this.querySelector(".mealz-like-button"), this.button && (this.getInitialStatus(), this.recipeLikeId && this.button.addEventListener("click", () => this.toggle()), console.log(this.button));
|
|
1336
|
+
}
|
|
1337
|
+
getInitialStatus() {
|
|
1338
|
+
var i;
|
|
1339
|
+
const s = (i = this.attributes["starting-data"]) == null ? void 0 : i.value;
|
|
1340
|
+
if (console.log(s), !s)
|
|
1341
|
+
return;
|
|
1342
|
+
const { id: t, liked: e } = JSON.parse(s);
|
|
1343
|
+
this.recipeLikeId = t, this.liked = e, this.removeAttribute("starting-data");
|
|
1344
|
+
}
|
|
1345
|
+
async toggle() {
|
|
1346
|
+
var e, i;
|
|
1347
|
+
const s = JSON.stringify({
|
|
1348
|
+
data: {
|
|
1349
|
+
type: "recipe-likes",
|
|
1350
|
+
id: 1,
|
|
1351
|
+
attributes: {
|
|
1352
|
+
"is-past": this.liked
|
|
1353
|
+
}
|
|
1354
|
+
}
|
|
1355
|
+
}), t = await fetch(
|
|
1356
|
+
`http://localhost:3000/api/v1/recipe-likes/${this.recipeLikeId}`,
|
|
1357
|
+
{ headers: this.requestHeaders, method: "PATCH", body: s }
|
|
1358
|
+
).then((o) => o.json());
|
|
1359
|
+
this.liked = !((i = (e = t.data) == null ? void 0 : e.attributes) != null && i["is-past"]), this.updateDOM();
|
|
1360
|
+
}
|
|
1361
|
+
updateDOM() {
|
|
1362
|
+
this.button.querySelector(".mealz-like-button__icon").classList.toggle("fill", this.liked), this.button.querySelectorAll(".mealz-like-button__icon img").forEach((s) => s.classList.toggle("active"));
|
|
1363
|
+
}
|
|
1364
|
+
};
|
|
1365
|
+
V = qt([
|
|
1366
|
+
ct("mealz-like-button")
|
|
1367
|
+
], V);
|
|
1368
|
+
window.customElements.get("mealz-like-button") || window.customElements.define("mealz-like-button", V);
|
|
1317
1369
|
export {
|
|
1370
|
+
V as MealzLikeButton,
|
|
1318
1371
|
m as MealzStoreLocator
|
|
1319
1372
|
};
|
|
@@ -3,35 +3,35 @@
|
|
|
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 rt=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 rt("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:ft,defineProperty:_t,getOwnPropertyDescriptor:bt,getOwnPropertyNames:$t,getOwnPropertySymbols:yt,getPrototypeOf:vt}=Object,$=globalThis,K=$.trustedTypes,wt=K?K.emptyScript:"",B=$.reactiveElementPolyfillSupport,L=(t,e)=>t,I={toAttribute(t,e){switch(e){case Boolean:t=t?wt: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)=>!ft(t,e),Y={attribute:!0,type:String,converter:I,reflect:!1,hasChanged:W};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),$.litPropertyMetadata??($.litPropertyMetadata=new WeakMap);class x 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&&_t(this.prototype,t,i)}}static getPropertyDescriptor(t,e,s){const{get:i,set:o}=bt(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=vt(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=[...$t(t),...yt(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){}}x.elementStyles=[],x.shadowRootOptions={mode:"open"},x[L("elementProperties")]=new Map,x[L("finalized")]=new Map,null==B||B({ReactiveElement:x}),($.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()+"").slice(9)}$`,lt="?"+b,At=`<${lt}>`,A=document,T=()=>A.createComment(""),M=t=>null===t||"object"!=typeof t&&"function"!=typeof t,pt=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,w=A.createTreeWalker(A,129);var s;function ht(t,e){if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==Q?Q.createHTML(e):e}class O{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[ht(t,n+(t[s]||"<?>")+(2===e?"</svg>":"")),i]})(t,e);if(this.el=O.createElement(a,s),w.currentNode=this.el.content,2===e){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes)}for(;null!==(i=w.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]?Pt:"?"===r[1]?Lt:"@"===r[1]?kt: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()),w.nextNode(),l.push({type:2,index:++o});i.append(t[e],T())}}}else if(8===i.nodeType)if(i.data===lt)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=A.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 Ct{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)??A).importNode(e,!0);w.currentNode=i;let o=w.nextNode(),n=0,r=0,l=s[0];for(;void 0!==l;){if(n===l.index){let e;2===l.type?e=new U(o,o.nextSibling,this,t):1===l.type?e=new l.ctor(o,l.name,l.strings,this,t):6===l.type&&(e=new Tt(o,this,t)),this._$AV.push(e),l=s[++r]}n!==(null==l?void 0:l.index)&&(o=w.nextNode(),n++)}return w.currentNode=A,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 U{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=>pt(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(A.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=O.createElement(ht(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 Ct(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 O(t)),e}k(t){pt(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 U(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 Pt extends H{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===h?void 0:t}}class Lt extends H{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==h)}}class kt 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 Tt{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(O,U),(k.litHtmlVersions??(k.litHtmlVersions=[])).push("3.1.2");
|
|
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 x{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 U(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 nt;S._$litElement$=!0,S.finalized=!0,null==(nt=globalThis.litElementHydrateSupport)||nt.call(globalThis,{LitElement:S});const q=globalThis.litElementPolyfillSupport;null==q||q({LitElement:S}),(globalThis.litElementVersions??(globalThis.litElementVersions=[])).push("4.0.4");
|
|
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 ct=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
|
+
*/,Ot={attribute:!0,type:String,converter:I,reflect:!1,hasChanged:W},Ut=(t=Ot,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
|
|
@@ -42,12 +42,12 @@ const Mt={attribute:!0,type:String,converter:I,reflect:!1,hasChanged:J},Rt=(t=Mt
|
|
|
42
42
|
* Copyright 2017 Google LLC
|
|
43
43
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
44
44
|
*/
|
|
45
|
-
const
|
|
45
|
+
const ot=(t,e,s)=>(s.configurable=!0,s.enumerable=!0,Reflect.decorate&&"object"!=typeof e&&Object.defineProperty(t,e,s),s)
|
|
46
46
|
/**
|
|
47
47
|
* @license
|
|
48
48
|
* Copyright 2017 Google LLC
|
|
49
49
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
50
|
-
*/;class
|
|
50
|
+
*/;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
51
|
<div class="wrapper miam-ds-body">
|
|
52
52
|
<div class="pos-selection">
|
|
53
53
|
<div class="title">
|
|
@@ -120,7 +120,7 @@ const it=(t,e,s)=>(s.configurable=!0,s.enumerable=!0,Reflect.decorate&&"object"!
|
|
|
120
120
|
</div>
|
|
121
121
|
`))}
|
|
122
122
|
</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
|
|
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 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 rt(s,t,J)})`
|
|
124
124
|
:host {
|
|
125
125
|
display: block;
|
|
126
126
|
height: 100%;
|
|
@@ -437,4 +437,4 @@ const it=(t,e,s)=>(s.configurable=!0,s.enumerable=!0,Reflect.decorate&&"object"!
|
|
|
437
437
|
top: 0;
|
|
438
438
|
}
|
|
439
439
|
}
|
|
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})}()],m.prototype,"_geolocationCoordinates",2),g([function(t,e){return(s,i,o)=>{const n=e=>{var s;return(null==(s=e.renderRoot)?void 0:s.querySelector(t))??null};if(e){const{get:t,set:e}="object"==typeof i?s:o??(()=>{const t=Symbol();return{get(){return this[t]},set(e){this[t]=e}}})();return
|
|
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})}()],m.prototype,"_geolocationCoordinates",2),g([function(t,e){return(s,i,o)=>{const n=e=>{var s;return(null==(s=e.renderRoot)?void 0:s.querySelector(t))??null};if(e){const{get:t,set:e}="object"==typeof i?s:o??(()=>{const t=Symbol();return{get(){return this[t]},set(e){this[t]=e}}})();return ot(s,i,{get(){let s=t.call(this);return void 0===s&&(s=n(this),(null!==s||this.hasUpdated)&&e.call(this,s)),s}})}return ot(s,i,{get(){return n(this)}})}}("input")],m.prototype,"_addressInput",2),m=g([ct("mealz-store-locator")],m),window.customElements.get("mealz-store-locator")||window.customElements.define("mealz-store-locator",m);class Bt extends S{createRenderRoot(){return this}}var Dt=Object.defineProperty,jt=Object.getOwnPropertyDescriptor;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=i>1?void 0:i?jt(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&&Dt(e,s,n),n})([ct("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 pt;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
|
|
5
|
+
*/var pt;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 ct=o=>new G(typeof o=="string"?o:o+"",void 0,D),ut=(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)},mt=(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 ct(e)})(o):o;/**
|
|
6
6
|
* @license
|
|
7
7
|
* Copyright 2017 Google LLC
|
|
8
8
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
9
|
-
*/const{is:
|
|
9
|
+
*/const{is:gt,defineProperty:ft,getOwnPropertyDescriptor:_t,getOwnPropertyNames:bt,getOwnPropertySymbols:$t,getPrototypeOf:yt}=Object,b=globalThis,K=b.trustedTypes,vt=K?K.emptyScript:"",j=b.reactiveElementPolyfillSupport,P=(o,t)=>o,R={toAttribute(o,t){switch(t){case Boolean:o=o?vt: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)=>!gt(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 x 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&&ft(this.prototype,t,i)}}static getPropertyDescriptor(t,e,s){const{get:i,set:n}=_t(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=yt(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=[...bt(e),...$t(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 mt(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){}}x.elementStyles=[],x.shadowRootOptions={mode:"open"},x[P("elementProperties")]=new Map,x[P("finalized")]=new Map,j==null||j({ReactiveElement:x}),(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,
|
|
13
|
+
*/const M=globalThis,N=M.trustedTypes,Q=N?N.createPolicy("lit-html",{createHTML:o=>o}):void 0,X="$lit$",$=`lit$${(Math.random()+"").slice(9)}$`,tt="?"+$,wt=`<${tt}>`,w=document,k=()=>w.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,A=RegExp(`>|${V}(?:([^\\s"'>=/]+)(${V}*=${V}*(?:[^
|
|
15
|
+
\f\r"'\`<>=]|("|')|))|$)`,"g"),ot=/'/g,nt=/"/g,rt=/^(?:script|style|textarea|title)$/i,St=o=>(t,...e)=>({_$litType$:o,strings:t,values:e}),m=St(1),E=Symbol.for("lit-noChange"),c=Symbol.for("lit-nothing"),at=new WeakMap,S=w.createTreeWalker(w,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 p,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=A):u[3]!==void 0&&(r=A):r===A?u[0]===">"?(r=i??T,d=-1):u[1]===void 0?d=-2:(d=r.lastIndex-u[2].length,p=u[1],r=u[3]===void 0?A:u[3]==='"'?nt:ot):r===nt||r===ot?r=A:r===st||r===it?r=T:(r=A,i=void 0);const v=r===A&&o[l+1].startsWith("/>")?" ":"";n+=r===T?a+wt:d>=0?(s.push(p),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 O{constructor({strings:t,_$litType$:e},s){let i;this.parts=[];let n=0,r=0;const l=t.length-1,a=this.parts,[p,u]=xt(t,e);if(this.el=O.createElement(p,s),S.currentNode=this.el.content,e===2){const d=this.el.content.firstChild;d.replaceWith(...d.childNodes)}for(;(i=S.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]==="."?Ct:B[1]==="?"?Lt:B[1]==="@"?Pt: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],k()),S.nextNode(),a.push({type:2,index:++n});i.append(d[f],k())}}}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=w.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 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=((t==null?void 0:t.creationScope)??w).importNode(e,!0);S.currentNode=i;let n=S.nextNode(),r=0,l=0,a=s[0];for(;a!==void 0;){if(r===a.index){let p;a.type===2?p=new U(n,n.nextSibling,this,t):a.type===1?p=new a.ctor(n,a.name,a.strings,this,t):a.type===6&&(p=new Mt(n,this,t)),this._$AV.push(p),a=s[++l]}r!==(a==null?void 0:a.index)&&(n=S.nextNode(),r++)}return S.currentNode=w,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 U{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=c,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===c||t==null||t===""?(this._$AH!==c&&this._$AR(),this._$AH=c):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!==c&&z(this._$AH)?this._$AA.nextSibling.data=t:this.T(w.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=O.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 Et(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 O(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 U(this.S(k()),this.S(k()),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=c,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=c}_$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,p;for(t=n[0],a=0;a<n.length-1;a++)p=C(this,l[s+a],e,a),p===E&&(p=this._$AH[a]),r||(r=!z(p)||p!==this._$AH[a]),p===c?t=c:t!==c&&(t+=(p??"")+n[a+1]),this._$AH[a]=p}r&&!i&&this.j(t)}j(t){t===c?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}class Ct extends I{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===c?void 0:t}}class Lt extends I{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==c)}}class Pt 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)??c)===E)return;const s=this._$AH,i=t===c&&s!==c||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,n=t!==c&&(s===c||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 Mt{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=M.litHtmlPolyfillSupport;F==null||F(O,U),(M.litHtmlVersions??(M.litHtmlVersions=[])).push("3.1.2");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 U(t.insertBefore(k(),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 x{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,(pt=globalThis.litElementHydrateSupport)==null||pt.call(globalThis,{LitElement:L});const J=globalThis.litElementPolyfillSupport;J==null||J({LitElement:L}),(globalThis.litElementVersions??(globalThis.litElementVersions=[])).push("4.0.4");/**
|
|
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 zt={attribute:!0,type:String,converter:R,reflect:!1,hasChanged:q},Tt=(o=zt,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"?Tt(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 Ot(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 ht=(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 Ut(o,t){return(e,s,i)=>{const n=r=>{var l;return((l=r.renderRoot)==null?void 0:l.querySelector(o))??null};if(t){const{get:r,set:l}=typeof s=="object"?e:i??(()=>{const a=Symbol();return{get(){return this[a]},set(p){this[a]=p}}})();return ht(e,s,{get(){let a=r.call(this);return a===void 0&&(a=n(this),(a!==null||this.hasUpdated)&&l.call(this,a)),a}})}return ht(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}"/>
|
|
@@ -122,7 +122,7 @@
|
|
|
122
122
|
<button id="select" class="miam-ds-button primary select-pos-button">Sélectionner</button>
|
|
123
123
|
</div>
|
|
124
124
|
</div>
|
|
125
|
-
`});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){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(()=>{this.geolocationCoordinates===void 0&&(this.geolocationCoordinates={})},2e4)}listenFormSubmit(){this.shadowRoot.getElementById("store-locator-form").addEventListener("submit",e=>{e.preventDefault(),this.setAddress()})}},h.MealzStoreLocator.styles=[
|
|
125
|
+
`});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){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(()=>{this.geolocationCoordinates===void 0&&(this.geolocationCoordinates={})},2e4)}listenFormSubmit(){this.shadowRoot.getElementById("store-locator-form").addEventListener("submit",e=>{e.preventDefault(),this.setAddress()})}},h.MealzStoreLocator.styles=[ut`
|
|
126
126
|
:host {
|
|
127
127
|
display: block;
|
|
128
128
|
height: 100%;
|
|
@@ -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([Ot()],h.MealzStoreLocator.prototype,"_geolocationCoordinates",2),g([Ut("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=Object.defineProperty,Dt=Object.getOwnPropertyDescriptor,jt=(o,t,e,s)=>{for(var i=s>1?void 0:s?Dt(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&&Ht(t,e,i),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=jt([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"})});
|
package/dist/style.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.mealz-like-button__icon img{display:none}.mealz-like-button__icon .active{display:block}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mealz-components",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.3.0-alpha.0",
|
|
5
5
|
"main": "./dist/mealz-components.js",
|
|
6
6
|
"module": "./dist/mealz-components.js",
|
|
7
7
|
"exports": {
|
|
@@ -12,6 +12,10 @@
|
|
|
12
12
|
"./store-locator": {
|
|
13
13
|
"import": "./dist/store-locator/store-locator.js",
|
|
14
14
|
"require": "./dist/store-locator/store-locator.cjs"
|
|
15
|
+
},
|
|
16
|
+
"./like-button": {
|
|
17
|
+
"import": "./dist/like-button/like-button.js",
|
|
18
|
+
"require": "./dist/like-button/like-button.cjs"
|
|
15
19
|
}
|
|
16
20
|
},
|
|
17
21
|
"files": [
|