@aurodesignsystem-dev/auro-formkit 0.0.0-pr1576.8 → 0.0.0-pr1577.0
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/customize.md +0 -40
- package/components/combobox/demo/customize.min.js +65 -368
- package/components/combobox/demo/getting-started.min.js +65 -368
- package/components/combobox/demo/index.min.js +65 -368
- package/components/combobox/dist/index.js +38 -56
- package/components/combobox/dist/registered.js +38 -56
- package/components/counter/demo/customize.min.js +11 -2
- package/components/counter/demo/index.min.js +11 -2
- package/components/counter/dist/index.js +11 -2
- package/components/counter/dist/registered.js +11 -2
- package/components/datepicker/demo/customize.min.js +12 -3
- package/components/datepicker/demo/index.min.js +12 -3
- package/components/datepicker/dist/index.js +12 -3
- package/components/datepicker/dist/registered.js +12 -3
- package/components/dropdown/demo/customize.min.js +10 -1
- package/components/dropdown/demo/getting-started.min.js +10 -1
- package/components/dropdown/demo/index.min.js +10 -1
- package/components/dropdown/dist/index.js +10 -1
- package/components/dropdown/dist/registered.js +10 -1
- package/components/form/demo/customize.min.js +102 -378
- package/components/form/demo/getting-started.min.js +102 -378
- package/components/form/demo/index.min.js +102 -378
- package/components/form/demo/registerDemoDeps.min.js +102 -378
- 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/customize.md +0 -50
- package/components/menu/demo/index.min.js +27 -312
- package/components/menu/dist/auro-menu-utils.d.ts +0 -30
- package/components/menu/dist/auro-menu.d.ts +0 -23
- package/components/menu/dist/index.js +27 -312
- package/components/menu/dist/registered.js +27 -312
- 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/customize.md +0 -72
- package/components/select/demo/customize.min.js +38 -314
- package/components/select/demo/getting-started.min.js +38 -314
- package/components/select/demo/index.min.js +38 -314
- package/components/select/dist/index.js +11 -2
- package/components/select/dist/registered.js +11 -2
- package/custom-elements.json +0 -103
- package/package.json +1 -1
|
@@ -238,116 +238,6 @@ function isSelectableByValue(option) {
|
|
|
238
238
|
!option.hasAttribute('static');
|
|
239
239
|
}
|
|
240
240
|
|
|
241
|
-
/* eslint-disable no-underscore-dangle */
|
|
242
|
-
/**
|
|
243
|
-
* Resolves the single selected option for a given `value`, preferring the
|
|
244
|
-
* option tracked by `selectedKey` (a user-initiated selection) over a
|
|
245
|
-
* first-by-value match. When multiple options share the same `value`, matching
|
|
246
|
-
* by `value` alone cannot distinguish which one the user picked; the key
|
|
247
|
-
* disambiguates it.
|
|
248
|
-
*
|
|
249
|
-
* The key is trusted only when it still resolves to an option whose `value`
|
|
250
|
-
* matches the requested `value`. If the key is stale (option removed) or the
|
|
251
|
-
* value was changed programmatically, resolution falls back to value matching —
|
|
252
|
-
* preserving backward-compatible behavior for preselection and `selectByValue`.
|
|
253
|
-
* @private
|
|
254
|
-
* @param {Array<HTMLElement>} items - The menu's flat option list.
|
|
255
|
-
* @param {string} value - The value to resolve.
|
|
256
|
-
* @param {string|undefined} selectedKey - The `_optionKey` of the user-selected option, if any.
|
|
257
|
-
* @returns {HTMLElement|undefined} The resolved option, or undefined when none match.
|
|
258
|
-
*/
|
|
259
|
-
function resolveSelectedOption(items, value, selectedKey) {
|
|
260
|
-
if (!items) {
|
|
261
|
-
return undefined;
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
if (selectedKey !== undefined) {
|
|
265
|
-
const keyed = items.find((item) => item._optionKey === selectedKey);
|
|
266
|
-
if (keyed && isSelectableByValue(keyed) && keyed.value === value) {
|
|
267
|
-
return keyed;
|
|
268
|
-
}
|
|
269
|
-
// Key exists but the option is gone or its value no longer matches — fall
|
|
270
|
-
// through to value-based matching.
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
return items.find((item) => isSelectableByValue(item) && item.value === value);
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
/**
|
|
277
|
-
* Resolves the selected options for a multi-select `value` array, preferring
|
|
278
|
-
* options tracked by `selectedKeys` (user-initiated selections) and falling
|
|
279
|
-
* back to value matching for any values not resolved by key. The result is
|
|
280
|
-
* always sorted into DOM order regardless of selection sequence.
|
|
281
|
-
* @private
|
|
282
|
-
* @param {Array<HTMLElement>} items - The menu's flat option list.
|
|
283
|
-
* @param {Array<string>} valueArray - The selected values.
|
|
284
|
-
* @param {Array<string>|undefined} selectedKeys - The `_optionKey`s of the user-selected options, if any.
|
|
285
|
-
* @returns {Array<HTMLElement>} The resolved options in DOM order.
|
|
286
|
-
*/
|
|
287
|
-
function resolveSelectedOptions(items, valueArray, selectedKeys) {
|
|
288
|
-
if (!items) {
|
|
289
|
-
return [];
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
const resolved = [];
|
|
293
|
-
// Mirror `resolved` as a Set for O(1) membership checks below, matching the
|
|
294
|
-
// indexMap optimization used for the sort rather than scanning `resolved`
|
|
295
|
-
// on every candidate.
|
|
296
|
-
const resolvedSet = new Set();
|
|
297
|
-
|
|
298
|
-
// Track how many of each value are still available to resolve. A value that
|
|
299
|
-
// appears N times in `valueArray` may be satisfied at most N times total across
|
|
300
|
-
// the key pass and the value fallback below — matching by count, not presence,
|
|
301
|
-
// on BOTH passes. This stops a duplicate value from being over-resolved: e.g.
|
|
302
|
-
// two keyed options that both carry `SEA` cannot both match a single requested
|
|
303
|
-
// `SEA` (which happens when `value` is set directly without clearing
|
|
304
|
-
// `_selectedKey`, so more keys survive than the value set now asks for).
|
|
305
|
-
const remaining = new Map();
|
|
306
|
-
valueArray.forEach((val) => remaining.set(val, (remaining.get(val) || 0) + 1));
|
|
307
|
-
|
|
308
|
-
// Resolve by key first: trust a key only when its option is still selectable
|
|
309
|
-
// and there is still an unmatched occurrence of its value in the request set.
|
|
310
|
-
if (Array.isArray(selectedKeys)) {
|
|
311
|
-
selectedKeys.forEach((key) => {
|
|
312
|
-
const keyed = items.find((item) => item._optionKey === key);
|
|
313
|
-
if (keyed && isSelectableByValue(keyed) && (remaining.get(keyed.value) || 0) > 0 && !resolvedSet.has(keyed)) {
|
|
314
|
-
resolved.push(keyed);
|
|
315
|
-
resolvedSet.add(keyed);
|
|
316
|
-
remaining.set(keyed.value, remaining.get(keyed.value) - 1);
|
|
317
|
-
}
|
|
318
|
-
});
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
// Fall back to value matching for the occurrences not resolved by key. Iterate
|
|
322
|
-
// the leftover per-value counts so a value that appears twice but was only
|
|
323
|
-
// resolved once by key still matches its remaining occurrence(s).
|
|
324
|
-
remaining.forEach((count, val) => {
|
|
325
|
-
for (let occurrence = 0; occurrence < count; occurrence += 1) {
|
|
326
|
-
const option = items.find((item) => isSelectableByValue(item) && item.value === val && !resolvedSet.has(item));
|
|
327
|
-
if (option) {
|
|
328
|
-
resolved.push(option);
|
|
329
|
-
resolvedSet.add(option);
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
});
|
|
333
|
-
|
|
334
|
-
// Always return in DOM order so display is consistent regardless of the order
|
|
335
|
-
// keys/values were selected. Every resolved option came from `items`, so an
|
|
336
|
-
// O(1) index lookup mirrors `_sortSelectedByDomOrder` and avoids the O(n)
|
|
337
|
-
// `items.indexOf` per comparison for large combobox option sets. Any element
|
|
338
|
-
// not in `items` (a stale snapshot from a future caller) sorts to the END via
|
|
339
|
-
// `?? items.length`, matching `_sortSelectedByDomOrder` and avoiding NaN
|
|
340
|
-
// comparisons.
|
|
341
|
-
const indexMap = new Map(items.map((item, index) => [
|
|
342
|
-
item,
|
|
343
|
-
index
|
|
344
|
-
]));
|
|
345
|
-
resolved.sort((optionA, optionB) => (indexMap.get(optionA) ?? items.length) - (indexMap.get(optionB) ?? items.length));
|
|
346
|
-
|
|
347
|
-
return resolved;
|
|
348
|
-
}
|
|
349
|
-
/* eslint-enable no-underscore-dangle */
|
|
350
|
-
|
|
351
241
|
/**
|
|
352
242
|
* Helper method to dispatch custom events.
|
|
353
243
|
* @param {HTMLElement} element - Element to dispatch event from.
|
|
@@ -373,14 +263,6 @@ function dispatchMenuEvent(element, eventName, detail = null) {
|
|
|
373
263
|
// See LICENSE in the project root for license information.
|
|
374
264
|
|
|
375
265
|
|
|
376
|
-
/**
|
|
377
|
-
* Monotonically increasing counter used to give each menu instance a unique
|
|
378
|
-
* `_menuInstanceId` prefix. Auto-generating the id (rather than using a random
|
|
379
|
-
* string) keeps option keys deterministic and collision-free across menus.
|
|
380
|
-
* @private
|
|
381
|
-
*/
|
|
382
|
-
let menuInstanceIdCounter = 0;
|
|
383
|
-
|
|
384
266
|
|
|
385
267
|
/**
|
|
386
268
|
* The `auro-menu` element provides users a way to select from a list of options.
|
|
@@ -452,8 +334,9 @@ class AuroMenu extends AuroElement {
|
|
|
452
334
|
|
|
453
335
|
// Instance properties (non-reactive)
|
|
454
336
|
|
|
455
|
-
|
|
456
|
-
|
|
337
|
+
/**
|
|
338
|
+
* @private
|
|
339
|
+
*/
|
|
457
340
|
Object.assign(this, {
|
|
458
341
|
// Root-level menu (true) or a nested submenu (false)
|
|
459
342
|
rootMenu: true,
|
|
@@ -463,21 +346,6 @@ class AuroMenu extends AuroElement {
|
|
|
463
346
|
nestingSpacer: '<span class="nestingSpacer"></span>',
|
|
464
347
|
// Loading indicator for slot elements
|
|
465
348
|
loadingSlots: null,
|
|
466
|
-
// Unique id for this menu instance; prefixes every auto-generated option
|
|
467
|
-
// key so keys never collide across menus in the same document.
|
|
468
|
-
_menuInstanceId: `menu-${menuInstanceIdCounter}`,
|
|
469
|
-
// Monotonically increasing counter for option key generation. Never
|
|
470
|
-
// resets, so a key is never reused within this instance's lifetime.
|
|
471
|
-
_optionKeyCounter: 0,
|
|
472
|
-
// Key(s) of the option(s) the user has actively selected. A single string
|
|
473
|
-
// in single-select, an array in multi-select, undefined when nothing is
|
|
474
|
-
// user-selected. Used to disambiguate options that share a `value`.
|
|
475
|
-
_selectedKey: undefined,
|
|
476
|
-
// True only for the one updated() cycle following a user selection, so
|
|
477
|
-
// reconciliation trusts `_selectedKey`. A `value` change from a consumer's
|
|
478
|
-
// direct property assignment leaves this false, dropping the stale key so
|
|
479
|
-
// reconciliation falls back to first-by-value (see updated()).
|
|
480
|
-
_valueChangeFromSelection: false,
|
|
481
349
|
});
|
|
482
350
|
}
|
|
483
351
|
|
|
@@ -697,13 +565,6 @@ class AuroMenu extends AuroElement {
|
|
|
697
565
|
return;
|
|
698
566
|
}
|
|
699
567
|
|
|
700
|
-
// A programmatic value set carries no positional intent, so drop any
|
|
701
|
-
// `_selectedKey` left over from a prior user click. This makes reconciliation
|
|
702
|
-
// in updated() fall back to first-by-value (single) / value-in-DOM-order
|
|
703
|
-
// (multi), matching the documented contract for programmatic selection even
|
|
704
|
-
// when a stale key would still resolve to a duplicate-value option.
|
|
705
|
-
this._selectedKey = undefined;
|
|
706
|
-
|
|
707
568
|
// `value` is a String property; stringify arrays so attribute reflection and `formattedValue` parsing stay correct.
|
|
708
569
|
this.value = Array.isArray(value) ? JSON.stringify(value) : value;
|
|
709
570
|
}
|
|
@@ -751,17 +612,6 @@ class AuroMenu extends AuroElement {
|
|
|
751
612
|
updated(changedProperties) {
|
|
752
613
|
super.updated(changedProperties);
|
|
753
614
|
|
|
754
|
-
// Consume the selection-driven flag for THIS cycle up front. Clearing it
|
|
755
|
-
// unconditionally — not only inside the `value` branch below — prevents it
|
|
756
|
-
// from lingering `true` when a selection produces a serialized `value`
|
|
757
|
-
// byte-identical to the current one, in which case Lit schedules no
|
|
758
|
-
// `value`-change cycle to consume it. A lingering flag would misclassify a
|
|
759
|
-
// later consumer's programmatic `value` set as selection-driven and keep a
|
|
760
|
-
// stale `_selectedKey`. The reconcile path below re-sets the instance flag
|
|
761
|
-
// after this point, so its intentional cross-cycle hand-off still works.
|
|
762
|
-
const valueChangeFromSelection = this._valueChangeFromSelection;
|
|
763
|
-
this._valueChangeFromSelection = false;
|
|
764
|
-
|
|
765
615
|
// Single source of truth for 'auroMenu-selectedOption'. Selection handlers
|
|
766
616
|
// mutate optionSelected and let Lit's update cycle dispatch here; the prior
|
|
767
617
|
// .value comparison missed multi-select array changes and combined with the
|
|
@@ -785,17 +635,6 @@ class AuroMenu extends AuroElement {
|
|
|
785
635
|
this.initItems();
|
|
786
636
|
}
|
|
787
637
|
|
|
788
|
-
// Distinguish a selection-driven `value` change (a user click, which set
|
|
789
|
-
// the flag in handleSelectState / _sortSelectedByDomOrder) from a
|
|
790
|
-
// programmatic assignment by a consumer. A programmatic set carries no
|
|
791
|
-
// positional intent, so drop any leftover `_selectedKey` and let
|
|
792
|
-
// reconciliation fall back to first-by-value (single) / value-in-DOM-order
|
|
793
|
-
// (multi) — the same contract selectByValue() guarantees, even when a
|
|
794
|
-
// stale key would otherwise still resolve to a duplicate-value option.
|
|
795
|
-
if (!valueChangeFromSelection) {
|
|
796
|
-
this._selectedKey = undefined;
|
|
797
|
-
}
|
|
798
|
-
|
|
799
638
|
// Set when reconciliation reassigns `value` below. That reassignment schedules a
|
|
800
639
|
// second updated() cycle, so the `event`-attribute dispatch is deferred to that
|
|
801
640
|
// cycle to avoid firing option custom events twice on the same selection.
|
|
@@ -813,55 +652,19 @@ class AuroMenu extends AuroElement {
|
|
|
813
652
|
// Defensive default: `formattedValue` can be undefined for unexpected value types,
|
|
814
653
|
// and calling `.includes` on undefined would throw during reconciliation.
|
|
815
654
|
const valueArray = this.formattedValue || [];
|
|
816
|
-
|
|
817
|
-
// value matching for any values not resolved by key — so pre-selection
|
|
818
|
-
// and programmatic value sets keep working. Result is DOM-ordered.
|
|
819
|
-
const matchingOptions = resolveSelectedOptions(this.items, valueArray, this._selectedKey);
|
|
655
|
+
const matchingOptions = this.items ? this.items.filter((item) => isSelectableByValue(item) && valueArray.includes(item.value)) : [];
|
|
820
656
|
newSelected = matchingOptions.length > 0 ? matchingOptions : undefined;
|
|
821
657
|
|
|
822
|
-
// Reconcile `value` with the selectable set.
|
|
823
|
-
//
|
|
824
|
-
//
|
|
825
|
-
//
|
|
826
|
-
//
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
// resurface on the next select/deselect.
|
|
833
|
-
const selectableByValue = new Map();
|
|
834
|
-
const loadedValues = new Set();
|
|
835
|
-
if (this.items) {
|
|
836
|
-
this.items.forEach((item) => {
|
|
837
|
-
loadedValues.add(item.value);
|
|
838
|
-
if (isSelectableByValue(item)) {
|
|
839
|
-
selectableByValue.set(item.value, (selectableByValue.get(item.value) || 0) + 1);
|
|
840
|
-
}
|
|
841
|
-
});
|
|
842
|
-
}
|
|
843
|
-
|
|
844
|
-
const reconciled = valueArray.filter((val) => {
|
|
845
|
-
// Not loaded yet (async preselection) — keep for a later cycle.
|
|
846
|
-
if (!loadedValues.has(val)) {
|
|
847
|
-
return true;
|
|
848
|
-
}
|
|
849
|
-
// Consume one selectable option per occurrence; drop once exhausted.
|
|
850
|
-
const remaining = selectableByValue.get(val) || 0;
|
|
851
|
-
if (remaining > 0) {
|
|
852
|
-
selectableByValue.set(val, remaining - 1);
|
|
853
|
-
return true;
|
|
854
|
-
}
|
|
855
|
-
return false;
|
|
856
|
-
});
|
|
857
|
-
|
|
858
|
-
if (reconciled.length !== valueArray.length) {
|
|
859
|
-
// This is an internal correction, not a consumer's programmatic set,
|
|
860
|
-
// so preserve the selection-driven flag through the re-entrant
|
|
861
|
-
// updated() cycle it schedules. Otherwise that cycle would treat the
|
|
862
|
-
// reassignment as programmatic and drop `_selectedKey` mid-cascade,
|
|
863
|
-
// flipping resolution and looping.
|
|
864
|
-
this._valueChangeFromSelection = true;
|
|
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));
|
|
865
668
|
this.value = serializeMultiSelectValue(reconciled);
|
|
866
669
|
valueReconciled = true;
|
|
867
670
|
}
|
|
@@ -873,11 +676,7 @@ class AuroMenu extends AuroElement {
|
|
|
873
676
|
// `hidden` is intentionally NOT excluded: the combobox toggles
|
|
874
677
|
// `hidden` as its type-ahead filter, so a filtered-out option is
|
|
875
678
|
// still a valid programmatic selection.
|
|
876
|
-
|
|
877
|
-
// `_selectedKey`) so a click on the second of two options sharing a
|
|
878
|
-
// `value` resolves back to that exact element instead of the first
|
|
879
|
-
// value match. Falls back to first-by-value for programmatic sets.
|
|
880
|
-
const matchingOption = resolveSelectedOption(this.items, this.value, this._selectedKey);
|
|
679
|
+
const matchingOption = this.items ? this.items.find((item) => isSelectableByValue(item) && item.value === this.value) : undefined;
|
|
881
680
|
|
|
882
681
|
if (matchingOption) {
|
|
883
682
|
newSelected = matchingOption;
|
|
@@ -1105,14 +904,6 @@ class AuroMenu extends AuroElement {
|
|
|
1105
904
|
}
|
|
1106
905
|
});
|
|
1107
906
|
|
|
1108
|
-
// Assign private keys once items are populated. Only the root menu assigns
|
|
1109
|
-
// keys: its `items` is a deep query that already includes nested submenu
|
|
1110
|
-
// options, so a single pass keys the entire tree. Nested menus skip this
|
|
1111
|
-
// and inherit keys from the root.
|
|
1112
|
-
if (this.rootMenu) {
|
|
1113
|
-
this._assignOptionKeys();
|
|
1114
|
-
}
|
|
1115
|
-
|
|
1116
907
|
if (this.noCheckmark) {
|
|
1117
908
|
this.updateItemsState(new Map([
|
|
1118
909
|
[
|
|
@@ -1129,31 +920,6 @@ class AuroMenu extends AuroElement {
|
|
|
1129
920
|
}));
|
|
1130
921
|
}
|
|
1131
922
|
|
|
1132
|
-
/**
|
|
1133
|
-
* Assigns a private, auto-generated unique key (`_optionKey`) to each menu
|
|
1134
|
-
* option that does not already have one. Keys are internal state on the
|
|
1135
|
-
* element instance — never reflected as an attribute or exposed publicly —
|
|
1136
|
-
* and let selection tracking distinguish options that share the same `value`.
|
|
1137
|
-
*
|
|
1138
|
-
* The `_optionKey === undefined` guard makes this idempotent: options keep the
|
|
1139
|
-
* key they were first assigned across re-renders and slot changes, and if a
|
|
1140
|
-
* nested menu's lifecycle runs a pass before the root, options simply wait for
|
|
1141
|
-
* the root to key them (or keep whatever key they already hold).
|
|
1142
|
-
* @private
|
|
1143
|
-
*/
|
|
1144
|
-
_assignOptionKeys() {
|
|
1145
|
-
if (!this.items) {
|
|
1146
|
-
return;
|
|
1147
|
-
}
|
|
1148
|
-
|
|
1149
|
-
this.items.forEach((option) => {
|
|
1150
|
-
if (option._optionKey === undefined) {
|
|
1151
|
-
this._optionKeyCounter += 1;
|
|
1152
|
-
option._optionKey = `${this._menuInstanceId}-${this._optionKeyCounter}`;
|
|
1153
|
-
}
|
|
1154
|
-
});
|
|
1155
|
-
}
|
|
1156
|
-
|
|
1157
923
|
// Logic Methods
|
|
1158
924
|
|
|
1159
925
|
/**
|
|
@@ -1163,28 +929,24 @@ class AuroMenu extends AuroElement {
|
|
|
1163
929
|
*/
|
|
1164
930
|
handleSelectState(option) {
|
|
1165
931
|
if (this.multiSelect) {
|
|
932
|
+
const currentValue = this.formattedValue || [];
|
|
1166
933
|
const currentSelected = this.optionSelected || [];
|
|
1167
934
|
|
|
935
|
+
if (!currentValue.includes(option.value)) {
|
|
936
|
+
this.value = serializeMultiSelectValue([
|
|
937
|
+
...currentValue,
|
|
938
|
+
option.value
|
|
939
|
+
]);
|
|
940
|
+
}
|
|
1168
941
|
if (!currentSelected.includes(option)) {
|
|
1169
942
|
this.optionSelected = [
|
|
1170
943
|
...currentSelected,
|
|
1171
944
|
option
|
|
1172
945
|
];
|
|
1173
946
|
}
|
|
1174
|
-
|
|
1175
|
-
// Re-sort by DOM order and rebuild `_selectedKey`/`value` from the
|
|
1176
|
-
// selected set so display order stays consistent with the menu, not with
|
|
1177
|
-
// click order.
|
|
1178
|
-
this._sortSelectedByDomOrder();
|
|
1179
947
|
} else {
|
|
1180
948
|
this.value = option.value;
|
|
1181
949
|
this.optionSelected = option;
|
|
1182
|
-
// Track the specific option the user selected so the value→option
|
|
1183
|
-
// reconciliation in updated() resolves back to this exact element even
|
|
1184
|
-
// when another option shares the same `value`.
|
|
1185
|
-
this._selectedKey = option._optionKey;
|
|
1186
|
-
// Mark this `value` change as selection-driven so updated() trusts the key.
|
|
1187
|
-
this._valueChangeFromSelection = true;
|
|
1188
950
|
}
|
|
1189
951
|
|
|
1190
952
|
this._index = this.items.indexOf(option);
|
|
@@ -1197,22 +959,18 @@ class AuroMenu extends AuroElement {
|
|
|
1197
959
|
*/
|
|
1198
960
|
handleDeselectState(option) {
|
|
1199
961
|
if (this.multiSelect) {
|
|
1200
|
-
// Remove this
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
962
|
+
// Remove this option from array; an empty result collapses `value` to undefined.
|
|
963
|
+
const newFormattedValue = (this.formattedValue || []).filter((val) => val !== option.value);
|
|
964
|
+
this.value = serializeMultiSelectValue(newFormattedValue);
|
|
965
|
+
|
|
966
|
+
this.optionSelected = this.optionSelected.filter((val) => val !== option);
|
|
1204
967
|
if (this.optionSelected.length === 0) {
|
|
1205
968
|
this.optionSelected = undefined;
|
|
1206
|
-
this._selectedKey = undefined;
|
|
1207
|
-
this.value = undefined;
|
|
1208
|
-
} else {
|
|
1209
|
-
this._sortSelectedByDomOrder();
|
|
1210
969
|
}
|
|
1211
970
|
} else {
|
|
1212
971
|
// For single-select: Back to undefined when deselected
|
|
1213
972
|
this.value = undefined;
|
|
1214
973
|
this.optionSelected = undefined;
|
|
1215
|
-
this._selectedKey = undefined;
|
|
1216
974
|
}
|
|
1217
975
|
|
|
1218
976
|
// Update the index tracking
|
|
@@ -1236,38 +994,9 @@ class AuroMenu extends AuroElement {
|
|
|
1236
994
|
clearSelection() {
|
|
1237
995
|
this.optionSelected = undefined;
|
|
1238
996
|
this.value = undefined;
|
|
1239
|
-
this._selectedKey = undefined;
|
|
1240
997
|
this._index = -1;
|
|
1241
998
|
}
|
|
1242
999
|
|
|
1243
|
-
/**
|
|
1244
|
-
* Re-sorts the multi-select selection into DOM order and rebuilds the derived
|
|
1245
|
-
* `_selectedKey` and `value` from `optionSelected`. Selection is always stored
|
|
1246
|
-
* and serialized in the order options appear in the menu, never in click
|
|
1247
|
-
* order — so selecting C then A yields `[A, C]`.
|
|
1248
|
-
* @private
|
|
1249
|
-
*/
|
|
1250
|
-
_sortSelectedByDomOrder() {
|
|
1251
|
-
if (!this.multiSelect || !Array.isArray(this.optionSelected) || !this.items) {
|
|
1252
|
-
return;
|
|
1253
|
-
}
|
|
1254
|
-
|
|
1255
|
-
const indexMap = new Map(this.items.map((item, index) => [
|
|
1256
|
-
item,
|
|
1257
|
-
index
|
|
1258
|
-
]));
|
|
1259
|
-
|
|
1260
|
-
// Sort any element no longer in `items` (a stale selection left over from a
|
|
1261
|
-
// dynamic rebuild that the consumer has not cleared) to the END rather than
|
|
1262
|
-
// the front, so it never displaces a live option to the head of the
|
|
1263
|
-
// serialized order. Value reconciliation drops it on the next updated() cycle.
|
|
1264
|
-
this.optionSelected.sort((optionA, optionB) => (indexMap.get(optionA) ?? this.items.length) - (indexMap.get(optionB) ?? this.items.length));
|
|
1265
|
-
this._selectedKey = this.optionSelected.map((option) => option._optionKey);
|
|
1266
|
-
this.value = serializeMultiSelectValue(this.optionSelected.map((option) => option.value));
|
|
1267
|
-
// Mark this `value` change as selection-driven so updated() trusts the keys.
|
|
1268
|
-
this._valueChangeFromSelection = true;
|
|
1269
|
-
}
|
|
1270
|
-
|
|
1271
1000
|
/**
|
|
1272
1001
|
* Resets the menu to its initial state.
|
|
1273
1002
|
* This is the only way to return value to undefined.
|
|
@@ -1277,7 +1006,6 @@ class AuroMenu extends AuroElement {
|
|
|
1277
1006
|
// Reset to undefined - initial state
|
|
1278
1007
|
this.value = undefined;
|
|
1279
1008
|
this.optionSelected = undefined;
|
|
1280
|
-
this._selectedKey = undefined;
|
|
1281
1009
|
this._index = -1;
|
|
1282
1010
|
|
|
1283
1011
|
// Clear active option state so a follow-up open/navigation starts fresh
|
|
@@ -1339,19 +1067,6 @@ class AuroMenu extends AuroElement {
|
|
|
1339
1067
|
this.initItems();
|
|
1340
1068
|
}
|
|
1341
1069
|
|
|
1342
|
-
// Recover `_index` from the highlighted option when it has been reset to -1.
|
|
1343
|
-
// In multi-select, deselecting the last remaining option collapses the value
|
|
1344
|
-
// to undefined, and the updated() reconciliation resets `_index = -1` even
|
|
1345
|
-
// though `optionActive` still points at the highlighted option. Without this,
|
|
1346
|
-
// reading `items[-1]` returns undefined and the re-select no-ops until the
|
|
1347
|
-
// highlight is moved away and back. Mirrors auro-combobox's reconcileMenuIndex.
|
|
1348
|
-
if (this._index < 0 && this.optionActive && this.items) {
|
|
1349
|
-
const activeIndex = this.items.indexOf(this.optionActive);
|
|
1350
|
-
if (activeIndex >= 0) {
|
|
1351
|
-
this._index = activeIndex;
|
|
1352
|
-
}
|
|
1353
|
-
}
|
|
1354
|
-
|
|
1355
1070
|
// Get currently selected menu option based on index
|
|
1356
1071
|
const option = this.items ? this.items[this._index] : undefined;
|
|
1357
1072
|
|
|
@@ -1227,7 +1227,7 @@ class AuroHelpText extends i$2 {
|
|
|
1227
1227
|
}
|
|
1228
1228
|
}
|
|
1229
1229
|
|
|
1230
|
-
var formkitVersion = '
|
|
1230
|
+
var formkitVersion = '202608041712';
|
|
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 = '202608041712';
|
|
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 = '202608041712';
|
|
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 = '202608041712';
|
|
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 = '202608041712';
|
|
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.
|
|
@@ -33,7 +33,6 @@
|
|
|
33
33
|
<auro-anchorlink fluid href="#noValidate" class="level2 body-xs">No Validation</auro-anchorlink>
|
|
34
34
|
<auro-anchorlink fluid href="#placeholder" class="level2 body-xs">Placeholder</auro-anchorlink>
|
|
35
35
|
<auro-anchorlink fluid href="#loading" class="level2 body-xs">Loading</auro-anchorlink>
|
|
36
|
-
<auro-anchorlink fluid href="#nonUniqueValues" class="level2 body-xs">Non-Unique Option Values</auro-anchorlink>
|
|
37
36
|
</auro-nav>
|
|
38
37
|
</nav>
|
|
39
38
|
<div class="mainContent">
|
|
@@ -1298,77 +1297,6 @@
|
|
|
1298
1297
|
</auro-select></code></pre>
|
|
1299
1298
|
<!-- AURO-GENERATED-CONTENT:END -->
|
|
1300
1299
|
</auro-accordion>
|
|
1301
|
-
<auro-header level="3" id="nonUniqueValues">Non-Unique Option Values</auro-header>
|
|
1302
|
-
<p>Two or more <code>auro-menuoption</code> elements may share the same <code>value</code>. This is common when the <code>value</code> represents a coarser grouping than the option label — for example, several airports that all serve the same city. The component tracks the specific option a user selects, so the correct label is displayed even when the underlying <code>value</code> is duplicated.</p>
|
|
1303
|
-
<div class="exampleWrapper">
|
|
1304
|
-
<!-- AURO-GENERATED-CONTENT:START (FILE:src=./../apiExamples/duplicate-values.html) -->
|
|
1305
|
-
<!-- The below content is automatically added from ./../apiExamples/duplicate-values.html -->
|
|
1306
|
-
<auro-select>
|
|
1307
|
-
<span slot="ariaLabel.bib.close">Close Popup</span>
|
|
1308
|
-
<span slot="bib.fullscreen.headline">Choose an airport</span>
|
|
1309
|
-
<span slot="label">Departure airport</span>
|
|
1310
|
-
<auro-menu>
|
|
1311
|
-
<auro-menuoption value="seattle">Seattle–Tacoma International (SEA)</auro-menuoption>
|
|
1312
|
-
<auro-menuoption value="seattle">Seattle Paine Field (PAE)</auro-menuoption>
|
|
1313
|
-
<auro-menuoption value="portland">Portland International (PDX)</auro-menuoption>
|
|
1314
|
-
<auro-menuoption value="spokane">Spokane International (GEG)</auro-menuoption>
|
|
1315
|
-
</auro-menu>
|
|
1316
|
-
</auro-select>
|
|
1317
|
-
<!-- AURO-GENERATED-CONTENT:END -->
|
|
1318
|
-
</div>
|
|
1319
|
-
<auro-accordion alignRight>
|
|
1320
|
-
<span slot="trigger">See code</span>
|
|
1321
|
-
<!-- AURO-GENERATED-CONTENT:START (CODE:src=./../apiExamples/duplicate-values.html) -->
|
|
1322
|
-
<!-- The below code snippet is automatically added from ./../apiExamples/duplicate-values.html -->
|
|
1323
|
-
<pre class="language-html"><code class="language-html"><auro-select>
|
|
1324
|
-
<span slot="ariaLabel.bib.close">Close Popup</span>
|
|
1325
|
-
<span slot="bib.fullscreen.headline">Choose an airport</span>
|
|
1326
|
-
<span slot="label">Departure airport</span>
|
|
1327
|
-
<auro-menu>
|
|
1328
|
-
<auro-menuoption value="seattle">Seattle&ndash;Tacoma International (SEA)</auro-menuoption>
|
|
1329
|
-
<auro-menuoption value="seattle">Seattle Paine Field (PAE)</auro-menuoption>
|
|
1330
|
-
<auro-menuoption value="portland">Portland International (PDX)</auro-menuoption>
|
|
1331
|
-
<auro-menuoption value="spokane">Spokane International (GEG)</auro-menuoption>
|
|
1332
|
-
</auro-menu>
|
|
1333
|
-
</auro-select></code></pre>
|
|
1334
|
-
<!-- AURO-GENERATED-CONTENT:END -->
|
|
1335
|
-
</auro-accordion>
|
|
1336
|
-
<p>In <code>multiselect</code> mode, options that share a <code>value</code> are tracked independently, so each can be selected and removed on its own. Selections are stored in DOM order regardless of the order in which they were chosen.</p>
|
|
1337
|
-
<div class="exampleWrapper">
|
|
1338
|
-
<!-- AURO-GENERATED-CONTENT:START (FILE:src=./../apiExamples/duplicate-values-multiselect.html) -->
|
|
1339
|
-
<!-- The below content is automatically added from ./../apiExamples/duplicate-values-multiselect.html -->
|
|
1340
|
-
<auro-select multiselect>
|
|
1341
|
-
<span slot="ariaLabel.bib.close">Close Popup</span>
|
|
1342
|
-
<span slot="bib.fullscreen.headline">Choose airports</span>
|
|
1343
|
-
<label slot="placeholder">Select one or more airports</label>
|
|
1344
|
-
<span slot="label">Airports served</span>
|
|
1345
|
-
<auro-menu>
|
|
1346
|
-
<auro-menuoption value="seattle">Seattle–Tacoma International (SEA)</auro-menuoption>
|
|
1347
|
-
<auro-menuoption value="seattle">Seattle Paine Field (PAE)</auro-menuoption>
|
|
1348
|
-
<auro-menuoption value="portland">Portland International (PDX)</auro-menuoption>
|
|
1349
|
-
<auro-menuoption value="spokane">Spokane International (GEG)</auro-menuoption>
|
|
1350
|
-
</auro-menu>
|
|
1351
|
-
</auro-select>
|
|
1352
|
-
<!-- AURO-GENERATED-CONTENT:END -->
|
|
1353
|
-
</div>
|
|
1354
|
-
<auro-accordion alignRight>
|
|
1355
|
-
<span slot="trigger">See code</span>
|
|
1356
|
-
<!-- AURO-GENERATED-CONTENT:START (CODE:src=./../apiExamples/duplicate-values-multiselect.html) -->
|
|
1357
|
-
<!-- The below code snippet is automatically added from ./../apiExamples/duplicate-values-multiselect.html -->
|
|
1358
|
-
<pre class="language-html"><code class="language-html"><auro-select multiselect>
|
|
1359
|
-
<span slot="ariaLabel.bib.close">Close Popup</span>
|
|
1360
|
-
<span slot="bib.fullscreen.headline">Choose airports</span>
|
|
1361
|
-
<label slot="placeholder">Select one or more airports</label>
|
|
1362
|
-
<span slot="label">Airports served</span>
|
|
1363
|
-
<auro-menu>
|
|
1364
|
-
<auro-menuoption value="seattle">Seattle&ndash;Tacoma International (SEA)</auro-menuoption>
|
|
1365
|
-
<auro-menuoption value="seattle">Seattle Paine Field (PAE)</auro-menuoption>
|
|
1366
|
-
<auro-menuoption value="portland">Portland International (PDX)</auro-menuoption>
|
|
1367
|
-
<auro-menuoption value="spokane">Spokane International (GEG)</auro-menuoption>
|
|
1368
|
-
</auro-menu>
|
|
1369
|
-
</auro-select></code></pre>
|
|
1370
|
-
<!-- AURO-GENERATED-CONTENT:END -->
|
|
1371
|
-
</auro-accordion>
|
|
1372
1300
|
</section>
|
|
1373
1301
|
</div>
|
|
1374
1302
|
</div>
|