@ionic/react 9.0.15-dev.11796247574.1ecbe59d → 9.0.15-dev.11796248397.1d85e35e

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,7 +1,7 @@
1
1
  import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
2
2
  import React, { useContext, useRef, useEffect, createElement, useState, useMemo, Fragment as Fragment$1, useCallback } from 'react';
3
3
  import { getPlatforms as getPlatforms$1, isPlatform as isPlatform$1, componentOnReady, createAnimation, actionSheetController, alertController, toastController, modalController, popoverController, loadingController, initialize } from '@ionic/core/components';
4
- export { IonicSafeString, IonicSlides, LogLevel, componentOnReady, createAnimation, createGesture, getIonPageElement, getMode, getTimeGivenProgression, iosTransitionAnimation, mdTransitionAnimation, menuController, openURL, setNonce } from '@ionic/core/components';
4
+ export { IonicSafeString, IonicSlides, LogLevel, createAnimation, createGesture, getIonPageElement, getTimeGivenProgression, iosTransitionAnimation, mdTransitionAnimation, openURL } from '@ionic/core/components';
5
5
  import { createComponent } from '@stencil/react-output-target/runtime';
6
6
  import { defineCustomElement as defineCustomElement$2, IonAccordion as IonAccordion$1 } from '@ionic/core/components/ion-accordion.js';
7
7
  import { defineCustomElement as defineCustomElement$3, IonAccordionGroup as IonAccordionGroup$1 } from '@ionic/core/components/ion-accordion-group.js';
@@ -1372,6 +1372,11 @@ const IonItem = /*@__PURE__*/ createRoutingComponent('ion-item', IonItem$1);
1372
1372
  const IonItemOption = /*@__PURE__*/ createRoutingComponent('ion-item-option', IonItemOption$1);
1373
1373
  const IonBreadcrumb = /*@__PURE__*/ createRoutingComponent('ion-breadcrumb', IonBreadcrumb$1);
1374
1374
 
1375
+ const StackContext = React.createContext({
1376
+ registerIonPage: () => undefined,
1377
+ isInOutlet: () => false,
1378
+ });
1379
+
1375
1380
  /**
1376
1381
  * The @stencil/react-output-target will bind event listeners for any
1377
1382
  * attached props that use the `on` prefix. This function will remove
@@ -1417,6 +1422,15 @@ const detachEvent = (node, eventName) => {
1417
1422
  * React event-delegation root.
1418
1423
  */
1419
1424
  const NestedOverlayContext = React.createContext(false);
1425
+ /**
1426
+ * Stops an `IonPage` inside the overlay from registering with the enclosing
1427
+ * outlet, which would mistake it for the route's page. An outlet inside the
1428
+ * overlay provides its own.
1429
+ */
1430
+ const outsideOutletContext = {
1431
+ registerIonPage: () => undefined,
1432
+ isInOutlet: () => false,
1433
+ };
1420
1434
  /**
1421
1435
  * React skips `componentWillUnmount` when it destroys a subtree it had already
1422
1436
  * hidden, so a hidden overlay watches its own marker leave the document. One
@@ -1715,7 +1729,7 @@ const createInlineOverlayComponent = (tagName, defineCustomElement, hasDelegateH
1715
1729
  ? createElement('div', {
1716
1730
  ref: this.wrapperRef,
1717
1731
  className: getWrapperClasses(),
1718
- }, children)
1732
+ }, createElement(StackContext.Provider, { value: outsideOutletContext }, children))
1719
1733
  : null));
1720
1734
  // The marker sits at the JSX location on both branches and leaves the
1721
1735
  // document only on a real unmount, which is how `componentWillUnmount`
@@ -1978,11 +1992,6 @@ class IonApp extends React.Component {
1978
1992
  static displayName = 'IonApp';
1979
1993
  }
1980
1994
 
1981
- const StackContext = React.createContext({
1982
- registerIonPage: () => undefined,
1983
- isInOutlet: () => false,
1984
- });
1985
-
1986
1995
  class PageManager extends React.PureComponent {
1987
1996
  ionLifeCycleContext;
1988
1997
  ionPageElementRef;
@@ -2321,6 +2330,7 @@ class IonTabs extends React.Component {
2321
2330
  routerOutletRef = React.createRef();
2322
2331
  selectTabHandler;
2323
2332
  tabBarRef = React.createRef();
2333
+ tabsElRef = React.createRef();
2324
2334
  ionTabContextState = {
2325
2335
  activeTab: undefined,
2326
2336
  selectTab: () => false,
@@ -2337,7 +2347,12 @@ class IonTabs extends React.Component {
2337
2347
  super(props);
2338
2348
  }
2339
2349
  componentDidMount() {
2340
- if (this.tabBarRef.current) {
2350
+ /**
2351
+ * Without a router outlet, the tab bar does not switch tabs,
2352
+ * so its `selectTab` and active tab must not replace the ones
2353
+ * set for `ion-tabs` in `render`.
2354
+ */
2355
+ if (this.ionTabContextState.hasRouterOutlet && this.tabBarRef.current) {
2341
2356
  // Grab initial value
2342
2357
  this.ionTabContextState.activeTab = this.tabBarRef.current.state.activeTab;
2343
2358
  // Override method
@@ -2347,6 +2362,31 @@ class IonTabs extends React.Component {
2347
2362
  this.ionTabContextState.selectTab = this.tabBarRef.current.selectTab;
2348
2363
  }
2349
2364
  }
2365
+ /**
2366
+ * Selects a tab on `ion-tabs` when it is used without a router outlet.
2367
+ * Returns `false` when no `ion-tab` has the given `tab`.
2368
+ */
2369
+ selectTabWithoutRouter = (tab) => {
2370
+ const tabsEl = this.tabsElRef.current;
2371
+ if (!tabsEl) {
2372
+ return false;
2373
+ }
2374
+ const hasTab = Array.from(tabsEl.querySelectorAll('ion-tab')).some((tabEl) => tabEl.tab === tab);
2375
+ if (!hasTab) {
2376
+ return false;
2377
+ }
2378
+ tabsEl.select(tab);
2379
+ return true;
2380
+ };
2381
+ onTabsDidChangeWithoutRouter = (event) => {
2382
+ /**
2383
+ * A tab change without a router does not re-render anything, so the
2384
+ * context needs a new value and a re-render to update its consumers.
2385
+ */
2386
+ this.ionTabContextState = { ...this.ionTabContextState, activeTab: event.detail.tab };
2387
+ this.forceUpdate();
2388
+ this.props.onIonTabsDidChange?.(event);
2389
+ };
2350
2390
  renderTabsInner(children, outlet) {
2351
2391
  return (jsx(IonTabsInner, { ...this.props, children: React.Children.map(children, (child) => {
2352
2392
  if (React.isValidElement(child)) {
@@ -2422,7 +2462,14 @@ class IonTabs extends React.Component {
2422
2462
  throw new Error('IonTabs cannot contain an IonRouterOutlet and an IonTab at the same time');
2423
2463
  }
2424
2464
  if (hasTab) {
2425
- return jsx(IonTabsInner, { ...this.props });
2465
+ /**
2466
+ * Core `ion-tabs` switches tabs and emits the tab change events
2467
+ * itself, so the tab bar gets no change handlers. Otherwise they
2468
+ * would run a second time from the tab bar's click handler.
2469
+ */
2470
+ this.ionTabContextState.tabBarProps = { ref: this.tabBarRef };
2471
+ this.ionTabContextState.selectTab = this.selectTabWithoutRouter;
2472
+ return (jsx(IonTabsContext.Provider, { value: this.ionTabContextState, children: jsx(IonTabsInner, { ...this.props, ref: this.tabsElRef, onIonTabsDidChange: this.onTabsDidChangeWithoutRouter, children: children }) }));
2426
2473
  }
2427
2474
  /**
2428
2475
  * TODO(ROU-11051)
@@ -3157,6 +3204,7 @@ const RouteManagerContext = /*@__PURE__*/ React.createContext({
3157
3204
  findViewItemByRouteInfo: () => undefined,
3158
3205
  getChildrenToRender: () => undefined,
3159
3206
  getViewItemsForOutlet: () => [],
3207
+ getLocationHistoryPathnames: () => [],
3160
3208
  goBack: () => undefined,
3161
3209
  unMountViewItem: () => undefined,
3162
3210
  });
@@ -3357,6 +3405,13 @@ class LocationHistory {
3357
3405
  canGoBack() {
3358
3406
  return this.locationHistory.length > 1;
3359
3407
  }
3408
+ /**
3409
+ * Returns the pathname of every entry in global history, oldest first.
3410
+ * The current entry is last.
3411
+ */
3412
+ getPathnames() {
3413
+ return this.locationHistory.map((ri) => ri.pathname);
3414
+ }
3360
3415
  findTabForPathname(pathname) {
3361
3416
  for (const tab of Object.keys(this.tabHistory)) {
3362
3417
  const routeInfos = this.tabHistory[tab];