@fibrae/semi-foundation 0.1.0 → 0.2.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/anchor/foundation.d.ts +1 -1
- package/dist/anchor/foundation.js +21 -21
- package/dist/audio-player/foundation.d.ts +10 -10
- package/dist/audio-player/foundation.js +19 -19
- package/dist/auto-complete/foundation.d.ts +12 -12
- package/dist/auto-complete/foundation.js +51 -51
- package/dist/avatar/foundation.d.ts +5 -5
- package/dist/avatar/foundation.js +16 -16
- package/dist/backtop/foundation.d.ts +2 -2
- package/dist/backtop/foundation.js +7 -7
- package/dist/banner/foundation.d.ts +1 -1
- package/dist/banner/foundation.js +4 -4
- package/dist/base/auto-close-foundation.d.ts +8 -8
- package/dist/base/auto-close-foundation.js +15 -15
- package/dist/base/foundation.d.ts +4 -3
- package/dist/base/foundation.js +12 -11
- package/dist/breadcrumb/foundation.d.ts +5 -5
- package/dist/breadcrumb/foundation.js +9 -10
- package/dist/breadcrumb/item-foundation.d.ts +3 -3
- package/dist/breadcrumb/item-foundation.js +6 -6
- package/dist/calendar/event-util.js +1 -1
- package/dist/calendar/foundation.js +4 -4
- package/dist/calendar/month-foundation.d.ts +2 -2
- package/dist/calendar/month-foundation.js +6 -6
- package/dist/carousel/foundation.d.ts +17 -17
- package/dist/carousel/foundation.js +51 -51
- package/dist/cascader/foundation.d.ts +34 -26
- package/dist/cascader/foundation.js +143 -121
- package/dist/checkbox/checkbox-foundation.d.ts +2 -2
- package/dist/checkbox/checkbox-foundation.js +15 -15
- package/dist/checkbox/checkbox-group-foundation.d.ts +2 -2
- package/dist/checkbox/checkbox-group-foundation.js +8 -8
- package/dist/code-highlight/index.d.ts +1 -1
- package/dist/code-highlight/index.js +3 -3
- package/dist/collapse/foundation.d.ts +2 -2
- package/dist/collapse/foundation.js +7 -7
- package/dist/collapsible/foundation.d.ts +3 -3
- package/dist/collapsible/foundation.js +8 -8
- package/dist/color-picker/alpha-slider-foundation.d.ts +2 -4
- package/dist/color-picker/alpha-slider-foundation.js +10 -10
- package/dist/color-picker/color-choose-area-foundation.d.ts +2 -5
- package/dist/color-picker/color-choose-area-foundation.js +14 -14
- package/dist/color-picker/color-slider-foundation.d.ts +2 -4
- package/dist/color-picker/color-slider-foundation.js +10 -10
- package/dist/color-picker/data-part-foundation.d.ts +5 -5
- package/dist/color-picker/data-part-foundation.js +11 -11
- package/dist/color-picker/foundation.d.ts +4 -4
- package/dist/color-picker/foundation.js +10 -10
- package/dist/config-provider/breakpoint-observer.d.ts +3 -3
- package/dist/config-provider/breakpoint-observer.js +6 -6
- package/dist/cropper/foundation.d.ts +15 -15
- package/dist/cropper/foundation.js +26 -23
- package/dist/date-picker/_utils/picker-type.d.ts +1 -1
- package/dist/date-picker/foundation.d.ts +36 -36
- package/dist/date-picker/foundation.js +125 -129
- package/dist/date-picker/input-foundation.d.ts +9 -9
- package/dist/date-picker/input-foundation.js +28 -28
- package/dist/date-picker/months-grid-foundation.d.ts +17 -17
- package/dist/date-picker/months-grid-foundation.js +64 -65
- package/dist/date-picker/year-and-month-foundation.d.ts +3 -3
- package/dist/date-picker/year-and-month-foundation.js +11 -11
- package/dist/drag-move/foundation.d.ts +2 -2
- package/dist/drag-move/foundation.js +15 -13
- package/dist/dropdown/foundation.d.ts +8 -5
- package/dist/dropdown/foundation.js +32 -28
- package/dist/dropdown/menu-foundation.d.ts +1 -1
- package/dist/dropdown/menu-foundation.js +11 -11
- package/dist/feedback/foundation.d.ts +9 -9
- package/dist/feedback/foundation.js +33 -33
- package/dist/form/form-api-proxy.d.ts +8 -7
- package/dist/form/form-api-proxy.js +25 -25
- package/dist/form/foundation.d.ts +5 -5
- package/dist/form/foundation.js +60 -61
- package/dist/highlight/foundation.js +1 -1
- package/dist/hot-keys/foundation.d.ts +2 -2
- package/dist/hot-keys/foundation.js +5 -5
- package/dist/image/image-foundation.d.ts +4 -4
- package/dist/image/image-foundation.js +10 -10
- package/dist/image/preview-footer-foundation.d.ts +3 -3
- package/dist/image/preview-footer-foundation.js +10 -10
- package/dist/image/preview-foundation.js +7 -6
- package/dist/image/preview-image-foundation.d.ts +6 -8
- package/dist/image/preview-image-foundation.js +14 -14
- package/dist/image/preview-inner-foundation.d.ts +9 -9
- package/dist/image/preview-inner-foundation.js +38 -38
- package/dist/input/foundation.d.ts +10 -10
- package/dist/input/foundation.js +47 -49
- package/dist/input/text-entry-foundation.d.ts +3 -3
- package/dist/input/text-entry-foundation.js +14 -14
- package/dist/input/textarea-foundation.d.ts +7 -7
- package/dist/input/textarea-foundation.js +36 -36
- package/dist/input-number/foundation.d.ts +16 -14
- package/dist/input-number/foundation.js +54 -53
- package/dist/json-viewer/foundation.d.ts +8 -8
- package/dist/json-viewer/foundation.js +23 -23
- package/dist/lottie/foundation.d.ts +1 -1
- package/dist/lottie/foundation.js +4 -4
- package/dist/markdown-render/foundation.d.ts +1 -1
- package/dist/markdown-render/foundation.js +4 -4
- package/dist/modal/modal-content-foundation.d.ts +7 -7
- package/dist/modal/modal-content-foundation.js +20 -20
- package/dist/modal/modal-foundation.d.ts +6 -6
- package/dist/modal/modal-foundation.js +24 -24
- package/dist/navigation/foundation.d.ts +1 -1
- package/dist/navigation/foundation.js +14 -14
- package/dist/navigation/item-foundation.d.ts +1 -1
- package/dist/navigation/item-foundation.js +8 -8
- package/dist/navigation/sub-nav-foundation.d.ts +3 -3
- package/dist/navigation/sub-nav-foundation.js +17 -17
- package/dist/notification/notification-list-foundation.d.ts +7 -7
- package/dist/notification/notification-list-foundation.js +12 -12
- package/dist/overflow-list/foundation.d.ts +4 -4
- package/dist/overflow-list/foundation.js +18 -18
- package/dist/pagination/foundation.d.ts +8 -8
- package/dist/pagination/foundation.js +28 -28
- package/dist/pincode/foundation.d.ts +5 -5
- package/dist/pincode/foundation.js +22 -22
- package/dist/popconfirm/popconfirm-foundation.d.ts +7 -7
- package/dist/popconfirm/popconfirm-foundation.js +26 -26
- package/dist/radio/radio-foundation.d.ts +5 -5
- package/dist/radio/radio-foundation.js +15 -15
- package/dist/radio/radio-group-foundation.d.ts +2 -2
- package/dist/radio/radio-group-foundation.js +9 -9
- package/dist/rating/foundation.d.ts +10 -10
- package/dist/rating/foundation.js +35 -35
- package/dist/resizable/group/index.d.ts +6 -6
- package/dist/resizable/group/index.js +40 -40
- package/dist/resizable/single/index.d.ts +2 -2
- package/dist/resizable/single/index.js +9 -9
- package/dist/scroll-list/item-foundation.d.ts +7 -7
- package/dist/scroll-list/item-foundation.js +35 -35
- package/dist/select/foundation.d.ts +42 -56
- package/dist/select/foundation.js +214 -279
- package/dist/select/option-foundation.d.ts +23 -27
- package/dist/select/option-foundation.js +10 -18
- package/dist/side-sheet/side-sheet-foundation.d.ts +6 -6
- package/dist/side-sheet/side-sheet-foundation.js +22 -22
- package/dist/slider/foundation.d.ts +16 -16
- package/dist/slider/foundation.js +46 -46
- package/dist/sortable/accessibility.d.ts +1 -1
- package/dist/sortable/accessibility.js +2 -2
- package/dist/spin/foundation.d.ts +2 -2
- package/dist/spin/foundation.js +6 -6
- package/dist/steps/utils.d.ts +1 -1
- package/dist/switch/foundation.d.ts +2 -2
- package/dist/switch/foundation.js +7 -7
- package/dist/table/foundation.d.ts +14 -14
- package/dist/table/foundation.js +93 -93
- package/dist/table/utils.d.ts +2 -2
- package/dist/tabs/foundation.d.ts +5 -5
- package/dist/tabs/foundation.js +17 -17
- package/dist/tag-input/foundation.d.ts +11 -11
- package/dist/tag-input/foundation.js +52 -52
- package/dist/time-picker/foundation.d.ts +13 -13
- package/dist/time-picker/foundation.js +39 -39
- package/dist/time-picker/input-foundation.d.ts +4 -4
- package/dist/time-picker/input-foundation.js +13 -13
- package/dist/toast/toast-list-foundation.d.ts +7 -7
- package/dist/toast/toast-list-foundation.js +14 -14
- package/dist/tooltip/foundation.d.ts +9 -9
- package/dist/tooltip/foundation.js +67 -61
- package/dist/transfer/foundation.d.ts +22 -9
- package/dist/transfer/foundation.js +38 -23
- package/dist/tree/foundation.d.ts +14 -14
- package/dist/tree/foundation.js +61 -61
- package/dist/tree/shared.d.ts +1 -1
- package/dist/tree-select/foundation.d.ts +26 -20
- package/dist/tree-select/foundation.js +91 -83
- package/dist/typography/ellipsis.d.ts +4 -4
- package/dist/typography/ellipsis.js +8 -8
- package/dist/typography/format-numeral.d.ts +1 -1
- package/dist/typography/format-numeral.js +2 -2
- package/dist/upload/constants.d.ts +1 -1
- package/dist/upload/foundation.d.ts +17 -17
- package/dist/upload/foundation.js +92 -92
- package/dist/upload/utils.d.ts +3 -3
- package/dist/upload/utils.js +6 -6
- package/dist/user-guide/foundation.d.ts +3 -3
- package/dist/user-guide/foundation.js +19 -19
- package/dist/utils/a11y.d.ts +1 -1
- package/dist/utils/announcer.d.ts +2 -2
- package/dist/utils/announcer.js +4 -4
- package/dist/utils/focus-handle.d.ts +1 -1
- package/dist/utils/focus-handle.js +1 -2
- package/dist/utils/focus-scope.d.ts +5 -5
- package/dist/utils/focus-scope.js +10 -10
- package/dist/utils/is-promise.d.ts +1 -1
- package/dist/utils/release-holder.d.ts +2 -2
- package/dist/utils/release-holder.js +4 -4
- package/dist/video-player/foundation.d.ts +15 -15
- package/dist/video-player/foundation.js +89 -89
- package/dist/video-player/progress-foundation.d.ts +2 -2
- package/dist/video-player/progress-foundation.js +12 -12
- package/package.json +2 -2
|
@@ -7,19 +7,19 @@
|
|
|
7
7
|
export default class FocusScope {
|
|
8
8
|
#private;
|
|
9
9
|
/** Remembers the focused element to return to; a re-activation finds the focus already inside and keeps the first */
|
|
10
|
-
record()
|
|
10
|
+
record: () => void;
|
|
11
11
|
/** Traps Tab in `container` and focuses it, unless an element inside already took focus */
|
|
12
12
|
activate(container: HTMLElement, preventScroll?: boolean): void;
|
|
13
13
|
/** Focuses `container` without trapping Tab, for a non-modal overlay; an element inside may already have focus */
|
|
14
14
|
enter(container: HTMLElement, preventScroll?: boolean): void;
|
|
15
15
|
/** `activate` for a modal overlay, `enter` for a non-modal one */
|
|
16
|
-
engage(container: HTMLElement, modal: boolean, preventScroll?: boolean)
|
|
17
|
-
deactivate()
|
|
16
|
+
engage: (container: HTMLElement, modal: boolean, preventScroll?: boolean) => void;
|
|
17
|
+
deactivate: () => void;
|
|
18
18
|
/** Focuses the recorded element again; call it after the inert around the overlay is released */
|
|
19
|
-
restore(preventScroll?: boolean)
|
|
19
|
+
restore: (preventScroll?: boolean) => void;
|
|
20
20
|
/**
|
|
21
21
|
* `restore` unless the user moved focus out of a non-modal `container` (see `FocusTrapHandle.shouldRestoreFocus`).
|
|
22
22
|
* `container` is passed in rather than read from `enter`, which may not have run for this close.
|
|
23
23
|
*/
|
|
24
|
-
restoreIfAllowed(container: HTMLElement | null | undefined, modal: boolean, preventScroll?: boolean)
|
|
24
|
+
restoreIfAllowed: (container: HTMLElement | null | undefined, modal: boolean, preventScroll?: boolean) => void;
|
|
25
25
|
}
|
|
@@ -35,13 +35,13 @@ var FocusScope = class {
|
|
|
35
35
|
#previous = null;
|
|
36
36
|
#fallbacks = [];
|
|
37
37
|
/** Remembers the focused element to return to; a re-activation finds the focus already inside and keeps the first */
|
|
38
|
-
record() {
|
|
38
|
+
record = () => {
|
|
39
39
|
const active = FocusTrapHandle.getDeepActiveElement();
|
|
40
40
|
if (!this.#container?.contains(FocusTrapHandle.getActiveElement(this.#container))) {
|
|
41
41
|
this.#previous = active;
|
|
42
42
|
this.#fallbacks = popupTriggers(active);
|
|
43
43
|
}
|
|
44
|
-
}
|
|
44
|
+
};
|
|
45
45
|
/** Traps Tab in `container` and focuses it, unless an element inside already took focus */
|
|
46
46
|
activate(container, preventScroll) {
|
|
47
47
|
this.#trap?.destroy();
|
|
@@ -55,24 +55,24 @@ var FocusScope = class {
|
|
|
55
55
|
if (!container.contains(FocusTrapHandle.getActiveElement(container))) FocusTrapHandle.getFocusableElements(container)[0]?.focus({ preventScroll });
|
|
56
56
|
}
|
|
57
57
|
/** `activate` for a modal overlay, `enter` for a non-modal one */
|
|
58
|
-
engage(container, modal, preventScroll) {
|
|
58
|
+
engage = (container, modal, preventScroll) => {
|
|
59
59
|
if (modal) this.activate(container, preventScroll);
|
|
60
60
|
else this.enter(container, preventScroll);
|
|
61
|
-
}
|
|
62
|
-
deactivate() {
|
|
61
|
+
};
|
|
62
|
+
deactivate = () => {
|
|
63
63
|
this.#trap?.destroy();
|
|
64
64
|
this.#trap = null;
|
|
65
|
-
}
|
|
65
|
+
};
|
|
66
66
|
/** Focuses the recorded element again; call it after the inert around the overlay is released */
|
|
67
|
-
restore(preventScroll) {
|
|
67
|
+
restore = (preventScroll) => {
|
|
68
68
|
[this.#previous, ...this.#fallbacks].find(canTakeFocus)?.focus({ preventScroll });
|
|
69
|
-
}
|
|
69
|
+
};
|
|
70
70
|
/**
|
|
71
71
|
* `restore` unless the user moved focus out of a non-modal `container` (see `FocusTrapHandle.shouldRestoreFocus`).
|
|
72
72
|
* `container` is passed in rather than read from `enter`, which may not have run for this close.
|
|
73
73
|
*/
|
|
74
|
-
restoreIfAllowed(container, modal, preventScroll) {
|
|
74
|
+
restoreIfAllowed = (container, modal, preventScroll) => {
|
|
75
75
|
if (FocusTrapHandle.shouldRestoreFocus(container, modal)) this.restore(preventScroll);
|
|
76
|
-
}
|
|
76
|
+
};
|
|
77
77
|
};
|
|
78
78
|
export { FocusScope as default };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export default function isPromise(value:
|
|
1
|
+
export default function isPromise(value: unknown): value is PromiseLike<unknown>;
|
|
@@ -5,14 +5,14 @@
|
|
|
5
5
|
*/
|
|
6
6
|
var ReleaseHolder = class {
|
|
7
7
|
#release = null;
|
|
8
|
-
hold(acquire) {
|
|
8
|
+
hold = (acquire) => {
|
|
9
9
|
this.release();
|
|
10
10
|
this.#release = acquire();
|
|
11
|
-
}
|
|
12
|
-
release() {
|
|
11
|
+
};
|
|
12
|
+
release = () => {
|
|
13
13
|
const release = this.#release;
|
|
14
14
|
this.#release = null;
|
|
15
15
|
release?.();
|
|
16
|
-
}
|
|
16
|
+
};
|
|
17
17
|
};
|
|
18
18
|
export { ReleaseHolder as default };
|
|
@@ -55,39 +55,39 @@ export default class VideoPlayerFoundation<P extends VideoPlayerBaseProps = Vide
|
|
|
55
55
|
protected checkFullScreen(): boolean;
|
|
56
56
|
init(): void;
|
|
57
57
|
destroy(): void;
|
|
58
|
-
handleTimeChange(value: number)
|
|
59
|
-
handleTimeUpdate()
|
|
60
|
-
handleDurationChange()
|
|
61
|
-
handleError()
|
|
58
|
+
handleTimeChange: (value: number) => void;
|
|
59
|
+
handleTimeUpdate: () => void;
|
|
60
|
+
handleDurationChange: () => void;
|
|
61
|
+
handleError: () => void;
|
|
62
62
|
handleLoadStart: () => void;
|
|
63
|
-
handlePlayOrPause()
|
|
63
|
+
handlePlayOrPause: () => void;
|
|
64
64
|
handlePlay(): void;
|
|
65
65
|
handlePause(): void;
|
|
66
66
|
handleVideoPlay: () => void;
|
|
67
67
|
handleVideoPause: () => void;
|
|
68
68
|
handleCanPlay: () => void;
|
|
69
|
-
handleWaiting(locale: VideoPlayerNotificationLocale)
|
|
70
|
-
handleStalled(locale: VideoPlayerNotificationLocale)
|
|
69
|
+
handleWaiting: (locale: VideoPlayerNotificationLocale) => void;
|
|
70
|
+
handleStalled: (locale: VideoPlayerNotificationLocale) => void;
|
|
71
71
|
handleProgress: () => void;
|
|
72
72
|
handleEnded: () => void;
|
|
73
73
|
/** From the user (the slider); init applies the initial volume without notifying */
|
|
74
|
-
handleVolumeChange(value: number)
|
|
74
|
+
handleVolumeChange: (value: number) => void;
|
|
75
75
|
/** Mutes, or unmutes to the volume before muting; to half volume when that was 0 */
|
|
76
76
|
handleVolumeSilent: () => void;
|
|
77
77
|
handleFullscreen: () => void;
|
|
78
|
-
handleRateChange(rate: {
|
|
78
|
+
handleRateChange: (rate: {
|
|
79
79
|
label: string;
|
|
80
80
|
value: number;
|
|
81
|
-
}, locale: VideoPlayerNotificationLocale)
|
|
82
|
-
handleQualityChange(quality: {
|
|
81
|
+
}, locale: VideoPlayerNotificationLocale) => void;
|
|
82
|
+
handleQualityChange: (quality: {
|
|
83
83
|
label: string;
|
|
84
84
|
value: string;
|
|
85
|
-
}, locale: VideoPlayerNotificationLocale)
|
|
86
|
-
handleRouteChange(route: {
|
|
85
|
+
}, locale: VideoPlayerNotificationLocale) => void;
|
|
86
|
+
handleRouteChange: (route: {
|
|
87
87
|
label: string;
|
|
88
88
|
value: string;
|
|
89
|
-
}, locale: VideoPlayerNotificationLocale)
|
|
90
|
-
handleMirror(locale: VideoPlayerNotificationLocale)
|
|
89
|
+
}, locale: VideoPlayerNotificationLocale) => void;
|
|
90
|
+
handleMirror: (locale: VideoPlayerNotificationLocale) => void;
|
|
91
91
|
handlePictureInPicture: () => void;
|
|
92
92
|
handleMouseEnterWrapper: () => void;
|
|
93
93
|
handleMouseLeaveWrapper: () => void;
|
|
@@ -13,32 +13,32 @@ var VideoPlayerFoundation = class extends BaseFoundation {
|
|
|
13
13
|
if (this.#controlsTimer) clearTimeout(this.#controlsTimer);
|
|
14
14
|
}
|
|
15
15
|
#handleMouseMove = throttle(() => {
|
|
16
|
-
this.
|
|
16
|
+
this.adapter.setShowControls(true);
|
|
17
17
|
this.#clearTimer();
|
|
18
18
|
this.#controlsTimer = setTimeout(() => {
|
|
19
|
-
if (this.getStates().isPlaying) this.
|
|
19
|
+
if (this.getStates().isPlaying) this.adapter.setShowControls(false);
|
|
20
20
|
}, 3e3);
|
|
21
21
|
}, 200);
|
|
22
22
|
#applyMuted(video, muted) {
|
|
23
23
|
video.muted = muted;
|
|
24
|
-
this.
|
|
24
|
+
this.adapter.setMuted(muted);
|
|
25
25
|
}
|
|
26
26
|
#handleLeavePictureInPicture = () => {
|
|
27
|
-
const video = this.
|
|
27
|
+
const video = this.adapter.getVideo();
|
|
28
28
|
if (!video) return;
|
|
29
|
-
this.
|
|
29
|
+
this.adapter.setIsPlaying(!video.paused);
|
|
30
30
|
};
|
|
31
31
|
#handleTemporaryNotification(content) {
|
|
32
32
|
this.#stalled = false;
|
|
33
|
-
this.
|
|
34
|
-
this.
|
|
33
|
+
this.adapter.setNotificationContent(content);
|
|
34
|
+
this.adapter.setShowNotification(true);
|
|
35
35
|
clearTimeout(this.#notificationTimer);
|
|
36
36
|
this.#notificationTimer = setTimeout(() => {
|
|
37
|
-
this.
|
|
37
|
+
this.adapter.setShowNotification(false);
|
|
38
38
|
}, 1e3);
|
|
39
39
|
}
|
|
40
40
|
#restorePlayPosition() {
|
|
41
|
-
const video = this.
|
|
41
|
+
const video = this.adapter.getVideo();
|
|
42
42
|
if (!video) return;
|
|
43
43
|
const wasPlaying = !video.paused;
|
|
44
44
|
const currentTime = video.currentTime;
|
|
@@ -56,7 +56,7 @@ var VideoPlayerFoundation = class extends BaseFoundation {
|
|
|
56
56
|
#handleFullscreenChange = () => {
|
|
57
57
|
const isFullScreen = this.checkFullScreen();
|
|
58
58
|
if (isFullScreen === this.getStates().isFullScreen) return;
|
|
59
|
-
this.
|
|
59
|
+
this.adapter.setIsFullScreen(isFullScreen);
|
|
60
60
|
if (isFullScreen) document.addEventListener("mousemove", this.#handleMouseMove, { signal: this.signal });
|
|
61
61
|
else {
|
|
62
62
|
if (this.#scrollPosition) setTimeout(() => {
|
|
@@ -66,7 +66,7 @@ var VideoPlayerFoundation = class extends BaseFoundation {
|
|
|
66
66
|
document.removeEventListener("mousemove", this.#handleMouseMove);
|
|
67
67
|
this.#handleMouseMove.cancel();
|
|
68
68
|
this.#clearTimer();
|
|
69
|
-
this.
|
|
69
|
+
this.adapter.setShowControls(true);
|
|
70
70
|
}
|
|
71
71
|
};
|
|
72
72
|
#handleBodyKeyDown = (e) => {
|
|
@@ -74,7 +74,7 @@ var VideoPlayerFoundation = class extends BaseFoundation {
|
|
|
74
74
|
const target = e.target instanceof Element ? e.target : null;
|
|
75
75
|
const ownsKey = e.key === " " ? "button, input, select, textarea" : "input, select, textarea, [role=\"slider\"], [role=\"menu\"]";
|
|
76
76
|
if (e.defaultPrevented || target?.closest(ownsKey)) return;
|
|
77
|
-
const videoWrapper = this.
|
|
77
|
+
const videoWrapper = this.adapter.getVideoWrapper();
|
|
78
78
|
if (videoWrapper && !videoWrapper.contains(FocusTrapHandle.getActiveElement(videoWrapper))) return;
|
|
79
79
|
const { currentTime } = this.getStates();
|
|
80
80
|
const { seekTime } = this.getProps();
|
|
@@ -89,25 +89,25 @@ var VideoPlayerFoundation = class extends BaseFoundation {
|
|
|
89
89
|
else if (e.key === "ArrowRight") this.handleTimeChange(currentTime + seekTime);
|
|
90
90
|
};
|
|
91
91
|
#registerEvent() {
|
|
92
|
-
const video = this.
|
|
92
|
+
const video = this.adapter.getVideo();
|
|
93
93
|
if (!video) return;
|
|
94
94
|
document.addEventListener("keydown", this.#handleBodyKeyDown, { signal: this.signal });
|
|
95
95
|
document.addEventListener("fullscreenchange", this.#handleFullscreenChange, { signal: this.signal });
|
|
96
96
|
video.addEventListener("leavepictureinpicture", this.#handleLeavePictureInPicture, { signal: this.signal });
|
|
97
97
|
}
|
|
98
98
|
checkFullScreen() {
|
|
99
|
-
const videoWrapper = this.
|
|
99
|
+
const videoWrapper = this.adapter.getVideoWrapper();
|
|
100
100
|
return !!videoWrapper && document.fullscreenElement === videoWrapper;
|
|
101
101
|
}
|
|
102
102
|
init() {
|
|
103
103
|
const { volume, muted } = this.getProps();
|
|
104
104
|
const { playbackRate } = this.getStates();
|
|
105
|
-
const video = this.
|
|
105
|
+
const video = this.adapter.getVideo();
|
|
106
106
|
if (video) {
|
|
107
|
-
this.
|
|
107
|
+
this.adapter.setTotalTime(video.duration || 0);
|
|
108
108
|
const initialVolume = Math.floor(volume > 0 ? volume : 0);
|
|
109
109
|
video.volume = initialVolume / 100;
|
|
110
|
-
this.
|
|
110
|
+
this.adapter.setVolume(initialVolume);
|
|
111
111
|
this.#applyMuted(video, muted || initialVolume === 0);
|
|
112
112
|
video.defaultPlaybackRate = video.playbackRate = playbackRate;
|
|
113
113
|
const captions = video.querySelector("track[default]");
|
|
@@ -121,117 +121,117 @@ var VideoPlayerFoundation = class extends BaseFoundation {
|
|
|
121
121
|
this.#clearTimer();
|
|
122
122
|
clearTimeout(this.#notificationTimer);
|
|
123
123
|
}
|
|
124
|
-
handleTimeChange(value) {
|
|
125
|
-
const video = this.
|
|
124
|
+
handleTimeChange = (value) => {
|
|
125
|
+
const video = this.adapter.getVideo();
|
|
126
126
|
if (!video) return;
|
|
127
127
|
if (Number.isFinite(value)) {
|
|
128
128
|
const time = Number.isFinite(video.duration) ? clamp(value, 0, video.duration) : Math.max(value, 0);
|
|
129
129
|
video.currentTime = time;
|
|
130
|
-
this.
|
|
130
|
+
this.adapter.setCurrentTime(time);
|
|
131
131
|
}
|
|
132
|
-
}
|
|
133
|
-
handleTimeUpdate() {
|
|
134
|
-
const video = this.
|
|
132
|
+
};
|
|
133
|
+
handleTimeUpdate = () => {
|
|
134
|
+
const video = this.adapter.getVideo();
|
|
135
135
|
if (!video) return;
|
|
136
|
-
this.
|
|
137
|
-
}
|
|
138
|
-
handleDurationChange() {
|
|
139
|
-
const video = this.
|
|
136
|
+
this.adapter.setCurrentTime(video.currentTime);
|
|
137
|
+
};
|
|
138
|
+
handleDurationChange = () => {
|
|
139
|
+
const video = this.adapter.getVideo();
|
|
140
140
|
if (!video) return;
|
|
141
|
-
this.
|
|
142
|
-
}
|
|
143
|
-
handleError() {
|
|
144
|
-
this.
|
|
145
|
-
}
|
|
141
|
+
this.adapter.setTotalTime(video.duration || 0);
|
|
142
|
+
};
|
|
143
|
+
handleError = () => {
|
|
144
|
+
this.adapter.setIsError(true);
|
|
145
|
+
};
|
|
146
146
|
handleLoadStart = () => {
|
|
147
|
-
this.
|
|
148
|
-
const video = this.
|
|
147
|
+
this.adapter.setIsError(false);
|
|
148
|
+
const video = this.adapter.getVideo();
|
|
149
149
|
if (!video) return;
|
|
150
|
-
this.
|
|
151
|
-
this.
|
|
150
|
+
this.adapter.setIsPlaying(!video.paused);
|
|
151
|
+
this.adapter.setBufferedValue(0);
|
|
152
152
|
};
|
|
153
|
-
handlePlayOrPause() {
|
|
154
|
-
const video = this.
|
|
153
|
+
handlePlayOrPause = () => {
|
|
154
|
+
const video = this.adapter.getVideo();
|
|
155
155
|
if (!video) return;
|
|
156
156
|
if (video.paused) this.handlePlay();
|
|
157
157
|
else this.handlePause();
|
|
158
|
-
}
|
|
158
|
+
};
|
|
159
159
|
handlePlay() {
|
|
160
|
-
const video = this.
|
|
160
|
+
const video = this.adapter.getVideo();
|
|
161
161
|
if (video) ignoreExpectedMediaErrors(video.play());
|
|
162
162
|
}
|
|
163
163
|
handlePause() {
|
|
164
|
-
const video = this.
|
|
164
|
+
const video = this.adapter.getVideo();
|
|
165
165
|
if (video) video.pause();
|
|
166
166
|
}
|
|
167
167
|
handleVideoPlay = () => {
|
|
168
|
-
this.
|
|
169
|
-
this.
|
|
168
|
+
this.adapter.setIsPlaying(true);
|
|
169
|
+
this.adapter.notifyPlay();
|
|
170
170
|
if (this.getStates().isFullScreen) this.#handleMouseMove();
|
|
171
171
|
};
|
|
172
172
|
handleVideoPause = () => {
|
|
173
|
-
this.
|
|
174
|
-
this.
|
|
175
|
-
if (this.getStates().isFullScreen) this.
|
|
173
|
+
this.adapter.setIsPlaying(false);
|
|
174
|
+
this.adapter.notifyPause();
|
|
175
|
+
if (this.getStates().isFullScreen) this.adapter.setShowControls(true);
|
|
176
176
|
};
|
|
177
177
|
handleCanPlay = () => {
|
|
178
178
|
this.#stalled = false;
|
|
179
|
-
this.
|
|
179
|
+
this.adapter.setShowNotification(false);
|
|
180
180
|
};
|
|
181
|
-
handleWaiting(locale) {
|
|
181
|
+
handleWaiting = (locale) => {
|
|
182
182
|
this.#stalled = false;
|
|
183
|
-
this.
|
|
184
|
-
this.
|
|
185
|
-
}
|
|
186
|
-
handleStalled(locale) {
|
|
183
|
+
this.adapter.setNotificationContent(locale.loading);
|
|
184
|
+
this.adapter.setShowNotification(true);
|
|
185
|
+
};
|
|
186
|
+
handleStalled = (locale) => {
|
|
187
187
|
this.#stalled = true;
|
|
188
|
-
this.
|
|
189
|
-
this.
|
|
190
|
-
}
|
|
188
|
+
this.adapter.setNotificationContent(locale.stall);
|
|
189
|
+
this.adapter.setShowNotification(true);
|
|
190
|
+
};
|
|
191
191
|
handleProgress = () => {
|
|
192
192
|
if (this.#stalled) {
|
|
193
193
|
this.#stalled = false;
|
|
194
|
-
this.
|
|
194
|
+
this.adapter.setShowNotification(false);
|
|
195
195
|
}
|
|
196
|
-
const video = this.
|
|
196
|
+
const video = this.adapter.getVideo();
|
|
197
197
|
if (video && video.buffered.length > 0) {
|
|
198
198
|
const bufferedEnd = video.buffered.end(video.buffered.length - 1);
|
|
199
|
-
this.
|
|
199
|
+
this.adapter.setBufferedValue(bufferedEnd);
|
|
200
200
|
}
|
|
201
201
|
};
|
|
202
202
|
handleEnded = () => {
|
|
203
|
-
this.
|
|
204
|
-
this.
|
|
203
|
+
this.adapter.setIsPlaying(false);
|
|
204
|
+
this.adapter.setShowControls(true);
|
|
205
205
|
};
|
|
206
206
|
/** From the user (the slider); init applies the initial volume without notifying */
|
|
207
|
-
handleVolumeChange(value) {
|
|
208
|
-
const video = this.
|
|
207
|
+
handleVolumeChange = (value) => {
|
|
208
|
+
const video = this.adapter.getVideo();
|
|
209
209
|
if (!video) return;
|
|
210
210
|
const { volume, muted } = this.getStates();
|
|
211
211
|
const next = Math.floor(value > 0 ? value : 0);
|
|
212
212
|
video.volume = next / 100;
|
|
213
|
-
this.
|
|
213
|
+
this.adapter.setVolume(next);
|
|
214
214
|
this.#applyMuted(video, next === 0);
|
|
215
|
-
if (next !== (muted ? 0 : volume)) this.
|
|
216
|
-
}
|
|
215
|
+
if (next !== (muted ? 0 : volume)) this.adapter.notifyVolumeChange(next);
|
|
216
|
+
};
|
|
217
217
|
/** Mutes, or unmutes to the volume before muting; to half volume when that was 0 */
|
|
218
218
|
handleVolumeSilent = () => {
|
|
219
|
-
const video = this.
|
|
219
|
+
const video = this.adapter.getVideo();
|
|
220
220
|
const { volume, muted } = this.getStates();
|
|
221
221
|
if (!video) return;
|
|
222
222
|
if (muted) {
|
|
223
223
|
const restored = volume > 0 ? volume : 50;
|
|
224
224
|
video.volume = restored / 100;
|
|
225
|
-
this.
|
|
225
|
+
this.adapter.setVolume(restored);
|
|
226
226
|
this.#applyMuted(video, false);
|
|
227
|
-
this.
|
|
227
|
+
this.adapter.notifyVolumeChange(restored);
|
|
228
228
|
} else {
|
|
229
229
|
this.#applyMuted(video, true);
|
|
230
|
-
this.
|
|
230
|
+
this.adapter.notifyVolumeChange(0);
|
|
231
231
|
}
|
|
232
232
|
};
|
|
233
233
|
handleFullscreen = () => {
|
|
234
|
-
const videoWrapper = this.
|
|
234
|
+
const videoWrapper = this.adapter.getVideoWrapper();
|
|
235
235
|
const isFullScreen = this.checkFullScreen();
|
|
236
236
|
if (videoWrapper) {
|
|
237
237
|
if (isFullScreen) ignoreExpectedMediaErrors(document.exitFullscreen());
|
|
@@ -244,44 +244,44 @@ var VideoPlayerFoundation = class extends BaseFoundation {
|
|
|
244
244
|
}
|
|
245
245
|
}
|
|
246
246
|
};
|
|
247
|
-
handleRateChange(rate, locale) {
|
|
248
|
-
const video = this.
|
|
247
|
+
handleRateChange = (rate, locale) => {
|
|
248
|
+
const video = this.adapter.getVideo();
|
|
249
249
|
if (!video) return;
|
|
250
250
|
video.defaultPlaybackRate = video.playbackRate = rate.value;
|
|
251
|
-
this.
|
|
252
|
-
this.
|
|
251
|
+
this.adapter.setPlaybackRate(rate.value);
|
|
252
|
+
this.adapter.notifyRateChange(rate.value);
|
|
253
253
|
this.#handleTemporaryNotification(locale.rateChange.replace("${rate}", () => rate.label));
|
|
254
|
-
}
|
|
255
|
-
handleQualityChange(quality, locale) {
|
|
254
|
+
};
|
|
255
|
+
handleQualityChange = (quality, locale) => {
|
|
256
256
|
const changed = quality.value !== this.getStates().currentQuality;
|
|
257
|
-
this.
|
|
258
|
-
this.
|
|
257
|
+
this.adapter.setQuality(quality.value);
|
|
258
|
+
this.adapter.notifyQualityChange(quality.value);
|
|
259
259
|
this.#handleTemporaryNotification(locale.qualityChange.replace("${quality}", () => quality.label));
|
|
260
260
|
if (changed) this.#restorePlayPosition();
|
|
261
|
-
}
|
|
262
|
-
handleRouteChange(route, locale) {
|
|
261
|
+
};
|
|
262
|
+
handleRouteChange = (route, locale) => {
|
|
263
263
|
const changed = route.value !== this.getStates().currentRoute;
|
|
264
|
-
this.
|
|
265
|
-
this.
|
|
264
|
+
this.adapter.setRoute(route.value);
|
|
265
|
+
this.adapter.notifyRouteChange(route.value);
|
|
266
266
|
this.#handleTemporaryNotification(locale.routeChange.replace("${route}", () => route.label));
|
|
267
267
|
if (changed) this.#restorePlayPosition();
|
|
268
|
-
}
|
|
269
|
-
handleMirror(locale) {
|
|
268
|
+
};
|
|
269
|
+
handleMirror = (locale) => {
|
|
270
270
|
const { isMirror } = this.getStates();
|
|
271
|
-
this.
|
|
271
|
+
this.adapter.setIsMirror(!isMirror);
|
|
272
272
|
this.#handleTemporaryNotification(!isMirror ? locale.mirror : locale.cancelMirror);
|
|
273
|
-
}
|
|
273
|
+
};
|
|
274
274
|
handlePictureInPicture = () => {
|
|
275
|
-
const video = this.
|
|
275
|
+
const video = this.adapter.getVideo();
|
|
276
276
|
if (!video) return;
|
|
277
277
|
ignoreExpectedMediaErrors(video.requestPictureInPicture());
|
|
278
278
|
};
|
|
279
279
|
handleMouseEnterWrapper = () => {
|
|
280
|
-
this.
|
|
280
|
+
this.adapter.setShowControls(true);
|
|
281
281
|
};
|
|
282
282
|
handleMouseLeaveWrapper = () => {
|
|
283
283
|
const { isPlaying } = this.getStates();
|
|
284
|
-
if (isPlaying) this.
|
|
284
|
+
if (isPlaying) this.adapter.setShowControls(false);
|
|
285
285
|
};
|
|
286
286
|
};
|
|
287
287
|
export { VideoPlayerFoundation as default };
|
|
@@ -74,7 +74,7 @@ export default class VideoProgressFoundation<P extends VideoProgressBaseProps =
|
|
|
74
74
|
/** Follows pointerup and pointercancel, and also fires when the bar leaves the page mid-drag */
|
|
75
75
|
handleLostPointerCapture: () => void;
|
|
76
76
|
/** Tracks the pointer over the bar for the tooltip; `seek` also moves the playhead while dragging or on the press. */
|
|
77
|
-
handlePointerPosition(e: ProgressPointerEvent, { seek }: {
|
|
77
|
+
handlePointerPosition: (e: ProgressPointerEvent, { seek }: {
|
|
78
78
|
seek: boolean;
|
|
79
|
-
})
|
|
79
|
+
}) => void;
|
|
80
80
|
}
|
|
@@ -5,8 +5,8 @@ import { clamp } from "es-toolkit";
|
|
|
5
5
|
// src/video-player/progress-foundation.ts
|
|
6
6
|
var VideoProgressFoundation = class VideoProgressFoundation extends BaseFoundation {
|
|
7
7
|
#setActiveIndex(currentValue) {
|
|
8
|
-
this.
|
|
9
|
-
if (VideoProgressFoundation.isInMarker(marker, currentValue)) this.
|
|
8
|
+
this.adapter.getMarkersList().forEach((marker, index) => {
|
|
9
|
+
if (VideoProgressFoundation.isInMarker(marker, currentValue)) this.adapter.setActiveIndex(index);
|
|
10
10
|
});
|
|
11
11
|
}
|
|
12
12
|
/**
|
|
@@ -76,42 +76,42 @@ var VideoProgressFoundation = class VideoProgressFoundation extends BaseFoundati
|
|
|
76
76
|
};
|
|
77
77
|
if (!Object.hasOwn(targets, e.key)) return;
|
|
78
78
|
e.preventDefault();
|
|
79
|
-
this.
|
|
80
|
-
this.
|
|
79
|
+
this.adapter.setMovingInfo(null);
|
|
80
|
+
this.adapter.notifyChange(clamp(targets[e.key], 0, max));
|
|
81
81
|
};
|
|
82
82
|
/** A keyboard focus shows the playhead's time, not the last hovered one */
|
|
83
83
|
handleFocus = (e) => {
|
|
84
|
-
if (e.currentTarget.matches(":focus-visible")) this.
|
|
84
|
+
if (e.currentTarget.matches(":focus-visible")) this.adapter.setMovingInfo(null);
|
|
85
85
|
};
|
|
86
86
|
/** The bar keeps the pointer from the press on, so the moves and the release reach it even outside it */
|
|
87
87
|
handlePointerDown = (e) => {
|
|
88
88
|
if (isSecondaryPress(e)) return;
|
|
89
89
|
e.currentTarget.setPointerCapture(e.pointerId);
|
|
90
|
-
this.
|
|
90
|
+
this.adapter.setIsDragging(true);
|
|
91
91
|
this.handlePointerPosition(e, { seek: true });
|
|
92
92
|
};
|
|
93
93
|
/** Follows pointerup and pointercancel, and also fires when the bar leaves the page mid-drag */
|
|
94
94
|
handleLostPointerCapture = () => {
|
|
95
|
-
this.
|
|
95
|
+
this.adapter.setIsDragging(false);
|
|
96
96
|
};
|
|
97
97
|
/** Tracks the pointer over the bar for the tooltip; `seek` also moves the playhead while dragging or on the press. */
|
|
98
|
-
handlePointerPosition(e, { seek }) {
|
|
98
|
+
handlePointerPosition = (e, { seek }) => {
|
|
99
99
|
const { isDragging } = this.getStates();
|
|
100
100
|
const { max } = this.getProps();
|
|
101
|
-
const sliderRef = this.
|
|
101
|
+
const sliderRef = this.adapter.getSliderRef();
|
|
102
102
|
if (!sliderRef) return;
|
|
103
103
|
const rect = sliderRef.getBoundingClientRect();
|
|
104
104
|
const { offset, ratio: percentage } = getPointerRatio(rect, e, false);
|
|
105
105
|
const value = percentage * max;
|
|
106
106
|
if (seek && (isDragging || e.type === "pointerdown")) {
|
|
107
107
|
this.#setActiveIndex(value);
|
|
108
|
-
this.
|
|
108
|
+
this.adapter.notifyChange(value);
|
|
109
109
|
}
|
|
110
|
-
this.
|
|
110
|
+
this.adapter.setMovingInfo({
|
|
111
111
|
progress: percentage,
|
|
112
112
|
offset: offset - rect.width / 2,
|
|
113
113
|
value
|
|
114
114
|
});
|
|
115
|
-
}
|
|
115
|
+
};
|
|
116
116
|
};
|
|
117
117
|
export { VideoProgressFoundation as default };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fibrae/semi-foundation",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://semi-design-next.pages.dev",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@date-fns/tz": "^1.5.0",
|
|
27
27
|
"@dnd-kit/dom": "~0.5.1",
|
|
28
|
-
"@fibrae/semi-json-viewer-core": "0.
|
|
28
|
+
"@fibrae/semi-json-viewer-core": "0.2.0",
|
|
29
29
|
"@mdx-js/mdx": "^3.1.1",
|
|
30
30
|
"@shikijs/core": "^4.5.0",
|
|
31
31
|
"async-validator": "^4.2.5",
|