@acorex/core 5.0.5 → 5.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/acorex-core.d.ts +5 -0
  2. package/bundles/acorex-core.umd.js +1333 -0
  3. package/bundles/acorex-core.umd.js.map +1 -0
  4. package/config/tailwind.config.js +209 -0
  5. package/esm2015/acorex-core.js +5 -0
  6. package/esm2015/lib/config/configs.js +30 -0
  7. package/esm2015/lib/core.module.js +18 -0
  8. package/esm2015/lib/dateTime/datetime.class.js +260 -0
  9. package/esm2015/lib/dateTime/datetime.module.js +31 -0
  10. package/esm2015/lib/dateTime/datetime.pipe.js +25 -0
  11. package/esm2015/lib/dateTime/georgian.calendar.js +162 -0
  12. package/esm2015/lib/dateTime/index.js +5 -0
  13. package/esm2015/lib/dateTime/jalali.calendar.js +327 -0
  14. package/esm2015/lib/platform/index.js +2 -0
  15. package/esm2015/lib/platform/platform.service.js +132 -0
  16. package/esm2015/lib/translation/index.js +4 -0
  17. package/esm2015/lib/translation/translation.module.js +18 -0
  18. package/esm2015/lib/translation/translator.js +26 -0
  19. package/esm2015/lib/translation/translator.pipe.js +15 -0
  20. package/esm2015/lib/utils/drawing-util.js +27 -0
  21. package/esm2015/lib/utils/index.js +4 -0
  22. package/esm2015/lib/utils/object-util.js +83 -0
  23. package/esm2015/lib/utils/safe.pipe.js +30 -0
  24. package/esm2015/public-api.js +11 -0
  25. package/fesm2015/acorex-core.js +1169 -0
  26. package/fesm2015/acorex-core.js.map +1 -0
  27. package/lib/config/configs.d.ts +9 -0
  28. package/lib/core.module.d.ts +7 -0
  29. package/lib/dateTime/datetime.class.d.ts +86 -0
  30. package/lib/dateTime/datetime.module.d.ts +8 -0
  31. package/lib/dateTime/datetime.pipe.d.ts +8 -0
  32. package/lib/dateTime/georgian.calendar.d.ts +19 -0
  33. package/{src/lib/dateTime/index.ts → lib/dateTime/index.d.ts} +1 -1
  34. package/lib/dateTime/jalali.calendar.d.ts +34 -0
  35. package/lib/platform/index.d.ts +1 -0
  36. package/lib/platform/platform.service.d.ts +23 -0
  37. package/{src/lib/translation/index.ts → lib/translation/index.d.ts} +1 -1
  38. package/lib/translation/translation.module.d.ts +7 -0
  39. package/lib/translation/translator.d.ts +9 -0
  40. package/lib/translation/translator.pipe.d.ts +7 -0
  41. package/lib/utils/drawing-util.d.ts +17 -0
  42. package/{src/lib/utils/index.ts → lib/utils/index.d.ts} +1 -1
  43. package/lib/utils/object-util.d.ts +7 -0
  44. package/lib/utils/safe.pipe.d.ts +10 -0
  45. package/package.json +18 -14
  46. package/{src/public-api.ts → public-api.d.ts} +1 -2
  47. package/karma.conf.js +0 -44
  48. package/ng-package.json +0 -11
  49. package/src/lib/config/configs.ts +0 -36
  50. package/src/lib/core.module.ts +0 -10
  51. package/src/lib/dateTime/datetime.class.ts +0 -395
  52. package/src/lib/dateTime/datetime.module.ts +0 -11
  53. package/src/lib/dateTime/datetime.pipe.ts +0 -20
  54. package/src/lib/dateTime/georgian.calendar.ts +0 -157
  55. package/src/lib/dateTime/jalali.calendar.ts +0 -376
  56. package/src/lib/http/http-error.class.ts +0 -7
  57. package/src/lib/http/http-events.interceptor.ts +0 -14
  58. package/src/lib/http/http-request.class.ts +0 -14
  59. package/src/lib/http/http-result.class.ts +0 -34
  60. package/src/lib/http/http.module.ts +0 -25
  61. package/src/lib/http/http.service.ts +0 -159
  62. package/src/lib/platform/index.ts +0 -1
  63. package/src/lib/platform/platform.service.ts +0 -185
  64. package/src/lib/translation/translation.module.ts +0 -12
  65. package/src/lib/translation/translator.pipe.ts +0 -9
  66. package/src/lib/translation/translator.ts +0 -31
  67. package/src/lib/utils/drawing-util.ts +0 -43
  68. package/src/lib/utils/object-util.ts +0 -82
  69. package/src/lib/utils/safe.pipe.ts +0 -24
  70. package/src/test.ts +0 -26
  71. package/tsconfig.lib.json +0 -20
  72. package/tsconfig.lib.prod.json +0 -10
  73. package/tsconfig.spec.json +0 -17
@@ -1,185 +0,0 @@
1
- import { Injectable } from "@angular/core";
2
- import { Subject } from "rxjs";
3
-
4
-
5
- export type AXPlatforms = 'Android' | 'Desktop' | 'iOS' | 'Mobile';
6
- export type AXBrowsers = 'Chrome' | 'Safari' | 'Edge' | 'Firefox' | 'Opera' | 'MSIE';
7
- export type AXTechnologies = 'PWA' | 'Hybrid' | 'Electron';
8
-
9
-
10
-
11
-
12
- const isChrome = (win: Window): boolean =>
13
- testUserAgent(win, /Chrome/i);
14
-
15
- const isFirefox = (win: Window): boolean =>
16
- testUserAgent(win, /Firefox/i);
17
-
18
- const isEdge = (win: Window): boolean =>
19
- testUserAgent(win, /Edge/i);
20
-
21
- const isSafari = (win: Window): boolean =>
22
- testUserAgent(win, /Safari/i);
23
-
24
- const isOpera = (win: Window): boolean =>
25
- testUserAgent(win, /Opera/i) || testUserAgent(win, /OPR/i);
26
-
27
- const isMSIE = (win: Window): boolean =>
28
- testUserAgent(win, /MSIE/i) || testUserAgent(win, /Trident/i);
29
-
30
-
31
- const isMobileWeb = (win: Window): boolean =>
32
- isMobile(win) && !isHybrid(win);
33
-
34
- const isIpad = (win: Window) => {
35
- // iOS 12 and below
36
- if (testUserAgent(win, /iPad/i)) {
37
- return true;
38
- }
39
-
40
- // iOS 13+
41
- if (testUserAgent(win, /Macintosh/i) && isMobile(win)) {
42
- return true;
43
- }
44
-
45
- return false;
46
- };
47
-
48
- const isIphone = (win: Window) =>
49
- testUserAgent(win, /iPhone/i);
50
-
51
- const isIOS = (win: Window) =>
52
- testUserAgent(win, /iPhone|iPod/i) || isIpad(win);
53
-
54
- const isAndroid = (win: Window) =>
55
- testUserAgent(win, /android|sink/i);
56
-
57
- const isAndroidTablet = (win: Window) => {
58
- return isAndroid(win) && !testUserAgent(win, /mobile/i);
59
- };
60
-
61
- const isPhablet = (win: Window) => {
62
- const width = win.innerWidth;
63
- const height = win.innerHeight;
64
- const smallest = Math.min(width, height);
65
- const largest = Math.max(width, height);
66
-
67
- return (smallest > 390 && smallest < 520) &&
68
- (largest > 620 && largest < 800);
69
- };
70
-
71
- const isTablet = (win: Window) => {
72
- const width = win.innerWidth;
73
- const height = win.innerHeight;
74
- const smallest = Math.min(width, height);
75
- const largest = Math.max(width, height);
76
-
77
- return (
78
- isIpad(win) ||
79
- isAndroidTablet(win) ||
80
- (
81
- (smallest > 460 && smallest < 820) &&
82
- (largest > 780 && largest < 1400)
83
- )
84
- );
85
- };
86
-
87
- const isMobile = (win: Window) =>
88
- matchMedia(win, '(any-pointer:coarse)');
89
-
90
- const isDesktop = (win: Window) =>
91
- !isMobile(win);
92
-
93
- const isHybrid = (win: Window) =>
94
- isCordova(win) || isCapacitorNative(win);
95
-
96
- const isCordova = (win: any): boolean =>
97
- !!(win['cordova'] || win['phonegap'] || win['PhoneGap']);
98
-
99
- const isCapacitorNative = (win: any): boolean => {
100
- const capacitor = win['Capacitor'];
101
- return !!(capacitor && capacitor.isNative);
102
- };
103
-
104
- const isElectron = (win: Window): boolean =>
105
- testUserAgent(win, /electron/i);
106
-
107
- const isPWA = (win: Window): boolean =>
108
- !!(win.matchMedia('(display-mode: standalone)').matches || (win.navigator as any).standalone);
109
-
110
- export const testUserAgent = (win: Window, expr: RegExp) =>
111
- expr.test(win.navigator.userAgent);
112
-
113
- const matchMedia = (win: Window, query: string): boolean =>
114
- win.matchMedia(query).matches;
115
-
116
-
117
- const PLATFORMS_MAP = {
118
- 'Android': isAndroid,
119
- 'iOS': isIOS,
120
- 'Desktop': isDesktop,
121
- 'Mobile': isMobile,
122
- 'Chrome': isChrome,
123
- 'Firefox': isFirefox,
124
- 'Safari': isSafari,
125
- 'Edge': isEdge,
126
- 'Opera': isOpera,
127
- 'Hybrid': isHybrid,
128
- 'PWA': isPWA,
129
- 'Electron': isElectron,
130
- };
131
-
132
-
133
- export class AXPlatformEvent {
134
- nativeEvent: UIEvent | Event;
135
- source: AXPlatform
136
- }
137
-
138
- @Injectable({
139
- providedIn: 'platform',
140
- })
141
- export class AXPlatform {
142
- resize: Subject<AXPlatformEvent> = new Subject<AXPlatformEvent>();
143
- click: Subject<AXPlatformEvent> = new Subject<AXPlatformEvent>()
144
- scroll: Subject<AXPlatformEvent> = new Subject<AXPlatformEvent>()
145
-
146
- isRtl(): boolean {
147
- return document.dir == 'rtl' || document.body.dir == 'rtl' || document.body.style.direction == 'rtl';
148
- }
149
-
150
-
151
- isLandscape(): boolean {
152
- return window.innerHeight < window.innerWidth;
153
- }
154
-
155
- isPortrate(): boolean {
156
- return !this.isLandscape()
157
- }
158
-
159
- is(name: AXPlatforms | AXBrowsers | AXTechnologies): boolean {
160
- return PLATFORMS_MAP[name](window) || false;
161
- }
162
-
163
- constructor() {
164
- window.addEventListener('resize', (e) => {
165
- this.resize.next({
166
- nativeEvent: e,
167
- source: this
168
- });
169
- })
170
-
171
- document.addEventListener('click', (e) => {
172
- this.click.next({
173
- nativeEvent: e,
174
- source: this
175
- });
176
- }, true)
177
-
178
- document.addEventListener('scroll', (e) => {
179
- this.scroll.next({
180
- nativeEvent: e,
181
- source: this
182
- });
183
- }, true)
184
- }
185
- }
@@ -1,12 +0,0 @@
1
- import { NgModule } from '@angular/core';
2
- import { AXTranslatorPipe } from './translator.pipe';
3
-
4
- @NgModule({
5
- imports: [],
6
- exports: [AXTranslatorPipe],
7
- declarations: [AXTranslatorPipe],
8
- providers: [],
9
- })
10
- export class AXTranslationModule {
11
-
12
- }
@@ -1,9 +0,0 @@
1
- import { Pipe, PipeTransform } from '@angular/core';
2
- import { AXTranslator } from './translator';
3
-
4
- @Pipe({ name: 'trans', pure: true })
5
- export class AXTranslatorPipe implements PipeTransform {
6
- transform(value: string, lang?: string): string {
7
- return AXTranslator.get(value, lang);
8
- }
9
- }
@@ -1,31 +0,0 @@
1
- import { Subject, Observable } from 'rxjs';
2
- import merge from 'lodash-es/merge';
3
- import { AXObjectUtil } from '../utils/object-util';
4
-
5
- // @dynamic
6
- export class AXTranslator {
7
- private static lang: string = 'en';
8
- private static dataChangeSubject = new Subject<any>();
9
-
10
-
11
- static get onChange(): Observable<any> {
12
- return AXTranslator.dataChangeSubject.asObservable();
13
- }
14
-
15
- public static load(lang: string, value: any) {
16
- if (typeof value === 'object') {
17
- if (!AXTranslator[`__data__${lang}`]) {
18
- AXTranslator[`__data__${lang}`] = {};
19
- }
20
- AXTranslator[`__data__${lang}`] = merge(AXTranslator[`__data__${lang}`], value);
21
- }
22
- }
23
-
24
- public static use(lang: string) {
25
- AXTranslator.lang = lang;
26
- }
27
-
28
- public static get(key: string, lang?: string): string {
29
- return AXObjectUtil.getPropByPath(AXTranslator[`__data__${lang || AXTranslator.lang}`], key) || key;
30
- }
31
- }
@@ -1,43 +0,0 @@
1
- export interface AXPoint {
2
- x: number;
3
- y: number;
4
- }
5
-
6
- export interface AXBoundingClientRect {
7
- left?: number;
8
- top?: number;
9
- width?: number;
10
- height?: number;
11
- bottom?: number;
12
- right?: number;
13
- }
14
- // @dynamic
15
- export class AXDrawingUtil {
16
- static collision(a: HTMLElement, b: HTMLElement): boolean {
17
- const ac = a.getBoundingClientRect();
18
- const bc = b.getBoundingClientRect();
19
-
20
- if (ac.left < bc.left + bc.width && ac.left + ac.width > bc.left &&
21
- ac.top < bc.top + bc.height && ac.top + ac.height > bc.top) {
22
- return true;
23
- }
24
- else {
25
- return false;
26
- }
27
- }
28
-
29
- static isInElementBound(pos: AXPoint, element: HTMLElement): boolean {
30
- const elBound = element.getBoundingClientRect();
31
- return AXDrawingUtil.isInRecPoint(pos, {
32
- left: elBound.x,
33
- width: elBound.width,
34
- top: elBound.y,
35
- height: elBound.height
36
- });
37
- }
38
-
39
- static isInRecPoint(pos: AXPoint, rec: AXBoundingClientRect): boolean {
40
- return pos.x >= rec.left && pos.x <= (rec.left + rec.width) && pos.y >= rec.top && (pos.y <= (rec.top + rec.height));
41
- }
42
-
43
- }
@@ -1,82 +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
- static fetchProp(obj, prop: string) {
37
- if (typeof obj === 'undefined') {
38
- return false;
39
- }
40
- const index = prop.indexOf('.');
41
-
42
- if (index > -1) {
43
- return AXObjectUtil.fetchProp(obj[prop.substring(0, index)], prop.substr(index + 1));
44
- }
45
-
46
- return obj[prop];
47
- }
48
-
49
- static getPropByPath(obj, path, defaultVal?) {
50
- path = path
51
- .replace(/\[/g, '.')
52
- .replace(/]/g, '')
53
- .split('.');
54
-
55
- path.forEach((level) => {
56
- if (obj) {
57
- obj = obj[level];
58
- }
59
- });
60
-
61
- if (obj === undefined) {
62
- return defaultVal;
63
- }
64
- return obj;
65
- }
66
-
67
- static setPropByPath(obj, path, value) {
68
- if (Object(obj) !== obj) { return obj; } // When obj is not an object
69
- // If not yet an array, get the keys from the string-path
70
- if (!Array.isArray(path)) { path = path.toString().match(/[^.[\]]+/g) || []; }
71
- path.slice(0, -1).reduce((a, c, i) => // Iterate all of them except the last one
72
- Object(a[c]) === a[c] // Does the key exist and is its value an object?
73
- // Yes: then follow that path
74
- ? a[c]
75
- // No: create the key. Is the next key a potential array-index?
76
- : a[c] = Math.abs(path[i + 1]) >> 0 === +path[i + 1]
77
- ? [] // Yes: assign a new array object
78
- : {}, // No: assign a new plain object
79
- obj)[path[path.length - 1]] = value; // Finally assign the value to the last key
80
- return obj; // Return the top-level object to allow chaining
81
- }
82
- }
@@ -1,24 +0,0 @@
1
- import { Pipe, PipeTransform } from '@angular/core';
2
- import { DomSanitizer, SafeHtml, SafeStyle, SafeScript, SafeUrl, SafeResourceUrl } from '@angular/platform-browser';
3
-
4
- @Pipe({
5
- name: 'safe',
6
- pure: true
7
- })
8
- export class AXSafePipe implements PipeTransform {
9
-
10
- constructor(protected sanitizer: DomSanitizer) { }
11
-
12
- public transform(value: any, type: string): SafeHtml | SafeStyle | SafeScript | SafeUrl | SafeResourceUrl {
13
- if (value == null || value == undefined || value == '')
14
- return null;
15
- switch (type) {
16
- case 'html': return this.sanitizer.bypassSecurityTrustHtml(value);
17
- case 'style': return this.sanitizer.bypassSecurityTrustStyle(value);
18
- case 'script': return this.sanitizer.bypassSecurityTrustScript(value);
19
- case 'url': return this.sanitizer.bypassSecurityTrustUrl(value);
20
- case 'resourceUrl': return this.sanitizer.bypassSecurityTrustResourceUrl(value);
21
- default: throw new Error(`Invalid safe type specified: ${type}`);
22
- }
23
- }
24
- }
package/src/test.ts DELETED
@@ -1,26 +0,0 @@
1
- // This file is required by karma.conf.js and loads recursively all the .spec and framework files
2
-
3
- import 'zone.js/dist/zone';
4
- import 'zone.js/dist/zone-testing';
5
- import { getTestBed } from '@angular/core/testing';
6
- import {
7
- BrowserDynamicTestingModule,
8
- platformBrowserDynamicTesting
9
- } from '@angular/platform-browser-dynamic/testing';
10
-
11
- declare const require: {
12
- context(path: string, deep?: boolean, filter?: RegExp): {
13
- keys(): string[];
14
- <T>(id: string): T;
15
- };
16
- };
17
-
18
- // First, initialize the Angular testing environment.
19
- getTestBed().initTestEnvironment(
20
- BrowserDynamicTestingModule,
21
- platformBrowserDynamicTesting()
22
- );
23
- // Then we find all the tests.
24
- const context = require.context('./', true, /\.spec\.ts$/);
25
- // And load the modules.
26
- context.keys().map(context);
package/tsconfig.lib.json DELETED
@@ -1,20 +0,0 @@
1
- /* To learn more about this file see: https://angular.io/config/tsconfig. */
2
- {
3
- "extends": "../../../tsconfig.json",
4
- "compilerOptions": {
5
- "outDir": "../../../out-tsc/lib",
6
- "target": "es2015",
7
- "declaration": true,
8
- "declarationMap": true,
9
- "inlineSources": true,
10
- "types": [],
11
- "lib": [
12
- "dom",
13
- "es2018"
14
- ]
15
- },
16
- "exclude": [
17
- "src/test.ts",
18
- "**/*.spec.ts"
19
- ]
20
- }
@@ -1,10 +0,0 @@
1
- /* To learn more about this file see: https://angular.io/config/tsconfig. */
2
- {
3
- "extends": "./tsconfig.lib.json",
4
- "compilerOptions": {
5
- "declarationMap": false
6
- },
7
- "angularCompilerOptions": {
8
- "compilationMode": "partial"
9
- }
10
- }
@@ -1,17 +0,0 @@
1
- /* To learn more about this file see: https://angular.io/config/tsconfig. */
2
- {
3
- "extends": "../../../tsconfig.json",
4
- "compilerOptions": {
5
- "outDir": "../../../out-tsc/spec",
6
- "types": [
7
- "jasmine"
8
- ]
9
- },
10
- "files": [
11
- "src/test.ts"
12
- ],
13
- "include": [
14
- "**/*.spec.ts",
15
- "**/*.d.ts"
16
- ]
17
- }