valtech-components 2.0.800 → 2.0.802
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/esm2022/lib/components/molecules/content-reaction/content-reaction.component.mjs +13 -21
- package/esm2022/lib/components/organisms/login/login.component.mjs +14 -20
- package/esm2022/lib/components/templates/page-wrapper/page-wrapper.component.mjs +37 -3
- package/esm2022/lib/services/auth/guards.mjs +9 -4
- package/esm2022/lib/services/page-refresh/page-refresh.service.mjs +77 -0
- package/esm2022/lib/services/toast.service.mjs +9 -3
- package/esm2022/lib/version.mjs +2 -2
- package/esm2022/public-api.mjs +4 -1
- package/fesm2022/valtech-components.mjs +148 -44
- package/fesm2022/valtech-components.mjs.map +1 -1
- package/lib/components/templates/page-wrapper/page-wrapper.component.d.ts +9 -0
- package/lib/services/auth/guards.d.ts +3 -0
- package/lib/services/page-refresh/page-refresh.service.d.ts +64 -0
- package/lib/services/toast.service.d.ts +6 -0
- package/lib/version.d.ts +1 -1
- package/package.json +1 -1
- package/public-api.d.ts +1 -0
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { EventEmitter, OnDestroy, OnInit } from '@angular/core';
|
|
2
2
|
import { ViewWillEnter, ViewWillLeave } from '@ionic/angular/standalone';
|
|
3
3
|
import { ContainerSize } from '../../atoms/container/types';
|
|
4
|
+
import { RefreshEvent } from '../../molecules/refresher/types';
|
|
5
|
+
import { PageRefreshService } from '../../../services/page-refresh/page-refresh.service';
|
|
4
6
|
import { PageWrapperMetadata } from './types';
|
|
5
7
|
import * as i0 from "@angular/core";
|
|
6
8
|
/**
|
|
@@ -29,6 +31,13 @@ export declare class PageWrapperComponent implements ViewWillEnter, ViewWillLeav
|
|
|
29
31
|
private nav;
|
|
30
32
|
private router;
|
|
31
33
|
private routerSubscription?;
|
|
34
|
+
/** Bus del pull-to-refresh — la página activa registra su handler aquí. */
|
|
35
|
+
protected pageRefresh: PageRefreshService;
|
|
36
|
+
/**
|
|
37
|
+
* Handler del gesto pull-to-refresh. Delega en el handler que registró la
|
|
38
|
+
* página activa (`PageRefreshService.run`) y cierra el spinner al terminar.
|
|
39
|
+
*/
|
|
40
|
+
onPageRefresh(event: RefreshEvent): Promise<void>;
|
|
32
41
|
/**
|
|
33
42
|
* Page wrapper configuration.
|
|
34
43
|
* Signal-based input for full reactivity with computed().
|
|
@@ -3,6 +3,9 @@ import { CanActivateFn } from '@angular/router';
|
|
|
3
3
|
* Guard que verifica si el usuario está autenticado.
|
|
4
4
|
* Redirige a loginRoute si no está autenticado.
|
|
5
5
|
*
|
|
6
|
+
* Preserva la URL solicitada en el query param `returnUrl` para que la
|
|
7
|
+
* página de login pueda devolver al usuario a su destino tras autenticarse.
|
|
8
|
+
*
|
|
6
9
|
* @example
|
|
7
10
|
* ```typescript
|
|
8
11
|
* import { authGuard } from 'valtech-components';
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
/**
|
|
3
|
+
* Handler de refresh que registra una página. Puede ser sync o async —
|
|
4
|
+
* `val-page-wrapper` espera (`await`) a que termine antes de cerrar el spinner.
|
|
5
|
+
*/
|
|
6
|
+
export type PageRefreshHandler = () => Promise<void> | void;
|
|
7
|
+
/**
|
|
8
|
+
* PageRefreshService — bus del pull-to-refresh estándar del factory.
|
|
9
|
+
*
|
|
10
|
+
* **Por qué existe:** `val-page-wrapper` posee un único `<ion-content>` y todas
|
|
11
|
+
* las páginas se renderizan dentro vía `<router-outlet>`. Un `<ion-refresher>`
|
|
12
|
+
* tiene que vivir dentro de ese `ion-content`, así que el refresher NO puede
|
|
13
|
+
* declararse en el template de cada página — vive una sola vez en
|
|
14
|
+
* `val-page-wrapper`. Este servicio es el puente: la página activa registra
|
|
15
|
+
* *qué hacer* al refrescar; el page-wrapper dispara el gesto y cierra el spinner.
|
|
16
|
+
*
|
|
17
|
+
* **Uso en una página** (ver `frontend/CLAUDE.md` — es el patrón estándar):
|
|
18
|
+
*
|
|
19
|
+
* ```ts
|
|
20
|
+
* export class MiPage implements ViewWillEnter, ViewWillLeave {
|
|
21
|
+
* private pageRefresh = inject(PageRefreshService);
|
|
22
|
+
*
|
|
23
|
+
* ionViewWillEnter(): void {
|
|
24
|
+
* this.pageRefresh.register(() => this.reload());
|
|
25
|
+
* }
|
|
26
|
+
* ionViewWillLeave(): void {
|
|
27
|
+
* this.pageRefresh.unregister();
|
|
28
|
+
* }
|
|
29
|
+
*
|
|
30
|
+
* private async reload(): Promise<void> {
|
|
31
|
+
* // re-fetch / re-suscribir streams / etc.
|
|
32
|
+
* }
|
|
33
|
+
* }
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* Páginas que no llaman `register()` simplemente no muestran refresher —
|
|
37
|
+
* opt-in, sin impacto.
|
|
38
|
+
*/
|
|
39
|
+
export declare class PageRefreshService {
|
|
40
|
+
private handler;
|
|
41
|
+
/**
|
|
42
|
+
* `true` cuando hay una página con handler registrado. `val-page-wrapper`
|
|
43
|
+
* renderiza el `<val-refresher>` sólo cuando esto es `true`.
|
|
44
|
+
*/
|
|
45
|
+
readonly hasHandler: import("@angular/core").WritableSignal<boolean>;
|
|
46
|
+
/**
|
|
47
|
+
* Registra el handler de refresh de la página activa. Llamar en
|
|
48
|
+
* `ionViewWillEnter`. Si ya había uno, lo reemplaza (sólo hay una página
|
|
49
|
+
* activa a la vez en el router-outlet de Ionic).
|
|
50
|
+
*/
|
|
51
|
+
register(handler: PageRefreshHandler): void;
|
|
52
|
+
/**
|
|
53
|
+
* Quita el handler. Llamar en `ionViewWillLeave` para que el refresher
|
|
54
|
+
* desaparezca al salir de la vista.
|
|
55
|
+
*/
|
|
56
|
+
unregister(): void;
|
|
57
|
+
/**
|
|
58
|
+
* Ejecuta el handler registrado y espera a que termine. Lo invoca
|
|
59
|
+
* `val-page-wrapper` al detectar el gesto de pull. No-op si no hay handler.
|
|
60
|
+
*/
|
|
61
|
+
run(): Promise<void>;
|
|
62
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<PageRefreshService, never>;
|
|
63
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<PageRefreshService>;
|
|
64
|
+
}
|
|
@@ -9,6 +9,12 @@ export declare class ToastService {
|
|
|
9
9
|
constructor(toastController: ToastController);
|
|
10
10
|
/**
|
|
11
11
|
* Presents a toast notification with the given options.
|
|
12
|
+
*
|
|
13
|
+
* Estándar Valtech: todos los toasts son `color: 'dark'` y `position: 'top'`.
|
|
14
|
+
* Estos son los defaults cuando el caller no los especifica — no hace falta
|
|
15
|
+
* pasarlos en cada llamada. El diferenciador semántico (éxito/error) va en
|
|
16
|
+
* el mensaje, no en el color.
|
|
17
|
+
*
|
|
12
18
|
* @param request Toast options (message, duration, position, color, etc.)
|
|
13
19
|
*/
|
|
14
20
|
presentToast(request: ToastOptions): Promise<void>;
|
package/lib/version.d.ts
CHANGED
package/package.json
CHANGED
package/public-api.d.ts
CHANGED
|
@@ -262,6 +262,7 @@ export * from './lib/services/firebase';
|
|
|
262
262
|
export * from './lib/services/auth';
|
|
263
263
|
export * from './lib/services/i18n';
|
|
264
264
|
export * from './lib/services/preferences';
|
|
265
|
+
export * from './lib/services/page-refresh/page-refresh.service';
|
|
265
266
|
export * from './lib/services/app-config';
|
|
266
267
|
export * from './lib/services/presets';
|
|
267
268
|
export * from './lib/services/skeleton';
|