text-guitar-chart 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/tsconfig.json ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "module": "ESNext",
5
+ "allowJs": true,
6
+ "checkJs": true,
7
+ "declaration": true,
8
+ "emitDeclarationOnly": true,
9
+ "outDir": "./types",
10
+ "rootDir": "./lib",
11
+ "strict": false,
12
+ "esModuleInterop": true,
13
+ "skipLibCheck": true,
14
+ "forceConsistentCasingInFileNames": true,
15
+ "moduleResolution": "Node"
16
+ },
17
+ "include": [
18
+ "lib/**/*"
19
+ ],
20
+ "exclude": [
21
+ "node_modules",
22
+ "test",
23
+ "types"
24
+ ]
25
+ }
@@ -0,0 +1,209 @@
1
+ export namespace DOT_COLORS {
2
+ let RED: string;
3
+ let BLACK: string;
4
+ }
5
+ /**
6
+ * EditableSVGuitarChord - Wrapper around SVGuitarChord that adds interactive editing capabilities
7
+ *
8
+ * Features:
9
+ * - Click on fretboard to add dots
10
+ * - Click existing dots to edit/remove them
11
+ * - Dialog for editing dot text and color
12
+ * - Fret count selector
13
+ * - Maintains same interface as SVGuitarChord
14
+ */
15
+ export class EditableSVGuitarChord {
16
+ /**
17
+ * @param {HTMLElement} container
18
+ * @param {any} SVGuitarChordClass
19
+ */
20
+ constructor(container: HTMLElement, SVGuitarChordClass?: any);
21
+ container: HTMLElement;
22
+ SVGuitarChordClass: any;
23
+ /** @type {import("svguitar").Chord} */
24
+ chordConfig: import("svguitar").Chord;
25
+ /** @type {any} */
26
+ config: any;
27
+ svgChord: any;
28
+ isDialogOpen: boolean;
29
+ controlsCreated: boolean;
30
+ currentEditElement: Element;
31
+ /** @type {Function|null} */
32
+ changeCallback: Function | null;
33
+ /**
34
+ * Create controls and containers
35
+ */
36
+ createControls(): void;
37
+ wrapper: HTMLDivElement;
38
+ settingsButton: HTMLButtonElement;
39
+ svgContainer: HTMLDivElement;
40
+ /**
41
+ * Create the settings dialog for title and position
42
+ */
43
+ createSettingsDialog(): void;
44
+ settingsDialog: HTMLDivElement;
45
+ titleInput: HTMLInputElement;
46
+ positionInput: HTMLInputElement;
47
+ settingsBackdrop: HTMLDivElement;
48
+ /**
49
+ * Create the edit dialog
50
+ */
51
+ createDialog(): void;
52
+ dialog: HTMLDivElement;
53
+ redRadio: HTMLInputElement;
54
+ blackRadio: HTMLInputElement;
55
+ textSection: HTMLDivElement;
56
+ textInput: HTMLInputElement;
57
+ backdrop: HTMLDivElement;
58
+ /**
59
+ * Set chord configuration
60
+ * @param {import("svguitar").Chord} config
61
+ * @returns {EditableSVGuitarChord}
62
+ */
63
+ chord(config: import("svguitar").Chord): EditableSVGuitarChord;
64
+ /**
65
+ * Configure SVGuitar options
66
+ * @param {any} config
67
+ * @returns {EditableSVGuitarChord}
68
+ */
69
+ configure(config: any): EditableSVGuitarChord;
70
+ /**
71
+ * Calculate dynamic fret count based on chord content
72
+ * @returns {number} - Number of frets needed (minimum 3, max dot position + 1)
73
+ */
74
+ calculateDynamicFrets(): number;
75
+ /**
76
+ * Draw the chord with interactive capabilities
77
+ * @param {number | undefined} [frets] - Force redraw even if already drawn
78
+ * @returns {EditableSVGuitarChord}
79
+ */
80
+ draw(frets?: number | undefined): EditableSVGuitarChord;
81
+ /**
82
+ * Redraw the chord
83
+ * @param {number | undefined} [frets] - Force redraw even if already drawn
84
+ */
85
+ redraw(frets?: number | undefined): void;
86
+ /**
87
+ * Add transparent placeholder dots for empty positions
88
+ * @param {import("svguitar").Chord} config
89
+ * @returns {import("svguitar").Chord}
90
+ */
91
+ addPlaceholderDots(config: import("svguitar").Chord): import("svguitar").Chord;
92
+ /**
93
+ * Add event listeners to SVG elements
94
+ */
95
+ addEventListeners(): void;
96
+ /**
97
+ * Handle click on a dot (finger circle)
98
+ * @param {Element} circleElement
99
+ */
100
+ handleDotClick(circleElement: Element): void;
101
+ /**
102
+ * Handle click on an open string element
103
+ * @param {Element} openStringElement
104
+ */
105
+ handleOpenStringClick(openStringElement: Element): void;
106
+ /**
107
+ * Add a new dot at the specified position
108
+ * @param {number} string
109
+ * @param {number} fret
110
+ */
111
+ addDot(string: number, fret: number): void;
112
+ /**
113
+ * Edit an existing dot
114
+ * @param {number} string
115
+ * @param {number} fret
116
+ */
117
+ editDot(string: number, fret: number): void;
118
+ currentEditFinger: import("svguitar").Finger;
119
+ currentEditString: number;
120
+ currentEditFret: number;
121
+ /**
122
+ * Open the edit dialog
123
+ */
124
+ openDialog(): void;
125
+ /**
126
+ * Position dialog relative to the clicked element
127
+ */
128
+ positionDialog(): void;
129
+ /**
130
+ * Add CSS arrow using ::after pseudo-element
131
+ * @param {string} side - 'left' or 'right' indicating arrow direction
132
+ * @param {number} dotY - Y position of the clicked dot
133
+ * @param {number} dialogY - Y position of the dialog
134
+ * @param {number} dialogHeight - Height of the dialog
135
+ */
136
+ addArrowCSS(side: string, dotY: number, dialogY: number, dialogHeight: number): void;
137
+ /**
138
+ * Ensure arrow CSS rules are added to the document
139
+ */
140
+ addCustomCSS(): void;
141
+ /**
142
+ * Close the edit dialog
143
+ */
144
+ closeDialog(): void;
145
+ /**
146
+ * Update text section visibility based on color selection
147
+ */
148
+ updateTextSectionVisibility(): void;
149
+ /**
150
+ * Update dot text in real-time
151
+ */
152
+ updateDotText(): void;
153
+ /**
154
+ * Update dot color in real-time
155
+ */
156
+ updateDotColor(): void;
157
+ /**
158
+ * Save changes to the current dot
159
+ */
160
+ saveDot(): void;
161
+ /**
162
+ * Remove the current dot
163
+ */
164
+ removeDot(): void;
165
+ /**
166
+ * Open the settings dialog
167
+ */
168
+ openSettingsDialog(): void;
169
+ /**
170
+ * Position settings dialog near the settings button
171
+ */
172
+ positionSettingsDialog(): void;
173
+ /**
174
+ * Close the settings dialog
175
+ */
176
+ closeSettingsDialog(): void;
177
+ /**
178
+ * Save settings from the dialog
179
+ */
180
+ saveSettings(): void;
181
+ /**
182
+ * Get current chord configuration
183
+ * @returns {import("svguitar").Chord}
184
+ */
185
+ getChord(): import("svguitar").Chord;
186
+ /**
187
+ * Get string representation of the chord
188
+ * @param {object} [options]
189
+ * @param {boolean} [options.useUnicode=false] - Whether to use Unicode characters for string/fret markers
190
+ * @returns {string}
191
+ */
192
+ toString(options?: {
193
+ useUnicode?: boolean;
194
+ }): string;
195
+ /**
196
+ * Register a callback for when the chord changes
197
+ * @param {(this: EditableSVGuitarChord) => void} callback - Called with updated fingers array
198
+ * @returns {EditableSVGuitarChord}
199
+ */
200
+ onChange(callback: (this: EditableSVGuitarChord) => void): EditableSVGuitarChord;
201
+ /**
202
+ * Trigger the change callback if registered
203
+ */
204
+ triggerChange(): void;
205
+ /**
206
+ * Clean up resources
207
+ */
208
+ destroy(): void;
209
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Parse a string representation of a guitar fingering into internal format
3
+ * @param {import("svguitar").Chord} chord
4
+ * @param {object} [options]
5
+ * @param {boolean} [options.useUnicode=false] - Whether to use Unicode characters for string/fret markers
6
+ * @returns {string}
7
+ */
8
+ export default function fingeringToString(chord: import("svguitar").Chord, options?: {
9
+ useUnicode?: boolean;
10
+ }): string;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Arranges an array of multi-line chord strings into a grid layout with proper padding.
3
+ * Empty strings are filtered out and trailing spaces are trimmed from each output line.
4
+ *
5
+ * @param {Array<string>} strings - Array of chord strings (can be multi-line)
6
+ * @param {number} columns - Number of columns per row (default: 3)
7
+ * @param {number} spacing - Number of spaces between columns (default: 1)
8
+ * @returns {string} - Formatted grid layout string
9
+ */
10
+ export default function layoutChordStrings(strings: Array<string>, columns?: number, spacing?: number): string;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * This function takes a string and splits it into an array of strings,
3
+ * each of the strings is a rectangle present in the original string and
4
+ * separated by spaces
5
+ *
6
+ * How it works:
7
+ * - convert the string into a 2D array of characters
8
+ * - scan the array left to right and top to bottom to find a non space character
9
+ * - once found search all adjacent non space characters using breadth first search,
10
+ * Consider horizontal, vertical and diagonal adjacency
11
+ * - once exhausted the search, determine the rectangle that bounds all found characters
12
+ * - extract the rectangle as a string and add it to the result array
13
+ * - mark all characters in the rectangle as visited (set to space)
14
+ * - continue scanning the array until all characters are visited
15
+ * @param {string} str
16
+ * @returns {Array<string>}
17
+ */
18
+ export default function splitStringInRectangles(str: string): Array<string>;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Parse a string representation of a guitar fingering into internal format
3
+ * @param {string} fingeringStr - The string representation of the fingering
4
+ * @param {{ redColor?: string, blackColor?: string }} [options]
5
+ * @returns {import("svguitar").Chord | null} The parsed fingering object
6
+ */
7
+ export default function stringToFingering(fingeringStr: string, options?: {
8
+ redColor?: string;
9
+ blackColor?: string;
10
+ }): import("svguitar").Chord | null;