@xsynaptic/sonic-ui 0.8.0 → 0.9.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/README.md +0 -2
- package/dist/default/elements/dial.js +12 -3
- package/dist/default/elements/envelope.js +2 -2
- package/dist/default/elements/modulation.js +45 -0
- package/dist/default/elements/readout-claim.js +8 -3
- package/dist/default/elements/slider.js +15 -17
- package/dist/default/elements/value-element.js +89 -330
- package/dist/default/elements/value-gestures.js +301 -0
- package/dist/default/elements/waveform.js +5 -2
- package/dist/default/elements/wavestrip.js +5 -15
- package/dist/default/elements/xy.js +9 -20
- package/dist/default/lib/asked-value.js +21 -0
- package/dist/default/lib/canvas-surface.js +3 -0
- package/dist/default/lib/marker-rider.js +6 -3
- package/dist/default/lib/read-ms-property.js +10 -0
- package/dist/dev/elements/dial.js +12 -3
- package/dist/dev/elements/dial.js.map +1 -1
- package/dist/dev/elements/envelope.js +2 -2
- package/dist/dev/elements/envelope.js.map +1 -1
- package/dist/dev/elements/modulation.js +46 -0
- package/dist/dev/elements/modulation.js.map +1 -0
- package/dist/dev/elements/readout-claim.js +8 -3
- package/dist/dev/elements/readout-claim.js.map +1 -1
- package/dist/dev/elements/slider.d.ts +0 -1
- package/dist/dev/elements/slider.js +15 -17
- package/dist/dev/elements/slider.js.map +1 -1
- package/dist/dev/elements/value-element.d.ts +8 -13
- package/dist/dev/elements/value-element.js +89 -330
- package/dist/dev/elements/value-element.js.map +1 -1
- package/dist/dev/elements/value-gestures.d.ts +10 -0
- package/dist/dev/elements/value-gestures.js +302 -0
- package/dist/dev/elements/value-gestures.js.map +1 -0
- package/dist/dev/elements/waveform.js +5 -2
- package/dist/dev/elements/waveform.js.map +1 -1
- package/dist/dev/elements/wavestrip.d.ts +0 -1
- package/dist/dev/elements/wavestrip.js +5 -15
- package/dist/dev/elements/wavestrip.js.map +1 -1
- package/dist/dev/elements/xy.js +9 -20
- package/dist/dev/elements/xy.js.map +1 -1
- package/dist/dev/lib/asked-value.js +22 -0
- package/dist/dev/lib/asked-value.js.map +1 -0
- package/dist/dev/lib/canvas-surface.d.ts +1 -0
- package/dist/dev/lib/canvas-surface.js +3 -0
- package/dist/dev/lib/canvas-surface.js.map +1 -1
- package/dist/dev/lib/marker-rider.js +6 -3
- package/dist/dev/lib/marker-rider.js.map +1 -1
- package/dist/dev/lib/read-ms-property.js +11 -0
- package/dist/dev/lib/read-ms-property.js.map +1 -0
- package/dist/styles/material.css +18 -0
- package/dist/styles/waveform.css +10 -0
- package/dist/styles/wavestrip.css +4 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -23,8 +23,6 @@ import '@xsynaptic/sonic-ui/define';
|
|
|
23
23
|
<sonic-dial aria-label="Cutoff" value="40"></sonic-dial>
|
|
24
24
|
```
|
|
25
25
|
|
|
26
|
-
A `-size` token takes any CSS length and scales its control as one piece; a `-length` token also takes a percentage of the parent.
|
|
27
|
-
|
|
28
26
|
A display takes its signal as data: `spectrum.analyser = node`, or `spectrum.push(frame)`.
|
|
29
27
|
|
|
30
28
|
Under a hydrating framework, register the definitions once hydration is done (in React, from an effect); a control owns one child of its host and uses only the children it documents.
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { requireChild, template } from "../lib/render.js";
|
|
2
|
+
import { createModulation } from "./modulation.js";
|
|
2
3
|
import { SonicValueElement } from "./value-element.js";
|
|
3
4
|
import { bindScale } from "./scale.js";
|
|
4
5
|
|
|
@@ -43,12 +44,15 @@ var SonicDial = class extends SonicValueElement {
|
|
|
43
44
|
this.reflect("modulation", amount);
|
|
44
45
|
}
|
|
45
46
|
get modulationValue() {
|
|
46
|
-
return this.
|
|
47
|
+
return this.#modulation.value();
|
|
47
48
|
}
|
|
48
49
|
set modulationValue(value) {
|
|
49
|
-
this.
|
|
50
|
+
this.#modulation.write(value, this.isBound() ? this.mapping() : void 0);
|
|
50
51
|
}
|
|
51
52
|
#dial = renderDial();
|
|
53
|
+
#modulation = createModulation(this.#dial, "dial", (isModulated) => {
|
|
54
|
+
this.toggleState("modulated", isModulated);
|
|
55
|
+
});
|
|
52
56
|
connectedCallback() {
|
|
53
57
|
this.upgradeProperties("endless", "modulationValue", "modulation");
|
|
54
58
|
super.connectedCallback();
|
|
@@ -67,7 +71,12 @@ var SonicDial = class extends SonicValueElement {
|
|
|
67
71
|
}));
|
|
68
72
|
}
|
|
69
73
|
draw() {
|
|
70
|
-
this.
|
|
74
|
+
this.#modulation.draw({
|
|
75
|
+
mapping: this.mapping(),
|
|
76
|
+
modulation: this.endless ? 0 : this.modulation,
|
|
77
|
+
origin: this.originValue(),
|
|
78
|
+
value: this.value
|
|
79
|
+
});
|
|
71
80
|
}
|
|
72
81
|
focusTarget() {
|
|
73
82
|
return this.#dial;
|
|
@@ -2,8 +2,8 @@ import { writeAttribute } from "../lib/write-attribute.js";
|
|
|
2
2
|
import { SonicElement } from "./sonic-element.js";
|
|
3
3
|
import { requireChild, template } from "../lib/render.js";
|
|
4
4
|
import { bindDrag } from "../lib/pointer-drag.js";
|
|
5
|
-
import { ReadoutClaim } from "./readout-claim.js";
|
|
6
5
|
import { Readout } from "./readout.js";
|
|
6
|
+
import { ReadoutClaim, revealDelay } from "./readout-claim.js";
|
|
7
7
|
import { dragThresholdPx } from "../lib/drag-step.js";
|
|
8
8
|
import { SonicValueElement, linkValue } from "./value-element.js";
|
|
9
9
|
import { adsrPath, adsrShape, adsrStages, timeStages } from "../lib/adsr-shape.js";
|
|
@@ -269,7 +269,7 @@ var SonicEnvelope = class extends SonicElement {
|
|
|
269
269
|
const pressed = this.#pressed(event);
|
|
270
270
|
if (!pressed || pressed.drives.length === 0) return void 0;
|
|
271
271
|
const { drives, isFlipped, part } = pressed;
|
|
272
|
-
this.#claim.press(true);
|
|
272
|
+
this.#claim.press(true, revealDelay(this.#envelope));
|
|
273
273
|
this.#held = part;
|
|
274
274
|
this.#drawBracket();
|
|
275
275
|
const box = this.#graph.getBoundingClientRect();
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { toNumber } from "../lib/math.js";
|
|
2
|
+
|
|
3
|
+
//#region src/elements/modulation.ts
|
|
4
|
+
function createModulation(control, prefix, toggle) {
|
|
5
|
+
const { style } = control;
|
|
6
|
+
let isModulated = false;
|
|
7
|
+
let modulationValue;
|
|
8
|
+
const writeProportion = (mapping) => {
|
|
9
|
+
const shown = mapping.isWrapping ? void 0 : modulationValue;
|
|
10
|
+
const isShown = shown !== void 0;
|
|
11
|
+
if (isShown !== isModulated) {
|
|
12
|
+
isModulated = isShown;
|
|
13
|
+
toggle(isShown);
|
|
14
|
+
}
|
|
15
|
+
if (shown === void 0) {
|
|
16
|
+
style.removeProperty(`--_sonic-${prefix}-modulation-value`);
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
style.setProperty(`--_sonic-${prefix}-modulation-value`, String(mapping.proportionOf(shown)));
|
|
20
|
+
};
|
|
21
|
+
return {
|
|
22
|
+
draw: ({ mapping, modulation, origin, value }) => {
|
|
23
|
+
const at = mapping.proportionOf(value);
|
|
24
|
+
const reach = mapping.proportionOf(value + modulation);
|
|
25
|
+
const { positionCount } = mapping;
|
|
26
|
+
style.setProperty(`--_sonic-${prefix}-value`, String(at));
|
|
27
|
+
style.setProperty(`--_sonic-${prefix}-origin`, String(mapping.proportionOf(origin)));
|
|
28
|
+
style.setProperty(`--_sonic-${prefix}-modulation-from`, String(Math.min(at, reach)));
|
|
29
|
+
style.setProperty(`--_sonic-${prefix}-modulation-to`, String(Math.max(at, reach)));
|
|
30
|
+
if (positionCount === void 0) style.removeProperty(`--_sonic-${prefix}-position-count`);
|
|
31
|
+
else style.setProperty(`--_sonic-${prefix}-position-count`, String(positionCount));
|
|
32
|
+
writeProportion(mapping);
|
|
33
|
+
},
|
|
34
|
+
value: () => modulationValue,
|
|
35
|
+
write: (next, mapping) => {
|
|
36
|
+
const value = next === void 0 || next === null ? void 0 : toNumber(next);
|
|
37
|
+
if (value !== void 0 && !Number.isFinite(value)) return;
|
|
38
|
+
modulationValue = value;
|
|
39
|
+
if (mapping) writeProportion(mapping);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
//#endregion
|
|
45
|
+
export { createModulation };
|
|
@@ -1,6 +1,11 @@
|
|
|
1
|
+
import { readMsProperty } from "../lib/read-ms-property.js";
|
|
2
|
+
|
|
1
3
|
//#region src/elements/readout-claim.ts
|
|
2
4
|
const keyRevealMs = 1e3;
|
|
3
5
|
const revealMs = 250;
|
|
6
|
+
function revealDelay(control) {
|
|
7
|
+
return Math.max(0, readMsProperty(getComputedStyle(control), "--_sonic-reveal-delay", revealMs));
|
|
8
|
+
}
|
|
4
9
|
var ReadoutClaim = class {
|
|
5
10
|
get isRevealed() {
|
|
6
11
|
return this.#isDragging || this.#keyTimer !== void 0;
|
|
@@ -24,7 +29,7 @@ var ReadoutClaim = class {
|
|
|
24
29
|
this.#keyTimer = void 0;
|
|
25
30
|
return wasTimed;
|
|
26
31
|
}
|
|
27
|
-
press(isDown) {
|
|
32
|
+
press(isDown, delayMs = revealMs) {
|
|
28
33
|
this.conceal("drag");
|
|
29
34
|
if (!isDown) {
|
|
30
35
|
this.#onLapse();
|
|
@@ -33,7 +38,7 @@ var ReadoutClaim = class {
|
|
|
33
38
|
this.#holdTimer = setTimeout(() => {
|
|
34
39
|
this.reveal("drag");
|
|
35
40
|
this.#onLapse();
|
|
36
|
-
},
|
|
41
|
+
}, delayMs);
|
|
37
42
|
}
|
|
38
43
|
reveal(by) {
|
|
39
44
|
if (by === "drag") {
|
|
@@ -49,4 +54,4 @@ var ReadoutClaim = class {
|
|
|
49
54
|
};
|
|
50
55
|
|
|
51
56
|
//#endregion
|
|
52
|
-
export { ReadoutClaim };
|
|
57
|
+
export { ReadoutClaim, revealDelay };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { clampProportion } from "../lib/math.js";
|
|
2
2
|
import { requireChild, template } from "../lib/render.js";
|
|
3
|
+
import { createModulation } from "./modulation.js";
|
|
3
4
|
import { SonicValueElement } from "./value-element.js";
|
|
4
5
|
import { bindScale } from "./scale.js";
|
|
5
|
-
import { bindHoverPreview } from "../lib/hover-preview.js";
|
|
6
6
|
import { sortedRegions } from "../lib/time-regions.js";
|
|
7
7
|
|
|
8
8
|
//#region src/elements/slider.ts
|
|
@@ -59,10 +59,10 @@ var SonicSlider = class extends SonicValueElement {
|
|
|
59
59
|
this.reflect("modulation", amount);
|
|
60
60
|
}
|
|
61
61
|
get modulationValue() {
|
|
62
|
-
return this.
|
|
62
|
+
return this.#modulation.value();
|
|
63
63
|
}
|
|
64
64
|
set modulationValue(value) {
|
|
65
|
-
this.
|
|
65
|
+
this.#modulation.write(value, this.isBound() ? this.mapping() : void 0);
|
|
66
66
|
}
|
|
67
67
|
get orientation() {
|
|
68
68
|
return this.getAttribute("orientation") === "vertical" ? "vertical" : "horizontal";
|
|
@@ -83,8 +83,10 @@ var SonicSlider = class extends SonicValueElement {
|
|
|
83
83
|
this.reflect("spring", isSpring);
|
|
84
84
|
}
|
|
85
85
|
#buffered = [];
|
|
86
|
-
#hover;
|
|
87
86
|
#slider = renderSlider();
|
|
87
|
+
#modulation = createModulation(this.#slider, "slider", (isModulated) => {
|
|
88
|
+
this.toggleState("modulated", isModulated);
|
|
89
|
+
});
|
|
88
90
|
connectedCallback() {
|
|
89
91
|
this.upgradeProperties("buffered", "groovePress", "modulationValue", "modulation", "orientation", "scrub", "spring");
|
|
90
92
|
super.connectedCallback();
|
|
@@ -99,14 +101,9 @@ var SonicSlider = class extends SonicValueElement {
|
|
|
99
101
|
slider.addEventListener("transitionend", (event) => {
|
|
100
102
|
if (event.propertyName === "--_sonic-slider-value") this.toggleState("springing", false);
|
|
101
103
|
}, { signal });
|
|
102
|
-
this
|
|
104
|
+
this.bindHover(slider, signal, {
|
|
103
105
|
canShow: () => this.scrub && this.readout && this.orientation === "horizontal",
|
|
104
|
-
|
|
105
|
-
this.render();
|
|
106
|
-
},
|
|
107
|
-
isTaken: () => this.isEditing() || this.isRevealed(),
|
|
108
|
-
show: () => {
|
|
109
|
-
this.renderReadout();
|
|
106
|
+
place: () => {
|
|
110
107
|
this.#placeReadout(slider);
|
|
111
108
|
},
|
|
112
109
|
valueAt: (event) => {
|
|
@@ -115,7 +112,7 @@ var SonicSlider = class extends SonicValueElement {
|
|
|
115
112
|
const mapping = this.mapping();
|
|
116
113
|
return mapping.snap(mapping.valueAt(at));
|
|
117
114
|
}
|
|
118
|
-
}
|
|
115
|
+
});
|
|
119
116
|
this.render();
|
|
120
117
|
this.checkStyles(slider, "slider.css");
|
|
121
118
|
this.bindGestures(slider, signal, (event) => {
|
|
@@ -130,8 +127,12 @@ var SonicSlider = class extends SonicValueElement {
|
|
|
130
127
|
return this.orientation;
|
|
131
128
|
}
|
|
132
129
|
draw() {
|
|
133
|
-
|
|
134
|
-
|
|
130
|
+
this.#modulation.draw({
|
|
131
|
+
mapping: this.mapping(),
|
|
132
|
+
modulation: this.modulation,
|
|
133
|
+
origin: this.originValue(),
|
|
134
|
+
value: this.value
|
|
135
|
+
});
|
|
135
136
|
this.#renderBuffered(this.#slider);
|
|
136
137
|
this.#renderScrub(this.#slider);
|
|
137
138
|
this.#placeReadout(this.#slider);
|
|
@@ -146,9 +147,6 @@ var SonicSlider = class extends SonicValueElement {
|
|
|
146
147
|
holdChanged() {
|
|
147
148
|
if (this.scrub) this.render();
|
|
148
149
|
}
|
|
149
|
-
previewValue() {
|
|
150
|
-
return this.#hover?.value();
|
|
151
|
-
}
|
|
152
150
|
scrubsKeyRepeat() {
|
|
153
151
|
return this.scrub;
|
|
154
152
|
}
|