@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
|
@@ -182,109 +182,236 @@ let AuroLibraryRuntimeUtils$4 = class AuroLibraryRuntimeUtils {
|
|
|
182
182
|
}
|
|
183
183
|
};
|
|
184
184
|
|
|
185
|
-
|
|
185
|
+
/**
|
|
186
|
+
* @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.
|
|
187
|
+
* @param {string} dateStr - Date string to parse.
|
|
188
|
+
* @param {string} format - Date format to parse.
|
|
189
|
+
* @returns {{ month?: string, day?: string, year?: string }|undefined}
|
|
190
|
+
*/
|
|
191
|
+
function getDateParts$1(dateStr, format) {
|
|
192
|
+
if (!dateStr) {
|
|
193
|
+
return undefined;
|
|
194
|
+
}
|
|
186
195
|
|
|
187
|
-
|
|
196
|
+
const formatSeparatorMatch = format.match(/[/.-]/);
|
|
197
|
+
let valueParts;
|
|
198
|
+
let formatParts;
|
|
188
199
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
200
|
+
if (formatSeparatorMatch) {
|
|
201
|
+
const separator = formatSeparatorMatch[0];
|
|
202
|
+
valueParts = dateStr.split(separator);
|
|
203
|
+
formatParts = format.split(separator);
|
|
204
|
+
} else {
|
|
205
|
+
if (dateStr.match(/[/.-]/)) {
|
|
206
|
+
throw new Error(
|
|
207
|
+
"AuroDatepickerUtilities | parseDate: Date string has no separators",
|
|
208
|
+
);
|
|
209
|
+
}
|
|
196
210
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
211
|
+
if (dateStr.length !== format.length) {
|
|
212
|
+
throw new Error(
|
|
213
|
+
"AuroDatepickerUtilities | parseDate: Date string and format length do not match",
|
|
214
|
+
);
|
|
215
|
+
}
|
|
201
216
|
|
|
202
|
-
|
|
203
|
-
|
|
217
|
+
valueParts = [dateStr];
|
|
218
|
+
formatParts = [format];
|
|
219
|
+
}
|
|
204
220
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
221
|
+
if (valueParts.length !== formatParts.length) {
|
|
222
|
+
throw new Error(
|
|
223
|
+
`AuroDatepickerUtilities | parseDate: Date string and format do not match : ${dateStr} vs ${format}`,
|
|
224
|
+
);
|
|
225
|
+
}
|
|
208
226
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
throw new Error('AuroDatepickerUtilities | parseDate: Date string and format length do not match');
|
|
212
|
-
}
|
|
227
|
+
const result = formatParts.reduce((acc, part, index) => {
|
|
228
|
+
const value = valueParts[index];
|
|
213
229
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
230
|
+
if (/m/iu.test(part) && part.length === value.length) {
|
|
231
|
+
acc.month = value;
|
|
232
|
+
} else if (/d/iu.test(part) && part.length === value.length) {
|
|
233
|
+
acc.day = value;
|
|
234
|
+
} else if (/y/iu.test(part) && part.length === value.length) {
|
|
235
|
+
acc.year = value;
|
|
236
|
+
}
|
|
217
237
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
} else if ((/d/iu).test(part)) {
|
|
221
|
-
acc.day = value;
|
|
222
|
-
} else if ((/y/iu).test(part)) {
|
|
223
|
-
acc.year = value;
|
|
224
|
-
}
|
|
238
|
+
return acc;
|
|
239
|
+
}, {});
|
|
225
240
|
|
|
226
|
-
|
|
227
|
-
|
|
241
|
+
if (!result.month && !result.day && !result.year) {
|
|
242
|
+
throw new Error(
|
|
243
|
+
"AuroDatepickerUtilities | parseDate: Unable to parse date string",
|
|
244
|
+
);
|
|
245
|
+
}
|
|
228
246
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
return result;
|
|
232
|
-
}
|
|
247
|
+
return result;
|
|
248
|
+
}
|
|
233
249
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
250
|
+
function isCalendarDate$1(year, month, day) {
|
|
251
|
+
let yearNumber = Number(year);
|
|
252
|
+
const monthNumber = Number(month);
|
|
253
|
+
const dayNumber = Number(day);
|
|
237
254
|
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
year: "numeric",
|
|
246
|
-
month: "2-digit",
|
|
247
|
-
day: "2-digit",
|
|
248
|
-
});
|
|
255
|
+
if (
|
|
256
|
+
!Number.isInteger(yearNumber) ||
|
|
257
|
+
!Number.isInteger(monthNumber) ||
|
|
258
|
+
!Number.isInteger(dayNumber)
|
|
259
|
+
) {
|
|
260
|
+
return false;
|
|
261
|
+
}
|
|
249
262
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
this.toNorthAmericanFormat = (dateStr, format) => {
|
|
263
|
+
// 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.
|
|
264
|
+
if (yearNumber < 100 && yearNumber >= 50) {
|
|
265
|
+
yearNumber += 1900;
|
|
266
|
+
} else if (yearNumber < 50) {
|
|
267
|
+
yearNumber += 2000;
|
|
268
|
+
}
|
|
257
269
|
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
}
|
|
270
|
+
const stringified = `${String(yearNumber).padStart(4, "0")}-${String(monthNumber).padStart(2, "0")}-${String(dayNumber).padStart(2, "0")}`;
|
|
271
|
+
const date = new Date(stringified.replace(/[.-]/g, "/"));
|
|
261
272
|
|
|
262
|
-
|
|
273
|
+
return (
|
|
274
|
+
!Number.isNaN(date.getTime()) && toISOFormatString$1(date) === stringified
|
|
275
|
+
);
|
|
276
|
+
}
|
|
263
277
|
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
278
|
+
/**
|
|
279
|
+
* @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).
|
|
280
|
+
*
|
|
281
|
+
* Partial formats are supported: components absent from `format` default to `year → "0"`,
|
|
282
|
+
* `month → "01"`, `day → "01"` for calendar validation only. The returned object contains
|
|
283
|
+
* only the fields actually present in the format string — missing fields are never injected.
|
|
284
|
+
* @param {string} dateStr - Date string to parse.
|
|
285
|
+
* @param {string} format - Date format to parse.
|
|
286
|
+
* @returns {{ month?: string, day?: string, year?: string }|undefined}
|
|
287
|
+
* @throws {Error} Throws when the parsed result does not represent a valid calendar date.
|
|
288
|
+
*/
|
|
289
|
+
function parseDate$1(dateStr, format = "mm/dd/yyyy") {
|
|
290
|
+
if (!dateStr || !format) {
|
|
291
|
+
return undefined;
|
|
292
|
+
}
|
|
293
|
+
const result = getDateParts$1(dateStr.trim(), format);
|
|
294
|
+
|
|
295
|
+
if (!result) {
|
|
296
|
+
return undefined;
|
|
297
|
+
}
|
|
267
298
|
|
|
268
|
-
|
|
299
|
+
const lowerFormat = format.toLowerCase();
|
|
300
|
+
const year = lowerFormat.includes("yy") ? result.year : "0";
|
|
301
|
+
const month = lowerFormat.includes("mm") ? result.month : "01";
|
|
302
|
+
const day = lowerFormat.includes("dd") ? result.day : "01";
|
|
269
303
|
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
}
|
|
304
|
+
if (isCalendarDate$1(year, month, day)) {
|
|
305
|
+
return result;
|
|
306
|
+
}
|
|
274
307
|
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
308
|
+
throw new Error(
|
|
309
|
+
`AuroDatepickerUtilities | parseDate: Date string is not a valid date ${JSON.stringify(result)} with format ${format}`,
|
|
310
|
+
);
|
|
311
|
+
}
|
|
278
312
|
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
313
|
+
/**
|
|
314
|
+
* Convert a date object to string format.
|
|
315
|
+
* @param {Object} date - Date to convert to string.
|
|
316
|
+
* @param {String} locale - Optional locale to use for the date string. Defaults to user's locale.
|
|
317
|
+
* @returns {String} Returns the date as a string.
|
|
318
|
+
*/
|
|
319
|
+
function getDateAsString$1(date, locale = undefined) {
|
|
320
|
+
return date.toLocaleDateString(locale, {
|
|
321
|
+
year: "numeric",
|
|
322
|
+
month: "2-digit",
|
|
323
|
+
day: "2-digit",
|
|
324
|
+
});
|
|
325
|
+
}
|
|
282
326
|
|
|
283
|
-
|
|
284
|
-
|
|
327
|
+
/**
|
|
328
|
+
* Converts a date string to a North American date format.
|
|
329
|
+
* @param {String} dateStr - Date to validate.
|
|
330
|
+
* @param {String} format - Date format to validate against.
|
|
331
|
+
* @returns {String}
|
|
332
|
+
*/
|
|
333
|
+
function toNorthAmericanFormat$3(dateStr, format) {
|
|
334
|
+
if (format === "mm/dd/yyyy") {
|
|
335
|
+
return dateStr;
|
|
285
336
|
}
|
|
337
|
+
|
|
338
|
+
const parsedDate = parseDate$1(dateStr, format);
|
|
339
|
+
|
|
340
|
+
if (!parsedDate) {
|
|
341
|
+
throw new Error(
|
|
342
|
+
"AuroDatepickerUtilities | toNorthAmericanFormat: Unable to parse date string",
|
|
343
|
+
);
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
const { month, day, year } = parsedDate;
|
|
347
|
+
|
|
348
|
+
return [month, day, year].filter(Boolean).join("/");
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
/**
|
|
352
|
+
* Validates that a date string matches the provided format and represents a real calendar date.
|
|
353
|
+
*
|
|
354
|
+
* @param {string} dateStr - Date string to validate.
|
|
355
|
+
* @param {string} [format="yyyy-mm-dd"] - Format of the date string.
|
|
356
|
+
* @returns {boolean} True when the date string is valid for the provided format, otherwise false.
|
|
357
|
+
*/
|
|
358
|
+
function isValidDate$1(dateStr, format = "yyyy-mm-dd") {
|
|
359
|
+
try {
|
|
360
|
+
if (typeof dateStr !== "string" || !dateStr || format?.length < 8) {
|
|
361
|
+
return false;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
if (parseDate$1(dateStr, format)) {
|
|
365
|
+
return true;
|
|
366
|
+
}
|
|
367
|
+
} catch (error) {
|
|
368
|
+
return false;
|
|
369
|
+
}
|
|
370
|
+
return false;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
/**
|
|
374
|
+
* 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.
|
|
375
|
+
*
|
|
376
|
+
* @param {Date} date - Date instance to convert to an ISO-like string.
|
|
377
|
+
* @returns {string} A string in the format "yyyy-mm-dd" representing the provided date.
|
|
378
|
+
* @throws {Error} Throws an error when the input is not a valid Date instance.
|
|
379
|
+
*/
|
|
380
|
+
function toISOFormatString$1(date) {
|
|
381
|
+
if (!(date instanceof Date) || Number.isNaN(date.getTime())) {
|
|
382
|
+
throw new Error(
|
|
383
|
+
"AuroDatepickerUtilities | toISOFormatString: Input must be a valid Date instance",
|
|
384
|
+
);
|
|
385
|
+
}
|
|
386
|
+
return `${String(date.getFullYear()).padStart(4, "0")}-${String(date.getMonth() + 1).padStart(2, "0")}-${String(date.getDate()).padStart(2, "0")}`;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
/**
|
|
390
|
+
* 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.
|
|
391
|
+
*
|
|
392
|
+
* @param {String} dateStr - Date string to convert into a Date object.
|
|
393
|
+
* @param {String} format - Date format used to parse the string when it is not in ISO format.
|
|
394
|
+
* @returns {Date|null} Returns a Date instance for valid input or null for non-string input.
|
|
395
|
+
* @throws {Error} Throws when parsing fails for non-ISO string input.
|
|
396
|
+
*/
|
|
397
|
+
function stringToDateInstance$1(dateStr, format = "yyyy-mm-dd") {
|
|
398
|
+
if (typeof dateStr !== "string") {
|
|
399
|
+
return null;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
const { month, day, year } = parseDate$1(dateStr, format);
|
|
403
|
+
return new Date(`${year}/${month}/${day}`);
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
const dateFormatter$1 = {
|
|
407
|
+
parseDate: parseDate$1,
|
|
408
|
+
getDateParts: getDateParts$1,
|
|
409
|
+
getDateAsString: getDateAsString$1,
|
|
410
|
+
toNorthAmericanFormat: toNorthAmericanFormat$3,
|
|
411
|
+
isValidDate: isValidDate$1,
|
|
412
|
+
toISOFormatString: toISOFormatString$1,
|
|
413
|
+
stringToDateInstance: stringToDateInstance$1,
|
|
286
414
|
};
|
|
287
|
-
const dateFormatter$1 = new DateFormatter$1();
|
|
288
415
|
|
|
289
416
|
// filepath: dateConstraints.mjs
|
|
290
417
|
const DATE_UTIL_CONSTRAINTS$1 = {
|
|
@@ -356,12 +483,11 @@ let AuroDateUtilitiesBase$1 = class AuroDateUtilitiesBase {
|
|
|
356
483
|
/* eslint-disable no-magic-numbers */
|
|
357
484
|
|
|
358
485
|
let AuroDateUtilities$1 = class AuroDateUtilities extends AuroDateUtilitiesBase$1 {
|
|
359
|
-
|
|
360
486
|
/**
|
|
361
487
|
* Returns the current century.
|
|
362
488
|
* @returns {String} The current century.
|
|
363
489
|
*/
|
|
364
|
-
getCentury
|
|
490
|
+
getCentury() {
|
|
365
491
|
return String(new Date().getFullYear()).slice(0, 2);
|
|
366
492
|
}
|
|
367
493
|
|
|
@@ -370,14 +496,12 @@ let AuroDateUtilities$1 = class AuroDateUtilities extends AuroDateUtilitiesBase$
|
|
|
370
496
|
* @param {String} year - The year to convert to four digits.
|
|
371
497
|
* @returns {String} The four digit year.
|
|
372
498
|
*/
|
|
373
|
-
getFourDigitYear
|
|
374
|
-
|
|
499
|
+
getFourDigitYear(year) {
|
|
375
500
|
const strYear = String(year).trim();
|
|
376
501
|
return strYear.length <= 2 ? this.getCentury() + strYear : strYear;
|
|
377
502
|
}
|
|
378
503
|
|
|
379
504
|
constructor() {
|
|
380
|
-
|
|
381
505
|
super();
|
|
382
506
|
|
|
383
507
|
/**
|
|
@@ -386,7 +510,8 @@ let AuroDateUtilities$1 = class AuroDateUtilities extends AuroDateUtilitiesBase$
|
|
|
386
510
|
* @param {Object} date2 - Second date to compare.
|
|
387
511
|
* @returns {Boolean} Returns true if the dates match.
|
|
388
512
|
*/
|
|
389
|
-
this.datesMatch = (date1, date2) =>
|
|
513
|
+
this.datesMatch = (date1, date2) =>
|
|
514
|
+
new Date(date1).getTime() === new Date(date2).getTime();
|
|
390
515
|
|
|
391
516
|
/**
|
|
392
517
|
* Returns true if value passed in is a valid date.
|
|
@@ -395,53 +520,41 @@ let AuroDateUtilities$1 = class AuroDateUtilities extends AuroDateUtilitiesBase$
|
|
|
395
520
|
* @returns {Boolean}
|
|
396
521
|
*/
|
|
397
522
|
this.validDateStr = (date, format) => {
|
|
398
|
-
|
|
399
523
|
// The length we expect the date string to be
|
|
400
|
-
const dateStrLength = format
|
|
524
|
+
const dateStrLength = format?.length || 0;
|
|
401
525
|
|
|
402
526
|
// Guard Clause: Date and format are defined
|
|
403
527
|
if (typeof date === "undefined" || typeof format === "undefined") {
|
|
404
|
-
throw new Error(
|
|
528
|
+
throw new Error(
|
|
529
|
+
"AuroDatepickerUtilities | validateDateStr: Date and format are required",
|
|
530
|
+
);
|
|
405
531
|
}
|
|
406
532
|
|
|
407
533
|
// Guard Clause: Date should be of type string
|
|
408
534
|
if (typeof date !== "string") {
|
|
409
|
-
throw new Error(
|
|
535
|
+
throw new Error(
|
|
536
|
+
"AuroDatepickerUtilities | validateDateStr: Date must be a string",
|
|
537
|
+
);
|
|
410
538
|
}
|
|
411
539
|
|
|
412
540
|
// Guard Clause: Format should be of type string
|
|
413
541
|
if (typeof format !== "string") {
|
|
414
|
-
throw new Error(
|
|
542
|
+
throw new Error(
|
|
543
|
+
"AuroDatepickerUtilities | validateDateStr: Format must be a string",
|
|
544
|
+
);
|
|
415
545
|
}
|
|
416
546
|
|
|
417
547
|
// Guard Clause: Length is what we expect it to be
|
|
418
548
|
if (date.length !== dateStrLength) {
|
|
419
549
|
return false;
|
|
420
550
|
}
|
|
421
|
-
// Get a formatted date string and parse it
|
|
422
|
-
const dateParts = dateFormatter$1.parseDate(date, format);
|
|
423
|
-
|
|
424
|
-
// Guard Clause: Date parse succeeded
|
|
425
|
-
if (!dateParts) {
|
|
426
|
-
return false;
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
// Create the expected date string based on the date parts
|
|
430
|
-
const expectedDateStr = `${dateParts.month}/${dateParts.day || "01"}/${this.getFourDigitYear(dateParts.year)}`;
|
|
431
551
|
|
|
432
|
-
//
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
const actualDateStr = dateFormatter$1.getDateAsString(dateObj, "en-US");
|
|
437
|
-
|
|
438
|
-
// Guard Clause: Generated date matches date string input
|
|
439
|
-
if (expectedDateStr !== actualDateStr) {
|
|
552
|
+
// Get a formatted date string and parse and validate it
|
|
553
|
+
try {
|
|
554
|
+
return Boolean(dateFormatter$1.parseDate(date, format));
|
|
555
|
+
} catch (error) {
|
|
440
556
|
return false;
|
|
441
557
|
}
|
|
442
|
-
|
|
443
|
-
// If we passed all other checks, we can assume the date is valid
|
|
444
|
-
return true;
|
|
445
558
|
};
|
|
446
559
|
|
|
447
560
|
/**
|
|
@@ -451,10 +564,11 @@ let AuroDateUtilities$1 = class AuroDateUtilities extends AuroDateUtilitiesBase$
|
|
|
451
564
|
* @returns {boolean}
|
|
452
565
|
*/
|
|
453
566
|
this.dateAndFormatMatch = (value, format) => {
|
|
454
|
-
|
|
455
567
|
// Ensure we have both values we need to do the comparison
|
|
456
568
|
if (!value || !format) {
|
|
457
|
-
throw new Error(
|
|
569
|
+
throw new Error(
|
|
570
|
+
"AuroFormValidation | dateFormatMatch: value and format are required",
|
|
571
|
+
);
|
|
458
572
|
}
|
|
459
573
|
|
|
460
574
|
// If the lengths are different, they cannot match
|
|
@@ -463,11 +577,10 @@ let AuroDateUtilities$1 = class AuroDateUtilities extends AuroDateUtilitiesBase$
|
|
|
463
577
|
}
|
|
464
578
|
|
|
465
579
|
// Get the parts of the date
|
|
466
|
-
const dateParts = dateFormatter$1.
|
|
580
|
+
const dateParts = dateFormatter$1.getDateParts(value, format);
|
|
467
581
|
|
|
468
582
|
// Validator for day
|
|
469
583
|
const dayValueIsValid = (day) => {
|
|
470
|
-
|
|
471
584
|
// Guard clause: if there is no day in the dateParts, we can ignore this check.
|
|
472
585
|
if (!dateParts.day) {
|
|
473
586
|
return true;
|
|
@@ -483,7 +596,9 @@ let AuroDateUtilities$1 = class AuroDateUtilities extends AuroDateUtilitiesBase$
|
|
|
483
596
|
|
|
484
597
|
// Guard clause: ensure day is a valid integer
|
|
485
598
|
if (Number.isNaN(numDay)) {
|
|
486
|
-
throw new Error(
|
|
599
|
+
throw new Error(
|
|
600
|
+
"AuroDatepickerUtilities | dayValueIsValid: Unable to parse day value integer",
|
|
601
|
+
);
|
|
487
602
|
}
|
|
488
603
|
|
|
489
604
|
// Guard clause: ensure day is within the valid range
|
|
@@ -497,6 +612,10 @@ let AuroDateUtilities$1 = class AuroDateUtilities extends AuroDateUtilitiesBase$
|
|
|
497
612
|
|
|
498
613
|
// Validator for month
|
|
499
614
|
const monthValueIsValid = (month) => {
|
|
615
|
+
// Guard clause: if there is no month in the dateParts, we can ignore this check.
|
|
616
|
+
if (!dateParts.month) {
|
|
617
|
+
return true;
|
|
618
|
+
}
|
|
500
619
|
|
|
501
620
|
// Guard clause: ensure month exists.
|
|
502
621
|
if (!month) {
|
|
@@ -508,7 +627,9 @@ let AuroDateUtilities$1 = class AuroDateUtilities extends AuroDateUtilitiesBase$
|
|
|
508
627
|
|
|
509
628
|
// Guard clause: ensure month is a valid integer
|
|
510
629
|
if (Number.isNaN(numMonth)) {
|
|
511
|
-
throw new Error(
|
|
630
|
+
throw new Error(
|
|
631
|
+
"AuroDatepickerUtilities | monthValueIsValid: Unable to parse month value integer",
|
|
632
|
+
);
|
|
512
633
|
}
|
|
513
634
|
|
|
514
635
|
// Guard clause: ensure month is within the valid range
|
|
@@ -522,6 +643,10 @@ let AuroDateUtilities$1 = class AuroDateUtilities extends AuroDateUtilitiesBase$
|
|
|
522
643
|
|
|
523
644
|
// Validator for year
|
|
524
645
|
const yearIsValid = (_year) => {
|
|
646
|
+
// Guard clause: if there is no year in the dateParts, we can ignore this check.
|
|
647
|
+
if (!dateParts.year) {
|
|
648
|
+
return true;
|
|
649
|
+
}
|
|
525
650
|
|
|
526
651
|
// Guard clause: ensure year exists.
|
|
527
652
|
if (!_year) {
|
|
@@ -536,7 +661,9 @@ let AuroDateUtilities$1 = class AuroDateUtilities extends AuroDateUtilitiesBase$
|
|
|
536
661
|
|
|
537
662
|
// Guard clause: ensure year is a valid integer
|
|
538
663
|
if (Number.isNaN(numYear)) {
|
|
539
|
-
throw new Error(
|
|
664
|
+
throw new Error(
|
|
665
|
+
"AuroDatepickerUtilities | yearValueIsValid: Unable to parse year value integer",
|
|
666
|
+
);
|
|
540
667
|
}
|
|
541
668
|
|
|
542
669
|
// Guard clause: ensure year is within the valid range
|
|
@@ -552,7 +679,7 @@ let AuroDateUtilities$1 = class AuroDateUtilities extends AuroDateUtilitiesBase$
|
|
|
552
679
|
const checks = [
|
|
553
680
|
monthValueIsValid(dateParts.month),
|
|
554
681
|
dayValueIsValid(dateParts.day),
|
|
555
|
-
yearIsValid(dateParts.year)
|
|
682
|
+
yearIsValid(dateParts.year),
|
|
556
683
|
];
|
|
557
684
|
|
|
558
685
|
// If any of the checks failed, the date format does not match and the result is invalid
|
|
@@ -586,10 +713,7 @@ const {
|
|
|
586
713
|
} = dateUtilities$1;
|
|
587
714
|
|
|
588
715
|
const {
|
|
589
|
-
toNorthAmericanFormat: toNorthAmericanFormat$1
|
|
590
|
-
parseDate: parseDate$1,
|
|
591
|
-
getDateAsString: getDateAsString$1
|
|
592
|
-
} = dateFormatter$1;
|
|
716
|
+
toNorthAmericanFormat: toNorthAmericanFormat$2} = dateFormatter$1;
|
|
593
717
|
|
|
594
718
|
// Copyright (c) Alaska Air. All right reserved. Licensed under the Apache-2.0 license
|
|
595
719
|
// See LICENSE in the project root for license information.
|
|
@@ -826,13 +950,13 @@ let AuroFormValidation$1 = class AuroFormValidation {
|
|
|
826
950
|
}
|
|
827
951
|
|
|
828
952
|
// Perform the rest of the validation
|
|
829
|
-
const formattedValue = toNorthAmericanFormat$
|
|
953
|
+
const formattedValue = toNorthAmericanFormat$2(elem.value, elem.format);
|
|
830
954
|
const valueDate = new Date(formattedValue);
|
|
831
955
|
|
|
832
956
|
// // Validate max date
|
|
833
957
|
if (elem.max?.length === elem.lengthForType) {
|
|
834
958
|
|
|
835
|
-
const maxDate = new Date(toNorthAmericanFormat$
|
|
959
|
+
const maxDate = new Date(toNorthAmericanFormat$2(elem.max, elem.format));
|
|
836
960
|
|
|
837
961
|
if (valueDate > maxDate) {
|
|
838
962
|
elem.validity = 'rangeOverflow';
|
|
@@ -843,7 +967,7 @@ let AuroFormValidation$1 = class AuroFormValidation {
|
|
|
843
967
|
|
|
844
968
|
// Validate min date
|
|
845
969
|
if (elem.min?.length === elem.lengthForType) {
|
|
846
|
-
const minDate = new Date(toNorthAmericanFormat$
|
|
970
|
+
const minDate = new Date(toNorthAmericanFormat$2(elem.min, elem.format));
|
|
847
971
|
|
|
848
972
|
if (valueDate < minDate) {
|
|
849
973
|
elem.validity = 'rangeUnderflow';
|
|
@@ -5293,7 +5417,7 @@ let AuroHelpText$2 = class AuroHelpText extends i$4 {
|
|
|
5293
5417
|
}
|
|
5294
5418
|
};
|
|
5295
5419
|
|
|
5296
|
-
var formkitVersion$2 = '
|
|
5420
|
+
var formkitVersion$2 = '202606012139';
|
|
5297
5421
|
|
|
5298
5422
|
let AuroElement$2 = class AuroElement extends i$4 {
|
|
5299
5423
|
static get properties() {
|
|
@@ -10636,109 +10760,236 @@ class AuroInputUtilities {
|
|
|
10636
10760
|
}
|
|
10637
10761
|
}
|
|
10638
10762
|
|
|
10639
|
-
|
|
10763
|
+
/**
|
|
10764
|
+
* @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.
|
|
10765
|
+
* @param {string} dateStr - Date string to parse.
|
|
10766
|
+
* @param {string} format - Date format to parse.
|
|
10767
|
+
* @returns {{ month?: string, day?: string, year?: string }|undefined}
|
|
10768
|
+
*/
|
|
10769
|
+
function getDateParts(dateStr, format) {
|
|
10770
|
+
if (!dateStr) {
|
|
10771
|
+
return undefined;
|
|
10772
|
+
}
|
|
10640
10773
|
|
|
10641
|
-
|
|
10774
|
+
const formatSeparatorMatch = format.match(/[/.-]/);
|
|
10775
|
+
let valueParts;
|
|
10776
|
+
let formatParts;
|
|
10642
10777
|
|
|
10643
|
-
|
|
10644
|
-
|
|
10645
|
-
|
|
10646
|
-
|
|
10647
|
-
|
|
10648
|
-
|
|
10649
|
-
|
|
10778
|
+
if (formatSeparatorMatch) {
|
|
10779
|
+
const separator = formatSeparatorMatch[0];
|
|
10780
|
+
valueParts = dateStr.split(separator);
|
|
10781
|
+
formatParts = format.split(separator);
|
|
10782
|
+
} else {
|
|
10783
|
+
if (dateStr.match(/[/.-]/)) {
|
|
10784
|
+
throw new Error(
|
|
10785
|
+
"AuroDatepickerUtilities | parseDate: Date string has no separators",
|
|
10786
|
+
);
|
|
10787
|
+
}
|
|
10650
10788
|
|
|
10651
|
-
|
|
10652
|
-
|
|
10653
|
-
|
|
10654
|
-
|
|
10789
|
+
if (dateStr.length !== format.length) {
|
|
10790
|
+
throw new Error(
|
|
10791
|
+
"AuroDatepickerUtilities | parseDate: Date string and format length do not match",
|
|
10792
|
+
);
|
|
10793
|
+
}
|
|
10655
10794
|
|
|
10656
|
-
|
|
10657
|
-
|
|
10795
|
+
valueParts = [dateStr];
|
|
10796
|
+
formatParts = [format];
|
|
10797
|
+
}
|
|
10658
10798
|
|
|
10659
|
-
|
|
10660
|
-
|
|
10661
|
-
|
|
10799
|
+
if (valueParts.length !== formatParts.length) {
|
|
10800
|
+
throw new Error(
|
|
10801
|
+
`AuroDatepickerUtilities | parseDate: Date string and format do not match : ${dateStr} vs ${format}`,
|
|
10802
|
+
);
|
|
10803
|
+
}
|
|
10662
10804
|
|
|
10663
|
-
|
|
10664
|
-
|
|
10665
|
-
throw new Error('AuroDatepickerUtilities | parseDate: Date string and format length do not match');
|
|
10666
|
-
}
|
|
10805
|
+
const result = formatParts.reduce((acc, part, index) => {
|
|
10806
|
+
const value = valueParts[index];
|
|
10667
10807
|
|
|
10668
|
-
|
|
10669
|
-
|
|
10670
|
-
|
|
10808
|
+
if (/m/iu.test(part) && part.length === value.length) {
|
|
10809
|
+
acc.month = value;
|
|
10810
|
+
} else if (/d/iu.test(part) && part.length === value.length) {
|
|
10811
|
+
acc.day = value;
|
|
10812
|
+
} else if (/y/iu.test(part) && part.length === value.length) {
|
|
10813
|
+
acc.year = value;
|
|
10814
|
+
}
|
|
10671
10815
|
|
|
10672
|
-
|
|
10673
|
-
|
|
10674
|
-
} else if ((/d/iu).test(part)) {
|
|
10675
|
-
acc.day = value;
|
|
10676
|
-
} else if ((/y/iu).test(part)) {
|
|
10677
|
-
acc.year = value;
|
|
10678
|
-
}
|
|
10816
|
+
return acc;
|
|
10817
|
+
}, {});
|
|
10679
10818
|
|
|
10680
|
-
|
|
10681
|
-
|
|
10819
|
+
if (!result.month && !result.day && !result.year) {
|
|
10820
|
+
throw new Error(
|
|
10821
|
+
"AuroDatepickerUtilities | parseDate: Unable to parse date string",
|
|
10822
|
+
);
|
|
10823
|
+
}
|
|
10682
10824
|
|
|
10683
|
-
|
|
10684
|
-
|
|
10685
|
-
return result;
|
|
10686
|
-
}
|
|
10825
|
+
return result;
|
|
10826
|
+
}
|
|
10687
10827
|
|
|
10688
|
-
|
|
10689
|
-
|
|
10690
|
-
|
|
10828
|
+
function isCalendarDate(year, month, day) {
|
|
10829
|
+
let yearNumber = Number(year);
|
|
10830
|
+
const monthNumber = Number(month);
|
|
10831
|
+
const dayNumber = Number(day);
|
|
10691
10832
|
|
|
10692
|
-
|
|
10693
|
-
|
|
10694
|
-
|
|
10695
|
-
|
|
10696
|
-
|
|
10697
|
-
|
|
10698
|
-
|
|
10699
|
-
year: "numeric",
|
|
10700
|
-
month: "2-digit",
|
|
10701
|
-
day: "2-digit",
|
|
10702
|
-
});
|
|
10833
|
+
if (
|
|
10834
|
+
!Number.isInteger(yearNumber) ||
|
|
10835
|
+
!Number.isInteger(monthNumber) ||
|
|
10836
|
+
!Number.isInteger(dayNumber)
|
|
10837
|
+
) {
|
|
10838
|
+
return false;
|
|
10839
|
+
}
|
|
10703
10840
|
|
|
10704
|
-
|
|
10705
|
-
|
|
10706
|
-
|
|
10707
|
-
|
|
10708
|
-
|
|
10709
|
-
|
|
10710
|
-
this.toNorthAmericanFormat = (dateStr, format) => {
|
|
10841
|
+
// 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.
|
|
10842
|
+
if (yearNumber < 100 && yearNumber >= 50) {
|
|
10843
|
+
yearNumber += 1900;
|
|
10844
|
+
} else if (yearNumber < 50) {
|
|
10845
|
+
yearNumber += 2000;
|
|
10846
|
+
}
|
|
10711
10847
|
|
|
10712
|
-
|
|
10713
|
-
|
|
10714
|
-
}
|
|
10848
|
+
const stringified = `${String(yearNumber).padStart(4, "0")}-${String(monthNumber).padStart(2, "0")}-${String(dayNumber).padStart(2, "0")}`;
|
|
10849
|
+
const date = new Date(stringified.replace(/[.-]/g, "/"));
|
|
10715
10850
|
|
|
10716
|
-
|
|
10851
|
+
return (
|
|
10852
|
+
!Number.isNaN(date.getTime()) && toISOFormatString(date) === stringified
|
|
10853
|
+
);
|
|
10854
|
+
}
|
|
10717
10855
|
|
|
10718
|
-
|
|
10719
|
-
|
|
10720
|
-
|
|
10856
|
+
/**
|
|
10857
|
+
* @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).
|
|
10858
|
+
*
|
|
10859
|
+
* Partial formats are supported: components absent from `format` default to `year → "0"`,
|
|
10860
|
+
* `month → "01"`, `day → "01"` for calendar validation only. The returned object contains
|
|
10861
|
+
* only the fields actually present in the format string — missing fields are never injected.
|
|
10862
|
+
* @param {string} dateStr - Date string to parse.
|
|
10863
|
+
* @param {string} format - Date format to parse.
|
|
10864
|
+
* @returns {{ month?: string, day?: string, year?: string }|undefined}
|
|
10865
|
+
* @throws {Error} Throws when the parsed result does not represent a valid calendar date.
|
|
10866
|
+
*/
|
|
10867
|
+
function parseDate(dateStr, format = "mm/dd/yyyy") {
|
|
10868
|
+
if (!dateStr || !format) {
|
|
10869
|
+
return undefined;
|
|
10870
|
+
}
|
|
10871
|
+
const result = getDateParts(dateStr.trim(), format);
|
|
10872
|
+
|
|
10873
|
+
if (!result) {
|
|
10874
|
+
return undefined;
|
|
10875
|
+
}
|
|
10721
10876
|
|
|
10722
|
-
|
|
10877
|
+
const lowerFormat = format.toLowerCase();
|
|
10878
|
+
const year = lowerFormat.includes("yy") ? result.year : "0";
|
|
10879
|
+
const month = lowerFormat.includes("mm") ? result.month : "01";
|
|
10880
|
+
const day = lowerFormat.includes("dd") ? result.day : "01";
|
|
10723
10881
|
|
|
10724
|
-
|
|
10725
|
-
|
|
10726
|
-
|
|
10727
|
-
}
|
|
10882
|
+
if (isCalendarDate(year, month, day)) {
|
|
10883
|
+
return result;
|
|
10884
|
+
}
|
|
10728
10885
|
|
|
10729
|
-
|
|
10730
|
-
|
|
10731
|
-
|
|
10886
|
+
throw new Error(
|
|
10887
|
+
`AuroDatepickerUtilities | parseDate: Date string is not a valid date ${JSON.stringify(result)} with format ${format}`,
|
|
10888
|
+
);
|
|
10889
|
+
}
|
|
10732
10890
|
|
|
10733
|
-
|
|
10734
|
-
|
|
10735
|
-
|
|
10891
|
+
/**
|
|
10892
|
+
* Convert a date object to string format.
|
|
10893
|
+
* @param {Object} date - Date to convert to string.
|
|
10894
|
+
* @param {String} locale - Optional locale to use for the date string. Defaults to user's locale.
|
|
10895
|
+
* @returns {String} Returns the date as a string.
|
|
10896
|
+
*/
|
|
10897
|
+
function getDateAsString(date, locale = undefined) {
|
|
10898
|
+
return date.toLocaleDateString(locale, {
|
|
10899
|
+
year: "numeric",
|
|
10900
|
+
month: "2-digit",
|
|
10901
|
+
day: "2-digit",
|
|
10902
|
+
});
|
|
10903
|
+
}
|
|
10736
10904
|
|
|
10737
|
-
|
|
10738
|
-
|
|
10905
|
+
/**
|
|
10906
|
+
* Converts a date string to a North American date format.
|
|
10907
|
+
* @param {String} dateStr - Date to validate.
|
|
10908
|
+
* @param {String} format - Date format to validate against.
|
|
10909
|
+
* @returns {String}
|
|
10910
|
+
*/
|
|
10911
|
+
function toNorthAmericanFormat$1(dateStr, format) {
|
|
10912
|
+
if (format === "mm/dd/yyyy") {
|
|
10913
|
+
return dateStr;
|
|
10739
10914
|
}
|
|
10915
|
+
|
|
10916
|
+
const parsedDate = parseDate(dateStr, format);
|
|
10917
|
+
|
|
10918
|
+
if (!parsedDate) {
|
|
10919
|
+
throw new Error(
|
|
10920
|
+
"AuroDatepickerUtilities | toNorthAmericanFormat: Unable to parse date string",
|
|
10921
|
+
);
|
|
10922
|
+
}
|
|
10923
|
+
|
|
10924
|
+
const { month, day, year } = parsedDate;
|
|
10925
|
+
|
|
10926
|
+
return [month, day, year].filter(Boolean).join("/");
|
|
10927
|
+
}
|
|
10928
|
+
|
|
10929
|
+
/**
|
|
10930
|
+
* Validates that a date string matches the provided format and represents a real calendar date.
|
|
10931
|
+
*
|
|
10932
|
+
* @param {string} dateStr - Date string to validate.
|
|
10933
|
+
* @param {string} [format="yyyy-mm-dd"] - Format of the date string.
|
|
10934
|
+
* @returns {boolean} True when the date string is valid for the provided format, otherwise false.
|
|
10935
|
+
*/
|
|
10936
|
+
function isValidDate(dateStr, format = "yyyy-mm-dd") {
|
|
10937
|
+
try {
|
|
10938
|
+
if (typeof dateStr !== "string" || !dateStr || format?.length < 8) {
|
|
10939
|
+
return false;
|
|
10940
|
+
}
|
|
10941
|
+
|
|
10942
|
+
if (parseDate(dateStr, format)) {
|
|
10943
|
+
return true;
|
|
10944
|
+
}
|
|
10945
|
+
} catch (error) {
|
|
10946
|
+
return false;
|
|
10947
|
+
}
|
|
10948
|
+
return false;
|
|
10949
|
+
}
|
|
10950
|
+
|
|
10951
|
+
/**
|
|
10952
|
+
* 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.
|
|
10953
|
+
*
|
|
10954
|
+
* @param {Date} date - Date instance to convert to an ISO-like string.
|
|
10955
|
+
* @returns {string} A string in the format "yyyy-mm-dd" representing the provided date.
|
|
10956
|
+
* @throws {Error} Throws an error when the input is not a valid Date instance.
|
|
10957
|
+
*/
|
|
10958
|
+
function toISOFormatString(date) {
|
|
10959
|
+
if (!(date instanceof Date) || Number.isNaN(date.getTime())) {
|
|
10960
|
+
throw new Error(
|
|
10961
|
+
"AuroDatepickerUtilities | toISOFormatString: Input must be a valid Date instance",
|
|
10962
|
+
);
|
|
10963
|
+
}
|
|
10964
|
+
return `${String(date.getFullYear()).padStart(4, "0")}-${String(date.getMonth() + 1).padStart(2, "0")}-${String(date.getDate()).padStart(2, "0")}`;
|
|
10740
10965
|
}
|
|
10741
|
-
|
|
10966
|
+
|
|
10967
|
+
/**
|
|
10968
|
+
* 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.
|
|
10969
|
+
*
|
|
10970
|
+
* @param {String} dateStr - Date string to convert into a Date object.
|
|
10971
|
+
* @param {String} format - Date format used to parse the string when it is not in ISO format.
|
|
10972
|
+
* @returns {Date|null} Returns a Date instance for valid input or null for non-string input.
|
|
10973
|
+
* @throws {Error} Throws when parsing fails for non-ISO string input.
|
|
10974
|
+
*/
|
|
10975
|
+
function stringToDateInstance(dateStr, format = "yyyy-mm-dd") {
|
|
10976
|
+
if (typeof dateStr !== "string") {
|
|
10977
|
+
return null;
|
|
10978
|
+
}
|
|
10979
|
+
|
|
10980
|
+
const { month, day, year } = parseDate(dateStr, format);
|
|
10981
|
+
return new Date(`${year}/${month}/${day}`);
|
|
10982
|
+
}
|
|
10983
|
+
|
|
10984
|
+
const dateFormatter = {
|
|
10985
|
+
parseDate,
|
|
10986
|
+
getDateParts,
|
|
10987
|
+
getDateAsString,
|
|
10988
|
+
toNorthAmericanFormat: toNorthAmericanFormat$1,
|
|
10989
|
+
isValidDate,
|
|
10990
|
+
toISOFormatString,
|
|
10991
|
+
stringToDateInstance,
|
|
10992
|
+
};
|
|
10742
10993
|
|
|
10743
10994
|
// filepath: dateConstraints.mjs
|
|
10744
10995
|
const DATE_UTIL_CONSTRAINTS = {
|
|
@@ -10810,12 +11061,11 @@ class AuroDateUtilitiesBase {
|
|
|
10810
11061
|
/* eslint-disable no-magic-numbers */
|
|
10811
11062
|
|
|
10812
11063
|
class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
10813
|
-
|
|
10814
11064
|
/**
|
|
10815
11065
|
* Returns the current century.
|
|
10816
11066
|
* @returns {String} The current century.
|
|
10817
11067
|
*/
|
|
10818
|
-
getCentury
|
|
11068
|
+
getCentury() {
|
|
10819
11069
|
return String(new Date().getFullYear()).slice(0, 2);
|
|
10820
11070
|
}
|
|
10821
11071
|
|
|
@@ -10824,14 +11074,12 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
10824
11074
|
* @param {String} year - The year to convert to four digits.
|
|
10825
11075
|
* @returns {String} The four digit year.
|
|
10826
11076
|
*/
|
|
10827
|
-
getFourDigitYear
|
|
10828
|
-
|
|
11077
|
+
getFourDigitYear(year) {
|
|
10829
11078
|
const strYear = String(year).trim();
|
|
10830
11079
|
return strYear.length <= 2 ? this.getCentury() + strYear : strYear;
|
|
10831
11080
|
}
|
|
10832
11081
|
|
|
10833
11082
|
constructor() {
|
|
10834
|
-
|
|
10835
11083
|
super();
|
|
10836
11084
|
|
|
10837
11085
|
/**
|
|
@@ -10840,7 +11088,8 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
10840
11088
|
* @param {Object} date2 - Second date to compare.
|
|
10841
11089
|
* @returns {Boolean} Returns true if the dates match.
|
|
10842
11090
|
*/
|
|
10843
|
-
this.datesMatch = (date1, date2) =>
|
|
11091
|
+
this.datesMatch = (date1, date2) =>
|
|
11092
|
+
new Date(date1).getTime() === new Date(date2).getTime();
|
|
10844
11093
|
|
|
10845
11094
|
/**
|
|
10846
11095
|
* Returns true if value passed in is a valid date.
|
|
@@ -10849,53 +11098,41 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
10849
11098
|
* @returns {Boolean}
|
|
10850
11099
|
*/
|
|
10851
11100
|
this.validDateStr = (date, format) => {
|
|
10852
|
-
|
|
10853
11101
|
// The length we expect the date string to be
|
|
10854
|
-
const dateStrLength = format
|
|
11102
|
+
const dateStrLength = format?.length || 0;
|
|
10855
11103
|
|
|
10856
11104
|
// Guard Clause: Date and format are defined
|
|
10857
11105
|
if (typeof date === "undefined" || typeof format === "undefined") {
|
|
10858
|
-
throw new Error(
|
|
11106
|
+
throw new Error(
|
|
11107
|
+
"AuroDatepickerUtilities | validateDateStr: Date and format are required",
|
|
11108
|
+
);
|
|
10859
11109
|
}
|
|
10860
11110
|
|
|
10861
11111
|
// Guard Clause: Date should be of type string
|
|
10862
11112
|
if (typeof date !== "string") {
|
|
10863
|
-
throw new Error(
|
|
11113
|
+
throw new Error(
|
|
11114
|
+
"AuroDatepickerUtilities | validateDateStr: Date must be a string",
|
|
11115
|
+
);
|
|
10864
11116
|
}
|
|
10865
11117
|
|
|
10866
11118
|
// Guard Clause: Format should be of type string
|
|
10867
11119
|
if (typeof format !== "string") {
|
|
10868
|
-
throw new Error(
|
|
11120
|
+
throw new Error(
|
|
11121
|
+
"AuroDatepickerUtilities | validateDateStr: Format must be a string",
|
|
11122
|
+
);
|
|
10869
11123
|
}
|
|
10870
11124
|
|
|
10871
11125
|
// Guard Clause: Length is what we expect it to be
|
|
10872
11126
|
if (date.length !== dateStrLength) {
|
|
10873
11127
|
return false;
|
|
10874
11128
|
}
|
|
10875
|
-
// Get a formatted date string and parse it
|
|
10876
|
-
const dateParts = dateFormatter.parseDate(date, format);
|
|
10877
|
-
|
|
10878
|
-
// Guard Clause: Date parse succeeded
|
|
10879
|
-
if (!dateParts) {
|
|
10880
|
-
return false;
|
|
10881
|
-
}
|
|
10882
11129
|
|
|
10883
|
-
//
|
|
10884
|
-
|
|
10885
|
-
|
|
10886
|
-
|
|
10887
|
-
const dateObj = new Date(this.getFourDigitYear(dateParts.year), dateParts.month - 1, dateParts.day || 1);
|
|
10888
|
-
|
|
10889
|
-
// Get the date string of the date object we created from the string date
|
|
10890
|
-
const actualDateStr = dateFormatter.getDateAsString(dateObj, "en-US");
|
|
10891
|
-
|
|
10892
|
-
// Guard Clause: Generated date matches date string input
|
|
10893
|
-
if (expectedDateStr !== actualDateStr) {
|
|
11130
|
+
// Get a formatted date string and parse and validate it
|
|
11131
|
+
try {
|
|
11132
|
+
return Boolean(dateFormatter.parseDate(date, format));
|
|
11133
|
+
} catch (error) {
|
|
10894
11134
|
return false;
|
|
10895
11135
|
}
|
|
10896
|
-
|
|
10897
|
-
// If we passed all other checks, we can assume the date is valid
|
|
10898
|
-
return true;
|
|
10899
11136
|
};
|
|
10900
11137
|
|
|
10901
11138
|
/**
|
|
@@ -10905,10 +11142,11 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
10905
11142
|
* @returns {boolean}
|
|
10906
11143
|
*/
|
|
10907
11144
|
this.dateAndFormatMatch = (value, format) => {
|
|
10908
|
-
|
|
10909
11145
|
// Ensure we have both values we need to do the comparison
|
|
10910
11146
|
if (!value || !format) {
|
|
10911
|
-
throw new Error(
|
|
11147
|
+
throw new Error(
|
|
11148
|
+
"AuroFormValidation | dateFormatMatch: value and format are required",
|
|
11149
|
+
);
|
|
10912
11150
|
}
|
|
10913
11151
|
|
|
10914
11152
|
// If the lengths are different, they cannot match
|
|
@@ -10917,11 +11155,10 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
10917
11155
|
}
|
|
10918
11156
|
|
|
10919
11157
|
// Get the parts of the date
|
|
10920
|
-
const dateParts = dateFormatter.
|
|
11158
|
+
const dateParts = dateFormatter.getDateParts(value, format);
|
|
10921
11159
|
|
|
10922
11160
|
// Validator for day
|
|
10923
11161
|
const dayValueIsValid = (day) => {
|
|
10924
|
-
|
|
10925
11162
|
// Guard clause: if there is no day in the dateParts, we can ignore this check.
|
|
10926
11163
|
if (!dateParts.day) {
|
|
10927
11164
|
return true;
|
|
@@ -10937,7 +11174,9 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
10937
11174
|
|
|
10938
11175
|
// Guard clause: ensure day is a valid integer
|
|
10939
11176
|
if (Number.isNaN(numDay)) {
|
|
10940
|
-
throw new Error(
|
|
11177
|
+
throw new Error(
|
|
11178
|
+
"AuroDatepickerUtilities | dayValueIsValid: Unable to parse day value integer",
|
|
11179
|
+
);
|
|
10941
11180
|
}
|
|
10942
11181
|
|
|
10943
11182
|
// Guard clause: ensure day is within the valid range
|
|
@@ -10951,6 +11190,10 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
10951
11190
|
|
|
10952
11191
|
// Validator for month
|
|
10953
11192
|
const monthValueIsValid = (month) => {
|
|
11193
|
+
// Guard clause: if there is no month in the dateParts, we can ignore this check.
|
|
11194
|
+
if (!dateParts.month) {
|
|
11195
|
+
return true;
|
|
11196
|
+
}
|
|
10954
11197
|
|
|
10955
11198
|
// Guard clause: ensure month exists.
|
|
10956
11199
|
if (!month) {
|
|
@@ -10962,7 +11205,9 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
10962
11205
|
|
|
10963
11206
|
// Guard clause: ensure month is a valid integer
|
|
10964
11207
|
if (Number.isNaN(numMonth)) {
|
|
10965
|
-
throw new Error(
|
|
11208
|
+
throw new Error(
|
|
11209
|
+
"AuroDatepickerUtilities | monthValueIsValid: Unable to parse month value integer",
|
|
11210
|
+
);
|
|
10966
11211
|
}
|
|
10967
11212
|
|
|
10968
11213
|
// Guard clause: ensure month is within the valid range
|
|
@@ -10976,6 +11221,10 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
10976
11221
|
|
|
10977
11222
|
// Validator for year
|
|
10978
11223
|
const yearIsValid = (_year) => {
|
|
11224
|
+
// Guard clause: if there is no year in the dateParts, we can ignore this check.
|
|
11225
|
+
if (!dateParts.year) {
|
|
11226
|
+
return true;
|
|
11227
|
+
}
|
|
10979
11228
|
|
|
10980
11229
|
// Guard clause: ensure year exists.
|
|
10981
11230
|
if (!_year) {
|
|
@@ -10990,7 +11239,9 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
10990
11239
|
|
|
10991
11240
|
// Guard clause: ensure year is a valid integer
|
|
10992
11241
|
if (Number.isNaN(numYear)) {
|
|
10993
|
-
throw new Error(
|
|
11242
|
+
throw new Error(
|
|
11243
|
+
"AuroDatepickerUtilities | yearValueIsValid: Unable to parse year value integer",
|
|
11244
|
+
);
|
|
10994
11245
|
}
|
|
10995
11246
|
|
|
10996
11247
|
// Guard clause: ensure year is within the valid range
|
|
@@ -11006,7 +11257,7 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
11006
11257
|
const checks = [
|
|
11007
11258
|
monthValueIsValid(dateParts.month),
|
|
11008
11259
|
dayValueIsValid(dateParts.day),
|
|
11009
|
-
yearIsValid(dateParts.year)
|
|
11260
|
+
yearIsValid(dateParts.year),
|
|
11010
11261
|
];
|
|
11011
11262
|
|
|
11012
11263
|
// If any of the checks failed, the date format does not match and the result is invalid
|
|
@@ -11040,10 +11291,7 @@ const {
|
|
|
11040
11291
|
} = dateUtilities;
|
|
11041
11292
|
|
|
11042
11293
|
const {
|
|
11043
|
-
toNorthAmericanFormat
|
|
11044
|
-
parseDate,
|
|
11045
|
-
getDateAsString
|
|
11046
|
-
} = dateFormatter;
|
|
11294
|
+
toNorthAmericanFormat} = dateFormatter;
|
|
11047
11295
|
|
|
11048
11296
|
// Copyright (c) Alaska Air. All right reserved. Licensed under the Apache-2.0 license
|
|
11049
11297
|
// See LICENSE in the project root for license information.
|
|
@@ -13258,7 +13506,7 @@ let AuroHelpText$1 = class AuroHelpText extends i$4 {
|
|
|
13258
13506
|
}
|
|
13259
13507
|
};
|
|
13260
13508
|
|
|
13261
|
-
var formkitVersion$1 = '
|
|
13509
|
+
var formkitVersion$1 = '202606012139';
|
|
13262
13510
|
|
|
13263
13511
|
// Copyright (c) 2025 Alaska Airlines. All right reserved. Licensed under the Apache-2.0 license
|
|
13264
13512
|
// See LICENSE in the project root for license information.
|
|
@@ -14331,7 +14579,7 @@ class AuroBibtemplate extends i$4 {
|
|
|
14331
14579
|
}
|
|
14332
14580
|
}
|
|
14333
14581
|
|
|
14334
|
-
var formkitVersion = '
|
|
14582
|
+
var formkitVersion = '202606012139';
|
|
14335
14583
|
|
|
14336
14584
|
var styleCss$3 = i$7`.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}`;
|
|
14337
14585
|
|