@aurodesignsystem-dev/auro-formkit 0.0.0-pr1489.5 → 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 +1818 -1491
- package/package.json +8 -8
|
@@ -167,109 +167,236 @@ let AuroLibraryRuntimeUtils$4 = class AuroLibraryRuntimeUtils {
|
|
|
167
167
|
}
|
|
168
168
|
};
|
|
169
169
|
|
|
170
|
-
|
|
170
|
+
/**
|
|
171
|
+
* @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.
|
|
172
|
+
* @param {string} dateStr - Date string to parse.
|
|
173
|
+
* @param {string} format - Date format to parse.
|
|
174
|
+
* @returns {{ month?: string, day?: string, year?: string }|undefined}
|
|
175
|
+
*/
|
|
176
|
+
function getDateParts$1(dateStr, format) {
|
|
177
|
+
if (!dateStr) {
|
|
178
|
+
return undefined;
|
|
179
|
+
}
|
|
171
180
|
|
|
172
|
-
|
|
181
|
+
const formatSeparatorMatch = format.match(/[/.-]/);
|
|
182
|
+
let valueParts;
|
|
183
|
+
let formatParts;
|
|
173
184
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
185
|
+
if (formatSeparatorMatch) {
|
|
186
|
+
const separator = formatSeparatorMatch[0];
|
|
187
|
+
valueParts = dateStr.split(separator);
|
|
188
|
+
formatParts = format.split(separator);
|
|
189
|
+
} else {
|
|
190
|
+
if (dateStr.match(/[/.-]/)) {
|
|
191
|
+
throw new Error(
|
|
192
|
+
"AuroDatepickerUtilities | parseDate: Date string has no separators",
|
|
193
|
+
);
|
|
194
|
+
}
|
|
181
195
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
196
|
+
if (dateStr.length !== format.length) {
|
|
197
|
+
throw new Error(
|
|
198
|
+
"AuroDatepickerUtilities | parseDate: Date string and format length do not match",
|
|
199
|
+
);
|
|
200
|
+
}
|
|
186
201
|
|
|
187
|
-
|
|
188
|
-
|
|
202
|
+
valueParts = [dateStr];
|
|
203
|
+
formatParts = [format];
|
|
204
|
+
}
|
|
189
205
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
206
|
+
if (valueParts.length !== formatParts.length) {
|
|
207
|
+
throw new Error(
|
|
208
|
+
`AuroDatepickerUtilities | parseDate: Date string and format do not match : ${dateStr} vs ${format}`,
|
|
209
|
+
);
|
|
210
|
+
}
|
|
193
211
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
throw new Error('AuroDatepickerUtilities | parseDate: Date string and format length do not match');
|
|
197
|
-
}
|
|
212
|
+
const result = formatParts.reduce((acc, part, index) => {
|
|
213
|
+
const value = valueParts[index];
|
|
198
214
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
215
|
+
if (/m/iu.test(part) && part.length === value.length) {
|
|
216
|
+
acc.month = value;
|
|
217
|
+
} else if (/d/iu.test(part) && part.length === value.length) {
|
|
218
|
+
acc.day = value;
|
|
219
|
+
} else if (/y/iu.test(part) && part.length === value.length) {
|
|
220
|
+
acc.year = value;
|
|
221
|
+
}
|
|
202
222
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
} else if ((/d/iu).test(part)) {
|
|
206
|
-
acc.day = value;
|
|
207
|
-
} else if ((/y/iu).test(part)) {
|
|
208
|
-
acc.year = value;
|
|
209
|
-
}
|
|
223
|
+
return acc;
|
|
224
|
+
}, {});
|
|
210
225
|
|
|
211
|
-
|
|
212
|
-
|
|
226
|
+
if (!result.month && !result.day && !result.year) {
|
|
227
|
+
throw new Error(
|
|
228
|
+
"AuroDatepickerUtilities | parseDate: Unable to parse date string",
|
|
229
|
+
);
|
|
230
|
+
}
|
|
213
231
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
return result;
|
|
217
|
-
}
|
|
232
|
+
return result;
|
|
233
|
+
}
|
|
218
234
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
235
|
+
function isCalendarDate$1(year, month, day) {
|
|
236
|
+
let yearNumber = Number(year);
|
|
237
|
+
const monthNumber = Number(month);
|
|
238
|
+
const dayNumber = Number(day);
|
|
222
239
|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
year: "numeric",
|
|
231
|
-
month: "2-digit",
|
|
232
|
-
day: "2-digit",
|
|
233
|
-
});
|
|
240
|
+
if (
|
|
241
|
+
!Number.isInteger(yearNumber) ||
|
|
242
|
+
!Number.isInteger(monthNumber) ||
|
|
243
|
+
!Number.isInteger(dayNumber)
|
|
244
|
+
) {
|
|
245
|
+
return false;
|
|
246
|
+
}
|
|
234
247
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
this.toNorthAmericanFormat = (dateStr, format) => {
|
|
248
|
+
// 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.
|
|
249
|
+
if (yearNumber < 100 && yearNumber >= 50) {
|
|
250
|
+
yearNumber += 1900;
|
|
251
|
+
} else if (yearNumber < 50) {
|
|
252
|
+
yearNumber += 2000;
|
|
253
|
+
}
|
|
242
254
|
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
}
|
|
255
|
+
const stringified = `${String(yearNumber).padStart(4, "0")}-${String(monthNumber).padStart(2, "0")}-${String(dayNumber).padStart(2, "0")}`;
|
|
256
|
+
const date = new Date(stringified.replace(/[.-]/g, "/"));
|
|
246
257
|
|
|
247
|
-
|
|
258
|
+
return (
|
|
259
|
+
!Number.isNaN(date.getTime()) && toISOFormatString$1(date) === stringified
|
|
260
|
+
);
|
|
261
|
+
}
|
|
248
262
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
263
|
+
/**
|
|
264
|
+
* @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).
|
|
265
|
+
*
|
|
266
|
+
* Partial formats are supported: components absent from `format` default to `year → "0"`,
|
|
267
|
+
* `month → "01"`, `day → "01"` for calendar validation only. The returned object contains
|
|
268
|
+
* only the fields actually present in the format string — missing fields are never injected.
|
|
269
|
+
* @param {string} dateStr - Date string to parse.
|
|
270
|
+
* @param {string} format - Date format to parse.
|
|
271
|
+
* @returns {{ month?: string, day?: string, year?: string }|undefined}
|
|
272
|
+
* @throws {Error} Throws when the parsed result does not represent a valid calendar date.
|
|
273
|
+
*/
|
|
274
|
+
function parseDate$1(dateStr, format = "mm/dd/yyyy") {
|
|
275
|
+
if (!dateStr || !format) {
|
|
276
|
+
return undefined;
|
|
277
|
+
}
|
|
278
|
+
const result = getDateParts$1(dateStr.trim(), format);
|
|
279
|
+
|
|
280
|
+
if (!result) {
|
|
281
|
+
return undefined;
|
|
282
|
+
}
|
|
252
283
|
|
|
253
|
-
|
|
284
|
+
const lowerFormat = format.toLowerCase();
|
|
285
|
+
const year = lowerFormat.includes("yy") ? result.year : "0";
|
|
286
|
+
const month = lowerFormat.includes("mm") ? result.month : "01";
|
|
287
|
+
const day = lowerFormat.includes("dd") ? result.day : "01";
|
|
254
288
|
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
}
|
|
289
|
+
if (isCalendarDate$1(year, month, day)) {
|
|
290
|
+
return result;
|
|
291
|
+
}
|
|
259
292
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
293
|
+
throw new Error(
|
|
294
|
+
`AuroDatepickerUtilities | parseDate: Date string is not a valid date ${JSON.stringify(result)} with format ${format}`,
|
|
295
|
+
);
|
|
296
|
+
}
|
|
263
297
|
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
298
|
+
/**
|
|
299
|
+
* Convert a date object to string format.
|
|
300
|
+
* @param {Object} date - Date to convert to string.
|
|
301
|
+
* @param {String} locale - Optional locale to use for the date string. Defaults to user's locale.
|
|
302
|
+
* @returns {String} Returns the date as a string.
|
|
303
|
+
*/
|
|
304
|
+
function getDateAsString$1(date, locale = undefined) {
|
|
305
|
+
return date.toLocaleDateString(locale, {
|
|
306
|
+
year: "numeric",
|
|
307
|
+
month: "2-digit",
|
|
308
|
+
day: "2-digit",
|
|
309
|
+
});
|
|
310
|
+
}
|
|
267
311
|
|
|
268
|
-
|
|
269
|
-
|
|
312
|
+
/**
|
|
313
|
+
* Converts a date string to a North American date format.
|
|
314
|
+
* @param {String} dateStr - Date to validate.
|
|
315
|
+
* @param {String} format - Date format to validate against.
|
|
316
|
+
* @returns {String}
|
|
317
|
+
*/
|
|
318
|
+
function toNorthAmericanFormat$3(dateStr, format) {
|
|
319
|
+
if (format === "mm/dd/yyyy") {
|
|
320
|
+
return dateStr;
|
|
270
321
|
}
|
|
322
|
+
|
|
323
|
+
const parsedDate = parseDate$1(dateStr, format);
|
|
324
|
+
|
|
325
|
+
if (!parsedDate) {
|
|
326
|
+
throw new Error(
|
|
327
|
+
"AuroDatepickerUtilities | toNorthAmericanFormat: Unable to parse date string",
|
|
328
|
+
);
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
const { month, day, year } = parsedDate;
|
|
332
|
+
|
|
333
|
+
return [month, day, year].filter(Boolean).join("/");
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* Validates that a date string matches the provided format and represents a real calendar date.
|
|
338
|
+
*
|
|
339
|
+
* @param {string} dateStr - Date string to validate.
|
|
340
|
+
* @param {string} [format="yyyy-mm-dd"] - Format of the date string.
|
|
341
|
+
* @returns {boolean} True when the date string is valid for the provided format, otherwise false.
|
|
342
|
+
*/
|
|
343
|
+
function isValidDate$1(dateStr, format = "yyyy-mm-dd") {
|
|
344
|
+
try {
|
|
345
|
+
if (typeof dateStr !== "string" || !dateStr || format?.length < 8) {
|
|
346
|
+
return false;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
if (parseDate$1(dateStr, format)) {
|
|
350
|
+
return true;
|
|
351
|
+
}
|
|
352
|
+
} catch (error) {
|
|
353
|
+
return false;
|
|
354
|
+
}
|
|
355
|
+
return false;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* 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.
|
|
360
|
+
*
|
|
361
|
+
* @param {Date} date - Date instance to convert to an ISO-like string.
|
|
362
|
+
* @returns {string} A string in the format "yyyy-mm-dd" representing the provided date.
|
|
363
|
+
* @throws {Error} Throws an error when the input is not a valid Date instance.
|
|
364
|
+
*/
|
|
365
|
+
function toISOFormatString$1(date) {
|
|
366
|
+
if (!(date instanceof Date) || Number.isNaN(date.getTime())) {
|
|
367
|
+
throw new Error(
|
|
368
|
+
"AuroDatepickerUtilities | toISOFormatString: Input must be a valid Date instance",
|
|
369
|
+
);
|
|
370
|
+
}
|
|
371
|
+
return `${String(date.getFullYear()).padStart(4, "0")}-${String(date.getMonth() + 1).padStart(2, "0")}-${String(date.getDate()).padStart(2, "0")}`;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
/**
|
|
375
|
+
* 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.
|
|
376
|
+
*
|
|
377
|
+
* @param {String} dateStr - Date string to convert into a Date object.
|
|
378
|
+
* @param {String} format - Date format used to parse the string when it is not in ISO format.
|
|
379
|
+
* @returns {Date|null} Returns a Date instance for valid input or null for non-string input.
|
|
380
|
+
* @throws {Error} Throws when parsing fails for non-ISO string input.
|
|
381
|
+
*/
|
|
382
|
+
function stringToDateInstance$1(dateStr, format = "yyyy-mm-dd") {
|
|
383
|
+
if (typeof dateStr !== "string") {
|
|
384
|
+
return null;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
const { month, day, year } = parseDate$1(dateStr, format);
|
|
388
|
+
return new Date(`${year}/${month}/${day}`);
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
const dateFormatter$1 = {
|
|
392
|
+
parseDate: parseDate$1,
|
|
393
|
+
getDateParts: getDateParts$1,
|
|
394
|
+
getDateAsString: getDateAsString$1,
|
|
395
|
+
toNorthAmericanFormat: toNorthAmericanFormat$3,
|
|
396
|
+
isValidDate: isValidDate$1,
|
|
397
|
+
toISOFormatString: toISOFormatString$1,
|
|
398
|
+
stringToDateInstance: stringToDateInstance$1,
|
|
271
399
|
};
|
|
272
|
-
const dateFormatter$1 = new DateFormatter$1();
|
|
273
400
|
|
|
274
401
|
// filepath: dateConstraints.mjs
|
|
275
402
|
const DATE_UTIL_CONSTRAINTS$1 = {
|
|
@@ -341,12 +468,11 @@ let AuroDateUtilitiesBase$1 = class AuroDateUtilitiesBase {
|
|
|
341
468
|
/* eslint-disable no-magic-numbers */
|
|
342
469
|
|
|
343
470
|
let AuroDateUtilities$1 = class AuroDateUtilities extends AuroDateUtilitiesBase$1 {
|
|
344
|
-
|
|
345
471
|
/**
|
|
346
472
|
* Returns the current century.
|
|
347
473
|
* @returns {String} The current century.
|
|
348
474
|
*/
|
|
349
|
-
getCentury
|
|
475
|
+
getCentury() {
|
|
350
476
|
return String(new Date().getFullYear()).slice(0, 2);
|
|
351
477
|
}
|
|
352
478
|
|
|
@@ -355,14 +481,12 @@ let AuroDateUtilities$1 = class AuroDateUtilities extends AuroDateUtilitiesBase$
|
|
|
355
481
|
* @param {String} year - The year to convert to four digits.
|
|
356
482
|
* @returns {String} The four digit year.
|
|
357
483
|
*/
|
|
358
|
-
getFourDigitYear
|
|
359
|
-
|
|
484
|
+
getFourDigitYear(year) {
|
|
360
485
|
const strYear = String(year).trim();
|
|
361
486
|
return strYear.length <= 2 ? this.getCentury() + strYear : strYear;
|
|
362
487
|
}
|
|
363
488
|
|
|
364
489
|
constructor() {
|
|
365
|
-
|
|
366
490
|
super();
|
|
367
491
|
|
|
368
492
|
/**
|
|
@@ -371,7 +495,8 @@ let AuroDateUtilities$1 = class AuroDateUtilities extends AuroDateUtilitiesBase$
|
|
|
371
495
|
* @param {Object} date2 - Second date to compare.
|
|
372
496
|
* @returns {Boolean} Returns true if the dates match.
|
|
373
497
|
*/
|
|
374
|
-
this.datesMatch = (date1, date2) =>
|
|
498
|
+
this.datesMatch = (date1, date2) =>
|
|
499
|
+
new Date(date1).getTime() === new Date(date2).getTime();
|
|
375
500
|
|
|
376
501
|
/**
|
|
377
502
|
* Returns true if value passed in is a valid date.
|
|
@@ -380,53 +505,41 @@ let AuroDateUtilities$1 = class AuroDateUtilities extends AuroDateUtilitiesBase$
|
|
|
380
505
|
* @returns {Boolean}
|
|
381
506
|
*/
|
|
382
507
|
this.validDateStr = (date, format) => {
|
|
383
|
-
|
|
384
508
|
// The length we expect the date string to be
|
|
385
|
-
const dateStrLength = format
|
|
509
|
+
const dateStrLength = format?.length || 0;
|
|
386
510
|
|
|
387
511
|
// Guard Clause: Date and format are defined
|
|
388
512
|
if (typeof date === "undefined" || typeof format === "undefined") {
|
|
389
|
-
throw new Error(
|
|
513
|
+
throw new Error(
|
|
514
|
+
"AuroDatepickerUtilities | validateDateStr: Date and format are required",
|
|
515
|
+
);
|
|
390
516
|
}
|
|
391
517
|
|
|
392
518
|
// Guard Clause: Date should be of type string
|
|
393
519
|
if (typeof date !== "string") {
|
|
394
|
-
throw new Error(
|
|
520
|
+
throw new Error(
|
|
521
|
+
"AuroDatepickerUtilities | validateDateStr: Date must be a string",
|
|
522
|
+
);
|
|
395
523
|
}
|
|
396
524
|
|
|
397
525
|
// Guard Clause: Format should be of type string
|
|
398
526
|
if (typeof format !== "string") {
|
|
399
|
-
throw new Error(
|
|
527
|
+
throw new Error(
|
|
528
|
+
"AuroDatepickerUtilities | validateDateStr: Format must be a string",
|
|
529
|
+
);
|
|
400
530
|
}
|
|
401
531
|
|
|
402
532
|
// Guard Clause: Length is what we expect it to be
|
|
403
533
|
if (date.length !== dateStrLength) {
|
|
404
534
|
return false;
|
|
405
535
|
}
|
|
406
|
-
// Get a formatted date string and parse it
|
|
407
|
-
const dateParts = dateFormatter$1.parseDate(date, format);
|
|
408
|
-
|
|
409
|
-
// Guard Clause: Date parse succeeded
|
|
410
|
-
if (!dateParts) {
|
|
411
|
-
return false;
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
// Create the expected date string based on the date parts
|
|
415
|
-
const expectedDateStr = `${dateParts.month}/${dateParts.day || "01"}/${this.getFourDigitYear(dateParts.year)}`;
|
|
416
536
|
|
|
417
|
-
//
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
const actualDateStr = dateFormatter$1.getDateAsString(dateObj, "en-US");
|
|
422
|
-
|
|
423
|
-
// Guard Clause: Generated date matches date string input
|
|
424
|
-
if (expectedDateStr !== actualDateStr) {
|
|
537
|
+
// Get a formatted date string and parse and validate it
|
|
538
|
+
try {
|
|
539
|
+
return Boolean(dateFormatter$1.parseDate(date, format));
|
|
540
|
+
} catch (error) {
|
|
425
541
|
return false;
|
|
426
542
|
}
|
|
427
|
-
|
|
428
|
-
// If we passed all other checks, we can assume the date is valid
|
|
429
|
-
return true;
|
|
430
543
|
};
|
|
431
544
|
|
|
432
545
|
/**
|
|
@@ -436,10 +549,11 @@ let AuroDateUtilities$1 = class AuroDateUtilities extends AuroDateUtilitiesBase$
|
|
|
436
549
|
* @returns {boolean}
|
|
437
550
|
*/
|
|
438
551
|
this.dateAndFormatMatch = (value, format) => {
|
|
439
|
-
|
|
440
552
|
// Ensure we have both values we need to do the comparison
|
|
441
553
|
if (!value || !format) {
|
|
442
|
-
throw new Error(
|
|
554
|
+
throw new Error(
|
|
555
|
+
"AuroFormValidation | dateFormatMatch: value and format are required",
|
|
556
|
+
);
|
|
443
557
|
}
|
|
444
558
|
|
|
445
559
|
// If the lengths are different, they cannot match
|
|
@@ -448,11 +562,10 @@ let AuroDateUtilities$1 = class AuroDateUtilities extends AuroDateUtilitiesBase$
|
|
|
448
562
|
}
|
|
449
563
|
|
|
450
564
|
// Get the parts of the date
|
|
451
|
-
const dateParts = dateFormatter$1.
|
|
565
|
+
const dateParts = dateFormatter$1.getDateParts(value, format);
|
|
452
566
|
|
|
453
567
|
// Validator for day
|
|
454
568
|
const dayValueIsValid = (day) => {
|
|
455
|
-
|
|
456
569
|
// Guard clause: if there is no day in the dateParts, we can ignore this check.
|
|
457
570
|
if (!dateParts.day) {
|
|
458
571
|
return true;
|
|
@@ -468,7 +581,9 @@ let AuroDateUtilities$1 = class AuroDateUtilities extends AuroDateUtilitiesBase$
|
|
|
468
581
|
|
|
469
582
|
// Guard clause: ensure day is a valid integer
|
|
470
583
|
if (Number.isNaN(numDay)) {
|
|
471
|
-
throw new Error(
|
|
584
|
+
throw new Error(
|
|
585
|
+
"AuroDatepickerUtilities | dayValueIsValid: Unable to parse day value integer",
|
|
586
|
+
);
|
|
472
587
|
}
|
|
473
588
|
|
|
474
589
|
// Guard clause: ensure day is within the valid range
|
|
@@ -482,6 +597,10 @@ let AuroDateUtilities$1 = class AuroDateUtilities extends AuroDateUtilitiesBase$
|
|
|
482
597
|
|
|
483
598
|
// Validator for month
|
|
484
599
|
const monthValueIsValid = (month) => {
|
|
600
|
+
// Guard clause: if there is no month in the dateParts, we can ignore this check.
|
|
601
|
+
if (!dateParts.month) {
|
|
602
|
+
return true;
|
|
603
|
+
}
|
|
485
604
|
|
|
486
605
|
// Guard clause: ensure month exists.
|
|
487
606
|
if (!month) {
|
|
@@ -493,7 +612,9 @@ let AuroDateUtilities$1 = class AuroDateUtilities extends AuroDateUtilitiesBase$
|
|
|
493
612
|
|
|
494
613
|
// Guard clause: ensure month is a valid integer
|
|
495
614
|
if (Number.isNaN(numMonth)) {
|
|
496
|
-
throw new Error(
|
|
615
|
+
throw new Error(
|
|
616
|
+
"AuroDatepickerUtilities | monthValueIsValid: Unable to parse month value integer",
|
|
617
|
+
);
|
|
497
618
|
}
|
|
498
619
|
|
|
499
620
|
// Guard clause: ensure month is within the valid range
|
|
@@ -507,6 +628,10 @@ let AuroDateUtilities$1 = class AuroDateUtilities extends AuroDateUtilitiesBase$
|
|
|
507
628
|
|
|
508
629
|
// Validator for year
|
|
509
630
|
const yearIsValid = (_year) => {
|
|
631
|
+
// Guard clause: if there is no year in the dateParts, we can ignore this check.
|
|
632
|
+
if (!dateParts.year) {
|
|
633
|
+
return true;
|
|
634
|
+
}
|
|
510
635
|
|
|
511
636
|
// Guard clause: ensure year exists.
|
|
512
637
|
if (!_year) {
|
|
@@ -521,7 +646,9 @@ let AuroDateUtilities$1 = class AuroDateUtilities extends AuroDateUtilitiesBase$
|
|
|
521
646
|
|
|
522
647
|
// Guard clause: ensure year is a valid integer
|
|
523
648
|
if (Number.isNaN(numYear)) {
|
|
524
|
-
throw new Error(
|
|
649
|
+
throw new Error(
|
|
650
|
+
"AuroDatepickerUtilities | yearValueIsValid: Unable to parse year value integer",
|
|
651
|
+
);
|
|
525
652
|
}
|
|
526
653
|
|
|
527
654
|
// Guard clause: ensure year is within the valid range
|
|
@@ -537,7 +664,7 @@ let AuroDateUtilities$1 = class AuroDateUtilities extends AuroDateUtilitiesBase$
|
|
|
537
664
|
const checks = [
|
|
538
665
|
monthValueIsValid(dateParts.month),
|
|
539
666
|
dayValueIsValid(dateParts.day),
|
|
540
|
-
yearIsValid(dateParts.year)
|
|
667
|
+
yearIsValid(dateParts.year),
|
|
541
668
|
];
|
|
542
669
|
|
|
543
670
|
// If any of the checks failed, the date format does not match and the result is invalid
|
|
@@ -571,10 +698,7 @@ const {
|
|
|
571
698
|
} = dateUtilities$1;
|
|
572
699
|
|
|
573
700
|
const {
|
|
574
|
-
toNorthAmericanFormat: toNorthAmericanFormat$1
|
|
575
|
-
parseDate: parseDate$1,
|
|
576
|
-
getDateAsString: getDateAsString$1
|
|
577
|
-
} = dateFormatter$1;
|
|
701
|
+
toNorthAmericanFormat: toNorthAmericanFormat$2} = dateFormatter$1;
|
|
578
702
|
|
|
579
703
|
// Copyright (c) Alaska Air. All right reserved. Licensed under the Apache-2.0 license
|
|
580
704
|
// See LICENSE in the project root for license information.
|
|
@@ -811,13 +935,13 @@ let AuroFormValidation$1 = class AuroFormValidation {
|
|
|
811
935
|
}
|
|
812
936
|
|
|
813
937
|
// Perform the rest of the validation
|
|
814
|
-
const formattedValue = toNorthAmericanFormat$
|
|
938
|
+
const formattedValue = toNorthAmericanFormat$2(elem.value, elem.format);
|
|
815
939
|
const valueDate = new Date(formattedValue);
|
|
816
940
|
|
|
817
941
|
// // Validate max date
|
|
818
942
|
if (elem.max?.length === elem.lengthForType) {
|
|
819
943
|
|
|
820
|
-
const maxDate = new Date(toNorthAmericanFormat$
|
|
944
|
+
const maxDate = new Date(toNorthAmericanFormat$2(elem.max, elem.format));
|
|
821
945
|
|
|
822
946
|
if (valueDate > maxDate) {
|
|
823
947
|
elem.validity = 'rangeOverflow';
|
|
@@ -828,7 +952,7 @@ let AuroFormValidation$1 = class AuroFormValidation {
|
|
|
828
952
|
|
|
829
953
|
// Validate min date
|
|
830
954
|
if (elem.min?.length === elem.lengthForType) {
|
|
831
|
-
const minDate = new Date(toNorthAmericanFormat$
|
|
955
|
+
const minDate = new Date(toNorthAmericanFormat$2(elem.min, elem.format));
|
|
832
956
|
|
|
833
957
|
if (valueDate < minDate) {
|
|
834
958
|
elem.validity = 'rangeUnderflow';
|
|
@@ -5278,7 +5402,7 @@ let AuroHelpText$2 = class AuroHelpText extends i$4 {
|
|
|
5278
5402
|
}
|
|
5279
5403
|
};
|
|
5280
5404
|
|
|
5281
|
-
var formkitVersion$2 = '
|
|
5405
|
+
var formkitVersion$2 = '202606012139';
|
|
5282
5406
|
|
|
5283
5407
|
let AuroElement$2 = class AuroElement extends i$4 {
|
|
5284
5408
|
static get properties() {
|
|
@@ -10621,109 +10745,236 @@ class AuroInputUtilities {
|
|
|
10621
10745
|
}
|
|
10622
10746
|
}
|
|
10623
10747
|
|
|
10624
|
-
|
|
10748
|
+
/**
|
|
10749
|
+
* @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.
|
|
10750
|
+
* @param {string} dateStr - Date string to parse.
|
|
10751
|
+
* @param {string} format - Date format to parse.
|
|
10752
|
+
* @returns {{ month?: string, day?: string, year?: string }|undefined}
|
|
10753
|
+
*/
|
|
10754
|
+
function getDateParts(dateStr, format) {
|
|
10755
|
+
if (!dateStr) {
|
|
10756
|
+
return undefined;
|
|
10757
|
+
}
|
|
10625
10758
|
|
|
10626
|
-
|
|
10759
|
+
const formatSeparatorMatch = format.match(/[/.-]/);
|
|
10760
|
+
let valueParts;
|
|
10761
|
+
let formatParts;
|
|
10627
10762
|
|
|
10628
|
-
|
|
10629
|
-
|
|
10630
|
-
|
|
10631
|
-
|
|
10632
|
-
|
|
10633
|
-
|
|
10634
|
-
|
|
10763
|
+
if (formatSeparatorMatch) {
|
|
10764
|
+
const separator = formatSeparatorMatch[0];
|
|
10765
|
+
valueParts = dateStr.split(separator);
|
|
10766
|
+
formatParts = format.split(separator);
|
|
10767
|
+
} else {
|
|
10768
|
+
if (dateStr.match(/[/.-]/)) {
|
|
10769
|
+
throw new Error(
|
|
10770
|
+
"AuroDatepickerUtilities | parseDate: Date string has no separators",
|
|
10771
|
+
);
|
|
10772
|
+
}
|
|
10635
10773
|
|
|
10636
|
-
|
|
10637
|
-
|
|
10638
|
-
|
|
10639
|
-
|
|
10774
|
+
if (dateStr.length !== format.length) {
|
|
10775
|
+
throw new Error(
|
|
10776
|
+
"AuroDatepickerUtilities | parseDate: Date string and format length do not match",
|
|
10777
|
+
);
|
|
10778
|
+
}
|
|
10640
10779
|
|
|
10641
|
-
|
|
10642
|
-
|
|
10780
|
+
valueParts = [dateStr];
|
|
10781
|
+
formatParts = [format];
|
|
10782
|
+
}
|
|
10643
10783
|
|
|
10644
|
-
|
|
10645
|
-
|
|
10646
|
-
|
|
10784
|
+
if (valueParts.length !== formatParts.length) {
|
|
10785
|
+
throw new Error(
|
|
10786
|
+
`AuroDatepickerUtilities | parseDate: Date string and format do not match : ${dateStr} vs ${format}`,
|
|
10787
|
+
);
|
|
10788
|
+
}
|
|
10647
10789
|
|
|
10648
|
-
|
|
10649
|
-
|
|
10650
|
-
throw new Error('AuroDatepickerUtilities | parseDate: Date string and format length do not match');
|
|
10651
|
-
}
|
|
10790
|
+
const result = formatParts.reduce((acc, part, index) => {
|
|
10791
|
+
const value = valueParts[index];
|
|
10652
10792
|
|
|
10653
|
-
|
|
10654
|
-
|
|
10655
|
-
|
|
10793
|
+
if (/m/iu.test(part) && part.length === value.length) {
|
|
10794
|
+
acc.month = value;
|
|
10795
|
+
} else if (/d/iu.test(part) && part.length === value.length) {
|
|
10796
|
+
acc.day = value;
|
|
10797
|
+
} else if (/y/iu.test(part) && part.length === value.length) {
|
|
10798
|
+
acc.year = value;
|
|
10799
|
+
}
|
|
10656
10800
|
|
|
10657
|
-
|
|
10658
|
-
|
|
10659
|
-
} else if ((/d/iu).test(part)) {
|
|
10660
|
-
acc.day = value;
|
|
10661
|
-
} else if ((/y/iu).test(part)) {
|
|
10662
|
-
acc.year = value;
|
|
10663
|
-
}
|
|
10801
|
+
return acc;
|
|
10802
|
+
}, {});
|
|
10664
10803
|
|
|
10665
|
-
|
|
10666
|
-
|
|
10804
|
+
if (!result.month && !result.day && !result.year) {
|
|
10805
|
+
throw new Error(
|
|
10806
|
+
"AuroDatepickerUtilities | parseDate: Unable to parse date string",
|
|
10807
|
+
);
|
|
10808
|
+
}
|
|
10667
10809
|
|
|
10668
|
-
|
|
10669
|
-
|
|
10670
|
-
return result;
|
|
10671
|
-
}
|
|
10810
|
+
return result;
|
|
10811
|
+
}
|
|
10672
10812
|
|
|
10673
|
-
|
|
10674
|
-
|
|
10675
|
-
|
|
10813
|
+
function isCalendarDate(year, month, day) {
|
|
10814
|
+
let yearNumber = Number(year);
|
|
10815
|
+
const monthNumber = Number(month);
|
|
10816
|
+
const dayNumber = Number(day);
|
|
10676
10817
|
|
|
10677
|
-
|
|
10678
|
-
|
|
10679
|
-
|
|
10680
|
-
|
|
10681
|
-
|
|
10682
|
-
|
|
10683
|
-
|
|
10684
|
-
year: "numeric",
|
|
10685
|
-
month: "2-digit",
|
|
10686
|
-
day: "2-digit",
|
|
10687
|
-
});
|
|
10818
|
+
if (
|
|
10819
|
+
!Number.isInteger(yearNumber) ||
|
|
10820
|
+
!Number.isInteger(monthNumber) ||
|
|
10821
|
+
!Number.isInteger(dayNumber)
|
|
10822
|
+
) {
|
|
10823
|
+
return false;
|
|
10824
|
+
}
|
|
10688
10825
|
|
|
10689
|
-
|
|
10690
|
-
|
|
10691
|
-
|
|
10692
|
-
|
|
10693
|
-
|
|
10694
|
-
|
|
10695
|
-
this.toNorthAmericanFormat = (dateStr, format) => {
|
|
10826
|
+
// 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.
|
|
10827
|
+
if (yearNumber < 100 && yearNumber >= 50) {
|
|
10828
|
+
yearNumber += 1900;
|
|
10829
|
+
} else if (yearNumber < 50) {
|
|
10830
|
+
yearNumber += 2000;
|
|
10831
|
+
}
|
|
10696
10832
|
|
|
10697
|
-
|
|
10698
|
-
|
|
10699
|
-
}
|
|
10833
|
+
const stringified = `${String(yearNumber).padStart(4, "0")}-${String(monthNumber).padStart(2, "0")}-${String(dayNumber).padStart(2, "0")}`;
|
|
10834
|
+
const date = new Date(stringified.replace(/[.-]/g, "/"));
|
|
10700
10835
|
|
|
10701
|
-
|
|
10836
|
+
return (
|
|
10837
|
+
!Number.isNaN(date.getTime()) && toISOFormatString(date) === stringified
|
|
10838
|
+
);
|
|
10839
|
+
}
|
|
10702
10840
|
|
|
10703
|
-
|
|
10704
|
-
|
|
10705
|
-
|
|
10841
|
+
/**
|
|
10842
|
+
* @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).
|
|
10843
|
+
*
|
|
10844
|
+
* Partial formats are supported: components absent from `format` default to `year → "0"`,
|
|
10845
|
+
* `month → "01"`, `day → "01"` for calendar validation only. The returned object contains
|
|
10846
|
+
* only the fields actually present in the format string — missing fields are never injected.
|
|
10847
|
+
* @param {string} dateStr - Date string to parse.
|
|
10848
|
+
* @param {string} format - Date format to parse.
|
|
10849
|
+
* @returns {{ month?: string, day?: string, year?: string }|undefined}
|
|
10850
|
+
* @throws {Error} Throws when the parsed result does not represent a valid calendar date.
|
|
10851
|
+
*/
|
|
10852
|
+
function parseDate(dateStr, format = "mm/dd/yyyy") {
|
|
10853
|
+
if (!dateStr || !format) {
|
|
10854
|
+
return undefined;
|
|
10855
|
+
}
|
|
10856
|
+
const result = getDateParts(dateStr.trim(), format);
|
|
10857
|
+
|
|
10858
|
+
if (!result) {
|
|
10859
|
+
return undefined;
|
|
10860
|
+
}
|
|
10706
10861
|
|
|
10707
|
-
|
|
10862
|
+
const lowerFormat = format.toLowerCase();
|
|
10863
|
+
const year = lowerFormat.includes("yy") ? result.year : "0";
|
|
10864
|
+
const month = lowerFormat.includes("mm") ? result.month : "01";
|
|
10865
|
+
const day = lowerFormat.includes("dd") ? result.day : "01";
|
|
10708
10866
|
|
|
10709
|
-
|
|
10710
|
-
|
|
10711
|
-
|
|
10712
|
-
}
|
|
10867
|
+
if (isCalendarDate(year, month, day)) {
|
|
10868
|
+
return result;
|
|
10869
|
+
}
|
|
10713
10870
|
|
|
10714
|
-
|
|
10715
|
-
|
|
10716
|
-
|
|
10871
|
+
throw new Error(
|
|
10872
|
+
`AuroDatepickerUtilities | parseDate: Date string is not a valid date ${JSON.stringify(result)} with format ${format}`,
|
|
10873
|
+
);
|
|
10874
|
+
}
|
|
10717
10875
|
|
|
10718
|
-
|
|
10719
|
-
|
|
10720
|
-
|
|
10876
|
+
/**
|
|
10877
|
+
* Convert a date object to string format.
|
|
10878
|
+
* @param {Object} date - Date to convert to string.
|
|
10879
|
+
* @param {String} locale - Optional locale to use for the date string. Defaults to user's locale.
|
|
10880
|
+
* @returns {String} Returns the date as a string.
|
|
10881
|
+
*/
|
|
10882
|
+
function getDateAsString(date, locale = undefined) {
|
|
10883
|
+
return date.toLocaleDateString(locale, {
|
|
10884
|
+
year: "numeric",
|
|
10885
|
+
month: "2-digit",
|
|
10886
|
+
day: "2-digit",
|
|
10887
|
+
});
|
|
10888
|
+
}
|
|
10721
10889
|
|
|
10722
|
-
|
|
10723
|
-
|
|
10890
|
+
/**
|
|
10891
|
+
* Converts a date string to a North American date format.
|
|
10892
|
+
* @param {String} dateStr - Date to validate.
|
|
10893
|
+
* @param {String} format - Date format to validate against.
|
|
10894
|
+
* @returns {String}
|
|
10895
|
+
*/
|
|
10896
|
+
function toNorthAmericanFormat$1(dateStr, format) {
|
|
10897
|
+
if (format === "mm/dd/yyyy") {
|
|
10898
|
+
return dateStr;
|
|
10724
10899
|
}
|
|
10900
|
+
|
|
10901
|
+
const parsedDate = parseDate(dateStr, format);
|
|
10902
|
+
|
|
10903
|
+
if (!parsedDate) {
|
|
10904
|
+
throw new Error(
|
|
10905
|
+
"AuroDatepickerUtilities | toNorthAmericanFormat: Unable to parse date string",
|
|
10906
|
+
);
|
|
10907
|
+
}
|
|
10908
|
+
|
|
10909
|
+
const { month, day, year } = parsedDate;
|
|
10910
|
+
|
|
10911
|
+
return [month, day, year].filter(Boolean).join("/");
|
|
10912
|
+
}
|
|
10913
|
+
|
|
10914
|
+
/**
|
|
10915
|
+
* Validates that a date string matches the provided format and represents a real calendar date.
|
|
10916
|
+
*
|
|
10917
|
+
* @param {string} dateStr - Date string to validate.
|
|
10918
|
+
* @param {string} [format="yyyy-mm-dd"] - Format of the date string.
|
|
10919
|
+
* @returns {boolean} True when the date string is valid for the provided format, otherwise false.
|
|
10920
|
+
*/
|
|
10921
|
+
function isValidDate(dateStr, format = "yyyy-mm-dd") {
|
|
10922
|
+
try {
|
|
10923
|
+
if (typeof dateStr !== "string" || !dateStr || format?.length < 8) {
|
|
10924
|
+
return false;
|
|
10925
|
+
}
|
|
10926
|
+
|
|
10927
|
+
if (parseDate(dateStr, format)) {
|
|
10928
|
+
return true;
|
|
10929
|
+
}
|
|
10930
|
+
} catch (error) {
|
|
10931
|
+
return false;
|
|
10932
|
+
}
|
|
10933
|
+
return false;
|
|
10934
|
+
}
|
|
10935
|
+
|
|
10936
|
+
/**
|
|
10937
|
+
* 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.
|
|
10938
|
+
*
|
|
10939
|
+
* @param {Date} date - Date instance to convert to an ISO-like string.
|
|
10940
|
+
* @returns {string} A string in the format "yyyy-mm-dd" representing the provided date.
|
|
10941
|
+
* @throws {Error} Throws an error when the input is not a valid Date instance.
|
|
10942
|
+
*/
|
|
10943
|
+
function toISOFormatString(date) {
|
|
10944
|
+
if (!(date instanceof Date) || Number.isNaN(date.getTime())) {
|
|
10945
|
+
throw new Error(
|
|
10946
|
+
"AuroDatepickerUtilities | toISOFormatString: Input must be a valid Date instance",
|
|
10947
|
+
);
|
|
10948
|
+
}
|
|
10949
|
+
return `${String(date.getFullYear()).padStart(4, "0")}-${String(date.getMonth() + 1).padStart(2, "0")}-${String(date.getDate()).padStart(2, "0")}`;
|
|
10725
10950
|
}
|
|
10726
|
-
|
|
10951
|
+
|
|
10952
|
+
/**
|
|
10953
|
+
* 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.
|
|
10954
|
+
*
|
|
10955
|
+
* @param {String} dateStr - Date string to convert into a Date object.
|
|
10956
|
+
* @param {String} format - Date format used to parse the string when it is not in ISO format.
|
|
10957
|
+
* @returns {Date|null} Returns a Date instance for valid input or null for non-string input.
|
|
10958
|
+
* @throws {Error} Throws when parsing fails for non-ISO string input.
|
|
10959
|
+
*/
|
|
10960
|
+
function stringToDateInstance(dateStr, format = "yyyy-mm-dd") {
|
|
10961
|
+
if (typeof dateStr !== "string") {
|
|
10962
|
+
return null;
|
|
10963
|
+
}
|
|
10964
|
+
|
|
10965
|
+
const { month, day, year } = parseDate(dateStr, format);
|
|
10966
|
+
return new Date(`${year}/${month}/${day}`);
|
|
10967
|
+
}
|
|
10968
|
+
|
|
10969
|
+
const dateFormatter = {
|
|
10970
|
+
parseDate,
|
|
10971
|
+
getDateParts,
|
|
10972
|
+
getDateAsString,
|
|
10973
|
+
toNorthAmericanFormat: toNorthAmericanFormat$1,
|
|
10974
|
+
isValidDate,
|
|
10975
|
+
toISOFormatString,
|
|
10976
|
+
stringToDateInstance,
|
|
10977
|
+
};
|
|
10727
10978
|
|
|
10728
10979
|
// filepath: dateConstraints.mjs
|
|
10729
10980
|
const DATE_UTIL_CONSTRAINTS = {
|
|
@@ -10795,12 +11046,11 @@ class AuroDateUtilitiesBase {
|
|
|
10795
11046
|
/* eslint-disable no-magic-numbers */
|
|
10796
11047
|
|
|
10797
11048
|
class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
10798
|
-
|
|
10799
11049
|
/**
|
|
10800
11050
|
* Returns the current century.
|
|
10801
11051
|
* @returns {String} The current century.
|
|
10802
11052
|
*/
|
|
10803
|
-
getCentury
|
|
11053
|
+
getCentury() {
|
|
10804
11054
|
return String(new Date().getFullYear()).slice(0, 2);
|
|
10805
11055
|
}
|
|
10806
11056
|
|
|
@@ -10809,14 +11059,12 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
10809
11059
|
* @param {String} year - The year to convert to four digits.
|
|
10810
11060
|
* @returns {String} The four digit year.
|
|
10811
11061
|
*/
|
|
10812
|
-
getFourDigitYear
|
|
10813
|
-
|
|
11062
|
+
getFourDigitYear(year) {
|
|
10814
11063
|
const strYear = String(year).trim();
|
|
10815
11064
|
return strYear.length <= 2 ? this.getCentury() + strYear : strYear;
|
|
10816
11065
|
}
|
|
10817
11066
|
|
|
10818
11067
|
constructor() {
|
|
10819
|
-
|
|
10820
11068
|
super();
|
|
10821
11069
|
|
|
10822
11070
|
/**
|
|
@@ -10825,7 +11073,8 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
10825
11073
|
* @param {Object} date2 - Second date to compare.
|
|
10826
11074
|
* @returns {Boolean} Returns true if the dates match.
|
|
10827
11075
|
*/
|
|
10828
|
-
this.datesMatch = (date1, date2) =>
|
|
11076
|
+
this.datesMatch = (date1, date2) =>
|
|
11077
|
+
new Date(date1).getTime() === new Date(date2).getTime();
|
|
10829
11078
|
|
|
10830
11079
|
/**
|
|
10831
11080
|
* Returns true if value passed in is a valid date.
|
|
@@ -10834,53 +11083,41 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
10834
11083
|
* @returns {Boolean}
|
|
10835
11084
|
*/
|
|
10836
11085
|
this.validDateStr = (date, format) => {
|
|
10837
|
-
|
|
10838
11086
|
// The length we expect the date string to be
|
|
10839
|
-
const dateStrLength = format
|
|
11087
|
+
const dateStrLength = format?.length || 0;
|
|
10840
11088
|
|
|
10841
11089
|
// Guard Clause: Date and format are defined
|
|
10842
11090
|
if (typeof date === "undefined" || typeof format === "undefined") {
|
|
10843
|
-
throw new Error(
|
|
11091
|
+
throw new Error(
|
|
11092
|
+
"AuroDatepickerUtilities | validateDateStr: Date and format are required",
|
|
11093
|
+
);
|
|
10844
11094
|
}
|
|
10845
11095
|
|
|
10846
11096
|
// Guard Clause: Date should be of type string
|
|
10847
11097
|
if (typeof date !== "string") {
|
|
10848
|
-
throw new Error(
|
|
11098
|
+
throw new Error(
|
|
11099
|
+
"AuroDatepickerUtilities | validateDateStr: Date must be a string",
|
|
11100
|
+
);
|
|
10849
11101
|
}
|
|
10850
11102
|
|
|
10851
11103
|
// Guard Clause: Format should be of type string
|
|
10852
11104
|
if (typeof format !== "string") {
|
|
10853
|
-
throw new Error(
|
|
11105
|
+
throw new Error(
|
|
11106
|
+
"AuroDatepickerUtilities | validateDateStr: Format must be a string",
|
|
11107
|
+
);
|
|
10854
11108
|
}
|
|
10855
11109
|
|
|
10856
11110
|
// Guard Clause: Length is what we expect it to be
|
|
10857
11111
|
if (date.length !== dateStrLength) {
|
|
10858
11112
|
return false;
|
|
10859
11113
|
}
|
|
10860
|
-
// Get a formatted date string and parse it
|
|
10861
|
-
const dateParts = dateFormatter.parseDate(date, format);
|
|
10862
|
-
|
|
10863
|
-
// Guard Clause: Date parse succeeded
|
|
10864
|
-
if (!dateParts) {
|
|
10865
|
-
return false;
|
|
10866
|
-
}
|
|
10867
11114
|
|
|
10868
|
-
//
|
|
10869
|
-
|
|
10870
|
-
|
|
10871
|
-
|
|
10872
|
-
const dateObj = new Date(this.getFourDigitYear(dateParts.year), dateParts.month - 1, dateParts.day || 1);
|
|
10873
|
-
|
|
10874
|
-
// Get the date string of the date object we created from the string date
|
|
10875
|
-
const actualDateStr = dateFormatter.getDateAsString(dateObj, "en-US");
|
|
10876
|
-
|
|
10877
|
-
// Guard Clause: Generated date matches date string input
|
|
10878
|
-
if (expectedDateStr !== actualDateStr) {
|
|
11115
|
+
// Get a formatted date string and parse and validate it
|
|
11116
|
+
try {
|
|
11117
|
+
return Boolean(dateFormatter.parseDate(date, format));
|
|
11118
|
+
} catch (error) {
|
|
10879
11119
|
return false;
|
|
10880
11120
|
}
|
|
10881
|
-
|
|
10882
|
-
// If we passed all other checks, we can assume the date is valid
|
|
10883
|
-
return true;
|
|
10884
11121
|
};
|
|
10885
11122
|
|
|
10886
11123
|
/**
|
|
@@ -10890,10 +11127,11 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
10890
11127
|
* @returns {boolean}
|
|
10891
11128
|
*/
|
|
10892
11129
|
this.dateAndFormatMatch = (value, format) => {
|
|
10893
|
-
|
|
10894
11130
|
// Ensure we have both values we need to do the comparison
|
|
10895
11131
|
if (!value || !format) {
|
|
10896
|
-
throw new Error(
|
|
11132
|
+
throw new Error(
|
|
11133
|
+
"AuroFormValidation | dateFormatMatch: value and format are required",
|
|
11134
|
+
);
|
|
10897
11135
|
}
|
|
10898
11136
|
|
|
10899
11137
|
// If the lengths are different, they cannot match
|
|
@@ -10902,11 +11140,10 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
10902
11140
|
}
|
|
10903
11141
|
|
|
10904
11142
|
// Get the parts of the date
|
|
10905
|
-
const dateParts = dateFormatter.
|
|
11143
|
+
const dateParts = dateFormatter.getDateParts(value, format);
|
|
10906
11144
|
|
|
10907
11145
|
// Validator for day
|
|
10908
11146
|
const dayValueIsValid = (day) => {
|
|
10909
|
-
|
|
10910
11147
|
// Guard clause: if there is no day in the dateParts, we can ignore this check.
|
|
10911
11148
|
if (!dateParts.day) {
|
|
10912
11149
|
return true;
|
|
@@ -10922,7 +11159,9 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
10922
11159
|
|
|
10923
11160
|
// Guard clause: ensure day is a valid integer
|
|
10924
11161
|
if (Number.isNaN(numDay)) {
|
|
10925
|
-
throw new Error(
|
|
11162
|
+
throw new Error(
|
|
11163
|
+
"AuroDatepickerUtilities | dayValueIsValid: Unable to parse day value integer",
|
|
11164
|
+
);
|
|
10926
11165
|
}
|
|
10927
11166
|
|
|
10928
11167
|
// Guard clause: ensure day is within the valid range
|
|
@@ -10936,6 +11175,10 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
10936
11175
|
|
|
10937
11176
|
// Validator for month
|
|
10938
11177
|
const monthValueIsValid = (month) => {
|
|
11178
|
+
// Guard clause: if there is no month in the dateParts, we can ignore this check.
|
|
11179
|
+
if (!dateParts.month) {
|
|
11180
|
+
return true;
|
|
11181
|
+
}
|
|
10939
11182
|
|
|
10940
11183
|
// Guard clause: ensure month exists.
|
|
10941
11184
|
if (!month) {
|
|
@@ -10947,7 +11190,9 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
10947
11190
|
|
|
10948
11191
|
// Guard clause: ensure month is a valid integer
|
|
10949
11192
|
if (Number.isNaN(numMonth)) {
|
|
10950
|
-
throw new Error(
|
|
11193
|
+
throw new Error(
|
|
11194
|
+
"AuroDatepickerUtilities | monthValueIsValid: Unable to parse month value integer",
|
|
11195
|
+
);
|
|
10951
11196
|
}
|
|
10952
11197
|
|
|
10953
11198
|
// Guard clause: ensure month is within the valid range
|
|
@@ -10961,6 +11206,10 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
10961
11206
|
|
|
10962
11207
|
// Validator for year
|
|
10963
11208
|
const yearIsValid = (_year) => {
|
|
11209
|
+
// Guard clause: if there is no year in the dateParts, we can ignore this check.
|
|
11210
|
+
if (!dateParts.year) {
|
|
11211
|
+
return true;
|
|
11212
|
+
}
|
|
10964
11213
|
|
|
10965
11214
|
// Guard clause: ensure year exists.
|
|
10966
11215
|
if (!_year) {
|
|
@@ -10975,7 +11224,9 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
10975
11224
|
|
|
10976
11225
|
// Guard clause: ensure year is a valid integer
|
|
10977
11226
|
if (Number.isNaN(numYear)) {
|
|
10978
|
-
throw new Error(
|
|
11227
|
+
throw new Error(
|
|
11228
|
+
"AuroDatepickerUtilities | yearValueIsValid: Unable to parse year value integer",
|
|
11229
|
+
);
|
|
10979
11230
|
}
|
|
10980
11231
|
|
|
10981
11232
|
// Guard clause: ensure year is within the valid range
|
|
@@ -10991,7 +11242,7 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
10991
11242
|
const checks = [
|
|
10992
11243
|
monthValueIsValid(dateParts.month),
|
|
10993
11244
|
dayValueIsValid(dateParts.day),
|
|
10994
|
-
yearIsValid(dateParts.year)
|
|
11245
|
+
yearIsValid(dateParts.year),
|
|
10995
11246
|
];
|
|
10996
11247
|
|
|
10997
11248
|
// If any of the checks failed, the date format does not match and the result is invalid
|
|
@@ -11025,10 +11276,7 @@ const {
|
|
|
11025
11276
|
} = dateUtilities;
|
|
11026
11277
|
|
|
11027
11278
|
const {
|
|
11028
|
-
toNorthAmericanFormat
|
|
11029
|
-
parseDate,
|
|
11030
|
-
getDateAsString
|
|
11031
|
-
} = dateFormatter;
|
|
11279
|
+
toNorthAmericanFormat} = dateFormatter;
|
|
11032
11280
|
|
|
11033
11281
|
// Copyright (c) Alaska Air. All right reserved. Licensed under the Apache-2.0 license
|
|
11034
11282
|
// See LICENSE in the project root for license information.
|
|
@@ -13243,7 +13491,7 @@ let AuroHelpText$1 = class AuroHelpText extends i$4 {
|
|
|
13243
13491
|
}
|
|
13244
13492
|
};
|
|
13245
13493
|
|
|
13246
|
-
var formkitVersion$1 = '
|
|
13494
|
+
var formkitVersion$1 = '202606012139';
|
|
13247
13495
|
|
|
13248
13496
|
// Copyright (c) 2025 Alaska Airlines. All right reserved. Licensed under the Apache-2.0 license
|
|
13249
13497
|
// See LICENSE in the project root for license information.
|
|
@@ -14316,7 +14564,7 @@ class AuroBibtemplate extends i$4 {
|
|
|
14316
14564
|
}
|
|
14317
14565
|
}
|
|
14318
14566
|
|
|
14319
|
-
var formkitVersion = '
|
|
14567
|
+
var formkitVersion = '202606012139';
|
|
14320
14568
|
|
|
14321
14569
|
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}`;
|
|
14322
14570
|
|