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