@ionic/core 8.7.13-dev.11765550444.1d97de23 → 8.7.13-dev.11765558154.1273081d
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/ion-datetime.js +68 -43
- package/dist/cjs/ion-datetime_3.cjs.entry.js +68 -43
- package/dist/collection/components/datetime/datetime.js +68 -43
- package/dist/docs.json +1 -1
- package/dist/esm/ion-datetime_3.entry.js +68 -43
- package/dist/ionic/ionic.esm.js +1 -1
- package/dist/ionic/p-8611adcf.entry.js +4 -0
- package/dist/types/components/datetime/datetime.d.ts +1 -0
- package/hydrate/index.js +70 -45
- package/hydrate/index.mjs +70 -45
- package/package.json +1 -1
- package/dist/ionic/p-4c09dde7.entry.js +0 -4
|
@@ -1071,6 +1071,10 @@ const Datetime = /*@__PURE__*/ proxyCustomElement(class Datetime extends HTMLEle
|
|
|
1071
1071
|
this.resizeObserver.disconnect();
|
|
1072
1072
|
this.resizeObserver = undefined;
|
|
1073
1073
|
}
|
|
1074
|
+
if (this.destroyOverlayListeners) {
|
|
1075
|
+
this.destroyOverlayListeners();
|
|
1076
|
+
this.destroyOverlayListeners = undefined;
|
|
1077
|
+
}
|
|
1074
1078
|
}
|
|
1075
1079
|
initializeListeners() {
|
|
1076
1080
|
this.initializeCalendarListener();
|
|
@@ -1085,52 +1089,73 @@ const Datetime = /*@__PURE__*/ proxyCustomElement(class Datetime extends HTMLEle
|
|
|
1085
1089
|
* visible if used inside of a modal or a popover otherwise the scrollable
|
|
1086
1090
|
* areas will not have the correct values snapped into place.
|
|
1087
1091
|
*
|
|
1088
|
-
* We use ResizeObserver to detect when the element transitions
|
|
1089
|
-
*
|
|
1090
|
-
*
|
|
1091
|
-
*
|
|
1092
|
+
* We use ResizeObserver to detect when the element transitions between
|
|
1093
|
+
* having dimensions (visible) and zero dimensions (hidden). This is more
|
|
1094
|
+
* reliable than IntersectionObserver for detecting visibility changes,
|
|
1095
|
+
* especially when the element is inside a modal or popover.
|
|
1092
1096
|
*/
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
const isVisible = width > 0 && height > 0;
|
|
1097
|
-
const isReady = el.classList.contains('datetime-ready');
|
|
1098
|
-
if (isVisible && !isReady) {
|
|
1099
|
-
this.initializeListeners();
|
|
1100
|
-
/**
|
|
1101
|
-
* TODO FW-2793: Datetime needs a frame to ensure that it
|
|
1102
|
-
* can properly scroll contents into view. As a result
|
|
1103
|
-
* we hide the scrollable content until after that frame
|
|
1104
|
-
* so users do not see the content quickly shifting. The downside
|
|
1105
|
-
* is that the content will pop into view a frame after. Maybe there
|
|
1106
|
-
* is a better way to handle this?
|
|
1107
|
-
*/
|
|
1108
|
-
writeTask(() => {
|
|
1109
|
-
el.classList.add('datetime-ready');
|
|
1110
|
-
});
|
|
1111
|
-
}
|
|
1112
|
-
else if (!isVisible && isReady) {
|
|
1113
|
-
/**
|
|
1114
|
-
* Clean up listeners when hidden so we can properly
|
|
1115
|
-
* reinitialize scroll positions on re-presentation.
|
|
1116
|
-
*/
|
|
1117
|
-
this.destroyInteractionListeners();
|
|
1118
|
-
/**
|
|
1119
|
-
* Close month/year picker when hidden, otherwise
|
|
1120
|
-
* it will be open when re-presented with a 0-height
|
|
1121
|
-
* scroll area, showing the wrong month.
|
|
1122
|
-
*/
|
|
1123
|
-
this.showMonthAndYear = false;
|
|
1124
|
-
writeTask(() => {
|
|
1125
|
-
el.classList.remove('datetime-ready');
|
|
1126
|
-
});
|
|
1097
|
+
const markReady = () => {
|
|
1098
|
+
if (el.classList.contains('datetime-ready')) {
|
|
1099
|
+
return;
|
|
1127
1100
|
}
|
|
1128
|
-
|
|
1101
|
+
this.initializeListeners();
|
|
1102
|
+
writeTask(() => {
|
|
1103
|
+
el.classList.add('datetime-ready');
|
|
1104
|
+
});
|
|
1105
|
+
};
|
|
1106
|
+
const markHidden = () => {
|
|
1107
|
+
this.destroyInteractionListeners();
|
|
1108
|
+
this.showMonthAndYear = false;
|
|
1109
|
+
writeTask(() => {
|
|
1110
|
+
el.classList.remove('datetime-ready');
|
|
1111
|
+
});
|
|
1112
|
+
};
|
|
1129
1113
|
/**
|
|
1130
|
-
*
|
|
1131
|
-
*
|
|
1114
|
+
* FW-6931: If datetime is inside a popover or modal, listen for the
|
|
1115
|
+
* overlay's present/dismiss events. This is more reliable than
|
|
1116
|
+
* ResizeObserver in some browsers (e.g., WebKit) where the observer
|
|
1117
|
+
* doesn't always fire when the overlay opens.
|
|
1132
1118
|
*/
|
|
1133
|
-
|
|
1119
|
+
const parentOverlay = el.closest('ion-modal, ion-popover');
|
|
1120
|
+
if (parentOverlay) {
|
|
1121
|
+
const handlePresent = () => markReady();
|
|
1122
|
+
const handleDismiss = () => markHidden();
|
|
1123
|
+
parentOverlay.addEventListener('didPresent', handlePresent);
|
|
1124
|
+
parentOverlay.addEventListener('didDismiss', handleDismiss);
|
|
1125
|
+
this.destroyOverlayListeners = () => {
|
|
1126
|
+
parentOverlay.removeEventListener('didPresent', handlePresent);
|
|
1127
|
+
parentOverlay.removeEventListener('didDismiss', handleDismiss);
|
|
1128
|
+
};
|
|
1129
|
+
}
|
|
1130
|
+
if (typeof ResizeObserver !== 'undefined') {
|
|
1131
|
+
this.resizeObserver = new ResizeObserver((entries) => {
|
|
1132
|
+
const entry = entries[0];
|
|
1133
|
+
const { width, height } = entry.contentRect;
|
|
1134
|
+
const isVisible = width > 0 && height > 0;
|
|
1135
|
+
const isReady = el.classList.contains('datetime-ready');
|
|
1136
|
+
if (isVisible && !isReady) {
|
|
1137
|
+
markReady();
|
|
1138
|
+
}
|
|
1139
|
+
else if (!isVisible && isReady) {
|
|
1140
|
+
markHidden();
|
|
1141
|
+
}
|
|
1142
|
+
});
|
|
1143
|
+
/**
|
|
1144
|
+
* Use raf to avoid a race condition between the component loading and
|
|
1145
|
+
* its display animation starting (such as when shown in a modal).
|
|
1146
|
+
*/
|
|
1147
|
+
raf(() => { var _a; return (_a = this.resizeObserver) === null || _a === void 0 ? void 0 : _a.observe(el); });
|
|
1148
|
+
}
|
|
1149
|
+
else {
|
|
1150
|
+
/**
|
|
1151
|
+
* Fallback for test environments where ResizeObserver is not available.
|
|
1152
|
+
* Just mark as ready without initializing scroll/keyboard listeners
|
|
1153
|
+
* since those also require browser APIs not available in Jest.
|
|
1154
|
+
*/
|
|
1155
|
+
writeTask(() => {
|
|
1156
|
+
el.classList.add('datetime-ready');
|
|
1157
|
+
});
|
|
1158
|
+
}
|
|
1134
1159
|
/**
|
|
1135
1160
|
* Datetime uses Ionic components that emit
|
|
1136
1161
|
* ionFocus and ionBlur. These events are
|
|
@@ -1859,7 +1884,7 @@ const Datetime = /*@__PURE__*/ proxyCustomElement(class Datetime extends HTMLEle
|
|
|
1859
1884
|
const hasDatePresentation = presentation === 'date' || presentation === 'date-time' || presentation === 'time-date';
|
|
1860
1885
|
const hasWheelVariant = hasDatePresentation && preferWheel;
|
|
1861
1886
|
renderHiddenInput(true, el, name, formatValue(value), disabled);
|
|
1862
|
-
return (h(Host, { key: '
|
|
1887
|
+
return (h(Host, { key: '5d01aefc3fc66ae90c4b1a85e0f804a3e7819c44', "aria-disabled": disabled ? 'true' : null, onFocus: this.onFocus, onBlur: this.onBlur, class: Object.assign({}, createColorClasses(color, {
|
|
1863
1888
|
[mode]: true,
|
|
1864
1889
|
['datetime-readonly']: readonly,
|
|
1865
1890
|
['datetime-disabled']: disabled,
|
|
@@ -1067,6 +1067,10 @@ const Datetime = class {
|
|
|
1067
1067
|
this.resizeObserver.disconnect();
|
|
1068
1068
|
this.resizeObserver = undefined;
|
|
1069
1069
|
}
|
|
1070
|
+
if (this.destroyOverlayListeners) {
|
|
1071
|
+
this.destroyOverlayListeners();
|
|
1072
|
+
this.destroyOverlayListeners = undefined;
|
|
1073
|
+
}
|
|
1070
1074
|
}
|
|
1071
1075
|
initializeListeners() {
|
|
1072
1076
|
this.initializeCalendarListener();
|
|
@@ -1081,52 +1085,73 @@ const Datetime = class {
|
|
|
1081
1085
|
* visible if used inside of a modal or a popover otherwise the scrollable
|
|
1082
1086
|
* areas will not have the correct values snapped into place.
|
|
1083
1087
|
*
|
|
1084
|
-
* We use ResizeObserver to detect when the element transitions
|
|
1085
|
-
*
|
|
1086
|
-
*
|
|
1087
|
-
*
|
|
1088
|
+
* We use ResizeObserver to detect when the element transitions between
|
|
1089
|
+
* having dimensions (visible) and zero dimensions (hidden). This is more
|
|
1090
|
+
* reliable than IntersectionObserver for detecting visibility changes,
|
|
1091
|
+
* especially when the element is inside a modal or popover.
|
|
1088
1092
|
*/
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
const isVisible = width > 0 && height > 0;
|
|
1093
|
-
const isReady = el.classList.contains('datetime-ready');
|
|
1094
|
-
if (isVisible && !isReady) {
|
|
1095
|
-
this.initializeListeners();
|
|
1096
|
-
/**
|
|
1097
|
-
* TODO FW-2793: Datetime needs a frame to ensure that it
|
|
1098
|
-
* can properly scroll contents into view. As a result
|
|
1099
|
-
* we hide the scrollable content until after that frame
|
|
1100
|
-
* so users do not see the content quickly shifting. The downside
|
|
1101
|
-
* is that the content will pop into view a frame after. Maybe there
|
|
1102
|
-
* is a better way to handle this?
|
|
1103
|
-
*/
|
|
1104
|
-
index.writeTask(() => {
|
|
1105
|
-
el.classList.add('datetime-ready');
|
|
1106
|
-
});
|
|
1107
|
-
}
|
|
1108
|
-
else if (!isVisible && isReady) {
|
|
1109
|
-
/**
|
|
1110
|
-
* Clean up listeners when hidden so we can properly
|
|
1111
|
-
* reinitialize scroll positions on re-presentation.
|
|
1112
|
-
*/
|
|
1113
|
-
this.destroyInteractionListeners();
|
|
1114
|
-
/**
|
|
1115
|
-
* Close month/year picker when hidden, otherwise
|
|
1116
|
-
* it will be open when re-presented with a 0-height
|
|
1117
|
-
* scroll area, showing the wrong month.
|
|
1118
|
-
*/
|
|
1119
|
-
this.showMonthAndYear = false;
|
|
1120
|
-
index.writeTask(() => {
|
|
1121
|
-
el.classList.remove('datetime-ready');
|
|
1122
|
-
});
|
|
1093
|
+
const markReady = () => {
|
|
1094
|
+
if (el.classList.contains('datetime-ready')) {
|
|
1095
|
+
return;
|
|
1123
1096
|
}
|
|
1124
|
-
|
|
1097
|
+
this.initializeListeners();
|
|
1098
|
+
index.writeTask(() => {
|
|
1099
|
+
el.classList.add('datetime-ready');
|
|
1100
|
+
});
|
|
1101
|
+
};
|
|
1102
|
+
const markHidden = () => {
|
|
1103
|
+
this.destroyInteractionListeners();
|
|
1104
|
+
this.showMonthAndYear = false;
|
|
1105
|
+
index.writeTask(() => {
|
|
1106
|
+
el.classList.remove('datetime-ready');
|
|
1107
|
+
});
|
|
1108
|
+
};
|
|
1125
1109
|
/**
|
|
1126
|
-
*
|
|
1127
|
-
*
|
|
1110
|
+
* FW-6931: If datetime is inside a popover or modal, listen for the
|
|
1111
|
+
* overlay's present/dismiss events. This is more reliable than
|
|
1112
|
+
* ResizeObserver in some browsers (e.g., WebKit) where the observer
|
|
1113
|
+
* doesn't always fire when the overlay opens.
|
|
1128
1114
|
*/
|
|
1129
|
-
|
|
1115
|
+
const parentOverlay = el.closest('ion-modal, ion-popover');
|
|
1116
|
+
if (parentOverlay) {
|
|
1117
|
+
const handlePresent = () => markReady();
|
|
1118
|
+
const handleDismiss = () => markHidden();
|
|
1119
|
+
parentOverlay.addEventListener('didPresent', handlePresent);
|
|
1120
|
+
parentOverlay.addEventListener('didDismiss', handleDismiss);
|
|
1121
|
+
this.destroyOverlayListeners = () => {
|
|
1122
|
+
parentOverlay.removeEventListener('didPresent', handlePresent);
|
|
1123
|
+
parentOverlay.removeEventListener('didDismiss', handleDismiss);
|
|
1124
|
+
};
|
|
1125
|
+
}
|
|
1126
|
+
if (typeof ResizeObserver !== 'undefined') {
|
|
1127
|
+
this.resizeObserver = new ResizeObserver((entries) => {
|
|
1128
|
+
const entry = entries[0];
|
|
1129
|
+
const { width, height } = entry.contentRect;
|
|
1130
|
+
const isVisible = width > 0 && height > 0;
|
|
1131
|
+
const isReady = el.classList.contains('datetime-ready');
|
|
1132
|
+
if (isVisible && !isReady) {
|
|
1133
|
+
markReady();
|
|
1134
|
+
}
|
|
1135
|
+
else if (!isVisible && isReady) {
|
|
1136
|
+
markHidden();
|
|
1137
|
+
}
|
|
1138
|
+
});
|
|
1139
|
+
/**
|
|
1140
|
+
* Use raf to avoid a race condition between the component loading and
|
|
1141
|
+
* its display animation starting (such as when shown in a modal).
|
|
1142
|
+
*/
|
|
1143
|
+
helpers.raf(() => { var _a; return (_a = this.resizeObserver) === null || _a === void 0 ? void 0 : _a.observe(el); });
|
|
1144
|
+
}
|
|
1145
|
+
else {
|
|
1146
|
+
/**
|
|
1147
|
+
* Fallback for test environments where ResizeObserver is not available.
|
|
1148
|
+
* Just mark as ready without initializing scroll/keyboard listeners
|
|
1149
|
+
* since those also require browser APIs not available in Jest.
|
|
1150
|
+
*/
|
|
1151
|
+
index.writeTask(() => {
|
|
1152
|
+
el.classList.add('datetime-ready');
|
|
1153
|
+
});
|
|
1154
|
+
}
|
|
1130
1155
|
/**
|
|
1131
1156
|
* Datetime uses Ionic components that emit
|
|
1132
1157
|
* ionFocus and ionBlur. These events are
|
|
@@ -1855,7 +1880,7 @@ const Datetime = class {
|
|
|
1855
1880
|
const hasDatePresentation = presentation === 'date' || presentation === 'date-time' || presentation === 'time-date';
|
|
1856
1881
|
const hasWheelVariant = hasDatePresentation && preferWheel;
|
|
1857
1882
|
helpers.renderHiddenInput(true, el, name, data.formatValue(value), disabled);
|
|
1858
|
-
return (index.h(index.Host, { key: '
|
|
1883
|
+
return (index.h(index.Host, { key: '5d01aefc3fc66ae90c4b1a85e0f804a3e7819c44', "aria-disabled": disabled ? 'true' : null, onFocus: this.onFocus, onBlur: this.onBlur, class: Object.assign({}, theme.createColorClasses(color, {
|
|
1859
1884
|
[mode]: true,
|
|
1860
1885
|
['datetime-readonly']: readonly,
|
|
1861
1886
|
['datetime-disabled']: disabled,
|
|
@@ -866,6 +866,10 @@ export class Datetime {
|
|
|
866
866
|
this.resizeObserver.disconnect();
|
|
867
867
|
this.resizeObserver = undefined;
|
|
868
868
|
}
|
|
869
|
+
if (this.destroyOverlayListeners) {
|
|
870
|
+
this.destroyOverlayListeners();
|
|
871
|
+
this.destroyOverlayListeners = undefined;
|
|
872
|
+
}
|
|
869
873
|
}
|
|
870
874
|
initializeListeners() {
|
|
871
875
|
this.initializeCalendarListener();
|
|
@@ -880,52 +884,73 @@ export class Datetime {
|
|
|
880
884
|
* visible if used inside of a modal or a popover otherwise the scrollable
|
|
881
885
|
* areas will not have the correct values snapped into place.
|
|
882
886
|
*
|
|
883
|
-
* We use ResizeObserver to detect when the element transitions
|
|
884
|
-
*
|
|
885
|
-
*
|
|
886
|
-
*
|
|
887
|
+
* We use ResizeObserver to detect when the element transitions between
|
|
888
|
+
* having dimensions (visible) and zero dimensions (hidden). This is more
|
|
889
|
+
* reliable than IntersectionObserver for detecting visibility changes,
|
|
890
|
+
* especially when the element is inside a modal or popover.
|
|
887
891
|
*/
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
const isVisible = width > 0 && height > 0;
|
|
892
|
-
const isReady = el.classList.contains('datetime-ready');
|
|
893
|
-
if (isVisible && !isReady) {
|
|
894
|
-
this.initializeListeners();
|
|
895
|
-
/**
|
|
896
|
-
* TODO FW-2793: Datetime needs a frame to ensure that it
|
|
897
|
-
* can properly scroll contents into view. As a result
|
|
898
|
-
* we hide the scrollable content until after that frame
|
|
899
|
-
* so users do not see the content quickly shifting. The downside
|
|
900
|
-
* is that the content will pop into view a frame after. Maybe there
|
|
901
|
-
* is a better way to handle this?
|
|
902
|
-
*/
|
|
903
|
-
writeTask(() => {
|
|
904
|
-
el.classList.add('datetime-ready');
|
|
905
|
-
});
|
|
906
|
-
}
|
|
907
|
-
else if (!isVisible && isReady) {
|
|
908
|
-
/**
|
|
909
|
-
* Clean up listeners when hidden so we can properly
|
|
910
|
-
* reinitialize scroll positions on re-presentation.
|
|
911
|
-
*/
|
|
912
|
-
this.destroyInteractionListeners();
|
|
913
|
-
/**
|
|
914
|
-
* Close month/year picker when hidden, otherwise
|
|
915
|
-
* it will be open when re-presented with a 0-height
|
|
916
|
-
* scroll area, showing the wrong month.
|
|
917
|
-
*/
|
|
918
|
-
this.showMonthAndYear = false;
|
|
919
|
-
writeTask(() => {
|
|
920
|
-
el.classList.remove('datetime-ready');
|
|
921
|
-
});
|
|
892
|
+
const markReady = () => {
|
|
893
|
+
if (el.classList.contains('datetime-ready')) {
|
|
894
|
+
return;
|
|
922
895
|
}
|
|
923
|
-
|
|
896
|
+
this.initializeListeners();
|
|
897
|
+
writeTask(() => {
|
|
898
|
+
el.classList.add('datetime-ready');
|
|
899
|
+
});
|
|
900
|
+
};
|
|
901
|
+
const markHidden = () => {
|
|
902
|
+
this.destroyInteractionListeners();
|
|
903
|
+
this.showMonthAndYear = false;
|
|
904
|
+
writeTask(() => {
|
|
905
|
+
el.classList.remove('datetime-ready');
|
|
906
|
+
});
|
|
907
|
+
};
|
|
924
908
|
/**
|
|
925
|
-
*
|
|
926
|
-
*
|
|
909
|
+
* FW-6931: If datetime is inside a popover or modal, listen for the
|
|
910
|
+
* overlay's present/dismiss events. This is more reliable than
|
|
911
|
+
* ResizeObserver in some browsers (e.g., WebKit) where the observer
|
|
912
|
+
* doesn't always fire when the overlay opens.
|
|
927
913
|
*/
|
|
928
|
-
|
|
914
|
+
const parentOverlay = el.closest('ion-modal, ion-popover');
|
|
915
|
+
if (parentOverlay) {
|
|
916
|
+
const handlePresent = () => markReady();
|
|
917
|
+
const handleDismiss = () => markHidden();
|
|
918
|
+
parentOverlay.addEventListener('didPresent', handlePresent);
|
|
919
|
+
parentOverlay.addEventListener('didDismiss', handleDismiss);
|
|
920
|
+
this.destroyOverlayListeners = () => {
|
|
921
|
+
parentOverlay.removeEventListener('didPresent', handlePresent);
|
|
922
|
+
parentOverlay.removeEventListener('didDismiss', handleDismiss);
|
|
923
|
+
};
|
|
924
|
+
}
|
|
925
|
+
if (typeof ResizeObserver !== 'undefined') {
|
|
926
|
+
this.resizeObserver = new ResizeObserver((entries) => {
|
|
927
|
+
const entry = entries[0];
|
|
928
|
+
const { width, height } = entry.contentRect;
|
|
929
|
+
const isVisible = width > 0 && height > 0;
|
|
930
|
+
const isReady = el.classList.contains('datetime-ready');
|
|
931
|
+
if (isVisible && !isReady) {
|
|
932
|
+
markReady();
|
|
933
|
+
}
|
|
934
|
+
else if (!isVisible && isReady) {
|
|
935
|
+
markHidden();
|
|
936
|
+
}
|
|
937
|
+
});
|
|
938
|
+
/**
|
|
939
|
+
* Use raf to avoid a race condition between the component loading and
|
|
940
|
+
* its display animation starting (such as when shown in a modal).
|
|
941
|
+
*/
|
|
942
|
+
raf(() => { var _a; return (_a = this.resizeObserver) === null || _a === void 0 ? void 0 : _a.observe(el); });
|
|
943
|
+
}
|
|
944
|
+
else {
|
|
945
|
+
/**
|
|
946
|
+
* Fallback for test environments where ResizeObserver is not available.
|
|
947
|
+
* Just mark as ready without initializing scroll/keyboard listeners
|
|
948
|
+
* since those also require browser APIs not available in Jest.
|
|
949
|
+
*/
|
|
950
|
+
writeTask(() => {
|
|
951
|
+
el.classList.add('datetime-ready');
|
|
952
|
+
});
|
|
953
|
+
}
|
|
929
954
|
/**
|
|
930
955
|
* Datetime uses Ionic components that emit
|
|
931
956
|
* ionFocus and ionBlur. These events are
|
|
@@ -1654,7 +1679,7 @@ export class Datetime {
|
|
|
1654
1679
|
const hasDatePresentation = presentation === 'date' || presentation === 'date-time' || presentation === 'time-date';
|
|
1655
1680
|
const hasWheelVariant = hasDatePresentation && preferWheel;
|
|
1656
1681
|
renderHiddenInput(true, el, name, formatValue(value), disabled);
|
|
1657
|
-
return (h(Host, { key: '
|
|
1682
|
+
return (h(Host, { key: '5d01aefc3fc66ae90c4b1a85e0f804a3e7819c44', "aria-disabled": disabled ? 'true' : null, onFocus: this.onFocus, onBlur: this.onBlur, class: Object.assign({}, createColorClasses(color, {
|
|
1658
1683
|
[mode]: true,
|
|
1659
1684
|
['datetime-readonly']: readonly,
|
|
1660
1685
|
['datetime-disabled']: disabled,
|
package/dist/docs.json
CHANGED
|
@@ -1065,6 +1065,10 @@ const Datetime = class {
|
|
|
1065
1065
|
this.resizeObserver.disconnect();
|
|
1066
1066
|
this.resizeObserver = undefined;
|
|
1067
1067
|
}
|
|
1068
|
+
if (this.destroyOverlayListeners) {
|
|
1069
|
+
this.destroyOverlayListeners();
|
|
1070
|
+
this.destroyOverlayListeners = undefined;
|
|
1071
|
+
}
|
|
1068
1072
|
}
|
|
1069
1073
|
initializeListeners() {
|
|
1070
1074
|
this.initializeCalendarListener();
|
|
@@ -1079,52 +1083,73 @@ const Datetime = class {
|
|
|
1079
1083
|
* visible if used inside of a modal or a popover otherwise the scrollable
|
|
1080
1084
|
* areas will not have the correct values snapped into place.
|
|
1081
1085
|
*
|
|
1082
|
-
* We use ResizeObserver to detect when the element transitions
|
|
1083
|
-
*
|
|
1084
|
-
*
|
|
1085
|
-
*
|
|
1086
|
+
* We use ResizeObserver to detect when the element transitions between
|
|
1087
|
+
* having dimensions (visible) and zero dimensions (hidden). This is more
|
|
1088
|
+
* reliable than IntersectionObserver for detecting visibility changes,
|
|
1089
|
+
* especially when the element is inside a modal or popover.
|
|
1086
1090
|
*/
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
const isVisible = width > 0 && height > 0;
|
|
1091
|
-
const isReady = el.classList.contains('datetime-ready');
|
|
1092
|
-
if (isVisible && !isReady) {
|
|
1093
|
-
this.initializeListeners();
|
|
1094
|
-
/**
|
|
1095
|
-
* TODO FW-2793: Datetime needs a frame to ensure that it
|
|
1096
|
-
* can properly scroll contents into view. As a result
|
|
1097
|
-
* we hide the scrollable content until after that frame
|
|
1098
|
-
* so users do not see the content quickly shifting. The downside
|
|
1099
|
-
* is that the content will pop into view a frame after. Maybe there
|
|
1100
|
-
* is a better way to handle this?
|
|
1101
|
-
*/
|
|
1102
|
-
writeTask(() => {
|
|
1103
|
-
el.classList.add('datetime-ready');
|
|
1104
|
-
});
|
|
1105
|
-
}
|
|
1106
|
-
else if (!isVisible && isReady) {
|
|
1107
|
-
/**
|
|
1108
|
-
* Clean up listeners when hidden so we can properly
|
|
1109
|
-
* reinitialize scroll positions on re-presentation.
|
|
1110
|
-
*/
|
|
1111
|
-
this.destroyInteractionListeners();
|
|
1112
|
-
/**
|
|
1113
|
-
* Close month/year picker when hidden, otherwise
|
|
1114
|
-
* it will be open when re-presented with a 0-height
|
|
1115
|
-
* scroll area, showing the wrong month.
|
|
1116
|
-
*/
|
|
1117
|
-
this.showMonthAndYear = false;
|
|
1118
|
-
writeTask(() => {
|
|
1119
|
-
el.classList.remove('datetime-ready');
|
|
1120
|
-
});
|
|
1091
|
+
const markReady = () => {
|
|
1092
|
+
if (el.classList.contains('datetime-ready')) {
|
|
1093
|
+
return;
|
|
1121
1094
|
}
|
|
1122
|
-
|
|
1095
|
+
this.initializeListeners();
|
|
1096
|
+
writeTask(() => {
|
|
1097
|
+
el.classList.add('datetime-ready');
|
|
1098
|
+
});
|
|
1099
|
+
};
|
|
1100
|
+
const markHidden = () => {
|
|
1101
|
+
this.destroyInteractionListeners();
|
|
1102
|
+
this.showMonthAndYear = false;
|
|
1103
|
+
writeTask(() => {
|
|
1104
|
+
el.classList.remove('datetime-ready');
|
|
1105
|
+
});
|
|
1106
|
+
};
|
|
1123
1107
|
/**
|
|
1124
|
-
*
|
|
1125
|
-
*
|
|
1108
|
+
* FW-6931: If datetime is inside a popover or modal, listen for the
|
|
1109
|
+
* overlay's present/dismiss events. This is more reliable than
|
|
1110
|
+
* ResizeObserver in some browsers (e.g., WebKit) where the observer
|
|
1111
|
+
* doesn't always fire when the overlay opens.
|
|
1126
1112
|
*/
|
|
1127
|
-
|
|
1113
|
+
const parentOverlay = el.closest('ion-modal, ion-popover');
|
|
1114
|
+
if (parentOverlay) {
|
|
1115
|
+
const handlePresent = () => markReady();
|
|
1116
|
+
const handleDismiss = () => markHidden();
|
|
1117
|
+
parentOverlay.addEventListener('didPresent', handlePresent);
|
|
1118
|
+
parentOverlay.addEventListener('didDismiss', handleDismiss);
|
|
1119
|
+
this.destroyOverlayListeners = () => {
|
|
1120
|
+
parentOverlay.removeEventListener('didPresent', handlePresent);
|
|
1121
|
+
parentOverlay.removeEventListener('didDismiss', handleDismiss);
|
|
1122
|
+
};
|
|
1123
|
+
}
|
|
1124
|
+
if (typeof ResizeObserver !== 'undefined') {
|
|
1125
|
+
this.resizeObserver = new ResizeObserver((entries) => {
|
|
1126
|
+
const entry = entries[0];
|
|
1127
|
+
const { width, height } = entry.contentRect;
|
|
1128
|
+
const isVisible = width > 0 && height > 0;
|
|
1129
|
+
const isReady = el.classList.contains('datetime-ready');
|
|
1130
|
+
if (isVisible && !isReady) {
|
|
1131
|
+
markReady();
|
|
1132
|
+
}
|
|
1133
|
+
else if (!isVisible && isReady) {
|
|
1134
|
+
markHidden();
|
|
1135
|
+
}
|
|
1136
|
+
});
|
|
1137
|
+
/**
|
|
1138
|
+
* Use raf to avoid a race condition between the component loading and
|
|
1139
|
+
* its display animation starting (such as when shown in a modal).
|
|
1140
|
+
*/
|
|
1141
|
+
raf(() => { var _a; return (_a = this.resizeObserver) === null || _a === void 0 ? void 0 : _a.observe(el); });
|
|
1142
|
+
}
|
|
1143
|
+
else {
|
|
1144
|
+
/**
|
|
1145
|
+
* Fallback for test environments where ResizeObserver is not available.
|
|
1146
|
+
* Just mark as ready without initializing scroll/keyboard listeners
|
|
1147
|
+
* since those also require browser APIs not available in Jest.
|
|
1148
|
+
*/
|
|
1149
|
+
writeTask(() => {
|
|
1150
|
+
el.classList.add('datetime-ready');
|
|
1151
|
+
});
|
|
1152
|
+
}
|
|
1128
1153
|
/**
|
|
1129
1154
|
* Datetime uses Ionic components that emit
|
|
1130
1155
|
* ionFocus and ionBlur. These events are
|
|
@@ -1853,7 +1878,7 @@ const Datetime = class {
|
|
|
1853
1878
|
const hasDatePresentation = presentation === 'date' || presentation === 'date-time' || presentation === 'time-date';
|
|
1854
1879
|
const hasWheelVariant = hasDatePresentation && preferWheel;
|
|
1855
1880
|
renderHiddenInput(true, el, name, formatValue(value), disabled);
|
|
1856
|
-
return (h(Host, { key: '
|
|
1881
|
+
return (h(Host, { key: '5d01aefc3fc66ae90c4b1a85e0f804a3e7819c44', "aria-disabled": disabled ? 'true' : null, onFocus: this.onFocus, onBlur: this.onBlur, class: Object.assign({}, createColorClasses(color, {
|
|
1857
1882
|
[mode]: true,
|
|
1858
1883
|
['datetime-readonly']: readonly,
|
|
1859
1884
|
['datetime-disabled']: disabled,
|