@acorex/core 5.1.2 → 5.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. package/README.md +2 -23
  2. package/karma.conf.js +32 -0
  3. package/ng-package.json +10 -0
  4. package/package.json +13 -38
  5. package/src/lib/classes/base-page.class.ts +29 -0
  6. package/src/lib/classes/color.class.ts +61 -0
  7. package/src/lib/classes/datetime.class.ts +373 -0
  8. package/src/lib/classes/menu.class.ts +37 -0
  9. package/src/lib/classes/navigator.class.ts +5 -0
  10. package/src/lib/classes/popup.class.ts +14 -0
  11. package/src/lib/classes/promise.class.ts +25 -0
  12. package/src/lib/classes/sectionlist.class.ts +8 -0
  13. package/src/lib/classes/select.class.ts +7 -0
  14. package/src/lib/core.module.ts +21 -0
  15. package/src/lib/error/error.class.ts +4 -0
  16. package/src/lib/error/error.module.ts +13 -0
  17. package/src/lib/error/error.service.ts +23 -0
  18. package/src/lib/error/index.ts +3 -0
  19. package/src/lib/events/keyboard.ts +5 -0
  20. package/src/lib/http/http-error.class.ts +7 -0
  21. package/src/lib/http/http-events.interceptor.ts +14 -0
  22. package/src/lib/http/http-request.class.ts +14 -0
  23. package/src/lib/http/http-result.class.ts +34 -0
  24. package/src/lib/http/http.module.ts +25 -0
  25. package/src/lib/http/http.service.ts +159 -0
  26. package/src/lib/locale/en.json +255 -0
  27. package/src/lib/locale/fa.json +244 -0
  28. package/src/lib/pipe/datetime.pipe.ts +20 -0
  29. package/src/lib/pipe/htmlToText.pipe.ts +18 -0
  30. package/src/lib/platform/index.ts +1 -0
  31. package/src/lib/platform/platform.service.ts +211 -0
  32. package/src/lib/services/config.ts +36 -0
  33. package/src/lib/services/event.service.ts +31 -0
  34. package/src/lib/services/navigator.service.ts +8 -0
  35. package/src/lib/services/storage.service.ts +11 -0
  36. package/src/lib/translator/translator.module.ts +19 -0
  37. package/src/lib/translator/translator.pipe.ts +22 -0
  38. package/src/lib/translator/translator.service.ts +19 -0
  39. package/src/lib/translator/translator.ts +31 -0
  40. package/src/lib/utils/array/array-util.ts +140 -0
  41. package/src/lib/utils/html/html-util.ts +264 -0
  42. package/src/lib/utils/html/html.module.ts +11 -0
  43. package/src/lib/utils/math/math-util.ts +5 -0
  44. package/src/lib/utils/object/object-util.ts +87 -0
  45. package/src/lib/utils/render/on-demand-preload-strategy.service.ts +25 -0
  46. package/src/lib/utils/render/render.service.ts +110 -0
  47. package/src/lib/utils/render/rendering.module.ts +25 -0
  48. package/src/lib/utils/scroll/scroll.directive.ts +35 -0
  49. package/src/lib/utils/scroll/scroll.module.ts +11 -0
  50. package/src/lib/utils/separator/separator.module.ts +11 -0
  51. package/src/lib/utils/separator/separator.pipe.ts +27 -0
  52. package/src/public-api.ts +53 -0
  53. package/src/test.ts +28 -0
  54. package/tsconfig.lib.json +25 -0
  55. package/tsconfig.lib.prod.json +6 -0
  56. package/tsconfig.spec.json +18 -0
  57. package/tslint.json +17 -0
  58. package/acorex-core.d.ts +0 -5
  59. package/config/ax-preset.js +0 -182
  60. package/esm2020/acorex-core.mjs +0 -5
  61. package/esm2020/lib/config/configs.mjs +0 -29
  62. package/esm2020/lib/core.module.mjs +0 -18
  63. package/esm2020/lib/dateTime/datetime.class.mjs +0 -295
  64. package/esm2020/lib/dateTime/datetime.module.mjs +0 -33
  65. package/esm2020/lib/dateTime/datetime.pipe.mjs +0 -26
  66. package/esm2020/lib/dateTime/georgian.calendar.mjs +0 -189
  67. package/esm2020/lib/dateTime/index.mjs +0 -6
  68. package/esm2020/lib/dateTime/jalali.calendar.mjs +0 -359
  69. package/esm2020/lib/events/event.service.mjs +0 -36
  70. package/esm2020/lib/events/index.mjs +0 -2
  71. package/esm2020/lib/hotkeys/hotkeys.service.mjs +0 -37
  72. package/esm2020/lib/hotkeys/index.mjs +0 -2
  73. package/esm2020/lib/platform/index.mjs +0 -2
  74. package/esm2020/lib/platform/platform.service.mjs +0 -138
  75. package/esm2020/lib/translation/index.mjs +0 -4
  76. package/esm2020/lib/translation/translation.module.mjs +0 -18
  77. package/esm2020/lib/translation/translator.mjs +0 -42
  78. package/esm2020/lib/translation/translator.pipe.mjs +0 -15
  79. package/esm2020/lib/utils/drawing-util.mjs +0 -27
  80. package/esm2020/lib/utils/index.mjs +0 -5
  81. package/esm2020/lib/utils/object-util.mjs +0 -39
  82. package/esm2020/lib/utils/safe.pipe.mjs +0 -30
  83. package/esm2020/lib/utils/string-util.mjs +0 -19
  84. package/esm2020/public-api.mjs +0 -13
  85. package/fesm2015/acorex-core.mjs +0 -1332
  86. package/fesm2015/acorex-core.mjs.map +0 -1
  87. package/fesm2020/acorex-core.mjs +0 -1329
  88. package/fesm2020/acorex-core.mjs.map +0 -1
  89. package/lib/config/configs.d.ts +0 -9
  90. package/lib/core.module.d.ts +0 -7
  91. package/lib/dateTime/datetime.class.d.ts +0 -100
  92. package/lib/dateTime/datetime.module.d.ts +0 -8
  93. package/lib/dateTime/datetime.pipe.d.ts +0 -8
  94. package/lib/dateTime/georgian.calendar.d.ts +0 -20
  95. package/lib/dateTime/index.d.ts +0 -5
  96. package/lib/dateTime/jalali.calendar.d.ts +0 -35
  97. package/lib/events/event.service.d.ts +0 -9
  98. package/lib/events/index.d.ts +0 -1
  99. package/lib/hotkeys/hotkeys.service.d.ts +0 -17
  100. package/lib/hotkeys/index.d.ts +0 -1
  101. package/lib/platform/index.d.ts +0 -1
  102. package/lib/platform/platform.service.d.ts +0 -25
  103. package/lib/translation/index.d.ts +0 -3
  104. package/lib/translation/translation.module.d.ts +0 -7
  105. package/lib/translation/translator.d.ts +0 -11
  106. package/lib/translation/translator.pipe.d.ts +0 -7
  107. package/lib/utils/drawing-util.d.ts +0 -17
  108. package/lib/utils/index.d.ts +0 -4
  109. package/lib/utils/object-util.d.ts +0 -4
  110. package/lib/utils/safe.pipe.d.ts +0 -10
  111. package/lib/utils/string-util.d.ts +0 -6
  112. package/public-api.d.ts +0 -12
@@ -0,0 +1,244 @@
1
+ {
2
+ "common": {
3
+ "search": "جستجو",
4
+ "yes": "بله",
5
+ "no": "خیر",
6
+ "confirm": "تایید",
7
+ "okay": "تایید",
8
+ "cancel": "انصراف",
9
+ "remove": "حذف",
10
+ "edit": "ویرایش",
11
+ "configs": "پیکربندی",
12
+ "noDataFound": "موردی یافت نشد!",
13
+ "searching": "درحال جستجو ...",
14
+ "save-as": "ذخیره به عنوان ...",
15
+ "title": "عنوان",
16
+ "description": "توضیحات",
17
+ "name": "نام",
18
+ "uniquename": "نام شناسه یکتا",
19
+ "size": "اندازه",
20
+ "add-item": "افزودن",
21
+ "color": "رنگ",
22
+ "display": "نمایش",
23
+ "value": "مقدار",
24
+ "min-value": "مقدار کمینه",
25
+ "max-value": "مقدار بیشینه",
26
+ "refresh-rate": "نرخ بروز رسانی",
27
+ "refresh": "بروز رسانی",
28
+ "reload": "بارگزاری مجدد",
29
+ "condition":"شرط",
30
+ "next":"بعدی",
31
+ "prev":"قبلی"
32
+ },
33
+ "dateTime": {
34
+ "weekdaysShort": {
35
+ "sun": "ی",
36
+ "mon": "د",
37
+ "tue": "س",
38
+ "wed": "چ",
39
+ "thu": "پ",
40
+ "fri": "ج",
41
+ "sat": "ش"
42
+ },
43
+ "dayTime": {
44
+ "am": "ق ظ",
45
+ "pm": "ب ظُ",
46
+ "m": ".ظ",
47
+ "a": "ق",
48
+ "p": "ب"
49
+ },
50
+ "today": "امروز",
51
+ "duration": {
52
+ "format_second": "{0} ثانیه",
53
+ "format_minute": "{0} دقیقه"
54
+ }
55
+ },
56
+ "queryBuilder": {
57
+ "contains": "شامل",
58
+ "not-contains":"به غیر از",
59
+ "contains-all":"شامل همه",
60
+ "start-with": "شروع شود با",
61
+ "end-with": "پایان با",
62
+ "equal": "برابر با",
63
+ "not-equal": "نا برابر با",
64
+ "null": " خالی باشد",
65
+ "not-null": "خالی نباشد",
66
+ "greater-than": "بزرگ تر",
67
+ "gt": "بزرگ تر",
68
+ "greater-than-equal": "بزرگتر مساوی",
69
+ "gte": "بزرگتر مساوی",
70
+ "less-than": "کوچکتر",
71
+ "lt": "کوچکتر",
72
+ "less-than-equal": "کوچکتر مساوی",
73
+ "lte": "کوچکتر مساوی",
74
+ "true": "true",
75
+ "false": "false"
76
+ },
77
+ "validation": {
78
+ "messages": {
79
+ "required": "مقدار این فیلد الزامی می باشد!",
80
+ "email": "این آدرس ایمیل معتبر نمی باشد!",
81
+ "phone": "این شماره تلفن معتبر نمی باشد!"
82
+ }
83
+ },
84
+ "dataGrid": {
85
+ "page": "صفحه",
86
+ "more": "بیشتر",
87
+ "to": "تا",
88
+ "of": "از",
89
+ "next": "بعدی",
90
+ "last": "آخرین",
91
+ "first": "اولین",
92
+ "previous": "قبلی",
93
+ "loadingOoo": "... لطفا منتظر بمانید",
94
+ "selectAll": "انتخاب همه",
95
+ "searchOoo": "جستجو ...",
96
+ "blanks": "جای خالی",
97
+ "filterOoo": "فیلتر ...",
98
+ "equals": "برابر",
99
+ "notEqual": "نابرابر",
100
+ "lessThan": "کوچکتر از",
101
+ "greaterThan": "بزرگتر از",
102
+ "lessThanOrEqual": "کوچکتر مساوی",
103
+ "greaterThanOrEqual": "بزرکتر مساوی",
104
+ "inRange": "در محدوده",
105
+ "inRangeStart": "تا",
106
+ "inRangeEnd": "از",
107
+ "contains": "شامل",
108
+ "notContains": "شامل نمی شود",
109
+ "startsWith": "شروع شود با",
110
+ "endsWith": "پایان با",
111
+ "andCondition": "و",
112
+ "orCondition": "یا",
113
+ "applyFilter": "اعمال",
114
+ "resetFilter": "تنظیم مجدد فیلتر",
115
+ "clearFilter": "پاک کردن فیلتر",
116
+ "group": "گروه",
117
+ "columns": "ستون ها",
118
+ "filters": "فیاتر ها",
119
+ "groups": "گروه ها ",
120
+ "values": "مقدار ها",
121
+ "enabled": "فعال شده",
122
+ "pinColumn": "سنجاق",
123
+ "groupBy": "دسته بندی بر اساس",
124
+ "ungroupBy": "حذف دسته بندی",
125
+ "resetColumns": "تنظیم مجدد ستون ها",
126
+ "expandAll": "باز کردن همه",
127
+ "collapseAll": "بستن همه",
128
+ "toolPanel": "پنل ابزار",
129
+ "export": "خروجی",
130
+ "csvExport": "csv خروجی",
131
+ "excelExport": "خروجی اکسل (.xlsx)",
132
+ "excelXmlExport": "خروجی اکسل (.xml)",
133
+ "chartRange": "محدوده نمودار",
134
+ "columnChart": "ستون",
135
+ "groupedColumn": "دسته بندی شده",
136
+ "stackedColumn": "انباشته",
137
+ "normalizedColumn": "ستون نرمال",
138
+ "barChart": "نمودار میله ای",
139
+ "groupedBar": "دسته بندی شده",
140
+ "stackedBar": "انباشته",
141
+ "normalizedBar": "نوار ",
142
+ "pie": "پای",
143
+ "doughnut": "Doughnut",
144
+ "line": "خط",
145
+ "xyChart": "X Y (پراکندگی)",
146
+ "scatter": "پراکندگی",
147
+ "bubble": "حباب",
148
+ "areaChart": "حوزه",
149
+ "area": "حوزه",
150
+ "stackedArea": "انباشته ",
151
+ "normalizedArea": "100% انباشته",
152
+ "histogramChart": "هیستوگرام",
153
+ "pinLeft": "سنجاق چپ",
154
+ "pinRight": "سنجاق راست",
155
+ "noPin": "حذف سنجاق",
156
+ "sum": "مجموع",
157
+ "min": "مینیمم",
158
+ "max": "ماکزیمم",
159
+ "none": "هیچ",
160
+ "count": "شمردن",
161
+ "avg": "میانگین",
162
+ "filteredRows": "فیلتر شده",
163
+ "selectedRows": "انتخاب شده",
164
+ "totalRows": "مجموع ردیف ها",
165
+ "totalAndFilteredRows": "سطر ها",
166
+ "copy": "کپی",
167
+ "copyWithHeaders": "کپی با هدر ها",
168
+ "ctrlC": "Ctrl C",
169
+ "paste": "جایگزینی",
170
+ "ctrlV": "Ctrl V",
171
+ "pivotChartTitle": "نمودار محوری",
172
+ "rangeChartTitle": "نمودار محدوده",
173
+ "settings": "تنظیمات",
174
+ "data": "تاریخ",
175
+ "format": "قالب",
176
+ "categories": "دسته بندی ها",
177
+ "series": "Series",
178
+ "xyValues": "X Y مقادیر",
179
+ "paired": "حالت زوج",
180
+ "axis": "محور",
181
+ "color": "رنگ",
182
+ "thickness": "ضخامت",
183
+ "xType": "X Type",
184
+ "automatic": "خودکار",
185
+ "category": "دسته بندی",
186
+ "number": "عدد",
187
+ "time": "زمان",
188
+ "xRotation": "X چرخش",
189
+ "yRotation": "Y چرخش",
190
+ "ticks": "نمادها",
191
+ "width": "عرض",
192
+ "length": "طول",
193
+ "padding": "لایه گزاری",
194
+ "chart": "جدول",
195
+ "title": "عنوان",
196
+ "background": "زمینه",
197
+ "font": "فونت",
198
+ "top": "بالا",
199
+ "right": "راست",
200
+ "bottom": "پایین",
201
+ "left": "چپ",
202
+ "labels": "برچسب",
203
+ "size": "اندازه",
204
+ "minSize": "حداقل اندازه",
205
+ "maxSize": "بیشترین اندازه",
206
+ "position": "موقعیت",
207
+ "markerSize": "اندازه نشانگر",
208
+ "callout": "فراخوان",
209
+ "markers": "نشانه گرها",
210
+ "shadow": "سایه",
211
+ "blur": "محو شدن",
212
+ "xOffset": "X انحراف",
213
+ "yOffset": "Y انحراف",
214
+ "lineWidth": "عرض خط",
215
+ "normal": "نرمال",
216
+ "italic": "Italic",
217
+ "boldItalic": "Bold Italic",
218
+ "predefined": "Predefined",
219
+ "fillOpacity": "Fill Opacity",
220
+ "strokeOpacity": "Line Opacity",
221
+ "histogramBinCount": "Bin Count",
222
+ "columnGroup": "ستون",
223
+ "barGroup": "Bar",
224
+ "pieGroup": "Pie",
225
+ "lineGroup": "خط",
226
+ "areaGroup": "حوزه",
227
+ "histogramGroup": "هیستوگرام",
228
+ "groupedColumnTooltip": "دسته بندی شده",
229
+ "stackedColumnTooltip": "Stacked",
230
+ "normalizedColumnTooltip": "100% Stacked",
231
+ "groupedBarTooltip": "دسته بندی شده",
232
+ "stackedBarTooltip": "Stacked",
233
+ "pieTooltip": "Pie",
234
+ "doughnutTooltip": "Doughnut",
235
+ "lineTooltip": "خط",
236
+ "groupedAreaTooltip": "گروه بندی شده",
237
+ "stackedAreaTooltip": "Stacked",
238
+ "scatterTooltip": "Scatter",
239
+ "bubbleTooltip": "حباب",
240
+ "histogramTooltip": "هیستوگرام",
241
+ "autosizeThiscolumn": "تنظیم اندازه ستون ",
242
+ "autosizeAllColumns": "تنظیم اندازه همه ستون ها"
243
+ }
244
+ }
@@ -0,0 +1,20 @@
1
+ import { PipeTransform, Pipe } from '@angular/core';
2
+ import { AXDateTime } from '../classes/datetime.class';
3
+
4
+ @Pipe({ name: 'dt' })
5
+ export class AXDateTimePipe implements PipeTransform {
6
+ constructor() { }
7
+
8
+ transform(value: any, format?: string): string {
9
+ const date: AXDateTime = AXDateTime.convert(value);
10
+ if (value == null) {
11
+ return '';
12
+ }
13
+ if (!format) {
14
+ return date.toString();
15
+ }
16
+ else {
17
+ return date.format(format);
18
+ }
19
+ }
20
+ }
@@ -0,0 +1,18 @@
1
+ import { Pipe, PipeTransform } from '@angular/core';
2
+
3
+ @Pipe({ name: 'html2text' })
4
+ export class AXHtmlToTextPipe implements PipeTransform {
5
+ transform(value: string) {
6
+ if (value) {
7
+ const regexHtml = /<\/?[^>]+>/gi;
8
+ const regexNbsp = /&nbsp;/gi;
9
+ const regexAmp = /&amp;/gi;
10
+ return value
11
+ .replace(regexHtml, '')
12
+ .replace(regexNbsp, '')
13
+ .replace(regexAmp, '');
14
+ } else {
15
+ return '';
16
+ }
17
+ }
18
+ }
@@ -0,0 +1 @@
1
+ export * from './platform.service';
@@ -0,0 +1,211 @@
1
+ import { Injectable } from "@angular/core";
2
+ import { from, fromEvent, Subject } from "rxjs";
3
+ import { debounceTime, distinctUntilChanged } from "rxjs/operators";
4
+
5
+
6
+ export type AXPlatforms = 'Android' | 'Desktop' | 'iOS' | 'Mobile';
7
+ export type AXBrowsers = 'Chrome' | 'Safari' | 'Edge' | 'Firefox' | 'Opera' | 'MSIE';
8
+ export type AXTechnologies = 'PWA' | 'Hybrid' | 'Electron';
9
+
10
+
11
+
12
+
13
+ const isChrome = (win: Window): boolean =>
14
+ testUserAgent(win, /Chrome/i);
15
+
16
+ const isFirefox = (win: Window): boolean =>
17
+ testUserAgent(win, /Firefox/i);
18
+
19
+ const isEdge = (win: Window): boolean =>
20
+ testUserAgent(win, /Edge/i);
21
+
22
+ const isSafari = (win: Window): boolean =>
23
+ testUserAgent(win, /Safari/i);
24
+
25
+ const isOpera = (win: Window): boolean =>
26
+ testUserAgent(win, /Opera/i) || testUserAgent(win, /OPR/i);
27
+
28
+ const isMSIE = (win: Window): boolean =>
29
+ testUserAgent(win, /MSIE/i) || testUserAgent(win, /Trident/i);
30
+
31
+
32
+ const isMobileWeb = (win: Window): boolean =>
33
+ isMobile(win) && !isHybrid(win);
34
+
35
+ const isIpad = (win: Window) => {
36
+ // iOS 12 and below
37
+ if (testUserAgent(win, /iPad/i)) {
38
+ return true;
39
+ }
40
+
41
+ // iOS 13+
42
+ if (testUserAgent(win, /Macintosh/i) && isMobile(win)) {
43
+ return true;
44
+ }
45
+
46
+ return false;
47
+ };
48
+
49
+ const isIphone = (win: Window) =>
50
+ testUserAgent(win, /iPhone/i);
51
+
52
+ const isIOS = (win: Window) =>
53
+ testUserAgent(win, /iPhone|iPod/i) || isIpad(win);
54
+
55
+ const isAndroid = (win: Window) =>
56
+ testUserAgent(win, /android|sink/i);
57
+
58
+ const isAndroidTablet = (win: Window) => {
59
+ return isAndroid(win) && !testUserAgent(win, /mobile/i);
60
+ };
61
+
62
+ const isPhablet = (win: Window) => {
63
+ const width = win.innerWidth;
64
+ const height = win.innerHeight;
65
+ const smallest = Math.min(width, height);
66
+ const largest = Math.max(width, height);
67
+
68
+ return (smallest > 390 && smallest < 520) &&
69
+ (largest > 620 && largest < 800);
70
+ };
71
+
72
+ const isTablet = (win: Window) => {
73
+ const width = win.innerWidth;
74
+ const height = win.innerHeight;
75
+ const smallest = Math.min(width, height);
76
+ const largest = Math.max(width, height);
77
+
78
+ return (
79
+ isIpad(win) ||
80
+ isAndroidTablet(win) ||
81
+ (
82
+ (smallest > 460 && smallest < 820) &&
83
+ (largest > 780 && largest < 1400)
84
+ )
85
+ );
86
+ };
87
+
88
+ const isMobile = (win: Window) =>
89
+ matchMedia(win, '(any-pointer:coarse)');
90
+
91
+ const isDesktop = (win: Window) =>
92
+ !isMobile(win);
93
+
94
+ const isHybrid = (win: Window) =>
95
+ isCordova(win) || isCapacitorNative(win);
96
+
97
+ const isCordova = (win: any): boolean =>
98
+ !!(win['cordova'] || win['phonegap'] || win['PhoneGap']);
99
+
100
+ const isCapacitorNative = (win: any): boolean => {
101
+ const capacitor = win['Capacitor'];
102
+ return !!(capacitor && capacitor.isNative);
103
+ };
104
+
105
+ const isElectron = (win: Window): boolean =>
106
+ testUserAgent(win, /electron/i);
107
+
108
+ const isPWA = (win: Window): boolean =>
109
+ !!(win.matchMedia('(display-mode: standalone)').matches || (win.navigator as any).standalone);
110
+
111
+ export const testUserAgent = (win: Window, expr: RegExp) =>
112
+ expr.test(win.navigator.userAgent);
113
+
114
+ const matchMedia = (win: Window, query: string): boolean =>
115
+ win.matchMedia(query).matches;
116
+
117
+
118
+ const PLATFORMS_MAP = {
119
+ 'Android': isAndroid,
120
+ 'iOS': isIOS,
121
+ 'Desktop': isDesktop,
122
+ 'Mobile': isMobile,
123
+ 'Chrome': isChrome,
124
+ 'Firefox': isFirefox,
125
+ 'Safari': isSafari,
126
+ 'Edge': isEdge,
127
+ 'Opera': isOpera,
128
+ 'Hybrid': isHybrid,
129
+ 'PWA': isPWA,
130
+ 'Electron': isElectron,
131
+ };
132
+
133
+
134
+ export class AXPlatformEvent {
135
+ nativeEvent: UIEvent | Event;
136
+ source: AXPlatform
137
+ }
138
+
139
+ @Injectable({
140
+ providedIn: 'platform',
141
+ })
142
+ export class AXPlatform {
143
+ resize: Subject<AXPlatformEvent> = new Subject<AXPlatformEvent>();
144
+ click: Subject<AXPlatformEvent> = new Subject<AXPlatformEvent>()
145
+ scroll: Subject<AXPlatformEvent> = new Subject<AXPlatformEvent>()
146
+
147
+ isRtl(): boolean {
148
+ return document.dir == 'rtl' || document.body.dir == 'rtl' || document.body.style.direction == 'rtl';
149
+ }
150
+
151
+
152
+ isLandscape(): boolean {
153
+ return window.innerHeight < window.innerWidth;
154
+ }
155
+
156
+ isPortrate(): boolean {
157
+ return !this.isLandscape()
158
+ }
159
+
160
+ is(name: AXPlatforms | AXBrowsers | AXTechnologies): boolean {
161
+ return PLATFORMS_MAP[name](window) || false;
162
+ }
163
+
164
+
165
+ switchDarkMode() {
166
+ const _html = document.getElementsByTagName("html")[0];
167
+ _html.classList.add('ax-dark')
168
+
169
+ }
170
+
171
+ switchLightMode() {
172
+ const _html = document.getElementsByTagName("html")[0];
173
+ _html.classList.remove('ax-dark')
174
+ }
175
+
176
+ private _setFullHeightRatio() {
177
+ document.querySelector<HTMLElement>(':root').style.setProperty('--ax-vh', window.innerHeight / 100 + 'px');
178
+ }
179
+
180
+ constructor() {
181
+
182
+ fromEvent<UIEvent>(window, 'resize')
183
+ .pipe(debounceTime(100))
184
+ .pipe(distinctUntilChanged())
185
+ .subscribe((e) => {
186
+ this.resize.next({
187
+ nativeEvent: e,
188
+ source: this
189
+ });
190
+ //
191
+ this._setFullHeightRatio();
192
+ });
193
+
194
+
195
+ document.addEventListener('click', (e) => {
196
+ this.click.next({
197
+ nativeEvent: e,
198
+ source: this
199
+ });
200
+ }, true)
201
+
202
+ document.addEventListener('scroll', (e) => {
203
+ this.scroll.next({
204
+ nativeEvent: e,
205
+ source: this
206
+ });
207
+ }, true);
208
+ // init functions
209
+ this._setFullHeightRatio();
210
+ }
211
+ }
@@ -0,0 +1,36 @@
1
+ import { Subject, Observable } from 'rxjs';
2
+ import { getPropByPath, setPropByPath } from '../utils/object/object-util';
3
+
4
+ // @dynamic
5
+ export class AXConfig {
6
+ private static dataModel: any = {};
7
+ private static dataChangeSubject = new Subject<any>();
8
+
9
+
10
+ static get onChange(): Observable<any> {
11
+ return AXConfig.dataChangeSubject.asObservable();
12
+ }
13
+
14
+ static set(config: any): any;
15
+ static set(path: string, value?: any): void;
16
+ static set(arg1?: any, arg2?: any) {
17
+
18
+ if (arg1 && typeof arg1 == 'string') {
19
+ setPropByPath(AXConfig.dataModel, arg1, arg2);
20
+ AXConfig.dataChangeSubject.next(AXConfig.dataModel);
21
+ return;
22
+ }
23
+ if (arg1 && typeof arg1 == 'object') {
24
+ Object.assign(AXConfig.dataModel, arg1);
25
+ AXConfig.dataChangeSubject.next(AXConfig.dataModel);
26
+ return;
27
+ }
28
+ if (!arg1 && !arg2) {
29
+ return AXConfig.dataChangeSubject.asObservable();
30
+ }
31
+ }
32
+
33
+ static get(path: string): any {
34
+ return getPropByPath(AXConfig.dataModel, path);
35
+ }
36
+ }
@@ -0,0 +1,31 @@
1
+ import { Injectable } from '@angular/core';
2
+
3
+ @Injectable({ providedIn: 'root' })
4
+ export class AXEventService {
5
+ private list: any[] = [];
6
+
7
+ public broadcast(key: string, options?: any): void {
8
+ const d = this.list.find(c => c.key === key);
9
+ if (d) {
10
+ d.events.forEach(c => {
11
+ c(options);
12
+ });
13
+ }
14
+ }
15
+
16
+ public on(key: string, callback: (options?: any) => void) {
17
+ let d = this.list.find(c => c.key === key);
18
+ if (!d) {
19
+ d = { key, events: [] };
20
+ this.list.push(d);
21
+ }
22
+ d.events.push(callback);
23
+ }
24
+
25
+ public destroy(key: string, callback: (options?: any) => void): void {
26
+ const d = this.list.find(c => c.key === key);
27
+ if (d) {
28
+ d.events = [];
29
+ }
30
+ }
31
+ }
@@ -0,0 +1,8 @@
1
+ import { Injectable } from '@angular/core';
2
+ import { AXNavigatorParam } from '../classes/navigator.class';
3
+
4
+ @Injectable()
5
+ export abstract class AXNavigator {
6
+ abstract navigate(params: AXNavigatorParam);
7
+ abstract popup(params: AXNavigatorParam);
8
+ }
@@ -0,0 +1,11 @@
1
+ import { Injectable } from '@angular/core';
2
+
3
+ @Injectable()
4
+ export class AXStorageService {
5
+ get(key: string): any {
6
+ return localStorage.getItem(key) as any;
7
+ }
8
+ set(key: string, value: any): void {
9
+ localStorage.setItem(key, value as string);
10
+ }
11
+ }
@@ -0,0 +1,19 @@
1
+ import { NgModule } from '@angular/core';
2
+ import { AXTranslatorPipe } from './translator.pipe';
3
+ import * as en from '../locale/en.json';
4
+ import * as fa from '../locale/fa.json';
5
+ import { AXTranslator } from './translator';
6
+
7
+
8
+ @NgModule({
9
+ imports: [],
10
+ exports: [AXTranslatorPipe],
11
+ declarations: [AXTranslatorPipe],
12
+ providers: [],
13
+ })
14
+ export class AXTranslatorModule {
15
+ constructor() {
16
+ AXTranslator.load('en', en);
17
+ AXTranslator.load('fa', fa);
18
+ }
19
+ }
@@ -0,0 +1,22 @@
1
+ import { Pipe, PipeTransform } from '@angular/core';
2
+ import { AXTranslator } from './translator';
3
+
4
+ @Pipe({ name: 'trans', pure: true })
5
+ export class AXTranslatorPipe implements PipeTransform {
6
+
7
+ constructor() { }
8
+
9
+ // transform(value: string, lang?: string): Promise<string> {
10
+ // return new Promise<string>((resolve, reject) => {
11
+ // if (!value) {
12
+ // resolve(value);
13
+ // }
14
+ // resolve(this.translate.get(value, lang));
15
+ // });
16
+
17
+ // }
18
+
19
+ transform(value: string, lang?: string): string {
20
+ return AXTranslator.get(value, lang);
21
+ }
22
+ }
@@ -0,0 +1,19 @@
1
+ import { Injectable } from '@angular/core';
2
+ import { AXTranslator } from './translator';
3
+
4
+ @Injectable({ providedIn: 'platform' })
5
+ export class AXTranslatorService {
6
+
7
+ public load(lang: string, value: any) {
8
+ AXTranslator.load(lang, value);
9
+ }
10
+
11
+ public use(lang: string) {
12
+ AXTranslator.use(lang);
13
+ }
14
+
15
+ public get(key: string, lang?: string): string {
16
+ return AXTranslator.get(lang, lang);
17
+ }
18
+ }
19
+
@@ -0,0 +1,31 @@
1
+ import { Subject, Observable } from 'rxjs';
2
+ import { getPropByPath} from '../utils/object/object-util';
3
+ import merge from 'lodash-es/merge';
4
+
5
+ // @dynamic
6
+ export class AXTranslator {
7
+ private static lang: string = 'en';
8
+ private static dataChangeSubject = new Subject<any>();
9
+
10
+
11
+ static get onChange(): Observable<any> {
12
+ return AXTranslator.dataChangeSubject.asObservable();
13
+ }
14
+
15
+ public static load(lang: string, value: any) {
16
+ if (typeof value === 'object') {
17
+ if (!AXTranslator[`__data__${lang}`]) {
18
+ AXTranslator[`__data__${lang}`] = {};
19
+ }
20
+ AXTranslator[`__data__${lang}`] = merge(AXTranslator[`__data__${lang}`], value);
21
+ }
22
+ }
23
+
24
+ public static use(lang: string) {
25
+ AXTranslator.lang = lang;
26
+ }
27
+
28
+ public static get(key: string, lang?: string): string {
29
+ return getPropByPath(AXTranslator[`__data__${lang || AXTranslator.lang}`], key) || key;
30
+ }
31
+ }