@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.
- package/CHANGELOG.md +40 -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 +35 -35
- package/components/select/demo/api.md +32 -32
- package/components/select/demo/api.min.js +99 -199
- package/components/select/demo/index.min.js +97 -197
- package/components/select/demo/readme.md +1 -1
- package/components/select/dist/auro-select.d.ts +12 -13
- package/components/select/dist/index.js +57 -72
- package/components/select/dist/registered.js +57 -72
- 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
|
|
|
@@ -5483,7 +5483,7 @@ i$5`:host{--ds-auro-menu-divider-color: var(--ds-basic-color-border-divider, rgb
|
|
|
5483
5483
|
* @throws {Error} - Throws an error if the value is not an array, undefined,
|
|
5484
5484
|
* or if the value cannot be parsed into an array from a JSON string.
|
|
5485
5485
|
*/
|
|
5486
|
-
function arrayConverter
|
|
5486
|
+
function arrayConverter(value) {
|
|
5487
5487
|
// Allow undefined
|
|
5488
5488
|
if (value === undefined) {
|
|
5489
5489
|
return undefined;
|
|
@@ -5512,61 +5512,6 @@ function arrayConverter$1(value) {
|
|
|
5512
5512
|
throw new Error('Invalid value: Input must be an array or undefined');
|
|
5513
5513
|
}
|
|
5514
5514
|
|
|
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
5515
|
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
5516
|
|
|
5572
5517
|
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)}`;
|
|
@@ -5728,7 +5673,7 @@ class AuroSelect extends i$2 {
|
|
|
5728
5673
|
|
|
5729
5674
|
/**
|
|
5730
5675
|
* If declared, make bib.fullscreen.headline in HeadingDisplay.
|
|
5731
|
-
* Otherwise, Heading 600
|
|
5676
|
+
* Otherwise, Heading 600.
|
|
5732
5677
|
*/
|
|
5733
5678
|
largeFullscreenHeadline: {
|
|
5734
5679
|
type: Boolean,
|
|
@@ -5786,12 +5731,11 @@ class AuroSelect extends i$2 {
|
|
|
5786
5731
|
},
|
|
5787
5732
|
|
|
5788
5733
|
/**
|
|
5789
|
-
* Specifies the current selected menuOption.
|
|
5734
|
+
* Specifies the current selected menuOption. Default type is `HTMLElement`, changing to `Array<HTMLElement>` when `multiSelect` is true.
|
|
5735
|
+
* @type {HTMLElement|Array<HTMLElement>}
|
|
5790
5736
|
*/
|
|
5791
5737
|
optionSelected: {
|
|
5792
|
-
|
|
5793
|
-
converter: arrayConverter$1,
|
|
5794
|
-
hasChanged: arrayOrUndefinedHasChanged$1
|
|
5738
|
+
type: Object
|
|
5795
5739
|
},
|
|
5796
5740
|
|
|
5797
5741
|
/**
|
|
@@ -5861,12 +5805,11 @@ class AuroSelect extends i$2 {
|
|
|
5861
5805
|
},
|
|
5862
5806
|
|
|
5863
5807
|
/**
|
|
5864
|
-
* Value selected for the component.
|
|
5808
|
+
* Value selected for the component. Default type is `String`, changing to `Array<String>` when `multiSelect` is true.
|
|
5809
|
+
* @type {String|Array<String>}
|
|
5865
5810
|
*/
|
|
5866
5811
|
value: {
|
|
5867
|
-
|
|
5868
|
-
converter: arrayConverter$1,
|
|
5869
|
-
hasChanged: arrayOrUndefinedHasChanged$1
|
|
5812
|
+
type: Object
|
|
5870
5813
|
},
|
|
5871
5814
|
|
|
5872
5815
|
/**
|
|
@@ -5945,9 +5888,15 @@ class AuroSelect extends i$2 {
|
|
|
5945
5888
|
}
|
|
5946
5889
|
|
|
5947
5890
|
// Handle selected options
|
|
5948
|
-
if (this.optionSelected
|
|
5949
|
-
|
|
5950
|
-
|
|
5891
|
+
if (this.optionSelected) {
|
|
5892
|
+
let displayText = '';
|
|
5893
|
+
|
|
5894
|
+
if (this.multiSelect && this.optionSelected.length > 0) {
|
|
5895
|
+
// Create display text from selected options
|
|
5896
|
+
displayText = this.optionSelected.map((option) => option.textContent).join(', ');
|
|
5897
|
+
} else {
|
|
5898
|
+
displayText = this.optionSelected.textContent;
|
|
5899
|
+
}
|
|
5951
5900
|
|
|
5952
5901
|
const span = document.createElement('span');
|
|
5953
5902
|
span.textContent = displayText;
|
|
@@ -6195,6 +6144,17 @@ class AuroSelect extends i$2 {
|
|
|
6195
6144
|
}
|
|
6196
6145
|
}
|
|
6197
6146
|
|
|
6147
|
+
/**
|
|
6148
|
+
* Resets all options to their default state.
|
|
6149
|
+
* @private
|
|
6150
|
+
*/
|
|
6151
|
+
clearSelection() {
|
|
6152
|
+
this.value = undefined;
|
|
6153
|
+
this.optionSelected = undefined;
|
|
6154
|
+
|
|
6155
|
+
this.menu.multiSelect = this.multiSelect;
|
|
6156
|
+
}
|
|
6157
|
+
|
|
6198
6158
|
/**
|
|
6199
6159
|
* Handle element attributes on update.
|
|
6200
6160
|
* @private
|
|
@@ -6231,13 +6191,20 @@ class AuroSelect extends i$2 {
|
|
|
6231
6191
|
|
|
6232
6192
|
// Set the initial value in auro-menu if defined
|
|
6233
6193
|
if (this.hasAttribute('value') && this.getAttribute('value').length > 0) {
|
|
6194
|
+
this.value = this.multiSelect ? arrayConverter(this.getAttribute('value')) : this.getAttribute('value');
|
|
6234
6195
|
this.menu.value = this.value;
|
|
6235
6196
|
}
|
|
6236
6197
|
}
|
|
6237
6198
|
|
|
6238
6199
|
async updated(changedProperties) {
|
|
6200
|
+
if (changedProperties.has('multiSelect')) {
|
|
6201
|
+
this.clearSelection();
|
|
6202
|
+
}
|
|
6203
|
+
|
|
6239
6204
|
if (changedProperties.has('value')) {
|
|
6240
6205
|
if (this.value) {
|
|
6206
|
+
this.value = this.multiSelect ? arrayConverter(this.value) : this.value;
|
|
6207
|
+
|
|
6241
6208
|
this.menu.value = this.value;
|
|
6242
6209
|
|
|
6243
6210
|
// Wait for menu to finish updating its value
|
|
@@ -6309,8 +6276,23 @@ class AuroSelect extends i$2 {
|
|
|
6309
6276
|
_handleNativeSelectChange(event) {
|
|
6310
6277
|
const selectedOption = event.target.options[event.target.selectedIndex];
|
|
6311
6278
|
const selectedValue = selectedOption.value;
|
|
6312
|
-
|
|
6313
|
-
this.
|
|
6279
|
+
|
|
6280
|
+
if (this.multiSelect) {
|
|
6281
|
+
const currentArray = Array.isArray(this.value) ? this.value : [];
|
|
6282
|
+
|
|
6283
|
+
if (!currentArray.includes(selectedValue)) {
|
|
6284
|
+
this.value = [
|
|
6285
|
+
...currentArray,
|
|
6286
|
+
selectedValue
|
|
6287
|
+
];
|
|
6288
|
+
}
|
|
6289
|
+
} else {
|
|
6290
|
+
const currentValue = this.value;
|
|
6291
|
+
|
|
6292
|
+
if (currentValue !== selectedValue) {
|
|
6293
|
+
this.value = selectedValue;
|
|
6294
|
+
}
|
|
6295
|
+
}
|
|
6314
6296
|
}
|
|
6315
6297
|
|
|
6316
6298
|
/**
|
|
@@ -6323,10 +6305,13 @@ class AuroSelect extends i$2 {
|
|
|
6323
6305
|
if (!nativeSelect) {
|
|
6324
6306
|
return;
|
|
6325
6307
|
}
|
|
6326
|
-
const [value] = this.value || [];
|
|
6327
|
-
nativeSelect.value = value || '';
|
|
6328
|
-
}
|
|
6329
6308
|
|
|
6309
|
+
if (this.multiSelect) {
|
|
6310
|
+
nativeSelect.value = this.value ? this.value[0] : '';
|
|
6311
|
+
} else {
|
|
6312
|
+
nativeSelect.value = this.value || '';
|
|
6313
|
+
}
|
|
6314
|
+
}
|
|
6330
6315
|
|
|
6331
6316
|
// When using auroElement, use the following attribute and function when hiding content from screen readers.
|
|
6332
6317
|
// aria-hidden="${this.hideAudible(this.hiddenAudible)}"
|
|
@@ -6432,102 +6417,6 @@ var tokensCss$1 = i$5`:host{--ds-auro-menu-divider-color: var(--ds-basic-color-b
|
|
|
6432
6417
|
// Copyright (c) 2021 Alaska Airlines. All right reserved. Licensed under the Apache-2.0 license
|
|
6433
6418
|
// See LICENSE in the project root for license information.
|
|
6434
6419
|
|
|
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
6420
|
|
|
6532
6421
|
/**
|
|
6533
6422
|
* Validates if an option can be interacted with.
|
|
@@ -6561,7 +6450,7 @@ function dispatchMenuEvent(element, eventName, detail = null) {
|
|
|
6561
6450
|
element.dispatchEvent(new CustomEvent(eventName, eventConfig));
|
|
6562
6451
|
}
|
|
6563
6452
|
|
|
6564
|
-
// Copyright (c)
|
|
6453
|
+
// Copyright (c) 2025 Alaska Airlines. All right reserved. Licensed under the Apache-2.0 license
|
|
6565
6454
|
// See LICENSE in the project root for license information.
|
|
6566
6455
|
|
|
6567
6456
|
|
|
@@ -6569,14 +6458,14 @@ function dispatchMenuEvent(element, eventName, detail = null) {
|
|
|
6569
6458
|
// See https://git.io/JJ6SJ for "How to document your components using JSDoc"
|
|
6570
6459
|
/**
|
|
6571
6460
|
* The auro-menu element provides users a way to select from a list of options.
|
|
6572
|
-
* @attr {Array<HTMLElement
|
|
6461
|
+
* @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
6462
|
* @attr {object} optionactive - Specifies the current active menuOption.
|
|
6574
6463
|
* @attr {string} matchword - Specifies a string used to highlight matched string parts in options.
|
|
6575
6464
|
* @attr {boolean} disabled - When true, the entire menu and all options are disabled;
|
|
6576
6465
|
* @attr {boolean} nocheckmark - When true, selected option will not show the checkmark.
|
|
6577
6466
|
* @attr {boolean} loading - When true, displays a loading state using the loadingIcon and loadingText slots if provided.
|
|
6578
6467
|
* @attr {boolean} multiselect - When true, the selected option can be multiple options.
|
|
6579
|
-
* @attr {Array<string
|
|
6468
|
+
* @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
6469
|
* @prop {boolean} hasLoadingPlaceholder - Indicates whether the menu has a loadingIcon or loadingText to render when in a loading state.
|
|
6581
6470
|
* @event {CustomEvent<Element>} auroMenu-activatedOption - Notifies that a menuoption has been made `active`.
|
|
6582
6471
|
* @event {CustomEvent<any>} auroMenu-customEventFired - Notifies that a custom event has been fired.
|
|
@@ -6589,7 +6478,7 @@ function dispatchMenuEvent(element, eventName, detail = null) {
|
|
|
6589
6478
|
* @slot - Slot for insertion of menu options.
|
|
6590
6479
|
*/
|
|
6591
6480
|
|
|
6592
|
-
/* eslint-disable no-magic-numbers, max-lines */
|
|
6481
|
+
/* eslint-disable no-magic-numbers, max-lines, no-extra-parens */
|
|
6593
6482
|
|
|
6594
6483
|
class AuroMenu extends i$2 {
|
|
6595
6484
|
constructor() {
|
|
@@ -6669,9 +6558,8 @@ class AuroMenu extends i$2 {
|
|
|
6669
6558
|
reflect: true
|
|
6670
6559
|
},
|
|
6671
6560
|
optionSelected: {
|
|
6672
|
-
// Allow HTMLElement[] arrays and undefined
|
|
6673
|
-
|
|
6674
|
-
hasChanged: arrayOrUndefinedHasChanged
|
|
6561
|
+
// Allow HTMLElement, HTMLElement[] arrays and undefined
|
|
6562
|
+
type: Object
|
|
6675
6563
|
},
|
|
6676
6564
|
optionActive: {
|
|
6677
6565
|
type: Object,
|
|
@@ -6687,10 +6575,8 @@ class AuroMenu extends i$2 {
|
|
|
6687
6575
|
attribute: 'multiselect'
|
|
6688
6576
|
},
|
|
6689
6577
|
value: {
|
|
6690
|
-
// Allow string[] arrays and undefined
|
|
6691
|
-
type: Object
|
|
6692
|
-
converter: arrayConverter,
|
|
6693
|
-
hasChanged: arrayOrUndefinedHasChanged
|
|
6578
|
+
// Allow string, string[] arrays and undefined
|
|
6579
|
+
type: Object
|
|
6694
6580
|
}
|
|
6695
6581
|
};
|
|
6696
6582
|
}
|
|
@@ -6743,30 +6629,39 @@ class AuroMenu extends i$2 {
|
|
|
6743
6629
|
}
|
|
6744
6630
|
|
|
6745
6631
|
updated(changedProperties) {
|
|
6632
|
+
if (changedProperties.has('multiSelect')) {
|
|
6633
|
+
// Reset selection if multiSelect mode changes
|
|
6634
|
+
this.clearSelection();
|
|
6635
|
+
}
|
|
6636
|
+
|
|
6746
6637
|
if (changedProperties.has('value')) {
|
|
6747
6638
|
// Handle null/undefined case
|
|
6748
6639
|
if (this.value === undefined || this.value === null) {
|
|
6749
6640
|
this.optionSelected = undefined;
|
|
6750
|
-
// Reset index tracking
|
|
6751
6641
|
this.index = -1;
|
|
6752
6642
|
} else {
|
|
6753
|
-
|
|
6754
|
-
|
|
6643
|
+
if (this.multiSelect) {
|
|
6644
|
+
// In multiselect mode, this.value should be an array of strings
|
|
6645
|
+
const valueArray = Array.isArray(this.value) ? this.value : [this.value];
|
|
6646
|
+
const matchingOptions = this.items.filter((item) => valueArray.includes(item.value));
|
|
6755
6647
|
|
|
6756
|
-
|
|
6757
|
-
|
|
6648
|
+
this.optionSelected = matchingOptions.length > 0 ? matchingOptions : undefined;
|
|
6649
|
+
} else {
|
|
6650
|
+
// In single-select mode, this.value should be a string
|
|
6651
|
+
const matchingOptions = this.items.find((item) => item.value === this.value);
|
|
6758
6652
|
|
|
6759
|
-
|
|
6760
|
-
if (this.multiSelect) {
|
|
6761
|
-
// For multiselect, keep all matching options
|
|
6653
|
+
if (matchingOptions) {
|
|
6762
6654
|
this.optionSelected = matchingOptions;
|
|
6655
|
+
this.index = this.items.indexOf(matchingOptions);
|
|
6763
6656
|
} else {
|
|
6764
|
-
//
|
|
6765
|
-
this.optionSelected =
|
|
6766
|
-
this.index =
|
|
6657
|
+
// If no matching option found, reset selection
|
|
6658
|
+
this.optionSelected = undefined;
|
|
6659
|
+
this.index = -1;
|
|
6767
6660
|
}
|
|
6768
|
-
}
|
|
6769
|
-
|
|
6661
|
+
}
|
|
6662
|
+
|
|
6663
|
+
// If no matching options were found in either mode
|
|
6664
|
+
if (!this.optionSelected || (Array.isArray(this.optionSelected) && this.optionSelected.length === 0)) {
|
|
6770
6665
|
dispatchMenuEvent(this, 'auroMenu-selectValueFailure');
|
|
6771
6666
|
this.optionSelected = undefined;
|
|
6772
6667
|
this.index = -1;
|
|
@@ -6918,8 +6813,8 @@ class AuroMenu extends i$2 {
|
|
|
6918
6813
|
}
|
|
6919
6814
|
} else {
|
|
6920
6815
|
// Single select - use arrays with single values
|
|
6921
|
-
this.value =
|
|
6922
|
-
this.optionSelected =
|
|
6816
|
+
this.value = option.value;
|
|
6817
|
+
this.optionSelected = option;
|
|
6923
6818
|
}
|
|
6924
6819
|
|
|
6925
6820
|
this.index = this.items.indexOf(option);
|
|
@@ -7241,8 +7136,13 @@ class AuroMenu extends i$2 {
|
|
|
7241
7136
|
if (!this.optionSelected) {
|
|
7242
7137
|
return false;
|
|
7243
7138
|
}
|
|
7244
|
-
|
|
7245
|
-
|
|
7139
|
+
|
|
7140
|
+
if (this.multiSelect) {
|
|
7141
|
+
// In multi-select mode, check if the option is in the selected array
|
|
7142
|
+
return Array.isArray(this.optionSelected) && this.optionSelected.some((selectedOption) => selectedOption === option);
|
|
7143
|
+
}
|
|
7144
|
+
|
|
7145
|
+
return this.optionSelected === option;
|
|
7246
7146
|
}
|
|
7247
7147
|
|
|
7248
7148
|
/**
|