@memberjunction/ng-container-directives 0.9.97 → 0.9.109
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.d.ts +8 -8
- package/dist/lib/ng-container-directive.js +15 -15
- package/dist/lib/ng-container-directives.module.d.ts +9 -9
- package/dist/lib/ng-container-directives.module.js +29 -29
- package/dist/lib/ng-fill-container-directive.d.ts +21 -21
- package/dist/lib/ng-fill-container-directive.js +143 -143
- package/dist/public-api.d.ts +3 -3
- package/dist/public-api.js +6 -6
- package/package.json +8 -8
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { ViewContainerRef } from '@angular/core';
|
|
2
|
-
import * as i0 from "@angular/core";
|
|
3
|
-
export declare class Container {
|
|
4
|
-
viewContainerRef: ViewContainerRef;
|
|
5
|
-
constructor(viewContainerRef: ViewContainerRef);
|
|
6
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<Container, never>;
|
|
7
|
-
static ɵdir: i0.ɵɵDirectiveDeclaration<Container, "[mjContainer]", never, {}, {}, never, never, false, never>;
|
|
8
|
-
}
|
|
1
|
+
import { ViewContainerRef } from '@angular/core';
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
export declare class Container {
|
|
4
|
+
viewContainerRef: ViewContainerRef;
|
|
5
|
+
constructor(viewContainerRef: ViewContainerRef);
|
|
6
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<Container, never>;
|
|
7
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<Container, "[mjContainer]", never, {}, {}, never, never, false, never>;
|
|
8
|
+
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { Directive } from '@angular/core';
|
|
2
|
-
import * as i0 from "@angular/core";
|
|
3
|
-
export class Container {
|
|
4
|
-
constructor(viewContainerRef) {
|
|
5
|
-
this.viewContainerRef = viewContainerRef;
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
|
-
Container.ɵfac = function Container_Factory(t) { return new (t || Container)(i0.ɵɵdirectiveInject(i0.ViewContainerRef)); };
|
|
9
|
-
Container.ɵdir = /*@__PURE__*/ i0.ɵɵdefineDirective({ type: Container, selectors: [["", "mjContainer", ""]] });
|
|
10
|
-
(
|
|
11
|
-
type: Directive,
|
|
12
|
-
args: [{
|
|
13
|
-
selector: '[mjContainer]',
|
|
14
|
-
}]
|
|
15
|
-
}],
|
|
1
|
+
import { Directive } from '@angular/core';
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
export class Container {
|
|
4
|
+
constructor(viewContainerRef) {
|
|
5
|
+
this.viewContainerRef = viewContainerRef;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
Container.ɵfac = function Container_Factory(t) { return new (t || Container)(i0.ɵɵdirectiveInject(i0.ViewContainerRef)); };
|
|
9
|
+
Container.ɵdir = /*@__PURE__*/ i0.ɵɵdefineDirective({ type: Container, selectors: [["", "mjContainer", ""]] });
|
|
10
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(Container, [{
|
|
11
|
+
type: Directive,
|
|
12
|
+
args: [{
|
|
13
|
+
selector: '[mjContainer]',
|
|
14
|
+
}]
|
|
15
|
+
}], () => [{ type: i0.ViewContainerRef }], null); })();
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import * as i0 from "@angular/core";
|
|
2
|
-
import * as i1 from "./ng-fill-container-directive";
|
|
3
|
-
import * as i2 from "./ng-container-directive";
|
|
4
|
-
import * as i3 from "@angular/common";
|
|
5
|
-
export declare class ContainerDirectivesModule {
|
|
6
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<ContainerDirectivesModule, never>;
|
|
7
|
-
static ɵmod: i0.ɵɵNgModuleDeclaration<ContainerDirectivesModule, [typeof i1.FillContainer, typeof i2.Container], [typeof i3.CommonModule], [typeof i1.FillContainer, typeof i2.Container]>;
|
|
8
|
-
static ɵinj: i0.ɵɵInjectorDeclaration<ContainerDirectivesModule>;
|
|
9
|
-
}
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
import * as i1 from "./ng-fill-container-directive";
|
|
3
|
+
import * as i2 from "./ng-container-directive";
|
|
4
|
+
import * as i3 from "@angular/common";
|
|
5
|
+
export declare class ContainerDirectivesModule {
|
|
6
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ContainerDirectivesModule, never>;
|
|
7
|
+
static ɵmod: i0.ɵɵNgModuleDeclaration<ContainerDirectivesModule, [typeof i1.FillContainer, typeof i2.Container], [typeof i3.CommonModule], [typeof i1.FillContainer, typeof i2.Container]>;
|
|
8
|
+
static ɵinj: i0.ɵɵInjectorDeclaration<ContainerDirectivesModule>;
|
|
9
|
+
}
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import { NgModule } from '@angular/core';
|
|
2
|
-
import { CommonModule } from '@angular/common';
|
|
3
|
-
import { FillContainer } from './ng-fill-container-directive';
|
|
4
|
-
import { Container } from './ng-container-directive';
|
|
5
|
-
import * as i0 from "@angular/core";
|
|
6
|
-
export class ContainerDirectivesModule {
|
|
7
|
-
}
|
|
8
|
-
ContainerDirectivesModule.ɵfac = function ContainerDirectivesModule_Factory(t) { return new (t || ContainerDirectivesModule)(); };
|
|
9
|
-
ContainerDirectivesModule.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: ContainerDirectivesModule });
|
|
10
|
-
ContainerDirectivesModule.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule] });
|
|
11
|
-
(
|
|
12
|
-
type: NgModule,
|
|
13
|
-
args: [{
|
|
14
|
-
declarations: [
|
|
15
|
-
FillContainer,
|
|
16
|
-
Container
|
|
17
|
-
],
|
|
18
|
-
imports: [
|
|
19
|
-
CommonModule
|
|
20
|
-
],
|
|
21
|
-
exports: [
|
|
22
|
-
FillContainer,
|
|
23
|
-
Container
|
|
24
|
-
]
|
|
25
|
-
}]
|
|
26
|
-
}], null, null); })();
|
|
27
|
-
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(ContainerDirectivesModule, { declarations: [FillContainer,
|
|
28
|
-
Container], imports: [CommonModule], exports: [FillContainer,
|
|
29
|
-
Container] }); })();
|
|
1
|
+
import { NgModule } from '@angular/core';
|
|
2
|
+
import { CommonModule } from '@angular/common';
|
|
3
|
+
import { FillContainer } from './ng-fill-container-directive';
|
|
4
|
+
import { Container } from './ng-container-directive';
|
|
5
|
+
import * as i0 from "@angular/core";
|
|
6
|
+
export class ContainerDirectivesModule {
|
|
7
|
+
}
|
|
8
|
+
ContainerDirectivesModule.ɵfac = function ContainerDirectivesModule_Factory(t) { return new (t || ContainerDirectivesModule)(); };
|
|
9
|
+
ContainerDirectivesModule.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: ContainerDirectivesModule });
|
|
10
|
+
ContainerDirectivesModule.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule] });
|
|
11
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ContainerDirectivesModule, [{
|
|
12
|
+
type: NgModule,
|
|
13
|
+
args: [{
|
|
14
|
+
declarations: [
|
|
15
|
+
FillContainer,
|
|
16
|
+
Container
|
|
17
|
+
],
|
|
18
|
+
imports: [
|
|
19
|
+
CommonModule
|
|
20
|
+
],
|
|
21
|
+
exports: [
|
|
22
|
+
FillContainer,
|
|
23
|
+
Container
|
|
24
|
+
]
|
|
25
|
+
}]
|
|
26
|
+
}], null, null); })();
|
|
27
|
+
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(ContainerDirectivesModule, { declarations: [FillContainer,
|
|
28
|
+
Container], imports: [CommonModule], exports: [FillContainer,
|
|
29
|
+
Container] }); })();
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { ElementRef, OnDestroy, OnInit } from '@angular/core';
|
|
2
|
-
import * as i0 from "@angular/core";
|
|
3
|
-
export declare class FillContainer implements OnInit, OnDestroy {
|
|
4
|
-
private elementRef;
|
|
5
|
-
fillWidth: boolean;
|
|
6
|
-
fillHeight: boolean;
|
|
7
|
-
rightMargin: number;
|
|
8
|
-
bottomMargin: number;
|
|
9
|
-
constructor(elementRef: ElementRef);
|
|
10
|
-
private _resizeDebounceTime;
|
|
11
|
-
private _resizeEndDebounceTime;
|
|
12
|
-
ngOnInit(): void;
|
|
13
|
-
private resizeImmediateSubscription;
|
|
14
|
-
private resizeEndSubscription;
|
|
15
|
-
ngOnDestroy(): void;
|
|
16
|
-
getParent(element: HTMLElement): HTMLElement | null;
|
|
17
|
-
resizeElement(): void;
|
|
18
|
-
protected elementBelowHiddenTab(element: HTMLElement): boolean;
|
|
19
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<FillContainer, never>;
|
|
20
|
-
static ɵdir: i0.ɵɵDirectiveDeclaration<FillContainer, "[mjFillContainer]", never, { "fillWidth": "fillWidth"; "fillHeight": "fillHeight"; "rightMargin": "rightMargin"; "bottomMargin": "bottomMargin"; }, {}, never, never, false, never>;
|
|
21
|
-
}
|
|
1
|
+
import { ElementRef, OnDestroy, OnInit } from '@angular/core';
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
export declare class FillContainer implements OnInit, OnDestroy {
|
|
4
|
+
private elementRef;
|
|
5
|
+
fillWidth: boolean;
|
|
6
|
+
fillHeight: boolean;
|
|
7
|
+
rightMargin: number;
|
|
8
|
+
bottomMargin: number;
|
|
9
|
+
constructor(elementRef: ElementRef);
|
|
10
|
+
private _resizeDebounceTime;
|
|
11
|
+
private _resizeEndDebounceTime;
|
|
12
|
+
ngOnInit(): void;
|
|
13
|
+
private resizeImmediateSubscription;
|
|
14
|
+
private resizeEndSubscription;
|
|
15
|
+
ngOnDestroy(): void;
|
|
16
|
+
getParent(element: HTMLElement): HTMLElement | null;
|
|
17
|
+
resizeElement(): void;
|
|
18
|
+
protected elementBelowHiddenTab(element: HTMLElement): boolean;
|
|
19
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<FillContainer, never>;
|
|
20
|
+
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>;
|
|
21
|
+
}
|
|
@@ -1,143 +1,143 @@
|
|
|
1
|
-
import { Directive, Input } from '@angular/core';
|
|
2
|
-
import { LogError, LogStatus } from '@memberjunction/core';
|
|
3
|
-
import { fromEvent } from 'rxjs';
|
|
4
|
-
import { debounceTime } from 'rxjs/operators';
|
|
5
|
-
import { MJEventType, MJGlobal } from '@memberjunction/global';
|
|
6
|
-
import * as i0 from "@angular/core";
|
|
7
|
-
export class FillContainer {
|
|
8
|
-
constructor(elementRef) {
|
|
9
|
-
this.elementRef = elementRef;
|
|
10
|
-
this.fillWidth = true;
|
|
11
|
-
this.fillHeight = true;
|
|
12
|
-
this.rightMargin = 0;
|
|
13
|
-
this.bottomMargin = 0;
|
|
14
|
-
this._resizeDebounceTime = 100;
|
|
15
|
-
this._resizeEndDebounceTime = 500;
|
|
16
|
-
this.resizeImmediateSubscription = null;
|
|
17
|
-
this.resizeEndSubscription = null;
|
|
18
|
-
}
|
|
19
|
-
ngOnInit() {
|
|
20
|
-
const el = this.elementRef.nativeElement;
|
|
21
|
-
if (el && el.style) {
|
|
22
|
-
this.resizeElement();
|
|
23
|
-
// This will fire more frequently while the user is resizing
|
|
24
|
-
this.resizeImmediateSubscription = fromEvent(window, 'resize')
|
|
25
|
-
.pipe(debounceTime(this._resizeDebounceTime))
|
|
26
|
-
.subscribe(() => this.resizeElement());
|
|
27
|
-
// This will fire once the user has stopped resizing for _resizeEndDebounceTime milliseconds
|
|
28
|
-
this.resizeEndSubscription = fromEvent(window, 'resize')
|
|
29
|
-
.pipe(debounceTime(this._resizeEndDebounceTime))
|
|
30
|
-
.subscribe(() => this.resizeElement());
|
|
31
|
-
// also subscribe to MJGlobal events so we can monitor for a manually invoked resize event request
|
|
32
|
-
// from another component
|
|
33
|
-
MJGlobal.Instance.GetEventListener(true).subscribe((event) => {
|
|
34
|
-
if (event.event === MJEventType.ManualResizeRequest) {
|
|
35
|
-
this.resizeElement();
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
ngOnDestroy() {
|
|
41
|
-
var _a, _b;
|
|
42
|
-
(_a = this.resizeImmediateSubscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
|
|
43
|
-
(_b = this.resizeEndSubscription) === null || _b === void 0 ? void 0 : _b.unsubscribe();
|
|
44
|
-
}
|
|
45
|
-
getParent(element) {
|
|
46
|
-
const parent = element.parentElement;
|
|
47
|
-
if (parent && parent.nodeName === 'APP-ROOT') {
|
|
48
|
-
let curElement = parent.parentElement;
|
|
49
|
-
// go to root of the DOM to get HTML element as that has size info
|
|
50
|
-
while (curElement && curElement.nodeName !== 'HTML') {
|
|
51
|
-
curElement = curElement.parentElement;
|
|
52
|
-
}
|
|
53
|
-
return curElement;
|
|
54
|
-
}
|
|
55
|
-
else if (parent) {
|
|
56
|
-
let style = window.getComputedStyle(parent);
|
|
57
|
-
let display = style.getPropertyValue('display');
|
|
58
|
-
if (display === 'block') {
|
|
59
|
-
return parent;
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
return this.getParent(parent); // recursive call, need to go up the DOM until we find a block element
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
else
|
|
66
|
-
return null; // no parent
|
|
67
|
-
}
|
|
68
|
-
resizeElement() {
|
|
69
|
-
const element = this.elementRef.nativeElement;
|
|
70
|
-
try {
|
|
71
|
-
if (element && element.style) {
|
|
72
|
-
const parent = this.getParent(element);
|
|
73
|
-
if (parent && !this.elementBelowHiddenTab(element)) {
|
|
74
|
-
let parentStyle = window.getComputedStyle(parent);
|
|
75
|
-
if (parentStyle.visibility === 'hidden' || parentStyle.display === 'none') {
|
|
76
|
-
LogStatus('skipping hidden element: ' + parent.nodeName);
|
|
77
|
-
}
|
|
78
|
-
else {
|
|
79
|
-
const parentRect = parent.getBoundingClientRect();
|
|
80
|
-
if (parent.nodeName === 'HTML') {
|
|
81
|
-
parentRect.height = window.innerHeight;
|
|
82
|
-
}
|
|
83
|
-
const elementRect = element.getBoundingClientRect();
|
|
84
|
-
let paddingTop = parseInt(parentStyle.getPropertyValue('padding-top'));
|
|
85
|
-
let paddingLeft = parseInt(parentStyle.getPropertyValue('padding-left'));
|
|
86
|
-
if (this.fillWidth) {
|
|
87
|
-
const widthVariance = (elementRect.left - parentRect.left) + paddingLeft + (paddingLeft > 0 ? 1 : 0); // add 1 to account for rounding errors
|
|
88
|
-
const newWidth = Math.floor(parentRect.width - this.rightMargin - widthVariance);
|
|
89
|
-
if (Math.floor(elementRect.width) !== newWidth) {
|
|
90
|
-
element.style.width = newWidth + 'px';
|
|
91
|
-
//LogStatus('setting ' + element.nodeName + ' width to ' + newWidth + ' from ' + elementRect.width)
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
if (this.fillHeight) {
|
|
95
|
-
const heightVariance = (elementRect.top - parentRect.top) + paddingTop + (paddingTop > 0 ? 1 : 0); // add 1 to account for rounding errors
|
|
96
|
-
const newHeight = Math.floor(parentRect.height - this.bottomMargin - heightVariance);
|
|
97
|
-
if (Math.floor(elementRect.height) !== newHeight) {
|
|
98
|
-
element.style.height = newHeight + 'px';
|
|
99
|
-
//LogStatus('setting ' + element.nodeName + ' height to ' + newHeight + ' from ' + elementRect.height)
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
catch (err) {
|
|
107
|
-
LogError(err);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
elementBelowHiddenTab(element) {
|
|
111
|
-
// 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
|
|
112
|
-
// we can go all the way up the tree to look for this
|
|
113
|
-
let parent = element.parentElement;
|
|
114
|
-
while (parent) {
|
|
115
|
-
if (parent.role === 'tabpanel') {
|
|
116
|
-
// element is below a tab
|
|
117
|
-
if (!parent.classList.contains('k-active'))
|
|
118
|
-
return true; // tab is NOT active
|
|
119
|
-
else
|
|
120
|
-
return false; // tab IS active
|
|
121
|
-
}
|
|
122
|
-
parent = parent.parentElement;
|
|
123
|
-
}
|
|
124
|
-
// not below a tab at all
|
|
125
|
-
return false;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
FillContainer.ɵfac = function FillContainer_Factory(t) { return new (t || FillContainer)(i0.ɵɵdirectiveInject(i0.ElementRef)); };
|
|
129
|
-
FillContainer.ɵdir = /*@__PURE__*/ i0.ɵɵdefineDirective({ type: FillContainer, selectors: [["", "mjFillContainer", ""]], inputs: { fillWidth: "fillWidth", fillHeight: "fillHeight", rightMargin: "rightMargin", bottomMargin: "bottomMargin" } });
|
|
130
|
-
(
|
|
131
|
-
type: Directive,
|
|
132
|
-
args: [{
|
|
133
|
-
selector: '[mjFillContainer]'
|
|
134
|
-
}]
|
|
135
|
-
}],
|
|
136
|
-
type: Input
|
|
137
|
-
}], fillHeight: [{
|
|
138
|
-
type: Input
|
|
139
|
-
}], rightMargin: [{
|
|
140
|
-
type: Input
|
|
141
|
-
}], bottomMargin: [{
|
|
142
|
-
type: Input
|
|
143
|
-
}] }); })();
|
|
1
|
+
import { Directive, Input } from '@angular/core';
|
|
2
|
+
import { LogError, LogStatus } from '@memberjunction/core';
|
|
3
|
+
import { fromEvent } from 'rxjs';
|
|
4
|
+
import { debounceTime } from 'rxjs/operators';
|
|
5
|
+
import { MJEventType, MJGlobal } from '@memberjunction/global';
|
|
6
|
+
import * as i0 from "@angular/core";
|
|
7
|
+
export class FillContainer {
|
|
8
|
+
constructor(elementRef) {
|
|
9
|
+
this.elementRef = elementRef;
|
|
10
|
+
this.fillWidth = true;
|
|
11
|
+
this.fillHeight = true;
|
|
12
|
+
this.rightMargin = 0;
|
|
13
|
+
this.bottomMargin = 0;
|
|
14
|
+
this._resizeDebounceTime = 100;
|
|
15
|
+
this._resizeEndDebounceTime = 500;
|
|
16
|
+
this.resizeImmediateSubscription = null;
|
|
17
|
+
this.resizeEndSubscription = null;
|
|
18
|
+
}
|
|
19
|
+
ngOnInit() {
|
|
20
|
+
const el = this.elementRef.nativeElement;
|
|
21
|
+
if (el && el.style) {
|
|
22
|
+
this.resizeElement();
|
|
23
|
+
// This will fire more frequently while the user is resizing
|
|
24
|
+
this.resizeImmediateSubscription = fromEvent(window, 'resize')
|
|
25
|
+
.pipe(debounceTime(this._resizeDebounceTime))
|
|
26
|
+
.subscribe(() => this.resizeElement());
|
|
27
|
+
// This will fire once the user has stopped resizing for _resizeEndDebounceTime milliseconds
|
|
28
|
+
this.resizeEndSubscription = fromEvent(window, 'resize')
|
|
29
|
+
.pipe(debounceTime(this._resizeEndDebounceTime))
|
|
30
|
+
.subscribe(() => this.resizeElement());
|
|
31
|
+
// also subscribe to MJGlobal events so we can monitor for a manually invoked resize event request
|
|
32
|
+
// from another component
|
|
33
|
+
MJGlobal.Instance.GetEventListener(true).subscribe((event) => {
|
|
34
|
+
if (event.event === MJEventType.ManualResizeRequest) {
|
|
35
|
+
this.resizeElement();
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
ngOnDestroy() {
|
|
41
|
+
var _a, _b;
|
|
42
|
+
(_a = this.resizeImmediateSubscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
|
|
43
|
+
(_b = this.resizeEndSubscription) === null || _b === void 0 ? void 0 : _b.unsubscribe();
|
|
44
|
+
}
|
|
45
|
+
getParent(element) {
|
|
46
|
+
const parent = element.parentElement;
|
|
47
|
+
if (parent && parent.nodeName === 'APP-ROOT') {
|
|
48
|
+
let curElement = parent.parentElement;
|
|
49
|
+
// go to root of the DOM to get HTML element as that has size info
|
|
50
|
+
while (curElement && curElement.nodeName !== 'HTML') {
|
|
51
|
+
curElement = curElement.parentElement;
|
|
52
|
+
}
|
|
53
|
+
return curElement;
|
|
54
|
+
}
|
|
55
|
+
else if (parent) {
|
|
56
|
+
let style = window.getComputedStyle(parent);
|
|
57
|
+
let display = style.getPropertyValue('display');
|
|
58
|
+
if (display === 'block') {
|
|
59
|
+
return parent;
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
return this.getParent(parent); // recursive call, need to go up the DOM until we find a block element
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
else
|
|
66
|
+
return null; // no parent
|
|
67
|
+
}
|
|
68
|
+
resizeElement() {
|
|
69
|
+
const element = this.elementRef.nativeElement;
|
|
70
|
+
try {
|
|
71
|
+
if (element && element.style) {
|
|
72
|
+
const parent = this.getParent(element);
|
|
73
|
+
if (parent && !this.elementBelowHiddenTab(element)) {
|
|
74
|
+
let parentStyle = window.getComputedStyle(parent);
|
|
75
|
+
if (parentStyle.visibility === 'hidden' || parentStyle.display === 'none') {
|
|
76
|
+
LogStatus('skipping hidden element: ' + parent.nodeName);
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
const parentRect = parent.getBoundingClientRect();
|
|
80
|
+
if (parent.nodeName === 'HTML') {
|
|
81
|
+
parentRect.height = window.innerHeight;
|
|
82
|
+
}
|
|
83
|
+
const elementRect = element.getBoundingClientRect();
|
|
84
|
+
let paddingTop = parseInt(parentStyle.getPropertyValue('padding-top'));
|
|
85
|
+
let paddingLeft = parseInt(parentStyle.getPropertyValue('padding-left'));
|
|
86
|
+
if (this.fillWidth) {
|
|
87
|
+
const widthVariance = (elementRect.left - parentRect.left) + paddingLeft + (paddingLeft > 0 ? 1 : 0); // add 1 to account for rounding errors
|
|
88
|
+
const newWidth = Math.floor(parentRect.width - this.rightMargin - widthVariance);
|
|
89
|
+
if (Math.floor(elementRect.width) !== newWidth) {
|
|
90
|
+
element.style.width = newWidth + 'px';
|
|
91
|
+
//LogStatus('setting ' + element.nodeName + ' width to ' + newWidth + ' from ' + elementRect.width)
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
if (this.fillHeight) {
|
|
95
|
+
const heightVariance = (elementRect.top - parentRect.top) + paddingTop + (paddingTop > 0 ? 1 : 0); // add 1 to account for rounding errors
|
|
96
|
+
const newHeight = Math.floor(parentRect.height - this.bottomMargin - heightVariance);
|
|
97
|
+
if (Math.floor(elementRect.height) !== newHeight) {
|
|
98
|
+
element.style.height = newHeight + 'px';
|
|
99
|
+
//LogStatus('setting ' + element.nodeName + ' height to ' + newHeight + ' from ' + elementRect.height)
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
catch (err) {
|
|
107
|
+
LogError(err);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
elementBelowHiddenTab(element) {
|
|
111
|
+
// 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
|
|
112
|
+
// we can go all the way up the tree to look for this
|
|
113
|
+
let parent = element.parentElement;
|
|
114
|
+
while (parent) {
|
|
115
|
+
if (parent.role === 'tabpanel') {
|
|
116
|
+
// element is below a tab
|
|
117
|
+
if (!parent.classList.contains('k-active'))
|
|
118
|
+
return true; // tab is NOT active
|
|
119
|
+
else
|
|
120
|
+
return false; // tab IS active
|
|
121
|
+
}
|
|
122
|
+
parent = parent.parentElement;
|
|
123
|
+
}
|
|
124
|
+
// not below a tab at all
|
|
125
|
+
return false;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
FillContainer.ɵfac = function FillContainer_Factory(t) { return new (t || FillContainer)(i0.ɵɵdirectiveInject(i0.ElementRef)); };
|
|
129
|
+
FillContainer.ɵdir = /*@__PURE__*/ i0.ɵɵdefineDirective({ type: FillContainer, selectors: [["", "mjFillContainer", ""]], inputs: { fillWidth: "fillWidth", fillHeight: "fillHeight", rightMargin: "rightMargin", bottomMargin: "bottomMargin" } });
|
|
130
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(FillContainer, [{
|
|
131
|
+
type: Directive,
|
|
132
|
+
args: [{
|
|
133
|
+
selector: '[mjFillContainer]'
|
|
134
|
+
}]
|
|
135
|
+
}], () => [{ type: i0.ElementRef }], { fillWidth: [{
|
|
136
|
+
type: Input
|
|
137
|
+
}], fillHeight: [{
|
|
138
|
+
type: Input
|
|
139
|
+
}], rightMargin: [{
|
|
140
|
+
type: Input
|
|
141
|
+
}], bottomMargin: [{
|
|
142
|
+
type: Input
|
|
143
|
+
}] }); })();
|
package/dist/public-api.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './lib/ng-container-directives.module';
|
|
2
|
-
export * from './lib/ng-fill-container-directive';
|
|
3
|
-
export * from './lib/ng-container-directive';
|
|
1
|
+
export * from './lib/ng-container-directives.module';
|
|
2
|
+
export * from './lib/ng-fill-container-directive';
|
|
3
|
+
export * from './lib/ng-container-directive';
|
package/dist/public-api.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Public API Surface of ng-link-directives
|
|
3
|
-
*/
|
|
4
|
-
export * from './lib/ng-container-directives.module';
|
|
5
|
-
export * from './lib/ng-fill-container-directive';
|
|
6
|
-
export * from './lib/ng-container-directive';
|
|
1
|
+
/*
|
|
2
|
+
* Public API Surface of ng-link-directives
|
|
3
|
+
*/
|
|
4
|
+
export * from './lib/ng-container-directives.module';
|
|
5
|
+
export * from './lib/ng-fill-container-directive';
|
|
6
|
+
export * from './lib/ng-container-directive';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@memberjunction/ng-container-directives",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.109",
|
|
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",
|
|
@@ -20,17 +20,17 @@
|
|
|
20
20
|
"author": "",
|
|
21
21
|
"license": "ISC",
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@angular/compiler": "^
|
|
24
|
-
"@angular/compiler-cli": "^
|
|
23
|
+
"@angular/compiler": "^17.1.2",
|
|
24
|
+
"@angular/compiler-cli": "^17.1.2"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
|
-
"@angular/common": "^
|
|
28
|
-
"@angular/core": "^
|
|
29
|
-
"@angular/router": "^
|
|
27
|
+
"@angular/common": "^17.1.2",
|
|
28
|
+
"@angular/core": "^17.1.2",
|
|
29
|
+
"@angular/router": "^17.1.2"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@memberjunction/core": "^0.9.
|
|
33
|
-
"@memberjunction/global": "^0.9.
|
|
32
|
+
"@memberjunction/core": "^0.9.141",
|
|
33
|
+
"@memberjunction/global": "^0.9.132",
|
|
34
34
|
"tslib": "^2.3.0"
|
|
35
35
|
},
|
|
36
36
|
"sideEffects": false
|