@hussmartinez/ui 0.11.0 → 0.13.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 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/react.d.ts +172 -5
- package/dist/react.js +640 -107
- package/dist/react.js.map +1 -1
- package/dist/styles.css +161 -0
- package/dist/ui.d.ts +172 -5
- package/package.json +1 -1
package/dist/react.js
CHANGED
|
@@ -9,7 +9,7 @@ var REGISTRY = /* @__PURE__ */ Symbol.for("@hussmartinez/ui");
|
|
|
9
9
|
var THIS_COPY = {};
|
|
10
10
|
var checked = false;
|
|
11
11
|
function ownVersion() {
|
|
12
|
-
return "0.
|
|
12
|
+
return "0.13.0";
|
|
13
13
|
}
|
|
14
14
|
function checkSingleCopy() {
|
|
15
15
|
if (checked || !(typeof process !== "undefined" && process.env.NODE_ENV !== "production")) return;
|
|
@@ -939,6 +939,7 @@ var ReorderableList = /* @__PURE__ */ forwardRef(function ReorderableList({ labe
|
|
|
939
939
|
const list = useRef(null);
|
|
940
940
|
const pending = useRef(void 0);
|
|
941
941
|
const lastSelected = useRef(selectedId);
|
|
942
|
+
const quiet = useRef(false);
|
|
942
943
|
const announce = useAnnounce();
|
|
943
944
|
const messages = useUiMessages();
|
|
944
945
|
useEffect(() => {
|
|
@@ -956,7 +957,12 @@ var ReorderableList = /* @__PURE__ */ forwardRef(function ReorderableList({ labe
|
|
|
956
957
|
const cells = cellsOf(row);
|
|
957
958
|
const target = cells[change.cell] ?? cells[0];
|
|
958
959
|
syncTabStop(element, target);
|
|
959
|
-
|
|
960
|
+
quiet.current = change.kind === "move";
|
|
961
|
+
try {
|
|
962
|
+
target?.focus();
|
|
963
|
+
} finally {
|
|
964
|
+
quiet.current = false;
|
|
965
|
+
}
|
|
960
966
|
}
|
|
961
967
|
if (row && change.kind === "move" && announceMoves) announce(messages.t("reorderableList.moved", {
|
|
962
968
|
label: cellsOf(row)[0]?.getAttribute("aria-label") ?? "",
|
|
@@ -977,7 +983,12 @@ var ReorderableList = /* @__PURE__ */ forwardRef(function ReorderableList({ labe
|
|
|
977
983
|
const cells = cellsOf(row);
|
|
978
984
|
const target = cells[cell] ?? cells[0];
|
|
979
985
|
syncTabStop(list.current, target);
|
|
980
|
-
|
|
986
|
+
quiet.current = true;
|
|
987
|
+
try {
|
|
988
|
+
target?.focus();
|
|
989
|
+
} finally {
|
|
990
|
+
quiet.current = false;
|
|
991
|
+
}
|
|
981
992
|
};
|
|
982
993
|
const handleKeyDown = (event) => {
|
|
983
994
|
onKeyDown?.(event);
|
|
@@ -1055,6 +1066,11 @@ var ReorderableList = /* @__PURE__ */ forwardRef(function ReorderableList({ labe
|
|
|
1055
1066
|
const handleFocus = (event) => {
|
|
1056
1067
|
onFocus?.(event);
|
|
1057
1068
|
syncTabStop(event.currentTarget, event.target);
|
|
1069
|
+
const target = event.target;
|
|
1070
|
+
if (!quiet.current && target.dataset["hmCell"] === "item") {
|
|
1071
|
+
const row = rowsOf(event.currentTarget).find((candidate) => candidate.contains(target));
|
|
1072
|
+
if (row) select(idOf(row));
|
|
1073
|
+
}
|
|
1058
1074
|
};
|
|
1059
1075
|
const handleBlur = (event) => {
|
|
1060
1076
|
onBlur?.(event);
|
|
@@ -1177,19 +1193,58 @@ function snap$1(value, min, max, step) {
|
|
|
1177
1193
|
const inRange = stepped > upper && step > 0 ? round(stepped - step) : stepped;
|
|
1178
1194
|
return Math.min(Math.max(inRange, min), upper);
|
|
1179
1195
|
}
|
|
1180
|
-
var Slider = /* @__PURE__ */ forwardRef(function Slider({ value: controlled, defaultValue, onValueChange, min = 0, max = 100, step = 1, largeStep, formatValue, label, className, classNames, unstyled, onKeyDown, ...props }, ref) {
|
|
1196
|
+
var Slider = /* @__PURE__ */ forwardRef(function Slider({ value: controlled, defaultValue, onValueChange, onValueCommit, min = 0, max = 100, step = 1, largeStep, formatValue, label, className, classNames, unstyled, onKeyDown, onKeyUp, onPointerDown, onBlur, ...props }, ref) {
|
|
1181
1197
|
const [uncontrolled, setUncontrolled] = useState(() => snap$1(defaultValue ?? min, min, max, step));
|
|
1182
1198
|
const value = snap$1(controlled ?? uncontrolled, min, max, step);
|
|
1183
1199
|
const fieldProps = useFieldProps(props, label);
|
|
1184
1200
|
if (label === void 0 && !props["aria-label"] && !props["aria-labelledby"] && fieldProps.id === void 0) {
|
|
1185
1201
|
if (typeof process !== "undefined" && process.env.NODE_ENV !== "production") warnInDevelopment("Slider needs an accessible name: pass label, or point a visible <label> at its id. Use text from your message catalogue.");
|
|
1186
1202
|
}
|
|
1203
|
+
const pending = useRef(null);
|
|
1204
|
+
const held = useRef(/* @__PURE__ */ new Set());
|
|
1205
|
+
const commitRef = useRef(onValueCommit);
|
|
1206
|
+
commitRef.current = onValueCommit;
|
|
1207
|
+
const commit = () => {
|
|
1208
|
+
const last = pending.current;
|
|
1209
|
+
pending.current = null;
|
|
1210
|
+
if (last !== null) commitRef.current?.(last);
|
|
1211
|
+
};
|
|
1187
1212
|
const change = (next) => {
|
|
1188
1213
|
const snapped = snap$1(next, min, max, step);
|
|
1189
1214
|
if (snapped === value) return;
|
|
1190
1215
|
if (controlled === void 0) setUncontrolled(snapped);
|
|
1216
|
+
pending.current = snapped;
|
|
1191
1217
|
onValueChange?.(snapped);
|
|
1192
1218
|
};
|
|
1219
|
+
const input = useRef(null);
|
|
1220
|
+
const commitLater = useRef(commit);
|
|
1221
|
+
commitLater.current = commit;
|
|
1222
|
+
useEffect(() => {
|
|
1223
|
+
const element = input.current;
|
|
1224
|
+
if (!element) return;
|
|
1225
|
+
const onCommit = () => commitLater.current();
|
|
1226
|
+
element.addEventListener("change", onCommit);
|
|
1227
|
+
return () => element.removeEventListener("change", onCommit);
|
|
1228
|
+
}, []);
|
|
1229
|
+
const handlePointerDown = (event) => {
|
|
1230
|
+
onPointerDown?.(event);
|
|
1231
|
+
const release = () => {
|
|
1232
|
+
window.removeEventListener("pointerup", release, true);
|
|
1233
|
+
window.removeEventListener("pointercancel", release, true);
|
|
1234
|
+
commitLater.current();
|
|
1235
|
+
};
|
|
1236
|
+
window.addEventListener("pointerup", release, true);
|
|
1237
|
+
window.addEventListener("pointercancel", release, true);
|
|
1238
|
+
};
|
|
1239
|
+
const handleKeyUp = (event) => {
|
|
1240
|
+
onKeyUp?.(event);
|
|
1241
|
+
if (held.current.delete(event.key) && held.current.size === 0) commit();
|
|
1242
|
+
};
|
|
1243
|
+
const handleBlur = (event) => {
|
|
1244
|
+
onBlur?.(event);
|
|
1245
|
+
held.current.clear();
|
|
1246
|
+
commit();
|
|
1247
|
+
};
|
|
1193
1248
|
const handleChange = (event) => {
|
|
1194
1249
|
change(event.currentTarget.valueAsNumber);
|
|
1195
1250
|
};
|
|
@@ -1210,12 +1265,17 @@ var Slider = /* @__PURE__ */ forwardRef(function Slider({ value: controlled, def
|
|
|
1210
1265
|
}[event.key];
|
|
1211
1266
|
if (next === void 0) return;
|
|
1212
1267
|
event.preventDefault();
|
|
1268
|
+
held.current.add(event.key);
|
|
1213
1269
|
change(next);
|
|
1214
1270
|
};
|
|
1215
1271
|
return /* @__PURE__ */ jsx("input", {
|
|
1216
1272
|
...props,
|
|
1217
1273
|
...fieldProps,
|
|
1218
|
-
ref
|
|
1274
|
+
ref: (node) => {
|
|
1275
|
+
input.current = node;
|
|
1276
|
+
if (typeof ref === "function") ref(node);
|
|
1277
|
+
else if (ref) ref.current = node;
|
|
1278
|
+
},
|
|
1219
1279
|
type: "range",
|
|
1220
1280
|
min,
|
|
1221
1281
|
max,
|
|
@@ -1226,7 +1286,10 @@ var Slider = /* @__PURE__ */ forwardRef(function Slider({ value: controlled, def
|
|
|
1226
1286
|
className: cx("hm-slider", classNames?.root, className),
|
|
1227
1287
|
"data-hm-unstyled": unstyledAttribute(unstyled),
|
|
1228
1288
|
onChange: handleChange,
|
|
1229
|
-
onKeyDown: handleKeyDown
|
|
1289
|
+
onKeyDown: handleKeyDown,
|
|
1290
|
+
onKeyUp: handleKeyUp,
|
|
1291
|
+
onPointerDown: handlePointerDown,
|
|
1292
|
+
onBlur: handleBlur
|
|
1230
1293
|
});
|
|
1231
1294
|
});
|
|
1232
1295
|
// src/components/spinner/Spinner.tsx
|
|
@@ -1283,10 +1346,25 @@ var TextField = /* @__PURE__ */ forwardRef(function TextField({ type = "text", o
|
|
|
1283
1346
|
onChange: handleChange
|
|
1284
1347
|
});
|
|
1285
1348
|
});
|
|
1349
|
+
// src/components/timeline/set-style.ts
|
|
1350
|
+
var written = /* @__PURE__ */ new WeakMap();
|
|
1351
|
+
function setStyle(element, property, value) {
|
|
1352
|
+
let last = written.get(element);
|
|
1353
|
+
if (!last) {
|
|
1354
|
+
last = /* @__PURE__ */ new Map();
|
|
1355
|
+
written.set(element, last);
|
|
1356
|
+
}
|
|
1357
|
+
if ((last.get(property) ?? "") === value) return;
|
|
1358
|
+
last.set(property, value);
|
|
1359
|
+
if (value === "") element.style.removeProperty(property);
|
|
1360
|
+
else element.style.setProperty(property, value);
|
|
1361
|
+
}
|
|
1286
1362
|
// src/components/timeline/Timeline.tsx
|
|
1287
1363
|
var SNAP_PIXELS = 8;
|
|
1288
1364
|
var MAX_TRACK_PIXELS = 8e6;
|
|
1365
|
+
var TimelineLaneContext = /* @__PURE__ */ createContext(void 0);
|
|
1289
1366
|
var TimelineContext = /* @__PURE__ */ createContext(void 0);
|
|
1367
|
+
var HEADERS_BESIDE = 720;
|
|
1290
1368
|
function useTimelineContext(part) {
|
|
1291
1369
|
checkSingleCopy();
|
|
1292
1370
|
const context = useContext(TimelineContext);
|
|
@@ -1297,6 +1375,7 @@ function useTimelineContext(part) {
|
|
|
1297
1375
|
}
|
|
1298
1376
|
var NO_SCALE = {
|
|
1299
1377
|
length: 0,
|
|
1378
|
+
extent: 0,
|
|
1300
1379
|
pixelsPerUnit: 0,
|
|
1301
1380
|
toPixels: () => 0,
|
|
1302
1381
|
unitAt: () => 0,
|
|
@@ -1310,30 +1389,62 @@ function useTimelineScale() {
|
|
|
1310
1389
|
return useTimelineContext("useTimelineScale")?.scale ?? NO_SCALE;
|
|
1311
1390
|
}
|
|
1312
1391
|
var isRtl = (element) => getComputedStyle(element).direction === "rtl";
|
|
1313
|
-
var Timeline = /* @__PURE__ */ forwardRef(function Timeline({ label, length: rawLength, zoom = 1, maxPixelsPerUnit = 48, onMaxZoomChange, snapping = true, snapTargets, onVisibleRangeChange, className, classNames, unstyled, children, ...props }, ref) {
|
|
1392
|
+
var Timeline = /* @__PURE__ */ forwardRef(function Timeline({ label, length: rawLength, extent: rawExtent, zoom = 1, maxPixelsPerUnit = 48, onMaxZoomChange, snapping = true, snapTargets, onVisibleRangeChange, className, classNames, unstyled, children, ...props }, ref) {
|
|
1314
1393
|
const length = Number.isSafeInteger(rawLength) && rawLength > 0 ? rawLength : 0;
|
|
1394
|
+
const extent = rawExtent !== void 0 && Number.isSafeInteger(rawExtent) ? Math.max(rawExtent, length) : length;
|
|
1315
1395
|
const viewport = useRef(null);
|
|
1316
1396
|
const track = useRef(null);
|
|
1317
1397
|
const [room, setRoom] = useState(0);
|
|
1318
1398
|
const lead = useRef(0);
|
|
1319
1399
|
const targets = useRef(/* @__PURE__ */ new Set());
|
|
1400
|
+
const laneParts = useRef(/* @__PURE__ */ new Map());
|
|
1401
|
+
const laneClips = useRef(/* @__PURE__ */ new Map());
|
|
1402
|
+
const [lanes, setLanes] = useState([]);
|
|
1403
|
+
const [headerWidth, setHeaderWidth] = useState(0);
|
|
1404
|
+
const [trail, setTrail] = useState(0);
|
|
1405
|
+
const [beside, setBeside] = useState(true);
|
|
1320
1406
|
const measure = (element) => {
|
|
1407
|
+
if (laneParts.current.size > 0 || order.current.length > 0) measureLanes(element);
|
|
1321
1408
|
const style = getComputedStyle(element);
|
|
1322
1409
|
const padding = Number.parseFloat(style.paddingLeft) + Number.parseFloat(style.paddingRight);
|
|
1323
1410
|
lead.current = Number.parseFloat(style.paddingInlineStart) || 0;
|
|
1324
1411
|
setRoom(Math.max(0, element.clientWidth - padding));
|
|
1325
1412
|
};
|
|
1413
|
+
const measureLanes = (element) => {
|
|
1414
|
+
const order = [...laneParts.current.entries()].sort(([, a], [, b]) => a.element.compareDocumentPosition(b.element) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1);
|
|
1415
|
+
const ids = order.map(([id]) => id);
|
|
1416
|
+
setLanes((current) => current.length === ids.length && current.every((id, index) => id === ids[index]) ? current : ids);
|
|
1417
|
+
const wide = element.offsetWidth >= HEADERS_BESIDE;
|
|
1418
|
+
setBeside(wide);
|
|
1419
|
+
const widest = Math.max(0, ...order.map(([, lane]) => lane.toolbar?.offsetWidth ?? 0));
|
|
1420
|
+
const column = wide ? Math.ceil(widest) : 0;
|
|
1421
|
+
setHeaderWidth(column);
|
|
1422
|
+
const after = Number.parseFloat(getComputedStyle(element).paddingInlineEnd) || 0;
|
|
1423
|
+
setTrail(after);
|
|
1424
|
+
setStyle(element, "padding-inline-start", column > 0 ? `${column + after}px` : "");
|
|
1425
|
+
};
|
|
1326
1426
|
const remeasure = useRef(measure);
|
|
1327
1427
|
remeasure.current = measure;
|
|
1428
|
+
const resized = useRef(null);
|
|
1328
1429
|
useEffect(() => {
|
|
1329
1430
|
const element = viewport.current;
|
|
1330
1431
|
if (!element) return;
|
|
1331
|
-
|
|
1432
|
+
let frame = 0;
|
|
1433
|
+
const observer = new ResizeObserver(() => {
|
|
1434
|
+
cancelAnimationFrame(frame);
|
|
1435
|
+
frame = requestAnimationFrame(() => remeasure.current(element));
|
|
1436
|
+
});
|
|
1332
1437
|
observer.observe(element);
|
|
1333
|
-
|
|
1438
|
+
resized.current = observer;
|
|
1439
|
+
for (const lane of laneParts.current.values()) if (lane.toolbar) observer.observe(lane.toolbar);
|
|
1440
|
+
return () => {
|
|
1441
|
+
resized.current = null;
|
|
1442
|
+
cancelAnimationFrame(frame);
|
|
1443
|
+
observer.disconnect();
|
|
1444
|
+
};
|
|
1334
1445
|
}, []);
|
|
1335
|
-
const fit =
|
|
1336
|
-
const closest = Math.max(fit, Math.min(maxPixelsPerUnit, MAX_TRACK_PIXELS / Math.max(
|
|
1446
|
+
const fit = extent > 0 && room > 0 ? room / extent : 0;
|
|
1447
|
+
const closest = Math.max(fit, Math.min(maxPixelsPerUnit, MAX_TRACK_PIXELS / Math.max(extent, 1)));
|
|
1337
1448
|
const pixelsPerUnit = Math.min(Math.max(fit * zoom, fit), closest);
|
|
1338
1449
|
const maxZoom = fit > 0 ? closest / fit : 1;
|
|
1339
1450
|
const notifyMaxZoom = useRef(onMaxZoomChange);
|
|
@@ -1342,8 +1453,10 @@ var Timeline = /* @__PURE__ */ forwardRef(function Timeline({ label, length: raw
|
|
|
1342
1453
|
if (fit > 0) notifyMaxZoom.current?.(maxZoom);
|
|
1343
1454
|
}, [fit, maxZoom]);
|
|
1344
1455
|
const sizeTrack = (element) => {
|
|
1345
|
-
element
|
|
1456
|
+
setStyle(element, "inline-size", pixelsPerUnit > 0 ? `${extent * pixelsPerUnit}px` : "");
|
|
1346
1457
|
};
|
|
1458
|
+
const headerColumn = useRef(headerWidth);
|
|
1459
|
+
headerColumn.current = headerWidth;
|
|
1347
1460
|
const settings = useRef({
|
|
1348
1461
|
snapping,
|
|
1349
1462
|
snapTargets
|
|
@@ -1352,16 +1465,19 @@ var Timeline = /* @__PURE__ */ forwardRef(function Timeline({ label, length: raw
|
|
|
1352
1465
|
snapping,
|
|
1353
1466
|
snapTargets
|
|
1354
1467
|
};
|
|
1468
|
+
const snapExceptRef = useRef((unit) => unit);
|
|
1355
1469
|
const scale = useMemo(() => {
|
|
1356
|
-
const snap$2 = (unit) => {
|
|
1470
|
+
const snap$2 = (unit, except = []) => {
|
|
1357
1471
|
if (!settings.current.snapping || pixelsPerUnit <= 0) return unit;
|
|
1358
1472
|
const all = [...settings.current.snapTargets ?? []];
|
|
1359
1473
|
for (const read of targets.current) all.push(...read());
|
|
1360
|
-
const valid = all.filter((target) => Number.isSafeInteger(target) && target >= 0);
|
|
1474
|
+
const valid = all.filter((target) => Number.isSafeInteger(target) && target >= 0 && !except.includes(target));
|
|
1361
1475
|
return snap(unit, valid, Math.round(SNAP_PIXELS / pixelsPerUnit));
|
|
1362
1476
|
};
|
|
1477
|
+
snapExceptRef.current = snap$2;
|
|
1363
1478
|
return {
|
|
1364
1479
|
length,
|
|
1480
|
+
extent,
|
|
1365
1481
|
pixelsPerUnit,
|
|
1366
1482
|
toPixels: (unit) => unit * pixelsPerUnit,
|
|
1367
1483
|
unitAt: (clientX, options) => {
|
|
@@ -1369,24 +1485,30 @@ var Timeline = /* @__PURE__ */ forwardRef(function Timeline({ label, length: raw
|
|
|
1369
1485
|
if (!element || pixelsPerUnit <= 0) return 0;
|
|
1370
1486
|
const box = element.getBoundingClientRect();
|
|
1371
1487
|
const offset = isRtl(element) ? box.right - clientX : clientX - box.left;
|
|
1372
|
-
const unit = Math.min(Math.max(Math.round(offset / pixelsPerUnit), 0),
|
|
1373
|
-
return options?.snap ? Math.min(snap$2(unit),
|
|
1488
|
+
const unit = Math.min(Math.max(Math.round(offset / pixelsPerUnit), 0), extent);
|
|
1489
|
+
return options?.snap ? Math.min(snap$2(unit), extent) : unit;
|
|
1374
1490
|
},
|
|
1375
|
-
snap: snap$2,
|
|
1491
|
+
snap: (unit) => snap$2(unit),
|
|
1376
1492
|
visibleRange: () => {
|
|
1377
1493
|
const element = viewport.current;
|
|
1378
1494
|
if (!element || pixelsPerUnit <= 0) return {
|
|
1379
1495
|
start: 0,
|
|
1380
|
-
end:
|
|
1496
|
+
end: extent
|
|
1381
1497
|
};
|
|
1382
|
-
const
|
|
1498
|
+
const scrolled = Math.abs(element.scrollLeft) - lead.current;
|
|
1499
|
+
const start = (scrolled + headerColumn.current) / pixelsPerUnit;
|
|
1500
|
+
const end = (scrolled + element.clientWidth) / pixelsPerUnit;
|
|
1383
1501
|
return {
|
|
1384
|
-
start: Math.min(Math.max(Math.floor(start), 0),
|
|
1385
|
-
end: Math.min(Math.max(Math.ceil(
|
|
1502
|
+
start: Math.min(Math.max(Math.floor(start), 0), extent),
|
|
1503
|
+
end: Math.min(Math.max(Math.ceil(end), 0), extent)
|
|
1386
1504
|
};
|
|
1387
1505
|
}
|
|
1388
1506
|
};
|
|
1389
|
-
}, [
|
|
1507
|
+
}, [
|
|
1508
|
+
length,
|
|
1509
|
+
extent,
|
|
1510
|
+
pixelsPerUnit
|
|
1511
|
+
]);
|
|
1390
1512
|
const addTargets = useCallback((read) => {
|
|
1391
1513
|
targets.current.add(read);
|
|
1392
1514
|
return () => {
|
|
@@ -1405,18 +1527,69 @@ var Timeline = /* @__PURE__ */ forwardRef(function Timeline({ label, length: raw
|
|
|
1405
1527
|
}
|
|
1406
1528
|
}, [scale]);
|
|
1407
1529
|
useEffect(reportRange, [reportRange, room]);
|
|
1530
|
+
const setLane = useCallback((id, lane) => {
|
|
1531
|
+
const before = laneParts.current.get(id);
|
|
1532
|
+
if (lane) {
|
|
1533
|
+
if (before?.element === lane.element && before.toolbar === lane.toolbar) return;
|
|
1534
|
+
laneParts.current.set(id, lane);
|
|
1535
|
+
if (lane.toolbar) resized.current?.observe(lane.toolbar);
|
|
1536
|
+
} else if (before) {
|
|
1537
|
+
laneParts.current.delete(id);
|
|
1538
|
+
if (before.toolbar) resized.current?.unobserve(before.toolbar);
|
|
1539
|
+
}
|
|
1540
|
+
if (viewport.current) remeasure.current(viewport.current);
|
|
1541
|
+
}, []);
|
|
1542
|
+
const setLaneClips = useCallback((id, clips) => {
|
|
1543
|
+
if (clips) laneClips.current.set(id, clips);
|
|
1544
|
+
else laneClips.current.delete(id);
|
|
1545
|
+
}, []);
|
|
1546
|
+
const order = useRef(lanes);
|
|
1547
|
+
order.current = lanes;
|
|
1548
|
+
const nextLaneClips = useCallback((id, direction) => {
|
|
1549
|
+
const ids = order.current;
|
|
1550
|
+
for (let at = ids.indexOf(id) + direction; at >= 0 && at < ids.length; at += direction) {
|
|
1551
|
+
const clips = laneClips.current.get(ids[at]);
|
|
1552
|
+
if (clips?.any()) return clips;
|
|
1553
|
+
}
|
|
1554
|
+
}, []);
|
|
1555
|
+
const focusOnAnotherLane = useCallback((from, key) => {
|
|
1556
|
+
for (const [id, clips] of laneClips.current) if (id !== from && clips.focus(key)) return true;
|
|
1557
|
+
return false;
|
|
1558
|
+
}, []);
|
|
1559
|
+
const snapExcept = useCallback((unit, except) => snapExceptRef.current(unit, except), []);
|
|
1408
1560
|
const context = useMemo(() => ({
|
|
1409
1561
|
scale,
|
|
1410
1562
|
viewport,
|
|
1411
1563
|
track,
|
|
1412
|
-
addTargets
|
|
1413
|
-
|
|
1564
|
+
addTargets,
|
|
1565
|
+
lanes,
|
|
1566
|
+
headerWidth,
|
|
1567
|
+
trail,
|
|
1568
|
+
setLane,
|
|
1569
|
+
setLaneClips,
|
|
1570
|
+
nextLaneClips,
|
|
1571
|
+
focusOnAnotherLane,
|
|
1572
|
+
snapExcept
|
|
1573
|
+
}), [
|
|
1574
|
+
scale,
|
|
1575
|
+
addTargets,
|
|
1576
|
+
lanes,
|
|
1577
|
+
headerWidth,
|
|
1578
|
+
trail,
|
|
1579
|
+
setLane,
|
|
1580
|
+
setLaneClips,
|
|
1581
|
+
nextLaneClips,
|
|
1582
|
+
focusOnAnotherLane,
|
|
1583
|
+
snapExcept
|
|
1584
|
+
]);
|
|
1585
|
+
const laned = lanes.length > 0;
|
|
1414
1586
|
return /* @__PURE__ */ jsx("section", {
|
|
1415
1587
|
...props,
|
|
1416
1588
|
ref,
|
|
1417
1589
|
"aria-label": label,
|
|
1418
1590
|
className: cx("hm-timeline", classNames?.root, className),
|
|
1419
1591
|
"data-hm-unstyled": unstyledAttribute(unstyled),
|
|
1592
|
+
"data-hm-lanes": laned ? beside ? "beside" : "above" : void 0,
|
|
1420
1593
|
children: /* @__PURE__ */ jsx("div", {
|
|
1421
1594
|
ref: (node) => {
|
|
1422
1595
|
viewport.current = node;
|
|
@@ -1424,30 +1597,75 @@ var Timeline = /* @__PURE__ */ forwardRef(function Timeline({ label, length: raw
|
|
|
1424
1597
|
},
|
|
1425
1598
|
className: cx("hm-timeline-viewport", classNames?.viewport),
|
|
1426
1599
|
onScroll: reportRange,
|
|
1427
|
-
children: /* @__PURE__ */
|
|
1600
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
1428
1601
|
ref: (node) => {
|
|
1429
1602
|
track.current = node;
|
|
1430
1603
|
if (node) sizeTrack(node);
|
|
1431
1604
|
},
|
|
1432
1605
|
className: cx("hm-timeline-track", classNames?.track),
|
|
1433
|
-
children:
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1606
|
+
children: [
|
|
1607
|
+
laned ? /* @__PURE__ */ jsx("div", {
|
|
1608
|
+
className: "hm-timeline-bar",
|
|
1609
|
+
"aria-hidden": "true",
|
|
1610
|
+
ref: (node) => {
|
|
1611
|
+
if (node) setStyle(node, "margin-inline-start", headerWidth > 0 ? `${-(headerWidth + trail)}px` : "");
|
|
1612
|
+
}
|
|
1613
|
+
}) : null,
|
|
1614
|
+
laned && headerWidth > 0 ? /* @__PURE__ */ jsx("div", {
|
|
1615
|
+
className: "hm-timeline-corner",
|
|
1616
|
+
"aria-hidden": "true",
|
|
1617
|
+
ref: (node) => {
|
|
1618
|
+
if (node) {
|
|
1619
|
+
setStyle(node, "margin-inline-start", `${-(headerWidth + trail)}px`);
|
|
1620
|
+
const cover = node.firstElementChild;
|
|
1621
|
+
setStyle(cover, "inline-size", `${headerWidth}px`);
|
|
1622
|
+
setStyle(cover, "inset-inline-start", `${-(headerWidth + trail)}px`);
|
|
1623
|
+
}
|
|
1624
|
+
},
|
|
1625
|
+
children: /* @__PURE__ */ jsx("div", { className: "hm-timeline-corner-cover" })
|
|
1626
|
+
}) : null,
|
|
1627
|
+
/* @__PURE__ */ jsx(TimelineContext.Provider, {
|
|
1628
|
+
value: context,
|
|
1629
|
+
children
|
|
1630
|
+
})
|
|
1631
|
+
]
|
|
1437
1632
|
})
|
|
1438
1633
|
})
|
|
1439
1634
|
});
|
|
1440
1635
|
});
|
|
1441
1636
|
var TimelineLayer = /* @__PURE__ */ forwardRef(function TimelineLayer({ className, children, ...props }, ref) {
|
|
1637
|
+
const lanes = useContext(TimelineContext)?.lanes.length ?? 0;
|
|
1638
|
+
const rows = useContext(TimelineLaneContext) !== void 0 ? 0 : lanes;
|
|
1442
1639
|
return /* @__PURE__ */ jsx("div", {
|
|
1443
1640
|
...props,
|
|
1444
|
-
ref
|
|
1641
|
+
ref: (node) => {
|
|
1642
|
+
if (node) setStyle(node, "grid-row", rows > 0 ? `2 / span ${rows}` : "");
|
|
1643
|
+
if (typeof ref === "function") ref(node);
|
|
1644
|
+
else if (ref) ref.current = node;
|
|
1645
|
+
},
|
|
1445
1646
|
className: cx("hm-timeline-layer", className),
|
|
1446
1647
|
children
|
|
1447
1648
|
});
|
|
1448
1649
|
});
|
|
1650
|
+
function useTimelineLanes() {
|
|
1651
|
+
const context = useTimelineContext("useTimelineLanes");
|
|
1652
|
+
const lanes = context?.lanes;
|
|
1653
|
+
const track = context?.track;
|
|
1654
|
+
return useMemo(() => ({
|
|
1655
|
+
lanes: lanes ?? [],
|
|
1656
|
+
laneAt: (clientY) => {
|
|
1657
|
+
for (const element of track?.current?.querySelectorAll(":scope > [data-hm-lane]") ?? []) {
|
|
1658
|
+
const box = element.getBoundingClientRect();
|
|
1659
|
+
if (clientY >= box.top && clientY < box.bottom) return element.dataset["hmLane"];
|
|
1660
|
+
}
|
|
1661
|
+
}
|
|
1662
|
+
}), [lanes, track]);
|
|
1663
|
+
}
|
|
1449
1664
|
// src/components/timeline/TimelineClips.tsx
|
|
1450
|
-
var
|
|
1665
|
+
var DRAG_AFTER = 4;
|
|
1666
|
+
var EDGE = 32;
|
|
1667
|
+
var SCROLL = 12;
|
|
1668
|
+
var Clip = /* @__PURE__ */ memo(function Clip({ clip, selected, tabStop, clipClass, contentClass, edges, dragging, pastEnd, moving }) {
|
|
1451
1669
|
return /* @__PURE__ */ jsxs("div", {
|
|
1452
1670
|
...clip.attributes,
|
|
1453
1671
|
role: "option",
|
|
@@ -1456,6 +1674,8 @@ var Clip = /* @__PURE__ */ memo(function Clip({ clip, selected, tabStop, clipCla
|
|
|
1456
1674
|
tabIndex: tabStop ? 0 : -1,
|
|
1457
1675
|
"data-hm-key": clip.key,
|
|
1458
1676
|
"data-hm-dragging": dragging,
|
|
1677
|
+
"data-hm-past-end": pastEnd ? "" : void 0,
|
|
1678
|
+
"data-hm-moving": moving,
|
|
1459
1679
|
className: clipClass,
|
|
1460
1680
|
children: [clip.content == null ? null : /* @__PURE__ */ jsx("span", {
|
|
1461
1681
|
className: contentClass,
|
|
@@ -1471,9 +1691,10 @@ var Clip = /* @__PURE__ */ memo(function Clip({ clip, selected, tabStop, clipCla
|
|
|
1471
1691
|
})] }) : null]
|
|
1472
1692
|
});
|
|
1473
1693
|
});
|
|
1474
|
-
var TimelineClips = /* @__PURE__ */ forwardRef(function TimelineClips({ label, clips: given, selectionMode = "single", selectedKeys, onSelectedKeysChange, onMove, onTrim, onTrimToPlayhead, trimStep = 1, trimLimits, className, classNames, unstyled }, ref) {
|
|
1694
|
+
var TimelineClips = /* @__PURE__ */ forwardRef(function TimelineClips({ label, clips: given, selectionMode = "single", selectedKeys, onSelectedKeysChange, onMove, onTrim, onTrimToPlayhead, trimStep = 1, trimLimits, onMoveLane, onDrop, canDrop, moveHandle = "clip", className, classNames, unstyled }, ref) {
|
|
1475
1695
|
const context = useTimelineContext("TimelineClips");
|
|
1476
1696
|
const pixelsPerUnit = context?.scale.pixelsPerUnit ?? 0;
|
|
1697
|
+
const timelineLength = context?.scale.length ?? Number.POSITIVE_INFINITY;
|
|
1477
1698
|
const multiple = selectionMode === "multiple";
|
|
1478
1699
|
const clips = useMemo(() => {
|
|
1479
1700
|
const valid = given.filter((clip) => Number.isSafeInteger(clip.length) && clip.length > 0);
|
|
@@ -1482,7 +1703,26 @@ var TimelineClips = /* @__PURE__ */ forwardRef(function TimelineClips({ label, c
|
|
|
1482
1703
|
}
|
|
1483
1704
|
return valid;
|
|
1484
1705
|
}, [given]);
|
|
1485
|
-
const
|
|
1706
|
+
const starts = useMemo(() => {
|
|
1707
|
+
const placed = clips.filter((clip) => clip.at !== void 0).length;
|
|
1708
|
+
if (placed === 0) return sequenceOffsets(clips.map((clip) => clip.length)).slice(0, clips.length);
|
|
1709
|
+
let end = 0;
|
|
1710
|
+
let mistake;
|
|
1711
|
+
if (placed !== clips.length) mistake = "gives some clips `at` and not others: give it to every clip, or to none";
|
|
1712
|
+
const result = clips.map((clip) => {
|
|
1713
|
+
const valid = clip.at !== void 0 && Number.isSafeInteger(clip.at) && clip.at >= 0;
|
|
1714
|
+
const start = valid ? clip.at : end;
|
|
1715
|
+
if (clip.at !== void 0 && !valid) mistake ??= "has a clip whose `at` isn't a whole number of at least 0";
|
|
1716
|
+
else if (start < end) mistake ??= "has clips that overlap or aren't in time order";
|
|
1717
|
+
end = Math.max(end, start + clip.length);
|
|
1718
|
+
return start;
|
|
1719
|
+
});
|
|
1720
|
+
if (mistake) {
|
|
1721
|
+
if (typeof process !== "undefined" && process.env.NODE_ENV !== "production") warnInDevelopment(`TimelineClips ${mistake}.`);
|
|
1722
|
+
}
|
|
1723
|
+
return result;
|
|
1724
|
+
}, [clips]);
|
|
1725
|
+
const positioned = clips.some((clip) => clip.at !== void 0);
|
|
1486
1726
|
const list = useRef(null);
|
|
1487
1727
|
const [focusKey, setFocusKey] = useState(null);
|
|
1488
1728
|
const anchor = useRef(null);
|
|
@@ -1502,31 +1742,99 @@ var TimelineClips = /* @__PURE__ */ forwardRef(function TimelineClips({ label, c
|
|
|
1502
1742
|
const viewport = context?.viewport.current;
|
|
1503
1743
|
if (viewport) {
|
|
1504
1744
|
const box = element.getBoundingClientRect();
|
|
1505
|
-
const
|
|
1745
|
+
const bounds = viewport.getBoundingClientRect();
|
|
1746
|
+
const header = context?.headerWidth ?? 0;
|
|
1747
|
+
const rtl = getComputedStyle(viewport).direction === "rtl";
|
|
1748
|
+
const view = {
|
|
1749
|
+
left: bounds.left + (rtl ? 0 : header),
|
|
1750
|
+
right: bounds.right - (rtl ? header : 0)
|
|
1751
|
+
};
|
|
1506
1752
|
if (box.left < view.left) viewport.scrollLeft -= view.left - box.left;
|
|
1507
1753
|
else if (box.right > view.right) viewport.scrollLeft += Math.min(box.right - view.right, box.left - view.left);
|
|
1508
1754
|
}
|
|
1509
1755
|
return true;
|
|
1510
1756
|
};
|
|
1511
1757
|
useImperativeHandle(ref, () => ({ focusClip }));
|
|
1758
|
+
const quiet = useRef(false);
|
|
1759
|
+
const focusQuietly = (key) => {
|
|
1760
|
+
quiet.current = true;
|
|
1761
|
+
try {
|
|
1762
|
+
return focusClip(key);
|
|
1763
|
+
} finally {
|
|
1764
|
+
quiet.current = false;
|
|
1765
|
+
}
|
|
1766
|
+
};
|
|
1767
|
+
const laneId = useContext(TimelineLaneContext);
|
|
1768
|
+
const forLanes = useRef({
|
|
1769
|
+
any: () => false,
|
|
1770
|
+
focus: () => false,
|
|
1771
|
+
focusNearest: () => void 0
|
|
1772
|
+
});
|
|
1773
|
+
forLanes.current = {
|
|
1774
|
+
any: () => clips.length > 0,
|
|
1775
|
+
focus: (key) => clips.some((clip) => clip.key === key) && focusQuietly(key),
|
|
1776
|
+
focusNearest: (unit, andSelect) => {
|
|
1777
|
+
let nearest;
|
|
1778
|
+
let distance = Number.POSITIVE_INFINITY;
|
|
1779
|
+
clips.forEach((clip, index) => {
|
|
1780
|
+
const start = starts[index] ?? 0;
|
|
1781
|
+
const end = start + clip.length;
|
|
1782
|
+
const away = unit < start ? start - unit : unit >= end ? unit - end + 1 : 0;
|
|
1783
|
+
if (away < distance) {
|
|
1784
|
+
nearest = clip;
|
|
1785
|
+
distance = away;
|
|
1786
|
+
}
|
|
1787
|
+
});
|
|
1788
|
+
if (nearest && focusQuietly(nearest.key) && andSelect) {
|
|
1789
|
+
anchor.current = nearest.key;
|
|
1790
|
+
select([nearest.key]);
|
|
1791
|
+
}
|
|
1792
|
+
}
|
|
1793
|
+
};
|
|
1794
|
+
const setLaneClips = context?.setLaneClips;
|
|
1795
|
+
useEffect(() => {
|
|
1796
|
+
if (laneId === void 0 || !setLaneClips) return;
|
|
1797
|
+
setLaneClips(laneId, {
|
|
1798
|
+
any: () => forLanes.current.any(),
|
|
1799
|
+
focus: (key) => forLanes.current.focus(key),
|
|
1800
|
+
focusNearest: (unit, andSelect) => forLanes.current.focusNearest(unit, andSelect)
|
|
1801
|
+
});
|
|
1802
|
+
return () => setLaneClips(laneId, null);
|
|
1803
|
+
}, [laneId, setLaneClips]);
|
|
1512
1804
|
const addTargets = context?.addTargets;
|
|
1513
|
-
const
|
|
1514
|
-
boundaries
|
|
1805
|
+
const edges = useMemo(() => [...new Set(clips.flatMap((clip, index) => [starts[index] ?? 0, (starts[index] ?? 0) + clip.length]))], [clips, starts]);
|
|
1806
|
+
const boundaries = useRef(edges);
|
|
1807
|
+
boundaries.current = edges;
|
|
1515
1808
|
useEffect(() => addTargets?.(() => boundaries.current), [addTargets]);
|
|
1516
1809
|
const [drag, setDrag] = useState(null);
|
|
1810
|
+
const [move, setMove] = useState(null);
|
|
1517
1811
|
const sized = useRef(null);
|
|
1518
1812
|
const sizeClips = (element) => {
|
|
1519
|
-
if (sized.current?.clips === clips && sized.current.scale === pixelsPerUnit && sized.current.drag === drag) return;
|
|
1813
|
+
if (sized.current?.clips === clips && sized.current.scale === pixelsPerUnit && sized.current.drag === drag && sized.current.move === move) return;
|
|
1520
1814
|
sized.current = {
|
|
1521
1815
|
clips,
|
|
1522
1816
|
scale: pixelsPerUnit,
|
|
1523
|
-
drag
|
|
1817
|
+
drag,
|
|
1818
|
+
move
|
|
1524
1819
|
};
|
|
1820
|
+
const rtl = move ? getComputedStyle(element).direction === "rtl" : false;
|
|
1525
1821
|
const elements = element.children;
|
|
1822
|
+
let end = 0;
|
|
1526
1823
|
for (let index = 0; index < elements.length; index++) {
|
|
1527
1824
|
const clip = clips[index];
|
|
1528
|
-
const
|
|
1529
|
-
|
|
1825
|
+
const node = elements[index];
|
|
1826
|
+
let start = starts[index] ?? end;
|
|
1827
|
+
let length = clip?.length ?? 0;
|
|
1828
|
+
if (clip && drag?.key === clip.key) {
|
|
1829
|
+
length += drag.delta;
|
|
1830
|
+
if (drag.edge === "start" && positioned) start -= drag.delta;
|
|
1831
|
+
}
|
|
1832
|
+
if (!positioned) start = end;
|
|
1833
|
+
const measured = pixelsPerUnit > 0;
|
|
1834
|
+
setStyle(node, "inline-size", measured ? `${length * pixelsPerUnit}px` : "");
|
|
1835
|
+
setStyle(node, "margin-inline-start", measured && start !== end ? `${(start - end) * pixelsPerUnit}px` : "");
|
|
1836
|
+
setStyle(node, "translate", clip && move?.key === clip.key ? `${move.by * pixelsPerUnit * (rtl ? -1 : 1)}px ${move.down}px` : "");
|
|
1837
|
+
end = start + length;
|
|
1530
1838
|
}
|
|
1531
1839
|
};
|
|
1532
1840
|
useEffect(() => {
|
|
@@ -1534,7 +1842,7 @@ var TimelineClips = /* @__PURE__ */ forwardRef(function TimelineClips({ label, c
|
|
|
1534
1842
|
if (!was) return;
|
|
1535
1843
|
if (clips.some((clip) => clip.key === was.key)) {
|
|
1536
1844
|
const active = document.activeElement;
|
|
1537
|
-
if (moved.current && (!active || active === document.body))
|
|
1845
|
+
if (moved.current && (!active || active === document.body)) focusQuietly(was.key);
|
|
1538
1846
|
moved.current = false;
|
|
1539
1847
|
return;
|
|
1540
1848
|
}
|
|
@@ -1542,12 +1850,120 @@ var TimelineClips = /* @__PURE__ */ forwardRef(function TimelineClips({ label, c
|
|
|
1542
1850
|
held.current = null;
|
|
1543
1851
|
const active = document.activeElement;
|
|
1544
1852
|
if (active && active !== document.body) return;
|
|
1853
|
+
if (laneId !== void 0 && context?.focusOnAnotherLane(laneId, was.key)) return;
|
|
1545
1854
|
const next = clips[Math.min(was.index, clips.length - 1)];
|
|
1546
1855
|
if (next) focusClip(next.key);
|
|
1547
1856
|
else context?.track.current?.querySelector(".hm-timeline-playhead-slider")?.focus();
|
|
1548
1857
|
});
|
|
1549
1858
|
const dragging = useRef(null);
|
|
1859
|
+
const movingWith = (key) => {
|
|
1860
|
+
if (!selected.has(key)) return [key];
|
|
1861
|
+
const own = new Set(clips.map((clip) => clip.key));
|
|
1862
|
+
return [...clips.filter((clip) => selected.has(clip.key)).map((clip) => clip.key), ...selectedKeys.filter((other) => !own.has(other))];
|
|
1863
|
+
};
|
|
1864
|
+
const moving = useRef(null);
|
|
1865
|
+
const dragged = useRef(false);
|
|
1866
|
+
const follow = () => {
|
|
1867
|
+
const at = moving.current;
|
|
1868
|
+
const scale = context?.scale;
|
|
1869
|
+
if (!at || !scale || !list.current) return;
|
|
1870
|
+
let start = Math.max(0, at.start + scale.unitAt(at.lastX) - at.unit);
|
|
1871
|
+
if (!at.alt) {
|
|
1872
|
+
const own = [at.start, at.start + at.length];
|
|
1873
|
+
const byStart = (context?.snapExcept(start, own) ?? start) - start;
|
|
1874
|
+
const end = start + at.length;
|
|
1875
|
+
const byEnd = (context?.snapExcept(end, own) ?? end) - end;
|
|
1876
|
+
start = Math.max(0, start + (byStart !== 0 && (byEnd === 0 || Math.abs(byStart) <= Math.abs(byEnd)) ? byStart : byEnd));
|
|
1877
|
+
}
|
|
1878
|
+
const by = start - at.start;
|
|
1879
|
+
let lane;
|
|
1880
|
+
let down = 0;
|
|
1881
|
+
const ownLane = list.current.closest("[data-hm-lane]");
|
|
1882
|
+
if (ownLane) for (const other of context?.track.current?.querySelectorAll(":scope > [data-hm-lane]") ?? []) {
|
|
1883
|
+
const box = other.getBoundingClientRect();
|
|
1884
|
+
if (at.lastY >= box.top && at.lastY < box.bottom && other !== ownLane) {
|
|
1885
|
+
lane = other.dataset["hmLane"];
|
|
1886
|
+
down = box.top - ownLane.getBoundingClientRect().top;
|
|
1887
|
+
}
|
|
1888
|
+
}
|
|
1889
|
+
const refused = canDrop ? !canDrop(at.keys, {
|
|
1890
|
+
by,
|
|
1891
|
+
lane
|
|
1892
|
+
}) : false;
|
|
1893
|
+
at.by = by;
|
|
1894
|
+
at.lane = lane;
|
|
1895
|
+
at.refused = refused;
|
|
1896
|
+
setMove((current) => current && current.by === by && current.lane === lane && current.down === down && current.refused === refused ? current : {
|
|
1897
|
+
key: at.key,
|
|
1898
|
+
by,
|
|
1899
|
+
lane,
|
|
1900
|
+
down,
|
|
1901
|
+
refused
|
|
1902
|
+
});
|
|
1903
|
+
};
|
|
1904
|
+
const scrollAtEdges = () => {
|
|
1905
|
+
const at = moving.current;
|
|
1906
|
+
const viewport = context?.viewport.current;
|
|
1907
|
+
if (!at?.started || !viewport) return;
|
|
1908
|
+
const box = viewport.getBoundingClientRect();
|
|
1909
|
+
const header = context?.headerWidth ?? 0;
|
|
1910
|
+
const rtl = getComputedStyle(viewport).direction === "rtl";
|
|
1911
|
+
const left = box.left + (rtl ? 0 : header);
|
|
1912
|
+
const right = box.right - (rtl ? header : 0);
|
|
1913
|
+
const step = at.lastX < left + EDGE ? -12 : at.lastX > right - EDGE ? SCROLL : 0;
|
|
1914
|
+
if (step !== 0) {
|
|
1915
|
+
const before = viewport.scrollLeft;
|
|
1916
|
+
viewport.scrollLeft += step;
|
|
1917
|
+
if (viewport.scrollLeft !== before) follow();
|
|
1918
|
+
}
|
|
1919
|
+
at.frame = requestAnimationFrame(scrollAtEdges);
|
|
1920
|
+
};
|
|
1921
|
+
const endMove = (commit) => {
|
|
1922
|
+
const at = moving.current;
|
|
1923
|
+
moving.current = null;
|
|
1924
|
+
if (!at) return;
|
|
1925
|
+
cancelAnimationFrame(at.frame);
|
|
1926
|
+
if (!at.started) return;
|
|
1927
|
+
dragged.current = true;
|
|
1928
|
+
setMove(null);
|
|
1929
|
+
if (commit && !at.refused && (at.by !== 0 || at.lane !== void 0)) {
|
|
1930
|
+
held.current ??= {
|
|
1931
|
+
key: at.key,
|
|
1932
|
+
index: clips.findIndex((clip) => clip.key === at.key)
|
|
1933
|
+
};
|
|
1934
|
+
moved.current = true;
|
|
1935
|
+
onDrop?.(at.keys, {
|
|
1936
|
+
by: at.by,
|
|
1937
|
+
lane: at.lane
|
|
1938
|
+
});
|
|
1939
|
+
}
|
|
1940
|
+
};
|
|
1550
1941
|
const handlePointerDown = (event) => {
|
|
1942
|
+
const pressed = event.target.closest("[data-hm-key]");
|
|
1943
|
+
const pressedClip = clips.find((clip) => clip.key === pressed?.dataset["hmKey"]);
|
|
1944
|
+
if (onDrop && pressed && pressedClip && event.button === 0 && event.pointerType !== "touch" && pixelsPerUnit > 0 && !event.target.closest("[data-hm-edge]") && (moveHandle === "clip" || event.target.closest(".hm-timeline-clip-content") !== null)) {
|
|
1945
|
+
const index = clips.indexOf(pressedClip);
|
|
1946
|
+
moving.current = {
|
|
1947
|
+
pointerId: event.pointerId,
|
|
1948
|
+
element: pressed,
|
|
1949
|
+
key: pressedClip.key,
|
|
1950
|
+
keys: movingWith(pressedClip.key),
|
|
1951
|
+
x: event.clientX,
|
|
1952
|
+
y: event.clientY,
|
|
1953
|
+
unit: context?.scale.unitAt(event.clientX) ?? 0,
|
|
1954
|
+
start: starts[index] ?? 0,
|
|
1955
|
+
length: pressedClip.length,
|
|
1956
|
+
started: false,
|
|
1957
|
+
lastX: event.clientX,
|
|
1958
|
+
lastY: event.clientY,
|
|
1959
|
+
alt: event.altKey,
|
|
1960
|
+
by: 0,
|
|
1961
|
+
lane: void 0,
|
|
1962
|
+
refused: false,
|
|
1963
|
+
frame: 0
|
|
1964
|
+
};
|
|
1965
|
+
return;
|
|
1966
|
+
}
|
|
1551
1967
|
const handle = event.target.closest("[data-hm-edge]");
|
|
1552
1968
|
const key = handle?.closest("[data-hm-key]")?.dataset["hmKey"];
|
|
1553
1969
|
const index = clips.findIndex((clip) => clip.key === key);
|
|
@@ -1560,7 +1976,7 @@ var TimelineClips = /* @__PURE__ */ forwardRef(function TimelineClips({ label, c
|
|
|
1560
1976
|
x: event.clientX,
|
|
1561
1977
|
key: clip.key,
|
|
1562
1978
|
edge,
|
|
1563
|
-
boundary:
|
|
1979
|
+
boundary: (starts[index] ?? 0) + (edge === "start" ? 0 : clip.length),
|
|
1564
1980
|
min: Math.max(limits?.min ?? Number.NEGATIVE_INFINITY, 1 - clip.length),
|
|
1565
1981
|
max: limits?.max ?? Number.POSITIVE_INFINITY,
|
|
1566
1982
|
delta: 0
|
|
@@ -1575,6 +1991,22 @@ var TimelineClips = /* @__PURE__ */ forwardRef(function TimelineClips({ label, c
|
|
|
1575
1991
|
});
|
|
1576
1992
|
};
|
|
1577
1993
|
const handlePointerMove = (event) => {
|
|
1994
|
+
const at = moving.current;
|
|
1995
|
+
if (at && event.pointerId === at.pointerId) {
|
|
1996
|
+
at.lastX = event.clientX;
|
|
1997
|
+
at.lastY = event.clientY;
|
|
1998
|
+
at.alt = event.altKey;
|
|
1999
|
+
if (!at.started) {
|
|
2000
|
+
if (Math.hypot(event.clientX - at.x, event.clientY - at.y) < DRAG_AFTER) return;
|
|
2001
|
+
at.started = true;
|
|
2002
|
+
try {
|
|
2003
|
+
at.element.setPointerCapture(event.pointerId);
|
|
2004
|
+
} catch {}
|
|
2005
|
+
at.frame = requestAnimationFrame(scrollAtEdges);
|
|
2006
|
+
}
|
|
2007
|
+
follow();
|
|
2008
|
+
return;
|
|
2009
|
+
}
|
|
1578
2010
|
const start = dragging.current;
|
|
1579
2011
|
if (!start || event.pointerId !== start.pointerId || pixelsPerUnit <= 0) return;
|
|
1580
2012
|
const along = getComputedStyle(event.currentTarget).direction === "rtl" ? start.x - event.clientX : event.clientX - start.x;
|
|
@@ -1594,7 +2026,7 @@ var TimelineClips = /* @__PURE__ */ forwardRef(function TimelineClips({ label, c
|
|
|
1594
2026
|
setDrag(null);
|
|
1595
2027
|
if (commit && start && start.delta !== 0) onTrim?.(start.key, start.edge, start.delta);
|
|
1596
2028
|
};
|
|
1597
|
-
const isDragging = drag !== null;
|
|
2029
|
+
const isDragging = drag !== null || move !== null;
|
|
1598
2030
|
useEffect(() => {
|
|
1599
2031
|
if (!isDragging) return;
|
|
1600
2032
|
const onKeyDown = (event) => {
|
|
@@ -1602,14 +2034,22 @@ var TimelineClips = /* @__PURE__ */ forwardRef(function TimelineClips({ label, c
|
|
|
1602
2034
|
event.preventDefault();
|
|
1603
2035
|
dragging.current = null;
|
|
1604
2036
|
setDrag(null);
|
|
2037
|
+
if (moving.current) {
|
|
2038
|
+
cancelAnimationFrame(moving.current.frame);
|
|
2039
|
+
moving.current = null;
|
|
2040
|
+
dragged.current = true;
|
|
2041
|
+
setMove(null);
|
|
2042
|
+
}
|
|
1605
2043
|
}
|
|
1606
2044
|
};
|
|
1607
2045
|
document.addEventListener("keydown", onKeyDown, true);
|
|
1608
2046
|
return () => document.removeEventListener("keydown", onKeyDown, true);
|
|
1609
2047
|
}, [isDragging]);
|
|
1610
|
-
const select = (keys) => {
|
|
2048
|
+
const select = (keys, keepOthers = false) => {
|
|
1611
2049
|
const wanted = new Set(keys);
|
|
2050
|
+
const own = new Set(clips.map((clip) => clip.key));
|
|
1612
2051
|
const next = clips.filter((clip) => wanted.has(clip.key)).map((clip) => clip.key);
|
|
2052
|
+
if (keepOthers) next.push(...selectedKeys.filter((key) => !own.has(key)));
|
|
1613
2053
|
if (next.length !== selectedKeys.length || next.some((key, i) => key !== selectedKeys[i])) onSelectedKeysChange(next);
|
|
1614
2054
|
};
|
|
1615
2055
|
const range = (to) => {
|
|
@@ -1620,7 +2060,7 @@ var TimelineClips = /* @__PURE__ */ forwardRef(function TimelineClips({ label, c
|
|
|
1620
2060
|
const next = new Set(selected);
|
|
1621
2061
|
if (!next.delete(key)) next.add(key);
|
|
1622
2062
|
anchor.current = key;
|
|
1623
|
-
select(next);
|
|
2063
|
+
select(next, true);
|
|
1624
2064
|
};
|
|
1625
2065
|
const handleKeyDown = (event) => {
|
|
1626
2066
|
if (event.defaultPrevented || event.nativeEvent.isComposing) return;
|
|
@@ -1639,7 +2079,13 @@ var TimelineClips = /* @__PURE__ */ forwardRef(function TimelineClips({ label, c
|
|
|
1639
2079
|
event.preventDefault();
|
|
1640
2080
|
if (onMove) {
|
|
1641
2081
|
moved.current = true;
|
|
1642
|
-
onMove(
|
|
2082
|
+
onMove(movingWith(current.key), event.key === forward ? 1 : -1);
|
|
2083
|
+
}
|
|
2084
|
+
} else if ((event.key === "ArrowUp" || event.key === "ArrowDown") && !event.shiftKey && laneId !== void 0) {
|
|
2085
|
+
event.preventDefault();
|
|
2086
|
+
if (onMoveLane) {
|
|
2087
|
+
moved.current = true;
|
|
2088
|
+
onMoveLane(movingWith(current.key), event.key === "ArrowDown" ? 1 : -1);
|
|
1643
2089
|
}
|
|
1644
2090
|
} else if (edge && onTrim) {
|
|
1645
2091
|
event.preventDefault();
|
|
@@ -1654,6 +2100,13 @@ var TimelineClips = /* @__PURE__ */ forwardRef(function TimelineClips({ label, c
|
|
|
1654
2100
|
}
|
|
1655
2101
|
return;
|
|
1656
2102
|
}
|
|
2103
|
+
if ((event.key === "ArrowUp" || event.key === "ArrowDown") && laneId !== void 0) {
|
|
2104
|
+
if (event.shiftKey || (context?.lanes.length ?? 0) < 2) return;
|
|
2105
|
+
event.preventDefault();
|
|
2106
|
+
const middle = (starts[index] ?? 0) + current.length / 2;
|
|
2107
|
+
context?.nextLaneClips(laneId, event.key === "ArrowDown" ? 1 : -1)?.focusNearest(middle, !mod);
|
|
2108
|
+
return;
|
|
2109
|
+
}
|
|
1657
2110
|
let to;
|
|
1658
2111
|
if (event.key === forward) to = Math.min(index + 1, clips.length - 1);
|
|
1659
2112
|
else if (event.key === backward) to = Math.max(index - 1, 0);
|
|
@@ -1663,8 +2116,8 @@ var TimelineClips = /* @__PURE__ */ forwardRef(function TimelineClips({ label, c
|
|
|
1663
2116
|
if (to !== void 0 && target) {
|
|
1664
2117
|
if (event.shiftKey && (mod || !multiple)) return;
|
|
1665
2118
|
event.preventDefault();
|
|
1666
|
-
|
|
1667
|
-
if (event.shiftKey) select(range(to));
|
|
2119
|
+
focusQuietly(target.key);
|
|
2120
|
+
if (event.shiftKey) select(range(to), true);
|
|
1668
2121
|
else if (!mod) {
|
|
1669
2122
|
anchor.current = target.key;
|
|
1670
2123
|
select([target.key]);
|
|
@@ -1674,7 +2127,7 @@ var TimelineClips = /* @__PURE__ */ forwardRef(function TimelineClips({ label, c
|
|
|
1674
2127
|
if (event.key === " " || event.key === "Enter" && !mod && !event.shiftKey) {
|
|
1675
2128
|
event.preventDefault();
|
|
1676
2129
|
if (!multiple) select([current.key]);
|
|
1677
|
-
else if (event.shiftKey) select(range(index));
|
|
2130
|
+
else if (event.shiftKey) select(range(index), true);
|
|
1678
2131
|
else if (event.key === " ") toggle(current.key);
|
|
1679
2132
|
else {
|
|
1680
2133
|
anchor.current = current.key;
|
|
@@ -1682,15 +2135,19 @@ var TimelineClips = /* @__PURE__ */ forwardRef(function TimelineClips({ label, c
|
|
|
1682
2135
|
}
|
|
1683
2136
|
} else if (multiple && mod && !event.shiftKey && event.key.toLowerCase() === "a") {
|
|
1684
2137
|
event.preventDefault();
|
|
1685
|
-
select(clips.map((clip) => clip.key));
|
|
2138
|
+
select(clips.map((clip) => clip.key), true);
|
|
1686
2139
|
}
|
|
1687
2140
|
};
|
|
1688
2141
|
const handleClick = (event) => {
|
|
1689
2142
|
const key = event.target.closest("[data-hm-key]")?.dataset["hmKey"];
|
|
1690
2143
|
const index = clips.findIndex((clip) => clip.key === key);
|
|
1691
2144
|
if (key === void 0 || index === -1 || event.defaultPrevented) return;
|
|
2145
|
+
if (dragged.current) {
|
|
2146
|
+
dragged.current = false;
|
|
2147
|
+
return;
|
|
2148
|
+
}
|
|
1692
2149
|
setFocusKey(key);
|
|
1693
|
-
if (multiple && event.shiftKey) select(range(index));
|
|
2150
|
+
if (multiple && event.shiftKey) select(range(index), true);
|
|
1694
2151
|
else if (multiple && (event.ctrlKey || event.metaKey)) toggle(key);
|
|
1695
2152
|
else {
|
|
1696
2153
|
anchor.current = key;
|
|
@@ -1707,6 +2164,10 @@ var TimelineClips = /* @__PURE__ */ forwardRef(function TimelineClips({ label, c
|
|
|
1707
2164
|
};
|
|
1708
2165
|
setFocusKey(key);
|
|
1709
2166
|
anchor.current ??= key;
|
|
2167
|
+
if (!multiple && !quiet.current && !(selectedKeys.length === 1 && selectedKeys[0] === key)) {
|
|
2168
|
+
anchor.current = key;
|
|
2169
|
+
select([key]);
|
|
2170
|
+
}
|
|
1710
2171
|
}
|
|
1711
2172
|
};
|
|
1712
2173
|
const handleBlur = (event) => {
|
|
@@ -1733,25 +2194,133 @@ var TimelineClips = /* @__PURE__ */ forwardRef(function TimelineClips({ label, c
|
|
|
1733
2194
|
className: cx("hm-timeline-clips", classNames?.root, className),
|
|
1734
2195
|
"data-hm-unstyled": unstyledAttribute(unstyled),
|
|
1735
2196
|
"data-hm-measured": pixelsPerUnit > 0 ? "" : void 0,
|
|
2197
|
+
"data-hm-move-handle": onDrop ? moveHandle : void 0,
|
|
1736
2198
|
onKeyDown: handleKeyDown,
|
|
1737
2199
|
onClick: handleClick,
|
|
1738
2200
|
onPointerDown: handlePointerDown,
|
|
1739
2201
|
onPointerMove: handlePointerMove,
|
|
1740
|
-
onPointerUp: () =>
|
|
1741
|
-
|
|
2202
|
+
onPointerUp: () => {
|
|
2203
|
+
endDrag(true);
|
|
2204
|
+
endMove(true);
|
|
2205
|
+
},
|
|
2206
|
+
onPointerCancel: () => {
|
|
2207
|
+
endDrag(false);
|
|
2208
|
+
endMove(false);
|
|
2209
|
+
},
|
|
1742
2210
|
onFocus: handleFocus,
|
|
1743
2211
|
onBlur: handleBlur,
|
|
1744
|
-
children: clips.map((clip) => /* @__PURE__ */ jsx(Clip, {
|
|
2212
|
+
children: clips.map((clip, index) => /* @__PURE__ */ jsx(Clip, {
|
|
1745
2213
|
clip,
|
|
1746
2214
|
selected: selected.has(clip.key),
|
|
1747
2215
|
tabStop: clip === tabStop,
|
|
1748
2216
|
clipClass,
|
|
1749
2217
|
contentClass,
|
|
1750
2218
|
edges: onTrim !== void 0,
|
|
1751
|
-
dragging: drag?.key === clip.key ? drag.edge : void 0
|
|
2219
|
+
dragging: drag?.key === clip.key ? drag.edge : void 0,
|
|
2220
|
+
pastEnd: (starts[index] ?? 0) + clip.length > timelineLength,
|
|
2221
|
+
moving: move?.key === clip.key ? move.refused ? "refused" : "allowed" : void 0
|
|
1752
2222
|
}, clip.key))
|
|
1753
2223
|
});
|
|
1754
2224
|
});
|
|
2225
|
+
// src/components/toolbar/Toolbar.tsx
|
|
2226
|
+
function useMergedRef(forwarded) {
|
|
2227
|
+
const local = useRef(null);
|
|
2228
|
+
return [local, useCallback((node) => {
|
|
2229
|
+
local.current = node;
|
|
2230
|
+
if (typeof forwarded === "function") forwarded(node);
|
|
2231
|
+
else if (forwarded) forwarded.current = node;
|
|
2232
|
+
}, [forwarded])];
|
|
2233
|
+
}
|
|
2234
|
+
var Toolbar = /* @__PURE__ */ forwardRef(function Toolbar({ label, orientation = "horizontal", className, classNames, unstyled, onKeyDown, onFocus, children, ...props }, forwardedRef) {
|
|
2235
|
+
const [ref, setRef] = useMergedRef(forwardedRef);
|
|
2236
|
+
useEffect(() => {
|
|
2237
|
+
const toolbar = ref.current;
|
|
2238
|
+
if (!toolbar) return;
|
|
2239
|
+
syncTabStop$1(toolbar);
|
|
2240
|
+
const observer = new MutationObserver(() => syncTabStop$1(toolbar, document.activeElement));
|
|
2241
|
+
observer.observe(toolbar, {
|
|
2242
|
+
childList: true,
|
|
2243
|
+
subtree: true,
|
|
2244
|
+
attributes: true,
|
|
2245
|
+
attributeFilter: ["disabled", "hidden"]
|
|
2246
|
+
});
|
|
2247
|
+
return () => observer.disconnect();
|
|
2248
|
+
}, [ref]);
|
|
2249
|
+
const handleKeyDown = (event) => {
|
|
2250
|
+
onKeyDown?.(event);
|
|
2251
|
+
if (!event.defaultPrevented && ref.current && moveFocus(ref.current, event, orientation)) event.preventDefault();
|
|
2252
|
+
};
|
|
2253
|
+
const handleFocus = (event) => {
|
|
2254
|
+
onFocus?.(event);
|
|
2255
|
+
if (ref.current && event.target !== ref.current) syncTabStop$1(ref.current, event.target);
|
|
2256
|
+
};
|
|
2257
|
+
return /* @__PURE__ */ jsx(ToolbarContext.Provider, {
|
|
2258
|
+
value: { orientation },
|
|
2259
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
2260
|
+
...props,
|
|
2261
|
+
ref: setRef,
|
|
2262
|
+
role: "toolbar",
|
|
2263
|
+
"aria-label": label,
|
|
2264
|
+
"aria-orientation": orientation,
|
|
2265
|
+
className: cx("hm-toolbar", orientation === "vertical" && "hm-toolbar--vertical", classNames?.root, className),
|
|
2266
|
+
"data-hm-unstyled": unstyledAttribute(unstyled),
|
|
2267
|
+
onKeyDown: handleKeyDown,
|
|
2268
|
+
onFocus: handleFocus,
|
|
2269
|
+
children
|
|
2270
|
+
})
|
|
2271
|
+
});
|
|
2272
|
+
});
|
|
2273
|
+
// src/components/timeline/TimelineLane.tsx
|
|
2274
|
+
var TimelineLane = /* @__PURE__ */ forwardRef(function TimelineLane({ id, label, header, className, classNames, unstyled, children, ...props }, ref) {
|
|
2275
|
+
const context = useTimelineContext("TimelineLane");
|
|
2276
|
+
useContext(TimelineLaneContext);
|
|
2277
|
+
const toolbar = useRef(null);
|
|
2278
|
+
const index = context?.lanes.indexOf(id) ?? -1;
|
|
2279
|
+
const column = context?.headerWidth ?? 0;
|
|
2280
|
+
const trail = context?.trail ?? 0;
|
|
2281
|
+
const setLane = context?.setLane;
|
|
2282
|
+
const hasHeader = header != null && header !== false;
|
|
2283
|
+
useEffect(() => () => setLane?.(id, null), [id, setLane]);
|
|
2284
|
+
return /* @__PURE__ */ jsx("div", {
|
|
2285
|
+
...props,
|
|
2286
|
+
ref: (node) => {
|
|
2287
|
+
if (node) {
|
|
2288
|
+
setStyle(node, "grid-row", index >= 0 ? String(index + 2) : "");
|
|
2289
|
+
setStyle(node, "margin-inline-start", column > 0 ? `${-(column + trail)}px` : "");
|
|
2290
|
+
setLane?.(id, {
|
|
2291
|
+
element: node,
|
|
2292
|
+
toolbar: toolbar.current
|
|
2293
|
+
});
|
|
2294
|
+
}
|
|
2295
|
+
if (typeof ref === "function") ref(node);
|
|
2296
|
+
else if (ref) ref.current = node;
|
|
2297
|
+
},
|
|
2298
|
+
role: "group",
|
|
2299
|
+
"aria-label": label,
|
|
2300
|
+
"data-hm-lane": id,
|
|
2301
|
+
className: cx("hm-timeline-lane", classNames?.root, className),
|
|
2302
|
+
"data-hm-unstyled": unstyledAttribute(unstyled),
|
|
2303
|
+
children: /* @__PURE__ */ jsxs(TimelineLaneContext.Provider, {
|
|
2304
|
+
value: id,
|
|
2305
|
+
children: [hasHeader ? /* @__PURE__ */ jsx("div", {
|
|
2306
|
+
className: cx("hm-timeline-lane-header", classNames?.header),
|
|
2307
|
+
ref: (node) => {
|
|
2308
|
+
if (node) {
|
|
2309
|
+
setStyle(node, "inline-size", column > 0 ? `${column}px` : "");
|
|
2310
|
+
setStyle(node, "margin-inline-end", column > 0 ? `${trail}px` : "");
|
|
2311
|
+
setStyle(node, "inset-inline-start", column > 0 ? `${-(column + trail)}px` : "");
|
|
2312
|
+
}
|
|
2313
|
+
},
|
|
2314
|
+
children: /* @__PURE__ */ jsx(Toolbar, {
|
|
2315
|
+
ref: toolbar,
|
|
2316
|
+
label,
|
|
2317
|
+
className: "hm-timeline-lane-toolbar",
|
|
2318
|
+
children: header
|
|
2319
|
+
})
|
|
2320
|
+
}) : null, children]
|
|
2321
|
+
})
|
|
2322
|
+
});
|
|
2323
|
+
});
|
|
1755
2324
|
// src/components/timeline/TimelinePlayhead.tsx
|
|
1756
2325
|
var OWN_PRESS = "input, button, a[href], select, textarea, [role=\"option\"], [tabindex]";
|
|
1757
2326
|
var TimelinePlayhead = /* @__PURE__ */ forwardRef(function TimelinePlayhead({ label, position: rawPosition, onPositionChange, step = 1, largeStep, formatValue, seekOnPress = true, following = false, className, classNames, unstyled }, ref) {
|
|
@@ -1759,6 +2328,7 @@ var TimelinePlayhead = /* @__PURE__ */ forwardRef(function TimelinePlayhead({ la
|
|
|
1759
2328
|
const scale = context?.scale;
|
|
1760
2329
|
const length = scale?.length ?? 0;
|
|
1761
2330
|
const pixelsPerUnit = scale?.pixelsPerUnit ?? 0;
|
|
2331
|
+
const extent = scale?.extent ?? 0;
|
|
1762
2332
|
const position = Math.min(Math.max(Math.round(rawPosition) || 0, 0), length);
|
|
1763
2333
|
const latest = useRef({
|
|
1764
2334
|
position,
|
|
@@ -1771,9 +2341,11 @@ var TimelinePlayhead = /* @__PURE__ */ forwardRef(function TimelinePlayhead({ la
|
|
|
1771
2341
|
const addTargets = context?.addTargets;
|
|
1772
2342
|
useEffect(() => addTargets?.(() => [latest.current.position]), [addTargets]);
|
|
1773
2343
|
const placeLine = (element) => {
|
|
1774
|
-
element
|
|
2344
|
+
setStyle(element, "inset-inline-start", `${position * pixelsPerUnit}px`);
|
|
1775
2345
|
};
|
|
1776
2346
|
const viewport = context?.viewport;
|
|
2347
|
+
const header = context?.headerWidth ?? 0;
|
|
2348
|
+
const lanes = context?.lanes.length ?? 0;
|
|
1777
2349
|
const lastScale = useRef(0);
|
|
1778
2350
|
useEffect(() => {
|
|
1779
2351
|
const element = viewport?.current;
|
|
@@ -1783,7 +2355,7 @@ var TimelinePlayhead = /* @__PURE__ */ forwardRef(function TimelinePlayhead({ la
|
|
|
1783
2355
|
if (!element || pixelsPerUnit <= 0 || !(following || zoomed || first)) return;
|
|
1784
2356
|
const at = position * pixelsPerUnit;
|
|
1785
2357
|
const start = Math.abs(element.scrollLeft);
|
|
1786
|
-
const width = element.clientWidth;
|
|
2358
|
+
const width = element.clientWidth - header;
|
|
1787
2359
|
if (zoomed || at < start || at > start + width) {
|
|
1788
2360
|
const to = Math.max(0, at - (zoomed || first ? width / 2 : width / 10));
|
|
1789
2361
|
element.scrollLeft = getComputedStyle(element).direction === "rtl" ? -to : to;
|
|
@@ -1792,7 +2364,8 @@ var TimelinePlayhead = /* @__PURE__ */ forwardRef(function TimelinePlayhead({ la
|
|
|
1792
2364
|
viewport,
|
|
1793
2365
|
position,
|
|
1794
2366
|
pixelsPerUnit,
|
|
1795
|
-
following
|
|
2367
|
+
following,
|
|
2368
|
+
header
|
|
1796
2369
|
]);
|
|
1797
2370
|
const track = context?.track;
|
|
1798
2371
|
useEffect(() => {
|
|
@@ -1811,6 +2384,14 @@ var TimelinePlayhead = /* @__PURE__ */ forwardRef(function TimelinePlayhead({ la
|
|
|
1811
2384
|
seekOnPress
|
|
1812
2385
|
]);
|
|
1813
2386
|
return /* @__PURE__ */ jsxs("div", {
|
|
2387
|
+
ref: (node) => {
|
|
2388
|
+
if (node) {
|
|
2389
|
+
setStyle(node, "grid-row", lanes > 0 ? `1 / span ${lanes + 1}` : "");
|
|
2390
|
+
const shorter = extent > length && pixelsPerUnit > 0;
|
|
2391
|
+
setStyle(node, "justify-self", shorter ? "start" : "");
|
|
2392
|
+
setStyle(node, "inline-size", shorter ? `${length * pixelsPerUnit}px` : "");
|
|
2393
|
+
}
|
|
2394
|
+
},
|
|
1814
2395
|
className: cx("hm-timeline-playhead", classNames?.root, className),
|
|
1815
2396
|
"data-hm-unstyled": unstyledAttribute(unstyled),
|
|
1816
2397
|
children: [/* @__PURE__ */ jsx(Slider, {
|
|
@@ -1860,54 +2441,6 @@ var ToggleButton = /* @__PURE__ */ forwardRef(function ToggleButton({ pressed: c
|
|
|
1860
2441
|
onClick: handleClick
|
|
1861
2442
|
});
|
|
1862
2443
|
});
|
|
1863
|
-
// src/components/toolbar/Toolbar.tsx
|
|
1864
|
-
function useMergedRef(forwarded) {
|
|
1865
|
-
const local = useRef(null);
|
|
1866
|
-
return [local, useCallback((node) => {
|
|
1867
|
-
local.current = node;
|
|
1868
|
-
if (typeof forwarded === "function") forwarded(node);
|
|
1869
|
-
else if (forwarded) forwarded.current = node;
|
|
1870
|
-
}, [forwarded])];
|
|
1871
|
-
}
|
|
1872
|
-
var Toolbar = /* @__PURE__ */ forwardRef(function Toolbar({ label, orientation = "horizontal", className, classNames, unstyled, onKeyDown, onFocus, children, ...props }, forwardedRef) {
|
|
1873
|
-
const [ref, setRef] = useMergedRef(forwardedRef);
|
|
1874
|
-
useEffect(() => {
|
|
1875
|
-
const toolbar = ref.current;
|
|
1876
|
-
if (!toolbar) return;
|
|
1877
|
-
syncTabStop$1(toolbar);
|
|
1878
|
-
const observer = new MutationObserver(() => syncTabStop$1(toolbar, document.activeElement));
|
|
1879
|
-
observer.observe(toolbar, {
|
|
1880
|
-
childList: true,
|
|
1881
|
-
subtree: true,
|
|
1882
|
-
attributes: true,
|
|
1883
|
-
attributeFilter: ["disabled", "hidden"]
|
|
1884
|
-
});
|
|
1885
|
-
return () => observer.disconnect();
|
|
1886
|
-
}, [ref]);
|
|
1887
|
-
const handleKeyDown = (event) => {
|
|
1888
|
-
onKeyDown?.(event);
|
|
1889
|
-
if (!event.defaultPrevented && ref.current && moveFocus(ref.current, event, orientation)) event.preventDefault();
|
|
1890
|
-
};
|
|
1891
|
-
const handleFocus = (event) => {
|
|
1892
|
-
onFocus?.(event);
|
|
1893
|
-
if (ref.current && event.target !== ref.current) syncTabStop$1(ref.current, event.target);
|
|
1894
|
-
};
|
|
1895
|
-
return /* @__PURE__ */ jsx(ToolbarContext.Provider, {
|
|
1896
|
-
value: { orientation },
|
|
1897
|
-
children: /* @__PURE__ */ jsx("div", {
|
|
1898
|
-
...props,
|
|
1899
|
-
ref: setRef,
|
|
1900
|
-
role: "toolbar",
|
|
1901
|
-
"aria-label": label,
|
|
1902
|
-
"aria-orientation": orientation,
|
|
1903
|
-
className: cx("hm-toolbar", orientation === "vertical" && "hm-toolbar--vertical", classNames?.root, className),
|
|
1904
|
-
"data-hm-unstyled": unstyledAttribute(unstyled),
|
|
1905
|
-
onKeyDown: handleKeyDown,
|
|
1906
|
-
onFocus: handleFocus,
|
|
1907
|
-
children
|
|
1908
|
-
})
|
|
1909
|
-
});
|
|
1910
|
-
});
|
|
1911
2444
|
// src/components/toolbar/ToolbarGroup.tsx
|
|
1912
2445
|
var ToolbarGroup = /* @__PURE__ */ forwardRef(function ToolbarGroup({ label, className, ...props }, ref) {
|
|
1913
2446
|
return /* @__PURE__ */ jsx("div", {
|
|
@@ -2580,6 +3113,6 @@ function ThemeProvider(props) {
|
|
|
2580
3113
|
}), children]
|
|
2581
3114
|
});
|
|
2582
3115
|
}
|
|
2583
|
-
export { AddIcon, AnnouncerProvider, ArrowIcon, Button, CheckIcon, ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, CloseIcon, ColorField, CropIcon, DeleteIcon, Dialog, DownloadIcon, DuplicateIcon, EllipseIcon, FadeInIcon, FadeOutIcon, Field, FileDropZone, FitIcon, FlipHorizontalIcon, FlipVerticalIcon, HiddenIcon, HighlighterIcon, IconButton, ImageIcon, InfoIcon, LayersIcon, LoopIcon, MenuIcon, MoreIcon, MoveDownIcon, MoveUpIcon, MutedIcon, NumberField, OpenIcon, PageAddIcon, PageGridIcon, PageSingleIcon, PanIcon, PauseIcon, PenIcon, PlayIcon, ProgressBar, RectangleIcon, RedactIcon, RedoIcon, RemoveIcon, ReorderableList, ReorderableListItem, RotateLeftIcon, RotateRightIcon, SearchIcon, SegmentedControl, SelectIcon, SkipBackIcon, SkipForwardIcon, Slider, SnapIcon, Spinner, SplitIcon, StopIcon, TextArea, TextField, TextIcon, ThemeProvider, Timeline, TimelineClips, TimelineLayer, TimelinePlayhead, ToggleButton, Toolbar, ToolbarGroup, ToolbarSeparator, Tooltip, TrimEndIcon, TrimStartIcon, UiMessagesProvider, UndoIcon, UploadIcon, VisibleIcon, VisuallyHidden, VolumeIcon, WarningIcon, ZoomInIcon, ZoomOutIcon, uiMessages, useAnnounce, usePlatform, useTimelineScale, useUiMessages };
|
|
3116
|
+
export { AddIcon, AnnouncerProvider, ArrowIcon, Button, CheckIcon, ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, CloseIcon, ColorField, CropIcon, DeleteIcon, Dialog, DownloadIcon, DuplicateIcon, EllipseIcon, FadeInIcon, FadeOutIcon, Field, FileDropZone, FitIcon, FlipHorizontalIcon, FlipVerticalIcon, HiddenIcon, HighlighterIcon, IconButton, ImageIcon, InfoIcon, LayersIcon, LoopIcon, MenuIcon, MoreIcon, MoveDownIcon, MoveUpIcon, MutedIcon, NumberField, OpenIcon, PageAddIcon, PageGridIcon, PageSingleIcon, PanIcon, PauseIcon, PenIcon, PlayIcon, ProgressBar, RectangleIcon, RedactIcon, RedoIcon, RemoveIcon, ReorderableList, ReorderableListItem, RotateLeftIcon, RotateRightIcon, SearchIcon, SegmentedControl, SelectIcon, SkipBackIcon, SkipForwardIcon, Slider, SnapIcon, Spinner, SplitIcon, StopIcon, TextArea, TextField, TextIcon, ThemeProvider, Timeline, TimelineClips, TimelineLane, TimelineLayer, TimelinePlayhead, ToggleButton, Toolbar, ToolbarGroup, ToolbarSeparator, Tooltip, TrimEndIcon, TrimStartIcon, UiMessagesProvider, UndoIcon, UploadIcon, VisibleIcon, VisuallyHidden, VolumeIcon, WarningIcon, ZoomInIcon, ZoomOutIcon, uiMessages, useAnnounce, usePlatform, useTimelineLanes, useTimelineScale, useUiMessages };
|
|
2584
3117
|
|
|
2585
3118
|
//# sourceMappingURL=react.js.map
|