@ionic/react 7.4.4-dev.11696895407.1bd7a380 → 7.4.4-dev.11699471770.1b7273c4

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/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import React, { useContext, useRef, useEffect, createElement, useState, useMemo, Fragment, useCallback } from 'react';
2
2
  import { isPlatform as isPlatform$1, getPlatforms as getPlatforms$1, componentOnReady, createAnimation, actionSheetController, alertController, toastController, modalController, popoverController, pickerController, loadingController, initialize } from '@ionic/core/components';
3
- export { IonicSafeString, IonicSlides, createAnimation, createGesture, getIonPageElement, getTimeGivenProgression, iosTransitionAnimation, mdTransitionAnimation } from '@ionic/core/components';
3
+ export { IonicSafeString, IonicSlides, createAnimation, createGesture, getIonPageElement, getTimeGivenProgression, iosTransitionAnimation, mdTransitionAnimation, openURL } from '@ionic/core/components';
4
4
  import { __rest } from 'tslib';
5
5
  import ReactDOM, { createPortal } from 'react-dom';
6
6
  import { defineCustomElement as defineCustomElement$1 } from '@ionic/core/components/ion-accordion.js';
@@ -113,18 +113,6 @@ const IonLifeCycleContext = /*@__PURE__*/ React.createContext({
113
113
  ionViewDidLeave: () => {
114
114
  return;
115
115
  },
116
- cleanupIonViewWillEnter: () => {
117
- return;
118
- },
119
- cleanupIonViewDidEnter: () => {
120
- return;
121
- },
122
- cleanupIonViewWillLeave: () => {
123
- return;
124
- },
125
- cleanupIonViewDidLeave: () => {
126
- return;
127
- },
128
116
  });
129
117
  const DefaultIonLifeCycleContext = class {
130
118
  constructor() {
@@ -132,10 +120,6 @@ const DefaultIonLifeCycleContext = class {
132
120
  this.ionViewDidEnterCallbacks = [];
133
121
  this.ionViewWillLeaveCallbacks = [];
134
122
  this.ionViewDidLeaveCallbacks = [];
135
- this.ionViewWillEnterDestructorCallbacks = [];
136
- this.ionViewDidEnterDestructorCallbacks = [];
137
- this.ionViewWillLeaveDestructorCallbacks = [];
138
- this.ionViewDidLeaveDestructorCallbacks = [];
139
123
  }
140
124
  onIonViewWillEnter(callback) {
141
125
  if (callback.id) {
@@ -151,71 +135,8 @@ const DefaultIonLifeCycleContext = class {
151
135
  this.ionViewWillEnterCallbacks.push(callback);
152
136
  }
153
137
  }
154
- teardownCallback(callback, callbacks) {
155
- // Find any destructors that have been registered for the callback
156
- const matches = callbacks.filter((x) => x.id === callback.id);
157
- if (matches.length !== 0) {
158
- // Execute the destructor for each matching item
159
- matches.forEach((match) => {
160
- if (match && typeof match.destructor === 'function') {
161
- match.destructor();
162
- }
163
- });
164
- // Remove all matching items from the array
165
- callbacks = callbacks.filter((x) => x.id !== callback.id);
166
- }
167
- else {
168
- /**
169
- * If the destructor isn't registered in the array, then the
170
- * user-provided callback was never invoked. This is usually
171
- * the result of the useEffect hook in dev mode. So we manually
172
- * invoke the callback to get the destructor to tear it down.
173
- */
174
- const destructor = callback();
175
- if (typeof destructor === 'function') {
176
- destructor();
177
- }
178
- }
179
- }
180
- /**
181
- * Tears down the user-provided ionViewWillEnter lifecycle callback.
182
- * This is the same behavior as React's useEffect hook. The callback
183
- * is invoked when the component is unmounted.
184
- */
185
- cleanupIonViewWillEnter(callback) {
186
- this.teardownCallback(callback, this.ionViewWillEnterDestructorCallbacks);
187
- }
188
- /**
189
- * Tears down the user-provided ionViewDidEnter lifecycle callback.
190
- * This is the same behavior as React's useEffect hook. The callback
191
- * is invoked when the component is unmounted.
192
- */
193
- cleanupIonViewDidEnter(callback) {
194
- this.teardownCallback(callback, this.ionViewDidEnterDestructorCallbacks);
195
- }
196
- /**
197
- * Tears down the user-provided ionViewWillLeave lifecycle callback.
198
- * This is the same behavior as React's useEffect hook. The callback
199
- * is invoked when the component is unmounted.
200
- */
201
- cleanupIonViewWillLeave(callback) {
202
- this.teardownCallback(callback, this.ionViewWillLeaveDestructorCallbacks);
203
- }
204
- /**
205
- * Tears down the user-provided ionViewDidLeave lifecycle callback.
206
- * This is the same behavior as React's useEffect hook. The callback
207
- * is invoked when the component is unmounted.
208
- */
209
- cleanupIonViewDidLeave(callback) {
210
- this.teardownCallback(callback, this.ionViewDidLeaveDestructorCallbacks);
211
- }
212
138
  ionViewWillEnter() {
213
- this.ionViewWillEnterCallbacks.forEach((cb) => {
214
- const destructor = cb();
215
- if (cb.id) {
216
- this.ionViewWillEnterDestructorCallbacks.push({ id: cb.id, destructor });
217
- }
218
- });
139
+ this.ionViewWillEnterCallbacks.forEach((cb) => cb());
219
140
  }
220
141
  onIonViewDidEnter(callback) {
221
142
  if (callback.id) {
@@ -232,12 +153,7 @@ const DefaultIonLifeCycleContext = class {
232
153
  }
233
154
  }
234
155
  ionViewDidEnter() {
235
- this.ionViewDidEnterCallbacks.forEach((cb) => {
236
- const destructor = cb();
237
- if (cb.id) {
238
- this.ionViewDidEnterDestructorCallbacks.push({ id: cb.id, destructor });
239
- }
240
- });
156
+ this.ionViewDidEnterCallbacks.forEach((cb) => cb());
241
157
  }
242
158
  onIonViewWillLeave(callback) {
243
159
  if (callback.id) {
@@ -254,12 +170,7 @@ const DefaultIonLifeCycleContext = class {
254
170
  }
255
171
  }
256
172
  ionViewWillLeave() {
257
- this.ionViewWillLeaveCallbacks.forEach((cb) => {
258
- const destructor = cb();
259
- if (cb.id) {
260
- this.ionViewWillLeaveDestructorCallbacks.push({ id: cb.id, destructor });
261
- }
262
- });
173
+ this.ionViewWillLeaveCallbacks.forEach((cb) => cb());
263
174
  }
264
175
  onIonViewDidLeave(callback) {
265
176
  if (callback.id) {
@@ -276,12 +187,7 @@ const DefaultIonLifeCycleContext = class {
276
187
  }
277
188
  }
278
189
  ionViewDidLeave() {
279
- this.ionViewDidLeaveCallbacks.forEach((cb) => {
280
- const destructor = cb();
281
- if (cb.id) {
282
- this.ionViewDidLeaveDestructorCallbacks.push({ id: cb.id, destructor });
283
- }
284
- });
190
+ this.ionViewDidLeaveCallbacks.forEach((cb) => cb());
285
191
  this.componentCanBeDestroyed();
286
192
  }
287
193
  onComponentCanBeDestroyed(callback) {
@@ -340,9 +246,6 @@ const useIonViewWillEnter = (callback, deps = []) => {
340
246
  useEffect(() => {
341
247
  callback.id = id.current;
342
248
  context.onIonViewWillEnter(callback);
343
- return () => {
344
- context.cleanupIonViewWillEnter(callback);
345
- };
346
249
  }, deps);
347
250
  };
348
251
  const useIonViewDidEnter = (callback, deps = []) => {
@@ -352,9 +255,6 @@ const useIonViewDidEnter = (callback, deps = []) => {
352
255
  useEffect(() => {
353
256
  callback.id = id.current;
354
257
  context.onIonViewDidEnter(callback);
355
- return () => {
356
- context.cleanupIonViewDidEnter(callback);
357
- };
358
258
  }, deps);
359
259
  };
360
260
  const useIonViewWillLeave = (callback, deps = []) => {
@@ -364,9 +264,6 @@ const useIonViewWillLeave = (callback, deps = []) => {
364
264
  useEffect(() => {
365
265
  callback.id = id.current;
366
266
  context.onIonViewWillLeave(callback);
367
- return () => {
368
- context.cleanupIonViewWillLeave(callback);
369
- };
370
267
  }, deps);
371
268
  };
372
269
  const useIonViewDidLeave = (callback, deps = []) => {
@@ -376,9 +273,6 @@ const useIonViewDidLeave = (callback, deps = []) => {
376
273
  useEffect(() => {
377
274
  callback.id = id.current;
378
275
  context.onIonViewDidLeave(callback);
379
- return () => {
380
- context.cleanupIonViewDidLeave(callback);
381
- };
382
276
  }, deps);
383
277
  };
384
278
 
@@ -1126,16 +1020,6 @@ class PageManager extends React.PureComponent {
1126
1020
  this.ionPageElementRef = React.createRef();
1127
1021
  // React refs must be stable (not created inline).
1128
1022
  this.stableMergedRefs = mergeRefs(this.ionPageElementRef, this.props.forwardedRef);
1129
- /**
1130
- * This binds the scope of the following methods to the class scope.
1131
- * The `.bind` method returns a new function, so we need to assign it
1132
- * in the constructor to avoid creating a new function when removing the
1133
- * event listeners.
1134
- */
1135
- this.ionViewWillEnterHandler = this.ionViewWillEnterHandler.bind(this);
1136
- this.ionViewDidEnterHandler = this.ionViewDidEnterHandler.bind(this);
1137
- this.ionViewWillLeaveHandler = this.ionViewWillLeaveHandler.bind(this);
1138
- this.ionViewDidLeaveHandler = this.ionViewDidLeaveHandler.bind(this);
1139
1023
  }
1140
1024
  componentDidMount() {
1141
1025
  if (this.ionPageElementRef.current) {
@@ -1143,18 +1027,18 @@ class PageManager extends React.PureComponent {
1143
1027
  this.ionPageElementRef.current.classList.add('ion-page-invisible');
1144
1028
  }
1145
1029
  this.context.registerIonPage(this.ionPageElementRef.current, this.props.routeInfo);
1146
- this.ionPageElementRef.current.addEventListener('ionViewWillEnter', this.ionViewWillEnterHandler);
1147
- this.ionPageElementRef.current.addEventListener('ionViewDidEnter', this.ionViewDidEnterHandler);
1148
- this.ionPageElementRef.current.addEventListener('ionViewWillLeave', this.ionViewWillLeaveHandler);
1149
- this.ionPageElementRef.current.addEventListener('ionViewDidLeave', this.ionViewDidLeaveHandler);
1030
+ this.ionPageElementRef.current.addEventListener('ionViewWillEnter', this.ionViewWillEnterHandler.bind(this));
1031
+ this.ionPageElementRef.current.addEventListener('ionViewDidEnter', this.ionViewDidEnterHandler.bind(this));
1032
+ this.ionPageElementRef.current.addEventListener('ionViewWillLeave', this.ionViewWillLeaveHandler.bind(this));
1033
+ this.ionPageElementRef.current.addEventListener('ionViewDidLeave', this.ionViewDidLeaveHandler.bind(this));
1150
1034
  }
1151
1035
  }
1152
1036
  componentWillUnmount() {
1153
1037
  if (this.ionPageElementRef.current) {
1154
- this.ionPageElementRef.current.removeEventListener('ionViewWillEnter', this.ionViewWillEnterHandler);
1155
- this.ionPageElementRef.current.removeEventListener('ionViewDidEnter', this.ionViewDidEnterHandler);
1156
- this.ionPageElementRef.current.removeEventListener('ionViewWillLeave', this.ionViewWillLeaveHandler);
1157
- this.ionPageElementRef.current.removeEventListener('ionViewDidLeave', this.ionViewDidLeaveHandler);
1038
+ this.ionPageElementRef.current.removeEventListener('ionViewWillEnter', this.ionViewWillEnterHandler.bind(this));
1039
+ this.ionPageElementRef.current.removeEventListener('ionViewDidEnter', this.ionViewDidEnterHandler.bind(this));
1040
+ this.ionPageElementRef.current.removeEventListener('ionViewWillLeave', this.ionViewWillLeaveHandler.bind(this));
1041
+ this.ionPageElementRef.current.removeEventListener('ionViewDidLeave', this.ionViewDidLeaveHandler.bind(this));
1158
1042
  }
1159
1043
  }
1160
1044
  ionViewWillEnterHandler() {
@@ -1263,16 +1147,6 @@ class OutletPageManager extends React.Component {
1263
1147
  constructor(props) {
1264
1148
  super(props);
1265
1149
  this.outletIsReady = false;
1266
- /**
1267
- * This binds the scope of the following methods to the class scope.
1268
- * The `.bind` method returns a new function, so we need to assign it
1269
- * in the constructor to avoid creating a new function when removing the
1270
- * event listeners.
1271
- */
1272
- this.ionViewWillEnterHandler = this.ionViewWillEnterHandler.bind(this);
1273
- this.ionViewDidEnterHandler = this.ionViewDidEnterHandler.bind(this);
1274
- this.ionViewWillLeaveHandler = this.ionViewWillLeaveHandler.bind(this);
1275
- this.ionViewDidLeaveHandler = this.ionViewDidLeaveHandler.bind(this);
1276
1150
  }
1277
1151
  componentDidMount() {
1278
1152
  if (this.ionRouterOutlet) {
@@ -1286,18 +1160,18 @@ class OutletPageManager extends React.Component {
1286
1160
  this.context.registerIonPage(this.ionRouterOutlet, this.props.routeInfo);
1287
1161
  });
1288
1162
  }
1289
- this.ionRouterOutlet.addEventListener('ionViewWillEnter', this.ionViewWillEnterHandler);
1290
- this.ionRouterOutlet.addEventListener('ionViewDidEnter', this.ionViewDidEnterHandler);
1291
- this.ionRouterOutlet.addEventListener('ionViewWillLeave', this.ionViewWillLeaveHandler);
1292
- this.ionRouterOutlet.addEventListener('ionViewDidLeave', this.ionViewDidLeaveHandler);
1163
+ this.ionRouterOutlet.addEventListener('ionViewWillEnter', this.ionViewWillEnterHandler.bind(this));
1164
+ this.ionRouterOutlet.addEventListener('ionViewDidEnter', this.ionViewDidEnterHandler.bind(this));
1165
+ this.ionRouterOutlet.addEventListener('ionViewWillLeave', this.ionViewWillLeaveHandler.bind(this));
1166
+ this.ionRouterOutlet.addEventListener('ionViewDidLeave', this.ionViewDidLeaveHandler.bind(this));
1293
1167
  }
1294
1168
  }
1295
1169
  componentWillUnmount() {
1296
1170
  if (this.ionRouterOutlet) {
1297
- this.ionRouterOutlet.removeEventListener('ionViewWillEnter', this.ionViewWillEnterHandler);
1298
- this.ionRouterOutlet.removeEventListener('ionViewDidEnter', this.ionViewDidEnterHandler);
1299
- this.ionRouterOutlet.removeEventListener('ionViewWillLeave', this.ionViewWillLeaveHandler);
1300
- this.ionRouterOutlet.removeEventListener('ionViewDidLeave', this.ionViewDidLeaveHandler);
1171
+ this.ionRouterOutlet.removeEventListener('ionViewWillEnter', this.ionViewWillEnterHandler.bind(this));
1172
+ this.ionRouterOutlet.removeEventListener('ionViewDidEnter', this.ionViewDidEnterHandler.bind(this));
1173
+ this.ionRouterOutlet.removeEventListener('ionViewWillLeave', this.ionViewWillLeaveHandler.bind(this));
1174
+ this.ionRouterOutlet.removeEventListener('ionViewDidLeave', this.ionViewDidLeaveHandler.bind(this));
1301
1175
  }
1302
1176
  }
1303
1177
  ionViewWillEnterHandler() {