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