@aurodesignsystem/auro-formkit 3.5.0 → 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
|
@@ -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)}`;
|
|
@@ -5636,7 +5581,7 @@ class AuroSelect extends i$2 {
|
|
|
5636
5581
|
|
|
5637
5582
|
/**
|
|
5638
5583
|
* If declared, make bib.fullscreen.headline in HeadingDisplay.
|
|
5639
|
-
* Otherwise, Heading 600
|
|
5584
|
+
* Otherwise, Heading 600.
|
|
5640
5585
|
*/
|
|
5641
5586
|
largeFullscreenHeadline: {
|
|
5642
5587
|
type: Boolean,
|
|
@@ -5694,12 +5639,11 @@ class AuroSelect extends i$2 {
|
|
|
5694
5639
|
},
|
|
5695
5640
|
|
|
5696
5641
|
/**
|
|
5697
|
-
* Specifies the current selected menuOption.
|
|
5642
|
+
* Specifies the current selected menuOption. Default type is `HTMLElement`, changing to `Array<HTMLElement>` when `multiSelect` is true.
|
|
5643
|
+
* @type {HTMLElement|Array<HTMLElement>}
|
|
5698
5644
|
*/
|
|
5699
5645
|
optionSelected: {
|
|
5700
|
-
|
|
5701
|
-
converter: arrayConverter$1,
|
|
5702
|
-
hasChanged: arrayOrUndefinedHasChanged$1
|
|
5646
|
+
type: Object
|
|
5703
5647
|
},
|
|
5704
5648
|
|
|
5705
5649
|
/**
|
|
@@ -5769,12 +5713,11 @@ class AuroSelect extends i$2 {
|
|
|
5769
5713
|
},
|
|
5770
5714
|
|
|
5771
5715
|
/**
|
|
5772
|
-
* Value selected for the component.
|
|
5716
|
+
* Value selected for the component. Default type is `String`, changing to `Array<String>` when `multiSelect` is true.
|
|
5717
|
+
* @type {String|Array<String>}
|
|
5773
5718
|
*/
|
|
5774
5719
|
value: {
|
|
5775
|
-
|
|
5776
|
-
converter: arrayConverter$1,
|
|
5777
|
-
hasChanged: arrayOrUndefinedHasChanged$1
|
|
5720
|
+
type: Object
|
|
5778
5721
|
},
|
|
5779
5722
|
|
|
5780
5723
|
/**
|
|
@@ -5853,9 +5796,15 @@ class AuroSelect extends i$2 {
|
|
|
5853
5796
|
}
|
|
5854
5797
|
|
|
5855
5798
|
// Handle selected options
|
|
5856
|
-
if (this.optionSelected
|
|
5857
|
-
|
|
5858
|
-
|
|
5799
|
+
if (this.optionSelected) {
|
|
5800
|
+
let displayText = '';
|
|
5801
|
+
|
|
5802
|
+
if (this.multiSelect && this.optionSelected.length > 0) {
|
|
5803
|
+
// Create display text from selected options
|
|
5804
|
+
displayText = this.optionSelected.map((option) => option.textContent).join(', ');
|
|
5805
|
+
} else {
|
|
5806
|
+
displayText = this.optionSelected.textContent;
|
|
5807
|
+
}
|
|
5859
5808
|
|
|
5860
5809
|
const span = document.createElement('span');
|
|
5861
5810
|
span.textContent = displayText;
|
|
@@ -6103,6 +6052,17 @@ class AuroSelect extends i$2 {
|
|
|
6103
6052
|
}
|
|
6104
6053
|
}
|
|
6105
6054
|
|
|
6055
|
+
/**
|
|
6056
|
+
* Resets all options to their default state.
|
|
6057
|
+
* @private
|
|
6058
|
+
*/
|
|
6059
|
+
clearSelection() {
|
|
6060
|
+
this.value = undefined;
|
|
6061
|
+
this.optionSelected = undefined;
|
|
6062
|
+
|
|
6063
|
+
this.menu.multiSelect = this.multiSelect;
|
|
6064
|
+
}
|
|
6065
|
+
|
|
6106
6066
|
/**
|
|
6107
6067
|
* Handle element attributes on update.
|
|
6108
6068
|
* @private
|
|
@@ -6139,13 +6099,20 @@ class AuroSelect extends i$2 {
|
|
|
6139
6099
|
|
|
6140
6100
|
// Set the initial value in auro-menu if defined
|
|
6141
6101
|
if (this.hasAttribute('value') && this.getAttribute('value').length > 0) {
|
|
6102
|
+
this.value = this.multiSelect ? arrayConverter(this.getAttribute('value')) : this.getAttribute('value');
|
|
6142
6103
|
this.menu.value = this.value;
|
|
6143
6104
|
}
|
|
6144
6105
|
}
|
|
6145
6106
|
|
|
6146
6107
|
async updated(changedProperties) {
|
|
6108
|
+
if (changedProperties.has('multiSelect')) {
|
|
6109
|
+
this.clearSelection();
|
|
6110
|
+
}
|
|
6111
|
+
|
|
6147
6112
|
if (changedProperties.has('value')) {
|
|
6148
6113
|
if (this.value) {
|
|
6114
|
+
this.value = this.multiSelect ? arrayConverter(this.value) : this.value;
|
|
6115
|
+
|
|
6149
6116
|
this.menu.value = this.value;
|
|
6150
6117
|
|
|
6151
6118
|
// Wait for menu to finish updating its value
|
|
@@ -6217,8 +6184,23 @@ class AuroSelect extends i$2 {
|
|
|
6217
6184
|
_handleNativeSelectChange(event) {
|
|
6218
6185
|
const selectedOption = event.target.options[event.target.selectedIndex];
|
|
6219
6186
|
const selectedValue = selectedOption.value;
|
|
6220
|
-
|
|
6221
|
-
this.
|
|
6187
|
+
|
|
6188
|
+
if (this.multiSelect) {
|
|
6189
|
+
const currentArray = Array.isArray(this.value) ? this.value : [];
|
|
6190
|
+
|
|
6191
|
+
if (!currentArray.includes(selectedValue)) {
|
|
6192
|
+
this.value = [
|
|
6193
|
+
...currentArray,
|
|
6194
|
+
selectedValue
|
|
6195
|
+
];
|
|
6196
|
+
}
|
|
6197
|
+
} else {
|
|
6198
|
+
const currentValue = this.value;
|
|
6199
|
+
|
|
6200
|
+
if (currentValue !== selectedValue) {
|
|
6201
|
+
this.value = selectedValue;
|
|
6202
|
+
}
|
|
6203
|
+
}
|
|
6222
6204
|
}
|
|
6223
6205
|
|
|
6224
6206
|
/**
|
|
@@ -6231,10 +6213,13 @@ class AuroSelect extends i$2 {
|
|
|
6231
6213
|
if (!nativeSelect) {
|
|
6232
6214
|
return;
|
|
6233
6215
|
}
|
|
6234
|
-
const [value] = this.value || [];
|
|
6235
|
-
nativeSelect.value = value || '';
|
|
6236
|
-
}
|
|
6237
6216
|
|
|
6217
|
+
if (this.multiSelect) {
|
|
6218
|
+
nativeSelect.value = this.value ? this.value[0] : '';
|
|
6219
|
+
} else {
|
|
6220
|
+
nativeSelect.value = this.value || '';
|
|
6221
|
+
}
|
|
6222
|
+
}
|
|
6238
6223
|
|
|
6239
6224
|
// When using auroElement, use the following attribute and function when hiding content from screen readers.
|
|
6240
6225
|
// aria-hidden="${this.hideAudible(this.hiddenAudible)}"
|
|
@@ -6340,102 +6325,6 @@ var tokensCss$1 = i$5`:host{--ds-auro-menu-divider-color: var(--ds-basic-color-b
|
|
|
6340
6325
|
// Copyright (c) 2021 Alaska Airlines. All right reserved. Licensed under the Apache-2.0 license
|
|
6341
6326
|
// See LICENSE in the project root for license information.
|
|
6342
6327
|
|
|
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
6328
|
|
|
6440
6329
|
/**
|
|
6441
6330
|
* Validates if an option can be interacted with.
|
|
@@ -6469,7 +6358,7 @@ function dispatchMenuEvent(element, eventName, detail = null) {
|
|
|
6469
6358
|
element.dispatchEvent(new CustomEvent(eventName, eventConfig));
|
|
6470
6359
|
}
|
|
6471
6360
|
|
|
6472
|
-
// Copyright (c)
|
|
6361
|
+
// Copyright (c) 2025 Alaska Airlines. All right reserved. Licensed under the Apache-2.0 license
|
|
6473
6362
|
// See LICENSE in the project root for license information.
|
|
6474
6363
|
|
|
6475
6364
|
|
|
@@ -6477,14 +6366,14 @@ function dispatchMenuEvent(element, eventName, detail = null) {
|
|
|
6477
6366
|
// See https://git.io/JJ6SJ for "How to document your components using JSDoc"
|
|
6478
6367
|
/**
|
|
6479
6368
|
* The auro-menu element provides users a way to select from a list of options.
|
|
6480
|
-
* @attr {Array<HTMLElement
|
|
6369
|
+
* @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
6370
|
* @attr {object} optionactive - Specifies the current active menuOption.
|
|
6482
6371
|
* @attr {string} matchword - Specifies a string used to highlight matched string parts in options.
|
|
6483
6372
|
* @attr {boolean} disabled - When true, the entire menu and all options are disabled;
|
|
6484
6373
|
* @attr {boolean} nocheckmark - When true, selected option will not show the checkmark.
|
|
6485
6374
|
* @attr {boolean} loading - When true, displays a loading state using the loadingIcon and loadingText slots if provided.
|
|
6486
6375
|
* @attr {boolean} multiselect - When true, the selected option can be multiple options.
|
|
6487
|
-
* @attr {Array<string
|
|
6376
|
+
* @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
6377
|
* @prop {boolean} hasLoadingPlaceholder - Indicates whether the menu has a loadingIcon or loadingText to render when in a loading state.
|
|
6489
6378
|
* @event {CustomEvent<Element>} auroMenu-activatedOption - Notifies that a menuoption has been made `active`.
|
|
6490
6379
|
* @event {CustomEvent<any>} auroMenu-customEventFired - Notifies that a custom event has been fired.
|
|
@@ -6497,7 +6386,7 @@ function dispatchMenuEvent(element, eventName, detail = null) {
|
|
|
6497
6386
|
* @slot - Slot for insertion of menu options.
|
|
6498
6387
|
*/
|
|
6499
6388
|
|
|
6500
|
-
/* eslint-disable no-magic-numbers, max-lines */
|
|
6389
|
+
/* eslint-disable no-magic-numbers, max-lines, no-extra-parens */
|
|
6501
6390
|
|
|
6502
6391
|
class AuroMenu extends i$2 {
|
|
6503
6392
|
constructor() {
|
|
@@ -6577,9 +6466,8 @@ class AuroMenu extends i$2 {
|
|
|
6577
6466
|
reflect: true
|
|
6578
6467
|
},
|
|
6579
6468
|
optionSelected: {
|
|
6580
|
-
// Allow HTMLElement[] arrays and undefined
|
|
6581
|
-
|
|
6582
|
-
hasChanged: arrayOrUndefinedHasChanged
|
|
6469
|
+
// Allow HTMLElement, HTMLElement[] arrays and undefined
|
|
6470
|
+
type: Object
|
|
6583
6471
|
},
|
|
6584
6472
|
optionActive: {
|
|
6585
6473
|
type: Object,
|
|
@@ -6595,10 +6483,8 @@ class AuroMenu extends i$2 {
|
|
|
6595
6483
|
attribute: 'multiselect'
|
|
6596
6484
|
},
|
|
6597
6485
|
value: {
|
|
6598
|
-
// Allow string[] arrays and undefined
|
|
6599
|
-
type: Object
|
|
6600
|
-
converter: arrayConverter,
|
|
6601
|
-
hasChanged: arrayOrUndefinedHasChanged
|
|
6486
|
+
// Allow string, string[] arrays and undefined
|
|
6487
|
+
type: Object
|
|
6602
6488
|
}
|
|
6603
6489
|
};
|
|
6604
6490
|
}
|
|
@@ -6651,30 +6537,39 @@ class AuroMenu extends i$2 {
|
|
|
6651
6537
|
}
|
|
6652
6538
|
|
|
6653
6539
|
updated(changedProperties) {
|
|
6540
|
+
if (changedProperties.has('multiSelect')) {
|
|
6541
|
+
// Reset selection if multiSelect mode changes
|
|
6542
|
+
this.clearSelection();
|
|
6543
|
+
}
|
|
6544
|
+
|
|
6654
6545
|
if (changedProperties.has('value')) {
|
|
6655
6546
|
// Handle null/undefined case
|
|
6656
6547
|
if (this.value === undefined || this.value === null) {
|
|
6657
6548
|
this.optionSelected = undefined;
|
|
6658
|
-
// Reset index tracking
|
|
6659
6549
|
this.index = -1;
|
|
6660
6550
|
} else {
|
|
6661
|
-
|
|
6662
|
-
|
|
6551
|
+
if (this.multiSelect) {
|
|
6552
|
+
// In multiselect mode, this.value should be an array of strings
|
|
6553
|
+
const valueArray = Array.isArray(this.value) ? this.value : [this.value];
|
|
6554
|
+
const matchingOptions = this.items.filter((item) => valueArray.includes(item.value));
|
|
6663
6555
|
|
|
6664
|
-
|
|
6665
|
-
|
|
6556
|
+
this.optionSelected = matchingOptions.length > 0 ? matchingOptions : undefined;
|
|
6557
|
+
} else {
|
|
6558
|
+
// In single-select mode, this.value should be a string
|
|
6559
|
+
const matchingOptions = this.items.find((item) => item.value === this.value);
|
|
6666
6560
|
|
|
6667
|
-
|
|
6668
|
-
if (this.multiSelect) {
|
|
6669
|
-
// For multiselect, keep all matching options
|
|
6561
|
+
if (matchingOptions) {
|
|
6670
6562
|
this.optionSelected = matchingOptions;
|
|
6563
|
+
this.index = this.items.indexOf(matchingOptions);
|
|
6671
6564
|
} else {
|
|
6672
|
-
//
|
|
6673
|
-
this.optionSelected =
|
|
6674
|
-
this.index =
|
|
6565
|
+
// If no matching option found, reset selection
|
|
6566
|
+
this.optionSelected = undefined;
|
|
6567
|
+
this.index = -1;
|
|
6675
6568
|
}
|
|
6676
|
-
}
|
|
6677
|
-
|
|
6569
|
+
}
|
|
6570
|
+
|
|
6571
|
+
// If no matching options were found in either mode
|
|
6572
|
+
if (!this.optionSelected || (Array.isArray(this.optionSelected) && this.optionSelected.length === 0)) {
|
|
6678
6573
|
dispatchMenuEvent(this, 'auroMenu-selectValueFailure');
|
|
6679
6574
|
this.optionSelected = undefined;
|
|
6680
6575
|
this.index = -1;
|
|
@@ -6826,8 +6721,8 @@ class AuroMenu extends i$2 {
|
|
|
6826
6721
|
}
|
|
6827
6722
|
} else {
|
|
6828
6723
|
// Single select - use arrays with single values
|
|
6829
|
-
this.value =
|
|
6830
|
-
this.optionSelected =
|
|
6724
|
+
this.value = option.value;
|
|
6725
|
+
this.optionSelected = option;
|
|
6831
6726
|
}
|
|
6832
6727
|
|
|
6833
6728
|
this.index = this.items.indexOf(option);
|
|
@@ -7149,8 +7044,13 @@ class AuroMenu extends i$2 {
|
|
|
7149
7044
|
if (!this.optionSelected) {
|
|
7150
7045
|
return false;
|
|
7151
7046
|
}
|
|
7152
|
-
|
|
7153
|
-
|
|
7047
|
+
|
|
7048
|
+
if (this.multiSelect) {
|
|
7049
|
+
// In multi-select mode, check if the option is in the selected array
|
|
7050
|
+
return Array.isArray(this.optionSelected) && this.optionSelected.some((selectedOption) => selectedOption === option);
|
|
7051
|
+
}
|
|
7052
|
+
|
|
7053
|
+
return this.optionSelected === option;
|
|
7154
7054
|
}
|
|
7155
7055
|
|
|
7156
7056
|
/**
|
|
@@ -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
|
|
|
@@ -63,7 +63,7 @@ export class AuroSelect extends LitElement {
|
|
|
63
63
|
};
|
|
64
64
|
/**
|
|
65
65
|
* If declared, make bib.fullscreen.headline in HeadingDisplay.
|
|
66
|
-
* Otherwise, Heading 600
|
|
66
|
+
* Otherwise, Heading 600.
|
|
67
67
|
*/
|
|
68
68
|
largeFullscreenHeadline: {
|
|
69
69
|
type: BooleanConstructor;
|
|
@@ -114,12 +114,10 @@ export class AuroSelect extends LitElement {
|
|
|
114
114
|
type: ObjectConstructor;
|
|
115
115
|
};
|
|
116
116
|
/**
|
|
117
|
-
* Specifies the current selected menuOption.
|
|
117
|
+
* Specifies the current selected menuOption. Default type is `HTMLElement`, changing to `Array<HTMLElement>` when `multiSelect` is true.
|
|
118
|
+
* @type {HTMLElement|Array<HTMLElement>}
|
|
118
119
|
*/
|
|
119
|
-
optionSelected:
|
|
120
|
-
converter: typeof arrayConverter;
|
|
121
|
-
hasChanged: typeof arrayOrUndefinedHasChanged;
|
|
122
|
-
};
|
|
120
|
+
optionSelected: HTMLElement | Array<HTMLElement>;
|
|
123
121
|
/**
|
|
124
122
|
* @private
|
|
125
123
|
*/
|
|
@@ -179,12 +177,10 @@ export class AuroSelect extends LitElement {
|
|
|
179
177
|
reflect: boolean;
|
|
180
178
|
};
|
|
181
179
|
/**
|
|
182
|
-
* Value selected for the component.
|
|
180
|
+
* Value selected for the component. Default type is `String`, changing to `Array<String>` when `multiSelect` is true.
|
|
181
|
+
* @type {String|Array<String>}
|
|
183
182
|
*/
|
|
184
|
-
value:
|
|
185
|
-
converter: typeof arrayConverter;
|
|
186
|
-
hasChanged: typeof arrayOrUndefinedHasChanged;
|
|
187
|
-
};
|
|
183
|
+
value: string | Array<string>;
|
|
188
184
|
/**
|
|
189
185
|
* Sets multi-select mode, allowing multiple options to be selected at once.
|
|
190
186
|
*/
|
|
@@ -322,6 +318,11 @@ export class AuroSelect extends LitElement {
|
|
|
322
318
|
* @returns {void}
|
|
323
319
|
*/
|
|
324
320
|
private generateOptionsArray;
|
|
321
|
+
/**
|
|
322
|
+
* Resets all options to their default state.
|
|
323
|
+
* @private
|
|
324
|
+
*/
|
|
325
|
+
private clearSelection;
|
|
325
326
|
firstUpdated(): void;
|
|
326
327
|
updated(changedProperties: any): Promise<void>;
|
|
327
328
|
/**
|
|
@@ -355,5 +356,3 @@ export class AuroSelect extends LitElement {
|
|
|
355
356
|
render(): import("lit-html").TemplateResult;
|
|
356
357
|
}
|
|
357
358
|
import { LitElement } from "lit";
|
|
358
|
-
import { arrayConverter } from '@aurodesignsystem/auro-menu';
|
|
359
|
-
import { arrayOrUndefinedHasChanged } from '@aurodesignsystem/auro-menu';
|