Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/angular/src/standalone/directives/checkbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { defineCustomElement } from '@ionic/core/components/ion-checkbox.js';
import { ProxyCmp, proxyOutputs } from './angular-component-lib/utils';

const CHECKBOX_INPUTS = [
'alignment',
'checked',
'color',
'disabled',
Expand All @@ -27,6 +28,7 @@ const CHECKBOX_INPUTS = [
'labelPlacement',
'mode',
'name',
'required',
'value',
];

Expand Down
1 change: 1 addition & 0 deletions packages/angular/src/standalone/directives/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const INPUT_INPUTS = [
'autocorrect',
'autofocus',
'clearInput',
'clearInputIcon',
'clearOnEdit',
'color',
'counter',
Expand Down
3 changes: 3 additions & 0 deletions packages/angular/src/standalone/directives/searchbar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { ProxyCmp, proxyOutputs } from './angular-component-lib/utils';

const SEARCHBAR_INPUTS = [
'animated',
'autocapitalize',
'autocomplete',
'autocorrect',
'cancelButtonIcon',
Expand All @@ -28,6 +29,8 @@ const SEARCHBAR_INPUTS = [
'disabled',
'enterkeyhint',
'inputmode',
'maxlength',
'minlength',
'mode',
'name',
'placeholder',
Expand Down
1 change: 1 addition & 0 deletions packages/angular/src/standalone/directives/select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const SELECT_INPUTS = [
'name',
'okText',
'placeholder',
'required',
'selectedText',
'shape',
'toggleIcon',
Expand Down
2 changes: 2 additions & 0 deletions packages/angular/src/standalone/directives/toggle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { defineCustomElement } from '@ionic/core/components/ion-toggle.js';
import { ProxyCmp, proxyOutputs } from './angular-component-lib/utils';

const TOGGLE_INPUTS = [
'alignment',
'checked',
'color',
'disabled',
Expand All @@ -27,6 +28,7 @@ const TOGGLE_INPUTS = [
'labelPlacement',
'mode',
'name',
'required',
'value',
];

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import { test, expect } from '@playwright/test';

test.describe('Standalone Inputs', () => {
test.beforeEach(async ({ page }) => {
await page.goto('/standalone/standalone-inputs');
});

test('should support ion-input clearInputIcon', async ({ page }) => {
const input = page.locator('ion-input#input-clear-input-icon');

// The custom clear icon should be set on the element.
await expect.poll(() => input.evaluate((el: HTMLIonInputElement) => el.clearInputIcon)).toBe('close-circle');

// The clear button should render the custom icon.
await expect
.poll(() =>
input.evaluate((el: HTMLIonInputElement) => {
const icon = el.querySelector('ion-icon') as { icon?: string } | null;
return icon ? icon.icon : null;
})
)
.toBe('close-circle');
});

test('should support ion-checkbox alignment and required', async ({ page }) => {
const checkbox = page.locator('ion-checkbox#checkbox-required');

await expect.poll(() => checkbox.evaluate((el: HTMLIonCheckboxElement) => el.alignment)).toBe('start');
await expect.poll(() => checkbox.evaluate((el: HTMLIonCheckboxElement) => el.required)).toBe(true);
});

test('should support ion-toggle alignment and required', async ({ page }) => {
const toggle = page.locator('ion-toggle#toggle-required');

await expect.poll(() => toggle.evaluate((el: HTMLIonToggleElement) => el.alignment)).toBe('start');
await expect.poll(() => toggle.evaluate((el: HTMLIonToggleElement) => el.required)).toBe(true);
});

test('should support ion-select required', async ({ page }) => {
const select = page.locator('ion-select#select-required');

await expect.poll(() => select.evaluate((el: HTMLIonSelectElement) => el.required)).toBe(true);
});

test('should support ion-searchbar autocapitalize, maxlength and minlength', async ({ page }) => {
const searchbar = page.locator('ion-searchbar#searchbar-inputs');

await expect.poll(() => searchbar.evaluate((el: HTMLIonSearchbarElement) => el.autocapitalize)).toBe('words');
await expect.poll(() => searchbar.evaluate((el: HTMLIonSearchbarElement) => el.maxlength)).toBe(5);
await expect.poll(() => searchbar.evaluate((el: HTMLIonSearchbarElement) => el.minlength)).toBe(2);

// The values should also reach the native input element.
await expect
.poll(() =>
searchbar.evaluate((el: HTMLIonSearchbarElement) => {
const nativeInput = el.querySelector('input');
return nativeInput?.getAttribute('autocapitalize') ?? null;
})
)
.toBe('words');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const routes: Routes = [
children: [
{ path: '', loadComponent: () => import('../home-page/home-page.component').then(c => c.HomePageComponent) },
{ path: 'inputs', loadComponent: () => import('../inputs/inputs.component').then(c => c.InputsComponent) },
{ path: 'standalone-inputs', loadComponent: () => import('../standalone-inputs/standalone-inputs.component').then(c => c.StandaloneInputsComponent) },
{ path: 'async-change-detection', loadComponent: () => import('../async-change-detection/async-change-detection.component').then(c => c.AsyncChangeDetectionComponent) },
{ path: 'async-change-detection-tabs', redirectTo: '/standalone/async-change-detection-tabs/tab-one', pathMatch: 'full' },
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<ion-header>
<ion-toolbar>
<ion-title>
Standalone Inputs
</ion-title>
</ion-toolbar>
</ion-header>
<ion-content>
<ion-list>
<ion-item>
<ion-input
id="input-clear-input-icon"
label="Input"
value="abc"
[clearInput]="true"
[clearInputIcon]="clearIcon">
</ion-input>
</ion-item>

<ion-item>
<ion-checkbox
id="checkbox-required"
[alignment]="checkboxAlignment"
[required]="checkboxRequired">
Checkbox
</ion-checkbox>
</ion-item>

<ion-item>
<ion-toggle
id="toggle-required"
[alignment]="toggleAlignment"
[required]="toggleRequired">
Toggle
</ion-toggle>
</ion-item>

<ion-item>
<ion-select id="select-required" label="Select" [required]="selectRequired">
<ion-select-option value="nes">NES</ion-select-option>
<ion-select-option value="n64">Nintendo64</ion-select-option>
</ion-select>
</ion-item>

<ion-item>
<ion-searchbar
id="searchbar-inputs"
[autocapitalize]="searchbarAutocapitalize"
[maxlength]="searchbarMaxlength"
[minlength]="searchbarMinlength">
</ion-searchbar>
</ion-item>
</ion-list>
</ion-content>
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { Component } from '@angular/core';
import { addIcons } from 'ionicons';
import { closeCircle } from 'ionicons/icons';
import {
IonCheckbox,
IonContent,
IonHeader,
IonInput,
IonItem,
IonList,
IonSearchbar,
IonSelect,
IonSelectOption,
IonTitle,
IonToggle,
IonToolbar,
} from '@ionic/angular';

addIcons({ closeCircle });

@Component({
selector: 'app-standalone-inputs',
templateUrl: './standalone-inputs.component.html',
standalone: true,
imports: [
IonCheckbox,
IonContent,
IonHeader,
IonInput,
IonItem,
IonList,
IonSearchbar,
IonSelect,
IonSelectOption,
IonTitle,
IonToggle,
IonToolbar,
],
})
export class StandaloneInputsComponent {
clearIcon = 'close-circle';
checkboxAlignment = 'start';
checkboxRequired = true;
toggleAlignment = 'start';
toggleRequired = true;
selectRequired = true;
searchbarAutocapitalize = 'words';
searchbarMaxlength = 5;
searchbarMinlength = 2;
}