@memberjunction/ng-container-directives 2.43.0 → 2.45.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 +80 -12
- package/dist/public-api.js +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -2,15 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
Angular directives for container management in MemberJunction applications, providing flexible and responsive layout utilities.
|
|
4
4
|
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
This package provides two essential directives for managing container layouts in Angular applications:
|
|
8
|
+
- **mjContainer**: Exposes a ViewContainerRef for dynamic component loading
|
|
9
|
+
- **mjFillContainer**: Automatically resizes elements to fill their parent containers with intelligent context awareness
|
|
10
|
+
|
|
5
11
|
## Features
|
|
6
12
|
|
|
7
|
-
- `mjContainer` directive for view container management
|
|
13
|
+
- `mjContainer` directive for view container management and dynamic component loading
|
|
8
14
|
- `mjFillContainer` directive for responsive filling of parent containers
|
|
9
|
-
- Automatic resizing on window resize events
|
|
10
|
-
- Manual resize event handling
|
|
15
|
+
- Automatic resizing on window resize events with dual debounce strategy
|
|
16
|
+
- Manual resize event handling via MJGlobal event system
|
|
11
17
|
- Customizable margin and dimension settings
|
|
12
|
-
- Smart context detection (skips resizing in grids, hidden tabs)
|
|
13
|
-
- Efficient resize event handling with debouncing
|
|
18
|
+
- Smart context detection (automatically skips resizing in grids, hidden tabs, and elements with `mjSkipResize`)
|
|
19
|
+
- Efficient resize event handling with configurable debouncing
|
|
20
|
+
- Debug mode for troubleshooting resize behavior
|
|
14
21
|
|
|
15
22
|
## Installation
|
|
16
23
|
|
|
@@ -36,7 +43,7 @@ export class YourModule { }
|
|
|
36
43
|
|
|
37
44
|
### mjContainer
|
|
38
45
|
|
|
39
|
-
|
|
46
|
+
The `mjContainer` directive exposes a ViewContainerRef for dynamic component loading. This is particularly useful when you need to programmatically create and insert components into the DOM.
|
|
40
47
|
|
|
41
48
|
```html
|
|
42
49
|
<div mjContainer></div>
|
|
@@ -45,15 +52,23 @@ Use the `mjContainer` directive to reference a ViewContainerRef for dynamic comp
|
|
|
45
52
|
In your component:
|
|
46
53
|
|
|
47
54
|
```typescript
|
|
55
|
+
import { Component, ViewChild, ViewContainerRef } from '@angular/core';
|
|
48
56
|
import { Container } from '@memberjunction/ng-container-directives';
|
|
49
57
|
|
|
50
58
|
@Component({
|
|
51
|
-
|
|
59
|
+
selector: 'app-your-component',
|
|
60
|
+
template: `<div mjContainer></div>`
|
|
52
61
|
})
|
|
53
62
|
export class YourComponent {
|
|
54
63
|
@ViewChild(Container, { static: true }) container!: Container;
|
|
55
64
|
|
|
56
|
-
|
|
65
|
+
ngOnInit() {
|
|
66
|
+
// Access the ViewContainerRef for dynamic component creation
|
|
67
|
+
const viewContainerRef: ViewContainerRef = this.container.viewContainerRef;
|
|
68
|
+
|
|
69
|
+
// Example: Create a dynamic component
|
|
70
|
+
// const componentRef = viewContainerRef.createComponent(YourDynamicComponent);
|
|
71
|
+
}
|
|
57
72
|
}
|
|
58
73
|
```
|
|
59
74
|
|
|
@@ -183,26 +198,41 @@ When nesting components with `mjFillContainer`:
|
|
|
183
198
|
</div>
|
|
184
199
|
```
|
|
185
200
|
|
|
201
|
+
## Dependencies
|
|
202
|
+
|
|
203
|
+
This package depends on:
|
|
204
|
+
- `@memberjunction/core` - Core MemberJunction utilities and logging
|
|
205
|
+
- `@memberjunction/global` - Global event system for manual resize triggers
|
|
206
|
+
- `rxjs` - For event handling and debouncing
|
|
207
|
+
|
|
208
|
+
Peer dependencies:
|
|
209
|
+
- `@angular/common` ^18.0.2
|
|
210
|
+
- `@angular/core` ^18.0.2
|
|
211
|
+
- `@angular/router` ^18.0.2
|
|
212
|
+
|
|
186
213
|
## Troubleshooting
|
|
187
214
|
|
|
188
215
|
### Element not resizing properly
|
|
189
216
|
|
|
190
217
|
- Check if any parent has `mjSkipResize` attribute
|
|
191
|
-
- Verify the element isn't within a grid or hidden tab
|
|
192
|
-
- Ensure parent elements have proper CSS display properties
|
|
218
|
+
- Verify the element isn't within a grid (role="grid") or hidden tab
|
|
219
|
+
- Ensure parent elements have proper CSS display properties (must be 'block')
|
|
193
220
|
- Check z-index and overflow settings
|
|
221
|
+
- Verify parent visibility (elements with hidden or not displayed parents are skipped)
|
|
194
222
|
|
|
195
223
|
### Flickering during resize
|
|
196
224
|
|
|
197
225
|
- This is usually caused by cascading resize calculations
|
|
198
226
|
- Try applying `mjFillContainer` only where necessary
|
|
199
227
|
- Use CSS transitions for smoother visual changes
|
|
228
|
+
- Consider the dual debounce strategy (100ms during resize, 500ms after)
|
|
200
229
|
|
|
201
230
|
### Height calculation issues
|
|
202
231
|
|
|
203
232
|
- Ensure parent element has a defined height or position
|
|
204
233
|
- For full window height, apply directive to a root element
|
|
205
234
|
- Check for competing CSS that might override the directive's styles
|
|
235
|
+
- Note that padding is accounted for in calculations
|
|
206
236
|
|
|
207
237
|
## Advanced Controls
|
|
208
238
|
|
|
@@ -214,6 +244,44 @@ import { FillContainer } from '@memberjunction/ng-container-directives';
|
|
|
214
244
|
// Disable resize globally (for all instances)
|
|
215
245
|
FillContainer.DisableResize = true;
|
|
216
246
|
|
|
217
|
-
// Enable resize debugging
|
|
247
|
+
// Enable resize debugging (logs to console)
|
|
218
248
|
FillContainer.OutputDebugInfo = true;
|
|
219
|
-
```
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
## API Reference
|
|
252
|
+
|
|
253
|
+
### Container Directive
|
|
254
|
+
|
|
255
|
+
```typescript
|
|
256
|
+
@Directive({
|
|
257
|
+
selector: '[mjContainer]'
|
|
258
|
+
})
|
|
259
|
+
export class Container {
|
|
260
|
+
constructor(public viewContainerRef: ViewContainerRef) { }
|
|
261
|
+
}
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
### FillContainer Directive
|
|
265
|
+
|
|
266
|
+
```typescript
|
|
267
|
+
@Directive({
|
|
268
|
+
selector: '[mjFillContainer]'
|
|
269
|
+
})
|
|
270
|
+
export class FillContainer {
|
|
271
|
+
@Input() fillWidth: boolean = true;
|
|
272
|
+
@Input() fillHeight: boolean = true;
|
|
273
|
+
@Input() rightMargin: number = 0;
|
|
274
|
+
@Input() bottomMargin: number = 0;
|
|
275
|
+
|
|
276
|
+
static DisableResize: boolean = false;
|
|
277
|
+
static OutputDebugInfo: boolean = false;
|
|
278
|
+
}
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
## Contributing
|
|
282
|
+
|
|
283
|
+
When contributing to this package:
|
|
284
|
+
1. Follow the MemberJunction development guidelines
|
|
285
|
+
2. Ensure all TypeScript compiles without errors: `npm run build`
|
|
286
|
+
3. Update this README if adding new features or changing behavior
|
|
287
|
+
4. Add appropriate TSDoc comments to all public APIs
|
package/dist/public-api.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@memberjunction/ng-container-directives",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.45.0",
|
|
4
4
|
"description": "MemberJunction: Angular Container Directives - Fill Container for Auto-Resizing, and plain container just for element identification/binding",
|
|
5
5
|
"main": "./dist/public-api.js",
|
|
6
6
|
"typings": "./dist/public-api.d.ts",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"@angular/router": "18.0.2"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@memberjunction/core": "2.
|
|
33
|
-
"@memberjunction/global": "2.
|
|
32
|
+
"@memberjunction/core": "2.45.0",
|
|
33
|
+
"@memberjunction/global": "2.45.0",
|
|
34
34
|
"tslib": "^2.3.0"
|
|
35
35
|
},
|
|
36
36
|
"sideEffects": false
|