@acorex/core 4.0.24 → 4.1.0

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