@juspay/svelte-ui-components 4.55.4 → 4.57.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Accordion/Accordion.svelte +66 -34
- package/dist/Accordion/Accordion.svelte.d.ts +1 -1
- package/dist/Accordion/properties.d.ts +11 -0
- package/dist/Avatar/Avatar.svelte +20 -6
- package/dist/Button/Button.svelte +34 -19
- package/dist/Button/Button.svelte.d.ts +1 -1
- package/dist/Button/properties.d.ts +10 -0
- package/dist/Card/Card.svelte +31 -18
- package/dist/Card/properties.d.ts +7 -0
- package/dist/Dialog/Dialog.svelte +186 -0
- package/dist/Dialog/Dialog.svelte.d.ts +4 -0
- package/dist/Dialog/properties.d.ts +23 -0
- package/dist/Dialog/properties.js +1 -0
- package/dist/DockPanel/DockPanel.svelte.d.ts +1 -1
- package/dist/EmptyState/EmptyState.svelte +58 -33
- package/dist/EmptyState/properties.d.ts +4 -0
- package/dist/FileInput/FileInput.svelte +130 -31
- package/dist/FileInput/FileInput.svelte.d.ts +1 -1
- package/dist/FileInput/properties.d.ts +9 -0
- package/dist/Icon/Icon.svelte +99 -21
- package/dist/Icon/properties.d.ts +8 -0
- package/dist/IframeViewer/IframeViewer.svelte +29 -5
- package/dist/IframeViewer/IframeViewer.svelte.d.ts +1 -1
- package/dist/IframeViewer/properties.d.ts +9 -0
- package/dist/Img/Img.svelte +31 -11
- package/dist/Img/Img.svelte.d.ts +1 -1
- package/dist/Img/properties.d.ts +13 -0
- package/dist/Input/Input.svelte +260 -170
- package/dist/Input/Input.svelte.d.ts +1 -1
- package/dist/Input/properties.d.ts +10 -0
- package/dist/Link/Link.svelte +33 -0
- package/dist/Link/Link.svelte.d.ts +4 -0
- package/dist/Link/properties.d.ts +14 -0
- package/dist/Link/properties.js +1 -0
- package/dist/Loader/Loader.svelte +50 -5
- package/dist/Loader/properties.d.ts +4 -0
- package/dist/MediaPlayer/MediaPlayer.svelte +223 -161
- package/dist/MediaPlayer/MediaPlayer.svelte.d.ts +1 -1
- package/dist/MediaPlayer/properties.d.ts +13 -0
- package/dist/Modal/Modal.svelte +52 -3
- package/dist/Modal/properties.d.ts +11 -0
- package/dist/NativeFileInput/NativeFileInput.svelte +52 -0
- package/dist/NativeFileInput/NativeFileInput.svelte.d.ts +6 -0
- package/dist/NativeFileInput/properties.d.ts +6 -0
- package/dist/NativeFileInput/properties.js +1 -0
- package/dist/Pill/Pill.svelte +7 -3
- package/dist/Pill/properties.d.ts +4 -0
- package/dist/Progress/Progress.svelte +46 -7
- package/dist/Progress/properties.d.ts +4 -0
- package/dist/Resizable/Resizable.svelte.d.ts +1 -1
- package/dist/Select/Select.svelte +535 -354
- package/dist/Select/Select.svelte.d.ts +1 -1
- package/dist/Select/dropdownPosition.d.ts +2 -0
- package/dist/Select/dropdownPosition.js +3 -2
- package/dist/Select/properties.d.ts +11 -0
- package/dist/ThemeSwitcher/ThemeSwitcher.svelte +5 -0
- package/dist/_chart/ChartContainer.svelte.d.ts +1 -1
- package/dist/_field/form-reset.d.ts +2 -0
- package/dist/_field/form-reset.js +34 -0
- package/dist/_interaction/dismissal.d.ts +2 -0
- package/dist/_interaction/dismissal.js +7 -1
- package/dist/_interaction/focus.d.ts +1 -1
- package/dist/_interaction/focus.js +66 -3
- package/dist/index.d.ts +6 -0
- package/dist/index.js +3 -0
- package/dist/styles/theme-dark.css +4 -0
- package/dist-codemod/codemod/migration-assets/legacy-display.css +5 -2
- package/dist-codemod/codemod/migration-assets/legacy-palette.css +4 -1
- package/dist-codemod/codemod/migration-assets/wc-display.json +15 -0
- package/dist-wc/index.js +5301 -3252
- package/package.json +2 -2
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import type { LoaderProperties } from './properties';
|
|
3
3
|
|
|
4
|
-
let { classes, testId }: LoaderProperties = $props();
|
|
4
|
+
let { classes, testId, variant = 'default', ariaLabel }: LoaderProperties = $props();
|
|
5
|
+
const mode = $derived(variant === 'border' || variant === 'orbit' ? variant : 'default');
|
|
5
6
|
</script>
|
|
6
7
|
|
|
7
8
|
<div
|
|
8
|
-
class="loader {classes ?? ''}"
|
|
9
|
+
class="loader loader-{mode} {classes ?? ''}"
|
|
10
|
+
role={ariaLabel ? 'status' : null}
|
|
11
|
+
aria-label={ariaLabel ?? null}
|
|
9
12
|
data-pw={typeof testId === 'string' ? testId : null}
|
|
10
13
|
testID={typeof testId === 'string' ? testId : null}
|
|
11
14
|
></div>
|
|
12
15
|
|
|
13
16
|
<style>
|
|
14
|
-
.loader {
|
|
17
|
+
.loader:where(.loader-default) {
|
|
15
18
|
font-size: var(--loader-font-size, 10px);
|
|
16
19
|
text-indent: var(--loader-text-indent, -9999em);
|
|
17
20
|
width: var(--loader-width, 20px);
|
|
@@ -55,7 +58,7 @@
|
|
|
55
58
|
-ms-transform: translateZ(0);
|
|
56
59
|
transform: translateZ(0);
|
|
57
60
|
}
|
|
58
|
-
.loader:before {
|
|
61
|
+
.loader:where(.loader-default):before {
|
|
59
62
|
width: var(--loader-before-width, 10px);
|
|
60
63
|
height: var(--loader-before-height, 10px);
|
|
61
64
|
background: var(--loader-foreground);
|
|
@@ -65,7 +68,7 @@
|
|
|
65
68
|
left: var(--loader-before-left, 0);
|
|
66
69
|
content: '';
|
|
67
70
|
}
|
|
68
|
-
.loader:after {
|
|
71
|
+
.loader:where(.loader-default):after {
|
|
69
72
|
background: var(--loader-background);
|
|
70
73
|
width: var(--loader-after-width, 15px);
|
|
71
74
|
height: var(--loader-after-height, 15px);
|
|
@@ -96,6 +99,48 @@
|
|
|
96
99
|
transform: rotate(360deg);
|
|
97
100
|
}
|
|
98
101
|
}
|
|
102
|
+
.loader-border {
|
|
103
|
+
box-sizing: border-box;
|
|
104
|
+
width: var(--loader-width, 20px);
|
|
105
|
+
height: var(--loader-height, 20px);
|
|
106
|
+
border: var(--loader-border-width, 2px) solid var(--loader-active-color, #6c5ff9);
|
|
107
|
+
border-left-color: var(--loader-track-color, #e0e0e0);
|
|
108
|
+
border-radius: var(--loader-border-radius, 50%);
|
|
109
|
+
animation: loader-spin var(--loader-spin-duration, 1s) var(--loader-spin-easing, linear)
|
|
110
|
+
infinite;
|
|
111
|
+
}
|
|
112
|
+
.loader-orbit {
|
|
113
|
+
box-sizing: border-box;
|
|
114
|
+
position: relative;
|
|
115
|
+
width: var(--loader-width, 48px);
|
|
116
|
+
height: var(--loader-height, 48px);
|
|
117
|
+
animation: loader-spin var(--loader-spin-duration, 1s) var(--loader-spin-easing, linear)
|
|
118
|
+
infinite;
|
|
119
|
+
}
|
|
120
|
+
.loader-orbit::before,
|
|
121
|
+
.loader-orbit::after {
|
|
122
|
+
content: '';
|
|
123
|
+
width: var(--loader-orbit-dot-size, 24px);
|
|
124
|
+
height: var(--loader-orbit-dot-size, 24px);
|
|
125
|
+
position: absolute;
|
|
126
|
+
border-radius: var(--loader-orbit-dot-radius, 50%);
|
|
127
|
+
background: var(--loader-orbit-primary, #6c5ff9);
|
|
128
|
+
animation: loader-spin var(--loader-spin-duration, 1s) var(--loader-spin-easing, linear)
|
|
129
|
+
infinite;
|
|
130
|
+
transform-origin: 0 100%;
|
|
131
|
+
}
|
|
132
|
+
.loader-orbit::before {
|
|
133
|
+
transform-origin: 0 50%;
|
|
134
|
+
background: var(--loader-orbit-secondary, #f3f4f6);
|
|
135
|
+
}
|
|
136
|
+
@keyframes loader-spin {
|
|
137
|
+
from {
|
|
138
|
+
transform: rotate(0deg);
|
|
139
|
+
}
|
|
140
|
+
to {
|
|
141
|
+
transform: rotate(360deg);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
99
144
|
/* An indefinite animation is the case this preference exists for: it never
|
|
100
145
|
ends, so a user who asked the OS to minimise motion gets a permanent loop.
|
|
101
146
|
The animation stops, but the element must still read as "busy" -- a guard
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
export type LoaderProperties = {
|
|
2
|
+
/** Preserve the existing gradient loader by default; opt into native border/orbit paint. */
|
|
3
|
+
variant?: 'default' | 'border' | 'orbit';
|
|
4
|
+
/** Optional accessible status name for a standalone spinner. */
|
|
5
|
+
ariaLabel?: string;
|
|
2
6
|
classes?: string;
|
|
3
7
|
testId?: string;
|
|
4
8
|
};
|
|
@@ -14,15 +14,21 @@
|
|
|
14
14
|
import type { MediaPlayerProperties } from './properties';
|
|
15
15
|
|
|
16
16
|
let {
|
|
17
|
+
unstyled = false,
|
|
18
|
+
audioOnly = false,
|
|
19
|
+
nativeAttrs,
|
|
20
|
+
children,
|
|
21
|
+
// eslint-disable-next-line no-useless-assignment -- Bindable output is assigned by the mounted DOM reference.
|
|
22
|
+
element = $bindable(),
|
|
17
23
|
src,
|
|
18
24
|
type,
|
|
19
25
|
alt = '',
|
|
20
|
-
ariaLabel
|
|
26
|
+
ariaLabel,
|
|
21
27
|
autoplay = true,
|
|
22
28
|
loop = false,
|
|
23
29
|
controls = false,
|
|
24
30
|
fallback,
|
|
25
|
-
playing = $bindable(
|
|
31
|
+
playing = $bindable(untrack(() => autoplay)),
|
|
26
32
|
muted = $bindable(true),
|
|
27
33
|
playIcon,
|
|
28
34
|
pauseIcon,
|
|
@@ -43,6 +49,7 @@
|
|
|
43
49
|
currentTime = $bindable(0),
|
|
44
50
|
duration = $bindable(0),
|
|
45
51
|
onplay,
|
|
52
|
+
onplayerror,
|
|
46
53
|
onpause,
|
|
47
54
|
onvolumechange,
|
|
48
55
|
oncaptionschange,
|
|
@@ -53,6 +60,8 @@
|
|
|
53
60
|
classes
|
|
54
61
|
}: MediaPlayerProperties = $props();
|
|
55
62
|
|
|
63
|
+
const effectiveAriaLabel = $derived(ariaLabel ?? (audioOnly ? 'Audio player' : 'Video player'));
|
|
64
|
+
|
|
56
65
|
// HTMLMediaElement.HAVE_METADATA. Named rather than inlined as 1, because `readyState >= 1`
|
|
57
66
|
// at a call site reads like a truthiness check rather than a specific media state.
|
|
58
67
|
const HAVE_METADATA = 1;
|
|
@@ -64,7 +73,11 @@
|
|
|
64
73
|
// A host write that arrived before the element could accept it; applied once metadata is.
|
|
65
74
|
let pendingSeek: number | null = null;
|
|
66
75
|
|
|
67
|
-
let videoPlayer
|
|
76
|
+
let videoPlayer = $state<HTMLVideoElement | HTMLAudioElement | null>(null);
|
|
77
|
+
const assignMediaElement = (node: HTMLVideoElement | HTMLAudioElement | null) => {
|
|
78
|
+
videoPlayer = node;
|
|
79
|
+
element = node;
|
|
80
|
+
};
|
|
68
81
|
let container: HTMLDivElement | null = $state(null);
|
|
69
82
|
let isFullscreen = $state(false);
|
|
70
83
|
|
|
@@ -93,12 +106,28 @@
|
|
|
93
106
|
return `${minutes}:${padded}`;
|
|
94
107
|
}
|
|
95
108
|
|
|
109
|
+
let playRevision = 0;
|
|
110
|
+
const requestPlay = (): void => {
|
|
111
|
+
const media = videoPlayer;
|
|
112
|
+
const revision = ++playRevision;
|
|
113
|
+
if (media === null) {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
void media.play().catch((error: unknown) => {
|
|
117
|
+
if (media !== videoPlayer || revision !== playRevision) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
playing = false;
|
|
121
|
+
onplayerror?.(error);
|
|
122
|
+
});
|
|
123
|
+
};
|
|
124
|
+
|
|
96
125
|
function togglePlayback(): void {
|
|
97
126
|
if (videoPlayer === null) {
|
|
98
127
|
return;
|
|
99
128
|
}
|
|
100
129
|
if (videoPlayer.paused) {
|
|
101
|
-
|
|
130
|
+
requestPlay();
|
|
102
131
|
} else {
|
|
103
132
|
videoPlayer.pause();
|
|
104
133
|
}
|
|
@@ -116,7 +145,7 @@
|
|
|
116
145
|
return;
|
|
117
146
|
}
|
|
118
147
|
if (playing && videoPlayer.paused) {
|
|
119
|
-
|
|
148
|
+
requestPlay();
|
|
120
149
|
} else if (!playing && !videoPlayer.paused) {
|
|
121
150
|
videoPlayer.pause();
|
|
122
151
|
}
|
|
@@ -358,182 +387,215 @@
|
|
|
358
387
|
});
|
|
359
388
|
</script>
|
|
360
389
|
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
390
|
+
{#if audioOnly}
|
|
391
|
+
<audio
|
|
392
|
+
{...nativeAttrs}
|
|
393
|
+
bind:this={() => videoPlayer, assignMediaElement}
|
|
394
|
+
bind:muted
|
|
395
|
+
src={src || null}
|
|
396
|
+
class={classes ?? ''}
|
|
397
|
+
data-pw={testId}
|
|
398
|
+
aria-label={effectiveAriaLabel}
|
|
399
|
+
{autoplay}
|
|
400
|
+
{controls}
|
|
401
|
+
{loop}
|
|
402
|
+
onplay={handlePlay}
|
|
403
|
+
onpause={handlePause}
|
|
404
|
+
ontimeupdate={handleTimeUpdate}
|
|
405
|
+
onloadedmetadata={handleLoadedMetadata}
|
|
406
|
+
>
|
|
407
|
+
{@render children?.()}
|
|
408
|
+
</audio>
|
|
409
|
+
{:else if unstyled && type === 'video'}
|
|
410
|
+
<video
|
|
411
|
+
{...nativeAttrs}
|
|
412
|
+
bind:this={() => videoPlayer, assignMediaElement}
|
|
413
|
+
bind:muted
|
|
414
|
+
src={src || null}
|
|
415
|
+
class={classes ?? ''}
|
|
416
|
+
data-pw={testId}
|
|
417
|
+
aria-label={effectiveAriaLabel}
|
|
418
|
+
{autoplay}
|
|
419
|
+
{controls}
|
|
420
|
+
{loop}
|
|
421
|
+
playsinline
|
|
422
|
+
onplay={handlePlay}
|
|
423
|
+
onpause={handlePause}
|
|
424
|
+
ontimeupdate={handleTimeUpdate}
|
|
425
|
+
onloadedmetadata={handleLoadedMetadata}
|
|
426
|
+
>
|
|
427
|
+
{@render children?.()}
|
|
428
|
+
</video>
|
|
429
|
+
{:else}
|
|
430
|
+
<div
|
|
431
|
+
bind:this={container}
|
|
432
|
+
class="media-player {classes ?? ''}"
|
|
433
|
+
class:fullscreen={isFullscreen}
|
|
434
|
+
data-pw={typeof testId === 'string' ? testId : null}
|
|
435
|
+
>
|
|
436
|
+
{#if type === 'image'}
|
|
437
|
+
<span class="media-image">
|
|
438
|
+
<Img {src} {alt} {fallback} />
|
|
439
|
+
</span>
|
|
440
|
+
{:else}
|
|
441
|
+
<video
|
|
442
|
+
{...nativeAttrs}
|
|
443
|
+
bind:this={() => videoPlayer, assignMediaElement}
|
|
444
|
+
bind:muted
|
|
445
|
+
src={src || null}
|
|
446
|
+
class="media"
|
|
447
|
+
aria-label={effectiveAriaLabel}
|
|
448
|
+
{controls}
|
|
449
|
+
{autoplay}
|
|
450
|
+
{loop}
|
|
451
|
+
playsinline
|
|
452
|
+
preload={hasTransportRow ? 'metadata' : nativeAttrs?.preload}
|
|
453
|
+
onplay={handlePlay}
|
|
454
|
+
onpause={handlePause}
|
|
455
|
+
ontimeupdate={handleTimeUpdate}
|
|
456
|
+
onloadedmetadata={handleLoadedMetadata}
|
|
457
|
+
>
|
|
458
|
+
{@render children?.()}
|
|
459
|
+
{#if hasCaptions}
|
|
460
|
+
<track
|
|
461
|
+
bind:this={captionTrack}
|
|
462
|
+
kind="captions"
|
|
463
|
+
src={captionsSrc}
|
|
464
|
+
label={typeof captionsLabel === 'string' ? captionsLabel : null}
|
|
465
|
+
srclang={typeof captionsSrcLang === 'string' ? captionsSrcLang : null}
|
|
466
|
+
/>
|
|
467
|
+
{/if}
|
|
468
|
+
</video>
|
|
469
|
+
|
|
470
|
+
{#if !controls}
|
|
471
|
+
<!-- A video cannot carry role="button". The full-surface native button
|
|
411
472
|
preserves pointer/keyboard playback without nesting the other controls. -->
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
473
|
+
<button
|
|
474
|
+
type="button"
|
|
475
|
+
class="media-surface-action"
|
|
476
|
+
aria-label={playing ? 'Pause video' : 'Play video'}
|
|
477
|
+
onclick={togglePlayback}
|
|
478
|
+
></button>
|
|
479
|
+
<div class="overlay">
|
|
480
|
+
<div class="center-controls">
|
|
481
|
+
<div class="control center-control">
|
|
482
|
+
<Button onclick={togglePlayback} ariaLabel={playing ? 'Pause video' : 'Play video'}>
|
|
483
|
+
{#if playing}
|
|
484
|
+
{#if typeof pauseIcon === 'function'}
|
|
485
|
+
{@render pauseIcon()}
|
|
486
|
+
{:else}
|
|
487
|
+
<!-- eslint-disable-next-line svelte/no-at-html-tags -->
|
|
488
|
+
{@html pauseSvg}
|
|
489
|
+
{/if}
|
|
490
|
+
{:else if typeof playIcon === 'function'}
|
|
491
|
+
{@render playIcon()}
|
|
425
492
|
{:else}
|
|
426
493
|
<!-- eslint-disable-next-line svelte/no-at-html-tags -->
|
|
427
|
-
{@html
|
|
494
|
+
{@html playSvg}
|
|
428
495
|
{/if}
|
|
429
|
-
|
|
430
|
-
{@render playIcon()}
|
|
431
|
-
{:else}
|
|
432
|
-
<!-- eslint-disable-next-line svelte/no-at-html-tags -->
|
|
433
|
-
{@html playSvg}
|
|
434
|
-
{/if}
|
|
435
|
-
</Button>
|
|
436
|
-
</div>
|
|
437
|
-
</div>
|
|
438
|
-
<div class="bottom-controls" class:transport={hasTransportRow}>
|
|
439
|
-
{#if seekBar}
|
|
440
|
-
<div class="seek" data-pw={typeof testId === 'string' ? `${testId}-seek` : null}>
|
|
441
|
-
<Slider
|
|
442
|
-
value={currentTime}
|
|
443
|
-
min={0}
|
|
444
|
-
max={duration > 0 ? duration : 1}
|
|
445
|
-
step={0.1}
|
|
446
|
-
disabled={duration <= 0}
|
|
447
|
-
oninput={handleSeek}
|
|
448
|
-
onchange={handleSeek}
|
|
449
|
-
ariaLabel="Seek"
|
|
450
|
-
/>
|
|
496
|
+
</Button>
|
|
451
497
|
</div>
|
|
452
|
-
|
|
453
|
-
{
|
|
454
|
-
|
|
455
|
-
{
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
{
|
|
498
|
+
</div>
|
|
499
|
+
<div class="bottom-controls" class:transport={hasTransportRow}>
|
|
500
|
+
{#if seekBar}
|
|
501
|
+
<div class="seek" data-pw={typeof testId === 'string' ? `${testId}-seek` : null}>
|
|
502
|
+
<Slider
|
|
503
|
+
value={currentTime}
|
|
504
|
+
min={0}
|
|
505
|
+
max={duration > 0 ? duration : 1}
|
|
506
|
+
step={0.1}
|
|
507
|
+
disabled={duration <= 0}
|
|
508
|
+
oninput={handleSeek}
|
|
509
|
+
onchange={handleSeek}
|
|
510
|
+
ariaLabel="Seek"
|
|
511
|
+
/>
|
|
512
|
+
</div>
|
|
513
|
+
{/if}
|
|
514
|
+
{#if timeDisplay}
|
|
515
|
+
<span class="time" data-pw={typeof testId === 'string' ? `${testId}-time` : null}>
|
|
516
|
+
{formatTime(currentTime)} / {formatTime(duration)}
|
|
517
|
+
</span>
|
|
518
|
+
{/if}
|
|
519
|
+
<div class="control bottom-control">
|
|
520
|
+
<Button onclick={toggleMute} ariaLabel={muted ? 'Unmute' : 'Mute'}>
|
|
521
|
+
{#if muted}
|
|
522
|
+
{#if typeof muteIcon === 'function'}
|
|
523
|
+
{@render muteIcon()}
|
|
524
|
+
{:else}
|
|
525
|
+
<!-- eslint-disable-next-line svelte/no-at-html-tags -->
|
|
526
|
+
{@html muteSvg}
|
|
527
|
+
{/if}
|
|
528
|
+
{:else if typeof unmuteIcon === 'function'}
|
|
529
|
+
{@render unmuteIcon()}
|
|
463
530
|
{:else}
|
|
464
531
|
<!-- eslint-disable-next-line svelte/no-at-html-tags -->
|
|
465
|
-
{@html
|
|
532
|
+
{@html volumeSvg}
|
|
466
533
|
{/if}
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
{#if captionsButton && hasCaptions}
|
|
476
|
-
<div
|
|
477
|
-
class="control bottom-control"
|
|
478
|
-
data-pw={typeof testId === 'string' ? `${testId}-captions` : null}
|
|
479
|
-
>
|
|
480
|
-
<!-- A native button rather than `Button`: the pressed state is the whole
|
|
534
|
+
</Button>
|
|
535
|
+
</div>
|
|
536
|
+
{#if captionsButton && hasCaptions}
|
|
537
|
+
<div
|
|
538
|
+
class="control bottom-control"
|
|
539
|
+
data-pw={typeof testId === 'string' ? `${testId}-captions` : null}
|
|
540
|
+
>
|
|
541
|
+
<!-- A native button rather than `Button`: the pressed state is the whole
|
|
481
542
|
point of this control and `Button` has no `aria-pressed`. The name stays
|
|
482
543
|
"Captions" and `aria-pressed` carries on/off, so a screen reader hears
|
|
483
544
|
"Captions, toggle button, pressed" rather than a name that flips under it. -->
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
545
|
+
<button
|
|
546
|
+
type="button"
|
|
547
|
+
class="captions-toggle"
|
|
548
|
+
aria-label="Captions"
|
|
549
|
+
aria-pressed={captionsVisible}
|
|
550
|
+
onclick={toggleCaptions}
|
|
551
|
+
>
|
|
552
|
+
{#if captionsVisible}
|
|
553
|
+
{#if typeof captionsOnIcon === 'function'}
|
|
554
|
+
{@render captionsOnIcon()}
|
|
555
|
+
{:else}
|
|
556
|
+
<!-- eslint-disable-next-line svelte/no-at-html-tags -->
|
|
557
|
+
{@html captionsOnSvg}
|
|
558
|
+
{/if}
|
|
559
|
+
{:else if typeof captionsIcon === 'function'}
|
|
560
|
+
{@render captionsIcon()}
|
|
494
561
|
{:else}
|
|
495
562
|
<!-- eslint-disable-next-line svelte/no-at-html-tags -->
|
|
496
|
-
{@html
|
|
563
|
+
{@html captionsSvg}
|
|
497
564
|
{/if}
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
</div>
|
|
506
|
-
{/if}
|
|
507
|
-
{#if fullscreenButton}
|
|
508
|
-
<div
|
|
509
|
-
class="control bottom-control"
|
|
510
|
-
data-pw={typeof testId === 'string' ? `${testId}-fullscreen` : null}
|
|
511
|
-
>
|
|
512
|
-
<Button
|
|
513
|
-
onclick={toggleFullscreen}
|
|
514
|
-
ariaLabel={isFullscreen ? 'Exit fullscreen' : 'Enter fullscreen'}
|
|
565
|
+
</button>
|
|
566
|
+
</div>
|
|
567
|
+
{/if}
|
|
568
|
+
{#if fullscreenButton}
|
|
569
|
+
<div
|
|
570
|
+
class="control bottom-control"
|
|
571
|
+
data-pw={typeof testId === 'string' ? `${testId}-fullscreen` : null}
|
|
515
572
|
>
|
|
516
|
-
|
|
517
|
-
{
|
|
518
|
-
|
|
573
|
+
<Button
|
|
574
|
+
onclick={toggleFullscreen}
|
|
575
|
+
ariaLabel={isFullscreen ? 'Exit fullscreen' : 'Enter fullscreen'}
|
|
576
|
+
>
|
|
577
|
+
{#if isFullscreen}
|
|
578
|
+
{#if typeof exitFullscreenIcon === 'function'}
|
|
579
|
+
{@render exitFullscreenIcon()}
|
|
580
|
+
{:else}
|
|
581
|
+
<!-- eslint-disable-next-line svelte/no-at-html-tags -->
|
|
582
|
+
{@html exitFullscreenSvg}
|
|
583
|
+
{/if}
|
|
584
|
+
{:else if typeof fullscreenIcon === 'function'}
|
|
585
|
+
{@render fullscreenIcon()}
|
|
519
586
|
{:else}
|
|
520
587
|
<!-- eslint-disable-next-line svelte/no-at-html-tags -->
|
|
521
|
-
{@html
|
|
588
|
+
{@html fullscreenSvg}
|
|
522
589
|
{/if}
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
{@html fullscreenSvg}
|
|
528
|
-
{/if}
|
|
529
|
-
</Button>
|
|
530
|
-
</div>
|
|
531
|
-
{/if}
|
|
590
|
+
</Button>
|
|
591
|
+
</div>
|
|
592
|
+
{/if}
|
|
593
|
+
</div>
|
|
532
594
|
</div>
|
|
533
|
-
|
|
595
|
+
{/if}
|
|
534
596
|
{/if}
|
|
535
|
-
|
|
536
|
-
|
|
597
|
+
</div>
|
|
598
|
+
{/if}
|
|
537
599
|
|
|
538
600
|
<style>
|
|
539
601
|
.media-player {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { MediaPlayerProperties } from './properties';
|
|
2
|
-
declare const MediaPlayer: import("svelte").Component<MediaPlayerProperties, {}, "
|
|
2
|
+
declare const MediaPlayer: import("svelte").Component<MediaPlayerProperties, {}, "playing" | "element" | "muted" | "captionsVisible" | "currentTime" | "duration">;
|
|
3
3
|
type MediaPlayer = ReturnType<typeof MediaPlayer>;
|
|
4
4
|
export default MediaPlayer;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { HTMLVideoAttributes } from 'svelte/elements';
|
|
3
|
+
/** Released 4.x discriminator; keep exhaustive consumer mappings valid. */
|
|
2
4
|
export type MediaType = 'image' | 'video';
|
|
3
5
|
export type MediaPlayerProperties = MandatoryMediaPlayerProperties & OptionalMediaPlayerProperties & MediaPlayerEventProperties;
|
|
4
6
|
export type MandatoryMediaPlayerProperties = {
|
|
@@ -6,6 +8,15 @@ export type MandatoryMediaPlayerProperties = {
|
|
|
6
8
|
type: MediaType;
|
|
7
9
|
};
|
|
8
10
|
export type OptionalMediaPlayerProperties = {
|
|
11
|
+
/** Opt-in native audio rendering, without widening the released type discriminator. */
|
|
12
|
+
audioOnly?: boolean;
|
|
13
|
+
/** Wrapper-free native video for art-directed/background media with host-owned controls. */
|
|
14
|
+
unstyled?: boolean;
|
|
15
|
+
/** Bindable native video reference for visibility and playback controllers. */
|
|
16
|
+
element?: HTMLVideoElement | HTMLAudioElement | null;
|
|
17
|
+
nativeAttrs?: Omit<HTMLVideoAttributes, Extract<keyof HTMLVideoAttributes, `on${string}`> | 'src' | 'class' | 'onplay' | 'onpause' | 'onloadedmetadata' | 'ontimeupdate' | 'muted'>;
|
|
18
|
+
/** Native source/track children; retains browser media-query/codec selection. */
|
|
19
|
+
children?: Snippet;
|
|
9
20
|
alt?: string;
|
|
10
21
|
/** Accessible name for the video. Image naming uses alt. Defaults to "Video player". */
|
|
11
22
|
ariaLabel?: string;
|
|
@@ -91,6 +102,8 @@ export type OptionalMediaPlayerProperties = {
|
|
|
91
102
|
classes?: string;
|
|
92
103
|
};
|
|
93
104
|
export type MediaPlayerEventProperties = {
|
|
105
|
+
/** Rejected autoplay/play request; state settles to paused. */
|
|
106
|
+
onplayerror?: (error: unknown) => void;
|
|
94
107
|
onplay?: (event: Event) => void;
|
|
95
108
|
onpause?: (event: Event) => void;
|
|
96
109
|
onvolumechange?: (muted: boolean) => void;
|