@xsynaptic/sonic-ui 0.10.1 → 0.10.3

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/CHANGELOG.md ADDED
@@ -0,0 +1,138 @@
1
+ # @xsynaptic/sonic-ui
2
+
3
+ ## 0.10.3
4
+
5
+ ### Patch Changes
6
+
7
+ - - Value controls: a release outside the control fires no `sonic-hover`, and `pointerType` holds through the `change` of a release, a tap or a reset press.
8
+ - XY pad: `:state(dragging)` is set before a press's first `input`.
9
+ - XY pad and envelope: `pointerType`, as on value controls.
10
+
11
+ ## 0.10.2
12
+
13
+ ### Patch Changes
14
+
15
+ - - Wave strip: a drag held past the cancel zone stays at its start again; 0.10.1 let it seek.
16
+ - Value controls: `pointerType` is set by a press's first `input`, and `hoverValue` returns under a still mouse when a key reveal lapses.
17
+ - Wave strip: marker dots are in the DOM in ascending `start` order, regions apart.
18
+ - `CHANGELOG.md` ships in the package, and `sonic-hover`, `sonic-reveal` and `sonic-marker` are typed on `addEventListener`.
19
+
20
+ ## 0.10.1
21
+
22
+ ### Patch Changes
23
+
24
+ - Value controls: `hoverValue` returns on release, `:state(revealed)` covers a key reveal, and `dragging` and `revealed` are set before the `input` they describe.
25
+
26
+ ## 0.10.0
27
+
28
+ ### Minor Changes
29
+
30
+ - - Value controls: `formatEntry`, a function, sets the text the entry opens with, so a unit can stay out of what is typed.
31
+ - Switch: the shaft stays planted at the bushing while the bat is thrown, and a disabled switch is one opaque colour.
32
+ - Wave strip: a marker's dot is opaque.
33
+ - Relief skins: a softer glow on lit caps, legends, LEDs and a held XY puck; a shallower well on the waveform's glass.
34
+ - Edges: rims, outlines and hairlines snap to the device pixel grid, so an edge keeps one weight around a control at any size.
35
+ - - Glass: `--sonic-glass-edge-width`, a length, sets the edge's width on every glass part; at 0 a flat control's canvas is its own box. Forced colours keep a 1px edge. `--sonic-readout-edge` and `--sonic-readout-edge-width` set a readout's edge apart from its control's.
36
+ - Value controls: `hoverValue` and a `sonic-hover` event report the value under a hovering mouse on the wave strip and a `scrub` slider, with or without `readout`; a marker's start over its dot, `undefined` when nothing is hovered.
37
+ - Wave strip: `--sonic-wavestrip-marker-edge-width` and `--sonic-wavestrip-region-edge-width`, lengths, hold a dot's edge (and so the lane step) and a region's lines still on a `fill` strip.
38
+ - Waveform: `--sonic-waveform-scrim`, a background across the wave under the labels, on the new hook class `sonic-waveform-scrim`; `--sonic-waveform-label-inset-block`, a length, sets a label's block inset.
39
+ - Spectrum: `fill`, as on the wave controls.
40
+
41
+ ## 0.9.0
42
+
43
+ ### Minor Changes
44
+
45
+ - - Waveform: `currentMarker` and `sonic-marker` follow `value` and `markers` while the waveform is out of view or has not yet painted.
46
+ - Waveform: `--sonic-waveform-label-inset-inline`, a length (so it can hold `env(safe-area-inset-left)`), sets how far from the wave's edge a label parks. Unset, it follows `--sonic-waveform-label-inset-ratio` as before, which still sets the label's block inset and its gap from its marker's line.
47
+ - Wave strip: `--sonic-wavestrip-marker-size`, a length, overrides `--sonic-wavestrip-marker-ratio` so dots keep one size on a `fill` strip; lanes and the snap reach follow it.
48
+ - Value controls: `double-press="none"` makes a double press do nothing (Enter still opens the entry), and `--sonic-reveal-delay` sets how long a still press waits before the reveal (250ms by default).
49
+
50
+ ## 0.8.1
51
+
52
+ ### Patch Changes
53
+
54
+ - `--sonic-meter-length` takes a percentage, as the other length tokens do; `.sonic-meter` is now a size container.
55
+
56
+ ## 0.8.0
57
+
58
+ ### Minor Changes
59
+
60
+ - - Waveform: tokens for the playhead, grid, ends, placeholder, ghost and labels; `reduced-motion="scroll"`, `pending-delay`, and a `requestPeaks` that may return a promise.
61
+ - Wave controls: `fill`, `currentMarker` with a `sonic-marker` event, a plain groove on an empty wave strip, and a strip readout that stays inside the strip.
62
+ - Value controls: `:state(revealed)` with a `sonic-reveal` event, `:state(cancelling)`, `pointerType`, `spoken-step`, `--sonic-touch-action` and `--sonic-readout-text`; an empty `formatValue` string hides the readout.
63
+ - Slider: `scrub` and `--sonic-slider-groove-hover-ratio`. Button: `expanded`, `controls`, `popup`, `legend` and `--sonic-button-busy-delay`.
64
+ - `WaveMarker` and `TimeRegions` are exported.
65
+
66
+ ## 0.7.0
67
+
68
+ ### Minor Changes
69
+
70
+ - - `<sonic-spectrum>` draws level against log frequency on glass: set `analyser` to an `AnalyserNode`, or `push()` a frame of decibels per bin. `peak` and `resetPeak()` report the loudest bin.
71
+ - New tokens: `--sonic-spectrum-size`, `--sonic-spectrum-length`, `--sonic-spectrum-inset-ratio`, `--sonic-spectrum-radius-ratio`, `--sonic-spectrum-hot-from` and `--sonic-spectrum-clip-from`. New hook classes: `sonic-spectrum` and `sonic-spectrum-canvas`.
72
+
73
+ ## 0.6.1
74
+
75
+ ### Patch Changes
76
+
77
+ - - `--sonic-scale` colours a scale's ticks, and `--sonic-panel-text` the text on a panel.
78
+ - The number box, waveform, wavestrip and XY pad draw in `--sonic-glass-text`, no longer `--sonic-ink`.
79
+ - `--sonic-well` also colours the switch's bushing.
80
+ - The glass warp is gone, and glass with no depth is one flat colour.
81
+ - The held bracket moves to the hook classes `sonic-xy-bracket` and `sonic-envelope-bracket`.
82
+ - - A readout stays on one line, and `--sonic-readout-glass` colours it.
83
+ - `buffered` is on the slider and the wave strip only.
84
+ - `tabindex="-1"` on a value control's host removes its tab stop.
85
+ - - A bare button with no legend draws a faint edge in the text colour; `--sonic-cap-edge: transparent` removes it.
86
+ - A bare unlit LED is a tint of the text colour, with no bezel.
87
+ - Bare glass follows the colour scheme and has an edge; glass text follows the glass's lightness.
88
+
89
+ ## 0.6.0
90
+
91
+ ### Minor Changes
92
+
93
+ - Breaking: a control with no skin is now bare; the former default look is the `amber` skin, and `flat` is new. `--sonic-relief` scales depth and glow, and new tokens cover edges, wells, hover colours and `--sonic-target-size`.
94
+
95
+ Reworked XY puck, envelope handles, wavestrip markers and readout, and dial scale labels.
96
+
97
+ Controls put their control back when a morph removes it, warn in development about children they do not document, and take number properties as strings. Under a hydrating framework, register the definitions after hydration.
98
+
99
+ Controls draw once on connect and write the DOM only where something changed.
100
+
101
+ ## 0.5.0
102
+
103
+ ### Minor Changes
104
+
105
+ - Six new controls: `<sonic-switch>`, `<sonic-xy>`, `<sonic-envelope>`, `<sonic-split>`, `<sonic-wavestrip>` and `<sonic-waveform>`, along with `.sonic-panel`, `.sonic-ring` and a `./dat` reader for audiowaveform files.
106
+
107
+ Breaking: names were brought into one vocabulary, with no aliases. `<sonic-key>` is now `<sonic-button>`, `toggle` is `latching`, `values` is `positions`, and several hook classes and tokens were renamed to match.
108
+
109
+ The existing controls picked up markers, buffered regions, modulation, meter ballistics and a screen texture on glass, plus a round of fixes to stepping, dragging and focus.
110
+
111
+ ## 0.4.0
112
+
113
+ ### Minor Changes
114
+
115
+ - Scale legends on the dial and slider, `values` and `detent` on the range controls, `spring` and `buffered` on the slider, `origin`, `scale="linear"` and `lights` on the meter, `busy` and `soft-disabled` on the key, and a second LED colour. The dial and slider now render through a shadow root with one slot.
116
+
117
+ ## 0.3.0
118
+
119
+ ### Minor Changes
120
+
121
+ - `--sonic-glass-text` and `--sonic-glass-font` set the text colour and font on both readouts, `.sonic-number` and `.sonic-screen`.
122
+ - `<sonic-number>`, `.sonic-led`, `endless` on the dial and `modulation` on the slider.
123
+
124
+ ### Patch Changes
125
+
126
+ - Length tokens accept any CSS length; `--sonic-readout-size` now applies from the control or an ancestor, not the readout.
127
+
128
+ ## 0.2.0
129
+
130
+ ### Minor Changes
131
+
132
+ - Form association, reflected properties, forced-colours support, percent formatting helpers, framework-safe children, a draggable switch press and a warmer ivory skin.
133
+
134
+ ## 0.1.0
135
+
136
+ ### Minor Changes
137
+
138
+ - Initial release: `<sonic-dial>`, `<sonic-slider>`, `<sonic-key>`, `<sonic-segmented>` and `<sonic-meter>` as light-DOM custom elements, the `.sonic-screen` class, and the slate, lime and ivory skins.
@@ -103,6 +103,9 @@ var SonicEnvelope = class extends SonicElement {
103
103
  set hold(id) {
104
104
  this.reflect("hold", id);
105
105
  }
106
+ get pointerType() {
107
+ return this.#pointerType;
108
+ }
106
109
  get readout() {
107
110
  return this.hasAttribute("readout");
108
111
  }
@@ -142,6 +145,7 @@ var SonicEnvelope = class extends SonicElement {
142
145
  #isDriving = false;
143
146
  #line = requireChild(this.#envelope, ".sonic-envelope-line", SVGElement);
144
147
  #pointerDrag;
148
+ #pointerType;
145
149
  #readout = new Readout(requireChild(this.#envelope, ".sonic-envelope-readout", HTMLDivElement));
146
150
  #shape = adsrShape({});
147
151
  #signal;
@@ -206,6 +210,7 @@ var SonicEnvelope = class extends SonicElement {
206
210
  if (binding.link.value() === from) continue;
207
211
  binding.element.dispatchEvent(new Event("change", { bubbles: true }));
208
212
  }
213
+ this.#pointerType = void 0;
209
214
  },
210
215
  toggle: (isDragging) => {
211
216
  this.toggleState("dragging", isDragging);
@@ -269,6 +274,7 @@ var SonicEnvelope = class extends SonicElement {
269
274
  const pressed = this.#pressed(event);
270
275
  if (!pressed || pressed.drives.length === 0) return void 0;
271
276
  const { drives, isFlipped, part } = pressed;
277
+ this.#pointerType = event.pointerType;
272
278
  this.#claim.press(true, revealDelay(this.#envelope));
273
279
  this.#held = part;
274
280
  this.#drawBracket();
@@ -291,7 +291,7 @@ var SonicValueElement = class extends SonicFormElement {
291
291
  }, control);
292
292
  this.#gestures.bind(signal, grab);
293
293
  control.addEventListener("pointerup", (event) => {
294
- this.#hover?.at(event);
294
+ this.#hover?.lift(event);
295
295
  }, { signal });
296
296
  }
297
297
  bindHover(control, signal, { canShow = () => true, place, valueAt }) {
@@ -438,6 +438,7 @@ var SonicValueElement = class extends SonicFormElement {
438
438
  }
439
439
  #renderHold() {
440
440
  if (this.heldFrom() === void 0) this.#heldAt = void 0;
441
+ this.#hover?.restore();
441
442
  this.renderReadout();
442
443
  this.holdChanged();
443
444
  }
@@ -13,8 +13,8 @@ import { resetKeys } from "../lib/value-mapping.js";
13
13
  const detentZonePx = 8;
14
14
  var ValueGestures = class {
15
15
  #claim = new ReadoutClaim(() => {
16
- this.#host.holdChanged();
17
16
  this.#showRevealed();
17
+ this.#host.holdChanged();
18
18
  });
19
19
  #control;
20
20
  #entry;
@@ -22,6 +22,7 @@ var ValueGestures = class {
22
22
  #isRevealed = false;
23
23
  #keyScrub;
24
24
  #pointerDrag;
25
+ #pointerType;
25
26
  constructor(host, control) {
26
27
  this.#host = host;
27
28
  this.#control = control;
@@ -39,8 +40,10 @@ var ValueGestures = class {
39
40
  host.toggleState("springing", false);
40
41
  if (event.pointerType === "touch") event.preventDefault();
41
42
  focusByPointer(control);
43
+ this.#pointerType = event.pointerType;
42
44
  if (isResetPress(event)) {
43
45
  this.#reset();
46
+ this.#pointerType = void 0;
44
47
  return;
45
48
  }
46
49
  const fromValue = host.value();
@@ -48,6 +51,7 @@ var ValueGestures = class {
48
51
  const axis = grab(event);
49
52
  if (!axis) {
50
53
  host.toggleState("dragging", false);
54
+ this.#pointerType = void 0;
51
55
  return;
52
56
  }
53
57
  const drag = {
@@ -55,7 +59,6 @@ var ValueGestures = class {
55
59
  fromValue,
56
60
  isOutside: false,
57
61
  isRevealed: false,
58
- pointerType: event.pointerType,
59
62
  revealTimer: void 0,
60
63
  state: this.#startDrag(axis, event)
61
64
  };
@@ -65,16 +68,9 @@ var ValueGestures = class {
65
68
  return drag;
66
69
  },
67
70
  lift: (drag, event) => {
68
- const tap = drag.state.isEngaged ? void 0 : host.tapTarget();
69
- if (tap !== void 0) {
70
- entry.forgetPress();
71
- this.#commit(tap);
72
- return;
73
- }
74
- if (!entry.press(event) || host.springTarget() !== void 0) return;
75
- const gesture = host.doublePress();
76
- if (gesture === "reset") this.#reset();
77
- else if (gesture === "entry") entry.open();
71
+ this.#pointerType = event.pointerType;
72
+ this.#lift(drag, event, entry);
73
+ this.#pointerType = void 0;
78
74
  },
79
75
  move: (drag, event) => {
80
76
  this.#dragTo(drag, event);
@@ -113,7 +109,7 @@ var ValueGestures = class {
113
109
  return this.#claim.isRevealed;
114
110
  }
115
111
  pointerType() {
116
- return this.#dragging()?.pointerType;
112
+ return this.#pointerType;
117
113
  }
118
114
  #bindEntry(signal) {
119
115
  const control = this.#control;
@@ -174,8 +170,8 @@ var ValueGestures = class {
174
170
  }
175
171
  #concealKeyReveal() {
176
172
  if (!this.#claim.conceal("keys")) return;
177
- this.#host.holdChanged();
178
173
  this.#showRevealed();
174
+ this.#host.holdChanged();
179
175
  }
180
176
  #crossCancelZone(drag, value) {
181
177
  const host = this.#host;
@@ -202,7 +198,7 @@ var ValueGestures = class {
202
198
  drag.state = this.#withinLimit(mapping, state);
203
199
  if (value === void 0) return;
204
200
  if (!wasEngaged) this.#reveal(drag);
205
- if (isOutside === drag.isOutside) host.input(value);
201
+ if (isOutside === drag.isOutside) host.input(isOutside ? drag.fromValue : value);
206
202
  else this.#crossCancelZone(drag, value);
207
203
  }
208
204
  #endKeyScrub() {
@@ -227,6 +223,19 @@ var ValueGestures = class {
227
223
  this.#endKeyScrub();
228
224
  this.#commit(next, next > host.value() ? 1 : -1);
229
225
  }
226
+ #lift(drag, event, entry) {
227
+ const host = this.#host;
228
+ const tap = drag.state.isEngaged ? void 0 : host.tapTarget();
229
+ if (tap !== void 0) {
230
+ entry.forgetPress();
231
+ this.#commit(tap);
232
+ return;
233
+ }
234
+ if (!entry.press(event) || host.springTarget() !== void 0) return;
235
+ const gesture = host.doublePress();
236
+ if (gesture === "reset") this.#reset();
237
+ else if (gesture === "entry") entry.open();
238
+ }
230
239
  #releaseDrag(drag) {
231
240
  const host = this.#host;
232
241
  clearTimeout(drag.revealTimer);
@@ -236,6 +245,7 @@ var ValueGestures = class {
236
245
  this.#showRevealed();
237
246
  if (host.value() !== drag.fromValue) host.dispatch("change");
238
247
  this.#springBack();
248
+ this.#pointerType = void 0;
239
249
  }
240
250
  #renderDragReveal(drag) {
241
251
  if (drag.isRevealed && !drag.isOutside) this.#claim.reveal("drag");
@@ -74,6 +74,9 @@ var SonicXy = class extends SonicFormElement {
74
74
  this.#formatValue = format;
75
75
  this.render();
76
76
  }
77
+ get pointerType() {
78
+ return this.#pointerType;
79
+ }
77
80
  get readout() {
78
81
  return this.hasAttribute("readout");
79
82
  }
@@ -201,6 +204,7 @@ var SonicXy = class extends SonicFormElement {
201
204
  y: requireChild(this.#xy, "[data-sonic-axis=\"y\"]", HTMLDivElement)
202
205
  };
203
206
  #pointerDrag;
207
+ #pointerType;
204
208
  #puck = requireChild(this.#xy, ".sonic-xy-puck", HTMLDivElement);
205
209
  #readout = new Readout(requireChild(this.#xy, ".sonic-xy-readout", HTMLDivElement));
206
210
  #values = {
@@ -294,8 +298,13 @@ var SonicXy = class extends SonicFormElement {
294
298
  grab: (event) => {
295
299
  if (this.isDisabled() || isMenuPress(event)) return;
296
300
  focusByPointer(this.focusTarget());
297
- if (!isResetPress(event)) return this.#grab(event);
301
+ this.#pointerType = event.pointerType;
302
+ if (!isResetPress(event)) {
303
+ this.toggleState("dragging", true);
304
+ return this.#grab(event);
305
+ }
298
306
  this.#reset();
307
+ this.#pointerType = void 0;
299
308
  },
300
309
  move: (drag, event) => {
301
310
  const step = stepFieldDrag(this.#mappings(), drag.state, pointerMove(event));
@@ -304,9 +313,10 @@ var SonicXy = class extends SonicFormElement {
304
313
  if (!this.#input(step)) this.#renderReadout();
305
314
  },
306
315
  release: (drag) => {
316
+ const hasMoved = this.x !== drag.from.x || this.y !== drag.from.y;
307
317
  this.#claim.press(false);
308
- if (this.x === drag.from.x && this.y === drag.from.y) return;
309
- this.dispatchEvent(new Event("change", { bubbles: true }));
318
+ if (hasMoved) this.dispatchEvent(new Event("change", { bubbles: true }));
319
+ this.#pointerType = void 0;
310
320
  },
311
321
  toggle: (isDragging) => {
312
322
  this.toggleState("dragging", isDragging);
@@ -2,6 +2,7 @@
2
2
  function bindHoverPreview(target, options, signal) {
3
3
  let hover;
4
4
  let isDismissed = false;
5
+ let under;
5
6
  let escapeWatch;
6
7
  const hold = (value) => {
7
8
  if (value === hover) return;
@@ -24,6 +25,7 @@ function bindHoverPreview(target, options, signal) {
24
25
  }, { signal: escapeWatch.signal });
25
26
  };
26
27
  const hoverAt = (value) => {
28
+ under = value;
27
29
  if (value === void 0) isDismissed = false;
28
30
  if (!isDismissed && !options.isTaken()) hold(value);
29
31
  options.show();
@@ -41,10 +43,16 @@ function bindHoverPreview(target, options, signal) {
41
43
  watchEscape(false);
42
44
  }, { once: true });
43
45
  return {
44
- at,
45
46
  clear: () => {
46
47
  hold(void 0);
47
48
  },
49
+ lift: (event) => {
50
+ const box = target.getBoundingClientRect();
51
+ if (event.clientX >= box.left && event.clientX <= box.right && event.clientY >= box.top && event.clientY <= box.bottom) at(event);
52
+ },
53
+ restore: () => {
54
+ if (under !== void 0) hoverAt(under);
55
+ },
48
56
  value: () => hover
49
57
  };
50
58
  }
@@ -20,6 +20,7 @@ export declare class SonicEnvelope extends SonicElement {
20
20
  set delay(id: string | undefined);
21
21
  get hold(): string;
22
22
  set hold(id: string | undefined);
23
+ get pointerType(): string | undefined;
23
24
  get readout(): boolean;
24
25
  set readout(isOn: boolean);
25
26
  get release(): string;
@@ -103,6 +103,9 @@ var SonicEnvelope = class extends SonicElement {
103
103
  set hold(id) {
104
104
  this.reflect("hold", id);
105
105
  }
106
+ get pointerType() {
107
+ return this.#pointerType;
108
+ }
106
109
  get readout() {
107
110
  return this.hasAttribute("readout");
108
111
  }
@@ -142,6 +145,7 @@ var SonicEnvelope = class extends SonicElement {
142
145
  #isDriving = false;
143
146
  #line = requireChild(this.#envelope, ".sonic-envelope-line", SVGElement);
144
147
  #pointerDrag;
148
+ #pointerType;
145
149
  #readout = new Readout(requireChild(this.#envelope, ".sonic-envelope-readout", HTMLDivElement));
146
150
  #shape = adsrShape({});
147
151
  #signal;
@@ -206,6 +210,7 @@ var SonicEnvelope = class extends SonicElement {
206
210
  if (binding.link.value() === from) continue;
207
211
  binding.element.dispatchEvent(new Event("change", { bubbles: true }));
208
212
  }
213
+ this.#pointerType = void 0;
209
214
  },
210
215
  toggle: (isDragging) => {
211
216
  this.toggleState("dragging", isDragging);
@@ -269,6 +274,7 @@ var SonicEnvelope = class extends SonicElement {
269
274
  const pressed = this.#pressed(event);
270
275
  if (!pressed || pressed.drives.length === 0) return void 0;
271
276
  const { drives, isFlipped, part } = pressed;
277
+ this.#pointerType = event.pointerType;
272
278
  this.#claim.press(true, revealDelay(this.#envelope));
273
279
  this.#held = part;
274
280
  this.#drawBracket();
@@ -1 +1 @@
1
- {"version":3,"file":"envelope.js","names":[],"sources":["../../../src/elements/envelope.ts"],"sourcesContent":["import type { ValueLink } from '#elements/value-element.ts';\nimport type { AdsrCurves, AdsrProportions, AdsrShape } from '#lib/adsr-shape.ts';\nimport type { FieldAxis, FieldDragState, FieldMappings, FieldPoint } from '#lib/field.ts';\nimport type { PointerDrag } from '#lib/pointer-drag.ts';\n\nimport { ReadoutClaim, revealDelay } from '#elements/readout-claim.ts';\nimport { Readout } from '#elements/readout.ts';\nimport { SonicElement } from '#elements/sonic-element.ts';\nimport { linkValue, SonicValueElement } from '#elements/value-element.ts';\nimport { adsrPath, adsrShape, adsrStages, timeStages } from '#lib/adsr-shape.ts';\nimport { dragThresholdPx } from '#lib/drag-step.ts';\nimport { pointerMove, pointerPosition, startFieldDrag, stepFieldDrag } from '#lib/field.ts';\nimport { bindDrag } from '#lib/pointer-drag.ts';\nimport { requireChild, template } from '#lib/render.ts';\nimport { writeAttribute } from '#lib/write-attribute.ts';\n\n// eslint-disable-next-line unicorn/consistent-boolean-name -- the name bundlers and other kits use\ndeclare const __DEV__: boolean;\n\ndeclare global {\n\tinterface HTMLElementTagNameMap {\n\t\t'sonic-envelope': SonicEnvelope;\n\t}\n}\n\ninterface Binding {\n\telement: SonicValueElement;\n\tlink: ValueLink;\n\tunwatch: () => void;\n}\n\ninterface Drive {\n\taxis: FieldAxis;\n\tbinding: Binding;\n}\n\ninterface HandleDrag {\n\tdrives: Array<Drive & { from: number }>;\n\tisFlipped: boolean;\n\tpart: HTMLElement;\n\tstate: FieldDragState;\n}\n\nconst curveStages = ['attack', 'decay', 'release'] as const;\n\nconst bindable = [...adsrStages, 'attack-curve', 'decay-curve', 'release-curve'] as const;\n\nconst bindableNames = new Set<string>(bindable);\n\nfunction flip<Point extends FieldPoint>(point: Point, isFlipped: boolean): Point {\n\treturn isFlipped ? { ...point, y: -point.y } : point;\n}\n\nfunction isParent(node: Node): node is Node & ParentNode {\n\treturn 'querySelector' in node;\n}\n\nconst emptyPath = { fill: '', floor: { from: 0, to: 0 }, stroke: '' };\n\nfunction stageParts<Stage extends string>(\n\tenvelope: Element,\n\thook: string,\n\tstages: ReadonlyArray<Stage>,\n): Map<Stage, HTMLDivElement> {\n\treturn new Map(\n\t\tstages.map((stage) => [\n\t\t\tstage,\n\t\t\trequireChild(envelope, `.${hook}[data-sonic-stage=\"${stage}\"]`, HTMLDivElement),\n\t\t]),\n\t);\n}\n\nconst renderEnvelope = template(\n\t/* HTML */ `\n\t\t<div class=\"sonic-envelope\" aria-hidden=\"true\">\n\t\t\t<div class=\"sonic-envelope-bracket\"></div>\n\t\t\t<svg class=\"sonic-envelope-graph\" preserveAspectRatio=\"none\" viewBox=\"0 0 1 1\">\n\t\t\t\t<path class=\"sonic-envelope-fill\" />\n\t\t\t\t<rect class=\"sonic-envelope-fill sonic-envelope-floor\" y=\"1\" />\n\t\t\t\t<path class=\"sonic-envelope-line\" />\n\t\t\t</svg>\n\t\t\t<div class=\"sonic-envelope-handle\" data-sonic-stage=\"delay\" hidden></div>\n\t\t\t<div class=\"sonic-envelope-handle\" data-sonic-stage=\"attack\" hidden></div>\n\t\t\t<div class=\"sonic-envelope-handle\" data-sonic-stage=\"hold\" hidden></div>\n\t\t\t<div class=\"sonic-envelope-handle\" data-sonic-stage=\"decay\" hidden></div>\n\t\t\t<div class=\"sonic-envelope-handle\" data-sonic-stage=\"release\" hidden></div>\n\t\t\t<div class=\"sonic-envelope-curve\" data-sonic-stage=\"attack\" hidden></div>\n\t\t\t<div class=\"sonic-envelope-curve\" data-sonic-stage=\"decay\" hidden></div>\n\t\t\t<div class=\"sonic-envelope-curve\" data-sonic-stage=\"release\" hidden></div>\n\t\t\t<div class=\"sonic-envelope-readout\" popover=\"manual\"><span></span></div>\n\t\t</div>\n\t`,\n\tHTMLDivElement,\n);\n\nexport class SonicEnvelope extends SonicElement {\n\tstatic override readonly observedAttributes = [\n\t\t...SonicElement.observedAttributes,\n\t\t...bindable,\n\t\t'readout',\n\t];\n\n\tget attack(): string {\n\t\treturn this.getAttribute('attack') ?? '';\n\t}\n\n\tset attack(id: string | undefined) {\n\t\tthis.reflect('attack', id);\n\t}\n\n\tget attackCurve(): string {\n\t\treturn this.getAttribute('attack-curve') ?? '';\n\t}\n\n\tset attackCurve(id: string | undefined) {\n\t\tthis.reflect('attack-curve', id);\n\t}\n\n\tget decay(): string {\n\t\treturn this.getAttribute('decay') ?? '';\n\t}\n\n\tset decay(id: string | undefined) {\n\t\tthis.reflect('decay', id);\n\t}\n\n\tget decayCurve(): string {\n\t\treturn this.getAttribute('decay-curve') ?? '';\n\t}\n\n\tset decayCurve(id: string | undefined) {\n\t\tthis.reflect('decay-curve', id);\n\t}\n\n\tget delay(): string {\n\t\treturn this.getAttribute('delay') ?? '';\n\t}\n\n\tset delay(id: string | undefined) {\n\t\tthis.reflect('delay', id);\n\t}\n\n\tget hold(): string {\n\t\treturn this.getAttribute('hold') ?? '';\n\t}\n\n\tset hold(id: string | undefined) {\n\t\tthis.reflect('hold', id);\n\t}\n\n\tget readout(): boolean {\n\t\treturn this.hasAttribute('readout');\n\t}\n\n\tset readout(isOn: boolean) {\n\t\tthis.reflect('readout', isOn);\n\t}\n\n\tget release(): string {\n\t\treturn this.getAttribute('release') ?? '';\n\t}\n\n\tset release(id: string | undefined) {\n\t\tthis.reflect('release', id);\n\t}\n\n\tget releaseCurve(): string {\n\t\treturn this.getAttribute('release-curve') ?? '';\n\t}\n\n\tset releaseCurve(id: string | undefined) {\n\t\tthis.reflect('release-curve', id);\n\t}\n\n\tget sustain(): string {\n\t\treturn this.getAttribute('sustain') ?? '';\n\t}\n\n\tset sustain(id: string | undefined) {\n\t\tthis.reflect('sustain', id);\n\t}\n\n\treadonly #bindings = new Map<string, Binding>();\n\n\treadonly #envelope = renderEnvelope();\n\n\treadonly #bracket = requireChild(this.#envelope, '.sonic-envelope-bracket', HTMLDivElement);\n\n\treadonly #claim = new ReadoutClaim(() => {\n\t\tthis.#renderReadout();\n\t});\n\n\treadonly #curveHandles = stageParts(this.#envelope, 'sonic-envelope-curve', curveStages);\n\n\treadonly #fill = requireChild(this.#envelope, '.sonic-envelope-fill', SVGElement);\n\n\treadonly #floor = requireChild(this.#envelope, '.sonic-envelope-floor', SVGElement);\n\n\treadonly #graph = requireChild(this.#envelope, '.sonic-envelope-graph', SVGElement);\n\n\treadonly #handles = stageParts(this.#envelope, 'sonic-envelope-handle', timeStages);\n\n\t#held: HTMLElement | undefined;\n\n\t#isDriving = false;\n\n\treadonly #line = requireChild(this.#envelope, '.sonic-envelope-line', SVGElement);\n\n\t#pointerDrag: PointerDrag<HandleDrag> | undefined;\n\n\treadonly #readout = new Readout(\n\t\trequireChild(this.#envelope, '.sonic-envelope-readout', HTMLDivElement),\n\t);\n\n\t#shape: AdsrShape = adsrShape({});\n\n\t#signal: AbortSignal | undefined;\n\n\treadonly #waiting = new Set<unknown>();\n\n\treadonly #warned = new Set<string>();\n\n\tattributeChangedCallback(name: string): void {\n\t\tif (!this.#signal) return;\n\t\tif (name === 'disabled') {\n\t\t\tthis.#pointerDrag?.end();\n\t\t\tthis.#draw();\n\t\t\treturn;\n\t\t}\n\t\tif (bindableNames.has(name)) this.#bind();\n\t\telse this.#renderReadout();\n\t}\n\n\toverride connectedCallback(): void {\n\t\tthis.upgradeProperties(...adsrStages, 'attackCurve', 'decayCurve', 'readout', 'releaseCurve');\n\t\tsuper.connectedCallback();\n\t}\n\n\tprotected connect(signal: AbortSignal): void {\n\t\tconst envelope = this.#envelope;\n\n\t\tthis.#signal = signal;\n\t\tthis.keepControl(envelope, signal);\n\t\tthis.#bind();\n\t\tthis.checkStyles(envelope, 'envelope.css');\n\t\tthis.#bindPointer(envelope, signal);\n\t\tsignal.addEventListener(\n\t\t\t'abort',\n\t\t\t() => {\n\t\t\t\tthis.#signal = undefined;\n\t\t\t\tthis.#unbind();\n\t\t\t},\n\t\t\t{ once: true },\n\t\t);\n\t}\n\n\t#bind(): void {\n\t\tthis.#pointerDrag?.end();\n\t\tthis.#unbind();\n\t\tfor (const name of bindable) {\n\t\t\tconst element = this.#resolve(name);\n\t\t\tif (!element) continue;\n\n\t\t\tconst link = linkValue(element);\n\t\t\tconst unwatch = link.watch(() => {\n\t\t\t\tif (!this.#isDriving) this.#draw();\n\t\t\t});\n\n\t\t\tthis.#bindings.set(name, { element, link, unwatch });\n\t\t}\n\t\tthis.#draw();\n\t}\n\n\t#bindPointer(envelope: HTMLElement, signal: AbortSignal): void {\n\t\tthis.#pointerDrag = bindDrag(\n\t\t\tenvelope,\n\t\t\t{\n\t\t\t\tcancel: (drag) => {\n\t\t\t\t\tfor (const { binding, from } of drag.drives) binding.link.input(from);\n\t\t\t\t},\n\t\t\t\tgrab: (event) => this.#grab(event),\n\t\t\t\tmove: (drag, event) => {\n\t\t\t\t\tthis.#moveDrag(drag, event);\n\t\t\t\t},\n\t\t\t\trelease: (drag) => {\n\t\t\t\t\tthis.#claim.press(false);\n\t\t\t\t\tfor (const { binding, from } of drag.drives) {\n\t\t\t\t\t\tif (binding.link.value() === from) continue;\n\n\t\t\t\t\t\tbinding.element.dispatchEvent(new Event('change', { bubbles: true }));\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\ttoggle: (isDragging) => {\n\t\t\t\t\tthis.toggleState('dragging', isDragging);\n\t\t\t\t},\n\t\t\t},\n\t\t\tsignal,\n\t\t);\n\t}\n\n\t#curveDrives(stage: string): Array<Drive> {\n\t\tconst binding = this.#bindings.get(`${stage}-curve`);\n\n\t\treturn binding ? [{ axis: 'y', binding }] : [];\n\t}\n\n\t#draw(): void {\n\t\tconst shape = this.#readShape();\n\t\tconst path = this.#bindings.size === 0 ? emptyPath : adsrPath(shape);\n\n\t\tthis.#shape = shape;\n\t\twriteAttribute(this.#line, 'd', path.stroke);\n\t\twriteAttribute(this.#fill, 'd', path.fill);\n\t\twriteAttribute(this.#floor, 'x', String(path.floor.from));\n\t\twriteAttribute(this.#floor, 'width', String(path.floor.to - path.floor.from));\n\t\tfor (const [stage, part] of this.#handles) {\n\t\t\tthis.#drawPoint(part, {\n\t\t\t\tat: shape.handles.find((point) => point.stage === stage),\n\t\t\t\tdrives: this.#drives(stage),\n\t\t\t});\n\t\t}\n\t\tfor (const [stage, part] of this.#curveHandles) {\n\t\t\tthis.#drawPoint(part, {\n\t\t\t\tat: shape.curveHandles.find((point) => point.stage === stage),\n\t\t\t\tdrives: this.#curveDrives(stage),\n\t\t\t});\n\t\t}\n\t\tthis.#drawBracket();\n\t\tthis.#renderReadout();\n\t}\n\n\t#drawBracket(): void {\n\t\tconst part = this.#held;\n\t\tif (!part) return;\n\n\t\tfor (const name of ['--_sonic-envelope-x', '--_sonic-envelope-y']) {\n\t\t\tthis.#bracket.style.setProperty(name, part.style.getPropertyValue(name));\n\t\t}\n\t\twriteAttribute(\n\t\t\tthis.#bracket,\n\t\t\t'data-sonic-part',\n\t\t\tpart.classList.contains('sonic-envelope-curve') ? 'curve' : undefined,\n\t\t);\n\t}\n\n\t#drawPoint(\n\t\tpart: HTMLDivElement,\n\t\tpoint: { at: FieldPoint | undefined; drives: Array<Drive> },\n\t): void {\n\t\tconst { at, drives } = point;\n\n\t\twriteAttribute(part, 'hidden', at ? undefined : '');\n\t\tif (!at) return;\n\n\t\tconst isStill = this.isDisabled() || drives.every(({ binding }) => binding.link.isDisabled());\n\n\t\tpart.style.setProperty('--_sonic-envelope-x', String(at.x));\n\t\tpart.style.setProperty('--_sonic-envelope-y', String(at.y));\n\t\twriteAttribute(part, 'data-sonic-axes', drives.map(({ axis }) => axis).join(''));\n\t\twriteAttribute(part, 'data-sonic-disabled', isStill ? '' : undefined);\n\t}\n\n\t#drives(stage: string): Array<Drive> {\n\t\tconst x = this.#bindings.get(stage);\n\t\tconst y = stage === 'decay' ? this.#bindings.get('sustain') : undefined;\n\n\t\treturn [\n\t\t\t...(x ? [{ axis: 'x' as const, binding: x }] : []),\n\t\t\t...(y ? [{ axis: 'y' as const, binding: y }] : []),\n\t\t];\n\t}\n\n\t#grab(event: PointerEvent): HandleDrag | undefined {\n\t\tconst pressed = this.#pressed(event);\n\t\tif (!pressed || pressed.drives.length === 0) return undefined;\n\n\t\tconst { drives, isFlipped, part } = pressed;\n\n\t\tthis.#claim.press(true, revealDelay(this.#envelope));\n\t\tthis.#held = part;\n\t\tthis.#drawBracket();\n\t\tconst box = this.#graph.getBoundingClientRect();\n\t\tconst travel = { x: Math.max(1, box.width * this.#shape.share), y: Math.max(1, box.height) };\n\t\tconst start = (axis: FieldAxis) => {\n\t\t\tconst link = drives.find((drive) => drive.axis === axis)?.binding.link;\n\t\t\tif (!link) return;\n\n\t\t\tconst mapping = link.mapping();\n\t\t\tconst from = link.value();\n\n\t\t\treturn { from, mapping, proportion: mapping.proportionOf(from), travelPx: travel[axis] };\n\t\t};\n\n\t\treturn {\n\t\t\tdrives: drives.map((drive) => ({ ...drive, from: drive.binding.link.value() })),\n\t\t\tisFlipped,\n\t\t\tpart,\n\t\t\tstate: startFieldDrag({\n\t\t\t\tposition: flip(pointerPosition(event), isFlipped),\n\t\t\t\tthresholdPx: dragThresholdPx(event.pointerType),\n\t\t\t\tx: start('x'),\n\t\t\t\ty: start('y'),\n\t\t\t}),\n\t\t};\n\t}\n\n\t#moveDrag(drag: HandleDrag, event: PointerEvent): void {\n\t\tconst mappings: FieldMappings = {};\n\n\t\tfor (const { axis, binding } of drag.drives) mappings[axis] = binding.link.mapping();\n\n\t\tconst step = stepFieldDrag(mappings, drag.state, flip(pointerMove(event), drag.isFlipped));\n\n\t\tdrag.state = step.state;\n\t\tif (step.state.isEngaged) this.#claim.reveal('drag');\n\t\tthis.#isDriving = true;\n\t\tfor (const { axis, binding } of drag.drives) {\n\t\t\tconst next = step[axis];\n\n\t\t\tif (next !== undefined) binding.link.input(next);\n\t\t}\n\t\tthis.#isDriving = false;\n\t\tthis.#draw();\n\t}\n\n\t#pressed(\n\t\tevent: PointerEvent,\n\t): (Pick<HandleDrag, 'isFlipped' | 'part'> & { drives: Array<Drive> }) | undefined {\n\t\tconst part =\n\t\t\tevent.target instanceof Element\n\t\t\t\t? event.target.closest<HTMLElement>('.sonic-envelope-handle, .sonic-envelope-curve')\n\t\t\t\t: undefined;\n\t\tconst stage = part?.dataset.sonicStage;\n\t\tif (!part || stage === undefined || this.isDisabled()) return undefined;\n\n\t\tconst isCurveHandle = part.classList.contains('sonic-envelope-curve');\n\t\tconst drives = isCurveHandle ? this.#curveDrives(stage) : this.#drives(stage);\n\n\t\treturn {\n\t\t\tdrives: drives.filter(({ binding }) => !binding.link.isDisabled()),\n\t\t\tisFlipped: isCurveHandle && stage === 'attack',\n\t\t\tpart,\n\t\t};\n\t}\n\n\t#readShape(): AdsrShape {\n\t\tconst proportions: AdsrProportions = {};\n\t\tconst curves: AdsrCurves = {};\n\n\t\tfor (const stage of adsrStages) {\n\t\t\tconst link = this.#bindings.get(stage)?.link;\n\n\t\t\tproportions[stage] = link?.mapping().proportionOf(link.value());\n\t\t}\n\t\tfor (const stage of curveStages) {\n\t\t\tcurves[stage] = this.#bindings.get(`${stage}-curve`)?.link.value();\n\t\t}\n\n\t\treturn adsrShape(proportions, curves);\n\t}\n\n\t#rebindOnce(key: unknown, arrives: (rebind: () => void) => void): void {\n\t\tif (this.#waiting.has(key)) return;\n\n\t\tthis.#waiting.add(key);\n\t\tarrives(() => {\n\t\t\tthis.#waiting.delete(key);\n\t\t\tif (this.#signal) this.#bind();\n\t\t});\n\t}\n\n\t#renderReadout(): void {\n\t\tconst drag = this.#pointerDrag?.current();\n\n\t\tif (!drag) {\n\t\t\tthis.#readout.close();\n\t\t\treturn;\n\t\t}\n\n\t\tthis.#readout.show({\n\t\t\tanchor: drag.part,\n\t\t\tisOpen: this.#claim.isRevealed && this.readout,\n\t\t\ttext: drag.drives.map(({ binding }) => binding.element.valueText).join(', '),\n\t\t});\n\t}\n\n\t#resolve(name: string): SonicValueElement | undefined {\n\t\tconst id = this.getAttribute(name);\n\t\tconst root = this.getRootNode();\n\t\tif (!id || !isParent(root)) return undefined;\n\n\t\tconst found = root.querySelector(`#${CSS.escape(id)}`);\n\t\tif (found instanceof SonicValueElement) return found;\n\n\t\tthis.#wait(id, found);\n\n\t\treturn undefined;\n\t}\n\n\t#unbind(): void {\n\t\tfor (const { unwatch } of this.#bindings.values()) unwatch();\n\n\t\tthis.#bindings.clear();\n\t}\n\n\t#wait(id: string, found: Element | null): void {\n\t\tconst tag = found?.localName;\n\t\tconst { ownerDocument } = this;\n\n\t\tif (tag?.includes('-') && !customElements.get(tag)) {\n\t\t\tthis.#rebindOnce(tag, (rebind) => {\n\t\t\t\tvoid customElements.whenDefined(tag).then(rebind);\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\t\tif (!found && ownerDocument.readyState === 'loading') {\n\t\t\tthis.#rebindOnce(ownerDocument, (rebind) => {\n\t\t\t\townerDocument.addEventListener('DOMContentLoaded', rebind, { once: true });\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tthis.#warn(id);\n\t}\n\n\t#warn(id: string): void {\n\t\tif (!__DEV__) return;\n\t\tif (this.#warned.has(id)) return;\n\n\t\tthis.#warned.add(id);\n\t\tconsole.warn(`<sonic-envelope> found no dial, slider or number box with the id \"${id}\"`);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;AA2CA,MAAM,cAAc;CAAC;CAAU;CAAS;AAAS;AAEjD,MAAM,WAAW;CAAC,GAAG;CAAY;CAAgB;CAAe;AAAe;AAE/E,MAAM,gBAAgB,IAAI,IAAY,QAAQ;AAE9C,SAAS,KAA+B,OAAc,WAA2B;CAChF,OAAO,YAAY;EAAE,GAAG;EAAO,GAAG,CAAC,MAAM;CAAE,IAAI;AAChD;AAEA,S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IAAI,IAAI,OAAO,EAAE,GAAG;EACrD,IAAI,iBAAiB,mBAAmB,OAAO;EAE/C,KAAK,MAAM,IAAI,KAAK;CAGrB;CAEA,UAAgB;EACf,KAAK,MAAM,EAAE,aAAa,KAAK,UAAU,OAAO,GAAG,QAAQ;EAE3D,KAAK,UAAU,MAAM;CACtB;CAEA,MAAM,IAAY,OAA6B;EAC9C,MAAM,MAAM,OAAO;EACnB,MAAM,EAAE,kBAAkB;EAE1B,IAAI,KAAK,SAAS,GAAG,KAAK,CAAC,eAAe,IAAI,GAAG,GAAG;GACnD,KAAK,YAAY,MAAM,WAAW;IACjC,AAAK,eAAe,YAAY,GAAG,CAAC,CAAC,KAAK,MAAM;GACjD,CAAC;GACD;EACD;EACA,IAAI,CAAC,SAAS,cAAc,eAAe,WAAW;GACrD,KAAK,YAAY,gBAAgB,WAAW;IAC3C,cAAc,iBAAiB,oBAAoB,QAAQ,EAAE,MAAM,KAAK,CAAC;GAC1E,CAAC;GACD;EACD;EAEA,KAAK,MAAM,EAAE;CACd;CAEA,MAAM,IAAkB;EAEvB,IAAI,KAAK,QAAQ,IAAI,EAAE,GAAG;EAE1B,KAAK,QAAQ,IAAI,EAAE;EACnB,QAAQ,KAAK,qEAAqE,GAAG,EAAE;CACxF;AACD"}
1
+ {"version":3,"file":"envelope.js","names":[],"sources":["../../../src/elements/envelope.ts"],"sourcesContent":["import type { ValueLink } from '#elements/value-element.ts';\nimport type { AdsrCurves, AdsrProportions, AdsrShape } from '#lib/adsr-shape.ts';\nimport type { FieldAxis, FieldDragState, FieldMappings, FieldPoint } from '#lib/field.ts';\nimport type { PointerDrag } from '#lib/pointer-drag.ts';\n\nimport { ReadoutClaim, revealDelay } from '#elements/readout-claim.ts';\nimport { Readout } from '#elements/readout.ts';\nimport { SonicElement } from '#elements/sonic-element.ts';\nimport { linkValue, SonicValueElement } from '#elements/value-element.ts';\nimport { adsrPath, adsrShape, adsrStages, timeStages } from '#lib/adsr-shape.ts';\nimport { dragThresholdPx } from '#lib/drag-step.ts';\nimport { pointerMove, pointerPosition, startFieldDrag, stepFieldDrag } from '#lib/field.ts';\nimport { bindDrag } from '#lib/pointer-drag.ts';\nimport { requireChild, template } from '#lib/render.ts';\nimport { writeAttribute } from '#lib/write-attribute.ts';\n\n// eslint-disable-next-line unicorn/consistent-boolean-name -- the name bundlers and other kits use\ndeclare const __DEV__: boolean;\n\ndeclare global {\n\tinterface HTMLElementTagNameMap {\n\t\t'sonic-envelope': SonicEnvelope;\n\t}\n}\n\ninterface Binding {\n\telement: SonicValueElement;\n\tlink: ValueLink;\n\tunwatch: () => void;\n}\n\ninterface Drive {\n\taxis: FieldAxis;\n\tbinding: Binding;\n}\n\ninterface HandleDrag {\n\tdrives: Array<Drive & { from: number }>;\n\tisFlipped: boolean;\n\tpart: HTMLElement;\n\tstate: FieldDragState;\n}\n\nconst curveStages = ['attack', 'decay', 'release'] as const;\n\nconst bindable = [...adsrStages, 'attack-curve', 'decay-curve', 'release-curve'] as const;\n\nconst bindableNames = new Set<string>(bindable);\n\nfunction flip<Point extends FieldPoint>(point: Point, isFlipped: boolean): Point {\n\treturn isFlipped ? { ...point, y: -point.y } : point;\n}\n\nfunction isParent(node: Node): node is Node & ParentNode {\n\treturn 'querySelector' in node;\n}\n\nconst emptyPath = { fill: '', floor: { from: 0, to: 0 }, stroke: '' };\n\nfunction stageParts<Stage extends string>(\n\tenvelope: Element,\n\thook: string,\n\tstages: ReadonlyArray<Stage>,\n): Map<Stage, HTMLDivElement> {\n\treturn new Map(\n\t\tstages.map((stage) => [\n\t\t\tstage,\n\t\t\trequireChild(envelope, `.${hook}[data-sonic-stage=\"${stage}\"]`, HTMLDivElement),\n\t\t]),\n\t);\n}\n\nconst renderEnvelope = template(\n\t/* HTML */ `\n\t\t<div class=\"sonic-envelope\" aria-hidden=\"true\">\n\t\t\t<div class=\"sonic-envelope-bracket\"></div>\n\t\t\t<svg class=\"sonic-envelope-graph\" preserveAspectRatio=\"none\" viewBox=\"0 0 1 1\">\n\t\t\t\t<path class=\"sonic-envelope-fill\" />\n\t\t\t\t<rect class=\"sonic-envelope-fill sonic-envelope-floor\" y=\"1\" />\n\t\t\t\t<path class=\"sonic-envelope-line\" />\n\t\t\t</svg>\n\t\t\t<div class=\"sonic-envelope-handle\" data-sonic-stage=\"delay\" hidden></div>\n\t\t\t<div class=\"sonic-envelope-handle\" data-sonic-stage=\"attack\" hidden></div>\n\t\t\t<div class=\"sonic-envelope-handle\" data-sonic-stage=\"hold\" hidden></div>\n\t\t\t<div class=\"sonic-envelope-handle\" data-sonic-stage=\"decay\" hidden></div>\n\t\t\t<div class=\"sonic-envelope-handle\" data-sonic-stage=\"release\" hidden></div>\n\t\t\t<div class=\"sonic-envelope-curve\" data-sonic-stage=\"attack\" hidden></div>\n\t\t\t<div class=\"sonic-envelope-curve\" data-sonic-stage=\"decay\" hidden></div>\n\t\t\t<div class=\"sonic-envelope-curve\" data-sonic-stage=\"release\" hidden></div>\n\t\t\t<div class=\"sonic-envelope-readout\" popover=\"manual\"><span></span></div>\n\t\t</div>\n\t`,\n\tHTMLDivElement,\n);\n\nexport class SonicEnvelope extends SonicElement {\n\tstatic override readonly observedAttributes = [\n\t\t...SonicElement.observedAttributes,\n\t\t...bindable,\n\t\t'readout',\n\t];\n\n\tget attack(): string {\n\t\treturn this.getAttribute('attack') ?? '';\n\t}\n\n\tset attack(id: string | undefined) {\n\t\tthis.reflect('attack', id);\n\t}\n\n\tget attackCurve(): string {\n\t\treturn this.getAttribute('attack-curve') ?? '';\n\t}\n\n\tset attackCurve(id: string | undefined) {\n\t\tthis.reflect('attack-curve', id);\n\t}\n\n\tget decay(): string {\n\t\treturn this.getAttribute('decay') ?? '';\n\t}\n\n\tset decay(id: string | undefined) {\n\t\tthis.reflect('decay', id);\n\t}\n\n\tget decayCurve(): string {\n\t\treturn this.getAttribute('decay-curve') ?? '';\n\t}\n\n\tset decayCurve(id: string | undefined) {\n\t\tthis.reflect('decay-curve', id);\n\t}\n\n\tget delay(): string {\n\t\treturn this.getAttribute('delay') ?? '';\n\t}\n\n\tset delay(id: string | undefined) {\n\t\tthis.reflect('delay', id);\n\t}\n\n\tget hold(): string {\n\t\treturn this.getAttribute('hold') ?? '';\n\t}\n\n\tset hold(id: string | undefined) {\n\t\tthis.reflect('hold', id);\n\t}\n\n\tget pointerType(): string | undefined {\n\t\treturn this.#pointerType;\n\t}\n\n\tget readout(): boolean {\n\t\treturn this.hasAttribute('readout');\n\t}\n\n\tset readout(isOn: boolean) {\n\t\tthis.reflect('readout', isOn);\n\t}\n\n\tget release(): string {\n\t\treturn this.getAttribute('release') ?? '';\n\t}\n\n\tset release(id: string | undefined) {\n\t\tthis.reflect('release', id);\n\t}\n\n\tget releaseCurve(): string {\n\t\treturn this.getAttribute('release-curve') ?? '';\n\t}\n\n\tset releaseCurve(id: string | undefined) {\n\t\tthis.reflect('release-curve', id);\n\t}\n\n\tget sustain(): string {\n\t\treturn this.getAttribute('sustain') ?? '';\n\t}\n\n\tset sustain(id: string | undefined) {\n\t\tthis.reflect('sustain', id);\n\t}\n\n\treadonly #bindings = new Map<string, Binding>();\n\n\treadonly #envelope = renderEnvelope();\n\n\treadonly #bracket = requireChild(this.#envelope, '.sonic-envelope-bracket', HTMLDivElement);\n\n\treadonly #claim = new ReadoutClaim(() => {\n\t\tthis.#renderReadout();\n\t});\n\n\treadonly #curveHandles = stageParts(this.#envelope, 'sonic-envelope-curve', curveStages);\n\n\treadonly #fill = requireChild(this.#envelope, '.sonic-envelope-fill', SVGElement);\n\n\treadonly #floor = requireChild(this.#envelope, '.sonic-envelope-floor', SVGElement);\n\n\treadonly #graph = requireChild(this.#envelope, '.sonic-envelope-graph', SVGElement);\n\n\treadonly #handles = stageParts(this.#envelope, 'sonic-envelope-handle', timeStages);\n\n\t#held: HTMLElement | undefined;\n\n\t#isDriving = false;\n\n\treadonly #line = requireChild(this.#envelope, '.sonic-envelope-line', SVGElement);\n\n\t#pointerDrag: PointerDrag<HandleDrag> | undefined;\n\n\t#pointerType: string | undefined;\n\n\treadonly #readout = new Readout(\n\t\trequireChild(this.#envelope, '.sonic-envelope-readout', HTMLDivElement),\n\t);\n\n\t#shape: AdsrShape = adsrShape({});\n\n\t#signal: AbortSignal | undefined;\n\n\treadonly #waiting = new Set<unknown>();\n\n\treadonly #warned = new Set<string>();\n\n\tattributeChangedCallback(name: string): void {\n\t\tif (!this.#signal) return;\n\t\tif (name === 'disabled') {\n\t\t\tthis.#pointerDrag?.end();\n\t\t\tthis.#draw();\n\t\t\treturn;\n\t\t}\n\t\tif (bindableNames.has(name)) this.#bind();\n\t\telse this.#renderReadout();\n\t}\n\n\toverride connectedCallback(): void {\n\t\tthis.upgradeProperties(...adsrStages, 'attackCurve', 'decayCurve', 'readout', 'releaseCurve');\n\t\tsuper.connectedCallback();\n\t}\n\n\tprotected connect(signal: AbortSignal): void {\n\t\tconst envelope = this.#envelope;\n\n\t\tthis.#signal = signal;\n\t\tthis.keepControl(envelope, signal);\n\t\tthis.#bind();\n\t\tthis.checkStyles(envelope, 'envelope.css');\n\t\tthis.#bindPointer(envelope, signal);\n\t\tsignal.addEventListener(\n\t\t\t'abort',\n\t\t\t() => {\n\t\t\t\tthis.#signal = undefined;\n\t\t\t\tthis.#unbind();\n\t\t\t},\n\t\t\t{ once: true },\n\t\t);\n\t}\n\n\t#bind(): void {\n\t\tthis.#pointerDrag?.end();\n\t\tthis.#unbind();\n\t\tfor (const name of bindable) {\n\t\t\tconst element = this.#resolve(name);\n\t\t\tif (!element) continue;\n\n\t\t\tconst link = linkValue(element);\n\t\t\tconst unwatch = link.watch(() => {\n\t\t\t\tif (!this.#isDriving) this.#draw();\n\t\t\t});\n\n\t\t\tthis.#bindings.set(name, { element, link, unwatch });\n\t\t}\n\t\tthis.#draw();\n\t}\n\n\t#bindPointer(envelope: HTMLElement, signal: AbortSignal): void {\n\t\tthis.#pointerDrag = bindDrag(\n\t\t\tenvelope,\n\t\t\t{\n\t\t\t\tcancel: (drag) => {\n\t\t\t\t\tfor (const { binding, from } of drag.drives) binding.link.input(from);\n\t\t\t\t},\n\t\t\t\tgrab: (event) => this.#grab(event),\n\t\t\t\tmove: (drag, event) => {\n\t\t\t\t\tthis.#moveDrag(drag, event);\n\t\t\t\t},\n\t\t\t\trelease: (drag) => {\n\t\t\t\t\tthis.#claim.press(false);\n\t\t\t\t\tfor (const { binding, from } of drag.drives) {\n\t\t\t\t\t\tif (binding.link.value() === from) continue;\n\n\t\t\t\t\t\tbinding.element.dispatchEvent(new Event('change', { bubbles: true }));\n\t\t\t\t\t}\n\t\t\t\t\tthis.#pointerType = undefined;\n\t\t\t\t},\n\t\t\t\ttoggle: (isDragging) => {\n\t\t\t\t\tthis.toggleState('dragging', isDragging);\n\t\t\t\t},\n\t\t\t},\n\t\t\tsignal,\n\t\t);\n\t}\n\n\t#curveDrives(stage: string): Array<Drive> {\n\t\tconst binding = this.#bindings.get(`${stage}-curve`);\n\n\t\treturn binding ? [{ axis: 'y', binding }] : [];\n\t}\n\n\t#draw(): void {\n\t\tconst shape = this.#readShape();\n\t\tconst path = this.#bindings.size === 0 ? emptyPath : adsrPath(shape);\n\n\t\tthis.#shape = shape;\n\t\twriteAttribute(this.#line, 'd', path.stroke);\n\t\twriteAttribute(this.#fill, 'd', path.fill);\n\t\twriteAttribute(this.#floor, 'x', String(path.floor.from));\n\t\twriteAttribute(this.#floor, 'width', String(path.floor.to - path.floor.from));\n\t\tfor (const [stage, part] of this.#handles) {\n\t\t\tthis.#drawPoint(part, {\n\t\t\t\tat: shape.handles.find((point) => point.stage === stage),\n\t\t\t\tdrives: this.#drives(stage),\n\t\t\t});\n\t\t}\n\t\tfor (const [stage, part] of this.#curveHandles) {\n\t\t\tthis.#drawPoint(part, {\n\t\t\t\tat: shape.curveHandles.find((point) => point.stage === stage),\n\t\t\t\tdrives: this.#curveDrives(stage),\n\t\t\t});\n\t\t}\n\t\tthis.#drawBracket();\n\t\tthis.#renderReadout();\n\t}\n\n\t#drawBracket(): void {\n\t\tconst part = this.#held;\n\t\tif (!part) return;\n\n\t\tfor (const name of ['--_sonic-envelope-x', '--_sonic-envelope-y']) {\n\t\t\tthis.#bracket.style.setProperty(name, part.style.getPropertyValue(name));\n\t\t}\n\t\twriteAttribute(\n\t\t\tthis.#bracket,\n\t\t\t'data-sonic-part',\n\t\t\tpart.classList.contains('sonic-envelope-curve') ? 'curve' : undefined,\n\t\t);\n\t}\n\n\t#drawPoint(\n\t\tpart: HTMLDivElement,\n\t\tpoint: { at: FieldPoint | undefined; drives: Array<Drive> },\n\t): void {\n\t\tconst { at, drives } = point;\n\n\t\twriteAttribute(part, 'hidden', at ? undefined : '');\n\t\tif (!at) return;\n\n\t\tconst isStill = this.isDisabled() || drives.every(({ binding }) => binding.link.isDisabled());\n\n\t\tpart.style.setProperty('--_sonic-envelope-x', String(at.x));\n\t\tpart.style.setProperty('--_sonic-envelope-y', String(at.y));\n\t\twriteAttribute(part, 'data-sonic-axes', drives.map(({ axis }) => axis).join(''));\n\t\twriteAttribute(part, 'data-sonic-disabled', isStill ? '' : undefined);\n\t}\n\n\t#drives(stage: string): Array<Drive> {\n\t\tconst x = this.#bindings.get(stage);\n\t\tconst y = stage === 'decay' ? this.#bindings.get('sustain') : undefined;\n\n\t\treturn [\n\t\t\t...(x ? [{ axis: 'x' as const, binding: x }] : []),\n\t\t\t...(y ? [{ axis: 'y' as const, binding: y }] : []),\n\t\t];\n\t}\n\n\t#grab(event: PointerEvent): HandleDrag | undefined {\n\t\tconst pressed = this.#pressed(event);\n\t\tif (!pressed || pressed.drives.length === 0) return undefined;\n\n\t\tconst { drives, isFlipped, part } = pressed;\n\n\t\tthis.#pointerType = event.pointerType;\n\t\tthis.#claim.press(true, revealDelay(this.#envelope));\n\t\tthis.#held = part;\n\t\tthis.#drawBracket();\n\t\tconst box = this.#graph.getBoundingClientRect();\n\t\tconst travel = { x: Math.max(1, box.width * this.#shape.share), y: Math.max(1, box.height) };\n\t\tconst start = (axis: FieldAxis) => {\n\t\t\tconst link = drives.find((drive) => drive.axis === axis)?.binding.link;\n\t\t\tif (!link) return;\n\n\t\t\tconst mapping = link.mapping();\n\t\t\tconst from = link.value();\n\n\t\t\treturn { from, mapping, proportion: mapping.proportionOf(from), travelPx: travel[axis] };\n\t\t};\n\n\t\treturn {\n\t\t\tdrives: drives.map((drive) => ({ ...drive, from: drive.binding.link.value() })),\n\t\t\tisFlipped,\n\t\t\tpart,\n\t\t\tstate: startFieldDrag({\n\t\t\t\tposition: flip(pointerPosition(event), isFlipped),\n\t\t\t\tthresholdPx: dragThresholdPx(event.pointerType),\n\t\t\t\tx: start('x'),\n\t\t\t\ty: start('y'),\n\t\t\t}),\n\t\t};\n\t}\n\n\t#moveDrag(drag: HandleDrag, event: PointerEvent): void {\n\t\tconst mappings: FieldMappings = {};\n\n\t\tfor (const { axis, binding } of drag.drives) mappings[axis] = binding.link.mapping();\n\n\t\tconst step = stepFieldDrag(mappings, drag.state, flip(pointerMove(event), drag.isFlipped));\n\n\t\tdrag.state = step.state;\n\t\tif (step.state.isEngaged) this.#claim.reveal('drag');\n\t\tthis.#isDriving = true;\n\t\tfor (const { axis, binding } of drag.drives) {\n\t\t\tconst next = step[axis];\n\n\t\t\tif (next !== undefined) binding.link.input(next);\n\t\t}\n\t\tthis.#isDriving = false;\n\t\tthis.#draw();\n\t}\n\n\t#pressed(\n\t\tevent: PointerEvent,\n\t): (Pick<HandleDrag, 'isFlipped' | 'part'> & { drives: Array<Drive> }) | undefined {\n\t\tconst part =\n\t\t\tevent.target instanceof Element\n\t\t\t\t? event.target.closest<HTMLElement>('.sonic-envelope-handle, .sonic-envelope-curve')\n\t\t\t\t: undefined;\n\t\tconst stage = part?.dataset.sonicStage;\n\t\tif (!part || stage === undefined || this.isDisabled()) return undefined;\n\n\t\tconst isCurveHandle = part.classList.contains('sonic-envelope-curve');\n\t\tconst drives = isCurveHandle ? this.#curveDrives(stage) : this.#drives(stage);\n\n\t\treturn {\n\t\t\tdrives: drives.filter(({ binding }) => !binding.link.isDisabled()),\n\t\t\tisFlipped: isCurveHandle && stage === 'attack',\n\t\t\tpart,\n\t\t};\n\t}\n\n\t#readShape(): AdsrShape {\n\t\tconst proportions: AdsrProportions = {};\n\t\tconst curves: AdsrCurves = {};\n\n\t\tfor (const stage of adsrStages) {\n\t\t\tconst link = this.#bindings.get(stage)?.link;\n\n\t\t\tproportions[stage] = link?.mapping().proportionOf(link.value());\n\t\t}\n\t\tfor (const stage of curveStages) {\n\t\t\tcurves[stage] = this.#bindings.get(`${stage}-curve`)?.link.value();\n\t\t}\n\n\t\treturn adsrShape(proportions, curves);\n\t}\n\n\t#rebindOnce(key: unknown, arrives: (rebind: () => void) => void): void {\n\t\tif (this.#waiting.has(key)) return;\n\n\t\tthis.#waiting.add(key);\n\t\tarrives(() => {\n\t\t\tthis.#waiting.delete(key);\n\t\t\tif (this.#signal) this.#bind();\n\t\t});\n\t}\n\n\t#renderReadout(): void {\n\t\tconst drag = this.#pointerDrag?.current();\n\n\t\tif (!drag) {\n\t\t\tthis.#readout.close();\n\t\t\treturn;\n\t\t}\n\n\t\tthis.#readout.show({\n\t\t\tanchor: drag.part,\n\t\t\tisOpen: this.#claim.isRevealed && this.readout,\n\t\t\ttext: drag.drives.map(({ binding }) => binding.element.valueText).join(', '),\n\t\t});\n\t}\n\n\t#resolve(name: string): SonicValueElement | undefined {\n\t\tconst id = this.getAttribute(name);\n\t\tconst root = this.getRootNode();\n\t\tif (!id || !isParent(root)) return undefined;\n\n\t\tconst found = root.querySelector(`#${CSS.escape(id)}`);\n\t\tif (found instanceof SonicValueElement) return found;\n\n\t\tthis.#wait(id, found);\n\n\t\treturn undefined;\n\t}\n\n\t#unbind(): void {\n\t\tfor (const { unwatch } of this.#bindings.values()) unwatch();\n\n\t\tthis.#bindings.clear();\n\t}\n\n\t#wait(id: string, found: Element | null): void {\n\t\tconst tag = found?.localName;\n\t\tconst { ownerDocument } = this;\n\n\t\tif (tag?.includes('-') && !customElements.get(tag)) {\n\t\t\tthis.#rebindOnce(tag, (rebind) => {\n\t\t\t\tvoid customElements.whenDefined(tag).then(rebind);\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\t\tif (!found && ownerDocument.readyState === 'loading') {\n\t\t\tthis.#rebindOnce(ownerDocument, (rebind) => {\n\t\t\t\townerDocument.addEventListener('DOMContentLoaded', rebind, { once: true });\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tthis.#warn(id);\n\t}\n\n\t#warn(id: string): void {\n\t\tif (!__DEV__) return;\n\t\tif (this.#warned.has(id)) return;\n\n\t\tthis.#warned.add(id);\n\t\tconsole.warn(`<sonic-envelope> found no dial, slider or number box with the id \"${id}\"`);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;AA2CA,MAAM,cAAc;CAAC;CAAU;CAAS;AAAS;AAEjD,MAAM,WAAW;CAAC,GAAG;CAAY;CAAgB;CAAe;AAAe;AAE/E,MAAM,gBAAgB,IAAI,IAAY,QAAQ;AAE9C,SAAS,KAA+B,OAAc,WAA2B;CAChF,OAAO,YAAY;EAAE,GAAG;EAAO,GAAG,CAAC,MAAM;CAAE,IAAI;AAChD;AAEA,SAAS,SAAS,MAAuC;CACxD,OAAO,mBAAmB;AAC3B;AAEA,MAAM,YAAY;CAAE,MAAM;CAAI,OAAO;EAAE,MAAM;EAAG,IAAI;CAAE;CAAG,QAAQ;AAAG;AAEpE,SAAS,WACR,UACA,MACA,QAC6B;CAC7B,OAAO,IAAI,IACV,OAAO,KAAK,UAAU,CACrB,OACA,aAAa,UAAU,IAAI,KAAK,qBAAqB,MAAM,KAAK,cAAc,CAC/E,CAAC,CACF;AACD;AAEA,MAAM,iBAAiB,SACX;;;;;;;;;;;;;;;;;;IAmBX,cACD;AAEA,IAAa,gBAAb,cAAmC,aAAa;CAC/C,OAAyB,qBAAqB;EAC7C,GAAG,aAAa;EAChB,GAAG;EACH;CACD;CAEA,IAAI,SAAiB;EACpB,OAAO,KAAK,aAAa,QAAQ,KAAK;CACvC;CAEA,IAAI,OAAO,IAAwB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;GACD;EACD;EACA,IAAI,CAAC,SAAS,cAAc,eAAe,WAAW;GACrD,KAAK,YAAY,gBAAgB,WAAW;IAC3C,cAAc,iBAAiB,oBAAoB,QAAQ,EAAE,MAAM,KAAK,CAAC;GAC1E,CAAC;GACD;EACD;EAEA,KAAK,MAAM,EAAE;CACd;CAEA,MAAM,IAAkB;EAEvB,IAAI,KAAK,QAAQ,IAAI,EAAE,GAAG;EAE1B,KAAK,QAAQ,IAAI,EAAE;EACnB,QAAQ,KAAK,qEAAqE,GAAG,EAAE;CACxF;AACD"}
@@ -2,6 +2,12 @@ import { SonicFormElement } from "./form-element.js";
2
2
  import { ValueMapping } from "../lib/value-mapping.js";
3
3
  import { ValueAxis } from "./value-gestures.js";
4
4
  //#region src/elements/value-element.d.ts
5
+ declare global {
6
+ interface HTMLElementEventMap {
7
+ 'sonic-hover': Event;
8
+ 'sonic-reveal': Event;
9
+ }
10
+ }
5
11
  interface HoverBinding {
6
12
  canShow?: () => boolean;
7
13
  place: () => void;
@@ -291,7 +291,7 @@ var SonicValueElement = class extends SonicFormElement {
291
291
  }, control);
292
292
  this.#gestures.bind(signal, grab);
293
293
  control.addEventListener("pointerup", (event) => {
294
- this.#hover?.at(event);
294
+ this.#hover?.lift(event);
295
295
  }, { signal });
296
296
  }
297
297
  bindHover(control, signal, { canShow = () => true, place, valueAt }) {
@@ -440,6 +440,7 @@ var SonicValueElement = class extends SonicFormElement {
440
440
  }
441
441
  #renderHold() {
442
442
  if (this.heldFrom() === void 0) this.#heldAt = void 0;
443
+ this.#hover?.restore();
443
444
  this.renderReadout();
444
445
  this.holdChanged();
445
446
  }