@aurodesignsystem-dev/auro-formkit 0.0.0-pr1489.0 → 0.0.0-pr1489.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/checkbox/demo/customize.min.js +249 -125
- package/components/checkbox/demo/getting-started.min.js +249 -125
- package/components/checkbox/demo/index.min.js +249 -125
- package/components/checkbox/demo/styles.min.css +1 -1
- package/components/checkbox/dist/index.js +249 -125
- package/components/checkbox/dist/registered.js +249 -125
- package/components/combobox/demo/customize.min.js +523 -259
- package/components/combobox/demo/getting-started.min.js +523 -259
- package/components/combobox/demo/index.min.js +523 -259
- package/components/combobox/demo/styles.min.css +1 -1
- package/components/combobox/dist/index.js +523 -259
- package/components/combobox/dist/registered.js +523 -259
- package/components/counter/demo/customize.min.js +271 -131
- package/components/counter/demo/index.min.js +271 -131
- 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 +12 -9
- package/components/datepicker/demo/api.md +1 -1
- package/components/datepicker/demo/customize.md +4 -0
- package/components/datepicker/demo/customize.min.js +1638 -654
- package/components/datepicker/demo/index.md +35 -5
- package/components/datepicker/demo/index.min.js +1654 -659
- package/components/datepicker/demo/keyboard-behavior.md +16 -16
- package/components/datepicker/demo/styles.min.css +1 -1
- package/components/datepicker/demo/voiceover.md +5 -3
- package/components/datepicker/demo/why-datepicker.md +2 -2
- package/components/datepicker/dist/index.js +1642 -658
- package/components/datepicker/dist/registered.js +1642 -658
- package/components/datepicker/dist/src/auro-calendar-cell.d.ts +52 -17
- package/components/datepicker/dist/src/auro-calendar-month.d.ts +12 -4
- package/components/datepicker/dist/src/auro-calendar.d.ts +161 -8
- package/components/datepicker/dist/src/auro-datepicker.d.ts +77 -79
- package/components/dropdown/demo/customize.min.js +22 -6
- package/components/dropdown/demo/getting-started.min.js +22 -6
- package/components/dropdown/demo/index.min.js +22 -6
- package/components/dropdown/demo/styles.min.css +1 -1
- package/components/dropdown/dist/auro-dropdown.d.ts +3 -2
- package/components/dropdown/dist/index.js +22 -6
- package/components/dropdown/dist/registered.js +22 -6
- package/components/form/demo/customize.min.js +3461 -1561
- package/components/form/demo/getting-started.min.js +3461 -1561
- package/components/form/demo/index.min.js +3461 -1561
- package/components/form/demo/registerDemoDeps.min.js +3461 -1561
- package/components/form/demo/styles.min.css +1 -1
- package/components/input/demo/customize.min.js +249 -125
- package/components/input/demo/getting-started.min.js +249 -125
- package/components/input/demo/index.min.js +249 -125
- package/components/input/demo/styles.min.css +1 -1
- package/components/input/dist/index.js +249 -125
- package/components/input/dist/registered.js +249 -125
- package/components/menu/demo/styles.min.css +1 -1
- package/components/radio/demo/customize.min.js +249 -125
- package/components/radio/demo/getting-started.min.js +249 -125
- package/components/radio/demo/index.min.js +249 -125
- package/components/radio/demo/styles.min.css +1 -1
- package/components/radio/dist/index.js +249 -125
- package/components/radio/dist/registered.js +249 -125
- package/components/select/demo/customize.min.js +271 -131
- package/components/select/demo/getting-started.min.js +271 -131
- package/components/select/demo/index.min.js +271 -131
- package/components/select/demo/styles.min.css +1 -1
- package/components/select/dist/index.js +271 -131
- package/components/select/dist/registered.js +271 -131
- package/custom-elements.json +1936 -1614
- package/package.json +8 -8
|
@@ -130,109 +130,236 @@ let AuroLibraryRuntimeUtils$4 = class AuroLibraryRuntimeUtils {
|
|
|
130
130
|
}
|
|
131
131
|
};
|
|
132
132
|
|
|
133
|
-
|
|
133
|
+
/**
|
|
134
|
+
* @description Splits a date string into its parts according to the provided format. Does NOT validate that the result is a real calendar date — use `parseDate` when validation is required.
|
|
135
|
+
* @param {string} dateStr - Date string to parse.
|
|
136
|
+
* @param {string} format - Date format to parse.
|
|
137
|
+
* @returns {{ month?: string, day?: string, year?: string }|undefined}
|
|
138
|
+
*/
|
|
139
|
+
function getDateParts$1(dateStr, format) {
|
|
140
|
+
if (!dateStr) {
|
|
141
|
+
return undefined;
|
|
142
|
+
}
|
|
134
143
|
|
|
135
|
-
|
|
144
|
+
const formatSeparatorMatch = format.match(/[/.-]/);
|
|
145
|
+
let valueParts;
|
|
146
|
+
let formatParts;
|
|
136
147
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
148
|
+
if (formatSeparatorMatch) {
|
|
149
|
+
const separator = formatSeparatorMatch[0];
|
|
150
|
+
valueParts = dateStr.split(separator);
|
|
151
|
+
formatParts = format.split(separator);
|
|
152
|
+
} else {
|
|
153
|
+
if (dateStr.match(/[/.-]/)) {
|
|
154
|
+
throw new Error(
|
|
155
|
+
"AuroDatepickerUtilities | parseDate: Date string has no separators",
|
|
156
|
+
);
|
|
157
|
+
}
|
|
144
158
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
159
|
+
if (dateStr.length !== format.length) {
|
|
160
|
+
throw new Error(
|
|
161
|
+
"AuroDatepickerUtilities | parseDate: Date string and format length do not match",
|
|
162
|
+
);
|
|
163
|
+
}
|
|
149
164
|
|
|
150
|
-
|
|
151
|
-
|
|
165
|
+
valueParts = [dateStr];
|
|
166
|
+
formatParts = [format];
|
|
167
|
+
}
|
|
152
168
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
169
|
+
if (valueParts.length !== formatParts.length) {
|
|
170
|
+
throw new Error(
|
|
171
|
+
`AuroDatepickerUtilities | parseDate: Date string and format do not match : ${dateStr} vs ${format}`,
|
|
172
|
+
);
|
|
173
|
+
}
|
|
156
174
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
throw new Error('AuroDatepickerUtilities | parseDate: Date string and format length do not match');
|
|
160
|
-
}
|
|
175
|
+
const result = formatParts.reduce((acc, part, index) => {
|
|
176
|
+
const value = valueParts[index];
|
|
161
177
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
178
|
+
if (/m/iu.test(part) && part.length === value.length) {
|
|
179
|
+
acc.month = value;
|
|
180
|
+
} else if (/d/iu.test(part) && part.length === value.length) {
|
|
181
|
+
acc.day = value;
|
|
182
|
+
} else if (/y/iu.test(part) && part.length === value.length) {
|
|
183
|
+
acc.year = value;
|
|
184
|
+
}
|
|
165
185
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
} else if ((/d/iu).test(part)) {
|
|
169
|
-
acc.day = value;
|
|
170
|
-
} else if ((/y/iu).test(part)) {
|
|
171
|
-
acc.year = value;
|
|
172
|
-
}
|
|
186
|
+
return acc;
|
|
187
|
+
}, {});
|
|
173
188
|
|
|
174
|
-
|
|
175
|
-
|
|
189
|
+
if (!result.month && !result.day && !result.year) {
|
|
190
|
+
throw new Error(
|
|
191
|
+
"AuroDatepickerUtilities | parseDate: Unable to parse date string",
|
|
192
|
+
);
|
|
193
|
+
}
|
|
176
194
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
return result;
|
|
180
|
-
}
|
|
195
|
+
return result;
|
|
196
|
+
}
|
|
181
197
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
198
|
+
function isCalendarDate$1(year, month, day) {
|
|
199
|
+
let yearNumber = Number(year);
|
|
200
|
+
const monthNumber = Number(month);
|
|
201
|
+
const dayNumber = Number(day);
|
|
185
202
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
year: "numeric",
|
|
194
|
-
month: "2-digit",
|
|
195
|
-
day: "2-digit",
|
|
196
|
-
});
|
|
203
|
+
if (
|
|
204
|
+
!Number.isInteger(yearNumber) ||
|
|
205
|
+
!Number.isInteger(monthNumber) ||
|
|
206
|
+
!Number.isInteger(dayNumber)
|
|
207
|
+
) {
|
|
208
|
+
return false;
|
|
209
|
+
}
|
|
197
210
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
this.toNorthAmericanFormat = (dateStr, format) => {
|
|
211
|
+
// Handle 2-digit years by converting them to 4-digit years based on a cutoff. This allows for parsing of 2-digit year formats while still validating the resulting date.
|
|
212
|
+
if (yearNumber < 100 && yearNumber >= 50) {
|
|
213
|
+
yearNumber += 1900;
|
|
214
|
+
} else if (yearNumber < 50) {
|
|
215
|
+
yearNumber += 2000;
|
|
216
|
+
}
|
|
205
217
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
218
|
+
const stringified = `${String(yearNumber).padStart(4, "0")}-${String(monthNumber).padStart(2, "0")}-${String(dayNumber).padStart(2, "0")}`;
|
|
219
|
+
const date = new Date(stringified.replace(/[.-]/g, "/"));
|
|
220
|
+
|
|
221
|
+
return (
|
|
222
|
+
!Number.isNaN(date.getTime()) && toISOFormatString$1(date) === stringified
|
|
223
|
+
);
|
|
224
|
+
}
|
|
209
225
|
|
|
210
|
-
|
|
226
|
+
/**
|
|
227
|
+
* @description Parses a date string into its components and validates that the result is a real calendar date. Use `getDateParts` instead when raw splitting without validation is needed (e.g. for in-progress input).
|
|
228
|
+
*
|
|
229
|
+
* Partial formats are supported: components absent from `format` default to `year → "0"`,
|
|
230
|
+
* `month → "01"`, `day → "01"` for calendar validation only. The returned object contains
|
|
231
|
+
* only the fields actually present in the format string — missing fields are never injected.
|
|
232
|
+
* @param {string} dateStr - Date string to parse.
|
|
233
|
+
* @param {string} format - Date format to parse.
|
|
234
|
+
* @returns {{ month?: string, day?: string, year?: string }|undefined}
|
|
235
|
+
* @throws {Error} Throws when the parsed result does not represent a valid calendar date.
|
|
236
|
+
*/
|
|
237
|
+
function parseDate$1(dateStr, format = "mm/dd/yyyy") {
|
|
238
|
+
if (!dateStr || !format) {
|
|
239
|
+
return undefined;
|
|
240
|
+
}
|
|
241
|
+
const result = getDateParts$1(dateStr.trim(), format);
|
|
211
242
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
243
|
+
if (!result) {
|
|
244
|
+
return undefined;
|
|
245
|
+
}
|
|
215
246
|
|
|
216
|
-
|
|
247
|
+
const lowerFormat = format.toLowerCase();
|
|
248
|
+
const year = lowerFormat.includes("yy") ? result.year : "0";
|
|
249
|
+
const month = lowerFormat.includes("mm") ? result.month : "01";
|
|
250
|
+
const day = lowerFormat.includes("dd") ? result.day : "01";
|
|
217
251
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
}
|
|
252
|
+
if (isCalendarDate$1(year, month, day)) {
|
|
253
|
+
return result;
|
|
254
|
+
}
|
|
222
255
|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
256
|
+
throw new Error(
|
|
257
|
+
`AuroDatepickerUtilities | parseDate: Date string is not a valid date ${JSON.stringify(result)} with format ${format}`,
|
|
258
|
+
);
|
|
259
|
+
}
|
|
226
260
|
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
261
|
+
/**
|
|
262
|
+
* Convert a date object to string format.
|
|
263
|
+
* @param {Object} date - Date to convert to string.
|
|
264
|
+
* @param {String} locale - Optional locale to use for the date string. Defaults to user's locale.
|
|
265
|
+
* @returns {String} Returns the date as a string.
|
|
266
|
+
*/
|
|
267
|
+
function getDateAsString$1(date, locale = undefined) {
|
|
268
|
+
return date.toLocaleDateString(locale, {
|
|
269
|
+
year: "numeric",
|
|
270
|
+
month: "2-digit",
|
|
271
|
+
day: "2-digit",
|
|
272
|
+
});
|
|
273
|
+
}
|
|
230
274
|
|
|
231
|
-
|
|
232
|
-
|
|
275
|
+
/**
|
|
276
|
+
* Converts a date string to a North American date format.
|
|
277
|
+
* @param {String} dateStr - Date to validate.
|
|
278
|
+
* @param {String} format - Date format to validate against.
|
|
279
|
+
* @returns {String}
|
|
280
|
+
*/
|
|
281
|
+
function toNorthAmericanFormat$3(dateStr, format) {
|
|
282
|
+
if (format === "mm/dd/yyyy") {
|
|
283
|
+
return dateStr;
|
|
233
284
|
}
|
|
285
|
+
|
|
286
|
+
const parsedDate = parseDate$1(dateStr, format);
|
|
287
|
+
|
|
288
|
+
if (!parsedDate) {
|
|
289
|
+
throw new Error(
|
|
290
|
+
"AuroDatepickerUtilities | toNorthAmericanFormat: Unable to parse date string",
|
|
291
|
+
);
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
const { month, day, year } = parsedDate;
|
|
295
|
+
|
|
296
|
+
return [month, day, year].filter(Boolean).join("/");
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* Validates that a date string matches the provided format and represents a real calendar date.
|
|
301
|
+
*
|
|
302
|
+
* @param {string} dateStr - Date string to validate.
|
|
303
|
+
* @param {string} [format="yyyy-mm-dd"] - Format of the date string.
|
|
304
|
+
* @returns {boolean} True when the date string is valid for the provided format, otherwise false.
|
|
305
|
+
*/
|
|
306
|
+
function isValidDate$1(dateStr, format = "yyyy-mm-dd") {
|
|
307
|
+
try {
|
|
308
|
+
if (typeof dateStr !== "string" || !dateStr || format?.length < 8) {
|
|
309
|
+
return false;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
if (parseDate$1(dateStr, format)) {
|
|
313
|
+
return true;
|
|
314
|
+
}
|
|
315
|
+
} catch (error) {
|
|
316
|
+
return false;
|
|
317
|
+
}
|
|
318
|
+
return false;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* Converts a JavaScript Date instance to a simple ISO-like date string. This returns only the calendar date portion without any time or timezone information.
|
|
323
|
+
*
|
|
324
|
+
* @param {Date} date - Date instance to convert to an ISO-like string.
|
|
325
|
+
* @returns {string} A string in the format "yyyy-mm-dd" representing the provided date.
|
|
326
|
+
* @throws {Error} Throws an error when the input is not a valid Date instance.
|
|
327
|
+
*/
|
|
328
|
+
function toISOFormatString$1(date) {
|
|
329
|
+
if (!(date instanceof Date) || Number.isNaN(date.getTime())) {
|
|
330
|
+
throw new Error(
|
|
331
|
+
"AuroDatepickerUtilities | toISOFormatString: Input must be a valid Date instance",
|
|
332
|
+
);
|
|
333
|
+
}
|
|
334
|
+
return `${String(date.getFullYear()).padStart(4, "0")}-${String(date.getMonth() + 1).padStart(2, "0")}-${String(date.getDate()).padStart(2, "0")}`;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* Converts a date string into a JavaScript Date instance. This method supports ISO formatted strings and other formats that can be parsed by the formatter.
|
|
339
|
+
*
|
|
340
|
+
* @param {String} dateStr - Date string to convert into a Date object.
|
|
341
|
+
* @param {String} format - Date format used to parse the string when it is not in ISO format.
|
|
342
|
+
* @returns {Date|null} Returns a Date instance for valid input or null for non-string input.
|
|
343
|
+
* @throws {Error} Throws when parsing fails for non-ISO string input.
|
|
344
|
+
*/
|
|
345
|
+
function stringToDateInstance$1(dateStr, format = "yyyy-mm-dd") {
|
|
346
|
+
if (typeof dateStr !== "string") {
|
|
347
|
+
return null;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
const { month, day, year } = parseDate$1(dateStr, format);
|
|
351
|
+
return new Date(`${year}/${month}/${day}`);
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
const dateFormatter$1 = {
|
|
355
|
+
parseDate: parseDate$1,
|
|
356
|
+
getDateParts: getDateParts$1,
|
|
357
|
+
getDateAsString: getDateAsString$1,
|
|
358
|
+
toNorthAmericanFormat: toNorthAmericanFormat$3,
|
|
359
|
+
isValidDate: isValidDate$1,
|
|
360
|
+
toISOFormatString: toISOFormatString$1,
|
|
361
|
+
stringToDateInstance: stringToDateInstance$1,
|
|
234
362
|
};
|
|
235
|
-
const dateFormatter$1 = new DateFormatter$1();
|
|
236
363
|
|
|
237
364
|
// filepath: dateConstraints.mjs
|
|
238
365
|
const DATE_UTIL_CONSTRAINTS$1 = {
|
|
@@ -304,12 +431,11 @@ let AuroDateUtilitiesBase$1 = class AuroDateUtilitiesBase {
|
|
|
304
431
|
/* eslint-disable no-magic-numbers */
|
|
305
432
|
|
|
306
433
|
let AuroDateUtilities$1 = class AuroDateUtilities extends AuroDateUtilitiesBase$1 {
|
|
307
|
-
|
|
308
434
|
/**
|
|
309
435
|
* Returns the current century.
|
|
310
436
|
* @returns {String} The current century.
|
|
311
437
|
*/
|
|
312
|
-
getCentury
|
|
438
|
+
getCentury() {
|
|
313
439
|
return String(new Date().getFullYear()).slice(0, 2);
|
|
314
440
|
}
|
|
315
441
|
|
|
@@ -318,14 +444,12 @@ let AuroDateUtilities$1 = class AuroDateUtilities extends AuroDateUtilitiesBase$
|
|
|
318
444
|
* @param {String} year - The year to convert to four digits.
|
|
319
445
|
* @returns {String} The four digit year.
|
|
320
446
|
*/
|
|
321
|
-
getFourDigitYear
|
|
322
|
-
|
|
447
|
+
getFourDigitYear(year) {
|
|
323
448
|
const strYear = String(year).trim();
|
|
324
449
|
return strYear.length <= 2 ? this.getCentury() + strYear : strYear;
|
|
325
450
|
}
|
|
326
451
|
|
|
327
452
|
constructor() {
|
|
328
|
-
|
|
329
453
|
super();
|
|
330
454
|
|
|
331
455
|
/**
|
|
@@ -334,7 +458,8 @@ let AuroDateUtilities$1 = class AuroDateUtilities extends AuroDateUtilitiesBase$
|
|
|
334
458
|
* @param {Object} date2 - Second date to compare.
|
|
335
459
|
* @returns {Boolean} Returns true if the dates match.
|
|
336
460
|
*/
|
|
337
|
-
this.datesMatch = (date1, date2) =>
|
|
461
|
+
this.datesMatch = (date1, date2) =>
|
|
462
|
+
new Date(date1).getTime() === new Date(date2).getTime();
|
|
338
463
|
|
|
339
464
|
/**
|
|
340
465
|
* Returns true if value passed in is a valid date.
|
|
@@ -343,53 +468,41 @@ let AuroDateUtilities$1 = class AuroDateUtilities extends AuroDateUtilitiesBase$
|
|
|
343
468
|
* @returns {Boolean}
|
|
344
469
|
*/
|
|
345
470
|
this.validDateStr = (date, format) => {
|
|
346
|
-
|
|
347
471
|
// The length we expect the date string to be
|
|
348
|
-
const dateStrLength = format
|
|
472
|
+
const dateStrLength = format?.length || 0;
|
|
349
473
|
|
|
350
474
|
// Guard Clause: Date and format are defined
|
|
351
475
|
if (typeof date === "undefined" || typeof format === "undefined") {
|
|
352
|
-
throw new Error(
|
|
476
|
+
throw new Error(
|
|
477
|
+
"AuroDatepickerUtilities | validateDateStr: Date and format are required",
|
|
478
|
+
);
|
|
353
479
|
}
|
|
354
480
|
|
|
355
481
|
// Guard Clause: Date should be of type string
|
|
356
482
|
if (typeof date !== "string") {
|
|
357
|
-
throw new Error(
|
|
483
|
+
throw new Error(
|
|
484
|
+
"AuroDatepickerUtilities | validateDateStr: Date must be a string",
|
|
485
|
+
);
|
|
358
486
|
}
|
|
359
487
|
|
|
360
488
|
// Guard Clause: Format should be of type string
|
|
361
489
|
if (typeof format !== "string") {
|
|
362
|
-
throw new Error(
|
|
490
|
+
throw new Error(
|
|
491
|
+
"AuroDatepickerUtilities | validateDateStr: Format must be a string",
|
|
492
|
+
);
|
|
363
493
|
}
|
|
364
494
|
|
|
365
495
|
// Guard Clause: Length is what we expect it to be
|
|
366
496
|
if (date.length !== dateStrLength) {
|
|
367
497
|
return false;
|
|
368
498
|
}
|
|
369
|
-
// Get a formatted date string and parse it
|
|
370
|
-
const dateParts = dateFormatter$1.parseDate(date, format);
|
|
371
|
-
|
|
372
|
-
// Guard Clause: Date parse succeeded
|
|
373
|
-
if (!dateParts) {
|
|
374
|
-
return false;
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
// Create the expected date string based on the date parts
|
|
378
|
-
const expectedDateStr = `${dateParts.month}/${dateParts.day || "01"}/${this.getFourDigitYear(dateParts.year)}`;
|
|
379
|
-
|
|
380
|
-
// Generate a date object that we will extract a string date from to compare to the passed in date string
|
|
381
|
-
const dateObj = new Date(this.getFourDigitYear(dateParts.year), dateParts.month - 1, dateParts.day || 1);
|
|
382
499
|
|
|
383
|
-
// Get
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
if (expectedDateStr !== actualDateStr) {
|
|
500
|
+
// Get a formatted date string and parse and validate it
|
|
501
|
+
try {
|
|
502
|
+
return Boolean(dateFormatter$1.parseDate(date, format));
|
|
503
|
+
} catch (error) {
|
|
388
504
|
return false;
|
|
389
505
|
}
|
|
390
|
-
|
|
391
|
-
// If we passed all other checks, we can assume the date is valid
|
|
392
|
-
return true;
|
|
393
506
|
};
|
|
394
507
|
|
|
395
508
|
/**
|
|
@@ -399,10 +512,11 @@ let AuroDateUtilities$1 = class AuroDateUtilities extends AuroDateUtilitiesBase$
|
|
|
399
512
|
* @returns {boolean}
|
|
400
513
|
*/
|
|
401
514
|
this.dateAndFormatMatch = (value, format) => {
|
|
402
|
-
|
|
403
515
|
// Ensure we have both values we need to do the comparison
|
|
404
516
|
if (!value || !format) {
|
|
405
|
-
throw new Error(
|
|
517
|
+
throw new Error(
|
|
518
|
+
"AuroFormValidation | dateFormatMatch: value and format are required",
|
|
519
|
+
);
|
|
406
520
|
}
|
|
407
521
|
|
|
408
522
|
// If the lengths are different, they cannot match
|
|
@@ -411,11 +525,10 @@ let AuroDateUtilities$1 = class AuroDateUtilities extends AuroDateUtilitiesBase$
|
|
|
411
525
|
}
|
|
412
526
|
|
|
413
527
|
// Get the parts of the date
|
|
414
|
-
const dateParts = dateFormatter$1.
|
|
528
|
+
const dateParts = dateFormatter$1.getDateParts(value, format);
|
|
415
529
|
|
|
416
530
|
// Validator for day
|
|
417
531
|
const dayValueIsValid = (day) => {
|
|
418
|
-
|
|
419
532
|
// Guard clause: if there is no day in the dateParts, we can ignore this check.
|
|
420
533
|
if (!dateParts.day) {
|
|
421
534
|
return true;
|
|
@@ -431,7 +544,9 @@ let AuroDateUtilities$1 = class AuroDateUtilities extends AuroDateUtilitiesBase$
|
|
|
431
544
|
|
|
432
545
|
// Guard clause: ensure day is a valid integer
|
|
433
546
|
if (Number.isNaN(numDay)) {
|
|
434
|
-
throw new Error(
|
|
547
|
+
throw new Error(
|
|
548
|
+
"AuroDatepickerUtilities | dayValueIsValid: Unable to parse day value integer",
|
|
549
|
+
);
|
|
435
550
|
}
|
|
436
551
|
|
|
437
552
|
// Guard clause: ensure day is within the valid range
|
|
@@ -445,6 +560,10 @@ let AuroDateUtilities$1 = class AuroDateUtilities extends AuroDateUtilitiesBase$
|
|
|
445
560
|
|
|
446
561
|
// Validator for month
|
|
447
562
|
const monthValueIsValid = (month) => {
|
|
563
|
+
// Guard clause: if there is no month in the dateParts, we can ignore this check.
|
|
564
|
+
if (!dateParts.month) {
|
|
565
|
+
return true;
|
|
566
|
+
}
|
|
448
567
|
|
|
449
568
|
// Guard clause: ensure month exists.
|
|
450
569
|
if (!month) {
|
|
@@ -456,7 +575,9 @@ let AuroDateUtilities$1 = class AuroDateUtilities extends AuroDateUtilitiesBase$
|
|
|
456
575
|
|
|
457
576
|
// Guard clause: ensure month is a valid integer
|
|
458
577
|
if (Number.isNaN(numMonth)) {
|
|
459
|
-
throw new Error(
|
|
578
|
+
throw new Error(
|
|
579
|
+
"AuroDatepickerUtilities | monthValueIsValid: Unable to parse month value integer",
|
|
580
|
+
);
|
|
460
581
|
}
|
|
461
582
|
|
|
462
583
|
// Guard clause: ensure month is within the valid range
|
|
@@ -470,6 +591,10 @@ let AuroDateUtilities$1 = class AuroDateUtilities extends AuroDateUtilitiesBase$
|
|
|
470
591
|
|
|
471
592
|
// Validator for year
|
|
472
593
|
const yearIsValid = (_year) => {
|
|
594
|
+
// Guard clause: if there is no year in the dateParts, we can ignore this check.
|
|
595
|
+
if (!dateParts.year) {
|
|
596
|
+
return true;
|
|
597
|
+
}
|
|
473
598
|
|
|
474
599
|
// Guard clause: ensure year exists.
|
|
475
600
|
if (!_year) {
|
|
@@ -484,7 +609,9 @@ let AuroDateUtilities$1 = class AuroDateUtilities extends AuroDateUtilitiesBase$
|
|
|
484
609
|
|
|
485
610
|
// Guard clause: ensure year is a valid integer
|
|
486
611
|
if (Number.isNaN(numYear)) {
|
|
487
|
-
throw new Error(
|
|
612
|
+
throw new Error(
|
|
613
|
+
"AuroDatepickerUtilities | yearValueIsValid: Unable to parse year value integer",
|
|
614
|
+
);
|
|
488
615
|
}
|
|
489
616
|
|
|
490
617
|
// Guard clause: ensure year is within the valid range
|
|
@@ -500,7 +627,7 @@ let AuroDateUtilities$1 = class AuroDateUtilities extends AuroDateUtilitiesBase$
|
|
|
500
627
|
const checks = [
|
|
501
628
|
monthValueIsValid(dateParts.month),
|
|
502
629
|
dayValueIsValid(dateParts.day),
|
|
503
|
-
yearIsValid(dateParts.year)
|
|
630
|
+
yearIsValid(dateParts.year),
|
|
504
631
|
];
|
|
505
632
|
|
|
506
633
|
// If any of the checks failed, the date format does not match and the result is invalid
|
|
@@ -534,10 +661,7 @@ const {
|
|
|
534
661
|
} = dateUtilities$1;
|
|
535
662
|
|
|
536
663
|
const {
|
|
537
|
-
toNorthAmericanFormat: toNorthAmericanFormat$1
|
|
538
|
-
parseDate: parseDate$1,
|
|
539
|
-
getDateAsString: getDateAsString$1
|
|
540
|
-
} = dateFormatter$1;
|
|
664
|
+
toNorthAmericanFormat: toNorthAmericanFormat$2} = dateFormatter$1;
|
|
541
665
|
|
|
542
666
|
// Copyright (c) Alaska Air. All right reserved. Licensed under the Apache-2.0 license
|
|
543
667
|
// See LICENSE in the project root for license information.
|
|
@@ -774,13 +898,13 @@ let AuroFormValidation$1 = class AuroFormValidation {
|
|
|
774
898
|
}
|
|
775
899
|
|
|
776
900
|
// Perform the rest of the validation
|
|
777
|
-
const formattedValue = toNorthAmericanFormat$
|
|
901
|
+
const formattedValue = toNorthAmericanFormat$2(elem.value, elem.format);
|
|
778
902
|
const valueDate = new Date(formattedValue);
|
|
779
903
|
|
|
780
904
|
// // Validate max date
|
|
781
905
|
if (elem.max?.length === elem.lengthForType) {
|
|
782
906
|
|
|
783
|
-
const maxDate = new Date(toNorthAmericanFormat$
|
|
907
|
+
const maxDate = new Date(toNorthAmericanFormat$2(elem.max, elem.format));
|
|
784
908
|
|
|
785
909
|
if (valueDate > maxDate) {
|
|
786
910
|
elem.validity = 'rangeOverflow';
|
|
@@ -791,7 +915,7 @@ let AuroFormValidation$1 = class AuroFormValidation {
|
|
|
791
915
|
|
|
792
916
|
// Validate min date
|
|
793
917
|
if (elem.min?.length === elem.lengthForType) {
|
|
794
|
-
const minDate = new Date(toNorthAmericanFormat$
|
|
918
|
+
const minDate = new Date(toNorthAmericanFormat$2(elem.min, elem.format));
|
|
795
919
|
|
|
796
920
|
if (valueDate < minDate) {
|
|
797
921
|
elem.validity = 'rangeUnderflow';
|
|
@@ -5211,7 +5335,7 @@ let AuroHelpText$2 = class AuroHelpText extends LitElement {
|
|
|
5211
5335
|
}
|
|
5212
5336
|
};
|
|
5213
5337
|
|
|
5214
|
-
var formkitVersion$2 = '
|
|
5338
|
+
var formkitVersion$2 = '202606030033';
|
|
5215
5339
|
|
|
5216
5340
|
let AuroElement$2 = class AuroElement extends LitElement {
|
|
5217
5341
|
static get properties() {
|
|
@@ -6204,13 +6328,20 @@ class AuroDropdown extends AuroElement$2 {
|
|
|
6204
6328
|
|
|
6205
6329
|
// Walk up the ancestor chain, inerting siblings at each level
|
|
6206
6330
|
// to ensure the entire page outside the host subtree is inert.
|
|
6331
|
+
// Uses a reference counter (data-auro-inert-count) so multiple
|
|
6332
|
+
// simultaneous modal dropdowns share inert state safely.
|
|
6207
6333
|
let current = host;
|
|
6208
6334
|
while (current.parentElement) {
|
|
6209
6335
|
const parent = current.parentElement;
|
|
6210
6336
|
for (const sibling of parent.children) {
|
|
6211
6337
|
if (sibling !== current) {
|
|
6212
|
-
|
|
6338
|
+
const count = parseInt(sibling.dataset.auroInertCount || '0', 10);
|
|
6339
|
+
if (count === 0) {
|
|
6340
|
+
sibling.dataset.auroInertWas = sibling.inert ? 'true' : 'false';
|
|
6341
|
+
}
|
|
6342
|
+
sibling.dataset.auroInertCount = String(count + 1);
|
|
6213
6343
|
sibling.inert = true;
|
|
6344
|
+
this._inertSiblings.push(sibling);
|
|
6214
6345
|
}
|
|
6215
6346
|
}
|
|
6216
6347
|
current = parent;
|
|
@@ -6219,14 +6350,23 @@ class AuroDropdown extends AuroElement$2 {
|
|
|
6219
6350
|
|
|
6220
6351
|
/**
|
|
6221
6352
|
* Restores `inert` state on siblings that were tracked by `_setPageInert`.
|
|
6222
|
-
*
|
|
6223
|
-
*
|
|
6353
|
+
* Uses reference counting so inert is only cleared when the last modal
|
|
6354
|
+
* dropdown releases a given element. Preserves the original inert state
|
|
6355
|
+
* so externally-inerted elements are not inadvertently re-enabled.
|
|
6224
6356
|
* @private
|
|
6225
6357
|
*/
|
|
6226
6358
|
_clearPageInert() {
|
|
6227
6359
|
if (this._inertSiblings) {
|
|
6228
|
-
for (const
|
|
6229
|
-
|
|
6360
|
+
for (const sibling of this._inertSiblings) {
|
|
6361
|
+
const count = parseInt(sibling.dataset.auroInertCount || '1', 10) - 1;
|
|
6362
|
+
if (count <= 0) {
|
|
6363
|
+
const wasInert = sibling.dataset.auroInertWas === 'true';
|
|
6364
|
+
delete sibling.dataset.auroInertCount;
|
|
6365
|
+
delete sibling.dataset.auroInertWas;
|
|
6366
|
+
sibling.inert = wasInert;
|
|
6367
|
+
} else {
|
|
6368
|
+
sibling.dataset.auroInertCount = String(count);
|
|
6369
|
+
}
|
|
6230
6370
|
}
|
|
6231
6371
|
this._inertSiblings = undefined;
|
|
6232
6372
|
}
|
|
@@ -10544,109 +10684,236 @@ class AuroInputUtilities {
|
|
|
10544
10684
|
}
|
|
10545
10685
|
}
|
|
10546
10686
|
|
|
10547
|
-
|
|
10687
|
+
/**
|
|
10688
|
+
* @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.
|
|
10689
|
+
* @param {string} dateStr - Date string to parse.
|
|
10690
|
+
* @param {string} format - Date format to parse.
|
|
10691
|
+
* @returns {{ month?: string, day?: string, year?: string }|undefined}
|
|
10692
|
+
*/
|
|
10693
|
+
function getDateParts(dateStr, format) {
|
|
10694
|
+
if (!dateStr) {
|
|
10695
|
+
return undefined;
|
|
10696
|
+
}
|
|
10548
10697
|
|
|
10549
|
-
|
|
10698
|
+
const formatSeparatorMatch = format.match(/[/.-]/);
|
|
10699
|
+
let valueParts;
|
|
10700
|
+
let formatParts;
|
|
10550
10701
|
|
|
10551
|
-
|
|
10552
|
-
|
|
10553
|
-
|
|
10554
|
-
|
|
10555
|
-
|
|
10556
|
-
|
|
10557
|
-
|
|
10702
|
+
if (formatSeparatorMatch) {
|
|
10703
|
+
const separator = formatSeparatorMatch[0];
|
|
10704
|
+
valueParts = dateStr.split(separator);
|
|
10705
|
+
formatParts = format.split(separator);
|
|
10706
|
+
} else {
|
|
10707
|
+
if (dateStr.match(/[/.-]/)) {
|
|
10708
|
+
throw new Error(
|
|
10709
|
+
"AuroDatepickerUtilities | parseDate: Date string has no separators",
|
|
10710
|
+
);
|
|
10711
|
+
}
|
|
10558
10712
|
|
|
10559
|
-
|
|
10560
|
-
|
|
10561
|
-
|
|
10562
|
-
|
|
10713
|
+
if (dateStr.length !== format.length) {
|
|
10714
|
+
throw new Error(
|
|
10715
|
+
"AuroDatepickerUtilities | parseDate: Date string and format length do not match",
|
|
10716
|
+
);
|
|
10717
|
+
}
|
|
10563
10718
|
|
|
10564
|
-
|
|
10565
|
-
|
|
10719
|
+
valueParts = [dateStr];
|
|
10720
|
+
formatParts = [format];
|
|
10721
|
+
}
|
|
10566
10722
|
|
|
10567
|
-
|
|
10568
|
-
|
|
10569
|
-
|
|
10723
|
+
if (valueParts.length !== formatParts.length) {
|
|
10724
|
+
throw new Error(
|
|
10725
|
+
`AuroDatepickerUtilities | parseDate: Date string and format do not match : ${dateStr} vs ${format}`,
|
|
10726
|
+
);
|
|
10727
|
+
}
|
|
10570
10728
|
|
|
10571
|
-
|
|
10572
|
-
|
|
10573
|
-
throw new Error('AuroDatepickerUtilities | parseDate: Date string and format length do not match');
|
|
10574
|
-
}
|
|
10729
|
+
const result = formatParts.reduce((acc, part, index) => {
|
|
10730
|
+
const value = valueParts[index];
|
|
10575
10731
|
|
|
10576
|
-
|
|
10577
|
-
|
|
10578
|
-
|
|
10732
|
+
if (/m/iu.test(part) && part.length === value.length) {
|
|
10733
|
+
acc.month = value;
|
|
10734
|
+
} else if (/d/iu.test(part) && part.length === value.length) {
|
|
10735
|
+
acc.day = value;
|
|
10736
|
+
} else if (/y/iu.test(part) && part.length === value.length) {
|
|
10737
|
+
acc.year = value;
|
|
10738
|
+
}
|
|
10579
10739
|
|
|
10580
|
-
|
|
10581
|
-
|
|
10582
|
-
} else if ((/d/iu).test(part)) {
|
|
10583
|
-
acc.day = value;
|
|
10584
|
-
} else if ((/y/iu).test(part)) {
|
|
10585
|
-
acc.year = value;
|
|
10586
|
-
}
|
|
10740
|
+
return acc;
|
|
10741
|
+
}, {});
|
|
10587
10742
|
|
|
10588
|
-
|
|
10589
|
-
|
|
10743
|
+
if (!result.month && !result.day && !result.year) {
|
|
10744
|
+
throw new Error(
|
|
10745
|
+
"AuroDatepickerUtilities | parseDate: Unable to parse date string",
|
|
10746
|
+
);
|
|
10747
|
+
}
|
|
10590
10748
|
|
|
10591
|
-
|
|
10592
|
-
|
|
10593
|
-
return result;
|
|
10594
|
-
}
|
|
10749
|
+
return result;
|
|
10750
|
+
}
|
|
10595
10751
|
|
|
10596
|
-
|
|
10597
|
-
|
|
10598
|
-
|
|
10752
|
+
function isCalendarDate(year, month, day) {
|
|
10753
|
+
let yearNumber = Number(year);
|
|
10754
|
+
const monthNumber = Number(month);
|
|
10755
|
+
const dayNumber = Number(day);
|
|
10599
10756
|
|
|
10600
|
-
|
|
10601
|
-
|
|
10602
|
-
|
|
10603
|
-
|
|
10604
|
-
|
|
10605
|
-
|
|
10606
|
-
|
|
10607
|
-
year: "numeric",
|
|
10608
|
-
month: "2-digit",
|
|
10609
|
-
day: "2-digit",
|
|
10610
|
-
});
|
|
10757
|
+
if (
|
|
10758
|
+
!Number.isInteger(yearNumber) ||
|
|
10759
|
+
!Number.isInteger(monthNumber) ||
|
|
10760
|
+
!Number.isInteger(dayNumber)
|
|
10761
|
+
) {
|
|
10762
|
+
return false;
|
|
10763
|
+
}
|
|
10611
10764
|
|
|
10612
|
-
|
|
10613
|
-
|
|
10614
|
-
|
|
10615
|
-
|
|
10616
|
-
|
|
10617
|
-
|
|
10618
|
-
this.toNorthAmericanFormat = (dateStr, format) => {
|
|
10765
|
+
// 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.
|
|
10766
|
+
if (yearNumber < 100 && yearNumber >= 50) {
|
|
10767
|
+
yearNumber += 1900;
|
|
10768
|
+
} else if (yearNumber < 50) {
|
|
10769
|
+
yearNumber += 2000;
|
|
10770
|
+
}
|
|
10619
10771
|
|
|
10620
|
-
|
|
10621
|
-
|
|
10622
|
-
}
|
|
10772
|
+
const stringified = `${String(yearNumber).padStart(4, "0")}-${String(monthNumber).padStart(2, "0")}-${String(dayNumber).padStart(2, "0")}`;
|
|
10773
|
+
const date = new Date(stringified.replace(/[.-]/g, "/"));
|
|
10623
10774
|
|
|
10624
|
-
|
|
10775
|
+
return (
|
|
10776
|
+
!Number.isNaN(date.getTime()) && toISOFormatString(date) === stringified
|
|
10777
|
+
);
|
|
10778
|
+
}
|
|
10625
10779
|
|
|
10626
|
-
|
|
10627
|
-
|
|
10628
|
-
|
|
10780
|
+
/**
|
|
10781
|
+
* @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).
|
|
10782
|
+
*
|
|
10783
|
+
* Partial formats are supported: components absent from `format` default to `year → "0"`,
|
|
10784
|
+
* `month → "01"`, `day → "01"` for calendar validation only. The returned object contains
|
|
10785
|
+
* only the fields actually present in the format string — missing fields are never injected.
|
|
10786
|
+
* @param {string} dateStr - Date string to parse.
|
|
10787
|
+
* @param {string} format - Date format to parse.
|
|
10788
|
+
* @returns {{ month?: string, day?: string, year?: string }|undefined}
|
|
10789
|
+
* @throws {Error} Throws when the parsed result does not represent a valid calendar date.
|
|
10790
|
+
*/
|
|
10791
|
+
function parseDate(dateStr, format = "mm/dd/yyyy") {
|
|
10792
|
+
if (!dateStr || !format) {
|
|
10793
|
+
return undefined;
|
|
10794
|
+
}
|
|
10795
|
+
const result = getDateParts(dateStr.trim(), format);
|
|
10629
10796
|
|
|
10630
|
-
|
|
10797
|
+
if (!result) {
|
|
10798
|
+
return undefined;
|
|
10799
|
+
}
|
|
10631
10800
|
|
|
10632
|
-
|
|
10633
|
-
|
|
10634
|
-
|
|
10635
|
-
|
|
10801
|
+
const lowerFormat = format.toLowerCase();
|
|
10802
|
+
const year = lowerFormat.includes("yy") ? result.year : "0";
|
|
10803
|
+
const month = lowerFormat.includes("mm") ? result.month : "01";
|
|
10804
|
+
const day = lowerFormat.includes("dd") ? result.day : "01";
|
|
10636
10805
|
|
|
10637
|
-
|
|
10638
|
-
|
|
10639
|
-
|
|
10806
|
+
if (isCalendarDate(year, month, day)) {
|
|
10807
|
+
return result;
|
|
10808
|
+
}
|
|
10640
10809
|
|
|
10641
|
-
|
|
10642
|
-
|
|
10643
|
-
|
|
10810
|
+
throw new Error(
|
|
10811
|
+
`AuroDatepickerUtilities | parseDate: Date string is not a valid date ${JSON.stringify(result)} with format ${format}`,
|
|
10812
|
+
);
|
|
10813
|
+
}
|
|
10644
10814
|
|
|
10645
|
-
|
|
10646
|
-
|
|
10815
|
+
/**
|
|
10816
|
+
* Convert a date object to string format.
|
|
10817
|
+
* @param {Object} date - Date to convert to string.
|
|
10818
|
+
* @param {String} locale - Optional locale to use for the date string. Defaults to user's locale.
|
|
10819
|
+
* @returns {String} Returns the date as a string.
|
|
10820
|
+
*/
|
|
10821
|
+
function getDateAsString(date, locale = undefined) {
|
|
10822
|
+
return date.toLocaleDateString(locale, {
|
|
10823
|
+
year: "numeric",
|
|
10824
|
+
month: "2-digit",
|
|
10825
|
+
day: "2-digit",
|
|
10826
|
+
});
|
|
10827
|
+
}
|
|
10828
|
+
|
|
10829
|
+
/**
|
|
10830
|
+
* Converts a date string to a North American date format.
|
|
10831
|
+
* @param {String} dateStr - Date to validate.
|
|
10832
|
+
* @param {String} format - Date format to validate against.
|
|
10833
|
+
* @returns {String}
|
|
10834
|
+
*/
|
|
10835
|
+
function toNorthAmericanFormat$1(dateStr, format) {
|
|
10836
|
+
if (format === "mm/dd/yyyy") {
|
|
10837
|
+
return dateStr;
|
|
10647
10838
|
}
|
|
10839
|
+
|
|
10840
|
+
const parsedDate = parseDate(dateStr, format);
|
|
10841
|
+
|
|
10842
|
+
if (!parsedDate) {
|
|
10843
|
+
throw new Error(
|
|
10844
|
+
"AuroDatepickerUtilities | toNorthAmericanFormat: Unable to parse date string",
|
|
10845
|
+
);
|
|
10846
|
+
}
|
|
10847
|
+
|
|
10848
|
+
const { month, day, year } = parsedDate;
|
|
10849
|
+
|
|
10850
|
+
return [month, day, year].filter(Boolean).join("/");
|
|
10851
|
+
}
|
|
10852
|
+
|
|
10853
|
+
/**
|
|
10854
|
+
* Validates that a date string matches the provided format and represents a real calendar date.
|
|
10855
|
+
*
|
|
10856
|
+
* @param {string} dateStr - Date string to validate.
|
|
10857
|
+
* @param {string} [format="yyyy-mm-dd"] - Format of the date string.
|
|
10858
|
+
* @returns {boolean} True when the date string is valid for the provided format, otherwise false.
|
|
10859
|
+
*/
|
|
10860
|
+
function isValidDate(dateStr, format = "yyyy-mm-dd") {
|
|
10861
|
+
try {
|
|
10862
|
+
if (typeof dateStr !== "string" || !dateStr || format?.length < 8) {
|
|
10863
|
+
return false;
|
|
10864
|
+
}
|
|
10865
|
+
|
|
10866
|
+
if (parseDate(dateStr, format)) {
|
|
10867
|
+
return true;
|
|
10868
|
+
}
|
|
10869
|
+
} catch (error) {
|
|
10870
|
+
return false;
|
|
10871
|
+
}
|
|
10872
|
+
return false;
|
|
10873
|
+
}
|
|
10874
|
+
|
|
10875
|
+
/**
|
|
10876
|
+
* 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.
|
|
10877
|
+
*
|
|
10878
|
+
* @param {Date} date - Date instance to convert to an ISO-like string.
|
|
10879
|
+
* @returns {string} A string in the format "yyyy-mm-dd" representing the provided date.
|
|
10880
|
+
* @throws {Error} Throws an error when the input is not a valid Date instance.
|
|
10881
|
+
*/
|
|
10882
|
+
function toISOFormatString(date) {
|
|
10883
|
+
if (!(date instanceof Date) || Number.isNaN(date.getTime())) {
|
|
10884
|
+
throw new Error(
|
|
10885
|
+
"AuroDatepickerUtilities | toISOFormatString: Input must be a valid Date instance",
|
|
10886
|
+
);
|
|
10887
|
+
}
|
|
10888
|
+
return `${String(date.getFullYear()).padStart(4, "0")}-${String(date.getMonth() + 1).padStart(2, "0")}-${String(date.getDate()).padStart(2, "0")}`;
|
|
10889
|
+
}
|
|
10890
|
+
|
|
10891
|
+
/**
|
|
10892
|
+
* 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.
|
|
10893
|
+
*
|
|
10894
|
+
* @param {String} dateStr - Date string to convert into a Date object.
|
|
10895
|
+
* @param {String} format - Date format used to parse the string when it is not in ISO format.
|
|
10896
|
+
* @returns {Date|null} Returns a Date instance for valid input or null for non-string input.
|
|
10897
|
+
* @throws {Error} Throws when parsing fails for non-ISO string input.
|
|
10898
|
+
*/
|
|
10899
|
+
function stringToDateInstance(dateStr, format = "yyyy-mm-dd") {
|
|
10900
|
+
if (typeof dateStr !== "string") {
|
|
10901
|
+
return null;
|
|
10902
|
+
}
|
|
10903
|
+
|
|
10904
|
+
const { month, day, year } = parseDate(dateStr, format);
|
|
10905
|
+
return new Date(`${year}/${month}/${day}`);
|
|
10648
10906
|
}
|
|
10649
|
-
|
|
10907
|
+
|
|
10908
|
+
const dateFormatter = {
|
|
10909
|
+
parseDate,
|
|
10910
|
+
getDateParts,
|
|
10911
|
+
getDateAsString,
|
|
10912
|
+
toNorthAmericanFormat: toNorthAmericanFormat$1,
|
|
10913
|
+
isValidDate,
|
|
10914
|
+
toISOFormatString,
|
|
10915
|
+
stringToDateInstance,
|
|
10916
|
+
};
|
|
10650
10917
|
|
|
10651
10918
|
// filepath: dateConstraints.mjs
|
|
10652
10919
|
const DATE_UTIL_CONSTRAINTS = {
|
|
@@ -10718,12 +10985,11 @@ class AuroDateUtilitiesBase {
|
|
|
10718
10985
|
/* eslint-disable no-magic-numbers */
|
|
10719
10986
|
|
|
10720
10987
|
class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
10721
|
-
|
|
10722
10988
|
/**
|
|
10723
10989
|
* Returns the current century.
|
|
10724
10990
|
* @returns {String} The current century.
|
|
10725
10991
|
*/
|
|
10726
|
-
getCentury
|
|
10992
|
+
getCentury() {
|
|
10727
10993
|
return String(new Date().getFullYear()).slice(0, 2);
|
|
10728
10994
|
}
|
|
10729
10995
|
|
|
@@ -10732,14 +10998,12 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
10732
10998
|
* @param {String} year - The year to convert to four digits.
|
|
10733
10999
|
* @returns {String} The four digit year.
|
|
10734
11000
|
*/
|
|
10735
|
-
getFourDigitYear
|
|
10736
|
-
|
|
11001
|
+
getFourDigitYear(year) {
|
|
10737
11002
|
const strYear = String(year).trim();
|
|
10738
11003
|
return strYear.length <= 2 ? this.getCentury() + strYear : strYear;
|
|
10739
11004
|
}
|
|
10740
11005
|
|
|
10741
11006
|
constructor() {
|
|
10742
|
-
|
|
10743
11007
|
super();
|
|
10744
11008
|
|
|
10745
11009
|
/**
|
|
@@ -10748,7 +11012,8 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
10748
11012
|
* @param {Object} date2 - Second date to compare.
|
|
10749
11013
|
* @returns {Boolean} Returns true if the dates match.
|
|
10750
11014
|
*/
|
|
10751
|
-
this.datesMatch = (date1, date2) =>
|
|
11015
|
+
this.datesMatch = (date1, date2) =>
|
|
11016
|
+
new Date(date1).getTime() === new Date(date2).getTime();
|
|
10752
11017
|
|
|
10753
11018
|
/**
|
|
10754
11019
|
* Returns true if value passed in is a valid date.
|
|
@@ -10757,53 +11022,41 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
10757
11022
|
* @returns {Boolean}
|
|
10758
11023
|
*/
|
|
10759
11024
|
this.validDateStr = (date, format) => {
|
|
10760
|
-
|
|
10761
11025
|
// The length we expect the date string to be
|
|
10762
|
-
const dateStrLength = format
|
|
11026
|
+
const dateStrLength = format?.length || 0;
|
|
10763
11027
|
|
|
10764
11028
|
// Guard Clause: Date and format are defined
|
|
10765
11029
|
if (typeof date === "undefined" || typeof format === "undefined") {
|
|
10766
|
-
throw new Error(
|
|
11030
|
+
throw new Error(
|
|
11031
|
+
"AuroDatepickerUtilities | validateDateStr: Date and format are required",
|
|
11032
|
+
);
|
|
10767
11033
|
}
|
|
10768
11034
|
|
|
10769
11035
|
// Guard Clause: Date should be of type string
|
|
10770
11036
|
if (typeof date !== "string") {
|
|
10771
|
-
throw new Error(
|
|
11037
|
+
throw new Error(
|
|
11038
|
+
"AuroDatepickerUtilities | validateDateStr: Date must be a string",
|
|
11039
|
+
);
|
|
10772
11040
|
}
|
|
10773
11041
|
|
|
10774
11042
|
// Guard Clause: Format should be of type string
|
|
10775
11043
|
if (typeof format !== "string") {
|
|
10776
|
-
throw new Error(
|
|
11044
|
+
throw new Error(
|
|
11045
|
+
"AuroDatepickerUtilities | validateDateStr: Format must be a string",
|
|
11046
|
+
);
|
|
10777
11047
|
}
|
|
10778
11048
|
|
|
10779
11049
|
// Guard Clause: Length is what we expect it to be
|
|
10780
11050
|
if (date.length !== dateStrLength) {
|
|
10781
11051
|
return false;
|
|
10782
11052
|
}
|
|
10783
|
-
// Get a formatted date string and parse it
|
|
10784
|
-
const dateParts = dateFormatter.parseDate(date, format);
|
|
10785
|
-
|
|
10786
|
-
// Guard Clause: Date parse succeeded
|
|
10787
|
-
if (!dateParts) {
|
|
10788
|
-
return false;
|
|
10789
|
-
}
|
|
10790
|
-
|
|
10791
|
-
// Create the expected date string based on the date parts
|
|
10792
|
-
const expectedDateStr = `${dateParts.month}/${dateParts.day || "01"}/${this.getFourDigitYear(dateParts.year)}`;
|
|
10793
|
-
|
|
10794
|
-
// Generate a date object that we will extract a string date from to compare to the passed in date string
|
|
10795
|
-
const dateObj = new Date(this.getFourDigitYear(dateParts.year), dateParts.month - 1, dateParts.day || 1);
|
|
10796
|
-
|
|
10797
|
-
// Get the date string of the date object we created from the string date
|
|
10798
|
-
const actualDateStr = dateFormatter.getDateAsString(dateObj, "en-US");
|
|
10799
11053
|
|
|
10800
|
-
//
|
|
10801
|
-
|
|
11054
|
+
// Get a formatted date string and parse and validate it
|
|
11055
|
+
try {
|
|
11056
|
+
return Boolean(dateFormatter.parseDate(date, format));
|
|
11057
|
+
} catch (error) {
|
|
10802
11058
|
return false;
|
|
10803
11059
|
}
|
|
10804
|
-
|
|
10805
|
-
// If we passed all other checks, we can assume the date is valid
|
|
10806
|
-
return true;
|
|
10807
11060
|
};
|
|
10808
11061
|
|
|
10809
11062
|
/**
|
|
@@ -10813,10 +11066,11 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
10813
11066
|
* @returns {boolean}
|
|
10814
11067
|
*/
|
|
10815
11068
|
this.dateAndFormatMatch = (value, format) => {
|
|
10816
|
-
|
|
10817
11069
|
// Ensure we have both values we need to do the comparison
|
|
10818
11070
|
if (!value || !format) {
|
|
10819
|
-
throw new Error(
|
|
11071
|
+
throw new Error(
|
|
11072
|
+
"AuroFormValidation | dateFormatMatch: value and format are required",
|
|
11073
|
+
);
|
|
10820
11074
|
}
|
|
10821
11075
|
|
|
10822
11076
|
// If the lengths are different, they cannot match
|
|
@@ -10825,11 +11079,10 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
10825
11079
|
}
|
|
10826
11080
|
|
|
10827
11081
|
// Get the parts of the date
|
|
10828
|
-
const dateParts = dateFormatter.
|
|
11082
|
+
const dateParts = dateFormatter.getDateParts(value, format);
|
|
10829
11083
|
|
|
10830
11084
|
// Validator for day
|
|
10831
11085
|
const dayValueIsValid = (day) => {
|
|
10832
|
-
|
|
10833
11086
|
// Guard clause: if there is no day in the dateParts, we can ignore this check.
|
|
10834
11087
|
if (!dateParts.day) {
|
|
10835
11088
|
return true;
|
|
@@ -10845,7 +11098,9 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
10845
11098
|
|
|
10846
11099
|
// Guard clause: ensure day is a valid integer
|
|
10847
11100
|
if (Number.isNaN(numDay)) {
|
|
10848
|
-
throw new Error(
|
|
11101
|
+
throw new Error(
|
|
11102
|
+
"AuroDatepickerUtilities | dayValueIsValid: Unable to parse day value integer",
|
|
11103
|
+
);
|
|
10849
11104
|
}
|
|
10850
11105
|
|
|
10851
11106
|
// Guard clause: ensure day is within the valid range
|
|
@@ -10859,6 +11114,10 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
10859
11114
|
|
|
10860
11115
|
// Validator for month
|
|
10861
11116
|
const monthValueIsValid = (month) => {
|
|
11117
|
+
// Guard clause: if there is no month in the dateParts, we can ignore this check.
|
|
11118
|
+
if (!dateParts.month) {
|
|
11119
|
+
return true;
|
|
11120
|
+
}
|
|
10862
11121
|
|
|
10863
11122
|
// Guard clause: ensure month exists.
|
|
10864
11123
|
if (!month) {
|
|
@@ -10870,7 +11129,9 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
10870
11129
|
|
|
10871
11130
|
// Guard clause: ensure month is a valid integer
|
|
10872
11131
|
if (Number.isNaN(numMonth)) {
|
|
10873
|
-
throw new Error(
|
|
11132
|
+
throw new Error(
|
|
11133
|
+
"AuroDatepickerUtilities | monthValueIsValid: Unable to parse month value integer",
|
|
11134
|
+
);
|
|
10874
11135
|
}
|
|
10875
11136
|
|
|
10876
11137
|
// Guard clause: ensure month is within the valid range
|
|
@@ -10884,6 +11145,10 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
10884
11145
|
|
|
10885
11146
|
// Validator for year
|
|
10886
11147
|
const yearIsValid = (_year) => {
|
|
11148
|
+
// Guard clause: if there is no year in the dateParts, we can ignore this check.
|
|
11149
|
+
if (!dateParts.year) {
|
|
11150
|
+
return true;
|
|
11151
|
+
}
|
|
10887
11152
|
|
|
10888
11153
|
// Guard clause: ensure year exists.
|
|
10889
11154
|
if (!_year) {
|
|
@@ -10898,7 +11163,9 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
10898
11163
|
|
|
10899
11164
|
// Guard clause: ensure year is a valid integer
|
|
10900
11165
|
if (Number.isNaN(numYear)) {
|
|
10901
|
-
throw new Error(
|
|
11166
|
+
throw new Error(
|
|
11167
|
+
"AuroDatepickerUtilities | yearValueIsValid: Unable to parse year value integer",
|
|
11168
|
+
);
|
|
10902
11169
|
}
|
|
10903
11170
|
|
|
10904
11171
|
// Guard clause: ensure year is within the valid range
|
|
@@ -10914,7 +11181,7 @@ class AuroDateUtilities extends AuroDateUtilitiesBase {
|
|
|
10914
11181
|
const checks = [
|
|
10915
11182
|
monthValueIsValid(dateParts.month),
|
|
10916
11183
|
dayValueIsValid(dateParts.day),
|
|
10917
|
-
yearIsValid(dateParts.year)
|
|
11184
|
+
yearIsValid(dateParts.year),
|
|
10918
11185
|
];
|
|
10919
11186
|
|
|
10920
11187
|
// If any of the checks failed, the date format does not match and the result is invalid
|
|
@@ -10948,10 +11215,7 @@ const {
|
|
|
10948
11215
|
} = dateUtilities;
|
|
10949
11216
|
|
|
10950
11217
|
const {
|
|
10951
|
-
toNorthAmericanFormat
|
|
10952
|
-
parseDate,
|
|
10953
|
-
getDateAsString
|
|
10954
|
-
} = dateFormatter;
|
|
11218
|
+
toNorthAmericanFormat} = dateFormatter;
|
|
10955
11219
|
|
|
10956
11220
|
// Copyright (c) Alaska Air. All right reserved. Licensed under the Apache-2.0 license
|
|
10957
11221
|
// See LICENSE in the project root for license information.
|
|
@@ -13166,7 +13430,7 @@ let AuroHelpText$1 = class AuroHelpText extends LitElement {
|
|
|
13166
13430
|
}
|
|
13167
13431
|
};
|
|
13168
13432
|
|
|
13169
|
-
var formkitVersion$1 = '
|
|
13433
|
+
var formkitVersion$1 = '202606030033';
|
|
13170
13434
|
|
|
13171
13435
|
// Copyright (c) 2025 Alaska Airlines. All right reserved. Licensed under the Apache-2.0 license
|
|
13172
13436
|
// See LICENSE in the project root for license information.
|
|
@@ -14239,7 +14503,7 @@ class AuroBibtemplate extends LitElement {
|
|
|
14239
14503
|
}
|
|
14240
14504
|
}
|
|
14241
14505
|
|
|
14242
|
-
var formkitVersion = '
|
|
14506
|
+
var formkitVersion = '202606030033';
|
|
14243
14507
|
|
|
14244
14508
|
var styleCss$1 = css`.util_displayInline{display:inline}.util_displayInlineBlock{display:inline-block}.util_displayBlock{display:block}.util_displayFlex{display:flex}.util_displayHidden{display:none}.util_displayHiddenVisually{position:absolute;overflow:hidden;clip:rect(1px, 1px, 1px, 1px);width:1px;height:1px;padding:0;border:0}:host{display:block;text-align:left}:host [auro-dropdown]{--ds-auro-dropdown-trigger-background-color: transparent}:host #inputInBib::part(wrapper){box-shadow:none}:host #inputInBib::part(accent-left){display:none}:host([layout*=classic]) [auro-input]{width:100%}:host([layout*=classic]) [auro-input]::part(helpText){display:none}:host([layout*=classic]) #slotHolder{display:none}`;
|
|
14245
14509
|
|