@weasel-js/ui 1.4.4 → 1.5.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/dist/chunks/{BandEditor-CUlbOlJi.js → BandEditor-BeWO56_w.js} +1 -1
- package/dist/chunks/{BandEditor-CUlbOlJi.js.map → BandEditor-BeWO56_w.js.map} +1 -1
- package/dist/chunks/{Callout-Dvt6lqVn.js → Callout-BPIA2is-.js} +1 -1
- package/dist/chunks/{Callout-Dvt6lqVn.js.map → Callout-BPIA2is-.js.map} +1 -1
- package/dist/chunks/ComboBox-CPES6Y1i.js +138 -0
- package/dist/chunks/ComboBox-CPES6Y1i.js.map +1 -0
- package/dist/chunks/CurveEditor-Cj0lLiyR.js +533 -0
- package/dist/chunks/CurveEditor-Cj0lLiyR.js.map +1 -0
- package/dist/chunks/{DetentSlider-BpD7bgjN.js → DetentSlider-CYicfnKr.js} +2 -2
- package/dist/chunks/{DetentSlider-BpD7bgjN.js.map → DetentSlider-CYicfnKr.js.map} +1 -1
- package/dist/chunks/{GradientEditor-BLpAtMDK.js → GradientEditor-dBprHbS0.js} +2 -2
- package/dist/chunks/{GradientEditor-BLpAtMDK.js.map → GradientEditor-dBprHbS0.js.map} +1 -1
- package/dist/chunks/MenuButton-Do8fFUx1.js +60 -0
- package/dist/chunks/MenuButton-Do8fFUx1.js.map +1 -0
- package/dist/chunks/NumberField-BWzhqS19.js +112 -0
- package/dist/chunks/NumberField-BWzhqS19.js.map +1 -0
- package/dist/chunks/{PaintInput-B7AScmHN.js → PaintInput-DAevU7fd.js} +2 -2
- package/dist/chunks/{PaintInput-B7AScmHN.js.map → PaintInput-DAevU7fd.js.map} +1 -1
- package/dist/chunks/Plot2D-CVZwQpWJ.js +292 -0
- package/dist/chunks/Plot2D-CVZwQpWJ.js.map +1 -0
- package/dist/chunks/{PointPlotter-CbDKVggs.js → PointPlotter-anTHwz8f.js} +2 -2
- package/dist/chunks/PointPlotter-anTHwz8f.js.map +1 -0
- package/dist/chunks/Prefs-CzIn-hlq.js +302 -0
- package/dist/chunks/Prefs-CzIn-hlq.js.map +1 -0
- package/dist/chunks/Properties-DJaDEJkT.js +765 -0
- package/dist/chunks/Properties-DJaDEJkT.js.map +1 -0
- package/dist/chunks/{ResizeHandle-BrCO0JrH.js → ResizeHandle-CiExUWP-.js} +1 -1
- package/dist/chunks/{ResizeHandle-BrCO0JrH.js.map → ResizeHandle-CiExUWP-.js.map} +1 -1
- package/dist/chunks/{SelectionPanel-C59wavdA.js → SelectionPanel-CbyUT3Dh.js} +204 -194
- package/dist/chunks/SelectionPanel-CbyUT3Dh.js.map +1 -0
- package/dist/chunks/{Sidebar-BvwjZiFm.js → Sidebar-Cqcfx3_s.js} +1 -1
- package/dist/chunks/{Sidebar-BvwjZiFm.js.map → Sidebar-Cqcfx3_s.js.map} +1 -1
- package/dist/chunks/{SidebarPanel-D5Ua2vyP.js → SidebarPanel-BLzBo0S2.js} +1 -1
- package/dist/chunks/{SidebarPanel-D5Ua2vyP.js.map → SidebarPanel-BLzBo0S2.js.map} +1 -1
- package/dist/chunks/{Slider-Bs-KSYgQ.js → Slider--DFRC_hc.js} +2 -2
- package/dist/chunks/{Slider-Bs-KSYgQ.js.map → Slider--DFRC_hc.js.map} +1 -1
- package/dist/chunks/{StatusBar-Bqv4D0dW.js → StatusBar-B9NQ8atD.js} +1 -1
- package/dist/chunks/{StatusBar-Bqv4D0dW.js.map → StatusBar-B9NQ8atD.js.map} +1 -1
- package/dist/chunks/{Tabs-BT3CDkoQ.js → Tabs-9sODd2Ut.js} +1 -1
- package/dist/chunks/{Tabs-BT3CDkoQ.js.map → Tabs-9sODd2Ut.js.map} +1 -1
- package/dist/chunks/Timeline-DOZgb1CG.js +915 -0
- package/dist/chunks/Timeline-DOZgb1CG.js.map +1 -0
- package/dist/chunks/{Toast-B7ylq7fz.js → Toast-LpN1WK8E.js} +1 -1
- package/dist/chunks/{Toast-B7ylq7fz.js.map → Toast-LpN1WK8E.js.map} +1 -1
- package/dist/chunks/{ToolButton-CtDkqUIc.js → ToolButton-B81YjdwO.js} +1 -1
- package/dist/chunks/{ToolButton-CtDkqUIc.js.map → ToolButton-B81YjdwO.js.map} +1 -1
- package/dist/chunks/{ToolGroup-zDtqt0QJ.js → ToolGroup-D7juDOC_.js} +1 -1
- package/dist/chunks/{ToolGroup-zDtqt0QJ.js.map → ToolGroup-D7juDOC_.js.map} +1 -1
- package/dist/chunks/{ToolPalette-BbrMHfQ9.js → ToolPalette-BSzmRJS7.js} +3 -3
- package/dist/chunks/{ToolPalette-BbrMHfQ9.js.map → ToolPalette-BSzmRJS7.js.map} +1 -1
- package/dist/chunks/createKeyframeLayer-AL4jP0EX.js +694 -0
- package/dist/chunks/createKeyframeLayer-AL4jP0EX.js.map +1 -0
- package/dist/chunks/number-f6PydOZK.js +52 -0
- package/dist/chunks/number-f6PydOZK.js.map +1 -0
- package/dist/chunks/{schema-CtWwGbqJ.js → schema-CPdFNeP6.js} +15 -9
- package/dist/chunks/schema-CPdFNeP6.js.map +1 -0
- package/dist/components/BandEditor/index.js +1 -1
- package/dist/components/Callout/index.js +1 -1
- package/dist/components/ComboBox/ComboBox.d.ts +36 -0
- package/dist/components/ComboBox/ComboBox.d.ts.map +1 -1
- package/dist/components/ComboBox/index.d.ts +1 -1
- package/dist/components/ComboBox/index.d.ts.map +1 -1
- package/dist/components/ComboBox/index.js +1 -1
- package/dist/components/CurveEditor/CurveEditor.d.ts +4 -2
- package/dist/components/CurveEditor/CurveEditor.d.ts.map +1 -1
- package/dist/components/CurveEditor/LayeredCurveEditor.d.ts +8 -1
- package/dist/components/CurveEditor/LayeredCurveEditor.d.ts.map +1 -1
- package/dist/components/CurveEditor/createFunctionLayer.d.ts +2 -0
- package/dist/components/CurveEditor/createFunctionLayer.d.ts.map +1 -1
- package/dist/components/CurveEditor/createKeyframeLayer.d.ts +70 -0
- package/dist/components/CurveEditor/createKeyframeLayer.d.ts.map +1 -0
- package/dist/components/CurveEditor/index.d.ts +3 -1
- package/dist/components/CurveEditor/index.d.ts.map +1 -1
- package/dist/components/CurveEditor/index.js +3 -2
- package/dist/components/CurveEditor/layerTypes.d.ts +8 -3
- package/dist/components/CurveEditor/layerTypes.d.ts.map +1 -1
- package/dist/components/CurveEditor/snap.d.ts +3 -0
- package/dist/components/CurveEditor/snap.d.ts.map +1 -0
- package/dist/components/DetentSlider/index.js +1 -1
- package/dist/components/GradientEditor/index.js +1 -1
- package/dist/components/MenuButton/MenuButton.d.ts +29 -0
- package/dist/components/MenuButton/MenuButton.d.ts.map +1 -0
- package/dist/components/MenuButton/index.d.ts +3 -0
- package/dist/components/MenuButton/index.d.ts.map +1 -0
- package/dist/components/MenuButton/index.js +2 -0
- package/dist/components/NumberField/UnitField.d.ts +30 -0
- package/dist/components/NumberField/UnitField.d.ts.map +1 -0
- package/dist/components/NumberField/index.d.ts +2 -0
- package/dist/components/NumberField/index.d.ts.map +1 -1
- package/dist/components/NumberField/index.js +2 -2
- package/dist/components/PaintInput/index.js +1 -1
- package/dist/components/Plot2D/Plot2D.d.ts +38 -2
- package/dist/components/Plot2D/Plot2D.d.ts.map +1 -1
- package/dist/components/Plot2D/index.d.ts +2 -1
- package/dist/components/Plot2D/index.d.ts.map +1 -1
- package/dist/components/Plot2D/index.js +2 -2
- package/dist/components/Plot2D/ticks.d.ts +43 -0
- package/dist/components/Plot2D/ticks.d.ts.map +1 -0
- package/dist/components/PointPlotter/PointPlotter.d.ts +3 -1
- package/dist/components/PointPlotter/PointPlotter.d.ts.map +1 -1
- package/dist/components/PointPlotter/index.js +1 -1
- package/dist/components/Prefs/PrefsForm.d.ts.map +1 -1
- package/dist/components/Prefs/index.d.ts +1 -1
- package/dist/components/Prefs/index.d.ts.map +1 -1
- package/dist/components/Prefs/index.js +3 -3
- package/dist/components/Prefs/schema.d.ts +5 -2
- package/dist/components/Prefs/schema.d.ts.map +1 -1
- package/dist/components/Properties/PropertyPanel.d.ts +15 -6
- package/dist/components/Properties/PropertyPanel.d.ts.map +1 -1
- package/dist/components/Properties/index.js +1 -1
- package/dist/components/ResizeHandle/index.js +1 -1
- package/dist/components/SelectionPanel/index.js +1 -1
- package/dist/components/Sidebar/index.js +1 -1
- package/dist/components/SidebarPanel/index.js +1 -1
- package/dist/components/Slider/index.js +1 -1
- package/dist/components/StatusBar/index.js +1 -1
- package/dist/components/Tabs/index.js +1 -1
- package/dist/components/Timeline/Lane.d.ts +9 -7
- package/dist/components/Timeline/Lane.d.ts.map +1 -1
- package/dist/components/Timeline/LaneGraph.d.ts +24 -0
- package/dist/components/Timeline/LaneGraph.d.ts.map +1 -0
- package/dist/components/Timeline/Ruler.d.ts.map +1 -1
- package/dist/components/Timeline/Timeline.d.ts.map +1 -1
- package/dist/components/Timeline/index.js +1 -1
- package/dist/components/Timeline/keys.d.ts +4 -3
- package/dist/components/Timeline/keys.d.ts.map +1 -1
- package/dist/components/Timeline/timeScale.d.ts +2 -0
- package/dist/components/Timeline/timeScale.d.ts.map +1 -1
- package/dist/components/Toast/index.js +1 -1
- package/dist/components/ToolButton/index.js +1 -1
- package/dist/components/ToolGroup/index.js +1 -1
- package/dist/components/ToolPalette/index.js +1 -1
- package/dist/format/number.d.ts +16 -0
- package/dist/format/number.d.ts.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +99 -64
- package/dist/index.js.map +1 -1
- package/dist/style.css +1 -1
- package/dist/useAsyncOptions.d.ts +38 -0
- package/dist/useAsyncOptions.d.ts.map +1 -0
- package/package.json +7 -6
- package/dist/chunks/ComboBox-BBRRWvdc.js +0 -107
- package/dist/chunks/ComboBox-BBRRWvdc.js.map +0 -1
- package/dist/chunks/CurveEditor-DtjdpJVB.js +0 -784
- package/dist/chunks/CurveEditor-DtjdpJVB.js.map +0 -1
- package/dist/chunks/NumberField-DBowmOfe.js +0 -62
- package/dist/chunks/NumberField-DBowmOfe.js.map +0 -1
- package/dist/chunks/Plot2D-C97pO13t.js +0 -134
- package/dist/chunks/Plot2D-C97pO13t.js.map +0 -1
- package/dist/chunks/PointPlotter-CbDKVggs.js.map +0 -1
- package/dist/chunks/Prefs-4JSEtuU-.js +0 -294
- package/dist/chunks/Prefs-4JSEtuU-.js.map +0 -1
- package/dist/chunks/Properties-BpUYKi7-.js +0 -758
- package/dist/chunks/Properties-BpUYKi7-.js.map +0 -1
- package/dist/chunks/SelectionPanel-C59wavdA.js.map +0 -1
- package/dist/chunks/Timeline-Bz806JbE.js +0 -908
- package/dist/chunks/Timeline-Bz806JbE.js.map +0 -1
- package/dist/chunks/number-Bv1nbhOJ.js +0 -18
- package/dist/chunks/number-Bv1nbhOJ.js.map +0 -1
- package/dist/chunks/schema-CtWwGbqJ.js.map +0 -1
|
@@ -1,908 +0,0 @@
|
|
|
1
|
-
import { H as e, R as t, i as n } from "./icons-BV27dhKB.js";
|
|
2
|
-
import { t as r } from "./DetentSlider-BpD7bgjN.js";
|
|
3
|
-
import { Fragment as i, jsx as a, jsxs as o } from "react/jsx-runtime";
|
|
4
|
-
import { EASINGS as s, cubicBezierEasing as c, openPointerSession as l, resolveEasing as u, sampleTrack as d, useVisibleRaf as f } from "@weasel-js/core";
|
|
5
|
-
import { useCallback as p, useEffect as m, useLayoutEffect as h, useMemo as g, useReducer as _, useRef as v, useState as y } from "react";
|
|
6
|
-
var b = {
|
|
7
|
-
ruler: "_ruler_gapxk_1",
|
|
8
|
-
tick: "_tick_gapxk_11",
|
|
9
|
-
playhead: "_playhead_gapxk_29",
|
|
10
|
-
lane: "_lane_gapxk_38",
|
|
11
|
-
laneLabel: "_laneLabel_gapxk_45",
|
|
12
|
-
disclosure: "_disclosure_gapxk_63",
|
|
13
|
-
disclosureIcon: "_disclosureIcon_gapxk_64",
|
|
14
|
-
disclosureCollapsed: "_disclosureCollapsed_gapxk_65",
|
|
15
|
-
laneTrack: "_laneTrack_gapxk_67",
|
|
16
|
-
key: "_key_gapxk_74",
|
|
17
|
-
eventMark: "_eventMark_gapxk_74",
|
|
18
|
-
keyGhost: "_keyGhost_gapxk_94",
|
|
19
|
-
eventGhost: "_eventGhost_gapxk_94",
|
|
20
|
-
curve: "_curve_gapxk_109",
|
|
21
|
-
nestedBar: "_nestedBar_gapxk_123",
|
|
22
|
-
transport: "_transport_gapxk_132",
|
|
23
|
-
transportButton: "_transportButton_gapxk_141",
|
|
24
|
-
transportRow: "_transportRow_gapxk_167",
|
|
25
|
-
time: "_time_gapxk_182",
|
|
26
|
-
rate: "_rate_gapxk_183",
|
|
27
|
-
rateSlider: "_rateSlider_gapxk_184",
|
|
28
|
-
rateReadout: "_rateReadout_gapxk_188",
|
|
29
|
-
root: "_root_gapxk_194",
|
|
30
|
-
label: "_label_gapxk_209",
|
|
31
|
-
body: "_body_gapxk_211",
|
|
32
|
-
gutter: "_gutter_gapxk_212",
|
|
33
|
-
rulerWrap: "_rulerWrap_gapxk_213",
|
|
34
|
-
lanes: "_lanes_gapxk_215",
|
|
35
|
-
inspector: "_inspector_gapxk_222",
|
|
36
|
-
segment: "_segment_gapxk_231",
|
|
37
|
-
easingPicker: "_easingPicker_gapxk_241",
|
|
38
|
-
easingLabel: "_easingLabel_gapxk_242",
|
|
39
|
-
easingPreview: "_easingPreview_gapxk_244",
|
|
40
|
-
bezierHandle: "_bezierHandle_gapxk_253"
|
|
41
|
-
};
|
|
42
|
-
//#endregion
|
|
43
|
-
//#region src/components/Timeline/easingSpec.ts
|
|
44
|
-
function x(e) {
|
|
45
|
-
return typeof e == "object" && e && "bezier" in e ? e.bezier : null;
|
|
46
|
-
}
|
|
47
|
-
function S(e) {
|
|
48
|
-
return e === void 0 ? null : x(e);
|
|
49
|
-
}
|
|
50
|
-
function C(e) {
|
|
51
|
-
if (e === void 0) return "linear";
|
|
52
|
-
if (typeof e == "string") return e;
|
|
53
|
-
let t = x(e);
|
|
54
|
-
if (t) return `cubic-bezier(${t.join(", ")})`;
|
|
55
|
-
for (let [t, n] of Object.entries(s)) if (n === e) return t;
|
|
56
|
-
return "custom";
|
|
57
|
-
}
|
|
58
|
-
function w(e, t) {
|
|
59
|
-
let n = u(e), r = Array(t), i = t - 1;
|
|
60
|
-
for (let e = 0; e < t; e++) r[e] = n(i === 0 ? 0 : e / i);
|
|
61
|
-
return r;
|
|
62
|
-
}
|
|
63
|
-
var T = Object.keys(s), E = 24, D = {
|
|
64
|
-
linear: [
|
|
65
|
-
0,
|
|
66
|
-
0,
|
|
67
|
-
1,
|
|
68
|
-
1
|
|
69
|
-
],
|
|
70
|
-
easeInQuad: [
|
|
71
|
-
.11,
|
|
72
|
-
0,
|
|
73
|
-
.5,
|
|
74
|
-
0
|
|
75
|
-
],
|
|
76
|
-
easeOutQuad: [
|
|
77
|
-
.5,
|
|
78
|
-
1,
|
|
79
|
-
.89,
|
|
80
|
-
1
|
|
81
|
-
],
|
|
82
|
-
easeInOutQuad: [
|
|
83
|
-
.45,
|
|
84
|
-
0,
|
|
85
|
-
.55,
|
|
86
|
-
1
|
|
87
|
-
],
|
|
88
|
-
easeInCubic: [
|
|
89
|
-
.32,
|
|
90
|
-
0,
|
|
91
|
-
.67,
|
|
92
|
-
0
|
|
93
|
-
],
|
|
94
|
-
easeOutCubic: [
|
|
95
|
-
.33,
|
|
96
|
-
1,
|
|
97
|
-
.68,
|
|
98
|
-
1
|
|
99
|
-
],
|
|
100
|
-
easeInOutCubic: [
|
|
101
|
-
.65,
|
|
102
|
-
0,
|
|
103
|
-
.35,
|
|
104
|
-
1
|
|
105
|
-
],
|
|
106
|
-
easeInSine: [
|
|
107
|
-
.12,
|
|
108
|
-
0,
|
|
109
|
-
.39,
|
|
110
|
-
0
|
|
111
|
-
],
|
|
112
|
-
easeOutSine: [
|
|
113
|
-
.61,
|
|
114
|
-
1,
|
|
115
|
-
.88,
|
|
116
|
-
1
|
|
117
|
-
],
|
|
118
|
-
easeInOutSine: [
|
|
119
|
-
.37,
|
|
120
|
-
0,
|
|
121
|
-
.63,
|
|
122
|
-
1
|
|
123
|
-
]
|
|
124
|
-
}, O = [
|
|
125
|
-
.25,
|
|
126
|
-
.1,
|
|
127
|
-
.25,
|
|
128
|
-
1
|
|
129
|
-
];
|
|
130
|
-
function k(e) {
|
|
131
|
-
let { value: t, onChange: n } = e, r = S(t), i = C(t), s = r === null && T.includes(i), c = r === null ? s ? i : "linear" : "custom", l = w(t, E).map((e, t) => `${t / (E - 1) * 100},${100 - e * 100}`).join(" ");
|
|
132
|
-
return /* @__PURE__ */ o("div", {
|
|
133
|
-
className: b.easingPicker,
|
|
134
|
-
children: [
|
|
135
|
-
/* @__PURE__ */ o("label", { children: ["Easing", /* @__PURE__ */ o("select", {
|
|
136
|
-
value: c,
|
|
137
|
-
onChange: (e) => n(e.target.value === "linear" ? void 0 : e.target.value),
|
|
138
|
-
children: [
|
|
139
|
-
/* @__PURE__ */ a("option", {
|
|
140
|
-
value: "linear",
|
|
141
|
-
children: "linear"
|
|
142
|
-
}),
|
|
143
|
-
T.filter((e) => e !== "linear").map((e) => /* @__PURE__ */ a("option", {
|
|
144
|
-
value: e,
|
|
145
|
-
children: e
|
|
146
|
-
}, e)),
|
|
147
|
-
r === null ? null : /* @__PURE__ */ a("option", {
|
|
148
|
-
value: "custom",
|
|
149
|
-
children: "custom"
|
|
150
|
-
})
|
|
151
|
-
]
|
|
152
|
-
})] }),
|
|
153
|
-
r === null ? /* @__PURE__ */ a("button", {
|
|
154
|
-
type: "button",
|
|
155
|
-
className: b.transportButton,
|
|
156
|
-
onClick: () => n({ bezier: D[c] ?? O }),
|
|
157
|
-
children: "Convert to bezier"
|
|
158
|
-
}) : /* @__PURE__ */ a("span", {
|
|
159
|
-
className: b.easingLabel,
|
|
160
|
-
children: i
|
|
161
|
-
}),
|
|
162
|
-
/* @__PURE__ */ a("svg", {
|
|
163
|
-
className: b.easingPreview,
|
|
164
|
-
"data-testid": "easing-preview",
|
|
165
|
-
viewBox: "0 0 100 100",
|
|
166
|
-
preserveAspectRatio: "none",
|
|
167
|
-
children: /* @__PURE__ */ a("polyline", {
|
|
168
|
-
points: l,
|
|
169
|
-
vectorEffect: "non-scaling-stroke"
|
|
170
|
-
})
|
|
171
|
-
})
|
|
172
|
-
]
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
//#endregion
|
|
176
|
-
//#region src/components/Timeline/timeScale.ts
|
|
177
|
-
var A = 1;
|
|
178
|
-
function j(e, t) {
|
|
179
|
-
let n = e.to - e.from, r = n === 0 ? 0 : t / n, i = t === 0 ? 0 : n / t;
|
|
180
|
-
return {
|
|
181
|
-
window: e,
|
|
182
|
-
widthPx: t,
|
|
183
|
-
toPx: (t) => (t - e.from) * r,
|
|
184
|
-
toMs: (t) => e.from + t * i
|
|
185
|
-
};
|
|
186
|
-
}
|
|
187
|
-
function M(e, t) {
|
|
188
|
-
let n = e.to - e.from;
|
|
189
|
-
return n === 0 ? 0 : (t - e.from) / n;
|
|
190
|
-
}
|
|
191
|
-
function N(e, t) {
|
|
192
|
-
return `${M(e, t) * 100}%`;
|
|
193
|
-
}
|
|
194
|
-
function P(e, t) {
|
|
195
|
-
let n = e.to - e.from;
|
|
196
|
-
return n === 0 ? 0 : t / n;
|
|
197
|
-
}
|
|
198
|
-
function F(e, t) {
|
|
199
|
-
return `${P(e, t) * 100}%`;
|
|
200
|
-
}
|
|
201
|
-
function I(e, t) {
|
|
202
|
-
let n = Math.min(e.to - e.from, t.to - t.from), r = e.from;
|
|
203
|
-
return r < t.from && (r = t.from), r + n > t.to && (r = t.to - n), {
|
|
204
|
-
from: r,
|
|
205
|
-
to: r + n
|
|
206
|
-
};
|
|
207
|
-
}
|
|
208
|
-
function L(e, t, n, r) {
|
|
209
|
-
let i = e.to - e.from, a = r.to - r.from, o = Math.min(a, Math.max(A, i * n)), s = i === 0 ? .5 : (t - e.from) / i;
|
|
210
|
-
return I({
|
|
211
|
-
from: t - s * o,
|
|
212
|
-
to: t + (1 - s) * o
|
|
213
|
-
}, r);
|
|
214
|
-
}
|
|
215
|
-
function ee(e, t, n) {
|
|
216
|
-
return I({
|
|
217
|
-
from: e.from + t,
|
|
218
|
-
to: e.to + t
|
|
219
|
-
}, n);
|
|
220
|
-
}
|
|
221
|
-
function R(e) {
|
|
222
|
-
let t = 10 ** Math.floor(Math.log10(e)), n = e / t;
|
|
223
|
-
return (n <= 1 ? 1 : n <= 2 ? 2 : n <= 5 ? 5 : 10) * t;
|
|
224
|
-
}
|
|
225
|
-
function z(e, t, n) {
|
|
226
|
-
let r = e.to - e.from;
|
|
227
|
-
if (t <= 0 || r <= 0) return [];
|
|
228
|
-
let i = R(n / t * r), a = [];
|
|
229
|
-
for (let t = Math.ceil(e.from / i) * i; t <= e.to + 1e-9; t += i) a.push(Math.round(t / i) * i);
|
|
230
|
-
return a;
|
|
231
|
-
}
|
|
232
|
-
//#endregion
|
|
233
|
-
//#region src/components/Timeline/lanes.ts
|
|
234
|
-
function B(e) {
|
|
235
|
-
if (e.kind !== "sampled") return !1;
|
|
236
|
-
let t = e.keys;
|
|
237
|
-
return t.length > 0 && t.every((e) => typeof e.value == "number");
|
|
238
|
-
}
|
|
239
|
-
function V(e, t) {
|
|
240
|
-
let n = [], r = (e, i, a, o) => {
|
|
241
|
-
e.forEach((e, s) => {
|
|
242
|
-
let c = [...i, s], l = c.join(".");
|
|
243
|
-
n.push({
|
|
244
|
-
key: l,
|
|
245
|
-
path: c,
|
|
246
|
-
track: e,
|
|
247
|
-
label: e.label ?? `${e.kind} ${s}`,
|
|
248
|
-
depth: a,
|
|
249
|
-
offset: o,
|
|
250
|
-
kind: e.kind,
|
|
251
|
-
numeric: B(e)
|
|
252
|
-
}), e.kind === "timeline" && t.has(l) && r(e.timeline.tracks, c, a + 1, o + e.at);
|
|
253
|
-
});
|
|
254
|
-
};
|
|
255
|
-
return r(e, [], 0, 0), n;
|
|
256
|
-
}
|
|
257
|
-
function H(e, t) {
|
|
258
|
-
let n = e, r;
|
|
259
|
-
for (let e of t) {
|
|
260
|
-
if (r = n[e], !r) return;
|
|
261
|
-
n = r.kind === "timeline" ? r.timeline.tracks : [];
|
|
262
|
-
}
|
|
263
|
-
return r;
|
|
264
|
-
}
|
|
265
|
-
//#endregion
|
|
266
|
-
//#region src/components/Timeline/keys.ts
|
|
267
|
-
function U(e, t) {
|
|
268
|
-
return e.length === t.length && e.every((e, n) => e === t[n]);
|
|
269
|
-
}
|
|
270
|
-
function W(e, t) {
|
|
271
|
-
return {
|
|
272
|
-
...e,
|
|
273
|
-
keys: t
|
|
274
|
-
};
|
|
275
|
-
}
|
|
276
|
-
function te(e, t) {
|
|
277
|
-
return {
|
|
278
|
-
...e,
|
|
279
|
-
events: t
|
|
280
|
-
};
|
|
281
|
-
}
|
|
282
|
-
function G(e, t, n) {
|
|
283
|
-
let r = e.slice(), [i, ...a] = t;
|
|
284
|
-
if (a.length === 0) return r[i] = n, r;
|
|
285
|
-
let o = r[i];
|
|
286
|
-
if (o?.kind !== "timeline") return r;
|
|
287
|
-
let s = o;
|
|
288
|
-
return r[i] = {
|
|
289
|
-
...s,
|
|
290
|
-
timeline: {
|
|
291
|
-
...s.timeline,
|
|
292
|
-
tracks: G(s.timeline.tracks, a, n)
|
|
293
|
-
}
|
|
294
|
-
}, r;
|
|
295
|
-
}
|
|
296
|
-
function K(e, t, n) {
|
|
297
|
-
let r = H(e, t.trackPath), i = Math.max(0, n);
|
|
298
|
-
if (r?.kind === "sampled") {
|
|
299
|
-
let n = r, a = {
|
|
300
|
-
...n.keys[t.keyIndex],
|
|
301
|
-
t: i
|
|
302
|
-
}, o = n.keys.filter((e, n) => n !== t.keyIndex), s = o.findIndex((e) => e.t > i), c = s === -1 ? o.length : s;
|
|
303
|
-
return o.splice(c, 0, a), {
|
|
304
|
-
tracks: G(e, t.trackPath, W(r, o)),
|
|
305
|
-
selection: {
|
|
306
|
-
trackPath: t.trackPath,
|
|
307
|
-
keyIndex: c
|
|
308
|
-
}
|
|
309
|
-
};
|
|
310
|
-
}
|
|
311
|
-
if (r?.kind === "event") {
|
|
312
|
-
let n = r, a = {
|
|
313
|
-
...n.events[t.keyIndex],
|
|
314
|
-
t: i
|
|
315
|
-
}, o = n.events.filter((e, n) => n !== t.keyIndex), s = o.findIndex((e) => e.t > i), c = s === -1 ? o.length : s;
|
|
316
|
-
return o.splice(c, 0, a), {
|
|
317
|
-
tracks: G(e, t.trackPath, te(r, o)),
|
|
318
|
-
selection: {
|
|
319
|
-
trackPath: t.trackPath,
|
|
320
|
-
keyIndex: c
|
|
321
|
-
}
|
|
322
|
-
};
|
|
323
|
-
}
|
|
324
|
-
return {
|
|
325
|
-
tracks: e.slice(),
|
|
326
|
-
selection: t
|
|
327
|
-
};
|
|
328
|
-
}
|
|
329
|
-
function q(e, t, n) {
|
|
330
|
-
let r = H(e, t);
|
|
331
|
-
if (r?.kind !== "sampled") return {
|
|
332
|
-
tracks: e.slice(),
|
|
333
|
-
selection: null
|
|
334
|
-
};
|
|
335
|
-
let i = r, a = Math.max(0, n), o = i.keys.length === 0 ? 0 : d(i, a), s = i.keys.slice(), c = s.findIndex((e) => e.t > a), l = c === -1 ? s.length : c;
|
|
336
|
-
return s.splice(l, 0, {
|
|
337
|
-
t: a,
|
|
338
|
-
value: o
|
|
339
|
-
}), {
|
|
340
|
-
tracks: G(e, t, W(r, s)),
|
|
341
|
-
selection: {
|
|
342
|
-
trackPath: t,
|
|
343
|
-
keyIndex: l
|
|
344
|
-
}
|
|
345
|
-
};
|
|
346
|
-
}
|
|
347
|
-
function J(e, t) {
|
|
348
|
-
let n = H(e, t.trackPath);
|
|
349
|
-
if (n?.kind !== "sampled") return {
|
|
350
|
-
tracks: e.slice(),
|
|
351
|
-
selection: t
|
|
352
|
-
};
|
|
353
|
-
let r = n.keys.filter((e, n) => n !== t.keyIndex);
|
|
354
|
-
return {
|
|
355
|
-
tracks: G(e, t.trackPath, W(n, r)),
|
|
356
|
-
selection: r.length === 0 ? null : {
|
|
357
|
-
trackPath: t.trackPath,
|
|
358
|
-
keyIndex: Math.max(0, t.keyIndex - 1)
|
|
359
|
-
}
|
|
360
|
-
};
|
|
361
|
-
}
|
|
362
|
-
function Y(e, t, n) {
|
|
363
|
-
let r = H(e, t.trackPath);
|
|
364
|
-
if (r?.kind !== "sampled") return e.slice();
|
|
365
|
-
let i = r.keys.slice(), { easing: a, ...o } = i[t.keyIndex];
|
|
366
|
-
return i[t.keyIndex] = n === void 0 ? o : {
|
|
367
|
-
...o,
|
|
368
|
-
easing: n
|
|
369
|
-
}, G(e, t.trackPath, W(r, i));
|
|
370
|
-
}
|
|
371
|
-
function X(e, t, n) {
|
|
372
|
-
let r = H(e, t.trackPath);
|
|
373
|
-
if (r?.kind !== "sampled") return e.slice();
|
|
374
|
-
let i = r.keys.slice();
|
|
375
|
-
return i[t.keyIndex] = {
|
|
376
|
-
...i[t.keyIndex],
|
|
377
|
-
value: n
|
|
378
|
-
}, G(e, t.trackPath, W(r, i));
|
|
379
|
-
}
|
|
380
|
-
function ne(e, t, n) {
|
|
381
|
-
let r = e, i = n;
|
|
382
|
-
for (let n of t) {
|
|
383
|
-
let t = Math.abs(n - e);
|
|
384
|
-
t <= i && (r = n, i = t);
|
|
385
|
-
}
|
|
386
|
-
return r;
|
|
387
|
-
}
|
|
388
|
-
//#endregion
|
|
389
|
-
//#region src/components/Timeline/Lane.tsx
|
|
390
|
-
var Z = 8, re = 6, ie = 10, ae = 16;
|
|
391
|
-
function oe(e, t) {
|
|
392
|
-
let n = c(...e), r = Array(t), i = t - 1;
|
|
393
|
-
for (let e = 0; e < t; e++) r[e] = n(i === 0 ? 0 : e / i);
|
|
394
|
-
return r;
|
|
395
|
-
}
|
|
396
|
-
function se(e) {
|
|
397
|
-
return e.kind === "sampled" ? e.track.keys.map((e) => e.t) : e.kind === "event" ? e.track.events.map((e) => e.t) : [];
|
|
398
|
-
}
|
|
399
|
-
function ce(e) {
|
|
400
|
-
let { row: t, window: r, mode: s, selection: c, onSelect: u, onKeyInput: d, onKeyCommit: f, onInsert: p, onToggleExpand: h, expanded: g, snapTimes: _, selectedSegment: x = null, onSelectSegment: C, onEasingCommit: T } = e, E = v(null), D = v(null);
|
|
401
|
-
m(() => () => {
|
|
402
|
-
D.current?.cancel();
|
|
403
|
-
}, []);
|
|
404
|
-
let [O, k] = y(null), [A, P] = y(null), I = (e) => N(r, e + t.offset), L = (e) => {
|
|
405
|
-
let n = E.current?.getBoundingClientRect();
|
|
406
|
-
return n ? j(r, n.width).toMs(e - n.left) - t.offset : r.from;
|
|
407
|
-
}, ee = () => {
|
|
408
|
-
let e = j(r, E.current?.getBoundingClientRect().width ?? 0);
|
|
409
|
-
return e.toMs(re) - e.toMs(0);
|
|
410
|
-
}, R = s === "graph" && t.numeric, z = t.kind === "sampled" ? t.track.keys : [], B = z.map((e) => e.value), V = R ? Math.min(...B) : 0, H = (R ? Math.max(...B) : 1) - V || 1, U = (e) => Z + (e - V) / H * (100 - 2 * Z), W = (e) => {
|
|
411
|
-
let t = E.current?.getBoundingClientRect();
|
|
412
|
-
if (!t || t.height === 0) return V;
|
|
413
|
-
let n = ((1 - (e - t.top) / t.height) * 100 - Z) / (100 - 2 * Z);
|
|
414
|
-
return V + Math.min(1, Math.max(0, n)) * H;
|
|
415
|
-
}, te = () => {
|
|
416
|
-
let e = [];
|
|
417
|
-
for (let n = 1; n < z.length; n++) {
|
|
418
|
-
let i = z[n - 1], a = z[n], o = O && O.keyIndex === n ? oe(O.points, ae) : w(a.easing, ae);
|
|
419
|
-
for (let n = 0; n < o.length; n++) {
|
|
420
|
-
let s = i.t + (a.t - i.t) * n / (o.length - 1), c = i.value + (a.value - i.value) * o[n];
|
|
421
|
-
e.push(`${M(r, s + t.offset) * 100},${100 - U(c)}`);
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
return e.join(" ");
|
|
425
|
-
}, G = x != null && t.kind === "sampled" ? S(z[x]?.easing) : null, K = O && O.keyIndex === x ? O.points : G, q = (e, t, n) => {
|
|
426
|
-
let r = z[e - 1], i = z[e], a = r.t + t * (i.t - r.t), o = r.value + n * (i.value - r.value);
|
|
427
|
-
return {
|
|
428
|
-
left: I(a),
|
|
429
|
-
bottom: `${U(o)}%`
|
|
430
|
-
};
|
|
431
|
-
}, J = (e, t) => {
|
|
432
|
-
D.current?.cancel(), D.current = l(e.currentTarget, e, t, { capture: !1 });
|
|
433
|
-
}, Y = (e, t) => (n) => {
|
|
434
|
-
if (n.button !== 0 || !G) return;
|
|
435
|
-
n.stopPropagation();
|
|
436
|
-
let r = z[e - 1], i = z[e], a = [...G], o = (e) => {
|
|
437
|
-
let n = L(e.clientX), o = i.t === r.t ? 0 : Math.min(1, Math.max(0, (n - r.t) / (i.t - r.t))), s = W(e.clientY), c = i.value === r.value ? 0 : (s - r.value) / (i.value - r.value), l = [...a];
|
|
438
|
-
return l[t * 2] = o, l[t * 2 + 1] = c, l;
|
|
439
|
-
}, s = () => {
|
|
440
|
-
k(null), D.current = null;
|
|
441
|
-
};
|
|
442
|
-
J(n, {
|
|
443
|
-
onMove: (t) => {
|
|
444
|
-
a = o(t), k({
|
|
445
|
-
keyIndex: e,
|
|
446
|
-
points: a
|
|
447
|
-
});
|
|
448
|
-
},
|
|
449
|
-
onEnd: (t) => {
|
|
450
|
-
a = o(t), T?.(e, { bezier: a }), s();
|
|
451
|
-
},
|
|
452
|
-
onCancel: s
|
|
453
|
-
});
|
|
454
|
-
}, X = (e) => (n) => {
|
|
455
|
-
if (n.button !== 0) return;
|
|
456
|
-
n.stopPropagation(), u(e);
|
|
457
|
-
let r = (e) => {
|
|
458
|
-
let n = Math.max(0, L(e.clientX));
|
|
459
|
-
return e.altKey ? n : ne(n + t.offset, _, ee()) - t.offset;
|
|
460
|
-
}, i = (e) => R ? W(e.clientY) : void 0;
|
|
461
|
-
P({
|
|
462
|
-
keyIndex: e,
|
|
463
|
-
t: Q[e],
|
|
464
|
-
value: B[e]
|
|
465
|
-
});
|
|
466
|
-
let a = () => {
|
|
467
|
-
P(null), D.current = null;
|
|
468
|
-
};
|
|
469
|
-
J(n, {
|
|
470
|
-
onMove: (t) => {
|
|
471
|
-
let n = i(t);
|
|
472
|
-
P({
|
|
473
|
-
keyIndex: e,
|
|
474
|
-
t: r(t),
|
|
475
|
-
value: n ?? B[e]
|
|
476
|
-
}), n === void 0 ? d(e, r(t)) : d(e, r(t), n);
|
|
477
|
-
},
|
|
478
|
-
onEnd: (t) => {
|
|
479
|
-
let n = i(t);
|
|
480
|
-
n === void 0 ? f(e, r(t)) : f(e, r(t), n), a();
|
|
481
|
-
},
|
|
482
|
-
onCancel: a
|
|
483
|
-
});
|
|
484
|
-
}, ce = (e, t) => (n) => {
|
|
485
|
-
let r = ie * (n.shiftKey ? 10 : 1);
|
|
486
|
-
n.key === "ArrowRight" && (n.preventDefault(), f(e, t + r)), n.key === "ArrowLeft" && (n.preventDefault(), f(e, Math.max(0, t - r)));
|
|
487
|
-
}, Q = se(t);
|
|
488
|
-
return /* @__PURE__ */ o("div", {
|
|
489
|
-
className: b.lane,
|
|
490
|
-
"data-depth": t.depth,
|
|
491
|
-
"data-mode": s,
|
|
492
|
-
children: [/* @__PURE__ */ o("div", {
|
|
493
|
-
className: b.laneLabel,
|
|
494
|
-
children: [t.kind === "timeline" ? /* @__PURE__ */ a("span", {
|
|
495
|
-
role: "button",
|
|
496
|
-
tabIndex: 0,
|
|
497
|
-
"aria-expanded": g,
|
|
498
|
-
"data-testid": "timeline-disclosure",
|
|
499
|
-
className: b.disclosure,
|
|
500
|
-
onClick: h,
|
|
501
|
-
onKeyDown: (e) => {
|
|
502
|
-
(e.key === "Enter" || e.key === " ") && (e.preventDefault(), h());
|
|
503
|
-
},
|
|
504
|
-
children: /* @__PURE__ */ a(n, {
|
|
505
|
-
size: 14,
|
|
506
|
-
className: [b.disclosureIcon, !g && b.disclosureCollapsed].filter(Boolean).join(" ")
|
|
507
|
-
})
|
|
508
|
-
}) : null, t.label]
|
|
509
|
-
}), /* @__PURE__ */ o("div", {
|
|
510
|
-
className: b.laneTrack,
|
|
511
|
-
ref: E,
|
|
512
|
-
"data-testid": "timeline-lane-track",
|
|
513
|
-
onDoubleClick: (e) => {
|
|
514
|
-
t.kind === "sampled" && p(Math.max(0, L(e.clientX)));
|
|
515
|
-
},
|
|
516
|
-
children: [
|
|
517
|
-
t.kind === "timeline" ? /* @__PURE__ */ a("div", {
|
|
518
|
-
className: b.nestedBar,
|
|
519
|
-
"data-testid": "timeline-nested",
|
|
520
|
-
style: {
|
|
521
|
-
left: I(0),
|
|
522
|
-
width: F(r, t.track.timeline.duration ?? 0)
|
|
523
|
-
}
|
|
524
|
-
}) : null,
|
|
525
|
-
t.kind === "sampled" ? z.slice(1).map((e, n) => {
|
|
526
|
-
let i = n + 1;
|
|
527
|
-
return /* @__PURE__ */ a("div", {
|
|
528
|
-
role: "button",
|
|
529
|
-
tabIndex: 0,
|
|
530
|
-
"aria-label": `${t.label} segment into ${Math.round(e.t)} ms`,
|
|
531
|
-
"aria-current": x === i ? "true" : void 0,
|
|
532
|
-
"data-testid": "timeline-segment",
|
|
533
|
-
className: b.segment,
|
|
534
|
-
style: {
|
|
535
|
-
left: I(z[i - 1].t),
|
|
536
|
-
width: F(r, e.t - z[i - 1].t)
|
|
537
|
-
},
|
|
538
|
-
onClick: () => C?.(i),
|
|
539
|
-
onKeyDown: (e) => {
|
|
540
|
-
(e.key === "Enter" || e.key === " ") && (e.preventDefault(), C?.(i));
|
|
541
|
-
}
|
|
542
|
-
}, `seg-${i}`);
|
|
543
|
-
}) : null,
|
|
544
|
-
R && z.length > 1 ? /* @__PURE__ */ a("svg", {
|
|
545
|
-
className: b.curve,
|
|
546
|
-
"data-testid": "timeline-curve",
|
|
547
|
-
viewBox: "0 0 100 100",
|
|
548
|
-
preserveAspectRatio: "none",
|
|
549
|
-
children: /* @__PURE__ */ a("polyline", {
|
|
550
|
-
points: te(),
|
|
551
|
-
vectorEffect: "non-scaling-stroke"
|
|
552
|
-
})
|
|
553
|
-
}) : null,
|
|
554
|
-
Q.map((e, n) => /* @__PURE__ */ a("div", {
|
|
555
|
-
role: "button",
|
|
556
|
-
tabIndex: 0,
|
|
557
|
-
"aria-label": `${t.label} key at ${Math.round(e)} ms`,
|
|
558
|
-
"aria-current": c === n ? "true" : void 0,
|
|
559
|
-
"data-testid": t.kind === "event" ? "timeline-event" : "timeline-key",
|
|
560
|
-
"data-dragging": A?.keyIndex === n ? "true" : void 0,
|
|
561
|
-
className: t.kind === "event" ? b.eventMark : b.key,
|
|
562
|
-
style: R ? {
|
|
563
|
-
left: I(e),
|
|
564
|
-
bottom: `${U(B[n])}%`
|
|
565
|
-
} : { left: I(e) },
|
|
566
|
-
onPointerDown: X(n),
|
|
567
|
-
onKeyDown: ce(n, e)
|
|
568
|
-
}, n)),
|
|
569
|
-
A ? /* @__PURE__ */ a("div", {
|
|
570
|
-
"aria-hidden": "true",
|
|
571
|
-
"data-testid": "timeline-key-ghost",
|
|
572
|
-
className: t.kind === "event" ? b.eventGhost : b.keyGhost,
|
|
573
|
-
style: R && A.value !== void 0 ? {
|
|
574
|
-
left: I(A.t),
|
|
575
|
-
bottom: `${U(A.value)}%`
|
|
576
|
-
} : { left: I(A.t) }
|
|
577
|
-
}) : null,
|
|
578
|
-
R && K && x != null ? /* @__PURE__ */ o(i, { children: [/* @__PURE__ */ a("div", {
|
|
579
|
-
role: "button",
|
|
580
|
-
tabIndex: 0,
|
|
581
|
-
"aria-label": `${t.label} bezier handle 1`,
|
|
582
|
-
"data-testid": "timeline-bezier-handle",
|
|
583
|
-
className: b.bezierHandle,
|
|
584
|
-
style: q(x, K[0], K[1]),
|
|
585
|
-
onPointerDown: Y(x, 0)
|
|
586
|
-
}), /* @__PURE__ */ a("div", {
|
|
587
|
-
role: "button",
|
|
588
|
-
tabIndex: 0,
|
|
589
|
-
"aria-label": `${t.label} bezier handle 2`,
|
|
590
|
-
"data-testid": "timeline-bezier-handle",
|
|
591
|
-
className: b.bezierHandle,
|
|
592
|
-
style: q(x, K[2], K[3]),
|
|
593
|
-
onPointerDown: Y(x, 1)
|
|
594
|
-
})] }) : null
|
|
595
|
-
]
|
|
596
|
-
})]
|
|
597
|
-
});
|
|
598
|
-
}
|
|
599
|
-
//#endregion
|
|
600
|
-
//#region src/components/Timeline/Ruler.tsx
|
|
601
|
-
var Q = 64, le = .0015;
|
|
602
|
-
function ue(e) {
|
|
603
|
-
return e >= 1e3 ? `${(e / 1e3).toFixed(e % 1e3 == 0 ? 0 : 2)}s` : `${Math.round(e)}ms`;
|
|
604
|
-
}
|
|
605
|
-
function de(e) {
|
|
606
|
-
let { window: t, bounds: n, playhead: r, onScrub: i, onWindowChange: s } = e, c = v(null), u = v(null);
|
|
607
|
-
m(() => () => {
|
|
608
|
-
u.current?.cancel();
|
|
609
|
-
}, []);
|
|
610
|
-
let [d, f] = y(0);
|
|
611
|
-
h(() => {
|
|
612
|
-
let e = c.current;
|
|
613
|
-
if (!e) return;
|
|
614
|
-
let t = () => f(e.getBoundingClientRect().width);
|
|
615
|
-
if (t(), typeof ResizeObserver > "u") return;
|
|
616
|
-
let n = new ResizeObserver(t);
|
|
617
|
-
return n.observe(e), () => n.disconnect();
|
|
618
|
-
}, []);
|
|
619
|
-
let p = () => c.current?.getBoundingClientRect().width ?? 0, g = (e) => {
|
|
620
|
-
let n = c.current?.getBoundingClientRect();
|
|
621
|
-
if (!n) return t.from;
|
|
622
|
-
let r = j(t, n.width).toMs(e - n.left);
|
|
623
|
-
return Math.min(t.to, Math.max(t.from, r));
|
|
624
|
-
}, _ = (e) => {
|
|
625
|
-
if (e.button !== 0) return;
|
|
626
|
-
i(g(e.clientX)), u.current?.cancel();
|
|
627
|
-
let t = () => {
|
|
628
|
-
u.current = null;
|
|
629
|
-
};
|
|
630
|
-
u.current = l(e.currentTarget, e, {
|
|
631
|
-
onMove: (e) => {
|
|
632
|
-
i(g(e.clientX));
|
|
633
|
-
},
|
|
634
|
-
onEnd: t,
|
|
635
|
-
onCancel: t
|
|
636
|
-
}, { capture: !1 });
|
|
637
|
-
}, x = (e) => {
|
|
638
|
-
if (e.ctrlKey) s(L(t, g(e.clientX), Math.exp(e.deltaY * le), n));
|
|
639
|
-
else {
|
|
640
|
-
let r = p(), i = r === 0 ? 0 : (t.to - t.from) / r;
|
|
641
|
-
s(ee(t, e.deltaY * i, n));
|
|
642
|
-
}
|
|
643
|
-
}, S = z(t, d, Q), C = (e) => N(t, e);
|
|
644
|
-
return /* @__PURE__ */ o("div", {
|
|
645
|
-
className: b.ruler,
|
|
646
|
-
ref: c,
|
|
647
|
-
"data-testid": "timeline-ruler",
|
|
648
|
-
onPointerDown: _,
|
|
649
|
-
onWheel: x,
|
|
650
|
-
children: [S.map((e) => /* @__PURE__ */ a("span", {
|
|
651
|
-
className: b.tick,
|
|
652
|
-
"data-testid": "timeline-tick",
|
|
653
|
-
style: { left: C(e) },
|
|
654
|
-
children: ue(e)
|
|
655
|
-
}, e)), /* @__PURE__ */ a("div", {
|
|
656
|
-
className: b.playhead,
|
|
657
|
-
"data-testid": "timeline-playhead",
|
|
658
|
-
style: { left: C(r) }
|
|
659
|
-
})]
|
|
660
|
-
});
|
|
661
|
-
}
|
|
662
|
-
//#endregion
|
|
663
|
-
//#region src/components/Timeline/Transport.tsx
|
|
664
|
-
var $ = [
|
|
665
|
-
.25,
|
|
666
|
-
.5,
|
|
667
|
-
1,
|
|
668
|
-
2,
|
|
669
|
-
4
|
|
670
|
-
], fe = (e) => `${(e / 1e3).toFixed(2)}s`;
|
|
671
|
-
function pe(n) {
|
|
672
|
-
let { paused: i, loop: s, rate: c, playhead: l, duration: u, onPlay: d, onPause: f, onLoopChange: p, onRateChange: m } = n, h = s !== !1 && s !== 0, g = $.includes(c) ? $ : [...$, c].sort((e, t) => e - t);
|
|
673
|
-
return /* @__PURE__ */ o("div", {
|
|
674
|
-
className: b.transport,
|
|
675
|
-
children: [
|
|
676
|
-
/* @__PURE__ */ a("button", {
|
|
677
|
-
type: "button",
|
|
678
|
-
className: b.transportButton,
|
|
679
|
-
"aria-label": i ? "Play" : "Pause",
|
|
680
|
-
onClick: i ? d : f,
|
|
681
|
-
children: a(i ? e : t, { size: 14 })
|
|
682
|
-
}),
|
|
683
|
-
/* @__PURE__ */ o("span", {
|
|
684
|
-
className: b.time,
|
|
685
|
-
"data-testid": "timeline-time",
|
|
686
|
-
children: [
|
|
687
|
-
fe(l),
|
|
688
|
-
" / ",
|
|
689
|
-
fe(u)
|
|
690
|
-
]
|
|
691
|
-
}),
|
|
692
|
-
/* @__PURE__ */ a("button", {
|
|
693
|
-
type: "button",
|
|
694
|
-
role: "switch",
|
|
695
|
-
"aria-checked": h,
|
|
696
|
-
"aria-label": "Loop",
|
|
697
|
-
className: b.transportButton,
|
|
698
|
-
onClick: () => p(!h),
|
|
699
|
-
children: "⟲"
|
|
700
|
-
}),
|
|
701
|
-
/* @__PURE__ */ o("div", {
|
|
702
|
-
className: b.rate,
|
|
703
|
-
children: [
|
|
704
|
-
"Rate",
|
|
705
|
-
/* @__PURE__ */ a(r, {
|
|
706
|
-
ariaLabel: "Rate",
|
|
707
|
-
items: g,
|
|
708
|
-
value: c,
|
|
709
|
-
onChange: m,
|
|
710
|
-
formatLabel: (e) => `${e}x`,
|
|
711
|
-
labels: "none",
|
|
712
|
-
className: b.rateSlider
|
|
713
|
-
}),
|
|
714
|
-
/* @__PURE__ */ o("span", {
|
|
715
|
-
className: b.rateReadout,
|
|
716
|
-
children: [c, "x"]
|
|
717
|
-
})
|
|
718
|
-
]
|
|
719
|
-
})
|
|
720
|
-
]
|
|
721
|
-
});
|
|
722
|
-
}
|
|
723
|
-
//#endregion
|
|
724
|
-
//#region src/components/Timeline/Timeline.tsx
|
|
725
|
-
function me(e) {
|
|
726
|
-
let { tracks: t, duration: n, playhead: r, onInput: i, onChange: s, onScrub: c, renderKeyEditor: l, label: u, className: d } = e, [f, p] = y(() => /* @__PURE__ */ new Set()), [m, h] = y({
|
|
727
|
-
from: 0,
|
|
728
|
-
to: n
|
|
729
|
-
}), [_, v] = y(null), [x, S] = y(null), C = e.window ?? m, w = e.onWindowChange ?? h, T = e.selection === void 0 ? _ : e.selection, E = e.onSelect ?? v, D = {
|
|
730
|
-
from: 0,
|
|
731
|
-
to: n
|
|
732
|
-
}, O = g(() => V(t, f), [t, f]), A = g(() => {
|
|
733
|
-
let e = new Set([0, n]);
|
|
734
|
-
for (let t of O) if (t.kind === "sampled") for (let n of t.track.keys) e.add(n.t + t.offset);
|
|
735
|
-
return [...e];
|
|
736
|
-
}, [O, n]), j = (e) => {
|
|
737
|
-
p((t) => {
|
|
738
|
-
let n = new Set(t);
|
|
739
|
-
return n.has(e) ? n.delete(e) : n.add(e), n;
|
|
740
|
-
});
|
|
741
|
-
}, M = (e) => {
|
|
742
|
-
if ((e.key === "Delete" || e.key === "Backspace") && T) {
|
|
743
|
-
e.preventDefault();
|
|
744
|
-
let n = J(t, T);
|
|
745
|
-
s(n.tracks), E(n.selection);
|
|
746
|
-
}
|
|
747
|
-
}, N = T ? H(t, T.trackPath) : void 0, P = N?.kind === "sampled" ? N.keys[T.keyIndex] : void 0, F = x ? H(t, x.trackPath) : void 0, I = F?.kind === "sampled" ? F.keys[x.keyIndex] : void 0;
|
|
748
|
-
return /* @__PURE__ */ o("div", {
|
|
749
|
-
className: [b.root, d].filter(Boolean).join(" "),
|
|
750
|
-
"data-testid": "timeline-root",
|
|
751
|
-
tabIndex: -1,
|
|
752
|
-
onKeyDown: M,
|
|
753
|
-
children: [
|
|
754
|
-
u ? /* @__PURE__ */ a("div", {
|
|
755
|
-
className: b.label,
|
|
756
|
-
children: u
|
|
757
|
-
}) : null,
|
|
758
|
-
e.transport === !1 ? null : /* @__PURE__ */ o("div", {
|
|
759
|
-
className: b.transportRow,
|
|
760
|
-
children: [/* @__PURE__ */ a(pe, {
|
|
761
|
-
...e.transport ?? {
|
|
762
|
-
paused: !0,
|
|
763
|
-
loop: !1,
|
|
764
|
-
rate: 1,
|
|
765
|
-
onPlay: () => {},
|
|
766
|
-
onPause: () => {},
|
|
767
|
-
onLoopChange: () => {},
|
|
768
|
-
onRateChange: () => {}
|
|
769
|
-
},
|
|
770
|
-
playhead: r,
|
|
771
|
-
duration: n
|
|
772
|
-
}), /* @__PURE__ */ a("button", {
|
|
773
|
-
type: "button",
|
|
774
|
-
role: "switch",
|
|
775
|
-
"aria-checked": (e.mode ?? "dope") === "graph",
|
|
776
|
-
"aria-label": "Graph mode",
|
|
777
|
-
className: b.transportButton,
|
|
778
|
-
onClick: () => e.onModeChange?.((e.mode ?? "dope") === "graph" ? "dope" : "graph"),
|
|
779
|
-
children: "Graph"
|
|
780
|
-
})]
|
|
781
|
-
}),
|
|
782
|
-
/* @__PURE__ */ o("div", {
|
|
783
|
-
className: b.body,
|
|
784
|
-
children: [/* @__PURE__ */ a("div", { className: b.gutter }), /* @__PURE__ */ a("div", {
|
|
785
|
-
className: b.rulerWrap,
|
|
786
|
-
children: /* @__PURE__ */ a(de, {
|
|
787
|
-
window: C,
|
|
788
|
-
bounds: D,
|
|
789
|
-
playhead: r,
|
|
790
|
-
onScrub: c,
|
|
791
|
-
onWindowChange: w
|
|
792
|
-
})
|
|
793
|
-
})]
|
|
794
|
-
}),
|
|
795
|
-
/* @__PURE__ */ a("div", {
|
|
796
|
-
className: b.lanes,
|
|
797
|
-
children: O.map((n) => {
|
|
798
|
-
let r = n.path;
|
|
799
|
-
return /* @__PURE__ */ a(ce, {
|
|
800
|
-
row: n,
|
|
801
|
-
window: C,
|
|
802
|
-
mode: e.mode ?? "dope",
|
|
803
|
-
selection: T && U(T.trackPath, r) ? T.keyIndex : null,
|
|
804
|
-
expanded: f.has(n.key),
|
|
805
|
-
snapTimes: A,
|
|
806
|
-
onToggleExpand: () => j(n.key),
|
|
807
|
-
onSelect: (e) => E({
|
|
808
|
-
trackPath: r,
|
|
809
|
-
keyIndex: e
|
|
810
|
-
}),
|
|
811
|
-
onKeyInput: (e, n, a) => {
|
|
812
|
-
if (!i) return;
|
|
813
|
-
let o = K(t, {
|
|
814
|
-
trackPath: r,
|
|
815
|
-
keyIndex: e
|
|
816
|
-
}, n);
|
|
817
|
-
i(a === void 0 ? o.tracks : X(o.tracks, o.selection, a));
|
|
818
|
-
},
|
|
819
|
-
onKeyCommit: (e, n, i) => {
|
|
820
|
-
let a = K(t, {
|
|
821
|
-
trackPath: r,
|
|
822
|
-
keyIndex: e
|
|
823
|
-
}, n);
|
|
824
|
-
s(i === void 0 ? a.tracks : X(a.tracks, a.selection, i)), E(a.selection);
|
|
825
|
-
},
|
|
826
|
-
onInsert: (e) => {
|
|
827
|
-
let n = q(t, r, e);
|
|
828
|
-
s(n.tracks), E(n.selection);
|
|
829
|
-
},
|
|
830
|
-
selectedSegment: x && U(x.trackPath, r) ? x.keyIndex : null,
|
|
831
|
-
onSelectSegment: (e) => S({
|
|
832
|
-
trackPath: r,
|
|
833
|
-
keyIndex: e
|
|
834
|
-
}),
|
|
835
|
-
onEasingCommit: (e, n) => {
|
|
836
|
-
s(Y(t, {
|
|
837
|
-
trackPath: r,
|
|
838
|
-
keyIndex: e
|
|
839
|
-
}, n));
|
|
840
|
-
}
|
|
841
|
-
}, n.key);
|
|
842
|
-
})
|
|
843
|
-
}),
|
|
844
|
-
l && T && P && N?.kind === "sampled" ? /* @__PURE__ */ a("div", {
|
|
845
|
-
className: b.inspector,
|
|
846
|
-
children: l({
|
|
847
|
-
key: P,
|
|
848
|
-
track: N,
|
|
849
|
-
selection: T,
|
|
850
|
-
commit: (e) => s(X(t, T, e.value)),
|
|
851
|
-
setEasing: (e) => s(Y(t, T, e))
|
|
852
|
-
})
|
|
853
|
-
}) : null,
|
|
854
|
-
x && I ? /* @__PURE__ */ a("div", {
|
|
855
|
-
className: b.inspector,
|
|
856
|
-
children: /* @__PURE__ */ a(k, {
|
|
857
|
-
value: I.easing,
|
|
858
|
-
onChange: (e) => s(Y(t, x, e))
|
|
859
|
-
})
|
|
860
|
-
}) : null
|
|
861
|
-
]
|
|
862
|
-
});
|
|
863
|
-
}
|
|
864
|
-
//#endregion
|
|
865
|
-
//#region src/components/Timeline/AnimatedTimeline.tsx
|
|
866
|
-
function he(e) {
|
|
867
|
-
let { handle: t, ...n } = e, [, r] = _((e) => e + 1, 0);
|
|
868
|
-
m(() => t.subscribe(r), [t]);
|
|
869
|
-
let i = v(null), o = f(() => {
|
|
870
|
-
r(), t.isPaused() || i.current?.request();
|
|
871
|
-
});
|
|
872
|
-
i.current = o, m(() => (t.isPaused() || o.request(), () => o.cancel()), [t, o]);
|
|
873
|
-
let s = p((e) => {
|
|
874
|
-
t.edit(() => {
|
|
875
|
-
let n = t.tracks();
|
|
876
|
-
n.splice(0, n.length, ...e);
|
|
877
|
-
});
|
|
878
|
-
}, [t]), c = t.time(), l = t.duration();
|
|
879
|
-
return /* @__PURE__ */ a(me, {
|
|
880
|
-
...n,
|
|
881
|
-
tracks: t.tracks(),
|
|
882
|
-
duration: l,
|
|
883
|
-
playhead: c,
|
|
884
|
-
onChange: s,
|
|
885
|
-
onScrub: t.seek,
|
|
886
|
-
transport: e.transport === !1 ? !1 : {
|
|
887
|
-
paused: t.isPaused(),
|
|
888
|
-
loop: t.loop(),
|
|
889
|
-
rate: t.timeScale(),
|
|
890
|
-
onPlay: () => {
|
|
891
|
-
t.time() >= l && t.seek(0), t.resume(), o.request(), r();
|
|
892
|
-
},
|
|
893
|
-
onPause: () => {
|
|
894
|
-
t.pause(), r();
|
|
895
|
-
},
|
|
896
|
-
onLoopChange: (e) => {
|
|
897
|
-
t.setLoop(e), r();
|
|
898
|
-
},
|
|
899
|
-
onRateChange: (e) => {
|
|
900
|
-
t.setTimeScale(e), r();
|
|
901
|
-
}
|
|
902
|
-
}
|
|
903
|
-
});
|
|
904
|
-
}
|
|
905
|
-
//#endregion
|
|
906
|
-
export { k as a, C as c, U as i, w as l, me as n, T as o, pe as r, S as s, he as t };
|
|
907
|
-
|
|
908
|
-
//# sourceMappingURL=Timeline-Bz806JbE.js.map
|