@acorex/core 7.0.20 → 7.0.21
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/config/index.d.ts +5 -0
- package/config/public-api.d.ts +1 -0
- package/config/src/configs.d.ts +9 -0
- package/dateTime/index.d.ts +5 -0
- package/dateTime/{public-api.ts → public-api.d.ts} +1 -1
- package/dateTime/src/datetime.class.d.ts +100 -0
- package/dateTime/src/datetime.module.d.ts +8 -0
- package/dateTime/src/datetime.pipe.d.ts +8 -0
- package/dateTime/src/georgian.calendar.d.ts +20 -0
- package/dateTime/src/jalali.calendar.d.ts +35 -0
- package/esm2020/acorex-core.mjs +5 -0
- package/esm2020/config/acorex-core-config.mjs +5 -0
- package/esm2020/config/public-api.mjs +2 -0
- package/esm2020/config/src/configs.mjs +32 -0
- package/esm2020/dateTime/acorex-core-dateTime.mjs +5 -0
- package/esm2020/dateTime/public-api.mjs +6 -0
- package/esm2020/dateTime/src/datetime.class.mjs +288 -0
- package/esm2020/dateTime/src/datetime.module.mjs +39 -0
- package/esm2020/dateTime/src/datetime.pipe.mjs +26 -0
- package/esm2020/dateTime/src/georgian.calendar.mjs +189 -0
- package/esm2020/dateTime/src/jalali.calendar.mjs +359 -0
- package/esm2020/events/acorex-core-events.mjs +5 -0
- package/esm2020/events/public-api.mjs +2 -0
- package/esm2020/events/src/event.service.mjs +36 -0
- package/esm2020/file/acorex-core-file.mjs +5 -0
- package/esm2020/file/public-api.mjs +5 -0
- package/esm2020/file/src/file-download-ref.class.mjs +12 -0
- package/esm2020/file/src/file-download-result.class.mjs +47 -0
- package/esm2020/file/src/file-upload-ref.class.mjs +12 -0
- package/esm2020/file/src/file.service.mjs +101 -0
- package/esm2020/http/acorex-core-http.mjs +5 -0
- package/esm2020/http/public-api.mjs +6 -0
- package/esm2020/http/src/http-error.class.mjs +2 -0
- package/esm2020/http/src/http-events.interceptor.mjs +3 -0
- package/esm2020/http/src/http-request.class.mjs +2 -0
- package/esm2020/http/src/http-result.class.mjs +21 -0
- package/esm2020/http/src/http.module.mjs +29 -0
- package/esm2020/http/src/http.service.mjs +148 -0
- package/esm2020/image/acorex-core-image.mjs +5 -0
- package/esm2020/image/public-api.mjs +2 -0
- package/esm2020/image/src/image.service.mjs +43 -0
- package/esm2020/pipes/acorex-core-pipes.mjs +5 -0
- package/esm2020/pipes/public-api.mjs +3 -0
- package/esm2020/pipes/src/pipes.module.mjs +19 -0
- package/esm2020/pipes/src/safe.pipe.mjs +30 -0
- package/esm2020/platform/acorex-core-platform.mjs +5 -0
- package/esm2020/platform/public-api.mjs +2 -0
- package/esm2020/platform/src/platform.service.mjs +153 -0
- package/esm2020/public-api.mjs +5 -0
- package/esm2020/translation/acorex-core-translation.mjs +5 -0
- package/esm2020/translation/public-api.mjs +4 -0
- package/esm2020/translation/src/translation.module.mjs +18 -0
- package/esm2020/translation/src/translator.mjs +43 -0
- package/esm2020/translation/src/translator.pipe.mjs +15 -0
- package/esm2020/utils/acorex-core-utils.mjs +5 -0
- package/esm2020/utils/public-api.mjs +5 -0
- package/esm2020/utils/src/color-util.mjs +71 -0
- package/esm2020/utils/src/drawing-util.mjs +27 -0
- package/esm2020/utils/src/object-util.mjs +39 -0
- package/esm2020/utils/src/string-util.mjs +19 -0
- package/events/index.d.ts +5 -0
- package/events/public-api.d.ts +1 -0
- package/events/src/event.service.d.ts +9 -0
- package/fesm2015/acorex-core-config.mjs +40 -0
- package/fesm2015/acorex-core-config.mjs.map +1 -0
- package/fesm2015/acorex-core-dateTime.mjs +899 -0
- package/fesm2015/acorex-core-dateTime.mjs.map +1 -0
- package/fesm2015/acorex-core-events.mjs +44 -0
- package/fesm2015/acorex-core-events.mjs.map +1 -0
- package/fesm2015/acorex-core-file.mjs +177 -0
- package/fesm2015/acorex-core-file.mjs.map +1 -0
- package/fesm2015/acorex-core-http.mjs +203 -0
- package/fesm2015/acorex-core-http.mjs.map +1 -0
- package/fesm2015/acorex-core-image.mjs +54 -0
- package/fesm2015/acorex-core-image.mjs.map +1 -0
- package/fesm2015/acorex-core-pipes.mjs +54 -0
- package/fesm2015/acorex-core-pipes.mjs.map +1 -0
- package/fesm2015/acorex-core-platform.mjs +161 -0
- package/fesm2015/acorex-core-platform.mjs.map +1 -0
- package/fesm2015/acorex-core-translation.mjs +81 -0
- package/fesm2015/acorex-core-translation.mjs.map +1 -0
- package/fesm2015/acorex-core-utils.mjs +164 -0
- package/fesm2015/acorex-core-utils.mjs.map +1 -0
- package/fesm2015/acorex-core.mjs +12 -0
- package/fesm2015/acorex-core.mjs.map +1 -0
- package/fesm2020/acorex-core-config.mjs +40 -0
- package/fesm2020/acorex-core-config.mjs.map +1 -0
- package/fesm2020/acorex-core-dateTime.mjs +899 -0
- package/fesm2020/acorex-core-dateTime.mjs.map +1 -0
- package/fesm2020/acorex-core-events.mjs +44 -0
- package/fesm2020/acorex-core-events.mjs.map +1 -0
- package/fesm2020/acorex-core-file.mjs +177 -0
- package/fesm2020/acorex-core-file.mjs.map +1 -0
- package/fesm2020/acorex-core-http.mjs +202 -0
- package/fesm2020/acorex-core-http.mjs.map +1 -0
- package/fesm2020/acorex-core-image.mjs +51 -0
- package/fesm2020/acorex-core-image.mjs.map +1 -0
- package/fesm2020/acorex-core-pipes.mjs +54 -0
- package/fesm2020/acorex-core-pipes.mjs.map +1 -0
- package/fesm2020/acorex-core-platform.mjs +161 -0
- package/fesm2020/acorex-core-platform.mjs.map +1 -0
- package/fesm2020/acorex-core-translation.mjs +80 -0
- package/fesm2020/acorex-core-translation.mjs.map +1 -0
- package/fesm2020/acorex-core-utils.mjs +164 -0
- package/fesm2020/acorex-core-utils.mjs.map +1 -0
- package/fesm2020/acorex-core.mjs +12 -0
- package/fesm2020/acorex-core.mjs.map +1 -0
- package/file/index.d.ts +5 -0
- package/file/public-api.d.ts +4 -0
- package/file/src/file-download-ref.class.d.ts +6 -0
- package/file/src/file-download-result.class.d.ts +8 -0
- package/file/src/file-upload-ref.class.d.ts +5 -0
- package/file/src/file.service.d.ts +18 -0
- package/http/index.d.ts +5 -0
- package/http/{public-api.ts → public-api.d.ts} +1 -1
- package/http/src/{http-error.class.ts → http-error.class.d.ts} +2 -2
- package/http/src/{http-events.interceptor.ts → http-events.interceptor.d.ts} +3 -7
- package/http/src/{http-request.class.ts → http-request.class.d.ts} +5 -5
- package/http/src/http-result.class.d.ts +11 -0
- package/http/src/http.module.d.ts +8 -0
- package/http/src/http.service.d.ts +23 -0
- package/image/index.d.ts +5 -0
- package/image/public-api.d.ts +1 -0
- package/image/src/image.service.d.ts +12 -0
- package/index.d.ts +5 -0
- package/package.json +115 -16
- package/pipes/index.d.ts +5 -0
- package/pipes/public-api.d.ts +2 -0
- package/pipes/src/pipes.module.d.ts +8 -0
- package/pipes/src/safe.pipe.d.ts +10 -0
- package/platform/index.d.ts +5 -0
- package/platform/public-api.d.ts +1 -0
- package/platform/src/platform.service.d.ts +26 -0
- package/public-api.d.ts +1 -0
- package/translation/index.d.ts +5 -0
- package/translation/{public-api.ts → public-api.d.ts} +1 -1
- package/translation/src/translation.module.d.ts +7 -0
- package/translation/src/translator.d.ts +11 -0
- package/translation/src/translator.pipe.d.ts +7 -0
- package/utils/index.d.ts +5 -0
- package/utils/{public-api.ts → public-api.d.ts} +1 -1
- package/utils/src/color-util.d.ts +20 -0
- package/utils/src/drawing-util.d.ts +17 -0
- package/utils/src/object-util.d.ts +4 -0
- package/utils/src/string-util.d.ts +6 -0
- package/config/ax-preset.js +0 -186
- package/config/index.ts +0 -1
- package/config/ng-package.json +0 -6
- package/config/public-api.ts +0 -1
- package/config/src/configs.ts +0 -37
- package/dateTime/index.ts +0 -1
- package/dateTime/ng-package.json +0 -6
- package/dateTime/src/datetime.class.ts +0 -449
- package/dateTime/src/datetime.module.ts +0 -35
- package/dateTime/src/datetime.pipe.ts +0 -21
- package/dateTime/src/georgian.calendar.ts +0 -205
- package/dateTime/src/jalali.calendar.ts +0 -416
- package/events/index.ts +0 -1
- package/events/ng-package.json +0 -6
- package/events/public-api.ts +0 -1
- package/events/src/event.service.ts +0 -31
- package/file/index.ts +0 -1
- package/file/ng-package.json +0 -7
- package/file/public-api.ts +0 -4
- package/file/src/file-download-ref.class.ts +0 -16
- package/file/src/file-download-result.class.ts +0 -56
- package/file/src/file-upload-ref.class.ts +0 -14
- package/file/src/file.service.ts +0 -104
- package/http/index.ts +0 -1
- package/http/ng-package.json +0 -6
- package/http/src/http-result.class.ts +0 -34
- package/http/src/http.module.ts +0 -25
- package/http/src/http.service.ts +0 -161
- package/image/index.ts +0 -1
- package/image/ng-package.json +0 -7
- package/image/public-api.ts +0 -1
- package/image/src/image.service.ts +0 -42
- package/index.ts +0 -1
- package/karma.conf.js +0 -44
- package/ng-package.json +0 -7
- package/pipes/index.ts +0 -1
- package/pipes/ng-package.json +0 -6
- package/pipes/public-api.ts +0 -2
- package/pipes/src/pipes.module.ts +0 -11
- package/pipes/src/safe.pipe.ts +0 -24
- package/platform/index.ts +0 -1
- package/platform/ng-package.json +0 -6
- package/platform/public-api.ts +0 -1
- package/platform/src/platform.service.ts +0 -223
- package/public-api.ts +0 -4
- package/test.ts +0 -27
- package/translation/index.ts +0 -1
- package/translation/ng-package.json +0 -6
- package/translation/src/translation.module.ts +0 -12
- package/translation/src/translator.pipe.ts +0 -9
- package/translation/src/translator.ts +0 -49
- package/tsconfig.lib.json +0 -15
- package/tsconfig.lib.prod.json +0 -10
- package/tsconfig.spec.json +0 -17
- package/utils/index.ts +0 -1
- package/utils/ng-package.json +0 -6
- package/utils/src/color-util.ts +0 -83
- package/utils/src/drawing-util.ts +0 -43
- package/utils/src/object-util.ts +0 -82
- package/utils/src/string-util.ts +0 -25
package/config/ax-preset.js
DELETED
@@ -1,186 +0,0 @@
|
|
1
|
-
const plugin = require('tailwindcss/plugin');
|
2
|
-
|
3
|
-
function withOpacityValue(variable) {
|
4
|
-
return ({ opacityValue }) => {
|
5
|
-
if (opacityValue === undefined) {
|
6
|
-
return `rgb(var(${variable}))`
|
7
|
-
}
|
8
|
-
return `rgb(var(${variable}) / ${opacityValue})`
|
9
|
-
}
|
10
|
-
}
|
11
|
-
|
12
|
-
module.exports = {
|
13
|
-
prefix: 'ax-',
|
14
|
-
darkMode: 'class',
|
15
|
-
mode: "jit",
|
16
|
-
content: [
|
17
|
-
"./src/**/*.{html,ts,scss}",
|
18
|
-
"./projects/**/*.{html,ts,scss}",
|
19
|
-
"./dist/acorex/**/*.{html,ts,scss}",
|
20
|
-
"./node_modules/@acorex/**/*.{html,ts,scss}",
|
21
|
-
],
|
22
|
-
darkMode: "class", // or 'media' or 'class'
|
23
|
-
theme: {
|
24
|
-
extend: {
|
25
|
-
colors: {
|
26
|
-
black: withOpacityValue('--ax-color-black'),
|
27
|
-
white: withOpacityValue('--ax-color-white'),
|
28
|
-
"default-background": withOpacityValue('--ax-color-default-background'),
|
29
|
-
"default-color": withOpacityValue('--ax-color-default-color'),
|
30
|
-
"primary": {
|
31
|
-
"fore": withOpacityValue('--ax-color-primary-fore'),
|
32
|
-
"50": withOpacityValue('--ax-color-primary-50'),
|
33
|
-
"100": withOpacityValue('--ax-color-primary-100'),
|
34
|
-
"200": withOpacityValue('--ax-color-primary-200'),
|
35
|
-
"300": withOpacityValue('--ax-color-primary-300'),
|
36
|
-
"400": withOpacityValue('--ax-color-primary-400'),
|
37
|
-
"500": withOpacityValue('--ax-color-primary-500'),
|
38
|
-
"600": withOpacityValue('--ax-color-primary-600'),
|
39
|
-
"700": withOpacityValue('--ax-color-primary-700'),
|
40
|
-
"800": withOpacityValue('--ax-color-primary-800'),
|
41
|
-
"900": withOpacityValue('--ax-color-primary-900'),
|
42
|
-
},
|
43
|
-
"secondary": {
|
44
|
-
"fore": withOpacityValue('--ax-color-secondary-fore'),
|
45
|
-
"50": withOpacityValue('--ax-color-secondary-50'),
|
46
|
-
"100": withOpacityValue('--ax-color-secondary-100'),
|
47
|
-
"200": withOpacityValue('--ax-color-secondary-200'),
|
48
|
-
"300": withOpacityValue('--ax-color-secondary-300'),
|
49
|
-
"400": withOpacityValue('--ax-color-secondary-400'),
|
50
|
-
"500": withOpacityValue('--ax-color-secondary-500'),
|
51
|
-
"600": withOpacityValue('--ax-color-secondary-600'),
|
52
|
-
"700": withOpacityValue('--ax-color-secondary-700'),
|
53
|
-
"800": withOpacityValue('--ax-color-secondary-800'),
|
54
|
-
"900": withOpacityValue('--ax-color-secondary-900'),
|
55
|
-
},
|
56
|
-
"success": {
|
57
|
-
"fore": withOpacityValue('--ax-color-success-fore'),
|
58
|
-
"50": withOpacityValue('--ax-color-success-50'),
|
59
|
-
"100": withOpacityValue('--ax-color-success-100'),
|
60
|
-
"200": withOpacityValue('--ax-color-success-200'),
|
61
|
-
"300": withOpacityValue('--ax-color-success-300'),
|
62
|
-
"400": withOpacityValue('--ax-color-success-400'),
|
63
|
-
"500": withOpacityValue('--ax-color-success-500'),
|
64
|
-
"600": withOpacityValue('--ax-color-success-600'),
|
65
|
-
"700": withOpacityValue('--ax-color-success-700'),
|
66
|
-
"800": withOpacityValue('--ax-color-success-800'),
|
67
|
-
"900": withOpacityValue('--ax-color-success-900'),
|
68
|
-
},
|
69
|
-
"danger": {
|
70
|
-
"fore": withOpacityValue('--ax-color-danger-fore'),
|
71
|
-
"50": withOpacityValue('--ax-color-danger-50'),
|
72
|
-
"100": withOpacityValue('--ax-color-danger-100'),
|
73
|
-
"200": withOpacityValue('--ax-color-danger-200'),
|
74
|
-
"300": withOpacityValue('--ax-color-danger-300'),
|
75
|
-
"400": withOpacityValue('--ax-color-danger-400'),
|
76
|
-
"500": withOpacityValue('--ax-color-danger-500'),
|
77
|
-
"600": withOpacityValue('--ax-color-danger-600'),
|
78
|
-
"700": withOpacityValue('--ax-color-danger-700'),
|
79
|
-
"800": withOpacityValue('--ax-color-danger-800'),
|
80
|
-
"900": withOpacityValue('--ax-color-danger-900'),
|
81
|
-
},
|
82
|
-
"warning": {
|
83
|
-
"fore": withOpacityValue('--ax-color-warning-fore'),
|
84
|
-
"50": withOpacityValue('--ax-color-warning-50'),
|
85
|
-
"100": withOpacityValue('--ax-color-warning-100'),
|
86
|
-
"200": withOpacityValue('--ax-color-warning-200'),
|
87
|
-
"300": withOpacityValue('--ax-color-warning-300'),
|
88
|
-
"400": withOpacityValue('--ax-color-warning-400'),
|
89
|
-
"500": withOpacityValue('--ax-color-warning-500'),
|
90
|
-
"600": withOpacityValue('--ax-color-warning-600'),
|
91
|
-
"700": withOpacityValue('--ax-color-warning-700'),
|
92
|
-
"800": withOpacityValue('--ax-color-warning-800'),
|
93
|
-
"900": withOpacityValue('--ax-color-warning-900'),
|
94
|
-
},
|
95
|
-
"info": {
|
96
|
-
"fore": withOpacityValue('--ax-color-info-fore'),
|
97
|
-
"50": withOpacityValue('--ax-color-info-50'),
|
98
|
-
"100": withOpacityValue('--ax-color-info-100'),
|
99
|
-
"200": withOpacityValue('--ax-color-info-200'),
|
100
|
-
"300": withOpacityValue('--ax-color-info-300'),
|
101
|
-
"400": withOpacityValue('--ax-color-info-400'),
|
102
|
-
"500": withOpacityValue('--ax-color-info-500'),
|
103
|
-
"600": withOpacityValue('--ax-color-info-600'),
|
104
|
-
"700": withOpacityValue('--ax-color-info-700'),
|
105
|
-
"800": withOpacityValue('--ax-color-info-800'),
|
106
|
-
"900": withOpacityValue('--ax-color-info-900'),
|
107
|
-
},
|
108
|
-
"light": {
|
109
|
-
"fore": withOpacityValue('--ax-color-light-fore'),
|
110
|
-
"50": withOpacityValue('--ax-color-light-50'),
|
111
|
-
"100": withOpacityValue('--ax-color-light-100'),
|
112
|
-
"200": withOpacityValue('--ax-color-light-200'),
|
113
|
-
"300": withOpacityValue('--ax-color-light-300'),
|
114
|
-
"400": withOpacityValue('--ax-color-light-400'),
|
115
|
-
"500": withOpacityValue('--ax-color-light-500'),
|
116
|
-
"600": withOpacityValue('--ax-color-light-600'),
|
117
|
-
"700": withOpacityValue('--ax-color-light-700'),
|
118
|
-
"800": withOpacityValue('--ax-color-light-800'),
|
119
|
-
"900": withOpacityValue('--ax-color-light-900'),
|
120
|
-
},
|
121
|
-
"dark": {
|
122
|
-
"fore": withOpacityValue('--ax-color-dark-fore'),
|
123
|
-
"50": withOpacityValue('--ax-color-dark-50'),
|
124
|
-
"100": withOpacityValue('--ax-color-dark-100'),
|
125
|
-
"200": withOpacityValue('--ax-color-dark-200'),
|
126
|
-
"300": withOpacityValue('--ax-color-dark-300'),
|
127
|
-
"400": withOpacityValue('--ax-color-dark-400'),
|
128
|
-
"500": withOpacityValue('--ax-color-dark-500'),
|
129
|
-
"600": withOpacityValue('--ax-color-dark-600'),
|
130
|
-
"700": withOpacityValue('--ax-color-dark-700'),
|
131
|
-
"800": withOpacityValue('--ax-color-dark-800'),
|
132
|
-
"900": withOpacityValue('--ax-color-dark-900'),
|
133
|
-
},
|
134
|
-
|
135
|
-
},
|
136
|
-
maxWidth: {
|
137
|
-
'8xl': '90rem',
|
138
|
-
},
|
139
|
-
keyframes: {
|
140
|
-
fadeIn: {
|
141
|
-
"0%": { opacity: 0 },
|
142
|
-
"100%": { opacity: 1 }
|
143
|
-
},
|
144
|
-
fadeOut: {
|
145
|
-
"0%": { opacity: 1 },
|
146
|
-
"100%": { opacity: 0 }
|
147
|
-
}
|
148
|
-
},
|
149
|
-
animation: {
|
150
|
-
"fadeIn": "fadeIn ease-in-out 1s",
|
151
|
-
"fadeOut": "fadeOut ease-in-out 1s",
|
152
|
-
}
|
153
|
-
},
|
154
|
-
},
|
155
|
-
variants: {
|
156
|
-
extend: {},
|
157
|
-
},
|
158
|
-
plugins: [
|
159
|
-
plugin(function ({ addUtilities }) {
|
160
|
-
const acorexClasses = {
|
161
|
-
'.animate-fast': {
|
162
|
-
animationDuration: '800ms'
|
163
|
-
},
|
164
|
-
'.animate-faster': {
|
165
|
-
animationDuration: '500ms'
|
166
|
-
},
|
167
|
-
'.bg-default': {
|
168
|
-
backgroundColor: 'rgb(var(--ax-color-default-background) / var(--tw-bg-opacity))'
|
169
|
-
},
|
170
|
-
'.text-default': {
|
171
|
-
backgroundColor: 'rgb(var(--ax-color-default-color) / var(--tw-text-opacity))'
|
172
|
-
}
|
173
|
-
}
|
174
|
-
addUtilities(acorexClasses, ['responsive', 'hover', 'focus'])
|
175
|
-
}),
|
176
|
-
require('postcss-import'),
|
177
|
-
require('tailwindcss/nesting')(require('postcss-nesting')),
|
178
|
-
require('tailwindcss'),
|
179
|
-
require('autoprefixer'),
|
180
|
-
require('tailwind-rtl-utilities')
|
181
|
-
// require('@tailwindcss/aspect-ratio'),
|
182
|
-
// require('@tailwindcss/forms'),
|
183
|
-
// require('@tailwindcss/line-clamp'),
|
184
|
-
// require('@tailwindcss/typography')
|
185
|
-
],
|
186
|
-
};
|
package/config/index.ts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
export * from './public-api';
|
package/config/ng-package.json
DELETED
package/config/public-api.ts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
export * from './src/configs';
|
package/config/src/configs.ts
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
import { get, set, merge } from 'lodash-es';
|
2
|
-
import { Subject, Observable } from 'rxjs';
|
3
|
-
|
4
|
-
// @dynamic
|
5
|
-
export class AXConfig {
|
6
|
-
private static dataModel: any = {};
|
7
|
-
private static dataChangeSubject = new Subject<any>();
|
8
|
-
|
9
|
-
static get onChange(): Observable<any> {
|
10
|
-
return AXConfig.dataChangeSubject.asObservable();
|
11
|
-
}
|
12
|
-
|
13
|
-
static set(config: any): any;
|
14
|
-
static set(path: string, value?: any): void;
|
15
|
-
static set(arg1?: any, arg2?: any) {
|
16
|
-
if (arg1 && typeof arg1 == 'string') {
|
17
|
-
set(AXConfig.dataModel, arg1, arg2);
|
18
|
-
AXConfig.dataChangeSubject.next(AXConfig.dataModel);
|
19
|
-
return true;
|
20
|
-
}
|
21
|
-
if (arg1 && typeof arg1 == 'object') {
|
22
|
-
merge(AXConfig.dataModel, arg1);
|
23
|
-
AXConfig.dataChangeSubject.next(AXConfig.dataModel);
|
24
|
-
return true;
|
25
|
-
}
|
26
|
-
if (!arg1 && !arg2) {
|
27
|
-
return AXConfig.dataChangeSubject.asObservable();
|
28
|
-
}
|
29
|
-
// TODO: Arash please check 'Not all code paths return a value.'.
|
30
|
-
// if remove return you can see error on line 15.
|
31
|
-
return '';
|
32
|
-
}
|
33
|
-
|
34
|
-
static get(path: string, defaultValue?: any): any {
|
35
|
-
return get(AXConfig.dataModel, path, defaultValue);
|
36
|
-
}
|
37
|
-
}
|
package/dateTime/index.ts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
export * from './public-api';
|
package/dateTime/ng-package.json
DELETED
@@ -1,449 +0,0 @@
|
|
1
|
-
import * as _ from 'lodash';
|
2
|
-
import { AXConfig } from '@acorex/core/config';
|
3
|
-
|
4
|
-
export type TimeUnit =
|
5
|
-
| 'ms'
|
6
|
-
| 'second'
|
7
|
-
| 'minute'
|
8
|
-
| 'hour'
|
9
|
-
| 'day'
|
10
|
-
| 'month'
|
11
|
-
| 'year'
|
12
|
-
| 'week';
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
export interface AXDateValue {
|
19
|
-
year: number,
|
20
|
-
month: number,
|
21
|
-
date: number,
|
22
|
-
hours?: number,
|
23
|
-
minutes?: number,
|
24
|
-
seconds?: number,
|
25
|
-
ms?: number
|
26
|
-
calendar: string;
|
27
|
-
}
|
28
|
-
|
29
|
-
|
30
|
-
export interface AXCalendar {
|
31
|
-
monthNames: string[];
|
32
|
-
|
33
|
-
monthShortNames: string[];
|
34
|
-
|
35
|
-
dayNames: string[];
|
36
|
-
|
37
|
-
dayShortNames: string[];
|
38
|
-
|
39
|
-
name(): string;
|
40
|
-
|
41
|
-
dayOfMonth(date: Date): number;
|
42
|
-
|
43
|
-
dayOfYear(date: Date): number;
|
44
|
-
|
45
|
-
dayOfWeek(date: Date): number;
|
46
|
-
|
47
|
-
monthOfYear(date: Date): number;
|
48
|
-
|
49
|
-
weekOfYear(date: Date): number;
|
50
|
-
|
51
|
-
year(date: Date): number;
|
52
|
-
|
53
|
-
add(date: Date, unit: TimeUnit, amount: number): AXDateTime;
|
54
|
-
|
55
|
-
set(date: Date, unit: TimeUnit, value: number): AXDateTime;
|
56
|
-
|
57
|
-
startOf(date: Date, unit: TimeUnit): AXDateTime;
|
58
|
-
|
59
|
-
endOf(date: Date, unit: TimeUnit): AXDateTime;
|
60
|
-
|
61
|
-
create(value: AXDateValue): AXDateTime;
|
62
|
-
|
63
|
-
}
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
// @dynamic
|
69
|
-
export class AXDateTime {
|
70
|
-
static convert(
|
71
|
-
value: Date | AXDateTime | string,
|
72
|
-
calendar: string = AXConfig.get('dateTime.calendar')
|
73
|
-
): AXDateTime {
|
74
|
-
let date: AXDateTime;
|
75
|
-
if (typeof value === 'string' || value instanceof String) {
|
76
|
-
date = new AXDateTime(value as string, calendar);
|
77
|
-
} else if (value instanceof Date) {
|
78
|
-
date = new AXDateTime(value as Date, calendar);
|
79
|
-
} else if (value instanceof AXDateTime) {
|
80
|
-
date = new AXDateTime(value.date, calendar);
|
81
|
-
}
|
82
|
-
return date!;
|
83
|
-
}
|
84
|
-
|
85
|
-
static from(value: AXDateValue = {
|
86
|
-
calendar: AXConfig.get('dateTime.calendar'),
|
87
|
-
year: 1,
|
88
|
-
month: 1,
|
89
|
-
date: 1,
|
90
|
-
hours: 0,
|
91
|
-
minutes: 0,
|
92
|
-
seconds: 0,
|
93
|
-
ms: 0
|
94
|
-
}): AXDateTime {
|
95
|
-
return AXDateTime.resolveCalendar(value.calendar).create(value);
|
96
|
-
}
|
97
|
-
|
98
|
-
|
99
|
-
static resolveCalendar(calendar: string | AXCalendar): AXCalendar {
|
100
|
-
return typeof calendar == 'string'
|
101
|
-
? AXConfig.get(`dateTime.calendars.${calendar}.class`)
|
102
|
-
: calendar;
|
103
|
-
}
|
104
|
-
|
105
|
-
|
106
|
-
private _date: Date;
|
107
|
-
|
108
|
-
get date(): Date {
|
109
|
-
return this._date;
|
110
|
-
}
|
111
|
-
|
112
|
-
private _calendar: AXCalendar;
|
113
|
-
get calendar(): AXCalendar {
|
114
|
-
return this._calendar;
|
115
|
-
}
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
constructor(
|
120
|
-
value: Date | string = new Date(),
|
121
|
-
calendar: string | AXCalendar = AXConfig.get(`dateTime.calendar`)
|
122
|
-
) {
|
123
|
-
this._calendar = AXDateTime.resolveCalendar(calendar);
|
124
|
-
if (value instanceof Date) {
|
125
|
-
this._date = value as Date;
|
126
|
-
} else {
|
127
|
-
//TODO: parse jalali
|
128
|
-
this._date = new Date(value);
|
129
|
-
}
|
130
|
-
}
|
131
|
-
|
132
|
-
clone(): AXDateTime {
|
133
|
-
return new AXDateTime(this.date, this.calendar);
|
134
|
-
}
|
135
|
-
|
136
|
-
get dayOfMonth(): number {
|
137
|
-
return this._calendar.dayOfMonth(this.date);
|
138
|
-
}
|
139
|
-
|
140
|
-
get dayOfYear(): number {
|
141
|
-
return this._calendar.dayOfYear(this.date);
|
142
|
-
}
|
143
|
-
|
144
|
-
get dayOfWeek(): number {
|
145
|
-
return this._calendar.dayOfWeek(this.date);
|
146
|
-
}
|
147
|
-
|
148
|
-
get hour(): number {
|
149
|
-
return this._date.getHours();
|
150
|
-
}
|
151
|
-
|
152
|
-
get minute(): number {
|
153
|
-
return this._date.getMinutes();
|
154
|
-
}
|
155
|
-
|
156
|
-
get second(): number {
|
157
|
-
return this._date.getSeconds();
|
158
|
-
}
|
159
|
-
|
160
|
-
get year(): number {
|
161
|
-
return this._calendar.year(this.date);
|
162
|
-
}
|
163
|
-
|
164
|
-
get monthOfYear(): number {
|
165
|
-
return this._calendar.monthOfYear(this.date);
|
166
|
-
}
|
167
|
-
|
168
|
-
get weekOfYear(): number {
|
169
|
-
return this._calendar.weekOfYear(this.date);
|
170
|
-
}
|
171
|
-
|
172
|
-
get month(): AXCalendarMonth {
|
173
|
-
return new AXCalendarMonth(this);
|
174
|
-
}
|
175
|
-
|
176
|
-
add(unit: TimeUnit, amount: number): AXDateTime {
|
177
|
-
return this._calendar.add(this.date, unit, amount);
|
178
|
-
}
|
179
|
-
|
180
|
-
set(unit: TimeUnit = 'day', value: number): AXDateTime {
|
181
|
-
return this._calendar.set(this.date, unit, value);
|
182
|
-
}
|
183
|
-
|
184
|
-
duration(
|
185
|
-
end: Date | AXDateTime,
|
186
|
-
unit: TimeUnit = 'day'
|
187
|
-
): AXTimeSpan {
|
188
|
-
const range = new AXDateTimeRange(
|
189
|
-
this,
|
190
|
-
AXDateTime.convert(end, this.calendar.name())
|
191
|
-
);
|
192
|
-
return range.duration();
|
193
|
-
}
|
194
|
-
|
195
|
-
startOf(unit: TimeUnit = 'day'): AXDateTime {
|
196
|
-
return this._calendar.startOf(this.date, unit);
|
197
|
-
}
|
198
|
-
|
199
|
-
endOf(unit: TimeUnit = 'day'): AXDateTime {
|
200
|
-
return this._calendar.endOf(this.date, unit);
|
201
|
-
}
|
202
|
-
|
203
|
-
private _formatKeys = {
|
204
|
-
ss: () => this.pad(this.date.getSeconds(), 2),
|
205
|
-
s: () => this.date.getSeconds().toString(),
|
206
|
-
//
|
207
|
-
dd: () => this.pad(this.calendar.dayOfMonth(this.date), 2),
|
208
|
-
d: () => this.calendar.dayOfMonth(this.date).toString(),
|
209
|
-
//
|
210
|
-
mm: () => this.pad(this.date.getMinutes(), 2),
|
211
|
-
m: () => this.date.getMinutes().toString(),
|
212
|
-
//
|
213
|
-
MMMM: () => this.calendar.monthNames[this.calendar.monthOfYear(this.date) - 1],
|
214
|
-
MMM: () => this.calendar.monthShortNames[this.calendar.monthOfYear(this.date) - 1],
|
215
|
-
MM: () => this.pad(this.calendar.monthOfYear(this.date), 2),
|
216
|
-
//
|
217
|
-
DDDD: () => this.calendar.dayNames[this.calendar.dayOfWeek(this.date) - 1],
|
218
|
-
DDD: () => this.calendar.dayShortNames[this.calendar.dayOfWeek(this.date) - 1],
|
219
|
-
//
|
220
|
-
yyyy: () => this.calendar.year(this.date).toString(),
|
221
|
-
YYYY: () => this.calendar.year(this.date).toString(),
|
222
|
-
yy: () => this.calendar.year(this.date).toString().substring(2),
|
223
|
-
YY: () => this.calendar.year(this.date).toString().substring(2),
|
224
|
-
//
|
225
|
-
HH: () => this.pad(this.date.getHours(), 2),
|
226
|
-
H: () => this.date.getHours().toString(),
|
227
|
-
//
|
228
|
-
hh: () => this.pad((this.date.getHours() % 12 || 12), 2),
|
229
|
-
h: () => (this.date.getHours() % 12 || 12).toString(),
|
230
|
-
//
|
231
|
-
A: () => (this.date.getHours() < 12) ? 'am' : 'pm',
|
232
|
-
a: () => (this.date.getHours() < 12) ? 'am' : 'pm',
|
233
|
-
};
|
234
|
-
|
235
|
-
format(
|
236
|
-
format: string = AXConfig.get('dateTime.shortDateFormat')
|
237
|
-
): string {
|
238
|
-
const re = new RegExp(_.orderBy(Object.keys(this._formatKeys), c => c.length, ['desc']).join("|"), "gi");
|
239
|
-
return format.replace(re, (matched) => {
|
240
|
-
return this._formatKeys[matched]();
|
241
|
-
});
|
242
|
-
}
|
243
|
-
|
244
|
-
private pad(n, width, z = '0') {
|
245
|
-
n = n + '';
|
246
|
-
return n.length >= width ? n : new Array(width - n.length + 1).join(z) + n;
|
247
|
-
}
|
248
|
-
|
249
|
-
toString(format: string = AXConfig.get('dateTime.shortDateFormat')): string {
|
250
|
-
return this.format(format);
|
251
|
-
}
|
252
|
-
|
253
|
-
equal(value: Date | AXDateTime, unit: TimeUnit = 'day') {
|
254
|
-
return this.compare(value, unit) == 0;
|
255
|
-
}
|
256
|
-
|
257
|
-
compare(value: Date | AXDateTime, unit: TimeUnit = 'day') {
|
258
|
-
const val = AXDateTime.convert(value, this.calendar.name());
|
259
|
-
const func = (v1: number, v2: number) => {
|
260
|
-
if (v1 == v2) {
|
261
|
-
return 0;
|
262
|
-
} else if (v1 > v2) {
|
263
|
-
return 1;
|
264
|
-
} else {
|
265
|
-
return -1;
|
266
|
-
}
|
267
|
-
}
|
268
|
-
let p = 0;
|
269
|
-
switch (unit) {
|
270
|
-
case 'year':
|
271
|
-
return func(this.year, val.year);
|
272
|
-
case 'week':
|
273
|
-
p = this.compare(val, 'year');
|
274
|
-
return p == 0 ? func(this.weekOfYear, val.weekOfYear) : p;
|
275
|
-
case 'month':
|
276
|
-
p = this.compare(val, 'year');
|
277
|
-
return p == 0 ? func(this.monthOfYear, val.monthOfYear) : p;
|
278
|
-
case 'day':
|
279
|
-
p = this.compare(val, 'year');
|
280
|
-
return p == 0 ? func(this.dayOfYear, val.dayOfYear) : p;
|
281
|
-
case 'hour':
|
282
|
-
p = this.compare(val, 'day');
|
283
|
-
return p == 0 ? func(this.hour, val.hour) : p;
|
284
|
-
case 'minute':
|
285
|
-
p = this.compare(val, 'hour');
|
286
|
-
return p == 0 ? func(this.minute, val.minute) : p;
|
287
|
-
case 'second':
|
288
|
-
p = this.compare(val, 'minute');
|
289
|
-
return p == 0 ? func(this.second, val.second) : p;
|
290
|
-
default:
|
291
|
-
return func(this.date.getTime(), val.date.getTime());
|
292
|
-
}
|
293
|
-
|
294
|
-
}
|
295
|
-
|
296
|
-
convert(calendar: string) {
|
297
|
-
return AXDateTime.convert(this, calendar);
|
298
|
-
}
|
299
|
-
}
|
300
|
-
|
301
|
-
export class AXCalendarMonth {
|
302
|
-
private _range: AXDateTimeRange;
|
303
|
-
public get range(): AXDateTimeRange {
|
304
|
-
return this._range;
|
305
|
-
}
|
306
|
-
public set range(v: AXDateTimeRange) {
|
307
|
-
this._range = v;
|
308
|
-
}
|
309
|
-
|
310
|
-
constructor(date: AXDateTime) {
|
311
|
-
this.index = date.date.getMonth();
|
312
|
-
this.name = date.format('MMMM');
|
313
|
-
this.range = new AXDateTimeRange(
|
314
|
-
new AXDateTime(date.startOf('month').date, date.calendar),
|
315
|
-
new AXDateTime(date.endOf('month').date, date.calendar)
|
316
|
-
);
|
317
|
-
}
|
318
|
-
|
319
|
-
private readonly index: number;
|
320
|
-
private readonly name: string;
|
321
|
-
}
|
322
|
-
|
323
|
-
export interface AXTimeSpanTotal {
|
324
|
-
miliseconds: number;
|
325
|
-
seconds: number;
|
326
|
-
minutes: number;
|
327
|
-
hours: number;
|
328
|
-
days: number;
|
329
|
-
weeks: number;
|
330
|
-
months: number;
|
331
|
-
years: number;
|
332
|
-
}
|
333
|
-
|
334
|
-
export interface AXTimeSpan {
|
335
|
-
miliseconds: number;
|
336
|
-
seconds: number;
|
337
|
-
minutes: number;
|
338
|
-
hours: number;
|
339
|
-
days: number;
|
340
|
-
months: number;
|
341
|
-
years: number;
|
342
|
-
total: AXTimeSpanTotal;
|
343
|
-
}
|
344
|
-
|
345
|
-
export class AXDateTimeRange {
|
346
|
-
private _startTime: AXDateTime;
|
347
|
-
private _endTime: AXDateTime;
|
348
|
-
|
349
|
-
public get startTime(): AXDateTime {
|
350
|
-
return this._startTime;
|
351
|
-
}
|
352
|
-
|
353
|
-
public get endTime(): AXDateTime {
|
354
|
-
return this._endTime;
|
355
|
-
}
|
356
|
-
|
357
|
-
constructor(startTime: AXDateTime, endTime: AXDateTime) {
|
358
|
-
this._startTime = startTime;
|
359
|
-
this._endTime = endTime;
|
360
|
-
}
|
361
|
-
|
362
|
-
duration(): AXTimeSpan {
|
363
|
-
const result: AXTimeSpan = {
|
364
|
-
miliseconds: 0,
|
365
|
-
seconds: 0,
|
366
|
-
minutes: 0,
|
367
|
-
hours: 0,
|
368
|
-
days: 0,
|
369
|
-
months: 0,
|
370
|
-
years: 0,
|
371
|
-
total: {
|
372
|
-
miliseconds: 0,
|
373
|
-
seconds: 0,
|
374
|
-
minutes: 0,
|
375
|
-
hours: 0,
|
376
|
-
days: 0,
|
377
|
-
weeks: 0,
|
378
|
-
months: 0,
|
379
|
-
years: 0,
|
380
|
-
},
|
381
|
-
};
|
382
|
-
|
383
|
-
const one_second = 1000;
|
384
|
-
const one_min = one_second * 60;
|
385
|
-
const one_hour = one_min * 60;
|
386
|
-
const one_day = one_hour * 24;
|
387
|
-
const one_week = one_day * 7;
|
388
|
-
const one_year = 365.25 * one_day;
|
389
|
-
const one_month = one_year / 12;
|
390
|
-
const startTime = this._startTime.date.getTime();
|
391
|
-
const endTime = this._endTime.date.getTime();
|
392
|
-
const diff = Math.abs(endTime - startTime);
|
393
|
-
//
|
394
|
-
result.total.miliseconds = diff;
|
395
|
-
result.total.seconds = Number((diff / one_second).toFixed(2));
|
396
|
-
result.total.minutes = Number((diff / one_min).toFixed(2));
|
397
|
-
result.total.hours = Number((diff / one_hour).toFixed(2));
|
398
|
-
result.total.days = Number((diff / one_day).toFixed(2));
|
399
|
-
result.total.weeks = Number((diff / one_week).toFixed(2));
|
400
|
-
//
|
401
|
-
// let months = (this.endTime.year - this.startTime.year) * 12;
|
402
|
-
// months += this.endTime.monthOfYear - this.startTime.monthOfYear + 1;
|
403
|
-
// if (this.endTime.dayOfYear < this.startTime.dayOfYear) {
|
404
|
-
// months--;
|
405
|
-
// }
|
406
|
-
// result.total.months = Math.abs(months);
|
407
|
-
// TODO: review
|
408
|
-
result.total.months = Number((diff / one_month).toFixed(2));
|
409
|
-
result.total.years = Number((diff / one_year).toFixed(2));
|
410
|
-
//
|
411
|
-
result.miliseconds = result.total.miliseconds % 1000;
|
412
|
-
result.seconds = Number((result.total.seconds % 60).toFixed(0));
|
413
|
-
result.minutes = Number((result.total.minutes % 60).toFixed(0));
|
414
|
-
result.hours = Number((result.total.hours % 24).toFixed(0));
|
415
|
-
// TODO: review
|
416
|
-
result.days = Number((result.total.days % 30.4).toFixed(0));
|
417
|
-
result.months = Number((result.total.months % 12).toFixed(0));
|
418
|
-
result.years = Number(result.total.years.toFixed(0));
|
419
|
-
return result;
|
420
|
-
}
|
421
|
-
|
422
|
-
enumurate(unit: TimeUnit = 'day', amount: number = 1): AXDateTime[] {
|
423
|
-
const result: AXDateTime[] = [];
|
424
|
-
let item = this._startTime.clone();
|
425
|
-
while (item.compare(this._endTime, unit) < 1) {
|
426
|
-
if (!result.some(c => c.equal(item, unit))) {
|
427
|
-
result.push(item);
|
428
|
-
}
|
429
|
-
item = item.add(unit, amount)
|
430
|
-
}
|
431
|
-
return result;
|
432
|
-
}
|
433
|
-
|
434
|
-
includes(value: AXDateTime, unit: TimeUnit = 'day'): boolean {
|
435
|
-
// TODO: ??
|
436
|
-
return true;
|
437
|
-
}
|
438
|
-
|
439
|
-
// getViewCompaire(view) {
|
440
|
-
// switch (view) {
|
441
|
-
// case 'day':
|
442
|
-
// return 'YMD';
|
443
|
-
// case 'month':
|
444
|
-
// return 'YM';
|
445
|
-
// case 'year':
|
446
|
-
// return 'Y';
|
447
|
-
// }
|
448
|
-
// }
|
449
|
-
}
|