@memberjunction/ng-entity-card 0.0.1 → 5.25.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.
@@ -0,0 +1,171 @@
1
+ import { EventEmitter, OnChanges, SimpleChanges } from '@angular/core';
2
+ import { EntityInfo } from '@memberjunction/core';
3
+ import { EntityCardVariant, CardTemplate, CardDisplayField, CancelableCardEvent, CardRecordEvent } from './entity-card.types';
4
+ import * as i0 from "@angular/core";
5
+ /**
6
+ * `MJEntityCardComponent` — A generic, metadata-driven entity record card.
7
+ *
8
+ * Renders a single entity record as a visual card with automatically prioritized
9
+ * fields based on MemberJunction entity metadata (`IsNameField`, `DefaultInView`,
10
+ * `Sequence`). Designed to work with both full entity records and sparse vector
11
+ * metadata from the Knowledge Hub.
12
+ *
13
+ * ## Variants
14
+ * - `compact` — Tooltip-sized. Title + 2-3 key fields. No avatar.
15
+ * - `card` — Grid card. Avatar + title + subtitle + display fields + badge.
16
+ * - `detail` — Full panel. All available fields with labels.
17
+ *
18
+ * ## Field Resolution
19
+ * 1. **Title**: All `IsNameField` fields combined in Sequence order
20
+ * 2. **Primary fields**: `DefaultInView=true` sorted by Sequence
21
+ * 3. **Fallback**: First 5 non-PK/FK fields when no metadata flags are set
22
+ *
23
+ * ## Events
24
+ * All interactions follow the `BeforeXXX` / `AfterXXX` cancelable event pattern.
25
+ * Set `event.Cancel = true` in a `BeforeXXX` handler to prevent the default action.
26
+ *
27
+ * @example
28
+ * ```html
29
+ * <!-- From entity name + vector metadata -->
30
+ * <mj-entity-card
31
+ * [EntityName]="'Members'"
32
+ * [Record]="vectorMetadata"
33
+ * Variant="card"
34
+ * (CardClicked)="onCardClick($event)">
35
+ * </mj-entity-card>
36
+ *
37
+ * <!-- From EntityInfo + full record -->
38
+ * <mj-entity-card
39
+ * [Entity]="entityInfo"
40
+ * [Record]="record.GetAll()"
41
+ * Variant="detail"
42
+ * [ShowOpenButton]="true"
43
+ * (OpenRequested)="onOpen($event)">
44
+ * </mj-entity-card>
45
+ * ```
46
+ *
47
+ * @selector mj-entity-card
48
+ */
49
+ export declare class MJEntityCardComponent implements OnChanges {
50
+ private cdr;
51
+ /**
52
+ * The entity name (e.g., "Members"). Used to look up `EntityInfo` from
53
+ * the MJ Metadata cache. Mutually exclusive with `Entity` — if both are
54
+ * provided, `Entity` takes precedence.
55
+ */
56
+ EntityName: string | null;
57
+ /**
58
+ * Pre-resolved EntityInfo object. Takes precedence over `EntityName`.
59
+ * Use this when you already have the EntityInfo to avoid a redundant lookup.
60
+ */
61
+ Entity: EntityInfo | null;
62
+ /**
63
+ * The record data as a plain key-value object. Works with both full entity
64
+ * records (`record.GetAll()`) and sparse vector metadata.
65
+ *
66
+ * Fields not present in the record are gracefully skipped in the display.
67
+ */
68
+ Record: Record<string, unknown>;
69
+ /**
70
+ * Visual variant controlling size, layout, and detail level.
71
+ * @default 'card'
72
+ */
73
+ Variant: EntityCardVariant;
74
+ /**
75
+ * Custom card template. When provided, overrides the auto-generated template.
76
+ * Use `GenerateCardTemplate()` from the types module to build one programmatically.
77
+ */
78
+ Template: CardTemplate | null;
79
+ /**
80
+ * Maximum number of display fields in the card body.
81
+ * Only applies when using the auto-generated template.
82
+ * @default 4 for 'card', 2 for 'compact', unlimited for 'detail'
83
+ */
84
+ MaxDisplayFields: number | null;
85
+ /**
86
+ * Whether to show the entity icon/avatar.
87
+ * @default true for 'card', false for 'compact', true for 'detail'
88
+ */
89
+ ShowAvatar: boolean | null;
90
+ /**
91
+ * Whether to show the "Open Record" button.
92
+ * @default false
93
+ */
94
+ ShowOpenButton: boolean;
95
+ /**
96
+ * Whether to show field labels alongside values.
97
+ * @default true for 'detail', false for 'compact', true for 'card'
98
+ */
99
+ ShowFieldLabels: boolean | null;
100
+ /**
101
+ * CSS class to apply to the outer container for custom styling.
102
+ */
103
+ CssClass: string;
104
+ /**
105
+ * Fires before the card is clicked. Set `Cancel = true` to prevent
106
+ * the `CardClicked` event from firing.
107
+ */
108
+ BeforeCardClick: EventEmitter<CancelableCardEvent<CardRecordEvent>>;
109
+ /** Fires after the card is clicked (if not canceled). */
110
+ CardClicked: EventEmitter<CardRecordEvent>;
111
+ /**
112
+ * Fires before the "Open Record" button is clicked. Set `Cancel = true`
113
+ * to prevent the `OpenRequested` event from firing.
114
+ */
115
+ BeforeOpen: EventEmitter<CancelableCardEvent<CardRecordEvent>>;
116
+ /** Fires when the "Open Record" button is clicked (if not canceled). */
117
+ OpenRequested: EventEmitter<CardRecordEvent>;
118
+ /** The resolved EntityInfo (from Entity input or EntityName lookup) */
119
+ ResolvedEntity: EntityInfo | null;
120
+ /** The effective card template (custom or auto-generated) */
121
+ EffectiveTemplate: CardTemplate | null;
122
+ /** The combined title string */
123
+ Title: string;
124
+ /** The entity icon class (from vector metadata or entity info) */
125
+ EntityIcon: string;
126
+ /** Resolved entity display name */
127
+ EntityDisplayName: string;
128
+ ngOnChanges(changes: SimpleChanges): void;
129
+ /** @internal Handle card click with cancelable before/after pattern */
130
+ OnCardClick(): void;
131
+ /** @internal Handle open button click with cancelable before/after pattern */
132
+ OnOpenClick(event: MouseEvent): void;
133
+ /** Get the resolved display fields, respecting maxFields for variant */
134
+ get DisplayFields(): CardDisplayField[];
135
+ /** Whether to show the avatar based on variant and input */
136
+ get ShouldShowAvatar(): boolean;
137
+ /** Whether to show field labels based on variant and input */
138
+ get ShouldShowLabels(): boolean;
139
+ /** Get formatted value for a display field */
140
+ GetFieldValue(field: CardDisplayField): string;
141
+ /** Get the label for a field */
142
+ GetFieldLabel(fieldName: string): string;
143
+ /** Get initials from the title for avatar fallback */
144
+ get Initials(): string;
145
+ /** Get a deterministic color for the avatar based on the record */
146
+ get AvatarColor(): string;
147
+ /** Get the subtitle value */
148
+ get Subtitle(): string;
149
+ /** Get the description value */
150
+ get Description(): string;
151
+ /** Check if a thumbnail is available */
152
+ get HasThumbnail(): boolean;
153
+ /** Get the thumbnail URL or icon class */
154
+ get ThumbnailValue(): string;
155
+ /** Whether the thumbnail is an image URL */
156
+ get ThumbnailIsImage(): boolean;
157
+ /** Whether the thumbnail is an icon class */
158
+ get ThumbnailIsIcon(): boolean;
159
+ private get ResolvedMaxFields();
160
+ private resolve;
161
+ private resolveEntity;
162
+ private resolveTemplate;
163
+ private resolveTitle;
164
+ private resolveEntityIcon;
165
+ private resolveEntityDisplayName;
166
+ private FormatValue;
167
+ private BuildEventPayload;
168
+ static ɵfac: i0.ɵɵFactoryDeclaration<MJEntityCardComponent, never>;
169
+ static ɵcmp: i0.ɵɵComponentDeclaration<MJEntityCardComponent, "mj-entity-card", never, { "EntityName": { "alias": "EntityName"; "required": false; }; "Entity": { "alias": "Entity"; "required": false; }; "Record": { "alias": "Record"; "required": false; }; "Variant": { "alias": "Variant"; "required": false; }; "Template": { "alias": "Template"; "required": false; }; "MaxDisplayFields": { "alias": "MaxDisplayFields"; "required": false; }; "ShowAvatar": { "alias": "ShowAvatar"; "required": false; }; "ShowOpenButton": { "alias": "ShowOpenButton"; "required": false; }; "ShowFieldLabels": { "alias": "ShowFieldLabels"; "required": false; }; "CssClass": { "alias": "CssClass"; "required": false; }; }, { "BeforeCardClick": "BeforeCardClick"; "CardClicked": "CardClicked"; "BeforeOpen": "BeforeOpen"; "OpenRequested": "OpenRequested"; }, never, never, true, never>;
170
+ }
171
+ //# sourceMappingURL=entity-card.component.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entity-card.component.d.ts","sourceRoot":"","sources":["../../src/lib/entity-card.component.ts"],"names":[],"mappings":"AAAA,OAAO,EACuB,YAAY,EACtC,SAAS,EAAE,aAAa,EAC3B,MAAM,eAAe,CAAC;AACvB,OAAO,EAAY,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EACH,iBAAiB,EAAE,YAAY,EAAE,gBAAgB,EACjD,mBAAmB,EAAE,eAAe,EAGvC,MAAM,qBAAqB,CAAC;;AAE7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2C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