@pixerate/editor-react 0.154.0 → 0.156.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/animation-editor/ShotCameraMoves.d.cts +14 -0
- package/dist/animation-editor/ShotCameraMoves.d.ts +14 -0
- package/dist/animation-editor/ShotInspector.d.cts +2 -2
- package/dist/animation-editor/ShotInspector.d.ts +2 -2
- package/dist/animation-editor/index.cjs +516 -387
- package/dist/animation-editor/index.d.cts +1 -0
- package/dist/animation-editor/index.d.ts +1 -0
- package/dist/animation-editor/index.js +238 -112
- package/dist/video-editor/ClipCameraMoves.d.cts +15 -0
- package/dist/video-editor/ClipCameraMoves.d.ts +15 -0
- package/dist/video-editor/ClipInspector.d.cts +2 -2
- package/dist/video-editor/ClipInspector.d.ts +2 -2
- package/dist/video-editor/index.cjs +3131 -2977
- package/dist/video-editor/index.d.cts +1 -0
- package/dist/video-editor/index.d.ts +1 -0
- package/dist/video-editor/index.js +392 -241
- package/package.json +3 -3
|
@@ -40,6 +40,7 @@ __export(animation_editor_exports, {
|
|
|
40
40
|
EasePicker: () => EasePicker,
|
|
41
41
|
PlayheadScrubber: () => PlayheadScrubber,
|
|
42
42
|
SceneSettings: () => SceneSettings,
|
|
43
|
+
ShotCameraMoves: () => ShotCameraMoves,
|
|
43
44
|
ShotInspector: () => ShotInspector,
|
|
44
45
|
ShotTimeline: () => ShotTimeline,
|
|
45
46
|
useAnimationEditor: () => useAnimationEditor,
|
|
@@ -120,13 +121,17 @@ function AnimationStage({ controller, values, onionSkin, motionPaths, onPick, hi
|
|
|
120
121
|
controller.toSvg(time, { pretty: false, idPrefix: "ae-", values, onionSkin, motionPaths }).replace(/<svg ([^>]*?)width="[^"]*" height="[^"]*"/, '<svg $1width="100%" height="100%"'),
|
|
121
122
|
highlight ?? []
|
|
122
123
|
),
|
|
123
|
-
[controller, scene, time, samples, values, onionSkin, motionPaths, key]
|
|
124
|
+
[controller, scene, time, samples, values, onionSkin, motionPaths, key, state.effectsProvider]
|
|
124
125
|
);
|
|
126
|
+
const stageRef = (0, import_react2.useRef)(null);
|
|
127
|
+
const view = (0, import_react2.useMemo)(() => (0, import_animation_editor2.motionCameraViewAt)(controller.viewScene(), time, state.effectsProvider), [controller, scene, time, samples, state.effectsProvider]);
|
|
128
|
+
const transform = (0, import_animation_editor2.motionCameraTransform)(view, stageRef.current?.clientWidth || scene.artwork.width);
|
|
125
129
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
126
130
|
"div",
|
|
127
131
|
{
|
|
132
|
+
ref: stageRef,
|
|
128
133
|
className: `relative overflow-hidden ${recording ? "cursor-grab touch-none" : onPick ? "cursor-crosshair" : ""} ${className}`,
|
|
129
|
-
style: { aspectRatio: `${scene.artwork.width} / ${scene.artwork.height}
|
|
134
|
+
style: { aspectRatio: `${scene.artwork.width} / ${scene.artwork.height}`, ...transform ? { transform } : {} },
|
|
130
135
|
"data-animation-stage": "",
|
|
131
136
|
"data-recording": recording ? "" : void 0,
|
|
132
137
|
role: "img",
|
|
@@ -222,7 +227,7 @@ function ShotTimeline({ controller, className = "" }) {
|
|
|
222
227
|
}
|
|
223
228
|
|
|
224
229
|
// src/animation-editor/AnimationEditor.tsx
|
|
225
|
-
var
|
|
230
|
+
var import_react23 = require("react");
|
|
226
231
|
|
|
227
232
|
// src/playback/AgentPlaybackContext.tsx
|
|
228
233
|
var import_react3 = require("react");
|
|
@@ -316,7 +321,7 @@ function PresenceLayer({ presence, viewport, clip = true, renderCursor, classNam
|
|
|
316
321
|
}
|
|
317
322
|
|
|
318
323
|
// src/animation-editor/AnimationEditor.tsx
|
|
319
|
-
var
|
|
324
|
+
var import_animation_editor12 = require("@pixerate/editor/animation-editor");
|
|
320
325
|
|
|
321
326
|
// src/animation-editor/AnimationRecordPanel.tsx
|
|
322
327
|
var import_animation_editor3 = require("@pixerate/editor/animation-editor");
|
|
@@ -1031,128 +1036,25 @@ function SceneSettings({ controller, className = "" }) {
|
|
|
1031
1036
|
}
|
|
1032
1037
|
|
|
1033
1038
|
// src/animation-editor/ShotInspector.tsx
|
|
1034
|
-
var
|
|
1039
|
+
var import_react21 = require("react");
|
|
1040
|
+
var import_animation_editor10 = require("@pixerate/editor/animation-editor");
|
|
1041
|
+
|
|
1042
|
+
// src/animation-editor/ShotCameraMoves.tsx
|
|
1043
|
+
var import_react20 = __toESM(require("react"), 1);
|
|
1035
1044
|
var import_animation_editor9 = require("@pixerate/editor/animation-editor");
|
|
1036
|
-
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
1037
|
-
var input3 = "w-full min-w-0 rounded border border-border bg-transparent px-1 py-0.5 text-xs";
|
|
1038
|
-
var btn4 = "rounded border border-border px-1.5 py-0.5 text-[11px] disabled:opacity-40";
|
|
1039
|
-
function ShotInspector({ controller, shot, className = "" }) {
|
|
1040
|
-
const state = useAnimationEditorState(controller);
|
|
1041
|
-
const { scene, selection, readOnly, error } = state;
|
|
1042
|
-
const [local, setLocalState] = (0, import_react11.useState)(null);
|
|
1043
|
-
const setLocal = (text) => setLocalState(text ? { text, revision: state.revision } : null);
|
|
1044
|
-
const elements = (0, import_react11.useMemo)(() => (0, import_animation_editor9.describeMotionElements)(scene), [scene.artwork]);
|
|
1045
|
-
const cues = (0, import_react11.useMemo)(() => (0, import_animation_editor9.motionCueChoices)(scene), [scene]);
|
|
1046
|
-
const id = shot ?? selection?.shot ?? scene.shots[0]?.id;
|
|
1047
|
-
const index = scene.shots.findIndex((s) => s.id === id);
|
|
1048
|
-
const current = scene.shots[index];
|
|
1049
|
-
const apply = (edit, label) => {
|
|
1050
|
-
setLocal(null);
|
|
1051
|
-
return controller.apply(edit, label);
|
|
1052
|
-
};
|
|
1053
|
-
const addShot = () => {
|
|
1054
|
-
const newId = (0, import_animation_editor9.freshShotId)(scene, "shot");
|
|
1055
|
-
const at = index >= 0 ? index + 1 : scene.shots.length;
|
|
1056
|
-
if (apply({ op: "insert_shots", shots: [{ id: newId, label: "New shot", run: [] }], at }, "Add shot").ok) {
|
|
1057
|
-
controller.select({ shot: newId });
|
|
1058
|
-
controller.seekShot(newId);
|
|
1059
|
-
}
|
|
1060
|
-
};
|
|
1061
|
-
const number = (key, raw, label) => {
|
|
1062
|
-
const n = Number(raw);
|
|
1063
|
-
if (raw.trim() === "") return apply({ op: "update_shot", shot: current.id, remove: [key] }, label);
|
|
1064
|
-
if (!Number.isFinite(n) || n < 0 || key === "speed" && n <= 0) return setLocal(key === "speed" ? "Speed must be a number above 0 (1 = as written)." : "Hold must be a number of ms, 0 or more.");
|
|
1065
|
-
apply({ op: "update_shot", shot: current.id, set: { [key]: n } }, label);
|
|
1066
|
-
};
|
|
1067
|
-
const message = (local && local.revision === state.revision ? local.text : null) ?? error;
|
|
1068
|
-
const cueKey = current ? (0, import_animation_editor9.motionCueKey)(current.at) : "";
|
|
1069
|
-
const frame = current?.camera && "frame" in current.camera ? current.camera.frame : "";
|
|
1070
|
-
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: `flex flex-col gap-1.5 text-xs ${className}`, "data-shot-inspector": "", children: [
|
|
1071
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
1072
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "font-medium", children: "Shot" }),
|
|
1073
|
-
current && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("code", { className: "text-[10px] text-muted-foreground", children: current.id }),
|
|
1074
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("span", { className: "ml-auto flex gap-0.5", children: [
|
|
1075
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("button", { type: "button", className: btn4, disabled: readOnly, onClick: addShot, "data-add-shot": "", children: "+ Shot" }),
|
|
1076
|
-
current && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
|
|
1077
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("button", { type: "button", className: btn4, "aria-label": "Move shot earlier", disabled: readOnly || index === 0, onClick: () => apply({ op: "move_shot", shot: current.id, to: index - 1 }, "Move shot"), children: "\u2190" }),
|
|
1078
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("button", { type: "button", className: btn4, "aria-label": "Move shot later", disabled: readOnly || index === scene.shots.length - 1, onClick: () => apply({ op: "move_shot", shot: current.id, to: index + 1 }, "Move shot"), children: "\u2192" }),
|
|
1079
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("button", { type: "button", className: btn4, "aria-label": "Delete shot", disabled: readOnly, onClick: () => apply({ op: "delete_shots", shots: [current.id] }, "Delete shot"), children: "\u2715" })
|
|
1080
|
-
] })
|
|
1081
|
-
] })
|
|
1082
|
-
] }),
|
|
1083
|
-
current && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "grid grid-cols-[6.5rem_1fr] items-center gap-x-2 gap-y-1", children: [
|
|
1084
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("label", { className: "text-muted-foreground", children: "Label" }),
|
|
1085
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(CommitInput, { className: input3, "aria-label": "Shot label", disabled: readOnly, value: current.label ?? "", onCommit: (raw) => apply(raw.trim() ? { op: "update_shot", shot: current.id, set: { label: raw.trim() } } : { op: "update_shot", shot: current.id, remove: ["label"] }, "Rename shot") }),
|
|
1086
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("label", { className: "text-muted-foreground", children: "Hold" }),
|
|
1087
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
1088
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(CommitInput, { className: input3, type: "number", min: 0, step: 50, "aria-label": "Hold", placeholder: "600", disabled: readOnly, value: current.hold !== void 0 ? String(current.hold) : "", onCommit: (raw) => number("hold", raw, "Change hold") }),
|
|
1089
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "text-[10px] text-muted-foreground", children: "ms" })
|
|
1090
|
-
] }),
|
|
1091
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("label", { className: "text-muted-foreground", children: "Speed" }),
|
|
1092
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
1093
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(CommitInput, { className: input3, type: "number", min: 0.05, step: 0.05, "aria-label": "Speed", placeholder: "1", disabled: readOnly, value: current.speed !== void 0 ? String(current.speed) : "", onCommit: (raw) => number("speed", raw, "Change speed") }),
|
|
1094
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "text-[10px] text-muted-foreground", children: "\xD7" })
|
|
1095
|
-
] }),
|
|
1096
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("label", { className: "text-muted-foreground", children: "Camera" }),
|
|
1097
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
1098
|
-
"select",
|
|
1099
|
-
{
|
|
1100
|
-
className: input3,
|
|
1101
|
-
"aria-label": "Camera frames",
|
|
1102
|
-
disabled: readOnly,
|
|
1103
|
-
value: current.camera ? frame ? `frame:${frame}` : "rect" : "",
|
|
1104
|
-
onChange: (e) => {
|
|
1105
|
-
const v = e.target.value;
|
|
1106
|
-
if (!v) apply({ op: "update_shot", shot: current.id, remove: ["camera"] }, "Clear camera");
|
|
1107
|
-
else if (v.startsWith("frame:")) apply({ op: "update_shot", shot: current.id, set: { camera: { frame: v.slice(6), padding: 24 } } }, "Frame camera");
|
|
1108
|
-
},
|
|
1109
|
-
children: [
|
|
1110
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("option", { value: "", children: "keep framing" }),
|
|
1111
|
-
current.camera && !frame && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("option", { value: "rect", children: "a rectangle" }),
|
|
1112
|
-
elements.map((e) => /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("option", { value: `frame:${e.id}`, children: [
|
|
1113
|
-
"frame ",
|
|
1114
|
-
e.name ?? e.id
|
|
1115
|
-
] }, e.id))
|
|
1116
|
-
]
|
|
1117
|
-
}
|
|
1118
|
-
),
|
|
1119
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("label", { className: "text-muted-foreground", children: "Starts on" }),
|
|
1120
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
1121
|
-
"select",
|
|
1122
|
-
{
|
|
1123
|
-
className: input3,
|
|
1124
|
-
"aria-label": "Cue",
|
|
1125
|
-
disabled: readOnly || index === 0,
|
|
1126
|
-
value: cueKey,
|
|
1127
|
-
onChange: (e) => {
|
|
1128
|
-
const cue = (0, import_animation_editor9.motionCueFromKey)(e.target.value);
|
|
1129
|
-
apply(cue ? { op: "update_shot", shot: current.id, set: { at: cue } } : { op: "update_shot", shot: current.id, remove: ["at"] }, "Cue shot");
|
|
1130
|
-
},
|
|
1131
|
-
children: [
|
|
1132
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("option", { value: "", children: "after the shot before" }),
|
|
1133
|
-
cueKey && !cues.some((c) => c.value === cueKey) && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("option", { value: cueKey, children: cueKey }),
|
|
1134
|
-
cues.map((c) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("option", { value: c.value, children: c.label }, c.value))
|
|
1135
|
-
]
|
|
1136
|
-
}
|
|
1137
|
-
),
|
|
1138
|
-
!cues.length && index > 0 && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { className: "col-span-2 text-[10px] text-muted-foreground", children: "Add a beat grid or narration in the scene settings to cue shots to them." })
|
|
1139
|
-
] }),
|
|
1140
|
-
message && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { className: "text-red-500", role: "alert", "data-edit-error": "", children: message })
|
|
1141
|
-
] });
|
|
1142
|
-
}
|
|
1143
1045
|
|
|
1144
1046
|
// src/effects/useEffects.ts
|
|
1145
|
-
var
|
|
1047
|
+
var import_react11 = require("react");
|
|
1146
1048
|
function useEffects(host, provider) {
|
|
1147
|
-
(0,
|
|
1049
|
+
(0, import_react11.useEffect)(() => {
|
|
1148
1050
|
if (!host || !provider) return;
|
|
1149
1051
|
return host.useEffects(provider);
|
|
1150
1052
|
}, [host, provider]);
|
|
1151
1053
|
}
|
|
1152
1054
|
function useEffectDescription(provider, effect) {
|
|
1153
|
-
const [state, setState] = (0,
|
|
1055
|
+
const [state, setState] = (0, import_react11.useState)({ key: "", description: null, error: null });
|
|
1154
1056
|
const key = provider && effect ? `${provider.id}:${effect}` : "";
|
|
1155
|
-
(0,
|
|
1057
|
+
(0, import_react11.useEffect)(() => {
|
|
1156
1058
|
if (!provider || !effect) return;
|
|
1157
1059
|
let live = true;
|
|
1158
1060
|
Promise.resolve().then(() => provider.describe(effect)).then(
|
|
@@ -1167,14 +1069,14 @@ function useEffectDescription(provider, effect) {
|
|
|
1167
1069
|
}
|
|
1168
1070
|
|
|
1169
1071
|
// src/effects/EffectThumbnail.tsx
|
|
1170
|
-
var
|
|
1072
|
+
var import_react12 = require("react");
|
|
1171
1073
|
var import_effects = require("@pixerate/editor/effects");
|
|
1172
|
-
var
|
|
1074
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
1173
1075
|
var LABELS = { motion: "Motion", camera: "Camera" };
|
|
1174
1076
|
function EffectThumbnail({ provider, effect, width = 96, height = 54, className = "" }) {
|
|
1175
|
-
const ref = (0,
|
|
1176
|
-
const [failed, setFailed] = (0,
|
|
1177
|
-
(0,
|
|
1077
|
+
const ref = (0, import_react12.useRef)(null);
|
|
1078
|
+
const [failed, setFailed] = (0, import_react12.useState)(effect.kind in LABELS);
|
|
1079
|
+
(0, import_react12.useEffect)(() => {
|
|
1178
1080
|
if (effect.kind in LABELS) return;
|
|
1179
1081
|
let live = true;
|
|
1180
1082
|
(0, import_effects.renderEffectThumbnail)(provider, effect, { width, height }).then(
|
|
@@ -1189,28 +1091,28 @@ function EffectThumbnail({ provider, effect, width = 96, height = 54, className
|
|
|
1189
1091
|
live = false;
|
|
1190
1092
|
};
|
|
1191
1093
|
}, [provider, effect, width, height]);
|
|
1192
|
-
return /* @__PURE__ */ (0,
|
|
1094
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1193
1095
|
"div",
|
|
1194
1096
|
{
|
|
1195
1097
|
className: `relative overflow-hidden rounded border border-border bg-[repeating-conic-gradient(#8884_0_25%,transparent_0_50%)] bg-[length:12px_12px] ${className}`,
|
|
1196
1098
|
style: { aspectRatio: `${width} / ${height}` },
|
|
1197
1099
|
"data-effect-thumbnail": effect.id,
|
|
1198
|
-
children: failed ? /* @__PURE__ */ (0,
|
|
1100
|
+
children: failed ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "absolute inset-0 flex items-center justify-center text-[10px] text-muted-foreground", children: LABELS[effect.kind] ?? "No preview" }) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("canvas", { ref, width, height, className: "h-full w-full", "aria-hidden": "true" })
|
|
1199
1101
|
}
|
|
1200
1102
|
);
|
|
1201
1103
|
}
|
|
1202
1104
|
|
|
1203
1105
|
// src/effects/EffectsBrowser.tsx
|
|
1204
|
-
var
|
|
1106
|
+
var import_react13 = require("react");
|
|
1205
1107
|
var import_effects2 = require("@pixerate/editor/effects");
|
|
1206
|
-
var
|
|
1108
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
1207
1109
|
function EffectsBrowser({ provider, uses, kinds, onPick, thumbnails = true, title = "Effects", className = "" }) {
|
|
1208
|
-
const [all, setAll] = (0,
|
|
1209
|
-
const [query, setQuery] = (0,
|
|
1210
|
-
const [category, setCategory] = (0,
|
|
1211
|
-
const [use, setUse] = (0,
|
|
1212
|
-
const [error, setError] = (0,
|
|
1213
|
-
(0,
|
|
1110
|
+
const [all, setAll] = (0, import_react13.useState)([]);
|
|
1111
|
+
const [query, setQuery] = (0, import_react13.useState)("");
|
|
1112
|
+
const [category, setCategory] = (0, import_react13.useState)("");
|
|
1113
|
+
const [use, setUse] = (0, import_react13.useState)("");
|
|
1114
|
+
const [error, setError] = (0, import_react13.useState)(null);
|
|
1115
|
+
(0, import_react13.useEffect)(() => {
|
|
1214
1116
|
if (!provider) return setAll([]);
|
|
1215
1117
|
let live = true;
|
|
1216
1118
|
Promise.resolve().then(() => provider.list()).then(
|
|
@@ -1221,8 +1123,8 @@ function EffectsBrowser({ provider, uses, kinds, onPick, thumbnails = true, titl
|
|
|
1221
1123
|
live = false;
|
|
1222
1124
|
};
|
|
1223
1125
|
}, [provider]);
|
|
1224
|
-
const [found, setFound] = (0,
|
|
1225
|
-
(0,
|
|
1126
|
+
const [found, setFound] = (0, import_react13.useState)([]);
|
|
1127
|
+
(0, import_react13.useEffect)(() => {
|
|
1226
1128
|
if (!provider) return setFound([]);
|
|
1227
1129
|
let live = true;
|
|
1228
1130
|
Promise.resolve().then(() => provider.search(query, { ...category ? { category } : {}, ...use ? { use } : {} })).then((list) => live && setFound(list), () => live && setFound([]));
|
|
@@ -1231,14 +1133,14 @@ function EffectsBrowser({ provider, uses, kinds, onPick, thumbnails = true, titl
|
|
|
1231
1133
|
};
|
|
1232
1134
|
}, [provider, query, category, use]);
|
|
1233
1135
|
const allowed = (e) => (!kinds || kinds.includes(e.kind)) && (0, import_effects2.effectOffered)(e, uses);
|
|
1234
|
-
const categories = (0,
|
|
1136
|
+
const categories = (0, import_react13.useMemo)(() => [...new Set(all.filter(allowed).map((e) => e.category))], [all, uses, kinds]);
|
|
1235
1137
|
const shown = found.filter(allowed);
|
|
1236
1138
|
if (!provider)
|
|
1237
|
-
return /* @__PURE__ */ (0,
|
|
1238
|
-
return /* @__PURE__ */ (0,
|
|
1239
|
-
title && /* @__PURE__ */ (0,
|
|
1240
|
-
/* @__PURE__ */ (0,
|
|
1241
|
-
/* @__PURE__ */ (0,
|
|
1139
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: `rounded-md border border-dashed border-border p-3 text-xs text-muted-foreground ${className}`, "data-effects-browser": "", "data-effects-unavailable": "", children: "No effects provider is registered, so effects cannot be added. Effects already in the document are kept." });
|
|
1140
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("section", { className: `flex flex-col gap-2 ${className}`, "data-effects-browser": "", "aria-label": "Effects browser", children: [
|
|
1141
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("h3", { className: "text-xs font-semibold", children: title }),
|
|
1142
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex flex-wrap gap-1", children: [
|
|
1143
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1242
1144
|
"input",
|
|
1243
1145
|
{
|
|
1244
1146
|
type: "search",
|
|
@@ -1249,17 +1151,17 @@ function EffectsBrowser({ provider, uses, kinds, onPick, thumbnails = true, titl
|
|
|
1249
1151
|
onChange: (e) => setQuery(e.currentTarget.value)
|
|
1250
1152
|
}
|
|
1251
1153
|
),
|
|
1252
|
-
/* @__PURE__ */ (0,
|
|
1253
|
-
/* @__PURE__ */ (0,
|
|
1254
|
-
categories.map((c) => /* @__PURE__ */ (0,
|
|
1154
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("select", { className: "rounded border border-border bg-transparent px-1 py-0.5 text-xs", "aria-label": "Category", value: category, onChange: (e) => setCategory(e.currentTarget.value), children: [
|
|
1155
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("option", { value: "", children: "All categories" }),
|
|
1156
|
+
categories.map((c) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("option", { value: c, children: c }, c))
|
|
1255
1157
|
] }),
|
|
1256
|
-
uses && uses.length > 1 && /* @__PURE__ */ (0,
|
|
1257
|
-
/* @__PURE__ */ (0,
|
|
1258
|
-
uses.map((u) => /* @__PURE__ */ (0,
|
|
1158
|
+
uses && uses.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("select", { className: "rounded border border-border bg-transparent px-1 py-0.5 text-xs", "aria-label": "Use", value: use, onChange: (e) => setUse(e.currentTarget.value), children: [
|
|
1159
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("option", { value: "", children: "Any use" }),
|
|
1160
|
+
uses.map((u) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("option", { value: u, children: import_effects2.EFFECT_USE_LABELS[u] }, u))
|
|
1259
1161
|
] })
|
|
1260
1162
|
] }),
|
|
1261
|
-
error && /* @__PURE__ */ (0,
|
|
1262
|
-
/* @__PURE__ */ (0,
|
|
1163
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { role: "alert", className: "text-[11px] text-destructive", children: error }),
|
|
1164
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("ul", { className: "grid max-h-96 grid-cols-[repeat(auto-fill,minmax(6.5rem,1fr))] gap-1.5 overflow-y-auto", role: "list", children: shown.map((e) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
1263
1165
|
"button",
|
|
1264
1166
|
{
|
|
1265
1167
|
type: "button",
|
|
@@ -1268,23 +1170,23 @@ function EffectsBrowser({ provider, uses, kinds, onPick, thumbnails = true, titl
|
|
|
1268
1170
|
"data-effect-id": e.id,
|
|
1269
1171
|
onClick: () => onPick(e),
|
|
1270
1172
|
children: [
|
|
1271
|
-
thumbnails && /* @__PURE__ */ (0,
|
|
1272
|
-
/* @__PURE__ */ (0,
|
|
1273
|
-
/* @__PURE__ */ (0,
|
|
1173
|
+
thumbnails && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(EffectThumbnail, { provider, effect: e }),
|
|
1174
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "truncate text-[11px] font-medium", children: e.name }),
|
|
1175
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "truncate text-[10px] text-muted-foreground", children: e.uses.map((u) => import_effects2.EFFECT_USE_LABELS[u]).join(" \xB7 ") })
|
|
1274
1176
|
]
|
|
1275
1177
|
}
|
|
1276
1178
|
) }, e.id)) }),
|
|
1277
|
-
!shown.length && !error && /* @__PURE__ */ (0,
|
|
1179
|
+
!shown.length && !error && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No effects match." })
|
|
1278
1180
|
] });
|
|
1279
1181
|
}
|
|
1280
1182
|
|
|
1281
1183
|
// src/effects/EffectParameters.tsx
|
|
1282
|
-
var
|
|
1184
|
+
var import_react19 = __toESM(require("react"), 1);
|
|
1283
1185
|
var import_effects3 = require("@pixerate/editor/effects");
|
|
1284
1186
|
var import_parameters2 = require("@pixerate/editor/parameters");
|
|
1285
1187
|
|
|
1286
1188
|
// src/parameters/fields.tsx
|
|
1287
|
-
var
|
|
1189
|
+
var import_react18 = require("react");
|
|
1288
1190
|
var import_parameters = require("@pixerate/editor/parameters");
|
|
1289
1191
|
|
|
1290
1192
|
// src/color/index.ts
|
|
@@ -1297,9 +1199,9 @@ __export(color_exports, {
|
|
|
1297
1199
|
});
|
|
1298
1200
|
|
|
1299
1201
|
// src/color/ColorPicker.tsx
|
|
1300
|
-
var
|
|
1202
|
+
var import_react14 = require("react");
|
|
1301
1203
|
var import_color = require("@pixerate/editor/color");
|
|
1302
|
-
var
|
|
1204
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
1303
1205
|
var LOCAL_STORAGE_KEY = "pixerate:color:recent";
|
|
1304
1206
|
function readLocalRecents() {
|
|
1305
1207
|
try {
|
|
@@ -1337,24 +1239,24 @@ var ColorPicker = ({
|
|
|
1337
1239
|
id,
|
|
1338
1240
|
"aria-label": ariaLabel = "Color picker"
|
|
1339
1241
|
}) => {
|
|
1340
|
-
const generatedId = (0,
|
|
1242
|
+
const generatedId = (0, import_react14.useId)();
|
|
1341
1243
|
const pickerId = id || generatedId;
|
|
1342
|
-
const [pickerState, setPickerState] = (0,
|
|
1244
|
+
const [pickerState, setPickerState] = (0, import_react14.useState)(
|
|
1343
1245
|
() => (0, import_color.pickerStateFromColor)(value) ?? DEFAULT_PICKER_STATE
|
|
1344
1246
|
);
|
|
1345
|
-
const stateRef = (0,
|
|
1247
|
+
const stateRef = (0, import_react14.useRef)(pickerState);
|
|
1346
1248
|
stateRef.current = pickerState;
|
|
1347
|
-
(0,
|
|
1249
|
+
(0, import_react14.useEffect)(() => {
|
|
1348
1250
|
const next = (0, import_color.pickerStateFromColor)(value, stateRef.current);
|
|
1349
1251
|
if (next) {
|
|
1350
1252
|
setPickerState(next);
|
|
1351
1253
|
}
|
|
1352
1254
|
}, [value]);
|
|
1353
|
-
const [internalRecent, setInternalRecent] = (0,
|
|
1255
|
+
const [internalRecent, setInternalRecent] = (0, import_react14.useState)(
|
|
1354
1256
|
() => controlledRecent ? [] : readLocalRecents()
|
|
1355
1257
|
);
|
|
1356
1258
|
const activeRecent = controlledRecent ?? internalRecent;
|
|
1357
|
-
const recordRecent = (0,
|
|
1259
|
+
const recordRecent = (0, import_react14.useCallback)(
|
|
1358
1260
|
(color) => {
|
|
1359
1261
|
const updated = (0, import_color.pushRecentColor)(activeRecent, color, 12);
|
|
1360
1262
|
if (!controlledRecent) {
|
|
@@ -1365,11 +1267,11 @@ var ColorPicker = ({
|
|
|
1365
1267
|
},
|
|
1366
1268
|
[activeRecent, controlledRecent, onRecentChange]
|
|
1367
1269
|
);
|
|
1368
|
-
const [textDraft, setTextDraft] = (0,
|
|
1369
|
-
const [isInvalid, setIsInvalid] = (0,
|
|
1370
|
-
const [isClipped, setIsClipped] = (0,
|
|
1371
|
-
const isTypingRef = (0,
|
|
1372
|
-
(0,
|
|
1270
|
+
const [textDraft, setTextDraft] = (0, import_react14.useState)(value);
|
|
1271
|
+
const [isInvalid, setIsInvalid] = (0, import_react14.useState)(false);
|
|
1272
|
+
const [isClipped, setIsClipped] = (0, import_react14.useState)(false);
|
|
1273
|
+
const isTypingRef = (0, import_react14.useRef)(false);
|
|
1274
|
+
(0, import_react14.useEffect)(() => {
|
|
1373
1275
|
if (!isTypingRef.current) {
|
|
1374
1276
|
setTextDraft(value);
|
|
1375
1277
|
setIsInvalid(false);
|
|
@@ -1377,11 +1279,11 @@ var ColorPicker = ({
|
|
|
1377
1279
|
setIsClipped(Boolean(parsed && !(0, import_color.inSrgbGamut)(parsed)));
|
|
1378
1280
|
}
|
|
1379
1281
|
}, [value]);
|
|
1380
|
-
const [hasEyeDropper, setHasEyeDropper] = (0,
|
|
1381
|
-
(0,
|
|
1282
|
+
const [hasEyeDropper, setHasEyeDropper] = (0, import_react14.useState)(false);
|
|
1283
|
+
(0, import_react14.useEffect)(() => {
|
|
1382
1284
|
setHasEyeDropper(typeof window !== "undefined" && "EyeDropper" in window);
|
|
1383
1285
|
}, []);
|
|
1384
|
-
const emitColorChange = (0,
|
|
1286
|
+
const emitColorChange = (0, import_react14.useCallback)(
|
|
1385
1287
|
(nextState) => {
|
|
1386
1288
|
setPickerState(nextState);
|
|
1387
1289
|
const hex = (0, import_color.pickerStateToHex)(nextState, alpha);
|
|
@@ -1389,10 +1291,10 @@ var ColorPicker = ({
|
|
|
1389
1291
|
},
|
|
1390
1292
|
[alpha, onChange]
|
|
1391
1293
|
);
|
|
1392
|
-
const latest = (0,
|
|
1294
|
+
const latest = (0, import_react14.useRef)({ emitColorChange, recordRecent, onGestureEnd, alpha });
|
|
1393
1295
|
latest.current = { emitColorChange, recordRecent, onGestureEnd, alpha };
|
|
1394
|
-
const endDragRef = (0,
|
|
1395
|
-
(0,
|
|
1296
|
+
const endDragRef = (0, import_react14.useRef)(null);
|
|
1297
|
+
(0, import_react14.useEffect)(() => () => endDragRef.current?.(), []);
|
|
1396
1298
|
const startDrag = (e, next) => {
|
|
1397
1299
|
if (disabled) return;
|
|
1398
1300
|
e.preventDefault();
|
|
@@ -1494,7 +1396,7 @@ var ColorPicker = ({
|
|
|
1494
1396
|
} catch {
|
|
1495
1397
|
}
|
|
1496
1398
|
};
|
|
1497
|
-
const contrastResult = (0,
|
|
1399
|
+
const contrastResult = (0, import_react14.useMemo)(() => {
|
|
1498
1400
|
if (!contrastAgainst) return null;
|
|
1499
1401
|
const fg = (0, import_color.parseColor)(value);
|
|
1500
1402
|
const bg = (0, import_color.parseColor)(contrastAgainst);
|
|
@@ -1506,7 +1408,7 @@ var ColorPicker = ({
|
|
|
1506
1408
|
}, [value, contrastAgainst]);
|
|
1507
1409
|
const currentHex = (0, import_color.pickerStateToHex)(pickerState, alpha);
|
|
1508
1410
|
const liveDescription = `Selected color: ${value}${contrastResult ? `, contrast ${contrastResult.ratio.toFixed(1)}:1 against ${contrastAgainst}, ${contrastResult.aa ? "passes AA" : "fails AA"}` : ""}`;
|
|
1509
|
-
return /* @__PURE__ */ (0,
|
|
1411
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
1510
1412
|
"div",
|
|
1511
1413
|
{
|
|
1512
1414
|
id: pickerId,
|
|
@@ -1530,7 +1432,7 @@ var ColorPicker = ({
|
|
|
1530
1432
|
pointerEvents: disabled ? "none" : "auto"
|
|
1531
1433
|
},
|
|
1532
1434
|
children: [
|
|
1533
|
-
/* @__PURE__ */ (0,
|
|
1435
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1534
1436
|
"span",
|
|
1535
1437
|
{
|
|
1536
1438
|
role: "status",
|
|
@@ -1549,7 +1451,7 @@ var ColorPicker = ({
|
|
|
1549
1451
|
children: liveDescription
|
|
1550
1452
|
}
|
|
1551
1453
|
),
|
|
1552
|
-
/* @__PURE__ */ (0,
|
|
1454
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1553
1455
|
"div",
|
|
1554
1456
|
{
|
|
1555
1457
|
role: "slider",
|
|
@@ -1571,7 +1473,7 @@ var ColorPicker = ({
|
|
|
1571
1473
|
touchAction: "none",
|
|
1572
1474
|
outline: "none"
|
|
1573
1475
|
},
|
|
1574
|
-
children: /* @__PURE__ */ (0,
|
|
1476
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1575
1477
|
"div",
|
|
1576
1478
|
{
|
|
1577
1479
|
style: {
|
|
@@ -1591,7 +1493,7 @@ var ColorPicker = ({
|
|
|
1591
1493
|
)
|
|
1592
1494
|
}
|
|
1593
1495
|
),
|
|
1594
|
-
/* @__PURE__ */ (0,
|
|
1496
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1595
1497
|
"div",
|
|
1596
1498
|
{
|
|
1597
1499
|
role: "slider",
|
|
@@ -1614,7 +1516,7 @@ var ColorPicker = ({
|
|
|
1614
1516
|
touchAction: "none",
|
|
1615
1517
|
outline: "none"
|
|
1616
1518
|
},
|
|
1617
|
-
children: /* @__PURE__ */ (0,
|
|
1519
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1618
1520
|
"div",
|
|
1619
1521
|
{
|
|
1620
1522
|
style: {
|
|
@@ -1634,7 +1536,7 @@ var ColorPicker = ({
|
|
|
1634
1536
|
)
|
|
1635
1537
|
}
|
|
1636
1538
|
),
|
|
1637
|
-
alpha && /* @__PURE__ */ (0,
|
|
1539
|
+
alpha && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
1638
1540
|
"div",
|
|
1639
1541
|
{
|
|
1640
1542
|
role: "slider",
|
|
@@ -1660,7 +1562,7 @@ var ColorPicker = ({
|
|
|
1660
1562
|
overflow: "hidden"
|
|
1661
1563
|
},
|
|
1662
1564
|
children: [
|
|
1663
|
-
/* @__PURE__ */ (0,
|
|
1565
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1664
1566
|
"div",
|
|
1665
1567
|
{
|
|
1666
1568
|
style: {
|
|
@@ -1670,7 +1572,7 @@ var ColorPicker = ({
|
|
|
1670
1572
|
}
|
|
1671
1573
|
}
|
|
1672
1574
|
),
|
|
1673
|
-
/* @__PURE__ */ (0,
|
|
1575
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1674
1576
|
"div",
|
|
1675
1577
|
{
|
|
1676
1578
|
style: {
|
|
@@ -1691,8 +1593,8 @@ var ColorPicker = ({
|
|
|
1691
1593
|
]
|
|
1692
1594
|
}
|
|
1693
1595
|
),
|
|
1694
|
-
/* @__PURE__ */ (0,
|
|
1695
|
-
/* @__PURE__ */ (0,
|
|
1596
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "8px", marginTop: "2px" }, children: [
|
|
1597
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1696
1598
|
"div",
|
|
1697
1599
|
{
|
|
1698
1600
|
style: {
|
|
@@ -1706,7 +1608,7 @@ var ColorPicker = ({
|
|
|
1706
1608
|
flexShrink: 0,
|
|
1707
1609
|
border: "1px solid rgba(255,255,255,0.15)"
|
|
1708
1610
|
},
|
|
1709
|
-
children: /* @__PURE__ */ (0,
|
|
1611
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1710
1612
|
"div",
|
|
1711
1613
|
{
|
|
1712
1614
|
style: {
|
|
@@ -1718,7 +1620,7 @@ var ColorPicker = ({
|
|
|
1718
1620
|
)
|
|
1719
1621
|
}
|
|
1720
1622
|
),
|
|
1721
|
-
/* @__PURE__ */ (0,
|
|
1623
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1722
1624
|
"input",
|
|
1723
1625
|
{
|
|
1724
1626
|
type: "text",
|
|
@@ -1748,7 +1650,7 @@ var ColorPicker = ({
|
|
|
1748
1650
|
}
|
|
1749
1651
|
}
|
|
1750
1652
|
),
|
|
1751
|
-
hasEyeDropper && /* @__PURE__ */ (0,
|
|
1653
|
+
hasEyeDropper && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1752
1654
|
"button",
|
|
1753
1655
|
{
|
|
1754
1656
|
type: "button",
|
|
@@ -1768,7 +1670,7 @@ var ColorPicker = ({
|
|
|
1768
1670
|
color: "inherit",
|
|
1769
1671
|
cursor: disabled ? "default" : "pointer"
|
|
1770
1672
|
},
|
|
1771
|
-
children: /* @__PURE__ */ (0,
|
|
1673
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
1772
1674
|
"svg",
|
|
1773
1675
|
{
|
|
1774
1676
|
width: "14",
|
|
@@ -1780,16 +1682,16 @@ var ColorPicker = ({
|
|
|
1780
1682
|
strokeLinecap: "round",
|
|
1781
1683
|
strokeLinejoin: "round",
|
|
1782
1684
|
children: [
|
|
1783
|
-
/* @__PURE__ */ (0,
|
|
1784
|
-
/* @__PURE__ */ (0,
|
|
1785
|
-
/* @__PURE__ */ (0,
|
|
1685
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "m19 11-8-8-8.5 8.5a2.12 2.12 0 0 0 0 3l2.5 2.5 1.5-1.5" }),
|
|
1686
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "m5 16-3 3 1 1 3-3" }),
|
|
1687
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "m14 6 4 4" })
|
|
1786
1688
|
]
|
|
1787
1689
|
}
|
|
1788
1690
|
)
|
|
1789
1691
|
}
|
|
1790
1692
|
)
|
|
1791
1693
|
] }),
|
|
1792
|
-
isClipped && /* @__PURE__ */ (0,
|
|
1694
|
+
isClipped && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1793
1695
|
"div",
|
|
1794
1696
|
{
|
|
1795
1697
|
role: "note",
|
|
@@ -1805,10 +1707,10 @@ var ColorPicker = ({
|
|
|
1805
1707
|
borderRadius: "4px",
|
|
1806
1708
|
alignSelf: "flex-start"
|
|
1807
1709
|
},
|
|
1808
|
-
children: /* @__PURE__ */ (0,
|
|
1710
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { children: "\u26A0 Clipped to sRGB" })
|
|
1809
1711
|
}
|
|
1810
1712
|
),
|
|
1811
|
-
contrastResult && /* @__PURE__ */ (0,
|
|
1713
|
+
contrastResult && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
1812
1714
|
"div",
|
|
1813
1715
|
{
|
|
1814
1716
|
style: {
|
|
@@ -1822,15 +1724,15 @@ var ColorPicker = ({
|
|
|
1822
1724
|
border: "1px solid rgba(255,255,255,0.1)"
|
|
1823
1725
|
},
|
|
1824
1726
|
children: [
|
|
1825
|
-
/* @__PURE__ */ (0,
|
|
1727
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("span", { children: [
|
|
1826
1728
|
"Contrast: ",
|
|
1827
|
-
/* @__PURE__ */ (0,
|
|
1729
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("strong", { children: [
|
|
1828
1730
|
contrastResult.ratio.toFixed(2),
|
|
1829
1731
|
":1"
|
|
1830
1732
|
] })
|
|
1831
1733
|
] }),
|
|
1832
|
-
/* @__PURE__ */ (0,
|
|
1833
|
-
/* @__PURE__ */ (0,
|
|
1734
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { style: { display: "flex", gap: "6px" }, children: [
|
|
1735
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
1834
1736
|
"span",
|
|
1835
1737
|
{
|
|
1836
1738
|
style: {
|
|
@@ -1843,7 +1745,7 @@ var ColorPicker = ({
|
|
|
1843
1745
|
]
|
|
1844
1746
|
}
|
|
1845
1747
|
),
|
|
1846
|
-
/* @__PURE__ */ (0,
|
|
1748
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
1847
1749
|
"span",
|
|
1848
1750
|
{
|
|
1849
1751
|
style: {
|
|
@@ -1860,9 +1762,9 @@ var ColorPicker = ({
|
|
|
1860
1762
|
]
|
|
1861
1763
|
}
|
|
1862
1764
|
),
|
|
1863
|
-
swatches && swatches.length > 0 && /* @__PURE__ */ (0,
|
|
1864
|
-
/* @__PURE__ */ (0,
|
|
1865
|
-
/* @__PURE__ */ (0,
|
|
1765
|
+
swatches && swatches.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { style: { display: "flex", flexDirection: "column", gap: "4px" }, children: [
|
|
1766
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { style: { fontSize: "10px", textTransform: "uppercase", opacity: 0.6 }, children: "Palette" }),
|
|
1767
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { style: { display: "flex", flexWrap: "wrap", gap: "4px" }, children: swatches.map((color, idx) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1866
1768
|
"button",
|
|
1867
1769
|
{
|
|
1868
1770
|
type: "button",
|
|
@@ -1888,9 +1790,9 @@ var ColorPicker = ({
|
|
|
1888
1790
|
`${color}-${idx}`
|
|
1889
1791
|
)) })
|
|
1890
1792
|
] }),
|
|
1891
|
-
activeRecent.length > 0 && /* @__PURE__ */ (0,
|
|
1892
|
-
/* @__PURE__ */ (0,
|
|
1893
|
-
/* @__PURE__ */ (0,
|
|
1793
|
+
activeRecent.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { style: { display: "flex", flexDirection: "column", gap: "4px" }, children: [
|
|
1794
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { style: { fontSize: "10px", textTransform: "uppercase", opacity: 0.6 }, children: "Recent" }),
|
|
1795
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { style: { display: "flex", flexWrap: "wrap", gap: "4px" }, children: activeRecent.map((color, idx) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1894
1796
|
"button",
|
|
1895
1797
|
{
|
|
1896
1798
|
type: "button",
|
|
@@ -1921,9 +1823,9 @@ var ColorPicker = ({
|
|
|
1921
1823
|
};
|
|
1922
1824
|
|
|
1923
1825
|
// src/color/DualColorPicker.tsx
|
|
1924
|
-
var
|
|
1826
|
+
var import_react15 = require("react");
|
|
1925
1827
|
var import_color2 = require("@pixerate/editor/color");
|
|
1926
|
-
var
|
|
1828
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
1927
1829
|
function DualColorPicker({
|
|
1928
1830
|
value,
|
|
1929
1831
|
onChange,
|
|
@@ -1938,8 +1840,8 @@ function DualColorPicker({
|
|
|
1938
1840
|
disabled = false,
|
|
1939
1841
|
className = ""
|
|
1940
1842
|
}) {
|
|
1941
|
-
const sameId = (0,
|
|
1942
|
-
const [internalScheme, setInternalScheme] = (0,
|
|
1843
|
+
const sameId = (0, import_react15.useId)();
|
|
1844
|
+
const [internalScheme, setInternalScheme] = (0, import_react15.useState)("light");
|
|
1943
1845
|
const activeScheme = controlledScheme ?? internalScheme;
|
|
1944
1846
|
const handleSchemeSelect = (nextScheme) => {
|
|
1945
1847
|
if (onSchemeChange) {
|
|
@@ -1950,7 +1852,7 @@ function DualColorPicker({
|
|
|
1950
1852
|
};
|
|
1951
1853
|
const dual = (0, import_color2.normalizeDualColor)(value) ?? { light: "#000000", dark: "#000000" };
|
|
1952
1854
|
const isSame = dual.light.toLowerCase() === dual.dark.toLowerCase();
|
|
1953
|
-
const [sameInBoth, setSameInBoth] = (0,
|
|
1855
|
+
const [sameInBoth, setSameInBoth] = (0, import_react15.useState)(isSame);
|
|
1954
1856
|
const handleSameToggle = (e) => {
|
|
1955
1857
|
const nextSame = e.target.checked;
|
|
1956
1858
|
setSameInBoth(nextSame);
|
|
@@ -1982,7 +1884,7 @@ function DualColorPicker({
|
|
|
1982
1884
|
const activeColor = activeScheme === "dark" ? dual.dark : dual.light;
|
|
1983
1885
|
const activeContrastTarget = contrastAgainst ? (0, import_color2.resolveColor)(contrastAgainst, activeScheme) ?? void 0 : void 0;
|
|
1984
1886
|
const dualContrast = contrastAgainst && (0, import_color2.normalizeDualColor)(contrastAgainst) ? (0, import_color2.checkDualColorContrast)(dual, contrastAgainst) : null;
|
|
1985
|
-
return /* @__PURE__ */ (0,
|
|
1887
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
1986
1888
|
"div",
|
|
1987
1889
|
{
|
|
1988
1890
|
className: `pixerate-dual-color-picker ${className}`,
|
|
@@ -2001,7 +1903,7 @@ function DualColorPicker({
|
|
|
2001
1903
|
boxSizing: "border-box"
|
|
2002
1904
|
},
|
|
2003
1905
|
children: [
|
|
2004
|
-
/* @__PURE__ */ (0,
|
|
1906
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
2005
1907
|
"div",
|
|
2006
1908
|
{
|
|
2007
1909
|
role: "tablist",
|
|
@@ -2014,7 +1916,7 @@ function DualColorPicker({
|
|
|
2014
1916
|
gap: "2px"
|
|
2015
1917
|
},
|
|
2016
1918
|
children: [
|
|
2017
|
-
/* @__PURE__ */ (0,
|
|
1919
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2018
1920
|
"button",
|
|
2019
1921
|
{
|
|
2020
1922
|
type: "button",
|
|
@@ -2037,7 +1939,7 @@ function DualColorPicker({
|
|
|
2037
1939
|
children: "Light"
|
|
2038
1940
|
}
|
|
2039
1941
|
),
|
|
2040
|
-
/* @__PURE__ */ (0,
|
|
1942
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2041
1943
|
"button",
|
|
2042
1944
|
{
|
|
2043
1945
|
type: "button",
|
|
@@ -2063,8 +1965,8 @@ function DualColorPicker({
|
|
|
2063
1965
|
]
|
|
2064
1966
|
}
|
|
2065
1967
|
),
|
|
2066
|
-
/* @__PURE__ */ (0,
|
|
2067
|
-
/* @__PURE__ */ (0,
|
|
1968
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { style: { display: "flex", gap: "8px" }, children: [
|
|
1969
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
2068
1970
|
"button",
|
|
2069
1971
|
{
|
|
2070
1972
|
type: "button",
|
|
@@ -2086,7 +1988,7 @@ function DualColorPicker({
|
|
|
2086
1988
|
outline: "none"
|
|
2087
1989
|
},
|
|
2088
1990
|
children: [
|
|
2089
|
-
/* @__PURE__ */ (0,
|
|
1991
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2090
1992
|
"span",
|
|
2091
1993
|
{
|
|
2092
1994
|
style: {
|
|
@@ -2098,11 +2000,11 @@ function DualColorPicker({
|
|
|
2098
2000
|
}
|
|
2099
2001
|
}
|
|
2100
2002
|
),
|
|
2101
|
-
/* @__PURE__ */ (0,
|
|
2003
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { style: { fontSize: "11px", fontWeight: 600 }, children: "Light" })
|
|
2102
2004
|
]
|
|
2103
2005
|
}
|
|
2104
2006
|
),
|
|
2105
|
-
/* @__PURE__ */ (0,
|
|
2007
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
2106
2008
|
"button",
|
|
2107
2009
|
{
|
|
2108
2010
|
type: "button",
|
|
@@ -2124,7 +2026,7 @@ function DualColorPicker({
|
|
|
2124
2026
|
outline: "none"
|
|
2125
2027
|
},
|
|
2126
2028
|
children: [
|
|
2127
|
-
/* @__PURE__ */ (0,
|
|
2029
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2128
2030
|
"span",
|
|
2129
2031
|
{
|
|
2130
2032
|
style: {
|
|
@@ -2136,12 +2038,12 @@ function DualColorPicker({
|
|
|
2136
2038
|
}
|
|
2137
2039
|
}
|
|
2138
2040
|
),
|
|
2139
|
-
/* @__PURE__ */ (0,
|
|
2041
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { style: { fontSize: "11px", fontWeight: 600 }, children: "Dark" })
|
|
2140
2042
|
]
|
|
2141
2043
|
}
|
|
2142
2044
|
)
|
|
2143
2045
|
] }),
|
|
2144
|
-
/* @__PURE__ */ (0,
|
|
2046
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
2145
2047
|
"div",
|
|
2146
2048
|
{
|
|
2147
2049
|
style: {
|
|
@@ -2152,7 +2054,7 @@ function DualColorPicker({
|
|
|
2152
2054
|
padding: "2px 0"
|
|
2153
2055
|
},
|
|
2154
2056
|
children: [
|
|
2155
|
-
/* @__PURE__ */ (0,
|
|
2057
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
2156
2058
|
"label",
|
|
2157
2059
|
{
|
|
2158
2060
|
htmlFor: sameId,
|
|
@@ -2166,7 +2068,7 @@ function DualColorPicker({
|
|
|
2166
2068
|
color: "#c4cad4"
|
|
2167
2069
|
},
|
|
2168
2070
|
children: [
|
|
2169
|
-
/* @__PURE__ */ (0,
|
|
2071
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2170
2072
|
"input",
|
|
2171
2073
|
{
|
|
2172
2074
|
id: sameId,
|
|
@@ -2177,11 +2079,11 @@ function DualColorPicker({
|
|
|
2177
2079
|
style: { cursor: disabled ? "not-allowed" : "pointer" }
|
|
2178
2080
|
}
|
|
2179
2081
|
),
|
|
2180
|
-
/* @__PURE__ */ (0,
|
|
2082
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { children: "Same in both" })
|
|
2181
2083
|
]
|
|
2182
2084
|
}
|
|
2183
2085
|
),
|
|
2184
|
-
/* @__PURE__ */ (0,
|
|
2086
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2185
2087
|
"button",
|
|
2186
2088
|
{
|
|
2187
2089
|
type: "button",
|
|
@@ -2203,7 +2105,7 @@ function DualColorPicker({
|
|
|
2203
2105
|
]
|
|
2204
2106
|
}
|
|
2205
2107
|
),
|
|
2206
|
-
dualContrast && /* @__PURE__ */ (0,
|
|
2108
|
+
dualContrast && /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
2207
2109
|
"div",
|
|
2208
2110
|
{
|
|
2209
2111
|
"data-testid": "dual-contrast-summary",
|
|
@@ -2217,20 +2119,20 @@ function DualColorPicker({
|
|
|
2217
2119
|
color: "#8c95a6"
|
|
2218
2120
|
},
|
|
2219
2121
|
children: [
|
|
2220
|
-
/* @__PURE__ */ (0,
|
|
2122
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("span", { children: [
|
|
2221
2123
|
"Light:",
|
|
2222
2124
|
" ",
|
|
2223
|
-
/* @__PURE__ */ (0,
|
|
2125
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("strong", { style: { color: dualContrast.light.level === "fail" ? "#ef4444" : "#22c55e" }, children: [
|
|
2224
2126
|
dualContrast.light.ratio.toFixed(2),
|
|
2225
2127
|
" (",
|
|
2226
2128
|
dualContrast.light.level,
|
|
2227
2129
|
")"
|
|
2228
2130
|
] })
|
|
2229
2131
|
] }),
|
|
2230
|
-
/* @__PURE__ */ (0,
|
|
2132
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("span", { children: [
|
|
2231
2133
|
"Dark:",
|
|
2232
2134
|
" ",
|
|
2233
|
-
/* @__PURE__ */ (0,
|
|
2135
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("strong", { style: { color: dualContrast.dark.level === "fail" ? "#ef4444" : "#22c55e" }, children: [
|
|
2234
2136
|
dualContrast.dark.ratio.toFixed(2),
|
|
2235
2137
|
" (",
|
|
2236
2138
|
dualContrast.dark.level,
|
|
@@ -2240,7 +2142,7 @@ function DualColorPicker({
|
|
|
2240
2142
|
]
|
|
2241
2143
|
}
|
|
2242
2144
|
),
|
|
2243
|
-
/* @__PURE__ */ (0,
|
|
2145
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2244
2146
|
ColorPicker,
|
|
2245
2147
|
{
|
|
2246
2148
|
value: activeColor,
|
|
@@ -2259,7 +2161,7 @@ function DualColorPicker({
|
|
|
2259
2161
|
}
|
|
2260
2162
|
|
|
2261
2163
|
// src/color/useColorScheme.ts
|
|
2262
|
-
var
|
|
2164
|
+
var import_react16 = require("react");
|
|
2263
2165
|
var import_color3 = require("@pixerate/editor/color");
|
|
2264
2166
|
function getSnapshot(attribute) {
|
|
2265
2167
|
if (typeof window === "undefined" || typeof document === "undefined") {
|
|
@@ -2284,7 +2186,7 @@ function getServerSnapshot() {
|
|
|
2284
2186
|
function useColorScheme(options) {
|
|
2285
2187
|
const override = options?.override;
|
|
2286
2188
|
const attribute = options?.attribute;
|
|
2287
|
-
const subscribe = (0,
|
|
2189
|
+
const subscribe = (0, import_react16.useMemo)(() => {
|
|
2288
2190
|
return (callback) => {
|
|
2289
2191
|
if (typeof window === "undefined" || typeof document === "undefined") {
|
|
2290
2192
|
return () => {
|
|
@@ -2310,7 +2212,7 @@ function useColorScheme(options) {
|
|
|
2310
2212
|
};
|
|
2311
2213
|
};
|
|
2312
2214
|
}, [attribute]);
|
|
2313
|
-
const detected = (0,
|
|
2215
|
+
const detected = (0, import_react16.useSyncExternalStore)(
|
|
2314
2216
|
subscribe,
|
|
2315
2217
|
() => getSnapshot(attribute),
|
|
2316
2218
|
getServerSnapshot
|
|
@@ -2327,11 +2229,11 @@ function useResolvedColor(value, scheme) {
|
|
|
2327
2229
|
__reExport(color_exports, require("@pixerate/editor/color"));
|
|
2328
2230
|
|
|
2329
2231
|
// src/parameters/controls.tsx
|
|
2330
|
-
var
|
|
2331
|
-
var
|
|
2332
|
-
var ParameterComponentsContext = (0,
|
|
2232
|
+
var import_react17 = require("react");
|
|
2233
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
2234
|
+
var ParameterComponentsContext = (0, import_react17.createContext)({});
|
|
2333
2235
|
function useParameterComponents() {
|
|
2334
|
-
return (0,
|
|
2236
|
+
return (0, import_react17.useContext)(ParameterComponentsContext);
|
|
2335
2237
|
}
|
|
2336
2238
|
function resolveParameterComponents(explicit, context) {
|
|
2337
2239
|
return {
|
|
@@ -2343,7 +2245,7 @@ function resolveParameterComponents(explicit, context) {
|
|
|
2343
2245
|
}
|
|
2344
2246
|
|
|
2345
2247
|
// src/parameters/fields.tsx
|
|
2346
|
-
var
|
|
2248
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
2347
2249
|
var parameterInputStyle = import_parameters.parameterThemeStyles.input;
|
|
2348
2250
|
var parameterSelectStyle = import_parameters.parameterThemeStyles.select;
|
|
2349
2251
|
var parameterButtonStyle = import_parameters.parameterThemeStyles.button;
|
|
@@ -2352,9 +2254,9 @@ var parameterInputClass = "h-7 w-full min-w-0 rounded-md border border-input bg-
|
|
|
2352
2254
|
var parameterButtonClass = "inline-flex h-7 items-center justify-center gap-1 rounded-md border border-input bg-background px-2 text-xs text-foreground hover:bg-muted focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary disabled:pointer-events-none disabled:opacity-50";
|
|
2353
2255
|
var rangeClass = "h-4 w-full min-w-0 flex-1 cursor-pointer accent-primary disabled:cursor-not-allowed disabled:opacity-50";
|
|
2354
2256
|
function ParameterCommitInput({ value, onCommit, multiline, className, onKeyDown, style, ...rest }) {
|
|
2355
|
-
const inputRef = (0,
|
|
2356
|
-
const lastCommitted = (0,
|
|
2357
|
-
(0,
|
|
2257
|
+
const inputRef = (0, import_react18.useRef)(null);
|
|
2258
|
+
const lastCommitted = (0, import_react18.useRef)(null);
|
|
2259
|
+
(0, import_react18.useLayoutEffect)(() => {
|
|
2358
2260
|
lastCommitted.current = null;
|
|
2359
2261
|
const el = inputRef.current;
|
|
2360
2262
|
if (el && el.value !== value) el.value = value;
|
|
@@ -2365,9 +2267,9 @@ function ParameterCommitInput({ value, onCommit, multiline, className, onKeyDown
|
|
|
2365
2267
|
onCommit(text, el);
|
|
2366
2268
|
lastCommitted.current = el.value === text ? text : null;
|
|
2367
2269
|
};
|
|
2368
|
-
const commitRef = (0,
|
|
2270
|
+
const commitRef = (0, import_react18.useRef)(commit);
|
|
2369
2271
|
commitRef.current = commit;
|
|
2370
|
-
(0,
|
|
2272
|
+
(0, import_react18.useEffect)(() => {
|
|
2371
2273
|
const el = inputRef.current;
|
|
2372
2274
|
if (!el) return;
|
|
2373
2275
|
const change = () => commitRef.current(el);
|
|
@@ -2398,7 +2300,7 @@ function ParameterCommitInput({ value, onCommit, multiline, className, onKeyDown
|
|
|
2398
2300
|
if (typeof forwarded === "function") forwarded(el);
|
|
2399
2301
|
else if (forwarded) forwarded.current = el;
|
|
2400
2302
|
};
|
|
2401
|
-
return multiline ? /* @__PURE__ */ (0,
|
|
2303
|
+
return multiline ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("textarea", { ...props, ref: setRef, className: `${props.className} h-auto min-h-[3.5rem] py-1` }) : /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("input", { type: "text", ...props, ref: setRef });
|
|
2402
2304
|
}
|
|
2403
2305
|
var plainNumber = (field, value) => (0, import_parameters.formatParameterNumber)({ ...field, unit: void 0 }, value);
|
|
2404
2306
|
function ParameterNumberInput(props) {
|
|
@@ -2407,10 +2309,10 @@ function ParameterNumberInput(props) {
|
|
|
2407
2309
|
const resolved = resolveParameterComponents(components, ctx);
|
|
2408
2310
|
const CustomInput = resolved.input;
|
|
2409
2311
|
const plain = plainNumber(field, value);
|
|
2410
|
-
const handleCommit = (text,
|
|
2312
|
+
const handleCommit = (text, input5) => {
|
|
2411
2313
|
const n = (0, import_parameters.parseParameterNumberInput)(field, text);
|
|
2412
2314
|
if (n === null || n === value) {
|
|
2413
|
-
if (
|
|
2315
|
+
if (input5) input5.value = plain;
|
|
2414
2316
|
} else {
|
|
2415
2317
|
onChange(n);
|
|
2416
2318
|
}
|
|
@@ -2432,9 +2334,9 @@ function ParameterNumberInput(props) {
|
|
|
2432
2334
|
onCommit: handleCommit,
|
|
2433
2335
|
onKeyDown: handleKeyDown
|
|
2434
2336
|
};
|
|
2435
|
-
return /* @__PURE__ */ (0,
|
|
2436
|
-
CustomInput ? /* @__PURE__ */ (0,
|
|
2437
|
-
field.unit && /* @__PURE__ */ (0,
|
|
2337
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "relative min-w-0 flex-1", children: [
|
|
2338
|
+
CustomInput ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(CustomInput, { ...inputProps, label: (0, import_parameters.parameterLabel)(field) }) : /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ParameterCommitInput, { ...inputProps }),
|
|
2339
|
+
field.unit && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "pointer-events-none absolute right-2 top-1/2 -translate-y-1/2 text-[10px] text-muted-foreground", children: field.unit })
|
|
2438
2340
|
] });
|
|
2439
2341
|
}
|
|
2440
2342
|
function ParameterSlider(props) {
|
|
@@ -2442,7 +2344,7 @@ function ParameterSlider(props) {
|
|
|
2442
2344
|
const ctx = useParameterComponents();
|
|
2443
2345
|
const resolved = resolveParameterComponents(components, ctx);
|
|
2444
2346
|
const CustomSlider = resolved.slider;
|
|
2445
|
-
const dragging = (0,
|
|
2347
|
+
const dragging = (0, import_react18.useRef)(false);
|
|
2446
2348
|
const start = () => {
|
|
2447
2349
|
if (dragging.current) return;
|
|
2448
2350
|
dragging.current = true;
|
|
@@ -2453,7 +2355,7 @@ function ParameterSlider(props) {
|
|
|
2453
2355
|
dragging.current = false;
|
|
2454
2356
|
onGestureEnd?.();
|
|
2455
2357
|
};
|
|
2456
|
-
if (!(0, import_parameters.isSliderField)(field)) return /* @__PURE__ */ (0,
|
|
2358
|
+
if (!(0, import_parameters.isSliderField)(field)) return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ParameterNumberInput, { ...props });
|
|
2457
2359
|
const step = (0, import_parameters.parameterStep)(field);
|
|
2458
2360
|
const sliderProps = {
|
|
2459
2361
|
"aria-label": (0, import_parameters.parameterLabel)(field),
|
|
@@ -2467,8 +2369,8 @@ function ParameterSlider(props) {
|
|
|
2467
2369
|
className: rangeClass,
|
|
2468
2370
|
style: parameterRangeStyle
|
|
2469
2371
|
};
|
|
2470
|
-
return /* @__PURE__ */ (0,
|
|
2471
|
-
CustomSlider ? /* @__PURE__ */ (0,
|
|
2372
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
2373
|
+
CustomSlider ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
2472
2374
|
CustomSlider,
|
|
2473
2375
|
{
|
|
2474
2376
|
...sliderProps,
|
|
@@ -2478,7 +2380,7 @@ function ParameterSlider(props) {
|
|
|
2478
2380
|
onGestureStart: start,
|
|
2479
2381
|
onGestureEnd: end
|
|
2480
2382
|
}
|
|
2481
|
-
) : /* @__PURE__ */ (0,
|
|
2383
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
2482
2384
|
"input",
|
|
2483
2385
|
{
|
|
2484
2386
|
type: "range",
|
|
@@ -2490,11 +2392,11 @@ function ParameterSlider(props) {
|
|
|
2490
2392
|
onChange: (e) => onChange((0, import_parameters.clampParameterNumber)(field, Number(e.target.value)))
|
|
2491
2393
|
}
|
|
2492
2394
|
),
|
|
2493
|
-
/* @__PURE__ */ (0,
|
|
2395
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "w-20 shrink-0", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ParameterNumberInput, { ...props, id: props.id, "aria-label": `${(0, import_parameters.parameterLabel)(field)} value` }) })
|
|
2494
2396
|
] });
|
|
2495
2397
|
}
|
|
2496
2398
|
function ParameterToggle({ field, value, onChange, disabled, id }) {
|
|
2497
|
-
return /* @__PURE__ */ (0,
|
|
2399
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
2498
2400
|
"button",
|
|
2499
2401
|
{
|
|
2500
2402
|
type: "button",
|
|
@@ -2505,7 +2407,7 @@ function ParameterToggle({ field, value, onChange, disabled, id }) {
|
|
|
2505
2407
|
disabled: disabled || field.readOnly,
|
|
2506
2408
|
onClick: () => onChange(!value),
|
|
2507
2409
|
className: `relative inline-flex h-5 w-9 shrink-0 items-center rounded-full border border-transparent transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary disabled:opacity-50 ${value ? "bg-primary" : "bg-muted"}`,
|
|
2508
|
-
children: /* @__PURE__ */ (0,
|
|
2410
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
2509
2411
|
"span",
|
|
2510
2412
|
{
|
|
2511
2413
|
className: `pointer-events-none block h-4 w-4 rounded-full bg-background shadow transition-transform ${value ? "translate-x-4" : "translate-x-0.5"}`
|
|
@@ -2522,7 +2424,7 @@ function ParameterSelect(props) {
|
|
|
2522
2424
|
const options = (0, import_parameters.getChoiceOptions)(field);
|
|
2523
2425
|
const off = disabled || field.readOnly;
|
|
2524
2426
|
if (field.control === "segmented") {
|
|
2525
|
-
return /* @__PURE__ */ (0,
|
|
2427
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { role: "radiogroup", "aria-label": (0, import_parameters.parameterLabel)(field), className: "inline-flex flex-wrap rounded-md border border-input bg-muted p-0.5", children: options.map((o) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
2526
2428
|
"button",
|
|
2527
2429
|
{
|
|
2528
2430
|
type: "button",
|
|
@@ -2539,7 +2441,7 @@ function ParameterSelect(props) {
|
|
|
2539
2441
|
}
|
|
2540
2442
|
if (CustomSelect) {
|
|
2541
2443
|
const customOptions = options.map((o) => ({ value: o.value, label: (0, import_parameters.choiceOptionLabel)(o), description: o.description }));
|
|
2542
|
-
return /* @__PURE__ */ (0,
|
|
2444
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
2543
2445
|
CustomSelect,
|
|
2544
2446
|
{
|
|
2545
2447
|
id,
|
|
@@ -2555,7 +2457,7 @@ function ParameterSelect(props) {
|
|
|
2555
2457
|
);
|
|
2556
2458
|
}
|
|
2557
2459
|
const index = options.findIndex((o) => o.value === value);
|
|
2558
|
-
return /* @__PURE__ */ (0,
|
|
2460
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
2559
2461
|
"select",
|
|
2560
2462
|
{
|
|
2561
2463
|
id,
|
|
@@ -2568,23 +2470,23 @@ function ParameterSelect(props) {
|
|
|
2568
2470
|
},
|
|
2569
2471
|
className: parameterInputClass,
|
|
2570
2472
|
style: parameterSelectStyle,
|
|
2571
|
-
children: options.map((o, i) => /* @__PURE__ */ (0,
|
|
2473
|
+
children: options.map((o, i) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("option", { value: String(i), title: o.description, style: parameterSelectStyle, children: (0, import_parameters.choiceOptionLabel)(o) }, String(o.value)))
|
|
2572
2474
|
}
|
|
2573
2475
|
);
|
|
2574
2476
|
}
|
|
2575
2477
|
function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd, disabled, id, components }) {
|
|
2576
2478
|
const CustomColor = resolveParameterComponents(components, useParameterComponents()).color;
|
|
2577
|
-
const [open, setOpen] = (0,
|
|
2578
|
-
const containerRef = (0,
|
|
2579
|
-
const buttonRef = (0,
|
|
2580
|
-
const popoverRef = (0,
|
|
2479
|
+
const [open, setOpen] = (0, import_react18.useState)(false);
|
|
2480
|
+
const containerRef = (0, import_react18.useRef)(null);
|
|
2481
|
+
const buttonRef = (0, import_react18.useRef)(null);
|
|
2482
|
+
const popoverRef = (0, import_react18.useRef)(null);
|
|
2581
2483
|
const alpha = !!field.alpha;
|
|
2582
2484
|
const hex = (0, import_parameters.normalizeHexColor)(value, true) ?? "#000000ff";
|
|
2583
2485
|
const rgb = hex.slice(0, 7);
|
|
2584
2486
|
const shown = alpha ? hex : rgb;
|
|
2585
2487
|
const off = disabled || field.readOnly;
|
|
2586
2488
|
const name = (0, import_parameters.parameterLabel)(field);
|
|
2587
|
-
(0,
|
|
2489
|
+
(0, import_react18.useEffect)(() => {
|
|
2588
2490
|
if (!open) return;
|
|
2589
2491
|
const onPointerDown = (e) => {
|
|
2590
2492
|
if (containerRef.current && !containerRef.current.contains(e.target)) {
|
|
@@ -2606,7 +2508,7 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
2606
2508
|
};
|
|
2607
2509
|
}, [open]);
|
|
2608
2510
|
if (CustomColor) {
|
|
2609
|
-
return /* @__PURE__ */ (0,
|
|
2511
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
2610
2512
|
CustomColor,
|
|
2611
2513
|
{
|
|
2612
2514
|
id,
|
|
@@ -2621,9 +2523,9 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
2621
2523
|
}
|
|
2622
2524
|
);
|
|
2623
2525
|
}
|
|
2624
|
-
return /* @__PURE__ */ (0,
|
|
2625
|
-
/* @__PURE__ */ (0,
|
|
2626
|
-
/* @__PURE__ */ (0,
|
|
2526
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { ref: containerRef, className: "relative space-y-1.5", children: [
|
|
2527
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
2528
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
2627
2529
|
"button",
|
|
2628
2530
|
{
|
|
2629
2531
|
ref: buttonRef,
|
|
@@ -2634,10 +2536,10 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
2634
2536
|
disabled: off,
|
|
2635
2537
|
onClick: () => setOpen((prev) => !prev),
|
|
2636
2538
|
className: "relative h-7 w-9 shrink-0 overflow-hidden rounded-md border border-input bg-[repeating-conic-gradient(#d4d4d8_0_25%,#fff_0_50%)] bg-[length:8px_8px] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary disabled:cursor-not-allowed disabled:opacity-50",
|
|
2637
|
-
children: /* @__PURE__ */ (0,
|
|
2539
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "absolute inset-0", style: { background: shown } })
|
|
2638
2540
|
}
|
|
2639
2541
|
),
|
|
2640
|
-
/* @__PURE__ */ (0,
|
|
2542
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
2641
2543
|
ParameterCommitInput,
|
|
2642
2544
|
{
|
|
2643
2545
|
id,
|
|
@@ -2653,7 +2555,7 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
2653
2555
|
}
|
|
2654
2556
|
)
|
|
2655
2557
|
] }),
|
|
2656
|
-
open && /* @__PURE__ */ (0,
|
|
2558
|
+
open && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
2657
2559
|
"div",
|
|
2658
2560
|
{
|
|
2659
2561
|
ref: popoverRef,
|
|
@@ -2667,7 +2569,7 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
2667
2569
|
},
|
|
2668
2570
|
className: "absolute left-0 top-full z-50 mt-1 w-64 rounded-lg border border-border bg-popover p-2 text-popover-foreground shadow-xl",
|
|
2669
2571
|
style: { background: "var(--popover, var(--background, #fff))" },
|
|
2670
|
-
children: /* @__PURE__ */ (0,
|
|
2572
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
2671
2573
|
ColorPicker,
|
|
2672
2574
|
{
|
|
2673
2575
|
value: shown,
|
|
@@ -2685,11 +2587,11 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
2685
2587
|
}
|
|
2686
2588
|
function ParameterVector({ field, value, onChange, disabled, id, components }) {
|
|
2687
2589
|
const size = (0, import_parameters.vectorSize)(field);
|
|
2688
|
-
return /* @__PURE__ */ (0,
|
|
2590
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "grid gap-1.5", style: { gridTemplateColumns: `repeat(${size}, minmax(0, 1fr))` }, children: Array.from({ length: size }, (_, i) => {
|
|
2689
2591
|
const component = (0, import_parameters.vectorComponentField)(field, i);
|
|
2690
|
-
return /* @__PURE__ */ (0,
|
|
2691
|
-
/* @__PURE__ */ (0,
|
|
2692
|
-
/* @__PURE__ */ (0,
|
|
2592
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("label", { className: "flex min-w-0 items-center gap-1", children: [
|
|
2593
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "w-3 shrink-0 text-[10px] uppercase text-muted-foreground", children: component.label }),
|
|
2594
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
2693
2595
|
ParameterNumberInput,
|
|
2694
2596
|
{
|
|
2695
2597
|
field: component,
|
|
@@ -2707,11 +2609,11 @@ function ParameterVector({ field, value, onChange, disabled, id, components }) {
|
|
|
2707
2609
|
function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
|
|
2708
2610
|
const off = disabled || field.readOnly;
|
|
2709
2611
|
const name = (0, import_parameters.parameterLabel)(field);
|
|
2710
|
-
return /* @__PURE__ */ (0,
|
|
2711
|
-
/* @__PURE__ */ (0,
|
|
2712
|
-
/* @__PURE__ */ (0,
|
|
2713
|
-
/* @__PURE__ */ (0,
|
|
2714
|
-
/* @__PURE__ */ (0,
|
|
2612
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "space-y-1.5", children: [
|
|
2613
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
2614
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "flex h-12 w-16 shrink-0 items-center justify-center overflow-hidden rounded-md border border-input bg-muted", children: value ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("img", { src: value, alt: name, className: "h-full w-full object-cover" }) : /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "text-[10px] text-muted-foreground", children: "None" }) }),
|
|
2615
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "flex min-w-0 flex-1 flex-col gap-1", children: [
|
|
2616
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
2715
2617
|
ParameterCommitInput,
|
|
2716
2618
|
{
|
|
2717
2619
|
id,
|
|
@@ -2722,15 +2624,15 @@ function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
|
|
|
2722
2624
|
onCommit: (text) => onChange(text.trim())
|
|
2723
2625
|
}
|
|
2724
2626
|
),
|
|
2725
|
-
/* @__PURE__ */ (0,
|
|
2726
|
-
resolveFile && /* @__PURE__ */ (0,
|
|
2627
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "flex gap-1", children: [
|
|
2628
|
+
resolveFile && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
|
|
2727
2629
|
"label",
|
|
2728
2630
|
{
|
|
2729
2631
|
style: parameterButtonStyle,
|
|
2730
2632
|
className: `${parameterButtonClass} cursor-pointer ${off ? "pointer-events-none opacity-50" : ""}`,
|
|
2731
2633
|
children: [
|
|
2732
2634
|
"Choose file\u2026",
|
|
2733
|
-
/* @__PURE__ */ (0,
|
|
2635
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
2734
2636
|
"input",
|
|
2735
2637
|
{
|
|
2736
2638
|
type: "file",
|
|
@@ -2748,7 +2650,7 @@ function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
|
|
|
2748
2650
|
]
|
|
2749
2651
|
}
|
|
2750
2652
|
),
|
|
2751
|
-
value && /* @__PURE__ */ (0,
|
|
2653
|
+
value && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
2752
2654
|
"button",
|
|
2753
2655
|
{
|
|
2754
2656
|
type: "button",
|
|
@@ -2763,7 +2665,7 @@ function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
|
|
|
2763
2665
|
] })
|
|
2764
2666
|
] })
|
|
2765
2667
|
] }),
|
|
2766
|
-
field.options && field.options.length > 0 && /* @__PURE__ */ (0,
|
|
2668
|
+
field.options && field.options.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "flex flex-wrap gap-1", children: field.options.map((o) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
2767
2669
|
"button",
|
|
2768
2670
|
{
|
|
2769
2671
|
type: "button",
|
|
@@ -2773,14 +2675,14 @@ function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
|
|
|
2773
2675
|
disabled: off,
|
|
2774
2676
|
onClick: () => onChange(o.url),
|
|
2775
2677
|
className: "h-9 w-12 overflow-hidden rounded border border-input aria-pressed:ring-2 aria-pressed:ring-primary",
|
|
2776
|
-
children: /* @__PURE__ */ (0,
|
|
2678
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("img", { src: o.url, alt: "", className: "h-full w-full object-cover" })
|
|
2777
2679
|
},
|
|
2778
2680
|
o.url
|
|
2779
2681
|
)) })
|
|
2780
2682
|
] });
|
|
2781
2683
|
}
|
|
2782
2684
|
function ParameterText({ field, value, onChange, disabled, id }) {
|
|
2783
|
-
return /* @__PURE__ */ (0,
|
|
2685
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
2784
2686
|
ParameterCommitInput,
|
|
2785
2687
|
{
|
|
2786
2688
|
id,
|
|
@@ -2799,24 +2701,24 @@ function ParameterFieldControl({ field, value, onChange, resolveFile, ...rest })
|
|
|
2799
2701
|
switch (field.type) {
|
|
2800
2702
|
case "number":
|
|
2801
2703
|
case "int":
|
|
2802
|
-
return /* @__PURE__ */ (0,
|
|
2704
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ParameterSlider, { field, value, onChange: set, ...rest });
|
|
2803
2705
|
case "boolean":
|
|
2804
|
-
return /* @__PURE__ */ (0,
|
|
2706
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ParameterToggle, { field, value, onChange: set, ...rest });
|
|
2805
2707
|
case "choice":
|
|
2806
|
-
return /* @__PURE__ */ (0,
|
|
2708
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ParameterSelect, { field, value, onChange: set, ...rest });
|
|
2807
2709
|
case "color":
|
|
2808
|
-
return /* @__PURE__ */ (0,
|
|
2710
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ParameterColor, { field, value, onChange: set, ...rest });
|
|
2809
2711
|
case "vector":
|
|
2810
|
-
return /* @__PURE__ */ (0,
|
|
2712
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ParameterVector, { field, value, onChange: set, ...rest });
|
|
2811
2713
|
case "image":
|
|
2812
|
-
return /* @__PURE__ */ (0,
|
|
2714
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ParameterImage, { field, value, onChange: set, resolveFile, ...rest });
|
|
2813
2715
|
case "text":
|
|
2814
|
-
return /* @__PURE__ */ (0,
|
|
2716
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ParameterText, { field, value, onChange: set, ...rest });
|
|
2815
2717
|
}
|
|
2816
2718
|
}
|
|
2817
2719
|
|
|
2818
2720
|
// src/effects/EffectParameters.tsx
|
|
2819
|
-
var
|
|
2721
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
2820
2722
|
function EffectParameters({
|
|
2821
2723
|
description,
|
|
2822
2724
|
values,
|
|
@@ -2831,10 +2733,10 @@ function EffectParameters({
|
|
|
2831
2733
|
className = "",
|
|
2832
2734
|
components
|
|
2833
2735
|
}) {
|
|
2834
|
-
const fields = (0,
|
|
2835
|
-
const idBase = (0,
|
|
2836
|
-
const gesture =
|
|
2837
|
-
const count =
|
|
2736
|
+
const fields = (0, import_react19.useMemo)(() => (0, import_effects3.effectParameterFields)(description, { fonts }), [description, fonts]);
|
|
2737
|
+
const idBase = (0, import_react19.useId)();
|
|
2738
|
+
const gesture = import_react19.default.useRef(null);
|
|
2739
|
+
const count = import_react19.default.useRef(0);
|
|
2838
2740
|
const CustomPresetSelect = resolveParameterComponents(components, useParameterComponents()).select;
|
|
2839
2741
|
const handlePresetSelect = (name) => {
|
|
2840
2742
|
if (!name) return;
|
|
@@ -2845,8 +2747,8 @@ function EffectParameters({
|
|
|
2845
2747
|
if (preset) onPreset({ ...description.defaults, ...preset.values });
|
|
2846
2748
|
}
|
|
2847
2749
|
};
|
|
2848
|
-
return /* @__PURE__ */ (0,
|
|
2849
|
-
(onPreset || onPresetName) && description.presets.length > 0 && (CustomPresetSelect ? /* @__PURE__ */ (0,
|
|
2750
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: `space-y-2 ${className}`, "data-effect-parameters": description.id, children: [
|
|
2751
|
+
(onPreset || onPresetName) && description.presets.length > 0 && (CustomPresetSelect ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2850
2752
|
CustomPresetSelect,
|
|
2851
2753
|
{
|
|
2852
2754
|
"aria-label": `${description.name} presets`,
|
|
@@ -2861,7 +2763,7 @@ function EffectParameters({
|
|
|
2861
2763
|
],
|
|
2862
2764
|
onChange: (name) => handlePresetSelect(String(name))
|
|
2863
2765
|
}
|
|
2864
|
-
) : /* @__PURE__ */ (0,
|
|
2766
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
|
|
2865
2767
|
"select",
|
|
2866
2768
|
{
|
|
2867
2769
|
className: "w-full rounded border border-border px-1 py-0.5 text-xs",
|
|
@@ -2871,8 +2773,8 @@ function EffectParameters({
|
|
|
2871
2773
|
disabled,
|
|
2872
2774
|
onChange: (e) => handlePresetSelect(e.currentTarget.value),
|
|
2873
2775
|
children: [
|
|
2874
|
-
/* @__PURE__ */ (0,
|
|
2875
|
-
description.presets.map((p) => /* @__PURE__ */ (0,
|
|
2776
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("option", { value: "", style: parameterSelectStyle, children: "Presets\u2026" }),
|
|
2777
|
+
description.presets.map((p) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("option", { value: p.name, style: parameterSelectStyle, children: p.name }, p.name))
|
|
2876
2778
|
]
|
|
2877
2779
|
}
|
|
2878
2780
|
)),
|
|
@@ -2882,14 +2784,14 @@ function EffectParameters({
|
|
|
2882
2784
|
const keyed = keyframed?.has(field.id) ?? false;
|
|
2883
2785
|
const value = (0, import_effects3.effectFieldValue)(field, values[field.id]);
|
|
2884
2786
|
const changed = !keyed && !(0, import_parameters2.parameterValuesEqual)(value, field.default);
|
|
2885
|
-
return /* @__PURE__ */ (0,
|
|
2886
|
-
/* @__PURE__ */ (0,
|
|
2887
|
-
/* @__PURE__ */ (0,
|
|
2888
|
-
keyed && /* @__PURE__ */ (0,
|
|
2787
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "space-y-1", "data-effect-control": field.id, children: [
|
|
2788
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex items-center gap-1.5", children: [
|
|
2789
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("label", { htmlFor: inputId, className: "min-w-0 flex-1 truncate text-xs font-medium", title: field.description, children: label }),
|
|
2790
|
+
keyed && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: "text-[10px] text-muted-foreground", children: "keyframed" }),
|
|
2889
2791
|
renderControlAddon?.(field.id),
|
|
2890
|
-
onReset && changed && !disabled && /* @__PURE__ */ (0,
|
|
2792
|
+
onReset && changed && !disabled && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("button", { type: "button", className: "rounded px-1 text-[11px] text-muted-foreground hover:text-foreground", "aria-label": `Reset ${label}`, onClick: () => onReset(field.id), children: "\u21BA" })
|
|
2891
2793
|
] }),
|
|
2892
|
-
/* @__PURE__ */ (0,
|
|
2794
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2893
2795
|
ParameterFieldControl,
|
|
2894
2796
|
{
|
|
2895
2797
|
field,
|
|
@@ -2904,25 +2806,251 @@ function EffectParameters({
|
|
|
2904
2806
|
)
|
|
2905
2807
|
] }, field.id);
|
|
2906
2808
|
}),
|
|
2907
|
-
!fields.length && /* @__PURE__ */ (0,
|
|
2809
|
+
!fields.length && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No controls." })
|
|
2908
2810
|
] });
|
|
2909
2811
|
}
|
|
2910
2812
|
|
|
2911
|
-
// src/animation-editor/
|
|
2912
|
-
var
|
|
2913
|
-
var
|
|
2813
|
+
// src/animation-editor/ShotCameraMoves.tsx
|
|
2814
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
2815
|
+
var input3 = "w-full min-w-0 rounded border border-border bg-transparent px-1 py-0.5 text-xs";
|
|
2816
|
+
var ROLES = [
|
|
2817
|
+
{ role: "transition", label: "Move in", none: "ease in" },
|
|
2818
|
+
{ role: "hold", label: "While holding", none: "stay still" }
|
|
2819
|
+
];
|
|
2820
|
+
function useCameraMoves(controller, provider) {
|
|
2821
|
+
const [moves, setMoves] = (0, import_react20.useState)({ transition: [], hold: [] });
|
|
2822
|
+
(0, import_react20.useEffect)(() => {
|
|
2823
|
+
let live = true;
|
|
2824
|
+
void Promise.all([controller.cameraMoves("transition"), controller.cameraMoves("hold")]).then(
|
|
2825
|
+
([transition, hold]) => live && setMoves({ transition, hold }),
|
|
2826
|
+
() => live && setMoves({ transition: [], hold: [] })
|
|
2827
|
+
);
|
|
2828
|
+
return () => {
|
|
2829
|
+
live = false;
|
|
2830
|
+
};
|
|
2831
|
+
}, [controller, provider]);
|
|
2832
|
+
return moves;
|
|
2833
|
+
}
|
|
2834
|
+
function MoveControls({ controller, shot, role }) {
|
|
2835
|
+
const state = useAnimationEditorState(controller);
|
|
2836
|
+
const move = (0, import_animation_editor9.motionShotCameraMove)(state.scene.shots.find((s) => s.id === shot), role);
|
|
2837
|
+
const { description, error } = useEffectDescription(state.effectsProvider, move?.move);
|
|
2838
|
+
const [message, setMessage] = (0, import_react20.useState)(null);
|
|
2839
|
+
if (!move) return null;
|
|
2840
|
+
const report = (r) => void r.then((x) => setMessage(x.ok ? null : x.error));
|
|
2841
|
+
const set = (changes, merge) => {
|
|
2842
|
+
const next = { ...move, ...changes };
|
|
2843
|
+
for (const k of Object.keys(next)) if (next[k] === null || k === "values" && !Object.keys(next[k]).length) delete next[k];
|
|
2844
|
+
report(controller.setShotCameraMove(shot, role, next, { merge: merge ?? void 0 }));
|
|
2845
|
+
};
|
|
2846
|
+
if (error) return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("p", { className: "text-[11px] text-amber-500", children: error });
|
|
2847
|
+
if (!description) return null;
|
|
2848
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "col-span-2 flex flex-col gap-1 border-l border-border pl-2", "data-camera-move-controls": role, children: [
|
|
2849
|
+
role === "transition" && /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
2850
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "w-16 text-muted-foreground", children: "Length" }),
|
|
2851
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
2852
|
+
CommitInput,
|
|
2853
|
+
{
|
|
2854
|
+
className: input3,
|
|
2855
|
+
type: "number",
|
|
2856
|
+
min: 0,
|
|
2857
|
+
step: 50,
|
|
2858
|
+
"aria-label": "Move length",
|
|
2859
|
+
placeholder: String(description.camera?.durationMs ?? ""),
|
|
2860
|
+
value: move.ms !== void 0 ? String(move.ms) : "",
|
|
2861
|
+
onCommit: (raw) => raw.trim() === "" ? set({ ms: null }) : Number.isFinite(Number(raw)) && Number(raw) >= 0 ? set({ ms: Number(raw) }) : setMessage("Length is a number of ms, 0 or more.")
|
|
2862
|
+
}
|
|
2863
|
+
),
|
|
2864
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "text-[10px] text-muted-foreground", children: "ms" })
|
|
2865
|
+
] }),
|
|
2866
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
2867
|
+
EffectParameters,
|
|
2868
|
+
{
|
|
2869
|
+
description,
|
|
2870
|
+
values: move.values ?? {},
|
|
2871
|
+
onChange: (k, v, gesture) => set({ values: { ...move.values ?? {}, [k]: v }, preset: null }, gesture),
|
|
2872
|
+
onReset: (k) => {
|
|
2873
|
+
const { [k]: _gone, ...rest } = move.values ?? {};
|
|
2874
|
+
set({ values: rest, preset: null });
|
|
2875
|
+
},
|
|
2876
|
+
onPresetName: (name) => set({ preset: name, values: {} })
|
|
2877
|
+
}
|
|
2878
|
+
),
|
|
2879
|
+
message && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("p", { role: "alert", className: "text-[11px] text-destructive", children: message })
|
|
2880
|
+
] });
|
|
2881
|
+
}
|
|
2882
|
+
function ShotCameraMoves({ controller, shot, className = "" }) {
|
|
2883
|
+
const state = useAnimationEditorState(controller);
|
|
2884
|
+
const moves = useCameraMoves(controller, state.effectsProvider);
|
|
2885
|
+
const current = state.scene.shots.find((s) => s.id === shot);
|
|
2886
|
+
const [message, setMessage] = (0, import_react20.useState)(null);
|
|
2887
|
+
if (!current) return null;
|
|
2888
|
+
const has = moves.transition.length + moves.hold.length > 0;
|
|
2889
|
+
const named = current.camera?.in !== void 0 || current.camera?.during !== void 0;
|
|
2890
|
+
if (!has)
|
|
2891
|
+
return named ? /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("p", { className: `text-[10px] text-muted-foreground ${className}`, "data-camera-moves": "unavailable", children: [
|
|
2892
|
+
"This shot names camera moves, but ",
|
|
2893
|
+
state.effectsProvider ? `${state.effectsProvider.name} has none` : "no effects provider is set",
|
|
2894
|
+
", so the camera eases instead."
|
|
2895
|
+
] }) : null;
|
|
2896
|
+
const report = (r) => void Promise.resolve(r).then((x) => setMessage(x.ok ? null : x.error));
|
|
2897
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: `grid grid-cols-[6.5rem_1fr] items-center gap-x-2 gap-y-1 ${className}`, "data-camera-moves": "", children: [
|
|
2898
|
+
ROLES.map(({ role, label, none }) => {
|
|
2899
|
+
const move = (0, import_animation_editor9.motionShotCameraMove)(current, role);
|
|
2900
|
+
const known = moves[role].some((m) => m.id === move?.move);
|
|
2901
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_react20.default.Fragment, { children: [
|
|
2902
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("label", { className: "text-muted-foreground", children: label }),
|
|
2903
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
|
|
2904
|
+
"select",
|
|
2905
|
+
{
|
|
2906
|
+
className: input3,
|
|
2907
|
+
"aria-label": label,
|
|
2908
|
+
disabled: state.readOnly,
|
|
2909
|
+
value: move?.move ?? "",
|
|
2910
|
+
onChange: (e) => report(e.target.value ? controller.setShotCameraMove(current.id, role, e.target.value) : controller.clearShotCameraMove(current.id, role)),
|
|
2911
|
+
children: [
|
|
2912
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("option", { value: "", children: none }),
|
|
2913
|
+
move && !known && /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("option", { value: move.move, children: [
|
|
2914
|
+
move.move,
|
|
2915
|
+
" (not in the provider)"
|
|
2916
|
+
] }),
|
|
2917
|
+
moves[role].map((m) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("option", { value: m.id, children: m.name }, m.id))
|
|
2918
|
+
]
|
|
2919
|
+
}
|
|
2920
|
+
),
|
|
2921
|
+
move && known && !state.readOnly && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(MoveControls, { controller, shot: current.id, role })
|
|
2922
|
+
] }, role);
|
|
2923
|
+
}),
|
|
2924
|
+
message && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("p", { className: "col-span-2 text-[11px] text-destructive", role: "alert", children: message })
|
|
2925
|
+
] });
|
|
2926
|
+
}
|
|
2927
|
+
|
|
2928
|
+
// src/animation-editor/ShotInspector.tsx
|
|
2914
2929
|
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
2930
|
+
var input4 = "w-full min-w-0 rounded border border-border bg-transparent px-1 py-0.5 text-xs";
|
|
2931
|
+
var btn4 = "rounded border border-border px-1.5 py-0.5 text-[11px] disabled:opacity-40";
|
|
2932
|
+
function ShotInspector({ controller, shot, className = "" }) {
|
|
2933
|
+
const state = useAnimationEditorState(controller);
|
|
2934
|
+
const { scene, selection, readOnly, error } = state;
|
|
2935
|
+
const [local, setLocalState] = (0, import_react21.useState)(null);
|
|
2936
|
+
const setLocal = (text) => setLocalState(text ? { text, revision: state.revision } : null);
|
|
2937
|
+
const elements = (0, import_react21.useMemo)(() => (0, import_animation_editor10.describeMotionElements)(scene), [scene.artwork]);
|
|
2938
|
+
const cues = (0, import_react21.useMemo)(() => (0, import_animation_editor10.motionCueChoices)(scene), [scene]);
|
|
2939
|
+
const id = shot ?? selection?.shot ?? scene.shots[0]?.id;
|
|
2940
|
+
const index = scene.shots.findIndex((s) => s.id === id);
|
|
2941
|
+
const current = scene.shots[index];
|
|
2942
|
+
const apply = (edit, label) => {
|
|
2943
|
+
setLocal(null);
|
|
2944
|
+
return controller.apply(edit, label);
|
|
2945
|
+
};
|
|
2946
|
+
const addShot = () => {
|
|
2947
|
+
const newId = (0, import_animation_editor10.freshShotId)(scene, "shot");
|
|
2948
|
+
const at = index >= 0 ? index + 1 : scene.shots.length;
|
|
2949
|
+
if (apply({ op: "insert_shots", shots: [{ id: newId, label: "New shot", run: [] }], at }, "Add shot").ok) {
|
|
2950
|
+
controller.select({ shot: newId });
|
|
2951
|
+
controller.seekShot(newId);
|
|
2952
|
+
}
|
|
2953
|
+
};
|
|
2954
|
+
const number = (key, raw, label) => {
|
|
2955
|
+
const n = Number(raw);
|
|
2956
|
+
if (raw.trim() === "") return apply({ op: "update_shot", shot: current.id, remove: [key] }, label);
|
|
2957
|
+
if (!Number.isFinite(n) || n < 0 || key === "speed" && n <= 0) return setLocal(key === "speed" ? "Speed must be a number above 0 (1 = as written)." : "Hold must be a number of ms, 0 or more.");
|
|
2958
|
+
apply({ op: "update_shot", shot: current.id, set: { [key]: n } }, label);
|
|
2959
|
+
};
|
|
2960
|
+
const message = (local && local.revision === state.revision ? local.text : null) ?? error;
|
|
2961
|
+
const cueKey = current ? (0, import_animation_editor10.motionCueKey)(current.at) : "";
|
|
2962
|
+
const frame = current?.camera && "frame" in current.camera ? current.camera.frame : "";
|
|
2963
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: `flex flex-col gap-1.5 text-xs ${className}`, "data-shot-inspector": "", children: [
|
|
2964
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
2965
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: "font-medium", children: "Shot" }),
|
|
2966
|
+
current && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("code", { className: "text-[10px] text-muted-foreground", children: current.id }),
|
|
2967
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("span", { className: "ml-auto flex gap-0.5", children: [
|
|
2968
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("button", { type: "button", className: btn4, disabled: readOnly, onClick: addShot, "data-add-shot": "", children: "+ Shot" }),
|
|
2969
|
+
current && /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(import_jsx_runtime20.Fragment, { children: [
|
|
2970
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("button", { type: "button", className: btn4, "aria-label": "Move shot earlier", disabled: readOnly || index === 0, onClick: () => apply({ op: "move_shot", shot: current.id, to: index - 1 }, "Move shot"), children: "\u2190" }),
|
|
2971
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("button", { type: "button", className: btn4, "aria-label": "Move shot later", disabled: readOnly || index === scene.shots.length - 1, onClick: () => apply({ op: "move_shot", shot: current.id, to: index + 1 }, "Move shot"), children: "\u2192" }),
|
|
2972
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("button", { type: "button", className: btn4, "aria-label": "Delete shot", disabled: readOnly, onClick: () => apply({ op: "delete_shots", shots: [current.id] }, "Delete shot"), children: "\u2715" })
|
|
2973
|
+
] })
|
|
2974
|
+
] })
|
|
2975
|
+
] }),
|
|
2976
|
+
current && /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "grid grid-cols-[6.5rem_1fr] items-center gap-x-2 gap-y-1", children: [
|
|
2977
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("label", { className: "text-muted-foreground", children: "Label" }),
|
|
2978
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(CommitInput, { className: input4, "aria-label": "Shot label", disabled: readOnly, value: current.label ?? "", onCommit: (raw) => apply(raw.trim() ? { op: "update_shot", shot: current.id, set: { label: raw.trim() } } : { op: "update_shot", shot: current.id, remove: ["label"] }, "Rename shot") }),
|
|
2979
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("label", { className: "text-muted-foreground", children: "Hold" }),
|
|
2980
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
2981
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(CommitInput, { className: input4, type: "number", min: 0, step: 50, "aria-label": "Hold", placeholder: "600", disabled: readOnly, value: current.hold !== void 0 ? String(current.hold) : "", onCommit: (raw) => number("hold", raw, "Change hold") }),
|
|
2982
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: "text-[10px] text-muted-foreground", children: "ms" })
|
|
2983
|
+
] }),
|
|
2984
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("label", { className: "text-muted-foreground", children: "Speed" }),
|
|
2985
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
2986
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(CommitInput, { className: input4, type: "number", min: 0.05, step: 0.05, "aria-label": "Speed", placeholder: "1", disabled: readOnly, value: current.speed !== void 0 ? String(current.speed) : "", onCommit: (raw) => number("speed", raw, "Change speed") }),
|
|
2987
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: "text-[10px] text-muted-foreground", children: "\xD7" })
|
|
2988
|
+
] }),
|
|
2989
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("label", { className: "text-muted-foreground", children: "Camera" }),
|
|
2990
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
|
|
2991
|
+
"select",
|
|
2992
|
+
{
|
|
2993
|
+
className: input4,
|
|
2994
|
+
"aria-label": "Camera frames",
|
|
2995
|
+
disabled: readOnly,
|
|
2996
|
+
value: current.camera && (0, import_animation_editor10.motionCameraFramed)(current.camera) ? frame ? `frame:${frame}` : "rect" : "",
|
|
2997
|
+
onChange: (e) => {
|
|
2998
|
+
const v = e.target.value;
|
|
2999
|
+
const moves = { ...current.camera?.in !== void 0 ? { in: current.camera.in } : {}, ...current.camera?.during !== void 0 ? { during: current.camera.during } : {} };
|
|
3000
|
+
if (!v) apply(Object.keys(moves).length ? { op: "update_shot", shot: current.id, set: { camera: moves } } : { op: "update_shot", shot: current.id, remove: ["camera"] }, "Clear camera");
|
|
3001
|
+
else if (v.startsWith("frame:")) apply({ op: "update_shot", shot: current.id, set: { camera: { ...moves, frame: v.slice(6), padding: 24 } } }, "Frame camera");
|
|
3002
|
+
},
|
|
3003
|
+
children: [
|
|
3004
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("option", { value: "", children: "keep framing" }),
|
|
3005
|
+
current.camera && (0, import_animation_editor10.motionCameraFramed)(current.camera) && !frame && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("option", { value: "rect", children: "a rectangle" }),
|
|
3006
|
+
elements.map((e) => /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("option", { value: `frame:${e.id}`, children: [
|
|
3007
|
+
"frame ",
|
|
3008
|
+
e.name ?? e.id
|
|
3009
|
+
] }, e.id))
|
|
3010
|
+
]
|
|
3011
|
+
}
|
|
3012
|
+
),
|
|
3013
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("label", { className: "text-muted-foreground", children: "Starts on" }),
|
|
3014
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
|
|
3015
|
+
"select",
|
|
3016
|
+
{
|
|
3017
|
+
className: input4,
|
|
3018
|
+
"aria-label": "Cue",
|
|
3019
|
+
disabled: readOnly || index === 0,
|
|
3020
|
+
value: cueKey,
|
|
3021
|
+
onChange: (e) => {
|
|
3022
|
+
const cue = (0, import_animation_editor10.motionCueFromKey)(e.target.value);
|
|
3023
|
+
apply(cue ? { op: "update_shot", shot: current.id, set: { at: cue } } : { op: "update_shot", shot: current.id, remove: ["at"] }, "Cue shot");
|
|
3024
|
+
},
|
|
3025
|
+
children: [
|
|
3026
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("option", { value: "", children: "after the shot before" }),
|
|
3027
|
+
cueKey && !cues.some((c) => c.value === cueKey) && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("option", { value: cueKey, children: cueKey }),
|
|
3028
|
+
cues.map((c) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("option", { value: c.value, children: c.label }, c.value))
|
|
3029
|
+
]
|
|
3030
|
+
}
|
|
3031
|
+
),
|
|
3032
|
+
!cues.length && index > 0 && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("p", { className: "col-span-2 text-[10px] text-muted-foreground", children: "Add a beat grid or narration in the scene settings to cue shots to them." })
|
|
3033
|
+
] }),
|
|
3034
|
+
current && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ShotCameraMoves, { controller, shot: current.id }),
|
|
3035
|
+
message && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("p", { className: "text-red-500", role: "alert", "data-edit-error": "", children: message })
|
|
3036
|
+
] });
|
|
3037
|
+
}
|
|
3038
|
+
|
|
3039
|
+
// src/animation-editor/AnimationEffectsPanel.tsx
|
|
3040
|
+
var import_react22 = require("react");
|
|
3041
|
+
var import_animation_editor11 = require("@pixerate/editor/animation-editor");
|
|
3042
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
2915
3043
|
var btn5 = "rounded border border-border px-1.5 py-0.5 text-[11px] disabled:opacity-40";
|
|
2916
3044
|
function Controls({ controller, instance, effect, values }) {
|
|
2917
3045
|
const provider = controller.effectsProvider;
|
|
2918
3046
|
const { description, error } = useEffectDescription(provider, effect);
|
|
2919
|
-
const [message, setMessage] = (0,
|
|
3047
|
+
const [message, setMessage] = (0, import_react22.useState)(null);
|
|
2920
3048
|
const report = (r) => void r.then((x) => setMessage(x.ok ? null : x.error));
|
|
2921
|
-
if (!provider) return /* @__PURE__ */ (0,
|
|
2922
|
-
if (error) return /* @__PURE__ */ (0,
|
|
2923
|
-
if (!description) return /* @__PURE__ */ (0,
|
|
2924
|
-
return /* @__PURE__ */ (0,
|
|
2925
|
-
/* @__PURE__ */ (0,
|
|
3049
|
+
if (!provider) return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No effects provider: its commands are kept as they are." });
|
|
3050
|
+
if (error) return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("p", { className: "text-[11px] text-amber-500", children: error });
|
|
3051
|
+
if (!description) return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "Loading\u2026" });
|
|
3052
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(import_jsx_runtime21.Fragment, { children: [
|
|
3053
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2926
3054
|
EffectParameters,
|
|
2927
3055
|
{
|
|
2928
3056
|
description,
|
|
@@ -2932,60 +3060,60 @@ function Controls({ controller, instance, effect, values }) {
|
|
|
2932
3060
|
onPreset: (v) => report(controller.updateMotionEffect(instance, v))
|
|
2933
3061
|
}
|
|
2934
3062
|
),
|
|
2935
|
-
message && /* @__PURE__ */ (0,
|
|
3063
|
+
message && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("p", { role: "alert", className: "text-[11px] text-destructive", children: message })
|
|
2936
3064
|
] });
|
|
2937
3065
|
}
|
|
2938
3066
|
function AnimationEffectsPanel({ controller, node, className = "" }) {
|
|
2939
3067
|
const state = useAnimationEditorState(controller);
|
|
2940
3068
|
const provider = state.effectsProvider;
|
|
2941
|
-
const nodes = (0,
|
|
2942
|
-
const [chosen, setChosen] = (0,
|
|
3069
|
+
const nodes = (0, import_react22.useMemo)(() => [...(0, import_animation_editor11.indexMotionNodes)(state.scene.artwork.nodes).keys()], [state.scene.artwork]);
|
|
3070
|
+
const [chosen, setChosen] = (0, import_react22.useState)("");
|
|
2943
3071
|
const target = node && nodes.includes(node) ? node : chosen && nodes.includes(chosen) ? chosen : "";
|
|
2944
|
-
const [browse, setBrowse] = (0,
|
|
2945
|
-
const [open, setOpen] = (0,
|
|
2946
|
-
const [message, setMessage] = (0,
|
|
3072
|
+
const [browse, setBrowse] = (0, import_react22.useState)(null);
|
|
3073
|
+
const [open, setOpen] = (0, import_react22.useState)(null);
|
|
3074
|
+
const [message, setMessage] = (0, import_react22.useState)(null);
|
|
2947
3075
|
const report = (r) => void Promise.resolve(r).then((x) => setMessage(x.ok ? x.notes.length ? x.notes.join(" ") : null : x.error));
|
|
2948
|
-
const applied = (0,
|
|
3076
|
+
const applied = (0, import_react22.useMemo)(() => controller.appliedEffects(), [controller, state.scene]);
|
|
2949
3077
|
const disabled = state.readOnly;
|
|
2950
|
-
return /* @__PURE__ */ (0,
|
|
2951
|
-
/* @__PURE__ */ (0,
|
|
2952
|
-
/* @__PURE__ */ (0,
|
|
2953
|
-
/* @__PURE__ */ (0,
|
|
2954
|
-
/* @__PURE__ */ (0,
|
|
2955
|
-
nodes.map((id) => /* @__PURE__ */ (0,
|
|
3078
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("section", { className: `flex flex-col gap-2 text-xs ${className}`, "aria-label": "Effects", "data-animation-effects": "", children: [
|
|
3079
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "flex flex-wrap items-center gap-1", children: [
|
|
3080
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { className: "flex-1 font-semibold", children: "Effects" }),
|
|
3081
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("select", { className: "rounded border border-border bg-transparent px-1 py-0.5 text-[11px]", "aria-label": "Node to animate", value: target, disabled: !!node, onChange: (e) => setChosen(e.currentTarget.value), children: [
|
|
3082
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("option", { value: "", children: "Node\u2026" }),
|
|
3083
|
+
nodes.map((id) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("option", { value: id, children: id }, id))
|
|
2956
3084
|
] }),
|
|
2957
|
-
/* @__PURE__ */ (0,
|
|
2958
|
-
/* @__PURE__ */ (0,
|
|
3085
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("button", { type: "button", className: btn5, disabled: disabled || !provider || !target, "aria-pressed": browse === "motion", onClick: () => setBrowse(browse === "motion" ? null : "motion"), children: "Animate\u2026" }),
|
|
3086
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("button", { type: "button", className: btn5, disabled: disabled || !provider, "aria-pressed": browse === "vector", onClick: () => setBrowse(browse === "vector" ? null : "vector"), children: "Vector effect\u2026" })
|
|
2959
3087
|
] }),
|
|
2960
|
-
!provider && /* @__PURE__ */ (0,
|
|
2961
|
-
browse === "motion" && /* @__PURE__ */ (0,
|
|
2962
|
-
browse === "vector" && /* @__PURE__ */ (0,
|
|
2963
|
-
/* @__PURE__ */ (0,
|
|
2964
|
-
/* @__PURE__ */ (0,
|
|
2965
|
-
/* @__PURE__ */ (0,
|
|
3088
|
+
!provider && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No effects provider is registered. Commands effects made are kept." }),
|
|
3089
|
+
browse === "motion" && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(EffectsBrowser, { provider, uses: ["motion"], kinds: ["motion"], title: `Motion for ${target}`, onPick: (e) => (setBrowse(null), report(controller.applyMotionEffect(e.id, [target]))) }),
|
|
3090
|
+
browse === "vector" && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(EffectsBrowser, { provider, kinds: ["vector"], title: "Vector effects", onPick: (e) => (setBrowse(null), report(controller.addVectorEffect(e.id))) }),
|
|
3091
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("ol", { className: "space-y-1", children: applied.map((e) => /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("li", { className: "rounded border border-border p-1", "data-motion-effect": e.instance, children: [
|
|
3092
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
3093
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("button", { type: "button", className: "min-w-0 flex-1 truncate text-left", "aria-expanded": open === e.instance, onClick: () => setOpen(open === e.instance ? null : e.instance), children: [
|
|
2966
3094
|
e.name ?? e.effect,
|
|
2967
3095
|
" ",
|
|
2968
|
-
/* @__PURE__ */ (0,
|
|
3096
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("span", { className: "text-muted-foreground", children: [
|
|
2969
3097
|
"\xB7 ",
|
|
2970
3098
|
e.kind === "vector" ? "picture" : e.targets.join(", ")
|
|
2971
3099
|
] })
|
|
2972
3100
|
] }),
|
|
2973
|
-
/* @__PURE__ */ (0,
|
|
3101
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("button", { type: "button", className: btn5, disabled, "aria-label": `Remove ${e.name ?? e.effect}`, onClick: () => report(controller.removeMotionEffect(e.instance)), children: "\u2715" })
|
|
2974
3102
|
] }),
|
|
2975
|
-
open === e.instance && /* @__PURE__ */ (0,
|
|
3103
|
+
open === e.instance && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "mt-1", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Controls, { controller, instance: e.instance, effect: e.effect, values: e.values }) })
|
|
2976
3104
|
] }, e.instance)) }),
|
|
2977
|
-
!applied.length && /* @__PURE__ */ (0,
|
|
2978
|
-
message && /* @__PURE__ */ (0,
|
|
3105
|
+
!applied.length && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No provider effects in this scene." }),
|
|
3106
|
+
message && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("p", { role: "status", className: "text-[11px] text-muted-foreground", "data-effects-message": "", children: message })
|
|
2979
3107
|
] });
|
|
2980
3108
|
}
|
|
2981
3109
|
|
|
2982
3110
|
// src/animation-editor/AnimationEditor.tsx
|
|
2983
|
-
var
|
|
3111
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
2984
3112
|
var ONION = { before: 3, after: 1 };
|
|
2985
3113
|
var btn6 = "rounded border border-border px-2 py-0.5 text-xs disabled:opacity-40";
|
|
2986
3114
|
function AnimationEditor({ controller, values, onionSkin, motionPaths, showIssues = true, editable = true, effects, className = "", playback, playbackId = "animation", onPlaybackReveal }) {
|
|
2987
3115
|
const state = useAnimationEditorState(controller);
|
|
2988
|
-
const rootRef = (0,
|
|
3116
|
+
const rootRef = (0, import_react23.useRef)(null);
|
|
2989
3117
|
const ambientPlayback = useAgentPlayback();
|
|
2990
3118
|
const playing = (playback === void 0 ? ambientPlayback : playback) ?? null;
|
|
2991
3119
|
const rectIn = (el) => {
|
|
@@ -3020,16 +3148,16 @@ function AnimationEditor({ controller, values, onionSkin, motionPaths, showIssue
|
|
|
3020
3148
|
},
|
|
3021
3149
|
reveal: () => onPlaybackReveal?.()
|
|
3022
3150
|
});
|
|
3023
|
-
const presenceLayer = playing ? /* @__PURE__ */ (0,
|
|
3151
|
+
const presenceLayer = playing ? /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(PresenceLayer, { presence: agentPresence }) : null;
|
|
3024
3152
|
useEffects(controller, effects);
|
|
3025
3153
|
const { issues, scene, selection, readOnly } = state;
|
|
3026
|
-
const [picked, setPicked] = (0,
|
|
3027
|
-
const [onion, setOnion] = (0,
|
|
3028
|
-
const [paths, setPaths] = (0,
|
|
3029
|
-
const [recordMode, setRecordMode] = (0,
|
|
3154
|
+
const [picked, setPicked] = (0, import_react23.useState)(null);
|
|
3155
|
+
const [onion, setOnion] = (0, import_react23.useState)(false);
|
|
3156
|
+
const [paths, setPaths] = (0, import_react23.useState)(false);
|
|
3157
|
+
const [recordMode, setRecordMode] = (0, import_react23.useState)("move");
|
|
3030
3158
|
const command = selection?.command !== void 0 ? scene.shots.find((s) => s.id === selection.shot)?.run[selection.command] : void 0;
|
|
3031
3159
|
const targets = command && "targets" in command ? command.targets : [];
|
|
3032
|
-
const nodes = (0,
|
|
3160
|
+
const nodes = (0, import_react23.useMemo)(() => (0, import_animation_editor12.indexMotionNodes)(scene.artwork.nodes), [scene.artwork]);
|
|
3033
3161
|
const pickedValid = picked && nodes.has(picked) ? picked : null;
|
|
3034
3162
|
const onPick = (id, event) => {
|
|
3035
3163
|
if (event.shiftKey && id && command && "targets" in command && selection?.command !== void 0 && !readOnly) {
|
|
@@ -3039,7 +3167,7 @@ function AnimationEditor({ controller, values, onionSkin, motionPaths, showIssue
|
|
|
3039
3167
|
}
|
|
3040
3168
|
setPicked(id);
|
|
3041
3169
|
};
|
|
3042
|
-
const stage = /* @__PURE__ */ (0,
|
|
3170
|
+
const stage = /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
3043
3171
|
AnimationStage,
|
|
3044
3172
|
{
|
|
3045
3173
|
controller,
|
|
@@ -3052,15 +3180,15 @@ function AnimationEditor({ controller, values, onionSkin, motionPaths, showIssue
|
|
|
3052
3180
|
className: "rounded-md border border-border bg-muted/40"
|
|
3053
3181
|
}
|
|
3054
3182
|
);
|
|
3055
|
-
const issueList = showIssues && issues.length > 0 && /* @__PURE__ */ (0,
|
|
3183
|
+
const issueList = showIssues && issues.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("ul", { className: "space-y-0.5 text-xs", "aria-label": "Animation issues", children: issues.map((issue, i) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("li", { className: issue.severity === "error" ? "text-red-500" : issue.severity === "warning" ? "text-amber-500" : "text-muted-foreground", children: (0, import_animation_editor12.motionIssueLine)(issue) }, i)) });
|
|
3056
3184
|
if (!editable)
|
|
3057
|
-
return /* @__PURE__ */ (0,
|
|
3185
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { ref: rootRef, className: `relative flex flex-col gap-2 ${className}`, "data-animation-editor": "", children: [
|
|
3058
3186
|
presenceLayer,
|
|
3059
3187
|
stage,
|
|
3060
|
-
/* @__PURE__ */ (0,
|
|
3188
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(PlayheadScrubber, { controller }),
|
|
3061
3189
|
issueList
|
|
3062
3190
|
] });
|
|
3063
|
-
return /* @__PURE__ */ (0,
|
|
3191
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
|
|
3064
3192
|
"div",
|
|
3065
3193
|
{
|
|
3066
3194
|
ref: rootRef,
|
|
@@ -3075,41 +3203,41 @@ function AnimationEditor({ controller, values, onionSkin, motionPaths, showIssue
|
|
|
3075
3203
|
},
|
|
3076
3204
|
children: [
|
|
3077
3205
|
presenceLayer,
|
|
3078
|
-
/* @__PURE__ */ (0,
|
|
3206
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "flex min-w-0 flex-col gap-2", children: [
|
|
3079
3207
|
stage,
|
|
3080
|
-
/* @__PURE__ */ (0,
|
|
3081
|
-
/* @__PURE__ */ (0,
|
|
3082
|
-
/* @__PURE__ */ (0,
|
|
3083
|
-
/* @__PURE__ */ (0,
|
|
3084
|
-
onionSkin === void 0 && /* @__PURE__ */ (0,
|
|
3085
|
-
/* @__PURE__ */ (0,
|
|
3208
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(PlayheadScrubber, { controller }),
|
|
3209
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "flex flex-wrap items-center gap-2 text-xs text-muted-foreground", children: [
|
|
3210
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("button", { type: "button", className: btn6, onClick: () => controller.undo(), disabled: !state.canUndo, title: state.canUndo ? `Undo ${state.undoLabel}` : "Nothing to undo", "data-undo": "", children: "Undo" }),
|
|
3211
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("button", { type: "button", className: btn6, onClick: () => controller.redo(), disabled: !state.canRedo, title: state.canRedo ? `Redo ${state.redoLabel}` : "Nothing to redo", "data-redo": "", children: "Redo" }),
|
|
3212
|
+
onionSkin === void 0 && /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
3213
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("input", { type: "checkbox", checked: onion, onChange: (e) => setOnion(e.target.checked) }),
|
|
3086
3214
|
" Onion skin"
|
|
3087
3215
|
] }),
|
|
3088
|
-
motionPaths === void 0 && /* @__PURE__ */ (0,
|
|
3089
|
-
/* @__PURE__ */ (0,
|
|
3216
|
+
motionPaths === void 0 && /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
3217
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("input", { type: "checkbox", checked: paths, onChange: (e) => setPaths(e.target.checked) }),
|
|
3090
3218
|
" Motion paths"
|
|
3091
3219
|
] }),
|
|
3092
|
-
/* @__PURE__ */ (0,
|
|
3220
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { className: "ml-auto", "data-picked-element": pickedValid ?? void 0, children: pickedValid ? /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(import_jsx_runtime22.Fragment, { children: [
|
|
3093
3221
|
"Picked ",
|
|
3094
|
-
/* @__PURE__ */ (0,
|
|
3222
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("code", { className: "text-rose-500", children: pickedValid }),
|
|
3095
3223
|
" ",
|
|
3096
|
-
/* @__PURE__ */ (0,
|
|
3224
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("button", { type: "button", className: "underline", onClick: () => setPicked(null), children: "clear" })
|
|
3097
3225
|
] }) : "Click the stage to pick an element; shift-click to toggle it as a target." })
|
|
3098
3226
|
] }),
|
|
3099
|
-
!readOnly && /* @__PURE__ */ (0,
|
|
3227
|
+
!readOnly && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(AnimationRecordPanel, { controller, node: pickedValid, mode: recordMode, onModeChange: setRecordMode, className: "border-t border-border pt-2" }),
|
|
3100
3228
|
issueList
|
|
3101
3229
|
] }),
|
|
3102
|
-
/* @__PURE__ */ (0,
|
|
3103
|
-
/* @__PURE__ */ (0,
|
|
3104
|
-
(state.effectsProvider || controller.appliedEffects().length > 0) && /* @__PURE__ */ (0,
|
|
3105
|
-
/* @__PURE__ */ (0,
|
|
3106
|
-
/* @__PURE__ */ (0,
|
|
3107
|
-
/* @__PURE__ */ (0,
|
|
3108
|
-
/* @__PURE__ */ (0,
|
|
3230
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "flex min-w-0 flex-col gap-3", children: [
|
|
3231
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(CommandList, { controller, targets: pickedValid ? [pickedValid] : void 0 }),
|
|
3232
|
+
(state.effectsProvider || controller.appliedEffects().length > 0) && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(AnimationEffectsPanel, { controller, node: pickedValid, className: "border-t border-border pt-2" }),
|
|
3233
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(CommandInspector, { controller, picked: pickedValid, className: "border-t border-border pt-2" }),
|
|
3234
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("details", { open: true, className: "border-t border-border pt-2", children: [
|
|
3235
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("summary", { className: "cursor-pointer text-xs font-medium", children: "Shot" }),
|
|
3236
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(ShotInspector, { controller, className: "mt-1" })
|
|
3109
3237
|
] }),
|
|
3110
|
-
/* @__PURE__ */ (0,
|
|
3111
|
-
/* @__PURE__ */ (0,
|
|
3112
|
-
/* @__PURE__ */ (0,
|
|
3238
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("details", { className: "border-t border-border pt-2", children: [
|
|
3239
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("summary", { className: "cursor-pointer text-xs font-medium", children: "Scene settings" }),
|
|
3240
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(SceneSettings, { controller, className: "mt-1" })
|
|
3113
3241
|
] })
|
|
3114
3242
|
] })
|
|
3115
3243
|
]
|
|
@@ -3127,6 +3255,7 @@ function AnimationEditor({ controller, values, onionSkin, motionPaths, showIssue
|
|
|
3127
3255
|
EasePicker,
|
|
3128
3256
|
PlayheadScrubber,
|
|
3129
3257
|
SceneSettings,
|
|
3258
|
+
ShotCameraMoves,
|
|
3130
3259
|
ShotInspector,
|
|
3131
3260
|
ShotTimeline,
|
|
3132
3261
|
useAnimationEditor,
|