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