@pixerate/editor-react 0.94.0 → 0.96.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/dist/animation-editor/index.cjs +1240 -195
- package/dist/animation-editor/index.js +4 -2
- package/dist/canvas/index.cjs +1419 -372
- package/dist/canvas/index.js +9 -4
- package/dist/canvas/useMermaidDiagram.d.cts +7 -1
- package/dist/canvas/useMermaidDiagram.d.ts +7 -1
- package/dist/chunk-3I7FOSLF.js +988 -0
- package/dist/{chunk-OTGJEYHV.js → chunk-5LFQ2UQZ.js} +75 -68
- package/dist/{chunk-5R67YSSD.js → chunk-GLSOQNQR.js} +1 -1
- package/dist/{chunk-6YRSQW2V.js → chunk-IY6YOY5B.js} +1 -1
- package/dist/chunk-KIRIU53A.js +72 -0
- package/dist/{chunk-NNM633RN.js → chunk-R7MEGRPV.js} +23 -0
- package/dist/color/ColorPicker.d.cts +30 -0
- package/dist/color/ColorPicker.d.ts +30 -0
- package/dist/color/DualColorPicker.d.cts +29 -0
- package/dist/color/DualColorPicker.d.ts +29 -0
- package/dist/color/index.cjs +1067 -0
- package/dist/color/index.d.cts +7 -0
- package/dist/color/index.d.ts +7 -0
- package/dist/color/index.js +14 -0
- package/dist/color/useColorScheme.d.cts +16 -0
- package/dist/color/useColorScheme.d.ts +16 -0
- package/dist/effects/index.cjs +1169 -124
- package/dist/effects/index.js +4 -2
- package/dist/gradient/FillPicker.d.cts +27 -0
- package/dist/gradient/FillPicker.d.ts +27 -0
- package/dist/gradient/GradientEditor.d.cts +21 -0
- package/dist/gradient/GradientEditor.d.ts +21 -0
- package/dist/gradient/index.cjs +1601 -0
- package/dist/gradient/index.d.cts +6 -0
- package/dist/gradient/index.d.ts +6 -0
- package/dist/gradient/index.js +617 -0
- package/dist/gradient/useGradientController.d.cts +10 -0
- package/dist/gradient/useGradientController.d.ts +10 -0
- package/dist/image-editor/index.cjs +1742 -697
- package/dist/image-editor/index.js +5 -3
- package/dist/index.cjs +2181 -1115
- package/dist/index.js +9 -5
- package/dist/paint-editor/index.cjs +1233 -188
- package/dist/paint-editor/index.js +4 -2
- package/dist/parameters/fields.d.cts +1 -1
- package/dist/parameters/fields.d.ts +1 -1
- package/dist/parameters/index.cjs +1218 -173
- package/dist/parameters/index.js +3 -1
- package/dist/persistence/index.cjs +25 -4
- package/dist/persistence/index.d.cts +1 -0
- package/dist/persistence/index.d.ts +1 -0
- package/dist/persistence/index.js +5 -3
- package/dist/persistence/useEditorAutosave.d.cts +17 -0
- package/dist/persistence/useEditorAutosave.d.ts +17 -0
- package/dist/vector/index.cjs +1219 -174
- package/dist/vector/index.js +4 -2
- package/dist/video-editor/index.cjs +1230 -185
- package/dist/video-editor/index.js +4 -2
- package/package.json +29 -3
|
@@ -17,6 +17,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
}
|
|
18
18
|
return to;
|
|
19
19
|
};
|
|
20
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
20
21
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
22
|
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
23
|
// file that has been converted to a CommonJS file using a Babel-
|
|
@@ -219,7 +220,7 @@ function ShotTimeline({ controller, className = "" }) {
|
|
|
219
220
|
}
|
|
220
221
|
|
|
221
222
|
// src/animation-editor/AnimationEditor.tsx
|
|
222
|
-
var
|
|
223
|
+
var import_react21 = require("react");
|
|
223
224
|
|
|
224
225
|
// src/playback/AgentPlaybackContext.tsx
|
|
225
226
|
var import_react3 = require("react");
|
|
@@ -1271,14 +1272,1055 @@ function EffectsBrowser({ provider, uses, kinds, onPick, thumbnails = true, titl
|
|
|
1271
1272
|
}
|
|
1272
1273
|
|
|
1273
1274
|
// src/effects/EffectParameters.tsx
|
|
1274
|
-
var
|
|
1275
|
+
var import_react19 = __toESM(require("react"), 1);
|
|
1275
1276
|
var import_effects3 = require("@pixerate/editor/effects");
|
|
1276
1277
|
var import_parameters2 = require("@pixerate/editor/parameters");
|
|
1277
1278
|
|
|
1278
1279
|
// src/parameters/fields.tsx
|
|
1279
|
-
var
|
|
1280
|
+
var import_react18 = require("react");
|
|
1280
1281
|
var import_parameters = require("@pixerate/editor/parameters");
|
|
1282
|
+
|
|
1283
|
+
// src/color/index.ts
|
|
1284
|
+
var color_exports = {};
|
|
1285
|
+
__export(color_exports, {
|
|
1286
|
+
ColorPicker: () => ColorPicker,
|
|
1287
|
+
DualColorPicker: () => DualColorPicker,
|
|
1288
|
+
useColorScheme: () => useColorScheme,
|
|
1289
|
+
useResolvedColor: () => useResolvedColor
|
|
1290
|
+
});
|
|
1291
|
+
|
|
1292
|
+
// src/color/ColorPicker.tsx
|
|
1293
|
+
var import_react15 = require("react");
|
|
1294
|
+
var import_color = require("@pixerate/editor/color");
|
|
1281
1295
|
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
1296
|
+
var LOCAL_STORAGE_KEY = "pixerate:color:recent";
|
|
1297
|
+
function readLocalRecents() {
|
|
1298
|
+
try {
|
|
1299
|
+
if (typeof localStorage === "undefined") return [];
|
|
1300
|
+
const raw = localStorage.getItem(LOCAL_STORAGE_KEY);
|
|
1301
|
+
if (!raw) return [];
|
|
1302
|
+
const parsed = JSON.parse(raw);
|
|
1303
|
+
return Array.isArray(parsed) ? parsed : [];
|
|
1304
|
+
} catch {
|
|
1305
|
+
return [];
|
|
1306
|
+
}
|
|
1307
|
+
}
|
|
1308
|
+
function writeLocalRecents(list) {
|
|
1309
|
+
try {
|
|
1310
|
+
if (typeof localStorage !== "undefined") {
|
|
1311
|
+
localStorage.setItem(LOCAL_STORAGE_KEY, JSON.stringify(list));
|
|
1312
|
+
}
|
|
1313
|
+
} catch {
|
|
1314
|
+
}
|
|
1315
|
+
}
|
|
1316
|
+
var CHECKERBOARD_BG = "repeating-conic-gradient(var(--pixerate-checker-a, #d4d4d8) 0 25%, var(--pixerate-checker-b, #ffffff) 0 50%)";
|
|
1317
|
+
var DEFAULT_PICKER_STATE = { h: 0, s: 1, v: 1, alpha: 1 };
|
|
1318
|
+
var ColorPicker = ({
|
|
1319
|
+
value,
|
|
1320
|
+
onChange,
|
|
1321
|
+
onGestureStart,
|
|
1322
|
+
onGestureEnd,
|
|
1323
|
+
alpha = false,
|
|
1324
|
+
swatches,
|
|
1325
|
+
recent: controlledRecent,
|
|
1326
|
+
onRecentChange,
|
|
1327
|
+
contrastAgainst,
|
|
1328
|
+
disabled = false,
|
|
1329
|
+
className,
|
|
1330
|
+
id,
|
|
1331
|
+
"aria-label": ariaLabel = "Color picker"
|
|
1332
|
+
}) => {
|
|
1333
|
+
const generatedId = (0, import_react15.useId)();
|
|
1334
|
+
const pickerId = id || generatedId;
|
|
1335
|
+
const [pickerState, setPickerState] = (0, import_react15.useState)(
|
|
1336
|
+
() => (0, import_color.pickerStateFromColor)(value) ?? DEFAULT_PICKER_STATE
|
|
1337
|
+
);
|
|
1338
|
+
const stateRef = (0, import_react15.useRef)(pickerState);
|
|
1339
|
+
stateRef.current = pickerState;
|
|
1340
|
+
(0, import_react15.useEffect)(() => {
|
|
1341
|
+
const next = (0, import_color.pickerStateFromColor)(value, stateRef.current);
|
|
1342
|
+
if (next) {
|
|
1343
|
+
setPickerState(next);
|
|
1344
|
+
}
|
|
1345
|
+
}, [value]);
|
|
1346
|
+
const [internalRecent, setInternalRecent] = (0, import_react15.useState)(
|
|
1347
|
+
() => controlledRecent ? [] : readLocalRecents()
|
|
1348
|
+
);
|
|
1349
|
+
const activeRecent = controlledRecent ?? internalRecent;
|
|
1350
|
+
const recordRecent = (0, import_react15.useCallback)(
|
|
1351
|
+
(color) => {
|
|
1352
|
+
const updated = (0, import_color.pushRecentColor)(activeRecent, color, 12);
|
|
1353
|
+
if (!controlledRecent) {
|
|
1354
|
+
setInternalRecent(updated);
|
|
1355
|
+
writeLocalRecents(updated);
|
|
1356
|
+
}
|
|
1357
|
+
onRecentChange?.(updated);
|
|
1358
|
+
},
|
|
1359
|
+
[activeRecent, controlledRecent, onRecentChange]
|
|
1360
|
+
);
|
|
1361
|
+
const [textDraft, setTextDraft] = (0, import_react15.useState)(value);
|
|
1362
|
+
const [isInvalid, setIsInvalid] = (0, import_react15.useState)(false);
|
|
1363
|
+
const [isClipped, setIsClipped] = (0, import_react15.useState)(false);
|
|
1364
|
+
const isTypingRef = (0, import_react15.useRef)(false);
|
|
1365
|
+
(0, import_react15.useEffect)(() => {
|
|
1366
|
+
if (!isTypingRef.current) {
|
|
1367
|
+
setTextDraft(value);
|
|
1368
|
+
setIsInvalid(false);
|
|
1369
|
+
const parsed = (0, import_color.parseColor)(value);
|
|
1370
|
+
setIsClipped(Boolean(parsed && !(0, import_color.inSrgbGamut)(parsed)));
|
|
1371
|
+
}
|
|
1372
|
+
}, [value]);
|
|
1373
|
+
const [hasEyeDropper, setHasEyeDropper] = (0, import_react15.useState)(false);
|
|
1374
|
+
(0, import_react15.useEffect)(() => {
|
|
1375
|
+
setHasEyeDropper(typeof window !== "undefined" && "EyeDropper" in window);
|
|
1376
|
+
}, []);
|
|
1377
|
+
const emitColorChange = (0, import_react15.useCallback)(
|
|
1378
|
+
(nextState) => {
|
|
1379
|
+
setPickerState(nextState);
|
|
1380
|
+
const hex = (0, import_color.pickerStateToHex)(nextState, alpha);
|
|
1381
|
+
onChange(hex);
|
|
1382
|
+
},
|
|
1383
|
+
[alpha, onChange]
|
|
1384
|
+
);
|
|
1385
|
+
const latest = (0, import_react15.useRef)({ emitColorChange, recordRecent, onGestureEnd, alpha });
|
|
1386
|
+
latest.current = { emitColorChange, recordRecent, onGestureEnd, alpha };
|
|
1387
|
+
const endDragRef = (0, import_react15.useRef)(null);
|
|
1388
|
+
(0, import_react15.useEffect)(() => () => endDragRef.current?.(), []);
|
|
1389
|
+
const startDrag = (e, next) => {
|
|
1390
|
+
if (disabled) return;
|
|
1391
|
+
e.preventDefault();
|
|
1392
|
+
endDragRef.current?.();
|
|
1393
|
+
onGestureStart?.();
|
|
1394
|
+
const rect = e.currentTarget.getBoundingClientRect();
|
|
1395
|
+
const update = (clientX, clientY) => {
|
|
1396
|
+
const x = Math.max(0, Math.min(1, (clientX - rect.left) / rect.width));
|
|
1397
|
+
const y = Math.max(0, Math.min(1, (clientY - rect.top) / rect.height));
|
|
1398
|
+
latest.current.emitColorChange(next(stateRef.current, x, y));
|
|
1399
|
+
};
|
|
1400
|
+
update(e.clientX, e.clientY);
|
|
1401
|
+
const onPointerMove = (ev) => update(ev.clientX, ev.clientY);
|
|
1402
|
+
const end = () => {
|
|
1403
|
+
window.removeEventListener("pointermove", onPointerMove);
|
|
1404
|
+
window.removeEventListener("pointerup", onPointerUp);
|
|
1405
|
+
window.removeEventListener("pointercancel", onPointerUp);
|
|
1406
|
+
endDragRef.current = null;
|
|
1407
|
+
latest.current.onGestureEnd?.();
|
|
1408
|
+
};
|
|
1409
|
+
const onPointerUp = () => {
|
|
1410
|
+
end();
|
|
1411
|
+
latest.current.recordRecent((0, import_color.pickerStateToHex)(stateRef.current, latest.current.alpha));
|
|
1412
|
+
};
|
|
1413
|
+
endDragRef.current = end;
|
|
1414
|
+
window.addEventListener("pointermove", onPointerMove);
|
|
1415
|
+
window.addEventListener("pointerup", onPointerUp);
|
|
1416
|
+
window.addEventListener("pointercancel", onPointerUp);
|
|
1417
|
+
};
|
|
1418
|
+
const handleAreaPointerDown = (e) => startDrag(e, (state, x, y) => (0, import_color.pickerStateFromArea)(state, x, y));
|
|
1419
|
+
const handleHuePointerDown = (e) => startDrag(e, (state, x) => (0, import_color.pickerStateFromHue)(state, x));
|
|
1420
|
+
const handleAlphaPointerDown = (e) => startDrag(e, (state, x) => (0, import_color.pickerStateFromAlpha)(state, x));
|
|
1421
|
+
const handleAreaKeyDown = (e) => {
|
|
1422
|
+
if (disabled) return;
|
|
1423
|
+
const next = (0, import_color.pickerKeyStep)(pickerState, "area", e.key, e.shiftKey);
|
|
1424
|
+
if (next) {
|
|
1425
|
+
e.preventDefault();
|
|
1426
|
+
emitColorChange(next);
|
|
1427
|
+
recordRecent((0, import_color.pickerStateToHex)(next, alpha));
|
|
1428
|
+
}
|
|
1429
|
+
};
|
|
1430
|
+
const handleHueKeyDown = (e) => {
|
|
1431
|
+
if (disabled) return;
|
|
1432
|
+
const next = (0, import_color.pickerKeyStep)(pickerState, "hue", e.key, e.shiftKey);
|
|
1433
|
+
if (next) {
|
|
1434
|
+
e.preventDefault();
|
|
1435
|
+
emitColorChange(next);
|
|
1436
|
+
recordRecent((0, import_color.pickerStateToHex)(next, alpha));
|
|
1437
|
+
}
|
|
1438
|
+
};
|
|
1439
|
+
const handleAlphaKeyDown = (e) => {
|
|
1440
|
+
if (disabled) return;
|
|
1441
|
+
const next = (0, import_color.pickerKeyStep)(pickerState, "alpha", e.key, e.shiftKey);
|
|
1442
|
+
if (next) {
|
|
1443
|
+
e.preventDefault();
|
|
1444
|
+
emitColorChange(next);
|
|
1445
|
+
recordRecent((0, import_color.pickerStateToHex)(next, alpha));
|
|
1446
|
+
}
|
|
1447
|
+
};
|
|
1448
|
+
const commitTextInput = (inputElement) => {
|
|
1449
|
+
isTypingRef.current = false;
|
|
1450
|
+
const parsed = (0, import_color.parseColor)(textDraft);
|
|
1451
|
+
if (parsed) {
|
|
1452
|
+
setIsInvalid(false);
|
|
1453
|
+
setIsClipped(!(0, import_color.inSrgbGamut)(parsed));
|
|
1454
|
+
const formatted = (0, import_color.formatHex)(parsed);
|
|
1455
|
+
onChange(formatted);
|
|
1456
|
+
recordRecent(formatted);
|
|
1457
|
+
} else {
|
|
1458
|
+
setIsInvalid(true);
|
|
1459
|
+
setTextDraft(value);
|
|
1460
|
+
if (inputElement) {
|
|
1461
|
+
inputElement.value = value;
|
|
1462
|
+
}
|
|
1463
|
+
}
|
|
1464
|
+
};
|
|
1465
|
+
const handleTextKeyDown = (e) => {
|
|
1466
|
+
if (e.key === "Enter") {
|
|
1467
|
+
e.preventDefault();
|
|
1468
|
+
commitTextInput(e.currentTarget);
|
|
1469
|
+
} else if (e.key === "Escape") {
|
|
1470
|
+
e.preventDefault();
|
|
1471
|
+
isTypingRef.current = false;
|
|
1472
|
+
setIsInvalid(false);
|
|
1473
|
+
setTextDraft(value);
|
|
1474
|
+
e.currentTarget.value = value;
|
|
1475
|
+
}
|
|
1476
|
+
};
|
|
1477
|
+
const handleEyeDropper = async () => {
|
|
1478
|
+
if (disabled || !hasEyeDropper) return;
|
|
1479
|
+
try {
|
|
1480
|
+
const EyeDropperClass = window.EyeDropper;
|
|
1481
|
+
const eyeDropper = new EyeDropperClass();
|
|
1482
|
+
const res = await eyeDropper.open();
|
|
1483
|
+
if (res?.sRGBHex) {
|
|
1484
|
+
onChange(res.sRGBHex);
|
|
1485
|
+
recordRecent(res.sRGBHex);
|
|
1486
|
+
}
|
|
1487
|
+
} catch {
|
|
1488
|
+
}
|
|
1489
|
+
};
|
|
1490
|
+
const contrastResult = (0, import_react15.useMemo)(() => {
|
|
1491
|
+
if (!contrastAgainst) return null;
|
|
1492
|
+
const fg = (0, import_color.parseColor)(value);
|
|
1493
|
+
const bg = (0, import_color.parseColor)(contrastAgainst);
|
|
1494
|
+
if (!fg || !bg) return null;
|
|
1495
|
+
const ratio = (0, import_color.contrastRatio)(fg, bg);
|
|
1496
|
+
const aa = ratio >= 4.5;
|
|
1497
|
+
const aaa = ratio >= 7;
|
|
1498
|
+
return { ratio, aa, aaa };
|
|
1499
|
+
}, [value, contrastAgainst]);
|
|
1500
|
+
const currentHex = (0, import_color.pickerStateToHex)(pickerState, alpha);
|
|
1501
|
+
const liveDescription = `Selected color: ${value}${contrastResult ? `, contrast ${contrastResult.ratio.toFixed(1)}:1 against ${contrastAgainst}, ${contrastResult.aa ? "passes AA" : "fails AA"}` : ""}`;
|
|
1502
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
1503
|
+
"div",
|
|
1504
|
+
{
|
|
1505
|
+
id: pickerId,
|
|
1506
|
+
role: "group",
|
|
1507
|
+
"aria-label": ariaLabel,
|
|
1508
|
+
className,
|
|
1509
|
+
style: {
|
|
1510
|
+
boxSizing: "border-box",
|
|
1511
|
+
width: "var(--pixerate-color-picker-width, 240px)",
|
|
1512
|
+
borderRadius: "var(--pixerate-color-picker-radius, 8px)",
|
|
1513
|
+
background: "var(--pixerate-color-picker-bg, #1f2430)",
|
|
1514
|
+
color: "var(--pixerate-color-picker-fg, #f0f2f5)",
|
|
1515
|
+
padding: "12px",
|
|
1516
|
+
display: "flex",
|
|
1517
|
+
flexDirection: "column",
|
|
1518
|
+
gap: "10px",
|
|
1519
|
+
fontFamily: "system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif",
|
|
1520
|
+
fontSize: "12px",
|
|
1521
|
+
userSelect: "none",
|
|
1522
|
+
opacity: disabled ? 0.6 : 1,
|
|
1523
|
+
pointerEvents: disabled ? "none" : "auto"
|
|
1524
|
+
},
|
|
1525
|
+
children: [
|
|
1526
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1527
|
+
"span",
|
|
1528
|
+
{
|
|
1529
|
+
role: "status",
|
|
1530
|
+
"aria-live": "polite",
|
|
1531
|
+
style: {
|
|
1532
|
+
position: "absolute",
|
|
1533
|
+
width: "1px",
|
|
1534
|
+
height: "1px",
|
|
1535
|
+
padding: 0,
|
|
1536
|
+
margin: "-1px",
|
|
1537
|
+
overflow: "hidden",
|
|
1538
|
+
clip: "rect(0, 0, 0, 0)",
|
|
1539
|
+
whiteSpace: "nowrap",
|
|
1540
|
+
border: 0
|
|
1541
|
+
},
|
|
1542
|
+
children: liveDescription
|
|
1543
|
+
}
|
|
1544
|
+
),
|
|
1545
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1546
|
+
"div",
|
|
1547
|
+
{
|
|
1548
|
+
role: "slider",
|
|
1549
|
+
tabIndex: disabled ? -1 : 0,
|
|
1550
|
+
"aria-label": "Saturation and brightness",
|
|
1551
|
+
"aria-valuetext": `Saturation ${Math.round(pickerState.s * 100)}%, Brightness ${Math.round(
|
|
1552
|
+
pickerState.v * 100
|
|
1553
|
+
)}%`,
|
|
1554
|
+
"aria-disabled": disabled,
|
|
1555
|
+
onPointerDown: handleAreaPointerDown,
|
|
1556
|
+
onKeyDown: handleAreaKeyDown,
|
|
1557
|
+
style: {
|
|
1558
|
+
position: "relative",
|
|
1559
|
+
width: "100%",
|
|
1560
|
+
height: "150px",
|
|
1561
|
+
borderRadius: "6px",
|
|
1562
|
+
background: (0, import_color.pickerAreaBackground)(pickerState),
|
|
1563
|
+
cursor: disabled ? "default" : "crosshair",
|
|
1564
|
+
touchAction: "none",
|
|
1565
|
+
outline: "none"
|
|
1566
|
+
},
|
|
1567
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1568
|
+
"div",
|
|
1569
|
+
{
|
|
1570
|
+
style: {
|
|
1571
|
+
position: "absolute",
|
|
1572
|
+
width: "var(--pixerate-color-picker-thumb-size, 14px)",
|
|
1573
|
+
height: "var(--pixerate-color-picker-thumb-size, 14px)",
|
|
1574
|
+
borderRadius: "50%",
|
|
1575
|
+
transform: "translate(-50%, -50%)",
|
|
1576
|
+
left: `${pickerState.s * 100}%`,
|
|
1577
|
+
top: `${(1 - pickerState.v) * 100}%`,
|
|
1578
|
+
border: "2px solid #ffffff",
|
|
1579
|
+
boxShadow: "0 0 2px 1px rgba(0,0,0,0.6)",
|
|
1580
|
+
pointerEvents: "none",
|
|
1581
|
+
backgroundColor: currentHex
|
|
1582
|
+
}
|
|
1583
|
+
}
|
|
1584
|
+
)
|
|
1585
|
+
}
|
|
1586
|
+
),
|
|
1587
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1588
|
+
"div",
|
|
1589
|
+
{
|
|
1590
|
+
role: "slider",
|
|
1591
|
+
tabIndex: disabled ? -1 : 0,
|
|
1592
|
+
"aria-label": "Hue",
|
|
1593
|
+
"aria-valuenow": Math.round(pickerState.h),
|
|
1594
|
+
"aria-valuemin": 0,
|
|
1595
|
+
"aria-valuemax": 360,
|
|
1596
|
+
"aria-valuetext": `${Math.round(pickerState.h)} degrees`,
|
|
1597
|
+
"aria-disabled": disabled,
|
|
1598
|
+
onPointerDown: handleHuePointerDown,
|
|
1599
|
+
onKeyDown: handleHueKeyDown,
|
|
1600
|
+
style: {
|
|
1601
|
+
position: "relative",
|
|
1602
|
+
width: "100%",
|
|
1603
|
+
height: "12px",
|
|
1604
|
+
borderRadius: "6px",
|
|
1605
|
+
background: import_color.PICKER_HUE_BACKGROUND,
|
|
1606
|
+
cursor: disabled ? "default" : "pointer",
|
|
1607
|
+
touchAction: "none",
|
|
1608
|
+
outline: "none"
|
|
1609
|
+
},
|
|
1610
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1611
|
+
"div",
|
|
1612
|
+
{
|
|
1613
|
+
style: {
|
|
1614
|
+
position: "absolute",
|
|
1615
|
+
top: "50%",
|
|
1616
|
+
transform: "translate(-50%, -50%)",
|
|
1617
|
+
left: `${pickerState.h / 360 * 100}%`,
|
|
1618
|
+
width: "var(--pixerate-color-picker-thumb-size, 14px)",
|
|
1619
|
+
height: "var(--pixerate-color-picker-thumb-size, 14px)",
|
|
1620
|
+
borderRadius: "50%",
|
|
1621
|
+
border: "2px solid #ffffff",
|
|
1622
|
+
boxShadow: "0 0 2px 1px rgba(0,0,0,0.6)",
|
|
1623
|
+
pointerEvents: "none",
|
|
1624
|
+
backgroundColor: `hsl(${pickerState.h}, 100%, 50%)`
|
|
1625
|
+
}
|
|
1626
|
+
}
|
|
1627
|
+
)
|
|
1628
|
+
}
|
|
1629
|
+
),
|
|
1630
|
+
alpha && /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
1631
|
+
"div",
|
|
1632
|
+
{
|
|
1633
|
+
role: "slider",
|
|
1634
|
+
tabIndex: disabled ? -1 : 0,
|
|
1635
|
+
"aria-label": "Alpha",
|
|
1636
|
+
"aria-valuenow": Math.round(pickerState.alpha * 100),
|
|
1637
|
+
"aria-valuemin": 0,
|
|
1638
|
+
"aria-valuemax": 100,
|
|
1639
|
+
"aria-valuetext": `${Math.round(pickerState.alpha * 100)}%`,
|
|
1640
|
+
"aria-disabled": disabled,
|
|
1641
|
+
onPointerDown: handleAlphaPointerDown,
|
|
1642
|
+
onKeyDown: handleAlphaKeyDown,
|
|
1643
|
+
style: {
|
|
1644
|
+
position: "relative",
|
|
1645
|
+
width: "100%",
|
|
1646
|
+
height: "12px",
|
|
1647
|
+
borderRadius: "6px",
|
|
1648
|
+
backgroundImage: CHECKERBOARD_BG,
|
|
1649
|
+
backgroundSize: "8px 8px",
|
|
1650
|
+
cursor: disabled ? "default" : "pointer",
|
|
1651
|
+
touchAction: "none",
|
|
1652
|
+
outline: "none",
|
|
1653
|
+
overflow: "hidden"
|
|
1654
|
+
},
|
|
1655
|
+
children: [
|
|
1656
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1657
|
+
"div",
|
|
1658
|
+
{
|
|
1659
|
+
style: {
|
|
1660
|
+
position: "absolute",
|
|
1661
|
+
inset: 0,
|
|
1662
|
+
background: (0, import_color.pickerAlphaBackground)(pickerState)
|
|
1663
|
+
}
|
|
1664
|
+
}
|
|
1665
|
+
),
|
|
1666
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1667
|
+
"div",
|
|
1668
|
+
{
|
|
1669
|
+
style: {
|
|
1670
|
+
position: "absolute",
|
|
1671
|
+
top: "50%",
|
|
1672
|
+
transform: "translate(-50%, -50%)",
|
|
1673
|
+
left: `${pickerState.alpha * 100}%`,
|
|
1674
|
+
width: "var(--pixerate-color-picker-thumb-size, 14px)",
|
|
1675
|
+
height: "var(--pixerate-color-picker-thumb-size, 14px)",
|
|
1676
|
+
borderRadius: "50%",
|
|
1677
|
+
border: "2px solid #ffffff",
|
|
1678
|
+
boxShadow: "0 0 2px 1px rgba(0,0,0,0.6)",
|
|
1679
|
+
pointerEvents: "none",
|
|
1680
|
+
backgroundColor: currentHex
|
|
1681
|
+
}
|
|
1682
|
+
}
|
|
1683
|
+
)
|
|
1684
|
+
]
|
|
1685
|
+
}
|
|
1686
|
+
),
|
|
1687
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "8px", marginTop: "2px" }, children: [
|
|
1688
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1689
|
+
"div",
|
|
1690
|
+
{
|
|
1691
|
+
style: {
|
|
1692
|
+
position: "relative",
|
|
1693
|
+
width: "28px",
|
|
1694
|
+
height: "28px",
|
|
1695
|
+
borderRadius: "4px",
|
|
1696
|
+
backgroundImage: CHECKERBOARD_BG,
|
|
1697
|
+
backgroundSize: "8px 8px",
|
|
1698
|
+
overflow: "hidden",
|
|
1699
|
+
flexShrink: 0,
|
|
1700
|
+
border: "1px solid rgba(255,255,255,0.15)"
|
|
1701
|
+
},
|
|
1702
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1703
|
+
"div",
|
|
1704
|
+
{
|
|
1705
|
+
style: {
|
|
1706
|
+
width: "100%",
|
|
1707
|
+
height: "100%",
|
|
1708
|
+
backgroundColor: currentHex
|
|
1709
|
+
}
|
|
1710
|
+
}
|
|
1711
|
+
)
|
|
1712
|
+
}
|
|
1713
|
+
),
|
|
1714
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1715
|
+
"input",
|
|
1716
|
+
{
|
|
1717
|
+
type: "text",
|
|
1718
|
+
value: textDraft,
|
|
1719
|
+
disabled,
|
|
1720
|
+
"aria-label": "Color hex or CSS string",
|
|
1721
|
+
"aria-invalid": isInvalid ? "true" : void 0,
|
|
1722
|
+
onChange: (e) => {
|
|
1723
|
+
isTypingRef.current = true;
|
|
1724
|
+
setTextDraft(e.target.value);
|
|
1725
|
+
setIsInvalid(false);
|
|
1726
|
+
},
|
|
1727
|
+
onKeyDown: handleTextKeyDown,
|
|
1728
|
+
onBlur: (e) => commitTextInput(e.currentTarget),
|
|
1729
|
+
style: {
|
|
1730
|
+
flex: 1,
|
|
1731
|
+
minWidth: 0,
|
|
1732
|
+
height: "28px",
|
|
1733
|
+
padding: "0 8px",
|
|
1734
|
+
fontSize: "12px",
|
|
1735
|
+
fontFamily: "monospace",
|
|
1736
|
+
borderRadius: "4px",
|
|
1737
|
+
border: isInvalid ? "1px solid #ef4444" : "1px solid rgba(255,255,255,0.2)",
|
|
1738
|
+
background: "rgba(0,0,0,0.2)",
|
|
1739
|
+
color: "inherit",
|
|
1740
|
+
outline: "none"
|
|
1741
|
+
}
|
|
1742
|
+
}
|
|
1743
|
+
),
|
|
1744
|
+
hasEyeDropper && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1745
|
+
"button",
|
|
1746
|
+
{
|
|
1747
|
+
type: "button",
|
|
1748
|
+
disabled,
|
|
1749
|
+
"aria-label": "Pick color from screen",
|
|
1750
|
+
title: "Pick color from screen",
|
|
1751
|
+
onClick: handleEyeDropper,
|
|
1752
|
+
style: {
|
|
1753
|
+
display: "inline-flex",
|
|
1754
|
+
alignItems: "center",
|
|
1755
|
+
justifyContent: "center",
|
|
1756
|
+
width: "28px",
|
|
1757
|
+
height: "28px",
|
|
1758
|
+
borderRadius: "4px",
|
|
1759
|
+
border: "1px solid rgba(255,255,255,0.2)",
|
|
1760
|
+
background: "transparent",
|
|
1761
|
+
color: "inherit",
|
|
1762
|
+
cursor: disabled ? "default" : "pointer"
|
|
1763
|
+
},
|
|
1764
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
1765
|
+
"svg",
|
|
1766
|
+
{
|
|
1767
|
+
width: "14",
|
|
1768
|
+
height: "14",
|
|
1769
|
+
viewBox: "0 0 24 24",
|
|
1770
|
+
fill: "none",
|
|
1771
|
+
stroke: "currentColor",
|
|
1772
|
+
strokeWidth: "2",
|
|
1773
|
+
strokeLinecap: "round",
|
|
1774
|
+
strokeLinejoin: "round",
|
|
1775
|
+
children: [
|
|
1776
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("path", { d: "m19 11-8-8-8.5 8.5a2.12 2.12 0 0 0 0 3l2.5 2.5 1.5-1.5" }),
|
|
1777
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("path", { d: "m5 16-3 3 1 1 3-3" }),
|
|
1778
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("path", { d: "m14 6 4 4" })
|
|
1779
|
+
]
|
|
1780
|
+
}
|
|
1781
|
+
)
|
|
1782
|
+
}
|
|
1783
|
+
)
|
|
1784
|
+
] }),
|
|
1785
|
+
isClipped && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1786
|
+
"div",
|
|
1787
|
+
{
|
|
1788
|
+
role: "note",
|
|
1789
|
+
title: "This colour was outside standard sRGB and clipped.",
|
|
1790
|
+
style: {
|
|
1791
|
+
display: "inline-flex",
|
|
1792
|
+
alignItems: "center",
|
|
1793
|
+
gap: "4px",
|
|
1794
|
+
fontSize: "10px",
|
|
1795
|
+
color: "#f59e0b",
|
|
1796
|
+
background: "rgba(245, 158, 11, 0.1)",
|
|
1797
|
+
padding: "2px 6px",
|
|
1798
|
+
borderRadius: "4px",
|
|
1799
|
+
alignSelf: "flex-start"
|
|
1800
|
+
},
|
|
1801
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { children: "\u26A0 Clipped to sRGB" })
|
|
1802
|
+
}
|
|
1803
|
+
),
|
|
1804
|
+
contrastResult && /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
1805
|
+
"div",
|
|
1806
|
+
{
|
|
1807
|
+
style: {
|
|
1808
|
+
display: "flex",
|
|
1809
|
+
alignItems: "center",
|
|
1810
|
+
justifyContent: "space-between",
|
|
1811
|
+
fontSize: "11px",
|
|
1812
|
+
padding: "4px 8px",
|
|
1813
|
+
borderRadius: "4px",
|
|
1814
|
+
background: "rgba(255,255,255,0.05)",
|
|
1815
|
+
border: "1px solid rgba(255,255,255,0.1)"
|
|
1816
|
+
},
|
|
1817
|
+
children: [
|
|
1818
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("span", { children: [
|
|
1819
|
+
"Contrast: ",
|
|
1820
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("strong", { children: [
|
|
1821
|
+
contrastResult.ratio.toFixed(2),
|
|
1822
|
+
":1"
|
|
1823
|
+
] })
|
|
1824
|
+
] }),
|
|
1825
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { style: { display: "flex", gap: "6px" }, children: [
|
|
1826
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
1827
|
+
"span",
|
|
1828
|
+
{
|
|
1829
|
+
style: {
|
|
1830
|
+
color: contrastResult.aa ? "#10b981" : "#ef4444",
|
|
1831
|
+
fontWeight: 600
|
|
1832
|
+
},
|
|
1833
|
+
children: [
|
|
1834
|
+
"AA ",
|
|
1835
|
+
contrastResult.aa ? "\u2713" : "\u2717"
|
|
1836
|
+
]
|
|
1837
|
+
}
|
|
1838
|
+
),
|
|
1839
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
1840
|
+
"span",
|
|
1841
|
+
{
|
|
1842
|
+
style: {
|
|
1843
|
+
color: contrastResult.aaa ? "#10b981" : "#ef4444",
|
|
1844
|
+
fontWeight: 600
|
|
1845
|
+
},
|
|
1846
|
+
children: [
|
|
1847
|
+
"AAA ",
|
|
1848
|
+
contrastResult.aaa ? "\u2713" : "\u2717"
|
|
1849
|
+
]
|
|
1850
|
+
}
|
|
1851
|
+
)
|
|
1852
|
+
] })
|
|
1853
|
+
]
|
|
1854
|
+
}
|
|
1855
|
+
),
|
|
1856
|
+
swatches && swatches.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { style: { display: "flex", flexDirection: "column", gap: "4px" }, children: [
|
|
1857
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { style: { fontSize: "10px", textTransform: "uppercase", opacity: 0.6 }, children: "Palette" }),
|
|
1858
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { style: { display: "flex", flexWrap: "wrap", gap: "4px" }, children: swatches.map((color, idx) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1859
|
+
"button",
|
|
1860
|
+
{
|
|
1861
|
+
type: "button",
|
|
1862
|
+
"data-testid": "color-picker-swatch",
|
|
1863
|
+
title: color,
|
|
1864
|
+
disabled,
|
|
1865
|
+
"aria-label": `Color ${color}`,
|
|
1866
|
+
onClick: () => {
|
|
1867
|
+
onChange(color);
|
|
1868
|
+
recordRecent(color);
|
|
1869
|
+
},
|
|
1870
|
+
style: {
|
|
1871
|
+
width: "18px",
|
|
1872
|
+
height: "18px",
|
|
1873
|
+
borderRadius: "3px",
|
|
1874
|
+
backgroundColor: color,
|
|
1875
|
+
border: color.toLowerCase() === value.toLowerCase() ? "2px solid #ffffff" : "1px solid rgba(255,255,255,0.2)",
|
|
1876
|
+
cursor: disabled ? "default" : "pointer",
|
|
1877
|
+
padding: 0,
|
|
1878
|
+
outline: "none"
|
|
1879
|
+
}
|
|
1880
|
+
},
|
|
1881
|
+
`${color}-${idx}`
|
|
1882
|
+
)) })
|
|
1883
|
+
] }),
|
|
1884
|
+
activeRecent.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { style: { display: "flex", flexDirection: "column", gap: "4px" }, children: [
|
|
1885
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { style: { fontSize: "10px", textTransform: "uppercase", opacity: 0.6 }, children: "Recent" }),
|
|
1886
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { style: { display: "flex", flexWrap: "wrap", gap: "4px" }, children: activeRecent.map((color, idx) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1887
|
+
"button",
|
|
1888
|
+
{
|
|
1889
|
+
type: "button",
|
|
1890
|
+
"data-testid": "color-picker-recent",
|
|
1891
|
+
disabled,
|
|
1892
|
+
"aria-label": `Color ${color}`,
|
|
1893
|
+
onClick: () => {
|
|
1894
|
+
onChange(color);
|
|
1895
|
+
recordRecent(color);
|
|
1896
|
+
},
|
|
1897
|
+
style: {
|
|
1898
|
+
width: "18px",
|
|
1899
|
+
height: "18px",
|
|
1900
|
+
borderRadius: "3px",
|
|
1901
|
+
backgroundColor: color,
|
|
1902
|
+
border: color.toLowerCase() === value.toLowerCase() ? "2px solid #ffffff" : "1px solid rgba(255,255,255,0.2)",
|
|
1903
|
+
cursor: disabled ? "default" : "pointer",
|
|
1904
|
+
padding: 0,
|
|
1905
|
+
outline: "none"
|
|
1906
|
+
}
|
|
1907
|
+
},
|
|
1908
|
+
`recent-${color}-${idx}`
|
|
1909
|
+
)) })
|
|
1910
|
+
] })
|
|
1911
|
+
]
|
|
1912
|
+
}
|
|
1913
|
+
);
|
|
1914
|
+
};
|
|
1915
|
+
|
|
1916
|
+
// src/color/DualColorPicker.tsx
|
|
1917
|
+
var import_react16 = require("react");
|
|
1918
|
+
var import_color2 = require("@pixerate/editor/color");
|
|
1919
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
1920
|
+
function DualColorPicker({
|
|
1921
|
+
value,
|
|
1922
|
+
onChange,
|
|
1923
|
+
onGestureStart,
|
|
1924
|
+
onGestureEnd,
|
|
1925
|
+
scheme: controlledScheme,
|
|
1926
|
+
onSchemeChange,
|
|
1927
|
+
surfaces = import_color2.DEFAULT_SCHEME_SURFACES,
|
|
1928
|
+
contrastAgainst,
|
|
1929
|
+
alpha = false,
|
|
1930
|
+
swatches,
|
|
1931
|
+
disabled = false,
|
|
1932
|
+
className = ""
|
|
1933
|
+
}) {
|
|
1934
|
+
const sameId = (0, import_react16.useId)();
|
|
1935
|
+
const [internalScheme, setInternalScheme] = (0, import_react16.useState)("light");
|
|
1936
|
+
const activeScheme = controlledScheme ?? internalScheme;
|
|
1937
|
+
const handleSchemeSelect = (nextScheme) => {
|
|
1938
|
+
if (onSchemeChange) {
|
|
1939
|
+
onSchemeChange(nextScheme);
|
|
1940
|
+
} else {
|
|
1941
|
+
setInternalScheme(nextScheme);
|
|
1942
|
+
}
|
|
1943
|
+
};
|
|
1944
|
+
const dual = (0, import_color2.normalizeDualColor)(value) ?? { light: "#000000", dark: "#000000" };
|
|
1945
|
+
const isSame = dual.light.toLowerCase() === dual.dark.toLowerCase();
|
|
1946
|
+
const [sameInBoth, setSameInBoth] = (0, import_react16.useState)(isSame);
|
|
1947
|
+
const handleSameToggle = (e) => {
|
|
1948
|
+
const nextSame = e.target.checked;
|
|
1949
|
+
setSameInBoth(nextSame);
|
|
1950
|
+
if (nextSame) {
|
|
1951
|
+
const activeVal = activeScheme === "dark" ? dual.dark : dual.light;
|
|
1952
|
+
onChange({ light: activeVal, dark: activeVal });
|
|
1953
|
+
}
|
|
1954
|
+
};
|
|
1955
|
+
const handleDerive = () => {
|
|
1956
|
+
if (disabled) return;
|
|
1957
|
+
onGestureStart?.();
|
|
1958
|
+
const currentActive = activeScheme === "dark" ? dual.dark : dual.light;
|
|
1959
|
+
const derived = (0, import_color2.deriveDualColor)(currentActive, {
|
|
1960
|
+
from: activeScheme,
|
|
1961
|
+
// An unreadable surfaces prop falls back to the defaults rather than throwing.
|
|
1962
|
+
surfaces: (0, import_color2.normalizeDualColor)(surfaces) ?? import_color2.DEFAULT_SCHEME_SURFACES
|
|
1963
|
+
});
|
|
1964
|
+
onChange(derived);
|
|
1965
|
+
onGestureEnd?.();
|
|
1966
|
+
};
|
|
1967
|
+
const handleInnerChange = (hex) => {
|
|
1968
|
+
if (sameInBoth) {
|
|
1969
|
+
onChange({ light: hex, dark: hex });
|
|
1970
|
+
} else {
|
|
1971
|
+
const updated = (0, import_color2.setDualColorSide)(dual, activeScheme, hex);
|
|
1972
|
+
onChange(updated);
|
|
1973
|
+
}
|
|
1974
|
+
};
|
|
1975
|
+
const activeColor = activeScheme === "dark" ? dual.dark : dual.light;
|
|
1976
|
+
const activeContrastTarget = contrastAgainst ? (0, import_color2.resolveColor)(contrastAgainst, activeScheme) ?? void 0 : void 0;
|
|
1977
|
+
const dualContrast = contrastAgainst && (0, import_color2.normalizeDualColor)(contrastAgainst) ? (0, import_color2.checkDualColorContrast)(dual, contrastAgainst) : null;
|
|
1978
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
|
|
1979
|
+
"div",
|
|
1980
|
+
{
|
|
1981
|
+
className: `pixerate-dual-color-picker ${className}`,
|
|
1982
|
+
style: {
|
|
1983
|
+
display: "flex",
|
|
1984
|
+
flexDirection: "column",
|
|
1985
|
+
gap: "12px",
|
|
1986
|
+
padding: "12px",
|
|
1987
|
+
background: "#1a1d24",
|
|
1988
|
+
color: "#e2e8f0",
|
|
1989
|
+
borderRadius: "10px",
|
|
1990
|
+
boxShadow: "0 4px 12px rgba(0,0,0,0.3)",
|
|
1991
|
+
width: "260px",
|
|
1992
|
+
fontFamily: "system-ui, -apple-system, sans-serif",
|
|
1993
|
+
fontSize: "13px",
|
|
1994
|
+
boxSizing: "border-box"
|
|
1995
|
+
},
|
|
1996
|
+
children: [
|
|
1997
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
|
|
1998
|
+
"div",
|
|
1999
|
+
{
|
|
2000
|
+
role: "tablist",
|
|
2001
|
+
"aria-label": "Color scheme mode",
|
|
2002
|
+
style: {
|
|
2003
|
+
display: "flex",
|
|
2004
|
+
background: "#111318",
|
|
2005
|
+
borderRadius: "6px",
|
|
2006
|
+
padding: "2px",
|
|
2007
|
+
gap: "2px"
|
|
2008
|
+
},
|
|
2009
|
+
children: [
|
|
2010
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
2011
|
+
"button",
|
|
2012
|
+
{
|
|
2013
|
+
type: "button",
|
|
2014
|
+
role: "tab",
|
|
2015
|
+
"aria-selected": activeScheme === "light",
|
|
2016
|
+
onClick: () => handleSchemeSelect("light"),
|
|
2017
|
+
disabled,
|
|
2018
|
+
style: {
|
|
2019
|
+
flex: 1,
|
|
2020
|
+
padding: "6px 8px",
|
|
2021
|
+
border: "none",
|
|
2022
|
+
borderRadius: "4px",
|
|
2023
|
+
background: activeScheme === "light" ? "#2d3342" : "transparent",
|
|
2024
|
+
color: activeScheme === "light" ? "#ffffff" : "#8c95a6",
|
|
2025
|
+
fontWeight: activeScheme === "light" ? 600 : 400,
|
|
2026
|
+
cursor: disabled ? "not-allowed" : "pointer",
|
|
2027
|
+
fontSize: "12px",
|
|
2028
|
+
transition: "all 0.15s ease"
|
|
2029
|
+
},
|
|
2030
|
+
children: "Light"
|
|
2031
|
+
}
|
|
2032
|
+
),
|
|
2033
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
2034
|
+
"button",
|
|
2035
|
+
{
|
|
2036
|
+
type: "button",
|
|
2037
|
+
role: "tab",
|
|
2038
|
+
"aria-selected": activeScheme === "dark",
|
|
2039
|
+
onClick: () => handleSchemeSelect("dark"),
|
|
2040
|
+
disabled,
|
|
2041
|
+
style: {
|
|
2042
|
+
flex: 1,
|
|
2043
|
+
padding: "6px 8px",
|
|
2044
|
+
border: "none",
|
|
2045
|
+
borderRadius: "4px",
|
|
2046
|
+
background: activeScheme === "dark" ? "#2d3342" : "transparent",
|
|
2047
|
+
color: activeScheme === "dark" ? "#ffffff" : "#8c95a6",
|
|
2048
|
+
fontWeight: activeScheme === "dark" ? 600 : 400,
|
|
2049
|
+
cursor: disabled ? "not-allowed" : "pointer",
|
|
2050
|
+
fontSize: "12px",
|
|
2051
|
+
transition: "all 0.15s ease"
|
|
2052
|
+
},
|
|
2053
|
+
children: "Dark"
|
|
2054
|
+
}
|
|
2055
|
+
)
|
|
2056
|
+
]
|
|
2057
|
+
}
|
|
2058
|
+
),
|
|
2059
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { style: { display: "flex", gap: "8px" }, children: [
|
|
2060
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
|
|
2061
|
+
"button",
|
|
2062
|
+
{
|
|
2063
|
+
type: "button",
|
|
2064
|
+
onClick: () => handleSchemeSelect("light"),
|
|
2065
|
+
disabled,
|
|
2066
|
+
title: "Edit light mode colour",
|
|
2067
|
+
style: {
|
|
2068
|
+
flex: 1,
|
|
2069
|
+
display: "flex",
|
|
2070
|
+
flexDirection: "column",
|
|
2071
|
+
alignItems: "center",
|
|
2072
|
+
gap: "6px",
|
|
2073
|
+
padding: "8px",
|
|
2074
|
+
background: surfaces.light,
|
|
2075
|
+
color: "#000000",
|
|
2076
|
+
border: activeScheme === "light" ? "2px solid #3b82f6" : "1px solid #333842",
|
|
2077
|
+
borderRadius: "6px",
|
|
2078
|
+
cursor: disabled ? "not-allowed" : "pointer",
|
|
2079
|
+
outline: "none"
|
|
2080
|
+
},
|
|
2081
|
+
children: [
|
|
2082
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
2083
|
+
"span",
|
|
2084
|
+
{
|
|
2085
|
+
style: {
|
|
2086
|
+
width: "100%",
|
|
2087
|
+
height: "24px",
|
|
2088
|
+
borderRadius: "4px",
|
|
2089
|
+
background: dual.light,
|
|
2090
|
+
border: "1px solid rgba(0,0,0,0.15)"
|
|
2091
|
+
}
|
|
2092
|
+
}
|
|
2093
|
+
),
|
|
2094
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { style: { fontSize: "11px", fontWeight: 600 }, children: "Light" })
|
|
2095
|
+
]
|
|
2096
|
+
}
|
|
2097
|
+
),
|
|
2098
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
|
|
2099
|
+
"button",
|
|
2100
|
+
{
|
|
2101
|
+
type: "button",
|
|
2102
|
+
onClick: () => handleSchemeSelect("dark"),
|
|
2103
|
+
disabled,
|
|
2104
|
+
title: "Edit dark mode colour",
|
|
2105
|
+
style: {
|
|
2106
|
+
flex: 1,
|
|
2107
|
+
display: "flex",
|
|
2108
|
+
flexDirection: "column",
|
|
2109
|
+
alignItems: "center",
|
|
2110
|
+
gap: "6px",
|
|
2111
|
+
padding: "8px",
|
|
2112
|
+
background: surfaces.dark,
|
|
2113
|
+
color: "#ffffff",
|
|
2114
|
+
border: activeScheme === "dark" ? "2px solid #3b82f6" : "1px solid #333842",
|
|
2115
|
+
borderRadius: "6px",
|
|
2116
|
+
cursor: disabled ? "not-allowed" : "pointer",
|
|
2117
|
+
outline: "none"
|
|
2118
|
+
},
|
|
2119
|
+
children: [
|
|
2120
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
2121
|
+
"span",
|
|
2122
|
+
{
|
|
2123
|
+
style: {
|
|
2124
|
+
width: "100%",
|
|
2125
|
+
height: "24px",
|
|
2126
|
+
borderRadius: "4px",
|
|
2127
|
+
background: dual.dark,
|
|
2128
|
+
border: "1px solid rgba(255,255,255,0.15)"
|
|
2129
|
+
}
|
|
2130
|
+
}
|
|
2131
|
+
),
|
|
2132
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { style: { fontSize: "11px", fontWeight: 600 }, children: "Dark" })
|
|
2133
|
+
]
|
|
2134
|
+
}
|
|
2135
|
+
)
|
|
2136
|
+
] }),
|
|
2137
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
|
|
2138
|
+
"div",
|
|
2139
|
+
{
|
|
2140
|
+
style: {
|
|
2141
|
+
display: "flex",
|
|
2142
|
+
alignItems: "center",
|
|
2143
|
+
justifyContent: "space-between",
|
|
2144
|
+
gap: "8px",
|
|
2145
|
+
padding: "2px 0"
|
|
2146
|
+
},
|
|
2147
|
+
children: [
|
|
2148
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
|
|
2149
|
+
"label",
|
|
2150
|
+
{
|
|
2151
|
+
htmlFor: sameId,
|
|
2152
|
+
style: {
|
|
2153
|
+
display: "flex",
|
|
2154
|
+
alignItems: "center",
|
|
2155
|
+
gap: "6px",
|
|
2156
|
+
cursor: disabled ? "not-allowed" : "pointer",
|
|
2157
|
+
userSelect: "none",
|
|
2158
|
+
fontSize: "12px",
|
|
2159
|
+
color: "#c4cad4"
|
|
2160
|
+
},
|
|
2161
|
+
children: [
|
|
2162
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
2163
|
+
"input",
|
|
2164
|
+
{
|
|
2165
|
+
id: sameId,
|
|
2166
|
+
type: "checkbox",
|
|
2167
|
+
checked: sameInBoth,
|
|
2168
|
+
onChange: handleSameToggle,
|
|
2169
|
+
disabled,
|
|
2170
|
+
style: { cursor: disabled ? "not-allowed" : "pointer" }
|
|
2171
|
+
}
|
|
2172
|
+
),
|
|
2173
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { children: "Same in both" })
|
|
2174
|
+
]
|
|
2175
|
+
}
|
|
2176
|
+
),
|
|
2177
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
2178
|
+
"button",
|
|
2179
|
+
{
|
|
2180
|
+
type: "button",
|
|
2181
|
+
onClick: handleDerive,
|
|
2182
|
+
disabled,
|
|
2183
|
+
style: {
|
|
2184
|
+
padding: "4px 10px",
|
|
2185
|
+
background: "#2d3342",
|
|
2186
|
+
color: "#e2e8f0",
|
|
2187
|
+
border: "1px solid #3b4252",
|
|
2188
|
+
borderRadius: "4px",
|
|
2189
|
+
fontSize: "11px",
|
|
2190
|
+
fontWeight: 500,
|
|
2191
|
+
cursor: disabled ? "not-allowed" : "pointer"
|
|
2192
|
+
},
|
|
2193
|
+
children: "Derive"
|
|
2194
|
+
}
|
|
2195
|
+
)
|
|
2196
|
+
]
|
|
2197
|
+
}
|
|
2198
|
+
),
|
|
2199
|
+
dualContrast && /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
|
|
2200
|
+
"div",
|
|
2201
|
+
{
|
|
2202
|
+
"data-testid": "dual-contrast-summary",
|
|
2203
|
+
style: {
|
|
2204
|
+
display: "flex",
|
|
2205
|
+
justifyContent: "space-between",
|
|
2206
|
+
background: "#111318",
|
|
2207
|
+
padding: "6px 8px",
|
|
2208
|
+
borderRadius: "6px",
|
|
2209
|
+
fontSize: "11px",
|
|
2210
|
+
color: "#8c95a6"
|
|
2211
|
+
},
|
|
2212
|
+
children: [
|
|
2213
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("span", { children: [
|
|
2214
|
+
"Light:",
|
|
2215
|
+
" ",
|
|
2216
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("strong", { style: { color: dualContrast.light.level === "fail" ? "#ef4444" : "#22c55e" }, children: [
|
|
2217
|
+
dualContrast.light.ratio.toFixed(2),
|
|
2218
|
+
" (",
|
|
2219
|
+
dualContrast.light.level,
|
|
2220
|
+
")"
|
|
2221
|
+
] })
|
|
2222
|
+
] }),
|
|
2223
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("span", { children: [
|
|
2224
|
+
"Dark:",
|
|
2225
|
+
" ",
|
|
2226
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("strong", { style: { color: dualContrast.dark.level === "fail" ? "#ef4444" : "#22c55e" }, children: [
|
|
2227
|
+
dualContrast.dark.ratio.toFixed(2),
|
|
2228
|
+
" (",
|
|
2229
|
+
dualContrast.dark.level,
|
|
2230
|
+
")"
|
|
2231
|
+
] })
|
|
2232
|
+
] })
|
|
2233
|
+
]
|
|
2234
|
+
}
|
|
2235
|
+
),
|
|
2236
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
2237
|
+
ColorPicker,
|
|
2238
|
+
{
|
|
2239
|
+
value: activeColor,
|
|
2240
|
+
onChange: handleInnerChange,
|
|
2241
|
+
onGestureStart,
|
|
2242
|
+
onGestureEnd,
|
|
2243
|
+
contrastAgainst: activeContrastTarget,
|
|
2244
|
+
alpha,
|
|
2245
|
+
swatches,
|
|
2246
|
+
disabled
|
|
2247
|
+
}
|
|
2248
|
+
)
|
|
2249
|
+
]
|
|
2250
|
+
}
|
|
2251
|
+
);
|
|
2252
|
+
}
|
|
2253
|
+
|
|
2254
|
+
// src/color/useColorScheme.ts
|
|
2255
|
+
var import_react17 = require("react");
|
|
2256
|
+
var import_color3 = require("@pixerate/editor/color");
|
|
2257
|
+
function getSnapshot(attribute) {
|
|
2258
|
+
if (typeof window === "undefined" || typeof document === "undefined") {
|
|
2259
|
+
return "light";
|
|
2260
|
+
}
|
|
2261
|
+
if (attribute) {
|
|
2262
|
+
const el = document.documentElement;
|
|
2263
|
+
if (attribute === "class") {
|
|
2264
|
+
return el.classList.contains("dark") ? "dark" : "light";
|
|
2265
|
+
}
|
|
2266
|
+
const val = el.getAttribute(attribute);
|
|
2267
|
+
return val === "dark" ? "dark" : "light";
|
|
2268
|
+
}
|
|
2269
|
+
if (typeof window.matchMedia === "function") {
|
|
2270
|
+
return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
2271
|
+
}
|
|
2272
|
+
return "light";
|
|
2273
|
+
}
|
|
2274
|
+
function getServerSnapshot() {
|
|
2275
|
+
return "light";
|
|
2276
|
+
}
|
|
2277
|
+
function useColorScheme(options) {
|
|
2278
|
+
const override = options?.override;
|
|
2279
|
+
const attribute = options?.attribute;
|
|
2280
|
+
const subscribe = (0, import_react17.useMemo)(() => {
|
|
2281
|
+
return (callback) => {
|
|
2282
|
+
if (typeof window === "undefined" || typeof document === "undefined") {
|
|
2283
|
+
return () => {
|
|
2284
|
+
};
|
|
2285
|
+
}
|
|
2286
|
+
if (attribute) {
|
|
2287
|
+
const observer = new MutationObserver(() => {
|
|
2288
|
+
callback();
|
|
2289
|
+
});
|
|
2290
|
+
observer.observe(document.documentElement, {
|
|
2291
|
+
attributes: true,
|
|
2292
|
+
attributeFilter: [attribute]
|
|
2293
|
+
});
|
|
2294
|
+
return () => observer.disconnect();
|
|
2295
|
+
}
|
|
2296
|
+
if (typeof window.matchMedia === "function") {
|
|
2297
|
+
const mql = window.matchMedia("(prefers-color-scheme: dark)");
|
|
2298
|
+
const handler = () => callback();
|
|
2299
|
+
mql.addEventListener("change", handler);
|
|
2300
|
+
return () => mql.removeEventListener("change", handler);
|
|
2301
|
+
}
|
|
2302
|
+
return () => {
|
|
2303
|
+
};
|
|
2304
|
+
};
|
|
2305
|
+
}, [attribute]);
|
|
2306
|
+
const detected = (0, import_react17.useSyncExternalStore)(
|
|
2307
|
+
subscribe,
|
|
2308
|
+
() => getSnapshot(attribute),
|
|
2309
|
+
getServerSnapshot
|
|
2310
|
+
);
|
|
2311
|
+
return override ?? detected;
|
|
2312
|
+
}
|
|
2313
|
+
function useResolvedColor(value, scheme) {
|
|
2314
|
+
const detectedScheme = useColorScheme();
|
|
2315
|
+
const activeScheme = scheme ?? detectedScheme;
|
|
2316
|
+
return (0, import_color3.resolveColor)(value, activeScheme);
|
|
2317
|
+
}
|
|
2318
|
+
|
|
2319
|
+
// src/color/index.ts
|
|
2320
|
+
__reExport(color_exports, require("@pixerate/editor/color"));
|
|
2321
|
+
|
|
2322
|
+
// src/parameters/fields.tsx
|
|
2323
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
1282
2324
|
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";
|
|
1283
2325
|
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";
|
|
1284
2326
|
var rangeClass = "h-4 w-full min-w-0 flex-1 cursor-pointer accent-primary disabled:cursor-not-allowed disabled:opacity-50";
|
|
@@ -1302,7 +2344,7 @@ function ParameterCommitInput({ value, onCommit, multiline, className, onKeyDown
|
|
|
1302
2344
|
onKeyDown: keyDown,
|
|
1303
2345
|
...rest
|
|
1304
2346
|
};
|
|
1305
|
-
return multiline ? /* @__PURE__ */ (0,
|
|
2347
|
+
return multiline ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("textarea", { ...props, className: `${props.className} h-auto min-h-[3.5rem] py-1` }, value) : /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("input", { type: "text", ...props }, value);
|
|
1306
2348
|
}
|
|
1307
2349
|
var plainNumber = (field, value) => (0, import_parameters.formatParameterNumber)({ ...field, unit: void 0 }, value);
|
|
1308
2350
|
function ParameterNumberInput({
|
|
@@ -1313,8 +2355,8 @@ function ParameterNumberInput({
|
|
|
1313
2355
|
id,
|
|
1314
2356
|
"aria-label": ariaLabel
|
|
1315
2357
|
}) {
|
|
1316
|
-
return /* @__PURE__ */ (0,
|
|
1317
|
-
/* @__PURE__ */ (0,
|
|
2358
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "relative min-w-0 flex-1", children: [
|
|
2359
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1318
2360
|
ParameterCommitInput,
|
|
1319
2361
|
{
|
|
1320
2362
|
id,
|
|
@@ -1336,21 +2378,21 @@ function ParameterNumberInput({
|
|
|
1336
2378
|
}
|
|
1337
2379
|
}
|
|
1338
2380
|
),
|
|
1339
|
-
field.unit && /* @__PURE__ */ (0,
|
|
2381
|
+
field.unit && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "pointer-events-none absolute right-2 top-1/2 -translate-y-1/2 text-[10px] text-muted-foreground", children: field.unit })
|
|
1340
2382
|
] });
|
|
1341
2383
|
}
|
|
1342
2384
|
function ParameterSlider(props) {
|
|
1343
2385
|
const { field, value, onChange, onGestureStart, onGestureEnd, disabled } = props;
|
|
1344
|
-
const dragging = (0,
|
|
2386
|
+
const dragging = (0, import_react18.useRef)(false);
|
|
1345
2387
|
const end = () => {
|
|
1346
2388
|
if (!dragging.current) return;
|
|
1347
2389
|
dragging.current = false;
|
|
1348
2390
|
onGestureEnd?.();
|
|
1349
2391
|
};
|
|
1350
|
-
if (!(0, import_parameters.isSliderField)(field)) return /* @__PURE__ */ (0,
|
|
2392
|
+
if (!(0, import_parameters.isSliderField)(field)) return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ParameterNumberInput, { ...props });
|
|
1351
2393
|
const step = (0, import_parameters.parameterStep)(field);
|
|
1352
|
-
return /* @__PURE__ */ (0,
|
|
1353
|
-
/* @__PURE__ */ (0,
|
|
2394
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
2395
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1354
2396
|
"input",
|
|
1355
2397
|
{
|
|
1356
2398
|
type: "range",
|
|
@@ -1373,11 +2415,11 @@ function ParameterSlider(props) {
|
|
|
1373
2415
|
onChange: (e) => onChange((0, import_parameters.clampParameterNumber)(field, Number(e.target.value)))
|
|
1374
2416
|
}
|
|
1375
2417
|
),
|
|
1376
|
-
/* @__PURE__ */ (0,
|
|
2418
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "w-20 shrink-0", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ParameterNumberInput, { ...props, id: props.id, "aria-label": `${(0, import_parameters.parameterLabel)(field)} value` }) })
|
|
1377
2419
|
] });
|
|
1378
2420
|
}
|
|
1379
2421
|
function ParameterToggle({ field, value, onChange, disabled, id }) {
|
|
1380
|
-
return /* @__PURE__ */ (0,
|
|
2422
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1381
2423
|
"button",
|
|
1382
2424
|
{
|
|
1383
2425
|
type: "button",
|
|
@@ -1388,7 +2430,7 @@ function ParameterToggle({ field, value, onChange, disabled, id }) {
|
|
|
1388
2430
|
disabled: disabled || field.readOnly,
|
|
1389
2431
|
onClick: () => onChange(!value),
|
|
1390
2432
|
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"}`,
|
|
1391
|
-
children: /* @__PURE__ */ (0,
|
|
2433
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1392
2434
|
"span",
|
|
1393
2435
|
{
|
|
1394
2436
|
className: `pointer-events-none block h-4 w-4 rounded-full bg-background shadow transition-transform ${value ? "translate-x-4" : "translate-x-0.5"}`
|
|
@@ -1401,7 +2443,7 @@ function ParameterSelect({ field, value, onChange, disabled, id }) {
|
|
|
1401
2443
|
const options = (0, import_parameters.getChoiceOptions)(field);
|
|
1402
2444
|
const off = disabled || field.readOnly;
|
|
1403
2445
|
if (field.control === "segmented") {
|
|
1404
|
-
return /* @__PURE__ */ (0,
|
|
2446
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { role: "radiogroup", "aria-label": (0, import_parameters.parameterLabel)(field), className: "inline-flex flex-wrap rounded-md border border-input bg-muted p-0.5", children: options.map((o) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1405
2447
|
"button",
|
|
1406
2448
|
{
|
|
1407
2449
|
type: "button",
|
|
@@ -1417,7 +2459,7 @@ function ParameterSelect({ field, value, onChange, disabled, id }) {
|
|
|
1417
2459
|
)) });
|
|
1418
2460
|
}
|
|
1419
2461
|
const index = options.findIndex((o) => o.value === value);
|
|
1420
|
-
return /* @__PURE__ */ (0,
|
|
2462
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1421
2463
|
"select",
|
|
1422
2464
|
{
|
|
1423
2465
|
id,
|
|
@@ -1429,53 +2471,64 @@ function ParameterSelect({ field, value, onChange, disabled, id }) {
|
|
|
1429
2471
|
if (option) onChange(option.value);
|
|
1430
2472
|
},
|
|
1431
2473
|
className: parameterInputClass,
|
|
1432
|
-
children: options.map((o, i) => /* @__PURE__ */ (0,
|
|
2474
|
+
children: options.map((o, i) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("option", { value: String(i), title: o.description, children: (0, import_parameters.choiceOptionLabel)(o) }, String(o.value)))
|
|
1433
2475
|
}
|
|
1434
2476
|
);
|
|
1435
2477
|
}
|
|
1436
2478
|
function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd, disabled, id }) {
|
|
1437
|
-
const
|
|
2479
|
+
const [open, setOpen] = (0, import_react18.useState)(false);
|
|
2480
|
+
const containerRef = (0, import_react18.useRef)(null);
|
|
2481
|
+
const buttonRef = (0, import_react18.useRef)(null);
|
|
2482
|
+
const popoverRef = (0, import_react18.useRef)(null);
|
|
1438
2483
|
const alpha = !!field.alpha;
|
|
1439
2484
|
const hex = (0, import_parameters.normalizeHexColor)(value, true) ?? "#000000ff";
|
|
1440
2485
|
const rgb = hex.slice(0, 7);
|
|
1441
|
-
const
|
|
2486
|
+
const shown = alpha ? hex : rgb;
|
|
1442
2487
|
const off = disabled || field.readOnly;
|
|
1443
|
-
const
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
2488
|
+
const name = (0, import_parameters.parameterLabel)(field);
|
|
2489
|
+
(0, import_react18.useEffect)(() => {
|
|
2490
|
+
if (!open) return;
|
|
2491
|
+
const onPointerDown = (e) => {
|
|
2492
|
+
if (containerRef.current && !containerRef.current.contains(e.target)) {
|
|
2493
|
+
setOpen(false);
|
|
2494
|
+
}
|
|
2495
|
+
};
|
|
2496
|
+
const onKeyDown = (e) => {
|
|
2497
|
+
if (e.key === "Escape") {
|
|
2498
|
+
e.stopPropagation();
|
|
2499
|
+
setOpen(false);
|
|
2500
|
+
buttonRef.current?.focus();
|
|
2501
|
+
}
|
|
2502
|
+
};
|
|
2503
|
+
window.addEventListener("pointerdown", onPointerDown, true);
|
|
2504
|
+
window.addEventListener("keydown", onKeyDown, true);
|
|
2505
|
+
return () => {
|
|
2506
|
+
window.removeEventListener("pointerdown", onPointerDown, true);
|
|
2507
|
+
window.removeEventListener("keydown", onKeyDown, true);
|
|
2508
|
+
};
|
|
2509
|
+
}, [open]);
|
|
2510
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { ref: containerRef, className: "relative space-y-1.5", children: [
|
|
2511
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
2512
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
2513
|
+
"button",
|
|
2514
|
+
{
|
|
2515
|
+
ref: buttonRef,
|
|
2516
|
+
type: "button",
|
|
2517
|
+
"aria-label": name,
|
|
2518
|
+
"aria-expanded": open,
|
|
2519
|
+
"aria-haspopup": "dialog",
|
|
2520
|
+
disabled: off,
|
|
2521
|
+
onClick: () => setOpen((prev) => !prev),
|
|
2522
|
+
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",
|
|
2523
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "absolute inset-0", style: { background: shown } })
|
|
2524
|
+
}
|
|
2525
|
+
),
|
|
2526
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1474
2527
|
ParameterCommitInput,
|
|
1475
2528
|
{
|
|
1476
2529
|
id,
|
|
1477
|
-
"aria-label": `${
|
|
1478
|
-
value:
|
|
2530
|
+
"aria-label": `${name} hex`,
|
|
2531
|
+
value: shown,
|
|
1479
2532
|
disabled: off,
|
|
1480
2533
|
spellCheck: false,
|
|
1481
2534
|
className: `${parameterInputClass} font-mono`,
|
|
@@ -1486,51 +2539,43 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
1486
2539
|
}
|
|
1487
2540
|
)
|
|
1488
2541
|
] }),
|
|
1489
|
-
|
|
1490
|
-
"
|
|
2542
|
+
open && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
2543
|
+
"div",
|
|
1491
2544
|
{
|
|
1492
|
-
|
|
1493
|
-
"
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
onPointerDown: start,
|
|
1501
|
-
onPointerUp: end,
|
|
1502
|
-
onPointerCancel: end,
|
|
1503
|
-
onBlur: end,
|
|
1504
|
-
onChange: (e) => onChange(`${rgb}${Number(e.target.value).toString(16).padStart(2, "0")}`)
|
|
1505
|
-
}
|
|
1506
|
-
),
|
|
1507
|
-
field.swatches && field.swatches.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: "flex flex-wrap gap-1", children: field.swatches.map((s) => {
|
|
1508
|
-
const swatch = (0, import_parameters.normalizeHexColor)(s, alpha);
|
|
1509
|
-
if (!swatch) return null;
|
|
1510
|
-
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1511
|
-
"button",
|
|
1512
|
-
{
|
|
1513
|
-
type: "button",
|
|
1514
|
-
title: swatch,
|
|
1515
|
-
"aria-label": `${(0, import_parameters.parameterLabel)(field)} ${swatch}`,
|
|
1516
|
-
"aria-pressed": swatch === (alpha ? hex : rgb),
|
|
1517
|
-
disabled: off,
|
|
1518
|
-
onClick: () => onChange(swatch),
|
|
1519
|
-
className: "h-5 w-5 rounded border border-input aria-pressed:ring-1 aria-pressed:ring-primary",
|
|
1520
|
-
style: { background: swatch }
|
|
2545
|
+
ref: popoverRef,
|
|
2546
|
+
role: "dialog",
|
|
2547
|
+
"aria-label": name,
|
|
2548
|
+
tabIndex: -1,
|
|
2549
|
+
onBlur: (e) => {
|
|
2550
|
+
if (popoverRef.current && !popoverRef.current.contains(e.relatedTarget)) {
|
|
2551
|
+
setOpen(false);
|
|
2552
|
+
}
|
|
1521
2553
|
},
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
2554
|
+
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",
|
|
2555
|
+
style: { background: "var(--popover, var(--background, #fff))" },
|
|
2556
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
2557
|
+
ColorPicker,
|
|
2558
|
+
{
|
|
2559
|
+
value: shown,
|
|
2560
|
+
alpha,
|
|
2561
|
+
swatches: field.swatches,
|
|
2562
|
+
disabled: off,
|
|
2563
|
+
onChange,
|
|
2564
|
+
onGestureStart,
|
|
2565
|
+
onGestureEnd
|
|
2566
|
+
}
|
|
2567
|
+
)
|
|
2568
|
+
}
|
|
2569
|
+
)
|
|
1525
2570
|
] });
|
|
1526
2571
|
}
|
|
1527
2572
|
function ParameterVector({ field, value, onChange, disabled, id }) {
|
|
1528
2573
|
const size = (0, import_parameters.vectorSize)(field);
|
|
1529
|
-
return /* @__PURE__ */ (0,
|
|
2574
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "grid gap-1.5", style: { gridTemplateColumns: `repeat(${size}, minmax(0, 1fr))` }, children: Array.from({ length: size }, (_, i) => {
|
|
1530
2575
|
const component = (0, import_parameters.vectorComponentField)(field, i);
|
|
1531
|
-
return /* @__PURE__ */ (0,
|
|
1532
|
-
/* @__PURE__ */ (0,
|
|
1533
|
-
/* @__PURE__ */ (0,
|
|
2576
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("label", { className: "flex min-w-0 items-center gap-1", children: [
|
|
2577
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "w-3 shrink-0 text-[10px] uppercase text-muted-foreground", children: component.label }),
|
|
2578
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1534
2579
|
ParameterNumberInput,
|
|
1535
2580
|
{
|
|
1536
2581
|
field: component,
|
|
@@ -1547,11 +2592,11 @@ function ParameterVector({ field, value, onChange, disabled, id }) {
|
|
|
1547
2592
|
function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
|
|
1548
2593
|
const off = disabled || field.readOnly;
|
|
1549
2594
|
const name = (0, import_parameters.parameterLabel)(field);
|
|
1550
|
-
return /* @__PURE__ */ (0,
|
|
1551
|
-
/* @__PURE__ */ (0,
|
|
1552
|
-
/* @__PURE__ */ (0,
|
|
1553
|
-
/* @__PURE__ */ (0,
|
|
1554
|
-
/* @__PURE__ */ (0,
|
|
2595
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "space-y-1.5", children: [
|
|
2596
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
2597
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "flex h-12 w-16 shrink-0 items-center justify-center overflow-hidden rounded-md border border-input bg-muted", children: value ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("img", { src: value, alt: name, className: "h-full w-full object-cover" }) : /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "text-[10px] text-muted-foreground", children: "None" }) }),
|
|
2598
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "flex min-w-0 flex-1 flex-col gap-1", children: [
|
|
2599
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1555
2600
|
ParameterCommitInput,
|
|
1556
2601
|
{
|
|
1557
2602
|
id,
|
|
@@ -1562,10 +2607,10 @@ function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
|
|
|
1562
2607
|
onCommit: (text) => onChange(text.trim())
|
|
1563
2608
|
}
|
|
1564
2609
|
),
|
|
1565
|
-
/* @__PURE__ */ (0,
|
|
1566
|
-
resolveFile && /* @__PURE__ */ (0,
|
|
2610
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "flex gap-1", children: [
|
|
2611
|
+
resolveFile && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("label", { className: `${parameterButtonClass} cursor-pointer ${off ? "pointer-events-none opacity-50" : ""}`, children: [
|
|
1567
2612
|
"Choose file\u2026",
|
|
1568
|
-
/* @__PURE__ */ (0,
|
|
2613
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1569
2614
|
"input",
|
|
1570
2615
|
{
|
|
1571
2616
|
type: "file",
|
|
@@ -1581,11 +2626,11 @@ function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
|
|
|
1581
2626
|
}
|
|
1582
2627
|
)
|
|
1583
2628
|
] }),
|
|
1584
|
-
value && /* @__PURE__ */ (0,
|
|
2629
|
+
value && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("button", { type: "button", className: parameterButtonClass, disabled: off, onClick: () => onChange(""), "aria-label": `Clear ${name}`, children: "Clear" })
|
|
1585
2630
|
] })
|
|
1586
2631
|
] })
|
|
1587
2632
|
] }),
|
|
1588
|
-
field.options && field.options.length > 0 && /* @__PURE__ */ (0,
|
|
2633
|
+
field.options && field.options.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "flex flex-wrap gap-1", children: field.options.map((o) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1589
2634
|
"button",
|
|
1590
2635
|
{
|
|
1591
2636
|
type: "button",
|
|
@@ -1595,14 +2640,14 @@ function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
|
|
|
1595
2640
|
disabled: off,
|
|
1596
2641
|
onClick: () => onChange(o.url),
|
|
1597
2642
|
className: "h-9 w-12 overflow-hidden rounded border border-input aria-pressed:ring-2 aria-pressed:ring-primary",
|
|
1598
|
-
children: /* @__PURE__ */ (0,
|
|
2643
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("img", { src: o.url, alt: "", className: "h-full w-full object-cover" })
|
|
1599
2644
|
},
|
|
1600
2645
|
o.url
|
|
1601
2646
|
)) })
|
|
1602
2647
|
] });
|
|
1603
2648
|
}
|
|
1604
2649
|
function ParameterText({ field, value, onChange, disabled, id }) {
|
|
1605
|
-
return /* @__PURE__ */ (0,
|
|
2650
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1606
2651
|
ParameterCommitInput,
|
|
1607
2652
|
{
|
|
1608
2653
|
id,
|
|
@@ -1621,31 +2666,31 @@ function ParameterFieldControl({ field, value, onChange, resolveFile, ...rest })
|
|
|
1621
2666
|
switch (field.type) {
|
|
1622
2667
|
case "number":
|
|
1623
2668
|
case "int":
|
|
1624
|
-
return /* @__PURE__ */ (0,
|
|
2669
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ParameterSlider, { field, value, onChange: set, ...rest });
|
|
1625
2670
|
case "boolean":
|
|
1626
|
-
return /* @__PURE__ */ (0,
|
|
2671
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ParameterToggle, { field, value, onChange: set, ...rest });
|
|
1627
2672
|
case "choice":
|
|
1628
|
-
return /* @__PURE__ */ (0,
|
|
2673
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ParameterSelect, { field, value, onChange: set, ...rest });
|
|
1629
2674
|
case "color":
|
|
1630
|
-
return /* @__PURE__ */ (0,
|
|
2675
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ParameterColor, { field, value, onChange: set, ...rest });
|
|
1631
2676
|
case "vector":
|
|
1632
|
-
return /* @__PURE__ */ (0,
|
|
2677
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ParameterVector, { field, value, onChange: set, ...rest });
|
|
1633
2678
|
case "image":
|
|
1634
|
-
return /* @__PURE__ */ (0,
|
|
2679
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ParameterImage, { field, value, onChange: set, resolveFile, ...rest });
|
|
1635
2680
|
case "text":
|
|
1636
|
-
return /* @__PURE__ */ (0,
|
|
2681
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ParameterText, { field, value, onChange: set, ...rest });
|
|
1637
2682
|
}
|
|
1638
2683
|
}
|
|
1639
2684
|
|
|
1640
2685
|
// src/effects/EffectParameters.tsx
|
|
1641
|
-
var
|
|
2686
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
1642
2687
|
function EffectParameters({ description, values, onChange, onReset, keyframed, onPreset, disabled = false, className = "" }) {
|
|
1643
|
-
const fields = (0,
|
|
1644
|
-
const idBase = (0,
|
|
1645
|
-
const gesture =
|
|
1646
|
-
const count =
|
|
1647
|
-
return /* @__PURE__ */ (0,
|
|
1648
|
-
onPreset && description.presets.length > 0 && /* @__PURE__ */ (0,
|
|
2688
|
+
const fields = (0, import_react19.useMemo)(() => (0, import_effects3.effectParameterFields)(description), [description]);
|
|
2689
|
+
const idBase = (0, import_react19.useId)();
|
|
2690
|
+
const gesture = import_react19.default.useRef(null);
|
|
2691
|
+
const count = import_react19.default.useRef(0);
|
|
2692
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: `space-y-2 ${className}`, "data-effect-parameters": description.id, children: [
|
|
2693
|
+
onPreset && description.presets.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
|
|
1649
2694
|
"select",
|
|
1650
2695
|
{
|
|
1651
2696
|
className: "w-full rounded border border-border bg-transparent px-1 py-0.5 text-xs",
|
|
@@ -1657,8 +2702,8 @@ function EffectParameters({ description, values, onChange, onReset, keyframed, o
|
|
|
1657
2702
|
if (preset) onPreset({ ...description.defaults, ...preset.values });
|
|
1658
2703
|
},
|
|
1659
2704
|
children: [
|
|
1660
|
-
/* @__PURE__ */ (0,
|
|
1661
|
-
description.presets.map((p) => /* @__PURE__ */ (0,
|
|
2705
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("option", { value: "", children: "Presets\u2026" }),
|
|
2706
|
+
description.presets.map((p) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("option", { value: p.name, children: p.name }, p.name))
|
|
1662
2707
|
]
|
|
1663
2708
|
}
|
|
1664
2709
|
),
|
|
@@ -1668,13 +2713,13 @@ function EffectParameters({ description, values, onChange, onReset, keyframed, o
|
|
|
1668
2713
|
const keyed = keyframed?.has(field.id) ?? false;
|
|
1669
2714
|
const value = (0, import_effects3.effectFieldValue)(field, values[field.id]);
|
|
1670
2715
|
const changed = !keyed && !(0, import_parameters2.parameterValuesEqual)(value, field.default);
|
|
1671
|
-
return /* @__PURE__ */ (0,
|
|
1672
|
-
/* @__PURE__ */ (0,
|
|
1673
|
-
/* @__PURE__ */ (0,
|
|
1674
|
-
keyed && /* @__PURE__ */ (0,
|
|
1675
|
-
onReset && changed && !disabled && /* @__PURE__ */ (0,
|
|
2716
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "space-y-1", "data-effect-control": field.id, children: [
|
|
2717
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex items-center gap-1.5", children: [
|
|
2718
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("label", { htmlFor: inputId, className: "min-w-0 flex-1 truncate text-xs font-medium", title: field.description, children: label }),
|
|
2719
|
+
keyed && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: "text-[10px] text-muted-foreground", children: "keyframed" }),
|
|
2720
|
+
onReset && changed && !disabled && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("button", { type: "button", className: "rounded px-1 text-[11px] text-muted-foreground hover:text-foreground", "aria-label": `Reset ${label}`, onClick: () => onReset(field.id), children: "\u21BA" })
|
|
1676
2721
|
] }),
|
|
1677
|
-
/* @__PURE__ */ (0,
|
|
2722
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
1678
2723
|
ParameterFieldControl,
|
|
1679
2724
|
{
|
|
1680
2725
|
field,
|
|
@@ -1688,25 +2733,25 @@ function EffectParameters({ description, values, onChange, onReset, keyframed, o
|
|
|
1688
2733
|
)
|
|
1689
2734
|
] }, field.id);
|
|
1690
2735
|
}),
|
|
1691
|
-
!fields.length && /* @__PURE__ */ (0,
|
|
2736
|
+
!fields.length && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No controls." })
|
|
1692
2737
|
] });
|
|
1693
2738
|
}
|
|
1694
2739
|
|
|
1695
2740
|
// src/animation-editor/AnimationEffectsPanel.tsx
|
|
1696
|
-
var
|
|
2741
|
+
var import_react20 = require("react");
|
|
1697
2742
|
var import_animation_editor10 = require("@pixerate/editor/animation-editor");
|
|
1698
|
-
var
|
|
2743
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
1699
2744
|
var btn5 = "rounded border border-border px-1.5 py-0.5 text-[11px] disabled:opacity-40";
|
|
1700
2745
|
function Controls({ controller, instance, effect, values }) {
|
|
1701
2746
|
const provider = controller.effectsProvider;
|
|
1702
2747
|
const { description, error } = useEffectDescription(provider, effect);
|
|
1703
|
-
const [message, setMessage] = (0,
|
|
2748
|
+
const [message, setMessage] = (0, import_react20.useState)(null);
|
|
1704
2749
|
const report = (r) => void r.then((x) => setMessage(x.ok ? null : x.error));
|
|
1705
|
-
if (!provider) return /* @__PURE__ */ (0,
|
|
1706
|
-
if (error) return /* @__PURE__ */ (0,
|
|
1707
|
-
if (!description) return /* @__PURE__ */ (0,
|
|
1708
|
-
return /* @__PURE__ */ (0,
|
|
1709
|
-
/* @__PURE__ */ (0,
|
|
2750
|
+
if (!provider) return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No effects provider: its commands are kept as they are." });
|
|
2751
|
+
if (error) return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("p", { className: "text-[11px] text-amber-500", children: error });
|
|
2752
|
+
if (!description) return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "Loading\u2026" });
|
|
2753
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_jsx_runtime19.Fragment, { children: [
|
|
2754
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
1710
2755
|
EffectParameters,
|
|
1711
2756
|
{
|
|
1712
2757
|
description,
|
|
@@ -1716,60 +2761,60 @@ function Controls({ controller, instance, effect, values }) {
|
|
|
1716
2761
|
onPreset: (v) => report(controller.updateMotionEffect(instance, v))
|
|
1717
2762
|
}
|
|
1718
2763
|
),
|
|
1719
|
-
message && /* @__PURE__ */ (0,
|
|
2764
|
+
message && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("p", { role: "alert", className: "text-[11px] text-destructive", children: message })
|
|
1720
2765
|
] });
|
|
1721
2766
|
}
|
|
1722
2767
|
function AnimationEffectsPanel({ controller, node, className = "" }) {
|
|
1723
2768
|
const state = useAnimationEditorState(controller);
|
|
1724
2769
|
const provider = state.effectsProvider;
|
|
1725
|
-
const nodes = (0,
|
|
1726
|
-
const [chosen, setChosen] = (0,
|
|
2770
|
+
const nodes = (0, import_react20.useMemo)(() => [...(0, import_animation_editor10.indexMotionNodes)(state.scene.artwork.nodes).keys()], [state.scene.artwork]);
|
|
2771
|
+
const [chosen, setChosen] = (0, import_react20.useState)("");
|
|
1727
2772
|
const target = node && nodes.includes(node) ? node : chosen && nodes.includes(chosen) ? chosen : "";
|
|
1728
|
-
const [browse, setBrowse] = (0,
|
|
1729
|
-
const [open, setOpen] = (0,
|
|
1730
|
-
const [message, setMessage] = (0,
|
|
2773
|
+
const [browse, setBrowse] = (0, import_react20.useState)(null);
|
|
2774
|
+
const [open, setOpen] = (0, import_react20.useState)(null);
|
|
2775
|
+
const [message, setMessage] = (0, import_react20.useState)(null);
|
|
1731
2776
|
const report = (r) => void Promise.resolve(r).then((x) => setMessage(x.ok ? x.notes.length ? x.notes.join(" ") : null : x.error));
|
|
1732
|
-
const applied = (0,
|
|
2777
|
+
const applied = (0, import_react20.useMemo)(() => controller.appliedEffects(), [controller, state.scene]);
|
|
1733
2778
|
const disabled = state.readOnly;
|
|
1734
|
-
return /* @__PURE__ */ (0,
|
|
1735
|
-
/* @__PURE__ */ (0,
|
|
1736
|
-
/* @__PURE__ */ (0,
|
|
1737
|
-
/* @__PURE__ */ (0,
|
|
1738
|
-
/* @__PURE__ */ (0,
|
|
1739
|
-
nodes.map((id) => /* @__PURE__ */ (0,
|
|
2779
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("section", { className: `flex flex-col gap-2 text-xs ${className}`, "aria-label": "Effects", "data-animation-effects": "", children: [
|
|
2780
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "flex flex-wrap items-center gap-1", children: [
|
|
2781
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "flex-1 font-semibold", children: "Effects" }),
|
|
2782
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("select", { className: "rounded border border-border bg-transparent px-1 py-0.5 text-[11px]", "aria-label": "Node to animate", value: target, disabled: !!node, onChange: (e) => setChosen(e.currentTarget.value), children: [
|
|
2783
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("option", { value: "", children: "Node\u2026" }),
|
|
2784
|
+
nodes.map((id) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("option", { value: id, children: id }, id))
|
|
1740
2785
|
] }),
|
|
1741
|
-
/* @__PURE__ */ (0,
|
|
1742
|
-
/* @__PURE__ */ (0,
|
|
2786
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("button", { type: "button", className: btn5, disabled: disabled || !provider || !target, "aria-pressed": browse === "motion", onClick: () => setBrowse(browse === "motion" ? null : "motion"), children: "Animate\u2026" }),
|
|
2787
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("button", { type: "button", className: btn5, disabled: disabled || !provider, "aria-pressed": browse === "vector", onClick: () => setBrowse(browse === "vector" ? null : "vector"), children: "Vector effect\u2026" })
|
|
1743
2788
|
] }),
|
|
1744
|
-
!provider && /* @__PURE__ */ (0,
|
|
1745
|
-
browse === "motion" && /* @__PURE__ */ (0,
|
|
1746
|
-
browse === "vector" && /* @__PURE__ */ (0,
|
|
1747
|
-
/* @__PURE__ */ (0,
|
|
1748
|
-
/* @__PURE__ */ (0,
|
|
1749
|
-
/* @__PURE__ */ (0,
|
|
2789
|
+
!provider && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No effects provider is registered. Commands effects made are kept." }),
|
|
2790
|
+
browse === "motion" && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(EffectsBrowser, { provider, uses: ["motion"], kinds: ["motion"], title: `Motion for ${target}`, onPick: (e) => (setBrowse(null), report(controller.applyMotionEffect(e.id, [target]))) }),
|
|
2791
|
+
browse === "vector" && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(EffectsBrowser, { provider, kinds: ["vector"], title: "Vector effects", onPick: (e) => (setBrowse(null), report(controller.addVectorEffect(e.id))) }),
|
|
2792
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("ol", { className: "space-y-1", children: applied.map((e) => /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("li", { className: "rounded border border-border p-1", "data-motion-effect": e.instance, children: [
|
|
2793
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
2794
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("button", { type: "button", className: "min-w-0 flex-1 truncate text-left", "aria-expanded": open === e.instance, onClick: () => setOpen(open === e.instance ? null : e.instance), children: [
|
|
1750
2795
|
e.name ?? e.effect,
|
|
1751
2796
|
" ",
|
|
1752
|
-
/* @__PURE__ */ (0,
|
|
2797
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("span", { className: "text-muted-foreground", children: [
|
|
1753
2798
|
"\xB7 ",
|
|
1754
2799
|
e.kind === "vector" ? "picture" : e.targets.join(", ")
|
|
1755
2800
|
] })
|
|
1756
2801
|
] }),
|
|
1757
|
-
/* @__PURE__ */ (0,
|
|
2802
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("button", { type: "button", className: btn5, disabled, "aria-label": `Remove ${e.name ?? e.effect}`, onClick: () => report(controller.removeMotionEffect(e.instance)), children: "\u2715" })
|
|
1758
2803
|
] }),
|
|
1759
|
-
open === e.instance && /* @__PURE__ */ (0,
|
|
2804
|
+
open === e.instance && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "mt-1", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Controls, { controller, instance: e.instance, effect: e.effect, values: e.values }) })
|
|
1760
2805
|
] }, e.instance)) }),
|
|
1761
|
-
!applied.length && /* @__PURE__ */ (0,
|
|
1762
|
-
message && /* @__PURE__ */ (0,
|
|
2806
|
+
!applied.length && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No provider effects in this scene." }),
|
|
2807
|
+
message && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("p", { role: "status", className: "text-[11px] text-muted-foreground", "data-effects-message": "", children: message })
|
|
1763
2808
|
] });
|
|
1764
2809
|
}
|
|
1765
2810
|
|
|
1766
2811
|
// src/animation-editor/AnimationEditor.tsx
|
|
1767
|
-
var
|
|
2812
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
1768
2813
|
var ONION = { before: 3, after: 1 };
|
|
1769
2814
|
var btn6 = "rounded border border-border px-2 py-0.5 text-xs disabled:opacity-40";
|
|
1770
2815
|
function AnimationEditor({ controller, values, onionSkin, motionPaths, showIssues = true, editable = true, effects, className = "", playback, playbackId = "animation", onPlaybackReveal }) {
|
|
1771
2816
|
const state = useAnimationEditorState(controller);
|
|
1772
|
-
const rootRef = (0,
|
|
2817
|
+
const rootRef = (0, import_react21.useRef)(null);
|
|
1773
2818
|
const ambientPlayback = useAgentPlayback();
|
|
1774
2819
|
const playing = (playback === void 0 ? ambientPlayback : playback) ?? null;
|
|
1775
2820
|
const rectIn = (el) => {
|
|
@@ -1804,16 +2849,16 @@ function AnimationEditor({ controller, values, onionSkin, motionPaths, showIssue
|
|
|
1804
2849
|
},
|
|
1805
2850
|
reveal: () => onPlaybackReveal?.()
|
|
1806
2851
|
});
|
|
1807
|
-
const presenceLayer = playing ? /* @__PURE__ */ (0,
|
|
2852
|
+
const presenceLayer = playing ? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(PresenceLayer, { presence: agentPresence }) : null;
|
|
1808
2853
|
useEffects(controller, effects);
|
|
1809
2854
|
const { issues, scene, selection, readOnly } = state;
|
|
1810
|
-
const [picked, setPicked] = (0,
|
|
1811
|
-
const [onion, setOnion] = (0,
|
|
1812
|
-
const [paths, setPaths] = (0,
|
|
1813
|
-
const [recordMode, setRecordMode] = (0,
|
|
2855
|
+
const [picked, setPicked] = (0, import_react21.useState)(null);
|
|
2856
|
+
const [onion, setOnion] = (0, import_react21.useState)(false);
|
|
2857
|
+
const [paths, setPaths] = (0, import_react21.useState)(false);
|
|
2858
|
+
const [recordMode, setRecordMode] = (0, import_react21.useState)("move");
|
|
1814
2859
|
const command = selection?.command !== void 0 ? scene.shots.find((s) => s.id === selection.shot)?.run[selection.command] : void 0;
|
|
1815
2860
|
const targets = command && "targets" in command ? command.targets : [];
|
|
1816
|
-
const nodes = (0,
|
|
2861
|
+
const nodes = (0, import_react21.useMemo)(() => (0, import_animation_editor11.indexMotionNodes)(scene.artwork.nodes), [scene.artwork]);
|
|
1817
2862
|
const pickedValid = picked && nodes.has(picked) ? picked : null;
|
|
1818
2863
|
const onPick = (id, event) => {
|
|
1819
2864
|
if (event.shiftKey && id && command && "targets" in command && selection?.command !== void 0 && !readOnly) {
|
|
@@ -1823,7 +2868,7 @@ function AnimationEditor({ controller, values, onionSkin, motionPaths, showIssue
|
|
|
1823
2868
|
}
|
|
1824
2869
|
setPicked(id);
|
|
1825
2870
|
};
|
|
1826
|
-
const stage = /* @__PURE__ */ (0,
|
|
2871
|
+
const stage = /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
1827
2872
|
AnimationStage,
|
|
1828
2873
|
{
|
|
1829
2874
|
controller,
|
|
@@ -1836,15 +2881,15 @@ function AnimationEditor({ controller, values, onionSkin, motionPaths, showIssue
|
|
|
1836
2881
|
className: "rounded-md border border-border bg-muted/40"
|
|
1837
2882
|
}
|
|
1838
2883
|
);
|
|
1839
|
-
const issueList = showIssues && issues.length > 0 && /* @__PURE__ */ (0,
|
|
2884
|
+
const issueList = showIssues && issues.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("ul", { className: "space-y-0.5 text-xs", "aria-label": "Animation issues", children: issues.map((issue, i) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("li", { className: issue.severity === "error" ? "text-red-500" : issue.severity === "warning" ? "text-amber-500" : "text-muted-foreground", children: (0, import_animation_editor11.motionIssueLine)(issue) }, i)) });
|
|
1840
2885
|
if (!editable)
|
|
1841
|
-
return /* @__PURE__ */ (0,
|
|
2886
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { ref: rootRef, className: `relative flex flex-col gap-2 ${className}`, "data-animation-editor": "", children: [
|
|
1842
2887
|
presenceLayer,
|
|
1843
2888
|
stage,
|
|
1844
|
-
/* @__PURE__ */ (0,
|
|
2889
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(PlayheadScrubber, { controller }),
|
|
1845
2890
|
issueList
|
|
1846
2891
|
] });
|
|
1847
|
-
return /* @__PURE__ */ (0,
|
|
2892
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
|
|
1848
2893
|
"div",
|
|
1849
2894
|
{
|
|
1850
2895
|
ref: rootRef,
|
|
@@ -1859,41 +2904,41 @@ function AnimationEditor({ controller, values, onionSkin, motionPaths, showIssue
|
|
|
1859
2904
|
},
|
|
1860
2905
|
children: [
|
|
1861
2906
|
presenceLayer,
|
|
1862
|
-
/* @__PURE__ */ (0,
|
|
2907
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "flex min-w-0 flex-col gap-2", children: [
|
|
1863
2908
|
stage,
|
|
1864
|
-
/* @__PURE__ */ (0,
|
|
1865
|
-
/* @__PURE__ */ (0,
|
|
1866
|
-
/* @__PURE__ */ (0,
|
|
1867
|
-
/* @__PURE__ */ (0,
|
|
1868
|
-
onionSkin === void 0 && /* @__PURE__ */ (0,
|
|
1869
|
-
/* @__PURE__ */ (0,
|
|
2909
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(PlayheadScrubber, { controller }),
|
|
2910
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "flex flex-wrap items-center gap-2 text-xs text-muted-foreground", children: [
|
|
2911
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("button", { type: "button", className: btn6, onClick: () => controller.undo(), disabled: !state.canUndo, title: state.canUndo ? `Undo ${state.undoLabel}` : "Nothing to undo", "data-undo": "", children: "Undo" }),
|
|
2912
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("button", { type: "button", className: btn6, onClick: () => controller.redo(), disabled: !state.canRedo, title: state.canRedo ? `Redo ${state.redoLabel}` : "Nothing to redo", "data-redo": "", children: "Redo" }),
|
|
2913
|
+
onionSkin === void 0 && /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
2914
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("input", { type: "checkbox", checked: onion, onChange: (e) => setOnion(e.target.checked) }),
|
|
1870
2915
|
" Onion skin"
|
|
1871
2916
|
] }),
|
|
1872
|
-
motionPaths === void 0 && /* @__PURE__ */ (0,
|
|
1873
|
-
/* @__PURE__ */ (0,
|
|
2917
|
+
motionPaths === void 0 && /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
2918
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("input", { type: "checkbox", checked: paths, onChange: (e) => setPaths(e.target.checked) }),
|
|
1874
2919
|
" Motion paths"
|
|
1875
2920
|
] }),
|
|
1876
|
-
/* @__PURE__ */ (0,
|
|
2921
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: "ml-auto", "data-picked-element": pickedValid ?? void 0, children: pickedValid ? /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(import_jsx_runtime20.Fragment, { children: [
|
|
1877
2922
|
"Picked ",
|
|
1878
|
-
/* @__PURE__ */ (0,
|
|
2923
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("code", { className: "text-rose-500", children: pickedValid }),
|
|
1879
2924
|
" ",
|
|
1880
|
-
/* @__PURE__ */ (0,
|
|
2925
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("button", { type: "button", className: "underline", onClick: () => setPicked(null), children: "clear" })
|
|
1881
2926
|
] }) : "Click the stage to pick an element; shift-click to toggle it as a target." })
|
|
1882
2927
|
] }),
|
|
1883
|
-
!readOnly && /* @__PURE__ */ (0,
|
|
2928
|
+
!readOnly && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(AnimationRecordPanel, { controller, node: pickedValid, mode: recordMode, onModeChange: setRecordMode, className: "border-t border-border pt-2" }),
|
|
1884
2929
|
issueList
|
|
1885
2930
|
] }),
|
|
1886
|
-
/* @__PURE__ */ (0,
|
|
1887
|
-
/* @__PURE__ */ (0,
|
|
1888
|
-
(state.effectsProvider || controller.appliedEffects().length > 0) && /* @__PURE__ */ (0,
|
|
1889
|
-
/* @__PURE__ */ (0,
|
|
1890
|
-
/* @__PURE__ */ (0,
|
|
1891
|
-
/* @__PURE__ */ (0,
|
|
1892
|
-
/* @__PURE__ */ (0,
|
|
2931
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "flex min-w-0 flex-col gap-3", children: [
|
|
2932
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(CommandList, { controller, targets: pickedValid ? [pickedValid] : void 0 }),
|
|
2933
|
+
(state.effectsProvider || controller.appliedEffects().length > 0) && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(AnimationEffectsPanel, { controller, node: pickedValid, className: "border-t border-border pt-2" }),
|
|
2934
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(CommandInspector, { controller, picked: pickedValid, className: "border-t border-border pt-2" }),
|
|
2935
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("details", { open: true, className: "border-t border-border pt-2", children: [
|
|
2936
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("summary", { className: "cursor-pointer text-xs font-medium", children: "Shot" }),
|
|
2937
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ShotInspector, { controller, className: "mt-1" })
|
|
1893
2938
|
] }),
|
|
1894
|
-
/* @__PURE__ */ (0,
|
|
1895
|
-
/* @__PURE__ */ (0,
|
|
1896
|
-
/* @__PURE__ */ (0,
|
|
2939
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("details", { className: "border-t border-border pt-2", children: [
|
|
2940
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("summary", { className: "cursor-pointer text-xs font-medium", children: "Scene settings" }),
|
|
2941
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(SceneSettings, { controller, className: "mt-1" })
|
|
1897
2942
|
] })
|
|
1898
2943
|
] })
|
|
1899
2944
|
]
|