@parent-tobias/chord-component 1.0.0 → 1.1.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,17 +1,16 @@
1
- import { css as b, LitElement as x, html as n } from "lit";
2
- import { customElement as w } from "./node_modules/@lit/reactive-element/decorators/custom-element.js";
3
- import { property as v } from "./node_modules/@lit/reactive-element/decorators/property.js";
1
+ import { LitElement as w, css as E, html as e } from "lit";
2
+ import { property as x } from "./node_modules/@lit/reactive-element/decorators/property.js";
4
3
  import { state as g } from "./node_modules/@lit/reactive-element/decorators/state.js";
5
- import { query as C } from "./node_modules/@lit/reactive-element/decorators/query.js";
6
- import { SVGuitarChord as D } from "svguitar";
7
- import { instruments as E, chordToNotes as $, chordOnInstrument as j } from "./music-utils.js";
8
- import { chordDataService as F } from "./chord-data-service.js";
9
- var O = Object.defineProperty, L = Object.getOwnPropertyDescriptor, d = (r, c, a, o) => {
10
- for (var i = o > 1 ? void 0 : o ? L(c, a) : c, h = r.length - 1, s; h >= 0; h--)
11
- (s = r[h]) && (i = (o ? s(c, a, i) : s(i)) || i);
12
- return o && i && O(c, a, i), i;
4
+ import { query as $ } from "./node_modules/@lit/reactive-element/decorators/query.js";
5
+ import { SVGuitarChord as C } from "svguitar";
6
+ import { instruments as D, chordToNotes as j, chordOnInstrument as F } from "./music-utils.js";
7
+ import { chordDataService as k } from "./chord-data-service.js";
8
+ var L = Object.defineProperty, a = (v, r, d, s) => {
9
+ for (var i = void 0, n = v.length - 1, c; n >= 0; n--)
10
+ (c = v[n]) && (i = c(r, d, i) || i);
11
+ return i && L(r, d, i), i;
13
12
  };
14
- let e = class extends x {
13
+ const u = class u extends w {
15
14
  constructor() {
16
15
  super(...arguments), this.instrument = "Standard Ukulele", this.chord = "", this.chordData = {}, this.isLoading = !1, this.loadError = null;
17
16
  }
@@ -24,7 +23,7 @@ let e = class extends x {
24
23
  async loadChordData() {
25
24
  this.isLoading = !0, this.loadError = null;
26
25
  try {
27
- const r = await F.getChordData(this.instrument);
26
+ const r = await k.getChordData(this.instrument);
28
27
  this.chordData = r.data;
29
28
  } catch (r) {
30
29
  console.error("Failed to load chord data:", r), this.loadError = "Failed to load chord data", this.chordData = {};
@@ -34,7 +33,7 @@ let e = class extends x {
34
33
  }
35
34
  render() {
36
35
  if (this.isLoading)
37
- return n`
36
+ return e`
38
37
  <div class='chord'>
39
38
  <div style="color: #90cdf4; font-size: 0.8rem; text-align: center; padding: 0.5rem;">
40
39
  Loading...
@@ -42,61 +41,61 @@ let e = class extends x {
42
41
  </div>
43
42
  `;
44
43
  if (this.loadError)
45
- return n`
44
+ return e`
46
45
  <div class='chord'>
47
46
  <div class='error'>${this.loadError}</div>
48
47
  </div>
49
48
  `;
50
49
  if (!this.chord)
51
- return n`
50
+ return e`
52
51
  <div class='chord'>
53
52
  <div class='error'>No chord specified</div>
54
53
  </div>
55
54
  `;
56
- const r = E.find(({ name: t }) => t === this.instrument);
55
+ const r = D.find(({ name: t }) => t === this.instrument);
57
56
  if (!r)
58
- return n`
57
+ return e`
59
58
  <div class='chord'>
60
59
  <span>${this.chord.replace(/(maj)$/, "")}</span>
61
60
  <div class='error'>Unknown instrument: ${this.instrument}</div>
62
61
  </div>
63
62
  `;
64
- const c = j(r), a = $(this.chord);
65
- if (!a || !a.notes || a.notes.length === 0)
66
- return n`
63
+ const d = F(r), s = j(this.chord);
64
+ if (!s || !s.notes || s.notes.length === 0)
65
+ return e`
67
66
  <div class='chord'>
68
67
  <span>${this.chord.replace(/(maj)$/, "")}</span>
69
68
  <div class='error'>Unknown chord: ${this.chord}</div>
70
69
  </div>
71
70
  `;
72
- const o = this.chordData[this.chord] ? this.chordData[this.chord] : {
71
+ const i = this.chordData[this.chord] ? this.chordData[this.chord] : {
73
72
  barres: [],
74
- fingers: c(a) || []
75
- }, i = o.fingers.map(
73
+ fingers: d(s) || []
74
+ }, n = i.fingers.map(
76
75
  ([, t]) => typeof t == "number" ? t : 1 / 0
77
- ), h = o.barres.map((t) => typeof t.fret == "number" ? t.fret : 0), s = [...i, ...h], y = s.length > 0 ? Math.min(...s.filter((t) => t > 0)) : 1, l = s.length > 0 ? Math.max(...s, 0) : 4;
76
+ ), c = i.barres.map((t) => typeof t.fret == "number" ? t.fret : 0), h = [...n, ...c], b = h.length > 0 ? Math.min(...h.filter((t) => t > 0)) : 1, l = h.length > 0 ? Math.max(...h, 0) : 4;
78
77
  let m = 1;
79
- l > 4 && (m = Math.max(1, y));
78
+ l > 4 && (m = Math.max(1, b));
80
79
  let p, f;
81
80
  m > 1 || l > 4 ? (p = Math.max(l - m + 1, 4), f = m) : (p = Math.max(l, 4), f = 1);
82
- const u = document.createElement("div");
81
+ const y = document.createElement("div");
83
82
  try {
84
- return new D(u).configure({
83
+ return new C(y).configure({
85
84
  strings: r.strings.length,
86
85
  frets: p,
87
86
  position: f,
88
87
  tuning: [...r.strings]
89
88
  }).chord({
90
- fingers: o.fingers,
91
- barres: o.barres
92
- }).draw(), n`
89
+ fingers: i.fingers,
90
+ barres: i.barres
91
+ }).draw(), e`
93
92
  <div class='chord'>
94
93
  <span>${this.chord.replace(/(maj)$/, "")}</span>
95
- <div class='diagram'>${u.firstChild}</div>
94
+ <div class='diagram'>${y.firstChild}</div>
96
95
  </div>
97
96
  `;
98
97
  } catch (t) {
99
- return console.error("Error generating chord diagram:", t), n`
98
+ return console.error("Error generating chord diagram:", t), e`
100
99
  <div class='chord'>
101
100
  <span>${this.chord.replace(/(maj)$/, "")}</span>
102
101
  <div class='error'>Error generating diagram</div>
@@ -105,7 +104,7 @@ let e = class extends x {
105
104
  }
106
105
  }
107
106
  };
108
- e.styles = b`
107
+ u.styles = E`
109
108
  :host {
110
109
  display: block;
111
110
  width: 100%;
@@ -151,31 +150,30 @@ e.styles = b`
151
150
  padding: 0.5rem;
152
151
  }
153
152
  `;
154
- d([
155
- v({
153
+ let o = u;
154
+ a([
155
+ x({
156
156
  type: String
157
157
  })
158
- ], e.prototype, "instrument", 2);
159
- d([
160
- v({
158
+ ], o.prototype, "instrument");
159
+ a([
160
+ x({
161
161
  type: String
162
162
  })
163
- ], e.prototype, "chord", 2);
164
- d([
165
- C(".diagram")
166
- ], e.prototype, "container", 2);
167
- d([
163
+ ], o.prototype, "chord");
164
+ a([
165
+ $(".diagram")
166
+ ], o.prototype, "container");
167
+ a([
168
168
  g()
169
- ], e.prototype, "chordData", 2);
170
- d([
169
+ ], o.prototype, "chordData");
170
+ a([
171
171
  g()
172
- ], e.prototype, "isLoading", 2);
173
- d([
172
+ ], o.prototype, "isLoading");
173
+ a([
174
174
  g()
175
- ], e.prototype, "loadError", 2);
176
- e = d([
177
- w("chord-diagram")
178
- ], e);
175
+ ], o.prototype, "loadError");
176
+ customElements.get("chord-diagram") || customElements.define("chord-diagram", o);
179
177
  export {
180
- e as ChordDiagram
178
+ o as ChordDiagram
181
179
  };
@@ -1,22 +1,21 @@
1
- import { css as b, LitElement as v, html as l } from "lit";
2
- import { customElement as y } from "./node_modules/@lit/reactive-element/decorators/custom-element.js";
3
- import { property as m } from "./node_modules/@lit/reactive-element/decorators/property.js";
1
+ import { LitElement as y, css as w, html as d } from "lit";
2
+ import { property as b } from "./node_modules/@lit/reactive-element/decorators/property.js";
4
3
  import { state as c } from "./node_modules/@lit/reactive-element/decorators/state.js";
5
- import { query as w } from "./node_modules/@lit/reactive-element/decorators/query.js";
6
- import { SVGuitarChord as x } from "svguitar";
7
- import { instruments as g, chordToNotes as F, chordOnInstrument as k } from "./music-utils.js";
8
- import { chordDataService as f } from "./chord-data-service.js";
9
- var M = Object.defineProperty, C = Object.getOwnPropertyDescriptor, d = (t, i, e, r) => {
10
- for (var s = r > 1 ? void 0 : r ? C(i, e) : i, o = t.length - 1, n; o >= 0; o--)
11
- (n = t[o]) && (s = (r ? n(i, e, s) : n(s)) || s);
12
- return r && s && M(i, e, s), s;
4
+ import { query as x } from "./node_modules/@lit/reactive-element/decorators/query.js";
5
+ import { SVGuitarChord as k } from "svguitar";
6
+ import { instruments as f, chordToNotes as F, chordOnInstrument as M } from "./music-utils.js";
7
+ import { chordDataService as g } from "./chord-data-service.js";
8
+ var C = Object.defineProperty, l = (p, t, i, e) => {
9
+ for (var r = void 0, o = p.length - 1, s; o >= 0; o--)
10
+ (s = p[o]) && (r = s(t, i, r) || r);
11
+ return r && C(t, i, r), r;
13
12
  };
14
- let a = class extends v {
13
+ const m = class m extends y {
15
14
  constructor() {
16
15
  super(...arguments), this.instrument = "Standard Ukulele", this.chord = "", this.fingers = [], this.barres = [], this.viewPosition = 1, this.isLoading = !1, this.isModified = !1, this.editMode = "finger";
17
16
  }
18
17
  get numStrings() {
19
- const t = g.find(({ name: i }) => i === this.instrument);
18
+ const t = f.find(({ name: i }) => i === this.instrument);
20
19
  return (t == null ? void 0 : t.strings.length) || 4;
21
20
  }
22
21
  get calculatedPosition() {
@@ -30,8 +29,8 @@ let a = class extends v {
30
29
  }
31
30
  get maxFrets() {
32
31
  const t = [
33
- ...this.fingers.map(([, s]) => typeof s == "number" ? s : 0),
34
- ...this.barres.map((s) => typeof s.fret == "number" ? s.fret : 0)
32
+ ...this.fingers.map(([, o]) => typeof o == "number" ? o : 0),
33
+ ...this.barres.map((o) => typeof o.fret == "number" ? o.fret : 0)
35
34
  ], i = Math.max(...t, 0), e = 5, r = Math.max(i - this.viewPosition + 1, 4);
36
35
  return Math.max(e, r);
37
36
  }
@@ -45,11 +44,11 @@ let a = class extends v {
45
44
  if (this.chord) {
46
45
  this.isLoading = !0;
47
46
  try {
48
- const t = await f.getChord(this.instrument, this.chord, !0);
47
+ const t = await g.getChord(this.instrument, this.chord, !0);
49
48
  if (t)
50
49
  this.fingers = [...t.fingers], this.barres = [...t.barres], this.viewPosition = this.calculatedPosition, this.isModified = !1;
51
50
  else {
52
- const i = await f.getChord(this.instrument, this.chord, !1);
51
+ const i = await g.getChord(this.instrument, this.chord, !1);
53
52
  i ? (this.fingers = [...i.fingers], this.barres = [...i.barres], this.viewPosition = this.calculatedPosition, this.isModified = !1) : this.generateDefaultChord();
54
53
  }
55
54
  } catch (t) {
@@ -60,38 +59,38 @@ let a = class extends v {
60
59
  }
61
60
  }
62
61
  generateDefaultChord() {
63
- const t = g.find(({ name: r }) => r === this.instrument);
62
+ const t = f.find(({ name: r }) => r === this.instrument);
64
63
  if (!t) return;
65
- const i = k(t), e = F(this.chord);
64
+ const i = M(t), e = F(this.chord);
66
65
  e && e.notes && e.notes.length > 0 && (this.fingers = i(e) || [], this.barres = [], this.viewPosition = this.calculatedPosition, this.isModified = !1);
67
66
  }
68
67
  renderDiagram() {
69
68
  if (!this.diagramContainer) return;
70
- const t = g.find(({ name: e }) => e === this.instrument);
69
+ const t = f.find(({ name: e }) => e === this.instrument);
71
70
  if (!t) return;
72
71
  this.diagramContainer.innerHTML = "";
73
72
  const i = document.createElement("div");
74
73
  try {
75
- const e = this.fingers.map(([o, n]) => {
76
- if (typeof n == "number") {
77
- const h = n - this.viewPosition + 1;
74
+ const e = this.fingers.map(([s, a]) => {
75
+ if (typeof a == "number") {
76
+ const h = a - this.viewPosition + 1;
78
77
  if (h >= 0 && h <= this.maxFrets)
79
- return [o, h];
78
+ return [s, h];
80
79
  } else
81
- return [o, n];
80
+ return [s, a];
82
81
  return null;
83
- }).filter((o) => o !== null), r = this.barres.map((o) => {
84
- if (typeof o.fret == "number") {
85
- const n = o.fret - this.viewPosition + 1;
86
- if (n >= 0 && n <= this.maxFrets)
82
+ }).filter((s) => s !== null), r = this.barres.map((s) => {
83
+ if (typeof s.fret == "number") {
84
+ const a = s.fret - this.viewPosition + 1;
85
+ if (a >= 0 && a <= this.maxFrets)
87
86
  return {
88
- ...o,
89
- fret: n
87
+ ...s,
88
+ fret: a
90
89
  };
91
90
  }
92
91
  return null;
93
- }).filter((o) => o !== null);
94
- new x(i).configure({
92
+ }).filter((s) => s !== null);
93
+ new k(i).configure({
95
94
  strings: t.strings.length,
96
95
  frets: this.maxFrets,
97
96
  position: this.viewPosition,
@@ -110,11 +109,11 @@ let a = class extends v {
110
109
  t && t.addEventListener("click", (e) => this.handleDiagramClick(e));
111
110
  }
112
111
  handleDiagramClick(t) {
113
- const e = t.currentTarget.getBoundingClientRect(), r = t.clientX - e.left, s = t.clientY - e.top, o = e.width / (this.numStrings + 1), n = e.height / (this.maxFrets + 2), h = Math.round((e.width - r) / o);
114
- let u = Math.round((s - n) / n);
112
+ const e = t.currentTarget.getBoundingClientRect(), r = t.clientX - e.left, o = t.clientY - e.top, s = e.width / (this.numStrings + 1), a = e.height / (this.maxFrets + 2), h = Math.round((e.width - r) / s);
113
+ let u = Math.round((o - a) / a);
115
114
  u = u + this.viewPosition - 1;
116
- const p = this.viewPosition + this.maxFrets - 1;
117
- h >= 1 && h <= this.numStrings && u >= 0 && u <= p && this.handlePositionClick(h, u);
115
+ const v = this.viewPosition + this.maxFrets - 1;
116
+ h >= 1 && h <= this.numStrings && u >= 0 && u <= v && this.handlePositionClick(h, u);
118
117
  }
119
118
  handlePositionClick(t, i) {
120
119
  this.editMode === "finger" ? this.addOrUpdateFinger(t, i) : this.editMode === "remove" && this.removeFinger(t);
@@ -132,7 +131,7 @@ let a = class extends v {
132
131
  async saveChord() {
133
132
  if (this.chord)
134
133
  try {
135
- await f.saveUserChord(
134
+ await g.saveUserChord(
136
135
  this.instrument,
137
136
  this.chord,
138
137
  {
@@ -156,7 +155,7 @@ let a = class extends v {
156
155
  async resetToDefault() {
157
156
  if (confirm("Reset to default chord? This will discard your changes."))
158
157
  try {
159
- await f.deleteUserChord(this.instrument, this.chord), await this.loadChordData(), this.dispatchEvent(new CustomEvent("chord-reset", {
158
+ await g.deleteUserChord(this.instrument, this.chord), await this.loadChordData(), this.dispatchEvent(new CustomEvent("chord-reset", {
160
159
  detail: {
161
160
  instrument: this.instrument,
162
161
  chord: this.chord
@@ -213,15 +212,15 @@ let a = class extends v {
213
212
  this.barres.splice(t, 1), this.barres = [...this.barres], this.isModified = !0, this.requestUpdate();
214
213
  }
215
214
  render() {
216
- return this.isLoading ? l`
215
+ return this.isLoading ? d`
217
216
  <div class='editor'>
218
217
  <div class='info'>Loading...</div>
219
218
  </div>
220
- ` : this.chord ? l`
219
+ ` : this.chord ? d`
221
220
  <div class='editor'>
222
221
  <div class='header'>
223
222
  <h3>${this.chord} - ${this.instrument}</h3>
224
- ${this.isModified ? l`<span class='badge modified'>Modified</span>` : l`<span class='badge'>Saved</span>`}
223
+ ${this.isModified ? d`<span class='badge modified'>Modified</span>` : d`<span class='badge'>Saved</span>`}
225
224
  </div>
226
225
 
227
226
  <div class='diagram-container'></div>
@@ -266,9 +265,9 @@ let a = class extends v {
266
265
  <div class='control-group'>
267
266
  <label>Finger Positions (${this.fingers.length})</label>
268
267
  <div class='finger-list'>
269
- ${this.fingers.length === 0 ? l`
268
+ ${this.fingers.length === 0 ? d`
270
269
  <div class='info'>No finger positions. Click the diagram or use "Add Finger" below.</div>
271
- ` : this.fingers.map((t, i) => l`
270
+ ` : this.fingers.map((t, i) => d`
272
271
  <div class='finger-item'>
273
272
  <div class='finger-inputs'>
274
273
  <label style="color: #a0aec0; font-size: 0.75rem;">String:</label>
@@ -276,14 +275,14 @@ let a = class extends v {
276
275
  type="number"
277
276
  min="1"
278
277
  max="${this.numStrings}"
279
- .value="${t[0]}"
278
+ .value="${t[0].toString()}"
280
279
  @input=${(e) => this.updateFingerString(i, e.target.value)}
281
280
  />
282
281
  <label style="color: #a0aec0; font-size: 0.75rem;">Fret:</label>
283
282
  <input
284
283
  type="number"
285
284
  min="0"
286
- .value="${t[1]}"
285
+ .value="${t[1].toString()}"
287
286
  @input=${(e) => this.updateFingerFret(i, e.target.value)}
288
287
  />
289
288
  </div>
@@ -304,9 +303,9 @@ let a = class extends v {
304
303
  <div class='control-group'>
305
304
  <label>Barre Positions (${this.barres.length})</label>
306
305
  <div class='finger-list'>
307
- ${this.barres.length === 0 ? l`
306
+ ${this.barres.length === 0 ? d`
308
307
  <div class='info'>No barres. Use "Add Barre" below to create one.</div>
309
- ` : this.barres.map((t, i) => l`
308
+ ` : this.barres.map((t, i) => d`
310
309
  <div class='finger-item'>
311
310
  <div class='finger-inputs'>
312
311
  <label style="color: #a0aec0; font-size: 0.75rem;">From:</label>
@@ -314,7 +313,7 @@ let a = class extends v {
314
313
  type="number"
315
314
  min="1"
316
315
  max="${this.numStrings}"
317
- .value="${t.fromString}"
316
+ .value="${t.fromString.toString()}"
318
317
  @input=${(e) => this.updateBarreFromString(i, e.target.value)}
319
318
  />
320
319
  <label style="color: #a0aec0; font-size: 0.75rem;">To:</label>
@@ -322,14 +321,14 @@ let a = class extends v {
322
321
  type="number"
323
322
  min="1"
324
323
  max="${this.numStrings}"
325
- .value="${t.toString}"
324
+ .value="${t.toString.toString()}"
326
325
  @input=${(e) => this.updateBarreToString(i, e.target.value)}
327
326
  />
328
327
  <label style="color: #a0aec0; font-size: 0.75rem;">Fret:</label>
329
328
  <input
330
329
  type="number"
331
330
  min="0"
332
- .value="${t.fret}"
331
+ .value="${t.fret.toString()}"
333
332
  @input=${(e) => this.updateBarreFret(i, e.target.value)}
334
333
  />
335
334
  </div>
@@ -374,14 +373,14 @@ let a = class extends v {
374
373
  ${this.editMode === "finger" ? "Click on the diagram to add or update finger positions." : "Click on a finger position to remove it."}
375
374
  </div>
376
375
  </div>
377
- ` : l`
376
+ ` : d`
378
377
  <div class='editor'>
379
378
  <div class='error'>No chord specified</div>
380
379
  </div>
381
380
  `;
382
381
  }
383
382
  };
384
- a.styles = b`
383
+ m.styles = w`
385
384
  :host {
386
385
  display: block;
387
386
  width: 100%;
@@ -656,36 +655,35 @@ a.styles = b`
656
655
  font-style: italic;
657
656
  }
658
657
  `;
659
- d([
660
- m({ type: String })
661
- ], a.prototype, "instrument", 2);
662
- d([
663
- m({ type: String })
664
- ], a.prototype, "chord", 2);
665
- d([
658
+ let n = m;
659
+ l([
660
+ b({ type: String })
661
+ ], n.prototype, "instrument");
662
+ l([
663
+ b({ type: String })
664
+ ], n.prototype, "chord");
665
+ l([
666
666
  c()
667
- ], a.prototype, "fingers", 2);
668
- d([
667
+ ], n.prototype, "fingers");
668
+ l([
669
669
  c()
670
- ], a.prototype, "barres", 2);
671
- d([
670
+ ], n.prototype, "barres");
671
+ l([
672
672
  c()
673
- ], a.prototype, "viewPosition", 2);
674
- d([
673
+ ], n.prototype, "viewPosition");
674
+ l([
675
675
  c()
676
- ], a.prototype, "isLoading", 2);
677
- d([
676
+ ], n.prototype, "isLoading");
677
+ l([
678
678
  c()
679
- ], a.prototype, "isModified", 2);
680
- d([
679
+ ], n.prototype, "isModified");
680
+ l([
681
681
  c()
682
- ], a.prototype, "editMode", 2);
683
- d([
684
- w(".diagram-container")
685
- ], a.prototype, "diagramContainer", 2);
686
- a = d([
687
- y("chord-editor")
688
- ], a);
682
+ ], n.prototype, "editMode");
683
+ l([
684
+ x(".diagram-container")
685
+ ], n.prototype, "diagramContainer");
686
+ customElements.get("chord-editor") || customElements.define("chord-editor", n);
689
687
  export {
690
- a as ChordEditor
688
+ n as ChordEditor
691
689
  };
@@ -1,14 +1,13 @@
1
- import { css as p, LitElement as c, html as m } from "lit";
2
- import { customElement as l } from "./node_modules/@lit/reactive-element/decorators/custom-element.js";
3
- import { property as d } from "./node_modules/@lit/reactive-element/decorators/property.js";
4
- import { state as u } from "./node_modules/@lit/reactive-element/decorators/state.js";
1
+ import { LitElement as p, css as c, html as n } from "lit";
2
+ import { property as m } from "./node_modules/@lit/reactive-element/decorators/property.js";
3
+ import { state as l } from "./node_modules/@lit/reactive-element/decorators/state.js";
5
4
  import "./chord-diagram.js";
6
- var f = Object.defineProperty, g = Object.getOwnPropertyDescriptor, o = (t, e, n, i) => {
7
- for (var r = i > 1 ? void 0 : i ? g(e, n) : e, a = t.length - 1, h; a >= 0; a--)
8
- (h = t[a]) && (r = (i ? h(e, n, r) : h(r)) || r);
9
- return i && r && f(e, n, r), r;
5
+ var u = Object.defineProperty, a = (d, t, s, f) => {
6
+ for (var r = void 0, i = d.length - 1, h; i >= 0; i--)
7
+ (h = d[i]) && (r = h(t, s, r) || r);
8
+ return r && u(t, s, r), r;
10
9
  };
11
- let s = class extends c {
10
+ const o = class o extends p {
12
11
  constructor() {
13
12
  super(...arguments), this.instrument = "Standard Ukulele", this.chords = "[]", this.numChords = 0;
14
13
  }
@@ -27,26 +26,26 @@ let s = class extends c {
27
26
  }
28
27
  render() {
29
28
  const t = this.parsedChords;
30
- return t.length === 0 ? m`
29
+ return t.length === 0 ? n`
31
30
  <header>
32
31
  <h3>${this.instrument}</h3>
33
32
  </header>
34
33
  <div class='empty-state'>
35
34
  No chords to display
36
35
  </div>
37
- ` : m`
36
+ ` : n`
38
37
  <header>
39
38
  <h3>${this.instrument} (${this.numChords} chord${this.numChords !== 1 ? "s" : ""})</h3>
40
39
  </header>
41
40
  <div class='list'>
42
41
  ${t.map(
43
- (e) => m`<chord-diagram chord=${e} instrument='${this.instrument}'></chord-diagram>`
42
+ (s) => n`<chord-diagram chord=${s} instrument='${this.instrument}'></chord-diagram>`
44
43
  )}
45
44
  </div>
46
45
  `;
47
46
  }
48
47
  };
49
- s.styles = p`
48
+ o.styles = c`
50
49
  :host {
51
50
  display: block;
52
51
  width: 100%;
@@ -100,20 +99,19 @@ s.styles = p`
100
99
  }
101
100
  }
102
101
  `;
103
- o([
104
- d({
102
+ let e = o;
103
+ a([
104
+ m({
105
105
  type: String
106
106
  })
107
- ], s.prototype, "instrument", 2);
108
- o([
109
- d()
110
- ], s.prototype, "chords", 2);
111
- o([
112
- u()
113
- ], s.prototype, "numChords", 2);
114
- s = o([
115
- l("chord-list")
116
- ], s);
107
+ ], e.prototype, "instrument");
108
+ a([
109
+ m()
110
+ ], e.prototype, "chords");
111
+ a([
112
+ l()
113
+ ], e.prototype, "numChords");
114
+ customElements.get("chord-list") || customElements.define("chord-list", e);
117
115
  export {
118
- s as ChordList
116
+ e as ChordList
119
117
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@parent-tobias/chord-component",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "Lit-based web components for displaying musical chord diagrams and chord lists",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -80,4 +80,4 @@
80
80
  "engines": {
81
81
  "node": ">=18.0.0"
82
82
  }
83
- }
83
+ }
@@ -1,5 +1,5 @@
1
1
  import { LitElement, css, html } from 'lit';
2
- import { customElement, property, query, state } from 'lit/decorators.js';
2
+ import { property, query, state } from 'lit/decorators.js';
3
3
  import { SVGuitarChord } from 'svguitar';
4
4
 
5
5
  import { instruments, chordOnInstrument, chordToNotes } from './music-utils.js';
@@ -19,8 +19,12 @@ import type { InstrumentDefault } from './default-chords.js';
19
19
  * <chord-diagram chord="C" instrument="Standard Ukulele"></chord-diagram>
20
20
  * <chord-diagram chord="Am7" instrument="Standard Guitar"></chord-diagram>
21
21
  * ```
22
+ *
23
+ * Remove the customElement decorator as it's not going to handle re-registration gracefully.
24
+ * Instead, register the component manually if it has not already been.
22
25
  */
23
- @customElement('chord-diagram')
26
+
27
+ // @customElement('chord-diagram')
24
28
  export class ChordDiagram extends LitElement {
25
29
 
26
30
  static styles = css`
@@ -252,4 +256,8 @@ export class ChordDiagram extends LitElement {
252
256
  `;
253
257
  }
254
258
  }
259
+ }
260
+
261
+ if(!customElements.get('chord-diagram')) {
262
+ customElements.define('chord-diagram', ChordDiagram);
255
263
  }
@@ -1,5 +1,5 @@
1
1
  import { LitElement, css, html } from 'lit';
2
- import { customElement, property, state, query } from 'lit/decorators.js';
2
+ import { property, state, query } from 'lit/decorators.js';
3
3
  import { SVGuitarChord } from 'svguitar';
4
4
  import type { Finger, Barre } from 'svguitar';
5
5
 
@@ -23,7 +23,8 @@ import { chordDataService } from './chord-data-service.js';
23
23
  * <chord-editor chord="C" instrument="Standard Ukulele"></chord-editor>
24
24
  * ```
25
25
  */
26
- @customElement('chord-editor')
26
+
27
+ // @customElement('chord-editor')
27
28
  export class ChordEditor extends LitElement {
28
29
 
29
30
  static styles = css`
@@ -816,14 +817,14 @@ export class ChordEditor extends LitElement {
816
817
  type="number"
817
818
  min="1"
818
819
  max="${this.numStrings}"
819
- .value="${finger[0]}"
820
+ .value="${finger[0].toString()}"
820
821
  @input=${(e: Event) => this.updateFingerString(index, (e.target as HTMLInputElement).value)}
821
822
  />
822
823
  <label style="color: #a0aec0; font-size: 0.75rem;">Fret:</label>
823
824
  <input
824
825
  type="number"
825
826
  min="0"
826
- .value="${finger[1]}"
827
+ .value="${finger[1].toString()}"
827
828
  @input=${(e: Event) => this.updateFingerFret(index, (e.target as HTMLInputElement).value)}
828
829
  />
829
830
  </div>
@@ -854,7 +855,7 @@ export class ChordEditor extends LitElement {
854
855
  type="number"
855
856
  min="1"
856
857
  max="${this.numStrings}"
857
- .value="${barre.fromString}"
858
+ .value="${barre.fromString.toString()}"
858
859
  @input=${(e: Event) => this.updateBarreFromString(index, (e.target as HTMLInputElement).value)}
859
860
  />
860
861
  <label style="color: #a0aec0; font-size: 0.75rem;">To:</label>
@@ -862,14 +863,14 @@ export class ChordEditor extends LitElement {
862
863
  type="number"
863
864
  min="1"
864
865
  max="${this.numStrings}"
865
- .value="${barre.toString}"
866
+ .value="${barre.toString.toString()}"
866
867
  @input=${(e: Event) => this.updateBarreToString(index, (e.target as HTMLInputElement).value)}
867
868
  />
868
869
  <label style="color: #a0aec0; font-size: 0.75rem;">Fret:</label>
869
870
  <input
870
871
  type="number"
871
872
  min="0"
872
- .value="${barre.fret}"
873
+ .value="${barre.fret.toString()}"
873
874
  @input=${(e: Event) => this.updateBarreFret(index, (e.target as HTMLInputElement).value)}
874
875
  />
875
876
  </div>
@@ -917,3 +918,7 @@ export class ChordEditor extends LitElement {
917
918
  `;
918
919
  }
919
920
  }
921
+
922
+ if(!customElements.get('chord-editor')) {
923
+ customElements.define('chord-editor', ChordEditor);
924
+ }
package/src/chord-list.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { LitElement, css, html, type PropertyValues } from 'lit';
2
- import { customElement, property, state } from 'lit/decorators.js';
2
+ import { property, state } from 'lit/decorators.js';
3
3
  import './chord-diagram.js';
4
4
 
5
5
  /**
@@ -16,7 +16,7 @@ import './chord-diagram.js';
16
16
  * <chord-list instrument="Standard Guitar" chords='["E", "A", "D"]'></chord-list>
17
17
  * ```
18
18
  */
19
- @customElement('chord-list')
19
+ // @customElement('chord-list')
20
20
  export class ChordList extends LitElement {
21
21
 
22
22
  /**
@@ -142,4 +142,8 @@ export class ChordList extends LitElement {
142
142
  </div>
143
143
  `;
144
144
  }
145
+ }
146
+
147
+ if(!customElements.get('chord-list')) {
148
+ customElements.define('chord-list', ChordList);
145
149
  }
@@ -1,13 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright 2017 Google LLC
4
- * SPDX-License-Identifier: BSD-3-Clause
5
- */
6
- const s = (e) => (t, n) => {
7
- n !== void 0 ? n.addInitializer(() => {
8
- customElements.define(e, t);
9
- }) : customElements.define(e, t);
10
- };
11
- export {
12
- s as customElement
13
- };