@rdlabo/ionic-angular-kit 22.0.0-2 → 22.0.0-3
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/README.md
CHANGED
|
@@ -25,6 +25,7 @@ Install `@ionic/storage-angular` when using storage. Other peers are feature-sco
|
|
|
25
25
|
| `@rdlabo/ionic-angular-kit` | Storage, overlays, guards, HTTP, realtime, directives, keyboard, and utilities |
|
|
26
26
|
| `@rdlabo/ionic-angular-kit/offline` | Scoped local replica, outbox, pull, replay, and request policies |
|
|
27
27
|
| `@rdlabo/ionic-angular-kit/theme` | Persisted light/dark theme and native status bar sync |
|
|
28
|
+
| `@rdlabo/ionic-angular-kit/forms` | Ionic error text and state classes for Angular Signal Forms |
|
|
28
29
|
| `@rdlabo/ionic-angular-kit/review` | Throttled native in-app review requests |
|
|
29
30
|
| `@rdlabo/ionic-angular-kit/printer` | DOM-to-PNG, Brother label, and PDF helpers |
|
|
30
31
|
| `@rdlabo/ionic-angular-kit/auth-firebase` | Firebase dependency wiring and authentication flows |
|
|
@@ -42,6 +43,7 @@ Most features expose a provider whose callbacks keep routes, copy, credentials,
|
|
|
42
43
|
- [Authentication and HTTP](./docs/auth-http.md)
|
|
43
44
|
- [Offline and Realtime](./docs/offline-realtime.md)
|
|
44
45
|
- [Optional Features](./docs/optional-features.md)
|
|
46
|
+
- [Ionic Signal Forms](./docs/forms.md)
|
|
45
47
|
|
|
46
48
|
<!-- rdlabo-docs-omit -->
|
|
47
49
|
**Full documentation:** [https://docs.rdlabo.dev/projects/ionic-angular-kit](https://docs.rdlabo.dev/projects/ionic-angular-kit)
|
package/docs/forms.md
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# Ionic Signal Forms
|
|
2
|
+
|
|
3
|
+
This entry point targets Angular 22 Signal Forms.
|
|
4
|
+
|
|
5
|
+
Import Angular's `FormField` together with the kit adapter in each standalone component that binds Signal Forms to Ionic controls.
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
import { FormField } from '@angular/forms/signals';
|
|
9
|
+
import { KitIonicFormField } from '@rdlabo/ionic-angular-kit/forms';
|
|
10
|
+
|
|
11
|
+
@Component({
|
|
12
|
+
imports: [FormField, KitIonicFormField],
|
|
13
|
+
})
|
|
14
|
+
export class ProfilePage {}
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
The adapter copies the first non-empty string validation message to Ionic's `errorText` property for `ion-input`, `ion-textarea`, `ion-select`, `ion-checkbox`, `ion-radio-group`, and `ion-toggle`. Validation wording and localization remain the application's responsibility. An explicit `errorText` or `[errorText]` binding takes precedence and prevents the adapter from being instantiated.
|
|
18
|
+
|
|
19
|
+
Install the state-class configuration once at application bootstrap:
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
import { provideKitIonicSignalForms } from '@rdlabo/ionic-angular-kit/forms';
|
|
23
|
+
|
|
24
|
+
export const appConfig: ApplicationConfig = {
|
|
25
|
+
providers: [provideKitIonicSignalForms()],
|
|
26
|
+
};
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Angular does not merge multiple `provideSignalFormsConfig` class configurations. If the application provides its own configuration, combine all required class mappings in one provider instead of registering both providers and relying on their order.
|
|
30
|
+
|
|
31
|
+
When using `@rdlabo/eslint-plugin-rules`, enable its adapter-aware mode only after every relevant standalone component has imported the adapter:
|
|
32
|
+
|
|
33
|
+
```js
|
|
34
|
+
{
|
|
35
|
+
files: ['**/*.html'],
|
|
36
|
+
rules: {
|
|
37
|
+
'@rdlabo/rules/require-ion-error-text': ['error', { formFieldProvidesErrorText: true }],
|
|
38
|
+
},
|
|
39
|
+
}
|
|
40
|
+
```
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { inject, ElementRef, Renderer2, effect, Directive } from '@angular/core';
|
|
3
|
+
import { FORM_FIELD, provideSignalFormsConfig } from '@angular/forms/signals';
|
|
4
|
+
|
|
5
|
+
class KitIonicFormField {
|
|
6
|
+
#field = inject(FORM_FIELD, { self: true });
|
|
7
|
+
#element = inject((ElementRef));
|
|
8
|
+
#renderer = inject(Renderer2);
|
|
9
|
+
constructor() {
|
|
10
|
+
effect(() => {
|
|
11
|
+
const message = this.#field
|
|
12
|
+
.errors()
|
|
13
|
+
.map((error) => error.message)
|
|
14
|
+
.find((candidate) => typeof candidate === 'string' && candidate.trim().length > 0);
|
|
15
|
+
this.#renderer.setProperty(this.#element.nativeElement, 'errorText', message);
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: KitIonicFormField, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
19
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.1.3", type: KitIonicFormField, isStandalone: true, selector: "\n ion-input[formField]:not([errorText]),\n ion-textarea[formField]:not([errorText]),\n ion-select[formField]:not([errorText]),\n ion-checkbox[formField]:not([errorText]),\n ion-radio-group[formField]:not([errorText]),\n ion-toggle[formField]:not([errorText])\n ", ngImport: i0 }); }
|
|
20
|
+
}
|
|
21
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: KitIonicFormField, decorators: [{
|
|
22
|
+
type: Directive,
|
|
23
|
+
args: [{
|
|
24
|
+
// Angular's FormField owns [formField]. This sibling directive only adapts its validation message to Ionic.
|
|
25
|
+
selector: `
|
|
26
|
+
ion-input[formField]:not([errorText]),
|
|
27
|
+
ion-textarea[formField]:not([errorText]),
|
|
28
|
+
ion-select[formField]:not([errorText]),
|
|
29
|
+
ion-checkbox[formField]:not([errorText]),
|
|
30
|
+
ion-radio-group[formField]:not([errorText]),
|
|
31
|
+
ion-toggle[formField]:not([errorText])
|
|
32
|
+
`,
|
|
33
|
+
}]
|
|
34
|
+
}], ctorParameters: () => [] });
|
|
35
|
+
|
|
36
|
+
/** Adds Angular and Ionic validity state classes to Signal Forms controls. */
|
|
37
|
+
const provideKitIonicSignalForms = () => provideSignalFormsConfig({
|
|
38
|
+
classes: {
|
|
39
|
+
'ng-dirty': ({ state }) => state().dirty(),
|
|
40
|
+
'ng-invalid': ({ state }) => state().invalid(),
|
|
41
|
+
'ng-pending': ({ state }) => state().pending(),
|
|
42
|
+
'ng-pristine': ({ state }) => !state().dirty(),
|
|
43
|
+
'ng-touched': ({ state }) => state().touched(),
|
|
44
|
+
'ng-untouched': ({ state }) => !state().touched(),
|
|
45
|
+
'ng-valid': ({ state }) => state().valid(),
|
|
46
|
+
'ion-invalid': ({ state }) => state().invalid(),
|
|
47
|
+
'ion-touched': ({ state }) => state().touched(),
|
|
48
|
+
'ion-valid': ({ state }) => state().valid(),
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Generated bundle index. Do not edit.
|
|
54
|
+
*/
|
|
55
|
+
|
|
56
|
+
export { KitIonicFormField, provideKitIonicSignalForms };
|
|
57
|
+
//# sourceMappingURL=rdlabo-ionic-angular-kit-forms.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rdlabo-ionic-angular-kit-forms.mjs","sources":["../../../projects/kit/forms/src/kit-ionic-form-field.ts","../../../projects/kit/forms/src/provide-kit-ionic-signal-forms.ts","../../../projects/kit/forms/src/rdlabo-ionic-angular-kit-forms.ts"],"sourcesContent":["import { Directive, effect, ElementRef, inject, Renderer2 } from '@angular/core';\nimport { FORM_FIELD } from '@angular/forms/signals';\n\n@Directive({\n // Angular's FormField owns [formField]. This sibling directive only adapts its validation message to Ionic.\n selector: `\n ion-input[formField]:not([errorText]),\n ion-textarea[formField]:not([errorText]),\n ion-select[formField]:not([errorText]),\n ion-checkbox[formField]:not([errorText]),\n ion-radio-group[formField]:not([errorText]),\n ion-toggle[formField]:not([errorText])\n `,\n})\nexport class KitIonicFormField {\n readonly #field = inject(FORM_FIELD, { self: true });\n readonly #element = inject(ElementRef<HTMLElement>);\n readonly #renderer = inject(Renderer2);\n\n constructor() {\n effect(() => {\n const message = this.#field\n .errors()\n .map((error) => error.message)\n .find((candidate): candidate is string => typeof candidate === 'string' && candidate.trim().length > 0);\n this.#renderer.setProperty(this.#element.nativeElement, 'errorText', message);\n });\n }\n}\n","import { provideSignalFormsConfig } from '@angular/forms/signals';\n\n/** Adds Angular and Ionic validity state classes to Signal Forms controls. */\nexport const provideKitIonicSignalForms = () =>\n provideSignalFormsConfig({\n classes: {\n 'ng-dirty': ({ state }) => state().dirty(),\n 'ng-invalid': ({ state }) => state().invalid(),\n 'ng-pending': ({ state }) => state().pending(),\n 'ng-pristine': ({ state }) => !state().dirty(),\n 'ng-touched': ({ state }) => state().touched(),\n 'ng-untouched': ({ state }) => !state().touched(),\n 'ng-valid': ({ state }) => state().valid(),\n 'ion-invalid': ({ state }) => state().invalid(),\n 'ion-touched': ({ state }) => state().touched(),\n 'ion-valid': ({ state }) => state().valid(),\n },\n });\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;MAca,iBAAiB,CAAA;IACnB,MAAM,GAAG,MAAM,CAAC,UAAU,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;AAC3C,IAAA,QAAQ,GAAG,MAAM,EAAC,UAAuB,EAAC;AAC1C,IAAA,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC;AAEtC,IAAA,WAAA,GAAA;QACE,MAAM,CAAC,MAAK;AACV,YAAA,MAAM,OAAO,GAAG,IAAI,CAAC;AAClB,iBAAA,MAAM;iBACN,GAAG,CAAC,CAAC,KAAK,KAAK,KAAK,CAAC,OAAO;iBAC5B,IAAI,CAAC,CAAC,SAAS,KAA0B,OAAO,SAAS,KAAK,QAAQ,IAAI,SAAS,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC;AACzG,YAAA,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC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AA,aAAa,EAAE,CAAC,EAAE,KAAK,EAAE,KAAK,KAAK,EAAE,CAAC,OAAO,EAAE;AAC/C,QAAA,WAAW,EAAE,CAAC,EAAE,KAAK,EAAE,KAAK,KAAK,EAAE,CAAC,KAAK,EAAE;AAC5C,KAAA;AACF,CAAA;;ACjBH;;AAEG;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rdlabo/ionic-angular-kit",
|
|
3
|
-
"version": "22.0.0-
|
|
3
|
+
"version": "22.0.0-3",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/rdlabo-dev/ionic-angular-library.git"
|
|
@@ -92,6 +92,10 @@
|
|
|
92
92
|
"types": "./types/rdlabo-ionic-angular-kit-auth-firebase-social.d.ts",
|
|
93
93
|
"default": "./fesm2022/rdlabo-ionic-angular-kit-auth-firebase-social.mjs"
|
|
94
94
|
},
|
|
95
|
+
"./forms": {
|
|
96
|
+
"types": "./types/rdlabo-ionic-angular-kit-forms.d.ts",
|
|
97
|
+
"default": "./fesm2022/rdlabo-ionic-angular-kit-forms.mjs"
|
|
98
|
+
},
|
|
95
99
|
"./live-update": {
|
|
96
100
|
"types": "./types/rdlabo-ionic-angular-kit-live-update.d.ts",
|
|
97
101
|
"default": "./fesm2022/rdlabo-ionic-angular-kit-live-update.mjs"
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
|
|
3
|
+
declare class KitIonicFormField {
|
|
4
|
+
#private;
|
|
5
|
+
constructor();
|
|
6
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<KitIonicFormField, never>;
|
|
7
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<KitIonicFormField, " ion-input[formField]:not([errorText]), ion-textarea[formField]:not([errorText]), ion-select[formField]:not([errorText]), ion-checkbox[formField]:not([errorText]), ion-radio-group[formField]:not([errorText]), ion-toggle[formField]:not([errorText]) ", never, {}, {}, never, never, true, never>;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/** Adds Angular and Ionic validity state classes to Signal Forms controls. */
|
|
11
|
+
declare const provideKitIonicSignalForms: () => i0.Provider[];
|
|
12
|
+
|
|
13
|
+
export { KitIonicFormField, provideKitIonicSignalForms };
|