@aurodesignsystem-dev/auro-formkit 0.0.0-pr1483.3 → 0.0.0-pr1488.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 (59) hide show
  1. package/components/checkbox/demo/customize.min.js +436 -14
  2. package/components/checkbox/demo/getting-started.min.js +436 -14
  3. package/components/checkbox/demo/index.min.js +436 -14
  4. package/components/checkbox/dist/index.js +436 -14
  5. package/components/checkbox/dist/registered.js +436 -14
  6. package/components/combobox/demo/customize.min.js +1482 -6618
  7. package/components/combobox/demo/getting-started.min.js +1482 -6618
  8. package/components/combobox/demo/index.min.js +1482 -6618
  9. package/components/combobox/demo/keyboard-behavior.md +68 -8
  10. package/components/combobox/dist/index.js +1489 -6625
  11. package/components/combobox/dist/registered.js +1489 -6625
  12. package/components/counter/demo/customize.min.js +437 -15
  13. package/components/counter/demo/index.min.js +437 -15
  14. package/components/counter/dist/index.js +436 -14
  15. package/components/counter/dist/registered.js +436 -14
  16. package/components/datepicker/demo/api.md +3 -10
  17. package/components/datepicker/demo/customize.md +6 -6
  18. package/components/datepicker/demo/index.md +4 -4
  19. package/components/datepicker/demo/index.min.js +2194 -7510
  20. package/components/datepicker/dist/index.js +2194 -7510
  21. package/components/datepicker/dist/registered.js +2194 -7510
  22. package/components/datepicker/dist/src/auro-calendar.d.ts +0 -6
  23. package/components/datepicker/dist/src/auro-datepicker.d.ts +10 -23
  24. package/components/datepicker/dist/src/utilities.d.ts +42 -10
  25. package/components/datepicker/dist/src/utilitiesCalendar.d.ts +2 -1
  26. package/components/dropdown/demo/customize.min.js +1 -1
  27. package/components/dropdown/demo/getting-started.min.js +1 -1
  28. package/components/dropdown/demo/index.min.js +1 -1
  29. package/components/dropdown/dist/index.js +1 -1
  30. package/components/dropdown/dist/registered.js +1 -1
  31. package/components/form/demo/customize.min.js +43986 -58306
  32. package/components/form/demo/getting-started.min.js +43986 -58306
  33. package/components/form/demo/index.min.js +43986 -58306
  34. package/components/form/demo/registerDemoDeps.min.js +43986 -58306
  35. package/components/input/demo/api.md +51 -57
  36. package/components/input/demo/customize.md +0 -160
  37. package/components/input/demo/customize.min.js +1011 -6565
  38. package/components/input/demo/getting-started.md +0 -11
  39. package/components/input/demo/getting-started.min.js +1010 -6564
  40. package/components/input/demo/index.md +3 -28
  41. package/components/input/demo/index.min.js +1010 -6564
  42. package/components/input/dist/auro-input.d.ts +6 -25
  43. package/components/input/dist/base-input.d.ts +69 -82
  44. package/components/input/dist/index.d.ts +1 -2
  45. package/components/input/dist/index.js +1003 -6599
  46. package/components/input/dist/registered.js +1010 -6564
  47. package/components/input/dist/utilities.d.ts +9 -68
  48. package/components/radio/demo/index.min.js +436 -14
  49. package/components/radio/dist/index.js +436 -14
  50. package/components/radio/dist/registered.js +436 -14
  51. package/components/select/demo/customize.min.js +455 -31
  52. package/components/select/demo/getting-started.min.js +455 -31
  53. package/components/select/demo/index.min.js +455 -31
  54. package/components/select/demo/keyboard-behavior.md +54 -8
  55. package/components/select/dist/index.js +455 -31
  56. package/components/select/dist/registered.js +455 -31
  57. package/custom-elements.json +717 -1199
  58. package/package.json +4 -4
  59. package/components/input/dist/auro-input-util.d.ts +0 -17
@@ -302,6 +302,415 @@ let p$3 = class p{registerComponent(t,a){customElements.get(t)||customElements.d
302
302
 
303
303
  var iconVersion$2 = '9.1.2';
304
304
 
305
+ class DateFormatter {
306
+
307
+ constructor() {
308
+
309
+ /**
310
+ * @description Parses a date string into its components.
311
+ * @param {string} dateStr - Date string to parse.
312
+ * @param {string} format - Date format to parse.
313
+ * @returns {Object<key["month" | "day" | "year"]: number>|undefined}
314
+ */
315
+ this.parseDate = (dateStr, format = 'mm/dd/yyyy') => {
316
+
317
+ // Guard Clause: Date string is defined
318
+ if (!dateStr) {
319
+ return undefined;
320
+ }
321
+
322
+ // Assume the separator is a "/" a defined in our code base
323
+ const separator = '/';
324
+
325
+ // Get the parts of the date and format
326
+ const valueParts = dateStr.split(separator);
327
+ const formatParts = format.split(separator);
328
+
329
+ // Check if the value and format have the correct number of parts
330
+ if (valueParts.length !== formatParts.length) {
331
+ throw new Error('AuroDatepickerUtilities | parseDate: Date string and format length do not match');
332
+ }
333
+
334
+ // Holds the result to be returned
335
+ const result = formatParts.reduce((acc, part, index) => {
336
+ const value = valueParts[index];
337
+
338
+ if ((/m/iu).test(part)) {
339
+ acc.month = value;
340
+ } else if ((/d/iu).test(part)) {
341
+ acc.day = value;
342
+ } else if ((/y/iu).test(part)) {
343
+ acc.year = value;
344
+ }
345
+
346
+ return acc;
347
+ }, {});
348
+
349
+ // If we found all the parts, return the result
350
+ if (result.month && result.year) {
351
+ return result;
352
+ }
353
+
354
+ // Throw an error to let the dev know we were unable to parse the date string
355
+ throw new Error('AuroDatepickerUtilities | parseDate: Unable to parse date string');
356
+ };
357
+
358
+ /**
359
+ * Convert a date object to string format.
360
+ * @param {Object} date - Date to convert to string.
361
+ * @param {String} locale - Optional locale to use for the date string. Defaults to user's locale.
362
+ * @returns {String} Returns the date as a string.
363
+ */
364
+ this.getDateAsString = (date, locale = undefined) => date.toLocaleDateString(locale, {
365
+ year: "numeric",
366
+ month: "2-digit",
367
+ day: "2-digit",
368
+ });
369
+
370
+ /**
371
+ * Converts a date string to a North American date format.
372
+ * @param {String} dateStr - Date to validate.
373
+ * @param {String} format - Date format to validate against.
374
+ * @returns {Boolean}
375
+ */
376
+ this.toNorthAmericanFormat = (dateStr, format) => {
377
+
378
+ if (format === 'mm/dd/yyyy') {
379
+ return dateStr;
380
+ }
381
+
382
+ const parsedDate = this.parseDate(dateStr, format);
383
+
384
+ if (!parsedDate) {
385
+ throw new Error('AuroDatepickerUtilities | toNorthAmericanFormat: Unable to parse date string');
386
+ }
387
+
388
+ const { month, day, year } = parsedDate;
389
+
390
+ const dateParts = [];
391
+ if (month) {
392
+ dateParts.push(month);
393
+ }
394
+
395
+ if (day) {
396
+ dateParts.push(day);
397
+ }
398
+
399
+ if (year) {
400
+ dateParts.push(year);
401
+ }
402
+
403
+ return dateParts.join('/');
404
+ };
405
+ }
406
+ }
407
+ const dateFormatter = new DateFormatter();
408
+
409
+ // filepath: dateConstraints.mjs
410
+ const DATE_UTIL_CONSTRAINTS = {
411
+ maxDay: 31,
412
+ maxMonth: 12,
413
+ maxYear: 2400,
414
+ minDay: 1,
415
+ minMonth: 1,
416
+ minYear: 1900,
417
+ };
418
+
419
+ class AuroDateUtilitiesBase {
420
+
421
+ /**
422
+ * @description The maximum day value allowed by the various utilities in this class.
423
+ * @readonly
424
+ * @type {Number}
425
+ */
426
+ get maxDay() {
427
+ return DATE_UTIL_CONSTRAINTS.maxDay;
428
+ }
429
+
430
+ /**
431
+ * @description The maximum month value allowed by the various utilities in this class.
432
+ * @readonly
433
+ * @type {Number}
434
+ */
435
+ get maxMonth() {
436
+ return DATE_UTIL_CONSTRAINTS.maxMonth;
437
+ }
438
+
439
+ /**
440
+ * @description The maximum year value allowed by the various utilities in this class.
441
+ * @readonly
442
+ * @type {Number}
443
+ */
444
+ get maxYear() {
445
+ return DATE_UTIL_CONSTRAINTS.maxYear;
446
+ }
447
+
448
+ /**
449
+ * @description The minimum day value allowed by the various utilities in this class.
450
+ * @readonly
451
+ * @type {Number}
452
+ */
453
+ get minDay() {
454
+ return DATE_UTIL_CONSTRAINTS.minDay;
455
+ }
456
+
457
+ /**
458
+ * @description The minimum month value allowed by the various utilities in this class.
459
+ * @readonly
460
+ * @type {Number}
461
+ */
462
+ get minMonth() {
463
+ return DATE_UTIL_CONSTRAINTS.minMonth;
464
+ }
465
+
466
+ /**
467
+ * @description The minimum year value allowed by the various utilities in this class.
468
+ * @readonly
469
+ * @type {Number}
470
+ */
471
+ get minYear() {
472
+ return DATE_UTIL_CONSTRAINTS.minYear;
473
+ }
474
+ }
475
+
476
+ /* eslint-disable no-magic-numbers */
477
+
478
+ class AuroDateUtilities extends AuroDateUtilitiesBase {
479
+
480
+ /**
481
+ * Returns the current century.
482
+ * @returns {String} The current century.
483
+ */
484
+ getCentury () {
485
+ return String(new Date().getFullYear()).slice(0, 2);
486
+ }
487
+
488
+ /**
489
+ * Returns a four digit year.
490
+ * @param {String} year - The year to convert to four digits.
491
+ * @returns {String} The four digit year.
492
+ */
493
+ getFourDigitYear (year) {
494
+
495
+ const strYear = String(year).trim();
496
+ return strYear.length <= 2 ? this.getCentury() + strYear : strYear;
497
+ }
498
+
499
+ constructor() {
500
+
501
+ super();
502
+
503
+ /**
504
+ * Compares two dates to see if they match.
505
+ * @param {Object} date1 - First date to compare.
506
+ * @param {Object} date2 - Second date to compare.
507
+ * @returns {Boolean} Returns true if the dates match.
508
+ */
509
+ this.datesMatch = (date1, date2) => new Date(date1).getTime() === new Date(date2).getTime();
510
+
511
+ /**
512
+ * Returns true if value passed in is a valid date.
513
+ * @param {String} date - Date to validate.
514
+ * @param {String} format - Date format to validate against.
515
+ * @returns {Boolean}
516
+ */
517
+ this.validDateStr = (date, format) => {
518
+
519
+ // The length we expect the date string to be
520
+ const dateStrLength = format.length;
521
+
522
+ // Guard Clause: Date and format are defined
523
+ if (typeof date === "undefined" || typeof format === "undefined") {
524
+ throw new Error('AuroDatepickerUtilities | validateDateStr: Date and format are required');
525
+ }
526
+
527
+ // Guard Clause: Date should be of type string
528
+ if (typeof date !== "string") {
529
+ throw new Error('AuroDatepickerUtilities | validateDateStr: Date must be a string');
530
+ }
531
+
532
+ // Guard Clause: Format should be of type string
533
+ if (typeof format !== "string") {
534
+ throw new Error('AuroDatepickerUtilities | validateDateStr: Format must be a string');
535
+ }
536
+
537
+ // Guard Clause: Length is what we expect it to be
538
+ if (date.length !== dateStrLength) {
539
+ return false;
540
+ }
541
+ // Get a formatted date string and parse it
542
+ const dateParts = dateFormatter.parseDate(date, format);
543
+
544
+ // Guard Clause: Date parse succeeded
545
+ if (!dateParts) {
546
+ return false;
547
+ }
548
+
549
+ // Create the expected date string based on the date parts
550
+ const expectedDateStr = `${dateParts.month}/${dateParts.day || "01"}/${this.getFourDigitYear(dateParts.year)}`;
551
+
552
+ // Generate a date object that we will extract a string date from to compare to the passed in date string
553
+ const dateObj = new Date(this.getFourDigitYear(dateParts.year), dateParts.month - 1, dateParts.day || 1);
554
+
555
+ // Get the date string of the date object we created from the string date
556
+ const actualDateStr = dateFormatter.getDateAsString(dateObj, "en-US");
557
+
558
+ // Guard Clause: Generated date matches date string input
559
+ if (expectedDateStr !== actualDateStr) {
560
+ return false;
561
+ }
562
+
563
+ // If we passed all other checks, we can assume the date is valid
564
+ return true;
565
+ };
566
+
567
+ /**
568
+ * Determines if a string date value matches the format provided.
569
+ * @param {string} value = The date string value.
570
+ * @param { string} format = The date format to match against.
571
+ * @returns {boolean}
572
+ */
573
+ this.dateAndFormatMatch = (value, format) => {
574
+
575
+ // Ensure we have both values we need to do the comparison
576
+ if (!value || !format) {
577
+ throw new Error('AuroFormValidation | dateFormatMatch: value and format are required');
578
+ }
579
+
580
+ // If the lengths are different, they cannot match
581
+ if (value.length !== format.length) {
582
+ return false;
583
+ }
584
+
585
+ // Get the parts of the date
586
+ const dateParts = dateFormatter.parseDate(value, format);
587
+
588
+ // Validator for day
589
+ const dayValueIsValid = (day) => {
590
+
591
+ // Guard clause: if there is no day in the dateParts, we can ignore this check.
592
+ if (!dateParts.day) {
593
+ return true;
594
+ }
595
+
596
+ // Guard clause: ensure day exists.
597
+ if (!day) {
598
+ return false;
599
+ }
600
+
601
+ // Convert day to number
602
+ const numDay = Number.parseInt(day, 10);
603
+
604
+ // Guard clause: ensure day is a valid integer
605
+ if (Number.isNaN(numDay)) {
606
+ throw new Error('AuroDatepickerUtilities | dayValueIsValid: Unable to parse day value integer');
607
+ }
608
+
609
+ // Guard clause: ensure day is within the valid range
610
+ if (numDay < this.minDay || numDay > this.maxDay) {
611
+ return false;
612
+ }
613
+
614
+ // Default return
615
+ return true;
616
+ };
617
+
618
+ // Validator for month
619
+ const monthValueIsValid = (month) => {
620
+
621
+ // Guard clause: ensure month exists.
622
+ if (!month) {
623
+ return false;
624
+ }
625
+
626
+ // Convert month to number
627
+ const numMonth = Number.parseInt(month, 10);
628
+
629
+ // Guard clause: ensure month is a valid integer
630
+ if (Number.isNaN(numMonth)) {
631
+ throw new Error('AuroDatepickerUtilities | monthValueIsValid: Unable to parse month value integer');
632
+ }
633
+
634
+ // Guard clause: ensure month is within the valid range
635
+ if (numMonth < this.minMonth || numMonth > this.maxMonth) {
636
+ return false;
637
+ }
638
+
639
+ // Default return
640
+ return true;
641
+ };
642
+
643
+ // Validator for year
644
+ const yearIsValid = (_year) => {
645
+
646
+ // Guard clause: ensure year exists.
647
+ if (!_year) {
648
+ return false;
649
+ }
650
+
651
+ // Get the full year
652
+ const year = this.getFourDigitYear(_year);
653
+
654
+ // Convert year to number
655
+ const numYear = Number.parseInt(year, 10);
656
+
657
+ // Guard clause: ensure year is a valid integer
658
+ if (Number.isNaN(numYear)) {
659
+ throw new Error('AuroDatepickerUtilities | yearValueIsValid: Unable to parse year value integer');
660
+ }
661
+
662
+ // Guard clause: ensure year is within the valid range
663
+ if (numYear < this.minYear || numYear > this.maxYear) {
664
+ return false;
665
+ }
666
+
667
+ // Default return
668
+ return true;
669
+ };
670
+
671
+ // Self-contained checks for month, day, and year
672
+ const checks = [
673
+ monthValueIsValid(dateParts.month),
674
+ dayValueIsValid(dateParts.day),
675
+ yearIsValid(dateParts.year)
676
+ ];
677
+
678
+ // If any of the checks failed, the date format does not match and the result is invalid
679
+ const isValid = checks.every((check) => check === true);
680
+
681
+ // If the check is invalid, return false
682
+ if (!isValid) {
683
+ return false;
684
+ }
685
+
686
+ // Default case
687
+ return true;
688
+ };
689
+ }
690
+ }
691
+
692
+ // Export a class instance
693
+ const dateUtilities = new AuroDateUtilities();
694
+
695
+ // Export the class instance methods individually
696
+ const {
697
+ datesMatch,
698
+ validDateStr,
699
+ dateAndFormatMatch,
700
+ minDay,
701
+ minMonth,
702
+ minYear,
703
+ maxDay,
704
+ maxMonth,
705
+ maxYear
706
+ } = dateUtilities;
707
+
708
+ const {
709
+ toNorthAmericanFormat,
710
+ parseDate,
711
+ getDateAsString
712
+ } = dateFormatter;
713
+
305
714
  // Copyright (c) Alaska Air. All right reserved. Licensed under the Apache-2.0 license
306
715
  // See LICENSE in the project root for license information.
307
716
 
@@ -443,7 +852,7 @@ class AuroFormValidation {
443
852
  validity: 'valueMissing',
444
853
  message: e => e.getAttribute('setCustomValidityValueMissingFilter') || e.setCustomValidity || ''
445
854
  }
446
- ]
855
+ ]
447
856
  }
448
857
  };
449
858
 
@@ -508,12 +917,12 @@ class AuroFormValidation {
508
917
 
509
918
  // Guard Clause: if the value is too short
510
919
  if (elem.value?.length < elem.lengthForType) {
511
-
920
+
512
921
  elem.validity = 'tooShort';
513
922
  elem.errorMessage = elem.setCustomValidityForType || elem.setCustomValidity || '';
514
923
  return;
515
- }
516
-
924
+ }
925
+
517
926
  // Guard Clause: If the value is too long for the type
518
927
  if (elem.value?.length > elem.lengthForType) {
519
928
 
@@ -521,20 +930,31 @@ class AuroFormValidation {
521
930
  elem.errorMessage = elem.setCustomValidityForType || elem.setCustomValidity || '';
522
931
  return;
523
932
  }
524
-
525
- // Validate that the date passed was the correct format and is a valid date
526
- if (elem.value && !elem.valueObject) {
933
+
934
+ // Validate that the date passed was the correct format
935
+ if (!dateAndFormatMatch(elem.value, elem.format)) {
527
936
  elem.validity = 'patternMismatch';
528
- elem.errorMessage = elem.setCustomValidityPatternMismatch || elem.setCustomValidity || 'Invalid Date Format Entered';
937
+ elem.errorMessage = elem.setCustomValidityForType || elem.setCustomValidity || 'Invalid Date Format Entered';
938
+ return;
939
+ }
940
+
941
+ // Validate that the date passed was a valid date
942
+ if (!validDateStr(elem.value, elem.format)) {
943
+ elem.validity = 'invalidDate';
944
+ elem.errorMessage = elem.setCustomValidityInvalidDate || elem.setCustomValidity || 'Invalid Date Entered';
529
945
  return;
530
946
  }
531
947
 
532
948
  // Perform the rest of the validation
949
+ const formattedValue = toNorthAmericanFormat(elem.value, elem.format);
950
+ const valueDate = new Date(formattedValue);
533
951
 
534
952
  // // Validate max date
535
953
  if (elem.max?.length === elem.lengthForType) {
536
954
 
537
- if (elem.valueObject > elem.maxObject) {
955
+ const maxDate = new Date(toNorthAmericanFormat(elem.max, elem.format));
956
+
957
+ if (valueDate > maxDate) {
538
958
  elem.validity = 'rangeOverflow';
539
959
  elem.errorMessage = elem.setCustomValidityRangeOverflow || elem.setCustomValidity || '';
540
960
  return;
@@ -543,7 +963,9 @@ class AuroFormValidation {
543
963
 
544
964
  // Validate min date
545
965
  if (elem.min?.length === elem.lengthForType) {
546
- if (elem.valueObject < elem.minObject) {
966
+ const minDate = new Date(toNorthAmericanFormat(elem.min, elem.format));
967
+
968
+ if (valueDate < minDate) {
547
969
  elem.validity = 'rangeUnderflow';
548
970
  elem.errorMessage = elem.setCustomValidityRangeUnderflow || elem.setCustomValidity || '';
549
971
  return;
@@ -603,7 +1025,7 @@ class AuroFormValidation {
603
1025
  if (typeof elem.value === "string") {
604
1026
  hasValue = elem.value && elem.value.length > 0;
605
1027
  }
606
-
1028
+
607
1029
  if (typeof elem.value === "boolean") {
608
1030
  hasValue = elem.value || elem.value === false;
609
1031
  }
@@ -628,7 +1050,7 @@ class AuroFormValidation {
628
1050
  }
629
1051
 
630
1052
  const isCombobox = this.runtimeUtils.elementMatch(elem, 'auro-combobox');
631
-
1053
+
632
1054
  if (isCombobox) {
633
1055
 
634
1056
  if (!elem.persistInput || elem.behavior === "filter") {
@@ -668,7 +1090,7 @@ class AuroFormValidation {
668
1090
  }
669
1091
 
670
1092
  // multiple input in one components (datepicker)
671
- // combobox has 2 inputs but no need to check validity on the 2nd one which is in fullscreen bib.
1093
+ // combobox has 2 inputs but no need to check validity on the 2nd one which is in fullscreen bib.
672
1094
  if (elem.validity === 'valid' && this.auroInputElements.length > 1 && !isCombobox) {
673
1095
  elem.validity = this.auroInputElements[1].validity;
674
1096
  elem.errorMessage = this.auroInputElements[1].errorMessage;
@@ -1099,7 +1521,7 @@ let AuroHelpText$1 = class AuroHelpText extends i$2 {
1099
1521
  }
1100
1522
  };
1101
1523
 
1102
- var formkitVersion$1 = '202605271944';
1524
+ var formkitVersion$1 = '202605292307';
1103
1525
 
1104
1526
  // Copyright (c) 2026 Alaska Airlines. All rights reserved. Licensed under the Apache-2.0 license
1105
1527
  // See LICENSE in the project root for license information.
@@ -5445,7 +5867,7 @@ class AuroHelpText extends i$2 {
5445
5867
  }
5446
5868
  }
5447
5869
 
5448
- var formkitVersion = '202605271944';
5870
+ var formkitVersion = '202605292307';
5449
5871
 
5450
5872
  let AuroElement$1 = class AuroElement extends i$2 {
5451
5873
  static get properties() {