@zonsh/ui 0.2.0 → 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/LICENSE +22 -0
- package/README.md +19 -13
- package/dist/components/accordion.js +1 -1
- package/dist/components/alert-dialog.js +1 -1
- package/dist/components/ascii-field.d.ts +1 -1
- package/dist/components/ascii-field.js +2 -1
- package/dist/components/bottom-nav.d.ts +86 -0
- package/dist/components/bottom-nav.js +175 -0
- package/dist/components/breadcrumb.d.ts +9 -0
- package/dist/components/breadcrumb.js +6 -1
- package/dist/components/button-group.d.ts +1 -1
- package/dist/components/button-group.js +2 -2
- package/dist/components/button.js +1 -1
- package/dist/components/calendar.d.ts +1 -1
- package/dist/components/calendar.js +18 -3
- package/dist/components/carousel.d.ts +22 -3
- package/dist/components/carousel.js +25 -7
- package/dist/components/chart.d.ts +20 -0
- package/dist/components/chart.js +52 -3
- package/dist/components/code-block.d.ts +20 -10
- package/dist/components/code-block.js +54 -12
- package/dist/components/collapsible.js +3 -3
- package/dist/components/color-picker.d.ts +30 -8
- package/dist/components/color-picker.js +48 -27
- package/dist/components/combobox.d.ts +21 -3
- package/dist/components/combobox.js +79 -7
- package/dist/components/command.d.ts +23 -3
- package/dist/components/command.js +63 -18
- package/dist/components/conversation.d.ts +10 -1
- package/dist/components/conversation.js +24 -7
- package/dist/components/copy-button.d.ts +15 -6
- package/dist/components/copy-button.js +27 -10
- package/dist/components/data-table.d.ts +66 -6
- package/dist/components/data-table.js +376 -23
- package/dist/components/date-picker.d.ts +73 -4
- package/dist/components/date-picker.js +138 -7
- package/dist/components/dialog.d.ts +10 -1
- package/dist/components/dialog.js +6 -3
- package/dist/components/drawer.d.ts +10 -1
- package/dist/components/drawer.js +6 -3
- package/dist/components/feature-list.js +2 -2
- package/dist/components/field.d.ts +27 -8
- package/dist/components/field.js +49 -4
- package/dist/components/file-drop.d.ts +26 -4
- package/dist/components/file-drop.js +125 -64
- package/dist/components/filter-bar.d.ts +50 -3
- package/dist/components/filter-bar.js +71 -33
- package/dist/components/form.d.ts +4 -2
- package/dist/components/form.js +24 -2
- package/dist/components/graph.d.ts +41 -0
- package/dist/components/graph.js +106 -50
- package/dist/components/illustration.js +51 -4
- package/dist/components/input-group.d.ts +18 -7
- package/dist/components/input-group.js +41 -19
- package/dist/components/input.d.ts +2 -2
- package/dist/components/input.js +3 -3
- package/dist/components/kbd.d.ts +17 -0
- package/dist/components/kbd.js +8 -1
- package/dist/components/layout.d.ts +2 -1
- package/dist/components/layout.js +55 -11
- package/dist/components/lightbox.d.ts +100 -0
- package/dist/components/lightbox.js +457 -0
- package/dist/components/locale.d.ts +44 -0
- package/dist/components/locale.js +37 -0
- package/dist/components/logo.js +1 -1
- package/dist/components/menu.js +3 -1
- package/dist/components/menubar.js +60 -13
- package/dist/components/message.d.ts +3 -3
- package/dist/components/message.js +12 -8
- package/dist/components/meter.js +3 -1
- package/dist/components/money-input.d.ts +80 -0
- package/dist/components/money-input.js +253 -0
- package/dist/components/navigation-menu.js +4 -2
- package/dist/components/number-field.d.ts +21 -2
- package/dist/components/number-field.js +53 -28
- package/dist/components/otp-field.d.ts +14 -1
- package/dist/components/otp-field.js +10 -2
- package/dist/components/pagination.d.ts +13 -7
- package/dist/components/pagination.js +18 -7
- package/dist/components/pdf-viewer.d.ts +67 -2
- package/dist/components/pdf-viewer.js +88 -21
- package/dist/components/phone-input.d.ts +79 -0
- package/dist/components/phone-input.js +282 -0
- package/dist/components/popover.js +1 -1
- package/dist/components/progress.js +3 -1
- package/dist/components/prompt-input.d.ts +34 -9
- package/dist/components/prompt-input.js +37 -17
- package/dist/components/radio-group.js +7 -2
- package/dist/components/rating.d.ts +73 -0
- package/dist/components/rating.js +124 -0
- package/dist/components/reasoning.d.ts +16 -1
- package/dist/components/reasoning.js +10 -7
- package/dist/components/resizable.d.ts +10 -1
- package/dist/components/resizable.js +4 -1
- package/dist/components/response.d.ts +17 -5
- package/dist/components/response.js +58 -18
- package/dist/components/scroll-area.d.ts +1 -1
- package/dist/components/select.js +14 -3
- package/dist/components/separator.js +1 -1
- package/dist/components/sidebar.d.ts +20 -4
- package/dist/components/sidebar.js +70 -35
- package/dist/components/site-header.d.ts +46 -12
- package/dist/components/site-header.js +78 -19
- package/dist/components/skeleton.d.ts +1 -1
- package/dist/components/skeleton.js +1 -1
- package/dist/components/slider.js +3 -1
- package/dist/components/sortable.d.ts +178 -0
- package/dist/components/sortable.js +1282 -0
- package/dist/components/sources.d.ts +17 -2
- package/dist/components/sources.js +11 -4
- package/dist/components/spinner.d.ts +13 -1
- package/dist/components/spinner.js +5 -2
- package/dist/components/stat.d.ts +91 -0
- package/dist/components/stat.js +141 -0
- package/dist/components/stepper.d.ts +71 -0
- package/dist/components/stepper.js +101 -0
- package/dist/components/switch.d.ts +2 -2
- package/dist/components/switch.js +2 -2
- package/dist/components/table.d.ts +13 -3
- package/dist/components/table.js +231 -41
- package/dist/components/tabs.js +8 -4
- package/dist/components/tags-input.d.ts +18 -2
- package/dist/components/tags-input.js +66 -34
- package/dist/components/theme.d.ts +16 -2
- package/dist/components/theme.js +34 -8
- package/dist/components/time-field.d.ts +24 -4
- package/dist/components/time-field.js +32 -9
- package/dist/components/timeline.d.ts +18 -2
- package/dist/components/timeline.js +13 -4
- package/dist/components/tippy.d.ts +48 -0
- package/dist/components/tippy.js +648 -0
- package/dist/components/toast.d.ts +18 -2
- package/dist/components/toast.js +12 -3
- package/dist/components/toggle-group.js +1 -0
- package/dist/components/tool-call.d.ts +19 -8
- package/dist/components/tool-call.js +23 -7
- package/dist/components/toolbar.d.ts +1 -1
- package/dist/components/toolbar.js +10 -2
- package/dist/components/tooltip.d.ts +4 -2
- package/dist/components/tooltip.js +10 -4
- package/dist/components/tour.d.ts +127 -0
- package/dist/components/tour.js +673 -0
- package/dist/components/tree.js +45 -9
- package/dist/components/video-player.d.ts +10 -2
- package/dist/components/video-player.js +134 -38
- package/dist/illustration.d.ts +2 -0
- package/dist/illustration.js +7 -0
- package/dist/index.d.ts +11 -3
- package/dist/index.js +11 -3
- package/dist/lib/code-highlight.d.ts +3 -16
- package/dist/lib/code-highlight.js +160 -10
- package/dist/lib/code-theme.js +3 -3
- package/dist/lib/digit-roll.js +8 -8
- package/dist/lib/field-errors.d.ts +28 -0
- package/dist/lib/field-errors.js +24 -0
- package/dist/lib/field-value.d.ts +13 -0
- package/dist/lib/field-value.js +44 -0
- package/dist/lib/glide.d.ts +5 -4
- package/dist/lib/glide.js +5 -4
- package/dist/lib/graph-layout.js +11 -2
- package/dist/lib/money.d.ts +73 -0
- package/dist/lib/money.js +343 -0
- package/dist/lib/phone-countries.d.ts +1 -0
- package/dist/lib/phone-countries.js +281 -0
- package/dist/lib/phone.d.ts +90 -0
- package/dist/lib/phone.js +286 -0
- package/dist/lib/platform.d.ts +8 -3
- package/dist/lib/platform.js +13 -6
- package/dist/lib/row-index.d.ts +15 -0
- package/dist/lib/row-index.js +136 -0
- package/dist/lib/table-fit.d.ts +3 -2
- package/dist/lib/table-fit.js +52 -23
- package/dist/lib/theme-script.d.ts +15 -2
- package/dist/lib/theme-script.js +23 -3
- package/dist/lib/tippy/pixels.d.ts +47 -0
- package/dist/lib/tippy/pixels.js +187 -0
- package/dist/lib/tippy/sprite.d.ts +86 -0
- package/dist/lib/tippy/sprite.js +753 -0
- package/dist/messages/de.d.ts +12 -0
- package/dist/messages/de.js +326 -0
- package/dist/styles/expressive.css +60 -26
- package/dist/styles/index.css +11 -2
- package/dist/styles/material.css +47 -23
- package/dist/styles/parts/ai.css +4 -2
- package/dist/styles/parts/controls.css +85 -32
- package/dist/styles/parts/data.css +33 -5
- package/dist/styles/parts/feedback.css +110 -13
- package/dist/styles/parts/foundations.css +1 -1
- package/dist/styles/parts/navigation.css +230 -5
- package/dist/styles/parts/overlays.css +98 -11
- package/dist/styles/parts/pdf.css +13 -7
- package/dist/styles/tokens.css +28 -4
- package/dist/vite.d.ts +0 -50
- package/dist/vite.js +0 -100
- package/package.json +28 -33
- package/dist/components/code-highlight.d.ts +0 -13
- package/dist/components/code-highlight.js +0 -107
- package/dist/components/whiteboard.d.ts +0 -80
- package/dist/components/whiteboard.js +0 -389
- package/dist/styles/parts/whiteboard.css +0 -855
package/dist/components/tree.js
CHANGED
|
@@ -144,11 +144,11 @@ const TreeRow = React.memo(function TreeRow({ node, level, expanded, selected, }
|
|
|
144
144
|
const state = { expanded, selected, level };
|
|
145
145
|
const icon = typeof node.icon === "function" ? node.icon(state) : node.icon;
|
|
146
146
|
const Row = node.href ? "a" : "div";
|
|
147
|
-
return (_jsxs(Row, { "data-slot": "tree-row", "data-selected": selected ? "" : undefined, "data-current": selected ? "" : undefined, "data-disabled": node.disabled ? "" : undefined, href: node.href, tabIndex: node.href ? -1 : undefined, onClick: (event) => ctx.onRowClick(node, event), className: cn("flex w-full cursor-pointer items-center rounded-item material-row leading-none no-underline select-none",
|
|
147
|
+
return (_jsxs(Row, { "data-slot": "tree-row", "data-selected": selected ? "" : undefined, "data-current": selected ? "" : undefined, "data-disabled": node.disabled ? "" : undefined, href: node.href, tabIndex: node.href ? -1 : undefined, "aria-current": node.href && selected && ctx.selectionMode === "single" ? "page" : undefined, onClick: (event) => ctx.onRowClick(node, event), className: cn("flex w-full cursor-pointer items-center rounded-item material-row leading-none no-underline select-none",
|
|
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: "
|
|
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.
|
|
@@ -479,13 +481,19 @@ export function Tree({ items, size = "default", selectionMode = "single", select
|
|
|
479
481
|
// On a Mac, Ctrl-click is a right-click: it belongs to a context menu, not to the row.
|
|
480
482
|
if (event.ctrlKey && isApple())
|
|
481
483
|
return;
|
|
484
|
+
// A disabled link row is not followed, by the pointer as by Enter.
|
|
485
|
+
if (node.disabled)
|
|
486
|
+
event.preventDefault();
|
|
482
487
|
// The treeitem keeps the focus, also when a link row took it on mousedown.
|
|
483
488
|
setFocusState(node.id);
|
|
484
489
|
elements.current.get(node.id)?.focus({ preventScroll: true });
|
|
485
490
|
// ⌘ on Apple devices, Ctrl elsewhere.
|
|
486
491
|
const extend = modPressed(event);
|
|
487
|
-
if (selectionMode === "multiple" && (event.shiftKey || extend))
|
|
492
|
+
if (selectionMode === "multiple" && (event.shiftKey || extend)) {
|
|
493
|
+
// The modifier selects: it doesn't also open a link row in a new tab or window.
|
|
494
|
+
event.preventDefault();
|
|
488
495
|
select(node.id, event.shiftKey ? "range" : "toggle");
|
|
496
|
+
}
|
|
489
497
|
else {
|
|
490
498
|
select(node.id, "replace");
|
|
491
499
|
// A plain click on a branch also opens or closes it, as in a file explorer.
|
|
@@ -514,6 +522,21 @@ export function Tree({ items, size = "default", selectionMode = "single", select
|
|
|
514
522
|
onRowClick: (node, event) => handlers.current.onRowClick(node, event),
|
|
515
523
|
onChevronClick: (node, event) => handlers.current.onChevronClick(node, event),
|
|
516
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
|
+
};
|
|
517
540
|
const handleKeyDown = (event) => {
|
|
518
541
|
onKeyDown?.(event);
|
|
519
542
|
if (event.defaultPrevented)
|
|
@@ -548,13 +571,17 @@ export function Tree({ items, size = "default", selectionMode = "single", select
|
|
|
548
571
|
case "ArrowLeft": {
|
|
549
572
|
const forward = (event.key === "ArrowRight") === (getComputedStyle(item).direction !== "rtl");
|
|
550
573
|
if (forward) {
|
|
551
|
-
if (node.children && !expanded.has(node.id))
|
|
574
|
+
if (node.children && !expanded.has(node.id)) {
|
|
575
|
+
instantly();
|
|
552
576
|
toggle(node, true);
|
|
577
|
+
}
|
|
553
578
|
else if (node.children?.length && expanded.has(node.id))
|
|
554
579
|
focus(node.children[0].id);
|
|
555
580
|
}
|
|
556
|
-
else if (node.children && expanded.has(node.id))
|
|
581
|
+
else if (node.children && expanded.has(node.id)) {
|
|
582
|
+
instantly();
|
|
557
583
|
toggle(node, false);
|
|
584
|
+
}
|
|
558
585
|
else
|
|
559
586
|
focus(entry.parent ?? undefined);
|
|
560
587
|
break;
|
|
@@ -578,7 +605,14 @@ export function Tree({ items, size = "default", selectionMode = "single", select
|
|
|
578
605
|
break;
|
|
579
606
|
}
|
|
580
607
|
case " ":
|
|
581
|
-
|
|
608
|
+
// Shift+Space selects from the last selected row to this one (WAI-ARIA tree pattern).
|
|
609
|
+
if (multiple && event.shiftKey) {
|
|
610
|
+
if (!anchor.current || !position.has(anchor.current))
|
|
611
|
+
anchor.current = rangeEnd.current = id;
|
|
612
|
+
select(id, "range");
|
|
613
|
+
}
|
|
614
|
+
else
|
|
615
|
+
select(id, multiple ? "toggle" : "replace");
|
|
582
616
|
break;
|
|
583
617
|
case "*": {
|
|
584
618
|
// Open every sibling branch at this level.
|
|
@@ -586,8 +620,10 @@ export function Tree({ items, size = "default", selectionMode = "single", select
|
|
|
586
620
|
const open = siblings
|
|
587
621
|
.filter((n) => n.children && !n.disabled && !expanded.has(n.id))
|
|
588
622
|
.map((n) => n.id);
|
|
589
|
-
if (open.length)
|
|
623
|
+
if (open.length) {
|
|
624
|
+
instantly();
|
|
590
625
|
setExpanded([...expandedIds, ...open]);
|
|
626
|
+
}
|
|
591
627
|
break;
|
|
592
628
|
}
|
|
593
629
|
default: {
|
|
@@ -632,5 +668,5 @@ export function Tree({ items, size = "default", selectionMode = "single", select
|
|
|
632
668
|
if (focused.current === el && el.isConnected)
|
|
633
669
|
focused.current = null;
|
|
634
670
|
});
|
|
635
|
-
}, 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)))) }) }));
|
|
636
672
|
}
|
|
@@ -158,9 +158,17 @@ export interface VideoPlayerProps extends Omit<React.ComponentProps<"div">, "chi
|
|
|
158
158
|
src?: string | VideoSource[];
|
|
159
159
|
/** Versions of the same video in other languages or resolutions, in place of `src`. */
|
|
160
160
|
versions?: VideoVersion[];
|
|
161
|
-
/**
|
|
161
|
+
/**
|
|
162
|
+
* The version's `audio` to start with. Defaults to the first version's. Changed later, the
|
|
163
|
+
* player switches to it from the same moment, as the audio menu does, until the viewer picks one.
|
|
164
|
+
*/
|
|
162
165
|
defaultAudio?: string;
|
|
163
|
-
/**
|
|
166
|
+
/**
|
|
167
|
+
* The version's `quality` to start with. Defaults to the first version's. Changed later (a watch
|
|
168
|
+
* party wants 1080p, a stalling connection a step down), the player switches to it from the same
|
|
169
|
+
* moment, playing or paused as it was, as the quality menu does; the viewer's own pick from the
|
|
170
|
+
* menu stays until the app changes it again. Neither calls `onQualityChange` / `onAudioChange`.
|
|
171
|
+
*/
|
|
164
172
|
defaultQuality?: string;
|
|
165
173
|
/** The image shown before the video plays. */
|
|
166
174
|
poster?: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { Slider as BaseSlider } from "@base-ui/react/slider";
|
|
4
|
-
import { AirplayIcon, ArrowLeftIcon, AudioLinesIcon, CaptionsIcon, CaptionsOffIcon, ChevronLeftIcon, GalleryVerticalEndIcon, LanguagesIcon, MaximizeIcon, MinimizeIcon, PauseIcon, PictureInPicture2Icon, PlayIcon, RotateCcwIcon, RotateCwIcon, SkipForwardIcon, VideoOffIcon, Volume1Icon, Volume2Icon, VolumeXIcon, } from "lucide-react";
|
|
4
|
+
import { AirplayIcon, ArrowLeftIcon, AudioLinesIcon, CaptionsIcon, CaptionsOffIcon, ChevronLeftIcon, ChevronsLeftIcon, ChevronsRightIcon, GalleryVerticalEndIcon, LanguagesIcon, MaximizeIcon, MinimizeIcon, PauseIcon, PictureInPicture2Icon, PlayIcon, RotateCcwIcon, RotateCwIcon, SkipForwardIcon, VideoOffIcon, Volume1Icon, Volume2Icon, VolumeXIcon, } from "lucide-react";
|
|
5
5
|
import * as React from "react";
|
|
6
6
|
import { cn } from "../lib/cn.js";
|
|
7
7
|
import { mergeRefs } from "../lib/merge-refs.js";
|
|
@@ -76,8 +76,9 @@ const LARGE_FRAME = 768;
|
|
|
76
76
|
/** How wide a timeline preview shows: the normal and the large movie layout. */
|
|
77
77
|
const PREVIEW_WIDTH = 176;
|
|
78
78
|
const PREVIEW_WIDTH_LARGE = 256;
|
|
79
|
-
/** How long the play or pause icon shows in the middle after the viewer toggles, in ms
|
|
80
|
-
|
|
79
|
+
/** How long the play or pause icon shows in the middle after the viewer toggles, in ms: an answer
|
|
80
|
+
to a press, so within the 300ms motion budget. */
|
|
81
|
+
const FLASH_MS = 300;
|
|
81
82
|
/** The last moment of a segment that still offers its skip, so it doesn't flash at the cut. */
|
|
82
83
|
const SEGMENT_TAIL = 0.5;
|
|
83
84
|
/** How long a skip stays on its own, in seconds of playback; after that it shows with the controls. */
|
|
@@ -92,8 +93,17 @@ const SCRUB_STEP = 0.1;
|
|
|
92
93
|
const MENU_CLOSE_MS = 400;
|
|
93
94
|
/** Two taps this close together are a double tap (ms). */
|
|
94
95
|
const DOUBLE_TAP_MS = 350;
|
|
95
|
-
/** A
|
|
96
|
-
const JUMP_MS =
|
|
96
|
+
/** A jump shows this long after the last press or tap, and jumps the same way within it add to it (ms). */
|
|
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;
|
|
97
107
|
/** A subtitle file still on its way after this long gets a note where the subtitles show (ms). */
|
|
98
108
|
const SUBTITLE_SLOW_MS = 2000;
|
|
99
109
|
/** Asks for a subtitle file, and the pause between them (ms): cutting one out of a whole file can outlast a request. */
|
|
@@ -385,6 +395,14 @@ export function VideoPlayer({ src, versions = [], defaultAudio, defaultQuality,
|
|
|
385
395
|
const told = React.useRef("pause");
|
|
386
396
|
// A drag on the scrubber holds the playing video still until the thumb is let go: to the app it plays on.
|
|
387
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);
|
|
388
406
|
// The video can't be played. The controls go, with their menus and without a pointer leaving or a
|
|
389
407
|
// blur: what held them up (an open menu, the pointer, focus) would otherwise hold them up for good.
|
|
390
408
|
const fail = () => {
|
|
@@ -400,6 +418,7 @@ export function VideoPlayer({ src, versions = [], defaultAudio, defaultQuality,
|
|
|
400
418
|
return;
|
|
401
419
|
let frame = 0;
|
|
402
420
|
let shownAt = -1;
|
|
421
|
+
let stalled;
|
|
403
422
|
// Each frame would redraw the scrubber sixty times a second; the eye needs far fewer.
|
|
404
423
|
const show = () => {
|
|
405
424
|
const now = el.currentTime;
|
|
@@ -472,9 +491,22 @@ export function VideoPlayer({ src, versions = [], defaultAudio, defaultQuality,
|
|
|
472
491
|
callbacks.current.onPause?.();
|
|
473
492
|
},
|
|
474
493
|
seeked: () => playhead.set({ time: el.currentTime, buffered: bufferedEnd(el) }),
|
|
475
|
-
waiting: () =>
|
|
476
|
-
|
|
477
|
-
|
|
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
|
+
},
|
|
478
510
|
ended: () => {
|
|
479
511
|
setPlaying(false);
|
|
480
512
|
setEnded(true);
|
|
@@ -485,7 +517,10 @@ export function VideoPlayer({ src, versions = [], defaultAudio, defaultQuality,
|
|
|
485
517
|
callbacks.current.onEnded?.();
|
|
486
518
|
},
|
|
487
519
|
// A `src` that fails; one of several `<source>`s tells its own element (below).
|
|
488
|
-
error:
|
|
520
|
+
error: () => {
|
|
521
|
+
if (!autoRetry.current())
|
|
522
|
+
fail();
|
|
523
|
+
},
|
|
489
524
|
enterpictureinpicture: () => setInPip(true),
|
|
490
525
|
leavepictureinpicture: () => setInPip(false),
|
|
491
526
|
};
|
|
@@ -496,6 +531,7 @@ export function VideoPlayer({ src, versions = [], defaultAudio, defaultQuality,
|
|
|
496
531
|
sync();
|
|
497
532
|
return () => {
|
|
498
533
|
cancelAnimationFrame(frame);
|
|
534
|
+
clearTimeout(stalled);
|
|
499
535
|
for (const [type, handler] of Object.entries(handlers))
|
|
500
536
|
el.removeEventListener(type, handler);
|
|
501
537
|
};
|
|
@@ -556,6 +592,28 @@ export function VideoPlayer({ src, versions = [], defaultAudio, defaultQuality,
|
|
|
556
592
|
if (next.quality !== undefined)
|
|
557
593
|
setQuality(next.quality);
|
|
558
594
|
};
|
|
595
|
+
// The app's audio and quality, like its subtitle: shown until the viewer picks one, and again
|
|
596
|
+
// whenever the app changes them. A switch carries on from the same moment, as the menus' do. A
|
|
597
|
+
// new title takes its defaults above, in the render, so this sees nothing left to switch.
|
|
598
|
+
const appVersion = React.useRef({ audio: defaultAudio, quality: defaultQuality });
|
|
599
|
+
React.useEffect(() => {
|
|
600
|
+
const before = appVersion.current;
|
|
601
|
+
appVersion.current = { audio: defaultAudio, quality: defaultQuality };
|
|
602
|
+
const next = {};
|
|
603
|
+
if (defaultAudio !== undefined &&
|
|
604
|
+
defaultAudio !== before.audio &&
|
|
605
|
+
defaultAudio !== audio &&
|
|
606
|
+
versions.some((v) => v.audio === defaultAudio))
|
|
607
|
+
next.audio = defaultAudio;
|
|
608
|
+
if (defaultQuality !== undefined &&
|
|
609
|
+
defaultQuality !== before.quality &&
|
|
610
|
+
defaultQuality !== quality &&
|
|
611
|
+
versions.some((v) => v.quality === defaultQuality))
|
|
612
|
+
next.quality = defaultQuality;
|
|
613
|
+
if (next.audio !== undefined || next.quality !== undefined)
|
|
614
|
+
switchVersion(next);
|
|
615
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- only when the app changes its choice.
|
|
616
|
+
}, [defaultAudio, defaultQuality]);
|
|
559
617
|
// Subtitles: the browser parses the track, the player draws the cue. The <track> elements are
|
|
560
618
|
// the tracks without a renderer of their own, in order.
|
|
561
619
|
const latestTracks = React.useRef(tracks);
|
|
@@ -753,6 +811,42 @@ export function VideoPlayer({ src, versions = [], defaultAudio, defaultQuality,
|
|
|
753
811
|
playhead.set({ time: el.currentTime });
|
|
754
812
|
}, [playhead]);
|
|
755
813
|
const seekBy = (delta) => seekTo((video.current?.currentTime ?? 0) + delta);
|
|
814
|
+
// A jump the viewer asked for (a key, a skip button, a double tap) shows on its side, back on the
|
|
815
|
+
// left and ahead on the right, as the timeline runs; quick ones the same way add up there.
|
|
816
|
+
const [jump, setJump] = React.useState(null);
|
|
817
|
+
const jumpBy = (delta, at = performance.now()) => {
|
|
818
|
+
seekBy(delta);
|
|
819
|
+
const side = Math.sign(delta);
|
|
820
|
+
setJump((before) => {
|
|
821
|
+
const more = before !== null && before.side === side && at - before.at < JUMP_MS;
|
|
822
|
+
return {
|
|
823
|
+
side,
|
|
824
|
+
seconds: (more ? before.seconds : 0) + Math.abs(delta),
|
|
825
|
+
at,
|
|
826
|
+
n: (before?.n ?? 0) + 1,
|
|
827
|
+
first: !more,
|
|
828
|
+
};
|
|
829
|
+
});
|
|
830
|
+
};
|
|
831
|
+
const jumpRef = React.useRef(null);
|
|
832
|
+
React.useEffect(() => {
|
|
833
|
+
const el = jumpRef.current;
|
|
834
|
+
if (!jump || !el)
|
|
835
|
+
return;
|
|
836
|
+
const still = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
837
|
+
// Each press nudges it the way it went; only the first fades in, so a run of them doesn't blink.
|
|
838
|
+
const from = jump.first ? 0 : 1;
|
|
839
|
+
const animation = el.animate(still
|
|
840
|
+
? [{ opacity: from }, { opacity: 1, offset: 0.1 }, { opacity: 1, offset: 0.65 }, { opacity: 0 }]
|
|
841
|
+
: [
|
|
842
|
+
{ opacity: from, transform: `translateX(${jump.side * -6}px) scale(0.94)` },
|
|
843
|
+
{ opacity: 1, transform: "none", offset: 0.15 },
|
|
844
|
+
{ opacity: 1, transform: "none", offset: 0.65 },
|
|
845
|
+
{ opacity: 0, transform: "none" },
|
|
846
|
+
], { duration: JUMP_MS, easing: "ease-out" });
|
|
847
|
+
animation.onfinish = () => setJump(null);
|
|
848
|
+
return () => animation.cancel();
|
|
849
|
+
}, [jump]);
|
|
756
850
|
const changeVolume = (next) => {
|
|
757
851
|
const el = video.current;
|
|
758
852
|
if (!el)
|
|
@@ -808,10 +902,31 @@ export function VideoPlayer({ src, versions = [], defaultAudio, defaultQuality,
|
|
|
808
902
|
const el = video.current;
|
|
809
903
|
if (!el)
|
|
810
904
|
return;
|
|
811
|
-
|
|
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 };
|
|
812
907
|
setFailed(false);
|
|
813
908
|
el.load();
|
|
814
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), []);
|
|
815
930
|
const nextQuality = qualities[qualities.indexOf(version?.quality ?? "") + 1];
|
|
816
931
|
const togglePip = () => {
|
|
817
932
|
const v = video.current;
|
|
@@ -858,17 +973,17 @@ export function VideoPlayer({ src, versions = [], defaultAudio, defaultQuality,
|
|
|
858
973
|
break;
|
|
859
974
|
case "ArrowLeft":
|
|
860
975
|
if (!onSlider)
|
|
861
|
-
run(() =>
|
|
976
|
+
run(() => jumpBy(-5));
|
|
862
977
|
break;
|
|
863
978
|
case "ArrowRight":
|
|
864
979
|
if (!onSlider)
|
|
865
|
-
run(() =>
|
|
980
|
+
run(() => jumpBy(5));
|
|
866
981
|
break;
|
|
867
982
|
case "j":
|
|
868
|
-
run(() =>
|
|
983
|
+
run(() => jumpBy(-SKIP));
|
|
869
984
|
break;
|
|
870
985
|
case "l":
|
|
871
|
-
run(() =>
|
|
986
|
+
run(() => jumpBy(SKIP));
|
|
872
987
|
break;
|
|
873
988
|
case "ArrowUp":
|
|
874
989
|
if (!onSlider)
|
|
@@ -927,7 +1042,6 @@ export function VideoPlayer({ src, versions = [], defaultAudio, defaultQuality,
|
|
|
927
1042
|
// A click on the picture plays or pauses. A tap shows or hides the controls (play and pause wait
|
|
928
1043
|
// in the middle then); quick taps on the left or right third jump back or ahead.
|
|
929
1044
|
const lastTap = React.useRef(null);
|
|
930
|
-
const [jump, setJump] = React.useState(null);
|
|
931
1045
|
const handleStageClick = (event) => {
|
|
932
1046
|
if (event.button !== 0)
|
|
933
1047
|
return;
|
|
@@ -952,13 +1066,7 @@ export function VideoPlayer({ src, versions = [], defaultAudio, defaultQuality,
|
|
|
952
1066
|
const last = lastTap.current;
|
|
953
1067
|
lastTap.current = { at: now, side };
|
|
954
1068
|
if (started && side !== 0 && last?.side === side && now - last.at < DOUBLE_TAP_MS) {
|
|
955
|
-
|
|
956
|
-
setJump((before) => ({
|
|
957
|
-
side,
|
|
958
|
-
seconds: before && before.side === side && now - before.at < JUMP_MS ? before.seconds + SKIP : SKIP,
|
|
959
|
-
at: now,
|
|
960
|
-
n: (before?.n ?? 0) + 1,
|
|
961
|
-
}));
|
|
1069
|
+
jumpBy(side * SKIP, now);
|
|
962
1070
|
return;
|
|
963
1071
|
}
|
|
964
1072
|
if (hidden)
|
|
@@ -968,18 +1076,6 @@ export function VideoPlayer({ src, versions = [], defaultAudio, defaultQuality,
|
|
|
968
1076
|
setIdle(true);
|
|
969
1077
|
}
|
|
970
1078
|
};
|
|
971
|
-
const jumpRef = React.useRef(null);
|
|
972
|
-
React.useEffect(() => {
|
|
973
|
-
const el = jumpRef.current;
|
|
974
|
-
if (!jump || !el)
|
|
975
|
-
return;
|
|
976
|
-
const animation = el.animate([{ opacity: 1 }, { opacity: 1, offset: 0.6 }, { opacity: 0 }], {
|
|
977
|
-
duration: JUMP_MS,
|
|
978
|
-
easing: "ease-out",
|
|
979
|
-
});
|
|
980
|
-
animation.onfinish = () => setJump(null);
|
|
981
|
-
return () => animation.cancel();
|
|
982
|
-
}, [jump]);
|
|
983
1079
|
const ready = duration > 0;
|
|
984
1080
|
// In full screen, popups have to live inside the player to be seen.
|
|
985
1081
|
const portal = isFullscreen ? { container: root } : undefined;
|
|
@@ -1029,7 +1125,7 @@ export function VideoPlayer({ src, versions = [], defaultAudio, defaultQuality,
|
|
|
1029
1125
|
}, [playhead, seekTo]);
|
|
1030
1126
|
/* ── The controls, placed by the layout below ── */
|
|
1031
1127
|
const playButton = (_jsx(Control, { label: ended ? labels.playAgain : playing ? labels.pause : labels.play, portal: portal, size: size, onClick: togglePlay, children: ended ? _jsx(RotateCcwIcon, {}) : playing ? _jsx(PauseIcon, {}) : _jsx(PlayIcon, {}) }));
|
|
1032
|
-
const skipButtons = (_jsxs(_Fragment, { children: [_jsx(Control, { label: labels.skipBack(SKIP), portal: portal, size: size, onClick: () =>
|
|
1128
|
+
const skipButtons = (_jsxs(_Fragment, { children: [_jsx(Control, { label: labels.skipBack(SKIP), portal: portal, size: size, onClick: () => jumpBy(-SKIP), children: _jsx(SkipIcon, { direction: "back", large: large }) }), _jsx(Control, { label: labels.skipForward(SKIP), portal: portal, size: size, onClick: () => jumpBy(SKIP), children: _jsx(SkipIcon, { direction: "forward", large: large }) })] }));
|
|
1033
1129
|
const volumeControls = (_jsxs("div", { "data-slot": "video-player-volume",
|
|
1034
1130
|
// In the movie layout's row, free to narrow: its slider gives way before anything overflows.
|
|
1035
1131
|
className: cn("flex items-center", movie ? "min-w-0" : "@max-md/video:mr-auto"), children: [_jsx(Control, { label: muted || volume === 0 ? labels.unmute : labels.mute, portal: portal, size: size, onClick: toggleMute, children: muted || volume === 0 ? _jsx(VolumeXIcon, {}) : volume < 0.5 ? _jsx(Volume1Icon, {}) : _jsx(Volume2Icon, {}) }), _jsx(BaseSlider.Root, { "data-slot": "video-player-volume-slider", value: muted ? 0 : Math.round(volume * 100), min: 0, max: 100, step: 5, onValueChange: (value) => changeVolume(value / 100),
|
|
@@ -1100,13 +1196,13 @@ export function VideoPlayer({ src, versions = [], defaultAudio, defaultQuality,
|
|
|
1100
1196
|
.filter((t) => !t.render)
|
|
1101
1197
|
.map((t) => (_jsx("track", { src: loaded[t.src] ?? t.src, label: t.label, srcLang: t.srcLang, kind: t.kind ?? "subtitles" }, loaded[t.src] ?? t.src)))] }), _jsx("div", { "aria-hidden": true, "data-slot": "video-player-stage", className: "absolute inset-0", onPointerUp: handleStageClick, onDoubleClick: () => allowFullscreen && canFullscreen && toggleFullscreen() }), movie && (_jsxs(_Fragment, { children: [_jsx("div", { hidden: failed, "aria-hidden": true, "data-slot": "video-player-scrim", "data-hidden": hidden ? "" : undefined, className: cn("pointer-events-none absolute inset-0 bg-[linear-gradient(to_bottom,rgb(0_0_0/0.55),transparent_22%,transparent_40%,rgb(0_0_0/0.85))]", "transition-opacity duration-(--duration) ease-brand data-hidden:opacity-0") }), (title || onBack) && (_jsxs("div", { "data-slot": "video-player-title", "data-hidden": hidden ? "" : undefined, ...focusProps, className: cn("theme-dark pointer-events-none absolute inset-x-0 top-0 flex items-center gap-1 bg-transparent px-5 pt-4 @2xl/video:px-7 @2xl/video:pt-6", "transition-opacity duration-(--duration) ease-brand data-hidden:opacity-0 data-hidden:*:pointer-events-none!",
|
|
1102
1198
|
// The arrow stands over the play button, in the controls' own column; the title follows it.
|
|
1103
|
-
onBack && "pt-3 pl-3 @2xl/video:pt-5 @2xl/video:pl-5", large && "[--icon-button:var(--control-h-lg)] [&_button_svg:not([class*='size-'])]:size-5", large && onBack && "pt-5! pl-7!"), children: [onBack && (_jsx(Control, { label: labels.back, portal: portal, size: size, onClick: onBack, className: "pointer-events-auto", children: _jsx(ArrowLeftIcon, {}) })), title && (_jsx("p", { className: "max-w-[min(100%,40rem)] min-w-0 truncate font-heading text-[17px] font-light text-foreground @2xl/video:text-2xl", children: title }))] }))] })), _jsx("div", { className: "theme-dark pointer-events-none absolute inset-0 flex items-center justify-center bg-transparent text-foreground", children: failed ? (_jsxs("div", { className: "flex flex-col items-center gap-4", children: [_jsxs("p", { "data-slot": "video-player-error", className: "flex items-center gap-2 font-mono text-xs text-muted-foreground", children: [_jsx(VideoOffIcon, { "aria-hidden": true, className: "size-4" }), labels.error] }), _jsxs("div", { className: "pointer-events-auto flex flex-wrap justify-center gap-2", children: [_jsx(Button, { variant: "secondary", size: "sm", onClick: retry, children: labels.retry }), nextQuality && (_jsx(Button, { variant: "ghost", size: "sm", onClick: () => {
|
|
1199
|
+
onBack && "pt-3 pl-3 @2xl/video:pt-5 @2xl/video:pl-5", large && "[--icon-button:var(--control-h-lg)] [&_button_svg:not([class*='size-'])]:size-5", large && onBack && "pt-5! pl-7!"), children: [onBack && (_jsx(Control, { label: labels.back, portal: portal, size: size, onClick: onBack, className: "pointer-events-auto", children: _jsx(ArrowLeftIcon, { className: "rtl:-scale-x-100" }) })), title && (_jsx("p", { className: "max-w-[min(100%,40rem)] min-w-0 truncate font-heading text-[17px] font-light text-foreground @2xl/video:text-2xl", children: title }))] }))] })), _jsx("div", { className: "theme-dark pointer-events-none absolute inset-0 flex items-center justify-center bg-transparent text-foreground", children: failed ? (_jsxs("div", { className: "flex flex-col items-center gap-4", children: [_jsxs("p", { "data-slot": "video-player-error", className: "flex items-center gap-2 font-mono text-xs text-muted-foreground", children: [_jsx(VideoOffIcon, { "aria-hidden": true, className: "size-4" }), labels.error] }), _jsxs("div", { className: "pointer-events-auto flex flex-wrap justify-center gap-2", children: [_jsx(Button, { variant: "secondary", size: "sm", onClick: retry, children: labels.retry }), nextQuality && (_jsx(Button, { variant: "ghost", size: "sm", onClick: () => {
|
|
1104
1200
|
switchVersion({ quality: nextQuality });
|
|
1105
1201
|
onQualityChange?.(nextQuality);
|
|
1106
1202
|
}, children: labels.tryQuality(nextQuality) }))] })] })) : preparing ? (_jsx(Spinner, { size: "lg", label: labels.loading })) : !started || ended ? (_jsx(Button, { "data-slot": "video-player-start", variant: "secondary", size: "icon", "aria-label": ended ? labels.playAgain : labels.play, onClick: togglePlay, className: "pointer-events-auto size-(--control-h-lg) [&_svg:not([class*='size-'])]:size-5", children: ended ? _jsx(RotateCcwIcon, {}) : _jsx(PlayIcon, { className: "translate-x-px" }) })) : waiting ? (_jsx(Spinner, { size: "lg", label: labels.loading })) : (_jsx(Button, { "data-slot": "video-player-center", "data-hidden": controlsHidden ? "" : undefined, variant: "secondary", size: "icon", "aria-label": playing ? labels.pause : labels.play, onClick: () => {
|
|
1107
1203
|
togglePlay();
|
|
1108
1204
|
wake();
|
|
1109
|
-
}, className: cn("pointer-events-auto hidden size-(--control-h-lg) pointer-coarse:inline-flex [&_svg:not([class*='size-'])]:size-5", "transition-opacity duration-(--duration) ease-brand data-hidden:pointer-events-none data-hidden:opacity-0"), children: playing ? _jsx(PauseIcon, {}) : _jsx(PlayIcon, { className: "translate-x-px" }) })) }), jump && (_jsx("div", { "aria-hidden": true, className: cn("theme-dark pointer-events-none absolute inset-y-0 flex w-1/3 items-center justify-center bg-transparent", jump.side < 0 ? "left-0" : "right-0"), children:
|
|
1205
|
+
}, className: cn("pointer-events-auto hidden size-(--control-h-lg) pointer-coarse:inline-flex [&_svg:not([class*='size-'])]:size-5", "transition-opacity duration-(--duration) ease-brand data-hidden:pointer-events-none data-hidden:opacity-0"), children: playing ? _jsx(PauseIcon, {}) : _jsx(PlayIcon, { className: "translate-x-px" }) })) }), jump && (_jsx("div", { "aria-hidden": true, className: cn("theme-dark pointer-events-none absolute inset-y-0 flex w-1/3 items-center justify-center bg-transparent", jump.side < 0 ? "left-0" : "right-0"), children: _jsxs("div", { ref: jumpRef, "data-slot": "video-player-jump", className: cn("flex flex-col items-center justify-center gap-1 rounded-full bg-black/50 text-foreground opacity-0", movie ? "size-20 [&_svg]:size-7" : "size-14 [&_svg]:size-5"), children: [jump.side < 0 ? (_jsx(ChevronsLeftIcon, { strokeWidth: 1.5 })) : (_jsx(ChevronsRightIcon, { strokeWidth: 1.5 })), _jsx("span", { className: cn("font-mono leading-none tabular-nums", movie ? "text-xs" : "text-[10px]"), children: labels.jumped(jump.side * jump.seconds) })] }, jump.n) })), flash && (_jsx("div", { "aria-hidden": true, className: "theme-dark pointer-events-none absolute inset-0 flex items-center justify-center bg-transparent", children: _jsx("div", { ref: flashRef, "data-slot": "video-player-flash", className: cn("flex items-center justify-center rounded-full bg-black/50 text-foreground opacity-0", movie ? "size-20 [&_svg]:size-8" : "size-14 [&_svg]:size-6"), children: flash.playing ? _jsx(PlayIcon, { className: "translate-x-0.5" }) : _jsx(PauseIcon, {}) }, flash.n) })), _jsx("div", { ref: subtitleLayer, "aria-hidden": true, "data-slot": "video-player-subtitle-layer", className: cn("pointer-events-none absolute inset-0 transition-transform duration-(--duration) ease-brand", !controlsHidden &&
|
|
1110
1206
|
(large
|
|
1111
1207
|
? "-translate-y-[calc(var(--control-h-lg)+56px)]"
|
|
1112
1208
|
: movie
|
|
@@ -1335,7 +1431,7 @@ function EpisodesMenu({ seasons, current, onSeasonOpen, onSelect, labels, portal
|
|
|
1335
1431
|
if (!playing.episodes)
|
|
1336
1432
|
onSeasonOpen?.(playing.id);
|
|
1337
1433
|
}
|
|
1338
|
-
}, children: [_jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { render: _jsx(MenuTrigger, { render: _jsx(Button, { variant: "ghost", size: size, "aria-label": labels.episodes, children: _jsx(GalleryVerticalEndIcon, {}) }) }) }), _jsx(TooltipContent, { portal: portal, className: "theme-dark", children: labels.episodes })] }), _jsx(MenuContent, { side: "top", align: "end", portal: portal, className: "theme-dark flex max-h-[min(36rem,var(--available-height,36rem))] w-[min(30rem,var(--available-width))] flex-col overflow-hidden", children: picking ? (_jsxs(MenuGroup, { className: "min-h-0 overflow-y-auto overscroll-contain", children: [_jsx(MenuGroupLabel, { children: labels.seasons }), _jsx(MenuRadioGroup, { value: season?.id ?? "", onValueChange: (id) => showSeason(String(id)), children: seasons.map((s) => (_jsxs(MenuRadioItem, { value: s.id, closeOnClick: false, children: [_jsx("span", { className: "flex-1", children: s.label }), countOf(s)] }, s.id))) })] })) : (_jsxs(_Fragment, { children: [seasons.length > 1 ? (_jsxs(MenuItem, { closeOnClick: false, onClick: () => setPicking(true), "aria-label": `${labels.seasons}: ${season?.label ?? ""}`, className: "shrink-0", children: [_jsx(ChevronLeftIcon, {}), header] })) : (_jsx("div", { className: "flex min-h-(--control-h) shrink-0 items-center gap-2.5 px-2.5 text-sm", children: header })), _jsx(MenuSeparator, { className: "shrink-0" }), _jsx("div", { ref: list, className: "relative min-h-0 overflow-y-auto overscroll-contain", children: _jsx(MenuGroup, { "aria-label": season?.label, "aria-busy": !season?.episodes || undefined, children: season?.episodes
|
|
1434
|
+
}, children: [_jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { render: _jsx(MenuTrigger, { render: _jsx(Button, { variant: "ghost", size: size, "aria-label": labels.episodes, children: _jsx(GalleryVerticalEndIcon, {}) }) }) }), _jsx(TooltipContent, { portal: portal, className: "theme-dark", children: labels.episodes })] }), _jsx(MenuContent, { side: "top", align: "end", portal: portal, className: "theme-dark flex max-h-[min(36rem,var(--available-height,36rem))] w-[min(30rem,var(--available-width))] flex-col overflow-hidden", children: picking ? (_jsxs(MenuGroup, { className: "min-h-0 overflow-y-auto overscroll-contain", children: [_jsx(MenuGroupLabel, { children: labels.seasons }), _jsx(MenuRadioGroup, { value: season?.id ?? "", onValueChange: (id) => showSeason(String(id)), children: seasons.map((s) => (_jsxs(MenuRadioItem, { value: s.id, closeOnClick: false, children: [_jsx("span", { className: "flex-1", children: s.label }), countOf(s)] }, s.id))) })] })) : (_jsxs(_Fragment, { children: [seasons.length > 1 ? (_jsxs(MenuItem, { closeOnClick: false, onClick: () => setPicking(true), "aria-label": `${labels.seasons}: ${season?.label ?? ""}`, className: "shrink-0", children: [_jsx(ChevronLeftIcon, { className: "rtl:-scale-x-100" }), header] })) : (_jsx("div", { className: "flex min-h-(--control-h) shrink-0 items-center gap-2.5 px-2.5 text-sm", children: header })), _jsx(MenuSeparator, { className: "shrink-0" }), _jsx("div", { ref: list, className: "relative min-h-0 overflow-y-auto overscroll-contain", children: _jsx(MenuGroup, { "aria-label": season?.label, "aria-busy": !season?.episodes || undefined, children: season?.episodes
|
|
1339
1435
|
? season.episodes.map((e) => (_jsx(EpisodeItem, { episode: e, playing: e.id === current, labels: labels, onSelect: onSelect }, e.id)))
|
|
1340
1436
|
: // Rows the size of the ones to come, so the list doesn't jump when they do.
|
|
1341
1437
|
Array.from({ length: Math.min(season?.count ?? 3, 6) }, (_, i) => (_jsxs("div", { className: "flex items-start gap-3 px-2.5 py-2", children: [_jsx(Skeleton, { shape: "item", className: "aspect-video w-28" }), _jsxs("div", { className: "flex flex-1 flex-col gap-2 py-1 text-sm", children: [_jsx(Skeleton, { className: "w-2/3" }), _jsx(Skeleton, { className: "w-full text-[13px]" }), _jsx(Skeleton, { className: "w-1/2 text-[13px]" })] })] }, i))) }) })] })) })] }));
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// `@zonsh/ui/illustration`: the illustration library, an entry of its own because its editorial
|
|
2
|
+
// images are files, which a bundler copies into every build that reads the module.
|
|
3
|
+
export * from "./components/illustration.js";
|
|
4
|
+
// Plain data, named from a plain module: a server component reads it, and a client module's
|
|
5
|
+
// exports reach the server only as references. Named here, it wins over the same names re-exported
|
|
6
|
+
// by ./components/illustration.
|
|
7
|
+
export { illustrationKinds, illustrations } from "./lib/illustration-info.js";
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export * from "./lib/cn.js";
|
|
2
|
-
export { createThemeScript, themeScript, THEME_STORAGE_KEY, type ThemeMode } from "./lib/theme-script.js";
|
|
3
|
-
export { illustrationKinds, illustrations, type IllustrationInfo } from "./lib/illustration-info.js";
|
|
2
|
+
export { createThemeScript, themeScript, PAGE_TONE, THEME_STORAGE_KEY, type ThemeMode } from "./lib/theme-script.js";
|
|
4
3
|
export { zonCodeTheme } from "./lib/code-theme.js";
|
|
5
4
|
export * from "./components/accordion.js";
|
|
6
5
|
export * from "./components/alert-dialog.js";
|
|
@@ -9,6 +8,7 @@ export * from "./components/ascii-field.js";
|
|
|
9
8
|
export * from "./components/aspect-ratio.js";
|
|
10
9
|
export * from "./components/avatar.js";
|
|
11
10
|
export * from "./components/badge.js";
|
|
11
|
+
export * from "./components/bottom-nav.js";
|
|
12
12
|
export * from "./components/breadcrumb.js";
|
|
13
13
|
export * from "./components/button-group.js";
|
|
14
14
|
export * from "./components/button.js";
|
|
@@ -30,29 +30,33 @@ export * from "./components/feature-list.js";
|
|
|
30
30
|
export * from "./components/field.js";
|
|
31
31
|
export * from "./components/file-drop.js";
|
|
32
32
|
export * from "./components/form.js";
|
|
33
|
-
export * from "./components/illustration.js";
|
|
34
33
|
export * from "./components/input-group.js";
|
|
35
34
|
export * from "./components/input.js";
|
|
36
35
|
export * from "./components/item.js";
|
|
37
36
|
export * from "./components/kbd.js";
|
|
38
37
|
export * from "./components/label.js";
|
|
39
38
|
export * from "./components/layout.js";
|
|
39
|
+
export * from "./components/lightbox.js";
|
|
40
|
+
export * from "./components/locale.js";
|
|
40
41
|
export * from "./components/logo.js";
|
|
41
42
|
export * from "./components/menu.js";
|
|
42
43
|
export * from "./components/menubar.js";
|
|
43
44
|
export * from "./components/message.js";
|
|
44
45
|
export * from "./components/meter.js";
|
|
46
|
+
export * from "./components/money-input.js";
|
|
45
47
|
export * from "./components/native-select.js";
|
|
46
48
|
export * from "./components/navigation-menu.js";
|
|
47
49
|
export * from "./components/number-field.js";
|
|
48
50
|
export * from "./components/otp-field.js";
|
|
49
51
|
export * from "./components/pagination.js";
|
|
52
|
+
export * from "./components/phone-input.js";
|
|
50
53
|
export * from "./components/popover.js";
|
|
51
54
|
export * from "./components/preview-card.js";
|
|
52
55
|
export * from "./components/progress.js";
|
|
53
56
|
export * from "./components/prompt-input.js";
|
|
54
57
|
export * from "./components/quote.js";
|
|
55
58
|
export * from "./components/radio-group.js";
|
|
59
|
+
export * from "./components/rating.js";
|
|
56
60
|
export * from "./components/reasoning.js";
|
|
57
61
|
export * from "./components/response.js";
|
|
58
62
|
export * from "./components/scroll-area.js";
|
|
@@ -62,8 +66,11 @@ export * from "./components/sidebar.js";
|
|
|
62
66
|
export * from "./components/site-header.js";
|
|
63
67
|
export * from "./components/skeleton.js";
|
|
64
68
|
export * from "./components/slider.js";
|
|
69
|
+
export * from "./components/sortable.js";
|
|
65
70
|
export * from "./components/sources.js";
|
|
66
71
|
export * from "./components/spinner.js";
|
|
72
|
+
export * from "./components/stat.js";
|
|
73
|
+
export * from "./components/stepper.js";
|
|
67
74
|
export * from "./components/suggestions.js";
|
|
68
75
|
export * from "./components/switch.js";
|
|
69
76
|
export * from "./components/table.js";
|
|
@@ -80,6 +87,7 @@ export * from "./components/toggle.js";
|
|
|
80
87
|
export * from "./components/tool-call.js";
|
|
81
88
|
export * from "./components/toolbar.js";
|
|
82
89
|
export * from "./components/tooltip.js";
|
|
90
|
+
export * from "./components/tour.js";
|
|
83
91
|
export * from "./components/tree.js";
|
|
84
92
|
export * from "./components/typography.js";
|
|
85
93
|
export * from "./components/video-player.js";
|