@aurodesignsystem-dev/auro-formkit 0.0.0-pr1489.1 → 0.0.0-pr1489.11
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/customize.min.js +249 -125
- package/components/checkbox/demo/getting-started.min.js +249 -125
- package/components/checkbox/demo/index.min.js +249 -125
- package/components/checkbox/demo/styles.min.css +1 -1
- package/components/checkbox/dist/index.js +249 -125
- package/components/checkbox/dist/registered.js +249 -125
- package/components/combobox/demo/customize.min.js +523 -259
- package/components/combobox/demo/getting-started.min.js +523 -259
- package/components/combobox/demo/index.min.js +523 -259
- package/components/combobox/demo/styles.min.css +1 -1
- package/components/combobox/dist/index.js +523 -259
- package/components/combobox/dist/registered.js +523 -259
- package/components/counter/demo/customize.min.js +271 -131
- package/components/counter/demo/index.min.js +271 -131
- package/components/counter/demo/styles.min.css +1 -1
- package/components/counter/dist/index.js +488 -137
- package/components/counter/dist/registered.js +249 -125
- package/components/datepicker/demo/accessibility.md +12 -9
- package/components/datepicker/demo/api.md +1 -1
- package/components/datepicker/demo/customize.md +4 -0
- package/components/datepicker/demo/customize.min.js +1638 -654
- package/components/datepicker/demo/index.md +35 -5
- package/components/datepicker/demo/index.min.js +1654 -659
- package/components/datepicker/demo/keyboard-behavior.md +16 -16
- package/components/datepicker/demo/styles.min.css +1 -1
- package/components/datepicker/demo/voiceover.md +5 -3
- package/components/datepicker/demo/why-datepicker.md +2 -2
- package/components/datepicker/dist/index.js +1642 -658
- package/components/datepicker/dist/registered.js +1642 -658
- package/components/datepicker/dist/src/auro-calendar-cell.d.ts +52 -17
- package/components/datepicker/dist/src/auro-calendar-month.d.ts +12 -4
- package/components/datepicker/dist/src/auro-calendar.d.ts +161 -8
- package/components/datepicker/dist/src/auro-datepicker.d.ts +77 -79
- package/components/dropdown/demo/customize.min.js +22 -6
- package/components/dropdown/demo/getting-started.min.js +22 -6
- package/components/dropdown/demo/index.min.js +22 -6
- package/components/dropdown/demo/styles.min.css +1 -1
- package/components/dropdown/dist/auro-dropdown.d.ts +3 -2
- package/components/dropdown/dist/index.js +22 -6
- package/components/dropdown/dist/registered.js +22 -6
- package/components/form/demo/customize.min.js +3731 -1831
- package/components/form/demo/getting-started.min.js +3731 -1831
- package/components/form/demo/index.min.js +3731 -1831
- package/components/form/demo/registerDemoDeps.min.js +3727 -1827
- package/components/form/demo/styles.min.css +1 -1
- package/components/input/demo/customize.min.js +249 -125
- package/components/input/demo/getting-started.min.js +249 -125
- package/components/input/demo/index.min.js +249 -125
- package/components/input/demo/styles.min.css +1 -1
- package/components/input/dist/index.js +249 -125
- package/components/input/dist/registered.js +249 -125
- package/components/menu/demo/styles.min.css +1 -1
- package/components/radio/demo/customize.min.js +249 -125
- package/components/radio/demo/getting-started.min.js +249 -125
- package/components/radio/demo/index.min.js +249 -125
- package/components/radio/demo/styles.min.css +1 -1
- package/components/radio/dist/index.js +249 -125
- package/components/radio/dist/registered.js +249 -125
- package/components/select/demo/customize.min.js +271 -131
- package/components/select/demo/getting-started.min.js +271 -131
- package/components/select/demo/index.min.js +271 -131
- package/components/select/demo/styles.min.css +1 -1
- package/components/select/dist/index.js +271 -131
- package/components/select/dist/registered.js +271 -131
- package/custom-elements.json +836 -514
- package/package.json +8 -8
|
@@ -539,109 +539,236 @@ 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
|
-
|
|
542
|
+
/**
|
|
543
|
+
* @description Splits a date string into its parts according to the provided format. Does NOT validate that the result is a real calendar date — use `parseDate` when validation is required.
|
|
544
|
+
* @param {string} dateStr - Date string to parse.
|
|
545
|
+
* @param {string} format - Date format to parse.
|
|
546
|
+
* @returns {{ month?: string, day?: string, year?: string }|undefined}
|
|
547
|
+
*/
|
|
548
|
+
function getDateParts(dateStr, format) {
|
|
549
|
+
if (!dateStr) {
|
|
550
|
+
return undefined;
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
const formatSeparatorMatch = format.match(/[/.-]/);
|
|
554
|
+
let valueParts;
|
|
555
|
+
let formatParts;
|
|
556
|
+
|
|
557
|
+
if (formatSeparatorMatch) {
|
|
558
|
+
const separator = formatSeparatorMatch[0];
|
|
559
|
+
valueParts = dateStr.split(separator);
|
|
560
|
+
formatParts = format.split(separator);
|
|
561
|
+
} else {
|
|
562
|
+
if (dateStr.match(/[/.-]/)) {
|
|
563
|
+
throw new Error(
|
|
564
|
+
"AuroDatepickerUtilities | parseDate: Date string has no separators",
|
|
565
|
+
);
|
|
566
|
+
}
|
|
543
567
|
|
|
544
|
-
|
|
568
|
+
if (dateStr.length !== format.length) {
|
|
569
|
+
throw new Error(
|
|
570
|
+
"AuroDatepickerUtilities | parseDate: Date string and format length do not match",
|
|
571
|
+
);
|
|
572
|
+
}
|
|
545
573
|
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
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') => {
|
|
574
|
+
valueParts = [dateStr];
|
|
575
|
+
formatParts = [format];
|
|
576
|
+
}
|
|
553
577
|
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
578
|
+
if (valueParts.length !== formatParts.length) {
|
|
579
|
+
throw new Error(
|
|
580
|
+
`AuroDatepickerUtilities | parseDate: Date string and format do not match : ${dateStr} vs ${format}`,
|
|
581
|
+
);
|
|
582
|
+
}
|
|
558
583
|
|
|
559
|
-
|
|
560
|
-
|
|
584
|
+
const result = formatParts.reduce((acc, part, index) => {
|
|
585
|
+
const value = valueParts[index];
|
|
561
586
|
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
587
|
+
if (/m/iu.test(part) && part.length === value.length) {
|
|
588
|
+
acc.month = value;
|
|
589
|
+
} else if (/d/iu.test(part) && part.length === value.length) {
|
|
590
|
+
acc.day = value;
|
|
591
|
+
} else if (/y/iu.test(part) && part.length === value.length) {
|
|
592
|
+
acc.year = value;
|
|
593
|
+
}
|
|
565
594
|
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
throw new Error('AuroDatepickerUtilities | parseDate: Date string and format length do not match');
|
|
569
|
-
}
|
|
595
|
+
return acc;
|
|
596
|
+
}, {});
|
|
570
597
|
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
598
|
+
if (!result.month && !result.day && !result.year) {
|
|
599
|
+
throw new Error(
|
|
600
|
+
"AuroDatepickerUtilities | parseDate: Unable to parse date string",
|
|
601
|
+
);
|
|
602
|
+
}
|
|
574
603
|
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
} else if ((/d/iu).test(part)) {
|
|
578
|
-
acc.day = value;
|
|
579
|
-
} else if ((/y/iu).test(part)) {
|
|
580
|
-
acc.year = value;
|
|
581
|
-
}
|
|
604
|
+
return result;
|
|
605
|
+
}
|
|
582
606
|
|
|
583
|
-
|
|
584
|
-
|
|
607
|
+
function isCalendarDate(year, month, day) {
|
|
608
|
+
let yearNumber = Number(year);
|
|
609
|
+
const monthNumber = Number(month);
|
|
610
|
+
const dayNumber = Number(day);
|
|
585
611
|
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
612
|
+
if (
|
|
613
|
+
!Number.isInteger(yearNumber) ||
|
|
614
|
+
!Number.isInteger(monthNumber) ||
|
|
615
|
+
!Number.isInteger(dayNumber)
|
|
616
|
+
) {
|
|
617
|
+
return false;
|
|
618
|
+
}
|
|
590
619
|
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
620
|
+
// Handle 2-digit years by converting them to 4-digit years based on a cutoff. This allows for parsing of 2-digit year formats while still validating the resulting date.
|
|
621
|
+
if (yearNumber < 100 && yearNumber >= 50) {
|
|
622
|
+
yearNumber += 1900;
|
|
623
|
+
} else if (yearNumber < 50) {
|
|
624
|
+
yearNumber += 2000;
|
|
625
|
+
}
|
|
594
626
|
|
|
595
|
-
|
|
596
|
-
|
|
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
|
-
});
|
|
627
|
+
const stringified = `${String(yearNumber).padStart(4, "0")}-${String(monthNumber).padStart(2, "0")}-${String(dayNumber).padStart(2, "0")}`;
|
|
628
|
+
const date = new Date(stringified.replace(/[.-]/g, "/"));
|
|
606
629
|
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
* @returns {Boolean}
|
|
612
|
-
*/
|
|
613
|
-
this.toNorthAmericanFormat = (dateStr, format) => {
|
|
630
|
+
return (
|
|
631
|
+
!Number.isNaN(date.getTime()) && toISOFormatString(date) === stringified
|
|
632
|
+
);
|
|
633
|
+
}
|
|
614
634
|
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
635
|
+
/**
|
|
636
|
+
* @description Parses a date string into its components and validates that the result is a real calendar date. Use `getDateParts` instead when raw splitting without validation is needed (e.g. for in-progress input).
|
|
637
|
+
*
|
|
638
|
+
* Partial formats are supported: components absent from `format` default to `year → "0"`,
|
|
639
|
+
* `month → "01"`, `day → "01"` for calendar validation only. The returned object contains
|
|
640
|
+
* only the fields actually present in the format string — missing fields are never injected.
|
|
641
|
+
* @param {string} dateStr - Date string to parse.
|
|
642
|
+
* @param {string} format - Date format to parse.
|
|
643
|
+
* @returns {{ month?: string, day?: string, year?: string }|undefined}
|
|
644
|
+
* @throws {Error} Throws when the parsed result does not represent a valid calendar date.
|
|
645
|
+
*/
|
|
646
|
+
function parseDate(dateStr, format = "mm/dd/yyyy") {
|
|
647
|
+
if (!dateStr || !format) {
|
|
648
|
+
return undefined;
|
|
649
|
+
}
|
|
650
|
+
const result = getDateParts(dateStr.trim(), format);
|
|
651
|
+
|
|
652
|
+
if (!result) {
|
|
653
|
+
return undefined;
|
|
654
|
+
}
|
|
618
655
|
|
|
619
|
-
|
|
656
|
+
const lowerFormat = format.toLowerCase();
|
|
657
|
+
const year = lowerFormat.includes("yy") ? result.year : "0";
|
|
658
|
+
const month = lowerFormat.includes("mm") ? result.month : "01";
|
|
659
|
+
const day = lowerFormat.includes("dd") ? result.day : "01";
|
|
620
660
|
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
661
|
+
if (isCalendarDate(year, month, day)) {
|
|
662
|
+
return result;
|
|
663
|
+
}
|
|
624
664
|
|
|
625
|
-
|
|
665
|
+
throw new Error(
|
|
666
|
+
`AuroDatepickerUtilities | parseDate: Date string is not a valid date ${JSON.stringify(result)} with format ${format}`,
|
|
667
|
+
);
|
|
668
|
+
}
|
|
626
669
|
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
670
|
+
/**
|
|
671
|
+
* Convert a date object to string format.
|
|
672
|
+
* @param {Object} date - Date to convert to string.
|
|
673
|
+
* @param {String} locale - Optional locale to use for the date string. Defaults to user's locale.
|
|
674
|
+
* @returns {String} Returns the date as a string.
|
|
675
|
+
*/
|
|
676
|
+
function getDateAsString(date, locale = undefined) {
|
|
677
|
+
return date.toLocaleDateString(locale, {
|
|
678
|
+
year: "numeric",
|
|
679
|
+
month: "2-digit",
|
|
680
|
+
day: "2-digit",
|
|
681
|
+
});
|
|
682
|
+
}
|
|
631
683
|
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
684
|
+
/**
|
|
685
|
+
* Converts a date string to a North American date format.
|
|
686
|
+
* @param {String} dateStr - Date to validate.
|
|
687
|
+
* @param {String} format - Date format to validate against.
|
|
688
|
+
* @returns {String}
|
|
689
|
+
*/
|
|
690
|
+
function toNorthAmericanFormat$1(dateStr, format) {
|
|
691
|
+
if (format === "mm/dd/yyyy") {
|
|
692
|
+
return dateStr;
|
|
693
|
+
}
|
|
635
694
|
|
|
636
|
-
|
|
637
|
-
dateParts.push(year);
|
|
638
|
-
}
|
|
695
|
+
const parsedDate = parseDate(dateStr, format);
|
|
639
696
|
|
|
640
|
-
|
|
641
|
-
|
|
697
|
+
if (!parsedDate) {
|
|
698
|
+
throw new Error(
|
|
699
|
+
"AuroDatepickerUtilities | toNorthAmericanFormat: Unable to parse date string",
|
|
700
|
+
);
|
|
642
701
|
}
|
|
702
|
+
|
|
703
|
+
const { month, day, year } = parsedDate;
|
|
704
|
+
|
|
705
|
+
return [month, day, year].filter(Boolean).join("/");
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
/**
|
|
709
|
+
* Validates that a date string matches the provided format and represents a real calendar date.
|
|
710
|
+
*
|
|
711
|
+
* @param {string} dateStr - Date string to validate.
|
|
712
|
+
* @param {string} [format="yyyy-mm-dd"] - Format of the date string.
|
|
713
|
+
* @returns {boolean} True when the date string is valid for the provided format, otherwise false.
|
|
714
|
+
*/
|
|
715
|
+
function isValidDate(dateStr, format = "yyyy-mm-dd") {
|
|
716
|
+
try {
|
|
717
|
+
if (typeof dateStr !== "string" || !dateStr || format?.length < 8) {
|
|
718
|
+
return false;
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
if (parseDate(dateStr, format)) {
|
|
722
|
+
return true;
|
|
723
|
+
}
|
|
724
|
+
} catch (error) {
|
|
725
|
+
return false;
|
|
726
|
+
}
|
|
727
|
+
return false;
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
/**
|
|
731
|
+
* Converts a JavaScript Date instance to a simple ISO-like date string. This returns only the calendar date portion without any time or timezone information.
|
|
732
|
+
*
|
|
733
|
+
* @param {Date} date - Date instance to convert to an ISO-like string.
|
|
734
|
+
* @returns {string} A string in the format "yyyy-mm-dd" representing the provided date.
|
|
735
|
+
* @throws {Error} Throws an error when the input is not a valid Date instance.
|
|
736
|
+
*/
|
|
737
|
+
function toISOFormatString(date) {
|
|
738
|
+
if (!(date instanceof Date) || Number.isNaN(date.getTime())) {
|
|
739
|
+
throw new Error(
|
|
740
|
+
"AuroDatepickerUtilities | toISOFormatString: Input must be a valid Date instance",
|
|
741
|
+
);
|
|
742
|
+
}
|
|
743
|
+
return `${String(date.getFullYear()).padStart(4, "0")}-${String(date.getMonth() + 1).padStart(2, "0")}-${String(date.getDate()).padStart(2, "0")}`;
|
|
643
744
|
}
|
|
644
|
-
|
|
745
|
+
|
|
746
|
+
/**
|
|
747
|
+
* Converts a date string into a JavaScript Date instance. This method supports ISO formatted strings and other formats that can be parsed by the formatter.
|
|
748
|
+
*
|
|
749
|
+
* @param {String} dateStr - Date string to convert into a Date object.
|
|
750
|
+
* @param {String} format - Date format used to parse the string when it is not in ISO format.
|
|
751
|
+
* @returns {Date|null} Returns a Date instance for valid input or null for non-string input.
|
|
752
|
+
* @throws {Error} Throws when parsing fails for non-ISO string input.
|
|
753
|
+
*/
|
|
754
|
+
function stringToDateInstance(dateStr, format = "yyyy-mm-dd") {
|
|
755
|
+
if (typeof dateStr !== "string") {
|
|
756
|
+
return null;
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
const { month, day, year } = parseDate(dateStr, format);
|
|
760
|
+
return new Date(`${year}/${month}/${day}`);
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
const dateFormatter = {
|
|
764
|
+
parseDate,
|
|
765
|
+
getDateParts,
|
|
766
|
+
getDateAsString,
|
|
767
|
+
toNorthAmericanFormat: toNorthAmericanFormat$1,
|
|
768
|
+
isValidDate,
|
|
769
|
+
toISOFormatString,
|
|
770
|
+
stringToDateInstance,
|
|
771
|
+
};
|
|
645
772
|
|
|
646
773
|
// filepath: dateConstraints.mjs
|
|
647
774
|
const DATE_UTIL_CONSTRAINTS = {
|
|
@@ -713,12 +840,11 @@ class AuroDateUtilitiesBase {
|
|
|
713
840
|
/* eslint-disable no-magic-numbers */
|
|
714
841
|
|
|
715
842
|
class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
716
|
-
|
|
717
843
|
/**
|
|
718
844
|
* Returns the current century.
|
|
719
845
|
* @returns {String} The current century.
|
|
720
846
|
*/
|
|
721
|
-
getCentury
|
|
847
|
+
getCentury() {
|
|
722
848
|
return String(new Date().getFullYear()).slice(0, 2);
|
|
723
849
|
}
|
|
724
850
|
|
|
@@ -727,14 +853,12 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
727
853
|
* @param {String} year - The year to convert to four digits.
|
|
728
854
|
* @returns {String} The four digit year.
|
|
729
855
|
*/
|
|
730
|
-
getFourDigitYear
|
|
731
|
-
|
|
856
|
+
getFourDigitYear(year) {
|
|
732
857
|
const strYear = String(year).trim();
|
|
733
858
|
return strYear.length <= 2 ? this.getCentury() + strYear : strYear;
|
|
734
859
|
}
|
|
735
860
|
|
|
736
861
|
constructor() {
|
|
737
|
-
|
|
738
862
|
super();
|
|
739
863
|
|
|
740
864
|
/**
|
|
@@ -743,7 +867,8 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
743
867
|
* @param {Object} date2 - Second date to compare.
|
|
744
868
|
* @returns {Boolean} Returns true if the dates match.
|
|
745
869
|
*/
|
|
746
|
-
this.datesMatch = (date1, date2) =>
|
|
870
|
+
this.datesMatch = (date1, date2) =>
|
|
871
|
+
new Date(date1).getTime() === new Date(date2).getTime();
|
|
747
872
|
|
|
748
873
|
/**
|
|
749
874
|
* Returns true if value passed in is a valid date.
|
|
@@ -752,53 +877,41 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
752
877
|
* @returns {Boolean}
|
|
753
878
|
*/
|
|
754
879
|
this.validDateStr = (date, format) => {
|
|
755
|
-
|
|
756
880
|
// The length we expect the date string to be
|
|
757
|
-
const dateStrLength = format
|
|
881
|
+
const dateStrLength = format?.length || 0;
|
|
758
882
|
|
|
759
883
|
// Guard Clause: Date and format are defined
|
|
760
884
|
if (typeof date === "undefined" || typeof format === "undefined") {
|
|
761
|
-
throw new Error(
|
|
885
|
+
throw new Error(
|
|
886
|
+
"AuroDatepickerUtilities | validateDateStr: Date and format are required",
|
|
887
|
+
);
|
|
762
888
|
}
|
|
763
889
|
|
|
764
890
|
// Guard Clause: Date should be of type string
|
|
765
891
|
if (typeof date !== "string") {
|
|
766
|
-
throw new Error(
|
|
892
|
+
throw new Error(
|
|
893
|
+
"AuroDatepickerUtilities | validateDateStr: Date must be a string",
|
|
894
|
+
);
|
|
767
895
|
}
|
|
768
896
|
|
|
769
897
|
// Guard Clause: Format should be of type string
|
|
770
898
|
if (typeof format !== "string") {
|
|
771
|
-
throw new Error(
|
|
899
|
+
throw new Error(
|
|
900
|
+
"AuroDatepickerUtilities | validateDateStr: Format must be a string",
|
|
901
|
+
);
|
|
772
902
|
}
|
|
773
903
|
|
|
774
904
|
// Guard Clause: Length is what we expect it to be
|
|
775
905
|
if (date.length !== dateStrLength) {
|
|
776
906
|
return false;
|
|
777
907
|
}
|
|
778
|
-
// Get a formatted date string and parse it
|
|
779
|
-
const dateParts = dateFormatter.parseDate(date, format);
|
|
780
908
|
|
|
781
|
-
//
|
|
782
|
-
|
|
909
|
+
// Get a formatted date string and parse and validate it
|
|
910
|
+
try {
|
|
911
|
+
return Boolean(dateFormatter.parseDate(date, format));
|
|
912
|
+
} catch (error) {
|
|
783
913
|
return false;
|
|
784
914
|
}
|
|
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
915
|
};
|
|
803
916
|
|
|
804
917
|
/**
|
|
@@ -808,10 +921,11 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
808
921
|
* @returns {boolean}
|
|
809
922
|
*/
|
|
810
923
|
this.dateAndFormatMatch = (value, format) => {
|
|
811
|
-
|
|
812
924
|
// Ensure we have both values we need to do the comparison
|
|
813
925
|
if (!value || !format) {
|
|
814
|
-
throw new Error(
|
|
926
|
+
throw new Error(
|
|
927
|
+
"AuroFormValidation | dateFormatMatch: value and format are required",
|
|
928
|
+
);
|
|
815
929
|
}
|
|
816
930
|
|
|
817
931
|
// If the lengths are different, they cannot match
|
|
@@ -820,11 +934,10 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
820
934
|
}
|
|
821
935
|
|
|
822
936
|
// Get the parts of the date
|
|
823
|
-
const dateParts = dateFormatter.
|
|
937
|
+
const dateParts = dateFormatter.getDateParts(value, format);
|
|
824
938
|
|
|
825
939
|
// Validator for day
|
|
826
940
|
const dayValueIsValid = (day) => {
|
|
827
|
-
|
|
828
941
|
// Guard clause: if there is no day in the dateParts, we can ignore this check.
|
|
829
942
|
if (!dateParts.day) {
|
|
830
943
|
return true;
|
|
@@ -840,7 +953,9 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
840
953
|
|
|
841
954
|
// Guard clause: ensure day is a valid integer
|
|
842
955
|
if (Number.isNaN(numDay)) {
|
|
843
|
-
throw new Error(
|
|
956
|
+
throw new Error(
|
|
957
|
+
"AuroDatepickerUtilities | dayValueIsValid: Unable to parse day value integer",
|
|
958
|
+
);
|
|
844
959
|
}
|
|
845
960
|
|
|
846
961
|
// Guard clause: ensure day is within the valid range
|
|
@@ -854,6 +969,10 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
854
969
|
|
|
855
970
|
// Validator for month
|
|
856
971
|
const monthValueIsValid = (month) => {
|
|
972
|
+
// Guard clause: if there is no month in the dateParts, we can ignore this check.
|
|
973
|
+
if (!dateParts.month) {
|
|
974
|
+
return true;
|
|
975
|
+
}
|
|
857
976
|
|
|
858
977
|
// Guard clause: ensure month exists.
|
|
859
978
|
if (!month) {
|
|
@@ -865,7 +984,9 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
865
984
|
|
|
866
985
|
// Guard clause: ensure month is a valid integer
|
|
867
986
|
if (Number.isNaN(numMonth)) {
|
|
868
|
-
throw new Error(
|
|
987
|
+
throw new Error(
|
|
988
|
+
"AuroDatepickerUtilities | monthValueIsValid: Unable to parse month value integer",
|
|
989
|
+
);
|
|
869
990
|
}
|
|
870
991
|
|
|
871
992
|
// Guard clause: ensure month is within the valid range
|
|
@@ -879,6 +1000,10 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
879
1000
|
|
|
880
1001
|
// Validator for year
|
|
881
1002
|
const yearIsValid = (_year) => {
|
|
1003
|
+
// Guard clause: if there is no year in the dateParts, we can ignore this check.
|
|
1004
|
+
if (!dateParts.year) {
|
|
1005
|
+
return true;
|
|
1006
|
+
}
|
|
882
1007
|
|
|
883
1008
|
// Guard clause: ensure year exists.
|
|
884
1009
|
if (!_year) {
|
|
@@ -893,7 +1018,9 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
893
1018
|
|
|
894
1019
|
// Guard clause: ensure year is a valid integer
|
|
895
1020
|
if (Number.isNaN(numYear)) {
|
|
896
|
-
throw new Error(
|
|
1021
|
+
throw new Error(
|
|
1022
|
+
"AuroDatepickerUtilities | yearValueIsValid: Unable to parse year value integer",
|
|
1023
|
+
);
|
|
897
1024
|
}
|
|
898
1025
|
|
|
899
1026
|
// Guard clause: ensure year is within the valid range
|
|
@@ -909,7 +1036,7 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
909
1036
|
const checks = [
|
|
910
1037
|
monthValueIsValid(dateParts.month),
|
|
911
1038
|
dayValueIsValid(dateParts.day),
|
|
912
|
-
yearIsValid(dateParts.year)
|
|
1039
|
+
yearIsValid(dateParts.year),
|
|
913
1040
|
];
|
|
914
1041
|
|
|
915
1042
|
// If any of the checks failed, the date format does not match and the result is invalid
|
|
@@ -943,10 +1070,7 @@ const {
|
|
|
943
1070
|
} = dateUtilities;
|
|
944
1071
|
|
|
945
1072
|
const {
|
|
946
|
-
toNorthAmericanFormat
|
|
947
|
-
parseDate,
|
|
948
|
-
getDateAsString
|
|
949
|
-
} = dateFormatter;
|
|
1073
|
+
toNorthAmericanFormat} = dateFormatter;
|
|
950
1074
|
|
|
951
1075
|
// Copyright (c) Alaska Air. All right reserved. Licensed under the Apache-2.0 license
|
|
952
1076
|
// See LICENSE in the project root for license information.
|
|
@@ -1682,7 +1806,7 @@ class AuroHelpText extends i$2 {
|
|
|
1682
1806
|
}
|
|
1683
1807
|
}
|
|
1684
1808
|
|
|
1685
|
-
var formkitVersion = '
|
|
1809
|
+
var formkitVersion = '202606031320';
|
|
1686
1810
|
|
|
1687
1811
|
// Copyright (c) 2026 Alaska Airlines. All rights reserved. Licensed under the Apache-2.0 license
|
|
1688
1812
|
// See LICENSE in the project root for license information.
|