@aurodesignsystem/auro-formkit 3.5.0-rc-627.2.1 → 4.0.0-rc-658.1

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 (53) hide show
  1. package/CHANGELOG.md +40 -1
  2. package/components/checkbox/README.md +1 -1
  3. package/components/checkbox/demo/api.min.js +1 -1
  4. package/components/checkbox/demo/index.min.js +1 -1
  5. package/components/checkbox/demo/readme.md +1 -1
  6. package/components/checkbox/dist/index.js +1 -1
  7. package/components/checkbox/dist/registered.js +1 -1
  8. package/components/combobox/README.md +1 -1
  9. package/components/combobox/demo/api.md +27 -27
  10. package/components/combobox/demo/api.min.js +63 -275
  11. package/components/combobox/demo/index.html +1 -0
  12. package/components/combobox/demo/index.min.js +61 -273
  13. package/components/combobox/demo/readme.md +1 -1
  14. package/components/combobox/dist/auro-combobox.d.ts +5 -10
  15. package/components/combobox/dist/index.js +22 -149
  16. package/components/combobox/dist/registered.js +22 -149
  17. package/components/counter/README.md +1 -1
  18. package/components/counter/demo/readme.md +1 -1
  19. package/components/datepicker/README.md +1 -1
  20. package/components/datepicker/demo/readme.md +1 -1
  21. package/components/dropdown/README.md +1 -1
  22. package/components/dropdown/demo/readme.md +1 -1
  23. package/components/form/README.md +1 -1
  24. package/components/form/demo/readme.md +1 -1
  25. package/components/input/README.md +1 -1
  26. package/components/input/demo/readme.md +1 -1
  27. package/components/menu/README.md +1 -1
  28. package/components/menu/demo/api.md +11 -11
  29. package/components/menu/demo/api.min.js +39 -124
  30. package/components/menu/demo/index.min.js +39 -124
  31. package/components/menu/demo/readme.md +1 -1
  32. package/components/menu/dist/auro-menu-utils.d.ts +0 -8
  33. package/components/menu/dist/auro-menu.d.ts +3 -8
  34. package/components/menu/dist/index.d.ts +1 -1
  35. package/components/menu/dist/index.js +40 -84
  36. package/components/menu/dist/registered.js +39 -124
  37. package/components/radio/README.md +1 -1
  38. package/components/radio/demo/api.md +8 -0
  39. package/components/radio/demo/api.min.js +13 -5
  40. package/components/radio/demo/index.min.js +13 -5
  41. package/components/radio/demo/readme.md +1 -1
  42. package/components/radio/dist/auro-radio.d.ts +4 -0
  43. package/components/radio/dist/index.js +13 -5
  44. package/components/radio/dist/registered.js +13 -5
  45. package/components/select/README.md +35 -35
  46. package/components/select/demo/api.md +32 -32
  47. package/components/select/demo/api.min.js +99 -199
  48. package/components/select/demo/index.min.js +97 -197
  49. package/components/select/demo/readme.md +1 -1
  50. package/components/select/dist/auro-select.d.ts +12 -13
  51. package/components/select/dist/index.js +57 -72
  52. package/components/select/dist/registered.js +57 -72
  53. package/package.json +1 -1
@@ -7,17 +7,17 @@ The auro-menu element provides users a way to select from a list of options.
7
7
 
8
8
  ## Properties
9
9
 
10
- | Property | Attribute | Type | Default | Description |
11
- |-------------------------|------------------|---------------------------------|-------------|--------------------------------------------------|
12
- | [disabled](#disabled) | `disabled` | `boolean` | | When true, the entire menu and all options are disabled; |
13
- | [hasLoadingPlaceholder](#hasLoadingPlaceholder) | | `boolean` | | Indicates whether the menu has a loadingIcon or loadingText to render when in a loading state. |
14
- | [loading](#loading) | `loading` | `boolean` | false | When true, displays a loading state using the loadingIcon and loadingText slots if provided. |
15
- | [matchWord](#matchWord) | `matchword` | `string` | "undefined" | Specifies a string used to highlight matched string parts in options. |
16
- | [multiSelect](#multiSelect) | `multiselect` | `boolean` | false | When true, the selected option can be multiple options. |
17
- | [noCheckmark](#noCheckmark) | `nocheckmark` | `boolean` | false | When true, selected option will not show the checkmark. |
18
- | [optionActive](#optionActive) | `optionactive` | `object` | "undefined" | Specifies the current active menuOption. |
19
- | [optionSelected](#optionSelected) | `optionSelected` | `Array<HTMLElement>\|undefined` | "undefined" | An array of currently selected menu options. In single-select mode, the array will contain only one HTMLElement. `undefined` when no options are selected. |
20
- | [value](#value) | `value` | `Array<string>\|undefined` | "undefined" | Value selected for the menu. `undefined` when no selection has been made, otherwise an array of strings. In single-select mode, the array will contain only one value. |
10
+ | Property | Attribute | Type | Default | Description |
11
+ |-------------------------|------------------|-----------------------------------|-------------|--------------------------------------------------|
12
+ | [disabled](#disabled) | `disabled` | `boolean` | | When true, the entire menu and all options are disabled; |
13
+ | [hasLoadingPlaceholder](#hasLoadingPlaceholder) | | `boolean` | | Indicates whether the menu has a loadingIcon or loadingText to render when in a loading state. |
14
+ | [loading](#loading) | `loading` | `boolean` | false | When true, displays a loading state using the loadingIcon and loadingText slots if provided. |
15
+ | [matchWord](#matchWord) | `matchword` | `string` | "undefined" | Specifies a string used to highlight matched string parts in options. |
16
+ | [multiSelect](#multiSelect) | `multiselect` | `boolean` | false | When true, the selected option can be multiple options. |
17
+ | [noCheckmark](#noCheckmark) | `nocheckmark` | `boolean` | false | When true, selected option will not show the checkmark. |
18
+ | [optionActive](#optionActive) | `optionactive` | `object` | "undefined" | Specifies the current active menuOption. |
19
+ | [optionSelected](#optionSelected) | `optionSelected` | `HTMLElement\|Array<HTMLElement>` | "undefined" | An array of currently selected menu options, type `HTMLElement` by default. In multi-select mode, `optionSelected` is an array of HTML elements. |
20
+ | [value](#value) | `value` | `String\|Array<string>` | "undefined" | Value selected for the menu, type `string` by default. In multi-select mode, `value` is an array of strings. |
21
21
 
22
22
  ## Methods
23
23
 
@@ -143,102 +143,6 @@ class AuroLibraryRuntimeUtils {
143
143
  // Copyright (c) 2021 Alaska Airlines. All right reserved. Licensed under the Apache-2.0 license
144
144
  // See LICENSE in the project root for license information.
145
145
 
146
- // ---------------------------------------------------------------------
147
-
148
- /**
149
- * Converts value to an array.
150
- * If the value is a JSON string representing an array, it will be parsed.
151
- * If the value is already an array, it is returned.
152
- * If the value is undefined, it returns undefined.
153
- * @private
154
- * @param {any} value - The value to be converted. Can be a string, array, or undefined.
155
- * @returns {Array|undefined} - The converted array or undefined.
156
- * @throws {Error} - Throws an error if the value is not an array, undefined,
157
- * or if the value cannot be parsed into an array from a JSON string.
158
- */
159
- function arrayConverter(value) {
160
- // Allow undefined
161
- if (value === undefined) {
162
- return undefined;
163
- }
164
-
165
- // Return the value if it is already an array
166
- if (Array.isArray(value)) {
167
- return value;
168
- }
169
-
170
- try {
171
- // If value is a JSON string, parse it
172
- const parsed = typeof value === 'string' ? JSON.parse(value) : value;
173
-
174
- // Check if the parsed value is an array
175
- if (Array.isArray(parsed)) {
176
- return parsed;
177
- }
178
- } catch (error) {
179
- // If JSON parsing fails, continue to throw an error below
180
- /* eslint-disable no-console */
181
- console.error('JSON parsing failed:', error);
182
- }
183
-
184
- // Throw error if the input is not an array or undefined
185
- throw new Error('Invalid value: Input must be an array or undefined');
186
- }
187
-
188
- /**
189
- * Compare two arrays for equality.
190
- * @private
191
- * @param {Array} arr1 - First array to compare.
192
- * @param {Array} arr2 - Second array to compare.
193
- * @returns {boolean} True if arrays are equal.
194
- */
195
- function arraysAreEqual(arr1, arr2) {
196
- // If both arrays undefined, they are equal (true)
197
- if (arr1 === undefined || arr2 === undefined) {
198
- return arr1 === arr2;
199
- }
200
-
201
- // If arrays have different lengths, they are not equal
202
- if (arr1.length !== arr2.length) {
203
- return false;
204
- }
205
-
206
- // If every item at each index is the same, return true
207
- for (let index = 0; index < arr1.length; index += 1) {
208
- if (arr1[index] !== arr2[index]) {
209
- return false;
210
- }
211
- }
212
- return true;
213
- }
214
-
215
- /**
216
- * Compares array for changes.
217
- * @private
218
- * @param {Array|any} newVal - New value to compare.
219
- * @param {Array|any} oldVal - Old value to compare.
220
- * @returns {boolean} True if arrays have changed.
221
- */
222
- function arrayOrUndefinedHasChanged(newVal, oldVal) {
223
- try {
224
- // Check if values are undefined or arrays
225
- const isArrayOrUndefined = (val) => val === undefined || Array.isArray(val);
226
-
227
- // If non-array or non-undefined, throw error
228
- if (!isArrayOrUndefined(newVal) || !isArrayOrUndefined(oldVal)) {
229
- const invalidValue = isArrayOrUndefined(newVal) ? oldVal : newVal;
230
- throw new Error(`Value must be an array or undefined, received ${typeof invalidValue}`);
231
- }
232
-
233
- // Return true if arrays have changed, false if they are the same
234
- return !arraysAreEqual(newVal, oldVal);
235
- } catch (error) {
236
- /* eslint-disable no-console */
237
- console.error(error);
238
- // If validation fails, it has changed
239
- return true;
240
- }
241
- }
242
146
 
243
147
  /**
244
148
  * Validates if an option can be interacted with.
@@ -272,7 +176,7 @@ function dispatchMenuEvent(element, eventName, detail = null) {
272
176
  element.dispatchEvent(new CustomEvent(eventName, eventConfig));
273
177
  }
274
178
 
275
- // Copyright (c) 2021 Alaska Airlines. All right reserved. Licensed under the Apache-2.0 license
179
+ // Copyright (c) 2025 Alaska Airlines. All right reserved. Licensed under the Apache-2.0 license
276
180
  // See LICENSE in the project root for license information.
277
181
 
278
182
 
@@ -280,14 +184,14 @@ function dispatchMenuEvent(element, eventName, detail = null) {
280
184
  // See https://git.io/JJ6SJ for "How to document your components using JSDoc"
281
185
  /**
282
186
  * The auro-menu element provides users a way to select from a list of options.
283
- * @attr {Array<HTMLElement>|undefined} optionSelected - An array of currently selected menu options. In single-select mode, the array will contain only one HTMLElement. `undefined` when no options are selected.
187
+ * @attr {HTMLElement|Array<HTMLElement>} optionSelected - An array of currently selected menu options, type `HTMLElement` by default. In multi-select mode, `optionSelected` is an array of HTML elements.
284
188
  * @attr {object} optionactive - Specifies the current active menuOption.
285
189
  * @attr {string} matchword - Specifies a string used to highlight matched string parts in options.
286
190
  * @attr {boolean} disabled - When true, the entire menu and all options are disabled;
287
191
  * @attr {boolean} nocheckmark - When true, selected option will not show the checkmark.
288
192
  * @attr {boolean} loading - When true, displays a loading state using the loadingIcon and loadingText slots if provided.
289
193
  * @attr {boolean} multiselect - When true, the selected option can be multiple options.
290
- * @attr {Array<string>|undefined} value - Value selected for the menu. `undefined` when no selection has been made, otherwise an array of strings. In single-select mode, the array will contain only one value.
194
+ * @attr {String|Array<string>} value - Value selected for the menu, type `string` by default. In multi-select mode, `value` is an array of strings.
291
195
  * @prop {boolean} hasLoadingPlaceholder - Indicates whether the menu has a loadingIcon or loadingText to render when in a loading state.
292
196
  * @event {CustomEvent<Element>} auroMenu-activatedOption - Notifies that a menuoption has been made `active`.
293
197
  * @event {CustomEvent<any>} auroMenu-customEventFired - Notifies that a custom event has been fired.
@@ -300,7 +204,7 @@ function dispatchMenuEvent(element, eventName, detail = null) {
300
204
  * @slot - Slot for insertion of menu options.
301
205
  */
302
206
 
303
- /* eslint-disable no-magic-numbers, max-lines */
207
+ /* eslint-disable no-magic-numbers, max-lines, no-extra-parens */
304
208
 
305
209
  class AuroMenu extends i$2 {
306
210
  constructor() {
@@ -380,9 +284,8 @@ class AuroMenu extends i$2 {
380
284
  reflect: true
381
285
  },
382
286
  optionSelected: {
383
- // Allow HTMLElement[] arrays and undefined
384
- converter: arrayConverter,
385
- hasChanged: arrayOrUndefinedHasChanged
287
+ // Allow HTMLElement, HTMLElement[] arrays and undefined
288
+ type: Object
386
289
  },
387
290
  optionActive: {
388
291
  type: Object,
@@ -398,10 +301,8 @@ class AuroMenu extends i$2 {
398
301
  attribute: 'multiselect'
399
302
  },
400
303
  value: {
401
- // Allow string[] arrays and undefined
402
- type: Object,
403
- converter: arrayConverter,
404
- hasChanged: arrayOrUndefinedHasChanged
304
+ // Allow string, string[] arrays and undefined
305
+ type: Object
405
306
  }
406
307
  };
407
308
  }
@@ -454,30 +355,39 @@ class AuroMenu extends i$2 {
454
355
  }
455
356
 
456
357
  updated(changedProperties) {
358
+ if (changedProperties.has('multiSelect')) {
359
+ // Reset selection if multiSelect mode changes
360
+ this.clearSelection();
361
+ }
362
+
457
363
  if (changedProperties.has('value')) {
458
364
  // Handle null/undefined case
459
365
  if (this.value === undefined || this.value === null) {
460
366
  this.optionSelected = undefined;
461
- // Reset index tracking
462
367
  this.index = -1;
463
368
  } else {
464
- // Convert single values to arrays
465
- const valueArray = Array.isArray(this.value) ? this.value : [this.value];
369
+ if (this.multiSelect) {
370
+ // In multiselect mode, this.value should be an array of strings
371
+ const valueArray = Array.isArray(this.value) ? this.value : [this.value];
372
+ const matchingOptions = this.items.filter((item) => valueArray.includes(item.value));
466
373
 
467
- // Find all matching options
468
- const matchingOptions = this.items.filter((item) => valueArray.includes(item.value));
374
+ this.optionSelected = matchingOptions.length > 0 ? matchingOptions : undefined;
375
+ } else {
376
+ // In single-select mode, this.value should be a string
377
+ const matchingOptions = this.items.find((item) => item.value === this.value);
469
378
 
470
- if (matchingOptions.length > 0) {
471
- if (this.multiSelect) {
472
- // For multiselect, keep all matching options
379
+ if (matchingOptions) {
473
380
  this.optionSelected = matchingOptions;
381
+ this.index = this.items.indexOf(matchingOptions);
474
382
  } else {
475
- // For single select, only use the first match
476
- this.optionSelected = [matchingOptions[0]];
477
- this.index = this.items.indexOf(matchingOptions[0]);
383
+ // If no matching option found, reset selection
384
+ this.optionSelected = undefined;
385
+ this.index = -1;
478
386
  }
479
- } else {
480
- // No matches found - trigger failure event
387
+ }
388
+
389
+ // If no matching options were found in either mode
390
+ if (!this.optionSelected || (Array.isArray(this.optionSelected) && this.optionSelected.length === 0)) {
481
391
  dispatchMenuEvent(this, 'auroMenu-selectValueFailure');
482
392
  this.optionSelected = undefined;
483
393
  this.index = -1;
@@ -629,8 +539,8 @@ class AuroMenu extends i$2 {
629
539
  }
630
540
  } else {
631
541
  // Single select - use arrays with single values
632
- this.value = [option.value];
633
- this.optionSelected = [option];
542
+ this.value = option.value;
543
+ this.optionSelected = option;
634
544
  }
635
545
 
636
546
  this.index = this.items.indexOf(option);
@@ -952,8 +862,13 @@ class AuroMenu extends i$2 {
952
862
  if (!this.optionSelected) {
953
863
  return false;
954
864
  }
955
- // Always treat as array for both single and multi-select
956
- return Array.isArray(this.optionSelected) && this.optionSelected.includes(option);
865
+
866
+ if (this.multiSelect) {
867
+ // In multi-select mode, check if the option is in the selected array
868
+ return Array.isArray(this.optionSelected) && this.optionSelected.some((selectedOption) => selectedOption === option);
869
+ }
870
+
871
+ return this.optionSelected === option;
957
872
  }
958
873
 
959
874
  /**
@@ -103,102 +103,6 @@ class AuroLibraryRuntimeUtils {
103
103
  // Copyright (c) 2021 Alaska Airlines. All right reserved. Licensed under the Apache-2.0 license
104
104
  // See LICENSE in the project root for license information.
105
105
 
106
- // ---------------------------------------------------------------------
107
-
108
- /**
109
- * Converts value to an array.
110
- * If the value is a JSON string representing an array, it will be parsed.
111
- * If the value is already an array, it is returned.
112
- * If the value is undefined, it returns undefined.
113
- * @private
114
- * @param {any} value - The value to be converted. Can be a string, array, or undefined.
115
- * @returns {Array|undefined} - The converted array or undefined.
116
- * @throws {Error} - Throws an error if the value is not an array, undefined,
117
- * or if the value cannot be parsed into an array from a JSON string.
118
- */
119
- function arrayConverter(value) {
120
- // Allow undefined
121
- if (value === undefined) {
122
- return undefined;
123
- }
124
-
125
- // Return the value if it is already an array
126
- if (Array.isArray(value)) {
127
- return value;
128
- }
129
-
130
- try {
131
- // If value is a JSON string, parse it
132
- const parsed = typeof value === 'string' ? JSON.parse(value) : value;
133
-
134
- // Check if the parsed value is an array
135
- if (Array.isArray(parsed)) {
136
- return parsed;
137
- }
138
- } catch (error) {
139
- // If JSON parsing fails, continue to throw an error below
140
- /* eslint-disable no-console */
141
- console.error('JSON parsing failed:', error);
142
- }
143
-
144
- // Throw error if the input is not an array or undefined
145
- throw new Error('Invalid value: Input must be an array or undefined');
146
- }
147
-
148
- /**
149
- * Compare two arrays for equality.
150
- * @private
151
- * @param {Array} arr1 - First array to compare.
152
- * @param {Array} arr2 - Second array to compare.
153
- * @returns {boolean} True if arrays are equal.
154
- */
155
- function arraysAreEqual(arr1, arr2) {
156
- // If both arrays undefined, they are equal (true)
157
- if (arr1 === undefined || arr2 === undefined) {
158
- return arr1 === arr2;
159
- }
160
-
161
- // If arrays have different lengths, they are not equal
162
- if (arr1.length !== arr2.length) {
163
- return false;
164
- }
165
-
166
- // If every item at each index is the same, return true
167
- for (let index = 0; index < arr1.length; index += 1) {
168
- if (arr1[index] !== arr2[index]) {
169
- return false;
170
- }
171
- }
172
- return true;
173
- }
174
-
175
- /**
176
- * Compares array for changes.
177
- * @private
178
- * @param {Array|any} newVal - New value to compare.
179
- * @param {Array|any} oldVal - Old value to compare.
180
- * @returns {boolean} True if arrays have changed.
181
- */
182
- function arrayOrUndefinedHasChanged(newVal, oldVal) {
183
- try {
184
- // Check if values are undefined or arrays
185
- const isArrayOrUndefined = (val) => val === undefined || Array.isArray(val);
186
-
187
- // If non-array or non-undefined, throw error
188
- if (!isArrayOrUndefined(newVal) || !isArrayOrUndefined(oldVal)) {
189
- const invalidValue = isArrayOrUndefined(newVal) ? oldVal : newVal;
190
- throw new Error(`Value must be an array or undefined, received ${typeof invalidValue}`);
191
- }
192
-
193
- // Return true if arrays have changed, false if they are the same
194
- return !arraysAreEqual(newVal, oldVal);
195
- } catch (error) {
196
- /* eslint-disable no-console */
197
- console.error(error);
198
- // If validation fails, it has changed
199
- return true;
200
- }
201
- }
202
106
 
203
107
  /**
204
108
  * Validates if an option can be interacted with.
@@ -232,7 +136,7 @@ function dispatchMenuEvent(element, eventName, detail = null) {
232
136
  element.dispatchEvent(new CustomEvent(eventName, eventConfig));
233
137
  }
234
138
 
235
- // Copyright (c) 2021 Alaska Airlines. All right reserved. Licensed under the Apache-2.0 license
139
+ // Copyright (c) 2025 Alaska Airlines. All right reserved. Licensed under the Apache-2.0 license
236
140
  // See LICENSE in the project root for license information.
237
141
 
238
142
 
@@ -240,14 +144,14 @@ function dispatchMenuEvent(element, eventName, detail = null) {
240
144
  // See https://git.io/JJ6SJ for "How to document your components using JSDoc"
241
145
  /**
242
146
  * The auro-menu element provides users a way to select from a list of options.
243
- * @attr {Array<HTMLElement>|undefined} optionSelected - An array of currently selected menu options. In single-select mode, the array will contain only one HTMLElement. `undefined` when no options are selected.
147
+ * @attr {HTMLElement|Array<HTMLElement>} optionSelected - An array of currently selected menu options, type `HTMLElement` by default. In multi-select mode, `optionSelected` is an array of HTML elements.
244
148
  * @attr {object} optionactive - Specifies the current active menuOption.
245
149
  * @attr {string} matchword - Specifies a string used to highlight matched string parts in options.
246
150
  * @attr {boolean} disabled - When true, the entire menu and all options are disabled;
247
151
  * @attr {boolean} nocheckmark - When true, selected option will not show the checkmark.
248
152
  * @attr {boolean} loading - When true, displays a loading state using the loadingIcon and loadingText slots if provided.
249
153
  * @attr {boolean} multiselect - When true, the selected option can be multiple options.
250
- * @attr {Array<string>|undefined} value - Value selected for the menu. `undefined` when no selection has been made, otherwise an array of strings. In single-select mode, the array will contain only one value.
154
+ * @attr {String|Array<string>} value - Value selected for the menu, type `string` by default. In multi-select mode, `value` is an array of strings.
251
155
  * @prop {boolean} hasLoadingPlaceholder - Indicates whether the menu has a loadingIcon or loadingText to render when in a loading state.
252
156
  * @event {CustomEvent<Element>} auroMenu-activatedOption - Notifies that a menuoption has been made `active`.
253
157
  * @event {CustomEvent<any>} auroMenu-customEventFired - Notifies that a custom event has been fired.
@@ -260,7 +164,7 @@ function dispatchMenuEvent(element, eventName, detail = null) {
260
164
  * @slot - Slot for insertion of menu options.
261
165
  */
262
166
 
263
- /* eslint-disable no-magic-numbers, max-lines */
167
+ /* eslint-disable no-magic-numbers, max-lines, no-extra-parens */
264
168
 
265
169
  class AuroMenu extends i$2 {
266
170
  constructor() {
@@ -340,9 +244,8 @@ class AuroMenu extends i$2 {
340
244
  reflect: true
341
245
  },
342
246
  optionSelected: {
343
- // Allow HTMLElement[] arrays and undefined
344
- converter: arrayConverter,
345
- hasChanged: arrayOrUndefinedHasChanged
247
+ // Allow HTMLElement, HTMLElement[] arrays and undefined
248
+ type: Object
346
249
  },
347
250
  optionActive: {
348
251
  type: Object,
@@ -358,10 +261,8 @@ class AuroMenu extends i$2 {
358
261
  attribute: 'multiselect'
359
262
  },
360
263
  value: {
361
- // Allow string[] arrays and undefined
362
- type: Object,
363
- converter: arrayConverter,
364
- hasChanged: arrayOrUndefinedHasChanged
264
+ // Allow string, string[] arrays and undefined
265
+ type: Object
365
266
  }
366
267
  };
367
268
  }
@@ -414,30 +315,39 @@ class AuroMenu extends i$2 {
414
315
  }
415
316
 
416
317
  updated(changedProperties) {
318
+ if (changedProperties.has('multiSelect')) {
319
+ // Reset selection if multiSelect mode changes
320
+ this.clearSelection();
321
+ }
322
+
417
323
  if (changedProperties.has('value')) {
418
324
  // Handle null/undefined case
419
325
  if (this.value === undefined || this.value === null) {
420
326
  this.optionSelected = undefined;
421
- // Reset index tracking
422
327
  this.index = -1;
423
328
  } else {
424
- // Convert single values to arrays
425
- const valueArray = Array.isArray(this.value) ? this.value : [this.value];
329
+ if (this.multiSelect) {
330
+ // In multiselect mode, this.value should be an array of strings
331
+ const valueArray = Array.isArray(this.value) ? this.value : [this.value];
332
+ const matchingOptions = this.items.filter((item) => valueArray.includes(item.value));
426
333
 
427
- // Find all matching options
428
- const matchingOptions = this.items.filter((item) => valueArray.includes(item.value));
334
+ this.optionSelected = matchingOptions.length > 0 ? matchingOptions : undefined;
335
+ } else {
336
+ // In single-select mode, this.value should be a string
337
+ const matchingOptions = this.items.find((item) => item.value === this.value);
429
338
 
430
- if (matchingOptions.length > 0) {
431
- if (this.multiSelect) {
432
- // For multiselect, keep all matching options
339
+ if (matchingOptions) {
433
340
  this.optionSelected = matchingOptions;
341
+ this.index = this.items.indexOf(matchingOptions);
434
342
  } else {
435
- // For single select, only use the first match
436
- this.optionSelected = [matchingOptions[0]];
437
- this.index = this.items.indexOf(matchingOptions[0]);
343
+ // If no matching option found, reset selection
344
+ this.optionSelected = undefined;
345
+ this.index = -1;
438
346
  }
439
- } else {
440
- // No matches found - trigger failure event
347
+ }
348
+
349
+ // If no matching options were found in either mode
350
+ if (!this.optionSelected || (Array.isArray(this.optionSelected) && this.optionSelected.length === 0)) {
441
351
  dispatchMenuEvent(this, 'auroMenu-selectValueFailure');
442
352
  this.optionSelected = undefined;
443
353
  this.index = -1;
@@ -589,8 +499,8 @@ class AuroMenu extends i$2 {
589
499
  }
590
500
  } else {
591
501
  // Single select - use arrays with single values
592
- this.value = [option.value];
593
- this.optionSelected = [option];
502
+ this.value = option.value;
503
+ this.optionSelected = option;
594
504
  }
595
505
 
596
506
  this.index = this.items.indexOf(option);
@@ -912,8 +822,13 @@ class AuroMenu extends i$2 {
912
822
  if (!this.optionSelected) {
913
823
  return false;
914
824
  }
915
- // Always treat as array for both single and multi-select
916
- return Array.isArray(this.optionSelected) && this.optionSelected.includes(option);
825
+
826
+ if (this.multiSelect) {
827
+ // In multi-select mode, check if the option is in the selected array
828
+ return Array.isArray(this.optionSelected) && this.optionSelected.some((selectedOption) => selectedOption === option);
829
+ }
830
+
831
+ return this.optionSelected === option;
917
832
  }
918
833
 
919
834
  /**
@@ -110,7 +110,7 @@ The use of any Auro custom element has a dependency on the [Auro Design Tokens](
110
110
  In cases where the project is not able to process JS assets, there are pre-processed assets available for use. Legacy browsers such as IE11 are no longer supported.
111
111
 
112
112
  ```html
113
- <script type="module" src="https://cdn.jsdelivr.net/npm/@aurodesignsystem/auro-formkit@0.0.0/auro-menu/+esm"></script>
113
+ <script type="module" src="https://cdn.jsdelivr.net/npm/@aurodesignsystem/auro-formkit@latest/auro-menu/+esm"></script>
114
114
  ```
115
115
  <!-- AURO-GENERATED-CONTENT:END -->
116
116
 
@@ -18,14 +18,6 @@ export function arrayConverter(value: any): any[] | undefined;
18
18
  * @returns {boolean} True if arrays are equal.
19
19
  */
20
20
  export function arraysAreEqual(arr1: any[], arr2: any[]): boolean;
21
- /**
22
- * Compares array for changes.
23
- * @private
24
- * @param {Array|any} newVal - New value to compare.
25
- * @param {Array|any} oldVal - Old value to compare.
26
- * @returns {boolean} True if arrays have changed.
27
- */
28
- export function arrayOrUndefinedHasChanged(newVal: any[] | any, oldVal: any[] | any): boolean;
29
21
  /**
30
22
  * Validates if an option can be interacted with.
31
23
  * @private
@@ -1,13 +1,13 @@
1
1
  /**
2
2
  * The auro-menu element provides users a way to select from a list of options.
3
- * @attr {Array<HTMLElement>|undefined} optionSelected - An array of currently selected menu options. In single-select mode, the array will contain only one HTMLElement. `undefined` when no options are selected.
3
+ * @attr {HTMLElement|Array<HTMLElement>} optionSelected - An array of currently selected menu options, type `HTMLElement` by default. In multi-select mode, `optionSelected` is an array of HTML elements.
4
4
  * @attr {object} optionactive - Specifies the current active menuOption.
5
5
  * @attr {string} matchword - Specifies a string used to highlight matched string parts in options.
6
6
  * @attr {boolean} disabled - When true, the entire menu and all options are disabled;
7
7
  * @attr {boolean} nocheckmark - When true, selected option will not show the checkmark.
8
8
  * @attr {boolean} loading - When true, displays a loading state using the loadingIcon and loadingText slots if provided.
9
9
  * @attr {boolean} multiselect - When true, the selected option can be multiple options.
10
- * @attr {Array<string>|undefined} value - Value selected for the menu. `undefined` when no selection has been made, otherwise an array of strings. In single-select mode, the array will contain only one value.
10
+ * @attr {String|Array<string>} value - Value selected for the menu, type `string` by default. In multi-select mode, `value` is an array of strings.
11
11
  * @prop {boolean} hasLoadingPlaceholder - Indicates whether the menu has a loadingIcon or loadingText to render when in a loading state.
12
12
  * @event {CustomEvent<Element>} auroMenu-activatedOption - Notifies that a menuoption has been made `active`.
13
13
  * @event {CustomEvent<any>} auroMenu-customEventFired - Notifies that a custom event has been fired.
@@ -35,8 +35,7 @@ export class AuroMenu extends LitElement {
35
35
  reflect: boolean;
36
36
  };
37
37
  optionSelected: {
38
- converter: typeof arrayConverter;
39
- hasChanged: typeof arrayOrUndefinedHasChanged;
38
+ type: ObjectConstructor;
40
39
  };
41
40
  optionActive: {
42
41
  type: ObjectConstructor;
@@ -53,8 +52,6 @@ export class AuroMenu extends LitElement {
53
52
  };
54
53
  value: {
55
54
  type: ObjectConstructor;
56
- converter: typeof arrayConverter;
57
- hasChanged: typeof arrayOrUndefinedHasChanged;
58
55
  };
59
56
  };
60
57
  static get styles(): import("lit").CSSResult[];
@@ -201,5 +198,3 @@ export class AuroMenu extends LitElement {
201
198
  render(): boolean;
202
199
  }
203
200
  import { LitElement } from "lit";
204
- import { arrayConverter } from './auro-menu-utils.js';
205
- import { arrayOrUndefinedHasChanged } from './auro-menu-utils.js';
@@ -1,4 +1,4 @@
1
1
  import { AuroMenu } from './auro-menu.js';
2
2
  import { AuroMenuOption } from './auro-menuoption.js';
3
3
  export { AuroMenu, AuroMenuOption };
4
- export { arrayConverter, arrayOrUndefinedHasChanged, isOptionInteractive, dispatchMenuEvent } from "./auro-menu-utils.js";
4
+ export { arrayConverter, isOptionInteractive, dispatchMenuEvent } from "./auro-menu-utils.js";