@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
|
@@ -5391,7 +5391,7 @@ i$5`:host{--ds-auro-menu-divider-color: var(--ds-basic-color-border-divider, rgb
|
|
|
5391
5391
|
* @throws {Error} - Throws an error if the value is not an array, undefined,
|
|
5392
5392
|
* or if the value cannot be parsed into an array from a JSON string.
|
|
5393
5393
|
*/
|
|
5394
|
-
function arrayConverter
|
|
5394
|
+
function arrayConverter(value) {
|
|
5395
5395
|
// Allow undefined
|
|
5396
5396
|
if (value === undefined) {
|
|
5397
5397
|
return undefined;
|
|
@@ -5420,61 +5420,6 @@ function arrayConverter$1(value) {
|
|
|
5420
5420
|
throw new Error('Invalid value: Input must be an array or undefined');
|
|
5421
5421
|
}
|
|
5422
5422
|
|
|
5423
|
-
/**
|
|
5424
|
-
* Compare two arrays for equality.
|
|
5425
|
-
* @private
|
|
5426
|
-
* @param {Array} arr1 - First array to compare.
|
|
5427
|
-
* @param {Array} arr2 - Second array to compare.
|
|
5428
|
-
* @returns {boolean} True if arrays are equal.
|
|
5429
|
-
*/
|
|
5430
|
-
function arraysAreEqual$1(arr1, arr2) {
|
|
5431
|
-
// If both arrays undefined, they are equal (true)
|
|
5432
|
-
if (arr1 === undefined || arr2 === undefined) {
|
|
5433
|
-
return arr1 === arr2;
|
|
5434
|
-
}
|
|
5435
|
-
|
|
5436
|
-
// If arrays have different lengths, they are not equal
|
|
5437
|
-
if (arr1.length !== arr2.length) {
|
|
5438
|
-
return false;
|
|
5439
|
-
}
|
|
5440
|
-
|
|
5441
|
-
// If every item at each index is the same, return true
|
|
5442
|
-
for (let index = 0; index < arr1.length; index += 1) {
|
|
5443
|
-
if (arr1[index] !== arr2[index]) {
|
|
5444
|
-
return false;
|
|
5445
|
-
}
|
|
5446
|
-
}
|
|
5447
|
-
return true;
|
|
5448
|
-
}
|
|
5449
|
-
|
|
5450
|
-
/**
|
|
5451
|
-
* Compares array for changes.
|
|
5452
|
-
* @private
|
|
5453
|
-
* @param {Array|any} newVal - New value to compare.
|
|
5454
|
-
* @param {Array|any} oldVal - Old value to compare.
|
|
5455
|
-
* @returns {boolean} True if arrays have changed.
|
|
5456
|
-
*/
|
|
5457
|
-
function arrayOrUndefinedHasChanged$1(newVal, oldVal) {
|
|
5458
|
-
try {
|
|
5459
|
-
// Check if values are undefined or arrays
|
|
5460
|
-
const isArrayOrUndefined = (val) => val === undefined || Array.isArray(val);
|
|
5461
|
-
|
|
5462
|
-
// If non-array or non-undefined, throw error
|
|
5463
|
-
if (!isArrayOrUndefined(newVal) || !isArrayOrUndefined(oldVal)) {
|
|
5464
|
-
const invalidValue = isArrayOrUndefined(newVal) ? oldVal : newVal;
|
|
5465
|
-
throw new Error(`Value must be an array or undefined, received ${typeof invalidValue}`);
|
|
5466
|
-
}
|
|
5467
|
-
|
|
5468
|
-
// Return true if arrays have changed, false if they are the same
|
|
5469
|
-
return !arraysAreEqual$1(newVal, oldVal);
|
|
5470
|
-
} catch (error) {
|
|
5471
|
-
/* eslint-disable no-console */
|
|
5472
|
-
console.error(error);
|
|
5473
|
-
// If validation fails, it has changed
|
|
5474
|
-
return true;
|
|
5475
|
-
}
|
|
5476
|
-
}
|
|
5477
|
-
|
|
5478
5423
|
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}`;
|
|
5479
5424
|
|
|
5480
5425
|
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)}`;
|
|
@@ -5500,8 +5445,9 @@ var styleCss$3 = i$5`:focus:not(:focus-visible){outline:3px solid transparent}.u
|
|
|
5500
5445
|
* @slot label - Defines the content of the label.
|
|
5501
5446
|
* @slot helpText - Defines the content of the helpText.
|
|
5502
5447
|
* @slot placeholder - Defines the content of the placeholder to be shown when there is no value
|
|
5448
|
+
* @slot valueText - Dropdown value text display.
|
|
5503
5449
|
* @event auroSelect-valueSet - Notifies that the component has a new value set.
|
|
5504
|
-
* @event input - Notifies every time the value prop of the element is changed.
|
|
5450
|
+
* @event input - Notifies every time the value prop of the element is changed. The updated `value` and `optionSelected` will be delivered in `detail` object.
|
|
5505
5451
|
* @event auroFormElement-validated - Notifies that the `validity` and `errorMessage` values have changed.
|
|
5506
5452
|
* @csspart helpText - Apply CSS to the help text.
|
|
5507
5453
|
*/
|
|
@@ -5636,7 +5582,7 @@ class AuroSelect extends i$2 {
|
|
|
5636
5582
|
|
|
5637
5583
|
/**
|
|
5638
5584
|
* If declared, make bib.fullscreen.headline in HeadingDisplay.
|
|
5639
|
-
* Otherwise, Heading 600
|
|
5585
|
+
* Otherwise, Heading 600.
|
|
5640
5586
|
*/
|
|
5641
5587
|
largeFullscreenHeadline: {
|
|
5642
5588
|
type: Boolean,
|
|
@@ -5694,12 +5640,11 @@ class AuroSelect extends i$2 {
|
|
|
5694
5640
|
},
|
|
5695
5641
|
|
|
5696
5642
|
/**
|
|
5697
|
-
* Specifies the current selected menuOption.
|
|
5643
|
+
* Specifies the current selected menuOption. Default type is `HTMLElement`, changing to `Array<HTMLElement>` when `multiSelect` is true.
|
|
5644
|
+
* @type {HTMLElement|Array<HTMLElement>}
|
|
5698
5645
|
*/
|
|
5699
5646
|
optionSelected: {
|
|
5700
|
-
|
|
5701
|
-
converter: arrayConverter$1,
|
|
5702
|
-
hasChanged: arrayOrUndefinedHasChanged$1
|
|
5647
|
+
type: Object
|
|
5703
5648
|
},
|
|
5704
5649
|
|
|
5705
5650
|
/**
|
|
@@ -5769,12 +5714,11 @@ class AuroSelect extends i$2 {
|
|
|
5769
5714
|
},
|
|
5770
5715
|
|
|
5771
5716
|
/**
|
|
5772
|
-
* Value selected for the component.
|
|
5717
|
+
* Value selected for the component. Default type is `String`, changing to `Array<String>` when `multiSelect` is true.
|
|
5718
|
+
* @type {String|Array<String>}
|
|
5773
5719
|
*/
|
|
5774
5720
|
value: {
|
|
5775
|
-
|
|
5776
|
-
converter: arrayConverter$1,
|
|
5777
|
-
hasChanged: arrayOrUndefinedHasChanged$1
|
|
5721
|
+
type: Object
|
|
5778
5722
|
},
|
|
5779
5723
|
|
|
5780
5724
|
/**
|
|
@@ -5845,21 +5789,21 @@ class AuroSelect extends i$2 {
|
|
|
5845
5789
|
updateDisplayedValue() {
|
|
5846
5790
|
const triggerContentEl = this.dropdown.querySelector('#triggerFocus');
|
|
5847
5791
|
|
|
5848
|
-
|
|
5849
|
-
|
|
5850
|
-
triggerContentEl.innerHTML = '';
|
|
5851
|
-
if (placeholder) {
|
|
5852
|
-
triggerContentEl.appendChild(placeholder);
|
|
5853
|
-
}
|
|
5792
|
+
const valueText = triggerContentEl.querySelector("#valueText");
|
|
5793
|
+
valueText.textContent = '';
|
|
5854
5794
|
|
|
5855
5795
|
// Handle selected options
|
|
5856
|
-
if (this.optionSelected
|
|
5857
|
-
|
|
5858
|
-
|
|
5796
|
+
if (this.optionSelected) {
|
|
5797
|
+
let displayText = '';
|
|
5798
|
+
|
|
5799
|
+
if (this.multiSelect && this.optionSelected.length > 0) {
|
|
5800
|
+
// Create display text from selected options
|
|
5801
|
+
displayText = this.optionSelected.map((option) => option.textContent).join(', ');
|
|
5802
|
+
} else {
|
|
5803
|
+
displayText = this.optionSelected.textContent;
|
|
5804
|
+
}
|
|
5859
5805
|
|
|
5860
|
-
|
|
5861
|
-
span.textContent = displayText;
|
|
5862
|
-
triggerContentEl.appendChild(span);
|
|
5806
|
+
valueText.textContent = displayText;
|
|
5863
5807
|
}
|
|
5864
5808
|
|
|
5865
5809
|
this.dropdown.requestUpdate();
|
|
@@ -6103,6 +6047,17 @@ class AuroSelect extends i$2 {
|
|
|
6103
6047
|
}
|
|
6104
6048
|
}
|
|
6105
6049
|
|
|
6050
|
+
/**
|
|
6051
|
+
* Resets all options to their default state.
|
|
6052
|
+
* @private
|
|
6053
|
+
*/
|
|
6054
|
+
clearSelection() {
|
|
6055
|
+
this.value = undefined;
|
|
6056
|
+
this.optionSelected = undefined;
|
|
6057
|
+
|
|
6058
|
+
this.menu.multiSelect = this.multiSelect;
|
|
6059
|
+
}
|
|
6060
|
+
|
|
6106
6061
|
/**
|
|
6107
6062
|
* Handle element attributes on update.
|
|
6108
6063
|
* @private
|
|
@@ -6139,13 +6094,20 @@ class AuroSelect extends i$2 {
|
|
|
6139
6094
|
|
|
6140
6095
|
// Set the initial value in auro-menu if defined
|
|
6141
6096
|
if (this.hasAttribute('value') && this.getAttribute('value').length > 0) {
|
|
6097
|
+
this.value = this.multiSelect ? arrayConverter(this.getAttribute('value')) : this.getAttribute('value');
|
|
6142
6098
|
this.menu.value = this.value;
|
|
6143
6099
|
}
|
|
6144
6100
|
}
|
|
6145
6101
|
|
|
6146
6102
|
async updated(changedProperties) {
|
|
6103
|
+
if (changedProperties.has('multiSelect')) {
|
|
6104
|
+
this.clearSelection();
|
|
6105
|
+
}
|
|
6106
|
+
|
|
6147
6107
|
if (changedProperties.has('value')) {
|
|
6148
6108
|
if (this.value) {
|
|
6109
|
+
this.value = this.multiSelect ? arrayConverter(this.value) : this.value;
|
|
6110
|
+
|
|
6149
6111
|
this.menu.value = this.value;
|
|
6150
6112
|
|
|
6151
6113
|
// Wait for menu to finish updating its value
|
|
@@ -6170,6 +6132,10 @@ class AuroSelect extends i$2 {
|
|
|
6170
6132
|
bubbles: true,
|
|
6171
6133
|
cancelable: true,
|
|
6172
6134
|
composed: true,
|
|
6135
|
+
detail: {
|
|
6136
|
+
optionSelected: this.optionSelected,
|
|
6137
|
+
value: this.value
|
|
6138
|
+
}
|
|
6173
6139
|
}));
|
|
6174
6140
|
}
|
|
6175
6141
|
|
|
@@ -6217,8 +6183,23 @@ class AuroSelect extends i$2 {
|
|
|
6217
6183
|
_handleNativeSelectChange(event) {
|
|
6218
6184
|
const selectedOption = event.target.options[event.target.selectedIndex];
|
|
6219
6185
|
const selectedValue = selectedOption.value;
|
|
6220
|
-
|
|
6221
|
-
this.
|
|
6186
|
+
|
|
6187
|
+
if (this.multiSelect) {
|
|
6188
|
+
const currentArray = Array.isArray(this.value) ? this.value : [];
|
|
6189
|
+
|
|
6190
|
+
if (!currentArray.includes(selectedValue)) {
|
|
6191
|
+
this.value = [
|
|
6192
|
+
...currentArray,
|
|
6193
|
+
selectedValue
|
|
6194
|
+
];
|
|
6195
|
+
}
|
|
6196
|
+
} else {
|
|
6197
|
+
const currentValue = this.value;
|
|
6198
|
+
|
|
6199
|
+
if (currentValue !== selectedValue) {
|
|
6200
|
+
this.value = selectedValue;
|
|
6201
|
+
}
|
|
6202
|
+
}
|
|
6222
6203
|
}
|
|
6223
6204
|
|
|
6224
6205
|
/**
|
|
@@ -6231,10 +6212,13 @@ class AuroSelect extends i$2 {
|
|
|
6231
6212
|
if (!nativeSelect) {
|
|
6232
6213
|
return;
|
|
6233
6214
|
}
|
|
6234
|
-
const [value] = this.value || [];
|
|
6235
|
-
nativeSelect.value = value || '';
|
|
6236
|
-
}
|
|
6237
6215
|
|
|
6216
|
+
if (this.multiSelect) {
|
|
6217
|
+
nativeSelect.value = this.value ? this.value[0] : '';
|
|
6218
|
+
} else {
|
|
6219
|
+
nativeSelect.value = this.value || '';
|
|
6220
|
+
}
|
|
6221
|
+
}
|
|
6238
6222
|
|
|
6239
6223
|
// When using auroElement, use the following attribute and function when hiding content from screen readers.
|
|
6240
6224
|
// aria-hidden="${this.hideAudible(this.hiddenAudible)}"
|
|
@@ -6280,7 +6264,13 @@ class AuroSelect extends i$2 {
|
|
|
6280
6264
|
?noFlip="${this.noFlip}"
|
|
6281
6265
|
part="dropdown">
|
|
6282
6266
|
<span slot="trigger" aria-haspopup="true" id="triggerFocus">
|
|
6283
|
-
<span id="placeholder"
|
|
6267
|
+
<span id="placeholder"
|
|
6268
|
+
class="${e(placeholderClass)}"
|
|
6269
|
+
?aria-hidden="${this.optionSelected && this.optionSelected.length ? 'true' : false}"
|
|
6270
|
+
>
|
|
6271
|
+
<slot name="placeholder"></slot>
|
|
6272
|
+
</span>
|
|
6273
|
+
<slot name="valueText" id="valueText"></slot>
|
|
6284
6274
|
</span>
|
|
6285
6275
|
|
|
6286
6276
|
<div class="menuWrapper">
|
|
@@ -6340,102 +6330,6 @@ var tokensCss$1 = i$5`:host{--ds-auro-menu-divider-color: var(--ds-basic-color-b
|
|
|
6340
6330
|
// Copyright (c) 2021 Alaska Airlines. All right reserved. Licensed under the Apache-2.0 license
|
|
6341
6331
|
// See LICENSE in the project root for license information.
|
|
6342
6332
|
|
|
6343
|
-
// ---------------------------------------------------------------------
|
|
6344
|
-
|
|
6345
|
-
/**
|
|
6346
|
-
* Converts value to an array.
|
|
6347
|
-
* If the value is a JSON string representing an array, it will be parsed.
|
|
6348
|
-
* If the value is already an array, it is returned.
|
|
6349
|
-
* If the value is undefined, it returns undefined.
|
|
6350
|
-
* @private
|
|
6351
|
-
* @param {any} value - The value to be converted. Can be a string, array, or undefined.
|
|
6352
|
-
* @returns {Array|undefined} - The converted array or undefined.
|
|
6353
|
-
* @throws {Error} - Throws an error if the value is not an array, undefined,
|
|
6354
|
-
* or if the value cannot be parsed into an array from a JSON string.
|
|
6355
|
-
*/
|
|
6356
|
-
function arrayConverter(value) {
|
|
6357
|
-
// Allow undefined
|
|
6358
|
-
if (value === undefined) {
|
|
6359
|
-
return undefined;
|
|
6360
|
-
}
|
|
6361
|
-
|
|
6362
|
-
// Return the value if it is already an array
|
|
6363
|
-
if (Array.isArray(value)) {
|
|
6364
|
-
return value;
|
|
6365
|
-
}
|
|
6366
|
-
|
|
6367
|
-
try {
|
|
6368
|
-
// If value is a JSON string, parse it
|
|
6369
|
-
const parsed = typeof value === 'string' ? JSON.parse(value) : value;
|
|
6370
|
-
|
|
6371
|
-
// Check if the parsed value is an array
|
|
6372
|
-
if (Array.isArray(parsed)) {
|
|
6373
|
-
return parsed;
|
|
6374
|
-
}
|
|
6375
|
-
} catch (error) {
|
|
6376
|
-
// If JSON parsing fails, continue to throw an error below
|
|
6377
|
-
/* eslint-disable no-console */
|
|
6378
|
-
console.error('JSON parsing failed:', error);
|
|
6379
|
-
}
|
|
6380
|
-
|
|
6381
|
-
// Throw error if the input is not an array or undefined
|
|
6382
|
-
throw new Error('Invalid value: Input must be an array or undefined');
|
|
6383
|
-
}
|
|
6384
|
-
|
|
6385
|
-
/**
|
|
6386
|
-
* Compare two arrays for equality.
|
|
6387
|
-
* @private
|
|
6388
|
-
* @param {Array} arr1 - First array to compare.
|
|
6389
|
-
* @param {Array} arr2 - Second array to compare.
|
|
6390
|
-
* @returns {boolean} True if arrays are equal.
|
|
6391
|
-
*/
|
|
6392
|
-
function arraysAreEqual(arr1, arr2) {
|
|
6393
|
-
// If both arrays undefined, they are equal (true)
|
|
6394
|
-
if (arr1 === undefined || arr2 === undefined) {
|
|
6395
|
-
return arr1 === arr2;
|
|
6396
|
-
}
|
|
6397
|
-
|
|
6398
|
-
// If arrays have different lengths, they are not equal
|
|
6399
|
-
if (arr1.length !== arr2.length) {
|
|
6400
|
-
return false;
|
|
6401
|
-
}
|
|
6402
|
-
|
|
6403
|
-
// If every item at each index is the same, return true
|
|
6404
|
-
for (let index = 0; index < arr1.length; index += 1) {
|
|
6405
|
-
if (arr1[index] !== arr2[index]) {
|
|
6406
|
-
return false;
|
|
6407
|
-
}
|
|
6408
|
-
}
|
|
6409
|
-
return true;
|
|
6410
|
-
}
|
|
6411
|
-
|
|
6412
|
-
/**
|
|
6413
|
-
* Compares array for changes.
|
|
6414
|
-
* @private
|
|
6415
|
-
* @param {Array|any} newVal - New value to compare.
|
|
6416
|
-
* @param {Array|any} oldVal - Old value to compare.
|
|
6417
|
-
* @returns {boolean} True if arrays have changed.
|
|
6418
|
-
*/
|
|
6419
|
-
function arrayOrUndefinedHasChanged(newVal, oldVal) {
|
|
6420
|
-
try {
|
|
6421
|
-
// Check if values are undefined or arrays
|
|
6422
|
-
const isArrayOrUndefined = (val) => val === undefined || Array.isArray(val);
|
|
6423
|
-
|
|
6424
|
-
// If non-array or non-undefined, throw error
|
|
6425
|
-
if (!isArrayOrUndefined(newVal) || !isArrayOrUndefined(oldVal)) {
|
|
6426
|
-
const invalidValue = isArrayOrUndefined(newVal) ? oldVal : newVal;
|
|
6427
|
-
throw new Error(`Value must be an array or undefined, received ${typeof invalidValue}`);
|
|
6428
|
-
}
|
|
6429
|
-
|
|
6430
|
-
// Return true if arrays have changed, false if they are the same
|
|
6431
|
-
return !arraysAreEqual(newVal, oldVal);
|
|
6432
|
-
} catch (error) {
|
|
6433
|
-
/* eslint-disable no-console */
|
|
6434
|
-
console.error(error);
|
|
6435
|
-
// If validation fails, it has changed
|
|
6436
|
-
return true;
|
|
6437
|
-
}
|
|
6438
|
-
}
|
|
6439
6333
|
|
|
6440
6334
|
/**
|
|
6441
6335
|
* Validates if an option can be interacted with.
|
|
@@ -6469,7 +6363,7 @@ function dispatchMenuEvent(element, eventName, detail = null) {
|
|
|
6469
6363
|
element.dispatchEvent(new CustomEvent(eventName, eventConfig));
|
|
6470
6364
|
}
|
|
6471
6365
|
|
|
6472
|
-
// Copyright (c)
|
|
6366
|
+
// Copyright (c) 2025 Alaska Airlines. All right reserved. Licensed under the Apache-2.0 license
|
|
6473
6367
|
// See LICENSE in the project root for license information.
|
|
6474
6368
|
|
|
6475
6369
|
|
|
@@ -6477,14 +6371,14 @@ function dispatchMenuEvent(element, eventName, detail = null) {
|
|
|
6477
6371
|
// See https://git.io/JJ6SJ for "How to document your components using JSDoc"
|
|
6478
6372
|
/**
|
|
6479
6373
|
* The auro-menu element provides users a way to select from a list of options.
|
|
6480
|
-
* @attr {Array<HTMLElement
|
|
6374
|
+
* @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.
|
|
6481
6375
|
* @attr {object} optionactive - Specifies the current active menuOption.
|
|
6482
6376
|
* @attr {string} matchword - Specifies a string used to highlight matched string parts in options.
|
|
6483
6377
|
* @attr {boolean} disabled - When true, the entire menu and all options are disabled;
|
|
6484
6378
|
* @attr {boolean} nocheckmark - When true, selected option will not show the checkmark.
|
|
6485
6379
|
* @attr {boolean} loading - When true, displays a loading state using the loadingIcon and loadingText slots if provided.
|
|
6486
6380
|
* @attr {boolean} multiselect - When true, the selected option can be multiple options.
|
|
6487
|
-
* @attr {Array<string
|
|
6381
|
+
* @attr {String|Array<string>} value - Value selected for the menu, type `string` by default. In multi-select mode, `value` is an array of strings.
|
|
6488
6382
|
* @prop {boolean} hasLoadingPlaceholder - Indicates whether the menu has a loadingIcon or loadingText to render when in a loading state.
|
|
6489
6383
|
* @event {CustomEvent<Element>} auroMenu-activatedOption - Notifies that a menuoption has been made `active`.
|
|
6490
6384
|
* @event {CustomEvent<any>} auroMenu-customEventFired - Notifies that a custom event has been fired.
|
|
@@ -6497,7 +6391,7 @@ function dispatchMenuEvent(element, eventName, detail = null) {
|
|
|
6497
6391
|
* @slot - Slot for insertion of menu options.
|
|
6498
6392
|
*/
|
|
6499
6393
|
|
|
6500
|
-
/* eslint-disable no-magic-numbers, max-lines */
|
|
6394
|
+
/* eslint-disable no-magic-numbers, max-lines, no-extra-parens */
|
|
6501
6395
|
|
|
6502
6396
|
class AuroMenu extends i$2 {
|
|
6503
6397
|
constructor() {
|
|
@@ -6577,9 +6471,8 @@ class AuroMenu extends i$2 {
|
|
|
6577
6471
|
reflect: true
|
|
6578
6472
|
},
|
|
6579
6473
|
optionSelected: {
|
|
6580
|
-
// Allow HTMLElement[] arrays and undefined
|
|
6581
|
-
|
|
6582
|
-
hasChanged: arrayOrUndefinedHasChanged
|
|
6474
|
+
// Allow HTMLElement, HTMLElement[] arrays and undefined
|
|
6475
|
+
type: Object
|
|
6583
6476
|
},
|
|
6584
6477
|
optionActive: {
|
|
6585
6478
|
type: Object,
|
|
@@ -6595,10 +6488,8 @@ class AuroMenu extends i$2 {
|
|
|
6595
6488
|
attribute: 'multiselect'
|
|
6596
6489
|
},
|
|
6597
6490
|
value: {
|
|
6598
|
-
// Allow string[] arrays and undefined
|
|
6599
|
-
type: Object
|
|
6600
|
-
converter: arrayConverter,
|
|
6601
|
-
hasChanged: arrayOrUndefinedHasChanged
|
|
6491
|
+
// Allow string, string[] arrays and undefined
|
|
6492
|
+
type: Object
|
|
6602
6493
|
}
|
|
6603
6494
|
};
|
|
6604
6495
|
}
|
|
@@ -6651,30 +6542,39 @@ class AuroMenu extends i$2 {
|
|
|
6651
6542
|
}
|
|
6652
6543
|
|
|
6653
6544
|
updated(changedProperties) {
|
|
6545
|
+
if (changedProperties.has('multiSelect')) {
|
|
6546
|
+
// Reset selection if multiSelect mode changes
|
|
6547
|
+
this.clearSelection();
|
|
6548
|
+
}
|
|
6549
|
+
|
|
6654
6550
|
if (changedProperties.has('value')) {
|
|
6655
6551
|
// Handle null/undefined case
|
|
6656
6552
|
if (this.value === undefined || this.value === null) {
|
|
6657
6553
|
this.optionSelected = undefined;
|
|
6658
|
-
// Reset index tracking
|
|
6659
6554
|
this.index = -1;
|
|
6660
6555
|
} else {
|
|
6661
|
-
|
|
6662
|
-
|
|
6556
|
+
if (this.multiSelect) {
|
|
6557
|
+
// In multiselect mode, this.value should be an array of strings
|
|
6558
|
+
const valueArray = Array.isArray(this.value) ? this.value : [this.value];
|
|
6559
|
+
const matchingOptions = this.items.filter((item) => valueArray.includes(item.value));
|
|
6663
6560
|
|
|
6664
|
-
|
|
6665
|
-
|
|
6561
|
+
this.optionSelected = matchingOptions.length > 0 ? matchingOptions : undefined;
|
|
6562
|
+
} else {
|
|
6563
|
+
// In single-select mode, this.value should be a string
|
|
6564
|
+
const matchingOptions = this.items.find((item) => item.value === this.value);
|
|
6666
6565
|
|
|
6667
|
-
|
|
6668
|
-
if (this.multiSelect) {
|
|
6669
|
-
// For multiselect, keep all matching options
|
|
6566
|
+
if (matchingOptions) {
|
|
6670
6567
|
this.optionSelected = matchingOptions;
|
|
6568
|
+
this.index = this.items.indexOf(matchingOptions);
|
|
6671
6569
|
} else {
|
|
6672
|
-
//
|
|
6673
|
-
this.optionSelected =
|
|
6674
|
-
this.index =
|
|
6570
|
+
// If no matching option found, reset selection
|
|
6571
|
+
this.optionSelected = undefined;
|
|
6572
|
+
this.index = -1;
|
|
6675
6573
|
}
|
|
6676
|
-
}
|
|
6677
|
-
|
|
6574
|
+
}
|
|
6575
|
+
|
|
6576
|
+
// If no matching options were found in either mode
|
|
6577
|
+
if (!this.optionSelected || (Array.isArray(this.optionSelected) && this.optionSelected.length === 0)) {
|
|
6678
6578
|
dispatchMenuEvent(this, 'auroMenu-selectValueFailure');
|
|
6679
6579
|
this.optionSelected = undefined;
|
|
6680
6580
|
this.index = -1;
|
|
@@ -6826,8 +6726,8 @@ class AuroMenu extends i$2 {
|
|
|
6826
6726
|
}
|
|
6827
6727
|
} else {
|
|
6828
6728
|
// Single select - use arrays with single values
|
|
6829
|
-
this.value =
|
|
6830
|
-
this.optionSelected =
|
|
6729
|
+
this.value = option.value;
|
|
6730
|
+
this.optionSelected = option;
|
|
6831
6731
|
}
|
|
6832
6732
|
|
|
6833
6733
|
this.index = this.items.indexOf(option);
|
|
@@ -7149,8 +7049,13 @@ class AuroMenu extends i$2 {
|
|
|
7149
7049
|
if (!this.optionSelected) {
|
|
7150
7050
|
return false;
|
|
7151
7051
|
}
|
|
7152
|
-
|
|
7153
|
-
|
|
7052
|
+
|
|
7053
|
+
if (this.multiSelect) {
|
|
7054
|
+
// In multi-select mode, check if the option is in the selected array
|
|
7055
|
+
return Array.isArray(this.optionSelected) && this.optionSelected.some((selectedOption) => selectedOption === option);
|
|
7056
|
+
}
|
|
7057
|
+
|
|
7058
|
+
return this.optionSelected === option;
|
|
7154
7059
|
}
|
|
7155
7060
|
|
|
7156
7061
|
/**
|
|
@@ -111,7 +111,7 @@ The use of any Auro custom element has a dependency on the [Auro Design Tokens](
|
|
|
111
111
|
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.
|
|
112
112
|
|
|
113
113
|
```html
|
|
114
|
-
<script type="module" src="https://cdn.jsdelivr.net/npm/@aurodesignsystem/auro-formkit@
|
|
114
|
+
<script type="module" src="https://cdn.jsdelivr.net/npm/@aurodesignsystem/auro-formkit@latest/auro-select/+esm"></script>
|
|
115
115
|
```
|
|
116
116
|
<!-- AURO-GENERATED-CONTENT:END -->
|
|
117
117
|
|
|
@@ -6,8 +6,9 @@
|
|
|
6
6
|
* @slot label - Defines the content of the label.
|
|
7
7
|
* @slot helpText - Defines the content of the helpText.
|
|
8
8
|
* @slot placeholder - Defines the content of the placeholder to be shown when there is no value
|
|
9
|
+
* @slot valueText - Dropdown value text display.
|
|
9
10
|
* @event auroSelect-valueSet - Notifies that the component has a new value set.
|
|
10
|
-
* @event input - Notifies every time the value prop of the element is changed.
|
|
11
|
+
* @event input - Notifies every time the value prop of the element is changed. The updated `value` and `optionSelected` will be delivered in `detail` object.
|
|
11
12
|
* @event auroFormElement-validated - Notifies that the `validity` and `errorMessage` values have changed.
|
|
12
13
|
* @csspart helpText - Apply CSS to the help text.
|
|
13
14
|
*/
|
|
@@ -63,7 +64,7 @@ export class AuroSelect extends LitElement {
|
|
|
63
64
|
};
|
|
64
65
|
/**
|
|
65
66
|
* If declared, make bib.fullscreen.headline in HeadingDisplay.
|
|
66
|
-
* Otherwise, Heading 600
|
|
67
|
+
* Otherwise, Heading 600.
|
|
67
68
|
*/
|
|
68
69
|
largeFullscreenHeadline: {
|
|
69
70
|
type: BooleanConstructor;
|
|
@@ -114,12 +115,10 @@ export class AuroSelect extends LitElement {
|
|
|
114
115
|
type: ObjectConstructor;
|
|
115
116
|
};
|
|
116
117
|
/**
|
|
117
|
-
* Specifies the current selected menuOption.
|
|
118
|
+
* Specifies the current selected menuOption. Default type is `HTMLElement`, changing to `Array<HTMLElement>` when `multiSelect` is true.
|
|
119
|
+
* @type {HTMLElement|Array<HTMLElement>}
|
|
118
120
|
*/
|
|
119
|
-
optionSelected:
|
|
120
|
-
converter: typeof arrayConverter;
|
|
121
|
-
hasChanged: typeof arrayOrUndefinedHasChanged;
|
|
122
|
-
};
|
|
121
|
+
optionSelected: HTMLElement | Array<HTMLElement>;
|
|
123
122
|
/**
|
|
124
123
|
* @private
|
|
125
124
|
*/
|
|
@@ -179,12 +178,10 @@ export class AuroSelect extends LitElement {
|
|
|
179
178
|
reflect: boolean;
|
|
180
179
|
};
|
|
181
180
|
/**
|
|
182
|
-
* Value selected for the component.
|
|
181
|
+
* Value selected for the component. Default type is `String`, changing to `Array<String>` when `multiSelect` is true.
|
|
182
|
+
* @type {String|Array<String>}
|
|
183
183
|
*/
|
|
184
|
-
value:
|
|
185
|
-
converter: typeof arrayConverter;
|
|
186
|
-
hasChanged: typeof arrayOrUndefinedHasChanged;
|
|
187
|
-
};
|
|
184
|
+
value: string | Array<string>;
|
|
188
185
|
/**
|
|
189
186
|
* Sets multi-select mode, allowing multiple options to be selected at once.
|
|
190
187
|
*/
|
|
@@ -322,6 +319,11 @@ export class AuroSelect extends LitElement {
|
|
|
322
319
|
* @returns {void}
|
|
323
320
|
*/
|
|
324
321
|
private generateOptionsArray;
|
|
322
|
+
/**
|
|
323
|
+
* Resets all options to their default state.
|
|
324
|
+
* @private
|
|
325
|
+
*/
|
|
326
|
+
private clearSelection;
|
|
325
327
|
firstUpdated(): void;
|
|
326
328
|
updated(changedProperties: any): Promise<void>;
|
|
327
329
|
/**
|
|
@@ -355,5 +357,3 @@ export class AuroSelect extends LitElement {
|
|
|
355
357
|
render(): import("lit-html").TemplateResult;
|
|
356
358
|
}
|
|
357
359
|
import { LitElement } from "lit";
|
|
358
|
-
import { arrayConverter } from '@aurodesignsystem/auro-menu';
|
|
359
|
-
import { arrayOrUndefinedHasChanged } from '@aurodesignsystem/auro-menu';
|