@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
@@ -492,6 +492,415 @@ class AuroCheckbox extends LitElement {
492
492
  }
493
493
  }
494
494
 
495
+ class DateFormatter {
496
+
497
+ constructor() {
498
+
499
+ /**
500
+ * @description Parses a date string into its components.
501
+ * @param {string} dateStr - Date string to parse.
502
+ * @param {string} format - Date format to parse.
503
+ * @returns {Object<key["month" | "day" | "year"]: number>|undefined}
504
+ */
505
+ this.parseDate = (dateStr, format = 'mm/dd/yyyy') => {
506
+
507
+ // Guard Clause: Date string is defined
508
+ if (!dateStr) {
509
+ return undefined;
510
+ }
511
+
512
+ // Assume the separator is a "/" a defined in our code base
513
+ const separator = '/';
514
+
515
+ // Get the parts of the date and format
516
+ const valueParts = dateStr.split(separator);
517
+ const formatParts = format.split(separator);
518
+
519
+ // Check if the value and format have the correct number of parts
520
+ if (valueParts.length !== formatParts.length) {
521
+ throw new Error('AuroDatepickerUtilities | parseDate: Date string and format length do not match');
522
+ }
523
+
524
+ // Holds the result to be returned
525
+ const result = formatParts.reduce((acc, part, index) => {
526
+ const value = valueParts[index];
527
+
528
+ if ((/m/iu).test(part)) {
529
+ acc.month = value;
530
+ } else if ((/d/iu).test(part)) {
531
+ acc.day = value;
532
+ } else if ((/y/iu).test(part)) {
533
+ acc.year = value;
534
+ }
535
+
536
+ return acc;
537
+ }, {});
538
+
539
+ // If we found all the parts, return the result
540
+ if (result.month && result.year) {
541
+ return result;
542
+ }
543
+
544
+ // Throw an error to let the dev know we were unable to parse the date string
545
+ throw new Error('AuroDatepickerUtilities | parseDate: Unable to parse date string');
546
+ };
547
+
548
+ /**
549
+ * Convert a date object to string format.
550
+ * @param {Object} date - Date to convert to string.
551
+ * @param {String} locale - Optional locale to use for the date string. Defaults to user's locale.
552
+ * @returns {String} Returns the date as a string.
553
+ */
554
+ this.getDateAsString = (date, locale = undefined) => date.toLocaleDateString(locale, {
555
+ year: "numeric",
556
+ month: "2-digit",
557
+ day: "2-digit",
558
+ });
559
+
560
+ /**
561
+ * Converts a date string to a North American date format.
562
+ * @param {String} dateStr - Date to validate.
563
+ * @param {String} format - Date format to validate against.
564
+ * @returns {Boolean}
565
+ */
566
+ this.toNorthAmericanFormat = (dateStr, format) => {
567
+
568
+ if (format === 'mm/dd/yyyy') {
569
+ return dateStr;
570
+ }
571
+
572
+ const parsedDate = this.parseDate(dateStr, format);
573
+
574
+ if (!parsedDate) {
575
+ throw new Error('AuroDatepickerUtilities | toNorthAmericanFormat: Unable to parse date string');
576
+ }
577
+
578
+ const { month, day, year } = parsedDate;
579
+
580
+ const dateParts = [];
581
+ if (month) {
582
+ dateParts.push(month);
583
+ }
584
+
585
+ if (day) {
586
+ dateParts.push(day);
587
+ }
588
+
589
+ if (year) {
590
+ dateParts.push(year);
591
+ }
592
+
593
+ return dateParts.join('/');
594
+ };
595
+ }
596
+ }
597
+ const dateFormatter = new DateFormatter();
598
+
599
+ // filepath: dateConstraints.mjs
600
+ const DATE_UTIL_CONSTRAINTS = {
601
+ maxDay: 31,
602
+ maxMonth: 12,
603
+ maxYear: 2400,
604
+ minDay: 1,
605
+ minMonth: 1,
606
+ minYear: 1900,
607
+ };
608
+
609
+ class AuroDateUtilitiesBase {
610
+
611
+ /**
612
+ * @description The maximum day value allowed by the various utilities in this class.
613
+ * @readonly
614
+ * @type {Number}
615
+ */
616
+ get maxDay() {
617
+ return DATE_UTIL_CONSTRAINTS.maxDay;
618
+ }
619
+
620
+ /**
621
+ * @description The maximum month value allowed by the various utilities in this class.
622
+ * @readonly
623
+ * @type {Number}
624
+ */
625
+ get maxMonth() {
626
+ return DATE_UTIL_CONSTRAINTS.maxMonth;
627
+ }
628
+
629
+ /**
630
+ * @description The maximum year value allowed by the various utilities in this class.
631
+ * @readonly
632
+ * @type {Number}
633
+ */
634
+ get maxYear() {
635
+ return DATE_UTIL_CONSTRAINTS.maxYear;
636
+ }
637
+
638
+ /**
639
+ * @description The minimum day value allowed by the various utilities in this class.
640
+ * @readonly
641
+ * @type {Number}
642
+ */
643
+ get minDay() {
644
+ return DATE_UTIL_CONSTRAINTS.minDay;
645
+ }
646
+
647
+ /**
648
+ * @description The minimum month value allowed by the various utilities in this class.
649
+ * @readonly
650
+ * @type {Number}
651
+ */
652
+ get minMonth() {
653
+ return DATE_UTIL_CONSTRAINTS.minMonth;
654
+ }
655
+
656
+ /**
657
+ * @description The minimum year value allowed by the various utilities in this class.
658
+ * @readonly
659
+ * @type {Number}
660
+ */
661
+ get minYear() {
662
+ return DATE_UTIL_CONSTRAINTS.minYear;
663
+ }
664
+ }
665
+
666
+ /* eslint-disable no-magic-numbers */
667
+
668
+ class AuroDateUtilities extends AuroDateUtilitiesBase {
669
+
670
+ /**
671
+ * Returns the current century.
672
+ * @returns {String} The current century.
673
+ */
674
+ getCentury () {
675
+ return String(new Date().getFullYear()).slice(0, 2);
676
+ }
677
+
678
+ /**
679
+ * Returns a four digit year.
680
+ * @param {String} year - The year to convert to four digits.
681
+ * @returns {String} The four digit year.
682
+ */
683
+ getFourDigitYear (year) {
684
+
685
+ const strYear = String(year).trim();
686
+ return strYear.length <= 2 ? this.getCentury() + strYear : strYear;
687
+ }
688
+
689
+ constructor() {
690
+
691
+ super();
692
+
693
+ /**
694
+ * Compares two dates to see if they match.
695
+ * @param {Object} date1 - First date to compare.
696
+ * @param {Object} date2 - Second date to compare.
697
+ * @returns {Boolean} Returns true if the dates match.
698
+ */
699
+ this.datesMatch = (date1, date2) => new Date(date1).getTime() === new Date(date2).getTime();
700
+
701
+ /**
702
+ * Returns true if value passed in is a valid date.
703
+ * @param {String} date - Date to validate.
704
+ * @param {String} format - Date format to validate against.
705
+ * @returns {Boolean}
706
+ */
707
+ this.validDateStr = (date, format) => {
708
+
709
+ // The length we expect the date string to be
710
+ const dateStrLength = format.length;
711
+
712
+ // Guard Clause: Date and format are defined
713
+ if (typeof date === "undefined" || typeof format === "undefined") {
714
+ throw new Error('AuroDatepickerUtilities | validateDateStr: Date and format are required');
715
+ }
716
+
717
+ // Guard Clause: Date should be of type string
718
+ if (typeof date !== "string") {
719
+ throw new Error('AuroDatepickerUtilities | validateDateStr: Date must be a string');
720
+ }
721
+
722
+ // Guard Clause: Format should be of type string
723
+ if (typeof format !== "string") {
724
+ throw new Error('AuroDatepickerUtilities | validateDateStr: Format must be a string');
725
+ }
726
+
727
+ // Guard Clause: Length is what we expect it to be
728
+ if (date.length !== dateStrLength) {
729
+ return false;
730
+ }
731
+ // Get a formatted date string and parse it
732
+ const dateParts = dateFormatter.parseDate(date, format);
733
+
734
+ // Guard Clause: Date parse succeeded
735
+ if (!dateParts) {
736
+ return false;
737
+ }
738
+
739
+ // Create the expected date string based on the date parts
740
+ const expectedDateStr = `${dateParts.month}/${dateParts.day || "01"}/${this.getFourDigitYear(dateParts.year)}`;
741
+
742
+ // Generate a date object that we will extract a string date from to compare to the passed in date string
743
+ const dateObj = new Date(this.getFourDigitYear(dateParts.year), dateParts.month - 1, dateParts.day || 1);
744
+
745
+ // Get the date string of the date object we created from the string date
746
+ const actualDateStr = dateFormatter.getDateAsString(dateObj, "en-US");
747
+
748
+ // Guard Clause: Generated date matches date string input
749
+ if (expectedDateStr !== actualDateStr) {
750
+ return false;
751
+ }
752
+
753
+ // If we passed all other checks, we can assume the date is valid
754
+ return true;
755
+ };
756
+
757
+ /**
758
+ * Determines if a string date value matches the format provided.
759
+ * @param {string} value = The date string value.
760
+ * @param { string} format = The date format to match against.
761
+ * @returns {boolean}
762
+ */
763
+ this.dateAndFormatMatch = (value, format) => {
764
+
765
+ // Ensure we have both values we need to do the comparison
766
+ if (!value || !format) {
767
+ throw new Error('AuroFormValidation | dateFormatMatch: value and format are required');
768
+ }
769
+
770
+ // If the lengths are different, they cannot match
771
+ if (value.length !== format.length) {
772
+ return false;
773
+ }
774
+
775
+ // Get the parts of the date
776
+ const dateParts = dateFormatter.parseDate(value, format);
777
+
778
+ // Validator for day
779
+ const dayValueIsValid = (day) => {
780
+
781
+ // Guard clause: if there is no day in the dateParts, we can ignore this check.
782
+ if (!dateParts.day) {
783
+ return true;
784
+ }
785
+
786
+ // Guard clause: ensure day exists.
787
+ if (!day) {
788
+ return false;
789
+ }
790
+
791
+ // Convert day to number
792
+ const numDay = Number.parseInt(day, 10);
793
+
794
+ // Guard clause: ensure day is a valid integer
795
+ if (Number.isNaN(numDay)) {
796
+ throw new Error('AuroDatepickerUtilities | dayValueIsValid: Unable to parse day value integer');
797
+ }
798
+
799
+ // Guard clause: ensure day is within the valid range
800
+ if (numDay < this.minDay || numDay > this.maxDay) {
801
+ return false;
802
+ }
803
+
804
+ // Default return
805
+ return true;
806
+ };
807
+
808
+ // Validator for month
809
+ const monthValueIsValid = (month) => {
810
+
811
+ // Guard clause: ensure month exists.
812
+ if (!month) {
813
+ return false;
814
+ }
815
+
816
+ // Convert month to number
817
+ const numMonth = Number.parseInt(month, 10);
818
+
819
+ // Guard clause: ensure month is a valid integer
820
+ if (Number.isNaN(numMonth)) {
821
+ throw new Error('AuroDatepickerUtilities | monthValueIsValid: Unable to parse month value integer');
822
+ }
823
+
824
+ // Guard clause: ensure month is within the valid range
825
+ if (numMonth < this.minMonth || numMonth > this.maxMonth) {
826
+ return false;
827
+ }
828
+
829
+ // Default return
830
+ return true;
831
+ };
832
+
833
+ // Validator for year
834
+ const yearIsValid = (_year) => {
835
+
836
+ // Guard clause: ensure year exists.
837
+ if (!_year) {
838
+ return false;
839
+ }
840
+
841
+ // Get the full year
842
+ const year = this.getFourDigitYear(_year);
843
+
844
+ // Convert year to number
845
+ const numYear = Number.parseInt(year, 10);
846
+
847
+ // Guard clause: ensure year is a valid integer
848
+ if (Number.isNaN(numYear)) {
849
+ throw new Error('AuroDatepickerUtilities | yearValueIsValid: Unable to parse year value integer');
850
+ }
851
+
852
+ // Guard clause: ensure year is within the valid range
853
+ if (numYear < this.minYear || numYear > this.maxYear) {
854
+ return false;
855
+ }
856
+
857
+ // Default return
858
+ return true;
859
+ };
860
+
861
+ // Self-contained checks for month, day, and year
862
+ const checks = [
863
+ monthValueIsValid(dateParts.month),
864
+ dayValueIsValid(dateParts.day),
865
+ yearIsValid(dateParts.year)
866
+ ];
867
+
868
+ // If any of the checks failed, the date format does not match and the result is invalid
869
+ const isValid = checks.every((check) => check === true);
870
+
871
+ // If the check is invalid, return false
872
+ if (!isValid) {
873
+ return false;
874
+ }
875
+
876
+ // Default case
877
+ return true;
878
+ };
879
+ }
880
+ }
881
+
882
+ // Export a class instance
883
+ const dateUtilities = new AuroDateUtilities();
884
+
885
+ // Export the class instance methods individually
886
+ const {
887
+ datesMatch,
888
+ validDateStr,
889
+ dateAndFormatMatch,
890
+ minDay,
891
+ minMonth,
892
+ minYear,
893
+ maxDay,
894
+ maxMonth,
895
+ maxYear
896
+ } = dateUtilities;
897
+
898
+ const {
899
+ toNorthAmericanFormat,
900
+ parseDate,
901
+ getDateAsString
902
+ } = dateFormatter;
903
+
495
904
  // Copyright (c) Alaska Air. All right reserved. Licensed under the Apache-2.0 license
496
905
  // See LICENSE in the project root for license information.
497
906
 
@@ -633,7 +1042,7 @@ class AuroFormValidation {
633
1042
  validity: 'valueMissing',
634
1043
  message: e => e.getAttribute('setCustomValidityValueMissingFilter') || e.setCustomValidity || ''
635
1044
  }
636
- ]
1045
+ ]
637
1046
  }
638
1047
  };
639
1048
 
@@ -698,12 +1107,12 @@ class AuroFormValidation {
698
1107
 
699
1108
  // Guard Clause: if the value is too short
700
1109
  if (elem.value?.length < elem.lengthForType) {
701
-
1110
+
702
1111
  elem.validity = 'tooShort';
703
1112
  elem.errorMessage = elem.setCustomValidityForType || elem.setCustomValidity || '';
704
1113
  return;
705
- }
706
-
1114
+ }
1115
+
707
1116
  // Guard Clause: If the value is too long for the type
708
1117
  if (elem.value?.length > elem.lengthForType) {
709
1118
 
@@ -711,20 +1120,31 @@ class AuroFormValidation {
711
1120
  elem.errorMessage = elem.setCustomValidityForType || elem.setCustomValidity || '';
712
1121
  return;
713
1122
  }
714
-
715
- // Validate that the date passed was the correct format and is a valid date
716
- if (elem.value && !elem.valueObject) {
1123
+
1124
+ // Validate that the date passed was the correct format
1125
+ if (!dateAndFormatMatch(elem.value, elem.format)) {
717
1126
  elem.validity = 'patternMismatch';
718
- elem.errorMessage = elem.setCustomValidityPatternMismatch || elem.setCustomValidity || 'Invalid Date Format Entered';
1127
+ elem.errorMessage = elem.setCustomValidityForType || elem.setCustomValidity || 'Invalid Date Format Entered';
1128
+ return;
1129
+ }
1130
+
1131
+ // Validate that the date passed was a valid date
1132
+ if (!validDateStr(elem.value, elem.format)) {
1133
+ elem.validity = 'invalidDate';
1134
+ elem.errorMessage = elem.setCustomValidityInvalidDate || elem.setCustomValidity || 'Invalid Date Entered';
719
1135
  return;
720
1136
  }
721
1137
 
722
1138
  // Perform the rest of the validation
1139
+ const formattedValue = toNorthAmericanFormat(elem.value, elem.format);
1140
+ const valueDate = new Date(formattedValue);
723
1141
 
724
1142
  // // Validate max date
725
1143
  if (elem.max?.length === elem.lengthForType) {
726
1144
 
727
- if (elem.valueObject > elem.maxObject) {
1145
+ const maxDate = new Date(toNorthAmericanFormat(elem.max, elem.format));
1146
+
1147
+ if (valueDate > maxDate) {
728
1148
  elem.validity = 'rangeOverflow';
729
1149
  elem.errorMessage = elem.setCustomValidityRangeOverflow || elem.setCustomValidity || '';
730
1150
  return;
@@ -733,7 +1153,9 @@ class AuroFormValidation {
733
1153
 
734
1154
  // Validate min date
735
1155
  if (elem.min?.length === elem.lengthForType) {
736
- if (elem.valueObject < elem.minObject) {
1156
+ const minDate = new Date(toNorthAmericanFormat(elem.min, elem.format));
1157
+
1158
+ if (valueDate < minDate) {
737
1159
  elem.validity = 'rangeUnderflow';
738
1160
  elem.errorMessage = elem.setCustomValidityRangeUnderflow || elem.setCustomValidity || '';
739
1161
  return;
@@ -793,7 +1215,7 @@ class AuroFormValidation {
793
1215
  if (typeof elem.value === "string") {
794
1216
  hasValue = elem.value && elem.value.length > 0;
795
1217
  }
796
-
1218
+
797
1219
  if (typeof elem.value === "boolean") {
798
1220
  hasValue = elem.value || elem.value === false;
799
1221
  }
@@ -818,7 +1240,7 @@ class AuroFormValidation {
818
1240
  }
819
1241
 
820
1242
  const isCombobox = this.runtimeUtils.elementMatch(elem, 'auro-combobox');
821
-
1243
+
822
1244
  if (isCombobox) {
823
1245
 
824
1246
  if (!elem.persistInput || elem.behavior === "filter") {
@@ -858,7 +1280,7 @@ class AuroFormValidation {
858
1280
  }
859
1281
 
860
1282
  // multiple input in one components (datepicker)
861
- // combobox has 2 inputs but no need to check validity on the 2nd one which is in fullscreen bib.
1283
+ // combobox has 2 inputs but no need to check validity on the 2nd one which is in fullscreen bib.
862
1284
  if (elem.validity === 'valid' && this.auroInputElements.length > 1 && !isCombobox) {
863
1285
  elem.validity = this.auroInputElements[1].validity;
864
1286
  elem.errorMessage = this.auroInputElements[1].errorMessage;
@@ -1213,7 +1635,7 @@ class AuroHelpText extends LitElement {
1213
1635
  }
1214
1636
  }
1215
1637
 
1216
- var formkitVersion = '202605271944';
1638
+ var formkitVersion = '202605292307';
1217
1639
 
1218
1640
  // Copyright (c) 2026 Alaska Airlines. All rights reserved. Licensed under the Apache-2.0 license
1219
1641
  // See LICENSE in the project root for license information.