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