@aurodesignsystem-dev/auro-formkit 0.0.0-pr1489.4 → 0.0.0-pr1490.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.
- 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 +502 -254
- package/components/combobox/demo/getting-started.min.js +502 -254
- package/components/combobox/demo/index.min.js +502 -254
- package/components/combobox/demo/styles.min.css +1 -1
- package/components/combobox/dist/index.js +502 -254
- package/components/combobox/dist/registered.js +502 -254
- package/components/counter/demo/customize.min.js +250 -126
- package/components/counter/demo/index.min.js +250 -126
- package/components/counter/demo/styles.min.css +1 -1
- package/components/counter/dist/index.js +249 -125
- package/components/counter/dist/registered.js +249 -125
- package/components/datepicker/demo/accessibility.md +9 -6
- package/components/datepicker/demo/api.md +1 -1
- package/components/datepicker/demo/customize.min.js +1544 -527
- package/components/datepicker/demo/index.md +6 -4
- package/components/datepicker/demo/index.min.js +1560 -532
- package/components/datepicker/demo/keyboard-behavior.md +15 -15
- 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 +1536 -519
- package/components/datepicker/dist/registered.js +1536 -519
- package/components/datepicker/dist/src/auro-calendar-cell.d.ts +50 -15
- package/components/datepicker/dist/src/auro-calendar-month.d.ts +9 -0
- package/components/datepicker/dist/src/auro-calendar.d.ts +161 -8
- package/components/datepicker/dist/src/auro-datepicker.d.ts +5 -7
- package/components/dropdown/demo/customize.min.js +1 -1
- package/components/dropdown/demo/getting-started.min.js +1 -1
- package/components/dropdown/demo/index.min.js +1 -1
- package/components/dropdown/demo/styles.min.css +1 -1
- package/components/dropdown/dist/index.js +1 -1
- package/components/dropdown/dist/registered.js +1 -1
- package/components/form/demo/customize.min.js +3263 -1378
- package/components/form/demo/getting-started.min.js +3263 -1378
- package/components/form/demo/index.min.js +3263 -1378
- package/components/form/demo/registerDemoDeps.min.js +3263 -1378
- 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 +250 -126
- package/components/select/demo/getting-started.min.js +250 -126
- package/components/select/demo/index.min.js +250 -126
- package/components/select/demo/styles.min.css +1 -1
- package/components/select/dist/index.js +250 -126
- package/components/select/dist/registered.js +250 -126
- package/custom-elements.json +964 -637
- package/package.json +8 -8
|
@@ -492,109 +492,236 @@ class AuroCheckbox extends LitElement {
|
|
|
492
492
|
}
|
|
493
493
|
}
|
|
494
494
|
|
|
495
|
-
|
|
495
|
+
/**
|
|
496
|
+
* @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.
|
|
497
|
+
* @param {string} dateStr - Date string to parse.
|
|
498
|
+
* @param {string} format - Date format to parse.
|
|
499
|
+
* @returns {{ month?: string, day?: string, year?: string }|undefined}
|
|
500
|
+
*/
|
|
501
|
+
function getDateParts(dateStr, format) {
|
|
502
|
+
if (!dateStr) {
|
|
503
|
+
return undefined;
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
const formatSeparatorMatch = format.match(/[/.-]/);
|
|
507
|
+
let valueParts;
|
|
508
|
+
let formatParts;
|
|
509
|
+
|
|
510
|
+
if (formatSeparatorMatch) {
|
|
511
|
+
const separator = formatSeparatorMatch[0];
|
|
512
|
+
valueParts = dateStr.split(separator);
|
|
513
|
+
formatParts = format.split(separator);
|
|
514
|
+
} else {
|
|
515
|
+
if (dateStr.match(/[/.-]/)) {
|
|
516
|
+
throw new Error(
|
|
517
|
+
"AuroDatepickerUtilities | parseDate: Date string has no separators",
|
|
518
|
+
);
|
|
519
|
+
}
|
|
496
520
|
|
|
497
|
-
|
|
521
|
+
if (dateStr.length !== format.length) {
|
|
522
|
+
throw new Error(
|
|
523
|
+
"AuroDatepickerUtilities | parseDate: Date string and format length do not match",
|
|
524
|
+
);
|
|
525
|
+
}
|
|
498
526
|
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
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') => {
|
|
527
|
+
valueParts = [dateStr];
|
|
528
|
+
formatParts = [format];
|
|
529
|
+
}
|
|
506
530
|
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
531
|
+
if (valueParts.length !== formatParts.length) {
|
|
532
|
+
throw new Error(
|
|
533
|
+
`AuroDatepickerUtilities | parseDate: Date string and format do not match : ${dateStr} vs ${format}`,
|
|
534
|
+
);
|
|
535
|
+
}
|
|
511
536
|
|
|
512
|
-
|
|
513
|
-
|
|
537
|
+
const result = formatParts.reduce((acc, part, index) => {
|
|
538
|
+
const value = valueParts[index];
|
|
514
539
|
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
540
|
+
if (/m/iu.test(part) && part.length === value.length) {
|
|
541
|
+
acc.month = value;
|
|
542
|
+
} else if (/d/iu.test(part) && part.length === value.length) {
|
|
543
|
+
acc.day = value;
|
|
544
|
+
} else if (/y/iu.test(part) && part.length === value.length) {
|
|
545
|
+
acc.year = value;
|
|
546
|
+
}
|
|
518
547
|
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
throw new Error('AuroDatepickerUtilities | parseDate: Date string and format length do not match');
|
|
522
|
-
}
|
|
548
|
+
return acc;
|
|
549
|
+
}, {});
|
|
523
550
|
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
551
|
+
if (!result.month && !result.day && !result.year) {
|
|
552
|
+
throw new Error(
|
|
553
|
+
"AuroDatepickerUtilities | parseDate: Unable to parse date string",
|
|
554
|
+
);
|
|
555
|
+
}
|
|
527
556
|
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
} else if ((/d/iu).test(part)) {
|
|
531
|
-
acc.day = value;
|
|
532
|
-
} else if ((/y/iu).test(part)) {
|
|
533
|
-
acc.year = value;
|
|
534
|
-
}
|
|
557
|
+
return result;
|
|
558
|
+
}
|
|
535
559
|
|
|
536
|
-
|
|
537
|
-
|
|
560
|
+
function isCalendarDate(year, month, day) {
|
|
561
|
+
let yearNumber = Number(year);
|
|
562
|
+
const monthNumber = Number(month);
|
|
563
|
+
const dayNumber = Number(day);
|
|
538
564
|
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
565
|
+
if (
|
|
566
|
+
!Number.isInteger(yearNumber) ||
|
|
567
|
+
!Number.isInteger(monthNumber) ||
|
|
568
|
+
!Number.isInteger(dayNumber)
|
|
569
|
+
) {
|
|
570
|
+
return false;
|
|
571
|
+
}
|
|
543
572
|
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
573
|
+
// 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.
|
|
574
|
+
if (yearNumber < 100 && yearNumber >= 50) {
|
|
575
|
+
yearNumber += 1900;
|
|
576
|
+
} else if (yearNumber < 50) {
|
|
577
|
+
yearNumber += 2000;
|
|
578
|
+
}
|
|
547
579
|
|
|
548
|
-
|
|
549
|
-
|
|
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
|
-
});
|
|
580
|
+
const stringified = `${String(yearNumber).padStart(4, "0")}-${String(monthNumber).padStart(2, "0")}-${String(dayNumber).padStart(2, "0")}`;
|
|
581
|
+
const date = new Date(stringified.replace(/[.-]/g, "/"));
|
|
559
582
|
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
* @returns {Boolean}
|
|
565
|
-
*/
|
|
566
|
-
this.toNorthAmericanFormat = (dateStr, format) => {
|
|
583
|
+
return (
|
|
584
|
+
!Number.isNaN(date.getTime()) && toISOFormatString(date) === stringified
|
|
585
|
+
);
|
|
586
|
+
}
|
|
567
587
|
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
588
|
+
/**
|
|
589
|
+
* @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).
|
|
590
|
+
*
|
|
591
|
+
* Partial formats are supported: components absent from `format` default to `year → "0"`,
|
|
592
|
+
* `month → "01"`, `day → "01"` for calendar validation only. The returned object contains
|
|
593
|
+
* only the fields actually present in the format string — missing fields are never injected.
|
|
594
|
+
* @param {string} dateStr - Date string to parse.
|
|
595
|
+
* @param {string} format - Date format to parse.
|
|
596
|
+
* @returns {{ month?: string, day?: string, year?: string }|undefined}
|
|
597
|
+
* @throws {Error} Throws when the parsed result does not represent a valid calendar date.
|
|
598
|
+
*/
|
|
599
|
+
function parseDate(dateStr, format = "mm/dd/yyyy") {
|
|
600
|
+
if (!dateStr || !format) {
|
|
601
|
+
return undefined;
|
|
602
|
+
}
|
|
603
|
+
const result = getDateParts(dateStr.trim(), format);
|
|
604
|
+
|
|
605
|
+
if (!result) {
|
|
606
|
+
return undefined;
|
|
607
|
+
}
|
|
571
608
|
|
|
572
|
-
|
|
609
|
+
const lowerFormat = format.toLowerCase();
|
|
610
|
+
const year = lowerFormat.includes("yy") ? result.year : "0";
|
|
611
|
+
const month = lowerFormat.includes("mm") ? result.month : "01";
|
|
612
|
+
const day = lowerFormat.includes("dd") ? result.day : "01";
|
|
573
613
|
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
614
|
+
if (isCalendarDate(year, month, day)) {
|
|
615
|
+
return result;
|
|
616
|
+
}
|
|
577
617
|
|
|
578
|
-
|
|
618
|
+
throw new Error(
|
|
619
|
+
`AuroDatepickerUtilities | parseDate: Date string is not a valid date ${JSON.stringify(result)} with format ${format}`,
|
|
620
|
+
);
|
|
621
|
+
}
|
|
579
622
|
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
623
|
+
/**
|
|
624
|
+
* Convert a date object to string format.
|
|
625
|
+
* @param {Object} date - Date to convert to string.
|
|
626
|
+
* @param {String} locale - Optional locale to use for the date string. Defaults to user's locale.
|
|
627
|
+
* @returns {String} Returns the date as a string.
|
|
628
|
+
*/
|
|
629
|
+
function getDateAsString(date, locale = undefined) {
|
|
630
|
+
return date.toLocaleDateString(locale, {
|
|
631
|
+
year: "numeric",
|
|
632
|
+
month: "2-digit",
|
|
633
|
+
day: "2-digit",
|
|
634
|
+
});
|
|
635
|
+
}
|
|
584
636
|
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
637
|
+
/**
|
|
638
|
+
* Converts a date string to a North American date format.
|
|
639
|
+
* @param {String} dateStr - Date to validate.
|
|
640
|
+
* @param {String} format - Date format to validate against.
|
|
641
|
+
* @returns {String}
|
|
642
|
+
*/
|
|
643
|
+
function toNorthAmericanFormat$1(dateStr, format) {
|
|
644
|
+
if (format === "mm/dd/yyyy") {
|
|
645
|
+
return dateStr;
|
|
646
|
+
}
|
|
588
647
|
|
|
589
|
-
|
|
590
|
-
dateParts.push(year);
|
|
591
|
-
}
|
|
648
|
+
const parsedDate = parseDate(dateStr, format);
|
|
592
649
|
|
|
593
|
-
|
|
594
|
-
|
|
650
|
+
if (!parsedDate) {
|
|
651
|
+
throw new Error(
|
|
652
|
+
"AuroDatepickerUtilities | toNorthAmericanFormat: Unable to parse date string",
|
|
653
|
+
);
|
|
595
654
|
}
|
|
655
|
+
|
|
656
|
+
const { month, day, year } = parsedDate;
|
|
657
|
+
|
|
658
|
+
return [month, day, year].filter(Boolean).join("/");
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
/**
|
|
662
|
+
* Validates that a date string matches the provided format and represents a real calendar date.
|
|
663
|
+
*
|
|
664
|
+
* @param {string} dateStr - Date string to validate.
|
|
665
|
+
* @param {string} [format="yyyy-mm-dd"] - Format of the date string.
|
|
666
|
+
* @returns {boolean} True when the date string is valid for the provided format, otherwise false.
|
|
667
|
+
*/
|
|
668
|
+
function isValidDate(dateStr, format = "yyyy-mm-dd") {
|
|
669
|
+
try {
|
|
670
|
+
if (typeof dateStr !== "string" || !dateStr || format?.length < 8) {
|
|
671
|
+
return false;
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
if (parseDate(dateStr, format)) {
|
|
675
|
+
return true;
|
|
676
|
+
}
|
|
677
|
+
} catch (error) {
|
|
678
|
+
return false;
|
|
679
|
+
}
|
|
680
|
+
return false;
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
/**
|
|
684
|
+
* 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.
|
|
685
|
+
*
|
|
686
|
+
* @param {Date} date - Date instance to convert to an ISO-like string.
|
|
687
|
+
* @returns {string} A string in the format "yyyy-mm-dd" representing the provided date.
|
|
688
|
+
* @throws {Error} Throws an error when the input is not a valid Date instance.
|
|
689
|
+
*/
|
|
690
|
+
function toISOFormatString(date) {
|
|
691
|
+
if (!(date instanceof Date) || Number.isNaN(date.getTime())) {
|
|
692
|
+
throw new Error(
|
|
693
|
+
"AuroDatepickerUtilities | toISOFormatString: Input must be a valid Date instance",
|
|
694
|
+
);
|
|
695
|
+
}
|
|
696
|
+
return `${String(date.getFullYear()).padStart(4, "0")}-${String(date.getMonth() + 1).padStart(2, "0")}-${String(date.getDate()).padStart(2, "0")}`;
|
|
596
697
|
}
|
|
597
|
-
|
|
698
|
+
|
|
699
|
+
/**
|
|
700
|
+
* 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.
|
|
701
|
+
*
|
|
702
|
+
* @param {String} dateStr - Date string to convert into a Date object.
|
|
703
|
+
* @param {String} format - Date format used to parse the string when it is not in ISO format.
|
|
704
|
+
* @returns {Date|null} Returns a Date instance for valid input or null for non-string input.
|
|
705
|
+
* @throws {Error} Throws when parsing fails for non-ISO string input.
|
|
706
|
+
*/
|
|
707
|
+
function stringToDateInstance(dateStr, format = "yyyy-mm-dd") {
|
|
708
|
+
if (typeof dateStr !== "string") {
|
|
709
|
+
return null;
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
const { month, day, year } = parseDate(dateStr, format);
|
|
713
|
+
return new Date(`${year}/${month}/${day}`);
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
const dateFormatter = {
|
|
717
|
+
parseDate,
|
|
718
|
+
getDateParts,
|
|
719
|
+
getDateAsString,
|
|
720
|
+
toNorthAmericanFormat: toNorthAmericanFormat$1,
|
|
721
|
+
isValidDate,
|
|
722
|
+
toISOFormatString,
|
|
723
|
+
stringToDateInstance,
|
|
724
|
+
};
|
|
598
725
|
|
|
599
726
|
// filepath: dateConstraints.mjs
|
|
600
727
|
const DATE_UTIL_CONSTRAINTS = {
|
|
@@ -666,12 +793,11 @@ class AuroDateUtilitiesBase {
|
|
|
666
793
|
/* eslint-disable no-magic-numbers */
|
|
667
794
|
|
|
668
795
|
class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
669
|
-
|
|
670
796
|
/**
|
|
671
797
|
* Returns the current century.
|
|
672
798
|
* @returns {String} The current century.
|
|
673
799
|
*/
|
|
674
|
-
getCentury
|
|
800
|
+
getCentury() {
|
|
675
801
|
return String(new Date().getFullYear()).slice(0, 2);
|
|
676
802
|
}
|
|
677
803
|
|
|
@@ -680,14 +806,12 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
680
806
|
* @param {String} year - The year to convert to four digits.
|
|
681
807
|
* @returns {String} The four digit year.
|
|
682
808
|
*/
|
|
683
|
-
getFourDigitYear
|
|
684
|
-
|
|
809
|
+
getFourDigitYear(year) {
|
|
685
810
|
const strYear = String(year).trim();
|
|
686
811
|
return strYear.length <= 2 ? this.getCentury() + strYear : strYear;
|
|
687
812
|
}
|
|
688
813
|
|
|
689
814
|
constructor() {
|
|
690
|
-
|
|
691
815
|
super();
|
|
692
816
|
|
|
693
817
|
/**
|
|
@@ -696,7 +820,8 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
696
820
|
* @param {Object} date2 - Second date to compare.
|
|
697
821
|
* @returns {Boolean} Returns true if the dates match.
|
|
698
822
|
*/
|
|
699
|
-
this.datesMatch = (date1, date2) =>
|
|
823
|
+
this.datesMatch = (date1, date2) =>
|
|
824
|
+
new Date(date1).getTime() === new Date(date2).getTime();
|
|
700
825
|
|
|
701
826
|
/**
|
|
702
827
|
* Returns true if value passed in is a valid date.
|
|
@@ -705,53 +830,41 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
705
830
|
* @returns {Boolean}
|
|
706
831
|
*/
|
|
707
832
|
this.validDateStr = (date, format) => {
|
|
708
|
-
|
|
709
833
|
// The length we expect the date string to be
|
|
710
|
-
const dateStrLength = format
|
|
834
|
+
const dateStrLength = format?.length || 0;
|
|
711
835
|
|
|
712
836
|
// Guard Clause: Date and format are defined
|
|
713
837
|
if (typeof date === "undefined" || typeof format === "undefined") {
|
|
714
|
-
throw new Error(
|
|
838
|
+
throw new Error(
|
|
839
|
+
"AuroDatepickerUtilities | validateDateStr: Date and format are required",
|
|
840
|
+
);
|
|
715
841
|
}
|
|
716
842
|
|
|
717
843
|
// Guard Clause: Date should be of type string
|
|
718
844
|
if (typeof date !== "string") {
|
|
719
|
-
throw new Error(
|
|
845
|
+
throw new Error(
|
|
846
|
+
"AuroDatepickerUtilities | validateDateStr: Date must be a string",
|
|
847
|
+
);
|
|
720
848
|
}
|
|
721
849
|
|
|
722
850
|
// Guard Clause: Format should be of type string
|
|
723
851
|
if (typeof format !== "string") {
|
|
724
|
-
throw new Error(
|
|
852
|
+
throw new Error(
|
|
853
|
+
"AuroDatepickerUtilities | validateDateStr: Format must be a string",
|
|
854
|
+
);
|
|
725
855
|
}
|
|
726
856
|
|
|
727
857
|
// Guard Clause: Length is what we expect it to be
|
|
728
858
|
if (date.length !== dateStrLength) {
|
|
729
859
|
return false;
|
|
730
860
|
}
|
|
731
|
-
// Get a formatted date string and parse it
|
|
732
|
-
const dateParts = dateFormatter.parseDate(date, format);
|
|
733
861
|
|
|
734
|
-
//
|
|
735
|
-
|
|
862
|
+
// Get a formatted date string and parse and validate it
|
|
863
|
+
try {
|
|
864
|
+
return Boolean(dateFormatter.parseDate(date, format));
|
|
865
|
+
} catch (error) {
|
|
736
866
|
return false;
|
|
737
867
|
}
|
|
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
868
|
};
|
|
756
869
|
|
|
757
870
|
/**
|
|
@@ -761,10 +874,11 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
761
874
|
* @returns {boolean}
|
|
762
875
|
*/
|
|
763
876
|
this.dateAndFormatMatch = (value, format) => {
|
|
764
|
-
|
|
765
877
|
// Ensure we have both values we need to do the comparison
|
|
766
878
|
if (!value || !format) {
|
|
767
|
-
throw new Error(
|
|
879
|
+
throw new Error(
|
|
880
|
+
"AuroFormValidation | dateFormatMatch: value and format are required",
|
|
881
|
+
);
|
|
768
882
|
}
|
|
769
883
|
|
|
770
884
|
// If the lengths are different, they cannot match
|
|
@@ -773,11 +887,10 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
773
887
|
}
|
|
774
888
|
|
|
775
889
|
// Get the parts of the date
|
|
776
|
-
const dateParts = dateFormatter.
|
|
890
|
+
const dateParts = dateFormatter.getDateParts(value, format);
|
|
777
891
|
|
|
778
892
|
// Validator for day
|
|
779
893
|
const dayValueIsValid = (day) => {
|
|
780
|
-
|
|
781
894
|
// Guard clause: if there is no day in the dateParts, we can ignore this check.
|
|
782
895
|
if (!dateParts.day) {
|
|
783
896
|
return true;
|
|
@@ -793,7 +906,9 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
793
906
|
|
|
794
907
|
// Guard clause: ensure day is a valid integer
|
|
795
908
|
if (Number.isNaN(numDay)) {
|
|
796
|
-
throw new Error(
|
|
909
|
+
throw new Error(
|
|
910
|
+
"AuroDatepickerUtilities | dayValueIsValid: Unable to parse day value integer",
|
|
911
|
+
);
|
|
797
912
|
}
|
|
798
913
|
|
|
799
914
|
// Guard clause: ensure day is within the valid range
|
|
@@ -807,6 +922,10 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
807
922
|
|
|
808
923
|
// Validator for month
|
|
809
924
|
const monthValueIsValid = (month) => {
|
|
925
|
+
// Guard clause: if there is no month in the dateParts, we can ignore this check.
|
|
926
|
+
if (!dateParts.month) {
|
|
927
|
+
return true;
|
|
928
|
+
}
|
|
810
929
|
|
|
811
930
|
// Guard clause: ensure month exists.
|
|
812
931
|
if (!month) {
|
|
@@ -818,7 +937,9 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
818
937
|
|
|
819
938
|
// Guard clause: ensure month is a valid integer
|
|
820
939
|
if (Number.isNaN(numMonth)) {
|
|
821
|
-
throw new Error(
|
|
940
|
+
throw new Error(
|
|
941
|
+
"AuroDatepickerUtilities | monthValueIsValid: Unable to parse month value integer",
|
|
942
|
+
);
|
|
822
943
|
}
|
|
823
944
|
|
|
824
945
|
// Guard clause: ensure month is within the valid range
|
|
@@ -832,6 +953,10 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
832
953
|
|
|
833
954
|
// Validator for year
|
|
834
955
|
const yearIsValid = (_year) => {
|
|
956
|
+
// Guard clause: if there is no year in the dateParts, we can ignore this check.
|
|
957
|
+
if (!dateParts.year) {
|
|
958
|
+
return true;
|
|
959
|
+
}
|
|
835
960
|
|
|
836
961
|
// Guard clause: ensure year exists.
|
|
837
962
|
if (!_year) {
|
|
@@ -846,7 +971,9 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
846
971
|
|
|
847
972
|
// Guard clause: ensure year is a valid integer
|
|
848
973
|
if (Number.isNaN(numYear)) {
|
|
849
|
-
throw new Error(
|
|
974
|
+
throw new Error(
|
|
975
|
+
"AuroDatepickerUtilities | yearValueIsValid: Unable to parse year value integer",
|
|
976
|
+
);
|
|
850
977
|
}
|
|
851
978
|
|
|
852
979
|
// Guard clause: ensure year is within the valid range
|
|
@@ -862,7 +989,7 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
862
989
|
const checks = [
|
|
863
990
|
monthValueIsValid(dateParts.month),
|
|
864
991
|
dayValueIsValid(dateParts.day),
|
|
865
|
-
yearIsValid(dateParts.year)
|
|
992
|
+
yearIsValid(dateParts.year),
|
|
866
993
|
];
|
|
867
994
|
|
|
868
995
|
// If any of the checks failed, the date format does not match and the result is invalid
|
|
@@ -896,10 +1023,7 @@ const {
|
|
|
896
1023
|
} = dateUtilities;
|
|
897
1024
|
|
|
898
1025
|
const {
|
|
899
|
-
toNorthAmericanFormat
|
|
900
|
-
parseDate,
|
|
901
|
-
getDateAsString
|
|
902
|
-
} = dateFormatter;
|
|
1026
|
+
toNorthAmericanFormat} = dateFormatter;
|
|
903
1027
|
|
|
904
1028
|
// Copyright (c) Alaska Air. All right reserved. Licensed under the Apache-2.0 license
|
|
905
1029
|
// See LICENSE in the project root for license information.
|
|
@@ -1635,7 +1759,7 @@ class AuroHelpText extends LitElement {
|
|
|
1635
1759
|
}
|
|
1636
1760
|
}
|
|
1637
1761
|
|
|
1638
|
-
var formkitVersion = '
|
|
1762
|
+
var formkitVersion = '202606012111';
|
|
1639
1763
|
|
|
1640
1764
|
// Copyright (c) 2026 Alaska Airlines. All rights reserved. Licensed under the Apache-2.0 license
|
|
1641
1765
|
// See LICENSE in the project root for license information.
|