@aurodesignsystem-dev/auro-formkit 0.0.0-pr1489.4 → 0.0.0-pr1489.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/checkbox/demo/customize.min.js +249 -125
- package/components/checkbox/demo/getting-started.min.js +249 -125
- package/components/checkbox/demo/index.min.js +249 -125
- package/components/checkbox/demo/styles.min.css +1 -1
- package/components/checkbox/dist/index.js +249 -125
- package/components/checkbox/dist/registered.js +249 -125
- package/components/combobox/demo/customize.min.js +502 -254
- package/components/combobox/demo/getting-started.min.js +502 -254
- package/components/combobox/demo/index.min.js +502 -254
- package/components/combobox/demo/styles.min.css +1 -1
- package/components/combobox/dist/index.js +502 -254
- package/components/combobox/dist/registered.js +502 -254
- package/components/counter/demo/customize.min.js +250 -126
- package/components/counter/demo/index.min.js +250 -126
- package/components/counter/demo/styles.min.css +1 -1
- package/components/counter/dist/index.js +249 -125
- package/components/counter/dist/registered.js +249 -125
- package/components/datepicker/demo/accessibility.md +9 -6
- package/components/datepicker/demo/api.md +1 -1
- package/components/datepicker/demo/customize.min.js +1544 -527
- package/components/datepicker/demo/index.md +6 -4
- package/components/datepicker/demo/index.min.js +1560 -532
- package/components/datepicker/demo/keyboard-behavior.md +15 -15
- package/components/datepicker/demo/styles.min.css +1 -1
- package/components/datepicker/demo/voiceover.md +5 -3
- package/components/datepicker/demo/why-datepicker.md +2 -2
- package/components/datepicker/dist/index.js +1536 -519
- package/components/datepicker/dist/registered.js +1536 -519
- package/components/datepicker/dist/src/auro-calendar-cell.d.ts +50 -15
- package/components/datepicker/dist/src/auro-calendar-month.d.ts +9 -0
- package/components/datepicker/dist/src/auro-calendar.d.ts +161 -8
- package/components/datepicker/dist/src/auro-datepicker.d.ts +5 -7
- package/components/dropdown/demo/customize.min.js +1 -1
- package/components/dropdown/demo/getting-started.min.js +1 -1
- package/components/dropdown/demo/index.min.js +1 -1
- package/components/dropdown/demo/styles.min.css +1 -1
- package/components/dropdown/dist/index.js +1 -1
- package/components/dropdown/dist/registered.js +1 -1
- package/components/form/demo/customize.min.js +3263 -1378
- package/components/form/demo/getting-started.min.js +3263 -1378
- package/components/form/demo/index.min.js +3263 -1378
- package/components/form/demo/registerDemoDeps.min.js +3263 -1378
- package/components/form/demo/styles.min.css +1 -1
- package/components/input/demo/customize.min.js +249 -125
- package/components/input/demo/getting-started.min.js +249 -125
- package/components/input/demo/index.min.js +249 -125
- package/components/input/demo/styles.min.css +1 -1
- package/components/input/dist/index.js +249 -125
- package/components/input/dist/registered.js +249 -125
- package/components/menu/demo/styles.min.css +1 -1
- package/components/radio/demo/customize.min.js +249 -125
- package/components/radio/demo/getting-started.min.js +249 -125
- package/components/radio/demo/index.min.js +249 -125
- package/components/radio/demo/styles.min.css +1 -1
- package/components/radio/dist/index.js +249 -125
- package/components/radio/dist/registered.js +249 -125
- package/components/select/demo/customize.min.js +250 -126
- package/components/select/demo/getting-started.min.js +250 -126
- package/components/select/demo/index.min.js +250 -126
- package/components/select/demo/styles.min.css +1 -1
- package/components/select/dist/index.js +250 -126
- package/components/select/dist/registered.js +250 -126
- package/custom-elements.json +964 -637
- package/package.json +8 -8
|
@@ -130,109 +130,236 @@ let AuroLibraryRuntimeUtils$4 = class AuroLibraryRuntimeUtils {
|
|
|
130
130
|
}
|
|
131
131
|
};
|
|
132
132
|
|
|
133
|
-
|
|
133
|
+
/**
|
|
134
|
+
* @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.
|
|
135
|
+
* @param {string} dateStr - Date string to parse.
|
|
136
|
+
* @param {string} format - Date format to parse.
|
|
137
|
+
* @returns {{ month?: string, day?: string, year?: string }|undefined}
|
|
138
|
+
*/
|
|
139
|
+
function getDateParts$1(dateStr, format) {
|
|
140
|
+
if (!dateStr) {
|
|
141
|
+
return undefined;
|
|
142
|
+
}
|
|
134
143
|
|
|
135
|
-
|
|
144
|
+
const formatSeparatorMatch = format.match(/[/.-]/);
|
|
145
|
+
let valueParts;
|
|
146
|
+
let formatParts;
|
|
136
147
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
148
|
+
if (formatSeparatorMatch) {
|
|
149
|
+
const separator = formatSeparatorMatch[0];
|
|
150
|
+
valueParts = dateStr.split(separator);
|
|
151
|
+
formatParts = format.split(separator);
|
|
152
|
+
} else {
|
|
153
|
+
if (dateStr.match(/[/.-]/)) {
|
|
154
|
+
throw new Error(
|
|
155
|
+
"AuroDatepickerUtilities | parseDate: Date string has no separators",
|
|
156
|
+
);
|
|
157
|
+
}
|
|
144
158
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
159
|
+
if (dateStr.length !== format.length) {
|
|
160
|
+
throw new Error(
|
|
161
|
+
"AuroDatepickerUtilities | parseDate: Date string and format length do not match",
|
|
162
|
+
);
|
|
163
|
+
}
|
|
149
164
|
|
|
150
|
-
|
|
151
|
-
|
|
165
|
+
valueParts = [dateStr];
|
|
166
|
+
formatParts = [format];
|
|
167
|
+
}
|
|
152
168
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
169
|
+
if (valueParts.length !== formatParts.length) {
|
|
170
|
+
throw new Error(
|
|
171
|
+
`AuroDatepickerUtilities | parseDate: Date string and format do not match : ${dateStr} vs ${format}`,
|
|
172
|
+
);
|
|
173
|
+
}
|
|
156
174
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
throw new Error('AuroDatepickerUtilities | parseDate: Date string and format length do not match');
|
|
160
|
-
}
|
|
175
|
+
const result = formatParts.reduce((acc, part, index) => {
|
|
176
|
+
const value = valueParts[index];
|
|
161
177
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
178
|
+
if (/m/iu.test(part) && part.length === value.length) {
|
|
179
|
+
acc.month = value;
|
|
180
|
+
} else if (/d/iu.test(part) && part.length === value.length) {
|
|
181
|
+
acc.day = value;
|
|
182
|
+
} else if (/y/iu.test(part) && part.length === value.length) {
|
|
183
|
+
acc.year = value;
|
|
184
|
+
}
|
|
165
185
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
} else if ((/d/iu).test(part)) {
|
|
169
|
-
acc.day = value;
|
|
170
|
-
} else if ((/y/iu).test(part)) {
|
|
171
|
-
acc.year = value;
|
|
172
|
-
}
|
|
186
|
+
return acc;
|
|
187
|
+
}, {});
|
|
173
188
|
|
|
174
|
-
|
|
175
|
-
|
|
189
|
+
if (!result.month && !result.day && !result.year) {
|
|
190
|
+
throw new Error(
|
|
191
|
+
"AuroDatepickerUtilities | parseDate: Unable to parse date string",
|
|
192
|
+
);
|
|
193
|
+
}
|
|
176
194
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
return result;
|
|
180
|
-
}
|
|
195
|
+
return result;
|
|
196
|
+
}
|
|
181
197
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
198
|
+
function isCalendarDate$1(year, month, day) {
|
|
199
|
+
let yearNumber = Number(year);
|
|
200
|
+
const monthNumber = Number(month);
|
|
201
|
+
const dayNumber = Number(day);
|
|
185
202
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
year: "numeric",
|
|
194
|
-
month: "2-digit",
|
|
195
|
-
day: "2-digit",
|
|
196
|
-
});
|
|
203
|
+
if (
|
|
204
|
+
!Number.isInteger(yearNumber) ||
|
|
205
|
+
!Number.isInteger(monthNumber) ||
|
|
206
|
+
!Number.isInteger(dayNumber)
|
|
207
|
+
) {
|
|
208
|
+
return false;
|
|
209
|
+
}
|
|
197
210
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
this.toNorthAmericanFormat = (dateStr, format) => {
|
|
211
|
+
// 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.
|
|
212
|
+
if (yearNumber < 100 && yearNumber >= 50) {
|
|
213
|
+
yearNumber += 1900;
|
|
214
|
+
} else if (yearNumber < 50) {
|
|
215
|
+
yearNumber += 2000;
|
|
216
|
+
}
|
|
205
217
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
}
|
|
218
|
+
const stringified = `${String(yearNumber).padStart(4, "0")}-${String(monthNumber).padStart(2, "0")}-${String(dayNumber).padStart(2, "0")}`;
|
|
219
|
+
const date = new Date(stringified.replace(/[.-]/g, "/"));
|
|
209
220
|
|
|
210
|
-
|
|
221
|
+
return (
|
|
222
|
+
!Number.isNaN(date.getTime()) && toISOFormatString$1(date) === stringified
|
|
223
|
+
);
|
|
224
|
+
}
|
|
211
225
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
226
|
+
/**
|
|
227
|
+
* @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).
|
|
228
|
+
*
|
|
229
|
+
* Partial formats are supported: components absent from `format` default to `year → "0"`,
|
|
230
|
+
* `month → "01"`, `day → "01"` for calendar validation only. The returned object contains
|
|
231
|
+
* only the fields actually present in the format string — missing fields are never injected.
|
|
232
|
+
* @param {string} dateStr - Date string to parse.
|
|
233
|
+
* @param {string} format - Date format to parse.
|
|
234
|
+
* @returns {{ month?: string, day?: string, year?: string }|undefined}
|
|
235
|
+
* @throws {Error} Throws when the parsed result does not represent a valid calendar date.
|
|
236
|
+
*/
|
|
237
|
+
function parseDate$1(dateStr, format = "mm/dd/yyyy") {
|
|
238
|
+
if (!dateStr || !format) {
|
|
239
|
+
return undefined;
|
|
240
|
+
}
|
|
241
|
+
const result = getDateParts$1(dateStr.trim(), format);
|
|
242
|
+
|
|
243
|
+
if (!result) {
|
|
244
|
+
return undefined;
|
|
245
|
+
}
|
|
215
246
|
|
|
216
|
-
|
|
247
|
+
const lowerFormat = format.toLowerCase();
|
|
248
|
+
const year = lowerFormat.includes("yy") ? result.year : "0";
|
|
249
|
+
const month = lowerFormat.includes("mm") ? result.month : "01";
|
|
250
|
+
const day = lowerFormat.includes("dd") ? result.day : "01";
|
|
217
251
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
}
|
|
252
|
+
if (isCalendarDate$1(year, month, day)) {
|
|
253
|
+
return result;
|
|
254
|
+
}
|
|
222
255
|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
256
|
+
throw new Error(
|
|
257
|
+
`AuroDatepickerUtilities | parseDate: Date string is not a valid date ${JSON.stringify(result)} with format ${format}`,
|
|
258
|
+
);
|
|
259
|
+
}
|
|
226
260
|
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
261
|
+
/**
|
|
262
|
+
* Convert a date object to string format.
|
|
263
|
+
* @param {Object} date - Date to convert to string.
|
|
264
|
+
* @param {String} locale - Optional locale to use for the date string. Defaults to user's locale.
|
|
265
|
+
* @returns {String} Returns the date as a string.
|
|
266
|
+
*/
|
|
267
|
+
function getDateAsString$1(date, locale = undefined) {
|
|
268
|
+
return date.toLocaleDateString(locale, {
|
|
269
|
+
year: "numeric",
|
|
270
|
+
month: "2-digit",
|
|
271
|
+
day: "2-digit",
|
|
272
|
+
});
|
|
273
|
+
}
|
|
230
274
|
|
|
231
|
-
|
|
232
|
-
|
|
275
|
+
/**
|
|
276
|
+
* Converts a date string to a North American date format.
|
|
277
|
+
* @param {String} dateStr - Date to validate.
|
|
278
|
+
* @param {String} format - Date format to validate against.
|
|
279
|
+
* @returns {String}
|
|
280
|
+
*/
|
|
281
|
+
function toNorthAmericanFormat$3(dateStr, format) {
|
|
282
|
+
if (format === "mm/dd/yyyy") {
|
|
283
|
+
return dateStr;
|
|
233
284
|
}
|
|
285
|
+
|
|
286
|
+
const parsedDate = parseDate$1(dateStr, format);
|
|
287
|
+
|
|
288
|
+
if (!parsedDate) {
|
|
289
|
+
throw new Error(
|
|
290
|
+
"AuroDatepickerUtilities | toNorthAmericanFormat: Unable to parse date string",
|
|
291
|
+
);
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
const { month, day, year } = parsedDate;
|
|
295
|
+
|
|
296
|
+
return [month, day, year].filter(Boolean).join("/");
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* Validates that a date string matches the provided format and represents a real calendar date.
|
|
301
|
+
*
|
|
302
|
+
* @param {string} dateStr - Date string to validate.
|
|
303
|
+
* @param {string} [format="yyyy-mm-dd"] - Format of the date string.
|
|
304
|
+
* @returns {boolean} True when the date string is valid for the provided format, otherwise false.
|
|
305
|
+
*/
|
|
306
|
+
function isValidDate$1(dateStr, format = "yyyy-mm-dd") {
|
|
307
|
+
try {
|
|
308
|
+
if (typeof dateStr !== "string" || !dateStr || format?.length < 8) {
|
|
309
|
+
return false;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
if (parseDate$1(dateStr, format)) {
|
|
313
|
+
return true;
|
|
314
|
+
}
|
|
315
|
+
} catch (error) {
|
|
316
|
+
return false;
|
|
317
|
+
}
|
|
318
|
+
return false;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* 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.
|
|
323
|
+
*
|
|
324
|
+
* @param {Date} date - Date instance to convert to an ISO-like string.
|
|
325
|
+
* @returns {string} A string in the format "yyyy-mm-dd" representing the provided date.
|
|
326
|
+
* @throws {Error} Throws an error when the input is not a valid Date instance.
|
|
327
|
+
*/
|
|
328
|
+
function toISOFormatString$1(date) {
|
|
329
|
+
if (!(date instanceof Date) || Number.isNaN(date.getTime())) {
|
|
330
|
+
throw new Error(
|
|
331
|
+
"AuroDatepickerUtilities | toISOFormatString: Input must be a valid Date instance",
|
|
332
|
+
);
|
|
333
|
+
}
|
|
334
|
+
return `${String(date.getFullYear()).padStart(4, "0")}-${String(date.getMonth() + 1).padStart(2, "0")}-${String(date.getDate()).padStart(2, "0")}`;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* 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.
|
|
339
|
+
*
|
|
340
|
+
* @param {String} dateStr - Date string to convert into a Date object.
|
|
341
|
+
* @param {String} format - Date format used to parse the string when it is not in ISO format.
|
|
342
|
+
* @returns {Date|null} Returns a Date instance for valid input or null for non-string input.
|
|
343
|
+
* @throws {Error} Throws when parsing fails for non-ISO string input.
|
|
344
|
+
*/
|
|
345
|
+
function stringToDateInstance$1(dateStr, format = "yyyy-mm-dd") {
|
|
346
|
+
if (typeof dateStr !== "string") {
|
|
347
|
+
return null;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
const { month, day, year } = parseDate$1(dateStr, format);
|
|
351
|
+
return new Date(`${year}/${month}/${day}`);
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
const dateFormatter$1 = {
|
|
355
|
+
parseDate: parseDate$1,
|
|
356
|
+
getDateParts: getDateParts$1,
|
|
357
|
+
getDateAsString: getDateAsString$1,
|
|
358
|
+
toNorthAmericanFormat: toNorthAmericanFormat$3,
|
|
359
|
+
isValidDate: isValidDate$1,
|
|
360
|
+
toISOFormatString: toISOFormatString$1,
|
|
361
|
+
stringToDateInstance: stringToDateInstance$1,
|
|
234
362
|
};
|
|
235
|
-
const dateFormatter$1 = new DateFormatter$1();
|
|
236
363
|
|
|
237
364
|
// filepath: dateConstraints.mjs
|
|
238
365
|
const DATE_UTIL_CONSTRAINTS$1 = {
|
|
@@ -304,12 +431,11 @@ let AuroDateUtilitiesBase$1 = class AuroDateUtilitiesBase {
|
|
|
304
431
|
/* eslint-disable no-magic-numbers */
|
|
305
432
|
|
|
306
433
|
let AuroDateUtilities$1 = class AuroDateUtilities extends AuroDateUtilitiesBase$1 {
|
|
307
|
-
|
|
308
434
|
/**
|
|
309
435
|
* Returns the current century.
|
|
310
436
|
* @returns {String} The current century.
|
|
311
437
|
*/
|
|
312
|
-
getCentury
|
|
438
|
+
getCentury() {
|
|
313
439
|
return String(new Date().getFullYear()).slice(0, 2);
|
|
314
440
|
}
|
|
315
441
|
|
|
@@ -318,14 +444,12 @@ let AuroDateUtilities$1 = class AuroDateUtilities extends AuroDateUtilitiesBase$
|
|
|
318
444
|
* @param {String} year - The year to convert to four digits.
|
|
319
445
|
* @returns {String} The four digit year.
|
|
320
446
|
*/
|
|
321
|
-
getFourDigitYear
|
|
322
|
-
|
|
447
|
+
getFourDigitYear(year) {
|
|
323
448
|
const strYear = String(year).trim();
|
|
324
449
|
return strYear.length <= 2 ? this.getCentury() + strYear : strYear;
|
|
325
450
|
}
|
|
326
451
|
|
|
327
452
|
constructor() {
|
|
328
|
-
|
|
329
453
|
super();
|
|
330
454
|
|
|
331
455
|
/**
|
|
@@ -334,7 +458,8 @@ let AuroDateUtilities$1 = class AuroDateUtilities extends AuroDateUtilitiesBase$
|
|
|
334
458
|
* @param {Object} date2 - Second date to compare.
|
|
335
459
|
* @returns {Boolean} Returns true if the dates match.
|
|
336
460
|
*/
|
|
337
|
-
this.datesMatch = (date1, date2) =>
|
|
461
|
+
this.datesMatch = (date1, date2) =>
|
|
462
|
+
new Date(date1).getTime() === new Date(date2).getTime();
|
|
338
463
|
|
|
339
464
|
/**
|
|
340
465
|
* Returns true if value passed in is a valid date.
|
|
@@ -343,53 +468,41 @@ let AuroDateUtilities$1 = class AuroDateUtilities extends AuroDateUtilitiesBase$
|
|
|
343
468
|
* @returns {Boolean}
|
|
344
469
|
*/
|
|
345
470
|
this.validDateStr = (date, format) => {
|
|
346
|
-
|
|
347
471
|
// The length we expect the date string to be
|
|
348
|
-
const dateStrLength = format
|
|
472
|
+
const dateStrLength = format?.length || 0;
|
|
349
473
|
|
|
350
474
|
// Guard Clause: Date and format are defined
|
|
351
475
|
if (typeof date === "undefined" || typeof format === "undefined") {
|
|
352
|
-
throw new Error(
|
|
476
|
+
throw new Error(
|
|
477
|
+
"AuroDatepickerUtilities | validateDateStr: Date and format are required",
|
|
478
|
+
);
|
|
353
479
|
}
|
|
354
480
|
|
|
355
481
|
// Guard Clause: Date should be of type string
|
|
356
482
|
if (typeof date !== "string") {
|
|
357
|
-
throw new Error(
|
|
483
|
+
throw new Error(
|
|
484
|
+
"AuroDatepickerUtilities | validateDateStr: Date must be a string",
|
|
485
|
+
);
|
|
358
486
|
}
|
|
359
487
|
|
|
360
488
|
// Guard Clause: Format should be of type string
|
|
361
489
|
if (typeof format !== "string") {
|
|
362
|
-
throw new Error(
|
|
490
|
+
throw new Error(
|
|
491
|
+
"AuroDatepickerUtilities | validateDateStr: Format must be a string",
|
|
492
|
+
);
|
|
363
493
|
}
|
|
364
494
|
|
|
365
495
|
// Guard Clause: Length is what we expect it to be
|
|
366
496
|
if (date.length !== dateStrLength) {
|
|
367
497
|
return false;
|
|
368
498
|
}
|
|
369
|
-
// Get a formatted date string and parse it
|
|
370
|
-
const dateParts = dateFormatter$1.parseDate(date, format);
|
|
371
|
-
|
|
372
|
-
// Guard Clause: Date parse succeeded
|
|
373
|
-
if (!dateParts) {
|
|
374
|
-
return false;
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
// Create the expected date string based on the date parts
|
|
378
|
-
const expectedDateStr = `${dateParts.month}/${dateParts.day || "01"}/${this.getFourDigitYear(dateParts.year)}`;
|
|
379
499
|
|
|
380
|
-
//
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
const actualDateStr = dateFormatter$1.getDateAsString(dateObj, "en-US");
|
|
385
|
-
|
|
386
|
-
// Guard Clause: Generated date matches date string input
|
|
387
|
-
if (expectedDateStr !== actualDateStr) {
|
|
500
|
+
// Get a formatted date string and parse and validate it
|
|
501
|
+
try {
|
|
502
|
+
return Boolean(dateFormatter$1.parseDate(date, format));
|
|
503
|
+
} catch (error) {
|
|
388
504
|
return false;
|
|
389
505
|
}
|
|
390
|
-
|
|
391
|
-
// If we passed all other checks, we can assume the date is valid
|
|
392
|
-
return true;
|
|
393
506
|
};
|
|
394
507
|
|
|
395
508
|
/**
|
|
@@ -399,10 +512,11 @@ let AuroDateUtilities$1 = class AuroDateUtilities extends AuroDateUtilitiesBase$
|
|
|
399
512
|
* @returns {boolean}
|
|
400
513
|
*/
|
|
401
514
|
this.dateAndFormatMatch = (value, format) => {
|
|
402
|
-
|
|
403
515
|
// Ensure we have both values we need to do the comparison
|
|
404
516
|
if (!value || !format) {
|
|
405
|
-
throw new Error(
|
|
517
|
+
throw new Error(
|
|
518
|
+
"AuroFormValidation | dateFormatMatch: value and format are required",
|
|
519
|
+
);
|
|
406
520
|
}
|
|
407
521
|
|
|
408
522
|
// If the lengths are different, they cannot match
|
|
@@ -411,11 +525,10 @@ let AuroDateUtilities$1 = class AuroDateUtilities extends AuroDateUtilitiesBase$
|
|
|
411
525
|
}
|
|
412
526
|
|
|
413
527
|
// Get the parts of the date
|
|
414
|
-
const dateParts = dateFormatter$1.
|
|
528
|
+
const dateParts = dateFormatter$1.getDateParts(value, format);
|
|
415
529
|
|
|
416
530
|
// Validator for day
|
|
417
531
|
const dayValueIsValid = (day) => {
|
|
418
|
-
|
|
419
532
|
// Guard clause: if there is no day in the dateParts, we can ignore this check.
|
|
420
533
|
if (!dateParts.day) {
|
|
421
534
|
return true;
|
|
@@ -431,7 +544,9 @@ let AuroDateUtilities$1 = class AuroDateUtilities extends AuroDateUtilitiesBase$
|
|
|
431
544
|
|
|
432
545
|
// Guard clause: ensure day is a valid integer
|
|
433
546
|
if (Number.isNaN(numDay)) {
|
|
434
|
-
throw new Error(
|
|
547
|
+
throw new Error(
|
|
548
|
+
"AuroDatepickerUtilities | dayValueIsValid: Unable to parse day value integer",
|
|
549
|
+
);
|
|
435
550
|
}
|
|
436
551
|
|
|
437
552
|
// Guard clause: ensure day is within the valid range
|
|
@@ -445,6 +560,10 @@ let AuroDateUtilities$1 = class AuroDateUtilities extends AuroDateUtilitiesBase$
|
|
|
445
560
|
|
|
446
561
|
// Validator for month
|
|
447
562
|
const monthValueIsValid = (month) => {
|
|
563
|
+
// Guard clause: if there is no month in the dateParts, we can ignore this check.
|
|
564
|
+
if (!dateParts.month) {
|
|
565
|
+
return true;
|
|
566
|
+
}
|
|
448
567
|
|
|
449
568
|
// Guard clause: ensure month exists.
|
|
450
569
|
if (!month) {
|
|
@@ -456,7 +575,9 @@ let AuroDateUtilities$1 = class AuroDateUtilities extends AuroDateUtilitiesBase$
|
|
|
456
575
|
|
|
457
576
|
// Guard clause: ensure month is a valid integer
|
|
458
577
|
if (Number.isNaN(numMonth)) {
|
|
459
|
-
throw new Error(
|
|
578
|
+
throw new Error(
|
|
579
|
+
"AuroDatepickerUtilities | monthValueIsValid: Unable to parse month value integer",
|
|
580
|
+
);
|
|
460
581
|
}
|
|
461
582
|
|
|
462
583
|
// Guard clause: ensure month is within the valid range
|
|
@@ -470,6 +591,10 @@ let AuroDateUtilities$1 = class AuroDateUtilities extends AuroDateUtilitiesBase$
|
|
|
470
591
|
|
|
471
592
|
// Validator for year
|
|
472
593
|
const yearIsValid = (_year) => {
|
|
594
|
+
// Guard clause: if there is no year in the dateParts, we can ignore this check.
|
|
595
|
+
if (!dateParts.year) {
|
|
596
|
+
return true;
|
|
597
|
+
}
|
|
473
598
|
|
|
474
599
|
// Guard clause: ensure year exists.
|
|
475
600
|
if (!_year) {
|
|
@@ -484,7 +609,9 @@ let AuroDateUtilities$1 = class AuroDateUtilities extends AuroDateUtilitiesBase$
|
|
|
484
609
|
|
|
485
610
|
// Guard clause: ensure year is a valid integer
|
|
486
611
|
if (Number.isNaN(numYear)) {
|
|
487
|
-
throw new Error(
|
|
612
|
+
throw new Error(
|
|
613
|
+
"AuroDatepickerUtilities | yearValueIsValid: Unable to parse year value integer",
|
|
614
|
+
);
|
|
488
615
|
}
|
|
489
616
|
|
|
490
617
|
// Guard clause: ensure year is within the valid range
|
|
@@ -500,7 +627,7 @@ let AuroDateUtilities$1 = class AuroDateUtilities extends AuroDateUtilitiesBase$
|
|
|
500
627
|
const checks = [
|
|
501
628
|
monthValueIsValid(dateParts.month),
|
|
502
629
|
dayValueIsValid(dateParts.day),
|
|
503
|
-
yearIsValid(dateParts.year)
|
|
630
|
+
yearIsValid(dateParts.year),
|
|
504
631
|
];
|
|
505
632
|
|
|
506
633
|
// If any of the checks failed, the date format does not match and the result is invalid
|
|
@@ -534,10 +661,7 @@ const {
|
|
|
534
661
|
} = dateUtilities$1;
|
|
535
662
|
|
|
536
663
|
const {
|
|
537
|
-
toNorthAmericanFormat: toNorthAmericanFormat$1
|
|
538
|
-
parseDate: parseDate$1,
|
|
539
|
-
getDateAsString: getDateAsString$1
|
|
540
|
-
} = dateFormatter$1;
|
|
664
|
+
toNorthAmericanFormat: toNorthAmericanFormat$2} = dateFormatter$1;
|
|
541
665
|
|
|
542
666
|
// Copyright (c) Alaska Air. All right reserved. Licensed under the Apache-2.0 license
|
|
543
667
|
// See LICENSE in the project root for license information.
|
|
@@ -774,13 +898,13 @@ let AuroFormValidation$1 = class AuroFormValidation {
|
|
|
774
898
|
}
|
|
775
899
|
|
|
776
900
|
// Perform the rest of the validation
|
|
777
|
-
const formattedValue = toNorthAmericanFormat$
|
|
901
|
+
const formattedValue = toNorthAmericanFormat$2(elem.value, elem.format);
|
|
778
902
|
const valueDate = new Date(formattedValue);
|
|
779
903
|
|
|
780
904
|
// // Validate max date
|
|
781
905
|
if (elem.max?.length === elem.lengthForType) {
|
|
782
906
|
|
|
783
|
-
const maxDate = new Date(toNorthAmericanFormat$
|
|
907
|
+
const maxDate = new Date(toNorthAmericanFormat$2(elem.max, elem.format));
|
|
784
908
|
|
|
785
909
|
if (valueDate > maxDate) {
|
|
786
910
|
elem.validity = 'rangeOverflow';
|
|
@@ -791,7 +915,7 @@ let AuroFormValidation$1 = class AuroFormValidation {
|
|
|
791
915
|
|
|
792
916
|
// Validate min date
|
|
793
917
|
if (elem.min?.length === elem.lengthForType) {
|
|
794
|
-
const minDate = new Date(toNorthAmericanFormat$
|
|
918
|
+
const minDate = new Date(toNorthAmericanFormat$2(elem.min, elem.format));
|
|
795
919
|
|
|
796
920
|
if (valueDate < minDate) {
|
|
797
921
|
elem.validity = 'rangeUnderflow';
|
|
@@ -5211,7 +5335,7 @@ let AuroHelpText$2 = class AuroHelpText extends LitElement {
|
|
|
5211
5335
|
}
|
|
5212
5336
|
};
|
|
5213
5337
|
|
|
5214
|
-
var formkitVersion$2 = '
|
|
5338
|
+
var formkitVersion$2 = '202606012139';
|
|
5215
5339
|
|
|
5216
5340
|
let AuroElement$2 = class AuroElement extends LitElement {
|
|
5217
5341
|
static get properties() {
|
|
@@ -10547,109 +10671,236 @@ class AuroInputUtilities {
|
|
|
10547
10671
|
}
|
|
10548
10672
|
}
|
|
10549
10673
|
|
|
10550
|
-
|
|
10674
|
+
/**
|
|
10675
|
+
* @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.
|
|
10676
|
+
* @param {string} dateStr - Date string to parse.
|
|
10677
|
+
* @param {string} format - Date format to parse.
|
|
10678
|
+
* @returns {{ month?: string, day?: string, year?: string }|undefined}
|
|
10679
|
+
*/
|
|
10680
|
+
function getDateParts(dateStr, format) {
|
|
10681
|
+
if (!dateStr) {
|
|
10682
|
+
return undefined;
|
|
10683
|
+
}
|
|
10551
10684
|
|
|
10552
|
-
|
|
10685
|
+
const formatSeparatorMatch = format.match(/[/.-]/);
|
|
10686
|
+
let valueParts;
|
|
10687
|
+
let formatParts;
|
|
10553
10688
|
|
|
10554
|
-
|
|
10555
|
-
|
|
10556
|
-
|
|
10557
|
-
|
|
10558
|
-
|
|
10559
|
-
|
|
10560
|
-
|
|
10689
|
+
if (formatSeparatorMatch) {
|
|
10690
|
+
const separator = formatSeparatorMatch[0];
|
|
10691
|
+
valueParts = dateStr.split(separator);
|
|
10692
|
+
formatParts = format.split(separator);
|
|
10693
|
+
} else {
|
|
10694
|
+
if (dateStr.match(/[/.-]/)) {
|
|
10695
|
+
throw new Error(
|
|
10696
|
+
"AuroDatepickerUtilities | parseDate: Date string has no separators",
|
|
10697
|
+
);
|
|
10698
|
+
}
|
|
10561
10699
|
|
|
10562
|
-
|
|
10563
|
-
|
|
10564
|
-
|
|
10565
|
-
|
|
10700
|
+
if (dateStr.length !== format.length) {
|
|
10701
|
+
throw new Error(
|
|
10702
|
+
"AuroDatepickerUtilities | parseDate: Date string and format length do not match",
|
|
10703
|
+
);
|
|
10704
|
+
}
|
|
10566
10705
|
|
|
10567
|
-
|
|
10568
|
-
|
|
10706
|
+
valueParts = [dateStr];
|
|
10707
|
+
formatParts = [format];
|
|
10708
|
+
}
|
|
10569
10709
|
|
|
10570
|
-
|
|
10571
|
-
|
|
10572
|
-
|
|
10710
|
+
if (valueParts.length !== formatParts.length) {
|
|
10711
|
+
throw new Error(
|
|
10712
|
+
`AuroDatepickerUtilities | parseDate: Date string and format do not match : ${dateStr} vs ${format}`,
|
|
10713
|
+
);
|
|
10714
|
+
}
|
|
10573
10715
|
|
|
10574
|
-
|
|
10575
|
-
|
|
10576
|
-
throw new Error('AuroDatepickerUtilities | parseDate: Date string and format length do not match');
|
|
10577
|
-
}
|
|
10716
|
+
const result = formatParts.reduce((acc, part, index) => {
|
|
10717
|
+
const value = valueParts[index];
|
|
10578
10718
|
|
|
10579
|
-
|
|
10580
|
-
|
|
10581
|
-
|
|
10719
|
+
if (/m/iu.test(part) && part.length === value.length) {
|
|
10720
|
+
acc.month = value;
|
|
10721
|
+
} else if (/d/iu.test(part) && part.length === value.length) {
|
|
10722
|
+
acc.day = value;
|
|
10723
|
+
} else if (/y/iu.test(part) && part.length === value.length) {
|
|
10724
|
+
acc.year = value;
|
|
10725
|
+
}
|
|
10582
10726
|
|
|
10583
|
-
|
|
10584
|
-
|
|
10585
|
-
} else if ((/d/iu).test(part)) {
|
|
10586
|
-
acc.day = value;
|
|
10587
|
-
} else if ((/y/iu).test(part)) {
|
|
10588
|
-
acc.year = value;
|
|
10589
|
-
}
|
|
10727
|
+
return acc;
|
|
10728
|
+
}, {});
|
|
10590
10729
|
|
|
10591
|
-
|
|
10592
|
-
|
|
10730
|
+
if (!result.month && !result.day && !result.year) {
|
|
10731
|
+
throw new Error(
|
|
10732
|
+
"AuroDatepickerUtilities | parseDate: Unable to parse date string",
|
|
10733
|
+
);
|
|
10734
|
+
}
|
|
10593
10735
|
|
|
10594
|
-
|
|
10595
|
-
|
|
10596
|
-
return result;
|
|
10597
|
-
}
|
|
10736
|
+
return result;
|
|
10737
|
+
}
|
|
10598
10738
|
|
|
10599
|
-
|
|
10600
|
-
|
|
10601
|
-
|
|
10739
|
+
function isCalendarDate(year, month, day) {
|
|
10740
|
+
let yearNumber = Number(year);
|
|
10741
|
+
const monthNumber = Number(month);
|
|
10742
|
+
const dayNumber = Number(day);
|
|
10602
10743
|
|
|
10603
|
-
|
|
10604
|
-
|
|
10605
|
-
|
|
10606
|
-
|
|
10607
|
-
|
|
10608
|
-
|
|
10609
|
-
|
|
10610
|
-
year: "numeric",
|
|
10611
|
-
month: "2-digit",
|
|
10612
|
-
day: "2-digit",
|
|
10613
|
-
});
|
|
10744
|
+
if (
|
|
10745
|
+
!Number.isInteger(yearNumber) ||
|
|
10746
|
+
!Number.isInteger(monthNumber) ||
|
|
10747
|
+
!Number.isInteger(dayNumber)
|
|
10748
|
+
) {
|
|
10749
|
+
return false;
|
|
10750
|
+
}
|
|
10614
10751
|
|
|
10615
|
-
|
|
10616
|
-
|
|
10617
|
-
|
|
10618
|
-
|
|
10619
|
-
|
|
10620
|
-
|
|
10621
|
-
this.toNorthAmericanFormat = (dateStr, format) => {
|
|
10752
|
+
// 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.
|
|
10753
|
+
if (yearNumber < 100 && yearNumber >= 50) {
|
|
10754
|
+
yearNumber += 1900;
|
|
10755
|
+
} else if (yearNumber < 50) {
|
|
10756
|
+
yearNumber += 2000;
|
|
10757
|
+
}
|
|
10622
10758
|
|
|
10623
|
-
|
|
10624
|
-
|
|
10625
|
-
}
|
|
10759
|
+
const stringified = `${String(yearNumber).padStart(4, "0")}-${String(monthNumber).padStart(2, "0")}-${String(dayNumber).padStart(2, "0")}`;
|
|
10760
|
+
const date = new Date(stringified.replace(/[.-]/g, "/"));
|
|
10626
10761
|
|
|
10627
|
-
|
|
10762
|
+
return (
|
|
10763
|
+
!Number.isNaN(date.getTime()) && toISOFormatString(date) === stringified
|
|
10764
|
+
);
|
|
10765
|
+
}
|
|
10628
10766
|
|
|
10629
|
-
|
|
10630
|
-
|
|
10631
|
-
|
|
10767
|
+
/**
|
|
10768
|
+
* @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).
|
|
10769
|
+
*
|
|
10770
|
+
* Partial formats are supported: components absent from `format` default to `year → "0"`,
|
|
10771
|
+
* `month → "01"`, `day → "01"` for calendar validation only. The returned object contains
|
|
10772
|
+
* only the fields actually present in the format string — missing fields are never injected.
|
|
10773
|
+
* @param {string} dateStr - Date string to parse.
|
|
10774
|
+
* @param {string} format - Date format to parse.
|
|
10775
|
+
* @returns {{ month?: string, day?: string, year?: string }|undefined}
|
|
10776
|
+
* @throws {Error} Throws when the parsed result does not represent a valid calendar date.
|
|
10777
|
+
*/
|
|
10778
|
+
function parseDate(dateStr, format = "mm/dd/yyyy") {
|
|
10779
|
+
if (!dateStr || !format) {
|
|
10780
|
+
return undefined;
|
|
10781
|
+
}
|
|
10782
|
+
const result = getDateParts(dateStr.trim(), format);
|
|
10783
|
+
|
|
10784
|
+
if (!result) {
|
|
10785
|
+
return undefined;
|
|
10786
|
+
}
|
|
10632
10787
|
|
|
10633
|
-
|
|
10788
|
+
const lowerFormat = format.toLowerCase();
|
|
10789
|
+
const year = lowerFormat.includes("yy") ? result.year : "0";
|
|
10790
|
+
const month = lowerFormat.includes("mm") ? result.month : "01";
|
|
10791
|
+
const day = lowerFormat.includes("dd") ? result.day : "01";
|
|
10634
10792
|
|
|
10635
|
-
|
|
10636
|
-
|
|
10637
|
-
|
|
10638
|
-
}
|
|
10793
|
+
if (isCalendarDate(year, month, day)) {
|
|
10794
|
+
return result;
|
|
10795
|
+
}
|
|
10639
10796
|
|
|
10640
|
-
|
|
10641
|
-
|
|
10642
|
-
|
|
10797
|
+
throw new Error(
|
|
10798
|
+
`AuroDatepickerUtilities | parseDate: Date string is not a valid date ${JSON.stringify(result)} with format ${format}`,
|
|
10799
|
+
);
|
|
10800
|
+
}
|
|
10643
10801
|
|
|
10644
|
-
|
|
10645
|
-
|
|
10646
|
-
|
|
10802
|
+
/**
|
|
10803
|
+
* Convert a date object to string format.
|
|
10804
|
+
* @param {Object} date - Date to convert to string.
|
|
10805
|
+
* @param {String} locale - Optional locale to use for the date string. Defaults to user's locale.
|
|
10806
|
+
* @returns {String} Returns the date as a string.
|
|
10807
|
+
*/
|
|
10808
|
+
function getDateAsString(date, locale = undefined) {
|
|
10809
|
+
return date.toLocaleDateString(locale, {
|
|
10810
|
+
year: "numeric",
|
|
10811
|
+
month: "2-digit",
|
|
10812
|
+
day: "2-digit",
|
|
10813
|
+
});
|
|
10814
|
+
}
|
|
10647
10815
|
|
|
10648
|
-
|
|
10649
|
-
|
|
10816
|
+
/**
|
|
10817
|
+
* Converts a date string to a North American date format.
|
|
10818
|
+
* @param {String} dateStr - Date to validate.
|
|
10819
|
+
* @param {String} format - Date format to validate against.
|
|
10820
|
+
* @returns {String}
|
|
10821
|
+
*/
|
|
10822
|
+
function toNorthAmericanFormat$1(dateStr, format) {
|
|
10823
|
+
if (format === "mm/dd/yyyy") {
|
|
10824
|
+
return dateStr;
|
|
10650
10825
|
}
|
|
10826
|
+
|
|
10827
|
+
const parsedDate = parseDate(dateStr, format);
|
|
10828
|
+
|
|
10829
|
+
if (!parsedDate) {
|
|
10830
|
+
throw new Error(
|
|
10831
|
+
"AuroDatepickerUtilities | toNorthAmericanFormat: Unable to parse date string",
|
|
10832
|
+
);
|
|
10833
|
+
}
|
|
10834
|
+
|
|
10835
|
+
const { month, day, year } = parsedDate;
|
|
10836
|
+
|
|
10837
|
+
return [month, day, year].filter(Boolean).join("/");
|
|
10838
|
+
}
|
|
10839
|
+
|
|
10840
|
+
/**
|
|
10841
|
+
* Validates that a date string matches the provided format and represents a real calendar date.
|
|
10842
|
+
*
|
|
10843
|
+
* @param {string} dateStr - Date string to validate.
|
|
10844
|
+
* @param {string} [format="yyyy-mm-dd"] - Format of the date string.
|
|
10845
|
+
* @returns {boolean} True when the date string is valid for the provided format, otherwise false.
|
|
10846
|
+
*/
|
|
10847
|
+
function isValidDate(dateStr, format = "yyyy-mm-dd") {
|
|
10848
|
+
try {
|
|
10849
|
+
if (typeof dateStr !== "string" || !dateStr || format?.length < 8) {
|
|
10850
|
+
return false;
|
|
10851
|
+
}
|
|
10852
|
+
|
|
10853
|
+
if (parseDate(dateStr, format)) {
|
|
10854
|
+
return true;
|
|
10855
|
+
}
|
|
10856
|
+
} catch (error) {
|
|
10857
|
+
return false;
|
|
10858
|
+
}
|
|
10859
|
+
return false;
|
|
10860
|
+
}
|
|
10861
|
+
|
|
10862
|
+
/**
|
|
10863
|
+
* 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.
|
|
10864
|
+
*
|
|
10865
|
+
* @param {Date} date - Date instance to convert to an ISO-like string.
|
|
10866
|
+
* @returns {string} A string in the format "yyyy-mm-dd" representing the provided date.
|
|
10867
|
+
* @throws {Error} Throws an error when the input is not a valid Date instance.
|
|
10868
|
+
*/
|
|
10869
|
+
function toISOFormatString(date) {
|
|
10870
|
+
if (!(date instanceof Date) || Number.isNaN(date.getTime())) {
|
|
10871
|
+
throw new Error(
|
|
10872
|
+
"AuroDatepickerUtilities | toISOFormatString: Input must be a valid Date instance",
|
|
10873
|
+
);
|
|
10874
|
+
}
|
|
10875
|
+
return `${String(date.getFullYear()).padStart(4, "0")}-${String(date.getMonth() + 1).padStart(2, "0")}-${String(date.getDate()).padStart(2, "0")}`;
|
|
10651
10876
|
}
|
|
10652
|
-
|
|
10877
|
+
|
|
10878
|
+
/**
|
|
10879
|
+
* 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.
|
|
10880
|
+
*
|
|
10881
|
+
* @param {String} dateStr - Date string to convert into a Date object.
|
|
10882
|
+
* @param {String} format - Date format used to parse the string when it is not in ISO format.
|
|
10883
|
+
* @returns {Date|null} Returns a Date instance for valid input or null for non-string input.
|
|
10884
|
+
* @throws {Error} Throws when parsing fails for non-ISO string input.
|
|
10885
|
+
*/
|
|
10886
|
+
function stringToDateInstance(dateStr, format = "yyyy-mm-dd") {
|
|
10887
|
+
if (typeof dateStr !== "string") {
|
|
10888
|
+
return null;
|
|
10889
|
+
}
|
|
10890
|
+
|
|
10891
|
+
const { month, day, year } = parseDate(dateStr, format);
|
|
10892
|
+
return new Date(`${year}/${month}/${day}`);
|
|
10893
|
+
}
|
|
10894
|
+
|
|
10895
|
+
const dateFormatter = {
|
|
10896
|
+
parseDate,
|
|
10897
|
+
getDateParts,
|
|
10898
|
+
getDateAsString,
|
|
10899
|
+
toNorthAmericanFormat: toNorthAmericanFormat$1,
|
|
10900
|
+
isValidDate,
|
|
10901
|
+
toISOFormatString,
|
|
10902
|
+
stringToDateInstance,
|
|
10903
|
+
};
|
|
10653
10904
|
|
|
10654
10905
|
// filepath: dateConstraints.mjs
|
|
10655
10906
|
const DATE_UTIL_CONSTRAINTS = {
|
|
@@ -10721,12 +10972,11 @@ class AuroDateUtilitiesBase {
|
|
|
10721
10972
|
/* eslint-disable no-magic-numbers */
|
|
10722
10973
|
|
|
10723
10974
|
class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
10724
|
-
|
|
10725
10975
|
/**
|
|
10726
10976
|
* Returns the current century.
|
|
10727
10977
|
* @returns {String} The current century.
|
|
10728
10978
|
*/
|
|
10729
|
-
getCentury
|
|
10979
|
+
getCentury() {
|
|
10730
10980
|
return String(new Date().getFullYear()).slice(0, 2);
|
|
10731
10981
|
}
|
|
10732
10982
|
|
|
@@ -10735,14 +10985,12 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
10735
10985
|
* @param {String} year - The year to convert to four digits.
|
|
10736
10986
|
* @returns {String} The four digit year.
|
|
10737
10987
|
*/
|
|
10738
|
-
getFourDigitYear
|
|
10739
|
-
|
|
10988
|
+
getFourDigitYear(year) {
|
|
10740
10989
|
const strYear = String(year).trim();
|
|
10741
10990
|
return strYear.length <= 2 ? this.getCentury() + strYear : strYear;
|
|
10742
10991
|
}
|
|
10743
10992
|
|
|
10744
10993
|
constructor() {
|
|
10745
|
-
|
|
10746
10994
|
super();
|
|
10747
10995
|
|
|
10748
10996
|
/**
|
|
@@ -10751,7 +10999,8 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
10751
10999
|
* @param {Object} date2 - Second date to compare.
|
|
10752
11000
|
* @returns {Boolean} Returns true if the dates match.
|
|
10753
11001
|
*/
|
|
10754
|
-
this.datesMatch = (date1, date2) =>
|
|
11002
|
+
this.datesMatch = (date1, date2) =>
|
|
11003
|
+
new Date(date1).getTime() === new Date(date2).getTime();
|
|
10755
11004
|
|
|
10756
11005
|
/**
|
|
10757
11006
|
* Returns true if value passed in is a valid date.
|
|
@@ -10760,53 +11009,41 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
10760
11009
|
* @returns {Boolean}
|
|
10761
11010
|
*/
|
|
10762
11011
|
this.validDateStr = (date, format) => {
|
|
10763
|
-
|
|
10764
11012
|
// The length we expect the date string to be
|
|
10765
|
-
const dateStrLength = format
|
|
11013
|
+
const dateStrLength = format?.length || 0;
|
|
10766
11014
|
|
|
10767
11015
|
// Guard Clause: Date and format are defined
|
|
10768
11016
|
if (typeof date === "undefined" || typeof format === "undefined") {
|
|
10769
|
-
throw new Error(
|
|
11017
|
+
throw new Error(
|
|
11018
|
+
"AuroDatepickerUtilities | validateDateStr: Date and format are required",
|
|
11019
|
+
);
|
|
10770
11020
|
}
|
|
10771
11021
|
|
|
10772
11022
|
// Guard Clause: Date should be of type string
|
|
10773
11023
|
if (typeof date !== "string") {
|
|
10774
|
-
throw new Error(
|
|
11024
|
+
throw new Error(
|
|
11025
|
+
"AuroDatepickerUtilities | validateDateStr: Date must be a string",
|
|
11026
|
+
);
|
|
10775
11027
|
}
|
|
10776
11028
|
|
|
10777
11029
|
// Guard Clause: Format should be of type string
|
|
10778
11030
|
if (typeof format !== "string") {
|
|
10779
|
-
throw new Error(
|
|
11031
|
+
throw new Error(
|
|
11032
|
+
"AuroDatepickerUtilities | validateDateStr: Format must be a string",
|
|
11033
|
+
);
|
|
10780
11034
|
}
|
|
10781
11035
|
|
|
10782
11036
|
// Guard Clause: Length is what we expect it to be
|
|
10783
11037
|
if (date.length !== dateStrLength) {
|
|
10784
11038
|
return false;
|
|
10785
11039
|
}
|
|
10786
|
-
// Get a formatted date string and parse it
|
|
10787
|
-
const dateParts = dateFormatter.parseDate(date, format);
|
|
10788
|
-
|
|
10789
|
-
// Guard Clause: Date parse succeeded
|
|
10790
|
-
if (!dateParts) {
|
|
10791
|
-
return false;
|
|
10792
|
-
}
|
|
10793
11040
|
|
|
10794
|
-
//
|
|
10795
|
-
|
|
10796
|
-
|
|
10797
|
-
|
|
10798
|
-
const dateObj = new Date(this.getFourDigitYear(dateParts.year), dateParts.month - 1, dateParts.day || 1);
|
|
10799
|
-
|
|
10800
|
-
// Get the date string of the date object we created from the string date
|
|
10801
|
-
const actualDateStr = dateFormatter.getDateAsString(dateObj, "en-US");
|
|
10802
|
-
|
|
10803
|
-
// Guard Clause: Generated date matches date string input
|
|
10804
|
-
if (expectedDateStr !== actualDateStr) {
|
|
11041
|
+
// Get a formatted date string and parse and validate it
|
|
11042
|
+
try {
|
|
11043
|
+
return Boolean(dateFormatter.parseDate(date, format));
|
|
11044
|
+
} catch (error) {
|
|
10805
11045
|
return false;
|
|
10806
11046
|
}
|
|
10807
|
-
|
|
10808
|
-
// If we passed all other checks, we can assume the date is valid
|
|
10809
|
-
return true;
|
|
10810
11047
|
};
|
|
10811
11048
|
|
|
10812
11049
|
/**
|
|
@@ -10816,10 +11053,11 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
10816
11053
|
* @returns {boolean}
|
|
10817
11054
|
*/
|
|
10818
11055
|
this.dateAndFormatMatch = (value, format) => {
|
|
10819
|
-
|
|
10820
11056
|
// Ensure we have both values we need to do the comparison
|
|
10821
11057
|
if (!value || !format) {
|
|
10822
|
-
throw new Error(
|
|
11058
|
+
throw new Error(
|
|
11059
|
+
"AuroFormValidation | dateFormatMatch: value and format are required",
|
|
11060
|
+
);
|
|
10823
11061
|
}
|
|
10824
11062
|
|
|
10825
11063
|
// If the lengths are different, they cannot match
|
|
@@ -10828,11 +11066,10 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
10828
11066
|
}
|
|
10829
11067
|
|
|
10830
11068
|
// Get the parts of the date
|
|
10831
|
-
const dateParts = dateFormatter.
|
|
11069
|
+
const dateParts = dateFormatter.getDateParts(value, format);
|
|
10832
11070
|
|
|
10833
11071
|
// Validator for day
|
|
10834
11072
|
const dayValueIsValid = (day) => {
|
|
10835
|
-
|
|
10836
11073
|
// Guard clause: if there is no day in the dateParts, we can ignore this check.
|
|
10837
11074
|
if (!dateParts.day) {
|
|
10838
11075
|
return true;
|
|
@@ -10848,7 +11085,9 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
10848
11085
|
|
|
10849
11086
|
// Guard clause: ensure day is a valid integer
|
|
10850
11087
|
if (Number.isNaN(numDay)) {
|
|
10851
|
-
throw new Error(
|
|
11088
|
+
throw new Error(
|
|
11089
|
+
"AuroDatepickerUtilities | dayValueIsValid: Unable to parse day value integer",
|
|
11090
|
+
);
|
|
10852
11091
|
}
|
|
10853
11092
|
|
|
10854
11093
|
// Guard clause: ensure day is within the valid range
|
|
@@ -10862,6 +11101,10 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
10862
11101
|
|
|
10863
11102
|
// Validator for month
|
|
10864
11103
|
const monthValueIsValid = (month) => {
|
|
11104
|
+
// Guard clause: if there is no month in the dateParts, we can ignore this check.
|
|
11105
|
+
if (!dateParts.month) {
|
|
11106
|
+
return true;
|
|
11107
|
+
}
|
|
10865
11108
|
|
|
10866
11109
|
// Guard clause: ensure month exists.
|
|
10867
11110
|
if (!month) {
|
|
@@ -10873,7 +11116,9 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
10873
11116
|
|
|
10874
11117
|
// Guard clause: ensure month is a valid integer
|
|
10875
11118
|
if (Number.isNaN(numMonth)) {
|
|
10876
|
-
throw new Error(
|
|
11119
|
+
throw new Error(
|
|
11120
|
+
"AuroDatepickerUtilities | monthValueIsValid: Unable to parse month value integer",
|
|
11121
|
+
);
|
|
10877
11122
|
}
|
|
10878
11123
|
|
|
10879
11124
|
// Guard clause: ensure month is within the valid range
|
|
@@ -10887,6 +11132,10 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
10887
11132
|
|
|
10888
11133
|
// Validator for year
|
|
10889
11134
|
const yearIsValid = (_year) => {
|
|
11135
|
+
// Guard clause: if there is no year in the dateParts, we can ignore this check.
|
|
11136
|
+
if (!dateParts.year) {
|
|
11137
|
+
return true;
|
|
11138
|
+
}
|
|
10890
11139
|
|
|
10891
11140
|
// Guard clause: ensure year exists.
|
|
10892
11141
|
if (!_year) {
|
|
@@ -10901,7 +11150,9 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
10901
11150
|
|
|
10902
11151
|
// Guard clause: ensure year is a valid integer
|
|
10903
11152
|
if (Number.isNaN(numYear)) {
|
|
10904
|
-
throw new Error(
|
|
11153
|
+
throw new Error(
|
|
11154
|
+
"AuroDatepickerUtilities | yearValueIsValid: Unable to parse year value integer",
|
|
11155
|
+
);
|
|
10905
11156
|
}
|
|
10906
11157
|
|
|
10907
11158
|
// Guard clause: ensure year is within the valid range
|
|
@@ -10917,7 +11168,7 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
10917
11168
|
const checks = [
|
|
10918
11169
|
monthValueIsValid(dateParts.month),
|
|
10919
11170
|
dayValueIsValid(dateParts.day),
|
|
10920
|
-
yearIsValid(dateParts.year)
|
|
11171
|
+
yearIsValid(dateParts.year),
|
|
10921
11172
|
];
|
|
10922
11173
|
|
|
10923
11174
|
// If any of the checks failed, the date format does not match and the result is invalid
|
|
@@ -10951,10 +11202,7 @@ const {
|
|
|
10951
11202
|
} = dateUtilities;
|
|
10952
11203
|
|
|
10953
11204
|
const {
|
|
10954
|
-
toNorthAmericanFormat
|
|
10955
|
-
parseDate,
|
|
10956
|
-
getDateAsString
|
|
10957
|
-
} = dateFormatter;
|
|
11205
|
+
toNorthAmericanFormat} = dateFormatter;
|
|
10958
11206
|
|
|
10959
11207
|
// Copyright (c) Alaska Air. All right reserved. Licensed under the Apache-2.0 license
|
|
10960
11208
|
// See LICENSE in the project root for license information.
|
|
@@ -13169,7 +13417,7 @@ let AuroHelpText$1 = class AuroHelpText extends LitElement {
|
|
|
13169
13417
|
}
|
|
13170
13418
|
};
|
|
13171
13419
|
|
|
13172
|
-
var formkitVersion$1 = '
|
|
13420
|
+
var formkitVersion$1 = '202606012139';
|
|
13173
13421
|
|
|
13174
13422
|
// Copyright (c) 2025 Alaska Airlines. All right reserved. Licensed under the Apache-2.0 license
|
|
13175
13423
|
// See LICENSE in the project root for license information.
|
|
@@ -14242,7 +14490,7 @@ class AuroBibtemplate extends LitElement {
|
|
|
14242
14490
|
}
|
|
14243
14491
|
}
|
|
14244
14492
|
|
|
14245
|
-
var formkitVersion = '
|
|
14493
|
+
var formkitVersion = '202606012139';
|
|
14246
14494
|
|
|
14247
14495
|
var styleCss$1 = css`.util_displayInline{display:inline}.util_displayInlineBlock{display:inline-block}.util_displayBlock{display:block}.util_displayFlex{display:flex}.util_displayHidden{display:none}.util_displayHiddenVisually{position:absolute;overflow:hidden;clip:rect(1px, 1px, 1px, 1px);width:1px;height:1px;padding:0;border:0}:host{display:block;text-align:left}:host [auro-dropdown]{--ds-auro-dropdown-trigger-background-color: transparent}:host #inputInBib::part(wrapper){box-shadow:none}:host #inputInBib::part(accent-left){display:none}:host([layout*=classic]) [auro-input]{width:100%}:host([layout*=classic]) [auro-input]::part(helpText){display:none}:host([layout*=classic]) #slotHolder{display:none}`;
|
|
14248
14496
|
|