@verisoft/ui-govcz 20.0.1 → 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.
- package/.eslintrc.json +60 -0
- package/assets/i18n/cs.json +2 -0
- package/assets/i18n/en.json +2 -0
- package/jest.config.ts +21 -0
- package/ng-package.json +28 -0
- package/package.json +9 -19
- package/project.json +49 -0
- package/src/config.d.ts +10 -0
- package/src/index.ts +1 -0
- package/src/lib/components/breadcrumb/breadcrumb.component.html +25 -0
- package/src/lib/components/breadcrumb/breadcrumb.component.scss +0 -0
- package/src/lib/components/breadcrumb/breadcrumb.component.spec.ts +21 -0
- package/src/lib/components/breadcrumb/breadcrumb.component.ts +28 -0
- package/src/lib/components/breadcrumb/index.ts +1 -0
- package/src/lib/components/button/button.component.html +28 -0
- package/src/lib/components/button/button.component.scss +21 -0
- package/src/lib/components/button/button.component.ts +77 -0
- package/src/lib/components/button/index.ts +1 -0
- package/src/lib/components/calendar/calendar.component.html +28 -0
- package/src/lib/components/calendar/calendar.component.scss +0 -0
- package/src/lib/components/calendar/calendar.component.ts +77 -0
- package/src/lib/components/calendar/index.ts +1 -0
- package/src/lib/components/checkbox/checkbox.component.html +23 -0
- package/src/lib/components/checkbox/checkbox.component.scss +0 -0
- package/src/lib/components/checkbox/checkbox.component.ts +61 -0
- package/src/lib/components/checkbox/index.ts +1 -0
- package/src/lib/components/confirm-dialog/confirm-dialog.component.html +50 -0
- package/src/lib/components/confirm-dialog/confirm-dialog.component.scss +4 -0
- package/src/lib/components/confirm-dialog/confirm-dialog.component.ts +79 -0
- package/src/lib/components/confirm-dialog/index.ts +1 -0
- package/src/lib/components/dropdown/dropdown-item.component.html +8 -0
- package/src/lib/components/dropdown/dropdown-item.component.ts +18 -0
- package/src/lib/components/dropdown/dropdown.component.html +91 -0
- package/src/lib/components/dropdown/dropdown.component.scss +108 -0
- package/src/lib/components/dropdown/dropdown.component.spec.ts +21 -0
- package/src/lib/components/dropdown/dropdown.component.ts +296 -0
- package/src/lib/components/dropdown/dropdown.model.ts +6 -0
- package/src/lib/components/dropdown/index.ts +1 -0
- package/src/lib/components/dropdown-button/dropdown-button.component.html +31 -0
- package/src/lib/components/dropdown-button/dropdown-button.component.ts +34 -0
- package/src/lib/components/dropdown-button/index.ts +1 -0
- package/src/lib/components/errors/error.component.html +11 -0
- package/src/lib/components/errors/error.component.scss +0 -0
- package/src/lib/components/errors/error.component.spec.ts +19 -0
- package/src/lib/components/errors/error.component.ts +29 -0
- package/src/lib/components/errors/index.ts +1 -0
- package/src/lib/components/feature-list/directives/feature-list-column.directive.ts +32 -0
- package/src/lib/components/feature-list/directives/feature-list-filter-field.directive.ts +8 -0
- package/src/lib/components/feature-list/feature-list-filter.pipe.ts +20 -0
- package/src/lib/components/feature-list/feature-list-page.component.ts +30 -0
- package/src/lib/components/feature-list/feature-list-page.model.ts +42 -0
- package/src/lib/components/feature-list/feature-list.component.html +67 -0
- package/src/lib/components/feature-list/feature-list.component.scss +10 -0
- package/src/lib/components/feature-list/feature-list.component.ts +360 -0
- package/src/lib/components/feature-list/index.ts +5 -0
- package/src/lib/components/filter/directives/filter-field.directive.ts +35 -0
- package/src/lib/components/filter/filter.component.html +78 -0
- package/src/lib/components/filter/filter.component.scss +32 -0
- package/src/lib/components/filter/filter.component.spec.ts +21 -0
- package/src/lib/components/filter/filter.component.stories.ts +23 -0
- package/src/lib/components/filter/filter.component.ts +286 -0
- package/src/lib/components/filter/filter.model.ts +18 -0
- package/src/lib/components/filter/index.ts +2 -0
- package/src/lib/components/form-field/form-field.component.html +14 -0
- package/src/lib/components/form-field/form-field.component.scss +0 -0
- package/src/lib/components/form-field/form-field.component.spec.ts +21 -0
- package/src/lib/components/form-field/form-field.component.ts +76 -0
- package/src/lib/components/form-field/index.ts +1 -0
- package/src/lib/components/header/header.component.html +122 -0
- package/src/lib/components/header/header.component.scss +0 -0
- package/src/lib/components/header/header.component.ts +90 -0
- package/src/lib/components/header/index.ts +1 -0
- package/src/lib/components/icon/icon.component.html +11 -0
- package/src/lib/components/icon/icon.component.scss +20 -0
- package/src/lib/components/icon/icon.component.ts +110 -0
- package/src/lib/components/icon/index.ts +2 -0
- package/src/lib/components/index.ts +37 -0
- package/src/lib/components/input-group/index.ts +1 -0
- package/src/lib/components/input-group/input-group.component.html +41 -0
- package/src/lib/components/input-group/input-group.component.scss +0 -0
- package/src/lib/components/input-group/input-group.component.ts +75 -0
- package/src/lib/components/loader/index.ts +1 -0
- package/src/lib/components/loader/loader.component.html +7 -0
- package/src/lib/components/loader/loader.component.scss +0 -0
- package/src/lib/components/loader/loader.component.spec.ts +21 -0
- package/src/lib/components/loader/loader.component.ts +33 -0
- package/src/lib/components/multiselect/index.ts +1 -0
- package/src/lib/components/multiselect/multiselect.component.html +21 -0
- package/src/lib/components/multiselect/multiselect.component.scss +0 -0
- package/src/lib/components/multiselect/multiselect.component.spec.ts +21 -0
- package/src/lib/components/multiselect/multiselect.component.ts +117 -0
- package/src/lib/components/number-input/index.ts +1 -0
- package/src/lib/components/number-input/number-input.component.html +48 -0
- package/src/lib/components/number-input/number-input.component.scss +0 -0
- package/src/lib/components/number-input/number-input.component.ts +80 -0
- package/src/lib/components/page-header/index.ts +1 -0
- package/src/lib/components/page-header/page-header.component.html +3 -0
- package/src/lib/components/page-header/page-header.component.scss +11 -0
- package/src/lib/components/page-header/page-header.component.spec.ts +21 -0
- package/src/lib/components/page-header/page-header.component.ts +27 -0
- package/src/lib/components/password/index.ts +1 -0
- package/src/lib/components/password/password.component.html +31 -0
- package/src/lib/components/password/password.component.scss +0 -0
- package/src/lib/components/password/password.component.spec.ts +21 -0
- package/src/lib/components/password/password.component.ts +83 -0
- package/src/lib/components/radiobutton/index.ts +1 -0
- package/src/lib/components/radiobutton/radiobutton.component.html +23 -0
- package/src/lib/components/radiobutton/radiobutton.component.scss +0 -0
- package/src/lib/components/radiobutton/radiobutton.component.ts +61 -0
- package/src/lib/components/search/index.ts +1 -0
- package/src/lib/components/search/search.component.html +23 -0
- package/src/lib/components/search/search.component.scss +0 -0
- package/src/lib/components/search/search.component.ts +45 -0
- package/src/lib/components/section/index.ts +1 -0
- package/src/lib/components/section/section.component.html +26 -0
- package/src/lib/components/section/section.component.scss +0 -0
- package/src/lib/components/section/section.component.ts +55 -0
- package/src/lib/components/side-menu/index.ts +2 -0
- package/src/lib/components/side-menu/side-menu.component.html +22 -0
- package/src/lib/components/side-menu/side-menu.component.scss +17 -0
- package/src/lib/components/side-menu/side-menu.component.ts +42 -0
- package/src/lib/components/side-menu/side-menu.module.ts +56 -0
- package/src/lib/components/snackbar/index.ts +2 -0
- package/src/lib/components/snackbar/services/snackbar.service.ts +73 -0
- package/src/lib/components/snackbar/snackbar.component.html +14 -0
- package/src/lib/components/snackbar/snackbar.component.scss +0 -0
- package/src/lib/components/snackbar/snackbar.component.spec.ts +21 -0
- package/src/lib/components/snackbar/snackbar.component.ts +44 -0
- package/src/lib/components/snackbar/snackbar.model.ts +10 -0
- package/src/lib/components/stepper/index.ts +1 -0
- package/src/lib/components/stepper/stepper.component.html +35 -0
- package/src/lib/components/stepper/stepper.component.scss +9 -0
- package/src/lib/components/stepper/stepper.component.ts +60 -0
- package/src/lib/components/switch/index.ts +1 -0
- package/src/lib/components/switch/switch.component.html +16 -0
- package/src/lib/components/switch/switch.component.scss +0 -0
- package/src/lib/components/switch/switch.component.ts +39 -0
- package/src/lib/components/tab-view/index.ts +2 -0
- package/src/lib/components/tab-view/tab-view-item.component.ts +23 -0
- package/src/lib/components/tab-view/tab-view.component.html +51 -0
- package/src/lib/components/tab-view/tab-view.component.scss +43 -0
- package/src/lib/components/tab-view/tab-view.component.ts +64 -0
- package/src/lib/components/tab-view/tab-view.module.ts +25 -0
- package/src/lib/components/table/index.ts +1 -0
- package/src/lib/components/table/table-pagination-info.component.html +9 -0
- package/src/lib/components/table/table-pagination-info.component.ts +22 -0
- package/src/lib/components/table/table.component.html +199 -0
- package/src/lib/components/table/table.component.scss +192 -0
- package/src/lib/components/table/table.component.ts +390 -0
- package/src/lib/components/table/table.model.ts +17 -0
- package/src/lib/components/table/table.models.ts +12 -0
- package/src/lib/components/tag/index.ts +3 -0
- package/src/lib/components/tag/tag.component.html +12 -0
- package/src/lib/components/tag/tag.component.scss +4 -0
- package/src/lib/components/tag/tag.component.ts +44 -0
- package/src/lib/components/tag/tag.model.ts +7 -0
- package/src/lib/components/textarea/index.ts +1 -0
- package/src/lib/components/textarea/textarea.component.html +50 -0
- package/src/lib/components/textarea/textarea.component.scss +0 -0
- package/src/lib/components/textarea/textarea.component.ts +77 -0
- package/src/lib/components/textfield/index.ts +1 -0
- package/src/lib/components/textfield/textfield.component.html +34 -0
- package/src/lib/components/textfield/textfield.component.scss +0 -0
- package/src/lib/components/textfield/textfield.component.ts +112 -0
- package/src/lib/components/tooltip/index.ts +1 -0
- package/src/lib/components/tooltip/tooltip.component.html +9 -0
- package/src/lib/components/tooltip/tooltip.component.ts +19 -0
- package/src/lib/icons.ts +36 -0
- package/src/lib/index.ts +5 -0
- package/src/lib/init.service.ts +11 -0
- package/src/lib/interceptors/http-error-message.interceptor.ts +45 -0
- package/src/lib/pages/bad-request-page/bad-request-page.component.html +5 -0
- package/src/lib/pages/bad-request-page/bad-request-page.component.scss +0 -0
- package/src/lib/pages/bad-request-page/bad-request-page.component.ts +14 -0
- package/src/lib/pages/error-page/error-page.component.html +5 -0
- package/src/lib/pages/error-page/error-page.component.scss +0 -0
- package/src/lib/pages/error-page/error-page.component.ts +31 -0
- package/src/lib/pages/error-page/error-page.constants.ts +19 -0
- package/src/lib/pages/index.ts +3 -0
- package/src/lib/pages/internal-server-error-page/internal-server-error-page.component.html +5 -0
- package/src/lib/pages/internal-server-error-page/internal-server-error-page.component.scss +0 -0
- package/src/lib/pages/internal-server-error-page/internal-server-error-page.component.ts +15 -0
- package/src/lib/pages/not-authenticated/index.ts +1 -0
- package/src/lib/pages/not-authenticated/not-authenticated.component.html +5 -0
- package/src/lib/pages/not-authenticated/not-authenticated.component.ts +13 -0
- package/src/lib/pages/not-authorized/index.ts +1 -0
- package/src/lib/pages/not-authorized/not-authorized.component.html +5 -0
- package/src/lib/pages/not-authorized/not-authorized.component.ts +17 -0
- package/src/lib/pages/not-found/index.ts +1 -0
- package/src/lib/pages/not-found/not-found.component.html +5 -0
- package/src/lib/pages/not-found/not-found.component.ts +17 -0
- package/src/lib/pages/not-found-page/not-found-page.component.html +6 -0
- package/src/lib/pages/not-found-page/not-found-page.component.scss +0 -0
- package/src/lib/pages/not-found-page/not-found-page.component.ts +15 -0
- package/src/lib/pipes/color/color.pipe.ts +24 -0
- package/src/lib/pipes/index.ts +3 -0
- package/src/lib/pipes/multiselect/multiselect-options.pipe.ts +61 -0
- package/src/lib/pipes/size/size.pipe.ts +24 -0
- package/src/sass/foundations/_colors.scss +4 -0
- package/src/sass/foundations/index.scss +1 -0
- package/src/sass/integrations/_bootstrap.scss +4 -0
- package/src/sass/integrations/index.scss +1 -0
- package/src/sass/main.scss +12 -0
- package/src/sass/overrides/_gov.scss +4 -0
- package/src/sass/overrides/index.scss +1 -0
- package/src/sass/tokens/_theme-dark.scss +18 -0
- package/src/sass/tokens/_theme-light.scss +9 -0
- package/src/sass/tokens/index.scss +3 -0
- package/src/sass/utils/_table_filter.scss +4 -0
- package/src/sass/utils/index.scss +2 -0
- package/{styles → src}/sass/vendors/_bootstrap.scss +1 -0
- package/src/test-setup.ts +8 -0
- package/tsconfig.json +30 -0
- package/tsconfig.lib.json +17 -0
- package/tsconfig.lib.prod.json +9 -0
- package/tsconfig.spec.json +16 -0
- package/fesm2022/verisoft-ui-govcz.mjs +0 -3582
- package/fesm2022/verisoft-ui-govcz.mjs.map +0 -1
- package/index.d.ts +0 -955
- package/styles/dist/main.css +0 -9
- package/styles/dist/main.css.map +0 -1
- package/styles/sass/main.scss +0 -10
- package/styles/sass/utils/_variables.scss +0 -3
- package/styles/sass/utils/index.scss +0 -2
- /package/{styles → src}/sass/header.css +0 -0
- /package/{styles → src}/sass/header.scss +0 -0
- /package/{styles → src}/sass/scrollbar.scss +0 -0
- /package/{styles → src}/sass/utils/_utils.scss +0 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
<gov-dialog
|
|
2
|
+
[open]="visible"
|
|
3
|
+
[attr.block-close]="data.closable !== undefined ? !data.closable : false"
|
|
4
|
+
[attr.block-backdrop-close]="data.closable !== undefined ? !data.closable : false"
|
|
5
|
+
[style.--dialog-max-width]="data.width"
|
|
6
|
+
[style.--dialog-max-height]="data.height"
|
|
7
|
+
role="dialog"
|
|
8
|
+
accessible-close-label="Close dialog box with more information"
|
|
9
|
+
(gov-close)="data.cancelButtonFn ? dialogClick(false) : (visible = false)"
|
|
10
|
+
>
|
|
11
|
+
<gov-icon
|
|
12
|
+
type="components"
|
|
13
|
+
[name]="data.headerIcon"
|
|
14
|
+
slot="icon"
|
|
15
|
+
[color]="data.severity | govColor"
|
|
16
|
+
/>
|
|
17
|
+
|
|
18
|
+
<h2 slot="title">{{ data.title ?? 'Title' }}</h2>
|
|
19
|
+
|
|
20
|
+
@if (data && data.innerHTML) {
|
|
21
|
+
<div [innerHTML]="data.innerHTML"></div>
|
|
22
|
+
} @else if (data.componentType) {
|
|
23
|
+
<v-dynamic-component
|
|
24
|
+
[componentType]="data.componentType"
|
|
25
|
+
[data]="$any(data.data)"
|
|
26
|
+
></v-dynamic-component>
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
<gov-button
|
|
30
|
+
color="primary"
|
|
31
|
+
size="m"
|
|
32
|
+
type="solid"
|
|
33
|
+
slot="footer"
|
|
34
|
+
(gov-click)="data.confirmButtonFn ? dialogClick(true) : (visible = false)"
|
|
35
|
+
>
|
|
36
|
+
{{ data.confirmButtonText ?? 'Yes'}}
|
|
37
|
+
</gov-button>
|
|
38
|
+
|
|
39
|
+
<gov-button
|
|
40
|
+
[ngClass]="!data.showCancelButton ? 'd-none' : ''"
|
|
41
|
+
color="primary"
|
|
42
|
+
size="m"
|
|
43
|
+
type="outlined"
|
|
44
|
+
slot="footer"
|
|
45
|
+
[disabled]="!data.showCancelButton"
|
|
46
|
+
(gov-click)="data.cancelButtonFn ? dialogClick(false) : (visible = false)"
|
|
47
|
+
>
|
|
48
|
+
{{ data.cancelButtonText ?? 'No' }}
|
|
49
|
+
</gov-button>
|
|
50
|
+
</gov-dialog>
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { CommonModule } from '@angular/common';
|
|
2
|
+
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnInit, inject } from '@angular/core';
|
|
3
|
+
import { GovDesignSystemModule } from '@gov-design-system-ce/angular';
|
|
4
|
+
import {
|
|
5
|
+
CONFIRM_DIALOG_COMPONENT_TOKEN,
|
|
6
|
+
ConfirmDialogCore,
|
|
7
|
+
DialogData,
|
|
8
|
+
DialogService,
|
|
9
|
+
UnsubscribeComponent,
|
|
10
|
+
} from '@verisoft/ui-core';
|
|
11
|
+
import { takeUntil } from 'rxjs';
|
|
12
|
+
import { GovColorPipe } from '../../pipes';
|
|
13
|
+
import { DynamicComponent } from '../shared-components/dynamic-component';
|
|
14
|
+
|
|
15
|
+
@Component({
|
|
16
|
+
selector: 'v-confirm-dialog',
|
|
17
|
+
imports: [
|
|
18
|
+
CommonModule,
|
|
19
|
+
GovDesignSystemModule,
|
|
20
|
+
GovColorPipe,
|
|
21
|
+
DynamicComponent,
|
|
22
|
+
],
|
|
23
|
+
templateUrl: './confirm-dialog.component.html',
|
|
24
|
+
styleUrl: './confirm-dialog.component.scss',
|
|
25
|
+
providers: [
|
|
26
|
+
{
|
|
27
|
+
provide: CONFIRM_DIALOG_COMPONENT_TOKEN,
|
|
28
|
+
useExisting: ConfirmDialogComponent,
|
|
29
|
+
},
|
|
30
|
+
]
|
|
31
|
+
})
|
|
32
|
+
export class ConfirmDialogComponent
|
|
33
|
+
extends UnsubscribeComponent
|
|
34
|
+
implements OnInit, ConfirmDialogCore
|
|
35
|
+
{
|
|
36
|
+
constructor(
|
|
37
|
+
private readonly dialogService: DialogService,
|
|
38
|
+
private readonly cdr: ChangeDetectorRef
|
|
39
|
+
) {
|
|
40
|
+
super();
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
visible = false;
|
|
44
|
+
protected closable = false;
|
|
45
|
+
data: DialogData = { severity: 'primary', headerIcon: 'info-circle' };
|
|
46
|
+
|
|
47
|
+
ngOnInit(): void {
|
|
48
|
+
this.dialogService.showEvent
|
|
49
|
+
.pipe(takeUntil(this.destroyed$))
|
|
50
|
+
.subscribe((x: DialogData) => {
|
|
51
|
+
this.data = x;
|
|
52
|
+
this.visible = true;
|
|
53
|
+
this.cdr.detectChanges();
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
this.dialogService.closeEvent
|
|
57
|
+
.pipe(takeUntil(this.destroyed$))
|
|
58
|
+
.subscribe(() => {
|
|
59
|
+
this.data = {};
|
|
60
|
+
this.visible = false;
|
|
61
|
+
this.cdr.detectChanges();
|
|
62
|
+
})
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
protected dialogClick(confirm: boolean) {
|
|
66
|
+
const { confirmButtonFn, cancelButtonFn } = this.data;
|
|
67
|
+
|
|
68
|
+
if (confirm && confirmButtonFn) {
|
|
69
|
+
confirmButtonFn();
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (!confirm && cancelButtonFn) {
|
|
73
|
+
cancelButtonFn();
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
this.visible = false;
|
|
77
|
+
this.cdr.detectChanges();
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './confirm-dialog.component';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ChangeDetectionStrategy,
|
|
3
|
+
Component,
|
|
4
|
+
Input,
|
|
5
|
+
ViewEncapsulation,
|
|
6
|
+
} from '@angular/core';
|
|
7
|
+
import { DropDownItemData } from './dropdown.model';
|
|
8
|
+
|
|
9
|
+
@Component({
|
|
10
|
+
selector: 'v-dropdown-item',
|
|
11
|
+
standalone: true,
|
|
12
|
+
templateUrl: './dropdown-item.component.html',
|
|
13
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
14
|
+
encapsulation: ViewEncapsulation.None,
|
|
15
|
+
})
|
|
16
|
+
export class DropdownItemComponent<T> {
|
|
17
|
+
@Input() item : DropDownItemData<T> | undefined;
|
|
18
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
<div
|
|
2
|
+
class="v-dropdown mb-3"
|
|
3
|
+
(keydown)="onKeyDown($event)"
|
|
4
|
+
>
|
|
5
|
+
<gov-form-control [disabled]="this.ngControl?.disabled">
|
|
6
|
+
@if (label && !floatLabel) {
|
|
7
|
+
<gov-form-label
|
|
8
|
+
slot="top"
|
|
9
|
+
[ngClass]="labelClasses"
|
|
10
|
+
>
|
|
11
|
+
<span [ngClass]="labelClasses">
|
|
12
|
+
{{ label | translate }}
|
|
13
|
+
@if (tooltip) {
|
|
14
|
+
<v-tooltip [message]="tooltip | translate" />
|
|
15
|
+
}
|
|
16
|
+
</span>
|
|
17
|
+
</gov-form-label>
|
|
18
|
+
}
|
|
19
|
+
<div
|
|
20
|
+
class="gov-form-input"
|
|
21
|
+
[ngStyle]="forceMinWidth ? {'min-width': '16rem'} : {}"
|
|
22
|
+
[ngClass]="inputClasses"
|
|
23
|
+
>
|
|
24
|
+
<div
|
|
25
|
+
class="element d-flex gov-form-input-child"
|
|
26
|
+
[ngClass]="labelClasses"
|
|
27
|
+
(click)="toggleDropdown()"
|
|
28
|
+
>
|
|
29
|
+
<div class="v-dropdown__value flex-grow-1 me-1">{{ selectedItem?.label ?? placeholder }}</div>
|
|
30
|
+
@if (clearable && ngControl?.enabled && selectedItem !== undefined && selectedItem !== null) {
|
|
31
|
+
<gov-icon
|
|
32
|
+
[name]="icons.cross"
|
|
33
|
+
size="m"
|
|
34
|
+
class="v-dropdown__clear me-1"
|
|
35
|
+
color="error"
|
|
36
|
+
(click)="clearSelection($event)"
|
|
37
|
+
/>
|
|
38
|
+
}
|
|
39
|
+
@if (loading) {
|
|
40
|
+
<div class="v-dropdown__loader">
|
|
41
|
+
<gov-icon [name]="icons.loader" />
|
|
42
|
+
</div>
|
|
43
|
+
}
|
|
44
|
+
<div class="v-dropdown__trigger">
|
|
45
|
+
<gov-icon [name]="opened ? icons.chevronUp : icons.chevronDown" />
|
|
46
|
+
</div>
|
|
47
|
+
</div>
|
|
48
|
+
</div>
|
|
49
|
+
<div class="position-relative">
|
|
50
|
+
@if (opened) {
|
|
51
|
+
<div class="v-dropdown__container">
|
|
52
|
+
@if (showFilter) {
|
|
53
|
+
<div
|
|
54
|
+
class="v-dropdown__filter"
|
|
55
|
+
#filterTextField
|
|
56
|
+
(keydown)="onKeyDown($event)"
|
|
57
|
+
>
|
|
58
|
+
<v-textfield
|
|
59
|
+
placeholder="Search"
|
|
60
|
+
[formControl]="filterControl"
|
|
61
|
+
iconPos="right"
|
|
62
|
+
[icon]="icons.search"
|
|
63
|
+
/>
|
|
64
|
+
</div>
|
|
65
|
+
}
|
|
66
|
+
@if (!dropdownOptions?.length) {
|
|
67
|
+
<div class="v-dropdown__no-item">No option was found.</div>
|
|
68
|
+
} @else {
|
|
69
|
+
<ul
|
|
70
|
+
role="listbox"
|
|
71
|
+
class="v-dropdown__list"
|
|
72
|
+
>
|
|
73
|
+
<cdk-virtual-scroll-viewport
|
|
74
|
+
[itemSize]="30"
|
|
75
|
+
class="v-dropdown__scroll"
|
|
76
|
+
(scrolledIndexChange)="onScroll($event)"
|
|
77
|
+
>
|
|
78
|
+
<v-dropdown-item
|
|
79
|
+
*cdkVirtualFor="let option of dropdownOptions;"
|
|
80
|
+
[item]="option"
|
|
81
|
+
(click)="selectItem(option, true)"
|
|
82
|
+
/>
|
|
83
|
+
</cdk-virtual-scroll-viewport>
|
|
84
|
+
</ul>
|
|
85
|
+
}
|
|
86
|
+
</div>
|
|
87
|
+
}
|
|
88
|
+
</div>
|
|
89
|
+
<v-validation-message [ngControl]="ngControl" />
|
|
90
|
+
</gov-form-control>
|
|
91
|
+
</div>
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
.v-dropdown__container {
|
|
2
|
+
position: absolute;
|
|
3
|
+
z-index: 100;
|
|
4
|
+
background-color: var(--button-outlined-primary-hover);
|
|
5
|
+
min-width: 100%;
|
|
6
|
+
border-radius: var(--border-radius, var(--corner-radius-s));
|
|
7
|
+
border: var(--border-width, 0.0625rem) solid var(--form-border-color, var(--border-neutral));
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.v-dropdown__trigger {
|
|
11
|
+
min-height: 1.5rem;
|
|
12
|
+
display: flex;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.disabled {
|
|
16
|
+
color: var(--form-state-value-disabled, var(--text-disabled));
|
|
17
|
+
cursor: default !important;
|
|
18
|
+
pointer-events: none;
|
|
19
|
+
|
|
20
|
+
&-input {
|
|
21
|
+
border-color: var(--form-state-border-disabled, var(--border-subtlest)) !important;
|
|
22
|
+
background: var(--form-state-bg-disabled, transparent);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.error {
|
|
27
|
+
color: var(--form-state-label-error, var(--text-status-error));
|
|
28
|
+
|
|
29
|
+
&-input {
|
|
30
|
+
border-color: var(--form-state-border-error, var(--status-error)) !important;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.gov-form-input-child {
|
|
35
|
+
padding: 0.5rem 0.75rem;
|
|
36
|
+
border: 0px !important;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.v-dropdown__no-item {
|
|
40
|
+
padding: 0.5rem;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.v-dropdown__list {
|
|
44
|
+
margin: 0;
|
|
45
|
+
padding: 0;
|
|
46
|
+
list-style-type: none;
|
|
47
|
+
display: flex;
|
|
48
|
+
flex-direction: column;
|
|
49
|
+
overflow: auto;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.v-dropdown__scroll {
|
|
53
|
+
height: 10rem;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.v-dropdown__filter {
|
|
57
|
+
padding: 0.5rem;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.v-dropdown__item {
|
|
61
|
+
padding: 0.25rem 0.5rem;
|
|
62
|
+
cursor: pointer;
|
|
63
|
+
|
|
64
|
+
&.is-active {
|
|
65
|
+
background-color: var(--background-primary);
|
|
66
|
+
color: var(--text-white);
|
|
67
|
+
|
|
68
|
+
&:hover {
|
|
69
|
+
opacity: 0.8;
|
|
70
|
+
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
&:hover {
|
|
75
|
+
background-color: var(--background-primary);
|
|
76
|
+
;
|
|
77
|
+
color: var(--text-white);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.v-dropdown__loader {
|
|
82
|
+
width: 1.5rem;
|
|
83
|
+
height: 1.5rem;
|
|
84
|
+
margin-right: 1rem;
|
|
85
|
+
animation: rotate 1s linear infinite;
|
|
86
|
+
display: inline-block;
|
|
87
|
+
transform-origin: center;
|
|
88
|
+
color: var(--color-neutral-300)
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.v-dropdown__clear {
|
|
92
|
+
z-index: 99;
|
|
93
|
+
cursor: pointer;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
@keyframes rotate {
|
|
97
|
+
from {
|
|
98
|
+
transform: rotate(0deg);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
to {
|
|
102
|
+
transform: rotate(360deg);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
::ng-deep .cdk-virtual-scrollable {
|
|
107
|
+
contain: none;
|
|
108
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
+
import { MultiselectComponent } from './gov-multiselect.component';
|
|
3
|
+
|
|
4
|
+
describe('MultiselectComponent', () => {
|
|
5
|
+
let component: MultiselectComponent<any>;
|
|
6
|
+
let fixture: ComponentFixture<MultiselectComponent<any>>;
|
|
7
|
+
|
|
8
|
+
beforeEach(async () => {
|
|
9
|
+
await TestBed.configureTestingModule({
|
|
10
|
+
imports: [MultiselectComponent],
|
|
11
|
+
}).compileComponents();
|
|
12
|
+
|
|
13
|
+
fixture = TestBed.createComponent(MultiselectComponent);
|
|
14
|
+
component = fixture.componentInstance;
|
|
15
|
+
fixture.detectChanges();
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('should create', () => {
|
|
19
|
+
expect(component).toBeTruthy();
|
|
20
|
+
});
|
|
21
|
+
});
|
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
import { ScrollingModule } from '@angular/cdk/scrolling';
|
|
2
|
+
import { CommonModule } from '@angular/common';
|
|
3
|
+
import {
|
|
4
|
+
ChangeDetectionStrategy,
|
|
5
|
+
ChangeDetectorRef,
|
|
6
|
+
Component,
|
|
7
|
+
ElementRef,
|
|
8
|
+
EventEmitter,
|
|
9
|
+
HostListener,
|
|
10
|
+
Input,
|
|
11
|
+
NO_ERRORS_SCHEMA,
|
|
12
|
+
OnChanges,
|
|
13
|
+
OnDestroy,
|
|
14
|
+
OnInit,
|
|
15
|
+
Optional,
|
|
16
|
+
Output,
|
|
17
|
+
Self,
|
|
18
|
+
SimpleChanges,
|
|
19
|
+
ViewChild,
|
|
20
|
+
ViewEncapsulation,
|
|
21
|
+
} from '@angular/core';
|
|
22
|
+
import {
|
|
23
|
+
ControlValueAccessor,
|
|
24
|
+
FormControl,
|
|
25
|
+
NgControl,
|
|
26
|
+
ReactiveFormsModule,
|
|
27
|
+
} from '@angular/forms';
|
|
28
|
+
import { GovDesignSystemModule } from '@gov-design-system-ce/angular';
|
|
29
|
+
import { TranslateModule } from '@ngx-translate/core';
|
|
30
|
+
import { DEFAULT_PAGE_SIZE, FilterEvent, getValueByPath, LazyLoadEvent } from '@verisoft/core';
|
|
31
|
+
import {
|
|
32
|
+
BaseFormInputComponent,
|
|
33
|
+
DropdownCore,
|
|
34
|
+
DROPDOWN_COMPONENT_TOKEN,
|
|
35
|
+
FieldSizeType,
|
|
36
|
+
FieldSize,
|
|
37
|
+
} from '@verisoft/ui-core';
|
|
38
|
+
import { debounceTime, distinctUntilChanged, Subscription } from 'rxjs';
|
|
39
|
+
import { Icons } from '../../icons';
|
|
40
|
+
import { ErrorComponent } from '../errors';
|
|
41
|
+
import { TextfieldComponent } from '../textfield';
|
|
42
|
+
import { DropdownItemComponent } from './dropdown-item.component';
|
|
43
|
+
import { DropDownItemData } from './dropdown.model';
|
|
44
|
+
|
|
45
|
+
@Component({
|
|
46
|
+
selector: 'v-dropdown',
|
|
47
|
+
imports: [
|
|
48
|
+
CommonModule,
|
|
49
|
+
ReactiveFormsModule,
|
|
50
|
+
GovDesignSystemModule,
|
|
51
|
+
ErrorComponent,
|
|
52
|
+
DropdownItemComponent,
|
|
53
|
+
TextfieldComponent,
|
|
54
|
+
ScrollingModule,
|
|
55
|
+
TranslateModule,
|
|
56
|
+
],
|
|
57
|
+
templateUrl: './dropdown.component.html',
|
|
58
|
+
styleUrl: './dropdown.component.scss',
|
|
59
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
60
|
+
encapsulation: ViewEncapsulation.None,
|
|
61
|
+
providers: [
|
|
62
|
+
{
|
|
63
|
+
provide: DROPDOWN_COMPONENT_TOKEN,
|
|
64
|
+
useExisting: DropdownComponent,
|
|
65
|
+
},
|
|
66
|
+
],
|
|
67
|
+
schemas: [
|
|
68
|
+
NO_ERRORS_SCHEMA
|
|
69
|
+
]
|
|
70
|
+
})
|
|
71
|
+
export class DropdownComponent<T>
|
|
72
|
+
extends BaseFormInputComponent
|
|
73
|
+
implements ControlValueAccessor, DropdownCore<T>, OnInit, OnChanges, OnDestroy {
|
|
74
|
+
|
|
75
|
+
@ViewChild('filterTextField', { static: false }) filterTextField!: ElementRef;
|
|
76
|
+
|
|
77
|
+
@Input() options: T[] | undefined = [];
|
|
78
|
+
@Input() optionLabel: string | undefined;
|
|
79
|
+
@Input() optionValue: string | undefined;
|
|
80
|
+
@Input() dropdownIcon: string | undefined;
|
|
81
|
+
@Input() floatLabel: string | undefined;
|
|
82
|
+
@Input() lazy!: boolean;
|
|
83
|
+
@Input() filter!: boolean;
|
|
84
|
+
@Input() editable!: boolean;
|
|
85
|
+
@Input() loading!: boolean;
|
|
86
|
+
@Input() size: FieldSizeType = FieldSize.medium;
|
|
87
|
+
@Input() showFilter = true;
|
|
88
|
+
@Input() localSearch = true;
|
|
89
|
+
@Input() forceMinWidth = false;
|
|
90
|
+
|
|
91
|
+
@Output() changed = new EventEmitter<any>();
|
|
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
|
+
opened = false;
|
|
98
|
+
icons = Icons;
|
|
99
|
+
selectedItem: DropDownItemData<T> | undefined;
|
|
100
|
+
filterControl = new FormControl('');
|
|
101
|
+
filterSub: Subscription | undefined
|
|
102
|
+
dropdownOptions: DropDownItemData<T>[] | undefined;
|
|
103
|
+
private readonly pageSize = DEFAULT_PAGE_SIZE;
|
|
104
|
+
private lastPage: number | undefined;
|
|
105
|
+
|
|
106
|
+
get labelClasses() {
|
|
107
|
+
return {
|
|
108
|
+
disabled: this.ngControl?.disabled,
|
|
109
|
+
error: this.ngControl?.invalid
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
get inputClasses() {
|
|
114
|
+
return {
|
|
115
|
+
'disabled-input': this.ngControl?.disabled,
|
|
116
|
+
'error-input': this.ngControl?.invalid
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
constructor(@Optional() @Self() ngControl: NgControl,
|
|
121
|
+
private changeDetectorRef: ChangeDetectorRef) {
|
|
122
|
+
super(ngControl);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
override ngOnInit() {
|
|
126
|
+
super.ngOnInit();
|
|
127
|
+
this.filterSub = this.filterControl.valueChanges.pipe(
|
|
128
|
+
debounceTime(300),
|
|
129
|
+
distinctUntilChanged()
|
|
130
|
+
).subscribe((value) => {
|
|
131
|
+
this.filterOptions(value);
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
override writeValue(value: any): void {
|
|
136
|
+
const selectedItem = (value == undefined || value === "") ? undefined : (this.dropdownOptions?.find(x => x.value === value)
|
|
137
|
+
?? { value, label: '', option: undefined as T, selected: false } as unknown as DropDownItemData<T>)
|
|
138
|
+
this.selectItem(selectedItem, false);
|
|
139
|
+
|
|
140
|
+
this.changeDetectorRef.detectChanges();
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
ngOnChanges(changes: SimpleChanges) {
|
|
144
|
+
if (changes['options'] || changes['loading']) {
|
|
145
|
+
this.dropdownOptions = this.convertToOptions();
|
|
146
|
+
if (this.selectedItem && !this.selectedItem?.item) {
|
|
147
|
+
const item = this.dropdownOptions?.find(x => this.selectedItem?.value === x.value);
|
|
148
|
+
if (item) {
|
|
149
|
+
this.selectItem(item, false);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
this.changeDetectorRef.detectChanges();
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
private convertToOptions(): DropDownItemData<T>[] | undefined {
|
|
158
|
+
return this.options?.map((option) => ({
|
|
159
|
+
label: (this.optionLabel ? getValueByPath(option, this.optionLabel) : option) as unknown as string,
|
|
160
|
+
value: this.optionValue ? getValueByPath(option, this.optionValue) : option as unknown as string,
|
|
161
|
+
item: option,
|
|
162
|
+
selected: false,
|
|
163
|
+
} as DropDownItemData<T>)
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
ngOnDestroy() {
|
|
168
|
+
this.filterSub?.unsubscribe();
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
toggleDropdown() {
|
|
172
|
+
if (this.ngControl?.disabled) {
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
if (!this.opened) {
|
|
177
|
+
this.openDropdown();
|
|
178
|
+
} else {
|
|
179
|
+
this.closeDropdown();
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
protected clearSelection(event: MouseEvent) {
|
|
184
|
+
event.stopPropagation();
|
|
185
|
+
this.changed.emit(null);
|
|
186
|
+
this.dropdownOptions = this.dropdownOptions?.map(x => ({ ...x, selected: false })) ?? [];
|
|
187
|
+
this.ngControl?.control?.setValue(null);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
private openDropdown() {
|
|
191
|
+
this.opened = true;
|
|
192
|
+
this.setFilterFocus();
|
|
193
|
+
this.showed.emit();
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
selectItem(option: DropDownItemData<T> | undefined, emitChange: boolean) {
|
|
197
|
+
if (option == undefined) {
|
|
198
|
+
this.selectedItem = undefined;
|
|
199
|
+
this.closeDropdown();
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
if (this.selectedItem && this.selectedItem != option) {
|
|
204
|
+
this.selectedItem.selected = false;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
option.selected = true;
|
|
208
|
+
this.selectedItem = option;
|
|
209
|
+
|
|
210
|
+
if (emitChange) {
|
|
211
|
+
if (this.ngControl?.control?.value !== option.value) {
|
|
212
|
+
this.changed.emit(option.value);
|
|
213
|
+
this.ngControl?.control?.setValue(option?.value);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
this.closeDropdown();
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
@HostListener('document:click', ['$event'])
|
|
221
|
+
onDocumentClick(event: MouseEvent) {
|
|
222
|
+
const target = event.target as HTMLElement;
|
|
223
|
+
if (!target.closest('v-dropdown')) {
|
|
224
|
+
this.opened = false;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
onScroll(index: number) {
|
|
229
|
+
this.loadDataForIndex(index);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
onKeyDown(event: KeyboardEvent) {
|
|
233
|
+
if (this.formControl.disabled || this.readonly || this.loading || !this.opened) {
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
switch (event.code) {
|
|
238
|
+
case 'ArrowDown':
|
|
239
|
+
break;
|
|
240
|
+
|
|
241
|
+
case 'ArrowUp':
|
|
242
|
+
break;
|
|
243
|
+
|
|
244
|
+
case 'ArrowLeft':
|
|
245
|
+
case 'ArrowRight':
|
|
246
|
+
break;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
private loadDataForIndex(index: number) {
|
|
251
|
+
if (this.lazy) {
|
|
252
|
+
const currentPage = Math.floor(index / this.pageSize);
|
|
253
|
+
const shouldLazyLoad = currentPage !== this.lastPage;
|
|
254
|
+
if (shouldLazyLoad) {
|
|
255
|
+
this.lastPage = currentPage;
|
|
256
|
+
this.lazyLoad.emit({
|
|
257
|
+
filter: this.createFilterObject(this.filterControl.value),
|
|
258
|
+
offset: currentPage * this.pageSize,
|
|
259
|
+
limit: this.pageSize,
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
private setFilterFocus() {
|
|
266
|
+
setTimeout(() => {
|
|
267
|
+
this.filterTextField?.nativeElement?.querySelector("input").focus();
|
|
268
|
+
}, 200);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
private closeDropdown() {
|
|
272
|
+
this.opened = false;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
private filterOptions(value: string | null) {
|
|
276
|
+
if (!this.localSearch) {
|
|
277
|
+
this.filtered.emit({
|
|
278
|
+
filter: !value ? undefined : value,
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
if (this.lazy) {
|
|
283
|
+
this.loadDataForIndex(0);
|
|
284
|
+
} else {
|
|
285
|
+
const loweredFilterValue = value?.toLocaleLowerCase();
|
|
286
|
+
this.dropdownOptions = !loweredFilterValue ?
|
|
287
|
+
this.convertToOptions()
|
|
288
|
+
: this.convertToOptions()?.filter(x => x.label?.toLocaleLowerCase()?.indexOf(loweredFilterValue) !== -1);
|
|
289
|
+
this.changeDetectorRef.detectChanges();
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
private createFilterObject(filterValue: string | null): Partial<T> {
|
|
294
|
+
return (this.optionLabel ? { [this.optionLabel]: filterValue } : filterValue) as unknown as Partial<T>
|
|
295
|
+
}
|
|
296
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './dropdown.component';
|