@memberjunction/ng-generic-dialog 2.43.0 → 2.44.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.
Files changed (2) hide show
  1. package/README.md +247 -27
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,15 +1,21 @@
1
- # Generic Dialog Component
1
+ # @memberjunction/ng-generic-dialog
2
2
 
3
3
  A flexible and customizable dialog component for Angular applications in the MemberJunction framework. This component provides a consistent way to create modal dialogs with standard features like OK/Cancel buttons and custom action slots.
4
4
 
5
+ ## Overview
6
+
7
+ The `@memberjunction/ng-generic-dialog` package provides a reusable Angular dialog component built on top of Kendo UI's dialog and button components. It offers a standardized way to create modals with configurable content, actions, and behavior while maintaining consistency across your MemberJunction application.
8
+
5
9
  ## Features
6
10
 
7
- - **Customizable Content**: Easily insert any content inside the dialog body
8
- - **Flexible Button Options**: Show/hide standard OK and Cancel buttons
9
- - **Custom Actions**: Add custom buttons and actions through content projection
11
+ - **Customizable Content**: Easily insert any content inside the dialog body using content projection
12
+ - **Flexible Button Options**: Show/hide standard OK and Cancel buttons with customizable text
13
+ - **Custom Actions**: Add custom buttons and actions through the `custom-actions` content projection slot
10
14
  - **Responsive Design**: Configure width and height in pixels or percentages
11
- - **Event Handling**: Events for dialog closure and data refreshing
12
- - **Simple Integration**: Easy to use in any Angular component
15
+ - **Event Handling**: Built-in events for dialog closure and data refresh lifecycle
16
+ - **Auto-refresh**: Automatically triggers data refresh when dialog becomes visible
17
+ - **Kendo UI Integration**: Seamlessly integrates with Kendo UI theming system
18
+ - **TypeScript Support**: Full TypeScript support with proper typing
13
19
 
14
20
  ## Installation
15
21
 
@@ -17,6 +23,15 @@ A flexible and customizable dialog component for Angular applications in the Mem
17
23
  npm install @memberjunction/ng-generic-dialog
18
24
  ```
19
25
 
26
+ ### Peer Dependencies
27
+
28
+ This package requires the following peer dependencies:
29
+
30
+ - `@angular/common`: ^18.0.2
31
+ - `@angular/core`: ^18.0.2
32
+ - `@progress/kendo-angular-buttons`: ^16.2.0
33
+ - `@progress/kendo-angular-dialog`: ^16.2.0
34
+
20
35
  ## Usage
21
36
 
22
37
  ### Import the Module
@@ -159,39 +174,244 @@ export class SettingsDialogComponent {
159
174
  }
160
175
  ```
161
176
 
162
- ## API Reference
177
+ ## Component API
178
+
179
+ ### Selector
180
+ `mj-generic-dialog`
163
181
 
164
182
  ### Inputs
165
183
 
166
- - `DialogTitle`: string - Title displayed in the dialog header (default: 'Default Title')
167
- - `DialogWidth`: string - Width of the dialog (default: '700px')
168
- - `DialogHeight`: string - Height of the dialog (default: '450px')
169
- - `ShowOKButton`: boolean - Whether to show the OK button (default: true)
170
- - `OKButtonText`: string - Text for the OK button (default: 'OK')
171
- - `ShowCancelButton`: boolean - Whether to show the Cancel button (default: true)
172
- - `CancelButtonText`: string - Text for the Cancel button (default: 'Cancel')
173
- - `DialogVisible`: boolean - Controls the visibility of the dialog
184
+ | Property | Type | Default | Description |
185
+ |----------|------|---------|-------------|
186
+ | `DialogTitle` | `string` | `'Default Title'` | Title displayed in the dialog header |
187
+ | `DialogWidth` | `string` | `'700px'` | Width of the dialog in pixels or percentage |
188
+ | `DialogHeight` | `string` | `'450px'` | Height of the dialog in pixels or percentage |
189
+ | `DialogVisible` | `boolean` | `false` | Controls the visibility of the dialog. When set to `true`, triggers `RefreshData` event |
190
+ | `ShowOKButton` | `boolean` | `true` | Whether to show the OK button |
191
+ | `OKButtonText` | `string` | `'OK'` | Text displayed on the OK button |
192
+ | `ShowCancelButton` | `boolean` | `true` | Whether to show the Cancel button |
193
+ | `CancelButtonText` | `string` | `'Cancel'` | Text displayed on the Cancel button |
174
194
 
175
195
  ### Outputs
176
196
 
177
- - `DialogClosed`: EventEmitter<boolean> - Emitted when the dialog is closed (true if OK, false if Cancel)
178
- - `RefreshData`: EventEmitter<void> - Emitted when the dialog needs to refresh its content data
197
+ | Event | Type | Description |
198
+ |-------|------|-------------|
199
+ | `DialogClosed` | `EventEmitter<boolean>` | Emitted when the dialog is closed. Returns `true` if closed via OK button, `false` if closed via Cancel button or X |
200
+ | `RefreshData` | `EventEmitter<void>` | Emitted when the dialog becomes visible, allowing parent components to refresh data |
179
201
 
180
- ### Methods
202
+ ### Public Methods
181
203
 
182
- - `HandleOKClick()`: Programmatically trigger the OK button click
183
- - `HandleCancelClick()`: Programmatically trigger the Cancel button click
204
+ | Method | Description |
205
+ |--------|-------------|
206
+ | `HandleOKClick()` | Programmatically trigger the OK button click. Closes dialog and emits `DialogClosed` with `true` |
207
+ | `HandleCancelClick()` | Programmatically trigger the Cancel button click. Closes dialog and emits `DialogClosed` with `false` |
184
208
 
185
- ### Content Projection
209
+ ### Content Projection Slots
210
+
211
+ - **Default slot**: Content displayed in the dialog body
212
+ - **`custom-actions` slot**: Content projected into the dialog action area for custom buttons. Use the `custom-actions` attribute on any element to project it into this slot
213
+
214
+ ## Advanced Usage
215
+
216
+ ### Programmatic Control
217
+
218
+ You can control the dialog programmatically from the parent component:
219
+
220
+ ```typescript
221
+ import { Component, ViewChild } from '@angular/core';
222
+ import { GenericDialogComponent } from '@memberjunction/ng-generic-dialog';
186
223
 
187
- - Default content slot: Content displayed in the dialog body
188
- - `custom-actions` slot: Projected into the dialog action area for custom buttons
224
+ @Component({
225
+ selector: 'app-advanced-dialog',
226
+ template: `
227
+ <mj-generic-dialog #myDialog
228
+ DialogTitle="Programmatic Control"
229
+ [DialogVisible]="isDialogVisible"
230
+ (DialogClosed)="onDialogClosed($event)">
231
+ <div>Dialog content here</div>
232
+ </mj-generic-dialog>
233
+
234
+ <button (click)="openDialog()">Open Dialog</button>
235
+ <button (click)="closeDialogProgrammatically(true)">Close with OK</button>
236
+ <button (click)="closeDialogProgrammatically(false)">Close with Cancel</button>
237
+ `
238
+ })
239
+ export class AdvancedDialogComponent {
240
+ @ViewChild('myDialog') dialog!: GenericDialogComponent;
241
+ isDialogVisible = false;
242
+
243
+ openDialog() {
244
+ this.isDialogVisible = true;
245
+ }
246
+
247
+ closeDialogProgrammatically(withOK: boolean) {
248
+ if (withOK) {
249
+ this.dialog.HandleOKClick();
250
+ } else {
251
+ this.dialog.HandleCancelClick();
252
+ }
253
+ }
254
+
255
+ onDialogClosed(confirmed: boolean) {
256
+ console.log('Dialog closed with:', confirmed ? 'OK' : 'Cancel');
257
+ }
258
+ }
259
+ ```
260
+
261
+ ### Data Refresh Pattern
262
+
263
+ The dialog automatically emits a `RefreshData` event when it becomes visible. Use this to load fresh data:
264
+
265
+ ```typescript
266
+ @Component({
267
+ selector: 'app-data-dialog',
268
+ template: `
269
+ <mj-generic-dialog
270
+ DialogTitle="User Details"
271
+ [DialogVisible]="showUserDialog"
272
+ (DialogClosed)="onDialogClosed($event)"
273
+ (RefreshData)="loadUserData()">
274
+
275
+ <div *ngIf="userData">
276
+ <p>Name: {{ userData.name }}</p>
277
+ <p>Email: {{ userData.email }}</p>
278
+ <p>Last Updated: {{ userData.lastUpdated }}</p>
279
+ </div>
280
+
281
+ <div *ngIf="loading">Loading...</div>
282
+ </mj-generic-dialog>
283
+ `
284
+ })
285
+ export class DataDialogComponent {
286
+ showUserDialog = false;
287
+ userData: any = null;
288
+ loading = false;
289
+
290
+ loadUserData() {
291
+ this.loading = true;
292
+ // Simulate API call
293
+ setTimeout(() => {
294
+ this.userData = {
295
+ name: 'John Doe',
296
+ email: 'john@example.com',
297
+ lastUpdated: new Date().toLocaleString()
298
+ };
299
+ this.loading = false;
300
+ }, 1000);
301
+ }
302
+
303
+ onDialogClosed(confirmed: boolean) {
304
+ this.showUserDialog = false;
305
+ if (confirmed) {
306
+ console.log('Saving user data...');
307
+ }
308
+ }
309
+ }
310
+ ```
189
311
 
190
312
  ## Styling
191
313
 
192
- The component uses Kendo UI dialog and button components, which follow the Kendo UI theming system. You can apply your own styles to the content within the dialog.
314
+ The component uses Kendo UI dialog and button components, which inherit the active Kendo theme. You can apply custom styles to the content within the dialog using standard CSS or Angular styling approaches.
315
+
316
+ ### Custom Styling Example
317
+
318
+ ```css
319
+ /* In your component styles */
320
+ :host ::ng-deep .k-dialog-title {
321
+ background-color: #3f51b5;
322
+ color: white;
323
+ }
324
+
325
+ :host ::ng-deep .k-dialog-content {
326
+ padding: 20px;
327
+ }
328
+
329
+ .settings-form {
330
+ display: flex;
331
+ flex-direction: column;
332
+ gap: 15px;
333
+ }
334
+
335
+ .form-group {
336
+ display: flex;
337
+ align-items: center;
338
+ gap: 10px;
339
+ }
340
+ ```
341
+
342
+ ## Integration with MemberJunction
343
+
344
+ This dialog component is designed to work seamlessly within the MemberJunction framework:
345
+
346
+ - **Consistent UI**: Follows MemberJunction's UI patterns and Kendo theme
347
+ - **TypeScript Support**: Full type safety for all properties and events
348
+ - **Angular Best Practices**: Uses OnPush change detection strategy compatible patterns
349
+ - **Accessibility**: Inherits Kendo UI's accessibility features
350
+
351
+ ## Common Patterns
352
+
353
+ ### Confirmation Dialog
354
+ ```typescript
355
+ <mj-generic-dialog
356
+ DialogTitle="Confirm Delete"
357
+ DialogWidth="400px"
358
+ DialogHeight="200px"
359
+ [DialogVisible]="showDeleteConfirm"
360
+ OKButtonText="Delete"
361
+ CancelButtonText="Keep"
362
+ (DialogClosed)="handleDeleteConfirmation($event)">
363
+ <div>
364
+ <p>Are you sure you want to delete this item?</p>
365
+ <p><strong>This action cannot be undone.</strong></p>
366
+ </div>
367
+ </mj-generic-dialog>
368
+ ```
369
+
370
+ ### Form Dialog
371
+ ```typescript
372
+ <mj-generic-dialog
373
+ DialogTitle="Edit User"
374
+ DialogWidth="600px"
375
+ [DialogVisible]="showEditDialog"
376
+ [ShowOKButton]="false"
377
+ [ShowCancelButton]="false"
378
+ (RefreshData)="loadUserForEdit()">
379
+
380
+ <form [formGroup]="userForm">
381
+ <!-- Form fields -->
382
+ </form>
383
+
384
+ <div custom-actions>
385
+ <button kendoButton
386
+ [disabled]="!userForm.valid"
387
+ (click)="saveUser()"
388
+ themeColor="primary">
389
+ Save Changes
390
+ </button>
391
+ <button kendoButton (click)="cancelEdit()">Cancel</button>
392
+ </div>
393
+ </mj-generic-dialog>
394
+ ```
395
+
396
+ ## Troubleshooting
397
+
398
+ ### Dialog Not Showing
399
+ - Ensure `DialogVisible` is properly bound to a boolean property
400
+ - Check that the module is imported correctly
401
+ - Verify Kendo UI dependencies are installed
402
+
403
+ ### Custom Actions Not Appearing
404
+ - Use the `custom-actions` attribute on the container element
405
+ - Ensure the element is a direct child of `mj-generic-dialog`
406
+
407
+ ### Dialog Closes Immediately
408
+ - Check for any code that might be setting `DialogVisible` to false
409
+ - Ensure event handlers aren't causing unintended state changes
410
+
411
+ ## Version History
412
+
413
+ See [CHANGELOG.md](./CHANGELOG.md) for detailed version history.
193
414
 
194
- ## Dependencies
415
+ ## License
195
416
 
196
- - `@progress/kendo-angular-dialog`: For the dialog component
197
- - `@progress/kendo-angular-buttons`: For the buttons
417
+ This package is part of the MemberJunction framework and follows the same license terms.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@memberjunction/ng-generic-dialog",
3
- "version": "2.43.0",
3
+ "version": "2.44.0",
4
4
  "description": "MemberJunction: Angular component for a generic dialog",
5
5
  "main": "./dist/public-api.js",
6
6
  "typings": "./dist/public-api.d.ts",