@aurodesignsystem/auro-formkit 3.5.0 → 4.0.0-rc-658.1.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.
- package/CHANGELOG.md +41 -1
- package/components/checkbox/README.md +1 -1
- package/components/checkbox/demo/api.min.js +1 -1
- package/components/checkbox/demo/index.min.js +1 -1
- package/components/checkbox/demo/readme.md +1 -1
- package/components/checkbox/dist/index.js +1 -1
- package/components/checkbox/dist/registered.js +1 -1
- package/components/combobox/README.md +1 -1
- package/components/combobox/demo/api.md +27 -27
- package/components/combobox/demo/api.min.js +63 -275
- package/components/combobox/demo/index.html +1 -0
- package/components/combobox/demo/index.min.js +61 -273
- package/components/combobox/demo/readme.md +1 -1
- package/components/combobox/dist/auro-combobox.d.ts +5 -10
- package/components/combobox/dist/index.js +22 -149
- package/components/combobox/dist/registered.js +22 -149
- package/components/counter/README.md +1 -1
- package/components/counter/demo/readme.md +1 -1
- package/components/datepicker/README.md +1 -1
- package/components/datepicker/demo/readme.md +1 -1
- package/components/dropdown/README.md +1 -1
- package/components/dropdown/demo/readme.md +1 -1
- package/components/form/README.md +1 -1
- package/components/form/demo/readme.md +1 -1
- package/components/input/README.md +1 -1
- package/components/input/demo/readme.md +1 -1
- package/components/menu/README.md +1 -1
- package/components/menu/demo/api.md +11 -11
- package/components/menu/demo/api.min.js +39 -124
- package/components/menu/demo/index.min.js +39 -124
- package/components/menu/demo/readme.md +1 -1
- package/components/menu/dist/auro-menu-utils.d.ts +0 -8
- package/components/menu/dist/auro-menu.d.ts +3 -8
- package/components/menu/dist/index.d.ts +1 -1
- package/components/menu/dist/index.js +40 -84
- package/components/menu/dist/registered.js +39 -124
- package/components/radio/README.md +1 -1
- package/components/radio/demo/api.md +8 -0
- package/components/radio/demo/api.min.js +13 -5
- package/components/radio/demo/index.min.js +13 -5
- package/components/radio/demo/readme.md +1 -1
- package/components/radio/dist/auro-radio.d.ts +4 -0
- package/components/radio/dist/index.js +13 -5
- package/components/radio/dist/registered.js +13 -5
- package/components/select/README.md +1 -1
- package/components/select/demo/api.js +2 -0
- package/components/select/demo/api.md +96 -38
- package/components/select/demo/api.min.js +127 -210
- package/components/select/demo/index.min.js +113 -208
- package/components/select/demo/readme.md +1 -1
- package/components/select/dist/auro-select.d.ts +14 -14
- package/components/select/dist/index.js +73 -83
- package/components/select/dist/registered.js +73 -83
- package/package.json +1 -1
|
@@ -14,11 +14,11 @@ function valueExample() {
|
|
|
14
14
|
const valueExample = document.querySelector('#valueExample');
|
|
15
15
|
|
|
16
16
|
document.querySelector('#validValueExampleBtn').addEventListener('click', () => {
|
|
17
|
-
valueExample.value = [
|
|
17
|
+
valueExample.value = '["arrival", "prefer alaska"]';
|
|
18
18
|
});
|
|
19
19
|
|
|
20
20
|
document.querySelector('#invalidValueExampleBtn').addEventListener('click', () => {
|
|
21
|
-
valueExample.value = [
|
|
21
|
+
valueExample.value = '["flight course"]';
|
|
22
22
|
});
|
|
23
23
|
}
|
|
24
24
|
|
|
@@ -90,6 +90,17 @@ function auroMenuLoadingExample() {
|
|
|
90
90
|
});
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
+
function valueTextExample() {
|
|
94
|
+
const onValueTextSelectInput = (e) => {
|
|
95
|
+
const valueText = e.target.querySelector("[slot=valueText]");
|
|
96
|
+
|
|
97
|
+
valueText.textContent = e.detail.optionSelected.dataset.display;
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
const select = document.querySelector("#valueTextExample");
|
|
101
|
+
select.addEventListener('input', onValueTextSelectInput);
|
|
102
|
+
}
|
|
103
|
+
|
|
93
104
|
/**
|
|
94
105
|
* @license
|
|
95
106
|
* Copyright 2019 Google LLC
|
|
@@ -5483,7 +5494,7 @@ i$5`:host{--ds-auro-menu-divider-color: var(--ds-basic-color-border-divider, rgb
|
|
|
5483
5494
|
* @throws {Error} - Throws an error if the value is not an array, undefined,
|
|
5484
5495
|
* or if the value cannot be parsed into an array from a JSON string.
|
|
5485
5496
|
*/
|
|
5486
|
-
function arrayConverter
|
|
5497
|
+
function arrayConverter(value) {
|
|
5487
5498
|
// Allow undefined
|
|
5488
5499
|
if (value === undefined) {
|
|
5489
5500
|
return undefined;
|
|
@@ -5512,61 +5523,6 @@ function arrayConverter$1(value) {
|
|
|
5512
5523
|
throw new Error('Invalid value: Input must be an array or undefined');
|
|
5513
5524
|
}
|
|
5514
5525
|
|
|
5515
|
-
/**
|
|
5516
|
-
* Compare two arrays for equality.
|
|
5517
|
-
* @private
|
|
5518
|
-
* @param {Array} arr1 - First array to compare.
|
|
5519
|
-
* @param {Array} arr2 - Second array to compare.
|
|
5520
|
-
* @returns {boolean} True if arrays are equal.
|
|
5521
|
-
*/
|
|
5522
|
-
function arraysAreEqual$1(arr1, arr2) {
|
|
5523
|
-
// If both arrays undefined, they are equal (true)
|
|
5524
|
-
if (arr1 === undefined || arr2 === undefined) {
|
|
5525
|
-
return arr1 === arr2;
|
|
5526
|
-
}
|
|
5527
|
-
|
|
5528
|
-
// If arrays have different lengths, they are not equal
|
|
5529
|
-
if (arr1.length !== arr2.length) {
|
|
5530
|
-
return false;
|
|
5531
|
-
}
|
|
5532
|
-
|
|
5533
|
-
// If every item at each index is the same, return true
|
|
5534
|
-
for (let index = 0; index < arr1.length; index += 1) {
|
|
5535
|
-
if (arr1[index] !== arr2[index]) {
|
|
5536
|
-
return false;
|
|
5537
|
-
}
|
|
5538
|
-
}
|
|
5539
|
-
return true;
|
|
5540
|
-
}
|
|
5541
|
-
|
|
5542
|
-
/**
|
|
5543
|
-
* Compares array for changes.
|
|
5544
|
-
* @private
|
|
5545
|
-
* @param {Array|any} newVal - New value to compare.
|
|
5546
|
-
* @param {Array|any} oldVal - Old value to compare.
|
|
5547
|
-
* @returns {boolean} True if arrays have changed.
|
|
5548
|
-
*/
|
|
5549
|
-
function arrayOrUndefinedHasChanged$1(newVal, oldVal) {
|
|
5550
|
-
try {
|
|
5551
|
-
// Check if values are undefined or arrays
|
|
5552
|
-
const isArrayOrUndefined = (val) => val === undefined || Array.isArray(val);
|
|
5553
|
-
|
|
5554
|
-
// If non-array or non-undefined, throw error
|
|
5555
|
-
if (!isArrayOrUndefined(newVal) || !isArrayOrUndefined(oldVal)) {
|
|
5556
|
-
const invalidValue = isArrayOrUndefined(newVal) ? oldVal : newVal;
|
|
5557
|
-
throw new Error(`Value must be an array or undefined, received ${typeof invalidValue}`);
|
|
5558
|
-
}
|
|
5559
|
-
|
|
5560
|
-
// Return true if arrays have changed, false if they are the same
|
|
5561
|
-
return !arraysAreEqual$1(newVal, oldVal);
|
|
5562
|
-
} catch (error) {
|
|
5563
|
-
/* eslint-disable no-console */
|
|
5564
|
-
console.error(error);
|
|
5565
|
-
// If validation fails, it has changed
|
|
5566
|
-
return true;
|
|
5567
|
-
}
|
|
5568
|
-
}
|
|
5569
|
-
|
|
5570
5526
|
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}`;
|
|
5571
5527
|
|
|
5572
5528
|
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)}`;
|
|
@@ -5592,8 +5548,9 @@ var styleCss$3 = i$5`:focus:not(:focus-visible){outline:3px solid transparent}.u
|
|
|
5592
5548
|
* @slot label - Defines the content of the label.
|
|
5593
5549
|
* @slot helpText - Defines the content of the helpText.
|
|
5594
5550
|
* @slot placeholder - Defines the content of the placeholder to be shown when there is no value
|
|
5551
|
+
* @slot valueText - Dropdown value text display.
|
|
5595
5552
|
* @event auroSelect-valueSet - Notifies that the component has a new value set.
|
|
5596
|
-
* @event input - Notifies every time the value prop of the element is changed.
|
|
5553
|
+
* @event input - Notifies every time the value prop of the element is changed. The updated `value` and `optionSelected` will be delivered in `detail` object.
|
|
5597
5554
|
* @event auroFormElement-validated - Notifies that the `validity` and `errorMessage` values have changed.
|
|
5598
5555
|
* @csspart helpText - Apply CSS to the help text.
|
|
5599
5556
|
*/
|
|
@@ -5728,7 +5685,7 @@ class AuroSelect extends i$2 {
|
|
|
5728
5685
|
|
|
5729
5686
|
/**
|
|
5730
5687
|
* If declared, make bib.fullscreen.headline in HeadingDisplay.
|
|
5731
|
-
* Otherwise, Heading 600
|
|
5688
|
+
* Otherwise, Heading 600.
|
|
5732
5689
|
*/
|
|
5733
5690
|
largeFullscreenHeadline: {
|
|
5734
5691
|
type: Boolean,
|
|
@@ -5786,12 +5743,11 @@ class AuroSelect extends i$2 {
|
|
|
5786
5743
|
},
|
|
5787
5744
|
|
|
5788
5745
|
/**
|
|
5789
|
-
* Specifies the current selected menuOption.
|
|
5746
|
+
* Specifies the current selected menuOption. Default type is `HTMLElement`, changing to `Array<HTMLElement>` when `multiSelect` is true.
|
|
5747
|
+
* @type {HTMLElement|Array<HTMLElement>}
|
|
5790
5748
|
*/
|
|
5791
5749
|
optionSelected: {
|
|
5792
|
-
|
|
5793
|
-
converter: arrayConverter$1,
|
|
5794
|
-
hasChanged: arrayOrUndefinedHasChanged$1
|
|
5750
|
+
type: Object
|
|
5795
5751
|
},
|
|
5796
5752
|
|
|
5797
5753
|
/**
|
|
@@ -5861,12 +5817,11 @@ class AuroSelect extends i$2 {
|
|
|
5861
5817
|
},
|
|
5862
5818
|
|
|
5863
5819
|
/**
|
|
5864
|
-
* Value selected for the component.
|
|
5820
|
+
* Value selected for the component. Default type is `String`, changing to `Array<String>` when `multiSelect` is true.
|
|
5821
|
+
* @type {String|Array<String>}
|
|
5865
5822
|
*/
|
|
5866
5823
|
value: {
|
|
5867
|
-
|
|
5868
|
-
converter: arrayConverter$1,
|
|
5869
|
-
hasChanged: arrayOrUndefinedHasChanged$1
|
|
5824
|
+
type: Object
|
|
5870
5825
|
},
|
|
5871
5826
|
|
|
5872
5827
|
/**
|
|
@@ -5937,21 +5892,21 @@ class AuroSelect extends i$2 {
|
|
|
5937
5892
|
updateDisplayedValue() {
|
|
5938
5893
|
const triggerContentEl = this.dropdown.querySelector('#triggerFocus');
|
|
5939
5894
|
|
|
5940
|
-
|
|
5941
|
-
|
|
5942
|
-
triggerContentEl.innerHTML = '';
|
|
5943
|
-
if (placeholder) {
|
|
5944
|
-
triggerContentEl.appendChild(placeholder);
|
|
5945
|
-
}
|
|
5895
|
+
const valueText = triggerContentEl.querySelector("#valueText");
|
|
5896
|
+
valueText.textContent = '';
|
|
5946
5897
|
|
|
5947
5898
|
// Handle selected options
|
|
5948
|
-
if (this.optionSelected
|
|
5949
|
-
|
|
5950
|
-
|
|
5899
|
+
if (this.optionSelected) {
|
|
5900
|
+
let displayText = '';
|
|
5901
|
+
|
|
5902
|
+
if (this.multiSelect && this.optionSelected.length > 0) {
|
|
5903
|
+
// Create display text from selected options
|
|
5904
|
+
displayText = this.optionSelected.map((option) => option.textContent).join(', ');
|
|
5905
|
+
} else {
|
|
5906
|
+
displayText = this.optionSelected.textContent;
|
|
5907
|
+
}
|
|
5951
5908
|
|
|
5952
|
-
|
|
5953
|
-
span.textContent = displayText;
|
|
5954
|
-
triggerContentEl.appendChild(span);
|
|
5909
|
+
valueText.textContent = displayText;
|
|
5955
5910
|
}
|
|
5956
5911
|
|
|
5957
5912
|
this.dropdown.requestUpdate();
|
|
@@ -6195,6 +6150,17 @@ class AuroSelect extends i$2 {
|
|
|
6195
6150
|
}
|
|
6196
6151
|
}
|
|
6197
6152
|
|
|
6153
|
+
/**
|
|
6154
|
+
* Resets all options to their default state.
|
|
6155
|
+
* @private
|
|
6156
|
+
*/
|
|
6157
|
+
clearSelection() {
|
|
6158
|
+
this.value = undefined;
|
|
6159
|
+
this.optionSelected = undefined;
|
|
6160
|
+
|
|
6161
|
+
this.menu.multiSelect = this.multiSelect;
|
|
6162
|
+
}
|
|
6163
|
+
|
|
6198
6164
|
/**
|
|
6199
6165
|
* Handle element attributes on update.
|
|
6200
6166
|
* @private
|
|
@@ -6231,13 +6197,20 @@ class AuroSelect extends i$2 {
|
|
|
6231
6197
|
|
|
6232
6198
|
// Set the initial value in auro-menu if defined
|
|
6233
6199
|
if (this.hasAttribute('value') && this.getAttribute('value').length > 0) {
|
|
6200
|
+
this.value = this.multiSelect ? arrayConverter(this.getAttribute('value')) : this.getAttribute('value');
|
|
6234
6201
|
this.menu.value = this.value;
|
|
6235
6202
|
}
|
|
6236
6203
|
}
|
|
6237
6204
|
|
|
6238
6205
|
async updated(changedProperties) {
|
|
6206
|
+
if (changedProperties.has('multiSelect')) {
|
|
6207
|
+
this.clearSelection();
|
|
6208
|
+
}
|
|
6209
|
+
|
|
6239
6210
|
if (changedProperties.has('value')) {
|
|
6240
6211
|
if (this.value) {
|
|
6212
|
+
this.value = this.multiSelect ? arrayConverter(this.value) : this.value;
|
|
6213
|
+
|
|
6241
6214
|
this.menu.value = this.value;
|
|
6242
6215
|
|
|
6243
6216
|
// Wait for menu to finish updating its value
|
|
@@ -6262,6 +6235,10 @@ class AuroSelect extends i$2 {
|
|
|
6262
6235
|
bubbles: true,
|
|
6263
6236
|
cancelable: true,
|
|
6264
6237
|
composed: true,
|
|
6238
|
+
detail: {
|
|
6239
|
+
optionSelected: this.optionSelected,
|
|
6240
|
+
value: this.value
|
|
6241
|
+
}
|
|
6265
6242
|
}));
|
|
6266
6243
|
}
|
|
6267
6244
|
|
|
@@ -6309,8 +6286,23 @@ class AuroSelect extends i$2 {
|
|
|
6309
6286
|
_handleNativeSelectChange(event) {
|
|
6310
6287
|
const selectedOption = event.target.options[event.target.selectedIndex];
|
|
6311
6288
|
const selectedValue = selectedOption.value;
|
|
6312
|
-
|
|
6313
|
-
this.
|
|
6289
|
+
|
|
6290
|
+
if (this.multiSelect) {
|
|
6291
|
+
const currentArray = Array.isArray(this.value) ? this.value : [];
|
|
6292
|
+
|
|
6293
|
+
if (!currentArray.includes(selectedValue)) {
|
|
6294
|
+
this.value = [
|
|
6295
|
+
...currentArray,
|
|
6296
|
+
selectedValue
|
|
6297
|
+
];
|
|
6298
|
+
}
|
|
6299
|
+
} else {
|
|
6300
|
+
const currentValue = this.value;
|
|
6301
|
+
|
|
6302
|
+
if (currentValue !== selectedValue) {
|
|
6303
|
+
this.value = selectedValue;
|
|
6304
|
+
}
|
|
6305
|
+
}
|
|
6314
6306
|
}
|
|
6315
6307
|
|
|
6316
6308
|
/**
|
|
@@ -6323,10 +6315,13 @@ class AuroSelect extends i$2 {
|
|
|
6323
6315
|
if (!nativeSelect) {
|
|
6324
6316
|
return;
|
|
6325
6317
|
}
|
|
6326
|
-
const [value] = this.value || [];
|
|
6327
|
-
nativeSelect.value = value || '';
|
|
6328
|
-
}
|
|
6329
6318
|
|
|
6319
|
+
if (this.multiSelect) {
|
|
6320
|
+
nativeSelect.value = this.value ? this.value[0] : '';
|
|
6321
|
+
} else {
|
|
6322
|
+
nativeSelect.value = this.value || '';
|
|
6323
|
+
}
|
|
6324
|
+
}
|
|
6330
6325
|
|
|
6331
6326
|
// When using auroElement, use the following attribute and function when hiding content from screen readers.
|
|
6332
6327
|
// aria-hidden="${this.hideAudible(this.hiddenAudible)}"
|
|
@@ -6372,7 +6367,13 @@ class AuroSelect extends i$2 {
|
|
|
6372
6367
|
?noFlip="${this.noFlip}"
|
|
6373
6368
|
part="dropdown">
|
|
6374
6369
|
<span slot="trigger" aria-haspopup="true" id="triggerFocus">
|
|
6375
|
-
<span id="placeholder"
|
|
6370
|
+
<span id="placeholder"
|
|
6371
|
+
class="${e(placeholderClass)}"
|
|
6372
|
+
?aria-hidden="${this.optionSelected && this.optionSelected.length ? 'true' : false}"
|
|
6373
|
+
>
|
|
6374
|
+
<slot name="placeholder"></slot>
|
|
6375
|
+
</span>
|
|
6376
|
+
<slot name="valueText" id="valueText"></slot>
|
|
6376
6377
|
</span>
|
|
6377
6378
|
|
|
6378
6379
|
<div class="menuWrapper">
|
|
@@ -6432,102 +6433,6 @@ var tokensCss$1 = i$5`:host{--ds-auro-menu-divider-color: var(--ds-basic-color-b
|
|
|
6432
6433
|
// Copyright (c) 2021 Alaska Airlines. All right reserved. Licensed under the Apache-2.0 license
|
|
6433
6434
|
// See LICENSE in the project root for license information.
|
|
6434
6435
|
|
|
6435
|
-
// ---------------------------------------------------------------------
|
|
6436
|
-
|
|
6437
|
-
/**
|
|
6438
|
-
* Converts value to an array.
|
|
6439
|
-
* If the value is a JSON string representing an array, it will be parsed.
|
|
6440
|
-
* If the value is already an array, it is returned.
|
|
6441
|
-
* If the value is undefined, it returns undefined.
|
|
6442
|
-
* @private
|
|
6443
|
-
* @param {any} value - The value to be converted. Can be a string, array, or undefined.
|
|
6444
|
-
* @returns {Array|undefined} - The converted array or undefined.
|
|
6445
|
-
* @throws {Error} - Throws an error if the value is not an array, undefined,
|
|
6446
|
-
* or if the value cannot be parsed into an array from a JSON string.
|
|
6447
|
-
*/
|
|
6448
|
-
function arrayConverter(value) {
|
|
6449
|
-
// Allow undefined
|
|
6450
|
-
if (value === undefined) {
|
|
6451
|
-
return undefined;
|
|
6452
|
-
}
|
|
6453
|
-
|
|
6454
|
-
// Return the value if it is already an array
|
|
6455
|
-
if (Array.isArray(value)) {
|
|
6456
|
-
return value;
|
|
6457
|
-
}
|
|
6458
|
-
|
|
6459
|
-
try {
|
|
6460
|
-
// If value is a JSON string, parse it
|
|
6461
|
-
const parsed = typeof value === 'string' ? JSON.parse(value) : value;
|
|
6462
|
-
|
|
6463
|
-
// Check if the parsed value is an array
|
|
6464
|
-
if (Array.isArray(parsed)) {
|
|
6465
|
-
return parsed;
|
|
6466
|
-
}
|
|
6467
|
-
} catch (error) {
|
|
6468
|
-
// If JSON parsing fails, continue to throw an error below
|
|
6469
|
-
/* eslint-disable no-console */
|
|
6470
|
-
console.error('JSON parsing failed:', error);
|
|
6471
|
-
}
|
|
6472
|
-
|
|
6473
|
-
// Throw error if the input is not an array or undefined
|
|
6474
|
-
throw new Error('Invalid value: Input must be an array or undefined');
|
|
6475
|
-
}
|
|
6476
|
-
|
|
6477
|
-
/**
|
|
6478
|
-
* Compare two arrays for equality.
|
|
6479
|
-
* @private
|
|
6480
|
-
* @param {Array} arr1 - First array to compare.
|
|
6481
|
-
* @param {Array} arr2 - Second array to compare.
|
|
6482
|
-
* @returns {boolean} True if arrays are equal.
|
|
6483
|
-
*/
|
|
6484
|
-
function arraysAreEqual(arr1, arr2) {
|
|
6485
|
-
// If both arrays undefined, they are equal (true)
|
|
6486
|
-
if (arr1 === undefined || arr2 === undefined) {
|
|
6487
|
-
return arr1 === arr2;
|
|
6488
|
-
}
|
|
6489
|
-
|
|
6490
|
-
// If arrays have different lengths, they are not equal
|
|
6491
|
-
if (arr1.length !== arr2.length) {
|
|
6492
|
-
return false;
|
|
6493
|
-
}
|
|
6494
|
-
|
|
6495
|
-
// If every item at each index is the same, return true
|
|
6496
|
-
for (let index = 0; index < arr1.length; index += 1) {
|
|
6497
|
-
if (arr1[index] !== arr2[index]) {
|
|
6498
|
-
return false;
|
|
6499
|
-
}
|
|
6500
|
-
}
|
|
6501
|
-
return true;
|
|
6502
|
-
}
|
|
6503
|
-
|
|
6504
|
-
/**
|
|
6505
|
-
* Compares array for changes.
|
|
6506
|
-
* @private
|
|
6507
|
-
* @param {Array|any} newVal - New value to compare.
|
|
6508
|
-
* @param {Array|any} oldVal - Old value to compare.
|
|
6509
|
-
* @returns {boolean} True if arrays have changed.
|
|
6510
|
-
*/
|
|
6511
|
-
function arrayOrUndefinedHasChanged(newVal, oldVal) {
|
|
6512
|
-
try {
|
|
6513
|
-
// Check if values are undefined or arrays
|
|
6514
|
-
const isArrayOrUndefined = (val) => val === undefined || Array.isArray(val);
|
|
6515
|
-
|
|
6516
|
-
// If non-array or non-undefined, throw error
|
|
6517
|
-
if (!isArrayOrUndefined(newVal) || !isArrayOrUndefined(oldVal)) {
|
|
6518
|
-
const invalidValue = isArrayOrUndefined(newVal) ? oldVal : newVal;
|
|
6519
|
-
throw new Error(`Value must be an array or undefined, received ${typeof invalidValue}`);
|
|
6520
|
-
}
|
|
6521
|
-
|
|
6522
|
-
// Return true if arrays have changed, false if they are the same
|
|
6523
|
-
return !arraysAreEqual(newVal, oldVal);
|
|
6524
|
-
} catch (error) {
|
|
6525
|
-
/* eslint-disable no-console */
|
|
6526
|
-
console.error(error);
|
|
6527
|
-
// If validation fails, it has changed
|
|
6528
|
-
return true;
|
|
6529
|
-
}
|
|
6530
|
-
}
|
|
6531
6436
|
|
|
6532
6437
|
/**
|
|
6533
6438
|
* Validates if an option can be interacted with.
|
|
@@ -6561,7 +6466,7 @@ function dispatchMenuEvent(element, eventName, detail = null) {
|
|
|
6561
6466
|
element.dispatchEvent(new CustomEvent(eventName, eventConfig));
|
|
6562
6467
|
}
|
|
6563
6468
|
|
|
6564
|
-
// Copyright (c)
|
|
6469
|
+
// Copyright (c) 2025 Alaska Airlines. All right reserved. Licensed under the Apache-2.0 license
|
|
6565
6470
|
// See LICENSE in the project root for license information.
|
|
6566
6471
|
|
|
6567
6472
|
|
|
@@ -6569,14 +6474,14 @@ function dispatchMenuEvent(element, eventName, detail = null) {
|
|
|
6569
6474
|
// See https://git.io/JJ6SJ for "How to document your components using JSDoc"
|
|
6570
6475
|
/**
|
|
6571
6476
|
* The auro-menu element provides users a way to select from a list of options.
|
|
6572
|
-
* @attr {Array<HTMLElement
|
|
6477
|
+
* @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.
|
|
6573
6478
|
* @attr {object} optionactive - Specifies the current active menuOption.
|
|
6574
6479
|
* @attr {string} matchword - Specifies a string used to highlight matched string parts in options.
|
|
6575
6480
|
* @attr {boolean} disabled - When true, the entire menu and all options are disabled;
|
|
6576
6481
|
* @attr {boolean} nocheckmark - When true, selected option will not show the checkmark.
|
|
6577
6482
|
* @attr {boolean} loading - When true, displays a loading state using the loadingIcon and loadingText slots if provided.
|
|
6578
6483
|
* @attr {boolean} multiselect - When true, the selected option can be multiple options.
|
|
6579
|
-
* @attr {Array<string
|
|
6484
|
+
* @attr {String|Array<string>} value - Value selected for the menu, type `string` by default. In multi-select mode, `value` is an array of strings.
|
|
6580
6485
|
* @prop {boolean} hasLoadingPlaceholder - Indicates whether the menu has a loadingIcon or loadingText to render when in a loading state.
|
|
6581
6486
|
* @event {CustomEvent<Element>} auroMenu-activatedOption - Notifies that a menuoption has been made `active`.
|
|
6582
6487
|
* @event {CustomEvent<any>} auroMenu-customEventFired - Notifies that a custom event has been fired.
|
|
@@ -6589,7 +6494,7 @@ function dispatchMenuEvent(element, eventName, detail = null) {
|
|
|
6589
6494
|
* @slot - Slot for insertion of menu options.
|
|
6590
6495
|
*/
|
|
6591
6496
|
|
|
6592
|
-
/* eslint-disable no-magic-numbers, max-lines */
|
|
6497
|
+
/* eslint-disable no-magic-numbers, max-lines, no-extra-parens */
|
|
6593
6498
|
|
|
6594
6499
|
class AuroMenu extends i$2 {
|
|
6595
6500
|
constructor() {
|
|
@@ -6669,9 +6574,8 @@ class AuroMenu extends i$2 {
|
|
|
6669
6574
|
reflect: true
|
|
6670
6575
|
},
|
|
6671
6576
|
optionSelected: {
|
|
6672
|
-
// Allow HTMLElement[] arrays and undefined
|
|
6673
|
-
|
|
6674
|
-
hasChanged: arrayOrUndefinedHasChanged
|
|
6577
|
+
// Allow HTMLElement, HTMLElement[] arrays and undefined
|
|
6578
|
+
type: Object
|
|
6675
6579
|
},
|
|
6676
6580
|
optionActive: {
|
|
6677
6581
|
type: Object,
|
|
@@ -6687,10 +6591,8 @@ class AuroMenu extends i$2 {
|
|
|
6687
6591
|
attribute: 'multiselect'
|
|
6688
6592
|
},
|
|
6689
6593
|
value: {
|
|
6690
|
-
// Allow string[] arrays and undefined
|
|
6691
|
-
type: Object
|
|
6692
|
-
converter: arrayConverter,
|
|
6693
|
-
hasChanged: arrayOrUndefinedHasChanged
|
|
6594
|
+
// Allow string, string[] arrays and undefined
|
|
6595
|
+
type: Object
|
|
6694
6596
|
}
|
|
6695
6597
|
};
|
|
6696
6598
|
}
|
|
@@ -6743,30 +6645,39 @@ class AuroMenu extends i$2 {
|
|
|
6743
6645
|
}
|
|
6744
6646
|
|
|
6745
6647
|
updated(changedProperties) {
|
|
6648
|
+
if (changedProperties.has('multiSelect')) {
|
|
6649
|
+
// Reset selection if multiSelect mode changes
|
|
6650
|
+
this.clearSelection();
|
|
6651
|
+
}
|
|
6652
|
+
|
|
6746
6653
|
if (changedProperties.has('value')) {
|
|
6747
6654
|
// Handle null/undefined case
|
|
6748
6655
|
if (this.value === undefined || this.value === null) {
|
|
6749
6656
|
this.optionSelected = undefined;
|
|
6750
|
-
// Reset index tracking
|
|
6751
6657
|
this.index = -1;
|
|
6752
6658
|
} else {
|
|
6753
|
-
|
|
6754
|
-
|
|
6659
|
+
if (this.multiSelect) {
|
|
6660
|
+
// In multiselect mode, this.value should be an array of strings
|
|
6661
|
+
const valueArray = Array.isArray(this.value) ? this.value : [this.value];
|
|
6662
|
+
const matchingOptions = this.items.filter((item) => valueArray.includes(item.value));
|
|
6755
6663
|
|
|
6756
|
-
|
|
6757
|
-
|
|
6664
|
+
this.optionSelected = matchingOptions.length > 0 ? matchingOptions : undefined;
|
|
6665
|
+
} else {
|
|
6666
|
+
// In single-select mode, this.value should be a string
|
|
6667
|
+
const matchingOptions = this.items.find((item) => item.value === this.value);
|
|
6758
6668
|
|
|
6759
|
-
|
|
6760
|
-
if (this.multiSelect) {
|
|
6761
|
-
// For multiselect, keep all matching options
|
|
6669
|
+
if (matchingOptions) {
|
|
6762
6670
|
this.optionSelected = matchingOptions;
|
|
6671
|
+
this.index = this.items.indexOf(matchingOptions);
|
|
6763
6672
|
} else {
|
|
6764
|
-
//
|
|
6765
|
-
this.optionSelected =
|
|
6766
|
-
this.index =
|
|
6673
|
+
// If no matching option found, reset selection
|
|
6674
|
+
this.optionSelected = undefined;
|
|
6675
|
+
this.index = -1;
|
|
6767
6676
|
}
|
|
6768
|
-
}
|
|
6769
|
-
|
|
6677
|
+
}
|
|
6678
|
+
|
|
6679
|
+
// If no matching options were found in either mode
|
|
6680
|
+
if (!this.optionSelected || (Array.isArray(this.optionSelected) && this.optionSelected.length === 0)) {
|
|
6770
6681
|
dispatchMenuEvent(this, 'auroMenu-selectValueFailure');
|
|
6771
6682
|
this.optionSelected = undefined;
|
|
6772
6683
|
this.index = -1;
|
|
@@ -6918,8 +6829,8 @@ class AuroMenu extends i$2 {
|
|
|
6918
6829
|
}
|
|
6919
6830
|
} else {
|
|
6920
6831
|
// Single select - use arrays with single values
|
|
6921
|
-
this.value =
|
|
6922
|
-
this.optionSelected =
|
|
6832
|
+
this.value = option.value;
|
|
6833
|
+
this.optionSelected = option;
|
|
6923
6834
|
}
|
|
6924
6835
|
|
|
6925
6836
|
this.index = this.items.indexOf(option);
|
|
@@ -7241,8 +7152,13 @@ class AuroMenu extends i$2 {
|
|
|
7241
7152
|
if (!this.optionSelected) {
|
|
7242
7153
|
return false;
|
|
7243
7154
|
}
|
|
7244
|
-
|
|
7245
|
-
|
|
7155
|
+
|
|
7156
|
+
if (this.multiSelect) {
|
|
7157
|
+
// In multi-select mode, check if the option is in the selected array
|
|
7158
|
+
return Array.isArray(this.optionSelected) && this.optionSelected.some((selectedOption) => selectedOption === option);
|
|
7159
|
+
}
|
|
7160
|
+
|
|
7161
|
+
return this.optionSelected === option;
|
|
7246
7162
|
}
|
|
7247
7163
|
|
|
7248
7164
|
/**
|
|
@@ -7750,6 +7666,7 @@ function initExamples(initCount) {
|
|
|
7750
7666
|
inDialogExample();
|
|
7751
7667
|
resetStateExample();
|
|
7752
7668
|
auroMenuLoadingExample();
|
|
7669
|
+
valueTextExample();
|
|
7753
7670
|
} catch (err) {
|
|
7754
7671
|
if (initCount <= 20) {
|
|
7755
7672
|
// setTimeout handles issue where content is sometimes loaded after the functions get called
|