@ionic/core 8.8.12 → 8.8.13-nightly.20260626

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.
@@ -1114,548 +1114,23 @@ const formatValue = (value) => {
1114
1114
  return Array.isArray(value) ? value.join(',') : value;
1115
1115
  };
1116
1116
 
1117
- /**
1118
- * Returns the current date as
1119
- * an ISO string in the user's
1120
- * time zone.
1121
- */
1122
- const getToday = () => {
1123
- /**
1124
- * ion-datetime intentionally does not
1125
- * parse time zones/do automatic time zone
1126
- * conversion when accepting user input.
1127
- * However when we get today's date string,
1128
- * we want it formatted relative to the user's
1129
- * time zone.
1130
- *
1131
- * When calling toISOString(), the browser
1132
- * will convert the date to UTC time by either adding
1133
- * or subtracting the time zone offset.
1134
- * To work around this, we need to either add
1135
- * or subtract the time zone offset to the Date
1136
- * object prior to calling toISOString().
1137
- * This allows us to get an ISO string
1138
- * that is in the user's time zone.
1139
- */
1140
- return removeDateTzOffset(new Date()).toISOString();
1141
- };
1142
- const minutes = [
1143
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
1144
- 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59,
1145
- ];
1146
- // h11 hour system uses 0-11. Midnight starts at 0:00am.
1147
- const hour11 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11];
1148
- // h12 hour system uses 0-12. Midnight starts at 12:00am.
1149
- const hour12 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11];
1150
- // h23 hour system uses 0-23. Midnight starts at 0:00.
1151
- const hour23 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23];
1152
- // h24 hour system uses 1-24. Midnight starts at 24:00.
1153
- const hour24 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 0];
1154
- /**
1155
- * Given a locale and a mode,
1156
- * return an array with formatted days
1157
- * of the week. iOS should display days
1158
- * such as "Mon" or "Tue".
1159
- * MD should display days such as "M"
1160
- * or "T".
1161
- */
1162
- const getDaysOfWeek = (locale, mode, firstDayOfWeek = 0) => {
1163
- /**
1164
- * Nov 1st, 2020 starts on a Sunday.
1165
- * ion-datetime assumes weeks start on Sunday,
1166
- * but is configurable via `firstDayOfWeek`.
1167
- */
1168
- const weekdayFormat = mode === 'ios' ? 'short' : 'narrow';
1169
- const intl = new Intl.DateTimeFormat(locale, { weekday: weekdayFormat });
1170
- const startDate = new Date('11/01/2020');
1171
- const daysOfWeek = [];
1172
- /**
1173
- * For each day of the week,
1174
- * get the day name.
1175
- */
1176
- for (let i = firstDayOfWeek; i < firstDayOfWeek + 7; i++) {
1177
- const currentDate = new Date(startDate);
1178
- currentDate.setDate(currentDate.getDate() + i);
1179
- daysOfWeek.push(intl.format(currentDate));
1180
- }
1181
- return daysOfWeek;
1182
- };
1183
- /**
1184
- * Returns an array containing all of the
1185
- * days in a month for a given year. Values are
1186
- * aligned with a week calendar starting on
1187
- * the firstDayOfWeek value (Sunday by default)
1188
- * using null values.
1189
- */
1190
- const getDaysOfMonth = (month, year, firstDayOfWeek, showAdjacentDays = false) => {
1191
- const numDays = getNumDaysInMonth(month, year);
1192
- let previousNumDays; //previous month number of days
1193
- if (month === 1) {
1194
- // If the current month is January, the previous month should be December of the previous year.
1195
- previousNumDays = getNumDaysInMonth(12, year - 1);
1196
- }
1197
- else {
1198
- // Otherwise, the previous month should be the current month - 1 of the same year.
1199
- previousNumDays = getNumDaysInMonth(month - 1, year);
1200
- }
1201
- const firstOfMonth = new Date(`${month}/1/${year}`).getDay();
1202
- /**
1203
- * To get the first day of the month aligned on the correct
1204
- * day of the week, we need to determine how many "filler" days
1205
- * to generate. These filler days as empty/disabled buttons
1206
- * that fill the space of the days of the week before the first
1207
- * of the month.
1208
- *
1209
- * There are two cases here:
1210
- *
1211
- * 1. If firstOfMonth = 4, firstDayOfWeek = 0 then the offset
1212
- * is (4 - (0 + 1)) = 3. Since the offset loop goes from 0 to 3 inclusive,
1213
- * this will generate 4 filler days (0, 1, 2, 3), and then day of week 4 will have
1214
- * the first day of the month.
1215
- *
1216
- * 2. If firstOfMonth = 2, firstDayOfWeek = 4 then the offset
1217
- * is (6 - (4 - 2)) = 4. Since the offset loop goes from 0 to 4 inclusive,
1218
- * this will generate 5 filler days (0, 1, 2, 3, 4), and then day of week 5 will have
1219
- * the first day of the month.
1220
- */
1221
- const offset = firstOfMonth >= firstDayOfWeek ? firstOfMonth - (firstDayOfWeek + 1) : 6 - (firstDayOfWeek - firstOfMonth);
1222
- let days = [];
1223
- for (let i = 1; i <= numDays; i++) {
1224
- days.push({ day: i, dayOfWeek: (offset + i) % 7, isAdjacentDay: false });
1225
- }
1226
- if (showAdjacentDays) {
1227
- for (let i = 0; i <= offset; i++) {
1228
- // Using offset create previous month adjacent day, starting from last day
1229
- days = [{ day: previousNumDays - i, dayOfWeek: (previousNumDays - i) % 7, isAdjacentDay: true }, ...days];
1230
- }
1231
- // Calculate positiveOffset
1232
- // The calendar will display 42 days (6 rows of 7 columns)
1233
- // Knowing this the offset is 41 (we start at index 0)
1234
- // minus (the previous offset + the current month days)
1235
- const positiveOffset = 41 - (numDays + offset);
1236
- for (let i = 0; i < positiveOffset; i++) {
1237
- days.push({ day: i + 1, dayOfWeek: (numDays + offset + i) % 7, isAdjacentDay: true });
1238
- }
1239
- }
1240
- else {
1241
- for (let i = 0; i <= offset; i++) {
1242
- days = [{ day: null, dayOfWeek: null, isAdjacentDay: false }, ...days];
1243
- }
1244
- }
1245
- return days;
1246
- };
1247
- /**
1248
- * Returns an array of pre-defined hour
1249
- * values based on the provided hourCycle.
1250
- */
1251
- const getHourData = (hourCycle) => {
1252
- switch (hourCycle) {
1253
- case 'h11':
1254
- return hour11;
1255
- case 'h12':
1256
- return hour12;
1257
- case 'h23':
1258
- return hour23;
1259
- case 'h24':
1260
- return hour24;
1261
- default:
1262
- throw new Error(`Invalid hour cycle "${hourCycle}"`);
1263
- }
1264
- };
1265
- /**
1266
- * Given a local, reference datetime parts and option
1267
- * max/min bound datetime parts, calculate the acceptable
1268
- * hour and minute values according to the bounds and locale.
1269
- */
1270
- const generateTime = (locale, refParts, hourCycle = 'h12', minParts, maxParts, hourValues, minuteValues) => {
1271
- const computedHourCycle = getHourCycle(locale, hourCycle);
1272
- const use24Hour = is24Hour(computedHourCycle);
1273
- let processedHours = getHourData(computedHourCycle);
1274
- let processedMinutes = minutes;
1275
- let isAMAllowed = true;
1276
- let isPMAllowed = true;
1277
- if (hourValues) {
1278
- processedHours = processedHours.filter((hour) => hourValues.includes(hour));
1279
- }
1280
- if (minuteValues) {
1281
- processedMinutes = processedMinutes.filter((minute) => minuteValues.includes(minute));
1282
- }
1283
- if (minParts) {
1284
- /**
1285
- * If ref day is the same as the
1286
- * minimum allowed day, filter hour/minute
1287
- * values according to min hour and minute.
1288
- */
1289
- if (isSameDay(refParts, minParts)) {
1290
- /**
1291
- * Users may not always set the hour/minute for
1292
- * min value (i.e. 2021-06-02) so we should allow
1293
- * all hours/minutes in that case.
1294
- */
1295
- if (minParts.hour !== undefined) {
1296
- processedHours = processedHours.filter((hour) => {
1297
- const convertedHour = refParts.ampm === 'pm' ? (hour + 12) % 24 : hour;
1298
- return (use24Hour ? hour : convertedHour) >= minParts.hour;
1299
- });
1300
- isAMAllowed = minParts.hour < 13;
1301
- }
1302
- if (minParts.minute !== undefined) {
1303
- /**
1304
- * The minimum minute range should not be enforced when
1305
- * the hour is greater than the min hour.
1306
- *
1307
- * For example with a minimum range of 09:30, users
1308
- * should be able to select 10:00-10:29 and beyond.
1309
- */
1310
- let isPastMinHour = false;
1311
- if (minParts.hour !== undefined && refParts.hour !== undefined) {
1312
- if (refParts.hour > minParts.hour) {
1313
- isPastMinHour = true;
1314
- }
1315
- }
1316
- processedMinutes = processedMinutes.filter((minute) => {
1317
- if (isPastMinHour) {
1318
- return true;
1319
- }
1320
- return minute >= minParts.minute;
1321
- });
1322
- }
1323
- /**
1324
- * If ref day is before minimum
1325
- * day do not render any hours/minute values
1326
- */
1327
- }
1328
- else if (isBefore(refParts, minParts)) {
1329
- processedHours = [];
1330
- processedMinutes = [];
1331
- isAMAllowed = isPMAllowed = false;
1332
- }
1333
- }
1334
- if (maxParts) {
1335
- /**
1336
- * If ref day is the same as the
1337
- * maximum allowed day, filter hour/minute
1338
- * values according to max hour and minute.
1339
- */
1340
- if (isSameDay(refParts, maxParts)) {
1341
- /**
1342
- * Users may not always set the hour/minute for
1343
- * max value (i.e. 2021-06-02) so we should allow
1344
- * all hours/minutes in that case.
1345
- */
1346
- if (maxParts.hour !== undefined) {
1347
- processedHours = processedHours.filter((hour) => {
1348
- const convertedHour = refParts.ampm === 'pm' ? (hour + 12) % 24 : hour;
1349
- return (use24Hour ? hour : convertedHour) <= maxParts.hour;
1350
- });
1351
- isPMAllowed = maxParts.hour >= 12;
1352
- }
1353
- if (maxParts.minute !== undefined && refParts.hour === maxParts.hour) {
1354
- // The available minutes should only be filtered when the hour is the same as the max hour.
1355
- // For example if the max hour is 10:30 and the current hour is 10:00,
1356
- // users should be able to select 00-30 minutes.
1357
- // If the current hour is 09:00, users should be able to select 00-60 minutes.
1358
- processedMinutes = processedMinutes.filter((minute) => minute <= maxParts.minute);
1359
- }
1360
- /**
1361
- * If ref day is after minimum
1362
- * day do not render any hours/minute values
1363
- */
1364
- }
1365
- else if (isAfter(refParts, maxParts)) {
1366
- processedHours = [];
1367
- processedMinutes = [];
1368
- isAMAllowed = isPMAllowed = false;
1369
- }
1370
- }
1371
- return {
1372
- hours: processedHours,
1373
- minutes: processedMinutes,
1374
- am: isAMAllowed,
1375
- pm: isPMAllowed,
1376
- };
1377
- };
1378
- /**
1379
- * Given DatetimeParts, generate the previous,
1380
- * current, and and next months.
1381
- */
1382
- const generateMonths = (refParts, forcedDate) => {
1383
- const current = { month: refParts.month, year: refParts.year, day: refParts.day };
1384
- /**
1385
- * If we're forcing a month to appear, and it's different from the current month,
1386
- * ensure it appears by replacing the next or previous month as appropriate.
1387
- */
1388
- if (forcedDate !== undefined && (refParts.month !== forcedDate.month || refParts.year !== forcedDate.year)) {
1389
- const forced = { month: forcedDate.month, year: forcedDate.year, day: forcedDate.day };
1390
- const forcedMonthIsBefore = isBefore(forced, current);
1391
- return forcedMonthIsBefore
1392
- ? [forced, current, getNextMonth(refParts)]
1393
- : [getPreviousMonth(refParts), current, forced];
1394
- }
1395
- return [getPreviousMonth(refParts), current, getNextMonth(refParts)];
1396
- };
1397
- const getMonthColumnData = (locale, refParts, minParts, maxParts, monthValues, formatOptions = {
1398
- month: 'long',
1399
- }) => {
1400
- const { year } = refParts;
1401
- const months = [];
1402
- if (monthValues !== undefined) {
1403
- let processedMonths = monthValues;
1404
- if ((maxParts === null || maxParts === void 0 ? void 0 : maxParts.month) !== undefined) {
1405
- processedMonths = processedMonths.filter((month) => month <= maxParts.month);
1406
- }
1407
- if ((minParts === null || minParts === void 0 ? void 0 : minParts.month) !== undefined) {
1408
- processedMonths = processedMonths.filter((month) => month >= minParts.month);
1409
- }
1410
- processedMonths.forEach((processedMonth) => {
1411
- const date = new Date(`${processedMonth}/1/${year} GMT+0000`);
1412
- const monthString = new Intl.DateTimeFormat(locale, Object.assign(Object.assign({}, formatOptions), { timeZone: 'UTC' })).format(date);
1413
- months.push({ text: monthString, value: processedMonth });
1414
- });
1415
- }
1416
- else {
1417
- const maxMonth = maxParts && maxParts.year === year ? maxParts.month : 12;
1418
- const minMonth = minParts && minParts.year === year ? minParts.month : 1;
1419
- for (let i = minMonth; i <= maxMonth; i++) {
1420
- /**
1421
- *
1422
- * There is a bug on iOS 14 where
1423
- * Intl.DateTimeFormat takes into account
1424
- * the local timezone offset when formatting dates.
1425
- *
1426
- * Forcing the timezone to 'UTC' fixes the issue. However,
1427
- * we should keep this workaround as it is safer. In the event
1428
- * this breaks in another browser, we will not be impacted
1429
- * because all dates will be interpreted in UTC.
1430
- *
1431
- * Example:
1432
- * new Intl.DateTimeFormat('en-US', { month: 'long' }).format(new Date('Sat Apr 01 2006 00:00:00 GMT-0400 (EDT)')) // "March"
1433
- * new Intl.DateTimeFormat('en-US', { month: 'long', timeZone: 'UTC' }).format(new Date('Sat Apr 01 2006 00:00:00 GMT-0400 (EDT)')) // "April"
1434
- *
1435
- * In certain timezones, iOS 14 shows the wrong
1436
- * date for .toUTCString(). To combat this, we
1437
- * force all of the timezones to GMT+0000 (UTC).
1438
- *
1439
- * Example:
1440
- * Time Zone: Central European Standard Time
1441
- * new Date('1/1/1992').toUTCString() // "Tue, 31 Dec 1991 23:00:00 GMT"
1442
- * new Date('1/1/1992 GMT+0000').toUTCString() // "Wed, 01 Jan 1992 00:00:00 GMT"
1443
- */
1444
- const date = new Date(`${i}/1/${year} GMT+0000`);
1445
- const monthString = new Intl.DateTimeFormat(locale, Object.assign(Object.assign({}, formatOptions), { timeZone: 'UTC' })).format(date);
1446
- months.push({ text: monthString, value: i });
1447
- }
1448
- }
1449
- return months;
1450
- };
1451
- /**
1452
- * Returns information regarding
1453
- * selectable dates (i.e 1st, 2nd, 3rd, etc)
1454
- * within a reference month.
1455
- * @param locale The locale to format the date with
1456
- * @param refParts The reference month/year to generate dates for
1457
- * @param minParts The minimum bound on the date that can be returned
1458
- * @param maxParts The maximum bound on the date that can be returned
1459
- * @param dayValues The allowed date values
1460
- * @returns Date data to be used in ion-picker-column
1461
- */
1462
- const getDayColumnData = (locale, refParts, minParts, maxParts, dayValues, formatOptions = {
1463
- day: 'numeric',
1464
- }) => {
1465
- const { month, year } = refParts;
1466
- const days = [];
1467
- /**
1468
- * If we have max/min bounds that in the same
1469
- * month/year as the refParts, we should
1470
- * use the define day as the max/min day.
1471
- * Otherwise, fallback to the max/min days in a month.
1472
- */
1473
- const numDaysInMonth = getNumDaysInMonth(month, year);
1474
- const maxDay = (maxParts === null || maxParts === void 0 ? void 0 : maxParts.day) !== null && (maxParts === null || maxParts === void 0 ? void 0 : maxParts.day) !== undefined && maxParts.year === year && maxParts.month === month
1475
- ? maxParts.day
1476
- : numDaysInMonth;
1477
- const minDay = (minParts === null || minParts === void 0 ? void 0 : minParts.day) !== null && (minParts === null || minParts === void 0 ? void 0 : minParts.day) !== undefined && minParts.year === year && minParts.month === month
1478
- ? minParts.day
1479
- : 1;
1480
- if (dayValues !== undefined) {
1481
- let processedDays = dayValues;
1482
- processedDays = processedDays.filter((day) => day >= minDay && day <= maxDay);
1483
- processedDays.forEach((processedDay) => {
1484
- const date = new Date(`${month}/${processedDay}/${year} GMT+0000`);
1485
- const dayString = new Intl.DateTimeFormat(locale, Object.assign(Object.assign({}, formatOptions), { timeZone: 'UTC' })).format(date);
1486
- days.push({ text: dayString, value: processedDay });
1487
- });
1488
- }
1489
- else {
1490
- for (let i = minDay; i <= maxDay; i++) {
1491
- const date = new Date(`${month}/${i}/${year} GMT+0000`);
1492
- const dayString = new Intl.DateTimeFormat(locale, Object.assign(Object.assign({}, formatOptions), { timeZone: 'UTC' })).format(date);
1493
- days.push({ text: dayString, value: i });
1494
- }
1495
- }
1496
- return days;
1497
- };
1498
- const getYearColumnData = (locale, refParts, minParts, maxParts, yearValues) => {
1499
- var _a, _b;
1500
- let processedYears = [];
1501
- if (yearValues !== undefined) {
1502
- processedYears = yearValues;
1503
- if ((maxParts === null || maxParts === void 0 ? void 0 : maxParts.year) !== undefined) {
1504
- processedYears = processedYears.filter((year) => year <= maxParts.year);
1505
- }
1506
- if ((minParts === null || minParts === void 0 ? void 0 : minParts.year) !== undefined) {
1507
- processedYears = processedYears.filter((year) => year >= minParts.year);
1508
- }
1509
- }
1510
- else {
1511
- const { year } = refParts;
1512
- const maxYear = (_a = maxParts === null || maxParts === void 0 ? void 0 : maxParts.year) !== null && _a !== void 0 ? _a : year;
1513
- const minYear = (_b = minParts === null || minParts === void 0 ? void 0 : minParts.year) !== null && _b !== void 0 ? _b : year - 100;
1514
- for (let i = minYear; i <= maxYear; i++) {
1515
- processedYears.push(i);
1516
- }
1517
- }
1518
- return processedYears.map((year) => ({
1519
- text: getYear(locale, { year, month: refParts.month, day: refParts.day }),
1520
- value: year,
1521
- }));
1522
- };
1523
- /**
1524
- * Given a starting date and an upper bound,
1525
- * this functions returns an array of all
1526
- * month objects in that range.
1527
- */
1528
- const getAllMonthsInRange = (currentParts, maxParts) => {
1529
- if (currentParts.month === maxParts.month && currentParts.year === maxParts.year) {
1530
- return [currentParts];
1531
- }
1532
- return [currentParts, ...getAllMonthsInRange(getNextMonth(currentParts), maxParts)];
1533
- };
1534
- /**
1535
- * Creates and returns picker items
1536
- * that represent the days in a month.
1537
- * Example: "Thu, Jun 2"
1538
- */
1539
- const getCombinedDateColumnData = (locale, todayParts, minParts, maxParts, dayValues, monthValues) => {
1540
- let items = [];
1541
- let parts = [];
1542
- /**
1543
- * Get all month objects from the min date
1544
- * to the max date. Note: Do not use getMonthColumnData
1545
- * as that function only generates dates within a
1546
- * single year.
1547
- */
1548
- let months = getAllMonthsInRange(minParts, maxParts);
1549
- /**
1550
- * Filter out any disallowed month values.
1551
- */
1552
- if (monthValues) {
1553
- months = months.filter(({ month }) => monthValues.includes(month));
1554
- }
1555
- /**
1556
- * Get all of the days in the month.
1557
- * From there, generate an array where
1558
- * each item has the month, date, and day
1559
- * of work as the text.
1560
- */
1561
- months.forEach((monthObject) => {
1562
- const referenceMonth = { month: monthObject.month, day: null, year: monthObject.year };
1563
- const monthDays = getDayColumnData(locale, referenceMonth, minParts, maxParts, dayValues, {
1564
- month: 'short',
1565
- day: 'numeric',
1566
- weekday: 'short',
1567
- });
1568
- const dateParts = [];
1569
- const dateColumnItems = [];
1570
- monthDays.forEach((dayObject) => {
1571
- const isToday = isSameDay(Object.assign(Object.assign({}, referenceMonth), { day: dayObject.value }), todayParts);
1572
- /**
1573
- * Today's date should read as "Today" (localized)
1574
- * not the actual date string
1575
- */
1576
- dateColumnItems.push({
1577
- text: isToday ? getTodayLabel(locale) : dayObject.text,
1578
- value: `${referenceMonth.year}-${referenceMonth.month}-${dayObject.value}`,
1579
- });
1580
- /**
1581
- * When selecting a date in the wheel picker
1582
- * we need access to the raw datetime parts data.
1583
- * The picker column only accepts values of
1584
- * type string or number, so we need to return
1585
- * two sets of data: A data set to be passed
1586
- * to the picker column, and a data set to
1587
- * be used to reference the raw data when
1588
- * updating the picker column value.
1589
- */
1590
- dateParts.push({
1591
- month: referenceMonth.month,
1592
- year: referenceMonth.year,
1593
- day: dayObject.value,
1594
- });
1595
- });
1596
- parts = [...parts, ...dateParts];
1597
- items = [...items, ...dateColumnItems];
1598
- });
1599
- return {
1600
- parts,
1601
- items,
1602
- };
1603
- };
1604
- const getTimeColumnsData = (locale, refParts, hourCycle, minParts, maxParts, allowedHourValues, allowedMinuteValues) => {
1605
- const computedHourCycle = getHourCycle(locale, hourCycle);
1606
- const use24Hour = is24Hour(computedHourCycle);
1607
- const { hours, minutes, am, pm } = generateTime(locale, refParts, computedHourCycle, minParts, maxParts, allowedHourValues, allowedMinuteValues);
1608
- const hoursItems = hours.map((hour) => {
1609
- return {
1610
- text: getFormattedHour(hour, computedHourCycle),
1611
- value: getInternalHourValue(hour, use24Hour, refParts.ampm),
1612
- };
1613
- });
1614
- const minutesItems = minutes.map((minute) => {
1615
- return {
1616
- text: addTimePadding(minute),
1617
- value: minute,
1618
- };
1619
- });
1620
- const dayPeriodItems = [];
1621
- if (am && !use24Hour) {
1622
- dayPeriodItems.push({
1623
- text: getLocalizedDayPeriod(locale, 'am'),
1624
- value: 'am',
1625
- });
1626
- }
1627
- if (pm && !use24Hour) {
1628
- dayPeriodItems.push({
1629
- text: getLocalizedDayPeriod(locale, 'pm'),
1630
- value: 'pm',
1631
- });
1632
- }
1633
- return {
1634
- minutesData: minutesItems,
1635
- hoursData: hoursItems,
1636
- dayPeriodData: dayPeriodItems,
1637
- };
1638
- };
1639
-
1117
+ exports.addTimePadding = addTimePadding;
1640
1118
  exports.calculateHourFromAMPM = calculateHourFromAMPM;
1641
1119
  exports.clampDate = clampDate;
1642
1120
  exports.convertDataToISO = convertDataToISO;
1643
1121
  exports.convertToArrayOfNumbers = convertToArrayOfNumbers;
1644
1122
  exports.formatValue = formatValue;
1645
1123
  exports.generateDayAriaLabel = generateDayAriaLabel;
1646
- exports.generateMonths = generateMonths;
1647
1124
  exports.getClosestValidDate = getClosestValidDate;
1648
- exports.getCombinedDateColumnData = getCombinedDateColumnData;
1649
1125
  exports.getDay = getDay;
1650
- exports.getDayColumnData = getDayColumnData;
1651
- exports.getDaysOfMonth = getDaysOfMonth;
1652
- exports.getDaysOfWeek = getDaysOfWeek;
1653
1126
  exports.getEndOfWeek = getEndOfWeek;
1127
+ exports.getFormattedHour = getFormattedHour;
1654
1128
  exports.getHourCycle = getHourCycle;
1129
+ exports.getInternalHourValue = getInternalHourValue;
1655
1130
  exports.getLocalizedDateTime = getLocalizedDateTime;
1131
+ exports.getLocalizedDayPeriod = getLocalizedDayPeriod;
1656
1132
  exports.getLocalizedTime = getLocalizedTime;
1657
1133
  exports.getMonthAndYear = getMonthAndYear;
1658
- exports.getMonthColumnData = getMonthColumnData;
1659
1134
  exports.getNextDay = getNextDay;
1660
1135
  exports.getNextMonth = getNextMonth;
1661
1136
  exports.getNextWeek = getNextWeek;
@@ -1667,9 +1142,9 @@ exports.getPreviousMonth = getPreviousMonth;
1667
1142
  exports.getPreviousWeek = getPreviousWeek;
1668
1143
  exports.getPreviousYear = getPreviousYear;
1669
1144
  exports.getStartOfWeek = getStartOfWeek;
1670
- exports.getTimeColumnsData = getTimeColumnsData;
1671
- exports.getToday = getToday;
1672
- exports.getYearColumnData = getYearColumnData;
1145
+ exports.getTodayLabel = getTodayLabel;
1146
+ exports.getYear = getYear;
1147
+ exports.is24Hour = is24Hour;
1673
1148
  exports.isAfter = isAfter;
1674
1149
  exports.isBefore = isBefore;
1675
1150
  exports.isLocaleDayPeriodRTL = isLocaleDayPeriodRTL;
@@ -1679,5 +1154,6 @@ exports.parseAmPm = parseAmPm;
1679
1154
  exports.parseDate = parseDate;
1680
1155
  exports.parseMaxParts = parseMaxParts;
1681
1156
  exports.parseMinParts = parseMinParts;
1157
+ exports.removeDateTzOffset = removeDateTzOffset;
1682
1158
  exports.validateParts = validateParts;
1683
1159
  exports.warnIfValueOutOfBounds = warnIfValueOutOfBounds;
@@ -7,7 +7,7 @@ var index = require('./index-Ct7gcRif.js');
7
7
  var helpers = require('./helpers-Cv23MFHM.js');
8
8
  var theme = require('./theme-CeDs6Hcv.js');
9
9
  var ionicGlobal = require('./ionic-global-B-cA6LkY.js');
10
- var data = require('./data-DLTUw-KF.js');
10
+ var format = require('./format-PxvGiOik.js');
11
11
 
12
12
  const datetimeButtonIosCss = () => `:host{display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center}:host button{border-radius:8px;-webkit-margin-start:2px;margin-inline-start:2px;-webkit-margin-end:2px;margin-inline-end:2px;margin-top:0px;margin-bottom:0px;position:relative;-webkit-transition:150ms color ease-in-out;transition:150ms color ease-in-out;border:none;background:var(--ion-color-step-300, var(--ion-background-color-step-300, #edeef0));color:var(--ion-text-color, #000);font-family:inherit;font-size:1rem;cursor:pointer;overflow:hidden;-webkit-appearance:none;-moz-appearance:none;appearance:none}:host(.time-active) #time-button,:host(.date-active) #date-button{color:var(--ion-color-base)}:host(.datetime-button-disabled){pointer-events:none}:host(.datetime-button-disabled) button{opacity:0.4}:host button{-webkit-padding-start:13px;padding-inline-start:13px;-webkit-padding-end:13px;padding-inline-end:13px;padding-top:7px;padding-bottom:7px}:host button.ion-activated{color:var(--ion-color-step-600, var(--ion-text-color-step-400, #666666))}`;
13
13
 
@@ -50,7 +50,7 @@ const DatetimeButton = class {
50
50
  * ion-datetime and then format it according
51
51
  * to the locale specified on ion-datetime.
52
52
  */
53
- this.setDateTimeText = () => {
53
+ this.setDateTimeText = async () => {
54
54
  var _a, _b, _c, _d, _e;
55
55
  const { datetimeEl, datetimePresentation } = this;
56
56
  if (!datetimeEl) {
@@ -59,10 +59,12 @@ const DatetimeButton = class {
59
59
  const { value, locale, formatOptions, hourCycle, preferWheel, multiple, titleSelectedDatesFormatter } = datetimeEl;
60
60
  const parsedValues = this.getParsedDateValues(value);
61
61
  /**
62
- * Both ion-datetime and ion-datetime-button default
63
- * to today's date and time if no value is set.
62
+ * Both ion-datetime and ion-datetime-button default to today's date and
63
+ * time if no value is set. We read the datetime's computed default so the
64
+ * button respects the same constraints (min, max, minuteValues, etc.) that
65
+ * the datetime applies to its own fallback, instead of using a raw "now".
64
66
  */
65
- const parsedDatetimes = data.parseDate(parsedValues.length > 0 ? parsedValues : [data.getToday()]);
67
+ const parsedDatetimes = parsedValues.length > 0 ? format.parseDate(parsedValues) : [await datetimeEl.getDefaultPart()];
66
68
  if (!parsedDatetimes) {
67
69
  return;
68
70
  }
@@ -74,13 +76,13 @@ const DatetimeButton = class {
74
76
  * warning in the console.
75
77
  */
76
78
  const firstParsedDatetime = parsedDatetimes[0];
77
- const computedHourCycle = data.getHourCycle(locale, hourCycle);
79
+ const computedHourCycle = format.getHourCycle(locale, hourCycle);
78
80
  this.dateText = this.timeText = undefined;
79
81
  switch (datetimePresentation) {
80
82
  case 'date-time':
81
83
  case 'time-date':
82
- const dateText = data.getLocalizedDateTime(locale, firstParsedDatetime, (_a = formatOptions === null || formatOptions === void 0 ? void 0 : formatOptions.date) !== null && _a !== void 0 ? _a : { month: 'short', day: 'numeric', year: 'numeric' });
83
- const timeText = data.getLocalizedTime(locale, firstParsedDatetime, computedHourCycle, formatOptions === null || formatOptions === void 0 ? void 0 : formatOptions.time);
84
+ const dateText = format.getLocalizedDateTime(locale, firstParsedDatetime, (_a = formatOptions === null || formatOptions === void 0 ? void 0 : formatOptions.date) !== null && _a !== void 0 ? _a : { month: 'short', day: 'numeric', year: 'numeric' });
85
+ const timeText = format.getLocalizedTime(locale, firstParsedDatetime, computedHourCycle, formatOptions === null || formatOptions === void 0 ? void 0 : formatOptions.time);
84
86
  if (preferWheel) {
85
87
  this.dateText = `${dateText} ${timeText}`;
86
88
  }
@@ -103,20 +105,20 @@ const DatetimeButton = class {
103
105
  this.dateText = headerText;
104
106
  }
105
107
  else {
106
- this.dateText = data.getLocalizedDateTime(locale, firstParsedDatetime, (_b = formatOptions === null || formatOptions === void 0 ? void 0 : formatOptions.date) !== null && _b !== void 0 ? _b : { month: 'short', day: 'numeric', year: 'numeric' });
108
+ this.dateText = format.getLocalizedDateTime(locale, firstParsedDatetime, (_b = formatOptions === null || formatOptions === void 0 ? void 0 : formatOptions.date) !== null && _b !== void 0 ? _b : { month: 'short', day: 'numeric', year: 'numeric' });
107
109
  }
108
110
  break;
109
111
  case 'time':
110
- this.timeText = data.getLocalizedTime(locale, firstParsedDatetime, computedHourCycle, formatOptions === null || formatOptions === void 0 ? void 0 : formatOptions.time);
112
+ this.timeText = format.getLocalizedTime(locale, firstParsedDatetime, computedHourCycle, formatOptions === null || formatOptions === void 0 ? void 0 : formatOptions.time);
111
113
  break;
112
114
  case 'month-year':
113
- this.dateText = data.getLocalizedDateTime(locale, firstParsedDatetime, (_c = formatOptions === null || formatOptions === void 0 ? void 0 : formatOptions.date) !== null && _c !== void 0 ? _c : { month: 'long', year: 'numeric' });
115
+ this.dateText = format.getLocalizedDateTime(locale, firstParsedDatetime, (_c = formatOptions === null || formatOptions === void 0 ? void 0 : formatOptions.date) !== null && _c !== void 0 ? _c : { month: 'long', year: 'numeric' });
114
116
  break;
115
117
  case 'month':
116
- this.dateText = data.getLocalizedDateTime(locale, firstParsedDatetime, (_d = formatOptions === null || formatOptions === void 0 ? void 0 : formatOptions.time) !== null && _d !== void 0 ? _d : { month: 'long' });
118
+ this.dateText = format.getLocalizedDateTime(locale, firstParsedDatetime, (_d = formatOptions === null || formatOptions === void 0 ? void 0 : formatOptions.time) !== null && _d !== void 0 ? _d : { month: 'long' });
117
119
  break;
118
120
  case 'year':
119
- this.dateText = data.getLocalizedDateTime(locale, firstParsedDatetime, (_e = formatOptions === null || formatOptions === void 0 ? void 0 : formatOptions.time) !== null && _e !== void 0 ? _e : { year: 'numeric' });
121
+ this.dateText = format.getLocalizedDateTime(locale, firstParsedDatetime, (_e = formatOptions === null || formatOptions === void 0 ? void 0 : formatOptions.time) !== null && _e !== void 0 ? _e : { year: 'numeric' });
120
122
  break;
121
123
  }
122
124
  };
@@ -337,11 +339,11 @@ const DatetimeButton = class {
337
339
  render() {
338
340
  const { color, dateText, timeText, selectedButton, datetimeActive, disabled } = this;
339
341
  const mode = ionicGlobal.getIonMode(this);
340
- return (index.h(index.Host, { key: '11d037e6ab061e5116842970760b04850b42f2c7', class: theme.createColorClasses(color, {
342
+ return (index.h(index.Host, { key: 'c28e5e428111f18eaceb030dca8aba5579867eaa', class: theme.createColorClasses(color, {
341
343
  [mode]: true,
342
344
  [`${selectedButton}-active`]: datetimeActive,
343
345
  ['datetime-button-disabled']: disabled,
344
- }) }, dateText && (index.h("button", { key: '08ecb62da0fcbf7466a1f2403276712a3ff17fbc', class: "ion-activatable", id: "date-button", "aria-expanded": datetimeActive ? 'true' : 'false', onClick: this.handleDateClick, disabled: disabled, part: "native", ref: (el) => (this.dateTargetEl = el) }, index.h("slot", { key: '1c04853d4d23c0f1a594602bde44511c98355644', name: "date-target" }, dateText), mode === 'md' && index.h("ion-ripple-effect", { key: '5fc566cd4bc885bcf983ce99e3dc65d7f485bf9b' }))), timeText && (index.h("button", { key: 'c9c5c34ac338badf8659da22bea5829d62c51169', class: "ion-activatable", id: "time-button", "aria-expanded": datetimeActive ? 'true' : 'false', onClick: this.handleTimeClick, disabled: disabled, part: "native", ref: (el) => (this.timeTargetEl = el) }, index.h("slot", { key: '147a9d2069dbf737f6fc64787823d6d5af5aa653', name: "time-target" }, timeText), mode === 'md' && index.h("ion-ripple-effect", { key: '70a5e25b75ed90ac6bba003468435f67aa9d8f0a' })))));
346
+ }) }, dateText && (index.h("button", { key: 'a08f41b3150ef7171d0f1d9b3d69b51be67b7b84', class: "ion-activatable", id: "date-button", "aria-expanded": datetimeActive ? 'true' : 'false', onClick: this.handleDateClick, disabled: disabled, part: "native", ref: (el) => (this.dateTargetEl = el) }, index.h("slot", { key: '35ee68ca1cea59f03e1b59b72606e618141c8e1f', name: "date-target" }, dateText), mode === 'md' && index.h("ion-ripple-effect", { key: '4be53227aaf0acd20e8ebbff9f645140e8a96f33' }))), timeText && (index.h("button", { key: 'ab500f9b78f8c194180073eaf7325041adbd02f7', class: "ion-activatable", id: "time-button", "aria-expanded": datetimeActive ? 'true' : 'false', onClick: this.handleTimeClick, disabled: disabled, part: "native", ref: (el) => (this.timeTargetEl = el) }, index.h("slot", { key: '5822486dfdedba6c071a0f5233cc06f8321a1f5d', name: "time-target" }, timeText), mode === 'md' && index.h("ion-ripple-effect", { key: '054a4acb811a98cc6d9bb6a3cf51232a1f09b0ea' })))));
345
347
  }
346
348
  get el() { return index.getElement(this); }
347
349
  };