@aurodesignsystem-dev/auro-formkit 0.0.0-pr1483.0 → 0.0.0-pr1483.1
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 +2 -233
- package/components/checkbox/demo/getting-started.min.js +2 -233
- package/components/checkbox/demo/index.min.js +2 -233
- package/components/checkbox/dist/index.js +2 -233
- package/components/checkbox/dist/registered.js +2 -233
- package/components/combobox/demo/customize.min.js +5 -236
- package/components/combobox/demo/getting-started.min.js +5 -236
- package/components/combobox/demo/index.min.js +5 -236
- package/components/combobox/dist/index.js +5 -236
- package/components/combobox/dist/registered.js +5 -236
- package/components/counter/demo/customize.min.js +3 -234
- package/components/counter/demo/index.min.js +3 -234
- package/components/counter/dist/index.js +2 -233
- package/components/counter/dist/registered.js +2 -233
- package/components/datepicker/demo/index.min.js +6 -5
- package/components/datepicker/dist/index.js +6 -5
- package/components/datepicker/dist/registered.js +6 -5
- 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/dist/index.js +1 -1
- package/components/dropdown/dist/registered.js +1 -1
- package/components/form/demo/customize.min.js +168 -1322
- package/components/form/demo/getting-started.min.js +168 -1322
- package/components/form/demo/index.min.js +168 -1322
- package/components/form/demo/registerDemoDeps.min.js +168 -1322
- package/components/input/demo/customize.min.js +2 -2
- package/components/input/demo/getting-started.min.js +2 -2
- package/components/input/demo/index.min.js +2 -2
- package/components/input/dist/index.js +2 -2
- package/components/input/dist/registered.js +2 -2
- package/components/radio/demo/index.min.js +2 -233
- package/components/radio/dist/index.js +2 -233
- package/components/radio/dist/registered.js +2 -233
- package/components/select/demo/customize.min.js +3 -234
- package/components/select/demo/getting-started.min.js +3 -234
- package/components/select/demo/index.min.js +3 -234
- package/components/select/dist/index.js +3 -234
- package/components/select/dist/registered.js +3 -234
- package/custom-elements.json +1444 -1444
- package/package.json +1 -1
|
@@ -4344,7 +4344,7 @@ class AuroFormValidation {
|
|
|
4344
4344
|
}
|
|
4345
4345
|
|
|
4346
4346
|
// Validate that the date passed was the correct format and is a valid date
|
|
4347
|
-
if (elem.value && !
|
|
4347
|
+
if (elem.value && !elem.valueObject) {
|
|
4348
4348
|
elem.validity = 'patternMismatch';
|
|
4349
4349
|
elem.errorMessage = elem.setCustomValidityPatternMismatch || elem.setCustomValidity || 'Invalid Date Format Entered';
|
|
4350
4350
|
return;
|
|
@@ -12178,7 +12178,7 @@ class AuroHelpText extends i$3 {
|
|
|
12178
12178
|
}
|
|
12179
12179
|
}
|
|
12180
12180
|
|
|
12181
|
-
var formkitVersion = '
|
|
12181
|
+
var formkitVersion = '202605271820';
|
|
12182
12182
|
|
|
12183
12183
|
/**
|
|
12184
12184
|
* @license
|
|
@@ -4344,7 +4344,7 @@ class AuroFormValidation {
|
|
|
4344
4344
|
}
|
|
4345
4345
|
|
|
4346
4346
|
// Validate that the date passed was the correct format and is a valid date
|
|
4347
|
-
if (elem.value && !
|
|
4347
|
+
if (elem.value && !elem.valueObject) {
|
|
4348
4348
|
elem.validity = 'patternMismatch';
|
|
4349
4349
|
elem.errorMessage = elem.setCustomValidityPatternMismatch || elem.setCustomValidity || 'Invalid Date Format Entered';
|
|
4350
4350
|
return;
|
|
@@ -12178,7 +12178,7 @@ class AuroHelpText extends i$3 {
|
|
|
12178
12178
|
}
|
|
12179
12179
|
}
|
|
12180
12180
|
|
|
12181
|
-
var formkitVersion = '
|
|
12181
|
+
var formkitVersion = '202605271820';
|
|
12182
12182
|
|
|
12183
12183
|
/**
|
|
12184
12184
|
* @license
|
|
@@ -4344,7 +4344,7 @@ class AuroFormValidation {
|
|
|
4344
4344
|
}
|
|
4345
4345
|
|
|
4346
4346
|
// Validate that the date passed was the correct format and is a valid date
|
|
4347
|
-
if (elem.value && !
|
|
4347
|
+
if (elem.value && !elem.valueObject) {
|
|
4348
4348
|
elem.validity = 'patternMismatch';
|
|
4349
4349
|
elem.errorMessage = elem.setCustomValidityPatternMismatch || elem.setCustomValidity || 'Invalid Date Format Entered';
|
|
4350
4350
|
return;
|
|
@@ -12178,7 +12178,7 @@ class AuroHelpText extends i$3 {
|
|
|
12178
12178
|
}
|
|
12179
12179
|
}
|
|
12180
12180
|
|
|
12181
|
-
var formkitVersion = '
|
|
12181
|
+
var formkitVersion = '202605271820';
|
|
12182
12182
|
|
|
12183
12183
|
/**
|
|
12184
12184
|
* @license
|
|
@@ -4286,7 +4286,7 @@ class AuroFormValidation {
|
|
|
4286
4286
|
}
|
|
4287
4287
|
|
|
4288
4288
|
// Validate that the date passed was the correct format and is a valid date
|
|
4289
|
-
if (elem.value && !
|
|
4289
|
+
if (elem.value && !elem.valueObject) {
|
|
4290
4290
|
elem.validity = 'patternMismatch';
|
|
4291
4291
|
elem.errorMessage = elem.setCustomValidityPatternMismatch || elem.setCustomValidity || 'Invalid Date Format Entered';
|
|
4292
4292
|
return;
|
|
@@ -12120,7 +12120,7 @@ class AuroHelpText extends LitElement {
|
|
|
12120
12120
|
}
|
|
12121
12121
|
}
|
|
12122
12122
|
|
|
12123
|
-
var formkitVersion = '
|
|
12123
|
+
var formkitVersion = '202605271820';
|
|
12124
12124
|
|
|
12125
12125
|
// Copyright (c) 2025 Alaska Airlines. All right reserved. Licensed under the Apache-2.0 license
|
|
12126
12126
|
// See LICENSE in the project root for license information.
|
|
@@ -4286,7 +4286,7 @@ class AuroFormValidation {
|
|
|
4286
4286
|
}
|
|
4287
4287
|
|
|
4288
4288
|
// Validate that the date passed was the correct format and is a valid date
|
|
4289
|
-
if (elem.value && !
|
|
4289
|
+
if (elem.value && !elem.valueObject) {
|
|
4290
4290
|
elem.validity = 'patternMismatch';
|
|
4291
4291
|
elem.errorMessage = elem.setCustomValidityPatternMismatch || elem.setCustomValidity || 'Invalid Date Format Entered';
|
|
4292
4292
|
return;
|
|
@@ -12120,7 +12120,7 @@ class AuroHelpText extends LitElement {
|
|
|
12120
12120
|
}
|
|
12121
12121
|
}
|
|
12122
12122
|
|
|
12123
|
-
var formkitVersion = '
|
|
12123
|
+
var formkitVersion = '202605271820';
|
|
12124
12124
|
|
|
12125
12125
|
// Copyright (c) 2025 Alaska Airlines. All right reserved. Licensed under the Apache-2.0 license
|
|
12126
12126
|
// See LICENSE in the project root for license information.
|
|
@@ -495,237 +495,6 @@ 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
|
-
/**
|
|
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
|
-
}
|
|
523
|
-
|
|
524
|
-
if (dateStr.length !== format.length) {
|
|
525
|
-
throw new Error(
|
|
526
|
-
"AuroDatepickerUtilities | parseDate: Date string and format length do not match",
|
|
527
|
-
);
|
|
528
|
-
}
|
|
529
|
-
|
|
530
|
-
valueParts = [dateStr];
|
|
531
|
-
formatParts = [format];
|
|
532
|
-
}
|
|
533
|
-
|
|
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
|
-
}
|
|
539
|
-
|
|
540
|
-
const result = formatParts.reduce((acc, part, index) => {
|
|
541
|
-
const value = valueParts[index];
|
|
542
|
-
|
|
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
|
-
}
|
|
550
|
-
|
|
551
|
-
return acc;
|
|
552
|
-
}, {});
|
|
553
|
-
|
|
554
|
-
if (!result.month && !result.day && !result.year) {
|
|
555
|
-
throw new Error(
|
|
556
|
-
"AuroDatepickerUtilities | parseDate: Unable to parse date string",
|
|
557
|
-
);
|
|
558
|
-
}
|
|
559
|
-
|
|
560
|
-
return result;
|
|
561
|
-
}
|
|
562
|
-
|
|
563
|
-
function isCalendarDate(year, month, day) {
|
|
564
|
-
let yearNumber = Number(year);
|
|
565
|
-
const monthNumber = Number(month);
|
|
566
|
-
const dayNumber = Number(day);
|
|
567
|
-
|
|
568
|
-
if (
|
|
569
|
-
!Number.isInteger(yearNumber) ||
|
|
570
|
-
!Number.isInteger(monthNumber) ||
|
|
571
|
-
!Number.isInteger(dayNumber)
|
|
572
|
-
) {
|
|
573
|
-
return false;
|
|
574
|
-
}
|
|
575
|
-
|
|
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
|
-
}
|
|
582
|
-
|
|
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, "/"));
|
|
585
|
-
|
|
586
|
-
return (
|
|
587
|
-
!Number.isNaN(date.getTime()) && toISOFormatString(date) === stringified
|
|
588
|
-
);
|
|
589
|
-
}
|
|
590
|
-
|
|
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);
|
|
607
|
-
|
|
608
|
-
if (!result) {
|
|
609
|
-
return undefined;
|
|
610
|
-
}
|
|
611
|
-
|
|
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";
|
|
616
|
-
|
|
617
|
-
if (isCalendarDate(year, month, day)) {
|
|
618
|
-
return result;
|
|
619
|
-
}
|
|
620
|
-
|
|
621
|
-
throw new Error(
|
|
622
|
-
`AuroDatepickerUtilities | parseDate: Date string is not a valid date ${JSON.stringify(result)} with format ${format}`,
|
|
623
|
-
);
|
|
624
|
-
}
|
|
625
|
-
|
|
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
|
-
}
|
|
639
|
-
|
|
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(dateStr, format) {
|
|
647
|
-
if (format === "mm/dd/yyyy") {
|
|
648
|
-
return dateStr;
|
|
649
|
-
}
|
|
650
|
-
|
|
651
|
-
const parsedDate = parseDate(dateStr, format);
|
|
652
|
-
|
|
653
|
-
if (!parsedDate) {
|
|
654
|
-
throw new Error(
|
|
655
|
-
"AuroDatepickerUtilities | toNorthAmericanFormat: Unable to parse date string",
|
|
656
|
-
);
|
|
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}`);
|
|
717
|
-
}
|
|
718
|
-
|
|
719
|
-
const dateFormatter = {
|
|
720
|
-
parseDate,
|
|
721
|
-
getDateParts,
|
|
722
|
-
getDateAsString,
|
|
723
|
-
toNorthAmericanFormat,
|
|
724
|
-
isValidDate,
|
|
725
|
-
toISOFormatString,
|
|
726
|
-
stringToDateInstance,
|
|
727
|
-
};
|
|
728
|
-
|
|
729
498
|
// Copyright (c) Alaska Air. All right reserved. Licensed under the Apache-2.0 license
|
|
730
499
|
// See LICENSE in the project root for license information.
|
|
731
500
|
|
|
@@ -947,7 +716,7 @@ class AuroFormValidation {
|
|
|
947
716
|
}
|
|
948
717
|
|
|
949
718
|
// Validate that the date passed was the correct format and is a valid date
|
|
950
|
-
if (elem.value && !
|
|
719
|
+
if (elem.value && !elem.valueObject) {
|
|
951
720
|
elem.validity = 'patternMismatch';
|
|
952
721
|
elem.errorMessage = elem.setCustomValidityPatternMismatch || elem.setCustomValidity || 'Invalid Date Format Entered';
|
|
953
722
|
return;
|
|
@@ -1443,7 +1212,7 @@ class AuroHelpText extends i$2 {
|
|
|
1443
1212
|
}
|
|
1444
1213
|
}
|
|
1445
1214
|
|
|
1446
|
-
var formkitVersion = '
|
|
1215
|
+
var formkitVersion = '202605271820';
|
|
1447
1216
|
|
|
1448
1217
|
// Copyright (c) Alaska Air. All right reserved. Licensed under the Apache-2.0 license
|
|
1449
1218
|
// See LICENSE in the project root for license information.
|
|
@@ -434,237 +434,6 @@ 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
|
-
/**
|
|
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
|
-
}
|
|
462
|
-
|
|
463
|
-
if (dateStr.length !== format.length) {
|
|
464
|
-
throw new Error(
|
|
465
|
-
"AuroDatepickerUtilities | parseDate: Date string and format length do not match",
|
|
466
|
-
);
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
valueParts = [dateStr];
|
|
470
|
-
formatParts = [format];
|
|
471
|
-
}
|
|
472
|
-
|
|
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
|
-
}
|
|
478
|
-
|
|
479
|
-
const result = formatParts.reduce((acc, part, index) => {
|
|
480
|
-
const value = valueParts[index];
|
|
481
|
-
|
|
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
|
-
}
|
|
489
|
-
|
|
490
|
-
return acc;
|
|
491
|
-
}, {});
|
|
492
|
-
|
|
493
|
-
if (!result.month && !result.day && !result.year) {
|
|
494
|
-
throw new Error(
|
|
495
|
-
"AuroDatepickerUtilities | parseDate: Unable to parse date string",
|
|
496
|
-
);
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
return result;
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
function isCalendarDate(year, month, day) {
|
|
503
|
-
let yearNumber = Number(year);
|
|
504
|
-
const monthNumber = Number(month);
|
|
505
|
-
const dayNumber = Number(day);
|
|
506
|
-
|
|
507
|
-
if (
|
|
508
|
-
!Number.isInteger(yearNumber) ||
|
|
509
|
-
!Number.isInteger(monthNumber) ||
|
|
510
|
-
!Number.isInteger(dayNumber)
|
|
511
|
-
) {
|
|
512
|
-
return false;
|
|
513
|
-
}
|
|
514
|
-
|
|
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
|
-
}
|
|
521
|
-
|
|
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, "/"));
|
|
524
|
-
|
|
525
|
-
return (
|
|
526
|
-
!Number.isNaN(date.getTime()) && toISOFormatString(date) === stringified
|
|
527
|
-
);
|
|
528
|
-
}
|
|
529
|
-
|
|
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
|
-
}
|
|
550
|
-
|
|
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";
|
|
555
|
-
|
|
556
|
-
if (isCalendarDate(year, month, day)) {
|
|
557
|
-
return result;
|
|
558
|
-
}
|
|
559
|
-
|
|
560
|
-
throw new Error(
|
|
561
|
-
`AuroDatepickerUtilities | parseDate: Date string is not a valid date ${JSON.stringify(result)} with format ${format}`,
|
|
562
|
-
);
|
|
563
|
-
}
|
|
564
|
-
|
|
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
|
-
}
|
|
578
|
-
|
|
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(dateStr, format) {
|
|
586
|
-
if (format === "mm/dd/yyyy") {
|
|
587
|
-
return dateStr;
|
|
588
|
-
}
|
|
589
|
-
|
|
590
|
-
const parsedDate = parseDate(dateStr, format);
|
|
591
|
-
|
|
592
|
-
if (!parsedDate) {
|
|
593
|
-
throw new Error(
|
|
594
|
-
"AuroDatepickerUtilities | toNorthAmericanFormat: Unable to parse date string",
|
|
595
|
-
);
|
|
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")}`;
|
|
639
|
-
}
|
|
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,
|
|
663
|
-
isValidDate,
|
|
664
|
-
toISOFormatString,
|
|
665
|
-
stringToDateInstance,
|
|
666
|
-
};
|
|
667
|
-
|
|
668
437
|
// Copyright (c) Alaska Air. All right reserved. Licensed under the Apache-2.0 license
|
|
669
438
|
// See LICENSE in the project root for license information.
|
|
670
439
|
|
|
@@ -886,7 +655,7 @@ class AuroFormValidation {
|
|
|
886
655
|
}
|
|
887
656
|
|
|
888
657
|
// Validate that the date passed was the correct format and is a valid date
|
|
889
|
-
if (elem.value && !
|
|
658
|
+
if (elem.value && !elem.valueObject) {
|
|
890
659
|
elem.validity = 'patternMismatch';
|
|
891
660
|
elem.errorMessage = elem.setCustomValidityPatternMismatch || elem.setCustomValidity || 'Invalid Date Format Entered';
|
|
892
661
|
return;
|
|
@@ -1382,7 +1151,7 @@ class AuroHelpText extends LitElement {
|
|
|
1382
1151
|
}
|
|
1383
1152
|
}
|
|
1384
1153
|
|
|
1385
|
-
var formkitVersion = '
|
|
1154
|
+
var formkitVersion = '202605271820';
|
|
1386
1155
|
|
|
1387
1156
|
// Copyright (c) Alaska Air. All right reserved. Licensed under the Apache-2.0 license
|
|
1388
1157
|
// See LICENSE in the project root for license information.
|