valtech-components 4.0.203 → 4.0.205
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/reaction-bar/reaction-bar.component.mjs +326 -0
- package/esm2022/lib/components/molecules/reaction-bar/types.mjs +2 -0
- package/esm2022/lib/components/organisms/toolbar/toolbar.component.mjs +3 -3
- package/esm2022/lib/services/reactions/config.mjs +22 -0
- package/esm2022/lib/services/reactions/index.mjs +3 -0
- package/esm2022/lib/services/reactions/reactions.service.mjs +89 -0
- package/esm2022/lib/services/reactions/types.mjs +2 -0
- package/esm2022/lib/version.mjs +2 -2
- package/esm2022/public-api.mjs +5 -1
- package/fesm2022/valtech-components.mjs +430 -5
- package/fesm2022/valtech-components.mjs.map +1 -1
- package/lib/components/molecules/reaction-bar/reaction-bar.component.d.ts +44 -0
- package/lib/components/molecules/reaction-bar/types.d.ts +55 -0
- package/lib/services/reactions/config.d.ts +20 -0
- package/lib/services/reactions/index.d.ts +3 -0
- package/lib/services/reactions/reactions.service.d.ts +42 -0
- package/lib/services/reactions/types.d.ts +48 -0
- package/lib/version.d.ts +1 -1
- package/package.json +1 -1
- package/public-api.d.ts +3 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { EventEmitter, OnInit } from '@angular/core';
|
|
2
|
+
import { ReactionBarMetadata, ReactionBarEvent, EnrichedReaction } from './types';
|
|
3
|
+
import { ReactionSet } from '../../../services/reactions/types';
|
|
4
|
+
import * as i0 from "@angular/core";
|
|
5
|
+
/**
|
|
6
|
+
* Barra de reacciones emoji configurables por contexto.
|
|
7
|
+
*
|
|
8
|
+
* Muestra un set de emojis y permite al usuario reaccionar a una entidad.
|
|
9
|
+
* Soporta conteos, multiples reacciones y modo picker (popup).
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* html
|
|
13
|
+
* <val-reaction-bar
|
|
14
|
+
* [props]="{
|
|
15
|
+
* entityRef: { entityType: 'post', entityId: 'p1' },
|
|
16
|
+
* reactionSet: mySet,
|
|
17
|
+
* showCounts: true
|
|
18
|
+
* }"
|
|
19
|
+
* (reactionChange)="onReaction($event)"
|
|
20
|
+
* />
|
|
21
|
+
*/
|
|
22
|
+
export declare class ReactionBarComponent implements OnInit {
|
|
23
|
+
props: ReactionBarMetadata;
|
|
24
|
+
reactionChange: EventEmitter<ReactionBarEvent>;
|
|
25
|
+
private reactionsService;
|
|
26
|
+
private i18n;
|
|
27
|
+
protected reactionSet: import("@angular/core").WritableSignal<ReactionSet>;
|
|
28
|
+
protected myReactions: import("@angular/core").WritableSignal<string[]>;
|
|
29
|
+
protected counts: import("@angular/core").WritableSignal<Record<string, number>>;
|
|
30
|
+
protected isLoading: import("@angular/core").WritableSignal<boolean>;
|
|
31
|
+
protected pickerOpen: import("@angular/core").WritableSignal<boolean>;
|
|
32
|
+
protected enrichedReactions: import("@angular/core").Signal<EnrichedReaction[]>;
|
|
33
|
+
constructor();
|
|
34
|
+
ngOnInit(): void;
|
|
35
|
+
private loadSetAndCounts;
|
|
36
|
+
private loadCounts;
|
|
37
|
+
protected onReact(token: string): void;
|
|
38
|
+
protected onReactAndClosePicker(token: string): void;
|
|
39
|
+
protected togglePicker(): void;
|
|
40
|
+
private handleReact;
|
|
41
|
+
protected t(key: string): string;
|
|
42
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ReactionBarComponent, never>;
|
|
43
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<ReactionBarComponent, "val-reaction-bar", never, { "props": { "alias": "props"; "required": false; }; }, { "reactionChange": "reactionChange"; }, never, never, true, never>;
|
|
44
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { ReactionSet } from '../../../services/reactions/types';
|
|
2
|
+
export interface ReactionBarMetadata {
|
|
3
|
+
/** Referencia a la entidad a reaccionar */
|
|
4
|
+
entityRef: {
|
|
5
|
+
entityType: string;
|
|
6
|
+
entityId: string;
|
|
7
|
+
};
|
|
8
|
+
/** ID del set de reacciones a mostrar. Si no se provee, se carga desde el binding. */
|
|
9
|
+
reactionSetId?: string;
|
|
10
|
+
/** Set completo (si ya se tiene, evita fetch) */
|
|
11
|
+
reactionSet?: ReactionSet;
|
|
12
|
+
/** Max reacciones permitidas por usuario: 1=swap, 0=multiples */
|
|
13
|
+
maxReactions?: number;
|
|
14
|
+
/** Tamano visual */
|
|
15
|
+
size?: 'sm' | 'md' | 'lg';
|
|
16
|
+
/** Mostrar conteos numericos junto al emoji */
|
|
17
|
+
showCounts?: boolean;
|
|
18
|
+
/** Layout: row=barra horizontal, picker=popup selector */
|
|
19
|
+
layout?: 'row' | 'picker';
|
|
20
|
+
/** Modo readonly */
|
|
21
|
+
readonly?: boolean;
|
|
22
|
+
/** appId para la API */
|
|
23
|
+
appId?: string;
|
|
24
|
+
/** Reacciones del usuario ya conocidas (evita fetch inicial) */
|
|
25
|
+
initialMyReactions?: string[];
|
|
26
|
+
/** Conteos ya conocidos (evita fetch inicial) */
|
|
27
|
+
initialCounts?: Record<string, number>;
|
|
28
|
+
/** Omitir carga inicial desde API */
|
|
29
|
+
skipInitialLoad?: boolean;
|
|
30
|
+
}
|
|
31
|
+
export interface ReactionBarState {
|
|
32
|
+
reactionSet: ReactionSet | null;
|
|
33
|
+
myReactions: string[];
|
|
34
|
+
counts: Record<string, number>;
|
|
35
|
+
isLoading: boolean;
|
|
36
|
+
error: string | null;
|
|
37
|
+
}
|
|
38
|
+
export interface ReactionBarEvent {
|
|
39
|
+
token: string;
|
|
40
|
+
active: boolean;
|
|
41
|
+
entityRef: {
|
|
42
|
+
entityType: string;
|
|
43
|
+
entityId: string;
|
|
44
|
+
};
|
|
45
|
+
counts: Record<string, number>;
|
|
46
|
+
}
|
|
47
|
+
export interface EnrichedReaction {
|
|
48
|
+
token: string;
|
|
49
|
+
emoji: string;
|
|
50
|
+
label: string;
|
|
51
|
+
icon: string;
|
|
52
|
+
order: number;
|
|
53
|
+
count: number;
|
|
54
|
+
active: boolean;
|
|
55
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { EnvironmentProviders, InjectionToken } from '@angular/core';
|
|
2
|
+
import { ValtechReactionsConfig } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Token de inyeccion para la configuracion del servicio de Reactions.
|
|
5
|
+
*/
|
|
6
|
+
export declare const VALTECH_REACTIONS_CONFIG: InjectionToken<ValtechReactionsConfig>;
|
|
7
|
+
/**
|
|
8
|
+
* Provee el servicio de reactions a la aplicacion Angular.
|
|
9
|
+
*
|
|
10
|
+
* @param config - Configuracion de reactions
|
|
11
|
+
* @returns EnvironmentProviders para usar en bootstrapApplication
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* bootstrapApplication(AppComponent, {
|
|
15
|
+
* providers: [
|
|
16
|
+
* provideValtechReactions({ apiUrl: environment.apiUrl, appId: 'my-app' }),
|
|
17
|
+
* ],
|
|
18
|
+
* });
|
|
19
|
+
*/
|
|
20
|
+
export declare function provideValtechReactions(config: ValtechReactionsConfig): EnvironmentProviders;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { VALTECH_REACTIONS_CONFIG, provideValtechReactions } from './config';
|
|
2
|
+
export { ReactionsService } from './reactions.service';
|
|
3
|
+
export type { ValtechReactionsConfig, ReactionSetContext, ReactionDefinition, ReactionSet, ReactionCounts, ReactRequest, ReactResponse, GetCountsResponse, GetMyReactionsResponse, } from './types';
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Observable } from 'rxjs';
|
|
2
|
+
import { ReactRequest, ReactResponse, GetCountsResponse, ReactionSet } from './types';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
/**
|
|
5
|
+
* Servicio para gestionar reacciones emoji configurables por contexto.
|
|
6
|
+
*
|
|
7
|
+
* Requiere provideValtechReactions() en el bootstrap de la app.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* const svc = inject(ReactionsService);
|
|
11
|
+
* svc.react({ entityRef: { entityType: 'post', entityId: '1' }, token: 'heart', appId: 'app' })
|
|
12
|
+
* .subscribe(res => console.log(res.counts));
|
|
13
|
+
*/
|
|
14
|
+
export declare class ReactionsService {
|
|
15
|
+
private http;
|
|
16
|
+
private config;
|
|
17
|
+
constructor();
|
|
18
|
+
private get apiUrl();
|
|
19
|
+
private get baseUrl();
|
|
20
|
+
/**
|
|
21
|
+
* Toggle reaccion — retorna estado nuevo + conteos actualizados.
|
|
22
|
+
*/
|
|
23
|
+
react(req: ReactRequest): Observable<ReactResponse>;
|
|
24
|
+
/**
|
|
25
|
+
* Conteos + reacciones del usuario para una entidad.
|
|
26
|
+
*/
|
|
27
|
+
getCounts(appId: string, entityType: string, entityId: string): Observable<GetCountsResponse>;
|
|
28
|
+
/**
|
|
29
|
+
* Solo mis tokens activos para una entidad.
|
|
30
|
+
*/
|
|
31
|
+
getMyReactions(appId: string, entityType: string, entityId: string): Observable<string[]>;
|
|
32
|
+
/**
|
|
33
|
+
* Obtener un set de reacciones por ID.
|
|
34
|
+
*/
|
|
35
|
+
getSet(setId: string): Observable<ReactionSet>;
|
|
36
|
+
/**
|
|
37
|
+
* Listar todos los sets disponibles para una app.
|
|
38
|
+
*/
|
|
39
|
+
listSets(appId: string): Observable<ReactionSet[]>;
|
|
40
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ReactionsService, never>;
|
|
41
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<ReactionsService>;
|
|
42
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export type ReactionSetContext = 'formal' | 'social' | 'celebration' | 'opinion' | 'custom';
|
|
2
|
+
export interface ReactionDefinition {
|
|
3
|
+
token: string;
|
|
4
|
+
emoji: string;
|
|
5
|
+
label: string;
|
|
6
|
+
icon: string;
|
|
7
|
+
order: number;
|
|
8
|
+
}
|
|
9
|
+
export interface ReactionSet {
|
|
10
|
+
setId: string;
|
|
11
|
+
appId: string;
|
|
12
|
+
name: string;
|
|
13
|
+
context: ReactionSetContext;
|
|
14
|
+
reactions: ReactionDefinition[];
|
|
15
|
+
isPreset: boolean;
|
|
16
|
+
createdAt: string;
|
|
17
|
+
updatedAt: string;
|
|
18
|
+
}
|
|
19
|
+
export interface ReactionCounts {
|
|
20
|
+
counts: Record<string, number>;
|
|
21
|
+
}
|
|
22
|
+
export interface ReactRequest {
|
|
23
|
+
entityRef: {
|
|
24
|
+
entityType: string;
|
|
25
|
+
entityId: string;
|
|
26
|
+
};
|
|
27
|
+
token: string;
|
|
28
|
+
appId: string;
|
|
29
|
+
}
|
|
30
|
+
export interface ReactResponse {
|
|
31
|
+
operationId: string;
|
|
32
|
+
token: string;
|
|
33
|
+
active: boolean;
|
|
34
|
+
counts: Record<string, number>;
|
|
35
|
+
}
|
|
36
|
+
export interface GetCountsResponse {
|
|
37
|
+
operationId: string;
|
|
38
|
+
counts: Record<string, number>;
|
|
39
|
+
myReactions: string[];
|
|
40
|
+
}
|
|
41
|
+
export interface GetMyReactionsResponse {
|
|
42
|
+
operationId: string;
|
|
43
|
+
tokens: string[];
|
|
44
|
+
}
|
|
45
|
+
export interface ValtechReactionsConfig {
|
|
46
|
+
apiUrl: string;
|
|
47
|
+
appId?: string;
|
|
48
|
+
}
|
package/lib/version.d.ts
CHANGED
package/package.json
CHANGED
package/public-api.d.ts
CHANGED
|
@@ -410,6 +410,9 @@ export * from './lib/components/molecules/request-form/request-form.component';
|
|
|
410
410
|
export * from './lib/components/molecules/request-form/types';
|
|
411
411
|
export * from './lib/components/molecules/content-reaction/content-reaction.component';
|
|
412
412
|
export * from './lib/components/molecules/content-reaction/types';
|
|
413
|
+
export * from './lib/services/reactions/index';
|
|
414
|
+
export * from './lib/components/molecules/reaction-bar/reaction-bar.component';
|
|
415
|
+
export * from './lib/components/molecules/reaction-bar/types';
|
|
413
416
|
export * from './lib/services/splash-screen';
|
|
414
417
|
export * from './lib/services/haptics';
|
|
415
418
|
export * from './lib/components/templates/docs-layout/docs-layout.component';
|