@acorex/core 7.0.20 → 7.0.22
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/config/index.d.ts +5 -0
- package/config/public-api.d.ts +1 -0
- package/config/src/configs.d.ts +9 -0
- package/dateTime/index.d.ts +5 -0
- package/dateTime/{public-api.ts → public-api.d.ts} +1 -1
- package/dateTime/src/datetime.class.d.ts +100 -0
- package/dateTime/src/datetime.module.d.ts +8 -0
- package/dateTime/src/datetime.pipe.d.ts +8 -0
- package/dateTime/src/georgian.calendar.d.ts +20 -0
- package/dateTime/src/jalali.calendar.d.ts +35 -0
- package/esm2020/acorex-core.mjs +5 -0
- package/esm2020/config/acorex-core-config.mjs +5 -0
- package/esm2020/config/public-api.mjs +2 -0
- package/esm2020/config/src/configs.mjs +32 -0
- package/esm2020/dateTime/acorex-core-dateTime.mjs +5 -0
- package/esm2020/dateTime/public-api.mjs +6 -0
- package/esm2020/dateTime/src/datetime.class.mjs +288 -0
- package/esm2020/dateTime/src/datetime.module.mjs +39 -0
- package/esm2020/dateTime/src/datetime.pipe.mjs +26 -0
- package/esm2020/dateTime/src/georgian.calendar.mjs +189 -0
- package/esm2020/dateTime/src/jalali.calendar.mjs +359 -0
- package/esm2020/events/acorex-core-events.mjs +5 -0
- package/esm2020/events/public-api.mjs +2 -0
- package/esm2020/events/src/event.service.mjs +36 -0
- package/esm2020/file/acorex-core-file.mjs +5 -0
- package/esm2020/file/public-api.mjs +5 -0
- package/esm2020/file/src/file-download-ref.class.mjs +12 -0
- package/esm2020/file/src/file-download-result.class.mjs +47 -0
- package/esm2020/file/src/file-upload-ref.class.mjs +12 -0
- package/esm2020/file/src/file.service.mjs +101 -0
- package/esm2020/http/acorex-core-http.mjs +5 -0
- package/esm2020/http/public-api.mjs +6 -0
- package/esm2020/http/src/http-error.class.mjs +2 -0
- package/esm2020/http/src/http-events.interceptor.mjs +3 -0
- package/esm2020/http/src/http-request.class.mjs +2 -0
- package/esm2020/http/src/http-result.class.mjs +21 -0
- package/esm2020/http/src/http.module.mjs +29 -0
- package/esm2020/http/src/http.service.mjs +148 -0
- package/esm2020/image/acorex-core-image.mjs +5 -0
- package/esm2020/image/public-api.mjs +2 -0
- package/esm2020/image/src/image.service.mjs +43 -0
- package/esm2020/pipes/acorex-core-pipes.mjs +5 -0
- package/esm2020/pipes/public-api.mjs +3 -0
- package/esm2020/pipes/src/pipes.module.mjs +19 -0
- package/esm2020/pipes/src/safe.pipe.mjs +30 -0
- package/esm2020/platform/acorex-core-platform.mjs +5 -0
- package/esm2020/platform/public-api.mjs +2 -0
- package/esm2020/platform/src/platform.service.mjs +153 -0
- package/esm2020/public-api.mjs +5 -0
- package/esm2020/translation/acorex-core-translation.mjs +5 -0
- package/esm2020/translation/public-api.mjs +4 -0
- package/esm2020/translation/src/translation.module.mjs +18 -0
- package/esm2020/translation/src/translator.mjs +43 -0
- package/esm2020/translation/src/translator.pipe.mjs +15 -0
- package/esm2020/utils/acorex-core-utils.mjs +5 -0
- package/esm2020/utils/public-api.mjs +5 -0
- package/esm2020/utils/src/color-util.mjs +71 -0
- package/esm2020/utils/src/drawing-util.mjs +27 -0
- package/esm2020/utils/src/object-util.mjs +39 -0
- package/esm2020/utils/src/string-util.mjs +19 -0
- package/events/index.d.ts +5 -0
- package/events/public-api.d.ts +1 -0
- package/events/src/event.service.d.ts +9 -0
- package/fesm2015/acorex-core-config.mjs +40 -0
- package/fesm2015/acorex-core-config.mjs.map +1 -0
- package/fesm2015/acorex-core-dateTime.mjs +899 -0
- package/fesm2015/acorex-core-dateTime.mjs.map +1 -0
- package/fesm2015/acorex-core-events.mjs +44 -0
- package/fesm2015/acorex-core-events.mjs.map +1 -0
- package/fesm2015/acorex-core-file.mjs +177 -0
- package/fesm2015/acorex-core-file.mjs.map +1 -0
- package/fesm2015/acorex-core-http.mjs +203 -0
- package/fesm2015/acorex-core-http.mjs.map +1 -0
- package/fesm2015/acorex-core-image.mjs +54 -0
- package/fesm2015/acorex-core-image.mjs.map +1 -0
- package/fesm2015/acorex-core-pipes.mjs +54 -0
- package/fesm2015/acorex-core-pipes.mjs.map +1 -0
- package/fesm2015/acorex-core-platform.mjs +161 -0
- package/fesm2015/acorex-core-platform.mjs.map +1 -0
- package/fesm2015/acorex-core-translation.mjs +81 -0
- package/fesm2015/acorex-core-translation.mjs.map +1 -0
- package/fesm2015/acorex-core-utils.mjs +164 -0
- package/fesm2015/acorex-core-utils.mjs.map +1 -0
- package/fesm2015/acorex-core.mjs +12 -0
- package/fesm2015/acorex-core.mjs.map +1 -0
- package/fesm2020/acorex-core-config.mjs +40 -0
- package/fesm2020/acorex-core-config.mjs.map +1 -0
- package/fesm2020/acorex-core-dateTime.mjs +899 -0
- package/fesm2020/acorex-core-dateTime.mjs.map +1 -0
- package/fesm2020/acorex-core-events.mjs +44 -0
- package/fesm2020/acorex-core-events.mjs.map +1 -0
- package/fesm2020/acorex-core-file.mjs +177 -0
- package/fesm2020/acorex-core-file.mjs.map +1 -0
- package/fesm2020/acorex-core-http.mjs +202 -0
- package/fesm2020/acorex-core-http.mjs.map +1 -0
- package/fesm2020/acorex-core-image.mjs +51 -0
- package/fesm2020/acorex-core-image.mjs.map +1 -0
- package/fesm2020/acorex-core-pipes.mjs +54 -0
- package/fesm2020/acorex-core-pipes.mjs.map +1 -0
- package/fesm2020/acorex-core-platform.mjs +161 -0
- package/fesm2020/acorex-core-platform.mjs.map +1 -0
- package/fesm2020/acorex-core-translation.mjs +80 -0
- package/fesm2020/acorex-core-translation.mjs.map +1 -0
- package/fesm2020/acorex-core-utils.mjs +164 -0
- package/fesm2020/acorex-core-utils.mjs.map +1 -0
- package/fesm2020/acorex-core.mjs +12 -0
- package/fesm2020/acorex-core.mjs.map +1 -0
- package/file/index.d.ts +5 -0
- package/file/public-api.d.ts +4 -0
- package/file/src/file-download-ref.class.d.ts +6 -0
- package/file/src/file-download-result.class.d.ts +8 -0
- package/file/src/file-upload-ref.class.d.ts +5 -0
- package/file/src/file.service.d.ts +18 -0
- package/http/index.d.ts +5 -0
- package/http/{public-api.ts → public-api.d.ts} +1 -1
- package/http/src/{http-error.class.ts → http-error.class.d.ts} +2 -2
- package/http/src/{http-events.interceptor.ts → http-events.interceptor.d.ts} +3 -7
- package/http/src/{http-request.class.ts → http-request.class.d.ts} +5 -5
- package/http/src/http-result.class.d.ts +11 -0
- package/http/src/http.module.d.ts +8 -0
- package/http/src/http.service.d.ts +23 -0
- package/image/index.d.ts +5 -0
- package/image/public-api.d.ts +1 -0
- package/image/src/image.service.d.ts +12 -0
- package/index.d.ts +5 -0
- package/package.json +115 -16
- package/pipes/index.d.ts +5 -0
- package/pipes/public-api.d.ts +2 -0
- package/pipes/src/pipes.module.d.ts +8 -0
- package/pipes/src/safe.pipe.d.ts +10 -0
- package/platform/index.d.ts +5 -0
- package/platform/public-api.d.ts +1 -0
- package/platform/src/platform.service.d.ts +26 -0
- package/public-api.d.ts +1 -0
- package/translation/index.d.ts +5 -0
- package/translation/{public-api.ts → public-api.d.ts} +1 -1
- package/translation/src/translation.module.d.ts +7 -0
- package/translation/src/translator.d.ts +11 -0
- package/translation/src/translator.pipe.d.ts +7 -0
- package/utils/index.d.ts +5 -0
- package/utils/{public-api.ts → public-api.d.ts} +1 -1
- package/utils/src/color-util.d.ts +20 -0
- package/utils/src/drawing-util.d.ts +17 -0
- package/utils/src/object-util.d.ts +4 -0
- package/utils/src/string-util.d.ts +6 -0
- package/config/ax-preset.js +0 -186
- package/config/index.ts +0 -1
- package/config/ng-package.json +0 -6
- package/config/public-api.ts +0 -1
- package/config/src/configs.ts +0 -37
- package/dateTime/index.ts +0 -1
- package/dateTime/ng-package.json +0 -6
- package/dateTime/src/datetime.class.ts +0 -449
- package/dateTime/src/datetime.module.ts +0 -35
- package/dateTime/src/datetime.pipe.ts +0 -21
- package/dateTime/src/georgian.calendar.ts +0 -205
- package/dateTime/src/jalali.calendar.ts +0 -416
- package/events/index.ts +0 -1
- package/events/ng-package.json +0 -6
- package/events/public-api.ts +0 -1
- package/events/src/event.service.ts +0 -31
- package/file/index.ts +0 -1
- package/file/ng-package.json +0 -7
- package/file/public-api.ts +0 -4
- package/file/src/file-download-ref.class.ts +0 -16
- package/file/src/file-download-result.class.ts +0 -56
- package/file/src/file-upload-ref.class.ts +0 -14
- package/file/src/file.service.ts +0 -104
- package/http/index.ts +0 -1
- package/http/ng-package.json +0 -6
- package/http/src/http-result.class.ts +0 -34
- package/http/src/http.module.ts +0 -25
- package/http/src/http.service.ts +0 -161
- package/image/index.ts +0 -1
- package/image/ng-package.json +0 -7
- package/image/public-api.ts +0 -1
- package/image/src/image.service.ts +0 -42
- package/index.ts +0 -1
- package/karma.conf.js +0 -44
- package/ng-package.json +0 -7
- package/pipes/index.ts +0 -1
- package/pipes/ng-package.json +0 -6
- package/pipes/public-api.ts +0 -2
- package/pipes/src/pipes.module.ts +0 -11
- package/pipes/src/safe.pipe.ts +0 -24
- package/platform/index.ts +0 -1
- package/platform/ng-package.json +0 -6
- package/platform/public-api.ts +0 -1
- package/platform/src/platform.service.ts +0 -223
- package/public-api.ts +0 -4
- package/test.ts +0 -27
- package/translation/index.ts +0 -1
- package/translation/ng-package.json +0 -6
- package/translation/src/translation.module.ts +0 -12
- package/translation/src/translator.pipe.ts +0 -9
- package/translation/src/translator.ts +0 -49
- package/tsconfig.lib.json +0 -15
- package/tsconfig.lib.prod.json +0 -10
- package/tsconfig.spec.json +0 -17
- package/utils/index.ts +0 -1
- package/utils/ng-package.json +0 -6
- package/utils/src/color-util.ts +0 -83
- package/utils/src/drawing-util.ts +0 -43
- package/utils/src/object-util.ts +0 -82
- package/utils/src/string-util.ts +0 -25
@@ -1,223 +0,0 @@
|
|
1
|
-
import { Injectable } from '@angular/core';
|
2
|
-
import { fromEvent, Subject } from 'rxjs';
|
3
|
-
import { debounceTime, distinctUntilChanged } from 'rxjs/operators';
|
4
|
-
|
5
|
-
export type AXPlatforms = 'Android' | 'Desktop' | 'iOS' | 'Mobile';
|
6
|
-
export type AXBrowsers =
|
7
|
-
| 'Chrome'
|
8
|
-
| 'Safari'
|
9
|
-
| 'Edge'
|
10
|
-
| 'Firefox'
|
11
|
-
| 'Opera'
|
12
|
-
| 'MSIE';
|
13
|
-
export type AXTechnologies = 'PWA' | 'Hybrid' | 'Electron';
|
14
|
-
|
15
|
-
export type AXScreenSizes = 'SM' | 'MD' | 'LG' | 'XL' | '2XL';
|
16
|
-
|
17
|
-
const isChrome = (win: Window): boolean => testUserAgent(win, /Chrome/i);
|
18
|
-
|
19
|
-
const isFirefox = (win: Window): boolean => testUserAgent(win, /Firefox/i);
|
20
|
-
|
21
|
-
const isEdge = (win: Window): boolean => testUserAgent(win, /Edge/i);
|
22
|
-
|
23
|
-
const isSafari = (win: Window): boolean => testUserAgent(win, /Safari/i);
|
24
|
-
|
25
|
-
const isOpera = (win: Window): boolean =>
|
26
|
-
testUserAgent(win, /Opera/i) || testUserAgent(win, /OPR/i);
|
27
|
-
|
28
|
-
const isMSIE = (win: Window): boolean =>
|
29
|
-
testUserAgent(win, /MSIE/i) || testUserAgent(win, /Trident/i);
|
30
|
-
|
31
|
-
const isMobileWeb = (win: Window): boolean => isMobile(win) && !isHybrid(win);
|
32
|
-
|
33
|
-
const isIpad = (win: Window) => {
|
34
|
-
// iOS 12 and below
|
35
|
-
if (testUserAgent(win, /iPad/i)) {
|
36
|
-
return true;
|
37
|
-
}
|
38
|
-
|
39
|
-
// iOS 13+
|
40
|
-
if (testUserAgent(win, /Macintosh/i) && isMobile(win)) {
|
41
|
-
return true;
|
42
|
-
}
|
43
|
-
|
44
|
-
return false;
|
45
|
-
};
|
46
|
-
|
47
|
-
const isIphone = (win: Window) => testUserAgent(win, /iPhone/i);
|
48
|
-
|
49
|
-
const isIOS = (win: Window) =>
|
50
|
-
testUserAgent(win, /iPhone|iPod/i) || isIpad(win);
|
51
|
-
|
52
|
-
const isAndroid = (win: Window) => testUserAgent(win, /android|sink/i);
|
53
|
-
|
54
|
-
const isAndroidTablet = (win: Window) => {
|
55
|
-
return isAndroid(win) && !testUserAgent(win, /mobile/i);
|
56
|
-
};
|
57
|
-
|
58
|
-
const isPhablet = (win: Window) => {
|
59
|
-
const width = win.innerWidth;
|
60
|
-
const height = win.innerHeight;
|
61
|
-
const smallest = Math.min(width, height);
|
62
|
-
const largest = Math.max(width, height);
|
63
|
-
|
64
|
-
return smallest > 390 && smallest < 520 && largest > 620 && largest < 800;
|
65
|
-
};
|
66
|
-
|
67
|
-
const isTablet = (win: Window) => {
|
68
|
-
const width = win.innerWidth;
|
69
|
-
const height = win.innerHeight;
|
70
|
-
const smallest = Math.min(width, height);
|
71
|
-
const largest = Math.max(width, height);
|
72
|
-
|
73
|
-
return (
|
74
|
-
isIpad(win) ||
|
75
|
-
isAndroidTablet(win) ||
|
76
|
-
(smallest > 460 && smallest < 820 && largest > 780 && largest < 1400)
|
77
|
-
);
|
78
|
-
};
|
79
|
-
|
80
|
-
const isMobile = (win: Window) => matchMedia(win, '(any-pointer:coarse)');
|
81
|
-
const isTouch = (win: Window) => matchMedia(win, '(any-pointer:coarse)');
|
82
|
-
|
83
|
-
const isDesktop = (win: Window) => !isMobile(win);
|
84
|
-
|
85
|
-
const isHybrid = (win: Window) => isCordova(win) || isCapacitorNative(win);
|
86
|
-
|
87
|
-
const isCordova = (win: any): boolean =>
|
88
|
-
!!(win['cordova'] || win['phonegap'] || win['PhoneGap']);
|
89
|
-
|
90
|
-
const isCapacitorNative = (win: any): boolean => {
|
91
|
-
const capacitor = win['Capacitor'];
|
92
|
-
return !!(capacitor && capacitor.isNative);
|
93
|
-
};
|
94
|
-
|
95
|
-
const isElectron = (win: Window): boolean => testUserAgent(win, /electron/i);
|
96
|
-
|
97
|
-
const isPWA = (win: Window): boolean =>
|
98
|
-
!!(
|
99
|
-
win.matchMedia('(display-mode: standalone)').matches ||
|
100
|
-
(win.navigator as any).standalone
|
101
|
-
);
|
102
|
-
|
103
|
-
export const testUserAgent = (win: Window, expr: RegExp) =>
|
104
|
-
expr.test(win.navigator.userAgent);
|
105
|
-
|
106
|
-
const matchMedia = (win: Window, query: string): boolean =>
|
107
|
-
win.matchMedia(query).matches;
|
108
|
-
|
109
|
-
|
110
|
-
const isSMScreen = (win: Window) => matchMedia(win, '(max-width: 640px)');
|
111
|
-
const isMDScreen = (win: Window) => matchMedia(win, '(max-width: 768px)');
|
112
|
-
const isLGScreen = (win: Window) => matchMedia(win, '(max-width: 1024px)');
|
113
|
-
const isXLScreen = (win: Window) => matchMedia(win, '(max-width: 1280px)');
|
114
|
-
const is2XLScreen = (win: Window) => matchMedia(win, '(max-width: 1536px)');
|
115
|
-
|
116
|
-
const PLATFORMS_MAP: any = {
|
117
|
-
Android: isAndroid,
|
118
|
-
iOS: isIOS,
|
119
|
-
Desktop: isDesktop,
|
120
|
-
Mobile: isMobile,
|
121
|
-
Touch: isTouch,
|
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
|
-
SM: isSMScreen,
|
131
|
-
MD: isMDScreen,
|
132
|
-
LG: isLGScreen,
|
133
|
-
XL: isXLScreen,
|
134
|
-
"2XL": is2XLScreen,
|
135
|
-
};
|
136
|
-
|
137
|
-
export class AXPlatformEvent<T extends Event = Event> {
|
138
|
-
nativeEvent!: T;
|
139
|
-
source!: AXPlatform;
|
140
|
-
}
|
141
|
-
|
142
|
-
@Injectable({
|
143
|
-
providedIn: 'root',
|
144
|
-
})
|
145
|
-
export class AXPlatform {
|
146
|
-
resize: Subject<AXPlatformEvent> = new Subject<AXPlatformEvent>();
|
147
|
-
click: Subject<AXPlatformEvent> = new Subject<AXPlatformEvent>();
|
148
|
-
scroll: Subject<AXPlatformEvent> = new Subject<AXPlatformEvent>();
|
149
|
-
|
150
|
-
isRtl(): boolean {
|
151
|
-
return (
|
152
|
-
document.dir == 'rtl' ||
|
153
|
-
document.body.dir == 'rtl' ||
|
154
|
-
document.body.style.direction == 'rtl'
|
155
|
-
);
|
156
|
-
}
|
157
|
-
|
158
|
-
isLandscape(): boolean {
|
159
|
-
return window.innerHeight < window.innerWidth;
|
160
|
-
}
|
161
|
-
|
162
|
-
isPortrate(): boolean {
|
163
|
-
return !this.isLandscape();
|
164
|
-
}
|
165
|
-
|
166
|
-
is(name: AXPlatforms | AXBrowsers | AXTechnologies | AXScreenSizes): boolean {
|
167
|
-
return PLATFORMS_MAP[name](window) || false;
|
168
|
-
}
|
169
|
-
|
170
|
-
switchDarkMode() {
|
171
|
-
const _html = document.getElementsByTagName('html')[0];
|
172
|
-
_html.classList.add('ax-dark');
|
173
|
-
}
|
174
|
-
|
175
|
-
switchLightMode() {
|
176
|
-
const _html = document.getElementsByTagName('html')[0];
|
177
|
-
_html.classList.remove('ax-dark');
|
178
|
-
}
|
179
|
-
|
180
|
-
private _setFullHeightRatio() {
|
181
|
-
document
|
182
|
-
.querySelector<HTMLElement>(':root')
|
183
|
-
?.style.setProperty('--ax-vh', window.innerHeight / 100 + 'px');
|
184
|
-
}
|
185
|
-
|
186
|
-
constructor() {
|
187
|
-
fromEvent<UIEvent>(window, 'resize')
|
188
|
-
.pipe(debounceTime(100))
|
189
|
-
.pipe(distinctUntilChanged())
|
190
|
-
.subscribe((e) => {
|
191
|
-
this.resize.next({
|
192
|
-
nativeEvent: e,
|
193
|
-
source: this,
|
194
|
-
});
|
195
|
-
//
|
196
|
-
this._setFullHeightRatio();
|
197
|
-
});
|
198
|
-
|
199
|
-
document.addEventListener(
|
200
|
-
'click',
|
201
|
-
(e) => {
|
202
|
-
this.click.next({
|
203
|
-
nativeEvent: e,
|
204
|
-
source: this,
|
205
|
-
});
|
206
|
-
},
|
207
|
-
true
|
208
|
-
);
|
209
|
-
|
210
|
-
document.addEventListener(
|
211
|
-
'scroll',
|
212
|
-
(e) => {
|
213
|
-
this.scroll.next({
|
214
|
-
nativeEvent: e,
|
215
|
-
source: this,
|
216
|
-
});
|
217
|
-
},
|
218
|
-
true
|
219
|
-
);
|
220
|
-
// init functions
|
221
|
-
this._setFullHeightRatio();
|
222
|
-
}
|
223
|
-
}
|
package/public-api.ts
DELETED
package/test.ts
DELETED
@@ -1,27 +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';
|
4
|
-
import 'zone.js/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
|
-
<T>(id: string): T;
|
14
|
-
keys(): string[];
|
15
|
-
};
|
16
|
-
};
|
17
|
-
|
18
|
-
// First, initialize the Angular testing environment.
|
19
|
-
getTestBed().initTestEnvironment(
|
20
|
-
BrowserDynamicTestingModule,
|
21
|
-
platformBrowserDynamicTesting(),
|
22
|
-
);
|
23
|
-
|
24
|
-
// Then we find all the tests.
|
25
|
-
const context = require.context('./', true, /\.spec\.ts$/);
|
26
|
-
// And load the modules.
|
27
|
-
context.keys().forEach(context);
|
package/translation/index.ts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
export * from './public-api'
|
@@ -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, arg1?: object | string, arg2?: object): string {
|
7
|
-
return AXTranslator.get(value, arg1, arg2);
|
8
|
-
}
|
9
|
-
}
|
@@ -1,49 +0,0 @@
|
|
1
|
-
import { Subject, Observable } from 'rxjs';
|
2
|
-
import merge from 'lodash-es/merge';
|
3
|
-
import * as _ from 'lodash';
|
4
|
-
|
5
|
-
// @dynamic
|
6
|
-
export class AXTranslator {
|
7
|
-
private static lang: string = 'en';
|
8
|
-
private static dataChangeSubject = new Subject<any>();
|
9
|
-
private static _varsRegx = /((\$\{[a-zA-Z_0-9\.]+\})+)/gm;
|
10
|
-
private static _varNameRegx = /[a-zA-Z_0-9\.]+/gm;
|
11
|
-
|
12
|
-
|
13
|
-
static get onChange(): Observable<any> {
|
14
|
-
return AXTranslator.dataChangeSubject.asObservable();
|
15
|
-
}
|
16
|
-
|
17
|
-
public static load(lang: string, value: any) {
|
18
|
-
if (typeof value === 'object') {
|
19
|
-
if (!AXTranslator[`__data__${lang}`]) {
|
20
|
-
AXTranslator[`__data__${lang}`] = {};
|
21
|
-
}
|
22
|
-
AXTranslator[`__data__${lang}`] = merge(AXTranslator[`__data__${lang}`], value);
|
23
|
-
}
|
24
|
-
}
|
25
|
-
|
26
|
-
public static use(lang: string) {
|
27
|
-
AXTranslator.lang = lang;
|
28
|
-
}
|
29
|
-
|
30
|
-
public static get(key: string, arg1?: object | string, arg2?: object): string {
|
31
|
-
|
32
|
-
const lang = arg1 && typeof arg1 == 'string' ? arg1 : AXTranslator.lang;
|
33
|
-
const params = arg1 && typeof arg1 == 'object' ? arg1 : arg2;
|
34
|
-
let result = _.get(AXTranslator[`__data__${lang}`], key, key);
|
35
|
-
const vars = typeof (result) == 'string' ? result?.match(this._varsRegx) : [];
|
36
|
-
if (vars?.length) {
|
37
|
-
vars.forEach((v:any) => {
|
38
|
-
const varKey = v.match(this._varNameRegx)?.length ? v.match(this._varNameRegx)[0] : null;
|
39
|
-
if (varKey) {
|
40
|
-
const p = _.get(params, varKey) || this.get(varKey, lang);
|
41
|
-
if (p) {
|
42
|
-
result = result.replace(v, p);
|
43
|
-
}
|
44
|
-
}
|
45
|
-
})
|
46
|
-
}
|
47
|
-
return typeof (result) == 'string' ? result : JSON.stringify(result);
|
48
|
-
}
|
49
|
-
}
|
package/tsconfig.lib.json
DELETED
@@ -1,15 +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
|
-
"declaration": true,
|
7
|
-
"declarationMap": true,
|
8
|
-
"inlineSources": true,
|
9
|
-
"types": []
|
10
|
-
},
|
11
|
-
"exclude": [
|
12
|
-
"src/test.ts",
|
13
|
-
"**/*.spec.ts"
|
14
|
-
]
|
15
|
-
}
|
package/tsconfig.lib.prod.json
DELETED
package/tsconfig.spec.json
DELETED
@@ -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
|
-
}
|
package/utils/index.ts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
export * from './public-api';
|
package/utils/ng-package.json
DELETED
package/utils/src/color-util.ts
DELETED
@@ -1,83 +0,0 @@
|
|
1
|
-
export type AXColorMode = 'rgba' | 'hex' | 'hsla' | 'hsva';
|
2
|
-
|
3
|
-
import tinycolor, { ColorInput } from 'tinycolor2';
|
4
|
-
import tinygradient from 'tinygradient'
|
5
|
-
|
6
|
-
export type AXColorFormat = ColorInput;
|
7
|
-
|
8
|
-
export class AXColorUtil {
|
9
|
-
|
10
|
-
|
11
|
-
static to(color: AXColorFormat, mode: AXColorMode): AXColorFormat {
|
12
|
-
const _color = tinycolor(color)
|
13
|
-
switch (mode) {
|
14
|
-
case 'rgba': ;
|
15
|
-
return _color.toRgb();
|
16
|
-
case 'hsla':
|
17
|
-
return _color.toHsl();
|
18
|
-
case 'hsva':
|
19
|
-
return _color.toHsv();
|
20
|
-
default:
|
21
|
-
return _color.toHex();
|
22
|
-
}
|
23
|
-
};
|
24
|
-
|
25
|
-
static toString(color: AXColorFormat, mode: AXColorMode): string {
|
26
|
-
const _color = tinycolor(color)
|
27
|
-
switch (mode) {
|
28
|
-
case 'rgba':
|
29
|
-
return _color.toRgbString();
|
30
|
-
case 'hsla':
|
31
|
-
return _color.toHslString();
|
32
|
-
case 'hsva':
|
33
|
-
return _color.toHsvString();
|
34
|
-
default:
|
35
|
-
return _color.toHexString();
|
36
|
-
}
|
37
|
-
};
|
38
|
-
|
39
|
-
static mix(baseColor: AXColorFormat, hex: AXColorFormat, percentage: number): string {
|
40
|
-
return tinycolor.mix(baseColor, hex, percentage).toString('rgb');
|
41
|
-
}
|
42
|
-
|
43
|
-
static multiply(color1: AXColorFormat, color2: AXColorFormat): string {
|
44
|
-
let rgb1 = tinycolor(color1).toRgb();
|
45
|
-
let rgb2 = tinycolor(color2).toRgb();
|
46
|
-
rgb1.b = Math.floor(rgb1.b * rgb2.b / 255);
|
47
|
-
rgb1.g = Math.floor(rgb1.g * rgb2.g / 255);
|
48
|
-
rgb1.r = Math.floor(rgb1.r * rgb2.r / 255);
|
49
|
-
return tinycolor('rgb ' + rgb1.r + ' ' + rgb1.g + ' ' + rgb1.b).toString('rgb');
|
50
|
-
}
|
51
|
-
static toHexSting(color: string): string {
|
52
|
-
const _color = tinycolor(color)
|
53
|
-
return _color.toHexString()
|
54
|
-
};
|
55
|
-
|
56
|
-
static toRGBString(color: AXColorFormat): string {
|
57
|
-
const _color = tinycolor(color)
|
58
|
-
return _color.toRgbString()
|
59
|
-
};
|
60
|
-
|
61
|
-
static contrastToWhite(color: AXColorFormat): number {
|
62
|
-
return tinycolor.readability("#fff", color);
|
63
|
-
};
|
64
|
-
|
65
|
-
|
66
|
-
static lighten(hex: AXColorFormat, percentage?: number) {
|
67
|
-
return tinycolor(hex).lighten(percentage)
|
68
|
-
}
|
69
|
-
|
70
|
-
static darken(hex: AXColorFormat, percentage?: number) {
|
71
|
-
return tinycolor(hex).darken(percentage)
|
72
|
-
}
|
73
|
-
|
74
|
-
static equal(color1: AXColorFormat, color2: AXColorFormat): boolean {
|
75
|
-
return tinycolor.equals(color1, color2);
|
76
|
-
}
|
77
|
-
|
78
|
-
|
79
|
-
static gradient(values: any[] | { color: any, pos: number }[]): tinygradient.Instance {
|
80
|
-
return tinygradient([...values])
|
81
|
-
}
|
82
|
-
|
83
|
-
}
|
@@ -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 | any): 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
|
-
}
|
package/utils/src/object-util.ts
DELETED
@@ -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
|
-
}
|
package/utils/src/string-util.ts
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
// @dynamic
|
2
|
-
export class AXStringUtil {
|
3
|
-
|
4
|
-
static getWordBoundsAtPosition(str: string, position: number): { start: number, end: number } {
|
5
|
-
const isSpace = (c) => /[^a-zA-Z0-9]+/i.test(c);
|
6
|
-
let start = position - 1;
|
7
|
-
|
8
|
-
while (start >= 0 && !isSpace(str[start])) {
|
9
|
-
start -= 1;
|
10
|
-
}
|
11
|
-
start = Math.max(0, start + 1);
|
12
|
-
const leftSideString:any = str.slice(start).match(/[a-zA-Z0-9]+/i);
|
13
|
-
start += leftSideString.index;
|
14
|
-
let end = start + leftSideString[0].length;
|
15
|
-
return {
|
16
|
-
start,
|
17
|
-
end
|
18
|
-
};
|
19
|
-
}
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
}
|