@aurodesignsystem-dev/auro-formkit 0.0.0-pr1344.3 → 0.0.0-pr1344.5
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.
- package/components/checkbox/demo/api.min.js +66 -41
- package/components/checkbox/demo/index.min.js +66 -41
- package/components/checkbox/dist/index.js +66 -41
- package/components/checkbox/dist/registered.js +66 -41
- package/components/combobox/demo/api.min.js +146 -83
- package/components/combobox/demo/index.min.js +146 -83
- package/components/combobox/dist/index.js +146 -83
- package/components/combobox/dist/registered.js +146 -83
- package/components/counter/demo/api.min.js +67 -42
- package/components/counter/demo/index.min.js +67 -42
- package/components/counter/dist/index.js +67 -42
- package/components/counter/dist/registered.js +67 -42
- package/components/datepicker/demo/api.min.js +148 -83
- package/components/datepicker/demo/index.min.js +148 -83
- package/components/datepicker/dist/index.js +148 -83
- package/components/datepicker/dist/registered.js +148 -83
- package/components/dropdown/demo/api.min.js +1 -1
- package/components/dropdown/demo/index.min.js +1 -1
- package/components/dropdown/dist/index.js +1 -1
- package/components/dropdown/dist/registered.js +1 -1
- package/components/input/demo/api.min.js +79 -41
- package/components/input/demo/index.html +2 -2
- package/components/input/demo/index.min.js +79 -41
- package/components/input/dist/index.js +79 -41
- package/components/input/dist/registered.js +79 -41
- package/components/radio/demo/api.min.js +66 -41
- package/components/radio/demo/index.min.js +66 -41
- package/components/radio/dist/index.js +66 -41
- package/components/radio/dist/registered.js +66 -41
- package/components/select/demo/api.min.js +67 -42
- package/components/select/demo/index.min.js +67 -42
- package/components/select/dist/index.js +67 -42
- package/components/select/dist/registered.js +67 -42
- package/custom-elements.json +1406 -1406
- package/package.json +2 -2
|
@@ -545,24 +545,21 @@ class AuroCheckbox extends i$2 {
|
|
|
545
545
|
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);
|
|
546
546
|
|
|
547
547
|
class DateFormatter {
|
|
548
|
-
|
|
549
548
|
constructor() {
|
|
550
|
-
|
|
551
549
|
/**
|
|
552
550
|
* @description Parses a date string into its components.
|
|
553
551
|
* @param {string} dateStr - Date string to parse.
|
|
554
552
|
* @param {string} format - Date format to parse.
|
|
555
553
|
* @returns {Object<key["month" | "day" | "year"]: number>|undefined}
|
|
556
554
|
*/
|
|
557
|
-
this.parseDate = (dateStr, format =
|
|
558
|
-
|
|
555
|
+
this.parseDate = (dateStr, format = "mm/dd/yyyy") => {
|
|
559
556
|
// Guard Clause: Date string is defined
|
|
560
557
|
if (!dateStr) {
|
|
561
558
|
return undefined;
|
|
562
559
|
}
|
|
563
560
|
|
|
564
561
|
// Assume the separator is a "/" a defined in our code base
|
|
565
|
-
const separator =
|
|
562
|
+
const separator = "/";
|
|
566
563
|
|
|
567
564
|
// Get the parts of the date and format
|
|
568
565
|
const valueParts = dateStr.split(separator);
|
|
@@ -570,31 +567,35 @@ class DateFormatter {
|
|
|
570
567
|
|
|
571
568
|
// Check if the value and format have the correct number of parts
|
|
572
569
|
if (valueParts.length !== formatParts.length) {
|
|
573
|
-
throw new Error(
|
|
570
|
+
throw new Error(
|
|
571
|
+
"AuroDatepickerUtilities | parseDate: Date string and format length do not match",
|
|
572
|
+
);
|
|
574
573
|
}
|
|
575
574
|
|
|
576
575
|
// Holds the result to be returned
|
|
577
576
|
const result = formatParts.reduce((acc, part, index) => {
|
|
578
577
|
const value = valueParts[index];
|
|
579
578
|
|
|
580
|
-
if (
|
|
579
|
+
if (/m/iu.test(part)) {
|
|
581
580
|
acc.month = value;
|
|
582
|
-
} else if (
|
|
581
|
+
} else if (/d/iu.test(part)) {
|
|
583
582
|
acc.day = value;
|
|
584
|
-
} else if (
|
|
583
|
+
} else if (/y/iu.test(part)) {
|
|
585
584
|
acc.year = value;
|
|
586
585
|
}
|
|
587
586
|
|
|
588
587
|
return acc;
|
|
589
588
|
}, {});
|
|
590
589
|
|
|
591
|
-
// If we found
|
|
592
|
-
if (result.month
|
|
590
|
+
// If we found at least one part, return the result
|
|
591
|
+
if (result.month || result.day || result.year) {
|
|
593
592
|
return result;
|
|
594
593
|
}
|
|
595
594
|
|
|
596
595
|
// Throw an error to let the dev know we were unable to parse the date string
|
|
597
|
-
throw new Error(
|
|
596
|
+
throw new Error(
|
|
597
|
+
"AuroDatepickerUtilities | parseDate: Unable to parse date string",
|
|
598
|
+
);
|
|
598
599
|
};
|
|
599
600
|
|
|
600
601
|
/**
|
|
@@ -603,11 +604,12 @@ class DateFormatter {
|
|
|
603
604
|
* @param {String} locale - Optional locale to use for the date string. Defaults to user's locale.
|
|
604
605
|
* @returns {String} Returns the date as a string.
|
|
605
606
|
*/
|
|
606
|
-
this.getDateAsString = (date, locale = undefined) =>
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
607
|
+
this.getDateAsString = (date, locale = undefined) =>
|
|
608
|
+
date.toLocaleDateString(locale, {
|
|
609
|
+
year: "numeric",
|
|
610
|
+
month: "2-digit",
|
|
611
|
+
day: "2-digit",
|
|
612
|
+
});
|
|
611
613
|
|
|
612
614
|
/**
|
|
613
615
|
* Converts a date string to a North American date format.
|
|
@@ -616,15 +618,16 @@ class DateFormatter {
|
|
|
616
618
|
* @returns {Boolean}
|
|
617
619
|
*/
|
|
618
620
|
this.toNorthAmericanFormat = (dateStr, format) => {
|
|
619
|
-
|
|
620
|
-
if (format === 'mm/dd/yyyy') {
|
|
621
|
+
if (format === "mm/dd/yyyy") {
|
|
621
622
|
return dateStr;
|
|
622
623
|
}
|
|
623
624
|
|
|
624
625
|
const parsedDate = this.parseDate(dateStr, format);
|
|
625
626
|
|
|
626
627
|
if (!parsedDate) {
|
|
627
|
-
throw new Error(
|
|
628
|
+
throw new Error(
|
|
629
|
+
"AuroDatepickerUtilities | toNorthAmericanFormat: Unable to parse date string",
|
|
630
|
+
);
|
|
628
631
|
}
|
|
629
632
|
|
|
630
633
|
const { month, day, year } = parsedDate;
|
|
@@ -642,10 +645,11 @@ class DateFormatter {
|
|
|
642
645
|
dateParts.push(year);
|
|
643
646
|
}
|
|
644
647
|
|
|
645
|
-
return dateParts.join(
|
|
648
|
+
return dateParts.join("/");
|
|
646
649
|
};
|
|
647
650
|
}
|
|
648
651
|
}
|
|
652
|
+
|
|
649
653
|
const dateFormatter = new DateFormatter();
|
|
650
654
|
|
|
651
655
|
// filepath: dateConstraints.mjs
|
|
@@ -718,12 +722,11 @@ class AuroDateUtilitiesBase {
|
|
|
718
722
|
/* eslint-disable no-magic-numbers */
|
|
719
723
|
|
|
720
724
|
class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
721
|
-
|
|
722
725
|
/**
|
|
723
726
|
* Returns the current century.
|
|
724
727
|
* @returns {String} The current century.
|
|
725
728
|
*/
|
|
726
|
-
getCentury
|
|
729
|
+
getCentury() {
|
|
727
730
|
return String(new Date().getFullYear()).slice(0, 2);
|
|
728
731
|
}
|
|
729
732
|
|
|
@@ -732,14 +735,12 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
732
735
|
* @param {String} year - The year to convert to four digits.
|
|
733
736
|
* @returns {String} The four digit year.
|
|
734
737
|
*/
|
|
735
|
-
getFourDigitYear
|
|
736
|
-
|
|
738
|
+
getFourDigitYear(year) {
|
|
737
739
|
const strYear = String(year).trim();
|
|
738
740
|
return strYear.length <= 2 ? this.getCentury() + strYear : strYear;
|
|
739
741
|
}
|
|
740
742
|
|
|
741
743
|
constructor() {
|
|
742
|
-
|
|
743
744
|
super();
|
|
744
745
|
|
|
745
746
|
/**
|
|
@@ -748,7 +749,8 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
748
749
|
* @param {Object} date2 - Second date to compare.
|
|
749
750
|
* @returns {Boolean} Returns true if the dates match.
|
|
750
751
|
*/
|
|
751
|
-
this.datesMatch = (date1, date2) =>
|
|
752
|
+
this.datesMatch = (date1, date2) =>
|
|
753
|
+
new Date(date1).getTime() === new Date(date2).getTime();
|
|
752
754
|
|
|
753
755
|
/**
|
|
754
756
|
* Returns true if value passed in is a valid date.
|
|
@@ -757,29 +759,35 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
757
759
|
* @returns {Boolean}
|
|
758
760
|
*/
|
|
759
761
|
this.validDateStr = (date, format) => {
|
|
760
|
-
|
|
761
762
|
// The length we expect the date string to be
|
|
762
763
|
const dateStrLength = format.length;
|
|
763
764
|
|
|
764
765
|
// Guard Clause: Date and format are defined
|
|
765
766
|
if (typeof date === "undefined" || typeof format === "undefined") {
|
|
766
|
-
throw new Error(
|
|
767
|
+
throw new Error(
|
|
768
|
+
"AuroDatepickerUtilities | validateDateStr: Date and format are required",
|
|
769
|
+
);
|
|
767
770
|
}
|
|
768
771
|
|
|
769
772
|
// Guard Clause: Date should be of type string
|
|
770
773
|
if (typeof date !== "string") {
|
|
771
|
-
throw new Error(
|
|
774
|
+
throw new Error(
|
|
775
|
+
"AuroDatepickerUtilities | validateDateStr: Date must be a string",
|
|
776
|
+
);
|
|
772
777
|
}
|
|
773
778
|
|
|
774
779
|
// Guard Clause: Format should be of type string
|
|
775
780
|
if (typeof format !== "string") {
|
|
776
|
-
throw new Error(
|
|
781
|
+
throw new Error(
|
|
782
|
+
"AuroDatepickerUtilities | validateDateStr: Format must be a string",
|
|
783
|
+
);
|
|
777
784
|
}
|
|
778
785
|
|
|
779
786
|
// Guard Clause: Length is what we expect it to be
|
|
780
787
|
if (date.length !== dateStrLength) {
|
|
781
788
|
return false;
|
|
782
789
|
}
|
|
790
|
+
|
|
783
791
|
// Get a formatted date string and parse it
|
|
784
792
|
const dateParts = dateFormatter.parseDate(date, format);
|
|
785
793
|
|
|
@@ -789,10 +797,13 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
789
797
|
}
|
|
790
798
|
|
|
791
799
|
// Create the expected date string based on the date parts
|
|
792
|
-
const
|
|
800
|
+
const month = dateParts.month || "01";
|
|
801
|
+
const day = dateParts.day || "01";
|
|
802
|
+
const year = this.getFourDigitYear(dateParts.year || "2000");
|
|
803
|
+
const expectedDateStr = `${month}/${day}/${year}`;
|
|
793
804
|
|
|
794
805
|
// Generate a date object that we will extract a string date from to compare to the passed in date string
|
|
795
|
-
const dateObj = new Date(
|
|
806
|
+
const dateObj = new Date(year, month - 1, day);
|
|
796
807
|
|
|
797
808
|
// Get the date string of the date object we created from the string date
|
|
798
809
|
const actualDateStr = dateFormatter.getDateAsString(dateObj, "en-US");
|
|
@@ -813,10 +824,11 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
813
824
|
* @returns {boolean}
|
|
814
825
|
*/
|
|
815
826
|
this.dateAndFormatMatch = (value, format) => {
|
|
816
|
-
|
|
817
827
|
// Ensure we have both values we need to do the comparison
|
|
818
828
|
if (!value || !format) {
|
|
819
|
-
throw new Error(
|
|
829
|
+
throw new Error(
|
|
830
|
+
"AuroFormValidation | dateFormatMatch: value and format are required",
|
|
831
|
+
);
|
|
820
832
|
}
|
|
821
833
|
|
|
822
834
|
// If the lengths are different, they cannot match
|
|
@@ -829,7 +841,6 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
829
841
|
|
|
830
842
|
// Validator for day
|
|
831
843
|
const dayValueIsValid = (day) => {
|
|
832
|
-
|
|
833
844
|
// Guard clause: if there is no day in the dateParts, we can ignore this check.
|
|
834
845
|
if (!dateParts.day) {
|
|
835
846
|
return true;
|
|
@@ -845,7 +856,9 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
845
856
|
|
|
846
857
|
// Guard clause: ensure day is a valid integer
|
|
847
858
|
if (Number.isNaN(numDay)) {
|
|
848
|
-
throw new Error(
|
|
859
|
+
throw new Error(
|
|
860
|
+
"AuroDatepickerUtilities | dayValueIsValid: Unable to parse day value integer",
|
|
861
|
+
);
|
|
849
862
|
}
|
|
850
863
|
|
|
851
864
|
// Guard clause: ensure day is within the valid range
|
|
@@ -859,6 +872,10 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
859
872
|
|
|
860
873
|
// Validator for month
|
|
861
874
|
const monthValueIsValid = (month) => {
|
|
875
|
+
// Guard clause: if there is no month in the dateParts, we can ignore this check.
|
|
876
|
+
if (!dateParts.month) {
|
|
877
|
+
return true;
|
|
878
|
+
}
|
|
862
879
|
|
|
863
880
|
// Guard clause: ensure month exists.
|
|
864
881
|
if (!month) {
|
|
@@ -870,7 +887,9 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
870
887
|
|
|
871
888
|
// Guard clause: ensure month is a valid integer
|
|
872
889
|
if (Number.isNaN(numMonth)) {
|
|
873
|
-
throw new Error(
|
|
890
|
+
throw new Error(
|
|
891
|
+
"AuroDatepickerUtilities | monthValueIsValid: Unable to parse month value integer",
|
|
892
|
+
);
|
|
874
893
|
}
|
|
875
894
|
|
|
876
895
|
// Guard clause: ensure month is within the valid range
|
|
@@ -884,6 +903,10 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
884
903
|
|
|
885
904
|
// Validator for year
|
|
886
905
|
const yearIsValid = (_year) => {
|
|
906
|
+
// Guard clause: if there is no year in the dateParts, we can ignore this check.
|
|
907
|
+
if (!dateParts.year) {
|
|
908
|
+
return true;
|
|
909
|
+
}
|
|
887
910
|
|
|
888
911
|
// Guard clause: ensure year exists.
|
|
889
912
|
if (!_year) {
|
|
@@ -898,7 +921,9 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
898
921
|
|
|
899
922
|
// Guard clause: ensure year is a valid integer
|
|
900
923
|
if (Number.isNaN(numYear)) {
|
|
901
|
-
throw new Error(
|
|
924
|
+
throw new Error(
|
|
925
|
+
"AuroDatepickerUtilities | yearValueIsValid: Unable to parse year value integer",
|
|
926
|
+
);
|
|
902
927
|
}
|
|
903
928
|
|
|
904
929
|
// Guard clause: ensure year is within the valid range
|
|
@@ -914,7 +939,7 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
914
939
|
const checks = [
|
|
915
940
|
monthValueIsValid(dateParts.month),
|
|
916
941
|
dayValueIsValid(dateParts.day),
|
|
917
|
-
yearIsValid(dateParts.year)
|
|
942
|
+
yearIsValid(dateParts.year),
|
|
918
943
|
];
|
|
919
944
|
|
|
920
945
|
// If any of the checks failed, the date format does not match and the result is invalid
|
|
@@ -1687,7 +1712,7 @@ class AuroHelpText extends i$2 {
|
|
|
1687
1712
|
}
|
|
1688
1713
|
}
|
|
1689
1714
|
|
|
1690
|
-
var formkitVersion = '
|
|
1715
|
+
var formkitVersion = '202602201901';
|
|
1691
1716
|
|
|
1692
1717
|
// Copyright (c) 2026 Alaska Airlines. All right reserved. Licensed under the Apache-2.0 license
|
|
1693
1718
|
// See LICENSE in the project root for license information.
|
|
@@ -537,24 +537,21 @@ class AuroCheckbox extends i$2 {
|
|
|
537
537
|
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);
|
|
538
538
|
|
|
539
539
|
class DateFormatter {
|
|
540
|
-
|
|
541
540
|
constructor() {
|
|
542
|
-
|
|
543
541
|
/**
|
|
544
542
|
* @description Parses a date string into its components.
|
|
545
543
|
* @param {string} dateStr - Date string to parse.
|
|
546
544
|
* @param {string} format - Date format to parse.
|
|
547
545
|
* @returns {Object<key["month" | "day" | "year"]: number>|undefined}
|
|
548
546
|
*/
|
|
549
|
-
this.parseDate = (dateStr, format =
|
|
550
|
-
|
|
547
|
+
this.parseDate = (dateStr, format = "mm/dd/yyyy") => {
|
|
551
548
|
// Guard Clause: Date string is defined
|
|
552
549
|
if (!dateStr) {
|
|
553
550
|
return undefined;
|
|
554
551
|
}
|
|
555
552
|
|
|
556
553
|
// Assume the separator is a "/" a defined in our code base
|
|
557
|
-
const separator =
|
|
554
|
+
const separator = "/";
|
|
558
555
|
|
|
559
556
|
// Get the parts of the date and format
|
|
560
557
|
const valueParts = dateStr.split(separator);
|
|
@@ -562,31 +559,35 @@ class DateFormatter {
|
|
|
562
559
|
|
|
563
560
|
// Check if the value and format have the correct number of parts
|
|
564
561
|
if (valueParts.length !== formatParts.length) {
|
|
565
|
-
throw new Error(
|
|
562
|
+
throw new Error(
|
|
563
|
+
"AuroDatepickerUtilities | parseDate: Date string and format length do not match",
|
|
564
|
+
);
|
|
566
565
|
}
|
|
567
566
|
|
|
568
567
|
// Holds the result to be returned
|
|
569
568
|
const result = formatParts.reduce((acc, part, index) => {
|
|
570
569
|
const value = valueParts[index];
|
|
571
570
|
|
|
572
|
-
if (
|
|
571
|
+
if (/m/iu.test(part)) {
|
|
573
572
|
acc.month = value;
|
|
574
|
-
} else if (
|
|
573
|
+
} else if (/d/iu.test(part)) {
|
|
575
574
|
acc.day = value;
|
|
576
|
-
} else if (
|
|
575
|
+
} else if (/y/iu.test(part)) {
|
|
577
576
|
acc.year = value;
|
|
578
577
|
}
|
|
579
578
|
|
|
580
579
|
return acc;
|
|
581
580
|
}, {});
|
|
582
581
|
|
|
583
|
-
// If we found
|
|
584
|
-
if (result.month
|
|
582
|
+
// If we found at least one part, return the result
|
|
583
|
+
if (result.month || result.day || result.year) {
|
|
585
584
|
return result;
|
|
586
585
|
}
|
|
587
586
|
|
|
588
587
|
// Throw an error to let the dev know we were unable to parse the date string
|
|
589
|
-
throw new Error(
|
|
588
|
+
throw new Error(
|
|
589
|
+
"AuroDatepickerUtilities | parseDate: Unable to parse date string",
|
|
590
|
+
);
|
|
590
591
|
};
|
|
591
592
|
|
|
592
593
|
/**
|
|
@@ -595,11 +596,12 @@ class DateFormatter {
|
|
|
595
596
|
* @param {String} locale - Optional locale to use for the date string. Defaults to user's locale.
|
|
596
597
|
* @returns {String} Returns the date as a string.
|
|
597
598
|
*/
|
|
598
|
-
this.getDateAsString = (date, locale = undefined) =>
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
599
|
+
this.getDateAsString = (date, locale = undefined) =>
|
|
600
|
+
date.toLocaleDateString(locale, {
|
|
601
|
+
year: "numeric",
|
|
602
|
+
month: "2-digit",
|
|
603
|
+
day: "2-digit",
|
|
604
|
+
});
|
|
603
605
|
|
|
604
606
|
/**
|
|
605
607
|
* Converts a date string to a North American date format.
|
|
@@ -608,15 +610,16 @@ class DateFormatter {
|
|
|
608
610
|
* @returns {Boolean}
|
|
609
611
|
*/
|
|
610
612
|
this.toNorthAmericanFormat = (dateStr, format) => {
|
|
611
|
-
|
|
612
|
-
if (format === 'mm/dd/yyyy') {
|
|
613
|
+
if (format === "mm/dd/yyyy") {
|
|
613
614
|
return dateStr;
|
|
614
615
|
}
|
|
615
616
|
|
|
616
617
|
const parsedDate = this.parseDate(dateStr, format);
|
|
617
618
|
|
|
618
619
|
if (!parsedDate) {
|
|
619
|
-
throw new Error(
|
|
620
|
+
throw new Error(
|
|
621
|
+
"AuroDatepickerUtilities | toNorthAmericanFormat: Unable to parse date string",
|
|
622
|
+
);
|
|
620
623
|
}
|
|
621
624
|
|
|
622
625
|
const { month, day, year } = parsedDate;
|
|
@@ -634,10 +637,11 @@ class DateFormatter {
|
|
|
634
637
|
dateParts.push(year);
|
|
635
638
|
}
|
|
636
639
|
|
|
637
|
-
return dateParts.join(
|
|
640
|
+
return dateParts.join("/");
|
|
638
641
|
};
|
|
639
642
|
}
|
|
640
643
|
}
|
|
644
|
+
|
|
641
645
|
const dateFormatter = new DateFormatter();
|
|
642
646
|
|
|
643
647
|
// filepath: dateConstraints.mjs
|
|
@@ -710,12 +714,11 @@ class AuroDateUtilitiesBase {
|
|
|
710
714
|
/* eslint-disable no-magic-numbers */
|
|
711
715
|
|
|
712
716
|
class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
713
|
-
|
|
714
717
|
/**
|
|
715
718
|
* Returns the current century.
|
|
716
719
|
* @returns {String} The current century.
|
|
717
720
|
*/
|
|
718
|
-
getCentury
|
|
721
|
+
getCentury() {
|
|
719
722
|
return String(new Date().getFullYear()).slice(0, 2);
|
|
720
723
|
}
|
|
721
724
|
|
|
@@ -724,14 +727,12 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
724
727
|
* @param {String} year - The year to convert to four digits.
|
|
725
728
|
* @returns {String} The four digit year.
|
|
726
729
|
*/
|
|
727
|
-
getFourDigitYear
|
|
728
|
-
|
|
730
|
+
getFourDigitYear(year) {
|
|
729
731
|
const strYear = String(year).trim();
|
|
730
732
|
return strYear.length <= 2 ? this.getCentury() + strYear : strYear;
|
|
731
733
|
}
|
|
732
734
|
|
|
733
735
|
constructor() {
|
|
734
|
-
|
|
735
736
|
super();
|
|
736
737
|
|
|
737
738
|
/**
|
|
@@ -740,7 +741,8 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
740
741
|
* @param {Object} date2 - Second date to compare.
|
|
741
742
|
* @returns {Boolean} Returns true if the dates match.
|
|
742
743
|
*/
|
|
743
|
-
this.datesMatch = (date1, date2) =>
|
|
744
|
+
this.datesMatch = (date1, date2) =>
|
|
745
|
+
new Date(date1).getTime() === new Date(date2).getTime();
|
|
744
746
|
|
|
745
747
|
/**
|
|
746
748
|
* Returns true if value passed in is a valid date.
|
|
@@ -749,29 +751,35 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
749
751
|
* @returns {Boolean}
|
|
750
752
|
*/
|
|
751
753
|
this.validDateStr = (date, format) => {
|
|
752
|
-
|
|
753
754
|
// The length we expect the date string to be
|
|
754
755
|
const dateStrLength = format.length;
|
|
755
756
|
|
|
756
757
|
// Guard Clause: Date and format are defined
|
|
757
758
|
if (typeof date === "undefined" || typeof format === "undefined") {
|
|
758
|
-
throw new Error(
|
|
759
|
+
throw new Error(
|
|
760
|
+
"AuroDatepickerUtilities | validateDateStr: Date and format are required",
|
|
761
|
+
);
|
|
759
762
|
}
|
|
760
763
|
|
|
761
764
|
// Guard Clause: Date should be of type string
|
|
762
765
|
if (typeof date !== "string") {
|
|
763
|
-
throw new Error(
|
|
766
|
+
throw new Error(
|
|
767
|
+
"AuroDatepickerUtilities | validateDateStr: Date must be a string",
|
|
768
|
+
);
|
|
764
769
|
}
|
|
765
770
|
|
|
766
771
|
// Guard Clause: Format should be of type string
|
|
767
772
|
if (typeof format !== "string") {
|
|
768
|
-
throw new Error(
|
|
773
|
+
throw new Error(
|
|
774
|
+
"AuroDatepickerUtilities | validateDateStr: Format must be a string",
|
|
775
|
+
);
|
|
769
776
|
}
|
|
770
777
|
|
|
771
778
|
// Guard Clause: Length is what we expect it to be
|
|
772
779
|
if (date.length !== dateStrLength) {
|
|
773
780
|
return false;
|
|
774
781
|
}
|
|
782
|
+
|
|
775
783
|
// Get a formatted date string and parse it
|
|
776
784
|
const dateParts = dateFormatter.parseDate(date, format);
|
|
777
785
|
|
|
@@ -781,10 +789,13 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
781
789
|
}
|
|
782
790
|
|
|
783
791
|
// Create the expected date string based on the date parts
|
|
784
|
-
const
|
|
792
|
+
const month = dateParts.month || "01";
|
|
793
|
+
const day = dateParts.day || "01";
|
|
794
|
+
const year = this.getFourDigitYear(dateParts.year || "2000");
|
|
795
|
+
const expectedDateStr = `${month}/${day}/${year}`;
|
|
785
796
|
|
|
786
797
|
// Generate a date object that we will extract a string date from to compare to the passed in date string
|
|
787
|
-
const dateObj = new Date(
|
|
798
|
+
const dateObj = new Date(year, month - 1, day);
|
|
788
799
|
|
|
789
800
|
// Get the date string of the date object we created from the string date
|
|
790
801
|
const actualDateStr = dateFormatter.getDateAsString(dateObj, "en-US");
|
|
@@ -805,10 +816,11 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
805
816
|
* @returns {boolean}
|
|
806
817
|
*/
|
|
807
818
|
this.dateAndFormatMatch = (value, format) => {
|
|
808
|
-
|
|
809
819
|
// Ensure we have both values we need to do the comparison
|
|
810
820
|
if (!value || !format) {
|
|
811
|
-
throw new Error(
|
|
821
|
+
throw new Error(
|
|
822
|
+
"AuroFormValidation | dateFormatMatch: value and format are required",
|
|
823
|
+
);
|
|
812
824
|
}
|
|
813
825
|
|
|
814
826
|
// If the lengths are different, they cannot match
|
|
@@ -821,7 +833,6 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
821
833
|
|
|
822
834
|
// Validator for day
|
|
823
835
|
const dayValueIsValid = (day) => {
|
|
824
|
-
|
|
825
836
|
// Guard clause: if there is no day in the dateParts, we can ignore this check.
|
|
826
837
|
if (!dateParts.day) {
|
|
827
838
|
return true;
|
|
@@ -837,7 +848,9 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
837
848
|
|
|
838
849
|
// Guard clause: ensure day is a valid integer
|
|
839
850
|
if (Number.isNaN(numDay)) {
|
|
840
|
-
throw new Error(
|
|
851
|
+
throw new Error(
|
|
852
|
+
"AuroDatepickerUtilities | dayValueIsValid: Unable to parse day value integer",
|
|
853
|
+
);
|
|
841
854
|
}
|
|
842
855
|
|
|
843
856
|
// Guard clause: ensure day is within the valid range
|
|
@@ -851,6 +864,10 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
851
864
|
|
|
852
865
|
// Validator for month
|
|
853
866
|
const monthValueIsValid = (month) => {
|
|
867
|
+
// Guard clause: if there is no month in the dateParts, we can ignore this check.
|
|
868
|
+
if (!dateParts.month) {
|
|
869
|
+
return true;
|
|
870
|
+
}
|
|
854
871
|
|
|
855
872
|
// Guard clause: ensure month exists.
|
|
856
873
|
if (!month) {
|
|
@@ -862,7 +879,9 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
862
879
|
|
|
863
880
|
// Guard clause: ensure month is a valid integer
|
|
864
881
|
if (Number.isNaN(numMonth)) {
|
|
865
|
-
throw new Error(
|
|
882
|
+
throw new Error(
|
|
883
|
+
"AuroDatepickerUtilities | monthValueIsValid: Unable to parse month value integer",
|
|
884
|
+
);
|
|
866
885
|
}
|
|
867
886
|
|
|
868
887
|
// Guard clause: ensure month is within the valid range
|
|
@@ -876,6 +895,10 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
876
895
|
|
|
877
896
|
// Validator for year
|
|
878
897
|
const yearIsValid = (_year) => {
|
|
898
|
+
// Guard clause: if there is no year in the dateParts, we can ignore this check.
|
|
899
|
+
if (!dateParts.year) {
|
|
900
|
+
return true;
|
|
901
|
+
}
|
|
879
902
|
|
|
880
903
|
// Guard clause: ensure year exists.
|
|
881
904
|
if (!_year) {
|
|
@@ -890,7 +913,9 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
890
913
|
|
|
891
914
|
// Guard clause: ensure year is a valid integer
|
|
892
915
|
if (Number.isNaN(numYear)) {
|
|
893
|
-
throw new Error(
|
|
916
|
+
throw new Error(
|
|
917
|
+
"AuroDatepickerUtilities | yearValueIsValid: Unable to parse year value integer",
|
|
918
|
+
);
|
|
894
919
|
}
|
|
895
920
|
|
|
896
921
|
// Guard clause: ensure year is within the valid range
|
|
@@ -906,7 +931,7 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
906
931
|
const checks = [
|
|
907
932
|
monthValueIsValid(dateParts.month),
|
|
908
933
|
dayValueIsValid(dateParts.day),
|
|
909
|
-
yearIsValid(dateParts.year)
|
|
934
|
+
yearIsValid(dateParts.year),
|
|
910
935
|
];
|
|
911
936
|
|
|
912
937
|
// If any of the checks failed, the date format does not match and the result is invalid
|
|
@@ -1679,7 +1704,7 @@ class AuroHelpText extends i$2 {
|
|
|
1679
1704
|
}
|
|
1680
1705
|
}
|
|
1681
1706
|
|
|
1682
|
-
var formkitVersion = '
|
|
1707
|
+
var formkitVersion = '202602201901';
|
|
1683
1708
|
|
|
1684
1709
|
// Copyright (c) 2026 Alaska Airlines. All right reserved. Licensed under the Apache-2.0 license
|
|
1685
1710
|
// See LICENSE in the project root for license information.
|