@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
|
@@ -4050,109 +4050,236 @@ class AuroInputUtilities {
|
|
|
4050
4050
|
}
|
|
4051
4051
|
}
|
|
4052
4052
|
|
|
4053
|
-
|
|
4053
|
+
/**
|
|
4054
|
+
* @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.
|
|
4055
|
+
* @param {string} dateStr - Date string to parse.
|
|
4056
|
+
* @param {string} format - Date format to parse.
|
|
4057
|
+
* @returns {{ month?: string, day?: string, year?: string }|undefined}
|
|
4058
|
+
*/
|
|
4059
|
+
function getDateParts(dateStr, format) {
|
|
4060
|
+
if (!dateStr) {
|
|
4061
|
+
return undefined;
|
|
4062
|
+
}
|
|
4054
4063
|
|
|
4055
|
-
|
|
4064
|
+
const formatSeparatorMatch = format.match(/[/.-]/);
|
|
4065
|
+
let valueParts;
|
|
4066
|
+
let formatParts;
|
|
4056
4067
|
|
|
4057
|
-
|
|
4058
|
-
|
|
4059
|
-
|
|
4060
|
-
|
|
4061
|
-
|
|
4062
|
-
|
|
4063
|
-
|
|
4068
|
+
if (formatSeparatorMatch) {
|
|
4069
|
+
const separator = formatSeparatorMatch[0];
|
|
4070
|
+
valueParts = dateStr.split(separator);
|
|
4071
|
+
formatParts = format.split(separator);
|
|
4072
|
+
} else {
|
|
4073
|
+
if (dateStr.match(/[/.-]/)) {
|
|
4074
|
+
throw new Error(
|
|
4075
|
+
"AuroDatepickerUtilities | parseDate: Date string has no separators",
|
|
4076
|
+
);
|
|
4077
|
+
}
|
|
4064
4078
|
|
|
4065
|
-
|
|
4066
|
-
|
|
4067
|
-
|
|
4068
|
-
|
|
4079
|
+
if (dateStr.length !== format.length) {
|
|
4080
|
+
throw new Error(
|
|
4081
|
+
"AuroDatepickerUtilities | parseDate: Date string and format length do not match",
|
|
4082
|
+
);
|
|
4083
|
+
}
|
|
4069
4084
|
|
|
4070
|
-
|
|
4071
|
-
|
|
4085
|
+
valueParts = [dateStr];
|
|
4086
|
+
formatParts = [format];
|
|
4087
|
+
}
|
|
4072
4088
|
|
|
4073
|
-
|
|
4074
|
-
|
|
4075
|
-
|
|
4089
|
+
if (valueParts.length !== formatParts.length) {
|
|
4090
|
+
throw new Error(
|
|
4091
|
+
`AuroDatepickerUtilities | parseDate: Date string and format do not match : ${dateStr} vs ${format}`,
|
|
4092
|
+
);
|
|
4093
|
+
}
|
|
4076
4094
|
|
|
4077
|
-
|
|
4078
|
-
|
|
4079
|
-
throw new Error('AuroDatepickerUtilities | parseDate: Date string and format length do not match');
|
|
4080
|
-
}
|
|
4095
|
+
const result = formatParts.reduce((acc, part, index) => {
|
|
4096
|
+
const value = valueParts[index];
|
|
4081
4097
|
|
|
4082
|
-
|
|
4083
|
-
|
|
4084
|
-
|
|
4098
|
+
if (/m/iu.test(part) && part.length === value.length) {
|
|
4099
|
+
acc.month = value;
|
|
4100
|
+
} else if (/d/iu.test(part) && part.length === value.length) {
|
|
4101
|
+
acc.day = value;
|
|
4102
|
+
} else if (/y/iu.test(part) && part.length === value.length) {
|
|
4103
|
+
acc.year = value;
|
|
4104
|
+
}
|
|
4085
4105
|
|
|
4086
|
-
|
|
4087
|
-
|
|
4088
|
-
} else if ((/d/iu).test(part)) {
|
|
4089
|
-
acc.day = value;
|
|
4090
|
-
} else if ((/y/iu).test(part)) {
|
|
4091
|
-
acc.year = value;
|
|
4092
|
-
}
|
|
4106
|
+
return acc;
|
|
4107
|
+
}, {});
|
|
4093
4108
|
|
|
4094
|
-
|
|
4095
|
-
|
|
4109
|
+
if (!result.month && !result.day && !result.year) {
|
|
4110
|
+
throw new Error(
|
|
4111
|
+
"AuroDatepickerUtilities | parseDate: Unable to parse date string",
|
|
4112
|
+
);
|
|
4113
|
+
}
|
|
4096
4114
|
|
|
4097
|
-
|
|
4098
|
-
|
|
4099
|
-
return result;
|
|
4100
|
-
}
|
|
4115
|
+
return result;
|
|
4116
|
+
}
|
|
4101
4117
|
|
|
4102
|
-
|
|
4103
|
-
|
|
4104
|
-
|
|
4118
|
+
function isCalendarDate(year, month, day) {
|
|
4119
|
+
let yearNumber = Number(year);
|
|
4120
|
+
const monthNumber = Number(month);
|
|
4121
|
+
const dayNumber = Number(day);
|
|
4105
4122
|
|
|
4106
|
-
|
|
4107
|
-
|
|
4108
|
-
|
|
4109
|
-
|
|
4110
|
-
|
|
4111
|
-
|
|
4112
|
-
|
|
4113
|
-
year: "numeric",
|
|
4114
|
-
month: "2-digit",
|
|
4115
|
-
day: "2-digit",
|
|
4116
|
-
});
|
|
4123
|
+
if (
|
|
4124
|
+
!Number.isInteger(yearNumber) ||
|
|
4125
|
+
!Number.isInteger(monthNumber) ||
|
|
4126
|
+
!Number.isInteger(dayNumber)
|
|
4127
|
+
) {
|
|
4128
|
+
return false;
|
|
4129
|
+
}
|
|
4117
4130
|
|
|
4118
|
-
|
|
4119
|
-
|
|
4120
|
-
|
|
4121
|
-
|
|
4122
|
-
|
|
4123
|
-
|
|
4124
|
-
this.toNorthAmericanFormat = (dateStr, format) => {
|
|
4131
|
+
// 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.
|
|
4132
|
+
if (yearNumber < 100 && yearNumber >= 50) {
|
|
4133
|
+
yearNumber += 1900;
|
|
4134
|
+
} else if (yearNumber < 50) {
|
|
4135
|
+
yearNumber += 2000;
|
|
4136
|
+
}
|
|
4125
4137
|
|
|
4126
|
-
|
|
4127
|
-
|
|
4128
|
-
}
|
|
4138
|
+
const stringified = `${String(yearNumber).padStart(4, "0")}-${String(monthNumber).padStart(2, "0")}-${String(dayNumber).padStart(2, "0")}`;
|
|
4139
|
+
const date = new Date(stringified.replace(/[.-]/g, "/"));
|
|
4129
4140
|
|
|
4130
|
-
|
|
4141
|
+
return (
|
|
4142
|
+
!Number.isNaN(date.getTime()) && toISOFormatString(date) === stringified
|
|
4143
|
+
);
|
|
4144
|
+
}
|
|
4131
4145
|
|
|
4132
|
-
|
|
4133
|
-
|
|
4134
|
-
|
|
4146
|
+
/**
|
|
4147
|
+
* @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).
|
|
4148
|
+
*
|
|
4149
|
+
* Partial formats are supported: components absent from `format` default to `year → "0"`,
|
|
4150
|
+
* `month → "01"`, `day → "01"` for calendar validation only. The returned object contains
|
|
4151
|
+
* only the fields actually present in the format string — missing fields are never injected.
|
|
4152
|
+
* @param {string} dateStr - Date string to parse.
|
|
4153
|
+
* @param {string} format - Date format to parse.
|
|
4154
|
+
* @returns {{ month?: string, day?: string, year?: string }|undefined}
|
|
4155
|
+
* @throws {Error} Throws when the parsed result does not represent a valid calendar date.
|
|
4156
|
+
*/
|
|
4157
|
+
function parseDate(dateStr, format = "mm/dd/yyyy") {
|
|
4158
|
+
if (!dateStr || !format) {
|
|
4159
|
+
return undefined;
|
|
4160
|
+
}
|
|
4161
|
+
const result = getDateParts(dateStr.trim(), format);
|
|
4135
4162
|
|
|
4136
|
-
|
|
4163
|
+
if (!result) {
|
|
4164
|
+
return undefined;
|
|
4165
|
+
}
|
|
4137
4166
|
|
|
4138
|
-
|
|
4139
|
-
|
|
4140
|
-
|
|
4141
|
-
|
|
4167
|
+
const lowerFormat = format.toLowerCase();
|
|
4168
|
+
const year = lowerFormat.includes("yy") ? result.year : "0";
|
|
4169
|
+
const month = lowerFormat.includes("mm") ? result.month : "01";
|
|
4170
|
+
const day = lowerFormat.includes("dd") ? result.day : "01";
|
|
4142
4171
|
|
|
4143
|
-
|
|
4144
|
-
|
|
4145
|
-
|
|
4172
|
+
if (isCalendarDate(year, month, day)) {
|
|
4173
|
+
return result;
|
|
4174
|
+
}
|
|
4146
4175
|
|
|
4147
|
-
|
|
4148
|
-
|
|
4149
|
-
|
|
4176
|
+
throw new Error(
|
|
4177
|
+
`AuroDatepickerUtilities | parseDate: Date string is not a valid date ${JSON.stringify(result)} with format ${format}`,
|
|
4178
|
+
);
|
|
4179
|
+
}
|
|
4150
4180
|
|
|
4151
|
-
|
|
4152
|
-
|
|
4181
|
+
/**
|
|
4182
|
+
* Convert a date object to string format.
|
|
4183
|
+
* @param {Object} date - Date to convert to string.
|
|
4184
|
+
* @param {String} locale - Optional locale to use for the date string. Defaults to user's locale.
|
|
4185
|
+
* @returns {String} Returns the date as a string.
|
|
4186
|
+
*/
|
|
4187
|
+
function getDateAsString(date, locale = undefined) {
|
|
4188
|
+
return date.toLocaleDateString(locale, {
|
|
4189
|
+
year: "numeric",
|
|
4190
|
+
month: "2-digit",
|
|
4191
|
+
day: "2-digit",
|
|
4192
|
+
});
|
|
4193
|
+
}
|
|
4194
|
+
|
|
4195
|
+
/**
|
|
4196
|
+
* Converts a date string to a North American date format.
|
|
4197
|
+
* @param {String} dateStr - Date to validate.
|
|
4198
|
+
* @param {String} format - Date format to validate against.
|
|
4199
|
+
* @returns {String}
|
|
4200
|
+
*/
|
|
4201
|
+
function toNorthAmericanFormat$1(dateStr, format) {
|
|
4202
|
+
if (format === "mm/dd/yyyy") {
|
|
4203
|
+
return dateStr;
|
|
4153
4204
|
}
|
|
4205
|
+
|
|
4206
|
+
const parsedDate = parseDate(dateStr, format);
|
|
4207
|
+
|
|
4208
|
+
if (!parsedDate) {
|
|
4209
|
+
throw new Error(
|
|
4210
|
+
"AuroDatepickerUtilities | toNorthAmericanFormat: Unable to parse date string",
|
|
4211
|
+
);
|
|
4212
|
+
}
|
|
4213
|
+
|
|
4214
|
+
const { month, day, year } = parsedDate;
|
|
4215
|
+
|
|
4216
|
+
return [month, day, year].filter(Boolean).join("/");
|
|
4154
4217
|
}
|
|
4155
|
-
|
|
4218
|
+
|
|
4219
|
+
/**
|
|
4220
|
+
* Validates that a date string matches the provided format and represents a real calendar date.
|
|
4221
|
+
*
|
|
4222
|
+
* @param {string} dateStr - Date string to validate.
|
|
4223
|
+
* @param {string} [format="yyyy-mm-dd"] - Format of the date string.
|
|
4224
|
+
* @returns {boolean} True when the date string is valid for the provided format, otherwise false.
|
|
4225
|
+
*/
|
|
4226
|
+
function isValidDate(dateStr, format = "yyyy-mm-dd") {
|
|
4227
|
+
try {
|
|
4228
|
+
if (typeof dateStr !== "string" || !dateStr || format?.length < 8) {
|
|
4229
|
+
return false;
|
|
4230
|
+
}
|
|
4231
|
+
|
|
4232
|
+
if (parseDate(dateStr, format)) {
|
|
4233
|
+
return true;
|
|
4234
|
+
}
|
|
4235
|
+
} catch (error) {
|
|
4236
|
+
return false;
|
|
4237
|
+
}
|
|
4238
|
+
return false;
|
|
4239
|
+
}
|
|
4240
|
+
|
|
4241
|
+
/**
|
|
4242
|
+
* 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.
|
|
4243
|
+
*
|
|
4244
|
+
* @param {Date} date - Date instance to convert to an ISO-like string.
|
|
4245
|
+
* @returns {string} A string in the format "yyyy-mm-dd" representing the provided date.
|
|
4246
|
+
* @throws {Error} Throws an error when the input is not a valid Date instance.
|
|
4247
|
+
*/
|
|
4248
|
+
function toISOFormatString(date) {
|
|
4249
|
+
if (!(date instanceof Date) || Number.isNaN(date.getTime())) {
|
|
4250
|
+
throw new Error(
|
|
4251
|
+
"AuroDatepickerUtilities | toISOFormatString: Input must be a valid Date instance",
|
|
4252
|
+
);
|
|
4253
|
+
}
|
|
4254
|
+
return `${String(date.getFullYear()).padStart(4, "0")}-${String(date.getMonth() + 1).padStart(2, "0")}-${String(date.getDate()).padStart(2, "0")}`;
|
|
4255
|
+
}
|
|
4256
|
+
|
|
4257
|
+
/**
|
|
4258
|
+
* 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.
|
|
4259
|
+
*
|
|
4260
|
+
* @param {String} dateStr - Date string to convert into a Date object.
|
|
4261
|
+
* @param {String} format - Date format used to parse the string when it is not in ISO format.
|
|
4262
|
+
* @returns {Date|null} Returns a Date instance for valid input or null for non-string input.
|
|
4263
|
+
* @throws {Error} Throws when parsing fails for non-ISO string input.
|
|
4264
|
+
*/
|
|
4265
|
+
function stringToDateInstance(dateStr, format = "yyyy-mm-dd") {
|
|
4266
|
+
if (typeof dateStr !== "string") {
|
|
4267
|
+
return null;
|
|
4268
|
+
}
|
|
4269
|
+
|
|
4270
|
+
const { month, day, year } = parseDate(dateStr, format);
|
|
4271
|
+
return new Date(`${year}/${month}/${day}`);
|
|
4272
|
+
}
|
|
4273
|
+
|
|
4274
|
+
const dateFormatter = {
|
|
4275
|
+
parseDate,
|
|
4276
|
+
getDateParts,
|
|
4277
|
+
getDateAsString,
|
|
4278
|
+
toNorthAmericanFormat: toNorthAmericanFormat$1,
|
|
4279
|
+
isValidDate,
|
|
4280
|
+
toISOFormatString,
|
|
4281
|
+
stringToDateInstance,
|
|
4282
|
+
};
|
|
4156
4283
|
|
|
4157
4284
|
// filepath: dateConstraints.mjs
|
|
4158
4285
|
const DATE_UTIL_CONSTRAINTS = {
|
|
@@ -4224,12 +4351,11 @@ class AuroDateUtilitiesBase {
|
|
|
4224
4351
|
/* eslint-disable no-magic-numbers */
|
|
4225
4352
|
|
|
4226
4353
|
class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
4227
|
-
|
|
4228
4354
|
/**
|
|
4229
4355
|
* Returns the current century.
|
|
4230
4356
|
* @returns {String} The current century.
|
|
4231
4357
|
*/
|
|
4232
|
-
getCentury
|
|
4358
|
+
getCentury() {
|
|
4233
4359
|
return String(new Date().getFullYear()).slice(0, 2);
|
|
4234
4360
|
}
|
|
4235
4361
|
|
|
@@ -4238,14 +4364,12 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
4238
4364
|
* @param {String} year - The year to convert to four digits.
|
|
4239
4365
|
* @returns {String} The four digit year.
|
|
4240
4366
|
*/
|
|
4241
|
-
getFourDigitYear
|
|
4242
|
-
|
|
4367
|
+
getFourDigitYear(year) {
|
|
4243
4368
|
const strYear = String(year).trim();
|
|
4244
4369
|
return strYear.length <= 2 ? this.getCentury() + strYear : strYear;
|
|
4245
4370
|
}
|
|
4246
4371
|
|
|
4247
4372
|
constructor() {
|
|
4248
|
-
|
|
4249
4373
|
super();
|
|
4250
4374
|
|
|
4251
4375
|
/**
|
|
@@ -4254,7 +4378,8 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
4254
4378
|
* @param {Object} date2 - Second date to compare.
|
|
4255
4379
|
* @returns {Boolean} Returns true if the dates match.
|
|
4256
4380
|
*/
|
|
4257
|
-
this.datesMatch = (date1, date2) =>
|
|
4381
|
+
this.datesMatch = (date1, date2) =>
|
|
4382
|
+
new Date(date1).getTime() === new Date(date2).getTime();
|
|
4258
4383
|
|
|
4259
4384
|
/**
|
|
4260
4385
|
* Returns true if value passed in is a valid date.
|
|
@@ -4263,53 +4388,41 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
4263
4388
|
* @returns {Boolean}
|
|
4264
4389
|
*/
|
|
4265
4390
|
this.validDateStr = (date, format) => {
|
|
4266
|
-
|
|
4267
4391
|
// The length we expect the date string to be
|
|
4268
|
-
const dateStrLength = format
|
|
4392
|
+
const dateStrLength = format?.length || 0;
|
|
4269
4393
|
|
|
4270
4394
|
// Guard Clause: Date and format are defined
|
|
4271
4395
|
if (typeof date === "undefined" || typeof format === "undefined") {
|
|
4272
|
-
throw new Error(
|
|
4396
|
+
throw new Error(
|
|
4397
|
+
"AuroDatepickerUtilities | validateDateStr: Date and format are required",
|
|
4398
|
+
);
|
|
4273
4399
|
}
|
|
4274
4400
|
|
|
4275
4401
|
// Guard Clause: Date should be of type string
|
|
4276
4402
|
if (typeof date !== "string") {
|
|
4277
|
-
throw new Error(
|
|
4403
|
+
throw new Error(
|
|
4404
|
+
"AuroDatepickerUtilities | validateDateStr: Date must be a string",
|
|
4405
|
+
);
|
|
4278
4406
|
}
|
|
4279
4407
|
|
|
4280
4408
|
// Guard Clause: Format should be of type string
|
|
4281
4409
|
if (typeof format !== "string") {
|
|
4282
|
-
throw new Error(
|
|
4410
|
+
throw new Error(
|
|
4411
|
+
"AuroDatepickerUtilities | validateDateStr: Format must be a string",
|
|
4412
|
+
);
|
|
4283
4413
|
}
|
|
4284
4414
|
|
|
4285
4415
|
// Guard Clause: Length is what we expect it to be
|
|
4286
4416
|
if (date.length !== dateStrLength) {
|
|
4287
4417
|
return false;
|
|
4288
4418
|
}
|
|
4289
|
-
// Get a formatted date string and parse it
|
|
4290
|
-
const dateParts = dateFormatter.parseDate(date, format);
|
|
4291
|
-
|
|
4292
|
-
// Guard Clause: Date parse succeeded
|
|
4293
|
-
if (!dateParts) {
|
|
4294
|
-
return false;
|
|
4295
|
-
}
|
|
4296
|
-
|
|
4297
|
-
// Create the expected date string based on the date parts
|
|
4298
|
-
const expectedDateStr = `${dateParts.month}/${dateParts.day || "01"}/${this.getFourDigitYear(dateParts.year)}`;
|
|
4299
|
-
|
|
4300
|
-
// Generate a date object that we will extract a string date from to compare to the passed in date string
|
|
4301
|
-
const dateObj = new Date(this.getFourDigitYear(dateParts.year), dateParts.month - 1, dateParts.day || 1);
|
|
4302
|
-
|
|
4303
|
-
// Get the date string of the date object we created from the string date
|
|
4304
|
-
const actualDateStr = dateFormatter.getDateAsString(dateObj, "en-US");
|
|
4305
4419
|
|
|
4306
|
-
//
|
|
4307
|
-
|
|
4420
|
+
// Get a formatted date string and parse and validate it
|
|
4421
|
+
try {
|
|
4422
|
+
return Boolean(dateFormatter.parseDate(date, format));
|
|
4423
|
+
} catch (error) {
|
|
4308
4424
|
return false;
|
|
4309
4425
|
}
|
|
4310
|
-
|
|
4311
|
-
// If we passed all other checks, we can assume the date is valid
|
|
4312
|
-
return true;
|
|
4313
4426
|
};
|
|
4314
4427
|
|
|
4315
4428
|
/**
|
|
@@ -4319,10 +4432,11 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
4319
4432
|
* @returns {boolean}
|
|
4320
4433
|
*/
|
|
4321
4434
|
this.dateAndFormatMatch = (value, format) => {
|
|
4322
|
-
|
|
4323
4435
|
// Ensure we have both values we need to do the comparison
|
|
4324
4436
|
if (!value || !format) {
|
|
4325
|
-
throw new Error(
|
|
4437
|
+
throw new Error(
|
|
4438
|
+
"AuroFormValidation | dateFormatMatch: value and format are required",
|
|
4439
|
+
);
|
|
4326
4440
|
}
|
|
4327
4441
|
|
|
4328
4442
|
// If the lengths are different, they cannot match
|
|
@@ -4331,11 +4445,10 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
4331
4445
|
}
|
|
4332
4446
|
|
|
4333
4447
|
// Get the parts of the date
|
|
4334
|
-
const dateParts = dateFormatter.
|
|
4448
|
+
const dateParts = dateFormatter.getDateParts(value, format);
|
|
4335
4449
|
|
|
4336
4450
|
// Validator for day
|
|
4337
4451
|
const dayValueIsValid = (day) => {
|
|
4338
|
-
|
|
4339
4452
|
// Guard clause: if there is no day in the dateParts, we can ignore this check.
|
|
4340
4453
|
if (!dateParts.day) {
|
|
4341
4454
|
return true;
|
|
@@ -4351,7 +4464,9 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
4351
4464
|
|
|
4352
4465
|
// Guard clause: ensure day is a valid integer
|
|
4353
4466
|
if (Number.isNaN(numDay)) {
|
|
4354
|
-
throw new Error(
|
|
4467
|
+
throw new Error(
|
|
4468
|
+
"AuroDatepickerUtilities | dayValueIsValid: Unable to parse day value integer",
|
|
4469
|
+
);
|
|
4355
4470
|
}
|
|
4356
4471
|
|
|
4357
4472
|
// Guard clause: ensure day is within the valid range
|
|
@@ -4365,6 +4480,10 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
4365
4480
|
|
|
4366
4481
|
// Validator for month
|
|
4367
4482
|
const monthValueIsValid = (month) => {
|
|
4483
|
+
// Guard clause: if there is no month in the dateParts, we can ignore this check.
|
|
4484
|
+
if (!dateParts.month) {
|
|
4485
|
+
return true;
|
|
4486
|
+
}
|
|
4368
4487
|
|
|
4369
4488
|
// Guard clause: ensure month exists.
|
|
4370
4489
|
if (!month) {
|
|
@@ -4376,7 +4495,9 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
4376
4495
|
|
|
4377
4496
|
// Guard clause: ensure month is a valid integer
|
|
4378
4497
|
if (Number.isNaN(numMonth)) {
|
|
4379
|
-
throw new Error(
|
|
4498
|
+
throw new Error(
|
|
4499
|
+
"AuroDatepickerUtilities | monthValueIsValid: Unable to parse month value integer",
|
|
4500
|
+
);
|
|
4380
4501
|
}
|
|
4381
4502
|
|
|
4382
4503
|
// Guard clause: ensure month is within the valid range
|
|
@@ -4390,6 +4511,10 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
4390
4511
|
|
|
4391
4512
|
// Validator for year
|
|
4392
4513
|
const yearIsValid = (_year) => {
|
|
4514
|
+
// Guard clause: if there is no year in the dateParts, we can ignore this check.
|
|
4515
|
+
if (!dateParts.year) {
|
|
4516
|
+
return true;
|
|
4517
|
+
}
|
|
4393
4518
|
|
|
4394
4519
|
// Guard clause: ensure year exists.
|
|
4395
4520
|
if (!_year) {
|
|
@@ -4404,7 +4529,9 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
4404
4529
|
|
|
4405
4530
|
// Guard clause: ensure year is a valid integer
|
|
4406
4531
|
if (Number.isNaN(numYear)) {
|
|
4407
|
-
throw new Error(
|
|
4532
|
+
throw new Error(
|
|
4533
|
+
"AuroDatepickerUtilities | yearValueIsValid: Unable to parse year value integer",
|
|
4534
|
+
);
|
|
4408
4535
|
}
|
|
4409
4536
|
|
|
4410
4537
|
// Guard clause: ensure year is within the valid range
|
|
@@ -4420,7 +4547,7 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
4420
4547
|
const checks = [
|
|
4421
4548
|
monthValueIsValid(dateParts.month),
|
|
4422
4549
|
dayValueIsValid(dateParts.day),
|
|
4423
|
-
yearIsValid(dateParts.year)
|
|
4550
|
+
yearIsValid(dateParts.year),
|
|
4424
4551
|
];
|
|
4425
4552
|
|
|
4426
4553
|
// If any of the checks failed, the date format does not match and the result is invalid
|
|
@@ -4454,10 +4581,7 @@ const {
|
|
|
4454
4581
|
} = dateUtilities;
|
|
4455
4582
|
|
|
4456
4583
|
const {
|
|
4457
|
-
toNorthAmericanFormat
|
|
4458
|
-
parseDate,
|
|
4459
|
-
getDateAsString
|
|
4460
|
-
} = dateFormatter;
|
|
4584
|
+
toNorthAmericanFormat} = dateFormatter;
|
|
4461
4585
|
|
|
4462
4586
|
// Copyright (c) Alaska Air. All right reserved. Licensed under the Apache-2.0 license
|
|
4463
4587
|
// See LICENSE in the project root for license information.
|
|
@@ -6672,7 +6796,7 @@ class AuroHelpText extends i$3 {
|
|
|
6672
6796
|
}
|
|
6673
6797
|
}
|
|
6674
6798
|
|
|
6675
|
-
var formkitVersion = '
|
|
6799
|
+
var formkitVersion = '202606022350';
|
|
6676
6800
|
|
|
6677
6801
|
/**
|
|
6678
6802
|
* @license
|