@bbq-chat/widgets-angular 1.0.0 → 1.0.2
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/dist/fesm2022/index.mjs +542 -0
- package/dist/fesm2022/index.mjs.map +1 -0
- package/dist/types/index.d.ts +335 -0
- package/package.json +22 -38
- package/dist/LICENSE +0 -21
- package/dist/custom-widget-renderer.types.d.ts +0 -79
- package/dist/custom-widget-renderer.types.d.ts.map +0 -1
- package/dist/custom-widget-renderer.types.js +0 -43
- package/dist/custom-widget-renderer.types.js.map +0 -1
- package/dist/index.cjs +0 -38
- package/dist/index.d.ts +0 -20
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -23
- package/dist/index.js.map +0 -1
- package/dist/package.json +0 -16
- package/dist/widget-registry.service.d.ts +0 -95
- package/dist/widget-registry.service.d.ts.map +0 -1
- package/dist/widget-registry.service.js +0 -129
- package/dist/widget-registry.service.js.map +0 -1
- package/dist/widget-renderer.component.d.ts +0 -93
- package/dist/widget-renderer.component.d.ts.map +0 -1
- package/dist/widget-renderer.component.js +0 -316
- package/dist/widget-renderer.component.js.map +0 -1
- package/src/custom-widget-renderer.types.ts +0 -120
- package/src/index.ts +0 -65
- package/src/widget-registry.service.ts +0 -128
- package/src/widget-renderer.component.ts +0 -384
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { Type, TemplateRef, InjectionToken, OnInit, AfterViewInit, OnDestroy, OnChanges, Injector, EnvironmentInjector, EventEmitter, ElementRef, ComponentRef, EmbeddedViewRef, SimpleChanges } from '@angular/core';
|
|
3
|
+
import { ChatWidget, IWidgetActionHandler, WidgetEventManager, SsrWidgetRenderer } from '@bbq-chat/widgets';
|
|
4
|
+
export { ButtonWidget, CardWidget, ChatWidget, DatePickerWidget, DropdownWidget, FileUploadWidget, FormWidget, ImageCollectionWidget, ImageWidget, InputWidget, MultiSelectWidget, ProgressBarWidget, SliderWidget, SsrWidgetRenderer, TextAreaWidget, ThemeSwitcherWidget, ToggleWidget, WidgetEventManager, customWidgetRegistry } from '@bbq-chat/widgets';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Context provided to template-based custom widget renderers
|
|
8
|
+
*/
|
|
9
|
+
interface WidgetTemplateContext {
|
|
10
|
+
/**
|
|
11
|
+
* The widget instance being rendered
|
|
12
|
+
*/
|
|
13
|
+
$implicit: ChatWidget;
|
|
14
|
+
/**
|
|
15
|
+
* The widget instance (alternative access)
|
|
16
|
+
*/
|
|
17
|
+
widget: ChatWidget;
|
|
18
|
+
/**
|
|
19
|
+
* Emit a widget action
|
|
20
|
+
*/
|
|
21
|
+
emitAction: (actionName: string, payload: unknown) => void;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Interface for component-based custom widget renderers
|
|
25
|
+
*/
|
|
26
|
+
interface CustomWidgetComponent {
|
|
27
|
+
/**
|
|
28
|
+
* The widget instance to render
|
|
29
|
+
*/
|
|
30
|
+
widget: ChatWidget;
|
|
31
|
+
/**
|
|
32
|
+
* Event emitter for widget actions (optional, will be set by the renderer)
|
|
33
|
+
*/
|
|
34
|
+
widgetAction?: (actionName: string, payload: unknown) => void;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Type for custom widget renderer functions that return HTML strings
|
|
38
|
+
*/
|
|
39
|
+
type CustomWidgetHtmlRenderer = (widget: ChatWidget) => string;
|
|
40
|
+
/**
|
|
41
|
+
* Type for custom widget renderer configurations
|
|
42
|
+
*/
|
|
43
|
+
type CustomWidgetRenderer = CustomWidgetHtmlRenderer | Type<CustomWidgetComponent> | TemplateRef<WidgetTemplateContext>;
|
|
44
|
+
/**
|
|
45
|
+
* Configuration for registering a custom widget renderer
|
|
46
|
+
*/
|
|
47
|
+
interface CustomWidgetRendererConfig {
|
|
48
|
+
/**
|
|
49
|
+
* The widget type identifier
|
|
50
|
+
*/
|
|
51
|
+
type: string;
|
|
52
|
+
/**
|
|
53
|
+
* The renderer: can be a function returning HTML, an Angular Component class, or a TemplateRef
|
|
54
|
+
*/
|
|
55
|
+
renderer: CustomWidgetRenderer;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Type guard to check if a renderer is a TemplateRef
|
|
59
|
+
*/
|
|
60
|
+
declare function isTemplateRenderer(renderer: CustomWidgetRenderer): renderer is TemplateRef<WidgetTemplateContext>;
|
|
61
|
+
/**
|
|
62
|
+
* Type guard to check if a renderer is an Angular Component
|
|
63
|
+
*
|
|
64
|
+
* Note: This uses a heuristic check based on the following assumptions:
|
|
65
|
+
* 1. Components are constructor functions
|
|
66
|
+
* 2. Components have a prototype with a constructor property
|
|
67
|
+
* 3. Components typically use dependency injection (no required constructor params)
|
|
68
|
+
*
|
|
69
|
+
* Limitation: This may not detect components with required constructor parameters.
|
|
70
|
+
* For edge cases, explicitly check your component's constructor signature.
|
|
71
|
+
*
|
|
72
|
+
* Alternative: You can always register a wrapper component that has no required params.
|
|
73
|
+
*/
|
|
74
|
+
declare function isComponentRenderer(renderer: CustomWidgetRenderer): renderer is Type<CustomWidgetComponent>;
|
|
75
|
+
/**
|
|
76
|
+
* Type guard to check if a renderer is an HTML function
|
|
77
|
+
*
|
|
78
|
+
* Note: This should be checked AFTER checking for component and template renderers
|
|
79
|
+
* since components are also functions but with additional properties.
|
|
80
|
+
*/
|
|
81
|
+
declare function isHtmlRenderer(renderer: CustomWidgetRenderer): renderer is CustomWidgetHtmlRenderer;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Service for registering custom widget factories and renderers
|
|
85
|
+
*
|
|
86
|
+
* This service provides a centralized way to register custom widget types
|
|
87
|
+
* that extend the base widget functionality, including support for
|
|
88
|
+
* Angular components and templates as custom renderers.
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* ```typescript
|
|
92
|
+
* constructor(private widgetRegistry: WidgetRegistryService) {
|
|
93
|
+
* // Register a widget factory
|
|
94
|
+
* this.widgetRegistry.registerFactory('myWidget', (obj) => {
|
|
95
|
+
* if (obj.type === 'myWidget') {
|
|
96
|
+
* return new MyCustomWidget(obj.label, obj.action);
|
|
97
|
+
* }
|
|
98
|
+
* return null;
|
|
99
|
+
* });
|
|
100
|
+
*
|
|
101
|
+
* // Register a component-based renderer
|
|
102
|
+
* this.widgetRegistry.registerRenderer('myWidget', MyWidgetComponent);
|
|
103
|
+
* }
|
|
104
|
+
* ```
|
|
105
|
+
*/
|
|
106
|
+
declare class WidgetRegistryService {
|
|
107
|
+
private readonly customRenderers;
|
|
108
|
+
/**
|
|
109
|
+
* Register a custom widget factory function
|
|
110
|
+
*
|
|
111
|
+
* @param type - The widget type identifier
|
|
112
|
+
* @param factory - Factory function that creates widget instances from plain objects
|
|
113
|
+
*/
|
|
114
|
+
registerFactory(type: string, factory: (obj: unknown) => ChatWidget | null): void;
|
|
115
|
+
/**
|
|
116
|
+
* Register a widget class with automatic factory creation
|
|
117
|
+
*
|
|
118
|
+
* @param type - The widget type identifier
|
|
119
|
+
* @param ctor - Widget class constructor
|
|
120
|
+
*/
|
|
121
|
+
registerClass(type: string, ctor: any): void;
|
|
122
|
+
/**
|
|
123
|
+
* Get a factory for a specific widget type
|
|
124
|
+
*
|
|
125
|
+
* @param type - The widget type identifier
|
|
126
|
+
* @returns The factory function if registered, undefined otherwise
|
|
127
|
+
*/
|
|
128
|
+
getFactory(type: string): ((obj: any) => ChatWidget | null) | undefined;
|
|
129
|
+
/**
|
|
130
|
+
* Register a custom renderer for a specific widget type
|
|
131
|
+
*
|
|
132
|
+
* The renderer can be:
|
|
133
|
+
* - A function that returns HTML string
|
|
134
|
+
* - An Angular Component class
|
|
135
|
+
* - An Angular TemplateRef
|
|
136
|
+
*
|
|
137
|
+
* @param type - The widget type identifier
|
|
138
|
+
* @param renderer - The custom renderer (function, Component, or TemplateRef)
|
|
139
|
+
*
|
|
140
|
+
* @example
|
|
141
|
+
* ```typescript
|
|
142
|
+
* // HTML function renderer
|
|
143
|
+
* widgetRegistry.registerRenderer('weather', (widget) => `<div>${widget.label}</div>`);
|
|
144
|
+
*
|
|
145
|
+
* // Component renderer
|
|
146
|
+
* widgetRegistry.registerRenderer('weather', WeatherWidgetComponent);
|
|
147
|
+
*
|
|
148
|
+
* // Template renderer (from @ViewChild or elsewhere)
|
|
149
|
+
* widgetRegistry.registerRenderer('weather', this.weatherTemplate);
|
|
150
|
+
* ```
|
|
151
|
+
*/
|
|
152
|
+
registerRenderer(type: string, renderer: CustomWidgetRenderer): void;
|
|
153
|
+
/**
|
|
154
|
+
* Get a custom renderer for a specific widget type
|
|
155
|
+
*
|
|
156
|
+
* @param type - The widget type identifier
|
|
157
|
+
* @returns The custom renderer if registered, undefined otherwise
|
|
158
|
+
*/
|
|
159
|
+
getRenderer(type: string): CustomWidgetRenderer | undefined;
|
|
160
|
+
/**
|
|
161
|
+
* Check if a custom renderer is registered for a widget type
|
|
162
|
+
*
|
|
163
|
+
* @param type - The widget type identifier
|
|
164
|
+
* @returns True if a custom renderer is registered, false otherwise
|
|
165
|
+
*/
|
|
166
|
+
hasRenderer(type: string): boolean;
|
|
167
|
+
/**
|
|
168
|
+
* Unregister a custom renderer for a widget type
|
|
169
|
+
*
|
|
170
|
+
* @param type - The widget type identifier
|
|
171
|
+
* @returns True if a renderer was removed, false if none was registered
|
|
172
|
+
*/
|
|
173
|
+
unregisterRenderer(type: string): boolean;
|
|
174
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<WidgetRegistryService, never>;
|
|
175
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<WidgetRegistryService>;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Injection token for WidgetEventManager factory
|
|
180
|
+
*
|
|
181
|
+
* Use this token to inject a factory function that creates WidgetEventManager instances.
|
|
182
|
+
* The factory accepts an optional action handler to configure the manager.
|
|
183
|
+
*
|
|
184
|
+
* @example
|
|
185
|
+
* ```typescript
|
|
186
|
+
* constructor(@Inject(WIDGET_EVENT_MANAGER_FACTORY) private eventManagerFactory: WidgetEventManagerFactory) {
|
|
187
|
+
* const actionHandler = { handle: async (action, payload) => { ... } };
|
|
188
|
+
* this.eventManager = this.eventManagerFactory(actionHandler);
|
|
189
|
+
* }
|
|
190
|
+
* ```
|
|
191
|
+
*/
|
|
192
|
+
type WidgetEventManagerFactory = (actionHandler?: IWidgetActionHandler) => WidgetEventManager;
|
|
193
|
+
declare const WIDGET_EVENT_MANAGER_FACTORY: InjectionToken<WidgetEventManagerFactory>;
|
|
194
|
+
/**
|
|
195
|
+
* Injection token for SsrWidgetRenderer
|
|
196
|
+
*
|
|
197
|
+
* Use this token to inject a SsrWidgetRenderer instance in your components.
|
|
198
|
+
* By default, WidgetRendererComponent provides this token with a factory that creates
|
|
199
|
+
* a new instance for each component.
|
|
200
|
+
*
|
|
201
|
+
* @example
|
|
202
|
+
* ```typescript
|
|
203
|
+
* constructor(@Inject(SSR_WIDGET_RENDERER) private renderer: SsrWidgetRenderer) {}
|
|
204
|
+
* ```
|
|
205
|
+
*/
|
|
206
|
+
declare const SSR_WIDGET_RENDERER: InjectionToken<SsrWidgetRenderer>;
|
|
207
|
+
/**
|
|
208
|
+
* Factory function for creating WidgetEventManager instances
|
|
209
|
+
*
|
|
210
|
+
* This factory is used by default in WidgetRendererComponent's providers array.
|
|
211
|
+
* You can override this in your own providers if you need custom initialization.
|
|
212
|
+
*
|
|
213
|
+
* @returns A factory function that creates WidgetEventManager instances
|
|
214
|
+
*/
|
|
215
|
+
declare function widgetEventManagerFactoryProvider(): WidgetEventManagerFactory;
|
|
216
|
+
/**
|
|
217
|
+
* Factory function for creating SsrWidgetRenderer instances
|
|
218
|
+
*
|
|
219
|
+
* This factory is used by default in WidgetRendererComponent's providers array.
|
|
220
|
+
* You can override this in your own providers if you need custom initialization
|
|
221
|
+
* or custom rendering options.
|
|
222
|
+
*
|
|
223
|
+
* @returns A new SsrWidgetRenderer instance
|
|
224
|
+
*/
|
|
225
|
+
declare function ssrWidgetRendererFactory(): SsrWidgetRenderer;
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Angular component for rendering chat widgets
|
|
229
|
+
*
|
|
230
|
+
* This component handles rendering of chat widgets using the BbQ ChatWidgets library.
|
|
231
|
+
* It manages widget lifecycle, event handling, and cleanup.
|
|
232
|
+
*
|
|
233
|
+
* Supports three types of custom widget renderers:
|
|
234
|
+
* 1. HTML function renderers (return HTML strings)
|
|
235
|
+
* 2. Angular Component renderers (render as dynamic components)
|
|
236
|
+
* 3. Angular TemplateRef renderers (render as embedded views)
|
|
237
|
+
*
|
|
238
|
+
* @example
|
|
239
|
+
* ```typescript
|
|
240
|
+
* <bbq-widget-renderer
|
|
241
|
+
* [widgets]="messageWidgets"
|
|
242
|
+
* (widgetAction)="handleWidgetAction($event)">
|
|
243
|
+
* </bbq-widget-renderer>
|
|
244
|
+
* ```
|
|
245
|
+
*/
|
|
246
|
+
declare class WidgetRendererComponent implements OnInit, AfterViewInit, OnDestroy, OnChanges {
|
|
247
|
+
protected renderer: SsrWidgetRenderer;
|
|
248
|
+
protected eventManagerFactory: WidgetEventManagerFactory;
|
|
249
|
+
protected widgetRegistry: WidgetRegistryService;
|
|
250
|
+
protected injector: Injector;
|
|
251
|
+
protected environmentInjector: EnvironmentInjector;
|
|
252
|
+
/**
|
|
253
|
+
* Array of widgets to render
|
|
254
|
+
*/
|
|
255
|
+
widgets: ChatWidget[] | null | undefined;
|
|
256
|
+
/**
|
|
257
|
+
* Emits when a widget action is triggered
|
|
258
|
+
*/
|
|
259
|
+
widgetAction: EventEmitter<{
|
|
260
|
+
actionName: string;
|
|
261
|
+
payload: unknown;
|
|
262
|
+
}>;
|
|
263
|
+
containerRef: ElementRef<HTMLDivElement>;
|
|
264
|
+
protected widgetItems: Array<{
|
|
265
|
+
index: number;
|
|
266
|
+
widget: ChatWidget;
|
|
267
|
+
isHtml: boolean;
|
|
268
|
+
html?: string;
|
|
269
|
+
}>;
|
|
270
|
+
protected eventManager?: WidgetEventManager;
|
|
271
|
+
protected isViewInitialized: boolean;
|
|
272
|
+
protected dynamicComponents: Array<ComponentRef<any>>;
|
|
273
|
+
protected dynamicViews: Array<EmbeddedViewRef<WidgetTemplateContext>>;
|
|
274
|
+
constructor(renderer: SsrWidgetRenderer, eventManagerFactory: WidgetEventManagerFactory, widgetRegistry: WidgetRegistryService, injector: Injector, environmentInjector: EnvironmentInjector);
|
|
275
|
+
ngOnInit(): void;
|
|
276
|
+
ngOnChanges(changes: SimpleChanges): void;
|
|
277
|
+
ngAfterViewInit(): void;
|
|
278
|
+
ngOnDestroy(): void;
|
|
279
|
+
/**
|
|
280
|
+
* Base implementation for updating the rendered HTML for the current widgets.
|
|
281
|
+
*
|
|
282
|
+
* Subclasses may override this method to customize how widgets are rendered
|
|
283
|
+
* (for example, to inject additional markup or perform preprocessing).
|
|
284
|
+
*
|
|
285
|
+
* Since this is the base implementation, overriding implementations are not
|
|
286
|
+
* required to call `super.updateWidgetHtml()`.
|
|
287
|
+
*/
|
|
288
|
+
protected updateWidgetHtml(): void;
|
|
289
|
+
/**
|
|
290
|
+
* Render dynamic components and templates for custom widgets
|
|
291
|
+
*/
|
|
292
|
+
protected renderDynamicWidgets(): void;
|
|
293
|
+
/**
|
|
294
|
+
* Render an Angular component for a custom widget
|
|
295
|
+
*
|
|
296
|
+
* Note: This method safely assigns properties to component instances
|
|
297
|
+
* by checking for property existence at runtime. This approach is necessary
|
|
298
|
+
* because we cannot statically verify that all components implement
|
|
299
|
+
* the CustomWidgetComponent interface.
|
|
300
|
+
*/
|
|
301
|
+
protected renderComponent(componentType: any, widget: ChatWidget, targetElement: HTMLElement): void;
|
|
302
|
+
/**
|
|
303
|
+
* Render an Angular template for a custom widget
|
|
304
|
+
*/
|
|
305
|
+
protected renderTemplate(templateRef: TemplateRef<WidgetTemplateContext>, widget: ChatWidget, targetElement: HTMLElement): void;
|
|
306
|
+
/**
|
|
307
|
+
* Cleanup dynamic components and views
|
|
308
|
+
*/
|
|
309
|
+
protected cleanupDynamicWidgets(): void;
|
|
310
|
+
private setupEventHandlers;
|
|
311
|
+
handleClick(event: MouseEvent): void;
|
|
312
|
+
/**
|
|
313
|
+
* Cleanup all resources including event listeners.
|
|
314
|
+
*/
|
|
315
|
+
private cleanup;
|
|
316
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<WidgetRendererComponent, never>;
|
|
317
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<WidgetRendererComponent, "bbq-widget-renderer", never, { "widgets": { "alias": "widgets"; "required": false; }; }, { "widgetAction": "widgetAction"; }, never, never, true, never>;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* @bbq-chat/widgets-angular
|
|
322
|
+
*
|
|
323
|
+
* Angular components and services for BbQ ChatWidgets
|
|
324
|
+
*
|
|
325
|
+
* This package provides Angular-native components and services that wrap
|
|
326
|
+
* the core @bbq-chat/widgets library, making it easy to integrate chat
|
|
327
|
+
* widgets into Angular applications.
|
|
328
|
+
*
|
|
329
|
+
* @packageDocumentation
|
|
330
|
+
*/
|
|
331
|
+
|
|
332
|
+
declare const VERSION = "1.0.2";
|
|
333
|
+
|
|
334
|
+
export { SSR_WIDGET_RENDERER, VERSION, WIDGET_EVENT_MANAGER_FACTORY, WidgetRegistryService, WidgetRendererComponent, isComponentRenderer, isHtmlRenderer, isTemplateRenderer, ssrWidgetRendererFactory, widgetEventManagerFactoryProvider };
|
|
335
|
+
export type { CustomWidgetComponent, CustomWidgetHtmlRenderer, CustomWidgetRenderer, CustomWidgetRendererConfig, WidgetEventManagerFactory, WidgetTemplateContext };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bbq-chat/widgets-angular",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Angular components and services for BbQ ChatWidgets",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "BbQ ChatWidgets Contributors",
|
|
@@ -21,54 +21,38 @@
|
|
|
21
21
|
"components",
|
|
22
22
|
"bbq-chat"
|
|
23
23
|
],
|
|
24
|
-
"
|
|
25
|
-
"main": "./dist/index.js",
|
|
26
|
-
"module": "./dist/index.js",
|
|
27
|
-
"types": "./dist/index.d.ts",
|
|
28
|
-
"exports": {
|
|
29
|
-
".": {
|
|
30
|
-
"import": "./dist/index.js",
|
|
31
|
-
"require": "./dist/index.cjs",
|
|
32
|
-
"types": "./dist/index.d.ts"
|
|
33
|
-
}
|
|
34
|
-
},
|
|
24
|
+
"sideEffects": false,
|
|
35
25
|
"files": [
|
|
36
26
|
"dist",
|
|
37
|
-
"src",
|
|
38
27
|
"README.md",
|
|
39
28
|
"LICENSE"
|
|
40
29
|
],
|
|
41
30
|
"scripts": {
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"format": "prettier --write \"src/**/*.ts\"",
|
|
48
|
-
"type-check": "tsc --noEmit",
|
|
49
|
-
"prepublishOnly": "npm run build && npm run lint"
|
|
31
|
+
"ng": "ng",
|
|
32
|
+
"start": "ng serve",
|
|
33
|
+
"build": "ng build",
|
|
34
|
+
"watch": "ng build --watch --configuration development",
|
|
35
|
+
"test": "ng test"
|
|
50
36
|
},
|
|
37
|
+
"packageManager": "npm@10.9.0",
|
|
51
38
|
"peerDependencies": {
|
|
52
|
-
"@angular/common": "
|
|
53
|
-
"@angular/
|
|
39
|
+
"@angular/common": "^21.0.0",
|
|
40
|
+
"@angular/compiler": "^21.0.0",
|
|
41
|
+
"@angular/core": "^21.0.0",
|
|
42
|
+
"@angular/forms": "^21.0.0",
|
|
43
|
+
"@angular/platform-browser": "^21.0.0",
|
|
44
|
+
"@angular/router": "^21.0.0",
|
|
45
|
+
"rxjs": "~7.8.0",
|
|
54
46
|
"@bbq-chat/widgets": "^1.0.0"
|
|
55
47
|
},
|
|
56
48
|
"devDependencies": {
|
|
57
|
-
"@angular/
|
|
58
|
-
"@angular/
|
|
49
|
+
"@angular/build": "^21.0.5",
|
|
50
|
+
"@angular/cli": "^21.0.5",
|
|
51
|
+
"@angular/compiler-cli": "^21.0.0",
|
|
59
52
|
"@bbq-chat/widgets": "file:../js",
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"eslint": "^8.55.0",
|
|
65
|
-
"prettier": "^3.1.1",
|
|
66
|
-
"rxjs": "^7.8.0",
|
|
67
|
-
"tslib": "^2.3.0",
|
|
68
|
-
"typescript": "^5.4.2",
|
|
69
|
-
"zone.js": "^0.14.3"
|
|
70
|
-
},
|
|
71
|
-
"engines": {
|
|
72
|
-
"node": ">=14.0.0"
|
|
53
|
+
"jsdom": "^27.1.0",
|
|
54
|
+
"ng-packagr": "^21.0.0",
|
|
55
|
+
"typescript": "~5.9.2",
|
|
56
|
+
"vitest": "^4.0.8"
|
|
73
57
|
}
|
|
74
58
|
}
|
package/dist/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025 BbQ ChatWidgets Contributors
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { Type, TemplateRef } from '@angular/core';
|
|
2
|
-
import { ChatWidget } from '@bbq-chat/widgets';
|
|
3
|
-
/**
|
|
4
|
-
* Context provided to template-based custom widget renderers
|
|
5
|
-
*/
|
|
6
|
-
export interface WidgetTemplateContext {
|
|
7
|
-
/**
|
|
8
|
-
* The widget instance being rendered
|
|
9
|
-
*/
|
|
10
|
-
$implicit: ChatWidget;
|
|
11
|
-
/**
|
|
12
|
-
* The widget instance (alternative access)
|
|
13
|
-
*/
|
|
14
|
-
widget: ChatWidget;
|
|
15
|
-
/**
|
|
16
|
-
* Emit a widget action
|
|
17
|
-
*/
|
|
18
|
-
emitAction: (actionName: string, payload: unknown) => void;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Interface for component-based custom widget renderers
|
|
22
|
-
*/
|
|
23
|
-
export interface CustomWidgetComponent {
|
|
24
|
-
/**
|
|
25
|
-
* The widget instance to render
|
|
26
|
-
*/
|
|
27
|
-
widget: ChatWidget;
|
|
28
|
-
/**
|
|
29
|
-
* Event emitter for widget actions (optional, will be set by the renderer)
|
|
30
|
-
*/
|
|
31
|
-
widgetAction?: (actionName: string, payload: unknown) => void;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Type for custom widget renderer functions that return HTML strings
|
|
35
|
-
*/
|
|
36
|
-
export type CustomWidgetHtmlRenderer = (widget: ChatWidget) => string;
|
|
37
|
-
/**
|
|
38
|
-
* Type for custom widget renderer configurations
|
|
39
|
-
*/
|
|
40
|
-
export type CustomWidgetRenderer = CustomWidgetHtmlRenderer | Type<CustomWidgetComponent> | TemplateRef<WidgetTemplateContext>;
|
|
41
|
-
/**
|
|
42
|
-
* Configuration for registering a custom widget renderer
|
|
43
|
-
*/
|
|
44
|
-
export interface CustomWidgetRendererConfig {
|
|
45
|
-
/**
|
|
46
|
-
* The widget type identifier
|
|
47
|
-
*/
|
|
48
|
-
type: string;
|
|
49
|
-
/**
|
|
50
|
-
* The renderer: can be a function returning HTML, an Angular Component class, or a TemplateRef
|
|
51
|
-
*/
|
|
52
|
-
renderer: CustomWidgetRenderer;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Type guard to check if a renderer is a TemplateRef
|
|
56
|
-
*/
|
|
57
|
-
export declare function isTemplateRenderer(renderer: CustomWidgetRenderer): renderer is TemplateRef<WidgetTemplateContext>;
|
|
58
|
-
/**
|
|
59
|
-
* Type guard to check if a renderer is an Angular Component
|
|
60
|
-
*
|
|
61
|
-
* Note: This uses a heuristic check based on the following assumptions:
|
|
62
|
-
* 1. Components are constructor functions
|
|
63
|
-
* 2. Components have a prototype with a constructor property
|
|
64
|
-
* 3. Components typically use dependency injection (no required constructor params)
|
|
65
|
-
*
|
|
66
|
-
* Limitation: This may not detect components with required constructor parameters.
|
|
67
|
-
* For edge cases, explicitly check your component's constructor signature.
|
|
68
|
-
*
|
|
69
|
-
* Alternative: You can always register a wrapper component that has no required params.
|
|
70
|
-
*/
|
|
71
|
-
export declare function isComponentRenderer(renderer: CustomWidgetRenderer): renderer is Type<CustomWidgetComponent>;
|
|
72
|
-
/**
|
|
73
|
-
* Type guard to check if a renderer is an HTML function
|
|
74
|
-
*
|
|
75
|
-
* Note: This should be checked AFTER checking for component and template renderers
|
|
76
|
-
* since components are also functions but with additional properties.
|
|
77
|
-
*/
|
|
78
|
-
export declare function isHtmlRenderer(renderer: CustomWidgetRenderer): renderer is CustomWidgetHtmlRenderer;
|
|
79
|
-
//# sourceMappingURL=custom-widget-renderer.types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"custom-widget-renderer.types.d.ts","sourceRoot":"","sources":["../src/custom-widget-renderer.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC;;OAEG;IACH,SAAS,EAAE,UAAU,CAAC;IAEtB;;OAEG;IACH,MAAM,EAAE,UAAU,CAAC;IAEnB;;OAEG;IACH,UAAU,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;CAC5D;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC;;OAEG;IACH,MAAM,EAAE,UAAU,CAAC;IAEnB;;OAEG;IACH,YAAY,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;CAC/D;AAED;;GAEG;AACH,MAAM,MAAM,wBAAwB,GAAG,CAAC,MAAM,EAAE,UAAU,KAAK,MAAM,CAAC;AAEtE;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAC5B,wBAAwB,GACxB,IAAI,CAAC,qBAAqB,CAAC,GAC3B,WAAW,CAAC,qBAAqB,CAAC,CAAC;AAEvC;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,QAAQ,EAAE,oBAAoB,CAAC;CAChC;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,oBAAoB,GAC7B,QAAQ,IAAI,WAAW,CAAC,qBAAqB,CAAC,CAMhD;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,oBAAoB,GAC7B,QAAQ,IAAI,IAAI,CAAC,qBAAqB,CAAC,CAazC;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,oBAAoB,GAC7B,QAAQ,IAAI,wBAAwB,CAEtC"}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Type guard to check if a renderer is a TemplateRef
|
|
3
|
-
*/
|
|
4
|
-
export function isTemplateRenderer(renderer) {
|
|
5
|
-
return (renderer !== null &&
|
|
6
|
-
typeof renderer === 'object' &&
|
|
7
|
-
'createEmbeddedView' in renderer);
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Type guard to check if a renderer is an Angular Component
|
|
11
|
-
*
|
|
12
|
-
* Note: This uses a heuristic check based on the following assumptions:
|
|
13
|
-
* 1. Components are constructor functions
|
|
14
|
-
* 2. Components have a prototype with a constructor property
|
|
15
|
-
* 3. Components typically use dependency injection (no required constructor params)
|
|
16
|
-
*
|
|
17
|
-
* Limitation: This may not detect components with required constructor parameters.
|
|
18
|
-
* For edge cases, explicitly check your component's constructor signature.
|
|
19
|
-
*
|
|
20
|
-
* Alternative: You can always register a wrapper component that has no required params.
|
|
21
|
-
*/
|
|
22
|
-
export function isComponentRenderer(renderer) {
|
|
23
|
-
// Check if it's a function (constructor) but not a regular function renderer
|
|
24
|
-
if (typeof renderer !== 'function') {
|
|
25
|
-
return false;
|
|
26
|
-
}
|
|
27
|
-
// Check for Angular component characteristics
|
|
28
|
-
// Components typically have prototype with constructor property
|
|
29
|
-
return (renderer.prototype !== undefined &&
|
|
30
|
-
renderer.prototype.constructor === renderer &&
|
|
31
|
-
renderer.length === 0 // Constructor with no required params (Angular DI)
|
|
32
|
-
);
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Type guard to check if a renderer is an HTML function
|
|
36
|
-
*
|
|
37
|
-
* Note: This should be checked AFTER checking for component and template renderers
|
|
38
|
-
* since components are also functions but with additional properties.
|
|
39
|
-
*/
|
|
40
|
-
export function isHtmlRenderer(renderer) {
|
|
41
|
-
return typeof renderer === 'function';
|
|
42
|
-
}
|
|
43
|
-
//# sourceMappingURL=custom-widget-renderer.types.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"custom-widget-renderer.types.js","sourceRoot":"","sources":["../src/custom-widget-renderer.types.ts"],"names":[],"mappings":"AAkEA;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAChC,QAA8B;IAE9B,OAAO,CACL,QAAQ,KAAK,IAAI;QACjB,OAAO,QAAQ,KAAK,QAAQ;QAC5B,oBAAoB,IAAI,QAAQ,CACjC,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,mBAAmB,CACjC,QAA8B;IAE9B,6EAA6E;IAC7E,IAAI,OAAO,QAAQ,KAAK,UAAU,EAAE,CAAC;QACnC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,8CAA8C;IAC9C,gEAAgE;IAChE,OAAO,CACL,QAAQ,CAAC,SAAS,KAAK,SAAS;QAChC,QAAQ,CAAC,SAAS,CAAC,WAAW,KAAK,QAAQ;QAC3C,QAAQ,CAAC,MAAM,KAAK,CAAC,CAAC,mDAAmD;KAC1E,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAC5B,QAA8B;IAE9B,OAAO,OAAO,QAAQ,KAAK,UAAU,CAAC;AACxC,CAAC"}
|
package/dist/index.cjs
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var index_exports = {};
|
|
20
|
-
__export(index_exports, {
|
|
21
|
-
ChatWidget: () => import_widgets.ChatWidget,
|
|
22
|
-
SsrWidgetRenderer: () => import_widgets2.SsrWidgetRenderer,
|
|
23
|
-
VERSION: () => VERSION,
|
|
24
|
-
WidgetEventManager: () => import_widgets2.WidgetEventManager,
|
|
25
|
-
WidgetRegistryService: () => import_widget_registry.WidgetRegistryService,
|
|
26
|
-
WidgetRendererComponent: () => import_widget_renderer.WidgetRendererComponent,
|
|
27
|
-
customWidgetRegistry: () => import_widgets2.customWidgetRegistry,
|
|
28
|
-
isComponentRenderer: () => import_custom_widget_renderer.isComponentRenderer,
|
|
29
|
-
isHtmlRenderer: () => import_custom_widget_renderer.isHtmlRenderer,
|
|
30
|
-
isTemplateRenderer: () => import_custom_widget_renderer.isTemplateRenderer
|
|
31
|
-
});
|
|
32
|
-
module.exports = __toCommonJS(index_exports);
|
|
33
|
-
var import_widget_renderer = require("./widget-renderer.component");
|
|
34
|
-
var import_widget_registry = require("./widget-registry.service");
|
|
35
|
-
var import_custom_widget_renderer = require("./custom-widget-renderer.types");
|
|
36
|
-
var import_widgets = require("@bbq-chat/widgets");
|
|
37
|
-
var import_widgets2 = require("@bbq-chat/widgets");
|
|
38
|
-
const VERSION = "1.0.0";
|
package/dist/index.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @bbq-chat/widgets-angular
|
|
3
|
-
*
|
|
4
|
-
* Angular components and services for BbQ ChatWidgets
|
|
5
|
-
*
|
|
6
|
-
* This package provides Angular-native components and services that wrap
|
|
7
|
-
* the core @bbq-chat/widgets library, making it easy to integrate chat
|
|
8
|
-
* widgets into Angular applications.
|
|
9
|
-
*
|
|
10
|
-
* @packageDocumentation
|
|
11
|
-
*/
|
|
12
|
-
export { WidgetRendererComponent } from './widget-renderer.component';
|
|
13
|
-
export { WidgetRegistryService } from './widget-registry.service';
|
|
14
|
-
export type { CustomWidgetComponent, CustomWidgetRenderer, CustomWidgetHtmlRenderer, CustomWidgetRendererConfig, WidgetTemplateContext, } from './custom-widget-renderer.types';
|
|
15
|
-
export { isHtmlRenderer, isComponentRenderer, isTemplateRenderer, } from './custom-widget-renderer.types';
|
|
16
|
-
export { ChatWidget, } from '@bbq-chat/widgets';
|
|
17
|
-
export type { ButtonWidget, CardWidget, FormWidget, InputWidget, TextAreaWidget, DropdownWidget, SliderWidget, ToggleWidget, FileUploadWidget, DatePickerWidget, MultiSelectWidget, ProgressBarWidget, ThemeSwitcherWidget, ImageWidget, ImageCollectionWidget, } from '@bbq-chat/widgets';
|
|
18
|
-
export { SsrWidgetRenderer, WidgetEventManager, customWidgetRegistry, } from '@bbq-chat/widgets';
|
|
19
|
-
export declare const VERSION = "1.0.0";
|
|
20
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAGtE,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAGlE,YAAY,EACV,qBAAqB,EACrB,oBAAoB,EACpB,wBAAwB,EACxB,0BAA0B,EAC1B,qBAAqB,GACtB,MAAM,gCAAgC,CAAC;AAExC,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,gCAAgC,CAAC;AAGxC,OAAO,EACL,UAAU,GACX,MAAM,mBAAmB,CAAC;AAE3B,YAAY,EACV,YAAY,EACZ,UAAU,EACV,UAAU,EACV,WAAW,EACX,cAAc,EACd,cAAc,EACd,YAAY,EACZ,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,mBAAmB,EACnB,WAAW,EACX,qBAAqB,GACtB,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,oBAAoB,GACrB,MAAM,mBAAmB,CAAC;AAG3B,eAAO,MAAM,OAAO,UAAU,CAAC"}
|
package/dist/index.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @bbq-chat/widgets-angular
|
|
3
|
-
*
|
|
4
|
-
* Angular components and services for BbQ ChatWidgets
|
|
5
|
-
*
|
|
6
|
-
* This package provides Angular-native components and services that wrap
|
|
7
|
-
* the core @bbq-chat/widgets library, making it easy to integrate chat
|
|
8
|
-
* widgets into Angular applications.
|
|
9
|
-
*
|
|
10
|
-
* @packageDocumentation
|
|
11
|
-
*/
|
|
12
|
-
// Export components
|
|
13
|
-
export { WidgetRendererComponent } from './widget-renderer.component';
|
|
14
|
-
// Export services
|
|
15
|
-
export { WidgetRegistryService } from './widget-registry.service';
|
|
16
|
-
export { isHtmlRenderer, isComponentRenderer, isTemplateRenderer, } from './custom-widget-renderer.types';
|
|
17
|
-
// Re-export commonly used types and classes from core package
|
|
18
|
-
export { ChatWidget, } from '@bbq-chat/widgets';
|
|
19
|
-
// Re-export utilities
|
|
20
|
-
export { SsrWidgetRenderer, WidgetEventManager, customWidgetRegistry, } from '@bbq-chat/widgets';
|
|
21
|
-
// Version
|
|
22
|
-
export const VERSION = '1.0.0';
|
|
23
|
-
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,oBAAoB;AACpB,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAEtE,kBAAkB;AAClB,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAWlE,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,gCAAgC,CAAC;AAExC,8DAA8D;AAC9D,OAAO,EACL,UAAU,GACX,MAAM,mBAAmB,CAAC;AAoB3B,sBAAsB;AACtB,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,oBAAoB,GACrB,MAAM,mBAAmB,CAAC;AAE3B,UAAU;AACV,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC"}
|