@fibrae/semi-foundation 0.1.1 → 0.3.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 (282) hide show
  1. package/dist/anchor/foundation.d.ts +1 -4
  2. package/dist/anchor/foundation.js +21 -22
  3. package/dist/audio-player/foundation.d.ts +10 -13
  4. package/dist/audio-player/foundation.js +19 -20
  5. package/dist/auto-complete/foundation.d.ts +12 -14
  6. package/dist/auto-complete/foundation.js +51 -52
  7. package/dist/avatar/foundation.d.ts +5 -6
  8. package/dist/avatar/foundation.js +16 -16
  9. package/dist/avatar/variables.scss +0 -1
  10. package/dist/backtop/foundation.d.ts +2 -5
  11. package/dist/backtop/foundation.js +7 -8
  12. package/dist/banner/foundation.d.ts +1 -1
  13. package/dist/banner/foundation.js +4 -4
  14. package/dist/base/auto-close-foundation.d.ts +8 -9
  15. package/dist/base/auto-close-foundation.js +15 -15
  16. package/dist/base/foundation.d.ts +4 -4
  17. package/dist/base/foundation.js +12 -11
  18. package/dist/base/list-store.d.ts +0 -1
  19. package/dist/breadcrumb/foundation.d.ts +5 -5
  20. package/dist/breadcrumb/foundation.js +9 -10
  21. package/dist/breadcrumb/item-foundation.d.ts +3 -3
  22. package/dist/breadcrumb/item-foundation.js +6 -6
  23. package/dist/calendar/event-util.d.ts +0 -10
  24. package/dist/calendar/event-util.js +1 -11
  25. package/dist/calendar/foundation.d.ts +1 -6
  26. package/dist/calendar/foundation.js +5 -9
  27. package/dist/calendar/month-foundation.d.ts +2 -3
  28. package/dist/calendar/month-foundation.js +6 -7
  29. package/dist/carousel/foundation.d.ts +17 -19
  30. package/dist/carousel/foundation.js +51 -51
  31. package/dist/cascader/foundation.d.ts +36 -32
  32. package/dist/cascader/foundation.js +145 -132
  33. package/dist/cascader/util.d.ts +1 -8
  34. package/dist/cascader/util.js +1 -8
  35. package/dist/checkbox/checkbox-foundation.d.ts +3 -7
  36. package/dist/checkbox/checkbox-foundation.js +15 -17
  37. package/dist/checkbox/checkbox-group-foundation.d.ts +2 -3
  38. package/dist/checkbox/checkbox-group-foundation.js +8 -8
  39. package/dist/code-highlight/index.d.ts +1 -2
  40. package/dist/code-highlight/index.js +3 -3
  41. package/dist/collapse/foundation.d.ts +2 -2
  42. package/dist/collapse/foundation.js +7 -7
  43. package/dist/collapsible/foundation.d.ts +3 -3
  44. package/dist/collapsible/foundation.js +8 -8
  45. package/dist/color-picker/alpha-slider-foundation.d.ts +2 -4
  46. package/dist/color-picker/alpha-slider-foundation.js +10 -10
  47. package/dist/color-picker/color-choose-area-foundation.d.ts +2 -5
  48. package/dist/color-picker/color-choose-area-foundation.js +14 -14
  49. package/dist/color-picker/color-picker.scss +0 -2
  50. package/dist/color-picker/color-slider-foundation.d.ts +2 -4
  51. package/dist/color-picker/color-slider-foundation.js +10 -10
  52. package/dist/color-picker/data-part-foundation.d.ts +5 -5
  53. package/dist/color-picker/data-part-foundation.js +11 -11
  54. package/dist/color-picker/foundation.d.ts +4 -4
  55. package/dist/color-picker/foundation.js +10 -10
  56. package/dist/color-picker/interface.d.ts +0 -1
  57. package/dist/config-provider/breakpoint-observer.d.ts +3 -3
  58. package/dist/config-provider/breakpoint-observer.js +6 -6
  59. package/dist/config-provider/responsive-types.d.ts +0 -16
  60. package/dist/cropper/foundation.d.ts +15 -16
  61. package/dist/cropper/foundation.js +26 -24
  62. package/dist/date-picker/_utils/get-default-picker-date.d.ts +0 -3
  63. package/dist/date-picker/_utils/get-default-picker-date.js +0 -3
  64. package/dist/date-picker/_utils/get-inset-input-format-token.d.ts +0 -2
  65. package/dist/date-picker/_utils/get-inset-input-format-token.js +0 -2
  66. package/dist/date-picker/_utils/get-inset-input-value-from-inset-input-str.d.ts +0 -2
  67. package/dist/date-picker/_utils/get-inset-input-value-from-inset-input-str.js +0 -2
  68. package/dist/date-picker/_utils/parser.d.ts +0 -3
  69. package/dist/date-picker/_utils/parser.js +0 -7
  70. package/dist/date-picker/_utils/picker-type.d.ts +1 -3
  71. package/dist/date-picker/_utils/picker-type.js +0 -2
  72. package/dist/date-picker/_utils/to-callback-args.d.ts +0 -1
  73. package/dist/date-picker/_utils/to-callback-args.js +0 -1
  74. package/dist/date-picker/date-picker.scss +0 -3
  75. package/dist/date-picker/foundation.d.ts +39 -58
  76. package/dist/date-picker/foundation.js +126 -153
  77. package/dist/date-picker/input-foundation.d.ts +10 -16
  78. package/dist/date-picker/input-foundation.js +28 -30
  79. package/dist/date-picker/month-foundation.d.ts +0 -3
  80. package/dist/date-picker/month-foundation.js +0 -2
  81. package/dist/date-picker/months-grid-foundation.d.ts +17 -26
  82. package/dist/date-picker/months-grid-foundation.js +65 -75
  83. package/dist/date-picker/year-and-month-foundation.d.ts +3 -3
  84. package/dist/date-picker/year-and-month-foundation.js +11 -11
  85. package/dist/drag-move/foundation.d.ts +2 -3
  86. package/dist/drag-move/foundation.js +15 -13
  87. package/dist/dropdown/foundation.d.ts +8 -7
  88. package/dist/dropdown/foundation.js +32 -28
  89. package/dist/dropdown/menu-foundation.d.ts +1 -2
  90. package/dist/dropdown/menu-foundation.js +11 -11
  91. package/dist/feedback/foundation.d.ts +9 -10
  92. package/dist/feedback/foundation.js +33 -33
  93. package/dist/feedback/variables.scss +1 -5
  94. package/dist/float-button/float-button.css +0 -1
  95. package/dist/float-button/float-button.scss +0 -2
  96. package/dist/form/form-api-proxy.d.ts +8 -7
  97. package/dist/form/form-api-proxy.js +25 -25
  98. package/dist/form/form.scss +0 -12
  99. package/dist/form/foundation.d.ts +5 -5
  100. package/dist/form/foundation.js +60 -76
  101. package/dist/form/interface.d.ts +2 -15
  102. package/dist/form/utils.d.ts +0 -8
  103. package/dist/form/utils.js +0 -7
  104. package/dist/form/variables.scss +1 -4
  105. package/dist/grid/variables.scss +0 -10
  106. package/dist/highlight/foundation.d.ts +0 -2
  107. package/dist/highlight/foundation.js +1 -3
  108. package/dist/hot-keys/foundation.d.ts +2 -3
  109. package/dist/hot-keys/foundation.js +5 -5
  110. package/dist/image/image-foundation.d.ts +4 -6
  111. package/dist/image/image-foundation.js +10 -10
  112. package/dist/image/preview-footer-foundation.d.ts +3 -4
  113. package/dist/image/preview-footer-foundation.js +10 -10
  114. package/dist/image/preview-foundation.d.ts +0 -3
  115. package/dist/image/preview-foundation.js +7 -6
  116. package/dist/image/preview-image-foundation.d.ts +6 -9
  117. package/dist/image/preview-image-foundation.js +14 -14
  118. package/dist/image/preview-inner-foundation.d.ts +9 -10
  119. package/dist/image/preview-inner-foundation.js +38 -38
  120. package/dist/input/foundation.d.ts +10 -11
  121. package/dist/input/foundation.js +47 -49
  122. package/dist/input/text-entry-foundation.d.ts +3 -5
  123. package/dist/input/text-entry-foundation.js +14 -15
  124. package/dist/input/textarea-foundation.d.ts +7 -8
  125. package/dist/input/textarea-foundation.js +36 -36
  126. package/dist/input-number/caret.d.ts +0 -1
  127. package/dist/input-number/caret.js +0 -1
  128. package/dist/input-number/foundation.d.ts +16 -19
  129. package/dist/input-number/foundation.js +54 -58
  130. package/dist/json-viewer/foundation.d.ts +8 -10
  131. package/dist/json-viewer/foundation.js +23 -24
  132. package/dist/locale/interface.d.ts +0 -3
  133. package/dist/lottie/foundation.d.ts +1 -1
  134. package/dist/lottie/foundation.js +4 -4
  135. package/dist/markdown-render/foundation.d.ts +2 -7
  136. package/dist/markdown-render/foundation.js +5 -9
  137. package/dist/modal/modal-content-foundation.d.ts +7 -7
  138. package/dist/modal/modal-content-foundation.js +20 -20
  139. package/dist/modal/modal-foundation.d.ts +6 -6
  140. package/dist/modal/modal-foundation.js +24 -24
  141. package/dist/navigation/foundation.d.ts +1 -8
  142. package/dist/navigation/foundation.js +14 -20
  143. package/dist/navigation/item-foundation.d.ts +1 -1
  144. package/dist/navigation/item-foundation.js +8 -8
  145. package/dist/navigation/sub-nav-foundation.d.ts +3 -4
  146. package/dist/navigation/sub-nav-foundation.js +17 -17
  147. package/dist/notification/notification-list-foundation.d.ts +7 -8
  148. package/dist/notification/notification-list-foundation.js +12 -13
  149. package/dist/notification/variables.scss +0 -1
  150. package/dist/overflow-list/foundation.d.ts +4 -6
  151. package/dist/overflow-list/foundation.js +18 -19
  152. package/dist/pagination/foundation.d.ts +8 -10
  153. package/dist/pagination/foundation.js +28 -28
  154. package/dist/pincode/foundation.d.ts +6 -9
  155. package/dist/pincode/foundation.js +23 -26
  156. package/dist/popconfirm/popconfirm-foundation.d.ts +7 -9
  157. package/dist/popconfirm/popconfirm-foundation.js +26 -26
  158. package/dist/progress/generates.d.ts +1 -4
  159. package/dist/progress/generates.js +1 -4
  160. package/dist/progress/utils.d.ts +1 -1
  161. package/dist/progress/utils.js +1 -1
  162. package/dist/radio/radio-foundation.d.ts +5 -9
  163. package/dist/radio/radio-foundation.js +15 -16
  164. package/dist/radio/radio-group-foundation.d.ts +2 -3
  165. package/dist/radio/radio-group-foundation.js +9 -9
  166. package/dist/rating/foundation.d.ts +10 -15
  167. package/dist/rating/foundation.js +35 -38
  168. package/dist/resizable/group/index.d.ts +6 -10
  169. package/dist/resizable/group/index.js +40 -44
  170. package/dist/resizable/resizable.scss +0 -1
  171. package/dist/resizable/single/index.d.ts +3 -7
  172. package/dist/resizable/single/index.js +10 -13
  173. package/dist/scroll-list/item-foundation.d.ts +7 -9
  174. package/dist/scroll-list/item-foundation.js +35 -36
  175. package/dist/scroll-list/variables.scss +1 -6
  176. package/dist/select/foundation.d.ts +42 -57
  177. package/dist/select/foundation.js +214 -279
  178. package/dist/select/option-foundation.d.ts +23 -28
  179. package/dist/select/option-foundation.js +10 -19
  180. package/dist/select/variables.scss +1 -8
  181. package/dist/side-sheet/side-sheet-foundation.d.ts +7 -12
  182. package/dist/side-sheet/side-sheet-foundation.js +23 -27
  183. package/dist/side-sheet/variables.scss +1 -3
  184. package/dist/slider/foundation.d.ts +17 -28
  185. package/dist/slider/foundation.js +47 -59
  186. package/dist/slider/variables.scss +1 -5
  187. package/dist/sortable/accessibility.d.ts +1 -1
  188. package/dist/sortable/accessibility.js +2 -2
  189. package/dist/spin/foundation.d.ts +2 -4
  190. package/dist/spin/foundation.js +6 -7
  191. package/dist/spin/variables.scss +1 -3
  192. package/dist/steps/utils.d.ts +1 -1
  193. package/dist/switch/foundation.d.ts +2 -3
  194. package/dist/switch/foundation.js +7 -7
  195. package/dist/switch/switch.scss +1 -1
  196. package/dist/switch/variables.scss +1 -5
  197. package/dist/table/foundation.d.ts +24 -33
  198. package/dist/table/foundation.js +144 -108
  199. package/dist/table/table.scss +0 -1
  200. package/dist/table/utils.d.ts +2 -10
  201. package/dist/table/utils.js +0 -13
  202. package/dist/table/variables.scss +1 -5
  203. package/dist/tabs/foundation.d.ts +5 -14
  204. package/dist/tabs/foundation.js +17 -21
  205. package/dist/tabs/tabs.scss +1 -1
  206. package/dist/tag/focus.js +0 -1
  207. package/dist/tag-input/foundation.d.ts +11 -13
  208. package/dist/tag-input/foundation.js +52 -53
  209. package/dist/tag-input/tag-input.scss +0 -1
  210. package/dist/tag-input/utils/tag-focus.d.ts +0 -1
  211. package/dist/tag-input/utils/tag-focus.js +0 -1
  212. package/dist/time-picker/combox-foundation.d.ts +3 -11
  213. package/dist/time-picker/combox-foundation.js +3 -10
  214. package/dist/time-picker/foundation.d.ts +13 -23
  215. package/dist/time-picker/foundation.js +39 -48
  216. package/dist/time-picker/input-foundation.d.ts +4 -4
  217. package/dist/time-picker/input-foundation.js +13 -13
  218. package/dist/time-picker/utils/index.d.ts +0 -11
  219. package/dist/time-picker/utils/index.js +0 -11
  220. package/dist/toast/toast-list-foundation.d.ts +7 -7
  221. package/dist/toast/toast-list-foundation.js +14 -14
  222. package/dist/tooltip/adjust-position.d.ts +1 -2
  223. package/dist/tooltip/constants.d.ts +0 -3
  224. package/dist/tooltip/constants.js +0 -3
  225. package/dist/tooltip/foundation.d.ts +9 -12
  226. package/dist/tooltip/foundation.js +67 -63
  227. package/dist/tooltip/position.scss +0 -1
  228. package/dist/transfer/foundation.d.ts +22 -13
  229. package/dist/transfer/foundation.js +38 -24
  230. package/dist/tree/foundation.d.ts +14 -16
  231. package/dist/tree/foundation.js +61 -62
  232. package/dist/tree/shared.d.ts +2 -4
  233. package/dist/tree/shared.js +0 -2
  234. package/dist/tree/tree-util.d.ts +0 -5
  235. package/dist/tree/tree-util.js +0 -5
  236. package/dist/tree-select/foundation.d.ts +26 -22
  237. package/dist/tree-select/foundation.js +91 -86
  238. package/dist/typography/ellipsis.d.ts +5 -7
  239. package/dist/typography/ellipsis.js +8 -10
  240. package/dist/typography/format-numeral.d.ts +1 -1
  241. package/dist/typography/format-numeral.js +2 -2
  242. package/dist/typography/typography.scss +0 -1
  243. package/dist/upload/constants.d.ts +1 -1
  244. package/dist/upload/foundation.d.ts +17 -23
  245. package/dist/upload/foundation.js +93 -103
  246. package/dist/upload/utils.d.ts +3 -8
  247. package/dist/upload/utils.js +6 -11
  248. package/dist/user-guide/foundation.d.ts +3 -5
  249. package/dist/user-guide/foundation.js +19 -19
  250. package/dist/utils/a11y.d.ts +2 -6
  251. package/dist/utils/a11y.js +1 -4
  252. package/dist/utils/announcer.d.ts +2 -2
  253. package/dist/utils/announcer.js +4 -4
  254. package/dist/utils/array.d.ts +0 -6
  255. package/dist/utils/array.js +0 -6
  256. package/dist/utils/date-fns-extra.js +1 -5
  257. package/dist/utils/dom.d.ts +0 -1
  258. package/dist/utils/dom.js +0 -1
  259. package/dist/utils/escape-html.js +0 -3
  260. package/dist/utils/field-sizing.d.ts +0 -2
  261. package/dist/utils/field-sizing.js +0 -2
  262. package/dist/utils/focus-handle.d.ts +1 -2
  263. package/dist/utils/focus-handle.js +1 -3
  264. package/dist/utils/focus-scope.d.ts +5 -6
  265. package/dist/utils/focus-scope.js +10 -11
  266. package/dist/utils/is-promise.d.ts +1 -1
  267. package/dist/utils/release-holder.d.ts +2 -2
  268. package/dist/utils/release-holder.js +4 -4
  269. package/dist/utils/scroll-lock.d.ts +3 -4
  270. package/dist/utils/scroll-lock.js +3 -4
  271. package/dist/utils/tween.d.ts +0 -1
  272. package/dist/utils/tween.js +0 -1
  273. package/dist/utils/uuid.d.ts +0 -1
  274. package/dist/utils/uuid.js +0 -1
  275. package/dist/utils/warning.d.ts +0 -1
  276. package/dist/utils/warning.js +0 -1
  277. package/dist/video-player/foundation.d.ts +15 -15
  278. package/dist/video-player/foundation.js +89 -89
  279. package/dist/video-player/progress-foundation.d.ts +2 -3
  280. package/dist/video-player/progress-foundation.js +12 -13
  281. package/dist/video-player/variables.scss +1 -1
  282. package/package.json +2 -2
@@ -8,7 +8,6 @@ import truncateValue from "./util/truncate-value.js";
8
8
  var TextEntryFoundation = class TextEntryFoundation extends BaseFoundation {
9
9
  #compositionEnter = false;
10
10
  #composedSinceFocus = false;
11
- /** Whether an IME composition started since the element last took the focus */
12
11
  get composedSinceFocus() {
13
12
  return this.#composedSinceFocus;
14
13
  }
@@ -18,8 +17,8 @@ var TextEntryFoundation = class TextEntryFoundation extends BaseFoundation {
18
17
  return maxLength ? this.handleVisibleMaxLength(value) : value;
19
18
  }
20
19
  changeValue(value, e) {
21
- if (!this._isControlledComponent()) this._adapter.setValue(value);
22
- this._adapter.notifyChange(value, e);
20
+ if (!this.isControlledComponent()) this.adapter.setValue(value);
21
+ this.adapter.notifyChange(value, e);
23
22
  }
24
23
  handleVisibleMaxLength(value) {
25
24
  const { maxLength, getValueLength } = this.getProps();
@@ -49,30 +48,30 @@ var TextEntryFoundation = class TextEntryFoundation extends BaseFoundation {
49
48
  if (!value) return 0;
50
49
  return typeof getValueLength === "function" ? getValueLength(value) : value.length;
51
50
  }
52
- handleChange(value, e) {
51
+ handleChange = (value, e) => {
53
52
  const { composition } = this.getProps();
54
53
  let nextValue = value;
55
54
  if (composition && this.#compositionEnter) {
56
- this._adapter.setValue(nextValue);
55
+ this.adapter.setValue(nextValue);
57
56
  return;
58
57
  }
59
58
  if (!this.#compositionEnter) nextValue = this.getNextValue(nextValue);
60
59
  this.changeValue(nextValue, e);
61
- }
60
+ };
62
61
  handleCompositionStart = (e) => {
63
62
  this.#compositionEnter = true;
64
63
  this.#composedSinceFocus = true;
65
- this._adapter.notifyCompositionStart(e);
64
+ this.adapter.notifyCompositionStart(e);
66
65
  };
67
66
  handleCompositionEnd = (e) => {
68
67
  const { composition } = this.getProps();
69
- const value = e.target.value;
68
+ const value = e.target instanceof HTMLInputElement || e.target instanceof HTMLTextAreaElement ? e.target.value : "";
70
69
  this.#compositionEnter = false;
71
- this._adapter.notifyCompositionEnd(e);
70
+ this.adapter.notifyCompositionEnd(e);
72
71
  if (composition) {
73
72
  const nextValue = this.getNextValue(value);
74
73
  this.changeValue(nextValue, e);
75
- if (this._isControlledComponent()) this._adapter.setValue(this.getProp("value"));
74
+ if (this.isControlledComponent()) this.adapter.setValue(this.getProp("value"));
76
75
  return;
77
76
  }
78
77
  const { getValueLength, maxLength } = this.getProps();
@@ -81,13 +80,13 @@ var TextEntryFoundation = class TextEntryFoundation extends BaseFoundation {
81
80
  if (nextValue !== value) this.changeValue(nextValue, e);
82
81
  };
83
82
  handleCompositionUpdate = (e) => {
84
- this._adapter.notifyCompositionUpdate(e);
83
+ this.adapter.notifyCompositionUpdate(e);
85
84
  };
86
- handleFocus(e) {
85
+ handleFocus = (e) => {
87
86
  const { value } = this.getStates();
88
87
  this.#composedSinceFocus = false;
89
- this._adapter.toggleFocusing(true);
90
- this._adapter.notifyFocus(value, e);
91
- }
88
+ this.adapter.toggleFocusing(true);
89
+ this.adapter.notifyFocus(value, e);
90
+ };
92
91
  };
93
92
  export { TextEntryFoundation as default };
@@ -1,6 +1,5 @@
1
1
  import { isComposing } from "../utils/key-code.js";
2
2
  import TextEntryFoundation, { TextEntryAdapter, TextEntryBaseProps, TextEntryBaseState } from "./text-entry-foundation.js";
3
- /** The props the foundation reads with getProps */
4
3
  export interface TextAreaBaseProps extends TextEntryBaseProps {
5
4
  value?: string;
6
5
  disabled?: boolean;
@@ -44,10 +43,10 @@ export default class TextAreaFoundation<P extends TextAreaBaseProps = TextAreaBa
44
43
  init(): void;
45
44
  destroy(): void;
46
45
  /** Re-fits the inline height without field-sizing; hosts call it when the value, `autosize` or the node changes */
47
- fitAutosize(): void;
48
- handleValueChange(value: string): void;
49
- handleBlur(e: unknown): void;
50
- handleKeyDown(e: KE): void;
46
+ fitAutosize: () => void;
47
+ handleValueChange: (value: string) => void;
48
+ handleBlur: (e: unknown) => void;
49
+ handleKeyDown: (e: KE) => void;
51
50
  handleResize: (entries: {
52
51
  contentRect?: {
53
52
  width: number;
@@ -55,7 +54,7 @@ export default class TextAreaFoundation<P extends TextAreaBaseProps = TextAreaBa
55
54
  };
56
55
  target?: Element;
57
56
  }[]) => void;
58
- handleClear(e: Pick<Event, 'stopPropagation'>): void;
59
- handleClick(e: Pick<Event, 'target' | 'currentTarget'>): void;
60
- handleCounterClick(): void;
57
+ handleClear: (e: Pick<Event, "stopPropagation">) => void;
58
+ handleClick: (e: Pick<Event, "target" | "currentTarget">) => void;
59
+ handleCounterClick: () => void;
61
60
  }
@@ -27,8 +27,8 @@ var TextAreaFoundation = class extends TextEntryFoundation {
27
27
  this.#fitInline = false;
28
28
  }
29
29
  /** Re-fits the inline height without field-sizing; hosts call it when the value, `autosize` or the node changes */
30
- fitAutosize() {
31
- const textarea = this.#fitInline ? this._adapter.getTextarea() : null;
30
+ fitAutosize = () => {
31
+ const textarea = this.#fitInline ? this.adapter.getTextarea() : null;
32
32
  if (!textarea) return;
33
33
  if (!this.getProps().autosize) {
34
34
  if (this.#fitted) {
@@ -52,33 +52,33 @@ var TextAreaFoundation = class extends TextEntryFoundation {
52
52
  this.#observed = textarea;
53
53
  this.#lastWidth = NaN;
54
54
  }
55
- }
56
- handleValueChange(value) {
57
- this._adapter.setState({
55
+ };
56
+ handleValueChange = (value) => {
57
+ this.adapter.setState({
58
58
  value,
59
59
  cachedValue: value
60
60
  });
61
- }
62
- handleBlur(e) {
61
+ };
62
+ handleBlur = (e) => {
63
63
  const { value } = this.getStates();
64
64
  const { maxLength } = this.getProps();
65
65
  let realValue = value;
66
66
  if (maxLength && this.composedSinceFocus) {
67
67
  realValue = this.handleVisibleMaxLength(value);
68
68
  if (realValue !== value) {
69
- if (!this._isControlledComponent()) this._adapter.setValue(realValue);
70
- this._adapter.notifyChange(realValue, e);
69
+ if (!this.isControlledComponent()) this.adapter.setValue(realValue);
70
+ this.adapter.notifyChange(realValue, e);
71
71
  }
72
72
  }
73
- this._adapter.toggleFocusing(false);
74
- this._adapter.notifyBlur(realValue, e);
75
- }
76
- handleKeyDown(e) {
73
+ this.adapter.toggleFocusing(false);
74
+ this.adapter.notifyBlur(realValue, e);
75
+ };
76
+ handleKeyDown = (e) => {
77
77
  const { disabledEnterStartNewLine } = this.getProps();
78
78
  if (disabledEnterStartNewLine && e.key === "Enter" && !e.shiftKey) e.preventDefault();
79
- this._adapter.notifyKeyDown(e);
80
- if (e.key === "Enter" && !isComposing(e)) this._adapter.notifyEnterPress(e);
81
- }
79
+ this.adapter.notifyKeyDown(e);
80
+ if (e.key === "Enter" && !isComposing(e)) this.adapter.notifyEnterPress(e);
81
+ };
82
82
  handleResize = (entries) => {
83
83
  const entry = entries?.[0];
84
84
  const rect = entry?.contentRect;
@@ -95,36 +95,36 @@ var TextAreaFoundation = class extends TextEntryFoundation {
95
95
  }
96
96
  if (this.getProps().autosize) {
97
97
  if (last && last.height === height) return;
98
- this._adapter.notifyResize({ height: entry.target.getBoundingClientRect().height });
98
+ this.adapter.notifyResize({ height: entry.target.getBoundingClientRect().height });
99
99
  return;
100
100
  }
101
101
  if (last && last.width === width && last.height === height) return;
102
- this._adapter.notifyResize({
102
+ this.adapter.notifyResize({
103
103
  height,
104
104
  width
105
105
  });
106
106
  };
107
- handleClear(e) {
108
- if (!this._isControlledComponent("value")) this._adapter.setValue("");
109
- this._adapter.notifyChange("", e);
110
- this._adapter.notifyClear(e);
107
+ handleClear = (e) => {
108
+ if (!this.isControlledComponent("value")) this.adapter.setValue("");
109
+ this.adapter.notifyChange("", e);
110
+ this.adapter.notifyClear(e);
111
111
  e.stopPropagation();
112
- }
113
- handleClick(e) {
114
- const { disabled, readonly } = this._adapter.getProps();
115
- const { isFocus } = this._adapter.getStates();
112
+ };
113
+ handleClick = (e) => {
114
+ const { disabled, readonly } = this.adapter.getProps();
115
+ const { isFocus } = this.adapter.getStates();
116
116
  if (disabled || readonly || isFocus) return;
117
- if (this._adapter.isEventTarget(e)) {
118
- this._adapter.focusInput();
119
- this._adapter.toggleFocusing(true);
117
+ if (this.adapter.isEventTarget(e)) {
118
+ this.adapter.focusInput();
119
+ this.adapter.toggleFocusing(true);
120
120
  }
121
- }
122
- handleCounterClick() {
123
- const { disabled, readonly } = this._adapter.getProps();
124
- const { isFocus } = this._adapter.getStates();
121
+ };
122
+ handleCounterClick = () => {
123
+ const { disabled, readonly } = this.adapter.getProps();
124
+ const { isFocus } = this.adapter.getStates();
125
125
  if (disabled || readonly || isFocus) return;
126
- this._adapter.focusInput();
127
- this._adapter.toggleFocusing(true);
128
- }
126
+ this.adapter.focusInput();
127
+ this.adapter.toggleFocusing(true);
128
+ };
129
129
  };
130
130
  export { TextAreaFoundation as default };
@@ -1,4 +1,3 @@
1
- /** Records the text after the caret, so the caret can follow it when a change reformats the value */
2
1
  export declare function recordCaretTail(input: HTMLInputElement | null): string | undefined;
3
2
  /** Puts the caret in front of the longest suffix of the recorded tail that still ends the value */
4
3
  export declare function restoreCaretTail(input: HTMLInputElement | null, tail?: string): void;
@@ -1,5 +1,4 @@
1
1
  // src/input-number/caret.ts
2
- /** Records the text after the caret, so the caret can follow it when a change reformats the value */
3
2
  function recordCaretTail(input) {
4
3
  if (!input) return;
5
4
  const { selectionStart, selectionEnd, value } = input;
@@ -4,7 +4,6 @@ export interface ScientificNotationConfig {
4
4
  /** Number of digits threshold to trigger scientific notation display */
5
5
  threshold?: number;
6
6
  }
7
- /** The props the foundation reads with getProps */
8
7
  export interface InputNumberBaseProps {
9
8
  value?: number | string;
10
9
  defaultValue?: number | string;
@@ -35,6 +34,8 @@ export interface InputNumberBaseProps {
35
34
  export declare function reachesBound(number: number | null | undefined, bound: number | undefined, direction: 1 | -1): boolean;
36
35
  /** The members of a keyboard event the foundation reads; DOM events and React synthetic events both satisfy it */
37
36
  export type InputNumberKeyEvent = Pick<KeyboardEvent, 'key' | 'preventDefault' | 'shiftKey' | 'altKey' | 'ctrlKey' | 'metaKey'> & Parameters<typeof isComposing>[0];
37
+ /** The members of a step button's pointerdown the foundation reads, which it keeps for the repeats while the button is held */
38
+ export type InputNumberPressEvent = Pick<PointerEvent, 'button' | 'currentTarget' | 'pointerId' | 'shiftKey' | 'stopPropagation'>;
38
39
  /** FE and KE are the host's focus and keydown events, which the foundation passes on to the callbacks */
39
40
  export interface InputNumberAdapter<P extends InputNumberBaseProps = InputNumberBaseProps, S extends BaseInputNumberState = BaseInputNumberState, FE = unknown, KE = unknown> extends DefaultAdapter<P, S> {
40
41
  setValue: (value: string, cb?: () => void) => void;
@@ -48,7 +49,6 @@ export interface InputNumberAdapter<P extends InputNumberBaseProps = InputNumber
48
49
  notifyUpClick: (value: string, e: any) => void;
49
50
  notifyDownClick: (value: string, e: any) => void;
50
51
  notifyKeyDown: (e: KE) => void;
51
- /** The native input */
52
52
  getInput: () => HTMLInputElement | null;
53
53
  }
54
54
  export interface BaseInputNumberState {
@@ -62,8 +62,8 @@ export default class InputNumberFoundation<P extends InputNumberBaseProps = Inpu
62
62
  #private;
63
63
  protected isControlled(): boolean;
64
64
  protected isCurrency(): boolean;
65
- protected add(step?: number, event?: any): string;
66
- protected minus(step?: number, event?: any): string;
65
+ protected add(step?: number, event?: Pick<KeyboardEvent, 'shiftKey'>): string;
66
+ protected minus(step?: number, event?: Pick<KeyboardEvent, 'shiftKey'>): string;
67
67
  protected formatCurrency(value: number | string): string;
68
68
  /** `forDisplay` formats for the unfocused input: currency format and scientific notation apply only then */
69
69
  protected doFormat(value?: string | number, needAdjustPrec?: boolean, forDisplay?: boolean): string;
@@ -72,32 +72,29 @@ export default class InputNumberFoundation<P extends InputNumberBaseProps = Inpu
72
72
  protected doParse(value: string | number, needCheckPrec?: boolean, needAdjustPrec?: boolean, needAdjustMaxMin?: boolean): number;
73
73
  protected afterParser(value: string | number): string;
74
74
  protected toNumber(value: number | string, needAdjustPrec?: boolean): number;
75
- /**
76
- * True for a number within [min, max] whose decimal length is at most `precision` (when `needCheckPrec`).
77
- */
78
75
  protected isValidNumber(num: number, needCheckPrec?: boolean): boolean;
79
76
  /** ARIA takes a plain decimal, so 1.2e-7 is written out in full; an empty or infinite number has none */
80
77
  static getAriaValueNow(number?: number | null): string | undefined;
81
78
  /** The first render's state, so the formatted value shows without a second render (#2548); there is no init() */
82
79
  static getInitialState(props: Record<string, any>): BaseInputNumberState;
83
80
  destroy(): void;
84
- handleInputFocus(e: FE): void;
85
- handleInputChange(value: string, event: unknown): void;
86
- handleInputKeyDown(event: KE): void;
87
- handleInputBlur(e: FE): void;
88
- handleInputMouseEnter(): void;
89
- handleInputMouseLeave(): void;
90
- handleInputMouseMove(): void;
81
+ handleInputFocus: (e: FE) => void;
82
+ handleInputChange: (value: string, event: unknown) => void;
83
+ handleInputKeyDown: (event: KE) => void;
84
+ handleInputBlur: (e: FE) => void;
85
+ handleInputMouseEnter: () => void;
86
+ handleInputMouseLeave: () => void;
87
+ handleInputMouseMove: () => void;
91
88
  /** Ends the repeat of a held button; follows pointerup and pointercancel */
92
- handlePressEnd(): void;
89
+ handlePressEnd: () => void;
93
90
  /**
94
91
  * Under keepFocus or innerButtons a press on a step button never blurs the input, even when it steps nothing. This
95
92
  * belongs on mousedown: cancelling pointerdown would also suppress the mousedown that outside-click listeners of
96
93
  * other open popups wait for.
97
94
  */
98
- handleStepMouseDown(event: Pick<Event, 'preventDefault'>): void;
99
- handleUpPress(event: any): void;
100
- handleDownPress(event: any): void;
95
+ handleStepMouseDown: (event: Pick<Event, "preventDefault">) => void;
96
+ handleUpPress: (event: InputNumberPressEvent) => void;
97
+ handleDownPress: (event: InputNumberPressEvent) => void;
101
98
  /**
102
99
  * A changed controlled `value`, after the commit that received it. It never notifies: the parent already holds
103
100
  * this value, and an out-of-range one is shown as given until the user interacts.
@@ -106,5 +103,5 @@ export default class InputNumberFoundation<P extends InputNumberBaseProps = Inpu
106
103
  * be on blur (and the text right after a step), an unparsable value replaces the text. Otherwise the value is
107
104
  * formatted like on blur, except that it is not clamped, and an unparsable one empties it.
108
105
  */
109
- handleValueChange(value: number | string): void;
106
+ handleValueChange: (value: number | string) => void;
110
107
  }
@@ -20,30 +20,28 @@ var InputNumberFoundation = class InputNumberFoundation extends BaseFoundation {
20
20
  #lastChangeWasStep = false;
21
21
  #caretTail;
22
22
  #recordCaret() {
23
- this.#caretTail = recordCaretTail(this._adapter.getInput());
23
+ this.#caretTail = recordCaretTail(this.adapter.getInput());
24
24
  }
25
- /** Puts the caret back in front of the text that followed it before the last change */
26
25
  #restoreCaret() {
27
- restoreCaretTail(this._adapter.getInput(), this.#caretTail);
26
+ restoreCaretTail(this.adapter.getInput(), this.#caretTail);
28
27
  }
29
28
  #focusInput() {
30
- const input = this._adapter.getInput();
29
+ const input = this.adapter.getInput();
31
30
  if (input && FocusTrapHandle.getActiveElement(input) !== input) input.focus({ preventScroll: this.getProp("preventScroll") });
32
31
  }
33
32
  #getFinalCurrency() {
34
33
  const { currency } = this.getProps();
35
34
  return typeof currency === "string" ? currency : this.getProp("defaultCurrency");
36
35
  }
37
- /** Commits the formatted text a step produced */
38
36
  #commitStep(v = "", event = null, updateCb = null) {
39
37
  const parsed = this.doParse(v, false);
40
38
  const isValidNumber = !isNaN(parsed);
41
39
  if (!(isValidNumber && parsed === this.getState("number"))) this.#notifyChange(isValidNumber ? parsed : v, event);
42
40
  if (!this.isControlled()) {
43
- if (isValidNumber) this._adapter.setNumber(parsed);
44
- this._adapter.setValue(v, updateCb);
41
+ if (isValidNumber) this.adapter.setNumber(parsed);
42
+ this.adapter.setValue(v, updateCb);
45
43
  }
46
- if (this.getProp("keepFocus")) this._adapter.setFocusing(true, () => {
44
+ if (this.getProp("keepFocus")) this.adapter.setFocusing(true, () => {
47
45
  if (this.#lastChangeWasStep && this.getState("focusing")) this.#focusInput();
48
46
  this.#lastChangeWasStep = true;
49
47
  });
@@ -182,17 +180,18 @@ var InputNumberFoundation = class InputNumberFoundation extends BaseFoundation {
182
180
  #step(direction, event) {
183
181
  const value = direction > 0 ? this.add(null, event) : this.minus(null, event);
184
182
  this.#commitStep(value, event);
185
- if (direction > 0) this._adapter.notifyUpClick(value, event);
186
- else this._adapter.notifyDownClick(value, event);
183
+ if (direction > 0) this.adapter.notifyUpClick(value, event);
184
+ else this.adapter.notifyDownClick(value, event);
187
185
  }
188
186
  #canStep(direction) {
189
187
  const { readonly, disabled, min, max } = this.getProps();
190
188
  return !readonly && !disabled && !reachesBound(this.getState("number"), direction > 0 ? max : min, direction);
191
189
  }
192
190
  #press(direction, event) {
193
- if (isSecondaryPress(event) || !this.#canStep(direction)) return;
191
+ const { currentTarget } = event;
192
+ if (!(currentTarget instanceof Element) || isSecondaryPress(event) || !this.#canStep(direction)) return;
194
193
  this.#lastChangeWasStep = true;
195
- event.currentTarget.setPointerCapture(event.pointerId);
194
+ currentTarget.setPointerCapture(event.pointerId);
196
195
  event.stopPropagation();
197
196
  this.#step(direction, event);
198
197
  this.#registerTimer(() => {
@@ -206,21 +205,21 @@ var InputNumberFoundation = class InputNumberFoundation extends BaseFoundation {
206
205
  });
207
206
  }
208
207
  #notifyChange(value, e) {
209
- if (value == null || value === "") this._adapter.notifyChange("", e);
208
+ if (value == null || value === "") this.adapter.notifyChange("", e);
210
209
  else {
211
210
  const parsedNum = this.toNumber(value, true);
212
211
  if (typeof parsedNum === "number" && !isNaN(parsedNum)) {
213
- this._adapter.notifyChange(parsedNum, e);
212
+ this.adapter.notifyChange(parsedNum, e);
214
213
  this.#notifyNumberChange(parsedNum, e);
215
- } else this._adapter.notifyChange(this.afterParser(value), e);
214
+ } else this.adapter.notifyChange(this.afterParser(value), e);
216
215
  }
217
216
  }
218
217
  #notifyNumberChange(value, e) {
219
218
  const { number } = this.getStates();
220
- if (this.isValidNumber(value) && value !== number) this._adapter.notifyNumberChange(value, e);
219
+ if (this.isValidNumber(value) && value !== number) this.adapter.notifyNumberChange(value, e);
221
220
  }
222
221
  isControlled() {
223
- return this._isControlledComponent("value");
222
+ return this.isControlledComponent("value");
224
223
  }
225
224
  isCurrency() {
226
225
  const { currency } = this.getProps();
@@ -334,9 +333,6 @@ var InputNumberFoundation = class InputNumberFoundation extends BaseFoundation {
334
333
  }
335
334
  return Number(value);
336
335
  }
337
- /**
338
- * True for a number within [min, max] whose decimal length is at most `precision` (when `needCheckPrec`).
339
- */
340
336
  isValidNumber(num, needCheckPrec = true) {
341
337
  if (typeof num === "number" && !isNaN(num)) {
342
338
  const { min, max, precision } = this.getProps();
@@ -367,7 +363,7 @@ var InputNumberFoundation = class InputNumberFoundation extends BaseFoundation {
367
363
  this.#unregisterInterval();
368
364
  this.#unregisterTimer();
369
365
  }
370
- handleInputFocus(e) {
366
+ handleInputFocus = (e) => {
371
367
  const value = this.getState("value");
372
368
  if (value !== "") {
373
369
  if (this.#isScientificNotation() && !this.isCurrency()) {
@@ -377,17 +373,17 @@ var InputNumberFoundation = class InputNumberFoundation extends BaseFoundation {
377
373
  const parsedNum = typeof number === "number" ? number : this.doParse(strVal, false, false, false);
378
374
  if (!Number.isNaN(parsedNum)) {
379
375
  const fullNumberStr = this.doFormat(parsedNum, true, false);
380
- this._adapter.setValue(fullNumberStr);
376
+ this.adapter.setValue(fullNumberStr);
381
377
  }
382
378
  }
383
379
  }
384
380
  }
385
381
  this.#recordCaret();
386
- this._adapter.setFocusing(true);
382
+ this.adapter.setFocusing(true);
387
383
  this.#lastChangeWasStep = false;
388
- this._adapter.notifyFocus(e);
389
- }
390
- handleInputChange(value, event) {
384
+ this.adapter.notifyFocus(e);
385
+ };
386
+ handleInputChange = (value, event) => {
391
387
  this.#lastChangeWasStep = false;
392
388
  const parsedNum = this.doParse(value, true, true, true);
393
389
  const toNum = this.doParse(value, false, false, false);
@@ -416,14 +412,14 @@ var InputNumberFoundation = class InputNumberFoundation extends BaseFoundation {
416
412
  notifyVal = this.isControlled() ? formattedNum : valueAfterParser;
417
413
  }
418
414
  this.#notifyChange(notifyVal, event);
419
- if (!this.isControlled() && (num === null || typeof num === "number" && !isNaN(num))) this._adapter.setNumber(num);
420
- this._adapter.setValue(this.isControlled() && !this.isCurrency() ? formattedNum : this.doFormat(valueAfterParser, false), () => {
415
+ if (!this.isControlled() && (num === null || typeof num === "number" && !isNaN(num))) this.adapter.setNumber(num);
416
+ this.adapter.setValue(this.isControlled() && !this.isCurrency() ? formattedNum : this.doFormat(valueAfterParser, false), () => {
421
417
  this.#restoreCaret();
422
418
  });
423
- }
424
- handleInputKeyDown(event) {
419
+ };
420
+ handleInputKeyDown = (event) => {
425
421
  if (this.getProp("readonly")) {
426
- this._adapter.notifyKeyDown(event);
422
+ this.adapter.notifyKeyDown(event);
427
423
  return;
428
424
  }
429
425
  const key = isComposing(event) || event.altKey || event.ctrlKey || event.metaKey ? "" : event.key;
@@ -439,9 +435,9 @@ var InputNumberFoundation = class InputNumberFoundation extends BaseFoundation {
439
435
  });
440
436
  event.preventDefault();
441
437
  }
442
- this._adapter.notifyKeyDown(event);
443
- }
444
- handleInputBlur(e) {
438
+ this.adapter.notifyKeyDown(event);
439
+ };
440
+ handleInputBlur = (e) => {
445
441
  const currentValue = toString(this.getState("value"));
446
442
  let currentNumber = this.getState("number");
447
443
  if (currentNumber != null || currentValue != null && currentValue !== "") {
@@ -480,41 +476,41 @@ var InputNumberFoundation = class InputNumberFoundation extends BaseFoundation {
480
476
  if (strHasChanged || numHasChanged) {
481
477
  const reported = willSetVal != null ? this.#reportedText(willSetVal, currentNumber) : willSetNum;
482
478
  if (numHasChanged || reported !== currentValue) this.#notifyChange(reported, e);
483
- if (willSetVal != null) this._adapter.setValue(willSetVal);
484
- if (willSetNum != null && !this.isControlled()) this._adapter.setNumber(willSetNum);
479
+ if (willSetVal != null) this.adapter.setValue(willSetVal);
480
+ if (willSetNum != null && !this.isControlled()) this.adapter.setNumber(willSetNum);
485
481
  }
486
482
  }
487
- this._adapter.setFocusing(false);
488
- this._adapter.notifyBlur(e);
489
- }
490
- handleInputMouseEnter() {
491
- this._adapter.setHovering(true);
492
- }
493
- handleInputMouseLeave() {
494
- this._adapter.setHovering(false);
495
- }
496
- handleInputMouseMove() {
497
- if (!this.getState("hovering")) this._adapter.setHovering(true);
498
- }
483
+ this.adapter.setFocusing(false);
484
+ this.adapter.notifyBlur(e);
485
+ };
486
+ handleInputMouseEnter = () => {
487
+ this.adapter.setHovering(true);
488
+ };
489
+ handleInputMouseLeave = () => {
490
+ this.adapter.setHovering(false);
491
+ };
492
+ handleInputMouseMove = () => {
493
+ if (!this.getState("hovering")) this.adapter.setHovering(true);
494
+ };
499
495
  /** Ends the repeat of a held button; follows pointerup and pointercancel */
500
- handlePressEnd() {
496
+ handlePressEnd = () => {
501
497
  this.#unregisterInterval();
502
498
  this.#unregisterTimer();
503
- }
499
+ };
504
500
  /**
505
501
  * Under keepFocus or innerButtons a press on a step button never blurs the input, even when it steps nothing. This
506
502
  * belongs on mousedown: cancelling pointerdown would also suppress the mousedown that outside-click listeners of
507
503
  * other open popups wait for.
508
504
  */
509
- handleStepMouseDown(event) {
505
+ handleStepMouseDown = (event) => {
510
506
  if (this.getProp("keepFocus") || this.getProp("innerButtons")) event.preventDefault();
511
- }
512
- handleUpPress(event) {
507
+ };
508
+ handleUpPress = (event) => {
513
509
  this.#press(1, event);
514
- }
515
- handleDownPress(event) {
510
+ };
511
+ handleDownPress = (event) => {
516
512
  this.#press(-1, event);
517
- }
513
+ };
518
514
  /**
519
515
  * A changed controlled `value`, after the commit that received it. It never notifies: the parent already holds
520
516
  * this value, and an out-of-range one is shown as given until the user interacts.
@@ -523,7 +519,7 @@ var InputNumberFoundation = class InputNumberFoundation extends BaseFoundation {
523
519
  * be on blur (and the text right after a step), an unparsable value replaces the text. Otherwise the value is
524
520
  * formatted like on blur, except that it is not clamped, and an unparsable one empties it.
525
521
  */
526
- handleValueChange(value) {
522
+ handleValueChange = (value) => {
527
523
  let states;
528
524
  let callback;
529
525
  if (value == null || value === "") states = {
@@ -552,6 +548,6 @@ var InputNumberFoundation = class InputNumberFoundation extends BaseFoundation {
552
548
  };
553
549
  }
554
550
  this.setState(states, callback);
555
- }
551
+ };
556
552
  };
557
553
  export { InputNumberFoundation as default, reachesBound };
@@ -6,7 +6,6 @@ export interface SearchOptions {
6
6
  wholeWord: boolean;
7
7
  regex: boolean;
8
8
  }
9
- /** The props the foundation reads with getProps */
10
9
  export interface JsonViewerBaseProps {
11
10
  value: string;
12
11
  options?: JsonViewerOptions;
@@ -28,15 +27,14 @@ export default class JsonViewerFoundation<P extends JsonViewerBaseProps = JsonVi
28
27
  jsonViewer: JsonViewer | null;
29
28
  init(): void;
30
29
  destroy(): void;
31
- search(searchText: string, caseSensitive?: boolean, wholeWord?: boolean, regex?: boolean): void;
32
- prevSearch(step?: number): void;
33
- nextSearch(step?: number): void;
34
- replace(replaceText: string): void;
35
- replaceAll(replaceText: string): void;
36
- /** Toggles one search option, then searches again with the input text and the new options */
37
- toggleSearchOption(key: keyof SearchOptions): void;
38
- toggleSearchBar(): void;
30
+ search: (searchText: string, caseSensitive?: boolean, wholeWord?: boolean, regex?: boolean) => void;
31
+ prevSearch: (step?: number) => void;
32
+ nextSearch: (step?: number) => void;
33
+ replace: (replaceText: string) => void;
34
+ replaceAll: (replaceText: string) => void;
35
+ toggleSearchOption: (key: keyof SearchOptions) => void;
36
+ toggleSearchBar: () => void;
39
37
  /** `null` when nothing was searched (or the bar was closed), `undefined` while there is no editor */
40
- getSearchResults(): SearchResults | null | undefined;
38
+ getSearchResults: () => SearchResults | null | undefined;
41
39
  }
42
40
  export type { CustomRenderRule, JsonViewerOptions, TokenRenderType };