@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
@@ -89,11 +89,11 @@ function valueExample() {
89
89
  const valueExample = document.querySelector('#valueExample');
90
90
 
91
91
  document.querySelector('#valueValidExampleBtn').addEventListener('click', () => {
92
- valueExample.value = ['Oranges'];
92
+ valueExample.value = 'Oranges';
93
93
  });
94
94
 
95
95
  document.querySelector('#valueInvalidExampleBtn').addEventListener('click', () => {
96
- valueExample.value = ['Dragon Fruit'];
96
+ valueExample.value = 'Dragon Fruit';
97
97
  });
98
98
 
99
99
  document.querySelector('#valueUndefinedExampleBtn').addEventListener('click', () => {
@@ -12605,122 +12605,6 @@ class AuroBibtemplate extends i$2 {
12605
12605
 
12606
12606
  var bibTemplateVersion = '1.0.0';
12607
12607
 
12608
- i$5`:focus:not(:focus-visible){outline:3px solid transparent}:host{display:inline-block;width:100%;margin:0;padding:0;vertical-align:middle}:host ::slotted(auro-menuoption),:host ::slotted([auro-menuoption]),:host auro-menuoption[loadingplaceholder]{padding-left:calc(var(--ds-size-150, 0.75rem) + 24px + var(--ds-size-100, 0.5rem))}:host ::slotted([selected]){padding-left:0}:host ::slotted(hr){box-sizing:content-box !important;height:0 !important;overflow:visible !important;margin:var(--ds-size-100, 0.5rem) 0 !important;border-width:0 !important;border-top-width:1px !important;border-top-style:solid !important}:host([nocheckmark]) ::slotted(auro-menuoption),:host([nocheckmark]) auro-menuoption[loadingplaceholder]{padding-left:var(--ds-size-200, 1rem)}:host([root]){overflow-y:auto}[loadingplaceholder].empty{opacity:0;position:absolute}[loadingplaceholder] slot[name=loadingIcon]{vertical-align:middle;line-height:1;display:inline-block}[loadingplaceholder] slot[name=loadingIcon]::slotted(*){margin-right:var(--ds-size-150, 0.75rem)}`;
12609
-
12610
- i$5`:host ::slotted(hr){border-top-color:var(--ds-auro-menu-divider-color)}[loadingplaceholder] slot[name=loadingIcon]{color:var(--ds-auro-menu-loader-color)}[loadingplaceholder] slot[name=loadingText]{color:var(--ds-auro-menu-loader-text-color)}`;
12611
-
12612
- i$5`:host{--ds-auro-menu-divider-color: var(--ds-basic-color-border-divider, rgba(0, 0, 0, 0.15));--ds-auro-menu-loader-color: var(--ds-basic-color-brand-primary, #01426a);--ds-auro-menu-loader-text-color: var(--ds-basic-color-texticon-default, #2a2a2a);--ds-auro-menuoption-container-color: transparent;--ds-auro-menuoption-icon-color: transparent;--ds-auro-menuoption-text-color: var(--ds-basic-color-texticon-default, #2a2a2a)}`;
12613
-
12614
- // Copyright (c) 2021 Alaska Airlines. All right reserved. Licensed under the Apache-2.0 license
12615
- // See LICENSE in the project root for license information.
12616
-
12617
- // ---------------------------------------------------------------------
12618
-
12619
- /**
12620
- * Converts value to an array.
12621
- * If the value is a JSON string representing an array, it will be parsed.
12622
- * If the value is already an array, it is returned.
12623
- * If the value is undefined, it returns undefined.
12624
- * @private
12625
- * @param {any} value - The value to be converted. Can be a string, array, or undefined.
12626
- * @returns {Array|undefined} - The converted array or undefined.
12627
- * @throws {Error} - Throws an error if the value is not an array, undefined,
12628
- * or if the value cannot be parsed into an array from a JSON string.
12629
- */
12630
- function arrayConverter$1(value) {
12631
- // Allow undefined
12632
- if (value === undefined) {
12633
- return undefined;
12634
- }
12635
-
12636
- // Return the value if it is already an array
12637
- if (Array.isArray(value)) {
12638
- return value;
12639
- }
12640
-
12641
- try {
12642
- // If value is a JSON string, parse it
12643
- const parsed = typeof value === 'string' ? JSON.parse(value) : value;
12644
-
12645
- // Check if the parsed value is an array
12646
- if (Array.isArray(parsed)) {
12647
- return parsed;
12648
- }
12649
- } catch (error) {
12650
- // If JSON parsing fails, continue to throw an error below
12651
- /* eslint-disable no-console */
12652
- console.error('JSON parsing failed:', error);
12653
- }
12654
-
12655
- // Throw error if the input is not an array or undefined
12656
- throw new Error('Invalid value: Input must be an array or undefined');
12657
- }
12658
-
12659
- /**
12660
- * Compare two arrays for equality.
12661
- * @private
12662
- * @param {Array} arr1 - First array to compare.
12663
- * @param {Array} arr2 - Second array to compare.
12664
- * @returns {boolean} True if arrays are equal.
12665
- */
12666
- function arraysAreEqual$1(arr1, arr2) {
12667
- // If both arrays undefined, they are equal (true)
12668
- if (arr1 === undefined || arr2 === undefined) {
12669
- return arr1 === arr2;
12670
- }
12671
-
12672
- // If arrays have different lengths, they are not equal
12673
- if (arr1.length !== arr2.length) {
12674
- return false;
12675
- }
12676
-
12677
- // If every item at each index is the same, return true
12678
- for (let index = 0; index < arr1.length; index += 1) {
12679
- if (arr1[index] !== arr2[index]) {
12680
- return false;
12681
- }
12682
- }
12683
- return true;
12684
- }
12685
-
12686
- /**
12687
- * Compares array for changes.
12688
- * @private
12689
- * @param {Array|any} newVal - New value to compare.
12690
- * @param {Array|any} oldVal - Old value to compare.
12691
- * @returns {boolean} True if arrays have changed.
12692
- */
12693
- function arrayOrUndefinedHasChanged$1(newVal, oldVal) {
12694
- try {
12695
- // Check if values are undefined or arrays
12696
- const isArrayOrUndefined = (val) => val === undefined || Array.isArray(val);
12697
-
12698
- // If non-array or non-undefined, throw error
12699
- if (!isArrayOrUndefined(newVal) || !isArrayOrUndefined(oldVal)) {
12700
- const invalidValue = isArrayOrUndefined(newVal) ? oldVal : newVal;
12701
- throw new Error(`Value must be an array or undefined, received ${typeof invalidValue}`);
12702
- }
12703
-
12704
- // Return true if arrays have changed, false if they are the same
12705
- return !arraysAreEqual$1(newVal, oldVal);
12706
- } catch (error) {
12707
- /* eslint-disable no-console */
12708
- console.error(error);
12709
- // If validation fails, it has changed
12710
- return true;
12711
- }
12712
- }
12713
-
12714
- i$5`:host{display:flex;align-items:center;padding:var(--ds-size-50, 0.25rem) var(--ds-size-200, 1rem) var(--ds-size-50, 0.25rem) 0;cursor:pointer;user-select:none;-webkit-tap-highlight-color:transparent}:host slot{display:block;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}:host [auro-icon]{--ds-auro-icon-size: var(--ds-size-300, 1.5rem);margin-right:var(--ds-size-150, 0.75rem);margin-left:var(--ds-size-100, 0.5rem)}:host ::slotted(.nestingSpacer){display:inline-block;width:var(--ds-size-300, 1.5rem)}:host ::slotted(strong){font-weight:700}:host([hidden]){display:none}:host([static]){pointer-events:none}:host([disabled]:hover){cursor:auto}:host([disabled]){user-select:none;pointer-events:none}`;
12715
-
12716
- i$5`:host{background-color:var(--ds-auro-menuoption-container-color);color:var(--ds-auro-menuoption-text-color)}:host svg{fill:var(--ds-auro-menuoption-icon-color)}:host([disabled]){--ds-auro-menuoption-text-color: var(--ds-basic-color-texticon-disabled, #d0d0d0)}:host(:hover),:host(.active){--ds-auro-menuoption-container-color: var(--ds-basic-color-surface-neutral-subtle, #f7f7f7)}:host([selected]){--ds-auro-menuoption-container-color: var(--ds-advanced-color-state-selected, #01426a);--ds-auro-menuoption-text-color: var(--ds-basic-color-texticon-inverse, #ffffff);--ds-auro-menuoption-icon-color: var(--ds-basic-color-texticon-inverse, #ffffff)}:host([selected]):host(:hover),:host([selected]):host(.active){--ds-auro-menuoption-container-color: var(--ds-advanced-color-state-selected-hover, #00274a)}`;
12717
-
12718
- i$5`:focus:not(:focus-visible){outline:3px solid transparent}.util_displayInline{display:inline}.util_displayInlineBlock{display:inline-block}.util_displayBlock,:host{display:block}.util_displayFlex{display:flex}.util_displayHidden,:host([hidden]:not(:focus):not(:active)){display:none}.util_displayHiddenVisually,:host([hiddenVisually]:not(:focus):not(:active)){position:absolute;overflow:hidden;clip:rect(1px, 1px, 1px, 1px);width:1px;height:1px;padding:0;border:0}.ico_squareLarge{fill:currentColor;height:var(--auro-size-lg, var(--ds-size-300, 1.5rem))}.ico_squareSmall{fill:currentColor;height:.6rem}.ico_squareMed{fill:currentColor;height:var(--auro-size-md, var(--ds-size-200, 1rem))}.ico_squareSml{fill:currentColor;height:var(--auro-size-sm, var(--ds-size-150, 0.75rem))}:host{color:currentColor;vertical-align:middle;line-height:1;display:inline-block}svg{min-width:var(--ds-auro-icon-size, 1.5rem) !important;width:var(--ds-auro-icon-size, 1.5rem) !important;height:var(--ds-auro-icon-size, 1.5rem) !important}.componentWrapper{display:flex}.svgWrapper{height:var(--ds-auro-icon-size);width:var(--ds-auro-icon-size)}.labelWrapper{margin-left:var(--ds-size-50, 0.25rem);line-height:1.8}`;
12719
-
12720
- i$5`:host{--ds-auro-icon-color:var(--ds-basic-color-texticon-default, #2a2a2a);--ds-auro-alaska-color:#02426D;--ds-auro-icon-size:var(--ds-size-300, 1.5rem)}`;
12721
-
12722
- i$5`:host{color:var(--ds-auro-icon-color)}:host([customColor]){color:inherit}:host(:not([onDark])[variant=accent1]){--ds-auro-icon-color:var(--ds-basic-color-texticon-accent1, #265688)}:host(:not([onDark])[variant=disabled]){--ds-auro-icon-color:var(--ds-basic-color-texticon-disabled, #d0d0d0)}:host(:not([onDark])[variant=muted]){--ds-auro-icon-color:var(--ds-basic-color-texticon-muted, #676767)}:host(:not([onDark])[variant=statusDefault]){--ds-auro-icon-color:var(--ds-basic-color-status-default, #afb9c6)}:host(:not([onDark])[variant=statusInfo]){--ds-auro-icon-color:var(--ds-basic-color-status-info, #01426a)}:host(:not([onDark])[variant=statusSuccess]){--ds-auro-icon-color:var(--ds-basic-color-status-success, #447a1f)}:host(:not([onDark])[variant=statusWarning]){--ds-auro-icon-color:var(--ds-basic-color-status-warning, #fac200)}:host(:not([onDark])[variant=statusError]){--ds-auro-icon-color:var(--ds-basic-color-status-error, #e31f26)}:host(:not([onDark])[variant=statusInfoSubtle]){--ds-auro-icon-color:var(--ds-basic-color-status-info-subtle, #ebf3f9)}:host(:not([onDark])[variant=statusSuccessSubtle]){--ds-auro-icon-color:var(--ds-basic-color-status-success-subtle, #d6eac7)}:host(:not([onDark])[variant=statusWarningSubtle]){--ds-auro-icon-color:var(--ds-basic-color-status-warning-subtle, #fff0b2)}:host(:not([onDark])[variant=statusErrorSubtle]){--ds-auro-icon-color:var(--ds-basic-color-status-error-subtle, #fbc6c6)}:host(:not([onDark])[variant=fareBasicEconomy]){--ds-auro-icon-color:var(--ds-basic-color-fare-basiceconomy, #97eaf8)}:host(:not([onDark])[variant=fareBusiness]){--ds-auro-icon-color:var(--ds-basic-color-fare-business, #01426a)}:host(:not([onDark])[variant=fareEconomy]){--ds-auro-icon-color:var(--ds-basic-color-fare-economy, #0074ca)}:host(:not([onDark])[variant=fareFirst]){--ds-auro-icon-color:var(--ds-basic-color-fare-first, #00274a)}:host(:not([onDark])[variant=farePremiumEconomy]){--ds-auro-icon-color:var(--ds-basic-color-fare-premiumeconomy, #005154)}:host(:not([onDark])[variant=tierOneWorldEmerald]){--ds-auro-icon-color:var(--ds-basic-color-tier-program-oneworld-emerald, #139142)}:host(:not([onDark])[variant=tierOneWorldSapphire]){--ds-auro-icon-color:var(--ds-basic-color-tier-program-oneworld-sapphire, #015daa)}:host(:not([onDark])[variant=tierOneWorldRuby]){--ds-auro-icon-color:var(--ds-basic-color-tier-program-oneworld-ruby, #a41d4a)}:host([onDark]){--ds-auro-icon-color:var(--ds-basic-color-texticon-inverse, #ffffff)}:host([onDark][variant=disabled]){--ds-auro-icon-color:var(--ds-basic-color-texticon-inverse-disabled, #7e8894)}:host([onDark][variant=muted]){--ds-auro-icon-color:var(--ds-basic-color-texticon-inverse-muted, #ccd2db)}`;
12723
-
12724
12608
  var styleCss$3 = i$5`.util_displayInline{display:inline}.util_displayInlineBlock{display:inline-block}.util_displayBlock{display:block}.util_displayFlex{display:flex}.util_displayHidden{display:none}.util_displayHiddenVisually{position:absolute;overflow:hidden;clip:rect(1px, 1px, 1px, 1px);width:1px;height:1px;padding:0;border:0}[auro-input]{min-height:var(--ds-size-700, 3.5rem);max-height:var(--ds-size-700, 3.5rem)}[auro-input]::part(iconContainer){top:0;display:flex;height:100%;align-items:center}[auro-input]::part(accentIcon){transition:all .3s cubic-bezier(0.215, 0.61, 0.355, 1)}[auro-input]::part(helpText){display:none}[auro-input]::part(wrapper){--ds-auro-input-border-color: transparent;--ds-auro-input-container-color: transparent}[auro-input]::part(wrapper):focus-within{border-bottom-width:0 !important;box-shadow:unset !important;outline:unset !important}#slotHolder{display:none}`;
12725
12609
 
12726
12610
  // Copyright (c) 2022 Alaska Airlines. All right reserved. Licensed under the Apache-2.0 license
@@ -12912,11 +12796,10 @@ class AuroCombobox extends i$2 {
12912
12796
 
12913
12797
  /**
12914
12798
  * Specifies the current selected option.
12799
+ * @type {HTMLElement}
12915
12800
  */
12916
12801
  optionSelected: {
12917
- type: Object,
12918
- converter: arrayConverter$1,
12919
- hasChanged: arrayOrUndefinedHasChanged$1
12802
+ type: Object
12920
12803
  },
12921
12804
 
12922
12805
  /**
@@ -12988,11 +12871,10 @@ class AuroCombobox extends i$2 {
12988
12871
 
12989
12872
  /**
12990
12873
  * Value selected for the dropdown menu.
12991
- * @type {Array|String<Array>}
12874
+ * @type {string}
12992
12875
  */
12993
12876
  value: {
12994
- converter: arrayConverter$1,
12995
- hasChanged: arrayOrUndefinedHasChanged$1
12877
+ type: Object
12996
12878
  },
12997
12879
 
12998
12880
  /**
@@ -13064,17 +12946,15 @@ class AuroCombobox extends i$2 {
13064
12946
 
13065
12947
  if (this.menu.optionSelected) {
13066
12948
  // Get first option since combobox is single-select
13067
- const [selected] = this.menu.optionSelected;
12949
+ const selected = this.menu.optionSelected;
13068
12950
 
13069
- if (!this.optionSelected || this.optionSelected[0] !== selected) {
13070
- // Store as array
13071
- this.optionSelected = [selected];
12951
+ if (!this.optionSelected || this.optionSelected !== selected) {
12952
+ this.optionSelected = selected;
13072
12953
  }
13073
12954
 
13074
- if (!this.value || this.value[0] !== selected.value) {
13075
- // Store as array
13076
- this.value = [selected.value];
13077
- // Menu already expects array
12955
+ if (!this.value || this.value !== selected.value) {
12956
+ this.value = selected.value;
12957
+
13078
12958
  this.menu.value = this.value;
13079
12959
  }
13080
12960
 
@@ -13254,14 +13134,14 @@ class AuroCombobox extends i$2 {
13254
13134
  // handle the menu event for an option selection
13255
13135
  this.menu.addEventListener('auroMenu-selectedOption', () => {
13256
13136
  if (this.menu.optionSelected) {
13257
- const [selected] = this.menu.optionSelected;
13137
+ const selected = this.menu.optionSelected;
13258
13138
 
13259
- if (!this.optionSelected || this.optionSelected[0] !== selected) {
13260
- this.optionSelected = [selected];
13139
+ if (!this.optionSelected || this.optionSelected !== selected) {
13140
+ this.optionSelected = selected;
13261
13141
  }
13262
13142
 
13263
- if (!this.value || this.value[0] !== this.optionSelected[0].value) {
13264
- this.value = [this.optionSelected[0].value];
13143
+ if (!this.value || this.value !== this.optionSelected.value) {
13144
+ this.value = this.optionSelected.value;
13265
13145
  this.menu.value = this.value;
13266
13146
  }
13267
13147
 
@@ -13363,11 +13243,6 @@ class AuroCombobox extends i$2 {
13363
13243
  if (document.activeElement !== this) {
13364
13244
  this.validate();
13365
13245
  }
13366
-
13367
- // Set to undefined if empty
13368
- if (this.value && this.value.length === 0) {
13369
- this.value = undefined;
13370
- }
13371
13246
  });
13372
13247
 
13373
13248
  // Handle validation messages from auroFormElement-validated event
@@ -13462,10 +13337,8 @@ class AuroCombobox extends i$2 {
13462
13337
 
13463
13338
  let hasChange = false;
13464
13339
 
13465
- // Store value as array or undefined
13466
- if (!this.value || this.value[0] !== this.input.value) {
13467
- // Menu expects an array
13468
- this.menu.value = this.input.value ? [this.input.value] : undefined;
13340
+ if (!this.value || this.value !== this.input.value) {
13341
+ this.menu.value = this.input.value;
13469
13342
  this.value = this.menu.value;
13470
13343
  hasChange = true;
13471
13344
  this.dispatchEvent(new CustomEvent('auroCombobox-valueSet', {
@@ -13475,7 +13348,7 @@ class AuroCombobox extends i$2 {
13475
13348
  }));
13476
13349
  }
13477
13350
 
13478
- if (this.optionSelected && this.optionSelected[0] && this.input.value !== this.optionSelected[0].textContent) {
13351
+ if (this.optionSelected && this.input.value !== this.optionSelected.textContent) {
13479
13352
  this.optionSelected = undefined;
13480
13353
  hasChange = true;
13481
13354
  }
@@ -13618,15 +13491,15 @@ class AuroCombobox extends i$2 {
13618
13491
  // After the component is ready, send direct value changes to auro-menu.
13619
13492
  if (changedProperties.has('value')) {
13620
13493
  if (this.value) {
13621
- if (this.optionSelected && this.optionSelected[0] && this.optionSelected[0].value === this.value[0]) {
13494
+ if (this.optionSelected && this.optionSelected.value === this.value) {
13622
13495
  // If value updates and the previously selected option already matches the new value
13623
13496
  // just update the input value to use the textContent of the optionSelected
13624
- this.input.value = this.optionSelected[0].textContent;
13497
+ this.input.value = this.optionSelected.textContent;
13625
13498
  } else {
13626
13499
  // Otherwise just enter the value into the input
13627
13500
  this.optionSelected = undefined;
13628
- // Use first value since combobox is single-select
13629
- const [inputValue] = this.value;
13501
+
13502
+ const inputValue = this.value;
13630
13503
  this.input.value = inputValue;
13631
13504
 
13632
13505
  // Update the menu value and matchWord
@@ -13784,102 +13657,6 @@ var tokensCss$1 = i$5`:host{--ds-auro-menu-divider-color: var(--ds-basic-color-b
13784
13657
  // Copyright (c) 2021 Alaska Airlines. All right reserved. Licensed under the Apache-2.0 license
13785
13658
  // See LICENSE in the project root for license information.
13786
13659
 
13787
- // ---------------------------------------------------------------------
13788
-
13789
- /**
13790
- * Converts value to an array.
13791
- * If the value is a JSON string representing an array, it will be parsed.
13792
- * If the value is already an array, it is returned.
13793
- * If the value is undefined, it returns undefined.
13794
- * @private
13795
- * @param {any} value - The value to be converted. Can be a string, array, or undefined.
13796
- * @returns {Array|undefined} - The converted array or undefined.
13797
- * @throws {Error} - Throws an error if the value is not an array, undefined,
13798
- * or if the value cannot be parsed into an array from a JSON string.
13799
- */
13800
- function arrayConverter(value) {
13801
- // Allow undefined
13802
- if (value === undefined) {
13803
- return undefined;
13804
- }
13805
-
13806
- // Return the value if it is already an array
13807
- if (Array.isArray(value)) {
13808
- return value;
13809
- }
13810
-
13811
- try {
13812
- // If value is a JSON string, parse it
13813
- const parsed = typeof value === 'string' ? JSON.parse(value) : value;
13814
-
13815
- // Check if the parsed value is an array
13816
- if (Array.isArray(parsed)) {
13817
- return parsed;
13818
- }
13819
- } catch (error) {
13820
- // If JSON parsing fails, continue to throw an error below
13821
- /* eslint-disable no-console */
13822
- console.error('JSON parsing failed:', error);
13823
- }
13824
-
13825
- // Throw error if the input is not an array or undefined
13826
- throw new Error('Invalid value: Input must be an array or undefined');
13827
- }
13828
-
13829
- /**
13830
- * Compare two arrays for equality.
13831
- * @private
13832
- * @param {Array} arr1 - First array to compare.
13833
- * @param {Array} arr2 - Second array to compare.
13834
- * @returns {boolean} True if arrays are equal.
13835
- */
13836
- function arraysAreEqual(arr1, arr2) {
13837
- // If both arrays undefined, they are equal (true)
13838
- if (arr1 === undefined || arr2 === undefined) {
13839
- return arr1 === arr2;
13840
- }
13841
-
13842
- // If arrays have different lengths, they are not equal
13843
- if (arr1.length !== arr2.length) {
13844
- return false;
13845
- }
13846
-
13847
- // If every item at each index is the same, return true
13848
- for (let index = 0; index < arr1.length; index += 1) {
13849
- if (arr1[index] !== arr2[index]) {
13850
- return false;
13851
- }
13852
- }
13853
- return true;
13854
- }
13855
-
13856
- /**
13857
- * Compares array for changes.
13858
- * @private
13859
- * @param {Array|any} newVal - New value to compare.
13860
- * @param {Array|any} oldVal - Old value to compare.
13861
- * @returns {boolean} True if arrays have changed.
13862
- */
13863
- function arrayOrUndefinedHasChanged(newVal, oldVal) {
13864
- try {
13865
- // Check if values are undefined or arrays
13866
- const isArrayOrUndefined = (val) => val === undefined || Array.isArray(val);
13867
-
13868
- // If non-array or non-undefined, throw error
13869
- if (!isArrayOrUndefined(newVal) || !isArrayOrUndefined(oldVal)) {
13870
- const invalidValue = isArrayOrUndefined(newVal) ? oldVal : newVal;
13871
- throw new Error(`Value must be an array or undefined, received ${typeof invalidValue}`);
13872
- }
13873
-
13874
- // Return true if arrays have changed, false if they are the same
13875
- return !arraysAreEqual(newVal, oldVal);
13876
- } catch (error) {
13877
- /* eslint-disable no-console */
13878
- console.error(error);
13879
- // If validation fails, it has changed
13880
- return true;
13881
- }
13882
- }
13883
13660
 
13884
13661
  /**
13885
13662
  * Validates if an option can be interacted with.
@@ -13913,7 +13690,7 @@ function dispatchMenuEvent(element, eventName, detail = null) {
13913
13690
  element.dispatchEvent(new CustomEvent(eventName, eventConfig));
13914
13691
  }
13915
13692
 
13916
- // Copyright (c) 2021 Alaska Airlines. All right reserved. Licensed under the Apache-2.0 license
13693
+ // Copyright (c) 2025 Alaska Airlines. All right reserved. Licensed under the Apache-2.0 license
13917
13694
  // See LICENSE in the project root for license information.
13918
13695
 
13919
13696
 
@@ -13921,14 +13698,14 @@ function dispatchMenuEvent(element, eventName, detail = null) {
13921
13698
  // See https://git.io/JJ6SJ for "How to document your components using JSDoc"
13922
13699
  /**
13923
13700
  * The auro-menu element provides users a way to select from a list of options.
13924
- * @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.
13701
+ * @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.
13925
13702
  * @attr {object} optionactive - Specifies the current active menuOption.
13926
13703
  * @attr {string} matchword - Specifies a string used to highlight matched string parts in options.
13927
13704
  * @attr {boolean} disabled - When true, the entire menu and all options are disabled;
13928
13705
  * @attr {boolean} nocheckmark - When true, selected option will not show the checkmark.
13929
13706
  * @attr {boolean} loading - When true, displays a loading state using the loadingIcon and loadingText slots if provided.
13930
13707
  * @attr {boolean} multiselect - When true, the selected option can be multiple options.
13931
- * @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.
13708
+ * @attr {String|Array<string>} value - Value selected for the menu, type `string` by default. In multi-select mode, `value` is an array of strings.
13932
13709
  * @prop {boolean} hasLoadingPlaceholder - Indicates whether the menu has a loadingIcon or loadingText to render when in a loading state.
13933
13710
  * @event {CustomEvent<Element>} auroMenu-activatedOption - Notifies that a menuoption has been made `active`.
13934
13711
  * @event {CustomEvent<any>} auroMenu-customEventFired - Notifies that a custom event has been fired.
@@ -13941,7 +13718,7 @@ function dispatchMenuEvent(element, eventName, detail = null) {
13941
13718
  * @slot - Slot for insertion of menu options.
13942
13719
  */
13943
13720
 
13944
- /* eslint-disable no-magic-numbers, max-lines */
13721
+ /* eslint-disable no-magic-numbers, max-lines, no-extra-parens */
13945
13722
 
13946
13723
  class AuroMenu extends i$2 {
13947
13724
  constructor() {
@@ -14021,9 +13798,8 @@ class AuroMenu extends i$2 {
14021
13798
  reflect: true
14022
13799
  },
14023
13800
  optionSelected: {
14024
- // Allow HTMLElement[] arrays and undefined
14025
- converter: arrayConverter,
14026
- hasChanged: arrayOrUndefinedHasChanged
13801
+ // Allow HTMLElement, HTMLElement[] arrays and undefined
13802
+ type: Object
14027
13803
  },
14028
13804
  optionActive: {
14029
13805
  type: Object,
@@ -14039,10 +13815,8 @@ class AuroMenu extends i$2 {
14039
13815
  attribute: 'multiselect'
14040
13816
  },
14041
13817
  value: {
14042
- // Allow string[] arrays and undefined
14043
- type: Object,
14044
- converter: arrayConverter,
14045
- hasChanged: arrayOrUndefinedHasChanged
13818
+ // Allow string, string[] arrays and undefined
13819
+ type: Object
14046
13820
  }
14047
13821
  };
14048
13822
  }
@@ -14095,30 +13869,39 @@ class AuroMenu extends i$2 {
14095
13869
  }
14096
13870
 
14097
13871
  updated(changedProperties) {
13872
+ if (changedProperties.has('multiSelect')) {
13873
+ // Reset selection if multiSelect mode changes
13874
+ this.clearSelection();
13875
+ }
13876
+
14098
13877
  if (changedProperties.has('value')) {
14099
13878
  // Handle null/undefined case
14100
13879
  if (this.value === undefined || this.value === null) {
14101
13880
  this.optionSelected = undefined;
14102
- // Reset index tracking
14103
13881
  this.index = -1;
14104
13882
  } else {
14105
- // Convert single values to arrays
14106
- const valueArray = Array.isArray(this.value) ? this.value : [this.value];
13883
+ if (this.multiSelect) {
13884
+ // In multiselect mode, this.value should be an array of strings
13885
+ const valueArray = Array.isArray(this.value) ? this.value : [this.value];
13886
+ const matchingOptions = this.items.filter((item) => valueArray.includes(item.value));
14107
13887
 
14108
- // Find all matching options
14109
- const matchingOptions = this.items.filter((item) => valueArray.includes(item.value));
13888
+ this.optionSelected = matchingOptions.length > 0 ? matchingOptions : undefined;
13889
+ } else {
13890
+ // In single-select mode, this.value should be a string
13891
+ const matchingOptions = this.items.find((item) => item.value === this.value);
14110
13892
 
14111
- if (matchingOptions.length > 0) {
14112
- if (this.multiSelect) {
14113
- // For multiselect, keep all matching options
13893
+ if (matchingOptions) {
14114
13894
  this.optionSelected = matchingOptions;
13895
+ this.index = this.items.indexOf(matchingOptions);
14115
13896
  } else {
14116
- // For single select, only use the first match
14117
- this.optionSelected = [matchingOptions[0]];
14118
- this.index = this.items.indexOf(matchingOptions[0]);
13897
+ // If no matching option found, reset selection
13898
+ this.optionSelected = undefined;
13899
+ this.index = -1;
14119
13900
  }
14120
- } else {
14121
- // No matches found - trigger failure event
13901
+ }
13902
+
13903
+ // If no matching options were found in either mode
13904
+ if (!this.optionSelected || (Array.isArray(this.optionSelected) && this.optionSelected.length === 0)) {
14122
13905
  dispatchMenuEvent(this, 'auroMenu-selectValueFailure');
14123
13906
  this.optionSelected = undefined;
14124
13907
  this.index = -1;
@@ -14270,8 +14053,8 @@ class AuroMenu extends i$2 {
14270
14053
  }
14271
14054
  } else {
14272
14055
  // Single select - use arrays with single values
14273
- this.value = [option.value];
14274
- this.optionSelected = [option];
14056
+ this.value = option.value;
14057
+ this.optionSelected = option;
14275
14058
  }
14276
14059
 
14277
14060
  this.index = this.items.indexOf(option);
@@ -14593,8 +14376,13 @@ class AuroMenu extends i$2 {
14593
14376
  if (!this.optionSelected) {
14594
14377
  return false;
14595
14378
  }
14596
- // Always treat as array for both single and multi-select
14597
- return Array.isArray(this.optionSelected) && this.optionSelected.includes(option);
14379
+
14380
+ if (this.multiSelect) {
14381
+ // In multi-select mode, check if the option is in the selected array
14382
+ return Array.isArray(this.optionSelected) && this.optionSelected.some((selectedOption) => selectedOption === option);
14383
+ }
14384
+
14385
+ return this.optionSelected === option;
14598
14386
  }
14599
14387
 
14600
14388
  /**
@@ -46,6 +46,7 @@
46
46
  <!-- If additional elements are needed for the demo, add them here. -->
47
47
  <script src="https://cdn.jsdelivr.net/npm/@aurodesignsystem/auro-accordion@latest/dist/auro-accordion__bundled.js" type="module"></script>
48
48
  <script src="https://cdn.jsdelivr.net/npm/@aurodesignsystem/auro-button@latest/dist/auro-button__bundled.js" type="module"></script>
49
+ <script src="https://cdn.jsdelivr.net/npm/@aurodesignsystem/auro-icon@latest/dist/auro-icon__bundled.js" type="module"></script>
49
50
 
50
51
  <script type="module" data-demo-script="true">
51
52
  import { initExamples } from "./index.min.js"