@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,93 @@
1
+ import { Injectable } from '@angular/core';
2
+ import { ColumnConfiguration } from './column-configuration';
3
+ import { ColumnDefinition } from './table.models';
4
+
5
+ @Injectable({
6
+ providedIn: 'root',
7
+ })
8
+ export class TableBuilder<TEntity> {
9
+ private columns: ColumnDefinition<TEntity>[] = [];
10
+
11
+ addColumn(
12
+ id: string | keyof TEntity,
13
+ config?: (v: ColumnConfiguration<TEntity>) => void
14
+ ): TableBuilder<TEntity> {
15
+ const columnConfig = new ColumnConfiguration<TEntity>(id);
16
+ config?.(columnConfig);
17
+ this.columns.push(columnConfig.build());
18
+ return this;
19
+ }
20
+
21
+ addTextColumn(
22
+ id: string | keyof TEntity,
23
+ config?: (v: ColumnConfiguration<TEntity>) => void
24
+ ): TableBuilder<TEntity> {
25
+ return this.addColumn(id, (x) => {
26
+ config?.(x);
27
+ x.type('text');
28
+ });
29
+ }
30
+
31
+ addNumberColumn(
32
+ id: string | keyof TEntity,
33
+ config?: (v: ColumnConfiguration<TEntity>) => void
34
+ ): TableBuilder<TEntity> {
35
+ return this.addColumn(id, (x) => {
36
+ config?.(x);
37
+ x.type('number').columnClass('text-end');
38
+ });
39
+ }
40
+
41
+ addDateColumn(
42
+ id: string | keyof TEntity,
43
+ config?: (v: ColumnConfiguration<TEntity>) => void
44
+ ): TableBuilder<TEntity> {
45
+ return this.addColumn(id, (x) => {
46
+ config?.(x);
47
+ x.type('date').valueFunction((row) => covertFromDateToUserLocale(row, id as string));
48
+ });
49
+ }
50
+
51
+ addBooleanColumn(
52
+ id: string,
53
+ config?: (v: ColumnConfiguration<TEntity>) => void
54
+ ): TableBuilder<TEntity> {
55
+ return this.addColumn(id, (x) => {
56
+ config?.(x);
57
+ x.type('boolean');
58
+ });
59
+ }
60
+
61
+ addEnumColumn(
62
+ id: string | keyof TEntity,
63
+ config?: (v: ColumnConfiguration<TEntity>) => void
64
+ ): TableBuilder<TEntity> {
65
+ return this.addColumn(id, (x) => {
66
+ config?.(x);
67
+ x.type('enum');
68
+ });
69
+ }
70
+
71
+ build(): ColumnDefinition<TEntity>[] {
72
+ return this.columns;
73
+ }
74
+ }
75
+
76
+ function covertFromDateToUserLocale<TEntity>(row: TEntity, id: string) {
77
+ const value = (row as { [key: string]: undefined | string | Date })[id];
78
+ if (value === undefined) {
79
+ return '';
80
+ }
81
+
82
+ const locale = navigator.language;
83
+
84
+ if (value instanceof Date) {
85
+ return value.toLocaleDateString(locale);
86
+ }
87
+
88
+ if (typeof value === 'string' && !isNaN(Date.parse(value))) {
89
+ return new Date(value).toLocaleDateString(locale);
90
+ }
91
+
92
+ return value;
93
+ }
@@ -0,0 +1,62 @@
1
+ import { ContentChild, Directive, Input, TemplateRef } from '@angular/core';
2
+ import { Params } from '@angular/router';
3
+ import { FieldAlign, FieldAlignType } from '../../common';
4
+ import { ColumnDefinition, ColumnProvider, ColumnVisibility, ColumnVisibilityType, TABLE_COLUMN_PROVIDER } from './table.models';
5
+
6
+ @Directive({
7
+ // eslint-disable-next-line @angular-eslint/directive-selector
8
+ selector: 'v-table-column',
9
+ standalone: true,
10
+ providers: [
11
+ {
12
+ provide: TABLE_COLUMN_PROVIDER,
13
+ useExisting: TableColumnDirective,
14
+ multi: true,
15
+ },
16
+ ],
17
+ })
18
+ export class TableColumnDirective<T> implements ColumnProvider<T> {
19
+ @ContentChild(TemplateRef) template!:
20
+ TemplateRef<{ $implicit: T }>;
21
+
22
+ @Input() index = 0;
23
+
24
+ @Input() id!: string;
25
+
26
+ @Input() columnClass!: string;
27
+
28
+ @Input() sortable!: boolean;
29
+
30
+ @Input() routerLink!: (row: T) => string;
31
+
32
+ @Input() queryParams!: Params;
33
+
34
+ @Input() headerName!: ((column: string, index?: number) => string) | string;
35
+
36
+ @Input() width: string | number | undefined;
37
+
38
+ @Input() textAlign: FieldAlignType = FieldAlign.left;
39
+
40
+ @Input() format!: (row: T) => string
41
+
42
+ @Input() forceVisibility: ColumnVisibilityType = ColumnVisibility.default;
43
+
44
+ @Input() visible = true;
45
+
46
+ getDefinition(): ColumnDefinition<T> {
47
+ return {
48
+ id: this.id,
49
+ columnClass: this.columnClass,
50
+ template: this.template,
51
+ headerName: this.headerName,
52
+ routerLink: this.routerLink,
53
+ queryParams: this.queryParams,
54
+ sortable: this.sortable,
55
+ width: this.width,
56
+ format: this.format,
57
+ textAlign: this.textAlign,
58
+ forceVisibility: this.forceVisibility,
59
+ visible: this.visible,
60
+ };
61
+ }
62
+ }
@@ -0,0 +1,261 @@
1
+ import { EventEmitter, InjectionToken, TemplateRef } from '@angular/core';
2
+ import { Params } from '@angular/router';
3
+ import { LazyLoadEvent, Sort, SortDirectionType } from '@verisoft/core';
4
+ import { v4 } from 'uuid';
5
+ import { FieldAlignType } from '../../common';
6
+
7
+ export const TABLE_COMPONENT_TOKEN = new InjectionToken<TableCore<any>>(
8
+ 'TabVIewComponentToken'
9
+ );
10
+
11
+ export const TABLE_COLUMN_PROVIDER = new InjectionToken(
12
+ 'TABLE_COLUMN_PROVIDER'
13
+ );
14
+
15
+ export enum TableSelectionMode {
16
+ single = 'single',
17
+ multiple = 'multiple',
18
+ }
19
+
20
+ export enum TableButtonSeverity {
21
+ success = 'success',
22
+ info = 'info',
23
+ warning = 'warning',
24
+ danger = 'danger',
25
+ help = 'help',
26
+ primary = 'primary',
27
+ secondary = 'secondary',
28
+ contrast = 'contrast',
29
+ }
30
+
31
+ export enum ColumnVisibility {
32
+ visible = 'visible',
33
+ hidden = 'hidden',
34
+ default = 'default',
35
+ }
36
+
37
+ export type TableSelectionModeType = keyof typeof TableSelectionMode;
38
+ export type TableButtonSeverityType = keyof typeof TableButtonSeverity;
39
+ export type ColumnVisibilityType = keyof typeof ColumnVisibility;
40
+
41
+ export interface TableCore<T> {
42
+ sorters: Sort[];
43
+ columns: ColumnDefinition<T>[];
44
+ data: T[];
45
+ total: number;
46
+ filter: Partial<T> | undefined;
47
+ loading: boolean;
48
+ scrollable: boolean;
49
+ pageSize: number;
50
+ currentPage: number;
51
+ showPaginator: boolean;
52
+ sortMultiple: boolean;
53
+ lazy: boolean;
54
+ selection: T[];
55
+ selectionMode: TableSelectionModeType | undefined;
56
+ showPageSizePicker: boolean;
57
+ entityKey: string | undefined;
58
+ selectionChange: EventEmitter<T[]>;
59
+ lazyLoad: EventEmitter<LazyLoadEvent>;
60
+ maximumColumnLength: number;
61
+ disableCustomClicks: boolean;
62
+ }
63
+
64
+ export interface TableSignal {
65
+ name: string,
66
+ symbol: symbol
67
+ }
68
+
69
+ export interface ActionColumnsDefinition<T> {
70
+ severity?: TableButtonSeverity;
71
+ title?: string;
72
+ icon?: string;
73
+ tooltip?: string;
74
+ rounded?: boolean;
75
+ outlined?: boolean;
76
+ raised?: boolean;
77
+ badge?: string;
78
+ visible?: (row: T) => boolean;
79
+ routerLink?: (row: T) => string;
80
+ queryParams?: Params;
81
+ disabled?: boolean | ((row: T) => boolean);
82
+ onClick?: (row: T, event?: MouseEvent) => void;
83
+ }
84
+
85
+ export interface ColumnProvider<T> {
86
+ getDefinition(): ColumnDefinition<T>;
87
+ index: number;
88
+ }
89
+
90
+ export interface ColumnDefinition<T, _KEY = keyof T> {
91
+ id: string;
92
+ value?: (row: T, index?: number) => string;
93
+ headerName?: ((columnId: string, index?: number) => string) | string;
94
+ icon?: string | ((row?: T | undefined) => string);
95
+ type?: string;
96
+ sortable?: boolean;
97
+ format?: (row: T) => string
98
+ routerLink?: (row: T) => string | string;
99
+ queryParams?: Params;
100
+ columnClass?: string;
101
+ template?: TemplateRef<{ $implicit: T }>;
102
+ actions?: ActionColumnsDefinition<T>[];
103
+ textAlign?: FieldAlignType;
104
+ width?: string | number;
105
+ forceVisibility?: ColumnVisibilityType;
106
+ visible?: boolean;
107
+ }
108
+
109
+ export function LinkRenderer<T>(text: string, href: string) {
110
+ return (row: T, index: number | undefined) => {
111
+ return '<a href="' + href + '">' + text + '</a>';
112
+ };
113
+ }
114
+
115
+ export function routerRenderer<T>(link: string, text: string) {
116
+ return (row: T, index?: number | undefined) => {
117
+ return { text: text, link: link };
118
+ };
119
+ }
120
+
121
+ export function Renderer<T>(fnc: (row: T) => string) {
122
+ return (row: T) => {
123
+ return fnc(row);
124
+ };
125
+ }
126
+
127
+ export class ColumnModel<T> {
128
+ sortDirection: SortDirectionType | undefined = undefined;
129
+ columnClass?: string;
130
+ queryParams?: Params;
131
+ routerLink?: (row: T) => string | string;
132
+ valueGetter!: (row: T, index: number) => string;
133
+ headerGetter!: (columnId: string, index: number) => string | string;
134
+ template?: TemplateRef<{ $implicit: T }>;
135
+ actions?: ActionColumnsDefinition<T>[];
136
+ sortable?: boolean;
137
+ id: string;
138
+ // eslint-disable-next-line @typescript-eslint/ban-types
139
+ format!: Function;
140
+ textAlign?: FieldAlignType;
141
+ width: string | undefined;
142
+ forceVisibility: ColumnVisibilityType = ColumnVisibility.default;
143
+ visible = true;
144
+
145
+ constructor(readonly configuration: ColumnDefinition<T>) {
146
+ this.id = this.configuration.id;
147
+
148
+ if (this.configuration.format) {
149
+ this.format = this.configuration.format;
150
+ }
151
+
152
+ if (this.configuration.value) {
153
+ this.valueGetter = (row, index) => {
154
+ const value = this.configuration.value?.(row, index) ?? '-';
155
+ return this.format ? this.format(value, row) : value;
156
+ };
157
+ } else {
158
+ this.valueGetter = (row) => {
159
+ const value = ((row as { [key: string]: string })?.[this.configuration.id]) ?? '';
160
+ return this.format ? this.format(value, row) : value;
161
+ };
162
+ }
163
+
164
+ if (this.configuration.actions) {
165
+ this.actions = this.configuration.actions;
166
+ }
167
+
168
+ if (this.configuration.routerLink) {
169
+ this.routerLink = this.configuration.routerLink;
170
+ }
171
+
172
+ if (this.configuration.columnClass) {
173
+ this.columnClass = this.configuration.columnClass;
174
+ }
175
+
176
+ if (this.configuration.template) {
177
+ this.template = this.configuration.template;
178
+ }
179
+
180
+ if (this.configuration.headerName) {
181
+ this.headerGetter = (
182
+ typeof this.configuration.headerName === 'string'
183
+ ? () => this.configuration.headerName ?? ''
184
+ : (columnId: string, index: number) =>
185
+ (<(columnId: string, index?: number) => string>(
186
+ this.configuration.headerName
187
+ ))?.(columnId, index) ?? this.id
188
+ ) as (columnId: string, index: number) => string;
189
+ } else {
190
+ this.headerGetter = () => "";
191
+ }
192
+
193
+ if (this.configuration.queryParams) {
194
+ this.queryParams = this.configuration.queryParams;
195
+ }
196
+
197
+ if (this.routerLink) {
198
+ this.columnClass += ' ' + 'link';
199
+ }
200
+
201
+ if (this.configuration.sortable !== undefined) {
202
+ this.sortable = this.configuration.sortable;
203
+ } else {
204
+ this.sortable = true;
205
+ }
206
+
207
+ if (this.configuration.width){
208
+ this.width = typeof this.configuration.width === "number" ? this.configuration.width + 'px' : this.configuration.width;
209
+ }
210
+
211
+ if (this.configuration.textAlign !== undefined) {
212
+ this.textAlign = this.configuration.textAlign;
213
+ }
214
+
215
+ if (this.configuration.forceVisibility) {
216
+ this.forceVisibility = this.configuration.forceVisibility;
217
+ }
218
+
219
+ if (this.configuration.visible !== undefined) {
220
+ this.visible = this.configuration.visible;
221
+ }
222
+ }
223
+ }
224
+
225
+ export class RowModel<T> {
226
+ row: T;
227
+ index?: number;
228
+ id: number | string;
229
+ selected: boolean;
230
+ marked?: boolean;
231
+ focused?: boolean;
232
+ expanded: boolean;
233
+ fnc?: void;
234
+ customRoute: string | undefined;
235
+
236
+ constructor(
237
+ row: T,
238
+ selected: boolean,
239
+ expanded: boolean,
240
+ marked?: boolean,
241
+ index?: number,
242
+ fnc?: void,
243
+ customRoute?: string,
244
+ entityKey?: string
245
+ ) {
246
+ this.row = row;
247
+ this.id = (row as { [key: string]: string })['id'] ?? v4();
248
+ this.index = index;
249
+ this.selected = selected;
250
+ this.expanded = expanded;
251
+ this.marked = marked;
252
+ this.fnc = fnc;
253
+ this.customRoute = createCustomRoute<T>(row, entityKey, customRoute);
254
+ }
255
+ }
256
+
257
+ function createCustomRoute<T>(row: T, entityKey?: string, customRoute?: string) {
258
+ return customRoute && entityKey
259
+ ? `${customRoute}/` + (row as { [key: string]: string })[entityKey]
260
+ : undefined;
261
+ }
@@ -0,0 +1 @@
1
+ export * from './table-filter.model';
@@ -1,6 +1,10 @@
1
1
  import { InjectionToken } from '@angular/core';
2
2
  import { BaseFormDirectiveCore } from '../base-form';
3
- export declare const TABLE_FILTER_COMPONENT_TOKEN: InjectionToken<TableFilterCore<any>>;
3
+
4
+ export const TABLE_FILTER_COMPONENT_TOKEN = new InjectionToken<TableFilterCore<any>>(
5
+ 'TableFilterComponentToken'
6
+ );
7
+
4
8
  export interface FilterDefinition {
5
9
  optionLabel: string;
6
10
  label: string;
@@ -9,6 +13,7 @@ export interface FilterDefinition {
9
13
  filterType?: 'dropdown' | 'checkbox' | 'calendar' | 'multiselect';
10
14
  initialValue?: any;
11
15
  }
16
+
12
17
  export interface TableFilterCore<T> extends BaseFormDirectiveCore<T> {
13
18
  filterDefinitions: FilterDefinition[];
14
19
  title: string;
@@ -0,0 +1 @@
1
+ export * from './tag.model';
@@ -0,0 +1,13 @@
1
+ import { InjectionToken, InputSignal } from "@angular/core";
2
+ import { ControlSeverityType, FieldSizeType } from "../../common";
3
+
4
+ export const TAG_COMPONENT_TOKEN = new InjectionToken<TagCore>('TagComponentToken');
5
+
6
+ export type TagVariant = 'bold' | 'subtle';
7
+
8
+ export interface TagCore {
9
+ label: InputSignal<string | undefined>;
10
+ severity: InputSignal<ControlSeverityType | undefined>;
11
+ variant: InputSignal<TagVariant>;
12
+ size: InputSignal<FieldSizeType>;
13
+ }
@@ -0,0 +1 @@
1
+ export * from './textarea.model';
@@ -1,6 +1,10 @@
1
1
  import { InjectionToken } from '@angular/core';
2
2
  import { BaseFormCore } from '../base-form';
3
- export declare const TEXTAREA_COMPONENT_TOKEN: InjectionToken<TextareaCore>;
3
+
4
+ export const TEXTAREA_COMPONENT_TOKEN = new InjectionToken<TextareaCore>(
5
+ 'TextareaComponentToken'
6
+ );
7
+
4
8
  export interface TextareaCore extends BaseFormCore {
5
9
  rows: number;
6
10
  cols: number;
@@ -0,0 +1 @@
1
+ export * from './textfield.model';
@@ -1,9 +1,13 @@
1
1
  import { InjectionToken } from '@angular/core';
2
2
  import { FieldSizeType, FieldTypeType } from '../../common';
3
3
  import { BaseFormCore } from '../base-form';
4
- export declare const TEXTFIELD_COMPONENT_TOKEN: InjectionToken<TextfieldCore>;
4
+
5
+ export const TEXTFIELD_COMPONENT_TOKEN = new InjectionToken<TextfieldCore>(
6
+ 'TextfieldComponentToken'
7
+ );
8
+
5
9
  export interface TextfieldCore extends BaseFormCore {
6
10
  size: FieldSizeType | undefined;
7
11
  type: FieldTypeType;
8
12
  floatLabel: boolean;
9
- }
13
+ }
@@ -0,0 +1 @@
1
+ export * from './tooltip.model';
@@ -0,0 +1,13 @@
1
+ import { InjectionToken, Signal } from '@angular/core';
2
+ import { ControlSeverityType, FieldSizeType, PositionType } from '../../common';
3
+
4
+ export const TOOLTIP_COMPONENT_TOKEN = new InjectionToken<TooltipCore>(
5
+ 'TooltipComponentToken'
6
+ );
7
+
8
+ export interface TooltipCore {
9
+ color: Signal<ControlSeverityType | undefined>;
10
+ position: Signal<PositionType | undefined>;
11
+ size: Signal<FieldSizeType | undefined>;
12
+ tooltipText: Signal<string | undefined>;
13
+ }
@@ -0,0 +1,12 @@
1
+ import { Directive, OnDestroy } from '@angular/core';
2
+ import { Subject } from 'rxjs';
3
+
4
+ @Directive()
5
+ export abstract class UnsubscribeComponent implements OnDestroy {
6
+ destroyed$ = new Subject<void>();
7
+
8
+ ngOnDestroy() {
9
+ this.destroyed$.next();
10
+ this.destroyed$.complete();
11
+ }
12
+ }