@verisoft/ui-core 19.0.0-rc001 → 20.1.0

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 (216) hide show
  1. package/.eslintrc.json +48 -0
  2. package/README.md +314 -3
  3. package/jest.config.ts +21 -0
  4. package/ng-package.json +11 -0
  5. package/package.json +16 -31
  6. package/project.json +36 -0
  7. package/{index.d.ts → src/index.ts} +1 -1
  8. package/src/lib/common/angular-helper.ts +44 -0
  9. package/src/lib/common/constants.ts +5 -0
  10. package/src/lib/common/control.models.ts +80 -0
  11. package/src/lib/common/datasource-component.model.spec.ts +42 -0
  12. package/src/lib/common/datasource-component.model.ts +43 -0
  13. package/{lib/common/deactivate-guard.model.d.ts → src/lib/common/deactivate-guard.model.ts} +2 -1
  14. package/src/lib/common/download-file.ts +20 -0
  15. package/src/lib/common/filter.ts +7 -0
  16. package/{lib/common/icons.d.ts → src/lib/common/icons.ts} +34 -34
  17. package/{lib/common/index.d.ts → src/lib/common/index.ts} +10 -10
  18. package/{lib/common/notificable-property.model.d.ts → src/lib/common/notificable-property.model.ts} +5 -4
  19. package/src/lib/common/rxjs.spec.ts +58 -0
  20. package/src/lib/common/rxjs.ts +21 -0
  21. package/src/lib/components/action-button-group/action-button-group.model.ts +15 -0
  22. package/src/lib/components/action-button-group/action-button.model.ts +15 -0
  23. package/{lib/components/action-button-group/index.d.ts → src/lib/components/action-button-group/index.ts} +2 -2
  24. package/src/lib/components/base-form/base-form-input.component.ts +120 -0
  25. package/src/lib/components/base-form/base-form.component.ts +236 -0
  26. package/src/lib/components/base-form/directives/detail-store.directive.ts +219 -0
  27. package/{lib/components/base-form/index.d.ts → src/lib/components/base-form/index.ts} +2 -2
  28. package/src/lib/components/base-form/models/base-form-input.models.ts +11 -0
  29. package/src/lib/components/base-form/models/base-form.models.ts +31 -0
  30. package/{lib/components/base-form/models/index.d.ts → src/lib/components/base-form/models/index.ts} +1 -1
  31. package/{lib/components/breadcrumb/breadcrumb.model.d.ts → src/lib/components/breadcrumb/breadcrumb.model.ts} +6 -1
  32. package/src/lib/components/breadcrumb/breadcrumb.service.ts +9 -0
  33. package/src/lib/components/breadcrumb/breadcrumbcore.component.ts +117 -0
  34. package/src/lib/components/breadcrumb/index.ts +3 -0
  35. package/{lib/components/button/button.model.d.ts → src/lib/components/button/button.model.ts} +5 -1
  36. package/src/lib/components/button/index.ts +1 -0
  37. package/{lib/components/calendar/calendar.model.d.ts → src/lib/components/calendar/calendar.model.ts} +6 -2
  38. package/src/lib/components/calendar/index.ts +1 -0
  39. package/{lib/components/checkbox/checkbox.model.d.ts → src/lib/components/checkbox/checkbox.model.ts} +5 -1
  40. package/src/lib/components/checkbox/index.ts +1 -0
  41. package/src/lib/components/confirm-dialog/confirm-dialog.model.ts +31 -0
  42. package/src/lib/components/confirm-dialog/index.ts +1 -0
  43. package/{lib/components/dropdown/dropdown.model.d.ts → src/lib/components/dropdown/dropdown.model.ts} +5 -1
  44. package/src/lib/components/dropdown/index.ts +1 -0
  45. package/{lib/components/dropdown-button/dropdown-button.model.d.ts → src/lib/components/dropdown-button/dropdown-button.model.ts} +18 -14
  46. package/src/lib/components/dropdown-button/index.ts +1 -0
  47. package/src/lib/components/dynamic-component/dynamic-component.model.ts +2 -0
  48. package/src/lib/components/dynamic-component/index.ts +1 -0
  49. package/src/lib/components/filter/filter.model.ts +17 -0
  50. package/{lib/components/filter/index.d.ts → src/lib/components/filter/index.ts} +1 -1
  51. package/{lib/components/form-field/form-field.model.d.ts → src/lib/components/form-field/form-field.model.ts} +6 -2
  52. package/src/lib/components/form-field/index.ts +1 -0
  53. package/{lib/components/generic-field/generic-field.model.d.ts → src/lib/components/generic-field/generic-field.model.ts} +5 -1
  54. package/src/lib/components/generic-field/index.ts +1 -0
  55. package/src/lib/components/generic-form/generic-form.component.ts +33 -0
  56. package/{lib/components/generic-form/index.d.ts → src/lib/components/generic-form/index.ts} +1 -1
  57. package/{lib/components/header/header.model.d.ts → src/lib/components/header/header.model.ts} +9 -2
  58. package/src/lib/components/header/index.ts +1 -0
  59. package/src/lib/components/icons/icons.component.ts +22 -0
  60. package/src/lib/components/icons/icons.model.ts +16 -0
  61. package/src/lib/components/icons/index.ts +2 -0
  62. package/{lib/components/index.d.ts → src/lib/components/index.ts} +2 -0
  63. package/src/lib/components/input-group/index.ts +1 -0
  64. package/{lib/components/input-group/input-group.model.d.ts → src/lib/components/input-group/input-group.model.ts} +7 -2
  65. package/src/lib/components/loader/index.ts +1 -0
  66. package/src/lib/components/loader/loader.model.ts +7 -0
  67. package/src/lib/components/multiselect/index.ts +1 -0
  68. package/{lib/components/multiselect/mutiselect.model.d.ts → src/lib/components/multiselect/mutiselect.model.ts} +6 -2
  69. package/src/lib/components/number-input/index.ts +1 -0
  70. package/{lib/components/number-input/number-input.model.d.ts → src/lib/components/number-input/number-input.model.ts} +6 -2
  71. package/{lib/components/page-header/index.d.ts → src/lib/components/page-header/index.ts} +1 -1
  72. package/{lib/components/page-header/page-header.model.d.ts → src/lib/components/page-header/page-header.model.ts} +5 -1
  73. package/src/lib/components/page-header/page-header.service.ts +9 -0
  74. package/src/lib/components/page-header/page-headercore.component.ts +42 -0
  75. package/src/lib/components/password/index.ts +1 -0
  76. package/{lib/components/password/password.model.d.ts → src/lib/components/password/password.model.ts} +9 -3
  77. package/src/lib/components/radiobutton/index.ts +1 -0
  78. package/{lib/components/radiobutton/radiobutton.model.d.ts → src/lib/components/radiobutton/radiobutton.model.ts} +8 -3
  79. package/src/lib/components/section/index.ts +1 -0
  80. package/{lib/components/section/section.model.d.ts → src/lib/components/section/section.model.ts} +6 -2
  81. package/src/lib/components/side-menu/directives/side-menu-service.directive.ts +31 -0
  82. package/{lib/components/side-menu/index.d.ts → src/lib/components/side-menu/index.ts} +1 -1
  83. package/src/lib/components/side-menu/services/side-menu-provider.service.ts +13 -0
  84. package/src/lib/components/side-menu/services/side-menu.service.ts +62 -0
  85. package/src/lib/components/side-menu/side-menu.model.ts +67 -0
  86. package/src/lib/components/slider/index.ts +1 -0
  87. package/{lib/components/slider/slider.model.d.ts → src/lib/components/slider/slider.model.ts} +6 -2
  88. package/src/lib/components/snackbar/index.ts +1 -0
  89. package/src/lib/components/snackbar/snackbar.model.ts +7 -0
  90. package/src/lib/components/stepper/index.ts +1 -0
  91. package/{lib/components/stepper/stepper.model.d.ts → src/lib/components/stepper/stepper.model.ts} +10 -5
  92. package/src/lib/components/switch/index.ts +1 -0
  93. package/src/lib/components/switch/switch.model.ts +8 -0
  94. package/src/lib/components/tab-view/index.ts +1 -0
  95. package/{lib/components/tab-view/tab-view.model.d.ts → src/lib/components/tab-view/tab-view.model.ts} +8 -3
  96. package/src/lib/components/table/column-configuration.ts +38 -0
  97. package/src/lib/components/table/table-builder.ts +93 -0
  98. package/src/lib/components/table/table-column.directive.ts +62 -0
  99. package/src/lib/components/table/table.models.ts +261 -0
  100. package/src/lib/components/table-filter/index.ts +1 -0
  101. package/{lib/components/table-filter/table-filter.model.d.ts → src/lib/components/table-filter/table-filter.model.ts} +6 -1
  102. package/src/lib/components/tag/index.ts +1 -0
  103. package/src/lib/components/tag/tag.model.ts +13 -0
  104. package/src/lib/components/textarea/index.ts +1 -0
  105. package/{lib/components/textarea/textarea.model.d.ts → src/lib/components/textarea/textarea.model.ts} +5 -1
  106. package/src/lib/components/textfield/index.ts +1 -0
  107. package/{lib/components/textfield/textfield.model.d.ts → src/lib/components/textfield/textfield.model.ts} +6 -2
  108. package/src/lib/components/tooltip/index.ts +1 -0
  109. package/src/lib/components/tooltip/tooltip.model.ts +13 -0
  110. package/src/lib/components/unsubscribe.component.ts +12 -0
  111. package/src/lib/directives/datasource.directive.ts +275 -0
  112. package/{lib/directives/index.d.ts → src/lib/directives/index.ts} +4 -4
  113. package/src/lib/directives/shortcut.directive.ts +37 -0
  114. package/src/lib/directives/table-datasource.directive.ts +184 -0
  115. package/src/lib/directives/table-filter.directive.ts +69 -0
  116. package/src/lib/format/format.ts +74 -0
  117. package/src/lib/pipes/error/error.codes.ts +11 -0
  118. package/src/lib/pipes/error/error.models.ts +27 -0
  119. package/src/lib/pipes/error/error.pipe.ts +27 -0
  120. package/src/lib/pipes/error/warning.codes.ts +5 -0
  121. package/src/lib/pipes/error/warning.pipe.ts +27 -0
  122. package/src/lib/pipes/helper/enumToList.pipe.ts +16 -0
  123. package/{lib/pipes/index.d.ts → src/lib/pipes/index.ts} +1 -1
  124. package/src/lib/pipes/keyOrFn/keyOrFn.pipe.ts +23 -0
  125. package/src/lib/services/confirm-dialog.service.ts +44 -0
  126. package/{lib/services/index.d.ts → src/lib/services/index.ts} +4 -4
  127. package/src/lib/services/leave-form.service.ts +53 -0
  128. package/src/lib/services/screen-size.service.ts +25 -0
  129. package/src/lib/services/table.service.ts +22 -0
  130. package/src/test-setup.ts +8 -0
  131. package/tsconfig.json +28 -0
  132. package/tsconfig.lib.json +17 -0
  133. package/tsconfig.lib.prod.json +9 -0
  134. package/tsconfig.spec.json +16 -0
  135. package/fesm2022/verisoft-ui-core.mjs +0 -2013
  136. package/fesm2022/verisoft-ui-core.mjs.map +0 -1
  137. package/lib/common/angular-helper.d.ts +0 -1
  138. package/lib/common/constants.d.ts +0 -3
  139. package/lib/common/control.models.d.ts +0 -62
  140. package/lib/common/datasource-component.model.d.ts +0 -19
  141. package/lib/common/download-file.d.ts +0 -2
  142. package/lib/common/filter.d.ts +0 -1
  143. package/lib/common/rxjs.d.ts +0 -2
  144. package/lib/components/action-button-group/action-button-group.model.d.ts +0 -12
  145. package/lib/components/action-button-group/action-button.model.d.ts +0 -14
  146. package/lib/components/base-form/base-form-input.component.d.ts +0 -30
  147. package/lib/components/base-form/base-form.component.d.ts +0 -50
  148. package/lib/components/base-form/directives/detail-store.directive.d.ts +0 -35
  149. package/lib/components/base-form/models/base-form-input.models.d.ts +0 -7
  150. package/lib/components/base-form/models/base-form.models.d.ts +0 -18
  151. package/lib/components/breadcrumb/breadcrumb.service.d.ts +0 -8
  152. package/lib/components/breadcrumb/breadcrumbcore.component.d.ts +0 -30
  153. package/lib/components/breadcrumb/index.d.ts +0 -3
  154. package/lib/components/button/index.d.ts +0 -1
  155. package/lib/components/calendar/index.d.ts +0 -1
  156. package/lib/components/checkbox/index.d.ts +0 -1
  157. package/lib/components/confirm-dialog/confirm-dialog.model.d.ts +0 -25
  158. package/lib/components/confirm-dialog/index.d.ts +0 -1
  159. package/lib/components/dropdown/index.d.ts +0 -1
  160. package/lib/components/dropdown-button/index.d.ts +0 -1
  161. package/lib/components/dynamic-component/dynamic-component.model.d.ts +0 -3
  162. package/lib/components/dynamic-component/index.d.ts +0 -1
  163. package/lib/components/filter/filter.model.d.ts +0 -13
  164. package/lib/components/form-field/index.d.ts +0 -1
  165. package/lib/components/generic-field/index.d.ts +0 -1
  166. package/lib/components/generic-form/generic-form.component.d.ts +0 -30
  167. package/lib/components/header/index.d.ts +0 -1
  168. package/lib/components/icons/icons.component.d.ts +0 -6
  169. package/lib/components/icons/icons.model.d.ts +0 -6
  170. package/lib/components/icons/index.d.ts +0 -2
  171. package/lib/components/input-group/index.d.ts +0 -1
  172. package/lib/components/loader/index.d.ts +0 -1
  173. package/lib/components/loader/loader.model.d.ts +0 -3
  174. package/lib/components/multiselect/index.d.ts +0 -1
  175. package/lib/components/number-input/index.d.ts +0 -1
  176. package/lib/components/page-header/page-header.service.d.ts +0 -8
  177. package/lib/components/page-header/page-headercore.component.d.ts +0 -20
  178. package/lib/components/password/index.d.ts +0 -1
  179. package/lib/components/radiobutton/index.d.ts +0 -1
  180. package/lib/components/section/index.d.ts +0 -1
  181. package/lib/components/side-menu/directives/side-menu-service.directive.d.ts +0 -11
  182. package/lib/components/side-menu/services/side-menu-provider.service.d.ts +0 -10
  183. package/lib/components/side-menu/services/side-menu.service.d.ts +0 -15
  184. package/lib/components/side-menu/side-menu.model.d.ts +0 -42
  185. package/lib/components/slider/index.d.ts +0 -1
  186. package/lib/components/snackbar/index.d.ts +0 -1
  187. package/lib/components/snackbar/snackbar.model.d.ts +0 -3
  188. package/lib/components/stepper/index.d.ts +0 -1
  189. package/lib/components/switch/index.d.ts +0 -1
  190. package/lib/components/switch/switch.model.d.ts +0 -4
  191. package/lib/components/tab-view/index.d.ts +0 -1
  192. package/lib/components/table/column-configuration.d.ts +0 -12
  193. package/lib/components/table/table-builder.d.ts +0 -15
  194. package/lib/components/table/table-column.directive.d.ts +0 -25
  195. package/lib/components/table/table.models.d.ts +0 -132
  196. package/lib/components/table-filter/index.d.ts +0 -1
  197. package/lib/components/textarea/index.d.ts +0 -1
  198. package/lib/components/textfield/index.d.ts +0 -1
  199. package/lib/components/unsubscribe.component.d.ts +0 -9
  200. package/lib/directives/datasource.directive.d.ts +0 -32
  201. package/lib/directives/shortcut.directive.d.ts +0 -11
  202. package/lib/directives/table-datasource.directive.d.ts +0 -29
  203. package/lib/directives/table-filter.directive.d.ts +0 -17
  204. package/lib/format/format.d.ts +0 -9
  205. package/lib/pipes/error/error.codes.d.ts +0 -5
  206. package/lib/pipes/error/error.models.d.ts +0 -8
  207. package/lib/pipes/error/error.pipe.d.ts +0 -8
  208. package/lib/pipes/error/warning.codes.d.ts +0 -5
  209. package/lib/pipes/error/warning.pipe.d.ts +0 -8
  210. package/lib/pipes/helper/enumToList.pipe.d.ts +0 -7
  211. package/lib/pipes/keyOrFn/keyOrFn.pipe.d.ts +0 -7
  212. package/lib/services/confirm-dialog.service.d.ts +0 -12
  213. package/lib/services/leave-form.service.d.ts +0 -13
  214. package/lib/services/screen-size.service.d.ts +0 -10
  215. package/lib/services/table.service.d.ts +0 -13
  216. /package/{lib/components/table/index.d.ts → src/lib/components/table/index.ts} +0 -0
@@ -0,0 +1,219 @@
1
+ import {
2
+ Directive,
3
+ AfterViewInit,
4
+ inject,
5
+ Input,
6
+ OnInit,
7
+ ChangeDetectorRef,
8
+ OnDestroy,
9
+ } from '@angular/core';
10
+ import { ActivatedRoute } from '@angular/router';
11
+ import { createFeatureSelector, createSelector, Store } from '@ngrx/store';
12
+ import {
13
+ BackendValidationError,
14
+ createInitDetailAction,
15
+ createInitNewDetailAction,
16
+ createResetStateAction,
17
+ createUpdateDetailAction,
18
+ createUpdateDetailSetErrorsAction,
19
+ createUpdateFormStateAction,
20
+ DetailState,
21
+ } from '@verisoft/store';
22
+ import { takeUntil } from 'rxjs';
23
+ import { UnsubscribeComponent } from '../../unsubscribe.component';
24
+ import { BaseFormDirective } from '../base-form.component';
25
+
26
+ @Directive({
27
+ // eslint-disable-next-line @angular-eslint/directive-selector
28
+ selector: '[v-useDetailStore]',
29
+ exportAs: 'useDetailStore',
30
+ standalone: true,
31
+ })
32
+ export class DetailStoreDirective
33
+ extends UnsubscribeComponent
34
+ implements OnInit, AfterViewInit, OnDestroy
35
+ {
36
+ @Input({ required: true }) form!: BaseFormDirective<any>;
37
+
38
+ @Input({ required: true }) detailsRepository!: string;
39
+
40
+ @Input() autoBind = true;
41
+
42
+ @Input() detailId!: string | number | undefined;
43
+
44
+ @Input({ required: true }) ngrxFeatureKey!: string;
45
+
46
+ @Input() destroyForm = true;
47
+
48
+ @Input() readonly = false;
49
+
50
+ @Input() readonlyControlNames: string[] = [];
51
+
52
+ store = inject(Store);
53
+ cdr = inject(ChangeDetectorRef);
54
+ route = inject(ActivatedRoute);
55
+
56
+ private itemCache: any = null;
57
+ private loaded!: boolean;
58
+
59
+ ngOnInit(): void {
60
+ if (!this.loaded) {
61
+ this.listenFormState();
62
+ }
63
+ this.listenFormChange();
64
+ this.listenFormStatusChange();
65
+ }
66
+
67
+ ngAfterViewInit(): void {
68
+ if (this.autoBind && !this.loaded) {
69
+ this.initForm();
70
+ }
71
+ }
72
+
73
+ override ngOnDestroy(): void {
74
+ super.ngOnDestroy();
75
+ if (this.destroyForm) {
76
+ this.store.dispatch(createResetStateAction(this.detailsRepository)());
77
+ }
78
+ }
79
+
80
+ private initForm() {
81
+ if (this.detailId === 'create') {
82
+ this.store.dispatch(createInitNewDetailAction(this.detailsRepository)());
83
+ } else {
84
+ this.store.dispatch(
85
+ createInitDetailAction(this.detailsRepository)({ obj: this.detailId })
86
+ );
87
+ }
88
+
89
+ if (this.readonly) {
90
+ this.form.formGroup.disable();
91
+ return;
92
+ }
93
+
94
+ this.readonlyControlNames.forEach(x => {
95
+ this.form.formGroup.get(x)?.disable();
96
+ });
97
+ }
98
+
99
+ private listenFormState() {
100
+ const selectIncomeData = createSelector(
101
+ createFeatureSelector<any>(this.ngrxFeatureKey),
102
+ (state: any) => state?.[this.detailsRepository] as DetailState<any>
103
+ );
104
+ this.store
105
+ .select(selectIncomeData)
106
+ .pipe(takeUntil(this.destroyed$))
107
+ .subscribe(
108
+ (
109
+ { item, loaded, backendValidationErrors } = {
110
+ item: undefined,
111
+ loaded: false,
112
+ saveItemState: { saveInProgress: false },
113
+ backendValidationErrors: []
114
+ }
115
+ ) => {
116
+ if (item
117
+ && ((item.validationErrors || item.validationWarnings) && !this.form.formGroup.dirty)
118
+ || backendValidationErrors.length
119
+ ) {
120
+ this.handleValidation(
121
+ 'propertyName',
122
+ item.validationWarnings || [],
123
+ 'validationWarning',
124
+ 'warningMessage'
125
+ );
126
+ this.handleValidation(
127
+ 'propertyName',
128
+ item.validationErrors || [],
129
+ 'validationError',
130
+ 'errorMessage'
131
+ );
132
+
133
+ if (this.itemCache && this.isStateChanged(item) && backendValidationErrors.length) {
134
+ backendValidationErrors = this.dispatchErrors(item, backendValidationErrors);
135
+ }
136
+
137
+ this.handleBackendValidation(backendValidationErrors);
138
+ this.cdr.markForCheck();
139
+ }
140
+
141
+ this.itemCache = item;
142
+
143
+ this.loaded = loaded;
144
+ this.cdr.detectChanges();
145
+ }
146
+ );
147
+ }
148
+
149
+ private listenFormChange() {
150
+ this.form.dataChange.pipe(takeUntil(this.destroyed$)).subscribe((item) => {
151
+ this.store.dispatch(
152
+ createUpdateDetailAction(this.detailsRepository)({ item })
153
+ );
154
+ });
155
+ }
156
+
157
+ private listenFormStatusChange() {
158
+ this.form.statusChange
159
+ .pipe(takeUntil(this.destroyed$))
160
+ .subscribe((formState) => {
161
+ this.store.dispatch(
162
+ createUpdateFormStateAction(this.detailsRepository)({ formState })
163
+ );
164
+ });
165
+ }
166
+
167
+ private handleValidation = (
168
+ controlName: string,
169
+ errors: any[],
170
+ errorKey: string,
171
+ messageKey: string
172
+ ) => {
173
+ if (errors.length > 0) return;
174
+ errors.forEach((error: any) => {
175
+ const control = this.form.formGroup.get(error[controlName]);
176
+ if (control) {
177
+ control.disabled
178
+ ? control.disable({ emitEvent: false, onlySelf: true })
179
+ : control.enable({ emitEvent: false, onlySelf: true });
180
+ control.setErrors(
181
+ { [errorKey]: error[messageKey] },
182
+ { emitEvent: true }
183
+ );
184
+ control.markAsDirty();
185
+ }
186
+ });
187
+ };
188
+
189
+ private handleBackendValidation(errors: BackendValidationError[]) {
190
+ errors.forEach(({ parameters, code }: BackendValidationError) => {
191
+ const control = this.form.formGroup.get(this.normalizePropertyNames(parameters));
192
+ if (!control) return;
193
+
194
+ control[control.disabled ? "disable" : "enable"]({ emitEvent: false, onlySelf: true });
195
+ control.setErrors({ "validationError": code }, { emitEvent: true });
196
+ control.markAsDirty();
197
+ });
198
+ }
199
+
200
+ private dispatchErrors(item: any, errors: BackendValidationError[]): BackendValidationError[] {
201
+ const error = errors.filter((e: BackendValidationError) => {
202
+ return this.itemCache[this.normalizePropertyNames(e.parameters)] === item[this.normalizePropertyNames(e.parameters)];
203
+ });
204
+
205
+ this.store.dispatch(
206
+ createUpdateDetailSetErrorsAction(this.detailsRepository)({ error })
207
+ );
208
+
209
+ return error;
210
+ }
211
+
212
+ private normalizePropertyNames(input: string): string {
213
+ return String(input[0]).toLocaleLowerCase() + String(input).slice(1);
214
+ }
215
+
216
+ private isStateChanged(item: any): boolean {
217
+ return item !== this.itemCache;
218
+ }
219
+ }
@@ -1,4 +1,4 @@
1
1
  export * from './base-form-input.component';
2
- export * from './base-form.component';
2
+ export * from './base-form.component'
3
3
  export * from './directives/detail-store.directive';
4
- export * from './models';
4
+ export * from './models';
@@ -0,0 +1,11 @@
1
+ import { NgControl } from '@angular/forms';
2
+
3
+ export abstract class BaseInputControls<T> {
4
+ value?: T | null;
5
+
6
+ readonly ngControl?: NgControl;
7
+
8
+ readonly label?: string;
9
+
10
+ readonly required!: boolean;
11
+ }
@@ -0,0 +1,31 @@
1
+ export interface BaseFormCore {
2
+ label?: string;
3
+ required: boolean;
4
+ readonly: boolean;
5
+ tooltip: string;
6
+ formDisplay: 'flex' | 'block';
7
+ clearable: boolean;
8
+ placeholder?: string
9
+ testId?: string;
10
+ }
11
+
12
+ export interface BaseFormDirectiveCore<T> {
13
+ initialData: T | any;
14
+ }
15
+
16
+ export interface FormState {
17
+ dirty: boolean;
18
+ valid: boolean;
19
+ }
20
+
21
+ export function isFormStateEqual(current: FormState, other: FormState) {
22
+ if (!current && !other) {
23
+ return true;
24
+ }
25
+
26
+ if (current && other) {
27
+ return current.dirty === other.dirty && current.valid === other.valid;
28
+ }
29
+
30
+ return false;
31
+ }
@@ -1,2 +1,2 @@
1
1
  export * from './base-form-input.models';
2
- export * from './base-form.models';
2
+ export * from './base-form.models';
@@ -1,12 +1,17 @@
1
1
  import { InjectionToken } from '@angular/core';
2
2
  import { ActivatedRoute } from "@angular/router";
3
3
  import { MenuItem } from '../side-menu';
4
- export declare const BREADCRUMB_COMPONENT_TOKEN: InjectionToken<BreadcrumbCore>;
4
+
5
+ export const BREADCRUMB_COMPONENT_TOKEN = new InjectionToken<BreadcrumbCore>(
6
+ 'BreadcrumbComponentToken'
7
+ );
8
+
5
9
  export interface BreadcrumbCore {
6
10
  items: MenuItem[];
7
11
  homeRoute: string;
8
12
  useHomeRoute: boolean;
9
13
  }
14
+
10
15
  export interface Breadcrumb {
11
16
  label: string;
12
17
  routerLink?: string;
@@ -0,0 +1,9 @@
1
+ import { EventEmitter, Injectable, Output } from '@angular/core';
2
+ import { Breadcrumb } from './breadcrumb.model';
3
+
4
+ @Injectable({
5
+ providedIn: 'root',
6
+ })
7
+ export class BreadcrumbService {
8
+ @Output() routeChange: EventEmitter<Breadcrumb> = new EventEmitter();
9
+ }
@@ -0,0 +1,117 @@
1
+ import {
2
+ ChangeDetectorRef,
3
+ Directive,
4
+ Input,
5
+ inject,
6
+ OnInit,
7
+ } from '@angular/core';
8
+ import { ActivatedRoute, NavigationEnd, Router } from '@angular/router';
9
+ import { filter, takeUntil } from 'rxjs';
10
+ import { MenuItem } from '../side-menu';
11
+ import { UnsubscribeComponent } from '../unsubscribe.component';
12
+ import { BreadcrumbCore } from './breadcrumb.model';
13
+ import { BreadcrumbService } from './breadcrumb.service';
14
+
15
+ @Directive({
16
+
17
+ })
18
+ export class BreadcrumbCoreComponent
19
+ extends UnsubscribeComponent
20
+ implements BreadcrumbCore, OnInit
21
+ {
22
+ @Input() items: MenuItem[] = [];
23
+ @Input() homeRoute = '/';
24
+ @Input() useHomeRoute = false;
25
+
26
+ static readonly ROUTE_DATA_BREADCRUMB = 'breadcrumb';
27
+ static readonly ROUTE_DATA_BREADCRUMB_URL = 'breadcrumb_url';
28
+ static readonly ROUTE_DATA_NO_BREADCRUMB_ROUTE = 'breadcrumb_no_route';
29
+ static readonly BREADCRUMB_HIDE = 'breadcrumb_hide';
30
+ readonly home = { icon: 'pi pi-home', routerLink: this.homeRoute };
31
+
32
+ router = inject(Router);
33
+ activatedRoute = inject(ActivatedRoute);
34
+ breadcrumbService = inject(BreadcrumbService);
35
+ cdr = inject(ChangeDetectorRef);
36
+
37
+ ngOnInit(): void {
38
+ this.initBreadcrumbsCreation();
39
+ this.initRouteChangeListen();
40
+ }
41
+
42
+ private initBreadcrumbsCreation() {
43
+ this.router.events
44
+ .pipe(
45
+ filter((event) => event instanceof NavigationEnd),
46
+ takeUntil(this.destroyed$)
47
+ )
48
+ .subscribe(
49
+ () => (this.items = this.createBreadcrumbs(this.activatedRoute.root))
50
+ );
51
+ }
52
+
53
+ private initRouteChangeListen() {
54
+ this.breadcrumbService.routeChange
55
+ .pipe(
56
+ filter((x) => x.label !== 'Undefined'),
57
+ takeUntil(this.destroyed$)
58
+ )
59
+ .subscribe((x) => {
60
+ this.items = [
61
+ ...this.items,
62
+ {
63
+ label: x.label,
64
+ routerLink: x.routerLink,
65
+ url: x.url,
66
+ class: 'breadcrumb',
67
+ },
68
+ ];
69
+ this.cdr.detectChanges();
70
+ });
71
+ }
72
+
73
+ private createBreadcrumbs(
74
+ route: ActivatedRoute,
75
+ routerLink = '',
76
+ breadcrumbs: MenuItem[] = []
77
+ ): any {
78
+ const children: ActivatedRoute[] = route.children;
79
+
80
+ if (children.length === 0) {
81
+ return breadcrumbs;
82
+ }
83
+
84
+ for (const child of children) {
85
+ const routeURL: string = child.snapshot.url
86
+ .map((segment) => segment.path)
87
+ .join('/');
88
+
89
+ if (!child.snapshot.data[BreadcrumbCoreComponent.BREADCRUMB_HIDE]) {
90
+ if (BreadcrumbCoreComponent.ROUTE_DATA_BREADCRUMB_URL !== undefined) {
91
+ const route =
92
+ child.snapshot.data[BreadcrumbCoreComponent.ROUTE_DATA_BREADCRUMB_URL];
93
+ routerLink += `/${route}`;
94
+ }
95
+
96
+ if (!BreadcrumbCoreComponent.ROUTE_DATA_BREADCRUMB_URL && routeURL !== '') {
97
+ routerLink += `/${routeURL}`;
98
+ }
99
+
100
+ const label = child.snapshot.data[BreadcrumbCoreComponent.ROUTE_DATA_BREADCRUMB];
101
+ if (
102
+ label &&
103
+ BreadcrumbCoreComponent.ROUTE_DATA_NO_BREADCRUMB_ROUTE &&
104
+ child.snapshot.data[
105
+ BreadcrumbCoreComponent.ROUTE_DATA_NO_BREADCRUMB_ROUTE
106
+ ]
107
+ ) {
108
+ breadcrumbs.push({ label, routerLink: undefined });
109
+ } else if (label && child.snapshot.routeConfig?.path !== '') {
110
+ breadcrumbs.push({ label, routerLink: routerLink });
111
+ }
112
+ }
113
+
114
+ return this.createBreadcrumbs(child, routerLink, breadcrumbs);
115
+ }
116
+ }
117
+ }
@@ -0,0 +1,3 @@
1
+ export * from './breadcrumb.model';
2
+ export * from './breadcrumbcore.component'
3
+ export * from './breadcrumb.service';
@@ -1,7 +1,11 @@
1
1
  import { InjectionToken } from '@angular/core';
2
2
  import { Params } from '@angular/router';
3
3
  import { ControlSeverityType, FieldSizeType, IconPositionType } from '../../common';
4
- export declare const BUTTON_COMPONENT_TOKEN: InjectionToken<ButtonCore>;
4
+
5
+ export const BUTTON_COMPONENT_TOKEN = new InjectionToken<ButtonCore>(
6
+ 'ButtonComponentToken'
7
+ );
8
+
5
9
  export interface ButtonCore {
6
10
  label?: string;
7
11
  icon?: string;
@@ -0,0 +1 @@
1
+ export * from './button.model';
@@ -1,6 +1,10 @@
1
1
  import { InjectionToken } from '@angular/core';
2
2
  import { BaseFormCore } from '../base-form';
3
- export declare const CALENDAR_COMPONENT_TOKEN: InjectionToken<CalendarCore>;
3
+
4
+ export const CALENDAR_COMPONENT_TOKEN = new InjectionToken<CalendarCore>(
5
+ 'CalendarComponentToken'
6
+ );
7
+
4
8
  export interface CalendarCore extends BaseFormCore {
5
9
  maxDate: Date;
6
10
  icon: string;
@@ -9,4 +13,4 @@ export interface CalendarCore extends BaseFormCore {
9
13
  footer: string;
10
14
  floatLabel: string | undefined;
11
15
  selectionMode: "single" | "multiple" | "range" | undefined;
12
- }
16
+ }
@@ -0,0 +1 @@
1
+ export * from './calendar.model';
@@ -1,6 +1,10 @@
1
1
  import { InjectionToken, InputSignal } from '@angular/core';
2
2
  import { BaseFormCore } from '../base-form';
3
- export declare const CHECKBOX_COMPONENT_TOKEN: InjectionToken<CheckboxCore>;
3
+
4
+ export const CHECKBOX_COMPONENT_TOKEN = new InjectionToken<CheckboxCore>(
5
+ 'CheckboxComponentToken'
6
+ );
7
+
4
8
  export interface CheckboxCore extends BaseFormCore {
5
9
  indeterminate: InputSignal<boolean>;
6
10
  }
@@ -0,0 +1 @@
1
+ export * from './checkbox.model';
@@ -0,0 +1,31 @@
1
+ import { InjectionToken, Type } from '@angular/core';
2
+ import { SafeHtml } from "@angular/platform-browser";
3
+ import { ControlSeverityType } from '../../common';
4
+
5
+ export const CONFIRM_DIALOG_COMPONENT_TOKEN = new InjectionToken<ConfirmDialogCore>(
6
+ 'ConfirmDialogComponentToken'
7
+ );
8
+
9
+ export type ConfirmDialogCore = object
10
+
11
+ export interface DialogData {
12
+ title?: string;
13
+ headerIcon?: string;
14
+ severity?: ControlSeverityType;
15
+ showCancelButton?: boolean;
16
+ buttonOrder?: 'confirm-cancel' | 'cancel-confirm';
17
+ confirmButtonText?: string;
18
+ confirmButtonFn?: () => void;
19
+ cancelButtonFn?: () => void;
20
+ cancelButtonText?: string;
21
+ innerHTML?: string | SafeHtml;
22
+ data?: unknown;
23
+ componentType?: Type<unknown>;
24
+ closable?: boolean;
25
+ width?: string;
26
+ height?: string;
27
+ }
28
+
29
+ export interface ExtendedDialogData<TInputs = any, TOutputs = any> extends DialogData {
30
+ data?: TInputs & TOutputs;
31
+ }
@@ -0,0 +1 @@
1
+ export * from './confirm-dialog.model';
@@ -1,7 +1,11 @@
1
1
  import { InjectionToken } from '@angular/core';
2
2
  import { DataSourceComponentModel } from '../../common';
3
3
  import { BaseFormCore } from '../base-form';
4
- export declare const DROPDOWN_COMPONENT_TOKEN: InjectionToken<DropdownCore<any>>;
4
+
5
+ export const DROPDOWN_COMPONENT_TOKEN = new InjectionToken<DropdownCore<any>>(
6
+ 'DropdownComponentToken'
7
+ );
8
+
5
9
  export interface DropdownCore<T> extends DataSourceComponentModel<T>, BaseFormCore {
6
10
  dropdownIcon?: string;
7
11
  floatLabel?: string;
@@ -0,0 +1 @@
1
+ export * from './dropdown.model';
@@ -1,14 +1,18 @@
1
- import { InjectionToken, InputSignal } from "@angular/core";
2
- import { ControlSeverityType, FieldSizeType } from "../../common";
3
- import { MenuItem } from "../side-menu";
4
- export declare const DROPDOWN_BUTTON_COMPONENT_TOKEN: InjectionToken<DropdownButtonCore>;
5
- export interface DropdownButtonCore {
6
- label: InputSignal<string | undefined>;
7
- icon: InputSignal<string | undefined>;
8
- rounded: InputSignal<boolean | undefined>;
9
- outlined: InputSignal<boolean | undefined>;
10
- raised: InputSignal<boolean | undefined>;
11
- severity: InputSignal<ControlSeverityType | undefined>;
12
- size: InputSignal<FieldSizeType | undefined>;
13
- items: InputSignal<MenuItem[] | undefined>;
14
- }
1
+ import { InjectionToken, InputSignal } from "@angular/core";
2
+ import { ControlSeverityType, FieldSizeType } from "../../common";
3
+ import { MenuItem } from "../side-menu";
4
+
5
+ export const DROPDOWN_BUTTON_COMPONENT_TOKEN = new InjectionToken<DropdownButtonCore>(
6
+ 'DropdownButtonComponentToken'
7
+ );
8
+
9
+ export interface DropdownButtonCore {
10
+ label: InputSignal<string | undefined>;
11
+ icon: InputSignal<string | undefined>;
12
+ rounded: InputSignal<boolean | undefined>;
13
+ outlined: InputSignal<boolean | undefined>;
14
+ raised: InputSignal<boolean | undefined>;
15
+ severity: InputSignal<ControlSeverityType | undefined>;
16
+ size: InputSignal<FieldSizeType | undefined>;
17
+ items: InputSignal<MenuItem[] | undefined>;
18
+ }
@@ -0,0 +1 @@
1
+ export * from './dropdown-button.model';
@@ -0,0 +1,2 @@
1
+ export type ExtendedComponent<TComponent> =
2
+ Partial<TComponent> & { [key: string]: (value: any) => void; };
@@ -0,0 +1 @@
1
+ export * from './dynamic-component.model';
@@ -0,0 +1,17 @@
1
+ import { InjectionToken } from '@angular/core';
2
+ import { ControlValueAccessor } from '@angular/forms';
3
+ import { GenericFieldDefinition } from '../generic-form';
4
+
5
+ export const FILTER_COMPONENT_TOKEN = new InjectionToken<FilterCore>(
6
+ 'FilterComponentToken'
7
+ );
8
+
9
+ export interface FilterCore extends ControlValueAccessor {
10
+ fields: GenericFieldDefinition[];
11
+ title?: string;
12
+ fulltextFieldName: string;
13
+ showFulltext: boolean;
14
+ showFilters: boolean;
15
+ autoBind: boolean;
16
+ debounceTime?: number;
17
+ }
@@ -1 +1 @@
1
- export * from './filter.model';
1
+ export * from './filter.model';
@@ -1,6 +1,10 @@
1
1
  import { InjectionToken } from '@angular/core';
2
2
  import { NgControl } from '@angular/forms';
3
- export declare const FORM_FIELD_COMPONENT_TOKEN: InjectionToken<FormFieldCore>;
3
+
4
+ export const FORM_FIELD_COMPONENT_TOKEN = new InjectionToken<FormFieldCore>(
5
+ 'FormFieldComponentToken'
6
+ );
7
+
4
8
  export interface FormFieldCore {
5
9
  ngControl?: NgControl;
6
10
  label?: string;
@@ -8,4 +12,4 @@ export interface FormFieldCore {
8
12
  required: boolean;
9
13
  testId?: string;
10
14
  display: 'flex' | 'block';
11
- }
15
+ }
@@ -0,0 +1 @@
1
+ export * from './form-field.model';
@@ -1,6 +1,10 @@
1
1
  import { InjectionToken } from '@angular/core';
2
2
  import { DataSourceComponentModel } from '../../common';
3
3
  import { BaseFormCore } from '../base-form';
4
- export declare const GENERIC_FIELD_COMPONENT_TOKEN: InjectionToken<GenericFieldCore<any>>;
4
+
5
+ export const GENERIC_FIELD_COMPONENT_TOKEN = new InjectionToken<GenericFieldCore<any>>(
6
+ 'GenericFieldComponentToken'
7
+ );
8
+
5
9
  export interface GenericFieldCore<T> extends DataSourceComponentModel<T>, BaseFormCore {
6
10
  }
@@ -0,0 +1 @@
1
+ export * from './generic-field.model';
@@ -0,0 +1,33 @@
1
+ import { ValidatorFn } from '@angular/forms';
2
+ import { DatasourceType } from '@verisoft/core';
3
+ import { FieldSizeType } from '../../common';
4
+
5
+ export interface GenericFieldDefinition {
6
+ validator?: ValidatorFn[];
7
+ type?: GenericFieldTypeType;
8
+ label?: string;
9
+ floatLabel?: boolean;
10
+ name: string;
11
+ optionLabel?: string;
12
+ optionValue?: string;
13
+ options?: unknown[];
14
+ value?: unknown;
15
+ testId?: string;
16
+ size?: FieldSizeType;
17
+ readonly?: boolean;
18
+ datasource?: DatasourceType<any>;
19
+ filterField?: string;
20
+ showFilter?: boolean;
21
+ localSearch?: boolean;
22
+ }
23
+
24
+ export enum GenericFieldType {
25
+ 'dropdown' = 'dropdown',
26
+ 'checkbox' = 'checkbox',
27
+ 'simplecheckbox' = 'simplecheckbox',
28
+ 'calendar' = 'calendar',
29
+ 'multiselect' = 'multiselect',
30
+ 'text' = 'text',
31
+ }
32
+
33
+ export type GenericFieldTypeType = keyof typeof GenericFieldType;