@fibrae/semi-foundation 0.1.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (194) hide show
  1. package/dist/anchor/foundation.d.ts +1 -1
  2. package/dist/anchor/foundation.js +21 -21
  3. package/dist/audio-player/foundation.d.ts +10 -10
  4. package/dist/audio-player/foundation.js +19 -19
  5. package/dist/auto-complete/foundation.d.ts +12 -12
  6. package/dist/auto-complete/foundation.js +51 -51
  7. package/dist/avatar/foundation.d.ts +5 -5
  8. package/dist/avatar/foundation.js +16 -16
  9. package/dist/backtop/foundation.d.ts +2 -2
  10. package/dist/backtop/foundation.js +7 -7
  11. package/dist/banner/foundation.d.ts +1 -1
  12. package/dist/banner/foundation.js +4 -4
  13. package/dist/base/auto-close-foundation.d.ts +8 -8
  14. package/dist/base/auto-close-foundation.js +15 -15
  15. package/dist/base/foundation.d.ts +4 -3
  16. package/dist/base/foundation.js +12 -11
  17. package/dist/breadcrumb/foundation.d.ts +5 -5
  18. package/dist/breadcrumb/foundation.js +9 -10
  19. package/dist/breadcrumb/item-foundation.d.ts +3 -3
  20. package/dist/breadcrumb/item-foundation.js +6 -6
  21. package/dist/calendar/event-util.js +1 -1
  22. package/dist/calendar/foundation.js +4 -4
  23. package/dist/calendar/month-foundation.d.ts +2 -2
  24. package/dist/calendar/month-foundation.js +6 -6
  25. package/dist/carousel/foundation.d.ts +17 -17
  26. package/dist/carousel/foundation.js +51 -51
  27. package/dist/cascader/foundation.d.ts +34 -26
  28. package/dist/cascader/foundation.js +143 -121
  29. package/dist/checkbox/checkbox-foundation.d.ts +2 -2
  30. package/dist/checkbox/checkbox-foundation.js +15 -15
  31. package/dist/checkbox/checkbox-group-foundation.d.ts +2 -2
  32. package/dist/checkbox/checkbox-group-foundation.js +8 -8
  33. package/dist/code-highlight/index.d.ts +1 -1
  34. package/dist/code-highlight/index.js +3 -3
  35. package/dist/collapse/foundation.d.ts +2 -2
  36. package/dist/collapse/foundation.js +7 -7
  37. package/dist/collapsible/foundation.d.ts +3 -3
  38. package/dist/collapsible/foundation.js +8 -8
  39. package/dist/color-picker/alpha-slider-foundation.d.ts +2 -4
  40. package/dist/color-picker/alpha-slider-foundation.js +10 -10
  41. package/dist/color-picker/color-choose-area-foundation.d.ts +2 -5
  42. package/dist/color-picker/color-choose-area-foundation.js +14 -14
  43. package/dist/color-picker/color-slider-foundation.d.ts +2 -4
  44. package/dist/color-picker/color-slider-foundation.js +10 -10
  45. package/dist/color-picker/data-part-foundation.d.ts +5 -5
  46. package/dist/color-picker/data-part-foundation.js +11 -11
  47. package/dist/color-picker/foundation.d.ts +4 -4
  48. package/dist/color-picker/foundation.js +10 -10
  49. package/dist/config-provider/breakpoint-observer.d.ts +3 -3
  50. package/dist/config-provider/breakpoint-observer.js +6 -6
  51. package/dist/cropper/foundation.d.ts +15 -15
  52. package/dist/cropper/foundation.js +26 -23
  53. package/dist/date-picker/_utils/picker-type.d.ts +1 -1
  54. package/dist/date-picker/foundation.d.ts +36 -36
  55. package/dist/date-picker/foundation.js +125 -129
  56. package/dist/date-picker/input-foundation.d.ts +9 -9
  57. package/dist/date-picker/input-foundation.js +28 -28
  58. package/dist/date-picker/months-grid-foundation.d.ts +16 -16
  59. package/dist/date-picker/months-grid-foundation.js +64 -65
  60. package/dist/date-picker/year-and-month-foundation.d.ts +3 -3
  61. package/dist/date-picker/year-and-month-foundation.js +11 -11
  62. package/dist/drag-move/foundation.d.ts +2 -2
  63. package/dist/drag-move/foundation.js +15 -13
  64. package/dist/dropdown/foundation.d.ts +8 -5
  65. package/dist/dropdown/foundation.js +32 -28
  66. package/dist/dropdown/menu-foundation.d.ts +1 -1
  67. package/dist/dropdown/menu-foundation.js +11 -11
  68. package/dist/feedback/foundation.d.ts +9 -9
  69. package/dist/feedback/foundation.js +33 -33
  70. package/dist/form/form-api-proxy.d.ts +8 -7
  71. package/dist/form/form-api-proxy.js +25 -25
  72. package/dist/form/foundation.d.ts +5 -5
  73. package/dist/form/foundation.js +60 -61
  74. package/dist/highlight/foundation.js +1 -1
  75. package/dist/hot-keys/foundation.d.ts +2 -2
  76. package/dist/hot-keys/foundation.js +5 -5
  77. package/dist/image/image-foundation.d.ts +4 -4
  78. package/dist/image/image-foundation.js +10 -10
  79. package/dist/image/preview-footer-foundation.d.ts +3 -3
  80. package/dist/image/preview-footer-foundation.js +10 -10
  81. package/dist/image/preview-foundation.js +7 -6
  82. package/dist/image/preview-image-foundation.d.ts +6 -8
  83. package/dist/image/preview-image-foundation.js +14 -14
  84. package/dist/image/preview-inner-foundation.d.ts +9 -9
  85. package/dist/image/preview-inner-foundation.js +38 -38
  86. package/dist/input/foundation.d.ts +10 -10
  87. package/dist/input/foundation.js +47 -49
  88. package/dist/input/text-entry-foundation.d.ts +3 -3
  89. package/dist/input/text-entry-foundation.js +14 -14
  90. package/dist/input/textarea-foundation.d.ts +7 -7
  91. package/dist/input/textarea-foundation.js +36 -36
  92. package/dist/input-number/foundation.d.ts +16 -14
  93. package/dist/input-number/foundation.js +54 -53
  94. package/dist/json-viewer/foundation.d.ts +8 -8
  95. package/dist/json-viewer/foundation.js +23 -23
  96. package/dist/lottie/foundation.d.ts +1 -1
  97. package/dist/lottie/foundation.js +4 -4
  98. package/dist/markdown-render/foundation.d.ts +1 -1
  99. package/dist/markdown-render/foundation.js +4 -4
  100. package/dist/modal/modal-content-foundation.d.ts +7 -7
  101. package/dist/modal/modal-content-foundation.js +20 -20
  102. package/dist/modal/modal-foundation.d.ts +6 -6
  103. package/dist/modal/modal-foundation.js +24 -24
  104. package/dist/navigation/foundation.d.ts +1 -1
  105. package/dist/navigation/foundation.js +14 -14
  106. package/dist/navigation/item-foundation.d.ts +1 -1
  107. package/dist/navigation/item-foundation.js +8 -8
  108. package/dist/navigation/sub-nav-foundation.d.ts +3 -3
  109. package/dist/navigation/sub-nav-foundation.js +17 -17
  110. package/dist/notification/notification-list-foundation.d.ts +7 -7
  111. package/dist/notification/notification-list-foundation.js +12 -12
  112. package/dist/overflow-list/foundation.d.ts +4 -4
  113. package/dist/overflow-list/foundation.js +18 -18
  114. package/dist/pagination/foundation.d.ts +8 -8
  115. package/dist/pagination/foundation.js +28 -28
  116. package/dist/pincode/foundation.d.ts +5 -5
  117. package/dist/pincode/foundation.js +22 -22
  118. package/dist/popconfirm/popconfirm-foundation.d.ts +7 -7
  119. package/dist/popconfirm/popconfirm-foundation.js +26 -26
  120. package/dist/radio/radio-foundation.d.ts +5 -5
  121. package/dist/radio/radio-foundation.js +15 -15
  122. package/dist/radio/radio-group-foundation.d.ts +2 -2
  123. package/dist/radio/radio-group-foundation.js +9 -9
  124. package/dist/rating/foundation.d.ts +10 -10
  125. package/dist/rating/foundation.js +35 -35
  126. package/dist/resizable/group/index.d.ts +6 -6
  127. package/dist/resizable/group/index.js +40 -40
  128. package/dist/resizable/single/index.d.ts +2 -2
  129. package/dist/resizable/single/index.js +9 -9
  130. package/dist/scroll-list/item-foundation.d.ts +7 -7
  131. package/dist/scroll-list/item-foundation.js +35 -35
  132. package/dist/select/foundation.d.ts +42 -56
  133. package/dist/select/foundation.js +214 -279
  134. package/dist/select/option-foundation.d.ts +23 -27
  135. package/dist/select/option-foundation.js +10 -18
  136. package/dist/side-sheet/side-sheet-foundation.d.ts +6 -6
  137. package/dist/side-sheet/side-sheet-foundation.js +22 -22
  138. package/dist/slider/foundation.d.ts +16 -16
  139. package/dist/slider/foundation.js +46 -46
  140. package/dist/sortable/accessibility.d.ts +1 -1
  141. package/dist/sortable/accessibility.js +2 -2
  142. package/dist/spin/foundation.d.ts +2 -2
  143. package/dist/spin/foundation.js +6 -6
  144. package/dist/steps/utils.d.ts +1 -1
  145. package/dist/switch/foundation.d.ts +2 -2
  146. package/dist/switch/foundation.js +7 -7
  147. package/dist/table/foundation.d.ts +14 -14
  148. package/dist/table/foundation.js +93 -93
  149. package/dist/table/utils.d.ts +2 -2
  150. package/dist/tabs/foundation.d.ts +5 -5
  151. package/dist/tabs/foundation.js +17 -17
  152. package/dist/tag-input/foundation.d.ts +11 -11
  153. package/dist/tag-input/foundation.js +52 -52
  154. package/dist/time-picker/foundation.d.ts +13 -13
  155. package/dist/time-picker/foundation.js +39 -39
  156. package/dist/time-picker/input-foundation.d.ts +4 -4
  157. package/dist/time-picker/input-foundation.js +13 -13
  158. package/dist/toast/toast-list-foundation.d.ts +7 -7
  159. package/dist/toast/toast-list-foundation.js +14 -14
  160. package/dist/tooltip/foundation.d.ts +9 -9
  161. package/dist/tooltip/foundation.js +67 -61
  162. package/dist/transfer/foundation.d.ts +22 -9
  163. package/dist/transfer/foundation.js +38 -23
  164. package/dist/tree/foundation.d.ts +14 -14
  165. package/dist/tree/foundation.js +61 -61
  166. package/dist/tree/shared.d.ts +1 -1
  167. package/dist/tree-select/foundation.d.ts +26 -20
  168. package/dist/tree-select/foundation.js +91 -83
  169. package/dist/typography/ellipsis.d.ts +4 -4
  170. package/dist/typography/ellipsis.js +8 -8
  171. package/dist/typography/format-numeral.d.ts +1 -1
  172. package/dist/typography/format-numeral.js +2 -2
  173. package/dist/upload/constants.d.ts +1 -1
  174. package/dist/upload/foundation.d.ts +17 -17
  175. package/dist/upload/foundation.js +92 -92
  176. package/dist/upload/utils.d.ts +3 -3
  177. package/dist/upload/utils.js +6 -6
  178. package/dist/user-guide/foundation.d.ts +3 -3
  179. package/dist/user-guide/foundation.js +19 -19
  180. package/dist/utils/a11y.d.ts +1 -1
  181. package/dist/utils/announcer.d.ts +2 -2
  182. package/dist/utils/announcer.js +4 -4
  183. package/dist/utils/focus-handle.d.ts +1 -1
  184. package/dist/utils/focus-handle.js +1 -2
  185. package/dist/utils/focus-scope.d.ts +5 -5
  186. package/dist/utils/focus-scope.js +10 -10
  187. package/dist/utils/is-promise.d.ts +1 -1
  188. package/dist/utils/release-holder.d.ts +2 -2
  189. package/dist/utils/release-holder.js +4 -4
  190. package/dist/video-player/foundation.d.ts +15 -15
  191. package/dist/video-player/foundation.js +89 -89
  192. package/dist/video-player/progress-foundation.d.ts +2 -2
  193. package/dist/video-player/progress-foundation.js +12 -12
  194. package/package.json +2 -2
@@ -16,53 +16,38 @@ var SelectFoundation = class SelectFoundation extends BaseFoundation {
16
16
  return props.multiple ? SelectFoundation.#resolveMultiple(props, propValue, originalOptions, nowSelections) : SelectFoundation.#resolveSingle(props, propValue, originalOptions);
17
17
  }
18
18
  static #firstEnabledIndex(options) {
19
- return options.filter((option) => option._show).findIndex((option) => !option.disabled);
19
+ return options.filter((option) => option.show).findIndex((option) => !option.data.disabled);
20
20
  }
21
21
  static #markSelected({ allowCreate }, selections, options) {
22
22
  return options.map((option) => {
23
- if (selections.has(option.value)) {
24
- if (allowCreate) {
25
- const { _inputCreateOnly, ...rest } = option;
26
- return {
27
- ...rest,
28
- _selected: true
29
- };
30
- }
31
- return {
32
- ...option,
33
- _selected: true
34
- };
35
- }
36
- if (option._inputCreateOnly) return {
23
+ if (selections.has(option.data.value)) return allowCreate ? {
24
+ ...option,
25
+ selected: true,
26
+ create: false
27
+ } : {
37
28
  ...option,
38
- _show: false,
39
- _selected: false
29
+ selected: true
30
+ };
31
+ if (option.create) return {
32
+ ...option,
33
+ show: false,
34
+ selected: false
40
35
  };
41
36
  return {
42
37
  ...option,
43
- _selected: false
38
+ selected: false
44
39
  };
45
40
  });
46
41
  }
47
42
  static #resolveSingle({ onChangeWithObject }, propValue, originalOptions) {
48
43
  const selections = /* @__PURE__ */ new Map();
49
44
  const selectedValue = onChangeWithObject ? propValue?.value : propValue;
50
- const selectedOptions = originalOptions.filter((option) => option.value === selectedValue);
51
- const noMatchOptionInList = !selectedOptions.length && typeof selectedValue !== "undefined" && selectedValue !== null;
52
- if (selectedOptions.length) {
53
- const optionExist = { ...selectedOptions[0] };
54
- selections.set(optionExist.value, optionExist);
55
- } else if (noMatchOptionInList) {
56
- let optionNotExist = {
45
+ const selectedOption = originalOptions.find((option) => option.data.value === selectedValue);
46
+ if (selectedOption) selections.set(selectedValue, selectedOption.data);
47
+ else if (typeof selectedValue !== "undefined" && selectedValue !== null) {
48
+ const optionNotExist = onChangeWithObject ? { ...propValue } : {
57
49
  value: propValue,
58
- label: propValue,
59
- _notExist: true,
60
- _scrollIndex: -1
61
- };
62
- if (onChangeWithObject) optionNotExist = {
63
- ...propValue,
64
- _notExist: true,
65
- _scrollIndex: -1
50
+ label: propValue
66
51
  };
67
52
  selections.set(optionNotExist.value, optionNotExist);
68
53
  }
@@ -81,8 +66,8 @@ var SelectFoundation = class SelectFoundation extends BaseFoundation {
81
66
  selectedValues = selectedObjects.map((item) => item.value);
82
67
  }
83
68
  if (propValueIsArray && selectedValues.length) selectedValues.forEach((selectedValue, i) => {
84
- const index = originalOptions.findIndex((option) => option.value === selectedValue);
85
- if (index !== -1) selections.set(selectedValue, originalOptions[index]);
69
+ const record = originalOptions.find((option) => option.data.value === selectedValue);
70
+ if (record) selections.set(selectedValue, record.data);
86
71
  else {
87
72
  const indexInSelectedList = selectedOptionList.findIndex((option) => option.value === selectedValue);
88
73
  if (indexInSelectedList !== -1) {
@@ -91,32 +76,21 @@ var SelectFoundation = class SelectFoundation extends BaseFoundation {
91
76
  const optionCompare = { ...selectedObjects[i] };
92
77
  selections.set(selectedValue, isEqual(optionCompare, option) ? option : optionCompare);
93
78
  } else selections.set(selectedValue, option);
94
- } else {
95
- let optionNotExist = {
96
- value: selectedValue,
97
- label: selectedValue,
98
- _notExist: true
99
- };
100
- if (onChangeWithObject) optionNotExist = {
101
- ...selectedObjects[i],
102
- _notExist: true
103
- };
104
- selections.set(selectedValue, {
105
- ...optionNotExist,
106
- _scrollIndex: -1
107
- });
108
- }
79
+ } else selections.set(selectedValue, onChangeWithObject ? { ...selectedObjects[i] } : {
80
+ value: selectedValue,
81
+ label: selectedValue
82
+ });
109
83
  }
110
84
  });
111
85
  return selections;
112
86
  }
113
87
  #focusTrigger() {
114
- this._adapter.focusTrigger();
88
+ this.adapter.focusTrigger();
115
89
  }
116
90
  #update(propValue, originalOptions) {
117
91
  const selections = SelectFoundation.#resolveSelections(this.getProps(), propValue, originalOptions, this.getState("selections"));
118
92
  if (this.#isMultiple()) this.updateOverflowItemCount(selections.size);
119
- this._adapter.updateSelection(selections);
93
+ this.adapter.updateSelection(selections);
120
94
  this.#updateOptionsActiveStatus(selections, originalOptions);
121
95
  }
122
96
  #isMultiple() {
@@ -128,19 +102,11 @@ var SelectFoundation = class SelectFoundation extends BaseFoundation {
128
102
  #isFilterable() {
129
103
  return Boolean(this.getProp("filter"));
130
104
  }
131
- #handleSingleSelect({ value, label, ...rest }, event) {
132
- const selections = (/* @__PURE__ */ new Map()).set(value, {
133
- value,
134
- label,
135
- ...rest
136
- });
137
- this.#notifySelect(value, {
138
- value,
139
- label,
140
- ...rest
141
- });
105
+ #handleSingleSelect(option, event) {
106
+ const selections = (/* @__PURE__ */ new Map()).set(option.value, option);
107
+ this.adapter.notifySelect(option.value, option);
142
108
  const isFilterable = this.#isFilterable();
143
- if (this._isControlledComponent()) this.close({
109
+ if (this.isControlledComponent()) this.close({
144
110
  event,
145
111
  notToggleInput: true,
146
112
  closeCb: () => {
@@ -150,7 +116,7 @@ var SelectFoundation = class SelectFoundation extends BaseFoundation {
150
116
  });
151
117
  else {
152
118
  this.#notifyChange(selections);
153
- this._adapter.updateSelection(selections);
119
+ this.adapter.updateSelection(selections);
154
120
  this.close({
155
121
  event,
156
122
  closeCb: () => {
@@ -159,37 +125,22 @@ var SelectFoundation = class SelectFoundation extends BaseFoundation {
159
125
  });
160
126
  }
161
127
  }
162
- #handleMultipleSelect({ value, label, ...rest }, event) {
163
- const maxLimit = this._adapter.getMaxLimit();
164
- const selections = this._adapter.getSelections();
128
+ #handleMultipleSelect(option, event) {
129
+ const { value } = option;
130
+ const maxLimit = this.adapter.getMaxLimit();
131
+ const selections = this.adapter.getSelections();
165
132
  const { autoClearSearchValue } = this.getProps();
166
133
  if (selections.has(value)) {
167
- this.#notifyDeselect(value, {
168
- value,
169
- label,
170
- ...rest
171
- });
134
+ this.adapter.notifyDeselect(value, option);
172
135
  selections.delete(value);
173
136
  } else if (maxLimit && selections.size >= maxLimit) {
174
- this._adapter.notifyMaxLimit(this.#removeInternalKey({
175
- value,
176
- label,
177
- ...rest
178
- }));
137
+ this.adapter.notifyMaxLimit(option);
179
138
  return;
180
139
  } else {
181
- this.#notifySelect(value, {
182
- value,
183
- label,
184
- ...rest
185
- });
186
- selections.set(value, {
187
- value,
188
- label,
189
- ...rest
190
- });
140
+ this.adapter.notifySelect(value, option);
141
+ selections.set(value, option);
191
142
  }
192
- if (this._isControlledComponent()) {
143
+ if (this.isControlledComponent()) {
193
144
  this.#notifyChange(selections);
194
145
  if (this.#isFilterable()) {
195
146
  if (autoClearSearchValue) this.clearInput(event);
@@ -197,7 +148,7 @@ var SelectFoundation = class SelectFoundation extends BaseFoundation {
197
148
  }
198
149
  } else {
199
150
  this.#notifyChange(selections);
200
- this._adapter.updateSelection(selections);
151
+ this.adapter.updateSelection(selections);
201
152
  this.updateOverflowItemCount(selections.size);
202
153
  let { options } = this.getStates();
203
154
  if (this.#isFilterable()) {
@@ -215,65 +166,69 @@ var SelectFoundation = class SelectFoundation extends BaseFoundation {
215
166
  if (!filter) return originalOptions;
216
167
  else if (typeof filter === "function") return originalOptions.map((option) => ({
217
168
  ...option,
218
- _show: Boolean(filter(sugInput, option))
169
+ show: Boolean(filter(sugInput, option.data))
219
170
  }));
220
171
  const input = sugInput.toLowerCase();
221
172
  return originalOptions.map((option) => {
222
- const label = option.label ?? option.value;
173
+ const label = option.data.label ?? option.data.value;
223
174
  const text = typeof label === "string" || typeof label === "number" ? String(label).toLowerCase() : "";
224
- const groupLabel = option._parentGroup && option._parentGroup.label;
175
+ const groupLabel = option.group?.label;
225
176
  const matchOption = text.includes(input);
226
177
  const matchGroup = (typeof groupLabel === "string" || typeof groupLabel === "number") && String(groupLabel).toLowerCase().includes(input);
227
178
  return {
228
179
  ...option,
229
- _show: matchOption || matchGroup
180
+ show: matchOption || matchGroup
230
181
  };
231
182
  });
232
183
  }
233
184
  #createOptionByInput(allowCreate, optionsAfterFilter, sugInput) {
234
185
  if (allowCreate) {
235
186
  if (sugInput) {
236
- const newOptionByInput = {
237
- _show: true,
238
- _selected: false,
239
- value: sugInput,
240
- label: sugInput,
241
- _inputCreateOnly: true
242
- };
243
187
  let createOptionIndex = -1;
244
188
  let matchOptionIndex = -1;
245
189
  optionsAfterFilter = optionsAfterFilter.map((option, index) => {
246
- if (!option._show && !option._inputCreateOnly) return option;
247
- if (option.label === sugInput) matchOptionIndex = index;
248
- if (option._inputCreateOnly) {
190
+ if (!option.show && !option.create) return option;
191
+ if (option.data.label === sugInput) matchOptionIndex = index;
192
+ if (option.create) {
249
193
  createOptionIndex = index;
250
194
  return {
251
195
  ...option,
252
- value: sugInput,
253
- label: sugInput,
254
- _show: true
196
+ data: {
197
+ value: sugInput,
198
+ label: sugInput
199
+ },
200
+ show: true
255
201
  };
256
202
  }
257
203
  return option;
258
204
  });
259
- if (createOptionIndex === -1 && matchOptionIndex === -1) optionsAfterFilter = [...optionsAfterFilter, newOptionByInput];
260
- if (matchOptionIndex !== -1) optionsAfterFilter = optionsAfterFilter.filter((item) => !item._inputCreateOnly);
261
- } else optionsAfterFilter = optionsAfterFilter.filter((item) => !item._inputCreateOnly);
205
+ if (createOptionIndex === -1 && matchOptionIndex === -1) optionsAfterFilter = [...optionsAfterFilter, {
206
+ data: {
207
+ value: sugInput,
208
+ label: sugInput
209
+ },
210
+ index: -1,
211
+ show: true,
212
+ selected: false,
213
+ create: true
214
+ }];
215
+ if (matchOptionIndex !== -1) optionsAfterFilter = optionsAfterFilter.filter((item) => !item.create);
216
+ } else optionsAfterFilter = optionsAfterFilter.filter((item) => !item.create);
262
217
  }
263
218
  return optionsAfterFilter;
264
219
  }
265
220
  #setFocusIndex(index) {
266
- this._adapter.updateFocusIndex(index);
267
- if (index !== -1) this._adapter.updateScrollTop(index);
221
+ this.adapter.updateFocusIndex(index);
222
+ if (index !== -1) this.adapter.updateScrollTop(index);
268
223
  }
269
224
  #moveFocus(offset) {
270
225
  const { focusIndex, options } = this.getStates();
271
- const visibleOptions = options.filter((item) => item._show);
272
- this.#setFocusIndex(getEnabledStepIndex(offset, focusIndex, visibleOptions.length, (i) => visibleOptions[i].disabled));
226
+ const visibleOptions = options.filter((item) => item.show);
227
+ this.#setFocusIndex(getEnabledStepIndex(offset, focusIndex, visibleOptions.length, (i) => visibleOptions[i].data.disabled));
273
228
  }
274
229
  #selectedIndex(options) {
275
230
  const selections = this.getState("selections");
276
- return options.filter((option) => option._show).findIndex((option) => selections.has(option.value));
231
+ return options.filter((option) => option.show).findIndex((option) => selections.has(option.data.value));
277
232
  }
278
233
  #focusSelectedOption(options) {
279
234
  const index = this.#selectedIndex(options);
@@ -298,15 +253,15 @@ var SelectFoundation = class SelectFoundation extends BaseFoundation {
298
253
  }
299
254
  if (!wasOpen) this.open();
300
255
  const { focusIndex, options } = this.getStates();
301
- const visibleOptions = options.filter((option) => option._show);
256
+ const visibleOptions = options.filter((option) => option.show);
302
257
  let index;
303
258
  if (isTypeahead) {
304
- const labels = visibleOptions.map((option) => {
305
- const label = option.label ?? option.value;
306
- return !option.disabled && (typeof label === "string" || typeof label === "number") ? String(label) : "";
259
+ const labels = visibleOptions.map(({ data }) => {
260
+ const label = data.label ?? data.value;
261
+ return !data.disabled && (typeof label === "string" || typeof label === "number") ? String(label) : "";
307
262
  });
308
263
  index = this.#typeahead.match(key, labels, focusIndex);
309
- } else index = getListTargetIndex(key, focusIndex, visibleOptions.length, (i) => visibleOptions[i].disabled);
264
+ } else index = getListTargetIndex(key, focusIndex, visibleOptions.length, (i) => visibleOptions[i].data.disabled);
310
265
  if (index !== null && index !== -1) this.#setFocusIndex(index);
311
266
  return true;
312
267
  }
@@ -318,7 +273,7 @@ var SelectFoundation = class SelectFoundation extends BaseFoundation {
318
273
  #handleTabKeyDown(event) {
319
274
  const { isOpen } = this.getStates();
320
275
  if (isOpen) {
321
- const focusableElements = FocusTrapHandle.getFocusableElements(this._adapter.getOptionList());
276
+ const focusableElements = FocusTrapHandle.getFocusableElements(this.adapter.getOptionList());
322
277
  if (focusableElements.length > 0) {
323
278
  if (event.shiftKey) this.#handlePanelOpenShiftTabKeyDown(focusableElements, event);
324
279
  else this.#handlePanelOpenTabKeyDown(focusableElements, event);
@@ -326,13 +281,13 @@ var SelectFoundation = class SelectFoundation extends BaseFoundation {
326
281
  }
327
282
  }
328
283
  #getActiveElement() {
329
- return FocusTrapHandle.getActiveElement(this._adapter.getOptionList());
284
+ return FocusTrapHandle.getActiveElement(this.adapter.getOptionList());
330
285
  }
331
286
  #handlePanelOpenTabKeyDown(focusableElements, event) {
332
287
  const activeElement = this.#getActiveElement();
333
- if (!this._adapter.getIsFocusInContainer()) {
288
+ if (!this.adapter.getIsFocusInContainer()) {
334
289
  focusableElements[0].focus();
335
- this._adapter.setIsFocusInContainer(true);
290
+ this.adapter.setIsFocusInContainer(true);
336
291
  handlePrevent(event);
337
292
  } else if (activeElement === focusableElements.at(-1)) {
338
293
  this.#focusTrigger();
@@ -342,10 +297,10 @@ var SelectFoundation = class SelectFoundation extends BaseFoundation {
342
297
  }
343
298
  #handlePanelOpenShiftTabKeyDown(focusableElements, event) {
344
299
  const activeElement = this.#getActiveElement();
345
- if (!this._adapter.getIsFocusInContainer()) this.close({ event });
300
+ if (!this.adapter.getIsFocusInContainer()) this.close({ event });
346
301
  else if (activeElement === focusableElements[0]) {
347
302
  this.#focusTrigger();
348
- this._adapter.setIsFocusInContainer(false);
303
+ this.adapter.setIsFocusInContainer(false);
349
304
  handlePrevent(event);
350
305
  }
351
306
  }
@@ -353,19 +308,19 @@ var SelectFoundation = class SelectFoundation extends BaseFoundation {
353
308
  const { isOpen, options, focusIndex } = this.getStates();
354
309
  if (!isOpen) this.open();
355
310
  else if (focusIndex !== -1) {
356
- const visibleOptions = options.filter((item) => item._show);
311
+ const visibleOptions = options.filter((item) => item.show);
357
312
  const { length } = visibleOptions;
358
313
  if (length <= focusIndex) return;
359
314
  if (visibleOptions && length) {
360
315
  const selectedOption = visibleOptions[focusIndex];
361
- if (selectedOption.disabled) return;
316
+ if (selectedOption.data.disabled) return;
362
317
  this.onSelect(selectedOption, focusIndex, event);
363
318
  }
364
319
  } else this.close({ event });
365
320
  }
366
321
  #handleBackspaceKeyDown() {
367
322
  if (this.#isMultiple()) {
368
- const selections = this._adapter.getSelections();
323
+ const selections = this.adapter.getSelections();
369
324
  const { inputValue } = this.getStates();
370
325
  const length = selections.size;
371
326
  if (length && !inputValue) {
@@ -392,27 +347,8 @@ var SelectFoundation = class SelectFoundation extends BaseFoundation {
392
347
  const isMultiple = this.#isMultiple();
393
348
  if (!this.#diffSelections(selections, stateSelections, isMultiple)) return;
394
349
  if (onChangeWithObject) this.#notifyChangeWithObject(selections);
395
- else if (isMultiple) this._adapter.notifyChange(selectionsProps.map((props) => props.value));
396
- else this._adapter.notifyChange(selectionsProps[0]?.value);
397
- }
398
- #removeInternalKey(option) {
399
- let newOption = { ...option };
400
- delete newOption._parentGroup;
401
- delete newOption._show;
402
- delete newOption._selected;
403
- delete newOption._scrollIndex;
404
- delete newOption._keyInJsx;
405
- delete newOption._inputCreateOnly;
406
- delete newOption._notExist;
407
- return newOption;
408
- }
409
- #notifySelect(value, option) {
410
- const newOption = this.#removeInternalKey(option);
411
- this._adapter.notifySelect(value, newOption);
412
- }
413
- #notifyDeselect(value, option) {
414
- const newOption = this.#removeInternalKey(option);
415
- this._adapter.notifyDeselect(value, newOption);
350
+ else if (isMultiple) this.adapter.notifyChange(selectionsProps.map((props) => props.value));
351
+ else this.adapter.notifyChange(selectionsProps[0]?.value);
416
352
  }
417
353
  #diffSelections(selections, oldSelections, isMultiple) {
418
354
  if (isMultiple) return !isEqual([...selections.keys()], [...oldSelections.keys()]);
@@ -421,32 +357,31 @@ var SelectFoundation = class SelectFoundation extends BaseFoundation {
421
357
  return !isEqual(option?.value, oldOption?.value) || !isEqual(option?.label, oldOption?.label);
422
358
  }
423
359
  #notifyChangeWithObject(selections) {
424
- const values = [];
425
- for (const item of selections.values()) values.push(this.#removeInternalKey(item));
426
- if (!this.#isMultiple()) this._adapter.notifyChange(values[0]);
427
- else this._adapter.notifyChange(values);
360
+ const values = [...selections.values()];
361
+ if (!this.#isMultiple()) this.adapter.notifyChange(values[0]);
362
+ else this.adapter.notifyChange(values);
428
363
  }
429
364
  #notifyBlur(e) {
430
365
  this.#blurPending = false;
431
- this._adapter.notifyBlur(e);
366
+ this.adapter.notifyBlur(e);
432
367
  }
433
368
  #notifyFocus(e) {
434
369
  if (!this.#blurPending && !this.#isDisabled()) {
435
370
  this.#blurPending = true;
436
- this._adapter.notifyFocus(e);
371
+ this.adapter.notifyFocus(e);
437
372
  }
438
373
  }
439
374
  #toggle2SearchInput(isShow) {
440
- if (isShow) this._adapter.toggleInputShow(isShow, () => this.#focusInput());
441
- else this._adapter.toggleInputShow(isShow, () => void 0);
375
+ if (isShow) this.adapter.toggleInputShow(isShow, () => this.#focusInput());
376
+ else this.adapter.toggleInputShow(isShow, () => void 0);
442
377
  }
443
378
  #updateOptionsActiveStatus(selections, options = this.getState("options")) {
444
- this._adapter.updateOptions(SelectFoundation.#markSelected(this.getProps(), selections, options));
379
+ this.adapter.updateOptions(SelectFoundation.#markSelected(this.getProps(), selections, options));
445
380
  }
446
381
  #focusInput() {
447
- this._adapter.focusInput();
448
- this._adapter.updateFocusState(true);
449
- this._adapter.setIsFocusInContainer(false);
382
+ this.adapter.focusInput();
383
+ this.adapter.updateFocusState(true);
384
+ this.adapter.setIsFocusInContainer(false);
450
385
  }
451
386
  #filterByKeyword(options) {
452
387
  const { inputValue } = this.getStates();
@@ -454,34 +389,34 @@ var SelectFoundation = class SelectFoundation extends BaseFoundation {
454
389
  }
455
390
  #handleOptionListChange() {
456
391
  const { focusIndex, options } = this.getStates();
457
- const focusedOption = options.filter((option) => option._show)[focusIndex];
458
- const newOptionList = this.#filterByKeyword(this._adapter.getOptionsFromChildren());
392
+ const focusedOption = options.filter((option) => option.show)[focusIndex];
393
+ const newOptionList = this.#filterByKeyword(this.adapter.getOptionsFromChildren());
459
394
  this.#updateOptionsActiveStatus(this.getState("selections"), newOptionList);
460
- const keptIndex = focusedOption ? newOptionList.filter((option) => option._show).findIndex((option) => option.value === focusedOption.value) : -1;
395
+ const keptIndex = focusedOption ? newOptionList.filter((option) => option.show).findIndex((option) => option.data.value === focusedOption.data.value) : -1;
461
396
  if (keptIndex !== -1) {
462
- this._adapter.updateFocusIndex(keptIndex);
397
+ this.adapter.updateFocusIndex(keptIndex);
463
398
  return;
464
399
  }
465
400
  const selectedIndex = this.#selectedIndex(newOptionList);
466
401
  if (selectedIndex === -1 && !this.getProp("defaultActiveFirstOption")) return;
467
402
  const index = selectedIndex !== -1 ? selectedIndex : SelectFoundation.#firstEnabledIndex(newOptionList);
468
403
  if (focusedOption) this.#setFocusIndex(index);
469
- else this._adapter.updateFocusIndex(index);
404
+ else this.adapter.updateFocusIndex(index);
470
405
  }
471
406
  #handleOptionListChangeHadDefaultValue() {
472
407
  const { onChangeWithObject } = this.getProps();
473
408
  const items = [...this.getState("selections").values()].map((item) => onChangeWithObject ? item : item.value);
474
409
  const value = this.#isMultiple() ? items : items[0];
475
- this.#update(value, this.#filterByKeyword(this._adapter.getOptionsFromChildren()));
410
+ this.#update(value, this.#filterByKeyword(this.adapter.getOptionsFromChildren()));
476
411
  }
477
412
  #handleValueChange(value) {
478
413
  const { allowCreate } = this.getProps();
479
414
  let originalOptions;
480
- if (allowCreate && this._isControlledComponent()) originalOptions = this.getState("options").map((item) => ({
415
+ if (allowCreate && this.isControlledComponent()) originalOptions = this.getState("options").map((item) => ({
481
416
  ...item,
482
- _show: true
417
+ show: true
483
418
  }));
484
- else originalOptions = this._adapter.getOptionsFromChildren();
419
+ else originalOptions = this.adapter.getOptionsFromChildren();
485
420
  this.#update(value, this.#filterByKeyword(originalOptions));
486
421
  }
487
422
  /** `options` is the host's option list from optionList or the option children */
@@ -502,14 +437,14 @@ var SelectFoundation = class SelectFoundation extends BaseFoundation {
502
437
  if (this.getProp("defaultOpen") && !this.#isDisabled()) this.open();
503
438
  if (this.getProp("autoFocus") && !this.#isDisabled()) this.focus();
504
439
  }
505
- focus(optionsForOpen, openDropdown) {
440
+ focus = (optionsForOpen, openDropdown) => {
506
441
  const isFilterable = this.#isFilterable();
507
442
  const isMultiple = this.#isMultiple();
508
443
  const { isOpen } = this.getStates();
509
444
  const { searchPosition } = this.getProps();
510
445
  const shouldOpenDropdown = openDropdown !== false;
511
- this._adapter.updateFocusState(true);
512
- this._adapter.setIsFocusInContainer(false);
446
+ this.adapter.updateFocusState(true);
447
+ this.adapter.setIsFocusInContainer(false);
513
448
  if (isFilterable) {
514
449
  /**
515
450
  * openDropdown false only refocuses the Select. With searchPosition='dropdown' the search input lives in
@@ -530,117 +465,117 @@ var SelectFoundation = class SelectFoundation extends BaseFoundation {
530
465
  if (!isOpen) this.open(void 0, optionsForOpen);
531
466
  }
532
467
  } else this.#focusTrigger();
533
- }
468
+ };
534
469
  /** After an update, the host reports whether the options (optionList or children) and value changed by its own change detection */
535
- handleInputsChange({ optionsChanged, valueChanged }, value) {
470
+ handleInputsChange = ({ optionsChanged, valueChanged }, value) => {
536
471
  if (optionsChanged) this.#handleOptionListChange();
537
472
  if (valueChanged || optionsChanged && value !== void 0) this.#handleValueChange(value);
538
473
  else if (optionsChanged) this.#handleOptionListChangeHadDefaultValue();
539
- }
540
- handleClick(e) {
474
+ };
475
+ handleClick = (e) => {
541
476
  const { clickToHide } = this.getProps();
542
477
  const { isOpen } = this.getStates();
543
478
  if (this.#isDisabled() || isInnerControlActivation(e)) return;
544
479
  else if (!isOpen) this.open();
545
480
  else if (isOpen && clickToHide) this.close({ event: e });
546
481
  else if (isOpen && !clickToHide) this.#focusInput();
547
- }
548
- open(_acInput, originalOptions) {
482
+ };
483
+ open = (_acInput, originalOptions) => {
549
484
  this.#events.emit("popoverClose");
550
485
  const isFilterable = this.#isFilterable();
551
486
  let options = originalOptions || this.getState("options");
552
487
  if (isFilterable) {
553
- options = this.#filterOption(options, "").filter((item) => !item._inputCreateOnly);
554
- this._adapter.updateOptions(options);
488
+ options = this.#filterOption(options, "").filter((item) => !item.create);
489
+ this.adapter.updateOptions(options);
555
490
  this.#toggle2SearchInput(true);
556
- } else this._adapter.updateFocusState(true);
491
+ } else this.adapter.updateFocusState(true);
557
492
  this.#focusSelectedOption(options);
558
- this._adapter.openMenu(() => {
493
+ this.adapter.openMenu(() => {
559
494
  const { searchPosition, autoFocus } = this.getProps();
560
- if (autoFocus && searchPosition === strings.SEARCH_POSITION_DROPDOWN) this._adapter.focusDropdownInput();
495
+ if (autoFocus && searchPosition === strings.SEARCH_POSITION_DROPDOWN) this.adapter.focusDropdownInput();
561
496
  });
562
- this._adapter.notifyDropdownVisibleChange(true);
563
- }
564
- handleClickOutside(e) {
497
+ this.adapter.notifyDropdownVisibleChange(true);
498
+ };
499
+ handleClickOutside = (e) => {
565
500
  this.close({
566
501
  event: e,
567
502
  returnFocus: false
568
503
  });
569
504
  if (this.#blurPending) this.#notifyBlur(e);
570
- this._adapter.updateFocusState(false);
571
- }
572
- close(closeConfig) {
505
+ this.adapter.updateFocusState(false);
506
+ };
507
+ close = (closeConfig) => {
573
508
  const { isFocus, isOpen } = this.getStates();
574
509
  if (!isOpen) return;
575
510
  const { event, closeCb, notToggleInput, returnFocus = true } = closeConfig || {};
576
511
  if (isFocus && returnFocus) this.#focusTrigger();
577
- this._adapter.closeMenu();
578
- this._adapter.notifyDropdownVisibleChange(false);
579
- this._adapter.setIsFocusInContainer(false);
512
+ this.adapter.closeMenu();
513
+ this.adapter.notifyDropdownVisibleChange(false);
514
+ this.adapter.setIsFocusInContainer(false);
580
515
  const isFilterable = this.#isFilterable();
581
516
  if (isFilterable && !notToggleInput) this.#toggle2SearchInput(false);
582
517
  this.#events.once("popoverClose", () => {
583
518
  if (isFilterable) this.clearInput(event);
584
519
  if (closeCb) closeCb();
585
520
  });
586
- }
587
- onSelect(option, optionIndex, event) {
521
+ };
522
+ onSelect = (option, optionIndex, event) => {
588
523
  if (this.#isDisabled()) return;
589
- if (option._inputCreateOnly) this._adapter.notifyCreate(this.#removeInternalKey(option));
590
- if (!this.#isMultiple()) this.#handleSingleSelect(option, event);
591
- else this.#handleMultipleSelect(option, event);
592
- this._adapter.updateFocusIndex(optionIndex);
593
- }
594
- clearSelected() {
524
+ if (option.create) this.adapter.notifyCreate(option.data);
525
+ if (!this.#isMultiple()) this.#handleSingleSelect(option.data, event);
526
+ else this.#handleMultipleSelect(option.data, event);
527
+ this.adapter.updateFocusIndex(optionIndex);
528
+ };
529
+ clearSelected = () => {
595
530
  const selections = /* @__PURE__ */ new Map();
596
- if (this._isControlledComponent()) {
531
+ if (this.isControlledComponent()) {
597
532
  this.#notifyChange(selections);
598
- this._adapter.notifyClear();
533
+ this.adapter.notifyClear();
599
534
  } else {
600
535
  this.#notifyChange(selections);
601
- this._adapter.updateSelection(selections);
536
+ this.adapter.updateSelection(selections);
602
537
  this.#updateOptionsActiveStatus(selections);
603
- this._adapter.notifyClear();
538
+ this.adapter.notifyClear();
604
539
  }
605
- }
606
- removeTag(item) {
607
- const selections = this._adapter.getSelections();
540
+ };
541
+ removeTag = (item) => {
542
+ const selections = this.adapter.getSelections();
608
543
  selections.delete(item.value);
609
- if (this._isControlledComponent()) {
610
- this.#notifyDeselect(item.value, item);
544
+ if (this.isControlledComponent()) {
545
+ this.adapter.notifyDeselect(item.value, item);
611
546
  this.#notifyChange(selections);
612
547
  } else {
613
- this.#notifyDeselect(item.value, item);
548
+ this.adapter.notifyDeselect(item.value, item);
614
549
  this.#notifyChange(selections);
615
- this._adapter.updateSelection(selections);
550
+ this.adapter.updateSelection(selections);
616
551
  this.updateOverflowItemCount(selections.size);
617
552
  this.#updateOptionsActiveStatus(selections);
618
553
  }
619
- }
620
- clearInput(event) {
554
+ };
555
+ clearInput = (event) => {
621
556
  const { inputValue } = this.getStates();
622
557
  if (inputValue !== "") {
623
- this._adapter.updateInputValue("");
624
- this._adapter.notifySearch("", event);
558
+ this.adapter.updateInputValue("");
559
+ this.adapter.notifySearch("", event);
625
560
  const { options } = this.getStates();
626
561
  const { remote } = this.getProps();
627
562
  let optionsAfterFilter = options;
628
563
  if (!remote) optionsAfterFilter = this.#filterOption(options, "");
629
- this._adapter.updateOptions(optionsAfterFilter);
564
+ this.adapter.updateOptions(optionsAfterFilter);
630
565
  }
631
- }
632
- handleInputChange(sugInput, event) {
633
- this._adapter.updateInputValue(sugInput);
566
+ };
567
+ handleInputChange = (sugInput, event) => {
568
+ this.adapter.updateInputValue(sugInput);
634
569
  const { options } = this.getStates();
635
570
  const { allowCreate, remote } = this.getProps();
636
571
  let optionsAfterFilter = options;
637
572
  if (!remote) optionsAfterFilter = this.#filterOption(options, sugInput);
638
573
  optionsAfterFilter = this.#createOptionByInput(allowCreate, optionsAfterFilter, sugInput);
639
- this._adapter.updateOptions(optionsAfterFilter);
574
+ this.adapter.updateOptions(optionsAfterFilter);
640
575
  this.#setFocusIndex(this.getProp("defaultActiveFirstOption") ? SelectFoundation.#firstEnabledIndex(optionsAfterFilter) : -1);
641
- this._adapter.notifySearch(sugInput, event);
642
- }
643
- handleKeyDown(event) {
576
+ this.adapter.notifySearch(sugInput, event);
577
+ };
578
+ handleKeyDown = (event) => {
644
579
  const { loading, filter, multiple, disabled, searchPosition } = this.getProps();
645
580
  const { isOpen } = this.getStates();
646
581
  if (loading || disabled || isComposing(event) || isInnerControlKey(event)) return;
@@ -670,8 +605,8 @@ var SelectFoundation = class SelectFoundation extends BaseFoundation {
670
605
  break;
671
606
  case "Tab": this.#handleTabKeyDown(event);
672
607
  }
673
- }
674
- handleContainerKeyDown(event) {
608
+ };
609
+ handleContainerKeyDown = (event) => {
675
610
  if (!this.getStates().isOpen || isComposing(event)) return;
676
611
  if (event.key === "Tab") this.#handleTabKeyDown(event);
677
612
  else if (event.key === "Escape") {
@@ -679,97 +614,97 @@ var SelectFoundation = class SelectFoundation extends BaseFoundation {
679
614
  this.#focusTrigger();
680
615
  this.close({ event });
681
616
  }
682
- }
683
- handleMouseEnter(e) {
684
- this._adapter.notifyMouseEnter(e);
685
- }
686
- handleMouseLeave(e) {
687
- this._adapter.notifyMouseLeave(e);
688
- }
689
- handleClearClick(e) {
617
+ };
618
+ handleMouseEnter = (e) => {
619
+ this.adapter.notifyMouseEnter(e);
620
+ };
621
+ handleMouseLeave = (e) => {
622
+ this.adapter.notifyMouseLeave(e);
623
+ };
624
+ handleClearClick = (e) => {
690
625
  const { filter, searchPosition } = this.getProps();
691
626
  if (filter && searchPosition === strings.SEARCH_POSITION_TRIGGER) this.clearInput(e);
692
627
  this.focus(void 0, false);
693
628
  this.clearSelected();
694
629
  e?.stopPropagation();
695
- }
696
- handleOptionMouseEnter(optionIndex) {
697
- this._adapter.updateFocusIndex(optionIndex);
698
- }
699
- handleListScroll(e) {
700
- this._adapter.notifyListScroll(e);
701
- }
702
- handleTriggerFocus(e) {
703
- this._adapter.setIsFocusInContainer(false);
630
+ };
631
+ handleOptionMouseEnter = (optionIndex) => {
632
+ this.adapter.updateFocusIndex(optionIndex);
633
+ };
634
+ handleListScroll = (e) => {
635
+ this.adapter.notifyListScroll(e);
636
+ };
637
+ handleTriggerFocus = (e) => {
638
+ this.adapter.setIsFocusInContainer(false);
704
639
  this.#notifyFocus(e);
705
- }
706
- handleTriggerBlur(e) {
640
+ };
641
+ handleTriggerBlur = (e) => {
707
642
  const { isOpen } = this.getStates();
708
643
  if (this.#blurPending && !isOpen) {
709
644
  this.#notifyBlur(e);
710
- this._adapter.updateFocusState(false);
645
+ this.adapter.updateFocusState(false);
711
646
  }
712
- }
713
- handleInputFocus(e) {
647
+ };
648
+ handleInputFocus = (e) => {
714
649
  this.#notifyFocus(e);
715
- if (this.#isMultiple() && this.#isFilterable()) this._adapter.updateFocusState(true);
716
- }
717
- handleInputBlur() {
650
+ if (this.#isMultiple() && this.#isFilterable()) this.adapter.updateFocusState(true);
651
+ };
652
+ handleInputBlur = () => {
718
653
  const { filter, autoFocus } = this.getProps();
719
654
  const { showInput, isOpen } = this.getStates();
720
655
  const isMultiple = this.#isMultiple();
721
656
  if (filter && !isMultiple) {
722
657
  if ((showInput || autoFocus) && !isOpen) this.#toggle2SearchInput(false);
723
658
  }
724
- }
725
- selectAll() {
659
+ };
660
+ selectAll = () => {
726
661
  if (!this.#isMultiple()) {
727
662
  console.warn(`[Semi Select]: It seems that you have called the selectAll method in the single-selection Select.
728
663
  Please note that this is not a legal way to use it`);
729
664
  return;
730
665
  }
731
666
  const { options } = this.getStates();
732
- const maxLimit = this._adapter.getMaxLimit();
733
- const selections = this._adapter.getSelections();
667
+ const maxLimit = this.adapter.getMaxLimit();
668
+ const selections = this.adapter.getSelections();
734
669
  const sizeBefore = selections.size;
735
- for (const option of options) {
736
- if (!option._show || option.disabled || option._inputCreateOnly || selections.has(option.value)) continue;
670
+ for (const { data, show, create } of options) {
671
+ if (!show || data.disabled || create || selections.has(data.value)) continue;
737
672
  if (maxLimit && selections.size >= maxLimit) {
738
- this._adapter.notifyMaxLimit(this.#removeInternalKey(option));
673
+ this.adapter.notifyMaxLimit(data);
739
674
  break;
740
675
  }
741
- selections.set(option.value, option);
676
+ selections.set(data.value, data);
742
677
  }
743
678
  if (selections.size === sizeBefore) return;
744
679
  this.#notifyChange(selections);
745
- if (!this._isControlledComponent()) {
746
- this._adapter.updateSelection(selections);
680
+ if (!this.isControlledComponent()) {
681
+ this.adapter.updateSelection(selections);
747
682
  this.updateOverflowItemCount(selections.size);
748
683
  this.#updateOptionsActiveStatus(selections);
749
684
  }
750
- }
751
- updateScrollTop() {
685
+ };
686
+ updateScrollTop = () => {
752
687
  const { focusIndex } = this.getStates();
753
- this._adapter.updateScrollTop(focusIndex === -1 ? void 0 : focusIndex);
754
- }
755
- updateOverflowItemCount(selectionLength, overFlowCount) {
688
+ this.adapter.updateScrollTop(focusIndex === -1 ? void 0 : focusIndex);
689
+ };
690
+ updateOverflowItemCount = (selectionLength, overFlowCount) => {
756
691
  const { maxTagCount, ellipsisTrigger } = this.getProps();
757
692
  if (!ellipsisTrigger) return;
758
- if (overFlowCount) this._adapter.updateOverflowItemCount(overFlowCount);
693
+ if (overFlowCount) this.adapter.updateOverflowItemCount(overFlowCount);
759
694
  else if (typeof maxTagCount === "number") {
760
- if (selectionLength - maxTagCount > 0) this._adapter.updateOverflowItemCount(selectionLength - maxTagCount);
761
- else this._adapter.updateOverflowItemCount(0);
695
+ if (selectionLength - maxTagCount > 0) this.adapter.updateOverflowItemCount(selectionLength - maxTagCount);
696
+ else this.adapter.updateOverflowItemCount(0);
762
697
  }
763
- }
764
- updateIsFullTags() {
698
+ };
699
+ updateIsFullTags = () => {
765
700
  const { isFullTags } = this.getStates();
766
- if (!isFullTags) this._adapter.setState({ isFullTags: true });
767
- }
768
- handlePopoverClose() {
701
+ if (!isFullTags) this.adapter.setState({ isFullTags: true });
702
+ };
703
+ handlePopoverClose = () => {
769
704
  this.#events.emit("popoverClose");
770
- }
771
- handleSlotMouseEnter() {
772
- this._adapter.updateFocusIndex(-1);
773
- }
705
+ };
706
+ handleSlotMouseEnter = () => {
707
+ this.adapter.updateFocusIndex(-1);
708
+ };
774
709
  };
775
710
  export { SelectFoundation as default };