@verisoft/ui-primeng 18.0.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 (233) hide show
  1. package/.eslintrc.json +43 -0
  2. package/README.md +7 -0
  3. package/jest.config.ts +22 -0
  4. package/ng-package.json +7 -0
  5. package/package.json +21 -0
  6. package/project.json +36 -0
  7. package/src/assets/.gitkeep +0 -0
  8. package/src/assets/fonts/orbitron-black.ttf +0 -0
  9. package/src/assets/fonts/orbitron-bold.otf +0 -0
  10. package/src/assets/icons/complex/v-logo.svg +4 -0
  11. package/src/assets/images/_global/elon.jpg +0 -0
  12. package/src/assets/images/_global/jara.png +0 -0
  13. package/src/assets/images/_global/logos/v-logo.webp +0 -0
  14. package/src/assets/sass/base/_scrollbar.scss +18 -0
  15. package/src/assets/sass/base/_typography.scss +25 -0
  16. package/src/assets/sass/layout/_app.scss +27 -0
  17. package/src/assets/sass/layout/_button.scss +57 -0
  18. package/src/assets/sass/layout/_checkbox.scss +33 -0
  19. package/src/assets/sass/layout/_dialog.scss +13 -0
  20. package/src/assets/sass/layout/_dropdown.scss +9 -0
  21. package/src/assets/sass/layout/_formField.scss +5 -0
  22. package/src/assets/sass/layout/_header.scss +63 -0
  23. package/src/assets/sass/layout/_icons.scss +13 -0
  24. package/src/assets/sass/layout/_inputSwitch.scss +13 -0
  25. package/src/assets/sass/layout/_layout.scss +6 -0
  26. package/src/assets/sass/layout/_loader.scss +9 -0
  27. package/src/assets/sass/layout/_radiobutton.scss +21 -0
  28. package/src/assets/sass/layout/_sidemenu.scss +187 -0
  29. package/src/assets/sass/layout/_snackbar.scss +8 -0
  30. package/src/assets/sass/layout/_tables.scss +5 -0
  31. package/src/assets/sass/layout/_tree.scss +12 -0
  32. package/src/assets/sass/layout/_tristatecheckbox.scss +15 -0
  33. package/src/assets/sass/main.scss +28 -0
  34. package/src/assets/sass/themes/_verisoft_theme.scss +46 -0
  35. package/src/assets/sass/utils/_mixins.scss +0 -0
  36. package/src/assets/sass/utils/_utils.scss +39 -0
  37. package/src/assets/sass/utils/_variables.scss +12 -0
  38. package/src/assets/sass/vendors/_bootstrap.scss +2 -0
  39. package/src/assets/sass/vendors/_primeng.scss +2 -0
  40. package/src/index.ts +31 -0
  41. package/src/lib/components/action-button-group/action-button-group.component.html +29 -0
  42. package/src/lib/components/action-button-group/action-button-group.component.scss +0 -0
  43. package/src/lib/components/action-button-group/action-button-group.component.spec.ts +21 -0
  44. package/src/lib/components/action-button-group/action-button-group.component.ts +104 -0
  45. package/src/lib/components/action-button-group/components/action-button/action-button.component.html +12 -0
  46. package/src/lib/components/action-button-group/components/action-button/action-button.component.scss +0 -0
  47. package/src/lib/components/action-button-group/components/action-button/action-button.component.spec.ts +21 -0
  48. package/src/lib/components/action-button-group/components/action-button/action-button.component.ts +36 -0
  49. package/src/lib/components/action-button-group/index.ts +2 -0
  50. package/src/lib/components/breadcrumb/breadcrumb.component.html +12 -0
  51. package/src/lib/components/breadcrumb/breadcrumb.component.scss +18 -0
  52. package/src/lib/components/breadcrumb/breadcrumb.component.spec.ts +21 -0
  53. package/src/lib/components/breadcrumb/breadcrumb.component.stories.ts +36 -0
  54. package/src/lib/components/breadcrumb/breadcrumb.component.ts +24 -0
  55. package/src/lib/components/breadcrumb/index.ts +1 -0
  56. package/src/lib/components/button/button.component.html +20 -0
  57. package/src/lib/components/button/button.component.scss +0 -0
  58. package/src/lib/components/button/button.component.spec.ts +21 -0
  59. package/src/lib/components/button/button.component.ts +43 -0
  60. package/src/lib/components/button/directives/shortcut.directive.ts +37 -0
  61. package/src/lib/components/button/index.ts +2 -0
  62. package/src/lib/components/calendar/calendar.component.html +53 -0
  63. package/src/lib/components/calendar/calendar.component.scss +0 -0
  64. package/src/lib/components/calendar/calendar.component.spec.ts +21 -0
  65. package/src/lib/components/calendar/calendar.component.ts +67 -0
  66. package/src/lib/components/calendar/index.ts +1 -0
  67. package/src/lib/components/checkbox/checkbox.component.html +19 -0
  68. package/src/lib/components/checkbox/checkbox.component.scss +15 -0
  69. package/src/lib/components/checkbox/checkbox.component.spec.ts +21 -0
  70. package/src/lib/components/checkbox/checkbox.component.stories.ts +72 -0
  71. package/src/lib/components/checkbox/checkbox.component.ts +41 -0
  72. package/src/lib/components/checkbox/index.ts +1 -0
  73. package/src/lib/components/confirm-dialog/confirm-dialog.component.html +48 -0
  74. package/src/lib/components/confirm-dialog/confirm-dialog.component.scss +3 -0
  75. package/src/lib/components/confirm-dialog/confirm-dialog.component.spec.ts +21 -0
  76. package/src/lib/components/confirm-dialog/confirm-dialog.component.stories.ts +74 -0
  77. package/src/lib/components/confirm-dialog/confirm-dialog.component.ts +74 -0
  78. package/src/lib/components/confirm-dialog/index.ts +2 -0
  79. package/src/lib/components/confirm-dialog/services/confirm-dialog.service.ts +14 -0
  80. package/src/lib/components/dropdown/dropdown.component.html +96 -0
  81. package/src/lib/components/dropdown/dropdown.component.scss +16 -0
  82. package/src/lib/components/dropdown/dropdown.component.spec.ts +21 -0
  83. package/src/lib/components/dropdown/dropdown.component.stories.ts +90 -0
  84. package/src/lib/components/dropdown/dropdown.component.ts +139 -0
  85. package/src/lib/components/dropdown/index.ts +1 -0
  86. package/src/lib/components/dynamic-component/dynamic-component-factory.service.ts +90 -0
  87. package/src/lib/components/dynamic-component/dynamic-component.component.ts +55 -0
  88. package/src/lib/components/filter/directives/filter-field.directive.ts +25 -0
  89. package/src/lib/components/filter/directives/table-filter.directive.ts +22 -0
  90. package/src/lib/components/filter/filter.component.html +67 -0
  91. package/src/lib/components/filter/filter.component.scss +0 -0
  92. package/src/lib/components/filter/filter.component.spec.ts +21 -0
  93. package/src/lib/components/filter/filter.component.stories.ts +23 -0
  94. package/src/lib/components/filter/filter.component.ts +257 -0
  95. package/src/lib/components/filter/filter.model.ts +18 -0
  96. package/src/lib/components/filter/index.ts +3 -0
  97. package/src/lib/components/form-field/form-field.component.html +41 -0
  98. package/src/lib/components/form-field/form-field.component.scss +0 -0
  99. package/src/lib/components/form-field/form-field.component.spec.ts +21 -0
  100. package/src/lib/components/form-field/form-field.component.stories.ts +69 -0
  101. package/src/lib/components/form-field/form-field.component.ts +34 -0
  102. package/src/lib/components/form-field/index.ts +1 -0
  103. package/src/lib/components/generic-field/generic-field.component.html +54 -0
  104. package/src/lib/components/generic-field/generic-field.component.spec.ts +21 -0
  105. package/src/lib/components/generic-field/generic-field.component.ts +76 -0
  106. package/src/lib/components/generic-field/generic-field.model.ts +9 -0
  107. package/src/lib/components/generic-field/index.ts +2 -0
  108. package/src/lib/components/generic-form/generic-form.component.html +33 -0
  109. package/src/lib/components/generic-form/generic-form.component.spec.ts +21 -0
  110. package/src/lib/components/generic-form/generic-form.component.ts +48 -0
  111. package/src/lib/components/generic-form/generic-form.model.spec.ts +82 -0
  112. package/src/lib/components/generic-form/generic-form.model.ts +76 -0
  113. package/src/lib/components/generic-form/index.ts +2 -0
  114. package/src/lib/components/header/header.component.html +85 -0
  115. package/src/lib/components/header/header.component.scss +0 -0
  116. package/src/lib/components/header/header.component.spec.ts +21 -0
  117. package/src/lib/components/header/header.component.stories.ts +24 -0
  118. package/src/lib/components/header/header.component.ts +64 -0
  119. package/src/lib/components/header/index.ts +2 -0
  120. package/src/lib/components/header/services/header-provider.service.ts +15 -0
  121. package/src/lib/components/input-group/index.ts +1 -0
  122. package/src/lib/components/input-group/input-group.component.html +32 -0
  123. package/src/lib/components/input-group/input-group.component.spec.ts +21 -0
  124. package/src/lib/components/input-group/input-group.component.ts +60 -0
  125. package/src/lib/components/loader/index.ts +1 -0
  126. package/src/lib/components/loader/loader.component.html +5 -0
  127. package/src/lib/components/loader/loader.component.scss +0 -0
  128. package/src/lib/components/loader/loader.component.spec.ts +21 -0
  129. package/src/lib/components/loader/loader.component.ts +17 -0
  130. package/src/lib/components/multiselect/index.ts +1 -0
  131. package/src/lib/components/multiselect/multiselect.component.html +69 -0
  132. package/src/lib/components/multiselect/multiselect.component.scss +0 -0
  133. package/src/lib/components/multiselect/multiselect.component.spec.ts +21 -0
  134. package/src/lib/components/multiselect/multiselect.component.ts +120 -0
  135. package/src/lib/components/number-input/index.ts +1 -0
  136. package/src/lib/components/number-input/number-input.component.html +22 -0
  137. package/src/lib/components/number-input/number-input.component.spec.ts +21 -0
  138. package/src/lib/components/number-input/number-input.component.ts +54 -0
  139. package/src/lib/components/page-header/index.ts +2 -0
  140. package/src/lib/components/page-header/page-header.component.html +31 -0
  141. package/src/lib/components/page-header/page-header.component.scss +0 -0
  142. package/src/lib/components/page-header/page-header.component.spec.ts +21 -0
  143. package/src/lib/components/page-header/page-header.component.ts +60 -0
  144. package/src/lib/components/page-header/services/page-header.service.ts +9 -0
  145. package/src/lib/components/password/index.ts +1 -0
  146. package/src/lib/components/password/password.component.html +24 -0
  147. package/src/lib/components/password/password.component.scss +0 -0
  148. package/src/lib/components/password/password.component.spec.ts +21 -0
  149. package/src/lib/components/password/password.component.ts +56 -0
  150. package/src/lib/components/radiobutton/index.ts +1 -0
  151. package/src/lib/components/radiobutton/radiobutton.component.html +32 -0
  152. package/src/lib/components/radiobutton/radiobutton.component.scss +6 -0
  153. package/src/lib/components/radiobutton/radiobutton.component.spec.ts +21 -0
  154. package/src/lib/components/radiobutton/radiobutton.component.stories.ts +71 -0
  155. package/src/lib/components/radiobutton/radiobutton.component.ts +60 -0
  156. package/src/lib/components/section/index.ts +1 -0
  157. package/src/lib/components/section/section.component.html +24 -0
  158. package/src/lib/components/section/section.component.scss +0 -0
  159. package/src/lib/components/section/section.component.spec.ts +21 -0
  160. package/src/lib/components/section/section.component.ts +30 -0
  161. package/src/lib/components/side-menu/index.ts +2 -0
  162. package/src/lib/components/side-menu/side-menu.component.html +55 -0
  163. package/src/lib/components/side-menu/side-menu.component.scss +0 -0
  164. package/src/lib/components/side-menu/side-menu.component.spec.ts +21 -0
  165. package/src/lib/components/side-menu/side-menu.component.ts +97 -0
  166. package/src/lib/components/side-menu/side-menu.module.ts +66 -0
  167. package/src/lib/components/slider/index.ts +1 -0
  168. package/src/lib/components/slider/slider.component.html +19 -0
  169. package/src/lib/components/slider/slider.component.spec.ts +21 -0
  170. package/src/lib/components/slider/slider.component.ts +56 -0
  171. package/src/lib/components/snackbar/index.ts +2 -0
  172. package/src/lib/components/snackbar/services/snackbar.service.ts +45 -0
  173. package/src/lib/components/snackbar/snackbar.component.html +3 -0
  174. package/src/lib/components/snackbar/snackbar.component.scss +0 -0
  175. package/src/lib/components/snackbar/snackbar.component.spec.ts +21 -0
  176. package/src/lib/components/snackbar/snackbar.component.stories.ts +70 -0
  177. package/src/lib/components/snackbar/snackbar.component.ts +26 -0
  178. package/src/lib/components/stepper/index.ts +1 -0
  179. package/src/lib/components/stepper/stepper.component.html +43 -0
  180. package/src/lib/components/stepper/stepper.component.spec.ts +21 -0
  181. package/src/lib/components/stepper/stepper.component.ts +25 -0
  182. package/src/lib/components/switch/index.ts +1 -0
  183. package/src/lib/components/switch/switch.component.html +19 -0
  184. package/src/lib/components/switch/switch.component.scss +0 -0
  185. package/src/lib/components/switch/switch.component.spec.ts +21 -0
  186. package/src/lib/components/switch/switch.component.stories.ts +65 -0
  187. package/src/lib/components/switch/switch.component.ts +52 -0
  188. package/src/lib/components/tab-view/index.ts +3 -0
  189. package/src/lib/components/tab-view/tab-view-item.component.ts +20 -0
  190. package/src/lib/components/tab-view/tab-view.component.html +24 -0
  191. package/src/lib/components/tab-view/tab-view.component.ts +50 -0
  192. package/src/lib/components/tab-view/tab-view.module.ts +18 -0
  193. package/src/lib/components/table/directives/table-store.directive.ts +61 -0
  194. package/src/lib/components/table/index.ts +2 -0
  195. package/src/lib/components/table/table.component.html +183 -0
  196. package/src/lib/components/table/table.component.scss +0 -0
  197. package/src/lib/components/table/table.component.spec.ts +21 -0
  198. package/src/lib/components/table/table.component.stories.ts +55 -0
  199. package/src/lib/components/table/table.component.ts +256 -0
  200. package/src/lib/components/table-filter/filter.component.html +205 -0
  201. package/src/lib/components/table-filter/filter.component.scss +0 -0
  202. package/src/lib/components/table-filter/filter.component.spec.ts +21 -0
  203. package/src/lib/components/table-filter/filter.component.stories.ts +23 -0
  204. package/src/lib/components/textarea/index.ts +1 -0
  205. package/src/lib/components/textarea/textarea.component.html +40 -0
  206. package/src/lib/components/textarea/textarea.component.scss +5 -0
  207. package/src/lib/components/textarea/textarea.component.spec.ts +21 -0
  208. package/src/lib/components/textarea/textarea.component.stories.ts +98 -0
  209. package/src/lib/components/textarea/textarea.component.ts +62 -0
  210. package/src/lib/components/textfield/index.ts +1 -0
  211. package/src/lib/components/textfield/textfield.component.html +83 -0
  212. package/src/lib/components/textfield/textfield.component.scss +23 -0
  213. package/src/lib/components/textfield/textfield.component.spec.ts +21 -0
  214. package/src/lib/components/textfield/textfield.component.stories.ts +85 -0
  215. package/src/lib/components/textfield/textfield.component.ts +64 -0
  216. package/src/lib/components/tristatecheckbox/index.ts +1 -0
  217. package/src/lib/components/tristatecheckbox/tristatecheckbox.component.html +23 -0
  218. package/src/lib/components/tristatecheckbox/tristatecheckbox.component.scss +0 -0
  219. package/src/lib/components/tristatecheckbox/tristatecheckbox.component.spec.ts +21 -0
  220. package/src/lib/components/tristatecheckbox/tristatecheckbox.component.stories.ts +22 -0
  221. package/src/lib/components/tristatecheckbox/tristatecheckbox.component.ts +46 -0
  222. package/src/lib/interceptors/http-error-message.interceptor.ts +35 -0
  223. package/src/lib/pages/not-found-page/not-found-page.component.html +27 -0
  224. package/src/lib/pages/not-found-page/not-found-page.component.scss +0 -0
  225. package/src/lib/pages/not-found-page/not-found-page.component.spec.ts +21 -0
  226. package/src/lib/pages/not-found-page/not-found-page.component.ts +17 -0
  227. package/src/lib/services/screen-size.service.ts +25 -0
  228. package/src/tab-view.ts +1 -0
  229. package/src/test-setup.ts +8 -0
  230. package/tsconfig.json +29 -0
  231. package/tsconfig.lib.json +18 -0
  232. package/tsconfig.lib.prod.json +9 -0
  233. package/tsconfig.spec.json +16 -0
@@ -0,0 +1,96 @@
1
+ <div class="v-dropdown">
2
+ <ng-container *ngIf="label && !floatLabel">
3
+ <v-form-field
4
+ [label]="label"
5
+ [tooltip]="tooltip"
6
+ [required]="isRequired()"
7
+ [ngControl]="ngControl"
8
+ [testId]="testId"
9
+ [display]="formDisplay"
10
+ >
11
+ <p-dropdown
12
+ [baseZIndex]="9999"
13
+ class="w-100"
14
+ appendTo="body"
15
+ [formControl]="formControl"
16
+ [filter]="filter"
17
+ [title]="label"
18
+ [options]="options"
19
+ [optionLabel]="optionLabel"
20
+ [optionValue]="optionValue"
21
+ [loading]="loading"
22
+ [placeholder]="placeholder ?? ''"
23
+ [virtualScroll]="lazy"
24
+ [virtualScrollItemSize]="virtualOptionSize"
25
+ [virtualScrollOptions]="virtualScrollOptions"
26
+ [tooltip]="tooltip"
27
+ [required]="isRequired()"
28
+ [showClear]="formControl && clearable && !readonly"
29
+ [editable]="editable"
30
+ [dataKey]="optionValue"
31
+ (showEvent)="onDropdownShow()"
32
+ (clearEvent)="onDropdownClear()"
33
+ (onFilter)="filterChange($event)"
34
+ >
35
+ </p-dropdown>
36
+ </v-form-field>
37
+ </ng-container>
38
+ <ng-container *ngIf="!label && !floatLabel">
39
+ <p-dropdown
40
+ [baseZIndex]="9999"
41
+ class="w-100"
42
+ appendTo="body"
43
+ [formControl]="formControl"
44
+ [filter]="filter"
45
+ [title]="label"
46
+ [options]="options"
47
+ [optionLabel]="optionLabel"
48
+ [optionValue]="optionValue"
49
+ [loading]="loading"
50
+ [placeholder]="placeholder ? placeholder : label"
51
+ [tooltip]="tooltip"
52
+ [required]="isRequired()"
53
+ [showClear]="formControl && clearable && !readonly"
54
+ [editable]="editable"
55
+ [dataKey]="optionValue"
56
+ [virtualScroll]="lazy"
57
+ [virtualScrollItemSize]="virtualOptionSize"
58
+ [virtualScrollOptions]="virtualScrollOptions"
59
+ (showEvent)="onDropdownShow()"
60
+ (clearEvent)="onDropdownClear()"
61
+ (onFilter)="filterChange($event)"
62
+ >
63
+ </p-dropdown>
64
+ </ng-container>
65
+ <ng-container *ngIf="floatLabel && !label">
66
+ <p-floatLabel>
67
+ <p-dropdown
68
+ [baseZIndex]="9999"
69
+ class="w-100"
70
+ appendTo="body"
71
+ [formControl]="formControl"
72
+ [title]="label"
73
+ [options]="options"
74
+ [optionLabel]="optionLabel"
75
+ [optionValue]="optionValue"
76
+ [loading]="loading"
77
+ [placeholder]="placeholder ? placeholder : label"
78
+ [filter]="filter"
79
+ [tooltip]="tooltip"
80
+ [required]="isRequired()"
81
+ [showClear]="formControl && clearable && !readonly"
82
+ [editable]="editable"
83
+ [dataKey]="optionValue"
84
+ [virtualScroll]="lazy"
85
+ [virtualScrollItemSize]="virtualOptionSize"
86
+ [virtualScrollOptions]="virtualScrollOptions"
87
+ (showEvent)="onDropdownShow()"
88
+ (clearEvent)="onDropdownClear()"
89
+ (onFilter)="filterChange($event)"
90
+ (lazyLoad)="onLazyLoad($any($event))"
91
+ >
92
+ </p-dropdown>
93
+ <label [for]="inputId">{{ floatLabel }}</label>
94
+ </p-floatLabel>
95
+ </ng-container>
96
+ </div>
@@ -0,0 +1,16 @@
1
+ .v-dropdown {
2
+ justify-content: center;
3
+ width: 100%;
4
+ }
5
+
6
+ .p-dropdown-items-wrapper,
7
+ .p-scroller-viewport,
8
+ .p-scroller {
9
+ min-width: 8rem !important;
10
+ overflow-x: hidden;
11
+ overflow-y: auto;
12
+ }
13
+
14
+ .p-dropdown {
15
+ width: 100%;
16
+ }
@@ -0,0 +1,21 @@
1
+ import { ComponentFixture, TestBed } from '@angular/core/testing';
2
+ import { DropdownComponent } from './dropdown.component';
3
+
4
+ describe('DropdownComponent', () => {
5
+ let component: DropdownComponent<any>;
6
+ let fixture: ComponentFixture<DropdownComponent<any>>;
7
+
8
+ beforeEach(async () => {
9
+ await TestBed.configureTestingModule({
10
+ imports: [DropdownComponent],
11
+ }).compileComponents();
12
+
13
+ fixture = TestBed.createComponent(DropdownComponent);
14
+ component = fixture.componentInstance;
15
+ fixture.detectChanges();
16
+ });
17
+
18
+ it('should create', () => {
19
+ expect(component).toBeTruthy();
20
+ });
21
+ });
@@ -0,0 +1,90 @@
1
+ import { UntypedFormControl, Validators } from '@angular/forms';
2
+ import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
3
+ import { faker } from '@faker-js/faker';
4
+ import { moduleMetadata, type Meta, type StoryObj } from '@storybook/angular';
5
+ import { within, expect } from '@storybook/test';
6
+ import { DropdownComponent } from './dropdown.component';
7
+
8
+ const meta: Meta<DropdownComponent<any>> = {
9
+ component: DropdownComponent,
10
+ title: 'DropdownComponent',
11
+ decorators: [
12
+ moduleMetadata({
13
+ imports: [BrowserAnimationsModule],
14
+ }),
15
+ ],
16
+ };
17
+ export default meta;
18
+ type Story = StoryObj<DropdownComponent<any>>;
19
+ const options = Array(5)
20
+ .fill(0)
21
+ .map((x, i) => {
22
+ return {
23
+ id: i,
24
+ name: faker.airline.airline().name,
25
+ };
26
+ });
27
+ export const Primary: Story = {
28
+ parameters: {
29
+ controls: { expanded: true },
30
+ },
31
+ args: {
32
+ options: options,
33
+ optionLabel: 'name',
34
+ optionValue: 'id',
35
+ },
36
+ argTypes: {
37
+ optionLabel: {
38
+ description:
39
+ 'String value that sets matching `T[property]` as a label value, where `property = optionLabel`',
40
+ },
41
+ optionValue: {
42
+ description:
43
+ 'String value that sets matching `T[property]` as a binding value, where `property = optionValue`',
44
+ },
45
+ options: { description: 'Array of `T`' },
46
+ },
47
+ };
48
+
49
+ export const DropdownWithFormControl: Story = {
50
+ parameters: {
51
+ controls: { expanded: true },
52
+ },
53
+ args: {
54
+ options: options,
55
+ optionLabel: 'name',
56
+ optionValue: 'id',
57
+ label: 'Airline names',
58
+ placeholder: 'Select an option',
59
+ clearable: true,
60
+ formControl: new UntypedFormControl(undefined, Validators.required),
61
+ },
62
+ argTypes: {
63
+ formControl: {
64
+ control: false,
65
+ description: 'Form control with `Validators.required` set',
66
+ },
67
+ clearable: {
68
+ description: 'Defines if the `DropdownComponent` is clearable',
69
+ },
70
+ label: {
71
+ description:
72
+ 'Represents the `label` of the `DropdownComponent`. Label is also being used as `placeholder` if the placeholder is not set',
73
+ },
74
+ optionLabel: {
75
+ description:
76
+ 'String value that sets matching `T[property]` as a label value, where `property = optionLabel`',
77
+ },
78
+ optionValue: {
79
+ description:
80
+ 'String value that sets matching `T[property]` as a binding value, where `property = optionValue`',
81
+ },
82
+ placeholder: { description: 'Placeholder for the `DropdownComponent`' },
83
+ options: { description: 'Array of `T`' },
84
+ },
85
+ play: async ({ canvasElement }: any) => {
86
+ const canvas = within(canvasElement);
87
+ expect(canvas.getByTitle('Airline names')).toBeTruthy();
88
+ expect(canvas.findByPlaceholderText('Select an option')).toBeTruthy();
89
+ },
90
+ };
@@ -0,0 +1,139 @@
1
+ import { CommonModule } from '@angular/common';
2
+ import {
3
+ ChangeDetectionStrategy,
4
+ Component,
5
+ EventEmitter,
6
+ forwardRef,
7
+ Input,
8
+ OnChanges,
9
+ OnDestroy,
10
+ Optional,
11
+ Output,
12
+ Self,
13
+ SimpleChanges,
14
+ ViewEncapsulation,
15
+ OnInit,
16
+ } from '@angular/core';
17
+ import {
18
+ ControlValueAccessor,
19
+ NgControl,
20
+ ReactiveFormsModule,
21
+ } from '@angular/forms';
22
+ import { FilterEvent, LazyLoadEvent } from '@verisoft/core';
23
+ import {
24
+ BaseFormInputComponent,
25
+ BaseInputControls,
26
+ DROPDOWN_COMPONENT_TOKEN,
27
+ DropdownCore
28
+ } from '@verisoft/ui-core';
29
+ import { ScrollerOptions } from 'primeng/api';
30
+ import {
31
+ DropdownFilterEvent,
32
+ DropdownModule,
33
+ } from 'primeng/dropdown';
34
+ import { FloatLabelModule } from 'primeng/floatlabel';
35
+ import { MessageModule } from 'primeng/message';
36
+ import { ScrollerLazyLoadEvent } from 'primeng/scroller';
37
+ import { TooltipModule } from 'primeng/tooltip';
38
+ import { Subject } from 'rxjs';
39
+ import { FormFieldComponent } from '../form-field';
40
+
41
+ @Component({
42
+ selector: 'v-dropdown',
43
+ standalone: true,
44
+ imports: [
45
+ CommonModule,
46
+ ReactiveFormsModule,
47
+ DropdownModule,
48
+ TooltipModule,
49
+ FormFieldComponent,
50
+ MessageModule,
51
+ FloatLabelModule,
52
+ ],
53
+ templateUrl: './dropdown.component.html',
54
+ styleUrls: ['./dropdown.component.scss'],
55
+ changeDetection: ChangeDetectionStrategy.OnPush,
56
+ encapsulation: ViewEncapsulation.None,
57
+ providers: [
58
+ {
59
+ provide: BaseInputControls,
60
+ useExisting: forwardRef(() => DropdownComponent),
61
+ multi: true,
62
+ },
63
+ {
64
+ provide: DROPDOWN_COMPONENT_TOKEN,
65
+ useExisting: DropdownComponent,
66
+ },
67
+ ],
68
+ })
69
+ export class DropdownComponent<T>
70
+ extends BaseFormInputComponent
71
+ implements
72
+ ControlValueAccessor,
73
+ OnChanges,
74
+ OnDestroy,
75
+ OnInit,
76
+ DropdownCore<T>
77
+ {
78
+ constructor(@Optional() @Self() ngControl: NgControl) {
79
+ super(ngControl);
80
+ }
81
+
82
+ @Input() options?: T[] = [];
83
+ @Input() optionLabel?: string;
84
+ @Input() optionValue?: string;
85
+ @Input() dropdownIcon?: string;
86
+ @Input() floatLabel?: string;
87
+ @Input() editable = false;
88
+ @Input() loading = false;
89
+ @Input() lazy = false;
90
+ @Input() filter = true;
91
+
92
+ @Output() showed = new EventEmitter<any>();
93
+ @Output() cleared = new EventEmitter<any>();
94
+ @Output() lazyLoad = new EventEmitter<LazyLoadEvent>();
95
+ @Output() filtered = new EventEmitter<FilterEvent>();
96
+
97
+ private destroy$ = new Subject<void>();
98
+
99
+ virtualScrollOptions!: ScrollerOptions | undefined;
100
+ virtualOptionSize = 37.5;
101
+
102
+ ngOnChanges(changes: SimpleChanges): void {
103
+ if (changes['lazy'] || changes['loading']) {
104
+ this.virtualScrollOptions = this.lazy
105
+ ? {
106
+ showLoader: this.loading,
107
+ lazy: true,
108
+ onLazyLoad: this.onLazyLoad.bind(this),
109
+ }
110
+ : undefined;
111
+ }
112
+ }
113
+
114
+ ngOnDestroy(): void {
115
+ this.destroy$.next();
116
+ this.destroy$.complete();
117
+ }
118
+
119
+ onLazyLoad(event: ScrollerLazyLoadEvent): void {
120
+ this.lazyLoad.emit({
121
+ offset: event.first,
122
+ limit: event.last - event.first,
123
+ });
124
+ }
125
+
126
+ filterChange(event: DropdownFilterEvent): void {
127
+ this.filtered.emit({
128
+ filter: event.filter,
129
+ });
130
+ }
131
+
132
+ onDropdownShow(): void {
133
+ this.showed.emit();
134
+ }
135
+
136
+ onDropdownClear(): void {
137
+ this.cleared.emit();
138
+ }
139
+ }
@@ -0,0 +1 @@
1
+ export * from './dropdown.component';
@@ -0,0 +1,90 @@
1
+ import {
2
+ Injectable,
3
+ ViewContainerRef,
4
+ Type,
5
+ ComponentFactoryResolver,
6
+ Injector,
7
+ ComponentRef,
8
+ ComponentFactory,
9
+ OnInit,
10
+ OnChanges,
11
+ SimpleChanges,
12
+ SimpleChange,
13
+ } from '@angular/core';
14
+
15
+ @Injectable({
16
+ providedIn: 'root',
17
+ })
18
+ export class DynamicComponentFactoryService {
19
+ constructor(private componentFactoryResolver: ComponentFactoryResolver) {}
20
+
21
+ async createDynamicComponent<TComponent>(
22
+ componentType: Type<TComponent>,
23
+ viewContainerRef: ViewContainerRef,
24
+ inputs: Partial<TComponent>,
25
+ injector: Injector | undefined = undefined
26
+ ) {
27
+ const componentFactory =
28
+ this.componentFactoryResolver.resolveComponentFactory(componentType);
29
+ viewContainerRef.clear();
30
+ const component = viewContainerRef.createComponent(
31
+ componentFactory,
32
+ undefined,
33
+ injector
34
+ );
35
+
36
+ this.setComponentDataInt(componentFactory, component, inputs);
37
+ this.fireComponentEvents(component.instance, inputs);
38
+ return component;
39
+ }
40
+
41
+ setComponentData<TComponent>(
42
+ component: ComponentRef<TComponent>,
43
+ inputs: Partial<TComponent>
44
+ ) {
45
+ const factory = this.componentFactoryResolver.resolveComponentFactory(
46
+ component.componentType
47
+ );
48
+
49
+ this.setComponentDataInt(factory, component, inputs);
50
+ }
51
+
52
+ private fireComponentEvents<TComponent>(instance: TComponent, inputs: Partial<TComponent>) {
53
+ if (instance) {
54
+ const onChangeComponent = instance as unknown as OnChanges;
55
+ if (onChangeComponent.ngOnChanges && inputs) {
56
+ const changeEventArgs = Object.keys(inputs).reduce((changes: SimpleChanges, key: string) => {
57
+ const inputValue = (inputs as { [key: string]: unknown })[key];
58
+ changes[key] = new SimpleChange(undefined, inputValue, true);
59
+ return changes;
60
+ }, {} as SimpleChanges);
61
+
62
+
63
+ onChangeComponent.ngOnChanges(changeEventArgs);
64
+ }
65
+
66
+ const onInitComponent = instance as unknown as OnInit;
67
+ if (onInitComponent.ngOnInit) {
68
+ onInitComponent.ngOnInit();
69
+ }
70
+ }
71
+ }
72
+
73
+ private setComponentDataInt<TComponent>(
74
+ factory: ComponentFactory<TComponent>,
75
+ component: ComponentRef<TComponent>,
76
+ inputs: Partial<TComponent>
77
+ ) {
78
+ if (inputs) {
79
+ const propertyNames = factory.inputs.map((x) => x.propName);
80
+ const inputsHash = new Set(propertyNames);
81
+ Object.keys(inputs)
82
+ .filter((x) => inputsHash.has(x))
83
+ .forEach((x) => {
84
+ (<{ [key: string]: unknown }>component.instance)[x] = (<
85
+ { [key: string]: unknown }
86
+ >inputs)[x];
87
+ });
88
+ }
89
+ }
90
+ }
@@ -0,0 +1,55 @@
1
+ import {
2
+ AfterViewInit,
3
+ ChangeDetectionStrategy,
4
+ ChangeDetectorRef,
5
+ Component,
6
+ inject,
7
+ Injector,
8
+ Input,
9
+ OnChanges,
10
+ Type,
11
+ ViewChild,
12
+ ViewContainerRef,
13
+ } from '@angular/core';
14
+ import { DynamicComponentFactoryService } from './dynamic-component-factory.service';
15
+
16
+ @Component({
17
+ selector: 'v-dynamic-component',
18
+ standalone: true,
19
+ changeDetection: ChangeDetectionStrategy.OnPush,
20
+ template: `<ng-container #dynamicContainer></ng-container>`,
21
+ })
22
+ export class DynamicComponent<TComponent> implements AfterViewInit, OnChanges {
23
+ @Input() componentType!: Type<TComponent>;
24
+
25
+ @Input() data!: Partial<TComponent>;
26
+
27
+ @ViewChild('dynamicContainer', { read: ViewContainerRef, static: true })
28
+ container!: ViewContainerRef;
29
+
30
+ private factoryServices = inject(DynamicComponentFactoryService);
31
+
32
+ private changeDetectorRef = inject(ChangeDetectorRef);
33
+
34
+ private injector = inject(Injector);
35
+
36
+ ngOnChanges(): void {
37
+ this.crateComponent();
38
+ }
39
+
40
+ ngAfterViewInit(): void {
41
+ this.crateComponent();
42
+ this.changeDetectorRef.detectChanges();
43
+ }
44
+
45
+ private crateComponent() {
46
+ if (this.container) {
47
+ this.factoryServices.createDynamicComponent(
48
+ this.componentType,
49
+ this.container,
50
+ this.data,
51
+ this.injector
52
+ );
53
+ }
54
+ }
55
+ }
@@ -0,0 +1,25 @@
1
+ import { Directive, Input } from '@angular/core';
2
+ import { GenericFieldType, GenericFieldTypeType } from '../../generic-field';
3
+ import { GenericFieldDefinition } from '../../generic-form';
4
+
5
+ @Directive({
6
+ // eslint-disable-next-line @angular-eslint/directive-selector
7
+ selector: 'v-filter-field',
8
+ standalone: true,
9
+ })
10
+ export class FilterFieldDirective implements GenericFieldDefinition {
11
+
12
+ @Input({ required: true }) name!: string;
13
+
14
+ @Input() type?: GenericFieldTypeType | undefined = GenericFieldType.text;
15
+
16
+ @Input() label?: string | undefined;
17
+
18
+ @Input() optionLabel!: string;
19
+
20
+ @Input() optionValue?: string | undefined;
21
+
22
+ @Input() options?: unknown[] | undefined;
23
+
24
+ @Input() value?: unknown;
25
+ }
@@ -0,0 +1,22 @@
1
+ import { Directive, inject, Input } from '@angular/core';
2
+ import { UnsubscribeComponent } from '@verisoft/ui-core';
3
+ import { TableComponent } from '../../table/table.component';
4
+ import { FilterComponent } from '../filter.component';
5
+
6
+ @Directive({
7
+ // eslint-disable-next-line @angular-eslint/directive-selector
8
+ selector: 'v-filter[tableFilter]',
9
+ exportAs: 'tableFilter',
10
+ standalone: true,
11
+ })
12
+ export class TableFilterDirective<T> extends UnsubscribeComponent {
13
+ @Input({ required: true }) for!: TableComponent<T>;
14
+
15
+ @Input() ignoreQueryParamsFor?: string[];
16
+
17
+ @Input() useRouter = false;
18
+
19
+ protected removeIds: string[] = [];
20
+
21
+ filterComponent = inject(FilterComponent, { self: true });
22
+ }
@@ -0,0 +1,67 @@
1
+ <div class="v-filter w-100 p-3 bg-primary">
2
+ @if (formGroup$ | async; as formGroup){
3
+ <form [formGroup]="formGroup" class="d-flex align-items-center">
4
+ @if (title) {
5
+ <div class="v-filter_title pe-4">
6
+ <h2 class="text-white m-0">{{ title }}</h2>
7
+ </div>
8
+ }
9
+ <div class="v-filter__fulltext flex-grow-1 pe-4">
10
+ @if (showFulltext){
11
+ <v-textfield
12
+ class="d-none d-lg-block"
13
+ placeholder="Search"
14
+ size="large"
15
+ formControlName="searchField"
16
+ type="search"
17
+ [clearable]="true"
18
+ >
19
+ </v-textfield>
20
+ }
21
+ </div>
22
+ @if (simpleFormFieldDefinitions$ | async; as declaration){
23
+ @if (showFilters)
24
+ {
25
+ <div class="v-filter_filters d-none d-sm-block">
26
+ <v-generic-form
27
+ [fields]="declaration"
28
+ [formGroup]="formGroup"
29
+ ></v-generic-form>
30
+ </div>
31
+ }
32
+ <div class="v-filter_action-buttons d-flex">
33
+ @if (declaration.length) {
34
+ <i
35
+ class="mx-2 pi pi-filter text-white"
36
+ pBadge
37
+ [value]="$any(filledFiltersCount$ | async)"
38
+ (click)="openFilter()"
39
+ ></i>
40
+ } @if (!autoBind) {
41
+ <v-button
42
+ useShortCut
43
+ [shortCutFn]="submitValue.bind(this)"
44
+ shortCutKey="Enter"
45
+ class="text-white mx-2"
46
+ [outlined]="true"
47
+ size="small"
48
+ label="Apply"
49
+ (click)="submitValue()"
50
+ ></v-button>
51
+ <v-button
52
+ useShortCut
53
+ [shortCutFn]="clear.bind(this)"
54
+ shortCutKey="Escape"
55
+ class="text-white"
56
+ [outlined]="true"
57
+ size="small"
58
+ label="Clear"
59
+ (click)="clear()"
60
+ ></v-button>
61
+ }
62
+ </div>
63
+ }
64
+ <ng-content select="v-action-button-group"></ng-content>
65
+ </form>
66
+ }
67
+ </div>
@@ -0,0 +1,21 @@
1
+ import { ComponentFixture, TestBed } from '@angular/core/testing';
2
+ import { FilterComponent } from './filter.component';
3
+
4
+ describe('VerisoftTableFilterComponent', () => {
5
+ let component: FilterComponent<any>;
6
+ let fixture: ComponentFixture<FilterComponent<any>>;
7
+
8
+ beforeEach(async () => {
9
+ await TestBed.configureTestingModule({
10
+ imports: [FilterComponent],
11
+ }).compileComponents();
12
+
13
+ fixture = TestBed.createComponent(FilterComponent);
14
+ component = fixture.componentInstance;
15
+ fixture.detectChanges();
16
+ });
17
+
18
+ it('should create', () => {
19
+ expect(component).toBeTruthy();
20
+ });
21
+ });
@@ -0,0 +1,23 @@
1
+ import type { Meta, StoryObj } from '@storybook/angular';
2
+ import { FilterComponent } from './filter.component';
3
+
4
+ const meta: Meta<FilterComponent<any>> = {
5
+ component: FilterComponent,
6
+ title: 'VerisoftTableFilterComponent',
7
+ };
8
+ export default meta;
9
+ type Story = StoryObj<FilterComponent<any>>;
10
+
11
+ export const Primary: Story = {
12
+ args: {
13
+ filterDefinitions: [],
14
+ debounceTime: 0,
15
+ },
16
+ };
17
+
18
+ export const Heading: Story = {
19
+ args: {
20
+ filterDefinitions: [],
21
+ debounceTime: 0,
22
+ },
23
+ };