@aurodesignsystem-dev/auro-formkit 0.0.0-pr1483.2 → 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 +2319 -7650
  20. package/components/datepicker/dist/index.js +2319 -7650
  21. package/components/datepicker/dist/registered.js +2319 -7650
  22. package/components/datepicker/dist/src/auro-calendar.d.ts +0 -6
  23. package/components/datepicker/dist/src/auro-datepicker.d.ts +11 -24
  24. package/components/datepicker/dist/src/utilities.d.ts +40 -14
  25. package/components/datepicker/dist/src/utilitiesCalendar.d.ts +1 -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 +44181 -58516
  32. package/components/form/demo/getting-started.min.js +44181 -58516
  33. package/components/form/demo/index.min.js +44181 -58516
  34. package/components/form/demo/registerDemoDeps.min.js +44181 -58516
  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 +2117 -2625
  58. package/package.json +4 -4
  59. package/components/input/dist/auro-input-util.d.ts +0 -17
@@ -539,6 +539,415 @@ class AuroCheckbox extends i$2 {
539
539
  */
540
540
  const a=Symbol.for(""),o=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(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(b);
541
541
 
542
+ class DateFormatter {
543
+
544
+ constructor() {
545
+
546
+ /**
547
+ * @description Parses a date string into its components.
548
+ * @param {string} dateStr - Date string to parse.
549
+ * @param {string} format - Date format to parse.
550
+ * @returns {Object<key["month" | "day" | "year"]: number>|undefined}
551
+ */
552
+ this.parseDate = (dateStr, format = 'mm/dd/yyyy') => {
553
+
554
+ // Guard Clause: Date string is defined
555
+ if (!dateStr) {
556
+ return undefined;
557
+ }
558
+
559
+ // Assume the separator is a "/" a defined in our code base
560
+ const separator = '/';
561
+
562
+ // Get the parts of the date and format
563
+ const valueParts = dateStr.split(separator);
564
+ const formatParts = format.split(separator);
565
+
566
+ // Check if the value and format have the correct number of parts
567
+ if (valueParts.length !== formatParts.length) {
568
+ throw new Error('AuroDatepickerUtilities | parseDate: Date string and format length do not match');
569
+ }
570
+
571
+ // Holds the result to be returned
572
+ const result = formatParts.reduce((acc, part, index) => {
573
+ const value = valueParts[index];
574
+
575
+ if ((/m/iu).test(part)) {
576
+ acc.month = value;
577
+ } else if ((/d/iu).test(part)) {
578
+ acc.day = value;
579
+ } else if ((/y/iu).test(part)) {
580
+ acc.year = value;
581
+ }
582
+
583
+ return acc;
584
+ }, {});
585
+
586
+ // If we found all the parts, return the result
587
+ if (result.month && result.year) {
588
+ return result;
589
+ }
590
+
591
+ // Throw an error to let the dev know we were unable to parse the date string
592
+ throw new Error('AuroDatepickerUtilities | parseDate: Unable to parse date string');
593
+ };
594
+
595
+ /**
596
+ * Convert a date object to string format.
597
+ * @param {Object} date - Date to convert to string.
598
+ * @param {String} locale - Optional locale to use for the date string. Defaults to user's locale.
599
+ * @returns {String} Returns the date as a string.
600
+ */
601
+ this.getDateAsString = (date, locale = undefined) => date.toLocaleDateString(locale, {
602
+ year: "numeric",
603
+ month: "2-digit",
604
+ day: "2-digit",
605
+ });
606
+
607
+ /**
608
+ * Converts a date string to a North American date format.
609
+ * @param {String} dateStr - Date to validate.
610
+ * @param {String} format - Date format to validate against.
611
+ * @returns {Boolean}
612
+ */
613
+ this.toNorthAmericanFormat = (dateStr, format) => {
614
+
615
+ if (format === 'mm/dd/yyyy') {
616
+ return dateStr;
617
+ }
618
+
619
+ const parsedDate = this.parseDate(dateStr, format);
620
+
621
+ if (!parsedDate) {
622
+ throw new Error('AuroDatepickerUtilities | toNorthAmericanFormat: Unable to parse date string');
623
+ }
624
+
625
+ const { month, day, year } = parsedDate;
626
+
627
+ const dateParts = [];
628
+ if (month) {
629
+ dateParts.push(month);
630
+ }
631
+
632
+ if (day) {
633
+ dateParts.push(day);
634
+ }
635
+
636
+ if (year) {
637
+ dateParts.push(year);
638
+ }
639
+
640
+ return dateParts.join('/');
641
+ };
642
+ }
643
+ }
644
+ const dateFormatter = new DateFormatter();
645
+
646
+ // filepath: dateConstraints.mjs
647
+ const DATE_UTIL_CONSTRAINTS = {
648
+ maxDay: 31,
649
+ maxMonth: 12,
650
+ maxYear: 2400,
651
+ minDay: 1,
652
+ minMonth: 1,
653
+ minYear: 1900,
654
+ };
655
+
656
+ class AuroDateUtilitiesBase {
657
+
658
+ /**
659
+ * @description The maximum day value allowed by the various utilities in this class.
660
+ * @readonly
661
+ * @type {Number}
662
+ */
663
+ get maxDay() {
664
+ return DATE_UTIL_CONSTRAINTS.maxDay;
665
+ }
666
+
667
+ /**
668
+ * @description The maximum month value allowed by the various utilities in this class.
669
+ * @readonly
670
+ * @type {Number}
671
+ */
672
+ get maxMonth() {
673
+ return DATE_UTIL_CONSTRAINTS.maxMonth;
674
+ }
675
+
676
+ /**
677
+ * @description The maximum year value allowed by the various utilities in this class.
678
+ * @readonly
679
+ * @type {Number}
680
+ */
681
+ get maxYear() {
682
+ return DATE_UTIL_CONSTRAINTS.maxYear;
683
+ }
684
+
685
+ /**
686
+ * @description The minimum day value allowed by the various utilities in this class.
687
+ * @readonly
688
+ * @type {Number}
689
+ */
690
+ get minDay() {
691
+ return DATE_UTIL_CONSTRAINTS.minDay;
692
+ }
693
+
694
+ /**
695
+ * @description The minimum month value allowed by the various utilities in this class.
696
+ * @readonly
697
+ * @type {Number}
698
+ */
699
+ get minMonth() {
700
+ return DATE_UTIL_CONSTRAINTS.minMonth;
701
+ }
702
+
703
+ /**
704
+ * @description The minimum year value allowed by the various utilities in this class.
705
+ * @readonly
706
+ * @type {Number}
707
+ */
708
+ get minYear() {
709
+ return DATE_UTIL_CONSTRAINTS.minYear;
710
+ }
711
+ }
712
+
713
+ /* eslint-disable no-magic-numbers */
714
+
715
+ class AuroDateUtilities extends AuroDateUtilitiesBase {
716
+
717
+ /**
718
+ * Returns the current century.
719
+ * @returns {String} The current century.
720
+ */
721
+ getCentury () {
722
+ return String(new Date().getFullYear()).slice(0, 2);
723
+ }
724
+
725
+ /**
726
+ * Returns a four digit year.
727
+ * @param {String} year - The year to convert to four digits.
728
+ * @returns {String} The four digit year.
729
+ */
730
+ getFourDigitYear (year) {
731
+
732
+ const strYear = String(year).trim();
733
+ return strYear.length <= 2 ? this.getCentury() + strYear : strYear;
734
+ }
735
+
736
+ constructor() {
737
+
738
+ super();
739
+
740
+ /**
741
+ * Compares two dates to see if they match.
742
+ * @param {Object} date1 - First date to compare.
743
+ * @param {Object} date2 - Second date to compare.
744
+ * @returns {Boolean} Returns true if the dates match.
745
+ */
746
+ this.datesMatch = (date1, date2) => new Date(date1).getTime() === new Date(date2).getTime();
747
+
748
+ /**
749
+ * Returns true if value passed in is a valid date.
750
+ * @param {String} date - Date to validate.
751
+ * @param {String} format - Date format to validate against.
752
+ * @returns {Boolean}
753
+ */
754
+ this.validDateStr = (date, format) => {
755
+
756
+ // The length we expect the date string to be
757
+ const dateStrLength = format.length;
758
+
759
+ // Guard Clause: Date and format are defined
760
+ if (typeof date === "undefined" || typeof format === "undefined") {
761
+ throw new Error('AuroDatepickerUtilities | validateDateStr: Date and format are required');
762
+ }
763
+
764
+ // Guard Clause: Date should be of type string
765
+ if (typeof date !== "string") {
766
+ throw new Error('AuroDatepickerUtilities | validateDateStr: Date must be a string');
767
+ }
768
+
769
+ // Guard Clause: Format should be of type string
770
+ if (typeof format !== "string") {
771
+ throw new Error('AuroDatepickerUtilities | validateDateStr: Format must be a string');
772
+ }
773
+
774
+ // Guard Clause: Length is what we expect it to be
775
+ if (date.length !== dateStrLength) {
776
+ return false;
777
+ }
778
+ // Get a formatted date string and parse it
779
+ const dateParts = dateFormatter.parseDate(date, format);
780
+
781
+ // Guard Clause: Date parse succeeded
782
+ if (!dateParts) {
783
+ return false;
784
+ }
785
+
786
+ // Create the expected date string based on the date parts
787
+ const expectedDateStr = `${dateParts.month}/${dateParts.day || "01"}/${this.getFourDigitYear(dateParts.year)}`;
788
+
789
+ // Generate a date object that we will extract a string date from to compare to the passed in date string
790
+ const dateObj = new Date(this.getFourDigitYear(dateParts.year), dateParts.month - 1, dateParts.day || 1);
791
+
792
+ // Get the date string of the date object we created from the string date
793
+ const actualDateStr = dateFormatter.getDateAsString(dateObj, "en-US");
794
+
795
+ // Guard Clause: Generated date matches date string input
796
+ if (expectedDateStr !== actualDateStr) {
797
+ return false;
798
+ }
799
+
800
+ // If we passed all other checks, we can assume the date is valid
801
+ return true;
802
+ };
803
+
804
+ /**
805
+ * Determines if a string date value matches the format provided.
806
+ * @param {string} value = The date string value.
807
+ * @param { string} format = The date format to match against.
808
+ * @returns {boolean}
809
+ */
810
+ this.dateAndFormatMatch = (value, format) => {
811
+
812
+ // Ensure we have both values we need to do the comparison
813
+ if (!value || !format) {
814
+ throw new Error('AuroFormValidation | dateFormatMatch: value and format are required');
815
+ }
816
+
817
+ // If the lengths are different, they cannot match
818
+ if (value.length !== format.length) {
819
+ return false;
820
+ }
821
+
822
+ // Get the parts of the date
823
+ const dateParts = dateFormatter.parseDate(value, format);
824
+
825
+ // Validator for day
826
+ const dayValueIsValid = (day) => {
827
+
828
+ // Guard clause: if there is no day in the dateParts, we can ignore this check.
829
+ if (!dateParts.day) {
830
+ return true;
831
+ }
832
+
833
+ // Guard clause: ensure day exists.
834
+ if (!day) {
835
+ return false;
836
+ }
837
+
838
+ // Convert day to number
839
+ const numDay = Number.parseInt(day, 10);
840
+
841
+ // Guard clause: ensure day is a valid integer
842
+ if (Number.isNaN(numDay)) {
843
+ throw new Error('AuroDatepickerUtilities | dayValueIsValid: Unable to parse day value integer');
844
+ }
845
+
846
+ // Guard clause: ensure day is within the valid range
847
+ if (numDay < this.minDay || numDay > this.maxDay) {
848
+ return false;
849
+ }
850
+
851
+ // Default return
852
+ return true;
853
+ };
854
+
855
+ // Validator for month
856
+ const monthValueIsValid = (month) => {
857
+
858
+ // Guard clause: ensure month exists.
859
+ if (!month) {
860
+ return false;
861
+ }
862
+
863
+ // Convert month to number
864
+ const numMonth = Number.parseInt(month, 10);
865
+
866
+ // Guard clause: ensure month is a valid integer
867
+ if (Number.isNaN(numMonth)) {
868
+ throw new Error('AuroDatepickerUtilities | monthValueIsValid: Unable to parse month value integer');
869
+ }
870
+
871
+ // Guard clause: ensure month is within the valid range
872
+ if (numMonth < this.minMonth || numMonth > this.maxMonth) {
873
+ return false;
874
+ }
875
+
876
+ // Default return
877
+ return true;
878
+ };
879
+
880
+ // Validator for year
881
+ const yearIsValid = (_year) => {
882
+
883
+ // Guard clause: ensure year exists.
884
+ if (!_year) {
885
+ return false;
886
+ }
887
+
888
+ // Get the full year
889
+ const year = this.getFourDigitYear(_year);
890
+
891
+ // Convert year to number
892
+ const numYear = Number.parseInt(year, 10);
893
+
894
+ // Guard clause: ensure year is a valid integer
895
+ if (Number.isNaN(numYear)) {
896
+ throw new Error('AuroDatepickerUtilities | yearValueIsValid: Unable to parse year value integer');
897
+ }
898
+
899
+ // Guard clause: ensure year is within the valid range
900
+ if (numYear < this.minYear || numYear > this.maxYear) {
901
+ return false;
902
+ }
903
+
904
+ // Default return
905
+ return true;
906
+ };
907
+
908
+ // Self-contained checks for month, day, and year
909
+ const checks = [
910
+ monthValueIsValid(dateParts.month),
911
+ dayValueIsValid(dateParts.day),
912
+ yearIsValid(dateParts.year)
913
+ ];
914
+
915
+ // If any of the checks failed, the date format does not match and the result is invalid
916
+ const isValid = checks.every((check) => check === true);
917
+
918
+ // If the check is invalid, return false
919
+ if (!isValid) {
920
+ return false;
921
+ }
922
+
923
+ // Default case
924
+ return true;
925
+ };
926
+ }
927
+ }
928
+
929
+ // Export a class instance
930
+ const dateUtilities = new AuroDateUtilities();
931
+
932
+ // Export the class instance methods individually
933
+ const {
934
+ datesMatch,
935
+ validDateStr,
936
+ dateAndFormatMatch,
937
+ minDay,
938
+ minMonth,
939
+ minYear,
940
+ maxDay,
941
+ maxMonth,
942
+ maxYear
943
+ } = dateUtilities;
944
+
945
+ const {
946
+ toNorthAmericanFormat,
947
+ parseDate,
948
+ getDateAsString
949
+ } = dateFormatter;
950
+
542
951
  // Copyright (c) Alaska Air. All right reserved. Licensed under the Apache-2.0 license
543
952
  // See LICENSE in the project root for license information.
544
953
 
@@ -680,7 +1089,7 @@ class AuroFormValidation {
680
1089
  validity: 'valueMissing',
681
1090
  message: e => e.getAttribute('setCustomValidityValueMissingFilter') || e.setCustomValidity || ''
682
1091
  }
683
- ]
1092
+ ]
684
1093
  }
685
1094
  };
686
1095
 
@@ -745,12 +1154,12 @@ class AuroFormValidation {
745
1154
 
746
1155
  // Guard Clause: if the value is too short
747
1156
  if (elem.value?.length < elem.lengthForType) {
748
-
1157
+
749
1158
  elem.validity = 'tooShort';
750
1159
  elem.errorMessage = elem.setCustomValidityForType || elem.setCustomValidity || '';
751
1160
  return;
752
- }
753
-
1161
+ }
1162
+
754
1163
  // Guard Clause: If the value is too long for the type
755
1164
  if (elem.value?.length > elem.lengthForType) {
756
1165
 
@@ -758,20 +1167,31 @@ class AuroFormValidation {
758
1167
  elem.errorMessage = elem.setCustomValidityForType || elem.setCustomValidity || '';
759
1168
  return;
760
1169
  }
761
-
762
- // Validate that the date passed was the correct format and is a valid date
763
- if (elem.value && !elem.valueObject) {
1170
+
1171
+ // Validate that the date passed was the correct format
1172
+ if (!dateAndFormatMatch(elem.value, elem.format)) {
764
1173
  elem.validity = 'patternMismatch';
765
- elem.errorMessage = elem.setCustomValidityPatternMismatch || elem.setCustomValidity || 'Invalid Date Format Entered';
1174
+ elem.errorMessage = elem.setCustomValidityForType || elem.setCustomValidity || 'Invalid Date Format Entered';
1175
+ return;
1176
+ }
1177
+
1178
+ // Validate that the date passed was a valid date
1179
+ if (!validDateStr(elem.value, elem.format)) {
1180
+ elem.validity = 'invalidDate';
1181
+ elem.errorMessage = elem.setCustomValidityInvalidDate || elem.setCustomValidity || 'Invalid Date Entered';
766
1182
  return;
767
1183
  }
768
1184
 
769
1185
  // Perform the rest of the validation
1186
+ const formattedValue = toNorthAmericanFormat(elem.value, elem.format);
1187
+ const valueDate = new Date(formattedValue);
770
1188
 
771
1189
  // // Validate max date
772
1190
  if (elem.max?.length === elem.lengthForType) {
773
1191
 
774
- if (elem.valueObject > elem.maxObject) {
1192
+ const maxDate = new Date(toNorthAmericanFormat(elem.max, elem.format));
1193
+
1194
+ if (valueDate > maxDate) {
775
1195
  elem.validity = 'rangeOverflow';
776
1196
  elem.errorMessage = elem.setCustomValidityRangeOverflow || elem.setCustomValidity || '';
777
1197
  return;
@@ -780,7 +1200,9 @@ class AuroFormValidation {
780
1200
 
781
1201
  // Validate min date
782
1202
  if (elem.min?.length === elem.lengthForType) {
783
- if (elem.valueObject < elem.minObject) {
1203
+ const minDate = new Date(toNorthAmericanFormat(elem.min, elem.format));
1204
+
1205
+ if (valueDate < minDate) {
784
1206
  elem.validity = 'rangeUnderflow';
785
1207
  elem.errorMessage = elem.setCustomValidityRangeUnderflow || elem.setCustomValidity || '';
786
1208
  return;
@@ -840,7 +1262,7 @@ class AuroFormValidation {
840
1262
  if (typeof elem.value === "string") {
841
1263
  hasValue = elem.value && elem.value.length > 0;
842
1264
  }
843
-
1265
+
844
1266
  if (typeof elem.value === "boolean") {
845
1267
  hasValue = elem.value || elem.value === false;
846
1268
  }
@@ -865,7 +1287,7 @@ class AuroFormValidation {
865
1287
  }
866
1288
 
867
1289
  const isCombobox = this.runtimeUtils.elementMatch(elem, 'auro-combobox');
868
-
1290
+
869
1291
  if (isCombobox) {
870
1292
 
871
1293
  if (!elem.persistInput || elem.behavior === "filter") {
@@ -905,7 +1327,7 @@ class AuroFormValidation {
905
1327
  }
906
1328
 
907
1329
  // multiple input in one components (datepicker)
908
- // combobox has 2 inputs but no need to check validity on the 2nd one which is in fullscreen bib.
1330
+ // combobox has 2 inputs but no need to check validity on the 2nd one which is in fullscreen bib.
909
1331
  if (elem.validity === 'valid' && this.auroInputElements.length > 1 && !isCombobox) {
910
1332
  elem.validity = this.auroInputElements[1].validity;
911
1333
  elem.errorMessage = this.auroInputElements[1].errorMessage;
@@ -1260,7 +1682,7 @@ class AuroHelpText extends i$2 {
1260
1682
  }
1261
1683
  }
1262
1684
 
1263
- var formkitVersion = '202605271836';
1685
+ var formkitVersion = '202605292307';
1264
1686
 
1265
1687
  // Copyright (c) 2026 Alaska Airlines. All rights reserved. Licensed under the Apache-2.0 license
1266
1688
  // See LICENSE in the project root for license information.