@acorex/core 6.5.14 → 6.5.15
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/acorex-core.d.ts +5 -0
- package/esm2020/acorex-core.mjs +5 -0
- package/esm2020/lib/classes/base-page.class.mjs +28 -0
- package/esm2020/lib/classes/color.class.mjs +49 -0
- package/esm2020/lib/classes/datetime.class.mjs +314 -0
- package/esm2020/lib/classes/menu.class.mjs +27 -0
- package/esm2020/lib/classes/navigator.class.mjs +2 -0
- package/esm2020/lib/classes/popup.class.mjs +2 -0
- package/esm2020/lib/classes/promise.class.mjs +19 -0
- package/esm2020/lib/classes/sectionlist.class.mjs +2 -0
- package/esm2020/lib/classes/select.class.mjs +3 -0
- package/esm2020/lib/core.module.mjs +27 -0
- package/esm2020/lib/error/error.class.mjs +2 -0
- package/esm2020/lib/error/error.module.mjs +19 -0
- package/esm2020/lib/error/error.service.mjs +21 -0
- package/esm2020/lib/events/keyboard.mjs +2 -0
- package/esm2020/lib/http/http-error.class.mjs +2 -0
- package/esm2020/lib/http/http-events.interceptor.mjs +3 -0
- package/esm2020/lib/http/http-request.class.mjs +2 -0
- package/esm2020/lib/http/http-result.class.mjs +21 -0
- package/esm2020/lib/http/http.module.mjs +37 -0
- package/esm2020/lib/http/http.service.mjs +145 -0
- package/{src → esm2020}/lib/locale/en.json +6 -6
- package/{src → esm2020}/lib/locale/fa.json +7 -7
- package/esm2020/lib/pipe/datetime.pipe.mjs +25 -0
- package/esm2020/lib/pipe/htmlToText.pipe.mjs +25 -0
- package/esm2020/lib/platform/index.mjs +2 -0
- package/esm2020/lib/platform/platform.service.mjs +138 -0
- package/esm2020/lib/services/config.mjs +29 -0
- package/esm2020/lib/services/event.service.mjs +36 -0
- package/esm2020/lib/services/navigator.service.mjs +10 -0
- package/esm2020/lib/services/storage.service.mjs +16 -0
- package/esm2020/lib/translator/translator.mjs +26 -0
- package/esm2020/lib/translator/translator.module.mjs +25 -0
- package/esm2020/lib/translator/translator.pipe.mjs +24 -0
- package/esm2020/lib/translator/translator.service.mjs +21 -0
- package/esm2020/lib/utils/array/array-util.mjs +133 -0
- package/esm2020/lib/utils/html/html-util.mjs +192 -0
- package/esm2020/lib/utils/html/html.module.mjs +19 -0
- package/esm2020/lib/utils/math/math-util.mjs +6 -0
- package/esm2020/lib/utils/object/object-util.mjs +83 -0
- package/esm2020/lib/utils/render/on-demand-preload-strategy.service.mjs +20 -0
- package/esm2020/lib/utils/render/render.service.mjs +103 -0
- package/esm2020/lib/utils/render/rendering.module.mjs +35 -0
- package/esm2020/lib/utils/scroll/scroll.directive.mjs +54 -0
- package/esm2020/lib/utils/scroll/scroll.module.mjs +19 -0
- package/esm2020/lib/utils/separator/separator.module.mjs +19 -0
- package/esm2020/lib/utils/separator/separator.pipe.mjs +33 -0
- package/esm2020/public-api.mjs +44 -0
- package/fesm2015/acorex-core.mjs +2262 -0
- package/fesm2015/acorex-core.mjs.map +1 -0
- package/fesm2020/acorex-core.mjs +2258 -0
- package/fesm2020/acorex-core.mjs.map +1 -0
- package/lib/classes/base-page.class.d.ts +13 -0
- package/lib/classes/color.class.d.ts +17 -0
- package/lib/classes/datetime.class.d.ts +63 -0
- package/lib/classes/menu.class.d.ts +34 -0
- package/{src/lib/classes/navigator.class.ts → lib/classes/navigator.class.d.ts} +1 -1
- package/{src/lib/classes/popup.class.ts → lib/classes/popup.class.d.ts} +0 -2
- package/lib/classes/promise.class.d.ts +7 -0
- package/lib/classes/select.class.d.ts +7 -0
- package/lib/core.module.d.ts +9 -0
- package/lib/error/error.module.d.ts +7 -0
- package/lib/error/error.service.d.ts +13 -0
- package/{src/lib/events/keyboard.ts → lib/events/keyboard.d.ts} +0 -3
- package/{src/lib/http/http-error.class.ts → lib/http/http-error.class.d.ts} +2 -2
- package/{src/lib/http/http-events.interceptor.ts → lib/http/http-events.interceptor.d.ts} +3 -7
- package/{src/lib/http/http-request.class.ts → lib/http/http-request.class.d.ts} +5 -5
- package/lib/http/http-result.class.d.ts +11 -0
- package/lib/http/http.module.d.ts +10 -0
- package/lib/http/http.service.d.ts +23 -0
- package/lib/pipe/datetime.pipe.d.ts +8 -0
- package/lib/pipe/htmlToText.pipe.d.ts +7 -0
- package/lib/platform/index.d.ts +1 -0
- package/lib/platform/platform.service.d.ts +25 -0
- package/lib/services/config.d.ts +9 -0
- package/lib/services/event.service.d.ts +9 -0
- package/lib/services/navigator.service.d.ts +8 -0
- package/lib/services/storage.service.d.ts +7 -0
- package/lib/translator/translator.d.ts +9 -0
- package/lib/translator/translator.module.d.ts +8 -0
- package/lib/translator/translator.pipe.d.ts +8 -0
- package/lib/translator/translator.service.d.ts +8 -0
- package/lib/utils/array/array-util.d.ts +6 -0
- package/lib/utils/html/html-util.d.ts +62 -0
- package/lib/utils/html/html.module.d.ts +8 -0
- package/lib/utils/math/math-util.d.ts +3 -0
- package/lib/utils/object/object-util.d.ts +7 -0
- package/lib/utils/render/on-demand-preload-strategy.service.d.ts +10 -0
- package/lib/utils/render/render.service.d.ts +18 -0
- package/lib/utils/render/rendering.module.d.ts +8 -0
- package/lib/utils/scroll/scroll.directive.d.ts +18 -0
- package/lib/utils/scroll/scroll.module.d.ts +8 -0
- package/lib/utils/separator/separator.module.d.ts +8 -0
- package/lib/utils/separator/separator.pipe.d.ts +8 -0
- package/package.json +33 -13
- package/{src/public-api.ts → public-api.d.ts} +0 -10
- package/karma.conf.js +0 -32
- package/ng-package.json +0 -10
- package/src/lib/classes/base-page.class.ts +0 -29
- package/src/lib/classes/color.class.ts +0 -61
- package/src/lib/classes/datetime.class.ts +0 -373
- package/src/lib/classes/menu.class.ts +0 -37
- package/src/lib/classes/promise.class.ts +0 -25
- package/src/lib/classes/select.class.ts +0 -7
- package/src/lib/core.module.ts +0 -21
- package/src/lib/error/error.module.ts +0 -13
- package/src/lib/error/error.service.ts +0 -23
- package/src/lib/error/index.ts +0 -3
- package/src/lib/http/http-result.class.ts +0 -34
- package/src/lib/http/http.module.ts +0 -25
- package/src/lib/http/http.service.ts +0 -159
- package/src/lib/pipe/datetime.pipe.ts +0 -20
- package/src/lib/pipe/htmlToText.pipe.ts +0 -18
- package/src/lib/platform/index.ts +0 -1
- package/src/lib/platform/platform.service.ts +0 -211
- package/src/lib/services/config.ts +0 -36
- package/src/lib/services/event.service.ts +0 -31
- package/src/lib/services/navigator.service.ts +0 -8
- package/src/lib/services/storage.service.ts +0 -11
- package/src/lib/translator/translator.module.ts +0 -19
- package/src/lib/translator/translator.pipe.ts +0 -22
- package/src/lib/translator/translator.service.ts +0 -19
- package/src/lib/translator/translator.ts +0 -31
- package/src/lib/utils/array/array-util.ts +0 -140
- package/src/lib/utils/html/html-util.ts +0 -264
- package/src/lib/utils/html/html.module.ts +0 -11
- package/src/lib/utils/math/math-util.ts +0 -5
- package/src/lib/utils/object/object-util.ts +0 -87
- package/src/lib/utils/render/on-demand-preload-strategy.service.ts +0 -25
- package/src/lib/utils/render/render.service.ts +0 -110
- package/src/lib/utils/render/rendering.module.ts +0 -25
- package/src/lib/utils/scroll/scroll.directive.ts +0 -35
- package/src/lib/utils/scroll/scroll.module.ts +0 -11
- package/src/lib/utils/separator/separator.module.ts +0 -11
- package/src/lib/utils/separator/separator.pipe.ts +0 -27
- package/src/test.ts +0 -28
- package/tsconfig.lib.json +0 -25
- package/tsconfig.lib.prod.json +0 -6
- package/tsconfig.spec.json +0 -18
- package/tslint.json +0 -17
- /package/{src/lib/classes/sectionlist.class.ts → lib/classes/sectionlist.class.d.ts} +0 -0
- /package/{src/lib/error/error.class.ts → lib/error/error.class.d.ts} +0 -0
|
@@ -1,373 +0,0 @@
|
|
|
1
|
-
import moment from 'jalali-moment';
|
|
2
|
-
import { AXConfig } from '../services/config';
|
|
3
|
-
// const moment = moment_;
|
|
4
|
-
|
|
5
|
-
export type TimeUnit = 'second' | 'minute' | 'minutes' | 'hour' | 'hours' | 'day' | 'days' | 'month' | 'year' | 'week';
|
|
6
|
-
|
|
7
|
-
export type TimeDuration = 'seconds' | 'minutes' | 'hours' | 'days' | 'weeks' | 'month' | 'years';
|
|
8
|
-
|
|
9
|
-
export type TimeStep = 'Y' | 'M' | 'D' | 'YM' | 'YMD' | 'YMDh' | 'YMDhm' | 'YMDhms' | 'h' | 'm' | 's';
|
|
10
|
-
|
|
11
|
-
export type AXCalendarType = 'jalali' | 'gregorian';
|
|
12
|
-
|
|
13
|
-
export class AXDateTime {
|
|
14
|
-
static convert(value: any, type: AXCalendarType = AXConfig.get('dateTime.type') || 'gregorian'): AXDateTime {
|
|
15
|
-
let date: AXDateTime;
|
|
16
|
-
if (typeof value === 'string' || value instanceof String) {
|
|
17
|
-
date = new AXDateTime(value as string, type);
|
|
18
|
-
} else if (value instanceof Date) {
|
|
19
|
-
date = new AXDateTime(value as Date, type);
|
|
20
|
-
} else if (value instanceof AXDateTime) {
|
|
21
|
-
date = value;
|
|
22
|
-
}
|
|
23
|
-
return date;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
private _date: Date;
|
|
27
|
-
get date(): Date {
|
|
28
|
-
return this._date;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
private resolveUnit(unit: TimeUnit): any {
|
|
32
|
-
return this.type === 'jalali' ? 'j' + unit : unit;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
private _moment: moment.Moment;
|
|
36
|
-
|
|
37
|
-
// private get _moment(): moment_.Moment {
|
|
38
|
-
// const m = moment(this.date);
|
|
39
|
-
// if (this.type === 'jalali') {
|
|
40
|
-
// m.locale('fa');
|
|
41
|
-
// }
|
|
42
|
-
// return m;
|
|
43
|
-
// }
|
|
44
|
-
|
|
45
|
-
constructor(value: Date | string = new Date(), public type: AXCalendarType = AXConfig.get('dateTime.type') || 'gregorian') {
|
|
46
|
-
if (value instanceof Date) {
|
|
47
|
-
this._date = value as Date;
|
|
48
|
-
} else {
|
|
49
|
-
this._date = new Date(value);
|
|
50
|
-
}
|
|
51
|
-
this._moment = moment(this.date);
|
|
52
|
-
if (this.type === 'jalali') {
|
|
53
|
-
this._moment.locale('fa');
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
clone(): AXDateTime {
|
|
58
|
-
return new AXDateTime(this.date, this.type);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
get dayInMonth(): number {
|
|
62
|
-
return this._moment.date();
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
get dayOfYear(): number {
|
|
66
|
-
return this._moment.dayOfYear();
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
get dayInWeek(): number {
|
|
70
|
-
return this._moment.day();
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
get hour(): number {
|
|
74
|
-
return this._moment.hour();
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
get minute(): number {
|
|
78
|
-
return this._moment.minute();
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
get second(): number {
|
|
82
|
-
return this._moment.second();
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
get year(): number {
|
|
86
|
-
return this._moment.year();
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
get monthOfYear(): number {
|
|
90
|
-
return this._moment.month();
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
get month(): AXCalendarMonth {
|
|
94
|
-
return new AXCalendarMonth(this);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
get firstDayOfWeek(): AXDateTime {
|
|
98
|
-
const a = moment(this.date);
|
|
99
|
-
if (this.type === 'jalali') {
|
|
100
|
-
this._moment.locale('fa');
|
|
101
|
-
}
|
|
102
|
-
return new AXDateTime(a.startOf('w').toDate(), this.type);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
get endDayOfWeek(): AXDateTime {
|
|
106
|
-
const a = moment(this.date);
|
|
107
|
-
if (this.type === 'jalali') {
|
|
108
|
-
this._moment.locale('fa');
|
|
109
|
-
}
|
|
110
|
-
return new AXDateTime(moment(this.date).endOf('w').toDate(), this.type);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
convertStringToJalali(date: string, format: string) {
|
|
114
|
-
return moment(date).locale('fa').format('YYYY/M/D');
|
|
115
|
-
}
|
|
116
|
-
convertStringToGregorian(date: string, format: string) {
|
|
117
|
-
return new Date(moment.from(date, 'fa', 'YYYY/MM/DD').format('YYYY/MM/DD'));
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
add(unit: TimeUnit = 'day', amount: number): AXDateTime {
|
|
121
|
-
return new AXDateTime(moment(this.date).add(amount, this.resolveUnit(unit)).toDate(), this.type);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
addDay(amount: number): AXDateTime {
|
|
125
|
-
return new AXDateTime(moment(this.date).add(amount, 'd').toDate(), this.type);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
addMonth(amount: number): AXDateTime {
|
|
129
|
-
return new AXDateTime(moment(this.date).add(amount, 'months').toDate(), this.type);
|
|
130
|
-
}
|
|
131
|
-
addHour(amount: number) {
|
|
132
|
-
return new AXDateTime(moment(this.date).add(amount, 'hours').toDate(), this.type);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
set(unit: TimeUnit = 'day', value: number): AXDateTime {
|
|
136
|
-
return new AXDateTime(this._moment.set(unit, value).toDate(), this.type);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
duration(end: AXDateTime, unit: TimeDuration = 'days'): number {
|
|
140
|
-
const duration = moment.duration(this._moment.diff(end._moment));
|
|
141
|
-
return Math.round(duration.as(unit));
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
startOf(unit: TimeUnit = 'day'): AXDateTime {
|
|
145
|
-
return new AXDateTime(moment(this.date).startOf(this.resolveUnit(unit)).toDate(), this.type);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
endOf(unit: TimeUnit = 'day'): AXDateTime {
|
|
149
|
-
return new AXDateTime(moment(this.date).endOf(this.resolveUnit(unit)).toDate(), this.type);
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
format(format: string = AXConfig.get('dateTime.shortDateFormat') || (this.type === 'gregorian' ? 'DD-MM-YYYY' : 'YYYY-MM-DD')): string {
|
|
153
|
-
if (format === 'P') {
|
|
154
|
-
return this._moment.fromNow();
|
|
155
|
-
}
|
|
156
|
-
return this._moment.format(format);
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
toString(): string {
|
|
160
|
-
return this.format();
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
equal(value: AXDateTime, unit: TimeUnit = 'day') {
|
|
164
|
-
if (!value) {
|
|
165
|
-
return false;
|
|
166
|
-
}
|
|
167
|
-
return this._moment.isSame(moment(value.date), this.resolveUnit(unit));
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
convertToJalaliDate(value) {
|
|
171
|
-
const options: any = {
|
|
172
|
-
numberingSystem: 'latn',
|
|
173
|
-
year: 'numeric',
|
|
174
|
-
month: '2-digit',
|
|
175
|
-
day: '2-digit',
|
|
176
|
-
hour: '2-digit',
|
|
177
|
-
minute: '2-digit',
|
|
178
|
-
second: '2-digit'
|
|
179
|
-
};
|
|
180
|
-
const jDate = new Date(value).toLocaleDateString('fa-IR', options);
|
|
181
|
-
const item: any = {};
|
|
182
|
-
item.year = jDate.slice(0, 4);
|
|
183
|
-
item.month = jDate.slice(5, 7);
|
|
184
|
-
item.day = jDate.slice(8, 10);
|
|
185
|
-
item.hour = jDate.slice(13, 15);
|
|
186
|
-
item.minutes = jDate.slice(16, 18);
|
|
187
|
-
item.seconds = jDate.slice(19, 21);
|
|
188
|
-
return item;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
toJalaliString(value) {
|
|
192
|
-
const date = this.convertToJalaliDate(value);
|
|
193
|
-
let str = '';
|
|
194
|
-
str = date.year + '-' + date.month + '-' + date.day + 'T' + date.hour + ':' + date.minutes + ':' + date.seconds;
|
|
195
|
-
return str;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
convertToGregorianDate(value) {
|
|
199
|
-
// TODO: check this fucking type
|
|
200
|
-
const options: any = {
|
|
201
|
-
numberingSystem: 'latn',
|
|
202
|
-
year: 'numeric',
|
|
203
|
-
month: '2-digit',
|
|
204
|
-
day: '2-digit',
|
|
205
|
-
hour: '2-digit',
|
|
206
|
-
minute: '2-digit',
|
|
207
|
-
second: '2-digit'
|
|
208
|
-
};
|
|
209
|
-
const date = new Date(value).toLocaleString('en-us', options);
|
|
210
|
-
const item: any = {};
|
|
211
|
-
item.year = date.slice(6, 10);
|
|
212
|
-
item.month = date.slice(0, 2);
|
|
213
|
-
item.day = date.slice(3, 5);
|
|
214
|
-
item.hour = date.slice(12, 14);
|
|
215
|
-
item.minutes = date.slice(15, 17);
|
|
216
|
-
item.seconds = date.slice(18, 20);
|
|
217
|
-
return item;
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
toGregorianString(value) {
|
|
221
|
-
const date = this.convertToGregorianDate(value);
|
|
222
|
-
let str = '';
|
|
223
|
-
str = date.year + '-' + date.month + '-' + date.day + 'T' + date.hour + ':' + date.minutes + ':' + date.seconds;
|
|
224
|
-
return str;
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
compaireNew(value: AXDateTime, unit: TimeStep = 'YMD', type = 'jalali') {
|
|
228
|
-
const range = [0, 0];
|
|
229
|
-
let str1;
|
|
230
|
-
let str2;
|
|
231
|
-
if (type === 'jalali') {
|
|
232
|
-
str1 = this.toJalaliString(this.date);
|
|
233
|
-
str2 = this.toJalaliString(value.date ? value.date : value);
|
|
234
|
-
} else {
|
|
235
|
-
str1 = this.toGregorianString(this.date);
|
|
236
|
-
str2 = this.toGregorianString(value.date ? value.date : value);
|
|
237
|
-
}
|
|
238
|
-
switch (unit) {
|
|
239
|
-
case 'YMDhms':
|
|
240
|
-
range[0] = 0;
|
|
241
|
-
range[1] = 19;
|
|
242
|
-
break;
|
|
243
|
-
case 'YMDhm':
|
|
244
|
-
range[0] = 0;
|
|
245
|
-
range[1] = 16;
|
|
246
|
-
break;
|
|
247
|
-
case 'YMDh':
|
|
248
|
-
range[0] = 0;
|
|
249
|
-
range[1] = 13;
|
|
250
|
-
break;
|
|
251
|
-
case 'YMD':
|
|
252
|
-
range[0] = 0;
|
|
253
|
-
range[1] = 10;
|
|
254
|
-
break;
|
|
255
|
-
|
|
256
|
-
case 'YM':
|
|
257
|
-
range[0] = 0;
|
|
258
|
-
range[1] = 7;
|
|
259
|
-
break;
|
|
260
|
-
|
|
261
|
-
case 'h':
|
|
262
|
-
range[0] = 11;
|
|
263
|
-
range[1] = 13;
|
|
264
|
-
break;
|
|
265
|
-
|
|
266
|
-
case 'm':
|
|
267
|
-
range[0] = 14;
|
|
268
|
-
range[1] = 16;
|
|
269
|
-
break;
|
|
270
|
-
|
|
271
|
-
case 's':
|
|
272
|
-
range[0] = 17;
|
|
273
|
-
range[1] = 19;
|
|
274
|
-
break;
|
|
275
|
-
case 'D':
|
|
276
|
-
range[0] = 8;
|
|
277
|
-
range[1] = 10;
|
|
278
|
-
break;
|
|
279
|
-
|
|
280
|
-
case 'M':
|
|
281
|
-
range[0] = 5;
|
|
282
|
-
range[1] = 7;
|
|
283
|
-
break;
|
|
284
|
-
|
|
285
|
-
case 'Y':
|
|
286
|
-
range[0] = 0;
|
|
287
|
-
range[1] = 4;
|
|
288
|
-
break;
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
if (str1.slice(range[0], range[1]) === str2.slice(range[0], range[1])) {
|
|
292
|
-
return 0;
|
|
293
|
-
} else if (str1.slice(range[0], range[1]) > str2.slice(range[0], range[1])) {
|
|
294
|
-
return 1;
|
|
295
|
-
} else {
|
|
296
|
-
return -1;
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
compaire(value: AXDateTime, unit: TimeUnit = 'day') {
|
|
301
|
-
if (this._moment.isSame(moment(value.date), this.resolveUnit(unit))) {
|
|
302
|
-
return 0;
|
|
303
|
-
} else if (this._moment.isAfter(moment(value.date), this.resolveUnit(unit))) {
|
|
304
|
-
return 1;
|
|
305
|
-
} else {
|
|
306
|
-
return -1;
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
toISOString() {
|
|
311
|
-
return this._date.toISOString();
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
export class AXCalendarMonth {
|
|
316
|
-
private _moment: moment.Moment;
|
|
317
|
-
|
|
318
|
-
private _range: AXDateTimeRange;
|
|
319
|
-
public get range(): AXDateTimeRange {
|
|
320
|
-
return this._range;
|
|
321
|
-
}
|
|
322
|
-
public set range(v: AXDateTimeRange) {
|
|
323
|
-
this._range = v;
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
constructor(date: AXDateTime) {
|
|
327
|
-
this._moment = moment(date.date);
|
|
328
|
-
this.index = date.date.getMonth();
|
|
329
|
-
this.name = this._moment.format('MMMM');
|
|
330
|
-
this.range = new AXDateTimeRange(
|
|
331
|
-
new AXDateTime(this._moment.startOf('month').toDate(), date.type),
|
|
332
|
-
new AXDateTime(this._moment.endOf('month').toDate(), date.type)
|
|
333
|
-
);
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
private readonly index: number;
|
|
337
|
-
private readonly name: string;
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
export class AXDateTimeRange {
|
|
341
|
-
constructor(public startTime: AXDateTime, public endTime: AXDateTime) { }
|
|
342
|
-
|
|
343
|
-
duration(unit: TimeDuration = 'days'): number {
|
|
344
|
-
const duration = moment.duration(moment(this.startTime.date).diff(moment(this.endTime.date)));
|
|
345
|
-
return duration.as(unit);
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
enumurate(unit: TimeUnit = 'day', type: AXCalendarType = AXConfig.get('dateTime.type') || 'jalali'): AXDateTime[] {
|
|
349
|
-
const result: AXDateTime[] = [];
|
|
350
|
-
for (let index = 0; this.startTime.add(unit, index).compaireNew(this.endTime, this.getViewCompaire(unit), type) <= 0; index++) {
|
|
351
|
-
result.push(this.startTime.add(unit, index));
|
|
352
|
-
}
|
|
353
|
-
return result;
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
includes(value: AXDateTime, unit: TimeUnit = 'day', type = 'jalali'): boolean {
|
|
357
|
-
return (
|
|
358
|
-
value.compaireNew(this.startTime, this.getViewCompaire(unit), type) >= 0 &&
|
|
359
|
-
value.compaireNew(this.endTime, this.getViewCompaire(unit), type) <= 0
|
|
360
|
-
);
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
getViewCompaire(view) {
|
|
364
|
-
switch (view) {
|
|
365
|
-
case 'day':
|
|
366
|
-
return 'YMD';
|
|
367
|
-
case 'month':
|
|
368
|
-
return 'YM';
|
|
369
|
-
case 'year':
|
|
370
|
-
return 'Y';
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
export class AXBaseMenuItem {
|
|
2
|
-
uid?: string = new Date().getTime().toString();
|
|
3
|
-
id?: string;
|
|
4
|
-
name?: string;
|
|
5
|
-
text?: string;
|
|
6
|
-
tooltip?: string;
|
|
7
|
-
tooltipPlacement?: 'top' | 'right' | 'bottom' | 'left';
|
|
8
|
-
icon?: string;
|
|
9
|
-
visible?: boolean = true;
|
|
10
|
-
disable?: boolean = false;
|
|
11
|
-
selected?: boolean = false;
|
|
12
|
-
groupName?: string;
|
|
13
|
-
data?: any;
|
|
14
|
-
style?: string = 'ax light';
|
|
15
|
-
orderIndex?: number = 0;
|
|
16
|
-
endIcon?: string;
|
|
17
|
-
startIcon?: string;
|
|
18
|
-
onClick?: (e?: any) => void;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export class AXMenuItem extends AXBaseMenuItem {
|
|
22
|
-
items?: AXMenuItem[];
|
|
23
|
-
parentId?: string;
|
|
24
|
-
divider?: boolean = false;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export class AXButtonItem extends AXBaseMenuItem {
|
|
28
|
-
dropdown?: boolean = false;
|
|
29
|
-
submitBehavior?: boolean = false;
|
|
30
|
-
cancelBehavior?: boolean = false;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export class AXCheckItem {
|
|
34
|
-
text?: string;
|
|
35
|
-
value?: any;
|
|
36
|
-
selected?: boolean;
|
|
37
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
export class AXPromise<T> {
|
|
2
|
-
|
|
3
|
-
private _executor: (then?: (e?: T) => void) => void;
|
|
4
|
-
private thenAction?: (e?: T) => void;
|
|
5
|
-
|
|
6
|
-
static resolve<T>(value: T): AXPromise<T> {
|
|
7
|
-
const r = new AXPromise<T>(z => {
|
|
8
|
-
z(value);
|
|
9
|
-
}).then(() => { });
|
|
10
|
-
return r;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
constructor(executor: (then?: (e?: T) => void) => void) {
|
|
14
|
-
this._executor = executor;
|
|
15
|
-
setTimeout(() => {
|
|
16
|
-
this._executor(this.thenAction);
|
|
17
|
-
}, 50);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
then(action?: (e?: T) => void): AXPromise<T> {
|
|
22
|
-
this.thenAction = action;
|
|
23
|
-
return this;
|
|
24
|
-
}
|
|
25
|
-
}
|
package/src/lib/core.module.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { NgModule } from '@angular/core';
|
|
2
|
-
import { AXDateTimePipe } from './pipe/datetime.pipe';
|
|
3
|
-
import { AXEventService } from './services/event.service';
|
|
4
|
-
import { AXStorageService } from './services/storage.service';
|
|
5
|
-
import { AXScrollModule } from './utils/scroll/scroll.module';
|
|
6
|
-
import { AXTranslatorModule } from './translator/translator.module';
|
|
7
|
-
|
|
8
|
-
const PIPES = [AXDateTimePipe];
|
|
9
|
-
const MODULES = [AXScrollModule, AXTranslatorModule];
|
|
10
|
-
const SERVICES = [AXEventService,
|
|
11
|
-
AXStorageService
|
|
12
|
-
];
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
@NgModule({
|
|
16
|
-
declarations: [...PIPES],
|
|
17
|
-
imports: [...MODULES],
|
|
18
|
-
exports: [...PIPES],
|
|
19
|
-
providers: [...SERVICES]
|
|
20
|
-
})
|
|
21
|
-
export class AXCoreModule { }
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { NgModule } from '@angular/core';
|
|
2
|
-
import { CommonModule } from '@angular/common';
|
|
3
|
-
import { AXErrorService } from './error.service';
|
|
4
|
-
|
|
5
|
-
@NgModule({
|
|
6
|
-
declarations: [],
|
|
7
|
-
imports: [CommonModule],
|
|
8
|
-
exports: [],
|
|
9
|
-
providers: [AXErrorService],
|
|
10
|
-
})
|
|
11
|
-
export class AXErrorModule {
|
|
12
|
-
|
|
13
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { InjectionToken, Injectable, Injector } from '@angular/core';
|
|
2
|
-
|
|
3
|
-
export const AX_ERROR_DISPLAY_INTERCEPTOR = new InjectionToken<AXErrorDisplayInterceptor>('ax.error');
|
|
4
|
-
|
|
5
|
-
export interface AXErrorDisplayInterceptor {
|
|
6
|
-
show(message: string);
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
@Injectable({providedIn: 'root'})
|
|
10
|
-
export class AXErrorService {
|
|
11
|
-
|
|
12
|
-
constructor(private injector: Injector) {
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
handle(message: string) {
|
|
17
|
-
const instance = this.injector.get(AX_ERROR_DISPLAY_INTERCEPTOR);
|
|
18
|
-
if (instance) {
|
|
19
|
-
instance.show(message);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
}
|
package/src/lib/error/index.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { IHttpError } from './http-error.class';
|
|
2
|
-
|
|
3
|
-
export class HttpResult<T> {
|
|
4
|
-
private _executor: (result: (e?: T) => void, error: (e?: IHttpError) => void, complete: () => void) => void;
|
|
5
|
-
constructor(
|
|
6
|
-
executor: (
|
|
7
|
-
result: (e?: T) => void,
|
|
8
|
-
error: (e?: IHttpError) => void,
|
|
9
|
-
complete: () => void
|
|
10
|
-
) => void
|
|
11
|
-
) {
|
|
12
|
-
this._executor = executor;
|
|
13
|
-
setTimeout(() => {
|
|
14
|
-
this._executor(this.resultAction, this.errorAction, this.completeAction);
|
|
15
|
-
}, 50);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
private resultAction: (e?: T) => void;
|
|
19
|
-
private errorAction: (e?: IHttpError) => void;
|
|
20
|
-
private completeAction: () => void;
|
|
21
|
-
|
|
22
|
-
result(action: (e?: T) => void): HttpResult<T> {
|
|
23
|
-
this.resultAction = action;
|
|
24
|
-
return this;
|
|
25
|
-
}
|
|
26
|
-
error(action: (e?: IHttpError) => void): HttpResult<T> {
|
|
27
|
-
this.errorAction = action;
|
|
28
|
-
return this;
|
|
29
|
-
}
|
|
30
|
-
complete(action: () => void): HttpResult<T> {
|
|
31
|
-
this.completeAction = action;
|
|
32
|
-
return this;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { NgModule, ModuleWithProviders } from '@angular/core';
|
|
2
|
-
import { CommonModule } from '@angular/common';
|
|
3
|
-
import { HttpClientModule } from '@angular/common/http';
|
|
4
|
-
import { AXHttpService } from './http.service';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
@NgModule({
|
|
8
|
-
declarations: [],
|
|
9
|
-
imports: [
|
|
10
|
-
CommonModule,
|
|
11
|
-
HttpClientModule
|
|
12
|
-
],
|
|
13
|
-
exports: [HttpClientModule],
|
|
14
|
-
providers: [
|
|
15
|
-
AXHttpService
|
|
16
|
-
]
|
|
17
|
-
})
|
|
18
|
-
export class AXHttpModule {
|
|
19
|
-
static forRoot(): ModuleWithProviders<AXHttpModule> {
|
|
20
|
-
return {
|
|
21
|
-
ngModule: AXHttpModule,
|
|
22
|
-
providers: [AXHttpService]
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
}
|