@fibrae/semi-foundation 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (194) hide show
  1. package/dist/anchor/foundation.d.ts +1 -1
  2. package/dist/anchor/foundation.js +21 -21
  3. package/dist/audio-player/foundation.d.ts +10 -10
  4. package/dist/audio-player/foundation.js +19 -19
  5. package/dist/auto-complete/foundation.d.ts +12 -12
  6. package/dist/auto-complete/foundation.js +51 -51
  7. package/dist/avatar/foundation.d.ts +5 -5
  8. package/dist/avatar/foundation.js +16 -16
  9. package/dist/backtop/foundation.d.ts +2 -2
  10. package/dist/backtop/foundation.js +7 -7
  11. package/dist/banner/foundation.d.ts +1 -1
  12. package/dist/banner/foundation.js +4 -4
  13. package/dist/base/auto-close-foundation.d.ts +8 -8
  14. package/dist/base/auto-close-foundation.js +15 -15
  15. package/dist/base/foundation.d.ts +4 -3
  16. package/dist/base/foundation.js +12 -11
  17. package/dist/breadcrumb/foundation.d.ts +5 -5
  18. package/dist/breadcrumb/foundation.js +9 -10
  19. package/dist/breadcrumb/item-foundation.d.ts +3 -3
  20. package/dist/breadcrumb/item-foundation.js +6 -6
  21. package/dist/calendar/event-util.js +1 -1
  22. package/dist/calendar/foundation.js +4 -4
  23. package/dist/calendar/month-foundation.d.ts +2 -2
  24. package/dist/calendar/month-foundation.js +6 -6
  25. package/dist/carousel/foundation.d.ts +17 -17
  26. package/dist/carousel/foundation.js +51 -51
  27. package/dist/cascader/foundation.d.ts +34 -26
  28. package/dist/cascader/foundation.js +143 -121
  29. package/dist/checkbox/checkbox-foundation.d.ts +2 -2
  30. package/dist/checkbox/checkbox-foundation.js +15 -15
  31. package/dist/checkbox/checkbox-group-foundation.d.ts +2 -2
  32. package/dist/checkbox/checkbox-group-foundation.js +8 -8
  33. package/dist/code-highlight/index.d.ts +1 -1
  34. package/dist/code-highlight/index.js +3 -3
  35. package/dist/collapse/foundation.d.ts +2 -2
  36. package/dist/collapse/foundation.js +7 -7
  37. package/dist/collapsible/foundation.d.ts +3 -3
  38. package/dist/collapsible/foundation.js +8 -8
  39. package/dist/color-picker/alpha-slider-foundation.d.ts +2 -4
  40. package/dist/color-picker/alpha-slider-foundation.js +10 -10
  41. package/dist/color-picker/color-choose-area-foundation.d.ts +2 -5
  42. package/dist/color-picker/color-choose-area-foundation.js +14 -14
  43. package/dist/color-picker/color-slider-foundation.d.ts +2 -4
  44. package/dist/color-picker/color-slider-foundation.js +10 -10
  45. package/dist/color-picker/data-part-foundation.d.ts +5 -5
  46. package/dist/color-picker/data-part-foundation.js +11 -11
  47. package/dist/color-picker/foundation.d.ts +4 -4
  48. package/dist/color-picker/foundation.js +10 -10
  49. package/dist/config-provider/breakpoint-observer.d.ts +3 -3
  50. package/dist/config-provider/breakpoint-observer.js +6 -6
  51. package/dist/cropper/foundation.d.ts +15 -15
  52. package/dist/cropper/foundation.js +26 -23
  53. package/dist/date-picker/_utils/picker-type.d.ts +1 -1
  54. package/dist/date-picker/foundation.d.ts +36 -36
  55. package/dist/date-picker/foundation.js +125 -129
  56. package/dist/date-picker/input-foundation.d.ts +9 -9
  57. package/dist/date-picker/input-foundation.js +28 -28
  58. package/dist/date-picker/months-grid-foundation.d.ts +17 -17
  59. package/dist/date-picker/months-grid-foundation.js +64 -65
  60. package/dist/date-picker/year-and-month-foundation.d.ts +3 -3
  61. package/dist/date-picker/year-and-month-foundation.js +11 -11
  62. package/dist/drag-move/foundation.d.ts +2 -2
  63. package/dist/drag-move/foundation.js +15 -13
  64. package/dist/dropdown/foundation.d.ts +8 -5
  65. package/dist/dropdown/foundation.js +32 -28
  66. package/dist/dropdown/menu-foundation.d.ts +1 -1
  67. package/dist/dropdown/menu-foundation.js +11 -11
  68. package/dist/feedback/foundation.d.ts +9 -9
  69. package/dist/feedback/foundation.js +33 -33
  70. package/dist/form/form-api-proxy.d.ts +8 -7
  71. package/dist/form/form-api-proxy.js +25 -25
  72. package/dist/form/foundation.d.ts +5 -5
  73. package/dist/form/foundation.js +60 -61
  74. package/dist/highlight/foundation.js +1 -1
  75. package/dist/hot-keys/foundation.d.ts +2 -2
  76. package/dist/hot-keys/foundation.js +5 -5
  77. package/dist/image/image-foundation.d.ts +4 -4
  78. package/dist/image/image-foundation.js +10 -10
  79. package/dist/image/preview-footer-foundation.d.ts +3 -3
  80. package/dist/image/preview-footer-foundation.js +10 -10
  81. package/dist/image/preview-foundation.js +7 -6
  82. package/dist/image/preview-image-foundation.d.ts +6 -8
  83. package/dist/image/preview-image-foundation.js +14 -14
  84. package/dist/image/preview-inner-foundation.d.ts +9 -9
  85. package/dist/image/preview-inner-foundation.js +38 -38
  86. package/dist/input/foundation.d.ts +10 -10
  87. package/dist/input/foundation.js +47 -49
  88. package/dist/input/text-entry-foundation.d.ts +3 -3
  89. package/dist/input/text-entry-foundation.js +14 -14
  90. package/dist/input/textarea-foundation.d.ts +7 -7
  91. package/dist/input/textarea-foundation.js +36 -36
  92. package/dist/input-number/foundation.d.ts +16 -14
  93. package/dist/input-number/foundation.js +54 -53
  94. package/dist/json-viewer/foundation.d.ts +8 -8
  95. package/dist/json-viewer/foundation.js +23 -23
  96. package/dist/lottie/foundation.d.ts +1 -1
  97. package/dist/lottie/foundation.js +4 -4
  98. package/dist/markdown-render/foundation.d.ts +1 -1
  99. package/dist/markdown-render/foundation.js +4 -4
  100. package/dist/modal/modal-content-foundation.d.ts +7 -7
  101. package/dist/modal/modal-content-foundation.js +20 -20
  102. package/dist/modal/modal-foundation.d.ts +6 -6
  103. package/dist/modal/modal-foundation.js +24 -24
  104. package/dist/navigation/foundation.d.ts +1 -1
  105. package/dist/navigation/foundation.js +14 -14
  106. package/dist/navigation/item-foundation.d.ts +1 -1
  107. package/dist/navigation/item-foundation.js +8 -8
  108. package/dist/navigation/sub-nav-foundation.d.ts +3 -3
  109. package/dist/navigation/sub-nav-foundation.js +17 -17
  110. package/dist/notification/notification-list-foundation.d.ts +7 -7
  111. package/dist/notification/notification-list-foundation.js +12 -12
  112. package/dist/overflow-list/foundation.d.ts +4 -4
  113. package/dist/overflow-list/foundation.js +18 -18
  114. package/dist/pagination/foundation.d.ts +8 -8
  115. package/dist/pagination/foundation.js +28 -28
  116. package/dist/pincode/foundation.d.ts +5 -5
  117. package/dist/pincode/foundation.js +22 -22
  118. package/dist/popconfirm/popconfirm-foundation.d.ts +7 -7
  119. package/dist/popconfirm/popconfirm-foundation.js +26 -26
  120. package/dist/radio/radio-foundation.d.ts +5 -5
  121. package/dist/radio/radio-foundation.js +15 -15
  122. package/dist/radio/radio-group-foundation.d.ts +2 -2
  123. package/dist/radio/radio-group-foundation.js +9 -9
  124. package/dist/rating/foundation.d.ts +10 -10
  125. package/dist/rating/foundation.js +35 -35
  126. package/dist/resizable/group/index.d.ts +6 -6
  127. package/dist/resizable/group/index.js +40 -40
  128. package/dist/resizable/single/index.d.ts +2 -2
  129. package/dist/resizable/single/index.js +9 -9
  130. package/dist/scroll-list/item-foundation.d.ts +7 -7
  131. package/dist/scroll-list/item-foundation.js +35 -35
  132. package/dist/select/foundation.d.ts +42 -56
  133. package/dist/select/foundation.js +214 -279
  134. package/dist/select/option-foundation.d.ts +23 -27
  135. package/dist/select/option-foundation.js +10 -18
  136. package/dist/side-sheet/side-sheet-foundation.d.ts +6 -6
  137. package/dist/side-sheet/side-sheet-foundation.js +22 -22
  138. package/dist/slider/foundation.d.ts +16 -16
  139. package/dist/slider/foundation.js +46 -46
  140. package/dist/sortable/accessibility.d.ts +1 -1
  141. package/dist/sortable/accessibility.js +2 -2
  142. package/dist/spin/foundation.d.ts +2 -2
  143. package/dist/spin/foundation.js +6 -6
  144. package/dist/steps/utils.d.ts +1 -1
  145. package/dist/switch/foundation.d.ts +2 -2
  146. package/dist/switch/foundation.js +7 -7
  147. package/dist/table/foundation.d.ts +14 -14
  148. package/dist/table/foundation.js +93 -93
  149. package/dist/table/utils.d.ts +2 -2
  150. package/dist/tabs/foundation.d.ts +5 -5
  151. package/dist/tabs/foundation.js +17 -17
  152. package/dist/tag-input/foundation.d.ts +11 -11
  153. package/dist/tag-input/foundation.js +52 -52
  154. package/dist/time-picker/foundation.d.ts +13 -13
  155. package/dist/time-picker/foundation.js +39 -39
  156. package/dist/time-picker/input-foundation.d.ts +4 -4
  157. package/dist/time-picker/input-foundation.js +13 -13
  158. package/dist/toast/toast-list-foundation.d.ts +7 -7
  159. package/dist/toast/toast-list-foundation.js +14 -14
  160. package/dist/tooltip/foundation.d.ts +9 -9
  161. package/dist/tooltip/foundation.js +67 -61
  162. package/dist/transfer/foundation.d.ts +22 -9
  163. package/dist/transfer/foundation.js +38 -23
  164. package/dist/tree/foundation.d.ts +14 -14
  165. package/dist/tree/foundation.js +61 -61
  166. package/dist/tree/shared.d.ts +1 -1
  167. package/dist/tree-select/foundation.d.ts +26 -20
  168. package/dist/tree-select/foundation.js +91 -83
  169. package/dist/typography/ellipsis.d.ts +4 -4
  170. package/dist/typography/ellipsis.js +8 -8
  171. package/dist/typography/format-numeral.d.ts +1 -1
  172. package/dist/typography/format-numeral.js +2 -2
  173. package/dist/upload/constants.d.ts +1 -1
  174. package/dist/upload/foundation.d.ts +17 -17
  175. package/dist/upload/foundation.js +92 -92
  176. package/dist/upload/utils.d.ts +3 -3
  177. package/dist/upload/utils.js +6 -6
  178. package/dist/user-guide/foundation.d.ts +3 -3
  179. package/dist/user-guide/foundation.js +19 -19
  180. package/dist/utils/a11y.d.ts +1 -1
  181. package/dist/utils/announcer.d.ts +2 -2
  182. package/dist/utils/announcer.js +4 -4
  183. package/dist/utils/focus-handle.d.ts +1 -1
  184. package/dist/utils/focus-handle.js +1 -2
  185. package/dist/utils/focus-scope.d.ts +5 -5
  186. package/dist/utils/focus-scope.js +10 -10
  187. package/dist/utils/is-promise.d.ts +1 -1
  188. package/dist/utils/release-holder.d.ts +2 -2
  189. package/dist/utils/release-holder.js +4 -4
  190. package/dist/video-player/foundation.d.ts +15 -15
  191. package/dist/video-player/foundation.js +89 -89
  192. package/dist/video-player/progress-foundation.d.ts +2 -2
  193. package/dist/video-player/progress-foundation.js +12 -12
  194. package/package.json +2 -2
@@ -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;
@@ -371,9 +371,9 @@ var ResizableFoundation = class ResizableFoundation extends BaseFoundation {
371
371
  * Reads the size and limits for aria-valuenow, -valuemin and -valuemax. A change of the limits alone goes
372
372
  * unnoticed until the next resize.
373
373
  */
374
- updateAriaRange() {
374
+ updateAriaRange = () => {
375
375
  if (this.getStates().isResizing) return;
376
- this.#resizable = this._adapter.getResizable();
376
+ this.#resizable = this.adapter.getResizable();
377
377
  if (!this.#resizable || !this.#window) return;
378
378
  this.#setBoundary();
379
379
  const { parentSize, minWidth, minHeight, maxWidth, maxHeight } = this.#getLimits();
@@ -391,12 +391,12 @@ var ResizableFoundation = class ResizableFoundation extends BaseFoundation {
391
391
  }
392
392
  };
393
393
  if (!isEqual(ariaRange, this.getStates().ariaRange)) this.setState({ ariaRange });
394
- }
394
+ };
395
395
  /**
396
396
  * Keyboard resize along the axis of the edge, KEYBOARD_STEP px per press, reported like a drag.
397
397
  * Returns whether the key was handled.
398
398
  */
399
- resizeByKey(direction, e) {
399
+ resizeByKey = (direction, e) => {
400
400
  if (e.altKey || e.ctrlKey || e.metaKey) return false;
401
401
  const vertical = direction === "top" || direction === "bottom";
402
402
  const delta = new Map(vertical ? [["ArrowUp", -10], ["ArrowDown", 10]] : [["ArrowLeft", -10], ["ArrowRight", 10]]).get(e.key);
@@ -415,7 +415,7 @@ var ResizableFoundation = class ResizableFoundation extends BaseFoundation {
415
415
  this.#endResize(e, this.#changedSize ?? this.#size);
416
416
  }
417
417
  return true;
418
- }
418
+ };
419
419
  onResizeStart = (e, direction) => {
420
420
  if (!isSecondaryPress(e)) this.#beginResize(e, direction, e);
421
421
  };
@@ -40,17 +40,17 @@ export default class ItemFoundation<I extends Item = Item, P extends ScrollItemB
40
40
  /**
41
41
  * APG single-select listbox keyboard, selection follows focus; the column scrolls once `selectedIndex` returns
42
42
  */
43
- handleKeyDown(event: KeyboardEvent): void;
43
+ handleKeyDown: (event: KeyboardEvent) => void;
44
44
  /** Click on an item in normal mode */
45
- selectIndex(index: number): void;
45
+ selectIndex: (index: number) => void;
46
46
  /** Click in a wheel column: the item under the pointer is selected once scrolling settles */
47
- handleWheelClick(e: Pick<Event, 'target'>): void;
47
+ handleWheelClick: (e: Pick<Event, "target">) => void;
48
48
  /** Scroll of the column: in wheel mode the item at the selector is selected once scrolling settles */
49
- handleScroll(): void;
49
+ handleScroll: () => void;
50
50
  /** The list length changed */
51
- syncList(): void;
51
+ syncList: () => void;
52
52
  /** The owner changed `selectedIndex` */
53
- syncSelectedIndex(selectedIndex: number, previous: number): void;
53
+ syncSelectedIndex: (selectedIndex: number, previous: number) => void;
54
54
  /** Centres the item last selected */
55
- scrollToSelected(duration?: number): void;
55
+ scrollToSelected: (duration?: number) => void;
56
56
  }
@@ -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,10 @@ 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
- }
330
+ };
331
331
  /** Centres the item last selected */
332
- scrollToSelected(duration = numbers.DEFAULT_SCROLL_DURATION) {
332
+ scrollToSelected = (duration = numbers.DEFAULT_SCROLL_DURATION) => {
333
333
  this.#scrollToNode(this.#selectedNode, duration);
334
- }
334
+ };
335
335
  };
336
336
  export { ItemFoundation as default };
@@ -1,6 +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";
3
+ import { BasicOptionProps, OptionRecord } from "./option-foundation.js";
4
4
  /** The props the foundation reads with getProps */
5
5
  export interface SelectBaseProps {
6
6
  allowCreate?: boolean;
@@ -29,16 +29,19 @@ export interface SelectBaseState {
29
29
  isFocus: boolean;
30
30
  isFullTags: boolean;
31
31
  isOpen: boolean;
32
- options: BasicOptionProps[];
32
+ options: OptionRecord[];
33
+ /** The selected options' data by value */
33
34
  selections: Map<any, any>;
34
35
  showInput: boolean;
35
36
  }
37
+ /** The fields the foundation reads from a keydown, so a host framework's own event type also fits */
38
+ export type SelectKeyEvent = Pick<KeyboardEvent, 'key' | 'target' | 'currentTarget' | 'ctrlKey' | 'metaKey' | 'altKey' | 'shiftKey' | 'preventDefault' | 'stopPropagation'> & Parameters<typeof isComposing>[0];
36
39
  /** LE is the host's option list scroll event, which the foundation only passes through */
37
40
  export interface SelectAdapter<P extends SelectBaseProps = SelectBaseProps, S extends SelectBaseState = SelectBaseState, LE = unknown> extends DefaultAdapter<P, S> {
38
41
  updateFocusState(focus: boolean): void;
39
42
  focusTrigger(): void;
40
- getOptionsFromChildren(): BasicOptionProps[];
41
- updateOptions(options: BasicOptionProps[]): void;
43
+ getOptionsFromChildren(): OptionRecord[];
44
+ updateOptions(options: OptionRecord[]): void;
42
45
  updateFocusIndex(index: number): void;
43
46
  updateSelection(selection: Map<any, any>): void;
44
47
  openMenu(cb?: () => void): void;
@@ -73,68 +76,51 @@ type PropValue = LabelValue | Record<string, any>;
73
76
  export default class SelectFoundation<P extends SelectBaseProps = SelectBaseProps, S extends SelectBaseState = SelectBaseState, LE = unknown> extends BaseFoundation<SelectAdapter<P, S, LE>, P, S> {
74
77
  #private;
75
78
  /** `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
- })[];
79
+ static getInitialState(props: SelectBaseProps, options: OptionRecord[]): {
80
+ options: OptionRecord<BasicOptionProps, {
81
+ label?: unknown;
82
+ }>[];
97
83
  selections: Map<any, any>;
98
84
  focusIndex: number;
99
85
  overflowItemCount: number;
100
86
  };
101
87
  init(): void;
102
- focus(optionsForOpen?: BasicOptionProps[], openDropdown?: boolean): void;
88
+ focus: (optionsForOpen?: OptionRecord[], openDropdown?: boolean) => void;
103
89
  /** After an update, the host reports whether the options (optionList or children) and value changed by its own change detection */
104
- handleInputsChange({ optionsChanged, valueChanged }: {
90
+ handleInputsChange: ({ optionsChanged, valueChanged }: {
105
91
  optionsChanged: boolean;
106
92
  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;
93
+ }, value: PropValue) => void;
94
+ handleClick: (e: Pick<MouseEvent, "target" | "currentTarget" | "detail">) => void;
95
+ open: (_acInput?: string, originalOptions?: OptionRecord[]) => void;
96
+ handleClickOutside: (e: MouseEvent) => void;
97
+ close: (closeConfig?: {
98
+ event?: unknown;
113
99
  closeCb?: () => void;
114
100
  notToggleInput?: boolean;
115
101
  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;
102
+ }) => void;
103
+ onSelect: (option: OptionRecord, optionIndex: number, event: unknown) => void;
104
+ clearSelected: () => void;
105
+ removeTag: (item: BasicOptionProps) => void;
106
+ clearInput: (event?: unknown) => void;
107
+ handleInputChange: (sugInput: string, event: unknown) => void;
108
+ handleKeyDown: (event: SelectKeyEvent) => void;
109
+ handleContainerKeyDown: (event: Pick<KeyboardEvent, "key" | "shiftKey" | "preventDefault" | "stopPropagation"> & Parameters<typeof isComposing>[0]) => void;
110
+ handleMouseEnter: (e: unknown) => void;
111
+ handleMouseLeave: (e: unknown) => void;
112
+ handleClearClick: (e?: Pick<MouseEvent, "stopPropagation">) => void;
113
+ handleOptionMouseEnter: (optionIndex: number) => void;
114
+ handleListScroll: (e: LE) => void;
115
+ handleTriggerFocus: (e: unknown) => void;
116
+ handleTriggerBlur: (e: unknown) => void;
117
+ handleInputFocus: (e: unknown) => void;
118
+ handleInputBlur: () => void;
119
+ selectAll: () => void;
120
+ updateScrollTop: () => void;
121
+ updateOverflowItemCount: (selectionLength: number, overFlowCount?: number) => void;
122
+ updateIsFullTags: () => void;
123
+ handlePopoverClose: () => void;
124
+ handleSlotMouseEnter: () => void;
139
125
  }
140
126
  export {};