@acorex/core 4.0.22 → 4.1.1

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