@acorex/core 5.0.4 → 5.0.5
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/README.md +24 -24
- package/karma.conf.js +44 -0
- package/ng-package.json +11 -0
- package/package.json +14 -18
- package/src/lib/config/configs.ts +36 -0
- package/src/lib/core.module.ts +10 -0
- package/src/lib/dateTime/datetime.class.ts +395 -0
- package/src/lib/dateTime/datetime.module.ts +11 -0
- package/src/lib/dateTime/datetime.pipe.ts +20 -0
- package/src/lib/dateTime/georgian.calendar.ts +157 -0
- package/{lib/dateTime/index.d.ts → src/lib/dateTime/index.ts} +4 -4
- package/src/lib/dateTime/jalali.calendar.ts +376 -0
- package/src/lib/http/http-error.class.ts +7 -0
- package/src/lib/http/http-events.interceptor.ts +14 -0
- package/src/lib/http/http-request.class.ts +14 -0
- package/src/lib/http/http-result.class.ts +34 -0
- package/src/lib/http/http.module.ts +25 -0
- package/src/lib/http/http.service.ts +159 -0
- package/src/lib/platform/index.ts +1 -0
- package/src/lib/platform/platform.service.ts +185 -0
- package/{lib/translation/index.d.ts → src/lib/translation/index.ts} +3 -3
- package/src/lib/translation/translation.module.ts +12 -0
- package/src/lib/translation/translator.pipe.ts +9 -0
- package/src/lib/translation/translator.ts +31 -0
- package/src/lib/utils/drawing-util.ts +43 -0
- package/src/lib/utils/index.ts +3 -0
- package/src/lib/utils/object-util.ts +82 -0
- package/src/lib/utils/safe.pipe.ts +24 -0
- package/{public-api.d.ts → src/public-api.ts} +11 -10
- package/src/test.ts +26 -0
- package/tsconfig.lib.json +20 -0
- package/tsconfig.lib.prod.json +10 -0
- package/tsconfig.spec.json +17 -0
- package/acorex-core.d.ts +0 -5
- package/bundles/acorex-core.umd.js +0 -900
- package/bundles/acorex-core.umd.js.map +0 -1
- package/esm2015/acorex-core.js +0 -5
- package/esm2015/lib/config/configs.js +0 -29
- package/esm2015/lib/core.module.js +0 -18
- package/esm2015/lib/dateTime/datetime.class.js +0 -236
- package/esm2015/lib/dateTime/datetime.module.js +0 -18
- package/esm2015/lib/dateTime/datetime.pipe.js +0 -25
- package/esm2015/lib/dateTime/georgian.calendar.js +0 -145
- package/esm2015/lib/dateTime/index.js +0 -5
- package/esm2015/lib/platform/index.js +0 -2
- package/esm2015/lib/platform/platform.service.js +0 -119
- package/esm2015/lib/translation/index.js +0 -4
- package/esm2015/lib/translation/translation.module.js +0 -18
- package/esm2015/lib/translation/translator.js +0 -26
- package/esm2015/lib/translation/translator.pipe.js +0 -15
- package/esm2015/lib/utils/index.js +0 -3
- package/esm2015/lib/utils/object-util.js +0 -83
- package/esm2015/lib/utils/safe.pipe.js +0 -30
- package/esm2015/public-api.js +0 -11
- package/fesm2015/acorex-core.js +0 -751
- package/fesm2015/acorex-core.js.map +0 -1
- package/lib/config/configs.d.ts +0 -9
- package/lib/core.module.d.ts +0 -7
- package/lib/dateTime/datetime.class.d.ts +0 -96
- package/lib/dateTime/datetime.module.d.ts +0 -7
- package/lib/dateTime/datetime.pipe.d.ts +0 -8
- package/lib/dateTime/georgian.calendar.d.ts +0 -17
- package/lib/platform/index.d.ts +0 -1
- package/lib/platform/platform.service.d.ts +0 -22
- package/lib/translation/translation.module.d.ts +0 -7
- package/lib/translation/translator.d.ts +0 -9
- package/lib/translation/translator.pipe.d.ts +0 -7
- package/lib/utils/index.d.ts +0 -2
- package/lib/utils/object-util.d.ts +0 -7
- package/lib/utils/safe.pipe.d.ts +0 -10
package/fesm2015/acorex-core.js
DELETED
|
@@ -1,751 +0,0 @@
|
|
|
1
|
-
import * as i0 from '@angular/core';
|
|
2
|
-
import { Pipe, NgModule, Injectable } from '@angular/core';
|
|
3
|
-
import * as i1 from '@angular/platform-browser';
|
|
4
|
-
import { Subject } from 'rxjs';
|
|
5
|
-
import merge from 'lodash-es/merge';
|
|
6
|
-
|
|
7
|
-
// @dynamic
|
|
8
|
-
class AXObjectUtil {
|
|
9
|
-
static deepJSONClone(obj) {
|
|
10
|
-
return obj ? JSON.parse(JSON.stringify(obj)) : null;
|
|
11
|
-
}
|
|
12
|
-
static deepCopy(obj) {
|
|
13
|
-
let copy;
|
|
14
|
-
// Handle the 3 simple types, and null or undefined
|
|
15
|
-
if (null == obj || 'object' !== typeof obj) {
|
|
16
|
-
return obj;
|
|
17
|
-
}
|
|
18
|
-
// Handle Date
|
|
19
|
-
if (obj instanceof Date) {
|
|
20
|
-
copy = new Date();
|
|
21
|
-
copy.setTime(obj.getTime());
|
|
22
|
-
return copy;
|
|
23
|
-
}
|
|
24
|
-
// Handle Array
|
|
25
|
-
if (obj instanceof Array) {
|
|
26
|
-
copy = [];
|
|
27
|
-
for (let i = 0, len = obj.length; i < len; i++) {
|
|
28
|
-
copy[i] = AXObjectUtil.deepCopy(obj[i]);
|
|
29
|
-
}
|
|
30
|
-
return copy;
|
|
31
|
-
}
|
|
32
|
-
// Handle Object
|
|
33
|
-
if (obj instanceof Object) {
|
|
34
|
-
copy = {};
|
|
35
|
-
for (const attr in obj) {
|
|
36
|
-
if (obj.hasOwnProperty(attr)) {
|
|
37
|
-
copy[attr] = AXObjectUtil.deepCopy(obj[attr]);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
return copy;
|
|
41
|
-
}
|
|
42
|
-
throw new Error('Unable to copy obj! Its type isn\'t supported.');
|
|
43
|
-
}
|
|
44
|
-
static fetchProp(obj, prop) {
|
|
45
|
-
if (typeof obj === 'undefined') {
|
|
46
|
-
return false;
|
|
47
|
-
}
|
|
48
|
-
const index = prop.indexOf('.');
|
|
49
|
-
if (index > -1) {
|
|
50
|
-
return AXObjectUtil.fetchProp(obj[prop.substring(0, index)], prop.substr(index + 1));
|
|
51
|
-
}
|
|
52
|
-
return obj[prop];
|
|
53
|
-
}
|
|
54
|
-
static getPropByPath(obj, path, defaultVal) {
|
|
55
|
-
path = path
|
|
56
|
-
.replace(/\[/g, '.')
|
|
57
|
-
.replace(/]/g, '')
|
|
58
|
-
.split('.');
|
|
59
|
-
path.forEach((level) => {
|
|
60
|
-
if (obj) {
|
|
61
|
-
obj = obj[level];
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
if (obj === undefined) {
|
|
65
|
-
return defaultVal;
|
|
66
|
-
}
|
|
67
|
-
return obj;
|
|
68
|
-
}
|
|
69
|
-
static setPropByPath(obj, path, value) {
|
|
70
|
-
if (Object(obj) !== obj) {
|
|
71
|
-
return obj;
|
|
72
|
-
} // When obj is not an object
|
|
73
|
-
// If not yet an array, get the keys from the string-path
|
|
74
|
-
if (!Array.isArray(path)) {
|
|
75
|
-
path = path.toString().match(/[^.[\]]+/g) || [];
|
|
76
|
-
}
|
|
77
|
-
path.slice(0, -1).reduce((a, c, i) => // Iterate all of them except the last one
|
|
78
|
-
Object(a[c]) === a[c] // Does the key exist and is its value an object?
|
|
79
|
-
// Yes: then follow that path
|
|
80
|
-
? a[c]
|
|
81
|
-
// No: create the key. Is the next key a potential array-index?
|
|
82
|
-
: a[c] = Math.abs(path[i + 1]) >> 0 === +path[i + 1]
|
|
83
|
-
? [] // Yes: assign a new array object
|
|
84
|
-
: {}, // No: assign a new plain object
|
|
85
|
-
obj)[path[path.length - 1]] = value; // Finally assign the value to the last key
|
|
86
|
-
return obj; // Return the top-level object to allow chaining
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
class AXSafePipe {
|
|
91
|
-
constructor(sanitizer) {
|
|
92
|
-
this.sanitizer = sanitizer;
|
|
93
|
-
}
|
|
94
|
-
transform(value, type) {
|
|
95
|
-
if (value == null || value == undefined || value == '')
|
|
96
|
-
return null;
|
|
97
|
-
switch (type) {
|
|
98
|
-
case 'html': return this.sanitizer.bypassSecurityTrustHtml(value);
|
|
99
|
-
case 'style': return this.sanitizer.bypassSecurityTrustStyle(value);
|
|
100
|
-
case 'script': return this.sanitizer.bypassSecurityTrustScript(value);
|
|
101
|
-
case 'url': return this.sanitizer.bypassSecurityTrustUrl(value);
|
|
102
|
-
case 'resourceUrl': return this.sanitizer.bypassSecurityTrustResourceUrl(value);
|
|
103
|
-
default: throw new Error(`Invalid safe type specified: ${type}`);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
AXSafePipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0, type: AXSafePipe, deps: [{ token: i1.DomSanitizer }], target: i0.ɵɵFactoryTarget.Pipe });
|
|
108
|
-
AXSafePipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0, type: AXSafePipe, name: "safe" });
|
|
109
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0, type: AXSafePipe, decorators: [{
|
|
110
|
-
type: Pipe,
|
|
111
|
-
args: [{
|
|
112
|
-
name: 'safe',
|
|
113
|
-
pure: true
|
|
114
|
-
}]
|
|
115
|
-
}], ctorParameters: function () { return [{ type: i1.DomSanitizer }]; } });
|
|
116
|
-
|
|
117
|
-
class AXCoreModule {
|
|
118
|
-
}
|
|
119
|
-
AXCoreModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0, type: AXCoreModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
120
|
-
AXCoreModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0, type: AXCoreModule, declarations: [AXSafePipe], exports: [AXSafePipe] });
|
|
121
|
-
AXCoreModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0, type: AXCoreModule, providers: [], imports: [[]] });
|
|
122
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0, type: AXCoreModule, decorators: [{
|
|
123
|
-
type: NgModule,
|
|
124
|
-
args: [{
|
|
125
|
-
imports: [],
|
|
126
|
-
exports: [AXSafePipe],
|
|
127
|
-
declarations: [AXSafePipe],
|
|
128
|
-
providers: [],
|
|
129
|
-
}]
|
|
130
|
-
}] });
|
|
131
|
-
|
|
132
|
-
// @dynamic
|
|
133
|
-
class AXConfig {
|
|
134
|
-
static get onChange() {
|
|
135
|
-
return AXConfig.dataChangeSubject.asObservable();
|
|
136
|
-
}
|
|
137
|
-
static set(arg1, arg2) {
|
|
138
|
-
if (arg1 && typeof arg1 == 'string') {
|
|
139
|
-
AXObjectUtil.setPropByPath(AXConfig.dataModel, arg1, arg2);
|
|
140
|
-
AXConfig.dataChangeSubject.next(AXConfig.dataModel);
|
|
141
|
-
return;
|
|
142
|
-
}
|
|
143
|
-
if (arg1 && typeof arg1 == 'object') {
|
|
144
|
-
Object.assign(AXConfig.dataModel, arg1);
|
|
145
|
-
AXConfig.dataChangeSubject.next(AXConfig.dataModel);
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
148
|
-
if (!arg1 && !arg2) {
|
|
149
|
-
return AXConfig.dataChangeSubject.asObservable();
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
static get(path, defaultValue) {
|
|
153
|
-
return AXObjectUtil.getPropByPath(AXConfig.dataModel, path) || defaultValue;
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
AXConfig.dataModel = {};
|
|
157
|
-
AXConfig.dataChangeSubject = new Subject();
|
|
158
|
-
|
|
159
|
-
const AX_CALENDARS = [
|
|
160
|
-
{
|
|
161
|
-
name: 'gregorian',
|
|
162
|
-
type: 'GeorgianCalendar'
|
|
163
|
-
},
|
|
164
|
-
{
|
|
165
|
-
name: 'jalali',
|
|
166
|
-
type: 'JalaliCalendar'
|
|
167
|
-
}
|
|
168
|
-
];
|
|
169
|
-
/**
|
|
170
|
-
* Standard links:
|
|
171
|
-
* {@link Foo} or {@linkplain Foo} or [[Foo]]
|
|
172
|
-
*
|
|
173
|
-
* Code links: (Puts Foo inside <code> tags)
|
|
174
|
-
* {@linkcode Foo} or [[`Foo`]]
|
|
175
|
-
*/
|
|
176
|
-
// @dynamic
|
|
177
|
-
class AXDateTime {
|
|
178
|
-
constructor(value = new Date(), calendar = AXConfig.get('dateTime.type') || 'gregorian') {
|
|
179
|
-
this._calendar =
|
|
180
|
-
typeof calendar == 'string'
|
|
181
|
-
? eval(`new ${AX_CALENDARS.find((c) => c.name == calendar).type}()`)
|
|
182
|
-
: calendar;
|
|
183
|
-
if (value instanceof Date) {
|
|
184
|
-
this._date = value;
|
|
185
|
-
}
|
|
186
|
-
else {
|
|
187
|
-
this._date = new Date(value);
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
static convert(value, calendar = AXConfig.get('dateTime.type') || 'gregorian') {
|
|
191
|
-
let date;
|
|
192
|
-
if (typeof value === 'string' || value instanceof String) {
|
|
193
|
-
date = new AXDateTime(value, calendar);
|
|
194
|
-
}
|
|
195
|
-
else if (value instanceof Date) {
|
|
196
|
-
date = new AXDateTime(value, calendar);
|
|
197
|
-
}
|
|
198
|
-
else if (value instanceof AXDateTime) {
|
|
199
|
-
date = new AXDateTime(value.date, calendar);
|
|
200
|
-
}
|
|
201
|
-
return date;
|
|
202
|
-
}
|
|
203
|
-
/**
|
|
204
|
-
* This comment _supports_ [Markdown](https://marked.js.org/)
|
|
205
|
-
*/
|
|
206
|
-
get date() {
|
|
207
|
-
return this._date;
|
|
208
|
-
}
|
|
209
|
-
get calendar() {
|
|
210
|
-
return this._calendar;
|
|
211
|
-
}
|
|
212
|
-
clone() {
|
|
213
|
-
return new AXDateTime(this.date, this.calendar.name());
|
|
214
|
-
}
|
|
215
|
-
get dayInMonth() {
|
|
216
|
-
return this._calendar.dayInMonth(this.date);
|
|
217
|
-
}
|
|
218
|
-
get dayOfYear() {
|
|
219
|
-
return this._calendar.dayOfYear(this.date);
|
|
220
|
-
}
|
|
221
|
-
get dayInWeek() {
|
|
222
|
-
return this._calendar.dayInWeek(this.date);
|
|
223
|
-
}
|
|
224
|
-
get hour() {
|
|
225
|
-
return this._date.getHours();
|
|
226
|
-
}
|
|
227
|
-
get minute() {
|
|
228
|
-
return this._date.getMinutes();
|
|
229
|
-
}
|
|
230
|
-
get second() {
|
|
231
|
-
return this._date.getSeconds();
|
|
232
|
-
}
|
|
233
|
-
get year() {
|
|
234
|
-
return this._calendar.year(this.date);
|
|
235
|
-
}
|
|
236
|
-
get monthOfYear() {
|
|
237
|
-
return this._calendar.monthOfYear(this.date);
|
|
238
|
-
}
|
|
239
|
-
get month() {
|
|
240
|
-
return new AXCalendarMonth(this);
|
|
241
|
-
}
|
|
242
|
-
add(unit, amount) {
|
|
243
|
-
return this._calendar.add(this.date, unit, amount);
|
|
244
|
-
}
|
|
245
|
-
set(unit = 'day', value) {
|
|
246
|
-
return this._calendar.set(this.date, unit, value);
|
|
247
|
-
}
|
|
248
|
-
duration(end, unit = 'day') {
|
|
249
|
-
const range = new AXDateTimeRange(this, AXDateTime.convert(end, this.calendar.name()));
|
|
250
|
-
return range.duration();
|
|
251
|
-
}
|
|
252
|
-
startOf(unit = 'day') {
|
|
253
|
-
return this._calendar.startOf(this.date, unit);
|
|
254
|
-
}
|
|
255
|
-
endOf(unit = 'day') {
|
|
256
|
-
return this._calendar.endOf(this.date, unit);
|
|
257
|
-
}
|
|
258
|
-
format(format = AXConfig.get('dateTime.shortDateFormat') ||
|
|
259
|
-
'DDD, dd MMM yyyy') {
|
|
260
|
-
format = format.replace('ss', this.pad(this.date.getSeconds(), 2));
|
|
261
|
-
format = format.replace('s', this.date.getSeconds().toString());
|
|
262
|
-
format = format.replace('dd', this.pad(this.calendar.dayInMonth(this.date), 2));
|
|
263
|
-
format = format.replace('d', this.calendar.dayInMonth(this.date).toString());
|
|
264
|
-
format = format.replace('mm', this.pad(this.date.getMinutes(), 2));
|
|
265
|
-
format = format.replace('m', this.date.getMinutes().toString());
|
|
266
|
-
format = format.replace('MMMM', this.calendar.monthNames[this.calendar.monthOfYear(this.date) - 1]);
|
|
267
|
-
format = format.replace('MMM', this.calendar.monthShortNames[this.calendar.monthOfYear(this.date) - 1]);
|
|
268
|
-
format = format.replace('MM', this.pad(this.calendar.monthOfYear(this.date), 2));
|
|
269
|
-
format = format.replace(/M(?![ao])/, this.calendar.monthOfYear(this.date).toString());
|
|
270
|
-
format = format.replace('DDDD', this.calendar.dayNames[this.calendar.dayInWeek(this.date) - 1]);
|
|
271
|
-
format = format.replace('DDD', this.calendar.dayShortNames[this.calendar.dayInWeek(this.date) - 1]);
|
|
272
|
-
format = format.replace(/D(?!e)/, this.calendar.dayNames[this.calendar.dayInWeek(this.date) - 1].substring(0, 3));
|
|
273
|
-
format = format.replace('yyyy', this.calendar.year(this.date).toString());
|
|
274
|
-
format = format.replace('YYYY', this.calendar.year(this.date).toString());
|
|
275
|
-
format = format.replace('yy', this.calendar.year(this.date).toString().substring(2));
|
|
276
|
-
format = format.replace('YY', this.calendar.year(this.date).toString().substring(2));
|
|
277
|
-
format = format.replace('HH', this.pad(this.date.getHours(), 2));
|
|
278
|
-
format = format.replace('H', this.date.getHours().toString());
|
|
279
|
-
return format;
|
|
280
|
-
}
|
|
281
|
-
pad(n, width, z = '0') {
|
|
282
|
-
n = n + '';
|
|
283
|
-
return n.length >= width ? n : new Array(width - n.length + 1).join(z) + n;
|
|
284
|
-
}
|
|
285
|
-
toString() {
|
|
286
|
-
return this.format();
|
|
287
|
-
}
|
|
288
|
-
equal(value, unit = 'day') {
|
|
289
|
-
return this.compaire(value, unit) == 0;
|
|
290
|
-
}
|
|
291
|
-
compaire(value, unit = 'day') {
|
|
292
|
-
// TODO:
|
|
293
|
-
const val = AXDateTime.convert(value);
|
|
294
|
-
if (this.date == val.date) {
|
|
295
|
-
return 0;
|
|
296
|
-
}
|
|
297
|
-
else if (this.date > val.date) {
|
|
298
|
-
return 1;
|
|
299
|
-
}
|
|
300
|
-
else {
|
|
301
|
-
return -1;
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
convert(calendar) {
|
|
305
|
-
return AXDateTime.convert(this, calendar);
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
class AXCalendarMonth {
|
|
309
|
-
constructor(date) {
|
|
310
|
-
this.index = date.date.getMonth();
|
|
311
|
-
this.name = date.format('MMMM');
|
|
312
|
-
this.range = new AXDateTimeRange(new AXDateTime(date.startOf('month').date, date.calendar), new AXDateTime(date.endOf('month').date, date.calendar));
|
|
313
|
-
}
|
|
314
|
-
get range() {
|
|
315
|
-
return this._range;
|
|
316
|
-
}
|
|
317
|
-
set range(v) {
|
|
318
|
-
this._range = v;
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
class AXDateTimeRange {
|
|
322
|
-
constructor(startTime, endTime) {
|
|
323
|
-
this.startTime = startTime;
|
|
324
|
-
this.endTime = endTime;
|
|
325
|
-
}
|
|
326
|
-
duration() {
|
|
327
|
-
const result = {
|
|
328
|
-
miliseconds: 0,
|
|
329
|
-
seconds: 0,
|
|
330
|
-
minutes: 0,
|
|
331
|
-
hours: 0,
|
|
332
|
-
days: 0,
|
|
333
|
-
months: 0,
|
|
334
|
-
years: 0,
|
|
335
|
-
total: {
|
|
336
|
-
miliseconds: 0,
|
|
337
|
-
seconds: 0,
|
|
338
|
-
minutes: 0,
|
|
339
|
-
hours: 0,
|
|
340
|
-
days: 0,
|
|
341
|
-
weeks: 0,
|
|
342
|
-
months: 0,
|
|
343
|
-
years: 0,
|
|
344
|
-
},
|
|
345
|
-
};
|
|
346
|
-
const one_second = 1000;
|
|
347
|
-
const one_min = one_second * 60;
|
|
348
|
-
const one_hour = one_min * 60;
|
|
349
|
-
const one_day = one_hour * 24;
|
|
350
|
-
const one_week = one_day * 7;
|
|
351
|
-
const one_year = 365.25 * one_day;
|
|
352
|
-
const one_month = one_year / 12;
|
|
353
|
-
const startTime = this.startTime.date.getTime();
|
|
354
|
-
const endTime = this.endTime.date.getTime();
|
|
355
|
-
const diff = Math.abs(endTime - startTime);
|
|
356
|
-
//
|
|
357
|
-
result.total.miliseconds = diff;
|
|
358
|
-
result.total.seconds = Number((diff / one_second).toFixed(2));
|
|
359
|
-
result.total.minutes = Number((diff / one_min).toFixed(2));
|
|
360
|
-
result.total.hours = Number((diff / one_hour).toFixed(2));
|
|
361
|
-
result.total.days = Number((diff / one_day).toFixed(2));
|
|
362
|
-
result.total.weeks = Number((diff / one_week).toFixed(2));
|
|
363
|
-
//
|
|
364
|
-
// let months = (this.endTime.year - this.startTime.year) * 12;
|
|
365
|
-
// months += this.endTime.monthOfYear - this.startTime.monthOfYear + 1;
|
|
366
|
-
// if (this.endTime.dayOfYear < this.startTime.dayOfYear) {
|
|
367
|
-
// months--;
|
|
368
|
-
// }
|
|
369
|
-
// result.total.months = Math.abs(months);
|
|
370
|
-
// TODO: review
|
|
371
|
-
result.total.months = Number((diff / one_month).toFixed(2));
|
|
372
|
-
result.total.years = Number((diff / one_year).toFixed(2));
|
|
373
|
-
//
|
|
374
|
-
result.miliseconds = result.total.miliseconds % 1000;
|
|
375
|
-
result.seconds = Number((result.total.seconds % 60).toFixed(0));
|
|
376
|
-
result.minutes = Number((result.total.minutes % 60).toFixed(0));
|
|
377
|
-
result.hours = Number((result.total.hours % 24).toFixed(0));
|
|
378
|
-
// TODO: review
|
|
379
|
-
result.days = Number((result.total.days % 30.4).toFixed(0));
|
|
380
|
-
result.months = Number((result.total.months % 12).toFixed(0));
|
|
381
|
-
result.years = Number(result.total.years.toFixed(0));
|
|
382
|
-
return result;
|
|
383
|
-
}
|
|
384
|
-
enumurate(unit = 'day') {
|
|
385
|
-
// TODO: ??
|
|
386
|
-
return [];
|
|
387
|
-
}
|
|
388
|
-
includes(value, unit = 'day') {
|
|
389
|
-
// TODO: ??
|
|
390
|
-
return true;
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
class AXDateTimePipe {
|
|
395
|
-
constructor() { }
|
|
396
|
-
transform(value, format, calendar) {
|
|
397
|
-
if (value == null) {
|
|
398
|
-
return '';
|
|
399
|
-
}
|
|
400
|
-
const date = value instanceof AXDateTime ? value.clone() : AXDateTime.convert(value, calendar);
|
|
401
|
-
if (!format) {
|
|
402
|
-
return date.toString();
|
|
403
|
-
}
|
|
404
|
-
else {
|
|
405
|
-
return date.format(format);
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
AXDateTimePipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0, type: AXDateTimePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
410
|
-
AXDateTimePipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0, type: AXDateTimePipe, name: "axDate" });
|
|
411
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0, type: AXDateTimePipe, decorators: [{
|
|
412
|
-
type: Pipe,
|
|
413
|
-
args: [{ name: 'axDate' }]
|
|
414
|
-
}], ctorParameters: function () { return []; } });
|
|
415
|
-
|
|
416
|
-
class AXDateTimeModule {
|
|
417
|
-
}
|
|
418
|
-
AXDateTimeModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0, type: AXDateTimeModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
419
|
-
AXDateTimeModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0, type: AXDateTimeModule, declarations: [AXDateTimePipe], exports: [AXDateTimePipe] });
|
|
420
|
-
AXDateTimeModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0, type: AXDateTimeModule, providers: [], imports: [[]] });
|
|
421
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0, type: AXDateTimeModule, decorators: [{
|
|
422
|
-
type: NgModule,
|
|
423
|
-
args: [{
|
|
424
|
-
imports: [],
|
|
425
|
-
exports: [AXDateTimePipe],
|
|
426
|
-
declarations: [AXDateTimePipe],
|
|
427
|
-
providers: [],
|
|
428
|
-
}]
|
|
429
|
-
}] });
|
|
430
|
-
|
|
431
|
-
class GeorgianCalendar {
|
|
432
|
-
constructor() {
|
|
433
|
-
this.monthNames = [
|
|
434
|
-
"January", "February", "March",
|
|
435
|
-
"April", "May", "June", "July",
|
|
436
|
-
"August", "September", "October",
|
|
437
|
-
"November", "December"
|
|
438
|
-
];
|
|
439
|
-
this.monthShortNames = [
|
|
440
|
-
"Jan", "Feb", "Mar",
|
|
441
|
-
"Apr", "May", "Jun", "Jul",
|
|
442
|
-
"Aug", "Sep", "Oct",
|
|
443
|
-
"Nov", "Dec"
|
|
444
|
-
];
|
|
445
|
-
this.dayNames = [
|
|
446
|
-
"Sunday", "Monday", "Tuesday", "Wednesday",
|
|
447
|
-
"Thursday", "Friday", "Saturday"
|
|
448
|
-
];
|
|
449
|
-
this.dayShortNames = [
|
|
450
|
-
"Sun", "Mon", "Tue", "Wed",
|
|
451
|
-
"Thu", "Fri", "Sat"
|
|
452
|
-
];
|
|
453
|
-
}
|
|
454
|
-
name() {
|
|
455
|
-
return 'gregorian';
|
|
456
|
-
}
|
|
457
|
-
dayInMonth(date) {
|
|
458
|
-
return date.getDate();
|
|
459
|
-
}
|
|
460
|
-
dayOfYear(date) {
|
|
461
|
-
const start = +new Date(date.getFullYear(), 0, 0);
|
|
462
|
-
const diff = +date - start;
|
|
463
|
-
const oneDay = 1000 * 60 * 60 * 24;
|
|
464
|
-
return Math.floor(diff / oneDay);
|
|
465
|
-
}
|
|
466
|
-
dayInWeek(date) {
|
|
467
|
-
return date.getDay() + 1;
|
|
468
|
-
}
|
|
469
|
-
year(date) {
|
|
470
|
-
return date.getFullYear();
|
|
471
|
-
}
|
|
472
|
-
monthOfYear(date) {
|
|
473
|
-
return date.getMonth() + 1;
|
|
474
|
-
}
|
|
475
|
-
add(date, unit, amount) {
|
|
476
|
-
let value = date.valueOf();
|
|
477
|
-
switch (unit) {
|
|
478
|
-
case 'second':
|
|
479
|
-
value += 1000 * amount;
|
|
480
|
-
break;
|
|
481
|
-
case 'minute':
|
|
482
|
-
value += 60000 * amount;
|
|
483
|
-
break;
|
|
484
|
-
case 'hour':
|
|
485
|
-
value += 3600000 * amount;
|
|
486
|
-
break;
|
|
487
|
-
case 'month':
|
|
488
|
-
const v = new Date(value);
|
|
489
|
-
var mo = date.getMonth();
|
|
490
|
-
var yr = date.getFullYear();
|
|
491
|
-
mo = (mo + amount) % 12;
|
|
492
|
-
if (0 > mo) {
|
|
493
|
-
yr += (date.getMonth() + amount - mo - 12) / 12;
|
|
494
|
-
mo += 12;
|
|
495
|
-
}
|
|
496
|
-
else
|
|
497
|
-
yr += ((date.getMonth() + amount - mo) / 12);
|
|
498
|
-
v.setMonth(mo);
|
|
499
|
-
v.setFullYear(yr);
|
|
500
|
-
value = v.valueOf();
|
|
501
|
-
break;
|
|
502
|
-
case 'week':
|
|
503
|
-
value += 7 * 86400000 * amount;
|
|
504
|
-
break;
|
|
505
|
-
case 'year':
|
|
506
|
-
const yv = new Date(value);
|
|
507
|
-
yv.setFullYear(yv.getFullYear() + amount);
|
|
508
|
-
value = v.valueOf();
|
|
509
|
-
break;
|
|
510
|
-
case 'day':
|
|
511
|
-
default:
|
|
512
|
-
value += 86400000 * amount;
|
|
513
|
-
}
|
|
514
|
-
return new AXDateTime(new Date(value), this.name());
|
|
515
|
-
}
|
|
516
|
-
set(date, unit, value) {
|
|
517
|
-
throw new Error("Method not implemented.");
|
|
518
|
-
}
|
|
519
|
-
startOf(date, unit) {
|
|
520
|
-
const clone = new Date(date.valueOf());
|
|
521
|
-
switch (unit) {
|
|
522
|
-
case 'second':
|
|
523
|
-
clone.setHours(clone.getHours(), clone.getMinutes(), clone.getSeconds(), 0);
|
|
524
|
-
return new AXDateTime(clone, this.name());
|
|
525
|
-
case 'minute':
|
|
526
|
-
clone.setHours(clone.getHours(), clone.getMinutes(), 0, 0);
|
|
527
|
-
return new AXDateTime(clone, this.name());
|
|
528
|
-
case 'hour':
|
|
529
|
-
clone.setHours(clone.getHours(), 0, 0, 0);
|
|
530
|
-
return new AXDateTime(clone, this.name());
|
|
531
|
-
default:
|
|
532
|
-
case 'day':
|
|
533
|
-
clone.setHours(0, 0, 0, 0);
|
|
534
|
-
return new AXDateTime(clone, this.name());
|
|
535
|
-
case "week":
|
|
536
|
-
const diff = clone.getDate() - clone.getDay() + (clone.getDay() === 0 ? -6 : 1);
|
|
537
|
-
clone.setDate(diff);
|
|
538
|
-
return new AXDateTime(clone, this.name()).startOf('day');
|
|
539
|
-
case "month":
|
|
540
|
-
clone.setDate(1);
|
|
541
|
-
return new AXDateTime(clone, this.name()).startOf('day');
|
|
542
|
-
case "year":
|
|
543
|
-
clone.setMonth(0);
|
|
544
|
-
clone.setDate(1);
|
|
545
|
-
return new AXDateTime(clone, this.name()).startOf('day');
|
|
546
|
-
}
|
|
547
|
-
}
|
|
548
|
-
endOf(date, unit) {
|
|
549
|
-
const clone = new Date(date.valueOf());
|
|
550
|
-
switch (unit) {
|
|
551
|
-
case 'second':
|
|
552
|
-
clone.setHours(clone.getHours(), clone.getMinutes(), clone.getSeconds(), 999);
|
|
553
|
-
return new AXDateTime(clone, this.name());
|
|
554
|
-
case 'minute':
|
|
555
|
-
clone.setHours(clone.getHours(), clone.getMinutes(), 59, 999);
|
|
556
|
-
return new AXDateTime(clone, this.name());
|
|
557
|
-
case 'hour':
|
|
558
|
-
clone.setHours(clone.getHours(), 59, 59, 999);
|
|
559
|
-
return new AXDateTime(clone, this.name());
|
|
560
|
-
default:
|
|
561
|
-
case 'day':
|
|
562
|
-
clone.setHours(23, 59, 59, 999);
|
|
563
|
-
return new AXDateTime(clone, this.name());
|
|
564
|
-
case 'week':
|
|
565
|
-
return this.startOf(date, 'week').add('day', 6).endOf('day');
|
|
566
|
-
case 'month':
|
|
567
|
-
return new AXDateTime(new Date(date.getFullYear(), date.getMonth() + 1, 0), this.name()).endOf('day');
|
|
568
|
-
case "year":
|
|
569
|
-
clone.setMonth(11);
|
|
570
|
-
return new AXDateTime(clone, this.name()).endOf('month');
|
|
571
|
-
}
|
|
572
|
-
}
|
|
573
|
-
}
|
|
574
|
-
|
|
575
|
-
// @dynamic
|
|
576
|
-
class AXTranslator {
|
|
577
|
-
static get onChange() {
|
|
578
|
-
return AXTranslator.dataChangeSubject.asObservable();
|
|
579
|
-
}
|
|
580
|
-
static load(lang, value) {
|
|
581
|
-
if (typeof value === 'object') {
|
|
582
|
-
if (!AXTranslator[`__data__${lang}`]) {
|
|
583
|
-
AXTranslator[`__data__${lang}`] = {};
|
|
584
|
-
}
|
|
585
|
-
AXTranslator[`__data__${lang}`] = merge(AXTranslator[`__data__${lang}`], value);
|
|
586
|
-
}
|
|
587
|
-
}
|
|
588
|
-
static use(lang) {
|
|
589
|
-
AXTranslator.lang = lang;
|
|
590
|
-
}
|
|
591
|
-
static get(key, lang) {
|
|
592
|
-
return AXObjectUtil.getPropByPath(AXTranslator[`__data__${lang || AXTranslator.lang}`], key) || key;
|
|
593
|
-
}
|
|
594
|
-
}
|
|
595
|
-
AXTranslator.lang = 'en';
|
|
596
|
-
AXTranslator.dataChangeSubject = new Subject();
|
|
597
|
-
|
|
598
|
-
class AXTranslatorPipe {
|
|
599
|
-
transform(value, lang) {
|
|
600
|
-
return AXTranslator.get(value, lang);
|
|
601
|
-
}
|
|
602
|
-
}
|
|
603
|
-
AXTranslatorPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0, type: AXTranslatorPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
604
|
-
AXTranslatorPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0, type: AXTranslatorPipe, name: "trans" });
|
|
605
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0, type: AXTranslatorPipe, decorators: [{
|
|
606
|
-
type: Pipe,
|
|
607
|
-
args: [{ name: 'trans', pure: true }]
|
|
608
|
-
}] });
|
|
609
|
-
|
|
610
|
-
class AXTranslationModule {
|
|
611
|
-
}
|
|
612
|
-
AXTranslationModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0, type: AXTranslationModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
613
|
-
AXTranslationModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0, type: AXTranslationModule, declarations: [AXTranslatorPipe], exports: [AXTranslatorPipe] });
|
|
614
|
-
AXTranslationModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0, type: AXTranslationModule, providers: [], imports: [[]] });
|
|
615
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0, type: AXTranslationModule, decorators: [{
|
|
616
|
-
type: NgModule,
|
|
617
|
-
args: [{
|
|
618
|
-
imports: [],
|
|
619
|
-
exports: [AXTranslatorPipe],
|
|
620
|
-
declarations: [AXTranslatorPipe],
|
|
621
|
-
providers: [],
|
|
622
|
-
}]
|
|
623
|
-
}] });
|
|
624
|
-
|
|
625
|
-
const isChrome = (win) => testUserAgent(win, /Chrome/i);
|
|
626
|
-
const isFirefox = (win) => testUserAgent(win, /Firefox/i);
|
|
627
|
-
const isEdge = (win) => testUserAgent(win, /Edge/i);
|
|
628
|
-
const isSafari = (win) => testUserAgent(win, /Safari/i);
|
|
629
|
-
const isOpera = (win) => testUserAgent(win, /Opera/i) || testUserAgent(win, /OPR/i);
|
|
630
|
-
const isMSIE = (win) => testUserAgent(win, /MSIE/i) || testUserAgent(win, /Trident/i);
|
|
631
|
-
const isMobileWeb = (win) => isMobile(win) && !isHybrid(win);
|
|
632
|
-
const isIpad = (win) => {
|
|
633
|
-
// iOS 12 and below
|
|
634
|
-
if (testUserAgent(win, /iPad/i)) {
|
|
635
|
-
return true;
|
|
636
|
-
}
|
|
637
|
-
// iOS 13+
|
|
638
|
-
if (testUserAgent(win, /Macintosh/i) && isMobile(win)) {
|
|
639
|
-
return true;
|
|
640
|
-
}
|
|
641
|
-
return false;
|
|
642
|
-
};
|
|
643
|
-
const isIphone = (win) => testUserAgent(win, /iPhone/i);
|
|
644
|
-
const isIOS = (win) => testUserAgent(win, /iPhone|iPod/i) || isIpad(win);
|
|
645
|
-
const isAndroid = (win) => testUserAgent(win, /android|sink/i);
|
|
646
|
-
const isAndroidTablet = (win) => {
|
|
647
|
-
return isAndroid(win) && !testUserAgent(win, /mobile/i);
|
|
648
|
-
};
|
|
649
|
-
const isPhablet = (win) => {
|
|
650
|
-
const width = win.innerWidth;
|
|
651
|
-
const height = win.innerHeight;
|
|
652
|
-
const smallest = Math.min(width, height);
|
|
653
|
-
const largest = Math.max(width, height);
|
|
654
|
-
return (smallest > 390 && smallest < 520) &&
|
|
655
|
-
(largest > 620 && largest < 800);
|
|
656
|
-
};
|
|
657
|
-
const isTablet = (win) => {
|
|
658
|
-
const width = win.innerWidth;
|
|
659
|
-
const height = win.innerHeight;
|
|
660
|
-
const smallest = Math.min(width, height);
|
|
661
|
-
const largest = Math.max(width, height);
|
|
662
|
-
return (isIpad(win) ||
|
|
663
|
-
isAndroidTablet(win) ||
|
|
664
|
-
((smallest > 460 && smallest < 820) &&
|
|
665
|
-
(largest > 780 && largest < 1400)));
|
|
666
|
-
};
|
|
667
|
-
const isMobile = (win) => matchMedia(win, '(any-pointer:coarse)');
|
|
668
|
-
const isDesktop = (win) => !isMobile(win);
|
|
669
|
-
const isHybrid = (win) => isCordova(win) || isCapacitorNative(win);
|
|
670
|
-
const isCordova = (win) => !!(win['cordova'] || win['phonegap'] || win['PhoneGap']);
|
|
671
|
-
const isCapacitorNative = (win) => {
|
|
672
|
-
const capacitor = win['Capacitor'];
|
|
673
|
-
return !!(capacitor && capacitor.isNative);
|
|
674
|
-
};
|
|
675
|
-
const isElectron = (win) => testUserAgent(win, /electron/i);
|
|
676
|
-
const isPWA = (win) => !!(win.matchMedia('(display-mode: standalone)').matches || win.navigator.standalone);
|
|
677
|
-
const testUserAgent = (win, expr) => expr.test(win.navigator.userAgent);
|
|
678
|
-
const matchMedia = (win, query) => win.matchMedia(query).matches;
|
|
679
|
-
const PLATFORMS_MAP = {
|
|
680
|
-
'Android': isAndroid,
|
|
681
|
-
'iOS': isIOS,
|
|
682
|
-
'Desktop': isDesktop,
|
|
683
|
-
'Mobile': isMobile,
|
|
684
|
-
'Chrome': isChrome,
|
|
685
|
-
'Firefox': isFirefox,
|
|
686
|
-
'Safari': isSafari,
|
|
687
|
-
'Edge': isEdge,
|
|
688
|
-
'Opera': isOpera,
|
|
689
|
-
'Hybrid': isHybrid,
|
|
690
|
-
'PWA': isPWA,
|
|
691
|
-
'Electron': isElectron,
|
|
692
|
-
};
|
|
693
|
-
class AXPlatformEvent {
|
|
694
|
-
}
|
|
695
|
-
class AXPlatform {
|
|
696
|
-
constructor() {
|
|
697
|
-
this.resize = new Subject();
|
|
698
|
-
this.click = new Subject();
|
|
699
|
-
this.scroll = new Subject();
|
|
700
|
-
window.addEventListener('resize', (e) => {
|
|
701
|
-
this.resize.next({
|
|
702
|
-
nativeEvent: e,
|
|
703
|
-
source: this
|
|
704
|
-
});
|
|
705
|
-
});
|
|
706
|
-
document.addEventListener('click', (e) => {
|
|
707
|
-
this.click.next({
|
|
708
|
-
nativeEvent: e,
|
|
709
|
-
source: this
|
|
710
|
-
});
|
|
711
|
-
}, true);
|
|
712
|
-
document.addEventListener('scroll', (e) => {
|
|
713
|
-
this.scroll.next({
|
|
714
|
-
nativeEvent: e,
|
|
715
|
-
source: this
|
|
716
|
-
});
|
|
717
|
-
}, true);
|
|
718
|
-
}
|
|
719
|
-
isRtl() {
|
|
720
|
-
return document.dir == 'rtl' || document.body.dir == 'rtl' || document.body.style.direction == 'rtl';
|
|
721
|
-
}
|
|
722
|
-
isLandscape() {
|
|
723
|
-
return window.innerHeight < window.innerWidth;
|
|
724
|
-
}
|
|
725
|
-
isPortrate() {
|
|
726
|
-
return !this.isLandscape();
|
|
727
|
-
}
|
|
728
|
-
is(name) {
|
|
729
|
-
return PLATFORMS_MAP[name](window) || false;
|
|
730
|
-
}
|
|
731
|
-
}
|
|
732
|
-
AXPlatform.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0, type: AXPlatform, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
733
|
-
AXPlatform.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0, type: AXPlatform, providedIn: 'platform' });
|
|
734
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0, type: AXPlatform, decorators: [{
|
|
735
|
-
type: Injectable,
|
|
736
|
-
args: [{
|
|
737
|
-
providedIn: 'platform',
|
|
738
|
-
}]
|
|
739
|
-
}], ctorParameters: function () { return []; } });
|
|
740
|
-
|
|
741
|
-
/**
|
|
742
|
-
* Public API refrences of core libraries
|
|
743
|
-
* @module @acorex/core
|
|
744
|
-
*/
|
|
745
|
-
|
|
746
|
-
/**
|
|
747
|
-
* Generated bundle index. Do not edit.
|
|
748
|
-
*/
|
|
749
|
-
|
|
750
|
-
export { AXCalendarMonth, AXConfig, AXCoreModule, AXDateTime, AXDateTimeModule, AXDateTimePipe, AXDateTimeRange, AXObjectUtil, AXPlatform, AXPlatformEvent, AXSafePipe, AXTranslationModule, AXTranslator, AXTranslatorPipe, AX_CALENDARS, GeorgianCalendar, testUserAgent };
|
|
751
|
-
//# sourceMappingURL=acorex-core.js.map
|