@acorex/core 5.0.13 → 5.0.17

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 (32) hide show
  1. package/{esm2015/acorex-core.js → esm2020/acorex-core.mjs} +0 -0
  2. package/{esm2015/lib/config/configs.js → esm2020/lib/config/configs.mjs} +0 -0
  3. package/{esm2015/lib/core.module.js → esm2020/lib/core.module.mjs} +4 -4
  4. package/{esm2015/lib/dateTime/datetime.class.js → esm2020/lib/dateTime/datetime.class.mjs} +0 -0
  5. package/{esm2015/lib/dateTime/datetime.module.js → esm2020/lib/dateTime/datetime.module.mjs} +4 -4
  6. package/{esm2015/lib/dateTime/datetime.pipe.js → esm2020/lib/dateTime/datetime.pipe.mjs} +3 -3
  7. package/{esm2015/lib/dateTime/georgian.calendar.js → esm2020/lib/dateTime/georgian.calendar.mjs} +0 -0
  8. package/{esm2015/lib/dateTime/index.js → esm2020/lib/dateTime/index.mjs} +0 -0
  9. package/{esm2015/lib/dateTime/jalali.calendar.js → esm2020/lib/dateTime/jalali.calendar.mjs} +0 -0
  10. package/esm2020/lib/hotkeys/hotkeys.service.mjs +37 -0
  11. package/{esm2015/lib/hotkeys/index.js → esm2020/lib/hotkeys/index.mjs} +0 -0
  12. package/{esm2015/lib/platform/index.js → esm2020/lib/platform/index.mjs} +0 -0
  13. package/{esm2015/lib/platform/platform.service.js → esm2020/lib/platform/platform.service.mjs} +3 -3
  14. package/{esm2015/lib/translation/index.js → esm2020/lib/translation/index.mjs} +0 -0
  15. package/{esm2015/lib/translation/translation.module.js → esm2020/lib/translation/translation.module.mjs} +4 -4
  16. package/{esm2015/lib/translation/translator.js → esm2020/lib/translation/translator.mjs} +0 -0
  17. package/{esm2015/lib/translation/translator.pipe.js → esm2020/lib/translation/translator.pipe.mjs} +3 -3
  18. package/{esm2015/lib/utils/drawing-util.js → esm2020/lib/utils/drawing-util.mjs} +0 -0
  19. package/{esm2015/lib/utils/index.js → esm2020/lib/utils/index.mjs} +0 -0
  20. package/{esm2015/lib/utils/object-util.js → esm2020/lib/utils/object-util.mjs} +0 -0
  21. package/{esm2015/lib/utils/safe.pipe.js → esm2020/lib/utils/safe.pipe.mjs} +3 -3
  22. package/{esm2015/lib/utils/string-util.js → esm2020/lib/utils/string-util.mjs} +0 -0
  23. package/{esm2015/public-api.js → esm2020/public-api.mjs} +0 -0
  24. package/fesm2015/acorex-core.mjs +1221 -0
  25. package/fesm2015/acorex-core.mjs.map +1 -0
  26. package/{fesm2015/acorex-core.js → fesm2020/acorex-core.mjs} +29 -29
  27. package/fesm2020/acorex-core.mjs.map +1 -0
  28. package/package.json +25 -8
  29. package/bundles/acorex-core.umd.js +0 -1390
  30. package/bundles/acorex-core.umd.js.map +0 -1
  31. package/esm2015/lib/hotkeys/hotkeys.service.js +0 -37
  32. package/fesm2015/acorex-core.js.map +0 -1
@@ -1,1390 +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('@angular/common'), require('rxjs/internal/Observable'), require('lodash-es/merge')) :
3
- typeof define === 'function' && define.amd ? define('@acorex/core', ['exports', '@angular/core', '@angular/platform-browser', 'rxjs', '@angular/common', 'rxjs/internal/Observable', '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.ng.common, global.rxjs['internal/Observable'], global['lodash-es/merge']));
5
- }(this, (function (exports, i0, i1, rxjs, common, Observable, 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
- // @dynamic
121
- var AXDrawingUtil = /** @class */ (function () {
122
- function AXDrawingUtil() {
123
- }
124
- AXDrawingUtil.collision = function (a, b) {
125
- var ac = a.getBoundingClientRect();
126
- var bc = b.getBoundingClientRect();
127
- if (ac.left < bc.left + bc.width && ac.left + ac.width > bc.left &&
128
- ac.top < bc.top + bc.height && ac.top + ac.height > bc.top) {
129
- return true;
130
- }
131
- else {
132
- return false;
133
- }
134
- };
135
- AXDrawingUtil.isInElementBound = function (pos, element) {
136
- var elBound = element.getBoundingClientRect();
137
- return AXDrawingUtil.isInRecPoint(pos, {
138
- left: elBound.x,
139
- width: elBound.width,
140
- top: elBound.y,
141
- height: elBound.height
142
- });
143
- };
144
- AXDrawingUtil.isInRecPoint = function (pos, rec) {
145
- return pos.x >= rec.left && pos.x <= (rec.left + rec.width) && pos.y >= rec.top && (pos.y <= (rec.top + rec.height));
146
- };
147
- return AXDrawingUtil;
148
- }());
149
-
150
- // @dynamic
151
- var AXStringUtil = /** @class */ (function () {
152
- function AXStringUtil() {
153
- }
154
- AXStringUtil.getWordBoundsAtPosition = function (str, position) {
155
- var isSpace = function (c) { return /[^a-zA-Z0-9]+/i.exec(c); };
156
- var start = position - 1;
157
- var end = position;
158
- while (start >= 0 && !isSpace(str[start])) {
159
- start -= 1;
160
- }
161
- start = Math.max(0, start + 1);
162
- while (end < str.length && !isSpace(str[end])) {
163
- end += 1;
164
- }
165
- end = Math.max(start, end);
166
- return {
167
- start: start,
168
- end: end
169
- };
170
- };
171
- return AXStringUtil;
172
- }());
173
-
174
- var AXSafePipe = /** @class */ (function () {
175
- function AXSafePipe(sanitizer) {
176
- this.sanitizer = sanitizer;
177
- }
178
- AXSafePipe.prototype.transform = function (value, type) {
179
- if (value == null || value == undefined || value == '')
180
- return null;
181
- switch (type) {
182
- case 'html': return this.sanitizer.bypassSecurityTrustHtml(value);
183
- case 'style': return this.sanitizer.bypassSecurityTrustStyle(value);
184
- case 'script': return this.sanitizer.bypassSecurityTrustScript(value);
185
- case 'url': return this.sanitizer.bypassSecurityTrustUrl(value);
186
- case 'resourceUrl': return this.sanitizer.bypassSecurityTrustResourceUrl(value);
187
- default: throw new Error("Invalid safe type specified: " + type);
188
- }
189
- };
190
- return AXSafePipe;
191
- }());
192
- 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 });
193
- AXSafePipe.ɵpipe = i0__namespace.ɵɵngDeclarePipe({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0__namespace, type: AXSafePipe, name: "safe" });
194
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0__namespace, type: AXSafePipe, decorators: [{
195
- type: i0.Pipe,
196
- args: [{
197
- name: 'safe',
198
- pure: true
199
- }]
200
- }], ctorParameters: function () { return [{ type: i1__namespace.DomSanitizer }]; } });
201
-
202
- var AXCoreModule = /** @class */ (function () {
203
- function AXCoreModule() {
204
- }
205
- return AXCoreModule;
206
- }());
207
- AXCoreModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0__namespace, type: AXCoreModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
208
- AXCoreModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0__namespace, type: AXCoreModule, declarations: [AXSafePipe], exports: [AXSafePipe] });
209
- AXCoreModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0__namespace, type: AXCoreModule, providers: [], imports: [[]] });
210
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0__namespace, type: AXCoreModule, decorators: [{
211
- type: i0.NgModule,
212
- args: [{
213
- imports: [],
214
- exports: [AXSafePipe],
215
- declarations: [AXSafePipe],
216
- providers: [],
217
- }]
218
- }] });
219
-
220
- // @dynamic
221
- var AXConfig = /** @class */ (function () {
222
- function AXConfig() {
223
- }
224
- Object.defineProperty(AXConfig, "onChange", {
225
- get: function () {
226
- return AXConfig.dataChangeSubject.asObservable();
227
- },
228
- enumerable: false,
229
- configurable: true
230
- });
231
- AXConfig.set = function (arg1, arg2) {
232
- if (arg1 && typeof arg1 == 'string') {
233
- AXObjectUtil.setPropByPath(AXConfig.dataModel, arg1, arg2);
234
- AXConfig.dataChangeSubject.next(AXConfig.dataModel);
235
- return;
236
- }
237
- if (arg1 && typeof arg1 == 'object') {
238
- //TODO : fix override
239
- Object.assign(AXConfig.dataModel, arg1);
240
- AXConfig.dataChangeSubject.next(AXConfig.dataModel);
241
- return;
242
- }
243
- if (!arg1 && !arg2) {
244
- return AXConfig.dataChangeSubject.asObservable();
245
- }
246
- };
247
- AXConfig.get = function (path, defaultValue) {
248
- return AXObjectUtil.getPropByPath(AXConfig.dataModel, path) || defaultValue;
249
- };
250
- return AXConfig;
251
- }());
252
- AXConfig.dataModel = {};
253
- AXConfig.dataChangeSubject = new rxjs.Subject();
254
-
255
- // @dynamic
256
- var AXDateTime = /** @class */ (function () {
257
- function AXDateTime(value, calendar) {
258
- if (value === void 0) { value = new Date(); }
259
- if (calendar === void 0) { calendar = AXConfig.get('dateTime.type') || 'gregorian'; }
260
- this._calendar =
261
- // typeof calendar == 'string'
262
- // ? eval(`new ${AX_CALENDARS.find((c) => c.name == calendar).type}()`)
263
- // : calendar;
264
- typeof calendar == 'string'
265
- ? AXConfig.get("dateTime.calendars." + calendar)
266
- : calendar;
267
- if (value instanceof Date) {
268
- this._date = value;
269
- }
270
- else {
271
- this._date = new Date(value);
272
- }
273
- }
274
- AXDateTime.convert = function (value, calendar) {
275
- if (calendar === void 0) { calendar = AXConfig.get('dateTime.type') || 'gregorian'; }
276
- var date;
277
- if (typeof value === 'string' || value instanceof String) {
278
- date = new AXDateTime(value, calendar);
279
- }
280
- else if (value instanceof Date) {
281
- date = new AXDateTime(value, calendar);
282
- }
283
- else if (value instanceof AXDateTime) {
284
- date = new AXDateTime(value.date, calendar);
285
- }
286
- return date;
287
- };
288
- Object.defineProperty(AXDateTime.prototype, "date", {
289
- get: function () {
290
- return this._date;
291
- },
292
- enumerable: false,
293
- configurable: true
294
- });
295
- Object.defineProperty(AXDateTime.prototype, "calendar", {
296
- get: function () {
297
- return this._calendar;
298
- },
299
- enumerable: false,
300
- configurable: true
301
- });
302
- AXDateTime.prototype.clone = function () {
303
- return new AXDateTime(this.date, this.calendar.name());
304
- };
305
- Object.defineProperty(AXDateTime.prototype, "dayOfMonth", {
306
- get: function () {
307
- return this._calendar.dayOfMonth(this.date);
308
- },
309
- enumerable: false,
310
- configurable: true
311
- });
312
- Object.defineProperty(AXDateTime.prototype, "dayOfYear", {
313
- get: function () {
314
- return this._calendar.dayOfYear(this.date);
315
- },
316
- enumerable: false,
317
- configurable: true
318
- });
319
- Object.defineProperty(AXDateTime.prototype, "dayOfWeek", {
320
- get: function () {
321
- return this._calendar.dayOfWeek(this.date);
322
- },
323
- enumerable: false,
324
- configurable: true
325
- });
326
- Object.defineProperty(AXDateTime.prototype, "hour", {
327
- get: function () {
328
- return this._date.getHours();
329
- },
330
- enumerable: false,
331
- configurable: true
332
- });
333
- Object.defineProperty(AXDateTime.prototype, "minute", {
334
- get: function () {
335
- return this._date.getMinutes();
336
- },
337
- enumerable: false,
338
- configurable: true
339
- });
340
- Object.defineProperty(AXDateTime.prototype, "second", {
341
- get: function () {
342
- return this._date.getSeconds();
343
- },
344
- enumerable: false,
345
- configurable: true
346
- });
347
- Object.defineProperty(AXDateTime.prototype, "year", {
348
- get: function () {
349
- return this._calendar.year(this.date);
350
- },
351
- enumerable: false,
352
- configurable: true
353
- });
354
- Object.defineProperty(AXDateTime.prototype, "monthOfYear", {
355
- get: function () {
356
- return this._calendar.monthOfYear(this.date);
357
- },
358
- enumerable: false,
359
- configurable: true
360
- });
361
- Object.defineProperty(AXDateTime.prototype, "weekOfYear", {
362
- get: function () {
363
- return this._calendar.weekOfYear(this.date);
364
- },
365
- enumerable: false,
366
- configurable: true
367
- });
368
- Object.defineProperty(AXDateTime.prototype, "month", {
369
- get: function () {
370
- return new AXCalendarMonth(this);
371
- },
372
- enumerable: false,
373
- configurable: true
374
- });
375
- AXDateTime.prototype.add = function (unit, amount) {
376
- return this._calendar.add(this.date, unit, amount);
377
- };
378
- AXDateTime.prototype.set = function (unit, value) {
379
- if (unit === void 0) { unit = 'day'; }
380
- return this._calendar.set(this.date, unit, value);
381
- };
382
- AXDateTime.prototype.duration = function (end, unit) {
383
- if (unit === void 0) { unit = 'day'; }
384
- var range = new AXDateTimeRange(this, AXDateTime.convert(end, this.calendar.name()));
385
- return range.duration();
386
- };
387
- AXDateTime.prototype.startOf = function (unit) {
388
- if (unit === void 0) { unit = 'day'; }
389
- return this._calendar.startOf(this.date, unit);
390
- };
391
- AXDateTime.prototype.endOf = function (unit) {
392
- if (unit === void 0) { unit = 'day'; }
393
- return this._calendar.endOf(this.date, unit);
394
- };
395
- AXDateTime.prototype.format = function (format) {
396
- if (format === void 0) { format = AXConfig.get('dateTime.shortDateFormat') ||
397
- 'DDD, dd MMM yyyy'; }
398
- format = format.replace('ss', this.pad(this.date.getSeconds(), 2));
399
- format = format.replace('s', this.date.getSeconds().toString());
400
- format = format.replace('dd', this.pad(this.calendar.dayOfMonth(this.date), 2));
401
- format = format.replace('d', this.calendar.dayOfMonth(this.date).toString());
402
- format = format.replace('mm', this.pad(this.date.getMinutes(), 2));
403
- format = format.replace('m', this.date.getMinutes().toString());
404
- format = format.replace('MMMM', this.calendar.monthNames[this.calendar.monthOfYear(this.date) - 1]);
405
- format = format.replace('MMM', this.calendar.monthShortNames[this.calendar.monthOfYear(this.date) - 1]);
406
- format = format.replace('MM', this.pad(this.calendar.monthOfYear(this.date), 2));
407
- format = format.replace(/M(?![ao])/, this.calendar.monthOfYear(this.date).toString());
408
- format = format.replace('DDDD', this.calendar.dayNames[this.calendar.dayOfWeek(this.date) - 1]);
409
- format = format.replace('DDD', this.calendar.dayShortNames[this.calendar.dayOfWeek(this.date) - 1]);
410
- format = format.replace(/D(?!e)/, this.calendar.dayNames[this.calendar.dayOfWeek(this.date) - 1].substring(0, 3));
411
- format = format.replace('yyyy', this.calendar.year(this.date).toString());
412
- format = format.replace('YYYY', this.calendar.year(this.date).toString());
413
- format = format.replace('yy', this.calendar.year(this.date).toString().substring(2));
414
- format = format.replace('YY', this.calendar.year(this.date).toString().substring(2));
415
- format = format.replace('HH', this.pad(this.date.getHours(), 2));
416
- format = format.replace('H', this.date.getHours().toString());
417
- return format;
418
- };
419
- AXDateTime.prototype.pad = function (n, width, z) {
420
- if (z === void 0) { z = '0'; }
421
- n = n + '';
422
- return n.length >= width ? n : new Array(width - n.length + 1).join(z) + n;
423
- };
424
- AXDateTime.prototype.toString = function () {
425
- return this.format();
426
- };
427
- AXDateTime.prototype.equal = function (value, unit) {
428
- if (unit === void 0) { unit = 'day'; }
429
- return this.compare(value, unit) == 0;
430
- };
431
- AXDateTime.prototype.compare = function (value, unit) {
432
- if (unit === void 0) { unit = 'day'; }
433
- var val = AXDateTime.convert(value);
434
- var func = function (v1, v2) {
435
- if (v1 == v2) {
436
- return 0;
437
- }
438
- else if (v1 > v2) {
439
- return 1;
440
- }
441
- else {
442
- return -1;
443
- }
444
- };
445
- var p = 0;
446
- switch (unit) {
447
- case 'year':
448
- return func(this.year, val.year);
449
- case 'week':
450
- p = this.compare(val, 'year');
451
- return p == 0 ? func(this.weekOfYear, val.weekOfYear) : p;
452
- case 'month':
453
- p = this.compare(val, 'year');
454
- return p == 0 ? func(this.monthOfYear, val.monthOfYear) : p;
455
- case 'day':
456
- p = this.compare(val, 'year');
457
- return p == 0 ? func(this.dayOfYear, val.dayOfYear) : p;
458
- case 'hour':
459
- p = this.compare(val, 'day');
460
- return p == 0 ? func(this.hour, val.hour) : p;
461
- case 'minute':
462
- p = this.compare(val, 'hour');
463
- return p == 0 ? func(this.minute, val.minute) : p;
464
- case 'second':
465
- p = this.compare(val, 'minute');
466
- return p == 0 ? func(this.second, val.second) : p;
467
- default:
468
- return func(this.date.getTime(), val.date.getTime());
469
- }
470
- };
471
- AXDateTime.prototype.convert = function (calendar) {
472
- return AXDateTime.convert(this, calendar);
473
- };
474
- return AXDateTime;
475
- }());
476
- var AXCalendarMonth = /** @class */ (function () {
477
- function AXCalendarMonth(date) {
478
- this.index = date.date.getMonth();
479
- this.name = date.format('MMMM');
480
- this.range = new AXDateTimeRange(new AXDateTime(date.startOf('month').date, date.calendar), new AXDateTime(date.endOf('month').date, date.calendar));
481
- }
482
- Object.defineProperty(AXCalendarMonth.prototype, "range", {
483
- get: function () {
484
- return this._range;
485
- },
486
- set: function (v) {
487
- this._range = v;
488
- },
489
- enumerable: false,
490
- configurable: true
491
- });
492
- return AXCalendarMonth;
493
- }());
494
- var AXDateTimeRange = /** @class */ (function () {
495
- function AXDateTimeRange(startTime, endTime) {
496
- this._startTime = startTime;
497
- this._endTime = endTime;
498
- }
499
- Object.defineProperty(AXDateTimeRange.prototype, "startTime", {
500
- get: function () {
501
- return this._startTime;
502
- },
503
- enumerable: false,
504
- configurable: true
505
- });
506
- Object.defineProperty(AXDateTimeRange.prototype, "endTime", {
507
- get: function () {
508
- return this._endTime;
509
- },
510
- enumerable: false,
511
- configurable: true
512
- });
513
- AXDateTimeRange.prototype.duration = function () {
514
- var result = {
515
- miliseconds: 0,
516
- seconds: 0,
517
- minutes: 0,
518
- hours: 0,
519
- days: 0,
520
- months: 0,
521
- years: 0,
522
- total: {
523
- miliseconds: 0,
524
- seconds: 0,
525
- minutes: 0,
526
- hours: 0,
527
- days: 0,
528
- weeks: 0,
529
- months: 0,
530
- years: 0,
531
- },
532
- };
533
- var one_second = 1000;
534
- var one_min = one_second * 60;
535
- var one_hour = one_min * 60;
536
- var one_day = one_hour * 24;
537
- var one_week = one_day * 7;
538
- var one_year = 365.25 * one_day;
539
- var one_month = one_year / 12;
540
- var startTime = this._startTime.date.getTime();
541
- var endTime = this._endTime.date.getTime();
542
- var diff = Math.abs(endTime - startTime);
543
- //
544
- result.total.miliseconds = diff;
545
- result.total.seconds = Number((diff / one_second).toFixed(2));
546
- result.total.minutes = Number((diff / one_min).toFixed(2));
547
- result.total.hours = Number((diff / one_hour).toFixed(2));
548
- result.total.days = Number((diff / one_day).toFixed(2));
549
- result.total.weeks = Number((diff / one_week).toFixed(2));
550
- //
551
- // let months = (this.endTime.year - this.startTime.year) * 12;
552
- // months += this.endTime.monthOfYear - this.startTime.monthOfYear + 1;
553
- // if (this.endTime.dayOfYear < this.startTime.dayOfYear) {
554
- // months--;
555
- // }
556
- // result.total.months = Math.abs(months);
557
- // TODO: review
558
- result.total.months = Number((diff / one_month).toFixed(2));
559
- result.total.years = Number((diff / one_year).toFixed(2));
560
- //
561
- result.miliseconds = result.total.miliseconds % 1000;
562
- result.seconds = Number((result.total.seconds % 60).toFixed(0));
563
- result.minutes = Number((result.total.minutes % 60).toFixed(0));
564
- result.hours = Number((result.total.hours % 24).toFixed(0));
565
- // TODO: review
566
- result.days = Number((result.total.days % 30.4).toFixed(0));
567
- result.months = Number((result.total.months % 12).toFixed(0));
568
- result.years = Number(result.total.years.toFixed(0));
569
- return result;
570
- };
571
- AXDateTimeRange.prototype.enumurate = function (unit, amount) {
572
- if (unit === void 0) { unit = 'day'; }
573
- if (amount === void 0) { amount = 1; }
574
- // TODO: setptemper savingtime issue
575
- var result = [];
576
- var item = this._startTime.clone();
577
- while (item.compare(this._endTime, unit) < 1) {
578
- result.push(item);
579
- item = item.add(unit, amount);
580
- }
581
- return result;
582
- };
583
- AXDateTimeRange.prototype.includes = function (value, unit) {
584
- if (unit === void 0) { unit = 'day'; }
585
- // TODO: ??
586
- return true;
587
- };
588
- return AXDateTimeRange;
589
- }());
590
-
591
- var AXDateTimePipe = /** @class */ (function () {
592
- function AXDateTimePipe() {
593
- }
594
- AXDateTimePipe.prototype.transform = function (value, format, calendar) {
595
- if (value == null) {
596
- return '';
597
- }
598
- var date = value instanceof AXDateTime ? value.clone() : AXDateTime.convert(value, calendar);
599
- if (!format) {
600
- return date.toString();
601
- }
602
- else {
603
- return date.format(format);
604
- }
605
- };
606
- return AXDateTimePipe;
607
- }());
608
- AXDateTimePipe.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0__namespace, type: AXDateTimePipe, deps: [], target: i0__namespace.ɵɵFactoryTarget.Pipe });
609
- AXDateTimePipe.ɵpipe = i0__namespace.ɵɵngDeclarePipe({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0__namespace, type: AXDateTimePipe, name: "axDate" });
610
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0__namespace, type: AXDateTimePipe, decorators: [{
611
- type: i0.Pipe,
612
- args: [{ name: 'axDate' }]
613
- }], ctorParameters: function () { return []; } });
614
-
615
- var GeorgianCalendar = /** @class */ (function () {
616
- function GeorgianCalendar() {
617
- this.monthNames = [
618
- "January", "February", "March",
619
- "April", "May", "June", "July",
620
- "August", "September", "October",
621
- "November", "December"
622
- ];
623
- this.monthShortNames = [
624
- "Jan", "Feb", "Mar",
625
- "Apr", "May", "Jun", "Jul",
626
- "Aug", "Sep", "Oct",
627
- "Nov", "Dec"
628
- ];
629
- this.dayNames = [
630
- "Sunday", "Monday", "Tuesday", "Wednesday",
631
- "Thursday", "Friday", "Saturday"
632
- ];
633
- this.dayShortNames = [
634
- "Sun", "Mon", "Tue", "Wed",
635
- "Thu", "Fri", "Sat"
636
- ];
637
- }
638
- GeorgianCalendar.prototype.name = function () {
639
- return 'gregorian';
640
- };
641
- GeorgianCalendar.prototype.dayOfMonth = function (date) {
642
- return date.getDate();
643
- };
644
- GeorgianCalendar.prototype.dayOfYear = function (date) {
645
- var result = 0;
646
- var m = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
647
- if (this.isLeap(date)) {
648
- m[1] = 29;
649
- }
650
- for (var i = 0; i < date.getMonth(); i++) {
651
- result = result + m[i];
652
- }
653
- result += date.getDate();
654
- return result;
655
- };
656
- GeorgianCalendar.prototype.dayOfWeek = function (date) {
657
- return date.getDay() + 1;
658
- };
659
- GeorgianCalendar.prototype.weekOfYear = function (date) {
660
- var firstDay = new AXDateTime(date).startOf('year');
661
- return Math.ceil((((date.getTime() - firstDay.date.getTime()) / 86400000) + firstDay.date.getDay() + 1) / 7);
662
- };
663
- GeorgianCalendar.prototype.year = function (date) {
664
- return date.getFullYear();
665
- };
666
- GeorgianCalendar.prototype.monthOfYear = function (date) {
667
- return date.getMonth() + 1;
668
- };
669
- GeorgianCalendar.prototype.add = function (date, unit, amount) {
670
- var value = date.valueOf();
671
- switch (unit) {
672
- case 'second':
673
- value += 1000 * amount;
674
- break;
675
- case 'minute':
676
- value += 60000 * amount;
677
- break;
678
- case 'hour':
679
- value += 3600000 * amount;
680
- break;
681
- case 'month':
682
- var v = new Date(value);
683
- var mo = date.getMonth();
684
- var yr = date.getFullYear();
685
- mo = (mo + amount) % 12;
686
- if (0 > mo) {
687
- yr += (date.getMonth() + amount - mo - 12) / 12;
688
- mo += 12;
689
- }
690
- else
691
- yr += ((date.getMonth() + amount - mo) / 12);
692
- v.setMonth(mo);
693
- v.setFullYear(yr);
694
- value = v.valueOf();
695
- break;
696
- case 'week':
697
- value += 7 * 86400000 * amount;
698
- break;
699
- case 'year':
700
- var yv = new Date(value);
701
- yv.setFullYear(yv.getFullYear() + amount);
702
- value = yv.valueOf();
703
- break;
704
- case 'day':
705
- default:
706
- value += 86400000 * amount;
707
- }
708
- return new AXDateTime(new Date(value), this.name());
709
- };
710
- GeorgianCalendar.prototype.set = function (date, unit, value) {
711
- throw new Error("Method not implemented.");
712
- };
713
- GeorgianCalendar.prototype.startOf = function (date, unit) {
714
- var clone = new Date(date.valueOf());
715
- switch (unit) {
716
- case 'second':
717
- clone.setHours(clone.getHours(), clone.getMinutes(), clone.getSeconds(), 0);
718
- return new AXDateTime(clone, this.name());
719
- case 'minute':
720
- clone.setHours(clone.getHours(), clone.getMinutes(), 0, 0);
721
- return new AXDateTime(clone, this.name());
722
- case 'hour':
723
- clone.setHours(clone.getHours(), 0, 0, 0);
724
- return new AXDateTime(clone, this.name());
725
- default:
726
- case 'day':
727
- clone.setHours(0, 0, 0, 0);
728
- return new AXDateTime(clone, this.name());
729
- case "week":
730
- var index = 0;
731
- var start = index >= 0 ? index : 0;
732
- var day = clone.getDay();
733
- var diff = clone.getDate() - day + (start > day ? start - 7 : start);
734
- clone.setDate(diff);
735
- return new AXDateTime(clone, this.name()).startOf('day');
736
- case "month":
737
- clone.setDate(1);
738
- return new AXDateTime(clone, this.name()).startOf('day');
739
- case "year":
740
- clone.setMonth(0);
741
- clone.setDate(1);
742
- return new AXDateTime(clone, this.name()).startOf('day');
743
- }
744
- };
745
- GeorgianCalendar.prototype.endOf = function (date, unit) {
746
- var clone = new Date(date.valueOf());
747
- switch (unit) {
748
- case 'second':
749
- clone.setHours(clone.getHours(), clone.getMinutes(), clone.getSeconds(), 999);
750
- return new AXDateTime(clone, this.name());
751
- case 'minute':
752
- clone.setHours(clone.getHours(), clone.getMinutes(), 59, 999);
753
- return new AXDateTime(clone, this.name());
754
- case 'hour':
755
- clone.setHours(clone.getHours(), 59, 59, 999);
756
- return new AXDateTime(clone, this.name());
757
- default:
758
- case 'day':
759
- clone.setHours(23, 59, 59, 999);
760
- return new AXDateTime(clone, this.name());
761
- case 'week':
762
- return this.startOf(date, 'week').add('day', 6).endOf('day');
763
- case 'month':
764
- return new AXDateTime(new Date(date.getFullYear(), date.getMonth() + 1, 0), this.name()).endOf('day');
765
- case "year":
766
- clone.setMonth(11);
767
- return new AXDateTime(clone, this.name()).endOf('month');
768
- }
769
- };
770
- GeorgianCalendar.prototype.isLeap = function (date) {
771
- var leapYear = new Date(date.getFullYear(), 1, 29);
772
- return leapYear.getDate() == 29;
773
- };
774
- return GeorgianCalendar;
775
- }());
776
-
777
- var JalaliCalendar = /** @class */ (function () {
778
- function JalaliCalendar() {
779
- this.monthNames = ("فروردین_اردیبهشت_خرداد_تیر_مرداد_شهریور_مهر_آبان_آذر_دی_بهمن_اسفند").split("_");
780
- this.monthShortNames = ("فروردین_اردیبهشت_خرداد_تیر_مرداد_شهریور_مهر_آبان_آذر_دی_بهمن_اسفند").split("_");
781
- this.dayNames = ("شنبه_یکشنبه_دوشنبه_سه شنبه_چهارشنبه_پنج شنبه_جمعه").split("_");
782
- this.dayShortNames = "ش_ی_د_س_چ_پ_ج".split("_");
783
- }
784
- JalaliCalendar.prototype.name = function () {
785
- return 'jalali';
786
- };
787
- JalaliCalendar.prototype.dayOfMonth = function (date) {
788
- return this.toJalali(date).day;
789
- };
790
- JalaliCalendar.prototype.dayOfYear = function (date) {
791
- var j = this.toJalali(date);
792
- return (j.month <= 6 ? ((j.month - 1) * 31) : ((6 * 31) + (j.month - 7) * 30)) + j.day;
793
- };
794
- JalaliCalendar.prototype.dayOfWeek = function (date) {
795
- return date.getDay() == 6 ? 1 : date.getDay() + 2;
796
- };
797
- JalaliCalendar.prototype.weekOfYear = function (date) {
798
- //TODO : apply jalali
799
- var firstDay = new AXDateTime(date).startOf('year');
800
- return Math.ceil((((date.getTime() - firstDay.date.getTime()) / 86400000) + firstDay.date.getDay() + 1) / 7);
801
- };
802
- JalaliCalendar.prototype.year = function (date) {
803
- return this.toJalali(date).year;
804
- };
805
- JalaliCalendar.prototype.monthOfYear = function (date) {
806
- return this.toJalali(date).month;
807
- };
808
- JalaliCalendar.prototype.add = function (date, unit, amount) {
809
- var value = date.valueOf();
810
- switch (unit) {
811
- case 'second':
812
- value += 1000 * amount;
813
- break;
814
- case 'minute':
815
- value += 60000 * amount;
816
- break;
817
- case 'hour':
818
- value += 3600000 * amount;
819
- break;
820
- case 'month':
821
- {
822
- var v = new Date(value);
823
- var jd = this.dayOfMonth(date);
824
- var jm = this.monthOfYear(date);
825
- var jy = this.year(date);
826
- jm = (jm + amount) % 12;
827
- if (0 > jm) {
828
- jy += (this.monthOfYear(date) + amount - jm - 12) / 12;
829
- jm += 12;
830
- }
831
- else {
832
- jy += ((this.monthOfYear(date) + amount - jm) / 12);
833
- }
834
- var vv = this.toGregorian(jy, jm, jd);
835
- v.setFullYear(vv.getFullYear());
836
- v.setMonth(vv.getMonth());
837
- v.setDate(vv.getDate());
838
- value = v.valueOf();
839
- break;
840
- }
841
- case 'week':
842
- value += 7 * 86400000 * amount;
843
- break;
844
- case 'year':
845
- {
846
- var v = new Date(value);
847
- var jd = this.dayOfMonth(date);
848
- var jm = this.monthOfYear(date);
849
- var jy = this.year(date);
850
- var vv = this.toGregorian(jy + amount, jm, jd);
851
- v.setFullYear(vv.getFullYear());
852
- v.setMonth(vv.getMonth());
853
- v.setDate(vv.getDate());
854
- value = v.valueOf();
855
- }
856
- break;
857
- case 'day':
858
- default:
859
- value += 86400000 * amount;
860
- }
861
- return new AXDateTime(new Date(value), this.name());
862
- };
863
- JalaliCalendar.prototype.set = function (date, unit, value) {
864
- throw new Error("Method not implemented.");
865
- };
866
- JalaliCalendar.prototype.startOf = function (date, unit) {
867
- var clone = new Date(date.valueOf());
868
- switch (unit) {
869
- case 'second':
870
- clone.setHours(clone.getHours(), clone.getMinutes(), clone.getSeconds(), 0);
871
- return new AXDateTime(clone, this.name());
872
- case 'minute':
873
- clone.setHours(clone.getHours(), clone.getMinutes(), 0, 0);
874
- return new AXDateTime(clone, this.name());
875
- case 'hour':
876
- clone.setHours(clone.getHours(), 0, 0, 0);
877
- return new AXDateTime(clone, this.name());
878
- default:
879
- case 'day':
880
- clone.setHours(0, 0, 0, 0);
881
- return new AXDateTime(clone, this.name());
882
- case "week":
883
- return new AXDateTime(clone, this.name()).add('day', -this.dayOfWeek(clone) + 1).startOf('day');
884
- case "month":
885
- {
886
- var jy = this.year(date);
887
- var jm = this.monthOfYear(date);
888
- var gDate = this.toGregorian(jy, jm, 1);
889
- return new AXDateTime(gDate, this.name()).startOf('day');
890
- }
891
- case "year":
892
- {
893
- var jy = this.year(date);
894
- var gDate = this.toGregorian(jy, 1, 1);
895
- return new AXDateTime(gDate, this.name()).startOf('day');
896
- }
897
- }
898
- };
899
- JalaliCalendar.prototype.endOf = function (date, unit) {
900
- var clone = new Date(date.valueOf());
901
- switch (unit) {
902
- case 'second':
903
- clone.setHours(clone.getHours(), clone.getMinutes(), clone.getSeconds(), 999);
904
- return new AXDateTime(clone, this.name());
905
- case 'minute':
906
- clone.setHours(clone.getHours(), clone.getMinutes(), 59, 999);
907
- return new AXDateTime(clone, this.name());
908
- case 'hour':
909
- clone.setHours(clone.getHours(), 59, 59, 999);
910
- return new AXDateTime(clone, this.name());
911
- default:
912
- case 'day':
913
- clone.setHours(23, 59, 59, 999);
914
- return new AXDateTime(clone, this.name());
915
- case 'week':
916
- {
917
- return this.startOf(date, 'week').add('day', 6).endOf('day');
918
- }
919
- case 'month':
920
- {
921
- var jy_1 = this.year(date);
922
- var jm = this.monthOfYear(date);
923
- var jd = this.monthLength(jy_1, jm);
924
- var gDate_1 = this.toGregorian(jy_1, jm, jd);
925
- return new AXDateTime(gDate_1, this.name()).endOf('day');
926
- }
927
- case "year":
928
- var jy = this.year(date);
929
- var gDate = this.toGregorian(jy, 12, this.monthLength(jy, 12));
930
- return new AXDateTime(gDate, this.name()).endOf('day');
931
- }
932
- };
933
- JalaliCalendar.prototype.toJalali = function (date) {
934
- var gy = date.getFullYear();
935
- var gm = date.getMonth() + 1;
936
- var gd = date.getDate();
937
- var r = this.d2j(this.g2d(gy, gm, gd));
938
- return {
939
- year: r.jy,
940
- month: r.jm,
941
- day: r.jd,
942
- };
943
- };
944
- /*
945
- Converts a Jalaali date to Gregorian.
946
- */
947
- JalaliCalendar.prototype.toGregorian = function (jy, jm, jd) {
948
- var g = this.d2g(this.j2d(jy, jm, jd));
949
- return new Date(g.gy, g.gm - 1, g.gd);
950
- };
951
- /*
952
- Checks whether a Jalaali date is valid or not.
953
- */
954
- JalaliCalendar.prototype.isValid = function (jy, jm, jd) {
955
- return jy >= -61 && jy <= 3177 &&
956
- jm >= 1 && jm <= 12 &&
957
- jd >= 1 && jd <= this.monthLength(jy, jm);
958
- };
959
- /*
960
- Is this a leap year or not?
961
- */
962
- JalaliCalendar.prototype.isLeapYear = function (jy) {
963
- return this.jalCal(jy).leap === 0;
964
- };
965
- /*
966
- Number of days in a given month in a Jalaali year.
967
- */
968
- JalaliCalendar.prototype.monthLength = function (jy, jm) {
969
- if (jm <= 6)
970
- return 31;
971
- if (jm <= 11)
972
- return 30;
973
- if (this.isLeapYear(jy))
974
- return 30;
975
- return 29;
976
- };
977
- JalaliCalendar.prototype.jalCal = function (jy) {
978
- // Jalaali years starting the 33-year rule.
979
- var breaks = [-61, 9, 38, 199, 426, 686, 756, 818, 1111, 1181, 1210,
980
- 1635, 2060, 2097, 2192, 2262, 2324, 2394, 2456, 3178
981
- ], bl = breaks.length, gy = jy + 621, leapJ = -14, jp = breaks[0], jm, jump, leap, leapG, march, n, i;
982
- if (jy < jp || jy >= breaks[bl - 1])
983
- throw new Error('Invalid Jalaali year ' + jy);
984
- // Find the limiting years for the Jalaali year jy.
985
- for (i = 1; i < bl; i += 1) {
986
- jm = breaks[i];
987
- jump = jm - jp;
988
- if (jy < jm)
989
- break;
990
- leapJ = leapJ + this.div(jump, 33) * 8 + this.div(this.mod(jump, 33), 4);
991
- jp = jm;
992
- }
993
- n = jy - jp;
994
- // Find the number of leap years from AD 621 to the beginning
995
- // of the current Jalaali year in the Persian calendar.
996
- leapJ = leapJ + this.div(n, 33) * 8 + this.div(this.mod(n, 33) + 3, 4);
997
- if (this.mod(jump, 33) === 4 && jump - n === 4)
998
- leapJ += 1;
999
- // And the same in the Gregorian calendar (until the year gy).
1000
- leapG = this.div(gy, 4) - this.div((this.div(gy, 100) + 1) * 3, 4) - 150;
1001
- // Determine the Gregorian date of Farvardin the 1st.
1002
- march = 20 + leapJ - leapG;
1003
- // Find how many years have passed since the last leap year.
1004
- if (jump - n < 6)
1005
- n = n - jump + this.div(jump + 4, 33) * 33;
1006
- leap = this.mod(this.mod(n + 1, 33) - 1, 4);
1007
- if (leap === -1) {
1008
- leap = 4;
1009
- }
1010
- return {
1011
- leap: leap,
1012
- gy: gy,
1013
- march: march
1014
- };
1015
- };
1016
- /*
1017
- Converts a date of the Jalaali calendar to the Julian Day number.
1018
- @param jy Jalaali year (1 to 3100)
1019
- @param jm Jalaali month (1 to 12)
1020
- @param jd Jalaali day (1 to 29/31)
1021
- @return Julian Day number
1022
- */
1023
- JalaliCalendar.prototype.j2d = function (jy, jm, jd) {
1024
- var r = this.jalCal(jy);
1025
- return this.g2d(r.gy, 3, r.march) + (jm - 1) * 31 - this.div(jm, 7) * (jm - 7) + jd - 1;
1026
- };
1027
- /*
1028
- Converts the Julian Day number to a date in the Jalaali calendar.
1029
- @param jdn Julian Day number
1030
- @return
1031
- jy: Jalaali year (1 to 3100)
1032
- jm: Jalaali month (1 to 12)
1033
- jd: Jalaali day (1 to 29/31)
1034
- */
1035
- JalaliCalendar.prototype.d2j = function (jdn) {
1036
- var gy = this.d2g(jdn).gy // Calculate Gregorian year (gy).
1037
- , jy = gy - 621, r = this.jalCal(jy), jdn1f = this.g2d(gy, 3, r.march), jd, jm, k;
1038
- // Find number of days that passed since 1 Farvardin.
1039
- k = jdn - jdn1f;
1040
- if (k >= 0) {
1041
- if (k <= 185) {
1042
- // The first 6 months.
1043
- jm = 1 + this.div(k, 31);
1044
- jd = this.mod(k, 31) + 1;
1045
- return {
1046
- jy: jy,
1047
- jm: jm,
1048
- jd: jd
1049
- };
1050
- }
1051
- else {
1052
- // The remaining months.
1053
- k -= 186;
1054
- }
1055
- }
1056
- else {
1057
- // Previous Jalaali year.
1058
- jy -= 1;
1059
- k += 179;
1060
- if (r.leap === 1)
1061
- k += 1;
1062
- }
1063
- jm = 7 + this.div(k, 30);
1064
- jd = this.mod(k, 30) + 1;
1065
- return {
1066
- jy: jy,
1067
- jm: jm,
1068
- jd: jd
1069
- };
1070
- };
1071
- JalaliCalendar.prototype.g2d = function (gy, gm, gd) {
1072
- var d = this.div((gy + this.div(gm - 8, 6) + 100100) * 1461, 4)
1073
- + this.div(153 * this.mod(gm + 9, 12) + 2, 5)
1074
- + gd - 34840408;
1075
- d = d - this.div(this.div(gy + 100100 + this.div(gm - 8, 6), 100) * 3, 4) + 752;
1076
- return d;
1077
- };
1078
- JalaliCalendar.prototype.d2g = function (jdn) {
1079
- var j, i, gd, gm, gy;
1080
- j = 4 * jdn + 139361631;
1081
- j = j + this.div(this.div(4 * jdn + 183187720, 146097) * 3, 4) * 4 - 3908;
1082
- i = this.div(this.mod(j, 1461), 4) * 5 + 308;
1083
- gd = this.div(this.mod(i, 153), 5) + 1;
1084
- gm = this.mod(this.div(i, 153), 12) + 1;
1085
- gy = this.div(j, 1461) - 100100 + this.div(8 - gm, 6);
1086
- return {
1087
- gy: gy,
1088
- gm: gm,
1089
- gd: gd
1090
- };
1091
- };
1092
- /*
1093
- Utility helper functions.
1094
- */
1095
- JalaliCalendar.prototype.div = function (a, b) {
1096
- return ~~(a / b);
1097
- };
1098
- JalaliCalendar.prototype.mod = function (a, b) {
1099
- return a - ~~(a / b) * b;
1100
- };
1101
- return JalaliCalendar;
1102
- }());
1103
-
1104
- var AXDateTimeModule = /** @class */ (function () {
1105
- function AXDateTimeModule() {
1106
- AXConfig.set({
1107
- dateTime: {
1108
- calendars: {
1109
- jalali: new JalaliCalendar(),
1110
- gregorian: new GeorgianCalendar()
1111
- }
1112
- }
1113
- });
1114
- }
1115
- return AXDateTimeModule;
1116
- }());
1117
- AXDateTimeModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0__namespace, type: AXDateTimeModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
1118
- AXDateTimeModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0__namespace, type: AXDateTimeModule, declarations: [AXDateTimePipe], exports: [AXDateTimePipe] });
1119
- AXDateTimeModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0__namespace, type: AXDateTimeModule, providers: [], imports: [[]] });
1120
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0__namespace, type: AXDateTimeModule, decorators: [{
1121
- type: i0.NgModule,
1122
- args: [{
1123
- imports: [],
1124
- exports: [AXDateTimePipe],
1125
- declarations: [AXDateTimePipe],
1126
- providers: [],
1127
- }]
1128
- }], ctorParameters: function () { return []; } });
1129
-
1130
- var AXHotkeysService = /** @class */ (function () {
1131
- function AXHotkeysService(eventManager, document) {
1132
- this.eventManager = eventManager;
1133
- this.document = document;
1134
- this.defaults = {
1135
- element: this.document
1136
- };
1137
- }
1138
- AXHotkeysService.prototype.addShortcut = function (options) {
1139
- var _this = this;
1140
- var merged = Object.assign(Object.assign({}, this.defaults), options);
1141
- var event = "keydown." + merged.keys;
1142
- return new Observable.Observable(function (observer) {
1143
- var handler = function (e) {
1144
- e.preventDefault();
1145
- observer.next(e);
1146
- };
1147
- var dispose = _this.eventManager.addEventListener(merged.element, event, handler);
1148
- return function () {
1149
- dispose();
1150
- };
1151
- });
1152
- };
1153
- return AXHotkeysService;
1154
- }());
1155
- AXHotkeysService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0__namespace, type: AXHotkeysService, deps: [{ token: i1__namespace.EventManager }, { token: common.DOCUMENT }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1156
- AXHotkeysService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0__namespace, type: AXHotkeysService });
1157
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0__namespace, type: AXHotkeysService, decorators: [{
1158
- type: i0.Injectable
1159
- }], ctorParameters: function () {
1160
- return [{ type: i1__namespace.EventManager }, { type: Document, decorators: [{
1161
- type: i0.Inject,
1162
- args: [common.DOCUMENT]
1163
- }] }];
1164
- } });
1165
-
1166
- // @dynamic
1167
- var AXTranslator = /** @class */ (function () {
1168
- function AXTranslator() {
1169
- }
1170
- Object.defineProperty(AXTranslator, "onChange", {
1171
- get: function () {
1172
- return AXTranslator.dataChangeSubject.asObservable();
1173
- },
1174
- enumerable: false,
1175
- configurable: true
1176
- });
1177
- AXTranslator.load = function (lang, value) {
1178
- if (typeof value === 'object') {
1179
- if (!AXTranslator["__data__" + lang]) {
1180
- AXTranslator["__data__" + lang] = {};
1181
- }
1182
- AXTranslator["__data__" + lang] = merge__default['default'](AXTranslator["__data__" + lang], value);
1183
- }
1184
- };
1185
- AXTranslator.use = function (lang) {
1186
- AXTranslator.lang = lang;
1187
- };
1188
- AXTranslator.get = function (key, lang) {
1189
- return AXObjectUtil.getPropByPath(AXTranslator["__data__" + (lang || AXTranslator.lang)], key) || key;
1190
- };
1191
- return AXTranslator;
1192
- }());
1193
- AXTranslator.lang = 'en';
1194
- AXTranslator.dataChangeSubject = new rxjs.Subject();
1195
-
1196
- var AXTranslatorPipe = /** @class */ (function () {
1197
- function AXTranslatorPipe() {
1198
- }
1199
- AXTranslatorPipe.prototype.transform = function (value, lang) {
1200
- return AXTranslator.get(value, lang);
1201
- };
1202
- return AXTranslatorPipe;
1203
- }());
1204
- AXTranslatorPipe.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0__namespace, type: AXTranslatorPipe, deps: [], target: i0__namespace.ɵɵFactoryTarget.Pipe });
1205
- AXTranslatorPipe.ɵpipe = i0__namespace.ɵɵngDeclarePipe({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0__namespace, type: AXTranslatorPipe, name: "trans" });
1206
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0__namespace, type: AXTranslatorPipe, decorators: [{
1207
- type: i0.Pipe,
1208
- args: [{ name: 'trans', pure: true }]
1209
- }] });
1210
-
1211
- var AXTranslationModule = /** @class */ (function () {
1212
- function AXTranslationModule() {
1213
- }
1214
- return AXTranslationModule;
1215
- }());
1216
- AXTranslationModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0__namespace, type: AXTranslationModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
1217
- AXTranslationModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0__namespace, type: AXTranslationModule, declarations: [AXTranslatorPipe], exports: [AXTranslatorPipe] });
1218
- AXTranslationModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0__namespace, type: AXTranslationModule, providers: [], imports: [[]] });
1219
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0__namespace, type: AXTranslationModule, decorators: [{
1220
- type: i0.NgModule,
1221
- args: [{
1222
- imports: [],
1223
- exports: [AXTranslatorPipe],
1224
- declarations: [AXTranslatorPipe],
1225
- providers: [],
1226
- }]
1227
- }] });
1228
-
1229
- var isChrome = function (win) { return testUserAgent(win, /Chrome/i); };
1230
- var isFirefox = function (win) { return testUserAgent(win, /Firefox/i); };
1231
- var isEdge = function (win) { return testUserAgent(win, /Edge/i); };
1232
- var isSafari = function (win) { return testUserAgent(win, /Safari/i); };
1233
- var isOpera = function (win) { return testUserAgent(win, /Opera/i) || testUserAgent(win, /OPR/i); };
1234
- var isMSIE = function (win) { return testUserAgent(win, /MSIE/i) || testUserAgent(win, /Trident/i); };
1235
- var isMobileWeb = function (win) { return isMobile(win) && !isHybrid(win); };
1236
- var isIpad = function (win) {
1237
- // iOS 12 and below
1238
- if (testUserAgent(win, /iPad/i)) {
1239
- return true;
1240
- }
1241
- // iOS 13+
1242
- if (testUserAgent(win, /Macintosh/i) && isMobile(win)) {
1243
- return true;
1244
- }
1245
- return false;
1246
- };
1247
- var isIphone = function (win) { return testUserAgent(win, /iPhone/i); };
1248
- var isIOS = function (win) { return testUserAgent(win, /iPhone|iPod/i) || isIpad(win); };
1249
- var isAndroid = function (win) { return testUserAgent(win, /android|sink/i); };
1250
- var isAndroidTablet = function (win) {
1251
- return isAndroid(win) && !testUserAgent(win, /mobile/i);
1252
- };
1253
- var isPhablet = function (win) {
1254
- var width = win.innerWidth;
1255
- var height = win.innerHeight;
1256
- var smallest = Math.min(width, height);
1257
- var largest = Math.max(width, height);
1258
- return (smallest > 390 && smallest < 520) &&
1259
- (largest > 620 && largest < 800);
1260
- };
1261
- var isTablet = function (win) {
1262
- var width = win.innerWidth;
1263
- var height = win.innerHeight;
1264
- var smallest = Math.min(width, height);
1265
- var largest = Math.max(width, height);
1266
- return (isIpad(win) ||
1267
- isAndroidTablet(win) ||
1268
- ((smallest > 460 && smallest < 820) &&
1269
- (largest > 780 && largest < 1400)));
1270
- };
1271
- var isMobile = function (win) { return matchMedia(win, '(any-pointer:coarse)'); };
1272
- var isDesktop = function (win) { return !isMobile(win); };
1273
- var isHybrid = function (win) { return isCordova(win) || isCapacitorNative(win); };
1274
- var isCordova = function (win) { return !!(win['cordova'] || win['phonegap'] || win['PhoneGap']); };
1275
- var isCapacitorNative = function (win) {
1276
- var capacitor = win['Capacitor'];
1277
- return !!(capacitor && capacitor.isNative);
1278
- };
1279
- var isElectron = function (win) { return testUserAgent(win, /electron/i); };
1280
- var isPWA = function (win) { return !!(win.matchMedia('(display-mode: standalone)').matches || win.navigator.standalone); };
1281
- var testUserAgent = function (win, expr) { return expr.test(win.navigator.userAgent); };
1282
- var matchMedia = function (win, query) { return win.matchMedia(query).matches; };
1283
- var PLATFORMS_MAP = {
1284
- 'Android': isAndroid,
1285
- 'iOS': isIOS,
1286
- 'Desktop': isDesktop,
1287
- 'Mobile': isMobile,
1288
- 'Chrome': isChrome,
1289
- 'Firefox': isFirefox,
1290
- 'Safari': isSafari,
1291
- 'Edge': isEdge,
1292
- 'Opera': isOpera,
1293
- 'Hybrid': isHybrid,
1294
- 'PWA': isPWA,
1295
- 'Electron': isElectron,
1296
- };
1297
- var AXPlatformEvent = /** @class */ (function () {
1298
- function AXPlatformEvent() {
1299
- }
1300
- return AXPlatformEvent;
1301
- }());
1302
- var AXPlatform = /** @class */ (function () {
1303
- function AXPlatform() {
1304
- var _this = this;
1305
- this.resize = new rxjs.Subject();
1306
- this.click = new rxjs.Subject();
1307
- this.scroll = new rxjs.Subject();
1308
- window.addEventListener('resize', function (e) {
1309
- _this.resize.next({
1310
- nativeEvent: e,
1311
- source: _this
1312
- });
1313
- });
1314
- document.addEventListener('click', function (e) {
1315
- _this.click.next({
1316
- nativeEvent: e,
1317
- source: _this
1318
- });
1319
- }, true);
1320
- document.addEventListener('scroll', function (e) {
1321
- _this.scroll.next({
1322
- nativeEvent: e,
1323
- source: _this
1324
- });
1325
- }, true);
1326
- }
1327
- AXPlatform.prototype.isRtl = function () {
1328
- return document.dir == 'rtl' || document.body.dir == 'rtl' || document.body.style.direction == 'rtl';
1329
- };
1330
- AXPlatform.prototype.isLandscape = function () {
1331
- return window.innerHeight < window.innerWidth;
1332
- };
1333
- AXPlatform.prototype.isPortrate = function () {
1334
- return !this.isLandscape();
1335
- };
1336
- AXPlatform.prototype.is = function (name) {
1337
- return PLATFORMS_MAP[name](window) || false;
1338
- };
1339
- AXPlatform.prototype.switchDarkMode = function () {
1340
- var _html = document.getElementsByTagName("html")[0];
1341
- _html.classList.add('ax-dark');
1342
- };
1343
- AXPlatform.prototype.switchLightMode = function () {
1344
- var _html = document.getElementsByTagName("html")[0];
1345
- _html.classList.remove('ax-dark');
1346
- };
1347
- return AXPlatform;
1348
- }());
1349
- AXPlatform.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0__namespace, type: AXPlatform, deps: [], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1350
- AXPlatform.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0__namespace, type: AXPlatform, providedIn: 'platform' });
1351
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.6", ngImport: i0__namespace, type: AXPlatform, decorators: [{
1352
- type: i0.Injectable,
1353
- args: [{
1354
- providedIn: 'platform',
1355
- }]
1356
- }], ctorParameters: function () { return []; } });
1357
-
1358
- /**
1359
- * Public API refrences of core libraries
1360
- * @module @acorex/core
1361
- */
1362
-
1363
- /**
1364
- * Generated bundle index. Do not edit.
1365
- */
1366
-
1367
- exports.AXCalendarMonth = AXCalendarMonth;
1368
- exports.AXConfig = AXConfig;
1369
- exports.AXCoreModule = AXCoreModule;
1370
- exports.AXDateTime = AXDateTime;
1371
- exports.AXDateTimeModule = AXDateTimeModule;
1372
- exports.AXDateTimePipe = AXDateTimePipe;
1373
- exports.AXDateTimeRange = AXDateTimeRange;
1374
- exports.AXDrawingUtil = AXDrawingUtil;
1375
- exports.AXHotkeysService = AXHotkeysService;
1376
- exports.AXObjectUtil = AXObjectUtil;
1377
- exports.AXPlatform = AXPlatform;
1378
- exports.AXPlatformEvent = AXPlatformEvent;
1379
- exports.AXSafePipe = AXSafePipe;
1380
- exports.AXStringUtil = AXStringUtil;
1381
- exports.AXTranslationModule = AXTranslationModule;
1382
- exports.AXTranslator = AXTranslator;
1383
- exports.AXTranslatorPipe = AXTranslatorPipe;
1384
- exports.GeorgianCalendar = GeorgianCalendar;
1385
- exports.testUserAgent = testUserAgent;
1386
-
1387
- Object.defineProperty(exports, '__esModule', { value: true });
1388
-
1389
- })));
1390
- //# sourceMappingURL=acorex-core.umd.js.map