@acorex/core 3.0.21 → 3.0.25
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 +4 -0
- package/acorex-core.metadata.json +1 -0
- package/bundles/acorex-core.umd.js +2539 -0
- package/bundles/acorex-core.umd.js.map +1 -0
- package/bundles/acorex-core.umd.min.js +17 -0
- package/bundles/acorex-core.umd.min.js.map +1 -0
- package/esm2015/acorex-core.js +5 -0
- package/esm2015/lib/classes/base-page.class.js +21 -0
- package/esm2015/lib/classes/color.class.js +49 -0
- package/esm2015/lib/classes/datetime.class.js +314 -0
- package/esm2015/lib/classes/menu.class.js +27 -0
- package/esm2015/lib/classes/navigator.class.js +1 -0
- package/esm2015/lib/classes/popup.class.js +1 -0
- package/esm2015/lib/classes/promise.class.js +19 -0
- package/esm2015/lib/classes/sectionlist.class.js +1 -0
- package/esm2015/lib/classes/select.class.js +3 -0
- package/esm2015/lib/core.module.js +24 -0
- package/esm2015/lib/error/error.class.js +1 -0
- package/esm2015/lib/error/error.module.js +16 -0
- package/esm2015/lib/error/error.service.js +25 -0
- package/esm2015/lib/events/keyboard.js +1 -0
- package/esm2015/lib/http/http-error.class.js +1 -0
- package/esm2015/lib/http/http-events.interceptor.js +3 -0
- package/esm2015/lib/http/http-request.class.js +1 -0
- package/esm2015/lib/http/http-result.class.js +21 -0
- package/esm2015/lib/http/http.module.js +29 -0
- package/esm2015/lib/http/http.service.js +149 -0
- package/{src → esm2015}/lib/locale/en.json +2 -2
- package/{src → esm2015}/lib/locale/fa.json +3 -3
- package/esm2015/lib/pipe/datetime.pipe.js +24 -0
- package/esm2015/lib/pipe/htmlToText.pipe.js +23 -0
- package/esm2015/lib/services/config.js +29 -0
- package/esm2015/lib/services/event.service.js +36 -0
- package/esm2015/lib/services/navigator.service.js +9 -0
- package/esm2015/lib/services/storage.service.js +15 -0
- package/esm2015/lib/translator/translator.js +26 -0
- package/esm2015/lib/translator/translator.module.js +23 -0
- package/esm2015/lib/translator/translator.pipe.js +23 -0
- package/esm2015/lib/translator/translator.service.js +21 -0
- package/esm2015/lib/utils/array/array-util.js +133 -0
- package/esm2015/lib/utils/html/html-util.js +192 -0
- package/esm2015/lib/utils/html/html.module.js +16 -0
- package/esm2015/lib/utils/math/math-util.js +6 -0
- package/esm2015/lib/utils/object/object-util.js +83 -0
- package/esm2015/lib/utils/render/on-demand-preload-strategy.service.js +21 -0
- package/esm2015/lib/utils/render/render.service.js +112 -0
- package/esm2015/lib/utils/render/rendering.module.js +26 -0
- package/esm2015/lib/utils/scroll/scroll.directive.js +66 -0
- package/esm2015/lib/utils/scroll/scroll.module.js +16 -0
- package/esm2015/lib/utils/separator/separator.module.js +16 -0
- package/esm2015/lib/utils/separator/separator.pipe.js +22 -0
- package/esm2015/public-api.js +36 -0
- package/esm5/acorex-core.js +5 -0
- package/esm5/lib/classes/base-page.class.js +23 -0
- package/esm5/lib/classes/color.class.js +54 -0
- package/esm5/lib/classes/datetime.class.js +390 -0
- package/esm5/lib/classes/menu.class.js +42 -0
- package/esm5/lib/classes/navigator.class.js +1 -0
- package/esm5/lib/classes/popup.class.js +1 -0
- package/esm5/lib/classes/promise.class.js +22 -0
- package/esm5/lib/classes/sectionlist.class.js +1 -0
- package/esm5/lib/classes/select.class.js +7 -0
- package/esm5/lib/core.module.js +27 -0
- package/esm5/lib/error/error.class.js +1 -0
- package/esm5/lib/error/error.module.js +19 -0
- package/esm5/lib/error/error.service.js +26 -0
- package/esm5/lib/events/keyboard.js +1 -0
- package/esm5/lib/http/http-error.class.js +1 -0
- package/esm5/lib/http/http-events.interceptor.js +3 -0
- package/esm5/lib/http/http-request.class.js +1 -0
- package/esm5/lib/http/http-result.class.js +24 -0
- package/esm5/lib/http/http.module.js +33 -0
- package/esm5/lib/http/http.service.js +157 -0
- package/esm5/lib/locale/en.json +249 -0
- package/esm5/lib/locale/fa.json +238 -0
- package/esm5/lib/pipe/datetime.pipe.js +26 -0
- package/esm5/lib/pipe/htmlToText.pipe.js +26 -0
- package/esm5/lib/services/config.js +37 -0
- package/esm5/lib/services/event.service.js +37 -0
- package/esm5/lib/services/navigator.service.js +12 -0
- package/esm5/lib/services/storage.service.js +18 -0
- package/esm5/lib/translator/translator.js +34 -0
- package/esm5/lib/translator/translator.module.js +24 -0
- package/esm5/lib/translator/translator.pipe.js +25 -0
- package/esm5/lib/translator/translator.service.js +24 -0
- package/esm5/lib/utils/array/array-util.js +147 -0
- package/esm5/lib/utils/html/html-util.js +224 -0
- package/esm5/lib/utils/html/html.module.js +19 -0
- package/esm5/lib/utils/math/math-util.js +10 -0
- package/esm5/lib/utils/object/object-util.js +88 -0
- package/esm5/lib/utils/render/on-demand-preload-strategy.service.js +22 -0
- package/esm5/lib/utils/render/render.service.js +117 -0
- package/esm5/lib/utils/render/rendering.module.js +29 -0
- package/esm5/lib/utils/scroll/scroll.directive.js +68 -0
- package/esm5/lib/utils/scroll/scroll.module.js +19 -0
- package/esm5/lib/utils/separator/separator.module.js +19 -0
- package/esm5/lib/utils/separator/separator.pipe.js +25 -0
- package/esm5/public-api.js +36 -0
- package/fesm2015/acorex-core.js +2057 -0
- package/fesm2015/acorex-core.js.map +1 -0
- package/fesm5/acorex-core.js +2274 -0
- package/fesm5/acorex-core.js.map +1 -0
- package/lib/classes/base-page.class.d.ts +10 -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/{src/lib/classes/sectionlist.class.ts → lib/classes/sectionlist.class.d.ts} +0 -0
- package/lib/classes/select.class.d.ts +7 -0
- package/lib/core.module.d.ts +2 -0
- package/{src/lib/error/error.class.ts → lib/error/error.class.d.ts} +0 -0
- package/lib/error/error.module.d.ts +2 -0
- package/lib/error/error.service.d.ts +10 -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 +4 -0
- package/lib/http/http.service.d.ts +20 -0
- package/lib/pipe/datetime.pipe.d.ts +5 -0
- package/lib/pipe/htmlToText.pipe.d.ts +4 -0
- package/lib/services/config.d.ts +9 -0
- package/lib/services/event.service.d.ts +6 -0
- package/lib/services/navigator.service.d.ts +5 -0
- package/lib/services/storage.service.d.ts +4 -0
- package/lib/translator/translator.d.ts +9 -0
- package/lib/translator/translator.module.d.ts +3 -0
- package/lib/translator/translator.pipe.d.ts +5 -0
- package/lib/translator/translator.service.d.ts +5 -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 +2 -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 +7 -0
- package/lib/utils/render/render.service.d.ts +14 -0
- package/lib/utils/render/rendering.module.d.ts +4 -0
- package/lib/utils/scroll/scroll.directive.d.ts +13 -0
- package/lib/utils/scroll/scroll.module.d.ts +2 -0
- package/lib/utils/separator/separator.module.d.ts +2 -0
- package/lib/utils/separator/separator.pipe.d.ts +4 -0
- package/package.json +23 -13
- package/{src/public-api.ts → public-api.d.ts} +0 -9
- package/karma.conf.js +0 -32
- package/ng-package.json +0 -10
- package/src/lib/classes/base-page.class.ts +0 -27
- package/src/lib/classes/color.class.ts +0 -61
- package/src/lib/classes/datetime.class.ts +0 -374
- 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/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 -26
- package/src/lib/utils/render/render.service.ts +0 -107
- 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 -15
- package/src/test.ts +0 -26
- package/tsconfig.lib.json +0 -23
- package/tsconfig.lib.prod.json +0 -6
- package/tsconfig.spec.json +0 -18
- package/tslint.json +0 -17
|
@@ -1,374 +0,0 @@
|
|
|
1
|
-
import * as 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
|
-
|
|
117
|
-
}
|
|
118
|
-
convertStringToGregorian(date: string, format: string) {
|
|
119
|
-
return new Date((moment.from(date, 'fa', 'YYYY/MM/DD').format('YYYY/MM/DD')));
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
add(unit: TimeUnit = 'day', amount: number): AXDateTime {
|
|
123
|
-
return new AXDateTime(moment(this.date).add(amount, this.resolveUnit(unit)).toDate(), this.type);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
addDay(amount: number): AXDateTime {
|
|
127
|
-
return new AXDateTime(moment(this.date).add(amount, 'd').toDate(), this.type);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
addMonth(amount: number): AXDateTime {
|
|
131
|
-
return new AXDateTime(moment(this.date).add(amount, 'months').toDate(), this.type);
|
|
132
|
-
}
|
|
133
|
-
addHour(amount: number) {
|
|
134
|
-
return new AXDateTime(moment(this.date).add(amount, 'hours').toDate(), this.type);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
set(unit: TimeUnit = 'day', value: number): AXDateTime {
|
|
138
|
-
return new AXDateTime(this._moment.set(unit, value).toDate(), this.type);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
duration(end: AXDateTime, unit: TimeDuration = 'days'): number {
|
|
142
|
-
const duration = moment.duration(this._moment.diff(end._moment));
|
|
143
|
-
return Math.round(duration.as(unit));
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
startOf(unit: TimeUnit = 'day'): AXDateTime {
|
|
147
|
-
return new AXDateTime(moment(this.date).startOf(this.resolveUnit(unit)).toDate(), this.type);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
endOf(unit: TimeUnit = 'day'): AXDateTime {
|
|
151
|
-
return new AXDateTime(moment(this.date).endOf(this.resolveUnit(unit)).toDate(), this.type);
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
format(format: string = AXConfig.get('dateTime.shortDateFormat') || (this.type === 'gregorian' ? 'DD-MM-YYYY' : 'YYYY-MM-DD')): string {
|
|
155
|
-
if (format === 'P') {
|
|
156
|
-
return this._moment.fromNow();
|
|
157
|
-
}
|
|
158
|
-
return this._moment.format(format);
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
toString(): string {
|
|
162
|
-
return this.format();
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
equal(value: AXDateTime, unit: TimeUnit = 'day') {
|
|
166
|
-
if (!value) {
|
|
167
|
-
return false;
|
|
168
|
-
}
|
|
169
|
-
return this._moment.isSame(moment(value.date), this.resolveUnit(unit));
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
convertToJalaliDate(value) {
|
|
173
|
-
const options = {
|
|
174
|
-
numberingSystem: 'latn',
|
|
175
|
-
year: 'numeric',
|
|
176
|
-
month: '2-digit',
|
|
177
|
-
day: '2-digit',
|
|
178
|
-
hour: '2-digit',
|
|
179
|
-
minute: '2-digit',
|
|
180
|
-
second: '2-digit'
|
|
181
|
-
};
|
|
182
|
-
const jDate = new Date(value).toLocaleDateString('fa-IR', options);
|
|
183
|
-
const item: any = {};
|
|
184
|
-
item.year = jDate.slice(0, 4);
|
|
185
|
-
item.month = jDate.slice(5, 7);
|
|
186
|
-
item.day = jDate.slice(8, 10);
|
|
187
|
-
item.hour = jDate.slice(13, 15);
|
|
188
|
-
item.minutes = jDate.slice(16, 18);
|
|
189
|
-
item.seconds = jDate.slice(19, 21);
|
|
190
|
-
return item;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
toJalaliString(value) {
|
|
194
|
-
const date = this.convertToJalaliDate(value);
|
|
195
|
-
let str = '';
|
|
196
|
-
str = date.year + '-' + date.month + '-' + date.day + 'T' + date.hour + ':' + date.minutes + ':' + date.seconds;
|
|
197
|
-
return str;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
convertToGregorianDate(value) {
|
|
201
|
-
const options = {
|
|
202
|
-
numberingSystem: 'latn',
|
|
203
|
-
year: 'numeric',
|
|
204
|
-
month: '2-digit',
|
|
205
|
-
day: '2-digit',
|
|
206
|
-
hour: '2-digit',
|
|
207
|
-
minute: '2-digit',
|
|
208
|
-
second: '2-digit'
|
|
209
|
-
};
|
|
210
|
-
const date = new Date(value).toLocaleString('en-us', options);
|
|
211
|
-
const item: any = {};
|
|
212
|
-
item.year = date.slice(6, 10);
|
|
213
|
-
item.month = date.slice(0, 2);
|
|
214
|
-
item.day = date.slice(3, 5);
|
|
215
|
-
item.hour = date.slice(12, 14);
|
|
216
|
-
item.minutes = date.slice(15, 17);
|
|
217
|
-
item.seconds = date.slice(18, 20);
|
|
218
|
-
return item;
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
toGregorianString(value) {
|
|
222
|
-
const date = this.convertToGregorianDate(value);
|
|
223
|
-
let str = '';
|
|
224
|
-
str = date.year + '-' + date.month + '-' + date.day + 'T' + date.hour + ':' + date.minutes + ':' + date.seconds;
|
|
225
|
-
return str;
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
compaireNew(value: AXDateTime, unit: TimeStep = 'YMD', type = 'jalali') {
|
|
229
|
-
const range = [0, 0];
|
|
230
|
-
let str1;
|
|
231
|
-
let str2;
|
|
232
|
-
if (type === 'jalali') {
|
|
233
|
-
str1 = this.toJalaliString(this.date);
|
|
234
|
-
str2 = this.toJalaliString(value.date ? value.date : value);
|
|
235
|
-
} else {
|
|
236
|
-
str1 = this.toGregorianString(this.date);
|
|
237
|
-
str2 = this.toGregorianString(value.date ? value.date : value);
|
|
238
|
-
}
|
|
239
|
-
switch (unit) {
|
|
240
|
-
case 'YMDhms':
|
|
241
|
-
range[0] = 0;
|
|
242
|
-
range[1] = 19;
|
|
243
|
-
break;
|
|
244
|
-
case 'YMDhm':
|
|
245
|
-
range[0] = 0;
|
|
246
|
-
range[1] = 16;
|
|
247
|
-
break;
|
|
248
|
-
case 'YMDh':
|
|
249
|
-
range[0] = 0;
|
|
250
|
-
range[1] = 13;
|
|
251
|
-
break;
|
|
252
|
-
case 'YMD':
|
|
253
|
-
range[0] = 0;
|
|
254
|
-
range[1] = 10;
|
|
255
|
-
break;
|
|
256
|
-
|
|
257
|
-
case 'YM':
|
|
258
|
-
range[0] = 0;
|
|
259
|
-
range[1] = 7;
|
|
260
|
-
break;
|
|
261
|
-
|
|
262
|
-
case 'h':
|
|
263
|
-
range[0] = 11;
|
|
264
|
-
range[1] = 13;
|
|
265
|
-
break;
|
|
266
|
-
|
|
267
|
-
case 'm':
|
|
268
|
-
range[0] = 14;
|
|
269
|
-
range[1] = 16;
|
|
270
|
-
break;
|
|
271
|
-
|
|
272
|
-
case 's':
|
|
273
|
-
range[0] = 17;
|
|
274
|
-
range[1] = 19;
|
|
275
|
-
break;
|
|
276
|
-
case 'D':
|
|
277
|
-
range[0] = 8;
|
|
278
|
-
range[1] = 10;
|
|
279
|
-
break;
|
|
280
|
-
|
|
281
|
-
case 'M':
|
|
282
|
-
range[0] = 5;
|
|
283
|
-
range[1] = 7;
|
|
284
|
-
break;
|
|
285
|
-
|
|
286
|
-
case 'Y':
|
|
287
|
-
range[0] = 0;
|
|
288
|
-
range[1] = 4;
|
|
289
|
-
break;
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
if (str1.slice(range[0], range[1]) === str2.slice(range[0], range[1])) {
|
|
293
|
-
return 0;
|
|
294
|
-
} else if (str1.slice(range[0], range[1]) > str2.slice(range[0], range[1])) {
|
|
295
|
-
return 1;
|
|
296
|
-
} else {
|
|
297
|
-
return -1;
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
compaire(value: AXDateTime, unit: TimeUnit = 'day') {
|
|
302
|
-
if (this._moment.isSame(moment(value.date), this.resolveUnit(unit))) {
|
|
303
|
-
return 0;
|
|
304
|
-
} else if (this._moment.isAfter(moment(value.date), this.resolveUnit(unit))) {
|
|
305
|
-
return 1;
|
|
306
|
-
} else {
|
|
307
|
-
return -1;
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
toISOString() {
|
|
312
|
-
return this._date.toISOString();
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
export class AXCalendarMonth {
|
|
317
|
-
private _moment: moment_.Moment;
|
|
318
|
-
|
|
319
|
-
private _range: AXDateTimeRange;
|
|
320
|
-
public get range(): AXDateTimeRange {
|
|
321
|
-
return this._range;
|
|
322
|
-
}
|
|
323
|
-
public set range(v: AXDateTimeRange) {
|
|
324
|
-
this._range = v;
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
constructor(date: AXDateTime) {
|
|
328
|
-
this._moment = moment(date.date);
|
|
329
|
-
this.index = date.date.getMonth();
|
|
330
|
-
this.name = this._moment.format('MMMM');
|
|
331
|
-
this.range = new AXDateTimeRange(
|
|
332
|
-
new AXDateTime(this._moment.startOf('month').toDate(), date.type),
|
|
333
|
-
new AXDateTime(this._moment.endOf('month').toDate(), date.type)
|
|
334
|
-
);
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
private readonly index: number;
|
|
338
|
-
private readonly name: string;
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
export class AXDateTimeRange {
|
|
342
|
-
constructor(public startTime: AXDateTime, public endTime: AXDateTime) { }
|
|
343
|
-
|
|
344
|
-
duration(unit: TimeDuration = 'days'): number {
|
|
345
|
-
const duration = moment.duration(moment(this.startTime.date).diff(moment(this.endTime.date)));
|
|
346
|
-
return duration.as(unit);
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
enumurate(unit: TimeUnit = 'day', type: AXCalendarType = AXConfig.get('dateTime.type') || 'jalali'): AXDateTime[] {
|
|
350
|
-
const result: AXDateTime[] = [];
|
|
351
|
-
for (let index = 0; this.startTime.add(unit, index).compaireNew(this.endTime, this.getViewCompaire(unit), type) <= 0; index++) {
|
|
352
|
-
result.push(this.startTime.add(unit, index));
|
|
353
|
-
}
|
|
354
|
-
return result;
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
includes(value: AXDateTime, unit: TimeUnit = 'day', type = 'jalali'): boolean {
|
|
358
|
-
return (
|
|
359
|
-
value.compaireNew(this.startTime, this.getViewCompaire(unit), type) >= 0 &&
|
|
360
|
-
value.compaireNew(this.endTime, this.getViewCompaire(unit), type) <= 0
|
|
361
|
-
);
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
getViewCompaire(view) {
|
|
365
|
-
switch (view) {
|
|
366
|
-
case 'day':
|
|
367
|
-
return 'YMD';
|
|
368
|
-
case 'month':
|
|
369
|
-
return 'YM';
|
|
370
|
-
case 'year':
|
|
371
|
-
return 'Y';
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
}
|
|
@@ -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 {
|
|
20
|
-
return {
|
|
21
|
-
ngModule: AXHttpModule,
|
|
22
|
-
providers: [AXHttpService]
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
}
|