@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
@@ -278,7 +278,7 @@ var ResizableFoundation = class ResizableFoundation extends BaseFoundation {
278
278
  const flexBaseChanged = states.flexBasis !== newState.flexBasis;
279
279
  if (widthChanged || heightChanged || flexBaseChanged) {
280
280
  this.setState(newState);
281
- this._adapter.notifyChange({
281
+ this.adapter.notifyChange({
282
282
  width: newState.width,
283
283
  height: newState.height
284
284
  }, event, direction);
@@ -294,7 +294,7 @@ var ResizableFoundation = class ResizableFoundation extends BaseFoundation {
294
294
  #endResize(event, endSize = this.#size) {
295
295
  const { isResizing, direction } = this.getStates();
296
296
  if (!isResizing || !this.#resizable) return;
297
- this._adapter.notifyResizeEnd(endSize, event, direction);
297
+ this.adapter.notifyResizeEnd(endSize, event, direction);
298
298
  this.#restoreControlledSize();
299
299
  this.setState({
300
300
  isResizing: false,
@@ -305,11 +305,11 @@ var ResizableFoundation = class ResizableFoundation extends BaseFoundation {
305
305
  }, () => this.updateAriaRange());
306
306
  }
307
307
  #beginResize(e, direction, { clientX, clientY }) {
308
- this.#resizable = this._adapter.getResizable();
308
+ this.#resizable = this.adapter.getResizable();
309
309
  if (!this.#resizable || !this.#window) return false;
310
310
  const props = this.getProps();
311
311
  const states = this.getStates();
312
- if (this._adapter.notifyResizeStart(e, direction) === false) return false;
312
+ if (this.adapter.notifyResizeStart(e, direction) === false) return false;
313
313
  const { size } = props;
314
314
  if (size) {
315
315
  const { height, width } = size;
@@ -367,13 +367,10 @@ var ResizableFoundation = class ResizableFoundation extends BaseFoundation {
367
367
  init() {
368
368
  this.updateAriaRange();
369
369
  }
370
- /**
371
- * Reads the size and limits for aria-valuenow, -valuemin and -valuemax. A change of the limits alone goes
372
- * unnoticed until the next resize.
373
- */
374
- updateAriaRange() {
370
+ /** A change of the limits alone goes unnoticed until the next resize. */
371
+ updateAriaRange = () => {
375
372
  if (this.getStates().isResizing) return;
376
- this.#resizable = this._adapter.getResizable();
373
+ this.#resizable = this.adapter.getResizable();
377
374
  if (!this.#resizable || !this.#window) return;
378
375
  this.#setBoundary();
379
376
  const { parentSize, minWidth, minHeight, maxWidth, maxHeight } = this.#getLimits();
@@ -391,12 +388,12 @@ var ResizableFoundation = class ResizableFoundation extends BaseFoundation {
391
388
  }
392
389
  };
393
390
  if (!isEqual(ariaRange, this.getStates().ariaRange)) this.setState({ ariaRange });
394
- }
391
+ };
395
392
  /**
396
393
  * Keyboard resize along the axis of the edge, KEYBOARD_STEP px per press, reported like a drag.
397
394
  * Returns whether the key was handled.
398
395
  */
399
- resizeByKey(direction, e) {
396
+ resizeByKey = (direction, e) => {
400
397
  if (e.altKey || e.ctrlKey || e.metaKey) return false;
401
398
  const vertical = direction === "top" || direction === "bottom";
402
399
  const delta = new Map(vertical ? [["ArrowUp", -10], ["ArrowDown", 10]] : [["ArrowLeft", -10], ["ArrowRight", 10]]).get(e.key);
@@ -415,7 +412,7 @@ var ResizableFoundation = class ResizableFoundation extends BaseFoundation {
415
412
  this.#endResize(e, this.#changedSize ?? this.#size);
416
413
  }
417
414
  return true;
418
- }
415
+ };
419
416
  onResizeStart = (e, direction) => {
420
417
  if (!isSecondaryPress(e)) this.#beginResize(e, direction, e);
421
418
  };
@@ -6,7 +6,6 @@ export interface Item {
6
6
  text?: string;
7
7
  disabled?: boolean;
8
8
  }
9
- /** The props the foundation reads with getProp */
10
9
  export interface ScrollItemBaseProps<I extends Item = Item> {
11
10
  cycled?: boolean;
12
11
  list?: I[];
@@ -40,17 +39,16 @@ export default class ItemFoundation<I extends Item = Item, P extends ScrollItemB
40
39
  /**
41
40
  * APG single-select listbox keyboard, selection follows focus; the column scrolls once `selectedIndex` returns
42
41
  */
43
- handleKeyDown(event: KeyboardEvent): void;
42
+ handleKeyDown: (event: KeyboardEvent) => void;
44
43
  /** Click on an item in normal mode */
45
- selectIndex(index: number): void;
44
+ selectIndex: (index: number) => void;
46
45
  /** Click in a wheel column: the item under the pointer is selected once scrolling settles */
47
- handleWheelClick(e: Pick<Event, 'target'>): void;
46
+ handleWheelClick: (e: Pick<Event, "target">) => void;
48
47
  /** Scroll of the column: in wheel mode the item at the selector is selected once scrolling settles */
49
- handleScroll(): void;
48
+ handleScroll: () => void;
50
49
  /** The list length changed */
51
- syncList(): void;
50
+ syncList: () => void;
52
51
  /** The owner changed `selectedIndex` */
53
- syncSelectedIndex(selectedIndex: number, previous: number): void;
54
- /** Centres the item last selected */
55
- scrollToSelected(duration?: number): void;
52
+ syncSelectedIndex: (selectedIndex: number, previous: number) => void;
53
+ scrollToSelected: (duration?: number) => void;
56
54
  }
@@ -28,11 +28,11 @@ var ItemFoundation = class extends BaseFoundation {
28
28
  return Array.isArray(list) && list.length > 0 && index > -1 && Boolean(list[index % list.length]?.disabled);
29
29
  }
30
30
  #indexOf(node) {
31
- return Array.from(this._adapter.getListNode().children).indexOf(node);
31
+ return Array.from(this.adapter.getListNode().children).indexOf(node);
32
32
  }
33
33
  #getNodeByOffset(refNode, offset) {
34
34
  const { list, cycled, mode } = this.getProps();
35
- const listNode = this._adapter.getListNode();
35
+ const listNode = this.adapter.getListNode();
36
36
  if (isElement(refNode) && isElement(listNode) && Array.isArray(list) && list.length) {
37
37
  const sameCopyStep = offset % list.length;
38
38
  if (sameCopyStep) {
@@ -51,7 +51,7 @@ var ItemFoundation = class extends BaseFoundation {
51
51
  }
52
52
  #highlightNearestNode() {
53
53
  if (this.getProps().mode !== wheelMode) return;
54
- const listNode = this._adapter.getListNode();
54
+ const listNode = this.adapter.getListNode();
55
55
  const node = this.#getNearestNodeInfo().nearestNode || this.#selectedNode;
56
56
  if (isElement(node) && isElement(listNode)) {
57
57
  for (const child of Array.from(listNode.children)) child.classList.remove(cssClasses.SELECTED);
@@ -66,7 +66,7 @@ var ItemFoundation = class extends BaseFoundation {
66
66
  return this.#cancelScroll !== null;
67
67
  }
68
68
  #scrollToPos(targetTop, duration) {
69
- const wrapper = this._adapter.getScrollNode();
69
+ const wrapper = this.adapter.getScrollNode();
70
70
  this.#select.cancel();
71
71
  if (duration && this.getProps().motion) {
72
72
  this.#stopScroll();
@@ -83,11 +83,11 @@ var ItemFoundation = class extends BaseFoundation {
83
83
  #scrollToNode(node, duration) {
84
84
  if (!node) return;
85
85
  const itemHeight = node.offsetHeight || numbers.DEFAULT_ITEM_HEIGHT;
86
- const targetTop = (node.offsetTop || this._adapter.getListNode().children.length * itemHeight / 2) - (this._adapter.getScrollNode().offsetHeight - itemHeight) / 2;
86
+ const targetTop = (node.offsetTop || this.adapter.getListNode().children.length * itemHeight / 2) - (this.adapter.getScrollNode().offsetHeight - itemHeight) / 2;
87
87
  this.#scrollToPos(targetTop, duration);
88
88
  }
89
89
  #scrollToCenter(node) {
90
- const wrapper = this._adapter.getScrollNode();
90
+ const wrapper = this.adapter.getScrollNode();
91
91
  if (isElement(node) && isElement(wrapper)) {
92
92
  const scrollRect = wrapper.getBoundingClientRect();
93
93
  const selectedRect = node.getBoundingClientRect();
@@ -98,20 +98,20 @@ var ItemFoundation = class extends BaseFoundation {
98
98
  #recoverSelectedNode() {
99
99
  const { cycled, mode, selectedIndex } = this.getProps();
100
100
  if (cycled && mode === wheelMode || this.#selectedNode?.isConnected) return false;
101
- const node = this._adapter.getListNode().children[selectedIndex > -1 ? selectedIndex : 0];
101
+ const node = this.adapter.getListNode().children[selectedIndex > -1 ? selectedIndex : 0];
102
102
  this.#cacheSelectedNode(node);
103
103
  this.#cacheWillSelectNode(node);
104
104
  return Boolean(node);
105
105
  }
106
106
  #selectNode(node) {
107
107
  const { type, list: data, selectedIndex } = this.getProps();
108
- const listNode = this._adapter.getListNode();
108
+ const listNode = this.adapter.getListNode();
109
109
  if (isElement(node) && isElement(listNode)) {
110
110
  const indexInData = Array.from(listNode.children).findIndex((ele) => ele === node) % data.length;
111
111
  const item = data[indexInData];
112
112
  this.#cacheWillSelectNode(node);
113
113
  this.#scrollToCenter(node);
114
- if (indexInData !== selectedIndex % data.length) this._adapter.notifySelectItem({
114
+ if (indexInData !== selectedIndex % data.length) this.adapter.notifySelectItem({
115
115
  ...item,
116
116
  value: item.value,
117
117
  type,
@@ -121,8 +121,8 @@ var ItemFoundation = class extends BaseFoundation {
121
121
  }
122
122
  #initWheelList(callback) {
123
123
  const { list } = this.getProps();
124
- const listNode = this._adapter.getListNode();
125
- const wrapper = this._adapter.getScrollNode();
124
+ const listNode = this.adapter.getListNode();
125
+ const wrapper = this.adapter.getScrollNode();
126
126
  if (isElement(wrapper) && isElement(listNode) && list && list.length) {
127
127
  const prependCount = this.shouldPrepend(listNode, wrapper);
128
128
  const appendCount = this.shouldAppend(listNode, wrapper);
@@ -134,8 +134,8 @@ var ItemFoundation = class extends BaseFoundation {
134
134
  }
135
135
  #adjustInfiniteList() {
136
136
  const { list } = this.getProps();
137
- const listNode = this._adapter.getListNode();
138
- const wrapper = this._adapter.getScrollNode();
137
+ const listNode = this.adapter.getListNode();
138
+ const wrapper = this.adapter.getScrollNode();
139
139
  const nodeTag = "li";
140
140
  if (isElement(wrapper) && isElement(listNode) && list && list.length) {
141
141
  const allNodes = listNode.querySelectorAll(nodeTag);
@@ -154,8 +154,8 @@ var ItemFoundation = class extends BaseFoundation {
154
154
  }
155
155
  }
156
156
  #getNearestNodeInfo() {
157
- const listNode = this._adapter.getListNode();
158
- const selector = this._adapter.getSelectorNode();
157
+ const listNode = this.adapter.getListNode();
158
+ const selector = this.adapter.getSelectorNode();
159
159
  if (isElement(listNode) && isElement(selector)) {
160
160
  const selectorTop = selector.getBoundingClientRect().top;
161
161
  const itemNodes = listNode.querySelectorAll("li");
@@ -178,10 +178,10 @@ var ItemFoundation = class extends BaseFoundation {
178
178
  }
179
179
  }
180
180
  #getTargetNode(e) {
181
- const listNode = this._adapter.getListNode();
181
+ const listNode = this.adapter.getListNode();
182
182
  if (e && isElement(listNode)) {
183
183
  const targetTagName = "li";
184
- const currentTarget = e.target;
184
+ const currentTarget = e.target instanceof Node ? e.target : null;
185
185
  const itemNodes = listNode.querySelectorAll(targetTagName);
186
186
  const { list } = this.getProps();
187
187
  const length = Array.isArray(list) ? list.length : 0;
@@ -250,7 +250,7 @@ var ItemFoundation = class extends BaseFoundation {
250
250
  }
251
251
  init() {
252
252
  const { mode, cycled, selectedIndex } = this.getProps();
253
- const selectedNode = this._adapter.getListNode().children[typeof selectedIndex === "number" && selectedIndex > -1 ? selectedIndex : 0];
253
+ const selectedNode = this.adapter.getListNode().children[typeof selectedIndex === "number" && selectedIndex > -1 ? selectedIndex : 0];
254
254
  this.#cacheSelectedNode(selectedNode);
255
255
  this.#cacheWillSelectNode(selectedNode);
256
256
  if (mode === wheelMode && cycled) this.#initWheelList(() => this.#scrollToNode(selectedNode, 0));
@@ -264,7 +264,7 @@ var ItemFoundation = class extends BaseFoundation {
264
264
  /**
265
265
  * APG single-select listbox keyboard, selection follows focus; the column scrolls once `selectedIndex` returns
266
266
  */
267
- handleKeyDown(event) {
267
+ handleKeyDown = (event) => {
268
268
  const { list, selectedIndex, cycled, type } = this.getProps();
269
269
  let target = getListTargetIndex(event.key, selectedIndex, list.length, (index) => Boolean(list[index].disabled), { loop: cycled });
270
270
  if (target === null && this.#typeahead.accepts(event)) {
@@ -277,47 +277,47 @@ var ItemFoundation = class extends BaseFoundation {
277
277
  }
278
278
  event.preventDefault();
279
279
  this.#select.cancel();
280
- if (target !== selectedIndex) this._adapter.notifySelectItem({
280
+ if (target !== selectedIndex) this.adapter.notifySelectItem({
281
281
  ...list[target],
282
282
  type,
283
283
  index: target
284
284
  });
285
- }
285
+ };
286
286
  /** Click on an item in normal mode */
287
- selectIndex(index) {
287
+ selectIndex = (index) => {
288
288
  const { type, list } = this.getProps();
289
- const listNode = this._adapter.getListNode();
289
+ const listNode = this.adapter.getListNode();
290
290
  if (index > -1 && Array.isArray(list) && list.length && isElement(listNode)) {
291
291
  const indexInData = index % list.length;
292
292
  const item = list[indexInData];
293
293
  this.#cacheWillSelectNode(listNode.children[index]);
294
294
  this.#select.cancel();
295
- this._adapter.notifySelectItem({
295
+ this.adapter.notifySelectItem({
296
296
  ...item,
297
297
  value: item.value,
298
298
  type,
299
299
  index: indexInData
300
300
  });
301
301
  }
302
- }
302
+ };
303
303
  /** Click in a wheel column: the item under the pointer is selected once scrolling settles */
304
- handleWheelClick(e) {
304
+ handleWheelClick = (e) => {
305
305
  const { targetNode, infoInList } = this.#getTargetNode(e);
306
306
  if (targetNode && infoInList && !infoInList.disabled) this.#select(targetNode);
307
- }
307
+ };
308
308
  /** Scroll of the column: in wheel mode the item at the selector is selected once scrolling settles */
309
- handleScroll() {
309
+ handleScroll = () => {
310
310
  const info = this.#getNearestNodeInfo();
311
311
  if (!info) return;
312
312
  if (this.getProps().cycled) this.#adjustList();
313
313
  if (!this.#isAnimating) this.#select(info.nearestNode);
314
- }
314
+ };
315
315
  /** The list length changed */
316
- syncList() {
316
+ syncList = () => {
317
317
  if (this.#recoverSelectedNode()) this.scrollToSelected();
318
- }
318
+ };
319
319
  /** The owner changed `selectedIndex` */
320
- syncSelectedIndex(selectedIndex, previous) {
320
+ syncSelectedIndex = (selectedIndex, previous) => {
321
321
  if (this.#recoverSelectedNode()) {
322
322
  this.scrollToSelected();
323
323
  return;
@@ -327,10 +327,9 @@ var ItemFoundation = class extends BaseFoundation {
327
327
  if (!list.length || willSelectIndex % list.length !== selectedIndex % list.length) this.#cacheWillSelectNode(this.#getNodeByOffset(this.#selectedNode, selectedIndex - previous));
328
328
  this.#cacheSelectedNode(this.#willSelectNode);
329
329
  this.scrollToSelected();
330
- }
331
- /** Centres the item last selected */
332
- scrollToSelected(duration = numbers.DEFAULT_SCROLL_DURATION) {
330
+ };
331
+ scrollToSelected = (duration = numbers.DEFAULT_SCROLL_DURATION) => {
333
332
  this.#scrollToNode(this.#selectedNode, duration);
334
- }
333
+ };
335
334
  };
336
335
  export { ItemFoundation as default };
@@ -1,5 +1,5 @@
1
1
  @use 'semi:theme' as *;
2
- // Color
2
+
3
3
  $color-scrollList-bg: var(--semi-color-bg-3); // 滚动列表背景色
4
4
  $color-scrollList-border: var(--semi-color-border); // 滚动列表描边颜色
5
5
  $color-scrollList_header-bg: transparent; // 滚动列表 header 背景色
@@ -14,7 +14,6 @@ $color-scrollList_selected_item-text: var(--semi-color-text-0); // 滚动列表
14
14
  $color-scrollList_selected_item-icon: var(--semi-color-text-2); // 滚动列表选中选项图标颜色
15
15
  $color-scrollList_footer-border: var(--semi-color-border); // 滚动列表底部描边颜色
16
16
 
17
- // Width/Height
18
17
  $height-scrollList: 300px;
19
18
  $height-scrollList_item: 36px;
20
19
  $width-scrollList_item-border: $border-thickness-control;
@@ -23,7 +22,6 @@ $width-scrollList_item_wheel_selector-border: $border-thickness-control;
23
22
  $height-scrollList_line: 1px;
24
23
  $width-scrollList_footer-border: $border-thickness-control;
25
24
 
26
- // Spacing
27
25
  $spacing-scrollList_header-paddingY: 0;
28
26
  $spacing-scrollList_header-paddingX: 16px;
29
27
  $spacing-scrollList_header_title-paddingY: $spacing-base;
@@ -39,12 +37,9 @@ $spacing-scrollList_item_wheel_list_shade_pre-marginTop: -1 * ($height-scrollLis
39
37
  $spacing-scrollList_item_wheel_list_shade_post-marginTop: $height-scrollList_item * 0.5 + $border-thickness-control;
40
38
  $spacing-scrollList_footer-padding: 10px;
41
39
 
42
- // Radius
43
40
  $radius-scrollList: var(--semi-border-radius-medium);
44
41
 
45
- // Font
46
42
  $font-scrollList_header_title-fontWeight: $font-weight-bold;
47
43
  $font-scrollList_item_wheel_item_selected-fontWeight: $font-weight-bold;
48
44
 
49
- // Other
50
45
  $shadow-scrollList: var(--semi-shadow-elevated);
@@ -1,7 +1,6 @@
1
1
  import BaseFoundation, { DefaultAdapter } from "../base/foundation.js";
2
2
  import { isComposing } from "../utils/key-code.js";
3
- import { BasicOptionProps } from "./option-foundation.js";
4
- /** The props the foundation reads with getProps */
3
+ import { BasicOptionProps, OptionRecord } from "./option-foundation.js";
5
4
  export interface SelectBaseProps {
6
5
  allowCreate?: boolean;
7
6
  autoClearSearchValue?: boolean;
@@ -29,16 +28,19 @@ export interface SelectBaseState {
29
28
  isFocus: boolean;
30
29
  isFullTags: boolean;
31
30
  isOpen: boolean;
32
- options: BasicOptionProps[];
31
+ options: OptionRecord[];
32
+ /** The selected options' data by value */
33
33
  selections: Map<any, any>;
34
34
  showInput: boolean;
35
35
  }
36
+ /** The fields the foundation reads from a keydown, so a host framework's own event type also fits */
37
+ export type SelectKeyEvent = Pick<KeyboardEvent, 'key' | 'target' | 'currentTarget' | 'ctrlKey' | 'metaKey' | 'altKey' | 'shiftKey' | 'preventDefault' | 'stopPropagation'> & Parameters<typeof isComposing>[0];
36
38
  /** LE is the host's option list scroll event, which the foundation only passes through */
37
39
  export interface SelectAdapter<P extends SelectBaseProps = SelectBaseProps, S extends SelectBaseState = SelectBaseState, LE = unknown> extends DefaultAdapter<P, S> {
38
40
  updateFocusState(focus: boolean): void;
39
41
  focusTrigger(): void;
40
- getOptionsFromChildren(): BasicOptionProps[];
41
- updateOptions(options: BasicOptionProps[]): void;
42
+ getOptionsFromChildren(): OptionRecord[];
43
+ updateOptions(options: OptionRecord[]): void;
42
44
  updateFocusIndex(index: number): void;
43
45
  updateSelection(selection: Map<any, any>): void;
44
46
  openMenu(cb?: () => void): void;
@@ -73,68 +75,51 @@ type PropValue = LabelValue | Record<string, any>;
73
75
  export default class SelectFoundation<P extends SelectBaseProps = SelectBaseProps, S extends SelectBaseState = SelectBaseState, LE = unknown> extends BaseFoundation<SelectAdapter<P, S, LE>, P, S> {
74
76
  #private;
75
77
  /** `options` is the host's option list from optionList or the option children */
76
- static getInitialState(props: SelectBaseProps, options: BasicOptionProps[]): {
77
- options: ({
78
- _selected: boolean;
79
- value?: string | number;
80
- label?: string | number | unknown;
81
- children?: unknown;
82
- disabled?: boolean;
83
- showTick?: boolean;
84
- className?: string;
85
- style?: Record<string, any>;
86
- } | {
87
- _show: boolean;
88
- _selected: boolean;
89
- value?: string | number;
90
- label?: string | number | unknown;
91
- children?: unknown;
92
- disabled?: boolean;
93
- showTick?: boolean;
94
- className?: string;
95
- style?: Record<string, any>;
96
- })[];
78
+ static getInitialState(props: SelectBaseProps, options: OptionRecord[]): {
79
+ options: OptionRecord<BasicOptionProps, {
80
+ label?: unknown;
81
+ }>[];
97
82
  selections: Map<any, any>;
98
83
  focusIndex: number;
99
84
  overflowItemCount: number;
100
85
  };
101
86
  init(): void;
102
- focus(optionsForOpen?: BasicOptionProps[], openDropdown?: boolean): void;
87
+ focus: (optionsForOpen?: OptionRecord[], openDropdown?: boolean) => void;
103
88
  /** After an update, the host reports whether the options (optionList or children) and value changed by its own change detection */
104
- handleInputsChange({ optionsChanged, valueChanged }: {
89
+ handleInputsChange: ({ optionsChanged, valueChanged }: {
105
90
  optionsChanged: boolean;
106
91
  valueChanged: boolean;
107
- }, value: PropValue): void;
108
- handleClick(e: Pick<MouseEvent, 'target' | 'currentTarget' | 'detail'>): void;
109
- open(_acInput?: string, originalOptions?: BasicOptionProps[]): void;
110
- handleClickOutside(e: MouseEvent): void;
111
- close(closeConfig?: {
112
- event?: any;
92
+ }, value: PropValue) => void;
93
+ handleClick: (e: Pick<MouseEvent, "target" | "currentTarget" | "detail">) => void;
94
+ open: (_acInput?: string, originalOptions?: OptionRecord[]) => void;
95
+ handleClickOutside: (e: MouseEvent) => void;
96
+ close: (closeConfig?: {
97
+ event?: unknown;
113
98
  closeCb?: () => void;
114
99
  notToggleInput?: boolean;
115
100
  returnFocus?: boolean;
116
- }): void;
117
- onSelect(option: BasicOptionProps, optionIndex: number, event: MouseEvent | KeyboardEvent): void;
118
- clearSelected(): void;
119
- removeTag(item: BasicOptionProps): void;
120
- clearInput(event?: any): void;
121
- handleInputChange(sugInput: string, event: unknown): void;
122
- handleKeyDown(event: KeyboardEvent): void;
123
- handleContainerKeyDown(event: Pick<KeyboardEvent, 'key' | 'shiftKey' | 'preventDefault' | 'stopPropagation'> & Parameters<typeof isComposing>[0]): void;
124
- handleMouseEnter(e: MouseEvent): void;
125
- handleMouseLeave(e: MouseEvent): void;
126
- handleClearClick(e?: MouseEvent): void;
127
- handleOptionMouseEnter(optionIndex: number): void;
128
- handleListScroll(e: LE): void;
129
- handleTriggerFocus(e: FocusEvent): void;
130
- handleTriggerBlur(e: FocusEvent): void;
131
- handleInputFocus(e: FocusEvent): void;
132
- handleInputBlur(): void;
133
- selectAll(): void;
134
- updateScrollTop(): void;
135
- updateOverflowItemCount(selectionLength: number, overFlowCount?: number): void;
136
- updateIsFullTags(): void;
137
- handlePopoverClose(): void;
138
- handleSlotMouseEnter(): void;
101
+ }) => void;
102
+ onSelect: (option: OptionRecord, optionIndex: number, event: unknown) => void;
103
+ clearSelected: () => void;
104
+ removeTag: (item: BasicOptionProps) => void;
105
+ clearInput: (event?: unknown) => void;
106
+ handleInputChange: (sugInput: string, event: unknown) => void;
107
+ handleKeyDown: (event: SelectKeyEvent) => void;
108
+ handleContainerKeyDown: (event: Pick<KeyboardEvent, "key" | "shiftKey" | "preventDefault" | "stopPropagation"> & Parameters<typeof isComposing>[0]) => void;
109
+ handleMouseEnter: (e: unknown) => void;
110
+ handleMouseLeave: (e: unknown) => void;
111
+ handleClearClick: (e?: Pick<MouseEvent, "stopPropagation">) => void;
112
+ handleOptionMouseEnter: (optionIndex: number) => void;
113
+ handleListScroll: (e: LE) => void;
114
+ handleTriggerFocus: (e: unknown) => void;
115
+ handleTriggerBlur: (e: unknown) => void;
116
+ handleInputFocus: (e: unknown) => void;
117
+ handleInputBlur: () => void;
118
+ selectAll: () => void;
119
+ updateScrollTop: () => void;
120
+ updateOverflowItemCount: (selectionLength: number, overFlowCount?: number) => void;
121
+ updateIsFullTags: () => void;
122
+ handlePopoverClose: () => void;
123
+ handleSlotMouseEnter: () => void;
139
124
  }
140
125
  export {};