@rdlabo/ionic-angular-kit 0.0.16 → 0.0.19

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.
@@ -79,6 +79,57 @@ declare class KitStorageService {
79
79
  static ɵprov: i0.ɵɵInjectableDeclaration<KitStorageService>;
80
80
  }
81
81
 
82
+ /**
83
+ * Remember the email a user last entered on the sign-in form so the field can be prefilled next
84
+ * time (the password is never stored).
85
+ *
86
+ * @remarks
87
+ * Storage-agnostic: the helpers take a minimal async key/value store that {@link KitStorageService}
88
+ * satisfies structurally, so they stay pure and unit-testable without DI. `kitRememberEmail`
89
+ * **validates the address before persisting** — a malformed or partial string is silently ignored,
90
+ * so a garbage entry (or a fat-fingered attempt) never becomes the next prefill. A well-formed email
91
+ * that later fails to sign in is still remembered by design: the user simply re-enters/corrects it.
92
+ *
93
+ * These live in the main entry (next to {@link KitStorageService}) rather than in `auth-firebase`,
94
+ * so the `KitAutofillDirective` can consume them without the main entry depending on the Firebase
95
+ * entry.
96
+ */
97
+ /** Minimal async key/value store — structurally satisfied by `KitStorageService`. */
98
+ interface KitEmailStore {
99
+ get<T>(key: string): Promise<T | null>;
100
+ set<T>(key: string, value: T): Promise<void>;
101
+ remove(key: string): Promise<void>;
102
+ }
103
+ /** Storage key under which the last entered sign-in email is kept. */
104
+ declare const KIT_LAST_AUTH_EMAIL_KEY = "kit:last-auth-email";
105
+ /** Whether `email` is a well-formed address (matches `@angular/forms` `Validators.email`). */
106
+ declare const kitIsValidEmail: (email: string) => boolean;
107
+ /**
108
+ * Persist the entered email for next time — but only when it is a well-formed address.
109
+ *
110
+ * @param store - the app's storage (e.g. `KitStorageService`)
111
+ * @param email - the entered email; ignored (not stored) when malformed
112
+ * @returns `true` when the value passed validation and was stored, `false` when it was ignored
113
+ */
114
+ declare const kitRememberEmail: (store: KitEmailStore, email: string) => Promise<boolean>;
115
+ /**
116
+ * Recall the last remembered email.
117
+ *
118
+ * @param store - the app's storage (e.g. `KitStorageService`)
119
+ * @returns the stored email, or `null` when none has been remembered
120
+ */
121
+ declare const kitRecallEmail: (store: KitEmailStore) => Promise<string | null>;
122
+ /**
123
+ * Forget the remembered email.
124
+ *
125
+ * @remarks
126
+ * Called when the user intentionally clears or invalidates the field, so a stale prefill is not
127
+ * resurrected next time.
128
+ *
129
+ * @param store - the app's storage (e.g. `KitStorageService`)
130
+ */
131
+ declare const kitForgetEmail: (store: KitEmailStore) => Promise<void>;
132
+
82
133
  /**
83
134
  * User-visible button labels consumed by `KitOverlayController`.
84
135
  *
@@ -603,43 +654,70 @@ interface KitLanguageActionSheetOptions {
603
654
  declare const kitPresentLanguageActionSheet: (actionSheetCtrl: ActionSheetController, options: KitLanguageActionSheetOptions) => Promise<void>;
604
655
 
605
656
  /**
606
- * Work around iOS `ion-input` autofill values not propagating to the Angular form model.
657
+ * The mode of {@link KitAuthInputDirective}.
607
658
  *
608
- * On iOS, when the browser autofills an `ion-input` (for example a saved password), the value
609
- * is written to the underlying native `<input>` element but the corresponding `change` event is
610
- * not forwarded to the host `ion-input`, so the Angular form control (and `ngModel`) never sees
611
- * the autofilled value. This directive listens for the first `change` event on the inner input
612
- * element and mirrors its value back onto the host element, restoring two-way binding.
613
- *
614
- * Apply it to any `ion-input` that participates in a form and may be autofilled by attaching the
615
- * `rdlaboAutofill` attribute.
616
- *
617
- * @remarks
618
- * The directive is a no-op on every platform other than iOS, where the value already propagates
619
- * correctly. A short timeout is used because `ion-input` creates its inner `<input>` element
620
- * asynchronously after the host element is initialized.
659
+ * - `'autofill'` — iOS autofill propagation only (use on the password input).
660
+ * - `'email'` — sign-in email: prefill from storage + remember on change + forget when cleared.
661
+ * - `'email-remember'` — sign-up email: remember on change only (no prefill, no forget).
662
+ */
663
+ type KitAuthInputMode = 'autofill' | 'email' | 'email-remember';
664
+ /**
665
+ * Input conveniences for an `ion-input` in a sign-in / sign-up form, applied via the `kitAuthInput`
666
+ * attribute. The mode is a typed union so a typo is a compile-time error.
667
+ *
668
+ * 1. **iOS autofill propagation (always on, every mode).** On iOS, when the browser autofills an
669
+ * `ion-input` (e.g. a saved password) the value is written to the underlying native `<input>`
670
+ * but the `change` event is not forwarded to the host `ion-input`, so the Angular form model
671
+ * never sees it. This directive mirrors the first inner-input `change` back onto the host,
672
+ * restoring two-way binding. It is a no-op on every other platform.
673
+ *
674
+ * 2. **Remember / prefill the email (`'email'` and `'email-remember'`).**
675
+ * - `'email'` (sign-in) — on init recalls the last entered email and, *only while the field is
676
+ * still empty*, seeds it via the bound Signal Forms field, so a browser/OS autofill the user
677
+ * actually picks always wins over the prefill. On every committed change (`ionChange`) it
678
+ * remembers a well-formed address, or **forgets** the stored one when the field is cleared
679
+ * (empty after trim) or holds an invalid address — the user intentionally removing the prefill.
680
+ * - `'email-remember'` (sign-up) — remembers a well-formed address on change, but never prefills
681
+ * and never forgets. So the first-sign-up address is captured without pre-populating a
682
+ * stranger's email into a new-account form, and clearing the field does not wipe an email
683
+ * remembered elsewhere.
684
+ *
685
+ * A well-formed email is persisted even if it later fails to sign in — by design; the user simply
686
+ * re-enters it. A malformed/partial entry is never stored (see {@link kitRememberEmail}).
621
687
  *
622
688
  * @example
623
689
  * ```html
624
- * <ion-input rdlaboAutofill type="password" [(ngModel)]="password"></ion-input>
690
+ * <!-- sign-in email: iOS autofill + prefill + remember/forget -->
691
+ * <ion-input type="email" autocomplete="email" kitAuthInput="email" [formField]="form.email" />
692
+ * <!-- sign-up email: remember only -->
693
+ * <ion-input type="email" autocomplete="email" kitAuthInput="email-remember" [formField]="form.email" />
694
+ * <!-- password: iOS autofill propagation only -->
695
+ * <ion-input type="password" autocomplete="current-password" kitAuthInput="autofill" [formField]="form.password" />
625
696
  * ```
697
+ *
698
+ * @remarks
699
+ * Prefill writes through the Signal Forms `FORM_FIELD` bound on the same element; with no such field
700
+ * (e.g. `ngModel` / reactive forms) prefill is skipped — remember/forget still work off the DOM
701
+ * event. Storage is resolved lazily so the iOS mirror still works in apps without `@ionic/storage`.
626
702
  */
627
- declare class KitAutofillDirective implements OnInit {
703
+ declare class KitAuthInputDirective implements OnInit {
628
704
  #private;
705
+ /** Mode selector; see {@link KitAuthInputMode}. */
706
+ readonly kitAuthInput: i0.InputSignal<KitAuthInputMode>;
629
707
  constructor();
630
708
  /**
631
- * Register the iOS autofill workaround once the directive is initialized.
632
- *
633
- * Returns immediately on non-iOS platforms. On iOS, after a short delay it attaches a one-shot,
634
- * passive `change` listener to the inner `<input>` element that `ion-input` renders, copying the
635
- * autofilled value back onto the host element so the Angular form model stays in sync. Any error
636
- * while locating the inner input (for example if the element is not yet present) is swallowed.
637
- *
638
- * @returns Nothing.
709
+ * Register the iOS autofill workaround and, in `'email'` mode, seed the field from storage.
639
710
  */
640
711
  ngOnInit(): void;
641
- static ɵfac: i0.ɵɵFactoryDeclaration<KitAutofillDirective, never>;
642
- static ɵdir: i0.ɵɵDirectiveDeclaration<KitAutofillDirective, "[rdlaboAutofill]", never, {}, {}, never, never, true, never>;
712
+ /**
713
+ * On every committed change (`ionChange`): remember a well-formed email, or — only in the
714
+ * prefilling `'email'` (sign-in) mode — forget the stored one when the field is cleared or invalid,
715
+ * which is the user intentionally removing the prefill. `'email-remember'` never forgets, so
716
+ * editing the sign-up field cannot wipe an email remembered from sign-in.
717
+ */
718
+ onIonChange(event: Event): void;
719
+ static ɵfac: i0.ɵɵFactoryDeclaration<KitAuthInputDirective, never>;
720
+ static ɵdir: i0.ɵɵDirectiveDeclaration<KitAuthInputDirective, "[kitAuthInput]", never, { "kitAuthInput": { "alias": "kitAuthInput"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
643
721
  }
644
722
 
645
723
  /**
@@ -1236,5 +1314,5 @@ declare const kitChangeEventDisabled: (completeEvent: WritableSignal<HTMLIonInfi
1236
1314
  */
1237
1315
  declare const kitCreateDidEnter: (el: ElementRef) => Observable<boolean>;
1238
1316
 
1239
- export { KIT_AUTH_CONFIG, KIT_HTTP_CONFIG, KIT_OVERLAY_CONFIG, KitAutofillDirective, KitLoadingController, KitOverlayController, KitReloadAlertController, KitStorageService, arrayConcatById, disableHandler, kitAuthInterceptor, kitChangeEventDisabled, kitCreateDidEnter, kitImpact, kitKeyboardInit, kitPresentAuthFailedAlert, kitPresentLanguageActionSheet, kitRequireAuthorizedGuard, kitRequireConfirmingGuard, kitRequiredUnauthorizedGuard, objectEqual, provideKitAuth, provideKitHttp, provideKitOverlay };
1240
- export type { KitAlertCloseOptions, KitAlertConfirmOptions, KitAuthConfig, KitAuthFailedAlertOptions, KitAuthRedirects, KitAuthState, KitHttpConfig, KitKeyboardAdjust, KitLabels, KitLanguageActionSheetOptions, KitLanguageOption, KitModalPresentOptions, KitOverlayConfig, KitReloadAlertOptions, ModalMetadata };
1317
+ export { KIT_AUTH_CONFIG, KIT_HTTP_CONFIG, KIT_LAST_AUTH_EMAIL_KEY, KIT_OVERLAY_CONFIG, KitAuthInputDirective, KitLoadingController, KitOverlayController, KitReloadAlertController, KitStorageService, arrayConcatById, disableHandler, kitAuthInterceptor, kitChangeEventDisabled, kitCreateDidEnter, kitForgetEmail, kitImpact, kitIsValidEmail, kitKeyboardInit, kitPresentAuthFailedAlert, kitPresentLanguageActionSheet, kitRecallEmail, kitRememberEmail, kitRequireAuthorizedGuard, kitRequireConfirmingGuard, kitRequiredUnauthorizedGuard, objectEqual, provideKitAuth, provideKitHttp, provideKitOverlay };
1318
+ export type { KitAlertCloseOptions, KitAlertConfirmOptions, KitAuthConfig, KitAuthFailedAlertOptions, KitAuthInputMode, KitAuthRedirects, KitAuthState, KitEmailStore, KitHttpConfig, KitKeyboardAdjust, KitLabels, KitLanguageActionSheetOptions, KitLanguageOption, KitModalPresentOptions, KitOverlayConfig, KitReloadAlertOptions, ModalMetadata };