@ruc-lib/drawer 3.1.0 → 3.2.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,203 @@
1
+ import { MatDrawerMode } from "@angular/material/sidenav";
2
+ import { Type } from "@angular/core";
3
+ /**
4
+ * Defines the dimensions for a button, including text and icon sizing.
5
+ */
6
+ export interface ButtonDimensions {
7
+ /**
8
+ * The width of the button.
9
+ * @example '120px', '5em'
10
+ * @optional
11
+ */
12
+ width?: string;
13
+ /**
14
+ * The height of the button.
15
+ * @example '40px', '2.5em'
16
+ * @optional
17
+ */
18
+ height?: string;
19
+ /**
20
+ * The padding of the button. Primarily for the main toggle button.
21
+ * @example '0 10px'
22
+ * @optional
23
+ */
24
+ padding?: string;
25
+ /**
26
+ * The font size for text within the button.
27
+ * @example '14px'
28
+ * @optional
29
+ */
30
+ fontSize?: string;
31
+ /**
32
+ * The size of the icon within the button.
33
+ * @example '20px'
34
+ * @optional
35
+ */
36
+ iconSize?: string;
37
+ }
38
+ /**
39
+ * Defines the dimensions for an icon button, like a close button.
40
+ */
41
+ export interface IconDimensions {
42
+ /**
43
+ * The width of the icon button.
44
+ * @example '32px'
45
+ * @optional
46
+ */
47
+ width?: string;
48
+ /**
49
+ * The height of the icon button.
50
+ * @example '32px'
51
+ * @optional
52
+ */
53
+ height?: string;
54
+ /**
55
+ * The size of the icon itself within the button.
56
+ * @example '18px'
57
+ * @optional
58
+ */
59
+ iconSize?: string;
60
+ }
61
+ /**
62
+ * Defines the input properties for the RuclibDrawerComponent.
63
+ */
64
+ export interface RuclibDrawerInput {
65
+ /**
66
+ * Position of the drawer.
67
+ * @default 'left'
68
+ * @optional
69
+ */
70
+ drawerPosition?: 'left' | 'right' | 'top' | 'bottom';
71
+ /**
72
+ * Mode of the drawer.
73
+ * `side`: Drawer stays open and reduces the content area.
74
+ * `over`: Drawer floats over the content.
75
+ * `push`: Drawer pushes the content away.
76
+ * @optional
77
+ */
78
+ mode?: MatDrawerMode;
79
+ /**
80
+ * Whether the drawer is initially opened.
81
+ * @optional
82
+ */
83
+ initialOpenedState?: boolean;
84
+ /**
85
+ * Width of the drawer, used when `drawerPosition` is 'left' or 'right'.
86
+ * @example '250px', '30vw'
87
+ * @optional
88
+ */
89
+ drawerWidth?: string;
90
+ /**
91
+ * Height of the drawer, used when `drawerPosition` is 'top' or 'bottom'.
92
+ * @example '200px', '40vh'
93
+ * @optional
94
+ */
95
+ drawerHeight?: string;
96
+ /**
97
+ * Content to be displayed in the drawer and main area.
98
+ * @optional
99
+ */
100
+ content?: {
101
+ /**
102
+ * Title displayed within the drawer.
103
+ * @optional
104
+ */
105
+ drawerTitle?: string;
106
+ /**
107
+ * HTML content for the body of the drawer. Used if `drawerContentComponent` is not provided.
108
+ * @optional
109
+ */
110
+ drawerBody?: string;
111
+ /**
112
+ * An Angular component to be rendered as the drawer's body content.
113
+ * If provided, `drawerBody` (HTML string) will be ignored for the drawer.
114
+ * @optional
115
+ */
116
+ drawerContentComponent?: Type<any>;
117
+ /**
118
+ * HTML content for the main application area beside/under the drawer.
119
+ * @optional
120
+ */
121
+ mainBody?: string;
122
+ };
123
+ /**
124
+ * Data to be passed to the `drawerContentComponent` instance.
125
+ * The dynamic component should have an @Input() property to receive this data.
126
+ */
127
+ drawerContentComponentData?: any;
128
+ /**
129
+ * Whether to disable the toggle button in the main content area.
130
+ * @optional
131
+ */
132
+ disableToggleButtonInMainContent?: boolean;
133
+ /**
134
+ * Text for the toggle button, supporting different text for open and close states.
135
+ * Also used for aria-label.
136
+ * @optional
137
+ */
138
+ toggleButtonText?: {
139
+ /**
140
+ * Text for the button when the drawer is closed (action to open).
141
+ * @optional
142
+ */
143
+ open?: string;
144
+ /**
145
+ * Text for the button when the drawer is open (action to close).
146
+ * @optional
147
+ */
148
+ close?: string;
149
+ };
150
+ /**
151
+ * Material icon name for the toggle button.
152
+ * @example 'menu', 'settings'
153
+ * @optional
154
+ */
155
+ toggleButtonIcon?: string;
156
+ /**
157
+ * URL for an image to be used in the toggle button.
158
+ * @optional
159
+ */
160
+ toggleButtonImageUrl?: string;
161
+ /**
162
+ * Alt text for the toggle button image.
163
+ * @optional
164
+ */
165
+ toggleButtonImageAlt?: string;
166
+ /**
167
+ * Whether the drawer has a backdrop, especially in 'over' mode.
168
+ * @optional
169
+ */
170
+ hasBackdrop?: boolean;
171
+ /**
172
+ * Custom background color for the backdrop.
173
+ * @example 'rgba(0,0,0,0.5)', '#333333'
174
+ * @optional
175
+ */
176
+ backdropBackgroundColor?: string;
177
+ /**
178
+ * Whether to show a close icon (e.g., 'x') inside the drawer.
179
+ * @optional
180
+ */
181
+ showCloseIcon?: boolean;
182
+ /**
183
+ * Whether to disable closing the drawer by pressing the Escape key or clicking on the backdrop.
184
+ * @optional
185
+ */
186
+ disableClose?: boolean;
187
+ /**
188
+ * Duration for the drawer's open/close animation.
189
+ * @example '300ms', '0.5s'
190
+ * @optional Defaults to Material's default (usually around 400ms for MatDrawer, or 300ms for custom animations).
191
+ */
192
+ animationDuration?: string;
193
+ /**
194
+ * Custom dimensions for the main toggle button.
195
+ * @optional
196
+ */
197
+ toggleButtonDimensions?: ButtonDimensions;
198
+ /**
199
+ * Custom dimensions for the close icon button inside the drawer.
200
+ * @optional
201
+ */
202
+ closeButtonDimensions?: IconDimensions;
203
+ }
@@ -0,0 +1,176 @@
1
+ import { OnInit, OnChanges, SimpleChanges, EventEmitter, AfterViewInit, ChangeDetectorRef, ViewContainerRef, OnDestroy } from '@angular/core';
2
+ import { AnimationEvent } from '@angular/animations';
3
+ import { MatDrawerMode } from '@angular/material/sidenav';
4
+ import { RuclibDrawerInput } from '../../interface/drawer';
5
+ import * as i0 from "@angular/core";
6
+ /**
7
+ * @Component RuclibDrawerComponent
8
+ * @description A highly configurable drawer component that can slide in from any of the four directions (left, right, top, bottom).
9
+ * It uses custom Angular animations for smooth transitions and supports theming.
10
+ */
11
+ export declare class RuclibDrawerComponent implements OnInit, OnChanges, AfterViewInit, OnDestroy {
12
+ private cdr;
13
+ /**
14
+ * Input data for configuring the drawer's appearance and behavior.
15
+ * @see RuclibDrawerInput interface for detailed properties.
16
+ */
17
+ rucInputData: RuclibDrawerInput;
18
+ /**
19
+ * Optional custom theme class to be applied to the drawer panel.
20
+ * @example 'dark-theme', 'custom-theme-one'
21
+ */
22
+ customTheme: string | undefined;
23
+ /**
24
+ * EventEmitter for various drawer events.
25
+ * Emits objects with `type` (e.g., 'openedStart', 'closedStart', 'openedChange', 'drawerToggle')
26
+ * and `opened` (boolean) and `position` (string) properties.
27
+ */
28
+ rucEvent: EventEmitter<any>;
29
+ /** ViewContainerRef to host the dynamically loaded component. */
30
+ drawerComponentHost: ViewContainerRef;
31
+ /** Reference to the dynamically created component. */
32
+ private dynamicComponentRef;
33
+ /**
34
+ * Current animation state of the drawer ('in' or 'out').
35
+ * @public
36
+ */
37
+ drawerAnimationState: 'in' | 'out';
38
+ /**
39
+ * Current active position of the drawer.
40
+ * @public
41
+ * @default 'left'
42
+ */
43
+ currentDrawerPosition: 'left' | 'right' | 'top' | 'bottom';
44
+ /**
45
+ * Stores the next position if the drawer is currently open and a new position is requested.
46
+ * Used to sequence close and open animations.
47
+ * @private
48
+ */
49
+ private pendingDrawerPosition;
50
+ /**
51
+ * Flag to indicate if an animation is currently in progress to prevent rapid toggling.
52
+ * @public
53
+ */
54
+ isAnimating: boolean;
55
+ /**
56
+ * Effective animation duration for the drawer, derived from input or default.
57
+ * @public
58
+ * @default '300ms'
59
+ */
60
+ effectiveAnimationDuration: string;
61
+ /**
62
+ * Mode of the drawer, primarily for determining backdrop behavior with custom animations.
63
+ * @public
64
+ * @default 'side'
65
+ */
66
+ matDrawerMode: MatDrawerMode;
67
+ /**
68
+ * Actual position ('start' or 'end') used by Angular Material's MatDrawer if it were directly used.
69
+ * Retained for logical consistency in determining layout.
70
+ * @public
71
+ * @default 'start'
72
+ */
73
+ matActualPosition: 'start' | 'end';
74
+ /**
75
+ * Flag indicating if the drawer is in a vertical layout (top/bottom).
76
+ * Helps determine if width or height should be 100%.
77
+ * @public
78
+ */
79
+ isVerticalLayout: boolean;
80
+ /**
81
+ * Effective dimension (width or height) of the drawer panel.
82
+ * @public
83
+ * @default '250px'
84
+ */
85
+ effectiveDrawerDimension: string;
86
+ constructor(cdr: ChangeDetectorRef);
87
+ /**
88
+ * Angular lifecycle hook that is called after data-bound properties of a directive are initialized.
89
+ */
90
+ ngOnInit(): void;
91
+ /**
92
+ * Angular lifecycle hook that is called after Angular has fully initialized a component's view.
93
+ */
94
+ ngAfterViewInit(): void;
95
+ /**
96
+ * Angular lifecycle hook that is called when any data-bound property of a directive changes.
97
+ * @param changes - Object containing the changed properties.
98
+ */
99
+ ngOnChanges(changes: SimpleChanges): void;
100
+ /**
101
+ * Applies input data to component properties, calculating dimensions and positions.
102
+ * @private
103
+ */
104
+ private applyInputs;
105
+ /**
106
+ * Toggles the drawer's open/close state or switches to a new position.
107
+ * @param requestedPosition - The desired position to open the drawer from. If not provided, uses `currentDrawerPosition`.
108
+ */
109
+ toggleDrawer(requestedPosition?: 'left' | 'right' | 'top' | 'bottom'): void;
110
+ /**
111
+ * Sets the drawer's open state and triggers the animation.
112
+ * @param open - Boolean indicating whether to open (true) or close (false) the drawer.
113
+ * @private
114
+ */
115
+ private setDrawerOpenState;
116
+ /**
117
+ * Callback for when a drawer animation finishes.
118
+ * Manages state transitions, especially when switching between open drawers.
119
+ * @param event - The Angular AnimationEvent.
120
+ */
121
+ onAnimationDone(event: AnimationEvent): void;
122
+ /**
123
+ * Loads the dynamic component into the drawer if specified in rucInputData.
124
+ * Clears existing dynamic component if any.
125
+ * @private
126
+ */
127
+ private loadDynamicContent;
128
+ /**
129
+ * Getter for the current animation parameters to be passed to the animation triggers in the template.
130
+ * Includes the current animation state ('in' or 'out') and the effective duration.
131
+ */
132
+ get animationParams(): {
133
+ value: "out" | "in";
134
+ params: {
135
+ duration: string;
136
+ };
137
+ };
138
+ /**
139
+ * Getter for the backdrop animation parameters.
140
+ * Typically uses a faster duration than the main drawer animation.
141
+ */
142
+ get backdropAnimationParams(): {
143
+ value: "out" | "in";
144
+ params: {
145
+ duration: string;
146
+ };
147
+ };
148
+ /**
149
+ * Generates an accessible label for the toggle button based on the drawer's state and position.
150
+ * @returns The ARIA label string for the toggle button.
151
+ */
152
+ getToggleButtonAriaLabel(): string;
153
+ /**
154
+ * Handles clicks on the backdrop.
155
+ * Closes the drawer only if `disableClose` is not true.
156
+ * @public
157
+ */
158
+ handleBackdropClick(): void;
159
+ /**
160
+ * Listens for Escape key presses on the document.
161
+ * Closes the drawer if it's open and `disableClose` is not true.
162
+ * @param event - The KeyboardEvent.
163
+ */
164
+ onKeydownHandler(event: KeyboardEvent): void;
165
+ /**
166
+ * Clears any dynamically loaded component.
167
+ * @private
168
+ */
169
+ private clearDynamicContent;
170
+ /**
171
+ * Angular lifecycle hook that is called clear dynamic component content.
172
+ */
173
+ ngOnDestroy(): void;
174
+ static ɵfac: i0.ɵɵFactoryDeclaration<RuclibDrawerComponent, never>;
175
+ static ɵcmp: i0.ɵɵComponentDeclaration<RuclibDrawerComponent, "uxp-ruclib-drawer", never, { "rucInputData": "rucInputData"; "customTheme": "customTheme"; }, { "rucEvent": "rucEvent"; }, never, never, false, never>;
176
+ }
@@ -0,0 +1,13 @@
1
+ import * as i0 from "@angular/core";
2
+ import * as i1 from "./ruclib-drawer/ruclib-drawer.component";
3
+ import * as i2 from "../pipes/pipes/safe-html.pipe";
4
+ import * as i3 from "@angular/common";
5
+ import * as i4 from "@angular/material/button";
6
+ import * as i5 from "@angular/material/icon";
7
+ import * as i6 from "@angular/material/sidenav";
8
+ import * as i7 from "@angular/material/toolbar";
9
+ export declare class RuclibDrawerModule {
10
+ static ɵfac: i0.ɵɵFactoryDeclaration<RuclibDrawerModule, never>;
11
+ static ɵmod: i0.ɵɵNgModuleDeclaration<RuclibDrawerModule, [typeof i1.RuclibDrawerComponent, typeof i2.SafeHtmlPipe], [typeof i3.CommonModule, typeof i4.MatButtonModule, typeof i5.MatIconModule, typeof i6.MatSidenavModule, typeof i7.MatToolbarModule], [typeof i1.RuclibDrawerComponent]>;
12
+ static ɵinj: i0.ɵɵInjectorDeclaration<RuclibDrawerModule>;
13
+ }
@@ -0,0 +1,2 @@
1
+ import { RuclibDrawerInput } from "../interface/drawer";
2
+ export declare const defaultValues: RuclibDrawerInput;
package/package.json CHANGED
@@ -1,16 +1,24 @@
1
1
  {
2
2
  "name": "@ruc-lib/drawer",
3
- "version": "3.1.0",
3
+ "version": "3.2.0",
4
+ "license": "MIT",
4
5
  "peerDependencies": {
5
- "@angular/common": "^15.0.0 || ^16.0.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^20.0.0",
6
- "@angular/core": "^15.0.0 || ^16.0.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^20.0.0",
7
- "@angular/material": "^15.0.0 || ^16.0.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^20.0.0"
6
+ "@angular/common": "^17.0.0 || ^16.0.0 || ^15.0.0",
7
+ "@angular/core": "^17.0.0 || ^16.0.0 || ^15.0.0",
8
+ "@angular/material": "^15.2.9 || ^14.0.0 || ^13.0.0"
8
9
  },
9
10
  "dependencies": {
10
11
  "tslib": "^2.3.0"
11
12
  },
13
+ "publishConfig": {
14
+ "access": "public"
15
+ },
12
16
  "sideEffects": false,
13
- "module": "fesm2022/ruc-lib-drawer.mjs",
17
+ "module": "fesm2015/ruc-lib-drawer.mjs",
18
+ "es2020": "fesm2020/ruc-lib-drawer.mjs",
19
+ "esm2020": "esm2020/ruc-lib-drawer.mjs",
20
+ "fesm2020": "fesm2020/ruc-lib-drawer.mjs",
21
+ "fesm2015": "fesm2015/ruc-lib-drawer.mjs",
14
22
  "typings": "index.d.ts",
15
23
  "exports": {
16
24
  "./package.json": {
@@ -18,7 +26,11 @@
18
26
  },
19
27
  ".": {
20
28
  "types": "./index.d.ts",
21
- "default": "./fesm2022/ruc-lib-drawer.mjs"
29
+ "esm2020": "./esm2020/ruc-lib-drawer.mjs",
30
+ "es2020": "./fesm2020/ruc-lib-drawer.mjs",
31
+ "es2015": "./fesm2015/ruc-lib-drawer.mjs",
32
+ "node": "./fesm2015/ruc-lib-drawer.mjs",
33
+ "default": "./fesm2020/ruc-lib-drawer.mjs"
22
34
  }
23
35
  }
24
36
  }
@@ -0,0 +1,24 @@
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
+ }