@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.
Files changed (194) hide show
  1. package/dist/anchor/foundation.d.ts +1 -1
  2. package/dist/anchor/foundation.js +21 -21
  3. package/dist/audio-player/foundation.d.ts +10 -10
  4. package/dist/audio-player/foundation.js +19 -19
  5. package/dist/auto-complete/foundation.d.ts +12 -12
  6. package/dist/auto-complete/foundation.js +51 -51
  7. package/dist/avatar/foundation.d.ts +5 -5
  8. package/dist/avatar/foundation.js +16 -16
  9. package/dist/backtop/foundation.d.ts +2 -2
  10. package/dist/backtop/foundation.js +7 -7
  11. package/dist/banner/foundation.d.ts +1 -1
  12. package/dist/banner/foundation.js +4 -4
  13. package/dist/base/auto-close-foundation.d.ts +8 -8
  14. package/dist/base/auto-close-foundation.js +15 -15
  15. package/dist/base/foundation.d.ts +4 -3
  16. package/dist/base/foundation.js +12 -11
  17. package/dist/breadcrumb/foundation.d.ts +5 -5
  18. package/dist/breadcrumb/foundation.js +9 -10
  19. package/dist/breadcrumb/item-foundation.d.ts +3 -3
  20. package/dist/breadcrumb/item-foundation.js +6 -6
  21. package/dist/calendar/event-util.js +1 -1
  22. package/dist/calendar/foundation.js +4 -4
  23. package/dist/calendar/month-foundation.d.ts +2 -2
  24. package/dist/calendar/month-foundation.js +6 -6
  25. package/dist/carousel/foundation.d.ts +17 -17
  26. package/dist/carousel/foundation.js +51 -51
  27. package/dist/cascader/foundation.d.ts +34 -26
  28. package/dist/cascader/foundation.js +143 -121
  29. package/dist/checkbox/checkbox-foundation.d.ts +2 -2
  30. package/dist/checkbox/checkbox-foundation.js +15 -15
  31. package/dist/checkbox/checkbox-group-foundation.d.ts +2 -2
  32. package/dist/checkbox/checkbox-group-foundation.js +8 -8
  33. package/dist/code-highlight/index.d.ts +1 -1
  34. package/dist/code-highlight/index.js +3 -3
  35. package/dist/collapse/foundation.d.ts +2 -2
  36. package/dist/collapse/foundation.js +7 -7
  37. package/dist/collapsible/foundation.d.ts +3 -3
  38. package/dist/collapsible/foundation.js +8 -8
  39. package/dist/color-picker/alpha-slider-foundation.d.ts +2 -4
  40. package/dist/color-picker/alpha-slider-foundation.js +10 -10
  41. package/dist/color-picker/color-choose-area-foundation.d.ts +2 -5
  42. package/dist/color-picker/color-choose-area-foundation.js +14 -14
  43. package/dist/color-picker/color-slider-foundation.d.ts +2 -4
  44. package/dist/color-picker/color-slider-foundation.js +10 -10
  45. package/dist/color-picker/data-part-foundation.d.ts +5 -5
  46. package/dist/color-picker/data-part-foundation.js +11 -11
  47. package/dist/color-picker/foundation.d.ts +4 -4
  48. package/dist/color-picker/foundation.js +10 -10
  49. package/dist/config-provider/breakpoint-observer.d.ts +3 -3
  50. package/dist/config-provider/breakpoint-observer.js +6 -6
  51. package/dist/cropper/foundation.d.ts +15 -15
  52. package/dist/cropper/foundation.js +26 -23
  53. package/dist/date-picker/_utils/picker-type.d.ts +1 -1
  54. package/dist/date-picker/foundation.d.ts +36 -36
  55. package/dist/date-picker/foundation.js +125 -129
  56. package/dist/date-picker/input-foundation.d.ts +9 -9
  57. package/dist/date-picker/input-foundation.js +28 -28
  58. package/dist/date-picker/months-grid-foundation.d.ts +17 -17
  59. package/dist/date-picker/months-grid-foundation.js +64 -65
  60. package/dist/date-picker/year-and-month-foundation.d.ts +3 -3
  61. package/dist/date-picker/year-and-month-foundation.js +11 -11
  62. package/dist/drag-move/foundation.d.ts +2 -2
  63. package/dist/drag-move/foundation.js +15 -13
  64. package/dist/dropdown/foundation.d.ts +8 -5
  65. package/dist/dropdown/foundation.js +32 -28
  66. package/dist/dropdown/menu-foundation.d.ts +1 -1
  67. package/dist/dropdown/menu-foundation.js +11 -11
  68. package/dist/feedback/foundation.d.ts +9 -9
  69. package/dist/feedback/foundation.js +33 -33
  70. package/dist/form/form-api-proxy.d.ts +8 -7
  71. package/dist/form/form-api-proxy.js +25 -25
  72. package/dist/form/foundation.d.ts +5 -5
  73. package/dist/form/foundation.js +60 -61
  74. package/dist/highlight/foundation.js +1 -1
  75. package/dist/hot-keys/foundation.d.ts +2 -2
  76. package/dist/hot-keys/foundation.js +5 -5
  77. package/dist/image/image-foundation.d.ts +4 -4
  78. package/dist/image/image-foundation.js +10 -10
  79. package/dist/image/preview-footer-foundation.d.ts +3 -3
  80. package/dist/image/preview-footer-foundation.js +10 -10
  81. package/dist/image/preview-foundation.js +7 -6
  82. package/dist/image/preview-image-foundation.d.ts +6 -8
  83. package/dist/image/preview-image-foundation.js +14 -14
  84. package/dist/image/preview-inner-foundation.d.ts +9 -9
  85. package/dist/image/preview-inner-foundation.js +38 -38
  86. package/dist/input/foundation.d.ts +10 -10
  87. package/dist/input/foundation.js +47 -49
  88. package/dist/input/text-entry-foundation.d.ts +3 -3
  89. package/dist/input/text-entry-foundation.js +14 -14
  90. package/dist/input/textarea-foundation.d.ts +7 -7
  91. package/dist/input/textarea-foundation.js +36 -36
  92. package/dist/input-number/foundation.d.ts +16 -14
  93. package/dist/input-number/foundation.js +54 -53
  94. package/dist/json-viewer/foundation.d.ts +8 -8
  95. package/dist/json-viewer/foundation.js +23 -23
  96. package/dist/lottie/foundation.d.ts +1 -1
  97. package/dist/lottie/foundation.js +4 -4
  98. package/dist/markdown-render/foundation.d.ts +1 -1
  99. package/dist/markdown-render/foundation.js +4 -4
  100. package/dist/modal/modal-content-foundation.d.ts +7 -7
  101. package/dist/modal/modal-content-foundation.js +20 -20
  102. package/dist/modal/modal-foundation.d.ts +6 -6
  103. package/dist/modal/modal-foundation.js +24 -24
  104. package/dist/navigation/foundation.d.ts +1 -1
  105. package/dist/navigation/foundation.js +14 -14
  106. package/dist/navigation/item-foundation.d.ts +1 -1
  107. package/dist/navigation/item-foundation.js +8 -8
  108. package/dist/navigation/sub-nav-foundation.d.ts +3 -3
  109. package/dist/navigation/sub-nav-foundation.js +17 -17
  110. package/dist/notification/notification-list-foundation.d.ts +7 -7
  111. package/dist/notification/notification-list-foundation.js +12 -12
  112. package/dist/overflow-list/foundation.d.ts +4 -4
  113. package/dist/overflow-list/foundation.js +18 -18
  114. package/dist/pagination/foundation.d.ts +8 -8
  115. package/dist/pagination/foundation.js +28 -28
  116. package/dist/pincode/foundation.d.ts +5 -5
  117. package/dist/pincode/foundation.js +22 -22
  118. package/dist/popconfirm/popconfirm-foundation.d.ts +7 -7
  119. package/dist/popconfirm/popconfirm-foundation.js +26 -26
  120. package/dist/radio/radio-foundation.d.ts +5 -5
  121. package/dist/radio/radio-foundation.js +15 -15
  122. package/dist/radio/radio-group-foundation.d.ts +2 -2
  123. package/dist/radio/radio-group-foundation.js +9 -9
  124. package/dist/rating/foundation.d.ts +10 -10
  125. package/dist/rating/foundation.js +35 -35
  126. package/dist/resizable/group/index.d.ts +6 -6
  127. package/dist/resizable/group/index.js +40 -40
  128. package/dist/resizable/single/index.d.ts +2 -2
  129. package/dist/resizable/single/index.js +9 -9
  130. package/dist/scroll-list/item-foundation.d.ts +7 -7
  131. package/dist/scroll-list/item-foundation.js +35 -35
  132. package/dist/select/foundation.d.ts +42 -56
  133. package/dist/select/foundation.js +214 -279
  134. package/dist/select/option-foundation.d.ts +23 -27
  135. package/dist/select/option-foundation.js +10 -18
  136. package/dist/side-sheet/side-sheet-foundation.d.ts +6 -6
  137. package/dist/side-sheet/side-sheet-foundation.js +22 -22
  138. package/dist/slider/foundation.d.ts +16 -16
  139. package/dist/slider/foundation.js +46 -46
  140. package/dist/sortable/accessibility.d.ts +1 -1
  141. package/dist/sortable/accessibility.js +2 -2
  142. package/dist/spin/foundation.d.ts +2 -2
  143. package/dist/spin/foundation.js +6 -6
  144. package/dist/steps/utils.d.ts +1 -1
  145. package/dist/switch/foundation.d.ts +2 -2
  146. package/dist/switch/foundation.js +7 -7
  147. package/dist/table/foundation.d.ts +14 -14
  148. package/dist/table/foundation.js +93 -93
  149. package/dist/table/utils.d.ts +2 -2
  150. package/dist/tabs/foundation.d.ts +5 -5
  151. package/dist/tabs/foundation.js +17 -17
  152. package/dist/tag-input/foundation.d.ts +11 -11
  153. package/dist/tag-input/foundation.js +52 -52
  154. package/dist/time-picker/foundation.d.ts +13 -13
  155. package/dist/time-picker/foundation.js +39 -39
  156. package/dist/time-picker/input-foundation.d.ts +4 -4
  157. package/dist/time-picker/input-foundation.js +13 -13
  158. package/dist/toast/toast-list-foundation.d.ts +7 -7
  159. package/dist/toast/toast-list-foundation.js +14 -14
  160. package/dist/tooltip/foundation.d.ts +9 -9
  161. package/dist/tooltip/foundation.js +67 -61
  162. package/dist/transfer/foundation.d.ts +22 -9
  163. package/dist/transfer/foundation.js +38 -23
  164. package/dist/tree/foundation.d.ts +14 -14
  165. package/dist/tree/foundation.js +61 -61
  166. package/dist/tree/shared.d.ts +1 -1
  167. package/dist/tree-select/foundation.d.ts +26 -20
  168. package/dist/tree-select/foundation.js +91 -83
  169. package/dist/typography/ellipsis.d.ts +4 -4
  170. package/dist/typography/ellipsis.js +8 -8
  171. package/dist/typography/format-numeral.d.ts +1 -1
  172. package/dist/typography/format-numeral.js +2 -2
  173. package/dist/upload/constants.d.ts +1 -1
  174. package/dist/upload/foundation.d.ts +17 -17
  175. package/dist/upload/foundation.js +92 -92
  176. package/dist/upload/utils.d.ts +3 -3
  177. package/dist/upload/utils.js +6 -6
  178. package/dist/user-guide/foundation.d.ts +3 -3
  179. package/dist/user-guide/foundation.js +19 -19
  180. package/dist/utils/a11y.d.ts +1 -1
  181. package/dist/utils/announcer.d.ts +2 -2
  182. package/dist/utils/announcer.js +4 -4
  183. package/dist/utils/focus-handle.d.ts +1 -1
  184. package/dist/utils/focus-handle.js +1 -2
  185. package/dist/utils/focus-scope.d.ts +5 -5
  186. package/dist/utils/focus-scope.js +10 -10
  187. package/dist/utils/is-promise.d.ts +1 -1
  188. package/dist/utils/release-holder.d.ts +2 -2
  189. package/dist/utils/release-holder.js +4 -4
  190. package/dist/video-player/foundation.d.ts +15 -15
  191. package/dist/video-player/foundation.js +89 -89
  192. package/dist/video-player/progress-foundation.d.ts +2 -2
  193. package/dist/video-player/progress-foundation.js +12 -12
  194. 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(): void;
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): void;
17
- deactivate(): void;
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): void;
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): void;
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: any): boolean;
1
+ export default function isPromise(value: unknown): value is PromiseLike<unknown>;
@@ -4,6 +4,6 @@
4
4
  */
5
5
  export default class ReleaseHolder {
6
6
  #private;
7
- hold(acquire: () => () => void): void;
8
- release(): void;
7
+ hold: (acquire: () => () => void) => void;
8
+ release: () => void;
9
9
  }
@@ -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): void;
59
- handleTimeUpdate(): void;
60
- handleDurationChange(): void;
61
- handleError(): void;
58
+ handleTimeChange: (value: number) => void;
59
+ handleTimeUpdate: () => void;
60
+ handleDurationChange: () => void;
61
+ handleError: () => void;
62
62
  handleLoadStart: () => void;
63
- handlePlayOrPause(): void;
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): void;
70
- handleStalled(locale: VideoPlayerNotificationLocale): void;
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): void;
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): void;
82
- handleQualityChange(quality: {
81
+ }, locale: VideoPlayerNotificationLocale) => void;
82
+ handleQualityChange: (quality: {
83
83
  label: string;
84
84
  value: string;
85
- }, locale: VideoPlayerNotificationLocale): void;
86
- handleRouteChange(route: {
85
+ }, locale: VideoPlayerNotificationLocale) => void;
86
+ handleRouteChange: (route: {
87
87
  label: string;
88
88
  value: string;
89
- }, locale: VideoPlayerNotificationLocale): void;
90
- handleMirror(locale: VideoPlayerNotificationLocale): void;
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._adapter.setShowControls(true);
16
+ this.adapter.setShowControls(true);
17
17
  this.#clearTimer();
18
18
  this.#controlsTimer = setTimeout(() => {
19
- if (this.getStates().isPlaying) this._adapter.setShowControls(false);
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._adapter.setMuted(muted);
24
+ this.adapter.setMuted(muted);
25
25
  }
26
26
  #handleLeavePictureInPicture = () => {
27
- const video = this._adapter.getVideo();
27
+ const video = this.adapter.getVideo();
28
28
  if (!video) return;
29
- this._adapter.setIsPlaying(!video.paused);
29
+ this.adapter.setIsPlaying(!video.paused);
30
30
  };
31
31
  #handleTemporaryNotification(content) {
32
32
  this.#stalled = false;
33
- this._adapter.setNotificationContent(content);
34
- this._adapter.setShowNotification(true);
33
+ this.adapter.setNotificationContent(content);
34
+ this.adapter.setShowNotification(true);
35
35
  clearTimeout(this.#notificationTimer);
36
36
  this.#notificationTimer = setTimeout(() => {
37
- this._adapter.setShowNotification(false);
37
+ this.adapter.setShowNotification(false);
38
38
  }, 1e3);
39
39
  }
40
40
  #restorePlayPosition() {
41
- const video = this._adapter.getVideo();
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._adapter.setIsFullScreen(isFullScreen);
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._adapter.setShowControls(true);
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._adapter.getVideoWrapper();
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._adapter.getVideo();
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._adapter.getVideoWrapper();
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._adapter.getVideo();
105
+ const video = this.adapter.getVideo();
106
106
  if (video) {
107
- this._adapter.setTotalTime(video.duration || 0);
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._adapter.setVolume(initialVolume);
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._adapter.getVideo();
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._adapter.setCurrentTime(time);
130
+ this.adapter.setCurrentTime(time);
131
131
  }
132
- }
133
- handleTimeUpdate() {
134
- const video = this._adapter.getVideo();
132
+ };
133
+ handleTimeUpdate = () => {
134
+ const video = this.adapter.getVideo();
135
135
  if (!video) return;
136
- this._adapter.setCurrentTime(video.currentTime);
137
- }
138
- handleDurationChange() {
139
- const video = this._adapter.getVideo();
136
+ this.adapter.setCurrentTime(video.currentTime);
137
+ };
138
+ handleDurationChange = () => {
139
+ const video = this.adapter.getVideo();
140
140
  if (!video) return;
141
- this._adapter.setTotalTime(video.duration || 0);
142
- }
143
- handleError() {
144
- this._adapter.setIsError(true);
145
- }
141
+ this.adapter.setTotalTime(video.duration || 0);
142
+ };
143
+ handleError = () => {
144
+ this.adapter.setIsError(true);
145
+ };
146
146
  handleLoadStart = () => {
147
- this._adapter.setIsError(false);
148
- const video = this._adapter.getVideo();
147
+ this.adapter.setIsError(false);
148
+ const video = this.adapter.getVideo();
149
149
  if (!video) return;
150
- this._adapter.setIsPlaying(!video.paused);
151
- this._adapter.setBufferedValue(0);
150
+ this.adapter.setIsPlaying(!video.paused);
151
+ this.adapter.setBufferedValue(0);
152
152
  };
153
- handlePlayOrPause() {
154
- const video = this._adapter.getVideo();
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._adapter.getVideo();
160
+ const video = this.adapter.getVideo();
161
161
  if (video) ignoreExpectedMediaErrors(video.play());
162
162
  }
163
163
  handlePause() {
164
- const video = this._adapter.getVideo();
164
+ const video = this.adapter.getVideo();
165
165
  if (video) video.pause();
166
166
  }
167
167
  handleVideoPlay = () => {
168
- this._adapter.setIsPlaying(true);
169
- this._adapter.notifyPlay();
168
+ this.adapter.setIsPlaying(true);
169
+ this.adapter.notifyPlay();
170
170
  if (this.getStates().isFullScreen) this.#handleMouseMove();
171
171
  };
172
172
  handleVideoPause = () => {
173
- this._adapter.setIsPlaying(false);
174
- this._adapter.notifyPause();
175
- if (this.getStates().isFullScreen) this._adapter.setShowControls(true);
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._adapter.setShowNotification(false);
179
+ this.adapter.setShowNotification(false);
180
180
  };
181
- handleWaiting(locale) {
181
+ handleWaiting = (locale) => {
182
182
  this.#stalled = false;
183
- this._adapter.setNotificationContent(locale.loading);
184
- this._adapter.setShowNotification(true);
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._adapter.setNotificationContent(locale.stall);
189
- this._adapter.setShowNotification(true);
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._adapter.setShowNotification(false);
194
+ this.adapter.setShowNotification(false);
195
195
  }
196
- const video = this._adapter.getVideo();
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._adapter.setBufferedValue(bufferedEnd);
199
+ this.adapter.setBufferedValue(bufferedEnd);
200
200
  }
201
201
  };
202
202
  handleEnded = () => {
203
- this._adapter.setIsPlaying(false);
204
- this._adapter.setShowControls(true);
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._adapter.getVideo();
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._adapter.setVolume(next);
213
+ this.adapter.setVolume(next);
214
214
  this.#applyMuted(video, next === 0);
215
- if (next !== (muted ? 0 : volume)) this._adapter.notifyVolumeChange(next);
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._adapter.getVideo();
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._adapter.setVolume(restored);
225
+ this.adapter.setVolume(restored);
226
226
  this.#applyMuted(video, false);
227
- this._adapter.notifyVolumeChange(restored);
227
+ this.adapter.notifyVolumeChange(restored);
228
228
  } else {
229
229
  this.#applyMuted(video, true);
230
- this._adapter.notifyVolumeChange(0);
230
+ this.adapter.notifyVolumeChange(0);
231
231
  }
232
232
  };
233
233
  handleFullscreen = () => {
234
- const videoWrapper = this._adapter.getVideoWrapper();
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._adapter.getVideo();
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._adapter.setPlaybackRate(rate.value);
252
- this._adapter.notifyRateChange(rate.value);
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._adapter.setQuality(quality.value);
258
- this._adapter.notifyQualityChange(quality.value);
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._adapter.setRoute(route.value);
265
- this._adapter.notifyRouteChange(route.value);
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._adapter.setIsMirror(!isMirror);
271
+ this.adapter.setIsMirror(!isMirror);
272
272
  this.#handleTemporaryNotification(!isMirror ? locale.mirror : locale.cancelMirror);
273
- }
273
+ };
274
274
  handlePictureInPicture = () => {
275
- const video = this._adapter.getVideo();
275
+ const video = this.adapter.getVideo();
276
276
  if (!video) return;
277
277
  ignoreExpectedMediaErrors(video.requestPictureInPicture());
278
278
  };
279
279
  handleMouseEnterWrapper = () => {
280
- this._adapter.setShowControls(true);
280
+ this.adapter.setShowControls(true);
281
281
  };
282
282
  handleMouseLeaveWrapper = () => {
283
283
  const { isPlaying } = this.getStates();
284
- if (isPlaying) this._adapter.setShowControls(false);
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
- }): void;
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._adapter.getMarkersList().forEach((marker, index) => {
9
- if (VideoProgressFoundation.isInMarker(marker, currentValue)) this._adapter.setActiveIndex(index);
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._adapter.setMovingInfo(null);
80
- this._adapter.notifyChange(clamp(targets[e.key], 0, max));
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._adapter.setMovingInfo(null);
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._adapter.setIsDragging(true);
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._adapter.setIsDragging(false);
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._adapter.getSliderRef();
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._adapter.notifyChange(value);
108
+ this.adapter.notifyChange(value);
109
109
  }
110
- this._adapter.setMovingInfo({
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.1.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.1.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",