@zonsh/ui 0.4.1 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/accordion.js +1 -1
- package/dist/components/ascii-field.js +2 -1
- package/dist/components/bottom-nav.js +4 -4
- package/dist/components/button.js +1 -1
- package/dist/components/chart.d.ts +11 -0
- package/dist/components/chart.js +12 -0
- package/dist/components/collapsible.js +1 -1
- package/dist/components/command.js +3 -3
- package/dist/components/conversation.js +10 -3
- package/dist/components/copy-button.js +7 -5
- package/dist/components/graph.js +24 -7
- package/dist/components/illustration.js +50 -3
- package/dist/components/input-group.d.ts +2 -2
- package/dist/components/input-group.js +6 -4
- package/dist/components/input.d.ts +1 -1
- package/dist/components/input.js +1 -1
- package/dist/components/layout.d.ts +2 -1
- package/dist/components/layout.js +55 -11
- package/dist/components/lightbox.js +22 -4
- package/dist/components/menubar.js +60 -13
- package/dist/components/message.js +3 -2
- package/dist/components/navigation-menu.js +4 -2
- package/dist/components/number-field.js +26 -12
- package/dist/components/pagination.js +1 -1
- package/dist/components/prompt-input.js +14 -6
- package/dist/components/radio-group.js +7 -2
- package/dist/components/reasoning.js +1 -1
- package/dist/components/response.d.ts +3 -2
- package/dist/components/response.js +22 -10
- package/dist/components/sidebar.js +37 -18
- package/dist/components/site-header.js +6 -1
- package/dist/components/skeleton.d.ts +1 -1
- package/dist/components/skeleton.js +1 -1
- package/dist/components/sortable.js +61 -37
- package/dist/components/table.d.ts +1 -1
- package/dist/components/table.js +55 -2
- package/dist/components/tabs.js +8 -4
- package/dist/components/tags-input.js +1 -1
- package/dist/components/theme.d.ts +1 -1
- package/dist/components/theme.js +21 -3
- package/dist/components/time-field.d.ts +2 -1
- package/dist/components/time-field.js +13 -3
- package/dist/components/toggle-group.js +1 -0
- package/dist/components/tool-call.js +6 -1
- package/dist/components/toolbar.d.ts +1 -1
- package/dist/components/toolbar.js +5 -2
- package/dist/components/tooltip.d.ts +4 -2
- package/dist/components/tooltip.js +10 -4
- package/dist/components/tour.js +35 -10
- package/dist/components/tree.js +29 -6
- package/dist/components/video-player.js +61 -5
- package/dist/lib/glide.d.ts +5 -4
- package/dist/lib/glide.js +5 -4
- package/dist/lib/table-fit.d.ts +3 -2
- package/dist/lib/table-fit.js +29 -19
- package/dist/styles/expressive.css +40 -21
- package/dist/styles/index.css +8 -0
- package/dist/styles/material.css +40 -20
- package/dist/styles/parts/ai.css +2 -1
- package/dist/styles/parts/controls.css +24 -20
- package/dist/styles/parts/data.css +33 -5
- package/dist/styles/parts/feedback.css +43 -13
- package/dist/styles/parts/navigation.css +42 -9
- package/dist/styles/parts/overlays.css +93 -6
- package/dist/styles/parts/pdf.css +13 -7
- package/dist/styles/tokens.css +16 -1
- package/package.json +1 -1
package/dist/components/tour.js
CHANGED
|
@@ -40,7 +40,7 @@ const SPOTLIGHT_PADDING = 6;
|
|
|
40
40
|
/* ── Motion ────────────────────────────────────────────────────────────────── */
|
|
41
41
|
/** How long the popover and the spotlight take to move from one target to the next: 250ms, 0 under reduced motion. */
|
|
42
42
|
const glideMs = (el) => (cssDuration(el) * 5) / 3;
|
|
43
|
-
/** The brand curve as the element sees it, for scripted animations. */
|
|
43
|
+
/** The brand curve as the element sees it, for scripted animations: entering, leaving, fading. */
|
|
44
44
|
const easeOf = (el) => getComputedStyle(el).getPropertyValue("--ease").trim() || "cubic-bezier(0.16, 1, 0.3, 1)";
|
|
45
45
|
/** A CSS cubic-bezier() as a function of progress, for the spotlight drawn each frame. */
|
|
46
46
|
function bezier(css) {
|
|
@@ -311,6 +311,8 @@ export function Tour({ steps, open: openProp, defaultOpen = false, onOpenChange,
|
|
|
311
311
|
return;
|
|
312
312
|
const ms = glideMs(popup);
|
|
313
313
|
const easing = easeOf(popup);
|
|
314
|
+
// The height changes with the glide, on its curve, so the popover moves and resizes as one.
|
|
315
|
+
const move = easing;
|
|
314
316
|
const running = [];
|
|
315
317
|
const ghost = ghostRef.current;
|
|
316
318
|
if (how === "arrive") {
|
|
@@ -330,7 +332,7 @@ export function Tour({ steps, open: openProp, defaultOpen = false, onOpenChange,
|
|
|
330
332
|
if (Math.abs(height - from.height) > 0.5)
|
|
331
333
|
running.push(popup.animate([{ height: `${from.height}px` }, { height: `${height}px` }], {
|
|
332
334
|
duration: ms,
|
|
333
|
-
easing,
|
|
335
|
+
easing: move,
|
|
334
336
|
}));
|
|
335
337
|
if (ghost && from.content) {
|
|
336
338
|
// A picture of the last step, never read out or reached: no ids, nothing to focus.
|
|
@@ -575,11 +577,12 @@ const mix = (a, b, t) => ({
|
|
|
575
577
|
});
|
|
576
578
|
const round = (n) => Math.round(n * 10) / 10;
|
|
577
579
|
/**
|
|
578
|
-
* The page dimmed around the target, as the backdrop of a dialog is.
|
|
579
|
-
*
|
|
580
|
-
*
|
|
581
|
-
*
|
|
582
|
-
*
|
|
580
|
+
* The page dimmed around the target, as the backdrop of a dialog is. When the target changes, the
|
|
581
|
+
* hole moves from the last one to it on the glide's clock and curve, changing its size and its
|
|
582
|
+
* corners on the way (a step without a target closes it to the middle of the screen), drawn every
|
|
583
|
+
* frame while it moves. At rest nothing runs: it is drawn again, once in the next frame, when the
|
|
584
|
+
* page scrolls or resizes or the target or the page changes size — the events the popover follows
|
|
585
|
+
* too. The dim takes clicks; the hole lets them through to the target.
|
|
583
586
|
*/
|
|
584
587
|
function Spotlight({ anchor, closing, onClosed, }) {
|
|
585
588
|
const svgRef = React.useRef(null);
|
|
@@ -600,7 +603,9 @@ function Spotlight({ anchor, closing, onClosed, }) {
|
|
|
600
603
|
const start = performance.now();
|
|
601
604
|
let last = "";
|
|
602
605
|
let frame = 0;
|
|
606
|
+
let gliding = !!from && ms > 0;
|
|
603
607
|
const draw = (now) => {
|
|
608
|
+
frame = 0;
|
|
604
609
|
const w = window.innerWidth;
|
|
605
610
|
const h = window.innerHeight;
|
|
606
611
|
const p = SPOTLIGHT_PADDING;
|
|
@@ -611,8 +616,10 @@ function Spotlight({ anchor, closing, onClosed, }) {
|
|
|
611
616
|
}
|
|
612
617
|
else
|
|
613
618
|
to = { x: w / 2, y: h / 2, w: 0, h: 0, r: 0 };
|
|
614
|
-
const t =
|
|
619
|
+
const t = gliding ? ease((now - start) / ms) : 1;
|
|
615
620
|
const box = t < 1 && from ? mix(from, to, t) : to;
|
|
621
|
+
if (t >= 1)
|
|
622
|
+
gliding = false;
|
|
616
623
|
drawn.current = box;
|
|
617
624
|
let d = `M0 0H${w}V${h}H0Z`;
|
|
618
625
|
if (box.w >= 1 && box.h >= 1)
|
|
@@ -621,10 +628,28 @@ function Spotlight({ anchor, closing, onClosed, }) {
|
|
|
621
628
|
path.setAttribute("d", d);
|
|
622
629
|
last = d;
|
|
623
630
|
}
|
|
624
|
-
|
|
631
|
+
if (gliding)
|
|
632
|
+
frame = requestAnimationFrame(draw);
|
|
633
|
+
};
|
|
634
|
+
/** Draw again in the next frame, once however many events ask for it. */
|
|
635
|
+
const redraw = () => {
|
|
636
|
+
if (!frame)
|
|
637
|
+
frame = requestAnimationFrame(draw);
|
|
625
638
|
};
|
|
626
639
|
draw(start);
|
|
627
|
-
|
|
640
|
+
// Scrolls of any scroller (capture), the window's size, the target's and the page's.
|
|
641
|
+
window.addEventListener("scroll", redraw, { capture: true, passive: true });
|
|
642
|
+
window.addEventListener("resize", redraw);
|
|
643
|
+
const sizes = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(redraw);
|
|
644
|
+
if (anchor)
|
|
645
|
+
sizes?.observe(anchor);
|
|
646
|
+
sizes?.observe(document.documentElement);
|
|
647
|
+
return () => {
|
|
648
|
+
cancelAnimationFrame(frame);
|
|
649
|
+
window.removeEventListener("scroll", redraw, { capture: true });
|
|
650
|
+
window.removeEventListener("resize", redraw);
|
|
651
|
+
sizes?.disconnect();
|
|
652
|
+
};
|
|
628
653
|
}, [anchor]);
|
|
629
654
|
// Fading out as the tour ends, then off the page.
|
|
630
655
|
React.useEffect(() => {
|
package/dist/components/tree.js
CHANGED
|
@@ -148,7 +148,7 @@ const TreeRow = React.memo(function TreeRow({ node, level, expanded, selected, }
|
|
|
148
148
|
// Hover lifts like a highlighted menu item; the full raised row (outer edge) is the selection.
|
|
149
149
|
"hover:not-data-current:border-control-inner-edge! hover:not-data-current:bg-none! hover:not-data-current:shadow-highlight!",
|
|
150
150
|
// The treeitem holds the focus; its own row draws the ring, never the whole subtree.
|
|
151
|
-
"[li:focus-visible>&]:outline-2 [li:focus-visible>&]:outline-offset-0 [li:focus-visible>&]:outline-control-focus [li:focus-visible>&]:outline-solid", "data-disabled:cursor-default data-disabled:opacity-50", "[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", sizes[ctx.size].row), children: [branch ? (_jsx("span", { "data-slot": "tree-chevron", "aria-hidden": true, onClick: (event) => ctx.onChevronClick(node, event), className: "-my-1 flex shrink-0 items-center self-stretch text-muted-foreground", children: _jsx(ChevronRightIcon, { className: cn("transition-[rotate] duration-(--duration) ease-(--ease) rtl:-scale-x-100", expanded && "rotate-90 rtl:-rotate-90") }) })) : (_jsx("span", { "data-slot": "tree-chevron-space", "aria-hidden": true, className: "size-4 shrink-0" })), icon != null && (_jsx("span", { "data-slot": "tree-icon", "aria-hidden": true, className: cn("flex shrink-0", selected ? "text-foreground" : "text-muted-foreground"), children: icon })), _jsx("span", { "data-slot": "tree-label", className: "min-w-0 flex-1 truncate py-1 leading-5", children: node.label }), node.meta != null && (_jsx("span", { "data-slot": "tree-meta", className: "ms-auto shrink-0 ps-2 font-mono text-xs leading-none text-muted-foreground tabular-nums", children: node.meta }))] }));
|
|
151
|
+
"[li:focus-visible>&]:outline-2 [li:focus-visible>&]:outline-offset-0 [li:focus-visible>&]:outline-control-focus [li:focus-visible>&]:outline-solid", "data-disabled:cursor-default data-disabled:opacity-50", "[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", sizes[ctx.size].row), children: [branch ? (_jsx("span", { "data-slot": "tree-chevron", "aria-hidden": true, onClick: (event) => ctx.onChevronClick(node, event), className: "-my-1 flex shrink-0 items-center self-stretch text-muted-foreground", children: _jsx(ChevronRightIcon, { className: cn("transition-[rotate] duration-(--duration) ease-(--ease) group-data-instant/tree:transition-none rtl:-scale-x-100", expanded && "rotate-90 rtl:-rotate-90") }) })) : (_jsx("span", { "data-slot": "tree-chevron-space", "aria-hidden": true, className: "size-4 shrink-0" })), icon != null && (_jsx("span", { "data-slot": "tree-icon", "aria-hidden": true, className: cn("flex shrink-0", selected ? "text-foreground" : "text-muted-foreground"), children: icon })), _jsx("span", { "data-slot": "tree-label", className: "min-w-0 flex-1 truncate py-1 leading-5", children: node.label }), node.meta != null && (_jsx("span", { "data-slot": "tree-meta", className: "ms-auto shrink-0 ps-2 font-mono text-xs leading-none text-muted-foreground tabular-nums", children: node.meta }))] }));
|
|
152
152
|
});
|
|
153
153
|
/**
|
|
154
154
|
* One `treeitem`: the row, and below it — once first opened — its children in a `group`. The
|
|
@@ -173,7 +173,7 @@ function NestedTreeItem({ node, level, posinset, setsize, view }) {
|
|
|
173
173
|
expanded,
|
|
174
174
|
selected,
|
|
175
175
|
focused: view.focusId === node.id,
|
|
176
|
-
}), className: "flex flex-col outline-none", children: [_jsx(TreeRow, { node: node, level: level, expanded: expanded, selected: selected }), branch && mounted && (_jsx("div", { "data-slot": "tree-group-frame", "data-open": expanded ? "" : undefined, className: cn("grid transition-[grid-template-rows,visibility] duration-(--duration) ease-(--ease)", expanded ? "visible grid-rows-[1fr]" : "invisible grid-rows-[0fr]", expanded && mounted === "later" && "starting:grid-rows-[0fr]"), children: _jsx("ul", { role: "group", "data-slot": "tree-group", className: cn(
|
|
176
|
+
}), className: "flex flex-col outline-none", children: [_jsx(TreeRow, { node: node, level: level, expanded: expanded, selected: selected }), branch && mounted && (_jsx("div", { "data-slot": "tree-group-frame", "data-open": expanded ? "" : undefined, className: cn("grid transition-[grid-template-rows,visibility] duration-(--duration) ease-(--ease) group-data-instant/tree:transition-none", expanded ? "visible grid-rows-[1fr]" : "invisible grid-rows-[0fr]", expanded && mounted === "later" && "starting:grid-rows-[0fr]"), children: _jsx("ul", { role: "group", "data-slot": "tree-group", className: cn(
|
|
177
177
|
// Clipped for the open and close, but 2px out: the focus ring and the selection's
|
|
178
178
|
// outer edge on the group's last row and at its end stay whole. Not a scroll
|
|
179
179
|
// container, so it takes min-w-0 to let long labels truncate. The 2px above the
|
|
@@ -363,6 +363,8 @@ export function Tree({ items, size = "default", selectionMode = "single", select
|
|
|
363
363
|
const position = React.useMemo(() => new Map(order.map((id, i) => [id, i])), [order]);
|
|
364
364
|
const virtual = virtualized ?? index.size > VIRTUALIZE_FROM;
|
|
365
365
|
const tree = React.useRef(null);
|
|
366
|
+
const instantFrame = React.useRef(0);
|
|
367
|
+
React.useEffect(() => () => cancelAnimationFrame(instantFrame.current), []);
|
|
366
368
|
const treeRef = React.useMemo(() => mergeRefs(tree, ref), [ref]);
|
|
367
369
|
// Virtual rows watch the tree element, which is attached only after their own first effects
|
|
368
370
|
// have run: they get it once it is there.
|
|
@@ -520,6 +522,21 @@ export function Tree({ items, size = "default", selectionMode = "single", select
|
|
|
520
522
|
onRowClick: (node, event) => handlers.current.onRowClick(node, event),
|
|
521
523
|
onChevronClick: (node, event) => handlers.current.onChevronClick(node, event),
|
|
522
524
|
}), [size, guides, selectionMode, register]);
|
|
525
|
+
/**
|
|
526
|
+
* Opening and closing from the keyboard is instant: it is done many times in a row while
|
|
527
|
+
* walking a tree, and waiting for each fold makes the keys feel slow. The pointer keeps the
|
|
528
|
+
* fold. `data-instant` holds until the change has been drawn.
|
|
529
|
+
*/
|
|
530
|
+
const instantly = () => {
|
|
531
|
+
const el = tree.current;
|
|
532
|
+
if (!el)
|
|
533
|
+
return;
|
|
534
|
+
el.setAttribute("data-instant", "");
|
|
535
|
+
cancelAnimationFrame(instantFrame.current);
|
|
536
|
+
instantFrame.current = requestAnimationFrame(() => {
|
|
537
|
+
instantFrame.current = requestAnimationFrame(() => el.removeAttribute("data-instant"));
|
|
538
|
+
});
|
|
539
|
+
};
|
|
523
540
|
const handleKeyDown = (event) => {
|
|
524
541
|
onKeyDown?.(event);
|
|
525
542
|
if (event.defaultPrevented)
|
|
@@ -554,13 +571,17 @@ export function Tree({ items, size = "default", selectionMode = "single", select
|
|
|
554
571
|
case "ArrowLeft": {
|
|
555
572
|
const forward = (event.key === "ArrowRight") === (getComputedStyle(item).direction !== "rtl");
|
|
556
573
|
if (forward) {
|
|
557
|
-
if (node.children && !expanded.has(node.id))
|
|
574
|
+
if (node.children && !expanded.has(node.id)) {
|
|
575
|
+
instantly();
|
|
558
576
|
toggle(node, true);
|
|
577
|
+
}
|
|
559
578
|
else if (node.children?.length && expanded.has(node.id))
|
|
560
579
|
focus(node.children[0].id);
|
|
561
580
|
}
|
|
562
|
-
else if (node.children && expanded.has(node.id))
|
|
581
|
+
else if (node.children && expanded.has(node.id)) {
|
|
582
|
+
instantly();
|
|
563
583
|
toggle(node, false);
|
|
584
|
+
}
|
|
564
585
|
else
|
|
565
586
|
focus(entry.parent ?? undefined);
|
|
566
587
|
break;
|
|
@@ -599,8 +620,10 @@ export function Tree({ items, size = "default", selectionMode = "single", select
|
|
|
599
620
|
const open = siblings
|
|
600
621
|
.filter((n) => n.children && !n.disabled && !expanded.has(n.id))
|
|
601
622
|
.map((n) => n.id);
|
|
602
|
-
if (open.length)
|
|
623
|
+
if (open.length) {
|
|
624
|
+
instantly();
|
|
603
625
|
setExpanded([...expandedIds, ...open]);
|
|
626
|
+
}
|
|
604
627
|
break;
|
|
605
628
|
}
|
|
606
629
|
default: {
|
|
@@ -645,5 +668,5 @@ export function Tree({ items, size = "default", selectionMode = "single", select
|
|
|
645
668
|
if (focused.current === el && el.isConnected)
|
|
646
669
|
focused.current = null;
|
|
647
670
|
});
|
|
648
|
-
}, className: cn("m-0 w-full list-none p-0 font-body", virtual ? "block" : "flex flex-col gap-0.5", className), ...props, children: virtual ? (_jsx(TreeVirtualRows, { order: order, index: index, states: view, focusAt: focusId === null ? -1 : (position.get(focusId) ?? -1), tree: treeEl })) : (items.map((node, i) => (_jsx(TreeItem, { node: node, level: 1, posinset: i + 1, setsize: items.length, view: view }, node.id)))) }) }));
|
|
671
|
+
}, className: cn("group/tree m-0 w-full list-none p-0 font-body", virtual ? "block" : "flex flex-col gap-0.5", className), ...props, children: virtual ? (_jsx(TreeVirtualRows, { order: order, index: index, states: view, focusAt: focusId === null ? -1 : (position.get(focusId) ?? -1), tree: treeEl })) : (items.map((node, i) => (_jsx(TreeItem, { node: node, level: 1, posinset: i + 1, setsize: items.length, view: view }, node.id)))) }) }));
|
|
649
672
|
}
|
|
@@ -95,6 +95,15 @@ const MENU_CLOSE_MS = 400;
|
|
|
95
95
|
const DOUBLE_TAP_MS = 350;
|
|
96
96
|
/** A jump shows this long after the last press or tap, and jumps the same way within it add to it (ms). */
|
|
97
97
|
const JUMP_MS = 1000;
|
|
98
|
+
/**
|
|
99
|
+
* A stream that stops while it plays loads again by itself after each of these pauses in turn (ms),
|
|
100
|
+
* before the error shows: about half a minute, for a connection or a server that drops out.
|
|
101
|
+
*/
|
|
102
|
+
const RETRY_DELAYS = [1000, 3000, 8000, 15000];
|
|
103
|
+
/** Retries this long after the last one belong to a new dropout, which gets all of them again (ms). */
|
|
104
|
+
const AUTO_RETRY_MS = 60_000;
|
|
105
|
+
/** A stall this long while it should be playing counts as stopped (ms). */
|
|
106
|
+
const STALL_RETRY_MS = 15_000;
|
|
98
107
|
/** A subtitle file still on its way after this long gets a note where the subtitles show (ms). */
|
|
99
108
|
const SUBTITLE_SLOW_MS = 2000;
|
|
100
109
|
/** Asks for a subtitle file, and the pause between them (ms): cutting one out of a whole file can outlast a request. */
|
|
@@ -386,6 +395,14 @@ export function VideoPlayer({ src, versions = [], defaultAudio, defaultQuality,
|
|
|
386
395
|
const told = React.useRef("pause");
|
|
387
396
|
// A drag on the scrubber holds the playing video still until the thumb is let go: to the app it plays on.
|
|
388
397
|
const holding = React.useRef(false);
|
|
398
|
+
// How many times a stream that dropped has loaded again by itself, and when last (RETRY_DELAYS).
|
|
399
|
+
const retries = React.useRef({
|
|
400
|
+
count: 0,
|
|
401
|
+
at: -Infinity,
|
|
402
|
+
timer: undefined,
|
|
403
|
+
});
|
|
404
|
+
// The latest `retry`, for the video's events (set up once) to call; false where it didn't.
|
|
405
|
+
const autoRetry = React.useRef(() => false);
|
|
389
406
|
// The video can't be played. The controls go, with their menus and without a pointer leaving or a
|
|
390
407
|
// blur: what held them up (an open menu, the pointer, focus) would otherwise hold them up for good.
|
|
391
408
|
const fail = () => {
|
|
@@ -401,6 +418,7 @@ export function VideoPlayer({ src, versions = [], defaultAudio, defaultQuality,
|
|
|
401
418
|
return;
|
|
402
419
|
let frame = 0;
|
|
403
420
|
let shownAt = -1;
|
|
421
|
+
let stalled;
|
|
404
422
|
// Each frame would redraw the scrubber sixty times a second; the eye needs far fewer.
|
|
405
423
|
const show = () => {
|
|
406
424
|
const now = el.currentTime;
|
|
@@ -473,9 +491,22 @@ export function VideoPlayer({ src, versions = [], defaultAudio, defaultQuality,
|
|
|
473
491
|
callbacks.current.onPause?.();
|
|
474
492
|
},
|
|
475
493
|
seeked: () => playhead.set({ time: el.currentTime, buffered: bufferedEnd(el) }),
|
|
476
|
-
waiting: () =>
|
|
477
|
-
|
|
478
|
-
|
|
494
|
+
waiting: () => {
|
|
495
|
+
setWaiting(true);
|
|
496
|
+
clearTimeout(stalled);
|
|
497
|
+
stalled = setTimeout(() => {
|
|
498
|
+
if (!el.paused && el.readyState < HTMLMediaElement.HAVE_FUTURE_DATA)
|
|
499
|
+
autoRetry.current();
|
|
500
|
+
}, STALL_RETRY_MS);
|
|
501
|
+
},
|
|
502
|
+
playing: () => {
|
|
503
|
+
setWaiting(false);
|
|
504
|
+
clearTimeout(stalled);
|
|
505
|
+
},
|
|
506
|
+
canplay: () => {
|
|
507
|
+
setWaiting(false);
|
|
508
|
+
clearTimeout(stalled);
|
|
509
|
+
},
|
|
479
510
|
ended: () => {
|
|
480
511
|
setPlaying(false);
|
|
481
512
|
setEnded(true);
|
|
@@ -486,7 +517,10 @@ export function VideoPlayer({ src, versions = [], defaultAudio, defaultQuality,
|
|
|
486
517
|
callbacks.current.onEnded?.();
|
|
487
518
|
},
|
|
488
519
|
// A `src` that fails; one of several `<source>`s tells its own element (below).
|
|
489
|
-
error:
|
|
520
|
+
error: () => {
|
|
521
|
+
if (!autoRetry.current())
|
|
522
|
+
fail();
|
|
523
|
+
},
|
|
490
524
|
enterpictureinpicture: () => setInPip(true),
|
|
491
525
|
leavepictureinpicture: () => setInPip(false),
|
|
492
526
|
};
|
|
@@ -497,6 +531,7 @@ export function VideoPlayer({ src, versions = [], defaultAudio, defaultQuality,
|
|
|
497
531
|
sync();
|
|
498
532
|
return () => {
|
|
499
533
|
cancelAnimationFrame(frame);
|
|
534
|
+
clearTimeout(stalled);
|
|
500
535
|
for (const [type, handler] of Object.entries(handlers))
|
|
501
536
|
el.removeEventListener(type, handler);
|
|
502
537
|
};
|
|
@@ -867,10 +902,31 @@ export function VideoPlayer({ src, versions = [], defaultAudio, defaultQuality,
|
|
|
867
902
|
const el = video.current;
|
|
868
903
|
if (!el)
|
|
869
904
|
return;
|
|
870
|
-
|
|
905
|
+
// After a reload that failed too, the place it stopped is still the one to go back to.
|
|
906
|
+
resume.current = { time: el.currentTime || resume.current?.time || startOf, play: true };
|
|
871
907
|
setFailed(false);
|
|
872
908
|
el.load();
|
|
873
909
|
};
|
|
910
|
+
// A stream that dropped while it played (the connection, a server that fell behind) gets one more
|
|
911
|
+
// go by itself, from where it stopped, before the error shows: what "Try again" does. Not at the
|
|
912
|
+
// start, which says the video can't play, and not a stream the app feeds in itself (a blob:).
|
|
913
|
+
autoRetry.current = () => {
|
|
914
|
+
const el = video.current;
|
|
915
|
+
const r = retries.current;
|
|
916
|
+
if (!el || !(el.currentTime || resume.current?.time) || el.currentSrc.startsWith("blob:"))
|
|
917
|
+
return false;
|
|
918
|
+
if (performance.now() - r.at > AUTO_RETRY_MS)
|
|
919
|
+
r.count = 0;
|
|
920
|
+
if (r.count >= RETRY_DELAYS.length)
|
|
921
|
+
return false;
|
|
922
|
+
r.at = performance.now();
|
|
923
|
+
clearTimeout(r.timer);
|
|
924
|
+
// The spinner meanwhile, not the error.
|
|
925
|
+
setWaiting(true);
|
|
926
|
+
r.timer = setTimeout(retry, RETRY_DELAYS[r.count++]);
|
|
927
|
+
return true;
|
|
928
|
+
};
|
|
929
|
+
React.useEffect(() => () => clearTimeout(retries.current.timer), []);
|
|
874
930
|
const nextQuality = qualities[qualities.indexOf(version?.quality ?? "") + 1];
|
|
875
931
|
const togglePip = () => {
|
|
876
932
|
const v = video.current;
|
package/dist/lib/glide.d.ts
CHANGED
|
@@ -44,10 +44,11 @@ export declare function useGlide(container: React.RefObject<HTMLElement | null>,
|
|
|
44
44
|
/** Inline style that places an absolutely positioned indicator over the glide target. */
|
|
45
45
|
export declare function glideStyle({ rect }: Glide): React.CSSProperties | undefined;
|
|
46
46
|
/**
|
|
47
|
-
* The indicator's motion: translate and size in
|
|
48
|
-
* --duration. Put `data-instant` on it while
|
|
49
|
-
* Reduced motion sets --duration to 0, so it
|
|
47
|
+
* The indicator's motion: translate and size in --duration-glide on --ease-glide, the one speed and
|
|
48
|
+
* curve of every gliding indicator; opacity in --duration-fade. Put `data-instant` on it while
|
|
49
|
+
* `glide.instant`, `data-visible` while visible. Reduced motion sets --duration-glide to 0, so it
|
|
50
|
+
* moves instantly and only fades.
|
|
50
51
|
*/
|
|
51
|
-
export declare const glideMotion = "pointer-events-none absolute top-0 left-0 opacity-0 data-visible:opacity-100 transition-[translate,width,height,opacity]
|
|
52
|
+
export declare const glideMotion = "pointer-events-none absolute top-0 left-0 opacity-0 data-visible:opacity-100 transition-[translate,width,height,opacity] ease-(--ease-glide) [transition-duration:var(--duration-glide),var(--duration-glide),var(--duration-glide),var(--duration-fade)] data-instant:transition-none";
|
|
52
53
|
/** Merges a component's own ref with the one passed in by the caller. */
|
|
53
54
|
export declare function useMergedRef<T>(ref: React.Ref<T> | undefined): [React.RefObject<T | null>, (node: T | null) => void];
|
package/dist/lib/glide.js
CHANGED
|
@@ -119,11 +119,12 @@ export function glideStyle({ rect }) {
|
|
|
119
119
|
return rect ? { translate: `${rect.x}px ${rect.y}px`, width: rect.width, height: rect.height } : undefined;
|
|
120
120
|
}
|
|
121
121
|
/**
|
|
122
|
-
* The indicator's motion: translate and size in
|
|
123
|
-
* --duration. Put `data-instant` on it while
|
|
124
|
-
* Reduced motion sets --duration to 0, so it
|
|
122
|
+
* The indicator's motion: translate and size in --duration-glide on --ease-glide, the one speed and
|
|
123
|
+
* curve of every gliding indicator; opacity in --duration-fade. Put `data-instant` on it while
|
|
124
|
+
* `glide.instant`, `data-visible` while visible. Reduced motion sets --duration-glide to 0, so it
|
|
125
|
+
* moves instantly and only fades.
|
|
125
126
|
*/
|
|
126
|
-
export const glideMotion = "pointer-events-none absolute top-0 left-0 opacity-0 data-visible:opacity-100 transition-[translate,width,height,opacity]
|
|
127
|
+
export const glideMotion = "pointer-events-none absolute top-0 left-0 opacity-0 data-visible:opacity-100 transition-[translate,width,height,opacity] ease-(--ease-glide) [transition-duration:var(--duration-glide),var(--duration-glide),var(--duration-glide),var(--duration-fade)] data-instant:transition-none";
|
|
127
128
|
/** Merges a component's own ref with the one passed in by the caller. */
|
|
128
129
|
export function useMergedRef(ref) {
|
|
129
130
|
const own = React.useRef(null);
|
package/dist/lib/table-fit.d.ts
CHANGED
|
@@ -121,8 +121,9 @@ export declare class Flip {
|
|
|
121
121
|
/** Every drawn piece, its rect, and its position in its parent — less `offsets`, a glide in progress. */
|
|
122
122
|
private measure;
|
|
123
123
|
/**
|
|
124
|
-
* The cascade:
|
|
125
|
-
*
|
|
124
|
+
* The cascade: rows in view count 0, 1, 2… from the top, and a band takes the step of the row
|
|
125
|
+
* after it (it has nothing to glide, so it must not hold the rows back); those above the view
|
|
126
|
+
* start at once, those below with the last one in view.
|
|
126
127
|
*/
|
|
127
128
|
private cascade;
|
|
128
129
|
/** Forget the last positions: something other than the width moved things (scroll, data, a group). */
|
package/dist/lib/table-fit.js
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* fits on one line beside them; an `inline` column moves into the title cell instead. Only once
|
|
7
7
|
* every column that can step out has done so may titles wrap.
|
|
8
8
|
*/
|
|
9
|
+
import { cssDuration } from "./motion.js";
|
|
9
10
|
/* ── Fit ───────────────────────────────────────────────────────────────────── */
|
|
10
11
|
/** The columns that can step out, in the order they do. The title never does. */
|
|
11
12
|
export function removalOrder(columns, title) {
|
|
@@ -177,23 +178,27 @@ export function fitStep(options) {
|
|
|
177
178
|
/**
|
|
178
179
|
* One beat for the whole row: a leaving cell fades over exactly the time its neighbours take to
|
|
179
180
|
* glide into the space it frees, on the same curve and from the same start, so the gap closes as
|
|
180
|
-
* the cell goes. Entering cells start a moment later and land with them.
|
|
181
|
+
* the cell goes. Entering cells start a moment later and land with them. The beat is
|
|
182
|
+
* `--duration-glide` (1.6 × `--duration`, 240ms; 0 under reduced motion), read from the table.
|
|
181
183
|
*/
|
|
182
|
-
const
|
|
184
|
+
const moveMs = (el) => cssDuration(el) * 1.6;
|
|
183
185
|
const ENTER_DELAY_MS = 40;
|
|
184
|
-
|
|
186
|
+
/** Entering cells grow from this scale: near their size, so they arrive rather than appear. */
|
|
187
|
+
const ENTER_SCALE = "0.9";
|
|
185
188
|
/**
|
|
186
|
-
* Fades run on
|
|
187
|
-
*
|
|
189
|
+
* Fades run on `--ease-glide`, not the brand's front-loaded ease-out: on that curve a fade is
|
|
190
|
+
* ~85% done in the first frames, so a returning column seemed to pop straight in.
|
|
188
191
|
*/
|
|
189
|
-
const
|
|
190
|
-
const EXIT_MS = MOVE_MS;
|
|
192
|
+
const fadeEasing = (el) => getComputedStyle(el).getPropertyValue("--ease-glide").trim() || "cubic-bezier(0.33, 1, 0.68, 1)";
|
|
191
193
|
/** How far a leaving cell drifts towards its own side as it fades. */
|
|
192
194
|
const EXIT_DRIFT_PX = 8;
|
|
193
195
|
/** Delay between one row (or band) and the next, top to bottom — exits and glides alike. */
|
|
194
196
|
const STAGGER_MS = 30;
|
|
195
|
-
/**
|
|
196
|
-
|
|
197
|
+
/**
|
|
198
|
+
* Only the first rows in view are staggered; the rest start with the last of them. Two steps of
|
|
199
|
+
* 30ms and a 240ms glide: the whole table has settled within 300ms.
|
|
200
|
+
*/
|
|
201
|
+
const STAGGER_ROWS = 3;
|
|
197
202
|
const ZERO = { x: 0, y: 0 };
|
|
198
203
|
const keyOf = (el) => el.getAttribute("data-flip-key") ?? el;
|
|
199
204
|
/** Rows of a closed group are not drawn, nor a virtual body's sizer rows. */
|
|
@@ -306,8 +311,9 @@ export class Flip {
|
|
|
306
311
|
return { els, rects, rel, view: box };
|
|
307
312
|
}
|
|
308
313
|
/**
|
|
309
|
-
* The cascade:
|
|
310
|
-
*
|
|
314
|
+
* The cascade: rows in view count 0, 1, 2… from the top, and a band takes the step of the row
|
|
315
|
+
* after it (it has nothing to glide, so it must not hold the rows back); those above the view
|
|
316
|
+
* start at once, those below with the last one in view.
|
|
311
317
|
*/
|
|
312
318
|
cascade(rects, view) {
|
|
313
319
|
const index = new Map();
|
|
@@ -322,12 +328,11 @@ export class Flip {
|
|
|
322
328
|
else if (r.top >= view.bottom)
|
|
323
329
|
below.push(el);
|
|
324
330
|
else
|
|
325
|
-
index.set(el, count++);
|
|
331
|
+
index.set(el, el.getAttribute("data-flip") === "row" ? count++ : count);
|
|
326
332
|
}
|
|
327
333
|
for (const el of below)
|
|
328
334
|
index.set(el, Math.max(0, count - 1));
|
|
329
|
-
|
|
330
|
-
return (seq) => (seq ? (index.get(seq) ?? 0) * gap : 0);
|
|
335
|
+
return (seq) => (seq ? Math.min(index.get(seq) ?? 0, STAGGER_ROWS - 1) * STAGGER_MS : 0);
|
|
331
336
|
}
|
|
332
337
|
/** Forget the last positions: something other than the width moved things (scroll, data, a group). */
|
|
333
338
|
invalidate() {
|
|
@@ -343,6 +348,7 @@ export class Flip {
|
|
|
343
348
|
/** Glides from what is drawn now to the layout that `commit` applies (synchronously) for `next`. */
|
|
344
349
|
tier(next, commit) {
|
|
345
350
|
const easing = this.easing();
|
|
351
|
+
const move = moveMs(this.root);
|
|
346
352
|
this.direction();
|
|
347
353
|
// Read: positions (mid-glide included), the fade of anything mid-entrance, the ghosts still
|
|
348
354
|
// fading out, and clones of the pieces about to step out.
|
|
@@ -412,9 +418,13 @@ export class Flip {
|
|
|
412
418
|
}
|
|
413
419
|
if (!from) {
|
|
414
420
|
this.run(el, [
|
|
415
|
-
{ opacity: 0, scale:
|
|
421
|
+
{ opacity: 0, scale: ENTER_SCALE, transformOrigin: side },
|
|
416
422
|
{ opacity: 1, scale: "1", transformOrigin: side },
|
|
417
|
-
], {
|
|
423
|
+
], {
|
|
424
|
+
duration: Math.max(0, move - ENTER_DELAY_MS),
|
|
425
|
+
delay: move ? wait + ENTER_DELAY_MS : 0,
|
|
426
|
+
easing: fadeEasing(this.root),
|
|
427
|
+
});
|
|
418
428
|
continue;
|
|
419
429
|
}
|
|
420
430
|
const to = last.rel.get(keyOf(el));
|
|
@@ -431,7 +441,7 @@ export class Flip {
|
|
|
431
441
|
this.run(el, [
|
|
432
442
|
{ translate: `${dx}px ${dy}px`, ...fade[0] },
|
|
433
443
|
{ translate: "0px 0px", ...fade[1] },
|
|
434
|
-
], { duration:
|
|
444
|
+
], { duration: move, delay: wait, easing });
|
|
435
445
|
}
|
|
436
446
|
for (const l of leaving) {
|
|
437
447
|
if (l.key)
|
|
@@ -465,7 +475,7 @@ export class Flip {
|
|
|
465
475
|
transformOrigin: side,
|
|
466
476
|
offset: 1,
|
|
467
477
|
},
|
|
468
|
-
], { duration:
|
|
478
|
+
], { duration: move, delay: delay(l.seq), easing, fill: "both" }));
|
|
469
479
|
const ghost = { clone, anim };
|
|
470
480
|
if (l.key)
|
|
471
481
|
this.ghosts.set(l.key, ghost);
|
|
@@ -521,7 +531,7 @@ export class Flip {
|
|
|
521
531
|
this.run(el, [
|
|
522
532
|
{ translate: `${dx}px ${dy}px`, ...fade[0] },
|
|
523
533
|
{ translate: "0px 0px", ...fade[1] },
|
|
524
|
-
], { duration:
|
|
534
|
+
], { duration: moveMs(this.root), easing });
|
|
525
535
|
}
|
|
526
536
|
}
|
|
527
537
|
this.cache = now.rel;
|
|
@@ -67,7 +67,9 @@
|
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
/* The moving grain: an overlay for large or dark expressive regions (`<Grain />`).
|
|
70
|
+
/* The moving grain: an overlay for large or dark expressive regions (`<Grain />`). It moves only
|
|
71
|
+
on a desktop — a fine pointer that hovers, 48rem wide, motion allowed: a phone's backdrop stays
|
|
72
|
+
still (a moving full-screen layer costs a phone's battery, and it is held close to the eye). */
|
|
71
73
|
@utility grain {
|
|
72
74
|
pointer-events: none;
|
|
73
75
|
position: absolute;
|
|
@@ -81,7 +83,6 @@
|
|
|
81
83
|
inset: -40%;
|
|
82
84
|
background-image: var(--grain-noise);
|
|
83
85
|
background-size: 200px auto;
|
|
84
|
-
animation: ep-grain 0.8s steps(5) infinite;
|
|
85
86
|
}
|
|
86
87
|
&::before {
|
|
87
88
|
mix-blend-mode: overlay;
|
|
@@ -90,28 +91,38 @@
|
|
|
90
91
|
&::after {
|
|
91
92
|
mix-blend-mode: screen;
|
|
92
93
|
opacity: calc(var(--grain-opacity) * 0.35);
|
|
93
|
-
animation-delay: -0.4s;
|
|
94
94
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
animation: none;
|
|
95
|
+
@media (hover: hover) and (pointer: fine) and (min-width: 48rem) and (prefers-reduced-motion: no-preference) {
|
|
96
|
+
/* Still grain, for a picture rather than a region: a sheet in a carousel or a grid. */
|
|
97
|
+
&:not([data-still])::before,
|
|
98
|
+
&:not([data-still])::after {
|
|
99
|
+
animation: ep-grain 0.8s steps(5) infinite;
|
|
100
|
+
}
|
|
101
|
+
&:not([data-still])::after {
|
|
102
|
+
animation-delay: -0.4s;
|
|
104
103
|
}
|
|
105
104
|
}
|
|
106
105
|
}
|
|
107
106
|
|
|
108
107
|
@keyframes ep-grain {
|
|
109
|
-
0% {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
108
|
+
0% {
|
|
109
|
+
transform: translate(0);
|
|
110
|
+
}
|
|
111
|
+
20% {
|
|
112
|
+
transform: translate(-6%, 4%);
|
|
113
|
+
}
|
|
114
|
+
40% {
|
|
115
|
+
transform: translate(5%, -7%);
|
|
116
|
+
}
|
|
117
|
+
60% {
|
|
118
|
+
transform: translate(-3%, 8%);
|
|
119
|
+
}
|
|
120
|
+
80% {
|
|
121
|
+
transform: translate(7%, 2%);
|
|
122
|
+
}
|
|
123
|
+
100% {
|
|
124
|
+
transform: translate(0);
|
|
125
|
+
}
|
|
115
126
|
}
|
|
116
127
|
|
|
117
128
|
/* ── Blueprint grid (lights up under the pointer when data-lit="true") ───────── */
|
|
@@ -137,7 +148,11 @@
|
|
|
137
148
|
transition: opacity 0.7s var(--ease);
|
|
138
149
|
}
|
|
139
150
|
&::before {
|
|
140
|
-
background-image: radial-gradient(
|
|
151
|
+
background-image: radial-gradient(
|
|
152
|
+
circle 380px at var(--mx, 70%) var(--my, 30%),
|
|
153
|
+
var(--glow),
|
|
154
|
+
transparent 70%
|
|
155
|
+
);
|
|
141
156
|
}
|
|
142
157
|
&::after {
|
|
143
158
|
background-image:
|
|
@@ -198,6 +213,10 @@
|
|
|
198
213
|
}
|
|
199
214
|
|
|
200
215
|
@keyframes ep-draw {
|
|
201
|
-
from {
|
|
202
|
-
|
|
216
|
+
from {
|
|
217
|
+
stroke-dashoffset: var(--len, 1000);
|
|
218
|
+
}
|
|
219
|
+
to {
|
|
220
|
+
stroke-dashoffset: 0;
|
|
221
|
+
}
|
|
203
222
|
}
|
package/dist/styles/index.css
CHANGED
|
@@ -139,6 +139,14 @@
|
|
|
139
139
|
/* What the browser shows past the page's edges: the ground as one flat colour. The ground
|
|
140
140
|
itself, --background with its grain, is a layer of its own (expressive.css). */
|
|
141
141
|
background-color: var(--page-tone);
|
|
142
|
+
/* No grey flash over whatever is tapped on a phone: every control has its own pressed state. */
|
|
143
|
+
-webkit-tap-highlight-color: transparent;
|
|
144
|
+
}
|
|
145
|
+
/* A tap acts at once: no wait to rule out a double-tap zoom on the things people press. */
|
|
146
|
+
button,
|
|
147
|
+
a,
|
|
148
|
+
[role="button"] {
|
|
149
|
+
touch-action: manipulation;
|
|
142
150
|
}
|
|
143
151
|
body {
|
|
144
152
|
color: var(--foreground);
|