@fibrae/semi-foundation 0.1.1 → 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 +16 -16
  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
@@ -63,7 +63,7 @@ var HotKeysFoundation = class extends BaseFoundation {
63
63
  if (!allModifier.every((value, index) => value === clickedModifier[index])) return;
64
64
  if (keysPressed.every(Boolean)) {
65
65
  if (preventDefault) event.preventDefault();
66
- this._adapter.notifyHotKey(event);
66
+ this.adapter.notifyHotKey(event);
67
67
  return;
68
68
  }
69
69
  };
@@ -75,16 +75,16 @@ var HotKeysFoundation = class extends BaseFoundation {
75
75
  this.#bind();
76
76
  }
77
77
  /** Applies the same check as mounting, so an invalid combination set later fails just as loudly */
78
- handleHotKeysChange() {
78
+ handleHotKeysChange = () => {
79
79
  this.#validate();
80
- }
80
+ };
81
81
  /** Moves the keydown listener when `getListenerTarget` now returns a different element */
82
- handleTargetChange() {
82
+ handleTargetChange = () => {
83
83
  if (this.#getTarget() !== this.#target) {
84
84
  this.#unbind();
85
85
  this.#bind();
86
86
  }
87
- }
87
+ };
88
88
  destroy() {
89
89
  this.#unbind();
90
90
  }
@@ -22,9 +22,9 @@ export default class ImageFoundation<P extends ImageBaseProps = ImageBaseProps,
22
22
  static canOpen(preview: ImageBaseProps['preview'], loadStatus: ImageLoadStatus, isInGroup: boolean): boolean;
23
23
  /** The lone image's own preview stays mounted while the thumbnail loads, so an open preview survives a reload, a controlled visible need not wait for it, and closing it can restore focus */
24
24
  static canPreview(preview: ImageBaseProps['preview'], isInGroup: boolean): boolean;
25
- handleClick: (_e: any) => void;
26
- handleKeyDown: (e: any) => void;
27
- handleLoaded: (e: any) => void;
28
- handleError: (e: any) => void;
25
+ handleClick: (_e: unknown) => void;
26
+ handleKeyDown: (e: Pick<KeyboardEvent, "currentTarget" | "key" | "preventDefault" | "target">) => void;
27
+ handleLoaded: (e: unknown) => void;
28
+ handleError: (e: unknown) => void;
29
29
  handlePreviewVisibleChange: (newVisible: boolean) => void;
30
30
  }
@@ -12,29 +12,29 @@ var ImageFoundation = class extends BaseFoundation {
12
12
  handleClick = (_e) => {
13
13
  const { preview } = this.getProps();
14
14
  if (!preview) return;
15
- if (this._adapter.getIsInGroup()) this._adapter.openGroupPreview();
15
+ if (this.adapter.getIsInGroup()) this.adapter.openGroupPreview();
16
16
  else this.handlePreviewVisibleChange(true);
17
17
  };
18
18
  handleKeyDown = (e) => {
19
- if (e.target === e.currentTarget && (e.key === "Enter" || e.key === " ")) {
19
+ if (e.target === e.currentTarget && e.currentTarget instanceof HTMLElement && (e.key === "Enter" || e.key === " ")) {
20
20
  e.preventDefault();
21
- e.currentTarget.querySelector(":scope > img").click();
21
+ e.currentTarget.querySelector(":scope > img")?.click();
22
22
  }
23
23
  };
24
24
  handleLoaded = (e) => {
25
- this._adapter.notifyLoad(e);
26
- this._adapter.setLoadStatus("success");
25
+ this.adapter.notifyLoad(e);
26
+ this.adapter.setLoadStatus("success");
27
27
  };
28
28
  handleError = (e) => {
29
- this._adapter.notifyError(e);
30
- this._adapter.setLoadStatus("error");
29
+ this.adapter.notifyError(e);
30
+ this.adapter.setLoadStatus("error");
31
31
  };
32
32
  handlePreviewVisibleChange = (newVisible) => {
33
33
  const { preview } = this.getProps();
34
34
  if (typeof preview === "object" && preview !== null) {
35
- this._adapter.notifyPreviewVisibleChange(newVisible);
36
- if (preview.visible === void 0) this._adapter.setPreviewVisible(newVisible);
37
- } else this._adapter.setPreviewVisible(newVisible);
35
+ this.adapter.notifyPreviewVisibleChange(newVisible);
36
+ if (preview.visible === void 0) this.adapter.setPreviewVisible(newVisible);
37
+ } else this.adapter.setPreviewVisible(newVisible);
38
38
  };
39
39
  };
40
40
  export { ImageFoundation as default };
@@ -20,7 +20,7 @@ export default class PreviewFooterFoundation<P extends PreviewFooterBaseProps =
20
20
  protected handleValueChange(value: number): void;
21
21
  handleSlideChange: ThrottledFunction<(value: number | number[]) => void>;
22
22
  destroy(): void;
23
- changeSliderValue(type: 'plus' | 'minus'): void;
24
- handleRatioClick(): void;
25
- handleRotate(direction: RotateDirection): void;
23
+ changeSliderValue: (type: "plus" | "minus") => void;
24
+ handleRatioClick: () => void;
25
+ handleRotate: (direction: RotateDirection) => void;
26
26
  }
@@ -5,8 +5,8 @@ import { throttle } from "es-toolkit";
5
5
  var PreviewFooterFoundation = class extends BaseFoundation {
6
6
  handleValueChange(value) {
7
7
  const { zoom } = this.getProps();
8
- if (value > zoom) this._adapter.notifyZoomIn(Number((value / 100).toFixed(2)));
9
- else this._adapter.notifyZoomOut(Number((value / 100).toFixed(2)));
8
+ if (value > zoom) this.adapter.notifyZoomIn(Number((value / 100).toFixed(2)));
9
+ else this.adapter.notifyZoomOut(Number((value / 100).toFixed(2)));
10
10
  }
11
11
  handleSlideChange = throttle((value) => {
12
12
  this.handleValueChange(value);
@@ -14,17 +14,17 @@ var PreviewFooterFoundation = class extends BaseFoundation {
14
14
  destroy() {
15
15
  this.handleSlideChange.cancel();
16
16
  }
17
- changeSliderValue(type) {
17
+ changeSliderValue = (type) => {
18
18
  const { zoom, step, min, max } = this.getProps();
19
19
  this.handleValueChange(clampZoom(type === "plus" ? zoom + step : zoom - step, min, max));
20
- }
21
- handleRatioClick() {
20
+ };
21
+ handleRatioClick = () => {
22
22
  const { ratio } = this.getProps();
23
23
  const type = ratio === "adaptation" ? "realSize" : "adaptation";
24
- this._adapter.notifyAdjustRatio(type);
25
- }
26
- handleRotate(direction) {
27
- this._adapter.notifyRotate(direction);
28
- }
24
+ this.adapter.notifyAdjustRatio(type);
25
+ };
26
+ handleRotate = (direction) => {
27
+ this.adapter.notifyRotate(direction);
28
+ };
29
29
  };
30
30
  export { PreviewFooterFoundation as default };
@@ -23,7 +23,8 @@ function getGroupPreviewList(src, images) {
23
23
  /** Gives the imgs that entered the viewport their src; a loaded img has no data-src left and is skipped */
24
24
  function loadLazyImages(entries, observer) {
25
25
  for (const entry of entries) {
26
- const target = entry.target;
26
+ const { target } = entry;
27
+ if (!(target instanceof HTMLImageElement)) continue;
27
28
  const lazySrc = target.dataset.src;
28
29
  if (entry.isIntersecting && lazySrc) {
29
30
  target.src = lazySrc;
@@ -35,7 +36,7 @@ function loadLazyImages(entries, observer) {
35
36
  var PreviewFoundation = class extends BaseFoundation {
36
37
  #images = /* @__PURE__ */ new Map();
37
38
  #syncImages() {
38
- const images = [...this.#images.values()].sort(byDocumentOrder);
39
+ const images = [...this.#images.values()].toSorted(byDocumentOrder);
39
40
  const current = this.getState("images") ?? [];
40
41
  if (images.length !== current.length || images.some((image, i) => image !== current[i])) this.setState({ images });
41
42
  return images;
@@ -59,12 +60,12 @@ var PreviewFoundation = class extends BaseFoundation {
59
60
  this.handleVisibleChange(true);
60
61
  };
61
62
  handleVisibleChange = (newVisible) => {
62
- if (!this._isControlledComponent("visible")) this.setState({ visible: newVisible });
63
- this._adapter.notifyVisibleChange(newVisible);
63
+ if (!this.isControlledComponent("visible")) this.setState({ visible: newVisible });
64
+ this.adapter.notifyVisibleChange(newVisible);
64
65
  };
65
66
  handleCurrentIndexChange = (index) => {
66
- if (!this._isControlledComponent("currentIndex")) this.setState({ currentIndex: index });
67
- this._adapter.notifyChange(index);
67
+ if (!this.isControlledComponent("currentIndex")) this.setState({ currentIndex: index });
68
+ this.adapter.notifyChange(index);
68
69
  };
69
70
  };
70
71
  export { PreviewFoundation as default, getGroupPreviewList, loadLazyImages };
@@ -54,17 +54,15 @@ export default class PreviewImageFoundation<P extends PreviewImageBaseProps = Pr
54
54
  };
55
55
  init(): void;
56
56
  handleWindowResize: () => void;
57
- handleLoad: (e: {
58
- target: EventTarget;
59
- }) => void;
60
- handleError: (_e: any) => void;
61
- handlePropsUpdate(prevProps: {
57
+ handleLoad: (e: Pick<Event, "target">) => void;
58
+ handleError: (_e: unknown) => void;
59
+ handlePropsUpdate: (prevProps: {
62
60
  src?: string;
63
61
  ratio?: string;
64
62
  rotation?: number;
65
63
  zoom?: number;
66
- }, zoomEvent?: WheelEvent): void;
67
- handleRightClickImage: (e: any) => boolean;
68
- handleImageMove(e: Pick<PointerEvent, 'buttons' | 'clientX' | 'clientY'>): void;
64
+ }, zoomEvent?: WheelEvent) => void;
65
+ handleRightClickImage: (e: Pick<Event, "preventDefault" | "stopPropagation">) => boolean;
66
+ handleImageMove: (e: Pick<PointerEvent, "buttons" | "clientX" | "clientY">) => void;
69
67
  handleImagePointerDown: (e: Pick<PointerEvent, "button" | "clientX" | "clientY" | "pointerId">) => void;
70
68
  }
@@ -25,7 +25,7 @@ var PreviewImageFoundation = class extends BaseFoundation {
25
25
  return clampZoom(zoom, minZoom, maxZoom);
26
26
  }
27
27
  #getContainerBoundingRectSize() {
28
- const containerDOM = this._adapter.getContainer();
28
+ const containerDOM = this.adapter.getContainer();
29
29
  if (containerDOM) {
30
30
  this.#containerWidth = containerDOM.clientWidth;
31
31
  this.#containerHeight = containerDOM.clientHeight;
@@ -33,7 +33,7 @@ var PreviewImageFoundation = class extends BaseFoundation {
33
33
  }
34
34
  #getAdaptationZoom() {
35
35
  let _zoom = 1;
36
- if (this._adapter.getContainer() && this.#originImageWidth && this.#originImageHeight) {
36
+ if (this.adapter.getContainer() && this.#originImageWidth && this.#originImageHeight) {
37
37
  const { rotation } = this.getProps();
38
38
  const { width: imageWidth, height: imageHeight } = this.calcBoundingRectSize(this.#originImageWidth, this.#originImageHeight, rotation);
39
39
  const reservedWidth = this.#containerWidth - 80;
@@ -54,7 +54,7 @@ var PreviewImageFoundation = class extends BaseFoundation {
54
54
  return this.#clampZoom(_zoom);
55
55
  }
56
56
  #setLoading(loading) {
57
- this._adapter.setLoading(loading);
57
+ this.adapter.setLoading(loading);
58
58
  }
59
59
  #handleRatioChange() {
60
60
  this.#initializeImage();
@@ -62,7 +62,7 @@ var PreviewImageFoundation = class extends BaseFoundation {
62
62
  #initializeImageZoom(reportToUser = true) {
63
63
  const { zoom } = this.getProps();
64
64
  const _zoom = this.#getInitialZoom();
65
- if (zoom !== _zoom) this._adapter.requestZoom(_zoom, reportToUser);
65
+ if (zoom !== _zoom) this.adapter.requestZoom(_zoom, reportToUser);
66
66
  else this.#applyZoom(zoom);
67
67
  }
68
68
  #initializeTranslate() {
@@ -92,7 +92,7 @@ var PreviewImageFoundation = class extends BaseFoundation {
92
92
  }
93
93
  }
94
94
  #applyZoom(prevZoom, e) {
95
- const imageDOM = this._adapter.getImage();
95
+ const imageDOM = this.adapter.getImage();
96
96
  const { translate, width, height } = this.getStates();
97
97
  const { rotation, zoom: newZoom } = this.getProps();
98
98
  const changeScale = newZoom / (prevZoom || 1);
@@ -135,7 +135,7 @@ var PreviewImageFoundation = class extends BaseFoundation {
135
135
  if (imageDOM) {
136
136
  const { canDragVertical, canDragHorizontal } = this.getCanDragDirection(newImageBound.width, newImageBound.height);
137
137
  const canDrag = canDragVertical || canDragHorizontal;
138
- this._adapter.setImageCursor(canDrag);
138
+ this.adapter.setImageCursor(canDrag);
139
139
  }
140
140
  }
141
141
  calcBoundingRectSize(width = 0, height = 0, rotation = 0) {
@@ -179,7 +179,7 @@ var PreviewImageFoundation = class extends BaseFoundation {
179
179
  this.#initializeImage();
180
180
  };
181
181
  handleLoad = (e) => {
182
- if (e.target) {
182
+ if (e.target instanceof HTMLImageElement) {
183
183
  const { naturalWidth: w, naturalHeight: h } = e.target;
184
184
  this.#originImageHeight = h;
185
185
  this.#originImageWidth = w;
@@ -187,13 +187,13 @@ var PreviewImageFoundation = class extends BaseFoundation {
187
187
  this.setState({ loading: false });
188
188
  this.#initializeImage(false);
189
189
  }
190
- this._adapter.notifyLoad(this.getProp("src"));
190
+ this.adapter.notifyLoad(this.getProp("src"));
191
191
  };
192
192
  handleError = (_e) => {
193
193
  this.setState({ loading: false });
194
- this._adapter.notifyError(this.getProp("src"));
194
+ this.adapter.notifyError(this.getProp("src"));
195
195
  };
196
- handlePropsUpdate(prevProps, zoomEvent) {
196
+ handlePropsUpdate = (prevProps, zoomEvent) => {
197
197
  const { zoom, src, ratio, rotation } = this.getProps();
198
198
  const srcChange = src && src !== prevProps.src;
199
199
  if (srcChange) this.#setLoading(true);
@@ -202,7 +202,7 @@ var PreviewImageFoundation = class extends BaseFoundation {
202
202
  if (ratio !== prevProps.ratio) this.#handleRatioChange();
203
203
  if (rotation !== prevProps.rotation) this.handleWindowResize();
204
204
  }
205
- }
205
+ };
206
206
  handleRightClickImage = (e) => {
207
207
  const { disableDownload } = this.getProps();
208
208
  if (disableDownload) {
@@ -211,16 +211,16 @@ var PreviewImageFoundation = class extends BaseFoundation {
211
211
  return false;
212
212
  } else return true;
213
213
  };
214
- handleImageMove(e) {
214
+ handleImageMove = (e) => {
215
215
  if (e.buttons === 1) this.#moveImage(e);
216
- }
216
+ };
217
217
  handleImagePointerDown = (e) => {
218
218
  if (isSecondaryPress(e)) return;
219
219
  this.#startMouseClientPosition = {
220
220
  x: e.clientX,
221
221
  y: e.clientY
222
222
  };
223
- this._adapter.capturePointer(e.pointerId);
223
+ this.adapter.capturePointer(e.pointerId);
224
224
  };
225
225
  };
226
226
  export { PreviewImageFoundation as default };
@@ -66,19 +66,19 @@ export default class PreviewInnerFoundation<P extends PreviewInnerBaseProps = Pr
66
66
  static getSrcList(src: string | string[]): string[];
67
67
  static getCurrentIndex(props: Record<string, any>, state: Record<string, any>): number;
68
68
  static canSwitch(direction: 'prev' | 'next', currentIndex: number, total: number, infinite: boolean): boolean;
69
- beforeShow(): void;
70
- afterHide(): void;
69
+ beforeShow: () => void;
70
+ afterHide: () => void;
71
71
  destroy(): void;
72
- handleMouseMove: (e: any) => void;
73
- handleKeyboardActivity: (e: any) => void;
74
- updateTimer(): void;
72
+ handleMouseMove: (e: unknown) => void;
73
+ handleKeyboardActivity: (e: unknown) => void;
74
+ updateTimer: () => void;
75
75
  handleWheel: (e: WheelEvent) => void;
76
- handleMouseUp(e: MouseEvent): void;
76
+ handleMouseUp: (e: MouseEvent) => void;
77
77
  handleMouseDown: ({ button, clientX, clientY }: Pick<MouseEvent, "button" | "clientX" | "clientY">) => void;
78
- handleKeyDown(e: KeyboardEvent): void;
79
- handleSwitchImage(direction: SwitchDirection): void;
78
+ handleKeyDown: (e: KeyboardEvent) => void;
79
+ handleSwitchImage: (direction: SwitchDirection) => void;
80
80
  handleDownload: () => void;
81
- handlePreviewClose: (e: any) => void;
81
+ handlePreviewClose: (e: Pick<Event, "preventDefault" | "stopPropagation">) => void;
82
82
  handleAdjustRatio: (type: RatioType) => void;
83
83
  handleRotateImage: (direction: RotateDirection) => void;
84
84
  handleZoomImage: (newZoom: number, notify?: boolean, e?: WheelEvent) => void;
@@ -32,15 +32,15 @@ var PreviewInnerFoundation = class PreviewInnerFoundation extends BaseFoundation
32
32
  };
33
33
  #mouseMoveHandler = throttle((e) => {
34
34
  const { viewerVisible } = this.getStates();
35
- if (this._adapter.isValidTarget(e)) {
35
+ if (this.adapter.isValidTarget(e)) {
36
36
  if (!viewerVisible) this.setState({ viewerVisible: true });
37
37
  this.updateTimer();
38
38
  } else this.#clearTimer();
39
39
  }, 50);
40
40
  #handleEscape = () => {
41
41
  if (!this.getProp("closeOnEsc")) return false;
42
- this._adapter.notifyVisibleChange(false);
43
- this._adapter.notifyClose();
42
+ this.adapter.notifyVisibleChange(false);
43
+ this.adapter.notifyClose();
44
44
  return true;
45
45
  };
46
46
  #clearTimer() {
@@ -91,24 +91,24 @@ var PreviewInnerFoundation = class PreviewInnerFoundation extends BaseFoundation
91
91
  if (total <= 1) return false;
92
92
  return infinite || (direction === "prev" ? currentIndex > 0 : currentIndex < total - 1);
93
93
  }
94
- beforeShow() {
95
- this._adapter.registerKeyDownListener();
96
- this._adapter.openLayer(this.#handleEscape);
97
- this._adapter.disabledBodyScroll();
94
+ beforeShow = () => {
95
+ this.adapter.registerKeyDownListener();
96
+ this.adapter.openLayer(this.#handleEscape);
97
+ this.adapter.disabledBodyScroll();
98
98
  this.updateTimer();
99
- }
100
- afterHide() {
101
- this._adapter.unregisterKeyDownListener();
102
- this._adapter.closeLayer();
103
- this._adapter.enabledBodyScroll();
99
+ };
100
+ afterHide = () => {
101
+ this.adapter.unregisterKeyDownListener();
102
+ this.adapter.closeLayer();
103
+ this.adapter.enabledBodyScroll();
104
104
  this.#clearTimer();
105
105
  this.setState({
106
106
  viewerVisible: true,
107
107
  rotation: 0,
108
108
  preloadAfterVisibleChange: true
109
109
  });
110
- this._adapter.setRatio("adaptation");
111
- }
110
+ this.adapter.setRatio("adaptation");
111
+ };
112
112
  destroy() {
113
113
  this.#mouseMoveHandler.cancel();
114
114
  }
@@ -117,27 +117,27 @@ var PreviewInnerFoundation = class PreviewInnerFoundation extends BaseFoundation
117
117
  };
118
118
  handleKeyboardActivity = (e) => {
119
119
  if (!this.getState("viewerVisible")) this.setState({ viewerVisible: true });
120
- if (this._adapter.isValidTarget(e)) this.updateTimer();
120
+ if (this.adapter.isValidTarget(e)) this.updateTimer();
121
121
  else this.#clearTimer();
122
122
  };
123
- updateTimer() {
123
+ updateTimer = () => {
124
124
  const { viewerVisibleDelay, visible } = this.getProps();
125
125
  this.#clearTimer();
126
126
  if (visible) this.#timer = setTimeout(this.#handleViewVisibleChange, viewerVisibleDelay);
127
- }
127
+ };
128
128
  handleWheel = (e) => {
129
129
  this.#onWheel(e);
130
130
  handlePrevent(e);
131
131
  };
132
- handleMouseUp(e) {
132
+ handleMouseUp = (e) => {
133
133
  if (e.button !== 0) return;
134
134
  const { maskClosable } = this.getProps();
135
- let couldClose = this._adapter.isValidTarget(e);
135
+ let couldClose = this.adapter.isValidTarget(e);
136
136
  const { clientX, clientY } = e;
137
137
  const { x, y } = this.#startMouseDown;
138
138
  if (Math.abs(clientX - x) > 5 || Math.abs(y - clientY) > 5) couldClose = false;
139
- if (couldClose && maskClosable) this._adapter.notifyVisibleChange(false);
140
- }
139
+ if (couldClose && maskClosable) this.adapter.notifyVisibleChange(false);
140
+ };
141
141
  handleMouseDown = ({ button, clientX, clientY }) => {
142
142
  if (button !== 0) return;
143
143
  this.#startMouseDown = {
@@ -145,8 +145,8 @@ var PreviewInnerFoundation = class PreviewInnerFoundation extends BaseFoundation
145
145
  y: clientY
146
146
  };
147
147
  };
148
- handleKeyDown(e) {
149
- if (!this._adapter.isEventInPreview(e)) return;
148
+ handleKeyDown = (e) => {
149
+ if (!this.adapter.isEventInPreview(e)) return;
150
150
  if (e.key === "Escape" && this.getProp("closeOnEsc")) return;
151
151
  this.handleKeyboardActivity(e);
152
152
  if (!(e.key === "ArrowLeft" || e.key === "ArrowRight") || e.defaultPrevented || e.altKey || e.ctrlKey || e.metaKey || e.shiftKey || isEditable(e.target)) return;
@@ -157,50 +157,50 @@ var PreviewInnerFoundation = class PreviewInnerFoundation extends BaseFoundation
157
157
  e.preventDefault();
158
158
  this.handleSwitchImage(direction);
159
159
  }
160
- }
161
- handleSwitchImage(direction) {
160
+ };
161
+ handleSwitchImage = (direction) => {
162
162
  const step = direction === "prev" ? -1 : 1;
163
163
  const srcLength = this.#getImgSrc().length;
164
164
  const newIndex = (this.#getCurrentIndex() + step + srcLength) % srcLength;
165
- if (this._isControlledComponent("currentIndex")) {
166
- if (this._adapter.getIsInGroup()) this._adapter.getContext("setCurrentIndex")?.(newIndex);
165
+ if (this.isControlledComponent("currentIndex")) {
166
+ if (this.adapter.getIsInGroup()) this.adapter.getContext("setCurrentIndex")?.(newIndex);
167
167
  } else this.setState({ currentIndex: newIndex });
168
- this._adapter.notifyChange(newIndex, direction);
168
+ this.adapter.notifyChange(newIndex, direction);
169
169
  this.setState({
170
170
  direction,
171
171
  rotation: 0
172
172
  });
173
- }
173
+ };
174
174
  handleDownload = () => {
175
175
  const currentIndex = this.#getCurrentIndex();
176
- const setDownloadName = this._adapter.getSetDownloadFunc();
176
+ const setDownloadName = this.adapter.getSetDownloadFunc();
177
177
  const downloadSrc = this.#getImgSrc()[currentIndex];
178
178
  if (downloadSrc === void 0) return;
179
179
  const downloadName = setDownloadName ? setDownloadName(downloadSrc) : downloadSrc.slice(downloadSrc.lastIndexOf("/") + 1).split("?")[0];
180
- downloadImage(downloadSrc, downloadName, this._adapter.notifyDownloadError);
181
- this._adapter.notifyDownload(downloadSrc, currentIndex);
180
+ downloadImage(downloadSrc, downloadName, this.adapter.notifyDownloadError);
181
+ this.adapter.notifyDownload(downloadSrc, currentIndex);
182
182
  };
183
183
  handlePreviewClose = (e) => {
184
- this._adapter.notifyVisibleChange(false);
185
- this._adapter.notifyClose();
184
+ this.adapter.notifyVisibleChange(false);
185
+ this.adapter.notifyClose();
186
186
  handlePrevent(e);
187
187
  };
188
188
  handleAdjustRatio = (type) => {
189
- this._adapter.setRatio(type);
190
- this._adapter.notifyRatioChange(type);
189
+ this.adapter.setRatio(type);
190
+ this.adapter.notifyRatioChange(type);
191
191
  };
192
192
  handleRotateImage = (direction) => {
193
193
  const { rotation } = this.getStates();
194
194
  const newRotation = rotation + (direction === "left" ? -90 : 90);
195
195
  this.setState({ rotation: newRotation });
196
- this._adapter.notifyRotateChange(newRotation);
196
+ this.adapter.notifyRotateChange(newRotation);
197
197
  };
198
198
  handleZoomImage = (newZoom, notify = true, e) => {
199
199
  const { zoom } = this.getStates();
200
200
  const { maxZoom, minZoom } = this.getProps();
201
201
  const nextZoom = clampZoom(newZoom, minZoom, maxZoom);
202
202
  if (zoom !== nextZoom) {
203
- if (notify) this._adapter.notifyZoom(nextZoom, nextZoom > zoom);
203
+ if (notify) this.adapter.notifyZoom(nextZoom, nextZoom > zoom);
204
204
  this.setState({
205
205
  zoom: nextZoom,
206
206
  zoomEvent: e
@@ -38,14 +38,14 @@ export default class InputFoundation<P extends InputBaseProps = InputBaseProps,
38
38
  }, value?: string | number): boolean;
39
39
  static getInputType(type: string, mode: string | undefined, eyeClosed: boolean): string;
40
40
  init(): void;
41
- handleValueChange(value: string | number): void;
42
- handleClear(e: any): void;
43
- handleClick(e: Pick<Event, 'target' | 'currentTarget'>): void;
44
- handleModeChange(mode: string): void;
45
- handleClickEye(): void;
46
- handleBlur(e: unknown): void;
47
- handleInput(e: IE): void;
48
- handleKeyDown(e: KE): void;
49
- handleKeyUp(e: KE): void;
50
- handleClickPrefixOrSuffix(): void;
41
+ handleValueChange: (value: string | number) => void;
42
+ handleClear: (e: unknown) => void;
43
+ handleClick: (e: Pick<Event, "target" | "currentTarget">) => void;
44
+ handleModeChange: (mode: string) => void;
45
+ handleClickEye: () => void;
46
+ handleBlur: (e: unknown) => void;
47
+ handleInput: (e: IE) => void;
48
+ handleKeyDown: (e: KE) => void;
49
+ handleKeyUp: (e: KE) => void;
50
+ handleClickPrefixOrSuffix: () => void;
51
51
  }
@@ -16,64 +16,62 @@ var InputFoundation = class extends TextEntryFoundation {
16
16
  if (this.#initialized) return;
17
17
  this.#initialized = true;
18
18
  const { disabled, autoFocus, autofocus } = this.getProps();
19
- if (!disabled && (autoFocus || autofocus)) this._adapter.focusInput();
19
+ if (!disabled && (autoFocus || autofocus)) this.adapter.focusInput();
20
20
  }
21
- handleValueChange(value) {
22
- this._adapter.setState({
21
+ handleValueChange = (value) => {
22
+ this.adapter.setState({
23
23
  value,
24
24
  cachedValue: value
25
25
  });
26
- }
27
- handleClear(e) {
28
- let eventObj = e;
26
+ };
27
+ handleClear = (e) => {
29
28
  const value = "";
30
- if (!this._isControlledComponent("value")) this._adapter.setValue(value);
31
- if (!eventObj || typeof eventObj !== "object") eventObj = {};
32
- eventObj[strings.CLEARBTN_CLICKED_EVENT_FLAG] = true;
33
- this._adapter.notifyChange(value, eventObj);
34
- this._adapter.notifyClear(eventObj);
35
- }
36
- handleClick(e) {
37
- const { disabled } = this._adapter.getProps();
38
- const { isFocus } = this._adapter.getStates();
29
+ if (!this.isControlledComponent("value")) this.adapter.setValue(value);
30
+ const eventObj = Object.assign(typeof e === "object" && e !== null ? e : {}, { [strings.CLEARBTN_CLICKED_EVENT_FLAG]: true });
31
+ this.adapter.notifyChange(value, eventObj);
32
+ this.adapter.notifyClear(eventObj);
33
+ };
34
+ handleClick = (e) => {
35
+ const { disabled } = this.adapter.getProps();
36
+ const { isFocus } = this.adapter.getStates();
39
37
  if (disabled || isFocus) return;
40
- if (this._adapter.isEventTarget(e)) {
41
- this._adapter.focusInput();
42
- this._adapter.toggleFocusing(true);
38
+ if (this.adapter.isEventTarget(e)) {
39
+ this.adapter.focusInput();
40
+ this.adapter.toggleFocusing(true);
43
41
  }
44
- }
45
- handleModeChange(mode) {
46
- if (mode === "password") this._adapter.setEyeClosed(true);
47
- else this._adapter.setEyeClosed(false);
48
- }
49
- handleClickEye() {
50
- const eyeClosed = this._adapter.getState("eyeClosed");
51
- this._adapter.focusInput();
52
- this._adapter.toggleFocusing(true);
53
- this._adapter.setEyeClosed(!eyeClosed);
54
- }
55
- handleBlur(e) {
42
+ };
43
+ handleModeChange = (mode) => {
44
+ if (mode === "password") this.adapter.setEyeClosed(true);
45
+ else this.adapter.setEyeClosed(false);
46
+ };
47
+ handleClickEye = () => {
48
+ const eyeClosed = this.adapter.getState("eyeClosed");
49
+ this.adapter.focusInput();
50
+ this.adapter.toggleFocusing(true);
51
+ this.adapter.setEyeClosed(!eyeClosed);
52
+ };
53
+ handleBlur = (e) => {
56
54
  const { value } = this.getStates();
57
- this._adapter.toggleFocusing(false);
58
- this._adapter.notifyBlur(value, e);
59
- }
60
- handleInput(e) {
61
- this._adapter.notifyInput(e);
62
- }
63
- handleKeyDown(e) {
64
- this._adapter.notifyKeyDown(e);
65
- if (e.key === "Enter" && !isComposing(e)) this._adapter.notifyEnterPress(e);
66
- }
67
- handleKeyUp(e) {
68
- this._adapter.notifyKeyUp(e);
69
- }
70
- handleClickPrefixOrSuffix() {
71
- const { disabled } = this._adapter.getProps();
72
- const { isFocus } = this._adapter.getStates();
55
+ this.adapter.toggleFocusing(false);
56
+ this.adapter.notifyBlur(value, e);
57
+ };
58
+ handleInput = (e) => {
59
+ this.adapter.notifyInput(e);
60
+ };
61
+ handleKeyDown = (e) => {
62
+ this.adapter.notifyKeyDown(e);
63
+ if (e.key === "Enter" && !isComposing(e)) this.adapter.notifyEnterPress(e);
64
+ };
65
+ handleKeyUp = (e) => {
66
+ this.adapter.notifyKeyUp(e);
67
+ };
68
+ handleClickPrefixOrSuffix = () => {
69
+ const { disabled } = this.adapter.getProps();
70
+ const { isFocus } = this.adapter.getStates();
73
71
  if (!disabled && !isFocus) {
74
- this._adapter.focusInput();
75
- this._adapter.toggleFocusing(true);
72
+ this.adapter.focusInput();
73
+ this.adapter.toggleFocusing(true);
76
74
  }
77
- }
75
+ };
78
76
  };
79
77
  export { InputFoundation as default };
@@ -47,9 +47,9 @@ export default class TextEntryFoundation<A extends TextEntryAdapter<P, S, CE>, P
47
47
  }): V;
48
48
  /** The length the counter and maxLength count: `getValueLength` when given, otherwise UTF-16 units */
49
49
  static getValueCount(value?: string, getValueLength?: (value: string) => number): number;
50
- handleChange(value: string, e: unknown): void;
50
+ handleChange: (value: string, e: unknown) => void;
51
51
  handleCompositionStart: (e: CE) => void;
52
- handleCompositionEnd: (e: any) => void;
52
+ handleCompositionEnd: (e: CE & Pick<Event, "target">) => void;
53
53
  handleCompositionUpdate: (e: CE) => void;
54
- handleFocus(e: unknown): void;
54
+ handleFocus: (e: unknown) => void;
55
55
  }