@acorex/core 5.0.30 → 5.0.37
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/esm2020/lib/config/configs.mjs +6 -6
- package/esm2020/lib/dateTime/datetime.class.mjs +5 -8
- package/esm2020/lib/dateTime/datetime.module.mjs +4 -2
- package/esm2020/lib/dateTime/datetime.pipe.mjs +3 -2
- package/esm2020/lib/dateTime/index.mjs +2 -1
- package/esm2020/lib/translation/translator.mjs +3 -3
- package/esm2020/lib/utils/object-util.mjs +1 -45
- package/fesm2015/acorex-core.mjs +15 -59
- package/fesm2015/acorex-core.mjs.map +1 -1
- package/fesm2020/acorex-core.mjs +15 -59
- package/fesm2020/acorex-core.mjs.map +1 -1
- package/lib/dateTime/index.d.ts +1 -0
- package/lib/utils/object-util.d.ts +0 -3
- package/package.json +1 -1
package/fesm2020/acorex-core.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
2
|
import { Pipe, NgModule, Injectable, Inject } from '@angular/core';
|
|
3
3
|
import * as i1 from '@angular/platform-browser';
|
|
4
|
+
import _ from 'lodash';
|
|
4
5
|
import { Subject } from 'rxjs';
|
|
5
6
|
import { DOCUMENT } from '@angular/common';
|
|
6
7
|
import { Observable } from 'rxjs/internal/Observable';
|
|
@@ -43,50 +44,6 @@ class AXObjectUtil {
|
|
|
43
44
|
}
|
|
44
45
|
throw new Error('Unable to copy obj! Its type isn\'t supported.');
|
|
45
46
|
}
|
|
46
|
-
static fetchProp(obj, prop) {
|
|
47
|
-
if (typeof obj === 'undefined') {
|
|
48
|
-
return false;
|
|
49
|
-
}
|
|
50
|
-
const index = prop.indexOf('.');
|
|
51
|
-
if (index > -1) {
|
|
52
|
-
return AXObjectUtil.fetchProp(obj[prop.substring(0, index)], prop.substr(index + 1));
|
|
53
|
-
}
|
|
54
|
-
return obj[prop];
|
|
55
|
-
}
|
|
56
|
-
static getPropByPath(obj, path, defaultVal) {
|
|
57
|
-
path = path
|
|
58
|
-
.replace(/\[/g, '.')
|
|
59
|
-
.replace(/]/g, '')
|
|
60
|
-
.split('.');
|
|
61
|
-
path.forEach((level) => {
|
|
62
|
-
if (obj) {
|
|
63
|
-
obj = obj[level];
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
if (obj === undefined) {
|
|
67
|
-
return defaultVal;
|
|
68
|
-
}
|
|
69
|
-
return obj;
|
|
70
|
-
}
|
|
71
|
-
static setPropByPath(obj, path, value) {
|
|
72
|
-
if (Object(obj) !== obj) {
|
|
73
|
-
return obj;
|
|
74
|
-
} // When obj is not an object
|
|
75
|
-
// If not yet an array, get the keys from the string-path
|
|
76
|
-
if (!Array.isArray(path)) {
|
|
77
|
-
path = path.toString().match(/[^.[\]]+/g) || [];
|
|
78
|
-
}
|
|
79
|
-
path.slice(0, -1).reduce((a, c, i) => // Iterate all of them except the last one
|
|
80
|
-
Object(a[c]) === a[c] // Does the key exist and is its value an object?
|
|
81
|
-
// Yes: then follow that path
|
|
82
|
-
? a[c]
|
|
83
|
-
// No: create the key. Is the next key a potential array-index?
|
|
84
|
-
: a[c] = Math.abs(path[i + 1]) >> 0 === +path[i + 1]
|
|
85
|
-
? [] // Yes: assign a new array object
|
|
86
|
-
: {}, // No: assign a new plain object
|
|
87
|
-
obj)[path[path.length - 1]] = value; // Finally assign the value to the last key
|
|
88
|
-
return obj; // Return the top-level object to allow chaining
|
|
89
|
-
}
|
|
90
47
|
}
|
|
91
48
|
|
|
92
49
|
// @dynamic
|
|
@@ -184,13 +141,13 @@ class AXConfig {
|
|
|
184
141
|
}
|
|
185
142
|
static set(arg1, arg2) {
|
|
186
143
|
if (arg1 && typeof arg1 == 'string') {
|
|
187
|
-
|
|
144
|
+
debugger;
|
|
145
|
+
_.set(AXConfig.dataModel, arg1, arg2);
|
|
188
146
|
AXConfig.dataChangeSubject.next(AXConfig.dataModel);
|
|
189
147
|
return;
|
|
190
148
|
}
|
|
191
149
|
if (arg1 && typeof arg1 == 'object') {
|
|
192
|
-
|
|
193
|
-
Object.assign(AXConfig.dataModel, arg1);
|
|
150
|
+
_.merge(AXConfig.dataModel, arg1);
|
|
194
151
|
AXConfig.dataChangeSubject.next(AXConfig.dataModel);
|
|
195
152
|
return;
|
|
196
153
|
}
|
|
@@ -199,7 +156,7 @@ class AXConfig {
|
|
|
199
156
|
}
|
|
200
157
|
}
|
|
201
158
|
static get(path, defaultValue) {
|
|
202
|
-
return
|
|
159
|
+
return _.get(AXConfig.dataModel, path, defaultValue);
|
|
203
160
|
}
|
|
204
161
|
}
|
|
205
162
|
AXConfig.dataModel = {};
|
|
@@ -207,11 +164,9 @@ AXConfig.dataChangeSubject = new Subject();
|
|
|
207
164
|
|
|
208
165
|
// @dynamic
|
|
209
166
|
class AXDateTime {
|
|
210
|
-
constructor(value = new Date(), calendar = AXConfig.get(
|
|
167
|
+
constructor(value = new Date(), calendar = AXConfig.get(`dateTime.calendar`)) {
|
|
168
|
+
debugger;
|
|
211
169
|
this._calendar =
|
|
212
|
-
// typeof calendar == 'string'
|
|
213
|
-
// ? eval(`new ${AX_CALENDARS.find((c) => c.name == calendar).type}()`)
|
|
214
|
-
// : calendar;
|
|
215
170
|
typeof calendar == 'string'
|
|
216
171
|
? AXConfig.get(`dateTime.calendars.${calendar}`)
|
|
217
172
|
: calendar;
|
|
@@ -222,7 +177,7 @@ class AXDateTime {
|
|
|
222
177
|
this._date = new Date(value);
|
|
223
178
|
}
|
|
224
179
|
}
|
|
225
|
-
static convert(value, calendar = AXConfig.get('dateTime.
|
|
180
|
+
static convert(value, calendar = AXConfig.get('dateTime.calendar')) {
|
|
226
181
|
let date;
|
|
227
182
|
if (typeof value === 'string' || value instanceof String) {
|
|
228
183
|
date = new AXDateTime(value, calendar);
|
|
@@ -290,8 +245,7 @@ class AXDateTime {
|
|
|
290
245
|
endOf(unit = 'day') {
|
|
291
246
|
return this._calendar.endOf(this.date, unit);
|
|
292
247
|
}
|
|
293
|
-
format(format = AXConfig.get('dateTime.shortDateFormat')
|
|
294
|
-
'DDD, dd MMM yyyy') {
|
|
248
|
+
format(format = AXConfig.get('dateTime.shortDateFormat')) {
|
|
295
249
|
format = format.replace('ss', this.pad(this.date.getSeconds(), 2));
|
|
296
250
|
format = format.replace('s', this.date.getSeconds().toString());
|
|
297
251
|
format = format.replace('dd', this.pad(this.calendar.dayOfMonth(this.date), 2));
|
|
@@ -472,7 +426,7 @@ class AXDateTimePipe {
|
|
|
472
426
|
}
|
|
473
427
|
const date = value instanceof AXDateTime ? value.clone() : AXDateTime.convert(value, calendar);
|
|
474
428
|
if (!format) {
|
|
475
|
-
return date.
|
|
429
|
+
return date.format(AXConfig.get('dateTime.shortDateFormat'));
|
|
476
430
|
}
|
|
477
431
|
else {
|
|
478
432
|
return date.format(format);
|
|
@@ -1004,7 +958,9 @@ class AXDateTimeModule {
|
|
|
1004
958
|
calendars: {
|
|
1005
959
|
jalali: new JalaliCalendar(),
|
|
1006
960
|
gregorian: new GeorgianCalendar()
|
|
1007
|
-
}
|
|
961
|
+
},
|
|
962
|
+
calendar: 'gregorian',
|
|
963
|
+
shortDateFormat: 'DDD, dd MMM yyyy'
|
|
1008
964
|
}
|
|
1009
965
|
});
|
|
1010
966
|
}
|
|
@@ -1105,7 +1061,7 @@ class AXTranslator {
|
|
|
1105
1061
|
AXTranslator.lang = lang;
|
|
1106
1062
|
}
|
|
1107
1063
|
static get(key, lang) {
|
|
1108
|
-
return
|
|
1064
|
+
return _.get(AXTranslator[`__data__${lang || AXTranslator.lang}`], key, key);
|
|
1109
1065
|
}
|
|
1110
1066
|
}
|
|
1111
1067
|
AXTranslator.lang = 'en';
|
|
@@ -1271,5 +1227,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImpor
|
|
|
1271
1227
|
* Generated bundle index. Do not edit.
|
|
1272
1228
|
*/
|
|
1273
1229
|
|
|
1274
|
-
export { AXCalendarMonth, AXConfig, AXCoreModule, AXDateTime, AXDateTimeModule, AXDateTimePipe, AXDateTimeRange, AXDrawingUtil, AXEventService, AXHotkeysService, AXObjectUtil, AXPlatform, AXPlatformEvent, AXSafePipe, AXStringUtil, AXTranslationModule, AXTranslator, AXTranslatorPipe, GeorgianCalendar, testUserAgent };
|
|
1230
|
+
export { AXCalendarMonth, AXConfig, AXCoreModule, AXDateTime, AXDateTimeModule, AXDateTimePipe, AXDateTimeRange, AXDrawingUtil, AXEventService, AXHotkeysService, AXObjectUtil, AXPlatform, AXPlatformEvent, AXSafePipe, AXStringUtil, AXTranslationModule, AXTranslator, AXTranslatorPipe, GeorgianCalendar, JalaliCalendar, testUserAgent };
|
|
1275
1231
|
//# sourceMappingURL=acorex-core.mjs.map
|