@epigraph/epigraph-std-lib 4.1.0 → 4.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,359 +1,25 @@
1
- import { LitElement as Q, css as Z, html as F } from "lit";
2
- import J from "qr-creator";
3
- /**
4
- * @license
5
- * Copyright 2017 Google LLC
6
- * SPDX-License-Identifier: BSD-3-Clause
7
- */
8
- const S = globalThis, N = S.trustedTypes, L = N ? N.createPolicy("lit-html", { createHTML: (i) => i }) : void 0, j = "$lit$", u = `lit$${Math.random().toFixed(9).slice(2)}$`, q = "?" + u, K = `<${q}>`, g = document, w = () => g.createComment(""), C = (i) => i === null || typeof i != "object" && typeof i != "function", R = Array.isArray, X = (i) => R(i) || typeof i?.[Symbol.iterator] == "function", G = `[
9
- \f\r]`, m = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, k = /-->/g, B = />/g, p = RegExp(`>|${G}(?:([^\\s"'>=/]+)(${G}*=${G}*(?:[^
10
- \f\r"'\`<>=]|("|')|))|$)`, "g"), O = /'/g, D = /"/g, P = /^(?:script|style|textarea|title)$/i, H = Symbol.for("lit-noChange"), a = Symbol.for("lit-nothing"), W = /* @__PURE__ */ new WeakMap(), f = g.createTreeWalker(g, 129);
11
- function z(i, t) {
12
- if (!R(i) || !i.hasOwnProperty("raw")) throw Error("invalid template strings array");
13
- return L !== void 0 ? L.createHTML(t) : t;
14
- }
15
- const Y = (i, t) => {
16
- const e = i.length - 1, s = [];
17
- let n, o = t === 2 ? "<svg>" : t === 3 ? "<math>" : "", r = m;
18
- for (let d = 0; d < e; d++) {
19
- const h = i[d];
20
- let c, $, l = -1, A = 0;
21
- for (; A < h.length && (r.lastIndex = A, $ = r.exec(h), $ !== null); ) A = r.lastIndex, r === m ? $[1] === "!--" ? r = k : $[1] !== void 0 ? r = B : $[2] !== void 0 ? (P.test($[2]) && (n = RegExp("</" + $[2], "g")), r = p) : $[3] !== void 0 && (r = p) : r === p ? $[0] === ">" ? (r = n ?? m, l = -1) : $[1] === void 0 ? l = -2 : (l = r.lastIndex - $[2].length, c = $[1], r = $[3] === void 0 ? p : $[3] === '"' ? D : O) : r === D || r === O ? r = p : r === k || r === B ? r = m : (r = p, n = void 0);
22
- const _ = r === p && i[d + 1].startsWith("/>") ? " " : "";
23
- o += r === m ? h + K : l >= 0 ? (s.push(c), h.slice(0, l) + j + h.slice(l) + u + _) : h + u + (l === -2 ? d : _);
24
- }
25
- return [z(i, o + (i[e] || "<?>") + (t === 2 ? "</svg>" : t === 3 ? "</math>" : "")), s];
1
+ import { i as d, a as l, x as C } from "../../lit-element-C3moVMGu.js";
2
+ import { query as p } from "lit/decorators.js";
3
+ import m from "qr-creator";
4
+ var f = Object.defineProperty, c = (i, t, e, n) => {
5
+ for (var r = void 0, a = i.length - 1, o; a >= 0; a--)
6
+ (o = i[a]) && (r = o(t, e, r) || r);
7
+ return r && f(t, e, r), r;
26
8
  };
27
- class x {
28
- constructor({ strings: t, _$litType$: e }, s) {
29
- let n;
30
- this.parts = [];
31
- let o = 0, r = 0;
32
- const d = t.length - 1, h = this.parts, [c, $] = Y(t, e);
33
- if (this.el = x.createElement(c, s), f.currentNode = this.el.content, e === 2 || e === 3) {
34
- const l = this.el.content.firstChild;
35
- l.replaceWith(...l.childNodes);
36
- }
37
- for (; (n = f.nextNode()) !== null && h.length < d; ) {
38
- if (n.nodeType === 1) {
39
- if (n.hasAttributes()) for (const l of n.getAttributeNames()) if (l.endsWith(j)) {
40
- const A = $[r++], _ = n.getAttribute(l).split(u), b = /([.?@])?(.*)/.exec(A);
41
- h.push({ type: 1, index: o, name: b[2], strings: _, ctor: b[1] === "." ? et : b[1] === "?" ? st : b[1] === "@" ? it : U }), n.removeAttribute(l);
42
- } else l.startsWith(u) && (h.push({ type: 6, index: o }), n.removeAttribute(l));
43
- if (P.test(n.tagName)) {
44
- const l = n.textContent.split(u), A = l.length - 1;
45
- if (A > 0) {
46
- n.textContent = N ? N.emptyScript : "";
47
- for (let _ = 0; _ < A; _++) n.append(l[_], w()), f.nextNode(), h.push({ type: 2, index: ++o });
48
- n.append(l[A], w());
49
- }
50
- }
51
- } else if (n.nodeType === 8) if (n.data === q) h.push({ type: 2, index: o });
52
- else {
53
- let l = -1;
54
- for (; (l = n.data.indexOf(u, l + 1)) !== -1; ) h.push({ type: 7, index: o }), l += u.length - 1;
55
- }
56
- o++;
57
- }
58
- }
59
- static createElement(t, e) {
60
- const s = g.createElement("template");
61
- return s.innerHTML = t, s;
62
- }
63
- }
64
- function v(i, t, e = i, s) {
65
- if (t === H) return t;
66
- let n = s !== void 0 ? e._$Co?.[s] : e._$Cl;
67
- const o = C(t) ? void 0 : t._$litDirective$;
68
- return n?.constructor !== o && (n?._$AO?.(!1), o === void 0 ? n = void 0 : (n = new o(i), n._$AT(i, e, s)), s !== void 0 ? (e._$Co ??= [])[s] = n : e._$Cl = n), n !== void 0 && (t = v(i, n._$AS(i, t.values), n, s)), t;
69
- }
70
- class tt {
71
- constructor(t, e) {
72
- this._$AV = [], this._$AN = void 0, this._$AD = t, this._$AM = e;
73
- }
74
- get parentNode() {
75
- return this._$AM.parentNode;
76
- }
77
- get _$AU() {
78
- return this._$AM._$AU;
79
- }
80
- u(t) {
81
- const { el: { content: e }, parts: s } = this._$AD, n = (t?.creationScope ?? g).importNode(e, !0);
82
- f.currentNode = n;
83
- let o = f.nextNode(), r = 0, d = 0, h = s[0];
84
- for (; h !== void 0; ) {
85
- if (r === h.index) {
86
- let c;
87
- h.type === 2 ? c = new T(o, o.nextSibling, this, t) : h.type === 1 ? c = new h.ctor(o, h.name, h.strings, this, t) : h.type === 6 && (c = new nt(o, this, t)), this._$AV.push(c), h = s[++d];
88
- }
89
- r !== h?.index && (o = f.nextNode(), r++);
90
- }
91
- return f.currentNode = g, n;
92
- }
93
- p(t) {
94
- let e = 0;
95
- 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++;
96
- }
97
- }
98
- class T {
99
- get _$AU() {
100
- return this._$AM?._$AU ?? this._$Cv;
101
- }
102
- constructor(t, e, s, n) {
103
- this.type = 2, this._$AH = a, this._$AN = void 0, this._$AA = t, this._$AB = e, this._$AM = s, this.options = n, this._$Cv = n?.isConnected ?? !0;
104
- }
105
- get parentNode() {
106
- let t = this._$AA.parentNode;
107
- const e = this._$AM;
108
- return e !== void 0 && t?.nodeType === 11 && (t = e.parentNode), t;
109
- }
110
- get startNode() {
111
- return this._$AA;
112
- }
113
- get endNode() {
114
- return this._$AB;
115
- }
116
- _$AI(t, e = this) {
117
- t = v(this, t, e), C(t) ? t === a || t == null || t === "" ? (this._$AH !== a && this._$AR(), this._$AH = a) : t !== this._$AH && t !== H && this._(t) : t._$litType$ !== void 0 ? this.$(t) : t.nodeType !== void 0 ? this.T(t) : X(t) ? this.k(t) : this._(t);
118
- }
119
- O(t) {
120
- return this._$AA.parentNode.insertBefore(t, this._$AB);
121
- }
122
- T(t) {
123
- this._$AH !== t && (this._$AR(), this._$AH = this.O(t));
124
- }
125
- _(t) {
126
- this._$AH !== a && C(this._$AH) ? this._$AA.nextSibling.data = t : this.T(g.createTextNode(t)), this._$AH = t;
127
- }
128
- $(t) {
129
- const { values: e, _$litType$: s } = t, n = typeof s == "number" ? this._$AC(t) : (s.el === void 0 && (s.el = x.createElement(z(s.h, s.h[0]), this.options)), s);
130
- if (this._$AH?._$AD === n) this._$AH.p(e);
131
- else {
132
- const o = new tt(n, this), r = o.u(this.options);
133
- o.p(e), this.T(r), this._$AH = o;
134
- }
135
- }
136
- _$AC(t) {
137
- let e = W.get(t.strings);
138
- return e === void 0 && W.set(t.strings, e = new x(t)), e;
139
- }
140
- k(t) {
141
- R(this._$AH) || (this._$AH = [], this._$AR());
142
- const e = this._$AH;
143
- let s, n = 0;
144
- for (const o of t) n === e.length ? e.push(s = new T(this.O(w()), this.O(w()), this, this.options)) : s = e[n], s._$AI(o), n++;
145
- n < e.length && (this._$AR(s && s._$AB.nextSibling, n), e.length = n);
146
- }
147
- _$AR(t = this._$AA.nextSibling, e) {
148
- for (this._$AP?.(!1, !0, e); t && t !== this._$AB; ) {
149
- const s = t.nextSibling;
150
- t.remove(), t = s;
151
- }
152
- }
153
- setConnected(t) {
154
- this._$AM === void 0 && (this._$Cv = t, this._$AP?.(t));
155
- }
156
- }
157
- class U {
158
- get tagName() {
159
- return this.element.tagName;
160
- }
161
- get _$AU() {
162
- return this._$AM._$AU;
163
- }
164
- constructor(t, e, s, n, o) {
165
- this.type = 1, this._$AH = a, this._$AN = void 0, this.element = t, this.name = e, this._$AM = n, this.options = o, s.length > 2 || s[0] !== "" || s[1] !== "" ? (this._$AH = Array(s.length - 1).fill(new String()), this.strings = s) : this._$AH = a;
166
- }
167
- _$AI(t, e = this, s, n) {
168
- const o = this.strings;
169
- let r = !1;
170
- if (o === void 0) t = v(this, t, e, 0), r = !C(t) || t !== this._$AH && t !== H, r && (this._$AH = t);
171
- else {
172
- const d = t;
173
- let h, c;
174
- for (t = o[0], h = 0; h < o.length - 1; h++) c = v(this, d[s + h], e, h), c === H && (c = this._$AH[h]), r ||= !C(c) || c !== this._$AH[h], c === a ? t = a : t !== a && (t += (c ?? "") + o[h + 1]), this._$AH[h] = c;
175
- }
176
- r && !n && this.j(t);
177
- }
178
- j(t) {
179
- t === a ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, t ?? "");
180
- }
181
- }
182
- class et extends U {
183
- constructor() {
184
- super(...arguments), this.type = 3;
185
- }
186
- j(t) {
187
- this.element[this.name] = t === a ? void 0 : t;
188
- }
189
- }
190
- class st extends U {
191
- constructor() {
192
- super(...arguments), this.type = 4;
193
- }
194
- j(t) {
195
- this.element.toggleAttribute(this.name, !!t && t !== a);
196
- }
197
- }
198
- class it extends U {
199
- constructor(t, e, s, n, o) {
200
- super(t, e, s, n, o), this.type = 5;
201
- }
202
- _$AI(t, e = this) {
203
- if ((t = v(this, t, e, 0) ?? a) === H) return;
204
- const s = this._$AH, n = t === a && s !== a || t.capture !== s.capture || t.once !== s.once || t.passive !== s.passive, o = t !== a && (s === a || n);
205
- n && this.element.removeEventListener(this.name, this, s), o && this.element.addEventListener(this.name, this, t), this._$AH = t;
206
- }
207
- handleEvent(t) {
208
- typeof this._$AH == "function" ? this._$AH.call(this.options?.host ?? this.element, t) : this._$AH.handleEvent(t);
209
- }
210
- }
211
- class nt {
212
- constructor(t, e, s) {
213
- this.element = t, this.type = 6, this._$AN = void 0, this._$AM = e, this.options = s;
214
- }
215
- get _$AU() {
216
- return this._$AM._$AU;
217
- }
218
- _$AI(t) {
219
- v(this, t);
220
- }
221
- }
222
- const ot = S.litHtmlPolyfillSupport;
223
- ot?.(x, T), (S.litHtmlVersions ??= []).push("3.3.0");
224
- /**
225
- * @license
226
- * Copyright 2020 Google LLC
227
- * SPDX-License-Identifier: BSD-3-Clause
228
- */
229
- const rt = (i) => i.strings === void 0;
230
- /**
231
- * @license
232
- * Copyright 2017 Google LLC
233
- * SPDX-License-Identifier: BSD-3-Clause
234
- */
235
- const ht = { CHILD: 2 }, lt = (i) => (...t) => ({ _$litDirective$: i, values: t });
236
- class at {
237
- constructor(t) {
238
- }
239
- get _$AU() {
240
- return this._$AM._$AU;
241
- }
242
- _$AT(t, e, s) {
243
- this._$Ct = t, this._$AM = e, this._$Ci = s;
244
- }
245
- _$AS(t, e) {
246
- return this.update(t, e);
247
- }
248
- update(t, e) {
249
- return this.render(...e);
250
- }
251
- }
252
- /**
253
- * @license
254
- * Copyright 2017 Google LLC
255
- * SPDX-License-Identifier: BSD-3-Clause
256
- */
257
- const y = (i, t) => {
258
- const e = i._$AN;
259
- if (e === void 0) return !1;
260
- for (const s of e) s._$AO?.(t, !1), y(s, t);
261
- return !0;
262
- }, M = (i) => {
263
- let t, e;
264
- do {
265
- if ((t = i._$AM) === void 0) break;
266
- e = t._$AN, e.delete(i), i = t;
267
- } while (e?.size === 0);
268
- }, V = (i) => {
269
- for (let t; t = i._$AM; i = t) {
270
- let e = t._$AN;
271
- if (e === void 0) t._$AN = e = /* @__PURE__ */ new Set();
272
- else if (e.has(i)) break;
273
- e.add(i), dt(t);
274
- }
275
- };
276
- function ct(i) {
277
- this._$AN !== void 0 ? (M(this), this._$AM = i, V(this)) : this._$AM = i;
278
- }
279
- function $t(i, t = !1, e = 0) {
280
- const s = this._$AH, n = this._$AN;
281
- if (n !== void 0 && n.size !== 0) if (t) if (Array.isArray(s)) for (let o = e; o < s.length; o++) y(s[o], !1), M(s[o]);
282
- else s != null && (y(s, !1), M(s));
283
- else y(this, i);
284
- }
285
- const dt = (i) => {
286
- i.type == ht.CHILD && (i._$AP ??= $t, i._$AQ ??= ct);
287
- };
288
- class At extends at {
289
- constructor() {
290
- super(...arguments), this._$AN = void 0;
291
- }
292
- _$AT(t, e, s) {
293
- super._$AT(t, e, s), V(this), this.isConnected = t._$AU;
294
- }
295
- _$AO(t, e = !0) {
296
- t !== this.isConnected && (this.isConnected = t, t ? this.reconnected?.() : this.disconnected?.()), e && (y(this, t), M(this));
297
- }
298
- setValue(t) {
299
- if (rt(this._$Ct)) this._$Ct._$AI(t, this);
300
- else {
301
- const e = [...this._$Ct._$AH];
302
- e[this._$Ci] = t, this._$Ct._$AI(e, this, 0);
303
- }
304
- }
305
- disconnected() {
306
- }
307
- reconnected() {
308
- }
309
- }
310
- /**
311
- * @license
312
- * Copyright 2020 Google LLC
313
- * SPDX-License-Identifier: BSD-3-Clause
314
- */
315
- const _t = () => new ut();
316
- class ut {
317
- }
318
- const E = /* @__PURE__ */ new WeakMap(), pt = lt(class extends At {
319
- render(i) {
320
- return a;
321
- }
322
- update(i, [t]) {
323
- const e = t !== this.G;
324
- return e && this.G !== void 0 && this.rt(void 0), (e || this.lt !== this.ct) && (this.G = t, this.ht = i.options?.host, this.rt(this.ct = i.element)), a;
325
- }
326
- rt(i) {
327
- if (this.isConnected || (i = void 0), typeof this.G == "function") {
328
- const t = this.ht ?? globalThis;
329
- let e = E.get(t);
330
- e === void 0 && (e = /* @__PURE__ */ new WeakMap(), E.set(t, e)), e.get(this.G) !== void 0 && this.G.call(this.ht, void 0), e.set(this.G, i), i !== void 0 && this.G.call(this.ht, i);
331
- } else this.G.value = i;
332
- }
333
- get lt() {
334
- return typeof this.G == "function" ? E.get(this.ht ?? globalThis)?.get(this.G) : this.G?.value;
335
- }
336
- disconnected() {
337
- this.lt === this.ct && this.rt(void 0);
338
- }
339
- reconnected() {
340
- this.rt(this.ct);
341
- }
342
- });
343
- class I extends Q {
344
- constructor() {
345
- super(...arguments), this._qrCodeGenCanvasRef = _t();
346
- }
9
+ class s extends d {
347
10
  static {
348
11
  this.webComponentName = "epigraph-qr-code-generator";
349
12
  }
350
13
  static {
351
- this.styles = Z`
14
+ this.styles = l`
352
15
  :host {
353
16
  display: none;
354
17
  }
355
18
  `;
356
19
  }
20
+ get qrCodeGenCanvasRef() {
21
+ return this._qrCodeGenCanvasRef;
22
+ }
357
23
  /**
358
24
  * Converts any given data uri to a blob.
359
25
  *
@@ -364,8 +30,8 @@ class I extends Q {
364
30
  const e = t.split(",");
365
31
  if (e.length !== 2)
366
32
  throw new Error("Invalid data URI format");
367
- const s = e[0].split(":")[1].split(";")[0], n = atob(e[1]), o = new Uint8Array(Array.from(n, (r) => r.charCodeAt(0)));
368
- return new Blob([o], { type: s });
33
+ const n = e[0].split(":")[1].split(";")[0], r = atob(e[1]), a = new Uint8Array(Array.from(r, (o) => o.charCodeAt(0)));
34
+ return new Blob([a], { type: n });
369
35
  }
370
36
  /**
371
37
  * Generates a QR code as image data url for the qrCodeContent provided.
@@ -386,11 +52,11 @@ class I extends Q {
386
52
  size: 256
387
53
  // in pixels
388
54
  }) {
389
- if (!this._qrCodeGenCanvasRef.value)
55
+ if (!this._qrCodeGenCanvasRef)
390
56
  return "";
391
- J.render(t, this._qrCodeGenCanvasRef.value);
392
- const e = this._qrCodeGenCanvasRef.value.toDataURL(), s = this.dataUritoBlob(e);
393
- return URL.createObjectURL(s);
57
+ m.render(t, this._qrCodeGenCanvasRef);
58
+ const e = this._qrCodeGenCanvasRef.toDataURL(), n = this.dataUritoBlob(e);
59
+ return URL.createObjectURL(n);
394
60
  }
395
61
  /**
396
62
  * Override for the LitElement's render method.
@@ -398,12 +64,15 @@ class I extends Q {
398
64
  * @returns {html} HTML to be rendered by this component.
399
65
  */
400
66
  render() {
401
- return F`
402
- <canvas id="qrCode" ${pt(this._qrCodeGenCanvasRef)}></canvas>
67
+ return C`
68
+ <canvas id="qrCodeCanvas"></canvas>
403
69
  `;
404
70
  }
405
71
  }
406
- window.customElements.get(I.webComponentName) === void 0 && window.customElements.define(I.webComponentName, I);
72
+ c([
73
+ p("#qrCodeCanvas")
74
+ ], s.prototype, "_qrCodeGenCanvasRef");
75
+ window.customElements.get(s.webComponentName) === void 0 && window.customElements.define(s.webComponentName, s);
407
76
  export {
408
- I as EpigraphQrCodeGenerator
77
+ s as EpigraphQrCodeGenerator
409
78
  };