@aurodesignsystem-dev/auro-formkit 0.0.0-pr1489.5 → 0.0.0-pr1489.7
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 -262
- package/components/combobox/demo/getting-started.min.js +523 -262
- package/components/combobox/demo/index.min.js +523 -262
- package/components/combobox/demo/styles.min.css +1 -1
- package/components/combobox/dist/index.js +523 -262
- package/components/combobox/dist/registered.js +523 -262
- package/components/counter/demo/customize.min.js +271 -134
- package/components/counter/demo/index.min.js +271 -134
- 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 +1636 -656
- package/components/datepicker/demo/index.md +31 -3
- package/components/datepicker/demo/index.min.js +1652 -661
- 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 +1640 -660
- package/components/datepicker/dist/registered.js +1640 -660
- 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 -9
- package/components/dropdown/demo/getting-started.min.js +22 -9
- package/components/dropdown/demo/index.min.js +22 -9
- 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 -9
- package/components/dropdown/dist/registered.js +22 -9
- package/components/form/demo/customize.min.js +3459 -1572
- package/components/form/demo/getting-started.min.js +3459 -1572
- package/components/form/demo/index.min.js +3459 -1572
- package/components/form/demo/registerDemoDeps.min.js +3459 -1572
- 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 -134
- package/components/select/demo/getting-started.min.js +271 -134
- package/components/select/demo/index.min.js +271 -134
- package/components/select/demo/styles.min.css +1 -1
- package/components/select/dist/index.js +271 -134
- package/components/select/dist/registered.js +271 -134
- package/custom-elements.json +500 -178
- package/package.json +8 -8
|
@@ -434,109 +434,236 @@ var styleCss$1 = css`:host{display:block;padding-bottom:var(--ds-size-150, 0.75r
|
|
|
434
434
|
|
|
435
435
|
var colorCss$1 = css`: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)}`;
|
|
436
436
|
|
|
437
|
-
|
|
437
|
+
/**
|
|
438
|
+
* @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.
|
|
439
|
+
* @param {string} dateStr - Date string to parse.
|
|
440
|
+
* @param {string} format - Date format to parse.
|
|
441
|
+
* @returns {{ month?: string, day?: string, year?: string }|undefined}
|
|
442
|
+
*/
|
|
443
|
+
function getDateParts(dateStr, format) {
|
|
444
|
+
if (!dateStr) {
|
|
445
|
+
return undefined;
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
const formatSeparatorMatch = format.match(/[/.-]/);
|
|
449
|
+
let valueParts;
|
|
450
|
+
let formatParts;
|
|
451
|
+
|
|
452
|
+
if (formatSeparatorMatch) {
|
|
453
|
+
const separator = formatSeparatorMatch[0];
|
|
454
|
+
valueParts = dateStr.split(separator);
|
|
455
|
+
formatParts = format.split(separator);
|
|
456
|
+
} else {
|
|
457
|
+
if (dateStr.match(/[/.-]/)) {
|
|
458
|
+
throw new Error(
|
|
459
|
+
"AuroDatepickerUtilities | parseDate: Date string has no separators",
|
|
460
|
+
);
|
|
461
|
+
}
|
|
438
462
|
|
|
439
|
-
|
|
463
|
+
if (dateStr.length !== format.length) {
|
|
464
|
+
throw new Error(
|
|
465
|
+
"AuroDatepickerUtilities | parseDate: Date string and format length do not match",
|
|
466
|
+
);
|
|
467
|
+
}
|
|
440
468
|
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
* @param {string} format - Date format to parse.
|
|
445
|
-
* @returns {Object<key["month" | "day" | "year"]: number>|undefined}
|
|
446
|
-
*/
|
|
447
|
-
this.parseDate = (dateStr, format = 'mm/dd/yyyy') => {
|
|
469
|
+
valueParts = [dateStr];
|
|
470
|
+
formatParts = [format];
|
|
471
|
+
}
|
|
448
472
|
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
473
|
+
if (valueParts.length !== formatParts.length) {
|
|
474
|
+
throw new Error(
|
|
475
|
+
`AuroDatepickerUtilities | parseDate: Date string and format do not match : ${dateStr} vs ${format}`,
|
|
476
|
+
);
|
|
477
|
+
}
|
|
453
478
|
|
|
454
|
-
|
|
455
|
-
|
|
479
|
+
const result = formatParts.reduce((acc, part, index) => {
|
|
480
|
+
const value = valueParts[index];
|
|
456
481
|
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
482
|
+
if (/m/iu.test(part) && part.length === value.length) {
|
|
483
|
+
acc.month = value;
|
|
484
|
+
} else if (/d/iu.test(part) && part.length === value.length) {
|
|
485
|
+
acc.day = value;
|
|
486
|
+
} else if (/y/iu.test(part) && part.length === value.length) {
|
|
487
|
+
acc.year = value;
|
|
488
|
+
}
|
|
460
489
|
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
throw new Error('AuroDatepickerUtilities | parseDate: Date string and format length do not match');
|
|
464
|
-
}
|
|
490
|
+
return acc;
|
|
491
|
+
}, {});
|
|
465
492
|
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
493
|
+
if (!result.month && !result.day && !result.year) {
|
|
494
|
+
throw new Error(
|
|
495
|
+
"AuroDatepickerUtilities | parseDate: Unable to parse date string",
|
|
496
|
+
);
|
|
497
|
+
}
|
|
469
498
|
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
} else if ((/d/iu).test(part)) {
|
|
473
|
-
acc.day = value;
|
|
474
|
-
} else if ((/y/iu).test(part)) {
|
|
475
|
-
acc.year = value;
|
|
476
|
-
}
|
|
499
|
+
return result;
|
|
500
|
+
}
|
|
477
501
|
|
|
478
|
-
|
|
479
|
-
|
|
502
|
+
function isCalendarDate(year, month, day) {
|
|
503
|
+
let yearNumber = Number(year);
|
|
504
|
+
const monthNumber = Number(month);
|
|
505
|
+
const dayNumber = Number(day);
|
|
480
506
|
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
507
|
+
if (
|
|
508
|
+
!Number.isInteger(yearNumber) ||
|
|
509
|
+
!Number.isInteger(monthNumber) ||
|
|
510
|
+
!Number.isInteger(dayNumber)
|
|
511
|
+
) {
|
|
512
|
+
return false;
|
|
513
|
+
}
|
|
485
514
|
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
515
|
+
// 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.
|
|
516
|
+
if (yearNumber < 100 && yearNumber >= 50) {
|
|
517
|
+
yearNumber += 1900;
|
|
518
|
+
} else if (yearNumber < 50) {
|
|
519
|
+
yearNumber += 2000;
|
|
520
|
+
}
|
|
489
521
|
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
* @param {Object} date - Date to convert to string.
|
|
493
|
-
* @param {String} locale - Optional locale to use for the date string. Defaults to user's locale.
|
|
494
|
-
* @returns {String} Returns the date as a string.
|
|
495
|
-
*/
|
|
496
|
-
this.getDateAsString = (date, locale = undefined) => date.toLocaleDateString(locale, {
|
|
497
|
-
year: "numeric",
|
|
498
|
-
month: "2-digit",
|
|
499
|
-
day: "2-digit",
|
|
500
|
-
});
|
|
522
|
+
const stringified = `${String(yearNumber).padStart(4, "0")}-${String(monthNumber).padStart(2, "0")}-${String(dayNumber).padStart(2, "0")}`;
|
|
523
|
+
const date = new Date(stringified.replace(/[.-]/g, "/"));
|
|
501
524
|
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
* @returns {Boolean}
|
|
507
|
-
*/
|
|
508
|
-
this.toNorthAmericanFormat = (dateStr, format) => {
|
|
525
|
+
return (
|
|
526
|
+
!Number.isNaN(date.getTime()) && toISOFormatString(date) === stringified
|
|
527
|
+
);
|
|
528
|
+
}
|
|
509
529
|
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
530
|
+
/**
|
|
531
|
+
* @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).
|
|
532
|
+
*
|
|
533
|
+
* Partial formats are supported: components absent from `format` default to `year → "0"`,
|
|
534
|
+
* `month → "01"`, `day → "01"` for calendar validation only. The returned object contains
|
|
535
|
+
* only the fields actually present in the format string — missing fields are never injected.
|
|
536
|
+
* @param {string} dateStr - Date string to parse.
|
|
537
|
+
* @param {string} format - Date format to parse.
|
|
538
|
+
* @returns {{ month?: string, day?: string, year?: string }|undefined}
|
|
539
|
+
* @throws {Error} Throws when the parsed result does not represent a valid calendar date.
|
|
540
|
+
*/
|
|
541
|
+
function parseDate(dateStr, format = "mm/dd/yyyy") {
|
|
542
|
+
if (!dateStr || !format) {
|
|
543
|
+
return undefined;
|
|
544
|
+
}
|
|
545
|
+
const result = getDateParts(dateStr.trim(), format);
|
|
546
|
+
|
|
547
|
+
if (!result) {
|
|
548
|
+
return undefined;
|
|
549
|
+
}
|
|
513
550
|
|
|
514
|
-
|
|
551
|
+
const lowerFormat = format.toLowerCase();
|
|
552
|
+
const year = lowerFormat.includes("yy") ? result.year : "0";
|
|
553
|
+
const month = lowerFormat.includes("mm") ? result.month : "01";
|
|
554
|
+
const day = lowerFormat.includes("dd") ? result.day : "01";
|
|
515
555
|
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
556
|
+
if (isCalendarDate(year, month, day)) {
|
|
557
|
+
return result;
|
|
558
|
+
}
|
|
519
559
|
|
|
520
|
-
|
|
560
|
+
throw new Error(
|
|
561
|
+
`AuroDatepickerUtilities | parseDate: Date string is not a valid date ${JSON.stringify(result)} with format ${format}`,
|
|
562
|
+
);
|
|
563
|
+
}
|
|
521
564
|
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
565
|
+
/**
|
|
566
|
+
* Convert a date object to string format.
|
|
567
|
+
* @param {Object} date - Date to convert to string.
|
|
568
|
+
* @param {String} locale - Optional locale to use for the date string. Defaults to user's locale.
|
|
569
|
+
* @returns {String} Returns the date as a string.
|
|
570
|
+
*/
|
|
571
|
+
function getDateAsString(date, locale = undefined) {
|
|
572
|
+
return date.toLocaleDateString(locale, {
|
|
573
|
+
year: "numeric",
|
|
574
|
+
month: "2-digit",
|
|
575
|
+
day: "2-digit",
|
|
576
|
+
});
|
|
577
|
+
}
|
|
526
578
|
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
579
|
+
/**
|
|
580
|
+
* Converts a date string to a North American date format.
|
|
581
|
+
* @param {String} dateStr - Date to validate.
|
|
582
|
+
* @param {String} format - Date format to validate against.
|
|
583
|
+
* @returns {String}
|
|
584
|
+
*/
|
|
585
|
+
function toNorthAmericanFormat$1(dateStr, format) {
|
|
586
|
+
if (format === "mm/dd/yyyy") {
|
|
587
|
+
return dateStr;
|
|
588
|
+
}
|
|
530
589
|
|
|
531
|
-
|
|
532
|
-
dateParts.push(year);
|
|
533
|
-
}
|
|
590
|
+
const parsedDate = parseDate(dateStr, format);
|
|
534
591
|
|
|
535
|
-
|
|
536
|
-
|
|
592
|
+
if (!parsedDate) {
|
|
593
|
+
throw new Error(
|
|
594
|
+
"AuroDatepickerUtilities | toNorthAmericanFormat: Unable to parse date string",
|
|
595
|
+
);
|
|
537
596
|
}
|
|
597
|
+
|
|
598
|
+
const { month, day, year } = parsedDate;
|
|
599
|
+
|
|
600
|
+
return [month, day, year].filter(Boolean).join("/");
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
/**
|
|
604
|
+
* Validates that a date string matches the provided format and represents a real calendar date.
|
|
605
|
+
*
|
|
606
|
+
* @param {string} dateStr - Date string to validate.
|
|
607
|
+
* @param {string} [format="yyyy-mm-dd"] - Format of the date string.
|
|
608
|
+
* @returns {boolean} True when the date string is valid for the provided format, otherwise false.
|
|
609
|
+
*/
|
|
610
|
+
function isValidDate(dateStr, format = "yyyy-mm-dd") {
|
|
611
|
+
try {
|
|
612
|
+
if (typeof dateStr !== "string" || !dateStr || format?.length < 8) {
|
|
613
|
+
return false;
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
if (parseDate(dateStr, format)) {
|
|
617
|
+
return true;
|
|
618
|
+
}
|
|
619
|
+
} catch (error) {
|
|
620
|
+
return false;
|
|
621
|
+
}
|
|
622
|
+
return false;
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
/**
|
|
626
|
+
* 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.
|
|
627
|
+
*
|
|
628
|
+
* @param {Date} date - Date instance to convert to an ISO-like string.
|
|
629
|
+
* @returns {string} A string in the format "yyyy-mm-dd" representing the provided date.
|
|
630
|
+
* @throws {Error} Throws an error when the input is not a valid Date instance.
|
|
631
|
+
*/
|
|
632
|
+
function toISOFormatString(date) {
|
|
633
|
+
if (!(date instanceof Date) || Number.isNaN(date.getTime())) {
|
|
634
|
+
throw new Error(
|
|
635
|
+
"AuroDatepickerUtilities | toISOFormatString: Input must be a valid Date instance",
|
|
636
|
+
);
|
|
637
|
+
}
|
|
638
|
+
return `${String(date.getFullYear()).padStart(4, "0")}-${String(date.getMonth() + 1).padStart(2, "0")}-${String(date.getDate()).padStart(2, "0")}`;
|
|
538
639
|
}
|
|
539
|
-
|
|
640
|
+
|
|
641
|
+
/**
|
|
642
|
+
* 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.
|
|
643
|
+
*
|
|
644
|
+
* @param {String} dateStr - Date string to convert into a Date object.
|
|
645
|
+
* @param {String} format - Date format used to parse the string when it is not in ISO format.
|
|
646
|
+
* @returns {Date|null} Returns a Date instance for valid input or null for non-string input.
|
|
647
|
+
* @throws {Error} Throws when parsing fails for non-ISO string input.
|
|
648
|
+
*/
|
|
649
|
+
function stringToDateInstance(dateStr, format = "yyyy-mm-dd") {
|
|
650
|
+
if (typeof dateStr !== "string") {
|
|
651
|
+
return null;
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
const { month, day, year } = parseDate(dateStr, format);
|
|
655
|
+
return new Date(`${year}/${month}/${day}`);
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
const dateFormatter = {
|
|
659
|
+
parseDate,
|
|
660
|
+
getDateParts,
|
|
661
|
+
getDateAsString,
|
|
662
|
+
toNorthAmericanFormat: toNorthAmericanFormat$1,
|
|
663
|
+
isValidDate,
|
|
664
|
+
toISOFormatString,
|
|
665
|
+
stringToDateInstance,
|
|
666
|
+
};
|
|
540
667
|
|
|
541
668
|
// filepath: dateConstraints.mjs
|
|
542
669
|
const DATE_UTIL_CONSTRAINTS = {
|
|
@@ -608,12 +735,11 @@ class AuroDateUtilitiesBase {
|
|
|
608
735
|
/* eslint-disable no-magic-numbers */
|
|
609
736
|
|
|
610
737
|
class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
611
|
-
|
|
612
738
|
/**
|
|
613
739
|
* Returns the current century.
|
|
614
740
|
* @returns {String} The current century.
|
|
615
741
|
*/
|
|
616
|
-
getCentury
|
|
742
|
+
getCentury() {
|
|
617
743
|
return String(new Date().getFullYear()).slice(0, 2);
|
|
618
744
|
}
|
|
619
745
|
|
|
@@ -622,14 +748,12 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
622
748
|
* @param {String} year - The year to convert to four digits.
|
|
623
749
|
* @returns {String} The four digit year.
|
|
624
750
|
*/
|
|
625
|
-
getFourDigitYear
|
|
626
|
-
|
|
751
|
+
getFourDigitYear(year) {
|
|
627
752
|
const strYear = String(year).trim();
|
|
628
753
|
return strYear.length <= 2 ? this.getCentury() + strYear : strYear;
|
|
629
754
|
}
|
|
630
755
|
|
|
631
756
|
constructor() {
|
|
632
|
-
|
|
633
757
|
super();
|
|
634
758
|
|
|
635
759
|
/**
|
|
@@ -638,7 +762,8 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
638
762
|
* @param {Object} date2 - Second date to compare.
|
|
639
763
|
* @returns {Boolean} Returns true if the dates match.
|
|
640
764
|
*/
|
|
641
|
-
this.datesMatch = (date1, date2) =>
|
|
765
|
+
this.datesMatch = (date1, date2) =>
|
|
766
|
+
new Date(date1).getTime() === new Date(date2).getTime();
|
|
642
767
|
|
|
643
768
|
/**
|
|
644
769
|
* Returns true if value passed in is a valid date.
|
|
@@ -647,53 +772,41 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
647
772
|
* @returns {Boolean}
|
|
648
773
|
*/
|
|
649
774
|
this.validDateStr = (date, format) => {
|
|
650
|
-
|
|
651
775
|
// The length we expect the date string to be
|
|
652
|
-
const dateStrLength = format
|
|
776
|
+
const dateStrLength = format?.length || 0;
|
|
653
777
|
|
|
654
778
|
// Guard Clause: Date and format are defined
|
|
655
779
|
if (typeof date === "undefined" || typeof format === "undefined") {
|
|
656
|
-
throw new Error(
|
|
780
|
+
throw new Error(
|
|
781
|
+
"AuroDatepickerUtilities | validateDateStr: Date and format are required",
|
|
782
|
+
);
|
|
657
783
|
}
|
|
658
784
|
|
|
659
785
|
// Guard Clause: Date should be of type string
|
|
660
786
|
if (typeof date !== "string") {
|
|
661
|
-
throw new Error(
|
|
787
|
+
throw new Error(
|
|
788
|
+
"AuroDatepickerUtilities | validateDateStr: Date must be a string",
|
|
789
|
+
);
|
|
662
790
|
}
|
|
663
791
|
|
|
664
792
|
// Guard Clause: Format should be of type string
|
|
665
793
|
if (typeof format !== "string") {
|
|
666
|
-
throw new Error(
|
|
794
|
+
throw new Error(
|
|
795
|
+
"AuroDatepickerUtilities | validateDateStr: Format must be a string",
|
|
796
|
+
);
|
|
667
797
|
}
|
|
668
798
|
|
|
669
799
|
// Guard Clause: Length is what we expect it to be
|
|
670
800
|
if (date.length !== dateStrLength) {
|
|
671
801
|
return false;
|
|
672
802
|
}
|
|
673
|
-
// Get a formatted date string and parse it
|
|
674
|
-
const dateParts = dateFormatter.parseDate(date, format);
|
|
675
803
|
|
|
676
|
-
//
|
|
677
|
-
|
|
804
|
+
// Get a formatted date string and parse and validate it
|
|
805
|
+
try {
|
|
806
|
+
return Boolean(dateFormatter.parseDate(date, format));
|
|
807
|
+
} catch (error) {
|
|
678
808
|
return false;
|
|
679
809
|
}
|
|
680
|
-
|
|
681
|
-
// Create the expected date string based on the date parts
|
|
682
|
-
const expectedDateStr = `${dateParts.month}/${dateParts.day || "01"}/${this.getFourDigitYear(dateParts.year)}`;
|
|
683
|
-
|
|
684
|
-
// Generate a date object that we will extract a string date from to compare to the passed in date string
|
|
685
|
-
const dateObj = new Date(this.getFourDigitYear(dateParts.year), dateParts.month - 1, dateParts.day || 1);
|
|
686
|
-
|
|
687
|
-
// Get the date string of the date object we created from the string date
|
|
688
|
-
const actualDateStr = dateFormatter.getDateAsString(dateObj, "en-US");
|
|
689
|
-
|
|
690
|
-
// Guard Clause: Generated date matches date string input
|
|
691
|
-
if (expectedDateStr !== actualDateStr) {
|
|
692
|
-
return false;
|
|
693
|
-
}
|
|
694
|
-
|
|
695
|
-
// If we passed all other checks, we can assume the date is valid
|
|
696
|
-
return true;
|
|
697
810
|
};
|
|
698
811
|
|
|
699
812
|
/**
|
|
@@ -703,10 +816,11 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
703
816
|
* @returns {boolean}
|
|
704
817
|
*/
|
|
705
818
|
this.dateAndFormatMatch = (value, format) => {
|
|
706
|
-
|
|
707
819
|
// Ensure we have both values we need to do the comparison
|
|
708
820
|
if (!value || !format) {
|
|
709
|
-
throw new Error(
|
|
821
|
+
throw new Error(
|
|
822
|
+
"AuroFormValidation | dateFormatMatch: value and format are required",
|
|
823
|
+
);
|
|
710
824
|
}
|
|
711
825
|
|
|
712
826
|
// If the lengths are different, they cannot match
|
|
@@ -715,11 +829,10 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
715
829
|
}
|
|
716
830
|
|
|
717
831
|
// Get the parts of the date
|
|
718
|
-
const dateParts = dateFormatter.
|
|
832
|
+
const dateParts = dateFormatter.getDateParts(value, format);
|
|
719
833
|
|
|
720
834
|
// Validator for day
|
|
721
835
|
const dayValueIsValid = (day) => {
|
|
722
|
-
|
|
723
836
|
// Guard clause: if there is no day in the dateParts, we can ignore this check.
|
|
724
837
|
if (!dateParts.day) {
|
|
725
838
|
return true;
|
|
@@ -735,7 +848,9 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
735
848
|
|
|
736
849
|
// Guard clause: ensure day is a valid integer
|
|
737
850
|
if (Number.isNaN(numDay)) {
|
|
738
|
-
throw new Error(
|
|
851
|
+
throw new Error(
|
|
852
|
+
"AuroDatepickerUtilities | dayValueIsValid: Unable to parse day value integer",
|
|
853
|
+
);
|
|
739
854
|
}
|
|
740
855
|
|
|
741
856
|
// Guard clause: ensure day is within the valid range
|
|
@@ -749,6 +864,10 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
749
864
|
|
|
750
865
|
// Validator for month
|
|
751
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
|
+
}
|
|
752
871
|
|
|
753
872
|
// Guard clause: ensure month exists.
|
|
754
873
|
if (!month) {
|
|
@@ -760,7 +879,9 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
760
879
|
|
|
761
880
|
// Guard clause: ensure month is a valid integer
|
|
762
881
|
if (Number.isNaN(numMonth)) {
|
|
763
|
-
throw new Error(
|
|
882
|
+
throw new Error(
|
|
883
|
+
"AuroDatepickerUtilities | monthValueIsValid: Unable to parse month value integer",
|
|
884
|
+
);
|
|
764
885
|
}
|
|
765
886
|
|
|
766
887
|
// Guard clause: ensure month is within the valid range
|
|
@@ -774,6 +895,10 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
774
895
|
|
|
775
896
|
// Validator for year
|
|
776
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
|
+
}
|
|
777
902
|
|
|
778
903
|
// Guard clause: ensure year exists.
|
|
779
904
|
if (!_year) {
|
|
@@ -788,7 +913,9 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
788
913
|
|
|
789
914
|
// Guard clause: ensure year is a valid integer
|
|
790
915
|
if (Number.isNaN(numYear)) {
|
|
791
|
-
throw new Error(
|
|
916
|
+
throw new Error(
|
|
917
|
+
"AuroDatepickerUtilities | yearValueIsValid: Unable to parse year value integer",
|
|
918
|
+
);
|
|
792
919
|
}
|
|
793
920
|
|
|
794
921
|
// Guard clause: ensure year is within the valid range
|
|
@@ -804,7 +931,7 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
804
931
|
const checks = [
|
|
805
932
|
monthValueIsValid(dateParts.month),
|
|
806
933
|
dayValueIsValid(dateParts.day),
|
|
807
|
-
yearIsValid(dateParts.year)
|
|
934
|
+
yearIsValid(dateParts.year),
|
|
808
935
|
];
|
|
809
936
|
|
|
810
937
|
// If any of the checks failed, the date format does not match and the result is invalid
|
|
@@ -838,10 +965,7 @@ const {
|
|
|
838
965
|
} = dateUtilities;
|
|
839
966
|
|
|
840
967
|
const {
|
|
841
|
-
toNorthAmericanFormat
|
|
842
|
-
parseDate,
|
|
843
|
-
getDateAsString
|
|
844
|
-
} = dateFormatter;
|
|
968
|
+
toNorthAmericanFormat} = dateFormatter;
|
|
845
969
|
|
|
846
970
|
// Copyright (c) Alaska Air. All right reserved. Licensed under the Apache-2.0 license
|
|
847
971
|
// See LICENSE in the project root for license information.
|
|
@@ -1573,7 +1697,7 @@ class AuroHelpText extends LitElement {
|
|
|
1573
1697
|
}
|
|
1574
1698
|
}
|
|
1575
1699
|
|
|
1576
|
-
var formkitVersion = '
|
|
1700
|
+
var formkitVersion = '202606022350';
|
|
1577
1701
|
|
|
1578
1702
|
// Copyright (c) Alaska Air. All right reserved. Licensed under the Apache-2.0 license
|
|
1579
1703
|
// See LICENSE in the project root for license information.
|