@pixerate/editor-react 0.114.2 → 0.115.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/index.cjs +361 -216
- package/dist/animation-editor/index.js +2 -2
- package/dist/canvas/index.cjs +539 -394
- package/dist/canvas/index.js +2 -2
- package/dist/{chunk-2INOKIJN.js → chunk-2KXZLZAS.js} +381 -364
- package/dist/{chunk-5LFQ2UQZ.js → chunk-5RPB4WGT.js} +240 -102
- package/dist/{chunk-BWEARAWR.js → chunk-6BWTJ3EE.js} +40 -18
- package/dist/effects/EffectParameters.d.cts +4 -1
- package/dist/effects/EffectParameters.d.ts +4 -1
- package/dist/effects/index.cjs +367 -222
- 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/controls.d.cts +19 -0
- package/dist/image-editor/controls/controls.d.ts +19 -0
- 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 +924 -765
- package/dist/image-editor/index.d.cts +1 -1
- package/dist/image-editor/index.d.ts +1 -1
- package/dist/image-editor/index.js +5 -3
- package/dist/index.cjs +1444 -1285
- package/dist/index.js +5 -3
- package/dist/paint-editor/index.cjs +354 -209
- 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 +92 -0
- package/dist/parameters/controls.d.ts +92 -0
- package/dist/parameters/fields.d.cts +20 -7
- package/dist/parameters/fields.d.ts +20 -7
- package/dist/parameters/index.cjs +369 -184
- 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 +340 -195
- package/dist/vector/index.js +2 -2
- package/dist/video-editor/index.cjs +437 -292
- package/dist/video-editor/index.js +2 -2
- package/package.json +3 -3
package/dist/effects/index.cjs
CHANGED
|
@@ -178,12 +178,12 @@ function EffectsBrowser({ provider, uses, kinds, onPick, thumbnails = true, titl
|
|
|
178
178
|
}
|
|
179
179
|
|
|
180
180
|
// src/effects/EffectParameters.tsx
|
|
181
|
-
var
|
|
181
|
+
var import_react9 = __toESM(require("react"), 1);
|
|
182
182
|
var import_effects3 = require("@pixerate/editor/effects");
|
|
183
183
|
var import_parameters2 = require("@pixerate/editor/parameters");
|
|
184
184
|
|
|
185
185
|
// src/parameters/fields.tsx
|
|
186
|
-
var
|
|
186
|
+
var import_react8 = require("react");
|
|
187
187
|
var import_parameters = require("@pixerate/editor/parameters");
|
|
188
188
|
|
|
189
189
|
// src/color/index.ts
|
|
@@ -1225,18 +1225,58 @@ function useResolvedColor(value, scheme) {
|
|
|
1225
1225
|
// src/color/index.ts
|
|
1226
1226
|
__reExport(color_exports, require("@pixerate/editor/color"));
|
|
1227
1227
|
|
|
1228
|
-
// src/parameters/
|
|
1228
|
+
// src/parameters/controls.tsx
|
|
1229
|
+
var import_react7 = require("react");
|
|
1229
1230
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
1231
|
+
var ParameterComponentsContext = (0, import_react7.createContext)({});
|
|
1232
|
+
function useParameterComponents() {
|
|
1233
|
+
return (0, import_react7.useContext)(ParameterComponentsContext);
|
|
1234
|
+
}
|
|
1235
|
+
function resolveParameterComponents(explicit, context) {
|
|
1236
|
+
return {
|
|
1237
|
+
input: explicit?.input ?? context?.input,
|
|
1238
|
+
slider: explicit?.slider ?? context?.slider,
|
|
1239
|
+
select: explicit?.select ?? context?.select,
|
|
1240
|
+
color: explicit?.color ?? context?.color
|
|
1241
|
+
};
|
|
1242
|
+
}
|
|
1243
|
+
|
|
1244
|
+
// src/parameters/fields.tsx
|
|
1245
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
1246
|
+
var parameterInputStyle = import_parameters.parameterThemeStyles.input;
|
|
1247
|
+
var parameterSelectStyle = import_parameters.parameterThemeStyles.select;
|
|
1248
|
+
var parameterButtonStyle = import_parameters.parameterThemeStyles.button;
|
|
1249
|
+
var parameterRangeStyle = import_parameters.parameterThemeStyles.range;
|
|
1230
1250
|
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";
|
|
1231
1251
|
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";
|
|
1232
1252
|
var rangeClass = "h-4 w-full min-w-0 flex-1 cursor-pointer accent-primary disabled:cursor-not-allowed disabled:opacity-50";
|
|
1233
|
-
function ParameterCommitInput({ value, onCommit, multiline, className, onKeyDown, ...rest }) {
|
|
1253
|
+
function ParameterCommitInput({ value, onCommit, multiline, className, onKeyDown, style, ...rest }) {
|
|
1254
|
+
const inputRef = (0, import_react8.useRef)(null);
|
|
1255
|
+
const lastCommitted = (0, import_react8.useRef)(null);
|
|
1256
|
+
(0, import_react8.useLayoutEffect)(() => {
|
|
1257
|
+
lastCommitted.current = null;
|
|
1258
|
+
const el = inputRef.current;
|
|
1259
|
+
if (el && el.value !== value) el.value = value;
|
|
1260
|
+
}, [value]);
|
|
1234
1261
|
const commit = (el) => {
|
|
1235
|
-
|
|
1262
|
+
const text = el.value;
|
|
1263
|
+
if (text === value || text === lastCommitted.current) return;
|
|
1264
|
+
onCommit(text, el);
|
|
1265
|
+
lastCommitted.current = el.value === text ? text : null;
|
|
1236
1266
|
};
|
|
1267
|
+
const commitRef = (0, import_react8.useRef)(commit);
|
|
1268
|
+
commitRef.current = commit;
|
|
1269
|
+
(0, import_react8.useEffect)(() => {
|
|
1270
|
+
const el = inputRef.current;
|
|
1271
|
+
if (!el) return;
|
|
1272
|
+
const change = () => commitRef.current(el);
|
|
1273
|
+
el.addEventListener("change", change);
|
|
1274
|
+
return () => el.removeEventListener("change", change);
|
|
1275
|
+
}, [multiline]);
|
|
1237
1276
|
const keyDown = (e) => {
|
|
1238
1277
|
onKeyDown?.(e);
|
|
1239
1278
|
if (e.defaultPrevented) return;
|
|
1279
|
+
if (e.key === "Tab") commit(e.currentTarget);
|
|
1240
1280
|
if (e.key === "Enter" && (!multiline || e.metaKey || e.ctrlKey)) {
|
|
1241
1281
|
e.preventDefault();
|
|
1242
1282
|
commit(e.currentTarget);
|
|
@@ -1246,86 +1286,114 @@ function ParameterCommitInput({ value, onCommit, multiline, className, onKeyDown
|
|
|
1246
1286
|
const props = {
|
|
1247
1287
|
defaultValue: value,
|
|
1248
1288
|
className: className ?? parameterInputClass,
|
|
1289
|
+
style: { ...parameterInputStyle, ...style },
|
|
1249
1290
|
onBlur: (e) => commit(e.currentTarget),
|
|
1250
1291
|
onKeyDown: keyDown,
|
|
1251
1292
|
...rest
|
|
1252
1293
|
};
|
|
1253
|
-
|
|
1294
|
+
const forwarded = rest.ref;
|
|
1295
|
+
const setRef = (el) => {
|
|
1296
|
+
inputRef.current = el;
|
|
1297
|
+
if (typeof forwarded === "function") forwarded(el);
|
|
1298
|
+
else if (forwarded) forwarded.current = el;
|
|
1299
|
+
};
|
|
1300
|
+
return multiline ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("textarea", { ...props, ref: setRef, className: `${props.className} h-auto min-h-[3.5rem] py-1` }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("input", { type: "text", ...props, ref: setRef });
|
|
1254
1301
|
}
|
|
1255
1302
|
var plainNumber = (field, value) => (0, import_parameters.formatParameterNumber)({ ...field, unit: void 0 }, value);
|
|
1256
|
-
function ParameterNumberInput({
|
|
1257
|
-
field,
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1303
|
+
function ParameterNumberInput(props) {
|
|
1304
|
+
const { field, value, onChange, disabled, id, components, "aria-label": ariaLabel } = props;
|
|
1305
|
+
const ctx = useParameterComponents();
|
|
1306
|
+
const resolved = resolveParameterComponents(components, ctx);
|
|
1307
|
+
const CustomInput = resolved.input;
|
|
1308
|
+
const plain = plainNumber(field, value);
|
|
1309
|
+
const handleCommit = (text, input) => {
|
|
1310
|
+
const n = (0, import_parameters.parseParameterNumberInput)(field, text);
|
|
1311
|
+
if (n === null || n === value) {
|
|
1312
|
+
if (input) input.value = plain;
|
|
1313
|
+
} else {
|
|
1314
|
+
onChange(n);
|
|
1315
|
+
}
|
|
1316
|
+
};
|
|
1317
|
+
const handleKeyDown = (e) => {
|
|
1318
|
+
if (e.key !== "ArrowUp" && e.key !== "ArrowDown") return;
|
|
1319
|
+
e.preventDefault();
|
|
1320
|
+
const step = (0, import_parameters.parameterStep)(field) * (e.shiftKey ? 10 : 1);
|
|
1321
|
+
onChange((0, import_parameters.clampParameterNumber)(field, value + (e.key === "ArrowUp" ? step : -step)));
|
|
1322
|
+
};
|
|
1323
|
+
const inputProps = {
|
|
1324
|
+
id,
|
|
1325
|
+
inputMode: "decimal",
|
|
1326
|
+
"aria-label": ariaLabel ?? (0, import_parameters.parameterLabel)(field),
|
|
1327
|
+
value: plain,
|
|
1328
|
+
disabled: disabled || field.readOnly,
|
|
1329
|
+
className: `${parameterInputClass} ${field.unit ? "pr-6" : ""}`,
|
|
1330
|
+
style: parameterInputStyle,
|
|
1331
|
+
onCommit: handleCommit,
|
|
1332
|
+
onKeyDown: handleKeyDown
|
|
1333
|
+
};
|
|
1334
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "relative min-w-0 flex-1", children: [
|
|
1335
|
+
CustomInput ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(CustomInput, { ...inputProps, label: (0, import_parameters.parameterLabel)(field) }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ParameterCommitInput, { ...inputProps }),
|
|
1336
|
+
field.unit && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "pointer-events-none absolute right-2 top-1/2 -translate-y-1/2 text-[10px] text-muted-foreground", children: field.unit })
|
|
1288
1337
|
] });
|
|
1289
1338
|
}
|
|
1290
1339
|
function ParameterSlider(props) {
|
|
1291
|
-
const { field, value, onChange, onGestureStart, onGestureEnd, disabled } = props;
|
|
1292
|
-
const
|
|
1340
|
+
const { field, value, onChange, onGestureStart, onGestureEnd, disabled, components } = props;
|
|
1341
|
+
const ctx = useParameterComponents();
|
|
1342
|
+
const resolved = resolveParameterComponents(components, ctx);
|
|
1343
|
+
const CustomSlider = resolved.slider;
|
|
1344
|
+
const dragging = (0, import_react8.useRef)(false);
|
|
1345
|
+
const start = () => {
|
|
1346
|
+
if (dragging.current) return;
|
|
1347
|
+
dragging.current = true;
|
|
1348
|
+
onGestureStart?.();
|
|
1349
|
+
};
|
|
1293
1350
|
const end = () => {
|
|
1294
1351
|
if (!dragging.current) return;
|
|
1295
1352
|
dragging.current = false;
|
|
1296
1353
|
onGestureEnd?.();
|
|
1297
1354
|
};
|
|
1298
|
-
if (!(0, import_parameters.isSliderField)(field)) return /* @__PURE__ */ (0,
|
|
1355
|
+
if (!(0, import_parameters.isSliderField)(field)) return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ParameterNumberInput, { ...props });
|
|
1299
1356
|
const step = (0, import_parameters.parameterStep)(field);
|
|
1300
|
-
|
|
1301
|
-
|
|
1357
|
+
const sliderProps = {
|
|
1358
|
+
"aria-label": (0, import_parameters.parameterLabel)(field),
|
|
1359
|
+
"aria-valuetext": (0, import_parameters.formatParameterNumber)(field, value),
|
|
1360
|
+
// A `control: 'slider'` field may leave out a bound: the range input's own defaults.
|
|
1361
|
+
min: field.min ?? 0,
|
|
1362
|
+
max: field.max ?? 100,
|
|
1363
|
+
step,
|
|
1364
|
+
value,
|
|
1365
|
+
disabled: disabled || field.readOnly,
|
|
1366
|
+
className: rangeClass,
|
|
1367
|
+
style: parameterRangeStyle
|
|
1368
|
+
};
|
|
1369
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
1370
|
+
CustomSlider ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1371
|
+
CustomSlider,
|
|
1372
|
+
{
|
|
1373
|
+
...sliderProps,
|
|
1374
|
+
id: props.id ? `${props.id}-slider` : void 0,
|
|
1375
|
+
label: (0, import_parameters.parameterLabel)(field),
|
|
1376
|
+
onChange: (v) => onChange((0, import_parameters.clampParameterNumber)(field, v)),
|
|
1377
|
+
onGestureStart: start,
|
|
1378
|
+
onGestureEnd: end
|
|
1379
|
+
}
|
|
1380
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1302
1381
|
"input",
|
|
1303
1382
|
{
|
|
1304
1383
|
type: "range",
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
min: field.min,
|
|
1308
|
-
max: field.max,
|
|
1309
|
-
step,
|
|
1310
|
-
value,
|
|
1311
|
-
disabled: disabled || field.readOnly,
|
|
1312
|
-
className: rangeClass,
|
|
1313
|
-
onPointerDown: () => {
|
|
1314
|
-
if (dragging.current) return;
|
|
1315
|
-
dragging.current = true;
|
|
1316
|
-
onGestureStart?.();
|
|
1317
|
-
},
|
|
1384
|
+
...sliderProps,
|
|
1385
|
+
onPointerDown: start,
|
|
1318
1386
|
onPointerUp: end,
|
|
1319
1387
|
onPointerCancel: end,
|
|
1320
1388
|
onBlur: end,
|
|
1321
1389
|
onChange: (e) => onChange((0, import_parameters.clampParameterNumber)(field, Number(e.target.value)))
|
|
1322
1390
|
}
|
|
1323
1391
|
),
|
|
1324
|
-
/* @__PURE__ */ (0,
|
|
1392
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "w-20 shrink-0", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ParameterNumberInput, { ...props, id: props.id, "aria-label": `${(0, import_parameters.parameterLabel)(field)} value` }) })
|
|
1325
1393
|
] });
|
|
1326
1394
|
}
|
|
1327
1395
|
function ParameterToggle({ field, value, onChange, disabled, id }) {
|
|
1328
|
-
return /* @__PURE__ */ (0,
|
|
1396
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1329
1397
|
"button",
|
|
1330
1398
|
{
|
|
1331
1399
|
type: "button",
|
|
@@ -1336,7 +1404,7 @@ function ParameterToggle({ field, value, onChange, disabled, id }) {
|
|
|
1336
1404
|
disabled: disabled || field.readOnly,
|
|
1337
1405
|
onClick: () => onChange(!value),
|
|
1338
1406
|
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"}`,
|
|
1339
|
-
children: /* @__PURE__ */ (0,
|
|
1407
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1340
1408
|
"span",
|
|
1341
1409
|
{
|
|
1342
1410
|
className: `pointer-events-none block h-4 w-4 rounded-full bg-background shadow transition-transform ${value ? "translate-x-4" : "translate-x-0.5"}`
|
|
@@ -1345,11 +1413,15 @@ function ParameterToggle({ field, value, onChange, disabled, id }) {
|
|
|
1345
1413
|
}
|
|
1346
1414
|
);
|
|
1347
1415
|
}
|
|
1348
|
-
function ParameterSelect(
|
|
1416
|
+
function ParameterSelect(props) {
|
|
1417
|
+
const { field, value, onChange, disabled, id, components } = props;
|
|
1418
|
+
const ctx = useParameterComponents();
|
|
1419
|
+
const resolved = resolveParameterComponents(components, ctx);
|
|
1420
|
+
const CustomSelect = resolved.select;
|
|
1349
1421
|
const options = (0, import_parameters.getChoiceOptions)(field);
|
|
1350
1422
|
const off = disabled || field.readOnly;
|
|
1351
1423
|
if (field.control === "segmented") {
|
|
1352
|
-
return /* @__PURE__ */ (0,
|
|
1424
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.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_runtime6.jsx)(
|
|
1353
1425
|
"button",
|
|
1354
1426
|
{
|
|
1355
1427
|
type: "button",
|
|
@@ -1364,8 +1436,25 @@ function ParameterSelect({ field, value, onChange, disabled, id }) {
|
|
|
1364
1436
|
String(o.value)
|
|
1365
1437
|
)) });
|
|
1366
1438
|
}
|
|
1439
|
+
if (CustomSelect) {
|
|
1440
|
+
const customOptions = options.map((o) => ({ value: o.value, label: (0, import_parameters.choiceOptionLabel)(o), description: o.description }));
|
|
1441
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1442
|
+
CustomSelect,
|
|
1443
|
+
{
|
|
1444
|
+
id,
|
|
1445
|
+
label: (0, import_parameters.parameterLabel)(field),
|
|
1446
|
+
"aria-label": (0, import_parameters.parameterLabel)(field),
|
|
1447
|
+
value,
|
|
1448
|
+
options: customOptions,
|
|
1449
|
+
disabled: off,
|
|
1450
|
+
className: parameterInputClass,
|
|
1451
|
+
style: parameterSelectStyle,
|
|
1452
|
+
onChange: (v) => onChange((0, import_parameters.matchParameterOptionValue)(options, v))
|
|
1453
|
+
}
|
|
1454
|
+
);
|
|
1455
|
+
}
|
|
1367
1456
|
const index = options.findIndex((o) => o.value === value);
|
|
1368
|
-
return /* @__PURE__ */ (0,
|
|
1457
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1369
1458
|
"select",
|
|
1370
1459
|
{
|
|
1371
1460
|
id,
|
|
@@ -1377,22 +1466,24 @@ function ParameterSelect({ field, value, onChange, disabled, id }) {
|
|
|
1377
1466
|
if (option) onChange(option.value);
|
|
1378
1467
|
},
|
|
1379
1468
|
className: parameterInputClass,
|
|
1380
|
-
|
|
1469
|
+
style: parameterSelectStyle,
|
|
1470
|
+
children: options.map((o, i) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("option", { value: String(i), title: o.description, style: parameterSelectStyle, children: (0, import_parameters.choiceOptionLabel)(o) }, String(o.value)))
|
|
1381
1471
|
}
|
|
1382
1472
|
);
|
|
1383
1473
|
}
|
|
1384
|
-
function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd, disabled, id }) {
|
|
1385
|
-
const
|
|
1386
|
-
const
|
|
1387
|
-
const
|
|
1388
|
-
const
|
|
1474
|
+
function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd, disabled, id, components }) {
|
|
1475
|
+
const CustomColor = resolveParameterComponents(components, useParameterComponents()).color;
|
|
1476
|
+
const [open, setOpen] = (0, import_react8.useState)(false);
|
|
1477
|
+
const containerRef = (0, import_react8.useRef)(null);
|
|
1478
|
+
const buttonRef = (0, import_react8.useRef)(null);
|
|
1479
|
+
const popoverRef = (0, import_react8.useRef)(null);
|
|
1389
1480
|
const alpha = !!field.alpha;
|
|
1390
1481
|
const hex = (0, import_parameters.normalizeHexColor)(value, true) ?? "#000000ff";
|
|
1391
1482
|
const rgb = hex.slice(0, 7);
|
|
1392
1483
|
const shown = alpha ? hex : rgb;
|
|
1393
1484
|
const off = disabled || field.readOnly;
|
|
1394
1485
|
const name = (0, import_parameters.parameterLabel)(field);
|
|
1395
|
-
(0,
|
|
1486
|
+
(0, import_react8.useEffect)(() => {
|
|
1396
1487
|
if (!open) return;
|
|
1397
1488
|
const onPointerDown = (e) => {
|
|
1398
1489
|
if (containerRef.current && !containerRef.current.contains(e.target)) {
|
|
@@ -1413,9 +1504,25 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
1413
1504
|
window.removeEventListener("keydown", onKeyDown, true);
|
|
1414
1505
|
};
|
|
1415
1506
|
}, [open]);
|
|
1416
|
-
|
|
1417
|
-
/* @__PURE__ */ (0,
|
|
1418
|
-
|
|
1507
|
+
if (CustomColor) {
|
|
1508
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1509
|
+
CustomColor,
|
|
1510
|
+
{
|
|
1511
|
+
id,
|
|
1512
|
+
value: shown,
|
|
1513
|
+
alpha,
|
|
1514
|
+
swatches: field.swatches,
|
|
1515
|
+
disabled: off,
|
|
1516
|
+
label: name,
|
|
1517
|
+
onChange,
|
|
1518
|
+
onGestureStart,
|
|
1519
|
+
onGestureEnd
|
|
1520
|
+
}
|
|
1521
|
+
);
|
|
1522
|
+
}
|
|
1523
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { ref: containerRef, className: "relative space-y-1.5", children: [
|
|
1524
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
1525
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1419
1526
|
"button",
|
|
1420
1527
|
{
|
|
1421
1528
|
ref: buttonRef,
|
|
@@ -1426,10 +1533,10 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
1426
1533
|
disabled: off,
|
|
1427
1534
|
onClick: () => setOpen((prev) => !prev),
|
|
1428
1535
|
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",
|
|
1429
|
-
children: /* @__PURE__ */ (0,
|
|
1536
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "absolute inset-0", style: { background: shown } })
|
|
1430
1537
|
}
|
|
1431
1538
|
),
|
|
1432
|
-
/* @__PURE__ */ (0,
|
|
1539
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1433
1540
|
ParameterCommitInput,
|
|
1434
1541
|
{
|
|
1435
1542
|
id,
|
|
@@ -1445,7 +1552,7 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
1445
1552
|
}
|
|
1446
1553
|
)
|
|
1447
1554
|
] }),
|
|
1448
|
-
open && /* @__PURE__ */ (0,
|
|
1555
|
+
open && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1449
1556
|
"div",
|
|
1450
1557
|
{
|
|
1451
1558
|
ref: popoverRef,
|
|
@@ -1459,7 +1566,7 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
1459
1566
|
},
|
|
1460
1567
|
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",
|
|
1461
1568
|
style: { background: "var(--popover, var(--background, #fff))" },
|
|
1462
|
-
children: /* @__PURE__ */ (0,
|
|
1569
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1463
1570
|
ColorPicker,
|
|
1464
1571
|
{
|
|
1465
1572
|
value: shown,
|
|
@@ -1475,13 +1582,13 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
1475
1582
|
)
|
|
1476
1583
|
] });
|
|
1477
1584
|
}
|
|
1478
|
-
function ParameterVector({ field, value, onChange, disabled, id }) {
|
|
1585
|
+
function ParameterVector({ field, value, onChange, disabled, id, components }) {
|
|
1479
1586
|
const size = (0, import_parameters.vectorSize)(field);
|
|
1480
|
-
return /* @__PURE__ */ (0,
|
|
1587
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "grid gap-1.5", style: { gridTemplateColumns: `repeat(${size}, minmax(0, 1fr))` }, children: Array.from({ length: size }, (_, i) => {
|
|
1481
1588
|
const component = (0, import_parameters.vectorComponentField)(field, i);
|
|
1482
|
-
return /* @__PURE__ */ (0,
|
|
1483
|
-
/* @__PURE__ */ (0,
|
|
1484
|
-
/* @__PURE__ */ (0,
|
|
1589
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("label", { className: "flex min-w-0 items-center gap-1", children: [
|
|
1590
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "w-3 shrink-0 text-[10px] uppercase text-muted-foreground", children: component.label }),
|
|
1591
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1485
1592
|
ParameterNumberInput,
|
|
1486
1593
|
{
|
|
1487
1594
|
field: component,
|
|
@@ -1489,6 +1596,7 @@ function ParameterVector({ field, value, onChange, disabled, id }) {
|
|
|
1489
1596
|
id: i === 0 ? id : void 0,
|
|
1490
1597
|
"aria-label": `${(0, import_parameters.parameterLabel)(field)} ${component.label}`,
|
|
1491
1598
|
disabled: disabled || field.readOnly,
|
|
1599
|
+
components,
|
|
1492
1600
|
onChange: (n) => onChange(Array.from({ length: size }, (_2, j) => j === i ? n : value[j] ?? 0))
|
|
1493
1601
|
}
|
|
1494
1602
|
)
|
|
@@ -1498,11 +1606,11 @@ function ParameterVector({ field, value, onChange, disabled, id }) {
|
|
|
1498
1606
|
function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
|
|
1499
1607
|
const off = disabled || field.readOnly;
|
|
1500
1608
|
const name = (0, import_parameters.parameterLabel)(field);
|
|
1501
|
-
return /* @__PURE__ */ (0,
|
|
1502
|
-
/* @__PURE__ */ (0,
|
|
1503
|
-
/* @__PURE__ */ (0,
|
|
1504
|
-
/* @__PURE__ */ (0,
|
|
1505
|
-
/* @__PURE__ */ (0,
|
|
1609
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "space-y-1.5", children: [
|
|
1610
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
1611
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.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_runtime6.jsx)("img", { src: value, alt: name, className: "h-full w-full object-cover" }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "text-[10px] text-muted-foreground", children: "None" }) }),
|
|
1612
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "flex min-w-0 flex-1 flex-col gap-1", children: [
|
|
1613
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1506
1614
|
ParameterCommitInput,
|
|
1507
1615
|
{
|
|
1508
1616
|
id,
|
|
@@ -1513,30 +1621,48 @@ function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
|
|
|
1513
1621
|
onCommit: (text) => onChange(text.trim())
|
|
1514
1622
|
}
|
|
1515
1623
|
),
|
|
1516
|
-
/* @__PURE__ */ (0,
|
|
1517
|
-
resolveFile && /* @__PURE__ */ (0,
|
|
1518
|
-
"
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
{
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1624
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "flex gap-1", children: [
|
|
1625
|
+
resolveFile && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
1626
|
+
"label",
|
|
1627
|
+
{
|
|
1628
|
+
style: parameterButtonStyle,
|
|
1629
|
+
className: `${parameterButtonClass} cursor-pointer ${off ? "pointer-events-none opacity-50" : ""}`,
|
|
1630
|
+
children: [
|
|
1631
|
+
"Choose file\u2026",
|
|
1632
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1633
|
+
"input",
|
|
1634
|
+
{
|
|
1635
|
+
type: "file",
|
|
1636
|
+
className: "sr-only",
|
|
1637
|
+
accept: field.accept ?? "image/*",
|
|
1638
|
+
disabled: off,
|
|
1639
|
+
"aria-label": `${name} file`,
|
|
1640
|
+
onChange: async (e) => {
|
|
1641
|
+
const file = e.target.files?.[0];
|
|
1642
|
+
e.target.value = "";
|
|
1643
|
+
if (file) onChange(await resolveFile(file));
|
|
1644
|
+
}
|
|
1645
|
+
}
|
|
1646
|
+
)
|
|
1647
|
+
]
|
|
1648
|
+
}
|
|
1649
|
+
),
|
|
1650
|
+
value && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1651
|
+
"button",
|
|
1652
|
+
{
|
|
1653
|
+
type: "button",
|
|
1654
|
+
style: parameterButtonStyle,
|
|
1655
|
+
className: parameterButtonClass,
|
|
1656
|
+
disabled: off,
|
|
1657
|
+
onClick: () => onChange(""),
|
|
1658
|
+
"aria-label": `Clear ${name}`,
|
|
1659
|
+
children: "Clear"
|
|
1660
|
+
}
|
|
1661
|
+
)
|
|
1536
1662
|
] })
|
|
1537
1663
|
] })
|
|
1538
1664
|
] }),
|
|
1539
|
-
field.options && field.options.length > 0 && /* @__PURE__ */ (0,
|
|
1665
|
+
field.options && field.options.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "flex flex-wrap gap-1", children: field.options.map((o) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1540
1666
|
"button",
|
|
1541
1667
|
{
|
|
1542
1668
|
type: "button",
|
|
@@ -1546,14 +1672,14 @@ function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
|
|
|
1546
1672
|
disabled: off,
|
|
1547
1673
|
onClick: () => onChange(o.url),
|
|
1548
1674
|
className: "h-9 w-12 overflow-hidden rounded border border-input aria-pressed:ring-2 aria-pressed:ring-primary",
|
|
1549
|
-
children: /* @__PURE__ */ (0,
|
|
1675
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("img", { src: o.url, alt: "", className: "h-full w-full object-cover" })
|
|
1550
1676
|
},
|
|
1551
1677
|
o.url
|
|
1552
1678
|
)) })
|
|
1553
1679
|
] });
|
|
1554
1680
|
}
|
|
1555
1681
|
function ParameterText({ field, value, onChange, disabled, id }) {
|
|
1556
|
-
return /* @__PURE__ */ (0,
|
|
1682
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1557
1683
|
ParameterCommitInput,
|
|
1558
1684
|
{
|
|
1559
1685
|
id,
|
|
@@ -1572,24 +1698,24 @@ function ParameterFieldControl({ field, value, onChange, resolveFile, ...rest })
|
|
|
1572
1698
|
switch (field.type) {
|
|
1573
1699
|
case "number":
|
|
1574
1700
|
case "int":
|
|
1575
|
-
return /* @__PURE__ */ (0,
|
|
1701
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ParameterSlider, { field, value, onChange: set, ...rest });
|
|
1576
1702
|
case "boolean":
|
|
1577
|
-
return /* @__PURE__ */ (0,
|
|
1703
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ParameterToggle, { field, value, onChange: set, ...rest });
|
|
1578
1704
|
case "choice":
|
|
1579
|
-
return /* @__PURE__ */ (0,
|
|
1705
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ParameterSelect, { field, value, onChange: set, ...rest });
|
|
1580
1706
|
case "color":
|
|
1581
|
-
return /* @__PURE__ */ (0,
|
|
1707
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ParameterColor, { field, value, onChange: set, ...rest });
|
|
1582
1708
|
case "vector":
|
|
1583
|
-
return /* @__PURE__ */ (0,
|
|
1709
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ParameterVector, { field, value, onChange: set, ...rest });
|
|
1584
1710
|
case "image":
|
|
1585
|
-
return /* @__PURE__ */ (0,
|
|
1711
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ParameterImage, { field, value, onChange: set, resolveFile, ...rest });
|
|
1586
1712
|
case "text":
|
|
1587
|
-
return /* @__PURE__ */ (0,
|
|
1713
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ParameterText, { field, value, onChange: set, ...rest });
|
|
1588
1714
|
}
|
|
1589
1715
|
}
|
|
1590
1716
|
|
|
1591
1717
|
// src/effects/EffectParameters.tsx
|
|
1592
|
-
var
|
|
1718
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
1593
1719
|
function EffectParameters({
|
|
1594
1720
|
description,
|
|
1595
1721
|
values,
|
|
@@ -1601,56 +1727,75 @@ function EffectParameters({
|
|
|
1601
1727
|
renderControlAddon,
|
|
1602
1728
|
fonts,
|
|
1603
1729
|
disabled = false,
|
|
1604
|
-
className = ""
|
|
1730
|
+
className = "",
|
|
1731
|
+
components
|
|
1605
1732
|
}) {
|
|
1606
|
-
const fields = (0,
|
|
1607
|
-
const idBase = (0,
|
|
1608
|
-
const gesture =
|
|
1609
|
-
const count =
|
|
1610
|
-
|
|
1611
|
-
|
|
1733
|
+
const fields = (0, import_react9.useMemo)(() => (0, import_effects3.effectParameterFields)(description, { fonts }), [description, fonts]);
|
|
1734
|
+
const idBase = (0, import_react9.useId)();
|
|
1735
|
+
const gesture = import_react9.default.useRef(null);
|
|
1736
|
+
const count = import_react9.default.useRef(0);
|
|
1737
|
+
const CustomPresetSelect = resolveParameterComponents(components, useParameterComponents()).select;
|
|
1738
|
+
const handlePresetSelect = (name) => {
|
|
1739
|
+
if (!name) return;
|
|
1740
|
+
if (onPresetName) {
|
|
1741
|
+
onPresetName(name);
|
|
1742
|
+
} else if (onPreset) {
|
|
1743
|
+
const preset = description.presets.find((p) => p.name === name);
|
|
1744
|
+
if (preset) onPreset({ ...description.defaults, ...preset.values });
|
|
1745
|
+
}
|
|
1746
|
+
};
|
|
1747
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: `space-y-2 ${className}`, "data-effect-parameters": description.id, children: [
|
|
1748
|
+
(onPreset || onPresetName) && description.presets.length > 0 && (CustomPresetSelect ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1749
|
+
CustomPresetSelect,
|
|
1750
|
+
{
|
|
1751
|
+
"aria-label": `${description.name} presets`,
|
|
1752
|
+
label: `${description.name} presets`,
|
|
1753
|
+
value: "",
|
|
1754
|
+
disabled,
|
|
1755
|
+
className: "w-full rounded border border-border px-1 py-0.5 text-xs",
|
|
1756
|
+
style: parameterSelectStyle,
|
|
1757
|
+
options: [
|
|
1758
|
+
{ value: "", label: "Presets\u2026" },
|
|
1759
|
+
...description.presets.map((p) => ({ value: p.name, label: p.name }))
|
|
1760
|
+
],
|
|
1761
|
+
onChange: (name) => handlePresetSelect(String(name))
|
|
1762
|
+
}
|
|
1763
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
1612
1764
|
"select",
|
|
1613
1765
|
{
|
|
1614
|
-
className: "w-full rounded border border-border
|
|
1766
|
+
className: "w-full rounded border border-border px-1 py-0.5 text-xs",
|
|
1767
|
+
style: parameterSelectStyle,
|
|
1615
1768
|
"aria-label": `${description.name} presets`,
|
|
1616
1769
|
value: "",
|
|
1617
1770
|
disabled,
|
|
1618
|
-
onChange: (e) =>
|
|
1619
|
-
const name = e.currentTarget.value;
|
|
1620
|
-
if (!name) return;
|
|
1621
|
-
if (onPresetName) {
|
|
1622
|
-
onPresetName(name);
|
|
1623
|
-
} else if (onPreset) {
|
|
1624
|
-
const preset = description.presets.find((p) => p.name === name);
|
|
1625
|
-
if (preset) onPreset({ ...description.defaults, ...preset.values });
|
|
1626
|
-
}
|
|
1627
|
-
},
|
|
1771
|
+
onChange: (e) => handlePresetSelect(e.currentTarget.value),
|
|
1628
1772
|
children: [
|
|
1629
|
-
/* @__PURE__ */ (0,
|
|
1630
|
-
description.presets.map((p) => /* @__PURE__ */ (0,
|
|
1773
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("option", { value: "", style: parameterSelectStyle, children: "Presets\u2026" }),
|
|
1774
|
+
description.presets.map((p) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("option", { value: p.name, style: parameterSelectStyle, children: p.name }, p.name))
|
|
1631
1775
|
]
|
|
1632
1776
|
}
|
|
1633
|
-
),
|
|
1777
|
+
)),
|
|
1634
1778
|
fields.map((field) => {
|
|
1635
1779
|
const label = (0, import_parameters2.parameterLabel)(field);
|
|
1636
1780
|
const inputId = `${idBase}-${field.id}`;
|
|
1637
1781
|
const keyed = keyframed?.has(field.id) ?? false;
|
|
1638
1782
|
const value = (0, import_effects3.effectFieldValue)(field, values[field.id]);
|
|
1639
1783
|
const changed = !keyed && !(0, import_parameters2.parameterValuesEqual)(value, field.default);
|
|
1640
|
-
return /* @__PURE__ */ (0,
|
|
1641
|
-
/* @__PURE__ */ (0,
|
|
1642
|
-
/* @__PURE__ */ (0,
|
|
1643
|
-
keyed && /* @__PURE__ */ (0,
|
|
1784
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "space-y-1", "data-effect-control": field.id, children: [
|
|
1785
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "flex items-center gap-1.5", children: [
|
|
1786
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("label", { htmlFor: inputId, className: "min-w-0 flex-1 truncate text-xs font-medium", title: field.description, children: label }),
|
|
1787
|
+
keyed && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "text-[10px] text-muted-foreground", children: "keyframed" }),
|
|
1644
1788
|
renderControlAddon?.(field.id),
|
|
1645
|
-
onReset && changed && !disabled && /* @__PURE__ */ (0,
|
|
1789
|
+
onReset && changed && !disabled && /* @__PURE__ */ (0, import_jsx_runtime7.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" })
|
|
1646
1790
|
] }),
|
|
1647
|
-
/* @__PURE__ */ (0,
|
|
1791
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1648
1792
|
ParameterFieldControl,
|
|
1649
1793
|
{
|
|
1650
1794
|
field,
|
|
1651
1795
|
value,
|
|
1652
1796
|
id: inputId,
|
|
1653
1797
|
disabled: disabled || keyed,
|
|
1798
|
+
components,
|
|
1654
1799
|
onChange: (v) => onChange(field.id, v, gesture.current),
|
|
1655
1800
|
onGestureStart: () => gesture.current = `${idBase}:${field.id}:${++count.current}`,
|
|
1656
1801
|
onGestureEnd: () => gesture.current = null
|
|
@@ -1658,14 +1803,14 @@ function EffectParameters({
|
|
|
1658
1803
|
)
|
|
1659
1804
|
] }, field.id);
|
|
1660
1805
|
}),
|
|
1661
|
-
!fields.length && /* @__PURE__ */ (0,
|
|
1806
|
+
!fields.length && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No controls." })
|
|
1662
1807
|
] });
|
|
1663
1808
|
}
|
|
1664
1809
|
|
|
1665
1810
|
// src/effects/useEffectAuthoring.ts
|
|
1666
|
-
var
|
|
1811
|
+
var import_react10 = require("react");
|
|
1667
1812
|
function useEffectAuthoring(session) {
|
|
1668
|
-
return (0,
|
|
1813
|
+
return (0, import_react10.useSyncExternalStore)(
|
|
1669
1814
|
(callback) => {
|
|
1670
1815
|
if (!session) return () => {
|
|
1671
1816
|
};
|
|
@@ -1677,9 +1822,9 @@ function useEffectAuthoring(session) {
|
|
|
1677
1822
|
}
|
|
1678
1823
|
|
|
1679
1824
|
// src/effects/EffectAuthoringEditor.tsx
|
|
1680
|
-
var
|
|
1825
|
+
var import_react11 = require("react");
|
|
1681
1826
|
var import_effects4 = require("@pixerate/editor/effects");
|
|
1682
|
-
var
|
|
1827
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
1683
1828
|
function EffectAuthoringEditor({
|
|
1684
1829
|
session,
|
|
1685
1830
|
showSource = true,
|
|
@@ -1688,21 +1833,21 @@ function EffectAuthoringEditor({
|
|
|
1688
1833
|
className = ""
|
|
1689
1834
|
}) {
|
|
1690
1835
|
const state = useEffectAuthoring(session);
|
|
1691
|
-
const canvasRef = (0,
|
|
1692
|
-
const rendererRef = (0,
|
|
1693
|
-
const [rendererReady, setRendererReady] = (0,
|
|
1694
|
-
const renderingRef = (0,
|
|
1695
|
-
const pendingRef = (0,
|
|
1696
|
-
const timeRef = (0,
|
|
1697
|
-
const inputsRef = (0,
|
|
1698
|
-
const [previewError, setPreviewError] = (0,
|
|
1699
|
-
const [savingPreset, setSavingPreset] = (0,
|
|
1700
|
-
const [presetName, setPresetName] = (0,
|
|
1701
|
-
const textareaRef = (0,
|
|
1702
|
-
const gutterRef = (0,
|
|
1703
|
-
const [sourceCode, setSourceCode] = (0,
|
|
1704
|
-
const sourceDebounceRef = (0,
|
|
1705
|
-
(0,
|
|
1836
|
+
const canvasRef = (0, import_react11.useRef)(null);
|
|
1837
|
+
const rendererRef = (0, import_react11.useRef)(null);
|
|
1838
|
+
const [rendererReady, setRendererReady] = (0, import_react11.useState)(0);
|
|
1839
|
+
const renderingRef = (0, import_react11.useRef)(false);
|
|
1840
|
+
const pendingRef = (0, import_react11.useRef)(false);
|
|
1841
|
+
const timeRef = (0, import_react11.useRef)(0);
|
|
1842
|
+
const inputsRef = (0, import_react11.useRef)({});
|
|
1843
|
+
const [previewError, setPreviewError] = (0, import_react11.useState)(null);
|
|
1844
|
+
const [savingPreset, setSavingPreset] = (0, import_react11.useState)(false);
|
|
1845
|
+
const [presetName, setPresetName] = (0, import_react11.useState)("");
|
|
1846
|
+
const textareaRef = (0, import_react11.useRef)(null);
|
|
1847
|
+
const gutterRef = (0, import_react11.useRef)(null);
|
|
1848
|
+
const [sourceCode, setSourceCode] = (0, import_react11.useState)("");
|
|
1849
|
+
const sourceDebounceRef = (0, import_react11.useRef)(null);
|
|
1850
|
+
(0, import_react11.useEffect)(() => {
|
|
1706
1851
|
const canvas = canvasRef.current;
|
|
1707
1852
|
canvas?.getContext("2d")?.clearRect(0, 0, canvas.width, canvas.height);
|
|
1708
1853
|
setPreviewError(null);
|
|
@@ -1736,7 +1881,7 @@ function EffectAuthoringEditor({
|
|
|
1736
1881
|
}
|
|
1737
1882
|
};
|
|
1738
1883
|
}, [session, previewSize.width, previewSize.height]);
|
|
1739
|
-
const pump = (0,
|
|
1884
|
+
const pump = (0, import_react11.useCallback)(async () => {
|
|
1740
1885
|
if (renderingRef.current) {
|
|
1741
1886
|
pendingRef.current = true;
|
|
1742
1887
|
return;
|
|
@@ -1767,26 +1912,26 @@ function EffectAuthoringEditor({
|
|
|
1767
1912
|
}
|
|
1768
1913
|
}, []);
|
|
1769
1914
|
const inputSpecs = state?.description.inputs;
|
|
1770
|
-
(0,
|
|
1915
|
+
(0, import_react11.useEffect)(() => {
|
|
1771
1916
|
inputsRef.current = inputSpecs ? (0, import_effects4.effectSampleInputs)({ inputs: inputSpecs }, previewSize) : {};
|
|
1772
1917
|
}, [inputSpecs, previewSize.width, previewSize.height]);
|
|
1773
|
-
(0,
|
|
1918
|
+
(0, import_react11.useEffect)(() => {
|
|
1774
1919
|
if (!state) return;
|
|
1775
1920
|
timeRef.current = state.time;
|
|
1776
1921
|
void pump();
|
|
1777
1922
|
}, [state, rendererReady, pump]);
|
|
1778
|
-
(0,
|
|
1923
|
+
(0, import_react11.useEffect)(() => {
|
|
1779
1924
|
if (state?.source !== null && state?.source !== void 0) {
|
|
1780
1925
|
setSourceCode(state.source);
|
|
1781
1926
|
}
|
|
1782
1927
|
}, [state?.source]);
|
|
1783
|
-
(0,
|
|
1928
|
+
(0, import_react11.useEffect)(() => {
|
|
1784
1929
|
return () => {
|
|
1785
1930
|
if (sourceDebounceRef.current) clearTimeout(sourceDebounceRef.current);
|
|
1786
1931
|
};
|
|
1787
1932
|
}, []);
|
|
1788
1933
|
if (!session || !state) {
|
|
1789
|
-
return /* @__PURE__ */ (0,
|
|
1934
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: `p-4 text-center text-xs text-muted-foreground ${className}`, children: "No effect authoring session is open." });
|
|
1790
1935
|
}
|
|
1791
1936
|
const hasSource = showSource && state.sourceLanguage !== null && typeof session.setSource === "function";
|
|
1792
1937
|
const handleSourceChange = (e) => {
|
|
@@ -1820,10 +1965,10 @@ function EffectAuthoringEditor({
|
|
|
1820
1965
|
const issueLines = new Set(
|
|
1821
1966
|
state.issues.map((i) => i.line).filter((l) => typeof l === "number")
|
|
1822
1967
|
);
|
|
1823
|
-
return /* @__PURE__ */ (0,
|
|
1824
|
-
/* @__PURE__ */ (0,
|
|
1825
|
-
/* @__PURE__ */ (0,
|
|
1826
|
-
/* @__PURE__ */ (0,
|
|
1968
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: `space-y-4 rounded border border-border bg-background p-4 text-foreground ${className}`, "data-effect-authoring-editor": state.name, children: [
|
|
1969
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "flex flex-wrap items-center justify-between gap-2 border-b border-border pb-3", children: [
|
|
1970
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
1971
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1827
1972
|
"button",
|
|
1828
1973
|
{
|
|
1829
1974
|
type: "button",
|
|
@@ -1833,15 +1978,15 @@ function EffectAuthoringEditor({
|
|
|
1833
1978
|
children: state.playing ? "Pause" : "Play"
|
|
1834
1979
|
}
|
|
1835
1980
|
),
|
|
1836
|
-
/* @__PURE__ */ (0,
|
|
1981
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("span", { className: "font-mono text-xs text-muted-foreground", "data-time-readout": true, children: [
|
|
1837
1982
|
state.time,
|
|
1838
1983
|
"ms / ",
|
|
1839
1984
|
state.duration,
|
|
1840
1985
|
"ms"
|
|
1841
1986
|
] })
|
|
1842
1987
|
] }),
|
|
1843
|
-
/* @__PURE__ */ (0,
|
|
1844
|
-
/* @__PURE__ */ (0,
|
|
1988
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
1989
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1845
1990
|
"button",
|
|
1846
1991
|
{
|
|
1847
1992
|
type: "button",
|
|
@@ -1852,7 +1997,7 @@ function EffectAuthoringEditor({
|
|
|
1852
1997
|
children: "Undo"
|
|
1853
1998
|
}
|
|
1854
1999
|
),
|
|
1855
|
-
/* @__PURE__ */ (0,
|
|
2000
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1856
2001
|
"button",
|
|
1857
2002
|
{
|
|
1858
2003
|
type: "button",
|
|
@@ -1863,8 +2008,8 @@ function EffectAuthoringEditor({
|
|
|
1863
2008
|
children: "Redo"
|
|
1864
2009
|
}
|
|
1865
2010
|
),
|
|
1866
|
-
savingPreset ? /* @__PURE__ */ (0,
|
|
1867
|
-
/* @__PURE__ */ (0,
|
|
2011
|
+
savingPreset ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("form", { onSubmit: handleSavePreset, className: "flex items-center gap-1", children: [
|
|
2012
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1868
2013
|
"input",
|
|
1869
2014
|
{
|
|
1870
2015
|
type: "text",
|
|
@@ -1875,7 +2020,7 @@ function EffectAuthoringEditor({
|
|
|
1875
2020
|
onChange: (e) => setPresetName(e.target.value)
|
|
1876
2021
|
}
|
|
1877
2022
|
),
|
|
1878
|
-
/* @__PURE__ */ (0,
|
|
2023
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1879
2024
|
"button",
|
|
1880
2025
|
{
|
|
1881
2026
|
type: "submit",
|
|
@@ -1883,7 +2028,7 @@ function EffectAuthoringEditor({
|
|
|
1883
2028
|
children: "Save"
|
|
1884
2029
|
}
|
|
1885
2030
|
),
|
|
1886
|
-
/* @__PURE__ */ (0,
|
|
2031
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1887
2032
|
"button",
|
|
1888
2033
|
{
|
|
1889
2034
|
type: "button",
|
|
@@ -1892,7 +2037,7 @@ function EffectAuthoringEditor({
|
|
|
1892
2037
|
children: "Cancel"
|
|
1893
2038
|
}
|
|
1894
2039
|
)
|
|
1895
|
-
] }) : /* @__PURE__ */ (0,
|
|
2040
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1896
2041
|
"button",
|
|
1897
2042
|
{
|
|
1898
2043
|
type: "button",
|
|
@@ -1903,11 +2048,11 @@ function EffectAuthoringEditor({
|
|
|
1903
2048
|
)
|
|
1904
2049
|
] })
|
|
1905
2050
|
] }),
|
|
1906
|
-
/* @__PURE__ */ (0,
|
|
1907
|
-
/* @__PURE__ */ (0,
|
|
1908
|
-
/* @__PURE__ */ (0,
|
|
1909
|
-
/* @__PURE__ */ (0,
|
|
1910
|
-
/* @__PURE__ */ (0,
|
|
2051
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "grid grid-cols-1 gap-4 lg:grid-cols-2", children: [
|
|
2052
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "space-y-2", children: [
|
|
2053
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "text-xs font-semibold uppercase tracking-wider text-muted-foreground", children: "Preview" }),
|
|
2054
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "relative flex aspect-video w-full items-center justify-center overflow-hidden rounded border border-border bg-black", children: [
|
|
2055
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1911
2056
|
"canvas",
|
|
1912
2057
|
{
|
|
1913
2058
|
ref: canvasRef,
|
|
@@ -1917,9 +2062,9 @@ function EffectAuthoringEditor({
|
|
|
1917
2062
|
"aria-label": "Effect preview canvas"
|
|
1918
2063
|
}
|
|
1919
2064
|
),
|
|
1920
|
-
previewError && /* @__PURE__ */ (0,
|
|
2065
|
+
previewError && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "absolute inset-0 flex items-center justify-center p-4 text-center text-xs text-white/80", role: "status", "data-effect-preview-error": true, children: previewError })
|
|
1921
2066
|
] }),
|
|
1922
|
-
state.issues.length > 0 && /* @__PURE__ */ (0,
|
|
2067
|
+
state.issues.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "space-y-1 rounded border border-destructive/20 bg-destructive/10 p-2 text-xs", "data-effect-issues": true, children: state.issues.map((issue, idx) => /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
1923
2068
|
"div",
|
|
1924
2069
|
{
|
|
1925
2070
|
className: `cursor-pointer ${issue.severity === "error" ? "text-destructive" : "text-amber-500"}`,
|
|
@@ -1932,17 +2077,17 @@ function EffectAuthoringEditor({
|
|
|
1932
2077
|
idx
|
|
1933
2078
|
)) })
|
|
1934
2079
|
] }),
|
|
1935
|
-
hasSource && /* @__PURE__ */ (0,
|
|
1936
|
-
/* @__PURE__ */ (0,
|
|
2080
|
+
hasSource && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "space-y-2", "data-effect-source-pane": true, children: [
|
|
2081
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "flex items-center justify-between text-xs font-semibold uppercase tracking-wider text-muted-foreground", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("span", { children: [
|
|
1937
2082
|
"Source (",
|
|
1938
2083
|
state.sourceLanguage,
|
|
1939
2084
|
")"
|
|
1940
2085
|
] }) }),
|
|
1941
|
-
/* @__PURE__ */ (0,
|
|
1942
|
-
/* @__PURE__ */ (0,
|
|
2086
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "flex h-64 rounded border border-border bg-muted/20 font-mono text-xs", children: [
|
|
2087
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { ref: gutterRef, className: "select-none overflow-hidden border-r border-border bg-muted/40 px-2 py-2 text-right text-muted-foreground", "aria-hidden": "true", children: sourceLines.map((_, i) => {
|
|
1943
2088
|
const lineNum = i + 1;
|
|
1944
2089
|
const hasIssue = issueLines.has(lineNum);
|
|
1945
|
-
return /* @__PURE__ */ (0,
|
|
2090
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1946
2091
|
"div",
|
|
1947
2092
|
{
|
|
1948
2093
|
"data-gutter-line": lineNum,
|
|
@@ -1952,7 +2097,7 @@ function EffectAuthoringEditor({
|
|
|
1952
2097
|
i
|
|
1953
2098
|
);
|
|
1954
2099
|
}) }),
|
|
1955
|
-
/* @__PURE__ */ (0,
|
|
2100
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1956
2101
|
"textarea",
|
|
1957
2102
|
{
|
|
1958
2103
|
ref: textareaRef,
|
|
@@ -1970,9 +2115,9 @@ function EffectAuthoringEditor({
|
|
|
1970
2115
|
] })
|
|
1971
2116
|
] })
|
|
1972
2117
|
] }),
|
|
1973
|
-
/* @__PURE__ */ (0,
|
|
1974
|
-
/* @__PURE__ */ (0,
|
|
1975
|
-
/* @__PURE__ */ (0,
|
|
2118
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "space-y-2 border-t border-border pt-4", children: [
|
|
2119
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "text-xs font-semibold uppercase tracking-wider text-muted-foreground", children: "Parameters" }),
|
|
2120
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1976
2121
|
EffectParameters,
|
|
1977
2122
|
{
|
|
1978
2123
|
description: state.description,
|
|
@@ -1984,7 +2129,7 @@ function EffectAuthoringEditor({
|
|
|
1984
2129
|
const track = state.tracks[control];
|
|
1985
2130
|
const isAnimated = Boolean(track && track.length > 0);
|
|
1986
2131
|
const hasKeyframeAtPlayhead = isAnimated && track.some((kf) => kf.time === state.time);
|
|
1987
|
-
return /* @__PURE__ */ (0,
|
|
2132
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1988
2133
|
"button",
|
|
1989
2134
|
{
|
|
1990
2135
|
type: "button",
|
|
@@ -2006,17 +2151,17 @@ function EffectAuthoringEditor({
|
|
|
2006
2151
|
}
|
|
2007
2152
|
)
|
|
2008
2153
|
] }),
|
|
2009
|
-
showTimeline && /* @__PURE__ */ (0,
|
|
2010
|
-
/* @__PURE__ */ (0,
|
|
2011
|
-
/* @__PURE__ */ (0,
|
|
2012
|
-
/* @__PURE__ */ (0,
|
|
2013
|
-
/* @__PURE__ */ (0,
|
|
2014
|
-
/* @__PURE__ */ (0,
|
|
2015
|
-
/* @__PURE__ */ (0,
|
|
2016
|
-
/* @__PURE__ */ (0,
|
|
2154
|
+
showTimeline && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "space-y-3 border-t border-border pt-4", "data-effect-timeline": true, children: [
|
|
2155
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "flex flex-wrap items-center justify-between gap-4", children: [
|
|
2156
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "text-xs font-semibold uppercase tracking-wider text-muted-foreground", children: "Timeline" }),
|
|
2157
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "flex items-center gap-3 text-xs", children: [
|
|
2158
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("label", { className: "flex items-center gap-1.5", children: [
|
|
2159
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { children: "Duration:" }),
|
|
2160
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DurationField, { duration: state.duration, onCommit: (duration) => session.setTiming({ duration }) }),
|
|
2161
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "text-muted-foreground", children: "ms" })
|
|
2017
2162
|
] }),
|
|
2018
|
-
/* @__PURE__ */ (0,
|
|
2019
|
-
/* @__PURE__ */ (0,
|
|
2163
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("label", { className: "flex items-center gap-1.5 cursor-pointer", children: [
|
|
2164
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
2020
2165
|
"input",
|
|
2021
2166
|
{
|
|
2022
2167
|
type: "checkbox",
|
|
@@ -2025,11 +2170,11 @@ function EffectAuthoringEditor({
|
|
|
2025
2170
|
onChange: (e) => session.setTiming({ loop: e.target.checked })
|
|
2026
2171
|
}
|
|
2027
2172
|
),
|
|
2028
|
-
/* @__PURE__ */ (0,
|
|
2173
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { children: "Loop" })
|
|
2029
2174
|
] })
|
|
2030
2175
|
] })
|
|
2031
2176
|
] }),
|
|
2032
|
-
/* @__PURE__ */ (0,
|
|
2177
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "space-y-1", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
2033
2178
|
"input",
|
|
2034
2179
|
{
|
|
2035
2180
|
type: "range",
|
|
@@ -2041,12 +2186,12 @@ function EffectAuthoringEditor({
|
|
|
2041
2186
|
className: "w-full cursor-pointer accent-primary"
|
|
2042
2187
|
}
|
|
2043
2188
|
) }),
|
|
2044
|
-
Object.entries(state.tracks).length > 0 && /* @__PURE__ */ (0,
|
|
2189
|
+
Object.entries(state.tracks).length > 0 && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "space-y-2 pt-1", children: Object.entries(state.tracks).map(([control, keyframes]) => {
|
|
2045
2190
|
if (!keyframes || keyframes.length === 0) return null;
|
|
2046
|
-
return /* @__PURE__ */ (0,
|
|
2047
|
-
/* @__PURE__ */ (0,
|
|
2048
|
-
/* @__PURE__ */ (0,
|
|
2049
|
-
/* @__PURE__ */ (0,
|
|
2191
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "space-y-1", "data-track": control, children: [
|
|
2192
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "flex items-center justify-between text-xs text-muted-foreground", children: [
|
|
2193
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "font-medium", children: control }),
|
|
2194
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
2050
2195
|
"button",
|
|
2051
2196
|
{
|
|
2052
2197
|
type: "button",
|
|
@@ -2057,12 +2202,12 @@ function EffectAuthoringEditor({
|
|
|
2057
2202
|
}
|
|
2058
2203
|
)
|
|
2059
2204
|
] }),
|
|
2060
|
-
/* @__PURE__ */ (0,
|
|
2205
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "relative h-4 w-full rounded bg-muted/40", children: keyframes.map((kf, i) => {
|
|
2061
2206
|
const leftPct = Math.max(
|
|
2062
2207
|
0,
|
|
2063
2208
|
Math.min(100, kf.time / (state.duration || 1) * 100)
|
|
2064
2209
|
);
|
|
2065
|
-
return /* @__PURE__ */ (0,
|
|
2210
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
2066
2211
|
"button",
|
|
2067
2212
|
{
|
|
2068
2213
|
type: "button",
|
|
@@ -2082,14 +2227,14 @@ function EffectAuthoringEditor({
|
|
|
2082
2227
|
] });
|
|
2083
2228
|
}
|
|
2084
2229
|
function DurationField({ duration, onCommit }) {
|
|
2085
|
-
const [draft, setDraft] = (0,
|
|
2086
|
-
(0,
|
|
2230
|
+
const [draft, setDraft] = (0, import_react11.useState)(String(duration));
|
|
2231
|
+
(0, import_react11.useEffect)(() => setDraft(String(duration)), [duration]);
|
|
2087
2232
|
const commit = () => {
|
|
2088
2233
|
const next = Number(draft);
|
|
2089
2234
|
if (Number.isFinite(next) && next >= 1 && next !== duration) onCommit(next);
|
|
2090
2235
|
else setDraft(String(duration));
|
|
2091
2236
|
};
|
|
2092
|
-
return /* @__PURE__ */ (0,
|
|
2237
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
2093
2238
|
"input",
|
|
2094
2239
|
{
|
|
2095
2240
|
type: "number",
|