@aurodesignsystem-dev/auro-formkit 0.0.0-pr1541.3 → 0.0.0-pr1541.4
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/components/checkbox/demo/customize.min.js +1 -1
- package/components/checkbox/demo/getting-started.min.js +1 -1
- package/components/checkbox/demo/index.min.js +1 -1
- package/components/checkbox/dist/index.js +1 -1
- package/components/checkbox/dist/registered.js +1 -1
- package/components/combobox/demo/api.md +1 -1
- package/components/combobox/demo/customize.min.js +71 -20
- package/components/combobox/demo/getting-started.min.js +71 -20
- package/components/combobox/demo/index.md +1 -0
- package/components/combobox/demo/index.min.js +71 -20
- package/components/combobox/dist/auro-combobox.d.ts +1 -1
- package/components/combobox/dist/index.js +4 -4
- package/components/combobox/dist/registered.js +4 -4
- package/components/counter/demo/customize.min.js +2 -2
- package/components/counter/demo/index.min.js +2 -2
- package/components/counter/dist/index.js +2 -2
- package/components/counter/dist/registered.js +2 -2
- package/components/datepicker/demo/customize.min.js +3 -3
- package/components/datepicker/demo/index.min.js +3 -3
- package/components/datepicker/dist/index.js +3 -3
- package/components/datepicker/dist/registered.js +3 -3
- package/components/dropdown/demo/customize.min.js +1 -1
- package/components/dropdown/demo/getting-started.min.js +1 -1
- package/components/dropdown/demo/index.min.js +1 -1
- package/components/dropdown/dist/index.js +1 -1
- package/components/dropdown/dist/registered.js +1 -1
- package/components/form/demo/customize.min.js +86 -31
- package/components/form/demo/getting-started.min.js +86 -31
- package/components/form/demo/index.min.js +86 -31
- package/components/form/demo/registerDemoDeps.min.js +86 -31
- package/components/input/demo/customize.min.js +1 -1
- package/components/input/demo/getting-started.min.js +1 -1
- package/components/input/demo/index.min.js +1 -1
- package/components/input/dist/index.js +1 -1
- package/components/input/dist/registered.js +1 -1
- package/components/menu/demo/api.md +24 -18
- package/components/menu/demo/customize.md +1 -1
- package/components/menu/demo/getting-started.md +2 -2
- package/components/menu/demo/index.min.js +67 -16
- package/components/menu/dist/auro-menu-utils.d.ts +19 -0
- package/components/menu/dist/auro-menu.d.ts +3 -7
- package/components/menu/dist/auro-menuoption.d.ts +1 -0
- package/components/menu/dist/index.js +67 -16
- package/components/menu/dist/registered.js +67 -16
- package/components/radio/demo/customize.min.js +1 -1
- package/components/radio/demo/getting-started.min.js +1 -1
- package/components/radio/demo/index.min.js +1 -1
- package/components/radio/dist/index.js +1 -1
- package/components/radio/dist/registered.js +1 -1
- package/components/select/demo/api.md +2 -2
- package/components/select/demo/customize.md +3 -0
- package/components/select/demo/customize.min.js +74 -19
- package/components/select/demo/getting-started.md +1 -1
- package/components/select/demo/getting-started.min.js +74 -19
- package/components/select/demo/index.md +2 -2
- package/components/select/demo/index.min.js +74 -19
- package/components/select/dist/auro-select.d.ts +6 -2
- package/components/select/dist/index.js +7 -3
- package/components/select/dist/registered.js +7 -3
- package/custom-elements.json +1836 -1776
- package/package.json +1 -1
|
@@ -221,6 +221,18 @@ class AuroLibraryRuntimeUtils {
|
|
|
221
221
|
// See LICENSE in the project root for license information.
|
|
222
222
|
|
|
223
223
|
|
|
224
|
+
/**
|
|
225
|
+
* Serializes a multi-select value array back into the String `value` property.
|
|
226
|
+
* An empty (or missing) array collapses to `undefined` so an emptied selection
|
|
227
|
+
* clears `value` rather than reflecting a `"[]"` attribute.
|
|
228
|
+
* @private
|
|
229
|
+
* @param {Array<string>|undefined} values - The selected values.
|
|
230
|
+
* @returns {string|undefined} JSON string of the values, or undefined when empty.
|
|
231
|
+
*/
|
|
232
|
+
function serializeMultiSelectValue(values) {
|
|
233
|
+
return values && values.length > 0 ? JSON.stringify(values) : undefined;
|
|
234
|
+
}
|
|
235
|
+
|
|
224
236
|
/**
|
|
225
237
|
* Validates if an option can be interacted with.
|
|
226
238
|
* @private
|
|
@@ -233,6 +245,20 @@ function isOptionInteractive(option) {
|
|
|
233
245
|
!option.hasAttribute('static');
|
|
234
246
|
}
|
|
235
247
|
|
|
248
|
+
/**
|
|
249
|
+
* Validates if an option may be selected by matching a programmatic value.
|
|
250
|
+
* Unlike `isOptionInteractive`, `hidden` is allowed: the combobox toggles
|
|
251
|
+
* `hidden` as its type-ahead filter, so a filtered-out option is still a
|
|
252
|
+
* valid programmatic selection. Only disabled and static options — which are
|
|
253
|
+
* never selectable — are rejected.
|
|
254
|
+
* @param {HTMLElement} option - The option to check.
|
|
255
|
+
* @returns {boolean} True if option can be selected by value.
|
|
256
|
+
*/
|
|
257
|
+
function isSelectableByValue(option) {
|
|
258
|
+
return !option.hasAttribute('disabled') &&
|
|
259
|
+
!option.hasAttribute('static');
|
|
260
|
+
}
|
|
261
|
+
|
|
236
262
|
/**
|
|
237
263
|
* Helper method to dispatch custom events.
|
|
238
264
|
* @param {HTMLElement} element - Element to dispatch event from.
|
|
@@ -415,6 +441,7 @@ class AuroMenu extends AuroElement {
|
|
|
415
441
|
|
|
416
442
|
/**
|
|
417
443
|
* Specifies the current active menuOption.
|
|
444
|
+
* @readonly
|
|
418
445
|
*/
|
|
419
446
|
optionActive: {
|
|
420
447
|
type: Object,
|
|
@@ -423,14 +450,17 @@ class AuroMenu extends AuroElement {
|
|
|
423
450
|
|
|
424
451
|
/**
|
|
425
452
|
* The currently selected menu option(s). In single-select mode this is a single `HTMLElement` (or `undefined` when nothing is selected). In multi-select mode this is an array of `HTMLElement`s.
|
|
453
|
+
* @readonly
|
|
426
454
|
*/
|
|
427
455
|
optionSelected: {
|
|
428
456
|
// Allow HTMLElement, HTMLElement[] arrays and undefined
|
|
429
|
-
type: Object
|
|
457
|
+
type: Object,
|
|
458
|
+
attribute: false
|
|
430
459
|
},
|
|
431
460
|
|
|
432
461
|
/**
|
|
433
462
|
* The value of the selected option. In multi-select mode, this is a JSON stringified array of selected option values.
|
|
463
|
+
* Options marked `disabled` or `static` are not selectable by value; `hidden` options remain selectable. In single-select mode, if the value matches a non-selectable option the selection is cleared (`optionSelected` becomes `undefined`) and `auroMenu-selectValueFailure` is dispatched. In multi-select mode, non-selectable entries are dropped from the value and the remaining selectable entries are selected; `auroMenu-selectValueFailure` is dispatched only when none of the entries match a selectable option.
|
|
434
464
|
*/
|
|
435
465
|
value: {
|
|
436
466
|
type: String,
|
|
@@ -554,7 +584,7 @@ class AuroMenu extends AuroElement {
|
|
|
554
584
|
}
|
|
555
585
|
|
|
556
586
|
/**
|
|
557
|
-
* Selects options by value.
|
|
587
|
+
* Selects options by value. Options marked `disabled` or `static` are not selectable; `hidden` options remain selectable. In single-select mode, if the value matches a non-selectable option the selection is cleared and `auroMenu-selectValueFailure` is dispatched. In multi-select mode, non-selectable entries are dropped and the remaining selectable entries are selected; `auroMenu-selectValueFailure` is dispatched only when none of the entries match a selectable option. Passing `undefined`, `null`, an empty string, or an empty array clears the selection without dispatching a failure.
|
|
558
588
|
* @param {string|string[]|undefined|null} value - The value(s) to select.
|
|
559
589
|
* @public
|
|
560
590
|
*/
|
|
@@ -639,6 +669,11 @@ class AuroMenu extends AuroElement {
|
|
|
639
669
|
this.initItems();
|
|
640
670
|
}
|
|
641
671
|
|
|
672
|
+
// Set when reconciliation reassigns `value` below. That reassignment schedules a
|
|
673
|
+
// second updated() cycle, so the `event`-attribute dispatch is deferred to that
|
|
674
|
+
// cycle to avoid firing option custom events twice on the same selection.
|
|
675
|
+
let valueReconciled = false;
|
|
676
|
+
|
|
642
677
|
// Handle null/undefined/empty case — empty/whitespace strings clear selection
|
|
643
678
|
// consistently with selectByValue(''), and avoid downstream `.includes('')` matches.
|
|
644
679
|
if (this.value === undefined || this.value === null || (typeof this.value === 'string' && this.value.trim() === '')) {
|
|
@@ -651,11 +686,31 @@ class AuroMenu extends AuroElement {
|
|
|
651
686
|
// Defensive default: `formattedValue` can be undefined for unexpected value types,
|
|
652
687
|
// and calling `.includes` on undefined would throw during reconciliation.
|
|
653
688
|
const valueArray = this.formattedValue || [];
|
|
654
|
-
const matchingOptions = this.items ? this.items.filter((item) => valueArray.includes(item.value)) : [];
|
|
689
|
+
const matchingOptions = this.items ? this.items.filter((item) => isSelectableByValue(item) && valueArray.includes(item.value)) : [];
|
|
655
690
|
newSelected = matchingOptions.length > 0 ? matchingOptions : undefined;
|
|
691
|
+
|
|
692
|
+
// Reconcile `value` with the selectable set. Drop only entries whose option is
|
|
693
|
+
// loaded but non-selectable (disabled/static) — leaving them would desync `value`
|
|
694
|
+
// from `optionSelected`, and the toggle handlers rebuild `value` from `formattedValue`,
|
|
695
|
+
// so the rejected entry would resurface on the next select/deselect. Entries with no
|
|
696
|
+
// matching item yet are preserved so async preselection still works once options render.
|
|
697
|
+
const rejectedValues = this.items
|
|
698
|
+
? this.items.filter((item) => !isSelectableByValue(item) && valueArray.includes(item.value)).map((item) => item.value)
|
|
699
|
+
: [];
|
|
700
|
+
if (rejectedValues.length > 0) {
|
|
701
|
+
const reconciled = valueArray.filter((val) => !rejectedValues.includes(val));
|
|
702
|
+
this.value = serializeMultiSelectValue(reconciled);
|
|
703
|
+
valueReconciled = true;
|
|
704
|
+
}
|
|
656
705
|
} else {
|
|
657
|
-
// In single-select mode, this.value should be a string
|
|
658
|
-
|
|
706
|
+
// In single-select mode, this.value should be a string. Reject
|
|
707
|
+
// disabled/static options so a programmatic value pointing at a
|
|
708
|
+
// non-selectable option falls through to the no-match path below
|
|
709
|
+
// (dispatching auroMenu-selectValueFailure) instead of pinning it.
|
|
710
|
+
// `hidden` is intentionally NOT excluded: the combobox toggles
|
|
711
|
+
// `hidden` as its type-ahead filter, so a filtered-out option is
|
|
712
|
+
// still a valid programmatic selection.
|
|
713
|
+
const matchingOption = this.items ? this.items.find((item) => isSelectableByValue(item) && item.value === this.value) : undefined;
|
|
659
714
|
|
|
660
715
|
if (matchingOption) {
|
|
661
716
|
newSelected = matchingOption;
|
|
@@ -697,8 +752,9 @@ class AuroMenu extends AuroElement {
|
|
|
697
752
|
]
|
|
698
753
|
]));
|
|
699
754
|
|
|
700
|
-
// Notify of changes
|
|
701
|
-
|
|
755
|
+
// Notify of changes. Skip when reconciliation just reassigned `value`: the
|
|
756
|
+
// follow-on update cycle re-runs this branch and fires the events exactly once.
|
|
757
|
+
if (this.optionSelected !== undefined && !valueReconciled) {
|
|
702
758
|
const selected = Array.isArray(this.optionSelected) ? this.optionSelected : [this.optionSelected];
|
|
703
759
|
selected.forEach((opt) => {
|
|
704
760
|
if (opt.hasAttribute('event')) {
|
|
@@ -911,7 +967,7 @@ class AuroMenu extends AuroElement {
|
|
|
911
967
|
const currentSelected = this.optionSelected || [];
|
|
912
968
|
|
|
913
969
|
if (!currentValue.includes(option.value)) {
|
|
914
|
-
this.value =
|
|
970
|
+
this.value = serializeMultiSelectValue([
|
|
915
971
|
...currentValue,
|
|
916
972
|
option.value
|
|
917
973
|
]);
|
|
@@ -937,15 +993,9 @@ class AuroMenu extends AuroElement {
|
|
|
937
993
|
*/
|
|
938
994
|
handleDeselectState(option) {
|
|
939
995
|
if (this.multiSelect) {
|
|
940
|
-
// Remove this option from array
|
|
996
|
+
// Remove this option from array; an empty result collapses `value` to undefined.
|
|
941
997
|
const newFormattedValue = (this.formattedValue || []).filter((val) => val !== option.value);
|
|
942
|
-
|
|
943
|
-
// If array is empty after removal, set back to undefined
|
|
944
|
-
if (newFormattedValue && newFormattedValue.length === 0) {
|
|
945
|
-
this.value = undefined;
|
|
946
|
-
} else {
|
|
947
|
-
this.value = JSON.stringify(newFormattedValue);
|
|
948
|
-
}
|
|
998
|
+
this.value = serializeMultiSelectValue(newFormattedValue);
|
|
949
999
|
|
|
950
1000
|
this.optionSelected = this.optionSelected.filter((val) => val !== option);
|
|
951
1001
|
if (this.optionSelected.length === 0) {
|
|
@@ -1459,6 +1509,7 @@ let menuOptionIdCounter = 0;
|
|
|
1459
1509
|
* The `auro-menuoption` element provides users a way to define a menu option.
|
|
1460
1510
|
* @customElement auro-menuoption
|
|
1461
1511
|
*
|
|
1512
|
+
* @attr {Boolean} static - When present, marks the option as non-interactive — it renders but is skipped during keyboard navigation and cannot be selected. Useful for section headers, informational rows inside a menu, or attaching event listeners.
|
|
1462
1513
|
* @slot default - The default slot for the menu option text.
|
|
1463
1514
|
*
|
|
1464
1515
|
* @event auroMenuOption-mouseover - Notifies that this option has been hovered over.
|
|
@@ -10,6 +10,15 @@
|
|
|
10
10
|
* or if the value cannot be parsed into an array from a JSON string.
|
|
11
11
|
*/
|
|
12
12
|
export function arrayConverter(value: any): any[] | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* Serializes a multi-select value array back into the String `value` property.
|
|
15
|
+
* An empty (or missing) array collapses to `undefined` so an emptied selection
|
|
16
|
+
* clears `value` rather than reflecting a `"[]"` attribute.
|
|
17
|
+
* @private
|
|
18
|
+
* @param {Array<string>|undefined} values - The selected values.
|
|
19
|
+
* @returns {string|undefined} JSON string of the values, or undefined when empty.
|
|
20
|
+
*/
|
|
21
|
+
export function serializeMultiSelectValue(values: Array<string> | undefined): string | undefined;
|
|
13
22
|
/**
|
|
14
23
|
* Compare two arrays for equality.
|
|
15
24
|
* @private
|
|
@@ -25,6 +34,16 @@ export function arraysAreEqual(arr1: any[], arr2: any[]): boolean;
|
|
|
25
34
|
* @returns {boolean} True if option is interactive.
|
|
26
35
|
*/
|
|
27
36
|
export function isOptionInteractive(option: HTMLElement): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Validates if an option may be selected by matching a programmatic value.
|
|
39
|
+
* Unlike `isOptionInteractive`, `hidden` is allowed: the combobox toggles
|
|
40
|
+
* `hidden` as its type-ahead filter, so a filtered-out option is still a
|
|
41
|
+
* valid programmatic selection. Only disabled and static options — which are
|
|
42
|
+
* never selectable — are rejected.
|
|
43
|
+
* @param {HTMLElement} option - The option to check.
|
|
44
|
+
* @returns {boolean} True if option can be selected by value.
|
|
45
|
+
*/
|
|
46
|
+
export function isSelectableByValue(option: HTMLElement): boolean;
|
|
28
47
|
/**
|
|
29
48
|
* Helper method to dispatch custom events.
|
|
30
49
|
* @param {HTMLElement} element - Element to dispatch event from.
|
|
@@ -60,21 +60,17 @@ export class AuroMenu extends AuroElement {
|
|
|
60
60
|
reflect: boolean;
|
|
61
61
|
attribute: string;
|
|
62
62
|
};
|
|
63
|
-
/**
|
|
64
|
-
* Specifies the current active menuOption.
|
|
65
|
-
*/
|
|
66
63
|
optionActive: {
|
|
67
64
|
type: ObjectConstructor;
|
|
68
65
|
attribute: string;
|
|
69
66
|
};
|
|
70
|
-
/**
|
|
71
|
-
* The currently selected menu option(s). In single-select mode this is a single `HTMLElement` (or `undefined` when nothing is selected). In multi-select mode this is an array of `HTMLElement`s.
|
|
72
|
-
*/
|
|
73
67
|
optionSelected: {
|
|
74
68
|
type: ObjectConstructor;
|
|
69
|
+
attribute: boolean;
|
|
75
70
|
};
|
|
76
71
|
/**
|
|
77
72
|
* The value of the selected option. In multi-select mode, this is a JSON stringified array of selected option values.
|
|
73
|
+
* Options marked `disabled` or `static` are not selectable by value; `hidden` options remain selectable. In single-select mode, if the value matches a non-selectable option the selection is cleared (`optionSelected` becomes `undefined`) and `auroMenu-selectValueFailure` is dispatched. In multi-select mode, non-selectable entries are dropped from the value and the remaining selectable entries are selected; `auroMenu-selectValueFailure` is dispatched only when none of the entries match a selectable option.
|
|
78
74
|
*/
|
|
79
75
|
value: {
|
|
80
76
|
type: StringConstructor;
|
|
@@ -171,7 +167,7 @@ export class AuroMenu extends AuroElement {
|
|
|
171
167
|
*/
|
|
172
168
|
private get formattedValue();
|
|
173
169
|
/**
|
|
174
|
-
* Selects options by value.
|
|
170
|
+
* Selects options by value. Options marked `disabled` or `static` are not selectable; `hidden` options remain selectable. In single-select mode, if the value matches a non-selectable option the selection is cleared and `auroMenu-selectValueFailure` is dispatched. In multi-select mode, non-selectable entries are dropped and the remaining selectable entries are selected; `auroMenu-selectValueFailure` is dispatched only when none of the entries match a selectable option. Passing `undefined`, `null`, an empty string, or an empty array clears the selection without dispatching a failure.
|
|
175
171
|
* @param {string|string[]|undefined|null} value - The value(s) to select.
|
|
176
172
|
* @public
|
|
177
173
|
*/
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* The `auro-menuoption` element provides users a way to define a menu option.
|
|
3
3
|
* @customElement auro-menuoption
|
|
4
4
|
*
|
|
5
|
+
* @attr {Boolean} static - When present, marks the option as non-interactive — it renders but is skipped during keyboard navigation and cannot be selected. Useful for section headers, informational rows inside a menu, or attaching event listeners.
|
|
5
6
|
* @slot default - The default slot for the menu option text.
|
|
6
7
|
*
|
|
7
8
|
* @event auroMenuOption-mouseover - Notifies that this option has been hovered over.
|
|
@@ -241,6 +241,18 @@ function arrayConverter(value) {
|
|
|
241
241
|
throw new Error('Invalid value: Input must be an array or undefined');
|
|
242
242
|
}
|
|
243
243
|
|
|
244
|
+
/**
|
|
245
|
+
* Serializes a multi-select value array back into the String `value` property.
|
|
246
|
+
* An empty (or missing) array collapses to `undefined` so an emptied selection
|
|
247
|
+
* clears `value` rather than reflecting a `"[]"` attribute.
|
|
248
|
+
* @private
|
|
249
|
+
* @param {Array<string>|undefined} values - The selected values.
|
|
250
|
+
* @returns {string|undefined} JSON string of the values, or undefined when empty.
|
|
251
|
+
*/
|
|
252
|
+
function serializeMultiSelectValue(values) {
|
|
253
|
+
return values && values.length > 0 ? JSON.stringify(values) : undefined;
|
|
254
|
+
}
|
|
255
|
+
|
|
244
256
|
/**
|
|
245
257
|
* Validates if an option can be interacted with.
|
|
246
258
|
* @private
|
|
@@ -253,6 +265,20 @@ function isOptionInteractive(option) {
|
|
|
253
265
|
!option.hasAttribute('static');
|
|
254
266
|
}
|
|
255
267
|
|
|
268
|
+
/**
|
|
269
|
+
* Validates if an option may be selected by matching a programmatic value.
|
|
270
|
+
* Unlike `isOptionInteractive`, `hidden` is allowed: the combobox toggles
|
|
271
|
+
* `hidden` as its type-ahead filter, so a filtered-out option is still a
|
|
272
|
+
* valid programmatic selection. Only disabled and static options — which are
|
|
273
|
+
* never selectable — are rejected.
|
|
274
|
+
* @param {HTMLElement} option - The option to check.
|
|
275
|
+
* @returns {boolean} True if option can be selected by value.
|
|
276
|
+
*/
|
|
277
|
+
function isSelectableByValue(option) {
|
|
278
|
+
return !option.hasAttribute('disabled') &&
|
|
279
|
+
!option.hasAttribute('static');
|
|
280
|
+
}
|
|
281
|
+
|
|
256
282
|
/**
|
|
257
283
|
* Helper method to dispatch custom events.
|
|
258
284
|
* @param {HTMLElement} element - Element to dispatch event from.
|
|
@@ -422,6 +448,7 @@ class AuroMenu extends AuroElement {
|
|
|
422
448
|
|
|
423
449
|
/**
|
|
424
450
|
* Specifies the current active menuOption.
|
|
451
|
+
* @readonly
|
|
425
452
|
*/
|
|
426
453
|
optionActive: {
|
|
427
454
|
type: Object,
|
|
@@ -430,14 +457,17 @@ class AuroMenu extends AuroElement {
|
|
|
430
457
|
|
|
431
458
|
/**
|
|
432
459
|
* The currently selected menu option(s). In single-select mode this is a single `HTMLElement` (or `undefined` when nothing is selected). In multi-select mode this is an array of `HTMLElement`s.
|
|
460
|
+
* @readonly
|
|
433
461
|
*/
|
|
434
462
|
optionSelected: {
|
|
435
463
|
// Allow HTMLElement, HTMLElement[] arrays and undefined
|
|
436
|
-
type: Object
|
|
464
|
+
type: Object,
|
|
465
|
+
attribute: false
|
|
437
466
|
},
|
|
438
467
|
|
|
439
468
|
/**
|
|
440
469
|
* The value of the selected option. In multi-select mode, this is a JSON stringified array of selected option values.
|
|
470
|
+
* Options marked `disabled` or `static` are not selectable by value; `hidden` options remain selectable. In single-select mode, if the value matches a non-selectable option the selection is cleared (`optionSelected` becomes `undefined`) and `auroMenu-selectValueFailure` is dispatched. In multi-select mode, non-selectable entries are dropped from the value and the remaining selectable entries are selected; `auroMenu-selectValueFailure` is dispatched only when none of the entries match a selectable option.
|
|
441
471
|
*/
|
|
442
472
|
value: {
|
|
443
473
|
type: String,
|
|
@@ -561,7 +591,7 @@ class AuroMenu extends AuroElement {
|
|
|
561
591
|
}
|
|
562
592
|
|
|
563
593
|
/**
|
|
564
|
-
* Selects options by value.
|
|
594
|
+
* Selects options by value. Options marked `disabled` or `static` are not selectable; `hidden` options remain selectable. In single-select mode, if the value matches a non-selectable option the selection is cleared and `auroMenu-selectValueFailure` is dispatched. In multi-select mode, non-selectable entries are dropped and the remaining selectable entries are selected; `auroMenu-selectValueFailure` is dispatched only when none of the entries match a selectable option. Passing `undefined`, `null`, an empty string, or an empty array clears the selection without dispatching a failure.
|
|
565
595
|
* @param {string|string[]|undefined|null} value - The value(s) to select.
|
|
566
596
|
* @public
|
|
567
597
|
*/
|
|
@@ -646,6 +676,11 @@ class AuroMenu extends AuroElement {
|
|
|
646
676
|
this.initItems();
|
|
647
677
|
}
|
|
648
678
|
|
|
679
|
+
// Set when reconciliation reassigns `value` below. That reassignment schedules a
|
|
680
|
+
// second updated() cycle, so the `event`-attribute dispatch is deferred to that
|
|
681
|
+
// cycle to avoid firing option custom events twice on the same selection.
|
|
682
|
+
let valueReconciled = false;
|
|
683
|
+
|
|
649
684
|
// Handle null/undefined/empty case — empty/whitespace strings clear selection
|
|
650
685
|
// consistently with selectByValue(''), and avoid downstream `.includes('')` matches.
|
|
651
686
|
if (this.value === undefined || this.value === null || (typeof this.value === 'string' && this.value.trim() === '')) {
|
|
@@ -658,11 +693,31 @@ class AuroMenu extends AuroElement {
|
|
|
658
693
|
// Defensive default: `formattedValue` can be undefined for unexpected value types,
|
|
659
694
|
// and calling `.includes` on undefined would throw during reconciliation.
|
|
660
695
|
const valueArray = this.formattedValue || [];
|
|
661
|
-
const matchingOptions = this.items ? this.items.filter((item) => valueArray.includes(item.value)) : [];
|
|
696
|
+
const matchingOptions = this.items ? this.items.filter((item) => isSelectableByValue(item) && valueArray.includes(item.value)) : [];
|
|
662
697
|
newSelected = matchingOptions.length > 0 ? matchingOptions : undefined;
|
|
698
|
+
|
|
699
|
+
// Reconcile `value` with the selectable set. Drop only entries whose option is
|
|
700
|
+
// loaded but non-selectable (disabled/static) — leaving them would desync `value`
|
|
701
|
+
// from `optionSelected`, and the toggle handlers rebuild `value` from `formattedValue`,
|
|
702
|
+
// so the rejected entry would resurface on the next select/deselect. Entries with no
|
|
703
|
+
// matching item yet are preserved so async preselection still works once options render.
|
|
704
|
+
const rejectedValues = this.items
|
|
705
|
+
? this.items.filter((item) => !isSelectableByValue(item) && valueArray.includes(item.value)).map((item) => item.value)
|
|
706
|
+
: [];
|
|
707
|
+
if (rejectedValues.length > 0) {
|
|
708
|
+
const reconciled = valueArray.filter((val) => !rejectedValues.includes(val));
|
|
709
|
+
this.value = serializeMultiSelectValue(reconciled);
|
|
710
|
+
valueReconciled = true;
|
|
711
|
+
}
|
|
663
712
|
} else {
|
|
664
|
-
// In single-select mode, this.value should be a string
|
|
665
|
-
|
|
713
|
+
// In single-select mode, this.value should be a string. Reject
|
|
714
|
+
// disabled/static options so a programmatic value pointing at a
|
|
715
|
+
// non-selectable option falls through to the no-match path below
|
|
716
|
+
// (dispatching auroMenu-selectValueFailure) instead of pinning it.
|
|
717
|
+
// `hidden` is intentionally NOT excluded: the combobox toggles
|
|
718
|
+
// `hidden` as its type-ahead filter, so a filtered-out option is
|
|
719
|
+
// still a valid programmatic selection.
|
|
720
|
+
const matchingOption = this.items ? this.items.find((item) => isSelectableByValue(item) && item.value === this.value) : undefined;
|
|
666
721
|
|
|
667
722
|
if (matchingOption) {
|
|
668
723
|
newSelected = matchingOption;
|
|
@@ -704,8 +759,9 @@ class AuroMenu extends AuroElement {
|
|
|
704
759
|
]
|
|
705
760
|
]));
|
|
706
761
|
|
|
707
|
-
// Notify of changes
|
|
708
|
-
|
|
762
|
+
// Notify of changes. Skip when reconciliation just reassigned `value`: the
|
|
763
|
+
// follow-on update cycle re-runs this branch and fires the events exactly once.
|
|
764
|
+
if (this.optionSelected !== undefined && !valueReconciled) {
|
|
709
765
|
const selected = Array.isArray(this.optionSelected) ? this.optionSelected : [this.optionSelected];
|
|
710
766
|
selected.forEach((opt) => {
|
|
711
767
|
if (opt.hasAttribute('event')) {
|
|
@@ -918,7 +974,7 @@ class AuroMenu extends AuroElement {
|
|
|
918
974
|
const currentSelected = this.optionSelected || [];
|
|
919
975
|
|
|
920
976
|
if (!currentValue.includes(option.value)) {
|
|
921
|
-
this.value =
|
|
977
|
+
this.value = serializeMultiSelectValue([
|
|
922
978
|
...currentValue,
|
|
923
979
|
option.value
|
|
924
980
|
]);
|
|
@@ -944,15 +1000,9 @@ class AuroMenu extends AuroElement {
|
|
|
944
1000
|
*/
|
|
945
1001
|
handleDeselectState(option) {
|
|
946
1002
|
if (this.multiSelect) {
|
|
947
|
-
// Remove this option from array
|
|
1003
|
+
// Remove this option from array; an empty result collapses `value` to undefined.
|
|
948
1004
|
const newFormattedValue = (this.formattedValue || []).filter((val) => val !== option.value);
|
|
949
|
-
|
|
950
|
-
// If array is empty after removal, set back to undefined
|
|
951
|
-
if (newFormattedValue && newFormattedValue.length === 0) {
|
|
952
|
-
this.value = undefined;
|
|
953
|
-
} else {
|
|
954
|
-
this.value = JSON.stringify(newFormattedValue);
|
|
955
|
-
}
|
|
1005
|
+
this.value = serializeMultiSelectValue(newFormattedValue);
|
|
956
1006
|
|
|
957
1007
|
this.optionSelected = this.optionSelected.filter((val) => val !== option);
|
|
958
1008
|
if (this.optionSelected.length === 0) {
|
|
@@ -1453,6 +1503,7 @@ let menuOptionIdCounter = 0;
|
|
|
1453
1503
|
* The `auro-menuoption` element provides users a way to define a menu option.
|
|
1454
1504
|
* @customElement auro-menuoption
|
|
1455
1505
|
*
|
|
1506
|
+
* @attr {Boolean} static - When present, marks the option as non-interactive — it renders but is skipped during keyboard navigation and cannot be selected. Useful for section headers, informational rows inside a menu, or attaching event listeners.
|
|
1456
1507
|
* @slot default - The default slot for the menu option text.
|
|
1457
1508
|
*
|
|
1458
1509
|
* @event auroMenuOption-mouseover - Notifies that this option has been hovered over.
|
|
@@ -200,6 +200,18 @@ class AuroLibraryRuntimeUtils {
|
|
|
200
200
|
// See LICENSE in the project root for license information.
|
|
201
201
|
|
|
202
202
|
|
|
203
|
+
/**
|
|
204
|
+
* Serializes a multi-select value array back into the String `value` property.
|
|
205
|
+
* An empty (or missing) array collapses to `undefined` so an emptied selection
|
|
206
|
+
* clears `value` rather than reflecting a `"[]"` attribute.
|
|
207
|
+
* @private
|
|
208
|
+
* @param {Array<string>|undefined} values - The selected values.
|
|
209
|
+
* @returns {string|undefined} JSON string of the values, or undefined when empty.
|
|
210
|
+
*/
|
|
211
|
+
function serializeMultiSelectValue(values) {
|
|
212
|
+
return values && values.length > 0 ? JSON.stringify(values) : undefined;
|
|
213
|
+
}
|
|
214
|
+
|
|
203
215
|
/**
|
|
204
216
|
* Validates if an option can be interacted with.
|
|
205
217
|
* @private
|
|
@@ -212,6 +224,20 @@ function isOptionInteractive(option) {
|
|
|
212
224
|
!option.hasAttribute('static');
|
|
213
225
|
}
|
|
214
226
|
|
|
227
|
+
/**
|
|
228
|
+
* Validates if an option may be selected by matching a programmatic value.
|
|
229
|
+
* Unlike `isOptionInteractive`, `hidden` is allowed: the combobox toggles
|
|
230
|
+
* `hidden` as its type-ahead filter, so a filtered-out option is still a
|
|
231
|
+
* valid programmatic selection. Only disabled and static options — which are
|
|
232
|
+
* never selectable — are rejected.
|
|
233
|
+
* @param {HTMLElement} option - The option to check.
|
|
234
|
+
* @returns {boolean} True if option can be selected by value.
|
|
235
|
+
*/
|
|
236
|
+
function isSelectableByValue(option) {
|
|
237
|
+
return !option.hasAttribute('disabled') &&
|
|
238
|
+
!option.hasAttribute('static');
|
|
239
|
+
}
|
|
240
|
+
|
|
215
241
|
/**
|
|
216
242
|
* Helper method to dispatch custom events.
|
|
217
243
|
* @param {HTMLElement} element - Element to dispatch event from.
|
|
@@ -381,6 +407,7 @@ class AuroMenu extends AuroElement {
|
|
|
381
407
|
|
|
382
408
|
/**
|
|
383
409
|
* Specifies the current active menuOption.
|
|
410
|
+
* @readonly
|
|
384
411
|
*/
|
|
385
412
|
optionActive: {
|
|
386
413
|
type: Object,
|
|
@@ -389,14 +416,17 @@ class AuroMenu extends AuroElement {
|
|
|
389
416
|
|
|
390
417
|
/**
|
|
391
418
|
* The currently selected menu option(s). In single-select mode this is a single `HTMLElement` (or `undefined` when nothing is selected). In multi-select mode this is an array of `HTMLElement`s.
|
|
419
|
+
* @readonly
|
|
392
420
|
*/
|
|
393
421
|
optionSelected: {
|
|
394
422
|
// Allow HTMLElement, HTMLElement[] arrays and undefined
|
|
395
|
-
type: Object
|
|
423
|
+
type: Object,
|
|
424
|
+
attribute: false
|
|
396
425
|
},
|
|
397
426
|
|
|
398
427
|
/**
|
|
399
428
|
* The value of the selected option. In multi-select mode, this is a JSON stringified array of selected option values.
|
|
429
|
+
* Options marked `disabled` or `static` are not selectable by value; `hidden` options remain selectable. In single-select mode, if the value matches a non-selectable option the selection is cleared (`optionSelected` becomes `undefined`) and `auroMenu-selectValueFailure` is dispatched. In multi-select mode, non-selectable entries are dropped from the value and the remaining selectable entries are selected; `auroMenu-selectValueFailure` is dispatched only when none of the entries match a selectable option.
|
|
400
430
|
*/
|
|
401
431
|
value: {
|
|
402
432
|
type: String,
|
|
@@ -520,7 +550,7 @@ class AuroMenu extends AuroElement {
|
|
|
520
550
|
}
|
|
521
551
|
|
|
522
552
|
/**
|
|
523
|
-
* Selects options by value.
|
|
553
|
+
* Selects options by value. Options marked `disabled` or `static` are not selectable; `hidden` options remain selectable. In single-select mode, if the value matches a non-selectable option the selection is cleared and `auroMenu-selectValueFailure` is dispatched. In multi-select mode, non-selectable entries are dropped and the remaining selectable entries are selected; `auroMenu-selectValueFailure` is dispatched only when none of the entries match a selectable option. Passing `undefined`, `null`, an empty string, or an empty array clears the selection without dispatching a failure.
|
|
524
554
|
* @param {string|string[]|undefined|null} value - The value(s) to select.
|
|
525
555
|
* @public
|
|
526
556
|
*/
|
|
@@ -605,6 +635,11 @@ class AuroMenu extends AuroElement {
|
|
|
605
635
|
this.initItems();
|
|
606
636
|
}
|
|
607
637
|
|
|
638
|
+
// Set when reconciliation reassigns `value` below. That reassignment schedules a
|
|
639
|
+
// second updated() cycle, so the `event`-attribute dispatch is deferred to that
|
|
640
|
+
// cycle to avoid firing option custom events twice on the same selection.
|
|
641
|
+
let valueReconciled = false;
|
|
642
|
+
|
|
608
643
|
// Handle null/undefined/empty case — empty/whitespace strings clear selection
|
|
609
644
|
// consistently with selectByValue(''), and avoid downstream `.includes('')` matches.
|
|
610
645
|
if (this.value === undefined || this.value === null || (typeof this.value === 'string' && this.value.trim() === '')) {
|
|
@@ -617,11 +652,31 @@ class AuroMenu extends AuroElement {
|
|
|
617
652
|
// Defensive default: `formattedValue` can be undefined for unexpected value types,
|
|
618
653
|
// and calling `.includes` on undefined would throw during reconciliation.
|
|
619
654
|
const valueArray = this.formattedValue || [];
|
|
620
|
-
const matchingOptions = this.items ? this.items.filter((item) => valueArray.includes(item.value)) : [];
|
|
655
|
+
const matchingOptions = this.items ? this.items.filter((item) => isSelectableByValue(item) && valueArray.includes(item.value)) : [];
|
|
621
656
|
newSelected = matchingOptions.length > 0 ? matchingOptions : undefined;
|
|
657
|
+
|
|
658
|
+
// Reconcile `value` with the selectable set. Drop only entries whose option is
|
|
659
|
+
// loaded but non-selectable (disabled/static) — leaving them would desync `value`
|
|
660
|
+
// from `optionSelected`, and the toggle handlers rebuild `value` from `formattedValue`,
|
|
661
|
+
// so the rejected entry would resurface on the next select/deselect. Entries with no
|
|
662
|
+
// matching item yet are preserved so async preselection still works once options render.
|
|
663
|
+
const rejectedValues = this.items
|
|
664
|
+
? this.items.filter((item) => !isSelectableByValue(item) && valueArray.includes(item.value)).map((item) => item.value)
|
|
665
|
+
: [];
|
|
666
|
+
if (rejectedValues.length > 0) {
|
|
667
|
+
const reconciled = valueArray.filter((val) => !rejectedValues.includes(val));
|
|
668
|
+
this.value = serializeMultiSelectValue(reconciled);
|
|
669
|
+
valueReconciled = true;
|
|
670
|
+
}
|
|
622
671
|
} else {
|
|
623
|
-
// In single-select mode, this.value should be a string
|
|
624
|
-
|
|
672
|
+
// In single-select mode, this.value should be a string. Reject
|
|
673
|
+
// disabled/static options so a programmatic value pointing at a
|
|
674
|
+
// non-selectable option falls through to the no-match path below
|
|
675
|
+
// (dispatching auroMenu-selectValueFailure) instead of pinning it.
|
|
676
|
+
// `hidden` is intentionally NOT excluded: the combobox toggles
|
|
677
|
+
// `hidden` as its type-ahead filter, so a filtered-out option is
|
|
678
|
+
// still a valid programmatic selection.
|
|
679
|
+
const matchingOption = this.items ? this.items.find((item) => isSelectableByValue(item) && item.value === this.value) : undefined;
|
|
625
680
|
|
|
626
681
|
if (matchingOption) {
|
|
627
682
|
newSelected = matchingOption;
|
|
@@ -663,8 +718,9 @@ class AuroMenu extends AuroElement {
|
|
|
663
718
|
]
|
|
664
719
|
]));
|
|
665
720
|
|
|
666
|
-
// Notify of changes
|
|
667
|
-
|
|
721
|
+
// Notify of changes. Skip when reconciliation just reassigned `value`: the
|
|
722
|
+
// follow-on update cycle re-runs this branch and fires the events exactly once.
|
|
723
|
+
if (this.optionSelected !== undefined && !valueReconciled) {
|
|
668
724
|
const selected = Array.isArray(this.optionSelected) ? this.optionSelected : [this.optionSelected];
|
|
669
725
|
selected.forEach((opt) => {
|
|
670
726
|
if (opt.hasAttribute('event')) {
|
|
@@ -877,7 +933,7 @@ class AuroMenu extends AuroElement {
|
|
|
877
933
|
const currentSelected = this.optionSelected || [];
|
|
878
934
|
|
|
879
935
|
if (!currentValue.includes(option.value)) {
|
|
880
|
-
this.value =
|
|
936
|
+
this.value = serializeMultiSelectValue([
|
|
881
937
|
...currentValue,
|
|
882
938
|
option.value
|
|
883
939
|
]);
|
|
@@ -903,15 +959,9 @@ class AuroMenu extends AuroElement {
|
|
|
903
959
|
*/
|
|
904
960
|
handleDeselectState(option) {
|
|
905
961
|
if (this.multiSelect) {
|
|
906
|
-
// Remove this option from array
|
|
962
|
+
// Remove this option from array; an empty result collapses `value` to undefined.
|
|
907
963
|
const newFormattedValue = (this.formattedValue || []).filter((val) => val !== option.value);
|
|
908
|
-
|
|
909
|
-
// If array is empty after removal, set back to undefined
|
|
910
|
-
if (newFormattedValue && newFormattedValue.length === 0) {
|
|
911
|
-
this.value = undefined;
|
|
912
|
-
} else {
|
|
913
|
-
this.value = JSON.stringify(newFormattedValue);
|
|
914
|
-
}
|
|
964
|
+
this.value = serializeMultiSelectValue(newFormattedValue);
|
|
915
965
|
|
|
916
966
|
this.optionSelected = this.optionSelected.filter((val) => val !== option);
|
|
917
967
|
if (this.optionSelected.length === 0) {
|
|
@@ -1412,6 +1462,7 @@ let menuOptionIdCounter = 0;
|
|
|
1412
1462
|
* The `auro-menuoption` element provides users a way to define a menu option.
|
|
1413
1463
|
* @customElement auro-menuoption
|
|
1414
1464
|
*
|
|
1465
|
+
* @attr {Boolean} static - When present, marks the option as non-interactive — it renders but is skipped during keyboard navigation and cannot be selected. Useful for section headers, informational rows inside a menu, or attaching event listeners.
|
|
1415
1466
|
* @slot default - The default slot for the menu option text.
|
|
1416
1467
|
*
|
|
1417
1468
|
* @event auroMenuOption-mouseover - Notifies that this option has been hovered over.
|
|
@@ -1227,7 +1227,7 @@ class AuroHelpText extends i$2 {
|
|
|
1227
1227
|
}
|
|
1228
1228
|
}
|
|
1229
1229
|
|
|
1230
|
-
var formkitVersion = '
|
|
1230
|
+
var formkitVersion = '202607082038';
|
|
1231
1231
|
|
|
1232
1232
|
// Copyright (c) Alaska Air. All right reserved. Licensed under the Apache-2.0 license
|
|
1233
1233
|
// See LICENSE in the project root for license information.
|
|
@@ -1227,7 +1227,7 @@ class AuroHelpText extends i$2 {
|
|
|
1227
1227
|
}
|
|
1228
1228
|
}
|
|
1229
1229
|
|
|
1230
|
-
var formkitVersion = '
|
|
1230
|
+
var formkitVersion = '202607082038';
|
|
1231
1231
|
|
|
1232
1232
|
// Copyright (c) Alaska Air. All right reserved. Licensed under the Apache-2.0 license
|
|
1233
1233
|
// See LICENSE in the project root for license information.
|
|
@@ -1227,7 +1227,7 @@ class AuroHelpText extends i$2 {
|
|
|
1227
1227
|
}
|
|
1228
1228
|
}
|
|
1229
1229
|
|
|
1230
|
-
var formkitVersion = '
|
|
1230
|
+
var formkitVersion = '202607082038';
|
|
1231
1231
|
|
|
1232
1232
|
// Copyright (c) Alaska Air. All right reserved. Licensed under the Apache-2.0 license
|
|
1233
1233
|
// See LICENSE in the project root for license information.
|
|
@@ -1166,7 +1166,7 @@ class AuroHelpText extends LitElement {
|
|
|
1166
1166
|
}
|
|
1167
1167
|
}
|
|
1168
1168
|
|
|
1169
|
-
var formkitVersion = '
|
|
1169
|
+
var formkitVersion = '202607082038';
|
|
1170
1170
|
|
|
1171
1171
|
// Copyright (c) Alaska Air. All right reserved. Licensed under the Apache-2.0 license
|
|
1172
1172
|
// See LICENSE in the project root for license information.
|
|
@@ -1166,7 +1166,7 @@ class AuroHelpText extends LitElement {
|
|
|
1166
1166
|
}
|
|
1167
1167
|
}
|
|
1168
1168
|
|
|
1169
|
-
var formkitVersion = '
|
|
1169
|
+
var formkitVersion = '202607082038';
|
|
1170
1170
|
|
|
1171
1171
|
// Copyright (c) Alaska Air. All right reserved. Licensed under the Apache-2.0 license
|
|
1172
1172
|
// See LICENSE in the project root for license information.
|
|
@@ -40,7 +40,7 @@ The `auro-select` element is a wrapper for auro-dropdown and auro-menu to create
|
|
|
40
40
|
| `size` | `size` | `'lg' \| 'xl'` | | Determines the size of the dropdown bib. Only the `emphasized` layout supports size=`xl`, while all other layouts support size=`lg`. |
|
|
41
41
|
| `typeaheadTimeoutMs` | `typeaheadTimeoutMs` | `number` | "500" | Milliseconds of keyboard inactivity before the type-ahead buffer resets.<br />Increase for users who type slowly. |
|
|
42
42
|
| `validity` | `validity` | `string` | | Specifies the `validityState` this element is in. |
|
|
43
|
-
| `value` | `value` | `string` | | Value selected for the component.
|
|
43
|
+
| `value` | `value` | `string` | | Value selected for the component. When set programmatically or as a preset attribute, the value must match a selectable option. If it matches an option marked `disabled` or `static`, the selection is rejected: `value` and `optionSelected` are cleared to `undefined`. `hidden` options remain selectable by value. |
|
|
44
44
|
|
|
45
45
|
## Methods
|
|
46
46
|
|
|
@@ -48,7 +48,7 @@ The `auro-select` element is a wrapper for auro-dropdown and auro-menu to create
|
|
|
48
48
|
|----------------------|----------------------------------------|--------------------------------------------------|
|
|
49
49
|
| `hideBib` | `(): void` | Hides the dropdown bib if its open. |
|
|
50
50
|
| `reset` | `(): void` | Resets component to initial state. |
|
|
51
|
-
| `setMenuValue` | `(value:
|
|
51
|
+
| `setMenuValue` | `(value: string): void` | Sets the selected value by matching it against the menu options. Options marked `disabled` or `static` are not selectable: if the value matches one, the selection is rejected and `value`/`optionSelected` are cleared to `undefined`. `hidden` options remain selectable.<br /><br />**value**: The value to match against the menu options. |
|
|
52
52
|
| `showBib` | `(): void` | Shows the dropdown bib if there are options to show. |
|
|
53
53
|
| `updateActiveOption` | `(index: number): void` | Updates the active option in the menu.<br /><br />**index**: Index of the option to make active. |
|
|
54
54
|
| `validate` | `(force?: boolean \| undefined): void` | Validates value.<br /><br />**force**: Whether to force validation. |
|