@indice/ng-components 0.2.139 → 0.2.141

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 (228) hide show
  1. package/README.md +4 -4
  2. package/{src/assets/styles/indice-ng-icons-inline.css → _styles.css} +3501 -2286
  3. package/esm2020/indice-ng-components.mjs +5 -0
  4. package/esm2020/lib/controls/avatar-initials/avatar-initials.component.mjs +48 -0
  5. package/esm2020/lib/controls/collapsible-panel/collapsible-panel.component.mjs +20 -0
  6. package/esm2020/lib/controls/date-picker/date-picker.component.mjs +260 -0
  7. package/esm2020/lib/controls/drop-down-menu/drop-down-menu.component.mjs +68 -0
  8. package/esm2020/lib/controls/kpi-tile/kpi-tile.component.mjs +36 -0
  9. package/esm2020/lib/controls/list-view/list-column.component.mjs +25 -0
  10. package/esm2020/lib/controls/list-view/list-details-section.component.mjs +17 -0
  11. package/esm2020/lib/controls/list-view/list-tile.component.mjs +17 -0
  12. package/esm2020/lib/controls/list-view/list-view-empty-state.component.mjs +29 -0
  13. package/esm2020/lib/controls/list-view/list-view.component.mjs +183 -0
  14. package/esm2020/lib/controls/nav-links-list/nav-links-list.component.mjs +37 -0
  15. package/esm2020/lib/controls/notifications-indicator/notifications-indicator.component.mjs +77 -0
  16. package/esm2020/lib/controls/pager/pager.component.mjs +130 -0
  17. package/esm2020/lib/controls/side-pane/side-pane.component.mjs +72 -0
  18. package/esm2020/lib/controls/skeleton-loader/skeleton-loader.component.mjs +25 -0
  19. package/esm2020/lib/controls/toaster/toaster-container.component.mjs +28 -0
  20. package/esm2020/lib/controls/toaster/toaster.component.mjs +31 -0
  21. package/esm2020/lib/controls/toggle/toggle.component.mjs +64 -0
  22. package/esm2020/lib/directives/click-outside.directive.mjs +189 -0
  23. package/esm2020/lib/directives/dynamic-component-host.directive.mjs +17 -0
  24. package/esm2020/lib/helpers/base-list.component.mjs +181 -0
  25. package/esm2020/lib/icons.mjs +32 -0
  26. package/esm2020/lib/layouts/shell/shell-footer/shell-footer.component.mjs +19 -0
  27. package/esm2020/lib/layouts/shell/shell-header/shell-header.component.mjs +135 -0
  28. package/esm2020/lib/layouts/shell/shell-layout/shell-layout.component.mjs +101 -0
  29. package/esm2020/lib/layouts/views/form-layout/form-layout.component.mjs +80 -0
  30. package/esm2020/lib/layouts/views/model-view-layout/model-view-layout.component.mjs +49 -0
  31. package/esm2020/lib/layouts/views/side-view-layout/side-view-layout.component.mjs +98 -0
  32. package/esm2020/lib/layouts/views/view-layout/view-layout.component.mjs +104 -0
  33. package/esm2020/lib/ng-components.module.mjs +221 -0
  34. package/esm2020/lib/pages/auth/auth-callback/auth-callback.component.mjs +30 -0
  35. package/esm2020/lib/pages/auth/auth-renew/auth-renew.component.mjs +31 -0
  36. package/esm2020/lib/pages/auth/logged-out/logged-out.component.mjs +28 -0
  37. package/esm2020/lib/pages/http-status/error/error.component.mjs +17 -0
  38. package/esm2020/lib/pages/http-status/page-not-found/page-not-found.component.mjs +15 -0
  39. package/esm2020/lib/pages/http-status/unauthorized/unauthorized.component.mjs +14 -0
  40. package/esm2020/lib/pipes/address.pipe.mjs +21 -0
  41. package/esm2020/lib/pipes/duration-format.pipe.mjs +64 -0
  42. package/esm2020/lib/services/component-loader/component-loader-options.class.mjs +8 -0
  43. package/esm2020/lib/services/component-loader/component-loader.class.mjs +188 -0
  44. package/esm2020/lib/services/component-loader/component-loader.factory.mjs +32 -0
  45. package/esm2020/lib/services/component-loader/content-ref.class.mjs +13 -0
  46. package/esm2020/lib/services/modal-service/modal-backdrop-component.mjs +44 -0
  47. package/esm2020/lib/services/modal-service/modal-container-component.mjs +126 -0
  48. package/esm2020/lib/services/modal-service/modal-options.class.mjs +35 -0
  49. package/esm2020/lib/services/modal-service/modal-service.mjs +219 -0
  50. package/esm2020/lib/services/modal-service/modal-styles.class.mjs +11 -0
  51. package/esm2020/lib/services/modal-service/modal.class.mjs +27 -0
  52. package/esm2020/lib/services/toaster.service.mjs +24 -0
  53. package/esm2020/lib/tokens.mjs +5 -0
  54. package/esm2020/lib/types.mjs +117 -0
  55. package/esm2020/public-api.mjs +53 -0
  56. package/fesm2015/indice-ng-components.mjs +3268 -0
  57. package/fesm2015/indice-ng-components.mjs.map +1 -0
  58. package/fesm2020/indice-ng-components.mjs +3225 -0
  59. package/fesm2020/indice-ng-components.mjs.map +1 -0
  60. package/indice-ng-components.d.ts +5 -0
  61. package/lib/controls/avatar-initials/avatar-initials.component.d.ts +14 -0
  62. package/lib/controls/collapsible-panel/collapsible-panel.component.d.ts +10 -0
  63. package/lib/controls/date-picker/date-picker.component.d.ts +48 -0
  64. package/lib/controls/drop-down-menu/drop-down-menu.component.d.ts +25 -0
  65. package/lib/controls/kpi-tile/kpi-tile.component.d.ts +13 -0
  66. package/lib/controls/list-view/list-column.component.d.ts +9 -0
  67. package/lib/controls/list-view/list-details-section.component.d.ts +7 -0
  68. package/lib/controls/list-view/list-tile.component.d.ts +7 -0
  69. package/lib/controls/list-view/list-view-empty-state.component.d.ts +11 -0
  70. package/lib/controls/list-view/list-view.component.d.ts +55 -0
  71. package/lib/controls/nav-links-list/nav-links-list.component.d.ts +15 -0
  72. package/lib/controls/notifications-indicator/notifications-indicator.component.d.ts +23 -0
  73. package/lib/controls/pager/pager.component.d.ts +36 -0
  74. package/lib/controls/side-pane/side-pane.component.d.ts +18 -0
  75. package/lib/controls/skeleton-loader/skeleton-loader.component.d.ts +11 -0
  76. package/lib/controls/toaster/toaster-container.component.d.ts +13 -0
  77. package/lib/controls/toaster/toaster.component.d.ts +15 -0
  78. package/lib/controls/toggle/toggle.component.d.ts +19 -0
  79. package/lib/directives/click-outside.directive.d.ts +40 -0
  80. package/lib/directives/dynamic-component-host.directive.d.ts +9 -0
  81. package/lib/helpers/base-list.component.d.ts +42 -0
  82. package/lib/icons.d.ts +30 -0
  83. package/lib/layouts/shell/shell-footer/shell-footer.component.d.ts +8 -0
  84. package/lib/layouts/shell/shell-header/shell-header.component.d.ts +41 -0
  85. package/lib/layouts/shell/shell-layout/shell-layout.component.d.ts +28 -0
  86. package/lib/layouts/views/form-layout/form-layout.component.d.ts +24 -0
  87. package/lib/layouts/views/model-view-layout/model-view-layout.component.d.ts +25 -0
  88. package/lib/layouts/views/side-view-layout/side-view-layout.component.d.ts +28 -0
  89. package/lib/layouts/views/view-layout/view-layout.component.d.ts +31 -0
  90. package/lib/ng-components.module.d.ts +49 -0
  91. package/lib/pages/auth/auth-callback/auth-callback.component.d.ts +13 -0
  92. package/lib/pages/auth/auth-renew/auth-renew.component.d.ts +12 -0
  93. package/lib/pages/auth/logged-out/logged-out.component.d.ts +12 -0
  94. package/lib/pages/http-status/error/error.component.d.ts +8 -0
  95. package/lib/pages/http-status/page-not-found/page-not-found.component.d.ts +8 -0
  96. package/lib/pages/http-status/unauthorized/unauthorized.component.d.ts +8 -0
  97. package/lib/pipes/address.pipe.d.ts +8 -0
  98. package/lib/pipes/duration-format.pipe.d.ts +8 -0
  99. package/lib/services/component-loader/component-loader-options.class.d.ts +30 -0
  100. package/lib/services/component-loader/component-loader.class.d.ts +92 -0
  101. package/lib/services/component-loader/component-loader.factory.d.ts +24 -0
  102. package/lib/services/component-loader/content-ref.class.d.ts +12 -0
  103. package/lib/services/modal-service/modal-backdrop-component.d.ts +20 -0
  104. package/lib/services/modal-service/modal-container-component.d.ts +33 -0
  105. package/lib/services/modal-service/modal-options.class.d.ts +81 -0
  106. package/lib/services/modal-service/modal-service.d.ts +58 -0
  107. package/lib/services/modal-service/modal-styles.class.d.ts +10 -0
  108. package/lib/services/modal-service/modal.class.d.ts +43 -0
  109. package/lib/services/toaster.service.d.ts +11 -0
  110. package/lib/tokens.d.ts +5 -0
  111. package/lib/types.d.ts +153 -0
  112. package/{src/assets/styles/modal.css → modal.css} +157 -157
  113. package/package.json +24 -20
  114. package/{src/public-api.ts → public-api.d.ts} +43 -60
  115. package/CHANGELOG.md +0 -1
  116. package/karma.conf.js +0 -44
  117. package/ng-package.json +0 -10
  118. package/scripts/css-bundle.ts +0 -33
  119. package/src/_styles.css +0 -36
  120. package/src/_tests/utilities.service.spec.ts +0 -16
  121. package/src/assets/styles/avatar-initials.css +0 -37
  122. package/src/assets/styles/base.css +0 -46
  123. package/src/assets/styles/cards.css +0 -71
  124. package/src/assets/styles/collapsible-panel.css +0 -25
  125. package/src/assets/styles/components.css +0 -34
  126. package/src/assets/styles/date-picker.component.css +0 -0
  127. package/src/assets/styles/drop-down-menu.css +0 -50
  128. package/src/assets/styles/form-layout.css +0 -49
  129. package/src/assets/styles/list-view-empty-state.css +0 -0
  130. package/src/assets/styles/list-view.css +0 -64
  131. package/src/assets/styles/model-view-layout.css +0 -45
  132. package/src/assets/styles/nav-links.css +0 -35
  133. package/src/assets/styles/notifications-indicator.component.css +0 -43
  134. package/src/assets/styles/pager.css +0 -29
  135. package/src/assets/styles/shell-layout.css +0 -232
  136. package/src/assets/styles/side-pane.css +0 -46
  137. package/src/assets/styles/side-view-layout.css +0 -58
  138. package/src/assets/styles/toast.css +0 -72
  139. package/src/assets/styles/toggle.css +0 -26
  140. package/src/assets/styles/view-layout.css +0 -58
  141. package/src/lib/controls/avatar-initials/avatar-initials.component.html +0 -3
  142. package/src/lib/controls/avatar-initials/avatar-initials.component.ts +0 -47
  143. package/src/lib/controls/collapsible-panel/collapsible-panel.component.html +0 -15
  144. package/src/lib/controls/collapsible-panel/collapsible-panel.component.ts +0 -16
  145. package/src/lib/controls/date-picker/date-picker.component.html +0 -133
  146. package/src/lib/controls/date-picker/date-picker.component.ts +0 -258
  147. package/src/lib/controls/drop-down-menu/drop-down-menu.component.html +0 -61
  148. package/src/lib/controls/drop-down-menu/drop-down-menu.component.ts +0 -59
  149. package/src/lib/controls/kpi-tile/kpi-tile.component.html +0 -18
  150. package/src/lib/controls/kpi-tile/kpi-tile.component.ts +0 -26
  151. package/src/lib/controls/list-view/list-column.component.ts +0 -10
  152. package/src/lib/controls/list-view/list-details-section.component.ts +0 -8
  153. package/src/lib/controls/list-view/list-tile.component.ts +0 -8
  154. package/src/lib/controls/list-view/list-view-empty-state.component.html +0 -20
  155. package/src/lib/controls/list-view/list-view-empty-state.component.ts +0 -19
  156. package/src/lib/controls/list-view/list-view.component.html +0 -151
  157. package/src/lib/controls/list-view/list-view.component.ts +0 -146
  158. package/src/lib/controls/nav-links-list/nav-links-list.component.html +0 -27
  159. package/src/lib/controls/nav-links-list/nav-links-list.component.ts +0 -25
  160. package/src/lib/controls/notifications-indicator/notifications-indicator.component.html +0 -78
  161. package/src/lib/controls/notifications-indicator/notifications-indicator.component.ts +0 -75
  162. package/src/lib/controls/pager/pager.component.html +0 -33
  163. package/src/lib/controls/pager/pager.component.ts +0 -106
  164. package/src/lib/controls/side-pane/side-pane.component.html +0 -10
  165. package/src/lib/controls/side-pane/side-pane.component.ts +0 -59
  166. package/src/lib/controls/skeleton-loader/skeleton-loader.component.html +0 -112
  167. package/src/lib/controls/skeleton-loader/skeleton-loader.component.ts +0 -20
  168. package/src/lib/controls/toaster/toaster-container.component.html +0 -1
  169. package/src/lib/controls/toaster/toaster-container.component.ts +0 -27
  170. package/src/lib/controls/toaster/toaster.component.html +0 -103
  171. package/src/lib/controls/toaster/toaster.component.ts +0 -26
  172. package/src/lib/controls/toggle/toggle.component.html +0 -15
  173. package/src/lib/controls/toggle/toggle.component.ts +0 -58
  174. package/src/lib/directives/click-outside.directive.ts +0 -196
  175. package/src/lib/directives/dynamic-component-host.directive.ts +0 -7
  176. package/src/lib/directives/screen-size.directive.ts +0 -67
  177. package/src/lib/helpers/base-list.component.ts +0 -204
  178. package/src/lib/icons.ts +0 -39
  179. package/src/lib/layouts/shell/shell-footer/shell-footer.component.html +0 -71
  180. package/src/lib/layouts/shell/shell-footer/shell-footer.component.ts +0 -14
  181. package/src/lib/layouts/shell/shell-header/shell-header.component.html +0 -199
  182. package/src/lib/layouts/shell/shell-header/shell-header.component.ts +0 -111
  183. package/src/lib/layouts/shell/shell-layout/shell-layout.component.html +0 -36
  184. package/src/lib/layouts/shell/shell-layout/shell-layout.component.ts +0 -91
  185. package/src/lib/layouts/views/form-layout/form-layout.component.html +0 -67
  186. package/src/lib/layouts/views/form-layout/form-layout.component.ts +0 -66
  187. package/src/lib/layouts/views/model-view-layout/model-view-layout.component.html +0 -43
  188. package/src/lib/layouts/views/model-view-layout/model-view-layout.component.ts +0 -37
  189. package/src/lib/layouts/views/side-view-layout/side-view-layout.component.html +0 -36
  190. package/src/lib/layouts/views/side-view-layout/side-view-layout.component.ts +0 -67
  191. package/src/lib/layouts/views/view-layout/view-layout.component.html +0 -68
  192. package/src/lib/layouts/views/view-layout/view-layout.component.ts +0 -82
  193. package/src/lib/ng-components.module.ts +0 -135
  194. package/src/lib/pages/auth/auth-callback/auth-callback.component.html +0 -1
  195. package/src/lib/pages/auth/auth-callback/auth-callback.component.ts +0 -22
  196. package/src/lib/pages/auth/auth-renew/auth-renew.component.ts +0 -20
  197. package/src/lib/pages/auth/logged-out/logged-out.component.html +0 -1
  198. package/src/lib/pages/auth/logged-out/logged-out.component.ts +0 -22
  199. package/src/lib/pages/http-status/error/error.component.html +0 -13
  200. package/src/lib/pages/http-status/error/error.component.ts +0 -13
  201. package/src/lib/pages/http-status/page-not-found/page-not-found.component.html +0 -14
  202. package/src/lib/pages/http-status/page-not-found/page-not-found.component.ts +0 -14
  203. package/src/lib/pages/http-status/unauthorized/unauthorized.component.html +0 -15
  204. package/src/lib/pages/http-status/unauthorized/unauthorized.component.ts +0 -11
  205. package/src/lib/pipes/address.pipe.ts +0 -17
  206. package/src/lib/pipes/duration-format.pipe.ts +0 -67
  207. package/src/lib/services/component-loader/component-loader-options.class.ts +0 -31
  208. package/src/lib/services/component-loader/component-loader.class.ts +0 -226
  209. package/src/lib/services/component-loader/component-loader.factory.ts +0 -27
  210. package/src/lib/services/component-loader/content-ref.class.ts +0 -10
  211. package/src/lib/services/interceptors/bad-request.interceptor.ts +0 -34
  212. package/src/lib/services/modal-service/modal-backdrop-component.ts +0 -40
  213. package/src/lib/services/modal-service/modal-container-component.ts +0 -125
  214. package/src/lib/services/modal-service/modal-options.class.ts +0 -92
  215. package/src/lib/services/modal-service/modal-service.ts +0 -237
  216. package/src/lib/services/modal-service/modal-styles.class.ts +0 -11
  217. package/src/lib/services/modal-service/modal.class.ts +0 -45
  218. package/src/lib/services/shell-state-service.service.ts +0 -10
  219. package/src/lib/services/toaster.service.ts +0 -23
  220. package/src/lib/services/utilities.service.ts +0 -40
  221. package/src/lib/tokens.ts +0 -6
  222. package/src/lib/types.ts +0 -210
  223. package/src/test.ts +0 -28
  224. package/tsconfig.lib.json +0 -26
  225. package/tsconfig.lib.prod.json +0 -10
  226. package/tsconfig.spec.json +0 -17
  227. package/tslint.json +0 -17
  228. package/webpack.config.js +0 -36
@@ -1,226 +0,0 @@
1
- import {
2
- ComponentFactoryResolver,
3
- ViewContainerRef,
4
- ComponentFactory,
5
- Type,
6
- ElementRef,
7
- StaticProvider,
8
- TemplateRef,
9
- ComponentRef,
10
- ApplicationRef,
11
- Injector,
12
- } from '@angular/core';
13
- import { Subject } from 'rxjs';
14
- import { ComponentLoaderOptions } from './component-loader-options.class';
15
- import { ContentRef } from './content-ref.class';
16
-
17
- /**
18
- * Provides ways of loading and handling dynamic content.
19
- *
20
- * @remarks
21
- * Do NOT use this directly, create an instance through {@link ComponentLoaderFactory}
22
- * You can use this loader in two ways:
23
- * - Attaches a component to `ViewContainerRef`.
24
- * - Attaches a component to `ViewContainerRef`. The attached component has a `<ng-content>` tag inside its view. The {@link ComponentLoaderOptions.content} will be drawn inside this tag.
25
- *
26
- * @internal
27
- */
28
- export class ComponentLoader<T> {
29
- /**
30
- * Before content is shown event.
31
- */
32
- onBeforeShow = new Subject();
33
- /**
34
- * After show content event.
35
- * @returns The id of newly created component ref.
36
- */
37
- onShown = new Subject();
38
- /**
39
- * Before content is hidden event.
40
- * @returns The instance of attached component;
41
- */
42
- onBeforeHide = new Subject();
43
- /**
44
- * After content is hidden event.
45
- * @returns The id of destroyed component ref.
46
- */
47
- onHidden = new Subject();
48
-
49
- public instance?: T;
50
- public componentRef?: ComponentRef<T>;
51
- private componentFactory?: ComponentFactory<T>;
52
- private container: string | ElementRef | any;
53
- private providers: StaticProvider[] = [];
54
- private contentRef?: ContentRef;
55
- private containerDefaultSelector = 'body';
56
- private innerComponent?: ComponentRef<T>;
57
- constructor(
58
- private vcr: ViewContainerRef | undefined,
59
- private cfr: ComponentFactoryResolver,
60
- private applicationRef: ApplicationRef,
61
- private injector: Injector
62
- ) {}
63
-
64
- /**
65
- * Attaches component.
66
- * @param componentType - The type component to attach.
67
- * @returns Current instance of {@link ComponentLoader}
68
- */
69
- public attach(componentType: Type<T>): ComponentLoader<T> {
70
- this.componentFactory = this.cfr.resolveComponentFactory<T>(componentType);
71
- return this;
72
- }
73
-
74
- /**
75
- * Body will be used in nothing is provided.
76
- * @param container - The element in which dynamic content will be drawn inside to. For string case a query to the dom will be executed to find the element.
77
- * @returns Current instance of {@link ComponentLoader}
78
- */
79
- public to(container?: string | ElementRef): ComponentLoader<T> {
80
- this.container = container || this.container;
81
- return this;
82
- }
83
-
84
- /**
85
- * Adds provider to the providers array. These providers will be injected to the attached component.
86
- *
87
- * @see {@link https://angular.io/guide/glossary#di-token | Injection Token}
88
- *
89
- * @param provider - Provider to inject.
90
- * @returns Current instance of {@link ComponentLoader}
91
- */
92
- public provide(provider: StaticProvider): ComponentLoader<T> {
93
- this.providers.push(provider);
94
- return this;
95
- }
96
-
97
- /**
98
- * Attaches attached component to dom and any dynamic content if provided.
99
- * @remarks
100
- * Also triggers the {@link ComponentLoader.onBeforeShow} and {@link ComponentLoader.onShown} events.
101
- *
102
- * @param options - {@link ComponentLoaderOptions}.
103
- * @returns A reference to the created content.
104
- */
105
- public show(options: ComponentLoaderOptions = {}): ComponentRef<T> | undefined {
106
- if (this.componentRef) {
107
- throw Error('Component is already shown');
108
- }
109
- if (!this.componentFactory) {
110
- throw Error('You must attach a component');
111
- }
112
- this.onBeforeShow.next();
113
-
114
- if (options.content) {
115
- this.contentRef = this.getContentRef(options.content, options.context, options.initialState);
116
- }
117
- this.createComponentAndAttachToView(options);
118
- this.appendContentToContainer();
119
- this.markComponentsForCheck();
120
-
121
- this.onShown.next(options.id);
122
-
123
- return this.componentRef;
124
- }
125
-
126
- /**
127
- * Removes attached component from dom.
128
- * @remarks
129
- * Also triggers the {@link ComponentLoader.onBeforeHide} and {@link ComponentLoader.onHidden} events.
130
- *
131
- * @param id - If provided it is returned through the {@link ComponentLoader.onHidden}.
132
- * @returns Current instance of {@link ComponentLoader}
133
- */
134
- public hide(id?: number | string, result?: any): ComponentLoader<T> {
135
- if (!this.componentRef) {
136
- throw Error('No attached component found to hide');
137
- }
138
-
139
- this.onBeforeHide.next(this.componentRef.instance);
140
-
141
- const componentEl = this.componentRef.location.nativeElement;
142
- componentEl.parentNode.removeChild(componentEl);
143
- if (this.contentRef?.componentRef) {
144
- this.contentRef.componentRef.destroy();
145
- }
146
- if (this.vcr && this.contentRef?.viewRef) {
147
- this.vcr.remove(this.vcr.indexOf(this.contentRef.viewRef));
148
- }
149
- if (this.contentRef?.viewRef) {
150
- this.contentRef.viewRef.destroy();
151
- }
152
- this.contentRef = void 0;
153
- this.componentRef = void 0;
154
-
155
- this.onHidden.next(id ? { id, result } : null);
156
-
157
- return this;
158
- }
159
-
160
- getInnerComponent(): ComponentRef<T> | undefined {
161
- return this.innerComponent;
162
- }
163
-
164
- private markComponentsForCheck() {
165
- if (this.contentRef?.componentRef) {
166
- this.innerComponent = this.contentRef.componentRef.instance;
167
- this.contentRef.componentRef.changeDetectorRef.markForCheck();
168
- this.contentRef.componentRef.changeDetectorRef.detectChanges();
169
- }
170
- this.componentRef!.changeDetectorRef.markForCheck();
171
- this.componentRef!.changeDetectorRef.detectChanges();
172
- }
173
-
174
- private createComponentAndAttachToView(options: ComponentLoaderOptions) {
175
- const injector = Injector.create({
176
- providers: this.providers,
177
- parent: this.injector,
178
- });
179
- this.componentRef = this.componentFactory!.create(injector, this.contentRef?.nodes);
180
- this.applicationRef.attachView(this.componentRef.hostView);
181
- this.instance = this.componentRef.instance;
182
- Object.assign(this.componentRef.instance, options);
183
- }
184
-
185
- private appendContentToContainer() {
186
- if (this.container instanceof ElementRef) {
187
- this.container.nativeElement.appendChild(this.componentRef?.location.nativeElement);
188
- }
189
- if (typeof this.container === 'string' && typeof document !== 'undefined') {
190
- const selectedElement = document.querySelector(this.container) || document.querySelector(this.containerDefaultSelector);
191
- if (!selectedElement) {
192
- return;
193
- }
194
- selectedElement.appendChild(this.componentRef?.location.nativeElement);
195
- }
196
- }
197
-
198
- private getContentRef(content?: string | TemplateRef<any>, context?: any, initialState?: any): ContentRef {
199
- //TemplateRef case
200
- if (content instanceof TemplateRef) {
201
- if (this.vcr) {
202
- const viewRef = this.vcr.createEmbeddedView<TemplateRef<T>>(content, context);
203
- viewRef.markForCheck();
204
- return new ContentRef([viewRef.rootNodes], viewRef);
205
- }
206
- const viewRef = content.createEmbeddedView({});
207
- this.applicationRef.attachView(viewRef);
208
- return new ContentRef([viewRef.rootNodes], viewRef);
209
- }
210
-
211
- //Component case
212
- if (typeof content === 'function') {
213
- const contentCf = this.cfr.resolveComponentFactory(content);
214
- const injector = Injector.create({
215
- providers: this.providers,
216
- parent: this.injector,
217
- });
218
- const componentRef = contentCf.create(injector);
219
- Object.assign(componentRef.instance, initialState);
220
- this.applicationRef.attachView(componentRef.hostView);
221
- return new ContentRef([[componentRef.location.nativeElement]], componentRef.hostView, componentRef);
222
- }
223
-
224
- throw Error('Unsupported content type');
225
- }
226
- }
@@ -1,27 +0,0 @@
1
- import { ApplicationRef, ComponentFactoryResolver, Injectable, Injector, ViewContainerRef } from '@angular/core';
2
- import { ComponentLoader } from './component-loader.class';
3
-
4
- /**
5
- * Use to create instances of {@link ComponentLoader}.
6
- *
7
- * @public
8
- */
9
- @Injectable({ providedIn: 'root' })
10
- export class ComponentLoaderFactory {
11
- constructor(
12
- private componentFactoryResolver: ComponentFactoryResolver,
13
- private injector: Injector,
14
- private applicationRef: ApplicationRef
15
- ) {}
16
-
17
- /**
18
- * Returns a new instance of {@link ComponentLoader}
19
- * @param viewContainerRef - The view container the dynamic content will be attached to.
20
- * @returns A new instance of {@link ComponentLoader}.
21
- *
22
- * @public
23
- */
24
- createLoader<T>(viewContainerRef?: ViewContainerRef): ComponentLoader<T> {
25
- return new ComponentLoader<T>(viewContainerRef, this.componentFactoryResolver, this.applicationRef, this.injector);
26
- }
27
- }
@@ -1,10 +0,0 @@
1
- import { ComponentRef, ViewRef } from '@angular/core';
2
-
3
- /**
4
- * Holds information about the dynamic content.
5
- * @remarks
6
- * `ComponentRef` is undefined in the case content is of `TemplateRef` type.
7
- */
8
- export class ContentRef {
9
- constructor(public nodes: any[], public viewRef?: ViewRef, public componentRef?: ComponentRef<any>) {}
10
- }
@@ -1,34 +0,0 @@
1
- import { Inject, Injectable } from '@angular/core';
2
- import { HttpErrorResponse, HttpEvent, HttpHandler, HttpInterceptor, HttpRequest, HttpResponse } from '@angular/common/http';
3
-
4
- import { Observable } from 'rxjs';
5
- import { catchError } from 'rxjs/operators';
6
- import { ToasterService } from '../toaster.service';
7
- import { UtilitiesService } from '../utilities.service';
8
- import { ToastType } from '../../types';
9
-
10
-
11
- @Injectable()
12
- export class BadRequestInterceptor implements HttpInterceptor {
13
- constructor(
14
- @Inject(ToasterService) private toaster: ToasterService,
15
- private utilities: UtilitiesService
16
- ) { }
17
-
18
- public intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
19
- return next.handle(request).pipe(
20
- catchError((error: HttpResponse<any>) => {
21
- if (error instanceof HttpErrorResponse && error.status === 400) {
22
- const fileReader = new FileReader();
23
- fileReader.addEventListener('loadend', () => {
24
- // tslint:disable-next-line:no-non-null-assertion
25
- const problemDetails = fileReader.result!;
26
- this.toaster.show(ToastType.Error, 'Αποτυχία αιτήματος', `${this.utilities.getValidationProblemDetails(JSON.parse(problemDetails.toString()))}`, 6000);
27
- });
28
- fileReader.readAsText(error.error);
29
- }
30
- throw error;
31
- })
32
- );
33
- }
34
- }
@@ -1,40 +0,0 @@
1
- import { Component, ElementRef, OnInit, Renderer2, ViewEncapsulation } from '@angular/core';
2
- import { ComponentLoader } from '../component-loader/component-loader.class';
3
- import { animationTime, cssClassNames } from './modal-styles.class';
4
-
5
- /**
6
- * Background layer for modals.
7
- * Override class name to theme it.
8
- * @see {@link cssClassNames}
9
- * @internal
10
- */
11
- @Component({
12
- selector: 'lib-modal-backdrop',
13
- encapsulation: ViewEncapsulation.None,
14
- template: '',
15
- host: {
16
- class: cssClassNames.backdrop,
17
- },
18
- })
19
- export class ModalBackdropComponent implements OnInit {
20
- private animationsEnabled = false;
21
- private backdropLoader: ComponentLoader<ModalBackdropComponent> | undefined;
22
- constructor(private element: ElementRef, private renderer: Renderer2) {}
23
-
24
- ngOnInit(): void {
25
- if (this.animationsEnabled) {
26
- this.renderer.addClass(this.element.nativeElement, cssClassNames.fade);
27
- this.reflow(this.element.nativeElement);
28
- }
29
- this.renderer.addClass(this.element.nativeElement, cssClassNames.show);
30
- }
31
-
32
- public hide() {
33
- this.renderer.removeClass(this.element.nativeElement, cssClassNames.show);
34
- setTimeout(() => this.backdropLoader?.hide(), this.animationsEnabled ? animationTime.backdrop : 0);
35
- }
36
-
37
- reflow(element: any): void {
38
- ((bs: any): void => bs)(element.offsetHeight);
39
- }
40
- }
@@ -1,125 +0,0 @@
1
- import { Component, ElementRef, HostListener, OnDestroy, OnInit, Renderer2 } from '@angular/core';
2
- import { animationTime, cssClassNames } from './modal-styles.class';
3
- import { ModalOptions } from './modal-options.class';
4
- import { ModalService } from './modal-service';
5
-
6
- /**
7
- * Modal container component.
8
- * @remarks
9
- * All dynamic content `TemplateRef` or `Component` case will be drawn inside this.
10
- * You can override css classes to theme it {@link cssClassNames}
11
- * @internal
12
- */
13
- @Component({
14
- selector: 'lib-modal-container',
15
- template: `
16
- <div [class]="'modal-dialog' + (config.class ? ' ' + config.class : '')" role="document" focusTrap>
17
- <div class="modal-content">
18
- <ng-content></ng-content>
19
- </div>
20
- </div>
21
- `,
22
- host: {
23
- class: 'modal',
24
- role: 'dialog',
25
- tabindex: '-1',
26
- '[attr.aria-modal]': 'true',
27
- '[attr.aria-labelledby]': 'config.ariaLabelledBy',
28
- '[attr.aria-describedby]': 'config.ariaDescribedby',
29
- },
30
- })
31
- export class ModalContainerComponent implements OnInit, OnDestroy {
32
- public level?: number;
33
- public config: ModalOptions;
34
- public modalService?: ModalService;
35
- private isShown = false;
36
- private animationsEnabled = false;
37
- private isModalHiding = false;
38
- private clickStartedInContent = false;
39
- constructor(options: ModalOptions, protected _element: ElementRef, private renderer: Renderer2) {
40
- this.config = Object.assign({}, options);
41
- }
42
-
43
- ngOnInit(): void {
44
- if (this.animationsEnabled) {
45
- this.renderer.addClass(this._element.nativeElement, cssClassNames.fade);
46
- }
47
- this.renderer.setStyle(this._element.nativeElement, 'display', 'block');
48
- setTimeout(
49
- () => {
50
- this.isShown = true;
51
- this.renderer.addClass(this._element.nativeElement, cssClassNames.show);
52
- },
53
- this.animationsEnabled ? animationTime.backdrop : 0
54
- );
55
- if (this._element.nativeElement) {
56
- this._element.nativeElement.focus();
57
- }
58
- }
59
-
60
- @HostListener('mousedown', ['$event'])
61
- onClickStarted(event: MouseEvent): void {
62
- this.clickStartedInContent = event.target !== this._element.nativeElement;
63
- }
64
-
65
- @HostListener('click', ['$event'])
66
- onClickStop(event: MouseEvent): void {
67
- const clickedInBackdrop = event.target === this._element.nativeElement && !this.clickStartedInContent;
68
- if (this.config.ignoreBackdropClick || this.config.backdrop === 'static' || !clickedInBackdrop) {
69
- this.clickStartedInContent = false;
70
- return;
71
- }
72
- this.hide();
73
- }
74
-
75
- @HostListener('window:popstate')
76
- onPopState(): void {
77
- this.hide();
78
- }
79
-
80
- @HostListener('window:keydown.esc', ['$event'])
81
- onEsc(event: KeyboardEvent): void {
82
- if (!this.isShown) {
83
- return;
84
- }
85
- if (event.keyCode === 27 || event.key === 'Escape' || event.key === 'Esc') {
86
- event.preventDefault();
87
- }
88
- if (this.config.keyboard && this.config.id === this.modalService?.getActiveModal().config.id) {
89
- this.hide();
90
- }
91
- }
92
-
93
- ngOnDestroy(): void {
94
- if (this.isShown) {
95
- this._hide();
96
- }
97
- }
98
-
99
- hide(result?: any): void {
100
- if (this.isModalHiding || !this.isShown) {
101
- return;
102
- }
103
- if (this.config.closeInterceptor) {
104
- this.config.closeInterceptor().then(
105
- () => this._hide(),
106
- () => undefined
107
- );
108
- return;
109
- }
110
- this._hide(result);
111
- }
112
-
113
- private _hide(result?: any): void {
114
- this.isModalHiding = true;
115
- this.renderer.removeClass(this._element.nativeElement, cssClassNames.show);
116
- setTimeout(
117
- () => {
118
- this.isShown = false;
119
- this.modalService?.hide(this.config.id, result);
120
- this.isModalHiding = false;
121
- },
122
- this.animationsEnabled ? animationTime.modal : 0
123
- );
124
- }
125
- }
@@ -1,92 +0,0 @@
1
- import { Injectable, InjectionToken, StaticProvider } from '@angular/core';
2
-
3
- /**
4
- * Modals option can be passed to a specific modal from {@link ModalService.show} or
5
- * set globbaly using the injection token {@link MODAL_CONFIG_DEFAULT_OVERRIDE}.
6
- * @remarks
7
- * Modal specific options are merged with global options.
8
- * @see {@link modalConfigDefaults} for defaults.
9
- * @public
10
- */
11
- @Injectable()
12
- export class ModalOptions<T = Record<string, unknown>> {
13
- /**
14
- * Id for opened modal. If not set a random one is generated.
15
- */
16
- id?: number | string;
17
- /**
18
- * If static is set the modal will not close when clicking outside of modal.
19
- * @remarks
20
- * Keyboard event (escape key) stills applies. If you must get a result then also set keyboard to false.
21
- */
22
- backdrop?: boolean | 'static';
23
- /**
24
- * Closes the modal when escape key is pressed.
25
- */
26
- keyboard?: boolean;
27
- /**
28
- * Shows the modal when initialized.
29
- */
30
- show?: boolean;
31
- /**
32
- * Ignore the backdrop click. Pretty much the same as backdrop static.
33
- */
34
- ignoreBackdropClick?: boolean;
35
- /**
36
- * Css class for opened modal.
37
- */
38
- class?: string;
39
- /**
40
- * Toggle animation.
41
- */
42
- animated?: boolean;
43
- /**
44
- * Modal initial data.
45
- * @remarks
46
- * This data must be known properties of content component.
47
- */
48
- initialState?: Partial<T>;
49
- /**
50
- * Function to intercept the closure.
51
- * @remarks
52
- * You can use to catch the close event and even prevent it from closing.
53
- */
54
- closeInterceptor?: CloseInterceptorFn;
55
- /**
56
- * Modal static providers.
57
- * @see {@link https://angular.io/guide/glossary#di-token | Injection Token}
58
- */
59
- providers?: StaticProvider[];
60
- /**
61
- * aria-labelledby attribute value to set on the modal window.
62
- */
63
- ariaLabelledBy?: string;
64
- /**
65
- * aria-describedby attribute value to set on the modal window.
66
- */
67
- ariaDescribedby?: string;
68
- }
69
-
70
- /**
71
- * Default option values.
72
- */
73
- export const modalConfigDefaults: ModalOptions = {
74
- backdrop: true,
75
- keyboard: true,
76
- show: false,
77
- ignoreBackdropClick: false,
78
- class: '',
79
- animated: true,
80
- initialState: {},
81
- closeInterceptor: void 0,
82
- };
83
-
84
- /**
85
- * Use this injection token to set global options.
86
- */
87
- export const MODAL_CONFIG_DEFAULT_OVERRIDE: InjectionToken<ModalOptions> = new InjectionToken<ModalOptions>('override-default-config');
88
-
89
- /**
90
- * Close interceptor promise.
91
- */
92
- export type CloseInterceptorFn = () => Promise<void>;