@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
@@ -19,22 +19,22 @@ function getItemRole(selectionMode, showTick) {
19
19
  var DropdownMenuFoundation = class extends BaseFoundation {
20
20
  #typeahead = new Typeahead();
21
21
  #focusMenuButton(menu) {
22
- getMenuButton(this._adapter.getContext("getPopupId")?.() ?? "", menu.getRootNode())?.focus();
22
+ getMenuButton(this.adapter.getContext("getPopupId")?.() ?? "", menu.getRootNode())?.focus();
23
23
  }
24
24
  #getItems(menu) {
25
25
  return [...menu.querySelectorAll(ITEM_SELECTOR)].filter((item) => item.closest("[role=\"menu\"]") === menu && item.getAttribute("aria-disabled") !== "true");
26
26
  }
27
- onMenuKeydown(event) {
28
- const menu = event.currentTarget;
29
- const target = event.target;
27
+ onMenuKeydown = (event) => {
28
+ const { currentTarget: menu, target } = event;
29
+ if (!(menu instanceof Element) || !(target instanceof HTMLElement)) return;
30
30
  if (target.closest("[role=\"menu\"]") !== menu) {
31
31
  if (event.key !== "Escape") event.stopPropagation();
32
32
  return;
33
33
  }
34
34
  const items = this.#getItems(menu);
35
35
  const index = items.findIndex((item) => item.contains(target));
36
- const isRtl = this._adapter.getContext("direction") === "rtl";
37
- const isSubmenu = this._adapter.getContext("menuDepth") > 1;
36
+ const isRtl = this.adapter.getContext("direction") === "rtl";
37
+ const isSubmenu = this.adapter.getContext("menuDepth") > 1;
38
38
  switch (event.key) {
39
39
  case " ":
40
40
  case "Enter":
@@ -44,7 +44,7 @@ var DropdownMenuFoundation = class extends BaseFoundation {
44
44
  }
45
45
  break;
46
46
  case "Escape":
47
- if (this._adapter.getContext("trigger") === "custom") this.#focusMenuButton(menu);
47
+ if (this.adapter.getContext("trigger") === "custom") this.#focusMenuButton(menu);
48
48
  break;
49
49
  case "ArrowDown":
50
50
  case "ArrowUp":
@@ -60,15 +60,15 @@ var DropdownMenuFoundation = class extends BaseFoundation {
60
60
  if (isSubmenu && event.key === (isRtl ? "ArrowRight" : "ArrowLeft")) {
61
61
  handlePrevent(event);
62
62
  this.#focusMenuButton(menu);
63
- this._adapter.getContext("close")?.();
63
+ this.adapter.getContext("close")?.();
64
64
  }
65
65
  break;
66
66
  case "Tab": {
67
67
  const root = menu.getRootNode();
68
- let button = getMenuButton(this._adapter.getContext("getPopupId")?.() ?? "", root);
68
+ let button = getMenuButton(this.adapter.getContext("getPopupId")?.() ?? "", root);
69
69
  while (button?.matches(ITEM_SELECTOR)) button = getMenuButton(button.closest("[popover]")?.id ?? "", root);
70
70
  button?.focus();
71
- this._adapter.getContext("closeAll")?.();
71
+ this.adapter.getContext("closeAll")?.();
72
72
  break;
73
73
  }
74
74
  default: if (this.#typeahead.accepts(event)) {
@@ -77,6 +77,6 @@ var DropdownMenuFoundation = class extends BaseFoundation {
77
77
  if (found >= 0) setFocusToItem(items, items[found]);
78
78
  }
79
79
  }
80
- }
80
+ };
81
81
  };
82
82
  export { DropdownMenuFoundation as default, getItemRole };
@@ -30,14 +30,14 @@ export interface FeedbackAdapter<P extends object = object, S extends FeedbackBa
30
30
  }
31
31
  export default class FeedbackFoundation<P extends object = object, S extends FeedbackBaseState = FeedbackBaseState, CE = unknown, OE = unknown, TE = unknown> extends BaseFoundation<FeedbackAdapter<P, S, CE, OE, TE>, P, S> {
32
32
  #private;
33
- handleRadioChange(e: RadioChangeEvent): void;
34
- handleEmojiReasonChange(value: string, e?: TE): void;
35
- handleTextChange(value: string, e?: TE): void;
36
- handleEmojiChange(emoji: string): void;
37
- handleCheckboxChange(value: CheckboxValue[]): void;
38
- handleCancel(e: CE): void;
39
- handleSubmit(e: OE): void;
40
- handleModalOk(e: OE): Promise<void>;
41
- handleModalCancel(e: CE): Promise<void>;
33
+ handleRadioChange: (e: RadioChangeEvent) => void;
34
+ handleEmojiReasonChange: (value: string, e?: TE) => void;
35
+ handleTextChange: (value: string, e?: TE) => void;
36
+ handleEmojiChange: (emoji: string) => void;
37
+ handleCheckboxChange: (value: CheckboxValue[]) => void;
38
+ handleCancel: (e: CE) => void;
39
+ handleSubmit: (e: OE) => void;
40
+ handleModalOk: (e: OE) => Promise<void>;
41
+ handleModalCancel: (e: CE) => Promise<void>;
42
42
  }
43
43
  export {};
@@ -7,18 +7,18 @@ function isFeedbackValueEmpty(value) {
7
7
  }
8
8
  var FeedbackFoundation = class extends BaseFoundation {
9
9
  #changeValue(value) {
10
- this._adapter.setValue(value);
11
- this._adapter.notifyValueChange(value);
10
+ this.adapter.setValue(value);
11
+ this.adapter.notifyValueChange(value);
12
12
  }
13
13
  #settlePopup(result, report) {
14
14
  if (!isPromise(result)) {
15
- this._adapter.setValue(null);
15
+ this.adapter.setValue(null);
16
16
  return;
17
17
  }
18
18
  report("pending");
19
19
  result.then(() => {
20
20
  report("fulfilled");
21
- this._adapter.setValue(null);
21
+ this.adapter.setValue(null);
22
22
  }).catch((e) => {
23
23
  report("rejected");
24
24
  throw e;
@@ -26,47 +26,47 @@ var FeedbackFoundation = class extends BaseFoundation {
26
26
  }
27
27
  #settleModal(result) {
28
28
  if (!isPromise(result)) {
29
- this._adapter.setValue(null);
29
+ this.adapter.setValue(null);
30
30
  return null;
31
31
  }
32
- return result.then(() => this._adapter.setValue(null));
32
+ return result.then(() => this.adapter.setValue(null));
33
33
  }
34
- handleRadioChange(e) {
34
+ handleRadioChange = (e) => {
35
35
  const { value } = e.target;
36
- this._adapter.notifyRadioChange(e);
36
+ this.adapter.notifyRadioChange(e);
37
37
  this.#changeValue(value);
38
- }
39
- handleEmojiReasonChange(value, e) {
40
- this._adapter.notifyTextAreaChange(value, e);
41
- const oldValue = this._adapter.getState("value");
38
+ };
39
+ handleEmojiReasonChange = (value, e) => {
40
+ this.adapter.notifyTextAreaChange(value, e);
41
+ const oldValue = this.adapter.getState("value");
42
42
  const emoji = typeof oldValue === "object" && !Array.isArray(oldValue) ? oldValue?.emoji : void 0;
43
43
  this.#changeValue({
44
44
  ...emoji !== void 0 && { emoji },
45
45
  text: value
46
46
  });
47
- }
48
- handleTextChange(value, e) {
49
- this._adapter.notifyTextAreaChange(value, e);
47
+ };
48
+ handleTextChange = (value, e) => {
49
+ this.adapter.notifyTextAreaChange(value, e);
50
50
  this.#changeValue(value);
51
- }
52
- handleEmojiChange(emoji) {
51
+ };
52
+ handleEmojiChange = (emoji) => {
53
53
  this.#changeValue({ emoji });
54
- }
55
- handleCheckboxChange(value) {
56
- this._adapter.notifyCheckboxChange(value);
54
+ };
55
+ handleCheckboxChange = (value) => {
56
+ this.adapter.notifyCheckboxChange(value);
57
57
  this.#changeValue(value);
58
- }
59
- handleCancel(e) {
60
- this.#settlePopup(this._adapter.notifyCancel(e), (onCancelReturnPromiseStatus) => this._adapter.setState({ onCancelReturnPromiseStatus }));
61
- }
62
- handleSubmit(e) {
63
- this.#settlePopup(this._adapter.notifyOk(e), (onOKReturnPromiseStatus) => this._adapter.setState({ onOKReturnPromiseStatus }));
64
- }
65
- handleModalOk(e) {
66
- return this.#settleModal(this._adapter.notifyOk(e));
67
- }
68
- handleModalCancel(e) {
69
- return this.#settleModal(this._adapter.notifyCancel(e));
70
- }
58
+ };
59
+ handleCancel = (e) => {
60
+ this.#settlePopup(this.adapter.notifyCancel(e), (onCancelReturnPromiseStatus) => this.adapter.setState({ onCancelReturnPromiseStatus }));
61
+ };
62
+ handleSubmit = (e) => {
63
+ this.#settlePopup(this.adapter.notifyOk(e), (onOKReturnPromiseStatus) => this.adapter.setState({ onOKReturnPromiseStatus }));
64
+ };
65
+ handleModalOk = (e) => {
66
+ return this.#settleModal(this.adapter.notifyOk(e));
67
+ };
68
+ handleModalCancel = (e) => {
69
+ return this.#settleModal(this.adapter.notifyCancel(e));
70
+ };
71
71
  };
72
72
  export { FeedbackFoundation as default, isFeedbackValueEmpty };
@@ -1,13 +1,14 @@
1
1
  import { BaseFormApi, FormState } from "./interface.js";
2
2
  export declare const EMPTY_FORM_STATE: FormState;
3
3
  export interface FormApiProxyInternals<T extends Record<string, any> = any> {
4
- __realApi: BaseFormApi<T> | null;
5
- __bind: ((api: BaseFormApi<T>) => void) | null;
6
- __unbind: (() => void) | null;
7
- __updateState: ((state: FormState<T>) => void) | null;
4
+ bind: (api: BaseFormApi<T>) => void;
5
+ unbind: () => void;
6
+ updateState: (state: FormState<T>) => void;
8
7
  }
8
+ /** The binding hooks of a proxy made by createFormApiProxy; undefined for any other object. */
9
+ export declare function getFormApiProxyInternals<T extends Record<string, any> = any>(proxy?: object): FormApiProxyInternals<T>;
9
10
  /**
10
- * A FormApi that exists before its Form mounts: the Form binds the real api through `__bind` and pushes every
11
- * form state through `__updateState`, which the framework hook stores in its own state.
11
+ * A FormApi that exists before its Form mounts: the Form binds the real api through `bind` and pushes every
12
+ * form state through `updateState`, which the framework hook stores in its own state.
12
13
  */
13
- export declare function createFormApiProxy<T extends Record<string, any>>(setFormState: (state: FormState<T>) => void): BaseFormApi<T> & FormApiProxyInternals<T>;
14
+ export declare function createFormApiProxy<T extends Record<string, any>>(setFormState: (state: FormState<T>) => void): BaseFormApi<T>;
@@ -4,28 +4,20 @@ const EMPTY_FORM_STATE = {
4
4
  errors: {},
5
5
  touched: {}
6
6
  };
7
+ const internalsOf = /* @__PURE__ */ new WeakMap();
8
+ /** The binding hooks of a proxy made by createFormApiProxy; undefined for any other object. */
9
+ function getFormApiProxyInternals(proxy) {
10
+ return proxy && internalsOf.get(proxy);
11
+ }
7
12
  /**
8
- * A FormApi that exists before its Form mounts: the Form binds the real api through `__bind` and pushes every
9
- * form state through `__updateState`, which the framework hook stores in its own state.
13
+ * A FormApi that exists before its Form mounts: the Form binds the real api through `bind` and pushes every
14
+ * form state through `updateState`, which the framework hook stores in its own state.
10
15
  */
11
16
  function createFormApiProxy(setFormState) {
12
- const internals = {
13
- __realApi: null,
14
- __bind: (api) => {
15
- internals.__realApi = api;
16
- setFormState(api.getFormState());
17
- },
18
- __unbind: () => {
19
- internals.__realApi = null;
20
- setFormState(EMPTY_FORM_STATE);
21
- },
22
- __updateState: setFormState
23
- };
24
- return new Proxy(internals, {
25
- get(target, prop) {
26
- if (typeof prop !== "string") return Reflect.get(target, prop);
27
- if (prop.startsWith("__")) return target[prop];
28
- const realApi = target.__realApi;
17
+ let realApi = null;
18
+ const proxy = new Proxy({}, {
19
+ get(_target, prop) {
20
+ if (typeof prop !== "string") return;
29
21
  if (!realApi) {
30
22
  if (prop === "then") return;
31
23
  return () => {
@@ -36,13 +28,21 @@ function createFormApiProxy(setFormState) {
36
28
  if (typeof value === "function") return value.bind(realApi);
37
29
  return value;
38
30
  },
39
- set(target, prop, value) {
40
- if (typeof prop === "string" && prop.startsWith("__")) {
41
- Reflect.set(target, prop, value);
42
- return true;
43
- }
31
+ set() {
44
32
  return false;
45
33
  }
46
34
  });
35
+ internalsOf.set(proxy, {
36
+ bind: (api) => {
37
+ realApi = api;
38
+ setFormState(api.getFormState());
39
+ },
40
+ unbind: () => {
41
+ realApi = null;
42
+ setFormState(EMPTY_FORM_STATE);
43
+ },
44
+ updateState: setFormState
45
+ });
46
+ return proxy;
47
47
  }
48
- export { EMPTY_FORM_STATE, createFormApiProxy };
48
+ export { EMPTY_FORM_STATE, createFormApiProxy, getFormApiProxyInternals };
@@ -14,9 +14,9 @@ export default class FormFoundation<E = unknown> extends BaseFoundation<BaseForm
14
14
  protected getFormProps(keys?: Array<string>): ComponentProps;
15
15
  init(): void;
16
16
  destroy(): void;
17
- submit(e?: E): void;
18
- reset(fieldPaths?: Array<string>): void;
19
- getFieldBridge(): {
17
+ submit: (e?: E) => void;
18
+ reset: (fieldPaths?: Array<string>) => void;
19
+ getFieldBridge: () => {
20
20
  register: (field: string, registration: FieldRegistration) => void;
21
21
  unRegister: (field: string) => void;
22
22
  setFieldTouched: (registration: FieldRegistration, touched: boolean, opts?: CallOpts) => void;
@@ -28,7 +28,7 @@ export default class FormFoundation<E = unknown> extends BaseFoundation<BaseForm
28
28
  getInitValues: () => any;
29
29
  getInitValue: (field?: string) => any;
30
30
  getFormProps: (keys?: Array<string>) => ComponentProps;
31
- getField: (field: string) => FieldRegistration | undefined;
31
+ getField: (field: string) => FieldRegistration;
32
32
  registerArrayField: (arrayFieldPath: string, val: any) => void;
33
33
  mountArrayField: (arrayFieldPath: string, val: any) => void;
34
34
  unRegisterArrayField: (arrayField: string) => void;
@@ -40,7 +40,7 @@ export default class FormFoundation<E = unknown> extends BaseFoundation<BaseForm
40
40
  };
41
41
  removeArrayFieldRow: (arrayFieldPath: string, index: number) => void;
42
42
  };
43
- getFormApi(): {
43
+ getFormApi: () => {
44
44
  reset: (fields?: Array<string>) => void;
45
45
  validate: (fields?: Array<string> | ValidateOptions) => Promise<unknown>;
46
46
  getValue: (field?: string) => any;
@@ -38,8 +38,8 @@ var FormFoundation = class extends BaseFoundation {
38
38
  #unregisterNotifyPending = false;
39
39
  constructor(adapter) {
40
40
  super(adapter);
41
- let { initValues } = this._adapter.getProps();
42
- initValues = this._adapter.cloneDeep(initValues);
41
+ let { initValues } = this.adapter.getProps();
42
+ initValues = this.adapter.cloneDeep(initValues);
43
43
  this.#data = {
44
44
  values: initValues ? initValues : {},
45
45
  errors: {},
@@ -50,7 +50,7 @@ var FormFoundation = class extends BaseFoundation {
50
50
  this.#registeredArrayField = /* @__PURE__ */ new Map();
51
51
  }
52
52
  #forceUpdate(callback) {
53
- this._adapter.forceUpdate(this.getFormState(), callback);
53
+ this.adapter.forceUpdate(this.getFormState(), callback);
54
54
  }
55
55
  #updateField(store, snapshot) {
56
56
  if (!store.update(snapshot)) return;
@@ -77,7 +77,7 @@ var FormFoundation = class extends BaseFoundation {
77
77
  errors: {}
78
78
  };
79
79
  this.#injectErrorToField({});
80
- this._adapter.notifyChange(this.#data);
80
+ this.adapter.notifyChange(this.#data);
81
81
  this.#notifyErrorChange(prevErrors, this.#fields.keys());
82
82
  this.#forceUpdate();
83
83
  }
@@ -89,7 +89,7 @@ var FormFoundation = class extends BaseFoundation {
89
89
  errors: formErrors
90
90
  };
91
91
  this.#injectErrorToField(formErrors);
92
- this._adapter.notifyChange(this.#data);
92
+ this.adapter.notifyChange(this.#data);
93
93
  this.#notifyErrorChange(prevErrors, this.#fields.keys());
94
94
  this.#forceUpdate(() => this.#autoScroll());
95
95
  }
@@ -103,7 +103,7 @@ var FormFoundation = class extends BaseFoundation {
103
103
  const error = get$1(this.#data.errors, path);
104
104
  if (error !== get$1(prevErrors, path)) changedError[path] = error;
105
105
  }
106
- if (Object.keys(changedError).length) this._adapter.notifyErrorChange(this.#data.errors, changedError);
106
+ if (Object.keys(changedError).length) this.adapter.notifyErrorChange(this.#data.errors, changedError);
107
107
  }
108
108
  #isCancelled(epoch) {
109
109
  return this.#destroyed || epoch !== this.#epoch;
@@ -118,7 +118,7 @@ var FormFoundation = class extends BaseFoundation {
118
118
  const writes = () => validation === this.#formValidation;
119
119
  return new Promise((resolve, reject) => {
120
120
  const pass = () => {
121
- resolve(this._adapter.cloneDeep(this.#data.values));
121
+ resolve(this.adapter.cloneDeep(this.#data.values));
122
122
  if (writes()) this.#clearFormErrors();
123
123
  };
124
124
  const fail = (errors) => {
@@ -183,11 +183,11 @@ var FormFoundation = class extends BaseFoundation {
183
183
  valid = isEmpty(errors);
184
184
  }
185
185
  if (!silent) {
186
- this._adapter.notifyChange(this.#data);
186
+ this.adapter.notifyChange(this.#data);
187
187
  this.#notifyErrorChange(prevErrors, paths);
188
188
  this.#forceUpdate(valid ? void 0 : () => this.#autoScroll());
189
189
  }
190
- if (valid) resolve(this._adapter.cloneDeep(this.#data.values));
190
+ if (valid) resolve(this.adapter.cloneDeep(this.#data.values));
191
191
  else reject(errors);
192
192
  });
193
193
  });
@@ -239,7 +239,7 @@ var FormFoundation = class extends BaseFoundation {
239
239
  const arrayFieldPaths = [...this.#registeredArrayField.keys()].filter((path) => fieldPaths === void 0 || fieldPaths.some((target) => isPathWithin(path, target)));
240
240
  arrayFieldPaths.forEach((path) => {
241
241
  const arrayFieldState = this.#registeredArrayField.get(path);
242
- const arrayFieldInitValue = this._adapter.cloneDeep(arrayFieldState.initValue);
242
+ const arrayFieldInitValue = this.adapter.cloneDeep(arrayFieldState.initValue);
243
243
  this.#updateStateValue(path, arrayFieldInitValue, {
244
244
  skipNotify: true,
245
245
  skipRender: true
@@ -452,7 +452,7 @@ var FormFoundation = class extends BaseFoundation {
452
452
  this.#unregisterNotifyPending = true;
453
453
  this.#forceUpdate(() => {
454
454
  this.#unregisterNotifyPending = false;
455
- this._adapter.notifyChange(this.#data);
455
+ this.adapter.notifyChange(this.#data);
456
456
  });
457
457
  };
458
458
  #registerArrayField = (arrayFieldPath, val) => {
@@ -485,14 +485,14 @@ var FormFoundation = class extends BaseFoundation {
485
485
  value: this.#getValue(item.path)
486
486
  }));
487
487
  this.#registerArrayField(arrayFieldPath, val);
488
- this.#updateStateValue(arrayFieldPath, this._adapter.cloneDeep(val), SILENT);
488
+ this.#updateStateValue(arrayFieldPath, this.adapter.cloneDeep(val), SILENT);
489
489
  nestedValues.forEach(({ path, allowEmpty, value }) => {
490
490
  this.#updateStateValue(path, value, {
491
491
  ...SILENT,
492
492
  allowEmpty
493
493
  });
494
494
  });
495
- this.#updateArrayField(arrayFieldPath, { initValue: this._adapter.cloneDeep(this.#getValue(arrayFieldPath)) });
495
+ this.#updateArrayField(arrayFieldPath, { initValue: this.adapter.cloneDeep(this.#getValue(arrayFieldPath)) });
496
496
  this.#forceUpdate();
497
497
  };
498
498
  /** Inserts an empty row before `index`, or appends one without it; returns the ArrayField's new updateKey */
@@ -513,7 +513,7 @@ var FormFoundation = class extends BaseFoundation {
513
513
  const values = this.#getValue(arrayFieldPath);
514
514
  const rows = values ? values.slice() : [];
515
515
  const rowIndex = typeof index === "number" ? Math.max(0, Math.min(index, rows.length)) : rows.length;
516
- rows.splice(rowIndex, 0, this._adapter.cloneDeep(rowValue));
516
+ rows.splice(rowIndex, 0, this.adapter.cloneDeep(rowValue));
517
517
  const updateKey = nextUpdateKey();
518
518
  this.#updateArrayField(arrayFieldPath, { updateKey });
519
519
  this.#updateStateValue(arrayFieldPath, rows, {});
@@ -535,13 +535,13 @@ var FormFoundation = class extends BaseFoundation {
535
535
  #getArrayField = (arrayField) => {
536
536
  return this.#registeredArrayField.get(arrayField);
537
537
  };
538
- #updateArrayField = (arrayField, updateValue) => {
538
+ #updateArrayField(arrayField, updateValue) {
539
539
  const mergeVal = {
540
540
  ...this.#registeredArrayField.get(arrayField),
541
541
  ...updateValue
542
542
  };
543
543
  this.#registeredArrayField.set(arrayField, mergeVal);
544
- };
544
+ }
545
545
  #validate(fieldPaths) {
546
546
  const { validator } = this.getProps();
547
547
  let fields;
@@ -565,10 +565,10 @@ var FormFoundation = class extends BaseFoundation {
565
565
  }
566
566
  #getValue = (field, opts) => {
567
567
  const value = typeof field === "undefined" ? { ...this.#data.values } : get$1(this.#data.values, field);
568
- return opts?.needClone ? this._adapter.cloneDeep(value) : value;
568
+ return opts?.needClone ? this.adapter.cloneDeep(value) : value;
569
569
  };
570
- #setValues = (values, { isOverride = false }) => {
571
- const _values = this._adapter.cloneDeep(values);
570
+ #setValues(values, { isOverride = false }) {
571
+ const _values = this.adapter.cloneDeep(values);
572
572
  this.#fields.forEach((field) => {
573
573
  const value = get$1(_values, field.field);
574
574
  const opts = {
@@ -585,10 +585,10 @@ var FormFoundation = class extends BaseFoundation {
585
585
  ...this.#data,
586
586
  values: _values
587
587
  };
588
- this._adapter.notifyChange(this.#data);
589
- this._adapter.notifyValueChange(this.#data.values, { ...values });
588
+ this.adapter.notifyChange(this.#data);
589
+ this.adapter.notifyValueChange(this.#data.values, { ...values });
590
590
  this.#forceUpdate();
591
- };
591
+ }
592
592
  #updateStateValue = (field, value, opts, callback) => {
593
593
  const skipNotify = opts && opts.skipNotify;
594
594
  const skipRender = opts && opts.skipRender;
@@ -598,8 +598,8 @@ var FormFoundation = class extends BaseFoundation {
598
598
  values: set$1(this.#data.values, field, value, allowEmpty)
599
599
  };
600
600
  if (!skipNotify) {
601
- this._adapter.notifyChange(this.#data);
602
- this._adapter.notifyValueChange(this.#data.values, { [field]: value });
601
+ this.adapter.notifyChange(this.#data);
602
+ this.adapter.notifyValueChange(this.#data.values, { [field]: value });
603
603
  }
604
604
  if (!skipRender) this.#forceUpdate(callback);
605
605
  };
@@ -614,7 +614,7 @@ var FormFoundation = class extends BaseFoundation {
614
614
  ...this.#data,
615
615
  touched: set$1(this.#data.touched, field, isTouched)
616
616
  };
617
- if (!skipNotify) this._adapter.notifyChange(this.#data);
617
+ if (!skipNotify) this.adapter.notifyChange(this.#data);
618
618
  if (!skipRender) this.#forceUpdate(callback);
619
619
  };
620
620
  #getError = (field) => {
@@ -629,14 +629,13 @@ var FormFoundation = class extends BaseFoundation {
629
629
  errors: set$1(this.#data.errors, field, error)
630
630
  };
631
631
  if (!skipNotify) {
632
- this._adapter.notifyChange(this.#data);
633
- this._adapter.notifyErrorChange(this.#data.errors, { [field]: error });
632
+ this.adapter.notifyChange(this.#data);
633
+ this.adapter.notifyErrorChange(this.#data.errors, { [field]: error });
634
634
  }
635
635
  if (!skipRender) this.#forceUpdate(callback);
636
636
  };
637
- #setFieldError = (registration, error, opts) => {
637
+ #setFieldError = ({ store, field }, error, opts) => {
638
638
  if (opts?.silent) return;
639
- const { store, field } = registration;
640
639
  this.#batch(() => {
641
640
  if (opts?.status) this.#updateField(store, { status: opts.status });
642
641
  if (error === store.getSnapshot().error) return;
@@ -698,35 +697,35 @@ var FormFoundation = class extends BaseFoundation {
698
697
  return {
699
698
  setValue: (field, value, opts) => {
700
699
  this.#getOperateFieldMap([field]).forEach((_, path) => this.#validations.delete(path));
701
- this.#setByPath("values", field, this._adapter.cloneDeep(value), opts);
700
+ this.#setByPath("values", field, this.adapter.cloneDeep(value), opts);
702
701
  },
703
- setError: (field, error, opts) => this.#setByPath("errors", field, this._adapter.cloneDeep(error), opts),
702
+ setError: (field, error, opts) => this.#setByPath("errors", field, this.adapter.cloneDeep(error), opts),
704
703
  setTouched: (field, isTouched, opts) => this.#setByPath("touched", field, isTouched, opts)
705
704
  };
706
705
  }
707
- #getFieldExist = (field) => {
706
+ #getFieldExist(field) {
708
707
  return Boolean(this.#fields.has(field));
709
- };
708
+ }
710
709
  #getFieldDOM(field) {
711
- return this._adapter.getFormElement()?.querySelector(`.${prefix}-field[x-field-id="${CSS.escape(field)}"]`) ?? null;
710
+ return this.adapter.getFormElement()?.querySelector(`.${prefix}-field[x-field-id="${CSS.escape(field)}"]`) ?? null;
712
711
  }
713
712
  /** The root elements of the fields showing an error message, in document order */
714
713
  #getErrorFieldDOMs() {
715
- const errorDOMs = this._adapter.getFormElement()?.querySelectorAll(ERROR_SELECTOR) ?? [];
714
+ const errorDOMs = this.adapter.getFormElement()?.querySelectorAll(ERROR_SELECTOR) ?? [];
716
715
  return Array.from(errorDOMs, errorField).filter((fieldDOM) => fieldDOM !== null);
717
716
  }
718
717
  #getErrorFieldDOM(field) {
719
718
  const errorDOM = this.#getFieldDOM(field)?.querySelector(ERROR_SELECTOR);
720
719
  return errorDOM && errorField(errorDOM);
721
720
  }
722
- #scrollToField = (field, scrollOpts = {
721
+ #scrollToField(field, scrollOpts = {
723
722
  behavior: "smooth",
724
723
  block: "start"
725
- }) => {
724
+ }) {
726
725
  const fieldDOM = this.#getFieldExist(field) ? this.#getFieldDOM(field) : null;
727
726
  if (fieldDOM) scrollIntoView$1(fieldDOM, scrollOpts);
728
- };
729
- #scrollToError = (config) => {
727
+ }
728
+ #scrollToError(config) {
730
729
  const { field, index, scrollOpts = {
731
730
  behavior: "smooth",
732
731
  block: "start"
@@ -736,16 +735,16 @@ var FormFoundation = class extends BaseFoundation {
736
735
  else if (field) fieldDOM = this.#getErrorFieldDOM(field);
737
736
  else if (typeof field === "undefined") fieldDOM = this.#getErrorFieldDOMs()[0];
738
737
  if (fieldDOM) scrollIntoView$1(fieldDOM, scrollOpts);
739
- };
738
+ }
740
739
  getInitValues() {
741
- return this._adapter.getInitValues();
740
+ return this.adapter.getInitValues();
742
741
  }
743
742
  getInitValue(field) {
744
- if (typeof field === "undefined") return this._adapter.getInitValues();
745
- return get$1(this._adapter.getInitValues(), field);
743
+ if (typeof field === "undefined") return this.adapter.getInitValues();
744
+ return get$1(this.adapter.getInitValues(), field);
746
745
  }
747
746
  getFormProps(keys) {
748
- return this._adapter.getFormProps(keys);
747
+ return this.adapter.getFormProps(keys);
749
748
  }
750
749
  init() {
751
750
  this.#destroyed = false;
@@ -753,39 +752,39 @@ var FormFoundation = class extends BaseFoundation {
753
752
  destroy() {
754
753
  this.#destroyed = true;
755
754
  }
756
- submit(e) {
755
+ submit = (e) => {
757
756
  const epoch = this.#epoch;
758
757
  this.#validate().then((resolveValues) => {
759
758
  if (this.#isCancelled(epoch)) return;
760
- const _values = this._adapter.cloneDeep(resolveValues);
761
- this._adapter.notifySubmit(_values, e);
759
+ const _values = this.adapter.cloneDeep(resolveValues);
760
+ this.adapter.notifySubmit(_values, e);
762
761
  }, (errors) => {
763
762
  if (this.#isCancelled(epoch)) return;
764
- const _errors = this._adapter.cloneDeep(errors);
765
- const _values = this._adapter.cloneDeep(this.#data.values);
766
- this._adapter.notifySubmitFail(_errors, _values, e);
763
+ const _errors = this.adapter.cloneDeep(errors);
764
+ const _values = this.adapter.cloneDeep(this.#data.values);
765
+ this.adapter.notifySubmitFail(_errors, _values, e);
767
766
  });
768
- }
769
- reset(fieldPaths) {
767
+ };
768
+ reset = (fieldPaths) => {
770
769
  const targetFields = this.#getOperateFieldMap(fieldPaths);
771
770
  if (fieldPaths === void 0) this.#epoch += 1;
772
771
  else targetFields.forEach((_, path) => this.#validations.delete(path));
773
772
  const prevErrors = this.#data.errors;
774
773
  this.#batch(() => {
775
774
  targetFields.forEach((field) => {
776
- this.#setFieldValue(field, field.initValue !== null ? this._adapter.cloneDeep(field.initValue) : void 0, SILENT);
775
+ this.#setFieldValue(field, field.initValue !== null ? this.adapter.cloneDeep(field.initValue) : void 0, SILENT);
777
776
  this.#setFieldError(field, void 0, SILENT);
778
777
  this.#setFieldTouched(field, void 0, SILENT);
779
778
  this.#updateField(field.store, { status: "default" });
780
779
  });
781
780
  });
782
781
  if (this.#registeredArrayField.size) this.#resetArrayField(fieldPaths);
783
- this._adapter.notifyChange(this.#data);
782
+ this.adapter.notifyChange(this.#data);
784
783
  this.#notifyErrorChange(prevErrors, targetFields.keys());
785
784
  this.#forceUpdate();
786
- this._adapter.notifyReset();
787
- }
788
- getFieldBridge() {
785
+ this.adapter.notifyReset();
786
+ };
787
+ getFieldBridge = () => {
789
788
  return {
790
789
  register: this.#register,
791
790
  unRegister: this.#unRegister,
@@ -807,8 +806,8 @@ var FormFoundation = class extends BaseFoundation {
807
806
  addArrayFieldRowWithValue: this.#addArrayFieldRowWithValue,
808
807
  removeArrayFieldRow: this.#removeArrayFieldRow
809
808
  };
810
- }
811
- getFormApi() {
809
+ };
810
+ getFormApi = () => {
812
811
  return {
813
812
  ...this.#getFieldSetterApi(),
814
813
  reset: (fields) => this.reset(fields),
@@ -827,10 +826,10 @@ var FormFoundation = class extends BaseFoundation {
827
826
  scrollToField: (field, scrollOpts) => this.#scrollToField(field, scrollOpts),
828
827
  scrollToError: (opts) => this.#scrollToError(opts)
829
828
  };
830
- }
829
+ };
831
830
  getFormState = (needClone = false) => {
832
831
  if (!needClone) return { ...this.#data };
833
- else return this._adapter.cloneDeep(this.#data);
832
+ else return this.adapter.cloneDeep(this.#data);
834
833
  };
835
834
  };
836
835
  export { FormFoundation as default };
@@ -20,7 +20,7 @@ function findChunks({ autoEscape, caseSensitive, searchWords, sourceString }) {
20
20
  }, []);
21
21
  }
22
22
  function combineChunks({ chunks }) {
23
- return chunks.sort((first, second) => first.start - second.start).reduce((processedChunks, nextChunk) => {
23
+ return chunks.toSorted((first, second) => first.start - second.start).reduce((processedChunks, nextChunk) => {
24
24
  if (processedChunks.length === 0) return [nextChunk];
25
25
  else {
26
26
  const prevChunk = processedChunks.pop();
@@ -12,8 +12,8 @@ export default class HotKeysFoundation<P extends HotKeysBaseProps = HotKeysBaseP
12
12
  #private;
13
13
  init(): void;
14
14
  /** Applies the same check as mounting, so an invalid combination set later fails just as loudly */
15
- handleHotKeysChange(): void;
15
+ handleHotKeysChange: () => void;
16
16
  /** Moves the keydown listener when `getListenerTarget` now returns a different element */
17
- handleTargetChange(): void;
17
+ handleTargetChange: () => void;
18
18
  destroy(): void;
19
19
  }