@vivix-labs/short-drama-compare 1.0.0-beta.2 → 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/client-code.css +73 -18
- package/dist/client-code.js +270 -341
- package/package.json +2 -2
package/dist/client-code.css
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* packages/short-drama-compare/src/styles.css */
|
|
2
|
-
@scope (.drama-
|
|
2
|
+
@scope (.drama-compare-view) {
|
|
3
3
|
:scope {
|
|
4
4
|
display: grid;
|
|
5
5
|
grid-template-columns: minmax(0, 1fr);
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
min-block-size: calc(100dvh - 112px);
|
|
11
11
|
align-content: start;
|
|
12
12
|
gap: var(--vx-space-8);
|
|
13
|
-
padding: var(--vx-space-8) var(--vx-space-
|
|
13
|
+
padding: 0 var(--vx-space-8) var(--vx-space-8);
|
|
14
14
|
border-radius: var(--vx-radius-xl);
|
|
15
15
|
background: var(--vx-background-dialog);
|
|
16
16
|
}
|
|
@@ -48,13 +48,16 @@
|
|
|
48
48
|
min-inline-size: 0;
|
|
49
49
|
max-inline-size: 100%;
|
|
50
50
|
padding: var(--vx-space-6) var(--vx-space-8);
|
|
51
|
-
border:
|
|
51
|
+
border: 0;
|
|
52
52
|
border-radius: var(--vx-radius-md);
|
|
53
53
|
color: var(--vx-text-primary);
|
|
54
54
|
background: var(--vx-surface-input);
|
|
55
55
|
font: var(--vx-typography-inter-14-regular);
|
|
56
56
|
}
|
|
57
|
-
label >
|
|
57
|
+
label > select {
|
|
58
|
+
border: var(--vx-border-width) solid var(--vx-border-primary);
|
|
59
|
+
}
|
|
60
|
+
label > select:focus-visible {
|
|
58
61
|
outline: var(--vx-focus-ring-width) solid var(--vx-blue-light);
|
|
59
62
|
outline-offset: 2px;
|
|
60
63
|
}
|
|
@@ -113,7 +116,7 @@
|
|
|
113
116
|
display: grid;
|
|
114
117
|
grid-template-columns: repeat(5, minmax(10rem, 1fr));
|
|
115
118
|
gap: var(--vx-space-12);
|
|
116
|
-
overflow-x:
|
|
119
|
+
overflow-x: scroll;
|
|
117
120
|
padding-block: var(--vx-space-4) var(--vx-space-12);
|
|
118
121
|
}
|
|
119
122
|
.drama-board > section {
|
|
@@ -315,7 +318,7 @@
|
|
|
315
318
|
display: block;
|
|
316
319
|
margin-block-end: var(--vx-space-4);
|
|
317
320
|
font: var(--vx-typography-inter-18-semi-bold);
|
|
318
|
-
font-weight:
|
|
321
|
+
font-weight: 600;
|
|
319
322
|
}
|
|
320
323
|
.drama-player-cover-meta {
|
|
321
324
|
display: flex;
|
|
@@ -337,7 +340,7 @@
|
|
|
337
340
|
grid-auto-flow: column;
|
|
338
341
|
grid-auto-columns: 160px;
|
|
339
342
|
gap: var(--vx-space-8);
|
|
340
|
-
overflow-x:
|
|
343
|
+
overflow-x: scroll;
|
|
341
344
|
padding: var(--vx-space-4) var(--vx-space-16) var(--vx-space-16);
|
|
342
345
|
}
|
|
343
346
|
.drama-filmstrip-viewport {
|
|
@@ -389,7 +392,7 @@
|
|
|
389
392
|
}
|
|
390
393
|
}
|
|
391
394
|
}
|
|
392
|
-
@scope (.
|
|
395
|
+
@scope (.drama-compare-view) {
|
|
393
396
|
.drama-episode-actions {
|
|
394
397
|
display: flex;
|
|
395
398
|
justify-content: end;
|
|
@@ -443,7 +446,7 @@
|
|
|
443
446
|
.drama-filmstrip-status {
|
|
444
447
|
margin: 0;
|
|
445
448
|
padding: var(--vx-space-12) var(--vx-space-16);
|
|
446
|
-
border-block-start: var(--vx-
|
|
449
|
+
border-block-start: var(--vx-divider-width) solid var(--vx-border-secondary);
|
|
447
450
|
color: var(--vx-text-secondary-readable);
|
|
448
451
|
font: var(--vx-typography-inter-12-regular);
|
|
449
452
|
}
|
|
@@ -550,7 +553,7 @@
|
|
|
550
553
|
overflow-wrap: anywhere;
|
|
551
554
|
}
|
|
552
555
|
}
|
|
553
|
-
@scope (.
|
|
556
|
+
@scope (.drama-compare-view) {
|
|
554
557
|
.drama-reference-heading {
|
|
555
558
|
display: flex;
|
|
556
559
|
justify-content: space-between;
|
|
@@ -575,7 +578,7 @@
|
|
|
575
578
|
height: 32px;
|
|
576
579
|
}
|
|
577
580
|
}
|
|
578
|
-
@scope (.drama-
|
|
581
|
+
@scope (.drama-compare-view) {
|
|
579
582
|
.drama-shot-layout {
|
|
580
583
|
grid-template-columns: 320px minmax(0, 1fr) 280px;
|
|
581
584
|
gap: 8px;
|
|
@@ -602,7 +605,7 @@
|
|
|
602
605
|
.drama-scene-variants footer {
|
|
603
606
|
margin-top: auto;
|
|
604
607
|
padding-top: 12px;
|
|
605
|
-
border-top:
|
|
608
|
+
border-top: var(--vx-divider-width) solid var(--vx-border-secondary);
|
|
606
609
|
font-size: 12px;
|
|
607
610
|
color: var(--vx-text-secondary);
|
|
608
611
|
}
|
|
@@ -673,7 +676,7 @@
|
|
|
673
676
|
grid-auto-flow: column;
|
|
674
677
|
grid-auto-columns: 120px;
|
|
675
678
|
grid-template-columns: none;
|
|
676
|
-
overflow-x:
|
|
679
|
+
overflow-x: scroll;
|
|
677
680
|
}
|
|
678
681
|
.drama-shot-layout > aside:last-child:not(:first-child) {
|
|
679
682
|
grid-column: auto;
|
|
@@ -684,9 +687,11 @@
|
|
|
684
687
|
}
|
|
685
688
|
}
|
|
686
689
|
}
|
|
687
|
-
@scope (.drama-
|
|
690
|
+
@scope (.drama-compare-view) {
|
|
688
691
|
.drama-compare-bar {
|
|
689
|
-
|
|
692
|
+
box-sizing: border-box;
|
|
693
|
+
min-height: 56px;
|
|
694
|
+
padding: 0 4px 0 8px;
|
|
690
695
|
margin: 0;
|
|
691
696
|
}
|
|
692
697
|
.drama-compare-bar h2 {
|
|
@@ -696,8 +701,12 @@
|
|
|
696
701
|
.drama-compare-selection {
|
|
697
702
|
display: flex;
|
|
698
703
|
gap: 8px;
|
|
699
|
-
|
|
700
|
-
|
|
704
|
+
align-items: center;
|
|
705
|
+
flex-wrap: wrap;
|
|
706
|
+
padding: 0 8px 8px;
|
|
707
|
+
}
|
|
708
|
+
.drama-compare-selection:empty {
|
|
709
|
+
display: none;
|
|
701
710
|
}
|
|
702
711
|
.drama-compare-selection .vx-dropdown {
|
|
703
712
|
min-width: 0;
|
|
@@ -738,13 +747,59 @@
|
|
|
738
747
|
gap: 4px;
|
|
739
748
|
margin: 0 8px;
|
|
740
749
|
padding-top: 12px;
|
|
741
|
-
border-top:
|
|
750
|
+
border-top: var(--vx-divider-width) solid var(--vx-border-secondary);
|
|
742
751
|
font-size: 14px;
|
|
743
752
|
line-height: 20px;
|
|
744
753
|
}
|
|
745
754
|
.drama-compare-metadata dd {
|
|
746
755
|
margin-bottom: 8px;
|
|
747
756
|
}
|
|
757
|
+
.drama-compare-version {
|
|
758
|
+
display: flex;
|
|
759
|
+
align-items: center;
|
|
760
|
+
gap: var(--vx-space-8);
|
|
761
|
+
padding-block: var(--vx-space-4) var(--vx-space-8);
|
|
762
|
+
color: var(--vx-text-secondary-readable);
|
|
763
|
+
font: var(--vx-typography-inter-12-medium);
|
|
764
|
+
}
|
|
765
|
+
.drama-compare-version select {
|
|
766
|
+
max-width: 100%;
|
|
767
|
+
min-width: 0;
|
|
768
|
+
min-block-size: 28px;
|
|
769
|
+
padding: var(--vx-space-4) var(--vx-space-8);
|
|
770
|
+
font: inherit;
|
|
771
|
+
}
|
|
772
|
+
.drama-compare-whole .drama-filmstrip {
|
|
773
|
+
padding-inline: 0;
|
|
774
|
+
padding-block-end: var(--vx-space-12);
|
|
775
|
+
}
|
|
776
|
+
.drama-compare-whole .drama-filmstrip > li > strong {
|
|
777
|
+
margin-inline: 0;
|
|
778
|
+
margin-block-start: var(--vx-space-4);
|
|
779
|
+
}
|
|
780
|
+
.drama-compare-whole .drama-player {
|
|
781
|
+
gap: 0;
|
|
782
|
+
}
|
|
783
|
+
.drama-compare-whole .drama-player-stage {
|
|
784
|
+
border-end-start-radius: 0;
|
|
785
|
+
border-end-end-radius: 0;
|
|
786
|
+
}
|
|
787
|
+
@media (min-width: 1040px) {
|
|
788
|
+
.drama-compare-whole .drama-player-stage {
|
|
789
|
+
min-block-size: clamp(320px, calc(100dvh - 424px), 520px);
|
|
790
|
+
}
|
|
791
|
+
}
|
|
792
|
+
.drama-compare-whole .drama-player > .vx-playback-controls {
|
|
793
|
+
gap: var(--vx-space-8);
|
|
794
|
+
border-start-start-radius: 0;
|
|
795
|
+
border-start-end-radius: 0;
|
|
796
|
+
background: var(--vx-black-black);
|
|
797
|
+
color: var(--vx-text-on-content-primary);
|
|
798
|
+
--vx-button-foreground: var(--vx-text-on-content-primary);
|
|
799
|
+
}
|
|
800
|
+
.drama-compare-whole .drama-player-viewport + .vx-playback-controls {
|
|
801
|
+
margin-block-end: var(--vx-space-4);
|
|
802
|
+
}
|
|
748
803
|
.drama-compare-scenes .drama-player {
|
|
749
804
|
margin: 0;
|
|
750
805
|
grid-template-rows: 1fr;
|
package/dist/client-code.js
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
import { z } from "vivix-studio/sdk/shared";
|
|
3
3
|
|
|
4
4
|
// packages/short-drama-compare/src/compare-view.tsx
|
|
5
|
-
import { useState as
|
|
5
|
+
import { useState as useState11 } from "react";
|
|
6
6
|
|
|
7
7
|
// packages/short-drama-compare/src/compare.tsx
|
|
8
|
-
import { useCallback, useMemo as useMemo2
|
|
8
|
+
import { useCallback, useMemo as useMemo2 } from "react";
|
|
9
9
|
|
|
10
10
|
// packages/ui-system/dist/button.js
|
|
11
11
|
import { jsx as _jsx2, jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -78,6 +78,8 @@ var iconGeometry = {
|
|
|
78
78
|
height: 15.5625,
|
|
79
79
|
slot: 18
|
|
80
80
|
},
|
|
81
|
+
"select-items": { width: 13.8681, height: 13.8667, slot: 16 },
|
|
82
|
+
filter: { width: 13.2, height: 13.2, slot: 16 },
|
|
81
83
|
select: {
|
|
82
84
|
width: 14.6298,
|
|
83
85
|
height: 16.065,
|
|
@@ -158,6 +160,9 @@ var iconGeometry = {
|
|
|
158
160
|
height: 13.2,
|
|
159
161
|
slot: 16
|
|
160
162
|
},
|
|
163
|
+
favorite: { width: 11.8667, height: 14.5333, slot: 16 },
|
|
164
|
+
download: { width: 13.2001, height: 13.1997, slot: 16 },
|
|
165
|
+
delete: { width: 13.2, height: 14.533, slot: 16 },
|
|
161
166
|
edit: {
|
|
162
167
|
width: 10.8791,
|
|
163
168
|
height: 12.0459,
|
|
@@ -218,6 +223,7 @@ var buttonVariants = {
|
|
|
218
223
|
"text-filled-leading-sm": { size: 32, appearance: "filled", shape: "text" },
|
|
219
224
|
"text-ghost-sm": { size: 32, appearance: "ghost", shape: "text" },
|
|
220
225
|
"text-on-content-sm": { size: 32, appearance: "on-content", shape: "text" },
|
|
226
|
+
"text-outline-sm": { size: 32, appearance: "outline", shape: "text" },
|
|
221
227
|
"text-tonal-sm": { size: 32, appearance: "tonal", shape: "text" },
|
|
222
228
|
// The medium recipes are shared by all dialog footer actions.
|
|
223
229
|
"text-filled-md": { size: 40, appearance: "filled", shape: "text" },
|
|
@@ -252,136 +258,82 @@ function ButtonFrame({ label, variant, loading = false, width, children, disable
|
|
|
252
258
|
const buttonStyle = "width" in spec ? { ...style, "--vx-button-width": `${spec.width}px` } : style;
|
|
253
259
|
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" })] });
|
|
254
260
|
}
|
|
255
|
-
function Button({ variant = "text-filled-sm", leadingIcon, trailingIcon, ...props }) {
|
|
256
|
-
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 }) })] });
|
|
261
|
+
function Button({ variant = "text-filled-sm", leadingIcon, trailingIcon, badge, ...props }) {
|
|
262
|
+
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 }) })] });
|
|
257
263
|
}
|
|
258
264
|
function IconButton({ icon, variant = "icon-ghost-sm", ...props }) {
|
|
259
265
|
return _jsx2(ButtonFrame, { ...props, variant, children: _jsx2(Icon, { name: icon }) });
|
|
260
266
|
}
|
|
261
267
|
|
|
262
|
-
// packages/ui-system/dist/
|
|
268
|
+
// packages/ui-system/dist/script-cover.js
|
|
263
269
|
import { jsx as _jsx3, jsxs as _jsxs2 } from "react/jsx-runtime";
|
|
264
|
-
import { useEffect,
|
|
265
|
-
function
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
const
|
|
269
|
-
const
|
|
270
|
-
|
|
271
|
-
const
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
270
|
+
import { useEffect, useState } from "react";
|
|
271
|
+
async function readTextExcerpt(response, signal, maxBytes = 1024) {
|
|
272
|
+
if (!response.ok || !response.body)
|
|
273
|
+
throw Error("The text preview could not be loaded.");
|
|
274
|
+
const reader = response.body.getReader();
|
|
275
|
+
const decoder = new TextDecoder();
|
|
276
|
+
let text = "", used = 0;
|
|
277
|
+
const cancel = () => {
|
|
278
|
+
void reader.cancel(signal.reason).catch(() => void 0);
|
|
279
|
+
};
|
|
280
|
+
signal.addEventListener("abort", cancel, { once: true });
|
|
281
|
+
try {
|
|
282
|
+
while (true) {
|
|
283
|
+
signal.throwIfAborted();
|
|
284
|
+
const chunk = await reader.read();
|
|
285
|
+
signal.throwIfAborted();
|
|
286
|
+
if (chunk.done)
|
|
287
|
+
break;
|
|
288
|
+
const remaining = maxBytes - used;
|
|
289
|
+
text += decoder.decode(chunk.value.subarray(0, remaining), { stream: true });
|
|
290
|
+
used += Math.min(remaining, chunk.value.byteLength);
|
|
291
|
+
if (chunk.value.byteLength > remaining)
|
|
292
|
+
break;
|
|
285
293
|
}
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
function choose(option) {
|
|
293
|
-
close();
|
|
294
|
-
if (option && !option.disabled && option.value !== value)
|
|
295
|
-
onValueChange(option.value);
|
|
294
|
+
text += decoder.decode();
|
|
295
|
+
return text.trim();
|
|
296
|
+
} finally {
|
|
297
|
+
signal.removeEventListener("abort", cancel);
|
|
298
|
+
await reader.cancel().catch(() => void 0);
|
|
299
|
+
reader.releaseLock();
|
|
296
300
|
}
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
if (
|
|
302
|
-
if (expanded)
|
|
303
|
-
choose(active);
|
|
304
|
-
return;
|
|
305
|
-
}
|
|
306
|
-
if (key === "Escape") {
|
|
307
|
-
if (!expanded)
|
|
308
|
-
return;
|
|
309
|
-
event.preventDefault();
|
|
310
|
-
event.stopPropagation();
|
|
311
|
-
close();
|
|
312
|
-
return;
|
|
313
|
-
}
|
|
314
|
-
if (key === " " || key === "Enter") {
|
|
315
|
-
event.preventDefault();
|
|
316
|
-
if (expanded)
|
|
317
|
-
choose(active);
|
|
318
|
-
else
|
|
319
|
-
setOpen(true);
|
|
320
|
-
return;
|
|
321
|
-
}
|
|
322
|
-
if (key === "ArrowDown" || key === "ArrowUp" || key === "Home" || key === "End") {
|
|
323
|
-
event.preventDefault();
|
|
324
|
-
if (event.altKey && key === "ArrowUp" && expanded) {
|
|
325
|
-
choose(active);
|
|
326
|
-
return;
|
|
327
|
-
}
|
|
328
|
-
setOpen(true);
|
|
329
|
-
let index = activeIndex;
|
|
330
|
-
if (key === "Home")
|
|
331
|
-
index = 0;
|
|
332
|
-
else if (key === "End")
|
|
333
|
-
index = enabled.length - 1;
|
|
334
|
-
else if (expanded && !event.altKey) {
|
|
335
|
-
const step = key === "ArrowDown" ? 1 : -1;
|
|
336
|
-
index = Math.max(0, Math.min(activeIndex + step, enabled.length - 1));
|
|
337
|
-
}
|
|
338
|
-
setHighlighted(enabled[index]?.value ?? null);
|
|
301
|
+
}
|
|
302
|
+
function ScriptCover({ title, synopsis, src }) {
|
|
303
|
+
const [excerpt, setExcerpt] = useState();
|
|
304
|
+
useEffect(() => {
|
|
305
|
+
if (!src || synopsis)
|
|
339
306
|
return;
|
|
340
|
-
|
|
341
|
-
if (
|
|
307
|
+
const url = new URL(src, window.location.href);
|
|
308
|
+
if (url.origin !== window.location.origin)
|
|
342
309
|
return;
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
if (match)
|
|
354
|
-
setHighlighted(match.value);
|
|
355
|
-
}
|
|
356
|
-
return _jsxs2("div", { className: "vx-dropdown", "data-size": size, "data-width": width, "data-appearance": appearance, children: [_jsxs2("button", { type: "button", role: "combobox", className: "vx-dropdown-trigger", "aria-label": label, "aria-expanded": expanded, "aria-controls": `${id}-listbox`, "aria-activedescendant": expanded && active ? `${id}-option-${options.indexOf(active)}` : void 0, disabled: !canOpen, onClick: () => expanded ? close() : setOpen(true), onBlur: close, onKeyDown: handleKey, children: [_jsxs2("span", { className: "vx-dropdown-value", children: [selected?.icon && _jsx3(Icon, { name: selected.icon }), _jsx3("span", { children: selected?.label ?? placeholder })] }), _jsx3(Icon, { name: expanded ? "chevron-up" : "chevron-down" })] }), _jsx3("ul", { id: `${id}-listbox`, role: "listbox", "aria-label": label, hidden: !expanded, children: options.map((option, index) => _jsxs2("li", { id: `${id}-option-${index}`, ref: active === option ? activeOption : void 0, role: "option", "aria-selected": option.value === value, "aria-disabled": option.disabled || void 0, "data-active": active === option, onMouseDown: (event) => event.preventDefault(), onClick: () => {
|
|
357
|
-
if (!option.disabled)
|
|
358
|
-
choose(option);
|
|
359
|
-
}, children: [option.icon && _jsx3(Icon, { name: option.icon }), option.label, width === "hug" && option.value === value && _jsx3(Icon, { name: "check" })] }, option.value)) })] });
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
// packages/ui-system/dist/segmented-control.js
|
|
363
|
-
import { jsx as _jsx4, jsxs as _jsxs3 } from "react/jsx-runtime";
|
|
364
|
-
import { useId as useId2 } from "react";
|
|
365
|
-
function SegmentedControl({ label, items, value, onValueChange, size = "medium", width = "fixed", iconOnly = false }) {
|
|
366
|
-
const id = useId2();
|
|
367
|
-
return _jsx4("div", { role: "radiogroup", "aria-label": label, className: "vx-segment", "data-size": size, "data-width": width, "data-icon-only": iconOnly, children: items.map((item) => _jsxs3("label", { children: [_jsx4("input", { type: "radio", name: id, value: item.value, disabled: item.disabled, checked: item.value === value, "aria-label": item.label, onChange: () => onValueChange(item.value) }), _jsxs3("span", { className: "vx-segment-item", children: [item.icon && _jsx4(Icon, { name: item.icon }), (!iconOnly || !item.icon) && item.label] })] }, item.value)) });
|
|
310
|
+
const controller = new AbortController();
|
|
311
|
+
void fetch(url, { signal: controller.signal }).then((response) => readTextExcerpt(response, controller.signal)).then((text2) => {
|
|
312
|
+
if (!controller.signal.aborted)
|
|
313
|
+
setExcerpt({ src, text: text2 });
|
|
314
|
+
}).catch(() => {
|
|
315
|
+
});
|
|
316
|
+
return () => controller.abort();
|
|
317
|
+
}, [src, synopsis]);
|
|
318
|
+
const text = synopsis || (src && excerpt?.src === src ? excerpt.text : "");
|
|
319
|
+
return _jsx3("span", { className: "vx-script-cover", "aria-label": title, children: _jsxs2("span", { className: "vx-script-sheet", children: [_jsx3("strong", { children: title }), _jsx3("span", { children: text })] }) });
|
|
368
320
|
}
|
|
369
321
|
|
|
370
322
|
// packages/ui-system/dist/input.js
|
|
371
|
-
import { jsx as
|
|
372
|
-
function TextInput({ label, value, onValueChange, size = "medium", ...props }) {
|
|
373
|
-
return
|
|
323
|
+
import { jsx as _jsx4, jsxs as _jsxs3 } from "react/jsx-runtime";
|
|
324
|
+
function TextInput({ label, value, onValueChange, size = "medium", appearance = "default", ...props }) {
|
|
325
|
+
return _jsxs3("label", { className: "vx-field", "data-size": size, "data-appearance": appearance, children: [_jsx4("span", { children: label }), _jsx4("input", { ...props, type: "text", value, onChange: (event) => onValueChange(event.currentTarget.value) })] });
|
|
374
326
|
}
|
|
375
327
|
|
|
376
328
|
// packages/ui-system/dist/tag.js
|
|
377
|
-
import { jsx as
|
|
329
|
+
import { jsx as _jsx5 } from "react/jsx-runtime";
|
|
378
330
|
function Tag({ children, variant = "overlay", className }) {
|
|
379
|
-
return
|
|
331
|
+
return _jsx5("span", { className: className ? `vx-tag ${className}` : "vx-tag", "data-variant": variant, children });
|
|
380
332
|
}
|
|
381
333
|
|
|
382
334
|
// packages/ui-system/dist/dialog.js
|
|
383
|
-
import { jsx as
|
|
384
|
-
import { useId
|
|
335
|
+
import { jsx as _jsx6, jsxs as _jsxs4, Fragment as _Fragment } from "react/jsx-runtime";
|
|
336
|
+
import { useId, useLayoutEffect, useRef, useState as useState2 } from "react";
|
|
385
337
|
import { createPortal } from "react-dom";
|
|
386
338
|
|
|
387
339
|
// packages/ui-system/dist/dialog-surface.js
|
|
@@ -434,10 +386,10 @@ function createDialogSurface(anchor) {
|
|
|
434
386
|
|
|
435
387
|
// packages/ui-system/dist/dialog.js
|
|
436
388
|
function Dialog({ title, open, onOpenChange, children, actions, className, variant = "default" }) {
|
|
437
|
-
const ref =
|
|
438
|
-
const anchor =
|
|
389
|
+
const ref = useRef(null);
|
|
390
|
+
const anchor = useRef(null);
|
|
439
391
|
const [surface, setSurface] = useState2();
|
|
440
|
-
const heading =
|
|
392
|
+
const heading = useId();
|
|
441
393
|
useLayoutEffect(() => {
|
|
442
394
|
if (!open || !anchor.current)
|
|
443
395
|
return;
|
|
@@ -463,25 +415,25 @@ function Dialog({ title, open, onOpenChange, children, actions, className, varia
|
|
|
463
415
|
dialog2.close();
|
|
464
416
|
};
|
|
465
417
|
}, [open, surface]);
|
|
466
|
-
const dialog =
|
|
418
|
+
const dialog = _jsxs4("dialog", { ref, className: className ? `vx-dialog ${className}` : "vx-dialog", "data-variant": variant === "default" ? void 0 : variant, "aria-labelledby": heading, onCancel: (event) => {
|
|
467
419
|
event.preventDefault();
|
|
468
420
|
event.stopPropagation();
|
|
469
421
|
onOpenChange(false);
|
|
470
422
|
}, onClose: (event) => {
|
|
471
423
|
if (open && event.currentTarget.isConnected && !event.currentTarget.open)
|
|
472
424
|
onOpenChange(false);
|
|
473
|
-
}, children: [
|
|
474
|
-
return
|
|
425
|
+
}, children: [_jsxs4("header", { children: [_jsx6("h2", { id: heading, children: title }), _jsx6(IconButton, { icon: "close", label: "Close dialog", onClick: () => onOpenChange(false) })] }), _jsx6("div", { className: "vx-dialog-body", children }), actions && _jsx6("footer", { children: actions })] });
|
|
426
|
+
return _jsxs4(_Fragment, { children: [_jsx6("span", { ref: anchor, hidden: true }), open && (surface ? createPortal(dialog, surface) : dialog)] });
|
|
475
427
|
}
|
|
476
428
|
|
|
477
429
|
// packages/ui-system/dist/prompt-hint.js
|
|
478
|
-
import { jsx as
|
|
479
|
-
import { useRef as
|
|
430
|
+
import { jsx as _jsx7, jsxs as _jsxs5 } from "react/jsx-runtime";
|
|
431
|
+
import { useRef as useRef2, useState as useState3 } from "react";
|
|
480
432
|
function PromptHint({ label, message, prompt }) {
|
|
481
433
|
const [status, setStatus] = useState3("");
|
|
482
434
|
const [manual, setManual] = useState3(false);
|
|
483
|
-
const text =
|
|
484
|
-
return
|
|
435
|
+
const text = useRef2(null);
|
|
436
|
+
return _jsxs5("aside", { className: "vx-prompt-hint", "aria-label": label, children: [_jsx7("p", { children: message }), manual && _jsx7("textarea", { ref: text, "aria-label": "Prompt to copy", readOnly: true, value: prompt, autoFocus: true, onFocus: (event) => event.currentTarget.select() }), _jsx7(Button, { label: "Copy prompt", variant: "text-tonal-sm", width: "hug", onClick: async (event) => {
|
|
485
437
|
try {
|
|
486
438
|
await event.currentTarget.ownerDocument.defaultView.navigator.clipboard.writeText(prompt);
|
|
487
439
|
setStatus("Prompt copied.");
|
|
@@ -489,21 +441,24 @@ function PromptHint({ label, message, prompt }) {
|
|
|
489
441
|
setManual(true);
|
|
490
442
|
setStatus("Select and copy the prompt.");
|
|
491
443
|
}
|
|
492
|
-
} }), status &&
|
|
444
|
+
} }), status && _jsx7("span", { role: "status", children: status })] });
|
|
493
445
|
}
|
|
494
446
|
|
|
495
447
|
// packages/ui-system/dist/menu.js
|
|
496
|
-
import { jsx as
|
|
497
|
-
import { useEffect as useEffect2, useId as
|
|
448
|
+
import { jsx as _jsx8, jsxs as _jsxs6 } from "react/jsx-runtime";
|
|
449
|
+
import { useEffect as useEffect2, useId as useId2, useLayoutEffect as useLayoutEffect2, useRef as useRef3, useState as useState4 } from "react";
|
|
498
450
|
import { createPortal as createPortal2 } from "react-dom";
|
|
499
451
|
function isEnabled(item) {
|
|
500
452
|
return !item.disabled && item.items?.length !== 0;
|
|
501
453
|
}
|
|
502
|
-
function Menu({ label, items, triggerIcon, floating = false }) {
|
|
503
|
-
const id =
|
|
504
|
-
const trigger =
|
|
505
|
-
const popup =
|
|
506
|
-
const
|
|
454
|
+
function Menu({ label, items, triggerIcon, floating = false, cascading = false }) {
|
|
455
|
+
const id = useId2();
|
|
456
|
+
const trigger = useRef3(null);
|
|
457
|
+
const popup = useRef3(null);
|
|
458
|
+
const children = useRef3(/* @__PURE__ */ new Map());
|
|
459
|
+
const focusOnOpen = useRef3(true);
|
|
460
|
+
const cascade = floating && cascading;
|
|
461
|
+
const focusIndex = useRef3(0);
|
|
507
462
|
const [path, setPath] = useState4(null);
|
|
508
463
|
const [placement, setPlacement] = useState4({ visibility: "hidden" });
|
|
509
464
|
const portalRoot = floating ? trigger.current?.closest("dialog, [data-vx-theme]") : null;
|
|
@@ -524,19 +479,38 @@ function Menu({ label, items, triggerIcon, floating = false }) {
|
|
|
524
479
|
const flip = naturalHeight > below && above > below;
|
|
525
480
|
const maxHeight = Math.max(0, Math.min(480, height - 16, flip ? above : below));
|
|
526
481
|
const menuHeight = Math.min(naturalHeight, maxHeight);
|
|
482
|
+
const left = Math.max(8, Math.min(rect.right - bounds.width, width - bounds.width - 8));
|
|
483
|
+
const top = Math.max(8, Math.min(flip ? rect.top - menuHeight - 4 : rect.bottom + 4, height - menuHeight - 8));
|
|
527
484
|
setPlacement({
|
|
528
485
|
position: "fixed",
|
|
529
486
|
visibility: "visible",
|
|
530
487
|
insetInlineStart: "auto",
|
|
531
|
-
left
|
|
532
|
-
top
|
|
488
|
+
left,
|
|
489
|
+
top,
|
|
533
490
|
maxHeight,
|
|
534
491
|
zIndex: 100
|
|
535
492
|
});
|
|
493
|
+
let parent = menu2, parentLeft = left, parentTop = top;
|
|
494
|
+
for (let depth = 1; cascade && depth <= path.length; depth++) {
|
|
495
|
+
const panel = children.current.get(depth);
|
|
496
|
+
const item = Array.from(parent.querySelectorAll("button")).find((b) => b.dataset.key === path[depth - 1]);
|
|
497
|
+
if (!panel || !item)
|
|
498
|
+
break;
|
|
499
|
+
const parentBox = parent.getBoundingClientRect(), box = panel.getBoundingClientRect();
|
|
500
|
+
const nextLeft = parentLeft + parentBox.width;
|
|
501
|
+
parentLeft = Math.max(8, Math.min(nextLeft + box.width <= width - 8 ? nextLeft : parentLeft - box.width, width - box.width - 8));
|
|
502
|
+
parentTop = Math.max(8, Math.min(parentTop + item.getBoundingClientRect().top - parentBox.top - 4, height - box.height - 8));
|
|
503
|
+
Object.assign(panel.style, {
|
|
504
|
+
left: parentLeft + "px",
|
|
505
|
+
top: parentTop + "px",
|
|
506
|
+
visibility: "visible"
|
|
507
|
+
});
|
|
508
|
+
parent = panel;
|
|
509
|
+
}
|
|
536
510
|
};
|
|
537
511
|
const outside = (event) => {
|
|
538
512
|
const path2 = event.composedPath();
|
|
539
|
-
if (!path2.includes(trigger.current) && !path2.includes(popup.current))
|
|
513
|
+
if (!path2.includes(trigger.current) && !path2.includes(popup.current) && ![...children.current.values()].some((panel) => path2.includes(panel)))
|
|
540
514
|
setPath(null);
|
|
541
515
|
};
|
|
542
516
|
const document2 = portalRoot.ownerDocument;
|
|
@@ -550,21 +524,23 @@ function Menu({ label, items, triggerIcon, floating = false }) {
|
|
|
550
524
|
window2.removeEventListener("scroll", position, true);
|
|
551
525
|
document2.removeEventListener("pointerdown", outside);
|
|
552
526
|
};
|
|
553
|
-
}, [floating, path, portalRoot]);
|
|
527
|
+
}, [floating, path, portalRoot, cascade]);
|
|
554
528
|
let entries = items;
|
|
555
529
|
let menuLabel = label;
|
|
530
|
+
const levels = [{ entries, menuLabel }];
|
|
556
531
|
for (const key of path ?? []) {
|
|
557
532
|
const entry = entries.find((item) => item.id === key);
|
|
558
533
|
if (!entry?.items)
|
|
559
534
|
break;
|
|
560
535
|
menuLabel = entry.label;
|
|
561
536
|
entries = entry.items;
|
|
537
|
+
levels.push({ entries, menuLabel });
|
|
562
538
|
}
|
|
563
|
-
function buttons() {
|
|
564
|
-
return [...
|
|
539
|
+
function buttons(panel = cascade && path?.length ? children.current.get(path.length) : popup.current) {
|
|
540
|
+
return [...panel?.querySelectorAll("button:not(:disabled)") ?? []];
|
|
565
541
|
}
|
|
566
542
|
useEffect2(() => {
|
|
567
|
-
if (path && (!floating || !portalRoot || placement.visibility === "visible"))
|
|
543
|
+
if (focusOnOpen.current && path && (!floating || !portalRoot || placement.visibility === "visible"))
|
|
568
544
|
buttons().at(focusIndex.current)?.focus();
|
|
569
545
|
}, [path, floating && placement.visibility, portalRoot]);
|
|
570
546
|
function close() {
|
|
@@ -572,6 +548,7 @@ function Menu({ label, items, triggerIcon, floating = false }) {
|
|
|
572
548
|
trigger.current?.focus();
|
|
573
549
|
}
|
|
574
550
|
function back() {
|
|
551
|
+
focusOnOpen.current = true;
|
|
575
552
|
if (!path?.length)
|
|
576
553
|
return;
|
|
577
554
|
const parentPath = path.slice(0, -1);
|
|
@@ -579,24 +556,27 @@ function Menu({ label, items, triggerIcon, floating = false }) {
|
|
|
579
556
|
focusIndex.current = Math.max(0, parent.filter(isEnabled).findIndex((item) => item.id === path.at(-1)));
|
|
580
557
|
setPath(parentPath);
|
|
581
558
|
}
|
|
582
|
-
function choose(item) {
|
|
559
|
+
function choose(item, depth) {
|
|
560
|
+
focusOnOpen.current = true;
|
|
583
561
|
if (item.items?.length) {
|
|
584
562
|
focusIndex.current = 0;
|
|
585
|
-
setPath([...path ?? [], item.id]);
|
|
563
|
+
setPath([...(path ?? []).slice(0, depth), item.id]);
|
|
564
|
+
if (cascade && path?.[depth] === item.id)
|
|
565
|
+
buttons(children.current.get(depth + 1))?.at(0)?.focus();
|
|
586
566
|
} else if (item.onSelect) {
|
|
587
567
|
if (item.checked === void 0)
|
|
588
568
|
close();
|
|
589
569
|
item.onSelect();
|
|
590
570
|
}
|
|
591
571
|
}
|
|
592
|
-
function handleKey(event) {
|
|
572
|
+
function handleKey(event, depth) {
|
|
593
573
|
if (event.key === "Tab" && floating && portalRoot) {
|
|
594
574
|
if (event.shiftKey)
|
|
595
575
|
event.preventDefault();
|
|
596
576
|
close();
|
|
597
577
|
return;
|
|
598
578
|
}
|
|
599
|
-
const available = buttons();
|
|
579
|
+
const available = buttons(event.currentTarget);
|
|
600
580
|
const index = available.findIndex((button) => button === event.target);
|
|
601
581
|
if (event.key === "Escape") {
|
|
602
582
|
event.preventDefault();
|
|
@@ -613,10 +593,10 @@ function Menu({ label, items, triggerIcon, floating = false }) {
|
|
|
613
593
|
return;
|
|
614
594
|
}
|
|
615
595
|
if (event.key === "ArrowRight") {
|
|
616
|
-
const item = entries.filter(isEnabled)[index];
|
|
596
|
+
const item = levels[depth]?.entries.filter(isEnabled)[index];
|
|
617
597
|
if (item?.items?.length) {
|
|
618
598
|
event.preventDefault();
|
|
619
|
-
choose(item);
|
|
599
|
+
choose(item, depth);
|
|
620
600
|
}
|
|
621
601
|
return;
|
|
622
602
|
}
|
|
@@ -632,6 +612,7 @@ function Menu({ label, items, triggerIcon, floating = false }) {
|
|
|
632
612
|
}
|
|
633
613
|
}
|
|
634
614
|
function open(index = 0) {
|
|
615
|
+
focusOnOpen.current = true;
|
|
635
616
|
focusIndex.current = index;
|
|
636
617
|
setPath([]);
|
|
637
618
|
}
|
|
@@ -641,17 +622,45 @@ function Menu({ label, items, triggerIcon, floating = false }) {
|
|
|
641
622
|
open(event.key === "ArrowUp" ? -1 : 0);
|
|
642
623
|
}
|
|
643
624
|
}
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
625
|
+
function hover(item, depth) {
|
|
626
|
+
if (!cascade || !path)
|
|
627
|
+
return;
|
|
628
|
+
const next = path.slice(0, depth);
|
|
629
|
+
if (item.items?.length && isEnabled(item))
|
|
630
|
+
next.push(item.id);
|
|
631
|
+
if (next.length === path.length && next.every((key, i) => path[i] === key))
|
|
632
|
+
return;
|
|
633
|
+
focusOnOpen.current = false;
|
|
634
|
+
setPath(next);
|
|
635
|
+
}
|
|
636
|
+
const menu = levels.map(({ entries: entries2, menuLabel: menuLabel2 }, depth) => !cascade && depth !== levels.length - 1 ? null : _jsx8("div", { ref: !cascade || depth === 0 ? popup : (el) => {
|
|
637
|
+
if (el)
|
|
638
|
+
children.current.set(depth, el);
|
|
639
|
+
else
|
|
640
|
+
children.current.delete(depth);
|
|
641
|
+
}, 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 ? {
|
|
642
|
+
position: "fixed",
|
|
643
|
+
insetInlineStart: "auto",
|
|
644
|
+
visibility: "hidden",
|
|
645
|
+
maxHeight: "min(480px, calc(100dvh - 16px))",
|
|
646
|
+
zIndex: 100 + depth
|
|
647
|
+
} : placement : void 0, children: entries2.map((item) => _jsxs6("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) => {
|
|
648
|
+
if (e.pointerType !== "touch")
|
|
649
|
+
hover(item, depth);
|
|
650
|
+
} : void 0, "data-size": item.size ?? "medium", "data-tone": item.tone, disabled: !isEnabled(item), tabIndex: -1, onClick: () => choose(item, depth), children: [item.icon && _jsx8(Icon, { name: item.icon }), _jsx8("span", { children: item.label }), item.checked && _jsx8(Icon, { name: "check" }), item.items?.length ? _jsx8(Icon, { name: "chevron-right" }) : null] }, item.id)) }, depth));
|
|
651
|
+
return _jsxs6("div", { className: "vx-action-menu", onBlur: (event) => {
|
|
652
|
+
if (!event.currentTarget.contains(event.relatedTarget) && !(floating && popup.current?.contains(event.relatedTarget)) && ![...children.current.values()].some((panel) => panel.contains(event.relatedTarget)))
|
|
647
653
|
setPath(null);
|
|
648
|
-
}, children: [triggerIcon ?
|
|
654
|
+
}, children: [triggerIcon ? _jsx8(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 }) : _jsx8(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] });
|
|
649
655
|
}
|
|
650
656
|
|
|
651
657
|
// packages/ui-system/dist/media.js
|
|
652
|
-
import { jsx as
|
|
653
|
-
import { useRef as
|
|
654
|
-
function
|
|
658
|
+
import { jsx as _jsx9, Fragment as _Fragment2, jsxs as _jsxs7 } from "react/jsx-runtime";
|
|
659
|
+
import { useRef as useRef4, useState as useState5 } from "react";
|
|
660
|
+
function MediaBadges({ label, duration }) {
|
|
661
|
+
return _jsxs7(_Fragment2, { children: [" ", label && _jsx9("span", { className: "vx-media-label", children: _jsx9(Tag, { children: label }) }), duration && _jsx9("span", { className: "vx-media-duration", children: _jsx9(Tag, { children: duration }) })] });
|
|
662
|
+
}
|
|
663
|
+
function Media({ src, videoSrc, emptyLabel, script, alt, ratio = "16:9", state = "default", fit = "cover", emptyAppearance = "black", crop, label, duration, selectedLabel, selectionStyle = "outline", onSelect, onOpen }) {
|
|
655
664
|
const [failedImage, setFailedImage] = useState5();
|
|
656
665
|
const [failedVideo, setFailedVideo] = useState5();
|
|
657
666
|
const image = src !== failedImage ? src : void 0;
|
|
@@ -667,7 +676,7 @@ function Media({ src, videoSrc, emptyLabel, alt, ratio = "16:9", state = "defaul
|
|
|
667
676
|
transform: `rotate(${crop.rotation ?? 0}deg)`,
|
|
668
677
|
objectFit: "fill"
|
|
669
678
|
} : { objectFit: fit };
|
|
670
|
-
const content =
|
|
679
|
+
const content = _jsxs7(_Fragment2, { children: [script ? _jsx9(ScriptCover, { ...script }) : image ? _jsx9("img", { src: image, alt, style: imageStyle, onError: () => setFailedImage(image) }, image) : video ? _jsx9("video", { src: video, preload: "metadata", muted: true, playsInline: true, "aria-hidden": "true", style: { objectFit: fit }, onError: () => setFailedVideo(video) }, video) : emptyAppearance !== "black" && emptyAppearance !== "surface" ? _jsx9(Icon, { name: `placeholder-${emptyAppearance}`, size: 20 }) : emptyLabel && !busy ? _jsx9("span", { className: "vx-media-empty-label", children: emptyLabel }) : null, _jsx9(MediaBadges, { label, duration }), selected && selectedLabel && _jsx9("span", { className: "vx-media-selected", children: _jsx9(Tag, { variant: "selected", children: "Selected" }) }), selectionStyle === "checkbox" && _jsx9("span", { className: "vx-media-marker", "aria-hidden": "true", children: selected && _jsx9(Icon, { name: "check", size: 12 }) }), busy && _jsx9("span", { className: "vx-media-progress", role: "status", children: state === "loading" ? "Loading" : "Generating" })] });
|
|
671
680
|
const props = {
|
|
672
681
|
className: "vx-media",
|
|
673
682
|
"data-state": state,
|
|
@@ -676,24 +685,25 @@ function Media({ src, videoSrc, emptyLabel, alt, ratio = "16:9", state = "defaul
|
|
|
676
685
|
"aria-busy": busy || void 0,
|
|
677
686
|
style: { aspectRatio: ratio.replace(":", " / ") }
|
|
678
687
|
};
|
|
679
|
-
return onSelect || onOpen ?
|
|
688
|
+
return onSelect || onOpen ? _jsx9("button", { ...props, type: "button", "aria-label": alt, "aria-pressed": onSelect ? selected : void 0, disabled: busy, onClick: () => onSelect ? onSelect(!selected) : onOpen?.(), children: content }) : _jsx9("div", { ...props, "aria-label": image ? void 0 : alt, children: content });
|
|
680
689
|
}
|
|
681
690
|
|
|
682
691
|
// packages/ui-system/dist/video-player.js
|
|
683
|
-
import { jsx as
|
|
684
|
-
import { useEffect as useEffect3, useRef as
|
|
685
|
-
function timeLabel(seconds) {
|
|
692
|
+
import { jsx as _jsx10, jsxs as _jsxs8, Fragment as _Fragment3 } from "react/jsx-runtime";
|
|
693
|
+
import { useEffect as useEffect3, useRef as useRef5, useState as useState6 } from "react";
|
|
694
|
+
function timeLabel(seconds, padMinutes = false) {
|
|
686
695
|
const whole = Math.floor(seconds);
|
|
687
|
-
|
|
696
|
+
const minutes = String(Math.floor(whole / 60));
|
|
697
|
+
return `${padMinutes ? minutes.padStart(2, "0") : minutes}:${String(whole % 60).padStart(2, "0")}`;
|
|
688
698
|
}
|
|
689
|
-
function PlaybackControls({ playing, muted, time, duration, size = "medium", disabled, onTogglePlay, onToggleMute, onSeek, onFullscreen }) {
|
|
690
|
-
return
|
|
699
|
+
function PlaybackControls({ playing, muted, time, duration, size = "medium", disabled, onTogglePlay, onToggleMute, onSeek, onFullscreen, fullscreenLabel = "Toggle fullscreen", actions, appearance = "on-content", timeDisplay = "combined" }) {
|
|
700
|
+
return _jsxs8("div", { className: "vx-playback-controls", role: "group", "aria-label": "Playback controls", "data-size": size, "data-appearance": appearance, style: {
|
|
691
701
|
"--vx-playback-progress": `${duration > 0 ? Math.min(100, Math.max(0, time / duration * 100)) : 0}%`
|
|
692
|
-
}, children: [
|
|
702
|
+
}, children: [_jsx10(IconButton, { icon: playing ? size === "large" ? "pause-large" : "pause" : size === "large" ? "playback-play-large" : "playback-play", label: playing ? "Pause" : "Play", disabled, onClick: onTogglePlay }), timeDisplay === "split" && _jsx10("span", { "aria-hidden": "true", "data-time": "elapsed", children: timeLabel(time, true) }), _jsx10("input", { "aria-label": "Playback position", "aria-valuetext": `${timeLabel(time)} of ${timeLabel(duration)}`, type: "range", min: 0, max: duration, value: time, step: "any", disabled: disabled || !duration, onChange: (event) => onSeek(event.currentTarget.valueAsNumber) }), _jsx10("span", { "aria-hidden": "true", "data-time": timeDisplay === "split" ? "duration" : void 0, children: timeDisplay === "split" ? timeLabel(duration, true) : `${timeLabel(time)} / ${timeLabel(duration)}` }), _jsx10(IconButton, { icon: muted ? size === "large" ? "mute-large" : "mute" : size === "large" ? "volume-large" : "volume", label: muted ? "Unmute" : "Mute", disabled, onClick: onToggleMute }), actions, onFullscreen && _jsx10(IconButton, { icon: size === "large" ? "fullscreen-large" : "fullscreen", label: fullscreenLabel, onClick: onFullscreen })] });
|
|
693
703
|
}
|
|
694
704
|
|
|
695
705
|
// packages/short-drama-compare/src/sequence-player.tsx
|
|
696
|
-
import { useEffect as useEffect4, useMemo, useRef as
|
|
706
|
+
import { useEffect as useEffect4, useMemo, useRef as useRef6, useState as useState7 } from "react";
|
|
697
707
|
|
|
698
708
|
// packages/short-drama-compare/src/sequence.ts
|
|
699
709
|
function buildTimeline(clips) {
|
|
@@ -714,6 +724,7 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
|
714
724
|
function SequencePlayer({
|
|
715
725
|
title,
|
|
716
726
|
clips,
|
|
727
|
+
pending = false,
|
|
717
728
|
initialShotId,
|
|
718
729
|
showFilmstrip = true,
|
|
719
730
|
onEdit,
|
|
@@ -722,8 +733,8 @@ function SequencePlayer({
|
|
|
722
733
|
startPlaying = false,
|
|
723
734
|
decorate
|
|
724
735
|
}) {
|
|
725
|
-
const stage =
|
|
726
|
-
const video =
|
|
736
|
+
const stage = useRef6(null);
|
|
737
|
+
const video = useRef6(null);
|
|
727
738
|
const entries = useMemo(() => buildTimeline(clips), [clips]);
|
|
728
739
|
const videoCount = entries.filter((entry) => entry.src).length;
|
|
729
740
|
const stillCount = entries.filter((entry) => !entry.src && entry.poster).length;
|
|
@@ -732,7 +743,7 @@ function SequencePlayer({
|
|
|
732
743
|
const [position, setPosition] = useState7(
|
|
733
744
|
() => entries.find((entry) => entry.id === initialShotId)?.offset ?? 0
|
|
734
745
|
);
|
|
735
|
-
const positionRef =
|
|
746
|
+
const positionRef = useRef6(position);
|
|
736
747
|
const [playing, setPlaying] = useState7(startPlaying);
|
|
737
748
|
const [showCover, setShowCover] = useState7(Boolean(cover && !initialShotId));
|
|
738
749
|
const [failedArtwork, setFailedArtwork] = useState7();
|
|
@@ -832,11 +843,11 @@ function SequencePlayer({
|
|
|
832
843
|
active.id + active.src
|
|
833
844
|
) : showStill ? /* @__PURE__ */ jsx("img", { src: active.poster, alt: active.title }) : /* @__PURE__ */ jsxs("section", { className: "drama-player-empty", children: [
|
|
834
845
|
/* @__PURE__ */ jsx("strong", { children: active.title }),
|
|
835
|
-
/* @__PURE__ */ jsx("p", { role: "status", children: mediaMessage ?? "This shot has no video or storyboard still yet." }),
|
|
846
|
+
/* @__PURE__ */ jsx("p", { role: "status", children: pending ? "Loading preview\u2026" : mediaMessage ?? "This shot has no video or storyboard still yet." }),
|
|
836
847
|
onEdit && /* @__PURE__ */ jsx(Button, { label: "Open shot", width: "hug", onClick: () => onEdit(active.id) })
|
|
837
848
|
] });
|
|
838
849
|
const canPlay = !videoFailed && (videoCount > 0 || stillCount > 0);
|
|
839
|
-
const withCover = showCover && canPlay && cover;
|
|
850
|
+
const withCover = showCover && (canPlay || pending) && cover;
|
|
840
851
|
const artwork = cover?.artwork !== failedArtwork ? cover?.artwork : void 0;
|
|
841
852
|
const durationSeconds = Math.floor(duration / 1e3);
|
|
842
853
|
const minutes = Math.floor(durationSeconds / 60);
|
|
@@ -883,27 +894,36 @@ function SequencePlayer({
|
|
|
883
894
|
return /* @__PURE__ */ jsxs("section", { className: "drama-player", "aria-label": title, children: [
|
|
884
895
|
/* @__PURE__ */ jsx("div", { className: "drama-player-viewport", "data-cover": withCover ? true : void 0, children: /* @__PURE__ */ jsxs("div", { ref: stage, className: "drama-player-stage", "data-empty": !showVideo && !showStill, children: [
|
|
885
896
|
decorate && !videoFailed ? decorate(active, media) : media,
|
|
886
|
-
withCover && /* @__PURE__ */ jsxs(
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
897
|
+
withCover && /* @__PURE__ */ jsxs(
|
|
898
|
+
"button",
|
|
899
|
+
{
|
|
900
|
+
className: "drama-player-cover",
|
|
901
|
+
"aria-label": "Play",
|
|
902
|
+
disabled: !canPlay,
|
|
903
|
+
onClick: togglePlay,
|
|
904
|
+
children: [
|
|
905
|
+
artwork && /* @__PURE__ */ jsx("img", { src: artwork, alt: "", onError: () => setFailedArtwork(artwork) }),
|
|
906
|
+
/* @__PURE__ */ jsxs("span", { className: "drama-player-cover-info", children: [
|
|
892
907
|
/* @__PURE__ */ jsxs("span", { children: [
|
|
893
|
-
"
|
|
894
|
-
|
|
908
|
+
/* @__PURE__ */ jsx("strong", { children: cover.title }),
|
|
909
|
+
/* @__PURE__ */ jsxs("span", { className: "drama-player-cover-meta", children: [
|
|
910
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
911
|
+
"Total duration: ",
|
|
912
|
+
formattedDuration
|
|
913
|
+
] }),
|
|
914
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
915
|
+
"Contains a total of ",
|
|
916
|
+
entries.length,
|
|
917
|
+
" ",
|
|
918
|
+
entries.length === 1 ? "scene" : "scenes"
|
|
919
|
+
] })
|
|
920
|
+
] })
|
|
895
921
|
] }),
|
|
896
|
-
/* @__PURE__ */
|
|
897
|
-
"Contains a total of ",
|
|
898
|
-
entries.length,
|
|
899
|
-
" ",
|
|
900
|
-
entries.length === 1 ? "scene" : "scenes"
|
|
901
|
-
] })
|
|
922
|
+
/* @__PURE__ */ jsx("span", { className: "drama-player-cover-play", children: /* @__PURE__ */ jsx(Icon, { name: "play", size: 20 }) })
|
|
902
923
|
] })
|
|
903
|
-
]
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
] })
|
|
924
|
+
]
|
|
925
|
+
}
|
|
926
|
+
)
|
|
907
927
|
] }) }),
|
|
908
928
|
!withCover && canPlay && /* @__PURE__ */ jsx(
|
|
909
929
|
PlaybackControls,
|
|
@@ -943,38 +963,37 @@ function SequencePlayer({
|
|
|
943
963
|
}
|
|
944
964
|
|
|
945
965
|
// packages/short-drama-compare/src/view-support.tsx
|
|
946
|
-
import { useEffect as useEffect5, useRef as
|
|
966
|
+
import { useEffect as useEffect5, useRef as useRef7, useState as useState8 } from "react";
|
|
947
967
|
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
948
968
|
function CaptureTarget({
|
|
949
969
|
children,
|
|
950
970
|
target,
|
|
951
971
|
registerTarget
|
|
952
972
|
}) {
|
|
953
|
-
const element =
|
|
973
|
+
const element = useRef7(null);
|
|
954
974
|
useEffect5(() => {
|
|
955
975
|
if (element.current) return registerTarget({ ...target, element: element.current });
|
|
956
976
|
}, [registerTarget, target]);
|
|
957
977
|
return /* @__PURE__ */ jsx2("div", { ref: element, children });
|
|
958
978
|
}
|
|
959
|
-
function useRequest(read, revision) {
|
|
960
|
-
const [result, setResult] = useState8(
|
|
979
|
+
function useRequest(read, revision, initial) {
|
|
980
|
+
const [result, setResult] = useState8();
|
|
961
981
|
useEffect5(() => {
|
|
962
982
|
let active = true;
|
|
963
|
-
setResult(null);
|
|
964
983
|
void read().then(
|
|
965
984
|
(data) => {
|
|
966
|
-
if (active) setResult({ data });
|
|
985
|
+
if (active) setResult({ read, data });
|
|
967
986
|
},
|
|
968
987
|
(error) => {
|
|
969
988
|
if (active)
|
|
970
|
-
setResult({ error: error instanceof Error ? error.message : "Request failed." });
|
|
989
|
+
setResult({ read, error: error instanceof Error ? error.message : "Request failed." });
|
|
971
990
|
}
|
|
972
991
|
);
|
|
973
992
|
return () => {
|
|
974
993
|
active = false;
|
|
975
994
|
};
|
|
976
995
|
}, [read, revision]);
|
|
977
|
-
return result;
|
|
996
|
+
return result?.read === read ? result : initial === void 0 ? void 0 : { data: initial, error: void 0 };
|
|
978
997
|
}
|
|
979
998
|
function LoadMessage({ error, onRetry }) {
|
|
980
999
|
return error ? /* @__PURE__ */ jsxs2("div", { role: "alert", className: "drama-card", children: [
|
|
@@ -987,57 +1006,10 @@ function LoadMessage({ error, onRetry }) {
|
|
|
987
1006
|
import { Fragment as Fragment2, jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
988
1007
|
function Compare(props) {
|
|
989
1008
|
const { episode } = props;
|
|
990
|
-
const
|
|
991
|
-
const [shotId, setShotId] = useState9(props.route.shotId ?? episode.shots[0]?.id);
|
|
992
|
-
const [leftCutId, setLeftCutId] = useState9(episode.cuts[0]?.id);
|
|
993
|
-
const [rightCutId, setRightCutId] = useState9(episode.cuts[1]?.id);
|
|
994
|
-
const shot = episode.shots.find((shot2) => shot2.id === shotId) ?? episode.shots[0];
|
|
995
|
-
const left = episode.cuts.find((cut) => cut.id === leftCutId);
|
|
996
|
-
const right = episode.cuts.find((cut) => cut.id === rightCutId);
|
|
1009
|
+
const shot = episode.shots.find((item) => item.id === props.route.shotId) ?? episode.shots[0];
|
|
997
1010
|
return /* @__PURE__ */ jsxs3("section", { "aria-label": "Version comparison", children: [
|
|
998
|
-
/* @__PURE__ */
|
|
999
|
-
|
|
1000
|
-
"Compare ",
|
|
1001
|
-
mode === "shots" ? "Each Scene" : "Whole Video"
|
|
1002
|
-
] }),
|
|
1003
|
-
/* @__PURE__ */ jsxs3("div", { className: "drama-compare-selection", children: [
|
|
1004
|
-
props.episodes.length > 1 && /* @__PURE__ */ jsx3(
|
|
1005
|
-
Dropdown,
|
|
1006
|
-
{
|
|
1007
|
-
label: "Episode",
|
|
1008
|
-
value: episode.id,
|
|
1009
|
-
options: props.episodes.map((item, index) => ({
|
|
1010
|
-
value: item.id,
|
|
1011
|
-
label: `Episode ${index + 1}`
|
|
1012
|
-
})),
|
|
1013
|
-
onValueChange: (episodeId) => props.navigate({ view: "compare", episodeId })
|
|
1014
|
-
}
|
|
1015
|
-
),
|
|
1016
|
-
mode === "shots" && episode.shots.length > 0 && /* @__PURE__ */ jsx3(
|
|
1017
|
-
Dropdown,
|
|
1018
|
-
{
|
|
1019
|
-
label: "Scene",
|
|
1020
|
-
value: shot?.id ?? "",
|
|
1021
|
-
options: episode.shots.map((item) => ({ value: item.id, label: item.title })),
|
|
1022
|
-
onValueChange: setShotId
|
|
1023
|
-
}
|
|
1024
|
-
)
|
|
1025
|
-
] }),
|
|
1026
|
-
/* @__PURE__ */ jsx3(
|
|
1027
|
-
SegmentedControl,
|
|
1028
|
-
{
|
|
1029
|
-
label: "Comparison mode",
|
|
1030
|
-
width: "hug",
|
|
1031
|
-
items: [
|
|
1032
|
-
{ value: "episode", label: "Whole Video" },
|
|
1033
|
-
{ value: "shots", label: "Each Scene" }
|
|
1034
|
-
],
|
|
1035
|
-
value: mode,
|
|
1036
|
-
onValueChange: setMode
|
|
1037
|
-
}
|
|
1038
|
-
)
|
|
1039
|
-
] }),
|
|
1040
|
-
mode === "shots" && (shot ? /* @__PURE__ */ jsx3(
|
|
1011
|
+
/* @__PURE__ */ jsx3("header", { className: "drama-compare-bar", children: /* @__PURE__ */ jsx3("h2", { children: "Compare" }) }),
|
|
1012
|
+
shot ? /* @__PURE__ */ jsx3(
|
|
1041
1013
|
CandidateCompare,
|
|
1042
1014
|
{
|
|
1043
1015
|
...props,
|
|
@@ -1045,66 +1017,7 @@ function Compare(props) {
|
|
|
1045
1017
|
choices: props.candidateChoices[JSON.stringify([episode.id, shot.id])] ?? [],
|
|
1046
1018
|
onChoose: (choices) => props.onCandidateChoices(JSON.stringify([episode.id, shot.id]), choices)
|
|
1047
1019
|
}
|
|
1048
|
-
) : /* @__PURE__ */ jsx3("p", { children: "Add a shot before comparing candidates." })
|
|
1049
|
-
mode === "episode" && (episode.cuts.length < 2 ? /* @__PURE__ */ jsxs3("div", { className: "drama-card", children: [
|
|
1050
|
-
/* @__PURE__ */ jsx3("p", { children: "Save at least two episode versions to compare their sequences." }),
|
|
1051
|
-
/* @__PURE__ */ jsx3(
|
|
1052
|
-
Button,
|
|
1053
|
-
{
|
|
1054
|
-
label: "Open episode preview",
|
|
1055
|
-
variant: "text-tonal-sm",
|
|
1056
|
-
width: "hug",
|
|
1057
|
-
onClick: () => props.navigate({ view: "episode", episodeId: episode.id })
|
|
1058
|
-
}
|
|
1059
|
-
)
|
|
1060
|
-
] }) : /* @__PURE__ */ jsxs3("div", { className: "drama-compare", children: [
|
|
1061
|
-
/* @__PURE__ */ jsxs3("section", { "aria-label": "Episode A", children: [
|
|
1062
|
-
/* @__PURE__ */ jsxs3("label", { children: [
|
|
1063
|
-
"A",
|
|
1064
|
-
/* @__PURE__ */ jsx3(
|
|
1065
|
-
"select",
|
|
1066
|
-
{
|
|
1067
|
-
value: leftCutId,
|
|
1068
|
-
onChange: (event) => setLeftCutId(event.currentTarget.value),
|
|
1069
|
-
children: episode.cuts.map((cut) => /* @__PURE__ */ jsx3("option", { value: cut.id, disabled: cut.id === rightCutId, children: cut.title }, cut.id))
|
|
1070
|
-
}
|
|
1071
|
-
)
|
|
1072
|
-
] }),
|
|
1073
|
-
left && /* @__PURE__ */ jsx3(
|
|
1074
|
-
ResolvedPlayer,
|
|
1075
|
-
{
|
|
1076
|
-
...props,
|
|
1077
|
-
label: left.title,
|
|
1078
|
-
shots: left.shots,
|
|
1079
|
-
captureId: "episode-a"
|
|
1080
|
-
},
|
|
1081
|
-
left.id
|
|
1082
|
-
)
|
|
1083
|
-
] }),
|
|
1084
|
-
/* @__PURE__ */ jsxs3("section", { "aria-label": "Episode B", children: [
|
|
1085
|
-
/* @__PURE__ */ jsxs3("label", { children: [
|
|
1086
|
-
"B",
|
|
1087
|
-
/* @__PURE__ */ jsx3(
|
|
1088
|
-
"select",
|
|
1089
|
-
{
|
|
1090
|
-
value: rightCutId,
|
|
1091
|
-
onChange: (event) => setRightCutId(event.currentTarget.value),
|
|
1092
|
-
children: episode.cuts.map((cut) => /* @__PURE__ */ jsx3("option", { value: cut.id, disabled: cut.id === leftCutId, children: cut.title }, cut.id))
|
|
1093
|
-
}
|
|
1094
|
-
)
|
|
1095
|
-
] }),
|
|
1096
|
-
right && /* @__PURE__ */ jsx3(
|
|
1097
|
-
ResolvedPlayer,
|
|
1098
|
-
{
|
|
1099
|
-
...props,
|
|
1100
|
-
label: right.title,
|
|
1101
|
-
shots: right.shots,
|
|
1102
|
-
captureId: "episode-b"
|
|
1103
|
-
},
|
|
1104
|
-
right.id
|
|
1105
|
-
)
|
|
1106
|
-
] })
|
|
1107
|
-
] }))
|
|
1020
|
+
) : /* @__PURE__ */ jsx3("p", { children: "Add a shot before comparing candidates." })
|
|
1108
1021
|
] });
|
|
1109
1022
|
}
|
|
1110
1023
|
var compareSlots = ["A", "B", "C", "D"];
|
|
@@ -1143,17 +1056,7 @@ function CandidateCompare(props) {
|
|
|
1143
1056
|
captureId: `candidate-${side}`,
|
|
1144
1057
|
cover: true
|
|
1145
1058
|
}
|
|
1146
|
-
) : /* @__PURE__ */
|
|
1147
|
-
/* @__PURE__ */ jsx3("p", { children: "No video selected" }),
|
|
1148
|
-
/* @__PURE__ */ jsx3(
|
|
1149
|
-
Button,
|
|
1150
|
-
{
|
|
1151
|
-
label: "Add candidates",
|
|
1152
|
-
variant: "text-ghost-sm",
|
|
1153
|
-
onClick: () => openShot()
|
|
1154
|
-
}
|
|
1155
|
-
)
|
|
1156
|
-
] }),
|
|
1059
|
+
) : /* @__PURE__ */ jsx3("div", { className: "drama-compare-empty", children: /* @__PURE__ */ jsx3("p", { children: "No video selected" }) }),
|
|
1157
1060
|
/* @__PURE__ */ jsxs3("div", { className: "drama-compare-heading", children: [
|
|
1158
1061
|
/* @__PURE__ */ jsxs3("div", { children: [
|
|
1159
1062
|
/* @__PURE__ */ jsx3("h3", { children: take?.title ?? `Candidate ${side}` }),
|
|
@@ -1167,6 +1070,7 @@ function CandidateCompare(props) {
|
|
|
1167
1070
|
Menu,
|
|
1168
1071
|
{
|
|
1169
1072
|
floating: true,
|
|
1073
|
+
cascading: true,
|
|
1170
1074
|
triggerIcon: "more",
|
|
1171
1075
|
label: `More actions for candidate ${side}`,
|
|
1172
1076
|
items: [
|
|
@@ -1295,12 +1199,23 @@ function ResolvedPlayer({
|
|
|
1295
1199
|
[shots, assets]
|
|
1296
1200
|
);
|
|
1297
1201
|
const resolved = useRequest(read);
|
|
1298
|
-
|
|
1202
|
+
const pending = !resolved?.data && !resolved?.error;
|
|
1203
|
+
const provisional = useMemo2(
|
|
1204
|
+
() => shots.map(({ id, title, durationMs, still, take }) => ({
|
|
1205
|
+
id,
|
|
1206
|
+
title,
|
|
1207
|
+
durationMs,
|
|
1208
|
+
poster: still && assets.previewUrl?.(still),
|
|
1209
|
+
src: take && assets.previewUrl?.(take.ref)
|
|
1210
|
+
})),
|
|
1211
|
+
[shots, assets]
|
|
1212
|
+
);
|
|
1299
1213
|
return /* @__PURE__ */ jsx3(
|
|
1300
1214
|
SequencePlayer,
|
|
1301
1215
|
{
|
|
1302
1216
|
title: label,
|
|
1303
|
-
clips: resolved
|
|
1217
|
+
clips: resolved?.data ?? provisional,
|
|
1218
|
+
pending,
|
|
1304
1219
|
initialShotId,
|
|
1305
1220
|
onEdit,
|
|
1306
1221
|
showFilmstrip,
|
|
@@ -1335,7 +1250,7 @@ function ResolvedPlayer({
|
|
|
1335
1250
|
async function resolvePreview(assets, ref) {
|
|
1336
1251
|
if (!ref) return {};
|
|
1337
1252
|
try {
|
|
1338
|
-
const url = await assets.resolve(ref);
|
|
1253
|
+
const url = await (assets.loadPreview?.(ref) ?? assets.resolve(ref));
|
|
1339
1254
|
return url ? { url } : { issue: "unavailable" };
|
|
1340
1255
|
} catch (error) {
|
|
1341
1256
|
const denied = typeof error === "object" && error !== null && "code" in error && error.code === "ACCESS_DENIED";
|
|
@@ -1346,10 +1261,10 @@ async function resolvePreview(assets, ref) {
|
|
|
1346
1261
|
}
|
|
1347
1262
|
|
|
1348
1263
|
// packages/short-drama-compare/src/production-view.tsx
|
|
1349
|
-
import { useCallback as useCallback2, useEffect as useEffect6, useRef as
|
|
1264
|
+
import { useCallback as useCallback2, useEffect as useEffect6, useRef as useRef8, useState as useState10 } from "react";
|
|
1350
1265
|
|
|
1351
1266
|
// packages/short-drama-compare/src/episode-create.tsx
|
|
1352
|
-
import { useId as
|
|
1267
|
+
import { useId as useId3, useState as useState9 } from "react";
|
|
1353
1268
|
import { Fragment as Fragment3, jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
1354
1269
|
function CreateEpisode({
|
|
1355
1270
|
mutate,
|
|
@@ -1358,10 +1273,10 @@ function CreateEpisode({
|
|
|
1358
1273
|
onClose,
|
|
1359
1274
|
onCreated
|
|
1360
1275
|
}) {
|
|
1361
|
-
const [title, setTitle] =
|
|
1362
|
-
const [error, setError] =
|
|
1363
|
-
const [episodeId] =
|
|
1364
|
-
const formId =
|
|
1276
|
+
const [title, setTitle] = useState9(`Episode ${number}`);
|
|
1277
|
+
const [error, setError] = useState9("");
|
|
1278
|
+
const [episodeId] = useState9(() => crypto.randomUUID());
|
|
1279
|
+
const formId = useId3();
|
|
1365
1280
|
return /* @__PURE__ */ jsx4(
|
|
1366
1281
|
Dialog,
|
|
1367
1282
|
{
|
|
@@ -1421,24 +1336,38 @@ function ProductionData({
|
|
|
1421
1336
|
render,
|
|
1422
1337
|
...props
|
|
1423
1338
|
}) {
|
|
1424
|
-
const { route, navigate, readScriptEpisodes } = props;
|
|
1425
|
-
const
|
|
1426
|
-
const
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1339
|
+
const { route, navigate, readScriptEpisodes, viewSnapshots } = props;
|
|
1340
|
+
const productionKey = `production:${instanceId}`;
|
|
1341
|
+
const saveSnapshot = useCallback2(
|
|
1342
|
+
(value) => {
|
|
1343
|
+
const current = viewSnapshots?.get(productionKey);
|
|
1344
|
+
if (!current || value.revision > current.revision) viewSnapshots?.set(productionKey, value);
|
|
1345
|
+
return current && current.revision >= value.revision ? current : value;
|
|
1346
|
+
},
|
|
1347
|
+
[viewSnapshots, productionKey]
|
|
1348
|
+
);
|
|
1349
|
+
const [request, setRequest] = useState10(0);
|
|
1350
|
+
const [changed, setChanged] = useState10();
|
|
1351
|
+
const [busy, setBusy] = useState10(false);
|
|
1352
|
+
const [failure, setFailure] = useState10("");
|
|
1353
|
+
const [creatingEpisode, setCreatingEpisode] = useState10(false);
|
|
1354
|
+
const writing = useRef8(false);
|
|
1431
1355
|
const read = useCallback2(
|
|
1432
|
-
() => client.invoke({ instanceId, operationId: "production.get" }, {}),
|
|
1433
|
-
[client, instanceId]
|
|
1356
|
+
() => client.invoke({ instanceId, operationId: "production.get" }, {}).then(saveSnapshot),
|
|
1357
|
+
[client, instanceId, saveSnapshot]
|
|
1434
1358
|
);
|
|
1435
|
-
const stored = useRequest(read, request);
|
|
1436
|
-
const data = changed ?? stored?.data;
|
|
1437
|
-
const readEpisodes = useCallback2(
|
|
1438
|
-
|
|
1439
|
-
|
|
1359
|
+
const stored = useRequest(read, request, viewSnapshots?.get(productionKey));
|
|
1360
|
+
const data = changed && changed.revision >= (stored?.data?.revision ?? -1) ? changed : stored?.data;
|
|
1361
|
+
const readEpisodes = useCallback2(async () => {
|
|
1362
|
+
const episodes2 = await (readScriptEpisodes?.() ?? Promise.resolve([]));
|
|
1363
|
+
viewSnapshots?.set("script.episodes", episodes2);
|
|
1364
|
+
return episodes2;
|
|
1365
|
+
}, [readScriptEpisodes, viewSnapshots]);
|
|
1366
|
+
const script = useRequest(
|
|
1367
|
+
readEpisodes,
|
|
1368
|
+
request,
|
|
1369
|
+
viewSnapshots?.get("script.episodes")
|
|
1440
1370
|
);
|
|
1441
|
-
const script = useRequest(readEpisodes, request);
|
|
1442
1371
|
const storedEpisodes = data?.value.episodes ?? [];
|
|
1443
1372
|
const authored = script?.data ?? [];
|
|
1444
1373
|
const episodes = [
|
|
@@ -1507,7 +1436,7 @@ function ProductionData({
|
|
|
1507
1436
|
},
|
|
1508
1437
|
{ requestKey: crypto.randomUUID() }
|
|
1509
1438
|
);
|
|
1510
|
-
setChanged(result);
|
|
1439
|
+
setChanged(saveSnapshot(result));
|
|
1511
1440
|
return true;
|
|
1512
1441
|
} catch (error) {
|
|
1513
1442
|
setFailure(
|
|
@@ -1529,11 +1458,11 @@ function ProductionData({
|
|
|
1529
1458
|
return /* @__PURE__ */ jsxs5(
|
|
1530
1459
|
"section",
|
|
1531
1460
|
{
|
|
1532
|
-
className: "drama-production",
|
|
1461
|
+
className: "drama-production drama-compare-view",
|
|
1533
1462
|
"data-review": route.view === "compare" ? route.view : void 0,
|
|
1534
1463
|
children: [
|
|
1535
|
-
failure && /* @__PURE__ */ jsxs5("div", { className: "drama-card", role: "alert", children: [
|
|
1536
|
-
/* @__PURE__ */ jsx5("p", { children: failure }),
|
|
1464
|
+
(failure || stored?.error || script?.error) && /* @__PURE__ */ jsxs5("div", { className: "drama-card", role: "alert", children: [
|
|
1465
|
+
/* @__PURE__ */ jsx5("p", { children: failure || stored?.error || script?.error }),
|
|
1537
1466
|
/* @__PURE__ */ jsx5(
|
|
1538
1467
|
Button,
|
|
1539
1468
|
{
|
|
@@ -1597,7 +1526,7 @@ Map the relevant source records and media to this view. Keep the current view st
|
|
|
1597
1526
|
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
1598
1527
|
import { createElement } from "react";
|
|
1599
1528
|
function CompareView(props) {
|
|
1600
|
-
const [comparison, setComparison] =
|
|
1529
|
+
const [comparison, setComparison] = useState11({});
|
|
1601
1530
|
return /* @__PURE__ */ jsx6(
|
|
1602
1531
|
ProductionData,
|
|
1603
1532
|
{
|
package/package.json
CHANGED