@ruc-lib/widget 3.2.0 → 4.0.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.
@@ -1,92 +0,0 @@
1
- import { Type } from "@angular/core";
2
- /**
3
- * Defines the input properties for the main `ruclib-widget` component.
4
- */
5
- export interface WidgetConfig {
6
- /**
7
- * The theme color to be applied to interactive elements like icons.
8
- * @example 'primary', 'accent', 'warn'
9
- * @optional
10
- */
11
- color?: string;
12
- /**
13
- * An array of configuration objects, each defining a single widget.
14
- * @optional
15
- */
16
- widgetData?: WidgetConfigData[];
17
- }
18
- /**
19
- * Defines the configuration for a single widget within the container.
20
- */
21
- export interface WidgetConfigData {
22
- /** A unique identifier for the widget. */
23
- id: string;
24
- /**
25
- * The title to be displayed in the widget's header.
26
- * @optional
27
- */
28
- title?: string;
29
- /**
30
- * The description or main text content, used when `contentType` is 'text'.
31
- * @optional
32
- */
33
- description?: string;
34
- /**
35
- * If true, a close icon is displayed in the header to allow the user to remove the widget.
36
- * @optional
37
- */
38
- showCloseIcon?: boolean;
39
- /**
40
- * If true, the widget is visually faded and cannot be interacted with (dragged, resized, etc.).
41
- * @optional
42
- */
43
- disabled?: boolean;
44
- /**
45
- * The CSS width of the widget.
46
- * @example '300px', '50%', '33vw'
47
- * @optional
48
- */
49
- width?: string;
50
- /**
51
- * The CSS height of the widget.
52
- * @example '200px', 'auto', '50vh'
53
- * @optional
54
- */
55
- height?: string;
56
- /**
57
- * If true, the widget can be dragged around the container.
58
- * @optional
59
- */
60
- draggable?: boolean;
61
- /**
62
- * If true, the widget can be resized by the user (requires a resizing library implementation).
63
- * @optional
64
- */
65
- resizable?: boolean;
66
- /**
67
- * The type of content the widget will display.
68
- * @optional
69
- */
70
- contentType?: 'text' | 'html' | 'component' | 'chart' | 'video' | 'audio';
71
- /**
72
- * The data for the content. The structure depends on the `contentType`.
73
- * For 'component', it should be an object: `{ component: YourComponent, inputs: { ... } }`.
74
- * @optional
75
- */
76
- contentData?: any | {
77
- component: Type<any>;
78
- inputs?: {
79
- [key: string]: any;
80
- };
81
- };
82
- /** The CSS `top` position for absolute positioning. @example '20px', '5%' @optional */
83
- top?: string;
84
- /** The CSS `left` position for absolute positioning. @example '20px', '5%' @optional */
85
- left?: string;
86
- /** The name of a Material icon to display in the header. @optional */
87
- headerIcon?: string;
88
- /** Internal state flag to indicate if the widget is being actively dragged or resized. @optional */
89
- isActive?: boolean;
90
- /** The CSS `background-color` for the widget. @example '#ffffff', 'rgba(0,0,0,0.1)' @optional */
91
- backgroundColor?: string;
92
- }
@@ -1,77 +0,0 @@
1
- import { EventEmitter, ElementRef, AfterViewInit, ChangeDetectorRef } from '@angular/core';
2
- import { WidgetConfig, WidgetConfigData } from '../../interface/widget';
3
- import { CdkDragStart, CdkDragEnd } from '@angular/cdk/drag-drop';
4
- import * as i0 from "@angular/core";
5
- /**
6
- * A component that renders a collection of draggable and configurable widgets within a host container.
7
- * It manages the layout, interaction, and dynamic content of each widget.
8
- */
9
- export declare class RuclibWidgetComponent implements AfterViewInit {
10
- private cdr;
11
- /**
12
- * The main configuration object for the widget container.
13
- * It includes the array of widget data and global settings.
14
- * @see WidgetConfig interface for detailed properties.
15
- */
16
- rucInputData: WidgetConfig;
17
- /**
18
- * An optional custom theme class to be applied to the widget host container.
19
- * @example 'dark-theme', 'custom-theme-one'
20
- */
21
- customTheme: string | undefined;
22
- /**
23
- * An event emitter that fires when a widget's close icon is clicked.
24
- * It emits the unique ID of the widget to be closed.
25
- */
26
- widgetClose: EventEmitter<string>;
27
- /**
28
- * An event emitter that fires when a widget is dragged and dropped.
29
- * It emits the entire updated array of widget configurations, allowing the parent to save the new layout.
30
- */
31
- layoutChanged: EventEmitter<WidgetConfigData[]>;
32
- /**
33
- * @param cdr The ChangeDetectorRef to manually trigger change detection when needed.
34
- */
35
- constructor(cdr: ChangeDetectorRef);
36
- /** A reference to the host container element, used to define the drag boundary. */
37
- widgetsHostContainerRef: ElementRef<HTMLElement>;
38
- /** The HTML element that serves as the boundary for all drag operations. */
39
- dragBoundaryElement: HTMLElement;
40
- /**
41
- * After the view initializes, this hook captures the host container's native element
42
- * and sets it as the boundary for dragging widgets.
43
- */
44
- ngAfterViewInit(): void;
45
- /**
46
- * Handles the click event on a widget's close button.
47
- * @param widgetId The ID of the widget to be closed.
48
- */
49
- onCloseClick(widgetId: string): void;
50
- /**
51
- * Handles the start of a drag operation for a widget.
52
- * Sets the widget's isActive state to true for visual feedback.
53
- * @param widget The WidgetConfigData object being dragged.
54
- * @param event The CdkDragStart event.
55
- */
56
- onDragStarted(widget: WidgetConfigData, event: CdkDragStart): void;
57
- /**
58
- * Handles the end of a drag operation.
59
- * It calculates the new top/left position, updates the widget's configuration,
60
- * and emits the `layoutChanged` event with the new layout data.
61
- * @param widget The WidgetConfigData object that was dragged.
62
- * @param event The CdkDragEnd event.
63
- */
64
- onDragEnded(widget: WidgetConfigData, event: CdkDragEnd): void;
65
- /**
66
- * Retrieves the color for UI elements like icons from the input data.
67
- * @returns The color string (e.g., 'primary', 'accent') or 'primary' as a default.
68
- */
69
- getColor(): string;
70
- /**
71
- * A safe getter for the widget data array from the main input configuration.
72
- * @returns The array of widget configurations, or an empty array if not defined.
73
- */
74
- getWidgetData(): WidgetConfigData[] | any;
75
- static ɵfac: i0.ɵɵFactoryDeclaration<RuclibWidgetComponent, never>;
76
- static ɵcmp: i0.ɵɵComponentDeclaration<RuclibWidgetComponent, "uxp-ruclib-widget", never, { "rucInputData": "rucInputData"; "customTheme": "customTheme"; }, { "widgetClose": "widgetClose"; "layoutChanged": "layoutChanged"; }, never, never, false, never>;
77
- }
@@ -1,60 +0,0 @@
1
- import { ViewContainerRef, OnChanges, SimpleChanges, OnDestroy, ChangeDetectorRef, AfterViewInit } from '@angular/core';
2
- import { DomSanitizer } from '@angular/platform-browser';
3
- import { WidgetConfigData } from '../../interface/widget';
4
- import * as i0 from "@angular/core";
5
- /**
6
- * Represents a single item within a widget.
7
- * This component is responsible for rendering the content of a widget, which can be
8
- * simple text, HTML, a video, or a dynamically loaded Angular component.
9
- */
10
- export declare class RuclibWidgetItemComponent implements OnChanges, OnDestroy, AfterViewInit {
11
- private cdr;
12
- private sanitizer;
13
- /**
14
- * The configuration object for this specific widget item.
15
- * It determines the type of content to render and provides the necessary data.
16
- */
17
- widgetConfig: WidgetConfigData;
18
- /**
19
- * A reference to the view container where a dynamic component will be injected.
20
- * This is used when `widgetConfig.contentType` is 'component'.
21
- */
22
- widgetComponentHost: ViewContainerRef;
23
- /**
24
- * A reference to the dynamically created component instance.
25
- * This is used to manage the lifecycle of the injected component.
26
- */
27
- private dynamicComponentRef;
28
- /**
29
- * @param cdr The ChangeDetectorRef to manually trigger change detection.
30
- * @param sanitizer The DomSanitizer service to prevent XSS attacks by sanitizing HTML.
31
- */
32
- constructor(cdr: ChangeDetectorRef, sanitizer: DomSanitizer);
33
- /**
34
- * A lifecycle hook that responds when Angular sets or resets data-bound input properties.
35
- * It checks for changes in `widgetConfig` and reloads the content accordingly.
36
- * @param changes An object of the changed properties.
37
- */
38
- ngOnChanges(changes: SimpleChanges): void;
39
- /**
40
- * A lifecycle hook that is called after Angular has fully initialized a component's view.
41
- * It ensures that if the initial content type is 'component', it gets loaded.
42
- */
43
- ngAfterViewInit(): void;
44
- /**
45
- * Loads a dynamic component into the `widgetComponentHost` view container.
46
- * It reads the component type and any input data from the `widgetConfig`.
47
- */
48
- private loadDynamicContent;
49
- /**
50
- * Clears any dynamically loaded component from the view container and destroys its instance.
51
- */
52
- private clearDynamicContent;
53
- /**
54
- * A lifecycle hook that cleans up the component before it's destroyed.
55
- * Ensures that any dynamically created components are properly destroyed to avoid memory leaks.
56
- */
57
- ngOnDestroy(): void;
58
- static ɵfac: i0.ɵɵFactoryDeclaration<RuclibWidgetItemComponent, never>;
59
- static ɵcmp: i0.ɵɵComponentDeclaration<RuclibWidgetItemComponent, "uxp-ruclib-widget-item", never, { "widgetConfig": "widgetConfig"; }, {}, never, never, false, never>;
60
- }
@@ -1,13 +0,0 @@
1
- import * as i0 from "@angular/core";
2
- import * as i1 from "./ruclib-widget/ruclib-widget.component";
3
- import * as i2 from "../pipes/safe-html.pipe";
4
- import * as i3 from "./ruclib-widget-item/ruclib-widget-item.component";
5
- import * as i4 from "@angular/common";
6
- import * as i5 from "@angular/material/icon";
7
- import * as i6 from "@angular/material/button";
8
- import * as i7 from "@angular/cdk/drag-drop";
9
- export declare class RuclibWidgetModule {
10
- static ɵfac: i0.ɵɵFactoryDeclaration<RuclibWidgetModule, never>;
11
- static ɵmod: i0.ɵɵNgModuleDeclaration<RuclibWidgetModule, [typeof i1.RuclibWidgetComponent, typeof i2.SafeHtmlPipe, typeof i3.RuclibWidgetItemComponent], [typeof i4.CommonModule, typeof i5.MatIconModule, typeof i6.MatButtonModule, typeof i7.DragDropModule], [typeof i1.RuclibWidgetComponent]>;
12
- static ɵinj: i0.ɵɵInjectorDeclaration<RuclibWidgetModule>;
13
- }
@@ -1,2 +0,0 @@
1
- import { WidgetConfig } from "../interface/widget";
2
- export declare const defaultValues: WidgetConfig;
@@ -1,24 +0,0 @@
1
- import { PipeTransform } from '@angular/core';
2
- import { DomSanitizer } from '@angular/platform-browser';
3
- import * as i0 from "@angular/core";
4
- /**
5
- * @Pipe SafeHtmlPipe
6
- * @name safeHtml
7
- * @description A pipe that bypasses Angular's built-in security and sanitizes HTML content,
8
- * allowing it to be safely rendered in the DOM. Use with caution and only with trusted HTML sources.
9
- */
10
- export declare class SafeHtmlPipe implements PipeTransform {
11
- private sanitizer;
12
- /**
13
- * @param sanitizer - An instance of DomSanitizer used to bypass security.
14
- */
15
- constructor(sanitizer: DomSanitizer);
16
- /**
17
- * Transforms a string containing HTML into a SafeHtml object that can be bound to [innerHTML].
18
- * @param value - The HTML string to sanitize.
19
- * @returns A SafeHtml object, which Angular trusts as safe HTML.
20
- */
21
- transform(value: any): any;
22
- static ɵfac: i0.ɵɵFactoryDeclaration<SafeHtmlPipe, never>;
23
- static ɵpipe: i0.ɵɵPipeDeclaration<SafeHtmlPipe, "safeHtml", false>;
24
- }