@xosue-utils/services 0.1.3 → 0.2.0
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 +24 -45
- package/config/services-config.d.ts +3 -0
- package/fesm2022/xosue-utils-services.mjs +400 -16
- package/fesm2022/xosue-utils-services.mjs.map +1 -1
- package/lib/action-sheet/action-sheet-service.component.d.ts +17 -0
- package/lib/action-sheet/action-sheet.service.d.ts +37 -0
- package/lib/alert-service/alert-service.component.d.ts +1 -0
- package/lib/alert-service/alert.service.d.ts +7 -1
- package/lib/copy-feedback/copy-feedback.service.d.ts +11 -0
- package/lib/hotkey/hotkey.service.d.ts +27 -0
- package/lib/index.d.ts +10 -1
- package/lib/network-status/network-status-service.component.d.ts +13 -0
- package/lib/network-status/network-status.service.d.ts +13 -0
- package/lib/scroll-lock/scroll-lock.service.d.ts +17 -0
- package/package.json +10 -10
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { OnDestroy, OnInit } from '@angular/core';
|
|
2
|
+
import { ActionSheetOption, ActionSheetRequest } from './action-sheet.service';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
export declare class ActionSheetServiceComponent implements OnInit, OnDestroy {
|
|
5
|
+
private readonly service;
|
|
6
|
+
private sub;
|
|
7
|
+
private closeSub;
|
|
8
|
+
request: ActionSheetRequest | null;
|
|
9
|
+
ngOnInit(): void;
|
|
10
|
+
ngOnDestroy(): void;
|
|
11
|
+
select(opt: ActionSheetOption): void;
|
|
12
|
+
dismiss(): void;
|
|
13
|
+
mainOptions(options: ActionSheetOption[]): ActionSheetOption[];
|
|
14
|
+
cancelOption(options: ActionSheetOption[]): ActionSheetOption | null;
|
|
15
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ActionSheetServiceComponent, never>;
|
|
16
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<ActionSheetServiceComponent, "action-sheet-service", never, {}, {}, never, never, true, never>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
export interface ActionSheetOption<T = unknown> {
|
|
3
|
+
label: string;
|
|
4
|
+
value: T;
|
|
5
|
+
icon?: string;
|
|
6
|
+
/** Estilo destructivo. */
|
|
7
|
+
danger?: boolean;
|
|
8
|
+
/** Opción de cancelar (suele ir al final). */
|
|
9
|
+
cancel?: boolean;
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface ActionSheetRequest {
|
|
13
|
+
id: number;
|
|
14
|
+
title?: string;
|
|
15
|
+
message?: string;
|
|
16
|
+
options: ActionSheetOption[];
|
|
17
|
+
resolve: (value: ActionSheetOption | null) => void;
|
|
18
|
+
}
|
|
19
|
+
export interface ActionSheetOpenOptions {
|
|
20
|
+
title?: string;
|
|
21
|
+
message?: string;
|
|
22
|
+
}
|
|
23
|
+
export declare class ActionSheetService {
|
|
24
|
+
private platformId;
|
|
25
|
+
private readonly requestSubject;
|
|
26
|
+
readonly request$: import("rxjs").Observable<ActionSheetRequest>;
|
|
27
|
+
private readonly closeSubject;
|
|
28
|
+
readonly close$: import("rxjs").Observable<void>;
|
|
29
|
+
private idCounter;
|
|
30
|
+
private readonly isBrowser;
|
|
31
|
+
private readonly scrollLock;
|
|
32
|
+
constructor(platformId: object);
|
|
33
|
+
open(options: ActionSheetOption[], opts?: ActionSheetOpenOptions): Promise<ActionSheetOption | null>;
|
|
34
|
+
close(): void;
|
|
35
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ActionSheetService, never>;
|
|
36
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<ActionSheetService>;
|
|
37
|
+
}
|
|
@@ -12,6 +12,7 @@ export declare class AlertServiceComponent implements OnInit {
|
|
|
12
12
|
accept(alert: AlertMessage): void;
|
|
13
13
|
cancel(alert: AlertMessage): void;
|
|
14
14
|
trackById(_index: number, item: AlertMessage): number;
|
|
15
|
+
isSheet(alert: AlertMessage): boolean;
|
|
15
16
|
static ɵfac: i0.ɵɵFactoryDeclaration<AlertServiceComponent, never>;
|
|
16
17
|
static ɵcmp: i0.ɵɵComponentDeclaration<AlertServiceComponent, "alert-service", never, {}, {}, never, never, true, never>;
|
|
17
18
|
}
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import * as i0 from "@angular/core";
|
|
2
2
|
export type AlertMode = 'normal' | 'actions';
|
|
3
|
+
export type AlertPresentation = 'card' | 'sheet';
|
|
3
4
|
export type AlertConfirmOptions = {
|
|
4
5
|
/** Se ejecuta en el mismo tick del clic en Aceptar (p. ej. Notification.requestPermission). */
|
|
5
6
|
onAcceptClick?: () => void;
|
|
7
|
+
/** Presentación visual. Default: card centrada. */
|
|
8
|
+
presentation?: AlertPresentation;
|
|
6
9
|
};
|
|
7
10
|
export interface AlertMessage {
|
|
8
11
|
id: number;
|
|
9
12
|
message: string;
|
|
10
13
|
mode: AlertMode;
|
|
14
|
+
presentation: AlertPresentation;
|
|
11
15
|
resolve: (value: boolean) => void;
|
|
12
16
|
onAcceptClick?: () => void;
|
|
13
17
|
}
|
|
@@ -18,8 +22,10 @@ export declare class AlertService {
|
|
|
18
22
|
private idCounter;
|
|
19
23
|
private readonly isBrowser;
|
|
20
24
|
constructor(platformId: object);
|
|
21
|
-
showAlert(message: string): Promise<boolean>;
|
|
25
|
+
showAlert(message: string, presentation?: AlertPresentation): Promise<boolean>;
|
|
22
26
|
showConfirm(message: string, options?: AlertConfirmOptions): Promise<boolean>;
|
|
27
|
+
/** Confirmación estilo Cupertino sheet (desde abajo). */
|
|
28
|
+
showSheetConfirm(message: string, options?: Omit<AlertConfirmOptions, 'presentation'>): Promise<boolean>;
|
|
23
29
|
static ɵfac: i0.ɵɵFactoryDeclaration<AlertService, never>;
|
|
24
30
|
static ɵprov: i0.ɵɵInjectableDeclaration<AlertService>;
|
|
25
31
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
export declare class CopyFeedbackService {
|
|
3
|
+
private readonly isBrowser;
|
|
4
|
+
private readonly toast;
|
|
5
|
+
private readonly config;
|
|
6
|
+
constructor(platformId: object);
|
|
7
|
+
/** Copia texto al portapapeles y muestra toast de feedback. */
|
|
8
|
+
copyText(text: string, successMessage?: string): Promise<boolean>;
|
|
9
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<CopyFeedbackService, never>;
|
|
10
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<CopyFeedbackService>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { OnDestroy } from '@angular/core';
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
export type HotkeyHandler = (event: KeyboardEvent) => void;
|
|
4
|
+
export interface HotkeyRegistration {
|
|
5
|
+
/** Combo tipo "ctrl+k", "meta+s", "escape", "alt+shift+n". */
|
|
6
|
+
combo: string;
|
|
7
|
+
handler: HotkeyHandler;
|
|
8
|
+
/** Si true, evita default del browser. Default true. */
|
|
9
|
+
preventDefault?: boolean;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Registro mínimo de atajos de teclado (global).
|
|
13
|
+
*/
|
|
14
|
+
export declare class HotkeyService implements OnDestroy {
|
|
15
|
+
private readonly isBrowser;
|
|
16
|
+
private readonly map;
|
|
17
|
+
private readonly onKey;
|
|
18
|
+
constructor(platformId: object);
|
|
19
|
+
register(id: string, registration: HotkeyRegistration): void;
|
|
20
|
+
unregister(id: string): void;
|
|
21
|
+
clear(): void;
|
|
22
|
+
ngOnDestroy(): void;
|
|
23
|
+
private handle;
|
|
24
|
+
private matches;
|
|
25
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<HotkeyService, never>;
|
|
26
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<HotkeyService>;
|
|
27
|
+
}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { LucideIconComponent } from './lucide-icon/lucide-icon.component';
|
|
2
2
|
export { AlertService } from './alert-service/alert.service';
|
|
3
|
-
export type { AlertMode, AlertConfirmOptions, AlertMessage } from './alert-service/alert.service';
|
|
3
|
+
export type { AlertMode, AlertPresentation, AlertConfirmOptions, AlertMessage, } from './alert-service/alert.service';
|
|
4
4
|
export { AlertServiceComponent } from './alert-service/alert-service.component';
|
|
5
5
|
export { ToastService } from './toast-service/toast.service';
|
|
6
6
|
export type { ToastType, ToastMessage } from './toast-service/toast.service';
|
|
@@ -28,3 +28,12 @@ export type { AiAutofillOverlayState } from './ai-autofill-overlay-service/ai-au
|
|
|
28
28
|
export { AiAutofillOverlayServiceComponent } from './ai-autofill-overlay-service/ai-autofill-overlay-service.component';
|
|
29
29
|
export { BrowserNotificationService } from './browser-notification/browser-notification.service';
|
|
30
30
|
export type { BrowserNotificationPayload } from './browser-notification/browser-notification.service';
|
|
31
|
+
export { ActionSheetService } from './action-sheet/action-sheet.service';
|
|
32
|
+
export type { ActionSheetOption, ActionSheetRequest, ActionSheetOpenOptions, } from './action-sheet/action-sheet.service';
|
|
33
|
+
export { ActionSheetServiceComponent } from './action-sheet/action-sheet-service.component';
|
|
34
|
+
export { CopyFeedbackService } from './copy-feedback/copy-feedback.service';
|
|
35
|
+
export { NetworkStatusService } from './network-status/network-status.service';
|
|
36
|
+
export { NetworkStatusServiceComponent } from './network-status/network-status-service.component';
|
|
37
|
+
export { ScrollLockService } from './scroll-lock/scroll-lock.service';
|
|
38
|
+
export { HotkeyService } from './hotkey/hotkey.service';
|
|
39
|
+
export type { HotkeyHandler, HotkeyRegistration } from './hotkey/hotkey.service';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { OnDestroy, OnInit } from '@angular/core';
|
|
2
|
+
import { ResolvedXosueUtilsServicesConfig } from '../../config/services-config';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
export declare class NetworkStatusServiceComponent implements OnInit, OnDestroy {
|
|
5
|
+
private readonly network;
|
|
6
|
+
readonly config: ResolvedXosueUtilsServicesConfig;
|
|
7
|
+
readonly online$: any;
|
|
8
|
+
private sub;
|
|
9
|
+
ngOnInit(): void;
|
|
10
|
+
ngOnDestroy(): void;
|
|
11
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<NetworkStatusServiceComponent, never>;
|
|
12
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<NetworkStatusServiceComponent, "network-status-service", never, {}, {}, never, never, true, never>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { OnDestroy } from '@angular/core';
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
export declare class NetworkStatusService implements OnDestroy {
|
|
4
|
+
private readonly isBrowser;
|
|
5
|
+
private readonly onlineSubject;
|
|
6
|
+
private sub;
|
|
7
|
+
readonly online$: any;
|
|
8
|
+
constructor(platformId: object);
|
|
9
|
+
get isOnline(): boolean;
|
|
10
|
+
ngOnDestroy(): void;
|
|
11
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<NetworkStatusService, never>;
|
|
12
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<NetworkStatusService>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
/**
|
|
3
|
+
* Bloqueo de scroll del body para modales/overlays.
|
|
4
|
+
* Contador por clave: varios overlays pueden compartir el lock.
|
|
5
|
+
*/
|
|
6
|
+
export declare class ScrollLockService {
|
|
7
|
+
private readonly locks;
|
|
8
|
+
private readonly isBrowser;
|
|
9
|
+
private prevOverflow;
|
|
10
|
+
constructor(platformId: object);
|
|
11
|
+
lock(key?: string): void;
|
|
12
|
+
unlock(key?: string): void;
|
|
13
|
+
clear(): void;
|
|
14
|
+
get isLocked(): boolean;
|
|
15
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ScrollLockService, never>;
|
|
16
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<ScrollLockService>;
|
|
17
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xosue-utils/services",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Angular 19 root-level overlay services (alert, toast, context-menu, media
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Angular 19 root-level Cupertino overlay services (alert, toast, action-sheet, context-menu, media, loading, network, etc.).",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"private": false,
|
|
7
7
|
"sideEffects": false,
|
|
@@ -18,14 +18,14 @@
|
|
|
18
18
|
"xosue-utils"
|
|
19
19
|
],
|
|
20
20
|
"peerDependencies": {
|
|
21
|
-
"@angular/animations": "
|
|
22
|
-
"@angular/common": "
|
|
23
|
-
"@angular/core": "
|
|
24
|
-
"@angular/forms": "
|
|
25
|
-
"@angular/platform-browser": "
|
|
26
|
-
"@angular/router": "
|
|
27
|
-
"@lucide/angular": "
|
|
28
|
-
"rxjs": "
|
|
21
|
+
"@angular/animations": ">=19.0.0 <21.0.0",
|
|
22
|
+
"@angular/common": ">=19.0.0 <21.0.0",
|
|
23
|
+
"@angular/core": ">=19.0.0 <21.0.0",
|
|
24
|
+
"@angular/forms": ">=19.0.0 <21.0.0",
|
|
25
|
+
"@angular/platform-browser": ">=19.0.0 <21.0.0",
|
|
26
|
+
"@angular/router": ">=19.0.0 <21.0.0",
|
|
27
|
+
"@lucide/angular": ">=0.500.0 <2.0.0",
|
|
28
|
+
"rxjs": ">=7.8.0 <8.0.0"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"tslib": "^2.6.0"
|