diff --git a/.gitignore b/.gitignore index 71e2c8eba4d..a1ae05b6ea1 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,4 @@ yarn-debug.log* yarn-error.log* static/**/node_modules/ +.idea diff --git a/cspell-wordlist.txt b/cspell-wordlist.txt index bf433d7615a..96a53460ab9 100644 --- a/cspell-wordlist.txt +++ b/cspell-wordlist.txt @@ -13,6 +13,7 @@ Udemy Vetur Wistia WCAG +CDK actionsheet fabs diff --git a/docs/angular/overlays.md b/docs/angular/overlays.md new file mode 100644 index 00000000000..2e4335effcd --- /dev/null +++ b/docs/angular/overlays.md @@ -0,0 +1,213 @@ +--- +title: Overlay Components +sidebar_label: Overlays +--- + + + Angular Overlay Components: Modals, Popovers with Custom Injectors + + + +Ionic provides overlay components such as modals and popovers that display content on top of your application. In Angular, these overlays can be created using controllers like `ModalController` and `PopoverController`. + +## Creating Overlays + +Overlays can be created programmatically using their respective controllers: + +```typescript +import { Component } from '@angular/core'; +import { ModalController } from '@ionic/angular/standalone'; +import { MyModalComponent } from './my-modal.component'; + +@Component({ + selector: 'app-home', + templateUrl: './home.component.html', +}) +export class HomeComponent { + constructor(private modalController: ModalController) {} + + async openModal() { + const modal = await this.modalController.create({ + component: MyModalComponent, + componentProps: { + title: 'My Modal', + }, + }); + await modal.present(); + } +} +``` + +## Custom Injectors + +By default, overlay components use the root injector for dependency injection. This means that services or tokens provided at the route level or within a specific component tree are not accessible inside the overlay. + +The `injector` option allows you to pass a custom Angular `Injector` when creating a modal or popover. This enables overlay components to access services and tokens that are not available in the root injector. + +### Use Cases + +Custom injectors are useful when you need to: + +- Access route-scoped services from within an overlay +- Use Angular CDK's `Dir` directive for bidirectional text support +- Access any providers that are not registered at the root level + +### Usage + +To use a custom injector, pass it to the `create()` method: + +```typescript +import { Component, Injector } from '@angular/core'; +import { ModalController } from '@ionic/angular/standalone'; +import { MyModalComponent } from './my-modal.component'; +import { MyRouteService } from './my-route.service'; + +@Component({ + selector: 'app-feature', + templateUrl: './feature.component.html', + providers: [MyRouteService], // Service provided at route level +}) +export class FeatureComponent { + constructor(private modalController: ModalController, private injector: Injector) {} + + async openModal() { + const modal = await this.modalController.create({ + component: MyModalComponent, + injector: this.injector, // Pass the component's injector + }); + await modal.present(); + } +} +``` + +The modal component can now inject `MyRouteService`: + +```typescript +import { Component, inject } from '@angular/core'; +import { MyRouteService } from '../my-route.service'; + +@Component({ + selector: 'app-my-modal', + templateUrl: './my-modal.component.html', +}) +export class MyModalComponent { + private myRouteService = inject(MyRouteService); +} +``` + +### Creating a Custom Injector + +You can also create a custom injector with specific providers: + +```typescript +import { Component, Injector } from '@angular/core'; +import { ModalController } from '@ionic/angular/standalone'; +import { MyModalComponent } from './my-modal.component'; +import { MyService } from './my.service'; + +@Component({ + selector: 'app-feature', + templateUrl: './feature.component.html', +}) +export class FeatureComponent { + constructor(private modalController: ModalController, private injector: Injector) {} + + async openModal() { + const myService = new MyService(); + myService.configure({ someOption: true }); + + const customInjector = Injector.create({ + providers: [{ provide: MyService, useValue: myService }], + parent: this.injector, + }); + + const modal = await this.modalController.create({ + component: MyModalComponent, + injector: customInjector, + }); + await modal.present(); + } +} +``` + +### Using with Angular CDK Directionality + +A common use case is providing the Angular CDK `Dir` directive to overlays for bidirectional text support: + +```typescript +import { Component, Injector } from '@angular/core'; +import { Dir } from '@angular/cdk/bidi'; +import { ModalController } from '@ionic/angular/standalone'; +import { MyModalComponent } from './my-modal.component'; + +@Component({ + selector: 'app-feature', + templateUrl: './feature.component.html', +}) +export class FeatureComponent { + constructor(private modalController: ModalController, private injector: Injector) {} + + async openModal() { + const modal = await this.modalController.create({ + component: MyModalComponent, + injector: this.injector, // Includes Dir from component tree + }); + await modal.present(); + } +} +``` + +### Popover Controller + +The `PopoverController` supports the same `injector` option: + +```typescript +import { Component, Injector } from '@angular/core'; +import { PopoverController } from '@ionic/angular/standalone'; +import { MyPopoverComponent } from './my-popover.component'; + +@Component({ + selector: 'app-feature', + templateUrl: './feature.component.html', +}) +export class FeatureComponent { + constructor(private popoverController: PopoverController, private injector: Injector) {} + + async openPopover(event: Event) { + const popover = await this.popoverController.create({ + component: MyPopoverComponent, + event: event, + injector: this.injector, + }); + await popover.present(); + } +} +``` + +## Angular Options Types + +Ionic Angular exports its own `ModalOptions` and `PopoverOptions` types that extend the core options with Angular-specific properties like `injector`: + +- `ModalOptions` - Extends core `ModalOptions` with the `injector` property +- `PopoverOptions` - Extends core `PopoverOptions` with the `injector` property + +These types are exported from `@ionic/angular` and `@ionic/angular/standalone`: + +```typescript +import type { ModalOptions, PopoverOptions } from '@ionic/angular/standalone'; +``` + +## Docs for Overlays in Ionic + +For full docs and to see usage examples, visit the docs page for each of the overlays in Ionic: + +- [Action Sheet](https://ionicframework.com/docs/api/action-sheet) +- [Alert](https://ionicframework.com/docs/api/alert) +- [Loading](https://ionicframework.com/docs/api/loading) +- [Modal](https://ionicframework.com/docs/api/modal) +- [Picker](https://ionicframework.com/docs/api/picker) +- [Popover](https://ionicframework.com/docs/api/popover) +- [Toast](https://ionicframework.com/docs/api/toast) diff --git a/docs/api/datetime.md b/docs/api/datetime.md index fae0603a238..f023185c8d1 100644 --- a/docs/api/datetime.md +++ b/docs/api/datetime.md @@ -41,7 +41,9 @@ import ShowAdjacentDays from '@site/static/usage/v9/datetime/show-adjacent-days/ import MultipleDateSelection from '@site/static/usage/v9/datetime/multiple/index.md'; import GlobalTheming from '@site/static/usage/v9/datetime/styling/global-theming/index.md'; +import CalendarHeaderStyling from '@site/static/usage/v9/datetime/styling/calendar-header/index.md'; import CalendarDaysStyling from '@site/static/usage/v9/datetime/styling/calendar-days/index.md'; +import DatetimeHeaderStyling from '@site/static/usage/v9/datetime/styling/datetime-header/index.md'; import WheelStyling from '@site/static/usage/v9/datetime/styling/wheel-styling/index.md'; @@ -352,6 +354,24 @@ The benefit of this approach is that every component, not just `ion-datetime`, c +### Datetime Header + +The datetime header manages the content for the `title` slot and the selected date. + +:::note +The selected date will not render if `preferWheel` is set to `true`. +::: + + + +### Calender Header + +The calendar header manages the date navigation controls (month/year picker and prev/next buttons) and the days of the week when using a grid style layout. + +The header can be styled using CSS shadow parts. + + + ### Calendar Days The calendar days in a grid-style `ion-datetime` can be styled using CSS shadow parts. diff --git a/docs/api/modal.md b/docs/api/modal.md index 5695cfbc580..1182f2e35c6 100644 --- a/docs/api/modal.md +++ b/docs/api/modal.md @@ -210,6 +210,26 @@ A few things to keep in mind when creating custom dialogs: * `ion-content` is intended to be used in full-page modals, cards, and sheets. If your custom dialog has a dynamic or unknown size, `ion-content` should not be used. * Creating custom dialogs provides a way of ejecting from the default modal experience. As a result, custom dialogs should not be used with card or sheet modals. +## Event Handling + +### Using `ionDragStart` and `ionDragEnd` + +The `ionDragStart` event is emitted as soon as the user begins a dragging gesture on the modal. This event fires at the moment the user initiates contact with the handle or modal surface, before any actual displacement occurs. It is particularly useful for preparing the interface for a transition, such as hiding certain interactive elements (like headers or buttons) to ensure a smooth dragging experience. + +The `ionDragEnd` event is emitted when the user completes the dragging gesture by releasing the modal. Like the move event, it includes the final [`ModalDragEventDetail`](#modaldrageventdetail) object. This event is commonly used to finalize state changes once the modal has come to a rest. + +import DragStartEndEvents from '@site/static/usage/v8/modal/drag-start-end-events/index.md'; + + + +### Using `ionDragMove` + +The `ionDragMove` event is emitted continuously while the user is actively dragging the modal. This event provides a [`ModalDragEventDetail`](#modaldrageventdetail) object containing real-time data, essential for creating highly responsive UI updates that react instantly to the user's touch. For example, the `progress` value can be used to dynamically darken a header's opacity as the modal is dragged upward. + +import DragMoveEvent from '@site/static/usage/v8/modal/drag-move-event/index.md'; + + + ## Interfaces ### ModalOptions @@ -251,6 +271,59 @@ interface ModalCustomEvent extends CustomEvent { } ``` +### ModalDragEventDetail + +When using the `ionDragMove` and `ionDragEnd` events, the event detail contains the following properties: + +```typescript +interface ModalDragEventDetail { + /** + * The current Y position of the modal. + * + * This can be used to determine how far the modal has been dragged. + */ + currentY: number; + /** + * The change in Y position since the gesture started. + * + * This can be used to determine the direction of the drag. + */ + deltaY: number; + /** + * The velocity of the drag in the Y direction. + * + * This can be used to determine how fast the modal is being dragged. + */ + velocityY: number; + /** + * A number between 0 and 1. + * + * In a sheet modal, progress represents the relative position between + * the lowest and highest defined breakpoints. + * + * In a card modal, it measures the relative position between the + * bottom of the screen and the top of the modal when it is fully + * open. + * + * This can be used to style content based on how far the modal has + * been dragged. + */ + progress: number; + /** + * If the modal is a sheet modal, this will be the breakpoint that + * the modal will snap to if the user lets go of the modal at the + * current moment. + * + * If it's a card modal, this property will not be included in the + * event payload. + * + * This can be used to style content based on where the modal will + * snap to upon release. + */ + snapBreakpoint?: number; +} +``` + ## Accessibility ### Keyboard Interactions diff --git a/docs/api/range.md b/docs/api/range.md index 8dfec042426..3be1f6e6ea5 100644 --- a/docs/api/range.md +++ b/docs/api/range.md @@ -124,6 +124,8 @@ import CSSProps from '@site/static/usage/v9/range/theming/css-properties/index.m Range includes [CSS Shadow Parts](#css-shadow-parts) to allow complete customization of specific element nodes within the Range component. CSS Shadow Parts offer the most customization capabilities and are the recommended approach when requiring advance styling with the Range component. +When `dualKnobs` is enabled, additional Shadow Parts are exposed to allow each knob to be styled independently. These are available in two forms: **static identity parts** (`A` and `B`) and **dynamic position parts** (`lower` and `upper`). The A and B parts always refer to the same physical knobs, even if the knobs cross. In contrast, the lower and upper parts reflect the current value position and automatically swap if the knobs cross. This allows styling by consistent identity or by relative value within the range. + import CSSParts from '@site/static/usage/v9/range/theming/css-shadow-parts/index.md'; diff --git a/docs/api/refresher.md b/docs/api/refresher.md index 15c2abe8e49..691226fbe92 100644 --- a/docs/api/refresher.md +++ b/docs/api/refresher.md @@ -73,10 +73,10 @@ Developers should apply the following CSS to the scrollable container. This CSS .ion-content-scroll-host::before, .ion-content-scroll-host::after { position: absolute; - + width: 1px; height: 1px; - + content: ""; } @@ -102,6 +102,17 @@ import Advanced from '@site/static/usage/v9/refresher/advanced/index.md'; +## Event Handling + +### Using `ionPullStart` and `ionPullEnd` + +The `ionPullStart` event is emitted when the user begins a pull gesture. This event fires when the user starts to pull the refresher down. + +The `ionPullEnd` event is emitted when the refresher returns to an inactive state, with a reason property of `'complete'` or `'cancel'` indicating whether the refresh operation completed successfully or was canceled. + +import PullStartEndEvents from '@site/static/usage/v8/refresher/pull-start-end-events/index.md'; + + ## Interfaces @@ -113,6 +124,14 @@ interface RefresherEventDetail { } ``` +### RefresherPullEndEventDetail + +```typescript +interface RefresherPullEndEventDetail { + reason: 'complete' | 'cancel'; +} +``` + ### RefresherCustomEvent While not required, this interface can be used in place of the `CustomEvent` interface for stronger typing with Ionic events emitted from this component. @@ -124,6 +143,17 @@ interface RefresherCustomEvent extends CustomEvent { } ``` +### RefresherPullEndCustomEvent + +While not required, this interface can be used in place of the `CustomEvent` interface for stronger typing with the `ionPullEnd` event. + +```typescript +interface RefresherPullEndCustomEvent extends CustomEvent { + detail: RefresherPullEndEventDetail; + target: HTMLIonRefresherElement; +} +``` + ## Properties diff --git a/docs/layout/dynamic-font-scaling.md b/docs/layout/dynamic-font-scaling.md index 2ea1054851e..edc1af0ba92 100644 --- a/docs/layout/dynamic-font-scaling.md +++ b/docs/layout/dynamic-font-scaling.md @@ -67,7 +67,6 @@ However, the `em` unit has a compounding effect which can cause issues. In the f
Child element with 80px
-```
Parent element with 20px @@ -76,6 +75,7 @@ However, the `em` unit has a compounding effect which can cause issues. In the f
Child element with 80px
+``` Due to this compounding effect, we strongly recommend using `rem` units instead of `em` units when working with Dynamic Font Scaling. `rem` units set the font size of an element relative to the font size of the root element, which is typically ``. The default font size of the root element is typically `16px`. diff --git a/docs/react/navigation.md b/docs/react/navigation.md index 0941f148f5e..6b1d0515cd6 100644 --- a/docs/react/navigation.md +++ b/docs/react/navigation.md @@ -117,6 +117,8 @@ const DashboardPage: React.FC = () => ( The `IonPage` component wraps each view in an Ionic React app and allows page transitions and stack navigation to work properly. Each view that is navigated to using the router must include an `IonPage` component. +`IonPage` is also required for proper styling. It provides a flex container that ensures page content, such as `IonContent`, is properly sized and does not overlap other UI elements like `IonTabBar`. + ```tsx import { IonContent, IonHeader, IonPage, IonTitle, IonToolbar } from '@ionic/react'; import React from 'react'; diff --git a/docs/vue/navigation.md b/docs/vue/navigation.md index b77a19ba7e1..6f6afa3575f 100644 --- a/docs/vue/navigation.md +++ b/docs/vue/navigation.md @@ -494,6 +494,8 @@ Nothing should be provided inside of `IonRouterOutlet` when setting it up in you The `IonPage` component wraps each view in an Ionic Vue app and allows page transitions and stack navigation to work properly. Each view that is navigated to using the router must include an `IonPage` component. +`IonPage` is also required for proper styling. It provides a flex container that ensures page content, such as `IonContent`, is properly sized and does not overlap other UI elements like `IonTabBar`. + ```vue