@acorex/core 6.5.14 → 6.5.15
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/acorex-core.d.ts +5 -0
- package/esm2020/acorex-core.mjs +5 -0
- package/esm2020/lib/classes/base-page.class.mjs +28 -0
- package/esm2020/lib/classes/color.class.mjs +49 -0
- package/esm2020/lib/classes/datetime.class.mjs +314 -0
- package/esm2020/lib/classes/menu.class.mjs +27 -0
- package/esm2020/lib/classes/navigator.class.mjs +2 -0
- package/esm2020/lib/classes/popup.class.mjs +2 -0
- package/esm2020/lib/classes/promise.class.mjs +19 -0
- package/esm2020/lib/classes/sectionlist.class.mjs +2 -0
- package/esm2020/lib/classes/select.class.mjs +3 -0
- package/esm2020/lib/core.module.mjs +27 -0
- package/esm2020/lib/error/error.class.mjs +2 -0
- package/esm2020/lib/error/error.module.mjs +19 -0
- package/esm2020/lib/error/error.service.mjs +21 -0
- package/esm2020/lib/events/keyboard.mjs +2 -0
- package/esm2020/lib/http/http-error.class.mjs +2 -0
- package/esm2020/lib/http/http-events.interceptor.mjs +3 -0
- package/esm2020/lib/http/http-request.class.mjs +2 -0
- package/esm2020/lib/http/http-result.class.mjs +21 -0
- package/esm2020/lib/http/http.module.mjs +37 -0
- package/esm2020/lib/http/http.service.mjs +145 -0
- package/{src → esm2020}/lib/locale/en.json +6 -6
- package/{src → esm2020}/lib/locale/fa.json +7 -7
- package/esm2020/lib/pipe/datetime.pipe.mjs +25 -0
- package/esm2020/lib/pipe/htmlToText.pipe.mjs +25 -0
- package/esm2020/lib/platform/index.mjs +2 -0
- package/esm2020/lib/platform/platform.service.mjs +138 -0
- package/esm2020/lib/services/config.mjs +29 -0
- package/esm2020/lib/services/event.service.mjs +36 -0
- package/esm2020/lib/services/navigator.service.mjs +10 -0
- package/esm2020/lib/services/storage.service.mjs +16 -0
- package/esm2020/lib/translator/translator.mjs +26 -0
- package/esm2020/lib/translator/translator.module.mjs +25 -0
- package/esm2020/lib/translator/translator.pipe.mjs +24 -0
- package/esm2020/lib/translator/translator.service.mjs +21 -0
- package/esm2020/lib/utils/array/array-util.mjs +133 -0
- package/esm2020/lib/utils/html/html-util.mjs +192 -0
- package/esm2020/lib/utils/html/html.module.mjs +19 -0
- package/esm2020/lib/utils/math/math-util.mjs +6 -0
- package/esm2020/lib/utils/object/object-util.mjs +83 -0
- package/esm2020/lib/utils/render/on-demand-preload-strategy.service.mjs +20 -0
- package/esm2020/lib/utils/render/render.service.mjs +103 -0
- package/esm2020/lib/utils/render/rendering.module.mjs +35 -0
- package/esm2020/lib/utils/scroll/scroll.directive.mjs +54 -0
- package/esm2020/lib/utils/scroll/scroll.module.mjs +19 -0
- package/esm2020/lib/utils/separator/separator.module.mjs +19 -0
- package/esm2020/lib/utils/separator/separator.pipe.mjs +33 -0
- package/esm2020/public-api.mjs +44 -0
- package/fesm2015/acorex-core.mjs +2262 -0
- package/fesm2015/acorex-core.mjs.map +1 -0
- package/fesm2020/acorex-core.mjs +2258 -0
- package/fesm2020/acorex-core.mjs.map +1 -0
- package/lib/classes/base-page.class.d.ts +13 -0
- package/lib/classes/color.class.d.ts +17 -0
- package/lib/classes/datetime.class.d.ts +63 -0
- package/lib/classes/menu.class.d.ts +34 -0
- package/{src/lib/classes/navigator.class.ts → lib/classes/navigator.class.d.ts} +1 -1
- package/{src/lib/classes/popup.class.ts → lib/classes/popup.class.d.ts} +0 -2
- package/lib/classes/promise.class.d.ts +7 -0
- package/lib/classes/select.class.d.ts +7 -0
- package/lib/core.module.d.ts +9 -0
- package/lib/error/error.module.d.ts +7 -0
- package/lib/error/error.service.d.ts +13 -0
- package/{src/lib/events/keyboard.ts → lib/events/keyboard.d.ts} +0 -3
- package/{src/lib/http/http-error.class.ts → lib/http/http-error.class.d.ts} +2 -2
- package/{src/lib/http/http-events.interceptor.ts → lib/http/http-events.interceptor.d.ts} +3 -7
- package/{src/lib/http/http-request.class.ts → lib/http/http-request.class.d.ts} +5 -5
- package/lib/http/http-result.class.d.ts +11 -0
- package/lib/http/http.module.d.ts +10 -0
- package/lib/http/http.service.d.ts +23 -0
- package/lib/pipe/datetime.pipe.d.ts +8 -0
- package/lib/pipe/htmlToText.pipe.d.ts +7 -0
- package/lib/platform/index.d.ts +1 -0
- package/lib/platform/platform.service.d.ts +25 -0
- package/lib/services/config.d.ts +9 -0
- package/lib/services/event.service.d.ts +9 -0
- package/lib/services/navigator.service.d.ts +8 -0
- package/lib/services/storage.service.d.ts +7 -0
- package/lib/translator/translator.d.ts +9 -0
- package/lib/translator/translator.module.d.ts +8 -0
- package/lib/translator/translator.pipe.d.ts +8 -0
- package/lib/translator/translator.service.d.ts +8 -0
- package/lib/utils/array/array-util.d.ts +6 -0
- package/lib/utils/html/html-util.d.ts +62 -0
- package/lib/utils/html/html.module.d.ts +8 -0
- package/lib/utils/math/math-util.d.ts +3 -0
- package/lib/utils/object/object-util.d.ts +7 -0
- package/lib/utils/render/on-demand-preload-strategy.service.d.ts +10 -0
- package/lib/utils/render/render.service.d.ts +18 -0
- package/lib/utils/render/rendering.module.d.ts +8 -0
- package/lib/utils/scroll/scroll.directive.d.ts +18 -0
- package/lib/utils/scroll/scroll.module.d.ts +8 -0
- package/lib/utils/separator/separator.module.d.ts +8 -0
- package/lib/utils/separator/separator.pipe.d.ts +8 -0
- package/package.json +33 -13
- package/{src/public-api.ts → public-api.d.ts} +0 -10
- package/karma.conf.js +0 -32
- package/ng-package.json +0 -10
- package/src/lib/classes/base-page.class.ts +0 -29
- package/src/lib/classes/color.class.ts +0 -61
- package/src/lib/classes/datetime.class.ts +0 -373
- package/src/lib/classes/menu.class.ts +0 -37
- package/src/lib/classes/promise.class.ts +0 -25
- package/src/lib/classes/select.class.ts +0 -7
- package/src/lib/core.module.ts +0 -21
- package/src/lib/error/error.module.ts +0 -13
- package/src/lib/error/error.service.ts +0 -23
- package/src/lib/error/index.ts +0 -3
- package/src/lib/http/http-result.class.ts +0 -34
- package/src/lib/http/http.module.ts +0 -25
- package/src/lib/http/http.service.ts +0 -159
- package/src/lib/pipe/datetime.pipe.ts +0 -20
- package/src/lib/pipe/htmlToText.pipe.ts +0 -18
- package/src/lib/platform/index.ts +0 -1
- package/src/lib/platform/platform.service.ts +0 -211
- package/src/lib/services/config.ts +0 -36
- package/src/lib/services/event.service.ts +0 -31
- package/src/lib/services/navigator.service.ts +0 -8
- package/src/lib/services/storage.service.ts +0 -11
- package/src/lib/translator/translator.module.ts +0 -19
- package/src/lib/translator/translator.pipe.ts +0 -22
- package/src/lib/translator/translator.service.ts +0 -19
- package/src/lib/translator/translator.ts +0 -31
- package/src/lib/utils/array/array-util.ts +0 -140
- package/src/lib/utils/html/html-util.ts +0 -264
- package/src/lib/utils/html/html.module.ts +0 -11
- package/src/lib/utils/math/math-util.ts +0 -5
- package/src/lib/utils/object/object-util.ts +0 -87
- package/src/lib/utils/render/on-demand-preload-strategy.service.ts +0 -25
- package/src/lib/utils/render/render.service.ts +0 -110
- package/src/lib/utils/render/rendering.module.ts +0 -25
- package/src/lib/utils/scroll/scroll.directive.ts +0 -35
- package/src/lib/utils/scroll/scroll.module.ts +0 -11
- package/src/lib/utils/separator/separator.module.ts +0 -11
- package/src/lib/utils/separator/separator.pipe.ts +0 -27
- package/src/test.ts +0 -28
- package/tsconfig.lib.json +0 -25
- package/tsconfig.lib.prod.json +0 -6
- package/tsconfig.spec.json +0 -18
- package/tslint.json +0 -17
- /package/{src/lib/classes/sectionlist.class.ts → lib/classes/sectionlist.class.d.ts} +0 -0
- /package/{src/lib/error/error.class.ts → lib/error/error.class.d.ts} +0 -0
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
import { AXFetchProp } from '../object/object-util';
|
|
2
|
-
|
|
3
|
-
// @dynamic
|
|
4
|
-
export class AXArrayUtil {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
static pickRandom(array: any[]): any {
|
|
8
|
-
return array[Math.floor(Math.random() * array.length)];
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
static insert(array: any[], index, ...rest) {
|
|
13
|
-
array.splice.apply(array, [index, 0].concat(Array.prototype.slice.call(rest, 1)));
|
|
14
|
-
return array;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
static range(min: number, max: number): number[] {
|
|
18
|
-
return new Array(max - min).fill(1).map((d, i) => i);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
static filter(array: any[], filters: any[]): any[] {
|
|
22
|
-
if (filters == null || filters.length === 0) {
|
|
23
|
-
return array;
|
|
24
|
-
}
|
|
25
|
-
const lamda = (item) => {
|
|
26
|
-
let result = true;
|
|
27
|
-
for (const key in filters) {
|
|
28
|
-
if (filters.hasOwnProperty(key)) {
|
|
29
|
-
const f = filters[key];
|
|
30
|
-
if (f !== 'AND') {
|
|
31
|
-
const vals = [];
|
|
32
|
-
const mt = f.field.match(/\[\:(.*?)\]/);
|
|
33
|
-
if (mt && mt.length > 1) {
|
|
34
|
-
const p1 = f.field.replace(mt[0], '');
|
|
35
|
-
const p2 = mt[1];
|
|
36
|
-
const prop = AXFetchProp(item, p1);
|
|
37
|
-
if (prop instanceof Array && prop.length) {
|
|
38
|
-
vals.push(...prop.map(m => (AXFetchProp(m, p2))));
|
|
39
|
-
} else {
|
|
40
|
-
result = false;
|
|
41
|
-
}
|
|
42
|
-
} else {
|
|
43
|
-
vals.push(AXFetchProp(item, f.field));
|
|
44
|
-
}
|
|
45
|
-
for (const j in vals) {
|
|
46
|
-
if (vals.hasOwnProperty(j)) {
|
|
47
|
-
let v1 = vals[j];
|
|
48
|
-
const v2 = f.value;
|
|
49
|
-
if (f.dataType === 'string') {
|
|
50
|
-
v1 = v1.toString();
|
|
51
|
-
switch (f.condition) {
|
|
52
|
-
case 'equal':
|
|
53
|
-
result = (v1 && v2) && v1.toLowerCase() === v2.toLowerCase();
|
|
54
|
-
break;
|
|
55
|
-
case 'not-equal':
|
|
56
|
-
result = !((v1 && v2) && v1.toLowerCase() === v2.toLowerCase());
|
|
57
|
-
break;
|
|
58
|
-
case 'contains':
|
|
59
|
-
result = ((v1 && v2) && (v1.toLowerCase().includes(v2.toLowerCase())));
|
|
60
|
-
break;
|
|
61
|
-
case 'not-contains':
|
|
62
|
-
result = !((v1 && v2) && (v1.toLowerCase().includes(v2.toLowerCase())));
|
|
63
|
-
break;
|
|
64
|
-
case 'start-with':
|
|
65
|
-
result = ((v1 && v2) && (v1.toLowerCase().startsWith(v2.toLowerCase())));
|
|
66
|
-
break;
|
|
67
|
-
case 'end-with':
|
|
68
|
-
result = ((v1 && v2) && (v1.toLowerCase().endsWith(v2.toLowerCase())));
|
|
69
|
-
break;
|
|
70
|
-
case 'is-empty':
|
|
71
|
-
result = v1 == null || v1 === undefined;
|
|
72
|
-
break;
|
|
73
|
-
case 'is-not-empty':
|
|
74
|
-
result = !(v1 == null || v1 === undefined);
|
|
75
|
-
break;
|
|
76
|
-
default:
|
|
77
|
-
console.error('The condition is not defined');
|
|
78
|
-
result = false;
|
|
79
|
-
}
|
|
80
|
-
} else if (f.dataType === 'date') {
|
|
81
|
-
} else if (f.dataType === 'number') {
|
|
82
|
-
v1 = Number(v1);
|
|
83
|
-
switch (f.condition) {
|
|
84
|
-
case 'equal':
|
|
85
|
-
result = v1 === v2;
|
|
86
|
-
break;
|
|
87
|
-
case 'not-equal':
|
|
88
|
-
result = v1 !== v2;
|
|
89
|
-
break;
|
|
90
|
-
case 'contains':
|
|
91
|
-
result = v2 && v2 instanceof Array && v2.includes(v1);
|
|
92
|
-
break;
|
|
93
|
-
case 'less-than':
|
|
94
|
-
result = v1 < v2;
|
|
95
|
-
break;
|
|
96
|
-
case 'less-than-equal':
|
|
97
|
-
result = v1 <= v2;
|
|
98
|
-
break;
|
|
99
|
-
case 'greater-than':
|
|
100
|
-
result = v1 > v2;
|
|
101
|
-
break;
|
|
102
|
-
case 'greater-than-equal':
|
|
103
|
-
result = v1 >= v2;
|
|
104
|
-
break;
|
|
105
|
-
case 'is-empty':
|
|
106
|
-
result = v1 == null || v1 === undefined;
|
|
107
|
-
break;
|
|
108
|
-
case 'is-not-empty':
|
|
109
|
-
result = !(v1 == null || v1 === undefined);
|
|
110
|
-
break;
|
|
111
|
-
default:
|
|
112
|
-
console.error('The condition is not defined');
|
|
113
|
-
result = false;
|
|
114
|
-
}
|
|
115
|
-
} else {
|
|
116
|
-
console.error('The datatype is not supported');
|
|
117
|
-
result = false;
|
|
118
|
-
}
|
|
119
|
-
if (result) {
|
|
120
|
-
break;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
if (!result) {
|
|
126
|
-
return false;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
return true;
|
|
131
|
-
};
|
|
132
|
-
return array.filter(lamda);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
@@ -1,264 +0,0 @@
|
|
|
1
|
-
import { AXMathUtil } from '../math/math-util';
|
|
2
|
-
|
|
3
|
-
export type AXPlacement =
|
|
4
|
-
| 'top-start'
|
|
5
|
-
| 'top-middle'
|
|
6
|
-
| 'top-end'
|
|
7
|
-
| 'center-start'
|
|
8
|
-
| 'center-end'
|
|
9
|
-
| 'bottom-start'
|
|
10
|
-
| 'bottom-middle'
|
|
11
|
-
| 'bottom-end';
|
|
12
|
-
|
|
13
|
-
export interface AXIPoint {
|
|
14
|
-
x: number;
|
|
15
|
-
y: number;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export interface AXConnectedPosition {
|
|
19
|
-
originX: 'start' | 'center' | 'end';
|
|
20
|
-
originY: 'top' | 'center' | 'bottom';
|
|
21
|
-
overlayX: 'start' | 'center' | 'end';
|
|
22
|
-
overlayY: 'top' | 'center' | 'bottom';
|
|
23
|
-
weight?: number;
|
|
24
|
-
offsetX?: number;
|
|
25
|
-
offsetY?: number;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export class AXPoint implements AXIPoint {
|
|
29
|
-
constructor(public x: number, public y: number) {
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export interface AXClientRecCtor {
|
|
34
|
-
left?: number;
|
|
35
|
-
top?: number;
|
|
36
|
-
width?: number;
|
|
37
|
-
height?: number;
|
|
38
|
-
bottom?: number;
|
|
39
|
-
right?: number;
|
|
40
|
-
}
|
|
41
|
-
export class AXClientRec implements AXClientRecCtor {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
private _left: number;
|
|
45
|
-
public get left(): number {
|
|
46
|
-
return this._left;
|
|
47
|
-
}
|
|
48
|
-
public set left(v: number) {
|
|
49
|
-
this._left = v;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
private _top: number;
|
|
54
|
-
public get top(): number {
|
|
55
|
-
return this._top;
|
|
56
|
-
}
|
|
57
|
-
public set top(v: number) {
|
|
58
|
-
this._top = v;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
private _right: number;
|
|
63
|
-
public get right(): number {
|
|
64
|
-
return this._right;
|
|
65
|
-
}
|
|
66
|
-
public set right(v: number) {
|
|
67
|
-
this._right = v;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
private _bottom: number;
|
|
72
|
-
public get bottom(): number {
|
|
73
|
-
return this._bottom;
|
|
74
|
-
}
|
|
75
|
-
public set bottom(v: number) {
|
|
76
|
-
this._bottom = v;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
private _width: number;
|
|
82
|
-
public get width(): number {
|
|
83
|
-
return this._width;
|
|
84
|
-
}
|
|
85
|
-
public set width(v: number) {
|
|
86
|
-
this._width = v;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
private _height: number;
|
|
91
|
-
public get height(): number {
|
|
92
|
-
return this._height;
|
|
93
|
-
}
|
|
94
|
-
public set height(v: number) {
|
|
95
|
-
this._height = v;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
constructor(rec: AXClientRecCtor) {
|
|
100
|
-
this._left = rec.left;
|
|
101
|
-
this._top = rec.top;
|
|
102
|
-
this._width = rec.width;
|
|
103
|
-
this._height = rec.height;
|
|
104
|
-
this._right = this._left + this._width;
|
|
105
|
-
this._bottom = this._top + this._height;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
public intersect(rec: AXClientRecCtor): boolean {
|
|
109
|
-
return (this.left < rec.left + rec.width &&
|
|
110
|
-
this.left + this.width > rec.left &&
|
|
111
|
-
this.top < rec.top + rec.height &&
|
|
112
|
-
this.top + this.height > rec.top);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
}
|
|
117
|
-
// @dynamic
|
|
118
|
-
export class AXHtmlUtil {
|
|
119
|
-
static getBoundingRectPoint(el: HTMLElement, placement: AXPlacement): AXPoint {
|
|
120
|
-
const rec = el.getBoundingClientRect();
|
|
121
|
-
const width = el.offsetWidth;
|
|
122
|
-
const height = el.offsetHeight;
|
|
123
|
-
switch (placement) {
|
|
124
|
-
case 'top-start':
|
|
125
|
-
return new AXPoint(rec.left, rec.top);
|
|
126
|
-
case 'top-middle':
|
|
127
|
-
return new AXPoint(rec.left + (width / 2), rec.top);
|
|
128
|
-
case 'top-end':
|
|
129
|
-
return new AXPoint(rec.left + (width), rec.top);
|
|
130
|
-
case 'center-end':
|
|
131
|
-
return new AXPoint(rec.left + (width), rec.top + (height / 2));
|
|
132
|
-
case 'bottom-end':
|
|
133
|
-
return new AXPoint(rec.left + (width), rec.top + (height));
|
|
134
|
-
case 'bottom-middle':
|
|
135
|
-
return new AXPoint(rec.left + (width / 2), rec.top + (height));
|
|
136
|
-
case 'bottom-start':
|
|
137
|
-
return new AXPoint(rec.left, rec.top + (height));
|
|
138
|
-
case 'center-start':
|
|
139
|
-
return new AXPoint(rec.left, rec.top + (height / 2));
|
|
140
|
-
default:
|
|
141
|
-
return new AXPoint(rec.left + (width / 2), rec.top + (height));
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
static isInRecPoint(pos: AXIPoint, rec: AXClientRecCtor): boolean {
|
|
146
|
-
return pos.x >= rec.left && pos.x <= (rec.left + rec.width) && pos.y >= rec.top && (pos.y <= (rec.top + rec.height));
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
// static isOverLap(rec1: AXClientRecCtor, rec2: AXClientRecCtor): boolean {
|
|
150
|
-
// const r1: AXClientRec = new AXClientRec(rec1);
|
|
151
|
-
// const r2: AXClientRec = new AXClientRec(rec2);
|
|
152
|
-
|
|
153
|
-
// return ;
|
|
154
|
-
// }
|
|
155
|
-
|
|
156
|
-
static isInElementBound(pos: AXIPoint, element: HTMLElement): boolean {
|
|
157
|
-
const elBound = element.getBoundingClientRect();
|
|
158
|
-
return AXHtmlUtil.isInRecPoint(pos, {
|
|
159
|
-
left: elBound.left,
|
|
160
|
-
width: elBound.width,
|
|
161
|
-
top: elBound.top,
|
|
162
|
-
height: elBound.height
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
static getDimensions(): { width: number, height: number } {
|
|
167
|
-
let winW = 630;
|
|
168
|
-
let winH = 460;
|
|
169
|
-
if (document.body && document.body.offsetWidth) {
|
|
170
|
-
winW = document.body.offsetWidth;
|
|
171
|
-
winH = document.body.offsetHeight;
|
|
172
|
-
}
|
|
173
|
-
if (document.compatMode === 'CSS1Compat' && document.documentElement && document.documentElement.offsetWidth) {
|
|
174
|
-
winW = document.documentElement.offsetWidth;
|
|
175
|
-
winH = document.documentElement.offsetHeight;
|
|
176
|
-
}
|
|
177
|
-
if (window.innerWidth && window.innerHeight) {
|
|
178
|
-
winW = window.innerWidth;
|
|
179
|
-
winH = window.innerHeight;
|
|
180
|
-
}
|
|
181
|
-
return { width: winW, height: winH };
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
static getOffsetRight(elem: HTMLElement): number {
|
|
185
|
-
let element = elem;
|
|
186
|
-
const width = element.offsetWidth;
|
|
187
|
-
let right = 0;
|
|
188
|
-
while (element.offsetParent) {
|
|
189
|
-
right += element.offsetLeft;
|
|
190
|
-
element = element.offsetParent as HTMLElement;
|
|
191
|
-
}
|
|
192
|
-
right += element.offsetLeft;
|
|
193
|
-
right = AXHtmlUtil.getDimensions().width - right;
|
|
194
|
-
right -= width;
|
|
195
|
-
return right;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
static getUID(): string {
|
|
199
|
-
return 'el-' + AXMathUtil.randomRange(1000000000, 9999999999).toString();
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
static getRelatedPosition(source: HTMLElement, placement: AXPlacement, target: HTMLElement, alignment: AXPlacement): AXIPoint {
|
|
204
|
-
const result: AXIPoint = { x: 0, y: 0 };
|
|
205
|
-
|
|
206
|
-
const sourcePos: AXPoint = AXHtmlUtil.getBoundingRectPoint(source, placement);
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
let top: number = 0;
|
|
210
|
-
let left: number = 0;
|
|
211
|
-
switch (alignment) {
|
|
212
|
-
case 'top-start':
|
|
213
|
-
top = sourcePos.y;
|
|
214
|
-
left = sourcePos.x;
|
|
215
|
-
break;
|
|
216
|
-
case 'top-middle':
|
|
217
|
-
top = sourcePos.y;
|
|
218
|
-
left = sourcePos.x - target.offsetWidth / 2;
|
|
219
|
-
break;
|
|
220
|
-
case 'top-end':
|
|
221
|
-
top = sourcePos.y;
|
|
222
|
-
left = sourcePos.x - target.offsetWidth;
|
|
223
|
-
break;
|
|
224
|
-
case 'center-end':
|
|
225
|
-
top = sourcePos.y - target.offsetHeight / 2;
|
|
226
|
-
left = sourcePos.x - target.offsetWidth;
|
|
227
|
-
break;
|
|
228
|
-
case 'bottom-end':
|
|
229
|
-
top = sourcePos.y - target.offsetHeight;
|
|
230
|
-
left = sourcePos.x - target.offsetWidth;
|
|
231
|
-
break;
|
|
232
|
-
case 'bottom-middle':
|
|
233
|
-
top = sourcePos.y - target.offsetHeight;
|
|
234
|
-
left = sourcePos.x - target.offsetWidth / 2;
|
|
235
|
-
break;
|
|
236
|
-
case 'bottom-start':
|
|
237
|
-
top = sourcePos.y - target.offsetHeight;
|
|
238
|
-
left = sourcePos.x;
|
|
239
|
-
break;
|
|
240
|
-
case 'center-start':
|
|
241
|
-
top = sourcePos.y - target.offsetHeight / 2;
|
|
242
|
-
left = sourcePos.x;
|
|
243
|
-
break;
|
|
244
|
-
}
|
|
245
|
-
result.y = top;
|
|
246
|
-
result.x = left;
|
|
247
|
-
return result;
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
static collision(a: HTMLElement, b: HTMLElement): boolean {
|
|
252
|
-
const ac = a.getBoundingClientRect();
|
|
253
|
-
const bc = b.getBoundingClientRect();
|
|
254
|
-
|
|
255
|
-
if (ac.left < bc.left + bc.width && ac.left + ac.width > bc.left &&
|
|
256
|
-
ac.top < bc.top + bc.height && ac.top + ac.height > bc.top) {
|
|
257
|
-
return true;
|
|
258
|
-
}
|
|
259
|
-
else {
|
|
260
|
-
return false;
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { NgModule } from '@angular/core';
|
|
2
|
-
import { CommonModule } from '@angular/common';
|
|
3
|
-
import { AXHtmlToTextPipe } from '../../pipe/htmlToText.pipe';
|
|
4
|
-
|
|
5
|
-
@NgModule({
|
|
6
|
-
declarations: [AXHtmlToTextPipe],
|
|
7
|
-
imports: [CommonModule],
|
|
8
|
-
exports: [AXHtmlToTextPipe],
|
|
9
|
-
providers: []
|
|
10
|
-
})
|
|
11
|
-
export class AXHtmlModule { }
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
// @dynamic
|
|
2
|
-
export class AXObjectUtil {
|
|
3
|
-
static deepJSONClone(obj: any): any {
|
|
4
|
-
return obj ? JSON.parse(JSON.stringify(obj)) : null;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
static deepCopy(obj) {
|
|
8
|
-
let copy;
|
|
9
|
-
// Handle the 3 simple types, and null or undefined
|
|
10
|
-
if (null == obj || 'object' !== typeof obj) { return obj; }
|
|
11
|
-
// Handle Date
|
|
12
|
-
if (obj instanceof Date) {
|
|
13
|
-
copy = new Date();
|
|
14
|
-
copy.setTime(obj.getTime());
|
|
15
|
-
return copy;
|
|
16
|
-
}
|
|
17
|
-
// Handle Array
|
|
18
|
-
if (obj instanceof Array) {
|
|
19
|
-
copy = [];
|
|
20
|
-
for (let i = 0, len = obj.length; i < len; i++) {
|
|
21
|
-
copy[i] = AXObjectUtil.deepCopy(obj[i]);
|
|
22
|
-
}
|
|
23
|
-
return copy;
|
|
24
|
-
}
|
|
25
|
-
// Handle Object
|
|
26
|
-
if (obj instanceof Object) {
|
|
27
|
-
copy = {};
|
|
28
|
-
for (const attr in obj) {
|
|
29
|
-
if (obj.hasOwnProperty(attr)) { copy[attr] = AXObjectUtil.deepCopy(obj[attr]); }
|
|
30
|
-
}
|
|
31
|
-
return copy;
|
|
32
|
-
}
|
|
33
|
-
throw new Error('Unable to copy obj! Its type isn\'t supported.');
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export function AXFetchProp(obj, prop: string) {
|
|
38
|
-
if (typeof obj === 'undefined') {
|
|
39
|
-
return false;
|
|
40
|
-
}
|
|
41
|
-
const index = prop.indexOf('.');
|
|
42
|
-
|
|
43
|
-
if (index > -1) {
|
|
44
|
-
return AXFetchProp(obj[prop.substring(0, index)], prop.substr(index + 1));
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return obj[prop];
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
export function getPropByPath(obj, path, defaultVal?) {
|
|
54
|
-
path = path
|
|
55
|
-
.replace(/\[/g, '.')
|
|
56
|
-
.replace(/]/g, '')
|
|
57
|
-
.split('.');
|
|
58
|
-
|
|
59
|
-
path.forEach((level) => {
|
|
60
|
-
if (obj) {
|
|
61
|
-
obj = obj[level];
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
if (obj === undefined) {
|
|
66
|
-
return defaultVal;
|
|
67
|
-
}
|
|
68
|
-
return obj;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export function setPropByPath(obj, path, value) {
|
|
72
|
-
if (Object(obj) !== obj) { return obj; } // When obj is not an object
|
|
73
|
-
// If not yet an array, get the keys from the string-path
|
|
74
|
-
if (!Array.isArray(path)) { path = path.toString().match(/[^.[\]]+/g) || []; }
|
|
75
|
-
path.slice(0, -1).reduce((a, c, i) => // Iterate all of them except the last one
|
|
76
|
-
Object(a[c]) === a[c] // Does the key exist and is its value an object?
|
|
77
|
-
// Yes: then follow that path
|
|
78
|
-
? a[c]
|
|
79
|
-
// No: create the key. Is the next key a potential array-index?
|
|
80
|
-
: a[c] = Math.abs(path[i + 1]) >> 0 === +path[i + 1]
|
|
81
|
-
? [] // Yes: assign a new array object
|
|
82
|
-
: {}, // No: assign a new plain object
|
|
83
|
-
obj)[path[path.length - 1]] = value; // Finally assign the value to the last key
|
|
84
|
-
return obj[path[0]]; // Return the top-level object to allow chaining
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { PreloadingStrategy, Route } from '@angular/router';
|
|
2
|
-
import { Injectable } from '@angular/core';
|
|
3
|
-
import { Subject, Observable, of } from 'rxjs';
|
|
4
|
-
import { mergeMap } from 'rxjs/operators';
|
|
5
|
-
import { AXHtmlUtil } from '../html/html-util';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
@Injectable()
|
|
11
|
-
export class AXOnDemandPreloadService {
|
|
12
|
-
subject = new Subject<string>();
|
|
13
|
-
tmp: string;
|
|
14
|
-
|
|
15
|
-
constructor() {
|
|
16
|
-
this.tmp = AXHtmlUtil.getUID();
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
startPreload(routePath: string) {
|
|
20
|
-
const slices: string[] = [];
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
this.subject.next(routePath);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ApplicationRef, ComponentFactoryResolver, ComponentRef, Injectable,
|
|
3
|
-
Injector, EmbeddedViewRef, Type, Compiler, NgModuleFactory
|
|
4
|
-
} from '@angular/core';
|
|
5
|
-
import { Router, Route } from '@angular/router';
|
|
6
|
-
import { AXOnDemandPreloadService } from './on-demand-preload-strategy.service';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
@Injectable({ providedIn: 'root' })
|
|
11
|
-
export class AXRenderService {
|
|
12
|
-
constructor(
|
|
13
|
-
private appRef: ApplicationRef,
|
|
14
|
-
private router: Router,
|
|
15
|
-
private componentFactoryResolver: ComponentFactoryResolver,
|
|
16
|
-
private compiler: Compiler,
|
|
17
|
-
private modulePreloadService: AXOnDemandPreloadService,
|
|
18
|
-
private injector: Injector) {
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
appendComponent<T>(
|
|
24
|
-
componentClass: Type<T>,
|
|
25
|
-
options: any = {},
|
|
26
|
-
location?: Element): ComponentRef<any> {
|
|
27
|
-
|
|
28
|
-
const componentFactory = this.componentFactoryResolver.resolveComponentFactory(componentClass);
|
|
29
|
-
const componentRef = componentFactory.create(this.injector);
|
|
30
|
-
this.appRef.attachView(componentRef.hostView);
|
|
31
|
-
Object.assign(componentRef.instance, options);
|
|
32
|
-
//
|
|
33
|
-
const domElem = (componentRef.hostView as EmbeddedViewRef<any>).rootNodes[0] as HTMLElement;
|
|
34
|
-
componentRef.onDestroy(() => {
|
|
35
|
-
this.appRef.detachView(componentRef.hostView);
|
|
36
|
-
});
|
|
37
|
-
if (location) {
|
|
38
|
-
location.appendChild(domElem);
|
|
39
|
-
} else {
|
|
40
|
-
document.body.appendChild(domElem);
|
|
41
|
-
}
|
|
42
|
-
setTimeout(() => {
|
|
43
|
-
componentRef.changeDetectorRef.detectChanges();
|
|
44
|
-
}, 0);
|
|
45
|
-
return componentRef;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
findLoadedComponentByRoute(path: string, timeoutTime: number = 10): Promise<Route> {
|
|
49
|
-
const delay = 200;
|
|
50
|
-
const loop = timeoutTime * 1000 / delay;
|
|
51
|
-
return new Promise((resolve, reject) => {
|
|
52
|
-
let found: Route = null;
|
|
53
|
-
let preload: boolean = false;
|
|
54
|
-
const theLoop = (i) => {
|
|
55
|
-
setTimeout(async () => {
|
|
56
|
-
found = await this._findLoadedComponentByRoute(path);
|
|
57
|
-
if (--i && found == null) {
|
|
58
|
-
if (!preload) {
|
|
59
|
-
this.modulePreloadService.startPreload(path);
|
|
60
|
-
preload = true;
|
|
61
|
-
}
|
|
62
|
-
theLoop(i);
|
|
63
|
-
}
|
|
64
|
-
else if (found) {
|
|
65
|
-
resolve(found);
|
|
66
|
-
}
|
|
67
|
-
else {
|
|
68
|
-
reject();
|
|
69
|
-
}
|
|
70
|
-
}, delay);
|
|
71
|
-
};
|
|
72
|
-
theLoop(loop);
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
private async _findLoadedComponentByRoute(search) {
|
|
77
|
-
|
|
78
|
-
let found: Route = null;
|
|
79
|
-
const f = (children, parentPath) => {
|
|
80
|
-
for (const p in children) {
|
|
81
|
-
if (children.hasOwnProperty(p)) {
|
|
82
|
-
const route = children[p];
|
|
83
|
-
const pp = (route.path != '' && route.path != null) ? parentPath + '/' + route.path : parentPath;
|
|
84
|
-
if (pp == search && !route._loadedConfig && route.component) {
|
|
85
|
-
found = route;
|
|
86
|
-
return;
|
|
87
|
-
} else if (route._loadedConfig || route.children) {
|
|
88
|
-
f(route.children || route._loadedConfig.routes, pp);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
for (const p in this.router.config) {
|
|
95
|
-
if (this.router.config.hasOwnProperty(p)) {
|
|
96
|
-
const route = this.router.config[p];
|
|
97
|
-
if (route.path === search && route.component) {
|
|
98
|
-
found = route;
|
|
99
|
-
}
|
|
100
|
-
else if (route['_loadedConfig'] || route.children) {
|
|
101
|
-
f(route.children || route['_loadedConfig'].routes, route.path);
|
|
102
|
-
}
|
|
103
|
-
if (found)
|
|
104
|
-
break;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
return found;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { NgModule } from '@angular/core';
|
|
2
|
-
import { AXRenderService } from './render.service';
|
|
3
|
-
import { AXOnDemandPreloadService } from './on-demand-preload-strategy.service';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
// @dynamic
|
|
7
|
-
export function getOnDemandPreloadServiceFactory() {
|
|
8
|
-
return new AXOnDemandPreloadService();
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
@NgModule({
|
|
12
|
-
imports: [],
|
|
13
|
-
exports: [],
|
|
14
|
-
declarations: [],
|
|
15
|
-
providers: [
|
|
16
|
-
{
|
|
17
|
-
provide: AXOnDemandPreloadService,
|
|
18
|
-
useFactory: getOnDemandPreloadServiceFactory
|
|
19
|
-
},
|
|
20
|
-
AXRenderService
|
|
21
|
-
],
|
|
22
|
-
})
|
|
23
|
-
export class AXRenderingModule {
|
|
24
|
-
|
|
25
|
-
}
|