@memberjunction/ng-container-directives 6.1.4 → 6.2.0-edge.1
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/dist/lib/ng-container-directive.js +1 -1
- package/dist/lib/ng-container-directive.js.map +1 -1
- package/dist/lib/ng-fill-container-directive.d.ts +21 -5
- package/dist/lib/ng-fill-container-directive.d.ts.map +1 -1
- package/dist/lib/ng-fill-container-directive.js +50 -10
- package/dist/lib/ng-fill-container-directive.js.map +1 -1
- package/package.json +3 -3
|
@@ -21,7 +21,7 @@ export class Container {
|
|
|
21
21
|
*/
|
|
22
22
|
constructor(viewContainerRef) {
|
|
23
23
|
this.viewContainerRef = viewContainerRef;
|
|
24
|
-
}
|
|
24
|
+
} // case-violation-ok-legacy-back-compat: object literals are assigned to this class, so an accessor stub changes what they must supply
|
|
25
25
|
static ɵfac = function Container_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || Container)(i0.ɵɵdirectiveInject(i0.ViewContainerRef)); };
|
|
26
26
|
static ɵdir = /*@__PURE__*/ i0.ɵɵdefineDirective({ type: Container, selectors: [["", "mjContainer", ""]], standalone: false });
|
|
27
27
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ng-container-directive.js","sourceRoot":"","sources":["../../src/lib/ng-container-directive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAoB,MAAM,eAAe,CAAC;;AAE5D;;;;;;;;;;;;GAYG;AAKH,MAAM,OAAO,SAAS;IAKD;IAJnB;;;OAGG;IACH,YAAmB,gBAAkC;QAAlC,qBAAgB,GAAhB,gBAAgB,CAAkB;IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"ng-container-directive.js","sourceRoot":"","sources":["../../src/lib/ng-container-directive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAoB,MAAM,eAAe,CAAC;;AAE5D;;;;;;;;;;;;GAYG;AAKH,MAAM,OAAO,SAAS;IAKD;IAJnB;;;OAGG;IACH,YAAmB,gBAAkC;QAAlC,qBAAgB,GAAhB,gBAAgB,CAAkB;IAAI,CAAC,CAAE,sIAAsI;mGALvL,SAAS;6DAAT,SAAS;;iFAAT,SAAS;cAJrB,SAAS;eAAC;gBACT,UAAU,EAAE,KAAK;gBACjB,QAAQ,EAAE,eAAe;aAC1B","sourcesContent":["import { Directive, ViewContainerRef } from '@angular/core';\n\n/**\n * Directive that exposes a ViewContainerRef for dynamic component loading.\n * This is used to create a reference point for dynamically loading components\n * into the DOM without manually handling ViewContainerRef injection.\n * \n * @example\n * <!-- In template -->\n * <div mjContainer></div>\n *\n * <!-- In component -->\n * @ViewChild(Container, { static: true }) container!: Container;\n * // Now you can use this.container.viewContainerRef for dynamic component creation\n */\n@Directive({\n standalone: false,\n selector: '[mjContainer]',\n})\nexport class Container {\n /**\n * Constructor that exposes the ViewContainerRef for the element\n * @param viewContainerRef The ViewContainerRef for the element this directive is applied to\n */\n constructor(public viewContainerRef: ViewContainerRef) { } // case-violation-ok-legacy-back-compat: object literals are assigned to this class, so an accessor stub changes what they must supply\n}\n"]}
|
|
@@ -20,13 +20,29 @@ import * as i0 from "@angular/core";
|
|
|
20
20
|
export declare class FillContainer implements OnInit, OnDestroy {
|
|
21
21
|
private elementRef;
|
|
22
22
|
/** Whether to fill the parent's width. Default is true. */
|
|
23
|
-
|
|
23
|
+
FillWidth: boolean;
|
|
24
|
+
/** @deprecated Use {@link FillWidth}. */
|
|
25
|
+
set fillWidth(value: boolean);
|
|
26
|
+
/** @deprecated Use {@link FillWidth}. */
|
|
27
|
+
get fillWidth(): boolean;
|
|
24
28
|
/** Whether to fill the parent's height. Default is true. */
|
|
25
|
-
|
|
29
|
+
FillHeight: boolean;
|
|
30
|
+
/** @deprecated Use {@link FillHeight}. */
|
|
31
|
+
set fillHeight(value: boolean);
|
|
32
|
+
/** @deprecated Use {@link FillHeight}. */
|
|
33
|
+
get fillHeight(): boolean;
|
|
26
34
|
/** Right margin in pixels. Default is 0. */
|
|
27
|
-
|
|
35
|
+
RightMargin: number;
|
|
36
|
+
/** @deprecated Use {@link RightMargin}. */
|
|
37
|
+
set rightMargin(value: number);
|
|
38
|
+
/** @deprecated Use {@link RightMargin}. */
|
|
39
|
+
get rightMargin(): number;
|
|
28
40
|
/** Bottom margin in pixels. Default is 0. */
|
|
29
|
-
|
|
41
|
+
BottomMargin: number;
|
|
42
|
+
/** @deprecated Use {@link BottomMargin}. */
|
|
43
|
+
set bottomMargin(value: number);
|
|
44
|
+
/** @deprecated Use {@link BottomMargin}. */
|
|
45
|
+
get bottomMargin(): number;
|
|
30
46
|
/** Flag to globally disable resize functionality for all instances */
|
|
31
47
|
static DisableResize: boolean;
|
|
32
48
|
/** Flag to enable debug logging for resize operations */
|
|
@@ -82,6 +98,6 @@ export declare class FillContainer implements OnInit, OnDestroy {
|
|
|
82
98
|
*/
|
|
83
99
|
protected elementWithinGrid(element: HTMLElement): boolean;
|
|
84
100
|
static ɵfac: i0.ɵɵFactoryDeclaration<FillContainer, never>;
|
|
85
|
-
static ɵdir: i0.ɵɵDirectiveDeclaration<FillContainer, "[mjFillContainer]", never, { "fillWidth": { "alias": "fillWidth"; "required": false; }; "fillHeight": { "alias": "fillHeight"; "required": false; }; "rightMargin": { "alias": "rightMargin"; "required": false; }; "bottomMargin": { "alias": "bottomMargin"; "required": false; }; }, {}, never, never, false, never>;
|
|
101
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<FillContainer, "[mjFillContainer]", never, { "FillWidth": { "alias": "FillWidth"; "required": false; }; "fillWidth": { "alias": "fillWidth"; "required": false; }; "FillHeight": { "alias": "FillHeight"; "required": false; }; "fillHeight": { "alias": "fillHeight"; "required": false; }; "RightMargin": { "alias": "RightMargin"; "required": false; }; "rightMargin": { "alias": "rightMargin"; "required": false; }; "BottomMargin": { "alias": "BottomMargin"; "required": false; }; "bottomMargin": { "alias": "bottomMargin"; "required": false; }; }, {}, never, never, false, never>;
|
|
86
102
|
}
|
|
87
103
|
//# sourceMappingURL=ng-fill-container-directive.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ng-fill-container-directive.d.ts","sourceRoot":"","sources":["../../src/lib/ng-fill-container-directive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,UAAU,EAAS,SAAS,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;;AAMhF;;;;;;;;;;;;;;;;GAgBG;AACH,qBAIa,aAAc,YAAW,MAAM,EAAE,SAAS;
|
|
1
|
+
{"version":3,"file":"ng-fill-container-directive.d.ts","sourceRoot":"","sources":["../../src/lib/ng-fill-container-directive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,UAAU,EAAS,SAAS,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;;AAMhF;;;;;;;;;;;;;;;;GAgBG;AACH,qBAIa,aAAc,YAAW,MAAM,EAAE,SAAS;IAiEzC,OAAO,CAAC,UAAU;IAhE9B,2DAA2D;IAClD,SAAS,EAAE,OAAO,CAAQ;IAEnC,yCAAyC;IACzC,IAAa,SAAS,CAAC,KAAK,EAAE,OAAO,EAEpC;IACD,yCAAyC;IACzC,IAAI,SAAS,IAAI,OAAO,CAEvB;IAED,4DAA4D;IACnD,UAAU,EAAE,OAAO,CAAQ;IAEpC,0CAA0C;IAC1C,IAAa,UAAU,CAAC,KAAK,EAAE,OAAO,EAErC;IACD,0CAA0C;IAC1C,IAAI,UAAU,IAAI,OAAO,CAExB;IAED,4CAA4C;IACnC,WAAW,EAAE,MAAM,CAAK;IAEjC,2CAA2C;IAC3C,IAAa,WAAW,CAAC,KAAK,EAAE,MAAM,EAErC;IACD,2CAA2C;IAC3C,IAAI,WAAW,IAAI,MAAM,CAExB;IAED,6CAA6C;IACpC,YAAY,EAAE,MAAM,CAAK;IAElC,4CAA4C;IAC5C,IAAa,YAAY,CAAC,KAAK,EAAE,MAAM,EAEtC;IACD,4CAA4C;IAC5C,IAAI,YAAY,IAAI,MAAM,CAEzB;IAED,sEAAsE;IACtE,OAAc,aAAa,EAAE,OAAO,CAAS;IAE7C,yDAAyD;IACzD,OAAc,eAAe,EAAE,OAAO,CAAS;IAE/C;;;OAGG;IACH,SAAS,CAAC,MAAM,CAAC,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;gBAMtC,UAAU,EAAE,UAAU;IAG1C,4EAA4E;IAC5E,OAAO,CAAC,mBAAmB,CAAe;IAE1C,yDAAyD;IACzD,OAAO,CAAC,sBAAsB,CAAe;IAE7C,yCAAyC;IACzC,OAAO,CAAC,mBAAmB,CAA6B;IAExD,+CAA+C;IAC/C,OAAO,CAAC,4BAA4B,CAA6B;IAEjE;;OAEG;IACH,QAAQ,IAAI,IAAI;IAuDhB;;OAEG;IACH,WAAW,IAAI,IAAI;IAKnB;;;;OAIG;IACH,SAAS,CAAC,SAAS,CAAC,OAAO,EAAE,WAAW,GAAG,WAAW,GAAG,IAAI;IAW7D;;OAEG;IACH,SAAS,CAAC,aAAa,IAAI,IAAI;IAqD/B;;;;OAIG;IACH,SAAS,CAAC,gBAAgB,CAAC,EAAE,EAAE,WAAW,GAAG,OAAO;IAWpD;;;;OAIG;IACH,SAAS,CAAC,qBAAqB,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO;IAkB9D;;;;OAIG;IACH,SAAS,CAAC,iBAAiB,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO;yCAtQ/C,aAAa;2CAAb,aAAa;CAmRzB"}
|
|
@@ -24,13 +24,45 @@ import * as i0 from "@angular/core";
|
|
|
24
24
|
export class FillContainer {
|
|
25
25
|
elementRef;
|
|
26
26
|
/** Whether to fill the parent's width. Default is true. */
|
|
27
|
-
|
|
27
|
+
FillWidth = true;
|
|
28
|
+
/** @deprecated Use {@link FillWidth}. */
|
|
29
|
+
set fillWidth(value) {
|
|
30
|
+
this.FillWidth = value;
|
|
31
|
+
}
|
|
32
|
+
/** @deprecated Use {@link FillWidth}. */
|
|
33
|
+
get fillWidth() {
|
|
34
|
+
return this.FillWidth;
|
|
35
|
+
}
|
|
28
36
|
/** Whether to fill the parent's height. Default is true. */
|
|
29
|
-
|
|
37
|
+
FillHeight = true;
|
|
38
|
+
/** @deprecated Use {@link FillHeight}. */
|
|
39
|
+
set fillHeight(value) {
|
|
40
|
+
this.FillHeight = value;
|
|
41
|
+
}
|
|
42
|
+
/** @deprecated Use {@link FillHeight}. */
|
|
43
|
+
get fillHeight() {
|
|
44
|
+
return this.FillHeight;
|
|
45
|
+
}
|
|
30
46
|
/** Right margin in pixels. Default is 0. */
|
|
31
|
-
|
|
47
|
+
RightMargin = 0;
|
|
48
|
+
/** @deprecated Use {@link RightMargin}. */
|
|
49
|
+
set rightMargin(value) {
|
|
50
|
+
this.RightMargin = value;
|
|
51
|
+
}
|
|
52
|
+
/** @deprecated Use {@link RightMargin}. */
|
|
53
|
+
get rightMargin() {
|
|
54
|
+
return this.RightMargin;
|
|
55
|
+
}
|
|
32
56
|
/** Bottom margin in pixels. Default is 0. */
|
|
33
|
-
|
|
57
|
+
BottomMargin = 0;
|
|
58
|
+
/** @deprecated Use {@link BottomMargin}. */
|
|
59
|
+
set bottomMargin(value) {
|
|
60
|
+
this.BottomMargin = value;
|
|
61
|
+
}
|
|
62
|
+
/** @deprecated Use {@link BottomMargin}. */
|
|
63
|
+
get bottomMargin() {
|
|
64
|
+
return this.BottomMargin;
|
|
65
|
+
}
|
|
34
66
|
/** Flag to globally disable resize functionality for all instances */
|
|
35
67
|
static DisableResize = false;
|
|
36
68
|
/** Flag to enable debug logging for resize operations */
|
|
@@ -155,16 +187,16 @@ export class FillContainer {
|
|
|
155
187
|
const elementRect = element.getBoundingClientRect();
|
|
156
188
|
let paddingTop = parseInt(parentStyle.getPropertyValue('padding-top'));
|
|
157
189
|
let paddingLeft = parseInt(parentStyle.getPropertyValue('padding-left'));
|
|
158
|
-
if (this.
|
|
190
|
+
if (this.FillWidth) {
|
|
159
191
|
const widthVariance = (elementRect.left - parentRect.left) + paddingLeft + (paddingLeft > 0 ? 1 : 0); // add 1 to account for rounding errors
|
|
160
|
-
const newWidth = Math.floor(parentRect.width - this.
|
|
192
|
+
const newWidth = Math.floor(parentRect.width - this.RightMargin - widthVariance);
|
|
161
193
|
if (Math.floor(elementRect.width) !== newWidth) {
|
|
162
194
|
element.style.width = newWidth + 'px';
|
|
163
195
|
}
|
|
164
196
|
}
|
|
165
|
-
if (this.
|
|
197
|
+
if (this.FillHeight) {
|
|
166
198
|
const heightVariance = (elementRect.top - parentRect.top) + paddingTop + (paddingTop > 0 ? 1 : 0); // add 1 to account for rounding errors
|
|
167
|
-
const newHeight = Math.floor(parentRect.height - this.
|
|
199
|
+
const newHeight = Math.floor(parentRect.height - this.BottomMargin - heightVariance);
|
|
168
200
|
if (Math.floor(elementRect.height) !== newHeight) {
|
|
169
201
|
element.style.height = newHeight + 'px';
|
|
170
202
|
}
|
|
@@ -234,7 +266,7 @@ export class FillContainer {
|
|
|
234
266
|
return false;
|
|
235
267
|
}
|
|
236
268
|
static ɵfac = function FillContainer_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || FillContainer)(i0.ɵɵdirectiveInject(i0.ElementRef)); };
|
|
237
|
-
static ɵdir = /*@__PURE__*/ i0.ɵɵdefineDirective({ type: FillContainer, selectors: [["", "mjFillContainer", ""]], inputs: { fillWidth: "fillWidth", fillHeight: "fillHeight", rightMargin: "rightMargin", bottomMargin: "bottomMargin" }, standalone: false });
|
|
269
|
+
static ɵdir = /*@__PURE__*/ i0.ɵɵdefineDirective({ type: FillContainer, selectors: [["", "mjFillContainer", ""]], inputs: { FillWidth: "FillWidth", fillWidth: "fillWidth", FillHeight: "FillHeight", fillHeight: "fillHeight", RightMargin: "RightMargin", rightMargin: "rightMargin", BottomMargin: "BottomMargin", bottomMargin: "bottomMargin" }, standalone: false });
|
|
238
270
|
}
|
|
239
271
|
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(FillContainer, [{
|
|
240
272
|
type: Directive,
|
|
@@ -242,12 +274,20 @@ export class FillContainer {
|
|
|
242
274
|
standalone: false,
|
|
243
275
|
selector: '[mjFillContainer]'
|
|
244
276
|
}]
|
|
245
|
-
}], () => [{ type: i0.ElementRef }], {
|
|
277
|
+
}], () => [{ type: i0.ElementRef }], { FillWidth: [{
|
|
278
|
+
type: Input
|
|
279
|
+
}], fillWidth: [{
|
|
280
|
+
type: Input
|
|
281
|
+
}], FillHeight: [{
|
|
246
282
|
type: Input
|
|
247
283
|
}], fillHeight: [{
|
|
248
284
|
type: Input
|
|
285
|
+
}], RightMargin: [{
|
|
286
|
+
type: Input
|
|
249
287
|
}], rightMargin: [{
|
|
250
288
|
type: Input
|
|
289
|
+
}], BottomMargin: [{
|
|
290
|
+
type: Input
|
|
251
291
|
}], bottomMargin: [{
|
|
252
292
|
type: Input
|
|
253
293
|
}] }); })();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ng-fill-container-directive.js","sourceRoot":"","sources":["../../src/lib/ng-fill-container-directive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAc,KAAK,EAAqB,MAAM,eAAe,CAAC;AAChF,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAgB,MAAM,MAAM,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;;AAE/D;;;;;;;;;;;;;;;;GAgBG;AAKH,MAAM,OAAO,aAAa;IA6BJ;IA5BpB,2DAA2D;IAClD,SAAS,GAAY,IAAI,CAAC;IAEnC,4DAA4D;IACnD,UAAU,GAAY,IAAI,CAAC;IAEpC,4CAA4C;IACnC,WAAW,GAAW,CAAC,CAAC;IAEjC,6CAA6C;IACpC,YAAY,GAAW,CAAC,CAAC;IAElC,sEAAsE;IAC/D,MAAM,CAAC,aAAa,GAAY,KAAK,C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,CAAC;QAChC,CAAC;QACD,mBAAmB;QACnB,OAAO,KAAK,CAAC;IACf,CAAC;uGA9OU,aAAa;6DAAb,aAAa;;iFAAb,aAAa;cAJzB,SAAS;eAAC;gBACT,UAAU,EAAE,KAAK;gBACjB,QAAQ,EAAE,mBAAmB;aAC9B;;kBAGE,KAAK;;kBAGL,KAAK;;kBAGL,KAAK;;kBAGL,KAAK","sourcesContent":["import { Directive, ElementRef, Input, OnDestroy, OnInit } from '@angular/core';\nimport { LogError, LogStatus } from '@memberjunction/core';\nimport { fromEvent, Subscription } from 'rxjs';\nimport { debounceTime } from 'rxjs/operators';\nimport { MJEventType, MJGlobal } from '@memberjunction/global';\n\n/**\n * Directive that automatically resizes an element to fill its parent container.\n * This directive calculates and sets dimensions based on the parent container's size,\n * accounting for the element's position within the parent and any specified margins.\n * \n * It listens for window resize events and custom MJ application events to update dimensions.\n * The directive is context-aware and will automatically skip resizing in certain conditions.\n *\n * @example\n * <!-- Basic usage (fills both width and height) -->\n * <div >Content</div>\n *\n * <!-- With custom settings -->\n * <div [fillWidth]=\"true\" [fillHeight]=\"true\" [rightMargin]=\"10\" [bottomMargin]=\"20\">\n * Content with margins\n * </div>\n */\n@Directive({\n standalone: false,\n selector: '[mjFillContainer]'\n})\nexport class FillContainer implements OnInit, OnDestroy {\n /** Whether to fill the parent's width. Default is true. */\n @Input() fillWidth: boolean = true;\n \n /** Whether to fill the parent's height. Default is true. */\n @Input() fillHeight: boolean = true;\n \n /** Right margin in pixels. Default is 0. */\n @Input() rightMargin: number = 0;\n \n /** Bottom margin in pixels. Default is 0. */\n @Input() bottomMargin: number = 0;\n\n /** Flag to globally disable resize functionality for all instances */\n public static DisableResize: boolean = false;\n \n /** Flag to enable debug logging for resize operations */\n public static OutputDebugInfo: boolean = false;\n \n /**\n * Outputs a debug message if OutputDebugInfo is enabled\n * @param message The message to output\n */\n protected static OutputDebugMessage(message: string): void {\n if (FillContainer.OutputDebugInfo) {\n console.log(message);\n }\n }\n\n constructor(private elementRef: ElementRef) {\n }\n\n /** Debounce time for resize events during active resizing (milliseconds) */\n private _resizeDebounceTime: number = 100;\n \n /** Debounce time for resize end events (milliseconds) */\n private _resizeEndDebounceTime: number = 500;\n\n /** Subscription for resize end events */\n private _resizeSubscription: Subscription | null = null;\n \n /** Subscription for immediate resize events */\n private _resizeImmediateSubscription: Subscription | null = null;\n\n /**\n * Initializes the directive, sets up resize event listeners and performs initial resize\n */\n ngOnInit(): void {\n const el = this.elementRef.nativeElement as HTMLElement;\n if (el && el.style) { \n // initial resize\n FillContainer.OutputDebugMessage('');\n FillContainer.OutputDebugMessage('Initial resize event');\n this.resizeElement();\n\n // This will fire more frequently while the user is resizing so use a shorter debounce time\n this._resizeImmediateSubscription = fromEvent(window, 'resize')\n .pipe(debounceTime(this._resizeDebounceTime))\n .subscribe(() => {\n FillContainer.OutputDebugMessage('');\n FillContainer.OutputDebugMessage('RECEIVED resize event');\n this.resizeElement()\n });\n \n // This will fire once the user has stopped resizing for _resizeEndDebounceTime milliseconds\n this._resizeSubscription = fromEvent(window, 'resize')\n .pipe(debounceTime(this._resizeEndDebounceTime))\n .subscribe(() => {\n FillContainer.OutputDebugMessage('');\n FillContainer.OutputDebugMessage('RECEIVED resize end event');\n this.resizeElement()\n });\n\n // // Subscribe once but handle both scenarios\n // this._resizeSubscription = fromEvent(window, 'resize').pipe(\n // throttleTime(this._resizeDebounceTime), // handles frequent resizes\n // tap(() => {\n // this.resizeElement();\n // FillContainer.OutputDebugMessage('RECEIVED resize event');\n // }),\n // debounceTime(this._resizeEndDebounceTime), // handles end of resizing\n // finalize(() => {\n // this.resizeElement();\n // FillContainer.OutputDebugMessage('RECEIVED resize end event');\n // })\n // ).subscribe();\n \n \n // also subscribe to MJGlobal events so we can monitor for a manually invoked resize event request\n // from another component\n MJGlobal.Instance.GetEventListener(true)\n //.pipe(debounceTime(this._resizeDebounceTime))\n .subscribe((event) => {\n if (event.event === MJEventType.ManualResizeRequest) {\n FillContainer.OutputDebugMessage('');\n FillContainer.OutputDebugMessage('RECEIVED manual resize request');\n this.resizeElement();\n }\n }); \n }\n }\n\n /**\n * Cleans up subscriptions when the directive is destroyed\n */\n ngOnDestroy(): void {\n this._resizeImmediateSubscription?.unsubscribe();\n this._resizeSubscription?.unsubscribe();\n }\n\n /**\n * Finds the nearest block-level parent element\n * @param element The element to find the parent for\n * @returns The parent element or null if none found\n */\n protected getParent(element: HTMLElement): HTMLElement | null {\n let curElement: HTMLElement | null = element;\n while (curElement && curElement.nodeName !== 'HTML') {\n if (curElement.parentElement && window.getComputedStyle(curElement.parentElement).display === 'block') {\n return curElement.parentElement;\n }\n curElement = curElement.parentElement;\n }\n return curElement;\n }\n \n /**\n * Performs the actual resize calculation and applies dimensions to the element\n */\n protected resizeElement(): void {\n if (FillContainer.DisableResize) {\n // global disable flag\n return;\n }\n\n const element = this.elementRef.nativeElement as HTMLElement;\n try {\n if (element && element.style && !this.shouldSkipResize(element)) {\n const parent = this.getParent(element);\n \n if (parent && !this.elementBelowHiddenTab(element)) { \n let parentStyle = window.getComputedStyle(parent);\n if (parentStyle.visibility === 'hidden' || parentStyle.display === 'none') {\n LogStatus('skipping hidden element: ' + parent.nodeName )\n }\n else {\n FillContainer.OutputDebugMessage('Resizing element: ' + element.nodeName + ' parent: ' + parent.nodeName);\n\n const parentRect = parent.getBoundingClientRect();\n if (parent.nodeName === 'HTML') {\n parentRect.height = window.innerHeight;\n }\n const elementRect = element.getBoundingClientRect();\n \n \n let paddingTop = parseInt(parentStyle.getPropertyValue('padding-top'));\n let paddingLeft = parseInt(parentStyle.getPropertyValue('padding-left'));\n \n if (this.fillWidth) {\n const widthVariance = (elementRect.left - parentRect.left) + paddingLeft + (paddingLeft > 0 ? 1 : 0); // add 1 to account for rounding errors\n const newWidth = Math.floor(parentRect.width - this.rightMargin - widthVariance);\n if (Math.floor(elementRect.width) !== newWidth) {\n element.style.width = newWidth + 'px';\n }\n }\n \n if (this.fillHeight) {\n const heightVariance = (elementRect.top - parentRect.top) + paddingTop + (paddingTop > 0 ? 1 : 0); // add 1 to account for rounding errors \n const newHeight = Math.floor(parentRect.height - this.bottomMargin - heightVariance); \n if (Math.floor(elementRect.height) !== newHeight) {\n element.style.height = newHeight + 'px'; \n }\n }\n }\n } \n }\n }\n catch (err) {\n LogError(err);\n }\n }\n\n /**\n * Determines if resizing should be skipped for this element\n * @param el The element to check\n * @returns True if resizing should be skipped, false otherwise\n */\n protected shouldSkipResize(el: HTMLElement): boolean {\n let cur: HTMLElement | null = el;\n while (cur) {\n if (cur.hasAttribute('mjSkipResize') || cur.role === 'grid') {\n return true;\n }\n cur = cur.parentElement;\n }\n return false;\n };\n\n /**\n * Checks if element is below a hidden tab\n * @param element The element to check\n * @returns True if element is below a hidden tab, false otherwise\n */\n protected elementBelowHiddenTab(element: HTMLElement): boolean {\n // check if the element is below a hidden tab, a hidden tab will have a class of .k-tabstrip-content and also have .k-active applied\n // we can go all the way up the tree to look for this\n let parent = element.parentElement;\n while (parent) {\n if (parent.role === 'tabpanel') {\n // element is below a tab\n if(!parent.classList.contains('k-active')) \n return true; // tab is NOT active\n else\n return false; // tab IS active\n }\n parent = parent.parentElement;\n }\n // not below a tab at all\n return false;\n }\n \n /**\n * Checks if element is within a grid\n * @param element The element to check\n * @returns True if element is within a grid, false otherwise\n */\n protected elementWithinGrid(element: HTMLElement): boolean {\n // check if the element is within a kendo grid \n let parent = element.parentElement;\n while (parent) {\n if (parent.role === 'grid') {\n // element is below a grid\n return true; \n }\n parent = parent.parentElement;\n }\n // not below a grid\n return false;\n }\n}"]}
|
|
1
|
+
{"version":3,"file":"ng-fill-container-directive.js","sourceRoot":"","sources":["../../src/lib/ng-fill-container-directive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAc,KAAK,EAAqB,MAAM,eAAe,CAAC;AAChF,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAgB,MAAM,MAAM,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aAAa;;iFAAb,aAAa;cAJzB,SAAS;eAAC;gBACT,UAAU,EAAE,KAAK;gBACjB,QAAQ,EAAE,mBAAmB;aAC9B;;kBAGE,KAAK;;kBAGL,KAAK;;kBASL,KAAK;;kBAGL,KAAK;;kBASL,KAAK;;kBAGL,KAAK;;kBASL,KAAK;;kBAGL,KAAK","sourcesContent":["import { Directive, ElementRef, Input, OnDestroy, OnInit } from '@angular/core';\nimport { LogError, LogStatus } from '@memberjunction/core';\nimport { fromEvent, Subscription } from 'rxjs';\nimport { debounceTime } from 'rxjs/operators';\nimport { MJEventType, MJGlobal } from '@memberjunction/global';\n\n/**\n * Directive that automatically resizes an element to fill its parent container.\n * This directive calculates and sets dimensions based on the parent container's size,\n * accounting for the element's position within the parent and any specified margins.\n * \n * It listens for window resize events and custom MJ application events to update dimensions.\n * The directive is context-aware and will automatically skip resizing in certain conditions.\n *\n * @example\n * <!-- Basic usage (fills both width and height) -->\n * <div >Content</div>\n *\n * <!-- With custom settings -->\n * <div [fillWidth]=\"true\" [fillHeight]=\"true\" [rightMargin]=\"10\" [bottomMargin]=\"20\">\n * Content with margins\n * </div>\n */\n@Directive({\n standalone: false,\n selector: '[mjFillContainer]'\n})\nexport class FillContainer implements OnInit, OnDestroy {\n /** Whether to fill the parent's width. Default is true. */\n @Input() FillWidth: boolean = true;\n\n /** @deprecated Use {@link FillWidth}. */\n @Input() set fillWidth(value: boolean) {\n this.FillWidth = value;\n }\n /** @deprecated Use {@link FillWidth}. */\n get fillWidth(): boolean {\n return this.FillWidth;\n }\n \n /** Whether to fill the parent's height. Default is true. */\n @Input() FillHeight: boolean = true;\n\n /** @deprecated Use {@link FillHeight}. */\n @Input() set fillHeight(value: boolean) {\n this.FillHeight = value;\n }\n /** @deprecated Use {@link FillHeight}. */\n get fillHeight(): boolean {\n return this.FillHeight;\n }\n \n /** Right margin in pixels. Default is 0. */\n @Input() RightMargin: number = 0;\n\n /** @deprecated Use {@link RightMargin}. */\n @Input() set rightMargin(value: number) {\n this.RightMargin = value;\n }\n /** @deprecated Use {@link RightMargin}. */\n get rightMargin(): number {\n return this.RightMargin;\n }\n \n /** Bottom margin in pixels. Default is 0. */\n @Input() BottomMargin: number = 0;\n\n /** @deprecated Use {@link BottomMargin}. */\n @Input() set bottomMargin(value: number) {\n this.BottomMargin = value;\n }\n /** @deprecated Use {@link BottomMargin}. */\n get bottomMargin(): number {\n return this.BottomMargin;\n }\n\n /** Flag to globally disable resize functionality for all instances */\n public static DisableResize: boolean = false;\n \n /** Flag to enable debug logging for resize operations */\n public static OutputDebugInfo: boolean = false;\n \n /**\n * Outputs a debug message if OutputDebugInfo is enabled\n * @param message The message to output\n */\n protected static OutputDebugMessage(message: string): void {\n if (FillContainer.OutputDebugInfo) {\n console.log(message);\n }\n }\n\n constructor(private elementRef: ElementRef) {\n }\n\n /** Debounce time for resize events during active resizing (milliseconds) */\n private _resizeDebounceTime: number = 100;\n \n /** Debounce time for resize end events (milliseconds) */\n private _resizeEndDebounceTime: number = 500;\n\n /** Subscription for resize end events */\n private _resizeSubscription: Subscription | null = null;\n \n /** Subscription for immediate resize events */\n private _resizeImmediateSubscription: Subscription | null = null;\n\n /**\n * Initializes the directive, sets up resize event listeners and performs initial resize\n */\n ngOnInit(): void {\n const el = this.elementRef.nativeElement as HTMLElement;\n if (el && el.style) { \n // initial resize\n FillContainer.OutputDebugMessage('');\n FillContainer.OutputDebugMessage('Initial resize event');\n this.resizeElement();\n\n // This will fire more frequently while the user is resizing so use a shorter debounce time\n this._resizeImmediateSubscription = fromEvent(window, 'resize')\n .pipe(debounceTime(this._resizeDebounceTime))\n .subscribe(() => {\n FillContainer.OutputDebugMessage('');\n FillContainer.OutputDebugMessage('RECEIVED resize event');\n this.resizeElement()\n });\n \n // This will fire once the user has stopped resizing for _resizeEndDebounceTime milliseconds\n this._resizeSubscription = fromEvent(window, 'resize')\n .pipe(debounceTime(this._resizeEndDebounceTime))\n .subscribe(() => {\n FillContainer.OutputDebugMessage('');\n FillContainer.OutputDebugMessage('RECEIVED resize end event');\n this.resizeElement()\n });\n\n // // Subscribe once but handle both scenarios\n // this._resizeSubscription = fromEvent(window, 'resize').pipe(\n // throttleTime(this._resizeDebounceTime), // handles frequent resizes\n // tap(() => {\n // this.resizeElement();\n // FillContainer.OutputDebugMessage('RECEIVED resize event');\n // }),\n // debounceTime(this._resizeEndDebounceTime), // handles end of resizing\n // finalize(() => {\n // this.resizeElement();\n // FillContainer.OutputDebugMessage('RECEIVED resize end event');\n // })\n // ).subscribe();\n \n \n // also subscribe to MJGlobal events so we can monitor for a manually invoked resize event request\n // from another component\n MJGlobal.Instance.GetEventListener(true)\n //.pipe(debounceTime(this._resizeDebounceTime))\n .subscribe((event) => {\n if (event.event === MJEventType.ManualResizeRequest) {\n FillContainer.OutputDebugMessage('');\n FillContainer.OutputDebugMessage('RECEIVED manual resize request');\n this.resizeElement();\n }\n }); \n }\n }\n\n /**\n * Cleans up subscriptions when the directive is destroyed\n */\n ngOnDestroy(): void {\n this._resizeImmediateSubscription?.unsubscribe();\n this._resizeSubscription?.unsubscribe();\n }\n\n /**\n * Finds the nearest block-level parent element\n * @param element The element to find the parent for\n * @returns The parent element or null if none found\n */\n protected getParent(element: HTMLElement): HTMLElement | null {\n let curElement: HTMLElement | null = element;\n while (curElement && curElement.nodeName !== 'HTML') {\n if (curElement.parentElement && window.getComputedStyle(curElement.parentElement).display === 'block') {\n return curElement.parentElement;\n }\n curElement = curElement.parentElement;\n }\n return curElement;\n }\n \n /**\n * Performs the actual resize calculation and applies dimensions to the element\n */\n protected resizeElement(): void {\n if (FillContainer.DisableResize) {\n // global disable flag\n return;\n }\n\n const element = this.elementRef.nativeElement as HTMLElement;\n try {\n if (element && element.style && !this.shouldSkipResize(element)) {\n const parent = this.getParent(element);\n \n if (parent && !this.elementBelowHiddenTab(element)) { \n let parentStyle = window.getComputedStyle(parent);\n if (parentStyle.visibility === 'hidden' || parentStyle.display === 'none') {\n LogStatus('skipping hidden element: ' + parent.nodeName )\n }\n else {\n FillContainer.OutputDebugMessage('Resizing element: ' + element.nodeName + ' parent: ' + parent.nodeName);\n\n const parentRect = parent.getBoundingClientRect();\n if (parent.nodeName === 'HTML') {\n parentRect.height = window.innerHeight;\n }\n const elementRect = element.getBoundingClientRect();\n \n \n let paddingTop = parseInt(parentStyle.getPropertyValue('padding-top'));\n let paddingLeft = parseInt(parentStyle.getPropertyValue('padding-left'));\n \n if (this.FillWidth) {\n const widthVariance = (elementRect.left - parentRect.left) + paddingLeft + (paddingLeft > 0 ? 1 : 0); // add 1 to account for rounding errors\n const newWidth = Math.floor(parentRect.width - this.RightMargin - widthVariance);\n if (Math.floor(elementRect.width) !== newWidth) {\n element.style.width = newWidth + 'px';\n }\n }\n \n if (this.FillHeight) {\n const heightVariance = (elementRect.top - parentRect.top) + paddingTop + (paddingTop > 0 ? 1 : 0); // add 1 to account for rounding errors \n const newHeight = Math.floor(parentRect.height - this.BottomMargin - heightVariance); \n if (Math.floor(elementRect.height) !== newHeight) {\n element.style.height = newHeight + 'px'; \n }\n }\n }\n } \n }\n }\n catch (err) {\n LogError(err);\n }\n }\n\n /**\n * Determines if resizing should be skipped for this element\n * @param el The element to check\n * @returns True if resizing should be skipped, false otherwise\n */\n protected shouldSkipResize(el: HTMLElement): boolean {\n let cur: HTMLElement | null = el;\n while (cur) {\n if (cur.hasAttribute('mjSkipResize') || cur.role === 'grid') {\n return true;\n }\n cur = cur.parentElement;\n }\n return false;\n };\n\n /**\n * Checks if element is below a hidden tab\n * @param element The element to check\n * @returns True if element is below a hidden tab, false otherwise\n */\n protected elementBelowHiddenTab(element: HTMLElement): boolean {\n // check if the element is below a hidden tab, a hidden tab will have a class of .k-tabstrip-content and also have .k-active applied\n // we can go all the way up the tree to look for this\n let parent = element.parentElement;\n while (parent) {\n if (parent.role === 'tabpanel') {\n // element is below a tab\n if(!parent.classList.contains('k-active')) \n return true; // tab is NOT active\n else\n return false; // tab IS active\n }\n parent = parent.parentElement;\n }\n // not below a tab at all\n return false;\n }\n \n /**\n * Checks if element is within a grid\n * @param element The element to check\n * @returns True if element is within a grid, false otherwise\n */\n protected elementWithinGrid(element: HTMLElement): boolean {\n // check if the element is within a kendo grid \n let parent = element.parentElement;\n while (parent) {\n if (parent.role === 'grid') {\n // element is below a grid\n return true; \n }\n parent = parent.parentElement;\n }\n // not below a grid\n return false;\n }\n}"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@memberjunction/ng-container-directives",
|
|
3
|
-
"version": "6.1
|
|
3
|
+
"version": "6.2.0-edge.1",
|
|
4
4
|
"description": "DEPRECATED: Angular Container Directives - Fill Container for Auto-Resizing, and plain container for element identification/binding. Will be removed in a future release.",
|
|
5
5
|
"main": "./dist/public-api.js",
|
|
6
6
|
"typings": "./dist/public-api.d.ts",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"@angular/core": "^21.2.22"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@memberjunction/core": "6.1
|
|
29
|
-
"@memberjunction/global": "6.1
|
|
28
|
+
"@memberjunction/core": "6.2.0-edge.1",
|
|
29
|
+
"@memberjunction/global": "6.2.0-edge.1",
|
|
30
30
|
"rxjs": "~7.8.2",
|
|
31
31
|
"tslib": "^2.8.1"
|
|
32
32
|
},
|