@rdlabo/ionic-angular-kit 22.0.0-0 → 22.0.0-2
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
|
@@ -10,10 +10,11 @@ npm install @rdlabo/ionic-angular-kit
|
|
|
10
10
|
|
|
11
11
|
| Package | Supported version |
|
|
12
12
|
| ---------------------------------- | ----------------- |
|
|
13
|
-
| Angular | 21.x
|
|
14
|
-
| Ionic Angular |
|
|
13
|
+
| Angular | 21.x–22.x |
|
|
14
|
+
| Ionic Angular | 9.x |
|
|
15
15
|
| RxJS | 7.8.x |
|
|
16
|
-
| Capacitor core and feature plugins |
|
|
16
|
+
| Capacitor core and feature plugins | 7.x–8.x |
|
|
17
|
+
| iOS/iPadOS deployment target | 16.4 or later |
|
|
17
18
|
|
|
18
19
|
Install `@ionic/storage-angular` when using storage. Other peers are feature-scoped: install only the Capacitor, Firebase, printing, or Live Update packages used by your selected entry points.
|
|
19
20
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { inject, Injectable, InjectionToken, makeEnvironmentProviders,
|
|
2
|
+
import { inject, Injectable, InjectionToken, makeEnvironmentProviders, Injector, input, computed, HostListener, Directive, ErrorHandler, DestroyRef, provideAppInitializer, Optional, afterNextRender } from '@angular/core';
|
|
3
3
|
import { Storage } from '@ionic/storage-angular';
|
|
4
4
|
import { ModalController, PopoverController, ToastController, AlertController, LoadingController, NavController } from '@ionic/angular';
|
|
5
5
|
import { Capacitor } from '@capacitor/core';
|
|
@@ -114,7 +114,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImpor
|
|
|
114
114
|
* that later fails to sign in is still remembered by design: the user simply re-enters/corrects it.
|
|
115
115
|
*
|
|
116
116
|
* These live in the main entry (next to {@link KitStorageService}) rather than in `auth-firebase`,
|
|
117
|
-
* so
|
|
117
|
+
* so `KitAuthInputDirective` can consume them without the main entry depending on the Firebase
|
|
118
118
|
* entry.
|
|
119
119
|
*/
|
|
120
120
|
/** Storage key under which the last entered sign-in email is kept. */
|
|
@@ -945,104 +945,45 @@ const kitPresentLanguageActionSheet = async (actionSheetCtrl, options) => {
|
|
|
945
945
|
};
|
|
946
946
|
|
|
947
947
|
/**
|
|
948
|
-
*
|
|
949
|
-
*
|
|
950
|
-
*
|
|
951
|
-
*
|
|
952
|
-
*
|
|
953
|
-
* but the `change` event is not forwarded to the host `ion-input`, so the Angular form model
|
|
954
|
-
* never sees it. This directive mirrors the first inner-input `change` back onto the host,
|
|
955
|
-
* restoring two-way binding. It is a no-op on every other platform.
|
|
956
|
-
*
|
|
957
|
-
* 2. **Remember / prefill the email (`'email'` and `'email-remember'`).**
|
|
958
|
-
* - `'email'` (sign-in) — on init recalls the last entered email and, *only while the field is
|
|
959
|
-
* still empty*, seeds it via the bound Signal Forms field, so a browser/OS autofill the user
|
|
960
|
-
* actually picks always wins over the prefill. On every committed change (`ionChange`) it
|
|
961
|
-
* remembers a well-formed address, or **forgets** the stored one when the field is cleared
|
|
962
|
-
* (empty after trim) or holds an invalid address — the user intentionally removing the prefill.
|
|
963
|
-
* - `'email-remember'` (sign-up) — remembers a well-formed address on change, but never prefills
|
|
964
|
-
* and never forgets. So the first-sign-up address is captured without pre-populating a
|
|
965
|
-
* stranger's email into a new-account form, and clearing the field does not wipe an email
|
|
966
|
-
* remembered elsewhere.
|
|
967
|
-
*
|
|
968
|
-
* A well-formed email is persisted even if it later fails to sign in — by design; the user simply
|
|
969
|
-
* re-enters it. A malformed/partial entry is never stored (see {@link kitRememberEmail}).
|
|
948
|
+
* Email persistence conveniences for an `ion-input`, applied via the `kitAuthInput` attribute.
|
|
949
|
+
*
|
|
950
|
+
* The `'email'` mode recalls the last entered address and seeds an empty Signal Forms field. Both
|
|
951
|
+
* modes remember a well-formed address on `ionChange`; only `'email'` forgets a stored value when
|
|
952
|
+
* the field is cleared or invalid. Browser and OS autofill always wins over an asynchronous prefill.
|
|
970
953
|
*
|
|
971
954
|
* @example
|
|
972
955
|
* ```html
|
|
973
|
-
* <!-- sign-in email: iOS autofill + prefill + remember/forget -->
|
|
974
956
|
* <ion-input type="email" autocomplete="email" kitAuthInput="email" [formField]="form.email" />
|
|
975
|
-
* <!-- sign-up email: remember only -->
|
|
976
957
|
* <ion-input type="email" autocomplete="email" kitAuthInput="email-remember" [formField]="form.email" />
|
|
977
|
-
* <!-- password: iOS autofill propagation only -->
|
|
978
|
-
* <ion-input type="password" autocomplete="current-password" kitAuthInput="autofill" [formField]="form.password" />
|
|
979
958
|
* ```
|
|
980
959
|
*
|
|
981
960
|
* @remarks
|
|
982
|
-
* Prefill writes through the Signal Forms `FORM_FIELD` bound on the same element
|
|
983
|
-
*
|
|
984
|
-
*
|
|
961
|
+
* Prefill writes through the Signal Forms `FORM_FIELD` bound on the same element. With no field,
|
|
962
|
+
* prefill is skipped while remember/forget still work from the DOM event. Storage is resolved lazily
|
|
963
|
+
* so applications that do not configure `@ionic/storage` remain unaffected.
|
|
985
964
|
*/
|
|
986
965
|
class KitAuthInputDirective {
|
|
987
966
|
constructor() {
|
|
988
|
-
this.#el = inject(ElementRef);
|
|
989
967
|
this.#injector = inject(Injector);
|
|
990
|
-
/** The Signal Forms field bound on this same element, if any (used to seed the prefill). */
|
|
991
968
|
this.#field = inject(FORM_FIELD, { optional: true, self: true });
|
|
992
|
-
/**
|
|
993
|
-
this.kitAuthInput = input(
|
|
969
|
+
/** Required persistence mode; see {@link KitAuthInputMode}. */
|
|
970
|
+
this.kitAuthInput = input.required(/* @ts-ignore */
|
|
994
971
|
...(ngDevMode ? [{ debugName: "kitAuthInput" }] : /* istanbul ignore next */ []));
|
|
995
|
-
/** Whether this instance persists the entered email (`'email'` or `'email-remember'`). */
|
|
996
|
-
this.#remembers = computed(() => {
|
|
997
|
-
const mode = this.kitAuthInput();
|
|
998
|
-
return mode === 'email' || mode === 'email-remember';
|
|
999
|
-
}, /* @ts-ignore */
|
|
1000
|
-
...(ngDevMode ? [{ debugName: "#remembers" }] : /* istanbul ignore next */ []));
|
|
1001
|
-
/** Whether this instance prefills the field from storage (`'email'` only). */
|
|
1002
972
|
this.#prefills = computed(() => this.kitAuthInput() === 'email', /* @ts-ignore */
|
|
1003
973
|
...(ngDevMode ? [{ debugName: "#prefills" }] : /* istanbul ignore next */ []));
|
|
1004
|
-
/** Whether clearing/invalidating the field forgets the stored email (`'email'` only). */
|
|
1005
974
|
this.#forgetsOnClear = computed(() => this.kitAuthInput() === 'email', /* @ts-ignore */
|
|
1006
975
|
...(ngDevMode ? [{ debugName: "#forgetsOnClear" }] : /* istanbul ignore next */ []));
|
|
1007
976
|
}
|
|
1008
|
-
#el;
|
|
1009
977
|
#injector;
|
|
1010
|
-
/** The Signal Forms field bound on this same element, if any (used to seed the prefill). */
|
|
1011
978
|
#field;
|
|
1012
|
-
/**
|
|
1013
|
-
* Register the iOS autofill workaround and, in `'email'` mode, seed the field from storage.
|
|
1014
|
-
*/
|
|
979
|
+
/** Seeds an empty sign-in email field from storage. */
|
|
1015
980
|
ngOnInit() {
|
|
1016
981
|
if (this.#prefills()) {
|
|
1017
982
|
void this.#prefillEmail();
|
|
1018
983
|
}
|
|
1019
|
-
if (Capacitor.getPlatform() !== 'ios') {
|
|
1020
|
-
return;
|
|
1021
|
-
}
|
|
1022
|
-
setTimeout(() => {
|
|
1023
|
-
const input = this.#el.nativeElement.children[0];
|
|
1024
|
-
if (!input) {
|
|
1025
|
-
return;
|
|
1026
|
-
}
|
|
1027
|
-
input.addEventListener('change', (e) => {
|
|
1028
|
-
this.#el.nativeElement.value = e.target.value;
|
|
1029
|
-
}, {
|
|
1030
|
-
capture: false,
|
|
1031
|
-
once: true,
|
|
1032
|
-
passive: true,
|
|
1033
|
-
});
|
|
1034
|
-
}, 100); // Need some time for the ion-input to create the input element
|
|
1035
984
|
}
|
|
1036
|
-
/**
|
|
1037
|
-
* On every committed change (`ionChange`): remember a well-formed email, or — only in the
|
|
1038
|
-
* prefilling `'email'` (sign-in) mode — forget the stored one when the field is cleared or invalid,
|
|
1039
|
-
* which is the user intentionally removing the prefill. `'email-remember'` never forgets, so
|
|
1040
|
-
* editing the sign-up field cannot wipe an email remembered from sign-in.
|
|
1041
|
-
*/
|
|
985
|
+
/** Remembers a valid committed email and applies the selected clearing policy. */
|
|
1042
986
|
onIonChange(event) {
|
|
1043
|
-
if (!this.#remembers()) {
|
|
1044
|
-
return;
|
|
1045
|
-
}
|
|
1046
987
|
const storage = this.#resolveStorage();
|
|
1047
988
|
if (!storage) {
|
|
1048
989
|
return;
|
|
@@ -1055,13 +996,8 @@ class KitAuthInputDirective {
|
|
|
1055
996
|
void kitForgetEmail(storage);
|
|
1056
997
|
}
|
|
1057
998
|
}
|
|
1058
|
-
/** Whether this instance persists the entered email (`'email'` or `'email-remember'`). */
|
|
1059
|
-
#remembers;
|
|
1060
|
-
/** Whether this instance prefills the field from storage (`'email'` only). */
|
|
1061
999
|
#prefills;
|
|
1062
|
-
/** Whether clearing/invalidating the field forgets the stored email (`'email'` only). */
|
|
1063
1000
|
#forgetsOnClear;
|
|
1064
|
-
/** Resolve `KitStorageService` lazily; returns `null` when storage is not configured. */
|
|
1065
1001
|
#resolveStorage() {
|
|
1066
1002
|
try {
|
|
1067
1003
|
return this.#injector.get(KitStorageService);
|
|
@@ -1070,10 +1006,6 @@ class KitAuthInputDirective {
|
|
|
1070
1006
|
return null;
|
|
1071
1007
|
}
|
|
1072
1008
|
}
|
|
1073
|
-
/**
|
|
1074
|
-
* Seed the bound field with the remembered email, but only while it is still empty — so a value
|
|
1075
|
-
* the browser/OS autofills during the async recall is not clobbered.
|
|
1076
|
-
*/
|
|
1077
1009
|
async #prefillEmail() {
|
|
1078
1010
|
const field = this.#field;
|
|
1079
1011
|
if (!field) {
|
|
@@ -1090,7 +1022,7 @@ class KitAuthInputDirective {
|
|
|
1090
1022
|
}
|
|
1091
1023
|
}
|
|
1092
1024
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: KitAuthInputDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
1093
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.1.3", type: KitAuthInputDirective, isStandalone: true, selector: "[kitAuthInput]", inputs: { kitAuthInput: { classPropertyName: "kitAuthInput", publicName: "kitAuthInput", isSignal: true, isRequired:
|
|
1025
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.1.3", type: KitAuthInputDirective, isStandalone: true, selector: "[kitAuthInput]", inputs: { kitAuthInput: { classPropertyName: "kitAuthInput", publicName: "kitAuthInput", isSignal: true, isRequired: true, transformFunction: null } }, host: { listeners: { "ionChange": "onIonChange($event)" } }, ngImport: i0 }); }
|
|
1094
1026
|
}
|
|
1095
1027
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: KitAuthInputDirective, decorators: [{
|
|
1096
1028
|
type: Directive,
|
|
@@ -1098,7 +1030,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImpor
|
|
|
1098
1030
|
selector: '[kitAuthInput]',
|
|
1099
1031
|
standalone: true,
|
|
1100
1032
|
}]
|
|
1101
|
-
}], propDecorators: { kitAuthInput: [{ type: i0.Input, args: [{ isSignal: true, alias: "kitAuthInput", required:
|
|
1033
|
+
}], propDecorators: { kitAuthInput: [{ type: i0.Input, args: [{ isSignal: true, alias: "kitAuthInput", required: true }] }], onIonChange: [{
|
|
1102
1034
|
type: HostListener,
|
|
1103
1035
|
args: ['ionChange', ['$event']]
|
|
1104
1036
|
}] } });
|
|
@@ -2651,6 +2583,7 @@ const objectEqual = (a, b) => {
|
|
|
2651
2583
|
return JSON.stringify(sortDeep(a)) === JSON.stringify(sortDeep(b));
|
|
2652
2584
|
};
|
|
2653
2585
|
|
|
2586
|
+
const disableStates = new WeakMap();
|
|
2654
2587
|
const isDisableable = (element) => element instanceof HTMLElement && 'disabled' in element;
|
|
2655
2588
|
const getIonicSubmitButtons = (form) => Array.from(document.querySelectorAll('ion-button[type="submit"]')).filter((button) => {
|
|
2656
2589
|
if (!isDisableable(button))
|
|
@@ -2680,37 +2613,35 @@ const getDisableTargets = (event) => {
|
|
|
2680
2613
|
targets.push(event.target);
|
|
2681
2614
|
return [...new Set(targets)];
|
|
2682
2615
|
};
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
|
|
2616
|
+
const acquireDisableTarget = (target) => {
|
|
2617
|
+
const state = disableStates.get(target);
|
|
2618
|
+
if (state) {
|
|
2619
|
+
state.count += 1;
|
|
2620
|
+
return;
|
|
2621
|
+
}
|
|
2622
|
+
disableStates.set(target, { count: 1, original: target.disabled });
|
|
2623
|
+
target.disabled = true;
|
|
2624
|
+
};
|
|
2625
|
+
const releaseDisableTarget = (target) => {
|
|
2626
|
+
const state = disableStates.get(target);
|
|
2627
|
+
if (!state)
|
|
2628
|
+
return;
|
|
2629
|
+
state.count -= 1;
|
|
2630
|
+
if (state.count > 0)
|
|
2631
|
+
return;
|
|
2632
|
+
target.disabled = state.original;
|
|
2633
|
+
disableStates.delete(target);
|
|
2634
|
+
};
|
|
2635
|
+
function disableHandler(event, work) {
|
|
2703
2636
|
if (event.type === 'submit')
|
|
2704
2637
|
event.preventDefault();
|
|
2638
|
+
if (work === undefined)
|
|
2639
|
+
return;
|
|
2705
2640
|
const targets = getDisableTargets(event);
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
return work
|
|
2709
|
-
|
|
2710
|
-
.finally(() => {
|
|
2711
|
-
targets.forEach((target, index) => (target.disabled = disabledStates[index]));
|
|
2712
|
-
});
|
|
2713
|
-
};
|
|
2641
|
+
targets.forEach(acquireDisableTarget);
|
|
2642
|
+
const restore = () => targets.forEach(releaseDisableTarget);
|
|
2643
|
+
return new Promise((resolve) => resolve(work)).then(restore, restore);
|
|
2644
|
+
}
|
|
2714
2645
|
|
|
2715
2646
|
/**
|
|
2716
2647
|
* Toggle the `disabled` flag of a signal-held `ion-infinite-scroll` / `ion-refresher` element.
|