@pixerate/editor-react 0.114.2 → 0.114.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/animation-editor/index.cjs +342 -215
- package/dist/animation-editor/index.js +2 -2
- package/dist/canvas/index.cjs +520 -393
- package/dist/canvas/index.js +2 -2
- package/dist/{chunk-5LFQ2UQZ.js → chunk-354TA5QV.js} +221 -101
- package/dist/{chunk-2INOKIJN.js → chunk-SH63DFOO.js} +345 -297
- package/dist/{chunk-BWEARAWR.js → chunk-TOGMXZM4.js} +40 -18
- package/dist/effects/EffectParameters.d.cts +4 -1
- package/dist/effects/EffectParameters.d.ts +4 -1
- package/dist/effects/index.cjs +348 -221
- package/dist/effects/index.js +2 -2
- package/dist/image-editor/ImageEffectControls.d.cts +4 -1
- package/dist/image-editor/ImageEffectControls.d.ts +4 -1
- package/dist/image-editor/ImageProviderEffectsPanel.d.cts +4 -1
- package/dist/image-editor/ImageProviderEffectsPanel.d.ts +4 -1
- package/dist/image-editor/controls/parameterControls.d.cts +4 -0
- package/dist/image-editor/controls/parameterControls.d.ts +4 -0
- package/dist/image-editor/index.cjs +868 -697
- package/dist/image-editor/index.js +3 -3
- package/dist/index.cjs +1388 -1217
- package/dist/index.js +3 -3
- package/dist/paint-editor/index.cjs +335 -208
- package/dist/paint-editor/index.js +2 -2
- package/dist/parameters/ParametersPanel.d.cts +4 -1
- package/dist/parameters/ParametersPanel.d.ts +4 -1
- package/dist/parameters/controls.d.cts +72 -0
- package/dist/parameters/controls.d.ts +72 -0
- package/dist/parameters/fields.d.cts +19 -6
- package/dist/parameters/fields.d.ts +19 -6
- package/dist/parameters/index.cjs +350 -183
- package/dist/parameters/index.d.cts +1 -0
- package/dist/parameters/index.d.ts +1 -0
- package/dist/parameters/index.js +70 -14
- package/dist/vector/index.cjs +321 -194
- package/dist/vector/index.js +2 -2
- package/dist/video-editor/index.cjs +418 -291
- package/dist/video-editor/index.js +2 -2
- package/package.json +3 -3
|
@@ -34,6 +34,7 @@ __export(parameters_exports, {
|
|
|
34
34
|
KeyframeDiamond: () => KeyframeDiamond,
|
|
35
35
|
ParameterColor: () => ParameterColor,
|
|
36
36
|
ParameterCommitInput: () => ParameterCommitInput,
|
|
37
|
+
ParameterComponentsProvider: () => ParameterComponentsProvider,
|
|
37
38
|
ParameterFieldControl: () => ParameterFieldControl,
|
|
38
39
|
ParameterImage: () => ParameterImage,
|
|
39
40
|
ParameterNumberInput: () => ParameterNumberInput,
|
|
@@ -44,8 +45,14 @@ __export(parameters_exports, {
|
|
|
44
45
|
ParameterVector: () => ParameterVector,
|
|
45
46
|
ParametersPanel: () => ParametersPanel,
|
|
46
47
|
parameterButtonClass: () => parameterButtonClass,
|
|
48
|
+
parameterButtonStyle: () => parameterButtonStyle,
|
|
47
49
|
parameterInputClass: () => parameterInputClass,
|
|
50
|
+
parameterInputStyle: () => parameterInputStyle,
|
|
51
|
+
parameterRangeStyle: () => parameterRangeStyle,
|
|
52
|
+
parameterSelectStyle: () => parameterSelectStyle,
|
|
53
|
+
resolveParameterComponents: () => resolveParameterComponents,
|
|
48
54
|
useParameterCommands: () => useParameterCommands,
|
|
55
|
+
useParameterComponents: () => useParameterComponents,
|
|
49
56
|
useParameters: () => useParameters,
|
|
50
57
|
useParametersController: () => useParametersController,
|
|
51
58
|
useParametersState: () => useParametersState
|
|
@@ -105,7 +112,7 @@ function useParameterCommands(registry, controller, options = {}) {
|
|
|
105
112
|
}
|
|
106
113
|
|
|
107
114
|
// src/parameters/fields.tsx
|
|
108
|
-
var
|
|
115
|
+
var import_react6 = require("react");
|
|
109
116
|
var import_parameters2 = require("@pixerate/editor/parameters");
|
|
110
117
|
|
|
111
118
|
// src/color/index.ts
|
|
@@ -1147,18 +1154,60 @@ function useResolvedColor(value, scheme) {
|
|
|
1147
1154
|
// src/color/index.ts
|
|
1148
1155
|
__reExport(color_exports, require("@pixerate/editor/color"));
|
|
1149
1156
|
|
|
1150
|
-
// src/parameters/
|
|
1157
|
+
// src/parameters/controls.tsx
|
|
1158
|
+
var import_react5 = require("react");
|
|
1151
1159
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
1160
|
+
var ParameterComponentsContext = (0, import_react5.createContext)({});
|
|
1161
|
+
function ParameterComponentsProvider({ components, children }) {
|
|
1162
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ParameterComponentsContext.Provider, { value: components, children });
|
|
1163
|
+
}
|
|
1164
|
+
function useParameterComponents() {
|
|
1165
|
+
return (0, import_react5.useContext)(ParameterComponentsContext);
|
|
1166
|
+
}
|
|
1167
|
+
function resolveParameterComponents(explicit, context) {
|
|
1168
|
+
return {
|
|
1169
|
+
input: explicit?.input ?? context?.input,
|
|
1170
|
+
slider: explicit?.slider ?? context?.slider,
|
|
1171
|
+
select: explicit?.select ?? context?.select
|
|
1172
|
+
};
|
|
1173
|
+
}
|
|
1174
|
+
|
|
1175
|
+
// src/parameters/fields.tsx
|
|
1176
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
1177
|
+
var parameterInputStyle = import_parameters2.parameterThemeStyles.input;
|
|
1178
|
+
var parameterSelectStyle = import_parameters2.parameterThemeStyles.select;
|
|
1179
|
+
var parameterButtonStyle = import_parameters2.parameterThemeStyles.button;
|
|
1180
|
+
var parameterRangeStyle = import_parameters2.parameterThemeStyles.range;
|
|
1152
1181
|
var parameterInputClass = "h-7 w-full min-w-0 rounded-md border border-input bg-background px-2 text-xs text-foreground tabular-nums focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary disabled:cursor-not-allowed disabled:opacity-50";
|
|
1153
1182
|
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";
|
|
1154
1183
|
var rangeClass = "h-4 w-full min-w-0 flex-1 cursor-pointer accent-primary disabled:cursor-not-allowed disabled:opacity-50";
|
|
1155
|
-
function ParameterCommitInput({ value, onCommit, multiline, className, onKeyDown, ...rest }) {
|
|
1184
|
+
function ParameterCommitInput({ value, onCommit, multiline, className, onKeyDown, style, ...rest }) {
|
|
1185
|
+
const inputRef = (0, import_react6.useRef)(null);
|
|
1186
|
+
const lastCommitted = (0, import_react6.useRef)(null);
|
|
1187
|
+
(0, import_react6.useLayoutEffect)(() => {
|
|
1188
|
+
lastCommitted.current = null;
|
|
1189
|
+
const el = inputRef.current;
|
|
1190
|
+
if (el && el.value !== value) el.value = value;
|
|
1191
|
+
}, [value]);
|
|
1156
1192
|
const commit = (el) => {
|
|
1157
|
-
|
|
1193
|
+
const text = el.value;
|
|
1194
|
+
if (text === value || text === lastCommitted.current) return;
|
|
1195
|
+
onCommit(text, el);
|
|
1196
|
+
lastCommitted.current = el.value === text ? text : null;
|
|
1158
1197
|
};
|
|
1198
|
+
const commitRef = (0, import_react6.useRef)(commit);
|
|
1199
|
+
commitRef.current = commit;
|
|
1200
|
+
(0, import_react6.useEffect)(() => {
|
|
1201
|
+
const el = inputRef.current;
|
|
1202
|
+
if (!el) return;
|
|
1203
|
+
const change = () => commitRef.current(el);
|
|
1204
|
+
el.addEventListener("change", change);
|
|
1205
|
+
return () => el.removeEventListener("change", change);
|
|
1206
|
+
}, [multiline]);
|
|
1159
1207
|
const keyDown = (e) => {
|
|
1160
1208
|
onKeyDown?.(e);
|
|
1161
1209
|
if (e.defaultPrevented) return;
|
|
1210
|
+
if (e.key === "Tab") commit(e.currentTarget);
|
|
1162
1211
|
if (e.key === "Enter" && (!multiline || e.metaKey || e.ctrlKey)) {
|
|
1163
1212
|
e.preventDefault();
|
|
1164
1213
|
commit(e.currentTarget);
|
|
@@ -1168,86 +1217,114 @@ function ParameterCommitInput({ value, onCommit, multiline, className, onKeyDown
|
|
|
1168
1217
|
const props = {
|
|
1169
1218
|
defaultValue: value,
|
|
1170
1219
|
className: className ?? parameterInputClass,
|
|
1220
|
+
style: { ...parameterInputStyle, ...style },
|
|
1171
1221
|
onBlur: (e) => commit(e.currentTarget),
|
|
1172
1222
|
onKeyDown: keyDown,
|
|
1173
1223
|
...rest
|
|
1174
1224
|
};
|
|
1175
|
-
|
|
1225
|
+
const forwarded = rest.ref;
|
|
1226
|
+
const setRef = (el) => {
|
|
1227
|
+
inputRef.current = el;
|
|
1228
|
+
if (typeof forwarded === "function") forwarded(el);
|
|
1229
|
+
else if (forwarded) forwarded.current = el;
|
|
1230
|
+
};
|
|
1231
|
+
return multiline ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("textarea", { ...props, ref: setRef, className: `${props.className} h-auto min-h-[3.5rem] py-1` }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("input", { type: "text", ...props, ref: setRef });
|
|
1176
1232
|
}
|
|
1177
1233
|
var plainNumber = (field, value) => (0, import_parameters2.formatParameterNumber)({ ...field, unit: void 0 }, value);
|
|
1178
|
-
function ParameterNumberInput({
|
|
1179
|
-
field,
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1234
|
+
function ParameterNumberInput(props) {
|
|
1235
|
+
const { field, value, onChange, disabled, id, components, "aria-label": ariaLabel } = props;
|
|
1236
|
+
const ctx = useParameterComponents();
|
|
1237
|
+
const resolved = resolveParameterComponents(components, ctx);
|
|
1238
|
+
const CustomInput = resolved.input;
|
|
1239
|
+
const plain = plainNumber(field, value);
|
|
1240
|
+
const handleCommit = (text, input) => {
|
|
1241
|
+
const n = (0, import_parameters2.parseParameterNumberInput)(field, text);
|
|
1242
|
+
if (n === null || n === value) {
|
|
1243
|
+
if (input) input.value = plain;
|
|
1244
|
+
} else {
|
|
1245
|
+
onChange(n);
|
|
1246
|
+
}
|
|
1247
|
+
};
|
|
1248
|
+
const handleKeyDown = (e) => {
|
|
1249
|
+
if (e.key !== "ArrowUp" && e.key !== "ArrowDown") return;
|
|
1250
|
+
e.preventDefault();
|
|
1251
|
+
const step = (0, import_parameters2.parameterStep)(field) * (e.shiftKey ? 10 : 1);
|
|
1252
|
+
onChange((0, import_parameters2.clampParameterNumber)(field, value + (e.key === "ArrowUp" ? step : -step)));
|
|
1253
|
+
};
|
|
1254
|
+
const inputProps = {
|
|
1255
|
+
id,
|
|
1256
|
+
inputMode: "decimal",
|
|
1257
|
+
"aria-label": ariaLabel ?? (0, import_parameters2.parameterLabel)(field),
|
|
1258
|
+
value: plain,
|
|
1259
|
+
disabled: disabled || field.readOnly,
|
|
1260
|
+
className: `${parameterInputClass} ${field.unit ? "pr-6" : ""}`,
|
|
1261
|
+
style: parameterInputStyle,
|
|
1262
|
+
onCommit: handleCommit,
|
|
1263
|
+
onKeyDown: handleKeyDown
|
|
1264
|
+
};
|
|
1265
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "relative min-w-0 flex-1", children: [
|
|
1266
|
+
CustomInput ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CustomInput, { ...inputProps, label: (0, import_parameters2.parameterLabel)(field) }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ParameterCommitInput, { ...inputProps }),
|
|
1267
|
+
field.unit && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "pointer-events-none absolute right-2 top-1/2 -translate-y-1/2 text-[10px] text-muted-foreground", children: field.unit })
|
|
1210
1268
|
] });
|
|
1211
1269
|
}
|
|
1212
1270
|
function ParameterSlider(props) {
|
|
1213
|
-
const { field, value, onChange, onGestureStart, onGestureEnd, disabled } = props;
|
|
1214
|
-
const
|
|
1271
|
+
const { field, value, onChange, onGestureStart, onGestureEnd, disabled, components } = props;
|
|
1272
|
+
const ctx = useParameterComponents();
|
|
1273
|
+
const resolved = resolveParameterComponents(components, ctx);
|
|
1274
|
+
const CustomSlider = resolved.slider;
|
|
1275
|
+
const dragging = (0, import_react6.useRef)(false);
|
|
1276
|
+
const start = () => {
|
|
1277
|
+
if (dragging.current) return;
|
|
1278
|
+
dragging.current = true;
|
|
1279
|
+
onGestureStart?.();
|
|
1280
|
+
};
|
|
1215
1281
|
const end = () => {
|
|
1216
1282
|
if (!dragging.current) return;
|
|
1217
1283
|
dragging.current = false;
|
|
1218
1284
|
onGestureEnd?.();
|
|
1219
1285
|
};
|
|
1220
|
-
if (!(0, import_parameters2.isSliderField)(field)) return /* @__PURE__ */ (0,
|
|
1286
|
+
if (!(0, import_parameters2.isSliderField)(field)) return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ParameterNumberInput, { ...props });
|
|
1221
1287
|
const step = (0, import_parameters2.parameterStep)(field);
|
|
1222
|
-
|
|
1223
|
-
|
|
1288
|
+
const sliderProps = {
|
|
1289
|
+
"aria-label": (0, import_parameters2.parameterLabel)(field),
|
|
1290
|
+
"aria-valuetext": (0, import_parameters2.formatParameterNumber)(field, value),
|
|
1291
|
+
// A `control: 'slider'` field may leave out a bound: the range input's own defaults.
|
|
1292
|
+
min: field.min ?? 0,
|
|
1293
|
+
max: field.max ?? 100,
|
|
1294
|
+
step,
|
|
1295
|
+
value,
|
|
1296
|
+
disabled: disabled || field.readOnly,
|
|
1297
|
+
className: rangeClass,
|
|
1298
|
+
style: parameterRangeStyle
|
|
1299
|
+
};
|
|
1300
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
1301
|
+
CustomSlider ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1302
|
+
CustomSlider,
|
|
1303
|
+
{
|
|
1304
|
+
...sliderProps,
|
|
1305
|
+
id: props.id ? `${props.id}-slider` : void 0,
|
|
1306
|
+
label: (0, import_parameters2.parameterLabel)(field),
|
|
1307
|
+
onChange: (v) => onChange((0, import_parameters2.clampParameterNumber)(field, v)),
|
|
1308
|
+
onGestureStart: start,
|
|
1309
|
+
onGestureEnd: end
|
|
1310
|
+
}
|
|
1311
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1224
1312
|
"input",
|
|
1225
1313
|
{
|
|
1226
1314
|
type: "range",
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
min: field.min,
|
|
1230
|
-
max: field.max,
|
|
1231
|
-
step,
|
|
1232
|
-
value,
|
|
1233
|
-
disabled: disabled || field.readOnly,
|
|
1234
|
-
className: rangeClass,
|
|
1235
|
-
onPointerDown: () => {
|
|
1236
|
-
if (dragging.current) return;
|
|
1237
|
-
dragging.current = true;
|
|
1238
|
-
onGestureStart?.();
|
|
1239
|
-
},
|
|
1315
|
+
...sliderProps,
|
|
1316
|
+
onPointerDown: start,
|
|
1240
1317
|
onPointerUp: end,
|
|
1241
1318
|
onPointerCancel: end,
|
|
1242
1319
|
onBlur: end,
|
|
1243
1320
|
onChange: (e) => onChange((0, import_parameters2.clampParameterNumber)(field, Number(e.target.value)))
|
|
1244
1321
|
}
|
|
1245
1322
|
),
|
|
1246
|
-
/* @__PURE__ */ (0,
|
|
1323
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "w-20 shrink-0", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ParameterNumberInput, { ...props, id: props.id, "aria-label": `${(0, import_parameters2.parameterLabel)(field)} value` }) })
|
|
1247
1324
|
] });
|
|
1248
1325
|
}
|
|
1249
1326
|
function ParameterToggle({ field, value, onChange, disabled, id }) {
|
|
1250
|
-
return /* @__PURE__ */ (0,
|
|
1327
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1251
1328
|
"button",
|
|
1252
1329
|
{
|
|
1253
1330
|
type: "button",
|
|
@@ -1258,7 +1335,7 @@ function ParameterToggle({ field, value, onChange, disabled, id }) {
|
|
|
1258
1335
|
disabled: disabled || field.readOnly,
|
|
1259
1336
|
onClick: () => onChange(!value),
|
|
1260
1337
|
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"}`,
|
|
1261
|
-
children: /* @__PURE__ */ (0,
|
|
1338
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1262
1339
|
"span",
|
|
1263
1340
|
{
|
|
1264
1341
|
className: `pointer-events-none block h-4 w-4 rounded-full bg-background shadow transition-transform ${value ? "translate-x-4" : "translate-x-0.5"}`
|
|
@@ -1267,11 +1344,15 @@ function ParameterToggle({ field, value, onChange, disabled, id }) {
|
|
|
1267
1344
|
}
|
|
1268
1345
|
);
|
|
1269
1346
|
}
|
|
1270
|
-
function ParameterSelect(
|
|
1347
|
+
function ParameterSelect(props) {
|
|
1348
|
+
const { field, value, onChange, disabled, id, components } = props;
|
|
1349
|
+
const ctx = useParameterComponents();
|
|
1350
|
+
const resolved = resolveParameterComponents(components, ctx);
|
|
1351
|
+
const CustomSelect = resolved.select;
|
|
1271
1352
|
const options = (0, import_parameters2.getChoiceOptions)(field);
|
|
1272
1353
|
const off = disabled || field.readOnly;
|
|
1273
1354
|
if (field.control === "segmented") {
|
|
1274
|
-
return /* @__PURE__ */ (0,
|
|
1355
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { role: "radiogroup", "aria-label": (0, import_parameters2.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_runtime4.jsx)(
|
|
1275
1356
|
"button",
|
|
1276
1357
|
{
|
|
1277
1358
|
type: "button",
|
|
@@ -1286,8 +1367,25 @@ function ParameterSelect({ field, value, onChange, disabled, id }) {
|
|
|
1286
1367
|
String(o.value)
|
|
1287
1368
|
)) });
|
|
1288
1369
|
}
|
|
1370
|
+
if (CustomSelect) {
|
|
1371
|
+
const customOptions = options.map((o) => ({ value: o.value, label: (0, import_parameters2.choiceOptionLabel)(o), description: o.description }));
|
|
1372
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1373
|
+
CustomSelect,
|
|
1374
|
+
{
|
|
1375
|
+
id,
|
|
1376
|
+
label: (0, import_parameters2.parameterLabel)(field),
|
|
1377
|
+
"aria-label": (0, import_parameters2.parameterLabel)(field),
|
|
1378
|
+
value,
|
|
1379
|
+
options: customOptions,
|
|
1380
|
+
disabled: off,
|
|
1381
|
+
className: parameterInputClass,
|
|
1382
|
+
style: parameterSelectStyle,
|
|
1383
|
+
onChange: (v) => onChange((0, import_parameters2.matchParameterOptionValue)(options, v))
|
|
1384
|
+
}
|
|
1385
|
+
);
|
|
1386
|
+
}
|
|
1289
1387
|
const index = options.findIndex((o) => o.value === value);
|
|
1290
|
-
return /* @__PURE__ */ (0,
|
|
1388
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1291
1389
|
"select",
|
|
1292
1390
|
{
|
|
1293
1391
|
id,
|
|
@@ -1299,22 +1397,23 @@ function ParameterSelect({ field, value, onChange, disabled, id }) {
|
|
|
1299
1397
|
if (option) onChange(option.value);
|
|
1300
1398
|
},
|
|
1301
1399
|
className: parameterInputClass,
|
|
1302
|
-
|
|
1400
|
+
style: parameterSelectStyle,
|
|
1401
|
+
children: options.map((o, i) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("option", { value: String(i), title: o.description, style: parameterSelectStyle, children: (0, import_parameters2.choiceOptionLabel)(o) }, String(o.value)))
|
|
1303
1402
|
}
|
|
1304
1403
|
);
|
|
1305
1404
|
}
|
|
1306
1405
|
function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd, disabled, id }) {
|
|
1307
|
-
const [open, setOpen] = (0,
|
|
1308
|
-
const containerRef = (0,
|
|
1309
|
-
const buttonRef = (0,
|
|
1310
|
-
const popoverRef = (0,
|
|
1406
|
+
const [open, setOpen] = (0, import_react6.useState)(false);
|
|
1407
|
+
const containerRef = (0, import_react6.useRef)(null);
|
|
1408
|
+
const buttonRef = (0, import_react6.useRef)(null);
|
|
1409
|
+
const popoverRef = (0, import_react6.useRef)(null);
|
|
1311
1410
|
const alpha = !!field.alpha;
|
|
1312
1411
|
const hex = (0, import_parameters2.normalizeHexColor)(value, true) ?? "#000000ff";
|
|
1313
1412
|
const rgb = hex.slice(0, 7);
|
|
1314
1413
|
const shown = alpha ? hex : rgb;
|
|
1315
1414
|
const off = disabled || field.readOnly;
|
|
1316
1415
|
const name = (0, import_parameters2.parameterLabel)(field);
|
|
1317
|
-
(0,
|
|
1416
|
+
(0, import_react6.useEffect)(() => {
|
|
1318
1417
|
if (!open) return;
|
|
1319
1418
|
const onPointerDown = (e) => {
|
|
1320
1419
|
if (containerRef.current && !containerRef.current.contains(e.target)) {
|
|
@@ -1335,9 +1434,9 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
1335
1434
|
window.removeEventListener("keydown", onKeyDown, true);
|
|
1336
1435
|
};
|
|
1337
1436
|
}, [open]);
|
|
1338
|
-
return /* @__PURE__ */ (0,
|
|
1339
|
-
/* @__PURE__ */ (0,
|
|
1340
|
-
/* @__PURE__ */ (0,
|
|
1437
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { ref: containerRef, className: "relative space-y-1.5", children: [
|
|
1438
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
1439
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1341
1440
|
"button",
|
|
1342
1441
|
{
|
|
1343
1442
|
ref: buttonRef,
|
|
@@ -1348,10 +1447,10 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
1348
1447
|
disabled: off,
|
|
1349
1448
|
onClick: () => setOpen((prev) => !prev),
|
|
1350
1449
|
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",
|
|
1351
|
-
children: /* @__PURE__ */ (0,
|
|
1450
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "absolute inset-0", style: { background: shown } })
|
|
1352
1451
|
}
|
|
1353
1452
|
),
|
|
1354
|
-
/* @__PURE__ */ (0,
|
|
1453
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1355
1454
|
ParameterCommitInput,
|
|
1356
1455
|
{
|
|
1357
1456
|
id,
|
|
@@ -1367,7 +1466,7 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
1367
1466
|
}
|
|
1368
1467
|
)
|
|
1369
1468
|
] }),
|
|
1370
|
-
open && /* @__PURE__ */ (0,
|
|
1469
|
+
open && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1371
1470
|
"div",
|
|
1372
1471
|
{
|
|
1373
1472
|
ref: popoverRef,
|
|
@@ -1381,7 +1480,7 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
1381
1480
|
},
|
|
1382
1481
|
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",
|
|
1383
1482
|
style: { background: "var(--popover, var(--background, #fff))" },
|
|
1384
|
-
children: /* @__PURE__ */ (0,
|
|
1483
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1385
1484
|
ColorPicker,
|
|
1386
1485
|
{
|
|
1387
1486
|
value: shown,
|
|
@@ -1397,13 +1496,13 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
1397
1496
|
)
|
|
1398
1497
|
] });
|
|
1399
1498
|
}
|
|
1400
|
-
function ParameterVector({ field, value, onChange, disabled, id }) {
|
|
1499
|
+
function ParameterVector({ field, value, onChange, disabled, id, components }) {
|
|
1401
1500
|
const size = (0, import_parameters2.vectorSize)(field);
|
|
1402
|
-
return /* @__PURE__ */ (0,
|
|
1501
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "grid gap-1.5", style: { gridTemplateColumns: `repeat(${size}, minmax(0, 1fr))` }, children: Array.from({ length: size }, (_, i) => {
|
|
1403
1502
|
const component = (0, import_parameters2.vectorComponentField)(field, i);
|
|
1404
|
-
return /* @__PURE__ */ (0,
|
|
1405
|
-
/* @__PURE__ */ (0,
|
|
1406
|
-
/* @__PURE__ */ (0,
|
|
1503
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("label", { className: "flex min-w-0 items-center gap-1", children: [
|
|
1504
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "w-3 shrink-0 text-[10px] uppercase text-muted-foreground", children: component.label }),
|
|
1505
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1407
1506
|
ParameterNumberInput,
|
|
1408
1507
|
{
|
|
1409
1508
|
field: component,
|
|
@@ -1411,6 +1510,7 @@ function ParameterVector({ field, value, onChange, disabled, id }) {
|
|
|
1411
1510
|
id: i === 0 ? id : void 0,
|
|
1412
1511
|
"aria-label": `${(0, import_parameters2.parameterLabel)(field)} ${component.label}`,
|
|
1413
1512
|
disabled: disabled || field.readOnly,
|
|
1513
|
+
components,
|
|
1414
1514
|
onChange: (n) => onChange(Array.from({ length: size }, (_2, j) => j === i ? n : value[j] ?? 0))
|
|
1415
1515
|
}
|
|
1416
1516
|
)
|
|
@@ -1420,11 +1520,11 @@ function ParameterVector({ field, value, onChange, disabled, id }) {
|
|
|
1420
1520
|
function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
|
|
1421
1521
|
const off = disabled || field.readOnly;
|
|
1422
1522
|
const name = (0, import_parameters2.parameterLabel)(field);
|
|
1423
|
-
return /* @__PURE__ */ (0,
|
|
1424
|
-
/* @__PURE__ */ (0,
|
|
1425
|
-
/* @__PURE__ */ (0,
|
|
1426
|
-
/* @__PURE__ */ (0,
|
|
1427
|
-
/* @__PURE__ */ (0,
|
|
1523
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "space-y-1.5", children: [
|
|
1524
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
1525
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.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_runtime4.jsx)("img", { src: value, alt: name, className: "h-full w-full object-cover" }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "text-[10px] text-muted-foreground", children: "None" }) }),
|
|
1526
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "flex min-w-0 flex-1 flex-col gap-1", children: [
|
|
1527
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1428
1528
|
ParameterCommitInput,
|
|
1429
1529
|
{
|
|
1430
1530
|
id,
|
|
@@ -1435,30 +1535,48 @@ function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
|
|
|
1435
1535
|
onCommit: (text) => onChange(text.trim())
|
|
1436
1536
|
}
|
|
1437
1537
|
),
|
|
1438
|
-
/* @__PURE__ */ (0,
|
|
1439
|
-
resolveFile && /* @__PURE__ */ (0,
|
|
1440
|
-
"
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
{
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1538
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "flex gap-1", children: [
|
|
1539
|
+
resolveFile && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
1540
|
+
"label",
|
|
1541
|
+
{
|
|
1542
|
+
style: parameterButtonStyle,
|
|
1543
|
+
className: `${parameterButtonClass} cursor-pointer ${off ? "pointer-events-none opacity-50" : ""}`,
|
|
1544
|
+
children: [
|
|
1545
|
+
"Choose file\u2026",
|
|
1546
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1547
|
+
"input",
|
|
1548
|
+
{
|
|
1549
|
+
type: "file",
|
|
1550
|
+
className: "sr-only",
|
|
1551
|
+
accept: field.accept ?? "image/*",
|
|
1552
|
+
disabled: off,
|
|
1553
|
+
"aria-label": `${name} file`,
|
|
1554
|
+
onChange: async (e) => {
|
|
1555
|
+
const file = e.target.files?.[0];
|
|
1556
|
+
e.target.value = "";
|
|
1557
|
+
if (file) onChange(await resolveFile(file));
|
|
1558
|
+
}
|
|
1559
|
+
}
|
|
1560
|
+
)
|
|
1561
|
+
]
|
|
1562
|
+
}
|
|
1563
|
+
),
|
|
1564
|
+
value && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1565
|
+
"button",
|
|
1566
|
+
{
|
|
1567
|
+
type: "button",
|
|
1568
|
+
style: parameterButtonStyle,
|
|
1569
|
+
className: parameterButtonClass,
|
|
1570
|
+
disabled: off,
|
|
1571
|
+
onClick: () => onChange(""),
|
|
1572
|
+
"aria-label": `Clear ${name}`,
|
|
1573
|
+
children: "Clear"
|
|
1574
|
+
}
|
|
1575
|
+
)
|
|
1458
1576
|
] })
|
|
1459
1577
|
] })
|
|
1460
1578
|
] }),
|
|
1461
|
-
field.options && field.options.length > 0 && /* @__PURE__ */ (0,
|
|
1579
|
+
field.options && field.options.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "flex flex-wrap gap-1", children: field.options.map((o) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1462
1580
|
"button",
|
|
1463
1581
|
{
|
|
1464
1582
|
type: "button",
|
|
@@ -1468,14 +1586,14 @@ function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
|
|
|
1468
1586
|
disabled: off,
|
|
1469
1587
|
onClick: () => onChange(o.url),
|
|
1470
1588
|
className: "h-9 w-12 overflow-hidden rounded border border-input aria-pressed:ring-2 aria-pressed:ring-primary",
|
|
1471
|
-
children: /* @__PURE__ */ (0,
|
|
1589
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("img", { src: o.url, alt: "", className: "h-full w-full object-cover" })
|
|
1472
1590
|
},
|
|
1473
1591
|
o.url
|
|
1474
1592
|
)) })
|
|
1475
1593
|
] });
|
|
1476
1594
|
}
|
|
1477
1595
|
function ParameterText({ field, value, onChange, disabled, id }) {
|
|
1478
|
-
return /* @__PURE__ */ (0,
|
|
1596
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1479
1597
|
ParameterCommitInput,
|
|
1480
1598
|
{
|
|
1481
1599
|
id,
|
|
@@ -1491,7 +1609,7 @@ function ParameterText({ field, value, onChange, disabled, id }) {
|
|
|
1491
1609
|
}
|
|
1492
1610
|
function KeyframeDiamond({ state, onToggle, label, disabled, className = "" }) {
|
|
1493
1611
|
const keyed = state === "keyed";
|
|
1494
|
-
return /* @__PURE__ */ (0,
|
|
1612
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1495
1613
|
"button",
|
|
1496
1614
|
{
|
|
1497
1615
|
type: "button",
|
|
@@ -1502,7 +1620,7 @@ function KeyframeDiamond({ state, onToggle, label, disabled, className = "" }) {
|
|
|
1502
1620
|
disabled,
|
|
1503
1621
|
onClick: onToggle,
|
|
1504
1622
|
className: `inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-sm focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary disabled:opacity-40 ${state === "none" ? "text-muted-foreground hover:text-foreground" : "text-amber-500"} ${className}`,
|
|
1505
|
-
children: /* @__PURE__ */ (0,
|
|
1623
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("svg", { viewBox: "0 0 10 10", className: "h-2.5 w-2.5", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1506
1624
|
"path",
|
|
1507
1625
|
{
|
|
1508
1626
|
d: "M5 0.8 9.2 5 5 9.2 0.8 5Z",
|
|
@@ -1520,48 +1638,48 @@ function ParameterFieldControl({ field, value, onChange, resolveFile, ...rest })
|
|
|
1520
1638
|
switch (field.type) {
|
|
1521
1639
|
case "number":
|
|
1522
1640
|
case "int":
|
|
1523
|
-
return /* @__PURE__ */ (0,
|
|
1641
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ParameterSlider, { field, value, onChange: set, ...rest });
|
|
1524
1642
|
case "boolean":
|
|
1525
|
-
return /* @__PURE__ */ (0,
|
|
1643
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ParameterToggle, { field, value, onChange: set, ...rest });
|
|
1526
1644
|
case "choice":
|
|
1527
|
-
return /* @__PURE__ */ (0,
|
|
1645
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ParameterSelect, { field, value, onChange: set, ...rest });
|
|
1528
1646
|
case "color":
|
|
1529
|
-
return /* @__PURE__ */ (0,
|
|
1647
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ParameterColor, { field, value, onChange: set, ...rest });
|
|
1530
1648
|
case "vector":
|
|
1531
|
-
return /* @__PURE__ */ (0,
|
|
1649
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ParameterVector, { field, value, onChange: set, ...rest });
|
|
1532
1650
|
case "image":
|
|
1533
|
-
return /* @__PURE__ */ (0,
|
|
1651
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ParameterImage, { field, value, onChange: set, resolveFile, ...rest });
|
|
1534
1652
|
case "text":
|
|
1535
|
-
return /* @__PURE__ */ (0,
|
|
1653
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ParameterText, { field, value, onChange: set, ...rest });
|
|
1536
1654
|
}
|
|
1537
1655
|
}
|
|
1538
1656
|
|
|
1539
1657
|
// src/parameters/ParametersPanel.tsx
|
|
1540
|
-
var
|
|
1658
|
+
var import_react11 = require("react");
|
|
1541
1659
|
|
|
1542
1660
|
// src/playback/AgentPlaybackContext.tsx
|
|
1543
|
-
var
|
|
1544
|
-
var
|
|
1545
|
-
var AgentPlaybackContext = (0,
|
|
1661
|
+
var import_react7 = require("react");
|
|
1662
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
1663
|
+
var AgentPlaybackContext = (0, import_react7.createContext)(null);
|
|
1546
1664
|
function useAgentPlayback() {
|
|
1547
|
-
return (0,
|
|
1665
|
+
return (0, import_react7.useContext)(AgentPlaybackContext);
|
|
1548
1666
|
}
|
|
1549
1667
|
|
|
1550
1668
|
// src/playback/useElementPlaybackSurface.ts
|
|
1551
|
-
var
|
|
1669
|
+
var import_react9 = require("react");
|
|
1552
1670
|
var import_tools2 = require("@pixerate/editor/tools");
|
|
1553
1671
|
|
|
1554
1672
|
// src/playback/usePlaybackSurface.ts
|
|
1555
|
-
var
|
|
1673
|
+
var import_react8 = require("react");
|
|
1556
1674
|
var import_tools = require("@pixerate/editor/tools");
|
|
1557
1675
|
function usePlaybackSurface(playback, id, options = {}, sharedPresence) {
|
|
1558
1676
|
const ambient = useAgentPlayback();
|
|
1559
1677
|
const target = playback === void 0 ? ambient : playback;
|
|
1560
|
-
const [ownPresence] = (0,
|
|
1678
|
+
const [ownPresence] = (0, import_react8.useState)(() => new import_tools.PresenceStore());
|
|
1561
1679
|
const presence = sharedPresence ?? ownPresence;
|
|
1562
|
-
const latest = (0,
|
|
1680
|
+
const latest = (0, import_react8.useRef)(options);
|
|
1563
1681
|
latest.current = options;
|
|
1564
|
-
(0,
|
|
1682
|
+
(0, import_react8.useEffect)(() => {
|
|
1565
1683
|
if (!target || !id) return;
|
|
1566
1684
|
const o = () => latest.current;
|
|
1567
1685
|
const surface = {
|
|
@@ -1594,7 +1712,7 @@ function usePlaybackSurface(playback, id, options = {}, sharedPresence) {
|
|
|
1594
1712
|
|
|
1595
1713
|
// src/playback/useElementPlaybackSurface.ts
|
|
1596
1714
|
function useElementPlaybackSurface(playback, id, element, options) {
|
|
1597
|
-
const latest = (0,
|
|
1715
|
+
const latest = (0, import_react9.useRef)(options);
|
|
1598
1716
|
latest.current = options;
|
|
1599
1717
|
const box = () => element.current?.getBoundingClientRect() ?? null;
|
|
1600
1718
|
const fromViewport = (p) => {
|
|
@@ -1633,13 +1751,13 @@ function useElementPlaybackSurface(playback, id, element, options) {
|
|
|
1633
1751
|
}
|
|
1634
1752
|
|
|
1635
1753
|
// src/playback/PresenceLayer.tsx
|
|
1636
|
-
var
|
|
1637
|
-
var
|
|
1754
|
+
var import_react10 = __toESM(require("react"), 1);
|
|
1755
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
1638
1756
|
function PresenceLayer({ presence, viewport, clip = true, className = "" }) {
|
|
1639
|
-
const { actors } = (0,
|
|
1757
|
+
const { actors } = (0, import_react10.useSyncExternalStore)(presence.subscribe, presence.getState, presence.getState);
|
|
1640
1758
|
if (!actors.length) return null;
|
|
1641
1759
|
const map = typeof viewport === "function" ? viewport : viewport ? (p) => ({ x: p.x * viewport.zoom + viewport.x, y: p.y * viewport.zoom + viewport.y }) : (p) => p;
|
|
1642
|
-
return /* @__PURE__ */ (0,
|
|
1760
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1643
1761
|
"div",
|
|
1644
1762
|
{
|
|
1645
1763
|
className: `pixerate-presence ${className}`.trim(),
|
|
@@ -1653,19 +1771,19 @@ function PresenceLayer({ presence, viewport, clip = true, className = "" }) {
|
|
|
1653
1771
|
const br = map({ x: a.focus.x + a.focus.width, y: a.focus.y + a.focus.height });
|
|
1654
1772
|
return { left: tl.x - 4, top: tl.y - 4, width: br.x - tl.x + 8, height: br.y - tl.y + 8 };
|
|
1655
1773
|
})();
|
|
1656
|
-
return /* @__PURE__ */ (0,
|
|
1657
|
-
ring && /* @__PURE__ */ (0,
|
|
1774
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_react10.default.Fragment, { children: [
|
|
1775
|
+
ring && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1658
1776
|
"div",
|
|
1659
1777
|
{
|
|
1660
1778
|
"data-actor-focus": a.id,
|
|
1661
1779
|
style: { position: "absolute", ...ring, borderRadius: 8, border: `2px solid ${a.color}`, background: `${a.color}14`, transition: "all 160ms ease-out" }
|
|
1662
1780
|
}
|
|
1663
1781
|
),
|
|
1664
|
-
/* @__PURE__ */ (0,
|
|
1665
|
-
/* @__PURE__ */ (0,
|
|
1666
|
-
/* @__PURE__ */ (0,
|
|
1667
|
-
/* @__PURE__ */ (0,
|
|
1668
|
-
a.message && /* @__PURE__ */ (0,
|
|
1782
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { "data-actor": a.id, style: { position: "absolute", left: 0, top: 0, transform: `translate(${at.x}px, ${at.y}px)` }, children: [
|
|
1783
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("svg", { width: "18", height: "20", viewBox: "0 0 12 18", style: { display: "block", transform: a.pressed ? "scale(0.85)" : void 0, transformOrigin: "0 0", filter: "drop-shadow(0 1px 2px rgba(0,0,0,.35))" }, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("path", { d: "M0,0 L0,14 L4,10.5 L7,17 L9.5,16 L6.5,9.5 L11.5,9.5 Z", style: { fill: a.color, stroke: "#ffffff", strokeWidth: 1 } }) }),
|
|
1784
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { style: { position: "absolute", left: 14, top: 16, display: "flex", flexDirection: "column", alignItems: "flex-start", gap: 4 }, children: [
|
|
1785
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { style: { whiteSpace: "nowrap", borderRadius: 999, padding: "1px 7px", fontSize: 11, fontWeight: 600, color: "#ffffff", background: a.color }, children: a.name }),
|
|
1786
|
+
a.message && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { "data-actor-message": a.id, style: { width: "max-content", maxWidth: 240, borderRadius: 8, borderTopLeftRadius: 0, padding: "4px 8px", fontSize: 12, color: "#1e293b", background: "#ffffff", boxShadow: "0 4px 12px rgba(15,23,42,.18)" }, children: a.message })
|
|
1669
1787
|
] })
|
|
1670
1788
|
] })
|
|
1671
1789
|
] }, a.id);
|
|
@@ -1676,7 +1794,7 @@ function PresenceLayer({ presence, viewport, clip = true, className = "" }) {
|
|
|
1676
1794
|
|
|
1677
1795
|
// src/parameters/ParametersPanel.tsx
|
|
1678
1796
|
var import_parameters3 = require("@pixerate/editor/parameters");
|
|
1679
|
-
var
|
|
1797
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
1680
1798
|
function FieldRow({
|
|
1681
1799
|
controller,
|
|
1682
1800
|
state,
|
|
@@ -1684,18 +1802,19 @@ function FieldRow({
|
|
|
1684
1802
|
idBase,
|
|
1685
1803
|
showKeyframes,
|
|
1686
1804
|
showFieldReset,
|
|
1687
|
-
resolveFile
|
|
1805
|
+
resolveFile,
|
|
1806
|
+
components
|
|
1688
1807
|
}) {
|
|
1689
1808
|
const label = (0, import_parameters3.parameterLabel)(field);
|
|
1690
1809
|
const inputId = `${idBase}-${field.id}`;
|
|
1691
1810
|
const value = state.values[field.id];
|
|
1692
1811
|
const error = state.errors[field.id];
|
|
1693
1812
|
const changed = !(0, import_parameters3.parameterValuesEqual)(value, state.defaults[field.id]);
|
|
1694
|
-
return /* @__PURE__ */ (0,
|
|
1695
|
-
/* @__PURE__ */ (0,
|
|
1696
|
-
showKeyframes && /* @__PURE__ */ (0,
|
|
1697
|
-
/* @__PURE__ */ (0,
|
|
1698
|
-
showFieldReset && changed && !field.readOnly && /* @__PURE__ */ (0,
|
|
1813
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { "data-parameter-id": field.id, "data-parameter-type": field.type, className: "space-y-1", children: [
|
|
1814
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "flex min-h-[1.25rem] items-center gap-1.5", children: [
|
|
1815
|
+
showKeyframes && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(KeyframeDiamond, { state: state.keys[field.id] ?? "none", label, onToggle: () => controller.toggleKeyframe(field.id) }),
|
|
1816
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("label", { htmlFor: inputId, className: "min-w-0 flex-1 truncate text-xs font-medium text-foreground", title: field.description, children: label }),
|
|
1817
|
+
showFieldReset && changed && !field.readOnly && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1699
1818
|
"button",
|
|
1700
1819
|
{
|
|
1701
1820
|
type: "button",
|
|
@@ -1707,27 +1826,29 @@ function FieldRow({
|
|
|
1707
1826
|
}
|
|
1708
1827
|
)
|
|
1709
1828
|
] }),
|
|
1710
|
-
field.description && /* @__PURE__ */ (0,
|
|
1711
|
-
/* @__PURE__ */ (0,
|
|
1829
|
+
field.description && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { className: "text-[11px] leading-snug text-muted-foreground", children: field.description }),
|
|
1830
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1712
1831
|
ParameterFieldControl,
|
|
1713
1832
|
{
|
|
1714
1833
|
field,
|
|
1715
1834
|
value,
|
|
1716
1835
|
id: inputId,
|
|
1717
1836
|
resolveFile,
|
|
1837
|
+
components,
|
|
1718
1838
|
onChange: (v) => controller.setValue(field.id, v),
|
|
1719
1839
|
onGestureStart: () => controller.beginGesture(field.id),
|
|
1720
1840
|
onGestureEnd: () => controller.endGesture()
|
|
1721
1841
|
}
|
|
1722
1842
|
),
|
|
1723
|
-
error && /* @__PURE__ */ (0,
|
|
1843
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { role: "alert", className: "text-[11px] text-destructive", children: error })
|
|
1724
1844
|
] });
|
|
1725
1845
|
}
|
|
1726
|
-
function PresetBar({ controller, state }) {
|
|
1727
|
-
const [saving, setSaving] = (0,
|
|
1728
|
-
const [name, setName] = (0,
|
|
1729
|
-
const [message, setMessage] = (0,
|
|
1846
|
+
function PresetBar({ controller, state, components }) {
|
|
1847
|
+
const [saving, setSaving] = (0, import_react11.useState)(false);
|
|
1848
|
+
const [name, setName] = (0, import_react11.useState)("");
|
|
1849
|
+
const [message, setMessage] = (0, import_react11.useState)(null);
|
|
1730
1850
|
const active = state.presets.find((p) => p.name === state.activePreset);
|
|
1851
|
+
const CustomPresetSelect = resolveParameterComponents(components, useParameterComponents()).select;
|
|
1731
1852
|
const save = (e) => {
|
|
1732
1853
|
e.preventDefault();
|
|
1733
1854
|
const result = controller.savePreset(name);
|
|
@@ -1737,39 +1858,55 @@ function PresetBar({ controller, state }) {
|
|
|
1737
1858
|
setMessage(null);
|
|
1738
1859
|
} else setMessage(result.message);
|
|
1739
1860
|
};
|
|
1740
|
-
return /* @__PURE__ */ (0,
|
|
1741
|
-
/* @__PURE__ */ (0,
|
|
1742
|
-
/* @__PURE__ */ (0,
|
|
1861
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "space-y-1.5", "data-parameter-presets": "", children: [
|
|
1862
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "flex items-center gap-1.5", children: [
|
|
1863
|
+
CustomPresetSelect ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1864
|
+
CustomPresetSelect,
|
|
1865
|
+
{
|
|
1866
|
+
"aria-label": "Preset",
|
|
1867
|
+
label: "Preset",
|
|
1868
|
+
className: parameterInputClass,
|
|
1869
|
+
style: parameterSelectStyle,
|
|
1870
|
+
value: state.activePreset ?? "",
|
|
1871
|
+
options: [
|
|
1872
|
+
{ value: "", label: state.presets.length ? "Presets\u2026" : "No presets" },
|
|
1873
|
+
...state.presets.map((p) => ({ value: p.name, label: p.name, description: p.description }))
|
|
1874
|
+
],
|
|
1875
|
+
onChange: (val) => val && controller.applyPreset(String(val))
|
|
1876
|
+
}
|
|
1877
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
1743
1878
|
"select",
|
|
1744
1879
|
{
|
|
1745
1880
|
"aria-label": "Preset",
|
|
1746
1881
|
className: parameterInputClass,
|
|
1882
|
+
style: parameterSelectStyle,
|
|
1747
1883
|
value: state.activePreset ?? "",
|
|
1748
1884
|
onChange: (e) => e.target.value && controller.applyPreset(e.target.value),
|
|
1749
1885
|
children: [
|
|
1750
|
-
/* @__PURE__ */ (0,
|
|
1751
|
-
state.presets.map((p) => /* @__PURE__ */ (0,
|
|
1886
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("option", { value: "", style: parameterSelectStyle, children: state.presets.length ? "Presets\u2026" : "No presets" }),
|
|
1887
|
+
state.presets.map((p) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("option", { value: p.name, title: p.description, style: parameterSelectStyle, children: p.name }, p.name))
|
|
1752
1888
|
]
|
|
1753
1889
|
}
|
|
1754
1890
|
),
|
|
1755
|
-
/* @__PURE__ */ (0,
|
|
1756
|
-
active && !active.builtIn && /* @__PURE__ */ (0,
|
|
1891
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("button", { type: "button", className: parameterButtonClass, style: parameterButtonStyle, onClick: () => setSaving((s) => !s), "aria-expanded": saving, children: "Save\u2026" }),
|
|
1892
|
+
active && !active.builtIn && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("button", { type: "button", className: parameterButtonClass, style: parameterButtonStyle, "aria-label": `Delete preset ${active.name}`, onClick: () => controller.deletePreset(active.name), children: "Delete" })
|
|
1757
1893
|
] }),
|
|
1758
|
-
saving && /* @__PURE__ */ (0,
|
|
1759
|
-
/* @__PURE__ */ (0,
|
|
1894
|
+
saving && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("form", { className: "flex items-center gap-1.5", onSubmit: save, children: [
|
|
1895
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1760
1896
|
"input",
|
|
1761
1897
|
{
|
|
1762
1898
|
autoFocus: true,
|
|
1763
1899
|
"aria-label": "Preset name",
|
|
1764
1900
|
placeholder: "Preset name",
|
|
1765
1901
|
className: parameterInputClass,
|
|
1902
|
+
style: parameterInputStyle,
|
|
1766
1903
|
value: name,
|
|
1767
1904
|
onChange: (e) => setName(e.target.value)
|
|
1768
1905
|
}
|
|
1769
1906
|
),
|
|
1770
|
-
/* @__PURE__ */ (0,
|
|
1907
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("button", { type: "submit", className: parameterButtonClass, style: parameterButtonStyle, children: "Save" })
|
|
1771
1908
|
] }),
|
|
1772
|
-
message && /* @__PURE__ */ (0,
|
|
1909
|
+
message && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { role: "alert", className: "text-[11px] text-destructive", children: message })
|
|
1773
1910
|
] });
|
|
1774
1911
|
}
|
|
1775
1912
|
function ParametersPanel({
|
|
@@ -1782,12 +1919,13 @@ function ParametersPanel({
|
|
|
1782
1919
|
resolveFile,
|
|
1783
1920
|
emptyMessage = "No parameters.",
|
|
1784
1921
|
className = "",
|
|
1922
|
+
components,
|
|
1785
1923
|
playback,
|
|
1786
1924
|
playbackId = "parameters",
|
|
1787
1925
|
onPlaybackReveal
|
|
1788
1926
|
}) {
|
|
1789
1927
|
const state = useParametersState(controller);
|
|
1790
|
-
const rootRef = (0,
|
|
1928
|
+
const rootRef = (0, import_react11.useRef)(null);
|
|
1791
1929
|
const ambientPlayback = useAgentPlayback();
|
|
1792
1930
|
const playing = (playback === void 0 ? ambientPlayback : playback) ?? null;
|
|
1793
1931
|
const agentPresence = useElementPlaybackSurface(playing, playbackId, rootRef, {
|
|
@@ -1795,13 +1933,13 @@ function ParametersPanel({
|
|
|
1795
1933
|
selectors: { parameter: (id) => `[data-parameter-id="${CSS.escape(id)}"]` },
|
|
1796
1934
|
reveal: onPlaybackReveal
|
|
1797
1935
|
});
|
|
1798
|
-
const idBase = (0,
|
|
1936
|
+
const idBase = (0, import_react11.useId)();
|
|
1799
1937
|
const keys = showKeyframes ?? state.keyframesEnabled;
|
|
1800
1938
|
const heading = title === void 0 ? state.schema.title : title;
|
|
1801
1939
|
const renderItems = (items) => items.map((item) => {
|
|
1802
1940
|
if (state.visible[item.id] === false) return null;
|
|
1803
1941
|
if ((0, import_parameters3.isParameterGroup)(item)) return renderGroup(item);
|
|
1804
|
-
return /* @__PURE__ */ (0,
|
|
1942
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1805
1943
|
FieldRow,
|
|
1806
1944
|
{
|
|
1807
1945
|
controller,
|
|
@@ -1810,7 +1948,8 @@ function ParametersPanel({
|
|
|
1810
1948
|
idBase,
|
|
1811
1949
|
showKeyframes: keys,
|
|
1812
1950
|
showFieldReset,
|
|
1813
|
-
resolveFile
|
|
1951
|
+
resolveFile,
|
|
1952
|
+
components
|
|
1814
1953
|
},
|
|
1815
1954
|
item.id
|
|
1816
1955
|
);
|
|
@@ -1818,8 +1957,8 @@ function ParametersPanel({
|
|
|
1818
1957
|
const renderGroup = (group) => {
|
|
1819
1958
|
const collapsed = !!state.collapsed[group.id];
|
|
1820
1959
|
const bodyId = `${idBase}-group-${group.id}`;
|
|
1821
|
-
return /* @__PURE__ */ (0,
|
|
1822
|
-
/* @__PURE__ */ (0,
|
|
1960
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("section", { "data-parameter-group": group.id, className: "rounded-md border border-border", children: [
|
|
1961
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
1823
1962
|
"button",
|
|
1824
1963
|
{
|
|
1825
1964
|
type: "button",
|
|
@@ -1828,50 +1967,71 @@ function ParametersPanel({
|
|
|
1828
1967
|
onClick: () => controller.toggleCollapsed(group.id),
|
|
1829
1968
|
className: "flex w-full items-center gap-1.5 px-2 py-1.5 text-left text-xs font-semibold text-foreground hover:bg-muted",
|
|
1830
1969
|
children: [
|
|
1831
|
-
/* @__PURE__ */ (0,
|
|
1970
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { "aria-hidden": "true", className: `inline-block text-[10px] text-muted-foreground transition-transform ${collapsed ? "" : "rotate-90"}`, children: "\u25B6" }),
|
|
1832
1971
|
(0, import_parameters3.parameterLabel)(group)
|
|
1833
1972
|
]
|
|
1834
1973
|
}
|
|
1835
1974
|
),
|
|
1836
|
-
!collapsed && /* @__PURE__ */ (0,
|
|
1837
|
-
group.description && /* @__PURE__ */ (0,
|
|
1975
|
+
!collapsed && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { id: bodyId, className: "space-y-3 border-t border-border px-2 py-2", children: [
|
|
1976
|
+
group.description && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { className: "text-[11px] text-muted-foreground", children: group.description }),
|
|
1838
1977
|
renderItems(group.fields)
|
|
1839
1978
|
] })
|
|
1840
1979
|
] }, group.id);
|
|
1841
1980
|
};
|
|
1842
|
-
return /* @__PURE__ */ (0,
|
|
1843
|
-
(heading || showToolbar) && /* @__PURE__ */ (0,
|
|
1844
|
-
heading && /* @__PURE__ */ (0,
|
|
1845
|
-
showToolbar && /* @__PURE__ */ (0,
|
|
1846
|
-
/* @__PURE__ */ (0,
|
|
1981
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { ref: rootRef, className: `relative space-y-3 text-foreground ${className}`, "data-parameters-panel": "", children: [
|
|
1982
|
+
(heading || showToolbar) && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "flex flex-wrap items-center gap-1.5", children: [
|
|
1983
|
+
heading && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("h3", { className: "mr-auto text-sm font-semibold", children: heading }),
|
|
1984
|
+
showToolbar && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "flex flex-wrap gap-1", role: "toolbar", "aria-label": "Parameter actions", children: [
|
|
1985
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1847
1986
|
"button",
|
|
1848
1987
|
{
|
|
1849
1988
|
type: "button",
|
|
1850
1989
|
className: parameterButtonClass,
|
|
1990
|
+
style: parameterButtonStyle,
|
|
1851
1991
|
disabled: !state.canUndo,
|
|
1852
1992
|
title: state.canUndo ? `Undo ${state.undoLabel}` : "Nothing to undo",
|
|
1853
1993
|
onClick: () => controller.undo(),
|
|
1854
1994
|
children: "Undo"
|
|
1855
1995
|
}
|
|
1856
1996
|
),
|
|
1857
|
-
/* @__PURE__ */ (0,
|
|
1997
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1858
1998
|
"button",
|
|
1859
1999
|
{
|
|
1860
2000
|
type: "button",
|
|
1861
2001
|
className: parameterButtonClass,
|
|
2002
|
+
style: parameterButtonStyle,
|
|
1862
2003
|
disabled: !state.canRedo,
|
|
1863
2004
|
title: state.canRedo ? `Redo ${state.redoLabel}` : "Nothing to redo",
|
|
1864
2005
|
onClick: () => controller.redo(),
|
|
1865
2006
|
children: "Redo"
|
|
1866
2007
|
}
|
|
1867
2008
|
),
|
|
1868
|
-
/* @__PURE__ */ (0,
|
|
1869
|
-
|
|
2009
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
2010
|
+
"button",
|
|
2011
|
+
{
|
|
2012
|
+
type: "button",
|
|
2013
|
+
className: parameterButtonClass,
|
|
2014
|
+
style: parameterButtonStyle,
|
|
2015
|
+
disabled: !state.modified,
|
|
2016
|
+
onClick: () => controller.reset(),
|
|
2017
|
+
children: "Reset"
|
|
2018
|
+
}
|
|
2019
|
+
),
|
|
2020
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
2021
|
+
"button",
|
|
2022
|
+
{
|
|
2023
|
+
type: "button",
|
|
2024
|
+
className: parameterButtonClass,
|
|
2025
|
+
style: parameterButtonStyle,
|
|
2026
|
+
onClick: () => controller.randomize(),
|
|
2027
|
+
children: "Randomize"
|
|
2028
|
+
}
|
|
2029
|
+
)
|
|
1870
2030
|
] })
|
|
1871
2031
|
] }),
|
|
1872
|
-
showPresets && /* @__PURE__ */ (0,
|
|
1873
|
-
state.fields.length === 0 ? /* @__PURE__ */ (0,
|
|
1874
|
-
playing && /* @__PURE__ */ (0,
|
|
2032
|
+
showPresets && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(PresetBar, { controller, state, components }),
|
|
2033
|
+
state.fields.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { className: "text-xs text-muted-foreground", children: emptyMessage }) : renderItems(state.schema.fields),
|
|
2034
|
+
playing && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(PresenceLayer, { presence: agentPresence })
|
|
1875
2035
|
] });
|
|
1876
2036
|
}
|
|
1877
2037
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -1879,6 +2039,7 @@ function ParametersPanel({
|
|
|
1879
2039
|
KeyframeDiamond,
|
|
1880
2040
|
ParameterColor,
|
|
1881
2041
|
ParameterCommitInput,
|
|
2042
|
+
ParameterComponentsProvider,
|
|
1882
2043
|
ParameterFieldControl,
|
|
1883
2044
|
ParameterImage,
|
|
1884
2045
|
ParameterNumberInput,
|
|
@@ -1889,8 +2050,14 @@ function ParametersPanel({
|
|
|
1889
2050
|
ParameterVector,
|
|
1890
2051
|
ParametersPanel,
|
|
1891
2052
|
parameterButtonClass,
|
|
2053
|
+
parameterButtonStyle,
|
|
1892
2054
|
parameterInputClass,
|
|
2055
|
+
parameterInputStyle,
|
|
2056
|
+
parameterRangeStyle,
|
|
2057
|
+
parameterSelectStyle,
|
|
2058
|
+
resolveParameterComponents,
|
|
1893
2059
|
useParameterCommands,
|
|
2060
|
+
useParameterComponents,
|
|
1894
2061
|
useParameters,
|
|
1895
2062
|
useParametersController,
|
|
1896
2063
|
useParametersState
|