@parent-tobias/chord-component 1.0.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/LICENSE +21 -0
- package/README.md +359 -0
- package/dist/chord-data-service.js +190 -0
- package/dist/chord-diagram.js +181 -0
- package/dist/chord-editor.js +691 -0
- package/dist/chord-list.js +119 -0
- package/dist/default-chords.js +322 -0
- package/dist/index.js +26 -0
- package/dist/indexed-db-service.js +228 -0
- package/dist/music-utils.js +128 -0
- package/dist/node_modules/@lit/reactive-element/css-tag.js +42 -0
- package/dist/node_modules/@lit/reactive-element/decorators/base.js +9 -0
- package/dist/node_modules/@lit/reactive-element/decorators/custom-element.js +13 -0
- package/dist/node_modules/@lit/reactive-element/decorators/property.js +37 -0
- package/dist/node_modules/@lit/reactive-element/decorators/query.js +20 -0
- package/dist/node_modules/@lit/reactive-element/decorators/state.js +12 -0
- package/dist/node_modules/@lit/reactive-element/reactive-element.js +251 -0
- package/package.json +83 -0
- package/src/chord-data-service.ts +275 -0
- package/src/chord-diagram.ts +255 -0
- package/src/chord-editor.ts +919 -0
- package/src/chord-list.ts +145 -0
- package/src/default-chords.ts +333 -0
- package/src/index.ts +7 -0
- package/src/indexed-db-service.ts +356 -0
- package/src/music-utils.ts +216 -0
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
const u = [
|
|
2
|
+
{ key: "A", accidental: "#", relativeMinor: "F#" },
|
|
3
|
+
{ key: "A#", accidental: "#", relativeMinor: "G" },
|
|
4
|
+
{ key: "Bb", accidental: "b", relativeMinor: "G" },
|
|
5
|
+
{ key: "B", accidental: "#", relativeMinor: "G#" },
|
|
6
|
+
{ key: "C", accidental: "b", relativeMinor: "A" },
|
|
7
|
+
{ key: "C#", accidental: "#", relativeMinor: "A#" },
|
|
8
|
+
{ key: "Db", accidental: "b", relativeMinor: "Bb" },
|
|
9
|
+
{ key: "D", accidental: "#", relativeMinor: "B" },
|
|
10
|
+
{ key: "D#", accidental: "#", relativeMinor: "C" },
|
|
11
|
+
{ key: "Eb", accidental: "b", relativeMinor: "C" },
|
|
12
|
+
{ key: "E", accidental: "#", relativeMinor: "C#" },
|
|
13
|
+
{ key: "F", accidental: "b", relativeMinor: "D" },
|
|
14
|
+
{ key: "F#", accidental: "#", relativeMinor: "D#" },
|
|
15
|
+
{ key: "Gb", accidental: "b", relativeMinor: "Eb" },
|
|
16
|
+
{ key: "G", accidental: "#", relativeMinor: "E" },
|
|
17
|
+
{ key: "G#", accidental: "#", relativeMinor: "F" },
|
|
18
|
+
{ key: "Ab", accidental: "b", relativeMinor: "F" }
|
|
19
|
+
], c = [
|
|
20
|
+
["A"],
|
|
21
|
+
["A#", "Bb"],
|
|
22
|
+
["B"],
|
|
23
|
+
["C"],
|
|
24
|
+
["C#", "Db"],
|
|
25
|
+
["D"],
|
|
26
|
+
["D#", "Eb"],
|
|
27
|
+
["E"],
|
|
28
|
+
["F"],
|
|
29
|
+
["F#", "Gb"],
|
|
30
|
+
["G"],
|
|
31
|
+
["G#", "Ab"]
|
|
32
|
+
], b = [
|
|
33
|
+
{ variant: "maj", tones: [0, 4, 7] },
|
|
34
|
+
{ variant: "m", tones: [0, 3, 7] },
|
|
35
|
+
{ variant: "min", tones: [0, 3, 7] },
|
|
36
|
+
{ variant: "dim", tones: [0, 3, 6] },
|
|
37
|
+
{ variant: "aug", tones: [0, 4, 8] },
|
|
38
|
+
{ variant: "7", tones: [0, 4, 7, 10] },
|
|
39
|
+
{ variant: "m7", tones: [0, 3, 7, 10] },
|
|
40
|
+
{ variant: "maj7", tones: [0, 4, 7, 11] },
|
|
41
|
+
{ variant: "aug7", tones: [0, 4, 8, 10] },
|
|
42
|
+
{ variant: "dim7", tones: [0, 3, 6, 9] },
|
|
43
|
+
{ variant: "m7b5", tones: [0, 3, 6, 10] },
|
|
44
|
+
{ variant: "mMaj7", tones: [0, 3, 7, 11] },
|
|
45
|
+
{ variant: "sus2", tones: [0, 2, 7] },
|
|
46
|
+
{ variant: "sus4", tones: [0, 5, 7] },
|
|
47
|
+
{ variant: "7sus2", tones: [0, 2, 7, 10] },
|
|
48
|
+
{ variant: "7sus4", tones: [0, 5, 7, 10] },
|
|
49
|
+
{ variant: "9", tones: [0, 4, 7, 10, 14] },
|
|
50
|
+
{ variant: "m9", tones: [0, 3, 7, 10, 14] },
|
|
51
|
+
{ variant: "maj9", tones: [0, 4, 7, 11, 14] },
|
|
52
|
+
{ variant: "11", tones: [0, 4, 7, 10, 14, 17] },
|
|
53
|
+
{ variant: "m11", tones: [0, 3, 7, 10, 14, 17] },
|
|
54
|
+
{ variant: "13", tones: [0, 4, 7, 10, 14, 17, 21] },
|
|
55
|
+
{ variant: "m13", tones: [0, 3, 7, 10, 14, 17, 21] },
|
|
56
|
+
{ variant: "5", tones: [0, 7] },
|
|
57
|
+
{ variant: "6", tones: [0, 4, 7, 9] },
|
|
58
|
+
{ variant: "m6", tones: [0, 3, 7, 9] },
|
|
59
|
+
{ variant: "add9", tones: [0, 4, 7, 14] },
|
|
60
|
+
{ variant: "mAdd9", tones: [0, 3, 7, 14] }
|
|
61
|
+
], k = [
|
|
62
|
+
{ variant: "major", tones: [0, 2, 4, 5, 7, 9, 11] },
|
|
63
|
+
{ variant: "minor", tones: [0, 2, 3, 5, 7, 8, 10] },
|
|
64
|
+
{ variant: "major pentatonic", tones: [0, 2, 4, 7, 9] },
|
|
65
|
+
{ variant: "minor pentatonic", tones: [0, 3, 5, 7, 10] },
|
|
66
|
+
{ variant: "blues", tones: [0, 3, 5, 6, 7, 10] }
|
|
67
|
+
], f = [
|
|
68
|
+
{ variant: "major", chords: ["maj", "min", "min", "maj", "maj", "min", "dim"] },
|
|
69
|
+
{ variant: "minor", chords: ["min", "dim", "maj", "min", "min", "maj", "maj"] }
|
|
70
|
+
], A = [
|
|
71
|
+
{ name: "Standard Ukulele", strings: ["G", "C", "E", "A"], frets: 19 },
|
|
72
|
+
{ name: "Baritone Ukulele", strings: ["D", "G", "B", "E"], frets: 19 },
|
|
73
|
+
{ name: "5ths tuned Ukulele", strings: ["C", "G", "D", "A"], frets: 19 },
|
|
74
|
+
{ name: "Standard Guitar", strings: ["E", "A", "D", "G", "B", "E"], frets: 15 },
|
|
75
|
+
{ name: "Drop-D Guitar", strings: ["D", "A", "D", "G", "B", "E"], frets: 15 },
|
|
76
|
+
{ name: "Standard Mandolin", strings: ["G", "D", "A", "E"], frets: 20 }
|
|
77
|
+
], y = /\[([A-Ga-g](?:#|b)?)(m|min|maj|aug|dim|7|m7|maj7|aug7|dim7|m7b5|mMaj7|sus2|sus4|7sus2|7sus4|9|m9|maj9|11|m11|13|m13|5|6|m6|add9|mAdd9)?(-[a-zA-Z0-9]*)?\]/gm, M = (e) => {
|
|
78
|
+
const n = /* @__PURE__ */ new Map();
|
|
79
|
+
return [...e.matchAll(y)].forEach(([, t, a, s]) => {
|
|
80
|
+
n.set(`${t}${a || ""}${s || ""}`, { key: t, chord: a, alt: s });
|
|
81
|
+
}), n;
|
|
82
|
+
}, j = (e) => (n) => {
|
|
83
|
+
if (!e || !n) return;
|
|
84
|
+
const { strings: t } = e;
|
|
85
|
+
return [...t].reverse().map((a, s) => {
|
|
86
|
+
let r = 0, i = l(a), m = c[i];
|
|
87
|
+
for (; m.every((o) => {
|
|
88
|
+
var d;
|
|
89
|
+
return !((d = n == null ? void 0 : n.notes) != null && d.includes(o));
|
|
90
|
+
}); )
|
|
91
|
+
++r, m = c[(r + i) % c.length];
|
|
92
|
+
return [s + 1, r];
|
|
93
|
+
});
|
|
94
|
+
}, l = (e) => c.findIndex((n) => n.includes(e)), G = (e) => {
|
|
95
|
+
var m;
|
|
96
|
+
const n = Array.from(M(`[${e}]`));
|
|
97
|
+
if (!n || !n.length) return { name: "", notes: [] };
|
|
98
|
+
const [, { key: t, chord: a, alt: s }] = n[0], { accidental: r } = u.find(
|
|
99
|
+
(o) => o.key === t
|
|
100
|
+
) ?? { accidental: "" }, i = l(t);
|
|
101
|
+
return {
|
|
102
|
+
name: `${t}${a || ""}${s || ""}`,
|
|
103
|
+
notes: (m = b.find((o) => a ? o.variant === a : o.variant === "maj")) == null ? void 0 : m.tones.map(
|
|
104
|
+
(o) => c[(o + i) % c.length].find((d, g, v) => v.length > 1 && r ? d.endsWith(r) : v[0])
|
|
105
|
+
)
|
|
106
|
+
};
|
|
107
|
+
}, D = (e, n) => {
|
|
108
|
+
var r;
|
|
109
|
+
const t = l(e), { accidental: a } = u.find(
|
|
110
|
+
(i) => i.key === e
|
|
111
|
+
) ?? { accidental: "" };
|
|
112
|
+
return (r = k.find(({ variant: i }) => i === n)) == null ? void 0 : r.tones.map(
|
|
113
|
+
(i) => c[(i + t) % c.length].find((m, o, d) => d.length > 1 && a ? m.endsWith(a) : d[0])
|
|
114
|
+
);
|
|
115
|
+
};
|
|
116
|
+
export {
|
|
117
|
+
j as chordOnInstrument,
|
|
118
|
+
G as chordToNotes,
|
|
119
|
+
b as chords,
|
|
120
|
+
f as chordsPerScale,
|
|
121
|
+
l as findBase,
|
|
122
|
+
A as instruments,
|
|
123
|
+
u as keys,
|
|
124
|
+
c as notes,
|
|
125
|
+
M as parseChords,
|
|
126
|
+
D as scaleTones,
|
|
127
|
+
k as scales
|
|
128
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2019 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
5
|
+
*/
|
|
6
|
+
const S = globalThis, n = S.ShadowRoot && (S.ShadyCSS === void 0 || S.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype, l = Symbol(), c = /* @__PURE__ */ new WeakMap();
|
|
7
|
+
class a {
|
|
8
|
+
constructor(s, e, o) {
|
|
9
|
+
if (this._$cssResult$ = !0, o !== l) throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");
|
|
10
|
+
this.cssText = s, this.t = e;
|
|
11
|
+
}
|
|
12
|
+
get styleSheet() {
|
|
13
|
+
let s = this.o;
|
|
14
|
+
const e = this.t;
|
|
15
|
+
if (n && s === void 0) {
|
|
16
|
+
const o = e !== void 0 && e.length === 1;
|
|
17
|
+
o && (s = c.get(e)), s === void 0 && ((this.o = s = new CSSStyleSheet()).replaceSync(this.cssText), o && c.set(e, s));
|
|
18
|
+
}
|
|
19
|
+
return s;
|
|
20
|
+
}
|
|
21
|
+
toString() {
|
|
22
|
+
return this.cssText;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
const r = (t) => new a(typeof t == "string" ? t : t + "", void 0, l), h = (t, s) => {
|
|
26
|
+
if (n) t.adoptedStyleSheets = s.map((e) => e instanceof CSSStyleSheet ? e : e.styleSheet);
|
|
27
|
+
else for (const e of s) {
|
|
28
|
+
const o = document.createElement("style"), i = S.litNonce;
|
|
29
|
+
i !== void 0 && o.setAttribute("nonce", i), o.textContent = e.cssText, t.appendChild(o);
|
|
30
|
+
}
|
|
31
|
+
}, d = n ? (t) => t : (t) => t instanceof CSSStyleSheet ? ((s) => {
|
|
32
|
+
let e = "";
|
|
33
|
+
for (const o of s.cssRules) e += o.cssText;
|
|
34
|
+
return r(e);
|
|
35
|
+
})(t) : t;
|
|
36
|
+
export {
|
|
37
|
+
a as CSSResult,
|
|
38
|
+
h as adoptStyles,
|
|
39
|
+
d as getCompatibleStyle,
|
|
40
|
+
n as supportsAdoptingStyleSheets,
|
|
41
|
+
r as unsafeCSS
|
|
42
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2017 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
5
|
+
*/
|
|
6
|
+
const o = (r, t, e) => (e.configurable = !0, e.enumerable = !0, Reflect.decorate && typeof t != "object" && Object.defineProperty(r, t, e), e);
|
|
7
|
+
export {
|
|
8
|
+
o as desc
|
|
9
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { notEqual as p, defaultConverter as l } from "../reactive-element.js";
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright 2017 Google LLC
|
|
5
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
6
|
+
*/
|
|
7
|
+
const d = { attribute: !0, type: String, converter: l, reflect: !1, hasChanged: p }, u = (t = d, s, e) => {
|
|
8
|
+
const { kind: n, metadata: i } = e;
|
|
9
|
+
let r = globalThis.litPropertyMetadata.get(i);
|
|
10
|
+
if (r === void 0 && globalThis.litPropertyMetadata.set(i, r = /* @__PURE__ */ new Map()), n === "setter" && ((t = Object.create(t)).wrapped = !0), r.set(e.name, t), n === "accessor") {
|
|
11
|
+
const { name: o } = e;
|
|
12
|
+
return { set(a) {
|
|
13
|
+
const c = s.get.call(this);
|
|
14
|
+
s.set.call(this, a), this.requestUpdate(o, c, t);
|
|
15
|
+
}, init(a) {
|
|
16
|
+
return a !== void 0 && this.C(o, void 0, t, a), a;
|
|
17
|
+
} };
|
|
18
|
+
}
|
|
19
|
+
if (n === "setter") {
|
|
20
|
+
const { name: o } = e;
|
|
21
|
+
return function(a) {
|
|
22
|
+
const c = this[o];
|
|
23
|
+
s.call(this, a), this.requestUpdate(o, c, t);
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
throw Error("Unsupported decorator location: " + n);
|
|
27
|
+
};
|
|
28
|
+
function f(t) {
|
|
29
|
+
return (s, e) => typeof e == "object" ? u(t, s, e) : ((n, i, r) => {
|
|
30
|
+
const o = i.hasOwnProperty(r);
|
|
31
|
+
return i.constructor.createProperty(r, n), o ? Object.getOwnPropertyDescriptor(i, r) : void 0;
|
|
32
|
+
})(t, s, e);
|
|
33
|
+
}
|
|
34
|
+
export {
|
|
35
|
+
f as property,
|
|
36
|
+
u as standardProperty
|
|
37
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { desc as s } from "./base.js";
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright 2017 Google LLC
|
|
5
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
6
|
+
*/
|
|
7
|
+
function a(e, c) {
|
|
8
|
+
return (t, o, i) => {
|
|
9
|
+
const n = (u) => {
|
|
10
|
+
var r;
|
|
11
|
+
return ((r = u.renderRoot) == null ? void 0 : r.querySelector(e)) ?? null;
|
|
12
|
+
};
|
|
13
|
+
return s(t, o, { get() {
|
|
14
|
+
return n(this);
|
|
15
|
+
} });
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export {
|
|
19
|
+
a as query
|
|
20
|
+
};
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
import { getCompatibleStyle as E, adoptStyles as m } from "./css-tag.js";
|
|
2
|
+
import { CSSResult as M, supportsAdoptingStyleSheets as R, unsafeCSS as z } from "./css-tag.js";
|
|
3
|
+
/**
|
|
4
|
+
* @license
|
|
5
|
+
* Copyright 2017 Google LLC
|
|
6
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
7
|
+
*/
|
|
8
|
+
const { is: g, defineProperty: b, getOwnPropertyDescriptor: P, getOwnPropertyNames: v, getOwnPropertySymbols: w, getPrototypeOf: S } = Object, n = globalThis, _ = n.trustedTypes, U = _ ? _.emptyScript : "", d = n.reactiveElementPolyfillSupport, c = (a, t) => a, u = { toAttribute(a, t) {
|
|
9
|
+
switch (t) {
|
|
10
|
+
case Boolean:
|
|
11
|
+
a = a ? U : null;
|
|
12
|
+
break;
|
|
13
|
+
case Object:
|
|
14
|
+
case Array:
|
|
15
|
+
a = a == null ? a : JSON.stringify(a);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
}, fromAttribute(a, t) {
|
|
19
|
+
let e = a;
|
|
20
|
+
switch (t) {
|
|
21
|
+
case Boolean:
|
|
22
|
+
e = a !== null;
|
|
23
|
+
break;
|
|
24
|
+
case Number:
|
|
25
|
+
e = a === null ? null : Number(a);
|
|
26
|
+
break;
|
|
27
|
+
case Object:
|
|
28
|
+
case Array:
|
|
29
|
+
try {
|
|
30
|
+
e = JSON.parse(a);
|
|
31
|
+
} catch {
|
|
32
|
+
e = null;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return e;
|
|
36
|
+
} }, y = (a, t) => !g(a, t), $ = { attribute: !0, type: String, converter: u, reflect: !1, useDefault: !1, hasChanged: y };
|
|
37
|
+
Symbol.metadata ?? (Symbol.metadata = Symbol("metadata")), n.litPropertyMetadata ?? (n.litPropertyMetadata = /* @__PURE__ */ new WeakMap());
|
|
38
|
+
class l extends HTMLElement {
|
|
39
|
+
static addInitializer(t) {
|
|
40
|
+
this._$Ei(), (this.l ?? (this.l = [])).push(t);
|
|
41
|
+
}
|
|
42
|
+
static get observedAttributes() {
|
|
43
|
+
return this.finalize(), this._$Eh && [...this._$Eh.keys()];
|
|
44
|
+
}
|
|
45
|
+
static createProperty(t, e = $) {
|
|
46
|
+
if (e.state && (e.attribute = !1), this._$Ei(), this.prototype.hasOwnProperty(t) && ((e = Object.create(e)).wrapped = !0), this.elementProperties.set(t, e), !e.noAccessor) {
|
|
47
|
+
const s = Symbol(), i = this.getPropertyDescriptor(t, s, e);
|
|
48
|
+
i !== void 0 && b(this.prototype, t, i);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
static getPropertyDescriptor(t, e, s) {
|
|
52
|
+
const { get: i, set: r } = P(this.prototype, t) ?? { get() {
|
|
53
|
+
return this[e];
|
|
54
|
+
}, set(o) {
|
|
55
|
+
this[e] = o;
|
|
56
|
+
} };
|
|
57
|
+
return { get: i, set(o) {
|
|
58
|
+
const h = i == null ? void 0 : i.call(this);
|
|
59
|
+
r == null || r.call(this, o), this.requestUpdate(t, h, s);
|
|
60
|
+
}, configurable: !0, enumerable: !0 };
|
|
61
|
+
}
|
|
62
|
+
static getPropertyOptions(t) {
|
|
63
|
+
return this.elementProperties.get(t) ?? $;
|
|
64
|
+
}
|
|
65
|
+
static _$Ei() {
|
|
66
|
+
if (this.hasOwnProperty(c("elementProperties"))) return;
|
|
67
|
+
const t = S(this);
|
|
68
|
+
t.finalize(), t.l !== void 0 && (this.l = [...t.l]), this.elementProperties = new Map(t.elementProperties);
|
|
69
|
+
}
|
|
70
|
+
static finalize() {
|
|
71
|
+
if (this.hasOwnProperty(c("finalized"))) return;
|
|
72
|
+
if (this.finalized = !0, this._$Ei(), this.hasOwnProperty(c("properties"))) {
|
|
73
|
+
const e = this.properties, s = [...v(e), ...w(e)];
|
|
74
|
+
for (const i of s) this.createProperty(i, e[i]);
|
|
75
|
+
}
|
|
76
|
+
const t = this[Symbol.metadata];
|
|
77
|
+
if (t !== null) {
|
|
78
|
+
const e = litPropertyMetadata.get(t);
|
|
79
|
+
if (e !== void 0) for (const [s, i] of e) this.elementProperties.set(s, i);
|
|
80
|
+
}
|
|
81
|
+
this._$Eh = /* @__PURE__ */ new Map();
|
|
82
|
+
for (const [e, s] of this.elementProperties) {
|
|
83
|
+
const i = this._$Eu(e, s);
|
|
84
|
+
i !== void 0 && this._$Eh.set(i, e);
|
|
85
|
+
}
|
|
86
|
+
this.elementStyles = this.finalizeStyles(this.styles);
|
|
87
|
+
}
|
|
88
|
+
static finalizeStyles(t) {
|
|
89
|
+
const e = [];
|
|
90
|
+
if (Array.isArray(t)) {
|
|
91
|
+
const s = new Set(t.flat(1 / 0).reverse());
|
|
92
|
+
for (const i of s) e.unshift(E(i));
|
|
93
|
+
} else t !== void 0 && e.push(E(t));
|
|
94
|
+
return e;
|
|
95
|
+
}
|
|
96
|
+
static _$Eu(t, e) {
|
|
97
|
+
const s = e.attribute;
|
|
98
|
+
return s === !1 ? void 0 : typeof s == "string" ? s : typeof t == "string" ? t.toLowerCase() : void 0;
|
|
99
|
+
}
|
|
100
|
+
constructor() {
|
|
101
|
+
super(), this._$Ep = void 0, this.isUpdatePending = !1, this.hasUpdated = !1, this._$Em = null, this._$Ev();
|
|
102
|
+
}
|
|
103
|
+
_$Ev() {
|
|
104
|
+
var t;
|
|
105
|
+
this._$ES = new Promise((e) => this.enableUpdating = e), this._$AL = /* @__PURE__ */ new Map(), this._$E_(), this.requestUpdate(), (t = this.constructor.l) == null || t.forEach((e) => e(this));
|
|
106
|
+
}
|
|
107
|
+
addController(t) {
|
|
108
|
+
var e;
|
|
109
|
+
(this._$EO ?? (this._$EO = /* @__PURE__ */ new Set())).add(t), this.renderRoot !== void 0 && this.isConnected && ((e = t.hostConnected) == null || e.call(t));
|
|
110
|
+
}
|
|
111
|
+
removeController(t) {
|
|
112
|
+
var e;
|
|
113
|
+
(e = this._$EO) == null || e.delete(t);
|
|
114
|
+
}
|
|
115
|
+
_$E_() {
|
|
116
|
+
const t = /* @__PURE__ */ new Map(), e = this.constructor.elementProperties;
|
|
117
|
+
for (const s of e.keys()) this.hasOwnProperty(s) && (t.set(s, this[s]), delete this[s]);
|
|
118
|
+
t.size > 0 && (this._$Ep = t);
|
|
119
|
+
}
|
|
120
|
+
createRenderRoot() {
|
|
121
|
+
const t = this.shadowRoot ?? this.attachShadow(this.constructor.shadowRootOptions);
|
|
122
|
+
return m(t, this.constructor.elementStyles), t;
|
|
123
|
+
}
|
|
124
|
+
connectedCallback() {
|
|
125
|
+
var t;
|
|
126
|
+
this.renderRoot ?? (this.renderRoot = this.createRenderRoot()), this.enableUpdating(!0), (t = this._$EO) == null || t.forEach((e) => {
|
|
127
|
+
var s;
|
|
128
|
+
return (s = e.hostConnected) == null ? void 0 : s.call(e);
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
enableUpdating(t) {
|
|
132
|
+
}
|
|
133
|
+
disconnectedCallback() {
|
|
134
|
+
var t;
|
|
135
|
+
(t = this._$EO) == null || t.forEach((e) => {
|
|
136
|
+
var s;
|
|
137
|
+
return (s = e.hostDisconnected) == null ? void 0 : s.call(e);
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
attributeChangedCallback(t, e, s) {
|
|
141
|
+
this._$AK(t, s);
|
|
142
|
+
}
|
|
143
|
+
_$ET(t, e) {
|
|
144
|
+
var r;
|
|
145
|
+
const s = this.constructor.elementProperties.get(t), i = this.constructor._$Eu(t, s);
|
|
146
|
+
if (i !== void 0 && s.reflect === !0) {
|
|
147
|
+
const o = (((r = s.converter) == null ? void 0 : r.toAttribute) !== void 0 ? s.converter : u).toAttribute(e, s.type);
|
|
148
|
+
this._$Em = t, o == null ? this.removeAttribute(i) : this.setAttribute(i, o), this._$Em = null;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
_$AK(t, e) {
|
|
152
|
+
var r, o;
|
|
153
|
+
const s = this.constructor, i = s._$Eh.get(t);
|
|
154
|
+
if (i !== void 0 && this._$Em !== i) {
|
|
155
|
+
const h = s.getPropertyOptions(i), p = typeof h.converter == "function" ? { fromAttribute: h.converter } : ((r = h.converter) == null ? void 0 : r.fromAttribute) !== void 0 ? h.converter : u;
|
|
156
|
+
this._$Em = i;
|
|
157
|
+
const f = p.fromAttribute(e, h.type);
|
|
158
|
+
this[i] = f ?? ((o = this._$Ej) == null ? void 0 : o.get(i)) ?? f, this._$Em = null;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
requestUpdate(t, e, s) {
|
|
162
|
+
var i;
|
|
163
|
+
if (t !== void 0) {
|
|
164
|
+
const r = this.constructor, o = this[t];
|
|
165
|
+
if (s ?? (s = r.getPropertyOptions(t)), !((s.hasChanged ?? y)(o, e) || s.useDefault && s.reflect && o === ((i = this._$Ej) == null ? void 0 : i.get(t)) && !this.hasAttribute(r._$Eu(t, s)))) return;
|
|
166
|
+
this.C(t, e, s);
|
|
167
|
+
}
|
|
168
|
+
this.isUpdatePending === !1 && (this._$ES = this._$EP());
|
|
169
|
+
}
|
|
170
|
+
C(t, e, { useDefault: s, reflect: i, wrapped: r }, o) {
|
|
171
|
+
s && !(this._$Ej ?? (this._$Ej = /* @__PURE__ */ new Map())).has(t) && (this._$Ej.set(t, o ?? e ?? this[t]), r !== !0 || o !== void 0) || (this._$AL.has(t) || (this.hasUpdated || s || (e = void 0), this._$AL.set(t, e)), i === !0 && this._$Em !== t && (this._$Eq ?? (this._$Eq = /* @__PURE__ */ new Set())).add(t));
|
|
172
|
+
}
|
|
173
|
+
async _$EP() {
|
|
174
|
+
this.isUpdatePending = !0;
|
|
175
|
+
try {
|
|
176
|
+
await this._$ES;
|
|
177
|
+
} catch (e) {
|
|
178
|
+
Promise.reject(e);
|
|
179
|
+
}
|
|
180
|
+
const t = this.scheduleUpdate();
|
|
181
|
+
return t != null && await t, !this.isUpdatePending;
|
|
182
|
+
}
|
|
183
|
+
scheduleUpdate() {
|
|
184
|
+
return this.performUpdate();
|
|
185
|
+
}
|
|
186
|
+
performUpdate() {
|
|
187
|
+
var s;
|
|
188
|
+
if (!this.isUpdatePending) return;
|
|
189
|
+
if (!this.hasUpdated) {
|
|
190
|
+
if (this.renderRoot ?? (this.renderRoot = this.createRenderRoot()), this._$Ep) {
|
|
191
|
+
for (const [r, o] of this._$Ep) this[r] = o;
|
|
192
|
+
this._$Ep = void 0;
|
|
193
|
+
}
|
|
194
|
+
const i = this.constructor.elementProperties;
|
|
195
|
+
if (i.size > 0) for (const [r, o] of i) {
|
|
196
|
+
const { wrapped: h } = o, p = this[r];
|
|
197
|
+
h !== !0 || this._$AL.has(r) || p === void 0 || this.C(r, void 0, o, p);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
let t = !1;
|
|
201
|
+
const e = this._$AL;
|
|
202
|
+
try {
|
|
203
|
+
t = this.shouldUpdate(e), t ? (this.willUpdate(e), (s = this._$EO) == null || s.forEach((i) => {
|
|
204
|
+
var r;
|
|
205
|
+
return (r = i.hostUpdate) == null ? void 0 : r.call(i);
|
|
206
|
+
}), this.update(e)) : this._$EM();
|
|
207
|
+
} catch (i) {
|
|
208
|
+
throw t = !1, this._$EM(), i;
|
|
209
|
+
}
|
|
210
|
+
t && this._$AE(e);
|
|
211
|
+
}
|
|
212
|
+
willUpdate(t) {
|
|
213
|
+
}
|
|
214
|
+
_$AE(t) {
|
|
215
|
+
var e;
|
|
216
|
+
(e = this._$EO) == null || e.forEach((s) => {
|
|
217
|
+
var i;
|
|
218
|
+
return (i = s.hostUpdated) == null ? void 0 : i.call(s);
|
|
219
|
+
}), this.hasUpdated || (this.hasUpdated = !0, this.firstUpdated(t)), this.updated(t);
|
|
220
|
+
}
|
|
221
|
+
_$EM() {
|
|
222
|
+
this._$AL = /* @__PURE__ */ new Map(), this.isUpdatePending = !1;
|
|
223
|
+
}
|
|
224
|
+
get updateComplete() {
|
|
225
|
+
return this.getUpdateComplete();
|
|
226
|
+
}
|
|
227
|
+
getUpdateComplete() {
|
|
228
|
+
return this._$ES;
|
|
229
|
+
}
|
|
230
|
+
shouldUpdate(t) {
|
|
231
|
+
return !0;
|
|
232
|
+
}
|
|
233
|
+
update(t) {
|
|
234
|
+
this._$Eq && (this._$Eq = this._$Eq.forEach((e) => this._$ET(e, this[e]))), this._$EM();
|
|
235
|
+
}
|
|
236
|
+
updated(t) {
|
|
237
|
+
}
|
|
238
|
+
firstUpdated(t) {
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
l.elementStyles = [], l.shadowRootOptions = { mode: "open" }, l[c("elementProperties")] = /* @__PURE__ */ new Map(), l[c("finalized")] = /* @__PURE__ */ new Map(), d == null || d({ ReactiveElement: l }), (n.reactiveElementVersions ?? (n.reactiveElementVersions = [])).push("2.1.1");
|
|
242
|
+
export {
|
|
243
|
+
M as CSSResult,
|
|
244
|
+
l as ReactiveElement,
|
|
245
|
+
m as adoptStyles,
|
|
246
|
+
u as defaultConverter,
|
|
247
|
+
E as getCompatibleStyle,
|
|
248
|
+
y as notEqual,
|
|
249
|
+
R as supportsAdoptingStyleSheets,
|
|
250
|
+
z as unsafeCSS
|
|
251
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@parent-tobias/chord-component",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Lit-based web components for displaying musical chord diagrams and chord lists",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"module": "dist/index.js",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"types": "./dist/index.d.ts"
|
|
13
|
+
},
|
|
14
|
+
"./chord-diagram": {
|
|
15
|
+
"import": "./dist/chord-diagram.js",
|
|
16
|
+
"types": "./dist/chord-diagram.d.ts"
|
|
17
|
+
},
|
|
18
|
+
"./chord-list": {
|
|
19
|
+
"import": "./dist/chord-list.js",
|
|
20
|
+
"types": "./dist/chord-list.d.ts"
|
|
21
|
+
},
|
|
22
|
+
"./chord-editor": {
|
|
23
|
+
"import": "./dist/chord-editor.js",
|
|
24
|
+
"types": "./dist/chord-editor.d.ts"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"dist/**/*",
|
|
29
|
+
"src/**/*",
|
|
30
|
+
"README.md",
|
|
31
|
+
"LICENSE"
|
|
32
|
+
],
|
|
33
|
+
"scripts": {
|
|
34
|
+
"build": "tsc && vite build",
|
|
35
|
+
"build:demo": "vite build --config vite.demo.config.ts",
|
|
36
|
+
"build:all": "npm run build && npm run build:demo",
|
|
37
|
+
"dev": "vite serve demo --host",
|
|
38
|
+
"preview": "vite preview",
|
|
39
|
+
"test": "echo 'No tests yet' && exit 0",
|
|
40
|
+
"lint": "eslint src/**/*.ts",
|
|
41
|
+
"clean": "rm -rf dist",
|
|
42
|
+
"prepublishOnly": "npm run clean && npm run build"
|
|
43
|
+
},
|
|
44
|
+
"keywords": [
|
|
45
|
+
"lit",
|
|
46
|
+
"web-components",
|
|
47
|
+
"music",
|
|
48
|
+
"chord",
|
|
49
|
+
"diagram",
|
|
50
|
+
"ukulele",
|
|
51
|
+
"guitar",
|
|
52
|
+
"mandolin",
|
|
53
|
+
"chord-chart"
|
|
54
|
+
],
|
|
55
|
+
"author": "Tobias Padilla",
|
|
56
|
+
"license": "MIT",
|
|
57
|
+
"homepage": "https://github.com/parent-tobias/chord-component#readme",
|
|
58
|
+
"repository": {
|
|
59
|
+
"type": "git",
|
|
60
|
+
"url": "git+https://github.com/parent-tobias/chord-component.git"
|
|
61
|
+
},
|
|
62
|
+
"bugs": {
|
|
63
|
+
"url": "https://github.com/parent-tobias/chord-component/issues"
|
|
64
|
+
},
|
|
65
|
+
"dependencies": {
|
|
66
|
+
"lit": "^3.3.1",
|
|
67
|
+
"svguitar": "^2.4.1"
|
|
68
|
+
},
|
|
69
|
+
"devDependencies": {
|
|
70
|
+
"@types/node": "^20.0.0",
|
|
71
|
+
"@typescript-eslint/eslint-plugin": "^6.0.0",
|
|
72
|
+
"@typescript-eslint/parser": "^6.0.0",
|
|
73
|
+
"eslint": "^8.0.0",
|
|
74
|
+
"typescript": "^5.0.0",
|
|
75
|
+
"vite": "^5.0.0"
|
|
76
|
+
},
|
|
77
|
+
"peerDependencies": {
|
|
78
|
+
"lit": "^3.0.0"
|
|
79
|
+
},
|
|
80
|
+
"engines": {
|
|
81
|
+
"node": ">=18.0.0"
|
|
82
|
+
}
|
|
83
|
+
}
|