@molecule/app-feature-piano-roll-solid 0.0.0-stage → 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.
@@ -0,0 +1,91 @@
1
+ /**
2
+ * Pure geometry helpers and constants of the Solid piano roll — the same values
3
+ * and the same math as `@molecule/app-feature-piano-roll-react`, so the helper
4
+ * exports every framework must reproduce by value are identical.
5
+ *
6
+ * @module
7
+ */
8
+ import type { PianoRollSnap } from './types.js';
9
+ /** Pixel width of the leading piano-keys column. */
10
+ export declare const PIANO_KEYS_WIDTH_PX = 56;
11
+ /** Minimum note duration in beats — notes can't be resized below this. */
12
+ export declare const MIN_NOTE_DURATION_BEATS: number;
13
+ /** Pointer-distance threshold (px) before a press becomes a drag. */
14
+ export declare const DRAG_DISTANCE_THRESHOLD_PX = 3;
15
+ /** Default MIDI velocity assigned to freshly-painted notes. */
16
+ export declare const DEFAULT_NOTE_VELOCITY = 96;
17
+ /**
18
+ * Convert a snap setting to its size in beats.
19
+ *
20
+ * @param snap - Snap resolution.
21
+ * @returns Snap step size in beats.
22
+ */
23
+ export declare function snapToBeats(snap: PianoRollSnap): number;
24
+ /**
25
+ * Snap a beat value to the nearest multiple of the snap step (rounding down).
26
+ *
27
+ * @param beat - Raw beat value (may be fractional).
28
+ * @param snap - Snap resolution.
29
+ * @returns The floored snapped beat (>= 0).
30
+ */
31
+ export declare function snapBeat(beat: number, snap: PianoRollSnap): number;
32
+ /**
33
+ * Round a beat value to the nearest snap step.
34
+ *
35
+ * @param beat - Raw beat value (may be fractional).
36
+ * @param snap - Snap resolution.
37
+ * @returns The rounded snapped beat (>= 0).
38
+ */
39
+ export declare function snapBeatRound(beat: number, snap: PianoRollSnap): number;
40
+ /**
41
+ * Convert a pixel offset into beats given the horizontal scale.
42
+ *
43
+ * @param pixels - Offset in pixels.
44
+ * @param pixelsPerBeat - Horizontal scale.
45
+ * @returns Beats represented by the offset (may be negative).
46
+ */
47
+ export declare function pixelsToBeats(pixels: number, pixelsPerBeat: number): number;
48
+ /**
49
+ * Convert a beat value into pixels given the horizontal scale.
50
+ *
51
+ * @param beats - Beat value.
52
+ * @param pixelsPerBeat - Horizontal scale.
53
+ * @returns Pixel offset.
54
+ */
55
+ export declare function beatsToPixels(beats: number, pixelsPerBeat: number): number;
56
+ /**
57
+ * Convert a vertical pixel offset into a MIDI pitch. Higher pitches sit at the
58
+ * top, so `y = 0` maps to `highestPitch`.
59
+ *
60
+ * @param y - Vertical pixel offset from the top of the grid.
61
+ * @param noteHeight - Row height per pitch.
62
+ * @param highestPitch - Top-most pitch in the visible range.
63
+ * @param lowestPitch - Bottom-most pitch in the visible range.
64
+ * @returns A MIDI pitch clamped into `[lowestPitch, highestPitch]`.
65
+ */
66
+ export declare function yToPitch(y: number, noteHeight: number, highestPitch: number, lowestPitch: number): number;
67
+ /**
68
+ * Convert a MIDI pitch into the vertical pixel offset of its row.
69
+ *
70
+ * @param pitch - MIDI pitch number.
71
+ * @param noteHeight - Row height per pitch.
72
+ * @param highestPitch - Top-most pitch in the visible range.
73
+ * @returns Vertical pixel offset for the pitch's row.
74
+ */
75
+ export declare function pitchToY(pitch: number, noteHeight: number, highestPitch: number): number;
76
+ /**
77
+ * Determine whether a MIDI pitch corresponds to a black key on a piano
78
+ * keyboard.
79
+ *
80
+ * @param pitch - MIDI pitch number.
81
+ * @returns `true` if the pitch is a black key.
82
+ */
83
+ export declare function isBlackKey(pitch: number): boolean;
84
+ /**
85
+ * Format a MIDI pitch as a scientific-pitch-notation label.
86
+ *
87
+ * @param pitch - MIDI pitch number.
88
+ * @returns Formatted label.
89
+ */
90
+ export declare function pitchLabel(pitch: number): string;
91
+ //# sourceMappingURL=geometry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"geometry.d.ts","sourceRoot":"","sources":["../src/geometry.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAE/C,oDAAoD;AACpD,eAAO,MAAM,mBAAmB,KAAK,CAAA;AAErC,0EAA0E;AAC1E,eAAO,MAAM,uBAAuB,QAAS,CAAA;AAE7C,qEAAqE;AACrE,eAAO,MAAM,0BAA0B,IAAI,CAAA;AAE3C,+DAA+D;AAC/D,eAAO,MAAM,qBAAqB,KAAK,CAAA;AAQvC;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,aAAa,GAAG,MAAM,CAevD;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,GAAG,MAAM,CAMlE;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,GAAG,MAAM,CAMvE;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,MAAM,CAG3E;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,MAAM,CAG1E;AAED;;;;;;;;;GASG;AACH,wBAAgB,QAAQ,CACtB,CAAC,EAAE,MAAM,EACT,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,MAAM,EACpB,WAAW,EAAE,MAAM,GAClB,MAAM,CAOR;AAED;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM,CAExF;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAGjD;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAKhD"}
@@ -0,0 +1,150 @@
1
+ /**
2
+ * Pure geometry helpers and constants of the Solid piano roll — the same values
3
+ * and the same math as `@molecule/app-feature-piano-roll-react`, so the helper
4
+ * exports every framework must reproduce by value are identical.
5
+ *
6
+ * @module
7
+ */
8
+ /** Pixel width of the leading piano-keys column. */
9
+ export const PIANO_KEYS_WIDTH_PX = 56;
10
+ /** Minimum note duration in beats — notes can't be resized below this. */
11
+ export const MIN_NOTE_DURATION_BEATS = 1 / 32;
12
+ /** Pointer-distance threshold (px) before a press becomes a drag. */
13
+ export const DRAG_DISTANCE_THRESHOLD_PX = 3;
14
+ /** Default MIDI velocity assigned to freshly-painted notes. */
15
+ export const DEFAULT_NOTE_VELOCITY = 96;
16
+ /** Pitch class indices (0..11) that correspond to black keys on a piano. */
17
+ const BLACK_KEY_PITCH_CLASSES = new Set([1, 3, 6, 8, 10]);
18
+ /** Note names for the 12-tone chromatic scale, anchored at C. */
19
+ const NOTE_NAMES = ['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'A#', 'B'];
20
+ /**
21
+ * Convert a snap setting to its size in beats.
22
+ *
23
+ * @param snap - Snap resolution.
24
+ * @returns Snap step size in beats.
25
+ */
26
+ export function snapToBeats(snap) {
27
+ switch (snap) {
28
+ case '1/16':
29
+ return 0.25;
30
+ case '1/8':
31
+ return 0.5;
32
+ case '1/4':
33
+ return 1;
34
+ case '1/2':
35
+ return 2;
36
+ case '1':
37
+ return 4;
38
+ default:
39
+ return 0.25;
40
+ }
41
+ }
42
+ /**
43
+ * Snap a beat value to the nearest multiple of the snap step (rounding down).
44
+ *
45
+ * @param beat - Raw beat value (may be fractional).
46
+ * @param snap - Snap resolution.
47
+ * @returns The floored snapped beat (>= 0).
48
+ */
49
+ export function snapBeat(beat, snap) {
50
+ if (!Number.isFinite(beat))
51
+ return 0;
52
+ const step = snapToBeats(snap);
53
+ if (step <= 0)
54
+ return Math.max(0, beat);
55
+ const snapped = Math.floor(beat / step) * step;
56
+ return snapped < 0 ? 0 : snapped;
57
+ }
58
+ /**
59
+ * Round a beat value to the nearest snap step.
60
+ *
61
+ * @param beat - Raw beat value (may be fractional).
62
+ * @param snap - Snap resolution.
63
+ * @returns The rounded snapped beat (>= 0).
64
+ */
65
+ export function snapBeatRound(beat, snap) {
66
+ if (!Number.isFinite(beat))
67
+ return 0;
68
+ const step = snapToBeats(snap);
69
+ if (step <= 0)
70
+ return Math.max(0, beat);
71
+ const snapped = Math.round(beat / step) * step;
72
+ return snapped < 0 ? 0 : snapped;
73
+ }
74
+ /**
75
+ * Convert a pixel offset into beats given the horizontal scale.
76
+ *
77
+ * @param pixels - Offset in pixels.
78
+ * @param pixelsPerBeat - Horizontal scale.
79
+ * @returns Beats represented by the offset (may be negative).
80
+ */
81
+ export function pixelsToBeats(pixels, pixelsPerBeat) {
82
+ const safeScale = pixelsPerBeat > 0 ? pixelsPerBeat : 1;
83
+ return pixels / safeScale;
84
+ }
85
+ /**
86
+ * Convert a beat value into pixels given the horizontal scale.
87
+ *
88
+ * @param beats - Beat value.
89
+ * @param pixelsPerBeat - Horizontal scale.
90
+ * @returns Pixel offset.
91
+ */
92
+ export function beatsToPixels(beats, pixelsPerBeat) {
93
+ const safeScale = pixelsPerBeat > 0 ? pixelsPerBeat : 1;
94
+ return beats * safeScale;
95
+ }
96
+ /**
97
+ * Convert a vertical pixel offset into a MIDI pitch. Higher pitches sit at the
98
+ * top, so `y = 0` maps to `highestPitch`.
99
+ *
100
+ * @param y - Vertical pixel offset from the top of the grid.
101
+ * @param noteHeight - Row height per pitch.
102
+ * @param highestPitch - Top-most pitch in the visible range.
103
+ * @param lowestPitch - Bottom-most pitch in the visible range.
104
+ * @returns A MIDI pitch clamped into `[lowestPitch, highestPitch]`.
105
+ */
106
+ export function yToPitch(y, noteHeight, highestPitch, lowestPitch) {
107
+ const safeHeight = noteHeight > 0 ? noteHeight : 1;
108
+ const row = Math.floor(y / safeHeight);
109
+ const pitch = highestPitch - row;
110
+ if (pitch > highestPitch)
111
+ return highestPitch;
112
+ if (pitch < lowestPitch)
113
+ return lowestPitch;
114
+ return pitch;
115
+ }
116
+ /**
117
+ * Convert a MIDI pitch into the vertical pixel offset of its row.
118
+ *
119
+ * @param pitch - MIDI pitch number.
120
+ * @param noteHeight - Row height per pitch.
121
+ * @param highestPitch - Top-most pitch in the visible range.
122
+ * @returns Vertical pixel offset for the pitch's row.
123
+ */
124
+ export function pitchToY(pitch, noteHeight, highestPitch) {
125
+ return (highestPitch - pitch) * noteHeight;
126
+ }
127
+ /**
128
+ * Determine whether a MIDI pitch corresponds to a black key on a piano
129
+ * keyboard.
130
+ *
131
+ * @param pitch - MIDI pitch number.
132
+ * @returns `true` if the pitch is a black key.
133
+ */
134
+ export function isBlackKey(pitch) {
135
+ const pc = ((pitch % 12) + 12) % 12;
136
+ return BLACK_KEY_PITCH_CLASSES.has(pc);
137
+ }
138
+ /**
139
+ * Format a MIDI pitch as a scientific-pitch-notation label.
140
+ *
141
+ * @param pitch - MIDI pitch number.
142
+ * @returns Formatted label.
143
+ */
144
+ export function pitchLabel(pitch) {
145
+ const pc = ((pitch % 12) + 12) % 12;
146
+ // Standard MIDI octave numbering: C4 = 60. (C-1 = 0.)
147
+ const octave = Math.floor(pitch / 12) - 1;
148
+ return `${NOTE_NAMES[pc]}${octave}`;
149
+ }
150
+ //# sourceMappingURL=geometry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"geometry.js","sourceRoot":"","sources":["../src/geometry.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,oDAAoD;AACpD,MAAM,CAAC,MAAM,mBAAmB,GAAG,EAAE,CAAA;AAErC,0EAA0E;AAC1E,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,GAAG,EAAE,CAAA;AAE7C,qEAAqE;AACrE,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,CAAA;AAE3C,+DAA+D;AAC/D,MAAM,CAAC,MAAM,qBAAqB,GAAG,EAAE,CAAA;AAEvC,4EAA4E;AAC5E,MAAM,uBAAuB,GAAG,IAAI,GAAG,CAAS,CAAC,CAAC,EAAE,CAAC,E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AM,UAAU,QAAQ,CAAC,KAAa,EAAE,UAAkB,EAAE,YAAoB;IAC9E,OAAO,CAAC,YAAY,GAAG,KAAK,CAAC,GAAG,UAAU,CAAA;AAC5C,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CAAC,KAAa;IACtC,MAAM,EAAE,GAAG,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,CAAA;IACnC,OAAO,uBAAuB,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;AACxC,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,KAAa;IACtC,MAAM,EAAE,GAAG,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,CAAA;IACnC,sDAAsD;IACtD,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,EAAE,CAAC,GAAG,CAAC,CAAA;IACzC,OAAO,GAAG,UAAU,CAAC,EAAE,CAAC,GAAG,MAAM,EAAE,CAAA;AACrC,CAAC"}
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Solid piano roll — MIDI note-grid editor for music-daw and other DAW-style
3
+ * surfaces. Renders a vertical piano keyboard on the left, a horizontal time
4
+ * grid on the right, and draggable / resizable note rectangles on top.
5
+ *
6
+ * Solid counterpart of `@molecule/app-feature-piano-roll-react`: the same props
7
+ * (React names), the same DOM for the same input, and the same callback calls,
8
+ * so an app switches framework by changing only the package name it imports.
9
+ *
10
+ * @example
11
+ * ```tsx
12
+ * import { createSignal, For } from 'solid-js'
13
+ * import { PianoRoll, type MidiNote } from '@molecule/app-feature-piano-roll-solid'
14
+ *
15
+ * export function Roll() {
16
+ * const [notes, setNotes] = createSignal<MidiNote[]>([])
17
+ *
18
+ * return (
19
+ * <PianoRoll
20
+ * notes={notes()}
21
+ * snap="1/16"
22
+ * onNoteAdd={(note) => setNotes((all) => [...all, note])}
23
+ * onNoteMove={(noteId, startBeat, pitch) =>
24
+ * setNotes((all) => all.map((n) => (n.id === noteId ? { ...n, startBeat, pitch } : n)))
25
+ * }
26
+ * onNoteResize={(noteId, durationBeats) =>
27
+ * setNotes((all) => all.map((n) => (n.id === noteId ? { ...n, durationBeats } : n)))
28
+ * }
29
+ * onNoteDelete={(noteId) => setNotes((all) => all.filter((n) => n.id !== noteId))}
30
+ * />
31
+ * )
32
+ * }
33
+ * ```
34
+ *
35
+ * @remarks
36
+ * - Requires a bonded ClassMap (`cm.cn`, `cm.cursorPointer`, …) — rendering
37
+ * throws otherwise. No router dependency.
38
+ * - Every visible string comes from `useTranslation()` (`pianoRoll.aria.*`)
39
+ * via the companion `@molecule/app-locales-feature-piano-roll` locale bond,
40
+ * so a locale switch re-renders it.
41
+ * - The grid is focusable and paints from the keyboard (arrow keys move the
42
+ * cell cursor, Enter / Space paints), exactly as React's.
43
+ *
44
+ * @module
45
+ */
46
+ export * from './geometry.js';
47
+ export * from './PianoRoll.jsx';
48
+ export * from './types.js';
49
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAEH,cAAc,eAAe,CAAA;AAC7B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,YAAY,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Solid piano roll — MIDI note-grid editor for music-daw and other DAW-style
3
+ * surfaces. Renders a vertical piano keyboard on the left, a horizontal time
4
+ * grid on the right, and draggable / resizable note rectangles on top.
5
+ *
6
+ * Solid counterpart of `@molecule/app-feature-piano-roll-react`: the same props
7
+ * (React names), the same DOM for the same input, and the same callback calls,
8
+ * so an app switches framework by changing only the package name it imports.
9
+ *
10
+ * @example
11
+ * ```tsx
12
+ * import { createSignal, For } from 'solid-js'
13
+ * import { PianoRoll, type MidiNote } from '@molecule/app-feature-piano-roll-solid'
14
+ *
15
+ * export function Roll() {
16
+ * const [notes, setNotes] = createSignal<MidiNote[]>([])
17
+ *
18
+ * return (
19
+ * <PianoRoll
20
+ * notes={notes()}
21
+ * snap="1/16"
22
+ * onNoteAdd={(note) => setNotes((all) => [...all, note])}
23
+ * onNoteMove={(noteId, startBeat, pitch) =>
24
+ * setNotes((all) => all.map((n) => (n.id === noteId ? { ...n, startBeat, pitch } : n)))
25
+ * }
26
+ * onNoteResize={(noteId, durationBeats) =>
27
+ * setNotes((all) => all.map((n) => (n.id === noteId ? { ...n, durationBeats } : n)))
28
+ * }
29
+ * onNoteDelete={(noteId) => setNotes((all) => all.filter((n) => n.id !== noteId))}
30
+ * />
31
+ * )
32
+ * }
33
+ * ```
34
+ *
35
+ * @remarks
36
+ * - Requires a bonded ClassMap (`cm.cn`, `cm.cursorPointer`, …) — rendering
37
+ * throws otherwise. No router dependency.
38
+ * - Every visible string comes from `useTranslation()` (`pianoRoll.aria.*`)
39
+ * via the companion `@molecule/app-locales-feature-piano-roll` locale bond,
40
+ * so a locale switch re-renders it.
41
+ * - The grid is focusable and paints from the keyboard (arrow keys move the
42
+ * cell cursor, Enter / Space paints), exactly as React's.
43
+ *
44
+ * @module
45
+ */
46
+ export * from './geometry.js';
47
+ export * from './PianoRoll.jsx';
48
+ export * from './types.js';
49
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAEH,cAAc,eAAe,CAAA;AAC7B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,YAAY,CAAA"}
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Types of the Solid piano roll — the same props (React names) and the same DOM
3
+ * for the same input as `@molecule/app-feature-piano-roll-react`.
4
+ *
5
+ * @module
6
+ */
7
+ /**
8
+ * A single MIDI note rendered on the piano roll. `pitch` is a standard MIDI
9
+ * pitch number in the closed interval `[0, 127]` where `60` represents middle C
10
+ * (`C4`). `startBeat` is the note's start position on the time grid, and
11
+ * `durationBeats` is its length in beats. `id` is a stable identifier used as
12
+ * the row key and as the argument passed back to all event handlers.
13
+ * `velocity` is an optional MIDI velocity in the closed interval `[0, 127]`
14
+ * (defaults to a neutral mid-range).
15
+ */
16
+ export interface MidiNote {
17
+ /** Stable identifier for the note (used as the row key + handler arg). */
18
+ id: string;
19
+ /** MIDI pitch number, `0..127`. `60` is middle C. */
20
+ pitch: number;
21
+ /** Start beat on the timeline (>= 0). */
22
+ startBeat: number;
23
+ /** Duration in beats (always positive — minimum is enforced). */
24
+ durationBeats: number;
25
+ /** Optional MIDI velocity, `0..127`. */
26
+ velocity?: number;
27
+ }
28
+ /**
29
+ * Snap resolution for note placement / movement / resize. Each value is a
30
+ * fraction of a beat: `'1/16'` is sixteenth-notes (a quarter of a beat), `'1/4'`
31
+ * is quarter-notes (one beat), `'1'` snaps to whole beats with no
32
+ * sub-divisions, etc.
33
+ */
34
+ export type PianoRollSnap = '1/16' | '1/8' | '1/4' | '1/2' | '1';
35
+ /** Props accepted by the {@link PianoRoll} component. */
36
+ export interface PianoRollProps {
37
+ /** MIDI notes rendered on the grid. Order is preserved as-is. */
38
+ notes: MidiNote[];
39
+ /** Horizontal scale: pixels rendered per musical beat. Defaults to `80`. */
40
+ pixelsPerBeat?: number;
41
+ /** Vertical row height per pitch in pixels. Defaults to `20`. */
42
+ noteHeight?: number;
43
+ /** Lowest visible pitch (top-most row excluded — see `highestPitch`). Defaults to `21` (A0). */
44
+ lowestPitch?: number;
45
+ /** Highest visible pitch (top-most row inclusive). Defaults to `108` (C8). */
46
+ highestPitch?: number;
47
+ /** Snap resolution applied to clicks, drags, and resizes. Defaults to `'1/16'`. */
48
+ snap?: PianoRollSnap;
49
+ /**
50
+ * Total beats rendered in the time grid. When omitted, the grid extends to
51
+ * cover all notes plus a small trailing pad (minimum 16 beats so empty rolls
52
+ * are still usable).
53
+ */
54
+ beatsCount?: number;
55
+ /**
56
+ * Called with a freshly-created note when the user paints an empty cell — by
57
+ * clicking it, or via the keyboard cell cursor (arrow keys to move, Enter /
58
+ * Space to paint).
59
+ */
60
+ onNoteAdd?: (note: MidiNote) => void;
61
+ /** Called with the updated note when a note is dragged horizontally / vertically. */
62
+ onNoteMove?: (noteId: string, startBeat: number, pitch: number) => void;
63
+ /** Called with the updated duration when a note's right-edge handle is dragged. */
64
+ onNoteResize?: (noteId: string, durationBeats: number) => void;
65
+ /** Called when the user right-clicks a note. */
66
+ onNoteDelete?: (noteId: string) => void;
67
+ /** Extra classes merged onto the root element. */
68
+ className?: string;
69
+ }
70
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;;;;GAQG;AACH,MAAM,WAAW,QAAQ;IACvB,0EAA0E;IAC1E,EAAE,EAAE,MAAM,CAAA;IACV,qDAAqD;IACrD,KAAK,EAAE,MAAM,CAAA;IACb,yCAAyC;IACzC,SAAS,EAAE,MAAM,CAAA;IACjB,iEAAiE;IACjE,aAAa,EAAE,MAAM,CAAA;IACrB,wCAAwC;IACxC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAED;;;;;GAKG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,GAAG,CAAA;AAEhE,yDAAyD;AACzD,MAAM,WAAW,cAAc;IAC7B,iEAAiE;IACjE,KAAK,EAAE,QAAQ,EAAE,CAAA;IACjB,4EAA4E;IAC5E,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,iEAAiE;IACjE,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,gGAAgG;IAChG,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,8EAA8E;IAC9E,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,mFAAmF;IACnF,IAAI,CAAC,EAAE,aAAa,CAAA;IACpB;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB;;;;OAIG;IACH,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,IAAI,CAAA;IACpC,qFAAqF;IACrF,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IACvE,mFAAmF;IACnF,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,KAAK,IAAI,CAAA;IAC9D,gDAAgD;IAChD,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAA;IACvC,kDAAkD;IAClD,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB"}
package/dist/types.js ADDED
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Types of the Solid piano roll — the same props (React names) and the same DOM
3
+ * for the same input as `@molecule/app-feature-piano-roll-react`.
4
+ *
5
+ * @module
6
+ */
7
+ export {};
8
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
package/package.json CHANGED
@@ -1,6 +1,68 @@
1
1
  {
2
2
  "name": "@molecule/app-feature-piano-roll-solid",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.1.0",
4
+ "description": "MIDI piano roll editor — note grid with vertical piano keys + horizontal time grid + draggable/resizable note rectangles for music-daw",
5
+ "homepage": "https://www.molecule.dev/packages/app-feature-piano-roll-solid",
6
+ "type": "module",
7
+ "main": "dist/index.js",
8
+ "types": "dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist",
17
+ "README.md"
18
+ ],
19
+ "scripts": {
20
+ "build": "tsc",
21
+ "dev": "tsc --watch",
22
+ "test": "vitest run",
23
+ "test:watch": "vitest"
24
+ },
25
+ "keywords": [
26
+ "molecule",
27
+ "piano-roll",
28
+ "midi",
29
+ "music",
30
+ "daw",
31
+ "note-editor",
32
+ "solid"
33
+ ],
34
+ "author": "Molecule Dev, Inc. (https://molecule.dev)",
35
+ "license": "Apache-2.0",
36
+ "repository": {
37
+ "type": "git",
38
+ "url": "https://github.com/molecule-dev/molecule.git",
39
+ "directory": "packages/app/features/feature-piano-roll-solid"
40
+ },
41
+ "engines": {
42
+ "node": ">=20"
43
+ },
44
+ "bugs": "https://github.com/molecule-dev/molecule/issues",
45
+ "publishConfig": {
46
+ "access": "public"
47
+ },
48
+ "peerDependencies": {
49
+ "@molecule/app-solid": "^3.5.0",
50
+ "@molecule/app-ui": "^1.0.1",
51
+ "@molecule/app-ui-solid": "^1.1.0",
52
+ "solid-js": "^1.8.0"
53
+ },
54
+ "devDependencies": {
55
+ "@molecule/app-framework-conformance": "0.0.0",
56
+ "@molecule/app-i18n": "1.2.2",
57
+ "@molecule/app-icons": "1.0.4",
58
+ "@molecule/app-solid": "3.9.0",
59
+ "@molecule/app-ui": "1.5.0",
60
+ "@molecule/app-ui-solid": "1.2.1",
61
+ "@types/node": "26.6.5",
62
+ "jsdom": "30.1.3",
63
+ "solid-js": "1.9.17",
64
+ "typescript": "6.0.3",
65
+ "vite-plugin-solid": "2.11.15",
66
+ "vitest": "4.1.12"
67
+ }
68
+ }