@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
@@ -16,10 +16,10 @@ const readViewport = () => ({
16
16
  width: document.documentElement.clientWidth,
17
17
  height: document.documentElement.clientHeight
18
18
  });
19
- const isInside = (node, target) => {
19
+ function isInside(node, target) {
20
20
  for (let current = node; current; current = current instanceof ShadowRoot ? current.host : current.parentNode) if (current === target) return true;
21
21
  return false;
22
- };
22
+ }
23
23
  var Tooltip = class Tooltip extends BaseFoundation {
24
24
  static #tracking = /* @__PURE__ */ new Set();
25
25
  static #pending = /* @__PURE__ */ new Set();
@@ -42,7 +42,7 @@ var Tooltip = class Tooltip extends BaseFoundation {
42
42
  }
43
43
  static #handleScroll(event) {
44
44
  for (const tooltip of Tooltip.#tracking) {
45
- const trigger = tooltip._adapter.getTriggerElement();
45
+ const trigger = tooltip.adapter.getTriggerElement();
46
46
  if (!trigger || isInside(trigger, event.target)) Tooltip.#pending.add(tooltip);
47
47
  }
48
48
  Tooltip.#schedule();
@@ -63,8 +63,8 @@ var Tooltip = class Tooltip extends BaseFoundation {
63
63
  batch.forEach((tooltip, i) => tooltip.#apply(layouts[i]));
64
64
  }
65
65
  #handleClickOutside = (e) => {
66
- if (!this._adapter.getPortalContainer() || this._adapter.isEventInTrigger(e) || this._adapter.isEventInPopup(e)) return;
67
- this._adapter.notifyClickOutSide(e);
66
+ if (!this.adapter.getPortalContainer() || this.adapter.isEventInTrigger(e) || this.adapter.isEventInPopup(e)) return;
67
+ this.adapter.notifyClickOutSide(e);
68
68
  if (this.#hidesOnClickOutside) this.hide();
69
69
  };
70
70
  #bindEvent() {
@@ -74,10 +74,10 @@ var Tooltip = class Tooltip extends BaseFoundation {
74
74
  this.#bindPortalEvent(portalEventSet);
75
75
  }
76
76
  #bindTriggerEvent(triggerEventSet) {
77
- this._adapter.registerTriggerEvent(triggerEventSet);
77
+ this.adapter.registerTriggerEvent(triggerEventSet);
78
78
  }
79
79
  #bindPortalEvent(portalEventSet) {
80
- this._adapter.registerPortalEvent(portalEventSet);
80
+ this.adapter.registerPortalEvent(portalEventSet);
81
81
  }
82
82
  #generateEvent(types) {
83
83
  const triggerEventSet = {};
@@ -152,13 +152,13 @@ var Tooltip = class Tooltip extends BaseFoundation {
152
152
  #handleTriggerKeydown(event) {
153
153
  const key = event?.key;
154
154
  if (this.getProp("disableArrowKeyDown") || key !== "ArrowUp" && key !== "ArrowDown") return;
155
- const focusableElements = FocusTrapHandle.getFocusableElements(this._adapter.getPortalContainer());
155
+ const focusableElements = FocusTrapHandle.getFocusableElements(this.adapter.getPortalContainer());
156
156
  if (!focusableElements.length) return;
157
157
  if (key === "ArrowUp") this.#handleTriggerArrowUpKeydown(focusableElements, event);
158
158
  else this.#handleTriggerArrowDownKeydown(focusableElements, event);
159
159
  }
160
160
  #getActiveElement() {
161
- return FocusTrapHandle.getActiveElement(this._adapter.getPortalContainer() ?? this._adapter.getTriggerNode());
161
+ return FocusTrapHandle.getActiveElement(this.adapter.getPortalContainer() ?? this.adapter.getTriggerNode());
162
162
  }
163
163
  #handleContainerTabKeyDown(focusableElements, event) {
164
164
  const { preventScroll } = this.getProps();
@@ -197,14 +197,14 @@ var Tooltip = class Tooltip extends BaseFoundation {
197
197
  const controlled = this.getProp("visible");
198
198
  if (controlled === void 0 || controlled === visible) return false;
199
199
  this.#requestedVisible = visible;
200
- this._adapter.notifyVisibleChange(visible);
200
+ this.adapter.notifyVisibleChange(visible);
201
201
  return true;
202
202
  }
203
203
  #reportVisibleChange(visible) {
204
- if (this.getProp("visible") === void 0) this._adapter.notifyVisibleChange(visible);
204
+ if (this.getProp("visible") === void 0) this.adapter.notifyVisibleChange(visible);
205
205
  }
206
206
  #startTracking() {
207
- const popup = this._adapter.getPortalContainer();
207
+ const popup = this.adapter.getPortalContainer();
208
208
  this.#insetTop = popup ? Math.max(parseFloat(getComputedStyle(popup).getPropertyValue("--semi-tooltip-viewport-inset-top")) || 0, 0) : 0;
209
209
  const resizeObserver = new ResizeObserver((entries) => {
210
210
  for (const { target, borderBoxSize } of entries) if (target === popup) this.#popupSize = {
@@ -221,8 +221,8 @@ var Tooltip = class Tooltip extends BaseFoundation {
221
221
  this.calcPosition();
222
222
  }, { rootMargin: `${-this.#insetTop}px 0px 0px 0px` });
223
223
  if (popup) resizeObserver.observe(popup);
224
- this._adapter.observeTrigger(resizeObserver);
225
- this._adapter.observeTrigger(intersectionObserver);
224
+ this.adapter.observeTrigger(resizeObserver);
225
+ this.adapter.observeTrigger(intersectionObserver);
226
226
  if (!Tooltip.#tracking.size) {
227
227
  window.addEventListener("scroll", Tooltip.#handleScroll, {
228
228
  capture: true,
@@ -232,8 +232,8 @@ var Tooltip = class Tooltip extends BaseFoundation {
232
232
  }
233
233
  Tooltip.#tracking.add(this);
234
234
  this.#stopTracking = () => {
235
- this._adapter.unobserveTrigger(resizeObserver);
236
- this._adapter.unobserveTrigger(intersectionObserver);
235
+ this.adapter.unobserveTrigger(resizeObserver);
236
+ this.adapter.unobserveTrigger(intersectionObserver);
237
237
  resizeObserver.disconnect();
238
238
  intersectionObserver.disconnect();
239
239
  Tooltip.#tracking.delete(this);
@@ -257,8 +257,8 @@ var Tooltip = class Tooltip extends BaseFoundation {
257
257
  }
258
258
  /** Reads the layout: the trigger, the popup size and the placement; null while there is nothing to place */
259
259
  #measure(viewport) {
260
- const popup = this._adapter.getPortalContainer();
261
- const triggerRect = this._adapter.getTriggerRect();
260
+ const popup = this.adapter.getPortalContainer();
261
+ const triggerRect = this.adapter.getTriggerRect();
262
262
  if (!this.#stopTracking || !popup || !triggerRect) return null;
263
263
  const popupSize = this.#popupSize ?? {
264
264
  width: popup.offsetWidth,
@@ -300,7 +300,7 @@ var Tooltip = class Tooltip extends BaseFoundation {
300
300
  }
301
301
  /** Writes a measured layout to the popup unless it is already there */
302
302
  #apply(layout) {
303
- const popup = this._adapter.getPortalContainer();
303
+ const popup = this.adapter.getPortalContainer();
304
304
  if (!layout || !popup) return;
305
305
  this.#watchMove(layout);
306
306
  const applied = this.#applied;
@@ -319,13 +319,14 @@ var Tooltip = class Tooltip extends BaseFoundation {
319
319
  * every frame while open if such a trigger is seen not following.
320
320
  */
321
321
  #watchMove({ triggerRect: rect, viewport }) {
322
- const trigger = this._adapter.getTriggerElement();
323
- const rootMargin = [
324
- rect.top,
325
- viewport.width - rect.right,
326
- viewport.height - rect.bottom,
327
- rect.left
322
+ const trigger = this.adapter.getTriggerElement();
323
+ const marginAround = (around) => [
324
+ around.top,
325
+ viewport.width - around.right,
326
+ viewport.height - around.bottom,
327
+ around.left
328
328
  ].map((inset) => `${-Math.floor(inset)}px`).join(" ");
329
+ const rootMargin = marginAround(rect);
329
330
  if (this.#moveWatch?.trigger === trigger && this.#moveWatch.rootMargin === rootMargin) return;
330
331
  this.#moveWatch?.observer.disconnect();
331
332
  this.#moveWatch = null;
@@ -337,6 +338,11 @@ var Tooltip = class Tooltip extends BaseFoundation {
337
338
  this.calcPosition();
338
339
  return;
339
340
  }
341
+ const current = this.adapter.getTriggerRect();
342
+ if (current && marginAround(current) !== rootMargin) {
343
+ this.calcPosition();
344
+ return;
345
+ }
340
346
  first = false;
341
347
  if (!retried && intersectionRatio > 0 && intersectionRatio !== threshold) {
342
348
  observer.disconnect();
@@ -501,26 +507,26 @@ var Tooltip = class Tooltip extends BaseFoundation {
501
507
  }
502
508
  destroy() {
503
509
  if (this.#open || this.getState("visible") || this.getState("transitionState") === "leave") {
504
- this._adapter.closePopup();
505
- if (!this.getProp("keepDOM")) this._adapter.removePortal();
510
+ this.adapter.closePopup();
511
+ if (!this.getProp("keepDOM")) this.adapter.removePortal();
506
512
  }
507
513
  this.#mounted = false;
508
514
  this.#open = false;
509
515
  this.#requestedVisible = void 0;
510
516
  this.#endTracking();
511
- this._adapter.unregisterClickOutsideHandler();
517
+ this.adapter.unregisterClickOutsideHandler();
512
518
  this.#clearDelayTimer();
513
519
  }
514
520
  /** Regenerates the trigger and popup handlers, which depend on `trigger` and `clickToHide` */
515
- rebindEvents() {
521
+ rebindEvents = () => {
516
522
  this.#clearDelayTimer();
517
523
  this.#bindEvent();
518
- }
519
- removePortal() {
520
- this._adapter.removePortal();
521
- }
524
+ };
525
+ removePortal = () => {
526
+ this.adapter.removePortal();
527
+ };
522
528
  /** Hosts call this when the `visible` prop changes */
523
- handleVisiblePropChange() {
529
+ handleVisiblePropChange = () => {
524
530
  const visible = this.getProp("visible");
525
531
  const answered = visible === this.#requestedVisible;
526
532
  this.#requestedVisible = void 0;
@@ -530,10 +536,10 @@ var Tooltip = class Tooltip extends BaseFoundation {
530
536
  else this.show();
531
537
  } else if (delayed) this.delayHide();
532
538
  else this.hide();
533
- }
534
- updateStateIfCursorOnTrigger() {
535
- if (this._adapter.isTriggerHovered()) this.getState("triggerEventSet")[TRIGGER_EVENT_NAMES.mouseEnter]?.();
536
- }
539
+ };
540
+ updateStateIfCursorOnTrigger = () => {
541
+ if (this.adapter.isTriggerHovered()) this.getState("triggerEventSet")[TRIGGER_EVENT_NAMES.mouseEnter]?.();
542
+ };
537
543
  delayShow() {
538
544
  const mouseEnterDelay = this.getProp("mouseEnterDelay");
539
545
  this.#clearDelayTimer();
@@ -549,39 +555,39 @@ var Tooltip = class Tooltip extends BaseFoundation {
549
555
  if (this.#open || this.#requestFromOwner(true)) return;
550
556
  this.#open = true;
551
557
  this.#clearDelayTimer();
552
- this._adapter.insertPortal();
558
+ this.adapter.insertPortal();
553
559
  const hides = trigger === "click" || clickTriggerToHide || trigger === "contextMenu";
554
560
  if (hides || trigger === "custom") {
555
561
  this.#hidesOnClickOutside = hides;
556
- this._adapter.registerClickOutsideHandler(this.#handleClickOutside);
562
+ this.adapter.registerClickOutsideHandler(this.#handleClickOutside);
557
563
  }
558
564
  }
559
565
  /** Called once `showPopover()` has been issued for this opening (by the layout effect that reacts to the
560
566
  * mount `insertPortal` requested); a hover popup can still back out here if the pointer already left. */
561
- handleOpened() {
567
+ handleOpened = () => {
562
568
  if (!this.#open) return;
563
569
  if (this.getProp("trigger") === "hover" && this.getProp("visible") !== true) {
564
570
  const activeElement = this.#getActiveElement();
565
- const focusOpened = !this.getProp("disableFocusListener") && activeElement?.closest?.(`[data-popupid~="${CSS.escape(this._adapter.getPopupId())}"]`) != null;
566
- const focusInPopup = Boolean(this._adapter.getPortalContainer()?.contains(activeElement));
567
- if (!this._adapter.isTriggerHovered() && !focusOpened && !focusInPopup) {
571
+ const focusOpened = !this.getProp("disableFocusListener") && activeElement?.closest?.(`[data-popupid~="${CSS.escape(this.adapter.getPopupId())}"]`) != null;
572
+ const focusInPopup = Boolean(this.adapter.getPortalContainer()?.contains(activeElement));
573
+ if (!this.adapter.isTriggerHovered() && !focusOpened && !focusInPopup) {
568
574
  this.hide();
569
575
  return;
570
576
  }
571
577
  }
572
- this._adapter.setInitialFocus();
573
- this._adapter.notifyOpen();
578
+ this.adapter.setInitialFocus();
579
+ this.adapter.notifyOpen();
574
580
  this.#reportVisibleChange(true);
575
- }
581
+ };
576
582
  /** Hosts call this right after `showPopover()`: positions the popup and keeps it beside the trigger until it closes */
577
- handleShown() {
583
+ handleShown = () => {
578
584
  if (!this.#stopTracking) this.#startTracking();
579
585
  this.calcPosition();
580
- }
586
+ };
581
587
  /** Positions an open popup beside its trigger at once, without waiting for a frame */
582
- calcPosition() {
588
+ calcPosition = () => {
583
589
  this.#apply(this.#measure(readViewport()));
584
- }
590
+ };
585
591
  delayHide() {
586
592
  const mouseLeaveDelay = this.getProp("mouseLeaveDelay");
587
593
  this.#clearDelayTimer();
@@ -600,10 +606,10 @@ var Tooltip = class Tooltip extends BaseFoundation {
600
606
  this.#open = false;
601
607
  this.#clearDelayTimer();
602
608
  if (!this.#mounted) return;
603
- this._adapter.unregisterClickOutsideHandler();
609
+ this.adapter.unregisterClickOutsideHandler();
604
610
  this.#endTracking();
605
611
  if (wasOpen || this.getState("visible")) {
606
- this._adapter.closePopup();
612
+ this.adapter.closePopup();
607
613
  this.#reportVisibleChange(false);
608
614
  }
609
615
  };
@@ -615,17 +621,17 @@ var Tooltip = class Tooltip extends BaseFoundation {
615
621
  const { trigger, closeOnEsc } = this.getProps();
616
622
  if (!closeOnEsc) return false;
617
623
  if (trigger !== "custom") {
618
- if (this._adapter.getPortalContainer()?.contains(this.#getActiveElement())) this.focusTrigger();
624
+ if (this.adapter.getPortalContainer()?.contains(this.#getActiveElement())) this.focusTrigger();
619
625
  this.hide();
620
626
  }
621
- this._adapter.notifyEscKeydown(event);
627
+ this.adapter.notifyEscKeydown(event);
622
628
  return true;
623
629
  };
624
- handleContainerKeydown(event) {
630
+ handleContainerKeydown = (event) => {
625
631
  const { guardFocus } = this.getProps();
626
632
  switch (event && event.key) {
627
633
  case "Tab": if (guardFocus) {
628
- const container = this._adapter.getPortalContainer();
634
+ const container = this.adapter.getPortalContainer();
629
635
  const focusableElements = FocusTrapHandle.getFocusableElements(container);
630
636
  if (focusableElements.length) {
631
637
  if (event.shiftKey) this.#handleContainerShiftTabKeyDown(focusableElements, event);
@@ -633,18 +639,18 @@ var Tooltip = class Tooltip extends BaseFoundation {
633
639
  }
634
640
  }
635
641
  }
636
- }
642
+ };
637
643
  /**
638
644
  * Focus the trigger. A 'focus' or 'hover' trigger binds onFocus to show the popup, so focusing it
639
645
  * reopens the popup; callers hide the popup right after.
640
646
  */
641
- focusTrigger() {
647
+ focusTrigger = () => {
642
648
  const { trigger, returnFocusOnClose, preventScroll } = this.getProps();
643
649
  if (!returnFocusOnClose || trigger === "custom") return;
644
650
  const before = this.#getActiveElement();
645
- this._adapter.getTriggerNode()?.focus?.({ preventScroll });
651
+ this.adapter.getTriggerNode()?.focus?.({ preventScroll });
646
652
  const active = this.#getActiveElement();
647
653
  if (active !== before && active?.tabIndex < 0) FocusTrapHandle.getFocusableElements(active)[0]?.focus({ preventScroll });
648
- }
654
+ };
649
655
  };
650
656
  export { Tooltip as default };
@@ -29,6 +29,7 @@ export type BasicFilter = boolean | ((searchValue: string, item: BasicDataItem)
29
29
  /** The props the foundation reads with getProp */
30
30
  export interface TransferBaseProps {
31
31
  dataSource?: Array<object>;
32
+ defaultValue?: Array<number | string>;
32
33
  disabled?: boolean;
33
34
  filter?: BasicFilter;
34
35
  pagination?: {
@@ -45,7 +46,9 @@ export interface TransferBaseState {
45
46
  /** The uncontrolled selection, in the shape of `value`; it is resolved against the dataSource when read */
46
47
  selectedValues: Array<number | string>;
47
48
  }
48
- export interface TransferAdapter<P extends TransferBaseProps = TransferBaseProps, S extends TransferBaseState = TransferBaseState> extends DefaultAdapter<P, S> {
49
+ /** E is the host's focusout event, passed on to notifyBlur */
50
+ export interface TransferAdapter<P extends TransferBaseProps = TransferBaseProps, S extends TransferBaseState = TransferBaseState, E = FocusEvent> extends DefaultAdapter<P, S> {
51
+ notifyBlur: (e: E) => void;
49
52
  updateSelected: (values: Array<number | string>) => void;
50
53
  notifyChange: (values: Array<number | string>, items: Array<BasicDataItem>) => void;
51
54
  notifySearch: (searchValue: string) => void;
@@ -56,7 +59,7 @@ export interface TransferAdapter<P extends TransferBaseProps = TransferBaseProps
56
59
  updateCurrentPage: (currentPage: number) => void;
57
60
  notifyPageChange: (currentPage: number) => void;
58
61
  }
59
- export default class TransferFoundation<P extends TransferBaseProps = TransferBaseProps, S extends TransferBaseState = TransferBaseState> extends BaseFoundation<TransferAdapter<P, S>, P, S> {
62
+ export default class TransferFoundation<P extends TransferBaseProps = TransferBaseProps, S extends TransferBaseState = TransferBaseState, E = FocusEvent> extends BaseFoundation<TransferAdapter<P, S, E>, P, S> {
60
63
  #private;
61
64
  /** The flat item list of a dataSource: groupList items carry `_parent`, treeList nodes carry `_path` */
62
65
  static getData(dataSource: unknown, type: string): Array<BasicResolvedDataItem>;
@@ -102,11 +105,21 @@ export default class TransferFoundation<P extends TransferBaseProps = TransferBa
102
105
  static toPublicItem(item: BasicResolvedDataItem, type: string, showPath: boolean): BasicResolvedDataItem;
103
106
  /** The treeList path label shown with `showPath`, e.g. "Asia > China > Shanghai" */
104
107
  static generatePath({ _path }: BasicResolvedDataItem): string;
105
- handleInputChange(inputVal: string, notify: boolean): void;
106
- handleAll(wantAllChecked: boolean): void;
107
- handleClear(): void;
108
- handleSelectOrRemove(item: BasicResolvedDataItem): void;
109
- handleSelect(values: BasicValue): void;
110
- handleSortEnd({ oldIndex, newIndex }: OnSortEndProps): void;
111
- handlePageChange(currentPage: number): void;
108
+ handleInputChange: (inputVal: string, notify: boolean) => void;
109
+ handleAll: (wantAllChecked: boolean) => void;
110
+ handleClear: () => void;
111
+ handleSelectOrRemove: (item: BasicResolvedDataItem) => void;
112
+ handleSelect: (values: BasicValue) => void;
113
+ /**
114
+ * `value` went back to a non-array (a form reset). The state still holds what was selected before `value` took
115
+ * over, since a controlled selection never writes it, so it returns to the initial selection.
116
+ */
117
+ handleValueRelease: () => void;
118
+ /**
119
+ * A focusout from the root or anything inside it: reports the blur once the focus has left the whole transfer.
120
+ * A window blur has no relatedTarget and counts as leaving, as in TreeSelect.
121
+ */
122
+ handleFocusOut: (e: E & Pick<FocusEvent, "currentTarget" | "relatedTarget">) => void;
123
+ handleSortEnd: ({ oldIndex, newIndex }: OnSortEndProps) => void;
124
+ handlePageChange: (currentPage: number) => void;
112
125
  }
@@ -22,8 +22,8 @@ var TransferFoundation = class TransferFoundation extends BaseFoundation {
22
22
  }
23
23
  #updateSelected(selectedItems) {
24
24
  const { values, items } = this.#getValuesAndItems(selectedItems);
25
- if (!Array.isArray(this.getProp("value"))) this._adapter.updateSelected(values);
26
- this._adapter.notifyChange(values, items);
25
+ if (!Array.isArray(this.getProp("value"))) this.adapter.updateSelected(values);
26
+ this.adapter.notifyChange(values, items);
27
27
  }
28
28
  /** The flat item list of a dataSource: groupList items carry `_parent`, treeList nodes carry `_path` */
29
29
  static getData(dataSource, type) {
@@ -112,13 +112,13 @@ var TransferFoundation = class TransferFoundation extends BaseFoundation {
112
112
  static generatePath({ _path = [] }) {
113
113
  return _path.map((p) => p.label).join(" > ");
114
114
  }
115
- handleInputChange(inputVal, notify) {
116
- if (this.getProp("type") === strings.TYPE_TREE_TO_LIST) this._adapter.searchTree(inputVal);
117
- if (notify) this._adapter.notifySearch(inputVal);
118
- this._adapter.updateInput(inputVal);
115
+ handleInputChange = (inputVal, notify) => {
116
+ if (this.getProp("type") === strings.TYPE_TREE_TO_LIST) this.adapter.searchTree(inputVal);
117
+ if (notify) this.adapter.notifySearch(inputVal);
118
+ this.adapter.updateInput(inputVal);
119
119
  if (TransferFoundation.getPageNumber(this.getProp("pagination"), this.getState("leftCurrentPage")) !== 1) this.handlePageChange(1);
120
- }
121
- handleAll(wantAllChecked) {
120
+ };
121
+ handleAll = (wantAllChecked) => {
122
122
  const { disabled, type, filter } = this.getProps();
123
123
  if (disabled) return;
124
124
  const { inputValue } = this.getStates();
@@ -133,28 +133,28 @@ var TransferFoundation = class TransferFoundation extends BaseFoundation {
133
133
  for (const item of operateData) if (wantAllChecked && (!item.disabled || selectedItems.has(item.key))) selectedItems.set(item.key, item);
134
134
  else if (!wantAllChecked && !item.disabled) selectedItems.delete(item.key);
135
135
  this.#updateSelected(selectedItems);
136
- }
137
- handleClear() {
136
+ };
137
+ handleClear = () => {
138
138
  if (this.getProp("disabled")) return;
139
139
  const data = this.#getData();
140
140
  const selectedItems = this.#getSelected(data);
141
141
  for (const item of data) if (!item.disabled) selectedItems.delete(item.key);
142
142
  this.#updateSelected(selectedItems);
143
- }
144
- handleSelectOrRemove(item) {
143
+ };
144
+ handleSelectOrRemove = (item) => {
145
145
  if (this.getProp("disabled") || item.disabled) return;
146
146
  const selectedItems = this.#getSelected(this.#getData());
147
147
  const changedItem = this.#injectFullPath(item);
148
148
  if (selectedItems.has(item.key)) {
149
149
  selectedItems.delete(item.key);
150
- this._adapter.notifyDeselect(changedItem);
150
+ this.adapter.notifyDeselect(changedItem);
151
151
  } else {
152
152
  selectedItems.set(item.key, item);
153
- this._adapter.notifySelect(changedItem);
153
+ this.adapter.notifySelect(changedItem);
154
154
  }
155
155
  this.#updateSelected(selectedItems);
156
- }
157
- handleSelect(values) {
156
+ };
157
+ handleSelect = (values) => {
158
158
  if (this.getProp("disabled")) return;
159
159
  const data = this.#getData();
160
160
  const selectedItems = this.#getSelected(data);
@@ -165,15 +165,30 @@ var TransferFoundation = class TransferFoundation extends BaseFoundation {
165
165
  if (selectedItems.has(node.key) || !node.disabled) nextSelectedItemsMap.set(node.key, node);
166
166
  });
167
167
  this.#updateSelected(nextSelectedItemsMap);
168
- }
169
- handleSortEnd({ oldIndex, newIndex }) {
168
+ };
169
+ /**
170
+ * `value` went back to a non-array (a form reset). The state still holds what was selected before `value` took
171
+ * over, since a controlled selection never writes it, so it returns to the initial selection.
172
+ */
173
+ handleValueRelease = () => {
174
+ this.adapter.updateSelected([...this.getProp("defaultValue") ?? []]);
175
+ };
176
+ /**
177
+ * A focusout from the root or anything inside it: reports the blur once the focus has left the whole transfer.
178
+ * A window blur has no relatedTarget and counts as leaving, as in TreeSelect.
179
+ */
180
+ handleFocusOut = (e) => {
181
+ const { currentTarget, relatedTarget } = e;
182
+ if (!(currentTarget instanceof Node && relatedTarget instanceof Node && currentTarget.contains(relatedTarget))) this.adapter.notifyBlur(e);
183
+ };
184
+ handleSortEnd = ({ oldIndex, newIndex }) => {
170
185
  if (this.getProp("disabled")) return;
171
186
  const selectedArr = arrayMove([...this.#getSelected(this.#getData()).values()], oldIndex, newIndex);
172
187
  this.#updateSelected(new Map(selectedArr.map((option) => [option.key, option])));
173
- }
174
- handlePageChange(currentPage) {
175
- this._adapter.updateCurrentPage(currentPage);
176
- this._adapter.notifyPageChange(currentPage);
177
- }
188
+ };
189
+ handlePageChange = (currentPage) => {
190
+ this.adapter.updateCurrentPage(currentPage);
191
+ this.adapter.notifyPageChange(currentPage);
192
+ };
178
193
  };
179
194
  export { TransferFoundation as default };
@@ -274,23 +274,23 @@ export default class TreeFoundation<E = unknown> extends BaseFoundation<TreeAdap
274
274
  static getInitialState(props: BasicTreeProps): BasicTreeInnerData;
275
275
  destroy(): void;
276
276
  /** Writes the state derived from new props back, so handlers read what was rendered */
277
- syncDerivedState(derived: Partial<BasicTreeInnerData>): void;
278
- scrollTo({ key, align }: {
277
+ syncDerivedState: (derived: Partial<BasicTreeInnerData>) => void;
278
+ scrollTo: ({ key, align }: {
279
279
  key: string;
280
280
  align?: ScrollAlign;
281
- }): void;
282
- handleInputChange(sugInput: string): void;
283
- handleNodeSelect(e: any, treeNode: BasicTreeNodeProps): void;
284
- handleNodeRightClick(e: E, treeNode: BasicTreeNodeProps): void;
285
- handleNodeDoubleClick(e: E, treeNode: BasicTreeNodeProps): void;
286
- handleNodeExpand(_e: any, treeNode: BasicTreeNodeProps): void;
281
+ }) => void;
282
+ handleInputChange: (sugInput: string) => void;
283
+ handleNodeSelect: (e: unknown, treeNode: BasicTreeNodeProps) => void;
284
+ handleNodeRightClick: (e: E, treeNode: BasicTreeNodeProps) => void;
285
+ handleNodeDoubleClick: (e: E, treeNode: BasicTreeNodeProps) => void;
286
+ handleNodeExpand: (_e: unknown, treeNode: BasicTreeNodeProps) => void;
287
287
  /** Loads a node's children once; `key` is the node's entity key, which keyMaps may take from another field */
288
288
  handleNodeLoad(key: string, data: BasicTreeNodeData): void;
289
- handleNodeDragStart(e: TreeDragEvent, treeNode: BasicTreeNodeProps): void;
290
- handleNodeDragEnter(e: TreeDragEvent, treeNode: BasicTreeNodeProps): void;
291
- handleNodeDragOver(e: TreeDragEvent, treeNode: BasicTreeNodeProps): void;
292
- handleNodeDragLeave(e: TreeDragEvent, treeNode: BasicTreeNodeProps): void;
293
- handleNodeDragEnd(e: TreeDragEvent, treeNode: BasicTreeNodeProps): void;
294
- handleNodeDrop(e: TreeDragEvent, treeNode: BasicTreeNodeProps): void;
289
+ handleNodeDragStart: (e: TreeDragEvent, treeNode: BasicTreeNodeProps) => void;
290
+ handleNodeDragEnter: (e: TreeDragEvent, treeNode: BasicTreeNodeProps) => void;
291
+ handleNodeDragOver: (e: TreeDragEvent, treeNode: BasicTreeNodeProps) => void;
292
+ handleNodeDragLeave: (e: TreeDragEvent, treeNode: BasicTreeNodeProps) => void;
293
+ handleNodeDragEnd: (e: TreeDragEvent, treeNode: BasicTreeNodeProps) => void;
294
+ handleNodeDrop: (e: TreeDragEvent, treeNode: BasicTreeNodeProps) => void;
295
295
  }
296
296
  export type { KeyMapProps };