@vivix-labs/media-tools 1.0.0-beta.3 → 1.0.0-beta.6
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/assets/copy-document-EF4PHM7F.svg +10 -0
- package/dist/assets/delete-4Y3OUMEL.svg +8 -0
- package/dist/assets/download-VTKCEAZG.svg +6 -0
- package/dist/assets/favorite-6GMNHJCN.svg +5 -0
- package/dist/assets/filter-JSDZZVGN.svg +5 -0
- package/dist/assets/inria-serif-latin-400-italic-ZCFRMMVP.woff2 +0 -0
- package/dist/assets/inria-serif-latin-700-italic-UNRIXGAH.woff2 +0 -0
- package/dist/assets/inter-latin-900-normal-FKACR3DR.woff2 +0 -0
- package/dist/assets/refresh-WQ3CTB57.svg +3 -0
- package/dist/assets/select-items-GJZIVO37.svg +6 -0
- package/dist/assets/upload-U5RZT5QI.svg +5 -0
- package/dist/client.bundle.js +142 -36
- package/dist/client.css +644 -54
- package/dist/shared.d.ts +13 -0
- package/package.json +1 -1
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<g clip-path="url(#clip0_63_31727)">
|
|
3
|
+
<path d="M13.3336 4.73405C14.4011 4.73423 15.2671 5.59918 15.2672 6.66667V13.3337C15.2671 14.4012 14.4011 15.2671 13.3336 15.2673H6.66666C5.59917 15.2671 4.73422 14.4012 4.73404 13.3337V6.66667C4.73422 5.59918 5.59916 4.73423 6.66666 4.73405H13.3336ZM6.66666 5.93327C6.26191 5.93345 5.93343 6.26192 5.93326 6.66667V13.3337C5.93344 13.7384 6.26191 14.0669 6.66666 14.0671H13.3336C13.7384 14.0669 14.0669 13.7384 14.067 13.3337V6.66667C14.0669 6.26192 13.7384 5.93345 13.3336 5.93327H6.66666ZM9.33365 0.734055C10.3981 0.734231 11.2671 1.60222 11.2672 2.66667C11.2671 2.99778 10.9978 3.26708 10.6667 3.26726C10.3355 3.26708 10.0672 2.99778 10.067 2.66667C10.0669 2.26496 9.73536 1.93345 9.33365 1.93327H2.66666C2.26495 1.93345 1.93344 2.26496 1.93326 2.66667V9.33366C1.93344 9.73537 2.26495 10.0669 2.66666 10.0671C2.99777 10.0672 3.26707 10.3356 3.26724 10.6667C3.26706 10.9978 2.99777 11.2671 2.66666 11.2673C1.60221 11.2671 0.734219 10.3981 0.734039 9.33366V2.66667C0.734216 1.60222 1.60221 0.734232 2.66666 0.734055H9.33365Z" fill="white"/>
|
|
4
|
+
</g>
|
|
5
|
+
<defs>
|
|
6
|
+
<clipPath id="clip0_63_31727">
|
|
7
|
+
<rect width="16" height="16" fill="white"/>
|
|
8
|
+
</clipPath>
|
|
9
|
+
</defs>
|
|
10
|
+
</svg>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<svg preserveAspectRatio="none" overflow="visible" style="display: block;" width="13.2" height="14.533" viewBox="0 0 13.2 14.533" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<g id="elements">
|
|
3
|
+
<path id="Rectangle 980" d="M11.6 2.93301L11.1868 9.6164V9.61642C11.0813 11.324 11.0285 12.1778 10.6005 12.7916C10.3889 13.0951 10.1164 13.3512 9.80047 13.5437C9.16141 13.933 8.30599 13.933 6.59516 13.933C4.88208 13.933 4.02554 13.933 3.38604 13.543C3.06987 13.3501 2.79733 13.0935 2.58579 12.7896C2.15792 12.1747 2.1063 11.3198 2.00307 9.60978L1.6 2.93301" stroke-width="1.2" stroke-linecap="round" stroke="#0F0C0C"/>
|
|
4
|
+
<path id="Vector" d="M0.6 2.93333H3.96862M3.96862 2.93333H9.30382M3.96862 2.93333L4.3724 2.04751L4.37241 2.0475C4.66709 1.40103 4.81443 1.0778 5.0782 0.875447C5.13666 0.830599 5.19873 0.790673 5.26379 0.756081C5.55732 0.600001 5.91255 0.600001 6.62302 0.600001C7.31608 0.600001 7.66261 0.600001 7.95135 0.749802C8.0154 0.78303 8.07664 0.821401 8.13448 0.864539C8.39522 1.05902 8.54638 1.37084 8.8487 1.99449L9.30382 2.93333M9.30382 2.93333H12.6" stroke-width="1.2" stroke-linecap="round" stroke="#0F0C0C"/>
|
|
5
|
+
<path id="Line 5" d="M4.93203 10.267L4.93203 6.26699" stroke-width="1.2" stroke-linecap="round" stroke="#0F0C0C"/>
|
|
6
|
+
<path id="Line 6" d="M8.26797 10.267V6.26699" stroke-width="1.2" stroke-linecap="round" stroke="#0F0C0C"/>
|
|
7
|
+
</g>
|
|
8
|
+
</svg>
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
<svg preserveAspectRatio="none" overflow="visible" style="display: block;" width="13.2001" height="13.1997" viewBox="0 0 13.2001 13.1997" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<g id="elements">
|
|
3
|
+
<path id="Vector 9655" d="M0.600051 9.93301C0.600051 10.553 0.600051 10.863 0.668199 11.1173C0.853133 11.8075 1.39223 12.3466 2.08241 12.5315C2.33675 12.5997 2.64674 12.5997 3.26672 12.5997L9.93338 12.5997C10.5534 12.5997 10.8634 12.5997 11.1177 12.5315C11.8079 12.3466 12.347 11.8075 12.5319 11.1173C12.6001 10.863 12.6001 10.553 12.6001 9.93301" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round" stroke="#0F0C0C"/>
|
|
4
|
+
<path id="Vector" d="M9.60005 6.26669C9.60005 6.26669 7.39058 9.26666 6.60003 9.26667C5.80947 9.26667 3.60005 6.26667 3.60005 6.26667M6.60003 8.6V0.6" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round" stroke="#0F0C0C"/>
|
|
5
|
+
</g>
|
|
6
|
+
</svg>
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
<svg preserveAspectRatio="none" overflow="visible" style="display: block;" width="11.8667" height="14.5333" viewBox="0 0 11.8667 14.5333" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<g id="elements">
|
|
3
|
+
<path id="Vector" d="M0.600003 5.73835V11.2539C0.600003 12.7911 0.600003 13.5597 1.11523 13.8349C2.11298 14.3676 3.98454 12.5901 4.87334 12.0549C5.38881 11.7446 5.64654 11.5894 5.93334 11.5894C6.22013 11.5894 6.47787 11.7446 6.99333 12.0549C7.88214 12.5901 9.75369 14.3676 10.7514 13.8349C11.2667 13.5597 11.2667 12.7911 11.2667 11.2539V5.73835C11.2667 3.31611 11.2667 2.10499 10.4856 1.3525C9.70457 0.600001 8.44749 0.600001 5.93334 0.600001C3.41918 0.600001 2.1621 0.600001 1.38105 1.3525C0.600003 2.10499 0.600003 3.31611 0.600003 5.73835Z" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round" stroke="#0F0C0C"/>
|
|
4
|
+
</g>
|
|
5
|
+
</svg>
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
<svg preserveAspectRatio="none" overflow="visible" style="display: block;" width="13.2" height="13.2" viewBox="0 0 13.2 13.2" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<g id="elements">
|
|
3
|
+
<path id="Vector" d="M1.01821 3.56578C1.66375 4.33277 2.84599 5.69708 4.50496 6.9374C4.65656 7.05072 4.75605 7.23596 4.77284 7.44094C4.95973 9.72425 5.13094 11.2841 5.22184 12.0519C5.26952 12.4546 5.71603 12.7644 6.08399 12.5042C6.7021 12.0671 7.85682 11.5771 8.0094 10.7628C8.10391 10.2584 8.25578 9.26132 8.42046 7.44094C8.43884 7.23783 8.53798 7.05472 8.68837 6.94237C10.3507 5.70048 11.5353 4.33375 12.1817 3.56578C12.3816 3.32836 12.4471 3.15461 12.4864 2.84854C12.6212 1.80054 12.6886 1.27654 12.3814 0.938271C12.0741 0.600003 11.5306 0.600003 10.4438 0.600003H2.7562C1.66935 0.600003 1.12592 0.600003 0.818623 0.938271C0.511327 1.27654 0.57873 1.80054 0.713538 2.84854C0.752908 3.1546 0.818384 3.32835 1.01821 3.56578Z" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round" stroke="#0F0C0C"/>
|
|
4
|
+
</g>
|
|
5
|
+
</svg>
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><style>path,rect,circle,ellipse,line,polyline,polygon,use{vector-effect:non-scaling-stroke;stroke-width:calc(0.6px + 3.75vmax)}</style>
|
|
2
|
+
<path d="M20.0092 2V5.13219C20.0092 5.42605 19.6418 5.55908 19.4537 5.33333C17.6226 3.2875 14.9617 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22C17.5228 22 22 17.5228 22 12" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" stroke="#0F0C0C"/>
|
|
3
|
+
</svg>
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
<svg preserveAspectRatio="none" overflow="visible" style="display: block;" width="13.8681" height="13.8667" viewBox="0 0 13.8681 13.8667" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<g id="elements">
|
|
3
|
+
<path id="Rectangle 1773" d="M13.2318 4.4C13.2667 5.10009 13.2667 5.93291 13.2667 6.93333V6.93334C13.2667 9.9189 13.2667 11.4117 12.3392 12.3392C11.4117 13.2667 9.9189 13.2667 6.93334 13.2667H6.93333H6.93333C3.94777 13.2667 2.45499 13.2667 1.5275 12.3392C0.600001 11.4117 0.600001 9.9189 0.600001 6.93333C0.600001 3.94777 0.600001 2.45499 1.5275 1.5275C2.45499 0.600001 3.94777 0.600001 6.93333 0.600001C7.64795 0.600001 8.27705 0.600001 8.83333 0.61272" stroke-width="1.2" stroke-linecap="round" stroke="#0F0C0C"/>
|
|
4
|
+
<path id="Vector 6664" d="M4.26797 6.6C4.26797 6.6 5.26797 6.6 6.6013 8.93333C6.6013 8.93333 9.97385 2.82222 13.268 1.6" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round" stroke="#0F0C0C"/>
|
|
5
|
+
</g>
|
|
6
|
+
</svg>
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"><style>path,rect,circle,ellipse,line,polyline,polygon,use{vector-effect:non-scaling-stroke;stroke-width:calc(0.6px + 3.75vmax)}</style>
|
|
2
|
+
<path d="M1.66638 9.00004V6.33337C1.66638 5.39056 1.66638 4.91916 1.95928 4.62627C2.25217 4.33337 2.72357 4.33337 3.66638 4.33337H12.333C13.2759 4.33337 13.7473 4.33337 14.0402 4.62627C14.333 4.91916 14.333 5.39056 14.333 6.33337V9.00004C14.333 11.5142 14.333 12.7713 13.552 13.5523C12.771 14.3334 11.5139 14.3334 8.99972 14.3334H6.99972C4.48556 14.3334 3.22848 14.3334 2.44743 13.5523C1.66638 12.7713 1.66638 11.5142 1.66638 9.00004Z" stroke="white" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round"/>
|
|
3
|
+
<path d="M1.69934 5.30009C2.00012 4.00467 2.50277 2.60041 3.8071 1.94825C4.37015 1.66672 5.02444 1.66672 6.333 1.66672H9.66633C10.9749 1.66672 11.6292 1.66672 12.1922 1.94825C13.4966 2.60041 14.0001 4.00468 14.3001 5.30009" stroke="white" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round"/>
|
|
4
|
+
<path d="M9.99969 9.00003C9.99969 9.00003 8.52672 7.00005 7.99968 7.00005C7.47264 7.00004 5.99969 9.00005 5.99969 9.00005M7.99968 7.33336L7.99969 11.6667" stroke="white" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round"/>
|
|
5
|
+
</svg>
|
package/dist/client.bundle.js
CHANGED
|
@@ -244,6 +244,8 @@ var iconGeometry = {
|
|
|
244
244
|
height: 15.5625,
|
|
245
245
|
slot: 18
|
|
246
246
|
},
|
|
247
|
+
"select-items": { width: 13.8681, height: 13.8667, slot: 16 },
|
|
248
|
+
filter: { width: 13.2, height: 13.2, slot: 16 },
|
|
247
249
|
select: {
|
|
248
250
|
width: 14.6298,
|
|
249
251
|
height: 16.065,
|
|
@@ -324,6 +326,9 @@ var iconGeometry = {
|
|
|
324
326
|
height: 13.2,
|
|
325
327
|
slot: 16
|
|
326
328
|
},
|
|
329
|
+
favorite: { width: 11.8667, height: 14.5333, slot: 16 },
|
|
330
|
+
download: { width: 13.2001, height: 13.1997, slot: 16 },
|
|
331
|
+
delete: { width: 13.2, height: 14.533, slot: 16 },
|
|
327
332
|
edit: {
|
|
328
333
|
width: 10.8791,
|
|
329
334
|
height: 12.0459,
|
|
@@ -384,6 +389,7 @@ var buttonVariants = {
|
|
|
384
389
|
"text-filled-leading-sm": { size: 32, appearance: "filled", shape: "text" },
|
|
385
390
|
"text-ghost-sm": { size: 32, appearance: "ghost", shape: "text" },
|
|
386
391
|
"text-on-content-sm": { size: 32, appearance: "on-content", shape: "text" },
|
|
392
|
+
"text-outline-sm": { size: 32, appearance: "outline", shape: "text" },
|
|
387
393
|
"text-tonal-sm": { size: 32, appearance: "tonal", shape: "text" },
|
|
388
394
|
// The medium recipes are shared by all dialog footer actions.
|
|
389
395
|
"text-filled-md": { size: 40, appearance: "filled", shape: "text" },
|
|
@@ -418,8 +424,8 @@ function ButtonFrame({ label, variant, loading = false, width, children, disable
|
|
|
418
424
|
const buttonStyle = "width" in spec ? { ...style, "--vx-button-width": `${spec.width}px` } : style;
|
|
419
425
|
return _jsxs("button", { ...props, type, className: className ? `vx-button ${className}` : "vx-button", "data-variant": variant, "data-appearance": spec.appearance, "data-shape": spec.shape, "data-size": spec.size, "data-width": width, "data-state": loading ? "loading" : disabled ? "disabled" : "default", style: buttonStyle, disabled: disabled || loading, "aria-label": label, "aria-busy": loading || void 0, children: [_jsx2("span", { className: "vx-button-content", children }), loading && _jsx2("span", { className: "vx-button-loading", "aria-hidden": "true" })] });
|
|
420
426
|
}
|
|
421
|
-
function Button({ variant = "text-filled-sm", leadingIcon, trailingIcon, ...props }) {
|
|
422
|
-
return _jsxs(ButtonFrame, { ...props, variant, children: [leadingIcon && _jsx2(Icon, { name: leadingIcon }), _jsx2("span", { className: "vx-button-label", children: props.label }), trailingIcon && _jsx2("span", { className: "vx-button-trailing", children: _jsx2(Icon, { name: trailingIcon }) })] });
|
|
427
|
+
function Button({ variant = "text-filled-sm", leadingIcon, trailingIcon, badge, ...props }) {
|
|
428
|
+
return _jsxs(ButtonFrame, { ...props, label: badge ? `${props.label} (${badge})` : props.label, variant, children: [leadingIcon && _jsx2(Icon, { name: leadingIcon }), _jsx2("span", { className: "vx-button-label", children: props.label }), badge !== void 0 && badge > 0 && _jsx2("span", { className: "vx-button-badge", children: badge }), trailingIcon && _jsx2("span", { className: "vx-button-trailing", children: _jsx2(Icon, { name: trailingIcon }) })] });
|
|
423
429
|
}
|
|
424
430
|
function IconButton({ icon, variant = "icon-ghost-sm", ...props }) {
|
|
425
431
|
return _jsx2(ButtonFrame, { ...props, variant, children: _jsx2(Icon, { name: icon }) });
|
|
@@ -444,9 +450,9 @@ import { jsx as _jsx5, jsxs as _jsxs3, Fragment as _Fragment } from "react/jsx-r
|
|
|
444
450
|
var clamp = (value, min, max) => Math.min(max, Math.max(min, value));
|
|
445
451
|
function timeLabel(seconds) {
|
|
446
452
|
const whole = Math.floor(seconds);
|
|
447
|
-
return `${Math.floor(whole / 60)}:${String(whole % 60).padStart(2, "0")}`;
|
|
453
|
+
return `${String(Math.floor(whole / 60)).padStart(2, "0")}:${String(whole % 60).padStart(2, "0")}`;
|
|
448
454
|
}
|
|
449
|
-
function FrameRange({ duration, thumbnail, value, step = 0.1, variant = "range", onValueChange }) {
|
|
455
|
+
function FrameRange({ duration, thumbnail, frames, value, step = 0.1, variant = "range", onValueChange }) {
|
|
450
456
|
const length = Number.isFinite(duration) && duration > 0 ? duration : 0;
|
|
451
457
|
const increment = Math.min(length, Number.isFinite(step) && step > 0 ? step : 0.1);
|
|
452
458
|
const start = clamp(Number.isFinite(value.start) ? value.start : 0, 0, length - increment);
|
|
@@ -482,7 +488,7 @@ function FrameRange({ duration, thumbnail, value, step = 0.1, variant = "range",
|
|
|
482
488
|
return _jsxs3("div", { className: "vx-frame-range", "data-variant": variant, role: "group", "aria-label": "Playback range", "aria-disabled": !length, style: length ? {
|
|
483
489
|
"--vx-range-start": `${start / length * 100}%`,
|
|
484
490
|
"--vx-range-end": `${end / length * 100}%`
|
|
485
|
-
} : void 0, children: [thumbnail && length > 0 && _jsx5("img", { src: thumbnail, alt: "" }), length > 0 && _jsxs3(_Fragment, { children: [_jsx5("span", { className: "vx-frame-selection", "aria-hidden": "true", children: _jsxs3(Tag, { children: [timeLabel(start), " \u2013 ", timeLabel(end)] }) }), ["start", "end"].map((edge) => {
|
|
491
|
+
} : void 0, children: [frames?.length && length > 0 ? _jsx5("div", { className: "vx-frame-filmstrip", children: frames.map((src, index) => _jsx5("img", { src, alt: "" }, index)) }) : thumbnail && length > 0 && _jsx5("img", { src: thumbnail, alt: "" }), length > 0 && _jsxs3(_Fragment, { children: [_jsx5("span", { className: "vx-frame-selection", "aria-hidden": "true", children: _jsxs3(Tag, { children: [timeLabel(start), " \u2013 ", timeLabel(end)] }) }), ["start", "end"].map((edge) => {
|
|
486
492
|
const current = edge === "start" ? start : end;
|
|
487
493
|
return _jsx5("div", { tabIndex: 0, role: "slider", className: "vx-frame-handle", "data-edge": edge, "aria-label": edge === "start" ? "Range start" : "Range end", "aria-valuemin": edge === "start" ? 0 : start + increment, "aria-valuemax": edge === "start" ? end - increment : length, "aria-valuenow": current, "aria-valuetext": `${Number(current.toFixed(3))} seconds`, onKeyDown: (event) => handleKey(event, edge, current), onPointerDown: (event) => {
|
|
488
494
|
if (event.button !== 0)
|
|
@@ -595,10 +601,13 @@ import { createPortal as createPortal2 } from "react-dom";
|
|
|
595
601
|
function isEnabled(item) {
|
|
596
602
|
return !item.disabled && item.items?.length !== 0;
|
|
597
603
|
}
|
|
598
|
-
function Menu({ label, items, triggerIcon, floating = false }) {
|
|
604
|
+
function Menu({ label, items, triggerIcon, floating = false, cascading = false }) {
|
|
599
605
|
const id = useId3();
|
|
600
606
|
const trigger = useRef2(null);
|
|
601
607
|
const popup = useRef2(null);
|
|
608
|
+
const children = useRef2(/* @__PURE__ */ new Map());
|
|
609
|
+
const focusOnOpen = useRef2(true);
|
|
610
|
+
const cascade = floating && cascading;
|
|
602
611
|
const focusIndex = useRef2(0);
|
|
603
612
|
const [path, setPath] = useState2(null);
|
|
604
613
|
const [placement, setPlacement] = useState2({ visibility: "hidden" });
|
|
@@ -620,19 +629,38 @@ function Menu({ label, items, triggerIcon, floating = false }) {
|
|
|
620
629
|
const flip = naturalHeight > below && above > below;
|
|
621
630
|
const maxHeight = Math.max(0, Math.min(480, height - 16, flip ? above : below));
|
|
622
631
|
const menuHeight = Math.min(naturalHeight, maxHeight);
|
|
632
|
+
const left = Math.max(8, Math.min(rect.right - bounds.width, width - bounds.width - 8));
|
|
633
|
+
const top = Math.max(8, Math.min(flip ? rect.top - menuHeight - 4 : rect.bottom + 4, height - menuHeight - 8));
|
|
623
634
|
setPlacement({
|
|
624
635
|
position: "fixed",
|
|
625
636
|
visibility: "visible",
|
|
626
637
|
insetInlineStart: "auto",
|
|
627
|
-
left
|
|
628
|
-
top
|
|
638
|
+
left,
|
|
639
|
+
top,
|
|
629
640
|
maxHeight,
|
|
630
641
|
zIndex: 100
|
|
631
642
|
});
|
|
643
|
+
let parent = menu2, parentLeft = left, parentTop = top;
|
|
644
|
+
for (let depth = 1; cascade && depth <= path.length; depth++) {
|
|
645
|
+
const panel = children.current.get(depth);
|
|
646
|
+
const item = Array.from(parent.querySelectorAll("button")).find((b) => b.dataset.key === path[depth - 1]);
|
|
647
|
+
if (!panel || !item)
|
|
648
|
+
break;
|
|
649
|
+
const parentBox = parent.getBoundingClientRect(), box = panel.getBoundingClientRect();
|
|
650
|
+
const nextLeft = parentLeft + parentBox.width;
|
|
651
|
+
parentLeft = Math.max(8, Math.min(nextLeft + box.width <= width - 8 ? nextLeft : parentLeft - box.width, width - box.width - 8));
|
|
652
|
+
parentTop = Math.max(8, Math.min(parentTop + item.getBoundingClientRect().top - parentBox.top - 4, height - box.height - 8));
|
|
653
|
+
Object.assign(panel.style, {
|
|
654
|
+
left: parentLeft + "px",
|
|
655
|
+
top: parentTop + "px",
|
|
656
|
+
visibility: "visible"
|
|
657
|
+
});
|
|
658
|
+
parent = panel;
|
|
659
|
+
}
|
|
632
660
|
};
|
|
633
661
|
const outside = (event) => {
|
|
634
662
|
const path2 = event.composedPath();
|
|
635
|
-
if (!path2.includes(trigger.current) && !path2.includes(popup.current))
|
|
663
|
+
if (!path2.includes(trigger.current) && !path2.includes(popup.current) && ![...children.current.values()].some((panel) => path2.includes(panel)))
|
|
636
664
|
setPath(null);
|
|
637
665
|
};
|
|
638
666
|
const document2 = portalRoot.ownerDocument;
|
|
@@ -646,21 +674,23 @@ function Menu({ label, items, triggerIcon, floating = false }) {
|
|
|
646
674
|
window.removeEventListener("scroll", position, true);
|
|
647
675
|
document2.removeEventListener("pointerdown", outside);
|
|
648
676
|
};
|
|
649
|
-
}, [floating, path, portalRoot]);
|
|
677
|
+
}, [floating, path, portalRoot, cascade]);
|
|
650
678
|
let entries = items;
|
|
651
679
|
let menuLabel = label;
|
|
680
|
+
const levels = [{ entries, menuLabel }];
|
|
652
681
|
for (const key of path ?? []) {
|
|
653
682
|
const entry = entries.find((item) => item.id === key);
|
|
654
683
|
if (!entry?.items)
|
|
655
684
|
break;
|
|
656
685
|
menuLabel = entry.label;
|
|
657
686
|
entries = entry.items;
|
|
687
|
+
levels.push({ entries, menuLabel });
|
|
658
688
|
}
|
|
659
|
-
function buttons() {
|
|
660
|
-
return [...
|
|
689
|
+
function buttons(panel = cascade && path?.length ? children.current.get(path.length) : popup.current) {
|
|
690
|
+
return [...panel?.querySelectorAll("button:not(:disabled)") ?? []];
|
|
661
691
|
}
|
|
662
692
|
useEffect(() => {
|
|
663
|
-
if (path && (!floating || !portalRoot || placement.visibility === "visible"))
|
|
693
|
+
if (focusOnOpen.current && path && (!floating || !portalRoot || placement.visibility === "visible"))
|
|
664
694
|
buttons().at(focusIndex.current)?.focus();
|
|
665
695
|
}, [path, floating && placement.visibility, portalRoot]);
|
|
666
696
|
function close() {
|
|
@@ -668,6 +698,7 @@ function Menu({ label, items, triggerIcon, floating = false }) {
|
|
|
668
698
|
trigger.current?.focus();
|
|
669
699
|
}
|
|
670
700
|
function back() {
|
|
701
|
+
focusOnOpen.current = true;
|
|
671
702
|
if (!path?.length)
|
|
672
703
|
return;
|
|
673
704
|
const parentPath = path.slice(0, -1);
|
|
@@ -675,24 +706,27 @@ function Menu({ label, items, triggerIcon, floating = false }) {
|
|
|
675
706
|
focusIndex.current = Math.max(0, parent.filter(isEnabled).findIndex((item) => item.id === path.at(-1)));
|
|
676
707
|
setPath(parentPath);
|
|
677
708
|
}
|
|
678
|
-
function choose(item) {
|
|
709
|
+
function choose(item, depth) {
|
|
710
|
+
focusOnOpen.current = true;
|
|
679
711
|
if (item.items?.length) {
|
|
680
712
|
focusIndex.current = 0;
|
|
681
|
-
setPath([...path ?? [], item.id]);
|
|
713
|
+
setPath([...(path ?? []).slice(0, depth), item.id]);
|
|
714
|
+
if (cascade && path?.[depth] === item.id)
|
|
715
|
+
buttons(children.current.get(depth + 1))?.at(0)?.focus();
|
|
682
716
|
} else if (item.onSelect) {
|
|
683
717
|
if (item.checked === void 0)
|
|
684
718
|
close();
|
|
685
719
|
item.onSelect();
|
|
686
720
|
}
|
|
687
721
|
}
|
|
688
|
-
function handleKey(event) {
|
|
722
|
+
function handleKey(event, depth) {
|
|
689
723
|
if (event.key === "Tab" && floating && portalRoot) {
|
|
690
724
|
if (event.shiftKey)
|
|
691
725
|
event.preventDefault();
|
|
692
726
|
close();
|
|
693
727
|
return;
|
|
694
728
|
}
|
|
695
|
-
const available = buttons();
|
|
729
|
+
const available = buttons(event.currentTarget);
|
|
696
730
|
const index = available.findIndex((button) => button === event.target);
|
|
697
731
|
if (event.key === "Escape") {
|
|
698
732
|
event.preventDefault();
|
|
@@ -709,10 +743,10 @@ function Menu({ label, items, triggerIcon, floating = false }) {
|
|
|
709
743
|
return;
|
|
710
744
|
}
|
|
711
745
|
if (event.key === "ArrowRight") {
|
|
712
|
-
const item = entries.filter(isEnabled)[index];
|
|
746
|
+
const item = levels[depth]?.entries.filter(isEnabled)[index];
|
|
713
747
|
if (item?.items?.length) {
|
|
714
748
|
event.preventDefault();
|
|
715
|
-
choose(item);
|
|
749
|
+
choose(item, depth);
|
|
716
750
|
}
|
|
717
751
|
return;
|
|
718
752
|
}
|
|
@@ -728,6 +762,7 @@ function Menu({ label, items, triggerIcon, floating = false }) {
|
|
|
728
762
|
}
|
|
729
763
|
}
|
|
730
764
|
function open(index = 0) {
|
|
765
|
+
focusOnOpen.current = true;
|
|
731
766
|
focusIndex.current = index;
|
|
732
767
|
setPath([]);
|
|
733
768
|
}
|
|
@@ -737,37 +772,67 @@ function Menu({ label, items, triggerIcon, floating = false }) {
|
|
|
737
772
|
open(event.key === "ArrowUp" ? -1 : 0);
|
|
738
773
|
}
|
|
739
774
|
}
|
|
740
|
-
|
|
775
|
+
function hover(item, depth) {
|
|
776
|
+
if (!cascade || !path)
|
|
777
|
+
return;
|
|
778
|
+
const next = path.slice(0, depth);
|
|
779
|
+
if (item.items?.length && isEnabled(item))
|
|
780
|
+
next.push(item.id);
|
|
781
|
+
if (next.length === path.length && next.every((key, i) => path[i] === key))
|
|
782
|
+
return;
|
|
783
|
+
focusOnOpen.current = false;
|
|
784
|
+
setPath(next);
|
|
785
|
+
}
|
|
786
|
+
const menu = levels.map(({ entries: entries2, menuLabel: menuLabel2 }, depth) => !cascade && depth !== levels.length - 1 ? null : _jsx7("div", { ref: !cascade || depth === 0 ? popup : (el) => {
|
|
787
|
+
if (el)
|
|
788
|
+
children.current.set(depth, el);
|
|
789
|
+
else
|
|
790
|
+
children.current.delete(depth);
|
|
791
|
+
}, className: "vx-action-menu-items", role: "menu", id: !cascade || !depth ? id : id + "-" + depth, "aria-label": menuLabel2, hidden: !path, onKeyDown: (e) => handleKey(e, depth), "data-floating": floating || void 0, style: floating && portalRoot ? cascade && depth ? {
|
|
792
|
+
position: "fixed",
|
|
793
|
+
insetInlineStart: "auto",
|
|
794
|
+
visibility: "hidden",
|
|
795
|
+
maxHeight: "min(480px, calc(100dvh - 16px))",
|
|
796
|
+
zIndex: 100 + depth
|
|
797
|
+
} : placement : void 0, children: entries2.map((item) => _jsxs5("button", { type: "button", role: item.checked === void 0 ? "menuitem" : "menuitemcheckbox", "aria-checked": item.checked, "aria-haspopup": item.items?.length ? "menu" : void 0, "data-key": item.id, "aria-expanded": cascade && item.items ? path?.[depth] === item.id : void 0, onPointerEnter: cascade ? (e) => {
|
|
798
|
+
if (e.pointerType !== "touch")
|
|
799
|
+
hover(item, depth);
|
|
800
|
+
} : void 0, "data-size": item.size ?? "medium", "data-tone": item.tone, disabled: !isEnabled(item), tabIndex: -1, onClick: () => choose(item, depth), children: [item.icon && _jsx7(Icon, { name: item.icon }), _jsx7("span", { children: item.label }), item.checked && _jsx7(Icon, { name: "check" }), item.items?.length ? _jsx7(Icon, { name: "chevron-right" }) : null] }, item.id)) }, depth));
|
|
741
801
|
return _jsxs5("div", { className: "vx-action-menu", onBlur: (event) => {
|
|
742
|
-
if (!event.currentTarget.contains(event.relatedTarget) && !(floating && popup.current?.contains(event.relatedTarget)))
|
|
802
|
+
if (!event.currentTarget.contains(event.relatedTarget) && !(floating && popup.current?.contains(event.relatedTarget)) && ![...children.current.values()].some((panel) => panel.contains(event.relatedTarget)))
|
|
743
803
|
setPath(null);
|
|
744
804
|
}, children: [triggerIcon ? _jsx7(IconButton, { ref: trigger, label, icon: triggerIcon, variant: "icon-ghost-sm", "aria-haspopup": "menu", "aria-controls": id, "aria-expanded": path !== null, disabled: !items.some(isEnabled), onClick: () => path ? close() : open(), onKeyDown: triggerKey }) : _jsx7(Button, { ref: trigger, label, variant: "text-tonal-sm", trailingIcon: "chevron-down", "aria-haspopup": "menu", "aria-controls": id, "aria-expanded": path !== null, disabled: !items.some(isEnabled), onClick: () => path ? close() : open(), onKeyDown: triggerKey }), portalRoot ? createPortal2(menu, portalRoot) : menu] });
|
|
745
805
|
}
|
|
746
806
|
|
|
747
807
|
// packages/ui-system/dist/video-player.js
|
|
748
|
-
import { jsx as _jsx8, jsxs as _jsxs6 } from "react/jsx-runtime";
|
|
808
|
+
import { jsx as _jsx8, jsxs as _jsxs6, Fragment as _Fragment3 } from "react/jsx-runtime";
|
|
749
809
|
import { useEffect as useEffect2, useRef as useRef3, useState as useState3 } from "react";
|
|
750
|
-
function timeLabel2(seconds) {
|
|
810
|
+
function timeLabel2(seconds, padMinutes = false) {
|
|
751
811
|
const whole = Math.floor(seconds);
|
|
752
|
-
|
|
812
|
+
const minutes = String(Math.floor(whole / 60));
|
|
813
|
+
return `${padMinutes ? minutes.padStart(2, "0") : minutes}:${String(whole % 60).padStart(2, "0")}`;
|
|
753
814
|
}
|
|
754
|
-
function PlaybackControls({ playing, muted, time, duration, size = "medium", disabled, onTogglePlay, onToggleMute, onSeek, onFullscreen }) {
|
|
755
|
-
return _jsxs6("div", { className: "vx-playback-controls", role: "group", "aria-label": "Playback controls", "data-size": size, style: {
|
|
815
|
+
function PlaybackControls({ playing, muted, time, duration, size = "medium", disabled, onTogglePlay, onToggleMute, onSeek, onFullscreen, fullscreenLabel = "Toggle fullscreen", actions, appearance = "on-content", timeDisplay = "combined" }) {
|
|
816
|
+
return _jsxs6("div", { className: "vx-playback-controls", role: "group", "aria-label": "Playback controls", "data-size": size, "data-appearance": appearance, style: {
|
|
756
817
|
"--vx-playback-progress": `${duration > 0 ? Math.min(100, Math.max(0, time / duration * 100)) : 0}%`
|
|
757
|
-
}, children: [_jsx8(IconButton, { icon: playing ? size === "large" ? "pause-large" : "pause" : size === "large" ? "playback-play-large" : "playback-play", label: playing ? "Pause" : "Play", disabled, onClick: onTogglePlay }), _jsx8("input", { "aria-label": "Playback position", "aria-valuetext": `${timeLabel2(time)} of ${timeLabel2(duration)}`, type: "range", min: 0, max: duration, value: time, step: "any", disabled: disabled || !duration, onChange: (event) => onSeek(event.currentTarget.valueAsNumber) }),
|
|
818
|
+
}, children: [_jsx8(IconButton, { icon: playing ? size === "large" ? "pause-large" : "pause" : size === "large" ? "playback-play-large" : "playback-play", label: playing ? "Pause" : "Play", disabled, onClick: onTogglePlay }), timeDisplay === "split" && _jsx8("span", { "aria-hidden": "true", "data-time": "elapsed", children: timeLabel2(time, true) }), _jsx8("input", { "aria-label": "Playback position", "aria-valuetext": `${timeLabel2(time)} of ${timeLabel2(duration)}`, type: "range", min: 0, max: duration, value: time, step: "any", disabled: disabled || !duration, onChange: (event) => onSeek(event.currentTarget.valueAsNumber) }), _jsx8("span", { "aria-hidden": "true", "data-time": timeDisplay === "split" ? "duration" : void 0, children: timeDisplay === "split" ? timeLabel2(duration, true) : `${timeLabel2(time)} / ${timeLabel2(duration)}` }), _jsx8(IconButton, { icon: muted ? size === "large" ? "mute-large" : "mute" : size === "large" ? "volume-large" : "volume", label: muted ? "Unmute" : "Mute", disabled, onClick: onToggleMute }), actions, onFullscreen && _jsx8(IconButton, { icon: size === "large" ? "fullscreen-large" : "fullscreen", label: fullscreenLabel, onClick: onFullscreen })] });
|
|
758
819
|
}
|
|
759
820
|
function VideoPlayer(props) {
|
|
760
821
|
return _jsx8(Playback, { ...props }, JSON.stringify([props.src, props.poster, props.posterDuration]));
|
|
761
822
|
}
|
|
762
|
-
function Playback({ src, poster, posterDuration = 0, title, version, durationLabel, sceneLabel, defaultMuted = false, controlsPlacement = "overlay", controlsSize, showFullscreen = true, overlay, onBeforePlay, onStateChange, onTimeChange, onEnded, onError }) {
|
|
823
|
+
function Playback({ src, poster, aspectRatio, posterDuration = 0, title, version, durationLabel, sceneLabel, defaultMuted = false, controlsPlacement = "overlay", fitContent = false, controlsSize, timeDisplay, controlsActions, showFullscreen = true, fullscreenMode = "native", overlay, onBeforePlay, onStateChange, onTimeChange, onEnded, onError }) {
|
|
763
824
|
const root = useRef3(null);
|
|
764
825
|
const video = useRef3(null);
|
|
765
826
|
const position = useRef3(0);
|
|
766
827
|
const callbacks = useRef3({ onTimeChange, onStateChange, onEnded });
|
|
767
828
|
const [time, setTime] = useState3(0);
|
|
829
|
+
const [ratio, setRatio] = useState3(16 / 9);
|
|
768
830
|
const [metadataDuration, setMetadataDuration] = useState3(0);
|
|
769
831
|
const [state, setState] = useState3("cover");
|
|
770
832
|
const [muted, setMuted] = useState3(defaultMuted);
|
|
833
|
+
const [expanded, setExpanded] = useState3(false);
|
|
834
|
+
const [inlineHeight, setInlineHeight] = useState3();
|
|
835
|
+
const restore = useRef3(void 0);
|
|
771
836
|
const stillDuration = poster && Number.isFinite(posterDuration) ? Math.max(0, posterDuration) : 0;
|
|
772
837
|
const duration = src ? metadataDuration : stillDuration;
|
|
773
838
|
useEffect2(() => {
|
|
@@ -779,7 +844,7 @@ function Playback({ src, poster, posterDuration = 0, title, version, durationLab
|
|
|
779
844
|
element.removeAttribute("src");
|
|
780
845
|
element.load();
|
|
781
846
|
};
|
|
782
|
-
}, []);
|
|
847
|
+
}, [expanded, src]);
|
|
783
848
|
function updateTime(next) {
|
|
784
849
|
position.current = next;
|
|
785
850
|
setTime(next);
|
|
@@ -838,25 +903,66 @@ function Playback({ src, poster, posterDuration = 0, title, version, durationLab
|
|
|
838
903
|
updateTime(seconds);
|
|
839
904
|
}
|
|
840
905
|
async function toggleFullscreen() {
|
|
906
|
+
if (fullscreenMode === "dialog") {
|
|
907
|
+
changeExpanded(!expanded);
|
|
908
|
+
return;
|
|
909
|
+
}
|
|
841
910
|
try {
|
|
842
|
-
const
|
|
843
|
-
if (!
|
|
911
|
+
const player2 = root.current;
|
|
912
|
+
if (!player2?.requestFullscreen)
|
|
844
913
|
return;
|
|
845
|
-
if (
|
|
846
|
-
await
|
|
914
|
+
if (player2.ownerDocument.fullscreenElement === player2)
|
|
915
|
+
await player2.ownerDocument.exitFullscreen();
|
|
847
916
|
else
|
|
848
|
-
await
|
|
917
|
+
await player2.requestFullscreen();
|
|
849
918
|
} catch (error) {
|
|
850
919
|
onError?.(error);
|
|
851
920
|
}
|
|
852
921
|
}
|
|
853
|
-
|
|
922
|
+
function changeExpanded(next) {
|
|
923
|
+
const element = video.current;
|
|
924
|
+
restore.current = {
|
|
925
|
+
time: element?.currentTime ?? position.current,
|
|
926
|
+
playing: element ? !element.paused : state === "playing",
|
|
927
|
+
state
|
|
928
|
+
};
|
|
929
|
+
if (next)
|
|
930
|
+
setInlineHeight(root.current?.getBoundingClientRect().height);
|
|
931
|
+
element?.pause();
|
|
932
|
+
setExpanded(next);
|
|
933
|
+
}
|
|
934
|
+
const player = _jsxs6("section", { ref: root, className: "vx-video-player", "aria-label": title, "data-fit": fitContent ? "content" : void 0, style: fitContent ? { "--vx-video-ratio": ratio } : void 0, "data-placement": controlsPlacement, "data-state": state, children: [_jsxs6("div", { className: "vx-video-stage", style: aspectRatio ? { aspectRatio } : void 0, children: [src ? _jsx8("video", { ref: video, src, poster, muted, playsInline: true, preload: "metadata", onResize: (event) => {
|
|
935
|
+
const { videoWidth, videoHeight } = event.currentTarget;
|
|
936
|
+
if (fitContent && videoWidth && videoHeight)
|
|
937
|
+
setRatio(videoWidth / videoHeight);
|
|
938
|
+
}, onLoadedMetadata: (event) => {
|
|
939
|
+
const element = event.currentTarget;
|
|
940
|
+
const { videoWidth, videoHeight } = element;
|
|
941
|
+
if (fitContent && videoWidth && videoHeight)
|
|
942
|
+
setRatio(videoWidth / videoHeight);
|
|
943
|
+
const previous = restore.current;
|
|
944
|
+
if (!previous)
|
|
945
|
+
return;
|
|
946
|
+
element.currentTime = Math.min(previous.time, element.duration);
|
|
947
|
+
updateTime(element.currentTime);
|
|
948
|
+
restore.current = void 0;
|
|
949
|
+
if (previous.playing)
|
|
950
|
+
void element.play().catch(() => changeState("paused"));
|
|
951
|
+
else
|
|
952
|
+
changeState(previous.state);
|
|
953
|
+
}, onDurationChange: (event) => {
|
|
854
954
|
const value = event.currentTarget.duration;
|
|
855
955
|
setMetadataDuration(Number.isFinite(value) ? value : 0);
|
|
856
956
|
}, onPlay: () => changeState("playing"), onPause: (event) => {
|
|
957
|
+
if (restore.current)
|
|
958
|
+
return;
|
|
857
959
|
updateTime(event.currentTarget.currentTime);
|
|
858
960
|
changeState("paused");
|
|
859
|
-
}, onTimeUpdate: (event) =>
|
|
961
|
+
}, onTimeUpdate: (event) => {
|
|
962
|
+
if (!restore.current)
|
|
963
|
+
updateTime(event.currentTarget.currentTime);
|
|
964
|
+
}, onEnded, onError: (event) => onError?.(event.currentTarget.error) }) : poster && _jsx8("img", { src: poster, alt: "" }), overlay, state === "cover" && !fitContent && _jsxs6("div", { className: "vx-video-cover", children: [_jsxs6("div", { className: "vx-video-info", children: [_jsxs6("div", { className: "vx-video-title", children: [_jsx8("strong", { title, children: title }), version && _jsx8(Tag, { children: version })] }), (durationLabel || sceneLabel) && _jsxs6("div", { className: "vx-video-meta", children: [durationLabel && _jsx8("span", { children: durationLabel }), durationLabel && sceneLabel && _jsx8("span", { "aria-hidden": "true", children: "\xB7" }), sceneLabel && _jsx8("span", { children: sceneLabel })] })] }), (src || duration > 0) && _jsx8(IconButton, { icon: "play-cover", className: "vx-video-start", label: `Play ${title}`, variant: "icon-circle-lg", onClick: togglePlay })] })] }), _jsx8(PlaybackControls, { playing: state === "playing", muted, time: Math.min(time, duration), duration, disabled: !src && !duration, size: controlsSize, timeDisplay, actions: controlsActions, onTogglePlay: togglePlay, onToggleMute: () => setMuted(!muted), onSeek: seek, onFullscreen: showFullscreen ? () => void toggleFullscreen() : void 0, fullscreenLabel: fullscreenMode === "dialog" ? expanded ? "Close expanded video" : "Expand video" : void 0 })] });
|
|
965
|
+
return _jsxs6(_Fragment3, { children: [expanded ? _jsx8("div", { "aria-hidden": "true", style: { height: inlineHeight } }) : player, _jsx8(Dialog, { title, open: expanded, onOpenChange: changeExpanded, className: "vx-video-dialog", children: expanded && player })] });
|
|
860
966
|
}
|
|
861
967
|
|
|
862
968
|
// packages/media-tools/src/ui/recipe-player.tsx
|