@aurodesignsystem/auro-formkit 3.1.0-beta.1 → 3.2.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/CHANGELOG.md +19 -1
  2. package/components/checkbox/README.md +1 -1
  3. package/components/checkbox/demo/api.min.js +468 -25
  4. package/components/checkbox/demo/index.min.js +468 -25
  5. package/components/checkbox/demo/readme.md +1 -1
  6. package/components/checkbox/dist/index.js +468 -25
  7. package/components/checkbox/dist/registered.js +468 -25
  8. package/components/combobox/README.md +1 -1
  9. package/components/combobox/demo/api.min.js +1125 -74
  10. package/components/combobox/demo/index.min.js +1125 -74
  11. package/components/combobox/demo/readme.md +1 -1
  12. package/components/combobox/dist/auro-combobox.d.ts +30 -0
  13. package/components/combobox/dist/index.js +1125 -74
  14. package/components/combobox/dist/registered.js +1125 -74
  15. package/components/counter/README.md +1 -1
  16. package/components/counter/demo/api.min.js +570 -45
  17. package/components/counter/demo/index.min.js +570 -45
  18. package/components/counter/demo/readme.md +1 -1
  19. package/components/counter/dist/index.js +570 -45
  20. package/components/counter/dist/registered.js +570 -45
  21. package/components/datepicker/README.md +1 -1
  22. package/components/datepicker/demo/api.min.js +1073 -70
  23. package/components/datepicker/demo/index.min.js +1073 -70
  24. package/components/datepicker/demo/readme.md +1 -1
  25. package/components/datepicker/dist/index.js +1073 -70
  26. package/components/datepicker/dist/registered.js +1073 -70
  27. package/components/dropdown/README.md +1 -1
  28. package/components/dropdown/demo/api.md +8 -5
  29. package/components/dropdown/demo/api.min.js +104 -22
  30. package/components/dropdown/demo/index.min.js +104 -22
  31. package/components/dropdown/demo/readme.md +1 -1
  32. package/components/dropdown/dist/auro-dropdown.d.ts +29 -0
  33. package/components/dropdown/dist/index.js +104 -22
  34. package/components/dropdown/dist/registered.js +104 -22
  35. package/components/form/README.md +1 -1
  36. package/components/form/demo/readme.md +1 -1
  37. package/components/input/README.md +1 -1
  38. package/components/input/demo/api.md +4 -1
  39. package/components/input/demo/api.min.js +503 -25
  40. package/components/input/demo/index.min.js +503 -25
  41. package/components/input/demo/readme.md +1 -1
  42. package/components/input/dist/base-input.d.ts +24 -0
  43. package/components/input/dist/index.js +503 -25
  44. package/components/input/dist/registered.js +503 -25
  45. package/components/menu/README.md +1 -1
  46. package/components/menu/demo/readme.md +1 -1
  47. package/components/radio/README.md +1 -1
  48. package/components/radio/demo/api.min.js +468 -25
  49. package/components/radio/demo/index.min.js +468 -25
  50. package/components/radio/demo/readme.md +1 -1
  51. package/components/radio/dist/index.js +468 -25
  52. package/components/radio/dist/registered.js +468 -25
  53. package/components/select/README.md +1 -1
  54. package/components/select/demo/api.min.js +570 -45
  55. package/components/select/demo/index.min.js +570 -45
  56. package/components/select/demo/readme.md +1 -1
  57. package/components/select/dist/index.js +570 -45
  58. package/components/select/dist/registered.js +570 -45
  59. package/package.json +2 -2
@@ -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) {
364
782
 
365
- // validate max
366
- if (elem.max?.length === elem.lengthForType) {
367
- const maxDate = new Date(elem.util.toNorthAmericanFormat(elem.max, elem.format).dateForComparison);
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
+ }
368
801
 
369
- if (valueDate > maxDate) {
370
- elem.validity = 'rangeOverflow';
371
- elem.errorMessage = elem.setCustomValidityRangeOverflow || elem.setCustomValidity || '';
372
- }
802
+ // Perform the rest of the validation
803
+ const formattedValue = toNorthAmericanFormat(elem.value, elem.format);
804
+ const valueDate = new Date(formattedValue);
805
+
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);
@@ -3482,6 +3925,7 @@ var helpTextVersion = '1.0.0';
3482
3925
  * @csspart helpText - The helpText content container.
3483
3926
  * @event auroDropdown-triggerClick - Notifies that the trigger has been clicked.
3484
3927
  * @event auroDropdown-toggled - Notifies that the visibility of the dropdown bib has changed.
3928
+ * @event auroDropdown-idAdded - Notifies consumers that the unique ID for the dropdown bib has been generated.
3485
3929
  */
3486
3930
  class AuroDropdown extends r {
3487
3931
  constructor() {
@@ -3527,7 +3971,9 @@ class AuroDropdown extends r {
3527
3971
  this.rounded = false;
3528
3972
  this.tabIndex = 0;
3529
3973
  this.noToggle = false;
3974
+ this.a11yAutocomplete = 'none';
3530
3975
  this.labeled = true;
3976
+ this.a11yRole = 'combobox';
3531
3977
  this.onDark = false;
3532
3978
 
3533
3979
  // floaterConfig
@@ -3663,6 +4109,16 @@ class AuroDropdown extends r {
3663
4109
  type: Number
3664
4110
  },
3665
4111
 
4112
+ /**
4113
+ * The unique ID for the dropdown bib element.
4114
+ * @private
4115
+ */
4116
+ dropdownId: {
4117
+ type: String,
4118
+ reflect: false,
4119
+ attribute: false
4120
+ },
4121
+
3666
4122
  /**
3667
4123
  * If declared in combination with `bordered` property or `helpText` slot content, will apply red color to both.
3668
4124
  */
@@ -3830,6 +4286,23 @@ class AuroDropdown extends r {
3830
4286
  */
3831
4287
  tabIndex: {
3832
4288
  type: Number
4289
+ },
4290
+
4291
+ /**
4292
+ * The value for the role attribute of the trigger element.
4293
+ */
4294
+ a11yRole: {
4295
+ type: String || undefined,
4296
+ attribute: false,
4297
+ reflect: false
4298
+ },
4299
+
4300
+ /**
4301
+ * The value for the aria-autocomplete attribute of the trigger element.
4302
+ */
4303
+ a11yAutocomplete: {
4304
+ type: String,
4305
+ attribute: false,
3833
4306
  }
3834
4307
  };
3835
4308
  }
@@ -3891,7 +4364,22 @@ class AuroDropdown extends r {
3891
4364
  }
3892
4365
 
3893
4366
  firstUpdated() {
4367
+
4368
+ // Configure the floater to, this will generate the ID for the bib
3894
4369
  this.floater.configure(this, 'auroDropdown');
4370
+
4371
+ /**
4372
+ * @description Let subscribers know that the dropdown ID ha been generated and added.
4373
+ * @event auroDropdown-idAdded
4374
+ * @type {Object<key: 'id', value: string>} - The ID of the dropdown bib element.
4375
+ */
4376
+ this.dispatchEvent(new CustomEvent('auroDropdown-idAdded', {detail: {id: this.floater.element.id}}));
4377
+
4378
+ // Set the bib ID locally if the user hasn't provided a focusable trigger
4379
+ if (!this.triggerContentFocusable) {
4380
+ this.dropdownId = this.floater.element.id;
4381
+ }
4382
+
3895
4383
  this.bibContent = this.floater.element.bib;
3896
4384
 
3897
4385
  // Add the tag name as an attribute if it is different than the component name
@@ -4043,6 +4531,30 @@ class AuroDropdown extends r {
4043
4531
  });
4044
4532
  }
4045
4533
 
4534
+ /*
4535
+ * Sets aria attributes for the trigger element if a custom one is passed in.
4536
+ * @private
4537
+ * @method setTriggerAriaAttributes
4538
+ * @param { HTMLElement } triggerElement - The custom trigger element.
4539
+ */
4540
+ clearTriggerA11yAttributes(triggerElement) {
4541
+
4542
+ if (!triggerElement || !triggerElement.removeAttribute) {
4543
+ return;
4544
+ }
4545
+
4546
+ // Reset appropriate attributes for a11y
4547
+ triggerElement.removeAttribute('aria-labelledby');
4548
+ if (triggerElement.getAttribute('id') === `${this.id}-trigger-element`) {
4549
+ triggerElement.removeAttribute('id');
4550
+ }
4551
+ triggerElement.removeAttribute('role');
4552
+ triggerElement.removeAttribute('aria-expanded');
4553
+
4554
+ triggerElement.removeAttribute('aria-controls');
4555
+ triggerElement.removeAttribute('aria-autocomplete');
4556
+ }
4557
+
4046
4558
  /**
4047
4559
  * Handles changes to the trigger content slot and updates related properties.
4048
4560
  *
@@ -4056,32 +4568,41 @@ class AuroDropdown extends r {
4056
4568
  * @returns {void}
4057
4569
  */
4058
4570
  handleTriggerContentSlotChange(event) {
4571
+
4059
4572
  this.floater.handleTriggerTabIndex();
4060
4573
 
4574
+ // Get the trigger
4575
+ const trigger = this.shadowRoot.querySelector('#trigger');
4576
+
4577
+ // Get the trigger slot
4061
4578
  const triggerSlot = this.shadowRoot.querySelector('.triggerContent slot');
4062
4579
 
4580
+ // If there's a trigger slot
4063
4581
  if (triggerSlot) {
4064
4582
 
4583
+ // Get the content nodes to see if there are any children
4065
4584
  const triggerContentNodes = triggerSlot.assignedNodes();
4066
4585
 
4586
+ // If there are children
4067
4587
  if (triggerContentNodes) {
4068
4588
 
4069
- triggerContentNodes.forEach((node) => {
4070
- if (!this.triggerContentFocusable) {
4071
- this.triggerContentFocusable = this.containsFocusableElement(node);
4072
- }
4073
- });
4074
- }
4075
- }
4589
+ // See if any of them are focusable elemeents
4590
+ this.triggerContentFocusable = triggerContentNodes.some((node) => this.containsFocusableElement(node));
4076
4591
 
4077
- const trigger = this.shadowRoot.querySelector('#trigger');
4592
+ // If any of them are focusable elements
4593
+ if (this.triggerContentFocusable) {
4078
4594
 
4079
- if (!this.triggerContentFocusable) {
4080
- trigger.setAttribute('tabindex', '0');
4081
- trigger.setAttribute('role', 'button');
4082
- } else {
4083
- trigger.removeAttribute('tabindex');
4084
- trigger.removeAttribute('role');
4595
+ // Assume the consumer will be providing their own a11y in whatever they passed in
4596
+ this.clearTriggerA11yAttributes(trigger);
4597
+
4598
+ // Remove the tabindex from the trigger so it doesn't interrupt focus flow
4599
+ trigger.removeAttribute('tabindex');
4600
+ } else {
4601
+
4602
+ // Add the tabindex to the trigger so that it's in the focus flow
4603
+ trigger.setAttribute('tabindex', '0');
4604
+ }
4605
+ }
4085
4606
  }
4086
4607
 
4087
4608
  if (event) {
@@ -4091,6 +4612,7 @@ class AuroDropdown extends r {
4091
4612
 
4092
4613
  if (this.triggerContentSlot) {
4093
4614
  this.setupTriggerFocusEventBinding();
4615
+
4094
4616
  this.hasTriggerContent = this.triggerContentSlot.some((slot) => {
4095
4617
  if (slot.textContent.trim()) {
4096
4618
  return true;
@@ -4158,10 +4680,13 @@ class AuroDropdown extends r {
4158
4680
  id="trigger"
4159
4681
  class="trigger"
4160
4682
  part="trigger"
4161
- aria-labelledby="triggerLabel"
4162
4683
  tabindex="${this.tabIndex}"
4163
4684
  ?showBorder="${this.showTriggerBorders}"
4164
- >
4685
+ role="${o(this.triggerContentFocusable ? undefined : this.a11yRole)}"
4686
+ aria-expanded="${o(this.triggerContentFocusable ? undefined : this.isPopoverVisible)}"
4687
+ aria-controls="${o(this.triggerContentFocusable ? undefined : this.dropdownId)}"
4688
+ aria-labelledby="${o(this.triggerContentFocusable ? undefined : 'triggerLabel')}"
4689
+ >
4165
4690
  <div class="triggerContentWrapper">
4166
4691
  <label class="label" id="triggerLabel" hasTrigger=${this.hasTriggerContent}>
4167
4692
  <slot name="label" @slotchange="${this.handleLabelSlotChange}"></slot>
@@ -4195,12 +4720,12 @@ class AuroDropdown extends r {
4195
4720
  <div id="bibSizer" part="size"></div>
4196
4721
  <${this.dropdownBibTag}
4197
4722
  id="bib"
4198
- role="tooltip"
4199
4723
  ?data-show="${this.isPopoverVisible}"
4200
4724
  ?isfullscreen="${this.isBibFullscreen}"
4201
4725
  ?common="${this.common}"
4202
4726
  ?rounded="${this.common || this.rounded}"
4203
- ?inset="${this.common || this.inset}">
4727
+ ?inset="${this.common || this.inset}"
4728
+ >
4204
4729
  </${this.dropdownBibTag}>
4205
4730
  </div>
4206
4731
  `;