@morozeckiy/dd-lib 0.1.1 → 0.1.2

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 (227) hide show
  1. package/esm2022/lib/common/lib-common-button.mjs +62 -0
  2. package/esm2022/lib/common/lib-common-input-text.mjs +172 -0
  3. package/esm2022/lib/core/dialog/dialog-config.mjs +15 -0
  4. package/esm2022/lib/core/dialog/dialog-container.component.mjs +40 -0
  5. package/esm2022/lib/core/dialog/dialog-ref.mjs +19 -0
  6. package/esm2022/lib/core/dialog/dialog.service.mjs +106 -0
  7. package/esm2022/lib/core/directives/auto-height.directive.mjs +36 -0
  8. package/esm2022/lib/core/directives/click-outside.directive.mjs +42 -0
  9. package/esm2022/lib/core/directives/counter.directive.mjs +64 -0
  10. package/esm2022/lib/core/directives/declension.directive.mjs +40 -0
  11. package/esm2022/lib/core/directives/resize-textarea.directive.mjs +26 -0
  12. package/esm2022/lib/core/directives/triangle.directive.mjs +75 -0
  13. package/esm2022/lib/core/index.mjs +26 -0
  14. package/esm2022/lib/core/pipes/filter-tabs.pipe.mjs +31 -0
  15. package/esm2022/lib/core/pipes/filter.pipe.mjs +49 -0
  16. package/esm2022/lib/core/pipes/highlight.pipe.mjs +23 -0
  17. package/esm2022/lib/core/pipes/reverse.pipe.mjs +17 -0
  18. package/esm2022/lib/core/pipes/safe.pipe.mjs +34 -0
  19. package/esm2022/lib/core/services/date.service.mjs +113 -0
  20. package/esm2022/lib/core/services/destroy.service.mjs +15 -0
  21. package/esm2022/lib/core/services/fetcher.service.mjs +92 -0
  22. package/esm2022/lib/core/services/interceptors.service.mjs +27 -0
  23. package/esm2022/lib/core/services/svg-icons.service.mjs +26 -0
  24. package/esm2022/lib/core/services/theme-constructor.service.mjs +64 -0
  25. package/esm2022/lib/core/services/validators.service.mjs +73 -0
  26. package/esm2022/lib/core/tools.mjs +128 -0
  27. package/esm2022/lib/core/tooltip/tooltip.component.mjs +27 -0
  28. package/esm2022/lib/core/tooltip/tooltip.directive.mjs +137 -0
  29. package/esm2022/lib/lib-accordion/lib-accordion.component.mjs +15 -0
  30. package/esm2022/lib/lib-back-button/lib-back-button.component.mjs +37 -0
  31. package/esm2022/lib/lib-button/lib-button.component.mjs +30 -0
  32. package/esm2022/lib/lib-calendar/lib-calendar.component.mjs +222 -0
  33. package/esm2022/lib/lib-card/lib-card.component.mjs +34 -0
  34. package/esm2022/lib/lib-checkbox/lib-checkbox.component.mjs +66 -0
  35. package/esm2022/lib/lib-comment-input/lib-comment-input.component.mjs +20 -0
  36. package/esm2022/lib/lib-file-upload/lib-file-upload.component.mjs +34 -0
  37. package/esm2022/lib/lib-filter-button/lib-filter-button.component.mjs +42 -0
  38. package/esm2022/lib/lib-image-loader/lib-image-loader.component.mjs +14 -0
  39. package/esm2022/lib/lib-input/lib-input.component.mjs +55 -0
  40. package/esm2022/lib/lib-loader/lib-loader.component.mjs +16 -0
  41. package/esm2022/lib/lib-period/lib-period.component.mjs +114 -0
  42. package/esm2022/lib/lib-radio/lib-radio.component.mjs +76 -0
  43. package/esm2022/lib/lib-search-input/lib-search-input.component.mjs +91 -0
  44. package/esm2022/lib/lib-select/lib-select.component.mjs +137 -0
  45. package/esm2022/lib/lib-skeleton/lib-skeleton.component.mjs +45 -0
  46. package/esm2022/lib/lib-sort/lib-sort.component.mjs +44 -0
  47. package/esm2022/lib/lib-step/lib-step.component.mjs +19 -0
  48. package/esm2022/lib/lib-svg/lib-svg.component.mjs +75 -0
  49. package/esm2022/lib/lib-svg-icon/lib-svg-icon.component.mjs +55 -0
  50. package/esm2022/lib/lib-tabs-fragment/lib-tabs-fragment.component.mjs +79 -0
  51. package/esm2022/lib/lib-textarea/lib-textarea.component.mjs +50 -0
  52. package/esm2022/lib/toast/toast-base/toast-base.component.mjs +29 -0
  53. package/esm2022/lib/toast/toast-placeholder/toast-placeholder.component.mjs +29 -0
  54. package/esm2022/lib/toast/toast.service.mjs +124 -0
  55. package/esm2022/lib/utils/decorators.mjs +102 -0
  56. package/esm2022/morozeckiy-dd-lib.mjs +5 -0
  57. package/esm2022/public-api.mjs +35 -0
  58. package/fesm2022/morozeckiy-dd-lib.mjs +3004 -0
  59. package/fesm2022/morozeckiy-dd-lib.mjs.map +1 -0
  60. package/index.d.ts +5 -0
  61. package/lib/common/lib-common-button.d.ts +20 -0
  62. package/lib/common/lib-common-input-text.d.ts +53 -0
  63. package/lib/core/dialog/dialog-config.d.ts +14 -0
  64. package/lib/core/dialog/dialog-container.component.d.ts +18 -0
  65. package/lib/core/dialog/dialog-ref.d.ts +18 -0
  66. package/lib/core/dialog/dialog.service.d.ts +28 -0
  67. package/lib/core/directives/auto-height.directive.d.ts +11 -0
  68. package/lib/core/directives/click-outside.directive.d.ts +11 -0
  69. package/lib/core/directives/counter.directive.d.ts +11 -0
  70. package/lib/core/directives/declension.directive.d.ts +13 -0
  71. package/lib/core/directives/resize-textarea.directive.d.ts +10 -0
  72. package/lib/core/directives/triangle.directive.d.ts +16 -0
  73. package/lib/core/index.d.ts +20 -0
  74. package/lib/core/pipes/filter-tabs.pipe.d.ts +7 -0
  75. package/lib/core/pipes/filter.pipe.d.ts +12 -0
  76. package/lib/core/pipes/highlight.pipe.d.ts +7 -0
  77. package/lib/core/pipes/reverse.pipe.d.ts +7 -0
  78. package/lib/core/pipes/safe.pipe.d.ts +10 -0
  79. package/lib/core/services/date.service.d.ts +41 -0
  80. package/lib/core/services/destroy.service.d.ts +8 -0
  81. package/lib/core/services/fetcher.service.d.ts +29 -0
  82. package/lib/core/services/interceptors.service.d.ts +12 -0
  83. package/lib/core/services/svg-icons.service.d.ts +9 -0
  84. package/lib/core/services/theme-constructor.service.d.ts +27 -0
  85. package/lib/core/services/validators.service.d.ts +18 -0
  86. package/lib/core/tools.d.ts +16 -0
  87. package/lib/core/tooltip/tooltip.component.d.ts +12 -0
  88. package/lib/core/tooltip/tooltip.directive.d.ts +22 -0
  89. package/lib/lib-accordion/lib-accordion.component.d.ts +8 -0
  90. package/lib/lib-back-button/lib-back-button.component.d.ts +13 -0
  91. package/lib/lib-button/lib-button.component.d.ts +10 -0
  92. package/lib/lib-calendar/lib-calendar.component.d.ts +76 -0
  93. package/lib/lib-card/lib-card.component.d.ts +16 -0
  94. package/lib/lib-checkbox/lib-checkbox.component.d.ts +23 -0
  95. package/lib/lib-comment-input/lib-comment-input.component.d.ts +8 -0
  96. package/lib/lib-file-upload/lib-file-upload.component.d.ts +12 -0
  97. package/lib/lib-filter-button/lib-filter-button.component.d.ts +13 -0
  98. package/lib/lib-image-loader/lib-image-loader.component.d.ts +6 -0
  99. package/lib/lib-input/lib-input.component.d.ts +13 -0
  100. package/lib/lib-loader/lib-loader.component.d.ts +6 -0
  101. package/lib/lib-period/lib-period.component.d.ts +41 -0
  102. package/lib/lib-radio/lib-radio.component.d.ts +25 -0
  103. package/lib/lib-search-input/lib-search-input.component.d.ts +29 -0
  104. package/lib/lib-select/lib-select.component.d.ts +30 -0
  105. package/lib/lib-skeleton/lib-skeleton.component.d.ts +16 -0
  106. package/lib/lib-sort/lib-sort.component.d.ts +18 -0
  107. package/lib/lib-step/lib-step.component.d.ts +7 -0
  108. package/{src/lib/lib-svg/lib-svg.component.ts → lib/lib-svg/lib-svg.component.d.ts} +38 -66
  109. package/lib/lib-svg-icon/lib-svg-icon.component.d.ts +18 -0
  110. package/lib/lib-tabs-fragment/lib-tabs-fragment.component.d.ts +29 -0
  111. package/lib/lib-textarea/lib-textarea.component.d.ts +13 -0
  112. package/lib/toast/toast-base/toast-base.component.d.ts +21 -0
  113. package/lib/toast/toast-placeholder/toast-placeholder.component.d.ts +12 -0
  114. package/lib/toast/toast.service.d.ts +35 -0
  115. package/lib/utils/decorators.d.ts +4 -0
  116. package/package.json +16 -3
  117. package/public-api.d.ts +30 -0
  118. package/ekgip-dd-lib-0.0.1.tgz +0 -0
  119. package/ng-package.json +0 -8
  120. package/src/lib/common/lib-common-button.ts +0 -34
  121. package/src/lib/common/lib-common-input-text.ts +0 -154
  122. package/src/lib/core/dialog/dialog-config.ts +0 -19
  123. package/src/lib/core/dialog/dialog-container.component.ts +0 -38
  124. package/src/lib/core/dialog/dialog-ref.ts +0 -28
  125. package/src/lib/core/dialog/dialog.service.ts +0 -144
  126. package/src/lib/core/directives/auto-height.directive.ts +0 -29
  127. package/src/lib/core/directives/click-outside.directive.ts +0 -33
  128. package/src/lib/core/directives/counter.directive.ts +0 -54
  129. package/src/lib/core/directives/declension.directive.ts +0 -29
  130. package/src/lib/core/directives/resize-textarea.directive.ts +0 -16
  131. package/src/lib/core/directives/triangle.directive.ts +0 -56
  132. package/src/lib/core/index.ts +0 -27
  133. package/src/lib/core/pipes/filter-tabs.pipe.ts +0 -25
  134. package/src/lib/core/pipes/filter.pipe.ts +0 -36
  135. package/src/lib/core/pipes/highlight.pipe.ts +0 -17
  136. package/src/lib/core/pipes/reverse.pipe.ts +0 -11
  137. package/src/lib/core/pipes/safe.pipe.ts +0 -37
  138. package/src/lib/core/services/date.service.ts +0 -153
  139. package/src/lib/core/services/destroy.service.ts +0 -10
  140. package/src/lib/core/services/fetcher.service.ts +0 -109
  141. package/src/lib/core/services/interceptors.service.ts +0 -26
  142. package/src/lib/core/services/svg-icons.service.ts +0 -25
  143. package/src/lib/core/services/theme-constructor.service.ts +0 -68
  144. package/src/lib/core/services/validators.service.ts +0 -73
  145. package/src/lib/core/tools.ts +0 -159
  146. package/src/lib/core/tooltip/tooltip.component.html +0 -10
  147. package/src/lib/core/tooltip/tooltip.component.scss +0 -59
  148. package/src/lib/core/tooltip/tooltip.component.ts +0 -27
  149. package/src/lib/core/tooltip/tooltip.directive.ts +0 -137
  150. package/src/lib/core/utils.ts +0 -28
  151. package/src/lib/lib-accordion/lib-accordion.component.html +0 -15
  152. package/src/lib/lib-accordion/lib-accordion.component.scss +0 -23
  153. package/src/lib/lib-accordion/lib-accordion.component.ts +0 -17
  154. package/src/lib/lib-back-button/lib-back-button.component.html +0 -4
  155. package/src/lib/lib-back-button/lib-back-button.component.scss +0 -3
  156. package/src/lib/lib-back-button/lib-back-button.component.ts +0 -31
  157. package/src/lib/lib-button/lib-button.component.html +0 -30
  158. package/src/lib/lib-button/lib-button.component.scss +0 -89
  159. package/src/lib/lib-button/lib-button.component.ts +0 -33
  160. package/src/lib/lib-calendar/lib-calendar.component.html +0 -64
  161. package/src/lib/lib-calendar/lib-calendar.component.scss +0 -88
  162. package/src/lib/lib-calendar/lib-calendar.component.ts +0 -227
  163. package/src/lib/lib-card/lib-card.component.html +0 -23
  164. package/src/lib/lib-card/lib-card.component.scss +0 -64
  165. package/src/lib/lib-card/lib-card.component.ts +0 -32
  166. package/src/lib/lib-checkbox/lib-checkbox.component.html +0 -15
  167. package/src/lib/lib-checkbox/lib-checkbox.component.scss +0 -80
  168. package/src/lib/lib-checkbox/lib-checkbox.component.ts +0 -67
  169. package/src/lib/lib-comment-input/lib-comment-input.component.html +0 -32
  170. package/src/lib/lib-comment-input/lib-comment-input.component.scss +0 -28
  171. package/src/lib/lib-comment-input/lib-comment-input.component.ts +0 -20
  172. package/src/lib/lib-file-upload/lib-file-upload.component.html +0 -14
  173. package/src/lib/lib-file-upload/lib-file-upload.component.scss +0 -3
  174. package/src/lib/lib-file-upload/lib-file-upload.component.ts +0 -26
  175. package/src/lib/lib-filter-button/lib-filter-button.component.html +0 -46
  176. package/src/lib/lib-filter-button/lib-filter-button.component.scss +0 -62
  177. package/src/lib/lib-filter-button/lib-filter-button.component.ts +0 -45
  178. package/src/lib/lib-image-loader/lib-image-loader.component.html +0 -17
  179. package/src/lib/lib-image-loader/lib-image-loader.component.scss +0 -6
  180. package/src/lib/lib-image-loader/lib-image-loader.component.ts +0 -16
  181. package/src/lib/lib-input/lib-input.component.html +0 -32
  182. package/src/lib/lib-input/lib-input.component.scss +0 -72
  183. package/src/lib/lib-input/lib-input.component.ts +0 -62
  184. package/src/lib/lib-loader/lib-loader.component.html +0 -29
  185. package/src/lib/lib-loader/lib-loader.component.scss +0 -26
  186. package/src/lib/lib-loader/lib-loader.component.ts +0 -13
  187. package/src/lib/lib-period/lib-period.component.html +0 -41
  188. package/src/lib/lib-period/lib-period.component.scss +0 -77
  189. package/src/lib/lib-period/lib-period.component.ts +0 -131
  190. package/src/lib/lib-radio/lib-radio.component.html +0 -22
  191. package/src/lib/lib-radio/lib-radio.component.scss +0 -113
  192. package/src/lib/lib-radio/lib-radio.component.ts +0 -78
  193. package/src/lib/lib-search-input/lib-search-input.component.html +0 -48
  194. package/src/lib/lib-search-input/lib-search-input.component.scss +0 -86
  195. package/src/lib/lib-search-input/lib-search-input.component.ts +0 -94
  196. package/src/lib/lib-select/lib-select.component.html +0 -83
  197. package/src/lib/lib-select/lib-select.component.scss +0 -130
  198. package/src/lib/lib-select/lib-select.component.ts +0 -152
  199. package/src/lib/lib-skeleton/lib-skeleton.component.html +0 -11
  200. package/src/lib/lib-skeleton/lib-skeleton.component.scss +0 -36
  201. package/src/lib/lib-skeleton/lib-skeleton.component.ts +0 -41
  202. package/src/lib/lib-sort/lib-sort.component.html +0 -21
  203. package/src/lib/lib-sort/lib-sort.component.scss +0 -21
  204. package/src/lib/lib-sort/lib-sort.component.ts +0 -52
  205. package/src/lib/lib-step/lib-step.component.html +0 -4
  206. package/src/lib/lib-step/lib-step.component.scss +0 -23
  207. package/src/lib/lib-step/lib-step.component.ts +0 -14
  208. package/src/lib/lib-svg/lib-svg.component.html +0 -15
  209. package/src/lib/lib-svg/lib-svg.component.scss +0 -81
  210. package/src/lib/lib-svg-icon/lib-svg-icon.component.css +0 -0
  211. package/src/lib/lib-svg-icon/lib-svg-icon.component.ts +0 -58
  212. package/src/lib/lib-tabs-fragment/lib-tabs-fragment.component.html +0 -12
  213. package/src/lib/lib-tabs-fragment/lib-tabs-fragment.component.scss +0 -19
  214. package/src/lib/lib-tabs-fragment/lib-tabs-fragment.component.ts +0 -88
  215. package/src/lib/lib-textarea/lib-textarea.component.html +0 -37
  216. package/src/lib/lib-textarea/lib-textarea.component.scss +0 -77
  217. package/src/lib/lib-textarea/lib-textarea.component.ts +0 -49
  218. package/src/lib/toast/toast-base/toast-base.component.html +0 -7
  219. package/src/lib/toast/toast-base/toast-base.component.scss +0 -44
  220. package/src/lib/toast/toast-base/toast-base.component.ts +0 -38
  221. package/src/lib/toast/toast-placeholder/toast-placeholder.component.ts +0 -20
  222. package/src/lib/toast/toast.service.ts +0 -130
  223. package/src/lib/utils/decorators.ts +0 -124
  224. package/src/public-api.ts +0 -35
  225. package/tsconfig.lib.json +0 -14
  226. package/tsconfig.lib.prod.json +0 -10
  227. package/tsconfig.spec.json +0 -14
@@ -1,56 +0,0 @@
1
- import { Directive, ElementRef, Input, OnInit, Renderer2 } from '@angular/core';
2
-
3
- @Directive({
4
- standalone: true,
5
- selector: '[ddTriangle]',
6
- })
7
- export class TriangleDirective implements OnInit {
8
- @Input() public width = 16;
9
- @Input() public height = 16;
10
- @Input() public fill = '#fff';
11
- @Input() public stroke = '#fff';
12
- @Input() public points = '0,8 4,0 8,8';
13
- @Input() public drTriangle: 'top' | 'left' | 'right' | 'bottom' | 'top-left' = 'left';
14
-
15
- constructor(private rdr: Renderer2, private el: ElementRef) {}
16
-
17
- public ngOnInit(): void {
18
- setTimeout(() => {
19
- const option = this.el.nativeElement.getBoundingClientRect();
20
- let left = option.width / 2 - this.width / 2;
21
- let top = -this.height / 2;
22
- if (this.drTriangle === 'left') {
23
- this.points = '8,0 0,8 8,16';
24
- left = -this.width / 2;
25
- top = option.height / 2 - this.width / 2;
26
- }
27
- if (this.drTriangle === 'right') {
28
- this.points = '8,0 16,8 8,16';
29
- left = option.width - this.width / 2 - 2;
30
- top = option.height / 2 - this.width;
31
- }
32
- if (this.drTriangle === 'bottom') {
33
- this.points = '16,8 8,16 0,8';
34
- top = option.height - this.height / 2 - 2;
35
- }
36
- if (this.drTriangle === 'top-left') {
37
- left = 46 - this.width / 2;
38
- }
39
- const svg = this.rdr.createElement('svg', 'svg');
40
- this.rdr.setAttribute(svg, 'width', `${this.width}`);
41
- this.rdr.setAttribute(svg, 'height', `${this.height}`);
42
- this.rdr.setStyle(svg, 'width', `${this.width}px`);
43
- this.rdr.setStyle(svg, 'height', `${this.height}px`);
44
- this.rdr.setStyle(svg, 'position', 'absolute');
45
- this.rdr.setStyle(svg, 'fill', this.fill);
46
- this.rdr.setStyle(svg, 'stroke', this.stroke);
47
- this.rdr.setStyle(svg, 'top', `${top}px`);
48
- this.rdr.setStyle(svg, 'left', `${left}px`);
49
- this.rdr.setStyle(svg, 'box-shadow', `0 14px 64px -4px #18274B0F, 0px 8px 22px -6px #18274B0F`);
50
- const polyline = this.rdr.createElement('polyline', 'svg');
51
- this.rdr.setAttribute(polyline, 'points', this.points);
52
- this.rdr.appendChild(svg, polyline);
53
- this.rdr.appendChild(this.el.nativeElement, svg);
54
- });
55
- }
56
- }
@@ -1,27 +0,0 @@
1
- // services
2
- export * from './services/theme-constructor.service'
3
- export * from './services/date.service'
4
- export * from './services/svg-icons.service'
5
- export * from './services/destroy.service'
6
- export * from './services/interceptors.service'
7
- export * from './services/validators.service'
8
- export * from './services/fetcher.service'
9
- // pipes
10
- export * from './pipes/filter.pipe'
11
- export * from './pipes/highlight.pipe'
12
- export * from './pipes/safe.pipe'
13
- export * from './pipes/reverse.pipe'
14
- export * from './pipes/filter-tabs.pipe'
15
-
16
- // directives
17
- export * from './directives/auto-height.directive'
18
- export * from './directives/counter.directive'
19
- export * from './directives/declension.directive'
20
- export * from './directives/click-outside.directive'
21
- export * from './directives/resize-textarea.directive'
22
- export * from './tooltip/tooltip.directive'
23
- export * from './tooltip/tooltip.component'
24
- // export * from './directives/triangle.directive'
25
- // dialog
26
-
27
- export * from './dialog/dialog.service'
@@ -1,25 +0,0 @@
1
- import { Pipe, PipeTransform } from '@angular/core';
2
-
3
- @Pipe({
4
- name: 'filterTabs',
5
- standalone: true,
6
- })
7
- export class FilterTabsPipe implements PipeTransform {
8
- public transform(arr: any[] | null, tab?: number | null | undefined): any[] {
9
- if (arr) {
10
- return arr.filter(v => {
11
- if (tab === 0) {
12
- return [1, 2].indexOf(v.status.id) !== -1;
13
- }
14
- if (tab === 1) {
15
- return [3, 4].indexOf(v.status.id) !== -1;
16
- }
17
- if (tab === 2) {
18
- return [6].indexOf(v.status.id) !== -1;
19
- }
20
- return arr;
21
- });
22
- }
23
- return [];
24
- }
25
- }
@@ -1,36 +0,0 @@
1
- import { Pipe, PipeTransform } from '@angular/core';
2
- import { getProperty } from '../tools';
3
-
4
- @Pipe({
5
- name: 'filter',
6
- standalone: true,
7
- })
8
- export class FilterPipe implements PipeTransform {
9
- public transform(value: any[], args?: number): any {
10
- if (value && value.length) {
11
- return value.filter((item, i) => i === args);
12
- }
13
- }
14
- }
15
-
16
- @Pipe({
17
- name: 'filterByKey',
18
- standalone: true,
19
- })
20
- export class FilterByKeyPipe<T> implements PipeTransform {
21
- public transform(arr: any, fn: any): any[] {
22
- if (!arr?.length) {
23
- return arr;
24
- }
25
- if (typeof fn === 'function') {
26
- return arr.filter(fn);
27
- } else if (fn?.length) {
28
- const [key, value] = fn;
29
- return arr.filter((item: any) => getProperty(item, key) === value);
30
- } else if (fn) {
31
- return arr.filter((item: any) => item === fn);
32
- } else {
33
- return arr;
34
- }
35
- }
36
- }
@@ -1,17 +0,0 @@
1
- import { Pipe, PipeTransform } from '@angular/core';
2
- import { log } from '@angular-devkit/build-angular/src/builders/ssr-dev-server';
3
-
4
- @Pipe({
5
- name: 'highlight',
6
- standalone: true,
7
- })
8
- export class HighlightPipe implements PipeTransform {
9
- public transform(name: string, val?: string): string {
10
- if (val) {
11
- const re = new RegExp(val, 'gi');
12
- return name.toString().replace(re, `<span style="color: #07B700">$&</span>`);
13
- } else {
14
- return name;
15
- }
16
- }
17
- }
@@ -1,11 +0,0 @@
1
- import { Pipe, PipeTransform } from '@angular/core';
2
-
3
- @Pipe({
4
- name: 'reverse',
5
- standalone: true,
6
- })
7
- export class ReversePipe implements PipeTransform {
8
- public transform(value: any[], sort: string): any[] {
9
- return sort === 'asc' ? value : value.reverse();
10
- }
11
- }
@@ -1,37 +0,0 @@
1
- import { Pipe, PipeTransform } from '@angular/core';
2
- import {
3
- DomSanitizer,
4
- SafeHtml,
5
- SafeResourceUrl,
6
- SafeScript,
7
- SafeStyle,
8
- SafeUrl,
9
- } from '@angular/platform-browser';
10
-
11
- @Pipe({
12
- name: 'safe',
13
- standalone: true,
14
- })
15
- export class SafePipe implements PipeTransform {
16
- constructor(protected sanitizer: DomSanitizer) {}
17
-
18
- public transform(
19
- value: string,
20
- type: string,
21
- ): SafeHtml | SafeStyle | SafeScript | SafeUrl | SafeResourceUrl {
22
- switch (type) {
23
- case 'html':
24
- return this.sanitizer.bypassSecurityTrustHtml(value);
25
- case 'style':
26
- return this.sanitizer.bypassSecurityTrustStyle(value);
27
- case 'script':
28
- return this.sanitizer.bypassSecurityTrustScript(value);
29
- case 'url':
30
- return this.sanitizer.bypassSecurityTrustUrl(value);
31
- case 'resourceUrl':
32
- return this.sanitizer.bypassSecurityTrustResourceUrl(value);
33
- default:
34
- throw new Error(`Invalid safe type specified: ${type}`);
35
- }
36
- }
37
- }
@@ -1,153 +0,0 @@
1
- import { Injectable } from '@angular/core';
2
- import { format } from 'date-fns';
3
-
4
- export declare type GetDateMethod = () => Date;
5
-
6
- export declare type PeriodName = 'day' | 'week' | 'month' | 'month_3' | 'half_year' | 'year' | 'calendar';
7
-
8
- export declare interface GetDateBy {
9
- day?: GetDateMethod;
10
- week?: GetDateMethod;
11
- month?: GetDateMethod;
12
- month_3?: GetDateMethod;
13
- half_year?: GetDateMethod;
14
- year?: GetDateMethod;
15
- calendar?: GetDateMethod;
16
- }
17
-
18
- export declare type DateTypes = keyof GetDateBy;
19
-
20
- export declare interface TimeDate {
21
- time: string;
22
- }
23
-
24
- export declare interface CommonDateData {
25
- title: string;
26
- active: boolean;
27
- name: PeriodName;
28
- visible: string[];
29
- }
30
-
31
- export declare type PeriodMenuDate = TimeDate & CommonDateData;
32
-
33
- export const DEFAULT_FORMAT = 'yyyy-MM-dd';
34
- const DEFAULT_COMMON_DATE_DATA = {
35
- active: false,
36
- visible: ['all'],
37
- };
38
-
39
- export interface IDaysInMonth {
40
- prevDays: number[];
41
- days: number[];
42
- lastDays: number[];
43
- }
44
-
45
- @Injectable({ providedIn: 'root' }) /** сервис для обработки дат */
46
- export class DateService {
47
- private commonDateDataBy: Record<DateTypes, CommonDateData> = {
48
- day: {
49
- ...DEFAULT_COMMON_DATE_DATA,
50
- title: 'за день',
51
- name: 'day',
52
- },
53
- week: {
54
- ...DEFAULT_COMMON_DATE_DATA,
55
- title: 'за неделю',
56
- name: 'week',
57
- },
58
- month: {
59
- ...DEFAULT_COMMON_DATE_DATA,
60
- title: 'за месяц',
61
- name: 'month',
62
- },
63
- month_3: {
64
- ...DEFAULT_COMMON_DATE_DATA,
65
- title: 'за 3 месяца',
66
- name: 'month_3',
67
- },
68
- half_year: {
69
- ...DEFAULT_COMMON_DATE_DATA,
70
- title: 'за полгода',
71
- name: 'half_year',
72
- },
73
- year: {
74
- ...DEFAULT_COMMON_DATE_DATA,
75
- title: 'за год',
76
- name: 'year',
77
- },
78
- calendar: {
79
- active: false,
80
- visible: [],
81
- name: 'calendar',
82
- title: '',
83
- },
84
- };
85
-
86
- private getDateBy: GetDateBy = {
87
- day: () => new Date(new Date().setDate(new Date().getDate() - 1)),
88
- week: () => new Date(new Date().setDate(new Date().getDate() - 7)),
89
- month: () => new Date(new Date().setMonth(new Date().getMonth() - 1)),
90
- month_3: () => new Date(new Date().setMonth(new Date().getMonth() - 3)),
91
- half_year: () => new Date(new Date().setMonth(new Date().getMonth() - 6)),
92
- year: () => new Date(new Date().setFullYear(new Date().getFullYear() - 1)),
93
- };
94
-
95
- public getFormattedDate(dateType: keyof GetDateBy, f: string = DEFAULT_FORMAT): string {
96
- const date = this.getDateBy[dateType] || this.getDateBy.day;
97
- return format(date!(), f);
98
- }
99
-
100
- public getPeriodMenuDate(dateType: DateTypes, f?: string): TimeDate & CommonDateData {
101
- return {
102
- time: this.getFormattedDate(dateType, f),
103
- ...this.commonDateDataBy[dateType],
104
- };
105
- }
106
-
107
- public getPeriodMenuDateRange(dateTypes: DateTypes[], f?: string): PeriodMenuDate[] {
108
- return dateTypes.map(dateType => this.getPeriodMenuDate(dateType, f));
109
- }
110
-
111
- public getPeriodTime(name: string) {
112
- const period = this.getPeriodMenu();
113
- return period.find(p => p.name === name) || period[0];
114
- }
115
-
116
- public getPeriodMenu(activePeriodName: DateTypes = 'month'): PeriodMenuDate[] {
117
- const arr: DateTypes[] = ['day', 'week', 'month', 'month_3', 'half_year', 'year'];
118
-
119
- const periodMenus = this.getPeriodMenuDateRange(arr);
120
- const activePeriod = periodMenus.find(p => p.name === activePeriodName) || periodMenus[0];
121
-
122
- activePeriod.active = true;
123
- return periodMenus;
124
- }
125
-
126
- public getDaysInMonth(month: number, year: number): IDaysInMonth {
127
- const date = new Date(year, month, 1);
128
- const datePrev = new Date(year, month, 0);
129
- const days = [];
130
- const prevDays = [];
131
- while (date.getMonth() === month) {
132
- days.push(date.getDay());
133
- date.setDate(date.getDate() + 1);
134
- }
135
-
136
- const needFirstDays = days[0] === 1 ? 0 : days[0] === 0 ? 6 : days[0] - 1;
137
- const firstDays = [...Array(needFirstDays)].map(() => 0);
138
- const m = month === 0 ? 12 : month;
139
- while (datePrev.getMonth() === m - 1 && firstDays.length !== prevDays.length) {
140
- prevDays.push(datePrev.getDate());
141
- datePrev.setDate(datePrev.getDate() - 1);
142
- }
143
-
144
- const needLastDays = days[days.length - 1] === 0 ? 0 : 7 - days[days.length - 1];
145
- const lastDays = [...Array(needLastDays)].map((_d, i) => ++i);
146
-
147
- return {
148
- prevDays: prevDays.reverse(),
149
- days: days.map((_d, i) => ++i),
150
- lastDays,
151
- };
152
- }
153
- }
@@ -1,10 +0,0 @@
1
- import { Injectable, OnDestroy } from '@angular/core';
2
- import { Subject } from 'rxjs';
3
-
4
- @Injectable()
5
- export class DestroyService extends Subject<void> implements OnDestroy {
6
- public ngOnDestroy(): void {
7
- this.next();
8
- this.complete();
9
- }
10
- }
@@ -1,109 +0,0 @@
1
- import {HttpClient, HttpHeaders, HttpParams} from '@angular/common/http';
2
- import {Inject, Injectable} from '@angular/core';
3
-
4
- import {Observable, of} from 'rxjs';
5
- import {switchMap} from 'rxjs/operators';
6
- import {isArray} from "@angular/compiler-cli/src/ngtsc/annotations/common";
7
-
8
- export interface HttpIResponse<T> {
9
- error: string;
10
- errorCode: string;
11
- message: null | string;
12
- redirect: null | string;
13
- systemMessage: null | string;
14
- result: 'OK' | 'ERROR' | 'FAIL';
15
- value: T;
16
- }
17
-
18
- type PayloadMethod = 'post' | 'put' | 'get' | 'delete';
19
-
20
- @Injectable({providedIn: 'root'}) /** сервис обработки запросов к api */
21
- export class FetcherService {
22
- // private apiUrl = 'api';
23
- private readonly payloadMethods: string[] = ['post', 'put'];
24
-
25
- constructor(private http: HttpClient, @Inject('apiUrl') private apiUrl: string = 'api') {
26
- }
27
-
28
- public get<R>(urlParts: string, options: any = {}, urlId?: string | number): Observable<R> {
29
- urlParts = urlId ? urlParts.replace(/{[^}]+}/g, urlId.toString()) : urlParts;
30
- const url: string = urlParts ? [this.apiUrl].concat(urlParts).join('/') : this.apiUrl;
31
- let params = new HttpParams();
32
- for (const key of Object.keys(options)) {
33
- if (options[key] != null) {
34
- if (options[key].length && isArray(options[key])) {
35
- options[key].forEach((f: string | number | boolean) => {
36
- params = params.append(key, f);
37
- });
38
- } else {
39
- params = params.append(key, options[key]);
40
- }
41
- }
42
- }
43
- return this.request('get', url, {params});
44
- }
45
-
46
- public post<R>(urlParts: string[] | string, data?: any, options: any = {}): Observable<R> {
47
- const url: string = [this.apiUrl].concat(urlParts).join('/');
48
- if (options?.params) {
49
- let params = new HttpParams();
50
- for (const key of Object.keys(options.params)) {
51
- if (options.params[key] != null) {
52
- params = params.append(key, options.params[key]);
53
- }
54
- }
55
- options.params = params;
56
- }
57
- return this.request('post', url, options, data);
58
- }
59
-
60
- public put<R>(urlParts: string[] | string, options: any = {}, data: any): Observable<any> {
61
- const url: string = [this.apiUrl].concat(urlParts).join('/');
62
- return this.request('put', url, options, data);
63
- }
64
-
65
- public delete<R>(urlParts: string[] | string, options: any = {}): Observable<R> {
66
- const url: string = [this.apiUrl].concat(urlParts).join('/');
67
- return this.request('delete', url, options);
68
- }
69
-
70
- /** перегоняем объкты в форм дату*/
71
- public createFormData(form: { [x: string]: any }) {
72
- const formData: FormData = new FormData();
73
- Object.keys(form).forEach((item: string) => {
74
- formData.append(item, form[item]);
75
- });
76
- return formData;
77
- }
78
-
79
- private request<R>(method: PayloadMethod, url: string, options: any, data?: any): Observable<R> {
80
- if (options.headers) {
81
- options.headers = new HttpHeaders(options.headers);
82
- }
83
- let request: Observable<any>;
84
- options.withCredentials = true;
85
-
86
- if (this.payloadMethods.includes(method)) {
87
- request = this.http[method as 'post' | 'put'](url, data, options);
88
- } else {
89
- request = (this.http as any)[method](url, options);
90
- }
91
-
92
- return request.pipe(
93
- switchMap((response: any) => {
94
- if (response && response.error) {
95
- console.error(`API error with status: ${response.status}`);
96
- console.error(response.error);
97
- }
98
- return of(response);
99
- }),
100
- // catchError((error: any) => {
101
- // console.timeEnd('Время выполнения - ' + url);
102
- // if (error.status !== 403) {
103
- // console.log(error);
104
- // }
105
- // return of(error);
106
- // }),
107
- );
108
- }
109
- }
@@ -1,26 +0,0 @@
1
- import {HttpErrorResponse, HttpEvent, HttpHandler, HttpInterceptor, HttpRequest,} from '@angular/common/http';
2
- import {Injectable} from '@angular/core';
3
- import {Observable} from 'rxjs';
4
- import {catchError} from 'rxjs/operators';
5
- import {Router} from '@angular/router';
6
-
7
- @Injectable()
8
- export class InterceptorsService implements HttpInterceptor {
9
-
10
- constructor(private router: Router) {
11
- }
12
-
13
- /** перехватчик состояния запросов к api */
14
- public intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
15
- return next.handle(req).pipe(
16
- catchError(err => {
17
- if (err instanceof HttpErrorResponse) {
18
- if (err.status >= 500) {
19
- this.router.navigate(['tech-works']);
20
- }
21
- }
22
- throw err;
23
- }),
24
- );
25
- }
26
- }
@@ -1,25 +0,0 @@
1
- import { Injectable } from '@angular/core';
2
- import {SvgIcon} from "../../../../assets/svg-icons";
3
-
4
- @Injectable({
5
- providedIn: 'root'
6
- })
7
- export class SvgIconsService {
8
-
9
- private registry = new Map<string, string>();
10
-
11
- registerIcons(icons: SvgIcon[]): void {
12
- icons.forEach((icon: SvgIcon) => this.registry.set(icon.name, icon.data));
13
- }
14
-
15
- getIcon(iconName: string): string | undefined {
16
- if (!this.registry.has(iconName)) {
17
- // eslint-disable-next-line no-console
18
- console.warn(
19
- `We could not find the icon with name ${ iconName }, did you add it to the icon registry?`,
20
- );
21
- }
22
-
23
- return this.registry.get(iconName);
24
- }
25
- }
@@ -1,68 +0,0 @@
1
- import { Injectable, Renderer2, RendererFactory2 } from '@angular/core';
2
- import { BehaviorSubject, Observable } from 'rxjs';
3
-
4
- @Injectable({
5
- providedIn: 'root',
6
- })
7
- export class ThemeConstructorService {
8
- public get getTheme(): boolean {
9
- return this.themeConfigurator.theme;
10
- }
11
- public isDarkTheme!: Observable<boolean>;
12
- private readonly renderer: Renderer2;
13
- private themeConfigurator!: ThemeConfigurator;
14
-
15
- constructor(private rendererFactory: RendererFactory2) {
16
- this.renderer = rendererFactory.createRenderer(null, null);
17
- }
18
-
19
- public setThemeConfiguratorRoot(document: Document): void {
20
- this.themeConfigurator = new ThemeConfigurator(document, this.renderer);
21
- this.isDarkTheme = this.themeConfigurator.isDarkThemeObservable;
22
- }
23
-
24
- public changeTheme(darkMode: boolean): void {
25
- this.themeConfigurator.setTheme(darkMode);
26
- }
27
-
28
- public switchTheme(): void {
29
- this.themeConfigurator.switchTheme();
30
- }
31
- }
32
-
33
- export class ThemeConfigurator {
34
- public set theme(value: boolean) {
35
- localStorage.setItem('theme', value.toString());
36
- this.isDarkTheme$.next(value);
37
- }
38
-
39
- public get theme(): boolean {
40
- return this.isDarkTheme$.getValue();
41
- }
42
-
43
- private isDarkTheme$: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);
44
- public isDarkThemeObservable: Observable<boolean> = this.isDarkTheme$.asObservable();
45
-
46
- constructor(private document: Document, private renderer: Renderer2) {
47
- this.isDarkThemeObservable.subscribe(ref => this.setTheme(ref));
48
- const theme = localStorage.getItem('theme');
49
-
50
- if (!theme) {
51
- this.theme = false;
52
- } else {
53
- this.theme = localStorage.getItem('theme') !== 'false';
54
- }
55
- }
56
-
57
- public switchTheme(): void {
58
- this.theme = !this.theme;
59
- }
60
-
61
- public setTheme(isDarkMode: boolean): void {
62
- if (!this.document) {
63
- return;
64
- }
65
- const hostClass = isDarkMode ? 'theme-dark' : 'theme-light';
66
- this.renderer.setAttribute(this.document.body, 'class', hostClass);
67
- }
68
- }
@@ -1,73 +0,0 @@
1
- import { Injectable } from '@angular/core';
2
- import { AbstractControl, ValidationErrors, Validators } from '@angular/forms';
3
- import { Observable, of } from 'rxjs';
4
-
5
- @Injectable({ providedIn: 'root' })
6
- export class ValidatorsService {
7
- constructor() {}
8
-
9
- /** валидатор совпадения пароллей. При использовании указывать поля pswd & confPswd*/
10
- public static passEqual(el: AbstractControl): ValidationErrors | null {
11
- if (!el.get('pswd') || !el.get('oldPswd')) {
12
- return null;
13
- }
14
- if (!(el.dirty || el.touched) || el.get('pswd')?.value === el.get('confPswd')?.value) {
15
- return null;
16
- }
17
- return {
18
- passEqual: 'Пароли не совпадают',
19
- };
20
- }
21
-
22
- public static passNotEqual(el: AbstractControl): ValidationErrors | null {
23
- if (!el.get('pswd') || !el.get('oldPswd')) {
24
- return null;
25
- }
26
- if (!(el.dirty || el.touched) || el.get('pswd')?.value !== el.get('oldPswd')?.value) {
27
- return null;
28
- }
29
- return {
30
- passNotEqual: 'Старый и новый пароли не должны совпадать',
31
- };
32
- }
33
-
34
- public static wrongLogin(): ValidationErrors {
35
- return {
36
- wrongMail: 'Неверный логин!',
37
- };
38
- }
39
-
40
- public static wrongLoginOrPswd(): ValidationErrors {
41
- return {
42
- wrongLogin: 'Неверный логин или пароль!',
43
- };
44
- }
45
-
46
- public static existLogin(): ValidationErrors {
47
- return {
48
- mailErr: 'Пользователь с таким адресом уже зарегистрирован.',
49
- };
50
- }
51
-
52
- /** валидатор имени*/
53
- public static getNameValid() {
54
- return [Validators.required, Validators.pattern(/^[A-ZА-Яa-zа-яЁё0-9- .]+$/), Validators.maxLength(35)];
55
- }
56
-
57
- /** валидатор email*/
58
- public static getMailValid(el?: AbstractControl): Observable<ValidationErrors | null> {
59
- const pattern =
60
- /^([A-Za-z0-9+_-]+\.)*[A-Za-z0-9+_-]+@[A-Za-z0-9+_-]+(\.[A-Za-z0-9+_-]+)*\.[A-Za-z]{2,6}$/;
61
- if (!el?.value) {
62
- return of({
63
- required: 'Это поле обязательно для заполнения',
64
- });
65
- } else if (!pattern.test(el.value) && el.value !== 'test_admin' && el.value !== 'admin') {
66
- return of({
67
- email: 'Некорректно введены данные',
68
- });
69
- } else {
70
- return of(null);
71
- }
72
- }
73
- }