@bbq-chat/widgets-angular 1.0.3 → 1.0.5
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 +92 -3
- package/dist/README.md +341 -0
- package/dist/fesm2022/index.mjs +1992 -0
- package/dist/fesm2022/index.mjs.map +1 -0
- package/dist/types/index.d.ts +618 -0
- package/package.json +18 -15
|
@@ -0,0 +1,618 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { Type, TemplateRef, InjectionToken, OnInit, AfterViewInit, OnDestroy, OnChanges, Injector, EnvironmentInjector, EventEmitter, ElementRef, ComponentRef, EmbeddedViewRef, SimpleChanges, QueryList, ViewContainerRef } from '@angular/core';
|
|
3
|
+
import { ChatWidget, IWidgetRenderer, IWidgetActionHandler, WidgetEventManager, SsrWidgetRenderer, ButtonWidget, CardWidget, InputWidget, TextAreaWidget, DropdownWidget, SliderWidget, ToggleWidget, FileUploadWidget, ThemeSwitcherWidget, DatePickerWidget, MultiSelectWidget, ProgressBarWidget, FormWidget, ImageWidget, ImageCollectionWidget } 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
|
+
* Options for configuring the Angular widget renderer
|
|
180
|
+
*/
|
|
181
|
+
interface AngularRendererOptions {
|
|
182
|
+
/**
|
|
183
|
+
* Per-widget-type component overrides. Key is widget.type.
|
|
184
|
+
*/
|
|
185
|
+
components?: Partial<Record<string, Type<CustomWidgetComponent>>>;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Angular widget renderer
|
|
189
|
+
* Returns Angular component types for dynamic rendering
|
|
190
|
+
* Provides feature parity with SsrWidgetRenderer but uses Angular components
|
|
191
|
+
*/
|
|
192
|
+
declare class AngularWidgetRenderer implements IWidgetRenderer {
|
|
193
|
+
readonly framework = "Angular";
|
|
194
|
+
private overrides;
|
|
195
|
+
private componentRegistry;
|
|
196
|
+
constructor(options?: AngularRendererOptions);
|
|
197
|
+
/**
|
|
198
|
+
* Register all built-in widget components
|
|
199
|
+
* Must be called after components are imported to avoid circular dependencies
|
|
200
|
+
*/
|
|
201
|
+
registerBuiltInComponents(components: Record<string, Type<CustomWidgetComponent>>): void;
|
|
202
|
+
/**
|
|
203
|
+
* Register or override a widget component
|
|
204
|
+
* Use this to replace built-in components or add custom ones
|
|
205
|
+
*
|
|
206
|
+
* @example
|
|
207
|
+
* ```typescript
|
|
208
|
+
* renderer.registerComponent('button', MyCustomButtonComponent);
|
|
209
|
+
* ```
|
|
210
|
+
*/
|
|
211
|
+
registerComponent(type: string, component: Type<CustomWidgetComponent>): void;
|
|
212
|
+
/**
|
|
213
|
+
* Register multiple widget components at once
|
|
214
|
+
*
|
|
215
|
+
* @example
|
|
216
|
+
* ```typescript
|
|
217
|
+
* renderer.registerComponents({
|
|
218
|
+
* button: MyButtonComponent,
|
|
219
|
+
* card: MyCardComponent
|
|
220
|
+
* });
|
|
221
|
+
* ```
|
|
222
|
+
*/
|
|
223
|
+
registerComponents(components: Record<string, Type<CustomWidgetComponent>>): void;
|
|
224
|
+
/**
|
|
225
|
+
* Get the Angular component type for a given widget
|
|
226
|
+
* Returns the component class that should be dynamically instantiated
|
|
227
|
+
*/
|
|
228
|
+
getComponentType(widget: ChatWidget): Type<CustomWidgetComponent> | null;
|
|
229
|
+
/**
|
|
230
|
+
* Legacy method for IWidgetRenderer interface compatibility
|
|
231
|
+
* Not used in Angular rendering but required by interface
|
|
232
|
+
* @deprecated Use getComponentType() instead for Angular rendering
|
|
233
|
+
*/
|
|
234
|
+
renderWidget(widget: ChatWidget): string;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* Injection token for WidgetEventManager factory
|
|
239
|
+
*
|
|
240
|
+
* Use this token to inject a factory function that creates WidgetEventManager instances.
|
|
241
|
+
* The factory accepts an optional action handler to configure the manager.
|
|
242
|
+
*
|
|
243
|
+
* @example
|
|
244
|
+
* ```typescript
|
|
245
|
+
* constructor(@Inject(WIDGET_EVENT_MANAGER_FACTORY) private eventManagerFactory: WidgetEventManagerFactory) {
|
|
246
|
+
* const actionHandler = { handle: async (action, payload) => { ... } };
|
|
247
|
+
* this.eventManager = this.eventManagerFactory(actionHandler);
|
|
248
|
+
* }
|
|
249
|
+
* ```
|
|
250
|
+
*/
|
|
251
|
+
type WidgetEventManagerFactory = (actionHandler?: IWidgetActionHandler) => WidgetEventManager;
|
|
252
|
+
declare const WIDGET_EVENT_MANAGER_FACTORY: InjectionToken<WidgetEventManagerFactory>;
|
|
253
|
+
/**
|
|
254
|
+
* Injection token for SsrWidgetRenderer
|
|
255
|
+
*
|
|
256
|
+
* Use this token to inject a SsrWidgetRenderer instance in your components.
|
|
257
|
+
* By default, WidgetRendererComponent provides this token with a factory that creates
|
|
258
|
+
* a new instance for each component.
|
|
259
|
+
*
|
|
260
|
+
* @example
|
|
261
|
+
* ```typescript
|
|
262
|
+
* constructor(@Inject(SSR_WIDGET_RENDERER) private renderer: SsrWidgetRenderer) {}
|
|
263
|
+
* ```
|
|
264
|
+
*/
|
|
265
|
+
declare const SSR_WIDGET_RENDERER: InjectionToken<SsrWidgetRenderer>;
|
|
266
|
+
/**
|
|
267
|
+
* Injection token for AngularWidgetRenderer
|
|
268
|
+
*
|
|
269
|
+
* Use this token to inject an AngularWidgetRenderer instance in your components.
|
|
270
|
+
* This is the recommended renderer for Angular applications as it provides
|
|
271
|
+
* native Angular component rendering instead of HTML string rendering.
|
|
272
|
+
*
|
|
273
|
+
* @example
|
|
274
|
+
* ```typescript
|
|
275
|
+
* constructor(@Inject(ANGULAR_WIDGET_RENDERER) private renderer: AngularWidgetRenderer) {}
|
|
276
|
+
* ```
|
|
277
|
+
*/
|
|
278
|
+
declare const ANGULAR_WIDGET_RENDERER: InjectionToken<AngularWidgetRenderer>;
|
|
279
|
+
/**
|
|
280
|
+
* Factory function for creating WidgetEventManager instances
|
|
281
|
+
*
|
|
282
|
+
* This factory is used by default in WidgetRendererComponent's providers array.
|
|
283
|
+
* You can override this in your own providers if you need custom initialization.
|
|
284
|
+
*
|
|
285
|
+
* @returns A factory function that creates WidgetEventManager instances
|
|
286
|
+
*/
|
|
287
|
+
declare function widgetEventManagerFactoryProvider(): WidgetEventManagerFactory;
|
|
288
|
+
/**
|
|
289
|
+
* Factory function for creating SsrWidgetRenderer instances
|
|
290
|
+
*
|
|
291
|
+
* This factory is used by default in WidgetRendererComponent's providers array.
|
|
292
|
+
* You can override this in your own providers if you need custom initialization
|
|
293
|
+
* or custom rendering options.
|
|
294
|
+
*
|
|
295
|
+
* @returns A new SsrWidgetRenderer instance
|
|
296
|
+
*/
|
|
297
|
+
declare function ssrWidgetRendererFactory(): SsrWidgetRenderer;
|
|
298
|
+
/**
|
|
299
|
+
* Factory function for creating AngularWidgetRenderer instances
|
|
300
|
+
*
|
|
301
|
+
* This factory creates an AngularWidgetRenderer with all built-in widget components
|
|
302
|
+
* pre-registered. This is the recommended renderer for Angular applications.
|
|
303
|
+
*
|
|
304
|
+
* @returns A new AngularWidgetRenderer instance with built-in components registered
|
|
305
|
+
*/
|
|
306
|
+
declare function angularWidgetRendererFactory(): AngularWidgetRenderer;
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* Angular component for rendering chat widgets
|
|
310
|
+
*
|
|
311
|
+
* This component handles rendering of chat widgets using the BbQ ChatWidgets library.
|
|
312
|
+
* It manages widget lifecycle, event handling, and cleanup.
|
|
313
|
+
*
|
|
314
|
+
* Supports three types of custom widget renderers:
|
|
315
|
+
* 1. HTML function renderers (return HTML strings)
|
|
316
|
+
* 2. Angular Component renderers (render as dynamic components)
|
|
317
|
+
* 3. Angular TemplateRef renderers (render as embedded views)
|
|
318
|
+
*
|
|
319
|
+
* @example
|
|
320
|
+
* ```typescript
|
|
321
|
+
* <bbq-widget-renderer
|
|
322
|
+
* [widgets]="messageWidgets"
|
|
323
|
+
* (widgetAction)="handleWidgetAction($event)">
|
|
324
|
+
* </bbq-widget-renderer>
|
|
325
|
+
* ```
|
|
326
|
+
*/
|
|
327
|
+
declare class WidgetRendererComponent implements OnInit, AfterViewInit, OnDestroy, OnChanges {
|
|
328
|
+
protected renderer: SsrWidgetRenderer;
|
|
329
|
+
protected angularRenderer: AngularWidgetRenderer | null;
|
|
330
|
+
protected eventManagerFactory: WidgetEventManagerFactory;
|
|
331
|
+
protected widgetRegistry: WidgetRegistryService;
|
|
332
|
+
protected injector: Injector;
|
|
333
|
+
protected environmentInjector: EnvironmentInjector;
|
|
334
|
+
/**
|
|
335
|
+
* Array of widgets to render
|
|
336
|
+
*/
|
|
337
|
+
widgets: ChatWidget[] | null | undefined;
|
|
338
|
+
/**
|
|
339
|
+
* Emits when a widget action is triggered
|
|
340
|
+
*/
|
|
341
|
+
widgetAction: EventEmitter<{
|
|
342
|
+
actionName: string;
|
|
343
|
+
payload: unknown;
|
|
344
|
+
}>;
|
|
345
|
+
containerRef: ElementRef<HTMLDivElement>;
|
|
346
|
+
protected widgetItems: Array<{
|
|
347
|
+
index: number;
|
|
348
|
+
widget: ChatWidget;
|
|
349
|
+
isHtml: boolean;
|
|
350
|
+
html?: string;
|
|
351
|
+
}>;
|
|
352
|
+
protected eventManager?: WidgetEventManager;
|
|
353
|
+
protected isViewInitialized: boolean;
|
|
354
|
+
protected dynamicComponents: Array<ComponentRef<any>>;
|
|
355
|
+
protected dynamicViews: Array<EmbeddedViewRef<WidgetTemplateContext>>;
|
|
356
|
+
constructor(renderer: SsrWidgetRenderer, angularRenderer: AngularWidgetRenderer | null, eventManagerFactory: WidgetEventManagerFactory, widgetRegistry: WidgetRegistryService, injector: Injector, environmentInjector: EnvironmentInjector);
|
|
357
|
+
ngOnInit(): void;
|
|
358
|
+
ngOnChanges(changes: SimpleChanges): void;
|
|
359
|
+
ngAfterViewInit(): void;
|
|
360
|
+
ngOnDestroy(): void;
|
|
361
|
+
/**
|
|
362
|
+
* Base implementation for updating the rendered HTML for the current widgets.
|
|
363
|
+
*
|
|
364
|
+
* Subclasses may override this method to customize how widgets are rendered
|
|
365
|
+
* (for example, to inject additional markup or perform preprocessing).
|
|
366
|
+
*
|
|
367
|
+
* Since this is the base implementation, overriding implementations are not
|
|
368
|
+
* required to call `super.updateWidgetHtml()`.
|
|
369
|
+
*/
|
|
370
|
+
protected updateWidgetHtml(): void;
|
|
371
|
+
/**
|
|
372
|
+
* Render dynamic components and templates for custom widgets
|
|
373
|
+
*/
|
|
374
|
+
protected renderDynamicWidgets(): void;
|
|
375
|
+
/**
|
|
376
|
+
* Render an Angular component for a custom widget
|
|
377
|
+
*
|
|
378
|
+
* Note: This method safely assigns properties to component instances
|
|
379
|
+
* by checking for property existence at runtime. This approach is necessary
|
|
380
|
+
* because we cannot statically verify that all components implement
|
|
381
|
+
* the CustomWidgetComponent interface.
|
|
382
|
+
*/
|
|
383
|
+
protected renderComponent(componentType: any, widget: ChatWidget, targetElement: HTMLElement): void;
|
|
384
|
+
/**
|
|
385
|
+
* Render an Angular template for a custom widget
|
|
386
|
+
*/
|
|
387
|
+
protected renderTemplate(templateRef: TemplateRef<WidgetTemplateContext>, widget: ChatWidget, targetElement: HTMLElement): void;
|
|
388
|
+
/**
|
|
389
|
+
* Cleanup dynamic components and views
|
|
390
|
+
*/
|
|
391
|
+
protected cleanupDynamicWidgets(): void;
|
|
392
|
+
private setupEventHandlers;
|
|
393
|
+
handleClick(event: MouseEvent): void;
|
|
394
|
+
/**
|
|
395
|
+
* Cleanup all resources including event listeners.
|
|
396
|
+
*/
|
|
397
|
+
private cleanup;
|
|
398
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<WidgetRendererComponent, [null, { optional: true; }, null, null, null, null]>;
|
|
399
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<WidgetRendererComponent, "bbq-widget-renderer", never, { "widgets": { "alias": "widgets"; "required": false; }; }, { "widgetAction": "widgetAction"; }, never, never, true, never>;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
declare class ButtonWidgetComponent implements CustomWidgetComponent {
|
|
403
|
+
widget: any;
|
|
404
|
+
widgetAction?: (actionName: string, payload: unknown) => void;
|
|
405
|
+
get buttonWidget(): ButtonWidget;
|
|
406
|
+
onClick(): void;
|
|
407
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ButtonWidgetComponent, never>;
|
|
408
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<ButtonWidgetComponent, "bbq-button-widget", never, { "widget": { "alias": "widget"; "required": false; }; }, {}, never, never, true, never>;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
declare class CardWidgetComponent implements CustomWidgetComponent {
|
|
412
|
+
widget: any;
|
|
413
|
+
widgetAction?: (actionName: string, payload: unknown) => void;
|
|
414
|
+
get cardWidget(): CardWidget;
|
|
415
|
+
onClick(): void;
|
|
416
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<CardWidgetComponent, never>;
|
|
417
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<CardWidgetComponent, "bbq-card-widget", never, { "widget": { "alias": "widget"; "required": false; }; }, {}, never, never, true, never>;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
declare class InputWidgetComponent implements CustomWidgetComponent, OnInit {
|
|
421
|
+
widget: any;
|
|
422
|
+
widgetAction?: (actionName: string, payload: unknown) => void;
|
|
423
|
+
value: string;
|
|
424
|
+
inputId: string;
|
|
425
|
+
get inputWidget(): InputWidget;
|
|
426
|
+
get showLabel(): boolean;
|
|
427
|
+
get inputClasses(): string[];
|
|
428
|
+
private get isFormAppearance();
|
|
429
|
+
ngOnInit(): void;
|
|
430
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<InputWidgetComponent, never>;
|
|
431
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<InputWidgetComponent, "bbq-input-widget", never, { "widget": { "alias": "widget"; "required": false; }; }, {}, never, never, true, never>;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
declare class TextAreaWidgetComponent implements CustomWidgetComponent, OnInit {
|
|
435
|
+
widget: any;
|
|
436
|
+
widgetAction?: (actionName: string, payload: unknown) => void;
|
|
437
|
+
value: string;
|
|
438
|
+
textareaId: string;
|
|
439
|
+
get textareaWidget(): TextAreaWidget;
|
|
440
|
+
get showLabel(): boolean;
|
|
441
|
+
get textareaClasses(): string[];
|
|
442
|
+
private get isFormAppearance();
|
|
443
|
+
ngOnInit(): void;
|
|
444
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<TextAreaWidgetComponent, never>;
|
|
445
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<TextAreaWidgetComponent, "bbq-textarea-widget", never, { "widget": { "alias": "widget"; "required": false; }; }, {}, never, never, true, never>;
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
declare class DropdownWidgetComponent implements CustomWidgetComponent, OnInit {
|
|
449
|
+
widget: any;
|
|
450
|
+
widgetAction?: (actionName: string, payload: unknown) => void;
|
|
451
|
+
value: string;
|
|
452
|
+
selectId: string;
|
|
453
|
+
get dropdownWidget(): DropdownWidget;
|
|
454
|
+
get showLabel(): boolean;
|
|
455
|
+
get selectClasses(): string[];
|
|
456
|
+
private get isFormAppearance();
|
|
457
|
+
ngOnInit(): void;
|
|
458
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<DropdownWidgetComponent, never>;
|
|
459
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<DropdownWidgetComponent, "bbq-dropdown-widget", never, { "widget": { "alias": "widget"; "required": false; }; }, {}, never, never, true, never>;
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
declare class SliderWidgetComponent implements CustomWidgetComponent, OnInit {
|
|
463
|
+
widget: any;
|
|
464
|
+
widgetAction?: (actionName: string, payload: unknown) => void;
|
|
465
|
+
value: number;
|
|
466
|
+
sliderId: string;
|
|
467
|
+
get sliderWidget(): SliderWidget;
|
|
468
|
+
get showLabel(): boolean;
|
|
469
|
+
get sliderClasses(): string[];
|
|
470
|
+
private get isFormAppearance();
|
|
471
|
+
ngOnInit(): void;
|
|
472
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<SliderWidgetComponent, never>;
|
|
473
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<SliderWidgetComponent, "bbq-slider-widget", never, { "widget": { "alias": "widget"; "required": false; }; }, {}, never, never, true, never>;
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
declare class ToggleWidgetComponent implements CustomWidgetComponent, OnInit {
|
|
477
|
+
widget: any;
|
|
478
|
+
widgetAction?: (actionName: string, payload: unknown) => void;
|
|
479
|
+
checked: boolean;
|
|
480
|
+
checkboxId: string;
|
|
481
|
+
get toggleWidget(): ToggleWidget;
|
|
482
|
+
get showLabel(): boolean;
|
|
483
|
+
get checkboxClasses(): string[];
|
|
484
|
+
private get isFormAppearance();
|
|
485
|
+
ngOnInit(): void;
|
|
486
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ToggleWidgetComponent, never>;
|
|
487
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<ToggleWidgetComponent, "bbq-toggle-widget", never, { "widget": { "alias": "widget"; "required": false; }; }, {}, never, never, true, never>;
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
declare class FileUploadWidgetComponent implements CustomWidgetComponent, OnInit {
|
|
491
|
+
widget: any;
|
|
492
|
+
widgetAction?: (actionName: string, payload: unknown) => void;
|
|
493
|
+
inputId: string;
|
|
494
|
+
get fileUploadWidget(): FileUploadWidget;
|
|
495
|
+
get showLabel(): boolean;
|
|
496
|
+
get inputClasses(): string[];
|
|
497
|
+
private get isFormAppearance();
|
|
498
|
+
ngOnInit(): void;
|
|
499
|
+
onFileChange(event: Event): void;
|
|
500
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<FileUploadWidgetComponent, never>;
|
|
501
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<FileUploadWidgetComponent, "bbq-fileupload-widget", never, { "widget": { "alias": "widget"; "required": false; }; }, {}, never, never, true, never>;
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
declare class ThemeSwitcherWidgetComponent implements CustomWidgetComponent, OnInit {
|
|
505
|
+
widget: any;
|
|
506
|
+
widgetAction?: (actionName: string, payload: unknown) => void;
|
|
507
|
+
value: string;
|
|
508
|
+
selectId: string;
|
|
509
|
+
get themeSwitcherWidget(): ThemeSwitcherWidget;
|
|
510
|
+
ngOnInit(): void;
|
|
511
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ThemeSwitcherWidgetComponent, never>;
|
|
512
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<ThemeSwitcherWidgetComponent, "bbq-themeswitcher-widget", never, { "widget": { "alias": "widget"; "required": false; }; }, {}, never, never, true, never>;
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
declare class DatePickerWidgetComponent implements CustomWidgetComponent, OnInit {
|
|
516
|
+
widget: any;
|
|
517
|
+
widgetAction?: (actionName: string, payload: unknown) => void;
|
|
518
|
+
value: string;
|
|
519
|
+
inputId: string;
|
|
520
|
+
get datePickerWidget(): DatePickerWidget;
|
|
521
|
+
get showLabel(): boolean;
|
|
522
|
+
get inputClasses(): string[];
|
|
523
|
+
private get isFormAppearance();
|
|
524
|
+
ngOnInit(): void;
|
|
525
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<DatePickerWidgetComponent, never>;
|
|
526
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<DatePickerWidgetComponent, "bbq-datepicker-widget", never, { "widget": { "alias": "widget"; "required": false; }; }, {}, never, never, true, never>;
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
declare class MultiSelectWidgetComponent implements CustomWidgetComponent, OnInit {
|
|
530
|
+
widget: any;
|
|
531
|
+
widgetAction?: (actionName: string, payload: unknown) => void;
|
|
532
|
+
values: string[];
|
|
533
|
+
selectId: string;
|
|
534
|
+
get multiSelectWidget(): MultiSelectWidget;
|
|
535
|
+
get showLabel(): boolean;
|
|
536
|
+
get selectClasses(): string[];
|
|
537
|
+
private get isFormAppearance();
|
|
538
|
+
ngOnInit(): void;
|
|
539
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<MultiSelectWidgetComponent, never>;
|
|
540
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<MultiSelectWidgetComponent, "bbq-multiselect-widget", never, { "widget": { "alias": "widget"; "required": false; }; }, {}, never, never, true, never>;
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
declare class ProgressBarWidgetComponent implements CustomWidgetComponent, OnInit {
|
|
544
|
+
widget: any;
|
|
545
|
+
widgetAction?: (actionName: string, payload: unknown) => void;
|
|
546
|
+
progressId: string;
|
|
547
|
+
percentage: number;
|
|
548
|
+
get progressBarWidget(): ProgressBarWidget;
|
|
549
|
+
ngOnInit(): void;
|
|
550
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ProgressBarWidgetComponent, never>;
|
|
551
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<ProgressBarWidgetComponent, "bbq-progressbar-widget", never, { "widget": { "alias": "widget"; "required": false; }; }, {}, never, never, true, never>;
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
declare class FormWidgetComponent implements CustomWidgetComponent, OnInit, AfterViewInit, OnDestroy {
|
|
555
|
+
private injector;
|
|
556
|
+
private environmentInjector;
|
|
557
|
+
widget: any;
|
|
558
|
+
widgetAction?: (actionName: string, payload: unknown) => void;
|
|
559
|
+
fieldContainers: QueryList<ViewContainerRef>;
|
|
560
|
+
formId: string;
|
|
561
|
+
formData: Record<string, any>;
|
|
562
|
+
showValidationMessage: boolean;
|
|
563
|
+
private componentRefs;
|
|
564
|
+
private fieldComponentRegistry;
|
|
565
|
+
get formWidget(): FormWidget;
|
|
566
|
+
constructor(injector: Injector, environmentInjector: EnvironmentInjector);
|
|
567
|
+
ngOnInit(): void;
|
|
568
|
+
ngAfterViewInit(): void;
|
|
569
|
+
ngOnDestroy(): void;
|
|
570
|
+
private renderFieldWidgets;
|
|
571
|
+
private renderInputFallback;
|
|
572
|
+
getFieldId(fieldName: string): string;
|
|
573
|
+
getFieldProp(field: any, prop: string): any;
|
|
574
|
+
onActionClick(actionType: string): void;
|
|
575
|
+
private validateForm;
|
|
576
|
+
private gatherFormData;
|
|
577
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<FormWidgetComponent, never>;
|
|
578
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<FormWidgetComponent, "bbq-form-widget", never, { "widget": { "alias": "widget"; "required": false; }; }, {}, never, never, true, never>;
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
declare class ImageWidgetComponent implements CustomWidgetComponent {
|
|
582
|
+
widget: any;
|
|
583
|
+
widgetAction?: (actionName: string, payload: unknown) => void;
|
|
584
|
+
get imageWidget(): ImageWidget;
|
|
585
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ImageWidgetComponent, never>;
|
|
586
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<ImageWidgetComponent, "bbq-image-widget", never, { "widget": { "alias": "widget"; "required": false; }; }, {}, never, never, true, never>;
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
declare class ImageCollectionWidgetComponent implements CustomWidgetComponent {
|
|
590
|
+
widget: any;
|
|
591
|
+
widgetAction?: (actionName: string, payload: unknown) => void;
|
|
592
|
+
get imageCollectionWidget(): ImageCollectionWidget;
|
|
593
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ImageCollectionWidgetComponent, never>;
|
|
594
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<ImageCollectionWidgetComponent, "bbq-imagecollection-widget", never, { "widget": { "alias": "widget"; "required": false; }; }, {}, never, never, true, never>;
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
/**
|
|
598
|
+
* Registry of all built-in widget components
|
|
599
|
+
* Maps widget type to Angular component class
|
|
600
|
+
*/
|
|
601
|
+
declare const BUILT_IN_WIDGET_COMPONENTS: Record<string, Type<CustomWidgetComponent>>;
|
|
602
|
+
|
|
603
|
+
/**
|
|
604
|
+
* @bbq-chat/widgets-angular
|
|
605
|
+
*
|
|
606
|
+
* Angular components and services for BbQ ChatWidgets
|
|
607
|
+
*
|
|
608
|
+
* This package provides Angular-native components and services that wrap
|
|
609
|
+
* the core @bbq-chat/widgets library, making it easy to integrate chat
|
|
610
|
+
* widgets into Angular applications.
|
|
611
|
+
*
|
|
612
|
+
* @packageDocumentation
|
|
613
|
+
*/
|
|
614
|
+
|
|
615
|
+
declare const VERSION = "1.0.4";
|
|
616
|
+
|
|
617
|
+
export { ANGULAR_WIDGET_RENDERER, AngularWidgetRenderer, BUILT_IN_WIDGET_COMPONENTS, ButtonWidgetComponent, CardWidgetComponent, DatePickerWidgetComponent, DropdownWidgetComponent, FileUploadWidgetComponent, FormWidgetComponent, ImageCollectionWidgetComponent, ImageWidgetComponent, InputWidgetComponent, MultiSelectWidgetComponent, ProgressBarWidgetComponent, SSR_WIDGET_RENDERER, SliderWidgetComponent, TextAreaWidgetComponent, ThemeSwitcherWidgetComponent, ToggleWidgetComponent, VERSION, WIDGET_EVENT_MANAGER_FACTORY, WidgetRegistryService, WidgetRendererComponent, angularWidgetRendererFactory, isComponentRenderer, isHtmlRenderer, isTemplateRenderer, ssrWidgetRendererFactory, widgetEventManagerFactoryProvider };
|
|
618
|
+
export type { AngularRendererOptions, 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.5",
|
|
4
4
|
"description": "Angular components and services for BbQ ChatWidgets",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "BbQ ChatWidgets Contributors",
|
|
@@ -27,6 +27,13 @@
|
|
|
27
27
|
"README.md",
|
|
28
28
|
"LICENSE"
|
|
29
29
|
],
|
|
30
|
+
"scripts": {
|
|
31
|
+
"ng": "ng",
|
|
32
|
+
"start": "ng serve",
|
|
33
|
+
"build": "ng build",
|
|
34
|
+
"watch": "ng build --watch --configuration development",
|
|
35
|
+
"test": "ng test"
|
|
36
|
+
},
|
|
30
37
|
"packageManager": "npm@10.9.0",
|
|
31
38
|
"peerDependencies": {
|
|
32
39
|
"@angular/common": "^21.0.0",
|
|
@@ -38,18 +45,14 @@
|
|
|
38
45
|
"rxjs": "~7.8.0",
|
|
39
46
|
"@bbq-chat/widgets": "^1.0.0"
|
|
40
47
|
},
|
|
41
|
-
"
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
"
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
"
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
},
|
|
52
|
-
"dependencies": {
|
|
53
|
-
"tslib": "^2.3.0"
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@angular/build": "^21.0.5",
|
|
50
|
+
"@angular/cli": "^21.0.5",
|
|
51
|
+
"@angular/compiler-cli": "^21.0.0",
|
|
52
|
+
"@bbq-chat/widgets": "file:../js",
|
|
53
|
+
"jsdom": "^27.1.0",
|
|
54
|
+
"ng-packagr": "^21.0.0",
|
|
55
|
+
"typescript": "~5.9.2",
|
|
56
|
+
"vitest": "^4.0.8"
|
|
54
57
|
}
|
|
55
|
-
}
|
|
58
|
+
}
|