@ionic/core 7.5.7-dev.11700601905.13f94170 → 7.5.7-nightly.20231122

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.
Files changed (32) hide show
  1. package/components/data.js +13 -41
  2. package/components/ion-datetime.js +3 -22
  3. package/dist/cjs/{data-88d0864d.js → data-c8d21093.js} +13 -41
  4. package/dist/cjs/ion-datetime-button.cjs.entry.js +1 -1
  5. package/dist/cjs/ion-datetime_3.cjs.entry.js +4 -23
  6. package/dist/collection/components/datetime/datetime.js +3 -22
  7. package/dist/collection/components/datetime/test/manipulation.spec.js +1 -77
  8. package/dist/collection/components/datetime/utils/manipulation.js +14 -42
  9. package/dist/docs.json +1 -1
  10. package/dist/esm/{data-2b019469.js → data-44d9e816.js} +13 -41
  11. package/dist/esm/ion-datetime-button.entry.js +1 -1
  12. package/dist/esm/ion-datetime_3.entry.js +4 -23
  13. package/dist/esm-es5/data-44d9e816.js +4 -0
  14. package/dist/esm-es5/ion-datetime-button.entry.js +1 -1
  15. package/dist/esm-es5/ion-datetime_3.entry.js +1 -1
  16. package/dist/ionic/ionic.esm.js +1 -1
  17. package/dist/ionic/p-17240d90.js +4 -0
  18. package/dist/ionic/p-40903d34.system.js +1 -1
  19. package/dist/ionic/{p-2743f9a7.system.entry.js → p-4c80afe1.system.entry.js} +1 -1
  20. package/dist/ionic/{p-c4c7fd8f.entry.js → p-8ad82eb3.entry.js} +1 -1
  21. package/dist/ionic/p-ad61e508.entry.js +4 -0
  22. package/dist/ionic/p-b8c3f071.system.js +4 -0
  23. package/dist/ionic/p-d91e93ac.system.entry.js +4 -0
  24. package/dist/types/components/datetime/utils/manipulation.d.ts +15 -34
  25. package/hydrate/index.js +16 -63
  26. package/package.json +1 -1
  27. package/dist/collection/components/datetime/test/prefer-wheel/datetime.spec.js +0 -27
  28. package/dist/esm-es5/data-2b019469.js +0 -4
  29. package/dist/ionic/p-1108f9bf.system.entry.js +0 -4
  30. package/dist/ionic/p-264c16e9.entry.js +0 -4
  31. package/dist/ionic/p-297741bc.system.js +0 -4
  32. package/dist/ionic/p-598cdf16.js +0 -4
@@ -716,60 +716,32 @@ const validateParts = (parts, minParts, maxParts) => {
716
716
  * Returns the closest date to refParts
717
717
  * that also meets the constraints of
718
718
  * the *Values params.
719
+ * @param refParts The reference date
720
+ * @param monthValues The allowed month values
721
+ * @param dayValues The allowed day (of the month) values
722
+ * @param yearValues The allowed year values
723
+ * @param hourValues The allowed hour values
724
+ * @param minuteValues The allowed minute values
719
725
  */
720
- const getClosestValidDate = ({ refParts, monthValues, dayValues, yearValues, hourValues, minuteValues, minParts, maxParts, }) => {
726
+ const getClosestValidDate = (refParts, monthValues, dayValues, yearValues, hourValues, minuteValues) => {
721
727
  const { hour, minute, day, month, year } = refParts;
722
- const copyParts = clampDate(Object.assign(Object.assign({}, refParts), { dayOfWeek: undefined }), minParts, maxParts);
728
+ const copyParts = Object.assign(Object.assign({}, refParts), { dayOfWeek: undefined });
723
729
  if (monthValues !== undefined) {
724
- // Filters out months that are out of the min/max bounds
725
- const filteredMonths = monthValues.filter((month) => !(minParts !== undefined && month < minParts.month) && !(maxParts !== undefined && month > maxParts.month));
726
- copyParts.month = findClosestValue(month, filteredMonths);
730
+ copyParts.month = findClosestValue(month, monthValues);
727
731
  }
728
732
  // Day is nullable but cannot be undefined
729
733
  if (day !== null && dayValues !== undefined) {
730
- // Filters out days that are out of the min/max bounds
731
- const filteredDays = dayValues.filter((day) => {
732
- if (minParts && isBefore(Object.assign(Object.assign({}, copyParts), { day }), minParts)) {
733
- return false;
734
- }
735
- if (maxParts && isAfter(Object.assign(Object.assign({}, copyParts), { day }), maxParts)) {
736
- return false;
737
- }
738
- return true;
739
- });
740
- copyParts.day = findClosestValue(day, filteredDays);
734
+ copyParts.day = findClosestValue(day, dayValues);
741
735
  }
742
736
  if (yearValues !== undefined) {
743
- // Filters out years that are out of the min/max bounds
744
- const filteredYears = yearValues.filter((year) => !(minParts !== undefined && year < minParts.year) && !(maxParts !== undefined && year > maxParts.year));
745
- copyParts.year = findClosestValue(year, filteredYears);
737
+ copyParts.year = findClosestValue(year, yearValues);
746
738
  }
747
739
  if (hour !== undefined && hourValues !== undefined) {
748
- // Filters out hours that are out of the min/max bounds
749
- const filteredHours = hourValues.filter((hour) => {
750
- if ((minParts === null || minParts === void 0 ? void 0 : minParts.hour) !== undefined && isSameDay(copyParts, minParts) && hour < minParts.hour) {
751
- return false;
752
- }
753
- if ((maxParts === null || maxParts === void 0 ? void 0 : maxParts.hour) !== undefined && isSameDay(copyParts, maxParts) && hour > maxParts.hour) {
754
- return false;
755
- }
756
- return true;
757
- });
758
- copyParts.hour = findClosestValue(hour, filteredHours);
740
+ copyParts.hour = findClosestValue(hour, hourValues);
759
741
  copyParts.ampm = parseAmPm(copyParts.hour);
760
742
  }
761
743
  if (minute !== undefined && minuteValues !== undefined) {
762
- // Filters out minutes that are out of the min/max bounds
763
- const filteredMinutes = minuteValues.filter((minute) => {
764
- if ((minParts === null || minParts === void 0 ? void 0 : minParts.minute) !== undefined && isSameDay(copyParts, minParts) && minute < minParts.minute) {
765
- return false;
766
- }
767
- if ((maxParts === null || maxParts === void 0 ? void 0 : maxParts.minute) !== undefined && isSameDay(copyParts, maxParts) && minute > maxParts.minute) {
768
- return false;
769
- }
770
- return true;
771
- });
772
- copyParts.minute = findClosestValue(minute, filteredMinutes);
744
+ copyParts.minute = findClosestValue(minute, minuteValues);
773
745
  }
774
746
  return copyParts;
775
747
  };
@@ -867,24 +867,14 @@ const Datetime = /*@__PURE__*/ proxyCustomElement(class Datetime extends HTMLEle
867
867
  * or modal that the datetime was presented in.
868
868
  */
869
869
  async confirm(closeOverlay = false) {
870
- const { isCalendarPicker, activeParts, preferWheel, workingParts } = this;
870
+ const { isCalendarPicker, activeParts } = this;
871
871
  /**
872
872
  * We only update the value if the presentation is not a calendar picker.
873
873
  */
874
874
  if (activeParts !== undefined || !isCalendarPicker) {
875
875
  const activePartsIsArray = Array.isArray(activeParts);
876
876
  if (activePartsIsArray && activeParts.length === 0) {
877
- if (preferWheel) {
878
- /**
879
- * If the datetime is using a wheel picker, but the
880
- * active parts are empty, then the user has confirmed the
881
- * initial value (working parts) presented to them.
882
- */
883
- this.setValue(convertDataToISO(workingParts));
884
- }
885
- else {
886
- this.setValue(undefined);
887
- }
877
+ this.setValue(undefined);
888
878
  }
889
879
  else {
890
880
  this.setValue(convertDataToISO(activeParts));
@@ -1088,18 +1078,9 @@ const Datetime = /*@__PURE__*/ proxyCustomElement(class Datetime extends HTMLEle
1088
1078
  const yearValues = (this.parsedYearValues = convertToArrayOfNumbers(this.yearValues));
1089
1079
  const dayValues = (this.parsedDayValues = convertToArrayOfNumbers(this.dayValues));
1090
1080
  const todayParts = (this.todayParts = parseDate(getToday()));
1081
+ this.defaultParts = getClosestValidDate(todayParts, monthValues, dayValues, yearValues, hourValues, minuteValues);
1091
1082
  this.processMinParts();
1092
1083
  this.processMaxParts();
1093
- this.defaultParts = getClosestValidDate({
1094
- refParts: todayParts,
1095
- monthValues,
1096
- dayValues,
1097
- yearValues,
1098
- hourValues,
1099
- minuteValues,
1100
- minParts: this.minParts,
1101
- maxParts: this.maxParts,
1102
- });
1103
1084
  this.processValue(this.value);
1104
1085
  this.emitStyle();
1105
1086
  }
@@ -718,60 +718,32 @@ const validateParts = (parts, minParts, maxParts) => {
718
718
  * Returns the closest date to refParts
719
719
  * that also meets the constraints of
720
720
  * the *Values params.
721
+ * @param refParts The reference date
722
+ * @param monthValues The allowed month values
723
+ * @param dayValues The allowed day (of the month) values
724
+ * @param yearValues The allowed year values
725
+ * @param hourValues The allowed hour values
726
+ * @param minuteValues The allowed minute values
721
727
  */
722
- const getClosestValidDate = ({ refParts, monthValues, dayValues, yearValues, hourValues, minuteValues, minParts, maxParts, }) => {
728
+ const getClosestValidDate = (refParts, monthValues, dayValues, yearValues, hourValues, minuteValues) => {
723
729
  const { hour, minute, day, month, year } = refParts;
724
- const copyParts = clampDate(Object.assign(Object.assign({}, refParts), { dayOfWeek: undefined }), minParts, maxParts);
730
+ const copyParts = Object.assign(Object.assign({}, refParts), { dayOfWeek: undefined });
725
731
  if (monthValues !== undefined) {
726
- // Filters out months that are out of the min/max bounds
727
- const filteredMonths = monthValues.filter((month) => !(minParts !== undefined && month < minParts.month) && !(maxParts !== undefined && month > maxParts.month));
728
- copyParts.month = findClosestValue(month, filteredMonths);
732
+ copyParts.month = findClosestValue(month, monthValues);
729
733
  }
730
734
  // Day is nullable but cannot be undefined
731
735
  if (day !== null && dayValues !== undefined) {
732
- // Filters out days that are out of the min/max bounds
733
- const filteredDays = dayValues.filter((day) => {
734
- if (minParts && isBefore(Object.assign(Object.assign({}, copyParts), { day }), minParts)) {
735
- return false;
736
- }
737
- if (maxParts && isAfter(Object.assign(Object.assign({}, copyParts), { day }), maxParts)) {
738
- return false;
739
- }
740
- return true;
741
- });
742
- copyParts.day = findClosestValue(day, filteredDays);
736
+ copyParts.day = findClosestValue(day, dayValues);
743
737
  }
744
738
  if (yearValues !== undefined) {
745
- // Filters out years that are out of the min/max bounds
746
- const filteredYears = yearValues.filter((year) => !(minParts !== undefined && year < minParts.year) && !(maxParts !== undefined && year > maxParts.year));
747
- copyParts.year = findClosestValue(year, filteredYears);
739
+ copyParts.year = findClosestValue(year, yearValues);
748
740
  }
749
741
  if (hour !== undefined && hourValues !== undefined) {
750
- // Filters out hours that are out of the min/max bounds
751
- const filteredHours = hourValues.filter((hour) => {
752
- if ((minParts === null || minParts === void 0 ? void 0 : minParts.hour) !== undefined && isSameDay(copyParts, minParts) && hour < minParts.hour) {
753
- return false;
754
- }
755
- if ((maxParts === null || maxParts === void 0 ? void 0 : maxParts.hour) !== undefined && isSameDay(copyParts, maxParts) && hour > maxParts.hour) {
756
- return false;
757
- }
758
- return true;
759
- });
760
- copyParts.hour = findClosestValue(hour, filteredHours);
742
+ copyParts.hour = findClosestValue(hour, hourValues);
761
743
  copyParts.ampm = parseAmPm(copyParts.hour);
762
744
  }
763
745
  if (minute !== undefined && minuteValues !== undefined) {
764
- // Filters out minutes that are out of the min/max bounds
765
- const filteredMinutes = minuteValues.filter((minute) => {
766
- if ((minParts === null || minParts === void 0 ? void 0 : minParts.minute) !== undefined && isSameDay(copyParts, minParts) && minute < minParts.minute) {
767
- return false;
768
- }
769
- if ((maxParts === null || maxParts === void 0 ? void 0 : maxParts.minute) !== undefined && isSameDay(copyParts, maxParts) && minute > maxParts.minute) {
770
- return false;
771
- }
772
- return true;
773
- });
774
- copyParts.minute = findClosestValue(minute, filteredMinutes);
746
+ copyParts.minute = findClosestValue(minute, minuteValues);
775
747
  }
776
748
  return copyParts;
777
749
  };
@@ -10,7 +10,7 @@ const helpers = require('./helpers-ea4ccbcb.js');
10
10
  const index$1 = require('./index-cc7dfb7c.js');
11
11
  const theme = require('./theme-fbc56b3b.js');
12
12
  const ionicGlobal = require('./ionic-global-ea2901a3.js');
13
- const data = require('./data-88d0864d.js');
13
+ const data = require('./data-c8d21093.js');
14
14
 
15
15
  const iosDatetimeButtonCss = ":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-padding-start:12px;padding-inline-start:12px;-webkit-padding-end:12px;padding-inline-end:12px;padding-top:6px;padding-bottom:6px;-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, #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}";
16
16
 
@@ -13,7 +13,7 @@ const dir = require('./dir-f1e0ca26.js');
13
13
  const theme = require('./theme-fbc56b3b.js');
14
14
  const index$2 = require('./index-09471526.js');
15
15
  const ionicGlobal = require('./ionic-global-ea2901a3.js');
16
- const data = require('./data-88d0864d.js');
16
+ const data = require('./data-c8d21093.js');
17
17
  const lockController = require('./lock-controller-4ae2eb59.js');
18
18
  const overlays = require('./overlays-2ffc5f27.js');
19
19
  const animation = require('./animation-1083855c.js');
@@ -866,24 +866,14 @@ const Datetime = class {
866
866
  * or modal that the datetime was presented in.
867
867
  */
868
868
  async confirm(closeOverlay = false) {
869
- const { isCalendarPicker, activeParts, preferWheel, workingParts } = this;
869
+ const { isCalendarPicker, activeParts } = this;
870
870
  /**
871
871
  * We only update the value if the presentation is not a calendar picker.
872
872
  */
873
873
  if (activeParts !== undefined || !isCalendarPicker) {
874
874
  const activePartsIsArray = Array.isArray(activeParts);
875
875
  if (activePartsIsArray && activeParts.length === 0) {
876
- if (preferWheel) {
877
- /**
878
- * If the datetime is using a wheel picker, but the
879
- * active parts are empty, then the user has confirmed the
880
- * initial value (working parts) presented to them.
881
- */
882
- this.setValue(data.convertDataToISO(workingParts));
883
- }
884
- else {
885
- this.setValue(undefined);
886
- }
876
+ this.setValue(undefined);
887
877
  }
888
878
  else {
889
879
  this.setValue(data.convertDataToISO(activeParts));
@@ -1087,18 +1077,9 @@ const Datetime = class {
1087
1077
  const yearValues = (this.parsedYearValues = data.convertToArrayOfNumbers(this.yearValues));
1088
1078
  const dayValues = (this.parsedDayValues = data.convertToArrayOfNumbers(this.dayValues));
1089
1079
  const todayParts = (this.todayParts = data.parseDate(data.getToday()));
1080
+ this.defaultParts = data.getClosestValidDate(todayParts, monthValues, dayValues, yearValues, hourValues, minuteValues);
1090
1081
  this.processMinParts();
1091
1082
  this.processMaxParts();
1092
- this.defaultParts = data.getClosestValidDate({
1093
- refParts: todayParts,
1094
- monthValues,
1095
- dayValues,
1096
- yearValues,
1097
- hourValues,
1098
- minuteValues,
1099
- minParts: this.minParts,
1100
- maxParts: this.maxParts,
1101
- });
1102
1083
  this.processValue(this.value);
1103
1084
  this.emitStyle();
1104
1085
  }
@@ -704,24 +704,14 @@ export class Datetime {
704
704
  * or modal that the datetime was presented in.
705
705
  */
706
706
  async confirm(closeOverlay = false) {
707
- const { isCalendarPicker, activeParts, preferWheel, workingParts } = this;
707
+ const { isCalendarPicker, activeParts } = this;
708
708
  /**
709
709
  * We only update the value if the presentation is not a calendar picker.
710
710
  */
711
711
  if (activeParts !== undefined || !isCalendarPicker) {
712
712
  const activePartsIsArray = Array.isArray(activeParts);
713
713
  if (activePartsIsArray && activeParts.length === 0) {
714
- if (preferWheel) {
715
- /**
716
- * If the datetime is using a wheel picker, but the
717
- * active parts are empty, then the user has confirmed the
718
- * initial value (working parts) presented to them.
719
- */
720
- this.setValue(convertDataToISO(workingParts));
721
- }
722
- else {
723
- this.setValue(undefined);
724
- }
714
+ this.setValue(undefined);
725
715
  }
726
716
  else {
727
717
  this.setValue(convertDataToISO(activeParts));
@@ -925,18 +915,9 @@ export class Datetime {
925
915
  const yearValues = (this.parsedYearValues = convertToArrayOfNumbers(this.yearValues));
926
916
  const dayValues = (this.parsedDayValues = convertToArrayOfNumbers(this.dayValues));
927
917
  const todayParts = (this.todayParts = parseDate(getToday()));
918
+ this.defaultParts = getClosestValidDate(todayParts, monthValues, dayValues, yearValues, hourValues, minuteValues);
928
919
  this.processMinParts();
929
920
  this.processMaxParts();
930
- this.defaultParts = getClosestValidDate({
931
- refParts: todayParts,
932
- monthValues,
933
- dayValues,
934
- yearValues,
935
- hourValues,
936
- minuteValues,
937
- minParts: this.minParts,
938
- maxParts: this.maxParts,
939
- });
940
921
  this.processValue(this.value);
941
922
  this.emitStyle();
942
923
  }
@@ -1,7 +1,7 @@
1
1
  /*!
2
2
  * (C) Ionic http://ionicframework.com - MIT License
3
3
  */
4
- import { getPreviousYear, getNextYear, getPreviousMonth, getNextMonth, getPreviousDay, getNextDay, getPreviousWeek, getNextWeek, getEndOfWeek, getStartOfWeek, convert12HourTo24Hour, getInternalHourValue, calculateHourFromAMPM, subtractDays, addDays, validateParts, getClosestValidDate, } from "../utils/manipulation";
4
+ import { getPreviousYear, getNextYear, getPreviousMonth, getNextMonth, getPreviousDay, getNextDay, getPreviousWeek, getNextWeek, getEndOfWeek, getStartOfWeek, convert12HourTo24Hour, getInternalHourValue, calculateHourFromAMPM, subtractDays, addDays, validateParts, } from "../utils/manipulation";
5
5
  describe('addDays()', () => {
6
6
  it('should correctly add days', () => {
7
7
  expect(addDays({
@@ -431,79 +431,3 @@ describe('validateParts()', () => {
431
431
  })).toEqual({ month: 1, day: 1, year: 2022, hour: 9, minute: 30 });
432
432
  });
433
433
  });
434
- describe('getClosestValidDate()', () => {
435
- it('should match a date with only month/day/year', () => {
436
- // October 10, 2023
437
- const refParts = { month: 10, day: 10, year: 2023 };
438
- // April 10, 2021
439
- const minParts = { month: 4, day: 10, year: 2021 };
440
- // September 14, 2021
441
- const maxParts = { month: 9, day: 14, year: 2021 };
442
- // September 4, 2021
443
- const expected = { month: 9, day: 4, year: 2021, dayOfWeek: undefined };
444
- expect(getClosestValidDate({
445
- refParts,
446
- monthValues: [2, 3, 7, 9, 10],
447
- dayValues: [4, 15, 25],
448
- yearValues: [2020, 2021, 2023],
449
- maxParts,
450
- minParts,
451
- })).toEqual(expected);
452
- });
453
- it('should match a date when the reference date is before the min', () => {
454
- // April 2, 2020 3:20 PM
455
- const refParts = { month: 4, day: 2, year: 2020, hour: 15, minute: 20 };
456
- // September 10, 2021 10:10 AM
457
- const minParts = { month: 9, day: 10, year: 2021, hour: 10, minute: 10 };
458
- // September 14, 2021 10:11 AM
459
- const maxParts = { month: 9, day: 14, year: 2021, hour: 10, minute: 11 };
460
- // September 11, 2021 11:15 AM
461
- const expected = {
462
- year: 2021,
463
- day: 11,
464
- month: 9,
465
- hour: 11,
466
- minute: 15,
467
- ampm: 'am',
468
- dayOfWeek: undefined,
469
- };
470
- expect(getClosestValidDate({
471
- refParts,
472
- monthValues: [4, 9, 11],
473
- dayValues: [11, 12, 13, 14],
474
- yearValues: [2020, 2021, 2023],
475
- hourValues: [9, 10, 11],
476
- minuteValues: [11, 12, 13, 14, 15],
477
- maxParts,
478
- minParts,
479
- })).toEqual(expected);
480
- });
481
- it('should match a date when the reference date is before the min', () => {
482
- // April 2, 2020 3:20 PM
483
- const refParts = { month: 4, day: 2, year: 2020, hour: 15, minute: 20 };
484
- // September 10, 2021 10:10 AM
485
- const minParts = { month: 9, day: 10, year: 2021, hour: 10, minute: 10 };
486
- // September 10, 2021 10:15 AM
487
- const maxParts = { month: 9, day: 10, year: 2021, hour: 10, minute: 15 };
488
- // September 10, 2021 10:15 AM
489
- const expected = {
490
- month: 9,
491
- day: 10,
492
- year: 2021,
493
- hour: 10,
494
- minute: 15,
495
- ampm: 'am',
496
- dayOfWeek: undefined,
497
- };
498
- expect(getClosestValidDate({
499
- refParts,
500
- monthValues: [4, 9, 11],
501
- dayValues: [10, 12, 13, 14],
502
- yearValues: [2020, 2021, 2023],
503
- hourValues: [9, 10, 11],
504
- minuteValues: [11, 12, 13, 14, 15],
505
- minParts,
506
- maxParts,
507
- })).toEqual(expected);
508
- });
509
- });
@@ -1,7 +1,7 @@
1
1
  /*!
2
2
  * (C) Ionic http://ionicframework.com - MIT License
3
3
  */
4
- import { isAfter, isBefore, isSameDay } from "./comparison";
4
+ import { isSameDay } from "./comparison";
5
5
  import { getNumDaysInMonth } from "./helpers";
6
6
  import { clampDate, parseAmPm } from "./parse";
7
7
  const twoDigit = (val) => {
@@ -355,60 +355,32 @@ export const validateParts = (parts, minParts, maxParts) => {
355
355
  * Returns the closest date to refParts
356
356
  * that also meets the constraints of
357
357
  * the *Values params.
358
+ * @param refParts The reference date
359
+ * @param monthValues The allowed month values
360
+ * @param dayValues The allowed day (of the month) values
361
+ * @param yearValues The allowed year values
362
+ * @param hourValues The allowed hour values
363
+ * @param minuteValues The allowed minute values
358
364
  */
359
- export const getClosestValidDate = ({ refParts, monthValues, dayValues, yearValues, hourValues, minuteValues, minParts, maxParts, }) => {
365
+ export const getClosestValidDate = (refParts, monthValues, dayValues, yearValues, hourValues, minuteValues) => {
360
366
  const { hour, minute, day, month, year } = refParts;
361
- const copyParts = clampDate(Object.assign(Object.assign({}, refParts), { dayOfWeek: undefined }), minParts, maxParts);
367
+ const copyParts = Object.assign(Object.assign({}, refParts), { dayOfWeek: undefined });
362
368
  if (monthValues !== undefined) {
363
- // Filters out months that are out of the min/max bounds
364
- const filteredMonths = monthValues.filter((month) => !(minParts !== undefined && month < minParts.month) && !(maxParts !== undefined && month > maxParts.month));
365
- copyParts.month = findClosestValue(month, filteredMonths);
369
+ copyParts.month = findClosestValue(month, monthValues);
366
370
  }
367
371
  // Day is nullable but cannot be undefined
368
372
  if (day !== null && dayValues !== undefined) {
369
- // Filters out days that are out of the min/max bounds
370
- const filteredDays = dayValues.filter((day) => {
371
- if (minParts && isBefore(Object.assign(Object.assign({}, copyParts), { day }), minParts)) {
372
- return false;
373
- }
374
- if (maxParts && isAfter(Object.assign(Object.assign({}, copyParts), { day }), maxParts)) {
375
- return false;
376
- }
377
- return true;
378
- });
379
- copyParts.day = findClosestValue(day, filteredDays);
373
+ copyParts.day = findClosestValue(day, dayValues);
380
374
  }
381
375
  if (yearValues !== undefined) {
382
- // Filters out years that are out of the min/max bounds
383
- const filteredYears = yearValues.filter((year) => !(minParts !== undefined && year < minParts.year) && !(maxParts !== undefined && year > maxParts.year));
384
- copyParts.year = findClosestValue(year, filteredYears);
376
+ copyParts.year = findClosestValue(year, yearValues);
385
377
  }
386
378
  if (hour !== undefined && hourValues !== undefined) {
387
- // Filters out hours that are out of the min/max bounds
388
- const filteredHours = hourValues.filter((hour) => {
389
- if ((minParts === null || minParts === void 0 ? void 0 : minParts.hour) !== undefined && isSameDay(copyParts, minParts) && hour < minParts.hour) {
390
- return false;
391
- }
392
- if ((maxParts === null || maxParts === void 0 ? void 0 : maxParts.hour) !== undefined && isSameDay(copyParts, maxParts) && hour > maxParts.hour) {
393
- return false;
394
- }
395
- return true;
396
- });
397
- copyParts.hour = findClosestValue(hour, filteredHours);
379
+ copyParts.hour = findClosestValue(hour, hourValues);
398
380
  copyParts.ampm = parseAmPm(copyParts.hour);
399
381
  }
400
382
  if (minute !== undefined && minuteValues !== undefined) {
401
- // Filters out minutes that are out of the min/max bounds
402
- const filteredMinutes = minuteValues.filter((minute) => {
403
- if ((minParts === null || minParts === void 0 ? void 0 : minParts.minute) !== undefined && isSameDay(copyParts, minParts) && minute < minParts.minute) {
404
- return false;
405
- }
406
- if ((maxParts === null || maxParts === void 0 ? void 0 : maxParts.minute) !== undefined && isSameDay(copyParts, maxParts) && minute > maxParts.minute) {
407
- return false;
408
- }
409
- return true;
410
- });
411
- copyParts.minute = findClosestValue(minute, filteredMinutes);
383
+ copyParts.minute = findClosestValue(minute, minuteValues);
412
384
  }
413
385
  return copyParts;
414
386
  };
package/dist/docs.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "timestamp": "2023-11-21T21:26:53",
2
+ "timestamp": "2023-11-22T06:03:01",
3
3
  "compiler": {
4
4
  "name": "@stencil/core",
5
5
  "version": "4.7.2",
@@ -716,60 +716,32 @@ const validateParts = (parts, minParts, maxParts) => {
716
716
  * Returns the closest date to refParts
717
717
  * that also meets the constraints of
718
718
  * the *Values params.
719
+ * @param refParts The reference date
720
+ * @param monthValues The allowed month values
721
+ * @param dayValues The allowed day (of the month) values
722
+ * @param yearValues The allowed year values
723
+ * @param hourValues The allowed hour values
724
+ * @param minuteValues The allowed minute values
719
725
  */
720
- const getClosestValidDate = ({ refParts, monthValues, dayValues, yearValues, hourValues, minuteValues, minParts, maxParts, }) => {
726
+ const getClosestValidDate = (refParts, monthValues, dayValues, yearValues, hourValues, minuteValues) => {
721
727
  const { hour, minute, day, month, year } = refParts;
722
- const copyParts = clampDate(Object.assign(Object.assign({}, refParts), { dayOfWeek: undefined }), minParts, maxParts);
728
+ const copyParts = Object.assign(Object.assign({}, refParts), { dayOfWeek: undefined });
723
729
  if (monthValues !== undefined) {
724
- // Filters out months that are out of the min/max bounds
725
- const filteredMonths = monthValues.filter((month) => !(minParts !== undefined && month < minParts.month) && !(maxParts !== undefined && month > maxParts.month));
726
- copyParts.month = findClosestValue(month, filteredMonths);
730
+ copyParts.month = findClosestValue(month, monthValues);
727
731
  }
728
732
  // Day is nullable but cannot be undefined
729
733
  if (day !== null && dayValues !== undefined) {
730
- // Filters out days that are out of the min/max bounds
731
- const filteredDays = dayValues.filter((day) => {
732
- if (minParts && isBefore(Object.assign(Object.assign({}, copyParts), { day }), minParts)) {
733
- return false;
734
- }
735
- if (maxParts && isAfter(Object.assign(Object.assign({}, copyParts), { day }), maxParts)) {
736
- return false;
737
- }
738
- return true;
739
- });
740
- copyParts.day = findClosestValue(day, filteredDays);
734
+ copyParts.day = findClosestValue(day, dayValues);
741
735
  }
742
736
  if (yearValues !== undefined) {
743
- // Filters out years that are out of the min/max bounds
744
- const filteredYears = yearValues.filter((year) => !(minParts !== undefined && year < minParts.year) && !(maxParts !== undefined && year > maxParts.year));
745
- copyParts.year = findClosestValue(year, filteredYears);
737
+ copyParts.year = findClosestValue(year, yearValues);
746
738
  }
747
739
  if (hour !== undefined && hourValues !== undefined) {
748
- // Filters out hours that are out of the min/max bounds
749
- const filteredHours = hourValues.filter((hour) => {
750
- if ((minParts === null || minParts === void 0 ? void 0 : minParts.hour) !== undefined && isSameDay(copyParts, minParts) && hour < minParts.hour) {
751
- return false;
752
- }
753
- if ((maxParts === null || maxParts === void 0 ? void 0 : maxParts.hour) !== undefined && isSameDay(copyParts, maxParts) && hour > maxParts.hour) {
754
- return false;
755
- }
756
- return true;
757
- });
758
- copyParts.hour = findClosestValue(hour, filteredHours);
740
+ copyParts.hour = findClosestValue(hour, hourValues);
759
741
  copyParts.ampm = parseAmPm(copyParts.hour);
760
742
  }
761
743
  if (minute !== undefined && minuteValues !== undefined) {
762
- // Filters out minutes that are out of the min/max bounds
763
- const filteredMinutes = minuteValues.filter((minute) => {
764
- if ((minParts === null || minParts === void 0 ? void 0 : minParts.minute) !== undefined && isSameDay(copyParts, minParts) && minute < minParts.minute) {
765
- return false;
766
- }
767
- if ((maxParts === null || maxParts === void 0 ? void 0 : maxParts.minute) !== undefined && isSameDay(copyParts, maxParts) && minute > maxParts.minute) {
768
- return false;
769
- }
770
- return true;
771
- });
772
- copyParts.minute = findClosestValue(minute, filteredMinutes);
744
+ copyParts.minute = findClosestValue(minute, minuteValues);
773
745
  }
774
746
  return copyParts;
775
747
  };
@@ -6,7 +6,7 @@ import { a as addEventListener, c as componentOnReady } from './helpers-3379ba19
6
6
  import { a as printIonError } from './index-595d62c9.js';
7
7
  import { c as createColorClasses } from './theme-17531cdf.js';
8
8
  import { b as getIonMode } from './ionic-global-40e42e7f.js';
9
- import { q as parseDate, t as getToday, J as getHourCycle, S as getLocalizedDateTime, G as getMonthAndYear, K as getLocalizedTime, T as getMonthDayAndYear } from './data-2b019469.js';
9
+ import { q as parseDate, t as getToday, J as getHourCycle, S as getLocalizedDateTime, G as getMonthAndYear, K as getLocalizedTime, T as getMonthDayAndYear } from './data-44d9e816.js';
10
10
 
11
11
  const iosDatetimeButtonCss = ":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-padding-start:12px;padding-inline-start:12px;-webkit-padding-end:12px;padding-inline-end:12px;padding-top:6px;padding-bottom:6px;-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, #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}";
12
12
 
@@ -9,7 +9,7 @@ import { i as isRTL } from './dir-912e3e13.js';
9
9
  import { c as createColorClasses, g as getClassMap } from './theme-17531cdf.js';
10
10
  import { c as chevronBack, o as chevronForward, l as chevronDown, p as caretUpSharp, q as caretDownSharp } from './index-c132c5f1.js';
11
11
  import { b as getIonMode } from './ionic-global-40e42e7f.js';
12
- import { g as generateDayAriaLabel, a as getDay, i as isBefore, b as isAfter, c as isSameDay, d as getPreviousMonth, e as getNextMonth, v as validateParts, f as getPartsFromCalendarDay, h as getEndOfWeek, j as getStartOfWeek, k as getPreviousDay, l as getNextDay, m as getPreviousWeek, n as getNextWeek, p as parseMinParts, o as parseMaxParts, q as parseDate, w as warnIfValueOutOfBounds, r as convertToArrayOfNumbers, s as convertDataToISO, t as getToday, u as getClosestValidDate, x as getNumDaysInMonth, y as getCombinedDateColumnData, z as getMonthColumnData, A as getDayColumnData, B as getYearColumnData, C as isMonthFirstLocale, D as getTimeColumnsData, E as isLocaleDayPeriodRTL, F as getDaysOfWeek, G as getMonthAndYear, H as getDaysOfMonth, I as generateMonths, J as getHourCycle, K as getLocalizedTime, L as getMonthAndDay, M as formatValue, N as getNextYear, O as getPreviousYear, P as clampDate, Q as parseAmPm, R as calculateHourFromAMPM } from './data-2b019469.js';
12
+ import { g as generateDayAriaLabel, a as getDay, i as isBefore, b as isAfter, c as isSameDay, d as getPreviousMonth, e as getNextMonth, v as validateParts, f as getPartsFromCalendarDay, h as getEndOfWeek, j as getStartOfWeek, k as getPreviousDay, l as getNextDay, m as getPreviousWeek, n as getNextWeek, p as parseMinParts, o as parseMaxParts, q as parseDate, w as warnIfValueOutOfBounds, r as convertToArrayOfNumbers, s as convertDataToISO, t as getToday, u as getClosestValidDate, x as getNumDaysInMonth, y as getCombinedDateColumnData, z as getMonthColumnData, A as getDayColumnData, B as getYearColumnData, C as isMonthFirstLocale, D as getTimeColumnsData, E as isLocaleDayPeriodRTL, F as getDaysOfWeek, G as getMonthAndYear, H as getDaysOfMonth, I as generateMonths, J as getHourCycle, K as getLocalizedTime, L as getMonthAndDay, M as formatValue, N as getNextYear, O as getPreviousYear, P as clampDate, Q as parseAmPm, R as calculateHourFromAMPM } from './data-44d9e816.js';
13
13
  import { c as createLockController } from './lock-controller-e8c6c051.js';
14
14
  import { d as createDelegateController, e as createTriggerController, B as BACKDROP, i as isCancel, j as prepareOverlay, k as setOverlayId, f as present, g as dismiss, h as eventMethod, s as safeCall } from './overlays-6c9feb7e.js';
15
15
  import { c as createAnimation } from './animation-8aa13916.js';
@@ -862,24 +862,14 @@ const Datetime = class {
862
862
  * or modal that the datetime was presented in.
863
863
  */
864
864
  async confirm(closeOverlay = false) {
865
- const { isCalendarPicker, activeParts, preferWheel, workingParts } = this;
865
+ const { isCalendarPicker, activeParts } = this;
866
866
  /**
867
867
  * We only update the value if the presentation is not a calendar picker.
868
868
  */
869
869
  if (activeParts !== undefined || !isCalendarPicker) {
870
870
  const activePartsIsArray = Array.isArray(activeParts);
871
871
  if (activePartsIsArray && activeParts.length === 0) {
872
- if (preferWheel) {
873
- /**
874
- * If the datetime is using a wheel picker, but the
875
- * active parts are empty, then the user has confirmed the
876
- * initial value (working parts) presented to them.
877
- */
878
- this.setValue(convertDataToISO(workingParts));
879
- }
880
- else {
881
- this.setValue(undefined);
882
- }
872
+ this.setValue(undefined);
883
873
  }
884
874
  else {
885
875
  this.setValue(convertDataToISO(activeParts));
@@ -1083,18 +1073,9 @@ const Datetime = class {
1083
1073
  const yearValues = (this.parsedYearValues = convertToArrayOfNumbers(this.yearValues));
1084
1074
  const dayValues = (this.parsedDayValues = convertToArrayOfNumbers(this.dayValues));
1085
1075
  const todayParts = (this.todayParts = parseDate(getToday()));
1076
+ this.defaultParts = getClosestValidDate(todayParts, monthValues, dayValues, yearValues, hourValues, minuteValues);
1086
1077
  this.processMinParts();
1087
1078
  this.processMaxParts();
1088
- this.defaultParts = getClosestValidDate({
1089
- refParts: todayParts,
1090
- monthValues,
1091
- dayValues,
1092
- yearValues,
1093
- hourValues,
1094
- minuteValues,
1095
- minParts: this.minParts,
1096
- maxParts: this.maxParts,
1097
- });
1098
1079
  this.processValue(this.value);
1099
1080
  this.emitStyle();
1100
1081
  }