@aurodesignsystem/auro-formkit 3.1.0-beta.1 → 3.1.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.
Files changed (49) hide show
  1. package/CHANGELOG.md +9 -3
  2. package/components/checkbox/demo/api.min.js +468 -25
  3. package/components/checkbox/demo/index.min.js +468 -25
  4. package/components/checkbox/dist/index.js +468 -25
  5. package/components/checkbox/dist/registered.js +468 -25
  6. package/components/combobox/demo/api.md +1 -1
  7. package/components/combobox/demo/api.min.js +1265 -235
  8. package/components/combobox/demo/index.min.js +1265 -235
  9. package/components/combobox/dist/auro-combobox.d.ts +32 -5
  10. package/components/combobox/dist/index.js +1130 -100
  11. package/components/combobox/dist/registered.js +1130 -100
  12. package/components/counter/demo/api.md +1 -1
  13. package/components/counter/demo/api.min.js +575 -71
  14. package/components/counter/demo/index.min.js +575 -71
  15. package/components/counter/dist/auro-counter-group.d.ts +2 -5
  16. package/components/counter/dist/index.js +575 -71
  17. package/components/counter/dist/registered.js +575 -71
  18. package/components/datepicker/demo/api.md +0 -1
  19. package/components/datepicker/demo/api.min.js +1077 -106
  20. package/components/datepicker/demo/index.min.js +1077 -106
  21. package/components/datepicker/dist/auro-datepicker.d.ts +0 -13
  22. package/components/datepicker/dist/index.js +1077 -106
  23. package/components/datepicker/dist/registered.js +1077 -106
  24. package/components/dropdown/demo/api.md +9 -6
  25. package/components/dropdown/demo/api.min.js +107 -43
  26. package/components/dropdown/demo/index.md +0 -83
  27. package/components/dropdown/demo/index.min.js +107 -43
  28. package/components/dropdown/dist/auro-dropdown.d.ts +30 -12
  29. package/components/dropdown/dist/index.js +107 -43
  30. package/components/dropdown/dist/registered.js +107 -43
  31. package/components/input/demo/api.md +4 -1
  32. package/components/input/demo/api.min.js +503 -25
  33. package/components/input/demo/index.min.js +503 -25
  34. package/components/input/dist/base-input.d.ts +24 -0
  35. package/components/input/dist/index.js +503 -25
  36. package/components/input/dist/registered.js +503 -25
  37. package/components/radio/demo/api.min.js +468 -25
  38. package/components/radio/demo/index.min.js +468 -25
  39. package/components/radio/dist/index.js +468 -25
  40. package/components/radio/dist/registered.js +468 -25
  41. package/components/select/demo/api.md +1 -1
  42. package/components/select/demo/api.min.js +575 -71
  43. package/components/select/demo/index.md +1 -46
  44. package/components/select/demo/index.min.js +575 -71
  45. package/components/select/dist/auro-select.d.ts +2 -5
  46. package/components/select/dist/index.js +575 -71
  47. package/components/select/dist/registered.js +575 -71
  48. package/package.json +2 -2
  49. package/components/form/demo/autocomplete.html +0 -15
@@ -136,6 +136,414 @@ const t={ATTRIBUTE:1},e$1=t=>(...e)=>({_$litDirective$:t,values:e});let i$1 = cl
136
136
  */
137
137
  const a=Symbol.for(""),o$1=t=>{if(t?.r===a)return t?._$litStatic$},s=t=>({_$litStatic$:t,r:a}),i=(t,...r)=>({_$litStatic$:r.reduce(((r,e,a)=>r+(t=>{if(void 0!==t._$litStatic$)return t._$litStatic$;throw Error(`Value passed to 'literal' function must be a 'literal' result: ${t}. Use 'unsafeStatic' to pass non-literal values, but\n take care to ensure page security.`)})(e)+t[a+1]),t[0]),r:a}),l=new Map,n=t=>(r,...e)=>{const a=e.length;let s,i;const n=[],u=[];let c,$=0,f=false;for(;$<a;){for(c=r[$];$<a&&void 0!==(i=e[$],s=o$1(i));)c+=s+r[++$],f=true;$!==a&&u.push(i),n.push(c),$++;}if($===a&&n.push(r[a]),f){const t=n.join("$$lit$$");void 0===(r=l.get(t))&&(n.raw=n,l.set(t,r=n)),e=u;}return t(r,...e)},u=n(x);
138
138
 
139
+ class DateFormatter {
140
+
141
+ constructor() {
142
+
143
+ /**
144
+ * @description Parses a date string into its components.
145
+ * @param {string} dateStr - Date string to parse.
146
+ * @param {string} format - Date format to parse.
147
+ * @returns {Object<key["month" | "day" | "year"]: number>|undefined}
148
+ */
149
+ this.parseDate = (dateStr, format = 'mm/dd/yyyy') => {
150
+
151
+ // Guard Clause: Date string is defined
152
+ if (!dateStr) {
153
+ return undefined;
154
+ }
155
+
156
+ // Assume the separator is a "/" a defined in our code base
157
+ const separator = '/';
158
+
159
+ // Get the parts of the date and format
160
+ const valueParts = dateStr.split(separator);
161
+ const formatParts = format.split(separator);
162
+
163
+ // Check if the value and format have the correct number of parts
164
+ if (valueParts.length !== formatParts.length) {
165
+ throw new Error('AuroDatepickerUtilities | parseDate: Date string and format length do not match');
166
+ }
167
+
168
+ // Holds the result to be returned
169
+ const result = formatParts.reduce((acc, part, index) => {
170
+ const value = valueParts[index];
171
+
172
+ if ((/m/iu).test(part)) {
173
+ acc.month = value;
174
+ } else if ((/d/iu).test(part)) {
175
+ acc.day = value;
176
+ } else if ((/y/iu).test(part)) {
177
+ acc.year = value;
178
+ }
179
+
180
+ return acc;
181
+ }, {});
182
+
183
+ // If we found all the parts, return the result
184
+ if (result.month && result.year) {
185
+ return result;
186
+ }
187
+
188
+ // Throw an error to let the dev know we were unable to parse the date string
189
+ throw new Error('AuroDatepickerUtilities | parseDate: Unable to parse date string');
190
+ };
191
+
192
+ /**
193
+ * Convert a date object to string format.
194
+ * @param {Object} date - Date to convert to string.
195
+ * @returns {Object} Returns the date as a string.
196
+ */
197
+ this.getDateAsString = (date) => date.toLocaleDateString(undefined, {
198
+ year: "numeric",
199
+ month: "2-digit",
200
+ day: "2-digit",
201
+ });
202
+
203
+ /**
204
+ * Converts a date string to a North American date format.
205
+ * @param {String} dateStr - Date to validate.
206
+ * @param {String} format - Date format to validate against.
207
+ * @returns {Boolean}
208
+ */
209
+ this.toNorthAmericanFormat = (dateStr, format) => {
210
+
211
+ if (format === 'mm/dd/yyyy') {
212
+ return dateStr;
213
+ }
214
+
215
+ const parsedDate = this.parseDate(dateStr, format);
216
+
217
+ if (!parsedDate) {
218
+ throw new Error('AuroDatepickerUtilities | toNorthAmericanFormat: Unable to parse date string');
219
+ }
220
+
221
+ const { month, day, year } = parsedDate;
222
+
223
+ const dateParts = [];
224
+ if (month) {
225
+ dateParts.push(month);
226
+ }
227
+
228
+ if (day) {
229
+ dateParts.push(day);
230
+ }
231
+
232
+ if (year) {
233
+ dateParts.push(year);
234
+ }
235
+
236
+ return dateParts.join('/');
237
+ };
238
+ }
239
+ }
240
+ const dateFormatter = new DateFormatter();
241
+
242
+ // filepath: dateConstraints.mjs
243
+ const DATE_UTIL_CONSTRAINTS = {
244
+ maxDay: 31,
245
+ maxMonth: 12,
246
+ maxYear: 2400,
247
+ minDay: 1,
248
+ minMonth: 1,
249
+ minYear: 1900,
250
+ };
251
+
252
+ class AuroDateUtilitiesBase {
253
+
254
+ /**
255
+ * @description The maximum day value allowed by the various utilities in this class.
256
+ * @readonly
257
+ * @type {Number}
258
+ */
259
+ get maxDay() {
260
+ return DATE_UTIL_CONSTRAINTS.maxDay;
261
+ }
262
+
263
+ /**
264
+ * @description The maximum month value allowed by the various utilities in this class.
265
+ * @readonly
266
+ * @type {Number}
267
+ */
268
+ get maxMonth() {
269
+ return DATE_UTIL_CONSTRAINTS.maxMonth;
270
+ }
271
+
272
+ /**
273
+ * @description The maximum year value allowed by the various utilities in this class.
274
+ * @readonly
275
+ * @type {Number}
276
+ */
277
+ get maxYear() {
278
+ return DATE_UTIL_CONSTRAINTS.maxYear;
279
+ }
280
+
281
+ /**
282
+ * @description The minimum day value allowed by the various utilities in this class.
283
+ * @readonly
284
+ * @type {Number}
285
+ */
286
+ get minDay() {
287
+ return DATE_UTIL_CONSTRAINTS.minDay;
288
+ }
289
+
290
+ /**
291
+ * @description The minimum month value allowed by the various utilities in this class.
292
+ * @readonly
293
+ * @type {Number}
294
+ */
295
+ get minMonth() {
296
+ return DATE_UTIL_CONSTRAINTS.minMonth;
297
+ }
298
+
299
+ /**
300
+ * @description The minimum year value allowed by the various utilities in this class.
301
+ * @readonly
302
+ * @type {Number}
303
+ */
304
+ get minYear() {
305
+ return DATE_UTIL_CONSTRAINTS.minYear;
306
+ }
307
+ }
308
+
309
+ /* eslint-disable no-magic-numbers */
310
+
311
+ class AuroDateUtilities extends AuroDateUtilitiesBase {
312
+
313
+ /**
314
+ * Returns the current century.
315
+ * @returns {String} The current century.
316
+ */
317
+ getCentury () {
318
+ return String(new Date().getFullYear()).slice(0, 2);
319
+ }
320
+
321
+ /**
322
+ * Returns a four digit year.
323
+ * @param {String} year - The year to convert to four digits.
324
+ * @returns {String} The four digit year.
325
+ */
326
+ getFourDigitYear (year) {
327
+
328
+ const strYear = String(year).trim();
329
+ return strYear.length <= 2 ? this.getCentury() + strYear : strYear;
330
+ }
331
+
332
+ constructor() {
333
+
334
+ super();
335
+
336
+ /**
337
+ * Compares two dates to see if they match.
338
+ * @param {Object} date1 - First date to compare.
339
+ * @param {Object} date2 - Second date to compare.
340
+ * @returns {Boolean} Returns true if the dates match.
341
+ */
342
+ this.datesMatch = (date1, date2) => new Date(date1).getTime() === new Date(date2).getTime();
343
+
344
+ /**
345
+ * Returns true if value passed in is a valid date.
346
+ * @param {String} date - Date to validate.
347
+ * @param {String} format - Date format to validate against.
348
+ * @returns {Boolean}
349
+ */
350
+ this.validDateStr = (date, format) => {
351
+
352
+ // The length we expect the date string to be
353
+ const dateStrLength = format.length;
354
+
355
+ // Guard Clause: Date and format are defined
356
+ if (typeof date === "undefined" || typeof format === "undefined") {
357
+ throw new Error('AuroDatepickerUtilities | validateDateStr: Date and format are required');
358
+ }
359
+
360
+ // Guard Clause: Date should be of type string
361
+ if (typeof date !== "string") {
362
+ throw new Error('AuroDatepickerUtilities | validateDateStr: Date must be a string');
363
+ }
364
+
365
+ // Guard Clause: Format should be of type string
366
+ if (typeof format !== "string") {
367
+ throw new Error('AuroDatepickerUtilities | validateDateStr: Format must be a string');
368
+ }
369
+
370
+ // Guard Clause: Length is what we expect it to be
371
+ if (date.length !== dateStrLength) {
372
+ return false;
373
+ }
374
+ // Get a formatted date string and parse it
375
+ const dateParts = dateFormatter.parseDate(date, format);
376
+
377
+ // Guard Clause: Date parse succeeded
378
+ if (!dateParts) {
379
+ return false;
380
+ }
381
+
382
+ // Create the expected date string based on the date parts
383
+ const expectedDateStr = `${dateParts.month}/${dateParts.day || "01"}/${this.getFourDigitYear(dateParts.year)}`;
384
+
385
+ // Generate a date object that we will extract a string date from to compare to the passed in date string
386
+ const dateObj = new Date(this.getFourDigitYear(dateParts.year), dateParts.month - 1, dateParts.day || 1);
387
+
388
+ // Get the date string of the date object we created from the string date
389
+ const actualDateStr = dateFormatter.getDateAsString(dateObj);
390
+
391
+ // Guard Clause: Generated date matches date string input
392
+ if (expectedDateStr !== actualDateStr) {
393
+ return false;
394
+ }
395
+
396
+ // If we passed all other checks, we can assume the date is valid
397
+ return true;
398
+ };
399
+
400
+ /**
401
+ * Determines if a string date value matches the format provided.
402
+ * @param {string} value = The date string value.
403
+ * @param { string} format = The date format to match against.
404
+ * @returns {boolean}
405
+ */
406
+ this.dateAndFormatMatch = (value, format) => {
407
+
408
+ // Ensure we have both values we need to do the comparison
409
+ if (!value || !format) {
410
+ throw new Error('AuroFormValidation | dateFormatMatch: value and format are required');
411
+ }
412
+
413
+ // If the lengths are different, they cannot match
414
+ if (value.length !== format.length) {
415
+ return false;
416
+ }
417
+
418
+ // Get the parts of the date
419
+ const dateParts = dateFormatter.parseDate(value, format);
420
+
421
+ // Validator for day
422
+ const dayValueIsValid = (day) => {
423
+
424
+ // Guard clause: if there is no day in the dateParts, we can ignore this check.
425
+ if (!dateParts.day) {
426
+ return true;
427
+ }
428
+
429
+ // Guard clause: ensure day exists.
430
+ if (!day) {
431
+ return false;
432
+ }
433
+
434
+ // Convert day to number
435
+ const numDay = Number.parseInt(day, 10);
436
+
437
+ // Guard clause: ensure day is a valid integer
438
+ if (Number.isNaN(numDay)) {
439
+ throw new Error('AuroDatepickerUtilities | dayValueIsValid: Unable to parse day value integer');
440
+ }
441
+
442
+ // Guard clause: ensure day is within the valid range
443
+ if (numDay < this.minDay || numDay > this.maxDay) {
444
+ return false;
445
+ }
446
+
447
+ // Default return
448
+ return true;
449
+ };
450
+
451
+ // Validator for month
452
+ const monthValueIsValid = (month) => {
453
+
454
+ // Guard clause: ensure month exists.
455
+ if (!month) {
456
+ return false;
457
+ }
458
+
459
+ // Convert month to number
460
+ const numMonth = Number.parseInt(month, 10);
461
+
462
+ // Guard clause: ensure month is a valid integer
463
+ if (Number.isNaN(numMonth)) {
464
+ throw new Error('AuroDatepickerUtilities | monthValueIsValid: Unable to parse month value integer');
465
+ }
466
+
467
+ // Guard clause: ensure month is within the valid range
468
+ if (numMonth < this.minMonth || numMonth > this.maxMonth) {
469
+ return false;
470
+ }
471
+
472
+ // Default return
473
+ return true;
474
+ };
475
+
476
+ // Validator for year
477
+ const yearIsValid = (_year) => {
478
+
479
+ // Guard clause: ensure year exists.
480
+ if (!_year) {
481
+ return false;
482
+ }
483
+
484
+ // Get the full year
485
+ const year = this.getFourDigitYear(_year);
486
+
487
+ // Convert year to number
488
+ const numYear = Number.parseInt(year, 10);
489
+
490
+ // Guard clause: ensure year is a valid integer
491
+ if (Number.isNaN(numYear)) {
492
+ throw new Error('AuroDatepickerUtilities | yearValueIsValid: Unable to parse year value integer');
493
+ }
494
+
495
+ // Guard clause: ensure year is within the valid range
496
+ if (numYear < this.minYear || numYear > this.maxYear) {
497
+ return false;
498
+ }
499
+
500
+ // Default return
501
+ return true;
502
+ };
503
+
504
+ // Self-contained checks for month, day, and year
505
+ const checks = [
506
+ monthValueIsValid(dateParts.month),
507
+ dayValueIsValid(dateParts.day),
508
+ yearIsValid(dateParts.year)
509
+ ];
510
+
511
+ // If any of the checks failed, the date format does not match and the result is invalid
512
+ const isValid = checks.every((check) => check === true);
513
+
514
+ // If the check is invalid, return false
515
+ if (!isValid) {
516
+ return false;
517
+ }
518
+
519
+ // Default case
520
+ return true;
521
+ };
522
+ }
523
+ }
524
+
525
+ // Export a class instance
526
+ const dateUtilities = new AuroDateUtilities();
527
+
528
+ // Export the class instance methods individually
529
+ const {
530
+ datesMatch,
531
+ validDateStr,
532
+ dateAndFormatMatch,
533
+ minDay,
534
+ minMonth,
535
+ minYear,
536
+ maxDay,
537
+ maxMonth,
538
+ maxYear
539
+ } = dateUtilities;
540
+
541
+ const {
542
+ toNorthAmericanFormat,
543
+ parseDate,
544
+ getDateAsString
545
+ } = dateFormatter;
546
+
139
547
  // Copyright (c) Alaska Air. All right reserved. Licensed under the Apache-2.0 license
140
548
  // See LICENSE in the project root for license information.
141
549
 
@@ -211,6 +619,7 @@ let AuroLibraryRuntimeUtils$3 = class AuroLibraryRuntimeUtils {
211
619
 
212
620
 
213
621
  class AuroFormValidation {
622
+
214
623
  constructor() {
215
624
  this.runtimeUtils = new AuroLibraryRuntimeUtils$3();
216
625
  }
@@ -302,17 +711,17 @@ class AuroFormValidation {
302
711
  ]
303
712
  }
304
713
  };
305
-
714
+
306
715
  let elementType;
307
716
  if (this.runtimeUtils.elementMatch(elem, 'auro-input')) {
308
717
  elementType = 'input';
309
718
  } else if (this.runtimeUtils.elementMatch(elem, 'auro-counter') || this.runtimeUtils.elementMatch(elem, 'auro-counter-group')) {
310
719
  elementType = 'counter';
311
720
  }
312
-
721
+
313
722
  if (elementType) {
314
723
  const rules = validationRules[elementType];
315
-
724
+
316
725
  if (rules) {
317
726
  Object.values(rules).flat().forEach(rule => {
318
727
  if (rule.check(elem)) {
@@ -338,48 +747,82 @@ class AuroFormValidation {
338
747
  if (!elem.value.match(emailRegex)) {
339
748
  elem.validity = 'patternMismatch';
340
749
  elem.errorMessage = elem.setCustomValidityForType || elem.setCustomValidity || '';
750
+ return;
341
751
  }
342
752
  } else if (elem.type === 'credit-card') {
343
753
  if (elem.value.length > 0 && elem.value.length < elem.validationCCLength) {
344
754
  elem.validity = 'tooShort';
345
755
  elem.errorMessage = elem.setCustomValidityForType || elem.setCustomValidity || '';
756
+ return;
346
757
  }
347
758
  } else if (elem.type === 'number') {
348
759
  if (elem.max !== undefined && Number(elem.max) < Number(elem.value)) {
349
760
  elem.validity = 'rangeOverflow';
350
761
  elem.errorMessage = elem.setCustomValidityRangeOverflow || elem.setCustomValidity || '';
762
+ return;
351
763
  }
352
764
 
353
765
  if (elem.min !== undefined && elem.value?.length > 0 && Number(elem.min) > Number(elem.value)) {
354
766
  elem.validity = 'rangeUnderflow';
355
767
  elem.errorMessage = elem.setCustomValidityRangeUnderflow || elem.setCustomValidity || '';
768
+ return;
356
769
  }
357
- } else if (elem.type === 'date') {
358
- if (elem.value?.length > 0 && elem.value?.length < elem.lengthForType) {
770
+ } else if (elem.type === 'date' && elem.value?.length > 0) {
771
+
772
+ // Guard Clause: if the value is too short
773
+ if (elem.value.length < elem.lengthForType) {
774
+
359
775
  elem.validity = 'tooShort';
360
776
  elem.errorMessage = elem.setCustomValidityForType || elem.setCustomValidity || '';
361
- } else if (elem.value?.length === elem.lengthForType && elem.util.toNorthAmericanFormat(elem.value, elem.format)) {
362
- const formattedValue = elem.util.toNorthAmericanFormat(elem.value, elem.format);
363
- const valueDate = new Date(formattedValue.dateForComparison);
777
+ return;
778
+ }
779
+
780
+ // Guard Clause: If the value is too long for the type
781
+ if (elem.value?.length > elem.lengthForType) {
782
+
783
+ elem.validity = 'tooLong';
784
+ elem.errorMessage = elem.setCustomValidityForType || elem.setCustomValidity || '';
785
+ return;
786
+ }
787
+
788
+ // Validate that the date passed was the correct format
789
+ if (!dateAndFormatMatch(elem.value, elem.format)) {
790
+ elem.validity = 'patternMismatch';
791
+ elem.errorMessage = elem.setCustomValidityForType || elem.setCustomValidity || 'Invalid Date Format Entered';
792
+ return;
793
+ }
794
+
795
+ // Validate that the date passed was a valid date
796
+ if (!validDateStr(elem.value, elem.format)) {
797
+ elem.validity = 'invalidDate';
798
+ elem.errorMessage = elem.setCustomValidityInvalidDate || elem.setCustomValidity || 'Invalid Date Entered';
799
+ return;
800
+ }
364
801
 
365
- // validate max
366
- if (elem.max?.length === elem.lengthForType) {
367
- const maxDate = new Date(elem.util.toNorthAmericanFormat(elem.max, elem.format).dateForComparison);
802
+ // Perform the rest of the validation
803
+ const formattedValue = toNorthAmericanFormat(elem.value, elem.format);
804
+ const valueDate = new Date(formattedValue);
368
805
 
369
- if (valueDate > maxDate) {
370
- elem.validity = 'rangeOverflow';
371
- elem.errorMessage = elem.setCustomValidityRangeOverflow || elem.setCustomValidity || '';
372
- }
806
+ // // Validate max date
807
+ if (elem.max?.length === elem.lengthForType) {
808
+
809
+ const maxDate = new Date(toNorthAmericanFormat(elem.max, elem.format));
810
+
811
+ if (valueDate > maxDate) {
812
+ elem.validity = 'rangeOverflow';
813
+ elem.errorMessage = elem.setCustomValidityRangeOverflow || elem.setCustomValidity || '';
814
+ return;
373
815
  }
816
+ }
374
817
 
375
- // validate min
376
- if (elem.min?.length === elem.lengthForType) {
377
- const minDate = new Date(elem.util.toNorthAmericanFormat(elem.min, elem.format).dateForComparison);
818
+ // Validate min date
819
+ if (elem.min?.length === elem.lengthForType) {
820
+ const minDate = new Date(toNorthAmericanFormat(elem.min, elem.format));
378
821
 
379
- if (valueDate < minDate) {
380
- elem.validity = 'rangeUnderflow';
381
- elem.errorMessage = elem.setCustomValidityRangeUnderflow || elem.setCustomValidity || '';
382
- }
822
+ if (valueDate < minDate) {
823
+ elem.validity = 'rangeUnderflow';
824
+ elem.errorMessage = elem.setCustomValidityRangeUnderflow || elem.setCustomValidity || '';
825
+ return;
383
826
  }
384
827
  }
385
828
  }
@@ -498,7 +941,7 @@ class AuroFormValidation {
498
941
  if (input.validationMessage.length > 0) {
499
942
  elem.errorMessage = input.validationMessage;
500
943
  }
501
- } else if (this.inputElements?.length > 0 && elem.errorMessage === '') {
944
+ } else if (this.inputElements?.length > 0 && elem.errorMessage === '') {
502
945
  const firstInput = this.inputElements[0];
503
946
 
504
947
  if (firstInput.validationMessage.length > 0) {
@@ -2406,7 +2849,7 @@ class AuroFloatingUI {
2406
2849
  /**
2407
2850
  * @private
2408
2851
  * getting called on 'blur' in trigger or `focusin` in document
2409
- *
2852
+ *
2410
2853
  * Hides the bib if focus moves outside of the trigger or bib, unless a 'noHideOnThisFocusLoss' flag is set.
2411
2854
  * This method checks if the currently active element is still within the trigger or bib.
2412
2855
  * If not, and if the bib isn't in fullscreen mode with focus lost, it hides the bib.
@@ -2522,7 +2965,7 @@ class AuroFloatingUI {
2522
2965
  // Close any other dropdown that is already open
2523
2966
  const existedVisibleFloatingUI = document.expandedAuroFormkitDropdown || document.expandedAuroFloater;
2524
2967
  if (existedVisibleFloatingUI && existedVisibleFloatingUI !== this &&
2525
- existedVisibleFloatingUI.isPopoverVisible &&
2968
+ existedVisibleFloatingUI.element.isPopoverVisible &&
2526
2969
  document.expandedAuroFloater.eventPrefix === this.eventPrefix) {
2527
2970
  document.expandedAuroFloater.hideBib();
2528
2971
  }
@@ -2698,7 +3141,7 @@ class AuroFloatingUI {
2698
3141
  this.id = window.crypto.randomUUID();
2699
3142
  this.element.setAttribute('id', this.id);
2700
3143
  }
2701
-
3144
+
2702
3145
  this.element.bib.setAttribute("id", `${this.id}-floater-bib`);
2703
3146
  }
2704
3147
 
@@ -2751,7 +3194,7 @@ class AuroFloatingUI {
2751
3194
  if (this.element.bib) {
2752
3195
  this.element.shadowRoot.append(this.element.bib);
2753
3196
  }
2754
-
3197
+
2755
3198
  // Remove event & keyboard listeners
2756
3199
  if (this.element?.trigger) {
2757
3200
  this.element.trigger.removeEventListener('keydown', this.handleEvent);
@@ -3141,7 +3584,6 @@ var tokensCss$1$1 = i$5`:host{--ds-auro-dropdown-label-text-color: var(--ds-basi
3141
3584
 
3142
3585
  const DESIGN_TOKEN_BREAKPOINT_PREFIX = '--ds-grid-breakpoint-';
3143
3586
  const DESIGN_TOKEN_BREAKPOINT_OPTIONS = [
3144
- 'xl',
3145
3587
  'lg',
3146
3588
  'md',
3147
3589
  'sm',
@@ -3213,7 +3655,6 @@ class AuroDropdownBib extends r {
3213
3655
 
3214
3656
  set mobileFullscreenBreakpoint(value) {
3215
3657
  // verify the defined breakpoint is valid and exit out if not
3216
- // 'disabled' is a design token breakpoint so it acts as our "undefined" value
3217
3658
  const validatedValue = DESIGN_TOKEN_BREAKPOINT_OPTIONS.includes(value) ? value : undefined;
3218
3659
  if (!validatedValue) {
3219
3660
  this._mobileBreakpointValue = undefined;
@@ -3482,6 +3923,7 @@ var helpTextVersion = '1.0.0';
3482
3923
  * @csspart helpText - The helpText content container.
3483
3924
  * @event auroDropdown-triggerClick - Notifies that the trigger has been clicked.
3484
3925
  * @event auroDropdown-toggled - Notifies that the visibility of the dropdown bib has changed.
3926
+ * @event auroDropdown-idAdded - Notifies consumers that the unique ID for the dropdown bib has been generated.
3485
3927
  */
3486
3928
  class AuroDropdown extends r {
3487
3929
  constructor() {
@@ -3527,7 +3969,9 @@ class AuroDropdown extends r {
3527
3969
  this.rounded = false;
3528
3970
  this.tabIndex = 0;
3529
3971
  this.noToggle = false;
3972
+ this.a11yAutocomplete = 'none';
3530
3973
  this.labeled = true;
3974
+ this.a11yRole = 'combobox';
3531
3975
  this.onDark = false;
3532
3976
 
3533
3977
  // floaterConfig
@@ -3663,6 +4107,16 @@ class AuroDropdown extends r {
3663
4107
  type: Number
3664
4108
  },
3665
4109
 
4110
+ /**
4111
+ * The unique ID for the dropdown bib element.
4112
+ * @private
4113
+ */
4114
+ dropdownId: {
4115
+ type: String,
4116
+ reflect: false,
4117
+ attribute: false
4118
+ },
4119
+
3666
4120
  /**
3667
4121
  * If declared in combination with `bordered` property or `helpText` slot content, will apply red color to both.
3668
4122
  */
@@ -3726,12 +4180,7 @@ class AuroDropdown extends r {
3726
4180
  },
3727
4181
 
3728
4182
  /**
3729
- * Defines the screen size breakpoint (`xs`, `sm`, `md`, `lg`, `xl`, `disabled`)
3730
- * at which the dropdown switches to fullscreen mode on mobile. `disabled` indicates a dropdown should _never_ enter fullscreen.
3731
- *
3732
- * When expanded, the dropdown will automatically display in fullscreen mode
3733
- * if the screen size is equal to or smaller than the selected breakpoint.
3734
- * @default sm
4183
+ * Defines the screen size breakpoint (`lg`, `md`, `sm`, or `xs`) at which the dropdown switches to fullscreen mode on mobile. When expanded, the dropdown will automatically display in fullscreen mode if the screen size is equal to or smaller than the selected breakpoint.
3735
4184
  */
3736
4185
  fullscreenBreakpoint: {
3737
4186
  type: String,
@@ -3830,6 +4279,23 @@ class AuroDropdown extends r {
3830
4279
  */
3831
4280
  tabIndex: {
3832
4281
  type: Number
4282
+ },
4283
+
4284
+ /**
4285
+ * The value for the role attribute of the trigger element.
4286
+ */
4287
+ a11yRole: {
4288
+ type: String || undefined,
4289
+ attribute: false,
4290
+ reflect: false
4291
+ },
4292
+
4293
+ /**
4294
+ * The value for the aria-autocomplete attribute of the trigger element.
4295
+ */
4296
+ a11yAutocomplete: {
4297
+ type: String,
4298
+ attribute: false,
3833
4299
  }
3834
4300
  };
3835
4301
  }
@@ -3854,15 +4320,6 @@ class AuroDropdown extends r {
3854
4320
  AuroLibraryRuntimeUtils$1$1.prototype.registerComponent(name, AuroDropdown);
3855
4321
  }
3856
4322
 
3857
- /**
3858
- * Accessor for reusing the focusable entity query string.
3859
- * @private
3860
- * @returns {string}
3861
- */
3862
- get focusableEntityQuery () {
3863
- return 'auro-input, [auro-input], auro-button, [auro-button], button, input';
3864
- }
3865
-
3866
4323
  connectedCallback() {
3867
4324
  super.connectedCallback();
3868
4325
  }
@@ -3876,8 +4333,6 @@ class AuroDropdown extends r {
3876
4333
  updated(changedProperties) {
3877
4334
  this.floater.handleUpdate(changedProperties);
3878
4335
 
3879
- // Note: `disabled` is not a breakpoint (it is not a screen size),
3880
- // so it looks like we never consume this - however, dropdownBib handles this in the setter as "undefined"
3881
4336
  if (changedProperties.has('fullscreenBreakpoint')) {
3882
4337
  this.bibContent.mobileFullscreenBreakpoint = this.fullscreenBreakpoint;
3883
4338
  }
@@ -3891,7 +4346,22 @@ class AuroDropdown extends r {
3891
4346
  }
3892
4347
 
3893
4348
  firstUpdated() {
4349
+
4350
+ // Configure the floater to, this will generate the ID for the bib
3894
4351
  this.floater.configure(this, 'auroDropdown');
4352
+
4353
+ /**
4354
+ * @description Let subscribers know that the dropdown ID ha been generated and added.
4355
+ * @event auroDropdown-idAdded
4356
+ * @type {Object<key: 'id', value: string>} - The ID of the dropdown bib element.
4357
+ */
4358
+ this.dispatchEvent(new CustomEvent('auroDropdown-idAdded', {detail: {id: this.floater.element.id}}));
4359
+
4360
+ // Set the bib ID locally if the user hasn't provided a focusable trigger
4361
+ if (!this.triggerContentFocusable) {
4362
+ this.dropdownId = this.floater.element.id;
4363
+ }
4364
+
3895
4365
  this.bibContent = this.floater.element.bib;
3896
4366
 
3897
4367
  // Add the tag name as an attribute if it is different than the component name
@@ -4013,7 +4483,7 @@ class AuroDropdown extends r {
4013
4483
 
4014
4484
  this.triggerContentSlot.forEach((node) => {
4015
4485
  if (node.querySelectorAll) {
4016
- const auroElements = node.querySelectorAll(this.focusableEntityQuery);
4486
+ const auroElements = node.querySelectorAll('auro-input, [auro-input], auro-button, [auro-button], button, input');
4017
4487
  auroElements.forEach((auroEl) => {
4018
4488
  auroEl.addEventListener('focus', this.bindFocusEventToTrigger);
4019
4489
  auroEl.addEventListener('blur', this.bindFocusEventToTrigger);
@@ -4034,7 +4504,7 @@ class AuroDropdown extends r {
4034
4504
 
4035
4505
  this.triggerContentSlot.forEach((node) => {
4036
4506
  if (node.querySelectorAll) {
4037
- const auroElements = node.querySelectorAll(this.focusableEntityQuery);
4507
+ const auroElements = node.querySelectorAll('auro-input, [auro-input], auro-button, [auro-button], button, input');
4038
4508
  auroElements.forEach((auroEl) => {
4039
4509
  auroEl.removeEventListener('focus', this.bindFocusEventToTrigger);
4040
4510
  auroEl.removeEventListener('blur', this.bindFocusEventToTrigger);
@@ -4043,6 +4513,30 @@ class AuroDropdown extends r {
4043
4513
  });
4044
4514
  }
4045
4515
 
4516
+ /*
4517
+ * Sets aria attributes for the trigger element if a custom one is passed in.
4518
+ * @private
4519
+ * @method setTriggerAriaAttributes
4520
+ * @param { HTMLElement } triggerElement - The custom trigger element.
4521
+ */
4522
+ clearTriggerA11yAttributes(triggerElement) {
4523
+
4524
+ if (!triggerElement || !triggerElement.removeAttribute) {
4525
+ return;
4526
+ }
4527
+
4528
+ // Reset appropriate attributes for a11y
4529
+ triggerElement.removeAttribute('aria-labelledby');
4530
+ if (triggerElement.getAttribute('id') === `${this.id}-trigger-element`) {
4531
+ triggerElement.removeAttribute('id');
4532
+ }
4533
+ triggerElement.removeAttribute('role');
4534
+ triggerElement.removeAttribute('aria-expanded');
4535
+
4536
+ triggerElement.removeAttribute('aria-controls');
4537
+ triggerElement.removeAttribute('aria-autocomplete');
4538
+ }
4539
+
4046
4540
  /**
4047
4541
  * Handles changes to the trigger content slot and updates related properties.
4048
4542
  *
@@ -4056,32 +4550,41 @@ class AuroDropdown extends r {
4056
4550
  * @returns {void}
4057
4551
  */
4058
4552
  handleTriggerContentSlotChange(event) {
4553
+
4059
4554
  this.floater.handleTriggerTabIndex();
4060
4555
 
4556
+ // Get the trigger
4557
+ const trigger = this.shadowRoot.querySelector('#trigger');
4558
+
4559
+ // Get the trigger slot
4061
4560
  const triggerSlot = this.shadowRoot.querySelector('.triggerContent slot');
4062
4561
 
4562
+ // If there's a trigger slot
4063
4563
  if (triggerSlot) {
4064
4564
 
4565
+ // Get the content nodes to see if there are any children
4065
4566
  const triggerContentNodes = triggerSlot.assignedNodes();
4066
4567
 
4568
+ // If there are children
4067
4569
  if (triggerContentNodes) {
4068
4570
 
4069
- triggerContentNodes.forEach((node) => {
4070
- if (!this.triggerContentFocusable) {
4071
- this.triggerContentFocusable = this.containsFocusableElement(node);
4072
- }
4073
- });
4074
- }
4075
- }
4571
+ // See if any of them are focusable elemeents
4572
+ this.triggerContentFocusable = triggerContentNodes.some((node) => this.containsFocusableElement(node));
4076
4573
 
4077
- const trigger = this.shadowRoot.querySelector('#trigger');
4574
+ // If any of them are focusable elements
4575
+ if (this.triggerContentFocusable) {
4078
4576
 
4079
- if (!this.triggerContentFocusable) {
4080
- trigger.setAttribute('tabindex', '0');
4081
- trigger.setAttribute('role', 'button');
4082
- } else {
4083
- trigger.removeAttribute('tabindex');
4084
- trigger.removeAttribute('role');
4577
+ // Assume the consumer will be providing their own a11y in whatever they passed in
4578
+ this.clearTriggerA11yAttributes(trigger);
4579
+
4580
+ // Remove the tabindex from the trigger so it doesn't interrupt focus flow
4581
+ trigger.removeAttribute('tabindex');
4582
+ } else {
4583
+
4584
+ // Add the tabindex to the trigger so that it's in the focus flow
4585
+ trigger.setAttribute('tabindex', '0');
4586
+ }
4587
+ }
4085
4588
  }
4086
4589
 
4087
4590
  if (event) {
@@ -4091,6 +4594,7 @@ class AuroDropdown extends r {
4091
4594
 
4092
4595
  if (this.triggerContentSlot) {
4093
4596
  this.setupTriggerFocusEventBinding();
4597
+
4094
4598
  this.hasTriggerContent = this.triggerContentSlot.some((slot) => {
4095
4599
  if (slot.textContent.trim()) {
4096
4600
  return true;
@@ -4158,10 +4662,13 @@ class AuroDropdown extends r {
4158
4662
  id="trigger"
4159
4663
  class="trigger"
4160
4664
  part="trigger"
4161
- aria-labelledby="triggerLabel"
4162
4665
  tabindex="${this.tabIndex}"
4163
4666
  ?showBorder="${this.showTriggerBorders}"
4164
- >
4667
+ role="${o(this.triggerContentFocusable ? undefined : this.a11yRole)}"
4668
+ aria-expanded="${o(this.triggerContentFocusable ? undefined : this.isPopoverVisible)}"
4669
+ aria-controls="${o(this.triggerContentFocusable ? undefined : this.dropdownId)}"
4670
+ aria-labelledby="${o(this.triggerContentFocusable ? undefined : 'triggerLabel')}"
4671
+ >
4165
4672
  <div class="triggerContentWrapper">
4166
4673
  <label class="label" id="triggerLabel" hasTrigger=${this.hasTriggerContent}>
4167
4674
  <slot name="label" @slotchange="${this.handleLabelSlotChange}"></slot>
@@ -4195,12 +4702,12 @@ class AuroDropdown extends r {
4195
4702
  <div id="bibSizer" part="size"></div>
4196
4703
  <${this.dropdownBibTag}
4197
4704
  id="bib"
4198
- role="tooltip"
4199
4705
  ?data-show="${this.isPopoverVisible}"
4200
4706
  ?isfullscreen="${this.isBibFullscreen}"
4201
4707
  ?common="${this.common}"
4202
4708
  ?rounded="${this.common || this.rounded}"
4203
- ?inset="${this.common || this.inset}">
4709
+ ?inset="${this.common || this.inset}"
4710
+ >
4204
4711
  </${this.dropdownBibTag}>
4205
4712
  </div>
4206
4713
  `;
@@ -5221,11 +5728,8 @@ class AuroSelect extends r {
5221
5728
  },
5222
5729
 
5223
5730
  /**
5224
- * Defines the screen size breakpoint (`xs`, `sm`, `md`, `lg`, `xl`, `disabled`)
5225
- * at which the dropdown switches to fullscreen mode on mobile. `disabled` indicates a dropdown should _never_ enter fullscreen.
5226
- *
5227
- * When expanded, the dropdown will automatically display in fullscreen mode
5228
- * if the screen size is equal to or smaller than the selected breakpoint.
5731
+ * Defines the screen size breakpoint (`lg`, `md`, `sm`, or `xs`) at which the dropdown switches to fullscreen mode on mobile.
5732
+ * When expanded, the dropdown will automatically display in fullscreen mode if the screen size is equal to or smaller than the selected breakpoint.
5229
5733
  * @default sm
5230
5734
  */
5231
5735
  fullscreenBreakpoint: {