@ruc-lib/drawer 2.0.0 → 3.1.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.
- package/README.md +188 -97
- package/fesm2022/ruc-lib-drawer.mjs +456 -0
- package/fesm2022/ruc-lib-drawer.mjs.map +1 -0
- package/index.d.ts +375 -3
- package/package.json +6 -18
- package/esm2020/index.mjs +0 -4
- package/esm2020/interface/drawer.mjs +0 -2
- package/esm2020/lib/ruclib-drawer/ruclib-drawer.component.mjs +0 -412
- package/esm2020/lib/ruclib-drawer.module.mjs +0 -41
- package/esm2020/model/default-values.mjs +0 -37
- package/esm2020/pipes/pipes/safe-html.pipe.mjs +0 -36
- package/esm2020/ruc-lib-drawer.mjs +0 -5
- package/fesm2015/ruc-lib-drawer.mjs +0 -531
- package/fesm2015/ruc-lib-drawer.mjs.map +0 -1
- package/fesm2020/ruc-lib-drawer.mjs +0 -525
- package/fesm2020/ruc-lib-drawer.mjs.map +0 -1
- package/interface/drawer.d.ts +0 -203
- package/lib/ruclib-drawer/ruclib-drawer.component.d.ts +0 -176
- package/lib/ruclib-drawer.module.d.ts +0 -13
- package/model/default-values.d.ts +0 -2
- package/pipes/pipes/safe-html.pipe.d.ts +0 -24
package/README.md
CHANGED
|
@@ -1,136 +1,227 @@
|
|
|
1
1
|
# ruclib-drawer
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
##
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
A highly configurable drawer component that provides a slide-in panel from any of the four directions (left, right, top, or bottom). It's designed for displaying supplementary content, navigation, or forms without navigating away from the current view.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Flexible Positioning**: Open the drawer from the 'left', 'right', 'top', or 'bottom' of the container.
|
|
8
|
+
- **Custom Sizing**: Define custom width for vertical drawers and height for horizontal drawers.
|
|
9
|
+
- **Smooth Animations**: Configurable slide-in/out animation duration.
|
|
10
|
+
- **Display Modes**: Supports an 'over' mode where the drawer slides over the main content.
|
|
11
|
+
- **Content Customization**: Set a custom title and use rich HTML for the drawer's body and the main content area.
|
|
12
|
+
- **Interactive Toggle**:
|
|
13
|
+
- Optionally display a toggle button in the main content area.
|
|
14
|
+
- Customize button text for 'open' and 'close' states.
|
|
15
|
+
- Use Material icons or custom image URLs for the button.
|
|
16
|
+
- **Backdrop Control**: Enable or disable a backdrop, and customize its background color.
|
|
17
|
+
- **Close Mechanisms**:
|
|
18
|
+
- Show or hide a close icon within the drawer.
|
|
19
|
+
- Prevent closing via the Escape key or backdrop click.
|
|
20
|
+
- **Theming**: Apply custom theme classes for tailored styling.
|
|
21
|
+
|
|
22
|
+
## Installation Guide
|
|
23
|
+
|
|
24
|
+
### Install the Entire Library
|
|
25
|
+
```bash
|
|
26
|
+
npm install @uxpractice/ruc-lib
|
|
27
|
+
```
|
|
8
28
|
|
|
9
|
-
|
|
29
|
+
### Install Individual Component
|
|
30
|
+
If you only need the Drawer component:
|
|
31
|
+
```bash
|
|
32
|
+
npm install @ruc-lib/drawer
|
|
33
|
+
```
|
|
10
34
|
|
|
11
|
-
|
|
35
|
+
### 📦 Version Compatibility
|
|
12
36
|
|
|
13
|
-
|
|
37
|
+
Please ensure you install the correct version of `@ruc-lib/drawer` based on your Angular version.
|
|
14
38
|
|
|
15
|
-
|
|
39
|
+
| Angular Version | Compatible `@ruc-lib/drawer` Version |
|
|
40
|
+
|--------------------|------------------------------------------|
|
|
41
|
+
| 15.x.x | `npm install @ruc-lib/drawer@^3.0.0` |
|
|
42
|
+
| 16.x.x | `npm install @ruc-lib/drawer@^3.0.0` |
|
|
16
43
|
|
|
17
|
-
`npm install @ruc-lib/drawer`
|
|
18
44
|
|
|
19
45
|
## Usage
|
|
20
46
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
47
|
+
### 1. Import the Component
|
|
48
|
+
In your Angular component file (e.g., `app.component.ts`), import the `RuclibDrawerComponent`:
|
|
49
|
+
|
|
50
|
+
```typescript
|
|
51
|
+
import { Component } from '@angular/core';
|
|
52
|
+
|
|
53
|
+
// For Complete Library
|
|
54
|
+
import { RuclibDrawerComponent } from '@uxpractice/ruc-lib/drawer';
|
|
55
|
+
|
|
56
|
+
// For Individual Package
|
|
57
|
+
import { RuclibDrawerComponent } from '@ruc-lib/drawer';
|
|
58
|
+
|
|
59
|
+
@Component({
|
|
60
|
+
selector: 'app-root',
|
|
61
|
+
imports: [RuclibDrawerComponent],
|
|
62
|
+
templateUrl: './app.component.html',
|
|
63
|
+
})
|
|
64
|
+
export class AppComponent {
|
|
65
|
+
// Component code here
|
|
66
|
+
}
|
|
30
67
|
```
|
|
31
|
-
<uxp-ruclib-drawer
|
|
32
|
-
(rucEvent)="passEvent($event)"
|
|
33
|
-
[rucInputData]="inputObjectDataDrawer"
|
|
34
|
-
[customTheme]="customTheme">
|
|
35
|
-
</uxp-ruclib-drawer>
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
# Input and Output
|
|
39
|
-
|
|
40
|
-
## Input and Output
|
|
41
|
-
|
|
42
|
-
Inputs:
|
|
43
|
-
• rucInputData: Data to be passed to the drawer.
|
|
44
|
-
• customTheme: Custom styling/theme for the drawer.
|
|
45
|
-
|
|
46
|
-
Outputs:
|
|
47
|
-
• rucEvent: Event emitted from the drawer.
|
|
48
|
-
|
|
49
68
|
|
|
50
|
-
|
|
69
|
+
### 2. Use the Component
|
|
70
|
+
In your component's template, use the `<uxp-ruclib-drawer>` selector:
|
|
51
71
|
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
drawerHeight: string = '',
|
|
59
|
-
content: {
|
|
60
|
-
drawerTitle: string = 'Drawer Title',
|
|
61
|
-
drawerBody: string = '<p>This is the <strong>body</strong> content of the drawer.</p><p>It can contain <em>HTML</em>.</p>',
|
|
62
|
-
mainBody: string = '<h2>Main Content Area</h2><p>This is where the main application content would go.</p>',
|
|
63
|
-
},
|
|
64
|
-
disableToggleButtonInMainContent: boolean = false,
|
|
65
|
-
toggleButtonText: object = {
|
|
66
|
-
open: string = 'Open Drawer',
|
|
67
|
-
close: string = 'Close Drawer',
|
|
68
|
-
},
|
|
69
|
-
hasBackdrop: boolean = true,
|
|
70
|
-
backdropBackgroundColor: string = 'rgba(129, 124, 124, 0.6)',
|
|
71
|
-
showCloseIcon: boolean = true,
|
|
72
|
-
disableClose: boolean = false,
|
|
73
|
-
animationDuration: string = '300ms',
|
|
74
|
-
toggleButtonIcon: string = '',
|
|
75
|
-
toggleButtonImageAlt: string = '',
|
|
76
|
-
toggleButtonImageUrl: string = '',
|
|
77
|
-
toggleButtonDimensions: ButtonDimensions = {
|
|
78
|
-
width: string = 'auto',
|
|
79
|
-
height: string = '40px',
|
|
80
|
-
padding: string = '10px',
|
|
81
|
-
fontSize: string = '13px',
|
|
82
|
-
iconSize: string = '24px',
|
|
83
|
-
},
|
|
84
|
-
closeButtonDimensions: IconDimensions = {
|
|
85
|
-
width: string = '40px',
|
|
86
|
-
height: string = '40px',
|
|
87
|
-
iconSize: string = '24px',
|
|
88
|
-
},
|
|
89
|
-
};
|
|
72
|
+
```html
|
|
73
|
+
<uxp-ruclib-drawer
|
|
74
|
+
[rucInputData]="drawerInput"
|
|
75
|
+
[customTheme]="customTheme"
|
|
76
|
+
(rucEvent)="passEvent($event)">
|
|
77
|
+
</uxp-ruclib-drawer>
|
|
90
78
|
```
|
|
91
79
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
80
|
+
## API Reference
|
|
81
|
+
|
|
82
|
+
### Component Inputs
|
|
83
|
+
|
|
84
|
+
| Input | Type | Description |
|
|
85
|
+
|----------------|-----------------------|--------------------------------------------------|
|
|
86
|
+
| `rucInputData` | `RuclibDrawerInput` | The main configuration object for the drawer. |
|
|
87
|
+
| `customTheme` | `string` | An optional CSS class for custom theming. |
|
|
88
|
+
|
|
89
|
+
### Component Outputs
|
|
90
|
+
|
|
91
|
+
| Output | Type | Description |
|
|
92
|
+
|------------|-------|----------------------------------------------|
|
|
93
|
+
| `rucEvent` | `any` | Emits events from the drawer. |
|
|
94
|
+
|
|
95
|
+
### `rucInputData` (`RuclibDrawerInput`)
|
|
96
|
+
This is the main configuration object for the Drawer component.
|
|
97
|
+
|
|
98
|
+
| Property | Type | Description |
|
|
99
|
+
|------------------------------------|----------------------|---------------------------------------------------------------------------------------------------------|
|
|
100
|
+
| `drawerPosition` | `string` | Position of the drawer. Can be `'left'`, `'right'`, `'top'`, or `'bottom'`. Default is `'left'`. |
|
|
101
|
+
| `mode` | `string` | Drawer mode. Can be `'over'`, `'push'`, or `'side'`. Default is `'over'`. |
|
|
102
|
+
| `initialOpenedState` | `boolean` | If `true`, the drawer is open initially. Default is `false`. |
|
|
103
|
+
| `drawerWidth` | `string` | Width of the drawer when `drawerPosition` is `'left'` or `'right'`. Default is `'250px'`. |
|
|
104
|
+
| `drawerHeight` | `string` | Height of the drawer when `drawerPosition` is `'top'` or `'bottom'`. |
|
|
105
|
+
| `content` | `object` | An object containing the HTML content for the drawer and main area. See `Content` table below. |
|
|
106
|
+
| `disableToggleButtonInMainContent` | `boolean` | If `true`, the toggle button in the main content area is hidden. Default is `false`. |
|
|
107
|
+
| `toggleButtonText` | `object` | An object for the toggle button's text. See `ToggleButtonText` table below. |
|
|
108
|
+
| `hasBackdrop` | `boolean` | If `true`, a backdrop is shown when the drawer is open. Default is `true`. |
|
|
109
|
+
| `backdropBackgroundColor` | `string` | The CSS background color for the backdrop. Default is `'rgba(129, 124, 124, 0.6)'`. |
|
|
110
|
+
| `showCloseIcon` | `boolean` | If `true`, a close icon is displayed inside the drawer. Default is `true`. |
|
|
111
|
+
| `disableClose` | `boolean` | If `true`, the drawer cannot be closed by pressing Escape or clicking the backdrop. Default is `false`. |
|
|
112
|
+
| `animationDuration` | `string` | The duration of the open/close animation. Default is `'300ms'`. |
|
|
113
|
+
| `toggleButtonIcon` | `string` | The name of the Material Icon for the toggle button. |
|
|
114
|
+
| `toggleButtonImageUrl` | `string` | The URL for a custom image on the toggle button. |
|
|
115
|
+
| `toggleButtonDimensions` | `ButtonDimensions` | An object to control the dimensions of the toggle button. See `ButtonDimensions` table below. |
|
|
116
|
+
| `closeButtonDimensions` | `IconDimensions` | An object to control the dimensions of the close icon. See `IconDimensions` table below. |
|
|
117
|
+
|
|
118
|
+
### `content`
|
|
119
|
+
| Property | Type | Description |
|
|
120
|
+
|---------------|----------|-------------------------------------------|
|
|
121
|
+
| `drawerTitle` | `string` | The title displayed in the drawer's header. |
|
|
122
|
+
| `drawerBody` | `string` | The HTML content for the drawer's body. |
|
|
123
|
+
| `mainBody` | `string` | The HTML content for the main area. |
|
|
124
|
+
|
|
125
|
+
### `toggleButtonText`
|
|
126
|
+
| Property | Type | Description |
|
|
127
|
+
|----------|----------|---------------------------------------------|
|
|
128
|
+
| `open` | `string` | Text for the toggle button to open the drawer. |
|
|
129
|
+
| `close` | `string` | Text for the toggle button to close the drawer. |
|
|
130
|
+
|
|
131
|
+
### `toggleButtonDimensions` (`ButtonDimensions`)
|
|
132
|
+
| Property | Type | Description |
|
|
133
|
+
|------------|----------|-------------------------------------------|
|
|
134
|
+
| `width` | `string` | The width of the toggle button. |
|
|
135
|
+
| `height` | `string` | The height of the toggle button. |
|
|
136
|
+
| `padding` | `string` | The padding of the toggle button. |
|
|
137
|
+
| `fontSize` | `string` | The font size of the toggle button text. |
|
|
138
|
+
| `iconSize` | `string` | The size of the icon on the toggle button. |
|
|
139
|
+
|
|
140
|
+
### `closeButtonDimensions` (`IconDimensions`)
|
|
141
|
+
| Property | Type | Description |
|
|
142
|
+
|------------|----------|----------------------------------|
|
|
143
|
+
| `width` | `string` | The width of the close button. |
|
|
144
|
+
| `height` | `string` | The height of the close button. |
|
|
145
|
+
| `iconSize` | `string` | The size of the close icon. |
|
|
146
|
+
|
|
147
|
+
## Example Configuration
|
|
148
|
+
|
|
149
|
+
Here's an example of how to configure the Drawer component in your component's TypeScript file.
|
|
150
|
+
|
|
151
|
+
```typescript
|
|
152
|
+
import { Component } from '@angular/core';
|
|
153
|
+
|
|
154
|
+
// For Complete Library
|
|
155
|
+
import { RuclibDrawerModule, RuclibDrawerInput, ButtonDimensions, IconDimensions } from '@uxpractice/ruc-lib/drawer';
|
|
156
|
+
|
|
157
|
+
// For Individual package
|
|
158
|
+
import { RuclibDrawerModule, RuclibDrawerInput, ButtonDimensions, IconDimensions } from '@ruc-lib/drawer';
|
|
159
|
+
|
|
160
|
+
@Component({
|
|
161
|
+
selector: 'app-root',
|
|
162
|
+
templateUrl: './app.component.html',
|
|
163
|
+
})
|
|
164
|
+
export class AppComponent {
|
|
165
|
+
customTheme = 'ruc-custom-theme';
|
|
166
|
+
|
|
167
|
+
drawerInput: RuclibDrawerInput = {
|
|
96
168
|
drawerPosition: 'left',
|
|
97
169
|
mode: 'over',
|
|
98
170
|
initialOpenedState: false,
|
|
99
|
-
drawerWidth: '
|
|
171
|
+
drawerWidth: '300px',
|
|
100
172
|
drawerHeight: '',
|
|
101
173
|
content: {
|
|
102
|
-
drawerTitle: '
|
|
103
|
-
drawerBody: '<p>This is
|
|
104
|
-
mainBody: '<h2>Main Content
|
|
174
|
+
drawerTitle: 'Navigation Menu',
|
|
175
|
+
drawerBody: '<p>This is where your navigation links or filters would go.</p>',
|
|
176
|
+
mainBody: '<h2>Main Application Content</h2><p>Click the button to open the drawer.</p>',
|
|
105
177
|
},
|
|
106
178
|
disableToggleButtonInMainContent: false,
|
|
107
179
|
toggleButtonText: {
|
|
108
|
-
open: 'Open
|
|
109
|
-
close: 'Close
|
|
180
|
+
open: 'Open Menu',
|
|
181
|
+
close: 'Close Menu',
|
|
110
182
|
},
|
|
111
183
|
hasBackdrop: true,
|
|
112
|
-
backdropBackgroundColor: 'rgba(
|
|
184
|
+
backdropBackgroundColor: 'rgba(0, 0, 0, 0.5)',
|
|
113
185
|
showCloseIcon: true,
|
|
114
186
|
disableClose: false,
|
|
115
|
-
animationDuration: '
|
|
116
|
-
toggleButtonIcon: '',
|
|
117
|
-
toggleButtonImageAlt: '',
|
|
187
|
+
animationDuration: '400ms',
|
|
188
|
+
toggleButtonIcon: 'menu',
|
|
118
189
|
toggleButtonImageUrl: '',
|
|
119
190
|
toggleButtonDimensions: {
|
|
120
191
|
width: 'auto',
|
|
121
|
-
height: '
|
|
122
|
-
padding: '
|
|
123
|
-
fontSize: '
|
|
192
|
+
height: '48px',
|
|
193
|
+
padding: '0 16px',
|
|
194
|
+
fontSize: '14px',
|
|
124
195
|
iconSize: '24px',
|
|
125
196
|
},
|
|
126
197
|
closeButtonDimensions: {
|
|
127
|
-
width: '
|
|
128
|
-
height: '
|
|
198
|
+
width: '48px',
|
|
199
|
+
height: '48px',
|
|
129
200
|
iconSize: '24px',
|
|
130
201
|
},
|
|
131
|
-
};
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
passEvent(event: any) {
|
|
205
|
+
console.log('Drawer Event:', event);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
132
208
|
```
|
|
133
209
|
|
|
210
|
+
> ⚠️ **IMPORTANT: Custom Theme Usage in Angular Material**
|
|
211
|
+
|
|
212
|
+
When implementing **custom themes**, such as:
|
|
213
|
+
|
|
214
|
+
```scss
|
|
215
|
+
.custom-theme-1 {
|
|
216
|
+
@include angular-material-theme($custom-theme);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
// You must also include the typography mixin to ensure text styles are applied correctly as shown below:
|
|
220
|
+
.custom-theme-1 {
|
|
221
|
+
@include angular-material-theme($custom-theme);
|
|
222
|
+
@include mat.typography-level($theme-custom-typography-name, body-1);
|
|
223
|
+
}
|
|
224
|
+
```
|
|
134
225
|
|
|
135
226
|
# Contribution
|
|
136
227
|
|
|
@@ -138,4 +229,4 @@ Contributions are welcome! Feel free to open issues or pull requests for any enh
|
|
|
138
229
|
|
|
139
230
|
# Acknowledgements
|
|
140
231
|
|
|
141
|
-
Thank you for choosing the Drawer Component Library. If you have any feedback or suggestions, please let us know!
|
|
232
|
+
Thank you for choosing the Drawer Component Library. If you have any feedback or suggestions, please let us know!
|